Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(cli): parse where output on Windows to prefer .cmd/.exe wrappers

Ivan921bfbbe3c25
diff --git a/src/shared/services/cliRuntime.ts b/src/shared/services/cliRuntime.ts
index 86da91a085..5cb2cda0f3 100644
--- a/src/shared/services/cliRuntime.ts
+++ b/src/shared/services/cliRuntime.ts
@@ -537,7 +537,16 @@ const locateCommand = async (command: string, env: Record<string, string | undef
if (isWindows()) {
const located = await runProcess("where", [command], { env, timeoutMs: 3000 });
if (located.ok && located.stdout) {
- return { installed: true, commandPath: command, reason: null };
+ // `where` may return multiple matches (e.g. `opencode` + `opencode.cmd`).
+ // npm global installs on Windows create both a Unix shell script (no extension)
+ // and a .cmd wrapper. We must prefer the Windows executable extension.
+ const lines = located.stdout
+ .split(/\r?\n/)
+ .map((l) => l.trim())
+ .filter(Boolean);
+ const winExt = /\.(cmd|exe|bat|com)$/i;
+ const preferred = lines.find((l) => winExt.test(l)) || lines[0];
+ return { installed: true, commandPath: preferred, reason: null };
}
return { installed: false, commandPath: null, reason: "not_found" };
}