claude-token-saver 2.0.1 → 2.0.3
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 +51 -13
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# claude-token-saver
|
|
2
2
|
|
|
3
|
-
> **Renamed from `claude-cache-monitor` in v2.0.** The old
|
|
3
|
+
> **Renamed from `claude-cache-monitor` in v2.0.** The old npm package is deprecated and points here. The `claude-cache-monitor` binary is gone — use `claude-token-saver` instead. See [migration notes](#migration-from-claude-cache-monitor).
|
|
4
4
|
|
|
5
5
|
> 📺 **HNPulse Shorts** — 이 도구가 만들어진 배경 (캐시 TTL 1h→5m 변경 이슈):
|
|
6
6
|
> **[▶ Watch the Short](https://www.youtube.com/shorts/oSx2sg935nI)** · [All HNPulse Shorts](https://www.youtube.com/@HNPulseKR/shorts)
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
**Save tokens on Claude Code.** Catch the session that suddenly burned 10× your usual input, figure out *why*, and get a one-line remediation you can paste.
|
|
11
11
|
|
|
12
|
-
v1.5 adds three things on top of the original cache
|
|
12
|
+
v1.5 adds three things on top of the original `claude-cache-monitor`:
|
|
13
13
|
- **Spike diagnosis** — detect recent sessions whose input tokens exploded vs. your own baseline, and name the cause (1M context, 5m TTL churn, cache rebuild, chatty output).
|
|
14
14
|
- **1M-context detection** — Opus 4.7+ auto-enables 1M context on Max plans, silently. This tool surfaces it on the statusline as `Ctx 1M` (red) vs. `Ctx 200k` (green), with the OS-specific command to turn it off.
|
|
15
15
|
- **Actionable advice** — OS-aware remediation (`~/.zshrc` vs. `setx`) and the warning for the known `/model` toggle bug ([anthropics/claude-code#31640](https://github.com/anthropics/claude-code/issues/31640)).
|
|
@@ -47,6 +47,12 @@ npx claude-token-saver --format json
|
|
|
47
47
|
npx claude-token-saver --format csv
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
> **Upgrading from `claude-cache-monitor`?** Uninstall the old package first, then install the new one and update your settings command name:
|
|
51
|
+
> ```bash
|
|
52
|
+
> npm uninstall -g claude-cache-monitor && npm i -g claude-token-saver
|
|
53
|
+
> ```
|
|
54
|
+
> After upgrading, change any `claude-cache-monitor …` invocations (including `statusLine.command` in `~/.claude/settings.json`) to `claude-token-saver …`. See [Migration](#migration-from-claude-cache-monitor).
|
|
55
|
+
|
|
50
56
|
## Spike Diagnosis (new in v1.5.0)
|
|
51
57
|
|
|
52
58
|
When you run `npx claude-token-saver`, sessions from the last 24 hours whose total input tokens are **≥ 3× your p95 baseline** (or whose single-request context exceeds 250k, indicating 1M context) appear at the top of the report with root causes and remediation commands. Example output:
|
|
@@ -158,7 +164,7 @@ The Claude Code statusline is event-driven — it only re-renders on assistant m
|
|
|
158
164
|
}
|
|
159
165
|
```
|
|
160
166
|
|
|
161
|
-
Or combine with an existing statusline script — see [`examples/statusline-command.sh`](examples/statusline-command.sh) for a drop-in that prints `user@host:cwd | <
|
|
167
|
+
Or combine with an existing statusline script — see [`examples/statusline-command.sh`](examples/statusline-command.sh) for a drop-in that prints `user@host:cwd | <token-saver segment>`.
|
|
162
168
|
|
|
163
169
|
#### Windows (native PowerShell, not WSL)
|
|
164
170
|
|
|
@@ -230,9 +236,13 @@ When the hook is installed:
|
|
|
230
236
|
## Output Example
|
|
231
237
|
|
|
232
238
|
```
|
|
233
|
-
Claude
|
|
239
|
+
Claude 토큰 아껴쓰기 — Last 30 days
|
|
240
|
+
(claude-token-saver v2.0.1)
|
|
234
241
|
══════════════════════════════════════════════════
|
|
235
242
|
|
|
243
|
+
Context window: 200k ✓ 200k 컨텍스트 (표준)
|
|
244
|
+
(최근 단일 요청 최대 83k 토큰)
|
|
245
|
+
|
|
236
246
|
Summary
|
|
237
247
|
Sessions: 380 | API calls: 10,813 | Model: claude-opus-new
|
|
238
248
|
Cache hit rate: 98.2% | Total input: 1957.94M tokens
|
|
@@ -338,24 +348,52 @@ Zero dependencies.
|
|
|
338
348
|
|
|
339
349
|
## Migration from claude-cache-monitor
|
|
340
350
|
|
|
341
|
-
v2.0 renamed the package to reflect the expanded scope (spike diagnosis + 1M-context detection + remediation, not just cache monitoring).
|
|
351
|
+
v2.0 renamed the package to reflect the expanded scope (spike diagnosis + 1M-context detection + remediation, not just cache monitoring).
|
|
352
|
+
|
|
353
|
+
### New users
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
npm i -g claude-token-saver
|
|
357
|
+
# or, no install:
|
|
358
|
+
npx claude-token-saver
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Skip the rest of this section.
|
|
342
362
|
|
|
343
|
-
|
|
344
|
-
- The binary `claude-cache-monitor` still works alongside the new `claude-token-saver` (both map to the same entry point).
|
|
345
|
-
- Your existing `statusLine.command` setting in `~/.claude/settings.json` keeps working.
|
|
363
|
+
### Upgrading from `claude-cache-monitor` v1.x
|
|
346
364
|
|
|
347
|
-
|
|
365
|
+
Two steps:
|
|
348
366
|
|
|
349
367
|
```bash
|
|
368
|
+
# 1. Remove the old package (its claude-cache-monitor bin is now obsolete).
|
|
350
369
|
npm uninstall -g claude-cache-monitor
|
|
370
|
+
|
|
371
|
+
# 2. Install the new one.
|
|
351
372
|
npm i -g claude-token-saver
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Then update any `claude-cache-monitor …` references. The main one is `statusLine.command` in `~/.claude/settings.json`:
|
|
376
|
+
|
|
377
|
+
```jsonc
|
|
378
|
+
// before
|
|
379
|
+
"command": "claude-cache-monitor --statusline --icon"
|
|
380
|
+
|
|
381
|
+
// after
|
|
382
|
+
"command": "claude-token-saver --statusline --icon"
|
|
383
|
+
```
|
|
352
384
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
385
|
+
### Why we dropped the `claude-cache-monitor` bin alias
|
|
386
|
+
|
|
387
|
+
Earlier v2.0 releases shipped a `claude-cache-monitor` bin alongside `claude-token-saver` so existing settings would keep working without edits. In practice this caused an `EEXIST: file already exists` error on `npm i -g claude-token-saver` when v1.x was still installed — and that collision forced the uninstall step anyway. Dropping the alias makes the upgrade path a clean two-liner and lets `npm i -g claude-token-saver` succeed directly if you've never installed the old one.
|
|
388
|
+
|
|
389
|
+
### Zero-install (npx)
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
npx claude-token-saver@latest --statusline --icon
|
|
357
393
|
```
|
|
358
394
|
|
|
395
|
+
No uninstall needed; npm just fetches the new name.
|
|
396
|
+
|
|
359
397
|
## License
|
|
360
398
|
|
|
361
399
|
MIT
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-token-saver",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
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": {
|
|
7
|
-
"claude-token-saver": "./bin/cli.js"
|
|
8
|
-
"claude-cache-monitor": "./bin/cli.js"
|
|
7
|
+
"claude-token-saver": "./bin/cli.js"
|
|
9
8
|
},
|
|
10
9
|
"files": [
|
|
11
10
|
"bin/",
|