open-memex 0.3.0 → 0.4.0-alpha.4

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/AGENTS.md CHANGED
@@ -12,7 +12,7 @@ via `prepublishOnly` — Node refuses `--experimental-strip-types` for files und
12
12
 
13
13
  - **opencode host** loads `src/index.ts` under embedded **Bun**. SQLite here is `bun:sqlite` (built-in).
14
14
  - **CLI** (`src/cli.ts`) and smoke tests run under **Node 22+** with `--experimental-strip-types`. SQLite here is `better-sqlite3` (native module).
15
- - **MCP server** (`src/mcp.ts`, stdio) runs under **Node 22+** with `--experimental-strip-types`. It exposes the same five memory tools to any MCP client (VS Code Copilot, Cursor, Claude Code). **stdout is the protocol channel — never log to stdout in `mcp.ts`; diagnostics go to stderr.**
15
+ - **MCP server** (`src/mcp.ts`, stdio) runs under **Node 22+** with `--experimental-strip-types`. It exposes the same ten memory tools to any MCP client (VS Code Copilot, Cursor, Claude Code). **stdout is the protocol channel — never log to stdout in `mcp.ts`; diagnostics go to stderr.**
16
16
 
17
17
  `src/store/db.ts` picks the backend at runtime by sniffing `globalThis.Bun`. Both backends share the same surface (`new Database(path)`, `.exec`, `.prepare().run/all/get`, `.close`). Any DB code you write must stay on that common subset — do not import `better-sqlite3` or `bun:sqlite` directly outside `db.ts`.
18
18
 
@@ -29,6 +29,13 @@ Consequences:
29
29
  npm install # once
30
30
  npm run typecheck # tsc --noEmit — the only lint/type gate
31
31
  npm run cli -- where | list | search "q" | add ... | forget <id> | reindex
32
+ npm run cli -- <command> --help # per-command help (AI assistants discover flags this way)
33
+ npm run cli -- sync-status # last sync time/kind + outbox drafts + repo review states + uncommitted files
34
+ npm run cli -- submit <id...> [--onto <branch>] [--base <branch>] # drafts → .ai/open-memex/ (local branch+commit)
35
+ npm run cli -- propose <id...> --to project [--local-approve] # copy personal → project outbox (batch OK)
36
+ npm run cli -- promote <id> [--reject] [--resubmit] [--note "..."] # proposed → approved → published (audit trail appended)
37
+ npm run cli -- pr-status [--apply] # map branch PR's GitHub state onto review_state (report; apply = local only)
38
+ npm run cli -- resolve [id-or-path] # list / 3-way-merge conflicted memories
32
39
  npm run mcp # start the stdio MCP server
33
40
  node --experimental-strip-types scripts\smoke-pure.ts # runs pure-logic checks (no sqlite)
34
41
  node --experimental-strip-types scripts\smoke-mcp.ts # MCP handshake + tool round-trip (temp dirs, no real data)
@@ -129,3 +136,7 @@ hold `V2` and `V2/…` simultaneously. Full rules: `CONTRIBUTING.md`.
129
136
  and the frozen `docs/V2-DESIGN.md` (append a `D<n>` decision entry, never rewrite history);
130
137
  new commands → README CLI sections + this file's Commands. A change without its docs
131
138
  is not done.
139
+ - **Version bumps ship with features.** `package.json` + `package-lock.json` carry the
140
+ in-development version. New features on a dev branch bump the minor on the alpha
141
+ line (`0.3.0` → `0.4.0-alpha.1`); fixes bump the patch (`-alpha.1` → `-alpha.2`).
142
+ The bump goes in the same commit as the feature, never as an afterthought.
package/README.md CHANGED
@@ -153,7 +153,7 @@ open-memex doctor
153
153
 
154
154
  Checks: Node version, config source, scope resolution for the current directory,
155
155
  storage writability, then boots a real MCP server and runs `initialize` +
156
- `tools/list` against it — all five tools must show up.
156
+ `tools/list` against it — all eleven tools must show up.
157
157
 
158
158
  ## Tools the agent gets
159
159
 
@@ -164,6 +164,12 @@ storage writability, then boots a real MCP server and runs `initialize` +
164
164
  | `memory_list` | List memories in a scope, newest first |
165
165
  | `memory_supersede` | Replace a memory with a newer version (keeps a supersede chain) |
166
166
  | `memory_forget` | Delete a memory by id |
167
+ | `memory_status` | Show the sync queue: outbox drafts, repo review states, uncommitted files |
168
+ | `memory_submit` | Move named drafts into the repo memory dir (local branch + commit) |
169
+ | `memory_propose` | Copy personal memories into the project scope as review candidates |
170
+ | `memory_promote` | Advance `proposed → approved → published` (or reject / resubmit) |
171
+ | `memory_resolve` | List conflicted memory files / 3-way-merge one of them |
172
+ | `memory_pr_status` | Map the branch PR's GitHub state onto each memory's review state |
167
173
 
168
174
  ## Capture
169
175
 
@@ -222,10 +228,17 @@ Defaults:
222
228
  "maxProfileItems": 5, // top-N personal items injected on first turn
223
229
  "injectOnFirstTurn": true, // [OPEN-MEMEX] system-prompt block
224
230
  "keywordCaptureEnabled": true,
225
- "logLevel": "info" // info | debug
231
+ "logLevel": "info", // info | debug
232
+ "memoryDir": ".ai/open-memex" // in-repo project-memory dir, relative to repo root
226
233
  }
227
234
  ```
228
235
 
236
+ Project-scope memories are stored as one Markdown file each under
237
+ `<repo>/<memoryDir>/` (default `.ai/open-memex/`) so they can be shared via git;
238
+ personal memories stay in local appdata and never leave the machine. Existing
239
+ project files from appdata are moved into the repo dir automatically on first
240
+ write/sync.
241
+
229
242
  `open-memex config` prints the effective config (defaults + file).
230
243
  Change a setting after install:
231
244
 
@@ -235,7 +248,7 @@ open-memex config set maxProjectMemories 12
235
248
  ```
236
249
 
237
250
  Settable keys: `maxProjectMemories`, `maxProfileItems`, `injectOnFirstTurn`,
238
- `keywordCaptureEnabled`, `logLevel`. Full design: [docs/V2-DESIGN.md](./docs/V2-DESIGN.md).
251
+ `keywordCaptureEnabled`, `logLevel`, `memoryDir`. Full design: [docs/V2-DESIGN.md](./docs/V2-DESIGN.md).
239
252
 
240
253
  ## CLI reference
241
254
 
@@ -249,6 +262,7 @@ open-memex doctor # environment health check
249
262
  open-memex capture --dry-run "记住我喜欢简洁的回答" # preview keyword capture
250
263
  open-memex mcp --print-config vscode|cursor|claude|opencode|visualstudio
251
264
  open-memex --help # this reference
265
+ open-memex <command> --help # help for one command
252
266
  open-memex --version # installed version
253
267
  ```
254
268
 
@@ -263,6 +277,57 @@ open-memex status <id> deprecated
263
277
  open-memex forget <id>
264
278
  ```
265
279
 
280
+ Team review workflow (Phase 2B — two homes, one per stage):
281
+
282
+ Project drafts live in the **appdata outbox** (git-invisible, branch-independent);
283
+ only user-approved drafts move into `<repo>/.ai/open-memex/`, where they follow
284
+ branches and PRs. Nothing moves without you naming it.
285
+
286
+ In an AI chat with the MCP server connected, just say **"sync memory"**
287
+ (or "同步记忆") — the agent runs the status check, summarizes the outbox drafts,
288
+ and asks which ones to sync. The agent also proposes this on its own at session
289
+ start and at work checkpoints.
290
+
291
+ ```sh
292
+ open-memex sync-status
293
+ # show when the index was last synced (and what triggered it), the outbox
294
+ # (pending sync), the repo review states
295
+ # (draft / proposed / approved / published / rejected),
296
+ # and any uncommitted repo memory files.
297
+
298
+ open-memex submit <id...> [--onto <branch>] [--base <branch>]
299
+ # move your named drafts into .ai/open-memex/ as "proposed":
300
+ # creates mem/sync-<timestamp> (or stays on --onto for a code+memory PR),
301
+ # copies, flips review_state, local git commit. All-or-nothing; conflicts
302
+ # (same id, different content) abort cleanly. Prints the push + gh pr
303
+ # commands; an agent holding your Yes carries through push/PR itself.
304
+ # Default PR base is the current branch; --base redirects to main or your
305
+ # integration branch.
306
+
307
+ open-memex pr-status [--apply]
308
+ # read the branch's GitHub PR and map its state onto each in-repo memory:
309
+ # merged PR → published, PR approval → approved (approved_by = reviewer),
310
+ # changes-requested → suggestion only. Report by default; --apply performs
311
+ # the mapped transitions locally (no push).
312
+
313
+ open-memex propose <id...> --to project [--local-approve]
314
+ # propose one or several personal memories at once (one branch, one PR);
315
+ # each is copied with its own new id. All-or-nothing: a bad id aborts the
316
+ # whole batch, never a half-proposed one.
317
+ # copy a personal memory into the project scope as a review candidate
318
+ # (never moves — the personal original stays). Result lands in the outbox;
319
+ # run sync-status / submit when you're ready to put it in the repo.
320
+ open-memex promote <id> [--reject] [--resubmit] [--note "..."] [--by NAME]
321
+ # advance one step: proposed → approved → published (or reject with a note).
322
+ # Every transition is appended to the memory's review_history (who/when/why).
323
+ # A rejection never deletes the file — your call: accept it (close the PR,
324
+ # delete the branch), revise + --resubmit for another round, or keep it as
325
+ # a [rejected] record.
326
+ open-memex resolve [id-or-path]
327
+ # list conflicted memory files, or field-level 3-way merge one of them.
328
+ # Semantic conflicts are reported, never auto-resolved.
329
+ ```
330
+
266
331
  Maintenance:
267
332
 
268
333
  ```sh
@@ -280,7 +345,7 @@ simple cases — npm swallows unknown `--flag` args, so prefer direct `node`).
280
345
 
281
346
  ## MCP server
282
347
 
283
- The same five memory tools over the Model Context Protocol via a stdio server —
348
+ The same eleven memory tools over the Model Context Protocol via a stdio server —
284
349
  no host-specific plugin needed. Any MCP client can use open-memex.
285
350
 
286
351
  ```sh
@@ -293,8 +358,11 @@ server with cwd set to your project root (`init` handles this for you).
293
358
 
294
359
  > **Note:** MCP is request/response — it gives the agent tools, not the opencode
295
360
  > plugin's automatic keyword capture or first-turn context injection. Proactive
296
- > memory use depends on the agent's instructions (the Copilot instructions
297
- > that `init` writes).
361
+ > memory use depends on the agent's instructions: the server sends session-start
362
+ > guidance (call `memory_status` at session start and at checkpoints) in the MCP
363
+ > handshake `instructions`, and `init` writes the fuller version into the
364
+ > editor's instruction files. Both are advisory — no MCP consumer offers a hard
365
+ > session-start hook.
298
366
 
299
367
  ## Roadmap
300
368
 
@@ -302,8 +370,10 @@ server with cwd set to your project root (`init` handles this for you).
302
370
  `init` setup, Chinese keyword capture with personal/project routing, `config` /
303
371
  `capture --dry-run` / `doctor` helpers, Visual Studio support.
304
372
 
305
- **Coming — `0.4.0`:** team sync — shared memory via git (`propose` / `promote` /
306
- `resolve` workflow, in-repo memory dir), 1–2 colleague pilot.
373
+ **In progress — `0.4.0`:** team sync — shared memory via git: appdata draft
374
+ outbox → `sync-status` → `submit` (local branch+commit, push/PR on your Yes)
375
+ → `promote` / `resolve` review workflow, in-repo `.ai/open-memex/` dir, 1–2
376
+ colleague pilot.
307
377
 
308
378
  **Coming — `0.3.0` (stable):** org layer — org memory repo, curator convention,
309
379
  distill-to-AGENTS.md assist.
package/README.zh-CN.md CHANGED
@@ -149,7 +149,7 @@ open-memex doctor
149
149
 
150
150
  检查:Node 版本、配置来源、当前目录的 scope 解析、存储可写性,
151
151
  然后启动一个真实的 MCP server 做 `initialize` + `tools/list`——
152
- 五个 tools 都必须出现。
152
+ 十一个 tools 都必须出现。
153
153
 
154
154
  ## Agent 可用的 tools
155
155
 
@@ -160,6 +160,12 @@ open-memex doctor
160
160
  | `memory_list` | 按 scope 列出记忆,最新的在前 |
161
161
  | `memory_supersede` | 用新版本替换一条记忆(保留替换链) |
162
162
  | `memory_forget` | 按 id 删除一条记忆 |
163
+ | `memory_status` | 显示同步队列:outbox 草稿、repo 评审状态、未提交文件 |
164
+ | `memory_submit` | 把点名的草稿移入 repo memory 目录(建本地分支 + commit) |
165
+ | `memory_propose` | 把 personal 记忆复制到 project scope 作为评审候选 |
166
+ | `memory_promote` | 推进 `proposed → approved → published`(或 reject / resubmit) |
167
+ | `memory_resolve` | 列出冲突的记忆文件 / 对单个做三路合并 |
168
+ | `memory_pr_status` | 把分支 PR 的 GitHub 状态映射到每条记忆的评审状态 |
163
169
 
164
170
  ## 捕获(Capture)
165
171
 
@@ -220,10 +226,16 @@ Markdown 是 source of truth,SQLite 索引是派生的、可重建的
220
226
  "maxProfileItems": 5, // 首轮注入的个人偏好条数
221
227
  "injectOnFirstTurn": true, // [OPEN-MEMEX] system-prompt 块
222
228
  "keywordCaptureEnabled": true,
223
- "logLevel": "info" // info | debug
229
+ "logLevel": "info", // info | debug
230
+ "memoryDir": ".ai/open-memex" // 仓库内项目记忆目录,相对于仓库根目录
224
231
  }
225
232
  ```
226
233
 
234
+ project scope 的记忆以"一个记忆一个 Markdown 文件"的形式存放在
235
+ `<仓库>/<memoryDir>/`(默认 `.ai/open-memex/`)下,可经 git 共享;
236
+ personal 记忆只存本地 appdata,永不离开本机。已有的 appdata 项目文件会在
237
+ 首次写入/同步时自动搬进仓库目录。
238
+
227
239
  `open-memex config` 打印生效配置(默认值 + 文件)。
228
240
  安装后改设置:
229
241
 
@@ -233,7 +245,7 @@ open-memex config set maxProjectMemories 12
233
245
  ```
234
246
 
235
247
  可设置的 key:`maxProjectMemories`、`maxProfileItems`、`injectOnFirstTurn`、
236
- `keywordCaptureEnabled`、`logLevel`。完整设计见
248
+ `keywordCaptureEnabled`、`logLevel`、`memoryDir`。完整设计见
237
249
  [docs/V2-DESIGN.md](./docs/V2-DESIGN.md)。
238
250
 
239
251
  ## CLI 参考
@@ -248,6 +260,7 @@ open-memex doctor # 环境健康检查
248
260
  open-memex capture --dry-run "记住我喜欢简洁的回答" # 预览关键词捕获
249
261
  open-memex mcp --print-config vscode|cursor|claude|opencode|visualstudio
250
262
  open-memex --help # 本帮助
263
+ open-memex <command> --help # 单个命令的帮助
251
264
  open-memex --version # 已安装版本
252
265
  ```
253
266
 
@@ -262,6 +275,49 @@ open-memex status <id> deprecated
262
275
  open-memex forget <id>
263
276
  ```
264
277
 
278
+ 团队评审工作流(Phase 2B —— 两个家,各管一段):
279
+
280
+ project 草稿先住在 **appdata outbox**(git 看不见、跟分支无关);只有你
281
+ 点名批准的草稿,才会被移入 `<repo>/.ai/open-memex/`,之后随分支和 PR 走。
282
+ 没经过你点名,什么都不会动。
283
+
284
+ 在接了 MCP 服务器的 AI 对话里,直接说 **"同步记忆"**(或 "sync memory")——
285
+ agent 会查状态、把 outbox 草稿逐条摘要、问你同步哪几条。agent 也会在新对话
286
+ 开始和任务检查点主动提这件事。
287
+
288
+ ```sh
289
+ open-memex sync-status
290
+ # 看索引上次同步的时间和触发方、outbox(待同步)、repo 里的评审状态
291
+ # (draft / proposed / approved / published / rejected),
292
+ # 以及 repo 里还没 commit 的记忆文件。
293
+
294
+ open-memex submit <id...> [--onto <branch>] [--base <branch>]
295
+ # 把你点名的草稿移入 .ai/open-memex/,状态变为 proposed:
296
+ # 建 mem/sync-<timestamp> 分支(或 --onto 当前分支,跟代码走同一个 PR),
297
+ # 复制、改 review_state、本地 git commit。全有或全无;冲突(同 id 不同内容)
298
+ # 干净回滚。打印 push + gh pr 命令;Agent 拿到你的 Yes 后会自己走完 push/PR。
299
+ # PR 默认 base 是当前分支;--base 可改到 main 或集成支。
300
+
301
+ open-memex pr-status [--apply]
302
+ # 读分支的 GitHub PR,把它的状态映射到每条 in-repo 记忆:
303
+ # PR merged → published,PR approved → approved(approved_by = reviewer),
304
+ # changes requested 只给建议。默认只报告;--apply 在本地执行映射的流转(不 push)。
305
+
306
+ open-memex propose <id...> --to project [--local-approve]
307
+ # 一次 propose 一条或多条(一个分支、一个 PR),每条独立新 id。
308
+ # 全有或全无:id 有错整批回滚,不会留半截。
309
+ # 把一条 personal 记忆复制到 project scope 进入评审(复制而非移动,
310
+ # personal 原件保留)。结果落在 outbox;准备好进 repo 时再 sync-status / submit。
311
+ open-memex promote <id> [--reject] [--resubmit] [--note "..."] [--by NAME]
312
+ # 晋升一步:proposed → approved → published(或用 --reject 驳回并附注原因)。
313
+ # 每次流转都追加到记忆的 review_history(谁、何时、为什么)。
314
+ # 驳回不删文件,由你决定:接受(关 PR 删分支)、改完 --resubmit 再审、
315
+ # 或留着当 [rejected] 记录。
316
+ open-memex resolve [id-or-path]
317
+ # 列出冲突中的记忆文件,或对其中一个做字段级 3-way 合并。
318
+ # 语义冲突只报告、不自动解决。
319
+ ```
320
+
265
321
  维护:
266
322
 
267
323
  ```sh
@@ -280,7 +336,7 @@ CLI 跑在 Node 22 下。从源码 checkout 使用时走内置的实验性 TypeS
280
336
 
281
337
  ## MCP server
282
338
 
283
- 同一个五个 memory tools,走 Model Context Protocol 的 stdio server——
339
+ 同一个十一个 memory tools,走 Model Context Protocol 的 stdio server——
284
340
  不需要宿主专属插件,任何 MCP 客户端都能用 open-memex。
285
341
 
286
342
  ```sh
@@ -293,7 +349,10 @@ project scope 从进程工作目录解析,所以配置 server 时 cwd 要指
293
349
 
294
350
  > **注意:** MCP 是请求/响应式的——它给 agent 提供 tools,但没有 opencode
295
351
  > 插件的关键词自动捕获和首轮上下文注入。想让 agent 主动用记忆,
296
- > 靠的是 agent 的 instructions(`init` 写的 Copilot instructions)。
352
+ > 靠的是 agent 的 instructions:服务器在 MCP 握手的 `instructions` 里自带
353
+ > session-start 指引(开场调 `memory_status`、检查点再调),`init` 则把更完整
354
+ > 的版本写进编辑器的 instruction 文件。两者都是建议性的——MCP 客户端没有
355
+ > 强制的 session-start hook。
297
356
 
298
357
  ## 路线图(Roadmap)
299
358
 
@@ -301,8 +360,9 @@ project scope 从进程工作目录解析,所以配置 server 时 cwd 要指
301
360
  一键 `init` 配置、中文关键词捕获(含 personal/project 路由)、
302
361
  `config` / `capture --dry-run` / `doctor` 助手命令、Visual Studio 支持。
303
362
 
304
- **Coming —— `0.4.0`:** 团队同步——用 git 做共享记忆
305
- (`propose` / `promote` / `resolve` 工作流、仓库内记忆目录),
363
+ **进行中 —— `0.4.0`:** 团队同步——用 git 做共享记忆:appdata 草稿箱 →
364
+ `sync-status` → `submit`(本地分支+commit,push/PR 拿你的 Yes 才做)
365
+ → `promote` / `resolve` 评审工作流、仓库内 `.ai/open-memex/` 目录,
306
366
  找 1–2 个同事做 pilot。
307
367
 
308
368
  **Coming —— `0.3.0`(稳定版):** 组织层——组织记忆仓库、