claude-quota-bar 0.3.3 → 0.5.0

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 (2) hide show
  1. package/README.md +27 -7
  2. package/package.json +9 -9
package/README.md CHANGED
@@ -1,13 +1,16 @@
1
1
  # claude-quota-bar
2
2
 
3
3
  Fast Rust statusline for [Claude Code](https://github.com/anthropics/claude-code).
4
- Battery-style 5-hour / 7-day quota bars, context-window indicator, prompt-cache
5
- state, and `dir:branch *N` — at ~2.5ms cold start and a ~0.5MB binary.
4
+ Battery-style 5-hour / 7-day quota bars, context-window indicator, session
5
+ active time, and `dir:branch *N` — at ~2.5ms cold start and a ~0.5MB binary.
6
6
 
7
7
  ```
8
- 5h[███42%░░░░]⏰26m | 7d[███35%░░░░]⏰8d3h | Opus 4.7(71.0k/1.0M) | cache 4m12s | proj:main *3
8
+ 5h[███42%░░░░]⏰26m | 7d[███35%░░░░]⏰8d3h | Opus 4.7(71.0k/1.0M) | ⏱2h15m | proj:main *3
9
9
  ```
10
10
 
11
+ Requires Claude Code ≥ 2.1.132 (where `context_window.total_input_tokens`
12
+ reports the current context occupancy rather than a cumulative session total).
13
+
11
14
  ## Why this and not the Python ones
12
15
 
13
16
  - **Speed.** Claude Code renders statusLine on every prompt. Python is ~50ms cold
@@ -44,16 +47,34 @@ Then wire it into Claude Code (`~/.claude/settings.json`):
44
47
 
45
48
  ## Segments
46
49
 
47
- Default layout: `5h,7d,model,cache,dir`.
50
+ Default layout: `5h,7d,model,session,dir`.
48
51
 
49
52
  | Segment | Source | What it shows |
50
53
  |---------|--------|---------------|
51
54
  | `5h` | `rate_limits.five_hour` | Battery bar with `%` inside, plus `⏰` countdown to reset |
52
55
  | `7d` | `rate_limits.seven_day` | Same, weekly window |
53
56
  | `model` | `model` + `context_window` | `Opus 4.7(71.0k/1.0M)` — model + ctx tokens used / window |
54
- | `cache` | transcript scan | Time left on the prompt cache (`4m12s`), or `COLD` once it has expired |
57
+ | `session` | own ledger per `session_id` | `⏱2h15m` active time this session, idle gaps excluded |
55
58
  | `dir` | `workspace.current_dir` + git | `proj:main *3 ↑1 ↓2` — dir, branch, dirty count, ahead/behind |
56
59
 
60
+ ### How `session` counts time
61
+
62
+ Claude Code's own `cost.total_duration_ms` is wall-clock since process start:
63
+ it keeps growing while you're at lunch and resets to zero on `--resume`.
64
+ Instead, this bar keeps its own per-session ledger
65
+ (`~/.cache/claude-quota-bar/sessions/<session_id>.json`), treating each
66
+ statusline render as a heartbeat:
67
+
68
+ - Gaps **≤ 15 minutes** between renders count as active time (think-time,
69
+ long builds). Longer gaps are interruptions and are dropped.
70
+ - A render only accrues when the payload shows progress
71
+ (`total_api_duration_ms` changed), so `statusLine.refreshInterval` users
72
+ don't accumulate idle wall-clock.
73
+ - `--resume` / `--continue` keep their session_id, so the counter picks up
74
+ where it left off. `--fork-session` / `/branch` get a fresh counter.
75
+
76
+ Ledgers untouched for 7 days are swept automatically.
77
+
57
78
  When Anthropic hasn't yet shipped `rate_limits` (first few renders of a fresh
58
79
  session), the bar displays `--%`. A cross-session cache at
59
80
  `~/.cache/claude-quota-bar/last_stdin.json` restores the most recent values, so
@@ -65,8 +86,7 @@ Configured via environment variables:
65
86
 
66
87
  | Variable | Default | Meaning |
67
88
  |----------|---------|---------|
68
- | `STATUSLINE_LAYOUT` | `5h,7d,model,cache,dir` | Comma-separated segment names (order matters) |
69
- | `STATUSLINE_CACHE_TTL` | `3600` | Prompt-cache lifetime in seconds. The default assumes the 1-hour extended cache that Claude.ai Pro/Max accounts get automatically; set `300` for the standard 5-minute cache. The active TTL isn't exposed to the statusline, so it can't be auto-detected. |
89
+ | `STATUSLINE_LAYOUT` | `5h,7d,model,session,dir` | Comma-separated segment names (order matters) |
70
90
  | `NO_COLOR` | unset | If set, strips all ANSI — falls back to `█`/`░` glyphs |
71
91
 
72
92
  Severity thresholds (green / yellow / red) flip at 30% and 70% quota used.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "claude-quota-bar",
3
- "version": "0.3.3",
4
- "description": "Fast Rust statusline for Claude Code — battery-bar 5h/7d quota, ctx, cache age, git",
3
+ "version": "0.5.0",
4
+ "description": "Fast Rust statusline for Claude Code — battery-bar 5h/7d quota, ctx, git",
5
5
  "keywords": [
6
6
  "claude",
7
7
  "statusline",
@@ -29,12 +29,12 @@
29
29
  "node": ">=16"
30
30
  },
31
31
  "optionalDependencies": {
32
- "claude-quota-bar-darwin-arm64": "0.3.3",
33
- "claude-quota-bar-darwin-x64": "0.3.3",
34
- "claude-quota-bar-linux-x64": "0.3.3",
35
- "claude-quota-bar-linux-x64-musl": "0.3.3",
36
- "claude-quota-bar-linux-arm64": "0.3.3",
37
- "claude-quota-bar-linux-arm64-musl": "0.3.3",
38
- "claude-quota-bar-win32-x64": "0.3.3"
32
+ "claude-quota-bar-darwin-arm64": "0.5.0",
33
+ "claude-quota-bar-darwin-x64": "0.5.0",
34
+ "claude-quota-bar-linux-x64": "0.5.0",
35
+ "claude-quota-bar-linux-x64-musl": "0.5.0",
36
+ "claude-quota-bar-linux-arm64": "0.5.0",
37
+ "claude-quota-bar-linux-arm64-musl": "0.5.0",
38
+ "claude-quota-bar-win32-x64": "0.5.0"
39
39
  }
40
40
  }