OpenCode plugin.
Add to your opencode.json (global or per-project):
{
"plugin": ["@involvex/opencode-statusbar@latest"]
}OpenCode will automatically install the plugin on next launch.
# Install dependencies
bun install
# Run OpenCode with the plugin loaded from source
bun dev
# Typecheck
bun typecheckopencode-statusbar/
├── src/
│ └── index.ts # Plugin entry point with all available hooks
├── dev.ts # Development script (runs OpenCode with plugin)
├── package.json
├── tsconfig.json
└── ...
Your plugin receives a context object with:
client- OpenCode SDK client for API calls (logging, toasts, etc.)project- Current project informationdirectory- Current working directoryworktree- Git worktree path$- Bun shell for executing commands
See src/index.ts for all available hooks with descriptions. Key hooks:
| Hook | Description |
|---|---|
event |
Subscribe to OpenCode events (session.idle, file.edited, etc.) |
chat.message |
Intercept user messages |
chat.params |
Modify LLM parameters (temperature, etc.) |
tool.execute.before |
Modify tool arguments or block execution |
tool.execute.after |
Process tool results |
permission.ask |
Auto-allow/deny permissions |
tool |
Register custom tools |
Use client.app.log() for structured logging instead of console.log:
await ctx.client.app.log({
body: {
service: 'opencode-statusbar',
level: 'info', // 'debug' | 'info' | 'warn' | 'error'
message: 'Something happened',
extra: {foo: 'bar'},
},
})import {tool} from '@opencode-ai/plugin'
export const MyPlugin: Plugin = async ctx => {
return {
tool: {
mytool: tool({
description: 'What this tool does',
args: {
input: tool.schema.string(),
},
async execute(args, context) {
return `Result: ${args.input}`
},
}),
},
}
}npm publishAfter publishing, users can install with:
{
"plugin": ["@involvex/opencode-statusbar@latest"]
}MIT