@monoes/monomindcli 1.6.4 → 1.6.6
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/.claude/helpers/graphify-freshen.cjs +10 -1
- package/bundled-graph/dist/src/analyze.d.ts +32 -0
- package/bundled-graph/dist/src/analyze.d.ts.map +1 -0
- package/bundled-graph/dist/src/analyze.js +297 -0
- package/bundled-graph/dist/src/analyze.js.map +1 -0
- package/bundled-graph/dist/src/build.d.ts +8 -0
- package/bundled-graph/dist/src/build.d.ts.map +1 -0
- package/bundled-graph/dist/src/build.js +73 -0
- package/bundled-graph/dist/src/build.js.map +1 -0
- package/bundled-graph/dist/src/cache.d.ts +12 -0
- package/bundled-graph/dist/src/cache.d.ts.map +1 -0
- package/bundled-graph/dist/src/cache.js +43 -0
- package/bundled-graph/dist/src/cache.js.map +1 -0
- package/bundled-graph/dist/src/cluster.d.ts +5 -0
- package/bundled-graph/dist/src/cluster.d.ts.map +1 -0
- package/bundled-graph/dist/src/cluster.js +120 -0
- package/bundled-graph/dist/src/cluster.js.map +1 -0
- package/bundled-graph/dist/src/detect.d.ts +21 -0
- package/bundled-graph/dist/src/detect.d.ts.map +1 -0
- package/bundled-graph/dist/src/detect.js +195 -0
- package/bundled-graph/dist/src/detect.js.map +1 -0
- package/bundled-graph/dist/src/export.d.ts +21 -0
- package/bundled-graph/dist/src/export.d.ts.map +1 -0
- package/bundled-graph/dist/src/export.js +68 -0
- package/bundled-graph/dist/src/export.js.map +1 -0
- package/bundled-graph/dist/src/extract/index.d.ts +20 -0
- package/bundled-graph/dist/src/extract/index.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/index.js +158 -0
- package/bundled-graph/dist/src/extract/index.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/c.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/c.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/c.js +88 -0
- package/bundled-graph/dist/src/extract/languages/c.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/cpp.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/cpp.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/cpp.js +121 -0
- package/bundled-graph/dist/src/extract/languages/cpp.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/csharp.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/csharp.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/csharp.js +121 -0
- package/bundled-graph/dist/src/extract/languages/csharp.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/go.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/go.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/go.js +181 -0
- package/bundled-graph/dist/src/extract/languages/go.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/java.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/java.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/java.js +117 -0
- package/bundled-graph/dist/src/extract/languages/java.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/kotlin.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/kotlin.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/kotlin.js +112 -0
- package/bundled-graph/dist/src/extract/languages/kotlin.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/php.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/php.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/php.js +130 -0
- package/bundled-graph/dist/src/extract/languages/php.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/python.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/python.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/python.js +230 -0
- package/bundled-graph/dist/src/extract/languages/python.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/ruby.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/ruby.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/ruby.js +120 -0
- package/bundled-graph/dist/src/extract/languages/ruby.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/rust.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/rust.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/rust.js +195 -0
- package/bundled-graph/dist/src/extract/languages/rust.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/scala.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/scala.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/scala.js +110 -0
- package/bundled-graph/dist/src/extract/languages/scala.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/swift.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/swift.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/swift.js +122 -0
- package/bundled-graph/dist/src/extract/languages/swift.js.map +1 -0
- package/bundled-graph/dist/src/extract/languages/typescript.d.ts +3 -0
- package/bundled-graph/dist/src/extract/languages/typescript.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/languages/typescript.js +295 -0
- package/bundled-graph/dist/src/extract/languages/typescript.js.map +1 -0
- package/bundled-graph/dist/src/extract/semantic.d.ts +38 -0
- package/bundled-graph/dist/src/extract/semantic.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/semantic.js +242 -0
- package/bundled-graph/dist/src/extract/semantic.js.map +1 -0
- package/bundled-graph/dist/src/extract/tree-sitter-runner.d.ts +48 -0
- package/bundled-graph/dist/src/extract/tree-sitter-runner.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/tree-sitter-runner.js +137 -0
- package/bundled-graph/dist/src/extract/tree-sitter-runner.js.map +1 -0
- package/bundled-graph/dist/src/extract/types.d.ts +7 -0
- package/bundled-graph/dist/src/extract/types.d.ts.map +1 -0
- package/bundled-graph/dist/src/extract/types.js +2 -0
- package/bundled-graph/dist/src/extract/types.js.map +1 -0
- package/bundled-graph/dist/src/index.d.ts +28 -0
- package/bundled-graph/dist/src/index.d.ts.map +1 -0
- package/bundled-graph/dist/src/index.js +26 -0
- package/bundled-graph/dist/src/index.js.map +1 -0
- package/bundled-graph/dist/src/pipeline.d.ts +27 -0
- package/bundled-graph/dist/src/pipeline.d.ts.map +1 -0
- package/bundled-graph/dist/src/pipeline.js +269 -0
- package/bundled-graph/dist/src/pipeline.js.map +1 -0
- package/bundled-graph/dist/src/report.d.ts +26 -0
- package/bundled-graph/dist/src/report.d.ts.map +1 -0
- package/bundled-graph/dist/src/report.js +214 -0
- package/bundled-graph/dist/src/report.js.map +1 -0
- package/bundled-graph/dist/src/types.d.ts +124 -0
- package/bundled-graph/dist/src/types.d.ts.map +1 -0
- package/bundled-graph/dist/src/types.js +2 -0
- package/bundled-graph/dist/src/types.js.map +1 -0
- package/bundled-graph/dist/src/visualize.d.ts +4 -0
- package/bundled-graph/dist/src/visualize.d.ts.map +1 -0
- package/bundled-graph/dist/src/visualize.js +574 -0
- package/bundled-graph/dist/src/visualize.js.map +1 -0
- package/bundled-graph/dist/tsconfig.tsbuildinfo +1 -0
- package/bundled-graph/package.json +57 -0
- package/package.json +9 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ExtractionResult } from '../types.js';
|
|
2
|
+
import type { LanguageExtractor } from './types.js';
|
|
3
|
+
type ParserInstance = {
|
|
4
|
+
setLanguage(lang: unknown): void;
|
|
5
|
+
parse(src: string): {
|
|
6
|
+
rootNode: SyntaxNodeLike;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type SyntaxNodeLike = {
|
|
10
|
+
type: string;
|
|
11
|
+
text: string;
|
|
12
|
+
startPosition: {
|
|
13
|
+
row: number;
|
|
14
|
+
column: number;
|
|
15
|
+
};
|
|
16
|
+
endPosition: {
|
|
17
|
+
row: number;
|
|
18
|
+
column: number;
|
|
19
|
+
};
|
|
20
|
+
children: SyntaxNodeLike[];
|
|
21
|
+
childForFieldName(name: string): SyntaxNodeLike | null;
|
|
22
|
+
descendantsOfType(type: string | string[]): SyntaxNodeLike[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Returns true when node-tree-sitter is installed and loadable.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isTreeSitterAvailable(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Attempts to create a configured Parser for the given language identifier.
|
|
30
|
+
* Returns null when tree-sitter or the grammar is not installed.
|
|
31
|
+
*/
|
|
32
|
+
export declare function tryLoadParser(language: string): ParserInstance | null;
|
|
33
|
+
export declare function walk(node: SyntaxNodeLike, visitor: (n: SyntaxNodeLike) => void): void;
|
|
34
|
+
/**
|
|
35
|
+
* Parses a source file and delegates to the given LanguageExtractor.
|
|
36
|
+
* The extractor receives the file path and raw content; it owns the AST
|
|
37
|
+
* traversal internally (using tryLoadParser / walk from this module).
|
|
38
|
+
*
|
|
39
|
+
* Falls back gracefully: if tree-sitter cannot be loaded the extractor is still
|
|
40
|
+
* called with the raw content and is expected to use its regex fallback.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseFile(filePath: string, content: string, extractor: LanguageExtractor): ExtractionResult;
|
|
43
|
+
/**
|
|
44
|
+
* Convenience helper: read a file from disk and parse it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseFileFromDisk(filePath: string, extractor: LanguageExtractor): ExtractionResult;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=tree-sitter-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-sitter-runner.d.ts","sourceRoot":"","sources":["../../../src/extract/tree-sitter-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD,KAAK,cAAc,GAAG;IACpB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,cAAc,CAAA;KAAE,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;IACvD,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;CAC9D,CAAC;AA4BF;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAG/C;AAuBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CA2BrE;AAID,wBAAgB,IAAI,CAClB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,GACnC,IAAI,CAKN;AAID;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,iBAAiB,GAC3B,gBAAgB,CAclB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,iBAAiB,GAC3B,gBAAgB,CAgBlB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
// ---- availability probe ----
|
|
3
|
+
let _treeSitterAvailable = null;
|
|
4
|
+
let _ParserCtor = null;
|
|
5
|
+
function probeTreeSitter() {
|
|
6
|
+
if (_treeSitterAvailable !== null)
|
|
7
|
+
return;
|
|
8
|
+
try {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const mod = require('node-tree-sitter');
|
|
11
|
+
const ctor = mod.default !== undefined
|
|
12
|
+
? mod.default
|
|
13
|
+
: mod;
|
|
14
|
+
if (typeof ctor === 'function') {
|
|
15
|
+
_ParserCtor = ctor;
|
|
16
|
+
_treeSitterAvailable = true;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
_treeSitterAvailable = false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
_treeSitterAvailable = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns true when node-tree-sitter is installed and loadable.
|
|
28
|
+
*/
|
|
29
|
+
export function isTreeSitterAvailable() {
|
|
30
|
+
probeTreeSitter();
|
|
31
|
+
return _treeSitterAvailable === true;
|
|
32
|
+
}
|
|
33
|
+
// ---- language grammar loader ----
|
|
34
|
+
const LANGUAGE_MODULE_MAP = {
|
|
35
|
+
typescript: 'tree-sitter-typescript',
|
|
36
|
+
tsx: 'tree-sitter-typescript',
|
|
37
|
+
javascript: 'tree-sitter-javascript',
|
|
38
|
+
jsx: 'tree-sitter-javascript',
|
|
39
|
+
python: 'tree-sitter-python',
|
|
40
|
+
go: 'tree-sitter-go',
|
|
41
|
+
rust: 'tree-sitter-rust',
|
|
42
|
+
java: 'tree-sitter-java',
|
|
43
|
+
c: 'tree-sitter-c',
|
|
44
|
+
cpp: 'tree-sitter-cpp',
|
|
45
|
+
csharp: 'tree-sitter-c-sharp',
|
|
46
|
+
ruby: 'tree-sitter-ruby',
|
|
47
|
+
kotlin: 'tree-sitter-kotlin',
|
|
48
|
+
swift: 'tree-sitter-swift',
|
|
49
|
+
scala: 'tree-sitter-scala',
|
|
50
|
+
php: 'tree-sitter-php',
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Attempts to create a configured Parser for the given language identifier.
|
|
54
|
+
* Returns null when tree-sitter or the grammar is not installed.
|
|
55
|
+
*/
|
|
56
|
+
export function tryLoadParser(language) {
|
|
57
|
+
if (!isTreeSitterAvailable() || _ParserCtor === null)
|
|
58
|
+
return null;
|
|
59
|
+
const moduleName = LANGUAGE_MODULE_MAP[language];
|
|
60
|
+
if (!moduleName)
|
|
61
|
+
return null;
|
|
62
|
+
try {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
64
|
+
const grammarMod = require(moduleName);
|
|
65
|
+
// tree-sitter-typescript exposes { typescript, tsx } sub-grammars
|
|
66
|
+
let grammar;
|
|
67
|
+
if (language === 'typescript' || language === 'tsx') {
|
|
68
|
+
grammar =
|
|
69
|
+
grammarMod[language] ??
|
|
70
|
+
grammarMod['default'] ??
|
|
71
|
+
grammarMod;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
grammar = grammarMod['default'] ?? grammarMod;
|
|
75
|
+
}
|
|
76
|
+
const parser = new _ParserCtor();
|
|
77
|
+
parser.setLanguage(grammar);
|
|
78
|
+
return parser;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// ---- depth-first AST walker ----
|
|
85
|
+
export function walk(node, visitor) {
|
|
86
|
+
visitor(node);
|
|
87
|
+
for (const child of node.children) {
|
|
88
|
+
walk(child, visitor);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// ---- main entry point ----
|
|
92
|
+
/**
|
|
93
|
+
* Parses a source file and delegates to the given LanguageExtractor.
|
|
94
|
+
* The extractor receives the file path and raw content; it owns the AST
|
|
95
|
+
* traversal internally (using tryLoadParser / walk from this module).
|
|
96
|
+
*
|
|
97
|
+
* Falls back gracefully: if tree-sitter cannot be loaded the extractor is still
|
|
98
|
+
* called with the raw content and is expected to use its regex fallback.
|
|
99
|
+
*/
|
|
100
|
+
export function parseFile(filePath, content, extractor) {
|
|
101
|
+
try {
|
|
102
|
+
return extractor.extract(filePath, content);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
return {
|
|
106
|
+
nodes: [],
|
|
107
|
+
edges: [],
|
|
108
|
+
filesProcessed: 1,
|
|
109
|
+
fromCache: 0,
|
|
110
|
+
errors: [
|
|
111
|
+
`parseFile error for ${filePath}: ${err instanceof Error ? err.message : String(err)}`,
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Convenience helper: read a file from disk and parse it.
|
|
118
|
+
*/
|
|
119
|
+
export function parseFileFromDisk(filePath, extractor) {
|
|
120
|
+
let content;
|
|
121
|
+
try {
|
|
122
|
+
content = readFileSync(filePath, 'utf8');
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
return {
|
|
126
|
+
nodes: [],
|
|
127
|
+
edges: [],
|
|
128
|
+
filesProcessed: 1,
|
|
129
|
+
fromCache: 0,
|
|
130
|
+
errors: [
|
|
131
|
+
`Failed to read ${filePath}: ${err instanceof Error ? err.message : String(err)}`,
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return parseFile(filePath, content, extractor);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=tree-sitter-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-sitter-runner.js","sourceRoot":"","sources":["../../../src/extract/tree-sitter-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAqBlC,+BAA+B;AAE/B,IAAI,oBAAoB,GAAmB,IAAI,CAAC;AAChD,IAAI,WAAW,GAAsC,IAAI,CAAC;AAE1D,SAAS,eAAe;IACtB,IAAI,oBAAoB,KAAK,IAAI;QAAE,OAAO;IAE1C,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,kBAAkB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AG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;aACvF;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,SAA4B;IAE5B,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,EAAE;YACT,cAAc,EAAE,CAAC;YACjB,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE;gBACN,kBAAkB,QAAQ,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;aAClF;SACF,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extract/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extract/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { buildGraph } from './pipeline.js';
|
|
2
|
+
export { FileCache } from './cache.js';
|
|
3
|
+
export { collectFiles, loadIgnorePatterns, corpusHealth } from './detect.js';
|
|
4
|
+
export { buildGraph as buildGraphologyGraph } from './build.js';
|
|
5
|
+
export { detectCommunities, cohesionScore, splitOversizedCommunities } from './cluster.js';
|
|
6
|
+
export { buildAnalysis, godNodes, surprisingConnections, graphStats, suggestQuestions, graphDiff } from './analyze.js';
|
|
7
|
+
export { saveGraph, loadGraph, graphExists, getGraphPath } from './export.js';
|
|
8
|
+
export { exportHTML } from './visualize.js';
|
|
9
|
+
export { generateReport } from './report.js';
|
|
10
|
+
export { extractSemantic } from './extract/semantic.js';
|
|
11
|
+
export type { SemanticFile, SemanticOptions } from './extract/semantic.js';
|
|
12
|
+
export { isTreeSitterAvailable, tryLoadParser, parseFile, parseFileFromDisk } from './extract/tree-sitter-runner.js';
|
|
13
|
+
export type { LanguageExtractor } from './extract/types.js';
|
|
14
|
+
export { typescriptExtractor } from './extract/languages/typescript.js';
|
|
15
|
+
export { pythonExtractor } from './extract/languages/python.js';
|
|
16
|
+
export { goExtractor } from './extract/languages/go.js';
|
|
17
|
+
export { rustExtractor } from './extract/languages/rust.js';
|
|
18
|
+
export { javaExtractor } from './extract/languages/java.js';
|
|
19
|
+
export { cExtractor } from './extract/languages/c.js';
|
|
20
|
+
export { cppExtractor } from './extract/languages/cpp.js';
|
|
21
|
+
export { csharpExtractor } from './extract/languages/csharp.js';
|
|
22
|
+
export { rubyExtractor } from './extract/languages/ruby.js';
|
|
23
|
+
export { kotlinExtractor } from './extract/languages/kotlin.js';
|
|
24
|
+
export { swiftExtractor } from './extract/languages/swift.js';
|
|
25
|
+
export { scalaExtractor } from './extract/languages/scala.js';
|
|
26
|
+
export { phpExtractor } from './extract/languages/php.js';
|
|
27
|
+
export type * from './types.js';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA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AAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,mBAAmB,YAAY,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { buildGraph } from './pipeline.js';
|
|
2
|
+
export { FileCache } from './cache.js';
|
|
3
|
+
export { collectFiles, loadIgnorePatterns, corpusHealth } from './detect.js';
|
|
4
|
+
export { buildGraph as buildGraphologyGraph } from './build.js';
|
|
5
|
+
export { detectCommunities, cohesionScore, splitOversizedCommunities } from './cluster.js';
|
|
6
|
+
export { buildAnalysis, godNodes, surprisingConnections, graphStats, suggestQuestions, graphDiff } from './analyze.js';
|
|
7
|
+
export { saveGraph, loadGraph, graphExists, getGraphPath } from './export.js';
|
|
8
|
+
export { exportHTML } from './visualize.js';
|
|
9
|
+
export { generateReport } from './report.js';
|
|
10
|
+
export { extractSemantic } from './extract/semantic.js';
|
|
11
|
+
export { isTreeSitterAvailable, tryLoadParser, parseFile, parseFileFromDisk } from './extract/tree-sitter-runner.js';
|
|
12
|
+
// Language extractors
|
|
13
|
+
export { typescriptExtractor } from './extract/languages/typescript.js';
|
|
14
|
+
export { pythonExtractor } from './extract/languages/python.js';
|
|
15
|
+
export { goExtractor } from './extract/languages/go.js';
|
|
16
|
+
export { rustExtractor } from './extract/languages/rust.js';
|
|
17
|
+
export { javaExtractor } from './extract/languages/java.js';
|
|
18
|
+
export { cExtractor } from './extract/languages/c.js';
|
|
19
|
+
export { cppExtractor } from './extract/languages/cpp.js';
|
|
20
|
+
export { csharpExtractor } from './extract/languages/csharp.js';
|
|
21
|
+
export { rubyExtractor } from './extract/languages/ruby.js';
|
|
22
|
+
export { kotlinExtractor } from './extract/languages/kotlin.js';
|
|
23
|
+
export { swiftExtractor } from './extract/languages/swift.js';
|
|
24
|
+
export { scalaExtractor } from './extract/languages/scala.js';
|
|
25
|
+
export { phpExtractor } from './extract/languages/php.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACvH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAErH,sBAAsB;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BuildOptions, GraphAnalysis, SerializedGraph, GraphQuestion } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Main entry point for building a knowledge graph from a codebase.
|
|
4
|
+
*
|
|
5
|
+
* Orchestrates file collection, per-file extraction (with caching),
|
|
6
|
+
* graph construction via graphology, community detection, and serialisation.
|
|
7
|
+
*
|
|
8
|
+
* @param projectPath - Absolute path to the root of the codebase to analyse.
|
|
9
|
+
* @param options - Optional build configuration.
|
|
10
|
+
* @returns - Serialized graph + analysis summary.
|
|
11
|
+
*/
|
|
12
|
+
export interface BuildResult {
|
|
13
|
+
graph: SerializedGraph;
|
|
14
|
+
analysis: GraphAnalysis;
|
|
15
|
+
questions: GraphQuestion[];
|
|
16
|
+
corpusWarnings: string[];
|
|
17
|
+
filesProcessed: number;
|
|
18
|
+
fromCache: number;
|
|
19
|
+
graphPath: string;
|
|
20
|
+
reportPath: string;
|
|
21
|
+
/** Graph quality scalar: avgCohesion × ln(1 + avgDegree). Higher is better. */
|
|
22
|
+
graphQuality: number;
|
|
23
|
+
/** Experiment loop status — mirrors autoresearch's keep/discard protocol. */
|
|
24
|
+
experimentStatus: 'BASELINE' | 'KEEP' | 'DISCARD';
|
|
25
|
+
}
|
|
26
|
+
export declare function buildGraph(projectPath: string, options?: BuildOptions): Promise<BuildResult>;
|
|
27
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEZ,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;AA2HpB;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,gBAAgB,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;CACnD;AAED,wBAAsB,UAAU,CAC9B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CA+JtB"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
+
import { collectFiles, corpusHealth } from './detect.js';
|
|
4
|
+
import { FileCache } from './cache.js';
|
|
5
|
+
import { buildGraph as buildGraphologyGraph } from './build.js';
|
|
6
|
+
import { detectCommunities, cohesionScore } from './cluster.js';
|
|
7
|
+
import { buildAnalysis, suggestQuestions } from './analyze.js';
|
|
8
|
+
import { saveGraph } from './export.js';
|
|
9
|
+
import { exportHTML } from './visualize.js';
|
|
10
|
+
import { generateReport } from './report.js';
|
|
11
|
+
import { typescriptExtractor } from './extract/languages/typescript.js';
|
|
12
|
+
import { parseFile } from './extract/tree-sitter-runner.js';
|
|
13
|
+
const DEFAULT_OUTPUT_SUBDIR = '.monomind/graph';
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Experiment loop — adapted from autoresearch's program.md protocol
|
|
16
|
+
//
|
|
17
|
+
// Every buildGraph call appends one row to results.tsv with a quality scalar,
|
|
18
|
+
// then decides BASELINE / KEEP / DISCARD by comparing against the best known
|
|
19
|
+
// result. The quality metric mirrors autoresearch's val_bpb (a single number
|
|
20
|
+
// to optimise), but for graph structure rather than language model perplexity.
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
const RESULTS_TSV_HEADER = 'timestamp\tnodes\tedges\tcommunities\tavg_cohesion\tavg_degree\tgraph_quality\tfiles_processed\tstatus\tdescription\n';
|
|
23
|
+
/**
|
|
24
|
+
* Graph quality scalar.
|
|
25
|
+
*
|
|
26
|
+
* avgCohesion × ln(1 + avgDegree)
|
|
27
|
+
*
|
|
28
|
+
* Rewards both tight community structure (cohesion) and overall connectivity
|
|
29
|
+
* (avgDegree). Higher is better — directly comparable across builds, like
|
|
30
|
+
* autoresearch's vocab-size-independent bits-per-byte metric.
|
|
31
|
+
*/
|
|
32
|
+
function computeGraphQuality(avgCohesion, nodes, edges) {
|
|
33
|
+
const avgDegree = nodes > 0 ? (2 * edges) / nodes : 0;
|
|
34
|
+
return avgCohesion * Math.log(1 + avgDegree);
|
|
35
|
+
}
|
|
36
|
+
/** Read results.tsv and return the best graph_quality seen so far (BASELINE or KEEP rows). */
|
|
37
|
+
function readBestQuality(tsvPath) {
|
|
38
|
+
if (!existsSync(tsvPath))
|
|
39
|
+
return -Infinity;
|
|
40
|
+
try {
|
|
41
|
+
const lines = readFileSync(tsvPath, 'utf-8').split('\n').filter(Boolean);
|
|
42
|
+
let best = -Infinity;
|
|
43
|
+
for (const line of lines.slice(1)) { // skip header
|
|
44
|
+
const cols = line.split('\t');
|
|
45
|
+
const status = cols[8]; // status column
|
|
46
|
+
const quality = parseFloat(cols[6] ?? '0'); // graph_quality column
|
|
47
|
+
if ((status === 'BASELINE' || status === 'KEEP') && !isNaN(quality)) {
|
|
48
|
+
if (quality > best)
|
|
49
|
+
best = quality;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return best;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return -Infinity;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Append one experiment row to results.tsv. Creates file + header if needed. */
|
|
59
|
+
function appendResultsTsv(tsvPath, metrics) {
|
|
60
|
+
const avgDegree = metrics.nodes > 0 ? (2 * metrics.edges) / metrics.nodes : 0;
|
|
61
|
+
const description = `${metrics.nodes}n/${metrics.edges}e coh=${metrics.avgCohesion.toFixed(3)} deg=${avgDegree.toFixed(1)}`;
|
|
62
|
+
const row = [
|
|
63
|
+
new Date().toISOString(),
|
|
64
|
+
metrics.nodes,
|
|
65
|
+
metrics.edges,
|
|
66
|
+
metrics.communities,
|
|
67
|
+
metrics.avgCohesion.toFixed(4),
|
|
68
|
+
avgDegree.toFixed(2),
|
|
69
|
+
metrics.graphQuality.toFixed(6),
|
|
70
|
+
metrics.filesProcessed,
|
|
71
|
+
metrics.status,
|
|
72
|
+
description,
|
|
73
|
+
].join('\t') + '\n';
|
|
74
|
+
try {
|
|
75
|
+
if (!existsSync(tsvPath)) {
|
|
76
|
+
writeFileSync(tsvPath, RESULTS_TSV_HEADER + row, 'utf-8');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const existing = readFileSync(tsvPath, 'utf-8');
|
|
80
|
+
writeFileSync(tsvPath, existing + row, 'utf-8');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch { /* TSV tracking is non-fatal */ }
|
|
84
|
+
}
|
|
85
|
+
// Map language identifiers to the extractors we have available.
|
|
86
|
+
// python and go extractors are loaded lazily when their modules exist.
|
|
87
|
+
const EXTRACTOR_MAP = {
|
|
88
|
+
typescript: typescriptExtractor,
|
|
89
|
+
javascript: typescriptExtractor, // TS extractor handles JS via regex + tree-sitter-javascript
|
|
90
|
+
};
|
|
91
|
+
/** Attempt to load python/go extractors that may be present in the extract/languages dir. */
|
|
92
|
+
async function tryLoadExtractor(language) {
|
|
93
|
+
if (EXTRACTOR_MAP[language])
|
|
94
|
+
return EXTRACTOR_MAP[language];
|
|
95
|
+
try {
|
|
96
|
+
const mod = await import(`./extract/languages/${language}.js`);
|
|
97
|
+
const extractor = (mod[`${language}Extractor`] ?? mod['default']);
|
|
98
|
+
if (extractor)
|
|
99
|
+
EXTRACTOR_MAP[language] = extractor;
|
|
100
|
+
return extractor;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export async function buildGraph(projectPath, options = {}) {
|
|
107
|
+
// Resolve output directory
|
|
108
|
+
const outputDir = options.outputDir ?? join(projectPath, DEFAULT_OUTPUT_SUBDIR);
|
|
109
|
+
mkdirSync(outputDir, { recursive: true });
|
|
110
|
+
const cache = new FileCache(outputDir);
|
|
111
|
+
// 1. Collect files + corpus health check
|
|
112
|
+
const files = collectFiles(projectPath, options);
|
|
113
|
+
const corpusWarnings = corpusHealth(files);
|
|
114
|
+
// 2. Extract nodes/edges from each file (cache-aware)
|
|
115
|
+
const merged = {
|
|
116
|
+
nodes: [],
|
|
117
|
+
edges: [],
|
|
118
|
+
hyperedges: [],
|
|
119
|
+
filesProcessed: 0,
|
|
120
|
+
fromCache: 0,
|
|
121
|
+
errors: [],
|
|
122
|
+
};
|
|
123
|
+
for (const file of files) {
|
|
124
|
+
let content;
|
|
125
|
+
try {
|
|
126
|
+
content = readFileSync(file.path, 'utf-8');
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
merged.errors.push(`Cannot read ${file.path}: ${String(err)}`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const cacheKey = cache.key(file.path, content);
|
|
133
|
+
let result = cache.get(cacheKey);
|
|
134
|
+
if (result) {
|
|
135
|
+
merged.fromCache += 1;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const extractor = file.language
|
|
139
|
+
? await tryLoadExtractor(file.language)
|
|
140
|
+
: undefined;
|
|
141
|
+
if (extractor) {
|
|
142
|
+
result = parseFile(file.path, content, extractor);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
result = extractGeneric(file.path, content);
|
|
146
|
+
}
|
|
147
|
+
cache.set(cacheKey, result);
|
|
148
|
+
}
|
|
149
|
+
merged.nodes.push(...result.nodes);
|
|
150
|
+
merged.edges.push(...result.edges);
|
|
151
|
+
if (result.hyperedges)
|
|
152
|
+
merged.hyperedges.push(...result.hyperedges);
|
|
153
|
+
merged.filesProcessed += 1;
|
|
154
|
+
merged.errors.push(...result.errors);
|
|
155
|
+
}
|
|
156
|
+
// 3. Build graphology graph (dedup + stub endpoints)
|
|
157
|
+
const graph = buildGraphologyGraph(merged);
|
|
158
|
+
// 4. Community detection (Louvain with directory-based fallback)
|
|
159
|
+
await detectCommunities(graph);
|
|
160
|
+
// 5. Degree annotation
|
|
161
|
+
graph.forEachNode((id) => {
|
|
162
|
+
graph.setNodeAttribute(id, 'degree', graph.degree(id));
|
|
163
|
+
});
|
|
164
|
+
// 6. Build analysis (god nodes, surprise edges, communities, stats)
|
|
165
|
+
const analysis = buildAnalysis(graph, outputDir);
|
|
166
|
+
// 6b. Suggest questions the graph can answer
|
|
167
|
+
const questions = suggestQuestions(graph, analysis.communities);
|
|
168
|
+
// 6c. Compute cohesion scores per community
|
|
169
|
+
const cohesionScores = {};
|
|
170
|
+
for (const [cidStr, memberIds] of Object.entries(analysis.communities)) {
|
|
171
|
+
cohesionScores[Number(cidStr)] = cohesionScore(graph, memberIds);
|
|
172
|
+
}
|
|
173
|
+
// 6d. Graph quality metric + experiment loop (autoresearch protocol)
|
|
174
|
+
const cohesionValues = Object.values(cohesionScores);
|
|
175
|
+
const avgCohesion = cohesionValues.length > 0
|
|
176
|
+
? cohesionValues.reduce((a, b) => a + b, 0) / cohesionValues.length
|
|
177
|
+
: 0;
|
|
178
|
+
const graphQuality = computeGraphQuality(avgCohesion, graph.order, graph.size);
|
|
179
|
+
const tsvPath = join(outputDir, 'results.tsv');
|
|
180
|
+
const prevBest = readBestQuality(tsvPath);
|
|
181
|
+
const experimentStatus = prevBest === -Infinity
|
|
182
|
+
? 'BASELINE'
|
|
183
|
+
: graphQuality > prevBest * 1.001 // 0.1% improvement threshold
|
|
184
|
+
? 'KEEP'
|
|
185
|
+
: 'DISCARD';
|
|
186
|
+
appendResultsTsv(tsvPath, {
|
|
187
|
+
nodes: graph.order,
|
|
188
|
+
edges: graph.size,
|
|
189
|
+
communities: analysis.stats.communities,
|
|
190
|
+
avgCohesion,
|
|
191
|
+
graphQuality,
|
|
192
|
+
filesProcessed: merged.filesProcessed,
|
|
193
|
+
status: experimentStatus,
|
|
194
|
+
});
|
|
195
|
+
// 7. Persist to disk
|
|
196
|
+
saveGraph(graph, outputDir, projectPath);
|
|
197
|
+
const graphPath = join(outputDir, 'graph.json');
|
|
198
|
+
// 7b. Generate and save markdown report (non-fatal)
|
|
199
|
+
const reportPath = join(outputDir, 'GRAPH_REPORT.md');
|
|
200
|
+
try {
|
|
201
|
+
const totalWords = merged.nodes.reduce((sum, n) => sum + (n.linesOfCode ?? 0) * 10, 0);
|
|
202
|
+
const reportMd = generateReport(graph, analysis, cohesionScores, {
|
|
203
|
+
projectPath,
|
|
204
|
+
questions,
|
|
205
|
+
corpusStats: corpusWarnings.length > 0
|
|
206
|
+
? { totalFiles: files.length, totalWords, warning: corpusWarnings[0] }
|
|
207
|
+
: { totalFiles: files.length, totalWords },
|
|
208
|
+
});
|
|
209
|
+
writeFileSync(reportPath, reportMd, 'utf-8');
|
|
210
|
+
}
|
|
211
|
+
catch { /* report generation is non-fatal */ }
|
|
212
|
+
// 8. Serialize to the public return type
|
|
213
|
+
const serialized = {
|
|
214
|
+
version: '1.0.0',
|
|
215
|
+
builtAt: new Date().toISOString(),
|
|
216
|
+
projectPath,
|
|
217
|
+
directed: true,
|
|
218
|
+
multigraph: false,
|
|
219
|
+
nodes: graph.nodes().map((id) => ({
|
|
220
|
+
id,
|
|
221
|
+
...graph.getNodeAttributes(id),
|
|
222
|
+
})),
|
|
223
|
+
links: graph.edges().map((edgeId) => ({
|
|
224
|
+
source: graph.source(edgeId),
|
|
225
|
+
target: graph.target(edgeId),
|
|
226
|
+
...graph.getEdgeAttributes(edgeId),
|
|
227
|
+
})),
|
|
228
|
+
};
|
|
229
|
+
// 9. Generate interactive HTML visualization (non-fatal)
|
|
230
|
+
try {
|
|
231
|
+
exportHTML(serialized, outputDir);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
// Visualization is best-effort; never block the build
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
graph: serialized,
|
|
238
|
+
analysis,
|
|
239
|
+
questions,
|
|
240
|
+
corpusWarnings,
|
|
241
|
+
filesProcessed: merged.filesProcessed,
|
|
242
|
+
fromCache: merged.fromCache,
|
|
243
|
+
graphPath,
|
|
244
|
+
reportPath,
|
|
245
|
+
graphQuality,
|
|
246
|
+
experimentStatus,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// ---------------------------------------------------------------------------
|
|
250
|
+
// Internal: minimal fallback for languages without a dedicated extractor
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
function extractGeneric(filePath, content) {
|
|
253
|
+
return {
|
|
254
|
+
nodes: [
|
|
255
|
+
{
|
|
256
|
+
id: filePath,
|
|
257
|
+
label: filePath.split('/').pop() ?? filePath,
|
|
258
|
+
fileType: 'code',
|
|
259
|
+
sourceFile: filePath,
|
|
260
|
+
linesOfCode: content.split('\n').length,
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
edges: [],
|
|
264
|
+
filesProcessed: 1,
|
|
265
|
+
fromCache: 0,
|
|
266
|
+
errors: [],
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAQxE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEjD,8EAA8E;AAC9E,oEAAoE;AACpE,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAE9E,MAAM,kBAAkB,GACtB,uHAAuH,CAAC;AAE1H;;;;;;;;GAQG;AACH,SAAS,mBAAmB,CAC1B,WAAmB,EACnB,KAAa,EACb,KAAa;IAEb,MAAM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AC,cAAc;QACrC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS;QACT,UAAU;QACV,YAAY;QACZ,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAE9E,SAAS,cAAc,CAAC,QAAgB,EAAE,OAAe;IACvD,OAAO;QACL,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,QAAQ;gBACZ,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,QAAQ;gBAC5C,QAAQ,EAAE,MAAM;gBAChB,UAAU,EAAE,QAAQ;gBACpB,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;aACxC;SACF;QACD,KAAK,EAAE,EAAE;QACT,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type Graph from 'graphology';
|
|
2
|
+
import type { GraphAnalysis, GraphQuestion } from './types.js';
|
|
3
|
+
export interface CorpusStats {
|
|
4
|
+
totalFiles: number;
|
|
5
|
+
totalWords: number;
|
|
6
|
+
warning?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ReportOptions {
|
|
9
|
+
projectPath?: string;
|
|
10
|
+
tokenCost?: {
|
|
11
|
+
input: number;
|
|
12
|
+
output: number;
|
|
13
|
+
};
|
|
14
|
+
corpusStats?: CorpusStats;
|
|
15
|
+
questions?: GraphQuestion[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate the full markdown report string.
|
|
19
|
+
*
|
|
20
|
+
* @param graph - The annotated Graphology graph (with `community` attributes set)
|
|
21
|
+
* @param analysis - Result of buildAnalysis()
|
|
22
|
+
* @param cohesionScores - Map of communityId → cohesion score (0–1)
|
|
23
|
+
* @param options - Optional metadata (projectPath, tokenCost, corpusStats, questions)
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateReport(graph: Graph, analysis: GraphAnalysis, cohesionScores?: Record<number, number>, options?: ReportOptions): string;
|
|
26
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/report.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG/D,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7B;AAkCD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,aAAa,EACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAkMR"}
|