feat(ai): add configurable model env vars and ai env flags#19
Merged
Conversation
- add DUBSTACK_GEMINI_MODEL and DUBSTACK_AI_GATEWAY_MODEL support - extend dub ai env with --gemini-model and --gateway-model - allow model-only env updates with soft validation - update ask/create model resolution, docs, and tests
There was a problem hiding this comment.
Pull request overview
This PR adds configurable AI model environment variables (DUBSTACK_GEMINI_MODEL and DUBSTACK_AI_GATEWAY_MODEL) that allow users to override the model used by both dub ai ask and dub create --ai without changing provider credentials. It also extends dub ai env with --gemini-model and --gateway-model flags for writing model overrides to shell profiles, updates the README with examples, and adds validation (blocking empty or slash-containing Gemini model names via the CLI).
Changes:
ai-env.ts/ai-env.test.ts: Added model validation functions (normalizeGeminiModel,normalizeGatewayModel) and updated the guard logic to allow model-only updates without keysai.ts/create.ts+ their tests: UpdatedresolveModelin both commands to readDUBSTACK_GEMINI_MODEL/DUBSTACK_AI_GATEWAY_MODELenv vars, falling back to the new defaults (gemini-3-flash-previewandgoogle/gemini-3-flash)README.md/index.ts/history.test.ts: Documentation and CLI option registration for the new flags
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/commands/ai-env.ts |
Adds model options, validation functions, and updated no-op guard |
src/commands/ai-env.test.ts |
Tests for model writes, key+model together, empty/slash validation, and updated no-arg error |
src/commands/ai.ts |
resolveModel now reads DUBSTACK_GEMINI_MODEL/DUBSTACK_AI_GATEWAY_MODEL with fallback defaults |
src/commands/create.ts |
Same resolveModel update as ai.ts |
src/commands/ai.test.ts |
Tests for Gemini and Gateway model overrides in askAi; updates default model expectation |
src/commands/create.test.ts |
Tests for Gemini and Gateway model overrides in create --ai |
src/lib/history.test.ts |
Confirms --gemini-model / --gateway-model args are not redacted from history |
src/index.ts |
Registers --gemini-model and --gateway-model options on dub ai env |
README.md |
Updated provider/key selection docs and added model-override examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
DUBSTACK_GEMINI_MODELandDUBSTACK_AI_GATEWAY_MODELdub ai envwith--gemini-modeland--gateway-model, and allow model-only updates/form)dub ai askanddub create --aiwith existing defaults unchangedTest Plan