mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 21:20:44 +00:00
refactor(status-line): redesign JSON input schema and add context fields
Restructure the status line stdin JSON for clarity and accuracy: - Rename model.id → model.display_name, cwd → workspace.current_dir - Replace raw context_window size/count with used_percentage, remaining_percentage, current_usage, context_window_size, and total_input_tokens/total_output_tokens - Add version field from cfg.getCliVersion() - Add git.branch, metrics.models, metrics.files - Remove upstream-only fields: tokens.tool (never populated), session (start_time/elapsed_time not live-updating), streaming_state, approval_mode, terminal, metrics.tools - Rename tokens.candidates → tokens.completion (Qwen API convention) - Fix template string escaping in builtin-agents to avoid templateString() placeholder collision Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7902806e63
commit
24a28d5fb0
4 changed files with 240 additions and 47 deletions
|
|
@ -141,13 +141,34 @@ How to use the statusLine command:
|
|||
1. The statusLine command will receive the following JSON input via stdin:
|
||||
{
|
||||
"session_id": "string",
|
||||
"cwd": "string",
|
||||
"version": "string",
|
||||
"model": {
|
||||
"id": "string"
|
||||
"display_name": "string"
|
||||
},
|
||||
"context_window": {
|
||||
"context_window_size": number,
|
||||
"last_prompt_token_count": number
|
||||
"used_percentage": number,
|
||||
"remaining_percentage": number,
|
||||
"current_usage": number,
|
||||
"total_input_tokens": number,
|
||||
"total_output_tokens": number
|
||||
},
|
||||
"workspace": {
|
||||
"current_dir": "string"
|
||||
},
|
||||
"git": { // Optional, only present when inside a git repo
|
||||
"branch": "string"
|
||||
},
|
||||
"metrics": {
|
||||
"models": {
|
||||
"<model_id>": {
|
||||
"api": { "total_requests": number, "total_errors": number, "total_latency_ms": number },
|
||||
"tokens": { "prompt": number, "completion": number, "total": number, "cached": number, "thoughts": number }
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"total_lines_added": number, "total_lines_removed": number
|
||||
}
|
||||
},
|
||||
"vim": { // Optional, only present when vim mode is enabled
|
||||
"mode": "INSERT" | "NORMAL"
|
||||
|
|
@ -155,10 +176,13 @@ How to use the statusLine command:
|
|||
}
|
||||
|
||||
IMPORTANT: stdin can only be consumed once. Always read it into a variable first:
|
||||
- input=$(cat); echo "$(echo "$input" | jq -r '.model.id') in $(echo "$input" | jq -r '.cwd')"
|
||||
- input=$(cat); echo "$(echo "$input" | jq -r '.model.display_name') in $(echo "$input" | jq -r '.workspace.current_dir')"
|
||||
|
||||
To display context usage:
|
||||
- input=$(cat); tokens=$(echo "$input" | jq -r '.context_window.last_prompt_token_count'); size=$(echo "$input" | jq -r '.context_window.context_window_size'); [ "$tokens" -gt 0 ] 2>/dev/null && echo "Context: $((tokens * 100 / size))% used"
|
||||
- input=$(cat); pct=$(echo "$input" | jq -r '.context_window.used_percentage'); echo "Context: $pct% used"
|
||||
|
||||
To display git branch:
|
||||
- input=$(cat); branch=$(echo "$input" | jq -r '.git.branch // empty'); echo "\${branch:-no branch}"
|
||||
|
||||
2. For longer commands, you can save a new file in the user's ~/.qwen directory, e.g.:
|
||||
- ~/.qwen/statusline-command.sh and reference that file in the settings.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue