feat(cli): suggest closest command for unknown subcommands (#83999)#84036
feat(cli): suggest closest command for unknown subcommands (#83999)#840360xghost42 wants to merge 1 commit into
Conversation
…explicit alias map for upgrade/remove/ls/ping (openclaw#83999)
|
Codex review: needs real behavior proof before merge. Reviewed June 14, 2026, 8:03 PM ET / 00:03 UTC. Summary PR surface: Source +95, Tests +68. Total +163 across 3 files. Reproducibility: yes. for the PR defect: source inspection shows Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Share one command-suggestion helper across Commander parse errors and Do we have a high-confidence way to reproduce the issue? Yes for the PR defect: source inspection shows Is this the best way to solve the issue? No, not as submitted: the formatter helper is reasonable, but wiring only Commander Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9ba6ed1d5cb8. Label changesLabel justifications:
Evidence reviewedPR surface: Source +95, Tests +68. Total +163 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
@clawsweeper acknowledged on the missed runtime path — your read is correct, and I owe a transparent recap of where the patch lands today, where the real-environment gap is, and what direction would unblock without another back-and-forth. The patch only wires the suggester into the Commander parse-error pathToday the suggester reaches the user only through So The vitest case at Two paths I'd take, but want your call before pushing
Real-environment gap
Neither is reachable from a contributor sandbox without crabbox/testbox. Happy to either:
Asks
No further code from my side until your call — pushing path-1 now without ack would just re-trip the review state. |
|
Heads up: this PR needs to be updated against current |
|
Thanks @0xghost42 for putting together the first implementation for #83999. I am closing this PR as superseded by #91345 because both PRs track the same CLI closest-command suggestion, and #91345 is the surviving open canonical path: it wires the suggestion into both the Commander parse-error path and the early unowned-root path, while this branch's own recap notes it only reaches the Commander path. Clownfish is keeping #91345 as the canonical thread so validation and maintainer follow-up stay in one place. Your work in #84036 helped establish the direction, and that source PR context and attribution are preserved in the cluster record. If this branch has a distinct reproduction path or #91345 does not cover the case after it lands, please reply and we can reopen or split it back out. |
Closes #83999.
Summary
`openclaw upate` and `openclaw upgrade` previously failed with a generic `OpenClaw does not know the command "upate".` and left the user to inspect `openclaw --help` manually. This change appends npm-style `Did you mean this?` suggestions, computed from Levenshtein distance against the registered root commands plus a tight explicit alias map for terminology that doesn't fall out of edit distance (`upgrade -> update`, `remove -> uninstall`, `rm -> uninstall`, `ls -> list`, `ping -> doctor`).
Output shapes:
```
$ openclaw upate
OpenClaw does not know the command "upate".
Did you mean this?
openclaw update
Try: openclaw --help
Plugin command? openclaw plugins list
Docs: https://docs.openclaw.ai/cli
```
```
$ openclaw upgrade
OpenClaw does not know the command "upgrade".
Did you mean this?
openclaw update
...
```
```
$ openclaw zzqwerty # no suggestion when nothing is close
OpenClaw does not know the command "zzqwerty".
Try: openclaw --help
...
```
Design
Real behavior proof
Behavior addressed: unknown root commands now append `Did you mean this?` with the closest registered command (or alias target) when the distance is small enough.
Real environment tested: darwin / arm64 / Node 22.21.1, openclaw source tree at HEAD of branch above.
Exact steps or command run after this patch:
```
node scripts/run-vitest.mjs src/cli/program/error-output.test.ts
./node_modules/.bin/oxlint --type-aware src/cli/program/error-output.ts src/cli/program/error-output.test.ts src/cli/program/help.ts
```
Evidence after fix:
```
$ node scripts/run-vitest.mjs src/cli/program/error-output.test.ts
RUN v4.1.6 /Users/harshkumarkaithwas/Desktop/openclaw
Test Files 1 passed (1)
Tests 13 passed (13)
$ ./node_modules/.bin/oxlint --type-aware src/cli/program/error-output.ts src/cli/program/error-output.test.ts src/cli/program/help.ts
Found 0 warnings and 0 errors.
```
Observed result after fix: `formatCliParseErrorOutput` now emits `Did you mean this?\n openclaw update\n` between the unknown-command error line and the `Try:` hint when (a) a typo is within edit-distance threshold OR (b) the input matches an entry in the explicit alias map AND the alias target is registered.
What was not tested: live binary spawn against a built `openclaw` CLI — covered transitively by the existing parse-error round-trip and `run-main.exit.test.ts` suite, which both call the same Commander `outputError` path.
Coverage
Unit tests in `src/cli/program/error-output.test.ts`:
Notes