mneme-ai 2.115.0 → 2.116.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `mneme map` (v2.116.0) — render the Visual Knowledge Map: a gorgeous,
3
+ * dependency-free constellation of Mneme's live signed state (savings / loop /
4
+ * cortex / treasury) that auto-adapts to the terminal (truecolor gradients →
5
+ * 256-color → plain ASCII on a pipe/CI). Zero config — it just renders the
6
+ * richest form the surface supports.
7
+ *
8
+ * mneme map # the live knowledge-map frame
9
+ * mneme map --json # the underlying state (for embedding)
10
+ *
11
+ * Gathering is best-effort + total: missing ledgers → idle nodes, never an error.
12
+ */
13
+ import type { Command } from "commander";
14
+ export declare function registerMapCommands(program: Command): void;
15
+ //# sourceMappingURL=map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/commands/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmEzC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgB1D"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * `mneme map` (v2.116.0) — render the Visual Knowledge Map: a gorgeous,
3
+ * dependency-free constellation of Mneme's live signed state (savings / loop /
4
+ * cortex / treasury) that auto-adapts to the terminal (truecolor gradients →
5
+ * 256-color → plain ASCII on a pipe/CI). Zero config — it just renders the
6
+ * richest form the surface supports.
7
+ *
8
+ * mneme map # the live knowledge-map frame
9
+ * mneme map --json # the underlying state (for embedding)
10
+ *
11
+ * Gathering is best-effort + total: missing ledgers → idle nodes, never an error.
12
+ */
13
+ import { existsSync, readFileSync } from "node:fs";
14
+ import { join } from "node:path";
15
+ function writeText(l) { process.stdout.write(l + "\n"); }
16
+ function writeJson(p) { process.stdout.write(JSON.stringify(p, null, 2) + "\n"); }
17
+ async function core() {
18
+ try {
19
+ const c = (await import("@mneme-ai/core"));
20
+ if (c.visual)
21
+ return c;
22
+ }
23
+ catch { /* */ }
24
+ return null;
25
+ }
26
+ function readVersion() { try {
27
+ return String(require("../../package.json").version);
28
+ }
29
+ catch {
30
+ return "";
31
+ } }
32
+ /** Gather the live state into a MapState (best-effort, total). */
33
+ function gatherState(m, cwd) {
34
+ const nodes = [];
35
+ let headline = "";
36
+ let savingsSpark = [];
37
+ // TREASURY — token savings
38
+ try {
39
+ const p = join(cwd, ".mneme", "treasury", "ledger.jsonl");
40
+ if (existsSync(p) && m.treasury) {
41
+ const evs = m.treasury.parseLedger(readFileSync(p, "utf8"));
42
+ const agg = m.treasury.aggregate(evs);
43
+ if (agg.events > 0) {
44
+ nodes.push({ label: "SAVINGS", status: "ok" });
45
+ headline = `${agg.tokensSaved.toLocaleString()} input tokens saved (−${agg.savedPct}%)`;
46
+ savingsSpark = evs.slice(-24).map((e) => Math.max(0, (e.tokensBefore || 0) - (e.tokensAfter || 0)));
47
+ }
48
+ else {
49
+ nodes.push({ label: "SAVINGS", status: "idle" });
50
+ }
51
+ }
52
+ else {
53
+ nodes.push({ label: "SAVINGS", status: "idle" });
54
+ }
55
+ }
56
+ catch {
57
+ nodes.push({ label: "SAVINGS", status: "idle" });
58
+ }
59
+ // LOOPGUARD — thrash state
60
+ try {
61
+ const p = join(cwd, m.loopguard?.LOOPGUARD_LEDGER ?? ".mneme/loopguard/events.jsonl");
62
+ if (existsSync(p) && m.loopguard) {
63
+ const v = m.loopguard.detectStuck(m.loopguard.parseLedger(readFileSync(p, "utf8")));
64
+ nodes.unshift({ label: "LOOP", status: v.stuck ? "bad" : "ok" });
65
+ }
66
+ else {
67
+ nodes.unshift({ label: "LOOP", status: "idle" });
68
+ }
69
+ }
70
+ catch {
71
+ nodes.unshift({ label: "LOOP", status: "idle" });
72
+ }
73
+ // CORTEX — shared facts
74
+ try {
75
+ const p = join(cwd, ".mneme", "cortex", "store.json");
76
+ if (existsSync(p)) {
77
+ const store = JSON.parse(readFileSync(p, "utf8"));
78
+ const n = Array.isArray(store.entries) ? store.entries.length : 0;
79
+ nodes.push({ label: "CORTEX", status: n > 0 ? "ok" : "idle" });
80
+ }
81
+ else {
82
+ nodes.push({ label: "CORTEX", status: "idle" });
83
+ }
84
+ }
85
+ catch {
86
+ nodes.push({ label: "CORTEX", status: "idle" });
87
+ }
88
+ // TRUTH — always present (the savant identity)
89
+ nodes.unshift({ label: "TRUTH", status: "ok" });
90
+ return { state: { version: readVersion(), nodes, savingsSpark, headline: headline || undefined, signed: true } };
91
+ }
92
+ export function registerMapCommands(program) {
93
+ program
94
+ .command("map")
95
+ .alias("visual")
96
+ .description("🗺️ VISUAL KNOWLEDGE MAP — render Mneme's live signed state as a gorgeous terminal constellation (savings / loop / cortex / truth). Auto-adapts: truecolor gradients → 256-color → plain ASCII on a pipe/CI. Zero config.")
97
+ .option("--json", "emit the underlying state instead of the rendered frame.")
98
+ .option("--ascii", "force pure-ASCII output (no color, no Unicode).")
99
+ .action(async (opts) => {
100
+ const m = await core();
101
+ if (!m) {
102
+ writeText("✗ core unavailable");
103
+ process.exitCode = 1;
104
+ return;
105
+ }
106
+ const cwd = process.cwd();
107
+ const { state } = gatherState(m, cwd);
108
+ if (opts.json) {
109
+ writeJson(state);
110
+ return;
111
+ }
112
+ const env = opts.ascii ? { ...process.env, MNEME_NO_COLOR: "1", MNEME_ASCII: "1" } : process.env;
113
+ const caps = m.visual.detectCaps(env, Boolean(process.stdout.isTTY), process.stdout.columns);
114
+ writeText(m.visual.renderKnowledgeMap(state, caps));
115
+ });
116
+ }
117
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../../src/commands/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WA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,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;QACjG,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAyC,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACnI,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiJA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmgNvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkJA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAogNvD"}
package/dist/index.js CHANGED
@@ -78,6 +78,7 @@ import { registerAbsorbCommands } from "./commands/absorb.js";
78
78
  import { registerLoopguardCommands } from "./commands/loopguard.js";
79
79
  import { registerDistillCommands } from "./commands/distill.js";
80
80
  import { registerSavingsCommands } from "./commands/savings.js";
81
+ import { registerMapCommands } from "./commands/map.js";
81
82
  import { registerTrustCommands } from "./commands/trust.js";
82
83
  import { registerNuclearCommands } from "./commands/nuclear-cli.js";
83
84
  import { registerOvernightCommand } from "./commands/overnight.js";
@@ -4701,6 +4702,7 @@ export async function run(argv) {
4701
4702
  registerLoopguardCommands(program);
4702
4703
  registerDistillCommands(program);
4703
4704
  registerSavingsCommands(program);
4705
+ registerMapCommands(program);
4704
4706
  // ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
4705
4707
  registerTrustCommands(program);
4706
4708
  // ─── Wisdom reactor (v1.33.0) -- five nuclear-physics formulas as Mneme metrics