feat(cli): add dynamic shell completion for bash, zsh, and fish - #9785
Merged
Conversation
Replaces the hardcoded completion stubs in profiles.py with a dynamic generator that walks the live argparse parser tree at runtime. - New hermes_cli/completion.py: _walk() recursively extracts all subcommands and flags; generate_bash/zsh/fish() produce complete scripts with nested subcommand support - cmd_completion now accepts the parser via closure so completions always reflect the actual registered commands (including plugin- registered ones like honcho) - completion subcommand now accepts bash | zsh | fish (fish requested in issue comments) - Fix _SUBCOMMANDS set: add honcho, claw, plugins, acp, webhook, memory, dump, debug, backup, import, completion, logs so that multi-word session names after -c/-r are not broken by these commands - Add tests/hermes_cli/test_completion.py: 17 tests covering parser extraction, alias deduplication, bash/zsh/fish output content, bash syntax validation, fish syntax validation, and subcommand drift prevention Tested on Linux (Arch). bash and fish completion verified live. zsh script passes syntax check (zsh not installed on test machine). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fish users' $SHELL is /usr/bin/fish, which fell into the '*' case and incorrectly wrote 'export PATH=...' to ~/.bashrc and ~/.zshrc — neither of which fish reads. - setup_path(): add fish) case that writes fish_add_path to ~/.config/fish/config.fish (fish-compatible PATH syntax) - setup_path(): skip ~/.profile for fish (not sourced by fish) - print_success(): show correct reload instruction for fish: source ~/.config/fish/config.fish Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The dynamic parser walker from the contributor's commit lost the profile name tab-completion that existed in the old static generators. This adds it back for all three shells: - Bash: _hermes_profiles() helper, -p/--profile completion, profile action→name completion (use/delete/show/alias/rename/export) - Zsh: _hermes_profiles() function, -p/--profile argument spec, profile action case with name completion - Fish: __hermes_profiles function, -s p -l profile flag, profile action completions Also removes the dead fallback path in cmd_completion() that imported the old static generators from profiles.py (parser is always available via the lambda wiring) and adds 11 regression-prevention tests for profile completion.
6 tasks
19 tasks
This was referenced May 24, 2026
Big Mistake!Warning Never, ever add completion code to It goes into |
13 tasks
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
Salvage of PR #9476 by @leozeli. Closes #2582.
Replaces the hardcoded, stale shell completion stubs in
profiles.pywith a dynamic generator that walks the live argparse parser tree at runtime. Adds fish shell support in both the completion generator andinstall.sh.Changes
From contributor (cherry-picked):
hermes_cli/completion.py— dynamic parser walker generates bash/zsh/fish completions from the live argparse tree. No new dependencies.hermes_cli/main.py— adds missing subcommands to_SUBCOMMANDSin_coalesce_session_name_args(), wires new completion generator, adds fish as a shell choicescripts/install.sh— fish shell PATH setup (fish_add_path,~/.config/fish/config.fish, skips~/.profilefor fish)Follow-up fixes (ours):
_hermes_profiles()helper +-p/--profilecompletion + profile action→name completion_hermes_profiles()function +-p/--profileargument spec + profile action case__hermes_profilesfunction +-s p -l profileflag + profile action completionscmd_completion()that imported old static generators fromprofiles.pyUsage
Test plan
bash -nsyntax validation passesinstall.shsyntax check passestest_coalesce_session_args.py(17 tests) pass