Skip to content

fix: resolve OpenCode CLI from VS Code - #20

Closed
chryzxc wants to merge 3 commits into
mainfrom
agent/fix-opencode-cli-path
Closed

fix: resolve OpenCode CLI from VS Code#20
chryzxc wants to merge 3 commits into
mainfrom
agent/fix-opencode-cli-path

Conversation

@chryzxc

@chryzxc chryzxc commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • honor a configurable opencode.cliPath
  • resolve the CLI through a login shell for GUI-launched VS Code
  • add standard user, Bun, and Homebrew fallback locations
  • add regression coverage for CLI discovery

Root cause

The extension host does not always inherit the interactive shell PATH. The resolver then fell back to spawning bare opencode, producing spawn opencode ENOENT.

Validation

  • typecheck
  • compatibility tests
  • extension compile

Fixes the reported spawn opencode ENOENT error.

Summary by CodeRabbit

  • New Features

    • Added an optional setting to specify the absolute path to the OpenCode CLI.
    • Improved CLI discovery across Windows, macOS, and Linux, including common installation locations.
    • Added support for finding the CLI when VS Code is launched from a graphical interface.
  • Tests

    • Added coverage for configured paths, shell-based discovery, and common installation locations.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b2e22384-58ff-4db2-a1a9-90a62506f930

📥 Commits

Reviewing files that changed from the base of the PR and between 38ba206 and e94b29b.

📒 Files selected for processing (3)
  • package.json
  • src/services/OpencodeServerManager.ts
  • tests/services/opencode-version-compatibility.test.mjs

📝 Walkthrough

Walkthrough

Adds an opencode.cliPath setting and expands OpencodeServerManager CLI discovery using configuration, platform-specific shell lookup, and executable fallback paths. A compatibility test verifies the source includes these resolution strategies.

Changes

OpenCode CLI path resolution

Layer / File(s) Summary
CLI path configuration and override
package.json, src/services/OpencodeServerManager.ts
Adds the optional opencode.cliPath setting and prioritizes its normalized value during binary resolution.
Shell and filesystem discovery
src/services/OpencodeServerManager.ts, tests/services/opencode-version-compatibility.test.mjs
Uses platform-specific command lookup, checks common executable locations, caches the result, and adds compatibility coverage for these strategies.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant VSCodeSettings
  participant OpencodeServerManager
  participant execFileSync
  participant FileSystem

  VSCodeSettings->>OpencodeServerManager: read opencode.cliPath
  alt configured path exists
    OpencodeServerManager->>OpencodeServerManager: normalize and cache configured path
  else no configured path
    OpencodeServerManager->>execFileSync: run where or command -v opencode
    execFileSync-->>OpencodeServerManager: return discovered path
    alt command lookup fails
      OpencodeServerManager->>FileSystem: check fallback executable locations
      FileSystem-->>OpencodeServerManager: return candidate or no match
    end
    OpencodeServerManager->>OpencodeServerManager: cache path or opencode
  end
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-opencode-cli-path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chryzxc chryzxc closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant