@say8425/cc-statusline 5.0.2 → 6.0.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.
- package/README.md +36 -13
- package/dist/index.js +33 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Add the following to `~/.claude/settings.json`:
|
|
|
52
52
|
## Features
|
|
53
53
|
|
|
54
54
|
- **Session Time**: Current session elapsed time
|
|
55
|
-
- **Cost**: Session cost in USD
|
|
55
|
+
- **Cost**: Session cost in USD — hidden by default, set `CC_STATUSLINE_SHOW_COST=1` to show (see [Configuration](#configuration))
|
|
56
56
|
- **Context**: Token usage with percentage (color-coded)
|
|
57
57
|
- **Model**: Current model name and reasoning effort (e.g., `Fable 5 high`; effort shown only for models that support it), with an `⚡ultra` badge when ultracode is enabled in your Claude Code settings and the session reports `xhigh` effort
|
|
58
58
|
- **Git Diff**: File count, insertions, deletions
|
|
@@ -64,6 +64,7 @@ Add the following to `~/.claude/settings.json`:
|
|
|
64
64
|
- **Block Usage**: 5-hour utilization percentage
|
|
65
65
|
- **Weekly Reset Timer**: Weekly limit reset time (MM/DD HH:MM)
|
|
66
66
|
- **Weekly Usage**: 7-day utilization percentage
|
|
67
|
+
- **Session ID**: Full session UUID at the end of the usage line, with no emoji label — ready to copy into `claude --resume <id>` or a log lookup
|
|
67
68
|
|
|
68
69
|
## Emoji Guide
|
|
69
70
|
|
|
@@ -73,16 +74,46 @@ Add the following to `~/.claude/settings.json`:
|
|
|
73
74
|
| 🌲 | Worktree name (click to open worktree folder) |
|
|
74
75
|
| 🌿 | Current Git branch |
|
|
75
76
|
| ⏱️ | Session elapsed time |
|
|
76
|
-
| 💰 | Session cost in USD
|
|
77
|
+
| 💰 | Session cost in USD (hidden by default — see [Configuration](#configuration)) |
|
|
77
78
|
| 🧠 | Context window usage |
|
|
78
79
|
| 🤖 | Current model and effort |
|
|
79
80
|
| ⏳ | Limit reset time |
|
|
80
81
|
| 📊 | 5-hour utilization % |
|
|
81
82
|
| ⏰ | Weekly limit reset time |
|
|
82
83
|
| 📅 | 7-day utilization % |
|
|
84
|
+
| _(none)_ | Session ID — the full UUID, shown after 📅 without an emoji label |
|
|
83
85
|
| ✏️ | Uncommitted changes (click to open diff viewer) |
|
|
84
86
|
| 📎 | Pull request link — color-coded state in brackets (`[Open]`/`[Draft]`/`[Merged]`/`[Closed]`) immediately followed by a color-coded CI check summary in parens (`(N passed)`/`(N running)`/`(N failed)`) when checks exist |
|
|
85
87
|
|
|
88
|
+
## Color Thresholds
|
|
89
|
+
|
|
90
|
+
| Metric | Normal (white) | Warning (yellow) | Critical (red) |
|
|
91
|
+
| ------------- | -------------- | ---------------- | -------------- |
|
|
92
|
+
| Context % | < 50% | 50-80% | > 80% |
|
|
93
|
+
| Block Usage % | < 50% | 50-80% | > 80% |
|
|
94
|
+
|
|
95
|
+
## Configuration
|
|
96
|
+
|
|
97
|
+
Everything is driven by the stdin JSON Claude Code provides, so there is nothing to configure for the defaults. These environment variables adjust what is rendered:
|
|
98
|
+
|
|
99
|
+
| Environment variable | Effect |
|
|
100
|
+
| -------------------- | ------ |
|
|
101
|
+
| `CC_STATUSLINE_SHOW_COST=1` | Show the `💰` session cost segment (hidden by default) |
|
|
102
|
+
| `CC_STATUSLINE_DIFF_PORT` | Change the diff viewer port (default: `49573`) |
|
|
103
|
+
| `CC_STATUSLINE_DIFF_DISABLE=1` | Disable the diff viewer entirely |
|
|
104
|
+
|
|
105
|
+
Set them where your statusline command runs — for example in `~/.claude/settings.json`:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"statusLine": {
|
|
110
|
+
"type": "command",
|
|
111
|
+
"command": "CC_STATUSLINE_SHOW_COST=1 bunx @say8425/cc-statusline",
|
|
112
|
+
"padding": 0
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
86
117
|
## Diff Viewer
|
|
87
118
|
|
|
88
119
|
Click `✏️` in the statusline to open a local diff viewer in your browser. The viewer itself is provided by [diffdeck](https://github.com/say8425/diffdeck) ([`@say8425/diffdeck`](https://www.npmjs.com/package/@say8425/diffdeck) on npm), installed automatically as a runtime dependency of cc-statusline — the statusline spawns it as a background daemon and links to it from the `✏️` entry point.
|
|
@@ -112,10 +143,7 @@ Click `✏️` in the statusline to open a local diff viewer in your browser. Th
|
|
|
112
143
|
|
|
113
144
|
The statusline spawns diffdeck as a background daemon on demand at `127.0.0.1:49573` whenever the repo has something to show. Requests are token-protected and bound to localhost.
|
|
114
145
|
|
|
115
|
-
|
|
116
|
-
| -------------------- | ------ |
|
|
117
|
-
| `CC_STATUSLINE_DIFF_PORT` | Change the port (default: `49573`) |
|
|
118
|
-
| `CC_STATUSLINE_DIFF_DISABLE=1` | Disable the diff viewer entirely |
|
|
146
|
+
The two `CC_STATUSLINE_DIFF_*` variables that control it are listed in [Configuration](#configuration).
|
|
119
147
|
|
|
120
148
|
> [!TIP]
|
|
121
149
|
> Open the viewer through the `✏️` link instead of a bookmark — the link always carries a fresh token and makes sure the server is running.
|
|
@@ -135,6 +163,8 @@ Claude Code passes `rate_limits` in the stdin JSON input (CLI 2.1.80+):
|
|
|
135
163
|
|
|
136
164
|
Usage metrics are **automatically displayed** when `rate_limits` is present in the stdin JSON. No additional flags or configuration needed.
|
|
137
165
|
|
|
166
|
+
The session ID (`session_id`) is appended to the end of the same line, after the 7-day utilization. It comes from a separate field, so it still shows on its own when `rate_limits` is absent.
|
|
167
|
+
|
|
138
168
|
> [!NOTE]
|
|
139
169
|
> `rate_limits` is only available for Claude.ai subscribers (Pro/Max) after the first API response. See the [official statusline docs](https://code.claude.com/docs/en/statusline) for the full JSON schema.
|
|
140
170
|
|
|
@@ -165,13 +195,6 @@ bun run lint
|
|
|
165
195
|
bun run format
|
|
166
196
|
```
|
|
167
197
|
|
|
168
|
-
## Color Thresholds
|
|
169
|
-
|
|
170
|
-
| Metric | Normal (white) | Warning (yellow) | Critical (red) |
|
|
171
|
-
| ------------- | -------------- | ---------------- | -------------- |
|
|
172
|
-
| Context % | < 50% | 50-80% | > 80% |
|
|
173
|
-
| Block Usage % | < 50% | 50-80% | > 80% |
|
|
174
|
-
|
|
175
198
|
## License
|
|
176
199
|
|
|
177
200
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
|
+
// src/config.ts
|
|
5
|
+
var isCostVisible = (env = process.env) => env.CC_STATUSLINE_SHOW_COST === "1";
|
|
6
|
+
|
|
4
7
|
// src/diff-server/ensure.ts
|
|
5
8
|
import { mkdirSync, readFileSync as readFileSync2, rmSync, statSync } from "fs";
|
|
6
9
|
import { dirname, join as join3 } from "path";
|
|
@@ -513,7 +516,10 @@ var renderStatusLine = (ctx) => {
|
|
|
513
516
|
line1 += ` | ${C.WHITE}\uD83C\uDF3F ${ctx.branch}${C.RESET}`;
|
|
514
517
|
}
|
|
515
518
|
lines.push(line1);
|
|
516
|
-
let line2 = `${C.WHITE}\u23F1\uFE0F ${formatTime(sessionHrs, sessionMins)}${C.RESET}
|
|
519
|
+
let line2 = `${C.WHITE}\u23F1\uFE0F ${formatTime(sessionHrs, sessionMins)}${C.RESET}`;
|
|
520
|
+
if (ctx.showCost) {
|
|
521
|
+
line2 += ` | ${C.WHITE}\uD83D\uDCB0 $${costUsd.toFixed(2)}${C.RESET}`;
|
|
522
|
+
}
|
|
517
523
|
const usedPercentage = ctx.claudeJson.context_window?.used_percentage;
|
|
518
524
|
if (usedPercentage != null) {
|
|
519
525
|
const usage = ctx.claudeJson.context_window?.current_usage;
|
|
@@ -531,31 +537,33 @@ var renderStatusLine = (ctx) => {
|
|
|
531
537
|
line2 += ` | ${C.WHITE}\uD83E\uDD16 ${modelText}${C.RESET}`;
|
|
532
538
|
}
|
|
533
539
|
lines.push(line2);
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
parts.push(`${C.WHITE}\u23F3 ${formatTime(h, m)}${C.RESET}`);
|
|
543
|
-
}
|
|
544
|
-
const usageColor = getUsageColor(used_percentage);
|
|
545
|
-
parts.push(`${usageColor}\uD83D\uDCCA ${Math.round(used_percentage)}/100${C.RESET}`);
|
|
540
|
+
const usageParts = [];
|
|
541
|
+
if (ctx.rateLimits?.five_hour) {
|
|
542
|
+
const { resets_at, used_percentage } = ctx.rateLimits.five_hour;
|
|
543
|
+
if (resets_at) {
|
|
544
|
+
const resetTime = new Date(resets_at * 1000);
|
|
545
|
+
const h = resetTime.getHours();
|
|
546
|
+
const m = resetTime.getMinutes();
|
|
547
|
+
usageParts.push(`${C.WHITE}\u23F3 ${formatTime(h, m)}${C.RESET}`);
|
|
546
548
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
if (parts.length > 0) {
|
|
557
|
-
lines.push(parts.join(" | "));
|
|
549
|
+
const usageColor = getUsageColor(used_percentage);
|
|
550
|
+
usageParts.push(`${usageColor}\uD83D\uDCCA ${Math.round(used_percentage)}/100${C.RESET}`);
|
|
551
|
+
}
|
|
552
|
+
if (ctx.rateLimits?.seven_day) {
|
|
553
|
+
const { resets_at, used_percentage } = ctx.rateLimits.seven_day;
|
|
554
|
+
if (resets_at) {
|
|
555
|
+
const resetTime = new Date(resets_at * 1000);
|
|
556
|
+
usageParts.push(`${C.WHITE}\u23F0 ${formatResetDate(resetTime)}${C.RESET}`);
|
|
558
557
|
}
|
|
558
|
+
const weekColor = getUsageColor(used_percentage);
|
|
559
|
+
usageParts.push(`${weekColor}\uD83D\uDCC5 ${Math.round(used_percentage)}/100${C.RESET}`);
|
|
560
|
+
}
|
|
561
|
+
const sessionId = ctx.claudeJson.session_id;
|
|
562
|
+
if (sessionId) {
|
|
563
|
+
usageParts.push(`${C.WHITE}${sessionId}${C.RESET}`);
|
|
564
|
+
}
|
|
565
|
+
if (usageParts.length > 0) {
|
|
566
|
+
lines.push(usageParts.join(" | "));
|
|
559
567
|
}
|
|
560
568
|
const hasGitChanges = ctx.gitChanges.files > 0 || ctx.gitChanges.insertions > 0 || ctx.gitChanges.deletions > 0;
|
|
561
569
|
if (hasGitChanges || ctx.baseChanges || ctx.prInfo) {
|
|
@@ -679,6 +687,7 @@ var main = async () => {
|
|
|
679
687
|
gitChanges,
|
|
680
688
|
prInfo,
|
|
681
689
|
ultracode,
|
|
690
|
+
showCost: isCostVisible(),
|
|
682
691
|
rateLimits: claudeJson.rate_limits ?? null,
|
|
683
692
|
mainProjectName,
|
|
684
693
|
diffViewerUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@say8425/cc-statusline",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Custom statusline for Claude Code",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"typecheck": "tsc --noEmit"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@say8425/diffdeck": "1.
|
|
30
|
+
"@say8425/diffdeck": "1.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/bun": "^1.3.14",
|