Skip to content

✨ feat(init): add interactive init command to configure API key and LLM model#29

Merged
samzong merged 2 commits intomainfrom
feat/init-guided-setup
Dec 23, 2025
Merged

✨ feat(init): add interactive init command to configure API key and LLM model#29
samzong merged 2 commits intomainfrom
feat/init-guided-setup

Conversation

@samzong
Copy link
Owner

@samzong samzong commented Dec 23, 2025

What's Changes

  • Add gmc init subcommand for guided LLM configuration (API key, model, API base)
  • Add llm.TestConnection() to verify API connectivity during init
  • Integrate ensureLLMConfigured() check in both handleCommitFlow and handleSelectiveCommitFlow
  • Prompt user to run gmc init when API key is missing
  • Add unit tests for init wizard and ensureLLMConfigured
  • Update README with init command usage

Why

Improve first-run experience by guiding users through configuration instead of failing with cryptic errors.

…LM model

Signed-off-by: samzong <samzong.lu@gmail.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 gmc tool by introducing an interactive initialization command. This new feature guides users through the essential configuration steps for their Large Language Model (LLM) settings, including API key, model, and API base, and proactively verifies API connectivity. By integrating this setup process directly into the command-line interface, the PR aims to reduce initial friction and prevent common configuration-related errors, making the tool more accessible and user-friendly from the start.

Highlights

  • Interactive Initialization Command: Introduced a new gmc init command that provides an interactive wizard to guide users through configuring their LLM API key, model, and API base.
  • API Connectivity Verification: The init command now includes a step to test the LLM API connection, ensuring that the provided credentials and settings are valid.
  • Improved First-Run Experience: Integrated a check (ensureLLMConfigured) into the commit flows (handleCommitFlow and handleSelectiveCommitFlow) that prompts users to run gmc init if the API key is missing, preventing cryptic errors.
  • Comprehensive Testing: Added unit tests for the new init wizard and the ensureLLMConfigured function, along with a test for the LLM connection verification.
  • Documentation Update: The README.md has been updated to reflect the new gmc init command as the recommended way to set up the tool.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

high

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)

high

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)

medium

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)

medium

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,

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@samzong samzong merged commit 8bb579f into main Dec 23, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants