aidoc-kit 1.2.1 → 1.3.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/README.md +48 -5
- package/dist/cli.js +183 -25
- package/dist/cli.js.map +1 -1
- package/dist/codegraph/detect.d.ts +16 -0
- package/dist/codegraph/detect.d.ts.map +1 -0
- package/dist/codegraph/detect.js +68 -0
- package/dist/codegraph/detect.js.map +1 -0
- package/dist/codegraph/loader.d.ts +9 -0
- package/dist/codegraph/loader.d.ts.map +1 -0
- package/dist/codegraph/loader.js +161 -0
- package/dist/codegraph/loader.js.map +1 -0
- package/dist/codegraph/runner.d.ts +18 -0
- package/dist/codegraph/runner.d.ts.map +1 -0
- package/dist/codegraph/runner.js +60 -0
- package/dist/codegraph/runner.js.map +1 -0
- package/dist/core/scanner.js +1 -1
- package/dist/core/scanner.js.map +1 -1
- package/dist/core/writer.d.ts.map +1 -1
- package/dist/core/writer.js +8 -2
- package/dist/core/writer.js.map +1 -1
- package/dist/enricher/basicEnricher.d.ts +27 -0
- package/dist/enricher/basicEnricher.d.ts.map +1 -0
- package/dist/enricher/basicEnricher.js +157 -0
- package/dist/enricher/basicEnricher.js.map +1 -0
- package/dist/graph/query.d.ts +28 -0
- package/dist/graph/query.d.ts.map +1 -0
- package/dist/graph/query.js +24 -0
- package/dist/graph/query.js.map +1 -0
- package/dist/graph/serializer.d.ts +10 -0
- package/dist/graph/serializer.d.ts.map +1 -0
- package/dist/graph/serializer.js +51 -0
- package/dist/graph/serializer.js.map +1 -0
- package/dist/graph/types.d.ts +101 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +27 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadRawGraph = loadRawGraph;
|
|
37
|
+
/**
|
|
38
|
+
* @ai-agent general-expert
|
|
39
|
+
* @ai-agent-hint If you are not the general-expert specialist, consider switching to a specialized agent in Copilot Chat. Run `npx aidoc-kit agents` to generate agent instruction files.
|
|
40
|
+
* @ai-runtime UNIVERSEL
|
|
41
|
+
*
|
|
42
|
+
* @ai-context
|
|
43
|
+
* [GENERATED] This file exports: loadRawGraph
|
|
44
|
+
* Imported by: src/cli.ts
|
|
45
|
+
*
|
|
46
|
+
* @ai-when-modifying
|
|
47
|
+
* 1. Check cascade files below before modifying
|
|
48
|
+
* 2. After modifying, ask the developer to run @ai-validate
|
|
49
|
+
* 3. If you have no terminal access, report the command to run
|
|
50
|
+
*
|
|
51
|
+
* @ai-cascade
|
|
52
|
+
* - src/cli.ts
|
|
53
|
+
*
|
|
54
|
+
* @ai-validate
|
|
55
|
+
* npm run typecheck
|
|
56
|
+
*/
|
|
57
|
+
const node_fs_1 = require("node:fs");
|
|
58
|
+
const runner_1 = require("./runner");
|
|
59
|
+
/**
|
|
60
|
+
* Open the CodeGraph SQLite index with Node's built-in driver.
|
|
61
|
+
* node:sqlite ships with Node >= 22.5 — the same requirement CodeGraph
|
|
62
|
+
* itself has, so this adds no constraint beyond the indexing engine's own.
|
|
63
|
+
* Zero npm runtime dependency is preserved.
|
|
64
|
+
*/
|
|
65
|
+
async function openDatabase(dbPath) {
|
|
66
|
+
let sqlite;
|
|
67
|
+
try {
|
|
68
|
+
sqlite = await Promise.resolve().then(() => __importStar(require('node:sqlite')));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
throw new Error(`Reading the CodeGraph index requires Node.js >= 22.5 (built-in node:sqlite). ` +
|
|
72
|
+
`Current version: ${process.version}.`);
|
|
73
|
+
}
|
|
74
|
+
return new sqlite.DatabaseSync(dbPath, { readOnly: true });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* CodeGraph's SQLite schema is internal to that project, not a public
|
|
78
|
+
* contract. Verify the tables we read still exist and fail with an
|
|
79
|
+
* actionable message instead of a cryptic SQL error if the schema moved.
|
|
80
|
+
*/
|
|
81
|
+
function assertSchema(db, dbPath) {
|
|
82
|
+
const rows = db
|
|
83
|
+
.prepare(`SELECT name FROM sqlite_master WHERE type = 'table'`)
|
|
84
|
+
.all();
|
|
85
|
+
const tables = new Set(rows.map(r => r.name));
|
|
86
|
+
const required = ['files', 'nodes', 'edges'];
|
|
87
|
+
const missing = required.filter(t => !tables.has(t));
|
|
88
|
+
if (missing.length > 0) {
|
|
89
|
+
throw new Error(`Unexpected CodeGraph schema in ${dbPath} (missing table(s): ${missing.join(', ')}). ` +
|
|
90
|
+
`The installed CodeGraph version may be newer than what aidoc-kit supports — ` +
|
|
91
|
+
`please open an issue at https://github.com/Clemsrec/aidoc-kit/issues.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function readMetadata(db, key) {
|
|
95
|
+
try {
|
|
96
|
+
const row = db
|
|
97
|
+
.prepare(`SELECT value FROM project_metadata WHERE key = ?`)
|
|
98
|
+
.get(key);
|
|
99
|
+
return row?.value ?? null;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Load the raw knowledge graph produced by `codegraph index`.
|
|
107
|
+
* Symbol-level edges are aggregated to file level: the enrichment layer
|
|
108
|
+
* reasons about files, and the full symbol detail stays queryable in the
|
|
109
|
+
* CodeGraph database itself.
|
|
110
|
+
*/
|
|
111
|
+
async function loadRawGraph(projectRoot) {
|
|
112
|
+
const dbPath = (0, runner_1.codegraphDbPath)(projectRoot);
|
|
113
|
+
if (!(0, node_fs_1.existsSync)(dbPath)) {
|
|
114
|
+
throw new Error(`No CodeGraph index found at ${dbPath}. Run \`npx aidoc-kit index\` first.`);
|
|
115
|
+
}
|
|
116
|
+
const db = await openDatabase(dbPath);
|
|
117
|
+
try {
|
|
118
|
+
assertSchema(db, dbPath);
|
|
119
|
+
const files = db
|
|
120
|
+
.prepare(`SELECT path, language, node_count FROM files ORDER BY path`)
|
|
121
|
+
.all()
|
|
122
|
+
.map(r => ({ path: r.path, language: r.language, symbolCount: r.node_count }));
|
|
123
|
+
// `import` nodes are re-export bookkeeping, not declarations — skip them
|
|
124
|
+
const symbols = db
|
|
125
|
+
.prepare(`SELECT id, kind, name, qualified_name, file_path, start_line, end_line, is_exported
|
|
126
|
+
FROM nodes
|
|
127
|
+
WHERE kind NOT IN ('import', 'file')
|
|
128
|
+
ORDER BY file_path, start_line`)
|
|
129
|
+
.all()
|
|
130
|
+
.map(r => ({
|
|
131
|
+
id: r.id,
|
|
132
|
+
kind: r.kind,
|
|
133
|
+
name: r.name,
|
|
134
|
+
qualifiedName: r.qualified_name,
|
|
135
|
+
file: r.file_path,
|
|
136
|
+
startLine: r.start_line,
|
|
137
|
+
endLine: r.end_line,
|
|
138
|
+
exported: r.is_exported === 1,
|
|
139
|
+
}));
|
|
140
|
+
const fileEdges = db
|
|
141
|
+
.prepare(`SELECT s.file_path AS from_file, t.file_path AS to_file, e.kind AS kind, COUNT(*) AS count
|
|
142
|
+
FROM edges e
|
|
143
|
+
JOIN nodes s ON s.id = e.source
|
|
144
|
+
JOIN nodes t ON t.id = e.target
|
|
145
|
+
WHERE s.file_path != t.file_path
|
|
146
|
+
GROUP BY s.file_path, t.file_path, e.kind
|
|
147
|
+
ORDER BY from_file, to_file, kind`)
|
|
148
|
+
.all()
|
|
149
|
+
.map(r => ({ from: r.from_file, to: r.to_file, kind: r.kind, count: r.count }));
|
|
150
|
+
return {
|
|
151
|
+
files,
|
|
152
|
+
symbols,
|
|
153
|
+
fileEdges,
|
|
154
|
+
codegraphVersion: readMetadata(db, 'indexed_with_version'),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
db.close();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/codegraph/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,oCA4DC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Q,EAAE,CAAC,CAAC,WAAW,KAAK,CAAC;SAC9B,CAAC,CAAC,CAAA;QAEL,MAAM,SAAS,GAAmB,EAAE;aACjC,OAAO,CACN;;;;;;2CAMmC,CACpC;aACA,GAAG,EAAiF;aACpF,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QAEjF,OAAO;YACL,KAAK;YACL,OAAO;YACP,SAAS;YACT,gBAAgB,EAAE,YAAY,CAAC,EAAE,EAAE,sBAAsB,CAAC;SAC3D,CAAA;IACH,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAA;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Location of the CodeGraph SQLite index inside a project. */
|
|
2
|
+
export declare function codegraphDbPath(projectRoot: string): string;
|
|
3
|
+
export interface RunIndexOptions {
|
|
4
|
+
/** Map to `codegraph sync` (changes since last index) instead of a full rebuild */
|
|
5
|
+
incremental: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Run CodeGraph indexing on the target project and verify the index exists.
|
|
9
|
+
*
|
|
10
|
+
* First run: `codegraph init --yes` (initializes .codegraph/ and builds the
|
|
11
|
+
* initial index). Subsequent runs: `codegraph index` (full rebuild) or
|
|
12
|
+
* `codegraph sync` when incremental.
|
|
13
|
+
*
|
|
14
|
+
* The binary is spawned directly (no shell) with inherited stdio so
|
|
15
|
+
* CodeGraph's own progress output stays visible.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runCodegraphIndex(projectRoot: string, binPath: string, opts: RunIndexOptions): void;
|
|
18
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/codegraph/runner.ts"],"names":[],"mappings":"AAyBA,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,MAAM,WAAW,eAAe;IAC9B,mFAAmF;IACnF,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,GACpB,IAAI,CAoBN"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.codegraphDbPath = codegraphDbPath;
|
|
4
|
+
exports.runCodegraphIndex = runCodegraphIndex;
|
|
5
|
+
/**
|
|
6
|
+
* @ai-agent general-expert
|
|
7
|
+
* @ai-agent-hint If you are not the general-expert specialist, consider switching to a specialized agent in Copilot Chat. Run `npx aidoc-kit agents` to generate agent instruction files.
|
|
8
|
+
* @ai-runtime UNIVERSEL
|
|
9
|
+
*
|
|
10
|
+
* @ai-context
|
|
11
|
+
* [GENERATED] This file exports: codegraphDbPath, RunIndexOptions, runCodegraphIndex
|
|
12
|
+
* Imported by: src/cli.ts, src/codegraph/loader.ts
|
|
13
|
+
*
|
|
14
|
+
* @ai-when-modifying
|
|
15
|
+
* 1. Check cascade files below before modifying
|
|
16
|
+
* 2. After modifying, ask the developer to run @ai-validate
|
|
17
|
+
* 3. If you have no terminal access, report the command to run
|
|
18
|
+
*
|
|
19
|
+
* @ai-cascade
|
|
20
|
+
* - src/cli.ts
|
|
21
|
+
* - src/codegraph/loader.ts
|
|
22
|
+
*
|
|
23
|
+
* @ai-validate
|
|
24
|
+
* npm run typecheck
|
|
25
|
+
*/
|
|
26
|
+
const node_child_process_1 = require("node:child_process");
|
|
27
|
+
const node_fs_1 = require("node:fs");
|
|
28
|
+
const node_path_1 = require("node:path");
|
|
29
|
+
/** Location of the CodeGraph SQLite index inside a project. */
|
|
30
|
+
function codegraphDbPath(projectRoot) {
|
|
31
|
+
return (0, node_path_1.join)(projectRoot, '.codegraph', 'codegraph.db');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Run CodeGraph indexing on the target project and verify the index exists.
|
|
35
|
+
*
|
|
36
|
+
* First run: `codegraph init --yes` (initializes .codegraph/ and builds the
|
|
37
|
+
* initial index). Subsequent runs: `codegraph index` (full rebuild) or
|
|
38
|
+
* `codegraph sync` when incremental.
|
|
39
|
+
*
|
|
40
|
+
* The binary is spawned directly (no shell) with inherited stdio so
|
|
41
|
+
* CodeGraph's own progress output stays visible.
|
|
42
|
+
*/
|
|
43
|
+
function runCodegraphIndex(projectRoot, binPath, opts) {
|
|
44
|
+
const initialized = (0, node_fs_1.existsSync)(codegraphDbPath(projectRoot));
|
|
45
|
+
const subcommand = !initialized ? 'init' : opts.incremental ? 'sync' : 'index';
|
|
46
|
+
const args = subcommand === 'init'
|
|
47
|
+
? ['init', '--yes', projectRoot]
|
|
48
|
+
: [subcommand, projectRoot];
|
|
49
|
+
const result = (0, node_child_process_1.spawnSync)(binPath, args, { stdio: 'inherit' });
|
|
50
|
+
if (result.error) {
|
|
51
|
+
throw new Error(`Failed to run codegraph ${subcommand}: ${result.error.message}`);
|
|
52
|
+
}
|
|
53
|
+
if (result.status !== 0) {
|
|
54
|
+
throw new Error(`codegraph ${subcommand} exited with code ${result.status ?? 'unknown'}`);
|
|
55
|
+
}
|
|
56
|
+
if (!(0, node_fs_1.existsSync)(codegraphDbPath(projectRoot))) {
|
|
57
|
+
throw new Error(`codegraph ${subcommand} completed but ${codegraphDbPath(projectRoot)} was not created.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/codegraph/runner.ts"],"names":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C9C,MAAM,IAAI,KAAK,CACb,aAAa,UAAU,kBAAkB,eAAe,CAAC,WAAW,CAAC,mBAAmB,CACzF,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/dist/core/scanner.js
CHANGED
|
@@ -62,7 +62,7 @@ const node_fs_1 = require("node:fs");
|
|
|
62
62
|
const node_path_1 = require("node:path");
|
|
63
63
|
const EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx']);
|
|
64
64
|
const IGNORED_DIRS = new Set([
|
|
65
|
-
'node_modules', '.git', 'dist', '.next', 'out', 'build', '.codemod', 'coverage',
|
|
65
|
+
'node_modules', '.git', 'dist', '.next', '_next', 'out', 'build', '.codemod', '.codegraph', 'coverage',
|
|
66
66
|
]);
|
|
67
67
|
// ─── Public API ────────────────────────────────────────────────────────────
|
|
68
68
|
/**
|
package/dist/core/scanner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/core/scanner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,sDAgDC;AAqBD,kCAeC;AAED,sCAqCC;AAID,0BA2BC;AA/LD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,+CAAgC;AAChC,qCAA6D;AAC7D,yCAAqE;AAGrE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;AAC1D,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/core/scanner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,sDAgDC;AAqBD,kCAeC;AAED,sCAqCC;AAID,0B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AAC,IAAI,GAAG,wCAAwC,EAAE,GAAG,CAAC,CAAA;IAC9E,IAAI,CAAC,CAAA;IACL,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1B,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/core/writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/core/writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,UAAU,EAAE,MAAM,UAAU,CAAA;AAKrE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAKhF;AAID,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CA2G3E;AAID,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAetE"}
|
package/dist/core/writer.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.writeAgentsMd = writeAgentsMd;
|
|
|
5
5
|
exports.writeDocBlock = writeDocBlock;
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
+
const serializer_1 = require("../graph/serializer");
|
|
8
9
|
// ─── Knowledge base ────────────────────────────────────────────────────────
|
|
9
10
|
function writeKnowledgeBase(result, projectRoot) {
|
|
10
11
|
const outDir = (0, node_path_1.join)(projectRoot, '.codemod');
|
|
@@ -21,9 +22,14 @@ function writeAgentsMd(result, projectRoot) {
|
|
|
21
22
|
`> Generated by aidoc-kit on ${new Date().toISOString().slice(0, 10)}`,
|
|
22
23
|
`> ${result.totalScanned} files scanned — ${result.docs.length} with @ai-* docs`,
|
|
23
24
|
'',
|
|
24
|
-
'## Agents and their domains',
|
|
25
|
-
'',
|
|
26
25
|
];
|
|
26
|
+
// Enriched code graph section — placed first so agents see it before
|
|
27
|
+
// anything else. Only written when aidoc-graph.json exists.
|
|
28
|
+
const graph = (0, serializer_1.readEnrichedGraph)(projectRoot);
|
|
29
|
+
if (graph) {
|
|
30
|
+
lines.push(`## Code graph — query it, never read it in full`, '', `\`${serializer_1.GRAPH_FILENAME}\` (project root) maps every file: role (client/server/universal),`, `criticality 0-100, dependents and dependencies. Generated ${graph.generatedAt.slice(0, 10)}`, `by \`npx aidoc-kit index\` — ${graph.stats.files} files, ${graph.stats.edges} edges.`, '', `Rules for AI agents:`, '', `1. **Never load ${serializer_1.GRAPH_FILENAME} entirely** — it grows with the project. Query it.`, `2. Before modifying a file, check its entry. If \`criticalityLevel\` is \`high\` or`, ` \`critical\`, read every dependent file first.`, `3. Never import a \`role: server\` file from client code.`, `4. Freshness: if \`generatedAt\` is older than the last commit, the graph may be stale —`, ` ask the developer to run \`npx aidoc-kit index --incremental\` (do not run it yourself).`, '', `Queries (replace the path):`, '', '```bash', `# One file's entry (role, criticality, tags)`, `node -e "const g=require('./${serializer_1.GRAPH_FILENAME}');console.log(g.files.find(f=>f.file==='src/foo.ts'))"`, '', `# Who depends on a file (check these before modifying it)`, `node -e "const g=require('./${serializer_1.GRAPH_FILENAME}');console.log([...new Set(g.edges.filter(e=>e.to==='src/foo.ts').map(e=>e.from))])"`, '', `# Most critical files`, `node -e "const g=require('./${serializer_1.GRAPH_FILENAME}');g.files.filter(f=>f.criticality>=55).forEach(f=>console.log(f.criticality,f.file))"`, '```', '');
|
|
31
|
+
}
|
|
32
|
+
lines.push('## Agents and their domains', '');
|
|
27
33
|
for (const [agent, info] of Object.entries(kb.agents)) {
|
|
28
34
|
lines.push(`### ${agent}`, '');
|
|
29
35
|
lines.push(`**Files:** ${info.owns.length}`);
|
package/dist/core/writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../src/core/writer.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../src/core/writer.ts"],"names":[],"mappings":";;AAOA,gDAKC;AAID,sCA2GC;AAID,sCAeC;AA9ID,qCAAgE;AAChE,yCAAgC;AAEhC,oDAAuE;AAEvE,8EAA8E;AAE9E,SAAgB,kBAAkB,CAAC,MAAkB,EAAE,WAAmB;IACxE,MAAM,MAAM,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,UAAU,CAAC,CAAA;IAC5C,IAAA,mBAAS,EAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACtC,MAAM,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1C,IAAA,uBAAa,EAAC,IAAA,gBAAI,EAAC,MAAM,EAAE,wBAAwB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAC7F,CAAC;AAED,8EAA8E;AAE9E,SAAgB,aAAa,CAAC,MAAkB,EAAE,WAAmB;IACnE,MAAM,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1C,MAAM,KAAK,GAAa;QACtB,UAAU;QACV,EAAE;QACF,+BAA+B,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE;QACtE,KAAK,MAAM,CAAC,YAAY,oBAAoB,MAAM,CAAC,IAAI,CAAC,MAAM,kBAAkB;QAChF,EAAE;KACH,CAAA;IAED,qEAAqE;IACrE,4DAA4D;I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C;YAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,CAAA;QAEhE,cAAc;QACd,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,IAAI,WAAW,CAAA;QACrC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAAE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,CAAA;QACxC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAE7B,sBAAsB;QACtB,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACjB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAA;YAC5E,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA;AACxG,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CriticalityLevel, EnrichedGraph, FileRole, RawGraph } from '../graph/types';
|
|
2
|
+
/**
|
|
3
|
+
* Infer the execution role of a file. Explicit directives win, then path
|
|
4
|
+
* conventions (Next.js API routes, server/ folders, .server/.client
|
|
5
|
+
* suffixes), then content heuristics — same priority order as the
|
|
6
|
+
* @ai-runtime detection in core/transformer.
|
|
7
|
+
*/
|
|
8
|
+
export declare function inferRole(relPath: string, source: string): {
|
|
9
|
+
role: FileRole;
|
|
10
|
+
reason: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function inferTags(relPath: string): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Criticality score, 0-100:
|
|
15
|
+
* - fan-in: 6 points per dependent file, capped at 60 (10+ dependents saturate)
|
|
16
|
+
* - +15 when the file is an API surface
|
|
17
|
+
* - +25 when it belongs to a sensitive domain (auth, billing, payment)
|
|
18
|
+
*/
|
|
19
|
+
export declare function computeCriticality(inDegree: number, tags: string[]): number;
|
|
20
|
+
export declare function criticalityLevel(score: number): CriticalityLevel;
|
|
21
|
+
/**
|
|
22
|
+
* Layer aidoc-kit's intelligence (roles, criticality, tags) on top of the
|
|
23
|
+
* raw CodeGraph output. Pure function apart from reading file sources for
|
|
24
|
+
* directive detection — a file that cannot be read falls back to path rules.
|
|
25
|
+
*/
|
|
26
|
+
export declare function enrichGraph(raw: RawGraph, projectRoot: string): EnrichedGraph;
|
|
27
|
+
//# sourceMappingURL=basicEnricher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basicEnricher.d.ts","sourceRoot":"","sources":["../../src/enricher/basicEnricher.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,gBAAgB,EAEhB,aAAa,EACb,QAAQ,EACR,QAAQ,EACT,MAAM,gBAAgB,CAAA;AAOvB;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAmB7F;AAcD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAGnD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAK3E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAKhE;AAID;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAsD7E"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inferRole = inferRole;
|
|
4
|
+
exports.inferTags = inferTags;
|
|
5
|
+
exports.computeCriticality = computeCriticality;
|
|
6
|
+
exports.criticalityLevel = criticalityLevel;
|
|
7
|
+
exports.enrichGraph = enrichGraph;
|
|
8
|
+
/**
|
|
9
|
+
* @ai-agent general-expert
|
|
10
|
+
* @ai-agent-hint If you are not the general-expert specialist, consider switching to a specialized agent in Copilot Chat. Run `npx aidoc-kit agents` to generate agent instruction files.
|
|
11
|
+
* @ai-runtime UNIVERSEL
|
|
12
|
+
*
|
|
13
|
+
* @ai-context
|
|
14
|
+
* [GENERATED] This file exports: inferRole, inferTags, computeCriticality, criticalityLevel, enrichGraph
|
|
15
|
+
* Imported by: src/cli.ts
|
|
16
|
+
*
|
|
17
|
+
* @ai-when-modifying
|
|
18
|
+
* 1. Check cascade files below before modifying
|
|
19
|
+
* 2. After modifying, ask the developer to run @ai-validate
|
|
20
|
+
* 3. If you have no terminal access, report the command to run
|
|
21
|
+
*
|
|
22
|
+
* @ai-cascade
|
|
23
|
+
* - src/cli.ts
|
|
24
|
+
*
|
|
25
|
+
* @ai-validate
|
|
26
|
+
* npm run typecheck
|
|
27
|
+
*/
|
|
28
|
+
const node_fs_1 = require("node:fs");
|
|
29
|
+
const node_path_1 = require("node:path");
|
|
30
|
+
// ─── Role inference ────────────────────────────────────────────────────────
|
|
31
|
+
const SERVER_PATH_PATTERN = /(^|\/)(app\/api|pages\/api|server|api)(\/|$)/;
|
|
32
|
+
const CLIENT_HOOKS_PATTERN = /\buseState\b|\buseEffect\b|\buseRef\b|\buseReducer\b|\buseCallback\b|\buseMemo\b/;
|
|
33
|
+
/**
|
|
34
|
+
* Infer the execution role of a file. Explicit directives win, then path
|
|
35
|
+
* conventions (Next.js API routes, server/ folders, .server/.client
|
|
36
|
+
* suffixes), then content heuristics — same priority order as the
|
|
37
|
+
* @ai-runtime detection in core/transformer.
|
|
38
|
+
*/
|
|
39
|
+
function inferRole(relPath, source) {
|
|
40
|
+
const head = source.slice(0, 300);
|
|
41
|
+
if (/^\s*(?:\/\/[^\n]*\n\s*)*['"]use client['"]/.test(head)) {
|
|
42
|
+
return { role: 'client', reason: `'use client' directive` };
|
|
43
|
+
}
|
|
44
|
+
if (/^\s*(?:\/\/[^\n]*\n\s*)*['"]use server['"]/.test(head)) {
|
|
45
|
+
return { role: 'server', reason: `'use server' directive` };
|
|
46
|
+
}
|
|
47
|
+
const normalized = relPath.replace(/\\/g, '/');
|
|
48
|
+
if (/\.server\.[jt]sx?$/.test(normalized))
|
|
49
|
+
return { role: 'server', reason: '.server file suffix' };
|
|
50
|
+
if (/\.client\.[jt]sx?$/.test(normalized))
|
|
51
|
+
return { role: 'client', reason: '.client file suffix' };
|
|
52
|
+
const serverMatch = normalized.match(SERVER_PATH_PATTERN);
|
|
53
|
+
if (serverMatch)
|
|
54
|
+
return { role: 'server', reason: `server path (${serverMatch[2]}/)` };
|
|
55
|
+
if (/['"]firebase-admin['"]/.test(source))
|
|
56
|
+
return { role: 'server', reason: 'firebase-admin import' };
|
|
57
|
+
if (CLIENT_HOOKS_PATTERN.test(source))
|
|
58
|
+
return { role: 'client', reason: 'React hooks usage' };
|
|
59
|
+
return { role: 'universal', reason: 'no client/server signal' };
|
|
60
|
+
}
|
|
61
|
+
// ─── Criticality ───────────────────────────────────────────────────────────
|
|
62
|
+
const TAG_PATTERNS = [
|
|
63
|
+
['api', /(^|\/)(app\/api|pages\/api|api)(\/|$)/],
|
|
64
|
+
['auth', /auth/i],
|
|
65
|
+
['billing', /billing|invoice/i],
|
|
66
|
+
['payment', /payment|stripe|checkout/i],
|
|
67
|
+
];
|
|
68
|
+
/** Tags carrying a criticality bonus beyond plain fan-in. */
|
|
69
|
+
const SENSITIVE_TAGS = new Set(['auth', 'billing', 'payment']);
|
|
70
|
+
function inferTags(relPath) {
|
|
71
|
+
const normalized = relPath.replace(/\\/g, '/');
|
|
72
|
+
return TAG_PATTERNS.filter(([, pattern]) => pattern.test(normalized)).map(([tag]) => tag);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Criticality score, 0-100:
|
|
76
|
+
* - fan-in: 6 points per dependent file, capped at 60 (10+ dependents saturate)
|
|
77
|
+
* - +15 when the file is an API surface
|
|
78
|
+
* - +25 when it belongs to a sensitive domain (auth, billing, payment)
|
|
79
|
+
*/
|
|
80
|
+
function computeCriticality(inDegree, tags) {
|
|
81
|
+
let score = Math.min(60, inDegree * 6);
|
|
82
|
+
if (tags.includes('api'))
|
|
83
|
+
score += 15;
|
|
84
|
+
if (tags.some(t => SENSITIVE_TAGS.has(t)))
|
|
85
|
+
score += 25;
|
|
86
|
+
return Math.min(100, score);
|
|
87
|
+
}
|
|
88
|
+
function criticalityLevel(score) {
|
|
89
|
+
if (score >= 80)
|
|
90
|
+
return 'critical';
|
|
91
|
+
if (score >= 55)
|
|
92
|
+
return 'high';
|
|
93
|
+
if (score >= 25)
|
|
94
|
+
return 'medium';
|
|
95
|
+
return 'low';
|
|
96
|
+
}
|
|
97
|
+
// ─── Enrichment pass ───────────────────────────────────────────────────────
|
|
98
|
+
/**
|
|
99
|
+
* Layer aidoc-kit's intelligence (roles, criticality, tags) on top of the
|
|
100
|
+
* raw CodeGraph output. Pure function apart from reading file sources for
|
|
101
|
+
* directive detection — a file that cannot be read falls back to path rules.
|
|
102
|
+
*/
|
|
103
|
+
function enrichGraph(raw, projectRoot) {
|
|
104
|
+
// Distinct dependents/dependencies per file, all edge kinds included
|
|
105
|
+
const dependents = new Map();
|
|
106
|
+
const dependencies = new Map();
|
|
107
|
+
for (const edge of raw.fileEdges) {
|
|
108
|
+
if (!dependents.has(edge.to))
|
|
109
|
+
dependents.set(edge.to, new Set());
|
|
110
|
+
dependents.get(edge.to).add(edge.from);
|
|
111
|
+
if (!dependencies.has(edge.from))
|
|
112
|
+
dependencies.set(edge.from, new Set());
|
|
113
|
+
dependencies.get(edge.from).add(edge.to);
|
|
114
|
+
}
|
|
115
|
+
const files = raw.files.map(f => {
|
|
116
|
+
let source = '';
|
|
117
|
+
try {
|
|
118
|
+
source = (0, node_fs_1.readFileSync)((0, node_path_1.join)(projectRoot, f.path), 'utf-8');
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// deleted since indexing, or unreadable — path rules still apply
|
|
122
|
+
}
|
|
123
|
+
const { role, reason } = inferRole(f.path, source);
|
|
124
|
+
const tags = inferTags(f.path);
|
|
125
|
+
const inDegree = dependents.get(f.path)?.size ?? 0;
|
|
126
|
+
const outDegree = dependencies.get(f.path)?.size ?? 0;
|
|
127
|
+
const criticality = computeCriticality(inDegree, tags);
|
|
128
|
+
return {
|
|
129
|
+
file: f.path,
|
|
130
|
+
language: f.language,
|
|
131
|
+
role,
|
|
132
|
+
roleReason: reason,
|
|
133
|
+
criticality,
|
|
134
|
+
criticalityLevel: criticalityLevel(criticality),
|
|
135
|
+
inDegree,
|
|
136
|
+
outDegree,
|
|
137
|
+
tags,
|
|
138
|
+
symbolCount: f.symbolCount,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
const countRole = (role) => files.filter(f => f.role === role).length;
|
|
142
|
+
return {
|
|
143
|
+
version: 1,
|
|
144
|
+
generatedAt: new Date().toISOString(),
|
|
145
|
+
codegraph: { version: raw.codegraphVersion },
|
|
146
|
+
stats: {
|
|
147
|
+
files: files.length,
|
|
148
|
+
edges: raw.fileEdges.length,
|
|
149
|
+
client: countRole('client'),
|
|
150
|
+
server: countRole('server'),
|
|
151
|
+
universal: countRole('universal'),
|
|
152
|
+
},
|
|
153
|
+
files,
|
|
154
|
+
edges: raw.fileEdges,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=basicEnricher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basicEnricher.js","sourceRoot":"","sources":["../../src/enricher/basicEnricher.ts"],"names":[],"mappings":";;AAyCA,8BAmBC;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E,GAAG,CAAC,gBAAgB,EAAE;QAC5C,KAAK,EAAE;YACL,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,MAAM;YAC3B,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC;YAC3B,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC;YAC3B,SAAS,EAAE,SAAS,CAAC,WAAW,CAAC;SAClC;QACD,KAAK;QACL,KAAK,EAAE,GAAG,CAAC,SAAS;KACrB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ai-agent general-expert
|
|
3
|
+
* @ai-agent-hint If you are not the general-expert specialist, consider switching to a specialized agent in Copilot Chat. Run `npx aidoc-kit agents` to generate agent instruction files.
|
|
4
|
+
* @ai-runtime UNIVERSEL
|
|
5
|
+
*
|
|
6
|
+
* @ai-context
|
|
7
|
+
* [GENERATED] This file exports: getDependents, getDependencies, getCriticalFiles
|
|
8
|
+
* Imported by: src/cli.ts
|
|
9
|
+
*
|
|
10
|
+
* @ai-when-modifying
|
|
11
|
+
* 1. Check cascade files below before modifying
|
|
12
|
+
* 2. After modifying, ask the developer to run @ai-validate
|
|
13
|
+
* 3. If you have no terminal access, report the command to run
|
|
14
|
+
*
|
|
15
|
+
* @ai-cascade
|
|
16
|
+
* - src/cli.ts
|
|
17
|
+
*
|
|
18
|
+
* @ai-validate
|
|
19
|
+
* npm run typecheck
|
|
20
|
+
*/
|
|
21
|
+
import type { EnrichedGraph } from './types';
|
|
22
|
+
/** Files that import/call/reference the given file (direct dependents). */
|
|
23
|
+
export declare function getDependents(graph: EnrichedGraph, file: string): string[];
|
|
24
|
+
/** Files the given file imports/calls/references (direct dependencies). */
|
|
25
|
+
export declare function getDependencies(graph: EnrichedGraph, file: string): string[];
|
|
26
|
+
/** Files at or above a criticality level, most critical first. */
|
|
27
|
+
export declare function getCriticalFiles(graph: EnrichedGraph, minLevel?: 'medium' | 'high' | 'critical'): EnrichedGraph['files'];
|
|
28
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/graph/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1E;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE5E;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,QAAQ,GAAE,QAAQ,GAAG,MAAM,GAAG,UAAmB,GAChD,aAAa,CAAC,OAAO,CAAC,CAKxB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDependents = getDependents;
|
|
4
|
+
exports.getDependencies = getDependencies;
|
|
5
|
+
exports.getCriticalFiles = getCriticalFiles;
|
|
6
|
+
// Minimal query helpers over the enriched graph. Richer APIs (getCallers at
|
|
7
|
+
// symbol level, getImpact, search) are planned on top of the CodeGraph
|
|
8
|
+
// database itself — see ARCHITECTURE.md.
|
|
9
|
+
/** Files that import/call/reference the given file (direct dependents). */
|
|
10
|
+
function getDependents(graph, file) {
|
|
11
|
+
return [...new Set(graph.edges.filter(e => e.to === file).map(e => e.from))];
|
|
12
|
+
}
|
|
13
|
+
/** Files the given file imports/calls/references (direct dependencies). */
|
|
14
|
+
function getDependencies(graph, file) {
|
|
15
|
+
return [...new Set(graph.edges.filter(e => e.from === file).map(e => e.to))];
|
|
16
|
+
}
|
|
17
|
+
/** Files at or above a criticality level, most critical first. */
|
|
18
|
+
function getCriticalFiles(graph, minLevel = 'high') {
|
|
19
|
+
const order = { low: 0, medium: 1, high: 2, critical: 3 };
|
|
20
|
+
return graph.files
|
|
21
|
+
.filter(f => order[f.criticalityLevel] >= order[minLevel])
|
|
22
|
+
.sort((a, b) => b.criticality - a.criticality);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/graph/query.ts"],"names":[],"mappings":";;AA2BA,sCAEC;AAGD,0CAEC;AAGD,4CAQC;AAvBD,4EAA4E;AAC5E,uEAAuE;AACvE,yCAAyC;AAEzC,2EAA2E;AAC3E,SAAgB,aAAa,CAAC,KAAoB,EAAE,IAAY;IAC9D,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC9E,CAAC;AAED,2EAA2E;AAC3E,SAAgB,eAAe,CAAC,KAAoB,EAAE,IAAY;IAChE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC9E,CAAC;AAED,kEAAkE;AAClE,SAAgB,gBAAgB,CAC9B,KAAoB,EACpB,WAA2C,MAAM;IAEjD,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;IACzD,OAAO,KAAK,CAAC,KAAK;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;SACzD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EnrichedGraph } from './types';
|
|
2
|
+
export declare const GRAPH_FILENAME = "aidoc-graph.json";
|
|
3
|
+
/**
|
|
4
|
+
* Write the enriched graph at the project root. Files and edges are already
|
|
5
|
+
* sorted by path in the loader, so successive runs produce stable diffs.
|
|
6
|
+
*/
|
|
7
|
+
export declare function writeEnrichedGraph(graph: EnrichedGraph, projectRoot: string): string;
|
|
8
|
+
/** Read a previously generated aidoc-graph.json, or null when absent/invalid. */
|
|
9
|
+
export declare function readEnrichedGraph(projectRoot: string): EnrichedGraph | null;
|
|
10
|
+
//# sourceMappingURL=serializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/graph/serializer.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,cAAc,qBAAqB,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAIpF;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAS3E"}
|