@kage-core/kage-graph-mcp 1.1.18 → 1.1.19
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/dist/kernel.js +39 -0
- package/package.json +1 -1
package/dist/kernel.js
CHANGED
|
@@ -1522,6 +1522,36 @@ function readCodeIndexManifest(projectDir) {
|
|
|
1522
1522
|
function listCodeFiles(projectDir) {
|
|
1523
1523
|
return codeIndexSelection(projectDir).files;
|
|
1524
1524
|
}
|
|
1525
|
+
function codeGraphStatFingerprint(projectDir, absoluteFiles) {
|
|
1526
|
+
const entries = [
|
|
1527
|
+
...absoluteFiles,
|
|
1528
|
+
...externalIndexFiles(projectDir).map((index) => index.path),
|
|
1529
|
+
...["package.json", "requirements.txt", "go.mod", "Cargo.toml"]
|
|
1530
|
+
.map((path) => (0, node_path_1.join)(projectDir, path))
|
|
1531
|
+
.filter((path) => (0, node_fs_1.existsSync)(path)),
|
|
1532
|
+
]
|
|
1533
|
+
.filter((path) => (0, node_fs_1.existsSync)(path))
|
|
1534
|
+
.map((path) => {
|
|
1535
|
+
const stats = (0, node_fs_1.statSync)(path);
|
|
1536
|
+
return `${projectRelative(projectDir, path)}:${stats.size}:${Math.round(stats.mtimeMs)}`;
|
|
1537
|
+
})
|
|
1538
|
+
.sort();
|
|
1539
|
+
return sha256Hex(entries.join("\n"));
|
|
1540
|
+
}
|
|
1541
|
+
function readCachedCodeGraph(projectDir, fingerprint) {
|
|
1542
|
+
const path = (0, node_path_1.join)(codeGraphDir(projectDir), "graph.json");
|
|
1543
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
1544
|
+
return null;
|
|
1545
|
+
try {
|
|
1546
|
+
const graph = readJson(path);
|
|
1547
|
+
if (readCodeIndexManifest(projectDir).fingerprint !== fingerprint)
|
|
1548
|
+
return null;
|
|
1549
|
+
return graph;
|
|
1550
|
+
}
|
|
1551
|
+
catch {
|
|
1552
|
+
return null;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1525
1555
|
function fileFactCacheDir(projectDir) {
|
|
1526
1556
|
return (0, node_path_1.join)(codeGraphDir(projectDir), "file-cache");
|
|
1527
1557
|
}
|
|
@@ -2358,7 +2388,16 @@ function buildCodeGraph(projectDir) {
|
|
|
2358
2388
|
const mergeBase = gitMergeBase(projectDir);
|
|
2359
2389
|
const selection = codeIndexSelection(projectDir);
|
|
2360
2390
|
const absoluteFiles = selection.files;
|
|
2391
|
+
const fingerprint = codeGraphStatFingerprint(projectDir, absoluteFiles);
|
|
2392
|
+
const cachedGraph = readCachedCodeGraph(projectDir, fingerprint);
|
|
2393
|
+
if (cachedGraph) {
|
|
2394
|
+
selection.manifest.cache = { hits: absoluteFiles.length, misses: 0 };
|
|
2395
|
+
selection.manifest.fingerprint = fingerprint;
|
|
2396
|
+
writeCodeIndexManifest(projectDir, selection.manifest);
|
|
2397
|
+
return cachedGraph;
|
|
2398
|
+
}
|
|
2361
2399
|
const inputHash = codeGraphInputHash(projectDir, absoluteFiles);
|
|
2400
|
+
selection.manifest.fingerprint = fingerprint;
|
|
2362
2401
|
writeCodeIndexManifest(projectDir, selection.manifest);
|
|
2363
2402
|
const knownFiles = new Set(absoluteFiles.map((path) => (0, node_path_1.relative)(projectDir, path).replace(/\\/g, "/")));
|
|
2364
2403
|
const files = [];
|