@inbrace-tech/tokenline 1.2.1 → 1.2.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/README.md +6 -7
- package/package.json +3 -2
- package/tokenline.sh +13 -1
package/README.md
CHANGED
|
@@ -12,18 +12,17 @@
|
|
|
12
12
|
|
|
13
13
|
Run the installer for your AI coding CLI:
|
|
14
14
|
|
|
15
|
-
**Claude Code**
|
|
15
|
+
**Claude Code Per-project installation (`./.claude/settings.json`)**
|
|
16
16
|
```bash
|
|
17
|
-
# Per-project installation (./.claude/settings.json)
|
|
18
17
|
npx @inbrace-tech/tokenline init
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
```
|
|
19
|
+
**Claude Code Global installation (`~/.claude/settings.json`)**
|
|
20
|
+
```bash
|
|
21
21
|
npx @inbrace-tech/tokenline init --global
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
**Antigravity CLI**
|
|
24
|
+
**Antigravity CLI Global installation (`~/.gemini/antigravity-cli/settings.json`)**
|
|
25
25
|
```bash
|
|
26
|
-
# Global installation (~/.gemini/antigravity-cli/settings.json)
|
|
27
26
|
npx @inbrace-tech/tokenline init --antigravity
|
|
28
27
|
```
|
|
29
28
|
|
|
@@ -68,7 +67,7 @@ LLMs are stateless — by default, they must reread your entire codebase context
|
|
|
68
67
|
|
|
69
68
|
**Prompt Caching** solves this by saving that processed state in the provider's memory:
|
|
70
69
|
- **Cache Write (Cold):** The model reads everything and stores the state. This costs slightly more than base tokens.
|
|
71
|
-
- **Cache Hit (Warm):** If your prompt prefix matches the cached state exactly, the model skips the reading phase. This is **~90% cheaper** and starts responding almost instantly.
|
|
70
|
+
- **Cache Hit (Warm):** If your prompt prefix matches the cached state exactly, the model skips the reading phase. This is **~90% cheaper** (**97.5%** on Claude Fable 5.1 / Mythos 5.1, which bill cache hits at 0.025x base input) and starts responding almost instantly. `tokenline` picks the right multiplier from the active model.
|
|
72
71
|
- **TTL (Time-To-Live):** The cache operates as a **sliding window**. Every cache hit resets the countdown to its full duration for free. The secret to minimizing rate-limit drain is adjusting your workflow pace to keep the cache continuously **HOT**.
|
|
73
72
|
|
|
74
73
|
### 💡 Pro-tip: Forcing a 5m TTL to save rate limits
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inbrace-tech/tokenline",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "A cache-aware statusline for AI coding CLIs — installs tokenline.sh and wires it into your Claude Code settings.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tokenline": "dist/cli.js"
|
|
@@ -55,11 +55,12 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|
|
58
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
58
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p scripts/tsconfig.json",
|
|
59
59
|
"lint": "eslint . --cache --cache-location node_modules/.cache/.eslintcache --fix",
|
|
60
60
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
61
61
|
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
62
62
|
"test": "vitest run",
|
|
63
|
+
"audit:lockfile": "node --experimental-strip-types scripts/check-lockfile-release-age.mts",
|
|
63
64
|
"test:watch": "vitest",
|
|
64
65
|
"changeset": "changeset",
|
|
65
66
|
"release": "pnpm build && changeset publish"
|
package/tokenline.sh
CHANGED
|
@@ -95,7 +95,8 @@ parse_and_prepare_paths() {
|
|
|
95
95
|
(.context_window.current_usage.input_tokens // 0),
|
|
96
96
|
(.context_window.current_usage.output_tokens // 0),
|
|
97
97
|
(.context_window.current_usage.cache_creation_input_tokens // 0),
|
|
98
|
-
(.context_window.current_usage.cache_read_input_tokens // 0)
|
|
98
|
+
(.context_window.current_usage.cache_read_input_tokens // 0),
|
|
99
|
+
(.model.id // "")' 2>/dev/null)
|
|
99
100
|
|
|
100
101
|
# Malformed or empty stdin: jq emits nothing, so the array is empty. Degrade to
|
|
101
102
|
# a silent no-op render rather than leaking parse errors or rendering garbage —
|
|
@@ -115,6 +116,7 @@ parse_and_prepare_paths() {
|
|
|
115
116
|
cur_output="${_f[10]}"
|
|
116
117
|
cur_cwrite="${_f[11]}"
|
|
117
118
|
cur_cread="${_f[12]}"
|
|
119
|
+
model_id="${_f[13]}"
|
|
118
120
|
|
|
119
121
|
# Computed: total input-only tokens used in the current context window
|
|
120
122
|
tokens_used=$((cur_input + cur_cwrite + cur_cread))
|
|
@@ -141,6 +143,15 @@ parse_and_prepare_paths() {
|
|
|
141
143
|
is_gemini=true
|
|
142
144
|
fi
|
|
143
145
|
|
|
146
|
+
# Claude Fable 5.1 and Mythos 5.1 bill cache hits at 0.025x base input instead of
|
|
147
|
+
# the standard 0.1x. Match the API id (claude-fable-5-1[1m]) or the display name
|
|
148
|
+
# (Fable 5.1) so either field alone is enough.
|
|
149
|
+
discounted_cache_read=false
|
|
150
|
+
local discounted_re='(fable|mythos)[- ]5[-.]1([^0-9]|$)'
|
|
151
|
+
if [[ "${model_id,,}" =~ $discounted_re ]] || [[ "${model,,}" =~ $discounted_re ]]; then
|
|
152
|
+
discounted_cache_read=true
|
|
153
|
+
fi
|
|
154
|
+
|
|
144
155
|
# Get the current epoch timestamp once to be reused across all calculations
|
|
145
156
|
now=$(date +%s)
|
|
146
157
|
}
|
|
@@ -402,6 +413,7 @@ compute_turn_breakdown() {
|
|
|
402
413
|
output_mult="4"
|
|
403
414
|
else
|
|
404
415
|
read_mult="0.1"
|
|
416
|
+
[ "$discounted_cache_read" = true ] && read_mult="0.025"
|
|
405
417
|
write_mult="1.25"
|
|
406
418
|
[ "${ttl_label:-5m}" = "1h" ] && write_mult="2"
|
|
407
419
|
input_mult="1"
|