myagentmemory 0.4.17 → 0.5.2
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/README.md +68 -71
- package/dist/cli-spec.d.ts +7 -1
- package/dist/cli-spec.js +214 -12
- package/dist/cli.js +2053 -156
- package/dist/completions.js +24 -18
- package/dist/core.d.ts +42 -4
- package/dist/core.js +242 -68
- package/dist/hooks.d.ts +21 -1
- package/dist/hooks.js +382 -87
- package/dist/mcp-server.d.ts +27 -0
- package/dist/mcp-server.js +106 -0
- package/dist/plugin-bootstrap.js +4 -4
- package/dist/plugin-host.d.ts +34 -0
- package/dist/plugin-runtime.d.ts +22 -1
- package/dist/plugin-runtime.js +65 -2
- package/dist/plugin-service.d.ts +10 -4
- package/dist/plugin-service.js +52 -8
- package/dist/upgrade.d.ts +80 -0
- package/dist/upgrade.js +243 -0
- package/docs/official-plugin-bootstrap.md +3 -3
- package/package.json +24 -4
- package/scripts/install-skills.sh +1 -1
- package/skills/agent/SKILL.md +12 -2
- package/skills/claude-code/SKILL.md +17 -2
- package/skills/codex/SKILL.md +14 -2
- package/skills/cursor/SKILL.md +14 -2
- package/src/cli-spec.ts +218 -12
- package/src/completions.ts +26 -18
- package/src/core.ts +312 -123
- package/src/hooks.ts +395 -85
- package/src/plugin-bootstrap.ts +4 -4
- package/src/plugin-host.ts +34 -0
- package/src/cli.ts +0 -1332
- package/src/plugin-runtime.ts +0 -390
- package/src/plugin-service.ts +0 -627
package/src/cli-spec.ts
CHANGED
|
@@ -10,14 +10,18 @@ export interface CliOptionSpec {
|
|
|
10
10
|
|
|
11
11
|
export const COMMANDS = [
|
|
12
12
|
"context",
|
|
13
|
+
"save",
|
|
14
|
+
"note",
|
|
13
15
|
"write",
|
|
14
16
|
"read",
|
|
15
17
|
"scratchpad",
|
|
16
18
|
"search",
|
|
17
19
|
"distil",
|
|
18
20
|
"sync",
|
|
19
|
-
"
|
|
21
|
+
"setup",
|
|
20
22
|
"status",
|
|
23
|
+
"doctor",
|
|
24
|
+
"tutorial",
|
|
21
25
|
"install-skills",
|
|
22
26
|
"uninstall-skills",
|
|
23
27
|
"install-hooks",
|
|
@@ -28,6 +32,8 @@ export const COMMANDS = [
|
|
|
28
32
|
"learn",
|
|
29
33
|
"dashboard",
|
|
30
34
|
"plugin",
|
|
35
|
+
"serve",
|
|
36
|
+
"upgrade",
|
|
31
37
|
"version",
|
|
32
38
|
"help",
|
|
33
39
|
] as const;
|
|
@@ -39,24 +45,30 @@ export const SCRATCHPAD_ACTIONS = ["add", "done", "undo", "clear_done", "list"]
|
|
|
39
45
|
|
|
40
46
|
export const COMMAND_DESCRIPTIONS: Record<(typeof COMMANDS)[number], string> = {
|
|
41
47
|
context: "build context from scratchpad, logs, topics, and long-term memory",
|
|
48
|
+
save: 'shortcut: agent-memory save "<text>" → daily memory entry',
|
|
49
|
+
note: 'shortcut: agent-memory note "<text>" → scratchpad checklist item',
|
|
42
50
|
write: "append or overwrite a daily, topic, or long-term memory entry",
|
|
43
51
|
read: "read daily, topic, scratchpad, or long-term memory",
|
|
44
52
|
scratchpad: "add, complete, reopen, list, or clear persistent checklist items",
|
|
45
53
|
search: "search indexed memory with keyword, semantic, or deep qmd modes",
|
|
46
54
|
distil: "rebuild a compact MEMORY.md index from logs and topics",
|
|
47
55
|
sync: "update the qmd index and semantic embeddings",
|
|
48
|
-
|
|
56
|
+
setup: "one-shot idempotent installer: init + skills + hooks + plugin + mcp",
|
|
49
57
|
status: "show memory paths, file counts, qmd, and embedding health",
|
|
58
|
+
doctor: "run a one-shot health check across memory, qmd, skills, hooks, and Pro",
|
|
59
|
+
tutorial: "guided 3-minute walkthrough in a throwaway sandbox",
|
|
50
60
|
"install-skills": "install core instructions for detected agents",
|
|
51
61
|
"uninstall-skills": "remove core instructions from detected agents",
|
|
52
|
-
"install-hooks": "install
|
|
53
|
-
"uninstall-hooks": "remove only
|
|
62
|
+
"install-hooks": "install managed context and memory-write reminder hooks",
|
|
63
|
+
"uninstall-hooks": "remove only hooks managed by agent-memory",
|
|
54
64
|
completion: "install or print Bash, Zsh, Fish, or PowerShell completion",
|
|
55
65
|
pro: "install, inspect, or upgrade AgentMemory Pro",
|
|
56
66
|
recall: "recall decisions and context from prior coding sessions with Pro",
|
|
57
67
|
learn: "find repeated corrections worth remembering with Pro",
|
|
58
68
|
dashboard: "open the private local Memory Dashboard",
|
|
59
69
|
plugin: "discover, install, update, or remove optional official plugins",
|
|
70
|
+
serve: "run as a Model Context Protocol (MCP) server over stdio",
|
|
71
|
+
upgrade: "check for and install newer agent-memory CLI and Pro plugin releases",
|
|
60
72
|
version: "print the installed agent-memory version",
|
|
61
73
|
help: "show this command overview",
|
|
62
74
|
};
|
|
@@ -83,24 +95,41 @@ export const SCRATCHPAD_ACTION_DESCRIPTIONS: Record<(typeof SCRATCHPAD_ACTIONS)[
|
|
|
83
95
|
export const GLOBAL_OPTIONS = ["--dir", "--json", "--help", "--version", "-h", "-V"] as const;
|
|
84
96
|
|
|
85
97
|
export const COMMAND_OPTIONS: Record<string, readonly string[]> = {
|
|
86
|
-
context: ["--query", "--no-search"],
|
|
98
|
+
context: ["--query", "--no-search", "--layer"],
|
|
99
|
+
save: ["--target"],
|
|
100
|
+
note: [],
|
|
87
101
|
write: ["--content", "--target", "--mode", "--topic", "--date", "--source-uri"],
|
|
88
102
|
read: ["--target", "--date", "--topic"],
|
|
89
103
|
scratchpad: ["--text"],
|
|
90
104
|
search: ["--query", "--mode", "--limit"],
|
|
91
105
|
distil: ["--dry-run"],
|
|
92
106
|
sync: [],
|
|
93
|
-
init: [],
|
|
107
|
+
init: ["--yes", "--skip-skills", "--skip-hooks"],
|
|
108
|
+
setup: ["--yes", "--skip-skills", "--skip-hooks", "--skip-plugin", "--skip-mcp"],
|
|
94
109
|
status: ["--probe"],
|
|
95
|
-
|
|
110
|
+
doctor: [],
|
|
111
|
+
tutorial: [],
|
|
112
|
+
"install-skills": ["--uninstall"],
|
|
96
113
|
"uninstall-skills": [],
|
|
97
|
-
"install-hooks": ["--yes", "--all", "--only"],
|
|
114
|
+
"install-hooks": ["--yes", "--all", "--only", "--mode"],
|
|
98
115
|
"uninstall-hooks": ["--only"],
|
|
99
116
|
completion: ["--stdout"],
|
|
100
117
|
pro: [],
|
|
101
|
-
recall: [
|
|
102
|
-
|
|
118
|
+
recall: [
|
|
119
|
+
"--scope",
|
|
120
|
+
"--cwd",
|
|
121
|
+
"--limit",
|
|
122
|
+
"--context",
|
|
123
|
+
"--queries",
|
|
124
|
+
"--multi",
|
|
125
|
+
"--sessions",
|
|
126
|
+
"--events",
|
|
127
|
+
"--per-query",
|
|
128
|
+
],
|
|
129
|
+
learn: ["--preview"],
|
|
103
130
|
dashboard: ["--no-browser"],
|
|
131
|
+
serve: ["--mcp", "--register", "--only"],
|
|
132
|
+
upgrade: ["--check", "--refresh", "--yes", "--quiet", "--cli", "--plugin"],
|
|
104
133
|
version: [],
|
|
105
134
|
help: [],
|
|
106
135
|
};
|
|
@@ -112,6 +141,12 @@ export const PLUGIN_COMMAND_OPTIONS: Record<string, readonly string[]> = {
|
|
|
112
141
|
update: ["--channel"],
|
|
113
142
|
uninstall: ["--yes"],
|
|
114
143
|
manage: ["--no-browser"],
|
|
144
|
+
// Plugin runtime commands forwarded to the installed bundle
|
|
145
|
+
index: ["--date", "--since"],
|
|
146
|
+
recall: ["--query", "--limit", "--cwd", "--host", "--mode"],
|
|
147
|
+
worker: ["--token"],
|
|
148
|
+
learn: ["--limit", "--dry-run"],
|
|
149
|
+
eval: ["--limit"],
|
|
115
150
|
};
|
|
116
151
|
|
|
117
152
|
export const WORKER_ACTION_OPTIONS: Record<string, readonly string[]> = {};
|
|
@@ -135,7 +170,14 @@ export const OPTION_SPECS: Record<string, CliOptionSpec> = {
|
|
|
135
170
|
"--no-search": { description: "build context without invoking qmd" },
|
|
136
171
|
"--content": { description: "memory entry content to persist", value: { label: "text", kind: "value" } },
|
|
137
172
|
"--target": { description: "memory destination or collection to read", value: { label: "target", kind: "value" } },
|
|
138
|
-
"--mode": {
|
|
173
|
+
"--mode": {
|
|
174
|
+
description: "write behavior, qmd search strategy, or hook mode (stable|per-turn)",
|
|
175
|
+
value: { label: "mode", kind: "value" },
|
|
176
|
+
},
|
|
177
|
+
"--layer": {
|
|
178
|
+
description: "context layer to emit: stable, dynamic, or full (default)",
|
|
179
|
+
value: { label: "layer", kind: "value" },
|
|
180
|
+
},
|
|
139
181
|
"--topic": { description: "topic name used to resolve a topic file", value: { label: "name", kind: "value" } },
|
|
140
182
|
"--date": { description: "daily-log date in YYYY-MM-DD form", value: { label: "date", kind: "value" } },
|
|
141
183
|
"--source-uri": {
|
|
@@ -154,8 +196,13 @@ export const OPTION_SPECS: Record<string, CliOptionSpec> = {
|
|
|
154
196
|
"--state": { description: "override the plugin state root", value: { label: "directory", kind: "directory" } },
|
|
155
197
|
"--with-plugin": { description: "include both the core and optional plugin skills" },
|
|
156
198
|
"--plugin-only": { description: "operate only on the optional plugin skill" },
|
|
157
|
-
"--yes": { description: "apply eligible
|
|
199
|
+
"--yes": { description: "apply eligible changes without interactive prompts" },
|
|
158
200
|
"--all": { description: "apply eligible hook changes without confirmation" },
|
|
201
|
+
"--skip-skills": { description: "init: don't prompt to install agent skills" },
|
|
202
|
+
"--skip-hooks": { description: "init: don't prompt to install SessionStart hooks" },
|
|
203
|
+
"--skip-plugin": { description: "setup: don't offer to install the paid plugin bundle" },
|
|
204
|
+
"--skip-mcp": { description: "setup: don't register the MCP server in detected local harnesses" },
|
|
205
|
+
"--preview": { description: "learn: show detected patterns without writing or consuming quota" },
|
|
159
206
|
"--only": {
|
|
160
207
|
description: "restrict hook changes to comma-separated agent keys",
|
|
161
208
|
value: { label: "agents", kind: "value" },
|
|
@@ -178,6 +225,23 @@ export const OPTION_SPECS: Record<string, CliOptionSpec> = {
|
|
|
178
225
|
description: "surrounding events included with each recall hit",
|
|
179
226
|
value: { label: "number", kind: "number" },
|
|
180
227
|
},
|
|
228
|
+
"--queries": {
|
|
229
|
+
description: "JSON array of query strings for one-shot multi-query recall",
|
|
230
|
+
value: { label: "json", kind: "value" },
|
|
231
|
+
},
|
|
232
|
+
"--multi": { description: "treat each positional argument as a separate recall query" },
|
|
233
|
+
"--sessions": {
|
|
234
|
+
description: "maximum sessions returned by multi-query recall",
|
|
235
|
+
value: { label: "number", kind: "number" },
|
|
236
|
+
},
|
|
237
|
+
"--events": {
|
|
238
|
+
description: "top events per session returned by multi-query recall",
|
|
239
|
+
value: { label: "number", kind: "number" },
|
|
240
|
+
},
|
|
241
|
+
"--per-query": {
|
|
242
|
+
description: "candidate hits considered per query before fusion",
|
|
243
|
+
value: { label: "number", kind: "number" },
|
|
244
|
+
},
|
|
181
245
|
"--pi": { description: "override the Pi session root", value: { label: "directory", kind: "directory" } },
|
|
182
246
|
"--codex": { description: "override the Codex session root", value: { label: "directory", kind: "directory" } },
|
|
183
247
|
"--claude": {
|
|
@@ -230,6 +294,13 @@ export const OPTION_SPECS: Record<string, CliOptionSpec> = {
|
|
|
230
294
|
"--agent": { description: "internal SessionStart host key", value: { label: "agent", kind: "value" } },
|
|
231
295
|
"--token": { description: "internal session-worker lease token", value: { label: "token", kind: "value" } },
|
|
232
296
|
"--uninstall": { description: "use install-skills compatibility uninstall mode" },
|
|
297
|
+
"--mcp": { description: "serve as an MCP server over stdio (used by Claude Code)" },
|
|
298
|
+
"--register": { description: "register the MCP server in detected supported agents and exit" },
|
|
299
|
+
"--check": { description: "upgrade: report available updates without installing" },
|
|
300
|
+
"--refresh": { description: "upgrade: force a live registry lookup and rewrite the 24h cache" },
|
|
301
|
+
"--quiet": { description: "upgrade: suppress non-error output (used by the passive session-start refresh)" },
|
|
302
|
+
"--cli": { description: "upgrade: limit action to the CLI binary" },
|
|
303
|
+
"--plugin": { description: "upgrade: limit action to the Pro plugin bundle" },
|
|
233
304
|
};
|
|
234
305
|
|
|
235
306
|
export const SHELL_DESCRIPTIONS: Record<string, string> = {
|
|
@@ -246,3 +317,138 @@ export function optionDescription(option: string): string {
|
|
|
246
317
|
export function optionTakesValue(option: string): boolean {
|
|
247
318
|
return OPTION_SPECS[option]?.value !== undefined;
|
|
248
319
|
}
|
|
320
|
+
|
|
321
|
+
// One-line usage template per command — shows the shape agents/humans should type.
|
|
322
|
+
const COMMAND_USAGE: Record<string, string> = {
|
|
323
|
+
context: 'agent-memory context [--query "text"] [--no-search] [--json]',
|
|
324
|
+
save: 'agent-memory save "<text>" [--target daily|topic|long_term]',
|
|
325
|
+
note: 'agent-memory note "<text>"',
|
|
326
|
+
write: 'agent-memory write "<text>" [--target daily|topic|long_term] [--mode append|overwrite] [--topic <name>] [--date YYYY-MM-DD]',
|
|
327
|
+
read: "agent-memory read [--target daily|topic|long_term|scratchpad] [--date YYYY-MM-DD] [--topic <name>]",
|
|
328
|
+
scratchpad: 'agent-memory scratchpad <add|done|undo|clear_done|list> [--text "text"]',
|
|
329
|
+
search: 'agent-memory search --query "text" [--mode keyword|semantic|deep] [--limit N]',
|
|
330
|
+
distil: "agent-memory distil [--dry-run]",
|
|
331
|
+
sync: "agent-memory sync",
|
|
332
|
+
init: "agent-memory init [--yes] [--skip-skills] [--skip-hooks]",
|
|
333
|
+
setup: "agent-memory setup [--yes] [--json]",
|
|
334
|
+
status: "agent-memory status [--probe] [--json]",
|
|
335
|
+
doctor: "agent-memory doctor [--json]",
|
|
336
|
+
tutorial: "agent-memory tutorial",
|
|
337
|
+
"install-skills": "agent-memory install-skills [--json]",
|
|
338
|
+
"uninstall-skills": "agent-memory uninstall-skills [--json]",
|
|
339
|
+
"install-hooks":
|
|
340
|
+
"agent-memory install-hooks [--yes] [--all] [--only claude,codex,cursor] [--mode stable|per-turn] [--json]",
|
|
341
|
+
"uninstall-hooks": "agent-memory uninstall-hooks [--only claude,codex,cursor] [--json]",
|
|
342
|
+
completion: "agent-memory completion [bash|zsh|fish|powershell] [--stdout]",
|
|
343
|
+
pro: "agent-memory pro <install|status|upgrade> [--channel stable] [--yes]",
|
|
344
|
+
recall:
|
|
345
|
+
'agent-memory recall "<query>" [--limit N] [--context N] [--scope current|global] [--cwd <path>] [--json]\n Multi-query: agent-memory recall --queries \'["q1","q2","q3"]\' [--sessions N] [--events N]',
|
|
346
|
+
learn: "agent-memory learn [--preview] [--json]",
|
|
347
|
+
dashboard: "agent-memory dashboard [--no-browser]",
|
|
348
|
+
plugin:
|
|
349
|
+
"agent-memory plugin <list|status|install|update|uninstall|manage> [--channel stable] [--yes] [--no-browser]",
|
|
350
|
+
upgrade: "agent-memory upgrade [--check] [--yes] [--cli|--plugin] [--refresh] [--json]",
|
|
351
|
+
version: "agent-memory version",
|
|
352
|
+
help: "agent-memory help [<command>]",
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// Concrete examples per command — what an agent or dev is most likely to want.
|
|
356
|
+
const COMMAND_EXAMPLES: Record<string, string[]> = {
|
|
357
|
+
save: [
|
|
358
|
+
'agent-memory save "shipped the new recall path — bundle at 1.2.3"',
|
|
359
|
+
'agent-memory save --target long_term "prefer bun test over npm test in example-api"',
|
|
360
|
+
],
|
|
361
|
+
note: ['agent-memory note "verify the digest backfill against a real corpus"'],
|
|
362
|
+
write: [
|
|
363
|
+
'agent-memory write "keep sessions in reverse-chron order" --target long_term --mode overwrite',
|
|
364
|
+
'agent-memory write "half-line summary" --target topic --topic scheduling-machine',
|
|
365
|
+
],
|
|
366
|
+
read: [
|
|
367
|
+
"agent-memory read --target long_term",
|
|
368
|
+
"agent-memory read --target daily --date 2026-08-24",
|
|
369
|
+
"agent-memory read --target topic --topic scheduling-machine",
|
|
370
|
+
],
|
|
371
|
+
scratchpad: [
|
|
372
|
+
'agent-memory scratchpad add --text "chase down the flake in test/web.test.ts"',
|
|
373
|
+
'agent-memory scratchpad done --text "chase down the flake"',
|
|
374
|
+
"agent-memory scratchpad list",
|
|
375
|
+
],
|
|
376
|
+
search: [
|
|
377
|
+
'agent-memory search --query "API test collection credentials"',
|
|
378
|
+
'agent-memory search --query "grafana alert routing" --mode semantic --limit 10',
|
|
379
|
+
],
|
|
380
|
+
recall: [
|
|
381
|
+
'agent-memory recall "API test collection for booking service"',
|
|
382
|
+
'agent-memory recall --queries \'["API test collection for booking service","booking client integration","client credential setup"]\' --sessions 5',
|
|
383
|
+
'agent-memory recall "auth refresh" --scope current --limit 5',
|
|
384
|
+
],
|
|
385
|
+
context: ["agent-memory context", 'agent-memory context --query "grafana alerts" --json'],
|
|
386
|
+
status: ["agent-memory status", "agent-memory status --json"],
|
|
387
|
+
init: ["agent-memory init", "agent-memory init --yes --skip-hooks"],
|
|
388
|
+
setup: ["agent-memory setup", "agent-memory setup --json"],
|
|
389
|
+
"install-hooks": [
|
|
390
|
+
"agent-memory install-hooks",
|
|
391
|
+
"agent-memory install-hooks --yes",
|
|
392
|
+
"agent-memory install-hooks --only claude,codex",
|
|
393
|
+
"agent-memory install-hooks --mode stable # SessionStart only (skip UserPromptSubmit)",
|
|
394
|
+
],
|
|
395
|
+
distil: ["agent-memory distil", "agent-memory distil --dry-run"],
|
|
396
|
+
learn: ["agent-memory learn", "agent-memory learn --preview # see patterns without consuming quota or writing"],
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Render per-command help using existing spec metadata. Called when the user
|
|
401
|
+
* runs `agent-memory <cmd> --help` — should list the command's real flags with
|
|
402
|
+
* descriptions and one or two concrete examples, not the top-level command list.
|
|
403
|
+
*/
|
|
404
|
+
export function renderCommandHelp(command: string): string {
|
|
405
|
+
const canonical = command === "distill" ? "distil" : command;
|
|
406
|
+
const known = new Set<string>([...COMMANDS, "distill", "setup"]);
|
|
407
|
+
if (!known.has(canonical)) {
|
|
408
|
+
return `agent-memory: unknown command '${command}'. Run 'agent-memory help' for the full list.`;
|
|
409
|
+
}
|
|
410
|
+
const description =
|
|
411
|
+
COMMAND_DESCRIPTIONS[canonical as (typeof COMMANDS)[number]] ??
|
|
412
|
+
(canonical === "setup" ? "one-shot idempotent installer: init + skills + hooks + plugin + mcp" : "");
|
|
413
|
+
const usage = COMMAND_USAGE[canonical] ?? `agent-memory ${canonical} [options]`;
|
|
414
|
+
const options = COMMAND_OPTIONS[canonical] ?? [];
|
|
415
|
+
const examples = COMMAND_EXAMPLES[canonical] ?? [];
|
|
416
|
+
|
|
417
|
+
const optLines: string[] = [];
|
|
418
|
+
// Command-specific options
|
|
419
|
+
for (const opt of options) {
|
|
420
|
+
const spec = OPTION_SPECS[opt];
|
|
421
|
+
if (!spec) continue;
|
|
422
|
+
const label = spec.value ? `${opt} <${spec.value.label}>` : opt;
|
|
423
|
+
optLines.push(` ${label.padEnd(24)} ${spec.description}`);
|
|
424
|
+
}
|
|
425
|
+
// Global options that are always available
|
|
426
|
+
const globalKeys = ["--dir", "--json", "--help", "--version"];
|
|
427
|
+
const globalLines = globalKeys
|
|
428
|
+
.map((opt) => {
|
|
429
|
+
const spec = OPTION_SPECS[opt];
|
|
430
|
+
if (!spec) return "";
|
|
431
|
+
const label = spec.value ? `${opt} <${spec.value.label}>` : opt;
|
|
432
|
+
return ` ${label.padEnd(24)} ${spec.description}`;
|
|
433
|
+
})
|
|
434
|
+
.filter(Boolean);
|
|
435
|
+
|
|
436
|
+
// Command-specific subactions
|
|
437
|
+
let subactionLines = "";
|
|
438
|
+
if (canonical === "scratchpad") {
|
|
439
|
+
subactionLines = `\nActions:\n${SCRATCHPAD_ACTIONS.map((a) => ` ${a.padEnd(24)} ${SCRATCHPAD_ACTION_DESCRIPTIONS[a]}`).join("\n")}\n`;
|
|
440
|
+
}
|
|
441
|
+
if (canonical === "plugin" || canonical === "pro") {
|
|
442
|
+
subactionLines = `\nSubcommands:\n${PLUGIN_COMMANDS.map((a) => ` ${a.padEnd(24)} ${PLUGIN_COMMAND_DESCRIPTIONS[a]}`).join("\n")}\n`;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const parts = [`agent-memory ${canonical} — ${description}`, "", "Usage:", ` ${usage}`];
|
|
446
|
+
if (subactionLines) parts.push(subactionLines);
|
|
447
|
+
if (optLines.length) parts.push("\nOptions:", ...optLines);
|
|
448
|
+
if (globalLines.length) parts.push("\nGlobal:", ...globalLines);
|
|
449
|
+
if (examples.length) {
|
|
450
|
+
parts.push("\nExamples:");
|
|
451
|
+
for (const ex of examples) parts.push(` $ ${ex}`);
|
|
452
|
+
}
|
|
453
|
+
return parts.join("\n");
|
|
454
|
+
}
|
package/src/completions.ts
CHANGED
|
@@ -33,6 +33,14 @@ function words(values: readonly string[]): string {
|
|
|
33
33
|
return values.join(" ");
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
function shellSingleQuote(value: string): string {
|
|
37
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function powerShellSingleQuote(value: string): string {
|
|
41
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
function zshOptionValue(command: string, option: string): string {
|
|
37
45
|
if (option === "--target") {
|
|
38
46
|
return command === "read"
|
|
@@ -52,7 +60,7 @@ function zshOptionValue(command: string, option: string): string {
|
|
|
52
60
|
|
|
53
61
|
function zshOptionSpecs(command: string, options: readonly string[] = COMMAND_OPTIONS[command] ?? []): string {
|
|
54
62
|
return options
|
|
55
|
-
.map((option) =>
|
|
63
|
+
.map((option) => shellSingleQuote(`${option}[${optionDescription(option)}]${zshOptionValue(command, option)}`))
|
|
56
64
|
.join(" ");
|
|
57
65
|
}
|
|
58
66
|
|
|
@@ -71,7 +79,7 @@ function fishOption(command: string, condition: string, option: string): string
|
|
|
71
79
|
else if (option === "--only") suggestions = " -a 'claude codex cursor opencode pi'";
|
|
72
80
|
else if (spec?.value?.kind === "directory") suggestions = " -a '(__fish_complete_directories)'";
|
|
73
81
|
else if (spec?.value?.kind === "file") suggestions = " -F";
|
|
74
|
-
return `complete -c agent-memory -n
|
|
82
|
+
return `complete -c agent-memory -n ${shellSingleQuote(condition)} -l ${option.slice(2)}${value}${suggestions} -d ${shellSingleQuote(optionDescription(option))}`;
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
function bashCompletion(): string {
|
|
@@ -162,12 +170,12 @@ _agent-memory() {
|
|
|
162
170
|
local subcommand="$words[3]"
|
|
163
171
|
local action="$words[4]"
|
|
164
172
|
local command_position=$CURRENT
|
|
165
|
-
commands=(${COMMANDS.map((command) =>
|
|
166
|
-
plugin_commands=(${PLUGIN_COMMANDS.map((command) =>
|
|
167
|
-
worker_actions=(${WORKER_ACTIONS.map((action) =>
|
|
168
|
-
scratchpad_actions=(${SCRATCHPAD_ACTIONS.map((action) =>
|
|
173
|
+
commands=(${COMMANDS.map((command) => shellSingleQuote(`${command}:${COMMAND_DESCRIPTIONS[command] ?? command}`)).join(" ")})
|
|
174
|
+
plugin_commands=(${PLUGIN_COMMANDS.map((command) => shellSingleQuote(`${command}:${PLUGIN_COMMAND_DESCRIPTIONS[command]}`)).join(" ")})
|
|
175
|
+
worker_actions=(${WORKER_ACTIONS.map((action) => shellSingleQuote(`${action}:${WORKER_ACTION_DESCRIPTIONS[action]}`)).join(" ")})
|
|
176
|
+
scratchpad_actions=(${SCRATCHPAD_ACTIONS.map((action) => shellSingleQuote(`${action}:${SCRATCHPAD_ACTION_DESCRIPTIONS[action]}`)).join(" ")})
|
|
169
177
|
shells=(${Object.entries(SHELL_DESCRIPTIONS)
|
|
170
|
-
.map(([shell, description]) =>
|
|
178
|
+
.map(([shell, description]) => shellSingleQuote(`${shell}:${description}`))
|
|
171
179
|
.join(" ")})
|
|
172
180
|
|
|
173
181
|
_arguments -C \\
|
|
@@ -237,23 +245,23 @@ function fishCompletion(): string {
|
|
|
237
245
|
"complete -c agent-memory -f",
|
|
238
246
|
...COMMANDS.map(
|
|
239
247
|
(command) =>
|
|
240
|
-
`complete -c agent-memory -n '__fish_use_subcommand' -a '${command}' -d
|
|
248
|
+
`complete -c agent-memory -n '__fish_use_subcommand' -a '${command}' -d ${shellSingleQuote(COMMAND_DESCRIPTIONS[command] ?? command)}`,
|
|
241
249
|
),
|
|
242
250
|
...PLUGIN_COMMANDS.map(
|
|
243
251
|
(command) =>
|
|
244
|
-
`complete -c agent-memory -n '__fish_seen_subcommand_from plugin; and not __fish_seen_subcommand_from ${words(PLUGIN_COMMANDS)}' -a '${command}' -d
|
|
252
|
+
`complete -c agent-memory -n '__fish_seen_subcommand_from plugin; and not __fish_seen_subcommand_from ${words(PLUGIN_COMMANDS)}' -a '${command}' -d ${shellSingleQuote(PLUGIN_COMMAND_DESCRIPTIONS[command])}`,
|
|
245
253
|
),
|
|
246
254
|
...WORKER_ACTIONS.map(
|
|
247
255
|
(action) =>
|
|
248
|
-
`complete -c agent-memory -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from worker; and not __fish_seen_subcommand_from ${words(WORKER_ACTIONS)}' -a '${action}' -d
|
|
256
|
+
`complete -c agent-memory -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from worker; and not __fish_seen_subcommand_from ${words(WORKER_ACTIONS)}' -a '${action}' -d ${shellSingleQuote(WORKER_ACTION_DESCRIPTIONS[action])}`,
|
|
249
257
|
),
|
|
250
258
|
...SCRATCHPAD_ACTIONS.map(
|
|
251
259
|
(action) =>
|
|
252
|
-
`complete -c agent-memory -n '__fish_seen_subcommand_from scratchpad; and not __fish_seen_subcommand_from ${words(SCRATCHPAD_ACTIONS)}' -a '${action}' -d
|
|
260
|
+
`complete -c agent-memory -n '__fish_seen_subcommand_from scratchpad; and not __fish_seen_subcommand_from ${words(SCRATCHPAD_ACTIONS)}' -a '${action}' -d ${shellSingleQuote(SCRATCHPAD_ACTION_DESCRIPTIONS[action])}`,
|
|
253
261
|
),
|
|
254
262
|
...Object.entries(SHELL_DESCRIPTIONS).map(
|
|
255
263
|
([shell, description]) =>
|
|
256
|
-
`complete -c agent-memory -n '__fish_seen_subcommand_from completion' -a '${shell}' -d
|
|
264
|
+
`complete -c agent-memory -n '__fish_seen_subcommand_from completion' -a '${shell}' -d ${shellSingleQuote(description)}`,
|
|
257
265
|
),
|
|
258
266
|
"complete -c agent-memory -l dir -r -a '(__fish_complete_directories)' -d 'override the active memory directory'",
|
|
259
267
|
"complete -c agent-memory -l json -d 'emit command-specific structured JSON'",
|
|
@@ -330,32 +338,32 @@ Register-ArgumentCompleter -Native -CommandName agent-memory -ScriptBlock {
|
|
|
330
338
|
$shells = @('bash','zsh','fish','powershell')
|
|
331
339
|
$commandDescriptions = @{
|
|
332
340
|
${Object.entries(COMMAND_DESCRIPTIONS)
|
|
333
|
-
.map(([command, description]) => ` '${command}' =
|
|
341
|
+
.map(([command, description]) => ` '${command}' = ${powerShellSingleQuote(description)}`)
|
|
334
342
|
.join("\n")}
|
|
335
343
|
}
|
|
336
344
|
$pluginCommandDescriptions = @{
|
|
337
345
|
${Object.entries(PLUGIN_COMMAND_DESCRIPTIONS)
|
|
338
|
-
.map(([command, description]) => ` '${command}' =
|
|
346
|
+
.map(([command, description]) => ` '${command}' = ${powerShellSingleQuote(description)}`)
|
|
339
347
|
.join("\n")}
|
|
340
348
|
}
|
|
341
349
|
$workerActionDescriptions = @{
|
|
342
350
|
${Object.entries(WORKER_ACTION_DESCRIPTIONS)
|
|
343
|
-
.map(([action, description]) => ` '${action}' =
|
|
351
|
+
.map(([action, description]) => ` '${action}' = ${powerShellSingleQuote(String(description))}`)
|
|
344
352
|
.join("\n")}
|
|
345
353
|
}
|
|
346
354
|
$scratchpadActionDescriptions = @{
|
|
347
355
|
${Object.entries(SCRATCHPAD_ACTION_DESCRIPTIONS)
|
|
348
|
-
.map(([action, description]) => ` '${action}' =
|
|
356
|
+
.map(([action, description]) => ` '${action}' = ${powerShellSingleQuote(description)}`)
|
|
349
357
|
.join("\n")}
|
|
350
358
|
}
|
|
351
359
|
$shellDescriptions = @{
|
|
352
360
|
${Object.entries(SHELL_DESCRIPTIONS)
|
|
353
|
-
.map(([shell, description]) => ` '${shell}' =
|
|
361
|
+
.map(([shell, description]) => ` '${shell}' = ${powerShellSingleQuote(description)}`)
|
|
354
362
|
.join("\n")}
|
|
355
363
|
}
|
|
356
364
|
$optionDescriptions = @{
|
|
357
365
|
${Object.keys(OPTION_SPECS)
|
|
358
|
-
.map((option) => ` '${option}' =
|
|
366
|
+
.map((option) => ` '${option}' = ${powerShellSingleQuote(optionDescription(option))}`)
|
|
359
367
|
.join("\n")}
|
|
360
368
|
}
|
|
361
369
|
$globalOptions = @('${GLOBAL_OPTIONS.join("','")}')
|