Skip to content

Commit cca4668

Browse files
konardclaude
andcommitted
Add Qwen Code CLI support
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 <noreply@anthropic.com>
1 parent da78cc5 commit cca4668

File tree

5 files changed

+541
-6
lines changed

5 files changed

+541
-6
lines changed

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# agent-commander
22

3-
A JavaScript library to control agents enclosed in CLI commands like Anthropic Claude Code CLI, OpenAI Codex, OpenCode, and @link-assistant/agent.
3+
A JavaScript library to control agents enclosed in CLI commands like Anthropic Claude Code CLI, OpenAI Codex, OpenCode, Qwen Code, and @link-assistant/agent.
44

55
Built on the success of [hive-mind](https://github.com/link-assistant/hive-mind), `agent-commander` provides a flexible JavaScript interface and CLI tools for managing agent processes with various isolation levels.
66

@@ -11,6 +11,7 @@ Built on the success of [hive-mind](https://github.com/link-assistant/hive-mind)
1111
- `claude` - Anthropic Claude Code CLI
1212
- `codex` - OpenAI Codex CLI
1313
- `opencode` - OpenCode CLI
14+
- `qwen` - Qwen Code CLI (Alibaba's AI coding agent)
1415
- `agent` - @link-assistant/agent (unrestricted OpenCode fork)
1516
- **Multiple Isolation Modes**:
1617
- No isolation (direct execution)
@@ -56,6 +57,7 @@ bun add agent-commander
5657
| `claude` | Anthropic Claude Code CLI | ✅ (stream-json) | ✅ (stream-json) | `sonnet`, `opus`, `haiku` |
5758
| `codex` | OpenAI Codex CLI ||| `gpt5`, `o3`, `gpt4o` |
5859
| `opencode` | OpenCode CLI ||| `grok`, `gemini`, `sonnet` |
60+
| `qwen` | Qwen Code CLI | ✅ (stream-json) | ✅ (stream-json) | `qwen3-coder`, `coder`, `gpt-4o` |
5961
| `agent` | @link-assistant/agent ||| `grok`, `sonnet`, `haiku` |
6062

6163
### Claude-specific Features
@@ -70,6 +72,17 @@ The Claude Code CLI supports additional features:
7072
- **Verbose mode**: Enable with `--verbose` for detailed output
7173
- **User message replay**: Use `--replay-user-messages` for streaming acknowledgment
7274

75+
### Qwen-specific Features
76+
77+
The [Qwen Code CLI](https://github.com/QwenLM/qwen-code) supports additional features:
78+
79+
- **Stream JSON format**: Uses `--output-format stream-json` for real-time NDJSON streaming
80+
- **Auto-approval mode**: Use `--yolo` flag for automatic action approval (enabled by default)
81+
- **Session management**: Support for `--resume <sessionId>` and `--continue` for most recent session
82+
- **Context options**: Use `--all-files` to include all files, `--include-directories` for specific dirs
83+
- **Partial messages**: Use `--include-partial-messages` with stream-json for real-time UI updates
84+
- **Model flexibility**: Supports Qwen3-Coder models plus OpenAI-compatible models via API
85+
7386
## CLI Usage
7487

7588
### start-agent
@@ -82,7 +95,7 @@ start-agent --tool claude --working-directory "/tmp/dir" --prompt "Solve the iss
8295

8396
#### Options
8497

85-
- `--tool <name>` - CLI tool to use (e.g., 'claude', 'codex', 'opencode', 'agent') [required]
98+
- `--tool <name>` - CLI tool to use (e.g., 'claude', 'codex', 'opencode', 'qwen', 'agent') [required]
8699
- `--working-directory <path>` - Working directory for the agent [required]
87100
- `--prompt <text>` - Prompt for the agent
88101
- `--system-prompt <text>` - System prompt for the agent
@@ -118,6 +131,11 @@ start-agent --tool codex --working-directory "/tmp/dir" --prompt "Fix the bug" -
118131
start-agent --tool agent --working-directory "/tmp/dir" --prompt "Analyze code" --model grok
119132
```
120133

134+
**Using Qwen Code**
135+
```bash
136+
start-agent --tool qwen --working-directory "/tmp/dir" --prompt "Review this code" --model qwen3-coder
137+
```
138+
121139
**With model fallback (Claude)**
122140
```bash
123141
start-agent --tool claude --working-directory "/tmp/dir" \
@@ -233,6 +251,14 @@ const linkAgent = agent({
233251
prompt: 'Implement feature',
234252
model: 'grok',
235253
});
254+
255+
// Using Qwen Code
256+
const qwenAgent = agent({
257+
tool: 'qwen',
258+
workingDirectory: '/tmp/project',
259+
prompt: 'Review this code',
260+
model: 'qwen3-coder',
261+
});
236262
```
237263

238264
### Streaming JSON Messages
@@ -347,7 +373,7 @@ await myAgent.start({ dryRun: true });
347373
import { getTool, listTools, isToolSupported } from 'agent-commander';
348374

349375
// List all available tools
350-
console.log(listTools()); // ['claude', 'codex', 'opencode', 'agent']
376+
console.log(listTools()); // ['claude', 'codex', 'opencode', 'agent', 'qwen']
351377

352378
// Check if a tool is supported
353379
console.log(isToolSupported({ toolName: 'claude' })); // true
@@ -368,7 +394,7 @@ console.log(fullId); // 'claude-opus-4-5-20251101'
368394
Creates an agent controller.
369395

370396
**Parameters:**
371-
- `options.tool` (string, required) - CLI tool to use ('claude', 'codex', 'opencode', 'agent')
397+
- `options.tool` (string, required) - CLI tool to use ('claude', 'codex', 'opencode', 'qwen', 'agent')
372398
- `options.workingDirectory` (string, required) - Working directory
373399
- `options.prompt` (string, optional) - Prompt for the agent
374400
- `options.systemPrompt` (string, optional) - System prompt
@@ -535,6 +561,7 @@ agent-commander/
535561
│ │ ├── claude.mjs # Claude Code CLI config
536562
│ │ ├── codex.mjs # Codex CLI config
537563
│ │ ├── opencode.mjs # OpenCode CLI config
564+
│ │ ├── qwen.mjs # Qwen Code CLI config
538565
│ │ └── agent.mjs # @link-assistant/agent config
539566
│ ├── streaming/ # JSON streaming utilities
540567
│ │ ├── index.mjs # Stream exports
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"agent-commander": minor
3+
---
4+
5+
Add Qwen Code CLI support
6+
7+
- Added new `qwen` tool configuration for Qwen Code CLI (Alibaba's AI coding agent)
8+
- Supports stream-json output format for real-time NDJSON streaming
9+
- Supports auto-approval mode with `--yolo` flag (enabled by default)
10+
- Supports session management with `--resume` and `--continue` options
11+
- Supports context options like `--all-files` and `--include-directories`
12+
- Supports `--include-partial-messages` for real-time UI updates
13+
- Added model aliases: `qwen3-coder`, `coder`, `gpt-4o`
14+
- Added comprehensive tests for the new Qwen tool

js/src/tools/index.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/**
22
* Tool configurations and utilities
3-
* Provides configuration for different CLI agents: claude, codex, opencode, agent
3+
* Provides configuration for different CLI agents: claude, codex, opencode, agent, qwen
44
*/
55

66
import { claudeTool } from './claude.mjs';
77
import { codexTool } from './codex.mjs';
88
import { opencodeTool } from './opencode.mjs';
99
import { agentTool } from './agent.mjs';
10+
import { qwenTool } from './qwen.mjs';
1011

1112
/**
1213
* Available tool configurations
@@ -16,6 +17,7 @@ export const tools = {
1617
codex: codexTool,
1718
opencode: opencodeTool,
1819
agent: agentTool,
20+
qwen: qwenTool,
1921
};
2022

2123
/**
@@ -54,4 +56,4 @@ export function isToolSupported(options) {
5456
return toolName in tools;
5557
}
5658

57-
export { claudeTool, codexTool, opencodeTool, agentTool };
59+
export { claudeTool, codexTool, opencodeTool, agentTool, qwenTool };

0 commit comments

Comments
 (0)