slash-tokens 1.5.7 → 1.6.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,249 @@
1
+ # Changelog
2
+
3
+ ## [1.6.1] — The Fixed Deal Edition
4
+
5
+ *2026-08-24*
6
+
7
+ Team/Pro is the live cart; 10% of savings shows on the weekly number as the comparison, not as what Team is charged.
8
+
9
+ 1.6.0 put `counterfactual_fee_usd` on npm without Doc Gate (the tarball README still headlined v1.4). This patch is the public identity for that ship. Trial still meters 10% on the $5 credit. Team `fee_usd` is 0. slashtokens.com copy is unchanged.
10
+
11
+ **Not claimed:** a walked Team checkout (cart unbought). 10% is postponed until-further-notice, not dropped. CLI scanner “10% gate efficiency” is a different 10% (salvage rate).
12
+
13
+ **Verification:** `cd npm && bun test` (157 pass, 2 skip). Worker: `npx vitest run tests/wjttc/slash-usage-counterfactual.test.ts tests/wjttc/slash-statement-comparison.test.ts`.
14
+
15
+ ## 1.6.0 (2026-08-24)
16
+
17
+ ### Fixed Deal — 10% on the report, not the Team invoice
18
+
19
+ Team/Pro is the live cart ($39/mo or $390/yr). 10% of measured savings is postponed UFN; it still appears on the weekly number as the comparison (what the meter would have been vs the plan). Trial keys still pay 10%. `report()` may return `counterfactual_fee_usd` from the worker. Site copy unchanged.
20
+
21
+ ## 1.5.7 (2026-08-24)
22
+
23
+ Punch-list cleanup from the full-codebase review after calibration shipped.
24
+
25
+ ## 1.5.6 (2026-08-23)
26
+
27
+ `preflightRoute()` respects `init({ route, models })`.
28
+
29
+ ## 1.5.5 (2026-08-23)
30
+
31
+ CLI scanner/report calibrate and price per-provider, not one flat rate.
32
+
33
+ ## 1.5.4 (2026-08-23)
34
+
35
+ Claude Sonnet 5 pricing corrected to $2/$10. Doc drift.
36
+
37
+ ## 1.5.3 (2026-08-23)
38
+
39
+ WASM no longer silently truncates input above ~1.06 MB.
40
+
41
+ ## 1.5.2 (2026-08-23)
42
+
43
+ Gemini and Grok factors re-verified against the 29-sample corpus.
44
+
45
+ ## 1.5.1 (2026-08-23)
46
+
47
+ Corpus 9→29 samples. Claude factor 1.85→2.05 (Spanish under-report).
48
+
49
+ ## 1.5.0 (2026-08-23)
50
+
51
+ Per-model calibration wired into every real call site. Gemini and Grok calibrated. Retired API IDs fixed.
52
+
53
+ ## 1.4.1 (2026-04-20)
54
+
55
+ ### Polish release — no code changes
56
+
57
+ **FAF 100% 🏆 · synced with a lean CLAUDE.md.** Documentation and brand consistency pass ahead of wider distribution. No SDK surface changes; all code identical to 1.4.0.
58
+
59
+ `project.faf` now scores a full 🏆 Trophy (12/12 slots). CLAUDE.md is intentionally lean — a one-line `<!-- faf: ... -->` meta-stamp and a bi-sync status line, nothing more. Every piece of context has exactly one home: structured facts in `project.faf`, narrative in `README.md`, the sync pointer in `CLAUDE.md`. Token-frugal by design — which is on-brand for a token optimization SDK.
60
+
61
+ ### Changed
62
+ - **License/Brand language rewritten.** Merged the prior separate `Brand` and `License` sections into one. Leads with "Code: MIT. Fork it, ship it, change it, show it, share it, sell it." — six verbs, because *show* and *share* are community drivers. Brand protection follows in plain language ("don't represent your app as Slash") instead of the prior "violators will get a takedown request" phrasing. Consistent across the ecosystem (slash-nextjs, RadioFAF).
63
+ - **v1.4 and v1.3 callouts now stacked** at the top of both READMEs — newest first, with the 🆕 badge on v1.4. The Opus 4.7 story (v1.3) keeps its visibility, not erased by the newer release.
64
+ - **"Know the cost before the call leaves your machine."** subtitle added to `npm/README.md` so both READMEs read identically below the headline.
65
+ - **WASM badge now shows 4.8 KB** (the raw WASM engine size, matching every other surface) instead of the 5.1 KiB minzipped package total. Both numbers are true; the brand claim ("4.8 KB WASM") is the one users recognize.
66
+ - **Signature sign-off added:** 🏎️ *Don't go to the Corner Shop in a Ferrari.* — the line we've been using everywhere else now appears on both READMEs.
67
+ - **shields.io badge URLs refreshed** to the newer (`?style=flat`) format so GitHub's camo image proxy re-fetches under fresh URLs (fixes the intermittent "rate limited by upstream service" render on the bundle-size badge).
68
+
69
+ ### Why
70
+ The npm package page bakes the README into the tarball at publish time. After v1.4.0 shipped, several improvements landed on GitHub but couldn't reach the npm landing page without a new publish. With the launch X post about to fire, the page visitors land on first needs to reflect the current brand and language.
71
+
72
+ ---
73
+
74
+ ## 1.4.0 (2026-04-19)
75
+
76
+ ### The Single-Source-of-Truth Edition
77
+
78
+ Extracted `PROVIDER_MODELS` to a shared module and added `preflightRoute()` — the exact routing decision the Slash proxy makes (same-provider only). Fixes a class of downstream bug where consumers used `preflight().options[0]` as a routing decision (cross-provider analysis) instead of the actual routing. Also caught a latent bug: `claude-opus-4.7` was in `MODELS` but missing from the Anthropic provider group, making it an orphan to the routing algorithm.
79
+
80
+ ### New
81
+ - **`preflightRoute(content, model)`** — returns the single cheapest same-provider `Alternative | null`. Matches mcpaas-cf proxy's `findCheapestRoute` semantics exactly. This is what downstream consumers should use to show "what Slash would route to," not `preflight().options[0]`.
82
+ - **`PROVIDER_MODELS`** and **`providerOf(model)`** — exported from the new `providers.ts` shared module. Single source of truth for same-provider grouping.
83
+
84
+ ### Changed
85
+ - **`intercept.ts` refactored** — no longer maintains its own `PROVIDER_MODELS` copy; imports from `providers.ts`. Removes drift risk between `preflight.ts` and `intercept.ts`.
86
+ - **`claude-opus-4.7` added to Anthropic provider group** — was already in `MODELS` but orphaned from `PROVIDER_MODELS`, caught by the new test suite.
87
+
88
+ ### Clarified (not changed)
89
+ - **`preflight().options` is cross-provider analysis** — returns cheapest models globally, sorted by price. Use it to *show alternatives*. Do not use it as a routing decision.
90
+ - **`preflightRoute()` is the routing decision** — same-provider only. Use it to show *"what would Slash route to right now."*
91
+
92
+ ### Testing
93
+ - 127 pass, 0 fail, 432 assertions (up from 118 / 386 in v1.3.0)
94
+ - 7 new TIER 1 BRAKE tests asserting the same-provider invariant, null return semantics, and `providerOf` hygiene
95
+ - See `TEST-NOTES.md` for the full test matrix and WJTTC tier plan
96
+
97
+ ### Docs
98
+ - `TEST-NOTES.md` — new living doc collecting invariants and WJTTC tier plan
99
+
100
+ ### Non-breaking
101
+ - `preflight()` behavior unchanged
102
+ - All existing exports retained
103
+ - Only additions + one internal refactor
104
+
105
+ ---
106
+
107
+ ## 1.3.0 (2026-04-16)
108
+
109
+ ### The Opus 4.7 Edition
110
+
111
+ Same-day support for Claude Opus 4.7 — the new flagship — with measured token calibration and proxy-ready benchmarking. Plus a Gemini URL-extraction fix.
112
+
113
+ ### New
114
+ - **Opus 4.7 support** — pricing + calibration layer. Measured 1.16–1.51x token increase vs prior Opus generations
115
+ - **Benchmark harness** — now supports custom proxy + auth headers, so you can benchmark Slash against direct upstream
116
+ - **Gemini URL model extraction** fix — proxy path correctly identifies model from `/v1beta/models/:model:generateContent`
117
+ - **Cross-repo integration** — Gemini proxy path covered by integration tests
118
+
119
+ ### Model Registry
120
+ - `claude-opus-4.7` with confirmed API ID `claude-opus-4-7`
121
+ - All 4 providers routable through Slash proxy (Anthropic, OpenAI, xAI, Google)
122
+
123
+ ### Testing
124
+ - 118 pass, 0 fail, 386 assertions
125
+
126
+ ### Docs
127
+ - Honest production analysis — $75.98 saved, $7.60 collected (real numbers, not projections)
128
+
129
+ ---
130
+
131
+ ## 1.2.1 (2026-04-15)
132
+
133
+ ### Fixes
134
+ - Add `pass` action type to `ReportOptions` — SDK types now match server (`prevented | routed | pass`)
135
+
136
+ ### Testing
137
+ - Cross-repo integration suite: 17 tests verifying SDK ↔ mcpaas-cf contract
138
+ - Self-registering test keys, no secrets needed
139
+ - TIER 5 proxy-path tests (Anthropic gateway, OpenAI, txn counting)
140
+ - 118 tests total, 374 assertions
141
+
142
+ ---
143
+
144
+ ## 1.2.0 (2026-04-14)
145
+
146
+ ### The Next.js Edition
147
+
148
+ Session summary on exit — every time you stop your dev server, Slash prints how much you saved that session:
149
+ ```
150
+ [slash] Session: 47 calls | 23 routed | $0.89 salvaged — The more you build, the more you save
151
+ ```
152
+ Fires on `exit`, `SIGINT` (Ctrl+C), and `SIGTERM`. Zero calls = silent.
153
+
154
+ ### New
155
+ - `auto` mode: session summary on process exit
156
+ - Dashboard: 90-day transaction history (History panel, show all)
157
+ - Dashboard: live feed now scrollable, shows `$saved` instead of raw token counts
158
+
159
+ ### Testing
160
+ - 99 pass, 0 fail, 326 assertions
161
+
162
+ ---
163
+
164
+ ## 1.1.2 (2026-04-13)
165
+
166
+ ### Fixes
167
+ - Fix Haiku model ID — `claude-haiku-4-5-20251001` (was wrong, routing would fail)
168
+ - Action types aligned to Gate vocabulary — `prevented | routed` (was `skipped | reduced | routed`)
169
+
170
+ ### Testing
171
+ - 99 pass, 0 fail, 326 assertions
172
+
173
+ ## 1.1.1 (2026-04-08)
174
+
175
+ Token Optimization for Context Engineers.
176
+
177
+ ### Auto Mode — Routes to Cheapest Model
178
+ - `import 'slash-tokens/auto'` — one import, every call optimized
179
+ - Routes within same provider: Opus → Haiku, GPT-5.4 → Nano, Grok → Fast
180
+ - Rewrites request body before fetch — the API gets the cheaper model
181
+ - Verbose by default — new users see every call, every route, every save
182
+ - Nudges at $5/$10/$25/$50/$100 thresholds: `⚡ $5 salvaged — keep building`
183
+
184
+ ### Configuration
185
+ - `init({ route: true })` — route to cheapest model (default)
186
+ - `init({ route: false })` — track only, don't touch my models
187
+ - `init({ models: ['claude-haiku', 'claude-sonnet'] })` — model-level control
188
+ - `init({ quiet: true })` — nudges only, no per-call logging
189
+
190
+ ### CLI
191
+ - Evaluator doesn't charge — `bunx slash-tokens` is free
192
+ - "Token optimization analysis" (not "burn analysis")
193
+ - "TOKENS SALVAGED" (not "savings")
194
+ - "DAILY TOKEN VOLUME" (not "daily burn")
195
+ - Single "Next" link to setup page
196
+
197
+ ### API
198
+ - `salvaged` / `salvagePercent` (replaces `savings` / `savingsPercent`)
199
+ - npm description: "Token Optimization for Context Engineers"
200
+
201
+ ### Testing
202
+ - 99 pass, 0 fail, 326 assertions
203
+
204
+ ## 1.1.0 (2026-04-07)
205
+
206
+ Token Optimization for Context Engineering.
207
+
208
+ ### Features
209
+ - `preflight(content, model)` — tokens, cost, fits, cheaper alternatives
210
+ - `import 'slash-tokens/auto'` — one import, every LLM call pre-flighted
211
+ - 10 models with verified April 2026 pricing (Claude, Grok, Gemini, GPT)
212
+ - `report()` — metered savings reporting, 10% of what you save
213
+ - `init()` — key configuration with 3-layer resolution
214
+ - `MODELS` — full pricing table exported for direct access
215
+ - `listModels()` — enumerate all supported models
216
+
217
+ ### Models (April 2026)
218
+ - Anthropic: claude-opus ($5/M), claude-sonnet ($3/M), claude-haiku ($1/M)
219
+ - xAI: grok-4.20 ($2/M), grok-4-1-fast ($0.20/M)
220
+ - Google: gemini-3.1-pro ($2/M), gemini-2.5-flash ($0.30/M)
221
+ - OpenAI: gpt-5.4 ($2.50/M), gpt-5.4-mini ($0.75/M), gpt-5.4-nano ($0.20/M)
222
+
223
+ ### Auto mode
224
+ - Intercepts fetch() to Anthropic, OpenAI, xAI, Google endpoints
225
+ - Model name normalization (handles full API IDs + legacy names)
226
+ - Non-blocking, sub-millisecond
227
+
228
+ ### Testing
229
+ - 323 tests: 172 Zig, 101 TypeScript, 50 API
230
+
231
+ ## 1.0.0 (2026-04-07)
232
+
233
+ Initial v1 release. Superseded by 1.1.0 (pricing corrections).
234
+
235
+ ## 0.3.0 (2026-04-06)
236
+
237
+ Deprecated. Added preflight + auto mode with outdated pricing.
238
+
239
+ ## 0.2.0 (2026-04-06)
240
+
241
+ Deprecated. Added report() + init() SDK integration.
242
+
243
+ ## 0.1.0 (2026-04-04)
244
+
245
+ Deprecated. Token estimation + CLI scanner.
246
+
247
+ ## 0.0.1 (2026-04-02)
248
+
249
+ Initial placeholder.
package/README.md CHANGED
@@ -13,10 +13,20 @@ For anyone building with LLMs. 4.8 KB WASM. Sub-millisecond. Zero dependencies.
13
13
 
14
14
  Know the cost before the call leaves your machine.
15
15
 
16
- > 🆕 **v1.4 — The Single-Source-of-Truth Edition.** New `preflightRoute()` matches the Slash proxy exactly — same-provider only, zero routing drift. `PROVIDER_MODELS` is now the single source of truth across the SDK.
16
+ > 🆕 **v1.6.1 — The Fixed Deal Edition.** Team/Pro is the live cart; 10% of savings shows on the weekly number as the comparison, not as what Team is charged.
17
+ >
18
+ > **v1.5 — The Calibration Fix Edition.** Per-model calibration is wired into every call path. All four providers checked against the same 29-sample corpus.
19
+ >
20
+ > **v1.4 — The Single-Source-of-Truth Edition.** New `preflightRoute()` matches the Slash proxy exactly — same-provider only, zero routing drift. `PROVIDER_MODELS` is now the single source of truth across the SDK.
17
21
  >
18
22
  > **v1.3 — The Opus 4.7 Edition.** Same-day support for Claude Opus 4.7 with measured token calibration (1.16–1.51x). Plus Gemini proxy fix and benchmark harness for any upstream.
19
23
 
24
+ ## v1.6.1 — The Fixed Deal Edition
25
+
26
+ Team/Pro is the live cart; 10% of savings shows on the weekly number as the comparison, not as what Team is charged.
27
+
28
+ The library stays free. Trial still takes 10% of measured savings on the $5 meter. Team is $39/month or $390/year: the weekly number shows what 10% would have been next to the plan. Team is not charged that 10%.
29
+
20
30
  ```bash
21
31
  npm install slash-tokens
22
32
  ```
@@ -11,5 +11,7 @@ export interface ReportResult {
11
11
  fee_usd: number;
12
12
  balance_remaining_usd: number;
13
13
  timestamp: string;
14
+ /** 10% of this call's savings — comparison only. Charged fee is fee_usd (0 on Team). */
15
+ counterfactual_fee_usd?: number;
14
16
  }
15
17
  export declare function report(opts: ReportOptions): Promise<ReportResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slash-tokens",
3
- "version": "1.5.7",
3
+ "version": "1.6.1",
4
4
  "description": "Token Optimization for Context Engineers. 4.8 KB WASM. Sub-millisecond. Zero dependencies.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -20,7 +20,8 @@
20
20
  }
21
21
  },
22
22
  "files": [
23
- "dist"
23
+ "dist",
24
+ "CHANGELOG.md"
24
25
  ],
25
26
  "sideEffects": false,
26
27
  "scripts": {