fix(discover): exclude hook-rewritten commands from missed savings (#1055)#1195
Open
ousamabenyounes wants to merge 1 commit into
Open
fix(discover): exclude hook-rewritten commands from missed savings (#1055)#1195ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
Collaborator
📊 Automated PR Analysis
SummaryFixes the discover command incorrectly reporting hook-rewritten commands (e.g. git diff, cargo test) as 'missed savings' when the Claude Code PreToolUse hook is active. The fix detects hook status before scanning, routes hook-handled commands to a separate counter, and displays them as 'Hook-handled' in output. Also fixes git log --format output truncation that was corrupting programmatic output like SHAs. Review Checklist
Linked issues: #1055 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
58ffaf5 to
95fbce1
Compare
…tk-ai#1055) When the Claude Code PreToolUse hook (rtk-rewrite.sh) is active, it silently rewrites commands like `git diff` → `rtk git diff` before execution. The JSONL session log records the original command, so `rtk discover` classified all these as "missed savings" — even though the hook was already handling them. Fix: before the scan loop, detect hook status via hook_check::status(). When the hook is active, each Supported command is tested against rewrite_command(); if it would be rewritten, it is counted in a new hook_rewritten_count bucket instead of the missed-savings bucket. The report now shows a "Hook-handled: N commands" line so users understand the hook is doing its job. Generated by Claude Code Vibe coded by ousamabenyounes Co-Authored-By: Claude <noreply@anthropic.com>
95fbce1 to
7932d14
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
Fixes #1055
PreToolUsehook is active,rtk discoverwas reporting hook-rewritten commands (e.g.git diff,cargo test) as "missed savings" — even though the hook was already rewriting them tortk git diff,rtk cargo test, etc.git diffand classified it asSupported (missed).hook_check::status(); when active, test eachSupportedcommand withrewrite_command(). If the hook would rewrite it, count it ashook_rewritten(excluded from missed-savings) and show aHook-handled: N commandsline in the output.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testtest_supported_git_commands_are_rewriteable_by_hook,test_supported_cargo_commands_are_rewriteable_by_hook,test_hook_rewritten_count_shown_when_nonzero,test_hook_rewritten_count_hidden_when_zerortk discoveroutput now shows "Hook-handled: N commands" instead of listing them as missed savings when the hook is installedFiles changed
src/discover/mod.rssrc/discover/report.rshook_rewritten_count/hook_rewritten_tokenstoDiscoverReport; show in text outputsrc/discover/registry.rsCHANGELOG.mdGenerated by Ora Studio
Vibe coded by ousamabenyounes
Vibe Coded by Ousama Ben Younes
Developed With Ora Studio (Claude Code)