ccstatusline-usage 2.1.7 → 2.1.11

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 (3) hide show
  1. package/README.md +157 -34
  2. package/dist/ccstatusline.js +1264 -1244
  3. package/package.json +1 -3
package/README.md CHANGED
@@ -9,21 +9,38 @@
9
9
 
10
10
  </pre>
11
11
 
12
- # ccstatusline
12
+ # ccstatusline-usage
13
13
 
14
14
  **🎨 A highly customizable status line formatter for Claude Code CLI**
15
- *Display model info, git branch, token usage, and other metrics in your terminal*
15
+ *Display model info, git branch, token usage, API usage, and other metrics in your terminal*
16
16
 
17
- [![npm version](https://img.shields.io/npm/v/ccstatusline.svg)](https://www.npmjs.com/package/ccstatusline)
18
- [![npm downloads](https://img.shields.io/npm/dm/ccstatusline.svg)](https://www.npmjs.com/package/ccstatusline)
17
+ > Fork of [sirmalloc/ccstatusline](https://github.com/sirmalloc/ccstatusline) with added **API usage widgets** (session/weekly utilization bars, reset timer, context bar).
18
+
19
+ [![npm version](https://img.shields.io/npm/v/ccstatusline-usage.svg)](https://www.npmjs.com/package/ccstatusline-usage)
20
+ [![npm downloads](https://img.shields.io/npm/dm/ccstatusline-usage.svg)](https://www.npmjs.com/package/ccstatusline-usage)
19
21
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/sirmalloc/ccstatusline/blob/main/LICENSE)
20
- [![Node.js Version](https://img.shields.io/node/v/ccstatusline.svg)](https://nodejs.org)
21
- [![install size](https://packagephobia.com/badge?p=ccstatusline)](https://packagephobia.com/result?p=ccstatusline)
22
- [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/sirmalloc/ccstatusline/graphs/commit-activity)
22
+ [![Node.js Version](https://img.shields.io/node/v/ccstatusline-usage.svg)](https://nodejs.org)
23
+ [![install size](https://packagephobia.com/badge?p=ccstatusline-usage)](https://packagephobia.com/result?p=ccstatusline-usage)
24
+ [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/pcvelz/ccstatusline-usage/graphs/commit-activity)
23
25
 
24
26
  [![Mentioned in Awesome Claude Code](https://awesome.re/mentioned-badge.svg)](https://github.com/hesreallyhim/awesome-claude-code)
25
27
  [![ClaudeLog - A comprehensive knowledge base for Claude](https://claudelog.com/img/claude_log_badge.svg)](https://claudelog.com/)
26
28
 
29
+ ## Fork Enhancements
30
+
31
+ This fork adds API-based usage widgets beyond the upstream:
32
+
33
+ - **Session/Weekly Usage** - Real utilization from Anthropic API with progress bars
34
+ - **Reset Timer** - Time until 5-hour session window resets
35
+ - **Context Window Display** - Visual bar showing context usage
36
+ - **Two-line Layout** - Session info on line 1, context on line 2
37
+
38
+ ### Enhanced Status Line Preview
39
+
40
+ ```
41
+ Session: [████░░░░░░░░░░░] 27.0% | Weekly: [████████████░░░] 86.0% | 1:56 hr | Model: Opus 4.6 ▌▌▌ | Session ID: 0109b99d...
42
+ Context: [███████░░░░░░░░] 103k/200k (51%)
43
+ ```
27
44
 
28
45
  ![Demo](https://raw.githubusercontent.com/sirmalloc/ccstatusline/main/screenshots/demo.gif)
29
46
 
@@ -39,6 +56,7 @@
39
56
  - [API Documentation](#-api-documentation)
40
57
  - [Development](#️-development)
41
58
  - [Contributing](#-contributing)
59
+ - [Uninstall](#️-uninstall)
42
60
  - [License](#-license)
43
61
  - [Related Projects](#-related-projects)
44
62
 
@@ -46,6 +64,14 @@
46
64
 
47
65
  ## 🆕 Recent Updates
48
66
 
67
+ ### [v2.1.11](https://github.com/pcvelz/ccstatusline-usage/releases/tag/v2.1.11) - Configurable extra usage balance
68
+
69
+ - [pcvelz/ccstatusline-usage](https://github.com/pcvelz/ccstatusline-usage): **Configurable extra usage balance** — Add `extraUsageBalance` setting (in cents) to `~/.config/ccstatusline/settings.json` to override the API's monthly limit with your actual prepaid balance (e.g., `"extraUsageBalance": 5000` shows `Extra: €0.00/€50.00`)
70
+
71
+ ### [v2.1.8](https://github.com/pcvelz/ccstatusline-usage/releases/tag/v2.1.8) - Windows support for API usage widgets
72
+
73
+ - [pcvelz/ccstatusline-usage](https://github.com/pcvelz/ccstatusline-usage): **Windows compatibility** — API usage widgets now work on Windows by using `os.homedir()` instead of `process.env.HOME` for credential and cache file paths
74
+
49
75
  ### [v2.1.7](https://github.com/pcvelz/ccstatusline-usage/releases/tag/v2.1.7) - Battery widget, extra usage fix & upstream sync
50
76
 
51
77
  - [pcvelz/ccstatusline-usage](https://github.com/pcvelz/ccstatusline-usage): **Battery widget** — shows `B: xx%` on macOS and Linux when on battery power (hidden when charging)
@@ -143,10 +169,13 @@
143
169
  ## ✨ Features
144
170
 
145
171
  - **📊 Real-time Metrics** - Display model name, git branch, token usage, session duration, block timer, and more
172
+ - **📈 API Usage Tracking** - Real-time 5-hour session and weekly utilization from Anthropic API with progress bars
173
+ - **⏱️ Reset Timer** - Countdown to when your 5-hour session window resets
146
174
  - **🎨 Fully Customizable** - Choose what to display and customize colors for each element
147
175
  - **⚡ Powerline Support** - Beautiful Powerline-style rendering with arrow separators, caps, and custom fonts
148
176
  - **📐 Multi-line Support** - Configure multiple independent status lines
149
177
  - **🖥️ Interactive TUI** - Built-in configuration interface using React/Ink
178
+ - **🔎 Fast Widget Picker** - Add/change widgets by category with search and ranked matching
150
179
  - **⚙️ Global Options** - Apply consistent formatting across all widgets (padding, separators, bold, background)
151
180
  - **🚀 Cross-platform** - Works seamlessly with both Bun and Node.js
152
181
  - **🔧 Flexible Configuration** - Supports custom Claude Code config directory via `CLAUDE_CONFIG_DIR` environment variable
@@ -161,10 +190,10 @@
161
190
 
162
191
  ```bash
163
192
  # Run the configuration TUI with npm
164
- npx ccstatusline@latest
193
+ npx -y ccstatusline-usage@latest
165
194
 
166
195
  # Or with Bun (faster)
167
- bunx ccstatusline@latest
196
+ bunx -y ccstatusline-usage@latest
168
197
  ```
169
198
 
170
199
  ### Configure ccstatusline
@@ -189,6 +218,24 @@ The interactive configuration tool provides a terminal UI where you can:
189
218
  > $env:CLAUDE_CONFIG_DIR="C:\custom\path\.claude"
190
219
  > ```
191
220
 
221
+ ### Claude Code settings.json format
222
+
223
+ When you install from the TUI, ccstatusline writes a `statusLine` command object to your Claude Code settings:
224
+
225
+ ```json
226
+ {
227
+ "statusLine": {
228
+ "type": "command",
229
+ "command": "npx -y ccstatusline-usage@latest",
230
+ "padding": 0
231
+ }
232
+ }
233
+ ```
234
+
235
+ Other supported command values are:
236
+ - `bunx -y ccstatusline-usage@latest`
237
+ - `ccstatusline` (for self-managed/global installs)
238
+
192
239
  ---
193
240
 
194
241
  ## 🪟 Windows Support
@@ -203,13 +250,13 @@ ccstatusline works seamlessly on Windows with full feature compatibility across
203
250
  irm bun.sh/install.ps1 | iex
204
251
 
205
252
  # Run ccstatusline
206
- bunx ccstatusline@latest
253
+ bunx -y ccstatusline@latest
207
254
  ```
208
255
 
209
256
  #### Option 2: Using Node.js
210
257
  ```powershell
211
258
  # Using npm
212
- npx ccstatusline@latest
259
+ npx -y ccstatusline@latest
213
260
 
214
261
  # Or with Yarn
215
262
  yarn dlx ccstatusline@latest
@@ -270,7 +317,7 @@ winget install Git.Git
270
317
  **Issue**: Permission errors during installation
271
318
  ```powershell
272
319
  # Use non-global installation (recommended)
273
- npx ccstatusline@latest
320
+ npx -y ccstatusline@latest
274
321
 
275
322
  # Or run PowerShell as Administrator for global install
276
323
  ```
@@ -298,7 +345,7 @@ ccstatusline works perfectly in WSL environments:
298
345
  # Install in WSL Ubuntu/Debian
299
346
  curl -fsSL https://bun.sh/install | bash
300
347
  source ~/.bashrc
301
- bunx ccstatusline@latest
348
+ bunx -y ccstatusline@latest
302
349
  ```
303
350
 
304
351
  **WSL Benefits**:
@@ -335,14 +382,22 @@ Configure ccstatusline in your Claude Code settings:
335
382
  **For Bun users**:
336
383
  ```json
337
384
  {
338
- "statusLine": "bunx ccstatusline@latest"
385
+ "statusLine": {
386
+ "type": "command",
387
+ "command": "bunx -y ccstatusline@latest",
388
+ "padding": 0
389
+ }
339
390
  }
340
391
  ```
341
392
 
342
393
  **For npm users**:
343
394
  ```json
344
395
  {
345
- "statusLine": "npx ccstatusline@latest"
396
+ "statusLine": {
397
+ "type": "command",
398
+ "command": "npx -y ccstatusline@latest",
399
+ "padding": 0
400
+ }
346
401
  }
347
402
  ```
348
403
 
@@ -350,11 +405,10 @@ Configure ccstatusline in your Claude Code settings:
350
405
 
351
406
  ### Performance on Windows
352
407
 
353
- ccstatusline is optimized for Windows performance:
354
- - **Bun runtime**: Significantly faster startup times on Windows
355
- - **Caching**: Intelligent caching of git status and file operations
356
- - **Async operations**: Non-blocking command execution
357
- - **Memory efficient**: Minimal resource usage
408
+ ccstatusline includes Windows-specific runtime behavior:
409
+ - **UTF-8 piped output fix**: In piped mode, it attempts to set code page `65001` for reliable symbol rendering
410
+ - **Path compatibility**: Git and CWD widgets handle both `/` and `\` separators
411
+ - **Block timer cache**: Cached block metrics reduce repeated JSONL scanning
358
412
 
359
413
  ### Windows-Specific Widget Behavior
360
414
 
@@ -371,17 +425,31 @@ Some widgets have Windows-specific optimizations:
371
425
 
372
426
  Once configured, ccstatusline automatically formats your Claude Code status line. The status line appears at the bottom of your terminal during Claude Code sessions.
373
427
 
428
+ ### Runtime Modes
429
+
430
+ - **Interactive mode (TUI)**: Launches when there is no stdin input
431
+ - **Piped mode (renderer)**: Parses Claude Code status JSON from stdin and prints one or more formatted lines
432
+
433
+ ```bash
434
+ # Interactive TUI
435
+ bun run start
436
+
437
+ # Piped mode with example payload
438
+ bun run example
439
+ ```
440
+
374
441
  ### 📊 Available Widgets
375
442
 
376
443
  - **Model Name** - Shows the current Claude model (e.g., "Claude 3.5 Sonnet")
377
444
  - **Git Branch** - Displays current git branch name
378
445
  - **Git Changes** - Shows uncommitted insertions/deletions (e.g., "+42,-10")
446
+ - **Git Root Dir** - Shows the git repository root directory name
379
447
  - **Git Worktree** - Shows the name of the current git worktree
380
448
  - **Session Clock** - Shows elapsed time since session start (e.g., "2hr 15m")
381
449
  - **Session Cost** - Shows total session cost in USD (e.g., "$1.23")
382
450
  - **Session Name** - Shows the session name set via `/rename` command in Claude Code
383
451
  - **Block Timer** - Shows time elapsed in current 5-hour block or progress bar
384
- - **Current Working Directory** - Shows current working directory with configurable path segments
452
+ - **Current Working Directory** - Shows current working directory with segment limit, fish-style abbreviation, and optional `~` home abbreviation
385
453
  - **Version** - Shows Claude Code version
386
454
  - **Output Style** - Shows the currently set output style in Claude Code
387
455
  - **Tokens Input** - Shows input tokens used
@@ -389,15 +457,20 @@ Once configured, ccstatusline automatically formats your Claude Code status line
389
457
  - **Tokens Cached** - Shows cached tokens used
390
458
  - **Tokens Total** - Shows total tokens used
391
459
  - **Context Length** - Shows current context length in tokens
392
- - **Context Percentage** - Shows percentage of context limit used (dynamic: 1M for Sonnet 4.5 with `[1m]` suffix, 200k otherwise)
393
- - **Context Percentage (usable)** - Shows percentage of usable context (dynamic: 800k for Sonnet 4.5 with `[1m]` suffix, 160k otherwise, accounting for auto-compact at 80%)
460
+ - **Context Percentage** - Shows percentage of context limit used (dynamic: 1M for model IDs with `[1m]` suffix, 200k otherwise)
461
+ - **Context Percentage (usable)** - Shows percentage of usable context (dynamic: 800k for model IDs with `[1m]` suffix, 160k otherwise, accounting for auto-compact at 80%)
394
462
  - **Terminal Width** - Shows detected terminal width (for debugging)
395
463
  - **Memory Usage** - Shows system memory usage (used/total, e.g., "Mem: 12.4G/16.0G")
396
464
  - **Battery** - Shows battery percentage on macOS and Linux (only visible when on battery power, hidden when charging)
465
+ - **Claude Session ID** - Shows the current Claude Code session ID (compact: 8-char truncation)
466
+ - **Session Usage** *(ccstatusline-usage)* - Shows 5-hour session API utilization as a progress bar (e.g., "Session: [███░░░░░░░░░░░░] 20%")
467
+ - **Weekly Usage** *(ccstatusline-usage)* - Shows 7-day API utilization as a progress bar (e.g., "Weekly: [██░░░░░░░░░░░░░] 12%")
468
+ - **Reset Timer** *(ccstatusline-usage)* - Shows time until session limit resets (e.g., "4:30 hr"), or extra usage spending when weekly budget is exhausted
469
+ - **Context Bar** *(ccstatusline-usage)* - Shows context window usage as a progress bar (e.g., "Context: [████░░░░░░░░░░░] 50k/200k (25%)")
397
470
  - **Custom Text** - Add your own custom text to the status line
398
471
  - **Custom Command** - Execute shell commands and display their output (refreshes whenever the statusline is updated by Claude Code)
399
- - **Separator** - Visual divider between widgets (customizable: |, -, comma, space)
400
- - **Flex Separator** - Expands to fill available space
472
+ - **Separator** - Visual divider between widgets (customizable: |, -, comma, space; available when Powerline mode is off and no default separator is configured)
473
+ - **Flex Separator** - Expands to fill available space (available when Powerline mode is off)
401
474
 
402
475
  ---
403
476
 
@@ -467,6 +540,23 @@ Some widgets support "raw value" mode which displays just the value without a la
467
540
  - Normal: `Block: 3hr 45m` → Raw: `3hr 45m`
468
541
  - Normal: `Ctx: 18.6k` → Raw: `18.6k`
469
542
 
543
+ ### ⌨️ Widget Editor Keybinds
544
+
545
+ Common controls in the line editor:
546
+ - `a` add widget
547
+ - `i` insert widget
548
+ - `Enter` enter/exit move mode
549
+ - `d` delete selected widget
550
+ - `r` toggle raw value (supported widgets)
551
+ - `m` cycle merge mode (`off` → `merge` → `merge no padding`)
552
+
553
+ Widget-specific shortcuts:
554
+ - **Git widgets**: `h` toggle hide `no git` output
555
+ - **Context % widgets**: `l` toggle used vs remaining display
556
+ - **Block Timer**: `p` cycle display mode (time/full bar/short bar)
557
+ - **Current Working Dir**: `h` home abbreviation, `s` segment editor, `f` fish-style path
558
+ - **Custom Command**: `e` command, `w` max width, `t` timeout, `p` preserve ANSI colors
559
+
470
560
  ---
471
561
 
472
562
  ### 🔧 Custom Widgets
@@ -483,6 +573,8 @@ Execute shell commands and display their output dynamically:
483
573
  - Receives the full Claude Code JSON data via stdin (model info, session ID, transcript path, etc.)
484
574
  - Displays command output inline in your status line
485
575
  - Configurable timeout (default: 1000ms)
576
+ - Optional max-width truncation
577
+ - Optional ANSI color preservation (`preserve colors`)
486
578
  - Examples:
487
579
  - `pwd | xargs basename` - Show current directory name
488
580
  - `node -v` - Display Node.js version
@@ -554,7 +646,7 @@ The documentation will be generated in the `docs/` directory and can be viewed b
554
646
 
555
647
  - [Bun](https://bun.sh) (v1.0+)
556
648
  - Git
557
- - Node.js 18+ (optional, for npm publishing)
649
+ - Node.js 14+ (optional, for running the built `dist/ccstatusline.js` binary or npm publishing)
558
650
 
559
651
  ### Setup
560
652
 
@@ -570,13 +662,38 @@ bun install
570
662
  ### Development Commands
571
663
 
572
664
  ```bash
573
- # Run in TUI mode (configuration)
574
- bun run src/ccstatusline.ts
665
+ # Run in TUI mode
666
+ bun run start
667
+
668
+ # Test piped mode with example payload
669
+ bun run example
670
+
671
+ # Run tests
672
+ bun test
673
+
674
+ # Run typecheck + eslint autofix
675
+ bun run lint
575
676
 
576
677
  # Build for distribution
577
678
  bun run build
679
+
680
+ # Generate TypeDoc documentation
681
+ bun run docs
578
682
  ```
579
683
 
684
+ ### Configuration Files
685
+
686
+ - `~/.config/ccstatusline/settings.json` - ccstatusline UI/render settings
687
+ - `~/.claude/settings.json` - Claude Code settings (`statusLine` command object)
688
+ - `~/.cache/ccstatusline/block-cache-*.json` - block timer cache (keyed by Claude config directory hash)
689
+
690
+ If you use a custom Claude config location, set `CLAUDE_CONFIG_DIR` and ccstatusline will read/write that path instead of `~/.claude`.
691
+
692
+ ### Build Notes
693
+
694
+ - Build target is Node.js 14+ (`dist/ccstatusline.js`)
695
+ - During install, `ink@6.2.0` is patched to fix backspace handling on macOS terminals
696
+
580
697
  ### 📁 Project Structure
581
698
 
582
699
  ```
@@ -627,11 +744,13 @@ Contributions are welcome! Please feel free to submit a Pull Request.
627
744
 
628
745
  ---
629
746
 
630
- ## Support
747
+ ## 🗑️ Uninstall
631
748
 
632
- If ccstatusline is useful to you, consider buying me a coffee:
633
-
634
- <a href="https://www.buymeacoffee.com/sirmalloc" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
749
+ ```bash
750
+ npm uninstall -g ccstatusline-usage
751
+ rm -rf ~/.npm/_npx ~/.config/ccstatusline ~/.cache/ccstatusline*
752
+ jq 'del(.statusLine)' ~/.claude/settings.json > /tmp/cs.json && cat /tmp/cs.json > ~/.claude/settings.json
753
+ ```
635
754
 
636
755
  ---
637
756
 
@@ -647,6 +766,10 @@ If ccstatusline is useful to you, consider buying me a coffee:
647
766
 
648
767
  - GitHub: [@sirmalloc](https://github.com/sirmalloc)
649
768
 
769
+ **PC van Velzen** ([pcvelz/ccstatusline-usage](https://github.com/pcvelz/ccstatusline-usage) fork)
770
+
771
+ - GitHub: [@pcvelz](https://github.com/pcvelz)
772
+
650
773
  ---
651
774
 
652
775
  ## 🔗 Related Projects
@@ -684,8 +807,8 @@ Give a ⭐ if this project helped you!
684
807
  [![GitHub forks](https://img.shields.io/github/forks/sirmalloc/ccstatusline?style=social)](https://github.com/sirmalloc/ccstatusline/network/members)
685
808
  [![GitHub watchers](https://img.shields.io/github/watchers/sirmalloc/ccstatusline?style=social)](https://github.com/sirmalloc/ccstatusline/watchers)
686
809
 
687
- [![npm version](https://img.shields.io/npm/v/ccstatusline.svg)](https://www.npmjs.com/package/ccstatusline)
688
- [![npm downloads](https://img.shields.io/npm/dm/ccstatusline.svg)](https://www.npmjs.com/package/ccstatusline)
810
+ [![npm version](https://img.shields.io/npm/v/ccstatusline-usage.svg)](https://www.npmjs.com/package/ccstatusline-usage)
811
+ [![npm downloads](https://img.shields.io/npm/dm/ccstatusline-usage.svg)](https://www.npmjs.com/package/ccstatusline-usage)
689
812
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/sirmalloc/ccstatusline/blob/main/LICENSE)
690
813
  [![Made with Bun](https://img.shields.io/badge/Made%20with-Bun-000000.svg?logo=bun)](https://bun.sh)
691
814