Add iai-mcp-session-init plugin for automatic memory loading in OpenCode

This commit is contained in:
Apunkt 2026-05-26 09:48:46 +02:00
parent ebe7ebf17a
commit 31a69186a3
No known key found for this signature in database
2 changed files with 68 additions and 7 deletions

View file

@ -133,15 +133,21 @@ Use the absolute path. `~` and `$HOME` won't expand here.
For Claude Desktop (untested), edit `~/Library/Application Support/Claude/claude_desktop_config.json`.
### Install the OpenCode plugin
### Install the OpenCode plugins
This is the OpenCode equivalent of the Claude Code Stop hook. It listens for idle sessions and writes a deferred-capture JSONL file for the daemon to drain.
**Capture plugin** — listens for idle sessions and writes a deferred-capture JSONL file for the daemon to drain.
```bash
mkdir -p ~/.config/opencode/plugins
cp deploy/opencode/iai-mcp-capture.js ~/.config/opencode/plugins/
```
**Session-init plugin** — automatically loads session background memory on every new session. The model calls `memory_session_context` before responding, so it has your identity, topic cluster, and rich club context from turn one.
```bash
cp deploy/opencode/iai-mcp-session-init.js ~/.config/opencode/plugins/
```
Make sure `@opencode-ai/plugin` is installed:
```bash
@ -149,12 +155,27 @@ cd ~/.config/opencode
npm install @opencode-ai/plugin
```
### Connect OpenCode
Add the MCP server to `~/.config/opencode/config.json`:
Register both plugins in `~/.config/opencode/config.json`:
```json
{
"plugin": [
"~/.config/opencode/plugins/iai-mcp-capture.js",
"~/.config/opencode/plugins/iai-mcp-session-init.js"
]
}
```
### Connect OpenCode
Add the MCP server and plugins to `~/.config/opencode/config.json`:
```json
{
"plugin": [
"~/.config/opencode/plugins/iai-mcp-capture.js",
"~/.config/opencode/plugins/iai-mcp-session-init.js"
],
"mcp": {
"iai-mcp": {
"type": "local",
@ -165,7 +186,7 @@ Add the MCP server to `~/.config/opencode/config.json`:
}
```
Use the absolute path to `mcp-wrapper/dist/index.js`. The plugin file (`iai-mcp-capture.js`) must already be in `~/.config/opencode/plugins/`.
Use the absolute path to `mcp-wrapper/dist/index.js`. Both plugin files must already be in `~/.config/opencode/plugins/`.
### Verify
@ -362,7 +383,7 @@ Limitations worth knowing about:
Claude Code is the primary host, validated in daily use.
OpenCode is supported via the `iai-mcp-capture.js` plugin (see Install the OpenCode plugin above) and MCP server config in `~/.config/opencode/config.json`.
OpenCode is supported via the `iai-mcp-capture.js` and `iai-mcp-session-init.js` plugins (see Install the OpenCode plugins above) and MCP server config in `~/.config/opencode/config.json`.
Claude Desktop should work (uses `claude_desktop_config.json` instead of `~/.claude.json`) but hasn't been tested end to end.