docs: update README for V2-only, remove V1 references
This commit is contained in:
parent
bee794204b
commit
79e785330f
37
README.md
37
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# opencode-matrix-plugin
|
||||
|
||||
OpenCode plugin that connects your OpenCode agent to Matrix messaging servers. Supports both V1 (SDK) and V2 (full context) APIs.
|
||||
OpenCode V2 plugin that connects your OpenCode agent to Matrix messaging servers.
|
||||
|
||||
## Features
|
||||
|
||||
|
|
@ -14,17 +14,16 @@ OpenCode plugin that connects your OpenCode agent to Matrix messaging servers. S
|
|||
- **Rate Limiting**: Configurable per-user rate limiting
|
||||
- **User Allowlisting**: Restrict who can interact with the bot
|
||||
- **Session Persistence**: Sessions survive plugin reloads via `~/.opencode-matrix-sessions.json`
|
||||
- **V1/V2 Dual Support**: Works with OpenCode 1.18.x (V1 SDK) and V2 (full context)
|
||||
|
||||
## Installation
|
||||
|
||||
### Option 1: Local Plugin (Recommended)
|
||||
|
||||
1. Copy this plugin directory into your OpenCode config:
|
||||
1. Create a symlink from your OpenCode config to this plugin:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.config/opencode/plugins
|
||||
cp -r ./plugins/matrix-plugin ~/.config/opencode/plugins/
|
||||
ln -s /path/to/your/opencode_matrix ~/.config/opencode/plugins/matrix-plugin
|
||||
```
|
||||
|
||||
2. Add the plugin to your `opencode.jsonc`:
|
||||
|
|
@ -37,11 +36,14 @@ cp -r ./plugins/matrix-plugin ~/.config/opencode/plugins/
|
|||
}
|
||||
```
|
||||
|
||||
### Option 2: Symlink
|
||||
### Option 2: Published Package
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.config/opencode/plugins
|
||||
ln -s /path/to/your/project/plugins/matrix-plugin ~/.config/opencode/plugins/matrix-plugin
|
||||
```jsonc
|
||||
{
|
||||
"plugins": [
|
||||
"opencode-matrix-plugin"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
|
@ -200,15 +202,13 @@ MatrixBotClient (matrix-bot-sdk + Rust crypto)
|
|||
SessionManager
|
||||
│
|
||||
├── Rate limiting
|
||||
├── Event deduplication
|
||||
├── Thread isolation (room:threadId)
|
||||
└── Session persistence (~/.opencode-matrix-sessions.json)
|
||||
│
|
||||
▼
|
||||
OpenCode API
|
||||
OpenCode V2 API
|
||||
│
|
||||
├── V2: ctx.session.prompt() / ctx.session.create()
|
||||
├── V1: sdkClient.session.prompt() / sdkClient.session.create()
|
||||
├── ctx.session.prompt() / ctx.session.create()
|
||||
└── Session mapping: Matrix thread → OpenCode session
|
||||
│
|
||||
▼
|
||||
|
|
@ -219,8 +219,7 @@ Response → MatrixBotClient → Matrix Room
|
|||
|
||||
Sessions are persisted across plugin restarts in `~/.opencode-matrix-sessions.json`.
|
||||
|
||||
- **V1 API**: Sessions are created with auto-generated IDs, mapped via JSON file
|
||||
- **V2 API**: Sessions can be created with custom deterministic IDs (no map needed)
|
||||
- **V2 API**: Sessions are created with deterministic IDs (`roomId:threadRootId`)
|
||||
- **Sync**: Use `sessionManager.syncWithOpenCode(sessionIds)` to prune orphaned sessions
|
||||
|
||||
## Security
|
||||
|
|
@ -229,7 +228,7 @@ Sessions are persisted across plugin restarts in `~/.opencode-matrix-sessions.js
|
|||
- **Token Storage**: Access tokens saved with `0o600` permissions
|
||||
- **User Allowlisting**: Restrict bot access to specific users
|
||||
- **Rate Limiting**: Prevent message spam
|
||||
- **Event Deduplication**: Prevent processing duplicate events
|
||||
- **Mutex Lock**: Prevents duplicate bot startup (server + client both load plugins)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
|
@ -239,7 +238,7 @@ Sessions are persisted across plugin restarts in `~/.opencode-matrix-sessions.js
|
|||
2. Verify the trigger pattern matches your message
|
||||
3. Check if the user is in the allowed list (if configured)
|
||||
4. Check `~/.local/share/opencode-matrix-bot/` for state files
|
||||
5. Enable debug logging: `BRIDGE_DEBUG=1 opencode`
|
||||
5. Check logs: `~/.opencode-matrix-plugin/plugin.log`
|
||||
|
||||
### Authentication fails
|
||||
|
||||
|
|
@ -254,10 +253,14 @@ Sessions are persisted across plugin restarts in `~/.opencode-matrix-sessions.js
|
|||
2. Check crypto storage directory has write permissions
|
||||
3. Verify the bot has access to the encrypted room
|
||||
|
||||
### Double bot startup
|
||||
|
||||
OpenCode V2 loads plugins in both the background server and the client. The plugin uses a file-based mutex (`~/.local/share/opencode-matrix-bot/plugin-data/lock`) to prevent duplicate bot instances. If you see two bots, check that the lock file is being created.
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
cd plugins/matrix-plugin
|
||||
cd /path/to/opencode_matrix
|
||||
bun install
|
||||
bun run typecheck
|
||||
bun run build
|
||||
|
|
|
|||
Loading…
Reference in New Issue