| 8684 | // suffix-of-path, then substring — narrowing to a single file or handing |
| 8685 | // back the ambiguous set. |
| 8686 | const resolveOne = (want: string): { file?: (typeof allFiles)[number]; candidates: typeof allFiles } => { |
| 8687 | const wantLower = normalize(want).toLowerCase(); |
| 8688 | let file = allFiles.find((f) => f.path.toLowerCase() === wantLower); |
| 8689 | let found: typeof allFiles = []; |
| 8690 | if (!file) { |
| 8691 | found = allFiles.filter((f) => f.path.toLowerCase().endsWith('/' + wantLower)); |
| 8692 | if (found.length === 1) file = found[0]; |
| 8693 | } |
| 8694 | if (!file && found.length === 0) { |
| 8695 | found = allFiles.filter((f) => f.path.toLowerCase().includes(wantLower)); |
| 8696 | if (found.length === 1) file = found[0]; |
| 8697 | } |
| 8698 | return { file, candidates: found }; |
| 8699 | }; |
| 8700 | |
| 8701 | // Agents and humans paste file references WITH a line suffix — `a.ts:12`, |
| 8702 | // `a.ts:12-40`, `a.ts#L88`, `a.ts#L12-L40`. explore already strips exactly |