-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add interactive configuration setup wizard #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit introduces an interactive TUI setup wizard using
the **github.com/charmbracelet/huh** library.
The application now validates the loaded configuration upon
startup. If validation fails (e.g., missing API keys), the
wizard guides the user through setting the required LLM
provider, API keys, and models for either Gemini or OpenAI.
Additional changes:
* Added configuration validation via
**github.com/go-playground/validator/v10**.
* Implemented `Validate()` and `Save()` methods on the
`Config` struct.
…t/setup-wizard * 'main' of github.com:rm-hull/git-commit-summary: chore: Update indirect Go dependencies
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Unifies configuration settings by removing provider-specific
nested structs (`GeminiConfig`, `OpenAIConfig`) in favor of
generic fields (`APIKey`, `Model`, `BaseURL`) on the main
`Config` struct.
This change facilitates the introduction of the `llama.cpp`
provider, which reuses the existing OpenAI client infrastructure
but uses dedicated environment variables for configuration.
Refactors include:
* Introduction of `updateProperties` helper for saving config
while preserving comments and unrelated entries in the
`.env` file.
* Updated setup wizard to include Llama.cpp options.
* LLM providers now read configuration directly from the
top-level `Config` struct.
This commit implements security hardening and improves reliability:
* Hardens security by ensuring configuration files containing
API keys are only readable and writable by the owner (0o600).
They previously used 0o644.
* Explicitly passes the `APIKey` to the Google client, removing
reliance on automatic environment variable loading by the
underlying `genai` library. This increases reliability.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
When the setup wizard is aborted (e.g., via Ctrl+C), the error is now translated from the library-specific `huh.ErrUserAborted` to the internal `interfaces.ErrAborted`. This removes dependency on the `huh` package error types in calling functions, such as `main.go`, simplifying error handling logic there.
|
/gemini summary |
|
/gemini review |
Summary of ChangesThis pull request significantly improves the user experience for initial application setup by introducing an interactive, terminal-based configuration wizard. This wizard automatically activates if the existing configuration is invalid or incomplete, guiding the user through selecting an LLM provider and entering necessary API keys and model details. The changes also include a more robust and unified internal configuration management system with validation and persistence capabilities. Highlights
Changelog
Activity
|
There was a problem hiding this 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 helpful interactive setup wizard for configuration, which is a great improvement for user experience. The refactoring of the Config struct simplifies the structure nicely. My review focuses on a critical bug in saving the llama.cpp configuration, inconsistencies in how default values are loaded, a subtle bug in how the configuration file is updated, and opportunities to reduce duplicated code by centralizing default values. Addressing these points will improve the robustness and maintainability of the new configuration management.
internal/config/config.go
Outdated
| // 3: quote type = `"` or empty if unquoted | ||
| re := regexp.MustCompile(`^\s*([A-Za-z_][A-Za-z0-9_]*)=(?:"(.*)"|(.*))\s*$`) | ||
|
|
||
| for _, line := range original { | ||
| m := re.FindStringSubmatch(line) | ||
| if m == nil { | ||
| // Keep raw/unknown lines | ||
| out = append(out, line) | ||
| continue | ||
| } | ||
|
|
||
| key := m[1] | ||
|
|
||
| // m[2] is the quoted value (if present) | ||
| // m[3] is the unquoted value (if present) | ||
| quotedOriginal := m[2] != "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of issues in this section:
- The comment for the regex's capture group 3 is misleading. It captures the unquoted value, not the quote type.
- The logic on line 144 to detect if a value was originally quoted is buggy for empty quoted strings (e.g.,
KEY=""). It will be incorrectly identified as unquoted and rewritten without quotes.
A more robust approach would be to inspect the line string directly to check for surrounding quotes, as the regex capture groups are ambiguous for empty values.
Ensures consistency when appending new configuration properties to the config file by sorting them alphabetically.
The default LLM model assignment logic is now centralized
within `config.Load()`, removing duplication found in
`setup/wizard.go`.
This change also includes:
* Fixing the `LLM_PROVIDER` value when saving `llama.cpp`
configuration properties.
* Removing verbose output when configuration validation
fails and the setup wizard runs automatically.
This formalizes the configuration for the dummy test LLM provider.
* API key and Model validation are now bypassed when
`LLMProvider` is set to "test".
* The test provider can now be selected and saved using the
setup wizard, which is now triggered automatically if test
mode is detected.
* Simplifies the internal `NewTestDummy` provider constructor.
Updates the indirect dependency `github.com/clipperhouse/displaywidth` from `v0.5.0` to `v0.6.0` in `go.mod` for general maintenance.
Adds placeholders for planned future work in the setup wizard flow in `internal/setup/wizard.go`: * Adding invisible fields for form-level validation. * Implementing a final confirmation step (summary/Yes/No).
A confirmation step is now included at the end of the setup wizard flow. This allows users to review the selected LLM provider, API Key, and model before confirming that the configuration should be saved and potentially overwrite existing settings. If the user declines the confirmation prompt, the setup process is aborted.
When updating existing configuration properties in files, this change implements two key improvements: * The original line is archived by preceding it with a comment marker (`#`). * The new configuration value is always written using double quotes (`key="value"`), ensuring consistent formatting regardless of how the original property was structured.
Extracts the confirmation step into a dedicated submitGroup.
Adds validationGroup using **go-playground/validator** to display
required fields if configuration validation fails.
* Restructures provider groups (OpenAI, Google, Llama.cpp)
to show Model selection before API Key input.
* Converts Llama.cpp model input to a select list.
Updates to configuration properties now only comment out the existing line and write the new line if the value has actually changed (`oldVal != newVal`). This refinement reduces file churn and prevents unnecessary commenting of lines when configuration values are reapplied but are identical to the existing values.
Pull Request Test Coverage Report for Build 19863877439Details
💛 - Coveralls |
Adds new LLM options to the setup configuration wizard. * Includes `Gemini 3 Pro (Preview)` to the Google models list. * Updates the Llama.CPP model selection with several modern, high-performing models (e.g., Llama 3.1, Qwen 2.5, Phi 4, and updated Gemma 3 variants), replacing outdated options.
This commit introduces an interactive TUI setup wizard using
the github.com/charmbracelet/huh library.
The application now validates the loaded configuration upon
startup. If validation fails (e.g., missing API keys), the
wizard guides the user through setting the required LLM
provider, API keys, and models for either Gemini or OpenAI.
Additional changes:
github.com/go-playground/validator/v10.
Validate()andSave()methods on theConfigstruct.Fixes #19