Fix command detection false positives in line_starts_with_command#14
Conversation
…arts_with_command` to perform exact matching instead of prefix checking when scanning responses for valid commands. This ensures that normal words beginning with command names (e.g., \"catapult\", \".gitignore\") are not incorrectly parsed and executed as commands, significantly improving the accuracy and reliability of the auto-execute logic. Co-authored-by: insign <1113045+insign@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94b06d0f5d
ℹ️ 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 cmd == "./" || cmd == "/" || cmd == "~" { | ||
| first_word.starts_with(cmd) | ||
| } else { | ||
| first_word == cmd || first_word.starts_with(&format!("{cmd}-")) |
There was a problem hiding this comment.
Accept dotted command variants when matching starters
The new matcher only treats exact names or cmd-... as valid (first_word == cmd || first_word.starts_with("{cmd}-")), which regresses common versioned binaries that use dots, e.g. python3.11, php8.3, or node20.11. Before this change those were recognized via prefix matching; now line_starts_with_command returns false, so flatten_command_if_safe stops flattening otherwise valid multi-line command responses in these environments.
Useful? React with 👍 / 👎.
Fixes a critical bug where
line_starts_with_commandincorrectly identified sentences starting with words that partially match a command (such as "catapult" or ".gitignore") as shell commands.This was fixed by performing exact comparisons for standard commands, allowing
-suffixes (likeapt-getmatchingapt), and strictly matching specific path prefixes (./,/,~). This ensures natural language inputs or answers starting with words similar to commands are safely handled without unintended command injections. Tests were added to ensure behavior is correct.PR created automatically by Jules for task 8853274874295937706 started by @insign