feat(help): fuzzy "Did you mean?" suggestions for command typos#516
Merged
Conversation
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Telemetry
Other
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1049 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.77% 95.77% —%
==========================================
Files 180 180 —
Lines 24767 24822 +55
Branches 0 0 —
==========================================
+ Hits 23720 23773 +53
- Misses 1047 1049 +2
- Partials 0 0 —Generated by Codecov Action |
Add fuzzy matching to resolveCommandPath() so that top-level command
typos (e.g. `sentry isseu`) and subcommand typos via help (e.g.
`sentry help issue lis`) now show "Did you mean: issue?" suggestions
instead of a bare "Command not found" error.
This closes the gap where `defaultCommand: "help"` in app.ts routes
unrecognized words to the help command, bypassing Stricli's built-in
Damerau-Levenshtein fuzzy matching.
- Add UnresolvedPath type to introspect.ts with fuzzy suggestions
- Use fuzzyMatch() at both top-level and subcommand resolution levels
- Update HelpJsonResult to include optional `suggestions` array
- Surface suggestions in human output ("Did you mean: X?") and JSON
- Add formatSuggestionList() with Oxford-comma grammar
029bd70 to
c29fe0c
Compare
5 tasks
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.
Top-level command typos like
sentry isseunow show "Did you mean: issue?" suggestions instead of a bare "Command not found" error.Problem
defaultCommand: "help"inapp.tsroutes unrecognized top-level words to the help command, bypassing Stricli's built-in Damerau-Levenshtein fuzzy matching. Subcommand typos (sentry issue lis) and flag typos (--limt) already get suggestions via Stricli, but top-level command typos andsentry help <typo>did not.Solution
Add fuzzy matching to
resolveCommandPath()inintrospect.tsusing the existingfuzzyMatch()utility. When a path segment doesn't match any route, return anUnresolvedPathwith up to 3 fuzzy-matched suggestions.Before
After
JSON output includes a structured
suggestionsarray for machine consumers.Changes
introspect.ts:UnresolvedPathtype + fuzzy fallback at both top-level and subcommand resolutionhelp.ts: Surface suggestions in human output and JSON;formatSuggestionList()with Oxford-comma grammar