Repository navigation
feat(discover): track passthrough git/cargo/pnpm subcommands - #889
FlorianBruniaux wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves rtk discover --all classification accuracy by treating common git/cargo/pnpm passthrough subcommands as “supported (passthrough)” instead of “unhandled”, aligning discover’s reporting with existing passthrough behavior in the CLI.
Changes:
- Extend discover regex patterns to include
git checkout|merge|rebase,cargo run|publish, andpnpm build|exec. - Mark those newly-covered subcommands as
RtkStatus::Passthroughin the rule registry. - Update/expand registry tests to validate classification and rewrite behavior for these commands, and update
CLAUDE.mddocs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/discover/rules.rs |
Expands patterns and sets passthrough status for newly tracked subcommands. |
src/discover/registry.rs |
Updates coverage tests and adds new classify/rewrite tests for the added passthrough subcommands. |
CLAUDE.md |
Documents supported ecosystems list. |
| // Verify that every CargoCommand variant except Other has a matching pattern | ||
| for subcmd in ["build", "test", "clippy", "check", "fmt", "run", "publish"] { | ||
| let cmd = format!("cargo {subcmd}"); |
There was a problem hiding this comment.
The test comment says this verifies every CargoCommand variant (except Other) has a matching pattern, but run/publish are not CargoCommands variants in src/main.rs (they route through CargoCommands::Other). Suggest rewording the comment/test name to describe “cargo subcommands we treat as supported in discover (including passthrough)” rather than referring to enum variants.
| fn test_registry_covers_all_git_subcommands() { | ||
| // Verify that every GitCommand subcommand has a matching pattern | ||
| for subcmd in [ | ||
| "status", "log", "diff", "show", "add", "commit", "push", "pull", "branch", "fetch", | ||
| "stash", "worktree", | ||
| "stash", "worktree", "checkout", "merge", "rebase", | ||
| ] { |
There was a problem hiding this comment.
The comment claims this loop covers every GitCommand subcommand, but checkout/merge/rebase are not GitCommands variants in src/main.rs (they go through GitCommands::Other). Consider rewording to avoid implying a 1:1 mapping with enum variants (e.g., “git subcommands covered by discover patterns, including passthrough”).
|
Hey @FlorianBruniaux Two possible issues to address, then ok for merge ! Misleading estimated_savings_pct for passthrough commandsThe new passthrough subcommands have no subcmd_savings entry, so registry.rs:148 falls back to the parent rule's savings_pct (70% for git, 80% for cargo/pnpm). This inflates the estimated savings token count displayed in rtk discover reports, even though passthrough commands provide no actual filtering. Line 140-141: savings = output_tokens * estimated_savings_pct / 100.0
Line 142: bucket.total_output_tokens += savings
If a user ran git checkout 493 times and each produced ~200 chars of output, that's 493 * (200/4) * 70% = ~17K phantom saved tokens added to the "rtk git" bucket total.The report does label these as "passthrough" in the Status column, so users can distinguish them from filtered commands, but the inflated token estimate is still misleading. Note: This is a pre-existing design gap (e.g. cargo fmt already has the same issue, marked Passthrough but inherits 80%). Could you fix this in this PR so we do not extend this issue more ? missing rewrite end-to-end testsThe PR adds 7 classification tests but only 4 rewrite tests. Missing:
|
Fix estimated_savings_pct=0 for passthrough, add missing rewrite tests. Signed-off-by: Florian BRUNIAUX <[email protected]>
981f561 to
4296fe0
Compare
Summary
rtk discover --allreportsgit checkout,git merge,git rebase,pnpm build,pnpm exec,cargo run, andcargo publishas TOP UNHANDLED COMMANDS — even though they already work via passthrough handlers (GitCommands::Other,CargoCommands::Other,PnpmCommands::Other).The discover regex patterns in
src/discover/rules.rsdidn't include these subcommands, so they appeared unhandled instead of "already tracked, passthrough mode".Changes
src/discover/rules.rs: addcheckout|merge|rebaseto git pattern,run|publishto cargo pattern,build|execto pnpm pattern. Mark each asRtkStatus::Passthroughinsubcmd_status.src/discover/registry.rs: update existing coverage tests + 11 new tests (7 classify + 4 rewrite end-to-end).CLAUDE.md: cherry-pick supported ecosystems line fromfeature/help-reorganizeto fix pre-push validation.Impact
1277 commands correctly classified in discover output. Zero filtering changes, zero performance impact.
Closes #888
Test plan
cargo fmt --all— cleancargo clippy --all-targets— 0 errors, 2 pre-existing warningscargo test --all— 1134 passed, 3 ignoredrtk rewrite "git checkout main"→rtk git checkout main✓rtk rewrite "cargo run -- verify"→rtk cargo run -- verify✓rtk rewrite "pnpm build"→rtk pnpm build✓bash scripts/validate-docs.sh— passed🤖 Generated with Claude Code