Repository navigation
fix(find): support multiple path arguments - #2894
davidalecrim1 wants to merge 3 commits into
Conversation
rtk find silently searched only the first path argument, dropping matches from any additional paths with no warning (rtk-ai#2839). This made rtk unsafe as a PreToolUse hook filter, since an agent could be told a file "does not exist" when it only existed under a dropped path. Both parse_native_find_args and parse_rtk_find_args now collect all leading positional arguments as paths, and run() walks every given root via a single WalkBuilder. Display paths are stripped relative to the root only when a single path is given (unchanged behavior); multiple roots keep their prefix so results from different roots don't collide. Duplicate path arguments are preserved (not deduped), matching native find's behavior.
Searching the same root twice wastes a walk and produces misleading duplicate results in the output, which runs counter to rtk's goal of keeping filtered output compact and unambiguous. Deduping before building the walker also means a single remaining root is displayed root-relative, same as any other single-path search.
|
Thanks for digging into the multi-path case. rtk find changed shape in #3603 (merged 2026-08-26): it dispatches on find's own grammar, and anything outside the single-path subset it walks itself, including |
Summary
rtk findsilently searched only the first path argument, dropping matches from any additional paths with no warning or error ([BUG] find with multiple path arguments silently searches only the first path #2839). This made it unsafe as a PreToolUse hook filter, since an agent could be told a file "does not exist" when it only existed under a dropped path.find path1 path2 -name ...) and RTK-shorthand (find <pattern> path1 path2 ...) syntaxes now collect all leading path arguments, andrun()walks every given root through a singleWalkBuilder.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testrtk find pathA pathB -name "*.txt"inspected, confirmed matches from both paths; confirmed single-path output format unchanged; confirmed a repeated path argument (rtk find a a -name "*.txt") dedups to a single match