| 8413 | // suffix-of-path, then substring — narrowing to a single file or handing |
| 8414 | // back the ambiguous set. |
| 8415 | const resolveOne = (want: string): { file?: (typeof allFiles)[number]; candidates: typeof allFiles } => { |
| 8416 | const wantLower = normalize(want).toLowerCase(); |
| 8417 | let file = allFiles.find((f) => f.path.toLowerCase() === wantLower); |
| 8418 | let found: typeof allFiles = []; |
| 8419 | if (!file) { |
| 8420 | found = allFiles.filter((f) => f.path.toLowerCase().endsWith('/' + wantLower)); |
| 8421 | if (found.length === 1) file = found[0]; |
| 8422 | } |
| 8423 | if (!file && found.length === 0) { |
| 8424 | found = allFiles.filter((f) => f.path.toLowerCase().includes(wantLower)); |
| 8425 | if (found.length === 1) file = found[0]; |
| 8426 | } |
| 8427 | return { file, candidates: found }; |
| 8428 | }; |
| 8429 | |
| 8430 | // Agents and humans paste file references WITH a line suffix — `a.ts:12`, |
| 8431 | // `a.ts:12-40`, `a.ts#L88`, `a.ts#L12-L40`. explore already strips exactly |