OpenCode 2 for VS Code
Independent project. Not affiliated with or maintained by the OpenCode team (Anomaly). Built on the released OpenCode 2 API (@opencode/client 2.x).
A VS Code sidebar client for OpenCode, the AI coding agent. Prompt it, watch it work, review what it changed, and keep its sessions, permissions and background service in view.
Features
- Chat in the sidebar that reads and edits your code
- Open the same chat in an editor tab (
OpenCode 2: Open in Editor Tab) to maximize, split, or move it into its own window
- Interactive terminal (tabs, real PTY, owned by the service so it outlives the window) and a shell panel that can run a command on the host or inside the session
- Web search from the composer with
/web <query>, so answers can cite real sources
- Ask a side question with
/btw <question>: the answer opens in a dialog and never enters the transcript
- Tells you when a newer CLI is available, and can install it for you
- Finds and connects to the OpenCode background service, with optional auto start
- Streams replies, reasoning, tool calls, diffs and context compaction as they happen
- Slash commands, skills and
@ file mentions from the composer
- Inline permission approvals that show what an "always allow" will save, plus a saved-rules manager
- Sessions: search, rename, fork, delete, export and import
- Per session model and agent switching, queue follow-ups mid run, hand a long tool to the background
- Undo a turn with file restore, review diffs before they apply
- Worktrees, project instructions, session environment, MCP servers, providers and plugins in drawers, with plugin update checks
- Token, cost and context meters with optional auto compact, plus a collapsed service diagnostics section
- Optional companion server so the OC2 Companion Android app (a paid app: $2 on Google Play, plus a one-time $2 tablet-workspace unlock), a phone or a browser can reach the same OpenCode, with its own login and an option to keep running in the background with a tray icon
- Themes and density options
- Restores last session and reconnects after drops
Requirements
- VS Code 1.96+
- The OpenCode CLI installed locally as
opencode. You can install it from the command palette with OpenCode 2: Install CLI, or follow the OpenCode 2 install guide. Note that https://opencode.ai/docs is the older 1.x documentation and installs a different package (opencode-ai); this extension targets the 2.x CLI.
The extension checks at most once every four hours whether that CLI is current. When a newer release exists the header shows a CLI 2.0.x → 2.0.y pill with an update action; there is no separate update bar and no skip, so an available update stays visible until you take it. Run OpenCode 2: Check CLI Updates to check on demand, or turn the automatic check off with cli.checkForUpdates.
Set cli.autoUpdate if you would rather not be asked: the extension then updates the CLI as soon as it finds a newer release. Either way the update is the CLI's own (opencode upgrade), which picks both the package manager that actually owns your install (npm, pnpm, bun, yarn, vp, Homebrew, or the standalone installer) and the release itself, so the version in the pill is what we last saw published rather than a pin, and it comes from the same release channel the CLI reads. Updating the CLI restarts the background service for you when no sessions are running, so the new build is actually in use; if sessions are live it leaves the service alone and offers a Restart service button instead.
If you still have the pre-release opencode2 binary from the OpenCode 2 beta, it keeps working as a fallback and the update prompt will offer to move you to the released CLI.
Flatpak Linux users: install the CLI on the host, not in the sandbox. The extension reads the host's service registration through flatpak-spawn --host, so it normally needs no extra permission. If you would rather expose that directory to other tools as well, name your own app: flatpak override --user --filesystem=~/.local/state com.vscodium.codium (for VS Code itself, com.visualstudio.code; the id to use is the one in FLATPAK_ID).
The extension builds against @opencode/client 2.x. Newer or older service versions usually work. If something breaks after a CLI update, check the OpenCode 2 output channel and run OpenCode 2: Restart Background Service.
Getting started
- Open a workspace folder.
- Click the OpenCode icon in the activity bar.
- If no service is running, click Start OpenCode in the sidebar, or enable
server.autoStart.
- Type a prompt, or
/ for commands, @ to attach a file.
The ⋯ menu in the header is where the panels live, so nothing appears until you ask for it:
- session: copy the transcript, fork, compact now, run tools in the background, undo or redo a turn, discard a staged revert, export or import
- review: the inbox of queued follow-ups, working changes, the plan checklist
- workspace: instructions, worktrees, session environment, shell, terminal
- configure: models, providers, MCP servers, saved permissions
- appearance: theme presets, then usage, the companion panel and the tip jar
A prompt can start with /web <query> to search the web first and send the results with your request.
Commands
| Command |
Description |
OpenCode 2: Focus Sidebar |
Focus the OpenCode view |
OpenCode 2: Toggle Sidebar |
Open or close the sidebar |
OpenCode 2: New Session |
Create and select a fresh session |
OpenCode 2: Refresh |
Reconnect and resync |
OpenCode 2: Restart Background Service |
Force a new service connection |
OpenCode 2: Open Terminal |
Launch the CLI in a terminal |
OpenCode 2: Install CLI |
Install or update the CLI (npm, curl, brew) |
OpenCode 2: Check CLI Updates |
Compare the installed CLI with the released one |
OpenCode 2: Start Companion Server |
Open companion server settings for remote clients |
OpenCode 2: Remove Start-at-Login Item |
Delete the login item and its startup files |
Settings (opencode2.*)
Common settings. The full list is in the VS Code settings UI.
| Setting |
Default |
Description |
server.autoStart |
false |
Start a background service automatically when none is found |
server.mode |
own |
own starts a hidden service, discover finds a running one |
cli.checkForUpdates |
true |
Offer to update the CLI when a newer release exists |
cli.autoUpdate |
false |
Install newer CLI releases without asking (npm installs only) |
models.default |
opencode/big-pickle |
Default model for new sessions as providerID/modelID |
permissions.mode |
askFirst |
Ask first or auto allow |
ui.theme |
dark |
Sidebar theme preset |
sessions.autoTitle |
false |
Generate a title after the first completed turn |
agent.autoCompactThreshold |
0 |
Send a manual compact at this context percent, 0 disables |
server.listenEnabled |
false |
Host the companion server for remote clients |
server.listenGlobal |
false |
Keep the companion running (tray icon) after VS Code closes |
server.startAtLogin |
false |
Start the companion automatically when you log in |
Companion server
Optional and off by default. It serves the same OpenCode to remote clients (the Android app, a browser, Tailscale) behind one stable address with its own username and password, so you can chat, review sessions and use a terminal from your phone. Turn it on in the Mobile & Companion panel, where you set the bind address, port and auth and where every address your phone can reach is listed with a Copy button.
The Android client is OC2 Companion, a paid app: the phone features are included and the landscape tablet workspace is a one-time in-app purchase. It is in closed testing today, and the Mobile & Companion panel carries the link to join the test, or to get it once it is on Google Play. It is an independent project, not affiliated with or endorsed by Anomaly, the makers of OpenCode.
server.listenGlobal keeps it running (with a tray icon) after VS Code closes, and server.startAtLogin brings it up when you log in. Both are off by default.
Troubleshooting
OpenCode ships its own diagnostics for the shared background service. From a terminal:
opencode service status # is the daemon up, and on which URL
opencode api get /api/status # the API's own status answer, using service discovery and auth
opencode service restart # restart the daemon
opencode --version # the CLI build you are running
Logs are at ~/.local/share/opencode/log/opencode.log. Every line carries a run id, and role=server marks session, provider, permission and tool activity, which makes grep 'role=server' the fastest way to see what the service did.
Inside VS Code, the extension writes to its own OpenCode 2 output channel, and OpenCode 2: Restart Background Service (also in the header ⋯ menu) reconnects and starts a fresh service. When reporting a problem, include opencode --version and opencode service status.
Workspaces
New sessions use your open folder. The header shows the folder and git branch. Change session scope between this folder and all projects in the sessions drawer.
License
Free to use, including for commercial purposes. The source is not available. It is proprietary: copying, modification, redistribution, and reverse-engineering are reserved. The full terms ship in the LICENSE file bundled with the extension.