opencode-codex-memory 0.7.7 → 0.8.1
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 -482
- package/dist/opencode.json +2 -2
- package/dist/src/capture.d.ts +5 -0
- package/dist/src/capture.js +8 -0
- package/dist/src/claude-import.js +25 -27
- package/dist/src/codex-interop.js +5 -0
- package/dist/src/db.d.ts +7 -1
- package/dist/src/db.js +38 -11
- package/dist/src/host-client.d.ts +5 -0
- package/dist/src/index.d.ts +12 -4
- package/dist/src/index.js +39 -61
- package/dist/src/lifecycle.js +14 -9
- package/dist/src/llm.d.ts +3 -2
- package/dist/src/llm.js +47 -11
- package/dist/src/memory-version.d.ts +5 -0
- package/dist/src/memory-version.js +16 -0
- package/dist/src/migration.d.ts +24 -0
- package/dist/src/migration.js +37 -0
- package/dist/src/options.d.ts +4 -0
- package/dist/src/options.js +2 -0
- package/dist/src/paths.d.ts +9 -3
- package/dist/src/paths.js +22 -8
- package/dist/src/phase1.js +16 -2
- package/dist/src/phase2.js +15 -9
- package/dist/src/pipeline.d.ts +3 -0
- package/dist/src/pipeline.js +74 -0
- package/dist/src/ratelimit.js +5 -4
- package/dist/src/rollout-input.d.ts +3 -2
- package/dist/src/rollout-input.js +26 -17
- package/dist/src/session-version.d.ts +9 -0
- package/dist/src/session-version.js +27 -0
- package/dist/src/source.js +21 -6
- package/dist/src/store.d.ts +10 -1
- package/dist/src/store.js +76 -24
- package/dist/src/templates/consolidation_v2.md +54 -0
- package/dist/src/templates/read_path_v2.md +58 -0
- package/dist/src/templates/stage_one_input_v2.md +21 -0
- package/dist/src/templates/stage_one_system_v2.md +53 -0
- package/dist/src/token.d.ts +2 -0
- package/dist/src/token.js +16 -0
- package/dist/src/v2/agents.d.ts +4 -2
- package/dist/src/v2/agents.js +28 -9
- package/dist/src/v2/citation-overlay.d.ts +1 -1
- package/dist/src/v2/citation-overlay.js +27 -4
- package/dist/src/v2/plugin.js +47 -76
- 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 +82 -39
- package/dist/src/v2/status-rpc.d.ts +70 -1
- package/dist/src/v2/status-rpc.js +41 -2
- package/dist/src/v2/status.d.ts +1 -1
- package/dist/src/v2/status.js +28 -6
- package/dist/src/v2/tui.js +57 -2
- package/dist/src/workspace.d.ts +8 -6
- package/dist/src/workspace.js +31 -11
- package/dist/tools/control.d.ts +6 -2
- package/dist/tools/control.js +196 -164
- package/dist/tools/memory.js +11 -1
- package/opencode.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,524 +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.7.7"]
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Pin the version — OpenCode installs a plugin spec once and never re-resolves
|
|
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.
|
|
64
|
-
|
|
65
|
-
**2. That's it.** The memory workspace is created on first use; background
|
|
66
|
-
learning starts immediately.
|
|
67
|
-
|
|
68
|
-
Requires OpenCode 1.18 or newer. Models and other options: see
|
|
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.7.7" }],
|
|
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
|
-
| `use_memories` | `true` | Inject the memory summary into the system prompt |
|
|
193
|
-
| `dedicated_tools` | `true` | Expose the `memory_read`/`memory_search`/`memory_list`/`memory_add_note` tools |
|
|
194
|
-
| `disable_on_external_context` | `false` | Exclude sessions that used web/MCP tools from memory |
|
|
195
|
-
| `extract_model` | OpenCode `small_model`, else see below | Model used for per-session extraction |
|
|
196
|
-
| `consolidation_model` | OpenCode `model`, else see below | Model used for consolidation |
|
|
197
|
-
| `max_raw_memories_for_consolidation` | `256` | How many raw memories feed each consolidation pass |
|
|
198
|
-
| `max_rollout_age_days` | `10` | Ignore sessions older than this for extraction |
|
|
199
|
-
| `min_rollout_idle_hours` | `6` | How long a session must be idle before it's eligible |
|
|
200
|
-
| `max_rollouts_per_startup` | `2` | Max sessions extracted per pass |
|
|
201
|
-
| `max_unused_days` | `30` | Prune memories unused for this long |
|
|
202
|
-
| `codex_interop` | `{ "import": false, "export": false }` | Two-way memory exchange with a local Codex CLI (see below) |
|
|
203
|
-
| `claude_import` | `{ "enabled": false }` | One-way import of Claude Code project memories (see below) |
|
|
204
|
-
| `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) |
|
|
205
|
-
|
|
206
|
-
To set options, turn the plugin entry into a `[name, options]` pair:
|
|
207
|
-
|
|
208
|
-
```json
|
|
209
|
-
{
|
|
210
|
-
"plugin": [
|
|
211
|
-
["opencode-codex-memory@0.7.7", { "disable_on_external_context": true, "min_rollout_idle_hours": 2 }]
|
|
212
|
-
]
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
See the [OpenCode plugin docs](https://opencode.ai/docs/plugins/) for details.
|
|
217
|
-
|
|
218
|
-
Numeric options are clamped to Codex's valid ranges; unknown option keys are
|
|
219
|
-
ignored with a warning. Setting `use_memories: false` also hides the memory
|
|
220
|
-
tools, matching Codex's extension gating.
|
|
221
|
-
|
|
222
|
-
**Verifying your configuration:** the plugin never hard-fails on bad options.
|
|
223
|
-
To check what actually took effect, ask the agent to run `memory_inspect` — it
|
|
224
|
-
echoes the effective options (after parsing and clamping), lists warnings for
|
|
225
|
-
unknown or malformed keys (typos included), and shows the resolved Codex
|
|
226
|
-
interop state. A mistyped option shows up there twice: as a warning, and as
|
|
227
|
-
the default value appearing where you expected your setting.
|
|
228
|
-
|
|
229
|
-
Model selection mirrors Codex's cheap-extraction / capable-consolidation
|
|
230
|
-
split using OpenCode's own concepts: when `extract_model` is unset, the
|
|
231
|
-
`small_model` from your `opencode.json` is used (Codex uses `gpt-5.6-luna`);
|
|
232
|
-
when `consolidation_model` is unset, your main `model` is used (Codex uses
|
|
233
|
-
`gpt-5.6-terra`). If neither is configured, the learning sub-agents fall back to
|
|
234
|
-
their own agent-level `model` (if you defined one), else the provider default.
|
|
235
|
-
(OpenCode's *automatic* small-model pick is internal to OpenCode and not
|
|
236
|
-
exposed to plugins — set `small_model` explicitly to get the cheap extraction
|
|
237
|
-
path.)
|
|
238
|
-
|
|
239
|
-
The full precedence per phase: plugin option (`extract_model` /
|
|
240
|
-
`consolidation_model`) → OpenCode config (`small_model` / `model`) → a `model`
|
|
241
|
-
on your own `memorize-extract`/`memorize` agent definition, if you overrode
|
|
242
|
-
one → the provider's default model. Note that the first two pass the model
|
|
243
|
-
explicitly, so they win over an agent-level `model`.
|
|
24
|
+
The plugin works with its default settings; no extra memory configuration is needed.
|
|
244
25
|
|
|
245
|
-
|
|
246
|
-
consolidation) when the model lists that name. Otherwise the plugin picks the
|
|
247
|
-
nearest OpenCode variant on `none < minimal < low < medium < high < xhigh < max`
|
|
248
|
-
(ties go higher). No listed efforts → no pin, host default.
|
|
26
|
+
### 1. Add the plugin for your OpenCode version
|
|
249
27
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
>
|
|
254
|
-
> Turning `dedicated_tools` off keeps background learning, summary injection,
|
|
255
|
-
> and citation tracking working. The injected guidance switches to Codex's
|
|
256
|
-
> file-based mode — the agent reads the memory files with its normal file
|
|
257
|
-
> tools and writes "remember this" notes directly into
|
|
258
|
-
> `extensions/ad_hoc/notes/`. Caveat: the memory folder lives outside your
|
|
259
|
-
> project, so OpenCode raises an `external_directory` permission prompt the
|
|
260
|
-
> first time an agent touches it (allow-always covers later access); agents
|
|
261
|
-
> whose permissions deny that ask cannot use file-based mode. The dedicated
|
|
262
|
-
> tools have no such friction — that's why they are the default. The
|
|
263
|
-
> maintenance tools (`memory_reset`, `memory_inspect`, `memory_mode`) stay
|
|
264
|
-
> available either way.
|
|
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.
|
|
265
31
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
First match wins:
|
|
269
|
-
|
|
270
|
-
1. **`home` plugin option** — pinned. Always enforced. OpenCode's data
|
|
271
|
-
directory and `XDG_DATA_HOME` do not apply.
|
|
272
|
-
2. **`OPENCODE_CODEX_MEMORY_HOME`** — same pin, only if `home` is unset.
|
|
273
|
-
3. **OpenCode data dir** (default) — `$XDG_DATA_HOME/opencode` when that env
|
|
274
|
-
is set, otherwise `~/.local/share/opencode`. Memory moves with OpenCode's
|
|
275
|
-
local directory.
|
|
276
|
-
|
|
277
|
-
To mount **only** memory into a sandbox, use (1) or (2) and point at a
|
|
278
|
-
dedicated directory:
|
|
279
|
-
|
|
280
|
-
```json
|
|
281
|
-
{
|
|
282
|
-
"plugin": [
|
|
283
|
-
["opencode-codex-memory@0.7.7", { "home": "/path/to/opencode-memory" }]
|
|
284
|
-
]
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
OpenCode 2:
|
|
32
|
+
**OpenCode 2.x**
|
|
289
33
|
|
|
290
34
|
```jsonc
|
|
291
35
|
{
|
|
36
|
+
"$schema": "https://opencode.ai/config.json",
|
|
292
37
|
"plugins": [
|
|
293
|
-
{ "package": "opencode-codex-memory@0.
|
|
38
|
+
{ "package": "opencode-codex-memory@0.8.1" }
|
|
294
39
|
]
|
|
295
40
|
}
|
|
296
41
|
```
|
|
297
42
|
|
|
298
|
-
|
|
299
|
-
make memory follow the cwd, and memory is global. Same layout as the default,
|
|
300
|
-
just elsewhere:
|
|
301
|
-
|
|
302
|
-
```
|
|
303
|
-
/path/to/opencode-memory/
|
|
304
|
-
├── memory.db
|
|
305
|
-
└── memories/
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
Mount that directory into the sandbox at the **same absolute path**.
|
|
309
|
-
|
|
310
|
-
This does not move existing files. Stop OpenCode, copy `memory.db` (and
|
|
311
|
-
`memory.db-wal` / `memory.db-shm` if present) plus `memories/` into the new
|
|
312
|
-
home, then start it again. Do not symlink `memories/` in place of `home` —
|
|
313
|
-
a symlinked memory root is refused. Ask the agent to run `memory_inspect` to
|
|
314
|
-
confirm the resolved path.
|
|
315
|
-
|
|
316
|
-
### Sharing memory with the Codex CLI
|
|
317
|
-
|
|
318
|
-
If you use OpenCode and the Codex CLI on the same machine, turn this on so each
|
|
319
|
-
side can pick up what the other already learned. **Either or both directions.**
|
|
320
|
-
Off by default; no changes to Codex's own config are required.
|
|
321
|
-
|
|
322
|
-
**Enable both directions:**
|
|
323
|
-
|
|
324
|
-
```json
|
|
325
|
-
{
|
|
326
|
-
"plugin": [
|
|
327
|
-
[
|
|
328
|
-
"opencode-codex-memory@0.7.7",
|
|
329
|
-
{ "codex_interop": { "import": true, "export": true } }
|
|
330
|
-
]
|
|
331
|
-
]
|
|
332
|
-
}
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
- **Import:** on each consolidation pass here, durable memory from Codex is
|
|
336
|
-
merged into this plugin's store (tagged so you can tell it came from Codex).
|
|
337
|
-
- **Export:** after a successful consolidation here, this plugin's memory is
|
|
338
|
-
offered to Codex; Codex merges it on *its* next consolidation pass.
|
|
339
|
-
|
|
340
|
-
**Options** (all under `codex_interop`):
|
|
341
|
-
|
|
342
|
-
| Option | Default | Meaning |
|
|
343
|
-
| --- | --- | --- |
|
|
344
|
-
| `import` | `false` | Bring Codex's consolidated memory into OpenCode. |
|
|
345
|
-
| `export` | `false` | Offer this plugin's consolidated memory to Codex. |
|
|
346
|
-
| `codex_home` | `$CODEX_HOME`, else `~/.codex` | Where the Codex CLI keeps its data. Set this if you use a non-default location. |
|
|
347
|
-
|
|
348
|
-
**Notes**
|
|
349
|
-
|
|
350
|
-
- Export only runs once Codex has created its own memory workspace
|
|
351
|
-
(`$CODEX_HOME/memories`). Until then, import/export quietly do nothing for
|
|
352
|
-
the missing side.
|
|
353
|
-
- Codex's own files are never rewritten in place — export only adds a side
|
|
354
|
-
channel Codex already knows how to read.
|
|
355
|
-
- Both sides tag origin (`[from codex]` / `[from opencode]`) and skip the other
|
|
356
|
-
tag on re-import, so the same facts don't bounce back and forth.
|
|
357
|
-
- Safe to combine with `claude_import`. Check status with `memory_inspect`
|
|
358
|
-
(`codex_interop:` section).
|
|
359
|
-
|
|
360
|
-
**Turning it off**
|
|
361
|
-
|
|
362
|
-
Setting `import` / `export` back to `false` (or removing `codex_interop`) only
|
|
363
|
-
stops further sync. Already merged memory stays in this plugin's store, and any
|
|
364
|
-
staging copies stay on disk (harmless while import is off). The last export left
|
|
365
|
-
in Codex stays until Codex consolidates it away or you remove it there.
|
|
366
|
-
|
|
367
|
-
To drop the local staging copies too: turn import off first, then delete
|
|
368
|
-
`extensions/codex_import/` under the plugin memory directory (see
|
|
369
|
-
[Where your data lives](#where-your-data-lives)). Leave import off — if you turn
|
|
370
|
-
it back on, the next pass will recreate them from Codex. After a deletion, the
|
|
371
|
-
next consolidation can treat the missing files as a signal to drop entries that
|
|
372
|
-
only came from that import.
|
|
373
|
-
|
|
374
|
-
### Importing memory from Claude Code
|
|
375
|
-
|
|
376
|
-
If you use Claude Code as well as OpenCode, turn this on so OpenCode can learn
|
|
377
|
-
from the project memories Claude already keeps on your machine. **One-way only**
|
|
378
|
-
(Claude → OpenCode); nothing is written back into Claude. Off by default.
|
|
379
|
-
|
|
380
|
-
**Enable everything Claude has:**
|
|
43
|
+
**OpenCode 1.x** (1.18 or newer)
|
|
381
44
|
|
|
382
45
|
```json
|
|
383
46
|
{
|
|
384
|
-
"
|
|
385
|
-
|
|
386
|
-
]
|
|
47
|
+
"$schema": "https://opencode.ai/config.json",
|
|
48
|
+
"plugin": ["opencode-codex-memory@0.8.1"]
|
|
387
49
|
}
|
|
388
50
|
```
|
|
389
51
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
global summary.
|
|
394
|
-
|
|
395
|
-
**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.
|
|
396
55
|
|
|
397
|
-
|
|
398
|
-
| --- | --- | --- |
|
|
399
|
-
| `enabled` | `false` | Turn the importer on. |
|
|
400
|
-
| `claude_home` | `~/.claude` | Where Claude Code stores its data. Set this if you use a non-default location. |
|
|
401
|
-
| `projects` | all projects | Optional allowlist of Claude project ids to import (see below). |
|
|
56
|
+
### 2. Restart OpenCode and check status
|
|
402
57
|
|
|
403
|
-
|
|
58
|
+
On OpenCode 2, run:
|
|
404
59
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
```json
|
|
409
|
-
{
|
|
410
|
-
"plugin": [
|
|
411
|
-
[
|
|
412
|
-
"opencode-codex-memory@0.7.7",
|
|
413
|
-
{
|
|
414
|
-
"claude_import": {
|
|
415
|
-
"enabled": true,
|
|
416
|
-
"projects": ["-Users-you-Desktop-git-my-app"]
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
]
|
|
420
|
-
]
|
|
421
|
-
}
|
|
60
|
+
```sh
|
|
61
|
+
opencode service restart
|
|
422
62
|
```
|
|
423
63
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
```bash
|
|
427
|
-
ls ~/.claude/projects
|
|
428
|
-
```
|
|
64
|
+
On OpenCode 1.x, restart OpenCode. If an IDE or another app manages your
|
|
65
|
+
OpenCode server, restart that server too.
|
|
429
66
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
that project's memory in Claude) stops syncing it and removes the staging
|
|
434
|
-
copy on the next pass so consolidation can drop derived entries. Memory
|
|
435
|
-
already merged into the main store is not instantly deleted; the consolidator
|
|
436
|
-
cleans it up when it next runs.
|
|
437
|
-
- Turning `enabled` off (see below) does **not** prune anything.
|
|
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` panel**](./docs/usage.md#memory-panel).
|
|
438
70
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
Setting `enabled` to `false` (or removing `claude_import`) only stops further
|
|
442
|
-
import. Already merged memory stays in this plugin's store, and staging copies
|
|
443
|
-
stay on disk (harmless while import is off).
|
|
444
|
-
|
|
445
|
-
To drop the local staging copies too: turn import off first, then delete
|
|
446
|
-
`extensions/external_agent_import/` under the plugin memory directory (see
|
|
447
|
-
[Where your data lives](#where-your-data-lives)). Leave import off — if you turn
|
|
448
|
-
it back on, the next pass will recreate them from Claude. After a deletion, the
|
|
449
|
-
next consolidation can treat the missing files as a signal to drop entries that
|
|
450
|
-
only came from that import.
|
|
451
|
-
|
|
452
|
-
To stop importing *some* projects without turning the feature off: shrink
|
|
453
|
-
`projects` (or delete that memory in Claude) and let the next pass run. That
|
|
454
|
-
only affects the Claude import channel.
|
|
455
|
-
|
|
456
|
-
**Notes**
|
|
457
|
-
|
|
458
|
-
- Safe to combine with `codex_interop` (Codex sharing uses a separate channel).
|
|
459
|
-
- If you also run another OpenCode plugin that *writes* Claude-style memory,
|
|
460
|
-
pick one writer — two systems updating the same long-term store will fight.
|
|
461
|
-
- Check status anytime with `memory_inspect` (`claude_import:` section).
|
|
462
|
-
|
|
463
|
-
## Why one global memory?
|
|
464
|
-
|
|
465
|
-
There's a single store for everything you do, not one per project — and that's
|
|
466
|
-
the design choice most likely to surprise you, so it's worth explaining where it
|
|
467
|
-
came from.
|
|
468
|
-
|
|
469
|
-
Codex *started* with per-project memory: a separate bucket per directory, plus a
|
|
470
|
-
user-level scope on top. It **deliberately removed that** in early 2026 and
|
|
471
|
-
collapsed everything into one global root — one store, one lock, one
|
|
472
|
-
consolidation pass — for simplicity.
|
|
473
|
-
|
|
474
|
-
Simplicity is easy to underrate here — until you try to draw the boundaries
|
|
475
|
-
yourself. Scoping forces a question that often has no good answer: which project does
|
|
476
|
-
"prefers table-driven tests" belong to? Monorepos, worktrees, and sibling repos
|
|
477
|
-
of the same stack all blur the line, and the most valuable lessons — the ones
|
|
478
|
-
about how *you* work — belong to no project at all. Per-scope stores also each
|
|
479
|
-
consolidate over a thinner slice of evidence than the whole.
|
|
71
|
+
## Try it
|
|
480
72
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
conventions follow you into a new repo on day one) while project-specific facts
|
|
486
|
-
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.
|
|
487
77
|
|
|
488
|
-
|
|
489
|
-
the summary. Codex judged that cheaper than the alternative, and this port
|
|
490
|
-
mirrors that decision rather than layering scoping back on top.
|
|
78
|
+
In a later conversation, try:
|
|
491
79
|
|
|
492
|
-
|
|
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`.”
|
|
493
83
|
|
|
494
|
-
|
|
495
|
-
|
|
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.
|
|
496
87
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
-
|
|
501
|
-
|
|
502
|
-
- effective memory-agent health, including user overrides and required permissions
|
|
503
|
-
- 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.
|
|
504
93
|
|
|
505
|
-
|
|
94
|
+
## Start here
|
|
506
95
|
|
|
507
|
-
|
|
|
96
|
+
| I want to… | Read |
|
|
508
97
|
|---|---|
|
|
509
|
-
|
|
|
510
|
-
|
|
|
511
|
-
|
|
|
512
|
-
|
|
|
513
|
-
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
[How OpenCode Codex Memory works](./docs/how-ai-memory-works.md). Implementation
|
|
524
|
-
map and workarounds: [`ARCHITECTURE.md`](./ARCHITECTURE.md). Contributor
|
|
525
|
-
guidance lives in [`CONTRIBUTING.md`](./CONTRIBUTING.md) and
|
|
526
|
-
[`AGENTS.md`](./AGENTS.md) — in short: this repo exists to port Codex's memory
|
|
527
|
-
system to OpenCode, and PRs that break that parity will be rejected.
|
|
528
|
-
|
|
529
|
-
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.
|
|
530
112
|
|
|
531
113
|
## License
|
|
532
114
|
|
package/dist/opencode.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"agent": {
|
|
4
4
|
"memorize": {
|
|
5
5
|
"mode": "subagent",
|
|
6
|
-
"prompt": "You are a memory consolidation agent.
|
|
6
|
+
"prompt": "You are a memory consolidation agent. Follow the supplied version-specific consolidation contract and update only its requested artifacts under the supplied memory workspace. Do not read or edit project source files or a different memory workspace. Keep memory_summary.md under 10000 bytes. Prune stale entries. Do not access the network.",
|
|
7
7
|
"permission": {
|
|
8
8
|
"*": "deny",
|
|
9
9
|
"bash": "deny",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"memorize-extract": {
|
|
22
22
|
"mode": "subagent",
|
|
23
|
-
"prompt": "You are a memory extraction agent. The session transcript is provided inline in the prompt.
|
|
23
|
+
"prompt": "You are a memory extraction agent. The session transcript is provided inline in the prompt. Follow the supplied version-specific JSON schema. Exclude AGENTS.md/instruction content. Redact secrets.",
|
|
24
24
|
"permission": {
|
|
25
25
|
"*": "deny",
|
|
26
26
|
"bash": "deny",
|
package/dist/src/capture.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export interface TranscriptMessage {
|
|
|
11
11
|
type: string;
|
|
12
12
|
role?: string;
|
|
13
13
|
text?: string;
|
|
14
|
+
/** Native question-tool replies are human evidence, paired with the question. */
|
|
15
|
+
userReply?: {
|
|
16
|
+
question: string;
|
|
17
|
+
answer: string;
|
|
18
|
+
};
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Transcript loading uses the official API — the same surface opencode's own
|
package/dist/src/capture.js
CHANGED
|
@@ -97,10 +97,18 @@ export async function loadTranscript(sessionId) {
|
|
|
97
97
|
for (const row of rows) {
|
|
98
98
|
const role = row?.info?.role;
|
|
99
99
|
for (const part of row?.parts ?? []) {
|
|
100
|
+
const question = part;
|
|
101
|
+
const answer = question?.state?.output;
|
|
102
|
+
const userReply = question?.tool === "question" && question.ignored !== true
|
|
103
|
+
&& typeof answer === "string" && answer.startsWith("User has answered your questions:")
|
|
104
|
+
&& /"="(?!Unanswered")[^"]+"/.test(answer)
|
|
105
|
+
? { question: JSON.stringify(question.state?.input ?? {}), answer }
|
|
106
|
+
: undefined;
|
|
100
107
|
out.push({
|
|
101
108
|
type: hostPartType(part),
|
|
102
109
|
role,
|
|
103
110
|
text: extractText(part),
|
|
111
|
+
...(userReply ? { userReply } : {}),
|
|
104
112
|
});
|
|
105
113
|
}
|
|
106
114
|
}
|