Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/hooks/caveman-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const COMPRESSION = { 'full': 0.65 };
// https://www.anthropic.com/pricing if a release changes the tier.
// Most-specific prefixes MUST come first — priceForModel returns the first match.
const MODEL_OUTPUT_PRICE_PER_M = [
// Claude 5 generation.
['claude-fable-5', 50.00], // Fable 5 = $50/M output
['claude-mythos-5', 50.00], // Mythos 5 = same rate card as Fable 5
['claude-opus-5', 25.00], // Opus 5 = $25/M output (Opus tier unchanged since 4.5)
['claude-sonnet-5', 15.00], // Sonnet 5 = $15/M list ($10/M intro through 2026-08-31)
// Legacy Opus 4.0 / 4.1 (pre-4.5) billed at the old $75/M output tier,
// including the dated ids (e.g. claude-opus-4-20250514).
['claude-opus-4-0', 75.00],
Expand Down
12 changes: 12 additions & 0 deletions tests/test_caveman_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ test('priceForModel matches by prefix across point releases', () => {
assert.strictEqual(priceForModel('gpt-4'), null);
});

test('priceForModel covers the Claude 5 generation', () => {
const { priceForModel } = require(path.join(ROOT, 'src', 'hooks', 'caveman-stats.js'));
assert.strictEqual(priceForModel('claude-opus-5'), 25.00);
assert.strictEqual(priceForModel('claude-sonnet-5'), 15.00);
assert.strictEqual(priceForModel('claude-fable-5'), 50.00);
assert.strictEqual(priceForModel('claude-mythos-5'), 50.00);
// Claude Code reports the 1M-context variant with a bracket suffix.
assert.strictEqual(priceForModel('claude-opus-5[1m]'), 25.00);
// Claude 5 entries must not shadow the Claude 4 prefixes.
assert.strictEqual(priceForModel('claude-opus-4-8'), 25.00);
});

test('formatStats handles empty session gracefully', () => {
const { formatStats } = require(path.join(ROOT, 'src', 'hooks', 'caveman-stats.js'));
const out = formatStats({ outputTokens: 0, cacheReadTokens: 0, turns: 0, mode: 'full', model: null });
Expand Down