Skip to content

Commit 12fbed5

Browse files
committed
feat(statusline): add multi-provider support with z.ai GLM auto-detection
Detect model provider from JSON input (glm-* prefix) and fetch rate limits from the appropriate API. Add token counts and progress bar to context display, per-tool breakdown for z.ai (Search/Web/ZRead), and provider-aware caching to prevent stale cross-provider data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 30b8985 commit 12fbed5

6 files changed

Lines changed: 207 additions & 266 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.6.0",
4-
"description": "Configurable status bar showing context usage, API rate limits (5h/7d for Anthropic, detailed metrics for z.ai GLM), git branch, and active tools. Supports 1/2/3 line layouts with smart hiding of empty values.",
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.",
55
"author": {
66
"name": "duyet"
77
}

statusline/README.md

Lines changed: 68 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Statusline
22

3-
A Claude Code plugin that provides real-time visibility into your coding session. Track context usage, 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, API rate limits, active tools, running agents, and task progress at a glance.
44

5-
**Inspired by [claude-hud](https://github.com/jarrodwatts/claude-hud) — enhanced for the claude-plugins ecosystem.**
5+
**Multi-provider support:** Automatically detects Anthropic vs z.ai GLM models and shows provider-specific metrics.
66

77
## Overview
88

9-
Statusline keeps you informed about what's happening during your Claude Code session without interrupting your workflow. Get immediate feedback on:
9+
Statusline keeps you informed about what's happening during your Claude Code session without interrupting your workflow.
1010

11-
| Metric | Purpose |
12-
|--------|---------|
13-
| **Context Health** | Know exactly how much of your token window is in use |
14-
| **Active Tools** | See which tools Claude is using right now |
15-
| **Agent Tracking** | Monitor running agents and their execution time |
16-
| **Task Progress** | Track todo completion in real-time |
17-
| **API Rate Limits** | Monitor usage across Anthropic (5h/7d) or z.ai GLM (5h) |
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 |
1819

1920
## Installation
2021

@@ -24,211 +25,105 @@ Add the plugin to your Claude Code instance:
2425
/plugin install statusline
2526
```
2627

27-
Then enable monitoring:
28-
29-
```bash
30-
/statusline:enable
31-
```
32-
33-
## Quick Start
34-
35-
### View Current Status
36-
Check your session metrics anytime:
37-
```bash
38-
/statusline:status
39-
```
40-
41-
### Continuous Monitoring
42-
Enable automatic status updates (5-second interval by default):
43-
```bash
44-
/statusline:enable
45-
```
46-
47-
### Custom Update Interval
48-
Set a custom monitoring interval (in seconds):
49-
```bash
50-
/statusline:enable 10
51-
```
52-
53-
### Stop Monitoring
54-
Pause background updates while keeping the plugin active:
55-
```bash
56-
/statusline:disable
57-
```
58-
5928
## Commands
6029

6130
| Command | Purpose |
6231
|---------|---------|
63-
| `/statusline:status` | Display current session metrics immediately |
64-
| `/statusline:enable [interval]` | Enable real-time monitoring with optional custom interval |
32+
| `/statusline:status` | Display current session metrics |
33+
| `/statusline:config` | Configure display format (1/2/3 lines) |
34+
| `/statusline:setup` | Interactive setup wizard |
6535
| `/statusline:disable` | Pause automatic status updates |
6636

67-
## What Each Metric Shows
37+
## Provider Auto-Detection
6838

69-
### Context Window
70-
A visual progress bar showing your token usage with color coding:
71-
- 🟢 Green: 0-60% — Comfortable usage
72-
- 🟡 Yellow: 60-85% — Getting full
73-
- 🔴 Red: 85%+ — Approaching limit
39+
The plugin automatically detects your model provider:
7440

75-
Example:
76-
```
77-
Context: ████░░░░░░ 45% (90,000 / 200,000 tokens)
78-
```
79-
80-
### Compact One-Line Format
81-
All metrics displayed in a single line with empty values hidden:
82-
```
83-
📊 🟡 45% | Model: Opus 4.5 | 12m 34s | Tools: Glob×4 Bash×8 Read×12 | Agents: Explore(12s) | Tasks: 🔄 1 ⏳ 2 ✓ 5 | Context: 3 prompts
84-
```
85-
86-
**Smart hiding:**
87-
- ✓ No "None" values displayed
88-
- ✓ Empty collections omitted (no agents/tools if zero)
89-
- ✓ Claude Code version hidden
90-
- ✓ Context shows matching system prompts and tools
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.)
9143

92-
### API Rate Limits
44+
Detection happens from the model ID injected by Claude Code into the statusline JSON input.
9345

94-
The plugin automatically detects your model provider and shows appropriate usage metrics:
46+
## Display Formats
9547

96-
**Anthropic Models** (default, Claude, Opus, Sonnet, etc.):
97-
```
98-
5h: 42% | 7d: 28%
99-
```
100-
- Shows 5-hour and 7-day utilization percentages
101-
- Requires Claude Code OAuth credentials
48+
### 1-line (Compact)
10249

103-
**z.ai GLM Models** (glm-4, glm-4.7, glm-flash, glm-plus, etc.):
50+
Everything on a single line:
10451
```
105-
z.ai: 15%
52+
claude-plugins (master) │ GLM 5.1 │ ctx: 21% 43k/200k │ tokens: 15% │ tools: 11% (883 left)
10653
```
107-
- Shows token quota percentage (5h equivalent)
108-
- Requires z.ai API key from opencode auth file
109-
110-
#### z.ai Setup
111-
112-
For GLM models, the plugin tries multiple credential sources in order:
113-
114-
**1. macOS Keychain** (macOS only - highest priority)
115-
- Looks for keychain entries named: `z.ai`, `zai`, `opencode`, or `zai-coding-plan`
116-
- Parses JSON or uses raw value as API key
11754

118-
**2. Environment Variables** (cross-platform)
119-
- `ZAI_API_KEY` - Generic z.ai API key
120-
- `ZAI_CODING_PLAN_KEY` - Coding plan specific key
55+
### 2-line (Default)
12156

122-
**3. Configuration Files** (cross-platform fallback)
123-
Tries these paths in order:
57+
Location + model on line 1, all metrics on line 2:
12458
```
125-
~/.local/share/opencode/auth.json # Linux/Unix XDG standard
126-
~/.config/opencode/auth.json # Alternative XDG location
127-
~/.opencode/auth.json # Legacy location
128-
~/.zai/auth.json # z.ai specific
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
12961
```
13062

131-
Example auth file structure:
132-
```json
133-
{
134-
"zai-coding-plan": {
135-
"key": "your-zai-api-key-here"
136-
}
137-
}
138-
```
63+
### 3-line (Detailed)
13964

140-
Alternative JSON structures supported:
141-
```json
142-
{"zai": {"key": "..."}}
143-
{"apiKey": "..."}
144-
{"key": "..."}
65+
Full layout with progress bar and token details:
66+
```
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%)
14570
```
14671

147-
**Recommended Setup by Platform:**
148-
149-
| Platform | Recommended Method |
150-
|----------|-------------------|
151-
| macOS | Keychain: `security add-generic-password -s "z.ai" -w "your-key"` |
152-
| Linux | File: `~/.local/share/opencode/auth.json` |
153-
| Windows | File: `%USERPROFILE%\.local\share\opencode\auth.json` |
154-
155-
The provider is automatically detected from the `CLAUDE_MODEL` or `ANTHROPIC_MODEL` environment variable. Any model starting with `glm-` will use the z.ai API.
72+
## Context Health
15673

157-
## Features
74+
Color-coded progress indicator:
75+
- 🟢 Green: 0-60% — Comfortable
76+
- 🟡 Yellow: 60-85% — Getting full
77+
- 🔴 Red: 85%+ — Approaching limit
15878

159-
**Real-time Updates** — Status refreshes automatically at your chosen interval
79+
The 3-line format includes a visual progress bar: `███░░░░░░░ 30%`
16080

161-
**Non-intrusive** — Displays without interrupting your workflow
81+
## API Rate Limits
16282

163-
**Customizable** — Set monitoring frequency that works for you
83+
### Anthropic
16484

165-
**Manual Control** — Check status anytime with `/statusline:status`
85+
Shows 5-hour and 7-day utilization percentages:
86+
```
87+
5h: 42% │ 7d: 28%
88+
```
16689

167-
**Plugin Integration** — Works seamlessly with other Claude Code plugins
90+
Requires Claude Code OAuth credentials (auto-detected from keychain or config files).
16891

169-
**Token Awareness** — Shows actual token counts from Claude Code
92+
### z.ai GLM
17093

171-
## Use Cases
94+
Shows token quota and monthly tool usage:
95+
```
96+
tokens: 15% │ tools: 11% (883 left) Web:35 ZRead:82
97+
```
17298

173-
- **Monitor Context** — Know when you're approaching context limits before running out
174-
- **Track Progress** — See how many tasks have been completed in your session
175-
- **Debug Workflows** — Understand tool and agent activity during complex operations
176-
- **Optimize Sessions** — Identify bottlenecks and adjust your approach
177-
- **Stay Informed** — Keep awareness of background operations
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
178102

179-
## How It Works
103+
#### z.ai Credential Sources (tried in order)
180104

181-
The plugin reads session data from Claude Code's internal state and displays aggregated metrics about:
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`
182108

183-
1. **Token Usage** — Real counts from Claude Code's context window
184-
2. **Tool Activity** — Tracked from tool invocations in your session
185-
3. **Agent Operations** — Monitored from subagent execution
186-
4. **Task Management** — Read from your TodoWrite operations
109+
## Smart Hiding
187110

188-
Updates happen at a regular interval (default 5 seconds) without blocking your work.
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"
189116

190117
## Requirements
191118

192119
- Claude Code v1.0.80+
193-
- Node.js 18+ or Bun (if running custom build)
194-
195-
## Inspiration
196-
197-
This plugin is inspired by [claude-hud](https://github.com/jarrodwatts/claude-hud) but optimized for the claude-plugins marketplace with enhanced integration and customization options.
198-
199-
## Development
200-
201-
Session Monitor is built with:
202-
- TypeScript for type safety
203-
- Claude Code's native APIs
204-
- Minimal dependencies for quick performance
205-
206-
### Source Structure
207-
208-
```
209-
session-monitor/
210-
├── .claude-plugin/
211-
│ └── plugin.json # Plugin manifest
212-
├── commands/
213-
│ ├── status.md # Status command documentation
214-
│ ├── enable.md # Enable command documentation
215-
│ └── disable.md # Disable command documentation
216-
└── README.md # This file
217-
```
120+
- Node.js 18+ (for TypeScript CLI)
121+
- `jq` (for Bash statusline script)
218122

219123
## Contributing
220124

221-
Found an issue or have a feature idea? Contributions are welcome! This plugin is part of the [claude-plugins](https://github.com/duyet/claude-plugins) marketplace.
125+
Found an issue or have a feature idea? Open an issue on the [claude-plugins repository](https://github.com/duyet/claude-plugins/issues).
222126

223127
## License
224128

225-
MIT License — see LICENSE file
226-
227-
## Related Plugins
228-
229-
- **[team-agents](../team-agents)** — Coordinated parallel task execution
230-
- **[commit](../commit)** — Semantic Git commit automation
231-
232-
---
233-
234-
**Questions?** Open an issue on the [claude-plugins repository](https://github.com/duyet/claude-plugins/issues)
129+
MIT License

statusline/commands/config.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Ask the user which display format they prefer:
1414
**Question**: "How many lines should the statusline display?"
1515

1616
**Options**:
17-
1. **1 line (Compact)**`dir (branch) │ Model │ Ctx% │ 5h/7d │ Tasks`
17+
1. **1 line (Compact)**`dir (branch) │ Model │ Ctx% │ Rate │ Tasks`
1818
2. **2 lines** — Line 1: location/model, Line 2: all metrics
19-
3. **3 lines (Default)** — Full layout with separate lines for location, metrics, and activity
19+
3. **3 lines (Default)** — Full layout with progress bar, token details, and activity
2020

2121
### Save Configuration
2222

@@ -40,28 +40,50 @@ Output:
4040

4141
## Example Outputs
4242

43-
**1-line format**:
43+
**Anthropic** (Claude, Opus, Sonnet):
44+
45+
1-line:
46+
```
47+
claude-plugins (master) │ Opus 4.5 │ ctx: 21% 43k/200k │ 5h: 42% 7d: 28%
48+
```
49+
50+
2-line:
51+
```
52+
claude-plugins (master) │ Opus 4.5 │ v2.0.76
53+
ctx: 21% 43k/200k │ 5h: 42% │ 7d: 28% │ Tasks: 2/5 (40%)
54+
```
55+
56+
3-line:
57+
```
58+
claude-plugins (master) │ Opus 4.5 │ v2.0.76 │ explanatory
59+
ctx: ██░░░░░░░░ 21% (43k/200k tokens) │ 5h: 42% │ 7d: 28%
60+
Tools: Seq Ctx7 │ Agents: 2 active │ Tasks: 1/5 (20%)
61+
```
62+
63+
**z.ai GLM** (glm-5.1, glm-4, etc.):
64+
65+
1-line:
4466
```
45-
claude-plugins (master) │ Opus 4 5Ctx: 21% │ 5h: 14% 7d: 46%
67+
claude-plugins (master) │ GLM 5.1ctx: 21% 43k/200k │ tokens: 15% │ tools: 11% (883 left)
4668
```
4769

48-
**2-line format**:
70+
2-line:
4971
```
50-
claude-plugins (master) │ Opus 4 5 │ v2.0.76
51-
Ctx: 21% │ 5h: 14% 7d: 46% │ Tasks: 2/5
72+
claude-plugins (master) │ GLM 5.1 │ v2.0.76
73+
ctx: 21% 43k/200k │ tokens: 15% │ tools: 11% (883 left) Web:35 ZRead:82
5274
```
5375

54-
**3-line format** (default):
76+
3-line:
5577
```
56-
claude-plugins (master) │ Opus 4 5 │ v2.0.76
57-
Context: 21% (43,000 tokens) │ 5h: 14% 7d: 46%
58-
Tools: Sequential │ Tasks: 2/5
78+
claude-plugins (master) │ GLM 5.1 │ v2.0.76 │ explanatory
79+
ctx: ██░░░░░░░░ 21% (43k/200k tokens) │ tokens: 15% │ tools: 11% (883 left) Web:35 ZRead:82
80+
Tools: Seq Ctx7 │ Agents: 1 active
5981
```
6082

6183
**Note**: Empty values are automatically hidden (no "None", no "0%", no "No tasks").
84+
Provider is auto-detected from the model name.
6285

6386
## Related Commands
6487

6588
- `/statusline:status` — View current metrics
66-
- `/statusline:enable` — Enable monitoring
6789
- `/statusline:disable` — Disable monitoring

0 commit comments

Comments
 (0)