Skip to content

Conversation

@konard
Copy link
Contributor

@konard konard commented Jan 10, 2026

Summary

This PR implements support for Qwen Code CLI (Alibaba's AI coding agent optimized for Qwen3-Coder models) as a new tool option in agent-commander, similar to how Claude Code CLI, Codex CLI, OpenCode CLI, Gemini CLI, and @link-assistant/agent are implemented.

Key Changes

JavaScript Implementation (js/src/tools/qwen.mjs)

  • Added complete tool configuration for Qwen Code CLI
  • Supports stream-json output format for real-time NDJSON streaming
  • Auto-approval mode with --yolo flag (enabled by default)
  • Session management with --resume and --continue options
  • Context options: --all-files and --include-directories
  • Partial messages support with --include-partial-messages
  • Model aliases: qwen3-coder, coder, gpt-4o, gpt-4, sonnet, opus

Rust Implementation (rust/src/tools/qwen.rs)

  • Complete Rust implementation matching JavaScript functionality
  • All same features: model mapping, argument building, NDJSON parsing
  • Session ID and usage extraction
  • Error detection with proper error types
  • Tests in separate file: rust/tests/qwen_tests.rs (24 tests)

Tool Registry Updates

  • JavaScript: Added qwenTool to tools registry in js/src/tools/index.mjs
  • Rust: Added QwenTool to tools registry in rust/src/tools/mod.rs
  • Both registries now support: Claude, Codex, OpenCode, Agent, Gemini, and Qwen

Unit Testing

  • JavaScript: 23 tests for Qwen tool (total: 140 tests pass)
  • Rust: 24 tests for Qwen tool (total: 197 tests pass)
  • Tests cover all functionality: model mapping, argument building, output parsing, session ID extraction, usage statistics, error detection

Manual E2E Testing (.github/workflows/e2e-qwen.yml)

  • Added manual workflow for E2E testing with Qwen Code CLI
  • Supports workflow_dispatch for manual trigger with configurable inputs
  • Tests Qwen Code CLI installation and configuration
  • Tests agent-commander integration in dry-run mode

Experiment Script (js/experiments/test-qwen-integration.mjs)

  • Comprehensive local test script for Qwen tool configuration
  • Tests all tool functions without requiring API authentication
  • Can be extended with --live flag for authenticated testing

Changeset

  • Added changeset for minor version bump

Test Results

✅ All tests pass:

  • JavaScript: 140 tests passed (23 new for Qwen, 22 for Gemini)
  • Rust: 197 tests passed (24 new for Qwen, 25 for Gemini)
  • Local CI checks: cargo fmt, cargo clippy, npm test - all pass
  • GitHub CI: All workflows passing

Test Plan

  • Run npm test - all 140 JavaScript tests pass
  • Run cargo test - all 197 Rust tests pass
  • Run cargo fmt --check - no formatting issues
  • Run cargo clippy - no warnings or errors
  • Verify Qwen tool is correctly registered in both JS and Rust
  • Verify command line arguments are built correctly
  • Verify JSON output parsing works as expected
  • Verify Rust tests are in separate files, not mixed with code
  • Verify Rust and JavaScript implementations have the same features
  • Merge main branch and resolve conflicts with Gemini implementation
  • All CI checks passing

How to Run Manual E2E Tests

  1. Go to Actions tab → "E2E Tests - Qwen Code CLI" workflow
  2. Click "Run workflow" and configure optional parameters
  3. The workflow will test:
    • Qwen Code CLI installation
    • Tool configuration validation
    • Agent-commander integration (dry-run)

For authenticated local testing:

npm install -g @qwen-code/qwen-code@latest
qwen  # then run /auth to authenticate
node experiments/test-qwen-integration.mjs --live

Fixes #11

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #11
@konard konard self-assigned this Jan 10, 2026
Implements support for Qwen Code CLI (Alibaba's AI coding agent optimized for
Qwen3-Coder models) as a new tool option in agent-commander.

Key features:
- Stream JSON format with --output-format stream-json for real-time NDJSON streaming
- Auto-approval mode with --yolo flag (enabled by default for autonomous execution)
- Session management with --resume and --continue options
- Context options: --all-files and --include-directories
- Partial messages support with --include-partial-messages
- Model aliases: qwen3-coder, coder, gpt-4o

Files changed:
- js/src/tools/qwen.mjs: New tool configuration
- js/src/tools/index.mjs: Tool registry update
- js/test/tools.test.mjs: 23 new tests for Qwen tool
- README.md: Documentation and examples
- js/.changeset/add-qwen-coder-support.md: Changeset for release

Fixes #11

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@konard konard changed the title [WIP] Add Qwen Coder support Add Qwen Code CLI support Jan 10, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@konard konard marked this pull request as ready for review January 10, 2026 16:14
@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $6.705090 USD
  • Calculated by Anthropic: $5.143415 USD
  • Difference: $-1.561675 (-23.29%)
    📎 Log file uploaded as GitHub Gist (951KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

We should also check if link-assistant/hive-mind#556 has any useful ideas for that implementation.

Double check we do unit test everything we, can and it is executed in CI/CD. Also please add support for manual e2e tests (meaning it should be separate manually executed CI workflow) using free plan of Qwen Code CLI.

@konard konard marked this pull request as draft January 10, 2026 16:32
@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-10T16:32:03.619Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

- Add .github/workflows/e2e-qwen.yml for manual E2E testing
  - Supports workflow_dispatch for manual trigger
  - Tests Qwen Code CLI installation and configuration
  - Tests agent-commander integration in dry-run mode
  - Provides clear instructions for authenticated testing

- Add js/experiments/test-qwen-integration.mjs
  - Comprehensive test script for Qwen tool configuration
  - Tests model mapping, argument building, output parsing
  - Tests session ID extraction, usage extraction, error detection
  - Can be run locally without authentication

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@konard konard marked this pull request as ready for review January 10, 2026 16:39
@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

🤖 Work Session Complete

Based on the feedback from @konard, I've made the following updates:

1. Reviewed hive-mind PR #556

I studied the implementation in link-assistant/hive-mind#556 for useful ideas. The implementation here follows similar patterns with:

  • Model mapping functions
  • Session management support
  • NDJSON output parsing
  • Error detection
  • Usage statistics extraction

2. Verified Unit Tests

All 118 unit tests pass and are executed in CI/CD:

  • 23 tests specifically for the Qwen tool
  • Tests cover model mapping, argument building, output parsing, session ID extraction, usage extraction, error detection, and capability flags

3. Added Manual E2E Testing Support

New workflow: .github/workflows/e2e-qwen.yml

  • Manual workflow triggered via workflow_dispatch
  • Tests Qwen Code CLI installation
  • Tests tool configuration validation
  • Tests agent-commander integration (dry-run mode)
  • Provides clear instructions for authenticated testing with free tier

New experiment script: js/experiments/test-qwen-integration.mjs

  • 29 comprehensive integration tests
  • Can be run locally without authentication
  • Supports --live flag for authenticated testing

How to Run Manual E2E Tests

  1. Via GitHub Actions:

    • Go to Actions tab → "E2E Tests - Qwen Code CLI"
    • Click "Run workflow"
    • Configure optional parameters (prompt, working directory, model)
  2. Locally (authenticated):

    npm install -g @qwen-code/qwen-code@latest
    qwen  # then run /auth for free tier (2000 requests/day)
    node experiments/test-qwen-integration.mjs --live

CI Status

✅ All CI checks passing for the latest commit (70e5641)

@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.708896 USD
  • Calculated by Anthropic: $2.529908 USD
  • Difference: $-2.178989 (-46.27%)
    📎 Log file uploaded as GitHub Gist (590KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Jan 15, 2026

Both JavaScript and Rust versions must be implemented, have all the same tess. Make sure all our tests in Rust are in separate files, not mixed with code, like we do in JavaScript.

Also ensure all changes are correct, consistent and fully meet original requirements.

@konard konard marked this pull request as draft January 15, 2026 14:19
@konard
Copy link
Contributor Author

konard commented Jan 15, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-15T14:19:53.093Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

konard and others added 4 commits January 15, 2026 15:28
- Add rust/src/tools/qwen.rs with complete Qwen tool implementation
  - Model mapping with qwen3-coder, coder, gpt-4o, gpt-4, sonnet, opus aliases
  - Build args for all Qwen Code options (--yolo, --resume, --continue, etc.)
  - NDJSON output parsing, session ID extraction, usage stats, error detection
  - QwenTool struct with capability flags matching JS implementation

- Update rust/src/tools/mod.rs to register Qwen tool
  - Add qwen module and exports
  - Implement Tool trait for QwenTool
  - Update ToolRegistry, get_tool, list_tools, is_tool_supported

- Move all tool tests to separate test files (per feedback):
  - rust/tests/qwen_tests.rs (24 tests)
  - rust/tests/claude_tests.rs (17 tests)
  - rust/tests/codex_tests.rs (12 tests)
  - rust/tests/opencode_tests.rs (10 tests)
  - rust/tests/agent_tests.rs (14 tests)
  - rust/tests/tools_tests.rs (11 tests)

Test results:
- Rust: 60 unit tests + 88 integration tests = 148 total (all passing)
- JavaScript: 118 tests (all passing)

Both JS and Rust implementations are consistent with:
- Same model mappings
- Same capability flags
- Same default values
- Same function signatures and behavior

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Apply automatic formatting via cargo fmt to:
- rust/src/tools/qwen.rs: Align comment indentation
- rust/tests/agent_tests.rs: Multi-line assert formatting
- rust/tests/claude_tests.rs: Multi-line assert formatting
- rust/tests/opencode_tests.rs: Multi-line assert formatting

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace manual Default impl for QwenErrorResult with #[derive(Default)]
as suggested by clippy. This is equivalent since all fields have default
values (bool defaults to false, Option defaults to None).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- tests/claude_tests.rs: Remove unnecessary reference in comparison
- tests/qwen_tests.rs: Replace collect+is_empty with any() for cleaner code

Both fixes address clippy warnings that are treated as errors with -Dwarnings.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@konard konard marked this pull request as ready for review January 15, 2026 15:08
@konard
Copy link
Contributor Author

konard commented Jan 15, 2026

⚠️ Solution Draft Finished with Errors

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $12.351770 USD
  • Calculated by Anthropic: $0.000000 USD
  • Difference: $-12.351770 (-100.00%)

Note: The session encountered errors during execution, but some work may have been completed. Please review the changes carefully.

📎 Log file uploaded as Gist (1375KB)
🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard marked this pull request as draft January 17, 2026 23:08
@konard
Copy link
Contributor Author

konard commented Jan 17, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-17T23:08:03.655Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

konard and others added 2 commits January 18, 2026 00:09
…ntations

Both Qwen Code CLI and Gemini CLI are now supported:
- JavaScript: qwen.mjs and gemini.mjs tools
- Rust: qwen.rs and gemini.rs modules
- Updated tool registries to include both tools
- Test files updated to include both tools

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Added geminiTool to imports
- Combined Qwen and Gemini tests properly
- All 140 JavaScript tests now pass

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@konard konard marked this pull request as ready for review January 17, 2026 23:17
@konard
Copy link
Contributor Author

konard commented Jan 17, 2026

✅ Work Session Complete

All requirements from the feedback have been addressed:

1. Both JavaScript and Rust Versions Implemented ✅

  • JavaScript: Complete implementation in js/src/tools/qwen.mjs with 23 comprehensive tests
  • Rust: Complete implementation in rust/src/tools/qwen.rs with 24 comprehensive tests
  • Both implementations have the same features and functionality

2. Rust Tests in Separate Files ✅

  • All Rust tests are in rust/tests/qwen_tests.rs (separate file)
  • No inline tests in source code (verified with grep)
  • Matches the JavaScript testing pattern

3. Changes Are Correct and Consistent ✅

  • Merged main branch and resolved conflicts with Gemini implementation
  • Both Qwen and Gemini tools are now supported
  • Tool registries updated in both JavaScript and Rust
  • All 140 JavaScript tests pass
  • All 197 Rust tests pass

4. CI/CD Status ✅

  • All CI checks passing on latest commit (29bf13e)
  • Rust: cargo fmt, cargo clippy, cargo test - all pass
  • JavaScript: npm test, eslint - all pass

Implementation Summary

Files Changed:

  • js/src/tools/qwen.mjs - JavaScript implementation
  • js/src/tools/index.mjs - Added Qwen to registry (alongside Gemini)
  • js/test/tools.test.mjs - 23 tests for Qwen, 22 for Gemini
  • rust/src/tools/qwen.rs - Rust implementation
  • rust/src/tools/mod.rs - Added Qwen to registry (alongside Gemini)
  • rust/tests/qwen_tests.rs - 24 tests for Qwen

Test Coverage:

  • JavaScript: 140 tests (23 for Qwen, 22 for Gemini)
  • Rust: 197 tests (24 for Qwen, 25 for Gemini)

The PR is now ready for review!

🤖 Generated with Claude Code

@konard
Copy link
Contributor Author

konard commented Jan 17, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $5.250169 USD
  • Calculated by Anthropic: $2.514168 USD
  • Difference: $-2.736001 (-52.11%)
    📎 Log file uploaded as Gist (808KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 3fe9021 into main Jan 18, 2026
44 checks passed
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.

Add Qwen Coder support

2 participants