Skip to content

fix(cli): zsh completion crashes outside completion context#25075

Merged
teknium1 merged 4 commits into
mainfrom
hermes/hermes-b8c846ed
May 13, 2026
Merged

fix(cli): zsh completion crashes outside completion context#25075
teknium1 merged 4 commits into
mainfrom
hermes/hermes-b8c846ed

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Makes eval "$(hermes completion zsh)" in ~/.zshrc actually work — it currently errors on shell startup with _arguments:comparguments:327: can only be called from completion function because the generated script ends with _hermes "$@" instead of registering via compdef. Closes #6122.

What changed

  • hermes_cli/completion.py: _hermes "$@"compdef _hermes hermes (the standard pattern used by uv, kubectl, skaffold).
  • tests/hermes_cli/test_completion.py: regression for compdef registration, pin for _arguments exclusion-list quoting, and a zsh -n syntax check (skipped if zsh is unavailable).
  • hermes_cli/profiles.py: deleted dead generate_bash_completion() / generate_zsh_completion() and their tests. Multiple PRs (fix: zsh completion script crashes outside completion context #6141, fix(cli): zsh completion fails under eval in .zshrc (#6122) #9618) tried to fix the bug here only to discover the patch never reached users — hermes completion {bash,zsh} is wired to hermes_cli/completion.py's generators, not these.

Salvage credit

Anton Künzi (@ZeterMordio, #11754) — fix + tests cherry-picked with original authorship preserved.

Closes #11754, #6141, #9618, #21834, #22234.

Validation

  • scripts/run_tests.sh tests/hermes_cli/test_completion.py tests/hermes_cli/test_profiles.py → 135 passed, 3 skipped (zsh-not-installed; CI has zsh).
  • Manual: generate the script, verify compdef _hermes hermes is the trailing line and _hermes "$@" is gone.

ZeterMordio and others added 4 commits May 13, 2026 08:59
…sh_completion

These two functions in hermes_cli/profiles.py have no callers — the live
`hermes completion {bash,zsh}` command uses hermes_cli/completion.py's
generate_bash() / generate_zsh() instead. Multiple PRs (incl. #6141) tried
to fix the trailing-`_hermes "$@"` zsh bug here, only to discover the
patch never reached users. Delete the dead code so future contributors
patch the right file.

The actual user-facing fix lives in the preceding cherry-picked commits
to hermes_cli/completion.py.
For PR #11754 salvage (zsh completion compdef registration + _arguments
syntax tests). CI release script blocks unmapped emails.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-b8c846ed vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8252 on HEAD, 8252 on base (➖ 0)

🆕 New issues (3):

Rule Count
invalid-argument-type 3
First entries
run_agent.py:13591: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown | str, Unknown | str | dict[str, str]] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`
run_agent.py:13588: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`
run_agent.py:7391: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`

✅ Fixed issues (3):

Rule Count
invalid-argument-type 3
First entries
run_agent.py:13588: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`
run_agent.py:7391: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`
run_agent.py:13591: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown, Unknown] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`

Unchanged: 4330 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 13, 2026
@teknium1 teknium1 merged commit a9b8254 into main May 13, 2026
18 of 19 checks passed
@teknium1 teknium1 deleted the hermes/hermes-b8c846ed branch May 13, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zsh completion script fails with eval: _arguments called outside completion context

3 participants