OpenCode to VSCode Bridge
Author: Vlado Vrbanec — vlado.vrbanec@mvv.hr Purpose: Agent awareness of the user's visual working environment. The AI agent can see which tabs are open, cursor position, selection range, dirty (unsaved) state per file, and manipulate the editor directly. This lets the agent reason about what the user sees and work contextually within their editor. 🔧 From version 0.0.9, the bridge provides full active debugger control via VSCode's Debug Adapter Protocol (DAP). The agent can start and stop debug sessions, set breakpoints, step through code, inspect variables at runtime, evaluate expressions in the current execution context, and read program output — all through 23 dedicated debug tools. Instead of passively reasoning about bugs from source code alone, the agent can now observe the program's actual runtime state: variable values, call stacks, thread status, and live output. This transforms debugging from static analysis into an interactive diagnostic loop where the agent correlates source code with real execution behavior, dramatically improving its ability to identify root causes. Works in terminal or GUI client applications. Also works with any VSCode sidebar extension, or HTTP connected application. Agent can call 21 base MCP tools + 23 debug + 9 LSP + 3 Decorate tools (all loaded on demand) + 15 slash commands. Plugin supports up to 5 open VSCode sessions simultaneously, with automatic switching when changing sessions. Bridge is pure Node.js — likely works on macOS and Linux, but only tested on Windows. Components
Terminal or TUI Electron app ?
Architecture
Base MCP tools (always loaded — 21)
Debug MCP tools (loaded on demand via
|
| Capability | Tools |
|---|---|
| Session management | debug_configurations, debug_prerequisites, debug_build, debug_start, debug_stop |
| Execution control | debug_continue, debug_pause, debug_step_over, debug_step_into, debug_step_out |
| Breakpoints | debug_breakpoints (add/remove/list/listActive), debug_exceptions (first-chance/unhandled) |
| State inspection | debug_state, debug_overview, debug_session, debug_where, debug_thread_list, debug_callstack |
| Variables | debug_variables, debug_evaluate, debug_console_write, debug_set_variable |
| Output | debug_console (buffered, incremental), output_read, output_list |
Debug workflow
debug_prerequisites— check environment readiness (SDK, launch.json, project files)debug_build— build the project (uses tasks.json or falls back todotnet build)debug_start— start a debug session from launch.json config- Poll
debug_state(withcompact:true) untilstopped:true debug_where— see file, line, and source around the stop locationdebug_variables/debug_evaluate— inspect variables and expressionsdebug_continue/debug_step_over— advance execution, then poll again
ℹ️ After debug_continue or step commands, the agent polls debug_state until stopped:true — execution is asynchronous.
ℹ️ When debugging a GUI/EXE application, the agent cannot click buttons in the app window. It tells the user explicitly what to do, then polls for breakpoints or output.
Language Server Protocol (LSP)
The bridge exposes VSCode's Language Server infrastructure to the agent — semantic code analysis without running the program. The agent calls tool_topic("lsp") once to load the LSP tools.
| Capability | Tool | Description |
|---|---|---|
| Live diagnostics | lsp_diagnostics(file) |
Errors, warnings, hints from the Language Server for a file |
| Go to definition | lsp_definition(file, line, column) |
Where a symbol is declared |
| Find references | lsp_references(file, line, column) |
All usages of a symbol (AST-level, not text match) |
| Type info | lsp_hover(file, line, column) |
Type signature, documentation, parameters |
| Rename | lsp_rename(file, line, column, newName) |
Safe rename across the entire workspace |
| Document symbols | lsp_document_symbols(file) |
Hierarchical symbol tree (classes, functions, variables) |
| Completions | lsp_completion(file, line, column) |
Autocomplete suggestions at a position |
| Code actions | lsp_code_actions(file, startLine, endLine) |
List quick fixes and refactorings for a range |
| Apply code action | lsp_apply_code_action(file, index, startLine, endLine) |
Apply a code action by index (undoable) |
How LSP works in the bridge
Agent ──MCP──→ Plugin ──HTTP──→ Extension ──VSCode API──→ VSCode ──LSP/JSON-RPC──→ Language Server
The agent calls an LSP MCP tool (e.g. lsp_definition). The plugin forwards it via HTTP to the extension. The extension calls vscode.commands.executeCommand(...) with the target file URI and position. VSCode internally routes the request to the appropriate Language Server (tsserver, OmniSharp, Pylance, etc.) via LSP/JSON-RPC over stdio. The result travels back up the chain. The agent never communicates with the Language Server directly — only VSCode does.
ℹ️ LSP requires a VSCode extension for the language (TypeScript, C#, Python, etc.) — the bridge uses whatever Language Server is already active in VSCode.
ℹ️ lsp_diagnostics returns live errors from the Language Server — different from build/compile errors. Use it before debugging to catch type and syntax issues early.
Visual Decorations
The bridge lets the agent paint visual markers in the editor without changing file content. Unlike edit highlights (which auto-dismiss and are tied to edits), these decorations persist until explicitly cleared.
| Tool | What it does |
|---|---|
decorate_range(file, startLine, endLine, color?, tooltip?) |
Paint a colored background on a range of lines |
decorate_gutter(file, line, color?, tooltip?) |
Add a colored dot in the line-number gutter |
decorate_clear(file?) |
Remove all decorations from a file (omit file to clear all) |
Available colors: red, green, blue, yellow, purple, orange, cyan, pink, gray — or any CSS rgba/hsl/hex string.
ℹ️ The agent calls tool_topic("decorate") once to load these tools. Decorations survive editor tab switches and do NOT auto-dismiss.
Slash commands (from version 0.0.3)
User-facing shortcuts. Type /vsc........ in the OpenCode chat to run an editor-aware task. Registered by the plugin at startup — no configuration needed.
| Command | What it does |
|---|
| /vsc | Signal the agent that the rest of the conversation relates to working with the VSCode editor |
| /vscDebugTab | Debug the file open in the active VSCode editor tab |
| /vscDebugSelection | Debug the code currently selected in the VSCode active editor |
| /vscReviewTab | Code review of the file open in the active VSCode editor tab |
| /vscReviewSelection | Code review of the selected code in the VSCode active editor |
| /vscExplainTab | Explain what the file open in the active VSCode editor tab does |
| /vscExplainSelection | Explain the code currently selected in the VSCode active editor |
| /vscExplainProject | Explain current project and show prompt to save explanation to a file |
| /vscFindUsages | Find all usages of the selected function/class/variable across the workspace |
| /vscRefactorSelection | Refactor the selected code in the VSCode active editor |
| /vscDocTab | Add documentation comments to the file open in the active VSCode editor tab |
| /vscDocSelection | Add documentation comments to the selected code in the VSCode active editor |
| /vscMapToContext | Map the project structure and key files for context |
| /vscTranslateSelectionToEN | Translate the selected text in the VSCode active editor to English |
| /vscTranslateTabToEN | Translate the entire file content in the VSCode active editor to English |
Definitions: inject/vsc-commands.json. Always loaded — no configuration needed.
Quick Install
ℹ️ If not installed from side panel:
Install from marketplace.
OpenCode to VSCode Bridge — VS Code Marketplace
OpenCode plugin setup (required)
The OpenCode plugin is automatically installed when you start the VSCode extension.
⚡ If OPENCODE is installed after extension, please reinstall VSCode extension.
Usage
When component is installed, start or restart opencode.
The plugin automatically connects to the VSCode bridge when you open a workspace folder.
Ask the agent a few questions:
ℹ️ Doesn't need to be exact, agent will understand the context.
⚡ If agent is not aware of available tools, execute /vsc command to set editor context.
ℹ️ Instructions to the agent can be in any language, not just English; however, the agent will pick up context at the beginning of the session in English faster.
Agent will probably 'think' in English but will understand your language, and answer in your language.
⚡ If the agent doesn't immediately respond to editor context, start with "vsc" — it's a trigger word that anchors the conversation to the editor.
- Which file is opened in editor?
- What is the current cursor position?
- What is the current selection?
- What is the current line number?
- What is the current column number?
- What is the selected text?
- Please debug file opened in editor.
- ... and other questions
When the AI agent knows the context, we can ask without specifying the file name:
- Check file for errors.
- Insert "This text" at cursor position.
- Please create comment for function MyExampleFunction.
- Please check selected lines for errors.
- Translate selected text to Italian
And other instructions in natural language.
Agent will automatically try to obey instructions. With time you will learn which instructions are more clear to the agent.
⚡If VSCode extension is not active, or used folder is not the same, agent will respond with an predefined error message.
Status Bar
The extension adds a status bar indicator at the bottom-right of VSCode:
Mouse over icon will display info about last Opencode connection: 
| Indicator | Meaning |
|---|---|
$(broadcast) OCB |
Bridge starting (no port yet) |
$(broadcast) OCB: <port> |
Bridge active, listening on port |
$(check) OCB: <port> |
Bridge active, connected to Opencode session |
$(error) OCB |
Bridge failed to start |
Click on the status bar item to open the Actions Menu:
| Action | What it does |
|---|---|
$(terminal) Open Terminal |
Creates integrated terminal in workspace folder and runs opencode |
$(lines) Clear all highlights |
When lines are changed or inserted by agent via tool line is highlighted. |
| Highlight can be cleared one by one or all with this menu option. | |
$(gear) Reset Settings to Defaults |
Restore default timeout and highlight values. |
$(info) About |
Opens extension README |
Configuration
Settings are available in VSCode Settings UI (Ctrl+, → search "OpenCode Bridge") or settings.json.
| Setting | Default | Description |
|---|---|---|
opencodeBridge.highlightSafetyMs |
600000 (10 min) |
Auto-dismiss edit highlights after this many ms. Default is almost always functional — lower only if you want highlights to disappear faster. |
opencodeBridge.httpTimeoutMs |
5000 (5 s) |
HTTP request timeout for plugin-to-extension calls. Default is almost always functional — increase only on very slow machines or with very large files. |
opencodeBridge.scanTimeoutMs |
3000 (3 s) |
Port scan timeout for bridge discovery. Default is almost always functional — increase only if discovery is unreliable on slow networks. |
To reset all settings to defaults: open the Actions Menu (click the status bar item) and choose Reset Settings to Defaults, or run command OpenCode Bridge: Reset Settings to Defaults from the Command Palette.
Changes take effect on the next OpenCode session (plugin reads config on startup).
Notes
- Each OpenCode instance automatically pairs with VSCode running in the same workspace.