Skip to content

fix(cli): execute OpenCode command shims on Windows - #261

Open
Jonesxq wants to merge 1 commit into
cortexkit:masterfrom
Jonesxq:fix/windows-opencode-cmd-shim
Open

fix(cli): execute OpenCode command shims on Windows#261
Jonesxq wants to merge 1 commit into
cortexkit:masterfrom
Jonesxq:fix/windows-opencode-cmd-shim

Conversation

@Jonesxq

@Jonesxq Jonesxq commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • run detected OpenCode .cmd and .bat shims through ComSpec on Windows, because Node's execFileSync cannot execute command shims directly
  • preserve direct invocation for native executables and pass the shim path through the child environment so spaces, shell metacharacters, and literal %VAR% text remain intact
  • add coverage for case-insensitive shim extensions, native binaries, version/model probes, and tricky Windows paths

This restores OpenCode detection for npm-installed Windows users while keeping the existing timeout and native-executable behavior.

Verification

  • bun test packages/cli/src/lib/opencode-helpers.test.ts (25 passed, 10 platform skips, 0 failed)
  • production Bun build of packages/cli/src/lib/opencode-helpers.ts
  • real Windows npm.cmd smoke test (returned version 11.16.0)
  • git diff --check

Full workspace typecheck and lint were not run because dependency bootstrap could not complete in this environment: Bun registry metadata resolution failed, and the npm workspace install timed out.

Fixes #255


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Restores Windows OpenCode detection for npm-installed users. Uses a safer invocation path for command shims while preserving native binary behavior and timeouts.

  • Bug Fixes
    • Route .cmd/.bat shims through ComSpec (fallback cmd.exe) with a single quoted /c payload and windowsVerbatimArguments.
    • Pass the shim path via MAGIC_CONTEXT_OPENCODE_BINARY to prevent extra expansion and keep spaces, metacharacters, and literal %VAR% intact.
    • Invoke native executables directly; timeout behavior unchanged.
    • Add tests for case-insensitive shim extensions, version/model probes, native binaries, and tricky Windows paths.

Written for commit 47ca8f6. Summary will update on new commits.

Review in cubic

Greptile Summary

This PR restores OpenCode probing for Windows command shims.

  • Routes case-insensitive .cmd and .bat paths through ComSpec.
  • Preserves direct execution for native binaries.
  • Passes shim paths through the child environment to preserve special characters.
  • Adds tests for shim routing, native invocation, version probes, model probes, and tricky paths.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code failure identified.

Current production paths supply command shims only on Windows, and the new invocation preserves exact shim paths while retaining direct execution for native binaries.

Important Files Changed

Filename Overview
packages/cli/src/lib/opencode-helpers.ts Adds targeted Windows command-shim invocation while preserving existing native executable and timeout behavior; no actionable defect identified.
packages/cli/src/lib/opencode-helpers.test.ts Adds focused coverage for command construction and end-to-end version and model probing through command shims.

Reviews (1): Last reviewed commit: "fix(cli): execute OpenCode command shims..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

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

Labels

None yet

Projects

None yet

1 participant