ccstatusline-usage 2.1.8 → 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.
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,10 @@
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
+
49
71
  ### [v2.1.8](https://github.com/pcvelz/ccstatusline-usage/releases/tag/v2.1.8) - Windows support for API usage widgets
50
72
 
51
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
@@ -147,10 +169,13 @@
147
169
  ## ✨ Features
148
170
 
149
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
150
174
  - **🎨 Fully Customizable** - Choose what to display and customize colors for each element
151
175
  - **⚡ Powerline Support** - Beautiful Powerline-style rendering with arrow separators, caps, and custom fonts
152
176
  - **📐 Multi-line Support** - Configure multiple independent status lines
153
177
  - **🖥️ Interactive TUI** - Built-in configuration interface using React/Ink
178
+ - **🔎 Fast Widget Picker** - Add/change widgets by category with search and ranked matching
154
179
  - **⚙️ Global Options** - Apply consistent formatting across all widgets (padding, separators, bold, background)
155
180
  - **🚀 Cross-platform** - Works seamlessly with both Bun and Node.js
156
181
  - **🔧 Flexible Configuration** - Supports custom Claude Code config directory via `CLAUDE_CONFIG_DIR` environment variable
@@ -165,10 +190,10 @@
165
190
 
166
191
  ```bash
167
192
  # Run the configuration TUI with npm
168
- npx ccstatusline@latest
193
+ npx -y ccstatusline-usage@latest
169
194
 
170
195
  # Or with Bun (faster)
171
- bunx ccstatusline@latest
196
+ bunx -y ccstatusline-usage@latest
172
197
  ```
173
198
 
174
199
  ### Configure ccstatusline
@@ -193,6 +218,24 @@ The interactive configuration tool provides a terminal UI where you can:
193
218
  > $env:CLAUDE_CONFIG_DIR="C:\custom\path\.claude"
194
219
  > ```
195
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
+
196
239
  ---
197
240
 
198
241
  ## 🪟 Windows Support
@@ -207,13 +250,13 @@ ccstatusline works seamlessly on Windows with full feature compatibility across
207
250
  irm bun.sh/install.ps1 | iex
208
251
 
209
252
  # Run ccstatusline
210
- bunx ccstatusline@latest
253
+ bunx -y ccstatusline@latest
211
254
  ```
212
255
 
213
256
  #### Option 2: Using Node.js
214
257
  ```powershell
215
258
  # Using npm
216
- npx ccstatusline@latest
259
+ npx -y ccstatusline@latest
217
260
 
218
261
  # Or with Yarn
219
262
  yarn dlx ccstatusline@latest
@@ -274,7 +317,7 @@ winget install Git.Git
274
317
  **Issue**: Permission errors during installation
275
318
  ```powershell
276
319
  # Use non-global installation (recommended)
277
- npx ccstatusline@latest
320
+ npx -y ccstatusline@latest
278
321
 
279
322
  # Or run PowerShell as Administrator for global install
280
323
  ```
@@ -302,7 +345,7 @@ ccstatusline works perfectly in WSL environments:
302
345
  # Install in WSL Ubuntu/Debian
303
346
  curl -fsSL https://bun.sh/install | bash
304
347
  source ~/.bashrc
305
- bunx ccstatusline@latest
348
+ bunx -y ccstatusline@latest
306
349
  ```
307
350
 
308
351
  **WSL Benefits**:
@@ -339,14 +382,22 @@ Configure ccstatusline in your Claude Code settings:
339
382
  **For Bun users**:
340
383
  ```json
341
384
  {
342
- "statusLine": "bunx ccstatusline@latest"
385
+ "statusLine": {
386
+ "type": "command",
387
+ "command": "bunx -y ccstatusline@latest",
388
+ "padding": 0
389
+ }
343
390
  }
344
391
  ```
345
392
 
346
393
  **For npm users**:
347
394
  ```json
348
395
  {
349
- "statusLine": "npx ccstatusline@latest"
396
+ "statusLine": {
397
+ "type": "command",
398
+ "command": "npx -y ccstatusline@latest",
399
+ "padding": 0
400
+ }
350
401
  }
351
402
  ```
352
403
 
@@ -354,11 +405,10 @@ Configure ccstatusline in your Claude Code settings:
354
405
 
355
406
  ### Performance on Windows
356
407
 
357
- ccstatusline is optimized for Windows performance:
358
- - **Bun runtime**: Significantly faster startup times on Windows
359
- - **Caching**: Intelligent caching of git status and file operations
360
- - **Async operations**: Non-blocking command execution
361
- - **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
362
412
 
363
413
  ### Windows-Specific Widget Behavior
364
414
 
@@ -375,17 +425,31 @@ Some widgets have Windows-specific optimizations:
375
425
 
376
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.
377
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
+
378
441
  ### 📊 Available Widgets
379
442
 
380
443
  - **Model Name** - Shows the current Claude model (e.g., "Claude 3.5 Sonnet")
381
444
  - **Git Branch** - Displays current git branch name
382
445
  - **Git Changes** - Shows uncommitted insertions/deletions (e.g., "+42,-10")
446
+ - **Git Root Dir** - Shows the git repository root directory name
383
447
  - **Git Worktree** - Shows the name of the current git worktree
384
448
  - **Session Clock** - Shows elapsed time since session start (e.g., "2hr 15m")
385
449
  - **Session Cost** - Shows total session cost in USD (e.g., "$1.23")
386
450
  - **Session Name** - Shows the session name set via `/rename` command in Claude Code
387
451
  - **Block Timer** - Shows time elapsed in current 5-hour block or progress bar
388
- - **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
389
453
  - **Version** - Shows Claude Code version
390
454
  - **Output Style** - Shows the currently set output style in Claude Code
391
455
  - **Tokens Input** - Shows input tokens used
@@ -393,15 +457,20 @@ Once configured, ccstatusline automatically formats your Claude Code status line
393
457
  - **Tokens Cached** - Shows cached tokens used
394
458
  - **Tokens Total** - Shows total tokens used
395
459
  - **Context Length** - Shows current context length in tokens
396
- - **Context Percentage** - Shows percentage of context limit used (dynamic: 1M for Sonnet 4.5 with `[1m]` suffix, 200k otherwise)
397
- - **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%)
398
462
  - **Terminal Width** - Shows detected terminal width (for debugging)
399
463
  - **Memory Usage** - Shows system memory usage (used/total, e.g., "Mem: 12.4G/16.0G")
400
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%)")
401
470
  - **Custom Text** - Add your own custom text to the status line
402
471
  - **Custom Command** - Execute shell commands and display their output (refreshes whenever the statusline is updated by Claude Code)
403
- - **Separator** - Visual divider between widgets (customizable: |, -, comma, space)
404
- - **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)
405
474
 
406
475
  ---
407
476
 
@@ -471,6 +540,23 @@ Some widgets support "raw value" mode which displays just the value without a la
471
540
  - Normal: `Block: 3hr 45m` → Raw: `3hr 45m`
472
541
  - Normal: `Ctx: 18.6k` → Raw: `18.6k`
473
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
+
474
560
  ---
475
561
 
476
562
  ### 🔧 Custom Widgets
@@ -487,6 +573,8 @@ Execute shell commands and display their output dynamically:
487
573
  - Receives the full Claude Code JSON data via stdin (model info, session ID, transcript path, etc.)
488
574
  - Displays command output inline in your status line
489
575
  - Configurable timeout (default: 1000ms)
576
+ - Optional max-width truncation
577
+ - Optional ANSI color preservation (`preserve colors`)
490
578
  - Examples:
491
579
  - `pwd | xargs basename` - Show current directory name
492
580
  - `node -v` - Display Node.js version
@@ -558,7 +646,7 @@ The documentation will be generated in the `docs/` directory and can be viewed b
558
646
 
559
647
  - [Bun](https://bun.sh) (v1.0+)
560
648
  - Git
561
- - Node.js 18+ (optional, for npm publishing)
649
+ - Node.js 14+ (optional, for running the built `dist/ccstatusline.js` binary or npm publishing)
562
650
 
563
651
  ### Setup
564
652
 
@@ -574,13 +662,38 @@ bun install
574
662
  ### Development Commands
575
663
 
576
664
  ```bash
577
- # Run in TUI mode (configuration)
578
- 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
579
676
 
580
677
  # Build for distribution
581
678
  bun run build
679
+
680
+ # Generate TypeDoc documentation
681
+ bun run docs
582
682
  ```
583
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
+
584
697
  ### 📁 Project Structure
585
698
 
586
699
  ```
@@ -631,11 +744,13 @@ Contributions are welcome! Please feel free to submit a Pull Request.
631
744
 
632
745
  ---
633
746
 
634
- ## Support
747
+ ## 🗑️ Uninstall
635
748
 
636
- If ccstatusline is useful to you, consider buying me a coffee:
637
-
638
- <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
+ ```
639
754
 
640
755
  ---
641
756
 
@@ -651,6 +766,10 @@ If ccstatusline is useful to you, consider buying me a coffee:
651
766
 
652
767
  - GitHub: [@sirmalloc](https://github.com/sirmalloc)
653
768
 
769
+ **PC van Velzen** ([pcvelz/ccstatusline-usage](https://github.com/pcvelz/ccstatusline-usage) fork)
770
+
771
+ - GitHub: [@pcvelz](https://github.com/pcvelz)
772
+
654
773
  ---
655
774
 
656
775
  ## 🔗 Related Projects
@@ -688,8 +807,8 @@ Give a ⭐ if this project helped you!
688
807
  [![GitHub forks](https://img.shields.io/github/forks/sirmalloc/ccstatusline?style=social)](https://github.com/sirmalloc/ccstatusline/network/members)
689
808
  [![GitHub watchers](https://img.shields.io/github/watchers/sirmalloc/ccstatusline?style=social)](https://github.com/sirmalloc/ccstatusline/watchers)
690
809
 
691
- [![npm version](https://img.shields.io/npm/v/ccstatusline.svg)](https://www.npmjs.com/package/ccstatusline)
692
- [![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)
693
812
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/sirmalloc/ccstatusline/blob/main/LICENSE)
694
813
  [![Made with Bun](https://img.shields.io/badge/Made%20with-Bun-000000.svg?logo=bun)](https://bun.sh)
695
814
 
@@ -51034,6 +51034,7 @@ var SettingsSchema = exports_external.object({
51034
51034
  theme: undefined,
51035
51035
  autoAlign: false
51036
51036
  }),
51037
+ extraUsageBalance: exports_external.number().optional(),
51037
51038
  updatemessage: exports_external.object({
51038
51039
  message: exports_external.string().nullable().optional(),
51039
51040
  remaining: exports_external.number().nullable().optional()
@@ -51469,7 +51470,7 @@ import { execSync as execSync3 } from "child_process";
51469
51470
  import * as fs5 from "fs";
51470
51471
  import * as path4 from "path";
51471
51472
  var __dirname = "/Users/peter/Documents/Code/ccstatusline-usage/src/utils";
51472
- var PACKAGE_VERSION = "2.1.8";
51473
+ var PACKAGE_VERSION = "2.1.11";
51473
51474
  function getPackageVersion() {
51474
51475
  if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
51475
51476
  return PACKAGE_VERSION;
@@ -55025,7 +55026,8 @@ class ResetTimerWidget {
55025
55026
  return getErrorMessage(data.error);
55026
55027
  if (data.extraUsageEnabled && data.weeklyUsage !== undefined && data.weeklyUsage >= 100 && data.extraUsageUsed !== undefined && data.extraUsageLimit !== undefined) {
55027
55028
  const used = formatCents(data.extraUsageUsed);
55028
- const limit = formatCents(data.extraUsageLimit);
55029
+ const displayLimit = settings.extraUsageBalance ?? data.extraUsageLimit;
55030
+ const limit = formatCents(displayLimit);
55029
55031
  return `Extra: ${used}/${limit}`;
55030
55032
  }
55031
55033
  if (!data.sessionResetAt)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccstatusline-usage",
3
- "version": "2.1.8",
3
+ "version": "2.1.11",
4
4
  "description": "A customizable status line formatter for Claude Code CLI",
5
5
  "module": "src/ccstatusline.ts",
6
6
  "type": "module",
@@ -17,8 +17,6 @@
17
17
  "example": "cat scripts/payload.example.json | bun start",
18
18
  "prepublishOnly": "bun run build",
19
19
  "lint": "bun tsc --noEmit; eslint . --config eslint.config.js --max-warnings=999999 --fix",
20
- "test": "bun vitest",
21
- "publish:safe": "bash scripts/safe-publish.sh",
22
20
  "docs": "typedoc",
23
21
  "docs:clean": "rm -rf docs"
24
22
  },