open-memex 0.4.0-alpha.10 → 0.4.0-alpha.12

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 CHANGED
@@ -1,15 +1,77 @@
1
1
  # open-memex
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/open-memex.svg)](https://www.npmjs.com/package/open-memex)
4
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
5
+
3
6
  [中文文档](./README.zh-CN.md)
4
7
 
5
8
  Local-first persistent memory for AI coding agents: an [opencode](https://opencode.ai) plugin
6
9
  plus a generic MCP server (VS Code Copilot, Cursor, Claude Code, Visual Studio, …).
7
10
 
11
+ ## Why open-memex?
12
+
13
+ Engineering knowledge lives in two places: the code, and people's heads.
14
+ Every new AI coding session starts from zero — the same project context gets
15
+ explained again, the same gotchas get rediscovered, the same incident lessons
16
+ fade when the chat ends.
17
+
18
+ open-memex captures the part worth remembering — the decision, the constraint,
19
+ the lesson — as reviewable Markdown, and injects it back into the next session
20
+ automatically.
21
+
22
+ > No capture, nothing to inherit.
23
+
24
+ It also complements agentic development workflows (spec-driven development,
25
+ plan/implement/verify loops): plans produce decisions, verification produces
26
+ rules — open-memex is the memory layer that keeps them across sessions instead
27
+ of re-deriving them on every run.
28
+
29
+ ## How it compares
30
+
31
+ | | open-memex | Cloud memory services | Wiki / docs portal | Chat history |
32
+ |---|---|---|---|---|
33
+ | Data location | Your machine + your repos | Vendor servers | Central server | Gone when the chat ends |
34
+ | Review before sharing | Yes — outbox + PR | Varies | Yes | No |
35
+ | Agent recall | Session-start injection + search | API calls | Manual lookup | No |
36
+ | Human-readable | Plain Markdown files | Dashboard / API | Yes | No |
37
+
8
38
  - **Markdown files** as the source of truth (human-editable, git-friendly)
9
39
  - **SQLite FTS5** as a rebuildable index (BM25 keyword search, via `better-sqlite3`)
10
40
  - **Zero cloud**, zero account, zero third-party API
11
41
  - Loads directly under opencode's embedded Bun runtime; CLI and MCP server run under Node — no build step in development (the published npm package ships pre-compiled JS), no Bun install
12
42
 
43
+ ## Architecture
44
+
45
+ ```text
46
+ ┌──────────────────┐
47
+ │ AI agent │
48
+ │ Copilot / Cursor │
49
+ │ Claude / opencode│
50
+ └────────┬─────────┘
51
+ │ MCP (stdio) — 11 tools
52
+ │ session-start injection
53
+ ┌────────▼─────────┐
54
+ │ open-memex │
55
+ │ MCP server │
56
+ └──┬────────────┬──┘
57
+ │ │
58
+ ┌────────────▼───┐ ┌─────▼──────────┐
59
+ │ Markdown files │ │ SQLite FTS5 │
60
+ │ source of truth│ │ rebuildable │
61
+ │ local-first │ │ index (BM25) │
62
+ └─────────────┬──┘ └────────────────┘
63
+ │ submit (explicit,
64
+ │ local commit)
65
+ ┌───────▼────────┐
66
+ │ Git repo │
67
+ │ .ai/open-memex/│
68
+ │ PR-reviewed │
69
+ │ team memory │
70
+ └────────────────┘
71
+
72
+ personal scope: this machine only — never synced, never enters a repo.
73
+ ```
74
+
13
75
  ## Installation
14
76
 
15
77
  ### Requirements
@@ -18,7 +80,9 @@ plus a generic MCP server (VS Code Copilot, Cursor, Claude Code, Visual Studio,
18
80
 
19
81
  ### Step 1 — Install the CLI
20
82
 
21
- **npm (recommended):**
83
+ #### Stable vs alpha
84
+
85
+ **Stable** (recommended for most users) — the `latest` tag:
22
86
 
23
87
  ```sh
24
88
  npm install -g open-memex
@@ -26,10 +90,26 @@ npm install -g open-memex
26
90
 
27
91
  This installs the `0.3.0` stable release.
28
92
 
93
+ **Alpha** (bleeding edge, for testers) — the `alpha` tag:
94
+
95
+ ```sh
96
+ npm install -g open-memex@alpha
97
+ ```
98
+
99
+ See what's published:
100
+
101
+ ```sh
102
+ npm view open-memex version # latest stable
103
+ npm view open-memex@alpha version # latest alpha
104
+ ```
105
+
106
+ Alpha builds may have rough edges — bug reports are welcome.
107
+
29
108
  **No install — run via npx:**
30
109
 
31
110
  ```sh
32
- npx -y open-memex <command> # e.g. npx -y open-memex init --client vscode
111
+ npx -y open-memex <command> # e.g. npx -y open-memex init --client vscode
112
+ npx -y open-memex@alpha <command> # alpha line, no install
33
113
  ```
34
114
 
35
115
  **From source** (bleeding edge, `V2-dev-p2` branch):
@@ -185,6 +265,62 @@ storage writability, then boots a real MCP server and runs `initialize` +
185
265
  4 characters kept, the rest replaced with `x` — and the memory is saved.
186
266
  Preview what a message would capture with `open-memex capture --dry-run "…"`.
187
267
 
268
+ ## Memory types
269
+
270
+ Eleven types — `type` says what the memory is, `tags` say what it's about:
271
+
272
+ | Type | Captures |
273
+ |---|---|
274
+ | `fact` | A stable true statement about the project or world |
275
+ | `preference` | How someone likes things done |
276
+ | `decision` | A choice that was made — the why and the trade-off |
277
+ | `constraint` | A rule that must not be violated |
278
+ | `todo` | A commitment to do something later |
279
+ | `knowledge` | Durable domain or architecture knowledge |
280
+ | `howto` | A procedure that worked |
281
+ | `gotcha` | A trap to avoid |
282
+ | `lesson` | What an incident or mistake taught us |
283
+ | `observation` | Something noticed, not yet a conclusion |
284
+ | `reference` | A pointer to the authoritative doc (no copying) |
285
+
286
+ ## Team memory workflow
287
+
288
+ Personal notes stay private. Project knowledge follows an explicit, reviewable
289
+ pipeline — nothing is shared automatically:
290
+
291
+ ```
292
+ capture → outbox (draft, local) → submit → repo (.ai/open-memex/) → PR review → published → recall
293
+ ```
294
+
295
+ 1. **Capture** — save decisions, gotchas, lessons as drafts during normal work.
296
+ 2. **Review** — drafts wait in a local outbox; `sync-status` (or saying
297
+ "sync memory" in chat) shows what's pending.
298
+ 3. **Submit** — you name the memories; they move into `<repo>/.ai/open-memex/`
299
+ with a local commit. open-memex never auto-pushes.
300
+ 4. **PR review** — memories are plain Markdown; reviewers approve, request
301
+ changes, or reject through the normal branch/PR process (`promote`,
302
+ `pr-status`, `resolve`).
303
+ 5. **Recall** — published memories are injected at session start and searchable
304
+ on demand, for humans and agents alike.
305
+
306
+ Reviewer convention: [docs/CURATOR.md](./docs/CURATOR.md).
307
+
308
+ ## Security & data
309
+
310
+ - **Local-first:** everything lives on your machine (`%APPDATA%\open-memex` /
311
+ `~/.local/share/open-memex`) plus the repos you choose. Zero cloud calls,
312
+ zero accounts, zero third-party APIs, zero telemetry.
313
+ - **Secrets stay out:** `<private>…</private>` spans are stripped; detected API
314
+ keys/tokens are masked in place before saving. Preview with
315
+ `open-memex capture --dry-run "…"`.
316
+ - **Personal never syncs:** the `personal` scope is this machine only — excluded
317
+ from export by default and can never enter a repo.
318
+ - **Auditable sharing:** team memories move only by explicit `submit`, travel
319
+ through branch/PR review, and every `promote` transition is appended to the
320
+ memory's `review_history` (who / when / why).
321
+ - **You own the files:** Markdown is the source of truth — inspect, edit, or
322
+ delete anything by hand; the SQLite index rebuilds from the files.
323
+
188
324
  ## Scopes
189
325
 
190
326
  - **project** — scoped to the current repo (keyed off the git origin URL hash, or the cwd if no remote). Default for new memories.
@@ -339,7 +475,9 @@ open-memex distill-agents [--scope project|personal] [--type t1,t2] [--limit N]
339
475
  # propose an AGENTS.md snippet distilled from project memories
340
476
  # (decisions, constraints, lessons, gotchas, howtos). Prints markdown;
341
477
  # -o writes it to a file. You review and merge by hand — open-memex
342
- # never rewrites your AGENTS.md on its own.
478
+ # never rewrites your AGENTS.md on its own. The snippet ends with a
479
+ # "memory hygiene" section (§3.5 checkpoint guidance) so agents reading
480
+ # AGENTS.md learn to propose distilled captures at checkpoints.
343
481
 
344
482
  open-memex propose <id...> --to project [--local-approve]
345
483
  # propose one or several personal memories at once (one branch, one PR);
@@ -401,28 +539,27 @@ server with cwd set to your project root (`init` handles this for you).
401
539
 
402
540
  ## Roadmap
403
541
 
404
- **`0.3.0` (this release):** generic MCP server, `open-memex` bin/CLI, one-command
542
+ **`0.3.0` (stable):** generic MCP server, `open-memex` bin/CLI, one-command
405
543
  `init` setup, Chinese keyword capture with personal/project routing, `config` /
406
544
  `capture --dry-run` / `doctor` helpers, Visual Studio support.
407
545
 
408
- **In progress — `0.4.0`:** team sync — shared memory via git: appdata draft
546
+ **`0.4.0` (in development):** team sync — shared memory via git: appdata draft
409
547
  outbox → `sync-status` → `submit` (local branch+commit, push/PR on your Yes)
410
- → `promote` / `resolve` review workflow, in-repo `.ai/open-memex/` dir, 1–2
411
- colleague pilot; capture — §3.5 checkpoint distillation in MCP handshake +
412
- init instructions (agent proposes 1–3 captures, human decides).
413
-
414
- **Coming — `0.3.0` (stable):** org layer — org memory repo, curator convention,
415
- distill-to-AGENTS.md assist, `export`/`import` archive for user portability
416
- (Markdown + manifest, no walled garden; private excluded by default,
417
- `-a`/`--all` for full migration).
418
-
419
- **Future (signal-gated, no version committed):** native agent plugins (Claude Code /
420
- Codex hooks as enhancement paths over the same MCP tools); local embeddings as a
421
- benchmark-gated experiment (no embedding model is ever downloaded without explicit
422
- opt-in); cloud `RemoteProvider` customization only if multi-repo sharing, ACL, or
423
- compliance needs demand it.
424
-
425
- Design details: [docs/V2-DESIGN.md](./docs/V2-DESIGN.md) (append-only decision log D1–D20).
548
+ → `promote` / `resolve` review workflow, in-repo `.ai/open-memex/` dir;
549
+ `export` / `import` archive for user portability (Markdown + manifest, no walled
550
+ garden; private excluded by default, `-a` / `--all` for full migration);
551
+ distill-to-AGENTS.md assist (`distill-agents`, propose-only — you merge by hand);
552
+ §3.5 checkpoint distillation in the MCP handshake + init instructions (the agent
553
+ proposes 1–3 captures at checkpoints, the human decides); 1–2 colleague pilot.
554
+
555
+ **Future (signal-gated, no version committed):** org layer — org memory repo,
556
+ curator convention; native agent plugins (Claude Code / Codex hooks as
557
+ enhancement paths over the same MCP tools); local embeddings as a
558
+ benchmark-gated experiment (no embedding model is ever downloaded without
559
+ explicit opt-in); cloud `RemoteProvider` customization only if multi-repo
560
+ sharing, ACL, or compliance needs demand it.
561
+
562
+ Design details: [docs/V2-DESIGN.md](./docs/V2-DESIGN.md) (append-only decision log).
426
563
 
427
564
  ## License
428
565
 
package/README.zh-CN.md CHANGED
@@ -1,15 +1,74 @@
1
1
  # open-memex
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/open-memex.svg)](https://www.npmjs.com/package/open-memex)
4
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
5
+
3
6
  [English](./README.md)
4
7
 
5
8
  给 AI 编程助手的本地优先持久记忆:一个 [opencode](https://opencode.ai) 插件,
6
9
  加上一个通用 MCP server(VS Code Copilot、Cursor、Claude Code、Visual Studio 等)。
7
10
 
11
+ ## 为什么需要 open-memex?
12
+
13
+ 工程知识只存在于两个地方:代码里,和人的脑子里。
14
+ 每个新的 AI 编程会话都从零开始——同样的项目背景要反复讲,同样的坑要反复踩,
15
+ 同样的事故教训在聊天结束时就消失了。
16
+
17
+ open-memex 把值得记住的部分——决策、约束、教训——存成可 review 的 Markdown,
18
+ 并在下一次会话开始时自动注入回去。
19
+
20
+ > No capture, nothing to inherit.(不记录,就无从传承。)
21
+
22
+ 它也补齐了 agentic 开发工作流(spec 驱动开发、plan/implement/verify 循环)缺的那一块:
23
+ plan 产出决策,verify 产出规则——open-memex 是让它们跨会话留存的记忆层,
24
+ 而不是每次从头重新推导。
25
+
26
+ ## 和其它方案的对比
27
+
28
+ | | open-memex | 云端记忆服务 | Wiki / 文档平台 | 聊天记录 |
29
+ |---|---|---|---|---|
30
+ | 数据在哪 | 你的机器 + 你的仓库 | 服务商服务器 | 中心服务器 | 聊天结束就没了 |
31
+ | 分享前 review | 有——outbox + PR | 不一定 | 有 | 没有 |
32
+ | Agent 回忆 | 会话开始注入 + 搜索 | 调 API | 人工去查 | 没有 |
33
+ | 人类可读 | 纯 Markdown 文件 | 后台 / API | 有 | 没有 |
34
+
8
35
  - **Markdown 文件**是 source of truth(人类可读、git 友好)
9
36
  - **SQLite FTS5** 做可重建索引(BM25 关键词检索,`better-sqlite3`)
10
37
  - **零云端**、零账号、零第三方 API
11
38
  - 直接跑在 opencode 内嵌的 Bun 运行时里;CLI 和 MCP server 跑在 Node 下——开发时无需构建(发布的 npm 包带预编译好的 JS)、无需安装 Bun
12
39
 
40
+ ## 架构
41
+
42
+ ```text
43
+ ┌──────────────────┐
44
+ │ AI agent │
45
+ │ Copilot / Cursor │
46
+ │ Claude / opencode│
47
+ └────────┬─────────┘
48
+ │ MCP (stdio) — 11 tools
49
+ │ session-start injection
50
+ ┌────────▼─────────┐
51
+ │ open-memex │
52
+ │ MCP server │
53
+ └──┬────────────┬──┘
54
+ │ │
55
+ ┌────────────▼───┐ ┌─────▼──────────┐
56
+ │ Markdown files │ │ SQLite FTS5 │
57
+ │ source of truth│ │ rebuildable │
58
+ │ local-first │ │ index (BM25) │
59
+ └─────────────┬──┘ └────────────────┘
60
+ │ submit (explicit,
61
+ │ local commit)
62
+ ┌───────▼────────┐
63
+ │ Git repo │
64
+ │ .ai/open-memex/│
65
+ │ PR-reviewed │
66
+ │ team memory │
67
+ └────────────────┘
68
+
69
+ personal scope:只属于这台机器——永不同步,永远进不了仓库。
70
+ ```
71
+
13
72
  ## 安装
14
73
 
15
74
  ### 前置要求
@@ -18,7 +77,9 @@
18
77
 
19
78
  ### 第一步——安装 CLI
20
79
 
21
- **npm(推荐):**
80
+ #### 稳定版 vs Alpha 版
81
+
82
+ **稳定版**(推荐大多数用户)——`latest` 标签:
22
83
 
23
84
  ```sh
24
85
  npm install -g open-memex
@@ -26,10 +87,26 @@ npm install -g open-memex
26
87
 
27
88
  安装的是 `0.3.0` 正式版。
28
89
 
90
+ **Alpha 版**(最新开发版,给测试者)——`alpha` 标签:
91
+
92
+ ```sh
93
+ npm install -g open-memex@alpha
94
+ ```
95
+
96
+ 查看已发布版本:
97
+
98
+ ```sh
99
+ npm view open-memex version # 最新稳定版
100
+ npm view open-memex@alpha version # 最新 alpha 版
101
+ ```
102
+
103
+ Alpha 版可能有毛边——欢迎报 bug。
104
+
29
105
  **免安装——用 npx 直接跑:**
30
106
 
31
107
  ```sh
32
- npx -y open-memex <命令> # 例如 npx -y open-memex init --client vscode
108
+ npx -y open-memex <命令> # 例如 npx -y open-memex init --client vscode
109
+ npx -y open-memex@alpha <命令> # alpha 线,免安装
33
110
  ```
34
111
 
35
112
  **从源码安装**(最新开发版,`V2-dev-p2` 分支):
@@ -180,6 +257,48 @@ open-memex doctor
180
257
  (API key、token、高熵凭据)就地打码——保留前 4 个字符,其余替换为 `x`——
181
258
  然后照常保存。用 `open-memex capture --dry-run "…"` 预览一条消息会被如何捕获。
182
259
 
260
+ ## 记忆类型(Memory types)
261
+
262
+ 11 种类型——`type` 说明这条记忆是什么,`tags` 说明它和什么有关:
263
+
264
+ | 类型 | 记录什么 |
265
+ |---|---|
266
+ | `fact` | 关于项目或世界的稳定事实 |
267
+ | `preference` | 某人做事的偏好 |
268
+ | `decision` | 做过的选择——为什么、权衡了什么 |
269
+ | `constraint` | 不能违反的规则 |
270
+ | `todo` | 以后要做的承诺 |
271
+ | `knowledge` | 持久的领域或架构知识 |
272
+ | `howto` | 验证过的做法 |
273
+ | `gotcha` | 要避开的坑 |
274
+ | `lesson` | 事故或错误教会我们的东西 |
275
+ | `observation` | 注意到的现象,还不是结论 |
276
+ | `reference` | 指向权威文档的指针(不复制内容) |
277
+
278
+ ## 团队记忆工作流
279
+
280
+ 个人笔记永远私有。项目知识走一条显式、可 review 的流水线——没有任何东西会自动分享:
281
+
282
+ ```
283
+ capture → outbox(本地草稿)→ submit → 仓库(.ai/open-memex/)→ PR review → published → recall
284
+ ```
285
+
286
+ 1. **Capture**——正常工作中把决策、坑、教训存成草稿。
287
+ 2. **Review**——草稿在本地 outbox 里等着;`sync-status`(或在聊天里说"同步记忆")查看待处理项。
288
+ 3. **Submit**——你点名要分享的记忆才会进 `<repo>/.ai/open-memex/`,并做本地 commit。open-memex 永远不会自动 push。
289
+ 4. **PR review**——记忆就是纯 Markdown;reviewer 走正常的分支/PR 流程批准、要求修改或拒绝(`promote`、`pr-status`、`resolve`)。
290
+ 5. **Recall**——已发布的记忆在会话开始时自动注入,也可随时搜索,人和 agent 都能用。
291
+
292
+ Reviewer 守则:[docs/CURATOR.md](./docs/CURATOR.md)。
293
+
294
+ ## 安全与数据
295
+
296
+ - **本地优先:** 所有东西都在你的机器上(`%APPDATA%\open-memex` / `~/.local/share/open-memex`),加上你选择的仓库。零云端调用、零账号、零第三方 API、零遥测。
297
+ - **密钥进不来:** `<private>…</private>` 包裹的内容会被剥离;检测到的 API key / token 在保存前就地打码。先用 `open-memex capture --dry-run "…"` 预览。
298
+ - **个人 scope 永不同步:** `personal` 只属于这台机器——export 默认排除,也永远进不了仓库。
299
+ - **分享可审计:** 团队记忆只能靠显式的 `submit` 移动,走分支/PR review,每次 `promote` 状态流转都会追加到记忆的 `review_history`(谁/何时/为什么)。
300
+ - **文件是你的:** Markdown 是 source of truth——随手看、随手改、随手删;SQLite 索引可以从文件重建。
301
+
183
302
  ## Scope
184
303
 
185
304
  - **project** — 绑定当前仓库(用 git origin URL 哈希做 key,无 remote 则用 cwd)。新记忆默认进这里。
@@ -329,7 +448,8 @@ open-memex import <bundle.tar.gz> [--dry-run]
329
448
  open-memex distill-agents [--scope project|personal] [--type t1,t2] [--limit N] [-o <file>]
330
449
  # 把项目记忆(decision/constraint/lesson/gotcha/howto)提炼成
331
450
  # AGENTS.md 片段。默认打印到 stdout;-o 写文件。人工审阅后手工合并——
332
- # open-memex 永不自动改写你的 AGENTS.md。
451
+ # open-memex 永不自动改写你的 AGENTS.md。片段末尾带一段"记忆卫生"
452
+ # (§3.5 检查点指引),让读 AGENTS.md 的 agent 学会在检查点提议蒸馏捕获。
333
453
 
334
454
  open-memex propose <id...> --to project [--local-approve]
335
455
  # 一次 propose 一条或多条(一个分支、一个 PR),每条独立新 id。
@@ -387,28 +507,26 @@ project scope 从进程工作目录解析,所以配置 server 时 cwd 要指
387
507
 
388
508
  ## 路线图(Roadmap)
389
509
 
390
- **`0.3.0`(本版):** 通用 MCP server、`open-memex` bin/CLI、
510
+ **`0.3.0`(稳定版):** 通用 MCP server、`open-memex` bin/CLI、
391
511
  一键 `init` 配置、中文关键词捕获(含 personal/project 路由)、
392
512
  `config` / `capture --dry-run` / `doctor` 助手命令、Visual Studio 支持。
393
513
 
394
- **进行中 —— `0.4.0`:** 团队同步——用 git 做共享记忆:appdata 草稿箱 →
514
+ **`0.4.0`(开发中):** 团队同步——用 git 做共享记忆:appdata 草稿箱 →
395
515
  `sync-status` → `submit`(本地分支+commit,push/PR 拿你的 Yes 才做)
396
- → `promote` / `resolve` 评审工作流、仓库内 `.ai/open-memex/` 目录,
397
- 找 1–2 个同事做 pilot;捕获——§3.5 检查点蒸馏写进 MCP 握手指令和
398
- init 指令文件(agent 提议 1–3 条,人来定)。
399
-
400
- **Coming —— `0.3.0`(稳定版):** 组织层——组织记忆仓库、
401
- curator 约定、distill-to-AGENTS.md 辅助、`export`/`import` 归档
402
- (Markdown + manifest,不造围墙花园,用户可带走;
403
- private 默认不导出,`-a`/`--all` 全量迁移)。
404
-
405
- **未来(看信号再定,不承诺版本):** 原生 agent 插件
406
- (Claude Code / Codex hooks,作为同一套 MCP tools 的增强路径);
516
+ → `promote` / `resolve` 评审工作流、仓库内 `.ai/open-memex/` 目录;
517
+ `export` / `import` 归档做用户可携带(Markdown + manifest,不造围墙花园;
518
+ private 默认不导出,`-a` / `--all` 全量迁移);
519
+ distill-to-AGENTS.md 辅助(`distill-agents`,只提议不改写——人工合并);
520
+ §3.5 检查点蒸馏写进 MCP 握手指令和 init 指令文件
521
+ (agent 在检查点提议 1–3 条捕获,人来定);找 1–2 个同事做 pilot。
522
+
523
+ **未来(看信号再定,不承诺版本):** 组织层——组织记忆仓库、curator 约定;
524
+ 原生 agent 插件(Claude Code / Codex hooks,作为同一套 MCP tools 的增强路径);
407
525
  本地 embedding 做基准测试门控的实验(**未经明确 opt-in 绝不下载
408
526
  embedding 模型**);云端 `RemoteProvider` 定制只在多仓库共享、
409
527
  ACL 或合规需求出现时才做。
410
528
 
411
- 设计细节:[docs/V2-DESIGN.md](./docs/V2-DESIGN.md)(append-only 决策日志 D1–D20)。
529
+ 设计细节:[docs/V2-DESIGN.md](./docs/V2-DESIGN.md)(append-only 决策日志)。
412
530
 
413
531
  ## 许可证
414
532
 
package/dist/cli.js CHANGED
@@ -23,7 +23,10 @@ import { fileURLToPath } from "node:url";
23
23
  const COMMAND_HELP = {
24
24
  where: `Show which project scope the current directory resolves to, and where its data lives.
25
25
 
26
- Usage: open-memex where`,
26
+ Usage: open-memex where
27
+
28
+ Example:
29
+ open-memex where`,
27
30
  list: `List memories in a scope, newest first.
28
31
 
29
32
  Usage: open-memex list [--scope project|personal] [--type T] [--limit N]
@@ -60,13 +63,22 @@ Example:
60
63
  open-memex add "We deploy on Fridays" --scope project --tag process`,
61
64
  supersede: `Replace a memory with a newer version. The old one is kept as history.
62
65
 
63
- Usage: open-memex supersede <id> "new content" [--type T] [--tag t1,t2]`,
66
+ Usage: open-memex supersede <id> "new content" [--type T] [--tag t1,t2]
67
+
68
+ Example:
69
+ open-memex supersede 01ABC "We deploy on Thursdays now"`,
64
70
  status: `Change a memory's lifecycle status.
65
71
 
66
- Usage: open-memex status <id> active|deprecated|retracted|archived`,
72
+ Usage: open-memex status <id> active|deprecated|retracted|archived
73
+
74
+ Example:
75
+ open-memex status 01ABC deprecated`,
67
76
  forget: `Delete a memory by id.
68
77
 
69
- Usage: open-memex forget <id>`,
78
+ Usage: open-memex forget <id>
79
+
80
+ Example:
81
+ open-memex forget 01ABC`,
70
82
  propose: `Copy personal memories into the project outbox as review drafts.
71
83
  The personal originals stay put. Nothing enters git at this step.
72
84
 
@@ -100,21 +112,34 @@ Usage: open-memex resolve [id-or-path]
100
112
 
101
113
  With no argument, lists conflicts. With an id or file path, shows the
102
114
  3-way merge (base / outbox / repo) so you can resolve it by hand.
103
- Conflicts are never auto-resolved.`,
115
+ Conflicts are never auto-resolved.
116
+
117
+ Examples:
118
+ open-memex resolve
119
+ open-memex resolve 01ABC`,
104
120
  "sync-status": `Show the project memory sync pipeline: when the index last synced
105
121
  and what triggered it, drafts waiting in the outbox (appdata), memories in the
106
122
  repo awaiting review or published, and repo files not yet committed.
107
123
 
108
- Usage: open-memex sync-status`,
124
+ Usage: open-memex sync-status
125
+
126
+ Example:
127
+ open-memex sync-status`,
109
128
  pull: `Pull shared project memories from the git remote: fetch + fast-forward
110
129
  only. Never auto-merges — a diverged branch fails with a clear message and is
111
130
  left for you to resolve by hand. On success the local index re-syncs.
112
131
 
113
- Usage: open-memex pull`,
132
+ Usage: open-memex pull
133
+
134
+ Example:
135
+ open-memex pull`,
114
136
  push: `Push the current branch (with its submitted memories) to the git
115
137
  remote. Explicit only — open-memex never pushes on its own.
116
138
 
117
- Usage: open-memex push`,
139
+ Usage: open-memex push
140
+
141
+ Example:
142
+ open-memex push`,
118
143
  export: `Export memories to a portable .tar.gz bundle (markdown source of
119
144
  truth + manifest.json) for moving to another machine or another app.
120
145
  Excludes visibility:private memories by default; --all includes everything.
@@ -126,19 +151,31 @@ Flags:
126
151
  --type filter by memory type
127
152
  --tag filter by tag
128
153
  --all, -a include private memories (full migration)
129
- -o output file (default: ./open-memex-export-<timestamp>.tar.gz)`,
154
+ -o output file (default: ./open-memex-export-<timestamp>.tar.gz)
155
+
156
+ Examples:
157
+ open-memex export -o backup.tar.gz
158
+ open-memex export --scope both --all -o full-migration.tar.gz`,
130
159
  import: `Import a bundle created by \`open-memex export\`. Personal memories
131
160
  go to the personal dir; project memories are re-keyed to the current project
132
161
  and land in the outbox as drafts. Existing identical memories are skipped;
133
162
  conflicting ids are reported, never overwritten.
134
163
 
135
- Usage: open-memex import <bundle.tar.gz> [--dry-run]`,
164
+ Usage: open-memex import <bundle.tar.gz> [--dry-run]
165
+
166
+ Examples:
167
+ open-memex import backup.tar.gz --dry-run
168
+ open-memex import backup.tar.gz`,
136
169
  "distill-agents": `Propose an AGENTS.md snippet distilled from project
137
170
  memories (decisions, constraints, lessons, gotchas, howtos). Prints markdown
138
171
  to stdout, or writes it with -o. Review and merge by hand — open-memex never
139
172
  rewrites your AGENTS.md on its own.
140
173
 
141
- Usage: open-memex distill-agents [--scope project|personal] [--type t1,t2] [--limit N] [-o <file>]`,
174
+ Usage: open-memex distill-agents [--scope project|personal] [--type t1,t2] [--limit N] [-o <file>]
175
+
176
+ Examples:
177
+ open-memex distill-agents
178
+ open-memex distill-agents --type decision,gotcha -o agents-snippet.md`,
142
179
  submit: `Move outbox drafts into the repo for review: copies the drafts into
143
180
  the repo memory dir as proposed (a local-approved copy keeps its approval),
144
181
  commits locally on the CURRENT branch, and moves the outbox originals out.
@@ -162,13 +199,23 @@ overwritten. Report-only by default.
162
199
  Usage: open-memex pr-status [--apply]
163
200
 
164
201
  Flags:
165
- --apply write the transitions locally (still never pushes)`,
202
+ --apply write the transitions locally (still never pushes)
203
+
204
+ Examples:
205
+ open-memex pr-status
206
+ open-memex pr-status --apply`,
166
207
  reindex: `Rebuild the SQLite index from the markdown files.
167
208
 
168
- Usage: open-memex reindex`,
209
+ Usage: open-memex reindex
210
+
211
+ Example:
212
+ open-memex reindex`,
169
213
  scopes: `List the known scopes (personal + project).
170
214
 
171
- Usage: open-memex scopes`,
215
+ Usage: open-memex scopes
216
+
217
+ Example:
218
+ open-memex scopes`,
172
219
  migrate: `Move memories between scopes, or convert a legacy my-o-memory data dir.
173
220
 
174
221
  Usage: open-memex migrate [--from <key>] [--to <key>] [--dry-run] [--on-conflict newer|overwrite|skip]
@@ -180,13 +227,21 @@ Flags:
180
227
  --on-conflict newer (default), overwrite, or skip
181
228
  --to-v2 convert a legacy my-o-memory data dir to the v2 layout
182
229
 
183
- Always preview with --dry-run first; nothing moves without confirmation.`,
230
+ Always preview with --dry-run first; nothing moves without confirmation.
231
+
232
+ Examples:
233
+ open-memex migrate --dry-run
234
+ open-memex migrate --from personal --to project --dry-run`,
184
235
  mcp: `Start the stdio MCP server (the same server editors connect to).
185
236
 
186
237
  Usage: open-memex mcp [--print-config vscode|cursor|claude|opencode|visualstudio]
187
238
 
188
239
  Flags:
189
- --print-config print the MCP client config instead of starting the server`,
240
+ --print-config print the MCP client config instead of starting the server
241
+
242
+ Examples:
243
+ open-memex mcp
244
+ open-memex mcp --print-config vscode`,
190
245
  init: `One-command project setup: writes the MCP config for your editor and the
191
246
  agent memory instructions. Existing files are merged, never clobbered.
192
247
 
@@ -197,21 +252,32 @@ Flags:
197
252
  --client editor to configure (default: auto-detect)
198
253
  --instructions personal (default, ~/.copilot/copilot-instructions.md) or project
199
254
  --force overwrite existing config
200
- --yes accept all defaults, never prompt`,
255
+ --yes accept all defaults, never prompt
256
+
257
+ Examples:
258
+ open-memex init
259
+ open-memex init --client cursor --yes`,
201
260
  config: `Show config, or set a key.
202
261
 
203
262
  Usage: open-memex config [set <key> <value>]
204
263
 
205
- Example:
264
+ Examples:
265
+ open-memex config
206
266
  open-memex config set sync.autoPull false`,
207
267
  capture: `Preview what the keyword-capture watcher would extract from text.
208
268
 
209
- Usage: open-memex capture --dry-run "text"`,
269
+ Usage: open-memex capture --dry-run "text"
270
+
271
+ Example:
272
+ open-memex capture --dry-run "remember: we deploy on Fridays"`,
210
273
  doctor: `Environment health check: Node version, config source, scope resolution,
211
274
  storage writability, then boots a real MCP server and runs initialize +
212
275
  tools/list against it — all eleven tools must show up.
213
276
 
214
- Usage: open-memex doctor`,
277
+ Usage: open-memex doctor
278
+
279
+ Example:
280
+ open-memex doctor`,
215
281
  };
216
282
  function usage(exitCode = 1) {
217
283
  console.log(`open-memex CLI
@@ -247,6 +313,9 @@ Usage:
247
313
  open-memex capture --dry-run "text"
248
314
  open-memex doctor
249
315
 
316
+ Every command has its own help with description and examples:
317
+ open-memex <command> --help (or -h)
318
+
250
319
  One-command project setup: \`open-memex init\` (or \`npx open-memex@alpha init\`) writes
251
320
  the MCP config for your editor (\`.vscode/mcp.json\`, \`.cursor/mcp.json\`,
252
321
  \`opencode.jsonc\`, or Visual Studio's solution-level \`.mcp.json\`) — no copy-paste
@@ -1044,6 +1113,10 @@ async function main() {
1044
1113
  entries.push({ key: name, files, marker });
1045
1114
  }
1046
1115
  entries.sort((a, b) => b.files - a.files);
1116
+ if (entries.length === 0) {
1117
+ console.log("(no scopes with memories yet — add one with `open-memex add`)");
1118
+ return;
1119
+ }
1047
1120
  for (const e of entries) {
1048
1121
  console.log(` ${e.files.toString().padStart(4)} ${e.key}${e.marker}`);
1049
1122
  }