Skip to content

refactor: finish canonical provider identifier audit - #1030

Merged
edelauna merged 7 commits into
Zoo-Code-Org:mainfrom
WebMad:feat/960-canonical-provider-identifier-audit
Jul 30, 2026
Merged

refactor: finish canonical provider identifier audit#1030
edelauna merged 7 commits into
Zoo-Code-Org:mainfrom
WebMad:feat/960-canonical-provider-identifier-audit

Conversation

@WebMad

@WebMad WebMad commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace remaining raw API-provider comparisons in protocol selection with the canonical providerIdentifiers registry
  • use canonical identifiers for configuration-free, Kimi Code OAuth, and Zoo Gateway session-auth readiness checks
  • preserve serialized values and separate code-index, embedding, terminal, protocol, and model identifier domains
  • add focused mutation-based regression coverage proving runtime consumers read the canonical registry

Closes #960

TDD

Each migrated branch was driven by an observed red-green cycle:

  • Vertex Claude protocol routing
  • Vercel AI Gateway and Zoo Gateway Anthropic protocol routing
  • OpenCode Go model-specific protocol routing
  • configuration-free provider readiness
  • Kimi Code OAuth readiness
  • Zoo Gateway session-auth readiness

Verification

  • cd packages/types && npx vitest run src/__tests__/provider-settings.test.ts src/__tests__/provider-identifiers.test.ts src/__tests__/provider-default-model.test.ts — 38 passed
  • cd src && npx vitest run shared/__tests__/checkExistApiConfig.spec.ts shared/__tests__/ProfileValidator.spec.ts — 50 passed
  • types package type-check and changed-file ESLint — passed
  • extension package type-check and changed-file ESLint — passed
  • repository commit-time lint — passed

Known unrelated environment issue

The repository pre-push type-check reaches the new Playwright visual-test files and fails because local dependencies @playwright/experimental-ct-react, @playwright/test, and monocart-reporter are unavailable. The types and extension packages affected by this PR type-check successfully. The local runtime is Node 24.7.0 while the repository requests Node 22.23.1.

Summary by CodeRabbit

  • Bug Fixes
    • Improved API protocol routing for Anthropic-style vs OpenAI-style models, including Vertex, Zoo Gateway/Vercel AI Gateway canonical identifiers, and Opencode Go formatting.
    • Improved reliability of provider detection for authentication/config checks by using canonical provider identifiers, covering keyless, OAuth (including Kimi Code), and session-based scenarios.
    • Strengthened edge-case behavior for undefined/empty providers and case-insensitive Claude detection.
  • Tests
    • Updated and expanded test coverage to use shared protocol constants and canonical provider identifiers, adding explicit wire-string assertions and Gateway provider routing cases.

@coderabbitai

coderabbitai Bot commented Jul 26, 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: f012e027-44bd-4ecc-8bf3-a3d451666c9a

📥 Commits

Reviewing files that changed from the base of the PR and between 7b084ea and fcd904d.

📒 Files selected for processing (3)
  • packages/types/src/__tests__/provider-settings.test.ts
  • packages/types/src/provider-settings.ts
  • packages/types/src/providers/anthropic.ts
💤 Files with no reviewable changes (1)
  • packages/types/src/providers/anthropic.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/types/src/tests/provider-settings.test.ts
  • packages/types/src/provider-settings.ts

📝 Walkthrough

Walkthrough

The change adds shared Anthropic/OpenAI protocol constants, centralizes provider identifiers in protocol and authentication checks, and expands tests for provider-specific routing and keyless authentication behavior.

Changes

Provider identifier centralization

Layer / File(s) Summary
Protocol constants and routing
packages/types/src/providers/*.ts, packages/types/src/provider-settings.ts
Adds exported protocol constants and uses canonical identifiers for Anthropic-style, gateway, Vertex, and Opencode Go protocol selection.
Protocol routing coverage
packages/types/src/__tests__/provider-settings.test.ts
Uses canonical identifiers and verifies protocol constants, provider-specific routing, fallbacks, and edge cases.
Authentication provider checks
src/shared/checkExistApiConfig.ts, src/shared/__tests__/checkExistApiConfig.spec.ts
Uses canonical identifiers for configuration-free providers, Kimi Code OAuth, and Zoo Gateway session authentication, with corresponding tests.

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

Possibly related issues

Possibly related PRs

Suggested labels: awaiting-review

Suggested reviewers: taltas, navedmerchant

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the provider identifier audit refactor.
Description check ✅ Passed It covers the issue link, implementation summary, TDD, and verification details, matching the template well enough.
Linked Issues check ✅ Passed The changes replace remaining runtime provider literals with canonical identifiers and add regression coverage as requested by #960.
Out of Scope Changes check ✅ Passed The diff stays focused on provider-identifier cleanup and related tests, with no clear unrelated changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
@WebMad
WebMad marked this pull request as ready for review July 26, 2026 16:20

@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 `@src/shared/__tests__/checkExistApiConfig.spec.ts`:
- Around line 69-72: Update the keyless-provider tests around checkExistKey to
exercise providerIdentifiers.openaiCodex and providerIdentifiers.qwenCode in
addition to providerIdentifiers.fakeAi. Replace any hard-coded openaiCodex or
qwenCode identifiers in the nearby cases with their corresponding registry
values.
🪄 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: 73331000-75cf-46be-b611-189c7fe8291a

📥 Commits

Reviewing files that changed from the base of the PR and between c52f118 and 14f7277.

📒 Files selected for processing (6)
  • packages/types/src/__tests__/provider-settings.test.ts
  • packages/types/src/provider-settings.ts
  • packages/types/src/providers/anthropic.ts
  • packages/types/src/providers/openai.ts
  • src/shared/__tests__/checkExistApiConfig.spec.ts
  • src/shared/checkExistApiConfig.ts

Comment thread src/shared/__tests__/checkExistApiConfig.spec.ts
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 26, 2026
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/providers/anthropic.ts Outdated
@github-actions github-actions Bot removed the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 26, 2026
@github-actions github-actions Bot added the awaiting-author PR is waiting for the author to address requested changes label Jul 26, 2026
@WebMad
WebMad requested a review from edelauna July 29, 2026 16:23
@github-actions github-actions Bot added awaiting-review PR changes are ready and waiting for maintainer re-review and removed awaiting-author PR is waiting for the author to address requested changes labels Jul 29, 2026

@edelauna edelauna 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.

Thank you

@edelauna
edelauna added this pull request to the merge queue Jul 30, 2026
Merged via the queue into Zoo-Code-Org:main with commit c378193 Jul 30, 2026
20 checks passed
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.

[ENHANCEMENT] Replace remaining production provider literals and verify canonical identifier coverage

2 participants