Guidelines for AI agents working on this codebase.
OpenCode Browser provides browser automation tools to OpenCode via an OpenCode plugin, backed by a Chrome/Chromium extension.
Architecture:
OpenCode Plugin <-> Local Broker (unix socket) <-> Native Host <-> Chrome Extension
Components:
- Plugin (
src/plugin.ts) - OpenCode plugin that talks to the broker - Broker (
bin/broker.cjs) - local multiplexer + per-tab ownership - Native Host (
bin/native-host.cjs) - Chrome Native Messaging bridge to the broker - Extension (
extension/) - executes browser commands via Chrome APIs
# Install dependencies
bun install
# CLI install/uninstall/status
node bin/cli.js install
node bin/cli.js status
node bin/cli.js uninstall
# Validate scripts
node --check bin/broker.cjs
node --check bin/native-host.cjsTo test end-to-end you need:
- The extension loaded in
chrome://extensions - Native host manifest installed (via
npx @different-ai/opencode-browser install) - OpenCode configured with the plugin
Then run in a fresh OpenCode process:
opencode run "use browser_status"
opencode run "use browser_get_tabs"- 2-space indentation
- Double quotes
- Semicolons required
- 2-space indentation
- Double quotes
- No semicolons
- Native messaging requires the extension ID in the manifest (
allowed_origins). - Broker enforces per-tab ownership; first touch auto-claims.