Repository navigation
Conversation
Greptile SummaryAdds positional argument completion to the zsh completion generator by extracting a reusable Confidence Score: 5/5Safe to merge — the fix is narrowly scoped, well-tested, and all remaining findings are P2 style suggestions that do not affect the stated fix. No P0 or P1 issues found. The optional-positional indexing gap (using No files require special attention.
|
| return cmd.registeredArguments | ||
| .map((arg, index) => { | ||
| const description = escapeZshDescription(arg.description || arg.name()); | ||
| const position = arg.variadic ? "*::" : arg.required ? `${index + 1}:` : "::"; |
There was a problem hiding this comment.
Optional positional uses
:: without a position index
For optional non-variadic args, "::" is emitted without a position number. In zsh _arguments, the correct format for an Nth optional positional is N::message:action — omitting N makes it a free-floating "optional extra arg" spec rather than a position-bound one. For the current <path> fix this is a required arg (1:) so there's no impact, but if a future command registers multiple optional positional arguments the later ones will not bind to the right positions.
| const position = arg.variadic ? "*::" : arg.required ? `${index + 1}:` : "::"; | |
| const position = arg.variadic ? "*::" : arg.required ? `${index + 1}:` : `${index + 1}::`; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/completion-cli.ts
Line: 223
Comment:
**Optional positional uses `::` without a position index**
For optional non-variadic args, `"::"` is emitted without a position number. In zsh `_arguments`, the correct format for an *Nth optional positional* is `N::message:action` — omitting `N` makes it a free-floating "optional extra arg" spec rather than a position-bound one. For the current `<path>` fix this is a required arg (`1:`) so there's no impact, but if a future command registers multiple optional positional arguments the later ones will not bind to the right positions.
```suggestion
const position = arg.variadic ? "*::" : arg.required ? `${index + 1}:` : `${index + 1}::`;
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Addressed in commit f902855: optional non-variadic positionals now emit indexed N:: specs so later optional args stay position-bound.
There was a problem hiding this comment.
Pull request overview
This PR improves the zsh completion generator so it emits positional-argument specs for leaf commands (including _files completion for path-like args), restoring tab completion for openclaw wiki ingest <path>.
Changes:
- Refactors zsh description escaping into a reusable helper.
- Generates zsh positional argument specs from Commander registered arguments, routing path-like args to
_files. - Adds a regression test covering nested leaf command positional path completion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/cli/completion-cli.ts | Adds zsh positional argument spec generation and _files actions; refactors escaping helper. |
| src/cli/completion-cli.test.ts | Adds regression coverage for wiki ingest <path> positional completion. |
| return value | ||
| .replace(/\\/g, "\\\\") | ||
| .replace(/"/g, '\\"') | ||
| .replace(/'/g, "'\\''") |
There was a problem hiding this comment.
escapeZshDescription() is used for positional argument descriptions in generateZshPositionals(), but it does not escape :. In zsh _arguments specs, : is a field separator, so a description containing a colon (e.g. "Auth profile ids (e.g. anthropic:default)" in src/cli/models-cli.ts) will break parsing/completion. Please escape literal colons (e.g. replace : with \:) when emitting positional specs (either in escapeZshDescription or specifically for positional descriptions).
| .replace(/'/g, "'\\''") | |
| .replace(/'/g, "'\\''") | |
| .replace(/:/g, "\\:") |
There was a problem hiding this comment.
Addressed in commit f902855: zsh positional descriptions now escape literal colons before being inserted into _arguments specs.
| return cmd.registeredArguments | ||
| .map((arg, index) => { | ||
| const description = escapeZshDescription(arg.description || arg.name()); | ||
| const position = arg.variadic ? "*::" : arg.required ? `${index + 1}:` : "::"; |
There was a problem hiding this comment.
generateZshPositionals() treats all variadic args as optional by hard-coding the position prefix to *::, ignoring whether the Commander Argument is required (<arg...>) vs optional ([arg...]). This makes required variadic args (e.g. <entries...>) behave as optional in completion and can confuse _arguments’ arity handling. Consider using *: for required variadic and *:: for optional variadic (and keep the current non-variadic required/optional handling).
| const position = arg.variadic ? "*::" : arg.required ? `${index + 1}:` : "::"; | |
| const position = arg.variadic | |
| ? arg.required | |
| ? "*:" | |
| : "*::" | |
| : arg.required | |
| ? `${index + 1}:` | |
| : "::"; |
There was a problem hiding this comment.
Addressed in commit f902855: required variadics now emit *: while optional variadics keep *::, so the generated arity matches Commander semantics.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 534af48f5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .replace(/\\/g, "\\\\") | ||
| .replace(/"/g, '\\"') | ||
| .replace(/'/g, "'\\''") | ||
| .replace(/\[/g, "\\[") | ||
| .replace(/\]/g, "\\]"); |
There was a problem hiding this comment.
Escape
: in zsh positional message text
generateZshPositionals() emits specs in n:message:action form, but the shared escapeZshDescription() helper does not escape literal colons before inserting argument descriptions into the message field. Positional descriptions in this repo already include : (for example the JSON example in mcp set <value>), so zsh parses the generated spec as extra separators instead of one message, which can corrupt or break completion for those commands. _arguments requires literal colons in message/action text to be escaped, so this escaping needs to be added before positional specs are generated.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in commit f902855: the shared zsh description escaping now covers literal colons, which fixes positional specs whose descriptions include values like anthropic:default.
|
Addressed the current automated review feedback in commit f902855. Changes included:
Re-ran: pnpm exec vitest run src/cli/completion-cli.test.ts src/cli/completion-cli.write-state.test.ts |
|
Related work from PRtags group Title: Open PR duplicate: [Bug]: zsh completion for openclaw wiki ingest does not complete file paths
|
|
Closing this to reduce stale backlog on my side. I already pushed one follow-up iteration here, but I don’t want to keep an aging PR open if it isn’t the active fix path for #69293. If this issue still needs work later, I’d rather re-open the effort from current |
Summary
Teach the zsh completion generator to emit positional argument specs for leaf commands, including
_filescompletion for path-like arguments. This restores tab completion foropenclaw wiki ingest <path>without changing unrelated completion behavior.Changes
_filesopenclaw wiki ingest <path>Testing
pnpm exec vitest run src/cli/completion-cli.test.ts src/cli/completion-cli.write-state.test.tsFixes #69293