@fabersep/atlas 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.
- package/CHANGELOG.md +30 -0
- package/LICENSE +202 -0
- package/README.md +139 -2
- package/dist/packs/csharp/calls.d.ts +4 -0
- package/dist/packs/csharp/calls.js +167 -0
- package/dist/packs/csharp/declarations.d.ts +4 -0
- package/dist/packs/csharp/declarations.js +142 -0
- package/dist/packs/csharp/pack.d.ts +2 -0
- package/dist/packs/csharp/pack.js +39 -0
- package/dist/packs/csharp/resolve.d.ts +2 -0
- package/dist/packs/csharp/resolve.js +35 -0
- package/dist/packs/csharp/signals.d.ts +7 -0
- package/dist/packs/csharp/signals.js +143 -0
- package/dist/packs/dart/calls.d.ts +4 -0
- package/dist/packs/dart/calls.js +130 -0
- package/dist/packs/dart/declarations.d.ts +11 -0
- package/dist/packs/dart/declarations.js +79 -0
- package/dist/packs/dart/members.d.ts +4 -0
- package/dist/packs/dart/members.js +62 -0
- package/dist/packs/dart/pack.d.ts +2 -0
- package/dist/packs/dart/pack.js +37 -0
- package/dist/packs/dart/resolve.d.ts +2 -0
- package/dist/packs/dart/resolve.js +32 -0
- package/dist/packs/index.d.ts +3 -0
- package/dist/packs/index.js +8 -0
- package/dist/packs/json/pack.d.ts +2 -0
- package/dist/packs/json/pack.js +27 -0
- package/dist/packs/msbuild/pack.d.ts +2 -0
- package/dist/packs/msbuild/pack.js +75 -0
- package/dist/packs/msbuild/xml.d.ts +16 -0
- package/dist/packs/msbuild/xml.js +123 -0
- package/dist/packs/typescript/calls.d.ts +4 -0
- package/dist/packs/typescript/calls.js +201 -0
- package/dist/packs/typescript/declarations.d.ts +9 -0
- package/dist/packs/typescript/declarations.js +74 -0
- package/dist/packs/typescript/members.d.ts +4 -0
- package/dist/packs/typescript/members.js +92 -0
- package/dist/packs/typescript/pack.d.ts +2 -0
- package/dist/packs/typescript/pack.js +53 -0
- package/dist/packs/typescript/resolve.d.ts +2 -0
- package/dist/packs/typescript/resolve.js +68 -0
- package/dist/packs/typescript/signals.d.ts +7 -0
- package/dist/packs/typescript/signals.js +186 -0
- package/dist/packs/yaml/pack.d.ts +2 -0
- package/dist/packs/yaml/pack.js +35 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +371 -0
- package/dist/src/graph/build.d.ts +17 -0
- package/dist/src/graph/build.js +41 -0
- package/dist/src/graph/metrics.d.ts +12 -0
- package/dist/src/graph/metrics.js +75 -0
- package/dist/src/graph/topology.d.ts +5 -0
- package/dist/src/graph/topology.js +54 -0
- package/dist/src/health/compare.d.ts +2 -0
- package/dist/src/health/compare.js +38 -0
- package/dist/src/health/duplicates.d.ts +11 -0
- package/dist/src/health/duplicates.js +66 -0
- package/dist/src/health/health.d.ts +12 -0
- package/dist/src/health/health.js +94 -0
- package/dist/src/health/types.d.ts +101 -0
- package/dist/src/health/types.js +5 -0
- package/dist/src/index.d.ts +23 -0
- package/dist/src/index.js +20 -0
- package/dist/src/init/init.d.ts +73 -0
- package/dist/src/init/init.js +305 -0
- package/dist/src/init/scout.d.ts +45 -0
- package/dist/src/init/scout.js +208 -0
- package/dist/src/jsonc.d.ts +5 -0
- package/dist/src/jsonc.js +34 -0
- package/dist/src/mcp/server.d.ts +266 -0
- package/dist/src/mcp/server.js +414 -0
- package/dist/src/metrics/doctor.d.ts +15 -0
- package/dist/src/metrics/doctor.js +125 -0
- package/dist/src/metrics/log.d.ts +43 -0
- package/dist/src/metrics/log.js +101 -0
- package/dist/src/metrics/stats.d.ts +43 -0
- package/dist/src/metrics/stats.js +172 -0
- package/dist/src/model.d.ts +178 -0
- package/dist/src/model.js +2 -0
- package/dist/src/outputs.d.ts +16 -0
- package/dist/src/outputs.js +48 -0
- package/dist/src/packs/calls.d.ts +9 -0
- package/dist/src/packs/calls.js +119 -0
- package/dist/src/packs/dataShape.d.ts +6 -0
- package/dist/src/packs/dataShape.js +54 -0
- package/dist/src/packs/pack.d.ts +51 -0
- package/dist/src/packs/pack.js +3 -0
- package/dist/src/packs/packFiles.d.ts +5 -0
- package/dist/src/packs/packFiles.js +12 -0
- package/dist/src/packs/symbols.d.ts +39 -0
- package/dist/src/packs/symbols.js +98 -0
- package/dist/src/packs/treeSitter.d.ts +8 -0
- package/dist/src/packs/treeSitter.js +107 -0
- package/dist/src/queries/flow.d.ts +42 -0
- package/dist/src/queries/flow.js +391 -0
- package/dist/src/queries/map.d.ts +28 -0
- package/dist/src/queries/map.js +102 -0
- package/dist/src/queries/neighborhood.d.ts +35 -0
- package/dist/src/queries/neighborhood.js +60 -0
- package/dist/src/scan/audit.d.ts +2 -0
- package/dist/src/scan/audit.js +41 -0
- package/dist/src/scan/records.d.ts +12 -0
- package/dist/src/scan/records.js +42 -0
- package/dist/src/scan/resolveImports.d.ts +3 -0
- package/dist/src/scan/resolveImports.js +47 -0
- package/dist/src/scan/roles.d.ts +5 -0
- package/dist/src/scan/roles.js +87 -0
- package/dist/src/scan/scan.d.ts +24 -0
- package/dist/src/scan/scan.js +72 -0
- package/dist/src/text/briefs.d.ts +13 -0
- package/dist/src/text/briefs.js +43 -0
- package/dist/src/text/collapse.d.ts +10 -0
- package/dist/src/text/collapse.js +58 -0
- package/dist/src/text/declarations.d.ts +12 -0
- package/dist/src/text/declarations.js +120 -0
- package/dist/src/text/structure.d.ts +2 -0
- package/dist/src/text/structure.js +15 -0
- package/dist/src/text/tree.d.ts +20 -0
- package/dist/src/text/tree.js +49 -0
- package/dist/src/tokens.d.ts +4 -0
- package/dist/src/tokens.js +9 -0
- package/dist/src/version.d.ts +10 -0
- package/dist/src/version.js +11 -0
- package/dist/src/walk/ignoreRules.d.ts +17 -0
- package/dist/src/walk/ignoreRules.js +72 -0
- package/dist/src/walk/walk.d.ts +11 -0
- package/dist/src/walk/walk.js +29 -0
- package/grammars/LICENSE-tree-sitter-dart +20 -0
- package/grammars/README.md +11 -0
- package/grammars/tree-sitter-dart.wasm +0 -0
- package/package.json +68 -4
- package/packs/csharp/README.md +9 -0
- package/packs/csharp/imports.scm +3 -0
- package/packs/csharp/symbols.scm +17 -0
- package/packs/dart/imports.scm +5 -0
- package/packs/dart/symbols.scm +13 -0
- package/packs/msbuild/README.md +11 -0
- package/packs/typescript/exports.scm +16 -0
- package/packs/typescript/imports.scm +9 -0
- package/packs/typescript/symbols.scm +19 -0
- package/schema/ast_code_map.schema.json +144 -0
- package/schema/schema-lock.json +7 -0
- package/schema/topology.schema.json +87 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type CheckStatus = 'PASS' | 'WARN' | 'FAIL';
|
|
2
|
+
export interface DoctorCheck {
|
|
3
|
+
id: string;
|
|
4
|
+
status: CheckStatus;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DoctorReport {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
root: string;
|
|
10
|
+
out: string;
|
|
11
|
+
checks: DoctorCheck[];
|
|
12
|
+
}
|
|
13
|
+
/** Read-only health check for a repository's FaberSEP Atlas setup. Never mutates files. */
|
|
14
|
+
export declare function runDoctor(rootInput: string, outInput?: string): DoctorReport;
|
|
15
|
+
export declare function formatDoctor(report: DoctorReport): string;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { OutputMissingError, readCodeMap, readTopology } from '../outputs.js';
|
|
4
|
+
import { walk } from '../walk/walk.js';
|
|
5
|
+
import { MAX_METRICS_BYTES, metricsPath } from './log.js';
|
|
6
|
+
function checkGitignore(root, out) {
|
|
7
|
+
const gitDir = path.join(root, '.git');
|
|
8
|
+
if (!fs.existsSync(gitDir)) {
|
|
9
|
+
return { id: 'gitignore-hygiene', status: 'PASS', message: 'Not a git repository (no .gitignore check needed).' };
|
|
10
|
+
}
|
|
11
|
+
const rel = path.relative(root, out);
|
|
12
|
+
if (rel.startsWith('..') || path.isAbsolute(rel)) {
|
|
13
|
+
return { id: 'gitignore-hygiene', status: 'PASS', message: 'Index directory is outside the repository root.' };
|
|
14
|
+
}
|
|
15
|
+
const topDir = rel.split(path.sep)[0];
|
|
16
|
+
if (!fs.existsSync(out)) {
|
|
17
|
+
return { id: 'gitignore-hygiene', status: 'PASS', message: `"${topDir}/" will ignore itself in git when it is built.` };
|
|
18
|
+
}
|
|
19
|
+
const selfIgnore = path.join(out, '.gitignore');
|
|
20
|
+
if (fs.existsSync(selfIgnore) && fs.readFileSync(selfIgnore, 'utf8').split('\n').some((l) => l.trim() === '*')) {
|
|
21
|
+
return { id: 'gitignore-hygiene', status: 'PASS', message: `"${topDir}/" ignores itself (its own .gitignore).` };
|
|
22
|
+
}
|
|
23
|
+
const giPath = path.join(root, '.gitignore');
|
|
24
|
+
if (!fs.existsSync(giPath)) {
|
|
25
|
+
return {
|
|
26
|
+
id: 'gitignore-hygiene',
|
|
27
|
+
status: 'WARN',
|
|
28
|
+
message: `No .gitignore found; add "${topDir}/" to avoid committing index artifacts.`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const content = fs.readFileSync(giPath, 'utf8');
|
|
32
|
+
const lines = content.split('\n').map((l) => l.trim());
|
|
33
|
+
const ignored = lines.some((l) => l === topDir || l === `${topDir}/` || l === `/${topDir}` || l === `/${topDir}/`);
|
|
34
|
+
return ignored
|
|
35
|
+
? { id: 'gitignore-hygiene', status: 'PASS', message: `"${topDir}/" is listed in .gitignore.` }
|
|
36
|
+
: {
|
|
37
|
+
id: 'gitignore-hygiene',
|
|
38
|
+
status: 'WARN',
|
|
39
|
+
message: `"${topDir}/" is not listed in .gitignore; add it to keep generated index files out of git.`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Read-only health check for a repository's FaberSEP Atlas setup. Never mutates files. */
|
|
43
|
+
export function runDoctor(rootInput, outInput) {
|
|
44
|
+
const root = path.resolve(rootInput);
|
|
45
|
+
const out = path.resolve(outInput ?? path.join(root, '.faber-atlas'));
|
|
46
|
+
const checks = [];
|
|
47
|
+
// 1. Node runtime
|
|
48
|
+
const major = Number(process.versions.node.split('.')[0]);
|
|
49
|
+
checks.push(major >= 20
|
|
50
|
+
? { id: 'node-version', status: 'PASS', message: `Node.js ${process.versions.node} (>=20 required).` }
|
|
51
|
+
: { id: 'node-version', status: 'FAIL', message: `Node.js ${process.versions.node} detected; >=20 is required.` });
|
|
52
|
+
// 2. Index existence & schema compatibility
|
|
53
|
+
let map;
|
|
54
|
+
try {
|
|
55
|
+
map = readCodeMap(out);
|
|
56
|
+
readTopology(out);
|
|
57
|
+
checks.push({
|
|
58
|
+
id: 'index-present',
|
|
59
|
+
status: 'PASS',
|
|
60
|
+
message: `Valid index found (${map.summary.files} files, ${map.summary.symbols} declarations, schema v${map.schemaVersion}).`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
// A missing index is the normal state right after init: the MCP server builds it on its first call.
|
|
65
|
+
// An index that exists but cannot be read (another schema version, broken JSON) is a real failure.
|
|
66
|
+
checks.push(err instanceof OutputMissingError
|
|
67
|
+
? {
|
|
68
|
+
id: 'index-present',
|
|
69
|
+
status: 'WARN',
|
|
70
|
+
message: 'No index yet. It is built on the first MCP call, or run "faber-atlas scan ." now.',
|
|
71
|
+
}
|
|
72
|
+
: { id: 'index-present', status: 'FAIL', message: err instanceof Error ? err.message : String(err) });
|
|
73
|
+
}
|
|
74
|
+
// 3. Index freshness
|
|
75
|
+
if (map) {
|
|
76
|
+
const liveFiles = walk(root);
|
|
77
|
+
const indexed = new Map(map.files.map((f) => [f.path, f]));
|
|
78
|
+
let stale = 0;
|
|
79
|
+
for (const f of liveFiles) {
|
|
80
|
+
const prev = indexed.get(f.path);
|
|
81
|
+
if (!prev || prev.sizeBytes !== f.sizeBytes || prev.mtimeMs !== f.mtimeMs)
|
|
82
|
+
stale++;
|
|
83
|
+
}
|
|
84
|
+
const deleted = map.files.filter((f) => !liveFiles.some((l) => l.path === f.path)).length;
|
|
85
|
+
const totalDrift = stale + deleted;
|
|
86
|
+
checks.push(totalDrift === 0
|
|
87
|
+
? { id: 'index-freshness', status: 'PASS', message: 'Index matches all files on disk.' }
|
|
88
|
+
: {
|
|
89
|
+
id: 'index-freshness',
|
|
90
|
+
status: 'WARN',
|
|
91
|
+
message: `${totalDrift} file(s) changed since last scan (${stale} new/modified, ${deleted} removed). Run "faber-atlas scan ." or query with --fresh.`,
|
|
92
|
+
});
|
|
93
|
+
// 4. Parse health
|
|
94
|
+
const failed = map.summary.failed.length;
|
|
95
|
+
checks.push(failed === 0
|
|
96
|
+
? { id: 'parse-health', status: 'PASS', message: 'Zero parse errors.' }
|
|
97
|
+
: { id: 'parse-health', status: 'WARN', message: `${failed} file(s) had parse errors.` });
|
|
98
|
+
}
|
|
99
|
+
// 5. .gitignore hygiene
|
|
100
|
+
checks.push(checkGitignore(root, out));
|
|
101
|
+
// 6. Local metrics log hygiene
|
|
102
|
+
const mPath = metricsPath(out);
|
|
103
|
+
if (!fs.existsSync(mPath)) {
|
|
104
|
+
checks.push({ id: 'metrics-log', status: 'PASS', message: 'No local metrics.jsonl yet (created on first scan/MCP call).' });
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const size = fs.statSync(mPath).size;
|
|
108
|
+
checks.push(size <= MAX_METRICS_BYTES
|
|
109
|
+
? { id: 'metrics-log', status: 'PASS', message: `Local metrics.jsonl is ${(size / 1024).toFixed(1)} KB (zero telemetry).` }
|
|
110
|
+
: { id: 'metrics-log', status: 'WARN', message: `Local metrics.jsonl is ${(size / (1024 * 1024)).toFixed(1)} MB; will auto-rotate on next event.` });
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
ok: !checks.some((c) => c.status === 'FAIL'),
|
|
114
|
+
root,
|
|
115
|
+
out,
|
|
116
|
+
checks,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function formatDoctor(report) {
|
|
120
|
+
const lines = [`FaberSEP Atlas doctor — ${report.ok ? 'OK' : 'ISSUES FOUND'}`, ''];
|
|
121
|
+
for (const c of report.checks) {
|
|
122
|
+
lines.push(` [${c.status}] ${c.id}: ${c.message}`);
|
|
123
|
+
}
|
|
124
|
+
return lines.join('\n');
|
|
125
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ScanSummary } from '../model.js';
|
|
2
|
+
export declare const METRICS_FILE = "metrics.jsonl";
|
|
3
|
+
export declare const MAX_METRICS_BYTES: number;
|
|
4
|
+
export declare const MAX_METRICS_DAYS = 90;
|
|
5
|
+
/**
|
|
6
|
+
* Strictly numeric/enum local telemetry event.
|
|
7
|
+
* INVARIANT: Never store repository names, file paths, symbol names, or source code.
|
|
8
|
+
*/
|
|
9
|
+
export interface ScanMetricEvent {
|
|
10
|
+
ts: string;
|
|
11
|
+
event: 'scan';
|
|
12
|
+
incremental: boolean;
|
|
13
|
+
files: number;
|
|
14
|
+
parsed: number;
|
|
15
|
+
reused: number;
|
|
16
|
+
symbols: number;
|
|
17
|
+
rawTokens: number;
|
|
18
|
+
skeletonTokens: number;
|
|
19
|
+
durationMs: number;
|
|
20
|
+
failedCount: number;
|
|
21
|
+
languages: Record<string, number>;
|
|
22
|
+
}
|
|
23
|
+
export interface McpCallMetricEvent {
|
|
24
|
+
ts: string;
|
|
25
|
+
event: 'mcp_call';
|
|
26
|
+
tool: string;
|
|
27
|
+
zoom?: number;
|
|
28
|
+
durationMs: number;
|
|
29
|
+
responseTokens: number;
|
|
30
|
+
ok: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type MetricEvent = ScanMetricEvent | McpCallMetricEvent;
|
|
33
|
+
export declare function metricsPath(out: string): string;
|
|
34
|
+
export declare function appendMetric(out: string, event: MetricEvent, nowMs?: number): void;
|
|
35
|
+
export declare function recordScanMetric(out: string, summary: ScanSummary, incremental?: boolean, now?: Date): void;
|
|
36
|
+
export declare function recordMcpMetric(out: string, data: {
|
|
37
|
+
tool: string;
|
|
38
|
+
zoom?: number;
|
|
39
|
+
durationMs: number;
|
|
40
|
+
responseTokens: number;
|
|
41
|
+
ok: boolean;
|
|
42
|
+
}, now?: Date): void;
|
|
43
|
+
export declare function readMetrics(out: string, days?: number, nowMs?: number): MetricEvent[];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export const METRICS_FILE = 'metrics.jsonl';
|
|
4
|
+
export const MAX_METRICS_BYTES = 10 * 1024 * 1024; // 10 MB
|
|
5
|
+
export const MAX_METRICS_DAYS = 90;
|
|
6
|
+
export function metricsPath(out) {
|
|
7
|
+
return path.join(out, METRICS_FILE);
|
|
8
|
+
}
|
|
9
|
+
function pruneIfNeeded(file, nowMs) {
|
|
10
|
+
if (!fs.existsSync(file))
|
|
11
|
+
return;
|
|
12
|
+
const stat = fs.statSync(file);
|
|
13
|
+
const cutoff = nowMs - MAX_METRICS_DAYS * 24 * 60 * 60 * 1000;
|
|
14
|
+
const raw = fs.readFileSync(file, 'utf8');
|
|
15
|
+
const lines = raw.split('\n').filter((l) => l.trim().length > 0);
|
|
16
|
+
if (lines.length === 0)
|
|
17
|
+
return;
|
|
18
|
+
let needsRewrite = stat.size > MAX_METRICS_BYTES;
|
|
19
|
+
const kept = [];
|
|
20
|
+
for (const line of lines) {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = JSON.parse(line);
|
|
23
|
+
const tsMs = parsed.ts ? Date.parse(parsed.ts) : NaN;
|
|
24
|
+
if (!Number.isNaN(tsMs) && tsMs >= cutoff)
|
|
25
|
+
kept.push(line);
|
|
26
|
+
else
|
|
27
|
+
needsRewrite = true;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
needsRewrite = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (!needsRewrite)
|
|
34
|
+
return;
|
|
35
|
+
// If still above size cap after age pruning, drop oldest lines until within cap.
|
|
36
|
+
let payload = kept.length ? `${kept.join('\n')}\n` : '';
|
|
37
|
+
while (Buffer.byteLength(payload, 'utf8') > MAX_METRICS_BYTES && kept.length > 1) {
|
|
38
|
+
kept.shift();
|
|
39
|
+
payload = `${kept.join('\n')}\n`;
|
|
40
|
+
}
|
|
41
|
+
fs.writeFileSync(file, payload, 'utf8');
|
|
42
|
+
}
|
|
43
|
+
export function appendMetric(out, event, nowMs = Date.now()) {
|
|
44
|
+
try {
|
|
45
|
+
fs.mkdirSync(out, { recursive: true });
|
|
46
|
+
const file = metricsPath(out);
|
|
47
|
+
pruneIfNeeded(file, nowMs);
|
|
48
|
+
fs.appendFileSync(file, `${JSON.stringify(event)}\n`, 'utf8');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Metrics logging must never break scans or MCP calls.
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function recordScanMetric(out, summary, incremental = false, now = new Date()) {
|
|
55
|
+
appendMetric(out, {
|
|
56
|
+
ts: now.toISOString(),
|
|
57
|
+
event: 'scan',
|
|
58
|
+
incremental,
|
|
59
|
+
files: summary.files,
|
|
60
|
+
parsed: summary.parsed,
|
|
61
|
+
reused: summary.reused,
|
|
62
|
+
symbols: summary.symbols,
|
|
63
|
+
rawTokens: summary.rawTokens,
|
|
64
|
+
skeletonTokens: summary.skeletonTokens,
|
|
65
|
+
durationMs: summary.durationMs,
|
|
66
|
+
failedCount: summary.failed.length,
|
|
67
|
+
languages: { ...summary.languages },
|
|
68
|
+
}, now.getTime());
|
|
69
|
+
}
|
|
70
|
+
export function recordMcpMetric(out, data, now = new Date()) {
|
|
71
|
+
appendMetric(out, {
|
|
72
|
+
ts: now.toISOString(),
|
|
73
|
+
event: 'mcp_call',
|
|
74
|
+
tool: data.tool,
|
|
75
|
+
...(data.zoom !== undefined ? { zoom: data.zoom } : {}),
|
|
76
|
+
durationMs: data.durationMs,
|
|
77
|
+
responseTokens: data.responseTokens,
|
|
78
|
+
ok: data.ok,
|
|
79
|
+
}, now.getTime());
|
|
80
|
+
}
|
|
81
|
+
export function readMetrics(out, days = 30, nowMs = Date.now()) {
|
|
82
|
+
const file = metricsPath(out);
|
|
83
|
+
if (!fs.existsSync(file))
|
|
84
|
+
return [];
|
|
85
|
+
const cutoff = nowMs - days * 24 * 60 * 60 * 1000;
|
|
86
|
+
const events = [];
|
|
87
|
+
for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
|
|
88
|
+
if (!line.trim())
|
|
89
|
+
continue;
|
|
90
|
+
try {
|
|
91
|
+
const parsed = JSON.parse(line);
|
|
92
|
+
const tsMs = Date.parse(parsed.ts);
|
|
93
|
+
if (!Number.isNaN(tsMs) && tsMs >= cutoff)
|
|
94
|
+
events.push(parsed);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Skip malformed lines.
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return events;
|
|
101
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface AtlasStats {
|
|
2
|
+
generatorVersion: string;
|
|
3
|
+
windowDays: number;
|
|
4
|
+
index: {
|
|
5
|
+
files: number;
|
|
6
|
+
parsedLanguages: Record<string, number>;
|
|
7
|
+
symbols: number;
|
|
8
|
+
failedFiles: number;
|
|
9
|
+
rawTokens: number;
|
|
10
|
+
skeletonTokens: number;
|
|
11
|
+
skeletonReductionPct: number;
|
|
12
|
+
zoom0Tokens: number;
|
|
13
|
+
zoom1Tokens: number;
|
|
14
|
+
zoom2Tokens: number;
|
|
15
|
+
zoom0ReductionPct: number;
|
|
16
|
+
zoom1ReductionPct: number;
|
|
17
|
+
entrypoints: number;
|
|
18
|
+
thrownExceptions: number;
|
|
19
|
+
roleTaggedFiles: number;
|
|
20
|
+
importCycles: number;
|
|
21
|
+
mcpSchemaTokens: number;
|
|
22
|
+
};
|
|
23
|
+
runtime: {
|
|
24
|
+
scansTotal: number;
|
|
25
|
+
medianFullScanMs: number | null;
|
|
26
|
+
medianRescanMs: number | null;
|
|
27
|
+
mcpCallsTotal: number;
|
|
28
|
+
mcpErrorRatePct: number;
|
|
29
|
+
mcpByTool: Record<string, number>;
|
|
30
|
+
medianMcpLatencyMs: number | null;
|
|
31
|
+
medianMcpResponseTokens: number | null;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export declare function computeStats(out: string, options?: {
|
|
35
|
+
days?: number;
|
|
36
|
+
nowMs?: number;
|
|
37
|
+
}): AtlasStats;
|
|
38
|
+
export declare function formatStats(stats: AtlasStats): string;
|
|
39
|
+
/**
|
|
40
|
+
* Generates a strictly anonymized Markdown benchmark card safe for public sharing.
|
|
41
|
+
* Contains zero repository names, file paths, symbol names, or user identifiers.
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatShareCard(stats: AtlasStats): string;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { MCP_TOOLS } from '../mcp/server.js';
|
|
2
|
+
import { readCodeMap, readTopology } from '../outputs.js';
|
|
3
|
+
import { renderMap } from '../queries/map.js';
|
|
4
|
+
import { estimateTokens } from '../tokens.js';
|
|
5
|
+
import { GENERATOR_VERSION } from '../version.js';
|
|
6
|
+
import { readMetrics } from './log.js';
|
|
7
|
+
function pctReduction(raw, reduced) {
|
|
8
|
+
if (raw <= 0)
|
|
9
|
+
return 0;
|
|
10
|
+
return Number((((raw - reduced) / raw) * 100).toFixed(1));
|
|
11
|
+
}
|
|
12
|
+
function median(values) {
|
|
13
|
+
if (values.length === 0)
|
|
14
|
+
return null;
|
|
15
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
16
|
+
const mid = Math.floor(sorted.length / 2);
|
|
17
|
+
return sorted.length % 2 === 1
|
|
18
|
+
? sorted[mid]
|
|
19
|
+
: Number(((sorted[mid - 1] + sorted[mid]) / 2).toFixed(1));
|
|
20
|
+
}
|
|
21
|
+
export function computeStats(out, options = {}) {
|
|
22
|
+
const days = options.days ?? 30;
|
|
23
|
+
const map = readCodeMap(out);
|
|
24
|
+
const topology = readTopology(out);
|
|
25
|
+
const events = readMetrics(out, days, options.nowMs);
|
|
26
|
+
const zoom0Tokens = estimateTokens(renderMap(map, { zoom: 0 }));
|
|
27
|
+
const zoom1Tokens = estimateTokens(renderMap(map, { zoom: 1 }));
|
|
28
|
+
const zoom2Tokens = estimateTokens(renderMap(map, { zoom: 2 }));
|
|
29
|
+
const mcpSchemaTokens = estimateTokens(JSON.stringify(MCP_TOOLS));
|
|
30
|
+
let entrypoints = 0;
|
|
31
|
+
let thrownExceptions = 0;
|
|
32
|
+
let roleTaggedFiles = 0;
|
|
33
|
+
for (const f of map.files) {
|
|
34
|
+
if (f.roles && f.roles.length > 0)
|
|
35
|
+
roleTaggedFiles++;
|
|
36
|
+
const walkSyms = (syms) => {
|
|
37
|
+
for (const s of syms) {
|
|
38
|
+
if (s.entrypoints)
|
|
39
|
+
entrypoints += s.entrypoints.length;
|
|
40
|
+
if (s.throws)
|
|
41
|
+
thrownExceptions += s.throws.length;
|
|
42
|
+
if (s.members)
|
|
43
|
+
walkSyms(s.members);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
walkSyms(f.symbols);
|
|
47
|
+
}
|
|
48
|
+
const parsedLanguages = {};
|
|
49
|
+
for (const [lang, count] of Object.entries(map.summary.languages)) {
|
|
50
|
+
if (lang !== 'other')
|
|
51
|
+
parsedLanguages[lang] = count;
|
|
52
|
+
}
|
|
53
|
+
const scans = events.filter((e) => e.event === 'scan');
|
|
54
|
+
const fullScans = scans.filter((s) => !s.incremental).map((s) => s.durationMs);
|
|
55
|
+
const rescans = scans.filter((s) => s.incremental).map((s) => s.durationMs);
|
|
56
|
+
const mcpCalls = events.filter((e) => e.event === 'mcp_call');
|
|
57
|
+
const mcpByTool = {};
|
|
58
|
+
let mcpErrors = 0;
|
|
59
|
+
for (const c of mcpCalls) {
|
|
60
|
+
mcpByTool[c.tool] = (mcpByTool[c.tool] ?? 0) + 1;
|
|
61
|
+
if (!c.ok)
|
|
62
|
+
mcpErrors++;
|
|
63
|
+
}
|
|
64
|
+
const rawTokens = map.summary.rawTokens;
|
|
65
|
+
const skeletonTokens = map.summary.skeletonTokens;
|
|
66
|
+
return {
|
|
67
|
+
generatorVersion: GENERATOR_VERSION,
|
|
68
|
+
windowDays: days,
|
|
69
|
+
index: {
|
|
70
|
+
files: map.summary.files,
|
|
71
|
+
parsedLanguages,
|
|
72
|
+
symbols: map.summary.symbols,
|
|
73
|
+
failedFiles: map.summary.failed.length,
|
|
74
|
+
rawTokens,
|
|
75
|
+
skeletonTokens,
|
|
76
|
+
skeletonReductionPct: pctReduction(rawTokens, skeletonTokens),
|
|
77
|
+
zoom0Tokens,
|
|
78
|
+
zoom1Tokens,
|
|
79
|
+
zoom2Tokens,
|
|
80
|
+
zoom0ReductionPct: pctReduction(rawTokens, zoom0Tokens),
|
|
81
|
+
zoom1ReductionPct: pctReduction(rawTokens, zoom1Tokens),
|
|
82
|
+
entrypoints,
|
|
83
|
+
thrownExceptions,
|
|
84
|
+
roleTaggedFiles,
|
|
85
|
+
importCycles: topology.summary.circularDependencies.length,
|
|
86
|
+
mcpSchemaTokens,
|
|
87
|
+
},
|
|
88
|
+
runtime: {
|
|
89
|
+
scansTotal: scans.length,
|
|
90
|
+
medianFullScanMs: median(fullScans),
|
|
91
|
+
medianRescanMs: median(rescans),
|
|
92
|
+
mcpCallsTotal: mcpCalls.length,
|
|
93
|
+
mcpErrorRatePct: mcpCalls.length ? Number(((mcpErrors / mcpCalls.length) * 100).toFixed(1)) : 0,
|
|
94
|
+
mcpByTool,
|
|
95
|
+
medianMcpLatencyMs: median(mcpCalls.map((c) => c.durationMs)),
|
|
96
|
+
medianMcpResponseTokens: median(mcpCalls.map((c) => c.responseTokens)),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function fmtNum(n) {
|
|
101
|
+
return n.toLocaleString('en-US');
|
|
102
|
+
}
|
|
103
|
+
export function formatStats(stats) {
|
|
104
|
+
const { index: idx, runtime: rt } = stats;
|
|
105
|
+
const langs = Object.entries(idx.parsedLanguages)
|
|
106
|
+
.sort((a, b) => b[1] - a[1])
|
|
107
|
+
.map(([l, n]) => `${l} (${n})`)
|
|
108
|
+
.join(', ') || 'none';
|
|
109
|
+
const lines = [
|
|
110
|
+
`FaberSEP Atlas v${stats.generatorVersion} — Local Stats (last ${stats.windowDays}d, 100% local / zero telemetry)`,
|
|
111
|
+
'',
|
|
112
|
+
'Index & Token Compression:',
|
|
113
|
+
` Files: ${fmtNum(idx.files)} (${langs})`,
|
|
114
|
+
` Declarations: ${fmtNum(idx.symbols)}`,
|
|
115
|
+
` Source tokens: ${fmtNum(idx.rawTokens)}`,
|
|
116
|
+
` Skeleton tokens: ${fmtNum(idx.skeletonTokens)} (-${idx.skeletonReductionPct}%)`,
|
|
117
|
+
` Zoom 0 map: ${fmtNum(idx.zoom0Tokens)} tokens (-${idx.zoom0ReductionPct}%)`,
|
|
118
|
+
` Zoom 1 map: ${fmtNum(idx.zoom1Tokens)} tokens (-${idx.zoom1ReductionPct}%)`,
|
|
119
|
+
` Zoom 2 map: ${fmtNum(idx.zoom2Tokens)} tokens`,
|
|
120
|
+
` AST signals: ${fmtNum(idx.entrypoints)} entrypoints, ${fmtNum(idx.thrownExceptions)} throws, ${fmtNum(idx.roleTaggedFiles)} role-tagged files`,
|
|
121
|
+
` Import cycles: ${idx.importCycles}`,
|
|
122
|
+
` MCP schema cost: ~${fmtNum(idx.mcpSchemaTokens)} tokens (7 tools)`,
|
|
123
|
+
'',
|
|
124
|
+
`Runtime Activity (${stats.windowDays}d):`,
|
|
125
|
+
` Scans recorded: ${rt.scansTotal}` +
|
|
126
|
+
(rt.medianFullScanMs !== null ? ` | median full: ${rt.medianFullScanMs} ms` : '') +
|
|
127
|
+
(rt.medianRescanMs !== null ? ` | median rescan: ${rt.medianRescanMs} ms` : ''),
|
|
128
|
+
` MCP calls: ${rt.mcpCallsTotal}` +
|
|
129
|
+
(rt.mcpCallsTotal > 0
|
|
130
|
+
? ` | error rate: ${rt.mcpErrorRatePct}% | median latency: ${rt.medianMcpLatencyMs} ms | median response: ${rt.medianMcpResponseTokens} tokens`
|
|
131
|
+
: ''),
|
|
132
|
+
];
|
|
133
|
+
const tools = Object.entries(rt.mcpByTool).sort((a, b) => b[1] - a[1]);
|
|
134
|
+
if (tools.length > 0) {
|
|
135
|
+
lines.push(` Tools used: ${tools.map(([t, n]) => `${t}=${n}`).join(', ')}`);
|
|
136
|
+
}
|
|
137
|
+
return lines.join('\n');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Generates a strictly anonymized Markdown benchmark card safe for public sharing.
|
|
141
|
+
* Contains zero repository names, file paths, symbol names, or user identifiers.
|
|
142
|
+
*/
|
|
143
|
+
export function formatShareCard(stats) {
|
|
144
|
+
const { index: idx, runtime: rt } = stats;
|
|
145
|
+
const langs = Object.entries(idx.parsedLanguages)
|
|
146
|
+
.sort((a, b) => b[1] - a[1])
|
|
147
|
+
.map(([l, n]) => `${l}: ${n}`)
|
|
148
|
+
.join(', ') || 'none';
|
|
149
|
+
const rows = [
|
|
150
|
+
`### FaberSEP Atlas Benchmark Card (\`@fabersep/atlas\` v${stats.generatorVersion})`,
|
|
151
|
+
'',
|
|
152
|
+
'| Metric | Value |',
|
|
153
|
+
'| :--- | ---: |',
|
|
154
|
+
`| Files / Declarations | ${fmtNum(idx.files)} files / ${fmtNum(idx.symbols)} symbols |`,
|
|
155
|
+
`| Languages | ${langs} |`,
|
|
156
|
+
`| Raw Source → Skeleton | ${fmtNum(idx.rawTokens)} → ${fmtNum(idx.skeletonTokens)} tokens (**-${idx.skeletonReductionPct}%**) |`,
|
|
157
|
+
`| Layered Map (\`zoom 0\` / \`zoom 1\` / \`zoom 2\`) | ${fmtNum(idx.zoom0Tokens)} / ${fmtNum(idx.zoom1Tokens)} / ${fmtNum(idx.zoom2Tokens)} tokens |`,
|
|
158
|
+
`| AST Signals | ${fmtNum(idx.entrypoints)} entrypoints, ${fmtNum(idx.thrownExceptions)} throws, ${fmtNum(idx.roleTaggedFiles)} role-tagged files |`,
|
|
159
|
+
`| MCP Schema Footprint | ~${fmtNum(idx.mcpSchemaTokens)} tokens (7 tools) |`,
|
|
160
|
+
];
|
|
161
|
+
if (rt.medianFullScanMs !== null || rt.medianRescanMs !== null) {
|
|
162
|
+
const full = rt.medianFullScanMs !== null ? `${rt.medianFullScanMs} ms` : 'n/a';
|
|
163
|
+
const inc = rt.medianRescanMs !== null ? `${rt.medianRescanMs} ms` : 'n/a';
|
|
164
|
+
rows.push(`| Median Scan (full / incremental) | ${full} / ${inc} |`);
|
|
165
|
+
}
|
|
166
|
+
if (rt.mcpCallsTotal > 0) {
|
|
167
|
+
rows.push(`| MCP Calls (${stats.windowDays}d) | ${fmtNum(rt.mcpCallsTotal)} calls, median ${rt.medianMcpLatencyMs} ms, median ${rt.medianMcpResponseTokens} tokens |`);
|
|
168
|
+
}
|
|
169
|
+
rows.push('');
|
|
170
|
+
rows.push('_Generated 100% locally with `faber-atlas stats --share` — zero telemetry, no paths or code included._');
|
|
171
|
+
return rows.join('\n');
|
|
172
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/** The shapes of the published outputs (`schema/*.schema.json`). A breaking change is a new major version. */
|
|
2
|
+
export type SymbolKind = 'class' | 'interface' | 'enum' | 'mixin' | 'extension' | 'type' | 'function' | 'variable' | 'method' | 'constructor' | 'field' | 'getter' | 'setter' | 'enumMember';
|
|
3
|
+
export type Visibility = 'public' | 'protected' | 'private';
|
|
4
|
+
/** Closed-vocabulary structural role tags inferred deterministically from AST, decorators/attributes, and imports. */
|
|
5
|
+
export type RoleTag = 'http' | 'event' | 'job' | 'db' | 'auth' | 'ui' | 'io';
|
|
6
|
+
export type CallKind = 'calls' | 'emits' | 'queues' | 'sends';
|
|
7
|
+
export type ExternalBoundary = 'db' | 'http' | 'queue' | 'fs';
|
|
8
|
+
/** One static call or async/indirect wiring site extracted from a callable declaration. */
|
|
9
|
+
export interface CallSite {
|
|
10
|
+
/** Receiver + method or bare function name (e.g. `this.albumRepository.delete`, `helperFn`). */
|
|
11
|
+
callee: string;
|
|
12
|
+
/** Receiver field or variable name if member call (e.g. `albumRepository`, `_repo`, `this`). */
|
|
13
|
+
receiver?: string;
|
|
14
|
+
/** Resolved receiver type name if locally known from class fields/params (e.g. `AlbumRepository`). */
|
|
15
|
+
receiverType?: string;
|
|
16
|
+
/** Method or function name (e.g. `delete`, `helperFn`). */
|
|
17
|
+
method: string;
|
|
18
|
+
/** 1-based line number of the call expression. */
|
|
19
|
+
line: number;
|
|
20
|
+
/** Edge kind: direct call, event emission, job queue, or MediatR command/notification send. */
|
|
21
|
+
kind: CallKind;
|
|
22
|
+
/** Event name, job name, or command/notification type name for `emits` / `queues` / `sends`. */
|
|
23
|
+
targetKey?: string;
|
|
24
|
+
/** External boundary tag if the call hits DB, HTTP, queue, or filesystem. */
|
|
25
|
+
boundary?: ExternalBoundary;
|
|
26
|
+
}
|
|
27
|
+
/** One declaration. Containers (class, interface, enum, mixin, extension) hold their members. */
|
|
28
|
+
export interface SymbolNode {
|
|
29
|
+
kind: SymbolKind;
|
|
30
|
+
name: string;
|
|
31
|
+
/** The declaration on one line, without its body or initializer. */
|
|
32
|
+
signature: string;
|
|
33
|
+
/** A field's declared type, or a function's return type, when the source states it. */
|
|
34
|
+
type?: string;
|
|
35
|
+
lineStart: number;
|
|
36
|
+
lineEnd: number;
|
|
37
|
+
/** A function, method, constructor, getter or setter: its deepest nesting of control-flow blocks (FR-07). */
|
|
38
|
+
nesting?: number;
|
|
39
|
+
/** Top level: exported from the file. Members: visible outside the class (public). */
|
|
40
|
+
exported: boolean;
|
|
41
|
+
visibility: Visibility;
|
|
42
|
+
static?: boolean;
|
|
43
|
+
/** A framework callback such as `build` or `render`, left out of the map text. */
|
|
44
|
+
lifecycle?: boolean;
|
|
45
|
+
/** Entrypoints declared via decorators/attributes (e.g. `GET /:id`, `event:UserDelete`, `job:Thumbnail`). */
|
|
46
|
+
entrypoints?: string[];
|
|
47
|
+
/** Exception/error types instantiated in `throw` statements inside this declaration. */
|
|
48
|
+
throws?: string[];
|
|
49
|
+
/** Static call and async wiring sites inside this callable declaration. */
|
|
50
|
+
calls?: CallSite[];
|
|
51
|
+
extends?: string[];
|
|
52
|
+
implements?: string[];
|
|
53
|
+
mixins?: string[];
|
|
54
|
+
members?: SymbolNode[];
|
|
55
|
+
}
|
|
56
|
+
export type ImportKind = 'file' | 'package' | 'builtin' | 'unresolved';
|
|
57
|
+
export interface ImportRef {
|
|
58
|
+
specifier: string;
|
|
59
|
+
line: number;
|
|
60
|
+
typeOnly?: boolean;
|
|
61
|
+
kind: ImportKind;
|
|
62
|
+
/** The project file it resolves to (`kind: file`). */
|
|
63
|
+
target?: string;
|
|
64
|
+
/** The package name (`kind: package`), for the dependency audit. */
|
|
65
|
+
package?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface DeclaredDependency {
|
|
68
|
+
name: string;
|
|
69
|
+
version: string;
|
|
70
|
+
dev: boolean;
|
|
71
|
+
/** Declared through an SDK (`sdk: flutter`), never imported by name. */
|
|
72
|
+
sdk?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface FileRecord {
|
|
75
|
+
path: string;
|
|
76
|
+
language: string;
|
|
77
|
+
sizeBytes: number;
|
|
78
|
+
mtimeMs: number;
|
|
79
|
+
symbols: SymbolNode[];
|
|
80
|
+
imports: ImportRef[];
|
|
81
|
+
skeleton: string;
|
|
82
|
+
rawTokens: number;
|
|
83
|
+
skeletonTokens: number;
|
|
84
|
+
/** The parse error; the file then has no symbols. */
|
|
85
|
+
error?: string;
|
|
86
|
+
/** Why the file was not parsed (too large). */
|
|
87
|
+
skipped?: string;
|
|
88
|
+
/** Dependencies a manifest file declares. */
|
|
89
|
+
declares?: DeclaredDependency[];
|
|
90
|
+
/** Closed-vocabulary structural roles inferred for this file. */
|
|
91
|
+
roles?: RoleTag[];
|
|
92
|
+
}
|
|
93
|
+
export interface AuditEntry {
|
|
94
|
+
name: string;
|
|
95
|
+
manifest: string;
|
|
96
|
+
version: string;
|
|
97
|
+
dev: boolean;
|
|
98
|
+
dormant: boolean;
|
|
99
|
+
importCount: number;
|
|
100
|
+
files: string[];
|
|
101
|
+
}
|
|
102
|
+
export interface ScanSummary {
|
|
103
|
+
files: number;
|
|
104
|
+
parsed: number;
|
|
105
|
+
reused: number;
|
|
106
|
+
failed: Array<{
|
|
107
|
+
path: string;
|
|
108
|
+
error: string;
|
|
109
|
+
}>;
|
|
110
|
+
/** Files no pack claims, by extension (or file name when it has none). */
|
|
111
|
+
unsupported: Record<string, number>;
|
|
112
|
+
languages: Record<string, number>;
|
|
113
|
+
symbols: number;
|
|
114
|
+
rawTokens: number;
|
|
115
|
+
skeletonTokens: number;
|
|
116
|
+
durationMs: number;
|
|
117
|
+
}
|
|
118
|
+
export interface Generator {
|
|
119
|
+
schemaVersion: number;
|
|
120
|
+
generatorVersion: string;
|
|
121
|
+
generatedAt: string;
|
|
122
|
+
}
|
|
123
|
+
export interface CodeMap extends Generator {
|
|
124
|
+
/** The scanned folder's name, the root of the map text. */
|
|
125
|
+
rootName: string;
|
|
126
|
+
summary: ScanSummary;
|
|
127
|
+
files: FileRecord[];
|
|
128
|
+
audit: AuditEntry[];
|
|
129
|
+
}
|
|
130
|
+
export type NodeType = 'file' | 'class' | 'interface' | 'enum' | 'mixin' | 'extension' | 'type' | 'function';
|
|
131
|
+
export type EdgeType = 'imports' | 'defines' | 'extends' | 'implements';
|
|
132
|
+
export interface GraphNode {
|
|
133
|
+
id: string;
|
|
134
|
+
label: string;
|
|
135
|
+
path: string;
|
|
136
|
+
type: NodeType;
|
|
137
|
+
language?: string;
|
|
138
|
+
line?: number;
|
|
139
|
+
tokenEstimate?: number;
|
|
140
|
+
inDegree: number;
|
|
141
|
+
outDegree: number;
|
|
142
|
+
/** In-degree twice plus out-degree, over import edges for files. */
|
|
143
|
+
centralityScore: number;
|
|
144
|
+
pageRank: number;
|
|
145
|
+
cluster: string;
|
|
146
|
+
}
|
|
147
|
+
export interface GraphEdge {
|
|
148
|
+
source: string;
|
|
149
|
+
target: string;
|
|
150
|
+
type: EdgeType;
|
|
151
|
+
}
|
|
152
|
+
export interface Hub {
|
|
153
|
+
id: string;
|
|
154
|
+
path: string;
|
|
155
|
+
inDegree: number;
|
|
156
|
+
outDegree: number;
|
|
157
|
+
centralityScore: number;
|
|
158
|
+
pageRank: number;
|
|
159
|
+
}
|
|
160
|
+
export interface Topology extends Generator {
|
|
161
|
+
summary: {
|
|
162
|
+
totalFiles: number;
|
|
163
|
+
totalSymbols: number;
|
|
164
|
+
totalNodes: number;
|
|
165
|
+
totalEdges: number;
|
|
166
|
+
density: number;
|
|
167
|
+
circularDependencies: Array<{
|
|
168
|
+
cycle: string[];
|
|
169
|
+
}>;
|
|
170
|
+
clusters: Array<{
|
|
171
|
+
name: string;
|
|
172
|
+
nodeCount: number;
|
|
173
|
+
}>;
|
|
174
|
+
topHubs: Hub[];
|
|
175
|
+
};
|
|
176
|
+
nodes: GraphNode[];
|
|
177
|
+
edges: GraphEdge[];
|
|
178
|
+
}
|