mneme-ai 2.108.0 → 2.109.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,11 @@
1
+ /**
2
+ * `mneme absorb` (v2.109.0) — pipe a command's output in; Mneme deterministically
3
+ * extracts {intent, error-class, excerpt} and files it as a SIGNED Cortex fact
4
+ * (recall by any agent). If it's an error and you pass --fix, it also teaches
5
+ * the Shell Autopilot — closing the loop: absorb (learn) → autopilot (suggest).
6
+ *
7
+ * mycmd 2>&1 | mneme absorb --cmd "mycmd" --code $?
8
+ */
9
+ import type { Command } from "commander";
10
+ export declare function registerAbsorbCommands(program: Command): void;
11
+ //# sourceMappingURL=absorb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"absorb.d.ts","sourceRoot":"","sources":["../../src/commands/absorb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8BzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkC7D"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * `mneme absorb` (v2.109.0) — pipe a command's output in; Mneme deterministically
3
+ * extracts {intent, error-class, excerpt} and files it as a SIGNED Cortex fact
4
+ * (recall by any agent). If it's an error and you pass --fix, it also teaches
5
+ * the Shell Autopilot — closing the loop: absorb (learn) → autopilot (suggest).
6
+ *
7
+ * mycmd 2>&1 | mneme absorb --cmd "mycmd" --code $?
8
+ */
9
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ function writeJson(p) { process.stdout.write(JSON.stringify(p, null, 2) + "\n"); }
12
+ function writeText(l) { process.stdout.write(l + "\n"); }
13
+ async function core() {
14
+ try {
15
+ const c = (await import("@mneme-ai/core"));
16
+ if (c.logpipe && c.cortex)
17
+ return c;
18
+ }
19
+ catch { /* */ }
20
+ return null;
21
+ }
22
+ function cortexPath(cwd) { return join(cwd, ".mneme", "cortex", "store.json"); }
23
+ function readStdin() {
24
+ return new Promise((resolve) => {
25
+ if (process.stdin.isTTY)
26
+ return resolve("");
27
+ let data = "";
28
+ let done = false;
29
+ const finish = () => { if (!done) {
30
+ done = true;
31
+ resolve(data);
32
+ } };
33
+ process.stdin.setEncoding("utf8");
34
+ process.stdin.on("data", (c) => { data += c; if (data.length > 2_000_000)
35
+ finish(); });
36
+ process.stdin.on("end", finish);
37
+ process.stdin.on("error", finish);
38
+ setTimeout(finish, 4000); // never hang
39
+ });
40
+ }
41
+ export function registerAbsorbCommands(program) {
42
+ program
43
+ .command("absorb")
44
+ .description("📥 LOGPIPE — pipe a command's output in; Mneme extracts {intent, error, fix} deterministically and files it as a SIGNED, recallable Cortex fact (cross-agent). With --fix it also teaches the Shell Autopilot (absorb→autopilot loop). Usage: `mycmd 2>&1 | mneme absorb --cmd \"mycmd\" --code $?`")
45
+ .option("--cmd <c>", "the command that produced the output", "")
46
+ .option("--code <n>", "exit code (else inferred from output)", (v) => parseInt(v, 10))
47
+ .option("--fix <f>", "the command that FIXED this error (teaches the autopilot)")
48
+ .option("--text <t>", "output text inline (else read from stdin)")
49
+ .option("--agent <a>", "agent id", "absorb")
50
+ .option("--json", "JSON output.")
51
+ .action(async (opts) => {
52
+ const m = await core();
53
+ if (!m) {
54
+ writeText("✗ core unavailable");
55
+ process.exitCode = 1;
56
+ return;
57
+ }
58
+ const cwd = process.cwd();
59
+ const output = typeof opts.text === "string" ? opts.text : await readStdin();
60
+ const entry = m.logpipe.extractLogEntry(opts.cmd ?? "", output, typeof opts.code === "number" ? opts.code : NaN);
61
+ const f = m.logpipe.formatForCortex(entry);
62
+ // store as a signed cortex fact
63
+ let store = { v: 1, entries: [] };
64
+ try {
65
+ if (existsSync(cortexPath(cwd)))
66
+ store = JSON.parse(readFileSync(cortexPath(cwd), "utf8"));
67
+ }
68
+ catch { /* */ }
69
+ const out = m.cortex.contribute(cwd, store, { agent: opts.agent ?? "absorb", key: f.key, value: f.value, kind: f.kind }, Date.now());
70
+ store = out.store;
71
+ // close the loop: an error + a known fix → teach the autopilot
72
+ let taught = false;
73
+ if (entry.hadError && opts.fix) {
74
+ const rk = m.shellAutopilot.recoveryKey(entry.signature);
75
+ const o2 = m.cortex.contribute(cwd, store, { agent: opts.agent ?? "absorb", key: rk, value: opts.fix, kind: "fact" }, Date.now(), { update: true });
76
+ store = o2.store;
77
+ taught = true;
78
+ }
79
+ try {
80
+ const dir = join(cwd, ".mneme", "cortex");
81
+ if (!existsSync(dir))
82
+ mkdirSync(dir, { recursive: true });
83
+ writeFileSync(cortexPath(cwd), JSON.stringify(store, null, 2));
84
+ }
85
+ catch { /* */ }
86
+ if (opts.json) {
87
+ writeJson({ entry, cortex: out.result.verdict, taughtAutopilot: taught });
88
+ return;
89
+ }
90
+ writeText(`📥 ${entry.intent}`);
91
+ if (entry.hadError)
92
+ writeText(` error[${entry.errorClass}]: ${entry.excerpt}`);
93
+ writeText(` → cortex (${out.result.verdict})${taught ? " · taught the autopilot a recovery" : ""}`);
94
+ });
95
+ }
96
+ //# sourceMappingURL=absorb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"absorb.js","sourceRoot":"","sources":["../../src/commands/absorb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,SAAS,SAAS,CAAC,CAAU,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACjG,SAAS,SAAS,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAA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ources":["../src/index.ts"],"names":[],"mappings":"AA8IA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAw+MvD"}
package/dist/index.js CHANGED
@@ -74,6 +74,7 @@ import { registerCortexCommands } from "./commands/cortex.js";
74
74
  import { registerShellCommands } from "./commands/shell.js";
75
75
  import { registerDigCommands } from "./commands/dig.js";
76
76
  import { registerEntropyCommands } from "./commands/entropy.js";
77
+ import { registerAbsorbCommands } from "./commands/absorb.js";
77
78
  import { registerTrustCommands } from "./commands/trust.js";
78
79
  import { registerNuclearCommands } from "./commands/nuclear-cli.js";
79
80
  import { registerOvernightCommand } from "./commands/overnight.js";
@@ -4693,6 +4694,7 @@ export async function run(argv) {
4693
4694
  registerShellCommands(program);
4694
4695
  registerDigCommands(program);
4695
4696
  registerEntropyCommands(program);
4697
+ registerAbsorbCommands(program);
4696
4698
  // ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
4697
4699
  registerTrustCommands(program);
4698
4700
  // ─── Wisdom reactor (v1.33.0) -- five nuclear-physics formulas as Mneme metrics