codeep 2.18.0 → 2.18.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.
@@ -111,8 +111,15 @@ export declare function getCostBreakdown(startIndex?: number): ProviderCostBreak
111
111
  export interface CacheStats {
112
112
  cacheCreationTokens: number;
113
113
  cacheReadTokens: number;
114
- /** Sum of estimatedSavings across all Anthropic-priced records. */
114
+ /** Sum of estimatedSavings across pay-per-use records only. */
115
115
  estimatedSavingsUsd: number;
116
+ /** True when some cached tokens came from a flat-fee plan, whose "savings"
117
+ * are not a dollar amount at all. Lets the report say so instead of quoting
118
+ * a figure that silently covers only part of the session. */
119
+ hasFlatFeeCacheUsage: boolean;
120
+ /** True when EVERY cached token came from a flat-fee plan — there is no
121
+ * metered spend to have saved against. */
122
+ isEntirelyFlatFeeCache: boolean;
116
123
  }
117
124
  export declare function getCacheStats(): CacheStats;
118
125
  /**
@@ -96,6 +96,12 @@ const MODEL_PRICING = {
96
96
  'claude-sonnet-5': { inputPer1M: 3.00, outputPer1M: 15.00 },
97
97
  'claude-haiku-4-5-20251001': { inputPer1M: 1.00, outputPer1M: 5.00 },
98
98
  // DeepSeek (cache-miss input pricing)
99
+ // DeepSeek moved to peak / off-peak billing on 2026-08-16, with off-peak at
100
+ // half these rates. This table holds one rate per model and has no notion of
101
+ // wall-clock time, so it keeps the PEAK figures: an over-estimate is the
102
+ // honest direction for a cost estimate, and rule 5 of the catalogue policy
103
+ // allows a clearly-labelled conservative approximation but never an invented
104
+ // number. Cache-miss input; cache hits are ~1/50th and not modelled here.
99
105
  'deepseek-v4-pro': { inputPer1M: 0.435, outputPer1M: 0.87 },
100
106
  'deepseek-v4-flash': { inputPer1M: 0.14, outputPer1M: 0.28 },
101
107
  // Google
@@ -274,9 +280,20 @@ export function getCacheStats() {
274
280
  let cacheCreate = 0;
275
281
  let cacheRead = 0;
276
282
  let savings = 0;
283
+ let flatFeeCached = 0;
284
+ let meteredCached = 0;
277
285
  for (const record of currentRecords()) {
286
+ const cached = (record.cacheCreationTokens ?? 0) + (record.cacheReadTokens ?? 0);
278
287
  cacheCreate += record.cacheCreationTokens ?? 0;
279
288
  cacheRead += record.cacheReadTokens ?? 0;
289
+ // A plan bills a flat fee, so caching saves latency but not money — pricing
290
+ // its cached tokens would invent a dollar figure the same way the per-model
291
+ // cost lines used to. Count the tokens (measured), skip the arithmetic.
292
+ if (isFlatFeeProvider(record.provider)) {
293
+ flatFeeCached += cached;
294
+ continue;
295
+ }
296
+ meteredCached += cached;
280
297
  // Savings = what cache-read tokens would have cost at full input rate,
281
298
  // minus what they actually cost at 0.1×. (Cache creation is a slight
282
299
  // *penalty* of 0.25× — netted in for honest reporting.)
@@ -287,7 +304,13 @@ export function getCacheStats() {
287
304
  savings += cReadSaved - cCreateCost;
288
305
  }
289
306
  }
290
- return { cacheCreationTokens: cacheCreate, cacheReadTokens: cacheRead, estimatedSavingsUsd: Math.max(0, savings) };
307
+ return {
308
+ cacheCreationTokens: cacheCreate,
309
+ cacheReadTokens: cacheRead,
310
+ estimatedSavingsUsd: Math.max(0, savings),
311
+ hasFlatFeeCacheUsage: flatFeeCached > 0,
312
+ isEntirelyFlatFeeCache: flatFeeCached > 0 && meteredCached === 0,
313
+ };
291
314
  }
292
315
  /**
293
316
  * Get session stats
@@ -395,12 +418,22 @@ export function formatCostReport() {
395
418
  const cache = getCacheStats();
396
419
  if (cache.cacheReadTokens > 0 || cache.cacheCreationTokens > 0) {
397
420
  lines.push('', '### Prompt caching');
398
- lines.push(`**Cache reads:** ${formatTokenCount(cache.cacheReadTokens)} tokens (billed at 0.1× input rate)`);
421
+ // The billing multipliers only describe a metered account. On a plan
422
+ // nothing is billed per token, so quoting a rate there would be as invented
423
+ // as the per-model prices this report already refuses to show.
424
+ const readNote = cache.isEntirelyFlatFeeCache ? '' : ' (billed at 0.1× input rate)';
425
+ const writeNote = cache.isEntirelyFlatFeeCache ? '' : ' (billed at 1.25× input rate)';
426
+ lines.push(`**Cache reads:** ${formatTokenCount(cache.cacheReadTokens)} tokens${readNote}`);
399
427
  if (cache.cacheCreationTokens > 0) {
400
- lines.push(`**Cache writes:** ${formatTokenCount(cache.cacheCreationTokens)} tokens (billed at 1.25× input rate)`);
428
+ lines.push(`**Cache writes:** ${formatTokenCount(cache.cacheCreationTokens)} tokens${writeNote}`);
429
+ }
430
+ if (cache.isEntirelyFlatFeeCache) {
431
+ lines.push('**Savings:** caching saves latency, not money — this session is on a plan');
401
432
  }
402
- if (cache.estimatedSavingsUsd > 0) {
403
- lines.push(`**Estimated savings vs no caching:** $${cache.estimatedSavingsUsd.toFixed(4)}`);
433
+ else if (cache.estimatedSavingsUsd > 0) {
434
+ // Name the partial coverage rather than letting one figure look total.
435
+ const scope = cache.hasFlatFeeCacheUsage ? ' (pay-per-use models only)' : '';
436
+ lines.push(`**Estimated savings vs no caching:** $${cache.estimatedSavingsUsd.toFixed(4)}${scope}`);
404
437
  }
405
438
  }
406
439
  lines.push('', ...formatResourceImpactReport(stats.totalTokens));
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "2.18.0";
1
+ export declare const VERSION = "2.18.1";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Baked from package.json at build time so the bun-compiled binary reports
3
3
  // the right version (it has no package.json on disk to read at runtime).
4
- export const VERSION = '2.18.0';
4
+ export const VERSION = '2.18.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "2.18.0",
3
+ "version": "2.18.1",
4
4
  "description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,6 +16,7 @@
16
16
  "test:watch": "vitest",
17
17
  "test:coverage": "vitest run --coverage",
18
18
  "version": "node scripts/gen-version.js && git add src/version.ts",
19
+ "export:catalogue": "node --import tsx scripts/export-catalogue.ts",
19
20
  "release": "node scripts/release.js"
20
21
  },
21
22
  "repository": {