feat(cli): suggest the nearest command on engine-intercepted unknowns - #104
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves cli-engine’s early “unknown command” interception path by adding nearest-match suggestions (and an optional interactive correction prompt) so typos in top-level and nested command tokens produce actionable hints instead of bypassing clap’s suggestion machinery entirely.
Changes:
- Add nearest-subcommand suggestion logic (edit distance + visibility/alias handling) to the group-router unknown-command path.
- Add an interactive
Did you mean ...?confirmation prompt that can rewrite args and re-dispatch in interactive sessions. - Extend foundation/unit tests to cover suggested hints, non-hints, and
--operand handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cli-engine/tests/foundation.rs | Adds integration-style tests asserting suggested hints (and no hints) for unknown commands, including -- operand behavior. |
| cli-engine/src/prompt.rs | Introduces the command-correction prompt API and tests for non-interactive behavior. |
| cli-engine/src/cli.rs | Replaces the prior unknown-group-command message path with structured detection + nearest-match suggestion and optional interactive correction/arg rewrite. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jpage-godaddy
approved these changes
Aug 25, 2026
jpage-godaddy
approved these changes
Aug 25, 2026
Merged
jpage-godaddy
pushed a commit
that referenced
this pull request
Aug 25, 2026
🤖 I have created a release *beep* *boop* --- <details><summary>cli-engine: 0.9.1</summary> ## [0.9.1](cli-engine-v0.9.0...cli-engine-v0.9.1) (2026-08-25) ### Features * **cli:** suggest the nearest command on engine-intercepted unknowns ([#104](#104)) ([0bfe701](0bfe701)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cli-engine intercepts unknown group commands before clap parses, to emit structured
unknown command "X" for "Y"errors. That early return bypasses clap's suggestion machinery — stock cli-engine gives no hint (e.g.gddy domian → unknown command "domian" for "gddy").This change adds nearest-match hints on that path for top-level and nested typos, same plain message for humans and agents. In an interactive TTY, an optional
Did you mean domain? (Y/n)prompt re-dispatches on accept. Agents, pipes, and non-TTY runs never prompt — they get the hint in the error and exit non-zero.Mistyped commands now point at the closest real command instead of just failing:
Testing
cli-engine local:
cargo fmt --checkcargo clippy --all-targets -- -D warnings(zero warnings)cargo test(foundation 290 + unit/integration suites)cargo doc -D warningshandling,
--operands, and interactive decline pathsIntegration against gddy:
domaon/domian→ suggestdomain;dm→ no hintdomian lst→did you mean "gddy domain list"?domain avaliable example.com→"gddy domain available example.com"domain lst→ suggestlist;domain xyzzy→ no hintdomain -- lst→ clap error, no hint (operand after--)yauto-runsgddy domain(exit 0);n→ error (exit 1)