opencode VS Code Extension
opencode is a powerful Visual Studio Code extension that connects to opencode server to provide AI-powered code assistance, explanations, and improvements. Get instant help with your code using state-of-the-art language models from various providers.

✨ Features
🤖 AI-Powered Code Assistance
- Code Explanation: Get detailed explanations of selected code blocks
- Bug Detection: Hunt for potential bugs and issues in your code
- Code Improvement: Receive suggestions for optimizing and improving code
- Time Complexity: Analyze the computational complexity of algorithms
🔌 Multi-Provider Support
- Flexible Providers: Support for OpenAI, Anthropic, Google, Cohere, and more
- Auto-Detection: Automatically discover and configure available providers
- Unified Model Selection: Choose from hundreds of models across all providers in one dropdown
- Smart Auto-Selection: Intelligent provider and model selection based on availability
- Mode Configuration: Use specialized modes for different coding tasks
💬 Interactive Chat Interface
- Sidebar Chat: Dedicated chat panel for ongoing conversations
- Interactive Model Selection: Click-to-select any model from any provider
- Real-time Model Switching: Instantly switch models with visual feedback
- Smart Model Management: Favorites, history, and intelligent sorting
- Rich Formatting: Markdown support for code blocks and formatting
- Conversation History: Maintain context across multiple interactions
- Performance Optimized: Virtual scrolling for 100+ models, instant search
- Accessibility: Full keyboard navigation and screen reader support
⚙️ Advanced Configuration
- Connection Testing: Built-in tools to test and validate connections
- Configuration Validation: Automatic validation with helpful recommendations
- Provider Discovery: Browse available providers and models
- Smart Defaults: Intelligent fallback to optimal configurations
🚀 Quick Start
Prerequisites
opencode Server: You need access to an opencode server. The default configuration expects a server running at http://127.0.0.1:4096
Provider Setup: Ensure your opencode server has at least one provider configured (OpenAI, Anthropic, etc.)
Installation
- Install the extension from the VS Code Marketplace or from a
.vsix
file
- Open VS Code and look for the opencode icon in the Activity Bar
- The extension will automatically validate your configuration on startup
Basic Usage
- Select Code: Highlight any code block in your editor
- Open Command Palette: Press
Cmd+Shift+P
(Mac) or Ctrl+Shift+P
(Windows/Linux)
- Choose Action: Select one of the opencode commands:
opencode: Explain selected codeblock
opencode: Find bugs in selected codeblock
opencode: Suggest improvements for selected codeblock
opencode: Time complexity for selected codeblock
- View Results: The response will appear in the opencode chat panel
🎛️ Interactive Model Selection
🎉 Fully Interactive Model Switching!
The extension features a powerful, interactive model selection system:
Unified Model Dropdown
- Click-to-Select: Simply click any model to switch instantly
- Cross-Provider: Choose from hundreds of models across all providers
- Visual Feedback: Immediate confirmation with notifications and animations
- Real-time Updates: Changes apply instantly to new conversations
Advanced Search & Filtering
- Instant Search: Type to filter models by name, provider, or capabilities
- Keyboard Shortcuts: Press
/
or Ctrl+F
to focus search
- Smart Filtering: Search across model names, providers, and descriptions
- Performance: Virtual scrolling handles 100+ models smoothly
Favorites & History
- Star Models: Click ⭐ to favorite frequently used models
- Recent Models: See 🕐 indicators for recently used models
- Smart Sorting: Favorites first, then recent, then alphabetical
- Filter View: Toggle "Favorites Only" mode for focused selection
Keyboard Navigation
- Full Accessibility: Complete keyboard support for all features
- Quick Actions: Use
1-9
keys for rapid selection of first 9 models
- Navigation: Arrow keys, Page Up/Down, Home/End for browsing
- Global Shortcut:
Ctrl+Shift+M
(Cmd+Shift+M) to toggle dropdown
Professional UX
- Smooth Transitions: Elegant animations and progress indicators
- Rich Tooltips: Detailed model information on hover
- Status Notifications: Toast messages for selection feedback
- Error Handling: Graceful fallbacks and clear error messages
⌨️ Keyboard Shortcuts
OpenCode includes powerful keyboard shortcuts for efficient model selection:
Model Selection
Shortcut |
Action |
Ctrl+Shift+M (Cmd+Shift+M) |
Toggle model dropdown |
↑ / ↓ |
Navigate up/down in model list |
Page Up / Page Down |
Jump by 10 models |
Home / End |
Jump to first/last model |
Enter / Space |
Select highlighted model |
Escape |
Close dropdown |
1 -9 |
Quick select first 9 models |
Search & Filter
Shortcut |
Action |
/ |
Focus search input |
Ctrl+F (Cmd+F) |
Focus search input |
Escape |
Clear search and close |
Chat Interface
Shortcut |
Action |
Ctrl+Enter (Cmd+Enter) |
Send message |
Shift+Enter |
New line in message |
⚙️ Configuration
Basic Settings
Configure opencode through VS Code settings (Cmd/Ctrl + ,
):
{
"opencode.endpoint": "http://127.0.0.1:4096",
"opencode.provider": "openai",
"opencode.model": "gpt-4",
"opencode.mode": "build",
"opencode.history": 5,
"opencode.systemPrompt": "You are a helpful coding assistant..."
}
Configuration Options
Setting |
Description |
Default |
opencode.endpoint |
opencode server URL |
http://127.0.0.1:4096 |
opencode.provider |
AI provider to use |
"" (auto-detect) |
opencode.model |
Specific model to use |
"" (auto-detect) |
opencode.mode |
opencode mode for specialized tasks |
"build" |
opencode.history |
Number of previous messages to include |
5 |
opencode.systemPrompt |
Custom system prompt for conversations |
Default assistant prompt |
opencode.autoSelectModel |
Automatically select best available model |
true |
opencode.showModelDetails |
Show detailed model information in tooltips |
true |
opencode.enableKeyboardShortcuts |
Enable keyboard shortcuts for model selection |
true |
opencode.maxHistoryItems |
Maximum number of models in history |
10 |
opencode.enableNotifications |
Show status notifications for model changes |
true |
💡 Note: provider
and model
settings are automatically updated when you select models through the interactive dropdown.
Auto-Detection & Interactive Model Selection
💡 New in v1.0.0: Fully Interactive Model Selection
The extension now features a complete interactive model selection system:
- Open Chat Panel: Click the opencode icon in the Activity Bar
- Click Model Dropdown: Interactive dropdown shows all available models
- Select Any Model: Click any model to switch instantly - no settings required
- Automatic Configuration: Your selection is automatically saved to VS Code settings
- Cross-Provider: Switch between any provider seamlessly
- Persistent: Selections survive VS Code restarts and sync across devices
Getting Started with Model Selection
- First Time: Extension auto-selects the best available model
- Switching Models: Click dropdown → click model → start chatting
- Favorites: Star frequently used models for quick access
- Search: Type to find specific models from 100+ options
- Keyboard: Use
Ctrl+Shift+M
for quick dropdown access
Advanced Features
- Model History: Recently used models appear at the top
- Smart Sorting: Favorites, recent, then alphabetical organization
- Performance: Virtual scrolling handles large model lists efficiently
- Accessibility: Full keyboard navigation and screen reader support
Traditional Configuration
If you leave provider
or model
empty, opencode will automatically:
- Discover available providers on your server
- Select the best available model from any provider
- Use intelligent defaults based on your server configuration
- Present all options in the unified model dropdown for manual selection
🛠️ Management Commands
opencode provides several commands for managing your setup:
Connection & Validation
opencode: Test Connection
: Test connectivity to your opencode server
opencode: Validate Configuration
: Check your current configuration for issues
opencode: Show Configuration Recommendations
: Get intelligent suggestions for optimal setup
opencode: Show Available Providers
: Browse all providers on your server
opencode: Show Available Models
: View all available AI models
opencode: Show Available Modes
: See specialized modes for different tasks
opencode: Show Current Configuration
: Display your current settings
Chat Management
opencode: Open Chat
: Open the interactive chat panel with model selection
opencode: Restart Chat
: Clear conversation history and start fresh
opencode: Refresh Models
: Reload available models from the server
opencode: Reset Favorites
: Clear all favorite model selections
opencode: Clear History
: Remove model selection history
🔧 Troubleshooting
Common Issues
❌ Connection Failed
Problem: Cannot connect to opencode server
Solutions:
- Verify opencode server is running:
curl http://127.0.0.1:4096/app
- Check firewall and network settings
- Confirm endpoint URL in settings
- Use
opencode: Test Connection
command
⚠️ No Providers Available
Problem: Server has no configured providers
Solutions:
- Configure at least one provider on your opencode server
- Check provider API keys and credentials
- Use
opencode: Show Available Providers
to verify setup
🔧 Configuration Issues
Problem: Invalid provider or model configuration
Solutions:
- Use
opencode: Validate Configuration
for detailed analysis
- Use
opencode: Show Configuration Recommendations
for suggestions
- Set provider/model to empty string for auto-detection
Advanced Troubleshooting
Check Server Status
# Test basic connectivity
curl http://127.0.0.1:4096/app
# List available providers
curl http://127.0.0.1:4096/config/providers
# List available modes
curl http://127.0.0.1:4096/mode
Reset Configuration
- Open VS Code settings
- Search for "opencode"
- Reset problematic settings to defaults
- Restart VS Code
- Use
opencode: Show Configuration Recommendations
Debug Mode
Enable debug logging by adding to your VS Code settings:
{
"opencode.debug": true
}
Getting Help
- Built-in Commands: Use validation and recommendation commands
- Status Display: Check the status bar in the chat window
- Error Messages: Read detailed error messages with suggested actions
- Server Logs: Check your OpenCode server logs for additional details
🎯 Best Practices
Optimal Configuration
- Use specific provider/model combinations for consistent results
- Configure appropriate history length for your use case
- Customize system prompts for specialized domains
Efficient Usage
- Select relevant code blocks for better context
- Use different modes for different types of tasks
- Restart chat periodically to clear context
- Test connection regularly if using remote servers
- Monitor provider usage and rate limits
- Use auto-detection for dynamic environments
📝 Examples
Basic Code Explanation
- Select this Python function:
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
- Run
OpenCode: Explain selected codeblock
- Get detailed explanation of the recursive Fibonacci implementation
Bug Detection
- Select problematic code
- Run
OpenCode: Find bugs in selected codeblock
- Receive analysis of potential issues and fixes
- Select an algorithm
- Run
OpenCode: Time complexity for selected codeblock
- Get Big-O notation analysis and optimization suggestions
🔄 Updates & Migration
This extension has been migrated from legacy systems to work with OpenCode servers instead of local installations. Key improvements include:
- Multi-provider support instead of single backend
- Enhanced error handling with actionable suggestions
- Real-time status indicators for connection and configuration
- Comprehensive validation tools for easier setup
- Rich UI enhancements for better user experience
📄 License
This project is licensed under the GPLv3 License with Commons Clause - see the LICENSE file for details.
Notable Mentions
- OpenCode
- Ollacode - This extension is inspired by Vincent van Dam's work on Ollacode