fix(discover): add cargo nextest to rewrite rule#2122
Open
maxmilian wants to merge 1 commit into
Open
Conversation
b8a57c9 to
f8bc08e
Compare
`rtk cargo nextest` is implemented in src/cmds/rust/cargo_cmd.rs with
dedicated filtered output, but the discover rewrite pattern only matched
`cargo (build|test|clippy|check|fmt|install)`. The Claude Code hook
therefore never rewrote `cargo nextest` calls, so users invoking nextest
directly received raw output instead of RTK's compact summary.
Changes:
- Add `nextest` to the cargo pattern alternation in src/discover/rules.rs
- Register `("nextest", 90.0)` in subcmd_savings (matches `test`, since
both filters collapse to a one-line pass/fail summary)
- Add classify + rewrite + with-args tests in src/discover/registry.rs
- Update `test_registry_covers_all_cargo_subcommands` to include
`install` and `nextest` (the loop had drifted out of sync with the
CargoCommand enum when `Install` was added previously)
Closes rtk-ai#2046
f8bc08e to
226b676
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk rewrite \"cargo nextest run\"previously returned exit 1 ("no RTK equivalent"), so the Claude Code hook never rewrotecargo nextestcalls even thoughrtk cargo nextestis fully implemented insrc/cmds/rust/cargo_cmd.rswith a dedicated 90%-savings filter.Root cause
src/discover/rules.rs:47— the cargo rule's pattern alternation only matched(build|test|clippy|check|fmt|install).nextestwas missing, soRegexSetnever matchedcargo nextest …andclassify_commandfell through toUnsupported.Fix
nextestto the alternation:^cargo\s+(build|test|clippy|check|fmt|install|nextest).(\"nextest\", 90.0)insubcmd_savings, matchingtest(both filters reduce to a one-line pass/fail summary, seefilter_cargo_nextestinsrc/cmds/rust/cargo_cmd.rs:583).rewrite_prefixesorsubcmd_status—nextestreuses cargo's existing prefix and isExisting(not passthrough).Tests
cargo fmt --all --check— cleancargo clippy --all-targets— 0 warningscargo test --all— 1948 passed, 0 failed (2 new tests included)src/discover/registry.rs:test_classify_cargo_nextest—cargo nextest run→Supported { rtk_equivalent: \"rtk cargo\", category: \"Cargo\", estimated_savings_pct: 90.0, status: Existing }test_rewrite_cargo_nextest—cargo nextest run→rtk cargo nextest runrtk rewrite \"cargo nextest run\"→ empty output, EC=1rtk rewrite \"cargo nextest run\"→rtk cargo nextest run, EC=3 (matchescargo test/cargo buildbaseline; reporter's expected EC=0 was a minor misstatement — EC=3 is RTK's normal "rewrite suggested" status)Scope
src/cmds/rust/cargo_cmd.rs— the nextest filter already exists and is reachable asrtk cargo nextestonce routed via Clap.rewrite_prefixes(cargo invocations always start with literalcargo; no aliases needed).