open-memex 0.4.1 → 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 +13 -7
- package/CONTRIBUTING.md +10 -10
- package/README.md +52 -8
- package/README.zh-CN.md +49 -7
- package/dist/cli.js +18 -9
- package/dist/init.js +299 -30
- package/docs/TEST-PLAN.md +2 -0
- package/docs/V2-DESIGN.md +37 -0
- package/package.json +1 -1
- package/scripts/smoke-pure.ts +70 -0
- package/src/cli.ts +18 -9
- package/src/init.ts +327 -27
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;
|
|
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`
|
|
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
|
-
`
|
|
130
|
-
|
|
131
|
-
|
|
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` —
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
@@ -156,6 +156,17 @@ 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 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
|
+
|
|
159
170
|
**VS Code** (Copilot):
|
|
160
171
|
|
|
161
172
|
```sh
|
|
@@ -175,16 +186,40 @@ open-memex init --client cursor
|
|
|
175
186
|
|
|
176
187
|
Writes `.cursor/mcp.json` and user-level Copilot instructions.
|
|
177
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
|
+
|
|
178
215
|
**opencode** (as a plain MCP consumer):
|
|
179
216
|
|
|
180
217
|
```sh
|
|
181
218
|
open-memex init --client opencode
|
|
182
219
|
```
|
|
183
220
|
|
|
184
|
-
Writes project-level `opencode.jsonc` (`type: "local"`).
|
|
185
|
-
|
|
186
|
-
`~/.config/opencode/opencode.jsonc` — you get keyword auto-capture and first-turn
|
|
187
|
-
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.
|
|
188
223
|
|
|
189
224
|
**Claude Code** (from your project root):
|
|
190
225
|
|
|
@@ -210,16 +245,25 @@ above works too.
|
|
|
210
245
|
|
|
211
246
|
`init` notes:
|
|
212
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.
|
|
213
257
|
- The Copilot memory instructions default to **user-level**
|
|
214
258
|
(`~/.copilot/copilot-instructions.md`; `%USERPROFILE%\copilot-instructions.md`
|
|
215
259
|
for Visual Studio) — they apply to all your projects and are never checked
|
|
216
260
|
into a repo, so teammates without open-memex see nothing and nothing breaks
|
|
217
261
|
for them. `--instructions project` writes `.github/copilot-instructions.md`
|
|
218
262
|
instead, for teams where everyone uses open-memex.
|
|
219
|
-
- On a terminal it
|
|
220
|
-
|
|
221
|
-
`--yes` accepts the defaults; scripts /
|
|
222
|
-
|
|
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.
|
|
223
267
|
- Existing config files are **merged, never clobbered** — re-running is safe.
|
|
224
268
|
`--force` overwrites.
|
|
225
269
|
- With no durable `open-memex` on `PATH` (e.g. one-shot npx), `init` writes an
|
package/README.zh-CN.md
CHANGED
|
@@ -151,6 +151,17 @@ 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
|
+
|
|
154
165
|
**VS Code**(Copilot):
|
|
155
166
|
|
|
156
167
|
```sh
|
|
@@ -170,16 +181,39 @@ open-memex init --client cursor
|
|
|
170
181
|
|
|
171
182
|
自动写 `.cursor/mcp.json` 和用户级 Copilot instructions。
|
|
172
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
|
+
|
|
173
209
|
**opencode**(作为普通 MCP 客户端):
|
|
174
210
|
|
|
175
211
|
```sh
|
|
176
212
|
open-memex init --client opencode
|
|
177
213
|
```
|
|
178
214
|
|
|
179
|
-
写项目级 `opencode.jsonc`(`type: "local"
|
|
180
|
-
|
|
181
|
-
`"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]`——
|
|
182
|
-
在 tools 之外还能获得关键词自动捕获和首轮上下文注入。
|
|
215
|
+
写项目级 `opencode.jsonc`(`type: "local"`)。只有当你更想要纯 MCP 而不是原生
|
|
216
|
+
插件时才需要。
|
|
183
217
|
|
|
184
218
|
**Claude Code**(在项目根目录运行):
|
|
185
219
|
|
|
@@ -210,11 +244,19 @@ Visual Studio 也会自动发现 `.vscode/mcp.json` 和 `.cursor/mcp.json`,
|
|
|
210
244
|
到 repo,没装 open-memex 的同事看不到、也不会出错。团队人人都用
|
|
211
245
|
open-memex 时可用 `--instructions project` 改写
|
|
212
246
|
`.github/copilot-instructions.md`。
|
|
213
|
-
-
|
|
214
|
-
|
|
215
|
-
|
|
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 环境不提问,直接配所有检测到的编辑器。
|
|
216
255
|
- 已有配置文件会被**合并,不会被覆盖**——重复运行是安全的。
|
|
217
256
|
`--force` 强制覆盖。
|
|
257
|
+
- `--global` 把 MCP server 条目写到编辑器的用户级配置(VS Code / Cursor)——
|
|
258
|
+
一次配置,所有项目通用。opencode 的 `--global` 走用户级原生插件,
|
|
259
|
+
不用逐个项目 init;Visual Studio 按设计保持 solution 级。
|
|
218
260
|
- 如果 `PATH` 上没有可用的 `open-memex`(比如一次性 npx),`init` 会把
|
|
219
261
|
`npx -y open-memex mcp` 写进配置,配置照样能用。
|
|
220
262
|
以后 `npm i -g open-memex` + `open-memex init --force` 可切换到更快
|
package/dist/cli.js
CHANGED
|
@@ -250,16 +250,21 @@ 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`,
|
|
264
269
|
config: `Show config, or set a key.
|
|
265
270
|
|
|
@@ -320,16 +325,19 @@ Usage:
|
|
|
320
325
|
Every command has its own help with description and examples:
|
|
321
326
|
open-memex <command> --help (or -h)
|
|
322
327
|
|
|
323
|
-
One-command project setup: \`open-memex init\` (or \`npx open-memex@alpha init\`)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
|
327
335
|
\`~/.copilot/copilot-instructions.md\` (all projects, never checked into a repo);
|
|
328
336
|
\`--instructions project\` writes \`.github/copilot-instructions.md\` instead for
|
|
329
337
|
teams where everyone uses open-memex.
|
|
330
338
|
Existing files are merged, never clobbered; re-running is safe. On a terminal it
|
|
331
|
-
|
|
332
|
-
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.
|
|
333
341
|
\`open-memex config set <key> <value>\` changes those settings after install.
|
|
334
342
|
|
|
335
343
|
Once installed globally (\`npm i -g open-memex@alpha\`) the \`open-memex\` command is
|
|
@@ -526,7 +534,7 @@ async function main() {
|
|
|
526
534
|
return;
|
|
527
535
|
}
|
|
528
536
|
// `init` is a pure file operation (§17 adoption path) — no DB needed.
|
|
529
|
-
// Interactive when on a TTY (
|
|
537
|
+
// Interactive when on a TTY (confirms detected editors + settings); --yes skips prompts.
|
|
530
538
|
if (cmd === "init") {
|
|
531
539
|
const flags = parseFlags(rest);
|
|
532
540
|
const { initProject } = await import("./init.js");
|
|
@@ -535,6 +543,7 @@ async function main() {
|
|
|
535
543
|
force: flags["force"] === "true",
|
|
536
544
|
yes: flags["yes"] === "true",
|
|
537
545
|
instructions: flags["instructions"],
|
|
546
|
+
global: flags["global"] === "true",
|
|
538
547
|
});
|
|
539
548
|
return;
|
|
540
549
|
}
|