Skip to content

fix(discover): don't rewrite find with compound predicates to rtk find - #2453

Closed
multicam wants to merge 1 commit into
rtk-ai:developfrom
multicam:fix/find-compound-predicate-no-rewrite
Closed

multicam wants to merge 1 commit into
rtk-ai:developfrom
multicam:fix/find-compound-predicate-no-rewrite

Conversation

@multicam

Copy link
Copy Markdown

Problem

rtk find doesn't implement GNU find's compound predicates/actions (-not, -o, -a, -and, -or, -exec, -execdir, -ok, -okdir, -prune, !). But the rewrite registry still rewrites them:

$ rtk rewrite 'find . -name "*.ts" -not -path "*/node_modules/*"'
rtk find . -name "*.ts" -not -path "*/node_modules/*"      # exit 3 (rewrite)

The rewritten command then fails:

$ rtk find . -name "*.ts" -not -path "*/node_modules/*"
rtk: rtk find does not support compound predicates or actions (e.g. -not, -exec). Use `find` directly.

So a perfectly valid find gets rewritten into something rtk refuses to run. Automated callers (coding agents using rtk as a PreToolUse rewrite hook) tend to retry the same rewritten form in a loop, since the rewrite is deterministic.

Fix

In rewrite_segment_inner, skip the rewrite when the target is rtk find and the command contains a compound predicate/action — let the original bare find run, which handles these natively. Plain finds (find . -name x) still rewrite to rtk find as before.

Modeled on the existing gh --json special-case in the same function.

Tests

Adds has_find_compound_predicate + 6 unit tests (each compound operator passes through; plain find still rewrites). cargo test registry → 294 passed.

…find`

`rtk find` does not implement GNU find's compound predicates/actions
(-not, -o, -a, -and, -or, -exec, -execdir, -ok, -okdir, -prune, `!`).
The rewrite registry currently turns e.g.

    find . -name '*.ts' -not -path '*/node_modules/*'

into

    rtk find . -name '*.ts' -not -path '*/node_modules/*'

which `rtk find` then rejects ("does not support compound predicates"),
so the command errors. Automated callers (coding agents) often retry the
same rewritten form in a loop.

Fix: in `rewrite_segment_inner`, skip the rewrite when the target is
`rtk find` and the command contains a compound predicate/action, so the
original bare `find` runs and the predicate works. Plain finds
(`find . -name x`) still rewrite as before.

Adds `has_find_compound_predicate` + 6 unit tests. `cargo test registry`:
294 passed.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@multicam
multicam force-pushed the fix/find-compound-predicate-no-rewrite branch from a9165e4 to 62ad6cf Compare June 19, 2026 00:27
kylehgc added a commit to kylehgc/rtk that referenced this pull request Jul 23, 2026
- Conflict list: drop rtk-ai#2579/rtk-ai#2590/rtk-ai#2615 (already flagged 07-17), add
  rtk-ai#2401/rtk-ai#2453 and the chunk-7 conflict cluster; note top-pick rtk-ai#2401 is
  a hand-port (issue #54).
- Next-wave: restore recovered candidate rtk-ai#2256 (gh prompt-injection
  scan) dropped in distillation.

Co-Authored-By: Claude Fable 5 <[email protected]>
@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot

Copy link
Copy Markdown
Contributor

Closing this pull request after a prolonged period of inactivity. If this is still relevant, please ask for it to be reopened. Thank you!

@rtk-release-bot rtk-release-bot Bot closed this Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants