@oddessentials/odd-repo-mapper 3.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.
- package/LICENSE +81 -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 +115 -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 +49 -0
- package/dist/core/scanner.d.ts.map +1 -0
- package/dist/core/scanner.js +196 -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 +88 -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
package/LICENSE
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# **Odd Essentials License (OEL)**
|
|
2
|
+
|
|
3
|
+
**Copyright © 2025 Odd Essentials, LLC. All rights reserved.**
|
|
4
|
+
|
|
5
|
+
This repository and all associated code are provided under a **source-available, non-commercial license**.
|
|
6
|
+
|
|
7
|
+
You are free to **read, clone, fork, modify, and contribute** to the Software **solely for non-commercial purposes**, under the terms below.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## **Intent and Scope**
|
|
12
|
+
|
|
13
|
+
The Software is **not** intended for use in commercial products, services, platforms, or revenue-generating activities without an explicit commercial license.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## **1. Permitted Non-Commercial Use**
|
|
18
|
+
|
|
19
|
+
You may use, modify, and run the Software **only for non-commercial purposes**, including:
|
|
20
|
+
|
|
21
|
+
- Personal experimentation and learning
|
|
22
|
+
- Educational or academic research
|
|
23
|
+
- Open-source development and maintenance
|
|
24
|
+
- Internal development **solely for non-commercial, non-revenue-generating evaluation or research purposes**
|
|
25
|
+
- Submitting contributions (pull requests) to this repository
|
|
26
|
+
- Using the fixtures to improve or validate **non-commercial open-source projects**
|
|
27
|
+
|
|
28
|
+
Any use that directly or indirectly supports a commercial offering is excluded unless separately licensed.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## **2. Prohibited Commercial Use**
|
|
33
|
+
|
|
34
|
+
You **may not** use the Software, or any derivative of it, **for commercial purposes**, including but not limited to:
|
|
35
|
+
|
|
36
|
+
- Selling, licensing, or monetizing the Software
|
|
37
|
+
- Using the Software as part of a revenue-generating product, service, platform, or SaaS
|
|
38
|
+
- Incorporating the Software into any tool, framework, or system offered for a fee or commercial advantage
|
|
39
|
+
- Using the Software to **train, fine-tune, benchmark, or evaluate AI models or systems intended for commercial deployment**
|
|
40
|
+
- Using the Software to build, enhance, or validate tools or services that provide **substantially similar functionality** to Odd Essentials offerings and are offered commercially
|
|
41
|
+
|
|
42
|
+
Commercial use requires a **separate, written commercial license** from Odd Essentials, LLC.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## **3. Contributions**
|
|
47
|
+
|
|
48
|
+
By submitting a pull request or other contribution:
|
|
49
|
+
|
|
50
|
+
- You grant Odd Essentials, LLC a **perpetual, irrevocable, worldwide, royalty-free license** to use, modify, distribute, sublicense, and relicense your contribution, with or without attribution.
|
|
51
|
+
- You represent that your contribution is your own original work and does not infringe any third-party rights.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## **4. No Warranty**
|
|
56
|
+
|
|
57
|
+
The Software is provided **“as is”**, without warranty of any kind, express or implied.
|
|
58
|
+
Odd Essentials, LLC disclaims all warranties, including fitness for a particular purpose and non-infringement.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## **5. Trademark**
|
|
63
|
+
|
|
64
|
+
The names **Odd Essentials**, related odd-\* code repositories, and any related logos or branding are trademarks of Odd Essentials, LLC. and may not be used without prior written permission.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## **6. Termination**
|
|
69
|
+
|
|
70
|
+
This license is automatically terminated if you violate its terms.
|
|
71
|
+
Upon termination, you must **cease all use and distribution** of the Software.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## **7. Commercial Licensing**
|
|
76
|
+
|
|
77
|
+
For commercial use, redistribution, integration, or partnership inquiries, contact:
|
|
78
|
+
|
|
79
|
+
**Odd Essentials, LLC**
|
|
80
|
+
📧 legal@oddessentials.com
|
|
81
|
+
🌐 https://oddessentials.com/
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# odd-repo-mapper
|
|
2
|
+
|
|
3
|
+
Deterministic code intelligence tool producing evidence-backed architecture diagrams and feature-test traceability matrices.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
npm run build
|
|
10
|
+
|
|
11
|
+
# Scan a repository
|
|
12
|
+
npx repo-mapper scan --root . --out ./out
|
|
13
|
+
|
|
14
|
+
# Verify outputs
|
|
15
|
+
npx repo-mapper verify ./out
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Philosophy
|
|
19
|
+
|
|
20
|
+
> The mapper does not explain the codebase.
|
|
21
|
+
> It produces evidence that allows humans (and tools) to explain it safely.
|
|
22
|
+
|
|
23
|
+
- **Evidence-first**: Every claim is backed by file/symbol/edge proof
|
|
24
|
+
- **Deterministic**: Same inputs → same outputs, byte-for-byte
|
|
25
|
+
- **Fail-closed**: Missing evidence → failure, not silent degradation
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
| Command | Description |
|
|
30
|
+
| -------- | ------------------------------------------------------------- |
|
|
31
|
+
| `scan` | Produce `repo_profile.json`, `toolchain.json`, `graph.sqlite` |
|
|
32
|
+
| `verify` | Validate artifacts against schemas and invariants |
|
|
33
|
+
|
|
34
|
+
## Artifacts
|
|
35
|
+
|
|
36
|
+
| File | Description |
|
|
37
|
+
| ------------------- | -------------------------------------------------- |
|
|
38
|
+
| `repo_profile.json` | File classification, language stats, build systems |
|
|
39
|
+
| `toolchain.json` | Node version, lockfile hash, dependencies |
|
|
40
|
+
| `graph.sqlite` | SQLite knowledge graph (canonical) |
|
|
41
|
+
| `graph.json` | Portable JSON export with contentHash |
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
See [LICENSE](./LICENSE) for details. © Odd Essentials, LLC
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,UAAU,SAIjB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server CLI command.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { startMcpServer } from '../../mcp/server.js';
|
|
6
|
+
export const mcpCommand = new Command('mcp')
|
|
7
|
+
.description('Start the MCP (Model Context Protocol) server')
|
|
8
|
+
.action(async () => {
|
|
9
|
+
await startMcpServer();
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/cli/commands/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;KACvC,WAAW,CAAC,+CAA+C,CAAC;KAC5D,MAAM,CAAC,KAAK,IAAI,EAAE;IACf,MAAM,cAAc,EAAE,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/report.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,eAAO,MAAM,aAAa,SA8HpB,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report command: generates diagrams and traceability reports.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { resolve, join } from 'node:path';
|
|
6
|
+
import { existsSync, copyFileSync, mkdirSync } from 'node:fs';
|
|
7
|
+
import Database from 'better-sqlite3';
|
|
8
|
+
import { writeMermaidDiagram, importCoverage, writeTraceabilityMatrix, writeTraceabilityMarkdown, } from '../../core/reports/index.js';
|
|
9
|
+
export const reportCommand = new Command('report')
|
|
10
|
+
.description('Generate architecture diagrams and traceability reports')
|
|
11
|
+
.option('-d, --dir <path>', 'Output directory containing graph.sqlite', './out')
|
|
12
|
+
.option('-o, --out <path>', 'Report output directory', './out/reports')
|
|
13
|
+
.option('-c, --coverage <path>', 'Path to coverage file (lcov or cobertura)')
|
|
14
|
+
.option('--format <format>', 'Output format: mermaid, json, markdown, sqlite, all', 'all')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
const dataDir = resolve(options.dir);
|
|
17
|
+
const outDir = resolve(options.out);
|
|
18
|
+
const dbPath = join(dataDir, 'graph.sqlite');
|
|
19
|
+
console.log(`Loading graph: ${dbPath}`);
|
|
20
|
+
console.log(`Reports output: ${outDir}`);
|
|
21
|
+
if (!existsSync(dbPath)) {
|
|
22
|
+
console.error(`✗ Graph database not found: ${dbPath}`);
|
|
23
|
+
console.error(' Run "repo-mapper scan" first to generate the graph.');
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
const db = new Database(dbPath, { readonly: true });
|
|
27
|
+
try {
|
|
28
|
+
const formats = options.format === 'all'
|
|
29
|
+
? ['mermaid', 'json', 'markdown', 'sqlite']
|
|
30
|
+
: [options.format];
|
|
31
|
+
// 1. Import coverage if provided
|
|
32
|
+
let coverageData = undefined;
|
|
33
|
+
if (options.coverage && existsSync(options.coverage)) {
|
|
34
|
+
console.log(`\nImporting coverage: ${options.coverage}`);
|
|
35
|
+
const coverageResult = importCoverage(options.coverage, resolve('.'));
|
|
36
|
+
if (coverageResult.errors.length > 0) {
|
|
37
|
+
for (const err of coverageResult.errors) {
|
|
38
|
+
console.error(` ⚠ ${err}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (coverageResult.data.files.length > 0) {
|
|
42
|
+
console.log(` Files: ${coverageResult.data.files.length}`);
|
|
43
|
+
console.log(` Coverage: ${coverageResult.data.percentage}%`);
|
|
44
|
+
coverageData = coverageResult.data;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// 2. Generate Mermaid diagrams
|
|
48
|
+
if (formats.includes('mermaid')) {
|
|
49
|
+
console.log('\n--- Generating Diagrams ---');
|
|
50
|
+
// Import graph
|
|
51
|
+
const importGraphPath = join(outDir, 'import-graph.mmd');
|
|
52
|
+
const importResult = writeMermaidDiagram(db, importGraphPath, {
|
|
53
|
+
nodeTypes: ['file', 'module'],
|
|
54
|
+
edgeKinds: ['import'],
|
|
55
|
+
direction: 'LR',
|
|
56
|
+
groupByDirectory: true,
|
|
57
|
+
});
|
|
58
|
+
console.log(` Import graph: ${importResult.nodeCount} nodes, ${importResult.edgeCount} edges`);
|
|
59
|
+
if (importResult.truncated) {
|
|
60
|
+
console.log(` ⚠ Diagram truncated (max 250 nodes)`);
|
|
61
|
+
}
|
|
62
|
+
console.log(` Wrote: ${importGraphPath}`);
|
|
63
|
+
// Full architecture diagram
|
|
64
|
+
const fullGraphPath = join(outDir, 'architecture.mmd');
|
|
65
|
+
const fullResult = writeMermaidDiagram(db, fullGraphPath, {
|
|
66
|
+
direction: 'TB',
|
|
67
|
+
groupByDirectory: true,
|
|
68
|
+
});
|
|
69
|
+
console.log(` Architecture: ${fullResult.nodeCount} nodes, ${fullResult.edgeCount} edges`);
|
|
70
|
+
console.log(` Wrote: ${fullGraphPath}`);
|
|
71
|
+
}
|
|
72
|
+
// 3. Generate traceability matrix
|
|
73
|
+
console.log('\n--- Generating Traceability Matrix ---');
|
|
74
|
+
if (formats.includes('json')) {
|
|
75
|
+
const jsonPath = join(outDir, 'traceability.json');
|
|
76
|
+
const matrix = writeTraceabilityMatrix(db, jsonPath, { coverageData });
|
|
77
|
+
console.log(` Links: ${matrix.stats.totalLinks}`);
|
|
78
|
+
console.log(` By type: ${Object.entries(matrix.stats.byLinkType)
|
|
79
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
80
|
+
.join(', ')}`);
|
|
81
|
+
console.log(` Wrote: ${jsonPath}`);
|
|
82
|
+
}
|
|
83
|
+
if (formats.includes('markdown')) {
|
|
84
|
+
const mdPath = join(outDir, 'traceability.md');
|
|
85
|
+
writeTraceabilityMarkdown(db, mdPath, { coverageData });
|
|
86
|
+
console.log(` Wrote: ${mdPath}`);
|
|
87
|
+
}
|
|
88
|
+
// 4. Export SQLite database
|
|
89
|
+
if (formats.includes('sqlite')) {
|
|
90
|
+
console.log('\n--- Exporting SQLite Database ---');
|
|
91
|
+
mkdirSync(outDir, { recursive: true });
|
|
92
|
+
const sqlitePath = join(outDir, 'graph.sqlite');
|
|
93
|
+
// Close db before copying to avoid locks, then copy
|
|
94
|
+
db.close();
|
|
95
|
+
copyFileSync(dbPath, sqlitePath);
|
|
96
|
+
console.log(` Wrote: ${sqlitePath}`);
|
|
97
|
+
console.log('\n✓ Reports generated');
|
|
98
|
+
return; // Early return since db is already closed
|
|
99
|
+
}
|
|
100
|
+
console.log('\n✓ Reports generated');
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
console.error(`\n✗ Report generation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
try {
|
|
108
|
+
db.close();
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Already closed (sqlite format)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/cli/commands/report.ts"],"names":[],"mappings":"AAAA;;GAEG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AAC;YACrC,OAAO,CAAC,0CAA0C;QACtD,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CACT,iCAAiC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACtF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;YAAS,CAAC;QACP,IAAI,CAAC;YACD,EAAE,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACL,iCAAiC;QACrC,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/scan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,WAAW,SAwIlB,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scan command: produces repo_profile.json + populated graph.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { resolve, join } from 'node:path';
|
|
6
|
+
import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
7
|
+
import { loadConfig, createDefaultConfig } from '../../core/config.js';
|
|
8
|
+
import { collectToolchain } from '../../core/toolchain.js';
|
|
9
|
+
import { scanDirectory } from '../../core/scanner.js';
|
|
10
|
+
import { initGraphDatabase, insertNode, insertEdge, writeGraphJson } from '../../core/graph.js';
|
|
11
|
+
import { indexAll } from '../../core/indexers/index.js';
|
|
12
|
+
export const scanCommand = new Command('scan')
|
|
13
|
+
.description('Scan a repository and produce repo_profile.json + knowledge graph')
|
|
14
|
+
.option('-c, --config <path>', 'Path to config file', 'repo-mapper.config.json')
|
|
15
|
+
.option('-r, --root <path>', 'Repository root directory', '.')
|
|
16
|
+
.option('-o, --out <path>', 'Output directory', './out')
|
|
17
|
+
.option('--skip-index', 'Skip language indexing (M0 mode)', false)
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
const rootDir = resolve(options.root);
|
|
20
|
+
const outDir = resolve(options.out);
|
|
21
|
+
console.log(`Scanning: ${rootDir}`);
|
|
22
|
+
console.log(`Output: ${outDir}`);
|
|
23
|
+
// Load or create config
|
|
24
|
+
const configPath = resolve(options.config);
|
|
25
|
+
let config = createDefaultConfig(rootDir);
|
|
26
|
+
const loadResult = loadConfig(configPath);
|
|
27
|
+
if (loadResult.success && loadResult.config) {
|
|
28
|
+
config = loadResult.config;
|
|
29
|
+
}
|
|
30
|
+
else if (loadResult.errors) {
|
|
31
|
+
console.log('Using default config (no config file found)');
|
|
32
|
+
}
|
|
33
|
+
// Collect toolchain
|
|
34
|
+
const toolchain = collectToolchain(rootDir);
|
|
35
|
+
console.log(`Node: ${toolchain.node}`);
|
|
36
|
+
// Scan
|
|
37
|
+
try {
|
|
38
|
+
const scanResult = scanDirectory(rootDir, toolchain, {
|
|
39
|
+
maxFiles: config.limits?.maxFiles ?? undefined,
|
|
40
|
+
testPatterns: config.indexing?.tests?.patterns ?? undefined,
|
|
41
|
+
});
|
|
42
|
+
// Write outputs
|
|
43
|
+
mkdirSync(outDir, { recursive: true });
|
|
44
|
+
// repo_profile.json (remove internal fileEntries before serialization)
|
|
45
|
+
const profilePath = join(outDir, 'repo_profile.json');
|
|
46
|
+
const { fileEntries: _fileEntries, ...profileForJson } = scanResult;
|
|
47
|
+
writeFileSync(profilePath, JSON.stringify(profileForJson, null, 2).replace(/\r\n/g, '\n'), 'utf8');
|
|
48
|
+
console.log(`Wrote: ${profilePath}`);
|
|
49
|
+
// toolchain.json
|
|
50
|
+
const toolchainPath = join(outDir, 'toolchain.json');
|
|
51
|
+
writeFileSync(toolchainPath, JSON.stringify(toolchain, null, 2).replace(/\r\n/g, '\n'), 'utf8');
|
|
52
|
+
console.log(`Wrote: ${toolchainPath}`);
|
|
53
|
+
// Initialize graph
|
|
54
|
+
const dbPath = join(outDir, 'graph.sqlite');
|
|
55
|
+
const db = initGraphDatabase(dbPath);
|
|
56
|
+
console.log(`Initialized: ${dbPath}`);
|
|
57
|
+
// Index if not skipped
|
|
58
|
+
if (!options.skipIndex) {
|
|
59
|
+
// Group files by language for indexers
|
|
60
|
+
const filesByLanguage = groupFilesByLanguage(scanResult.fileEntries ?? []);
|
|
61
|
+
console.log('\n--- Indexing ---');
|
|
62
|
+
const tsConfigPath = join(rootDir, 'tsconfig.json');
|
|
63
|
+
const indexResult = indexAll({
|
|
64
|
+
rootDir,
|
|
65
|
+
files: filesByLanguage,
|
|
66
|
+
tsConfigPath: existsSync(tsConfigPath) ? tsConfigPath : undefined,
|
|
67
|
+
});
|
|
68
|
+
// Insert nodes
|
|
69
|
+
for (const node of indexResult.nodes) {
|
|
70
|
+
insertNode(db, node);
|
|
71
|
+
}
|
|
72
|
+
// Insert edges
|
|
73
|
+
for (const edge of indexResult.edges) {
|
|
74
|
+
insertEdge(db, edge);
|
|
75
|
+
}
|
|
76
|
+
console.log(`TypeScript: ${indexResult.stats.typescript.nodes} nodes, ${indexResult.stats.typescript.edges} edges`);
|
|
77
|
+
console.log(`Python: ${indexResult.stats.python.nodes} nodes, ${indexResult.stats.python.edges} edges`);
|
|
78
|
+
console.log(`Go: ${indexResult.stats.go.nodes} nodes, ${indexResult.stats.go.edges} edges`);
|
|
79
|
+
console.log(`Rust: ${indexResult.stats.rust.nodes} nodes, ${indexResult.stats.rust.edges} edges`);
|
|
80
|
+
}
|
|
81
|
+
// Export graph.json
|
|
82
|
+
const graphPath = join(outDir, 'graph.json');
|
|
83
|
+
const graphExport = await writeGraphJson(db, graphPath);
|
|
84
|
+
console.log(`\nWrote: ${graphPath} (${graphExport.meta.nodeCount} nodes, ${graphExport.meta.edgeCount} edges)`);
|
|
85
|
+
db.close();
|
|
86
|
+
// Print summary
|
|
87
|
+
console.log('\n--- Scan Summary ---');
|
|
88
|
+
console.log(`Files: ${scanResult.files.total}`);
|
|
89
|
+
console.log(`Languages: ${scanResult.languages.map((l) => `${l.id}(${l.fileCount})`).join(', ')}`);
|
|
90
|
+
console.log(`Build sys: ${scanResult.buildSystems
|
|
91
|
+
.filter((b) => b.detected)
|
|
92
|
+
.map((b) => b.id)
|
|
93
|
+
.join(', ') || 'none'}`);
|
|
94
|
+
if (scanResult.warnings.length > 0) {
|
|
95
|
+
console.log('\nWarnings:');
|
|
96
|
+
for (const w of scanResult.warnings) {
|
|
97
|
+
console.log(` ⚠ ${w}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
console.log('\n✓ Scan complete');
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
console.error(`\n✗ Scan failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
function groupFilesByLanguage(files) {
|
|
108
|
+
const map = new Map();
|
|
109
|
+
for (const file of files) {
|
|
110
|
+
const lang = file.language;
|
|
111
|
+
if (!map.has(lang)) {
|
|
112
|
+
map.set(lang, []);
|
|
113
|
+
}
|
|
114
|
+
map.get(lang).push(file.path);
|
|
115
|
+
}
|
|
116
|
+
return map;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../src/cli/commands/scan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EA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WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,SA4CpB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify command: validates all artifacts in output directory.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { verifyOutputDir } from '../../core/verify.js';
|
|
7
|
+
export const verifyCommand = new Command('verify')
|
|
8
|
+
.description('Verify artifacts in an output directory')
|
|
9
|
+
.argument('<outDir>', 'Output directory to verify')
|
|
10
|
+
.option('-r, --root <path>', 'Repository root directory (for toolchain alignment)', '.')
|
|
11
|
+
.action(async (outDir, options) => {
|
|
12
|
+
const resolvedOut = resolve(outDir);
|
|
13
|
+
const resolvedRoot = resolve(options.root);
|
|
14
|
+
console.log(`Verifying: ${resolvedOut}`);
|
|
15
|
+
console.log(`Root: ${resolvedRoot}`);
|
|
16
|
+
console.log('');
|
|
17
|
+
try {
|
|
18
|
+
const result = await verifyOutputDir(resolvedOut, resolvedRoot);
|
|
19
|
+
if (result.warnings.length > 0) {
|
|
20
|
+
console.log('Warnings:');
|
|
21
|
+
for (const w of result.warnings) {
|
|
22
|
+
console.log(` ⚠ ${w}`);
|
|
23
|
+
}
|
|
24
|
+
console.log('');
|
|
25
|
+
}
|
|
26
|
+
if (result.errors.length > 0) {
|
|
27
|
+
console.log('Errors:');
|
|
28
|
+
for (const e of result.errors) {
|
|
29
|
+
console.log(` ✗ ${e}`);
|
|
30
|
+
}
|
|
31
|
+
console.log('');
|
|
32
|
+
}
|
|
33
|
+
if (result.passed) {
|
|
34
|
+
console.log('✓ Verification passed');
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.log(`✗ Verification failed (${result.errors.length} errors)`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(`\n✗ Verification error: ${err instanceof Error ? err.message : String(err)}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/cli/commands/verify.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC7C,WAAW,CAAC,yCAAyC,CAAC;KACtD,QAAQ,CAAC,UAAU,EAAE,4BAA4B,CAAC;KAClD,MAAM,CAAC,mBAAmB,EAAE,qDAAqD,EAAE,GAAG,CAAC;KACvF,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,OAAO,EAAE,EAAE;IACtC,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,cAAc,WAAW,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,cAAc,YAAY,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAEhE,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACzB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACvB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,0BAA0B,MAAM,CAAC,MAAM,CAAC,MAAM,UAAU,CAAC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CACT,2BAA2B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAChF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI entry point for repo-mapper.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { scanCommand } from './commands/scan.js';
|
|
6
|
+
import { verifyCommand } from './commands/verify.js';
|
|
7
|
+
import { reportCommand } from './commands/report.js';
|
|
8
|
+
import { mcpCommand } from './commands/mcp.js';
|
|
9
|
+
import { REPO_MAPPER_VERSION } from '../core/constants.js';
|
|
10
|
+
const program = new Command();
|
|
11
|
+
program
|
|
12
|
+
.name('repo-mapper')
|
|
13
|
+
.description('Deterministic code intelligence tool')
|
|
14
|
+
.version(REPO_MAPPER_VERSION);
|
|
15
|
+
program.addCommand(scanCommand);
|
|
16
|
+
program.addCommand(verifyCommand);
|
|
17
|
+
program.addCommand(reportCommand);
|
|
18
|
+
program.addCommand(mcpCommand);
|
|
19
|
+
program.parse();
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,sCAAsC,CAAC;KACnD,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAElC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAE/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration loading and validation.
|
|
3
|
+
* Uses Ajv for strict JSON Schema validation.
|
|
4
|
+
*/
|
|
5
|
+
export interface RepoMapperConfig {
|
|
6
|
+
version: '0.1.0';
|
|
7
|
+
project: {
|
|
8
|
+
rootDir: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
repoId?: string;
|
|
11
|
+
};
|
|
12
|
+
indexing?: {
|
|
13
|
+
languages?: {
|
|
14
|
+
tier1?: ('typescript' | 'javascript' | 'python' | 'go' | 'rust')[];
|
|
15
|
+
tier2?: ('java' | 'kotlin' | 'csharp' | 'ruby' | 'php')[];
|
|
16
|
+
};
|
|
17
|
+
tests?: {
|
|
18
|
+
patterns?: string[];
|
|
19
|
+
linking?: {
|
|
20
|
+
minConfidence?: number;
|
|
21
|
+
allowBelowThreshold?: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
output: {
|
|
26
|
+
outDir: string;
|
|
27
|
+
writeIntermediateArtifacts?: boolean;
|
|
28
|
+
};
|
|
29
|
+
determinism?: {
|
|
30
|
+
sortOrder?: 'path_then_name' | 'name_then_path';
|
|
31
|
+
stableIdMode?: 'path_hash' | 'content_hash';
|
|
32
|
+
};
|
|
33
|
+
limits?: {
|
|
34
|
+
maxFiles?: number;
|
|
35
|
+
maxEdges?: number;
|
|
36
|
+
maxSymbols?: number;
|
|
37
|
+
maxNodesPerDiagram?: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface ConfigLoadResult {
|
|
41
|
+
success: boolean;
|
|
42
|
+
config?: RepoMapperConfig;
|
|
43
|
+
errors?: string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load and validate configuration from file.
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadConfig(configPath: string): ConfigLoadResult;
|
|
49
|
+
/**
|
|
50
|
+
* Create a minimal default config for a project.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createDefaultConfig(rootDir: string): RepoMapperConfig;
|
|
53
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,QAAQ,CAAC,EAAE;QACP,SAAS,CAAC,EAAE;YACR,KAAK,CAAC,EAAE,CAAC,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;YACnE,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC;SAC7D,CAAC;QACF,KAAK,CAAC,EAAE;YACJ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;YACpB,OAAO,CAAC,EAAE;gBACN,aAAa,CAAC,EAAE,MAAM,CAAC;gBACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;aACjC,CAAC;SACL,CAAC;KACL,CAAC;IACF,MAAM,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,0BAA0B,CAAC,EAAE,OAAO,CAAC;KACxC,CAAC;IACF,WAAW,CAAC,EAAE;QACV,SAAS,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;QAChD,YAAY,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC;KAC/C,CAAC;IACF,MAAM,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MA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