feat(cli): numbered menu for require_one_of provider selection#734
Merged
Conversation
When an interactive `af run`/`af install` hits an unsatisfied require_one_of group, the old flow prompted for each option in sequence and told the user to "fill in one, leave the rest blank" — so to use OpenRouter you had to know to press Enter past the Anthropic prompt. Nobody could tell how to select. It also listed options as `ANTHROPIC_API_KEY | OPENROUTER_API_KEY`, which reads poorly. Now a group with two or more options renders a numbered menu (each option on its own line with its description), reads a single selection, and prompts only for the chosen provider. A single-option group still prompts directly. All user-facing option enumerations join with "or" instead of "|" (menu prompt "Enter 1 or 2 …", and the missing-env error). Adds a PromptLine method to the Prompter interface (echoed line read for the selection) with a stdin-swap test, and menu contract tests covering select/retry/skip/exhaust/blank/single-option paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
Contributor
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
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
Fixes the
require_one_ofprovider prompt inaf run/af install. When anode needed one of several keys (e.g. SWE-AF's
ANTHROPIC_API_KEYorOPENROUTER_API_KEY), the old flow prompted for each option in sequence andtold the user to "fill in one, leave the rest blank" — so to pick OpenRouter you
had to know to press Enter past the Anthropic prompt. There was no visible way
to select. It also rendered the options as
ANTHROPIC_API_KEY | OPENROUTER_API_KEY,which reads poorly.
Before
After
Typing
2prompts only OpenRouter — no more guessing which blank does what.Changes
its description; a single line of input selects one, and only the chosen
provider is then prompted for and persisted. A single-option group still
prompts directly (no menu).
("Enter 1 or 2 …") and the missing-env error ("at least one of A or B is
required"), via a small
orJoinhelper.PromptLineto thePrompterinterface (an echoed, trimmed line read forthe selection — never used for secret values);
TTYPrompterimplements it.Validation contract / tests
leaves the group unsatisfied without prompting for a secret.
orJoin/ missing-env wording joins with "or", never "|".PromptLinereads a trimmed line from stdin.Verified end-to-end by driving a real
af run swe-plannerthrough a PTY (menurendered, selection routed to the right key).
internal/packages+internal/uisuites green; changed files are lint-clean. New functions:
promptGroup90%,storeGroupOption89%,orJoin100%,PromptLine83% (only error-returnbranches uncovered).
🤖 Generated with Claude Code