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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum CostUsageCacheIO {
let root = cacheRoot ?? self.defaultCacheRoot()
return root
.appendingPathComponent("cost-usage", isDirectory: true)
.appendingPathComponent("\(provider.rawValue)-v1.json", isDirectory: false)
.appendingPathComponent("\(provider.rawValue)-v2.json", isDirectory: false)
}

static func load(provider: UsageProvider, cacheRoot: URL? = nil) -> CostUsageCache {
Expand Down
20 changes: 16 additions & 4 deletions Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ enum CostUsagePricing {
inputCostPerToken: 1.25e-6,
outputCostPerToken: 1e-5,
cacheReadInputCostPerToken: 1.25e-7),
"gpt-5.1-codex": CodexPricing(
inputCostPerToken: 1.25e-6,
outputCostPerToken: 1e-5,
cacheReadInputCostPerToken: 1.25e-7),
"gpt-5.1-codex-mini": CodexPricing(
inputCostPerToken: 2.5e-7,
outputCostPerToken: 2e-6,
cacheReadInputCostPerToken: 2.5e-8),
"gpt-5.1-codex-max": CodexPricing(
inputCostPerToken: 1.25e-6,
outputCostPerToken: 1e-5,
cacheReadInputCostPerToken: 1.25e-7),
"gpt-5.2": CodexPricing(
inputCostPerToken: 1.75e-6,
outputCostPerToken: 1.4e-5,
Expand All @@ -41,6 +53,10 @@ enum CostUsagePricing {
inputCostPerToken: 1.75e-6,
outputCostPerToken: 1.4e-5,
cacheReadInputCostPerToken: 1.75e-7),
"gpt-5.3-codex": CodexPricing(
inputCostPerToken: 1.75e-6,
outputCostPerToken: 1.4e-5,
cacheReadInputCostPerToken: 1.75e-7),
Comment on lines 36 to 59
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Codex pricing keys were added (gpt-5.1-codex, gpt-5.1-codex-mini, gpt-5.1-codex-max, gpt-5.3-codex), but current tests only assert non-nil cost for gpt-5.1-codex-max. Add/extend tests to cover the new keys (especially gpt-5.1-codex-mini and gpt-5.3-codex) so a future typo in the dictionary key or normalization behavior doesn’t silently make lookups return nil.

Copilot uses AI. Check for mistakes.
]

private static let claude: [String: ClaudePricing] = [
Expand Down Expand Up @@ -161,10 +177,6 @@ enum CostUsagePricing {
if trimmed.hasPrefix("openai/") {
trimmed = String(trimmed.dropFirst("openai/".count))
}
if let codexRange = trimmed.range(of: "-codex") {
let base = String(trimmed[..<codexRange.lowerBound])
if self.codex[base] != nil { return base }
}
return trimmed
}

Expand Down
4 changes: 1 addition & 3 deletions Tests/CodexBarTests/CostUsagePricingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import Testing
struct CostUsagePricingTests {
@Test
func normalizesCodexModelVariants() {
#expect(CostUsagePricing.normalizeCodexModel("openai/gpt-5-codex") == "gpt-5")
#expect(CostUsagePricing.normalizeCodexModel("gpt-5.2-codex") == "gpt-5.2")
#expect(CostUsagePricing.normalizeCodexModel("gpt-5.1-codex-max") == "gpt-5.1")
#expect(CostUsagePricing.normalizeCodexModel("openai/gpt-5-codex") == "gpt-5-codex")
}
Comment on lines 6 to 9
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normalizesCodexModelVariants test no longer exercises the key behavior change (that -codex, -codex-max, and -codex-mini are not stripped). Consider adding expectations for inputs like gpt-5.1-codex-max/gpt-5.1-codex-mini (and optionally gpt-5.2-codex) to ensure normalization stays an exact lookup and doesn’t regress back to suffix stripping; alternatively rename the test if it’s only intended to cover the openai/ prefix.

Copilot uses AI. Check for mistakes.

@Test
Expand Down