Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions hooks/antigravity-rtk-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# RTK - Rust Token Killer (Google Antigravity)

**Usage**: Token-optimized CLI proxy for shell commands.

## Rule

Always prefix shell commands with `rtk` to minimize token consumption.

Examples:

```bash
rtk git status
rtk cargo test
rtk ls src/
rtk grep "pattern" src/
rtk find "*.rs" .
rtk docker ps
rtk gh pr list
```

## Meta Commands

```bash
rtk gain # Show token savings
rtk gain --history # Command history with savings
rtk discover # Find missed RTK opportunities
rtk proxy <cmd> # Run raw (no filtering, for debugging)
```

## Why

RTK filters and compresses command output before it reaches the LLM context, saving 60-90% tokens on common operations. Always use `rtk <cmd>` instead of raw commands.
32 changes: 32 additions & 0 deletions hooks/kilocode-rtk-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# RTK - Rust Token Killer (Kilo Code)

**Usage**: Token-optimized CLI proxy for shell commands.

## Rule

Always prefix shell commands with `rtk` to minimize token consumption.

Examples:

```bash
rtk git status
rtk cargo test
rtk ls src/
rtk grep "pattern" src/
rtk find "*.rs" .
rtk docker ps
rtk gh pr list
```

## Meta Commands

```bash
rtk gain # Show token savings
rtk gain --history # Command history with savings
rtk discover # Find missed RTK opportunities
rtk proxy <cmd> # Run raw (no filtering, for debugging)
```

## Why

RTK filters and compresses command output before it reaches the LLM context, saving 60-90% tokens on common operations. Always use `rtk <cmd>` instead of raw commands.
43 changes: 43 additions & 0 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const OPENCODE_PLUGIN: &str = include_str!("../hooks/opencode-rtk.ts");
const RTK_SLIM: &str = include_str!("../hooks/rtk-awareness.md");
const RTK_SLIM_CODEX: &str = include_str!("../hooks/rtk-awareness-codex.md");

const KILOCODE_RULES: &str = include_str!("../hooks/kilocode-rtk-rules.md");
const ANTIGRAVITY_RULES: &str = include_str!("../hooks/antigravity-rtk-rules.md");

/// Template written by `rtk init` when no filters.toml exists yet.
const FILTERS_TEMPLATE: &str = r#"# Project-local RTK filters — commit this file with your repo.
# Filters here override user-global and built-in filters.
Expand Down Expand Up @@ -212,6 +215,8 @@ pub fn run(
install_cursor: bool,
install_windsurf: bool,
install_cline: bool,
install_kilocode: bool,
install_antigravity: bool,
claude_md: bool,
hook_only: bool,
codex: bool,
Expand Down Expand Up @@ -261,6 +266,14 @@ pub fn run(
return run_cline_mode(verbose);
}

if install_kilocode {
return run_kilocode_mode();
}

if install_antigravity {
return run_antigravity_mode();
}

// Mode selection (Claude Code / OpenCode)
match (install_claude, install_opencode, claude_md, hook_only) {
(false, true, _, _) => run_opencode_only_mode(verbose)?,
Expand Down Expand Up @@ -1237,6 +1250,36 @@ fn run_windsurf_mode(verbose: u8) -> Result<()> {
Ok(())
}

fn run_kilocode_mode() -> Result<()> {
let target_dir = std::path::Path::new(".kilocode/rules");
std::fs::create_dir_all(target_dir)?;

let rules_path = target_dir.join("rtk-rules.md");
std::fs::write(&rules_path, KILOCODE_RULES)?;

println!("\nRTK configured for Kilo Code.\n");
println!(" Rules: .kilocode/rules/rtk-rules.md (installed)");
println!(" Kilo Code will now use rtk commands for token savings.");
println!(" Test with: git status\n");

Ok(())
}

fn run_antigravity_mode() -> Result<()> {
let target_dir = std::path::Path::new(".agent/rules");
std::fs::create_dir_all(target_dir)?;

let rules_path = target_dir.join("antigravity-rtk-rules.md");
std::fs::write(&rules_path, ANTIGRAVITY_RULES)?;

println!("\nRTK configured for Google Antigravity.\n");
println!(" Rules: .agent/rules/antigravity-rtk-rules.md (installed)");
println!(" Antigravity will now use rtk commands for token savings.");
println!(" Test with: git status\n");

Ok(())
}

fn run_codex_mode(global: bool, verbose: u8) -> Result<()> {
let (agents_md_path, rtk_md_path) = if global {
let codex_dir = resolve_codex_dir()?;
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ mod mypy_cmd;
mod next_cmd;
mod npm_cmd;
mod parser;
mod permissions;
mod pip_cmd;
mod playwright_cmd;
mod pnpm_cmd;
Expand Down Expand Up @@ -86,6 +85,10 @@ pub enum AgentTarget {
Windsurf,
/// Cline / Roo Code (VS Code)
Cline,
/// Kilo Code
Kilocode,
/// Google Antigravity
Antigravity,
}

#[derive(Parser)]
Expand Down Expand Up @@ -1710,6 +1713,8 @@ fn main() -> Result<()> {
let install_cursor = agent == Some(AgentTarget::Cursor);
let install_windsurf = agent == Some(AgentTarget::Windsurf);
let install_cline = agent == Some(AgentTarget::Cline);
let install_kilocode = agent == Some(AgentTarget::Kilocode);
let install_antigravity = agent == Some(AgentTarget::Antigravity);

let patch_mode = if auto_patch {
init::PatchMode::Auto
Expand All @@ -1725,6 +1730,8 @@ fn main() -> Result<()> {
install_cursor,
install_windsurf,
install_cline,
install_kilocode,
install_antigravity,
claude_md,
hook_only,
codex,
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub fn resolve_binary(name: &str) -> Result<PathBuf> {
pub fn resolved_command(name: &str) -> Command {
match resolve_binary(name) {
Ok(path) => Command::new(path),
Err(e) => {
Err(_e) => {
// On Windows, resolution failure likely means a .CMD/.BAT wrapper
// wasn't found — always warn so users have a signal.
// On Unix, this is less common; only log in debug builds.
Expand Down