Skip to content

feat(pricing): move model pricing to a DB-backed, periodically-updated table #22

Description

@ClaudiaFang

Context

`cli/src/utils/pricing.ts` currently hardcodes a static `MODEL_PRICING` map (Claude, Gemini, OpenAI/Codex) compiled into the CLI. Any time a provider changes pricing or ships a new model, the fix requires a code change + release (see the recent Codex GPT-5.6 pricing fix — cost was hardcoded to 0 until manually patched).

Proposal

Move model pricing out of source code and into the local SQLite database (~/.code-insights/data.db), with a mechanism to refresh it periodically instead of requiring a CLI update:

  • New table (e.g. model_pricing) keyed by (model_id, effective_from) so historical sessions are costed with the price that was actually in effect at the time, not today's price.
  • A sync/update path (e.g. code-insights sync or a dedicated code-insights pricing update command) that refreshes the table from a maintained source, with the current hardcoded map kept as the offline/bundled fallback seed.
  • getModelPricing() / calculateCost() in pricing.ts read from the DB table first, falling back to the bundled defaults if the DB has no entry or the model is unrecognized.

Why

  • New models currently silently cost $0 or fall back to a generic default until someone notices and patches pricing.ts in a release.
  • Historical cost figures are wrong once a model's price changes, since the static table only ever holds "current" pricing — no way to reprice old sessions accurately or preserve what a session cost at the time.

Scope note

Needs a design decision on where the periodic price data comes from (bundled JSON updated per release vs. remote fetch vs. manual entry) before implementation — flagging for scoping, not diving into full build yet.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions