@kage-core/kage-graph-mcp 1.2.0 → 1.4.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/dist/cli.js CHANGED
@@ -12,6 +12,7 @@ function usage() {
12
12
 
13
13
  Usage:
14
14
  kage index --project <dir>
15
+ kage demo [--project <dir>]
15
16
  kage init --project <dir>
16
17
  kage policy --project <dir>
17
18
  kage doctor --project <dir>
@@ -31,12 +32,14 @@ Usage:
31
32
  kage gc --project <dir> [--dry-run] [--force] [--json]
32
33
  kage compact --project <dir> [--dry-run] [--json]
33
34
  kage verify --project <dir> [--id <packet-id>] [--json]
35
+ kage suppressed --project <dir> [--json]
34
36
  kage pr summarize --project <dir> [--json]
35
37
  kage pr check --project <dir> [--json]
36
38
  kage upgrade [--dry-run]
37
39
  kage branch --project <dir> [--json]
38
40
  kage metrics --project <dir> [--json]
39
41
  kage memory-access --project <dir> [--json]
42
+ kage activity --project <dir> [--json]
40
43
  kage memory-audit --project <dir> [--limit <n>] [--json]
41
44
  kage slots --project <dir> [--json]
42
45
  kage slots set --project <dir> --label <label> --content <text> [--description <text>] [--paths a,b] [--tags a,b] [--size-limit <n>] [--unpinned] [--json]
@@ -60,6 +63,7 @@ Usage:
60
63
  kage inbox --project <dir> [--json]
61
64
  kage quality --project <dir> [--json]
62
65
  kage benchmark --project <dir> [--json]
66
+ kage benchmark --trust --project <dir> [--json]
63
67
  kage benchmark --memory-quality [--json]
64
68
  kage benchmark --scale [--sizes 240,1000,5000] [--json]
65
69
  kage benchmark --project <dir> --compare --task <task> [--json]
@@ -176,6 +180,30 @@ async function main() {
176
180
  console.log(`Indexes:\n${result.indexes.map((path) => ` - ${path}`).join("\n")}`);
177
181
  return;
178
182
  }
183
+ if (command === "demo") {
184
+ const demoDir = takeArg(args, "--project") ?? `${process.cwd()}/kage-demo`;
185
+ const result = (0, kernel_js_1.runDemo)(demoDir);
186
+ if (args.includes("--json")) {
187
+ console.log(JSON.stringify(result, null, 2));
188
+ return;
189
+ }
190
+ console.log("Kage demo — can you trust your agent's memory?\n");
191
+ console.log(`Seeded ${result.captured.length} grounded memories in ${result.project_dir}\n`);
192
+ console.log("1. Hallucinated citation — REJECTED on write:");
193
+ if (result.rejected_hallucination) {
194
+ console.log(` ✗ "${result.rejected_hallucination.title}"`);
195
+ console.log(` ${result.rejected_hallucination.error}\n`);
196
+ }
197
+ console.log("2. Stale memory (cited file deleted) — WITHHELD from recall:");
198
+ for (const w of result.withheld)
199
+ console.log(` ⊘ ${w.title}\n ${w.reason}`);
200
+ console.log("\n3. Recall returns only grounded, current memory:");
201
+ for (const t of result.recalled)
202
+ console.log(` ✓ ${t}`);
203
+ console.log(`\nTrust score: ${result.trust_score}/100`);
204
+ console.log(`\nSee it in the viewer: ${result.viewer_command}`);
205
+ return;
206
+ }
179
207
  if (command === "init") {
180
208
  const result = (0, kernel_js_1.initProject)(projectArg(args));
181
209
  console.log(`Initialized Kage memory for ${result.index.projectDir}`);
@@ -465,6 +493,21 @@ async function main() {
465
493
  }
466
494
  return;
467
495
  }
496
+ if (command === "suppressed") {
497
+ const result = (0, kernel_js_1.kageSuppressedMemory)(projectArg(args));
498
+ if (args.includes("--json")) {
499
+ console.log(JSON.stringify(result, null, 2));
500
+ return;
501
+ }
502
+ console.log(`Kage suppressed memory — ${result.count} packet(s) currently withheld from recall`);
503
+ for (const item of result.items) {
504
+ console.log(` ⊘ ${item.title}`);
505
+ console.log(` ${item.reason}`);
506
+ }
507
+ if (!result.count)
508
+ console.log(" (none — all recallable memory is grounded and current)");
509
+ return;
510
+ }
468
511
  if (command === "refresh") {
469
512
  const result = (0, kernel_js_1.refreshProject)(projectArg(args), { full: args.includes("--full") });
470
513
  if (args.includes("--json")) {
@@ -941,6 +984,19 @@ async function main() {
941
984
  }
942
985
  return;
943
986
  }
987
+ if (command === "activity") {
988
+ const result = (0, kernel_js_1.kageActivity)(projectArg(args));
989
+ if (args.includes("--json")) {
990
+ console.log(JSON.stringify(result, null, 2));
991
+ return;
992
+ }
993
+ console.log(`Kage activity: ${result.totals.events} events (${result.totals.recalls} recalls, ${result.totals.captures} captures); ${result.totals.recalls_7d} recalls in 7 days`);
994
+ console.log("\nRecent:");
995
+ for (const event of result.events.slice(0, 15)) {
996
+ console.log(`- ${event.at.slice(0, 16).replace("T", " ")} ${event.kind.padEnd(9)} ${event.title}`);
997
+ }
998
+ return;
999
+ }
944
1000
  if (command === "lifecycle" || command === "memory-lifecycle") {
945
1001
  const result = (0, kernel_js_1.kageMemoryLifecycle)(projectArg(args));
946
1002
  if (args.includes("--json")) {
@@ -1319,6 +1375,24 @@ async function main() {
1319
1375
  return;
1320
1376
  }
1321
1377
  if (command === "benchmark") {
1378
+ if (args.includes("--trust")) {
1379
+ const result = (0, kernel_js_1.benchmarkTrust)(projectArg(args));
1380
+ if (args.includes("--json")) {
1381
+ console.log(JSON.stringify(result, null, 2));
1382
+ if (!result.ok)
1383
+ process.exitCode = 1;
1384
+ return;
1385
+ }
1386
+ console.log("Kage Trust Benchmark — can this memory be trusted?");
1387
+ console.log(`Trust score: ${result.trust_score}/100 (${result.ok ? "PASS" : "REVIEW"})`);
1388
+ console.log(` Hallucinated-citation rejection: ${result.metrics.hallucinated_citation_rejection_rate}% (${result.detail.hallucination.rejected}/${result.detail.hallucination.attempted})`);
1389
+ console.log(` Stale-memory exclusion: ${result.metrics.stale_memory_exclusion_rate}% (${result.detail.staleness.excluded_after}/${result.detail.staleness.recallable_before})`);
1390
+ console.log(` Live grounding rate: ${result.metrics.live_grounding_rate}% (${result.detail.live_memory.grounded}/${result.detail.live_memory.checked} packets)`);
1391
+ console.log(` Wrong-advice prevented: ${result.metrics.wrong_advice_prevented_rate}%`);
1392
+ if (!result.ok)
1393
+ process.exitCode = 1;
1394
+ return;
1395
+ }
1322
1396
  if (args.includes("--memory-quality")) {
1323
1397
  const result = (0, kernel_js_1.benchmarkCodingMemoryQuality)({
1324
1398
  topK: Number(takeArg(args, "--top-k") ?? 10),
package/dist/daemon.js CHANGED
@@ -570,9 +570,12 @@ async function startViewer(projectDir, options = {}) {
570
570
  const memoryAuditPath = (0, node_path_1.join)(reportsDir, "memory-audit.json");
571
571
  const handoffPath = (0, node_path_1.join)(reportsDir, "handoff.json");
572
572
  const lifecyclePath = (0, node_path_1.join)(reportsDir, "lifecycle.json");
573
+ const activityPath = (0, node_path_1.join)(reportsDir, "activity.json");
573
574
  const timelinePath = (0, node_path_1.join)(reportsDir, "timeline.json");
574
575
  const lineagePath = (0, node_path_1.join)(reportsDir, "lineage.json");
575
576
  const setupPath = (0, node_path_1.join)(reportsDir, "setup.json");
577
+ const trustPath = (0, node_path_1.join)(reportsDir, "trust.json");
578
+ const suppressedPath = (0, node_path_1.join)(reportsDir, "suppressed.json");
576
579
  // Pre-generate lightweight JSON reports so the viewer can load them directly.
577
580
  try {
578
581
  (0, node_fs_1.mkdirSync)(reportsDir, { recursive: true });
@@ -598,14 +601,17 @@ async function startViewer(projectDir, options = {}) {
598
601
  (0, node_fs_1.writeFileSync)(memoryAuditPath, JSON.stringify((0, kernel_js_1.kageMemoryAudit)(projectDir), null, 2));
599
602
  (0, node_fs_1.writeFileSync)(handoffPath, JSON.stringify((0, kernel_js_1.kageMemoryHandoff)(projectDir), null, 2));
600
603
  (0, node_fs_1.writeFileSync)(lifecyclePath, JSON.stringify((0, kernel_js_1.kageMemoryLifecycle)(projectDir), null, 2));
604
+ (0, node_fs_1.writeFileSync)(activityPath, JSON.stringify((0, kernel_js_1.kageActivity)(projectDir), null, 2));
601
605
  (0, node_fs_1.writeFileSync)(timelinePath, JSON.stringify((0, kernel_js_1.kageMemoryTimeline)(projectDir), null, 2));
602
606
  (0, node_fs_1.writeFileSync)(lineagePath, JSON.stringify((0, kernel_js_1.kageMemoryLineage)(projectDir), null, 2));
603
607
  (0, node_fs_1.writeFileSync)(setupPath, JSON.stringify((0, kernel_js_1.setupDoctor)(projectDir), null, 2));
608
+ (0, node_fs_1.writeFileSync)(trustPath, JSON.stringify((0, kernel_js_1.benchmarkTrust)(projectDir), null, 2));
609
+ (0, node_fs_1.writeFileSync)(suppressedPath, JSON.stringify((0, kernel_js_1.kageSuppressedMemory)(projectDir), null, 2));
604
610
  }
605
611
  catch {
606
612
  // non-fatal: viewer will show 404 for reports if generation fails
607
613
  }
608
- const url = `http://${host}:${port}/viewer/index.html?graph=${encodeURIComponent(graphPath)}&code=${encodeURIComponent(codePath)}&metrics=${encodeURIComponent(metricsPath)}&inbox=${encodeURIComponent(inboxPath)}&review=${encodeURIComponent(reviewPath)}&pending=${encodeURIComponent(pendingDir)}&quality=${encodeURIComponent(qualityPath)}&benchmark=${encodeURIComponent(benchmarkPath)}&contributors=${encodeURIComponent(contributorsPath)}&profile=${encodeURIComponent(profilePath)}&xray=${encodeURIComponent(xrayPath)}&capabilities=${encodeURIComponent(capabilitiesPath)}&slots=${encodeURIComponent(slotsPath)}&decisions=${encodeURIComponent(decisionsPath)}&risk=${encodeURIComponent(riskPath)}&moduleHealth=${encodeURIComponent(moduleHealthPath)}&graphInsights=${encodeURIComponent(graphInsightsPath)}&workspace=${encodeURIComponent(workspacePath)}&sessions=${encodeURIComponent(sessionsPath)}&replay=${encodeURIComponent(replayPath)}&memoryAccess=${encodeURIComponent(memoryAccessPath)}&memoryAudit=${encodeURIComponent(memoryAuditPath)}&handoff=${encodeURIComponent(handoffPath)}&lifecycle=${encodeURIComponent(lifecyclePath)}&timeline=${encodeURIComponent(timelinePath)}&lineage=${encodeURIComponent(lineagePath)}&setup=${encodeURIComponent(setupPath)}&view=code`;
614
+ const url = `http://${host}:${port}/viewer/index.html?graph=${encodeURIComponent(graphPath)}&code=${encodeURIComponent(codePath)}&metrics=${encodeURIComponent(metricsPath)}&inbox=${encodeURIComponent(inboxPath)}&review=${encodeURIComponent(reviewPath)}&pending=${encodeURIComponent(pendingDir)}&quality=${encodeURIComponent(qualityPath)}&benchmark=${encodeURIComponent(benchmarkPath)}&contributors=${encodeURIComponent(contributorsPath)}&profile=${encodeURIComponent(profilePath)}&xray=${encodeURIComponent(xrayPath)}&capabilities=${encodeURIComponent(capabilitiesPath)}&slots=${encodeURIComponent(slotsPath)}&decisions=${encodeURIComponent(decisionsPath)}&risk=${encodeURIComponent(riskPath)}&moduleHealth=${encodeURIComponent(moduleHealthPath)}&graphInsights=${encodeURIComponent(graphInsightsPath)}&workspace=${encodeURIComponent(workspacePath)}&sessions=${encodeURIComponent(sessionsPath)}&replay=${encodeURIComponent(replayPath)}&memoryAccess=${encodeURIComponent(memoryAccessPath)}&memoryAudit=${encodeURIComponent(memoryAuditPath)}&handoff=${encodeURIComponent(handoffPath)}&lifecycle=${encodeURIComponent(lifecyclePath)}&activity=${encodeURIComponent(activityPath)}&timeline=${encodeURIComponent(timelinePath)}&lineage=${encodeURIComponent(lineagePath)}&setup=${encodeURIComponent(setupPath)}&trust=${encodeURIComponent(trustPath)}&suppressed=${encodeURIComponent(suppressedPath)}&view=code`;
609
615
  const server = (0, node_http_1.createServer)((req, res) => {
610
616
  const requestUrl = new URL(req.url ?? "/", `http://${host}:${port}`);
611
617
  let filePath = null;
package/dist/index.js CHANGED
@@ -590,7 +590,7 @@ function listTools() {
590
590
  type: "object",
591
591
  properties: {
592
592
  project_dir: { type: "string" },
593
- mode: { type: "string", enum: ["project", "memory_quality", "memory_scale"] },
593
+ mode: { type: "string", enum: ["project", "trust", "memory_quality", "memory_scale"] },
594
594
  sizes: { type: "array", items: { type: "number" } },
595
595
  top_k: { type: "number" },
596
596
  },
@@ -1376,14 +1376,16 @@ async function callTool(name, args) {
1376
1376
  }
1377
1377
  if (name === "kage_benchmark") {
1378
1378
  const mode = String(args?.mode ?? "project");
1379
- const result = mode === "memory_quality"
1380
- ? (0, kernel_js_1.benchmarkCodingMemoryQuality)({ topK: Number(args?.top_k ?? 10) })
1381
- : mode === "memory_scale"
1382
- ? (0, kernel_js_1.benchmarkMemoryScale)({
1383
- sizes: Array.isArray(args?.sizes) ? args.sizes.map(Number) : undefined,
1384
- topK: Number(args?.top_k ?? 10),
1385
- })
1386
- : (0, kernel_js_1.benchmarkProject)(String(args?.project_dir ?? ""));
1379
+ const result = mode === "trust"
1380
+ ? (0, kernel_js_1.benchmarkTrust)(String(args?.project_dir ?? ""))
1381
+ : mode === "memory_quality"
1382
+ ? (0, kernel_js_1.benchmarkCodingMemoryQuality)({ topK: Number(args?.top_k ?? 10) })
1383
+ : mode === "memory_scale"
1384
+ ? (0, kernel_js_1.benchmarkMemoryScale)({
1385
+ sizes: Array.isArray(args?.sizes) ? args.sizes.map(Number) : undefined,
1386
+ topK: Number(args?.top_k ?? 10),
1387
+ })
1388
+ : (0, kernel_js_1.benchmarkProject)(String(args?.project_dir ?? ""));
1387
1389
  return {
1388
1390
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
1389
1391
  };
@@ -1692,5 +1694,16 @@ async function main() {
1692
1694
  await server.connect(transport);
1693
1695
  }
1694
1696
  if (require.main === module) {
1697
+ const firstArg = process.argv[2];
1698
+ if (firstArg && !firstArg.startsWith("-")) {
1699
+ // A positional subcommand (demo, init, recall, ...) means the user wants the
1700
+ // kage CLI, not the MCP stdio server. Delegate so a single
1701
+ // `npx @kage-core/kage-graph-mcp <command>` works like the `kage` binary.
1702
+ // MCP clients launch with no args (or flags), which falls through to the server.
1703
+ const { spawnSync } = require("node:child_process");
1704
+ const { join } = require("node:path");
1705
+ const result = spawnSync(process.execPath, [join(__dirname, "cli.js"), ...process.argv.slice(2)], { stdio: "inherit" });
1706
+ process.exit(result.status ?? 0);
1707
+ }
1695
1708
  main().catch(console.error);
1696
1709
  }