Summary
The companion currently spawns opencode, node, and which directly. On Windows, npm-global binaries are usually .cmd shims (opencode.cmd, node may be outside the minimal PATH, etc.), and Node's spawn() with shell: false does not resolve .cmd wrappers.
This is the OpenCode equivalent of several upstream Codex plugin Windows issues.
Local evidence
Affected paths include:
plugins/opencode/scripts/lib/process.mjs
resolveOpencodeBinary() uses spawn("which", ["opencode"])
getOpencodeVersion() uses spawn("opencode", ["--version"])
runCommand() uses spawn(cmd, args, ...) without Windows shim handling
spawnDetached() uses spawn(cmd, args, ...) for background node
plugins/opencode/scripts/lib/opencode-server.mjs
ensureServer() uses spawn("opencode", ["serve", ...])
Expected behavior
Setup and runtime commands should work on Windows when OpenCode was installed through npm or another shim-based installer.
Suggested fix
Add a shared spawn helper that handles Windows command resolution deliberately:
- Prefer direct executable resolution where possible (
where opencode on Windows, command -v/which elsewhere).
- For npm
.cmd shims, use shell: true or resolve the concrete .cmd path only where needed.
- Preserve UNC/network-drive behavior by avoiding blanket
shell: true for all git subprocesses.
- Add regression coverage around the command-building behavior.
Upstream references
Derived from these applicable upstream issues:
Summary
The companion currently spawns
opencode,node, andwhichdirectly. On Windows, npm-global binaries are usually.cmdshims (opencode.cmd,nodemay be outside the minimal PATH, etc.), and Node'sspawn()withshell: falsedoes not resolve.cmdwrappers.This is the OpenCode equivalent of several upstream Codex plugin Windows issues.
Local evidence
Affected paths include:
plugins/opencode/scripts/lib/process.mjsresolveOpencodeBinary()usesspawn("which", ["opencode"])getOpencodeVersion()usesspawn("opencode", ["--version"])runCommand()usesspawn(cmd, args, ...)without Windows shim handlingspawnDetached()usesspawn(cmd, args, ...)for backgroundnodeplugins/opencode/scripts/lib/opencode-server.mjsensureServer()usesspawn("opencode", ["serve", ...])Expected behavior
Setup and runtime commands should work on Windows when OpenCode was installed through npm or another shim-based installer.
Suggested fix
Add a shared spawn helper that handles Windows command resolution deliberately:
where opencodeon Windows,command -v/whichelsewhere)..cmdshims, useshell: trueor resolve the concrete.cmdpath only where needed.shell: truefor all git subprocesses.Upstream references
Derived from these applicable upstream issues:
/codex:setupreports npm and codex as "Missing" / "Not installed" on Windows (Claude Code + Git Bash) openai/codex-plugin-cc#17spawn codex ENOENT— missingshell: truein app-server.mjs openai/codex-plugin-cc#46