OpenCode Connector for VS Code
Bridge the gap between your favorite editor and your favorite AI assistant.
OpenCode is fantastic as a standalone TUI (Terminal User Interface). It's powerful, agentic, and works with any editor. But if you spend your day in VS Code, constantly switching contexts or copy-pasting code snippets breaks your flow.
This extension integrates the OpenCode TUI directly into your VS Code workflow.

Why use this extension?
You shouldn't have to choose between a great editor (VS Code) and a great AI agent (OpenCode). This connector gives you the best of both worlds:
Context Awareness: The TUI automatically "knows" what file you are working on. The extension sends your active file, selection, and diagnostics to the OpenCode context.
- No more copy-pasting code blocks.
- No more manually typing file paths.
Seamless Process Management:
- Auto-Discovery: The extension automatically finds running OpenCode instances serving your current workspace.
- Auto-Spawn: If no instance is running, it spawns one for you in the integrated terminal.
- One command to rule them all.
Features
Opencode: Add File to Prompt: Instantly send the current file reference (e.g., @src/main.ts#L10-L20) to the running TUI session.
- Automatic Context Sync: Keeps the AI informed of your active document, selection, and diagnostics.
- Integrated Terminal: Runs the OpenCode TUI directly within VS Code's terminal panel.
Usage
- Open your project in VS Code.
- The extension will find or spawn an OpenCode TUI session.
- Use
Opencode: Add File to Prompt to reference your current code in the TUI.
- Use
Explain and Fix (OpenCode) to quick fix your issue.
Configuration
You can customize the extension behavior through the following VS Code settings:
opencode.port: The port used to connect to the OpenCode server. (Default: 4096)
opencode.binaryPath: Absolute path to the OpenCode executable. Leave empty to use the one available in your system PATH.
opencode.codeAction.severityLevels: An array of diagnostic severity levels (error, warning, information, hint) that should trigger the "Explain and Fix" code action. (Default: ["error", "warning", "information", "hint"])
Requirements
- VS Code 1.94.0 or higher
- OpenCode installed and available in your PATH (or configured via
opencode.binaryPath)
Running OpenCode
For the extension to detect your OpenCode instance, it must be running in server mode with a port specified:
opencode --port 4096
The extension will automatically:
- Discover running OpenCode instances by scanning for processes with
--port
- Match instances to your current workspace directory
- Connect to the correct instance automatically
If no running instance is found for your workspace, the extension will spawn one automatically in the integrated terminal.
Manual Start
If you want to start OpenCode manually:
# Terminal 1
opencode --port 4096
Then use VS Code as normal - the extension will detect and connect to it.
Credits
This extension is inspired by: