Repository navigation
feat(git): add ls-files filter grouping tracked files by directory - #2943
AnayGarodia wants to merge 1 commit into
Conversation
git ls-files enumerates every tracked path and passed through raw, so large repos emit thousands of lines. Group the listing into per-directory counts with a total and an overflow hint (~87% fewer tokens on this repo), following the directory-grouping precedent in find_cmd. Flag-aware per the design philosophy: shape-changing flags (-z, -s/--stage, -t, -u, --debug, --eol, --error-unmatch, --format) pass through untouched, and small listings are returned unchanged. Guarded by never_worse so output is never larger than raw. Closes rtk-ai#2940
|
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. |
|
Closing this as a duplicate of #1927, which adds the same Run on this branch at e391bfa, on rtk's own repo (798 tracked files), through Your captured |
Closes #2940.
What
Adds a
git ls-fileshandler that groups the tracked-file listing into per-directory counts instead of passing thousands of raw paths straight through.Example on this repo (398 tracked files):
That's ~87% fewer tokens, well past the 60% bar.
Why
rtk discoverflagsgit ls-filesunder TOP UNHANDLED COMMANDS. Agents run it to enumerate tracked paths, and in large repos the output is long and highly repetitive — the same shapefindalready compresses.How
GitCommand::LsFileshandler insrc/cmds/git/git.rs, registered in the clapGitCommandsenum and the discover rule so the hook rewritesgit ls-files→rtk git ls-files.group_ls_filescollapses the listing to a total plus onedir/ countline per directory (most files first), capped with an overflow hint so nothing is lost. Directory grouping follows the existingfind_cmdprecedent. @inktomi confirmed this format on the issue.-z,-s/--stage,-t,-u,--debug,--eol,--error-unmatch,--format) pass through untouched, and small listings are returned unchanged. Guarded bynever_worse, so output is never larger than raw.Tests
Three unit tests in the git module using a real
git ls-filesfixture: directory grouping + >=60% savings, small-listing passthrough, and shape-flag detection.cargo fmt --all && cargo clippy --all-targets && cargo test --allall pass.One open question: I sorted directories by file count (most first) rather than alphabetically, since the biggest directories are usually what the agent cares about. Easy to switch to alphabetical if you'd prefer it match
find's ordering.