Skip to content

Fix unknown command suggestions - #28

Open
Wenjunyun123 wants to merge 1 commit into
openai:mainfrom
Wenjunyun123:codex/fix-unknown-command-suggestions
Open

Fix unknown command suggestions#28
Wenjunyun123 wants to merge 1 commit into
openai:mainfrom
Wenjunyun123:codex/fix-unknown-command-suggestions

Conversation

@Wenjunyun123

Copy link
Copy Markdown

Summary:

  • Adds a maximum edit-distance threshold before suggesting a command for unknown input.
  • Keeps close typo suggestions while avoiding unrelated suggestions.
  • Adds regression coverage for close and distant unknown commands.

Testing:

  • git diff --check
  • Not run: go test ./pkg/cmd -run TestSuggestCommand because go is not installed in this local environment.

Fixes #16

AI assistance: This bug fix was prepared with AI assistance and reviewed before submission.

@Wenjunyun123
Wenjunyun123 requested a review from a team as a code owner June 26, 2026 03:05
@markstuart-oai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T01:31:41.999856Z 1b1ed62 Manual request
🔒 Security Review Completed 2026-09-06T01:31:13.754984Z 1b1ed62 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1b1ed626de

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b1ed626de

ℹ️ 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".

Comment thread pkg/cmd/suggest.go
// suggestCommand takes a list of commands and a provided string to suggest a
// command name
func suggestCommand(commands []*cli.Command, provided string) string {
const minSuggestionDistance = 0.75

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle single-edit typos for short commands

For the real run subcommand declared with suggestions enabled in pkg/cmd/finetuningalphagrader.go:17-20, omitting the middle character produces jaroWinkler("run", "rn") == 0.611, so this fixed threshold returns no suggestion even though the input is only one deletion away. The new filter therefore suppresses a close typo that the change is intended to preserve; the cutoff should account for short command lengths or use an edit-distance fallback.

Useful? React with 👍 / 👎.

Comment thread pkg/cmd/suggest.go
Comment on lines +117 to +118
if distance < minSuggestionDistance || len(lineage) == 0 {
return ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unrelated short inputs before suggesting

With the actual root command list, an unrelated invocation such as openai bar still passes this check because jaroWinkler("beta:threads", "bar") == 0.775: the short input's three characters match widely separated characters in the longer command, and the common b prefix boosts the score over the cutoff. As a result, the CLI still suggests beta:threads for clearly unrelated input, so the new regression test's two-command fixture does not establish that the production command set avoids the original false-positive behavior.

Useful? React with 👍 / 👎.

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

2 participants