ctxline-claude 0.0.7 → 1.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 CHANGED
@@ -103,6 +103,7 @@ Remove-Item "$env:USERPROFILE\.claude\cache\usage-cache.json" -ErrorAction Silen
103
103
  | **Context** | Visual bar of context-window usage |
104
104
  | **Current** | Live 5-hour session limit + reset countdown (subscription users) |
105
105
  | **Weekly** | Weekly usage allowance + time until the weekly reset (subscription users) |
106
+ | **Cost** | Running session cost in USD (e.g. `$0.42`) |
106
107
  | **Task** | The in-progress todo, when there is one |
107
108
 
108
109
  > [!NOTE]
@@ -125,6 +126,13 @@ Yes — the same 5-hour and weekly limits. It reads them from the session data C
125
126
 
126
127
  </details>
127
128
 
129
+ <details>
130
+ <summary>Is the session cost my actual bill?</summary>
131
+
132
+ It's the cost Claude Code computes for the session (tokens × per-model API pricing), read straight from the session data. For subscription (Pro/Max) users it's the *equivalent* pay-as-you-go API cost — useful as a gauge of session weight, but not what you're billed (you pay the flat subscription). It's an estimate, accurate to the extent your Claude Code pricing tables are current.
133
+
134
+ </details>
135
+
128
136
  <details>
129
137
  <summary>Does it work with API keys?</summary>
130
138
 
@@ -135,7 +143,7 @@ Yes. The statusline automatically detects subscription vs API-key usage.
135
143
  <details>
136
144
  <summary>Can it break Claude Code?</summary>
137
145
 
138
- No. All failures are handled silently and the statusline always renders.
146
+ No. [Statuslines are a built-in Claude Code feature](https://code.claude.com/docs/en/statusline) — this provides the command Claude Code runs. All failures are handled silently and the statusline always renders.
139
147
 
140
148
  </details>
141
149
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctxline-claude",
3
- "version": "0.0.7",
3
+ "version": "1.0.0",
4
4
  "description": "A customizable statusline for Claude Code that tracks context usage and session limits",
5
5
  "bin": {
6
6
  "ctxline-claude": "bin/install.js"
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "author": "Mithun Wijayasiri",
30
30
  "license": "MIT",
31
- "homepage": "https://github.com/MithunWijayasiri/ctxline-claude#readme",
31
+ "homepage": "https://ctxline.js.org",
32
32
  "bugs": {
33
33
  "url": "https://github.com/MithunWijayasiri/ctxline-claude/issues"
34
34
  },
package/statusline.js CHANGED
@@ -359,6 +359,15 @@ function getUsageWithCache(callback) {
359
359
  });
360
360
  }
361
361
 
362
+ // Session cost from stdin `cost.total_cost_usd` (USD float, computed client-side by
363
+ // Claude Code as tokens × per-model API pricing). Pure stdin — no network/cache.
364
+ // Returns "$0.00" rendered dim, or '' when absent/non-finite so the segment is omitted.
365
+ function getCostSegment(data) {
366
+ const usd = data?.cost?.total_cost_usd;
367
+ if (!Number.isFinite(usd)) return '';
368
+ return `${colors.dim}$${usd.toFixed(2)}${colors.reset}`;
369
+ }
370
+
362
371
  function getCurrentTask(sessionId) {
363
372
  if (!sessionId) return '';
364
373
 
@@ -395,6 +404,7 @@ function outputStatus(data, usage) {
395
404
  const remaining = data?.context_window?.remaining_percentage;
396
405
 
397
406
  const contextBar = getContextBar(remaining);
407
+ const cost = getCostSegment(data);
398
408
  const task = getCurrentTask(sessionId);
399
409
  const parts = [];
400
410
  parts.push(branch ? `${dirname} ${colors.dim}⎇ ${branch}${colors.reset}` : dirname);
@@ -404,6 +414,7 @@ function outputStatus(data, usage) {
404
414
  if (usage?.current) parts.push(usage.current);
405
415
  if (usage?.weekly) parts.push(usage.weekly);
406
416
 
417
+ if (cost) parts.push(cost);
407
418
  if (task) parts.push(`${colors.dim}${task}${colors.reset}`);
408
419
  process.stdout.write(parts.join(' \u2502 '));
409
420
  } catch (e) {