great-cto 3.38.0 → 3.39.0

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "great-cto",
3
3
  "description": "You already have the agent. This is everything around it. great_cto runs Claude Code as a pipeline of 71 specialist agents \u2014 an independent model checks each stage before the next builds on it, spending caps refuse rather than warn, and three decisions stay yours: what gets built, how, and whether it ships.",
4
- "version": "3.38.0",
4
+ "version": "3.39.0",
5
5
  "author": {
6
6
  "name": "Alexander Velikiy",
7
7
  "url": "https://hashnode.com/@Greatcto"
@@ -161,6 +161,25 @@ export function resolvePrice(model, prices = effectivePrices()) {
161
161
  *
162
162
  * @returns {{usd:number, priced:boolean, assumed:boolean, source:string, model:string}}
163
163
  */
164
+ /**
165
+ * Cache-write dollars. Anthropic bills a 5-minute cache write at 1.25× the input
166
+ * price and a 1-hour write at 2×; `usage.cache_creation` splits the tokens by TTL
167
+ * (`ephemeral_5m_input_tokens` / `ephemeral_1h_input_tokens`). Pricing every write
168
+ * at 1.25× understated long sessions — Claude Code writes the 1-hour cache — which
169
+ * session-shape found on 2026-09-27. Without the split, the flat 1.25× stands.
170
+ */
171
+ export function cacheWriteUsd(usage, inputPrice) {
172
+ const split = usage?.cache_creation;
173
+ const total = usage?.cache_creation_input_tokens || 0;
174
+ if (split && (split.ephemeral_1h_input_tokens != null || split.ephemeral_5m_input_tokens != null)) {
175
+ const h1 = split.ephemeral_1h_input_tokens || 0;
176
+ const m5 = split.ephemeral_5m_input_tokens || 0;
177
+ const rest = Math.max(0, total - h1 - m5); // any write the split does not name
178
+ return (h1 * 2 + (m5 + rest) * 1.25) * inputPrice;
179
+ }
180
+ return total * 1.25 * inputPrice;
181
+ }
182
+
164
183
  export function priceUsage({ model, usage, prices }) {
165
184
  const { price, source } = resolvePrice(model, prices || effectivePrices());
166
185
  if (!usage || !price) {
@@ -168,10 +187,9 @@ export function priceUsage({ model, usage, prices }) {
168
187
  }
169
188
  const inTok = usage.input_tokens || 0;
170
189
  const outTok = usage.output_tokens || 0;
171
- const cacheWrite = usage.cache_creation_input_tokens || 0;
172
190
  const cacheRead = usage.cache_read_input_tokens || 0;
173
191
  const usd = (inTok * price.input + outTok * price.output
174
- + cacheWrite * price.input * 1.25 + cacheRead * price.input * 0.1) / 1_000_000;
192
+ + cacheWriteUsd(usage, price.input) + cacheRead * price.input * 0.1) / 1_000_000;
175
193
  return { usd, priced: true, assumed: source === 'family', source, model: model || '' };
176
194
  }
177
195
 
@@ -190,13 +208,13 @@ export function costForUsage({ model, usage, prices }) {
190
208
  const inTok = usage.input_tokens || 0;
191
209
  const outTok = usage.output_tokens || 0;
192
210
  // Prompt-caching tokens bill at Anthropic's standard multipliers off the base
193
- // input price: cache WRITE = 1.25× input, cache READ = 0.1× input. Ignoring
211
+ // input price: cache WRITE = 1.25× input (2× for the 1-hour TTL, see
212
+ // cacheWriteUsd), cache READ = 0.1× input. Ignoring
194
213
  // them under-counts real spend badly (a cached turn is often 50k+ cache tokens
195
214
  // vs a few hundred fresh input tokens).
196
- const cacheWrite = usage.cache_creation_input_tokens || 0;
197
215
  const cacheRead = usage.cache_read_input_tokens || 0;
198
216
  return (inTok * p.input + outTok * p.output
199
- + cacheWrite * p.input * 1.25 + cacheRead * p.input * 0.1) / 1_000_000;
217
+ + cacheWriteUsd(usage, p.input) + cacheRead * p.input * 0.1) / 1_000_000;
200
218
  }
201
219
 
202
220
  export function round4(n) { return Math.round(n * 10000) / 10000; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "great-cto",
3
- "version": "3.38.0",
3
+ "version": "3.39.0",
4
4
  "description": "One command install for the great_cto Claude Code plugin. Auto-detects your stack, picks the right archetype, bootstraps PROJECT.md.",
5
5
  "keywords": [
6
6
  "claude-code",