fix(workspace): launch opencode/pi from the frontend on Windows#287
Merged
Conversation
ConPTY's CreateProcess only appends `.exe` when resolving a bare command name from PATH — it never tries `.cmd`/`.bat`. claude/codex ship native `.exe`s and resolved fine; opencode/pi install as npm shims (only a `.cmd`/`.ps1` exists, no `.exe`), so spawning them by bare name ENOENTed and the workspace never launched. Reported by a community user on Windows. Add `resolveLaunchCommand` (src/workspaces/win-command.ts): on win32, do the PATH × PATHEXT lookup ourselves — a native `.exe` is spawned directly, a `.cmd`/`.bat` shim is wrapped through `cmd.exe /d /c`. No-op off Windows. Wired into both node-pty spawn sites (interactive `persistent-session`, agent `probe`), where args are flags + a uuid so the shell wrap is injection-safe. Headless dispatch gets the same resolution for native-exe agents (claude/codex now work headless on win32 too), but `.cmd`-shim agents stay headless-unsupported on Windows: the task prompt is the trailing arg and routing it through cmd.exe would re-parse shell metacharacters (a real injection surface). That now fails with a clear, recorded reason instead of a silent ENOENT — interactive launch of those agents works. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CreateProcessonly appends.exewhen resolving a bare command name from PATH — it never tries.cmd/.bat.claude/codexship native.exes (resolved fine, which masked the bug);opencode/piinstall as npm shims (only a.cmd/.ps1exists, no.exe) → spawned by bare name they ENOENT and the workspace never launches. Community-reported on Windows.resolveLaunchCommand(src/workspaces/win-command.ts): on win32, do thePATH × PATHEXTlookup ourselves — native.exespawned directly,.cmd/.batshim wrapped throughcmd.exe /d /c. No-op off Windows.persistent-sessioninteractive,probeagent-detection), where args are flags + a uuid so the shell wrap is injection-safe..cmd-shim agents stay headless-unsupported on Windows — the task prompt is the trailing arg and routing it through cmd.exe would re-parse shell metacharacters (a real injection surface) — but now fail with a clear, recorded reason instead of a silent ENOENT.Test plan
npx tsc --noEmitcleanpnpm testpasses (1844)win-command.spec.ts— 10 cases, deterministically drives the win32 branch (exe direct / cmd wrap / exe-preferred-over-cmd / multi-PATH / PATHEXT fallback / passthrough)pnpm test:smoke) HARD checks passdev-smokeWindows job boots the guardian stack (tsx/pnpm shims), not workspace agent CLIs, so it neither caught this nor verifies the fix. The unit test verifies the resolution logic cross-platform but not real ConPTY spawn. Needs a manual check on a Windows box with opencode/pi installed. Follow-up option: add a realnode-ptyspawn assertion (temp.cmd) to the windows-latest matrix.Boundary touch
None — workspace launcher spawn plumbing only; no trading / auth / broker / migration surface.
🤖 Generated with Claude Code