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

Method resolveOne

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

Source from the content-addressed store, hash-verified

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

Callers 2

answersFunction · 0.45

Calls 1

normalizeFunction · 0.50

Tested by 1

answersFunction · 0.36