claude-token-saver 2.8.0 → 2.8.1

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 (2) hide show
  1. package/bin/cli.js +22 -1
  2. package/package.json +1 -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-token-saver",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "Save tokens on Claude Code — spike diagnosis, 1M-context detection, TTL countdown, statusline. (formerly claude-cache-monitor)",
5
5
  "type": "module",
6
6
  "bin": {