@ephemushroom/opencode-claude-mem 0.2.1 → 0.2.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/README.md +14 -12
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ This plugin communicates with the Claude-Mem worker service (HTTP API on port 37
|
|
|
11
11
|
- **Inject memory context** — previous session context is injected into the system prompt on every LLM call
|
|
12
12
|
- **Capture tool observations** — every tool execution is recorded as a structured observation
|
|
13
13
|
- **Summarize sessions** — when a session goes idle, the last user/assistant messages are sent for summarization
|
|
14
|
-
- **Search memory** —
|
|
14
|
+
- **Search memory** — memory search is available via claude-mem's MCP server
|
|
15
15
|
- **View context on demand** — `/memory` command displays the current memory context in the chat flow
|
|
16
16
|
|
|
17
17
|
## Differences from Claude Code Version
|
|
@@ -23,14 +23,15 @@ This OpenCode version works differently:
|
|
|
23
23
|
| | Claude Code | OpenCode (this plugin) |
|
|
24
24
|
|---|---|---|
|
|
25
25
|
| **Architecture** | Shell commands (`node script.js`) | JavaScript plugin API |
|
|
26
|
-
| **Context injection** | `SessionStart` hook stdout → system prompt (once) | `experimental.chat.system.transform` → system prompt (every LLM call) |
|
|
27
|
-
| **Context freshness** | Snapshot at session start |
|
|
26
|
+
| **Context injection** | `SessionStart` hook stdout → system prompt (once) | `experimental.chat.system.transform` → system prompt (every LLM call, session-level cache) |
|
|
27
|
+
| **Context freshness** | Snapshot at session start | Cached once per session (same as Claude Code) |
|
|
28
28
|
| **User-visible context** | Displayed in TUI automatically | `/memory` command to view on demand |
|
|
29
29
|
| **Session init** | `UserPromptSubmit` hook | `chat.message` hook with real user prompt |
|
|
30
|
-
| **Observations** | `PostToolUse` hook | `tool.execute.after` hook |
|
|
30
|
+
| **Observations** | `PostToolUse` hook | `tool.execute.after` hook (with circular memory protection) |
|
|
31
31
|
| **Summarization** | `Stop` hook | `session.idle` event |
|
|
32
|
+
| **Memory search** | MCP server | MCP server (same — no custom tool needed) |
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
Both versions behave the same way: context is fetched once per session and cached. The OpenCode plugin uses `experimental.chat.system.transform` which fires on every LLM call, but the context is session-level cached so the worker is only called once.
|
|
34
35
|
|
|
35
36
|
## Prerequisites
|
|
36
37
|
|
|
@@ -77,8 +78,8 @@ curl -s http://127.0.0.1:37777/api/health
|
|
|
77
78
|
|
|
78
79
|
Once installed, the plugin works automatically:
|
|
79
80
|
|
|
80
|
-
- **System prompt injection** — memory context is injected into every LLM call via `experimental.chat.system.transform`. The LLM sees your project's observation history, past decisions, and session summaries. Context is cached
|
|
81
|
-
- **Tool observation capture** — every tool execution (file reads, edits, searches, etc.) is recorded as an observation in the memory database.
|
|
81
|
+
- **System prompt injection** — memory context is injected into every LLM call via `experimental.chat.system.transform`. The LLM sees your project's observation history, past decisions, and session summaries. Context is cached once per session to avoid redundant worker calls.
|
|
82
|
+
- **Tool observation capture** — every tool execution (file reads, edits, searches, etc.) is recorded as an observation in the memory database. Claude-mem's own MCP tools are automatically filtered to prevent circular memory.
|
|
82
83
|
- **Session summarization** — when a session goes idle, the last user/assistant exchange is summarized and stored.
|
|
83
84
|
- **Toast notification** — on session start, a "Memory active · {project}" toast confirms the plugin is connected to the worker.
|
|
84
85
|
|
|
@@ -86,9 +87,9 @@ Once installed, the plugin works automatically:
|
|
|
86
87
|
|
|
87
88
|
Type `/memory` in the chat to display the current memory context inline. This shows you exactly what the LLM sees in its system prompt — the observation index, token economics, and session history.
|
|
88
89
|
|
|
89
|
-
###
|
|
90
|
+
### Memory Search
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
Memory search is provided by claude-mem's MCP server. If you have the claude-mem MCP configured in OpenCode, the LLM can search project history directly via MCP tools — no plugin-level tool needed.
|
|
92
93
|
|
|
93
94
|
### Alternative: Manual Installation (from source)
|
|
94
95
|
|
|
@@ -255,7 +256,7 @@ The plugin is a thin HTTP client. All heavy lifting (LLM processing, storage, se
|
|
|
255
256
|
|
|
256
257
|
| Claude Code Hook | OpenCode Hook | Purpose |
|
|
257
258
|
|-----------------|---------------|---------|
|
|
258
|
-
| `SessionStart` → context | `experimental.chat.system.transform` | Inject memory into system prompt (every LLM call,
|
|
259
|
+
| `SessionStart` → context | `experimental.chat.system.transform` | Inject memory into system prompt (every LLM call, session-level cache) |
|
|
259
260
|
| `UserPromptSubmit` → session-init | `chat.message` | Init session with real user prompt |
|
|
260
261
|
| `PostToolUse` → observation | `tool.execute.after` | Capture tool executions |
|
|
261
262
|
| `Stop` → summarize | `event` (session.idle) | Summarize with real message content |
|
|
@@ -272,7 +273,6 @@ The plugin is a thin HTTP client. All heavy lifting (LLM processing, storage, se
|
|
|
272
273
|
| `POST` | `/api/sessions/observations` | Send tool observation |
|
|
273
274
|
| `POST` | `/api/sessions/summarize` | Trigger summarization |
|
|
274
275
|
| `POST` | `/api/sessions/complete` | Complete session |
|
|
275
|
-
| `GET` | `/api/search?q={query}&project={name}` | Search memory |
|
|
276
276
|
|
|
277
277
|
## Key Implementation Details
|
|
278
278
|
|
|
@@ -281,8 +281,10 @@ The plugin is a thin HTTP client. All heavy lifting (LLM processing, storage, se
|
|
|
281
281
|
- **Deferred toast**: `client.tui.showToast()` is deferred to first hook invocation (TUI not ready during plugin init, calling it crashes OpenCode)
|
|
282
282
|
- **Real prompt**: `chat.message` hook extracts actual user input instead of hardcoded "SESSION_START"
|
|
283
283
|
- **Real summarize**: `session.idle` fetches last user/assistant messages via `client.session.messages()` for meaningful summaries
|
|
284
|
-
- **Context caching**: `getCachedContext()`
|
|
284
|
+
- **Context caching**: `getCachedContext()` caches context once per session (invalidated on `session.created`) to avoid redundant worker calls
|
|
285
285
|
- **Content-type handling**: Worker returns `text/plain` markdown — `getContext()` checks content-type and uses `response.text()` instead of `response.json()`
|
|
286
|
+
- **Context tag wrapping**: Injected context is wrapped in `<claude-mem-context>` tags so the worker's tag-stripping logic can remove it from observations, preventing circular memory
|
|
287
|
+
- **Circular memory protection**: `tool.execute.after` filters out claude-mem's own MCP tools (`claude-mem_mcp-search_*`) to prevent search results from being re-recorded as observations
|
|
286
288
|
- **`/memory` command**: Registered via `config` hook, handled by `command.execute.before` — displays context as an `ignored: true` message (visible to user, not sent to LLM)
|
|
287
289
|
|
|
288
290
|
## Troubleshooting
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ephemushroom/opencode-claude-mem",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "OpenCode plugin for Claude-Mem persistent memory system",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./server": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"scripts": {
|
|
@@ -44,10 +48,8 @@
|
|
|
44
48
|
"publishConfig": {
|
|
45
49
|
"access": "public"
|
|
46
50
|
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"@opencode-ai/plugin": "latest"
|
|
49
|
-
},
|
|
50
51
|
"devDependencies": {
|
|
52
|
+
"@opencode-ai/plugin": "^1.3.0",
|
|
51
53
|
"@types/bun": "latest",
|
|
52
54
|
"oxfmt": "^0.33.0",
|
|
53
55
|
"oxlint": "^1.48.0",
|