fix(windows): resolve and execute CLI shims safely - #655
Conversation
|
Reviewed on an isolated worktree at What I could verify, and didPowerShell 7.6.5 on Linux (no Windows here, so read these as evidence about PowerShell's parser, not about the Windows delivery path):
Blocking1. The 2. Please measure or narrow3. The stdin leg is untested, and it is the default commit-message path. 4. The argv case that motivates the whole design has no delivery test. The 5. CI has never run on this branch. Zero workflow runs on Small6. 7. Ordering#623 also rewrites this region of On #559This answers the decision that issue was held open for, for both consumers enes named. It does not close it yet: no Windows run on an npm ( |
b3d8eb4 to
2be60ce
Compare
|
Thanks for the detailed review. I rebased onto current The measurements changed the implementation rather than merely adding coverage:
Local Windows verification at
The first Windows gate run had one timeout in The ExecutionPolicy/GPO caveat no longer applies because the implementation no longer launches PowerShell. I left the non-blocking One gap remains explicit: this machine's installed Claude is the native |
|
Follow-up device validation completed: the end-to-end resume flow with an npm-installed Claude CLI passed on Windows. I have added that result to the PR testing notes. The fix remains published at |
|
Implementation complete at |
Summary
PATHEXT, usingF_OKinstead of the meaningless WindowsX_OKcheck.cmdshims through%SystemRoot%\System32\cmd.exe /d /s /v:off /cwithout enablingshell: truecmd.exeparses used by npm shims that forward%*, with delayed expansion disabled.bat,.ps1, CR/LF/NUL in argv, missingcmd.exe, and command lines above the conservative 8,100-character limit.cmdshim fixtures and include them in thequality-windowstest setWhy
Windows CLI discovery previously searched only for extensionless names. Tools installed as
claude.exe,gh.exe, or npm-generated.cmdshims were therefore invisible, so capability probes returned unknown values and agent nodes were created without a resumable session id.Resolving
PATHEXTfixes discovery, but Node cannot execute a.cmdfile directly.shell: truewould make prompts and other user-controlled arguments executable shell syntax. The first revision used npm's sibling.ps1shim; measuring its real$input | & node ...path on Windows PowerShell 5.1 showed that it corrupts Unicode and line endings on stdin. The implementation now invokes the.cmdshim through a hiddencmd.exe, escapes every argv element for both parser passes, disables delayed expansion, and leaves stdin connected directly to the child.The delivery tests cover empty arguments, spaces, quotes, trailing backslashes, backslashes before quotes,
&|<>()@^,%PATH%,!delayed!, Unicode, a shim path containing&and!, a hostile commit prompt, and byte-exact multiline Unicode stdin.Testing
Executed on Windows:
npm run typechecknpm run buildnpm run host:buildquality-windowsVitest command: 36 files passed, 552 tests passed, 7 skippedgit diff --checkThe first Windows gate run hit one timeout in
src/core/pty-session-host.test.ts; that test passed in isolation and the complete gate passed on the immediate repeat.GitHub Actions created CI and Security runs for commit
a7e70a26; both areaction_requiredand await maintainer approval. The Windows results above are local, not CI results.Surfaces
Fixes #559