This guide provides step-by-step instructions for setting up cursor-opencode-auth on WSL2, with special considerations for corporate environments (Zscaler, proxies, etc.).
- WSL2 (Ubuntu or Debian recommended)
- A Cursor Pro subscription
- Basic familiarity with the terminal
Background: In WSL2 environments with corporate SSL inspection (e.g., Zscaler), IPv6 may be enabled at the kernel level but completely non-functional. Bun (which OpenCode is built on) and Node.js will resolve DNS to both IPv6 and IPv4 addresses but may only attempt IPv6 connections, which can black-hole and hang indefinitely.
Symptoms:
bun installhangs indefinitelyopencode runhangs on startupnpm installtakes extremely long or times out- Bridge server fails to start or connect
Check if this affects you:
# Check for Zscaler or corporate SSL inspection certificate
ls /etc/ssl/certs/ | grep -i zscaler
# Check if IPv6 is enabled
sysctl net.ipv6.conf.all.disable_ipv6
# If output is "0", IPv6 is enabledFix: Disable IPv6 in WSL2
# Add IPv6 disable rules to sysctl
echo 'net.ipv6.conf.all.disable_ipv6 = 1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.default.disable_ipv6 = 1' | sudo tee -a /etc/sysctl.conf
# Apply changes
sudo sysctl -p
# Verify
sysctl net.ipv6.conf.all.disable_ipv6
# Should output: net.ipv6.conf.all.disable_ipv6 = 1Important: Apply this fix before installing Bun or OpenCode to avoid initial setup issues.
curl https://cursor.com/install -fsS | bashRestart your shell or run:
exec $SHELLVerify installation:
cursor-agent --versioncursor-agent loginFollow the browser-based authentication flow. Verify you're logged in:
cursor-agent statuscurl -fsSL https://bun.sh/install | bashRestart your shell:
exec $SHELLVerify:
bun --versionNote: If
bun --versionhangs, you need to apply the IPv6 fix from the "Known Issues" section above.
bun install -g opencode-aiVerify:
opencode --versionImportant: If you have an older version installed via Homebrew/Linuxbrew (v0.x), remove it first:
brew uninstall opencode which opencode # Should be ~/.bun/bin/opencode opencode --version # Should be 1.x.x
Clone and build this repository:
# Choose a permanent location (NOT /tmp)
cd ~/projects # or your preferred location
git clone https://github.com/Infiland/cursor-opencode-auth.git
cd cursor-opencode-auth
# Build the project
npm install
npm --workspaces run buildCreate the plugin configuration file:
mkdir -p ~/.config/opencode/pluginsCreate ~/.config/opencode/plugins/cursor-opencode-auth.ts with the following content (adjust path to match your installation):
// Uses your local checkout instead of a cached npm install
export { CursorPlugin } from "/home/YOUR_USERNAME/projects/cursor-opencode-auth/packages/opencode-plugin-cursor/dist/index.js";Replace /home/YOUR_USERNAME/projects/ with your actual path from step 5.
Get available Cursor models:
cursor-agent --list-modelsCreate or update ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [],
"provider": {
"cursor": {
"npm": "@ai-sdk/openai-compatible",
"name": "Cursor",
"options": {
"baseURL": "http://127.0.0.1:8765/v1",
"apiKey": "unused"
},
"models": {
"auto": { "name": "Auto (Cursor Default)" },
"gpt-5.3-codex": { "name": "GPT-5.3 Codex" },
"gpt-5.2": { "name": "GPT-5.2" },
"gpt-5.2-codex": { "name": "GPT-5.2 Codex" },
"opus-4.6-thinking": { "name": "Claude 4.6 Opus (Thinking)" },
"sonnet-4.5-thinking": { "name": "Claude 4.5 Sonnet (Thinking)" },
"opus-4.6": { "name": "Claude 4.6 Opus" }
}
}
}
}Note: You can add more models from the
cursor-agent --list-modelsoutput.
Create ~/.local/bin/cursor-bridge:
mkdir -p ~/.local/bin
cat > ~/.local/bin/cursor-bridge << 'EOF'
#!/usr/bin/env node
// Cursor OpenAI Bridge Launcher
require('/home/YOUR_USERNAME/projects/cursor-opencode-auth/packages/cursor-openai-bridge/dist/cli.js');
EOF
chmod +x ~/.local/bin/cursor-bridgeReplace /home/YOUR_USERNAME/projects/ with your actual path.
Ensure ~/.local/bin is in your PATH:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrccursor-bridgeOr if you didn't create the launcher script:
node ~/projects/cursor-opencode-auth/packages/cursor-openai-bridge/dist/cli.jsThe bridge should start and listen on http://127.0.0.1:8765.
In another terminal:
curl http://127.0.0.1:8765/v1/modelsYou should see a JSON response with available models.
opencode run -m cursor/gpt-5.2 "say hello"opencode run -m cursor/gpt-5.2 "read the file ~/.config/opencode/opencode.json and tell me what's in it"This should successfully read the file and return its contents, demonstrating that tool calling works.
Cause: IPv6 networking issues (see "Known Issues" section)
Solution: Apply the IPv6 fix and restart the bridge
Cause: Another instance of the bridge or another service is using the port
Solution: Find and kill the process:
lsof -i :8765
kill -9 <PID>Or configure the bridge to use a different port via environment variable (update your opencode.json accordingly):
PORT=8766 cursor-bridgeCause: Command is being run from a non-interactive shell without a TTY
Solution: Run from a regular terminal session, not from a script or non-TTY environment
Cause: Cursor CLI is not authenticated
Solution: Run cursor-agent login and complete the authentication flow
Cause: Bridge is not running or OpenCode is not configured correctly
Solution:
- Verify bridge is running:
curl http://127.0.0.1:8765/v1/models - Check OpenCode config:
opencode debug config - Verify plugin is loaded correctly
Cause: Stale Homebrew/Linuxbrew installation taking precedence
Solution:
brew uninstall opencode
which opencode # Should be ~/.bun/bin/opencode
opencode --version # Should be 1.x.xCause: Script is not executable
Solution:
chmod +x ~/.local/bin/cursor-bridgeYou can customize the bridge behavior with environment variables:
# Change Cursor CLI mode (ask, plan, agent)
CURSOR_BRIDGE_MODE=agent cursor-bridge
# Set workspace directory
CURSOR_BRIDGE_WORKSPACE=/path/to/project cursor-bridge
# Force mode even if model suggests otherwise
CURSOR_BRIDGE_FORCE=true cursor-bridge
# Auto-approve MCPs (use with caution)
CURSOR_BRIDGE_APPROVE_MCPS=true cursor-bridge
# Disable strict model checking
CURSOR_BRIDGE_STRICT_MODEL=false cursor-bridgeFor production use, consider creating a systemd service:
sudo tee /etc/systemd/system/cursor-bridge.service << EOF
[Unit]
Description=Cursor OpenAI Bridge
After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=$HOME
ExecStart=$HOME/.local/bin/cursor-bridge
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable cursor-bridge
sudo systemctl start cursor-bridgeEnable debug logging for troubleshooting:
# OpenCode debug logs
opencode --print-logs --log-level DEBUG
# Check OpenCode log directory
ls -lh ~/.local/share/opencode/log/If you previously used yet-another-opencode-cursor-auth:
| Feature | yet-another-opencode-cursor-auth | cursor-opencode-auth (this repo) |
|---|---|---|
| Tool Calling | ✅ Yes (direct API) | ✅ Yes (via bridge) |
| Method | Direct Cursor API | Cursor CLI wrapper |
| Auth | OAuth flow | cursor-agent login |
| Models | Limited | All Cursor CLI models |
| Modes | N/A | ask/plan/agent |
| Setup | OAuth only | Install + configure |
- The bridge runs locally and does not expose your credentials to the network
- Cursor CLI can read your repository - treat it as trusted code execution
- Configure permissions in
~/.cursor/cli-config.jsonor<project>/.cursor/cli.jsonto restrict Cursor CLI capabilities - See
docs/SECURITY.mdfor detailed security considerations
If you encounter issues not covered in this guide:
- Check the main README.md and docs/USAGE.md
- Review docs/SECURITY.md for safety considerations
- Open an issue on the GitHub repository
Found an issue with this guide or have suggestions for improvements? Please open a pull request or issue on GitHub.