Skip to main content

Module rtk

Module rtk 

Source
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 rtk

Structs§

RtkMetrics
Aggregate RTK metrics across all command executions
RtkResult
Result of RTK command rewriting
RtkTracker
Thread-safe metrics tracker
TokenSavings
Token savings for a single command execution

Constants§

RTK_NOT_INSTALLED_HELP
User-facing guidance shown by /rtk only 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.