Skip to content

fix(discover): reclassify universal-passthrough git subcommands and flag pre-hook nature - #1979

Closed
YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:fix/discover-post-hook-command
Closed

YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:fix/discover-post-hook-command

Conversation

@YOMXXX

@YOMXXX YOMXXX commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Three related `rtk discover` issues are partially addressed in this PR.

Fixed (#1897): `git checkout / clone / remote / reset / merge / rebase / restore / switch / tag / init / clean / cherry-pick / revert / bisect / grep / blame / …` (~30 subcommands) were misclassified as `Unsupported` and surfaced in the "missed savings" list, even though RTK proxies them transparently via the universal git passthrough. The git rule now matches those subcommands with `RtkStatus::Passthrough`.

Mitigated (#1973 / #1929): `rtk discover` parses Claude Code session transcripts, which record the pre-hook form of each Bash command (what the assistant originally proposed), not the post-hook form (what the RTK `PreToolUse` hook rewrote it to and what actually executed). When the hook is installed and active, the "Already using RTK" headline understates true adoption because hook-rewritten commands still appear in transcripts as their original form.

A full fix would require either Claude Code logging the post-hook `updatedInput` in transcripts, or RTK shadowing transcripts against its own audit log — both out of scope here. This PR provides a stopgap:

  • `discover` `--help` docstring explicitly explains the pre-hook nature and points users to `rtk gain --history` for executed-command data.
  • When the RTK `PreToolUse` hook is detected as installed, the report prepends a `Note:` warning the reader to cross-reference `rtk gain --history`.

Reproduction

```bash

Before

rtk discover

Output included e.g.:

git checkout main 50 rtk git - ~3500

(false positive: passthrough, not missed savings)

After

rtk discover

git checkout is classified as Passthrough (Supported) and does

not contribute to the "missed savings" total.

Plus, when the RTK hook is installed:

Note: RTK PreToolUse hook detected; transcripts capture the

pre-hook (assistant-proposed) command...

```

Behavior changes

  • The "Missed Savings" list shrinks for projects that use the previously-unsupported git subcommands.
  • Reports now display a note explaining the pre-hook caveat when a hook is detected.
  • No flag changes; no schema changes.

Test plan

  • `test_classify_git_checkout_is_supported_passthrough` — passthrough status, no longer "Unsupported".
  • `test_classify_git_clone_is_supported_passthrough`.
  • `test_classify_git_remote_is_supported_passthrough`.
  • `test_classify_git_reset_is_supported_passthrough`.
  • All 383 existing `discover` tests still pass.
  • `cargo fmt --all` clean.
  • `cargo clippy --all-targets` zero warnings.
  • `cargo test --bin rtk -- --test-threads=8` 1905 passed, 0 failed.

Out of scope (deferred)

Fixes #1897
Refs #1973, #1929

…lag pre-hook nature

Three discover issues are partially addressed here.

Issue rtk-ai#1897: git subcommands like checkout / clone / remote / reset
were misclassified as 'Unsupported' (so they appeared in the missed
savings list), even though RTK proxies them transparently via the
universal git passthrough. The git rule's pattern now matches those
plus ~20 other commonly-used subcommands, and each new entry is
marked with RtkStatus::Passthrough so the dashboard surfaces them as
supported-but-not-shrinking rather than as missed opportunities.

Issues rtk-ai#1973 / rtk-ai#1929: 'rtk discover' parses Claude Code session
transcripts, which record the PRE-hook form of every Bash command --
i.e. what the assistant originally proposed, not what actually
executed after the PreToolUse hook rewrote it. When the RTK hook is
present and active, the 'Already using RTK' headline understates true
adoption because hook-rewritten commands still appear in transcripts
as their original form.

A full fix requires either Claude Code logging the post-hook
updatedInput in transcripts, or RTK shadowing transcripts against
its own audit log; both are out of scope here. As a stopgap:
- discover --help docstring explicitly explains the pre-hook nature
  and points users to 'rtk gain --history' for executed-command data.
- When the RTK PreToolUse hook is detected as installed, the report
  prepends a 'Note:' that warns the reader to cross-reference 'rtk
  gain --history'.

Four new tests assert that git checkout / clone / remote / reset are
classified as Supported + Passthrough (not Unsupported).

Refs rtk-ai#1973, rtk-ai#1929
Fixes rtk-ai#1897
@rtk-release-bot

Copy link
Copy Markdown
Contributor

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.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@rtk-release-bot

Copy link
Copy Markdown
Contributor

Closing this pull request after a prolonged period of inactivity. If this is still relevant, please ask for it to be reopened. Thank you!

@rtk-release-bot rtk-release-bot Bot closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk discover: false positives for git subcommands (checkout, clone, remote)

1 participant