Skip to content

Source model list from /provider/v1/models API instead of scraping CLI bundle - #4

Closed
KRoperUK wants to merge 1 commit into
brent-weatherall:mainfrom
KRoperUK:feat/sync-models-from-api
Closed

Source model list from /provider/v1/models API instead of scraping CLI bundle#4
KRoperUK wants to merge 1 commit into
brent-weatherall:mainfrom
KRoperUK:feat/sync-models-from-api

Conversation

@KRoperUK

Copy link
Copy Markdown

Problem

The model list in models.json is generated by scripts/sync-models.ts, which downloads the command-code npm tarball and parses the minified JS bundle using fragile string anchors (e.g. 'SONNET_4_6:{id:"claude-sonnet-4-6"'). This drifts out of date as the bundle changes: models.json currently has 21 models, while Command Code now serves 30.

Missing models include xiaomi/mimo-v2.5-pro, xiaomi/mimo-v2.5, claude-opus-4-8, claude-fable-5, moonshotai/Kimi-K2.7-Code, MiniMaxAI/MiniMax-M3, Qwen/Qwen3.7-Plus, stepfun/Step-3.7-Flash, and nvidia/nemotron-3-ultra-550b-a55b.

Change

Use the public, OpenAI-compatible endpoint GET https://api.commandcode.ai/provider/v1/models as the source of truth for which models exist, their display names, and context windows.

  • The CLI bundle is still downloaded, but only to enrich entries with pricing (the endpoint does not expose cost).
  • Fields the endpoint lacks (reasoning, tool_call) come from a small MODEL_META overrides map with sensible defaults (reasoning: true, tool_call: true).
  • Tier is derived from the id namespace (namespaced → open-source, bare → premium), replacing the provider-based TIER_MAP which can't work since the endpoint reports owned_by: "command-code" for everything.
  • Models without bundle pricing are kept with zeroed cost and a warning, rather than being silently dropped — so newly released models appear immediately. (7 models currently fall into this bucket; FALLBACK_COSTS can be populated as pricing becomes known.)

Removed

Brittle catalog scraping: extractModelCatalog, extractSpecConstants, HARDCODED_EXTRAS, and the provider-based TIER_MAP.

Artifacts

  • Regenerated models.json (21 → 30 models) and the README table.
  • Added tests/unit/models-json.test.ts to guard the models.json shape (id/name/tier/cost/limit, unique ids).

Verification

  • bun run sync lists 30 models including xiaomi/mimo-v2.5-pro (1M context); no anchor/parse exceptions.
  • bun run generate-readme updates the table.
  • bun test tests/unit/76 pass, 0 fail.

Notes / open questions

  • This still relies on the bundle for pricing. A natural follow-up would be moving all cost data to a maintained FALLBACK_COSTS/overrides file and dropping bundle parsing entirely. Happy to do that here or separately — flagging since it changes the maintenance model.

🤖 Generated with Claude Code

…I bundle

The model list was extracted by parsing the minified command-code CLI bundle
with fragile string anchors (e.g. 'SONNET_4_6:{id:"claude-sonnet-4-6"'), which
drifted out of date: models.json had 21 models while Command Code now serves 30
(missing mimo, claude-opus-4-8, claude-fable-5, nemotron, and others).

Use the public OpenAI-compatible endpoint https://api.commandcode.ai/provider/v1/models
as the source of truth for which models exist, their names, and context windows.
The CLI bundle is still downloaded, but now only to enrich entries with pricing
(the endpoint does not expose cost). Fields the endpoint lacks (reasoning,
tool_call) come from a small MODEL_META overrides map with sensible defaults.

Models without bundle pricing are kept with zeroed cost and a warning rather than
being silently dropped, so newly released models appear immediately.

- Remove brittle catalog scraping (extractModelCatalog, extractSpecConstants,
  HARDCODED_EXTRAS, provider-based TIER_MAP); derive tier from id namespace.
- Regenerate models.json (21 -> 30) and README table.
- Add tests/unit/models-json.test.ts to guard the models.json shape.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@KRoperUK

Copy link
Copy Markdown
Author

Reopened as #6 — rebased to stack cleanly on #5/#1. (GitHub wouldn't reopen this one after the branch history was rewritten.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant