Summary
Reimplemented agentmemory's 12 Claude Code hooks + 4 skills as an OpenCode plugin, skill, and commands. This gives non-Claude-Code users the auto-capture pipeline: tool calls → observations, session lifecycle, compaction memory injection, and manual recall/remember commands.
What was built
1. OpenCode Plugin (~/.config/opencode/plugins/agentmemory-capture.ts)
| Claude hook |
OpenCode hook |
agentmemory API |
| SessionStart |
session.created |
POST /session/start |
| Stop |
session.idle |
POST /summarize |
| SessionEnd |
session.deleted |
POST /session/end |
| PostToolUse |
tool.execute.after |
POST /observe |
| PostToolUseFailure |
session.error |
POST /observe |
| UserPromptSubmit |
message.updated (user role) |
POST /observe |
| PreCompact |
experimental.session.compacting |
GET /context → output.context |
2. Session Recall Skill
Updated skills/agentmemory-setup/SKILL.md to instruct the agent to call memory_smart_search and memory_lessons_recall at session start, with example queries.
3. Commands
Created .opencode/commands/recall.md and remember.md — wrap memory_smart_search and memory_save MCP tools with usage guidance.
Gaps (not yet implemented)
| Claude feature |
Reason |
| PreToolUse (file enrichment) |
OpenCode tool.execute.before doesn't have stdout→context pipe; also disabled by default (#143) |
| SubagentStart/Stop |
OpenCode Task tool lifecycle not exposable via plugin events |
| Notification / TaskCompleted |
Claude-specific events with no OpenCode equivalent |
| Claude Memory Bridge (MEMORY.md sync) |
OpenCode uses AGENTS.md; could be implemented as a skill |
/forget and /session-history commands |
Lower priority; can add later |
PreCompact implementation detail
OpenCode's experimental.session.compacting hook has output.context: string[] — this maps directly to Claude's PreCompact stdout injection. The plugin calls GET /agentmemory/context and pushes the result into output.context.
Plugin registration
{ "plugin": ["./plugins/agentmemory-capture.ts"] }
Environment
- agentmemory: v0.9.4 (Docker, iii-engine 0.11.6)
- OpenCode + @opencode-ai/plugin v1.1.25
- Full stack: Ollama embeddings + OpenRouter LLM + HTTP→stdio MCP bridge
Summary
Reimplemented agentmemory's 12 Claude Code hooks + 4 skills as an OpenCode plugin, skill, and commands. This gives non-Claude-Code users the auto-capture pipeline: tool calls → observations, session lifecycle, compaction memory injection, and manual recall/remember commands.
What was built
1. OpenCode Plugin (
~/.config/opencode/plugins/agentmemory-capture.ts)session.createdsession.idlesession.deletedtool.execute.aftersession.errormessage.updated(user role)experimental.session.compacting2. Session Recall Skill
Updated
skills/agentmemory-setup/SKILL.mdto instruct the agent to callmemory_smart_searchandmemory_lessons_recallat session start, with example queries.3. Commands
Created
.opencode/commands/recall.mdandremember.md— wrapmemory_smart_searchandmemory_saveMCP tools with usage guidance.Gaps (not yet implemented)
tool.execute.beforedoesn't have stdout→context pipe; also disabled by default (#143)/forgetand/session-historycommandsPreCompact implementation detail
OpenCode's
experimental.session.compactinghook hasoutput.context: string[]— this maps directly to Claude's PreCompact stdout injection. The plugin calls GET /agentmemory/context and pushes the result into output.context.Plugin registration
{ "plugin": ["./plugins/agentmemory-capture.ts"] }Environment