| 8266 | // suffix-of-path, then substring — narrowing to a single file or handing |
| 8267 | // back the ambiguous set. |
| 8268 | const resolveOne = (want: string): { file?: (typeof allFiles)[number]; candidates: typeof allFiles } => { |
| 8269 | const wantLower = normalize(want).toLowerCase(); |
| 8270 | let file = allFiles.find((f) => f.path.toLowerCase() === wantLower); |
| 8271 | let found: typeof allFiles = []; |
| 8272 | if (!file) { |
| 8273 | found = allFiles.filter((f) => f.path.toLowerCase().endsWith('/' + wantLower)); |
| 8274 | if (found.length === 1) file = found[0]; |
| 8275 | } |
| 8276 | if (!file && found.length === 0) { |
| 8277 | found = allFiles.filter((f) => f.path.toLowerCase().includes(wantLower)); |
| 8278 | if (found.length === 1) file = found[0]; |
| 8279 | } |
| 8280 | return { file, candidates: found }; |
| 8281 | }; |
| 8282 | |
| 8283 | // Agents and humans paste file references WITH a line suffix — `a.ts:12`, |
| 8284 | // `a.ts:12-40`, `a.ts#L88`, `a.ts#L12-L40`. explore already strips exactly |