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-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
|
## Features
|
||||||
|
|
||||||
|
|
@ -14,17 +14,16 @@ OpenCode plugin that connects your OpenCode agent to Matrix messaging servers. S
|
||||||
- **Rate Limiting**: Configurable per-user rate limiting
|
- **Rate Limiting**: Configurable per-user rate limiting
|
||||||
- **User Allowlisting**: Restrict who can interact with the bot
|
- **User Allowlisting**: Restrict who can interact with the bot
|
||||||
- **Session Persistence**: Sessions survive plugin reloads via `~/.opencode-matrix-sessions.json`
|
- **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
|
## Installation
|
||||||
|
|
||||||
### Option 1: Local Plugin (Recommended)
|
### 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
|
```bash
|
||||||
mkdir -p ~/.config/opencode/plugins
|
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`:
|
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
|
```jsonc
|
||||||
mkdir -p ~/.config/opencode/plugins
|
{
|
||||||
ln -s /path/to/your/project/plugins/matrix-plugin ~/.config/opencode/plugins/matrix-plugin
|
"plugins": [
|
||||||
|
"opencode-matrix-plugin"
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
@ -200,15 +202,13 @@ MatrixBotClient (matrix-bot-sdk + Rust crypto)
|
||||||
SessionManager
|
SessionManager
|
||||||
│
|
│
|
||||||
├── Rate limiting
|
├── Rate limiting
|
||||||
├── Event deduplication
|
|
||||||
├── Thread isolation (room:threadId)
|
├── Thread isolation (room:threadId)
|
||||||
└── Session persistence (~/.opencode-matrix-sessions.json)
|
└── Session persistence (~/.opencode-matrix-sessions.json)
|
||||||
│
|
│
|
||||||
▼
|
▼
|
||||||
OpenCode API
|
OpenCode V2 API
|
||||||
│
|
│
|
||||||
├── V2: ctx.session.prompt() / ctx.session.create()
|
├── ctx.session.prompt() / ctx.session.create()
|
||||||
├── V1: sdkClient.session.prompt() / sdkClient.session.create()
|
|
||||||
└── Session mapping: Matrix thread → OpenCode session
|
└── 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`.
|
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 are created with deterministic IDs (`roomId:threadRootId`)
|
||||||
- **V2 API**: Sessions can be created with custom deterministic IDs (no map needed)
|
|
||||||
- **Sync**: Use `sessionManager.syncWithOpenCode(sessionIds)` to prune orphaned sessions
|
- **Sync**: Use `sessionManager.syncWithOpenCode(sessionIds)` to prune orphaned sessions
|
||||||
|
|
||||||
## Security
|
## Security
|
||||||
|
|
@ -229,7 +228,7 @@ Sessions are persisted across plugin restarts in `~/.opencode-matrix-sessions.js
|
||||||
- **Token Storage**: Access tokens saved with `0o600` permissions
|
- **Token Storage**: Access tokens saved with `0o600` permissions
|
||||||
- **User Allowlisting**: Restrict bot access to specific users
|
- **User Allowlisting**: Restrict bot access to specific users
|
||||||
- **Rate Limiting**: Prevent message spam
|
- **Rate Limiting**: Prevent message spam
|
||||||
- **Event Deduplication**: Prevent processing duplicate events
|
- **Mutex Lock**: Prevents duplicate bot startup (server + client both load plugins)
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
|
@ -239,7 +238,7 @@ Sessions are persisted across plugin restarts in `~/.opencode-matrix-sessions.js
|
||||||
2. Verify the trigger pattern matches your message
|
2. Verify the trigger pattern matches your message
|
||||||
3. Check if the user is in the allowed list (if configured)
|
3. Check if the user is in the allowed list (if configured)
|
||||||
4. Check `~/.local/share/opencode-matrix-bot/` for state files
|
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
|
### 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
|
2. Check crypto storage directory has write permissions
|
||||||
3. Verify the bot has access to the encrypted room
|
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
|
## Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd plugins/matrix-plugin
|
cd /path/to/opencode_matrix
|
||||||
bun install
|
bun install
|
||||||
bun run typecheck
|
bun run typecheck
|
||||||
bun run build
|
bun run build
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue