@inbrace-tech/tokenline 1.2.2 → 1.2.4

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 (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +12 -10
  3. package/tokenline.sh +27 -11
package/README.md CHANGED
@@ -67,7 +67,7 @@ LLMs are stateless — by default, they must reread your entire codebase context
67
67
 
68
68
  **Prompt Caching** solves this by saving that processed state in the provider's memory:
69
69
  - **Cache Write (Cold):** The model reads everything and stores the state. This costs slightly more than base tokens.
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.
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 **95%** on Claude Opus 5.5 at 0.05x) and starts responding almost instantly. `tokenline` picks the right multiplier from the active model.
71
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**.
72
72
 
73
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.2",
3
+ "version": "1.2.4",
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"
@@ -37,21 +37,22 @@
37
37
  "access": "public"
38
38
  },
39
39
  "devDependencies": {
40
- "@changesets/cli": "^2.31.0",
40
+ "@changesets/changelog-github": "1.0.1",
41
+ "@changesets/cli": "^3.0.2",
41
42
  "@eslint/js": "10.0.1",
42
- "@types/node": "24.13.3",
43
- "@vitest/eslint-plugin": "1.6.23",
44
- "eslint": "10.7.0",
43
+ "@types/node": "24.13.4",
44
+ "@vitest/eslint-plugin": "1.6.27",
45
+ "eslint": "10.10.0",
45
46
  "eslint-config-prettier": "10.1.8",
46
- "eslint-plugin-n": "18.2.2",
47
+ "eslint-plugin-n": "18.3.0",
47
48
  "eslint-plugin-prettier": "5.5.6",
48
49
  "eslint-plugin-simple-import-sort": "13.0.0",
49
- "globals": "17.7.0",
50
- "prettier": "3.9.5",
50
+ "globals": "17.12.0",
51
+ "prettier": "3.9.6",
51
52
  "tsup": "^8.5.1",
52
53
  "typescript": "5.9.3",
53
- "typescript-eslint": "8.64.0",
54
- "vitest": "4.1.10"
54
+ "typescript-eslint": "8.70.0",
55
+ "vitest": "4.1.11"
55
56
  },
56
57
  "scripts": {
57
58
  "build": "tsup",
@@ -63,6 +64,7 @@
63
64
  "audit:lockfile": "node --experimental-strip-types scripts/check-lockfile-release-age.mts",
64
65
  "test:watch": "vitest",
65
66
  "changeset": "changeset",
67
+ "changeset:check": "node --experimental-strip-types scripts/check-changeset-size.mts",
66
68
  "release": "pnpm build && changeset publish"
67
69
  }
68
70
  }
package/tokenline.sh CHANGED
@@ -56,6 +56,19 @@ epoch_from_iso() {
56
56
  fi
57
57
  }
58
58
 
59
+ epoch_from_reset() {
60
+ # rate_limits.*.resets_at -> epoch seconds; empty on failure.
61
+ # Claude Code sends Unix epoch seconds, which `date` cannot parse as a date
62
+ # (GNU needs '@<n>', BSD needs '-r <n>'), so an integer is taken as-is and
63
+ # never reaches `date`. Anything else is tried as ISO-8601.
64
+ local value="$1"
65
+ if [[ "$value" =~ ^[0-9]+$ ]]; then
66
+ printf '%s' "$value"
67
+ elif [ -n "$value" ]; then
68
+ epoch_from_iso "$value"
69
+ fi
70
+ }
71
+
59
72
  file_mtime() {
60
73
  local f="$1"
61
74
  if [ "$_stat_gnu" -eq 1 ]; then
@@ -109,9 +122,9 @@ parse_and_prepare_paths() {
109
122
  transcript_path="${_f[3]}"
110
123
  session_id="${_f[4]}"
111
124
  rl_5h_pct="${_f[5]}"
112
- rl_5h_reset=$(epoch_from_iso "${_f[6]}")
125
+ rl_5h_reset=$(epoch_from_reset "${_f[6]}")
113
126
  rl_7d_pct="${_f[7]}"
114
- rl_7d_reset=$(epoch_from_iso "${_f[8]}")
127
+ rl_7d_reset=$(epoch_from_reset "${_f[8]}")
115
128
  cur_input="${_f[9]}"
116
129
  cur_output="${_f[10]}"
117
130
  cur_cwrite="${_f[11]}"
@@ -143,13 +156,17 @@ parse_and_prepare_paths() {
143
156
  is_gemini=true
144
157
  fi
145
158
 
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
159
+ # Cache hits bill at 0.1x base input, except Claude Fable 5.1 / Mythos 5.1 (0.025x)
160
+ # and Claude Opus 5.5 (0.05x). Match the API id (claude-fable-5-1[1m]) or the
161
+ # display name (Fable 5.1) so either field alone is enough. Pin the full version:
162
+ # claude-opus-5 must stay 0.1x, and a later version's price is confirmed, not guessed.
163
+ claude_read_mult="0.1"
164
+ local fable_re='(fable|mythos)[- ]5[-.]1([^0-9]|$)'
165
+ local opus_re='opus[- ]5[-.]5([^0-9]|$)'
166
+ if [[ "${model_id,,}" =~ $fable_re ]] || [[ "${model,,}" =~ $fable_re ]]; then
167
+ claude_read_mult="0.025"
168
+ elif [[ "${model_id,,}" =~ $opus_re ]] || [[ "${model,,}" =~ $opus_re ]]; then
169
+ claude_read_mult="0.05"
153
170
  fi
154
171
 
155
172
  # Get the current epoch timestamp once to be reused across all calculations
@@ -412,8 +429,7 @@ compute_turn_breakdown() {
412
429
  input_mult="1"
413
430
  output_mult="4"
414
431
  else
415
- read_mult="0.1"
416
- [ "$discounted_cache_read" = true ] && read_mult="0.025"
432
+ read_mult="$claude_read_mult"
417
433
  write_mult="1.25"
418
434
  [ "${ttl_label:-5m}" = "1h" ] && write_mult="2"
419
435
  input_mult="1"