IntelliJ + OpenCode Integration
Overview
You can integrate OpenCode into IntelliJ IDEA in two ways:
- OpenCode UI Plugin (Recommended): Provides a native chat interface, visual diff viewer for code changes, and one-click context sharing.
- Terminal CLI: Runs the raw command-line interface inside IntelliJ's built-in terminal.
Setup
1. Install OpenCode CLI (Required for both methods)
The plugin acts as a bridge to the CLI, so the CLI must be installed first.
npm install -g opencode
# OR for macOS
brew install opencode2. Authenticate
Authenticate the CLI once; the plugin will inherit this session.
opencode auth login https://ai.camer.digital/opencodeBrowser opens for authentication. Login, return to terminal, and select your model.
Method A: Using the OpenCode UI Plugin (Recommended)
This method offers superior integration, including visual code reviews, automatic file synchronization, and desktop notifications.
1. Install the Plugin
From JetBrains Marketplace:
- Open IntelliJ IDEA.
- Go to Settings → Plugins → Marketplace.
- Search for "OpenCode UI" (plugin ID:
opencode-ui). - Click Install and Restart IDE.
Direct link: OpenCode UI on JetBrains Marketplace
Manual Installation (if not found in Marketplace):
- Download the plugin from JetBrains Marketplace.
- In IntelliJ, go to Settings → Plugins → Gear icon → Install Plugin from Disk...
- Select the downloaded
.zipfile. - Click OK and Restart IDE.
⚠️ Plugin compatibility note
There is an older "OpenCode" plugin (plugin version 1.0.0, not "OpenCode UI") that bundles OpenCode v1.2.26, which is outdated compared to the current v1.17.8. This older plugin:
- Bundles OpenCode v1.2.26 (outdated vs current v1.17.8)
- Has limited IntelliJ compatibility:
2025.3 — 2025.3.6(does not support newer IntelliJ versions)- May conflict with custom
.well-known/opencodeendpointsSymptom: If your
.well-known/opencodeconfiguration returns a plugin list as arrays, you may see:plugin.3: Invalid input: expected string, received arrayThis error indicates the plugin expects string values but received arrays in the configuration.
Solution: Use the OpenCode UI plugin instead, which is compatible with modern OpenCode versions and handles
.well-known/opencodeconfiguration correctly. If you encounter this error with an older plugin, uninstall it and install OpenCode UI instead.
2. Launch and Connect
- Shortcut: Press
Ctrl+\(Windows/Linux) orCmd+Esc(macOS). - Dialog:
- Create New Session: Select this to let the plugin spawn a managed session (default port
4096). - Connect to Server: If you already have
opencode serverunning, enter127.0.0.1:4096.
- Create New Session: Select this to let the plugin spawn a managed session (default port
- The OpenCode chat window will appear in the tool window bar.
Keyboard shortcuts differ from VSCode. For VSCode shortcuts, see VSCode Integration.
3. How It Works
The UI plugin connects to the OpenCode CLI in one of two ways:
- Managed mode (default): The plugin spawns a background HTTP server (
opencode serve) on port4096and communicates via HTTP. This is transparent to you — just open the tool window and start chatting. - External server mode: You run
opencode servemanually and connect to it. Useful for debugging or when running multiple IDEs simultaneously.
The CLI handles all AI interactions. The plugin provides the visual layer (chat, diffs, notifications).
4. Key Plugin Features
- Context Sharing: Highlight code in the editor and press
Ctrl+Alt+K(Win/Linux) orCmd+Option+K(Mac) to instantly send it to the chat. - Visual Diff Review: When OpenCode edits files, a native diff window opens automatically. Click Accept to write changes and stage them in Git, or Reject to discard.
- Notifications: Enable OS notifications to be alerted when long tasks complete.
Method B: Using the IntelliJ Terminal (CLI)
Use this method if you prefer the raw TUI (Text User Interface) or need to run specific shell commands alongside the agent.
1. Open Terminal
- Shortcut:
Alt+F12(Windows/Linux) orOption+F12(macOS). - Navigate:
cd /path/to/project
2. Run OpenCode
opencodeThe interactive terminal UI will load directly in the pane.
3. Terminal Split Workflow
For advanced multitasking:
- Right-click the terminal tab.
- Select Split Right.
- Run
opencodein one pane and your build/test commands in the other.
Configuration
Editor Environment Variables
To allow OpenCode to open files in IntelliJ from the terminal, set the EDITOR variable in your shell profile.
macOS (zsh — default shell):
echo 'export EDITOR="idea --wait"' >> ~/.zshrc
source ~/.zshrcmacOS (bash):
echo 'export EDITOR="idea --wait"' >> ~/.bash_profile
source ~/.bash_profileLinux:
export EDITOR="/opt/idea/bin/idea.sh --wait"
# Or if installed via Snap:
# export EDITOR="idea --wait"
# Add to ~/.bashrc or ~/.zshrc for persistenceWindows (PowerShell):
$env:EDITOR = "idea64 --wait"
# Add to $PROFILE for persistence
Add-Content -Path $PROFILE -Value '$env:EDITOR = "idea64 --wait"'Plugin Settings (Method A Only)
If the plugin cannot find the CLI or uses a non-standard port:
- Go to Settings → Tools → OpenCode.
- OpenCode Command: Set path if not in system PATH (e.g.,
/usr/local/bin/opencode). - Server Port: Default is
4096. Change if running multiple instances. - Auto Start Server: Enable to launch the background service when IntelliJ starts.
Usage Comparison
| Feature | OpenCode UI Plugin | Terminal CLI |
|---|---|---|
| Interface | Native Chat Window | Text-based TUI |
| Code Diffs | Visual Side-by-Side (Accept/Reject buttons) | Text Unified Diff (Manual typing) |
| Context | One-Click (Cmd+Option+K) | Manual typing (@file) |
| File Sync | Automatic (Instant VFS refresh) | May require "Reload from Disk" |
| Multitasking | Runs in background/tool window | Tied to terminal tab |
| Best for | Most users, visual workflows | Power users, script integration |
Troubleshooting
Command not found (Plugin)
If the plugin says "OpenCode command not found":
- Verify installation:
opencode --versionin your system terminal. - In Plugin Settings, set the absolute path to the binary:
- macOS/Linux:
/usr/local/bin/opencodeor/opt/homebrew/bin/opencode - Windows:
C:\Users\<You>\AppData\Roaming\npm\opencode.cmd - npm global:
$(npm config get prefix)/bin/opencode
- macOS/Linux:
Connection Refused
- Ensure no other process is using port
4096. - Try restarting the session via the plugin dialog (
Ctrl+\/Cmd+Esc). - Check firewall settings if using external server mode.
Plugin Not Appearing in Tool Windows
- Verify plugin is installed: Settings → Plugins → Installed → search "OpenCode"
- Ensure plugin is enabled: checkbox next to plugin name
- Restart IntelliJ after installation
- Check View → Tool Windows → OpenCode to manually open it
Authentication Issues
- Verify endpoint URL in plugin settings:
https://ai.camer.digital/opencode - Try re-authenticating via CLI:
opencode auth login https://ai.camer.digital/opencode - Check browser pop-up blocker settings
- Ensure session hasn't expired (re-login if needed)