feat(auth): add Kimi Code OAuth login#5
Conversation
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
WalkthroughKimi Code is added as an OpenAI-compatible device-code OAuth provider, with a built-in preset, CLI authentication shorthand, catalog coverage, wizard text, tests, and setup documentation. ChangesKimi OAuth integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as zero auth kimi
participant Login as runAuthLogin
participant Preset as Kimi OAuth preset
participant OAuth as Kimi OAuth endpoints
participant API as Kimi managed coding endpoint
CLI->>Login: invoke Kimi login
Login->>Preset: resolve device-flow configuration
Login->>OAuth: request device code and token
OAuth-->>Login: return access token
Login->>API: use bearer token on coding endpoint
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
Add a first-class Kimi Code OAuth provider modeled on the generic device-code preset path (like xAI), not the bespoke ChatGPT/Codex path. Kimi's returned access token works directly as a Bearer on its managed coding endpoint (api.kimi.com/coding/v1), so no claim extraction is needed. - internal/providercatalog/catalog.go: new `kimi` catalog entry, OpenAI-compatible at https://api.kimi.com/coding/v1, flagged OAuth + OAuthDeviceFlow, RequiresAuth with no API-key env var. Listed directly below the ChatGPT entry so it appears below ChatGPT in the OAuth options. - internal/oauth/presets.go: kimi device-code preset (auth.kimi.com endpoints, public kimi-code client_id); overridable via ZERO_OAUTH_KIMI_*. - internal/cli/auth.go: add `zero auth kimi` sugar routing to the generic device-code login; list kimi below chatgpt in help text. - internal/tui/provider_wizard.go: mention Kimi in the OAuth method subtitle and include it in the OAuth provider list. - docs/oauth-subscriptions.md: document the Kimi Code OAuth path. - Tests: presets, catalog, and oauth coverage updated.
2a296f5 to
94cafb7
Compare
|
Superseded by Gitlawb#708 (wrong target repo). |
Summary
Adds a first-class Kimi Code OAuth login to Zero, listed directly below ChatGPT in the OAuth options.
Kimi is modeled on the generic device-code preset path (like xAI), not the bespoke ChatGPT/Codex path — because Kimi's returned access token works directly as a
Beareron its managed coding endpoint, so no claim extraction is needed.Changes
internal/providercatalog/catalog.go— newkimicatalog entry, OpenAI-compatible athttps://api.kimi.com/coding/v1, flaggedOAuth+OAuthDeviceFlow,RequiresAuthwith no API-key env var. Placed immediately after the ChatGPT entry so it appears below ChatGPT in the OAuth provider list.internal/oauth/presets.go—kimidevice-code preset (auth.kimi.com endpoints, publickimi-codeclient_id); overridable viaZERO_OAUTH_KIMI_*.internal/cli/auth.go— addszero auth kimisugar routing to the generic device-code login; listskimibelowchatgptin the help text.internal/tui/provider_wizard.go— mentions Kimi in the OAuth method subtitle and includes it in the OAuth provider list.docs/oauth-subscriptions.md— documents the Kimi Code OAuth path.presets_test.go,catalog_test.go,oauth_test.goupdated.Safety / ToS note
The preset ships the public
kimi-codeclient_id and Moonshot'sauth.kimi.comendpoints copied from the open-sourcekimi-codeCLI. It does nothing a user couldn't already do manually (standard RFC 8628 device-code flow, no client spoofing). Off by default; enable withZERO_OAUTH_ALLOW_PRESETS=1or explicit env overrides.Verification
go fmt,go vet, golangci-lint (unused,ineffassign,staticcheck), andgovulncheckpass (no issues in modified files).go test ./internal/oauth/... ./internal/providercatalog/... ./internal/cli/...pass.🤖 Generated with Zero
Summary by CodeRabbit
New Features
zero auth kimias a shortcut for starting authentication.Documentation