MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / renderMapPretty

Function renderMapPretty

src/core/codebase-map.ts:584–679  ·  view source on GitHub ↗
(map: CodebaseMapSummary)

Source from the content-addressed store, hash-verified

582
583/** Render a `CodebaseMapSummary` to terminal-friendly box output. */
584export function renderMapPretty(map: CodebaseMapSummary): string {
585 const ascii = process.env.CODEBASE_CONTEXT_ASCII === '1';
586 const h = ascii ? '-' : '─';
587 const v = ascii ? '|' : '│';
588 const tl = ascii ? '+' : '┌';
589 const tr = ascii ? '+' : '┐';
590 const bl = ascii ? '+' : '└';
591 const br = ascii ? '+' : '┘';
592 const lm = ascii ? '+' : '├';
593 const rm = ascii ? '+' : '┤';
594
595 const width = 60;
596 const inner = width - 2;
597
598 function box(title: string, lines: string[]): string {
599 const top = `${tl}${h.repeat(inner)}${tr}`;
600 const mid = `${lm}${h.repeat(inner)}${rm}`;
601 const bot = `${bl}${h.repeat(inner)}${br}`;
602 const titleLine = `${v} ${title.padEnd(inner - 1)}${v}`;
603 const contentLines = lines.map((l) => {
604 const truncated = l.length > inner - 2 ? l.slice(0, inner - 5) + '...' : l;
605 return `${v} ${truncated.padEnd(inner - 2)}${v}`;
606 });
607 return [top, titleLine, mid, ...contentLines, bot].join('\n');
608 }
609
610 const sections: string[] = [];
611
612 sections.push(box(`Codebase Map — ${map.project}`, []));
613
614 const layerLines =
615 map.architecture.layers.length === 0
616 ? ['(none)']
617 : map.architecture.layers.map((l) =>
618 l.hubFile
619 ? `${l.name} ${l.fileCount} files [${l.hubFile}]`
620 : `${l.name} ${l.fileCount} files`
621 );
622 sections.push(box('Architecture Layers', layerLines));
623
624 const epLines =
625 map.architecture.entrypoints.length === 0 ? ['(none detected)'] : map.architecture.entrypoints;
626 sections.push(box('Entrypoints', epLines));
627
628 const hubLines =
629 map.architecture.hubFiles.length === 0 ? ['(none detected)'] : map.architecture.hubFiles;
630 sections.push(box('Hub Files', hubLines));
631
632 const kiLines =
633 map.architecture.keyInterfaces.length === 0
634 ? ['(none detected)']
635 : map.architecture.keyInterfaces.map(
636 (ki) => `${ki.name} ${ki.kind} ${ki.file} (×${ki.importerCount})`
637 );
638 sections.push(box('Key Interfaces', kiLines));
639
640 const apiLines =
641 map.architecture.apiSurface.length === 0

Callers 2

handleMapCliFunction · 0.85

Calls 1

boxFunction · 0.85

Tested by

no test coverage detected