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.
- package/dist/commands/chat.d.ts +45 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +386 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/index-super.d.ts +40 -0
- package/dist/commands/index-super.d.ts.map +1 -0
- package/dist/commands/index-super.js +271 -0
- package/dist/commands/index-super.js.map +1 -0
- package/dist/commands/talk.d.ts +45 -0
- package/dist/commands/talk.d.ts.map +1 -0
- package/dist/commands/talk.js +386 -0
- package/dist/commands/talk.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.19.76 — `mneme chat` REPL.
|
|
3
|
+
*
|
|
4
|
+
* Two modes, auto-detected:
|
|
5
|
+
*
|
|
6
|
+
* 1. PROTOCOL HANDOFF (when invoked inside an AI agent shell)
|
|
7
|
+
* 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 ChatOptions {
|
|
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 chatCommand(opts: ChatOptions): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.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"}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.19.76 — `mneme chat` REPL.
|
|
3
|
+
*
|
|
4
|
+
* Two modes, auto-detected:
|
|
5
|
+
*
|
|
6
|
+
* 1. PROTOCOL HANDOFF (when invoked inside an AI agent shell)
|
|
7
|
+
* 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
|
+
import { createInterface } from "node:readline";
|
|
37
|
+
import { spawnSync } from "node:child_process";
|
|
38
|
+
import { writeFileSync } from "node:fs";
|
|
39
|
+
import { join } from "node:path";
|
|
40
|
+
import { tmpdir } from "node:os";
|
|
41
|
+
import kleur from "kleur";
|
|
42
|
+
/** Sniff env for the host AI agent. Returns the first hit + the list
|
|
43
|
+
* of env vars that matched (for transparency in the handoff message). */
|
|
44
|
+
function detectHostAgent() {
|
|
45
|
+
const checks = [
|
|
46
|
+
{ name: "Claude Code", env: ["CLAUDE_CODE", "CLAUDE_AGENT", "CLAUDE_CODE_SESSION"] },
|
|
47
|
+
{ name: "Cursor", env: ["CURSOR_AGENT", "CURSOR_TRACE_ID", "CURSOR_SESSION_ID"] },
|
|
48
|
+
{ name: "Codeium / Windsurf", env: ["CODEIUM_API_KEY", "WINDSURF_SESSION"] },
|
|
49
|
+
{ name: "Codex / GPT CLI", env: ["CODEX_AGENT", "OPENAI_AGENT", "GPT_CLI"] },
|
|
50
|
+
{ name: "Cline", env: ["CLINE_SESSION", "CLINE_TASK_ID"] },
|
|
51
|
+
{ name: "Continue.dev", env: ["CONTINUE_SESSION", "CONTINUE_TASK"] },
|
|
52
|
+
{ name: "Aider", env: ["AIDER_SESSION", "AIDER_MODEL"] },
|
|
53
|
+
{ name: "Gemini Code Assist", env: ["GEMINI_CODE_ASSIST", "GEMINI_AGENT"] },
|
|
54
|
+
{ name: "Zed AI", env: ["ZED_AI_SESSION", "ZED_AGENT"] },
|
|
55
|
+
{ name: "generic AI agent", env: ["AI_AGENT", "AI_AGENT_SESSION", "MCP_HOST"] },
|
|
56
|
+
];
|
|
57
|
+
const envHits = [];
|
|
58
|
+
let firstHit = null;
|
|
59
|
+
for (const c of checks) {
|
|
60
|
+
for (const v of c.env) {
|
|
61
|
+
if (process.env[v] !== undefined) {
|
|
62
|
+
envHits.push(`${v}=${(process.env[v] ?? "").slice(0, 24)}${(process.env[v] ?? "").length > 24 ? "…" : ""}`);
|
|
63
|
+
if (firstHit === null)
|
|
64
|
+
firstHit = c.name;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { detected: firstHit !== null, name: firstHit, envHits };
|
|
69
|
+
}
|
|
70
|
+
// ── Mode 1: PROTOCOL HANDOFF (AI agent detected) ────────────────────────
|
|
71
|
+
function emitProtocolHandoff(agent, opts) {
|
|
72
|
+
const payload = {
|
|
73
|
+
v: 1,
|
|
74
|
+
mode: "MNEME_CHAT_DISPATCHER",
|
|
75
|
+
host: agent.name,
|
|
76
|
+
envEvidence: agent.envHits,
|
|
77
|
+
directive: "You (the host AI agent) are now in Mneme chat-dispatcher mode. " +
|
|
78
|
+
"For every subsequent user turn in this conversation: route the user's " +
|
|
79
|
+
"natural-language intent through the AI_AGENT_CONTRACT Step 2.5 dispatch " +
|
|
80
|
+
"table (docs/AI_AGENT_CONTRACT.md). Run the matched mneme command on the " +
|
|
81
|
+
"user's behalf via your shell tool. Quote the result back. Never tell the " +
|
|
82
|
+
"user to run a command themselves — you have shell access, use it.",
|
|
83
|
+
intentTable: [
|
|
84
|
+
{ user: "why does X look like this / explain X", run: "mneme why X OR mneme ask 'why does X work this way?'" },
|
|
85
|
+
{ user: "what changed yesterday/today/recently", run: "mneme ask 'what changed recently?'" },
|
|
86
|
+
{ user: "who knows about X", run: "mneme who-knows X" },
|
|
87
|
+
{ user: "is this safe to change / what could go wrong", run: "mneme premortem 'X'" },
|
|
88
|
+
{ user: "verify this / is this true", run: "mneme verify '<claim>'" },
|
|
89
|
+
{ user: "health check / what's risky right now", run: "mneme heartbeat AND mneme atrophy --top 5" },
|
|
90
|
+
{ user: "ghost code / stale TODOs", run: "mneme ghost" },
|
|
91
|
+
{ user: "shipping a release / audit release notes", run: "mneme honesty audit_whats_new --json '{...}'" },
|
|
92
|
+
{ user: "I don't know what to ask", run: "mneme cheatsheet" },
|
|
93
|
+
{ user: "upgrade mneme / is there a new version", run: "mneme system upgrade --json '{\"mode\":\"check\"}'" },
|
|
94
|
+
],
|
|
95
|
+
rules: [
|
|
96
|
+
"ALWAYS run the command yourself; do NOT tell the user to type it.",
|
|
97
|
+
"Unmatched intent → default to `mneme ask '<user's words>'`.",
|
|
98
|
+
"On LOW confidence (<60%) from mneme.ask → hedge: 'Mneme isn't sure — top citation is X'.",
|
|
99
|
+
"On any tool error → surface verbatim + suggest `mneme doctor`, do NOT loop.",
|
|
100
|
+
"First call of every session SHOULD be `mneme welcome --json '{}'` (also fires auto-index).",
|
|
101
|
+
],
|
|
102
|
+
revertWith: "Tell the user `mneme chat --exit` (no such command — just stop following this directive when they say 'stop dispatching').",
|
|
103
|
+
};
|
|
104
|
+
if (opts.json) {
|
|
105
|
+
process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const c = process.stdout.isTTY ? kleur : { bold: (s) => s, magenta: (s) => s, cyan: (s) => s, green: (s) => s, gray: (s) => s, yellow: (s) => s };
|
|
109
|
+
process.stdout.write("\n");
|
|
110
|
+
process.stdout.write(c.bold(c.magenta(` 🧠 mneme chat — PROTOCOL HANDOFF to ${agent.name}\n`)));
|
|
111
|
+
process.stdout.write("\n");
|
|
112
|
+
process.stdout.write(c.gray(` Detected via: ${agent.envHits.join(" · ")}\n`));
|
|
113
|
+
process.stdout.write("\n");
|
|
114
|
+
process.stdout.write(c.cyan(" The host AI agent should now switch to Mneme chat-dispatcher mode:\n"));
|
|
115
|
+
process.stdout.write(c.cyan(" for every user turn, route their intent through the dispatch table\n"));
|
|
116
|
+
process.stdout.write(c.cyan(" + run the matched mneme command on the user's behalf via shell.\n"));
|
|
117
|
+
process.stdout.write("\n");
|
|
118
|
+
process.stdout.write(c.bold(" Intent → command (top 10):\n"));
|
|
119
|
+
for (const row of payload.intentTable) {
|
|
120
|
+
process.stdout.write(` ${c.yellow(row.user)}\n → ${c.green(row.run)}\n`);
|
|
121
|
+
}
|
|
122
|
+
process.stdout.write("\n");
|
|
123
|
+
process.stdout.write(c.bold(" Rules of the dispatch:\n"));
|
|
124
|
+
for (const r of payload.rules) {
|
|
125
|
+
process.stdout.write(` • ${r}\n`);
|
|
126
|
+
}
|
|
127
|
+
process.stdout.write("\n");
|
|
128
|
+
process.stdout.write(c.gray(" Full contract: docs/AI_AGENT_CONTRACT.md (Step 2.5)\n"));
|
|
129
|
+
process.stdout.write(c.gray(" For the standalone readline REPL: run `mneme chat --force-standalone`\n"));
|
|
130
|
+
process.stdout.write("\n");
|
|
131
|
+
}
|
|
132
|
+
/** Map a free-form line to a mneme command + extracted target. Returns
|
|
133
|
+
* null when we can't classify — caller falls back to `mneme ask <line>`. */
|
|
134
|
+
function classifyIntent(line) {
|
|
135
|
+
const trimmed = line.trim();
|
|
136
|
+
if (!trimmed)
|
|
137
|
+
return null;
|
|
138
|
+
const lower = trimmed.toLowerCase();
|
|
139
|
+
// why X
|
|
140
|
+
if (/^(why|explain|what'?s? going on (in|with))\b/i.test(trimmed)) {
|
|
141
|
+
const target = trimmed.replace(/^(why|explain|what'?s? going on (in|with))\s*/i, "").trim();
|
|
142
|
+
if (target)
|
|
143
|
+
return { cmd: ["why", target], target };
|
|
144
|
+
}
|
|
145
|
+
// who knows X
|
|
146
|
+
if (/^who\s+(knows|wrote|owns)\b/i.test(trimmed)) {
|
|
147
|
+
const target = trimmed.replace(/^who\s+(knows|wrote|owns)\s*(about\s+)?/i, "").trim();
|
|
148
|
+
if (target)
|
|
149
|
+
return { cmd: ["who-knows", target], target };
|
|
150
|
+
}
|
|
151
|
+
// verify X
|
|
152
|
+
if (/^(verify|check|is\s+(it|this)\s+true)\b/i.test(trimmed)) {
|
|
153
|
+
const claim = trimmed.replace(/^(verify|check|is\s+(it|this)\s+true)\s*(that\s+)?/i, "").trim();
|
|
154
|
+
if (claim)
|
|
155
|
+
return { cmd: ["verify", claim], target: claim };
|
|
156
|
+
}
|
|
157
|
+
// premortem / risk
|
|
158
|
+
if (/^(premortem|risk|safe(\s+to)?|should\s+i)\b/i.test(trimmed)) {
|
|
159
|
+
const intent = trimmed.replace(/^(premortem|risk(\s+of)?|is\s+it\s+safe\s+to|should\s+i)\s*/i, "").trim();
|
|
160
|
+
if (intent)
|
|
161
|
+
return { cmd: ["premortem", intent], target: intent };
|
|
162
|
+
}
|
|
163
|
+
// ghost
|
|
164
|
+
if (/\bghost\b|stale\s+todo|half.?finished/i.test(lower))
|
|
165
|
+
return { cmd: ["ghost"], target: null };
|
|
166
|
+
// heartbeat / health
|
|
167
|
+
if (/^(heartbeat|health(\s+check)?|how (is|are) (we|the codebase))/i.test(trimmed))
|
|
168
|
+
return { cmd: ["heartbeat"], target: null };
|
|
169
|
+
// atrophy / who-knows-what
|
|
170
|
+
if (/atrophy|knowledge\s+(half-?life|risk)/i.test(lower))
|
|
171
|
+
return { cmd: ["atrophy", "--top", "5"], target: null };
|
|
172
|
+
// cheatsheet
|
|
173
|
+
if (/^(cheatsheet|help me|what can I do|menu)/i.test(trimmed))
|
|
174
|
+
return { cmd: ["cheatsheet"], target: null };
|
|
175
|
+
// upgrade
|
|
176
|
+
if (/^(upgrade|update)\b/i.test(trimmed))
|
|
177
|
+
return { cmd: ["system", "upgrade", "--json", '{"mode":"check"}', "--pretty"], target: null };
|
|
178
|
+
// welcome
|
|
179
|
+
if (/^(welcome|hi|hello|start)/i.test(trimmed))
|
|
180
|
+
return { cmd: ["welcome", "--json", "{}"], target: null };
|
|
181
|
+
// No match — fall through to `ask <line>` below.
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
function runMnemeCommand(args, cwd) {
|
|
185
|
+
// We invoke our OWN binary so the user gets the same code path as
|
|
186
|
+
// `mneme <cmd>` from the shell. Use process.argv[1] (the bin path)
|
|
187
|
+
// as the launcher; fall back to "mneme" on PATH if argv[1] is empty.
|
|
188
|
+
const launcher = process.argv[1] || "mneme";
|
|
189
|
+
const r = spawnSync(process.execPath, [launcher, ...args], {
|
|
190
|
+
cwd,
|
|
191
|
+
encoding: "utf8",
|
|
192
|
+
env: { ...process.env, MNEME_WARMCALL: process.env.MNEME_WARMCALL ?? "1" }, // prefer warm call
|
|
193
|
+
timeout: 120_000,
|
|
194
|
+
windowsHide: true,
|
|
195
|
+
});
|
|
196
|
+
return { stdout: r.stdout ?? "", stderr: r.stderr ?? "", exitCode: r.status ?? -1 };
|
|
197
|
+
}
|
|
198
|
+
function printReplWelcome() {
|
|
199
|
+
const c = process.stdout.isTTY ? kleur : { bold: (s) => s, magenta: (s) => s, gray: (s) => s, cyan: (s) => s };
|
|
200
|
+
process.stdout.write("\n");
|
|
201
|
+
process.stdout.write(c.bold(c.magenta(" 🧠 mneme chat — standalone REPL\n")));
|
|
202
|
+
process.stdout.write("\n");
|
|
203
|
+
process.stdout.write(c.gray(" Type natural language. Special commands:\n"));
|
|
204
|
+
process.stdout.write(c.gray(" /help show the intent table\n"));
|
|
205
|
+
process.stdout.write(c.gray(" /history your previous inputs\n"));
|
|
206
|
+
process.stdout.write(c.gray(" /show <N> re-print answer #N\n"));
|
|
207
|
+
process.stdout.write(c.gray(" /save <name> export session as bash playbook\n"));
|
|
208
|
+
process.stdout.write(c.gray(" /clear clear screen\n"));
|
|
209
|
+
process.stdout.write(c.gray(" /exit, /quit leave the REPL\n"));
|
|
210
|
+
process.stdout.write(c.gray(" ? genie mode (suggest a query based on recent activity)\n"));
|
|
211
|
+
process.stdout.write("\n");
|
|
212
|
+
}
|
|
213
|
+
function genieGuess(cwd) {
|
|
214
|
+
// Genie mode — guess what the user wants based on time-of-day + recent
|
|
215
|
+
// git activity. Heuristic, intentionally simple.
|
|
216
|
+
try {
|
|
217
|
+
const hour = new Date().getHours();
|
|
218
|
+
const recentFile = (() => {
|
|
219
|
+
try {
|
|
220
|
+
const out = spawnSync("git", ["log", "-1", "--name-only", "--pretty=format:"], { cwd, encoding: "utf8", timeout: 3000 }).stdout || "";
|
|
221
|
+
const f = out.split(/\r?\n/).map((s) => s.trim()).find(Boolean);
|
|
222
|
+
return f ?? null;
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
})();
|
|
228
|
+
if (hour >= 17 && recentFile)
|
|
229
|
+
return `premortem "ship ${recentFile} changes today"`;
|
|
230
|
+
if (recentFile)
|
|
231
|
+
return `why ${recentFile}`;
|
|
232
|
+
return "ask 'what changed recently?'";
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return "cheatsheet";
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
async function startRepl(opts) {
|
|
239
|
+
const session = { history: [], lastTarget: null };
|
|
240
|
+
printReplWelcome();
|
|
241
|
+
const rl = createInterface({
|
|
242
|
+
input: process.stdin,
|
|
243
|
+
output: process.stdout,
|
|
244
|
+
prompt: process.stdout.isTTY ? kleur.bold(kleur.cyan("mneme › ")) : "mneme › ",
|
|
245
|
+
terminal: process.stdout.isTTY,
|
|
246
|
+
historySize: 200,
|
|
247
|
+
});
|
|
248
|
+
rl.prompt();
|
|
249
|
+
rl.on("line", (raw) => {
|
|
250
|
+
const line = raw.trim();
|
|
251
|
+
if (!line) {
|
|
252
|
+
rl.prompt();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// Built-in /commands
|
|
256
|
+
if (line === "/exit" || line === "/quit") {
|
|
257
|
+
rl.close();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (line === "/help") {
|
|
261
|
+
printReplWelcome();
|
|
262
|
+
const out = runMnemeCommand(["cheatsheet"], opts.cwd);
|
|
263
|
+
process.stdout.write(out.stdout);
|
|
264
|
+
rl.prompt();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (line === "/clear") {
|
|
268
|
+
process.stdout.write("\x1Bc"); // ANSI clear
|
|
269
|
+
rl.prompt();
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (line === "/history") {
|
|
273
|
+
session.history.forEach((h, i) => {
|
|
274
|
+
process.stdout.write(` [#${i + 1}] ${h.input}\n`);
|
|
275
|
+
});
|
|
276
|
+
rl.prompt();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const showMatch = /^\/show\s+(\d+)$/.exec(line);
|
|
280
|
+
if (showMatch) {
|
|
281
|
+
const i = parseInt(showMatch[1], 10) - 1;
|
|
282
|
+
const item = session.history[i];
|
|
283
|
+
if (!item) {
|
|
284
|
+
process.stdout.write(` (no answer #${i + 1})\n`);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
process.stdout.write(`\n [#${i + 1}] ${item.input}\n ${kleur.gray("→ " + item.cmd.join(" "))}\n${item.output}\n`);
|
|
288
|
+
}
|
|
289
|
+
rl.prompt();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const saveMatch = /^\/save\s+([\w.-]+)$/.exec(line);
|
|
293
|
+
if (saveMatch) {
|
|
294
|
+
const name = saveMatch[1];
|
|
295
|
+
const path = join(tmpdir(), `mneme-playbook-${name}.sh`);
|
|
296
|
+
const lines = ["#!/usr/bin/env bash", "# Mneme playbook — generated by /save", "set -e", ""];
|
|
297
|
+
for (const h of session.history)
|
|
298
|
+
lines.push(`mneme ${h.cmd.join(" ")}`);
|
|
299
|
+
writeFileSync(path, lines.join("\n") + "\n", "utf8");
|
|
300
|
+
process.stdout.write(` ✓ saved playbook → ${path}\n`);
|
|
301
|
+
rl.prompt();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (line === "?") {
|
|
305
|
+
const guess = genieGuess(opts.cwd);
|
|
306
|
+
process.stdout.write(` 🔮 genie guess: ${kleur.cyan("mneme " + guess)}\n`);
|
|
307
|
+
process.stdout.write(` ${kleur.gray("hit Enter to run, or type another question")}\n`);
|
|
308
|
+
rl.question(kleur.cyan("> "), (ans) => {
|
|
309
|
+
const run = ans.trim() === "" ? guess : ans.trim();
|
|
310
|
+
executeAndStore(run, run, opts, session);
|
|
311
|
+
rl.prompt();
|
|
312
|
+
});
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// Single-letter hotkey follow-ups (only meaningful right after an answer).
|
|
316
|
+
if (line.length === 1 && session.lastTarget) {
|
|
317
|
+
const target = session.lastTarget;
|
|
318
|
+
const k = line.toLowerCase();
|
|
319
|
+
if (k === "w") {
|
|
320
|
+
executeAndStore(`why ${target}`, line, opts, session);
|
|
321
|
+
rl.prompt();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (k === "v") {
|
|
325
|
+
executeAndStore(`verify ${target}`, line, opts, session);
|
|
326
|
+
rl.prompt();
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (k === "p") {
|
|
330
|
+
executeAndStore(`premortem ${target}`, line, opts, session);
|
|
331
|
+
rl.prompt();
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (k === "q") {
|
|
335
|
+
rl.close();
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
// Classify natural language → mneme command.
|
|
340
|
+
const classified = classifyIntent(line);
|
|
341
|
+
const cmd = classified?.cmd ?? ["ask", line];
|
|
342
|
+
if (classified?.target)
|
|
343
|
+
session.lastTarget = classified.target;
|
|
344
|
+
executeAndStore(cmd.map(quoteArg).join(" "), line, opts, session, cmd);
|
|
345
|
+
rl.prompt();
|
|
346
|
+
});
|
|
347
|
+
rl.on("close", () => {
|
|
348
|
+
process.stdout.write(kleur.gray("\n 👋 bye — your session was logged in-memory only.\n\n"));
|
|
349
|
+
process.exit(0);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function quoteArg(s) {
|
|
353
|
+
if (/^[a-zA-Z0-9_\-./:=]+$/.test(s))
|
|
354
|
+
return s;
|
|
355
|
+
return `"${s.replace(/"/g, '\\"')}"`;
|
|
356
|
+
}
|
|
357
|
+
function executeAndStore(displayedCmd, rawInput, opts, session, cmdArgsOverride) {
|
|
358
|
+
const args = cmdArgsOverride ?? displayedCmd.split(" ");
|
|
359
|
+
process.stdout.write(` ${kleur.gray("→ mneme " + displayedCmd)}\n\n`);
|
|
360
|
+
const r = runMnemeCommand(args, opts.cwd);
|
|
361
|
+
if (r.stdout)
|
|
362
|
+
process.stdout.write(r.stdout);
|
|
363
|
+
if (r.stderr)
|
|
364
|
+
process.stderr.write(r.stderr);
|
|
365
|
+
const n = session.history.length + 1;
|
|
366
|
+
session.history.push({
|
|
367
|
+
at: new Date().toISOString(),
|
|
368
|
+
input: rawInput,
|
|
369
|
+
cmd: args,
|
|
370
|
+
output: r.stdout + (r.stderr ? "\n[stderr] " + r.stderr : ""),
|
|
371
|
+
});
|
|
372
|
+
if (session.lastTarget) {
|
|
373
|
+
const c = process.stdout.isTTY ? kleur : { gray: (s) => s };
|
|
374
|
+
process.stdout.write(c.gray(`\n [#${n}] (W)hy more · (V)erify · (P)remortem · (Q)uit\n`));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
// ── Entry point ─────────────────────────────────────────────────────────
|
|
378
|
+
export async function chatCommand(opts) {
|
|
379
|
+
const agent = detectHostAgent();
|
|
380
|
+
if (agent.detected && !opts.forceStandalone) {
|
|
381
|
+
emitProtocolHandoff(agent, opts);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
await startRepl(opts);
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAiB1B;0EAC0E;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AAM,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;QACpE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC;AAED,2EAA2E;AAE3E,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAiB;IACjD,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,KAAK,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;QAC5C,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACjC,OAAO;IACT,CAAC;IACD,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
export interface SuperIndexOptions {
|
|
27
|
+
cwd: string;
|
|
28
|
+
/** Force complete rebuild — ignore cursor. */
|
|
29
|
+
full?: boolean;
|
|
30
|
+
/** After indexing, keep alive + re-index on every git HEAD update. */
|
|
31
|
+
watch?: boolean;
|
|
32
|
+
/** Skip indexing — just (re-)compute the merkle root + print. */
|
|
33
|
+
merkleOnly?: boolean;
|
|
34
|
+
/** Quiet mode — no banner/colours. Sets implicitly when stdout !TTY. */
|
|
35
|
+
quiet?: boolean;
|
|
36
|
+
/** JSON output. */
|
|
37
|
+
json?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function superIndexCommand(opts: SuperIndexOptions): Promise<void>;
|
|
40
|
+
//# sourceMappingURL=index-super.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-super.d.ts","sourceRoot":"","sources":["../../src/commands/index-super.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAYH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mBAAmB;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAyLD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiE9E"}
|