opencode
A plugin for opencode that appends relevant memories to each turn and captures sessions when they go idle.
The opencode plugin gives opencode the same memory loop as the Claude Code hooks.
- Recall: each user message is searched against m3m0s, and the relevant hits are appended to that turn’s system prompt.
- Capture: on
session.idle(asStop) and on shutdown (SessionEnd) the session text is written to~/.m3m0s/hooks/opencode/<session>.jsonland handed tom3m0s hook claude-code. Memories carrysource: "opencode".
Install
- Install the binary and store the credentials: CLI and credentials. Set
M3M0S_BINif the binary is not at~/go/bin/m3m0sor onPATH. - Add the npm package to the
pluginarray ofopencode.json. opencode installs it on start:
{
"plugin": ["@rafaelvieiras/m3m0s-opencode"]
}
Manual install
Or put the file in opencode’s plugins folder:
mkdir -p ~/.config/opencode/plugins
curl -fsSL https://raw.githubusercontent.com/rafaelvieiras/m3m0s/main/integrations/opencode/m3m0s-memory.js \
-o ~/.config/opencode/plugins/m3m0s-memory.js
Then add it to opencode.json:
{
"plugin": ["./plugins/m3m0s-memory.js"]
}
Optional: read-only MCP
So the agent can also search explicitly:
{
"mcp": {
"m3m0s": {
"type": "local",
"enabled": true,
"command": ["sh", "-c", "set -a; . \"$HOME/.m3m0s/hook.env\"; exec m3m0s mcp --read-only"]
}
}
}
Troubleshooting
Failures are silent and never block opencode. The log is ~/.m3m0s/hooks/claude-code.log. Run m3m0s doctor to check credentials and the connection.