Make project ID optional in the CLI#1
Conversation
The ZeroGPU backend now derives the project from the API key, so the CLI no longer requires a project ID. Commands require only the API key and send x-project-id only when a project ID is configured; login no longer prompts for a project ID (pass --project-id only to pin a specific project). - commands/*: guard on the API key alone; include x-project-id header only when getProjectId() returns a value. - login: project ID is optional — validated and stored only when provided via --project-id; no longer prompted. - docs (README, DOCUMENTATION, ADDING_COMMANDS) updated to mark the project ID optional and show the new request/auth pattern.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAll CLI commands are updated so only the API key is required for authentication. The ChangesOptional Project ID Across CLI
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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/commands/login.ts`:
- Around line 104-109: When the login command is executed without the
--project-id flag, the existing projectId should be cleared from the config
rather than retained. In the writeConfig call within the login command, modify
the spread of existing config to explicitly remove or override the projectId
field so that when projectId is not provided (undefined), it is either set to
null or excluded entirely from the final config object. This ensures that old
projectId values are not retained when users run login without specifying a
project ID.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7154c5f3-b82d-4295-8213-ab4e9e0e8261
📒 Files selected for processing (16)
README.mddocs/ADDING_COMMANDS.mddocs/DOCUMENTATION.mdsrc/commands/chat.tssrc/commands/chatThinking.tssrc/commands/classifyIab.tssrc/commands/classifyIabEnriched.tssrc/commands/classifyStructured.tssrc/commands/classifyZeroShot.tssrc/commands/extractEntities.tssrc/commands/extractJson.tssrc/commands/extractPii.tssrc/commands/generateFollowups.tssrc/commands/login.tssrc/commands/redactPii.tssrc/commands/summarize.ts
Re-login without --project-id previously retained the old projectId via the spread of the existing config, leaving a stale pin. Build the config explicitly and remove projectId when none is provided, so login without it returns to the unpinned (derive-from-key) state.
Summary
The ZeroGPU backend now derives the project from the API key, so the CLI no longer requires a project ID. Commands require only the API key and send
x-project-idonly when a project ID is configured;loginno longer prompts for a project ID (pass--project-idonly to pin a specific project).Changes
src/commands/*(12 commands): guard on the API key alone (if (!apiKey)); include thex-project-idheader only whengetProjectId()returns a value (...(projectId ? { "x-project-id": projectId.projectId } : {})).src/commands/login.ts: project ID is optional — validated and stored only when provided via--project-id; the mandatory prompt was removed.README.md,docs/DOCUMENTATION.md,docs/ADDING_COMMANDS.md): mark the project ID optional and show the new request/auth pattern.Notes
lib/auth.ts(getProjectId) andlib/config.tsalready treated the project ID as optional — no change needed there.ZEROGPU_PROJECT_ID/--project-idis still honored and forwarded.Testing
tsc --noEmitclean,eslint .clean,vitestgreen (24 tests).Summary by CodeRabbit
Documentation
New Features
--project-id.