Skip to content

fix(cli): keep zsh subcommand descriptions literal - #135114

Merged
steipete merged 1 commit into
mainfrom
codex/qa-20260901-zsh-command-descriptions
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-20260901-zsh-command-descriptions

Conversation

@steipete

@steipete steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Closes #135089. Related: #76126 and #64490.

What Problem This Solves

Fixes an issue where users pressing Tab in zsh would execute command examples embedded in subcommand descriptions. For openclaw models auth , the built-in logout hint loses its literal models auth list text during completion.

Why This Change Was Made

Subcommand descriptions duplicated incomplete escaping inside a double-quoted _arguments specification. Reuse the existing option-description encoder and retain the separate single-quote layer. This removes the duplicate path without adding a helper, dependency, or configuration option.

Production: +1/−6, net −5 lines. Tests: +68 lines. Thanks to @walker1211 for the subcommand report in #76126; the merged #64490 addressed the option-description sibling. Introduction provenance is unknown.

User Impact

Newly generated zsh completions preserve literal command descriptions and aliases, including quotes, dollar signs, and backticks. Other shell generators and completion installation behavior are unchanged.

Evidence

  • Three regression cases—built-in models registration, root commands, and nested aliases—fail on the original generator and pass after the repair, including after formatting.
  • Real interactive zsh -f proof uses the actual registerModelsCli/getCompletionScript output and normal compinit -D, _arguments, and _values. Before: Tab invokes a harmless recording models function once and displays Remove a saved auth profile (see for ids). After: no invocation, and the complete literal description is retained. The typed command was never submitted; no auth action, full built CLI, profile change, or installation was performed.
  • Five completion owner/sibling test files: 78 passed, 107 skipped because Fish and PowerShell are unavailable; native zsh cases ran.
  • Independent managed P0–P2 review: no actionable findings. The unchanged encoder and zsh parsing boundary were also inspected directly.
  • All 29 normal changed-file checks passed, including typechecks, formatting, lint, dependency boundaries, and unused-export checks.

Focused reproduction command:

node scripts/run-vitest.mjs src/cli/completion-cli.test.ts \
  -t 'command descriptions literal through real zsh parsing'

Environment: macOS 27.0 arm64, Node 24.20.0, pnpm 12.1.0, zsh 5.9.2.

Reuse the canonical description encoder for the double-quoted zsh
arguments specification while retaining its single-quote layer. Remove
the duplicate escaping path and cover built-in, root, and nested commands
through real zsh parsing.

Fixes #135089
Related: #76126, #64490

Co-authored-by: walker <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 6:38 AM ET / 10:38 UTC.

ClawSweeper review

What this changes

The PR reuses the existing zsh double-quoted description encoder for subcommand completion entries and adds real zsh parsing coverage for built-in, root, and nested commands.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this protected maintainer PR open: it supplies a focused, unique repair for a defect still present on fetched current main, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: 6f8b4602f683892dcfb3662860a6749a0befad71

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused net-negative production repair with relevant zsh-boundary coverage and no supported correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate is not applicable; the supplied body nevertheless describes an after-fix real zsh -f run, and the added test executes the generated script through zsh when available.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate is not applicable; the supplied body nevertheless describes an after-fix real zsh -f run, and the added test executes the generated script through zsh when available.
Evidence reviewed 6 items Fetched current main still has the defect: The current-main subcommand path escapes backslashes, apostrophes, and brackets, but does not escape dollar signs or backticks even though the resulting _values specification is double-quoted.
Canonical encoder reuse: The introduced production hunk routes subcommand descriptions through the same encoder already used for zsh option descriptions; that encoder escapes double quotes, dollar signs, backticks, and brackets before the retained single-quote layer.
Affected built-in command metadata: The models-auth logout command has a backticked command example in its declared description, providing a real command-tree instance for the generator path.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI completion generator turns Commander command metadata into shell scripts. The zsh script passes command names and descriptions through _arguments and _values when a user presses Tab.

flowchart LR
  A[CLI command metadata] --> B[Completion generator]
  B --> C[Zsh completion script]
  C --> D[_arguments specification]
  D --> E[_values command menu]
Loading

Before merge

  • Complete next step (P2) - This maintainer-labeled PR already contains a coherent candidate fix and has no discrete automated repair to dispatch; retain it for normal merge review.
Agent review details

Security

None.

PR surface

Source -5, Tests +68. Total +63 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 6 -5
Tests 1 68 0 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 69 6 +63

Review metrics

Metric Value Why it matters
Production versus test LOC production −5, tests +68 The fix removes a duplicate production escaping path while adding boundary coverage for three zsh command-tree scopes.

Technical review

Best possible solution:

Merge the canonical encoder reuse after normal exact-head merge gates complete, preserving the new zsh parsing regression test as the owner-boundary guard.

Do we have a high-confidence way to reproduce the issue?

Yes—source-reproducible with high confidence: fetched main leaves dollar signs and backticks unescaped in a double-quoted zsh subcommand specification, and the supplied zsh scenario exercises that exact path.

Is this the best way to solve the issue?

Yes—the existing double-quoted description encoder is the narrowest maintainable solution because zsh option descriptions already use it and the PR retains the subcommand-specific single-quote layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1dc3d5f2e790.

Labels

Label changes:

  • add P2: This corrects damaged local CLI completion output and unintended command evaluation without demonstrated urgent availability or security impact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate is not applicable; the supplied body nevertheless describes an after-fix real zsh -f run, and the added test executes the generated script through zsh when available.

Label justifications:

  • P2: This corrects damaged local CLI completion output and unintended command evaluation without demonstrated urgent availability or security impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies this as a MEMBER-authored PR, so the external-contributor proof gate is not applicable; the supplied body nevertheless describes an after-fix real zsh -f run, and the added test executes the generated script through zsh when available.

Evidence

What I checked:

  • Fetched current main still has the defect: The current-main subcommand path escapes backslashes, apostrophes, and brackets, but does not escape dollar signs or backticks even though the resulting _values specification is double-quoted. (src/cli/completion-cli.ts:327, 1dc3d5f2e790)
  • Canonical encoder reuse: The introduced production hunk routes subcommand descriptions through the same encoder already used for zsh option descriptions; that encoder escapes double quotes, dollar signs, backticks, and brackets before the retained single-quote layer. (src/cli/completion-cli.ts:327, 6f8b4602f683)
  • Affected built-in command metadata: The models-auth logout command has a backticked command example in its declared description, providing a real command-tree instance for the generator path. (src/cli/models-cli.ts:361, 1dc3d5f2e790)
  • Boundary-level regression coverage: The added table-driven test invokes the generated zsh functions in zsh, verifies no recording command runs, and checks the complete literal description for the built-in, root, nested, and alias cases. (src/cli/completion-cli.test.ts:90, 6f8b4602f683)
  • Not already on main or released: The PR head is not an ancestor of the fetched main SHA, and no local release tag contains the head; the repair remains necessary rather than being redundant with current main. (6f8b4602f683)
  • Completion-area history: Recent merged completion work includes multiple fixes by steipete, including completion installation and Windows shell handling, making this a well-established routing candidate for the area. (src/cli/completion-cli.ts:324, 9a86f34e07db)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • MarMar Labs: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Allow the in-progress exact-head checks to complete before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Ready to land at 6f8b4602f683892dcfb3662860a6749a0befad71. The description producer now reuses the existing zsh encoder and removes the duplicate partial escaping path. Production is +1/−6, net −5 lines; tests +68. Contributor @walker1211 remains credited in the PR and commit.

Three maintained regressions failed before and passed after. Actual interactive zsh -f Tab completion with normal compinit -D, _arguments, and _values changed from one harmless recorder invocation and a damaged built-in hint to zero invocations and the full literal description. Five completion suites passed 78 cases, with 107 existing Fish/PowerShell skips; native zsh cases ran. All 29 normal changed-file checks passed. No auth action, full built CLI, shell profile installation, or unavailable shell execution is claimed.

Exact-head CI has completed successfully. A fresh independent managed P0–P2 review of the complete commit found no actionable findings. The latest ClawSweeper review found no correctness/security defect; its rank-up request to finish the checks is satisfied. Native scripts/pr review-validate-artifacts 135114 and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 135114 completed successfully against the unchanged head, using verified hosted evidence. Native merge verification remains required.

@steipete
steipete merged commit 045f6eb into main Sep 1, 2026
197 checks passed
@steipete
steipete deleted the codex/qa-20260901-zsh-command-descriptions branch September 1, 2026 11:13
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
Reuse the canonical description encoder for the double-quoted zsh
arguments specification while retaining its single-quote layer. Remove
the duplicate escaping path and cover built-in, root, and nested commands
through real zsh parsing.

Fixes openclaw#135089
Related: openclaw#76126, openclaw#64490

Co-authored-by: walker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: zsh Tab completion evaluates subcommand descriptions

1 participant