Opencode Plugins
1 min read
OpenCode Plugins
Plugins allow you to extend OpenCode's functionality by writing custom JavaScript or TypeScript code. They can hook into the agent's event loop, modify behavior, or integrate with external tools.
Capability
Plugins can hook into various events such as:
- Commands: Create custom slash commands.
- Files: React to file changes.
- LSP: Intercept or interact with Language Server Protocol events.
- Messages: Modify or analyze messages sent/received.
- Tools: Add new tools or modify existing ones.
Installation
You can load plugins from local files or via npm.
Local Plugins
Create .js or .ts files in:
- Project:
.opencode/plugin/ - Global:
~/.config/opencode/plugin/
Files in these directories are automatically loaded when OpenCode starts.
NPM Plugins
You can install plugins from npm and specify them in your opencode.json configuration file.
Example Use Cases
- Custom Logging: Log specific agent actions to a file.
- Enforce Rules: Prevent the agent from editing specific files.
- Integrations: Connect OpenCode to your issue tracker or deployment system.