| 178 | const staged = definitions.map((d) => ({ ...d })); |
| 179 | |
| 180 | const applyFactory = (items: typeof staged, factory: (d: (typeof staged)[number]) => string) => { |
| 181 | const byPath = new Map<string, typeof staged>(); |
| 182 | for (const item of items) { |
| 183 | const bucket = byPath.get(item.toolPath) ?? []; |
| 184 | bucket.push(item); |
| 185 | byPath.set(item.toolPath, bucket); |
| 186 | } |
| 187 | for (const bucket of byPath.values()) { |
| 188 | if (bucket.length < 2) continue; |
| 189 | for (const d of bucket) { |
| 190 | d.toolPath = factory(d); |
| 191 | } |
| 192 | } |
| 193 | }; |
| 194 | |
| 195 | // Round 1: add version segment |
| 196 | applyFactory(staged, (d) => |