@qwen-code/qwen-code 0.5.1 → 0.6.0-nightly.20251224.bc2a7efc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +88 -310
  2. package/cli.js +122187 -100237
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,382 +1,152 @@
1
- # Qwen Code
2
-
3
1
  <div align="center">
4
2
 
5
- ![Qwen Code Screenshot](./docs/assets/qwen-screenshot.png)
6
-
7
3
  [![npm version](https://img.shields.io/npm/v/@qwen-code/qwen-code.svg)](https://www.npmjs.com/package/@qwen-code/qwen-code)
8
4
  [![License](https://img.shields.io/github/license/QwenLM/qwen-code.svg)](./LICENSE)
9
5
  [![Node.js Version](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen.svg)](https://nodejs.org/)
10
6
  [![Downloads](https://img.shields.io/npm/dm/@qwen-code/qwen-code.svg)](https://www.npmjs.com/package/@qwen-code/qwen-code)
11
7
 
12
- **AI-powered command-line workflow tool for developers**
8
+ **An open-source AI agent that lives in your terminal.**
13
9
 
14
- [Installation](#installation) • [Quick Start](#quick-start) • [Features](#key-features) • [Documentation](./docs/) • [Contributing](./CONTRIBUTING.md)
10
+ <a href="https://qwenlm.github.io/qwen-code-docs/zh/users/overview">中文</a> |
11
+ <a href="https://qwenlm.github.io/qwen-code-docs/de/users/overview">Deutsch</a> |
12
+ <a href="https://qwenlm.github.io/qwen-code-docs/fr/users/overview">français</a> |
13
+ <a href="https://qwenlm.github.io/qwen-code-docs/ja/users/overview">日本語</a> |
14
+ <a href="https://qwenlm.github.io/qwen-code-docs/ru/users/overview">Русский</a> |
15
+ <a href="https://qwenlm.github.io/qwen-code-docs/pt-BR/users/overview">Português (Brasil)</a>
15
16
 
16
17
  </div>
17
18
 
18
- <div align="center">
19
-
20
- <a href="https://qwenlm.github.io/qwen-code-docs/de/">Deutsch</a> |
21
- <a href="https://qwenlm.github.io/qwen-code-docs/fr">français</a> |
22
- <a href="https://qwenlm.github.io/qwen-code-docs/ja/">日本語</a> |
23
- <a href="https://qwenlm.github.io/qwen-code-docs/ru">Русский</a> |
24
- <a href="https://qwenlm.github.io/qwen-code-docs/zh/">中文</a>
25
-
26
- </div>
27
-
28
- Qwen Code is a powerful command-line AI workflow tool adapted from [**Gemini CLI**](https://github.com/google-gemini/gemini-cli), specifically optimized for [Qwen3-Coder](https://github.com/QwenLM/Qwen3-Coder) models. It enhances your development workflow with advanced code understanding, automated tasks, and intelligent assistance.
29
-
30
- ## 💡 Free Options Available
31
-
32
- Get started with Qwen Code at no cost using any of these free options:
19
+ Qwen Code is an open-source AI agent for the terminal, optimized for [Qwen3-Coder](https://github.com/QwenLM/Qwen3-Coder). It helps you understand large codebases, automate tedious work, and ship faster.
33
20
 
34
- ### 🔥 Qwen OAuth (Recommended)
21
+ ![](https://gw.alicdn.com/imgextra/i1/O1CN01D2DviS1wwtEtMwIzJ_!!6000000006373-2-tps-1600-900.png)
35
22
 
36
- - **2,000 requests per day** with no token limits
37
- - **60 requests per minute** rate limit
38
- - Simply run `qwen` and authenticate with your qwen.ai account
39
- - Automatic credential management and refresh
40
- - Use `/auth` command to switch to Qwen OAuth if you have initialized with OpenAI compatible mode
23
+ ## Why Qwen Code?
41
24
 
42
- ### 🌏 Regional Free Tiers
43
-
44
- - **Mainland China**: ModelScope offers **2,000 free API calls per day**
45
- - **International**: OpenRouter provides **up to 1,000 free API calls per day** worldwide
46
-
47
- For detailed setup instructions, see [Authorization](#authorization).
48
-
49
- > [!WARNING]
50
- > **Token Usage Notice**: Qwen Code may issue multiple API calls per cycle, resulting in higher token usage (similar to Claude Code). We're actively optimizing API efficiency.
51
-
52
- ## Key Features
53
-
54
- - **Code Understanding & Editing** - Query and edit large codebases beyond traditional context window limits
55
- - **Workflow Automation** - Automate operational tasks like handling pull requests and complex rebases
56
- - **Enhanced Parser** - Adapted parser specifically optimized for Qwen-Coder models
57
- - **Vision Model Support** - Automatically detect images in your input and seamlessly switch to vision-capable models for multimodal analysis
25
+ - **OpenAI-compatible, OAuth free tier**: use an OpenAI-compatible API, or sign in with Qwen OAuth to get 2,000 free requests/day.
26
+ - **Open-source, co-evolving**: both the framework and the Qwen3-Coder model are open-source—and they ship and evolve together.
27
+ - **Agentic workflow, feature-rich**: rich built-in tools (Skills, SubAgents, Plan Mode) for a full agentic workflow and a Claude Code-like experience.
28
+ - **Terminal-first, IDE-friendly**: built for developers who live in the command line, with optional integration for VS Code and Zed.
58
29
 
59
30
  ## Installation
60
31
 
61
- ### Prerequisites
62
-
63
- Ensure you have [Node.js version 20](https://nodejs.org/en/download) or higher installed.
32
+ #### Prerequisites
64
33
 
65
34
  ```bash
35
+ # Node.js 20+
66
36
  curl -qL https://www.npmjs.com/install.sh | sh
67
37
  ```
68
38
 
69
- ### Install from npm
39
+ #### NPM (recommended)
70
40
 
71
41
  ```bash
72
42
  npm install -g @qwen-code/qwen-code@latest
73
- qwen --version
74
43
  ```
75
44
 
76
- ### Install from source
77
-
78
- ```bash
79
- git clone https://github.com/QwenLM/qwen-code.git
80
- cd qwen-code
81
- npm install
82
- npm install -g .
83
- ```
84
-
85
- ### Install globally with Homebrew (macOS/Linux)
45
+ #### Homebrew (macOS, Linux)
86
46
 
87
47
  ```bash
88
48
  brew install qwen-code
89
49
  ```
90
50
 
91
- ## VS Code Extension
92
-
93
- In addition to the CLI tool, Qwen Code also provides a **VS Code extension** that brings AI-powered coding assistance directly into your editor with features like file system operations, native diffing, interactive chat, and more.
94
-
95
- > 📦 The extension is currently in development. For installation, features, and development guide, see the [VS Code Extension README](./packages/vscode-ide-companion/README.md).
96
-
97
51
  ## Quick Start
98
52
 
99
53
  ```bash
100
- # Start Qwen Code
54
+ # Start Qwen Code (interactive)
101
55
  qwen
102
56
 
103
- # Example commands
104
- > Explain this codebase structure
105
- > Help me refactor this function
106
- > Generate unit tests for this module
57
+ # Then, in the session:
58
+ /help
59
+ /auth
107
60
  ```
108
61
 
109
- ### Session Management
110
-
111
- Control your token usage with configurable session limits to optimize costs and performance.
112
-
113
- #### Configure Session Token Limit
114
-
115
- Create or edit `.qwen/settings.json` in your home directory:
116
-
117
- ```json
118
- {
119
- "sessionTokenLimit": 32000
120
- }
121
- ```
122
-
123
- #### Session Commands
124
-
125
- - **`/compress`** - Compress conversation history to continue within token limits
126
- - **`/clear`** - Clear all conversation history and start fresh
127
- - **`/stats`** - Check current token usage and limits
62
+ On first use, you'll be prompted to sign in. You can run `/auth` anytime to switch authentication methods.
128
63
 
129
- > 📝 **Note**: Session token limit applies to a single conversation, not cumulative API calls.
64
+ Example prompts:
130
65
 
131
- ### Vision Model Configuration
132
-
133
- Qwen Code includes intelligent vision model auto-switching that detects images in your input and can automatically switch to vision-capable models for multimodal analysis. **This feature is enabled by default** - when you include images in your queries, you'll see a dialog asking how you'd like to handle the vision model switch.
134
-
135
- #### Skip the Switch Dialog (Optional)
136
-
137
- If you don't want to see the interactive dialog each time, configure the default behavior in your `.qwen/settings.json`:
138
-
139
- ```json
140
- {
141
- "experimental": {
142
- "vlmSwitchMode": "once"
143
- }
144
- }
145
- ```
146
-
147
- **Available modes:**
148
-
149
- - **`"once"`** - Switch to vision model for this query only, then revert
150
- - **`"session"`** - Switch to vision model for the entire session
151
- - **`"persist"`** - Continue with current model (no switching)
152
- - **Not set** - Show interactive dialog each time (default)
153
-
154
- #### Command Line Override
155
-
156
- You can also set the behavior via command line:
157
-
158
- ```bash
159
- # Switch once per query
160
- qwen --vlm-switch-mode once
161
-
162
- # Switch for entire session
163
- qwen --vlm-switch-mode session
164
-
165
- # Never switch automatically
166
- qwen --vlm-switch-mode persist
167
- ```
168
-
169
- #### Disable Vision Models (Optional)
170
-
171
- To completely disable vision model support, add to your `.qwen/settings.json`:
172
-
173
- ```json
174
- {
175
- "experimental": {
176
- "visionModelPreview": false
177
- }
178
- }
179
- ```
180
-
181
- > 💡 **Tip**: In YOLO mode (`--yolo`), vision switching happens automatically without prompts when images are detected.
182
-
183
- ### Authorization
184
-
185
- Choose your preferred authentication method based on your needs:
186
-
187
- #### 1. Qwen OAuth (🚀 Recommended - Start in 30 seconds)
188
-
189
- The easiest way to get started - completely free with generous quotas:
190
-
191
- ```bash
192
- # Just run this command and follow the browser authentication
193
- qwen
66
+ ```text
67
+ What does this project do?
68
+ Explain the codebase structure.
69
+ Help me refactor this function.
70
+ Generate unit tests for this module.
194
71
  ```
195
72
 
196
- **What happens:**
197
-
198
- 1. **Instant Setup**: CLI opens your browser automatically
199
- 2. **One-Click Login**: Authenticate with your qwen.ai account
200
- 3. **Automatic Management**: Credentials cached locally for future use
201
- 4. **No Configuration**: Zero setup required - just start coding!
202
-
203
- **Free Tier Benefits:**
204
-
205
- - ✅ **2,000 requests/day** (no token counting needed)
206
- - ✅ **60 requests/minute** rate limit
207
- - ✅ **Automatic credential refresh**
208
- - ✅ **Zero cost** for individual users
209
- - ℹ️ **Note**: Model fallback may occur to maintain service quality
210
-
211
- #### 2. OpenAI-Compatible API
212
-
213
- Use API keys for OpenAI or other compatible providers:
214
-
215
- **Configuration Methods:**
216
-
217
- 1. **Environment Variables**
218
-
219
- ```bash
220
- export OPENAI_API_KEY="your_api_key_here"
221
- export OPENAI_BASE_URL="your_api_endpoint"
222
- export OPENAI_MODEL="your_model_choice"
223
- ```
224
-
225
- 2. **Project `.env` File**
226
- Create a `.env` file in your project root:
227
- ```env
228
- OPENAI_API_KEY=your_api_key_here
229
- OPENAI_BASE_URL=your_api_endpoint
230
- OPENAI_MODEL=your_model_choice
231
- ```
73
+ <details>
74
+ <summary>Click to watch a demo video</summary>
232
75
 
233
- **API Provider Options**
76
+ <video src="https://cloud.video.taobao.com/vod/HLfyppnCHplRV9Qhz2xSqeazHeRzYtG-EYJnHAqtzkQ.mp4" controls>
77
+ Your browser does not support the video tag.
78
+ </video>
234
79
 
235
- > ⚠️ **Regional Notice:**
236
- >
237
- > - **Mainland China**: Use Alibaba Cloud Bailian or ModelScope
238
- > - **International**: Use Alibaba Cloud ModelStudio or OpenRouter
80
+ </details>
239
81
 
240
- <details>
241
- <summary><b>🇨🇳 For Users in Mainland China</b></summary>
82
+ ## Authentication
242
83
 
243
- **Option 1: Alibaba Cloud Bailian** ([Apply for API Key](https://bailian.console.aliyun.com/))
84
+ Qwen Code supports two authentication methods:
244
85
 
245
- ```bash
246
- export OPENAI_API_KEY="your_api_key_here"
247
- export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
248
- export OPENAI_MODEL="qwen3-coder-plus"
249
- ```
86
+ - **Qwen OAuth (recommended & free)**: sign in with your `qwen.ai` account in a browser.
87
+ - **OpenAI-compatible API**: use `OPENAI_API_KEY` (and optionally a custom base URL / model).
250
88
 
251
- **Option 2: ModelScope (Free Tier)** ([Apply for API Key](https://modelscope.cn/docs/model-service/API-Inference/intro))
89
+ #### Qwen OAuth (recommended)
252
90
 
253
- - **2,000 free API calls per day**
254
- - ⚠️ Connect your Aliyun account to avoid authentication errors
91
+ Start `qwen`, then run:
255
92
 
256
93
  ```bash
257
- export OPENAI_API_KEY="your_api_key_here"
258
- export OPENAI_BASE_URL="https://api-inference.modelscope.cn/v1"
259
- export OPENAI_MODEL="Qwen/Qwen3-Coder-480B-A35B-Instruct"
94
+ /auth
260
95
  ```
261
96
 
262
- </details>
97
+ Choose **Qwen OAuth** and complete the browser flow. Your credentials are cached locally so you usually won't need to log in again.
263
98
 
264
- <details>
265
- <summary><b>🌍 For International Users</b></summary>
99
+ #### OpenAI-compatible API (API key)
266
100
 
267
- **Option 1: Alibaba Cloud ModelStudio** ([Apply for API Key](https://modelstudio.console.alibabacloud.com/))
101
+ Environment variables (recommended for CI / headless environments):
268
102
 
269
103
  ```bash
270
- export OPENAI_API_KEY="your_api_key_here"
271
- export OPENAI_BASE_URL="https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
272
- export OPENAI_MODEL="qwen3-coder-plus"
104
+ export OPENAI_API_KEY="your-api-key-here"
105
+ export OPENAI_BASE_URL="https://api.openai.com/v1" # optional
106
+ export OPENAI_MODEL="gpt-4o" # optional
273
107
  ```
274
108
 
275
- **Option 2: OpenRouter (Free Tier Available)** ([Apply for API Key](https://openrouter.ai/))
109
+ For details (including `.qwen/.env` loading and security notes), see the [authentication guide](https://qwenlm.github.io/qwen-code-docs/en/users/configuration/auth/).
276
110
 
277
- ```bash
278
- export OPENAI_API_KEY="your_api_key_here"
279
- export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
280
- export OPENAI_MODEL="qwen/qwen3-coder:free"
281
- ```
111
+ ## Usage
282
112
 
283
- </details>
113
+ As an open-source terminal agent, you can use Qwen Code in four primary ways:
284
114
 
285
- ## Usage Examples
115
+ 1. Interactive mode (terminal UI)
116
+ 2. Headless mode (scripts, CI)
117
+ 3. IDE integration (VS Code, Zed)
118
+ 4. TypeScript SDK
286
119
 
287
- ### 🔍 Explore Codebases
120
+ #### Interactive mode
288
121
 
289
122
  ```bash
290
123
  cd your-project/
291
124
  qwen
292
-
293
- # Architecture analysis
294
- > Describe the main pieces of this system's architecture
295
- > What are the key dependencies and how do they interact?
296
- > Find all API endpoints and their authentication methods
297
- ```
298
-
299
- ### 💻 Code Development
300
-
301
- ```bash
302
- # Refactoring
303
- > Refactor this function to improve readability and performance
304
- > Convert this class to use dependency injection
305
- > Split this large module into smaller, focused components
306
-
307
- # Code generation
308
- > Create a REST API endpoint for user management
309
- > Generate unit tests for the authentication module
310
- > Add error handling to all database operations
311
125
  ```
312
126
 
313
- ### 🔄 Automate Workflows
127
+ Run `qwen` in your project folder to launch the interactive terminal UI. Use `@` to reference local files (for example `@src/main.ts`).
314
128
 
315
- ```bash
316
- # Git automation
317
- > Analyze git commits from the last 7 days, grouped by feature
318
- > Create a changelog from recent commits
319
- > Find all TODO comments and create GitHub issues
320
-
321
- # File operations
322
- > Convert all images in this directory to PNG format
323
- > Rename all test files to follow the *.test.ts pattern
324
- > Find and remove all console.log statements
325
- ```
326
-
327
- ### 🐛 Debugging & Analysis
129
+ #### Headless mode
328
130
 
329
131
  ```bash
330
- # Performance analysis
331
- > Identify performance bottlenecks in this React component
332
- > Find all N+1 query problems in the codebase
333
-
334
- # Security audit
335
- > Check for potential SQL injection vulnerabilities
336
- > Find all hardcoded credentials or API keys
132
+ cd your-project/
133
+ qwen -p "your question"
337
134
  ```
338
135
 
339
- ## Popular Tasks
136
+ Use `-p` to run Qwen Code without the interactive UI—ideal for scripts, automation, and CI/CD. Learn more: [Headless mode](https://qwenlm.github.io/qwen-code-docs/en/users/features/headless).
340
137
 
341
- ### 📚 Understand New Codebases
138
+ #### IDE integration
342
139
 
343
- ```text
344
- > What are the core business logic components?
345
- > What security mechanisms are in place?
346
- > How does the data flow through the system?
347
- > What are the main design patterns used?
348
- > Generate a dependency graph for this module
349
- ```
140
+ Use Qwen Code inside your editor (VS Code and Zed):
350
141
 
351
- ### 🔨 Code Refactoring & Optimization
142
+ - [Use in VS Code](https://qwenlm.github.io/qwen-code-docs/en/users/integration-vscode/)
143
+ - [Use in Zed](https://qwenlm.github.io/qwen-code-docs/en/users/integration-zed/)
352
144
 
353
- ```text
354
- > What parts of this module can be optimized?
355
- > Help me refactor this class to follow SOLID principles
356
- > Add proper error handling and logging
357
- > Convert callbacks to async/await pattern
358
- > Implement caching for expensive operations
359
- ```
360
-
361
- ### 📝 Documentation & Testing
362
-
363
- ```text
364
- > Generate comprehensive JSDoc comments for all public APIs
365
- > Write unit tests with edge cases for this component
366
- > Create API documentation in OpenAPI format
367
- > Add inline comments explaining complex algorithms
368
- > Generate a README for this module
369
- ```
145
+ #### TypeScript SDK
370
146
 
371
- ### 🚀 Development Acceleration
147
+ Build on top of Qwen Code with the TypeScript SDK:
372
148
 
373
- ```text
374
- > Set up a new Express server with authentication
375
- > Create a React component with TypeScript and tests
376
- > Implement a rate limiter middleware
377
- > Add database migrations for new schema
378
- > Configure CI/CD pipeline for this project
379
- ```
149
+ - [Use the Qwen Code SDK](./packages/sdk-typescript/README.md)
380
150
 
381
151
  ## Commands & Shortcuts
382
152
 
@@ -386,6 +156,7 @@ qwen
386
156
  - `/clear` - Clear conversation history
387
157
  - `/compress` - Compress history to save tokens
388
158
  - `/stats` - Show current session information
159
+ - `/bug` - Submit a bug report
389
160
  - `/exit` or `/quit` - Exit Qwen Code
390
161
 
391
162
  ### Keyboard Shortcuts
@@ -394,6 +165,19 @@ qwen
394
165
  - `Ctrl+D` - Exit (on empty line)
395
166
  - `Up/Down` - Navigate command history
396
167
 
168
+ > Learn more about [Commands](https://qwenlm.github.io/qwen-code-docs/en/users/features/commands/)
169
+ >
170
+ > **Tip**: In YOLO mode (`--yolo`), vision switching happens automatically without prompts when images are detected. Learn more about [Approval Mode](https://qwenlm.github.io/qwen-code-docs/en/users/features/approval-mode/)
171
+
172
+ ## Configuration
173
+
174
+ Qwen Code can be configured via `settings.json`, environment variables, and CLI flags.
175
+
176
+ - **User settings**: `~/.qwen/settings.json`
177
+ - **Project settings**: `.qwen/settings.json`
178
+
179
+ See [settings](https://qwenlm.github.io/qwen-code-docs/en/users/configuration/settings/) for available options and precedence.
180
+
397
181
  ## Benchmark Results
398
182
 
399
183
  ### Terminal-Bench Performance
@@ -403,24 +187,18 @@ qwen
403
187
  | Qwen Code | Qwen3-Coder-480A35 | 37.5% |
404
188
  | Qwen Code | Qwen3-Coder-30BA3B | 31.3% |
405
189
 
406
- ## Development & Contributing
190
+ ## Ecosystem
407
191
 
408
- See [CONTRIBUTING.md](./CONTRIBUTING.md) to learn how to contribute to the project.
192
+ Looking for a graphical interface?
409
193
 
410
- For detailed authentication setup, see the [authentication guide](./docs/cli/authentication.md).
194
+ - [**Gemini CLI Desktop**](https://github.com/Piebald-AI/gemini-cli-desktop) A cross-platform desktop/web/mobile UI for Qwen Code
411
195
 
412
196
  ## Troubleshooting
413
197
 
414
- If you encounter issues, check the [troubleshooting guide](docs/troubleshooting.md).
198
+ If you encounter issues, check the [troubleshooting guide](https://qwenlm.github.io/qwen-code-docs/en/users/support/troubleshooting/).
199
+
200
+ To report a bug from within the CLI, run `/bug` and include a short title and repro steps.
415
201
 
416
202
  ## Acknowledgments
417
203
 
418
204
  This project is based on [Google Gemini CLI](https://github.com/google-gemini/gemini-cli). We acknowledge and appreciate the excellent work of the Gemini CLI team. Our main contribution focuses on parser-level adaptations to better support Qwen-Coder models.
419
-
420
- ## License
421
-
422
- [LICENSE](./LICENSE)
423
-
424
- ## Star History
425
-
426
- [![Star History Chart](https://api.star-history.com/svg?repos=QwenLM/qwen-code&type=Date)](https://www.star-history.com/#QwenLM/qwen-code&Date)