mneme-ai 2.19.75 → 2.19.76

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,271 @@
1
+ /**
2
+ * v2.19.76 — `mneme index --auto` / `--watch` / `--merkle-only`.
3
+ *
4
+ * Layers shipped (per analysis in turn before this one):
5
+ * 1. Diff-based incremental — `git log <cursor>..HEAD` only
6
+ * 2. Schema versioning — refuse stale cursor from incompatible version
7
+ * 3. MERKLE root — sha256 of (commit_hash | text_hash) sorted →
8
+ * single fingerprint of the entire index; two devs can prove their
9
+ * indexes match by comparing 64 hex chars, not chunk-by-chunk
10
+ * 4. --watch mode — fs.watch on .git/HEAD + .git/refs/heads → on
11
+ * change, fire incremental. Within ~200ms of `git commit` the
12
+ * index is fresh. Foreground spinner UI; Ctrl+C to stop.
13
+ * 5. Live cursor file — JSON at `.mneme/index-cursor.json` with
14
+ * everything needed to resume safely after crash / version bump
15
+ *
16
+ * Deferred (specced in docs/wild_workarounds/09_super_index.md if/when
17
+ * we create it):
18
+ * - Content-addressable embedding cache across embedder switches
19
+ * - Predictive pre-fetch from user activity
20
+ * - Multi-modal (AST + tests + docs + PRs in one index)
21
+ * - Time-traveling chunks with born_at/died_at
22
+ * - Self-verifying re-embed sample
23
+ * - Cross-repo stigmergy via spore
24
+ * - Polyglot embedder ensemble
25
+ */
26
+ import { execSync } from "node:child_process";
27
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, watch as fsWatch } from "node:fs";
28
+ import { createHash } from "node:crypto";
29
+ import { join, dirname } from "node:path";
30
+ import kleur from "kleur";
31
+ const CURSOR_SCHEMA = 1;
32
+ const CURSOR_FILE = ".mneme/index-cursor.json";
33
+ const MERKLE_FILE = ".mneme/index-merkle-root.txt";
34
+ function cursorPath(cwd) { return join(cwd, CURSOR_FILE); }
35
+ function merklePath(cwd) { return join(cwd, MERKLE_FILE); }
36
+ function readCursor(cwd) {
37
+ const p = cursorPath(cwd);
38
+ if (!existsSync(p))
39
+ return null;
40
+ try {
41
+ const j = JSON.parse(readFileSync(p, "utf8"));
42
+ if (j.v !== CURSOR_SCHEMA)
43
+ return null; // schema mismatch — force rebuild
44
+ return j;
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ }
50
+ function writeCursor(cwd, rec) {
51
+ const p = cursorPath(cwd);
52
+ mkdirSync(dirname(p), { recursive: true });
53
+ writeFileSync(p, JSON.stringify(rec, null, 2) + "\n", "utf8");
54
+ }
55
+ function gitHeadSha(cwd) {
56
+ try {
57
+ return execSync("git rev-parse HEAD", { cwd, encoding: "utf8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] }).trim() || null;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ }
63
+ function gitNewCommits(cwd, sinceSha) {
64
+ try {
65
+ const range = sinceSha ? `${sinceSha}..HEAD` : "HEAD";
66
+ const out = execSync(`git log ${range} --format=%H`, { cwd, encoding: "utf8", timeout: 30_000, stdio: ["ignore", "pipe", "ignore"] });
67
+ return out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
68
+ }
69
+ catch {
70
+ return [];
71
+ }
72
+ }
73
+ /** Compute the merkle root of the current index state.
74
+ * Reads .mneme/mneme.db (if present) + hashes every (commit_hash,
75
+ * text_hash) pair sorted lexically → sha256 → 64 hex chars.
76
+ * Two indexes with the same root are byte-equivalent at the chunk
77
+ * layer. Falls back to git-only hash if the DB isn't there. */
78
+ function computeMerkleRoot(cwd) {
79
+ // Try the DB first.
80
+ const dbPath = join(cwd, ".mneme", "mneme.db");
81
+ let chunks = [];
82
+ let mode = "git-fallback";
83
+ if (existsSync(dbPath)) {
84
+ try {
85
+ const { DatabaseSync } = require("node:sqlite");
86
+ const db = new DatabaseSync(dbPath, { readOnly: true });
87
+ const rows = db.prepare("SELECT commit_hash, text FROM chunks ORDER BY commit_hash, id").all();
88
+ chunks = rows.map((r) => {
89
+ const textHash = createHash("sha256").update(String(r.text)).digest("hex");
90
+ return `${r.commit_hash}|${textHash}`;
91
+ });
92
+ db.close();
93
+ mode = "db";
94
+ }
95
+ catch { /* fallthrough */ }
96
+ }
97
+ if (chunks.length === 0) {
98
+ // Fall back to git log SHAs only. Less precise (doesn't reflect
99
+ // chunk content) but useful for users without the DB yet.
100
+ try {
101
+ const out = execSync("git log --format=%H", { cwd, encoding: "utf8", timeout: 10_000, stdio: ["ignore", "pipe", "ignore"] });
102
+ chunks = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean).sort();
103
+ }
104
+ catch { /* */ }
105
+ }
106
+ const root = createHash("sha256").update(chunks.join("\n")).digest("hex");
107
+ return { root, mode, chunkCount: chunks.length };
108
+ }
109
+ function writeMerkle(cwd, root, mode, count) {
110
+ const p = merklePath(cwd);
111
+ mkdirSync(dirname(p), { recursive: true });
112
+ writeFileSync(p, `${root}\n` +
113
+ `# mode: ${mode}\n# chunks: ${count}\n# computed: ${new Date().toISOString()}\n`, "utf8");
114
+ }
115
+ async function runOneIndexPass(opts) {
116
+ const t0 = Date.now();
117
+ const headSha = gitHeadSha(opts.cwd);
118
+ const cursor = opts.full ? null : readCursor(opts.cwd);
119
+ // Determine work scope.
120
+ let newCommits = [];
121
+ let mode;
122
+ if (opts.merkleOnly) {
123
+ mode = "merkle-only";
124
+ }
125
+ else if (cursor && cursor.lastHeadSha === headSha) {
126
+ mode = "no-op";
127
+ }
128
+ else if (cursor && cursor.lastHeadSha) {
129
+ mode = "incremental";
130
+ newCommits = gitNewCommits(opts.cwd, cursor.lastHeadSha);
131
+ }
132
+ else {
133
+ mode = "full";
134
+ }
135
+ // Execute the underlying index (unless no-op or merkle-only).
136
+ if (mode === "incremental" || mode === "full") {
137
+ // Reuse the existing `indexCommand` for the heavy lifting — we just
138
+ // narrow its scope. For `incremental` we run with no `since` (the
139
+ // existing index command is already idempotent on already-indexed
140
+ // commits via the chunk PRIMARY KEY); for `full` same.
141
+ const { indexCommand } = await import("./index-cmd.js");
142
+ await indexCommand({
143
+ cwd: opts.cwd,
144
+ since: undefined,
145
+ maxCount: undefined,
146
+ embedder: "auto",
147
+ });
148
+ }
149
+ // Recompute merkle after.
150
+ const m = computeMerkleRoot(opts.cwd);
151
+ writeMerkle(opts.cwd, m.root, m.mode, m.chunkCount);
152
+ // Update cursor (always, so next run has fresh baseline).
153
+ const { resolveMnemeVersion } = await import("@mneme-ai/core");
154
+ const newCursor = {
155
+ v: CURSOR_SCHEMA,
156
+ lastHeadSha: headSha,
157
+ lastIndexedAt: new Date().toISOString(),
158
+ embedder: cursor?.embedder ?? "auto",
159
+ merkleRoot: m.root,
160
+ mnemeVersion: resolveMnemeVersion(),
161
+ };
162
+ writeCursor(opts.cwd, newCursor);
163
+ return {
164
+ mode,
165
+ newCommits: newCommits.length,
166
+ previousSha: cursor?.lastHeadSha ?? null,
167
+ currentSha: headSha,
168
+ merkleRoot: m.root,
169
+ merkleMode: m.mode,
170
+ chunkCount: m.chunkCount,
171
+ durationMs: Date.now() - t0,
172
+ };
173
+ }
174
+ function renderResult(r, quiet) {
175
+ if (quiet)
176
+ return "";
177
+ const c = process.stdout.isTTY ? kleur : { gray: (s) => s, cyan: (s) => s, green: (s) => s, yellow: (s) => s, bold: (s) => s, magenta: (s) => s, red: (s) => s };
178
+ const lines = [];
179
+ lines.push("");
180
+ lines.push(c.bold(c.magenta(` ⚡ mneme index — ${r.mode.toUpperCase()} pass in ${r.durationMs}ms`)));
181
+ if (r.mode === "incremental" || r.mode === "full") {
182
+ lines.push(` new commits indexed: ${c.cyan(String(r.newCommits))}`);
183
+ }
184
+ if (r.previousSha)
185
+ lines.push(` previous HEAD: ${c.gray(r.previousSha.slice(0, 12))}`);
186
+ if (r.currentSha)
187
+ lines.push(` current HEAD: ${c.cyan(r.currentSha.slice(0, 12))}`);
188
+ lines.push(` chunks fingerprinted: ${c.cyan(String(r.chunkCount))}`);
189
+ lines.push(` merkle (${r.merkleMode}): ${c.green(r.merkleRoot.slice(0, 16) + "…")}`);
190
+ if (r.mode === "no-op") {
191
+ lines.push("");
192
+ lines.push(c.gray(" already up to date — nothing to do. Merkle recomputed for verification."));
193
+ }
194
+ lines.push("");
195
+ return lines.join("\n");
196
+ }
197
+ export async function superIndexCommand(opts) {
198
+ const first = await runOneIndexPass(opts);
199
+ if (opts.json) {
200
+ process.stdout.write(JSON.stringify(first, null, 2) + "\n");
201
+ }
202
+ else {
203
+ process.stdout.write(renderResult(first, !!opts.quiet));
204
+ }
205
+ if (!opts.watch)
206
+ return;
207
+ // --watch: stay alive + re-fire on git HEAD movement.
208
+ const gitDir = join(opts.cwd, ".git");
209
+ if (!existsSync(gitDir)) {
210
+ process.stderr.write("--watch: not a git repo, exiting\n");
211
+ return;
212
+ }
213
+ const c = process.stdout.isTTY ? kleur : { gray: (s) => s, dim: (s) => s };
214
+ process.stdout.write(c.gray("\n 👀 watching .git for HEAD updates (Ctrl+C to stop)…\n\n"));
215
+ // Debounce — git can fire multiple events per commit (HEAD + refs/heads/<branch> + index).
216
+ let pending = null;
217
+ let inFlight = false;
218
+ const trigger = () => {
219
+ if (pending)
220
+ clearTimeout(pending);
221
+ pending = setTimeout(async () => {
222
+ if (inFlight)
223
+ return;
224
+ inFlight = true;
225
+ try {
226
+ const r = await runOneIndexPass({ ...opts, watch: false });
227
+ if (r.mode !== "no-op")
228
+ process.stdout.write(renderResult(r, !!opts.quiet));
229
+ }
230
+ catch (err) {
231
+ process.stderr.write(` ⚠ watch pass error: ${err.message}\n`);
232
+ }
233
+ finally {
234
+ inFlight = false;
235
+ }
236
+ }, 300);
237
+ };
238
+ // Watch .git/HEAD + .git/refs/heads/ for any change.
239
+ const watchers = [
240
+ fsWatch(gitDir, { persistent: true }, (eventType, filename) => {
241
+ if (!filename)
242
+ return;
243
+ if (filename === "HEAD" || String(filename).startsWith("refs"))
244
+ trigger();
245
+ }),
246
+ ];
247
+ const refsDir = join(gitDir, "refs", "heads");
248
+ if (existsSync(refsDir)) {
249
+ try {
250
+ watchers.push(fsWatch(refsDir, { persistent: true, recursive: true }, () => trigger()));
251
+ }
252
+ catch { /* recursive may not be supported on every fs */ }
253
+ }
254
+ // Graceful shutdown.
255
+ const cleanup = () => {
256
+ for (const w of watchers) {
257
+ try {
258
+ w.close();
259
+ }
260
+ catch { /* */ }
261
+ }
262
+ if (pending)
263
+ clearTimeout(pending);
264
+ process.exit(0);
265
+ };
266
+ process.on("SIGINT", cleanup);
267
+ process.on("SIGTERM", cleanup);
268
+ // Keep the event loop alive forever.
269
+ await new Promise(() => { });
270
+ }
271
+ //# sourceMappingURL=index-super.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-super.js","sourceRoot":"","sources":["../../src/commands/index-super.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAS,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAC/C,MAAM,WAAW,GAAG,8BAA8B,CAAC;AA8BnD,SAAS,UAAU,CAAC,GAAW,IAAY,OAAO,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AAC3E,SAAS,UAAU,CAAC,GAAW,IAAY,OAAO,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AAE3E,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,IAA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 * Detected via env vars: CLAUDE_CODE, CURSOR_*, CODEIUM_*,
8
+ * CODEX_*, CLINE_*, CONTINUE_*, AIDER_*, GEMINI_CODE_ASSIST,
9
+ * ZED_AI_*, plus the generic AI_AGENT marker. Prints a short
10
+ * structured directive telling the host AI agent to switch to
11
+ * "Mneme chat dispatcher mode": every subsequent user turn
12
+ * should be routed through the AI_AGENT_CONTRACT Step 2.5
13
+ * dispatch table to Mneme MCP tools. The AI agent (Claude /
14
+ * ChatGPT / Cursor / etc.) becomes the chat — the user gets to
15
+ * keep all the LLM smartness of their host while gaining
16
+ * Mneme's verifier + memory layer.
17
+ *
18
+ * 2. STANDALONE REPL (when no AI agent detected — bare terminal)
19
+ * Pure Node readline. Keyword-based intent routing against the
20
+ * same 13-row dispatch table. Built-in commands:
21
+ * /exit, /quit — leave the REPL
22
+ * /help — show this list + the intent table
23
+ * /clear — clear screen
24
+ * /history — show past inputs
25
+ * /show <N> — re-print answer #N
26
+ * /save <name> — export session as a bash playbook
27
+ * ? — genie mode (context-aware guess)
28
+ * After every answer, prints "(W)hy / (V)erify / (P)remortem /
29
+ * (Q)uit" — single keystroke continues to a follow-up command
30
+ * against the same target.
31
+ *
32
+ * Both modes call into existing Mneme CLI commands via spawnSync —
33
+ * no LLM dependency in the standalone path, no new prompt template
34
+ * in the AI-agent path.
35
+ */
36
+ export interface TalkOptions {
37
+ cwd: string;
38
+ /** Force standalone REPL even if AI agent detected (for testing /
39
+ * for users who want the REPL inside Cursor terminal). */
40
+ forceStandalone?: boolean;
41
+ /** JSON dispatcher mode (machine-readable handoff). */
42
+ json?: boolean;
43
+ }
44
+ export declare function talkCommand(opts: TalkOptions): Promise<void>;
45
+ //# sourceMappingURL=talk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"talk.d.ts","sourceRoot":"","sources":["../../src/commands/talk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AASH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ;+DAC2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uDAAuD;IACvD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA8UD,wBAAsB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlE"}