Short description
Windows: isInstalled() always returns false even when OpenCode is on PATH
What happened?
On Windows, running npx @cortexkit/magic-context@latest setup --harness opencode reports "OpenCode host not found on PATH" even when OpenCode is correctly installed and discoverable via where.exe opencode.
Root cause: isInstalled() in packages/cli/src/adapters/opencode.ts uses two detection strategies, both of which fail on Windows:
process.env.HOME — typically undefined on Windows (should use os.homedir() or USERPROFILE)
execSync("command -v opencode") — this is a Bash built-in that does not exist in PowerShell/CMD, so it always throws, causing isInstalled() to return false unconditionally on Windows.
Expected behavior: OpenCode is detected correctly on Windows, e.g. by falling back to where.exe opencode or using execSync("where opencode") when process.platform === "win32".
Steps to reproduce:
- Install OpenCode on Windows so it is available on PATH (e.g. via bun —
C:\Users\<user>\.bun\bin\opencode.exe)
- Confirm with
where.exe opencode — returns the correct path
- Run
npx @cortexkit/magic-context@latest setup --harness opencode
- Setup reports: "OpenCode host not found on PATH. Install OpenCode: curl -fsSL https://opencode.ai/install | bash."
Suggested fix:
isInstalled(): boolean {
if (existsSync(join(homedir(), ".opencode", "bin", "opencode"))) return true;
const cmd = process.platform === "win32" ? "where opencode" : "command -v opencode";
try {
execSync(cmd, { stdio: "ignore" });
return true;
} catch {
return false;
}
}
Diagnostics
Plugin version
No response
OpenCode version
No response
Platform
Windows x64
Client
OpenCode TUI (CLI)
Log output (optional)
Short description
Windows:
isInstalled()always returns false even when OpenCode is on PATHWhat happened?
On Windows, running
npx @cortexkit/magic-context@latest setup --harness opencodereports "OpenCode host not found on PATH" even when OpenCode is correctly installed and discoverable viawhere.exe opencode.Root cause:
isInstalled()inpackages/cli/src/adapters/opencode.tsuses two detection strategies, both of which fail on Windows:process.env.HOME— typically undefined on Windows (should useos.homedir()orUSERPROFILE)execSync("command -v opencode")— this is a Bash built-in that does not exist in PowerShell/CMD, so it always throws, causingisInstalled()to returnfalseunconditionally on Windows.Expected behavior: OpenCode is detected correctly on Windows, e.g. by falling back to
where.exe opencodeor usingexecSync("where opencode")whenprocess.platform === "win32".Steps to reproduce:
C:\Users\<user>\.bun\bin\opencode.exe)where.exe opencode— returns the correct pathnpx @cortexkit/magic-context@latest setup --harness opencodeSuggested fix:
Diagnostics
Plugin version
No response
OpenCode version
No response
Platform
Windows x64
Client
OpenCode TUI (CLI)
Log output (optional)