discover: add output-size logging to fallback path for accurate missed-savings estimates
#2,130 创建于 2026年5月27日
仓库指标
- Star
- (48,085 star)
- PR 合并指标
- (平均合并 11天 1小时) (30 天内合并 45 个 PR)
描述
Problem
rtk discover estimates missed savings by matching command names against known RTK handlers. This produces false positives for commands that RTK handles but can't profitably compress — because the output is already small.
Example: 91 git push calls were flagged as ~5.8K tokens saveable. In practice, git push output is typically 1-3 lines (Everything up-to-date, or a brief ref update). RTK correctly falls back with 0% savings. No tokens were actually wasted.
The core issue: discover has no way to distinguish:
grepthat returned 3 lines (no real savings possible)grepthat returned 3,000 lines (real savings missed)
Proposed fix
Add output-size logging to the fallback path. When RTK decides not to compress a command result, record the output token/byte count alongside the fallback event.
rtk discover (or a new rtk discover --accurate mode) could then surface only fallbacks where output exceeded a meaningful threshold — these are the genuine missed opportunities where context is being wasted.
What this enables
A reliable answer to: "are there commands producing large output that RTK isn't compressing?" — the actual question users care about. The current heuristic answers a different question ("does RTK have a handler for this command name?") that doesn't map to real context waste.
Current workaround
None. Users have to manually test commands or check rtk gain --history to identify false positives after the fact.