Repository navigation
fix(cli): report unknown subcommands even with --help - #124707
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 2:33 PM ET / 18:33 UTC. ClawSweeper reviewWhat this changesThe PR makes lazy CLI groups report an unknown nested subcommand followed by Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review: the patch addresses a real lazy-CLI parsing gap with focused behavior coverage, but its private Commander 15 hook still needs exact-head dependency-contract and built-CLI confirmation before merge. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw registers many CLI command groups lazily for startup speed. Commander initially parses a placeholder, which loads the real command tree and reparses arguments before OpenClaw formats help or unknown-command output. flowchart LR
A[CLI arguments] --> B[Lazy command placeholder]
B --> C[Commander help check]
C --> D[Load real command tree]
D --> E[Reparse arguments]
E --> F[Valid command help]
E --> G[Unknown-command guidance]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +42, Tests +76. Total +118 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the narrow lazy-placeholder deferral, then validate the exact head against resolved Commander 15 source and a built CLI before merge. Do we have a high-confidence way to reproduce the issue? Yes: current source shows the help hook can exit before the existing post-error reclassification, and the PR supplies a concrete built-CLI before/after path for a lazy nested command. Is this the best way to solve the issue? Unclear: moving the decision to the lazy parser boundary is the best apparent design, but the exact Commander 15 private-hook contract must be checked before that conclusion is merge-ready. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9d0c1f8f8c59. LabelsLabel changes:
Label 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)
|
653b0cb to
cc8a383
Compare
cc8a383 to
5689d83
Compare
|
Merged via squash.
|
* fix(cli): report unknown subcommands even with --help * fix(cli): scope Commander hook lint exceptions * fix(cli): document Commander hook assertion * refactor(cli): delegate the Commander help hook through super
What Problem This Solves
Adding
--helpto a mistyped nested command made Commander print the parent group's help and exit 0. The invalid token disappeared, soopenclaw sessions lst --helplooked like successful help for a valid command instead of reporting thatlstdoes not exist.Why This Change Was Made
Commander 15 checks its internal help hook before dispatching command actions and before its unknown-command branch. That ordering is especially important for OpenClaw's lazy placeholders: the placeholder must run its action and load the real child tree before OpenClaw can decide whether the token is a real subcommand.
The OpenClaw Commander adapter now records lazy placeholders, defers only their early help check, and classifies the token after the real tree has loaded. Unknown tokens then use the same canonical unknown-command formatter as the no-help form. Real child commands continue to render their own help normally. This keeps lazy registration lazy and adds no per-group command lists.
Production LOC: +56/-16 (net +40) | Tests: +77/-2
User Impact
<group> <unknown> --helpnow names the invalid subcommand, suggests a nearby real command when available, points to the parent group's help, and exits 1. Root, parent, real-subcommand, short-form, andhelp <command>output remain byte-identical and exit 0.Evidence
Built-dist before and after
Both builds used source base
715c379fd949a9a77224a590e8d9016f88b62d0c,OPENCLAW_SKIP_CHANNELS=1, and an isolated temporaryOPENCLAW_STATE_DIRon Blacksmith Testboxtbx_01m05rnzy10cbmgnebpvqgjhc8(Actions run https://github.com/openclaw/openclaw/actions/runs/31960660687).The normalized nested help form is consistent too:
Valid help is byte-identical
openclaw sessions list --helpfd5e681456d8993d9d1d6bbbf9e17219fc932e1f3142eb9dc7f050ffed5f04bcopenclaw sessions --helpe8aca473eb906102b4f673a51539abe20b5ad05ce6cb5438aefb31c5098089f1openclaw --help6d0e4f8f41eade80f0a9876c1b77c67cc7b388dd4b620fe462394f216e1a38adopenclaw -h6d0e4f8f41eade80f0a9876c1b77c67cc7b388dd4b620fe462394f216e1a38adopenclaw help sessionse8aca473eb906102b4f673a51539abe20b5ad05ce6cb5438aefb31c5098089f1Every valid case also had empty stderr before and after.
Tests and review
reports an unmatched lazy subcommand before --help can hide itfailed with receivedcommander.helpDisplayed, expectedcommander.unknownCommand.node scripts/run-vitest.mjs src/cli/program— 63 files, 1,117 tests passed.pnpm build— passed; no ineffective dynamic-import warning..agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output— clean, no accepted/actionable findings.node scripts/check-changed.mjsselectedcore, coreTests, accepted the new assertion-safety comment, then stopped on unrelated shrink-only baseline drift already present onorigin/main:src/state/control-ui-device-auth-migration.ts: 0 < 1andui/src/lib/nodes/index.ts: 3 < 4. This PR does not touch those files or the protected baseline.