open-memex 0.4.1 → 0.5.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
@@ -49,16 +49,21 @@ node --experimental-strip-types scripts\smoke-mcp.ts # MCP handshake + tool r
49
49
  After `npm i -g open-memex` (or `npm link` from source), the `open-memex` bin is on
50
50
  PATH: `open-memex mcp` starts the MCP server, `open-memex mcp --print-config <client>`
51
51
  prints a client config snippet (client: vscode|cursor|claude|opencode|visualstudio),
52
- `open-memex init [--client vscode|cursor|opencode|visualstudio] [--instructions personal|project] [--force] [--yes]`
52
+ `open-memex init [--client vscode|cursor|opencode|visualstudio] [--instructions personal|project] [--global] [--force] [--yes]`
53
53
  one-command project setup (editor MCP config + Copilot memory instructions;
54
+ no --client → auto-detects installed editors and wires them all, user-level
55
+ where supported — init once, every editor, every project (D46);
54
56
  instructions default to user-level ~/.copilot/copilot-instructions.md so the repo
55
- stays clean for teammates without open-memex — D22; resolves the server command
57
+ stays clean for teammates without open-memex — D22; `--global` writes the MCP
58
+ server entry to the editor's user-level config instead (VS Code / Cursor; D45)
59
+ or the opencode native plugin entry into ~/.config/opencode/opencode.json (D46);
60
+ resolves the server command
56
61
  at init time — npx fallback when no durable bin is on PATH, D17),
57
62
  `open-memex config` prints the effective config, `open-memex capture --dry-run "text"`
58
63
  previews keyword capture without writing, `open-memex doctor` runs health checks
59
64
  (node version, config, scope resolution, storage writability, MCP handshake).
60
- `open-memex init` asks editor + two settings on a TTY (`--yes` skips, scripts never
61
- prompt); `open-memex config set <key> <value>` edits settings after install.
65
+ `open-memex init` with no --client auto-detects and wires every installed editor
66
+ (`--yes` skips, scripts never prompt); `open-memex config set <key> <value>` edits settings after install.
62
67
  The published `open-memex` bin points at `dist/cli.js` (compiled at publish time).
63
68
  From a source checkout, `npm run cli` / `npm run mcp` still run `src/` directly
64
69
  with type-stripping — no build step needed for development.
@@ -126,9 +131,10 @@ build roadmap; the design doc tracks the *why*.
126
131
 
127
132
  ## Branch workflow
128
133
 
129
- `main` (stable, mirrors npm) ← `V2` (v2 integration) ← `V2-dev-p<n>`
130
- (phase work; draft PRs into `V2`). Never create `V2/<anything>` — git can't
131
- hold `V2` and `V2/…` simultaneously. Full rules: `CONTRIBUTING.md`.
134
+ `dev/<topic>` → PR → `main` (the v2 line; alpha versions published with
135
+ `npm publish --tag alpha`, npm `latest` moves only on stable releases).
136
+ The `V2` integration branch was retired 2026-09-29 — its job (isolating the
137
+ breaking v1→v2 transition) shipped with 0.3.0. Full rules: `CONTRIBUTING.md`.
132
138
 
133
139
  ## Style notes
134
140
 
package/CONTRIBUTING.md CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  ## Branch workflow
4
4
 
5
- - `main` — stable. Mirrors the npm release line. Never commit directly;
6
- only merge from `V2` when a milestone is tested and ready to release.
7
- - `V2` — integration branch for the v2 line. Phase work lands here via
8
- pull request. Merges to `main` only after the milestone is dogfooded
9
- (plugin tested in opencode, `migrate --to-v2 --dry-run` clean on real data).
10
- - `V2-dev-p<n>` — phase dev branches (e.g. `V2-dev-p1`). Open as **draft**
11
- PRs against `V2`; mark ready and merge after local testing passes.
5
+ - `main` — the v2 line. Never commit directly; land work via pull request
6
+ from a dev branch. Alpha versions (e.g. `0.5.0-alpha.x`) live on `main`;
7
+ publish them with `npm publish --tag alpha` so the npm `latest` tag only
8
+ moves on stable releases.
9
+ - `dev/<topic>` — feature/fix branches (e.g. `dev/init-ux`). Open as **draft**
10
+ PRs against `main`; mark ready and merge after local testing passes.
12
11
 
13
- **Naming rule:** never create `V2/<anything>` — git cannot hold a branch
14
- named `V2` and a branch named `V2/…` at the same time (ref file vs.
15
- directory conflict). Use the flat `V2-dev-*` form instead.
12
+ (The `V2` integration branch was retired 2026-09-29 — it existed only to
13
+ isolate the breaking v1→v2 transition, which shipped with 0.3.0. If a future
14
+ breaking change ever needs isolation, create an integration branch then;
15
+ branches are cheap.)
16
16
 
17
17
  ## Before opening a PR
18
18
 
package/README.md CHANGED
@@ -90,7 +90,7 @@ personal scope: this machine only — never synced, never enters a repo.
90
90
  npm install -g open-memex
91
91
  ```
92
92
 
93
- This installs the `0.4.0` stable release.
93
+ This installs the `0.4.1` stable release.
94
94
 
95
95
  **Alpha** (bleeding edge, for testers) — the `alpha` tag:
96
96
 
@@ -114,10 +114,10 @@ npx -y open-memex <command> # e.g. npx -y open-memex init --client vscod
114
114
  npx -y open-memex@alpha <command> # alpha line, no install
115
115
  ```
116
116
 
117
- **From source** (bleeding edge, `V2-dev-p2` branch):
117
+ **From source** (bleeding edge, `main` branch):
118
118
 
119
119
  ```sh
120
- git clone -b V2-dev-p2 https://github.com/stoneskin/open-memex.git
120
+ git clone -b main https://github.com/stoneskin/open-memex.git
121
121
  cd open-memex
122
122
  npm install
123
123
  node --experimental-strip-types src/cli.ts <command>
@@ -156,16 +156,36 @@ folders under your global npm root and install again.
156
156
 
157
157
  Run from your **project root** (so the project scope resolves to this repo):
158
158
 
159
+ ```sh
160
+ open-memex init --yes
161
+ # …or without installing the package first:
162
+ npx -y open-memex init --yes
163
+ ```
164
+
165
+ With no `--client`, `init` **detects your installed editors and wires them all**
166
+ — user-level where the editor supports it (VS Code / Cursor MCP config, opencode
167
+ native plugin), so one init covers every project. Visual Studio joins in when the
168
+ project has a solution file. Prefer to pick a single editor? Pass `--client`:
169
+
170
+ > **Two different "globals" — don't mix them up.**
171
+ > - `npm install -g open-memex` installs the *package* globally: it puts the
172
+ > `open-memex` command on your PATH.
173
+ > - `init --global` writes the *editor config* at user level instead of the
174
+ > project: init once, the wiring works in every project. It works the same
175
+ > whether the package was installed globally or run via npx.
176
+
159
177
  **VS Code** (Copilot):
160
178
 
161
179
  ```sh
162
180
  open-memex init --client vscode
163
- # …or without a global install:
181
+ # …or without installing the package first:
164
182
  npx -y open-memex init --client vscode
165
183
  ```
166
184
 
167
- Writes `.vscode/mcp.json` and user-level Copilot instructions, then reload the
168
- window and confirm the `open-memex` server is started in Copilot Chat's MCP panel.
185
+ Wires the project-level `.vscode/mcp.json` and user-level Copilot instructions,
186
+ then reload the window and confirm the `open-memex` server is started in Copilot
187
+ Chat's MCP panel. On a TTY, `init` asks whether the MCP config should be
188
+ per-project or user-level instead of guessing; `--global` forces user-level.
169
189
 
170
190
  **Cursor:**
171
191
 
@@ -173,7 +193,36 @@ window and confirm the `open-memex` server is started in Copilot Chat's MCP pane
173
193
  open-memex init --client cursor
174
194
  ```
175
195
 
176
- Writes `.cursor/mcp.json` and user-level Copilot instructions.
196
+ Same shape as VS Code: project-level `.cursor/mcp.json` by default, user-level
197
+ with `--global` (or when `init` asks on a TTY), plus user-level Copilot
198
+ instructions.
199
+
200
+ **One-time setup for all projects (VS Code / Cursor):**
201
+
202
+ ```sh
203
+ open-memex init --client vscode --global --yes
204
+ ```
205
+
206
+ Writes the server entry to the editor's *user-level* MCP config
207
+ (`%APPDATA%\Code\User\mcp.json` on Windows,
208
+ `~/Library/Application Support/Code/User/mcp.json` on macOS,
209
+ `~/.config/Code/User/mcp.json` on Linux; `~/.cursor/mcp.json` for Cursor)
210
+ instead of the project — init once, the server starts in every project.
211
+ A per-project `.vscode/mcp.json` still wins if a project defines its own.
212
+ If the user-level file has comments in it (VS Code accepts JSONC), `init` leaves
213
+ the file untouched and prints the exact snippet to paste in by hand.
214
+
215
+ **opencode** (native plugin — recommended):
216
+
217
+ ```sh
218
+ open-memex init --client opencode --global --yes
219
+ ```
220
+
221
+ Merges `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]` into your
222
+ user-level `~/.config/opencode/opencode.json` — one-time, every project picks it
223
+ up, no per-project init. You get keyword auto-capture and first-turn context
224
+ injection on top of the tools. (A config file with comments is left untouched —
225
+ add the `plugin` line by hand in that case.)
177
226
 
178
227
  **opencode** (as a plain MCP consumer):
179
228
 
@@ -181,10 +230,8 @@ Writes `.cursor/mcp.json` and user-level Copilot instructions.
181
230
  open-memex init --client opencode
182
231
  ```
183
232
 
184
- Writes project-level `opencode.jsonc` (`type: "local"`). Prefer the native plugin
185
- instead? Add `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]` to
186
- `~/.config/opencode/opencode.jsonc` — you get keyword auto-capture and first-turn
187
- context injection on top of the tools.
233
+ Writes project-level `opencode.jsonc` (`type: "local"`). Needed only if you
234
+ prefer plain MCP over the native plugin.
188
235
 
189
236
  **Claude Code** (from your project root):
190
237
 
@@ -208,18 +255,38 @@ above works too.
208
255
  `open-memex mcp --print-config` as a starting point (`[mcp_servers]` in
209
256
  `config.toml`, or `codex mcp add`).
210
257
 
258
+ **Remove the wiring:**
259
+
260
+ ```sh
261
+ open-memex uninstall --yes
262
+ ```
263
+
264
+ Reverses `init` — removes the MCP server entry, the opencode plugin line, and
265
+ the open-memex section of the Copilot instructions. With no `--client` it cleans
266
+ up every detected editor (project-level and user-level wiring); `--global`
267
+ limits the cleanup to user-level. Your memories are never touched.
268
+
211
269
  `init` notes:
212
270
 
271
+ - With no `--client`, `init` auto-detects installed editors (VS Code via `code`
272
+ on `PATH` / install location / existing user config; Cursor via `cursor` on
273
+ `PATH` or `~/.cursor`; opencode via `opencode` on `PATH` or its config dir;
274
+ Visual Studio when the project has a `.sln`) and wires them all — user-level
275
+ where supported, so one init covers every project.
276
+ - `--global` writes the MCP server entry to the editor's user-level config
277
+ (VS Code / Cursor) — one init for all projects. For opencode, `--global`
278
+ wires the native plugin at user level (no per-project init needed);
279
+ Visual Studio stays solution-level by design.
213
280
  - The Copilot memory instructions default to **user-level**
214
281
  (`~/.copilot/copilot-instructions.md`; `%USERPROFILE%\copilot-instructions.md`
215
282
  for Visual Studio) — they apply to all your projects and are never checked
216
283
  into a repo, so teammates without open-memex see nothing and nothing breaks
217
284
  for them. `--instructions project` writes `.github/copilot-instructions.md`
218
285
  instead, for teams where everyone uses open-memex.
219
- - On a terminal it interactively asks which editor to set up, whether to enable
220
- keyword auto-capture, and whether to inject memories on the first turn.
221
- `--yes` accepts the defaults; scripts / non-TTY never prompt (editor defaults to
222
- VS Code).
286
+ - On a terminal it shows the detected editors, asks you to confirm wiring them
287
+ all (or pick one), and asks whether to enable keyword auto-capture and
288
+ first-turn memory injection. `--yes` accepts the defaults; scripts /
289
+ non-TTY never prompt and wire every detected editor.
223
290
  - Existing config files are **merged, never clobbered** — re-running is safe.
224
291
  `--force` overwrites.
225
292
  - With no durable `open-memex` on `PATH` (e.g. one-shot npx), `init` writes an
@@ -393,7 +460,9 @@ Settable keys: `maxProjectMemories`, `maxProfileItems`, `injectOnFirstTurn`,
393
460
  Setup & health:
394
461
 
395
462
  ```sh
396
- open-memex init [--client vscode|cursor|opencode|visualstudio] [--force] [--yes]
463
+ open-memex init [--client vscode|cursor|opencode|visualstudio]
464
+ [--instructions personal|project] [--global] [--force] [--yes]
465
+ open-memex uninstall [--client vscode|cursor|opencode|visualstudio] [--global] [--yes]
397
466
  open-memex config # print effective config
398
467
  open-memex config set <key> <value> # change a setting
399
468
  open-memex doctor # environment health check
@@ -563,6 +632,52 @@ sharing, ACL, or compliance needs demand it.
563
632
 
564
633
  Design details: [docs/V2-DESIGN.md](./docs/V2-DESIGN.md) (append-only decision log).
565
634
 
635
+ ## FAQ
636
+
637
+ **Do I need to initialize open-memex for each project after installing?**
638
+ Two layers. The data layer needs nothing — there is no per-project init:
639
+ the data dir is created on demand and the project scope is derived
640
+ automatically from your cwd's git remote or path, so memories are
641
+ namespaced per project with zero setup. The editor wiring takes one step:
642
+ run `open-memex init` with no arguments and it auto-detects every editor
643
+ you have installed (VS Code, Cursor, opencode — plus Visual Studio when the
644
+ project has a `.sln`) and wires them all, user-level wherever the editor
645
+ supports it, so one init covers every project. Prefer a single editor?
646
+ `open-memex init --client <vscode|cursor|opencode|visualstudio>`. Prefer to
647
+ force user-level for VS Code / Cursor? Add `--global`. The Copilot memory
648
+ instructions default to user-level (`~/.copilot/`), which is global.
649
+
650
+ **Does opencode need `init`?**
651
+ Two paths. Recommended: `open-memex init --client opencode --global` —
652
+ it merges the native open-memex plugin into
653
+ `~/.config/opencode/opencode.json` for you. One-time setup, applies to all
654
+ projects, and additionally enables keyword auto-capture and first-turn
655
+ memory injection. Prefer to do it by hand? Add
656
+ `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]`
657
+ (the installed package's path) to that file instead. As a plain MCP
658
+ consumer: `open-memex init --client opencode` writes a project-level
659
+ `opencode.jsonc` (no hooks). If your user-level config has comments, `init`
660
+ leaves it untouched and prints the manual step.
661
+
662
+ **VS Code — run `init` once, or per project?**
663
+ Once. Plain `open-memex init` auto-detects VS Code and writes the MCP server
664
+ entry to VS Code's user-level `mcp.json`
665
+ (`%APPDATA%/Code/User/mcp.json` on Windows,
666
+ `~/Library/Application Support/Code/User/mcp.json` on macOS,
667
+ `~/.config/Code/User/mcp.json` on Linux), so the server starts in every
668
+ project. A per-project `.vscode/mcp.json` still wins when present, and the
669
+ entry keeps `cwd=${workspaceFolder}` so project-scope resolution keeps
670
+ working per window. If your user-level `mcp.json` has comments (VS Code
671
+ accepts JSONC), `init` leaves it alone and prints the exact snippet to add
672
+ by hand.
673
+
674
+ **How do I remove the editor wiring?**
675
+ `open-memex uninstall` reverses `init`: it removes the MCP server entry,
676
+ the opencode plugin line, and the open-memex section of the Copilot
677
+ instructions. With no `--client` it cleans up every detected editor;
678
+ `--global` limits the cleanup to user-level wiring. Your memories are
679
+ never touched.
680
+
566
681
  ## License
567
682
 
568
683
  [Apache-2.0](./LICENSE)
package/README.zh-CN.md CHANGED
@@ -87,7 +87,7 @@ personal scope:只属于这台机器——永不同步,永远进不了仓库
87
87
  npm install -g open-memex
88
88
  ```
89
89
 
90
- 安装的是 `0.4.0` 正式版。
90
+ 安装的是 `0.4.1` 正式版。
91
91
 
92
92
  **Alpha 版**(最新开发版,给测试者)——`alpha` 标签:
93
93
 
@@ -111,10 +111,10 @@ npx -y open-memex <命令> # 例如 npx -y open-memex init --client vsc
111
111
  npx -y open-memex@alpha <命令> # alpha 线,免安装
112
112
  ```
113
113
 
114
- **从源码安装**(最新开发版,`V2-dev-p2` 分支):
114
+ **从源码安装**(最新开发版,`main` 分支):
115
115
 
116
116
  ```sh
117
- git clone -b V2-dev-p2 https://github.com/stoneskin/open-memex.git
117
+ git clone -b main https://github.com/stoneskin/open-memex.git
118
118
  cd open-memex
119
119
  npm install
120
120
  node --experimental-strip-types src/cli.ts <命令>
@@ -151,16 +151,35 @@ Windows 下被进程加载的 DLL 是锁死的:如果 open-memex MCP server
151
151
 
152
152
  在**项目根目录**下运行(这样 project scope 会解析到这个仓库):
153
153
 
154
+ ```sh
155
+ open-memex init --yes
156
+ # ……没先装包的话:
157
+ npx -y open-memex init --yes
158
+ ```
159
+
160
+ 不带 `--client` 时,`init` 会**自动检测本机装了哪些编辑器,一次全接上**——
161
+ 支持用户级的编辑器走用户级(VS Code / Cursor 的 MCP 配置、opencode 原生插件),
162
+ 一次 init,所有项目通用;项目里有 solution 文件时 Visual Studio 也会一起配。
163
+ 想只配某一个编辑器?加 `--client`:
164
+
165
+ > **两个"全局"不是一回事,别搞混。**
166
+ > - `npm install -g open-memex` 是把*包*装到全局:让 `open-memex` 命令出现在
167
+ > 你的 PATH 里。
168
+ > - `init --global` 是把*编辑器配置*写到用户级而不是项目里:init 一次,
169
+ > 每个项目都生效。不管包是全局安装的还是用 npx 临时跑的,效果一样。
170
+
154
171
  **VS Code**(Copilot):
155
172
 
156
173
  ```sh
157
174
  open-memex init --client vscode
158
- # ……没装全局包的话:
175
+ # ……没先装包的话:
159
176
  npx -y open-memex init --client vscode
160
177
  ```
161
178
 
162
- 自动写 `.vscode/mcp.json` 和用户级 Copilot instructions,然后重新加载窗口,
163
- 在 Copilot Chat 的 MCP 面板里确认 `open-memex` server 已启动。
179
+ 配项目级 `.vscode/mcp.json` 和用户级 Copilot instructions,然后重新加载窗口,
180
+ 在 Copilot Chat 的 MCP 面板里确认 `open-memex` server 已启动。终端交互模式下
181
+ `init` 会问你要配到项目级还是用户级,而不是替你猜;`--global` 直接强制
182
+ 用户级。
164
183
 
165
184
  **Cursor:**
166
185
 
@@ -168,7 +187,35 @@ npx -y open-memex init --client vscode
168
187
  open-memex init --client cursor
169
188
  ```
170
189
 
171
- 自动写 `.cursor/mcp.json` 和用户级 Copilot instructions。
190
+ 和 VS Code 一个套路:默认写项目级 `.cursor/mcp.json`,`--global`
191
+ (或终端里 `init` 问你时选用户级)就写用户级,外加用户级 Copilot
192
+ instructions。
193
+
194
+ **一次配置、所有项目通用(VS Code / Cursor):**
195
+
196
+ ```sh
197
+ open-memex init --client vscode --global --yes
198
+ ```
199
+
200
+ 把 server 条目写到编辑器的*用户级* MCP 配置(Windows 下是
201
+ `%APPDATA%\Code\User\mcp.json`,macOS 是
202
+ `~/Library/Application Support/Code/User/mcp.json`,Linux 是
203
+ `~/.config/Code/User/mcp.json`;Cursor 是 `~/.cursor/mcp.json`),
204
+ 而不是写到项目里——init 一次,每个项目打开自动启动 server。
205
+ 如果某个项目自己定义了 `.vscode/mcp.json`,项目级的优先。
206
+ 如果用户级文件里带注释(VS Code 接受 JSONC),`init` 不会碰这个文件,
207
+ 只打印可直接手贴的配置片段。
208
+
209
+ **opencode**(原生插件——推荐):
210
+
211
+ ```sh
212
+ open-memex init --client opencode --global --yes
213
+ ```
214
+
215
+ 把 `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]` 合并进用户级
216
+ `~/.config/opencode/opencode.json`——一次配置,每个项目自动生效,不用逐个项目
217
+ init。在 tools 之外还能获得关键词自动捕获和首轮上下文注入。(带注释的配置文件
218
+ 不会被改动——那种情况请手动加 `plugin` 这一行。)
172
219
 
173
220
  **opencode**(作为普通 MCP 客户端):
174
221
 
@@ -176,10 +223,8 @@ open-memex init --client cursor
176
223
  open-memex init --client opencode
177
224
  ```
178
225
 
179
- 写项目级 `opencode.jsonc`(`type: "local"`)。想用原生插件?
180
- 在 `~/.config/opencode/opencode.jsonc` 里加
181
- `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]`——
182
- 在 tools 之外还能获得关键词自动捕获和首轮上下文注入。
226
+ 写项目级 `opencode.jsonc`(`type: "local"`)。只有当你更想要纯 MCP 而不是原生
227
+ 插件时才需要。
183
228
 
184
229
  **Claude Code**(在项目根目录运行):
185
230
 
@@ -202,6 +247,16 @@ Visual Studio 也会自动发现 `.vscode/mcp.json` 和 `.cursor/mcp.json`,
202
247
  **Codex:** 暂无 `init` 客户端——以 `open-memex mcp --print-config` 为起点手动添加
203
248
  (`config.toml` 的 `[mcp_servers]`,或 `codex mcp add`)。
204
249
 
250
+ **拆掉接线:**
251
+
252
+ ```sh
253
+ open-memex uninstall --yes
254
+ ```
255
+
256
+ `init` 的逆操作——删掉 MCP server 条目、opencode 插件行和 Copilot
257
+ instructions 里的 open-memex 段。不带 `--client` 时把检测到的编辑器全清掉
258
+ (项目级和用户级都清);`--global` 只清用户级。你的记忆数据永远不会被碰。
259
+
205
260
  `init` 说明:
206
261
 
207
262
  - Copilot 记忆 instructions 默认写到**用户级**
@@ -210,11 +265,19 @@ Visual Studio 也会自动发现 `.vscode/mcp.json` 和 `.cursor/mcp.json`,
210
265
  到 repo,没装 open-memex 的同事看不到、也不会出错。团队人人都用
211
266
  open-memex 时可用 `--instructions project` 改写
212
267
  `.github/copilot-instructions.md`。
213
- - 在终端里会交互式询问:配哪个编辑器、是否开启关键词自动捕获、
214
- 是否在首轮注入记忆。`--yes` 全用默认值;脚本 / 非 TTY 环境不提问
215
- (编辑器默认 VS Code)。
268
+ - 不带 `--client` 时,`init` 自动检测已安装的编辑器(VS Code 看 `PATH` 有没有
269
+ `code` / 安装位置 / 已有的用户级配置;Cursor 看 `PATH` 有没有 `cursor` 或
270
+ `~/.cursor`;opencode 看 `PATH` 有没有 `opencode` 或其配置目录;项目里有
271
+ `.sln` 时算上 Visual Studio),一次全接上——支持用户级的走用户级,
272
+ 一次 init,所有项目通用。
273
+ - 在终端里会列出检测到的编辑器,请你确认是一次全配还是只配一个,
274
+ 再问是否开启关键词自动捕获、是否在首轮注入记忆。`--yes` 全用默认值;
275
+ 脚本 / 非 TTY 环境不提问,直接配所有检测到的编辑器。
216
276
  - 已有配置文件会被**合并,不会被覆盖**——重复运行是安全的。
217
277
  `--force` 强制覆盖。
278
+ - `--global` 把 MCP server 条目写到编辑器的用户级配置(VS Code / Cursor)——
279
+ 一次配置,所有项目通用。opencode 的 `--global` 走用户级原生插件,
280
+ 不用逐个项目 init;Visual Studio 按设计保持 solution 级。
218
281
  - 如果 `PATH` 上没有可用的 `open-memex`(比如一次性 npx),`init` 会把
219
282
  `npx -y open-memex mcp` 写进配置,配置照样能用。
220
283
  以后 `npm i -g open-memex` + `open-memex init --force` 可切换到更快
@@ -374,7 +437,9 @@ open-memex config set maxProjectMemories 12
374
437
  安装与健康检查:
375
438
 
376
439
  ```sh
377
- open-memex init [--client vscode|cursor|opencode|visualstudio] [--force] [--yes]
440
+ open-memex init [--client vscode|cursor|opencode|visualstudio]
441
+ [--instructions personal|project] [--global] [--force] [--yes]
442
+ open-memex uninstall [--client vscode|cursor|opencode|visualstudio] [--global] [--yes]
378
443
  open-memex config # 打印生效配置
379
444
  open-memex config set <key> <value> # 改设置
380
445
  open-memex doctor # 环境健康检查
@@ -530,6 +595,43 @@ ACL 或合规需求出现时才做。
530
595
 
531
596
  设计细节:[docs/V2-DESIGN.md](./docs/V2-DESIGN.md)(append-only 决策日志)。
532
597
 
598
+ ## 常见问题(FAQ)
599
+
600
+ **装完之后,每个项目都要初始化 open-memex 吗(像其他 app 那样)?**
601
+ 分两层。数据层不需要——没有 per-project 初始化的概念:数据目录按需自动创建,
602
+ project scope 从当前目录的 git remote 或路径自动推导,记忆天然按项目隔离,
603
+ 零配置。编辑器接线只需要一步:直接跑 `open-memex init`(不带参数),它会自动
604
+ 检测你装好的编辑器(VS Code、Cursor、opencode;项目里有 `.sln` 时还有 Visual
605
+ Studio)并一次全接上——支持用户级配置的编辑器就写用户级,一次 init 所有项目
606
+ 通用。只想接某一个编辑器?用
607
+ `open-memex init --client <vscode|cursor|opencode|visualstudio>`。
608
+ 想给 VS Code / Cursor 强制写用户级?加 `--global`。
609
+ Copilot 记忆指令默认写用户级(`~/.copilot/`),那个是全局的。
610
+
611
+ **opencode 需要跑 `init` 吗?**
612
+ 两条路。推荐:`open-memex init --client opencode --global`——自动把原生插件
613
+ 合并进 `~/.config/opencode/opencode.json`。一次配置,所有项目生效,还多拿
614
+ 关键词自动捕获和首轮记忆注入。想手写?往那个文件里加
615
+ `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]`
616
+ (填 open-memex 的实际安装路径)就行。当纯 MCP 用:
617
+ `open-memex init --client opencode` 写项目级 `opencode.jsonc`(无 hooks)。
618
+ 如果你的用户级配置里带注释,`init` 不会碰它,只打印手动步骤。
619
+
620
+ **VS Code 呢——跑一次就行,还是每个项目都要跑?**
621
+ 跑一次就行。直接 `open-memex init` 会自动检测到 VS Code,把 MCP server 写进
622
+ VS Code 的用户级 `mcp.json`(Windows:`%APPDATA%/Code/User/mcp.json`;
623
+ macOS:`~/Library/Application Support/Code/User/mcp.json`;
624
+ Linux:`~/.config/Code/User/mcp.json`),每个项目打开 server 都在。
625
+ 项目里如果有 `.vscode/mcp.json` 仍然优先;entry 里保留了
626
+ `cwd=${workspaceFolder}`,project scope 按窗口照常工作。
627
+ 如果你的用户级 `mcp.json` 带注释(VS Code 接受 JSONC),`init` 不会碰它,
628
+ 只打印可直接手贴的配置片段。
629
+
630
+ **怎么拆掉编辑器接线?**
631
+ `open-memex uninstall` 就是 `init` 的逆操作:删掉 MCP server 条目、opencode
632
+ 插件行和 Copilot instructions 里的 open-memex 段。不带 `--client` 时把检测
633
+ 到的编辑器全清掉;`--global` 只清用户级。你的记忆数据永远不会被碰。
634
+
533
635
  ## 许可证
534
636
 
535
637
  [Apache-2.0](./LICENSE)
package/dist/cli.js CHANGED
@@ -250,17 +250,38 @@ Examples:
250
250
  agent memory instructions. Existing files are merged, never clobbered.
251
251
 
252
252
  Usage: open-memex init [--client vscode|cursor|opencode|visualstudio]
253
- [--instructions personal|project] [--force] [--yes]
253
+ [--instructions personal|project] [--global] [--force] [--yes]
254
254
 
255
255
  Flags:
256
- --client editor to configure (default: auto-detect)
256
+ --client editor to configure (default: auto-detect all installed editors)
257
257
  --instructions personal (default, ~/.copilot/copilot-instructions.md) or project
258
+ --global write the MCP server entry to the editor's user-level config
259
+ (VS Code / Cursor) — init once, works in every project.
260
+ For opencode, --global wires the native plugin at user level
261
+ (~/.config/opencode/opencode.json) — no per-project init needed.
258
262
  --force overwrite existing config
259
263
  --yes accept all defaults, never prompt
260
264
 
261
265
  Examples:
262
266
  open-memex init
267
+ open-memex init --client vscode --global --yes
263
268
  open-memex init --client cursor --yes`,
269
+ uninstall: `Remove the editor wiring that \`init\` wrote: the MCP server entry,
270
+ the opencode native plugin line, and the Copilot instructions section.
271
+ Your memories are never touched.
272
+
273
+ Usage: open-memex uninstall [--client vscode|cursor|opencode|visualstudio]
274
+ [--global] [--yes]
275
+
276
+ Flags:
277
+ --client editor to unwire (default: auto-detect all installed editors)
278
+ --global only the user-level config; without it, both project-level and
279
+ user-level wiring are removed (init may have written either)
280
+ --yes accept all defaults, never prompt
281
+
282
+ Examples:
283
+ open-memex uninstall
284
+ open-memex uninstall --client vscode --yes`,
264
285
  config: `Show config, or set a key.
265
286
 
266
287
  Usage: open-memex config [set <key> <value>]
@@ -313,6 +334,8 @@ Usage:
313
334
  open-memex mcp [--print-config vscode|cursor|claude|opencode|visualstudio]
314
335
  open-memex init [--client vscode|cursor|opencode|visualstudio]
315
336
  [--instructions personal|project] [--force] [--yes]
337
+ open-memex uninstall [--client vscode|cursor|opencode|visualstudio]
338
+ [--global] [--yes]
316
339
  open-memex config [set <key> <value>]
317
340
  open-memex capture --dry-run "text"
318
341
  open-memex doctor
@@ -320,16 +343,19 @@ Usage:
320
343
  Every command has its own help with description and examples:
321
344
  open-memex <command> --help (or -h)
322
345
 
323
- One-command project setup: \`open-memex init\` (or \`npx open-memex@alpha init\`) writes
324
- the MCP config for your editor (\`.vscode/mcp.json\`, \`.cursor/mcp.json\`,
325
- \`opencode.jsonc\`, or Visual Studio's solution-level \`.mcp.json\`) — no copy-paste
326
- needed. The Copilot memory instructions default to your user-level
346
+ One-command project setup: \`open-memex init\` (or \`npx open-memex@alpha init\`) detects
347
+ your installed editors and wires them all — user-level where the editor supports it
348
+ (VS Code / Cursor MCP config, opencode native plugin), so one init covers every project;
349
+ Visual Studio is included when the project has a solution file (its \`.mcp.json\`
350
+ stays solution-level by design). \`--client\` picks a single editor instead, and a
351
+ single-editor opencode init writes the per-project plain-MCP \`opencode.jsonc\`.
352
+ The Copilot memory instructions default to your user-level
327
353
  \`~/.copilot/copilot-instructions.md\` (all projects, never checked into a repo);
328
354
  \`--instructions project\` writes \`.github/copilot-instructions.md\` instead for
329
355
  teams where everyone uses open-memex.
330
356
  Existing files are merged, never clobbered; re-running is safe. On a terminal it
331
- asks which editor to set up and a couple of settings (keyword capture, first-turn
332
- injection); \`--yes\` accepts all defaults, and non-terminal runs never prompt.
357
+ confirms the detected editors and asks a couple of settings (keyword capture,
358
+ first-turn injection); \`--yes\` accepts all defaults, and non-terminal runs never prompt.
333
359
  \`open-memex config set <key> <value>\` changes those settings after install.
334
360
 
335
361
  Once installed globally (\`npm i -g open-memex@alpha\`) the \`open-memex\` command is
@@ -526,7 +552,7 @@ async function main() {
526
552
  return;
527
553
  }
528
554
  // `init` is a pure file operation (§17 adoption path) — no DB needed.
529
- // Interactive when on a TTY (asks editor + settings); --yes skips prompts.
555
+ // Interactive when on a TTY (confirms detected editors + settings); --yes skips prompts.
530
556
  if (cmd === "init") {
531
557
  const flags = parseFlags(rest);
532
558
  const { initProject } = await import("./init.js");
@@ -535,6 +561,19 @@ async function main() {
535
561
  force: flags["force"] === "true",
536
562
  yes: flags["yes"] === "true",
537
563
  instructions: flags["instructions"],
564
+ global: flags["global"] === "true",
565
+ });
566
+ return;
567
+ }
568
+ // `uninstall` reverses `init` — removes the editor wiring; never touches data.
569
+ // No DB needed (pure file operation, like init).
570
+ if (cmd === "uninstall") {
571
+ const flags = parseFlags(rest);
572
+ const { uninstallProject } = await import("./init.js");
573
+ await uninstallProject({
574
+ client: flags["client"],
575
+ global: flags["global"] === "true",
576
+ yes: flags["yes"] === "true",
538
577
  });
539
578
  return;
540
579
  }