OpenCode CLI
VS Code extension that brings the OpenCode AI coding agent into your editor with workspace chat, session browsing, and a setup/doctor experience that does not depend on undocumented HTTP endpoints.
Features
- Chat Panel — converse with the OpenCode agent directly inside VS Code using
opencode run
- Workspace Sessions — browse and reopen sessions for the current workspace using
opencode session list --format json
- Setup Wizard — checks installation, provider login, optional web server health, and links to doctor/login flows
- Doctor Command — run
OpenCode CLI: Doctor to collect diagnostics (binary, version, npm, server health)
- Status Bar —
OC indicator with color states (green=ready, yellow=starting, red=error)
Requirements
- OpenCode CLI (
npm install -g opencode-ai)
- An LLM provider configured via
opencode auth login
Extension Settings
| Setting |
Default |
Description |
opencodeCli.port |
4096 |
Optional port for standalone opencode serve health checks |
opencodeCli.autoInstall |
true |
Try a background npm install -g opencode-ai if the binary is missing |
opencodeCli.serverPassword |
"" |
Reserved for standalone web server auth |
Commands
| Command |
Keybinding (Mac) |
Keybinding (Win) |
OpenCode CLI: Open Panel |
Cmd+K O |
Ctrl+K O |
OpenCode CLI: New Session |
— |
— |
OpenCode CLI: Doctor |
— |
— |
Commands are available in the editor title menu and editor context menu for Markdown, TypeScript, JavaScript, and Python files.
Architecture
opencode-cli/
├── src/
│ ├── extension.ts # Activation, status bar, command registration
│ ├── cli.ts # Binary detection & auto-install
│ ├── server.ts # ServerManager — spawns & monitors opencode serve
│ ├── panel.ts # WebviewPanel provider (CSP, message bridge)
│ └── webview/
│ ├── index.tsx # Preact entry
│ ├── App.tsx # Tab navigation (Chat / Setup / Agents)
│ ├── ChatPanel.tsx # Session-based chat UI backed by CLI commands
│ └── SetupWizard.tsx # Installation/provider checks and doctor actions
├── media/ # Static assets & compiled webview bundle
├── build.js # esbuild bundler (node + browser dual target)
└── package.json
The webview is built with Preact and communicates with the extension host via postMessage. The extension host shells out to opencode for chat, session export, and provider checks, and only uses opencode serve as an optional health probe for the standalone web UI.
Development
git clone https://github.com/daniel-sosa/opencode-cli.git
cd opencode-cli
npm install
npm run build # build both extension + webview
npm run watch # watch mode
npm run package # package .vsix with vsce
To test locally, open the opencode-cli folder in VS Code and press F5.
Publishing
npm run publish
Requires vsce auth token with publisher daniel-sosa.