Skip to content

fix(transport): launch npm shims directly so quoted arguments work - #313

Merged
maxthomas95 merged 2 commits into
mainfrom
fix/shim-quotes-20261109
Nov 10, 2026
Merged

maxthomas95 merged 2 commits into
mainfrom
fix/shim-quotes-20261109

Conversation

@maxthomas95

Copy link
Copy Markdown
Owner

Summary

Review item 5.2 (docs/REVIEW_2026-11-09.md).

On Windows a .cmd shim was launched through cmd.exe, and the argument escaper rejects any double quote because cmd.exe cannot carry one safely. Codex and OpenCode are npm shims, so an initial prompt or a Helm brief containing " failed to spawn.

  • Resolve through the shim. win-binary-resolver.ts reads an npm cmd-shim and returns a direct plan: node plus the script for a Node bin (a node.exe beside the shim wins, as in the shim itself), or the target when it is an .exe. Arguments then reach the program as argv with no shell in between.
  • Fallback unchanged. Anything not recognised with certainty keeps today's cmd.exe path: an unreadable file, another wrapper's format, more than one candidate line, a missing target, a .bat, or node not on PATH. The resolver never throws.
  • Clearer rejection. The quote rejection on the remaining shell path now says what to do.
  • local-transport.ts and coder-transport.ts place the plan's leading arguments before the user's.

Checked against the shims installed on this machine: codex and opencode resolve to node.exe plus their script; claude.exe was already direct; npm.cmd, a different wrapper, stays on the shell path.

Test plan

  • npx tsc --noEmit
  • npx eslint src/main/transport src/shared/shell-quote.ts
  • npx vitest run src/main/transport src/shared — 200 passed, 5 skipped
  • Manual: start a Codex session with an initial prompt containing a double quote and & — it launches and the prompt arrives intact
  • Manual: a Helm child with a quoted brief launches for a Codex child
  • Manual: Codex and OpenCode sessions start, resize, stop and resume as before

Out of scope

  • Wrappers other than npm's cmd-shim (pnpm, Volta, Scoop). They keep the shell path.

🤖 Generated with Claude Code

maxthomas95 and others added 2 commits November 9, 2026 20:55
On Windows a .cmd shim was launched through cmd.exe, and the argument
escaper rejects any double quote because cmd.exe cannot carry one
safely. Codex and OpenCode are npm shims, so an initial prompt or a Helm
brief containing a double quote failed to spawn.

The resolver now reads an npm cmd-shim and launches what it points at:
node plus the script for a Node bin (using a node.exe beside the shim
when there is one, as the shim itself does), or the target itself when
it is an .exe. The arguments then reach the program as argv, with no
shell in between. Anything the resolver does not recognise with
certainty - an unreadable file, another wrapper's format, more than one
candidate line, a missing target, a .bat, node not on PATH - keeps the
existing cmd.exe path unchanged, including the quote rejection, whose
message now says what to do.

Checked against the shims installed on this machine: codex and opencode
resolve to node.exe plus their script; claude.exe was already direct;
npm.cmd, a different wrapper, stays on the shell path.

Tests: resolver cases through injected file seams (Node shim with and
without a sibling node.exe, native target, unrecognised wrapper, missing
target, .bat, node missing), and a local transport case proving a prompt
with a double quote and an ampersand reaches the PTY as one unmodified
argument without cmd.exe.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@maxthomas95
maxthomas95 merged commit d876548 into main Nov 10, 2026
10 checks passed
@maxthomas95
maxthomas95 deleted the fix/shim-quotes-20261109 branch November 10, 2026 03:10
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant