Opencode V2
A Visual Studio Code extension that integrates opencode V2 directly into your development workflow.
Prerequisites
This extension requires the opencode CLI (V2) to be installed on your system. Visit opencode.ai for installation instructions.
Features
- Quick Launch: Use
Cmd+Esc (Mac) or Ctrl+Esc (Windows/Linux) to open opencode in a split terminal view, or focus an existing terminal session if one is already running.
- New Session: Use
Cmd+Shift+Esc (Mac) or Ctrl+Shift+Esc (Windows/Linux) to start a new opencode terminal session, even if one is already open. You can also click the opencode button in the editor title bar.
- Context Awareness: Automatically share your current selection or tab with opencode.
- File Reference Shortcuts: Use
Cmd+Option+K (Mac) or Ctrl+Alt+K (Linux/Windows) to insert file references. For example, @File#L37-42.
How it works (V2)
Opencode V2 uses a client-server architecture: the TUI connects to one shared background service instead of starting a server per terminal. This extension opens the TUI in a VS Code terminal and types @file references into it — no local ports or passwords to manage. If you point the extension at an explicit password-protected server, set the credentials via the opencode.terminalEnv setting.
Extension Settings
opencode.command: opencode binary to run (default: opencode).
opencode.serverUrl: explicit server URL, e.g. http://127.0.0.1:4096. Empty means use the shared background service (recommended).
opencode.extraArgs: extra args appended to the TUI command.
opencode.terminalEnv: extra env for the terminal, e.g. {"OPENCODE_SERVER_PASSWORD": "..."}.
opencode.attachDelayMs: delay before typing file context into a new terminal (default: 600).
Support
This is an early release. If you encounter issues or have feedback, please create an issue.
Known issue on Windows: pasting freezes the TUI
Copying into the OpenCode TUI can freeze the whole TUI on Windows: the screen stops repainting, mouse clicks stop working and nothing shows up in the prompt. It happens with Ctrl+V, with Ctrl+Shift+V and with right-click, so both terminal bracketed paste and the TUI's own paste handler are affected. mouse is not the cause — leave it at the default true, otherwise session tab clicks, the sidebar, the diff file tree and the wheel stop responding too.
Paste with Ctrl+Alt+V — Opencode V2: Paste clipboard. The extension reads the clipboard in the extension host and types the text into the TUI with sendText, so no clipboard read happens inside the TUI and no bracketed paste is involved. Newlines become spaces, because a raw newline is Enter in a terminal. While the opencode terminal is focused, Ctrl+V and Ctrl+Shift+V run the same command, so the usual shortcuts keep working without touching the broken paste paths.
If the terminal does freeze: run Opencode V2: Restart opencode terminal (Ctrl+Alt+Shift+O). The TUI is only a client, so the session survives on the OpenCode background service and is still there after the restart. The extension also shows a one-time informational notice per version; run Opencode V2: Mouse input & paste notice to show it again.
If you want the terminal's own paste behavior back once OpenCode fixes the freeze, disable the command's Ctrl+V / Ctrl+Shift+V keybindings in Keyboard Shortcuts (search for opencode.pasteClipboard).
Development
- Open the
vscode-extension directory in VS Code (do not open from the repo root).
npm install — install dependencies.
- Press
F5 to start debugging — this launches a new VS Code window with the extension loaded.
npm run compile — type-check and bundle to dist/; node scripts/make-icons.mjs regenerates the marketplace icon.