@kage-core/kage-graph-mcp 1.1.7 → 1.1.8

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 CHANGED
@@ -137,6 +137,11 @@ meaningful file changes. Refresh rebuilds indexes, code graph, memory graph,
137
137
  metrics, and stale-memory metadata. Memory is marked stale when status or
138
138
  feedback says it is stale, its TTL expires, or grounded paths disappear.
139
139
 
140
+ Use `kage gc --project <repo> --dry-run` to preview stale packet cleanup.
141
+ `kage gc --project <repo>` marks stale repo packets deprecated, rebuilds
142
+ indexes/graphs/metrics, and keeps helpful-voted memories unless `--force` is
143
+ used.
144
+
140
145
  Use `kage pr summarize --project <repo>` / `kage_pr_summarize` before handoff to
141
146
  write branch review metadata and repo-local change memory from the git diff.
142
147
  Use `kage pr check --project <repo>` / `kage_pr_check` before merge to verify
package/dist/cli.js CHANGED
@@ -24,6 +24,7 @@ Usage:
24
24
  kage daemon doctor --project <dir> [--json]
25
25
  kage viewer --project <dir> [--port 3113]
26
26
  kage refresh --project <dir> [--json]
27
+ kage gc --project <dir> [--dry-run] [--force] [--json]
27
28
  kage pr summarize --project <dir> [--json]
28
29
  kage pr check --project <dir> [--json]
29
30
  kage upgrade [--dry-run]
@@ -302,6 +303,32 @@ async function main() {
302
303
  await (0, daemon_js_1.startViewer)(projectArg(args), { port: numberArg(args, "--port", 3113) });
303
304
  return;
304
305
  }
306
+ if (command === "gc") {
307
+ const project = projectArg(args);
308
+ const dryRun = args.includes("--dry-run");
309
+ const force = args.includes("--force");
310
+ const result = (0, kernel_js_1.gcProject)(project, { dryRun, force });
311
+ if (args.includes("--json")) {
312
+ console.log(JSON.stringify(result, null, 2));
313
+ return;
314
+ }
315
+ const label = dryRun ? " [dry-run]" : "";
316
+ console.log(`Kage GC${label} — scanned ${result.total_scanned} packets`);
317
+ if (result.deprecated.length) {
318
+ console.log(`\nDeprecated (${result.deprecated.length}):`);
319
+ for (const p of result.deprecated)
320
+ console.log(` ✗ ${p.title} — ${p.reason}`);
321
+ }
322
+ if (result.deleted.length) {
323
+ console.log(`\nDeleted (${result.deleted.length}):`);
324
+ for (const p of result.deleted)
325
+ console.log(` 🗑 ${p.title}`);
326
+ }
327
+ if (!result.deprecated.length && !result.deleted.length) {
328
+ console.log("No stale packets found — memory is clean.");
329
+ }
330
+ return;
331
+ }
305
332
  if (command === "refresh") {
306
333
  const result = (0, kernel_js_1.refreshProject)(projectArg(args));
307
334
  if (args.includes("--json")) {
package/dist/kernel.js CHANGED
@@ -67,6 +67,7 @@ exports.buildKnowledgeGraph = buildKnowledgeGraph;
67
67
  exports.buildIndexes = buildIndexes;
68
68
  exports.indexProject = indexProject;
69
69
  exports.refreshProject = refreshProject;
70
+ exports.gcProject = gcProject;
70
71
  exports.installAgentPolicy = installAgentPolicy;
71
72
  exports.recall = recall;
72
73
  exports.queryCodeGraph = queryCodeGraph;
@@ -2516,6 +2517,57 @@ function refreshProject(projectDir) {
2516
2517
  next_actions: nextActions,
2517
2518
  };
2518
2519
  }
2520
+ function gcProject(projectDir, options = {}) {
2521
+ ensureMemoryDirs(projectDir);
2522
+ const packetEntries = loadPacketEntriesFromDir(packetsDir(projectDir));
2523
+ const deprecated = [];
2524
+ const deleted = [];
2525
+ const skipped = [];
2526
+ for (const { path, packet } of packetEntries) {
2527
+ if (packet.status === "deprecated") {
2528
+ skipped.push({ id: packet.id, title: packet.title, reason: "already deprecated" });
2529
+ continue;
2530
+ }
2531
+ const reasons = staleMemoryReasons(projectDir, packet);
2532
+ if (!reasons.length) {
2533
+ skipped.push({ id: packet.id, title: packet.title, reason: "healthy" });
2534
+ continue;
2535
+ }
2536
+ const quality = packet.quality;
2537
+ const hasHelpfulVotes = Number(quality?.votes_up ?? 0) > 0;
2538
+ if (hasHelpfulVotes && !options.force) {
2539
+ skipped.push({ id: packet.id, title: packet.title, reason: `stale but has helpful votes (use --force to override)` });
2540
+ continue;
2541
+ }
2542
+ // Mark as deprecated (or hard-delete if --force)
2543
+ if (options.force && !hasHelpfulVotes) {
2544
+ if (!options.dryRun) {
2545
+ (0, node_fs_1.unlinkSync)(path);
2546
+ }
2547
+ deleted.push({ id: packet.id, title: packet.title });
2548
+ }
2549
+ else {
2550
+ if (!options.dryRun) {
2551
+ const updated = { ...packet, status: "deprecated", updated_at: nowIso() };
2552
+ writeJson(path, updated);
2553
+ }
2554
+ deprecated.push({ id: packet.id, title: packet.title, reason: reasons[0] });
2555
+ }
2556
+ }
2557
+ if (!options.dryRun && (deprecated.length || deleted.length)) {
2558
+ buildIndexes(projectDir);
2559
+ buildKnowledgeGraph(projectDir);
2560
+ writeJson((0, node_path_1.join)(memoryRoot(projectDir), "metrics.json"), kageMetrics(projectDir));
2561
+ }
2562
+ return {
2563
+ ok: true,
2564
+ project_dir: projectDir,
2565
+ deprecated,
2566
+ deleted,
2567
+ skipped,
2568
+ total_scanned: packetEntries.length,
2569
+ };
2570
+ }
2519
2571
  function installAgentPolicy(projectDir) {
2520
2572
  const agentsPath = (0, node_path_1.join)(projectDir, "AGENTS.md");
2521
2573
  const claudePath = (0, node_path_1.join)(projectDir, "CLAUDE.md");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kage-core/kage-graph-mcp",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Local-first repo memory, code graph, and recall MCP server for coding agents",
5
5
  "main": "dist/index.js",
6
6
  "files": [