Bare model id with any provider qualifier stripped: everything after the
FIRST colon. blockedModels entries are provider-qualified
(“anthropic:claude-opus-5”); we only serve via command-code lanes, so match
on the id portion. A model id that itself contains ‘:’ keeps it.
Compact thousands/millions. Rounds half-away-from-zero explicitly before
formatting: {:.1} alone is round-half-to-even, which disagrees with JS
Math.round at exact .x5 ties (1_250_000 → “1.2M” vs “1.3M”).
Assemble the monthly usage window from the plan cap and subscription
period: used = cap − remaining (clamped to [0, cap]), reset = period end,
duration = period length. Returns (window, duration secs). Single source
for cli + zed; the opencode TS port mirrors it via conformance vectors.
Seconds until spend hits cap at the current rate, if that lands before the
window resets. None = no warning. Suppressed before 10% of the window has
elapsed — the flat-rate projection is unreliable that early.
Percent string of used/cap: “34%” or “—” when cap unknown. Rounds
half-away-from-zero (.round()), matching JS Math.round in the opencode
port; format!("{:.0}") alone is half-to-even and drifts at exact .5.
True when plan_id matched a NAME_RULES entry rather than falling through
to DEFAULT_NAME. Callers warn on false: the API returned a plan we don’t
know, so its name/cap may be wrong until plans.json is updated.