Skip to content

fix: resolve opencode via shutil.which and pipe prompts through stdin on Windows - #737

Open
dopamine-pixels wants to merge 1 commit into
peteromallet:mainfrom
dopamine-pixels:fix/windows-npm-shim-opencode-runner
Open

fix: resolve opencode via shutil.which and pipe prompts through stdin on Windows#737
dopamine-pixels wants to merge 1 commit into
peteromallet:mainfrom
dopamine-pixels:fix/windows-npm-shim-opencode-runner

Conversation

@dopamine-pixels

Copy link
Copy Markdown

Problem

desloppify review --run-batches --runner opencode fails on Windows when opencode is npm-installed. The runner invokes the bare name opencode, which CreateProcess cannot resolve for the npm .cmd shim — every batch exits 127 with [WinError 2] The system cannot find the file specified, and the run reports "Runner CLI not found on PATH" even though opencode is on PATH.

Fix

Mirror the existing codex runner handling:

  • Resolve the executable with shutil.which and, on Windows, wrap .cmd/.bat shims in cmd /c.
  • Because cmd.exe re-parses argv and mangles prompts containing quotes or angle brackets, the prompt is sent via stdin whenever the cmd /c wrapper is used (the
    un_batch_attempt plumbing already supported stdin). .exe binaries and non-Windows platforms keep argv prompt passing.

Verification

  • Verified against a real project on Windows 11: batch prompts now execute and return JSON payloads (opencode run --format json NDJSON stream extracted and persisted).
  • Added 4 unit tests (shim wrap + stdin, direct exe, non-Windows argv, stdin plumbing through
    un_opencode_batch).
  • pytest desloppify/tests/commands/review/test_review_runner_helpers_direct.py — 14 passed.
  • Full suite: failure set identical to base commit (31 pre-existing Windows-environment failures, no regressions).

… on Windows

The opencode batch runner invoked the bare name 'opencode', which
CreateProcess cannot resolve for npm-installed .cmd shims on Windows
(WinError 2, exit 127). Mirror the codex runner: resolve the executable
with shutil.which, wrap .cmd/.bat shims in 'cmd /c', and send the prompt
via stdin instead of argv when the wrapper is used (cmd.exe re-parses
argv and mangles prompts containing quotes or angle brackets).
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