Skip to content

cli: generated Zsh completions fail with doubled argument definition #41966

Description

@AdiY00

Summary

The Zsh script generated by opencode2 --completions zsh defines both the optional directory and command as positional argument 1. Pressing Tab after opencode2 fails instead of showing completions.

Environment

  • opencode version: opencode2 v0.0.0-next-17276
  • OS: Windows 11 with WSL2; Linux 6.18.33.2-microsoft-standard-WSL2 x86_64
  • Terminal: Windows Terminal; TERM=xterm-256color; TERM_PROGRAM and COLORTERM unset
  • Shell: /usr/bin/zsh, Zsh 5.9.2
  • Install/channel: next/beta, installed at ~/.bun/bin/opencode2
  • Active plugins: codex-limits.ts, git-ai.ts

Reproduction

  1. Run mkdir -p ~/.zsh/completions && opencode2 --completions zsh > ~/.zsh/completions/_opencode2.
  2. Add fpath=("$HOME/.zsh/completions" $fpath), autoload -Uz compinit, and compinit to .zshrc.
  3. Start a fresh Zsh shell.
  4. Type opencode2 and press Tab.

Expected Behavior

Zsh displays available OpenCode subcommands and options.

Actual Behavior

Completion fails consistently with:

_arguments:comparguments:327: doubled argument definition: 1:command:->command

The generated root specification contains:

':Directory to start OpenCode in:'
'1:command:->command'
'*::arg:->args'

The unnumbered directory specification occupies positional argument 1 and conflicts with the explicit command definition.

Additional Context

Removing ':Directory to start OpenCode in:' from the generated file makes completion work. Regenerating the file reintroduces the issue. This occurs with the script emitted directly by opencode2 --completions zsh; active plugins do not appear involved.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions