Skip to content

fix: Windows compatibility for qodercli#1

Open
shadowericq wants to merge 1 commit intozxcrf:mainfrom
shadowericq:fix/windows-support
Open

fix: Windows compatibility for qodercli#1
shadowericq wants to merge 1 commit intozxcrf:mainfrom
shadowericq:fix/windows-support

Conversation

@shadowericq
Copy link
Copy Markdown

Summary

This PR fixes the opencode-qoder-auth plugin to work on Windows with qodercli installed via npm.

Root Cause Chain (4 sequential failures)

  1. resolveQoderCLI() only searched for bare qodercli — on Windows, the binary is qodercli.exe
  2. --print mode caused ENAMETOOLONG on Windows (command line limit ~32767 chars)
  3. --verbose flag not supported by qodercli → exit code 1
  4. Multiple SDK flags (--storage-dir, --resource-dir, etc.) not supported by qodercli → silent failures

Changes

src/qoder-language-model.ts

  • Fix resolveQoderCLI(): On Windows, search for qodercli.exe first, then .cmd, then bare name. Also check npm global package embedded binary path (%APPDATA%\npm\node_modules\@qoder-ai\qodercli\bin\qodercli.exe)
  • Add wrapStringAsStream(): Forces streaming input mode (--input-format stream-json) instead of --print, avoiding Windows ENAMETOOLONG for long prompts
  • Force streaming in doStream(): String prompts are wrapped as async iterables so SDK uses stdin-based input

src/vendor/qoder-agent-sdk.mjs

  • Remove --verbose from buildCommand() — not supported by qodercli
  • Remove unsupported CLI flags: --storage-dir, --resource-dir, --max-turns, --max-budget-usd, --fallback-model, --betas, --resume-session-at, --include-partial-messages, --max-thinking-tokens, --json-schema
  • Add --mcp-config temp file fallback: When MCP config JSON exceeds 8000 chars, write to temp file instead of passing inline (avoids ENAMETOOLONG on Windows)

Testing

  • ✅ CLI resolution finds qodercli.exe on Windows
  • ✅ Streaming mode (--input-format stream-json) works from Node.js spawn
  • ✅ End-to-end: CLI returns result success with exit code 0
  • ✅ Plugin loads without ProviderInitError in opencode

Known Limitations

  • qodercli 0.2.7 does not emit stream_event messages — only complete assistant messages. This means no token-by-token streaming; the full response appears at once. This is a CLI limitation, not a plugin issue.

…nsupported flags

- Fix resolveQoderCLI() to search for .exe/.cmd on Windows and check
  npm global package embedded binary path
- Add wrapStringAsStream() to force streaming input mode (--input-format
  stream-json) instead of --print, avoiding Windows ENAMETOOLONG
- Remove unsupported CLI flags from buildCommand(): --verbose,
  --storage-dir, --resource-dir, --max-turns, --max-budget-usd,
  --fallback-model, --betas, --resume-session-at,
  --include-partial-messages, --max-thinking-tokens, --json-schema
- Add --mcp-config temp file fallback when JSON exceeds 8000 chars
  (Windows command line length limit)
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