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

Function attributeSourceBytes

src/mcp/explore-diagnostics.ts:653–689  ·  view source on GitHub ↗
(finalText: string)

Source from the content-addressed store, hash-verified

651 * arrives as `42\t```` and cannot close the block early.
652 */
653export function attributeSourceBytes(finalText: string): Map<string, number> {
654 const out = new Map<string, number>();
655 if (!finalText) return out;
656 const lines = finalText.split('\n');
657 let current: string | null = null;
658 let inFence = false;
659 let acc: string[] = [];
660 const flush = () => {
661 if (current && acc.length > 0) {
662 out.set(current, (out.get(current) ?? 0) + acc.join('\n').length);
663 }
664 acc = [];
665 };
666 for (const line of lines) {
667 if (!inFence) {
668 const header = /^\*\*`([^`]+)`\*\*/.exec(line);
669 if (header) {
670 current = header[1]!;
671 continue;
672 }
673 if (current && line.startsWith('```')) {
674 inFence = true;
675 continue;
676 }
677 continue;
678 }
679 if (line === '```') {
680 inFence = false;
681 flush();
682 continue;
683 }
684 acc.push(line);
685 }
686 // Unterminated fence (final-ceiling truncation cut mid-block): count it.
687 if (inFence) flush();
688 return out;
689}
690
691/** Human-readable stderr rendering of the JSON report. */
692export function renderTable(report: ExploreDiagnosticReport): string {

Callers 9

exploreFunction · 0.90
exploreFunction · 0.90
runFunction · 0.90
finishMethod · 0.85

Calls 3

pushMethod · 0.80
flushFunction · 0.70
execMethod · 0.65

Tested by 3

exploreFunction · 0.72
exploreFunction · 0.72
runFunction · 0.72