Skip to content

fix: suppress misleading "Did you mean" suggestions#17

Open
anmarhindi wants to merge 1 commit into
openai:mainfrom
anmarhindi:fix-suggest-threshold
Open

fix: suppress misleading "Did you mean" suggestions#17
anmarhindi wants to merge 1 commit into
openai:mainfrom
anmarhindi:fix-suggest-threshold

Conversation

@anmarhindi
Copy link
Copy Markdown

Summary

suggestCommand previously printed a suggestion for every unknown subcommand, even when the best jaro-winkler match was barely related. Two visible failure modes:

$ openai responses zzzzz
No help topic for 'zzzzz'. Did you mean ''?

$ openai totallybogus
No help topic for 'totallybogus'. Did you mean 'openai completions'?

Add a minimum similarity threshold below which suggestCommand returns "". The upstream urfave/cli error formatter already omits the suggestion clause when the function returns an empty string, so the user just sees No help topic for 'X'. cleanly.

After

$ openai responses zzzzz
No help topic for 'zzzzz'

$ openai totallybogus
No help topic for 'totallybogus'

$ openai responses creat
No help topic for 'creat'. Did you mean 'openai responses create'?

$ openai chat:completion
No help topic for 'chat:completion'. Did you mean 'openai chat:completions'?

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 existing boostThreshold constant inside jaroWinkler itself — 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.
  • Manually exercised the four cases above against a freshly built binary.

Closes #16

@anmarhindi anmarhindi requested a review from a team as a code owner May 14, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unknown-command suggestions are empty or misleading

1 participant