Skip to content

feat: Add Qwen Code CLI as LLM provider#559

Open
f-liva wants to merge 3 commits intoRightNow-AI:mainfrom
f-liva:feat/qwen-code-provider
Open

feat: Add Qwen Code CLI as LLM provider#559
f-liva wants to merge 3 commits intoRightNow-AI:mainfrom
f-liva:feat/qwen-code-provider

Conversation

@f-liva
Copy link

@f-liva f-liva commented Mar 12, 2026

Summary

  • Add Qwen Code as a new subprocess-based LLM provider, mirroring the Claude Code driver pattern
  • Refactor build_args() in both Claude Code and Qwen Code drivers for proper testability of CLI flag construction
  • Fix a bug in Claude Code where --dangerously-skip-permissions was added unconditionally regardless of the skip_permissions setting

Closes #558

Details

New provider: qwen-code

Qwen Code is an AI coding agent CLI similar to Claude Code. It supports non-interactive mode (--yolo), JSON/stream-JSON output, and free usage via Qwen OAuth (60 req/min, 2,000 req/day).

New file: drivers/qwen_code.rs

  • QwenCodeDriver implementing LlmDriver trait
  • detect() via qwen --version
  • complete()qwen -p <prompt> --yolo --output-format json
  • stream()qwen -p <prompt> --yolo --output-format stream-json
  • Sensitive env filtering (same pattern as Claude Code)
  • Credentials detection at ~/.qwen/

3 models registered:

Model ID Display Name Tier
qwen-code/qwen3-coder Qwen3 Coder (CLI) Smart
qwen-code/qwen-coder-plus Qwen Coder Plus (CLI) Frontier
qwen-code/qwq-32b QwQ 32B (CLI) Balanced

build_args() refactor (both drivers)

Extracted CLI argument construction into a testable build_args() method. Previously, the permission flags (--dangerously-skip-permissions for Claude, --yolo for Qwen) were only tested at the struct field level — not whether they actually appeared in the CLI arguments. Now we have explicit tests verifying:

  • Flag IS present when skip_permissions=true
  • Flag is NOT present when skip_permissions=false
  • Correct output format for streaming vs non-streaming
  • Model flag presence/absence

Bug fix: Claude Code duplicate flag

The Claude Code driver was adding --dangerously-skip-permissions unconditionally (hardcoded) plus a second time conditionally based on skip_permissions. The build_args() refactor fixes this — the flag is now only added when skip_permissions=true.

Test plan

  • 18 qwen-code unit tests (build_args, prompt building, model mapping, JSON parsing, stream events, catalog)
  • 13 claude-code unit tests (including 3 new build_args tests)
  • 19 driver mod tests (provider count updated to 35)
  • Validated in live deployment on Lazycat NAS with Qwen Code v0.12.1

🤖 Generated with Claude Code

Federico Liva and others added 3 commits March 12, 2026 12:12
…tability

Add qwen-code as a new subprocess-based LLM provider, mirroring the
claude-code driver pattern. Qwen Code CLI (qwen) uses --yolo for
non-interactive mode and supports json/stream-json output formats.

New files:
- drivers/qwen_code.rs: full driver with complete/stream, env filtering

Changes:
- drivers/mod.rs: register qwen-code provider (defaults, create_driver)
- model_catalog.rs: add provider info, 3 models (qwen3-coder,
  qwen-coder-plus, qwq-32b), aliases, auth detection
- claude_code.rs: extract build_args() for testability, fix duplicate
  --dangerously-skip-permissions flag that was always added regardless
  of skip_permissions setting

Tests: 31 new/updated (18 qwen-code + 13 claude-code) covering
build_args with/without permission flags, streaming, model selection,
prompt building, JSON parsing, and catalog integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

feat: Add Qwen Code CLI as LLM provider (like Claude Code)

1 participant