@oddessentials/odd-repo-mapper 1.0.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.
Potentially problematic release.
This version of @oddessentials/odd-repo-mapper might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/cli/commands/mcp.d.ts +6 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +11 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/report.d.ts +6 -0
- package/dist/cli/commands/report.d.ts.map +1 -0
- package/dist/cli/commands/report.js +96 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/scan.d.ts +6 -0
- package/dist/cli/commands/scan.d.ts.map +1 -0
- package/dist/cli/commands/scan.js +118 -0
- package/dist/cli/commands/scan.js.map +1 -0
- package/dist/cli/commands/verify.d.ts +6 -0
- package/dist/cli/commands/verify.d.ts.map +1 -0
- package/dist/cli/commands/verify.js +47 -0
- package/dist/cli/commands/verify.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +20 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +53 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +106 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/constants.d.ts +31 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +31 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/graph.d.ts +61 -0
- package/dist/core/graph.d.ts.map +1 -0
- package/dist/core/graph.js +163 -0
- package/dist/core/graph.js.map +1 -0
- package/dist/core/hashing.d.ts +37 -0
- package/dist/core/hashing.d.ts.map +1 -0
- package/dist/core/hashing.js +66 -0
- package/dist/core/hashing.js.map +1 -0
- package/dist/core/indexers/go.d.ts +14 -0
- package/dist/core/indexers/go.d.ts.map +1 -0
- package/dist/core/indexers/go.js +175 -0
- package/dist/core/indexers/go.js.map +1 -0
- package/dist/core/indexers/index.d.ts +39 -0
- package/dist/core/indexers/index.d.ts.map +1 -0
- package/dist/core/indexers/index.js +76 -0
- package/dist/core/indexers/index.js.map +1 -0
- package/dist/core/indexers/python.d.ts +14 -0
- package/dist/core/indexers/python.d.ts.map +1 -0
- package/dist/core/indexers/python.js +186 -0
- package/dist/core/indexers/python.js.map +1 -0
- package/dist/core/indexers/rust.d.ts +14 -0
- package/dist/core/indexers/rust.d.ts.map +1 -0
- package/dist/core/indexers/rust.js +156 -0
- package/dist/core/indexers/rust.js.map +1 -0
- package/dist/core/indexers/typescript.d.ts +19 -0
- package/dist/core/indexers/typescript.d.ts.map +1 -0
- package/dist/core/indexers/typescript.js +223 -0
- package/dist/core/indexers/typescript.js.map +1 -0
- package/dist/core/reports/coverage.d.ts +38 -0
- package/dist/core/reports/coverage.d.ts.map +1 -0
- package/dist/core/reports/coverage.js +175 -0
- package/dist/core/reports/coverage.js.map +1 -0
- package/dist/core/reports/index.d.ts +10 -0
- package/dist/core/reports/index.d.ts.map +1 -0
- package/dist/core/reports/index.js +7 -0
- package/dist/core/reports/index.js.map +1 -0
- package/dist/core/reports/mermaid.d.ts +41 -0
- package/dist/core/reports/mermaid.d.ts.map +1 -0
- package/dist/core/reports/mermaid.js +171 -0
- package/dist/core/reports/mermaid.js.map +1 -0
- package/dist/core/reports/traceability.d.ts +45 -0
- package/dist/core/reports/traceability.d.ts.map +1 -0
- package/dist/core/reports/traceability.js +190 -0
- package/dist/core/reports/traceability.js.map +1 -0
- package/dist/core/scanner.d.ts +48 -0
- package/dist/core/scanner.d.ts.map +1 -0
- package/dist/core/scanner.js +191 -0
- package/dist/core/scanner.js.map +1 -0
- package/dist/core/toolchain.d.ts +28 -0
- package/dist/core/toolchain.d.ts.map +1 -0
- package/dist/core/toolchain.js +68 -0
- package/dist/core/toolchain.js.map +1 -0
- package/dist/core/verify.d.ts +15 -0
- package/dist/core/verify.d.ts.map +1 -0
- package/dist/core/verify.js +182 -0
- package/dist/core/verify.js.map +1 -0
- package/dist/mcp/server.d.ts +46 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +421 -0
- package/dist/mcp/server.js.map +1 -0
- package/package.json +86 -0
- package/schemas/config.schema.json +140 -0
- package/schemas/graph.schema.json +132 -0
- package/schemas/repo-profile.schema.json +118 -0
- package/schemas/toolchain.schema.json +37 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript indexer using ts-morph.
|
|
3
|
+
* Per D5: Import edges require ast_import proof.
|
|
4
|
+
*/
|
|
5
|
+
import { Project, SyntaxKind } from 'ts-morph';
|
|
6
|
+
import { resolve, dirname, relative } from 'node:path';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { normalizePath, pathToId } from '../hashing.js';
|
|
9
|
+
/**
|
|
10
|
+
* Index TypeScript/JavaScript files for imports and symbols.
|
|
11
|
+
*/
|
|
12
|
+
export function indexTypeScript(options) {
|
|
13
|
+
const { rootDir, files, tsConfigPath } = options;
|
|
14
|
+
const nodes = [];
|
|
15
|
+
const edges = [];
|
|
16
|
+
// Create project
|
|
17
|
+
const project = new Project({
|
|
18
|
+
tsConfigFilePath: tsConfigPath && existsSync(tsConfigPath) ? tsConfigPath : undefined,
|
|
19
|
+
skipAddingFilesFromTsConfig: true,
|
|
20
|
+
compilerOptions: {
|
|
21
|
+
allowJs: true,
|
|
22
|
+
checkJs: false,
|
|
23
|
+
noEmit: true,
|
|
24
|
+
skipLibCheck: true,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// Add files
|
|
28
|
+
for (const filePath of files) {
|
|
29
|
+
try {
|
|
30
|
+
project.addSourceFileAtPath(filePath);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Skip files that can't be parsed
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Index each file
|
|
37
|
+
for (const sourceFile of project.getSourceFiles()) {
|
|
38
|
+
const filePath = sourceFile.getFilePath();
|
|
39
|
+
const relativePath = normalizePath(relative(rootDir, filePath));
|
|
40
|
+
const fileId = pathToId(relativePath);
|
|
41
|
+
// Skip node_modules
|
|
42
|
+
if (relativePath.includes('node_modules'))
|
|
43
|
+
continue;
|
|
44
|
+
// Add file node
|
|
45
|
+
const isTest = isTestFile(relativePath);
|
|
46
|
+
nodes.push({
|
|
47
|
+
id: fileId,
|
|
48
|
+
type: isTest ? 'test' : 'file',
|
|
49
|
+
path: relativePath,
|
|
50
|
+
language: getLanguage(filePath),
|
|
51
|
+
tier: 1,
|
|
52
|
+
});
|
|
53
|
+
// Extract imports
|
|
54
|
+
const imports = extractImports(sourceFile, rootDir);
|
|
55
|
+
for (const imp of imports) {
|
|
56
|
+
const targetId = pathToId(imp.resolvedPath);
|
|
57
|
+
edges.push({
|
|
58
|
+
source: fileId,
|
|
59
|
+
target: targetId,
|
|
60
|
+
kind: 'import',
|
|
61
|
+
proof: {
|
|
62
|
+
type: 'ast_import',
|
|
63
|
+
location: {
|
|
64
|
+
file: relativePath,
|
|
65
|
+
line: imp.line,
|
|
66
|
+
column: imp.column,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Extract entrypoints (exported functions, main)
|
|
72
|
+
const entrypoints = extractEntrypoints(sourceFile);
|
|
73
|
+
for (const ep of entrypoints) {
|
|
74
|
+
nodes.push({
|
|
75
|
+
id: pathToId(`${relativePath}#${ep.name}`),
|
|
76
|
+
type: 'entrypoint',
|
|
77
|
+
path: relativePath,
|
|
78
|
+
name: ep.name,
|
|
79
|
+
fqn: `${relativePath}#${ep.name}`,
|
|
80
|
+
language: getLanguage(filePath),
|
|
81
|
+
tier: 1,
|
|
82
|
+
});
|
|
83
|
+
edges.push({
|
|
84
|
+
source: pathToId(`${relativePath}#${ep.name}`),
|
|
85
|
+
target: fileId,
|
|
86
|
+
kind: 'entrypoint',
|
|
87
|
+
proof: {
|
|
88
|
+
type: 'ast_import',
|
|
89
|
+
location: {
|
|
90
|
+
file: relativePath,
|
|
91
|
+
line: ep.line,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { nodes, edges };
|
|
98
|
+
}
|
|
99
|
+
function extractImports(sourceFile, rootDir) {
|
|
100
|
+
const imports = [];
|
|
101
|
+
const filePath = sourceFile.getFilePath();
|
|
102
|
+
const fileDir = dirname(filePath);
|
|
103
|
+
// Static imports
|
|
104
|
+
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
105
|
+
const specifier = importDecl.getModuleSpecifierValue();
|
|
106
|
+
const resolvedPath = resolveImportPath(specifier, fileDir, rootDir);
|
|
107
|
+
if (resolvedPath) {
|
|
108
|
+
const pos = importDecl.getStart();
|
|
109
|
+
const { line, column } = sourceFile.getLineAndColumnAtPos(pos);
|
|
110
|
+
imports.push({
|
|
111
|
+
specifier,
|
|
112
|
+
resolvedPath,
|
|
113
|
+
line,
|
|
114
|
+
column,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Dynamic imports (import())
|
|
119
|
+
for (const callExpr of sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)) {
|
|
120
|
+
const expr = callExpr.getExpression();
|
|
121
|
+
if (expr.getKind() === SyntaxKind.ImportKeyword) {
|
|
122
|
+
const args = callExpr.getArguments();
|
|
123
|
+
if (args.length > 0) {
|
|
124
|
+
const arg = args[0];
|
|
125
|
+
if (arg.getKind() === SyntaxKind.StringLiteral) {
|
|
126
|
+
const specifier = arg.getText().slice(1, -1); // Remove quotes
|
|
127
|
+
const resolvedPath = resolveImportPath(specifier, fileDir, rootDir);
|
|
128
|
+
if (resolvedPath) {
|
|
129
|
+
const pos = callExpr.getStart();
|
|
130
|
+
const { line, column } = sourceFile.getLineAndColumnAtPos(pos);
|
|
131
|
+
imports.push({
|
|
132
|
+
specifier,
|
|
133
|
+
resolvedPath,
|
|
134
|
+
line,
|
|
135
|
+
column,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// require() calls
|
|
143
|
+
for (const callExpr of sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)) {
|
|
144
|
+
const expr = callExpr.getExpression();
|
|
145
|
+
if (expr.getText() === 'require') {
|
|
146
|
+
const args = callExpr.getArguments();
|
|
147
|
+
if (args.length > 0) {
|
|
148
|
+
const arg = args[0];
|
|
149
|
+
if (arg.getKind() === SyntaxKind.StringLiteral) {
|
|
150
|
+
const specifier = arg.getText().slice(1, -1);
|
|
151
|
+
const resolvedPath = resolveImportPath(specifier, fileDir, rootDir);
|
|
152
|
+
if (resolvedPath) {
|
|
153
|
+
const pos = callExpr.getStart();
|
|
154
|
+
const { line, column } = sourceFile.getLineAndColumnAtPos(pos);
|
|
155
|
+
imports.push({
|
|
156
|
+
specifier,
|
|
157
|
+
resolvedPath,
|
|
158
|
+
line,
|
|
159
|
+
column,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return imports;
|
|
167
|
+
}
|
|
168
|
+
function resolveImportPath(specifier, fromDir, rootDir) {
|
|
169
|
+
// Skip external modules
|
|
170
|
+
if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', ''];
|
|
174
|
+
const basePath = resolve(fromDir, specifier);
|
|
175
|
+
// Try with extensions
|
|
176
|
+
for (const ext of extensions) {
|
|
177
|
+
const fullPath = basePath + ext;
|
|
178
|
+
if (existsSync(fullPath)) {
|
|
179
|
+
return normalizePath(relative(rootDir, fullPath));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Try as directory with index
|
|
183
|
+
for (const ext of extensions) {
|
|
184
|
+
const indexPath = resolve(basePath, 'index' + ext);
|
|
185
|
+
if (existsSync(indexPath)) {
|
|
186
|
+
return normalizePath(relative(rootDir, indexPath));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
function extractEntrypoints(sourceFile) {
|
|
192
|
+
const entrypoints = [];
|
|
193
|
+
// Exported functions and classes
|
|
194
|
+
for (const func of sourceFile.getFunctions()) {
|
|
195
|
+
if (func.isExported()) {
|
|
196
|
+
const name = func.getName();
|
|
197
|
+
if (name) {
|
|
198
|
+
const pos = func.getStart();
|
|
199
|
+
const { line } = sourceFile.getLineAndColumnAtPos(pos);
|
|
200
|
+
entrypoints.push({ name, line });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
for (const cls of sourceFile.getClasses()) {
|
|
205
|
+
if (cls.isExported()) {
|
|
206
|
+
const name = cls.getName();
|
|
207
|
+
if (name) {
|
|
208
|
+
const pos = cls.getStart();
|
|
209
|
+
const { line } = sourceFile.getLineAndColumnAtPos(pos);
|
|
210
|
+
entrypoints.push({ name, line });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return entrypoints;
|
|
215
|
+
}
|
|
216
|
+
function isTestFile(path) {
|
|
217
|
+
const lower = path.toLowerCase();
|
|
218
|
+
return lower.includes('test') || lower.includes('spec') || lower.includes('__tests__');
|
|
219
|
+
}
|
|
220
|
+
function getLanguage(path) {
|
|
221
|
+
return path.endsWith('.ts') || path.endsWith('.tsx') ? 'typescript' : 'javascript';
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=typescript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/core/indexers/typescript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAc,UAAU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,CAAC,OAAO,EAAE,CAAC;YAC3B,IAAI,IAAI,EAAE,CAAC;gBACP,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;gBACvD,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YACrC,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage importers for lcov and cobertura formats.
|
|
3
|
+
* Per D4: Coverage ingestion is first-class in v0.1.
|
|
4
|
+
*/
|
|
5
|
+
import type { GraphEdge } from '../graph.js';
|
|
6
|
+
export interface CoverageData {
|
|
7
|
+
files: CoverageFile[];
|
|
8
|
+
totalLines: number;
|
|
9
|
+
coveredLines: number;
|
|
10
|
+
percentage: number;
|
|
11
|
+
}
|
|
12
|
+
export interface CoverageFile {
|
|
13
|
+
path: string;
|
|
14
|
+
lines: number;
|
|
15
|
+
covered: number;
|
|
16
|
+
percentage: number;
|
|
17
|
+
/** Map of line number -> hit count */
|
|
18
|
+
lineHits: Map<number, number>;
|
|
19
|
+
}
|
|
20
|
+
export interface CoverageImportResult {
|
|
21
|
+
data: CoverageData;
|
|
22
|
+
edges: GraphEdge[];
|
|
23
|
+
errors: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Import coverage from lcov format.
|
|
27
|
+
* Per D4: Fail-hard on malformed/missing coverage.
|
|
28
|
+
*/
|
|
29
|
+
export declare function importLcov(lcovPath: string, rootDir: string): CoverageImportResult;
|
|
30
|
+
/**
|
|
31
|
+
* Import coverage from Cobertura XML format.
|
|
32
|
+
*/
|
|
33
|
+
export declare function importCobertura(xmlPath: string, rootDir: string): CoverageImportResult;
|
|
34
|
+
/**
|
|
35
|
+
* Auto-detect coverage format and import.
|
|
36
|
+
*/
|
|
37
|
+
export declare function importCoverage(coveragePath: string, rootDir: string): CoverageImportResult;
|
|
38
|
+
//# sourceMappingURL=coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../../src/core/reports/coverage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,oBAAoB,CA+FlF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,oBAAoB,CA6DtF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAa1F"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage importers for lcov and cobertura formats.
|
|
3
|
+
* Per D4: Coverage ingestion is first-class in v0.1.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
6
|
+
import { resolve, relative } from 'node:path';
|
|
7
|
+
import { normalizePath, pathToId } from '../hashing.js';
|
|
8
|
+
/**
|
|
9
|
+
* Import coverage from lcov format.
|
|
10
|
+
* Per D4: Fail-hard on malformed/missing coverage.
|
|
11
|
+
*/
|
|
12
|
+
export function importLcov(lcovPath, rootDir) {
|
|
13
|
+
const errors = [];
|
|
14
|
+
const edges = [];
|
|
15
|
+
const files = [];
|
|
16
|
+
if (!existsSync(lcovPath)) {
|
|
17
|
+
errors.push(`Coverage file not found: ${lcovPath} (FAIL per D4)`);
|
|
18
|
+
return {
|
|
19
|
+
data: { files: [], totalLines: 0, coveredLines: 0, percentage: 0 },
|
|
20
|
+
edges,
|
|
21
|
+
errors,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
let content;
|
|
25
|
+
try {
|
|
26
|
+
content = readFileSync(lcovPath, 'utf8');
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
errors.push(`Failed to read coverage file: ${err instanceof Error ? err.message : String(err)}`);
|
|
30
|
+
return {
|
|
31
|
+
data: { files: [], totalLines: 0, coveredLines: 0, percentage: 0 },
|
|
32
|
+
edges,
|
|
33
|
+
errors,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// Parse lcov format
|
|
37
|
+
let currentFile = null;
|
|
38
|
+
for (const line of content.split('\n')) {
|
|
39
|
+
const trimmed = line.trim();
|
|
40
|
+
if (trimmed.startsWith('SF:')) {
|
|
41
|
+
// Source file
|
|
42
|
+
const filePath = trimmed.slice(3);
|
|
43
|
+
const relativePath = normalizePath(relative(rootDir, resolve(rootDir, filePath)));
|
|
44
|
+
currentFile = {
|
|
45
|
+
path: relativePath,
|
|
46
|
+
lines: 0,
|
|
47
|
+
covered: 0,
|
|
48
|
+
percentage: 0,
|
|
49
|
+
lineHits: new Map(),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else if (trimmed.startsWith('DA:') && currentFile) {
|
|
53
|
+
// Line data: DA:line,hits
|
|
54
|
+
const parts = trimmed.slice(3).split(',');
|
|
55
|
+
if (parts.length >= 2) {
|
|
56
|
+
const lineNum = parseInt(parts[0], 10);
|
|
57
|
+
const hits = parseInt(parts[1], 10);
|
|
58
|
+
currentFile.lineHits.set(lineNum, hits);
|
|
59
|
+
currentFile.lines++;
|
|
60
|
+
if (hits > 0) {
|
|
61
|
+
currentFile.covered++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (trimmed === 'end_of_record' && currentFile) {
|
|
66
|
+
currentFile.percentage =
|
|
67
|
+
currentFile.lines > 0
|
|
68
|
+
? Math.round((currentFile.covered / currentFile.lines) * 100)
|
|
69
|
+
: 0;
|
|
70
|
+
files.push(currentFile);
|
|
71
|
+
currentFile = null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Calculate totals
|
|
75
|
+
const totalLines = files.reduce((sum, f) => sum + f.lines, 0);
|
|
76
|
+
const coveredLines = files.reduce((sum, f) => sum + f.covered, 0);
|
|
77
|
+
const percentage = totalLines > 0 ? Math.round((coveredLines / totalLines) * 100) : 0;
|
|
78
|
+
// Generate coverage edges (test → source with coverage proof)
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
if (file.covered > 0) {
|
|
81
|
+
const fileId = pathToId(file.path);
|
|
82
|
+
// For now, we create a generic coverage edge
|
|
83
|
+
// In M3, we'll link this to specific tests
|
|
84
|
+
edges.push({
|
|
85
|
+
source: pathToId(`coverage:${file.path}`),
|
|
86
|
+
target: fileId,
|
|
87
|
+
kind: 'tests',
|
|
88
|
+
proof: {
|
|
89
|
+
type: 'coverage',
|
|
90
|
+
location: { file: file.path },
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
data: { files, totalLines, coveredLines, percentage },
|
|
97
|
+
edges,
|
|
98
|
+
errors,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Import coverage from Cobertura XML format.
|
|
103
|
+
*/
|
|
104
|
+
export function importCobertura(xmlPath, rootDir) {
|
|
105
|
+
const errors = [];
|
|
106
|
+
const edges = [];
|
|
107
|
+
const files = [];
|
|
108
|
+
if (!existsSync(xmlPath)) {
|
|
109
|
+
errors.push(`Coverage file not found: ${xmlPath} (FAIL per D4)`);
|
|
110
|
+
return {
|
|
111
|
+
data: { files: [], totalLines: 0, coveredLines: 0, percentage: 0 },
|
|
112
|
+
edges,
|
|
113
|
+
errors,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
let content;
|
|
117
|
+
try {
|
|
118
|
+
content = readFileSync(xmlPath, 'utf8');
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
errors.push(`Failed to read coverage file: ${err instanceof Error ? err.message : String(err)}`);
|
|
122
|
+
return {
|
|
123
|
+
data: { files: [], totalLines: 0, coveredLines: 0, percentage: 0 },
|
|
124
|
+
edges,
|
|
125
|
+
errors,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// Simple XML parsing for Cobertura format
|
|
129
|
+
// In production, we'd use a proper XML parser
|
|
130
|
+
const fileMatches = content.matchAll(/<class[^>]+filename="([^"]+)"[^>]*>/g);
|
|
131
|
+
for (const match of fileMatches) {
|
|
132
|
+
const filename = match[1];
|
|
133
|
+
const relativePath = normalizePath(relative(rootDir, resolve(rootDir, filename)));
|
|
134
|
+
// Extract line rate if present
|
|
135
|
+
const rateMatch = match[0].match(/line-rate="([^"]+)"/);
|
|
136
|
+
const lineRate = rateMatch ? parseFloat(rateMatch[1]) : 0;
|
|
137
|
+
files.push({
|
|
138
|
+
path: relativePath,
|
|
139
|
+
lines: 0, // Would need deeper parsing
|
|
140
|
+
covered: 0,
|
|
141
|
+
percentage: Math.round(lineRate * 100),
|
|
142
|
+
lineHits: new Map(),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const totalLines = files.reduce((sum, f) => sum + f.lines, 0);
|
|
146
|
+
const coveredLines = files.reduce((sum, f) => sum + f.covered, 0);
|
|
147
|
+
const percentage = files.length > 0
|
|
148
|
+
? Math.round(files.reduce((sum, f) => sum + f.percentage, 0) / files.length)
|
|
149
|
+
: 0;
|
|
150
|
+
return {
|
|
151
|
+
data: { files, totalLines, coveredLines, percentage },
|
|
152
|
+
edges,
|
|
153
|
+
errors,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Auto-detect coverage format and import.
|
|
158
|
+
*/
|
|
159
|
+
export function importCoverage(coveragePath, rootDir) {
|
|
160
|
+
if (coveragePath.endsWith('.info') || coveragePath.endsWith('.lcov')) {
|
|
161
|
+
return importLcov(coveragePath, rootDir);
|
|
162
|
+
}
|
|
163
|
+
else if (coveragePath.endsWith('.xml')) {
|
|
164
|
+
return importCobertura(coveragePath, rootDir);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Try lcov first, then cobertura
|
|
168
|
+
const lcovResult = importLcov(coveragePath, rootDir);
|
|
169
|
+
if (lcovResult.data.files.length > 0) {
|
|
170
|
+
return lcovResult;
|
|
171
|
+
}
|
|
172
|
+
return importCobertura(coveragePath, rootDir);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../../src/core/reports/coverage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAyBxD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,OAAe;IACxD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAmB,EAAE,CAAC;IAEjC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,4BAA4B,QAAQ,gBAAgB,CAAC,CAAC;QAClE,OAAO;YACH,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;YAClE,KAAK;YACL,MAAM;SACT,CAAC;IACN,CAAC;IAED,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACD,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,MAAM,CAAC,IAAI,CACP,iCAAiC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACtF,CAAC;QACF,OAAO;YACH,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE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C,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5E,CAAC,CAAC,CAAC,CAAC;IAEZ,OAAO;QACH,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE;QACrD,KAAK;QACL,MAAM;KACT,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB,EAAE,OAAe;IAChE,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACnE,OAAO,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,OAAO,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACJ,iCAAiC;QACjC,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACrD,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,UAAU,CAAC;QACtB,CAAC;QACD,OAAO,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reports index - re-exports all report generators.
|
|
3
|
+
*/
|
|
4
|
+
export { generateMermaidDiagram, writeMermaidDiagram, generateImportGraph, generateTestGraph, } from './mermaid.js';
|
|
5
|
+
export type { MermaidOptions, DiagramResult } from './mermaid.js';
|
|
6
|
+
export { importLcov, importCobertura, importCoverage } from './coverage.js';
|
|
7
|
+
export type { CoverageData, CoverageFile, CoverageImportResult } from './coverage.js';
|
|
8
|
+
export { buildTraceabilityMatrix, writeTraceabilityMatrix, writeTraceabilityMarkdown, } from './traceability.js';
|
|
9
|
+
export type { TraceabilityEntry, TraceabilityMatrix, TraceabilityOptions } from './traceability.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/reports/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,GACpB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEtF,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reports index - re-exports all report generators.
|
|
3
|
+
*/
|
|
4
|
+
export { generateMermaidDiagram, writeMermaidDiagram, generateImportGraph, generateTestGraph, } from './mermaid.js';
|
|
5
|
+
export { importLcov, importCobertura, importCoverage } from './coverage.js';
|
|
6
|
+
export { buildTraceabilityMatrix, writeTraceabilityMatrix, writeTraceabilityMarkdown, } from './traceability.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/reports/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG5E,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,GAC5B,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid diagram generator.
|
|
3
|
+
* Produces architecture diagrams from the knowledge graph.
|
|
4
|
+
*/
|
|
5
|
+
import Database from 'better-sqlite3';
|
|
6
|
+
import type { GraphNode, GraphEdge } from '../graph.js';
|
|
7
|
+
export interface MermaidOptions {
|
|
8
|
+
/** Maximum nodes per diagram */
|
|
9
|
+
maxNodes?: number;
|
|
10
|
+
/** Diagram direction */
|
|
11
|
+
direction?: 'TB' | 'BT' | 'LR' | 'RL';
|
|
12
|
+
/** Filter to specific node types */
|
|
13
|
+
nodeTypes?: GraphNode['type'][];
|
|
14
|
+
/** Include only edges of these kinds */
|
|
15
|
+
edgeKinds?: GraphEdge['kind'][];
|
|
16
|
+
/** Group nodes by directory depth */
|
|
17
|
+
groupByDirectory?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface DiagramResult {
|
|
20
|
+
mermaid: string;
|
|
21
|
+
nodeCount: number;
|
|
22
|
+
edgeCount: number;
|
|
23
|
+
truncated: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate a Mermaid flowchart from the graph database.
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateMermaidDiagram(db: Database.Database, options?: MermaidOptions): DiagramResult;
|
|
29
|
+
/**
|
|
30
|
+
* Write Mermaid diagram to file.
|
|
31
|
+
*/
|
|
32
|
+
export declare function writeMermaidDiagram(db: Database.Database, outPath: string, options?: MermaidOptions): DiagramResult;
|
|
33
|
+
/**
|
|
34
|
+
* Generate an import graph focusing on module dependencies.
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateImportGraph(db: Database.Database): DiagramResult;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a test coverage diagram.
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateTestGraph(db: Database.Database): DiagramResult;
|
|
41
|
+
//# sourceMappingURL=mermaid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../src/core/reports/mermaid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxD,MAAM,WAAW,cAAc;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACtC,oCAAoC;IACpC,SAAS,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,wCAAwC;IACxC,SAAS,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,qCAAqC;IACrC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAClC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,OAAO,GAAE,cAAmB,GAC7B,aAAa,CAiGf;AA0ED;;GAEG;AACH,wBAAgB,mBAAmB,CAC/B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,cAAmB,GAC7B,aAAa,CAOf;A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