@qwen-code/qwen-code 0.14.0-preview.1 → 0.14.0-preview.2
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.
- package/README.md +19 -9
- package/bundled/qc-helper/SKILL.md +151 -0
- package/bundled/qc-helper/docs/_meta.ts +30 -0
- package/bundled/qc-helper/docs/common-workflow.md +571 -0
- package/bundled/qc-helper/docs/configuration/_meta.ts +10 -0
- package/bundled/qc-helper/docs/configuration/auth.md +366 -0
- package/bundled/qc-helper/docs/configuration/memory.md +0 -0
- package/bundled/qc-helper/docs/configuration/model-providers.md +542 -0
- package/bundled/qc-helper/docs/configuration/qwen-ignore.md +55 -0
- package/bundled/qc-helper/docs/configuration/settings.md +655 -0
- package/bundled/qc-helper/docs/configuration/themes.md +160 -0
- package/bundled/qc-helper/docs/configuration/trusted-folders.md +61 -0
- package/bundled/qc-helper/docs/extension/_meta.ts +9 -0
- package/bundled/qc-helper/docs/extension/extension-releasing.md +121 -0
- package/bundled/qc-helper/docs/extension/getting-started-extensions.md +299 -0
- package/bundled/qc-helper/docs/extension/introduction.md +310 -0
- package/bundled/qc-helper/docs/features/_meta.ts +18 -0
- package/bundled/qc-helper/docs/features/approval-mode.md +263 -0
- package/bundled/qc-helper/docs/features/arena.md +218 -0
- package/bundled/qc-helper/docs/features/channels/_meta.ts +7 -0
- package/bundled/qc-helper/docs/features/channels/dingtalk.md +134 -0
- package/bundled/qc-helper/docs/features/channels/overview.md +336 -0
- package/bundled/qc-helper/docs/features/channels/plugins.md +87 -0
- package/bundled/qc-helper/docs/features/channels/telegram.md +120 -0
- package/bundled/qc-helper/docs/features/channels/weixin.md +106 -0
- package/bundled/qc-helper/docs/features/checkpointing.md +77 -0
- package/bundled/qc-helper/docs/features/commands.md +312 -0
- package/bundled/qc-helper/docs/features/headless.md +318 -0
- package/bundled/qc-helper/docs/features/hooks.md +715 -0
- package/bundled/qc-helper/docs/features/language.md +139 -0
- package/bundled/qc-helper/docs/features/lsp.md +417 -0
- package/bundled/qc-helper/docs/features/mcp.md +281 -0
- package/bundled/qc-helper/docs/features/sandbox.md +241 -0
- package/bundled/qc-helper/docs/features/skills.md +289 -0
- package/bundled/qc-helper/docs/features/sub-agents.md +511 -0
- package/bundled/qc-helper/docs/features/token-caching.md +29 -0
- package/bundled/qc-helper/docs/ide-integration/_meta.ts +4 -0
- package/bundled/qc-helper/docs/ide-integration/ide-companion-spec.md +182 -0
- package/bundled/qc-helper/docs/ide-integration/ide-integration.md +144 -0
- package/bundled/qc-helper/docs/integration-github-action.md +241 -0
- package/bundled/qc-helper/docs/integration-jetbrains.md +81 -0
- package/bundled/qc-helper/docs/integration-vscode.md +39 -0
- package/bundled/qc-helper/docs/integration-zed.md +72 -0
- package/bundled/qc-helper/docs/overview.md +64 -0
- package/bundled/qc-helper/docs/quickstart.md +273 -0
- package/bundled/qc-helper/docs/reference/_meta.ts +3 -0
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +72 -0
- package/bundled/qc-helper/docs/support/Uninstall.md +42 -0
- package/bundled/qc-helper/docs/support/_meta.ts +6 -0
- package/bundled/qc-helper/docs/support/tos-privacy.md +112 -0
- package/bundled/qc-helper/docs/support/troubleshooting.md +123 -0
- package/cli.js +4530 -3605
- package/locales/de.js +2 -2
- package/locales/en.js +2 -2
- package/locales/ja.js +2 -2
- package/locales/pt.js +2 -2
- package/locales/ru.js +2 -2
- package/locales/zh.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Checkpointing
|
|
2
|
+
|
|
3
|
+
Qwen Code includes a Checkpointing feature that automatically saves a snapshot of your project's state before any file modifications are made by AI-powered tools. This allows you to safely experiment with and apply code changes, knowing you can instantly revert back to the state before the tool was run.
|
|
4
|
+
|
|
5
|
+
## How It Works
|
|
6
|
+
|
|
7
|
+
When you approve a tool that modifies the file system (like `write_file` or `edit`), the CLI automatically creates a "checkpoint." This checkpoint includes:
|
|
8
|
+
|
|
9
|
+
1. **A Git Snapshot:** A commit is made in a special, shadow Git repository located in your home directory (`~/.qwen/history/<project_hash>`). This snapshot captures the complete state of your project files at that moment. It does **not** interfere with your own project's Git repository.
|
|
10
|
+
2. **Conversation History:** The entire conversation you've had with the agent up to that point is saved.
|
|
11
|
+
3. **The Tool Call:** The specific tool call that was about to be executed is also stored.
|
|
12
|
+
|
|
13
|
+
If you want to undo the change or simply go back, you can use the `/restore` command. Restoring a checkpoint will:
|
|
14
|
+
|
|
15
|
+
- Revert all files in your project to the state captured in the snapshot.
|
|
16
|
+
- Restore the conversation history in the CLI.
|
|
17
|
+
- Re-propose the original tool call, allowing you to run it again, modify it, or simply ignore it.
|
|
18
|
+
|
|
19
|
+
All checkpoint data, including the Git snapshot and conversation history, is stored locally on your machine. The Git snapshot is stored in the shadow repository while the conversation history and tool calls are saved in a JSON file in your project's temporary directory, typically located at `~/.qwen/tmp/<project_hash>/checkpoints`.
|
|
20
|
+
|
|
21
|
+
## Enabling the Feature
|
|
22
|
+
|
|
23
|
+
The Checkpointing feature is disabled by default. To enable it, you can either use a command-line flag or edit your `settings.json` file.
|
|
24
|
+
|
|
25
|
+
### Using the Command-Line Flag
|
|
26
|
+
|
|
27
|
+
You can enable checkpointing for the current session by using the `--checkpointing` flag when starting Qwen Code:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
qwen --checkpointing
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Using the `settings.json` File
|
|
34
|
+
|
|
35
|
+
To enable checkpointing by default for all sessions, you need to edit your `settings.json` file.
|
|
36
|
+
|
|
37
|
+
Add the following key to your `settings.json`:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"general": {
|
|
42
|
+
"checkpointing": {
|
|
43
|
+
"enabled": true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Using the `/restore` Command
|
|
50
|
+
|
|
51
|
+
Once enabled, checkpoints are created automatically. To manage them, you use the `/restore` command.
|
|
52
|
+
|
|
53
|
+
### List Available Checkpoints
|
|
54
|
+
|
|
55
|
+
To see a list of all saved checkpoints for the current project, simply run:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
/restore
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The CLI will display a list of available checkpoint files. These file names are typically composed of a timestamp, the name of the file being modified, and the name of the tool that was about to be run (e.g., `2025-06-22T10-00-00_000Z-my-file.txt-write_file`).
|
|
62
|
+
|
|
63
|
+
### Restore a Specific Checkpoint
|
|
64
|
+
|
|
65
|
+
To restore your project to a specific checkpoint, use the checkpoint file from the list:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
/restore <checkpoint_file>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For example:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
/restore 2025-06-22T10-00-00_000Z-my-file.txt-write_file
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
After running the command, your files and conversation will be immediately restored to the state they were in when the checkpoint was created, and the original tool prompt will reappear.
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# Commands
|
|
2
|
+
|
|
3
|
+
This document details all commands supported by Qwen Code, helping you efficiently manage sessions, customize the interface, and control its behavior.
|
|
4
|
+
|
|
5
|
+
Qwen Code commands are triggered through specific prefixes and fall into three categories:
|
|
6
|
+
|
|
7
|
+
| Prefix Type | Function Description | Typical Use Case |
|
|
8
|
+
| -------------------------- | --------------------------------------------------- | ---------------------------------------------------------------- |
|
|
9
|
+
| Slash Commands (`/`) | Meta-level control of Qwen Code itself | Managing sessions, modifying settings, getting help |
|
|
10
|
+
| At Commands (`@`) | Quickly inject local file content into conversation | Allowing AI to analyze specified files or code under directories |
|
|
11
|
+
| Exclamation Commands (`!`) | Direct interaction with system Shell | Executing system commands like `git status`, `ls`, etc. |
|
|
12
|
+
|
|
13
|
+
## 1. Slash Commands (`/`)
|
|
14
|
+
|
|
15
|
+
Slash commands are used to manage Qwen Code sessions, interface, and basic behavior.
|
|
16
|
+
|
|
17
|
+
### 1.1 Session and Project Management
|
|
18
|
+
|
|
19
|
+
These commands help you save, restore, and summarize work progress.
|
|
20
|
+
|
|
21
|
+
| Command | Description | Usage Examples |
|
|
22
|
+
| ----------- | --------------------------------------------------------- | ------------------------------------ |
|
|
23
|
+
| `/init` | Analyze current directory and create initial context file | `/init` |
|
|
24
|
+
| `/summary` | Generate project summary based on conversation history | `/summary` |
|
|
25
|
+
| `/compress` | Replace chat history with summary to save Tokens | `/compress` |
|
|
26
|
+
| `/resume` | Resume a previous conversation session | `/resume` |
|
|
27
|
+
| `/restore` | Restore files to state before tool execution | `/restore` (list) or `/restore <ID>` |
|
|
28
|
+
|
|
29
|
+
### 1.2 Interface and Workspace Control
|
|
30
|
+
|
|
31
|
+
Commands for adjusting interface appearance and work environment.
|
|
32
|
+
|
|
33
|
+
| Command | Description | Usage Examples |
|
|
34
|
+
| ------------ | ---------------------------------------- | ----------------------------- |
|
|
35
|
+
| `/clear` | Clear terminal screen content | `/clear` (shortcut: `Ctrl+L`) |
|
|
36
|
+
| `/context` | Show context window usage breakdown | `/context` |
|
|
37
|
+
| `/theme` | Change Qwen Code visual theme | `/theme` |
|
|
38
|
+
| `/vim` | Turn input area Vim editing mode on/off | `/vim` |
|
|
39
|
+
| `/directory` | Manage multi-directory support workspace | `/dir add ./src,./tests` |
|
|
40
|
+
| `/editor` | Open dialog to select supported editor | `/editor` |
|
|
41
|
+
|
|
42
|
+
### 1.3 Language Settings
|
|
43
|
+
|
|
44
|
+
Commands specifically for controlling interface and output language.
|
|
45
|
+
|
|
46
|
+
| Command | Description | Usage Examples |
|
|
47
|
+
| --------------------- | -------------------------------- | -------------------------- |
|
|
48
|
+
| `/language` | View or change language settings | `/language` |
|
|
49
|
+
| → `ui [language]` | Set UI interface language | `/language ui zh-CN` |
|
|
50
|
+
| → `output [language]` | Set LLM output language | `/language output Chinese` |
|
|
51
|
+
|
|
52
|
+
- Available built-in UI languages: `zh-CN` (Simplified Chinese), `en-US` (English), `ru-RU` (Russian), `de-DE` (German)
|
|
53
|
+
- Output language examples: `Chinese`, `English`, `Japanese`, etc.
|
|
54
|
+
|
|
55
|
+
### 1.4 Tool and Model Management
|
|
56
|
+
|
|
57
|
+
Commands for managing AI tools and models.
|
|
58
|
+
|
|
59
|
+
| Command | Description | Usage Examples |
|
|
60
|
+
| ---------------- | --------------------------------------------- | --------------------------------------------- |
|
|
61
|
+
| `/mcp` | List configured MCP servers and tools | `/mcp`, `/mcp desc` |
|
|
62
|
+
| `/tools` | Display currently available tool list | `/tools`, `/tools desc` |
|
|
63
|
+
| `/skills` | List and run available skills | `/skills`, `/skills <name>` |
|
|
64
|
+
| `/approval-mode` | Change approval mode for tool usage | `/approval-mode <mode (auto-edit)> --project` |
|
|
65
|
+
| →`plan` | Analysis only, no execution | Secure review |
|
|
66
|
+
| →`default` | Require approval for edits | Daily use |
|
|
67
|
+
| →`auto-edit` | Automatically approve edits | Trusted environment |
|
|
68
|
+
| →`yolo` | Automatically approve all | Quick prototyping |
|
|
69
|
+
| `/model` | Switch model used in current session | `/model` |
|
|
70
|
+
| `/extensions` | List all active extensions in current session | `/extensions` |
|
|
71
|
+
| `/memory` | Manage AI's instruction context | `/memory add Important Info` |
|
|
72
|
+
|
|
73
|
+
### 1.5 Information, Settings, and Help
|
|
74
|
+
|
|
75
|
+
Commands for obtaining information and performing system settings.
|
|
76
|
+
|
|
77
|
+
| Command | Description | Usage Examples |
|
|
78
|
+
| ----------- | ----------------------------------------------- | -------------------------------- |
|
|
79
|
+
| `/help` | Display help information for available commands | `/help` or `/?` |
|
|
80
|
+
| `/about` | Display version information | `/about` |
|
|
81
|
+
| `/stats` | Display detailed statistics for current session | `/stats` |
|
|
82
|
+
| `/settings` | Open settings editor | `/settings` |
|
|
83
|
+
| `/auth` | Change authentication method | `/auth` |
|
|
84
|
+
| `/bug` | Submit issue about Qwen Code | `/bug Button click unresponsive` |
|
|
85
|
+
| `/copy` | Copy last output content to clipboard | `/copy` |
|
|
86
|
+
| `/quit` | Exit Qwen Code immediately | `/quit` or `/exit` |
|
|
87
|
+
|
|
88
|
+
### 1.6 Common Shortcuts
|
|
89
|
+
|
|
90
|
+
| Shortcut | Function | Note |
|
|
91
|
+
| ------------------ | ----------------------- | ---------------------- |
|
|
92
|
+
| `Ctrl/cmd+L` | Clear screen | Equivalent to `/clear` |
|
|
93
|
+
| `Ctrl/cmd+T` | Toggle tool description | MCP tool management |
|
|
94
|
+
| `Ctrl/cmd+C`×2 | Exit confirmation | Secure exit mechanism |
|
|
95
|
+
| `Ctrl/cmd+Z` | Undo input | Text editing |
|
|
96
|
+
| `Ctrl/cmd+Shift+Z` | Redo input | Text editing |
|
|
97
|
+
|
|
98
|
+
### 1.7 CLI Auth Subcommands
|
|
99
|
+
|
|
100
|
+
In addition to the in-session `/auth` slash command, Qwen Code provides standalone CLI subcommands for managing authentication directly from the terminal:
|
|
101
|
+
|
|
102
|
+
| Command | Description |
|
|
103
|
+
| ---------------------------------------------------- | ------------------------------------------------- |
|
|
104
|
+
| `qwen auth` | Interactive authentication setup |
|
|
105
|
+
| `qwen auth qwen-oauth` | Authenticate with Qwen OAuth |
|
|
106
|
+
| `qwen auth coding-plan` | Authenticate with Alibaba Cloud Coding Plan |
|
|
107
|
+
| `qwen auth coding-plan --region china --key sk-sp-…` | Non-interactive Coding Plan setup (for scripting) |
|
|
108
|
+
| `qwen auth status` | Show current authentication status |
|
|
109
|
+
|
|
110
|
+
> [!tip]
|
|
111
|
+
>
|
|
112
|
+
> These commands run outside of a Qwen Code session. Use them to configure authentication before starting a session, or in scripts and CI environments. See the [Authentication](../configuration/auth) page for full details.
|
|
113
|
+
|
|
114
|
+
## 2. @ Commands (Introducing Files)
|
|
115
|
+
|
|
116
|
+
@ commands are used to quickly add local file or directory content to the conversation.
|
|
117
|
+
|
|
118
|
+
| Command Format | Description | Examples |
|
|
119
|
+
| ------------------- | -------------------------------------------- | ------------------------------------------------ |
|
|
120
|
+
| `@<file path>` | Inject content of specified file | `@src/main.py Please explain this code` |
|
|
121
|
+
| `@<directory path>` | Recursively read all text files in directory | `@docs/ Summarize content of this document` |
|
|
122
|
+
| Standalone `@` | Used when discussing `@` symbol itself | `@ What is this symbol used for in programming?` |
|
|
123
|
+
|
|
124
|
+
Note: Spaces in paths need to be escaped with backslash (e.g., `@My\ Documents/file.txt`)
|
|
125
|
+
|
|
126
|
+
## 3. Exclamation Commands (`!`) - Shell Command Execution
|
|
127
|
+
|
|
128
|
+
Exclamation commands allow you to execute system commands directly within Qwen Code.
|
|
129
|
+
|
|
130
|
+
| Command Format | Description | Examples |
|
|
131
|
+
| ------------------ | ------------------------------------------------------------------ | -------------------------------------- |
|
|
132
|
+
| `!<shell command>` | Execute command in sub-Shell | `!ls -la`, `!git status` |
|
|
133
|
+
| Standalone `!` | Switch Shell mode, any input is executed directly as Shell command | `!`(enter) → Input command → `!`(exit) |
|
|
134
|
+
|
|
135
|
+
Environment Variables: Commands executed via `!` will set the `QWEN_CODE=1` environment variable.
|
|
136
|
+
|
|
137
|
+
## 4. Custom Commands
|
|
138
|
+
|
|
139
|
+
Save frequently used prompts as shortcut commands to improve work efficiency and ensure consistency.
|
|
140
|
+
|
|
141
|
+
> [!note]
|
|
142
|
+
>
|
|
143
|
+
> Custom commands now use Markdown format with optional YAML frontmatter. TOML format is deprecated but still supported for backwards compatibility. When TOML files are detected, an automatic migration prompt will be displayed.
|
|
144
|
+
|
|
145
|
+
### Quick Overview
|
|
146
|
+
|
|
147
|
+
| Function | Description | Advantages | Priority | Applicable Scenarios |
|
|
148
|
+
| ---------------- | ------------------------------------------ | -------------------------------------- | -------- | ---------------------------------------------------- |
|
|
149
|
+
| Namespace | Subdirectory creates colon-named commands | Better command organization | | |
|
|
150
|
+
| Global Commands | `~/.qwen/commands/` | Available in all projects | Low | Personal frequently used commands, cross-project use |
|
|
151
|
+
| Project Commands | `<project root directory>/.qwen/commands/` | Project-specific, version-controllable | High | Team sharing, project-specific commands |
|
|
152
|
+
|
|
153
|
+
Priority Rules: Project commands > User commands (project command used when names are same)
|
|
154
|
+
|
|
155
|
+
### Command Naming Rules
|
|
156
|
+
|
|
157
|
+
#### File Path to Command Name Mapping Table
|
|
158
|
+
|
|
159
|
+
| File Location | Generated Command | Example Call |
|
|
160
|
+
| ---------------------------------------- | ----------------- | --------------------- |
|
|
161
|
+
| `~/.qwen/commands/test.md` | `/test` | `/test Parameter` |
|
|
162
|
+
| `<project>/.qwen/commands/git/commit.md` | `/git:commit` | `/git:commit Message` |
|
|
163
|
+
|
|
164
|
+
Naming Rules: Path separator (`/` or `\`) converted to colon (`:`)
|
|
165
|
+
|
|
166
|
+
### Markdown File Format Specification (Recommended)
|
|
167
|
+
|
|
168
|
+
Custom commands use Markdown files with optional YAML frontmatter:
|
|
169
|
+
|
|
170
|
+
```markdown
|
|
171
|
+
---
|
|
172
|
+
description: Optional description (displayed in /help)
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
Your prompt content here.
|
|
176
|
+
Use {{args}} for parameter injection.
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
| Field | Required | Description | Example |
|
|
180
|
+
| ------------- | -------- | ---------------------------------------- | ------------------------------------------ |
|
|
181
|
+
| `description` | Optional | Command description (displayed in /help) | `description: Code analysis tool` |
|
|
182
|
+
| Prompt body | Required | Prompt content sent to model | Any Markdown content after the frontmatter |
|
|
183
|
+
|
|
184
|
+
### TOML File Format (Deprecated)
|
|
185
|
+
|
|
186
|
+
> [!warning]
|
|
187
|
+
>
|
|
188
|
+
> **Deprecated:** TOML format is still supported but will be removed in a future version. Please migrate to Markdown format.
|
|
189
|
+
|
|
190
|
+
| Field | Required | Description | Example |
|
|
191
|
+
| ------------- | -------- | ---------------------------------------- | ------------------------------------------ |
|
|
192
|
+
| `prompt` | Required | Prompt content sent to model | `prompt = "Please analyze code: {{args}}"` |
|
|
193
|
+
| `description` | Optional | Command description (displayed in /help) | `description = "Code analysis tool"` |
|
|
194
|
+
|
|
195
|
+
### Parameter Processing Mechanism
|
|
196
|
+
|
|
197
|
+
| Processing Method | Syntax | Applicable Scenarios | Security Features |
|
|
198
|
+
| ---------------------------- | ------------------ | ------------------------------------ | -------------------------------------- |
|
|
199
|
+
| Context-aware Injection | `{{args}}` | Need precise parameter control | Automatic Shell escaping |
|
|
200
|
+
| Default Parameter Processing | No special marking | Simple commands, parameter appending | Append as-is |
|
|
201
|
+
| Shell Command Injection | `!{command}` | Need dynamic content | Execution confirmation required before |
|
|
202
|
+
|
|
203
|
+
#### 1. Context-aware Injection (`{{args}}`)
|
|
204
|
+
|
|
205
|
+
| Scenario | TOML Configuration | Call Method | Actual Effect |
|
|
206
|
+
| ---------------- | --------------------------------------- | --------------------- | ------------------------ |
|
|
207
|
+
| Raw Injection | `prompt = "Fix: {{args}}"` | `/fix "Button issue"` | `Fix: "Button issue"` |
|
|
208
|
+
| In Shell Command | `prompt = "Search: !{grep {{args}} .}"` | `/search "hello"` | Execute `grep "hello" .` |
|
|
209
|
+
|
|
210
|
+
#### 2. Default Parameter Processing
|
|
211
|
+
|
|
212
|
+
| Input Situation | Processing Method | Example |
|
|
213
|
+
| --------------- | ------------------------------------------------------ | ---------------------------------------------- |
|
|
214
|
+
| Has parameters | Append to end of prompt (separated by two line breaks) | `/cmd parameter` → Original prompt + parameter |
|
|
215
|
+
| No parameters | Send prompt as is | `/cmd` → Original prompt |
|
|
216
|
+
|
|
217
|
+
🚀 Dynamic Content Injection
|
|
218
|
+
|
|
219
|
+
| Injection Type | Syntax | Processing Order | Purpose |
|
|
220
|
+
| --------------------- | -------------- | ------------------- | -------------------------------- |
|
|
221
|
+
| File Content | `@{file path}` | Processed first | Inject static reference files |
|
|
222
|
+
| Shell Commands | `!{command}` | Processed in middle | Inject dynamic execution results |
|
|
223
|
+
| Parameter Replacement | `{{args}}` | Processed last | Inject user parameters |
|
|
224
|
+
|
|
225
|
+
#### 3. Shell Command Execution (`!{...}`)
|
|
226
|
+
|
|
227
|
+
| Operation | User Interaction |
|
|
228
|
+
| ------------------------------- | -------------------- |
|
|
229
|
+
| 1. Parse command and parameters | - |
|
|
230
|
+
| 2. Automatic Shell escaping | - |
|
|
231
|
+
| 3. Show confirmation dialog | ✅ User confirmation |
|
|
232
|
+
| 4. Execute command | - |
|
|
233
|
+
| 5. Inject output to prompt | - |
|
|
234
|
+
|
|
235
|
+
Example: Git Commit Message Generation
|
|
236
|
+
|
|
237
|
+
````markdown
|
|
238
|
+
---
|
|
239
|
+
description: Generate Commit message based on staged changes
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
Please generate a Commit message based on the following diff:
|
|
243
|
+
|
|
244
|
+
```diff
|
|
245
|
+
!{git diff --staged}
|
|
246
|
+
```
|
|
247
|
+
````
|
|
248
|
+
|
|
249
|
+
#### 4. File Content Injection (`@{...}`)
|
|
250
|
+
|
|
251
|
+
| File Type | Support Status | Processing Method |
|
|
252
|
+
| ------------ | ---------------------- | --------------------------- |
|
|
253
|
+
| Text Files | ✅ Full Support | Directly inject content |
|
|
254
|
+
| Images/PDF | ✅ Multi-modal Support | Encode and inject |
|
|
255
|
+
| Binary Files | ⚠️ Limited Support | May be skipped or truncated |
|
|
256
|
+
| Directory | ✅ Recursive Injection | Follow .gitignore rules |
|
|
257
|
+
|
|
258
|
+
Example: Code Review Command
|
|
259
|
+
|
|
260
|
+
```markdown
|
|
261
|
+
---
|
|
262
|
+
description: Code review based on best practices
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
Review {{args}}, reference standards:
|
|
266
|
+
|
|
267
|
+
@{docs/code-standards.md}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Practical Creation Example
|
|
271
|
+
|
|
272
|
+
#### "Pure Function Refactoring" Command Creation Steps Table
|
|
273
|
+
|
|
274
|
+
| Operation | Command/Code |
|
|
275
|
+
| ----------------------------- | ----------------------------------------- |
|
|
276
|
+
| 1. Create directory structure | `mkdir -p ~/.qwen/commands/refactor` |
|
|
277
|
+
| 2. Create command file | `touch ~/.qwen/commands/refactor/pure.md` |
|
|
278
|
+
| 3. Edit command content | Refer to the complete code below. |
|
|
279
|
+
| 4. Test command | `@file.js` → `/refactor:pure` |
|
|
280
|
+
|
|
281
|
+
```markdown
|
|
282
|
+
---
|
|
283
|
+
description: Refactor code to pure function
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
Please analyze code in current context, refactor to pure function.
|
|
287
|
+
Requirements:
|
|
288
|
+
|
|
289
|
+
1. Provide refactored code
|
|
290
|
+
2. Explain key changes and pure function characteristic implementation
|
|
291
|
+
3. Maintain function unchanged
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Custom Command Best Practices Summary
|
|
295
|
+
|
|
296
|
+
#### Command Design Recommendations Table
|
|
297
|
+
|
|
298
|
+
| Practice Points | Recommended Approach | Avoid |
|
|
299
|
+
| -------------------- | ----------------------------------- | ------------------------------------------- |
|
|
300
|
+
| Command Naming | Use namespaces for organization | Avoid overly generic names |
|
|
301
|
+
| Parameter Processing | Clearly use `{{args}}` | Rely on default appending (easy to confuse) |
|
|
302
|
+
| Error Handling | Utilize Shell error output | Ignore execution failure |
|
|
303
|
+
| File Organization | Organize by function in directories | All commands in root directory |
|
|
304
|
+
| Description Field | Always provide clear description | Rely on auto-generated description |
|
|
305
|
+
|
|
306
|
+
#### Security Features Reminder Table
|
|
307
|
+
|
|
308
|
+
| Security Mechanism | Protection Effect | User Operation |
|
|
309
|
+
| ---------------------- | -------------------------- | ---------------------- |
|
|
310
|
+
| Shell Escaping | Prevent command injection | Automatic processing |
|
|
311
|
+
| Execution Confirmation | Avoid accidental execution | Dialog confirmation |
|
|
312
|
+
| Error Reporting | Help diagnose issues | View error information |
|