myagentmemory 0.4.16 → 0.5.1

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/LICENSE CHANGED
@@ -1,6 +1,7 @@
1
1
  MIT License
2
2
 
3
3
  Copyright (c) 2026 Jay Zeng
4
+ Copyright (c) 2026 jo-inc
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,36 +1,54 @@
1
1
  # AgentMemory
2
2
 
3
- **Memory that survives the agent.** AgentMemory is a local, user-owned state layer for [Claude Code](https://claude.ai/code), [OpenAI Codex](https://github.com/openai/codex), [Cursor](https://cursor.com), and Agent (Cursor CLI). Keep scratch work, daily evidence, topic notes, and durable decisions as plain Markdown, then retrieve what matters with optional [qmd](https://github.com/tobi/qmd) search.
3
+ **Your agent forgets everything. AgentMemory doesn't.**
4
+
5
+ Every new session with [Claude Code](https://claude.ai/code), [Codex](https://github.com/openai/codex), or [Cursor](https://cursor.com) starts cold — the decisions you made yesterday are gone, and you explain them again. AgentMemory gives your agents a persistent, local, plain-Markdown memory that survives across sessions and models.
6
+
7
+ ```bash
8
+ npm install -g myagentmemory
9
+ agent-memory setup # one-shot: memory dir, skills, hooks, MCP, local Pro preview
10
+ ```
11
+
12
+ Then open your agent and ask *"what do you remember about me?"* — that's the wow.
4
13
 
5
14
  [![npm version](https://img.shields.io/npm/v/myagentmemory?color=cb3837&logo=npm)](https://www.npmjs.com/package/myagentmemory)
6
15
  [![npm downloads](https://img.shields.io/npm/dm/myagentmemory?color=cb3837&logo=npm)](https://www.npmjs.com/package/myagentmemory)
7
16
  [![license](https://img.shields.io/npm/l/myagentmemory)](LICENSE)
8
17
  [![website](https://img.shields.io/badge/website-jayzeng.github.io%2Fagentmemory-0d9b7a)](https://jayzeng.github.io/agentmemory/)
9
18
 
10
- [Website and quickstart](https://jayzeng.github.io/agentmemory/) · [Field report: lessons from 1,000+ coding-agent sessions](https://www.jayzeng.com/writing/agentmemory-field-report/) · [Install](#installation) · [CLI commands](#cli-commands) · [How it works](#how-it-works)
19
+ [Website and quickstart](https://jayzeng.github.io/agentmemory/) · [Field report: 1,000+ coding-agent sessions](https://www.jayzeng.com/writing/agentmemory-field-report/) · [Install](#installation) · [CLI commands](#cli-commands) · [How it works](#how-it-works)
11
20
 
12
- > **Field report:** “A session records what the agent did. Memory is a judgment about what the next agent should know.” Read [What 1000+ coding agent sessions taught me about LLM memory](https://www.jayzeng.com/writing/agentmemory-field-report/).
21
+ ## Why AgentMemory
13
22
 
14
- ## Why AgentMemory?
23
+ - AgentMemory injects your decisions, scratchpad, and daily log at session start — no copy-paste, no re-explaining.
24
+ - Repeated corrections become durable memory you can inspect and undo (Pro).
25
+ - Every memory is a plain Markdown file you own. Memory content, session content, queries, and repository paths stay on this machine.
15
26
 
16
- Coding-agent sessions preserve activity. They do not decide which facts, decisions, and follow-ups should remain useful tomorrow. AgentMemory gives that accumulated state explicit lifetimes, a user-controlled home, and a path back into future work.
27
+ AgentMemory does not provide a Python SDK, does not provide a vector database, and does not provide a knowledge graph. It is a local Markdown store with a CLI, agent skills, and optional full-text and semantic search via [qmd](https://github.com/tobi/qmd). See [product boundary](docs/product-boundary.md) for full scope.
17
28
 
18
- - **Different lifetimes and scopes** route short-lived follow-ups, chronological evidence, continuing topics, and durable decisions to the right destination.
19
- - **Curated continuity** — retain judgments that should affect future work instead of warehousing every transcript and abandoned path.
20
- - **Plain Markdown, local-first** — read, edit, diff, back up, or delete every memory. No database, cloud service, or lock-in.
21
- - **Optional retrieval** — skills load base context at session start and search related memories explicitly when a task needs them; qmd adds keyword, semantic, and hybrid search.
22
- - **Shared across agents** — Claude Code, Codex, Cursor, and Agent can use the same store even as models and harnesses change.
23
- - **Correctable state** — provenance, temporal status, secret screening, supersession, and forgetting help keep retained memory aligned with reality.
29
+ > **Field report:** "A session records what the agent did. Memory is a judgment about what the next agent should know." Read [What 1,000+ coding agent sessions taught me about LLM memory](https://www.jayzeng.com/writing/agentmemory-field-report/).
24
30
 
25
- > **Naming:** `agentmemory` is the GitHub repo (and Homebrew tap), `myagentmemory` is the npm package, and `agent-memory` is the installed CLI binary. Also known as *coding agent memory* or *AI coding memory*.
31
+ > **Naming:** `agentmemory` is the GitHub repo (and Homebrew tap), `myagentmemory` is the npm package, and `agent-memory` is the installed CLI binary. Free and MIT-licensed. See [product boundary](docs/product-boundary.md) for what it isn't.
26
32
 
27
- ### Product boundary
33
+ ### AgentMemory Pro preview
28
34
 
29
- AgentMemory is free, open-source software under the MIT License. The core is a local Markdown store with a CLI, optional qmd search, and agent skills, and it remains fully usable without an account or commercial plugin. It does not automatically import every vendor transcript or silently decide what becomes durable. It is not a Python SDK, vector database, or knowledge graph. The Markdown files remain the source of truth.
35
+ **Core remembers what you save. Pro learns from what you do.** Core remains free, MIT-licensed, and useful forever. Pro adds three things:
30
36
 
31
- ### Optional official plugins
37
+ - **Remember past sessions** — ask *"what did we decide about auth?"* across Claude Code, Codex, and Cursor.
38
+ - **Learn from your patterns** — turn repeated corrections into memory you can inspect and undo.
39
+ - **Private by default** — memory and session content index locally. Pro installation uses a pseudonymous installation identifier and bounded compatibility metadata, never your memory or session content.
32
40
 
33
- The MIT-licensed core can discover and host separately distributed, signed first-party plugins while remaining fully useful on its own. Optional plugins may use their own license and distribution terms; their implementation and browser assets are not part of the `myagentmemory` package. `agent-memory plugin list` and `plugin status` report local state. In an interactive terminal, `agent-memory plugin install` opens a nonce-bound loopback page for an email address, resumes the waiting command, verifies signed release metadata and the downloaded bundle, and installs atomically. The free plan uses a configurable daily agent-session allowance keyed by normalized email. D1 stores bounded activation metadata, a credential hash, and opaque SessionStart usage operations; it never receives memory, session content, queries, repository paths, raw agent session identifiers, IP addresses, or user-agent strings. Authentication and payment can extend this free activation flow later. See the [official plugin bootstrap and host contract](docs/official-plugin-bootstrap.md).
41
+ Preview what Pro would find in your existing sessions *before* installing anything:
42
+
43
+ ```bash
44
+ agent-memory pro preview # local-only scan, previews up to 50 sessions/day
45
+ agent-memory pro install # free preview, no account required
46
+ agent-memory recall "what did we decide about authentication?"
47
+ agent-memory learn
48
+ agent-memory dashboard
49
+ ```
50
+
51
+ Pre-install preview: up to 50 local sessions per day. Free installed preview: 20 recalls + 5 learning scans per local day. Memory, session, query, and repository content stay on your machine; installation sends only a pseudonymous identifier and bounded compatibility metadata. Full detail on [privacy, signing, and installation](docs/official-plugin-bootstrap.md).
34
52
 
35
53
  ## Installation
36
54
 
@@ -49,11 +67,8 @@ npm install -g myagentmemory
49
67
  bun run build:cli
50
68
  # => produces dist/agent-memory
51
69
 
52
- # Initialize memory directory
53
- agent-memory init
54
-
55
- # Install skill files for Claude Code, Codex, Cursor, and Agent
56
- agent-memory install-skills
70
+ # One-shot setup: memory dir, qmd collection, skills, hooks, MCP registration, local Pro preview
71
+ agent-memory setup
57
72
 
58
73
  # Uninstall skill files
59
74
  agent-memory uninstall-skills
@@ -61,6 +76,8 @@ agent-memory uninstall-skills
61
76
 
62
77
  The npm package installs a platform-neutral Node.js executable. The optional Homebrew and `build:cli` paths use a native binary built for the current platform.
63
78
 
79
+ `agent-memory setup` is the recommended entry point — it is idempotent, so re-running it after an upgrade or a partial install is always safe. Pass `--skip-skills`, `--skip-hooks`, `--skip-plugin`, or `--skip-mcp` to opt out of individual steps, or `--yes --json` for scripted/CI installs. If you want the older step-by-step interactive wizard instead, `agent-memory init` still works.
80
+
64
81
  `install-skills` writes a SKILL.md into each agent's config directory:
65
82
  - `~/.claude/skills/agent-memory/SKILL.md` — Claude Code skill
66
83
  - `~/.codex/skills/agent-memory/SKILL.md` — Codex skill
@@ -77,7 +94,7 @@ If you're on Pi and prefer a native extension, use `pi-memory` (https://github.c
77
94
 
78
95
  ### Optional: Enable search with qmd
79
96
 
80
- When qmd is installed, the collection is automatically set up via `agent-memory init`.
97
+ When qmd is installed, the collection is automatically set up via `agent-memory setup` (or `init`).
81
98
 
82
99
  Note: `memory_search` **semantic**/**deep** modes require vector embeddings. If you see a warning like "need embeddings", run `qmd embed` once and retry.
83
100
 
@@ -135,23 +152,39 @@ The memory directory defaults to `~/.agent-memory/`. Override with `AGENT_MEMORY
135
152
 
136
153
  ## CLI Commands
137
154
 
155
+ Run `agent-memory help` for the full generated list, or `agent-memory <command> --help` for a command's flags and examples.
156
+
138
157
  | Command | Purpose |
139
158
  |---------|---------|
140
- | `agent-memory context [--query <text>] [--no-search]` | Build context and optionally include qmd matches for a query |
141
- | `agent-memory write --target <long_term\|daily\|topic> --content <text> [--mode append\|overwrite] [--source-uri <uri>] [--topic <name>] [--date YYYY-MM-DD]` | Write to memory files with optional provenance |
159
+ | `agent-memory setup [--yes] [--skip-skills] [--skip-hooks] [--skip-plugin] [--skip-mcp]` | One-shot idempotent installer: memory dir + skills + hooks + local Pro preview + MCP registration |
160
+ | `agent-memory context [--query <text>] [--no-search] [--layer stable\|dynamic\|full]` | Build context and optionally include qmd matches for a query |
161
+ | `agent-memory save "<text>"` | Shortcut: append a daily memory entry |
162
+ | `agent-memory note "<text>"` | Shortcut: add a scratchpad checklist item |
163
+ | `agent-memory write "<text>" --target <long_term\|daily\|topic> [--mode append\|overwrite] [--source-uri <uri>] [--topic <name>] [--date YYYY-MM-DD]` | Write to memory files with optional provenance |
142
164
  | `agent-memory read --target <long_term\|scratchpad\|daily\|list\|topic\|topics> [--date YYYY-MM-DD] [--topic <name>]` | Read memory files |
143
165
  | `agent-memory scratchpad <add\|done\|undo\|clear_done\|list> [--text <text>]` | Manage checklist |
144
- | `agent-memory search --query <text> [--mode keyword\|semantic\|deep] [--limit N]` | Search via qmd |
145
- | `agent-memory install-skills` | Install bundled SKILL.md files into local agent directories |
166
+ | `agent-memory search --query <text> [--mode keyword\|semantic\|deep] [--limit N]` | Search indexed memory via qmd |
167
+ | `agent-memory distil [--dry-run]` | Rebuild a compact MEMORY.md index from logs and topics |
168
+ | `agent-memory sync` | Update the qmd index and semantic embeddings |
169
+ | `agent-memory install-skills [--uninstall]` | Install bundled SKILL.md files into local agent directories |
146
170
  | `agent-memory uninstall-skills` | Uninstall bundled SKILL.md files from local agent directories |
147
171
  | `agent-memory completion [bash\|zsh\|fish\|powershell] [--stdout]` | Install or print shell completion |
148
- | `agent-memory install-hooks [--yes] [--only <agents>]` | Install managed session-start memory hooks |
172
+ | `agent-memory install-hooks [--yes] [--all] [--only <agents>] [--mode stable\|per-turn]` | Install managed context and memory-write reminder hooks |
149
173
  | `agent-memory uninstall-hooks [--only <agents>]` | Remove only hooks managed by AgentMemory |
150
- | `agent-memory init` | Create dirs, detect qmd, setup collection |
151
- | `agent-memory status` | Show config, qmd status, file counts |
174
+ | `agent-memory init [--yes] [--skip-skills] [--skip-hooks]` | Legacy interactive wizard; `setup` runs this as its first step |
175
+ | `agent-memory status [--probe]` | Show config, qmd status, file counts, embedding health |
176
+ | `agent-memory doctor` | One-shot health check across memory, qmd, skills, hooks, and Pro |
177
+ | `agent-memory tutorial` | Guided 3-minute walkthrough in a throwaway sandbox |
178
+ | `agent-memory pro <install\|preview\|status\|upgrade\|manage>` | Install and manage the no-account AgentMemory Pro preview |
179
+ | `agent-memory recall <query>` | Recall decisions and context from prior coding sessions with Pro |
180
+ | `agent-memory learn [--preview]` | Find repeated corrections worth remembering with Pro |
181
+ | `agent-memory dashboard [--no-browser]` | Open the private local Memory Dashboard |
152
182
  | `agent-memory plugin <list\|status\|install\|update\|uninstall\|manage>` | Discover and manage optional signed first-party plugins |
183
+ | `agent-memory serve --mcp [--register]` | Run as a Model Context Protocol (MCP) server over stdio |
184
+ | `agent-memory upgrade [--check] [--cli\|--plugin] [--yes]` | Check for and install newer CLI/Pro releases |
185
+ | `agent-memory version` | Print the installed version |
153
186
 
154
- Global flags: `--dir <path>` (override directory), `--json` (machine output)
187
+ Global flags: `--dir <path>` (override directory), `--json` (machine output), `--help`, `--version`
155
188
 
156
189
  ### memory_search modes
157
190
 
@@ -202,13 +235,15 @@ The context builder emits the following sections in priority order. Installed sk
202
235
 
203
236
  Total output, including headings and truncation notices, is hard-capped at 16,000 characters. Explicitly untrusted, expired, superseded, revoked, or retired blocks are excluded; legacy secret-like values are redacted before injection. When qmd is unavailable, the relevant-memory step is skipped and the rest still works.
204
237
 
205
- Claude Code loads base context through the skill's shell injection. Codex, Cursor, and Agent run the same base command at session start. The bundled skills use explicit search when a task relates to prior work; they make no host-level guarantee of automatic retrieval.
238
+ Supported detected hosts can receive managed automatic context hooks after `agent-memory install-hooks`; Claude Code also receives a periodic memory-write reminder. Bundled skills remain the portable fallback and use explicit search when a task relates to prior work.
239
+
240
+ `context --layer` can request a subset instead of the full six-section build: `stable` (scratchpad + topics + MEMORY.md — durable facts unlikely to change with the current prompt), `dynamic` (today's log + qmd search + yesterday's log — turn-scoped, prompt-dependent), or `full` (default, all six sections). This backs the hook system's two install modes (`install-hooks --mode stable|per-turn` / `AGENT_MEMORY_HOOK_MODE`): `per-turn` (the default) installs a SessionStart hook that loads the `stable` layer once plus a UserPromptSubmit hook that reloads the `dynamic` layer every turn; `stable` mode installs SessionStart only, loading the `full` context once per session.
206
241
 
207
242
  ### Selective injection
208
243
 
209
- When qmd is available and `context --query` is supplied, the CLI sanitizes the query, limits it to 200 characters, and includes the top three keyword results with the standard context. Programmatic integrations should spawn the CLI with an argument array so query text is not evaluated by a shell.
244
+ When qmd is available and `context --query` is supplied, the CLI sanitizes the query, limits it to 200 characters, and runs one fused `qmd` query (BM25 + vector, reciprocal-rank-fused server-side) against the current prompt, including the top three hits with the standard context. Programmatic integrations should spawn the CLI with an argument array so query text is not evaluated by a shell.
210
245
 
211
- The search has a 3-second timeout and fails silently. If qmd is down or the query returns nothing, injection falls back to the standard behavior.
246
+ The search has an 8-second timeout and fails silently. If qmd is down or the query returns nothing, injection falls back to the standard behavior.
212
247
 
213
248
  ### Provenance, temporal state, and secret screening
214
249
 
@@ -232,7 +267,7 @@ These are content conventions, not enforced metadata. qmd's full-text indexing m
232
267
 
233
268
  - **Persistence**: Memory files are plain markdown on disk — readable, editable, and git-friendly.
234
269
  - **Tool response previews**: Write/scratchpad tools return size-capped previews instead of full file contents.
235
- - **qmd auto-setup**: Via `agent-memory init`, the collection and path contexts are created automatically.
270
+ - **qmd auto-setup**: Via `agent-memory setup` (or `init`), the collection and path contexts are created automatically.
236
271
  - **qmd re-indexing**: After every write, a debounced `qmd update` runs in the background (fire-and-forget, non-blocking) unless disabled via `AGENT_MEMORY_QMD_UPDATE`.
237
272
  - **qmd embeddings**: Semantic/deep search needs vector embeddings. If you see "need embeddings" warnings, run `qmd embed` once and retry.
238
273
  - **Graceful degradation**: If qmd is not installed, core tools work fine. `memory_search` returns install instructions.
@@ -243,7 +278,10 @@ These are content conventions, not enforced metadata. qmd's full-text indexing m
243
278
  |----------|--------|---------|-------------|
244
279
  | `AGENT_MEMORY_DIR` | path | `~/.agent-memory` | Memory directory |
245
280
  | `AGENT_MEMORY_QMD_UPDATE` | `background`, `manual`, `off` | `background` | Controls automatic `qmd update` after writes |
281
+ | `AGENT_MEMORY_QMD_EMBED` | `background`, `manual`, `off` | `background` | Controls automatic embedding generation after `init`/`setup` |
246
282
  | `AGENT_MEMORY_PLUGIN_DIR` | path | `~/.agent-memory/system/plugins` | Machine-local official plugin installation root; independent of `AGENT_MEMORY_DIR` |
283
+ | `AGENT_MEMORY_HOOK_MODE` | `stable`, `per-turn` | `per-turn` | SessionStart-only vs. SessionStart + UserPromptSubmit hook installation |
284
+ | `AGENT_MEMORY_SKILLS_ROOT` | path | auto-detected | Override where `install-skills`/`setup` look for the bundled `skills/` directory |
247
285
 
248
286
  ## Running tests
249
287
 
@@ -284,7 +322,7 @@ agent-memory install-skills
284
322
 
285
323
  ## Publishing (maintainers)
286
324
 
287
- Publication is tag-driven through `.github/workflows/publish-npm.yml`. Configure `jayzeng/agentmemory` and `publish-npm.yml` as the npm trusted publisher for `myagentmemory`, merge a versioned changelog/package update, and push the matching `v<version>` tag. The workflow uses short-lived OIDC credentials, runs the complete release gate, and publishes the public package with provenance. Do not publish this package from the private plugin workspace.
325
+ Publication is tag-driven through `.github/workflows/publish-npm.yml`. Configure the repository's `NPM_TOKEN` secret with publish access to `myagentmemory`, merge a versioned changelog/package update, and push the matching `v<version>` tag. The workflow runs the complete release gate and publishes the public package. Do not publish this package from the private plugin workspace.
288
326
 
289
327
  ### Repository assets (maintainers)
290
328
 
@@ -294,40 +332,12 @@ Publication is tag-driven through `.github/workflows/publish-npm.yml`. Configure
294
332
 
295
333
  ## Acknowledgments
296
334
 
297
- Inspired by [skyfallsin/pi-mem](https://github.com/skyfallsin/pi-mem). Semantic search is powered by [qmd](https://github.com/tobi/qmd).
298
-
299
- ## Changelog
335
+ AgentMemory contains portions adapted from [pi-mem](https://github.com/jo-inc/pi-mem), used under its MIT License; the upstream copyright notice is preserved in [LICENSE](LICENSE). Semantic search is powered by [qmd](https://github.com/tobi/qmd).
300
336
 
301
- ### 0.4.12
337
+ ## Copyright and commercial licensing
302
338
 
303
- - **Removed pi extension**: Removed `index.ts` and all pi-specific code (`@mariozechner/pi-ai`, `@mariozechner/pi-coding-agent`, `@sinclair/typebox` peer dependencies).
304
- - **Standalone tool functions**: Extracted `memoryWrite()`, `memoryRead()`, `scratchpadAction()`, `memorySearch()` into `src/core.ts` as standalone functions usable without any framework.
305
- - **Renamed package**: `pi-memory` → `myagentmemory` (npm); the CLI binary is `agent-memory`.
306
- - **Renamed env var**: `PI_MEMORY_QMD_UPDATE` → `AGENT_MEMORY_QMD_UPDATE` (old name still works as fallback).
307
- - **Default memory directory**: Now always `~/.agent-memory/`.
308
- - **Removed pi-specific tests**: Deleted `test/e2e.ts`, `test/eval-recall.ts`, `test/unit.ts`.
339
+ AgentMemory Core is released under the MIT License. Jay Zeng retains copyright in his original contributions and may also offer commercial products or differently licensed versions of code for which he holds the necessary rights. Existing MIT grants remain valid, and adapted upstream portions remain subject to their preserved copyright notices and license terms.
309
340
 
310
- ### 0.4.0
311
-
312
- - **Multi-platform support**: Memory system now works with Claude Code and OpenAI Codex via CLI + skills, in addition to pi.
313
- - **Extracted shared core**: `src/core.ts` contains platform-agnostic logic (paths, truncation, scratchpad, context builder, qmd) with zero pi peer dependencies.
314
- - **CLI binary**: `agent-memory` CLI with subcommands: `context`, `write`, `read`, `scratchpad`, `search`, `init`, `status`.
315
- - **Skill files**: `skills/claude-code/SKILL.md` and `skills/codex/SKILL.md` for installation into respective platforms.
316
- - **Configurable memory directory**: `AGENT_MEMORY_DIR` env var or `--dir` flag (default: `~/.agent-memory/`).
317
- - **CLI tests**: `test/cli.test.ts` with unit and subprocess tests.
318
-
319
- ### 0.2.0
320
-
321
- - **Selective injection**: Before each turn, the user's prompt is searched against memory via qmd. Top results are injected into the system prompt alongside standard context, surfacing relevant past decisions without explicit tool calls.
322
- - **qmd auto-setup**: The extension automatically creates the collection and path contexts on session start when qmd is available. No manual `qmd collection add` needed.
323
- - **Tags and links**: `memory_write` and context injection now encourage `#tags` and `[[wiki-links]]` as searchable content conventions.
324
- - **Context priority reordering**: Injection order is now scratchpad > today > search results > MEMORY.md > yesterday.
325
- - **Unit tests**: Added deterministic tests (no LLM/qmd needed).
326
- - **Recall eval**: Added recall effectiveness evaluation.
327
-
328
- ### 0.1.0
341
+ ## Changelog
329
342
 
330
- - Initial release: `memory_write`, `memory_read`, `scratchpad`, `memory_search` tools.
331
- - Context injection of MEMORY.md, scratchpad, and today/yesterday daily logs.
332
- - qmd integration for keyword, semantic, and hybrid search.
333
- - Debounced background `qmd update` after writes.
343
+ See [CHANGELOG.md](CHANGELOG.md) for the full release history.
@@ -6,7 +6,7 @@ export interface CliOptionSpec {
6
6
  kind: CliValueKind;
7
7
  };
8
8
  }
9
- export declare const COMMANDS: readonly ["context", "write", "read", "scratchpad", "search", "distil", "sync", "init", "status", "install-skills", "uninstall-skills", "install-hooks", "uninstall-hooks", "completion", "plugin", "version", "help"];
9
+ export declare const COMMANDS: readonly ["context", "save", "note", "write", "read", "scratchpad", "search", "distil", "sync", "setup", "status", "doctor", "tutorial", "install-skills", "uninstall-skills", "install-hooks", "uninstall-hooks", "completion", "pro", "recall", "learn", "dashboard", "plugin", "serve", "upgrade", "version", "help"];
10
10
  export declare const PLUGIN_COMMANDS: readonly ["list", "status", "install", "update", "uninstall", "manage"];
11
11
  export declare const WORKER_ACTIONS: readonly [];
12
12
  export declare const SCRATCHPAD_ACTIONS: readonly ["add", "done", "undo", "clear_done", "list"];
@@ -23,3 +23,9 @@ export declare const OPTION_SPECS: Record<string, CliOptionSpec>;
23
23
  export declare const SHELL_DESCRIPTIONS: Record<string, string>;
24
24
  export declare function optionDescription(option: string): string;
25
25
  export declare function optionTakesValue(option: string): boolean;
26
+ /**
27
+ * Render per-command help using existing spec metadata. Called when the user
28
+ * runs `agent-memory <cmd> --help` — should list the command's real flags with
29
+ * descriptions and one or two concrete examples, not the top-level command list.
30
+ */
31
+ export declare function renderCommandHelp(command: string): string;
package/dist/cli-spec.js CHANGED
@@ -1,19 +1,29 @@
1
1
  export const COMMANDS = [
2
2
  "context",
3
+ "save",
4
+ "note",
3
5
  "write",
4
6
  "read",
5
7
  "scratchpad",
6
8
  "search",
7
9
  "distil",
8
10
  "sync",
9
- "init",
11
+ "setup",
10
12
  "status",
13
+ "doctor",
14
+ "tutorial",
11
15
  "install-skills",
12
16
  "uninstall-skills",
13
17
  "install-hooks",
14
18
  "uninstall-hooks",
15
19
  "completion",
20
+ "pro",
21
+ "recall",
22
+ "learn",
23
+ "dashboard",
16
24
  "plugin",
25
+ "serve",
26
+ "upgrade",
17
27
  "version",
18
28
  "help",
19
29
  ];
@@ -22,22 +32,32 @@ export const WORKER_ACTIONS = [];
22
32
  export const SCRATCHPAD_ACTIONS = ["add", "done", "undo", "clear_done", "list"];
23
33
  export const COMMAND_DESCRIPTIONS = {
24
34
  context: "build context from scratchpad, logs, topics, and long-term memory",
35
+ save: 'shortcut: agent-memory save "<text>" → daily memory entry',
36
+ note: 'shortcut: agent-memory note "<text>" → scratchpad checklist item',
25
37
  write: "append or overwrite a daily, topic, or long-term memory entry",
26
38
  read: "read daily, topic, scratchpad, or long-term memory",
27
39
  scratchpad: "add, complete, reopen, list, or clear persistent checklist items",
28
40
  search: "search indexed memory with keyword, semantic, or deep qmd modes",
29
41
  distil: "rebuild a compact MEMORY.md index from logs and topics",
30
42
  sync: "update the qmd index and semantic embeddings",
31
- init: "create memory storage and configure qmd when available",
43
+ setup: "one-shot idempotent installer: init + skills + hooks + plugin + mcp",
32
44
  status: "show memory paths, file counts, qmd, and embedding health",
45
+ doctor: "run a one-shot health check across memory, qmd, skills, hooks, and Pro",
46
+ tutorial: "guided 3-minute walkthrough in a throwaway sandbox",
33
47
  "install-skills": "install core instructions for detected agents",
34
48
  "uninstall-skills": "remove core instructions from detected agents",
35
- "install-hooks": "install automatic SessionStart indexing and context hooks",
36
- "uninstall-hooks": "remove only SessionStart hooks managed by agent-memory",
49
+ "install-hooks": "install managed context and memory-write reminder hooks",
50
+ "uninstall-hooks": "remove only hooks managed by agent-memory",
37
51
  completion: "install or print Bash, Zsh, Fish, or PowerShell completion",
38
- plugin: "index, recall, learn from, and evaluate prior agent sessions",
52
+ pro: "install, inspect, or upgrade AgentMemory Pro",
53
+ recall: "recall decisions and context from prior coding sessions with Pro",
54
+ learn: "find repeated corrections worth remembering with Pro",
55
+ dashboard: "open the private local Memory Dashboard",
56
+ plugin: "discover, install, update, or remove optional official plugins",
57
+ serve: "run as a Model Context Protocol (MCP) server over stdio",
58
+ upgrade: "check for and install newer agent-memory CLI and Pro plugin releases",
39
59
  version: "print the installed agent-memory version",
40
- help: "show top-level, command, or nested plugin help",
60
+ help: "show this command overview",
41
61
  };
42
62
  export const PLUGIN_COMMAND_DESCRIPTIONS = {
43
63
  list: "list optional official plugins and local availability",
@@ -57,20 +77,41 @@ export const SCRATCHPAD_ACTION_DESCRIPTIONS = {
57
77
  };
58
78
  export const GLOBAL_OPTIONS = ["--dir", "--json", "--help", "--version", "-h", "-V"];
59
79
  export const COMMAND_OPTIONS = {
60
- context: ["--query", "--no-search"],
80
+ context: ["--query", "--no-search", "--layer"],
81
+ save: ["--target"],
82
+ note: [],
61
83
  write: ["--content", "--target", "--mode", "--topic", "--date", "--source-uri"],
62
84
  read: ["--target", "--date", "--topic"],
63
85
  scratchpad: ["--text"],
64
86
  search: ["--query", "--mode", "--limit"],
65
87
  distil: ["--dry-run"],
66
88
  sync: [],
67
- init: [],
89
+ init: ["--yes", "--skip-skills", "--skip-hooks"],
90
+ setup: ["--yes", "--skip-skills", "--skip-hooks", "--skip-plugin", "--skip-mcp"],
68
91
  status: ["--probe"],
69
- "install-skills": [],
92
+ doctor: [],
93
+ tutorial: [],
94
+ "install-skills": ["--uninstall"],
70
95
  "uninstall-skills": [],
71
- "install-hooks": ["--yes", "--all", "--only"],
96
+ "install-hooks": ["--yes", "--all", "--only", "--mode"],
72
97
  "uninstall-hooks": ["--only"],
73
98
  completion: ["--stdout"],
99
+ pro: [],
100
+ recall: [
101
+ "--scope",
102
+ "--cwd",
103
+ "--limit",
104
+ "--context",
105
+ "--queries",
106
+ "--multi",
107
+ "--sessions",
108
+ "--events",
109
+ "--per-query",
110
+ ],
111
+ learn: ["--preview"],
112
+ dashboard: ["--no-browser"],
113
+ serve: ["--mcp", "--register", "--only"],
114
+ upgrade: ["--check", "--refresh", "--yes", "--quiet", "--cli", "--plugin"],
74
115
  version: [],
75
116
  help: [],
76
117
  };
@@ -81,6 +122,12 @@ export const PLUGIN_COMMAND_OPTIONS = {
81
122
  update: ["--channel"],
82
123
  uninstall: ["--yes"],
83
124
  manage: ["--no-browser"],
125
+ // Plugin runtime commands forwarded to the installed bundle
126
+ index: ["--date", "--since"],
127
+ recall: ["--query", "--limit", "--cwd", "--host", "--mode"],
128
+ worker: ["--token"],
129
+ learn: ["--limit", "--dry-run"],
130
+ eval: ["--limit"],
84
131
  };
85
132
  export const WORKER_ACTION_OPTIONS = {};
86
133
  export const SCRATCHPAD_ACTION_OPTIONS = {
@@ -101,7 +148,14 @@ export const OPTION_SPECS = {
101
148
  "--no-search": { description: "build context without invoking qmd" },
102
149
  "--content": { description: "memory entry content to persist", value: { label: "text", kind: "value" } },
103
150
  "--target": { description: "memory destination or collection to read", value: { label: "target", kind: "value" } },
104
- "--mode": { description: "write behavior or qmd search strategy", value: { label: "mode", kind: "value" } },
151
+ "--mode": {
152
+ description: "write behavior, qmd search strategy, or hook mode (stable|per-turn)",
153
+ value: { label: "mode", kind: "value" },
154
+ },
155
+ "--layer": {
156
+ description: "context layer to emit: stable, dynamic, or full (default)",
157
+ value: { label: "layer", kind: "value" },
158
+ },
105
159
  "--topic": { description: "topic name used to resolve a topic file", value: { label: "name", kind: "value" } },
106
160
  "--date": { description: "daily-log date in YYYY-MM-DD form", value: { label: "date", kind: "value" } },
107
161
  "--source-uri": {
@@ -120,8 +174,13 @@ export const OPTION_SPECS = {
120
174
  "--state": { description: "override the plugin state root", value: { label: "directory", kind: "directory" } },
121
175
  "--with-plugin": { description: "include both the core and optional plugin skills" },
122
176
  "--plugin-only": { description: "operate only on the optional plugin skill" },
123
- "--yes": { description: "apply eligible hook changes without confirmation" },
177
+ "--yes": { description: "apply eligible changes without interactive prompts" },
124
178
  "--all": { description: "apply eligible hook changes without confirmation" },
179
+ "--skip-skills": { description: "init: don't prompt to install agent skills" },
180
+ "--skip-hooks": { description: "init: don't prompt to install SessionStart hooks" },
181
+ "--skip-plugin": { description: "setup: don't offer to install the paid plugin bundle" },
182
+ "--skip-mcp": { description: "setup: don't register the MCP server in detected local harnesses" },
183
+ "--preview": { description: "learn: show detected patterns without writing or consuming quota" },
125
184
  "--only": {
126
185
  description: "restrict hook changes to comma-separated agent keys",
127
186
  value: { label: "agents", kind: "value" },
@@ -144,6 +203,23 @@ export const OPTION_SPECS = {
144
203
  description: "surrounding events included with each recall hit",
145
204
  value: { label: "number", kind: "number" },
146
205
  },
206
+ "--queries": {
207
+ description: "JSON array of query strings for one-shot multi-query recall",
208
+ value: { label: "json", kind: "value" },
209
+ },
210
+ "--multi": { description: "treat each positional argument as a separate recall query" },
211
+ "--sessions": {
212
+ description: "maximum sessions returned by multi-query recall",
213
+ value: { label: "number", kind: "number" },
214
+ },
215
+ "--events": {
216
+ description: "top events per session returned by multi-query recall",
217
+ value: { label: "number", kind: "number" },
218
+ },
219
+ "--per-query": {
220
+ description: "candidate hits considered per query before fusion",
221
+ value: { label: "number", kind: "number" },
222
+ },
147
223
  "--pi": { description: "override the Pi session root", value: { label: "directory", kind: "directory" } },
148
224
  "--codex": { description: "override the Codex session root", value: { label: "directory", kind: "directory" } },
149
225
  "--claude": {
@@ -196,6 +272,13 @@ export const OPTION_SPECS = {
196
272
  "--agent": { description: "internal SessionStart host key", value: { label: "agent", kind: "value" } },
197
273
  "--token": { description: "internal session-worker lease token", value: { label: "token", kind: "value" } },
198
274
  "--uninstall": { description: "use install-skills compatibility uninstall mode" },
275
+ "--mcp": { description: "serve as an MCP server over stdio (used by Claude Code)" },
276
+ "--register": { description: "register the MCP server in detected supported agents and exit" },
277
+ "--check": { description: "upgrade: report available updates without installing" },
278
+ "--refresh": { description: "upgrade: force a live registry lookup and rewrite the 24h cache" },
279
+ "--quiet": { description: "upgrade: suppress non-error output (used by the passive session-start refresh)" },
280
+ "--cli": { description: "upgrade: limit action to the CLI binary" },
281
+ "--plugin": { description: "upgrade: limit action to the Pro plugin bundle" },
199
282
  };
200
283
  export const SHELL_DESCRIPTIONS = {
201
284
  bash: "generate or install Bash completion",
@@ -209,3 +292,134 @@ export function optionDescription(option) {
209
292
  export function optionTakesValue(option) {
210
293
  return OPTION_SPECS[option]?.value !== undefined;
211
294
  }
295
+ // One-line usage template per command — shows the shape agents/humans should type.
296
+ const COMMAND_USAGE = {
297
+ context: 'agent-memory context [--query "text"] [--no-search] [--json]',
298
+ save: 'agent-memory save "<text>" [--target daily|topic|long_term]',
299
+ note: 'agent-memory note "<text>"',
300
+ write: 'agent-memory write "<text>" [--target daily|topic|long_term] [--mode append|overwrite] [--topic <name>] [--date YYYY-MM-DD]',
301
+ read: "agent-memory read [--target daily|topic|long_term|scratchpad] [--date YYYY-MM-DD] [--topic <name>]",
302
+ scratchpad: 'agent-memory scratchpad <add|done|undo|clear_done|list> [--text "text"]',
303
+ search: 'agent-memory search --query "text" [--mode keyword|semantic|deep] [--limit N]',
304
+ distil: "agent-memory distil [--dry-run]",
305
+ sync: "agent-memory sync",
306
+ init: "agent-memory init [--yes] [--skip-skills] [--skip-hooks]",
307
+ setup: "agent-memory setup [--yes] [--json]",
308
+ status: "agent-memory status [--probe] [--json]",
309
+ doctor: "agent-memory doctor [--json]",
310
+ tutorial: "agent-memory tutorial",
311
+ "install-skills": "agent-memory install-skills [--json]",
312
+ "uninstall-skills": "agent-memory uninstall-skills [--json]",
313
+ "install-hooks": "agent-memory install-hooks [--yes] [--all] [--only claude,codex,cursor] [--mode stable|per-turn] [--json]",
314
+ "uninstall-hooks": "agent-memory uninstall-hooks [--only claude,codex,cursor] [--json]",
315
+ completion: "agent-memory completion [bash|zsh|fish|powershell] [--stdout]",
316
+ pro: "agent-memory pro <install|status|upgrade> [--channel stable] [--yes]",
317
+ recall: '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]',
318
+ learn: "agent-memory learn [--preview] [--json]",
319
+ dashboard: "agent-memory dashboard [--no-browser]",
320
+ plugin: "agent-memory plugin <list|status|install|update|uninstall|manage> [--channel stable] [--yes] [--no-browser]",
321
+ upgrade: "agent-memory upgrade [--check] [--yes] [--cli|--plugin] [--refresh] [--json]",
322
+ version: "agent-memory version",
323
+ help: "agent-memory help [<command>]",
324
+ };
325
+ // Concrete examples per command — what an agent or dev is most likely to want.
326
+ const COMMAND_EXAMPLES = {
327
+ save: [
328
+ 'agent-memory save "shipped the new recall path — bundle at 1.2.3"',
329
+ 'agent-memory save --target long_term "prefer bun test over npm test in example-api"',
330
+ ],
331
+ note: ['agent-memory note "verify the digest backfill against a real corpus"'],
332
+ write: [
333
+ 'agent-memory write "keep sessions in reverse-chron order" --target long_term --mode overwrite',
334
+ 'agent-memory write "half-line summary" --target topic --topic scheduling-machine',
335
+ ],
336
+ read: [
337
+ "agent-memory read --target long_term",
338
+ "agent-memory read --target daily --date 2026-08-24",
339
+ "agent-memory read --target topic --topic scheduling-machine",
340
+ ],
341
+ scratchpad: [
342
+ 'agent-memory scratchpad add --text "chase down the flake in test/web.test.ts"',
343
+ 'agent-memory scratchpad done --text "chase down the flake"',
344
+ "agent-memory scratchpad list",
345
+ ],
346
+ search: [
347
+ 'agent-memory search --query "API test collection credentials"',
348
+ 'agent-memory search --query "grafana alert routing" --mode semantic --limit 10',
349
+ ],
350
+ recall: [
351
+ 'agent-memory recall "API test collection for booking service"',
352
+ 'agent-memory recall --queries \'["API test collection for booking service","booking client integration","client credential setup"]\' --sessions 5',
353
+ 'agent-memory recall "auth refresh" --scope current --limit 5',
354
+ ],
355
+ context: ["agent-memory context", 'agent-memory context --query "grafana alerts" --json'],
356
+ status: ["agent-memory status", "agent-memory status --json"],
357
+ init: ["agent-memory init", "agent-memory init --yes --skip-hooks"],
358
+ setup: ["agent-memory setup", "agent-memory setup --json"],
359
+ "install-hooks": [
360
+ "agent-memory install-hooks",
361
+ "agent-memory install-hooks --yes",
362
+ "agent-memory install-hooks --only claude,codex",
363
+ "agent-memory install-hooks --mode stable # SessionStart only (skip UserPromptSubmit)",
364
+ ],
365
+ distil: ["agent-memory distil", "agent-memory distil --dry-run"],
366
+ learn: ["agent-memory learn", "agent-memory learn --preview # see patterns without consuming quota or writing"],
367
+ };
368
+ /**
369
+ * Render per-command help using existing spec metadata. Called when the user
370
+ * runs `agent-memory <cmd> --help` — should list the command's real flags with
371
+ * descriptions and one or two concrete examples, not the top-level command list.
372
+ */
373
+ export function renderCommandHelp(command) {
374
+ const canonical = command === "distill" ? "distil" : command;
375
+ const known = new Set([...COMMANDS, "distill", "setup"]);
376
+ if (!known.has(canonical)) {
377
+ return `agent-memory: unknown command '${command}'. Run 'agent-memory help' for the full list.`;
378
+ }
379
+ const description = COMMAND_DESCRIPTIONS[canonical] ??
380
+ (canonical === "setup" ? "one-shot idempotent installer: init + skills + hooks + plugin + mcp" : "");
381
+ const usage = COMMAND_USAGE[canonical] ?? `agent-memory ${canonical} [options]`;
382
+ const options = COMMAND_OPTIONS[canonical] ?? [];
383
+ const examples = COMMAND_EXAMPLES[canonical] ?? [];
384
+ const optLines = [];
385
+ // Command-specific options
386
+ for (const opt of options) {
387
+ const spec = OPTION_SPECS[opt];
388
+ if (!spec)
389
+ continue;
390
+ const label = spec.value ? `${opt} <${spec.value.label}>` : opt;
391
+ optLines.push(` ${label.padEnd(24)} ${spec.description}`);
392
+ }
393
+ // Global options that are always available
394
+ const globalKeys = ["--dir", "--json", "--help", "--version"];
395
+ const globalLines = globalKeys
396
+ .map((opt) => {
397
+ const spec = OPTION_SPECS[opt];
398
+ if (!spec)
399
+ return "";
400
+ const label = spec.value ? `${opt} <${spec.value.label}>` : opt;
401
+ return ` ${label.padEnd(24)} ${spec.description}`;
402
+ })
403
+ .filter(Boolean);
404
+ // Command-specific subactions
405
+ let subactionLines = "";
406
+ if (canonical === "scratchpad") {
407
+ subactionLines = `\nActions:\n${SCRATCHPAD_ACTIONS.map((a) => ` ${a.padEnd(24)} ${SCRATCHPAD_ACTION_DESCRIPTIONS[a]}`).join("\n")}\n`;
408
+ }
409
+ if (canonical === "plugin" || canonical === "pro") {
410
+ subactionLines = `\nSubcommands:\n${PLUGIN_COMMANDS.map((a) => ` ${a.padEnd(24)} ${PLUGIN_COMMAND_DESCRIPTIONS[a]}`).join("\n")}\n`;
411
+ }
412
+ const parts = [`agent-memory ${canonical} — ${description}`, "", "Usage:", ` ${usage}`];
413
+ if (subactionLines)
414
+ parts.push(subactionLines);
415
+ if (optLines.length)
416
+ parts.push("\nOptions:", ...optLines);
417
+ if (globalLines.length)
418
+ parts.push("\nGlobal:", ...globalLines);
419
+ if (examples.length) {
420
+ parts.push("\nExamples:");
421
+ for (const ex of examples)
422
+ parts.push(` $ ${ex}`);
423
+ }
424
+ return parts.join("\n");
425
+ }