MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / repositoryMap

Function repositoryMap

graph-ui/src/architecture/repository-map.ts:61–109  ·  view source on GitHub ↗
(graph: GraphData)

Source from the content-addressed store, hash-verified

59
60/** Linear in the already loaded graph. Every aggregate retains its real edges. */
61export function repositoryMap(graph: GraphData): RepositoryMap {
62 const areas = new Map<string, RepositoryArea>();
63 const nodes = new Map(graph.nodes.filter(isSource).map(node => [node.id, node]));
64 const files = new Map<string, Set<string>>();
65 for (const node of nodes.values()) {
66 const path = areaOf(node.file_path!);
67 let area = areas.get(path);
68 if (!area) {
69 area = { path, files: [], nodes: [], entryPoints: [], interfaces: [], incoming: [], outgoing: [] };
70 areas.set(path, area); files.set(path, new Set());
71 }
72 files.get(path)!.add(node.file_path!);
73 area.nodes.push(node);
74 if (node.status === 'entry') area.entryPoints.push(node);
75 if (node.status === 'exported') area.interfaces.push(node);
76 }
77 const evidence: MapEvidence[] = [];
78 const seen = new Set<string>();
79 let unresolvedEdges = 0;
80 for (const edge of graph.edges) {
81 if (!MAP_RELATIONS.includes(edge.type as MapRelation)) continue;
82 const key = `${edge.source}:${edge.type}:${edge.target}`;
83 if (seen.has(key)) continue;
84 seen.add(key);
85 const source = nodes.get(edge.source); const target = nodes.get(edge.target);
86 if (!source || !target) { unresolvedEdges++; continue; }
87 // Some parser edges retain preprocessed coordinates. An out-of-range
88 // number is evidence metadata, never a verified navigable call site.
89 const validSite = edge.line !== undefined && source.start_line !== undefined && source.end_line !== undefined
90 && edge.line >= source.start_line && edge.line <= source.end_line;
91 const finding: MapEvidence = { source, target, type: edge.type as MapRelation, id: edge.id,
92 line: validSite ? edge.line : undefined, unverifiedLine: validSite ? undefined : edge.line,
93 strategy: edge.strategy, confidence: edge.confidence };
94 evidence.push(finding);
95 const from = areas.get(areaOf(source.file_path!))!;
96 const to = areas.get(areaOf(target.file_path!))!;
97 if (from !== to) { from.outgoing.push(finding); to.incoming.push(finding); }
98 }
99 for (const area of areas.values()) {
100 area.files = [...files.get(area.path)!].sort();
101 area.entryPoints.sort(priority); area.interfaces.sort(priority); area.nodes.sort(priority);
102 }
103 return {
104 areas: [...areas.values()].sort((a, b) => b.incoming.length + b.outgoing.length
105 - a.incoming.length - a.outgoing.length || a.path.localeCompare(b.path)),
106 evidence, fileCount: new Set([...files.values()].flatMap(set => [...set])).size,
107 representedNodes: nodes.size, totalNodes: graph.total_nodes, unresolvedEdges,
108 };
109}
110
111export function areaConnections(area: RepositoryArea, direction: 'incoming' | 'outgoing') {
112 const rows = new Map<string, { area: string; type: MapRelation; evidence: MapEvidence[] }>();

Callers 3

RepositoryMapViewFunction · 0.90

Calls 3

areaOfFunction · 0.85
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected