@dahch/muninn 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +395 -2
- package/dist/cli.d.ts +23 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +186 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/check.d.ts +3 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +56 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/memory.d.ts +6 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +374 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/setup.d.ts +3 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +397 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/contracts/compiler.d.ts +71 -0
- package/dist/contracts/compiler.d.ts.map +1 -0
- package/dist/contracts/compiler.js +362 -0
- package/dist/contracts/compiler.js.map +1 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/db/client.d.ts +100 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +318 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/schema.sql +99 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer/ast-indexer.d.ts +55 -0
- package/dist/indexer/ast-indexer.d.ts.map +1 -0
- package/dist/indexer/ast-indexer.js +445 -0
- package/dist/indexer/ast-indexer.js.map +1 -0
- package/dist/indexer/index.d.ts +2 -0
- package/dist/indexer/index.d.ts.map +1 -0
- package/dist/indexer/index.js +2 -0
- package/dist/indexer/index.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +254 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +636 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/service/index.d.ts +2 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +2 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/memory-service.d.ts +320 -0
- package/dist/service/memory-service.d.ts.map +1 -0
- package/dist/service/memory-service.js +1511 -0
- package/dist/service/memory-service.js.map +1 -0
- package/dist/setup/index.d.ts +6 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js +6 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/json-target.d.ts +30 -0
- package/dist/setup/json-target.d.ts.map +1 -0
- package/dist/setup/json-target.js +263 -0
- package/dist/setup/json-target.js.map +1 -0
- package/dist/setup/portable.d.ts +56 -0
- package/dist/setup/portable.d.ts.map +1 -0
- package/dist/setup/portable.js +365 -0
- package/dist/setup/portable.js.map +1 -0
- package/dist/setup/registry.d.ts +54 -0
- package/dist/setup/registry.d.ts.map +1 -0
- package/dist/setup/registry.js +225 -0
- package/dist/setup/registry.js.map +1 -0
- package/dist/setup/rules-target.d.ts +31 -0
- package/dist/setup/rules-target.d.ts.map +1 -0
- package/dist/setup/rules-target.js +270 -0
- package/dist/setup/rules-target.js.map +1 -0
- package/dist/setup/toml-target.d.ts +62 -0
- package/dist/setup/toml-target.d.ts.map +1 -0
- package/dist/setup/toml-target.js +869 -0
- package/dist/setup/toml-target.js.map +1 -0
- package/dist/util/path-safety.d.ts +94 -0
- package/dist/util/path-safety.d.ts.map +1 -0
- package/dist/util/path-safety.js +162 -0
- package/dist/util/path-safety.js.map +1 -0
- package/dist/util/text.d.ts +9 -0
- package/dist/util/text.d.ts.map +1 -0
- package/dist/util/text.js +19 -0
- package/dist/util/text.js.map +1 -0
- package/package.json +87 -4
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes file path to forward slashes.
|
|
7
|
+
*/
|
|
8
|
+
export function normalizePath(p) {
|
|
9
|
+
return p.replace(/\\/g, "/");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Normalizes relative module specifiers against the importing file's directory.
|
|
13
|
+
* Maps .js, .mjs, .cjs to .ts, and .jsx to .tsx, while keeping extensionless specifiers bare.
|
|
14
|
+
*/
|
|
15
|
+
export function normalizeModuleSpecifier(filePath, specifier) {
|
|
16
|
+
if (!specifier.startsWith(".")) {
|
|
17
|
+
return specifier;
|
|
18
|
+
}
|
|
19
|
+
const fileDir = path.dirname(filePath);
|
|
20
|
+
let resolved = normalizePath(path.join(fileDir, specifier));
|
|
21
|
+
if (resolved.endsWith(".js")) {
|
|
22
|
+
resolved = resolved.slice(0, -3) + ".ts";
|
|
23
|
+
}
|
|
24
|
+
else if (resolved.endsWith(".mjs")) {
|
|
25
|
+
resolved = resolved.slice(0, -4) + ".ts";
|
|
26
|
+
}
|
|
27
|
+
else if (resolved.endsWith(".cjs")) {
|
|
28
|
+
resolved = resolved.slice(0, -4) + ".ts";
|
|
29
|
+
}
|
|
30
|
+
else if (resolved.endsWith(".jsx")) {
|
|
31
|
+
resolved = resolved.slice(0, -4) + ".tsx";
|
|
32
|
+
}
|
|
33
|
+
return resolved;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extracts symbols and dependencies from TypeScript / JavaScript source code.
|
|
37
|
+
*/
|
|
38
|
+
export function extractSymbolsFromSource(filePath, sourceText) {
|
|
39
|
+
const result = extractAstData(filePath, sourceText);
|
|
40
|
+
return result.symbols;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Comprehensive AST traversal returning both symbols and inter-symbol dependencies.
|
|
44
|
+
*/
|
|
45
|
+
export function extractAstData(filePath, sourceText) {
|
|
46
|
+
const normalizedFilePath = normalizePath(filePath);
|
|
47
|
+
const sourceFile = ts.createSourceFile(normalizedFilePath, sourceText, ts.ScriptTarget.Latest, false // REV-010: setParentNodes = false for low memory and high performance
|
|
48
|
+
);
|
|
49
|
+
const symbols = [];
|
|
50
|
+
const dependencies = [];
|
|
51
|
+
function getLine(pos) {
|
|
52
|
+
return sourceFile.getLineAndCharacterOfPosition(pos).line + 1;
|
|
53
|
+
}
|
|
54
|
+
function isNodeExported(node) {
|
|
55
|
+
const flags = ts.getCombinedModifierFlags(node);
|
|
56
|
+
if ((flags & ts.ModifierFlags.Export) !== 0) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (ts.canHaveModifiers(node)) {
|
|
60
|
+
const modifiers = ts.getModifiers(node);
|
|
61
|
+
return Boolean(modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword));
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// 1. Traverse top-level nodes for declarations and imports
|
|
66
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
67
|
+
// Import declarations
|
|
68
|
+
if (ts.isImportDeclaration(node)) {
|
|
69
|
+
if (ts.isStringLiteral(node.moduleSpecifier)) {
|
|
70
|
+
const rawSpecifier = node.moduleSpecifier.text;
|
|
71
|
+
const specifier = normalizeModuleSpecifier(normalizedFilePath, rawSpecifier);
|
|
72
|
+
dependencies.push({
|
|
73
|
+
sourceIdentifier: normalizedFilePath,
|
|
74
|
+
targetIdentifier: specifier,
|
|
75
|
+
relationType: "imports",
|
|
76
|
+
});
|
|
77
|
+
// Also record named imports
|
|
78
|
+
if (node.importClause?.namedBindings &&
|
|
79
|
+
ts.isNamedImports(node.importClause.namedBindings)) {
|
|
80
|
+
for (const spec of node.importClause.namedBindings.elements) {
|
|
81
|
+
dependencies.push({
|
|
82
|
+
sourceIdentifier: normalizedFilePath,
|
|
83
|
+
targetIdentifier: `${specifier}::${spec.name.text}`,
|
|
84
|
+
relationType: "imports",
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Export declarations with module specifiers: export { x } from './foo.js'
|
|
92
|
+
if (ts.isExportDeclaration(node) &&
|
|
93
|
+
node.moduleSpecifier &&
|
|
94
|
+
ts.isStringLiteral(node.moduleSpecifier)) {
|
|
95
|
+
const rawSpecifier = node.moduleSpecifier.text;
|
|
96
|
+
const specifier = normalizeModuleSpecifier(normalizedFilePath, rawSpecifier);
|
|
97
|
+
dependencies.push({
|
|
98
|
+
sourceIdentifier: normalizedFilePath,
|
|
99
|
+
targetIdentifier: specifier,
|
|
100
|
+
relationType: "imports",
|
|
101
|
+
});
|
|
102
|
+
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
103
|
+
for (const spec of node.exportClause.elements) {
|
|
104
|
+
dependencies.push({
|
|
105
|
+
sourceIdentifier: normalizedFilePath,
|
|
106
|
+
targetIdentifier: `${specifier}::${spec.name.text}`,
|
|
107
|
+
relationType: "imports",
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Top-level or exported function declarations
|
|
114
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
115
|
+
if (node.name && ts.isIdentifier(node.name)) {
|
|
116
|
+
const name = node.name.text;
|
|
117
|
+
const identifier = `${normalizedFilePath}::${name}`;
|
|
118
|
+
const isExported = isNodeExported(node);
|
|
119
|
+
symbols.push({
|
|
120
|
+
name,
|
|
121
|
+
identifier,
|
|
122
|
+
filePath: normalizedFilePath,
|
|
123
|
+
entityType: "function",
|
|
124
|
+
startLine: getLine(node.getStart(sourceFile)),
|
|
125
|
+
endLine: getLine(node.getEnd()),
|
|
126
|
+
isExported,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// Exported variable statements (arrow functions or function expressions)
|
|
132
|
+
if (ts.isVariableStatement(node)) {
|
|
133
|
+
const isExported = isNodeExported(node);
|
|
134
|
+
for (const decl of node.declarationList.declarations) {
|
|
135
|
+
if (ts.isIdentifier(decl.name) &&
|
|
136
|
+
decl.initializer &&
|
|
137
|
+
(ts.isArrowFunction(decl.initializer) ||
|
|
138
|
+
ts.isFunctionExpression(decl.initializer))) {
|
|
139
|
+
const name = decl.name.text;
|
|
140
|
+
const identifier = `${normalizedFilePath}::${name}`;
|
|
141
|
+
symbols.push({
|
|
142
|
+
name,
|
|
143
|
+
identifier,
|
|
144
|
+
filePath: normalizedFilePath,
|
|
145
|
+
entityType: "function",
|
|
146
|
+
startLine: getLine(decl.getStart(sourceFile)),
|
|
147
|
+
endLine: getLine(decl.getEnd()),
|
|
148
|
+
isExported,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
// Class declarations
|
|
155
|
+
if (ts.isClassDeclaration(node)) {
|
|
156
|
+
const className = node.name ? node.name.text : "AnonymousClass";
|
|
157
|
+
const classIdentifier = `${normalizedFilePath}::${className}`;
|
|
158
|
+
const isExported = isNodeExported(node);
|
|
159
|
+
symbols.push({
|
|
160
|
+
name: className,
|
|
161
|
+
identifier: classIdentifier,
|
|
162
|
+
filePath: normalizedFilePath,
|
|
163
|
+
entityType: "class",
|
|
164
|
+
startLine: getLine(node.getStart(sourceFile)),
|
|
165
|
+
endLine: getLine(node.getEnd()),
|
|
166
|
+
isExported,
|
|
167
|
+
});
|
|
168
|
+
// Class heritage clauses: extends and implements
|
|
169
|
+
if (node.heritageClauses) {
|
|
170
|
+
for (const clause of node.heritageClauses) {
|
|
171
|
+
if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
|
|
172
|
+
for (const typeNode of clause.types) {
|
|
173
|
+
const target = typeNode.expression.getText(sourceFile);
|
|
174
|
+
dependencies.push({
|
|
175
|
+
sourceIdentifier: classIdentifier,
|
|
176
|
+
targetIdentifier: target,
|
|
177
|
+
relationType: "extends",
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (clause.token === ts.SyntaxKind.ImplementsKeyword) {
|
|
182
|
+
for (const typeNode of clause.types) {
|
|
183
|
+
const target = typeNode.expression.getText(sourceFile);
|
|
184
|
+
dependencies.push({
|
|
185
|
+
sourceIdentifier: classIdentifier,
|
|
186
|
+
targetIdentifier: target,
|
|
187
|
+
relationType: "implements",
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Public class methods
|
|
194
|
+
for (const member of node.members) {
|
|
195
|
+
if (ts.isMethodDeclaration(member)) {
|
|
196
|
+
if (member.name && ts.isIdentifier(member.name)) {
|
|
197
|
+
const methodName = member.name.text;
|
|
198
|
+
// Check access modifiers: skip private / protected methods
|
|
199
|
+
const isPrivate = member.modifiers?.some((m) => m.kind === ts.SyntaxKind.PrivateKeyword ||
|
|
200
|
+
m.kind === ts.SyntaxKind.ProtectedKeyword);
|
|
201
|
+
if (!isPrivate && !methodName.startsWith("#")) {
|
|
202
|
+
const methodIdentifier = `${normalizedFilePath}::${className}.${methodName}`;
|
|
203
|
+
symbols.push({
|
|
204
|
+
name: `${className}.${methodName}`,
|
|
205
|
+
identifier: methodIdentifier,
|
|
206
|
+
filePath: normalizedFilePath,
|
|
207
|
+
entityType: "function",
|
|
208
|
+
startLine: getLine(member.getStart(sourceFile)),
|
|
209
|
+
endLine: getLine(member.getEnd()),
|
|
210
|
+
isExported,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// Interface declarations
|
|
219
|
+
if (ts.isInterfaceDeclaration(node)) {
|
|
220
|
+
const name = node.name.text;
|
|
221
|
+
const identifier = `${normalizedFilePath}::${name}`;
|
|
222
|
+
const isExported = isNodeExported(node);
|
|
223
|
+
symbols.push({
|
|
224
|
+
name,
|
|
225
|
+
identifier,
|
|
226
|
+
filePath: normalizedFilePath,
|
|
227
|
+
entityType: "interface",
|
|
228
|
+
startLine: getLine(node.getStart(sourceFile)),
|
|
229
|
+
endLine: getLine(node.getEnd()),
|
|
230
|
+
isExported,
|
|
231
|
+
});
|
|
232
|
+
if (node.heritageClauses) {
|
|
233
|
+
for (const clause of node.heritageClauses) {
|
|
234
|
+
if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
|
|
235
|
+
for (const typeNode of clause.types) {
|
|
236
|
+
const target = typeNode.expression.getText(sourceFile);
|
|
237
|
+
dependencies.push({
|
|
238
|
+
sourceIdentifier: identifier,
|
|
239
|
+
targetIdentifier: target,
|
|
240
|
+
relationType: "extends",
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
// Type Alias declarations
|
|
249
|
+
if (ts.isTypeAliasDeclaration(node)) {
|
|
250
|
+
const name = node.name.text;
|
|
251
|
+
const identifier = `${normalizedFilePath}::${name}`;
|
|
252
|
+
const isExported = isNodeExported(node);
|
|
253
|
+
symbols.push({
|
|
254
|
+
name,
|
|
255
|
+
identifier,
|
|
256
|
+
filePath: normalizedFilePath,
|
|
257
|
+
entityType: "interface",
|
|
258
|
+
startLine: getLine(node.getStart(sourceFile)),
|
|
259
|
+
endLine: getLine(node.getEnd()),
|
|
260
|
+
isExported,
|
|
261
|
+
});
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return {
|
|
266
|
+
filePath: normalizedFilePath,
|
|
267
|
+
symbols,
|
|
268
|
+
dependencies,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const SUPPORTED_EXTENSIONS = new Set([
|
|
272
|
+
".ts",
|
|
273
|
+
".tsx",
|
|
274
|
+
".mts",
|
|
275
|
+
".cts",
|
|
276
|
+
".js",
|
|
277
|
+
".jsx",
|
|
278
|
+
".mjs",
|
|
279
|
+
".cjs",
|
|
280
|
+
]);
|
|
281
|
+
const MAX_FILE_SIZE_BYTES = 2 * 1024 * 1024; // 2MB
|
|
282
|
+
/**
|
|
283
|
+
* Indexes a collection of files into Muninn's entities and entity_dependencies tables.
|
|
284
|
+
*
|
|
285
|
+
* Execution is cleanly separated into two stages (REV-001):
|
|
286
|
+
* 1. Synchronous file reading, filtering, validation, and AST parsing are performed in-memory outside any database transaction.
|
|
287
|
+
* 2. SQLite batch operations are executed inside a short-lived transaction with zombie entity pruning (REV-003, SEC-003).
|
|
288
|
+
*/
|
|
289
|
+
export function indexFilesIntoMuninn(memoryService, filePaths, options) {
|
|
290
|
+
const db = memoryService.db;
|
|
291
|
+
const project = memoryService.currentProject;
|
|
292
|
+
const projectRoot = options?.projectRoot ?? project.root_path;
|
|
293
|
+
// Step 1: Read files and parse AST in-memory outside the database transaction (REV-001)
|
|
294
|
+
const parsedFiles = [];
|
|
295
|
+
const seenPaths = new Set();
|
|
296
|
+
for (const rawFilePath of filePaths) {
|
|
297
|
+
try {
|
|
298
|
+
// Path Traversal Containment (SEC-001)
|
|
299
|
+
const absolutePath = path.resolve(projectRoot, rawFilePath);
|
|
300
|
+
const relPath = path.relative(projectRoot, absolutePath);
|
|
301
|
+
if (relPath.startsWith("..") || path.isAbsolute(relPath)) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
// Filter by supported extensions
|
|
305
|
+
const ext = path.extname(absolutePath).toLowerCase();
|
|
306
|
+
if (!SUPPORTED_EXTENSIONS.has(ext)) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
// Check file exists, is regular file, and within max file size (2MB)
|
|
310
|
+
const stat = fs.statSync(absolutePath);
|
|
311
|
+
if (!stat.isFile() || stat.size > MAX_FILE_SIZE_BYTES) {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const normalizedRelPath = normalizePath(relPath);
|
|
315
|
+
if (seenPaths.has(normalizedRelPath)) {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
seenPaths.add(normalizedRelPath);
|
|
319
|
+
// Read content and parse AST
|
|
320
|
+
const content = fs.readFileSync(absolutePath, "utf-8");
|
|
321
|
+
const ast = extractAstData(normalizedRelPath, content);
|
|
322
|
+
parsedFiles.push({
|
|
323
|
+
relPath: normalizedRelPath,
|
|
324
|
+
ast,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
// Individual file read / syntax errors don't abort other files (REV-007)
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// Step 2: Open db.transaction() strictly for the SQLite database batch inserts/updates
|
|
333
|
+
let totalFiles = 0;
|
|
334
|
+
let totalSymbols = 0;
|
|
335
|
+
let totalDependencies = 0;
|
|
336
|
+
db.transaction(() => {
|
|
337
|
+
const findEntityStmt = db.prepare(`SELECT id, project_id, entity_type, identifier, file_path
|
|
338
|
+
FROM entities
|
|
339
|
+
WHERE project_id = ? AND identifier = ?`);
|
|
340
|
+
const insertEntityStmt = db.prepare(`INSERT INTO entities (id, project_id, entity_type, identifier, file_path)
|
|
341
|
+
VALUES (?, ?, ?, ?, ?)`);
|
|
342
|
+
const updateEntityStmt = db.prepare(`UPDATE entities
|
|
343
|
+
SET entity_type = ?, file_path = ?
|
|
344
|
+
WHERE id = ?`);
|
|
345
|
+
const deleteEntityStmt = db.prepare(`DELETE FROM entities
|
|
346
|
+
WHERE id = ?`);
|
|
347
|
+
const getEntitiesForFileStmt = db.prepare(`SELECT id, identifier
|
|
348
|
+
FROM entities
|
|
349
|
+
WHERE project_id = ? AND file_path = ?`);
|
|
350
|
+
const insertDepStmt = db.prepare(`INSERT OR IGNORE INTO entity_dependencies (source_entity_id, target_entity_id, relation_type)
|
|
351
|
+
VALUES (?, ?, ?)`);
|
|
352
|
+
const deleteOldDepsStmt = db.prepare(`DELETE FROM entity_dependencies
|
|
353
|
+
WHERE source_entity_id = ?`);
|
|
354
|
+
function getOrCreateEntity(identifier, entityType, filePath, isAuthoritative = false) {
|
|
355
|
+
let entity = findEntityStmt.get(project.id, identifier);
|
|
356
|
+
if (entity) {
|
|
357
|
+
if (isAuthoritative &&
|
|
358
|
+
(entity.entity_type !== entityType || entity.file_path !== filePath)) {
|
|
359
|
+
updateEntityStmt.run(entityType, filePath, entity.id);
|
|
360
|
+
entity.entity_type = entityType;
|
|
361
|
+
entity.file_path = filePath;
|
|
362
|
+
}
|
|
363
|
+
return entity;
|
|
364
|
+
}
|
|
365
|
+
const entityId = crypto.randomUUID();
|
|
366
|
+
insertEntityStmt.run(entityId, project.id, entityType, identifier, filePath);
|
|
367
|
+
return {
|
|
368
|
+
id: entityId,
|
|
369
|
+
project_id: project.id,
|
|
370
|
+
entity_type: entityType,
|
|
371
|
+
identifier,
|
|
372
|
+
file_path: filePath,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
for (const { relPath, ast } of parsedFiles) {
|
|
376
|
+
totalFiles++;
|
|
377
|
+
// 1. Ensure file entity itself exists
|
|
378
|
+
const fileEntity = getOrCreateEntity(relPath, "file", relPath, true);
|
|
379
|
+
// Clean existing outgoing dependencies for the file
|
|
380
|
+
deleteOldDepsStmt.run(fileEntity.id);
|
|
381
|
+
// 2. Collect active identifiers for this file (the file entity + all extracted symbols)
|
|
382
|
+
const activeIdentifiers = new Set();
|
|
383
|
+
activeIdentifiers.add(relPath);
|
|
384
|
+
for (const sym of ast.symbols) {
|
|
385
|
+
activeIdentifiers.add(sym.identifier);
|
|
386
|
+
}
|
|
387
|
+
// 3. Prune zombie / ghost entities for this file (REV-003, SEC-003)
|
|
388
|
+
// Any entity belonging to (project_id, file_path) whose identifier is NOT in activeIdentifiers is removed.
|
|
389
|
+
// ON DELETE CASCADE automatically purges related rows in entity_dependencies and observation_entities.
|
|
390
|
+
const existingFileEntities = getEntitiesForFileStmt.all(project.id, relPath);
|
|
391
|
+
for (const existing of existingFileEntities) {
|
|
392
|
+
if (!activeIdentifiers.has(existing.identifier)) {
|
|
393
|
+
deleteEntityStmt.run(existing.id);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// Map from identifier to entity id for this file
|
|
397
|
+
const entityMap = new Map();
|
|
398
|
+
entityMap.set(relPath, fileEntity.id);
|
|
399
|
+
for (const sym of ast.symbols) {
|
|
400
|
+
totalSymbols++;
|
|
401
|
+
const symbolEntity = getOrCreateEntity(sym.identifier, sym.entityType, sym.filePath, true);
|
|
402
|
+
entityMap.set(sym.identifier, symbolEntity.id);
|
|
403
|
+
// Clean existing outgoing dependencies for this symbol before re-populating
|
|
404
|
+
deleteOldDepsStmt.run(symbolEntity.id);
|
|
405
|
+
// Link symbol to file as a reference
|
|
406
|
+
insertDepStmt.run(fileEntity.id, symbolEntity.id, "references");
|
|
407
|
+
totalDependencies++;
|
|
408
|
+
}
|
|
409
|
+
// 4. Insert dependencies
|
|
410
|
+
for (const dep of ast.dependencies) {
|
|
411
|
+
const sourceId = entityMap.get(dep.sourceIdentifier) ??
|
|
412
|
+
getOrCreateEntity(dep.sourceIdentifier, "file", relPath, false).id;
|
|
413
|
+
let targetEntityType = "module";
|
|
414
|
+
let targetFilePath = dep.targetIdentifier;
|
|
415
|
+
if (dep.relationType === "implements" ||
|
|
416
|
+
dep.relationType === "extends") {
|
|
417
|
+
targetEntityType = "interface";
|
|
418
|
+
}
|
|
419
|
+
else if (dep.targetIdentifier.endsWith(".ts") ||
|
|
420
|
+
dep.targetIdentifier.endsWith(".tsx") ||
|
|
421
|
+
dep.targetIdentifier.endsWith(".mts") ||
|
|
422
|
+
dep.targetIdentifier.endsWith(".cts") ||
|
|
423
|
+
dep.targetIdentifier.endsWith(".js") ||
|
|
424
|
+
dep.targetIdentifier.endsWith(".jsx") ||
|
|
425
|
+
dep.targetIdentifier.endsWith(".mjs") ||
|
|
426
|
+
dep.targetIdentifier.endsWith(".cjs")) {
|
|
427
|
+
targetEntityType = "file";
|
|
428
|
+
}
|
|
429
|
+
else if (dep.targetIdentifier.includes("::")) {
|
|
430
|
+
const [filePart] = dep.targetIdentifier.split("::");
|
|
431
|
+
targetFilePath = filePart;
|
|
432
|
+
}
|
|
433
|
+
const targetEntity = getOrCreateEntity(dep.targetIdentifier, targetEntityType, targetFilePath, false);
|
|
434
|
+
insertDepStmt.run(sourceId, targetEntity.id, dep.relationType);
|
|
435
|
+
totalDependencies++;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
})();
|
|
439
|
+
return {
|
|
440
|
+
indexedFiles: totalFiles,
|
|
441
|
+
indexedSymbols: totalSymbols,
|
|
442
|
+
indexedDependencies: totalDependencies,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
//# sourceMappingURL=ast-indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-indexer.js","sourceRoot":"","sources":["../../src/indexer/ast-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,YAAY,CAAC;AAqC5B;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAS;IACrC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAgB,EAChB,SAAiB;IAEjB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS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;YACtB,CAAC;QACH,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO;QACL,YAAY,EAAE,UAAU;QACxB,cAAc,EAAE,YAAY;QAC5B,mBAAmB,EAAE,iBAAiB;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|