open-memex 0.6.0 → 0.6.1-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 +3 -0
- package/README.md +546 -387
- package/README.zh-CN.md +381 -447
- package/dist/cli.js +71 -7
- package/dist/doctor.js +23 -1
- package/dist/init.js +3 -0
- package/dist/retrieve/cjk.js +14 -2
- package/dist/retrieve/query.js +54 -0
- package/dist/retrieve/search.js +20 -19
- package/dist/store/audit.js +101 -0
- package/dist/store/db.js +5 -0
- package/dist/store/markdown.js +6 -1
- package/dist/tools/memory.js +9 -1
- package/dist/tools/ops.js +6 -6
- package/docs/CONCEPTS.md +181 -0
- package/docs/CONCEPTS.zh-CN.md +163 -0
- package/docs/V2-DESIGN.md +80 -0
- package/package.json +1 -1
- package/scripts/smoke-pure.ts +36 -0
- package/src/cli.ts +78 -7
- package/src/doctor.ts +23 -1
- package/src/init.ts +3 -0
- package/src/retrieve/cjk.ts +18 -2
- package/src/retrieve/query.ts +58 -0
- package/src/retrieve/search.ts +27 -19
- package/src/store/audit.ts +136 -0
- package/src/store/db.ts +5 -0
- package/src/store/markdown.ts +6 -1
- package/src/tools/memory.ts +16 -1
- package/src/tools/ops.ts +6 -6
- package/docs/USER-GUIDE.md +0 -196
- package/docs/USER-GUIDE.zh-CN.md +0 -160
package/README.md
CHANGED
|
@@ -1,141 +1,195 @@
|
|
|
1
1
|
# open-memex
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Persistent memory for your AI coding agents — on your machine, in plain Markdown, shared by every tool you code with.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/open-memex)
|
|
6
6
|
[](./LICENSE)
|
|
7
7
|
|
|
8
8
|
[中文文档](./README.zh-CN.md)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Every AI coding session starts from zero: you re-explain the project, the agent
|
|
11
|
+
rediscovers the same gotchas, and yesterday's decisions vanish when the chat
|
|
12
|
+
ends. open-memex gives your agents a memory that survives the session. Say
|
|
13
|
+
"remember: we deploy on Fridays" once, and next week Copilot, Cursor, opencode,
|
|
14
|
+
or Claude Code already knows — because they all read and write the same local
|
|
15
|
+
memory on your machine.
|
|
16
|
+
|
|
17
|
+
- **Free and open source** (Apache-2.0). No account, no cloud, no telemetry —
|
|
18
|
+
everything lives on your machine, in files you can open and edit.
|
|
19
|
+
- **Local-first**: memories are plain Markdown files (the source of truth) with
|
|
20
|
+
a rebuildable SQLite keyword index. Nothing leaves your machine unless you
|
|
21
|
+
explicitly share it.
|
|
22
|
+
- **One memory, every agent**: wire up several editors with one command; they
|
|
23
|
+
share the same memory instead of keeping separate silos.
|
|
24
|
+
|
|
25
|
+
New here? This README takes you from install to a working memory in about a
|
|
26
|
+
minute. The [concept guide](./docs/CONCEPTS.md) explains the mental model in
|
|
27
|
+
depth once you're up and running.
|
|
28
|
+
|
|
29
|
+
## Contents
|
|
30
|
+
|
|
31
|
+
- [Quick start](#quick-start)
|
|
32
|
+
- [Core concepts](#core-concepts)
|
|
33
|
+
- [Which editors, which features](#which-editors-which-features)
|
|
34
|
+
- [Installation](#installation)
|
|
35
|
+
- [Setting up your editor](#setting-up-your-editor)
|
|
36
|
+
- [What `init` changes on your machine](#what-init-changes-on-your-machine)
|
|
37
|
+
- [Capture: how memories get saved](#capture-how-memories-get-saved)
|
|
38
|
+
- [Tools the agent gets](#tools-the-agent-gets)
|
|
39
|
+
- [Memory types](#memory-types)
|
|
40
|
+
- [Team workflow: sharing memories through Git](#team-workflow-sharing-memories-through-git)
|
|
41
|
+
- [Retrieval: how memories come back](#retrieval-how-memories-come-back)
|
|
42
|
+
- [Security & data](#security--data)
|
|
43
|
+
- [Limitations](#limitations)
|
|
44
|
+
- [Upgrading](#upgrading)
|
|
45
|
+
- [Storage layout](#storage-layout)
|
|
46
|
+
- [Config](#config)
|
|
47
|
+
- [CLI reference](#cli-reference)
|
|
48
|
+
- [MCP server](#mcp-server)
|
|
49
|
+
- [Scopes, in detail](#scopes-in-detail)
|
|
50
|
+
- [Troubleshooting](#troubleshooting)
|
|
51
|
+
- [FAQ](#faq)
|
|
52
|
+
- [Project status](#project-status)
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
You need **Node.js ≥ 22.6** (check with `node -v`). Then:
|
|
12
57
|
|
|
13
|
-
|
|
58
|
+
```sh
|
|
59
|
+
npm install -g open-memex
|
|
60
|
+
open-memex init
|
|
61
|
+
```
|
|
14
62
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
fade when the chat ends.
|
|
63
|
+
`init` detects the editors you have installed (VS Code, Cursor, opencode, and
|
|
64
|
+
Visual Studio when your project has a solution file) and connects each one to
|
|
65
|
+
open-memex. Restart your editor afterwards.
|
|
19
66
|
|
|
20
|
-
|
|
21
|
-
the lesson — as reviewable Markdown, and injects it back into the next session
|
|
22
|
-
automatically.
|
|
67
|
+
**See it work** (30 seconds):
|
|
23
68
|
|
|
24
|
-
|
|
69
|
+
```sh
|
|
70
|
+
open-memex add "This project deploys on Fridays"
|
|
71
|
+
```
|
|
25
72
|
|
|
26
|
-
|
|
73
|
+
Now open a new chat in your editor and ask your agent: *"When does this project
|
|
74
|
+
deploy?"* It already knows — no re-explaining. That round trip, capture once and
|
|
75
|
+
recall forever, is the whole product. Everything below is detail.
|
|
27
76
|
|
|
28
|
-
|
|
29
|
-
Copilot in VS Code, Cursor, opencode, Claude Code. Each tool keeps
|
|
30
|
-
its own silo: a decision made in one is invisible to the others.
|
|
77
|
+
Optional but recommended — check everything is wired up:
|
|
31
78
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
write the same memory on that machine. A constraint captured in VS Code is respected in
|
|
36
|
-
opencode; a lesson learned in Cursor shows up in Claude Code.
|
|
79
|
+
```sh
|
|
80
|
+
open-memex doctor
|
|
81
|
+
```
|
|
37
82
|
|
|
38
|
-
|
|
83
|
+
## Core concepts
|
|
39
84
|
|
|
40
|
-
|
|
41
|
-
plan/implement/verify loops): plans produce decisions, verification produces
|
|
42
|
-
rules — open-memex is the memory layer that keeps them across sessions instead
|
|
43
|
-
of re-deriving them on every run.
|
|
85
|
+
Three ideas explain almost everything open-memex does.
|
|
44
86
|
|
|
45
|
-
|
|
87
|
+
**1. Two scopes: `project` and `personal`.**
|
|
88
|
+
Every memory belongs to one of two places:
|
|
46
89
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
| Human-readable | Plain Markdown files | Dashboard / API | Yes | No |
|
|
53
|
-
| Works across AI tools | Yes — any MCP client (same machine) | Per-integration | No | No |
|
|
90
|
+
- **project** — knowledge about one codebase (decisions, constraints, lessons).
|
|
91
|
+
Scoped to the current repo automatically; you never set this up by hand.
|
|
92
|
+
- **personal** — knowledge about *you* (preferences, habits) that applies in
|
|
93
|
+
every project. It lives only on this machine and can never be shared into a
|
|
94
|
+
repo.
|
|
54
95
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- **Zero cloud**, zero account, zero third-party API
|
|
58
|
-
- 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
|
|
96
|
+
Facts about you ("I prefer concise diffs") go to `personal`; everything else
|
|
97
|
+
defaults to the current project.
|
|
59
98
|
|
|
60
|
-
|
|
99
|
+
**2. Capture → recall.**
|
|
100
|
+
Memories are saved as small Markdown files, one fact each. On the first turn of
|
|
101
|
+
every new session, open-memex hands your agent the most relevant ones
|
|
102
|
+
automatically, so it starts the session already knowing them. The agent can also
|
|
103
|
+
search the full memory on demand. You never have to "load" anything yourself.
|
|
61
104
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
│ MCP (stdio) — 11 tools
|
|
69
|
-
│ session-start injection
|
|
70
|
-
┌────────▼─────────┐
|
|
71
|
-
│ open-memex │
|
|
72
|
-
│ MCP server │
|
|
73
|
-
└──┬────────────┬──┘
|
|
74
|
-
│ │
|
|
75
|
-
┌────────────▼───┐ ┌─────▼──────────┐
|
|
76
|
-
│ Markdown files │ │ SQLite FTS5 │
|
|
77
|
-
│ source of truth│ │ rebuildable │
|
|
78
|
-
│ local-first │ │ index (BM25) │
|
|
79
|
-
└─────────────┬──┘ └────────────────┘
|
|
80
|
-
│ submit (explicit,
|
|
81
|
-
│ local commit)
|
|
82
|
-
┌───────▼────────┐
|
|
83
|
-
│ Git repo │
|
|
84
|
-
│ .ai/open-memex/│
|
|
85
|
-
│ PR-reviewed │
|
|
86
|
-
│ team memory │
|
|
87
|
-
└────────────────┘
|
|
88
|
-
|
|
89
|
-
personal scope: this machine only — never synced, never enters a repo.
|
|
90
|
-
```
|
|
105
|
+
**3. Your files, your rules.**
|
|
106
|
+
The Markdown files are the source of truth — open them, edit them, delete them,
|
|
107
|
+
grep them. The SQLite index next to them is just a search accelerator and
|
|
108
|
+
rebuilds from the files at any time (`open-memex reindex`). Team sharing, when
|
|
109
|
+
you want it, goes through the same review flow as code: nothing is shared
|
|
110
|
+
automatically (see [Team workflow](#team-workflow-sharing-memories-through-git)).
|
|
91
111
|
|
|
92
|
-
##
|
|
112
|
+
## Which editors, which features
|
|
93
113
|
|
|
94
|
-
|
|
114
|
+
open-memex talks to editors two ways: a native **opencode plugin**, and a
|
|
115
|
+
standard **MCP server** that any MCP-capable editor can use. (MCP — Model
|
|
116
|
+
Context Protocol — is the open standard editors use to give agents extra tools;
|
|
117
|
+
open-memex appears in your editor as a set of `memory_*` tools.) What you get
|
|
118
|
+
depends on which path an editor uses:
|
|
95
119
|
|
|
96
|
-
|
|
120
|
+
| Editor | Setup | Tools | Session-start recall | Keyword auto-capture |
|
|
121
|
+
|---|---|---|---|---|
|
|
122
|
+
| opencode (native plugin, recommended) | `open-memex init --client opencode --global` | 5 core tools | Built in — first turn of every session | Yes — `remember …`, `记住…` |
|
|
123
|
+
| VS Code (Copilot) | `open-memex init --client vscode` | All 11 via MCP | Via MCP guidance* | No — the agent saves when you ask |
|
|
124
|
+
| Cursor | `open-memex init --client cursor` | All 11 via MCP | Via MCP guidance* | No — the agent saves when you ask |
|
|
125
|
+
| Claude Code | `claude mcp add open-memex -- open-memex mcp` | All 11 via MCP | Via MCP guidance* | No — the agent saves when you ask |
|
|
126
|
+
| Visual Studio 2022 17.14+ / 2026 | `open-memex init --client visualstudio` | All 11 via MCP | Via MCP guidance* | No — the agent saves when you ask |
|
|
127
|
+
| Codex and other MCP clients | `open-memex mcp --print-config` | All 11 via MCP | Via MCP guidance* | No — the agent saves when you ask |
|
|
128
|
+
|
|
129
|
+
\* MCP has no hard session-start hook, so open-memex sends the agent guidance in
|
|
130
|
+
the MCP handshake (including how many drafts are waiting) and `init` writes the
|
|
131
|
+
fuller version into the editor's instruction files. In practice agents follow
|
|
132
|
+
it; the opencode plugin is the only path with true built-in first-turn
|
|
133
|
+
injection. The [Tools](#tools-the-agent-gets) section lists the 5 core tools
|
|
134
|
+
and the 6 extra workflow tools, so the "5 vs 11" split is explicit.
|
|
135
|
+
|
|
136
|
+
All editors on the same machine read and write the **same** memory — a
|
|
137
|
+
constraint captured in VS Code is respected in opencode; a lesson learned in
|
|
138
|
+
Cursor shows up in Claude Code. (Different machines do not sync automatically;
|
|
139
|
+
see the [FAQ](#faq).)
|
|
140
|
+
|
|
141
|
+
`init` also installs an **Agent Skill** (a short instruction file that teaches
|
|
142
|
+
skill-aware agents to use the CLI) for VS Code and Cursor, and for opencode in
|
|
143
|
+
per-project MCP mode. With the opencode native plugin wired, no skill is
|
|
144
|
+
installed there — the plugin already provides the memory tools, and a second
|
|
145
|
+
instruction set only made agents chatty.
|
|
97
146
|
|
|
98
|
-
|
|
147
|
+
## How it compares
|
|
99
148
|
|
|
100
|
-
|
|
149
|
+
| | open-memex | Instruction files (`CLAUDE.md`, `AGENTS.md`, …) | Cloud memory services | Chat history |
|
|
150
|
+
|---|---|---|---|---|
|
|
151
|
+
| Where it lives | Your machine + your repos | In the repo | Vendor servers | Gone when the chat ends |
|
|
152
|
+
| Who maintains it | Captured as you work; you review | You write and update by hand | The service | — |
|
|
153
|
+
| Works across AI tools | Yes — any MCP client (same machine) | One file per tool convention | Per-integration | No |
|
|
154
|
+
| Review before sharing | Yes — outbox + pull request | Yes — it's just files | Varies | No |
|
|
155
|
+
| Human-readable | Plain Markdown files | Yes | Dashboard / API | No |
|
|
101
156
|
|
|
102
|
-
|
|
157
|
+
Instruction files are great for a handful of standing rules — keep using them
|
|
158
|
+
(open-memex can even draft one from your memories; see `distill-agents` below).
|
|
159
|
+
open-memex covers the growing pile of decisions, lessons, and preferences that
|
|
160
|
+
no one remembers to write down.
|
|
103
161
|
|
|
104
|
-
|
|
105
|
-
npm install -g open-memex
|
|
106
|
-
```
|
|
162
|
+
## Installation
|
|
107
163
|
|
|
108
|
-
|
|
164
|
+
### Requirements
|
|
109
165
|
|
|
110
|
-
**
|
|
166
|
+
- **Node.js ≥ 22.6** (`open-memex doctor` verifies this for you)
|
|
111
167
|
|
|
112
|
-
|
|
113
|
-
npm install -g open-memex@alpha
|
|
114
|
-
```
|
|
168
|
+
### Install the CLI
|
|
115
169
|
|
|
116
170
|
```sh
|
|
117
|
-
open-memex
|
|
171
|
+
npm install -g open-memex
|
|
118
172
|
```
|
|
119
173
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```sh
|
|
125
|
-
npm view open-memex version # latest stable
|
|
126
|
-
npm view open-memex@alpha version # latest alpha
|
|
127
|
-
```
|
|
174
|
+
That's the stable release. Installing the package may print a reminder to run
|
|
175
|
+
`open-memex init` — the editor wiring is a separate step (see
|
|
176
|
+
[Setting up your editor](#setting-up-your-editor)), so don't worry if you
|
|
177
|
+
don't see the reminder; just run `init` next.
|
|
128
178
|
|
|
129
|
-
|
|
179
|
+
Two alternatives:
|
|
130
180
|
|
|
131
|
-
**No install — run via npx:**
|
|
181
|
+
- **No install — run via npx:** `npx -y open-memex <command>` runs any command
|
|
182
|
+
without installing (e.g. `npx -y open-memex init --client vscode`). Slower to
|
|
183
|
+
start, nothing to uninstall.
|
|
184
|
+
- **Alpha builds** (newest features, rougher edges, for testers):
|
|
185
|
+
`npm install -g open-memex@alpha`. Check what's published with
|
|
186
|
+
`npm view open-memex version` (stable) and `npm view open-memex@alpha version`
|
|
187
|
+
(alpha).
|
|
132
188
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
npx -y open-memex@alpha <command> # alpha line, no install
|
|
136
|
-
```
|
|
189
|
+
If `open-memex` isn't found after installing, your PATH needs attention — see
|
|
190
|
+
[Troubleshooting](#troubleshooting).
|
|
137
191
|
|
|
138
|
-
|
|
192
|
+
### From source (for contributors)
|
|
139
193
|
|
|
140
194
|
```sh
|
|
141
195
|
git clone -b main https://github.com/stoneskin/open-memex.git
|
|
@@ -144,38 +198,10 @@ npm install
|
|
|
144
198
|
node --experimental-strip-types src/cli.ts <command>
|
|
145
199
|
```
|
|
146
200
|
|
|
147
|
-
|
|
201
|
+
## Setting up your editor
|
|
148
202
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
1. Find the folder: `npm config get prefix`
|
|
153
|
-
- **Windows:** the launcher (`open-memex.cmd`) sits directly in that folder, e.g.
|
|
154
|
-
`C:\Users\<you>\AppData\Roaming\npm`
|
|
155
|
-
- **macOS / Linux:** it's in `<prefix>/bin`, e.g. `/usr/local/bin` or
|
|
156
|
-
`~/.nvm/versions/node/v22.x.x/bin`
|
|
157
|
-
2. Add it to `PATH`:
|
|
158
|
-
- **Windows:** Settings → System → About → Advanced system settings →
|
|
159
|
-
Environment Variables → add the folder to the *User* `Path` → **restart the
|
|
160
|
-
terminal**. Verify with `where open-memex`.
|
|
161
|
-
- **macOS / Linux:** add `export PATH="$(npm prefix -g)/bin:$PATH"` to
|
|
162
|
-
`~/.zshrc` (or `~/.bashrc`), restart the shell, verify with
|
|
163
|
-
`command -v open-memex`.
|
|
164
|
-
3. No admin rights / don't want to touch `PATH`? Use the npx form above — npx
|
|
165
|
-
resolves the package itself and needs no `PATH` changes.
|
|
166
|
-
|
|
167
|
-
#### "`EBUSY` / `EPERM` on `better_sqlite3.node`" — Windows reinstall
|
|
168
|
-
|
|
169
|
-
On Windows a loaded DLL is locked: if the open-memex MCP server is running
|
|
170
|
-
(VS Code MCP panel, Cursor, etc.), `npm install -g open-memex` cannot
|
|
171
|
-
replace `better_sqlite3.node` and fails with `EBUSY` / `EPERM`. Stop the MCP
|
|
172
|
-
server first (or quit the editor), then re-run the install. If it still fails,
|
|
173
|
-
delete `node_modules/open-memex` and any `node_modules/.open-memex-*` temp
|
|
174
|
-
folders under your global npm root and install again.
|
|
175
|
-
|
|
176
|
-
### Step 2 — One-command setup for your editor
|
|
177
|
-
|
|
178
|
-
Run from your **project root** (so the project scope resolves to this repo):
|
|
203
|
+
Run `init` from your **project root** (the top folder of the repo you're working
|
|
204
|
+
in) so the project scope resolves to that repo:
|
|
179
205
|
|
|
180
206
|
```sh
|
|
181
207
|
open-memex init --yes
|
|
@@ -183,41 +209,22 @@ open-memex init --yes
|
|
|
183
209
|
npx -y open-memex init --yes
|
|
184
210
|
```
|
|
185
211
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
the plugin already provides memory tools), so skill-aware agents can use your memory via
|
|
192
|
-
the CLI with no MCP configuration. Prefer to pick a single editor? Pass `--client`:
|
|
193
|
-
|
|
194
|
-
> **Two different "globals" — don't mix them up.**
|
|
195
|
-
> - `npm install -g open-memex` installs the *package* globally: it puts the
|
|
196
|
-
> `open-memex` command on your PATH.
|
|
197
|
-
> - `init --global` writes the *editor config* at user level instead of the
|
|
198
|
-
> project: init once, the wiring works in every project. It works the same
|
|
199
|
-
> whether the package was installed globally or run via npx.
|
|
200
|
-
|
|
201
|
-
Installing the package also prints a reminder to run `open-memex init` — the
|
|
202
|
-
wiring is a separate step. And if you run bare `open-memex` on a machine where
|
|
203
|
-
init never completed, it offers to run it for you (only on an interactive
|
|
204
|
-
terminal; scripts and CI just see the usual usage text). When init finishes,
|
|
205
|
-
it prints one concrete next step — save a memory with `open-memex add`, then
|
|
206
|
-
ask your agent to recall it — so a first-time user sees what "it works" looks
|
|
207
|
-
like.
|
|
212
|
+
`--yes` accepts the recommended defaults for everything `init` asks about
|
|
213
|
+
(editors to wire, auto-capture, first-turn recall). Leave it off if you want to
|
|
214
|
+
answer each question. With no `--client`, `init` detects your installed editors
|
|
215
|
+
and wires them all — one init covers every project. Prefer a single editor?
|
|
216
|
+
Pass `--client`:
|
|
208
217
|
|
|
209
218
|
**VS Code** (Copilot):
|
|
210
219
|
|
|
211
220
|
```sh
|
|
212
221
|
open-memex init --client vscode
|
|
213
|
-
# …or without installing the package first:
|
|
214
|
-
npx -y open-memex init --client vscode
|
|
215
222
|
```
|
|
216
223
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
Writes the MCP server entry; reload the window afterwards and confirm the
|
|
225
|
+
`open-memex` server is started in Copilot Chat's MCP panel. By default the
|
|
226
|
+
server entry goes to VS Code's *user-level* config (works in every project);
|
|
227
|
+
`init` can also write a project-level `.vscode/mcp.json` if you prefer.
|
|
221
228
|
|
|
222
229
|
**Cursor:**
|
|
223
230
|
|
|
@@ -225,24 +232,8 @@ per-project or user-level instead of guessing; `--global` forces user-level.
|
|
|
225
232
|
open-memex init --client cursor
|
|
226
233
|
```
|
|
227
234
|
|
|
228
|
-
Same shape as VS Code:
|
|
229
|
-
|
|
230
|
-
instructions.
|
|
231
|
-
|
|
232
|
-
**One-time setup for all projects (VS Code / Cursor):**
|
|
233
|
-
|
|
234
|
-
```sh
|
|
235
|
-
open-memex init --client vscode --global --yes
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
Writes the server entry to the editor's *user-level* MCP config
|
|
239
|
-
(`%APPDATA%\Code\User\mcp.json` on Windows,
|
|
240
|
-
`~/Library/Application Support/Code/User/mcp.json` on macOS,
|
|
241
|
-
`~/.config/Code/User/mcp.json` on Linux; `~/.cursor/mcp.json` for Cursor)
|
|
242
|
-
instead of the project — init once, the server starts in every project.
|
|
243
|
-
A per-project `.vscode/mcp.json` still wins if a project defines its own.
|
|
244
|
-
If the user-level file has comments in it (VS Code accepts JSONC), `init` leaves
|
|
245
|
-
the file untouched and prints the exact snippet to paste in by hand.
|
|
235
|
+
Same shape as VS Code: user-level MCP config by default, project-level
|
|
236
|
+
`.cursor/mcp.json` on request, plus Copilot-style instructions.
|
|
246
237
|
|
|
247
238
|
**opencode** (native plugin — recommended):
|
|
248
239
|
|
|
@@ -250,12 +241,11 @@ the file untouched and prints the exact snippet to paste in by hand.
|
|
|
250
241
|
open-memex init --client opencode --global --yes
|
|
251
242
|
```
|
|
252
243
|
|
|
253
|
-
Merges
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
add the `plugin` line by hand in that case.)
|
|
244
|
+
Merges the native plugin into your user-level `~/.config/opencode/opencode.json`
|
|
245
|
+
(or `opencode.jsonc` if that's the file you already have) — one-time, every
|
|
246
|
+
project picks it up, no per-project init. You get the 5 core tools, keyword
|
|
247
|
+
auto-capture, and first-turn context injection. (A config file with comments is
|
|
248
|
+
left untouched — `init` prints the line to add by hand.)
|
|
259
249
|
|
|
260
250
|
**opencode** (as a plain MCP consumer):
|
|
261
251
|
|
|
@@ -263,8 +253,9 @@ add the `plugin` line by hand in that case.)
|
|
|
263
253
|
open-memex init --client opencode
|
|
264
254
|
```
|
|
265
255
|
|
|
266
|
-
Writes project-level `opencode.jsonc`
|
|
267
|
-
prefer plain MCP over the native plugin
|
|
256
|
+
Writes a project-level `opencode.jsonc` with the MCP server. Only needed if you
|
|
257
|
+
prefer plain MCP over the native plugin — you give up keyword capture and
|
|
258
|
+
built-in injection.
|
|
268
259
|
|
|
269
260
|
**Claude Code** (from your project root):
|
|
270
261
|
|
|
@@ -279,97 +270,144 @@ claude mcp add open-memex -- open-memex mcp
|
|
|
279
270
|
open-memex init --client visualstudio
|
|
280
271
|
```
|
|
281
272
|
|
|
282
|
-
Writes solution-level `.mcp.json
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
above works too.
|
|
273
|
+
Writes solution-level `.mcp.json`. Requires Visual Studio 2022 17.14+ or Visual
|
|
274
|
+
Studio 2026 (Windows-only). Visual Studio also auto-discovers `.vscode/mcp.json`
|
|
275
|
+
and `.cursor/mcp.json`, so the VS Code setup above works too.
|
|
286
276
|
|
|
287
277
|
**Codex:** no `init` client yet — add the server manually via
|
|
288
278
|
`open-memex mcp --print-config` as a starting point (`[mcp_servers]` in
|
|
289
279
|
`config.toml`, or `codex mcp add`).
|
|
290
280
|
|
|
291
|
-
|
|
281
|
+
### One-time setup for all projects (VS Code / Cursor)
|
|
292
282
|
|
|
293
283
|
```sh
|
|
294
|
-
open-memex
|
|
284
|
+
open-memex init --client vscode --global --yes
|
|
295
285
|
```
|
|
296
286
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
for them. `--instructions project` writes `.github/copilot-instructions.md`
|
|
318
|
-
instead, for teams where everyone uses open-memex.
|
|
319
|
-
- On a terminal it shows the detected editors, asks you to confirm wiring them
|
|
320
|
-
all (or pick one), and asks whether to enable keyword auto-capture and
|
|
321
|
-
first-turn memory injection. `--yes` accepts the defaults; scripts /
|
|
322
|
-
non-TTY never prompt and wire every detected editor.
|
|
323
|
-
- Existing config files are **merged, never clobbered** — re-running is safe.
|
|
324
|
-
`--force` overwrites.
|
|
287
|
+
> **Two different "globals" — don't mix them up.**
|
|
288
|
+
> - `npm install -g open-memex` installs the *package* globally: it puts the
|
|
289
|
+
> `open-memex` command on your PATH.
|
|
290
|
+
> - `init --global` writes the *editor config* at user level instead of the
|
|
291
|
+
> project: init once, the wiring works in every project. It works the same
|
|
292
|
+
> whether the package was installed globally or run via npx.
|
|
293
|
+
|
|
294
|
+
The `--global` form writes the server entry to the editor's *user-level* MCP
|
|
295
|
+
config (`%APPDATA%\Code\User\mcp.json` on Windows,
|
|
296
|
+
`~/Library/Application Support/Code/User/mcp.json` on macOS,
|
|
297
|
+
`~/.config/Code/User/mcp.json` on Linux; `~/.cursor/mcp.json` for Cursor)
|
|
298
|
+
instead of the project — init once, the server starts in every project.
|
|
299
|
+
A per-project `.vscode/mcp.json` still wins if a project defines its own.
|
|
300
|
+
If the user-level file has comments in it (editors accept JSONC), `init` leaves
|
|
301
|
+
the file untouched and prints the exact snippet to paste in by hand.
|
|
302
|
+
|
|
303
|
+
### `init` behavior notes
|
|
304
|
+
|
|
305
|
+
- Existing config files are **merged, never overwritten** — re-running `init`
|
|
306
|
+
is safe. `--force` rewrites our entries.
|
|
325
307
|
- With no durable `open-memex` on `PATH` (e.g. one-shot npx), `init` writes an
|
|
326
308
|
`npx -y open-memex mcp` server command into the config so the setup keeps
|
|
327
309
|
working. `npm i -g open-memex` + `open-memex init --force` switches to the
|
|
328
310
|
faster direct command later.
|
|
311
|
+
- On an interactive terminal, `init` shows the detected editors and asks you to
|
|
312
|
+
confirm; scripts and CI never prompt and wire every detected editor.
|
|
313
|
+
- If you run bare `open-memex` on a machine where init never completed, it
|
|
314
|
+
offers to run it for you (interactive terminals only).
|
|
329
315
|
|
|
330
|
-
###
|
|
316
|
+
### Remove the wiring
|
|
331
317
|
|
|
332
318
|
```sh
|
|
333
|
-
open-memex
|
|
319
|
+
open-memex uninstall --yes
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Reverses `init` — removes the MCP server entry, the opencode plugin line, the
|
|
323
|
+
Agent Skill, and the open-memex section of the editor instructions. With no
|
|
324
|
+
`--client` it cleans up every detected editor; `--global` limits the cleanup to
|
|
325
|
+
user-level wiring. Your memories are never touched.
|
|
326
|
+
|
|
327
|
+
## What `init` changes on your machine
|
|
328
|
+
|
|
329
|
+
Everything `init` writes, in one place:
|
|
330
|
+
|
|
331
|
+
- **Memory data** (created on first use, not by `init` itself):
|
|
332
|
+
`%APPDATA%\open-memex\` on Windows, `~/.local/share/open-memex/` on
|
|
333
|
+
macOS/Linux — your memory files and the search index. Nothing here is ever
|
|
334
|
+
modified by `uninstall`.
|
|
335
|
+
- **Editor wiring** (removed by `open-memex uninstall`):
|
|
336
|
+
- opencode: a `"plugin"` entry merged into
|
|
337
|
+
`~/.config/opencode/opencode.json` (or `.jsonc`). Stale `my-o-memory`
|
|
338
|
+
entries from before the rename are removed at the same time.
|
|
339
|
+
- VS Code / Cursor: an `open-memex` server entry in the user-level or
|
|
340
|
+
project-level MCP config, plus an open-memex section in the Copilot
|
|
341
|
+
instructions (user-level `~/.copilot/copilot-instructions.md` by default;
|
|
342
|
+
`--instructions project` writes `.github/copilot-instructions.md` in the
|
|
343
|
+
repo instead, for teams where everyone uses open-memex).
|
|
344
|
+
- Visual Studio: `.mcp.json` next to your solution.
|
|
345
|
+
- Agent Skill: a `skills/open-memex/` folder for VS Code
|
|
346
|
+
(`~/.copilot/skills/`), Cursor (`~/.cursor/skills/`), or opencode in
|
|
347
|
+
per-project MCP mode (`~/.config/opencode/skills/`).
|
|
348
|
+
- **Your repo**: nothing. Files only appear in a repo when you explicitly run
|
|
349
|
+
`submit` (see Team workflow) — a local commit, never an automatic push.
|
|
350
|
+
|
|
351
|
+
Files with comments (JSONC) are never rewritten: `init` prints the exact
|
|
352
|
+
snippet to paste instead.
|
|
353
|
+
|
|
354
|
+
## Capture: how memories get saved
|
|
355
|
+
|
|
356
|
+
Three ways memories get in:
|
|
357
|
+
|
|
358
|
+
- **Keyword triggers** (opencode native plugin only): say `remember …`,
|
|
359
|
+
`note that …`, `don't forget …`, `TIL …`, `save this …` — or in Chinese
|
|
360
|
+
`记住…` / `记一下` / `记录一下` / `别忘了…` — and the sentence is captured
|
|
361
|
+
without any tool call. Captures land in the current **project** by default;
|
|
362
|
+
phrases that signal "this is about me" — `remember for me …`, `记住我…`,
|
|
363
|
+
`替我记…`, `我觉得…`, `我喜欢…` — go to **personal** instead, and
|
|
364
|
+
team-context phrases (`我们决定…`, `帮我们记住…`) stay in project.
|
|
365
|
+
- **The agent saves it**: in any editor, ask your agent to remember something
|
|
366
|
+
(or it saves on its own when you state a fact worth keeping) — it calls
|
|
367
|
+
`memory_add`. The routing above is a heuristic; you can always say "save this
|
|
368
|
+
to my personal memory" or use the CLI with `--scope` to be explicit.
|
|
369
|
+
- **The CLI**: `open-memex add "…"` with optional `--scope` / `--tags` / `--type`.
|
|
370
|
+
|
|
371
|
+
**Redaction.** Wrap anything sensitive in `<private>…</private>` and it is
|
|
372
|
+
stripped before saving. Recognized secrets (API keys, tokens, high-entropy
|
|
373
|
+
credentials) are masked in place — the first 4 characters are kept so you can
|
|
374
|
+
tell *which* key it was, the rest is replaced — and the memory is still saved.
|
|
375
|
+
Preview exactly what a message would capture, safely, any time:
|
|
376
|
+
|
|
377
|
+
```sh
|
|
378
|
+
open-memex capture --dry-run "…"
|
|
334
379
|
```
|
|
335
380
|
|
|
336
|
-
|
|
337
|
-
storage writability, then boots a real MCP server and runs `initialize` +
|
|
338
|
-
`tools/list` against it — all eleven tools must show up.
|
|
381
|
+
If a secret slips through anyway, `open-memex forget <id>` deletes the memory.
|
|
339
382
|
|
|
340
383
|
## Tools the agent gets
|
|
341
384
|
|
|
385
|
+
The MCP server exposes eleven tools; the opencode native plugin exposes the
|
|
386
|
+
five core ones (marked ●). The other six are the team-review workflow tools —
|
|
387
|
+
they only matter once you share memories through Git.
|
|
388
|
+
|
|
342
389
|
| Tool | What it does |
|
|
343
390
|
|---|---|
|
|
344
|
-
| `memory_add` | Save a fact, preference, decision, note |
|
|
345
|
-
| `memory_search` | Keyword search (BM25) across project + personal memories |
|
|
346
|
-
| `memory_list` | List memories in a scope, newest first |
|
|
347
|
-
| `memory_supersede` | Replace a memory with a newer version (keeps a supersede chain) |
|
|
348
|
-
| `memory_forget` | Delete a memory by id |
|
|
349
|
-
| `memory_status`
|
|
350
|
-
| `memory_submit`
|
|
351
|
-
| `memory_propose`
|
|
352
|
-
| `memory_promote`
|
|
353
|
-
| `memory_resolve`
|
|
354
|
-
| `memory_pr_status`
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
-
|
|
359
|
-
`note that …`, `don't forget …`, `TIL …`, `save this …`, plus Chinese
|
|
360
|
-
`记住…` / `记一下` / `记录一下` / `别忘了…`.
|
|
361
|
-
Scope routing: first-person singular goes **personal** (`remember for me`,
|
|
362
|
-
`记住我…`, `替我记…`, `我觉得…`, `我喜欢…`); first-person plural goes to the
|
|
363
|
-
current **project** scope (`我们认为…`, `我们决定…`, `帮我们记住…`).
|
|
364
|
-
- **Explicit tool calls** by the agent (via `memory_add`)
|
|
365
|
-
- **Redaction**: content inside `<private>…</private>` tags is stripped; detected
|
|
366
|
-
secrets (API keys, tokens, high-entropy credentials) are masked in place — first
|
|
367
|
-
4 characters kept, the rest replaced with `x` — and the memory is saved.
|
|
368
|
-
Preview what a message would capture with `open-memex capture --dry-run "…"`.
|
|
391
|
+
| ● `memory_add` | Save a fact, preference, decision, note |
|
|
392
|
+
| ● `memory_search` | Keyword search (BM25) across project + personal memories |
|
|
393
|
+
| ● `memory_list` | List memories in a scope, newest first |
|
|
394
|
+
| ● `memory_supersede` | Replace a memory with a newer version (keeps a supersede chain) |
|
|
395
|
+
| ● `memory_forget` | Delete a memory by id |
|
|
396
|
+
| `memory_status` | Show the sync queue: outbox drafts, repo review states, uncommitted files |
|
|
397
|
+
| `memory_submit` | Move named drafts into the repo memory dir (local branch + commit) |
|
|
398
|
+
| `memory_propose` | Copy personal memories into the project scope as review candidates |
|
|
399
|
+
| `memory_promote` | Advance `proposed → approved → published` (or reject / resubmit) |
|
|
400
|
+
| `memory_resolve` | List conflicted memory files / 3-way-merge one of them |
|
|
401
|
+
| `memory_pr_status` | Map the branch PR's GitHub state onto each memory's review state |
|
|
402
|
+
|
|
403
|
+
So an MCP-connected editor always has the full set; opencode's plugin covers
|
|
404
|
+
capture and recall, and anything workflow-shaped goes through the CLI or an
|
|
405
|
+
MCP-connected editor.
|
|
369
406
|
|
|
370
407
|
## Memory types
|
|
371
408
|
|
|
372
|
-
|
|
409
|
+
Every memory has a `type` (what it is) and `tags` (what it's about). Eleven
|
|
410
|
+
types are built in:
|
|
373
411
|
|
|
374
412
|
| Type | Captures |
|
|
375
413
|
|---|---|
|
|
@@ -385,60 +423,119 @@ Eleven types — `type` says what the memory is, `tags` say what it's about:
|
|
|
385
423
|
| `observation` | Something noticed, not yet a conclusion |
|
|
386
424
|
| `reference` | A pointer to the authoritative doc (no copying) |
|
|
387
425
|
|
|
388
|
-
|
|
426
|
+
`--type` accepts any string, but sticking to the built-in set keeps session-start
|
|
427
|
+
labels, search, and `distill-agents` output predictable.
|
|
428
|
+
|
|
429
|
+
## Team workflow: sharing memories through Git
|
|
389
430
|
|
|
390
|
-
|
|
391
|
-
|
|
431
|
+
**Working solo? You can skip this section** — everything above is the whole
|
|
432
|
+
product for one person. Nothing below ever happens automatically.
|
|
433
|
+
|
|
434
|
+
Personal notes stay private. Project knowledge, when you choose to share it,
|
|
435
|
+
follows an explicit, reviewable pipeline shaped like code review:
|
|
392
436
|
|
|
393
437
|
```
|
|
394
438
|
capture → outbox (draft, local) → submit → repo (.ai/open-memex/) → PR review → published → recall
|
|
395
439
|
```
|
|
396
440
|
|
|
397
441
|
1. **Capture** — save decisions, gotchas, lessons as drafts during normal work.
|
|
398
|
-
2. **Review** — drafts wait in a local outbox
|
|
399
|
-
"sync memory" in chat
|
|
442
|
+
2. **Review** — drafts wait in a local outbox (on your machine, invisible to
|
|
443
|
+
git); `open-memex sync-status` — or just saying "sync memory" in chat —
|
|
444
|
+
shows what's pending.
|
|
400
445
|
3. **Submit** — you name the memories; they move into `<repo>/.ai/open-memex/`
|
|
401
|
-
with a local commit. open-memex never
|
|
446
|
+
with a local commit on your current branch. open-memex never pushes on its
|
|
447
|
+
own; it prints the push + PR commands, and an agent holding your explicit
|
|
448
|
+
yes can carry them out.
|
|
402
449
|
4. **PR review** — memories are plain Markdown; reviewers approve, request
|
|
403
|
-
changes, or reject through the normal branch/PR process
|
|
404
|
-
`pr-status`, `resolve`).
|
|
450
|
+
changes, or reject through the normal branch/PR process.
|
|
405
451
|
5. **Recall** — published memories are injected at session start and searchable
|
|
406
452
|
on demand, for humans and agents alike.
|
|
407
453
|
|
|
408
|
-
|
|
454
|
+
Whoever tends the shared memory follows the [curator convention](./docs/CURATOR.md):
|
|
455
|
+
what to approve, what to send back, and the hygiene rules that keep shared
|
|
456
|
+
memory from rotting.
|
|
457
|
+
|
|
458
|
+
## Retrieval: how memories come back
|
|
459
|
+
|
|
460
|
+
On the first turn of every session, open-memex injects an `[OPEN-MEMEX]` block
|
|
461
|
+
into the agent's context with the most recent project memories (default: top 8)
|
|
462
|
+
and your personal preferences (default: top 5). It looks like this:
|
|
463
|
+
|
|
464
|
+
```text
|
|
465
|
+
[OPEN-MEMEX]
|
|
466
|
+
|
|
467
|
+
User profile / preferences:
|
|
468
|
+
- I prefer concise diffs
|
|
469
|
+
|
|
470
|
+
Project knowledge (my-repo):
|
|
471
|
+
- [decision] We deploy on Fridays; the release train leaves at 10:00
|
|
472
|
+
|
|
473
|
+
Use the `memory_search` tool to look up more. Use `memory_add` to save new facts.
|
|
474
|
+
Do not mention this block to the user unless asked.
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
It's a snapshot, not the whole memory — the agent can call `memory_search` any
|
|
478
|
+
time for the rest. Both top-N counts are configurable (see [Config](#config)).
|
|
479
|
+
For MCP clients this block is delivered as handshake guidance the agent follows;
|
|
480
|
+
the opencode plugin injects it directly on the first turn.
|
|
409
481
|
|
|
410
482
|
## Security & data
|
|
411
483
|
|
|
412
|
-
- **Local-first:** everything lives on your machine (`%APPDATA%\open-memex`
|
|
413
|
-
`~/.local/share/open-memex`) plus the repos you
|
|
414
|
-
zero accounts, zero third-party APIs, zero
|
|
484
|
+
- **Local-first:** everything lives on your machine (`%APPDATA%\open-memex` on
|
|
485
|
+
Windows, `~/.local/share/open-memex` on macOS/Linux) plus the repos you
|
|
486
|
+
choose. Zero cloud calls, zero accounts, zero third-party APIs, zero
|
|
487
|
+
telemetry.
|
|
415
488
|
- **Secrets stay out:** `<private>…</private>` spans are stripped; detected API
|
|
416
489
|
keys/tokens are masked in place before saving. Preview with
|
|
417
490
|
`open-memex capture --dry-run "…"`.
|
|
418
|
-
- **Personal never syncs:** the `personal` scope is this machine only —
|
|
419
|
-
from export by default and can never enter a repo.
|
|
491
|
+
- **Personal never syncs:** the `personal` scope is this machine only —
|
|
492
|
+
excluded from export by default and can never enter a repo.
|
|
420
493
|
- **Auditable sharing:** team memories move only by explicit `submit`, travel
|
|
421
494
|
through branch/PR review, and every `promote` transition is appended to the
|
|
422
495
|
memory's `review_history` (who / when / why).
|
|
423
496
|
- **You own the files:** Markdown is the source of truth — inspect, edit, or
|
|
424
497
|
delete anything by hand; the SQLite index rebuilds from the files.
|
|
425
498
|
|
|
426
|
-
##
|
|
499
|
+
## Limitations
|
|
500
|
+
|
|
501
|
+
Honest edges, so nothing surprises you:
|
|
502
|
+
|
|
503
|
+
- **Keyword search, not semantic.** Retrieval is BM25 keyword matching: search
|
|
504
|
+
finds the words you saved, not paraphrases. (Plain questions are fine —
|
|
505
|
+
"how do we…" / "请问…" wording is filtered out before matching, so asking
|
|
506
|
+
naturally doesn't dilute the results.) No embedding model is ever
|
|
507
|
+
downloaded without your explicit opt-in.
|
|
508
|
+
- **One machine.** Editors on the same machine share memory; there is no
|
|
509
|
+
cross-machine sync. `export` / `import` bundles (below) move memory between
|
|
510
|
+
machines manually.
|
|
511
|
+
- **A snapshot, not everything.** Session-start recall is a top-N snapshot (8
|
|
512
|
+
project + 5 personal by default); older memories are one `memory_search`
|
|
513
|
+
away, but they are not all in context at once.
|
|
514
|
+
- **MCP guidance is advisory.** Outside opencode, proactive capture and recall
|
|
515
|
+
depend on the agent following the handshake instructions — there is no hard
|
|
516
|
+
session-start hook in MCP. The tools themselves always work when called.
|
|
517
|
+
- **Capture routing is a heuristic.** Personal-signal phrases (`remember for
|
|
518
|
+
me …`, `我喜欢…`) go to personal; everything else defaults to the current
|
|
519
|
+
project. When it guesses wrong, say the scope out loud or use `--scope` in
|
|
520
|
+
the CLI.
|
|
521
|
+
|
|
522
|
+
## Upgrading
|
|
427
523
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
See [docs/SCOPES.md](./docs/SCOPES.md) for the full scope model: key derivation, migration, visibility, reserved names.
|
|
432
|
-
|
|
433
|
-
## Retrieval
|
|
524
|
+
```sh
|
|
525
|
+
npm install -g open-memex@latest # or @alpha
|
|
526
|
+
```
|
|
434
527
|
|
|
435
|
-
|
|
528
|
+
Your editor configs point at the installed `open-memex` command, so upgrades
|
|
529
|
+
need no re-wiring. After a major upgrade, run `open-memex init --force` once to
|
|
530
|
+
refresh the installed Agent Skill and instruction files with the latest wording.
|
|
531
|
+
If you installed from source or moved the package, `--force` also re-points the
|
|
532
|
+
opencode plugin path.
|
|
436
533
|
|
|
437
534
|
## Storage layout
|
|
438
535
|
|
|
439
536
|
```
|
|
440
537
|
%APPDATA%\open-memex\ (Windows)
|
|
441
|
-
|
|
538
|
+
~/.local/share/open-memex/ (macOS/Linux; $XDG_DATA_HOME if set)
|
|
442
539
|
├── index.db # SQLite FTS5 index (rebuildable)
|
|
443
540
|
└── memories/
|
|
444
541
|
├── personal/
|
|
@@ -447,16 +544,21 @@ $XDG_DATA_HOME/open-memex/ (Linux/macOS)
|
|
|
447
544
|
└── <id>.md
|
|
448
545
|
```
|
|
449
546
|
|
|
450
|
-
Each `.md` file
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
547
|
+
Each `.md` file is one memory: YAML frontmatter (`id, scope, type, tags,
|
|
548
|
+
created_at, schema_version`, …) followed by the content. You can edit them by
|
|
549
|
+
hand — the index re-syncs from the files, and Markdown is always the source of
|
|
550
|
+
truth (`open-memex reindex` rebuilds the index from scratch).
|
|
551
|
+
|
|
552
|
+
Once you `submit`, project memories also live as Markdown files under
|
|
553
|
+
`<repo>/.ai/open-memex/` (configurable via `memoryDir`), where they travel with
|
|
554
|
+
branches and PRs like any other file.
|
|
455
555
|
|
|
456
556
|
## Config
|
|
457
557
|
|
|
458
|
-
|
|
459
|
-
|
|
558
|
+
Settings live in `~/.config/opencode/open-memex.jsonc` — the `opencode` in the
|
|
559
|
+
path is historical; this one file is shared by every client. Override the config
|
|
560
|
+
path with `MY_O_MEMORY_CONFIG` and the storage root with `MY_O_MEMORY_HOME`
|
|
561
|
+
(legacy environment names from before the rename, still honored).
|
|
460
562
|
|
|
461
563
|
Defaults:
|
|
462
564
|
|
|
@@ -471,22 +573,19 @@ Defaults:
|
|
|
471
573
|
}
|
|
472
574
|
```
|
|
473
575
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
personal memories stay in local appdata and never leave the machine. Existing
|
|
477
|
-
project files from appdata are moved into the repo dir automatically on first
|
|
478
|
-
write/sync.
|
|
479
|
-
|
|
480
|
-
`open-memex config` prints the effective config (defaults + file).
|
|
481
|
-
Change a setting after install:
|
|
576
|
+
`open-memex config` prints the effective config (defaults + file). Change a
|
|
577
|
+
setting after install:
|
|
482
578
|
|
|
483
579
|
```sh
|
|
484
580
|
open-memex config set keywordCaptureEnabled false
|
|
485
581
|
open-memex config set maxProjectMemories 12
|
|
582
|
+
open-memex config set sync.autoPull true # best-effort pull at MCP session start
|
|
486
583
|
```
|
|
487
584
|
|
|
488
585
|
Settable keys: `maxProjectMemories`, `maxProfileItems`, `injectOnFirstTurn`,
|
|
489
|
-
`keywordCaptureEnabled`, `logLevel`, `memoryDir
|
|
586
|
+
`keywordCaptureEnabled`, `logLevel`, `memoryDir`, and `sync.autoPull` (a dotted
|
|
587
|
+
key that writes into the nested `sync` object). Full design:
|
|
588
|
+
[docs/V2-DESIGN.md](./docs/V2-DESIGN.md).
|
|
490
589
|
|
|
491
590
|
## CLI reference
|
|
492
591
|
|
|
@@ -499,6 +598,7 @@ open-memex uninstall [--client vscode|cursor|opencode|visualstudio] [--global] [
|
|
|
499
598
|
open-memex config # print effective config
|
|
500
599
|
open-memex config set <key> <value> # change a setting
|
|
501
600
|
open-memex doctor # environment health check
|
|
601
|
+
open-memex audit # memory health check (duplicates, stale, broken chains)
|
|
502
602
|
open-memex capture --dry-run "记住我喜欢简洁的回答" # preview keyword capture
|
|
503
603
|
open-memex mcp --print-config vscode|cursor|claude|opencode|visualstudio
|
|
504
604
|
open-memex --help # this reference
|
|
@@ -509,25 +609,25 @@ open-memex --version # installed version
|
|
|
509
609
|
Memory operations:
|
|
510
610
|
|
|
511
611
|
```sh
|
|
512
|
-
open-memex add "This repo uses better-sqlite3" --type
|
|
612
|
+
open-memex add "This repo uses better-sqlite3" --type fact
|
|
513
613
|
open-memex search "auth flow"
|
|
614
|
+
open-memex search "auth flow" --explain # show FTS expression, scores, lifecycle-hidden counts
|
|
514
615
|
open-memex list --scope project
|
|
515
616
|
open-memex supersede <id> "Updated content"
|
|
516
617
|
open-memex status <id> deprecated
|
|
517
618
|
open-memex forget <id>
|
|
518
619
|
```
|
|
519
620
|
|
|
520
|
-
Team review workflow (
|
|
621
|
+
Team review workflow (two homes, one per stage):
|
|
521
622
|
|
|
522
623
|
Project drafts live in the **appdata outbox** (git-invisible, branch-independent);
|
|
523
|
-
only
|
|
524
|
-
branches and PRs. Nothing moves without you naming it.
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
memory-changing tool result carries the current count when it is non-zero.
|
|
624
|
+
only drafts you approve move into `<repo>/.ai/open-memex/`, where they follow
|
|
625
|
+
branches and PRs. Nothing moves without you naming it. In an AI chat with the
|
|
626
|
+
MCP server connected, just say **"sync memory"** (or "同步记忆") — the agent
|
|
627
|
+
runs the status check, summarizes the outbox drafts, and asks which ones to
|
|
628
|
+
sync. The server also tells the agent on its own: at session start the
|
|
629
|
+
handshake reports how many drafts are waiting, and every memory-changing tool
|
|
630
|
+
result carries the current count when it is non-zero.
|
|
531
631
|
|
|
532
632
|
```sh
|
|
533
633
|
open-memex sync-status
|
|
@@ -544,8 +644,9 @@ open-memex submit <id...> [--branch <name>] [--base <branch>]
|
|
|
544
644
|
# All-or-nothing; conflicts (same id, different content) abort cleanly.
|
|
545
645
|
# Prints the push + gh pr commands; an agent holding your Yes carries
|
|
546
646
|
# through push/PR itself. --branch <name> creates the branch first
|
|
547
|
-
# (agent full-chain path). Default PR base is the current branch
|
|
548
|
-
# redirects to main or
|
|
647
|
+
# (agent full-chain path). Default PR base is the current branch (memory
|
|
648
|
+
# PRs stack onto your working branch); --base redirects it to main or
|
|
649
|
+
# wherever you review.
|
|
549
650
|
|
|
550
651
|
open-memex pr-status [--apply]
|
|
551
652
|
# read the branch's GitHub PR and map its state onto each in-repo memory:
|
|
@@ -581,8 +682,8 @@ open-memex distill-agents [--scope project|personal] [--type t1,t2] [--limit N]
|
|
|
581
682
|
# (decisions, constraints, lessons, gotchas, howtos). Prints markdown;
|
|
582
683
|
# -o writes it to a file. You review and merge by hand — open-memex
|
|
583
684
|
# never rewrites your AGENTS.md on its own. The snippet ends with a
|
|
584
|
-
# "memory hygiene" section
|
|
585
|
-
#
|
|
685
|
+
# "memory hygiene" section so agents reading AGENTS.md learn to propose
|
|
686
|
+
# distilled captures when a task ends.
|
|
586
687
|
|
|
587
688
|
open-memex propose <id...> --to project [--local-approve]
|
|
588
689
|
# propose one or several personal memories at once (one branch, one PR);
|
|
@@ -612,119 +713,177 @@ Maintenance:
|
|
|
612
713
|
open-memex where # show storage + config paths
|
|
613
714
|
open-memex scopes # list project scopes with memory counts
|
|
614
715
|
open-memex reindex # rebuild the SQLite index from markdown
|
|
615
|
-
open-memex
|
|
716
|
+
open-memex audit # memory health: duplicate pairs, stale memories, broken chains
|
|
717
|
+
open-memex migrate --to-v2 [--dry-run] # v1 data → v2 (renames user scope to personal)
|
|
616
718
|
```
|
|
617
719
|
|
|
618
|
-
The CLI runs under Node 22. From a source checkout it uses the built-in
|
|
619
|
-
TypeScript loader (no build step); the published npm package ships
|
|
620
|
-
(`npm run build` at publish time). From a source checkout,
|
|
621
|
-
`node --experimental-strip-types src/cli.ts` (or
|
|
622
|
-
simple cases — npm swallows unknown `--flag`
|
|
720
|
+
The CLI runs under Node 22. From a source checkout it uses the built-in
|
|
721
|
+
experimental TypeScript loader (no build step); the published npm package ships
|
|
722
|
+
pre-compiled JS (`npm run build` at publish time). From a source checkout,
|
|
723
|
+
prefix every command with `node --experimental-strip-types src/cli.ts` (or
|
|
724
|
+
`npm run cli -- <command>` for simple cases — npm swallows unknown `--flag`
|
|
725
|
+
args, so prefer direct `node`).
|
|
623
726
|
|
|
624
727
|
## MCP server
|
|
625
728
|
|
|
626
|
-
The same
|
|
729
|
+
The same memory tools over the Model Context Protocol, via a stdio server —
|
|
627
730
|
no host-specific plugin needed. Any MCP client can use open-memex.
|
|
628
731
|
|
|
629
732
|
```sh
|
|
630
733
|
open-memex mcp # after a global install
|
|
631
|
-
npx -y open-memex mcp
|
|
734
|
+
npx -y open-memex mcp # no install needed
|
|
632
735
|
```
|
|
633
736
|
|
|
634
|
-
The project scope is resolved from the process working directory, so configure
|
|
635
|
-
server with cwd set to your project root (`init` handles this for you).
|
|
636
|
-
|
|
637
|
-
> **Note:** MCP is request/response — it gives the agent tools, not the
|
|
638
|
-
> plugin's automatic keyword capture or first-turn
|
|
639
|
-
> memory use depends on the agent's instructions: the server sends
|
|
640
|
-
> guidance in the MCP handshake `instructions` (including the
|
|
641
|
-
> count at session start, plus the pending count appended to
|
|
642
|
-
> tool results when non-zero), and `init` writes the fuller
|
|
643
|
-
> editor's instruction files. Both are advisory — no MCP
|
|
644
|
-
> session-start hook.
|
|
645
|
-
|
|
646
|
-
##
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
**`
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
737
|
+
The project scope is resolved from the process working directory, so configure
|
|
738
|
+
the server with cwd set to your project root (`init` handles this for you).
|
|
739
|
+
|
|
740
|
+
> **Note:** MCP is request/response — it gives the agent tools, not the
|
|
741
|
+
> opencode plugin's automatic keyword capture or first-turn injection.
|
|
742
|
+
> Proactive memory use depends on the agent's instructions: the server sends
|
|
743
|
+
> session-start guidance in the MCP handshake `instructions` (including the
|
|
744
|
+
> live outbox draft count at session start, plus the pending count appended to
|
|
745
|
+
> memory-changing tool results when non-zero), and `init` writes the fuller
|
|
746
|
+
> version into the editor's instruction files. Both are advisory — no MCP
|
|
747
|
+
> consumer offers a hard session-start hook.
|
|
748
|
+
|
|
749
|
+
## Scopes, in detail
|
|
750
|
+
|
|
751
|
+
- **project** — scoped to the current repo, keyed off the git origin URL hash
|
|
752
|
+
(so clones of the same repo share a scope), or off the cwd path if there is
|
|
753
|
+
no remote. Default for new memories.
|
|
754
|
+
- **personal** — global across all your projects, this machine only, never
|
|
755
|
+
synced. Use for personal preferences. (v1 called this `user`;
|
|
756
|
+
`migrate --to-v2` renames it.)
|
|
757
|
+
|
|
758
|
+
See [docs/SCOPES.md](./docs/SCOPES.md) for the full scope model: key derivation,
|
|
759
|
+
migration, visibility, reserved names. The [concept guide](./docs/CONCEPTS.md)
|
|
760
|
+
walks through the mental model end to end.
|
|
761
|
+
|
|
762
|
+
## Troubleshooting
|
|
763
|
+
|
|
764
|
+
**`open-memex` is not recognized / command not found.**
|
|
765
|
+
A global `npm install -g` puts the `open-memex` launcher in npm's global bin
|
|
766
|
+
folder. If your terminal can't find it, that folder isn't on your `PATH`:
|
|
767
|
+
|
|
768
|
+
1. Find the folder: `npm config get prefix`
|
|
769
|
+
- **Windows:** the launcher (`open-memex.cmd`) sits directly in that folder,
|
|
770
|
+
e.g. `C:\Users\<you>\AppData\Roaming\npm`
|
|
771
|
+
- **macOS / Linux:** it's in `<prefix>/bin`, e.g. `/usr/local/bin` or
|
|
772
|
+
`~/.nvm/versions/node/v22.x.x/bin`
|
|
773
|
+
2. Add it to `PATH`:
|
|
774
|
+
- **Windows:** Settings → System → About → Advanced system settings →
|
|
775
|
+
Environment Variables → add the folder to the *User* `Path` → **restart
|
|
776
|
+
the terminal**. Verify with `where open-memex`.
|
|
777
|
+
- **macOS / Linux:** add `export PATH="$(npm prefix -g)/bin:$PATH"` to
|
|
778
|
+
`~/.zshrc` (or `~/.bashrc`), restart the shell, verify with
|
|
779
|
+
`command -v open-memex`.
|
|
780
|
+
3. No admin rights / don't want to touch `PATH`? Use the npx form —
|
|
781
|
+
`npx -y open-memex <command>` resolves the package itself and needs no
|
|
782
|
+
`PATH` changes.
|
|
783
|
+
|
|
784
|
+
**`EBUSY` / `EPERM` on `better_sqlite3.node` (Windows).**
|
|
785
|
+
On Windows a loaded DLL is locked: if the open-memex MCP server is running
|
|
786
|
+
(VS Code MCP panel, Cursor, etc.), `npm install -g open-memex` cannot replace
|
|
787
|
+
`better_sqlite3.node` and fails with `EBUSY` / `EPERM`. Stop the MCP server
|
|
788
|
+
first (or quit the editor), then re-run the install. If it still fails, delete
|
|
789
|
+
`node_modules/open-memex` and any `node_modules/.open-memex-*` temp folders
|
|
790
|
+
under your global npm root and install again.
|
|
791
|
+
|
|
792
|
+
**`init` says it left a config file untouched.**
|
|
793
|
+
Your editor config has comments (JSONC) or invalid JSON, and open-memex never
|
|
794
|
+
rewrites files it can't parse safely. `init` printed the exact snippet to add
|
|
795
|
+
by hand — paste it in, and you're done. The same applies to the opencode
|
|
796
|
+
config: if it has comments, add the `"plugin"` line manually.
|
|
797
|
+
|
|
798
|
+
**Something's off — run `open-memex doctor`.**
|
|
799
|
+
Checks the Node version, config source, scope resolution for the current
|
|
800
|
+
directory, and storage writability; verifies VS Code hasn't disabled MCP;
|
|
801
|
+
then boots a real MCP server and runs `initialize` + `tools/list` against
|
|
802
|
+
it — all eleven tools must show up. It also reports pre-rename `my-o-memory`
|
|
803
|
+
leftovers if any editor config still references the old package name.
|
|
681
804
|
|
|
682
805
|
## FAQ
|
|
683
806
|
|
|
684
|
-
**Do I need
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
807
|
+
**Do I need git?**
|
|
808
|
+
No. Capture and recall work in any folder — without a git repo the project
|
|
809
|
+
scope simply keys off the folder path. Git is only needed for the team
|
|
810
|
+
workflow (`submit` / PR review), which is optional.
|
|
811
|
+
|
|
812
|
+
**I use several editors. Do they really share one memory?**
|
|
813
|
+
Yes — on the same machine. Every wired editor reads and writes the same local
|
|
814
|
+
memory; see the [capability matrix](#which-editors-which-features) for what
|
|
815
|
+
each editor gets. A decision captured in VS Code is respected in opencode.
|
|
816
|
+
|
|
817
|
+
**I work on two computers (office + home). Does memory sync?**
|
|
818
|
+
Not automatically — memory is per-machine by design, and your personal scope
|
|
819
|
+
never leaves the machine it was created on. To move memory manually, use
|
|
820
|
+
`open-memex export` on one machine and `open-memex import` on the other.
|
|
821
|
+
Project memories shared through Git (Team workflow) travel with the repo, so
|
|
822
|
+
cloning the repo on the second machine brings the *published project* memories
|
|
823
|
+
along — your personal ones stay behind, on purpose.
|
|
824
|
+
|
|
825
|
+
**Is it really free? Do I need an account?**
|
|
826
|
+
Free and open source (Apache-2.0). No account, no sign-up, no telemetry, no
|
|
827
|
+
cloud calls. If it can't phone home, there's nothing to phone home to: the
|
|
828
|
+
only network open-memex ever touches is your own git remote, when you
|
|
829
|
+
explicitly push.
|
|
830
|
+
|
|
831
|
+
**I accidentally pasted a secret into a memory. What now?**
|
|
832
|
+
`open-memex search "<part of it>"` to find the memory, then
|
|
833
|
+
`open-memex forget <id>` to delete it. To prevent it next time, wrap sensitive
|
|
834
|
+
text in `<private>…</private>` (stripped before saving) — recognized API keys
|
|
835
|
+
and tokens are also masked automatically. Preview any message safely with
|
|
836
|
+
`open-memex capture --dry-run "…"`.
|
|
837
|
+
|
|
838
|
+
**Do I need to run `init` for every project?**
|
|
839
|
+
No. The data layer needs nothing — the project scope is derived automatically
|
|
840
|
+
from your cwd's git remote or path, so memories are namespaced per project
|
|
841
|
+
with zero setup. The editor wiring is one `open-memex init` per machine
|
|
842
|
+
(user-level wherever the editor supports it). Run it again only after
|
|
843
|
+
upgrading (`--force`) or if you switch editors.
|
|
696
844
|
|
|
697
845
|
**Does opencode need `init`?**
|
|
698
|
-
Two paths. Recommended: `open-memex init --client opencode --global` —
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
leaves it untouched and prints the manual step.
|
|
846
|
+
Two paths. Recommended: `open-memex init --client opencode --global` — it
|
|
847
|
+
merges the native open-memex plugin into `~/.config/opencode/opencode.json`
|
|
848
|
+
for you. One-time setup, applies to all projects, and additionally enables
|
|
849
|
+
keyword auto-capture and first-turn memory injection. Prefer to do it by hand?
|
|
850
|
+
Add `"plugin": ["file:///absolute/path/to/open-memex/src/index.ts"]` (the
|
|
851
|
+
installed package's path) to that file instead. As a plain MCP consumer:
|
|
852
|
+
`open-memex init --client opencode` writes a project-level `opencode.jsonc`
|
|
853
|
+
(no hooks). If your user-level config has comments, `init` leaves it
|
|
854
|
+
untouched and prints the manual step.
|
|
708
855
|
|
|
709
856
|
**VS Code — run `init` once, or per project?**
|
|
710
857
|
Once. Plain `open-memex init` auto-detects VS Code and writes the MCP server
|
|
711
|
-
entry to VS Code's user-level `mcp.json`
|
|
712
|
-
|
|
713
|
-
`~/Library/Application Support/Code/User/mcp.json` on macOS,
|
|
858
|
+
entry to VS Code's user-level `mcp.json` (`%APPDATA%/Code/User/mcp.json` on
|
|
859
|
+
Windows, `~/Library/Application Support/Code/User/mcp.json` on macOS,
|
|
714
860
|
`~/.config/Code/User/mcp.json` on Linux), so the server starts in every
|
|
715
861
|
project. A per-project `.vscode/mcp.json` still wins when present, and the
|
|
716
862
|
entry keeps `cwd=${workspaceFolder}` so project-scope resolution keeps
|
|
717
863
|
working per window. If your user-level `mcp.json` has comments (VS Code
|
|
718
|
-
accepts JSONC), `init` leaves it alone and prints the exact snippet to add
|
|
719
|
-
|
|
864
|
+
accepts JSONC), `init` leaves it alone and prints the exact snippet to add by
|
|
865
|
+
hand. An empty file is treated as blank and written to directly.
|
|
720
866
|
|
|
721
867
|
**How do I remove the editor wiring?**
|
|
722
|
-
`open-memex uninstall` reverses `init`: it removes the MCP server entry,
|
|
723
|
-
|
|
724
|
-
instructions. With no `--client` it cleans up every detected
|
|
725
|
-
`--global` limits the cleanup to user-level wiring. Your memories are
|
|
868
|
+
`open-memex uninstall` reverses `init`: it removes the MCP server entry, the
|
|
869
|
+
opencode plugin line, the Agent Skill directory, and the open-memex section of
|
|
870
|
+
the Copilot instructions. With no `--client` it cleans up every detected
|
|
871
|
+
editor; `--global` limits the cleanup to user-level wiring. Your memories are
|
|
726
872
|
never touched.
|
|
727
873
|
|
|
874
|
+
## Project status
|
|
875
|
+
|
|
876
|
+
open-memex is stable and in daily use; the current stable line is published on
|
|
877
|
+
npm as `latest`, with `alpha` builds for testers. Release history lives in
|
|
878
|
+
[GitHub Releases](https://github.com/stoneskin/open-memex/releases); design
|
|
879
|
+
decisions are recorded in the append-only log at
|
|
880
|
+
[docs/V2-DESIGN.md](./docs/V2-DESIGN.md).
|
|
881
|
+
|
|
882
|
+
On the horizon (no version promises): native agent plugins for more editors as
|
|
883
|
+
enhancements over the same MCP tools; local embeddings as an opt-in experiment
|
|
884
|
+
(no model is ever downloaded without asking); an org layer only if real
|
|
885
|
+
multi-repo sharing, ACL, or compliance needs demand it.
|
|
886
|
+
|
|
728
887
|
## License
|
|
729
888
|
|
|
730
889
|
[Apache-2.0](./LICENSE)
|