✨ feat(init): add interactive init command to configure API key and LLM model#29
✨ feat(init): add interactive init command to configure API key and LLM model#29
Conversation
…LM model Signed-off-by: samzong <samzong.lu@gmail.com>
Summary of ChangesHello @samzong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user onboarding experience for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new gmc init command to provide an interactive setup experience for users, which is a great improvement for first-time use. The changes also include adding a connection test for the LLM and integrating configuration checks into the main commit flows. The code is well-structured and includes corresponding tests. I've provided a few suggestions to improve code clarity and efficiency, particularly around handling I/O readers and reloading configuration.
I am having trouble creating individual review comments. Click here to see my feedback.
cmd/root.go (181)
After a successful run of runInitWizard (which saves the configuration), you are reloading the configuration here with cfg = config.GetConfig(). This is good practice to ensure the cfg variable holds the latest values. However, this same logic is missing in handleSelectiveCommitFlow after its call to ensureLLMConfigured. For consistency and correctness, you should also reload the config there.
cmd/root.go (389)
After ensureLLMConfigured runs and potentially updates the configuration, the cfg variable here will be stale if the user just went through the init flow. You should reload the configuration to get the new values, just like you do in handleCommitFlow.
cfg = config.GetConfig()
cmd/init.go (170)
In ensureLLMConfigured, you create a bufio.Reader and then pass it to initRunner. The initRunner (which is runInitWizard) then creates another bufio.Reader on top of the one it received. This is inefficient and can be confusing.
While this works, a cleaner approach would be to pass the original io.Reader (in) to initRunner and let runInitWizard be solely responsible for creating its bufio.Reader. To read the single-line response in ensureLLMConfigured, you can create a temporary bufio.Reader and not pass it down.
internal/llm/llm.go (152-153)
The TestConnection function uses a MaxTokens value of 1. If the LLM responds with a multi-token reply like "OK." (which can be tokenized as "OK", "."), the request might be truncated or fail unexpectedly depending on the model. To make this test more robust, consider increasing MaxTokens to a slightly larger value (e.g., 5 or 10) to accommodate simple affirmative responses.
MaxTokens: 10,
There was a problem hiding this comment.
Pull request overview
This PR enhances the first-run user experience by adding interactive LLM configuration checking. When an API key is missing, users are now prompted to run gmc init instead of encountering cryptic errors.
- Integrates
ensureLLMConfigured()check into both commit flow handlers - Adds test coverage for the selective commit flow when users decline initialization
- Updates documentation to recommend the guided setup approach
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/root.go | Adds ensureLLMConfigured() call to handleSelectiveCommitFlow to mirror existing handleCommitFlow behavior |
| cmd/init_test.go | Adds test case for handleSelectiveCommitFlow when user declines init prompt |
| README.md | Updates quick start section to emphasize guided setup and changes quote style in YAML examples |
What's Changes
gmc initsubcommand for guided LLM configuration (API key, model, API base)llm.TestConnection()to verify API connectivity during initensureLLMConfigured()check in both handleCommitFlow and handleSelectiveCommitFlowgmc initwhen API key is missingWhy
Improve first-run experience by guiding users through configuration instead of failing with cryptic errors.