Skip to content

refactor(cli): canonicalize provider identifiers - #1110

Open
WebMad wants to merge 5 commits into
Zoo-Code-Org:mainfrom
WebMad:refactor/944-cli-provider-identifiers
Open

refactor(cli): canonicalize provider identifiers#1110
WebMad wants to merge 5 commits into
Zoo-Code-Org:mainfrom
WebMad:refactor/944-cli-provider-identifiers

Conversation

@WebMad

@WebMad WebMad commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • build the CLI-supported provider subset from canonical providerIdentifiers
  • migrate the provider environment-variable map and getProviderSettings() dispatch cases
  • migrate provider-specific model-field selection in the CLI context-window utility
  • replace raw OpenRouter defaults and router-model request values in run.ts and list.ts
  • add focused regression coverage for the canonical subset, settings dispatch, environment mappings, and provider-specific model fields

Implements item 2 from #944 (comment).

Dependency

Stacked on #1109, which introduces the shared canonical provider-settings migration used as this branch's base. Until #1109 is merged, GitHub may show that parent commit in this PR's diff.

Test plan

  • pnpm test from apps/cli (549 passed, 1 skipped)
  • pnpm check-types from apps/cli
  • pnpm lint from apps/cli
  • repository commit/push hooks, including workspace lint and type checking
  • git diff --check

Summary by CodeRabbit

  • New Features

    • CLI options now consistently resolve model, provider, reasoning effort, workspace, and permission settings, including precedence between command-line flags and saved settings.
    • Model listings provide more reliable OpenRouter results and handle unavailable or malformed responses gracefully.
    • Provider configuration and model identification are consistently supported across Anthropic, OpenAI, Gemini, OpenRouter, and Vercel AI Gateway integrations.
  • Bug Fixes

    • Improved provider and model matching to prevent inconsistent configuration behavior.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6aa27c88-d5bd-47df-b5db-fd1a13562ec2

📥 Commits

Reviewing files that changed from the base of the PR and between 3e89aba and 6476237.

📒 Files selected for processing (2)
  • apps/cli/src/lib/utils/__tests__/context-window.test.ts
  • apps/cli/src/lib/utils/context-window.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/cli/src/lib/utils/tests/context-window.test.ts

📝 Walkthrough

Walkthrough

The PR centralizes provider identifier usage across shared provider settings, model registries, CLI commands, and utilities. It adds exported CLI resolution helpers and expands tests for provider configuration, context windows, model listing, and option precedence.

Changes

Provider identifier centralization

Layer / File(s) Summary
Shared provider contracts and registries
packages/types/src/provider-settings.ts, packages/types/src/__tests__/provider-identifiers.test.ts
Provider schemas, model mappings, and MODELS_BY_PROVIDER now use providerIdentifiers. Tests validate registry keys and model identifiers.
CLI option and model resolution
apps/cli/src/commands/cli/run.ts, apps/cli/src/commands/cli/list.ts, apps/cli/src/commands/cli/__tests__/*
CLI resolution helpers handle precedence, defaults, workspace paths, and legacy approval settings. OpenRouter listing uses the shared identifier. Tests cover host lifecycle, malformed responses, and command execution.
Provider utility integration
apps/cli/src/lib/utils/*, apps/cli/src/types/*
Provider environment mappings, settings construction, context-window lookup, and supported-provider lists use canonical identifiers with expanded tests.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: edelauna

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the change summary and test plan, but it omits the required issue-link format, checklist, documentation section, and other template sections. Add the required template sections, use a formal “Closes: #number” issue link, and complete the pre-submission checklist and documentation-impact fields.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: canonicalization of provider identifiers in the CLI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/cli/src/lib/utils/__tests__/context-window.test.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/cli/src/lib/utils/context-window.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/cli/src/lib/utils/context-window.ts`:
- Around line 39-53: Update getContextWindow’s provider switch to handle
opencode-go, kenari, and zoo-gateway using config.opencodeGoModelId,
config.kenariModelId, and config.zooGatewayModelId respectively, matching
modelIdKeysByProvider so provider-specific configurations resolve correctly. Add
corresponding coverage in the context-window tests for each provider.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e2162954-a3b9-4a83-8d11-ab66aeaf8af8

📥 Commits

Reviewing files that changed from the base of the PR and between cbdce3d and 52e2322.

📒 Files selected for processing (12)
  • apps/cli/src/commands/cli/__tests__/list.test.ts
  • apps/cli/src/commands/cli/__tests__/run.test.ts
  • apps/cli/src/commands/cli/list.ts
  • apps/cli/src/commands/cli/run.ts
  • apps/cli/src/lib/utils/__tests__/context-window.test.ts
  • apps/cli/src/lib/utils/__tests__/provider.test.ts
  • apps/cli/src/lib/utils/context-window.ts
  • apps/cli/src/lib/utils/provider.ts
  • apps/cli/src/types/__tests__/types.test.ts
  • apps/cli/src/types/types.ts
  • packages/types/src/__tests__/provider-identifiers.test.ts
  • packages/types/src/provider-settings.ts

Comment thread apps/cli/src/lib/utils/context-window.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant