MCPcopy Create free account
hub / github.com/backnotprop/plannotator / score

Function score

packages/shared/code-nav.ts:291–304  ·  view source on GitHub ↗
(loc: CodeNavLocation)

Source from the content-addressed store, hash-verified

289 const changedSet = new Set(context.changedFiles);
290
291 function score(loc: CodeNavLocation): number {
292 let s = 0;
293
294 if (loc.filePath === context.sourceFilePath) s += 1000;
295 else if (changedSet.has(loc.filePath)) s += 500;
296 else if (sameDirectory(loc.filePath, context.sourceFilePath)) s += 200;
297
298 if (isTestFile(loc.filePath) && !context.isTestFile) s -= 300;
299
300 if (loc.kind === "definition") s += 100;
301 if (loc.confidence === "likely") s += 50;
302
303 return s;
304 }
305
306 const sorted = [...locations].sort((a, b) => score(b) - score(a));
307 const truncated = sorted.slice(0, cap);

Callers 1

rankLocationsFunction · 0.85

Calls 3

sameDirectoryFunction · 0.85
isTestFileFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected