@mmmbuto/qwen-code-termux 0.14.1-termux → 0.15.5-termux

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 (41) hide show
  1. package/README.md +1 -1
  2. package/bundled/batch/SKILL.md +304 -0
  3. package/bundled/loop/SKILL.md +1 -0
  4. package/bundled/qc-helper/SKILL.md +1 -0
  5. package/bundled/qc-helper/docs/configuration/auth.md +13 -6
  6. package/bundled/qc-helper/docs/configuration/settings.md +173 -108
  7. package/bundled/qc-helper/docs/features/_meta.ts +6 -0
  8. package/bundled/qc-helper/docs/features/approval-mode.md +16 -8
  9. package/bundled/qc-helper/docs/features/arena.md +3 -2
  10. package/bundled/qc-helper/docs/features/code-review.md +279 -0
  11. package/bundled/qc-helper/docs/features/commands.md +96 -26
  12. package/bundled/qc-helper/docs/features/dual-output.md +593 -0
  13. package/bundled/qc-helper/docs/features/followup-suggestions.md +6 -6
  14. package/bundled/qc-helper/docs/features/headless.md +61 -0
  15. package/bundled/qc-helper/docs/features/hooks.md +408 -120
  16. package/bundled/qc-helper/docs/features/mcp.md +100 -14
  17. package/bundled/qc-helper/docs/features/memory.md +168 -0
  18. package/bundled/qc-helper/docs/features/sandbox.md +9 -1
  19. package/bundled/qc-helper/docs/features/status-line.md +261 -0
  20. package/bundled/qc-helper/docs/features/sub-agents.md +126 -7
  21. package/bundled/qc-helper/docs/features/tips.md +54 -0
  22. package/bundled/qc-helper/docs/features/tool-use-summaries.md +178 -0
  23. package/bundled/qc-helper/docs/overview.md +4 -4
  24. package/bundled/qc-helper/docs/quickstart.md +15 -9
  25. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +1 -1
  26. package/bundled/qc-helper/docs/support/tos-privacy.md +1 -1
  27. package/bundled/qc-helper/docs/support/troubleshooting.md +9 -3
  28. package/bundled/review/DESIGN.md +165 -0
  29. package/bundled/review/SKILL.md +359 -88
  30. package/cli.js +296184 -260145
  31. package/locales/ca.js +2143 -0
  32. package/locales/de.js +104 -14
  33. package/locales/en.js +113 -13
  34. package/locales/fr.js +2099 -0
  35. package/locales/ja.js +103 -14
  36. package/locales/pt.js +105 -14
  37. package/locales/ru.js +103 -14
  38. package/locales/zh-TW.js +1678 -0
  39. package/locales/zh.js +110 -13
  40. package/package.json +2 -2
  41. package/bundled/qc-helper/docs/configuration/memory.md +0 -0
@@ -153,6 +153,84 @@ qwen mcp add --transport sse sseServer http://localhost:8080/sse --timeout 30000
153
153
 
154
154
  - **Server trust** (`trust: true`): bypasses confirmation prompts for that server (use sparingly).
155
155
 
156
+ ### OAuth authentication
157
+
158
+ Qwen Code supports OAuth 2.0 authentication for MCP servers. This is useful when accessing remote servers that require authentication.
159
+
160
+ #### Basic usage
161
+
162
+ When you add an MCP server with OAuth credentials, Qwen Code will automatically handle the authentication flow:
163
+
164
+ ```bash
165
+ qwen mcp add --transport sse oauth-server https://api.example.com/sse/ \
166
+ --oauth-client-id your-client-id \
167
+ --oauth-redirect-uri https://your-server.com/oauth/callback \
168
+ --oauth-authorization-url https://provider.example.com/authorize \
169
+ --oauth-token-url https://provider.example.com/token
170
+ ```
171
+
172
+ #### Important: Redirect URI configuration
173
+
174
+ The OAuth flow requires a redirect URI where the authorization provider sends the authentication code.
175
+
176
+ - **Local development**: By default, Qwen Code uses `http://localhost:7777/oauth/callback`. This works when running Qwen Code on your local machine with a local browser.
177
+
178
+ - **Remote/cloud deployments**: When running Qwen Code on remote servers, cloud IDEs, or web terminals, the default `localhost` redirect will NOT work. You MUST configure `--oauth-redirect-uri` to point to a publicly accessible URL that can receive the OAuth callback.
179
+
180
+ Example for remote servers:
181
+
182
+ ```bash
183
+ qwen mcp add --transport sse remote-server https://api.example.com/sse/ \
184
+ --oauth-redirect-uri https://your-remote-server.example.com/oauth/callback
185
+ ```
186
+
187
+ #### Manual configuration via settings.json
188
+
189
+ You can also configure OAuth by editing `settings.json` directly:
190
+
191
+ ```json
192
+ {
193
+ "mcpServers": {
194
+ "oauthServer": {
195
+ "url": "https://api.example.com/sse/",
196
+ "oauth": {
197
+ "enabled": true,
198
+ "clientId": "your-client-id",
199
+ "clientSecret": "your-client-secret",
200
+ "authorizationUrl": "https://provider.example.com/authorize",
201
+ "tokenUrl": "https://provider.example.com/token",
202
+ "redirectUri": "https://your-server.com/oauth/callback",
203
+ "scopes": ["read", "write"]
204
+ }
205
+ }
206
+ }
207
+ }
208
+ ```
209
+
210
+ OAuth configuration properties:
211
+
212
+ | Property | Description |
213
+ | ------------------ | --------------------------------------------------------------------------------------------------------------------- |
214
+ | `enabled` | Enable OAuth for this server (boolean) |
215
+ | `clientId` | OAuth client identifier (string, optional with dynamic registration) |
216
+ | `clientSecret` | OAuth client secret (string, optional for public clients) |
217
+ | `authorizationUrl` | OAuth authorization endpoint (string, auto-discovered if omitted) |
218
+ | `tokenUrl` | OAuth token endpoint (string, auto-discovered if omitted) |
219
+ | `scopes` | Required OAuth scopes (array of strings) |
220
+ | `redirectUri` | Custom redirect URI (string). **Critical for remote deployments**. Defaults to `http://localhost:7777/oauth/callback` |
221
+ | `tokenParamName` | Query parameter name for tokens in SSE URLs (string) |
222
+ | `audiences` | Audiences the token is valid for (array of strings) |
223
+
224
+ #### Token management
225
+
226
+ OAuth tokens are automatically:
227
+
228
+ - **Stored securely** in `~/.qwen/mcp-oauth-tokens.json`
229
+ - **Refreshed** when expired (if refresh tokens are available)
230
+ - **Validated** before each connection attempt
231
+
232
+ Use the `/mcp auth` command within Qwen Code to manage OAuth authentication interactively.
233
+
156
234
  ### Tool filtering (allow/deny tools per server)
157
235
 
158
236
  Use `includeTools` / `excludeTools` to restrict tools exposed by a server (from Qwen Code’s perspective).
@@ -259,20 +337,28 @@ You can always configure MCP servers by manually editing `settings.json`, but th
259
337
  qwen mcp add [options] <name> <commandOrUrl> [args...]
260
338
  ```
261
339
 
262
- | Argument/Option | Description | Default | Example |
263
- | ------------------- | ------------------------------------------------------------------- | ------------------ | ----------------------------------------- |
264
- | `<name>` | A unique name for the server. | — | `example-server` |
265
- | `<commandOrUrl>` | The command to execute (for `stdio`) or the URL (for `http`/`sse`). | — | `/usr/bin/python` or `http://localhost:8` |
266
- | `[args...]` | Optional arguments for a `stdio` command. | — | `--port 5000` |
267
- | `-s`, `--scope` | Configuration scope (user or project). | `project` | `-s user` |
268
- | `-t`, `--transport` | Transport type (`stdio`, `sse`, `http`). | `stdio` | `-t sse` |
269
- | `-e`, `--env` | Set environment variables. | — | `-e KEY=value` |
270
- | `-H`, `--header` | Set HTTP headers for SSE and HTTP transports. | — | `-H "X-Api-Key: abc123"` |
271
- | `--timeout` | Set connection timeout in milliseconds. | — | `--timeout 30000` |
272
- | `--trust` | Trust the server (bypass all tool call confirmation prompts). | — (`false`) | `--trust` |
273
- | `--description` | Set the description for the server. | — | `--description "Local tools"` |
274
- | `--include-tools` | A comma-separated list of tools to include. | all tools included | `--include-tools mytool,othertool` |
275
- | `--exclude-tools` | A comma-separated list of tools to exclude. | none | `--exclude-tools mytool` |
340
+ | Argument/Option | Description | Default | Example |
341
+ | --------------------------- | ------------------------------------------------------------------- | -------------------------------------- | ------------------------------------------------------------------ |
342
+ | `<name>` | A unique name for the server. | — | `example-server` |
343
+ | `<commandOrUrl>` | The command to execute (for `stdio`) or the URL (for `http`/`sse`). | — | `/usr/bin/python` or `http://localhost:8` |
344
+ | `[args...]` | Optional arguments for a `stdio` command. | — | `--port 5000` |
345
+ | `-s`, `--scope` | Configuration scope (user or project). | `project` | `-s user` |
346
+ | `-t`, `--transport` | Transport type (`stdio`, `sse`, `http`). | `stdio` | `-t sse` |
347
+ | `-e`, `--env` | Set environment variables. | — | `-e KEY=value` |
348
+ | `-H`, `--header` | Set HTTP headers for SSE and HTTP transports. | — | `-H "X-Api-Key: abc123"` |
349
+ | `--timeout` | Set connection timeout in milliseconds. | — | `--timeout 30000` |
350
+ | `--trust` | Trust the server (bypass all tool call confirmation prompts). | — (`false`) | `--trust` |
351
+ | `--description` | Set the description for the server. | — | `--description "Local tools"` |
352
+ | `--include-tools` | A comma-separated list of tools to include. | all tools included | `--include-tools mytool,othertool` |
353
+ | `--exclude-tools` | A comma-separated list of tools to exclude. | none | `--exclude-tools mytool` |
354
+ | `--oauth-client-id` | OAuth client ID for MCP server authentication. | — | `--oauth-client-id your-client-id` |
355
+ | `--oauth-client-secret` | OAuth client secret for MCP server authentication. | — | `--oauth-client-secret your-client-secret` |
356
+ | `--oauth-redirect-uri` | OAuth redirect URI for authentication callback. | `http://localhost:7777/oauth/callback` | `--oauth-redirect-uri https://your-server.com/oauth/callback` |
357
+ | `--oauth-authorization-url` | OAuth authorization URL. | — | `--oauth-authorization-url https://provider.example.com/authorize` |
358
+ | `--oauth-token-url` | OAuth token URL. | — | `--oauth-token-url https://provider.example.com/token` |
359
+ | `--oauth-scopes` | OAuth scopes (comma-separated). | — | `--oauth-scopes scope1,scope2` |
360
+
361
+ > `--oauth-*` flags apply only to `--transport sse` and `--transport http`. Combining them with `--transport stdio` is rejected.
276
362
 
277
363
  #### Removing a server (`qwen mcp remove`)
278
364
 
@@ -0,0 +1,168 @@
1
+ # Memory
2
+
3
+ Every Qwen Code session starts with a fresh context window. Two mechanisms carry knowledge across sessions so you don't have to re-explain yourself every time:
4
+
5
+ - **QWEN.md** — instructions _you_ write once and Qwen reads every session
6
+ - **Auto-memory** — notes Qwen writes itself based on what it learns from you
7
+
8
+ ---
9
+
10
+ ## QWEN.md: your instructions to Qwen
11
+
12
+ QWEN.md is a plain text file where you write things Qwen should always know about your project or your preferences. Think of it as a permanent briefing that loads at the start of every conversation.
13
+
14
+ ### What to put in QWEN.md
15
+
16
+ Add things you'd otherwise have to repeat every session:
17
+
18
+ - Build and test commands (`npm run test`, `make build`)
19
+ - Coding conventions your team follows ("all new files must have JSDoc comments")
20
+ - Architectural decisions ("we use the repository pattern, never call the database directly from controllers")
21
+ - Personal preferences ("always use pnpm, not npm")
22
+
23
+ Don't include things Qwen can figure out by reading your code. QWEN.md works best when it's short and specific — the longer it gets, the less reliably Qwen follows it.
24
+
25
+ ### Where to create QWEN.md
26
+
27
+ | File | Who it applies to |
28
+ | ----------------------------- | --------------------------------------------- |
29
+ | `~/.qwen/QWEN.md` | You, across all your projects |
30
+ | `QWEN.md` in the project root | Your whole team (commit it to source control) |
31
+
32
+ You can have both. Qwen loads all QWEN.md files it finds when you start a session — your personal one plus any in the project.
33
+
34
+ If your repository already has an `AGENTS.md` file for other AI tools, Qwen reads that too. No need to duplicate instructions.
35
+
36
+ ### Generate one automatically with `/init`
37
+
38
+ Run `/init` and Qwen will analyze your codebase to create a starter QWEN.md with build commands, test instructions, and conventions it finds. If one already exists, it suggests additions instead of overwriting.
39
+
40
+ ### Reference other files
41
+
42
+ You can point QWEN.md at other files so Qwen reads them too:
43
+
44
+ ```markdown
45
+ See @README.md for project overview.
46
+
47
+ # Conventions
48
+
49
+ - Git workflow: @docs/git-workflow.md
50
+ ```
51
+
52
+ Use `@path/to/file` anywhere in QWEN.md. Relative paths resolve from the QWEN.md file itself.
53
+
54
+ ---
55
+
56
+ ## Auto-memory: what Qwen learns about you
57
+
58
+ Auto-memory runs in the background. After each of your conversations, Qwen quietly saves useful things it learned — your preferences, feedback you gave, project context — so it can use them in future sessions without you repeating yourself.
59
+
60
+ This is different from QWEN.md: you don't write it, Qwen does.
61
+
62
+ ### What Qwen saves
63
+
64
+ Qwen looks for four kinds of things worth remembering:
65
+
66
+ | What | Examples |
67
+ | ----------------------- | -------------------------------------------------------- |
68
+ | **About you** | Your role, background, how you like to work |
69
+ | **Your feedback** | Corrections you made, approaches you confirmed |
70
+ | **Project context** | Ongoing work, decisions, goals not obvious from the code |
71
+ | **External references** | Dashboards, ticket trackers, docs links you mentioned |
72
+
73
+ Qwen doesn't save everything — only things that would actually be useful next time.
74
+
75
+ ### Where it's stored
76
+
77
+ Auto-memory files live at `~/.qwen/projects/<project>/memory/`. All branches and worktrees of the same repository share the same memory folder, so what Qwen learns in one branch is available in others.
78
+
79
+ Everything saved is plain markdown — you can open, edit, or delete any file at any time.
80
+
81
+ ### Periodic cleanup
82
+
83
+ Qwen periodically goes through its saved memories to remove duplicates and clean up outdated entries. This runs automatically in the background once a day after enough sessions have accumulated. You can trigger it manually with `/dream` if you want it to run now.
84
+
85
+ While cleanup is running, **✦ dreaming** appears in the corner of the screen. Your session continues normally.
86
+
87
+ ### Turning it on or off
88
+
89
+ Auto-memory is on by default. To toggle it, open `/memory` and use the switches at the top. You can turn off just the automatic saving, just the periodic cleanup, or both.
90
+
91
+ You can also set them in `~/.qwen/settings.json` (applies to all projects) or `.qwen/settings.json` (this project only):
92
+
93
+ ```json
94
+ {
95
+ "memory": {
96
+ "enableManagedAutoMemory": true,
97
+ "enableManagedAutoDream": true
98
+ }
99
+ }
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Commands
105
+
106
+ ### `/memory`
107
+
108
+ Opens the Memory panel. From here you can:
109
+
110
+ - Turn auto-memory saving on or off
111
+ - Turn periodic cleanup (dream) on or off
112
+ - Open your personal QWEN.md (`~/.qwen/QWEN.md`)
113
+ - Open the project QWEN.md
114
+ - Browse the auto-memory folder
115
+
116
+ ### `/init`
117
+
118
+ Generates a starter QWEN.md for your project. Qwen reads your codebase and fills in build commands, test instructions, and conventions it discovers.
119
+
120
+ ### `/remember <text>`
121
+
122
+ Immediately saves something to auto-memory without waiting for Qwen to pick it up automatically:
123
+
124
+ ```
125
+ /remember always use snake_case for Python variable names
126
+ /remember the staging environment is at staging.example.com
127
+ ```
128
+
129
+ ### `/forget <text>`
130
+
131
+ Removes auto-memory entries that match your description:
132
+
133
+ ```
134
+ /forget old workaround for the login bug
135
+ ```
136
+
137
+ ### `/dream`
138
+
139
+ Runs the memory cleanup now instead of waiting for the automatic schedule:
140
+
141
+ ```
142
+ /dream
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Troubleshooting
148
+
149
+ ### Qwen isn't following my QWEN.md
150
+
151
+ Open `/memory` to see which files are loaded. If your file isn't listed, Qwen can't see it — make sure it's in the project root or `~/.qwen/`.
152
+
153
+ Instructions work better when they're specific:
154
+
155
+ - ✓ `Use 2-space indentation for TypeScript files`
156
+ - ✗ `Format code nicely`
157
+
158
+ If you have multiple QWEN.md files with conflicting instructions, Qwen may behave inconsistently. Review them and remove any contradictions.
159
+
160
+ ### I want to see what Qwen has saved
161
+
162
+ Run `/memory` and select **Open auto-memory folder**. All saved memories are readable markdown files you can browse, edit, or delete.
163
+
164
+ ### Qwen keeps forgetting things
165
+
166
+ If auto-memory is on but Qwen doesn't seem to remember things across sessions, try running `/dream` to force a cleanup pass. Also check `/memory` to confirm both toggles are enabled.
167
+
168
+ For things you always want Qwen to remember, add them to QWEN.md instead — auto-memory is best-effort, QWEN.md is guaranteed.
@@ -103,8 +103,16 @@ qwen -p "run the test suite"
103
103
 
104
104
  - **CLI flag**: `--sandbox-image <image>`
105
105
  - **Environment variable**: `QWEN_SANDBOX_IMAGE=<image>`
106
+ - **Settings file**: `tools.sandboxImage` in your `settings.json` (e.g., `{"tools": {"sandboxImage": "ghcr.io/qwenlm/qwen-code:0.14.1"}}`)
106
107
 
107
- If you don’t set either, Qwen Code uses the default image configured in the CLI package (for example `ghcr.io/qwenlm/qwen-code:<version>`).
108
+ Priority order (highest to lowest):
109
+
110
+ 1. `--sandbox-image`
111
+ 2. `QWEN_SANDBOX_IMAGE`
112
+ 3. `tools.sandboxImage`
113
+ 4. Built-in default image from the CLI package (for example `ghcr.io/qwenlm/qwen-code:<version>`)
114
+
115
+ `settings.env.QWEN_SANDBOX_IMAGE` also works as a generic env injection mechanism, but `tools.sandboxImage` is the preferred persistent setting.
108
116
 
109
117
  ### macOS Seatbelt profiles
110
118
 
@@ -0,0 +1,261 @@
1
+ # Status Line
2
+
3
+ > Display custom information in the footer using a shell command.
4
+
5
+ The status line lets you run a shell command whose output is displayed in the footer's left section. The command receives structured JSON context via stdin, so it can show session-aware information like the current model, token usage, git branch, or anything else you can script.
6
+
7
+ ```
8
+ Single-line status (default approval mode — 1 row):
9
+ ┌─────────────────────────────────────────────────────────────────┐
10
+ │ user@host ~/project (main) ctx:34% 🔒 docker | Debug | 67% │ ← status line
11
+ └─────────────────────────────────────────────────────────────────┘
12
+
13
+ Multi-line status (up to 2 lines — 2 rows):
14
+ ┌─────────────────────────────────────────────────────────────────┐
15
+ │ user@host ~/project (main) ctx:34% 🔒 docker | Debug | 67% │ ← status line 1
16
+ │ ████████░░░░░░░░░░ 34% context │ ← status line 2
17
+ └─────────────────────────────────────────────────────────────────┘
18
+
19
+ Multi-line status + non-default mode (3 rows max):
20
+ ┌─────────────────────────────────────────────────────────────────┐
21
+ │ user@host ~/project (main) ctx:34% 🔒 docker | Debug | 67% │ ← status line 1
22
+ │ ████████░░░░░░░░░░ 34% context │ ← status line 2
23
+ │ auto-accept edits (shift + tab to cycle) │ ← mode indicator
24
+ └─────────────────────────────────────────────────────────────────┘
25
+ ```
26
+
27
+ When configured, the status line replaces the default "? for shortcuts" hint. High-priority messages (Ctrl+C/D exit prompts, Esc, vim INSERT mode) temporarily override the status line. The status line text is truncated to fit within the available width.
28
+
29
+ ## Prerequisites
30
+
31
+ - [`jq`](https://jqlang.github.io/jq/) is recommended for parsing the JSON input (install via `brew install jq`, `apt install jq`, etc.)
32
+ - Simple commands that don't need JSON data (e.g. `git branch --show-current`) work without `jq`
33
+
34
+ ## Quick setup
35
+
36
+ The easiest way to configure a status line is the `/statusline` command. It launches a setup agent that reads your shell PS1 configuration and generates a matching status line:
37
+
38
+ ```
39
+ /statusline
40
+ ```
41
+
42
+ You can also give it specific instructions:
43
+
44
+ ```
45
+ /statusline show model name and context usage percentage
46
+ ```
47
+
48
+ ## Manual configuration
49
+
50
+ Add a `statusLine` object under the `ui` key in `~/.qwen/settings.json`:
51
+
52
+ ```json
53
+ {
54
+ "ui": {
55
+ "statusLine": {
56
+ "type": "command",
57
+ "command": "input=$(cat); model=$(echo \"$input\" | jq -r '.model.display_name'); pct=$(echo \"$input\" | jq -r '.context_window.used_percentage'); echo \"$model ctx:${pct}%\""
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ | Field | Type | Required | Description |
64
+ | ----------------- | ----------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
65
+ | `type` | `"command"` | Yes | Must be `"command"` |
66
+ | `command` | string | Yes | Shell command to execute. Receives JSON via stdin, stdout is displayed (up to 2 lines). |
67
+ | `refreshInterval` | number | No | Re-run the command every N seconds (minimum 1). Useful for data that changes without an Agent state event (clock, quota, uptime). |
68
+
69
+ ## JSON input
70
+
71
+ The command receives a JSON object via stdin with the following fields:
72
+
73
+ ```json
74
+ {
75
+ "session_id": "abc-123",
76
+ "version": "0.14.1",
77
+ "model": {
78
+ "display_name": "qwen-3-235b"
79
+ },
80
+ "context_window": {
81
+ "context_window_size": 131072,
82
+ "used_percentage": 34.3,
83
+ "remaining_percentage": 65.7,
84
+ "current_usage": 45000,
85
+ "total_input_tokens": 30000,
86
+ "total_output_tokens": 5000
87
+ },
88
+ "workspace": {
89
+ "current_dir": "/home/user/project"
90
+ },
91
+ "git": {
92
+ "branch": "main"
93
+ },
94
+ "metrics": {
95
+ "models": {
96
+ "qwen-3-235b": {
97
+ "api": {
98
+ "total_requests": 10,
99
+ "total_errors": 0,
100
+ "total_latency_ms": 5000
101
+ },
102
+ "tokens": {
103
+ "prompt": 30000,
104
+ "completion": 5000,
105
+ "total": 35000,
106
+ "cached": 10000,
107
+ "thoughts": 2000
108
+ }
109
+ }
110
+ },
111
+ "files": {
112
+ "total_lines_added": 120,
113
+ "total_lines_removed": 30
114
+ }
115
+ },
116
+ "vim": {
117
+ "mode": "INSERT"
118
+ }
119
+ }
120
+ ```
121
+
122
+ | Field | Type | Description |
123
+ | ------------------------------------- | ---------------- | ---------------------------------------------------------------------------------- |
124
+ | `session_id` | string | Unique session identifier |
125
+ | `version` | string | Qwen Code version |
126
+ | `model.display_name` | string | Current model name |
127
+ | `context_window.context_window_size` | number | Total context window size in tokens |
128
+ | `context_window.used_percentage` | number | Context window usage as percentage (0–100) |
129
+ | `context_window.remaining_percentage` | number | Context window remaining as percentage (0–100) |
130
+ | `context_window.current_usage` | number | Token count from the last API call (current context size) |
131
+ | `context_window.total_input_tokens` | number | Total input tokens consumed this session |
132
+ | `context_window.total_output_tokens` | number | Total output tokens consumed this session |
133
+ | `workspace.current_dir` | string | Current working directory |
134
+ | `git` | object \| absent | Present only inside a git repository. |
135
+ | `git.branch` | string | Current branch name |
136
+ | `metrics.models.<id>.api` | object | Per-model API stats: `total_requests`, `total_errors`, `total_latency_ms` |
137
+ | `metrics.models.<id>.tokens` | object | Per-model token usage: `prompt`, `completion`, `total`, `cached`, `thoughts` |
138
+ | `metrics.files` | object | File change stats: `total_lines_added`, `total_lines_removed` |
139
+ | `vim` | object \| absent | Present only when vim mode is enabled. Contains `mode` (`"INSERT"` or `"NORMAL"`). |
140
+
141
+ > **Important:** stdin can only be read once. Always store it in a variable first: `input=$(cat)`.
142
+
143
+ ## Examples
144
+
145
+ ### Model and token usage
146
+
147
+ ```json
148
+ {
149
+ "ui": {
150
+ "statusLine": {
151
+ "type": "command",
152
+ "command": "input=$(cat); model=$(echo \"$input\" | jq -r '.model.display_name'); pct=$(echo \"$input\" | jq -r '.context_window.used_percentage'); echo \"$model ctx:${pct}%\""
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ Output: `qwen-3-235b ctx:34%`
159
+
160
+ ### Git branch + directory
161
+
162
+ ```json
163
+ {
164
+ "ui": {
165
+ "statusLine": {
166
+ "type": "command",
167
+ "command": "input=$(cat); branch=$(echo \"$input\" | jq -r '.git.branch // empty'); dir=$(basename \"$(echo \"$input\" | jq -r '.workspace.current_dir')\"); echo \"$dir${branch:+ ($branch)}\""
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ Output: `my-project (main)`
174
+
175
+ > Note: The `git.branch` field is provided directly in the JSON input — no need to shell out to `git`.
176
+
177
+ ### File change stats
178
+
179
+ ```json
180
+ {
181
+ "ui": {
182
+ "statusLine": {
183
+ "type": "command",
184
+ "command": "input=$(cat); added=$(echo \"$input\" | jq -r '.metrics.files.total_lines_added'); removed=$(echo \"$input\" | jq -r '.metrics.files.total_lines_removed'); echo \"+$added/-$removed lines\""
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ Output: `+120/-30 lines`
191
+
192
+ ### Live clock and git branch
193
+
194
+ Use `refreshInterval` when the statusline shows data that changes without an Agent event (e.g. the clock, uptime, or rate-limit counters):
195
+
196
+ ```json
197
+ {
198
+ "ui": {
199
+ "statusLine": {
200
+ "type": "command",
201
+ "command": "input=$(cat); branch=$(echo \"$input\" | jq -r '.git.branch // \"no-git\"'); echo \"$(date +%H:%M:%S) ($branch)\"",
202
+ "refreshInterval": 1
203
+ }
204
+ }
205
+ }
206
+ ```
207
+
208
+ Output (refreshed every second): `14:32:07 (main)`
209
+
210
+ ### Script file for complex commands
211
+
212
+ For longer commands, save a script file at `~/.qwen/statusline-command.sh`:
213
+
214
+ ```bash
215
+ #!/bin/bash
216
+ input=$(cat)
217
+ model=$(echo "$input" | jq -r '.model.display_name')
218
+ pct=$(echo "$input" | jq -r '.context_window.used_percentage')
219
+ branch=$(echo "$input" | jq -r '.git.branch // empty')
220
+ added=$(echo "$input" | jq -r '.metrics.files.total_lines_added')
221
+ removed=$(echo "$input" | jq -r '.metrics.files.total_lines_removed')
222
+
223
+ parts=()
224
+ [ -n "$model" ] && parts+=("$model")
225
+ [ -n "$branch" ] && parts+=("($branch)")
226
+ [ "$pct" != "0" ] 2>/dev/null && parts+=("ctx:${pct}%")
227
+ ([ "$added" -gt 0 ] || [ "$removed" -gt 0 ]) 2>/dev/null && parts+=("+${added}/-${removed}")
228
+
229
+ echo "${parts[*]}"
230
+ ```
231
+
232
+ Then reference it in settings:
233
+
234
+ ```json
235
+ {
236
+ "ui": {
237
+ "statusLine": {
238
+ "type": "command",
239
+ "command": "bash ~/.qwen/statusline-command.sh"
240
+ }
241
+ }
242
+ }
243
+ ```
244
+
245
+ ## Behavior
246
+
247
+ - **Update triggers**: The status line updates when the model changes, a new message is sent (token count changes), vim mode is toggled, git branch changes, tool calls complete, or file changes occur. Updates are debounced (300ms). Set `refreshInterval` (seconds) to additionally re-run the command on a timer — useful for data that changes without an Agent event (clock, rate limits, build status).
248
+ - **Timeout**: Commands that take longer than 5 seconds are killed. The status line clears on failure.
249
+ - **Output**: Multi-line output is supported (up to 2 lines; extra lines are discarded). Each line is rendered as a separate row with dimmed colors in the footer's left section. Lines that exceed the available width are truncated.
250
+ - **Hot reload**: Changes to `ui.statusLine` in settings take effect immediately — no restart required.
251
+ - **Shell**: Commands run via `/bin/sh` on macOS/Linux. On Windows, `cmd.exe` is used by default — wrap POSIX commands with `bash -c "..."` or point to a bash script (e.g. `bash ~/.qwen/statusline-command.sh`).
252
+ - **Removal**: Delete the `ui.statusLine` key from settings to disable. The "? for shortcuts" hint returns.
253
+
254
+ ## Troubleshooting
255
+
256
+ | Problem | Cause | Fix |
257
+ | ----------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
258
+ | Status line not showing | Config at wrong path | Must be under `ui.statusLine`, not root-level `statusLine` |
259
+ | Empty output | Command fails silently | Test manually: `echo '{"session_id":"test","version":"0.14.1","model":{"display_name":"test"},"context_window":{"context_window_size":0,"used_percentage":0,"remaining_percentage":100,"current_usage":0,"total_input_tokens":0,"total_output_tokens":0},"workspace":{"current_dir":"/tmp"},"metrics":{"models":{},"files":{"total_lines_added":0,"total_lines_removed":0}}}' \| sh -c 'your_command'` |
260
+ | Stale data | No trigger fired | Send a message or switch models to trigger an update — or set `refreshInterval` to re-run the command on a timer |
261
+ | Command too slow | Complex script | Optimize the script or move heavy work to a background cache |