fix(setup): offer Keep/Replace/Clear when API key already exists#20162
Merged
Conversation
hermes setup / hermes model used to silently skip the key prompt when any value was present in .env — even a malformed paste — leaving users with a stuck '✓' and no way to recover without hand-editing .env. Replace the silent acknowledgement at all three API-key provider flows (Kimi, Stepfun, generic) with a single [K]eep / [R]eplace / [C]lear menu via a shared `_prompt_api_key` helper. - K / Enter / Ctrl-C / unknown input → keep (never destroys the key) - R → getpass for new key; empty input cancels and preserves existing - C → clears the env var, tells user to rerun hermes setup, aborts flow LM Studio's no-auth-placeholder substitution stays on first-time entry only; on Replace an empty input means 'cancel', not 'overwrite with dummy key'. 11 unit tests cover all branches incl. garbage-input-keeps-key, Ctrl-C at the choice prompt, Replace-cancel preserving the old key, Clear wiping only the target env var, and lmstudio placeholder semantics. Fixes #16394 Reshapes #18355 — original PR pasted the menu inline at 3 sites with no tests; this consolidates to one helper (+88/-66) with coverage. Co-authored-by: Feranmi10 <89228157+Feranmi10@users.noreply.github.com>
1 task
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.
hermes setup/hermes modelused to silently skip the key prompt when any value was present in.env— even a malformed paste — leaving users with a stuck✓and no way to recover without hand-editing~/.hermes/.env.Changes
hermes_cli/main.py(+88/−66): new_prompt_api_key(pconfig, existing_key, provider_id)helper. All three API-key provider flows (Kimi, Stepfun, generic) now call it instead of inlining ~30 lines of branching each.tests/hermes_cli/test_prompt_api_key.py(+11 tests): coverage for every branch incl. lmstudio placeholder semantics.UX
getpassfor new key; empty input cancels and preserves existinghermes setup, aborts the flowLM Studio's no-auth-placeholder substitution stays on first-time entry only; on Replace, empty input means 'cancel', not 'overwrite with dummy key'.
Validation
.env✓, stuckFixes #16394
Reshapes #18355 — original PR pasted the menu inline at 3 sites with no tests; this consolidates to one helper and adds coverage. Credit to @Feranmi10 for identifying the bug and the K/R/C UX; authorship preserved via
Co-authored-by.