diff --git a/src/main.rs b/src/main.rs index 7a1c0159..ac869f03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,8 @@ use std::path::{Path, PathBuf}; name = "rtk", version, about = "Rust Token Killer - Minimize LLM token consumption", - long_about = "A high-performance CLI proxy designed to filter and summarize system outputs before they reach your LLM context." + long_about = "A high-performance CLI proxy designed to filter and summarize system outputs before they reach your LLM context.", + next_display_order = None )] struct Cli { #[command(subcommand)] @@ -89,6 +90,7 @@ struct Cli { #[derive(Subcommand)] enum Commands { /// List directory contents with token-optimized output (proxy to native ls) + #[command(next_display_order = None)] Ls { /// Arguments passed to ls (supports all native ls flags like -l, -a, -h, -R) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -96,6 +98,7 @@ enum Commands { }, /// Directory tree with token-optimized output (proxy to native tree) + #[command(next_display_order = None)] Tree { /// Arguments passed to tree (supports all native tree flags like -L, -d, -a) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -103,6 +106,7 @@ enum Commands { }, /// Read file with intelligent filtering + #[command(next_display_order = None)] Read { /// File to read file: PathBuf, @@ -118,6 +122,7 @@ enum Commands { }, /// Generate 2-line technical summary (heuristic-based) + #[command(next_display_order = None)] Smart { /// File to analyze file: PathBuf, @@ -130,6 +135,7 @@ enum Commands { }, /// Git commands with compact output + #[command(next_display_order = None)] Git { /// Change to directory before executing (like git -C , can be repeated) #[arg(short = 'C', action = clap::ArgAction::Append)] @@ -168,6 +174,7 @@ enum Commands { }, /// GitHub CLI (gh) commands with token-optimized output + #[command(next_display_order = None)] Gh { /// Subcommand: pr, issue, run, repo subcommand: String, @@ -177,6 +184,7 @@ enum Commands { }, /// AWS CLI with compact output (force JSON, compress) + #[command(next_display_order = None)] Aws { /// AWS service subcommand (e.g., sts, s3, ec2, ecs, rds, cloudformation) subcommand: String, @@ -186,6 +194,7 @@ enum Commands { }, /// PostgreSQL client with compact output (strip borders, compress tables) + #[command(next_display_order = None)] Psql { /// psql arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -193,12 +202,14 @@ enum Commands { }, /// pnpm commands with ultra-compact output + #[command(next_display_order = None)] Pnpm { #[command(subcommand)] command: PnpmCommands, }, /// Run command and show only errors/warnings + #[command(next_display_order = None)] Err { /// Command to run #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -206,6 +217,7 @@ enum Commands { }, /// Run tests and show only failures + #[command(next_display_order = None)] Test { /// Test command (e.g. cargo test) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -213,6 +225,7 @@ enum Commands { }, /// Show JSON structure without values + #[command(next_display_order = None)] Json { /// JSON file file: PathBuf, @@ -222,6 +235,7 @@ enum Commands { }, /// Summarize project dependencies + #[command(next_display_order = None)] Deps { /// Project path #[arg(default_value = ".")] @@ -229,6 +243,7 @@ enum Commands { }, /// Show environment variables (filtered, sensitive masked) + #[command(next_display_order = None)] Env { /// Filter by name (e.g. PATH, AWS) #[arg(short, long)] @@ -239,6 +254,7 @@ enum Commands { }, /// Find files with compact tree output (accepts native find flags like -name, -type) + #[command(next_display_order = None)] Find { /// All find arguments (supports both RTK and native find syntax) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -246,6 +262,7 @@ enum Commands { }, /// Ultra-condensed diff (only changed lines) + #[command(next_display_order = None)] Diff { /// First file or - for stdin (unified diff) file1: PathBuf, @@ -254,24 +271,28 @@ enum Commands { }, /// Filter and deduplicate log output + #[command(next_display_order = None)] Log { /// Log file (omit for stdin) file: Option, }, /// Docker commands with compact output + #[command(next_display_order = None)] Docker { #[command(subcommand)] command: DockerCommands, }, /// Kubectl commands with compact output + #[command(next_display_order = None)] Kubectl { #[command(subcommand)] command: KubectlCommands, }, /// Run command and show heuristic summary + #[command(next_display_order = None)] Summary { /// Command to run and summarize #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -279,6 +300,7 @@ enum Commands { }, /// Compact grep - strips whitespace, truncates, groups by file + #[command(next_display_order = None)] Grep { /// Pattern to search pattern: String, @@ -306,6 +328,7 @@ enum Commands { }, /// Initialize rtk instructions in CLAUDE.md + #[command(next_display_order = None)] Init { /// Add to global ~/.claude/CLAUDE.md instead of local #[arg(short, long)] @@ -337,6 +360,7 @@ enum Commands { }, /// Download with compact output (strips progress bars) + #[command(next_display_order = None)] Wget { /// URL to download url: String, @@ -349,6 +373,7 @@ enum Commands { }, /// Word/line/byte count with compact output (strips paths and padding) + #[command(next_display_order = None)] Wc { /// Arguments passed to wc (files, flags like -l, -w, -c) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -356,8 +381,9 @@ enum Commands { }, /// Show token savings summary and history + #[command(next_display_order = None)] Gain { - /// Filter statistics to current project (current working directory) // added + /// Filter statistics to current project (current working directory) #[arg(short, long)] project: bool, /// Show ASCII graph of daily savings @@ -393,6 +419,7 @@ enum Commands { }, /// Claude Code economics: spending (ccusage) vs savings (rtk) analysis + #[command(next_display_order = None)] CcEconomics { /// Show detailed daily breakdown #[arg(short, long)] @@ -412,6 +439,7 @@ enum Commands { }, /// Show or create configuration file + #[command(next_display_order = None)] Config { /// Create default config file #[arg(long)] @@ -419,18 +447,21 @@ enum Commands { }, /// Vitest commands with compact output + #[command(next_display_order = None)] Vitest { #[command(subcommand)] command: VitestCommands, }, /// Prisma commands with compact output (no ASCII art) + #[command(next_display_order = None)] Prisma { #[command(subcommand)] command: PrismaCommands, }, /// TypeScript compiler with grouped error output + #[command(next_display_order = None)] Tsc { /// TypeScript compiler arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -438,6 +469,7 @@ enum Commands { }, /// Next.js build with compact output + #[command(next_display_order = None)] Next { /// Next.js build arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -445,6 +477,7 @@ enum Commands { }, /// ESLint with grouped rule violations + #[command(next_display_order = None)] Lint { /// Linter arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -452,6 +485,7 @@ enum Commands { }, /// Prettier format checker with compact output + #[command(next_display_order = None)] Prettier { /// Prettier arguments (e.g., --check, --write) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -459,6 +493,7 @@ enum Commands { }, /// Universal format checker (prettier, black, ruff format) + #[command(next_display_order = None)] Format { /// Formatter arguments (auto-detects formatter from project files) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -466,6 +501,7 @@ enum Commands { }, /// Playwright E2E tests with compact output + #[command(next_display_order = None)] Playwright { /// Playwright arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -473,12 +509,14 @@ enum Commands { }, /// Cargo commands with compact output + #[command(next_display_order = None)] Cargo { #[command(subcommand)] command: CargoCommands, }, /// npm run with filtered output (strip boilerplate) + #[command(next_display_order = None)] Npm { /// npm run arguments (script name + options) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -486,6 +524,7 @@ enum Commands { }, /// npx with intelligent routing (tsc, eslint, prisma -> specialized filters) + #[command(next_display_order = None)] Npx { /// npx arguments (command + options) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -493,6 +532,7 @@ enum Commands { }, /// Curl with auto-JSON detection and schema output + #[command(next_display_order = None)] Curl { /// Curl arguments (URL + options) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -500,6 +540,7 @@ enum Commands { }, /// Discover missed RTK savings from Claude Code history + #[command(next_display_order = None)] Discover { /// Filter by project path (substring match) #[arg(short, long)] @@ -519,6 +560,7 @@ enum Commands { }, /// Learn CLI corrections from Claude Code error history + #[command(next_display_order = None)] Learn { /// Filter by project path (substring match) #[arg(short, long)] @@ -544,6 +586,7 @@ enum Commands { }, /// Execute command without filtering but track usage + #[command(next_display_order = None)] Proxy { /// Command and arguments to execute #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -554,6 +597,7 @@ enum Commands { Verify, /// Ruff linter/formatter with compact output + #[command(next_display_order = None)] Ruff { /// Ruff arguments (e.g., check, format --check) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -561,6 +605,7 @@ enum Commands { }, /// Pytest test runner with compact output + #[command(next_display_order = None)] Pytest { /// Pytest arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -568,6 +613,7 @@ enum Commands { }, /// Mypy type checker with grouped error output + #[command(next_display_order = None)] Mypy { /// Mypy arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -575,6 +621,7 @@ enum Commands { }, /// Pip package manager with compact output (auto-detects uv) + #[command(next_display_order = None)] Pip { /// Pip arguments (e.g., list, outdated, install) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -582,19 +629,21 @@ enum Commands { }, /// Go commands with compact output + #[command(next_display_order = None)] Go { #[command(subcommand)] command: GoCommands, }, /// Graphite (gt) stacked PR commands with compact output + #[command(next_display_order = None)] Gt { #[command(subcommand)] command: GtCommands, }, /// golangci-lint with compact output - #[command(name = "golangci-lint")] + #[command(next_display_order = None, name = "golangci-lint")] GolangciLint { /// golangci-lint arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -602,7 +651,7 @@ enum Commands { }, /// Show hook rewrite audit metrics (requires RTK_HOOK_AUDIT=1) - #[command(name = "hook-audit")] + #[command(next_display_order = None, name = "hook-audit")] HookAudit { /// Show entries from last N days (0 = all time) #[arg(short, long, default_value = "7")] @@ -616,6 +665,7 @@ enum Commands { /// /// Used by Claude Code, Gemini CLI, and other LLM hooks: /// REWRITTEN=$(rtk rewrite "$CMD") || exit 0 + #[command(next_display_order = None)] Rewrite { /// Raw command to rewrite (e.g. "git status", "cargo test && git push") cmd: String, @@ -625,66 +675,77 @@ enum Commands { #[derive(Subcommand)] enum GitCommands { /// Condensed diff output + #[command(next_display_order = None)] Diff { /// Git arguments (supports all git diff flags like --stat, --cached, etc) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// One-line commit history + #[command(next_display_order = None)] Log { /// Git arguments (supports all git log flags like --oneline, --graph, --all) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Compact status (supports all git status flags) + #[command(next_display_order = None)] Status { /// Git arguments (supports all git status flags like --porcelain, --short, -s) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Compact show (commit summary + stat + compacted diff) + #[command(next_display_order = None)] Show { /// Git arguments (supports all git show flags) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Add files → "ok ✓" + #[command(next_display_order = None)] Add { /// Files and flags to add (supports all git add flags like -A, -p, --all, etc) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Commit → "ok ✓ \" + #[command(next_display_order = None)] Commit { /// Git commit arguments (supports -a, -m, --amend, --allow-empty, etc) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Push → "ok ✓ \" + #[command(next_display_order = None)] Push { /// Git push arguments (supports -u, remote, branch, etc.) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Pull → "ok ✓ \" + #[command(next_display_order = None)] Pull { /// Git pull arguments (supports --rebase, remote, branch, etc.) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Compact branch listing (current/local/remote) + #[command(next_display_order = None)] Branch { /// Git branch arguments (supports -d, -D, -m, etc.) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Fetch → "ok fetched (N new refs)" + #[command(next_display_order = None)] Fetch { /// Git fetch arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Stash management (list, show, pop, apply, drop) + #[command(next_display_order = None)] Stash { /// Subcommand: list, show, pop, apply, drop, push subcommand: Option, @@ -693,6 +754,7 @@ enum GitCommands { args: Vec, }, /// Compact worktree listing + #[command(next_display_order = None)] Worktree { /// Git worktree arguments (add, remove, prune, or empty for list) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -706,6 +768,7 @@ enum GitCommands { #[derive(Subcommand)] enum PnpmCommands { /// List installed packages (ultra-dense) + #[command(next_display_order = None)] List { /// Depth level (default: 0) #[arg(short, long, default_value = "0")] @@ -715,12 +778,14 @@ enum PnpmCommands { args: Vec, }, /// Show outdated packages (condensed: "pkg: old → new") + #[command(next_display_order = None)] Outdated { /// Additional pnpm arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Install packages (filter progress bars) + #[command(next_display_order = None)] Install { /// Packages to install packages: Vec, @@ -729,12 +794,14 @@ enum PnpmCommands { args: Vec, }, /// Build (delegates to next build filter) + #[command(next_display_order = None)] Build { /// Additional build arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Typecheck (delegates to tsc filter) + #[command(next_display_order = None)] Typecheck { /// Additional typecheck arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -748,12 +815,16 @@ enum PnpmCommands { #[derive(Subcommand)] enum DockerCommands { /// List running containers + #[command(next_display_order = None)] Ps, /// List images + #[command(next_display_order = None)] Images, /// Show container logs (deduplicated) + #[command(next_display_order = None)] Logs { container: String }, /// Docker Compose commands with compact output + #[command(next_display_order = None)] Compose { #[command(subcommand)] command: ComposeCommands, @@ -766,13 +837,16 @@ enum DockerCommands { #[derive(Subcommand)] enum ComposeCommands { /// List compose services (compact) + #[command(next_display_order = None)] Ps, /// Show compose logs (deduplicated) + #[command(next_display_order = None)] Logs { /// Optional service name service: Option, }, /// Build compose services (summary) + #[command(next_display_order = None)] Build { /// Optional service name service: Option, @@ -785,6 +859,7 @@ enum ComposeCommands { #[derive(Subcommand)] enum KubectlCommands { /// List pods + #[command(next_display_order = None)] Pods { #[arg(short, long)] namespace: Option, @@ -793,6 +868,7 @@ enum KubectlCommands { all: bool, }, /// List services + #[command(next_display_order = None)] Services { #[arg(short, long)] namespace: Option, @@ -801,6 +877,7 @@ enum KubectlCommands { all: bool, }, /// Show pod logs (deduplicated) + #[command(next_display_order = None)] Logs { pod: String, #[arg(short, long)] @@ -814,6 +891,7 @@ enum KubectlCommands { #[derive(Subcommand)] enum VitestCommands { /// Run tests with filtered output (90% token reduction) + #[command(next_display_order = None)] Run { /// Additional vitest arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -824,17 +902,20 @@ enum VitestCommands { #[derive(Subcommand)] enum PrismaCommands { /// Generate Prisma Client (strip ASCII art) + #[command(next_display_order = None)] Generate { /// Additional prisma arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Manage migrations + #[command(next_display_order = None)] Migrate { #[command(subcommand)] command: PrismaMigrateCommands, }, /// Push schema to database + #[command(next_display_order = None)] DbPush { /// Additional prisma arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -845,6 +926,7 @@ enum PrismaCommands { #[derive(Subcommand)] enum PrismaMigrateCommands { /// Create and apply migration + #[command(next_display_order = None)] Dev { /// Migration name #[arg(short, long)] @@ -854,12 +936,14 @@ enum PrismaMigrateCommands { args: Vec, }, /// Check migration status + #[command(next_display_order = None)] Status { /// Additional arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Deploy migrations to production + #[command(next_display_order = None)] Deploy { /// Additional arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -870,36 +954,42 @@ enum PrismaMigrateCommands { #[derive(Subcommand)] enum CargoCommands { /// Build with compact output (strip Compiling lines, keep errors) + #[command(next_display_order = None)] Build { /// Additional cargo build arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Test with failures-only output + #[command(next_display_order = None)] Test { /// Additional cargo test arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Clippy with warnings grouped by lint rule + #[command(next_display_order = None)] Clippy { /// Additional cargo clippy arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Check with compact output (strip Checking lines, keep errors) + #[command(next_display_order = None)] Check { /// Additional cargo check arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Install with compact output (strip dep compilation, keep installed/errors) + #[command(next_display_order = None)] Install { /// Additional cargo install arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Nextest with failures-only output + #[command(next_display_order = None)] Nextest { /// Additional cargo nextest arguments (e.g., run, list, --lib) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -913,18 +1003,21 @@ enum CargoCommands { #[derive(Subcommand)] enum GoCommands { /// Run tests with compact output (90% token reduction via JSON streaming) + #[command(next_display_order = None)] Test { /// Additional go test arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Build with compact output (errors only) + #[command(next_display_order = None)] Build { /// Additional go build arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Vet with compact output + #[command(next_display_order = None)] Vet { /// Additional go vet arguments #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -999,31 +1092,37 @@ fn run_fallback(parse_error: clap::Error) -> Result<()> { #[derive(Subcommand)] enum GtCommands { /// Compact stack log output + #[command(next_display_order = None)] Log { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Compact submit output + #[command(next_display_order = None)] Submit { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Compact sync output + #[command(next_display_order = None)] Sync { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Compact restack output + #[command(next_display_order = None)] Restack { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Compact create output + #[command(next_display_order = None)] Create { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Branch info and management + #[command(next_display_order = None)] Branch { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec,