fix(cli): completions exclude hidden/internal subcommands (v3.2.20)#63
Merged
Conversation
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
Follow-up bugfix to v3.2.19.
onebrain completions <SHELL>listed hidden subcommands — unimplemented resource groups (avatar,daemon,bundle,serve, …), legacy aliases (session-init,orphan-scan,migrate, …), and hidden nested verbs (qmd setup,vault scan, …) — soonebrain <TAB>surfaced internal/deprecated commands.Root cause
clap_complete's
aotshell generators (the staticgenerate()path we use) iteratecmd.get_subcommands()with nois_hide_set()filter —#[command(hide = true)]only affects--help, not completion. Verified in clap_complete 4.6.5 source; 4.6.5 is the latest release. clap'sCommandhas no remove-subcommand API, and the dynamic engine (which honors hide) is unstable + changes the install model.Fix
New recursive
visible_tree(&Command) -> Command(commands/completions.rs): rebuilds the command tree keeping only!is_hide_set()subcommands, thenrungenerates completions from it. Since clap can't remove subcommands, each node is reconstructed viaCommand::new, copying the settings that affect completion:about,version, args (skipping the autohelp/versionto avoid duplicate-id panic), visible aliases,disable_help_subcommand, andpropagate_version.Adds the clap
stringfeature (Str: From<String>is gated behind it; required for runtime-built commands).Testing
visible_tree_*): top-level drop, nested-verb drop, deep-visible retention (synthetic tree).completionsoutput): hidden top-level + legacy aliases +completionsitself +helpsubcommand absent from the root candidate list; visible 11 commands present; nested —qmdkeepsembed/status/reindex, dropssetup/search/help.bash -n/zsh -nOK); stdout stays clean (0-byte stderr — brew-safe); binary name staysonebrain; arg value-lists (--harness (claude gemini),--output (text json yaml)) preserved.helpassertions fail.3-round review (correctness / Rust-quality / adversarial) — the Rust-quality round caught a
help-subcommand leak (droppeddisable_help_subcommand), now fixed and guarded by tests.🤖 Generated with Claude Code