MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolveOne

Method resolveOne

src/mcp/tools.ts:8437–8450  ·  view source on GitHub ↗
(want: string)

Source from the content-addressed store, hash-verified

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

Callers 2

answersFunction · 0.45

Calls 1

normalizeFunction · 0.50

Tested by 1

answersFunction · 0.36