open-memex 0.4.0 → 0.5.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
@@ -1,5 +1,7 @@
1
1
  # open-memex
2
2
 
3
+ > A shared organizational memory layer that helps people and AI capture, retain, and reuse institutional knowledge.
4
+
3
5
  [![npm version](https://img.shields.io/npm/v/open-memex.svg)](https://www.npmjs.com/package/open-memex)
4
6
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
5
7
 
@@ -154,6 +156,17 @@ folders under your global npm root and install again.
154
156
 
155
157
  Run from your **project root** (so the project scope resolves to this repo):
156
158
 
159
+ ```sh
160
+ open-memex init --yes
161
+ # …or without a global install:
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
+
157
170
  **VS Code** (Copilot):
158
171
 
159
172
  ```sh
@@ -173,16 +186,40 @@ open-memex init --client cursor
173
186
 
174
187
  Writes `.cursor/mcp.json` and user-level Copilot instructions.
175
188
 
189
+ **One-time setup for all projects (VS Code / Cursor):**
190
+
191
+ ```sh
192
+ open-memex init --client vscode --global --yes
193
+ ```
194
+
195
+ Writes the server entry to the editor's *user-level* MCP config
196
+ (`%APPDATA%\Code\User\mcp.json` on Windows,
197
+ `~/Library/Application Support/Code/User/mcp.json` on macOS,
198
+ `~/.config/Code/User/mcp.json` on Linux; `~/.cursor/mcp.json` for Cursor)
199
+ instead of the project — init once, the server starts in every project.
200
+ A per-project `.vscode/mcp.json` still wins if a project defines its own.
201
+ (On a TTY, `init` asks whether the config should be per-project or user-level.)
202
+
203
+ **opencode** (native plugin — recommended):
204
+
205
+ ```sh
206
+ open-memex init --client opencode --global --yes
207
+ ```
208
+
209
+ Merges `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]` into your
210
+ user-level `~/.config/opencode/opencode.json` — one-time, every project picks it
211
+ up, no per-project init. You get keyword auto-capture and first-turn context
212
+ injection on top of the tools. (A config file with comments is left untouched —
213
+ add the `plugin` line by hand in that case.)
214
+
176
215
  **opencode** (as a plain MCP consumer):
177
216
 
178
217
  ```sh
179
218
  open-memex init --client opencode
180
219
  ```
181
220
 
182
- Writes project-level `opencode.jsonc` (`type: "local"`). Prefer the native plugin
183
- instead? Add `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]` to
184
- `~/.config/opencode/opencode.jsonc` — you get keyword auto-capture and first-turn
185
- context injection on top of the tools.
221
+ Writes project-level `opencode.jsonc` (`type: "local"`). Needed only if you
222
+ prefer plain MCP over the native plugin.
186
223
 
187
224
  **Claude Code** (from your project root):
188
225
 
@@ -208,16 +245,25 @@ above works too.
208
245
 
209
246
  `init` notes:
210
247
 
248
+ - With no `--client`, `init` auto-detects installed editors (VS Code via `code`
249
+ on `PATH` / install location / existing user config; Cursor via `cursor` on
250
+ `PATH` or `~/.cursor`; opencode via `opencode` on `PATH` or its config dir;
251
+ Visual Studio when the project has a `.sln`) and wires them all — user-level
252
+ where supported, so one init covers every project.
253
+ - `--global` writes the MCP server entry to the editor's user-level config
254
+ (VS Code / Cursor) — one init for all projects. For opencode, `--global`
255
+ wires the native plugin at user level (no per-project init needed);
256
+ Visual Studio stays solution-level by design.
211
257
  - The Copilot memory instructions default to **user-level**
212
258
  (`~/.copilot/copilot-instructions.md`; `%USERPROFILE%\copilot-instructions.md`
213
259
  for Visual Studio) — they apply to all your projects and are never checked
214
260
  into a repo, so teammates without open-memex see nothing and nothing breaks
215
261
  for them. `--instructions project` writes `.github/copilot-instructions.md`
216
262
  instead, for teams where everyone uses open-memex.
217
- - On a terminal it interactively asks which editor to set up, whether to enable
218
- keyword auto-capture, and whether to inject memories on the first turn.
219
- `--yes` accepts the defaults; scripts / non-TTY never prompt (editor defaults to
220
- VS Code).
263
+ - On a terminal it shows the detected editors, asks you to confirm wiring them
264
+ all (or pick one), and asks whether to enable keyword auto-capture and
265
+ first-turn memory injection. `--yes` accepts the defaults; scripts /
266
+ non-TTY never prompt and wire every detected editor.
221
267
  - Existing config files are **merged, never clobbered** — re-running is safe.
222
268
  `--force` overwrites.
223
269
  - With no durable `open-memex` on `PATH` (e.g. one-shot npx), `init` writes an
package/README.zh-CN.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # open-memex
2
2
 
3
+ > 共享组织记忆层,帮助人与 AI 捕获、沉淀并复用组织知识。
4
+
3
5
  [![npm version](https://img.shields.io/npm/v/open-memex.svg)](https://www.npmjs.com/package/open-memex)
4
6
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
5
7
 
@@ -149,6 +151,17 @@ Windows 下被进程加载的 DLL 是锁死的:如果 open-memex MCP server
149
151
 
150
152
  在**项目根目录**下运行(这样 project scope 会解析到这个仓库):
151
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
+
152
165
  **VS Code**(Copilot):
153
166
 
154
167
  ```sh
@@ -168,16 +181,39 @@ open-memex init --client cursor
168
181
 
169
182
  自动写 `.cursor/mcp.json` 和用户级 Copilot instructions。
170
183
 
184
+ **一次配置、所有项目通用(VS Code / Cursor):**
185
+
186
+ ```sh
187
+ open-memex init --client vscode --global --yes
188
+ ```
189
+
190
+ 把 server 条目写到编辑器的*用户级* MCP 配置(Windows 下是
191
+ `%APPDATA%\Code\User\mcp.json`,macOS 是
192
+ `~/Library/Application Support/Code/User/mcp.json`,Linux 是
193
+ `~/.config/Code/User/mcp.json`;Cursor 是 `~/.cursor/mcp.json`),
194
+ 而不是写到项目里——init 一次,每个项目打开自动启动 server。
195
+ 如果某个项目自己定义了 `.vscode/mcp.json`,项目级的优先。
196
+ (终端交互模式下,`init` 会问你配到项目级还是用户级。)
197
+
198
+ **opencode**(原生插件——推荐):
199
+
200
+ ```sh
201
+ open-memex init --client opencode --global --yes
202
+ ```
203
+
204
+ 把 `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]` 合并进用户级
205
+ `~/.config/opencode/opencode.json`——一次配置,每个项目自动生效,不用逐个项目
206
+ init。在 tools 之外还能获得关键词自动捕获和首轮上下文注入。(带注释的配置文件
207
+ 不会被改动——那种情况请手动加 `plugin` 这一行。)
208
+
171
209
  **opencode**(作为普通 MCP 客户端):
172
210
 
173
211
  ```sh
174
212
  open-memex init --client opencode
175
213
  ```
176
214
 
177
- 写项目级 `opencode.jsonc`(`type: "local"`)。想用原生插件?
178
- 在 `~/.config/opencode/opencode.jsonc` 里加
179
- `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]`——
180
- 在 tools 之外还能获得关键词自动捕获和首轮上下文注入。
215
+ 写项目级 `opencode.jsonc`(`type: "local"`)。只有当你更想要纯 MCP 而不是原生
216
+ 插件时才需要。
181
217
 
182
218
  **Claude Code**(在项目根目录运行):
183
219
 
@@ -208,11 +244,19 @@ Visual Studio 也会自动发现 `.vscode/mcp.json` 和 `.cursor/mcp.json`,
208
244
  到 repo,没装 open-memex 的同事看不到、也不会出错。团队人人都用
209
245
  open-memex 时可用 `--instructions project` 改写
210
246
  `.github/copilot-instructions.md`。
211
- - 在终端里会交互式询问:配哪个编辑器、是否开启关键词自动捕获、
212
- 是否在首轮注入记忆。`--yes` 全用默认值;脚本 / 非 TTY 环境不提问
213
- (编辑器默认 VS Code)。
247
+ - 不带 `--client` 时,`init` 自动检测已安装的编辑器(VS Code 看 `PATH` 有没有
248
+ `code` / 安装位置 / 已有的用户级配置;Cursor 看 `PATH` 有没有 `cursor` 或
249
+ `~/.cursor`;opencode 看 `PATH` 有没有 `opencode` 或其配置目录;项目里有
250
+ `.sln` 时算上 Visual Studio),一次全接上——支持用户级的走用户级,
251
+ 一次 init,所有项目通用。
252
+ - 在终端里会列出检测到的编辑器,请你确认是一次全配还是只配一个,
253
+ 再问是否开启关键词自动捕获、是否在首轮注入记忆。`--yes` 全用默认值;
254
+ 脚本 / 非 TTY 环境不提问,直接配所有检测到的编辑器。
214
255
  - 已有配置文件会被**合并,不会被覆盖**——重复运行是安全的。
215
256
  `--force` 强制覆盖。
257
+ - `--global` 把 MCP server 条目写到编辑器的用户级配置(VS Code / Cursor)——
258
+ 一次配置,所有项目通用。opencode 的 `--global` 走用户级原生插件,
259
+ 不用逐个项目 init;Visual Studio 按设计保持 solution 级。
216
260
  - 如果 `PATH` 上没有可用的 `open-memex`(比如一次性 npx),`init` 会把
217
261
  `npx -y open-memex mcp` 写进配置,配置照样能用。
218
262
  以后 `npm i -g open-memex` + `open-memex init --force` 可切换到更快
package/dist/cli.js CHANGED
@@ -223,11 +223,15 @@ Usage: open-memex migrate [--from <key>] [--to <key>] [--dry-run] [--on-conflict
223
223
 
224
224
  Flags:
225
225
  --from / --to scope keys (default: current project → personal)
226
- --dry-run preview without moving anything
226
+ --dry-run preview without moving anything (--to-v2 previews the legacy
227
+ files in place, including per-file conversion plans)
227
228
  --on-conflict newer (default), overwrite, or skip
228
229
  --to-v2 convert a legacy my-o-memory data dir to the v2 layout
229
230
 
230
231
  Always preview with --dry-run first; nothing moves without confirmation.
232
+ On Windows, if another program holds the legacy folder open, the backup
233
+ rename fails with an actionable message instead of a stack trace — close
234
+ the program and re-run.
231
235
 
232
236
  Examples:
233
237
  open-memex migrate --dry-run
@@ -246,16 +250,21 @@ Examples:
246
250
  agent memory instructions. Existing files are merged, never clobbered.
247
251
 
248
252
  Usage: open-memex init [--client vscode|cursor|opencode|visualstudio]
249
- [--instructions personal|project] [--force] [--yes]
253
+ [--instructions personal|project] [--global] [--force] [--yes]
250
254
 
251
255
  Flags:
252
- --client editor to configure (default: auto-detect)
256
+ --client editor to configure (default: auto-detect all installed editors)
253
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.
254
262
  --force overwrite existing config
255
263
  --yes accept all defaults, never prompt
256
264
 
257
265
  Examples:
258
266
  open-memex init
267
+ open-memex init --client vscode --global --yes
259
268
  open-memex init --client cursor --yes`,
260
269
  config: `Show config, or set a key.
261
270
 
@@ -316,16 +325,19 @@ Usage:
316
325
  Every command has its own help with description and examples:
317
326
  open-memex <command> --help (or -h)
318
327
 
319
- One-command project setup: \`open-memex init\` (or \`npx open-memex@alpha init\`) writes
320
- the MCP config for your editor (\`.vscode/mcp.json\`, \`.cursor/mcp.json\`,
321
- \`opencode.jsonc\`, or Visual Studio's solution-level \`.mcp.json\`) — no copy-paste
322
- needed. The Copilot memory instructions default to your user-level
328
+ One-command project setup: \`open-memex init\` (or \`npx open-memex@alpha init\`) detects
329
+ your installed editors and wires them all — user-level where the editor supports it
330
+ (VS Code / Cursor MCP config, opencode native plugin), so one init covers every project;
331
+ Visual Studio is included when the project has a solution file (its \`.mcp.json\`
332
+ stays solution-level by design). \`--client\` picks a single editor instead, and a
333
+ single-editor opencode init writes the per-project plain-MCP \`opencode.jsonc\`.
334
+ The Copilot memory instructions default to your user-level
323
335
  \`~/.copilot/copilot-instructions.md\` (all projects, never checked into a repo);
324
336
  \`--instructions project\` writes \`.github/copilot-instructions.md\` instead for
325
337
  teams where everyone uses open-memex.
326
338
  Existing files are merged, never clobbered; re-running is safe. On a terminal it
327
- asks which editor to set up and a couple of settings (keyword capture, first-turn
328
- injection); \`--yes\` accepts all defaults, and non-terminal runs never prompt.
339
+ confirms the detected editors and asks a couple of settings (keyword capture,
340
+ first-turn injection); \`--yes\` accepts all defaults, and non-terminal runs never prompt.
329
341
  \`open-memex config set <key> <value>\` changes those settings after install.
330
342
 
331
343
  Once installed globally (\`npm i -g open-memex@alpha\`) the \`open-memex\` command is
@@ -376,14 +388,21 @@ function parseFlags(argv) {
376
388
  for (let i = 0; i < argv.length; i++) {
377
389
  const a = argv[i];
378
390
  if (a.startsWith("--")) {
379
- const key = a.slice(2);
391
+ const raw = a.slice(2);
392
+ const eq = raw.indexOf("=");
393
+ if (eq >= 0) {
394
+ // D44: accept --key=value as well as --key value (issue #7 — the
395
+ // = form was silently misparsed before, dropping the flag).
396
+ out[raw.slice(0, eq)] = raw.slice(eq + 1);
397
+ continue;
398
+ }
380
399
  const val = argv[i + 1];
381
400
  if (val !== undefined && !val.startsWith("--")) {
382
- out[key] = val;
401
+ out[raw] = val;
383
402
  i++;
384
403
  }
385
404
  else {
386
- out[key] = "true";
405
+ out[raw] = "true";
387
406
  }
388
407
  }
389
408
  }
@@ -486,7 +505,15 @@ async function main() {
486
505
  if (cmd === "migrate" && rest.includes("--to-v2")) {
487
506
  const flags = parseFlags(rest);
488
507
  const dryRun = flags["dry-run"] === "true";
489
- const stats = migrateV2({ dryRun });
508
+ let stats;
509
+ try {
510
+ stats = migrateV2({ dryRun });
511
+ }
512
+ catch (err) {
513
+ // D44: actionable message, not a raw syscall stack (issue #7).
514
+ console.error(`Error: ${err.message}`);
515
+ process.exit(1);
516
+ }
490
517
  console.log(`${dryRun ? "DRY RUN: " : ""}scanned ${stats.scanned} files: ` +
491
518
  `${stats.converted} to convert, ${stats.skippedV2} already v2`);
492
519
  for (const p of stats.plans) {
@@ -496,7 +523,9 @@ async function main() {
496
523
  console.log(` - ${c}`);
497
524
  }
498
525
  if (stats.legacyBackup) {
499
- console.log(`\nlegacy my-o-memory data dir merged; backup kept at:\n ${stats.legacyBackup}`);
526
+ console.log(dryRun
527
+ ? `\nDRY RUN: legacy my-o-memory data dir found — it would be merged and backed up at:\n ${stats.legacyBackup}`
528
+ : `\nlegacy my-o-memory data dir merged; backup kept at:\n ${stats.legacyBackup}`);
500
529
  }
501
530
  if (!dryRun && stats.converted > 0) {
502
531
  console.log(`\nindex schema will rebuild automatically on next run; ` +
@@ -505,7 +534,7 @@ async function main() {
505
534
  return;
506
535
  }
507
536
  // `init` is a pure file operation (§17 adoption path) — no DB needed.
508
- // Interactive when on a TTY (asks editor + settings); --yes skips prompts.
537
+ // Interactive when on a TTY (confirms detected editors + settings); --yes skips prompts.
509
538
  if (cmd === "init") {
510
539
  const flags = parseFlags(rest);
511
540
  const { initProject } = await import("./init.js");
@@ -514,6 +543,7 @@ async function main() {
514
543
  force: flags["force"] === "true",
515
544
  yes: flags["yes"] === "true",
516
545
  instructions: flags["instructions"],
546
+ global: flags["global"] === "true",
517
547
  });
518
548
  return;
519
549
  }