opencode-codex-memory 0.8.0 → 0.8.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/README.md +64 -525
- package/dist/src/claude-import.js +25 -27
- package/dist/src/v2/agents.js +19 -8
- package/dist/src/v2/plugin.js +24 -5
- package/dist/src/v2/search-sandbox.d.ts +4 -0
- package/dist/src/v2/search-sandbox.js +33 -0
- package/dist/src/v2/service.d.ts +2 -0
- package/dist/src/v2/service.js +43 -4
- package/dist/src/v2/shim.d.ts +2 -2
- package/dist/src/v2/shim.js +77 -38
- package/dist/src/v2/tui.js +532 -287
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,567 +9,106 @@
|
|
|
9
9
|
</a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
|
-
Persistent memory for [OpenCode](https://opencode.ai)
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Persistent memory for [OpenCode](https://opencode.ai). Your agent learns from
|
|
13
|
+
past sessions — your conventions, your projects, the decisions you made — and
|
|
14
|
+
brings useful context into new conversations automatically.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
See the [changelog](./CHANGELOG.md) for release history.
|
|
22
|
-
|
|
23
|
-
**Local-first by design.** Memory is plain markdown files plus a small SQLite
|
|
24
|
-
database on your own machine — no memory service to sign up for, no MCP server,
|
|
25
|
-
no separate process, no sync. Installing it is one line in your `opencode.json`;
|
|
26
|
-
from there everything lives under `~/.local/share/opencode/` by default (or a
|
|
27
|
-
directory you set with `home`), so you can read it, grep it, edit it, or delete
|
|
28
|
-
it like anything else you own. Nothing leaves your machine beyond the model
|
|
29
|
-
calls OpenCode already makes.
|
|
30
|
-
|
|
31
|
-
If you *do* also use the Codex CLI or Claude Code on the same machine: the
|
|
32
|
-
plugin can bring their memories in (and, for Codex, push ours back). Off by
|
|
33
|
-
default — see [Sharing memory with the Codex CLI](#sharing-memory-with-the-codex-cli)
|
|
34
|
-
and [Importing memory from Claude Code](#importing-memory-from-claude-code).
|
|
35
|
-
|
|
36
|
-
## Why
|
|
37
|
-
|
|
38
|
-
By default every OpenCode session starts from zero. You re-explain your build
|
|
39
|
-
commands, your code style, and the quirks of each repo over and over.
|
|
40
|
-
|
|
41
|
-
This plugin closes that loop. It reviews finished sessions in the
|
|
42
|
-
background, keeps what's durable — your preferences, how a repo is built, what
|
|
43
|
-
worked and what didn't — and puts that context back in front of the agent in
|
|
44
|
-
later conversations. You don't manage any of it; OpenCode just gets more useful
|
|
45
|
-
the more you use it.
|
|
46
|
-
|
|
47
|
-
If you want the mental model — learning, remembering, forgetting — see
|
|
48
|
-
[How OpenCode Codex Memory works](./docs/how-ai-memory-works.md).
|
|
16
|
+
**No Codex subscription or OpenAI account required.** This plugin ports the
|
|
17
|
+
memory system from OpenAI's Codex and uses the models you already have in
|
|
18
|
+
OpenCode. Memory is stored locally as Markdown files and a small SQLite
|
|
19
|
+
database. Background learning makes additional calls through your configured
|
|
20
|
+
model providers; there is no separate memory service or MCP server.
|
|
49
21
|
|
|
50
22
|
## Install
|
|
51
23
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
```json
|
|
55
|
-
{
|
|
56
|
-
"plugin": ["opencode-codex-memory@0.8.0"]
|
|
57
|
-
}
|
|
58
|
-
```
|
|
24
|
+
The plugin works with its default settings; no extra memory configuration is needed.
|
|
59
25
|
|
|
60
|
-
|
|
61
|
-
it, so a bare `"opencode-codex-memory"` is not "always latest". Check
|
|
62
|
-
[npm](https://www.npmjs.com/package/opencode-codex-memory) for the current
|
|
63
|
-
version.
|
|
26
|
+
### 1. Add the plugin for your OpenCode version
|
|
64
27
|
|
|
65
|
-
|
|
66
|
-
|
|
28
|
+
Run `opencode --version` if you are unsure which version you use. Add the entry
|
|
29
|
+
to your existing global `~/.config/opencode/opencode.jsonc` or `opencode.json`
|
|
30
|
+
(under `$XDG_CONFIG_HOME/opencode` if set). Keep your other settings and plugins.
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
[Configuration](#configuration).
|
|
70
|
-
|
|
71
|
-
**OpenCode 2:** the same package works on opencode2 — install it with the
|
|
72
|
-
V2 plugin syntax:
|
|
73
|
-
|
|
74
|
-
```jsonc
|
|
75
|
-
{
|
|
76
|
-
"plugins": [{ "package": "opencode-codex-memory@0.8.0" }],
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Same pipeline, not the same host APIs — see [docs/opencode2.md](./docs/opencode2.md)
|
|
81
|
-
for the limits (registered service, retained citation markup, no `small_model`).
|
|
82
|
-
On opencode2 you also get a **Memory** section in the session sidebar plus a
|
|
83
|
-
`/memory-status` command, served live from the same state as `memory_inspect`.
|
|
84
|
-
|
|
85
|
-
### Installation hints
|
|
86
|
-
|
|
87
|
-
To bump pins, copy
|
|
88
|
-
[`docs/commands/update-plugins.md`](./docs/commands/update-plugins.md) to
|
|
89
|
-
`~/.config/opencode/command/update-plugins.md` and run `/update-plugins`.
|
|
90
|
-
This command is not part of the plugin package — nothing about it is
|
|
91
|
-
installed with the plugin. It works for every pinned plugin in your config,
|
|
92
|
-
not just this one.
|
|
93
|
-
|
|
94
|
-
## Try it
|
|
95
|
-
|
|
96
|
-
Just use OpenCode normally. Sessions that have been idle for a few hours get
|
|
97
|
-
reviewed in the background and memory starts building up — you don't have to do
|
|
98
|
-
anything. Come back the next day and ask something like *"what do you know about how I
|
|
99
|
-
work?"* or *"what was I doing in this repo?"* and the agent draws on what it
|
|
100
|
-
learned. The more you use it, the more it knows.
|
|
101
|
-
|
|
102
|
-
You can also steer it in plain language, mid-conversation:
|
|
103
|
-
|
|
104
|
-
- *"remember that I deploy this project with `make release`"* → saved as a note.
|
|
105
|
-
- *"what was I working on in this repo last week?"* → time-scoped recall.
|
|
106
|
-
- *"reset my memory"* → wipes it and starts over.
|
|
107
|
-
|
|
108
|
-
Want to prime it before the first session has a chance to be learned? You can
|
|
109
|
-
drop a starter summary in yourself — it's just a file:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
mkdir -p ~/.local/share/opencode/memories
|
|
113
|
-
echo 'I prefer TypeScript strict mode and 2-space indentation.' \
|
|
114
|
-
> ~/.local/share/opencode/memories/memory_summary.md
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Where your data lives
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
~/.local/share/opencode/
|
|
121
|
-
├── memory.db # the plugin's own database (OpenCode's data is only accessed via its API)
|
|
122
|
-
└── memories/
|
|
123
|
-
├── memory_summary.md # compact summary injected into the system prompt
|
|
124
|
-
├── MEMORY.md # searchable index of everything learned
|
|
125
|
-
├── rollout_summaries/ # one recap per past session
|
|
126
|
-
├── skills/ # reusable procedures discovered over time
|
|
127
|
-
└── extensions/ad_hoc/notes/ # things you explicitly asked it to remember
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
By default this is OpenCode's own data directory — `$XDG_DATA_HOME/opencode`
|
|
131
|
-
when that's set, otherwise `~/.local/share/opencode` (same resolution on macOS,
|
|
132
|
-
Linux, and Windows). Relocating OpenCode's local dir (for example by setting
|
|
133
|
-
`XDG_DATA_HOME`) therefore moves memory with it. To pin **only** `memory.db`
|
|
134
|
-
and `memories/` somewhere else — a sandbox mount, without the rest of
|
|
135
|
-
OpenCode's database — set `home`. That pin is always enforced; OpenCode's data
|
|
136
|
-
dir and `XDG_DATA_HOME` no longer apply. Precedence:
|
|
137
|
-
[Relocating memory](#relocating-memory-sandbox-mounts). Do not symlink
|
|
138
|
-
`memories/` — the plugin refuses a symlinked memory root.
|
|
139
|
-
|
|
140
|
-
It's all plain files and a local SQLite database. Read them, edit them, delete
|
|
141
|
-
them — it's yours. (The `memories/` folder also holds a few working files and
|
|
142
|
-
an internal `.git/` the plugin uses for change tracking; `memory_reset` wipes
|
|
143
|
-
those too.)
|
|
144
|
-
|
|
145
|
-
### Backup and restore
|
|
146
|
-
|
|
147
|
-
Back up the whole OpenCode data directory while OpenCode is stopped. The
|
|
148
|
-
SQLite database and `memories/` workspace are a pair: restoring only one can
|
|
149
|
-
leave job state, Git baseline, and memory files out of sync. Include hidden
|
|
150
|
-
files, especially `memories/.git/`, and SQLite sidecars such as `memory.db-wal`
|
|
151
|
-
or `memory.db-shm` when present.
|
|
152
|
-
|
|
153
|
-
The default directory is `$XDG_DATA_HOME/opencode` when `XDG_DATA_HOME` is set,
|
|
154
|
-
otherwise `~/.local/share/opencode`. If you set `home` (or
|
|
155
|
-
`OPENCODE_CODEX_MEMORY_HOME`), back up that directory instead — it is the pair
|
|
156
|
-
`memory.db` + `memories/`. Copy it to a dated backup location. To restore, stop
|
|
157
|
-
OpenCode, replace the current home with the backup copy, then start OpenCode
|
|
158
|
-
again. Do not restore while OpenCode is running or copy only `memory.db` or
|
|
159
|
-
only `memories/`.
|
|
160
|
-
|
|
161
|
-
## Privacy & safety
|
|
162
|
-
|
|
163
|
-
- **Local only.** There is no remote storage option to enable, by accident or
|
|
164
|
-
otherwise: Codex keeps memory storage behind a backend interface whose only
|
|
165
|
-
implementation today is the local filesystem, and this port implements that
|
|
166
|
-
path and nothing else. Nothing is sent anywhere except through your existing
|
|
167
|
-
OpenCode provider, using your existing credentials; the plugin holds no keys
|
|
168
|
-
of its own.
|
|
169
|
-
- **Secrets are redacted** (API keys, tokens, private keys, passwords) from
|
|
170
|
-
session transcripts and extracted memories before anything is written or sent
|
|
171
|
-
to a model. Notes you explicitly dictate ("remember that ...") are stored as
|
|
172
|
-
you said them.
|
|
173
|
-
- **The learning agents are sandboxed** — the extraction agent can't touch your
|
|
174
|
-
filesystem (the transcript is handed to it inline; it only emits its structured
|
|
175
|
-
result), and the consolidation agent gets only file tools plus access to the
|
|
176
|
-
memory folder. Shell, network, IDE, and MCP tools are denied for both.
|
|
177
|
-
- **Reset is safe.** `memory_reset` refuses to run if the memory folder is a
|
|
178
|
-
symlink, so it can't be tricked into deleting something else.
|
|
179
|
-
- **Web/MCP sessions:** by default, sessions that used web search, fetch, or MCP
|
|
180
|
-
tools are still eligible for memory (matching Codex). If you'd rather exclude
|
|
181
|
-
them so scraped or external content can't enter your memory, set
|
|
182
|
-
`disable_on_external_context: true`.
|
|
183
|
-
|
|
184
|
-
## Configuration
|
|
185
|
-
|
|
186
|
-
Optional plugin options (all have sensible defaults). Names and defaults match
|
|
187
|
-
Codex's `[memories]` config so the two stay easy to compare:
|
|
188
|
-
|
|
189
|
-
| Option | Default | Meaning |
|
|
190
|
-
|---|---|---|
|
|
191
|
-
| `generate_memories` | `true` | Turn the background learning pipeline on/off |
|
|
192
|
-
| `version` | `"v1"` | Read version for new sessions, and the sole writer when dual-write is off. `"v2"` is summary-only, with recaps in isolated `memories_v2/` and no `MEMORY.md`. |
|
|
193
|
-
| `dual_write` | `false` | Run both learning pipelines independently while reading the selected version. Enables V2 warmup before an explicit cutover. |
|
|
194
|
-
| `use_memories` | `true` | Inject the memory summary into the system prompt |
|
|
195
|
-
| `dedicated_tools` | `true` | Expose the `memory_read`/`memory_search`/`memory_list`/`memory_add_note` tools |
|
|
196
|
-
| `disable_on_external_context` | `false` | Exclude sessions that used web/MCP tools from memory |
|
|
197
|
-
| `extract_model` | OpenCode `small_model`, else see below | Model used for per-session extraction |
|
|
198
|
-
| `consolidation_model` | OpenCode `model`, else see below | Model used for consolidation |
|
|
199
|
-
| `max_raw_memories_for_consolidation` | `256` | How many raw memories feed each consolidation pass |
|
|
200
|
-
| `max_rollout_age_days` | `10` | Ignore sessions older than this for extraction |
|
|
201
|
-
| `min_rollout_idle_hours` | `6` | How long a session must be idle before it's eligible |
|
|
202
|
-
| `max_rollouts_per_startup` | `2` | Max sessions extracted per pass |
|
|
203
|
-
| `max_unused_days` | `30` | Prune memories unused for this long |
|
|
204
|
-
| `codex_interop` | `{ "import": false, "export": false }` | Two-way memory exchange with a local Codex CLI (see below) |
|
|
205
|
-
| `claude_import` | `{ "enabled": false }` | One-way import of Claude Code project memories (see below) |
|
|
206
|
-
| `home` | unset (follows OpenCode data dir) | Pin `memory.db` + `memories/` here. When set, OpenCode's data dir and `XDG_DATA_HOME` are ignored. See [Relocating memory](#relocating-memory-sandbox-mounts) |
|
|
207
|
-
|
|
208
|
-
To set options, turn the plugin entry into a `[name, options]` pair:
|
|
209
|
-
|
|
210
|
-
```json
|
|
211
|
-
{
|
|
212
|
-
"plugin": [
|
|
213
|
-
["opencode-codex-memory@0.8.0", { "disable_on_external_context": true, "min_rollout_idle_hours": 2 }]
|
|
214
|
-
]
|
|
215
|
-
}
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
See the [OpenCode plugin docs](https://opencode.ai/docs/plugins/) for details.
|
|
219
|
-
|
|
220
|
-
Numeric options are clamped to Codex's valid ranges; unknown option keys are
|
|
221
|
-
ignored with a warning. Setting `use_memories: false` also hides the memory
|
|
222
|
-
tools, matching Codex's extension gating.
|
|
223
|
-
|
|
224
|
-
**Verifying your configuration:** the plugin never hard-fails on bad options.
|
|
225
|
-
To check what actually took effect, ask the agent to run `memory_inspect` — it
|
|
226
|
-
echoes the effective options (after parsing and clamping), lists warnings for
|
|
227
|
-
unknown or malformed keys (typos included), and shows the resolved Codex
|
|
228
|
-
interop state. A mistyped option shows up there twice: as a warning, and as
|
|
229
|
-
the default value appearing where you expected your setting.
|
|
230
|
-
|
|
231
|
-
Model selection mirrors Codex's cheap-extraction / capable-consolidation
|
|
232
|
-
split using OpenCode's own concepts: when `extract_model` is unset, the
|
|
233
|
-
`small_model` from your `opencode.json` is used (Codex uses `gpt-5.6-luna`);
|
|
234
|
-
when `consolidation_model` is unset, your main `model` is used (Codex uses
|
|
235
|
-
`gpt-5.6-terra`). If neither is configured, the learning sub-agents fall back to
|
|
236
|
-
their own agent-level `model` (if you defined one), else the provider default.
|
|
237
|
-
(OpenCode's *automatic* small-model pick is internal to OpenCode and not
|
|
238
|
-
exposed to plugins — set `small_model` explicitly to get the cheap extraction
|
|
239
|
-
path.)
|
|
240
|
-
|
|
241
|
-
The full precedence per phase: plugin option (`extract_model` /
|
|
242
|
-
`consolidation_model`) → OpenCode config (`small_model` / `model`) → a `model`
|
|
243
|
-
on your own `memorize-extract`/`memorize` agent definition, if you overrode
|
|
244
|
-
one → the provider's default model. Note that the first two pass the model
|
|
245
|
-
explicitly, so they win over an agent-level `model`.
|
|
246
|
-
|
|
247
|
-
Reasoning effort follows Codex (`low` for extraction, `medium` for
|
|
248
|
-
consolidation) when the model lists that name. Otherwise the plugin picks the
|
|
249
|
-
nearest OpenCode variant on `none < minimal < low < medium < high < xhigh < max`
|
|
250
|
-
(ties go higher). No listed efforts → no pin, host default.
|
|
251
|
-
|
|
252
|
-
> Note: `dedicated_tools` defaults to `true` here (Codex defaults it to `false`).
|
|
253
|
-
> This is the one intentional default difference — the tools are a core part of a
|
|
254
|
-
> standalone memory plugin. Everything else matches Codex's defaults.
|
|
255
|
-
>
|
|
256
|
-
> Turning `dedicated_tools` off keeps background learning, summary injection,
|
|
257
|
-
> and citation tracking working. The injected guidance switches to Codex's
|
|
258
|
-
> file-based mode — the agent reads the memory files with its normal file
|
|
259
|
-
> tools and writes "remember this" notes directly into
|
|
260
|
-
> `extensions/ad_hoc/notes/`. Caveat: the memory folder lives outside your
|
|
261
|
-
> project, so OpenCode raises an `external_directory` permission prompt the
|
|
262
|
-
> first time an agent touches it (allow-always covers later access); agents
|
|
263
|
-
> whose permissions deny that ask cannot use file-based mode. The dedicated
|
|
264
|
-
> tools have no such friction — that's why they are the default. The
|
|
265
|
-
> maintenance tools (`memory_reset`, `memory_inspect`, `memory_mode`) stay
|
|
266
|
-
> available either way.
|
|
267
|
-
|
|
268
|
-
### Migrating from memory V1 to V2
|
|
269
|
-
|
|
270
|
-
Memory versions are independent of OpenCode host versions: both work on
|
|
271
|
-
OpenCode 1.x and 2.x. V1 remains the default. See the
|
|
272
|
-
[conceptual comparison](docs/how-ai-memory-works.md#two-versions-v1-and-v2)
|
|
273
|
-
for the different learning contracts.
|
|
274
|
-
|
|
275
|
-
1. Set these **plugin options** and restart OpenCode's server:
|
|
276
|
-
|
|
277
|
-
```json
|
|
278
|
-
{ "version": "v1", "dual_write": true }
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
V1 continues serving memory. Both pipelines independently extract eligible
|
|
282
|
-
conversations and consolidate into their own workspaces. This adds model
|
|
283
|
-
calls for the second pipeline; it does not copy or convert V1 artifacts.
|
|
284
|
-
|
|
285
|
-
2. Check `memory_inspect`, or `/memory` on OpenCode 2. `v2_ready` becomes true
|
|
286
|
-
when V2 has a valid summary and one successful consolidation has consumed
|
|
287
|
-
at least **20 distinct sessions**. The count is a high-water mark, not a
|
|
288
|
-
lifetime sum, so repeated consolidation of one session cannot make V2 ready.
|
|
289
|
-
`min_consolidated_threads` on inspect (RPC: `minConsolidatedThreads`) can
|
|
290
|
-
override the reporting threshold from 1 to 4096; it does not change config
|
|
291
|
-
or switch versions. Readiness is a warmup signal, not a quality guarantee.
|
|
292
|
-
|
|
293
|
-
3. When ready, set `version: "v2"` and restart the server. New sessions use V2.
|
|
294
|
-
Existing sessions keep the version selected on their first memory use,
|
|
295
|
-
including retrieval tools, explicit notes, and citation accounting across
|
|
296
|
-
server restarts. Start a new session to try the new read path.
|
|
297
|
-
|
|
298
|
-
4. Keep `dual_write: true` while evaluating V2, then set it to `false` when you
|
|
299
|
-
want only V2 learning. To roll back, select `version: "v1"` and start a new
|
|
300
|
-
session. If dual-write was off, V1 will not contain the intervening learning.
|
|
301
|
-
|
|
302
|
-
There is no automatic cutover. An explicit "remember this" note goes to the
|
|
303
|
-
requesting session's selected workspace; the other writer learns from eligible
|
|
304
|
-
conversation history. Disabled/polluted session flags are shared. Session
|
|
305
|
-
deletion removes extracted rows from both stores and queues forgetting;
|
|
306
|
-
`memory_reset` clears both stores and workspaces, preserving session modes and
|
|
307
|
-
read-version stamps. Inactive stores resume queued consolidation when enabled.
|
|
308
|
-
|
|
309
|
-
### Relocating memory (sandbox mounts)
|
|
310
|
-
|
|
311
|
-
First match wins:
|
|
312
|
-
|
|
313
|
-
1. **`home` plugin option** — pinned. Always enforced. OpenCode's data
|
|
314
|
-
directory and `XDG_DATA_HOME` do not apply.
|
|
315
|
-
2. **`OPENCODE_CODEX_MEMORY_HOME`** — same pin, only if `home` is unset.
|
|
316
|
-
3. **OpenCode data dir** (default) — `$XDG_DATA_HOME/opencode` when that env
|
|
317
|
-
is set, otherwise `~/.local/share/opencode`. Memory moves with OpenCode's
|
|
318
|
-
local directory.
|
|
319
|
-
|
|
320
|
-
To mount **only** memory into a sandbox, use (1) or (2) and point at a
|
|
321
|
-
dedicated directory:
|
|
322
|
-
|
|
323
|
-
```json
|
|
324
|
-
{
|
|
325
|
-
"plugin": [
|
|
326
|
-
["opencode-codex-memory@0.8.0", { "home": "/path/to/opencode-memory" }]
|
|
327
|
-
]
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
OpenCode 2:
|
|
32
|
+
**OpenCode 2.x**
|
|
332
33
|
|
|
333
34
|
```jsonc
|
|
334
35
|
{
|
|
36
|
+
"$schema": "https://opencode.ai/config.json",
|
|
335
37
|
"plugins": [
|
|
336
|
-
{ "package": "opencode-codex-memory@0.8.
|
|
38
|
+
{ "package": "opencode-codex-memory@0.8.2" }
|
|
337
39
|
]
|
|
338
40
|
}
|
|
339
41
|
```
|
|
340
42
|
|
|
341
|
-
|
|
342
|
-
make memory follow the cwd, and memory is global. Same layout as the default,
|
|
343
|
-
just elsewhere:
|
|
344
|
-
|
|
345
|
-
```
|
|
346
|
-
/path/to/opencode-memory/
|
|
347
|
-
├── memory.db
|
|
348
|
-
└── memories/
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
Mount that directory into the sandbox at the **same absolute path**.
|
|
352
|
-
|
|
353
|
-
This does not move existing files. Stop OpenCode, copy `memory.db` (and
|
|
354
|
-
`memory.db-wal` / `memory.db-shm` if present) plus `memories/` into the new
|
|
355
|
-
home, then start it again. Do not symlink `memories/` in place of `home` —
|
|
356
|
-
a symlinked memory root is refused. Ask the agent to run `memory_inspect` to
|
|
357
|
-
confirm the resolved path.
|
|
358
|
-
|
|
359
|
-
### Sharing memory with the Codex CLI
|
|
360
|
-
|
|
361
|
-
If you use OpenCode and the Codex CLI on the same machine, turn this on so each
|
|
362
|
-
side can pick up what the other already learned. **Either or both directions.**
|
|
363
|
-
Off by default; no changes to Codex's own config are required.
|
|
364
|
-
|
|
365
|
-
**Enable both directions:**
|
|
366
|
-
|
|
367
|
-
```json
|
|
368
|
-
{
|
|
369
|
-
"plugin": [
|
|
370
|
-
[
|
|
371
|
-
"opencode-codex-memory@0.8.0",
|
|
372
|
-
{ "codex_interop": { "import": true, "export": true } }
|
|
373
|
-
]
|
|
374
|
-
]
|
|
375
|
-
}
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
- **Import:** on each consolidation pass here, durable memory from Codex is
|
|
379
|
-
merged into this plugin's store (tagged so you can tell it came from Codex).
|
|
380
|
-
- **Export:** after a successful consolidation here, this plugin's memory is
|
|
381
|
-
offered to Codex; Codex merges it on *its* next consolidation pass.
|
|
382
|
-
|
|
383
|
-
**Options** (all under `codex_interop`):
|
|
384
|
-
|
|
385
|
-
| Option | Default | Meaning |
|
|
386
|
-
| --- | --- | --- |
|
|
387
|
-
| `import` | `false` | Bring Codex's consolidated memory into OpenCode. |
|
|
388
|
-
| `export` | `false` | Offer this plugin's consolidated memory to Codex. |
|
|
389
|
-
| `codex_home` | `$CODEX_HOME`, else `~/.codex` | Where the Codex CLI keeps its data. Set this if you use a non-default location. |
|
|
390
|
-
|
|
391
|
-
**Notes**
|
|
392
|
-
|
|
393
|
-
- Export only runs once Codex has created its own memory workspace
|
|
394
|
-
(`$CODEX_HOME/memories`). Until then, import/export quietly do nothing for
|
|
395
|
-
the missing side.
|
|
396
|
-
- Codex's own files are never rewritten in place — export only adds a side
|
|
397
|
-
channel Codex already knows how to read.
|
|
398
|
-
- Both sides tag origin (`[from codex]` / `[from opencode]`) and skip the other
|
|
399
|
-
tag on re-import, so the same facts don't bounce back and forth.
|
|
400
|
-
- Safe to combine with `claude_import`. Check status with `memory_inspect`
|
|
401
|
-
(`codex_interop:` section).
|
|
402
|
-
|
|
403
|
-
**Turning it off**
|
|
404
|
-
|
|
405
|
-
Setting `import` / `export` back to `false` (or removing `codex_interop`) only
|
|
406
|
-
stops further sync. Already merged memory stays in this plugin's store, and any
|
|
407
|
-
staging copies stay on disk (harmless while import is off). The last export left
|
|
408
|
-
in Codex stays until Codex consolidates it away or you remove it there.
|
|
409
|
-
|
|
410
|
-
To drop the local staging copies too: turn import off first, then delete
|
|
411
|
-
`extensions/codex_import/` under the plugin memory directory (see
|
|
412
|
-
[Where your data lives](#where-your-data-lives)). Leave import off — if you turn
|
|
413
|
-
it back on, the next pass will recreate them from Codex. After a deletion, the
|
|
414
|
-
next consolidation can treat the missing files as a signal to drop entries that
|
|
415
|
-
only came from that import.
|
|
416
|
-
|
|
417
|
-
### Importing memory from Claude Code
|
|
418
|
-
|
|
419
|
-
If you use Claude Code as well as OpenCode, turn this on so OpenCode can learn
|
|
420
|
-
from the project memories Claude already keeps on your machine. **One-way only**
|
|
421
|
-
(Claude → OpenCode); nothing is written back into Claude. Off by default.
|
|
422
|
-
|
|
423
|
-
**Enable everything Claude has:**
|
|
43
|
+
**OpenCode 1.x** (1.18 or newer)
|
|
424
44
|
|
|
425
45
|
```json
|
|
426
46
|
{
|
|
427
|
-
"
|
|
428
|
-
|
|
429
|
-
]
|
|
47
|
+
"$schema": "https://opencode.ai/config.json",
|
|
48
|
+
"plugin": ["opencode-codex-memory@0.8.2"]
|
|
430
49
|
}
|
|
431
50
|
```
|
|
432
51
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
global summary.
|
|
437
|
-
|
|
438
|
-
**Options** (all under `claude_import`):
|
|
52
|
+
Keep a published package version pinned as shown. See
|
|
53
|
+
[Updating the plugin](./docs/troubleshooting.md#updating-the-plugin) when a
|
|
54
|
+
new release is available.
|
|
439
55
|
|
|
440
|
-
|
|
441
|
-
| --- | --- | --- |
|
|
442
|
-
| `enabled` | `false` | Turn the importer on. |
|
|
443
|
-
| `claude_home` | `~/.claude` | Where Claude Code stores its data. Set this if you use a non-default location. |
|
|
444
|
-
| `projects` | all projects | Optional allowlist of Claude project ids to import (see below). |
|
|
56
|
+
### 2. Restart OpenCode and check status
|
|
445
57
|
|
|
446
|
-
|
|
58
|
+
On OpenCode 2, run:
|
|
447
59
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
```json
|
|
452
|
-
{
|
|
453
|
-
"plugin": [
|
|
454
|
-
[
|
|
455
|
-
"opencode-codex-memory@0.8.0",
|
|
456
|
-
{
|
|
457
|
-
"claude_import": {
|
|
458
|
-
"enabled": true,
|
|
459
|
-
"projects": ["-Users-you-Desktop-git-my-app"]
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
]
|
|
463
|
-
]
|
|
464
|
-
}
|
|
60
|
+
```sh
|
|
61
|
+
opencode service restart
|
|
465
62
|
```
|
|
466
63
|
|
|
467
|
-
|
|
64
|
+
On OpenCode 1.x, restart OpenCode. If an IDE or another app manages your
|
|
65
|
+
OpenCode server, restart that server too.
|
|
468
66
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
67
|
+
Start a conversation and ask **“Check my memory status.”** The agent can run
|
|
68
|
+
`memory_inspect` to show progress and any warnings. In OpenCode 2's terminal
|
|
69
|
+
UI, you can also open the [**`/memory-inspect` panel**](./docs/usage.md#memory-panel).
|
|
472
70
|
|
|
473
|
-
|
|
474
|
-
can place on disk.
|
|
475
|
-
- Add or remove ids anytime while import is **on**. Dropping an id (or deleting
|
|
476
|
-
that project's memory in Claude) stops syncing it and removes the staging
|
|
477
|
-
copy on the next pass so consolidation can drop derived entries. Memory
|
|
478
|
-
already merged into the main store is not instantly deleted; the consolidator
|
|
479
|
-
cleans it up when it next runs.
|
|
480
|
-
- Turning `enabled` off (see below) does **not** prune anything.
|
|
481
|
-
|
|
482
|
-
**Turning it off**
|
|
483
|
-
|
|
484
|
-
Setting `enabled` to `false` (or removing `claude_import`) only stops further
|
|
485
|
-
import. Already merged memory stays in this plugin's store, and staging copies
|
|
486
|
-
stay on disk (harmless while import is off).
|
|
487
|
-
|
|
488
|
-
To drop the local staging copies too: turn import off first, then delete
|
|
489
|
-
`extensions/external_agent_import/` under the plugin memory directory (see
|
|
490
|
-
[Where your data lives](#where-your-data-lives)). Leave import off — if you turn
|
|
491
|
-
it back on, the next pass will recreate them from Claude. After a deletion, the
|
|
492
|
-
next consolidation can treat the missing files as a signal to drop entries that
|
|
493
|
-
only came from that import.
|
|
494
|
-
|
|
495
|
-
To stop importing *some* projects without turning the feature off: shrink
|
|
496
|
-
`projects` (or delete that memory in Claude) and let the next pass run. That
|
|
497
|
-
only affects the Claude import channel.
|
|
498
|
-
|
|
499
|
-
**Notes**
|
|
500
|
-
|
|
501
|
-
- Safe to combine with `codex_interop` (Codex sharing uses a separate channel).
|
|
502
|
-
- If you also run another OpenCode plugin that *writes* Claude-style memory,
|
|
503
|
-
pick one writer — two systems updating the same long-term store will fight.
|
|
504
|
-
- Check status anytime with `memory_inspect` (`claude_import:` section).
|
|
505
|
-
|
|
506
|
-
## Why one global memory?
|
|
507
|
-
|
|
508
|
-
There's a single store for everything you do, not one per project — and that's
|
|
509
|
-
the design choice most likely to surprise you, so it's worth explaining where it
|
|
510
|
-
came from.
|
|
511
|
-
|
|
512
|
-
Codex *started* with per-project memory: a separate bucket per directory, plus a
|
|
513
|
-
user-level scope on top. It **deliberately removed that** in early 2026 and
|
|
514
|
-
collapsed everything into one global root — one store, one lock, one
|
|
515
|
-
consolidation pass — for simplicity.
|
|
516
|
-
|
|
517
|
-
Simplicity is easy to underrate here — until you try to draw the boundaries
|
|
518
|
-
yourself. Scoping forces a question that often has no good answer: which project does
|
|
519
|
-
"prefers table-driven tests" belong to? Monorepos, worktrees, and sibling repos
|
|
520
|
-
of the same stack all blur the line, and the most valuable lessons — the ones
|
|
521
|
-
about how *you* work — belong to no project at all. Per-scope stores also each
|
|
522
|
-
consolidate over a thinner slice of evidence than the whole.
|
|
71
|
+
## Try it
|
|
523
72
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
conventions follow you into a new repo on day one) while project-specific facts
|
|
529
|
-
stay recognizable as such.
|
|
73
|
+
Use OpenCode normally. By default, a session becomes eligible for learning
|
|
74
|
+
after **6 hours of inactivity**, and consolidation combines learned material
|
|
75
|
+
into memory. The work runs in the background while OpenCode is running;
|
|
76
|
+
an empty memory immediately after installation is normal.
|
|
530
77
|
|
|
531
|
-
|
|
532
|
-
the summary. Codex judged that cheaper than the alternative, and this port
|
|
533
|
-
mirrors that decision rather than layering scoping back on top.
|
|
78
|
+
In a later conversation, try:
|
|
534
79
|
|
|
535
|
-
|
|
80
|
+
- “What do you know about how I work?”
|
|
81
|
+
- “What was I working on in this repo last week?”
|
|
82
|
+
- “Remember that I deploy this project with `make release`.”
|
|
536
83
|
|
|
537
|
-
|
|
538
|
-
|
|
84
|
+
Explicit “remember this” requests save a note immediately; a later
|
|
85
|
+
consolidation integrates it into the summary. You can
|
|
86
|
+
[check progress or pause learning](./docs/usage.md) at any time.
|
|
539
87
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
-
|
|
544
|
-
|
|
545
|
-
- effective memory-agent health, including user overrides and required permissions
|
|
546
|
-
- a short eligibility reminder (`min_rollout_idle_hours`, default **6h**)
|
|
88
|
+
Memory is **global across projects**. Project-specific details carry context
|
|
89
|
+
about where they came from, while general preferences can follow you into a
|
|
90
|
+
new repo. Files live under `~/.local/share/opencode/` by default. See
|
|
91
|
+
[Storage and privacy](./docs/storage-and-privacy.md) for the layout, model-call
|
|
92
|
+
privacy, backups, and relocation.
|
|
547
93
|
|
|
548
|
-
|
|
94
|
+
## Start here
|
|
549
95
|
|
|
550
|
-
|
|
|
96
|
+
| I want to… | Read |
|
|
551
97
|
|---|---|
|
|
552
|
-
|
|
|
553
|
-
|
|
|
554
|
-
|
|
|
555
|
-
|
|
|
556
|
-
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
[How OpenCode Codex Memory works](./docs/how-ai-memory-works.md). Implementation
|
|
567
|
-
map and workarounds: [`ARCHITECTURE.md`](./ARCHITECTURE.md). Contributor
|
|
568
|
-
guidance lives in [`CONTRIBUTING.md`](./CONTRIBUTING.md) and
|
|
569
|
-
[`AGENTS.md`](./AGENTS.md) — in short: this repo exists to port Codex's memory
|
|
570
|
-
system to OpenCode, and PRs that break that parity will be rejected.
|
|
571
|
-
|
|
572
|
-
CI runs `bun test`, typecheck, build, and the packaging smoke test on every PR.
|
|
98
|
+
| Recall past work, save a note, or pause learning | [Using memory](./docs/usage.md) |
|
|
99
|
+
| Choose or switch memory behavior | [Memory V1 and Memory V2](./docs/memory-versions.md) |
|
|
100
|
+
| Set models, learning frequency, or other options | [Configuration](./docs/configuration.md) |
|
|
101
|
+
| Find, back up, move, or reset my data | [Storage and privacy](./docs/storage-and-privacy.md) |
|
|
102
|
+
| Share with Codex CLI or import Claude Code memories | [Integrations](./docs/integrations.md) |
|
|
103
|
+
| Fix missing memory or check an update | [Troubleshooting](./docs/troubleshooting.md) |
|
|
104
|
+
|
|
105
|
+
## Learn more and contribute
|
|
106
|
+
|
|
107
|
+
- [How memory works](./docs/how-ai-memory-works.md) — the illustrated explanation
|
|
108
|
+
of learning, recall, and forgetting.
|
|
109
|
+
- [Changelog](./CHANGELOG.md) — release history.
|
|
110
|
+
- [Contributing](./CONTRIBUTING.md) — development setup and the Codex parity policy.
|
|
111
|
+
- [Architecture](./ARCHITECTURE.md) — implementation map and host adaptations.
|
|
573
112
|
|
|
574
113
|
## License
|
|
575
114
|
|