Repository navigation
fix(cli): report unknown subcommands instead of excess arguments - #124661
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 11:48 AM ET / 15:48 UTC. ClawSweeper reviewWhat this changesThe PR changes lazy CLI groups so mistyped nested commands become unknown-command errors with live suggestions, while genuine leaf-command extra arguments remain excess-argument errors. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessNo concrete line-level defect was found, but this maintainer-labeled PR needs explicit maintainer review because Commander’s direct contract and exact-head CI could not be independently checked in this checkout. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw lazily registers CLI command groups, then reparses the original invocation once a group loads. Its Commander adapter turns parser errors into OpenClaw help, documentation links, and command suggestions. flowchart LR
A[CLI arguments] --> B[Lazy command group]
B --> C[Reparsed command tree]
C --> D{Parser error}
D -->|Unknown child| E[Unknown-command guidance]
D -->|Extra leaf arguments| F[Excess-argument guidance]
E --> G[Operator-visible CLI output]
F --> G
Decision needed
Why: The protected maintainer label requires explicit human handling, and the dependency contract could not be inspected locally. Before merge
Agent review detailsSecurityNone. PR surfaceSource +14, Tests +91. Total +105 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one centralized parser-error classification at the OpenClawCommand boundary, then merge only after exact-head CI and Commander 15 behavior are confirmed by a prepared reviewer environment. Do we have a high-confidence way to reproduce the issue? No—not independently in this checkout: the source and regression scenario are clear, but dependencies are absent and the supplied built-distribution proof predates the final head. Is this the best way to solve the issue? Yes, conditionally: the shared OpenClawCommand error boundary is the narrowest owner for this distinction, pending direct Commander 15 contract confirmation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5f561999a9d8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
199396b to
803a4c8
Compare
|
Merged via squash.
|
…nclaw#124661) * fix(cli): report unknown subcommands accurately * style(cli): avoid map spread when collecting child command names
What Problem This Solves
Fixes an issue where users who mistyped a nested CLI command under most command groups saw
Too many arguments for this commandinstead of an unknown-command error. The misleading branch also hid the live group context and command suggestions.Why This Change Was Made
Commander checks a parent action before its unknown-command branch. Eleven affected groups have a zero-argument parent action for default listing or help, while
webhooksandnodesdo not; that structural difference caused the inconsistent messages after lazy registration loaded the real command tree.The OpenClaw Commander adapter now reclassifies only excess-argument errors raised on zero-argument parents with unmatched live child names. Matched leaf commands keep Commander's genuine excess-argument behavior. Suggestion candidates come from the live child tree, including accepted aliases, without adding per-group command lists or making registration eager.
AI-assisted: yes.
Production LOC: +16/-2 (net +14) | Tests: +91/-0
User Impact
Every tested command group now names the invalid subcommand, points at group help and CLI docs, and suggests a nearby real command when one exists. Valid aliases continue to work, and extra arguments after a real leaf command are still reported as extra arguments.
Evidence
13-group built-dist sweep
cronToo many arguments for this command.OpenClaw cron has no command "bogusxyz".sessionsToo many arguments for this command.OpenClaw sessions has no command "bogusxyz".modelsToo many arguments for this command.OpenClaw models has no command "bogusxyz".tasksToo many arguments for this command.OpenClaw tasks has no command "bogusxyz".devicesToo many arguments for this command.OpenClaw devices has no command "bogusxyz".agentsToo many arguments for this command.OpenClaw agents has no command "bogusxyz".skillsToo many arguments for this command.OpenClaw skills has no command "bogusxyz".pluginsToo many arguments for this command.OpenClaw plugins has no command "bogusxyz".channelsToo many arguments for this command.OpenClaw channels has no command "bogusxyz".configToo many arguments for this command.OpenClaw config has no command "bogusxyz".memoryToo many arguments for this command.OpenClaw memory has no command "bogusxyz".webhooksOpenClaw webhooks has no command "bogusxyz".nodesOpenClaw nodes has no command "bogusxyz".Exact head
cc2de5eda1f2349bad09b20262eb6d05605ddab0built successfully on Blacksmith Testboxtbx_01m05hz0psprsq72s7kw006qh2: https://github.com/openclaw/openclaw/actions/runs/31954845647Focused built-dist behavior:
openclaw cron remove --helpalso exited successfully, proving the accepted alias remains intact.Tests and review
node scripts/run-vitest.mjs src/cli/program/error-output.test.ts src/cli/program/help.test.ts src/cli/program/build-program.test.ts src/cli/program/parent-default-help.test.ts src/cli/program/action-reparse.test.ts— 45 passedcommander.excessArguments, expectedcommander.unknownCommand..agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output— clean, no accepted/actionable findingsnode scripts/check-changed.mjsselectedcoreandcoreTests, then stopped on the existing global assertion-safety shrink ratchet (src/gateway/server.auth.control-ui.pairing.suite.ts: 6 < 11) before the selected type/lint fan-out. This PR does not touch that protected baseline.