From b2768d1c10e95ebfe1a9da5112a7c7707d9bbfd8 Mon Sep 17 00:00:00 2001 From: Ryan Duguid Date: Fri, 30 Oct 2026 20:10:25 +1100 Subject: [PATCH 1/2] fix(rewrite): stop rewriting yadm to rtk git yadm manages a separate dotfiles repository, so rewriting its subcommands to rtk git ran git on whatever project the shell was in. Remove yadm from the git rule; the yadm filter already routes it to the yadm binary as rtk yadm. Adapted from kylehgc/rtk 1d672725 by RawNuke (Apache-2.0), including the rule change and tests. Its bare git add change is not included. See rtk-ai/rtk#3408. --- README.md | 1 + src/discover/registry.rs | 37 ++++++++++++++++++++++++++----------- src/discover/rules.rs | 7 +++++-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3c8841e9db..1a9c02b790 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Each change has a regression test, except `grep_max_results`. | `git diff` | Shown verbatim up to `agent_output_max_chars`. Above it, a compacted diff or show ends with `[full output: rtk recall ]`, or `[full diff: rtk git diff --no-compact]` when recall cannot store it. | | `rtk read` | Exact line ranges, and a missing-file error worded as `cat` words it. | | `gh api` | GitHub API `*_url` links are dropped, with the whole response kept for `rtk recall`. Anything left unfiltered is written back byte for byte, and `--jq` and `--template` are untouched. | +| `yadm` | Never rewritten to `rtk git`, which would run git on the current project instead of yadm's dotfiles repository. It goes through `rtk yadm`. From [kylehgc/rtk](https://github.com/kylehgc/rtk/commit/1d672725f8cf9d43da32212310dd7abb5bca814d) by RawNuke (Apache-2.0); see [rtk-ai/rtk#3408](https://github.com/rtk-ai/rtk/issues/3408). | | `rtk gain` | The summary, per-command and daily, weekly and monthly tables count an oversised row at a fixed 7,500-token cap, and the headline figure is net. | Generally useful fixes are offered upstream as draft pull requests, listed in [FORKS.md](https://github.com/EquityBot/EquityBot/blob/main/FORKS.md). diff --git a/src/discover/registry.rs b/src/discover/registry.rs index edff9b0775..7af278bd5e 100644 --- a/src/discover/registry.rs +++ b/src/discover/registry.rs @@ -3033,13 +3033,12 @@ mod tests { #[test] fn test_classify_yadm_status() { + // yadm manages a separate dotfiles repository; it must never be + // rewritten to `rtk git`, which would act on the current project. assert_eq!( classify_command("yadm status"), - Classification::Supported { - rtk_equivalent: "rtk git", - category: "Git", - estimated_savings_pct: 70.0, - status: RtkStatus::Existing, + Classification::Unsupported { + base_command: "yadm status".to_string(), } ); } @@ -3048,20 +3047,36 @@ mod tests { fn test_classify_yadm_diff() { assert_eq!( classify_command("yadm diff"), - Classification::Supported { - rtk_equivalent: "rtk git", - category: "Git", - estimated_savings_pct: 80.0, - status: RtkStatus::Existing, + Classification::Unsupported { + base_command: "yadm diff".to_string(), } ); } #[test] fn test_rewrite_yadm_status() { + // Regression for rtk-ai/rtk#3408: yadm subcommands must route through + // the yadm filter to the yadm binary, never to git in the current + // directory. Tests adapted from kylehgc/rtk 1d672725 by RawNuke (Apache-2.0). assert_eq!( rewrite_command_no_prefixes("yadm status", &[]), - Some("rtk git status".to_string()) + Some("rtk yadm status".to_string()) + ); + } + + #[test] + fn test_rewrite_yadm_commit() { + assert_eq!( + rewrite_command_no_prefixes("yadm commit -m x", &[]), + Some("rtk yadm commit -m x".to_string()) + ); + } + + #[test] + fn test_rewrite_yadm_add() { + assert_eq!( + rewrite_command_no_prefixes("yadm add .", &[]), + Some("rtk yadm add .".to_string()) ); } diff --git a/src/discover/rules.rs b/src/discover/rules.rs index 976d5abf8f..467626f925 100644 --- a/src/discover/rules.rs +++ b/src/discover/rules.rs @@ -58,10 +58,13 @@ impl Default for RtkRule { /// `core::tracking::SUBCOMMAND_ROUTERS`, or its telemetry label stops at the tool name. pub const RULES: &[RtkRule] = &[ RtkRule { - pattern: r"^(?:git|yadm)\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|checkout|push|pull|branch|fetch|stash|worktree)(?:\s|$|[;|&()<>])", + // yadm stays out of this rule: `rtk git` would run git on the current + // project, not yadm's dotfiles repository. Change adapted from + // kylehgc/rtk 1d672725 by RawNuke (Apache-2.0); see rtk-ai/rtk#3408. + pattern: r"^git\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|checkout|push|pull|branch|fetch|stash|worktree)(?:\s|$|[;|&()<>])", rtk_cmd: "rtk git", pipeline_safety: PipelineSafety::ProducerOnly, - rewrite_prefixes: &["git", "yadm"], + rewrite_prefixes: &["git"], category: "Git", savings_pct: 70.0, subcmd_savings: &[ From 3addb530d398532b2cc77ea3a9232584ea8c88d4 Mon Sep 17 00:00:00 2001 From: Ryan Duguid Date: Fri, 30 Oct 2026 21:26:56 +1100 Subject: [PATCH 2/2] docs: state what the yadm change covers Say yadm left the git rewrite rule rather than claiming it can never be rewritten, and that discover lists it as unhandled like other commands with only a TOML filter. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a9c02b790..fa2e59f898 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Each change has a regression test, except `grep_max_results`. | `git diff` | Shown verbatim up to `agent_output_max_chars`. Above it, a compacted diff or show ends with `[full output: rtk recall ]`, or `[full diff: rtk git diff --no-compact]` when recall cannot store it. | | `rtk read` | Exact line ranges, and a missing-file error worded as `cat` words it. | | `gh api` | GitHub API `*_url` links are dropped, with the whole response kept for `rtk recall`. Anything left unfiltered is written back byte for byte, and `--jq` and `--template` are untouched. | -| `yadm` | Never rewritten to `rtk git`, which would run git on the current project instead of yadm's dotfiles repository. It goes through `rtk yadm`. From [kylehgc/rtk](https://github.com/kylehgc/rtk/commit/1d672725f8cf9d43da32212310dd7abb5bca814d) by RawNuke (Apache-2.0); see [rtk-ai/rtk#3408](https://github.com/rtk-ai/rtk/issues/3408). | +| `yadm` | Removed from the `git` rewrite rule, which would run git on the current project instead of yadm's dotfiles repository. It goes through `rtk yadm`, and `rtk discover` lists it as unhandled, as it does `jq` and other commands with only a TOML filter. From [kylehgc/rtk](https://github.com/kylehgc/rtk/commit/1d672725f8cf9d43da32212310dd7abb5bca814d) by RawNuke (Apache-2.0); see [rtk-ai/rtk#3408](https://github.com/rtk-ai/rtk/issues/3408). | | `rtk gain` | The summary, per-command and daily, weekly and monthly tables count an oversised row at a fixed 7,500-token cap, and the headline figure is net. | Generally useful fixes are offered upstream as draft pull requests, listed in [FORKS.md](https://github.com/EquityBot/EquityBot/blob/main/FORKS.md).