feat(use): CLI-agent presets in aic use + provider vocabulary completion - #140
Merged
Conversation
Expose the provider's registry aliases so callers can enumerate all names accepted by from_name
Derive clap possible values from Provider::all() so `aic use` accepts only known names/aliases (case-insensitively) and shell completions expose the same vocabulary as Provider::from_name.
…tion Assert that the zsh completion script offers every canonical provider name and alias for the `aic use` command, guarding against the reported missing-completion regression.
Let `aic use claude|codex|pi|opencode` switch the active backend to that CLI agent, reusing its own auth instead of requiring a setup profile. Preset names win over provider aliases and match case-insensitively; the dormant API row stays intact for switching back (ADR 0011).
Clarify that aic use switches between saved providers and CLI agents (claude, codex, pi, opencode) in both READMEs
- `aic use <preset>` now works on a machine with no config at all, honouring the documented "no setup needed" promise; provider switches still require an existing config (banked profiles come from `aic setup`). - One ASCII folding rule (clap `ignore_case`, preset arm, provider registry) now governs the whole `aic use` vocabulary, so the accepted set cannot drift between clap and `apply_use`. - `use_vocabulary()` is the single source for both clap possible values and the zsh completion test, which now asserts exact equality instead of re-deriving the assembly. - `use_messages` pure core (cf. `list_lines`/`run_list`) pins the switch output contracts: agent line on the CLI arm, key-note only on a keyless provider arm. - Truth up the cli_agent module docs: preset names ARE reserved words in `aic use` that win over provider aliases; replace dead `unwrap_or(name)` fallbacks with structural `expect`s; preset test now pins the full spec (command/args/timeout_secs/encoding) instead of spot checks.
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.
What
Two related changes to
aic use:aic use <TAB>. Theproviderpositional was a plainStringwith no possible values, so clap_complete emitted a_defaultaction that completes nothing (bell on TAB). Now driven byuse_values()— aPossibleValuesParserbuilt from the registry (single source of truth): every provider canonical name + alias.aic use <preset>switches to a CLI agent.claude,codex,pi,opencode(case-insensitive) write the preset'scommand/args/timeout_secs/encodingand flipbackend_kind = "cli". Preset names win over colliding provider aliases:aic use claudeis the claude code CLI agent —aic use anthropicis the API provider.How
src/core/cli/mod.rs—use_values(): CLI presets first, then provider names/aliases, order-preserving dedupe so a preset-shadowed alias (claude) appears exactly once.ignore_case = truekept.src/core/config/mod.rs—apply_usegained the preset arm (checked before the provider path, mirrors clap'signore_case); presets are stateless so switching just overwrites the CLI fields — the API row stays dormant-but-intact for a switch back (ADR 0011).run_useprintsSwitched to CLI agent <command>.and skips the API-key note on that arm.usevocabulary.README.md/README.zh-CN.mdmirrored.Verification
cargo test: 405 unit + 2 e2e passing;cargo fmt --all -- --checkandcargo clippy --all-targets -- -D warningsclean.HOME):aic use claude→backend_kind = "cli"+ full claude preset written, openai row intact;aic use ANTHROPIC→ restores banked anthropic profile,backend_kind = "api";aic use nonsense→ rejected with the full vocabulary.aic use <TAB>offers the whole vocabulary (zpty harness + fresh interactive shell against the real fpath).Known limitation
fishcompletion still lacks positional-arg values — upstream clap_complete fish generator limitation, unchanged by this PR.