Skip to content

Commit fc45626

Browse files
committed
feat(statusline): configurable renderer with cache stats, session duration, dual-provider support
- Add scripts/statusline.py: config-driven renderer with 1/2/3 line layouts - Add 6 template presets (detailed, balanced, minimal, monitor, developer, performance) - Cache hit rate with decimal precision (Anthropic only, hidden for GLM) - Session duration tracker (file-based, auto-reset after 24h) - Simplified model names with context window size tag - 3 icon themes: emoji, unicode, minimal - Dual-provider support: Anthropic Claude + z.ai GLM - Update commands, skills, README, CLAUDE.md - Bump version to 1.8.0
1 parent cb8838e commit fc45626

13 files changed

Lines changed: 842 additions & 163 deletions

File tree

statusline/.claude-plugin/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "statusline",
3-
"version": "1.7.0",
4-
"description": "Multi-provider status bar with context health, API rate limits (Anthropic 5h/7d + z.ai GLM tokens/tools), git branch, and active tools. Auto-detects provider from model name. Supports 1/2/3 line layouts with smart hiding.",
3+
"version": "1.8.0",
4+
"description": "Configurable multi-line status bar with context health, cache hit rate, session duration, API rate limits (Anthropic 5h/7d + z.ai GLM), git branch, and active tools. Supports 1/2/3 line layouts, icon themes, and template presets.",
55
"author": {
66
"name": "duyet"
77
}

statusline/CLAUDE.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Statusline Plugin
22

3-
Configurable status bar showing context usage, API rate limits (5h/7d), git branch, and active tools. Supports 1/2/3 line layouts with smart hiding of empty values.
3+
Configurable multi-line status bar with context health, cache hit rate, session duration, API rate limits (Anthropic 5h/7d + z.ai GLM), git branch, active tools, and agent tracking. Supports 1/2/3 line layouts, icon themes, and 6 template presets. Dual-provider: Anthropic Claude and z.ai GLM.
44

55
## Versioning
66

77
Follow semantic versioning (semver) for this plugin:
88

99
| Change Type | Version Bump | Example |
1010
|-------------|--------------|---------|
11-
| Bug fix, docs | Patch | 1.0.0 → 1.0.1 |
12-
| New feature, minor change | Minor | 1.0.0 → 1.1.0 |
13-
| Breaking change | Major | 1.0.0 → 2.0.0 |
11+
| Bug fix, docs | Patch | 1.8.0 → 1.8.1 |
12+
| New feature, minor change | Minor | 1.8.0 → 1.9.0 |
13+
| Breaking change | Major | 1.8.0 → 2.0.0 |
1414

1515
**When to bump:**
1616
- Adding new commands, skills, or agents → **Minor**
@@ -25,22 +25,44 @@ Always update `plugin.json` version when making changes.
2525
```
2626
statusline/
2727
├── .claude-plugin/
28-
│ └── plugin.json # Manifest (version 1.4.0)
29-
├── agents/ # Sub-agent definitions
28+
│ └── plugin.json # Manifest (version 1.8.0)
3029
├── commands/ # Slash commands
31-
├── skills/ # Reusable knowledge
32-
└── hooks/hooks.json # Lifecycle hooks (optional)
30+
│ ├── setup.md # /statusline:setup — interactive wizard
31+
│ ├── config.md # /statusline:config — quick changes
32+
│ ├── status.md # /statusline:status — view metrics
33+
│ └── disable.md # /statusline:disable — pause updates
34+
├── skills/
35+
│ └── statusline-workflow/
36+
│ └── SKILL.md # Reusable skill for configuration
37+
├── hooks/
38+
│ ├── hooks.json # Lifecycle hooks
39+
│ └── session-start.sh # Rate limit fetching on session start
40+
├── scripts/
41+
│ ├── statusline.py # Configurable renderer (reads config JSON)
42+
│ ├── format-status.ts # TypeScript rate-limit fetcher
43+
│ ├── test-statusline.sh # Test harness
44+
│ └── templates/ # Layout presets
45+
│ ├── detailed.json # 3-line, emoji, all sections (default)
46+
│ ├── balanced.json # 2-line, unicode, key metrics
47+
│ ├── minimal.json # 1-line, no icons, essentials
48+
│ ├── monitor.json # 2-line, rate-limit focused
49+
│ ├── developer.json # 2-line, tools+agents+git focused
50+
│ └── performance.json # 3-line, cache+context optimization
51+
└── README.md
3352
```
3453

35-
## Components
54+
## Dual-Provider Behavior
3655

37-
### Commands
56+
| Feature | Anthropic Claude | z.ai GLM |
57+
|---------|-----------------|----------|
58+
| Model name | Simplified (`opus-4.8[200k]`) | Preserved from ID |
59+
| Cache stats | Real prompt caching data | Hidden (proxy artifacts) |
60+
| Rate limits | 5h/7d from payload | When available |
61+
| All other features |||
3862

39-
- `/config`
40-
- `/disable`
41-
- `/setup`
42-
- `/status`
63+
## Config Schema
4364

65+
`~/.claude/statusline.config.json` — see SKILL.md for full field reference.
4466

4567
## Commit Convention
4668

@@ -53,7 +75,3 @@ docs(statusline): update documentation
5375
```
5476

5577
Co-author: `Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>`
56-
57-
---
58-
59-
**Generated by docs-generator v1.0.0**

statusline/README.md

Lines changed: 161 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,216 @@
11
# Statusline
22

3-
A Claude Code plugin that provides real-time visibility into your coding session. Track context usage, API rate limits, active tools, running agents, and task progress at a glance.
3+
A Claude Code plugin that provides real-time visibility into your coding session. Track context usage, cache hit rates, session duration, API rate limits, active tools, and running agents — all at a glance.
44

5-
**Multi-provider support:** Automatically detects Anthropic vs z.ai GLM models and shows provider-specific metrics.
5+
**Dual-provider support:** Automatically adapts to Anthropic Claude and z.ai GLM models with provider-specific metrics.
66

7-
## Overview
7+
## Quick Start
88

9-
Statusline keeps you informed about what's happening during your Claude Code session without interrupting your workflow.
9+
```bash
10+
/plugin install statusline
11+
/statusline:setup
12+
```
1013

11-
| Metric | Anthropic | z.ai GLM |
12-
|--------|-----------|----------|
13-
| **Context Health** | Token count, percentage, progress bar | Token count, percentage, progress bar |
14-
| **Rate Limits** | 5h utilization, 7d utilization | Token quota %, monthly tools % |
15-
| **Tool Breakdown** || Search, Web, ZRead usage counts |
16-
| **Active Tools** | MCP server detection | MCP server detection |
17-
| **Agent Tracking** | Running agents and count | Running agents and count |
18-
| **Task Progress** | Todo completion tracking | Todo completion tracking |
14+
Answer 4 questions and your statusline is live. That's it.
1915

20-
## Installation
16+
## What You See
2117

22-
Add the plugin to your Claude Code instance:
18+
The statusline renders in your terminal below the input prompt, updating automatically every turn.
19+
20+
### 3-line Detailed (default)
2321

24-
```bash
25-
/plugin install statusline
22+
```
23+
📁 monorepo (master) → 🤖 opus-4.8[200k] (medium) → ⏳ 23m
24+
📊 ██░░░░░░░░ 21% (43k/200k) → 🗃️ 98% (42k/43k) cache hit → ⏱️ 5h: 45% | 7d: 28%
25+
🔧 Seq Ctx7
2626
```
2727

28-
## Commands
28+
### 2-line Balanced
2929

30-
| Command | Purpose |
31-
|---------|---------|
32-
| `/statusline:status` | Display current session metrics |
33-
| `/statusline:config` | Configure display format (1/2/3 lines) |
34-
| `/statusline:setup` | Interactive setup wizard |
35-
| `/statusline:disable` | Pause automatic status updates |
30+
```
31+
monorepo (master) → opus-4.8[200k] (medium) → 23m
32+
██░░░░░░░░ 21% (43k/200k) → cache 98% (42k/43k) → 5h: 45% | 7d: 28% → Seq Ctx7
33+
```
34+
35+
### 1-line Minimal
3636

37-
## Provider Auto-Detection
37+
```
38+
monorepo (master) · opus-4.8[200k] (medium) · 21% · 5h: 45% | 7d: 28%
39+
```
40+
41+
## Features
3842

39-
The plugin automatically detects your model provider:
43+
### 📊 Context Health
4044

41-
- **Anthropic** — Any Claude model (claude-opus, claude-sonnet, claude-haiku, etc.)
42-
- **z.ai GLM** — Any model starting with `glm-` (glm-5.1, glm-4, glm-flash, etc.)
45+
See how much of your context window you've used — with color-coded thresholds:
4346

44-
Detection happens from the model ID injected by Claude Code into the statusline JSON input.
47+
| Range | Color | Meaning |
48+
|-------|-------|---------|
49+
| 0–49% | 🟢 Green | Plenty of room |
50+
| 50–69% | 🟡 Dim yellow | Starting to fill |
51+
| 70–84% | 🟡 Bold yellow | Getting tight |
52+
| 85%+ | 🔴 Bold red | Approaching limit |
4553

46-
## Display Formats
54+
Three display styles:
55+
- **Progress bar**: `██░░░░░░░░ 21% (43k/200k)`
56+
- **With tokens**: `21% (43k/200k)`
57+
- **Compact**: `21%`
4758

48-
### 1-line (Compact)
59+
### 🗃️ Cache Hit Rate (Anthropic only)
60+
61+
Shows how effective prompt caching is for your session:
4962

50-
Everything on a single line:
5163
```
52-
claude-plugins (master) │ GLM 5.1 │ ctx: 21% 43k/200k │ tokens: 15% │ tools: 11% (883 left)
64+
🗃️ 98% (42k/43k) cache hit
5365
```
5466

55-
### 2-line (Default)
67+
- Percentage with decimal precision when ≥99% (e.g., `99.98%`)
68+
- Token breakdown: cached reads vs total cacheable tokens
69+
- **Only shown for Anthropic Claude models** — GLM proxy values aren't real cache metrics
70+
71+
### ⏳ Session Duration
72+
73+
Tracks how long your current session has been running:
74+
75+
```
76+
⏳ 1h23m
77+
```
78+
79+
- File-based tracker persists across statusline updates
80+
- Auto-resets after 24 hours of inactivity
81+
82+
### ⏱️ Rate Limits
83+
84+
**Anthropic Claude** — 5-hour and 7-day utilization with reset timers:
5685

57-
Location + model on line 1, all metrics on line 2:
5886
```
59-
claude-plugins (master) │ GLM 5.1 │ v2.0.76
60-
ctx: 21% 43k/200k │ tokens: 15% │ tools: 11% (883 left) Web:35 ZRead:82
87+
⏱️ 5h: 45% (reset 1h12m) | 7d: 28%
6188
```
6289

63-
### 3-line (Detailed)
90+
**z.ai GLM** — Shown when available from the API:
6491

65-
Full layout with progress bar and token details:
6692
```
67-
claude-plugins (master) │ GLM 5.1 │ v2.0.76 │ explanatory
68-
ctx: ██░░░░░░░░ 21% (43k/200k tokens) │ tokens: 15% │ tools: 11% (883 left) Web:35 ZRead:82
69-
Tools: Seq Ctx7 │ Agents: 2 active │ Tasks: 3/5 (60%)
93+
⏱️ rate-limits: n/a
7094
```
7195

72-
## Context Health
96+
Rate limits use the same color thresholds as context health.
97+
98+
### 🤖 Model Name
7399

74-
Color-coded progress indicator:
75-
- 🟢 Green: 0-60% — Comfortable
76-
- 🟡 Yellow: 60-85% — Getting full
77-
- 🔴 Red: 85%+ — Approaching limit
100+
Simplified model names with context window size:
78101

79-
The 3-line format includes a visual progress bar: `███░░░░░░░ 30%`
102+
| Raw Model ID | Display |
103+
|-------------|---------|
104+
| `claude-opus-4-8` | `opus-4.8[200k]` |
105+
| `claude-sonnet-4-6` | `sonnet-4.6[200k]` |
106+
| `glm-5.1[1m]` | `glm-5.1[1m]` |
80107

81-
## API Rate Limits
108+
Effort/reasoning level shown in parentheses: `opus-4.8[200k] (medium)`
82109

83-
### Anthropic
110+
### 🔧 Active Tools & Agents
111+
112+
Process-detected MCP servers and running agent count:
84113

85-
Shows 5-hour and 7-day utilization percentages:
86114
```
87-
5h: 42% │ 7d: 28%
115+
🔧 Seq Ctx7 ZRead
116+
👷 3 active
88117
```
89118

90-
Requires Claude Code OAuth credentials (auto-detected from keychain or config files).
119+
Hidden when idle: `💤 idle`
120+
121+
### 📁 Project & Branch
91122

92-
### z.ai GLM
123+
Current directory and git branch:
93124

94-
Shows token quota and monthly tool usage:
95125
```
96-
tokens: 15% │ tools: 11% (883 left) Web:35 ZRead:82
126+
📁 monorepo (master)
97127
```
98128

99-
- **tokens** — 5-hour rolling window (equivalent to Anthropic's 5h)
100-
- **tools** — Monthly tool quota with remaining count
101-
- **Per-tool breakdown** — Search, Web-reader, ZRead usage
129+
## Dual-Provider Support
130+
131+
| Feature | Anthropic Claude | z.ai GLM |
132+
|---------|-----------------|----------|
133+
| Model name | Simplified (e.g., `opus-4.8[200k]`) | Preserved from model ID |
134+
| Rate limits | 5h/7d from JSON payload | Shown when available |
135+
| Cache stats | ✅ Real prompt caching data | ❌ Hidden (proxy artifacts) |
136+
| Context window | From JSON payload | From JSON payload |
137+
| Effort level | low/medium/high/max | low/medium/high/max |
138+
| Session/tools | All features | All features |
139+
140+
## Template Presets
141+
142+
Six built-in presets for different workflows. Apply via `/statusline:config` → Template:
143+
144+
| Template | Lines | Icons | Focus |
145+
|----------|-------|-------|-------|
146+
| **Detailed** | 3 | emoji | Full visibility — everything shown |
147+
| **Balanced** | 2 | unicode | Quick overview — key metrics only |
148+
| **Minimal** | 1 | none | Maximum space — bare essentials |
149+
| **Monitor** | 2 | emoji | Rate-limit tracking — hides tools |
150+
| **Developer** | 2 | unicode | Tools + agents + git focused |
151+
| **Performance** | 3 | emoji | Cache + context optimization |
152+
153+
## Configuration
154+
155+
All settings stored in `~/.claude/statusline.config.json`:
156+
157+
```json
158+
{
159+
"line_format": "3",
160+
"separator": "arrow",
161+
"context_style": "progress_bar",
162+
"icon_style": "emoji",
163+
"show_context": true,
164+
"show_rate_limits": true,
165+
"show_git_branch": true,
166+
"show_tools": true,
167+
"show_agents": true,
168+
"show_cache": true,
169+
"show_session": true,
170+
"show_reasoning": true,
171+
"color_style": "colorful"
172+
}
173+
```
174+
175+
### Config Reference
176+
177+
| Field | Values | Default | Description |
178+
|-------|--------|---------|-------------|
179+
| `line_format` | `"1"`, `"2"`, `"3"` | `"3"` | Number of output lines |
180+
| `separator` | `"arrow"`, `"pipe"`, `"dot"`, `"slash"` | `"arrow"` | Section separator |
181+
| `context_style` | `"progress_bar"`, `"tokens"`, `"compact"` | `"progress_bar"` | Context display format |
182+
| `icon_style` | `"emoji"`, `"unicode"`, `"minimal"` | `"emoji"` | Icon theme |
183+
| `show_context` | boolean | `true` | Token count and percentage |
184+
| `show_rate_limits` | boolean | `true` | API usage metrics |
185+
| `show_git_branch` | boolean | `true` | Current git branch |
186+
| `show_tools` | boolean | `true` | Running MCP servers |
187+
| `show_agents` | boolean | `true` | Running agent count |
188+
| `show_cache` | boolean | `true` | Cache hit rate (Claude only) |
189+
| `show_session` | boolean | `true` | Session duration |
190+
| `show_reasoning` | boolean | `true` | Effort level next to model |
102191

103-
#### z.ai Credential Sources (tried in order)
192+
## Commands
104193

105-
1. **macOS Keychain**`security add-generic-password -s "z.ai" -w "your-key"`
106-
2. **Environment**`ZAI_API_KEY` or `ZAI_CODING_PLAN_KEY`
107-
3. **Config files**`~/.local/share/opencode/auth.json` or `~/.zai/auth.json`
194+
| Command | Purpose |
195+
|---------|---------|
196+
| `/statusline:setup` | Interactive setup wizard |
197+
| `/statusline:config` | Quick layout/style changes |
198+
| `/statusline:status` | Display current session metrics |
199+
| `/statusline:disable` | Pause automatic status updates |
108200

109201
## Smart Hiding
110202

111-
Empty values are never shown:
112-
- No "None", "0%", or "No tasks" clutter
113-
- Tool/agent sections hidden when inactive
114-
- Per-tool breakdown only shown when usage > 0
115-
- Output style hidden when set to "default"
203+
Empty values are never shown — no "0%" or "n/a" clutter:
204+
- Cache section hidden for GLM models (not real data)
205+
- Rate limits show "n/a" only when provider data is genuinely unavailable
206+
- Tools/agents sections collapse when nothing is running
207+
- Session duration hidden on first render (0s)
116208

117209
## Requirements
118210

119211
- Claude Code v1.0.80+
120-
- Node.js 18+ (for TypeScript CLI)
121-
- `jq` (for Bash statusline script)
122-
123-
## Contributing
124-
125-
Found an issue or have a feature idea? Open an issue on the [claude-plugins repository](https://github.com/duyet/codex-claude-plugins/issues).
212+
- Python 3.8+ (for the statusline renderer)
213+
- Git (for branch detection)
126214

127215
## License
128216

0 commit comments

Comments
 (0)