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

Function numberSourceLines

src/mcp/tools.ts:363–370  ·  view source on GitHub ↗

* Prefix each line of a source slice with its 1-based line number, matching * the Read tool's `cat -n` convention (number + tab) so the agent treats it * the same way it treats Read output. * * @param slice contiguous source text (already extracted from the file) * @param firstLineNumber the

(slice: string, firstLineNumber: number)

Source from the content-addressed store, hash-verified

361 * @param firstLineNumber the 1-based line number of the slice's first line
362 */
363function numberSourceLines(slice: string, firstLineNumber: number): string {
364 const out: string[] = [];
365 const split = slice.split('\n');
366 for (let i = 0; i < split.length; i++) {
367 out.push(`${firstLineNumber + i}\t${split[i]}`);
368 }
369 return out.join('\n');
370}
371
372/**
373 * Unique line-prefix for a per-file source section in codegraph_explore output.

Callers 4

handleExploreMethod · 0.85
buildSectionMethod · 0.85
formatNodeDetailsMethod · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected