Skip to content

Comments

fix(registry): fi in IGNORED_PREFIXES shadows find commands#246

Open
hoklims wants to merge 1 commit intortk-ai:masterfrom
hoklims:fix/ignored-fi-blocks-find
Open

fix(registry): fi in IGNORED_PREFIXES shadows find commands#246
hoklims wants to merge 1 commit intortk-ai:masterfrom
hoklims:fix/ignored-fi-blocks-find

Conversation

@hoklims
Copy link

@hoklims hoklims commented Feb 21, 2026

Summary

  • "fi" (shell keyword for ending if blocks) was listed as a bare string in IGNORED_PREFIXES
  • "find".starts_with("fi") is true, so all find commands were classified as Ignored
  • This meant rtk rewrite "find ..." always returned exit 1 (no rewrite), making the hook system unable to intercept find commands
  • Same issue affected "done" which could shadow hypothetical commands starting with done

Fix

  • Move "fi" and "done" from IGNORED_PREFIXES to IGNORED_EXACT (exact match only)
  • Both copies of these constants in registry.rs are fixed
  • Added 3 regression tests: find is now Supported, bare fi and done remain Ignored

Root cause analysis

IGNORED_PREFIXES check (line ~310):
  for prefix in IGNORED_PREFIXES {
      if trimmed.starts_with(prefix) {  // "find ...".starts_with("fi") == true!
          return Classification::Ignored;
      }
  }
  // Never reaches REGEX_SET matching for find commands

Other shell keywords like then, else, do already used the "keyword\n" / "keyword " suffix pattern to avoid this. fi and done were the only bare entries without a trailing delimiter.

Test plan

  • cargo test — 416 passed, 0 failed
  • rtk rewrite "find . -name foo"rtk find . -name foo (was exit 1 before)
  • rtk rewrite "git status"rtk git status (no regression)
  • rtk rewrite "ls -la"rtk ls -la (no regression)

Partially fixes #170, #204, #236 — those issues reported find failures due to flag syntax mismatch, but the deeper blocker was that find was never classified as supported in the first place.

The shell keyword "fi" was listed as a bare prefix in IGNORED_PREFIXES,
causing classify_command("find ...") to return Ignored because
"find".starts_with("fi") is true. This prevented find commands from
being rewritten by rtk rewrite and the hook system.

Move "fi" and "done" from IGNORED_PREFIXES to IGNORED_EXACT so they
only match as exact standalone keywords, not as prefixes of other
commands.

Fixes rtk-ai#170, rtk-ai#204, rtk-ai#236 (partially — find classification was the root
blocker for rtk rewrite).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 21, 2026 23:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a command-classification bug in the discovery registry where shell keywords in the ignored prefix list caused unrelated commands (notably find) to be incorrectly classified as Ignored, preventing rewrite/hook interception.

Changes:

  • Moves fi and done from IGNORED_PREFIXES (prefix match) to IGNORED_EXACT (exact match) to avoid shadowing commands like find.
  • Adds regression tests ensuring find ... is classified as Supported while bare fi / done remain Ignored.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

bug: rtk-rewrite.sh doesn't translate POSIX find arguments to rtk find syntax

1 participant