| 8435 | // suffix-of-path, then substring — narrowing to a single file or handing |
| 8436 | // back the ambiguous set. |
| 8437 | const resolveOne = (want: string): { file?: (typeof allFiles)[number]; candidates: typeof allFiles } => { |
| 8438 | const wantLower = normalize(want).toLowerCase(); |
| 8439 | let file = allFiles.find((f) => f.path.toLowerCase() === wantLower); |
| 8440 | let found: typeof allFiles = []; |
| 8441 | if (!file) { |
| 8442 | found = allFiles.filter((f) => f.path.toLowerCase().endsWith('/' + wantLower)); |
| 8443 | if (found.length === 1) file = found[0]; |
| 8444 | } |
| 8445 | if (!file && found.length === 0) { |
| 8446 | found = allFiles.filter((f) => f.path.toLowerCase().includes(wantLower)); |
| 8447 | if (found.length === 1) file = found[0]; |
| 8448 | } |
| 8449 | return { file, candidates: found }; |
| 8450 | }; |
| 8451 | |
| 8452 | // Agents and humans paste file references WITH a line suffix — `a.ts:12`, |
| 8453 | // `a.ts:12-40`, `a.ts#L88`, `a.ts#L12-L40`. explore already strips exactly |