@qwen-code/qwen-code 0.14.0-preview.0 → 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 +55261 -35814
- package/locales/de.js +121 -5
- package/locales/en.js +118 -5
- package/locales/ja.js +117 -5
- package/locales/pt.js +120 -5
- package/locales/ru.js +119 -5
- package/locales/zh.js +111 -4
- package/package.json +2 -2
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# Headless Mode
|
|
2
|
+
|
|
3
|
+
Headless mode allows you to run Qwen Code programmatically from command line
|
|
4
|
+
scripts and automation tools without any interactive UI. This is ideal for
|
|
5
|
+
scripting, automation, CI/CD pipelines, and building AI-powered tools.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The headless mode provides a headless interface to Qwen Code that:
|
|
10
|
+
|
|
11
|
+
- Accepts prompts via command line arguments or stdin
|
|
12
|
+
- Returns structured output (text or JSON)
|
|
13
|
+
- Supports file redirection and piping
|
|
14
|
+
- Enables automation and scripting workflows
|
|
15
|
+
- Provides consistent exit codes for error handling
|
|
16
|
+
- Can resume previous sessions scoped to the current project for multi-step automation
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
### Direct Prompts
|
|
21
|
+
|
|
22
|
+
Use the `--prompt` (or `-p`) flag to run in headless mode:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
qwen --prompt "What is machine learning?"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Stdin Input
|
|
29
|
+
|
|
30
|
+
Pipe input to Qwen Code from your terminal:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
echo "Explain this code" | qwen
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Combining with File Input
|
|
37
|
+
|
|
38
|
+
Read from files and process with Qwen Code:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
cat README.md | qwen --prompt "Summarize this documentation"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Resume Previous Sessions (Headless)
|
|
45
|
+
|
|
46
|
+
Reuse conversation context from the current project in headless scripts:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Continue the most recent session for this project and run a new prompt
|
|
50
|
+
qwen --continue -p "Run the tests again and summarize failures"
|
|
51
|
+
|
|
52
|
+
# Resume a specific session ID directly (no UI)
|
|
53
|
+
qwen --resume 123e4567-e89b-12d3-a456-426614174000 -p "Apply the follow-up refactor"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> [!note]
|
|
57
|
+
>
|
|
58
|
+
> - Session data is project-scoped JSONL under `~/.qwen/projects/<sanitized-cwd>/chats`.
|
|
59
|
+
> - Restores conversation history, tool outputs, and chat-compression checkpoints before sending the new prompt.
|
|
60
|
+
|
|
61
|
+
## Customize the Main Session Prompt
|
|
62
|
+
|
|
63
|
+
You can change the main session system prompt for a single CLI run without editing shared memory files.
|
|
64
|
+
|
|
65
|
+
### Override the Built-in System Prompt
|
|
66
|
+
|
|
67
|
+
Use `--system-prompt` to replace Qwen Code's built-in main-session prompt for the current run:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
qwen -p "Review this patch" --system-prompt "You are a terse release reviewer. Report only blocking issues."
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Append Extra Instructions
|
|
74
|
+
|
|
75
|
+
Use `--append-system-prompt` to keep the built-in prompt and add extra instructions for this run:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
qwen -p "Review this patch" --append-system-prompt "Be terse and focus on concrete findings."
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You can combine both flags when you want a custom base prompt plus an extra run-specific instruction:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
qwen -p "Summarize this repository" \
|
|
85
|
+
--system-prompt "You are a migration planner." \
|
|
86
|
+
--append-system-prompt "Return exactly three bullets."
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
> [!note]
|
|
90
|
+
>
|
|
91
|
+
> - `--system-prompt` applies only to the current run's main session.
|
|
92
|
+
> - Loaded memory and context files such as `QWEN.md` are still appended after `--system-prompt`.
|
|
93
|
+
> - `--append-system-prompt` is applied after the built-in prompt and loaded memory, and can be used together with `--system-prompt`.
|
|
94
|
+
|
|
95
|
+
## Output Formats
|
|
96
|
+
|
|
97
|
+
Qwen Code supports multiple output formats for different use cases:
|
|
98
|
+
|
|
99
|
+
### Text Output (Default)
|
|
100
|
+
|
|
101
|
+
Standard human-readable output:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
qwen -p "What is the capital of France?"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Response format:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
The capital of France is Paris.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### JSON Output
|
|
114
|
+
|
|
115
|
+
Returns structured data as a JSON array. All messages are buffered and output together when the session completes. This format is ideal for programmatic processing and automation scripts.
|
|
116
|
+
|
|
117
|
+
The JSON output is an array of message objects. The output includes multiple message types: system messages (session initialization), assistant messages (AI responses), and result messages (execution summary).
|
|
118
|
+
|
|
119
|
+
#### Example Usage
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
qwen -p "What is the capital of France?" --output-format json
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Output (at end of execution):
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
[
|
|
129
|
+
{
|
|
130
|
+
"type": "system",
|
|
131
|
+
"subtype": "session_start",
|
|
132
|
+
"uuid": "...",
|
|
133
|
+
"session_id": "...",
|
|
134
|
+
"model": "qwen3-coder-plus",
|
|
135
|
+
...
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"type": "assistant",
|
|
139
|
+
"uuid": "...",
|
|
140
|
+
"session_id": "...",
|
|
141
|
+
"message": {
|
|
142
|
+
"id": "...",
|
|
143
|
+
"type": "message",
|
|
144
|
+
"role": "assistant",
|
|
145
|
+
"model": "qwen3-coder-plus",
|
|
146
|
+
"content": [
|
|
147
|
+
{
|
|
148
|
+
"type": "text",
|
|
149
|
+
"text": "The capital of France is Paris."
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"usage": {...}
|
|
153
|
+
},
|
|
154
|
+
"parent_tool_use_id": null
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"type": "result",
|
|
158
|
+
"subtype": "success",
|
|
159
|
+
"uuid": "...",
|
|
160
|
+
"session_id": "...",
|
|
161
|
+
"is_error": false,
|
|
162
|
+
"duration_ms": 1234,
|
|
163
|
+
"result": "The capital of France is Paris.",
|
|
164
|
+
"usage": {...}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Stream-JSON Output
|
|
170
|
+
|
|
171
|
+
Stream-JSON format emits JSON messages immediately as they occur during execution, enabling real-time monitoring. This format uses line-delimited JSON where each message is a complete JSON object on a single line.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
qwen -p "Explain TypeScript" --output-format stream-json
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Output (streaming as events occur):
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{"type":"system","subtype":"session_start","uuid":"...","session_id":"..."}
|
|
181
|
+
{"type":"assistant","uuid":"...","session_id":"...","message":{...}}
|
|
182
|
+
{"type":"result","subtype":"success","uuid":"...","session_id":"..."}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
When combined with `--include-partial-messages`, additional stream events are emitted in real-time (message_start, content_block_delta, etc.) for real-time UI updates.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
qwen -p "Write a Python script" --output-format stream-json --include-partial-messages
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Input Format
|
|
192
|
+
|
|
193
|
+
The `--input-format` parameter controls how Qwen Code consumes input from standard input:
|
|
194
|
+
|
|
195
|
+
- **`text`** (default): Standard text input from stdin or command-line arguments
|
|
196
|
+
- **`stream-json`**: JSON message protocol via stdin for bidirectional communication
|
|
197
|
+
|
|
198
|
+
> **Note:** Stream-json input mode is currently under construction and is intended for SDK integration. It requires `--output-format stream-json` to be set.
|
|
199
|
+
|
|
200
|
+
### File Redirection
|
|
201
|
+
|
|
202
|
+
Save output to files or pipe to other commands:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Save to file
|
|
206
|
+
qwen -p "Explain Docker" > docker-explanation.txt
|
|
207
|
+
qwen -p "Explain Docker" --output-format json > docker-explanation.json
|
|
208
|
+
|
|
209
|
+
# Append to file
|
|
210
|
+
qwen -p "Add more details" >> docker-explanation.txt
|
|
211
|
+
|
|
212
|
+
# Pipe to other tools
|
|
213
|
+
qwen -p "What is Kubernetes?" --output-format json | jq '.response'
|
|
214
|
+
qwen -p "Explain microservices" | wc -w
|
|
215
|
+
qwen -p "List programming languages" | grep -i "python"
|
|
216
|
+
|
|
217
|
+
# Stream-JSON output for real-time processing
|
|
218
|
+
qwen -p "Explain Docker" --output-format stream-json | jq '.type'
|
|
219
|
+
qwen -p "Write code" --output-format stream-json --include-partial-messages | jq '.event.type'
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Configuration Options
|
|
223
|
+
|
|
224
|
+
Key command-line options for headless usage:
|
|
225
|
+
|
|
226
|
+
| Option | Description | Example |
|
|
227
|
+
| ---------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
|
|
228
|
+
| `--prompt`, `-p` | Run in headless mode | `qwen -p "query"` |
|
|
229
|
+
| `--output-format`, `-o` | Specify output format (text, json, stream-json) | `qwen -p "query" --output-format json` |
|
|
230
|
+
| `--input-format` | Specify input format (text, stream-json) | `qwen --input-format text --output-format stream-json` |
|
|
231
|
+
| `--include-partial-messages` | Include partial messages in stream-json output | `qwen -p "query" --output-format stream-json --include-partial-messages` |
|
|
232
|
+
| `--system-prompt` | Override the main session system prompt for this run | `qwen -p "query" --system-prompt "You are a terse reviewer."` |
|
|
233
|
+
| `--append-system-prompt` | Append extra instructions to the main session system prompt for this run | `qwen -p "query" --append-system-prompt "Focus on concrete findings."` |
|
|
234
|
+
| `--debug`, `-d` | Enable debug mode | `qwen -p "query" --debug` |
|
|
235
|
+
| `--all-files`, `-a` | Include all files in context | `qwen -p "query" --all-files` |
|
|
236
|
+
| `--include-directories` | Include additional directories | `qwen -p "query" --include-directories src,docs` |
|
|
237
|
+
| `--yolo`, `-y` | Auto-approve all actions | `qwen -p "query" --yolo` |
|
|
238
|
+
| `--approval-mode` | Set approval mode | `qwen -p "query" --approval-mode auto_edit` |
|
|
239
|
+
| `--continue` | Resume the most recent session for this project | `qwen --continue -p "Pick up where we left off"` |
|
|
240
|
+
| `--resume [sessionId]` | Resume a specific session (or choose interactively) | `qwen --resume 123e... -p "Finish the refactor"` |
|
|
241
|
+
|
|
242
|
+
For complete details on all available configuration options, settings files, and environment variables, see the [Configuration Guide](../configuration/settings).
|
|
243
|
+
|
|
244
|
+
## Examples
|
|
245
|
+
|
|
246
|
+
### Code review
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
cat src/auth.py | qwen -p "Review this authentication code for security issues" > security-review.txt
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Generate commit messages
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
result=$(git diff --cached | qwen -p "Write a concise commit message for these changes" --output-format json)
|
|
256
|
+
echo "$result" | jq -r '.response'
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### API documentation
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
result=$(cat api/routes.js | qwen -p "Generate OpenAPI spec for these routes" --output-format json)
|
|
263
|
+
echo "$result" | jq -r '.response' > openapi.json
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Batch code analysis
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
for file in src/*.py; do
|
|
270
|
+
echo "Analyzing $file..."
|
|
271
|
+
result=$(cat "$file" | qwen -p "Find potential bugs and suggest improvements" --output-format json)
|
|
272
|
+
echo "$result" | jq -r '.response' > "reports/$(basename "$file").analysis"
|
|
273
|
+
echo "Completed analysis for $(basename "$file")" >> reports/progress.log
|
|
274
|
+
done
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### PR code review
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
result=$(git diff origin/main...HEAD | qwen -p "Review these changes for bugs, security issues, and code quality" --output-format json)
|
|
281
|
+
echo "$result" | jq -r '.response' > pr-review.json
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Log analysis
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
grep "ERROR" /var/log/app.log | tail -20 | qwen -p "Analyze these errors and suggest root cause and fixes" > error-analysis.txt
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Release notes generation
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
result=$(git log --oneline v1.0.0..HEAD | qwen -p "Generate release notes from these commits" --output-format json)
|
|
294
|
+
response=$(echo "$result" | jq -r '.response')
|
|
295
|
+
echo "$response"
|
|
296
|
+
echo "$response" >> CHANGELOG.md
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Model and tool usage tracking
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
result=$(qwen -p "Explain this database schema" --include-directories db --output-format json)
|
|
303
|
+
total_tokens=$(echo "$result" | jq -r '.stats.models // {} | to_entries | map(.value.tokens.total) | add // 0')
|
|
304
|
+
models_used=$(echo "$result" | jq -r '.stats.models // {} | keys | join(", ") | if . == "" then "none" else . end')
|
|
305
|
+
tool_calls=$(echo "$result" | jq -r '.stats.tools.totalCalls // 0')
|
|
306
|
+
tools_used=$(echo "$result" | jq -r '.stats.tools.byName // {} | keys | join(", ") | if . == "" then "none" else . end')
|
|
307
|
+
echo "$(date): $total_tokens tokens, $tool_calls tool calls ($tools_used) used with models: $models_used" >> usage.log
|
|
308
|
+
echo "$result" | jq -r '.response' > schema-docs.md
|
|
309
|
+
echo "Recent usage trends:"
|
|
310
|
+
tail -5 usage.log
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Resources
|
|
314
|
+
|
|
315
|
+
- [CLI Configuration](../configuration/settings#command-line-arguments) - Complete configuration guide
|
|
316
|
+
- [Authentication](../configuration/settings#environment-variables-for-api-access) - Setup authentication
|
|
317
|
+
- [Commands](../features/commands) - Interactive commands reference
|
|
318
|
+
- [Tutorials](../quickstart) - Step-by-step automation guides
|