Expand description
RTK (Rust Token Killer) integration module
This module provides token-saving functionality by filtering and compressing
bash command outputs before they reach the LLM context. It wraps the rtk
CLI binary to achieve 60-90% token savings on common development commands.
§Features
- Command rewriting via
rtk rewrite - Stats extraction (git diff, cargo build, etc.)
- Error-only mode for test runs
- Output grouping and deduplication
- Structure-only mode for JSON/data files
§Usage
Enable with the rtk feature flag:
cargo run --features rtkStructs§
- RtkMetrics
- Aggregate RTK metrics across all command executions
- RtkResult
- Result of RTK command rewriting
- RtkTracker
- Thread-safe metrics tracker
- Token
Savings - Token savings for a single command execution
Constants§
- RTK_
NOT_ INSTALLED_ HELP - User-facing guidance shown by
/rtkonly when the auto-download itself failed (no network, GitHub unreachable, unsupported platform). The happy path installs RTK silently on first use, so this is the rare failure note.
Functions§
- global_
tracker - Get the global RTK tracker instance
- is_
rtk_ available - Check if the rtk binary is available (bundled, in PATH, or auto-downloaded). Async + cached.
- rewrite_
command - Rewrite a bash command to use RTK as a proxy.
- warm_up
- Resolve RTK in the background at startup (triggering the first-use auto-download if needed) so the first bash command never blocks on it.