fix: suppress misleading "Did you mean" suggestions - #17
anmarhindi wants to merge 2 commits into
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d33f1b3c9d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if provided == "" { | ||
| return "" | ||
| } | ||
| distance := suggestionThreshold |
There was a problem hiding this comment.
Preserve suggestions for short command typos
For short command names, a normal one-character omission can score below this fixed threshold because the Jaro match window becomes zero. For example, openai fine-tuning:alpha:graders rn compares rn with the real run subcommand at only 0.611, while validate scores 0, so this change returns no suggestion even though the previous implementation unambiguously suggested run. Use a length-sensitive threshold or an edit-distance exception so ordinary typos of short commands are not suppressed.
Useful? React with 👍 / 👎.
saioai
left a comment
There was a problem hiding this comment.
requesting changes. short typos like rn and rnu still lose the correct run suggestion. please preserve those hints and add tests using the real command tree.
Summary
suggestCommandpreviously printed a suggestion for every unknown subcommand, even when the best jaro-winkler match was barely related. Two visible failure modes:Add a minimum similarity threshold below which
suggestCommandreturns"". The upstreamurfave/clierror formatter already omits the suggestion clause when the function returns an empty string, so the user just seesNo help topic for 'X'.cleanly.After
Why 0.7
I measured jaro-winkler scores against the real top-level commands. Real typos score 0.78-1.00 (e.g.
creat->create= 0.97,comp->completions= 0.87,lst->list= 0.93). Unrelated input scores at most 0.557 (totallybogus->completions). A threshold of 0.7 sits in the gap, and conveniently matches the existingboostThresholdconstant insidejaroWinkleritself — the prefix boost only kicks in past 0.7, so it's a natural "plausibly the same word" cutoff.Verification
go test ./pkg/cmd/ -run TestSuggest— new table-driven coverage of close typos, exact matches, unrelated input, low-similarity input, empty input, and empty command lists.Closes #16