fix(cli): enforce LiteLLM integration in setup when project has one configured - #429
Merged
Merged
Conversation
…nforcement threading
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ePluginSetup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Filter integrations by credential_type === 'LiteLLM' (CR-001) - Warn when multiple LiteLLM integrations match, use first (CR-002) - Skip SSO enforcement gate when isUpdate is true (CR-003) - Guard answers.apiKey with optional chain in enforcement mode (CR-004) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Includes spec, plan, technical-analysis, code-review reports, decisions/events audit logs, and .state.json (phase: maintenance). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
yanaSelin
reviewed
Jul 28, 2026
yanaSelin
left a comment
Collaborator
There was a problem hiding this comment.
Code review via SDLC Factory — 2 critical findings, 4 major findings. Full machine verdict: docs/superpowers/reviews/2026-07-28-pr-429/code-review-final.json
yanaSelin
reviewed
Jul 28, 2026
yanaSelin
reviewed
Jul 28, 2026
yanaSelin
reviewed
Jul 28, 2026
- CR-001: Remove isUpdate guard; enforcement runs on all flows per spec - CR-002: Add "Please reinstall codemie-cli." to provider-unavailable error - CR-003: Fix banner to use 📌 emoji and spec-exact message text - CR-004: Thread portal URL through LiteLLMEnforcementContext.codeMieUrl instead of using authResult.apiUrl (REST API URL, not portal) - CR-005: Re-throw ExitPromptError/AbortPromptError in catch block so Ctrl+C cannot silently bypass enforcement - CR-006: Add post-prompt guard in litellm.setup-steps.ts to reject empty API key in enforcement mode regardless of TTY context Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
yanaSelin
reviewed
Jul 29, 2026
Addresses reviewer feedback on commit 72d3d82. setup.ts: - Replace `(error as any)?.name` with `error instanceof Error` narrowing via isPromptAbortError() helper — complies with the no-any policy in AGENTS.md. - Wrap detectLiteLLMEnforcement() at the wizard call site in a try/catch that handles ExitPromptError cleanly (`Setup cancelled.` + return) instead of surfacing a raw stack trace through the Commander action. - Load the selected profile on update flows and thread its stored codeMieUrl to detectLiteLLMEnforcement() as existingCodeMieUrl, so `codemie setup --update` does not re-prompt for a portal URL the user already configured. - Drop the runSetupWizardForTest alias — tests now drive through the createSetupCommand() module boundary via Commander parseAsync. litellm.setup-steps.ts: - Remove the duplicate LiteLLM banner from getCredentials(); the spec-mandated banner already prints once from setup.ts before this step runs. - Interpolate enforced.codeMieUrl directly into the API-key prompt message and validator hint so the threaded portal URL actually reaches the user. - Simplify the return: with the pre-return guard in place, `key ?? ''` is dead code; use `key` directly in the enforced branch. setup.enforcement.test.ts: - Rewrite the second describe block to invoke createSetupCommand and parseAsync instead of the removed runSetupWizardForTest export. - Strengthen the SetupContext assertion to check codeMieUrl explicitly so a regression to authResult.apiUrl fails the test. - Add three new detectLiteLLMEnforcement tests: threads existingCodeMieUrl through to promptForCodeMieUrl, treats non-LiteLLM credential_type as not enforced, and re-throws ExitPromptError from both promptForCodeMieUrl and selectCodeMieProject. - Add a wizard-level test proving the setup wizard swallows ExitPromptError cleanly (no getCredentials call, no thrown stack trace). EPMCDME-11733
yanaSelin
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements EPMCDME-11733: when a CodeMie project already has a LiteLLM integration,
codemie setupnow detects it before the provider-selection prompt and forces the user through the LiteLLM path — they cannot complete setup without providing the required API key.Changes
src/providers/core/types.ts— addsSetupContextinterface (enforcedIntegration?: { id, alias, codeMieUrl }) and threads it intoProviderSetupSteps.getCredentialssrc/providers/plugins/litellm/litellm.setup-steps.ts— enforces non-empty API key whencontext.enforcedIntegrationis set; suppresses'not-required'fallbacksrc/cli/commands/setup.ts— addsdetectLiteLLMEnforcement()gate (SSO auth → project select → fetch integrations → filter byproject_nameandcredential_type === 'LiteLLM') that runs before provider selection; graceful fallback on any SSO error; update flows skip the gate (isUpdateguard)src/cli/commands/__tests__/setup.enforcement.test.ts— new; 7 tests covering the enforcement gate and its wiring into the wizardsrc/providers/plugins/litellm/__tests__/litellm.setup-steps.test.ts— new; 5 tests covering enforcement and normal modesTesting
npm run test:unit— 2329/2330 pass; 1 pre-existing unrelated failure)npm run lint— zero warnings)npm run typecheck)npm run build)Checklist
npm run ci— pre-existingself-update.test.tsfailure unrelated to this change)mainCloses EPMCDME-11733