@ephemushroom/opencode-claude-mem 0.7.0 → 0.7.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 +112 -62
- package/dist/capture-status.d.ts +26 -0
- package/dist/cli.js +239 -31
- package/dist/official-sync.d.ts +29 -0
- package/dist/server.d.ts +70 -0
- package/dist/server.js +1299 -0
- package/dist/sidebar-model.d.ts +4 -1
- package/dist/tui.js +195 -31
- package/dist/worker-client.d.ts +28 -1
- package/dist/worker-start.d.ts +46 -0
- package/dist/worker-tools.d.ts +33 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -18,10 +18,17 @@ The **Memory sidebar** for [OpenCode](https://opencode.ai), backed by
|
|
|
18
18
|
Click an item for details ← opens the full summary or observation
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
One package brings claude-mem to OpenCode 2, installed and updated like any other plugin:
|
|
22
|
+
|
|
23
|
+
- **Capture and context injection** run the **official claude-mem OpenCode plugin**. This
|
|
24
|
+
package downloads it at the running Worker's version (from the `claude-mem` npm release,
|
|
25
|
+
checked against the registry's sha512) and loads it, so capture always matches the
|
|
26
|
+
Worker's API and no file has to be copied by hand.
|
|
27
|
+
- **Memory tools** beyond the official plugin's search: `save_memory`, `work_state_write`,
|
|
28
|
+
`work_state_read`, `dumb_search`, `get_tool_uses` and the six corpus tools, served straight
|
|
29
|
+
from the Worker's HTTP API. No MCP server is needed.
|
|
30
|
+
- **The Worker is started** when nothing answers on its port.
|
|
31
|
+
- **The Memory sidebar**, below.
|
|
25
32
|
|
|
26
33
|
- Counts are for the current project (the directory name), matching the Worker's own
|
|
27
34
|
project filter: case-insensitive, merged projects included. They are read from the Worker's
|
|
@@ -38,61 +45,81 @@ removed so the two can never run side by side.
|
|
|
38
45
|
- Recent rows are fetched only while expanded; collapsed, it polls stats every 5s.
|
|
39
46
|
- Read-only and fail-open: an offline Worker shows the offline state, never blocks the TUI.
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
Verified on macOS with OpenCode **2.3.0** (built against `@opencode/plugin` 2.2.7,
|
|
49
|
+
`@opentui/solid` 0.8.1). The Windows paths follow claude-mem's own launcher location but
|
|
50
|
+
have not been run on Windows yet.
|
|
43
51
|
|
|
44
52
|
## Setup (OpenCode 2)
|
|
45
53
|
|
|
46
|
-
1. **Install
|
|
54
|
+
1. **Install claude-mem** once per machine. This installs the Worker and its launcher:
|
|
47
55
|
|
|
48
56
|
```bash
|
|
49
|
-
|
|
57
|
+
npx claude-mem install
|
|
50
58
|
```
|
|
51
59
|
|
|
52
|
-
2. **
|
|
53
|
-
`~/.config/opencode/
|
|
60
|
+
2. **Add the plugin.** This installs the package and lists it in
|
|
61
|
+
`~/.config/opencode/opencode.json`:
|
|
54
62
|
|
|
55
63
|
```bash
|
|
56
|
-
|
|
57
|
-
cd "$(mktemp -d)" && npm pack claude-mem@latest --silent \
|
|
58
|
-
&& tar -xzf claude-mem-*.tgz package/dist/opencode-plugin/index.js \
|
|
59
|
-
&& cp package/dist/opencode-plugin/index.js ~/.config/opencode/plugins/claude-mem.js
|
|
64
|
+
opencode plugin add @ephemushroom/opencode-claude-mem
|
|
60
65
|
```
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
Worker upgrade.
|
|
64
|
-
|
|
65
|
-
3. **Register the MCP server** (search, timeline, observations, `save_memory`,
|
|
66
|
-
`work_state_*`) in `~/.config/opencode/opencode.json`, under V2's `mcp.servers`:
|
|
67
|
+
3. **Add the sidebar** to `~/.config/opencode/cli.json`:
|
|
67
68
|
|
|
68
69
|
```json
|
|
69
|
-
{
|
|
70
|
-
"mcp": {
|
|
71
|
-
"servers": {
|
|
72
|
-
"claude-mem": {
|
|
73
|
-
"type": "local",
|
|
74
|
-
"command": [
|
|
75
|
-
"/opt/homebrew/bin/node",
|
|
76
|
-
"/Users/<you>/.claude/plugins/marketplaces/thedotmack/plugin/scripts/mcp-server.cjs"
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
70
|
+
{ "plugins": ["@ephemushroom/opencode-claude-mem"] }
|
|
82
71
|
```
|
|
83
72
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
which writes the V1 `mcp` shape.
|
|
73
|
+
Restart OpenCode. The first start downloads the official files (about 10 MB) in the
|
|
74
|
+
background; the memory tools work at once, and capture begins when the download finishes.
|
|
87
75
|
|
|
88
|
-
|
|
76
|
+
### Updating
|
|
89
77
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
```bash
|
|
79
|
+
opencode plugin update # this package: server part and sidebar
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
OpenCode does not update plugins by itself. The official claude-mem files need no command:
|
|
83
|
+
after a Worker upgrade, the next OpenCode start fetches the matching version.
|
|
84
|
+
|
|
85
|
+
### Options
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"plugins": [{ "package": "@ephemushroom/opencode-claude-mem", "options": { "mcp": true } }]
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `mcp: true` registers claude-mem's own MCP server (every tool it has, including the
|
|
94
|
+
`smart_*` code-outline tools) in a separate process, instead of this package's tools.
|
|
95
|
+
A `claude-mem` entry you wrote under `mcp.servers` is left as it is.
|
|
96
|
+
|
|
97
|
+
claude-mem's settings apply as usual (its `settings.json`, in `~/.claude-mem` or
|
|
98
|
+
`CLAUDE_MEM_DATA_DIR`, or the environment):
|
|
93
99
|
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
- `CLAUDE_MEM_WORKER_HOST` / `CLAUDE_MEM_WORKER_PORT` select the Worker. Without a port,
|
|
101
|
+
claude-mem's own default applies (37700 plus the last two digits of the user id).
|
|
102
|
+
- `CLAUDE_MEM_LOCAL_API_TOKEN` is sent to a Worker on this machine that requires it. This
|
|
103
|
+
package's own requests refuse redirects; the official plugin's capture requests are
|
|
104
|
+
claude-mem's code and follow them (as of 15.18.3).
|
|
105
|
+
- `CLAUDE_MEM_WORKER_AUTOSTART=false` keeps this package from starting the Worker.
|
|
106
|
+
- `CLAUDE_MEM_WORK_STATE_ENABLED=false` removes the two work-state tools.
|
|
107
|
+
- `CLAUDE_MEM_WORKER_URL` is not supported: the official OpenCode plugin addresses the
|
|
108
|
+
Worker by host and port only, so the sidebar reports it and nothing is captured.
|
|
109
|
+
|
|
110
|
+
### Tools
|
|
111
|
+
|
|
112
|
+
OpenCode lists them as the `claude_mem` namespace (`tools.claude_mem.save_memory(...)` in
|
|
113
|
+
Code Mode, `claude_mem_save_memory` as a direct tool call). The official plugin adds
|
|
114
|
+
`claude_mem_search`, `claude_mem_timeline` and `claude_mem_get_observations`.
|
|
115
|
+
|
|
116
|
+
| Tool | Purpose |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `save_memory` | Save a durable note |
|
|
119
|
+
| `work_state_write` / `work_state_read` | Per-project to-do lists and working state, shown at session start |
|
|
120
|
+
| `dumb_search` | One-call lookup by title overlap |
|
|
121
|
+
| `get_tool_uses` | Raw tool input/output for selected ids |
|
|
122
|
+
| `build_corpus`, `list_corpora`, `prime_corpus`, `query_corpus`, `rebuild_corpus`, `reprime_corpus` | Knowledge corpora |
|
|
96
123
|
|
|
97
124
|
### Share memory across Claude Code and OpenCode
|
|
98
125
|
|
|
@@ -106,52 +133,75 @@ add this to `~/.claude-mem/settings.json` (it also applies to Claude Code's sess
|
|
|
106
133
|
### Verify
|
|
107
134
|
|
|
108
135
|
```bash
|
|
109
|
-
opencode plugin list # claude-mem
|
|
110
|
-
opencode mcp list # ✓ claude-mem connected
|
|
136
|
+
opencode plugin list # opencode-claude-mem 0.7.1 @ephemushroom/opencode-claude-mem
|
|
111
137
|
```
|
|
112
138
|
|
|
113
139
|
Open a session: the sidebar shows `▶ Memory (online, …)`, and new observations carry
|
|
114
140
|
canonical tool names (`Read`, `Edit`, `Bash`) with `files_modified` filled in.
|
|
115
141
|
|
|
116
|
-
|
|
142
|
+
### Where files go
|
|
117
143
|
|
|
118
|
-
|
|
119
|
-
`
|
|
144
|
+
`~/.cache/opencode-claude-mem/` (or `$XDG_CACHE_HOME/opencode-claude-mem/`): the official
|
|
145
|
+
files under `official/<version>/` (about 1.5 MB per claude-mem version; earlier versions are
|
|
146
|
+
kept, because another OpenCode process may still run from them) and `status/`, which carries
|
|
147
|
+
the server part's state to the sidebar. Deleting the directory while OpenCode is closed is
|
|
148
|
+
safe.
|
|
120
149
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
## Migrating
|
|
151
|
+
|
|
152
|
+
**From v0.7.0's manual setup.** Remove what the manual steps installed, then follow Setup:
|
|
153
|
+
|
|
154
|
+
- delete `~/.config/opencode/plugins/claude-mem.js`. While that file exists it keeps
|
|
155
|
+
capturing, this package does not load a second copy, and that file is not kept up to date;
|
|
156
|
+
- delete the `claude-mem` entry under `mcp.servers` in `opencode.json`, unless you want
|
|
157
|
+
the MCP server; in that case use `options.mcp` instead.
|
|
158
|
+
|
|
159
|
+
**From v0.6.x.** Its own capture adapter is gone; capture is the official plugin's.
|
|
160
|
+
`mem-search` / `mem-timeline` / `mem-get-observations` are now `claude_mem_search` /
|
|
161
|
+
`claude_mem_timeline` / `claude_mem_get_observations`, and `mem-save` is `save_memory`.
|
|
162
|
+
Read-file history and opt-in semantic injection are not available.
|
|
127
163
|
|
|
128
|
-
|
|
164
|
+
**OpenCode 1.** The server part needs OpenCode 2. On OpenCode 1 use
|
|
165
|
+
`npx claude-mem install --ide opencode`; the sidebar still loads from `tui.json`.
|
|
129
166
|
|
|
130
167
|
## Troubleshooting
|
|
131
168
|
|
|
132
|
-
- **`(offline)`**: the Worker is not running
|
|
169
|
+
- **`(offline)`**: the Worker is not running and could not be started. Run
|
|
170
|
+
`npx claude-mem start`; if that command is missing, `npx claude-mem install`.
|
|
171
|
+
- **`(capture off)`**: nothing records this OpenCode's sessions. Expand the sidebar: the
|
|
172
|
+
first row says why (claude-mem not installed, the Worker did not start, the download
|
|
173
|
+
failed, or a `plugins/claude-mem.js` file that OpenCode has not loaded) and what to do.
|
|
174
|
+
The package looks again every minute.
|
|
133
175
|
- **Sidebar missing**: check `~/.config/opencode/cli.json` lists the package; the sidebar
|
|
134
176
|
needs OpenCode's `@opentui/solid` runtime and is skipped silently without it.
|
|
135
|
-
- **Duplicate observations**: two capture integrations are active. Remove
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
177
|
+
- **Duplicate observations**: two capture integrations are active. Remove
|
|
178
|
+
`~/.config/opencode/plugins/claude-mem.js` or this package, and disable any Claude Code
|
|
179
|
+
compatibility bridge for claude-mem. In Code Mode one call is recorded as `execute` plus
|
|
180
|
+
the tool it ran; that is one call, not a duplicate.
|
|
181
|
+
- **Behind a registry mirror**: the download uses `CLAUDE_MEM_NPM_REGISTRY`, then
|
|
182
|
+
`npm_config_registry`, then `https://registry.npmjs.org`. The mirror must be HTTPS (or on
|
|
183
|
+
this machine): it names both the tarball and its checksum, so it is trusted like the
|
|
184
|
+
registry itself.
|
|
139
185
|
|
|
140
186
|
## Development
|
|
141
187
|
|
|
142
188
|
```bash
|
|
143
189
|
bun install
|
|
144
|
-
bun run build # sidebar adapters + TUI bridge + declarations
|
|
190
|
+
bun run build # server part + sidebar adapters + TUI bridge + declarations
|
|
145
191
|
bun test # build first: export tests import dist artifacts
|
|
146
192
|
bun run typecheck && bun run lint && bun run fmt:check
|
|
193
|
+
bun src/test-fixtures/server-runtime.ts # installed opencode: download, capture, tools
|
|
194
|
+
bun src/test-fixtures/server-runtime.ts mcp # options.mcp registers the MCP server
|
|
195
|
+
bun src/test-fixtures/server-runtime.ts start # no Worker: the launcher is run (macOS/Linux)
|
|
196
|
+
bun src/test-fixtures/server-runtime.ts standalone # plugins/claude-mem.js present: one capture
|
|
147
197
|
bun src/test-fixtures/tui-runtime.ts # installed opencode: real PTY, render + mouse toggle
|
|
148
198
|
bun src/test-fixtures/tui-runtime.ts offline # offline state renders and toggles
|
|
149
199
|
bun --conditions=browser src/test-fixtures/cli-driver.ts render # OpenTUI component driver
|
|
150
200
|
```
|
|
151
201
|
|
|
152
|
-
The
|
|
153
|
-
the installed `opencode` in an isolated home with a fake Worker.
|
|
154
|
-
or memory database
|
|
202
|
+
The runtime checks pack the current build, serve it from a temporary local registry, and run
|
|
203
|
+
the installed `opencode` in an isolated home with a fake Worker and model. They never touch
|
|
204
|
+
your config or memory database. The server check downloads the real `claude-mem` release. Set `MEM_TUI_EVIDENCE_DIR` to keep the captured
|
|
155
205
|
collapsed, expanded, detail-dialog and re-collapsed frames.
|
|
156
206
|
|
|
157
207
|
## License
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface CaptureStatus {
|
|
2
|
+
/** `problem`: nothing is capturing this checkout's sessions. */
|
|
3
|
+
readonly state: 'ok' | 'problem';
|
|
4
|
+
/** Empty when there is nothing to tell the user. */
|
|
5
|
+
readonly message: string;
|
|
6
|
+
}
|
|
7
|
+
/** Holds the official claude-mem files this package downloads, and the status files. */
|
|
8
|
+
export declare function cacheDirectory(env?: Record<string, string | undefined>, home?: string): string;
|
|
9
|
+
/** Names the status files of one checkout, however its path was spelled. */
|
|
10
|
+
export declare function statusKey(directory: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* The newest status a running server part wrote for this checkout, preferring one from
|
|
13
|
+
* this process. Null when none is running: a status left by a package that was since
|
|
14
|
+
* removed from `opencode.json`, or by a process that exited, must not stay on screen.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readCaptureStatus(directory: string, dir?: string): CaptureStatus | null;
|
|
17
|
+
export interface CaptureStatusWriter {
|
|
18
|
+
readonly write: (status: CaptureStatus) => void;
|
|
19
|
+
/** Called when the server part is unloaded for the checkout while the host keeps running. */
|
|
20
|
+
readonly clear: () => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The status file of one `setup` call. Each has its own, so two servers on one checkout,
|
|
24
|
+
* or a reload that sets up before the old instance is disposed, never remove each other's.
|
|
25
|
+
*/
|
|
26
|
+
export declare function captureStatusWriter(directory: string, dir?: string): CaptureStatusWriter;
|