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

Method sectionOverhead

src/mcp/tools.ts:4370–4382  ·  view source on GitHub ↗
(filePath: string, nodes: readonly Node[])

Source from the content-addressed store, hash-verified

4368 */
4369 const overheadCache = new Map<string, number>();
4370 const sectionOverhead = (filePath: string, nodes: readonly Node[]): number => {
4371 const hit = overheadCache.get(filePath);
4372 if (hit !== undefined) return hit;
4373 const names = [...new Set(
4374 nodes.filter((n) => n.kind !== 'import' && n.kind !== 'export')
4375 .map((n) => `${n.name}(${n.kind})`),
4376 )].slice(0, budget.maxSymbolsInFileHeader);
4377 // header + blank, then ```lang / body / ``` / blank around the source.
4378 const cost = fileSectionHeader(filePath, names.join(', ')).length + 2
4379 + (nodes[0]?.language?.length ?? 0) + 11;
4380 overheadCache.set(filePath, cost);
4381 return cost;
4382 };
4383 /**
4384 * How much of what is still owed BELOW `fileIndex` the response can actually
4385 * still PAY, in render-space chars (CG-31).

Callers

nothing calls this directly

Calls 4

fileSectionHeaderFunction · 0.85
getMethod · 0.65
joinMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected