@prubbs88/codebase-cartographer 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +106 -2
  3. package/dist/ask.d.ts +20 -0
  4. package/dist/ask.js +93 -0
  5. package/dist/ask.js.map +1 -0
  6. package/dist/graph/analysis.d.ts +2 -0
  7. package/dist/graph/analysis.js +8 -0
  8. package/dist/graph/analysis.js.map +1 -0
  9. package/dist/graph/rank.d.ts +9 -0
  10. package/dist/graph/rank.js +173 -0
  11. package/dist/graph/rank.js.map +1 -0
  12. package/dist/graph/resolve.d.ts +11 -0
  13. package/dist/graph/resolve.js +299 -0
  14. package/dist/graph/resolve.js.map +1 -0
  15. package/dist/graph/serialize.d.ts +16 -0
  16. package/dist/graph/serialize.js +38 -0
  17. package/dist/graph/serialize.js.map +1 -0
  18. package/dist/graph/types.d.ts +64 -0
  19. package/dist/graph/types.js +2 -0
  20. package/dist/graph/types.js.map +1 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +101 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/llm/client.d.ts +13 -0
  25. package/dist/llm/client.js +46 -0
  26. package/dist/llm/client.js.map +1 -0
  27. package/dist/output/map.d.ts +2 -0
  28. package/dist/output/map.js +38 -0
  29. package/dist/output/map.js.map +1 -0
  30. package/dist/output/report.d.ts +22 -0
  31. package/dist/output/report.js +198 -0
  32. package/dist/output/report.js.map +1 -0
  33. package/dist/output/stats.d.ts +2 -0
  34. package/dist/output/stats.js +51 -0
  35. package/dist/output/stats.js.map +1 -0
  36. package/dist/parser/python.d.ts +2 -0
  37. package/dist/parser/python.js +366 -0
  38. package/dist/parser/python.js.map +1 -0
  39. package/dist/retrieval/chunk.d.ts +16 -0
  40. package/dist/retrieval/chunk.js +88 -0
  41. package/dist/retrieval/chunk.js.map +1 -0
  42. package/dist/retrieval/local-embed.d.ts +4 -0
  43. package/dist/retrieval/local-embed.js +53 -0
  44. package/dist/retrieval/local-embed.js.map +1 -0
  45. package/dist/retrieval/retrieve.d.ts +12 -0
  46. package/dist/retrieval/retrieve.js +85 -0
  47. package/dist/retrieval/retrieve.js.map +1 -0
  48. package/dist/scan.d.ts +2 -0
  49. package/dist/scan.js +46 -0
  50. package/dist/scan.js.map +1 -0
  51. package/dist/utils/module-name.d.ts +2 -0
  52. package/dist/utils/module-name.js +14 -0
  53. package/dist/utils/module-name.js.map +1 -0
  54. package/docs/benchmark.md +68 -0
  55. package/package.json +63 -4
@@ -0,0 +1,38 @@
1
+ export function formatMap(result) {
2
+ const lines = [];
3
+ lines.push("Module dependency map (cross-file call counts):");
4
+ lines.push("");
5
+ const moduleWeight = new Map();
6
+ for (const [from, targets] of result.moduleDeps) {
7
+ const w = moduleWeight.get(from) ?? { in: 0, out: 0 };
8
+ for (const count of targets.values())
9
+ w.out += count;
10
+ moduleWeight.set(from, w);
11
+ }
12
+ for (const [, targets] of result.moduleDeps) {
13
+ for (const [to, count] of targets) {
14
+ const w = moduleWeight.get(to) ?? { in: 0, out: 0 };
15
+ w.in += count;
16
+ moduleWeight.set(to, w);
17
+ }
18
+ }
19
+ const sorted = [...moduleWeight.entries()]
20
+ .map(([mod, w]) => ({ mod, weight: w.in + w.out, in: w.in, out: w.out }))
21
+ .sort((a, b) => b.weight - a.weight)
22
+ .slice(0, 25);
23
+ if (sorted.length === 0) {
24
+ lines.push(" No cross-module calls found.");
25
+ return lines.join("\n");
26
+ }
27
+ const width = Math.max(...sorted.map((s) => s.mod.length));
28
+ for (const s of sorted) {
29
+ const deps = result.moduleDeps.get(s.mod);
30
+ const topDeps = deps
31
+ ? [...deps.entries()].sort((a, b) => b[1] - a[1]).slice(0, 3).map(([d, c]) => `${d} (${c})`)
32
+ : [];
33
+ const depStr = topDeps.length > 0 ? ` -> ${topDeps.join(", ")}` : "";
34
+ lines.push(` ${s.mod.padEnd(width)} in:${String(s.in).padStart(4)} out:${String(s.out).padStart(4)}${depStr}`);
35
+ }
36
+ return lines.join("\n");
37
+ }
38
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../../src/output/map.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAC9D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuC,CAAC;IACpE,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAChD,MAAM,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;QACtD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE;YAAE,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC;QACrD,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,KAAK,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YACpD,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC;YACd,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,C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;YAC5F,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC;IACpH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { AnalysisResult } from "../graph/types.js";
2
+ export interface ReportModule {
3
+ path: string;
4
+ in: number;
5
+ out: number;
6
+ deps: [string, number][];
7
+ }
8
+ export interface ReportSymbol {
9
+ q: string;
10
+ file: string;
11
+ line: number;
12
+ kind: string;
13
+ cls: string;
14
+ in: number;
15
+ reach: number;
16
+ }
17
+ export declare function collectReportData(result: AnalysisResult): {
18
+ stats: Record<string, number>;
19
+ modules: ReportModule[];
20
+ symbols: ReportSymbol[];
21
+ };
22
+ export declare function renderReport(rootLabel: string, data: ReturnType<typeof collectReportData>): string;
@@ -0,0 +1,198 @@
1
+ export function collectReportData(result) {
2
+ const modules = [];
3
+ for (const [from, targets] of result.moduleDeps) {
4
+ let out = 0;
5
+ for (const count of targets.values())
6
+ out += count;
7
+ const deps = [...targets.entries()].sort((a, b) => b[1] - a[1]).slice(0, 8);
8
+ modules.push({ path: from, in: 0, out, deps });
9
+ }
10
+ for (const [, targets] of result.moduleDeps) {
11
+ for (const [to, count] of targets) {
12
+ const mod = modules.find((m) => m.path === to);
13
+ if (mod)
14
+ mod.in += count;
15
+ }
16
+ }
17
+ modules.sort((a, b) => b.in + b.out - (a.in + a.out));
18
+ const symbols = [...result.ranked.values()]
19
+ .filter((r) => r.classification !== "external")
20
+ .map((r) => ({
21
+ q: r.symbol.qualifiedName,
22
+ file: r.symbol.file,
23
+ line: r.symbol.startLine,
24
+ kind: r.symbol.kind,
25
+ cls: r.classification,
26
+ in: r.directInbound,
27
+ reach: r.entryPointReachCount,
28
+ }))
29
+ .sort((a, b) => b.in - a.in);
30
+ const counts = {};
31
+ for (const s of symbols)
32
+ counts[s.cls] = (counts[s.cls] ?? 0) + 1;
33
+ return {
34
+ stats: {
35
+ modules: new Set(symbols.map((s) => s.file)).size,
36
+ symbols: symbols.length,
37
+ callSites: result.edges.length,
38
+ resolution: Math.round(result.resolutionRate * 1000) / 10,
39
+ entryPoints: counts["entry-point"] ?? 0,
40
+ loadBearing: counts["load-bearing"] ?? 0,
41
+ deadCode: counts["dead-code-suspect"] ?? 0,
42
+ },
43
+ modules,
44
+ symbols,
45
+ };
46
+ }
47
+ const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
48
+ export function renderReport(rootLabel, data) {
49
+ const payload = JSON.stringify(data);
50
+ return `<!DOCTYPE html>
51
+ <html lang="en">
52
+ <head>
53
+ <meta charset="utf-8">
54
+ <meta name="viewport" content="width=device-width, initial-scale=1">
55
+ <title>Cartographer — ${esc(rootLabel)}</title>
56
+ <style>
57
+ :root { color-scheme: dark; }
58
+ * { box-sizing: border-box; }
59
+ body { margin: 0; background: #0d1117; color: #c9d1d9; font: 14px/1.5 -apple-system, "Segoe UI", sans-serif; }
60
+ header { padding: 20px 28px; border-bottom: 1px solid #21262d; display: flex; align-items: baseline; gap: 14px; }
61
+ header h1 { font-size: 18px; margin: 0; color: #58a6ff; }
62
+ header .path { color: #8b949e; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
63
+ .cards { display: flex; flex-wrap: wrap; gap: 12px; padding: 18px 28px; }
64
+ .card { background: #161b22; border: 1px solid #21262d; border-radius: 8px; padding: 12px 18px; min-width: 130px; }
65
+ .card .num { font-size: 24px; font-weight: 700; color: #e6edf3; }
66
+ .card .lbl { font-size: 11px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; }
67
+ main { display: flex; flex-wrap: wrap; gap: 20px; padding: 0 28px 40px; }
68
+ section { background: #161b22; border: 1px solid #21262d; border-radius: 8px; padding: 16px; }
69
+ section h2 { font-size: 13px; margin: 0 0 12px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; }
70
+ #map-section { flex: 1 1 640px; }
71
+ #table-section { flex: 1 1 380px; }
72
+ #search { width: 100%; background: #0d1117; border: 1px solid #30363d; color: #e6edf3; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; font: inherit; }
73
+ table { width: 100%; border-collapse: collapse; font-size: 13px; }
74
+ th { text-align: left; color: #8b949e; font-weight: 500; padding: 4px 8px; border-bottom: 1px solid #21262d; }
75
+ td { padding: 4px 8px; border-bottom: 1px solid #21262d22; }
76
+ td.mono, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
77
+ tr:hover td { background: #1c2129; }
78
+ .badge { display: inline-block; border-radius: 10px; padding: 0 8px; font-size: 11px; }
79
+ .b-entry-point { background: #1f6feb33; color: #58a6ff; }
80
+ .b-load-bearing { background: #f0883e33; color: #f0883e; }
81
+ .b-core { background: #23863633; color: #3fb950; }
82
+ .b-peripheral { background: #30363d; color: #8b949e; }
83
+ .b-dead-code-suspect { background: #f8514933; color: #f85149; }
84
+ text { fill: #8b949e; font-size: 10px; }
85
+ .dot { cursor: pointer; }
86
+ .legend { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
87
+ .legend span { font-size: 11px; color: #8b949e; }
88
+ .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
89
+ #tooltip { position: fixed; pointer-events: none; background: #30363d; border: 1px solid #444c56; border-radius: 6px; padding: 6px 10px; font-size: 12px; display: none; z-index: 10; max-width: 480px; }
90
+ .hint { color: #8b949e; font-size: 12px; margin-top: 6px; }
91
+ footer { padding: 0 28px 24px; color: #484f58; font-size: 12px; }
92
+ </style>
93
+ </head>
94
+ <body>
95
+ <header><h1>Cartographer</h1><span class="path">${esc(rootLabel)}</span></header>
96
+ <div class="cards" id="cards"></div>
97
+ <main>
98
+ <section id="map-section">
99
+ <h2>Module map — fan-out (x) vs fan-in (y), bubble size = cross-file calls</h2>
100
+ <svg id="map" width="100%" height="420" viewBox="0 0 800 420"></svg>
101
+ <div class="legend">
102
+ <span><i style="background:#58a6ff"></i>hub (high fan-in)</span>
103
+ <span><i style="background:#f0883e"></i>orchestrator (high fan-out)</span>
104
+ <span><i style="background:#3fb950"></i>balanced</span>
105
+ </div>
106
+ <div class="hint">Click a bubble to filter the symbol table. Hover for dependencies.</div>
107
+ </section>
108
+ <section id="table-section">
109
+ <h2>Symbols</h2>
110
+ <input id="search" placeholder="filter symbols (e.g. dispatch, dead)…">
111
+ <div style="max-height: 560px; overflow-y: auto;">
112
+ <table id="symtable"><thead><tr><th>symbol</th><th>class</th><th>in</th><th>ep</th></tr></thead><tbody></tbody></table>
113
+ </div>
114
+ </section>
115
+ </main>
116
+ <footer>Generated by carto report · static call graph · "dead-code suspects" are heuristics, not proof</footer>
117
+ <div id="tooltip"></div>
118
+ <script>
119
+ const DATA = ${payload};
120
+ const CLS_COLORS = { "entry-point": "#58a6ff", "load-bearing": "#f0883e", "core": "#3fb950", "peripheral": "#6e7681", "dead-code-suspect": "#f85149" };
121
+ const cards = document.getElementById("cards");
122
+ for (const [lbl, key] of [["modules", "modules"], ["symbols", "symbols"], ["call sites", "callSites"], ["resolution %", "resolution"], ["entry points", "entryPoints"], ["load-bearing", "loadBearing"], ["dead-code suspects", "deadCode"]]) {
123
+ cards.insertAdjacentHTML("beforeend", '<div class="card"><div class="num">' + DATA.stats[key] + '</div><div class="lbl">' + lbl + '</div></div>');
124
+ }
125
+
126
+ const svg = document.getElementById("map");
127
+ const tooltip = document.getElementById("tooltip");
128
+ const mods = DATA.modules.slice(0, 60);
129
+ const maxIn = Math.max(1, ...mods.map(m => m.in));
130
+ const maxOut = Math.max(1, ...mods.map(m => m.out));
131
+ const W = 800, H = 420, PAD = 40;
132
+ const px = v => PAD + (v / maxOut) * (W - PAD - 20);
133
+ const py = v => H - PAD - (v / maxIn) * (H - PAD - 30);
134
+
135
+ const axisX = document.createElementNS("http://www.w3.org/2000/svg", "line");
136
+ axisX.setAttribute("x1", PAD); axisX.setAttribute("y1", H - PAD); axisX.setAttribute("x2", W - 20); axisX.setAttribute("y2", H - PAD);
137
+ axisX.setAttribute("stroke", "#30363d"); svg.appendChild(axisX);
138
+ const axisY = document.createElementNS("http://www.w3.org/2000/svg", "line");
139
+ axisY.setAttribute("x1", PAD); axisY.setAttribute("y1", 20); axisY.setAttribute("x2", PAD); axisY.setAttribute("y2", H - PAD);
140
+ axisY.setAttribute("stroke", "#30363d"); svg.appendChild(axisY);
141
+
142
+ for (const m of mods) {
143
+ const cx = px(m.out), cy = py(m.in);
144
+ const r = 4 + Math.min(12, Math.sqrt(m.in + m.out) * 1.6);
145
+ const c = document.createElementNS("http://www.w3.org/2000/svg", "circle");
146
+ c.setAttribute("cx", cx); c.setAttribute("cy", cy); c.setAttribute("r", r);
147
+ c.setAttribute("fill", m.in >= m.out * 2 ? "#58a6ff" : m.out >= m.in * 2 ? "#f0883e" : "#3fb950");
148
+ c.setAttribute("fill-opacity", "0.75");
149
+ c.setAttribute("class", "dot");
150
+ c.dataset.module = m.path;
151
+ c.addEventListener("mousemove", (e) => {
152
+ tooltip.style.display = "block";
153
+ tooltip.style.left = (e.clientX + 14) + "px";
154
+ tooltip.style.top = (e.clientY + 14) + "px";
155
+ tooltip.innerHTML = "<b>" + m.path + "</b><br>fan-in: " + m.in + " · fan-out: " + m.out +
156
+ (m.deps.length ? "<br>" + m.deps.slice(0, 4).map(d => d[0] + " (" + d[1] + ")").join(", ") : "");
157
+ });
158
+ c.addEventListener("mouseleave", () => { tooltip.style.display = "none"; });
159
+ c.addEventListener("click", () => {
160
+ const input = document.getElementById("search");
161
+ input.value = "file:" + m.path;
162
+ renderRows();
163
+ });
164
+ svg.appendChild(c);
165
+ const label = document.createElementNS("http://www.w3.org/2000/svg", "text");
166
+ const short = m.path.split("/").pop();
167
+ label.setAttribute("x", cx); label.setAttribute("y", cy - r - 4);
168
+ label.setAttribute("text-anchor", "middle");
169
+ label.textContent = short;
170
+ svg.appendChild(label);
171
+ }
172
+
173
+ const tbody = document.querySelector("#symtable tbody");
174
+ const MAX_ROWS = 400;
175
+ function renderRows() {
176
+ const raw = document.getElementById("search").value.toLowerCase();
177
+ let filter = raw, fileFilter = null;
178
+ if (raw.startsWith("file:")) fileFilter = raw.slice(5), filter = "";
179
+ const rows = [];
180
+ for (const s of DATA.symbols) {
181
+ if (rows.length >= MAX_ROWS) break;
182
+ if (fileFilter && s.file !== fileFilter) continue;
183
+ if (filter && !(s.q.toLowerCase().includes(filter) || s.file.toLowerCase().includes(filter) || s.cls.includes(filter))) continue;
184
+ rows.push(s);
185
+ }
186
+ tbody.innerHTML = rows.map(s =>
187
+ "<tr><td class='mono'>" + s.q + "<br><span style='color:#6e7681'>" + s.file + ":" + s.line + "</span></td>" +
188
+ "<td><span class='badge b-" + s.cls + "'>" + s.cls + "</span></td>" +
189
+ "<td>" + s.in + "</td><td>" + (s.reach || "") + "</td></tr>"
190
+ ).join("") || "<tr><td colspan=4>no matches</td></tr>";
191
+ }
192
+ document.getElementById("search").addEventListener("input", renderRows);
193
+ renderRows();
194
+ </script>
195
+ </body>
196
+ </html>`;
197
+ }
198
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/output/report.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,iBAAiB,CAAC,MAAsB;IAKtD,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,KAAK,M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3C;QACD,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAChC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAE/F,MAAM,UAAU,YAAY,CAAC,SAAiB,EAAE,IAA0C;IACxF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO;;;;;wBAKe,GAAG,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAwCY,GAAG,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;eAwBjD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6Ed,CAAC;AACT,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { AnalysisResult } from "../graph/types.js";
2
+ export declare function formatStats(result: AnalysisResult, rootLabel: string): string;
@@ -0,0 +1,51 @@
1
+ export function formatStats(result, rootLabel) {
2
+ const lines = [];
3
+ const symbolList = [...result.ranked.values()].filter((r) => r.classification !== "external");
4
+ const modules = new Set(symbolList.map((r) => r.symbol.file));
5
+ const byClass = (c) => symbolList.filter((r) => r.classification === c).length;
6
+ lines.push(`Cartographer — ${rootLabel}`);
7
+ lines.push("");
8
+ lines.push(` ${modules.size} modules · ${symbolList.length} functions/classes · ${result.edges.length} call sites`);
9
+ lines.push(` Call resolution: ${(result.resolutionRate * 100).toFixed(1)}%`);
10
+ lines.push("");
11
+ lines.push(` entry-points ${byClass("entry-point")}`);
12
+ lines.push(` load-bearing ${byClass("load-bearing")}`);
13
+ lines.push(` core ${byClass("core")}`);
14
+ lines.push(` peripheral ${byClass("peripheral")}`);
15
+ lines.push(` dead-code suspects ${byClass("dead-code-suspect")}`);
16
+ lines.push("");
17
+ const hubs = [...result.ranked.values()]
18
+ .filter((r) => r.classification !== "external")
19
+ .sort((a, b) => b.directInbound - a.directInbound || b.score - a.score)
20
+ .slice(0, 5);
21
+ if (hubs.length > 0) {
22
+ lines.push(" Top hubs (most depended-on):");
23
+ for (const hub of hubs) {
24
+ lines.push(` ${hub.symbol.file}:${hub.symbol.startLine} ${hub.symbol.qualifiedName} (${hub.directInbound} inbound calls)`);
25
+ }
26
+ lines.push("");
27
+ }
28
+ const dead = symbolList
29
+ .filter((r) => r.classification === "dead-code-suspect")
30
+ .sort((a, b) => (b.symbol.endLine - b.symbol.startLine) - (a.symbol.endLine - a.symbol.startLine))
31
+ .slice(0, 10);
32
+ if (dead.length > 0) {
33
+ lines.push(" Dead-code suspects (never called, not exported):");
34
+ for (const d of dead) {
35
+ lines.push(` ${d.symbol.file}:${d.symbol.startLine} ${d.symbol.qualifiedName}`);
36
+ }
37
+ lines.push("");
38
+ }
39
+ const entryList = symbolList
40
+ .filter((r) => r.classification === "entry-point")
41
+ .sort((a, b) => b.entryPointReachCount - a.entryPointReachCount)
42
+ .slice(0, 5);
43
+ if (entryList.length > 0) {
44
+ lines.push(" Entry points (start reading here):");
45
+ for (const e of entryList) {
46
+ lines.push(` ${e.symbol.file}:${e.symbol.startLine} ${e.symbol.qualifiedName} (reaches ${e.entryPointReachCount} functions)`);
47
+ }
48
+ }
49
+ return lines.join("\n");
50
+ }
51
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/output/stats.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,MAAsB,EAAE,SAAiB;IACnE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EA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AAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;QACjE,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QACtF,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,SAAS,GAAG,UAAU;SACzB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,aAAa,CAAC;SACjD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,GAAG,CAAC,CAAC,oBAAoB,CAAC;SAC/D,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACf,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACnD,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;YAC1B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,cAAc,CAAC,CAAC,oBAAoB,aAAa,CAAC,CAAC;QACrI,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ParsedFile } from "../graph/types.js";
2
+ export declare function parsePythonFile(absPath: string, relPath: string, source: string): ParsedFile;