open-memex 0.3.0-alpha → 0.3.0-alpha.3

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
@@ -5,7 +5,10 @@ for user-facing docs; `docs/V2-DESIGN.md` §18 for the roadmap. This file lists
5
5
 
6
6
  ## Runtime model — read before touching anything
7
7
 
8
- Three entry points execute the same TypeScript source, with **no build step**:
8
+ Three entry points execute the same TypeScript source. **Development is build-free**;
9
+ the published npm package ships pre-compiled JS (`npm run build` → `dist/`,
10
+ via `prepublishOnly` — Node refuses `--experimental-strip-types` for files under
11
+ `node_modules`, so a global install cannot run `src/` directly):
9
12
 
10
13
  - **opencode host** loads `src/index.ts` under embedded **Bun**. SQLite here is `bun:sqlite` (built-in).
11
14
  - **CLI** (`src/cli.ts`) and smoke tests run under **Node 22+** with `--experimental-strip-types`. SQLite here is `better-sqlite3` (native module).
@@ -34,16 +37,19 @@ node --experimental-strip-types scripts\smoke-mcp.ts # MCP handshake + tool r
34
37
  After `npm i -g open-memex@alpha` (or `npm link` from source), the `open-memex` bin is on
35
38
  PATH: `open-memex mcp` starts the MCP server, `open-memex mcp --print-config <client>`
36
39
  prints a client config snippet (client: vscode|cursor|claude|opencode|visualstudio),
37
- `open-memex init [--client vscode|cursor|opencode|visualstudio] [--force] [--yes]`
38
- one-command project setup (editor MCP config + .github/copilot-instructions.md;
39
- resolves the server command at init time — npx fallback when no durable bin is on PATH, D17),
40
+ `open-memex init [--client vscode|cursor|opencode|visualstudio] [--instructions personal|project] [--force] [--yes]`
41
+ one-command project setup (editor MCP config + Copilot memory instructions;
42
+ instructions default to user-level ~/.copilot/copilot-instructions.md so the repo
43
+ stays clean for teammates without open-memex — D22; resolves the server command
44
+ at init time — npx fallback when no durable bin is on PATH, D17),
40
45
  `open-memex config` prints the effective config, `open-memex capture --dry-run "text"`
41
46
  previews keyword capture without writing, `open-memex doctor` runs health checks
42
47
  (node version, config, scope resolution, storage writability, MCP handshake).
43
48
  `open-memex init` asks editor + two settings on a TTY (`--yes` skips, scripts never
44
49
  prompt); `open-memex config set <key> <value>` edits settings after install.
45
- The bin is a tiny JS launcher (`bin/open-memex.js`) that
46
- re-execs `src/cli.ts` with type-stripping — no build step, works on Node 22.6+.
50
+ The published `open-memex` bin points at `dist/cli.js` (compiled at publish time).
51
+ From a source checkout, `npm run cli` / `npm run mcp` still run `src/` directly
52
+ with type-stripping — no build step needed for development.
47
53
 
48
54
  There is **no `npm test`** and no CI. Verification loop is: `npm run typecheck` + `smoke-pure.ts` + (if touching sqlite) `npm run cli -- reindex` against a scratch `MY_O_MEMORY_HOME`.
49
55
 
package/README.md CHANGED
@@ -8,7 +8,7 @@ plus a generic MCP server (VS Code Copilot, Cursor, Claude Code, Visual Studio,
8
8
  - **Markdown files** as the source of truth (human-editable, git-friendly)
9
9
  - **SQLite FTS5** as a rebuildable index (BM25 keyword search, via `better-sqlite3`)
10
10
  - **Zero cloud**, zero account, zero third-party API
11
- - Loads directly under opencode's embedded Bun runtime; CLI and MCP server run under Node — no build step, no Bun install
11
+ - 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
12
 
13
13
  ## Installation
14
14
 
@@ -77,7 +77,7 @@ open-memex init --client vscode
77
77
  npx -y open-memex@alpha init --client vscode
78
78
  ```
79
79
 
80
- Writes `.vscode/mcp.json` and `.github/copilot-instructions.md`, then reload the
80
+ Writes `.vscode/mcp.json` and user-level Copilot instructions, then reload the
81
81
  window and confirm the `open-memex` server is started in Copilot Chat's MCP panel.
82
82
 
83
83
  **Cursor:**
@@ -86,7 +86,7 @@ window and confirm the `open-memex` server is started in Copilot Chat's MCP pane
86
86
  open-memex init --client cursor
87
87
  ```
88
88
 
89
- Writes `.cursor/mcp.json` and `.github/copilot-instructions.md`.
89
+ Writes `.cursor/mcp.json` and user-level Copilot instructions.
90
90
 
91
91
  **opencode** (as a plain MCP consumer):
92
92
 
@@ -112,7 +112,7 @@ claude mcp add open-memex -- open-memex mcp
112
112
  open-memex init --client visualstudio
113
113
  ```
114
114
 
115
- Writes solution-level `.mcp.json` and `.github/copilot-instructions.md`. Requires
115
+ Writes solution-level `.mcp.json` and user-level Copilot instructions. Requires
116
116
  Visual Studio 2022 17.14+ or Visual Studio 2026 (**Windows-only**). Visual Studio
117
117
  also auto-discovers `.vscode/mcp.json` and `.cursor/mcp.json`, so the VS Code setup
118
118
  above works too.
@@ -123,6 +123,12 @@ above works too.
123
123
 
124
124
  `init` notes:
125
125
 
126
+ - The Copilot memory instructions default to **user-level**
127
+ (`~/.copilot/copilot-instructions.md`; `%USERPROFILE%\copilot-instructions.md`
128
+ for Visual Studio) — they apply to all your projects and are never checked
129
+ into a repo, so teammates without open-memex see nothing and nothing breaks
130
+ for them. `--instructions project` writes `.github/copilot-instructions.md`
131
+ instead, for teams where everyone uses open-memex.
126
132
  - On a terminal it interactively asks which editor to set up, whether to enable
127
133
  keyword auto-capture, and whether to inject memories on the first turn.
128
134
  `--yes` accepts the defaults; scripts / non-TTY never prompt (editor defaults to
@@ -237,6 +243,8 @@ open-memex config set <key> <value> # change a setting
237
243
  open-memex doctor # environment health check
238
244
  open-memex capture --dry-run "记住我喜欢简洁的回答" # preview keyword capture
239
245
  open-memex mcp --print-config vscode|cursor|claude|opencode|visualstudio
246
+ open-memex --help # this reference
247
+ open-memex --version # installed version
240
248
  ```
241
249
 
242
250
  Memory operations:
@@ -259,8 +267,9 @@ open-memex reindex # rebuild the SQLite index from markdown
259
267
  open-memex migrate --to-v2 [--dry-run] # v1 data → v2
260
268
  ```
261
269
 
262
- The CLI runs under Node 22 with the built-in experimental TypeScript loader (no build
263
- step). From a source checkout, prefix every command with
270
+ The CLI runs under Node 22. From a source checkout it uses the built-in experimental
271
+ TypeScript loader (no build step); the published npm package ships pre-compiled JS
272
+ (`npm run build` at publish time). From a source checkout, prefix every command with
264
273
  `node --experimental-strip-types src/cli.ts` (or `npm run cli -- <command>` for
265
274
  simple cases — npm swallows unknown `--flag` args, so prefer direct `node`).
266
275
 
@@ -279,7 +288,7 @@ server with cwd set to your project root (`init` handles this for you).
279
288
 
280
289
  > **Note:** MCP is request/response — it gives the agent tools, not the opencode
281
290
  > plugin's automatic keyword capture or first-turn context injection. Proactive
282
- > memory use depends on the agent's instructions (the `.github/copilot-instructions.md`
291
+ > memory use depends on the agent's instructions (the Copilot instructions
283
292
  > that `init` writes).
284
293
 
285
294
  ## Roadmap
package/README.zh-CN.md CHANGED
@@ -8,7 +8,7 @@
8
8
  - **Markdown 文件**是 source of truth(人类可读、git 友好)
9
9
  - **SQLite FTS5** 做可重建索引(BM25 关键词检索,`better-sqlite3`)
10
10
  - **零云端**、零账号、零第三方 API
11
- - 直接跑在 opencode 内嵌的 Bun 运行时里;CLI 和 MCP server 跑在 Node 下——无需构建、无需安装 Bun
11
+ - 直接跑在 opencode 内嵌的 Bun 运行时里;CLI 和 MCP server 跑在 Node 下——开发时无需构建(发布的 npm 包带预编译好的 JS)、无需安装 Bun
12
12
 
13
13
  ## 安装
14
14
 
@@ -75,7 +75,7 @@ open-memex init --client vscode
75
75
  npx -y open-memex@alpha init --client vscode
76
76
  ```
77
77
 
78
- 自动写 `.vscode/mcp.json` 和 `.github/copilot-instructions.md`,然后重新加载窗口,
78
+ 自动写 `.vscode/mcp.json` 和用户级 Copilot instructions,然后重新加载窗口,
79
79
  在 Copilot Chat 的 MCP 面板里确认 `open-memex` server 已启动。
80
80
 
81
81
  **Cursor:**
@@ -84,7 +84,7 @@ npx -y open-memex@alpha init --client vscode
84
84
  open-memex init --client cursor
85
85
  ```
86
86
 
87
- 自动写 `.cursor/mcp.json` 和 `.github/copilot-instructions.md`。
87
+ 自动写 `.cursor/mcp.json` 和用户级 Copilot instructions。
88
88
 
89
89
  **opencode**(作为普通 MCP 客户端):
90
90
 
@@ -110,7 +110,7 @@ claude mcp add open-memex -- open-memex mcp
110
110
  open-memex init --client visualstudio
111
111
  ```
112
112
 
113
- 写 solution 级 `.mcp.json` 和 `.github/copilot-instructions.md`。需要
113
+ 写 solution 级 `.mcp.json` 和用户级 Copilot instructions。需要
114
114
  Visual Studio 2022 17.14+ 或 Visual Studio 2026(**仅 Windows**)。
115
115
  Visual Studio 也会自动发现 `.vscode/mcp.json` 和 `.cursor/mcp.json`,
116
116
  所以上面的 VS Code 配置同样可用。
@@ -120,6 +120,12 @@ Visual Studio 也会自动发现 `.vscode/mcp.json` 和 `.cursor/mcp.json`,
120
120
 
121
121
  `init` 说明:
122
122
 
123
+ - Copilot 记忆 instructions 默认写到**用户级**
124
+ (`~/.copilot/copilot-instructions.md`;Visual Studio 是
125
+ `%USERPROFILE%\copilot-instructions.md`)——所有项目生效,永不 checkin
126
+ 到 repo,没装 open-memex 的同事看不到、也不会出错。团队人人都用
127
+ open-memex 时可用 `--instructions project` 改写
128
+ `.github/copilot-instructions.md`。
123
129
  - 在终端里会交互式询问:配哪个编辑器、是否开启关键词自动捕获、
124
130
  是否在首轮注入记忆。`--yes` 全用默认值;脚本 / 非 TTY 环境不提问
125
131
  (编辑器默认 VS Code)。
@@ -236,6 +242,8 @@ open-memex config set <key> <value> # 改设置
236
242
  open-memex doctor # 环境健康检查
237
243
  open-memex capture --dry-run "记住我喜欢简洁的回答" # 预览关键词捕获
238
244
  open-memex mcp --print-config vscode|cursor|claude|opencode|visualstudio
245
+ open-memex --help # 本帮助
246
+ open-memex --version # 已安装版本
239
247
  ```
240
248
 
241
249
  记忆操作:
@@ -258,7 +266,8 @@ open-memex reindex # 从 markdown 重建 SQLite 索引
258
266
  open-memex migrate --to-v2 [--dry-run] # v1 数据 → v2
259
267
  ```
260
268
 
261
- CLI 跑在 Node 22 内置的实验性 TypeScript loader 下(无需构建)。
269
+ CLI 跑在 Node 22 下。从源码 checkout 使用时走内置的实验性 TypeScript loader(无需构建);
270
+ 发布的 npm 包带预编译好的 JS(发布时间执行 `npm run build`)。
262
271
  从源码 checkout 使用时,每条命令前加
263
272
  `node --experimental-strip-types src/cli.ts`(简单场景也可用
264
273
  `npm run cli -- <命令>`——但 npm 会吞掉未知的 `--flag` 参数,
@@ -279,7 +288,7 @@ project scope 从进程工作目录解析,所以配置 server 时 cwd 要指
279
288
 
280
289
  > **注意:** MCP 是请求/响应式的——它给 agent 提供 tools,但没有 opencode
281
290
  > 插件的关键词自动捕获和首轮上下文注入。想让 agent 主动用记忆,
282
- > 靠的是 agent 的 instructions(`init` 写的 `.github/copilot-instructions.md`)。
291
+ > 靠的是 agent 的 instructions(`init` 写的 Copilot instructions)。
283
292
 
284
293
  ## 路线图(Roadmap)
285
294
 
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Scan user text for memory-capture keyword triggers.
3
+ * Each pattern must have a single capture group whose value becomes the memory body.
4
+ * Personal patterns (cfg.keywordPersonalPatterns) force the personal scope.
5
+ *
6
+ * Personal patterns run first and claim their line: an explicit scope signal
7
+ * (e.g. "记住我对花粉过敏") must not also fire the generic 记住 into the project scope.
8
+ */
9
+ export function detectKeywords(userText, cfg) {
10
+ if (!cfg.keywordCaptureEnabled)
11
+ return [];
12
+ const hits = [];
13
+ const lines = userText.split(/\r?\n/);
14
+ const claimed = new Set();
15
+ const scan = (patterns, personal, skipClaimed) => {
16
+ for (const src of patterns) {
17
+ let re;
18
+ try {
19
+ re = new RegExp(src, "i");
20
+ }
21
+ catch {
22
+ continue;
23
+ }
24
+ for (let i = 0; i < lines.length; i++) {
25
+ if (skipClaimed && claimed.has(i))
26
+ continue;
27
+ const m = lines[i].match(re);
28
+ if (!m || !m[1])
29
+ continue;
30
+ const content = m[1].trim().replace(/[.!?]$/, "").trim();
31
+ if (content.length >= 3 && content.length <= 2000) {
32
+ hits.push({ content, pattern: src, personal });
33
+ if (personal)
34
+ claimed.add(i);
35
+ break; // one hit per pattern per message
36
+ }
37
+ }
38
+ }
39
+ };
40
+ scan(cfg.keywordPersonalPatterns, true, false);
41
+ scan(cfg.keywordPatterns, false, true);
42
+ return hits;
43
+ }