Skip to content

fix(completion): correct zsh _arguments syntax for options with short and long forms#22690

Closed
KhanCold wants to merge 3 commits into
NousResearch:mainfrom
KhanCold:fix/zsh-completion-arguments-syntax
Closed

fix(completion): correct zsh _arguments syntax for options with short and long forms#22690
KhanCold wants to merge 3 commits into
NousResearch:mainfrom
KhanCold:fix/zsh-completion-arguments-syntax

Conversation

@KhanCold

@KhanCold KhanCold commented May 9, 2026

Copy link
Copy Markdown

Bug Description

The hermes completion zsh command generates a Zsh completion script with invalid _arguments syntax, causing:

_arguments:comparguments:327: invalid argument: (-h --help){-h,--help}[Show help and exit]

This breaks tab completion for all Zsh users.

Root Cause

The _arguments syntax in the generated script uses groups like (-h --help) which is invalid because:

  • () groups in _arguments must contain only single-letter short options (e.g., -h), not long options (--help)
  • The space in (-h --help) makes it syntactically invalid

Fix

Replace all instances of (-X --Y) with (-), which means the option can be used with any other option. The correct format is:

'(-)'{-h,--help}'[Show help and exit]'

Changes

  • hermes_cli/completion.py: Fixed _arguments syntax in generate_zsh()

Testing

This fix ensures that hermes completion zsh generates valid Zsh completion syntax that works correctly with tab completion.

Related

Fixes #22686

KhanCold and others added 3 commits May 9, 2026 23:04
Fixes NousResearch#22604. The _render_table_block_for_telegram() function was
incorrectly including the first column (row-label) as a bullet item
when rendering tables for Telegram output. Changed zip(headers, cells)
to zip(headers[1:], cells[1:]) to skip the row-label column, matching
the expected Telegram output format.
… and long forms

The zsh completion script used invalid _arguments syntax:
  '(-h --help){{-h,--help}}[Show help and exit]'

This caused:
  _arguments:comparguments:327: invalid argument: (-h --help){-h,--help}[Show help and exit]

The issue is that () groups in _arguments must contain only single-letter
short options, not long options. The space in (-h --help) makes it invalid.

Fix: Replace all (-X --Y) groups with (-), which means the option can be
used with any other option. The correct format is:
  '(-)'{-h,--help}'[Show help and exit]'

This follows Zsh's official completion syntax guidelines and fixes tab
completion for all Zsh users.

Fixes NousResearch#22686
@teknium1

teknium1 commented May 9, 2026

Copy link
Copy Markdown
Contributor

Closing in favor of #22802 (salvage of #22727). The fix used single-brace {-h,--help} inside an f-string, which Python interprets as an expression — running generate_zsh() would raise NameError at runtime. Credited in the salvage PR body. Thanks!

@teknium1 teknium1 closed this May 9, 2026
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels May 9, 2026
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.

BUG: zsh completion script has invalid _arguments syntax

3 participants