claude-token-saver 2.8.0 → 2.8.2
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/bin/cli.js +22 -1
- package/package.json +1 -1
- package/src/formatters/statusline.js +8 -1
package/bin/cli.js
CHANGED
|
@@ -77,10 +77,31 @@ function extractCaps(stdinJson) {
|
|
|
77
77
|
* `model.display_name` is the contract; fall back to `model.id` when it's
|
|
78
78
|
* absent. Returns null when nothing usable is in the JSON.
|
|
79
79
|
*/
|
|
80
|
+
// Bedrock/litellm proxies pass model IDs like
|
|
81
|
+
// global.anthropic.claude-opus-4-7-20251001-v1:0
|
|
82
|
+
// anthropic.claude-sonnet-4-6-20250930-v1:0
|
|
83
|
+
// bedrock/anthropic.claude-haiku-4-5
|
|
84
|
+
// while Claude Code's `display_name` collapses these to a generic family
|
|
85
|
+
// label ("Opus 4", "Sonnet 4") that hides the actual minor version. Pull the
|
|
86
|
+
// version out of the id when we can spot it so the statusline shows the real
|
|
87
|
+
// model in use (Opus 4.7 vs 4.6 matters a lot for token budgeting).
|
|
88
|
+
function bedrockDisplayFromId(id) {
|
|
89
|
+
if (typeof id !== 'string') return null;
|
|
90
|
+
const m = id.match(/claude[-_](opus|sonnet|haiku)[-_](\d+)[-_](\d+)/i);
|
|
91
|
+
if (!m) return null;
|
|
92
|
+
const family = m[1].charAt(0).toUpperCase() + m[1].slice(1).toLowerCase();
|
|
93
|
+
return `${family} ${m[2]}.${m[3]}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
function extractModel(stdinJson) {
|
|
81
97
|
if (!stdinJson || !stdinJson.model) return null;
|
|
82
98
|
const m = stdinJson.model;
|
|
83
|
-
if (typeof m === 'string') return m;
|
|
99
|
+
if (typeof m === 'string') return bedrockDisplayFromId(m) || m;
|
|
100
|
+
// Prefer the id when it carries a precise version (e.g. Bedrock IDs); fall
|
|
101
|
+
// back to display_name for the standard Claude Code path where display_name
|
|
102
|
+
// already says "Claude Opus 4.7".
|
|
103
|
+
const idDerived = bedrockDisplayFromId(m.id);
|
|
104
|
+
if (idDerived) return idDerived;
|
|
84
105
|
if (typeof m.display_name === 'string' && m.display_name) return m.display_name;
|
|
85
106
|
if (typeof m.id === 'string' && m.id) return m.id;
|
|
86
107
|
return null;
|
package/package.json
CHANGED
|
@@ -394,5 +394,12 @@ export function formatReport(data, { color = true, verbose = false, timer = true
|
|
|
394
394
|
// timeframe footer.
|
|
395
395
|
if (want('saved')) segs.push(saveSeg);
|
|
396
396
|
if (want('period')) segs.push(periodSeg);
|
|
397
|
-
|
|
397
|
+
// Trailing erase-to-end-of-line so any leftover characters from a previous
|
|
398
|
+
// (longer) statusline render don't bleed into ours. Some terminals + the
|
|
399
|
+
// Claude Code statusline integration don't fully clear the line on rewrite,
|
|
400
|
+
// which surfaced as "Cache expires 4:574" or "Cache expires 43550" — old
|
|
401
|
+
// digits from a prior frame leaking past the new shorter timer text.
|
|
402
|
+
// \x1b[K is the standard "erase from cursor to EOL" CSI; safe on any
|
|
403
|
+
// ANSI-compatible terminal and a no-op when stdout isn't a TTY.
|
|
404
|
+
return segs.join(' · ') + '\x1b[K';
|
|
398
405
|
}
|