@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 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** — `mem-search` tool lets the LLM query project history
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 | Refreshed every 60s — new observations during the conversation are picked up |
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
- The key advantage of this plugin is **live context refresh** — in long conversations, the LLM always sees the latest observations, not a stale snapshot from session start.
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 for 60s to avoid redundant worker calls.
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
- ### `mem-search` Tool
90
+ ### Memory Search
90
91
 
91
- The LLM can use the `mem-search` tool to search project history and memory. This is available automatically — no action needed.
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, 60s cache) |
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()` wraps `WorkerClient.getContext()` with a 60s TTL cache to avoid redundant worker calls
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
@@ -13,3 +13,7 @@ import { type Plugin } from '@opencode-ai/plugin';
13
13
  * Uses TUI toast notifications for status feedback.
14
14
  */
15
15
  export declare const ClaudeMemPlugin: Plugin;
16
+ declare const _default: {
17
+ server: Plugin;
18
+ };
19
+ export default _default;
package/dist/index.js CHANGED
@@ -287,6 +287,8 @@ ${context}
287
287
  }
288
288
  };
289
289
  };
290
+ var src_default = { server: ClaudeMemPlugin };
290
291
  export {
292
+ src_default as default,
291
293
  ClaudeMemPlugin
292
294
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ephemushroom/opencode-claude-mem",
3
- "version": "0.2.1",
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",