Skip to content

Commit 07607d5

Browse files
oakimovnkoynov
authored andcommitted
Price selectable models from the markdown table (oakimov#199)
* fix(pricing): price selectable Fast modes at the published thresholds OpenCode 2 selects a context tier by its token size, so a 272k, 256k, or 100k surcharge is no longer stored as a 200k rate. Fast modes with a published multiplier become their own catalog price, and Fast modes the docs name without a number stay unpriced. * test(pricing): cover Fast note rules in buildPricing Offline markdown now checks the 2x Fast multipliers, explicit Fast-row precedence, unpriced Fast notes, and the missing Opus 4.7 reference. * test(pricing): cover long-context notes in buildPricing Offline markdown checks 2x input at an explicit threshold and the default context, Haiku's published 5x rates, and a missing threshold. Invalid cost tiers are rejected. * fix(pricing): read per-model docs tables for every selectable rate The generator treats each model's rendered HTML pricing table as the rate and uses the main table only when that page has no matching row. Auto uses the Cursor staff forum rate. GPT-5.4 Fast and its long-context tier are derived from that page's own prose. * fix(pricing): parse model-page HTML in one pass CodeQL flagged chained entity replaces, comment stripping, and a script regex that misses a spaced end tag. Entity decoding is one replace, and comments and script blocks are removed by scanning for their markers. * fix(pricing): keep local pricing generation offline --from-file with --context-from-file no longer downloads model pages. --pages-from-dir reads saved <model-id>.html copies instead. * fix(pricing): fail offline generation when a saved page is missing A run with both markdown files and --pages-from-dir reads those files only. A model in the pricing markdown whose HTML file is absent fails the run instead of being fetched. * fix(pricing): price markdown rows first and pages only for gaps A pricing-markdown row is the rate. A model page is read only when a selectable variant has no row, and it does not replace that row. Notes are not prices. Auto stays the hand-edited staff rate. Generation fails before writing when a selectable model has no price. * test(pricing): keep only gap pages in the offline fixture The file run loads a model page only when a selectable variant has no markdown row. Drop the 25 pages that run never reads. * fix(pricing): refuse to write when a gap page lacks its row A page fetched for a selectable Fast or long-context gap must contain a pricing table and that row. Otherwise generation throws before writing and does not keep the base rate for the missing variant. * fix(pricing): read stated same-rate and Fast multiplier rules from model pages * fix(pricing): use the published row when the page states no separate rate * fix(pricing): price unpublished Fast variants at the provider list price Cursor bills third-party models at API list price. A Fast variant with no Cursor price now comes from the Anthropic or OpenAI page. The standard row is not copied onto Fast. * test(pricing): assert provider URLs as text, not as a regex CodeQL rejected a RegExp built from the Anthropic and OpenAI pricing URLs. * fix(pricing): verify selectable rates before generation Validate standard and Fast context tiers independently. Use the published Gemini 3.1 Pro long-context rate and leave route-dependent Auto unpriced. Validate Cursor pages before provider fallback and make saved-input generation reproduce the same bytes.
1 parent 556c39f commit 07607d5

55 files changed

Lines changed: 6226 additions & 162 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Saved OpenCode variant picks that use the old full-name keys (for example `grok-4.7#Grok 4.7 High 500k`) no longer match a variant until it is picked again under its new key. OpenCode 1.x sends the model's default variant meanwhile; OpenCode 2.x rejects the prompt with a variant-unavailable error. A variant whose delta is empty is keyed `Standard`, because OpenCode reserves `default` for "no variant".
88

9+
- Fast choices that now have a dedicated price move to the corresponding `-fast` model. Reselect any saved Fast choice under the new entry.
10+
911
### Added
1012

1113
- Gemini 4 Carbon, Hydrogen, and Neon token prices and context windows from Cursor's model docs (`gemini-4-carbon`, `gemini-4-hydrogen`, `gemini-4-neon`).

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ so both hosts can select its parameters.
200200

201201
#### Fast variants with distinct prices
202202

203-
When Cursor publishes a different Fast rate for a model (currently Composer and Grok), the plugin emits a separate OpenCode entry `<model-id>-fast` (for example `composer-2.5-fast`) using the same pattern as `-1m`:
203+
When a model has a published Fast rate, the plugin exposes a separate OpenCode entry `<model-id>-fast`, such as `composer-2.5-fast`, `gpt-5.5-fast`, or `claude-fable-5-2-fast`:
204204

205205
- only the Fast variants in its picker, with `" Fast"` in the catalog name
206206
- the real Cursor model id in `options.cursorModelId`, plus default Fast variant parameters
207207
- its own `cost` row (`composer-2.5-fast` is not nested under `composer-2.5`)
208208

209-
Claude Fast variants stay on the base entry: Cursor does not publish a separate Fast price for them, so they remain picker variants instead of a second catalog id. Combinations with long context use `<id>-1m-fast`.
209+
Combinations with long context use `<id>-1m-fast` where Cursor offers them. If you saved a Fast variant under a base model that now has a separate Fast entry, select the new model and pick its effort again.
210210

211211
#### Context limit sources
212212

‎docs/cache-log-runbook.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ prefix was recorded:
346346
| `stepOutput` | Output accepted by this finish: a characters / 4 estimate on tool steps, or outstanding measured output at turn-end, bounded to occupancy with a one-token display minimum. Reasoning is estimated separately and reconciled within its owning Run. |
347347
| `sessionRealOutput` / `sessionReportedOutput` | Cursor's measured output and output accepted by host finishes. Estimates or the display minimum can make reported output higher; that surplus never reduces a later Run's output. |
348348
| `delivered` | Whether the stream consumer accepted the finish; ledger totals contain accepted finishes only. |
349-
| `pricing=unpriced` | No published rate (`default`/Auto): nothing is billed. |
349+
| `pricing=unpriced` | The provider has no uniform rate for that catalog id and reports zero cost. This includes Auto (`default`), whose price can depend on the route and plan. |
350350

351351
The outstanding balance is `sessionRealUsd + sessionEstimatedUsd -
352352
sessionBilledUsd`, including rounding and the minimum/maximum charge the

‎scripts/check-cursor-pricing-coverage.ts‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env bun
22
/**
3-
* Check that known Cursor model ids resolve to pricing (or are intentionally unpriced).
4-
* Synthetic Fast catalog ids (`<id>-fast`) are first-class keys; Auto (`default`)
5-
* is the only remaining unpriced first-party id.
3+
* Check that every selectable model and variant has a price or is Auto.
64
*
75
* bun run check:pricing
86
* bun run check:pricing -- --models-file test/fixtures/cursor-pricing-models.txt
97
*/
108

119
import { readFileSync } from "node:fs"
1210
import { fileURLToPath } from "node:url"
11+
import { modelsToConfig } from "../src/model-config.js"
12+
import type { ModelInfo } from "../src/models.js"
1313
import {
1414
CURSOR_UNPRICED_MODEL_IDS,
1515
checkCursorPricingCoverage,
@@ -46,19 +46,26 @@ function loadModelIds(options: Options): string[] {
4646
.filter((line) => line && !line.startsWith("#"))
4747
}
4848

49+
function selectableEntryIds(): string[] {
50+
const catalogPath = fileURLToPath(new URL("../test/fixtures/selectable-catalog.json", import.meta.url))
51+
const catalog = JSON.parse(readFileSync(catalogPath, "utf8")) as ModelInfo[]
52+
return Object.keys(modelsToConfig(catalog))
53+
}
54+
4955
function main(): void {
5056
const options = parseArgs(process.argv.slice(2))
51-
const modelIds = loadModelIds(options)
57+
const modelIds = [...new Set([...loadModelIds(options), ...selectableEntryIds()])].sort()
5258
const coverage = checkCursorPricingCoverage(modelIds)
53-
const failed = coverage.missing.length > 0
59+
const unpriced = [...CURSOR_UNPRICED_MODEL_IDS]
60+
const failed = coverage.missing.length > 0 || unpriced.some((id) => id !== "default")
5461

5562
if (options.json) {
5663
console.log(
5764
JSON.stringify(
5865
{
5966
source: CURSOR_PRICING_SOURCE,
6067
modelCount: modelIds.length,
61-
intentionallyUnpriced: CURSOR_UNPRICED_MODEL_IDS,
68+
intentionallyUnpriced: unpriced,
6269
coverage,
6370
},
6471
null,
@@ -70,7 +77,7 @@ function main(): void {
7077
console.log(`Models checked: ${modelIds.length}`)
7178
console.log(`Covered: ${coverage.priced.length}`)
7279
console.log(`Missing: ${coverage.missing.length}`)
73-
console.log(`Intentionally unpriced: ${CURSOR_UNPRICED_MODEL_IDS.join(", ")}`)
80+
console.log(`Unpriced exceptions: ${unpriced.length === 0 ? "none" : unpriced.join(", ")}`)
7481
if (coverage.missing.length > 0) {
7582
console.log("Missing pricing:")
7683
for (const id of coverage.missing) console.log(` ${id}`)

0 commit comments

Comments
 (0)