Windows: OpenCode plugin loses OCR stdout because runOcr spawns the npm .cmd shim detached
OpenCodeReview Version
open-code-review v1.12.10 (579b931) windows/amd64
built at: 2026-09-28T07:36:20ZOperating System
Windows (Windows 11)
Installation Method
npm (global) — npm install -g @alibaba-group/open-code-review
LLM Provider
Other OpenAI-compatible endpoint (not relevant: the failure happens before any LLM call)
Environment
- OpenCode Desktop 2.0.18 (V2 plugin API, Bun runtime)
- Plugin loaded from
plugins/open-code-review/opencode/open-code-review.ts(currentmain, blobbc5fd2b7) - Runtime deps installed per the README:
@opencode-ai/plugin+@opencode/plugin
Bug Description
On Windows, the OpenCode plugin returns no output from the OCR child process.
ocr_health reports only:
LLM connection check failed: OpenCodeReview exited with code 1.with no version line at all, even though ocr version works fine in a terminal:
open-code-review v1.12.10 (579b931) windows/amd64ocr_review behaves the same way — e.g. ocr_review({ preview: true }) returns a generic OpenCodeReview exited with code 1. instead of the real OCR message.
The child process clearly runs (exit codes propagate correctly), but its stdout/stderr are never captured by the plugin.
Root cause
runOcr spawns the ocr command with (plugins/open-code-review/opencode/open-code-review.ts, around line 169–183):
const child = spawn(
invocation.command, // "ocr"
[...invocation.prefixArgs, ...args],
{
cwd: options.cwd,
env: process.env,
shell: false,
detached: true,
},
)On Windows, ocr resolves to npm's ocr.cmd shim. Spawning that shim with detached: true makes the OpenCode runtime (Bun) drop the child's stdio, so no output is captured. Exit codes still propagate, which is why the error surfaces as "exited with code 1" with an empty stdout/stderr.
This is exactly the Windows caveat called out in #702 ("detached: true behaves differently on Windows and introduces new compatibility problems") that PR #728 / commit 927b710d later added.
Note: shell: true is not a safe fix here. buildReviewArgs passes the working directory as --repo <cwd> and inline context as --background <text>, so shell word-splitting/quoting would corrupt paths containing spaces and arbitrary background text.
Steps to Reproduce
- Windows;
npm install -g @alibaba-group/open-code-review(v1.12.10); confirmocr versionworks in a terminal. - Install the OpenCode plugin as described in
plugins/open-code-review/opencode/README.md. - In OpenCode, call
ocr_health(or ask the agent to).
Expected Behavior
ocr_health prints the installed OCR version and the LLM connection result; ocr_review returns OCR's real stdout/stderr on failure.
Actual Behavior
LLM connection check failed: OpenCodeReview exited with code 1.— no version output, empty stdout/stderr.
Suggested Change
Don't detach the child on Windows, or spawn the resolved native binary instead of the .cmd shim. The npm package already ships scripts/platform.js with resolveNativeBinary(), so the plugin could reuse that on Windows.
Verified minimal fix (one line, keeps shell: false):
detached: process.platform !== "win32",After this change on the same machine:
ocr_healthreturns the version line and the real LLM error (no valid LLM endpoint configured ...)ocr_review({ preview: true })returns the real OCR message (... is not a git repository) instead of a generic exit code
Source: alibaba/open-code-review