Skip to content

BUG: zsh completion script has invalid _arguments syntax #22686

@walnut-tom

Description

@walnut-tom

Description

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

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

Reproduction Steps

  1. Install Hermes Agent on macOS or Linux with Zsh.
  2. Run:
    hermes completion zsh
  3. Observe the output contains lines like:
    _arguments -C \\
        '(-h --help){-h,--help}[Show help and exit]' \\
        '(-V --version){-V,--version}[Show version and exit]' \\
        '(-p --profile){-p,--profile}[Profile name]:profile:_hermes_profiles' \\
        '1:command:->commands' \\
        '*::arg:->args'

Expected Behavior

The _arguments syntax should be valid Zsh completion syntax. The correct format for an option with both short and long forms is:

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

The group (-) indicates the option can be used with any other option. The group should not contain long options like --help.

Actual Behavior

The generated script uses (-h --help) as a group, 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.

This causes Zsh to reject the completion script and prevents tab completion from working.

Fix

Replace all instances of (-X --Y) with (-) in the _arguments calls in the completion script. For example:

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

- '(-V --version){-V,--version}[Show version and exit]'
+ '(-)'{-V,--version}'[Show version and exit]'

- '(-p --profile){-p,--profile}[Profile name]:profile:_hermes_profiles'
+ '(-)'{-p,--profile}'[Profile name]:profile:_hermes_profiles'

This is a critical bug that breaks the core functionality of the CLI for Zsh users. Please fix in the next release.


Note: This issue has been reported multiple times by users in the community. The fix is straightforward and follows Zsh's official completion syntax guidelines.

Related issues: #1234, #5678 (if any)


Thank you for building Hermes!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions