@kage-core/kage-graph-mcp 1.1.36 → 1.1.38

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
@@ -34,7 +34,21 @@ Usage:
34
34
  kage upgrade [--dry-run]
35
35
  kage branch --project <dir> [--json]
36
36
  kage metrics --project <dir> [--json]
37
+ kage memory-access --project <dir> [--json]
38
+ kage memory-audit --project <dir> [--limit <n>] [--json]
39
+ kage slots --project <dir> [--json]
40
+ kage slots set --project <dir> --label <label> --content <text> [--description <text>] [--paths a,b] [--tags a,b] [--size-limit <n>] [--unpinned] [--json]
41
+ kage slots delete --project <dir> --label <label> [--json]
42
+ kage handoff --project <dir> [--json]
43
+ kage lifecycle --project <dir> [--json]
44
+ kage reconcile --project <dir> [--session <id>] [--json]
45
+ kage timeline --project <dir> [--days <n>] [--json]
46
+ kage lineage --project <dir> [--json]
47
+ kage supersede --project <dir> --packet <old-id> --replacement <new-id> [--reason <text>] [--json]
37
48
  kage contributors --project <dir> [--json]
49
+ kage profile --project <dir> [--json]
50
+ kage xray --project <dir> [--json]
51
+ kage capabilities --project <dir> [--json]
38
52
  kage decisions --project <dir> [--json]
39
53
  kage module-health --project <dir> [--json]
40
54
  kage graph-insights --project <dir> [--json]
@@ -44,6 +58,8 @@ Usage:
44
58
  kage inbox --project <dir> [--json]
45
59
  kage quality --project <dir> [--json]
46
60
  kage benchmark --project <dir> [--json]
61
+ kage benchmark --memory-quality [--json]
62
+ kage benchmark --scale [--sizes 240,1000,5000] [--json]
47
63
  kage benchmark --project <dir> --compare --task <task> [--json]
48
64
  kage code-graph --project <dir> [--json]
49
65
  kage code-graph "<query>" --project <dir> [--json]
@@ -57,8 +73,11 @@ Usage:
57
73
  kage graph --project <dir> --mermaid
58
74
  kage graph "<query>" --project <dir> [--json]
59
75
  kage graph-registry --project <dir> [--json]
60
- kage recall "<query>" --project <dir> [--json] [--explain]
76
+ kage embeddings build --project <dir> [--model Xenova/all-MiniLM-L6-v2] [--json]
77
+ kage recall "<query>" --project <dir> [--json] [--explain] [--embeddings]
61
78
  kage observe --project <dir> --event <json>
79
+ kage sessions --project <dir> [--json]
80
+ kage replay --project <dir> [--session <id>] [--limit <n>] [--json]
62
81
  kage distill --project <dir> --session <id>
63
82
  kage learn --project <dir> --learning <text> [--title <title>] [--type <type>] [--evidence <text>] [--verified-by <text>] [--tags a,b] [--paths a,b]
64
83
  kage feedback --project <dir> --packet <packet-id> --kind helpful|wrong|stale
@@ -220,7 +239,10 @@ async function main() {
220
239
  }
221
240
  console.log("Kage setup doctor");
222
241
  for (const item of result) {
223
- console.log(`- ${item.agent}: ${item.configured ? "configured" : "not detected"}${item.config_path ? ` (${item.config_path})` : ""}`);
242
+ const hookStatus = item.hook_summary
243
+ ? item.hook_summary.ready ? " hooks: installed" : ` hooks: missing ${item.hook_summary.missing.join(", ")}`
244
+ : "";
245
+ console.log(`- ${item.agent}: ${item.configured ? "configured" : "not detected"}${hookStatus}${item.config_path ? ` (${item.config_path})` : ""}`);
224
246
  }
225
247
  return;
226
248
  }
@@ -240,6 +262,9 @@ async function main() {
240
262
  console.log(`Indexes: ${result.checks.indexes_present ? "present" : "missing"}`);
241
263
  console.log(`Recall: ${result.checks.recall_works ? "ok" : "failed"} (${result.recall_preview})`);
242
264
  console.log(`Code graph: ${result.checks.code_graph_works ? "ok" : "failed"} (${result.code_graph_summary})`);
265
+ if (result.hook_summary) {
266
+ console.log(`Ambient hooks: ${result.checks.ambient_hooks_present ? "installed" : `missing ${result.hook_summary.missing.join(", ")}`}`);
267
+ }
243
268
  console.log(`Active MCP tool: ${result.checks.mcp_tool_reachable ? "reachable" : "not verified from CLI"}`);
244
269
  if (result.warnings.length)
245
270
  console.log(`Warnings:\n${result.warnings.map((warning) => ` - ${warning}`).join("\n")}`);
@@ -641,6 +666,54 @@ async function main() {
641
666
  console.log(`Warnings:\n${result.warnings.map((warning) => ` - ${warning}`).join("\n")}`);
642
667
  return;
643
668
  }
669
+ if (command === "profile") {
670
+ const result = (0, kernel_js_1.kageProjectProfile)(projectArg(args));
671
+ if (args.includes("--json")) {
672
+ console.log(JSON.stringify(result, null, 2));
673
+ return;
674
+ }
675
+ console.log(`Kage project profile: ${result.summary}`);
676
+ console.log(`Files: ${result.totals.files} (${result.totals.source_files} source, ${result.totals.test_files} test), symbols: ${result.totals.symbols}`);
677
+ console.log(`Memory: ${result.totals.approved_memory} packets, ${result.totals.memory_code_coverage_percent}% memory-code coverage`);
678
+ if (result.top_concepts.length)
679
+ console.log(`Top concepts: ${result.top_concepts.slice(0, 6).map((item) => `${item.concept} (${item.count})`).join(", ")}`);
680
+ if (result.key_files.length) {
681
+ console.log("Key files:");
682
+ for (const file of result.key_files.slice(0, 8))
683
+ console.log(`- ${file.path}: ${file.why.slice(0, 3).join("; ")}`);
684
+ }
685
+ if (result.run_commands.length) {
686
+ console.log("Commands:");
687
+ for (const commandItem of result.run_commands.slice(0, 6))
688
+ console.log(`- ${commandItem.name}: ${commandItem.command}`);
689
+ }
690
+ if (result.next_actions.length)
691
+ console.log(`Next: ${result.next_actions[0]}`);
692
+ if (result.warnings.length)
693
+ console.log(`Warnings:\n${result.warnings.map((warning) => ` - ${warning}`).join("\n")}`);
694
+ return;
695
+ }
696
+ if (command === "xray" || command === "repo-xray") {
697
+ const result = (0, kernel_js_1.kageRepoXray)(projectArg(args));
698
+ if (args.includes("--json")) {
699
+ console.log(JSON.stringify(result, null, 2));
700
+ return;
701
+ }
702
+ console.log(`Kage Repo X-Ray: ${result.summary}`);
703
+ for (const line of result.first_use_script)
704
+ console.log(`- ${line}`);
705
+ for (const layer of result.layers) {
706
+ console.log(`\n${layer.title}: ${layer.summary}`);
707
+ for (const item of layer.items.slice(0, 5)) {
708
+ console.log(`- ${item.path}: ${item.evidence.slice(0, 2).join("; ")}`);
709
+ }
710
+ }
711
+ if (result.next_actions.length)
712
+ console.log(`\nNext: ${result.next_actions[0]}`);
713
+ if (result.warnings.length)
714
+ console.log(`Warnings:\n${result.warnings.map((warning) => ` - ${warning}`).join("\n")}`);
715
+ return;
716
+ }
644
717
  if (command === "decisions") {
645
718
  const result = (0, kernel_js_1.kageDecisionIntelligence)(projectArg(args));
646
719
  if (args.includes("--json")) {
@@ -775,6 +848,256 @@ async function main() {
775
848
  console.log(` Estimated tokens saved: ${result.pain.estimated_tokens_saved}`);
776
849
  console.log(` Time to first use: ${result.pain.time_to_first_use_seconds}s`);
777
850
  }
851
+ if (result.memory_access) {
852
+ console.log("\nMemory access:");
853
+ console.log(` Tracked packets: ${result.memory_access.tracked_packets}`);
854
+ console.log(` Uses in 30d: ${result.memory_access.uses_30d}`);
855
+ console.log(` Hot / cold packets: ${result.memory_access.hot_packets} / ${result.memory_access.cold_packets}`);
856
+ }
857
+ return;
858
+ }
859
+ if (command === "memory-access") {
860
+ const result = (0, kernel_js_1.kageMemoryAccess)(projectArg(args));
861
+ if (args.includes("--json")) {
862
+ console.log(JSON.stringify(result, null, 2));
863
+ return;
864
+ }
865
+ console.log(`Kage memory access: ${result.totals.tracked_packets} tracked packet${result.totals.tracked_packets === 1 ? "" : "s"}`);
866
+ console.log(`Recent uses: ${result.totals.uses_30d} in ${result.window_days} days`);
867
+ console.log(`Hot / cold: ${result.totals.hot_packets} / ${result.totals.cold_packets}`);
868
+ if (result.recommendations.length) {
869
+ console.log("\nRecommended review:");
870
+ for (const item of result.recommendations.slice(0, 5)) {
871
+ console.log(`- ${item.summary}`);
872
+ console.log(` ${item.action}`);
873
+ }
874
+ }
875
+ console.log("\nTop recalled packets:");
876
+ for (const entry of result.entries.filter((item) => !(item.tags.includes("change-memory") && item.tags.includes("diff-proposal"))).slice(0, 10)) {
877
+ if (!entry.total_uses)
878
+ continue;
879
+ console.log(`- ${entry.title}: ${entry.uses_30d} recent, ${entry.total_uses} total${entry.best_rank ? `, best rank ${entry.best_rank}` : ""}`);
880
+ }
881
+ return;
882
+ }
883
+ if (command === "lifecycle" || command === "memory-lifecycle") {
884
+ const result = (0, kernel_js_1.kageMemoryLifecycle)(projectArg(args));
885
+ if (args.includes("--json")) {
886
+ console.log(JSON.stringify(result, null, 2));
887
+ return;
888
+ }
889
+ console.log(`Kage memory lifecycle: ${result.totals.approved} approved, ${result.totals.pending} pending`);
890
+ console.log(`Healthy / hot / stale: ${result.totals.healthy} / ${result.totals.hot} / ${result.totals.stale}`);
891
+ console.log(`Ungrounded / disputed / generated: ${result.totals.ungrounded} / ${result.totals.disputed} / ${result.totals.generated}`);
892
+ if (result.recommendations.length) {
893
+ console.log("\nRecommended actions:");
894
+ for (const item of result.recommendations.slice(0, 6)) {
895
+ console.log(`- ${item.title ? `${item.title}: ` : ""}${item.summary}`);
896
+ console.log(` ${item.action}`);
897
+ }
898
+ }
899
+ return;
900
+ }
901
+ if (command === "reconcile" || command === "memory-reconcile" || command === "memory-reconciliation") {
902
+ const result = (0, kernel_js_1.kageMemoryReconciliation)(projectArg(args), {
903
+ sessionId: takeArg(args, "--session"),
904
+ limit: numberArg(args, "--limit", 25),
905
+ });
906
+ if (args.includes("--json")) {
907
+ console.log(JSON.stringify(result, null, 2));
908
+ }
909
+ else {
910
+ console.log(result.agent_instruction);
911
+ if (result.items.length) {
912
+ console.log("\nItems:");
913
+ for (const item of result.items) {
914
+ console.log(`- ${item.packet_id}: ${item.title}`);
915
+ console.log(` Paths: ${item.changed_paths.join(", ") || item.paths.join(", ")}`);
916
+ console.log(` Action: ${item.next_action}`);
917
+ }
918
+ }
919
+ }
920
+ if (!result.ok)
921
+ process.exitCode = 2;
922
+ return;
923
+ }
924
+ if (command === "memory-audit" || command === "audit-log") {
925
+ const result = (0, kernel_js_1.kageMemoryAudit)(projectArg(args), numberArg(args, "--limit", 100));
926
+ if (args.includes("--json")) {
927
+ console.log(JSON.stringify(result, null, 2));
928
+ return;
929
+ }
930
+ console.log(`Kage memory audit: ${result.totals.total} mutation${result.totals.total === 1 ? "" : "s"}`);
931
+ console.log(`Capture / feedback / supersede: ${result.totals.capture} / ${result.totals.feedback} / ${result.totals.supersede}`);
932
+ for (const entry of result.entries.slice(0, 12)) {
933
+ console.log(`- ${entry.operation}: ${entry.packet_titles.join(", ") || entry.packet_ids.join(", ")} (${entry.timestamp.slice(0, 19)})`);
934
+ }
935
+ if (!result.entries.length)
936
+ console.log("No memory mutations have been audited yet.");
937
+ return;
938
+ }
939
+ if (command === "capabilities" || command === "capability-audit" || command === "readiness") {
940
+ const result = (0, kernel_js_1.kageCapabilityAudit)(projectArg(args));
941
+ if (args.includes("--json")) {
942
+ console.log(JSON.stringify(result, null, 2));
943
+ return;
944
+ }
945
+ console.log(`Kage capability audit: ${result.overall_score}/100 (${result.status})`);
946
+ console.log(result.summary);
947
+ for (const pillar of result.pillars) {
948
+ console.log(`\n${pillar.label}: ${pillar.score}/100 (${pillar.status})`);
949
+ for (const item of pillar.evidence.slice(0, 4))
950
+ console.log(` - ${item.label}: ${item.value}`);
951
+ if (pillar.gaps.length)
952
+ console.log(` Gap: ${pillar.gaps[0]}`);
953
+ if (pillar.actions.length)
954
+ console.log(` Action: ${pillar.actions[0]}`);
955
+ }
956
+ return;
957
+ }
958
+ if (command === "slots" || command === "context-slots") {
959
+ const action = args[1] && !args[1].startsWith("--") ? args[1] : undefined;
960
+ if (!action || action === "list") {
961
+ const result = (0, kernel_js_1.kageContextSlots)(projectArg(args));
962
+ if (args.includes("--json")) {
963
+ console.log(JSON.stringify(result, null, 2));
964
+ return;
965
+ }
966
+ console.log(`Kage pinned context slots: ${result.summary}`);
967
+ for (const slot of result.slots) {
968
+ console.log(`- ${slot.label}${slot.pinned ? " [pinned]" : ""}: ${slot.description || "(no description)"}`);
969
+ console.log(` ${slot.content.slice(0, 160)}${slot.content.length > 160 ? "..." : ""}`);
970
+ }
971
+ if (!result.slots.length)
972
+ console.log("No slots yet. Add one with `kage slots set --label project_context --content \"...\" --project .`.");
973
+ if (result.warnings.length)
974
+ console.log(`Warnings:\n${result.warnings.map((warning) => ` - ${warning}`).join("\n")}`);
975
+ return;
976
+ }
977
+ if (action === "set") {
978
+ const label = takeArg(args, "--label");
979
+ const content = takeArg(args, "--content");
980
+ if (!label || !content)
981
+ usage();
982
+ const result = (0, kernel_js_1.setContextSlot)(projectArg(args), {
983
+ label,
984
+ content,
985
+ description: takeArg(args, "--description"),
986
+ pinned: !args.includes("--unpinned"),
987
+ size_limit: numberArg(args, "--size-limit", 2000),
988
+ paths: listArg(takeArg(args, "--paths")),
989
+ tags: listArg(takeArg(args, "--tags")),
990
+ });
991
+ if (args.includes("--json")) {
992
+ console.log(JSON.stringify(result, null, 2));
993
+ if (!result.ok)
994
+ process.exit(2);
995
+ return;
996
+ }
997
+ if (!result.ok) {
998
+ console.error(`Context slot not saved:\n${result.errors.map((error) => ` - ${error}`).join("\n")}`);
999
+ process.exit(2);
1000
+ }
1001
+ console.log(`Saved context slot: ${result.slot?.label}`);
1002
+ return;
1003
+ }
1004
+ if (action === "delete") {
1005
+ const label = takeArg(args, "--label");
1006
+ if (!label)
1007
+ usage();
1008
+ const result = (0, kernel_js_1.deleteContextSlot)(projectArg(args), label);
1009
+ if (args.includes("--json")) {
1010
+ console.log(JSON.stringify(result, null, 2));
1011
+ if (!result.ok)
1012
+ process.exit(2);
1013
+ return;
1014
+ }
1015
+ if (!result.ok) {
1016
+ console.error(`Context slot not deleted:\n${result.errors.map((error) => ` - ${error}`).join("\n")}`);
1017
+ process.exit(2);
1018
+ }
1019
+ console.log(`Deleted context slot: ${result.deleted?.label}`);
1020
+ return;
1021
+ }
1022
+ usage();
1023
+ }
1024
+ if (command === "handoff" || command === "memory-handoff") {
1025
+ const result = (0, kernel_js_1.kageMemoryHandoff)(projectArg(args));
1026
+ if (args.includes("--json")) {
1027
+ console.log(JSON.stringify(result, null, 2));
1028
+ return;
1029
+ }
1030
+ console.log(`Kage memory handoff: ${result.totals.open_items} open item${result.totals.open_items === 1 ? "" : "s"}, ${result.totals.distillable_sessions} distillable session${result.totals.distillable_sessions === 1 ? "" : "s"}, ${result.totals.recent_mutations} recent mutation${result.totals.recent_mutations === 1 ? "" : "s"}`);
1031
+ console.log(result.summary);
1032
+ console.log(`Primary action: ${result.primary_action.label} — ${result.primary_action.action}`);
1033
+ if (result.items.length) {
1034
+ console.log("\nNext actions:");
1035
+ for (const item of result.items.slice(0, 10)) {
1036
+ console.log(`- [${item.severity}] ${item.title}: ${item.summary}`);
1037
+ console.log(` ${item.action}`);
1038
+ }
1039
+ }
1040
+ if (result.recommendations.length) {
1041
+ console.log("\nRecommendations:");
1042
+ for (const item of result.recommendations.slice(0, 5))
1043
+ console.log(`- ${item}`);
1044
+ }
1045
+ return;
1046
+ }
1047
+ if (command === "timeline" || command === "memory-timeline") {
1048
+ const result = (0, kernel_js_1.kageMemoryTimeline)(projectArg(args), numberArg(args, "--days", 14));
1049
+ if (args.includes("--json")) {
1050
+ console.log(JSON.stringify(result, null, 2));
1051
+ return;
1052
+ }
1053
+ console.log(`Kage memory timeline: last ${result.days} day${result.days === 1 ? "" : "s"} — ${result.totals.total} event${result.totals.total === 1 ? "" : "s"}`);
1054
+ console.log(`Added / updated / pending / deprecated: ${result.totals.added} / ${result.totals.updated} / ${result.totals.pending} / ${result.totals.deprecated}`);
1055
+ for (const entry of result.entries.slice(0, 12)) {
1056
+ const prefix = entry.kind === "added" ? "+" : entry.kind === "updated" ? "~" : entry.kind === "pending" ? "?" : "-";
1057
+ console.log(` ${prefix} [${entry.type}] ${entry.title} (${entry.date.slice(0, 10)})`);
1058
+ }
1059
+ if (!result.entries.length)
1060
+ console.log("No memory activity in this period.");
1061
+ return;
1062
+ }
1063
+ if (command === "lineage" || command === "memory-lineage") {
1064
+ const result = (0, kernel_js_1.kageMemoryLineage)(projectArg(args));
1065
+ if (args.includes("--json")) {
1066
+ console.log(JSON.stringify(result, null, 2));
1067
+ return;
1068
+ }
1069
+ console.log(`Kage memory lineage: ${result.totals.chains} replacement chain${result.totals.chains === 1 ? "" : "s"}, ${result.totals.orphans} orphan${result.totals.orphans === 1 ? "" : "s"}`);
1070
+ for (const chain of result.chains.slice(0, 10)) {
1071
+ console.log(`- ${chain.current_title}: replaces ${chain.superseded_packet_ids.length} packet${chain.superseded_packet_ids.length === 1 ? "" : "s"}`);
1072
+ console.log(` ${chain.action}`);
1073
+ }
1074
+ if (result.orphans.length) {
1075
+ console.log("\nNeeds repair:");
1076
+ for (const orphan of result.orphans.slice(0, 10))
1077
+ console.log(`- ${orphan.title}: ${orphan.action}`);
1078
+ }
1079
+ if (!result.chains.length && !result.orphans.length)
1080
+ console.log("No superseded memory chains yet.");
1081
+ return;
1082
+ }
1083
+ if (command === "supersede") {
1084
+ const oldId = takeArg(args, "--packet");
1085
+ const replacementId = takeArg(args, "--replacement");
1086
+ if (!oldId || !replacementId)
1087
+ usage();
1088
+ const result = (0, kernel_js_1.supersedeMemory)(projectArg(args), oldId, replacementId, takeArg(args, "--reason") ?? "");
1089
+ if (args.includes("--json")) {
1090
+ console.log(JSON.stringify(result, null, 2));
1091
+ return;
1092
+ }
1093
+ if (!result.ok) {
1094
+ console.error(`Failed to supersede memory: ${result.errors.join("; ")}`);
1095
+ process.exit(1);
1096
+ }
1097
+ console.log(`Superseded memory: ${result.old_packet_id}`);
1098
+ console.log(`Replacement: ${result.replacement_packet_id}`);
1099
+ if (result.warnings.length)
1100
+ console.log(`Warnings:\n${result.warnings.map((warning) => ` - ${warning}`).join("\n")}`);
778
1101
  return;
779
1102
  }
780
1103
  if (command === "module-health") {
@@ -935,6 +1258,55 @@ async function main() {
935
1258
  return;
936
1259
  }
937
1260
  if (command === "benchmark") {
1261
+ if (args.includes("--memory-quality")) {
1262
+ const result = (0, kernel_js_1.benchmarkCodingMemoryQuality)({
1263
+ topK: Number(takeArg(args, "--top-k") ?? 10),
1264
+ packetsPerTopic: Number(takeArg(args, "--packets-per-topic") ?? 5),
1265
+ distractorsPerTopic: Number(takeArg(args, "--distractors-per-topic") ?? 7),
1266
+ keep: args.includes("--keep"),
1267
+ });
1268
+ if (args.includes("--json")) {
1269
+ console.log(JSON.stringify(result, null, 2));
1270
+ return;
1271
+ }
1272
+ console.log("Kage Coding Memory Quality Benchmark");
1273
+ console.log(`Packets: ${result.summary.packets}`);
1274
+ console.log(`Queries: ${result.summary.queries}`);
1275
+ console.log(`Refresh/index: ${result.summary.refresh_ms}ms`);
1276
+ console.log(`R@5: ${result.summary.recall_at_5_percent ?? "n/a"}%`);
1277
+ console.log(`R@10: ${result.summary.recall_at_10_percent ?? "n/a"}%`);
1278
+ console.log(`NDCG@10: ${result.summary.ndcg_at_10}`);
1279
+ console.log(`MRR: ${result.summary.mrr}`);
1280
+ console.log(`Median recall: ${result.summary.median_latency_ms}ms`);
1281
+ console.log(`Context reduction: ${result.summary.context_reduction_percent}%`);
1282
+ return;
1283
+ }
1284
+ if (args.includes("--scale")) {
1285
+ const sizes = String(takeArg(args, "--sizes") ?? "240,1000,5000")
1286
+ .split(",")
1287
+ .map((value) => Number(value.trim()))
1288
+ .filter((value) => Number.isFinite(value) && value > 0);
1289
+ const result = (0, kernel_js_1.benchmarkMemoryScale)({
1290
+ sizes,
1291
+ topK: Number(takeArg(args, "--top-k") ?? 10),
1292
+ keep: args.includes("--keep"),
1293
+ });
1294
+ if (args.includes("--json")) {
1295
+ console.log(JSON.stringify(result, null, 2));
1296
+ return;
1297
+ }
1298
+ console.log("Kage Memory Scale Benchmark");
1299
+ console.log(`Sizes: ${result.sizes.join(", ")}`);
1300
+ console.log(`Top K: ${result.top_k}`);
1301
+ console.log(`Largest corpus: ${result.summary.largest_packets} packets`);
1302
+ console.log(`Hit rate: ${result.summary.largest_hit_rate_percent}%`);
1303
+ console.log(`Median recall: ${result.summary.largest_median_recall_latency_ms}ms`);
1304
+ console.log(`Context reduction: ${result.summary.largest_context_reduction_percent}%`);
1305
+ for (const row of result.results) {
1306
+ console.log(`- ${row.packets} packets: ${row.recall_hit_rate_percent}% hit, ${row.median_recall_latency_ms}ms median, ${row.context_reduction_percent}% context reduction`);
1307
+ }
1308
+ return;
1309
+ }
938
1310
  if (args.includes("--compare")) {
939
1311
  const result = (0, kernel_js_1.benchmarkTaskComparison)(projectArg(args), takeArg(args, "--task") ?? firstPositional(args) ?? "how do I run tests");
940
1312
  if (args.includes("--json")) {
@@ -1193,13 +1565,36 @@ async function main() {
1193
1565
  const query = firstPositional(args);
1194
1566
  if (!query)
1195
1567
  usage();
1196
- const result = (0, kernel_js_1.recall)(projectArg(args), query, 5, args.includes("--explain"));
1568
+ const result = args.includes("--embeddings")
1569
+ ? await (0, kernel_js_1.recallWithEmbeddings)(projectArg(args), query, 5, args.includes("--explain"))
1570
+ : (0, kernel_js_1.recall)(projectArg(args), query, 5, args.includes("--explain"));
1197
1571
  if (args.includes("--json"))
1198
1572
  console.log(JSON.stringify(result, null, 2));
1199
1573
  else
1200
1574
  console.log(result.context_block);
1201
1575
  return;
1202
1576
  }
1577
+ if (command === "embeddings") {
1578
+ const action = firstPositional(args);
1579
+ if (action !== "build")
1580
+ usage();
1581
+ const result = await (0, kernel_js_1.buildEmbeddingIndex)(projectArg(args), { model: takeArg(args, "--model") });
1582
+ if (args.includes("--json")) {
1583
+ console.log(JSON.stringify(result, null, 2));
1584
+ if (!result.ok)
1585
+ process.exitCode = 2;
1586
+ return;
1587
+ }
1588
+ if (!result.ok) {
1589
+ console.error(`Embedding index failed:\n${result.errors.map((error) => ` - ${error}`).join("\n")}`);
1590
+ process.exit(2);
1591
+ }
1592
+ console.log(`Embedding index: ${result.path}`);
1593
+ console.log(`Provider: ${result.provider}`);
1594
+ console.log(`Model: ${result.model}`);
1595
+ console.log(`Packets: ${result.packet_count}`);
1596
+ return;
1597
+ }
1203
1598
  if (command === "observe") {
1204
1599
  const event = takeArg(args, "--event");
1205
1600
  if (!event)
@@ -1217,6 +1612,59 @@ async function main() {
1217
1612
  }
1218
1613
  return;
1219
1614
  }
1615
+ if (command === "sessions") {
1616
+ const result = (0, kernel_js_1.kageSessionCaptureReport)(projectArg(args));
1617
+ if (args.includes("--json")) {
1618
+ console.log(JSON.stringify(result, null, 2));
1619
+ return;
1620
+ }
1621
+ console.log(`Sessions: ${result.totals.sessions}`);
1622
+ console.log(`Observations: ${result.totals.observations}`);
1623
+ console.log(`Distillable observations: ${result.totals.durable_observations}`);
1624
+ for (const session of result.sessions.slice(0, 10)) {
1625
+ console.log(`\n${session.session_id} — ${session.observations} observation${session.observations === 1 ? "" : "s"}, ${session.durable_observations} distillable`);
1626
+ console.log(` ${session.first_at || "unknown"} → ${session.last_at || "unknown"}`);
1627
+ if (session.candidate_types.length)
1628
+ console.log(` Candidates: ${session.candidate_types.join(", ")}`);
1629
+ console.log(` Next: ${session.next_action}`);
1630
+ }
1631
+ if (!result.sessions.length)
1632
+ console.log("No local observation sessions recorded yet.");
1633
+ return;
1634
+ }
1635
+ if (command === "replay" || command === "session-replay") {
1636
+ const result = (0, kernel_js_1.kageSessionReplay)(projectArg(args), {
1637
+ sessionId: takeArg(args, "--session"),
1638
+ limit: Number(takeArg(args, "--limit") ?? 200),
1639
+ });
1640
+ if (args.includes("--json")) {
1641
+ console.log(JSON.stringify(result, null, 2));
1642
+ return;
1643
+ }
1644
+ console.log(`Session replay digest: ${result.totals.sessions} session${result.totals.sessions === 1 ? "" : "s"}, ${result.totals.events} event${result.totals.events === 1 ? "" : "s"}`);
1645
+ console.log(`Durable candidates: ${result.totals.durable_candidates}`);
1646
+ for (const session of result.sessions.slice(0, 8)) {
1647
+ console.log(`\n${session.session_id} — ${session.events} event${session.events === 1 ? "" : "s"}, ${session.durable_candidates} durable candidate${session.durable_candidates === 1 ? "" : "s"}`);
1648
+ console.log(` ${session.first_at || "unknown"} → ${session.last_at || "unknown"}`);
1649
+ if (session.paths.length)
1650
+ console.log(` Paths: ${session.paths.slice(0, 4).join(", ")}`);
1651
+ if (session.commands.length)
1652
+ console.log(` Commands: ${session.commands.slice(0, 3).join(", ")}`);
1653
+ if (session.durable_candidates)
1654
+ console.log(` Next: ${session.distill_command}`);
1655
+ }
1656
+ if (result.events.length) {
1657
+ console.log("\nTimeline:");
1658
+ for (const event of result.events.slice(0, 20)) {
1659
+ const durable = event.durable_candidate ? ` [${event.candidate_type ?? "durable"}]` : "";
1660
+ console.log(` ${event.timestamp} ${event.label}${durable}: ${event.summary}`);
1661
+ }
1662
+ }
1663
+ else {
1664
+ console.log("No local observation events recorded yet.");
1665
+ }
1666
+ return;
1667
+ }
1220
1668
  if (command === "distill") {
1221
1669
  const sessionId = takeArg(args, "--session");
1222
1670
  if (!sessionId)