mneme-ai 2.77.0 → 2.78.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,18 @@
1
+ /**
2
+ * v2.78.0 — `mneme immune selftest`
3
+ *
4
+ * WORM-CANARY for humans. Two checks:
5
+ * 1. Mneme's OWN output: render a worst-case version-mismatch agent block
6
+ * (one carrying an upgrade autoAction) and prove it has zero worm
7
+ * signatures — Mneme informs, never commands.
8
+ * 2. This repo's agent files (CLAUDE.md / AGENTS.md / .cursorrules /
9
+ * .windsurfrules): scan the live Mneme block (or whole file) for any
10
+ * worm directive that may have been written by an OLDER Mneme.
11
+ *
12
+ * Exit 0 when clean, 1 when a worm directive is found.
13
+ */
14
+ export declare function immuneCommand(opts: {
15
+ cwd: string;
16
+ json?: boolean;
17
+ }): Promise<number>;
18
+ //# sourceMappingURL=immune.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immune.d.ts","sourceRoot":"","sources":["../../src/commands/immune.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,wBAAsB,aAAa,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAgE1F"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * v2.78.0 — `mneme immune selftest`
3
+ *
4
+ * WORM-CANARY for humans. Two checks:
5
+ * 1. Mneme's OWN output: render a worst-case version-mismatch agent block
6
+ * (one carrying an upgrade autoAction) and prove it has zero worm
7
+ * signatures — Mneme informs, never commands.
8
+ * 2. This repo's agent files (CLAUDE.md / AGENTS.md / .cursorrules /
9
+ * .windsurfrules): scan the live Mneme block (or whole file) for any
10
+ * worm directive that may have been written by an OLDER Mneme.
11
+ *
12
+ * Exit 0 when clean, 1 when a worm directive is found.
13
+ */
14
+ import { writeSync } from "node:fs";
15
+ import * as core from "@mneme-ai/core";
16
+ const AGENT_FILES = ["CLAUDE.md", "AGENTS.md", ".cursorrules", ".windsurfrules"];
17
+ // fd-1 synchronous write — survives the immediate process.exit() the action
18
+ // handler calls (an async stdout pipe would otherwise be truncated on Windows).
19
+ function out(s) {
20
+ try {
21
+ writeSync(1, s);
22
+ }
23
+ catch {
24
+ process.stdout.write(s);
25
+ }
26
+ }
27
+ export async function immuneCommand(opts) {
28
+ const { scanForWormSignatures, KNOWN_WORM_PAYLOAD } = core.immune;
29
+ const { renderMnemeBlock, readMnemeBlock } = core.notifier;
30
+ // Check 1 — Mneme's own worst-case output.
31
+ const ownBlock = renderMnemeBlock({
32
+ id: "version-up-to-date",
33
+ severity: "info",
34
+ title: "Mneme update available",
35
+ body: "installed v0.0.0, npm latest v9.9.9. The user can run `mneme upgrade` when convenient.",
36
+ autoAction: { tool: "mneme.system.upgrade", args: { mode: "install", force: true } },
37
+ });
38
+ const ownScan = scanForWormSignatures(ownBlock);
39
+ const control = scanForWormSignatures(KNOWN_WORM_PAYLOAD); // positive control
40
+ // Check 2 — this repo's persistent agent files.
41
+ const fileScans = [];
42
+ for (const f of AGENT_FILES) {
43
+ let block = null;
44
+ try {
45
+ block = readMnemeBlock(opts.cwd, f);
46
+ }
47
+ catch {
48
+ block = null;
49
+ }
50
+ if (block === null)
51
+ continue; // file or Mneme block absent — nothing to scan
52
+ const scan = scanForWormSignatures(block);
53
+ fileScans.push({
54
+ file: f,
55
+ clean: scan.clean,
56
+ findings: scan.findings.length,
57
+ detail: scan.findings.map((x) => `${x.kind}: "${x.match}"`),
58
+ });
59
+ }
60
+ const dirtyFiles = fileScans.filter((s) => !s.clean);
61
+ const ok = ownScan.clean && !control.clean && dirtyFiles.length === 0;
62
+ if (opts.json) {
63
+ out(JSON.stringify({
64
+ ok,
65
+ ownOutputClean: ownScan.clean,
66
+ canaryCatchesKnownPayload: !control.clean,
67
+ ownFindings: ownScan.findings,
68
+ files: fileScans,
69
+ }, null, 2) + "\n");
70
+ return ok ? 0 : 1;
71
+ }
72
+ const lines = [];
73
+ lines.push("🧬 MNEME IMMUNE SELFTEST — WORM-CANARY");
74
+ lines.push("");
75
+ lines.push(` ${ownScan.clean ? "🟢" : "🔴"} Mneme's own agent-file output: ${ownScan.clean ? "no worm signatures (informs, never commands)" : `${ownScan.findings.length} signature(s)!`}`);
76
+ for (const f of ownScan.findings)
77
+ lines.push(` └─ ${f.kind}: "${f.match}"`);
78
+ lines.push(` ${!control.clean ? "🟢" : "🔴"} Canary self-test: ${!control.clean ? "catches the known pre-v2.78 worm payload (positive control)" : "FAILED to catch the known payload — canary is broken!"}`);
79
+ if (fileScans.length === 0) {
80
+ lines.push(" · No Mneme blocks found in this repo's agent files (nothing to scan).");
81
+ }
82
+ else {
83
+ for (const s of fileScans) {
84
+ lines.push(` ${s.clean ? "🟢" : "🔴"} ${s.file}: ${s.clean ? "clean" : `${s.findings} worm signature(s)!`}`);
85
+ for (const d of s.detail)
86
+ lines.push(` └─ ${d}`);
87
+ }
88
+ }
89
+ lines.push("");
90
+ lines.push(ok
91
+ ? " ✅ CLEAN — Mneme is not a worm. It states version availability as informational context; upgrades are user-initiated only."
92
+ : " ❌ WORM DIRECTIVE present — see above. (If a repo file is dirty, an OLDER Mneme wrote it; run `mneme upgrade` then re-run this.)");
93
+ out(lines.join("\n") + "\n");
94
+ return ok ? 0 : 1;
95
+ }
96
+ //# sourceMappingURL=immune.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immune.js","sourceRoot":"","sources":["../../src/commands/immune.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAEjF,4EAA4E;AAC5E,gFAAgF;AAChF,SAAS,GAAG,CAAC,CAAS;IACp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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuIA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwyMvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuIA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwzMvD"}
package/dist/index.js CHANGED
@@ -4166,6 +4166,21 @@ export async function run(argv) {
4166
4166
  const { uiCommand } = await import("./commands/ui.js");
4167
4167
  await uiCommand({ cwd: process.cwd(), version: getVersion() });
4168
4168
  });
4169
+ // v2.78.0 — WORM-CANARY selftest. Prove Mneme is not an AI worm: its
4170
+ // agent-file output carries no imperative directives, and any worm payload
4171
+ // an OLDER Mneme may have written into this repo's CLAUDE.md/etc is detected.
4172
+ program
4173
+ .command("immune <action>")
4174
+ .description("🧬 IMMUNE — `mneme immune selftest` runs the WORM-CANARY: proves Mneme never injects a self-upgrade/self-propagation directive into AI agent files (CLAUDE.md/AGENTS.md/.cursorrules/.windsurfrules), and scans this repo's files for any worm payload left by an older Mneme.")
4175
+ .option("--json", "machine-readable output", false)
4176
+ .action(async (action, opts) => {
4177
+ if (action !== "selftest") {
4178
+ ui.error(`Unknown immune action "${action}". Try: selftest`);
4179
+ process.exit(2);
4180
+ }
4181
+ const { immuneCommand } = await import("./commands/immune.js");
4182
+ process.exit(await immuneCommand({ cwd: process.cwd(), json: !!opts.json }));
4183
+ });
4169
4184
  program
4170
4185
  .command("atlas")
4171
4186
  .description("🗺 ATLAS HELP — six-layer discovery (TASTE · BLOOM · HOT · TAGS · INTENT · FULL). AI agents read 200 bytes here instead of 14 KB from --help.")