MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / scoreFileTokens

Function scoreFileTokens

packages/code-map/src/parse.ts:264–278  ·  view source on GitHub ↗
(fullPath: string, parsed: ParsedTokens)

Source from the content-addressed store, hash-verified

262}
263
264function scoreFileTokens(fullPath: string, parsed: ParsedTokens): FileCallData {
265 const scores: Record<string, number> = {}
266 const dirs = path.dirname(fullPath).split(path.sep)
267 const depth = dirs.length
268 const tokenBaseScore =
269 0.8 ** depth * Math.sqrt(parsed.numLines / (parsed.identifiers.length + 1))
270
271 for (const identifier of parsed.identifiers) {
272 if (!IGNORE_TOKENS.includes(identifier)) {
273 scores[identifier] = tokenBaseScore
274 }
275 }
276
277 return { scores, calls: parsed.calls }
278}
279
280function buildTokenCallers(
281 tokenScores: Record<string, Record<string, number>>,

Callers 1

getFileTokenScoresFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected