mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Update README.md
This commit is contained in:
215
README.md
215
README.md
@@ -1,11 +1,26 @@
|
|||||||
# Qwen Code
|
# Qwen Code
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Qwen Code is a command-line AI workflow tool adapted from [**Gemini CLI**](https://github.com/google-gemini/gemini-cli) (Please refer to [this document](./README.gemini.md) for more details), optimized for [Qwen3-Coder](https://github.com/QwenLM/Qwen3-Coder) models with enhanced parser support & tool support.
|
[](https://www.npmjs.com/package/@qwen-code/qwen-code)
|
||||||
|
[](./LICENSE)
|
||||||
|
[](https://nodejs.org/)
|
||||||
|
[](https://www.npmjs.com/package/@qwen-code/qwen-code)
|
||||||
|
|
||||||
|
**AI-powered command-line workflow tool for developers**
|
||||||
|
|
||||||
|
[Installation](#installation) • [Quick Start](#quick-start) • [Features](#key-features) • [Documentation](./docs/) • [Contributing](./CONTRIBUTING.md)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Qwen Code is a powerful command-line AI workflow tool adapted from [**Gemini CLI**](https://github.com/google-gemini/gemini-cli) ([details](./README.gemini.md)), 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.
|
||||||
|
|
||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
> Qwen Code may issue multiple API calls per cycle, resulting in higher token usage, similar to Claude Code. We’re actively working to enhance API efficiency and improve the overall developer experience. ModelScope offers 2,000 free API calls if you are in China mainland. Please check [API config section](#api-configuration) for more details.
|
> **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.
|
||||||
|
>
|
||||||
|
> 💡 **Free Option**: ModelScope provides **2,000 free API calls per day** for users in mainland China. OpenRouter offers up to **1,000 free API calls per day** worldwide. For setup instructions, see [API Configuration](#api-configuration).
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
@@ -13,7 +28,7 @@ Qwen Code is a command-line AI workflow tool adapted from [**Gemini CLI**](https
|
|||||||
- **Workflow Automation** - Automate operational tasks like handling pull requests and complex rebases
|
- **Workflow Automation** - Automate operational tasks like handling pull requests and complex rebases
|
||||||
- **Enhanced Parser** - Adapted parser specifically optimized for Qwen-Coder models
|
- **Enhanced Parser** - Adapted parser specifically optimized for Qwen-Coder models
|
||||||
|
|
||||||
## Quick Start
|
## Installation
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
@@ -23,21 +38,13 @@ Ensure you have [Node.js version 20](https://nodejs.org/en/download) or higher i
|
|||||||
curl -qL https://www.npmjs.com/install.sh | sh
|
curl -qL https://www.npmjs.com/install.sh | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Install from npm
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g @qwen-code/qwen-code@latest
|
npm install -g @qwen-code/qwen-code@latest
|
||||||
qwen --version
|
qwen --version
|
||||||
```
|
```
|
||||||
|
|
||||||
Then run from anywhere:
|
### Install from source
|
||||||
|
|
||||||
```bash
|
|
||||||
qwen
|
|
||||||
```
|
|
||||||
|
|
||||||
Or you can install it from source:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/QwenLM/qwen-code.git
|
git clone https://github.com/QwenLM/qwen-code.git
|
||||||
cd qwen-code
|
cd qwen-code
|
||||||
@@ -45,8 +52,25 @@ npm install
|
|||||||
npm install -g .
|
npm install -g .
|
||||||
```
|
```
|
||||||
|
|
||||||
We now support max session token limit, you can set it in your `.qwen/settings.json` file to save the token usage.
|
## Quick Start
|
||||||
For example, if you want to set the max session token limit to 32000, you can set it like this:
|
|
||||||
|
```bash
|
||||||
|
# Start Qwen Code
|
||||||
|
qwen
|
||||||
|
|
||||||
|
# Example commands
|
||||||
|
> Explain this codebase structure
|
||||||
|
> Help me refactor this function
|
||||||
|
> Generate unit tests for this module
|
||||||
|
```
|
||||||
|
|
||||||
|
### Session Management
|
||||||
|
|
||||||
|
Control your token usage with configurable session limits to optimize costs and performance.
|
||||||
|
|
||||||
|
#### Configure Session Token Limit
|
||||||
|
|
||||||
|
Create or edit `.qwen/settings.json` in your home directory:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -54,117 +78,198 @@ For example, if you want to set the max session token limit to 32000, you can se
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The max session means the maximum number of tokens that can be used in one chat (not the total usage during multiple tool call shoots); if you reach the limit, you can use the `/compress` command to compress the history and go on, or use `/clear` command to clear the history.
|
#### Session Commands
|
||||||
|
|
||||||
|
- **`/compress`** - Compress conversation history to continue within token limits
|
||||||
|
- **`/clear`** - Clear all conversation history and start fresh
|
||||||
|
- **`/status`** - Check current token usage and limits
|
||||||
|
|
||||||
|
> 📝 **Note**: Session token limit applies to a single conversation, not cumulative API calls.
|
||||||
|
|
||||||
### API Configuration
|
### API Configuration
|
||||||
|
|
||||||
Set your Qwen API key (In Qwen Code project, you can also set your API key in `.env` file). the `.env` file should be placed in the root directory of your current project.
|
Qwen Code supports multiple API providers. You can configure your API key through environment variables or a `.env` file in your project root.
|
||||||
|
|
||||||
> ⚠️ **Notice:** <br>
|
#### Configuration Methods
|
||||||
> **If you are in mainland China, please go to https://bailian.console.aliyun.com/ or https://modelscope.cn/docs/model-service/API-Inference/intro to apply for your API key** <br>
|
|
||||||
> **If you are not in mainland China, please go to https://modelstudio.console.alibabacloud.com/ to apply for your API key**
|
|
||||||
|
|
||||||
If you are in mainland China, you can use Qwen3-Coder through the Alibaba Cloud bailian platform.
|
1. **Environment Variables**
|
||||||
|
```bash
|
||||||
|
export OPENAI_API_KEY="your_api_key_here"
|
||||||
|
export OPENAI_BASE_URL="your_api_endpoint"
|
||||||
|
export OPENAI_MODEL="your_model_choice"
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Project `.env` File**
|
||||||
|
Create a `.env` file in your project root:
|
||||||
|
```env
|
||||||
|
OPENAI_API_KEY=your_api_key_here
|
||||||
|
OPENAI_BASE_URL=your_api_endpoint
|
||||||
|
OPENAI_MODEL=your_model_choice
|
||||||
|
```
|
||||||
|
|
||||||
|
#### API Provider Options
|
||||||
|
|
||||||
|
> ⚠️ **Regional Notice:**
|
||||||
|
> - **Mainland China**: Use Alibaba Cloud Bailian or ModelScope
|
||||||
|
> - **International**: Use Alibaba Cloud ModelStudio or OpenRouter
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><b>🇨🇳 For Users in Mainland China</b></summary>
|
||||||
|
|
||||||
|
**Option 1: Alibaba Cloud Bailian** ([Apply for API Key](https://bailian.console.aliyun.com/))
|
||||||
```bash
|
```bash
|
||||||
export OPENAI_API_KEY="your_api_key_here"
|
export OPENAI_API_KEY="your_api_key_here"
|
||||||
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
export OPENAI_MODEL="qwen3-coder-plus"
|
export OPENAI_MODEL="qwen3-coder-plus"
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are in mainland China, ModelScope offers 2,000 free model inference API calls per day. Please make sure you connect your aliyun account to ModelScope so that you won't receive the API error like `API Error: OpenAI API error`.
|
**Option 2: ModelScope (Free Tier)** ([Apply for API Key](https://modelscope.cn/docs/model-service/API-Inference/intro))
|
||||||
|
- ✅ **2,000 free API calls per day**
|
||||||
|
- ⚠️ Connect your Aliyun account to avoid authentication errors
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export OPENAI_API_KEY="your_api_key_here"
|
export OPENAI_API_KEY="your_api_key_here"
|
||||||
export OPENAI_BASE_URL="https://api-inference.modelscope.cn/v1"
|
export OPENAI_BASE_URL="https://api-inference.modelscope.cn/v1"
|
||||||
export OPENAI_MODEL="Qwen/Qwen3-Coder-480B-A35B-Instruct"
|
export OPENAI_MODEL="Qwen/Qwen3-Coder-480B-A35B-Instruct"
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
If you are not in mainland China, you can use Qwen3-Coder through the Alibaba Cloud modelstuido platform.
|
<details>
|
||||||
|
<summary><b>🌍 For International Users</b></summary>
|
||||||
|
|
||||||
|
**Option 1: Alibaba Cloud ModelStudio** ([Apply for API Key](https://modelstudio.console.alibabacloud.com/))
|
||||||
```bash
|
```bash
|
||||||
export OPENAI_API_KEY="your_api_key_here"
|
export OPENAI_API_KEY="your_api_key_here"
|
||||||
export OPENAI_BASE_URL="https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
export OPENAI_BASE_URL="https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
||||||
export OPENAI_MODEL="qwen3-coder-plus"
|
export OPENAI_MODEL="qwen3-coder-plus"
|
||||||
```
|
```
|
||||||
|
|
||||||
OpenRouter also provides free Qwen3-Coder model access:
|
**Option 2: OpenRouter (Free Tier Available)** ([Apply for API Key](https://openrouter.ai/))
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export OPENAI_API_KEY="your_api_key_here"
|
export OPENAI_API_KEY="your_api_key_here"
|
||||||
export OPENAI_BASE_URL=https://openrouter.ai/api/v1
|
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
|
||||||
export OPENAI_MODEL="qwen/qwen3-coder:free"
|
export OPENAI_MODEL="qwen/qwen3-coder:free"
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
|
|
||||||
### Explore Codebases
|
### 🔍 Explore Codebases
|
||||||
|
|
||||||
```sh
|
```bash
|
||||||
cd your-project/
|
cd your-project/
|
||||||
qwen
|
qwen
|
||||||
|
|
||||||
|
# Architecture analysis
|
||||||
> Describe the main pieces of this system's architecture
|
> Describe the main pieces of this system's architecture
|
||||||
|
> What are the key dependencies and how do they interact?
|
||||||
|
> Find all API endpoints and their authentication methods
|
||||||
```
|
```
|
||||||
|
|
||||||
### Code Development
|
### 💻 Code Development
|
||||||
|
|
||||||
```sh
|
```bash
|
||||||
|
# Refactoring
|
||||||
> Refactor this function to improve readability and performance
|
> Refactor this function to improve readability and performance
|
||||||
|
> Convert this class to use dependency injection
|
||||||
|
> Split this large module into smaller, focused components
|
||||||
|
|
||||||
|
# Code generation
|
||||||
|
> Create a REST API endpoint for user management
|
||||||
|
> Generate unit tests for the authentication module
|
||||||
|
> Add error handling to all database operations
|
||||||
```
|
```
|
||||||
|
|
||||||
### Automate Workflows
|
### 🔄 Automate Workflows
|
||||||
|
|
||||||
```sh
|
```bash
|
||||||
> Analyze git commits from the last 7 days, grouped by feature and team member
|
# Git automation
|
||||||
```
|
> Analyze git commits from the last 7 days, grouped by feature
|
||||||
|
> Create a changelog from recent commits
|
||||||
|
> Find all TODO comments and create GitHub issues
|
||||||
|
|
||||||
```sh
|
# File operations
|
||||||
> Convert all images in this directory to PNG format
|
> Convert all images in this directory to PNG format
|
||||||
|
> Rename all test files to follow the *.test.ts pattern
|
||||||
|
> Find and remove all console.log statements
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🐛 Debugging & Analysis
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Performance analysis
|
||||||
|
> Identify performance bottlenecks in this React component
|
||||||
|
> Find all N+1 query problems in the codebase
|
||||||
|
|
||||||
|
# Security audit
|
||||||
|
> Check for potential SQL injection vulnerabilities
|
||||||
|
> Find all hardcoded credentials or API keys
|
||||||
```
|
```
|
||||||
|
|
||||||
## Popular Tasks
|
## Popular Tasks
|
||||||
|
|
||||||
### Understand New Codebases
|
### 📚 Understand New Codebases
|
||||||
|
|
||||||
```text
|
```text
|
||||||
> What are the core business logic components?
|
> What are the core business logic components?
|
||||||
> What security mechanisms are in place?
|
> What security mechanisms are in place?
|
||||||
> How does the data flow work?
|
> How does the data flow through the system?
|
||||||
|
> What are the main design patterns used?
|
||||||
|
> Generate a dependency graph for this module
|
||||||
```
|
```
|
||||||
|
|
||||||
### Code Refactoring & Optimization
|
### 🔨 Code Refactoring & Optimization
|
||||||
|
|
||||||
```text
|
```text
|
||||||
> What parts of this module can be optimized?
|
> What parts of this module can be optimized?
|
||||||
> Help me refactor this class to follow better design patterns
|
> Help me refactor this class to follow SOLID principles
|
||||||
> Add proper error handling and logging
|
> Add proper error handling and logging
|
||||||
|
> Convert callbacks to async/await pattern
|
||||||
|
> Implement caching for expensive operations
|
||||||
```
|
```
|
||||||
|
|
||||||
### Documentation & Testing
|
### 📝 Documentation & Testing
|
||||||
|
|
||||||
```text
|
```text
|
||||||
> Generate comprehensive JSDoc comments for this function
|
> Generate comprehensive JSDoc comments for all public APIs
|
||||||
> Write unit tests for this component
|
> Write unit tests with edge cases for this component
|
||||||
> Create API documentation
|
> Create API documentation in OpenAPI format
|
||||||
|
> Add inline comments explaining complex algorithms
|
||||||
|
> Generate a README for this module
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 🚀 Development Acceleration
|
||||||
|
|
||||||
|
```text
|
||||||
|
> Set up a new Express server with authentication
|
||||||
|
> Create a React component with TypeScript and tests
|
||||||
|
> Implement a rate limiter middleware
|
||||||
|
> Add database migrations for new schema
|
||||||
|
> Configure CI/CD pipeline for this project
|
||||||
|
```
|
||||||
|
|
||||||
|
## Commands & Shortcuts
|
||||||
|
|
||||||
|
### Session Commands
|
||||||
|
- `/help` - Display available commands
|
||||||
|
- `/clear` - Clear conversation history
|
||||||
|
- `/compress` - Compress history to save tokens
|
||||||
|
- `/status` - Show current session information
|
||||||
|
- `/exit` or `/quit` - Exit Qwen Code
|
||||||
|
|
||||||
|
### Keyboard Shortcuts
|
||||||
|
- `Ctrl+C` - Cancel current operation
|
||||||
|
- `Ctrl+D` - Exit (on empty line)
|
||||||
|
- `Up/Down` - Navigate command history
|
||||||
|
|
||||||
## Benchmark Results
|
## Benchmark Results
|
||||||
|
|
||||||
### Terminal-Bench
|
### Terminal-Bench Performance
|
||||||
|
|
||||||
| Agent | Model | Accuracy |
|
| Agent | Model | Accuracy |
|
||||||
| --------- | ------------------ | -------- |
|
| --------- | ------------------ | -------- |
|
||||||
| Qwen Code | Qwen3-Coder-480A35 | 37.5 |
|
| Qwen Code | Qwen3-Coder-480A35 | 37.5% |
|
||||||
|
| Qwen Code | Qwen3-Coder-30BA3B | 31.3% |
|
||||||
## Project Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
qwen-code/
|
|
||||||
├── packages/ # Core packages
|
|
||||||
├── docs/ # Documentation
|
|
||||||
├── examples/ # Example code
|
|
||||||
└── tests/ # Test files
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development & Contributing
|
## Development & Contributing
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user