diff --git a/src/main.rs b/src/main.rs index 0ff5124c..41b89bed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,7 +92,8 @@ pub enum AgentTarget { 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)] @@ -114,6 +115,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)] @@ -121,6 +123,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)] @@ -128,6 +131,7 @@ enum Commands { }, /// Read file with intelligent filtering + #[command(next_display_order = None)] Read { /// File to read file: PathBuf, @@ -146,6 +150,7 @@ enum Commands { }, /// Generate 2-line technical summary (heuristic-based) + #[command(next_display_order = None)] Smart { /// File to analyze file: PathBuf, @@ -158,6 +163,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)] @@ -196,6 +202,7 @@ enum Commands { }, /// GitHub CLI (gh) commands with token-optimized output + #[command(next_display_order = None)] Gh { /// Subcommand: pr, issue, run, repo subcommand: String, @@ -205,6 +212,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, @@ -214,6 +222,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)] @@ -221,12 +230,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)] @@ -234,6 +245,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)] @@ -241,6 +253,7 @@ enum Commands { }, /// Show JSON (compact values, or schema-only with --schema) + #[command(next_display_order = None)] Json { /// JSON file file: PathBuf, @@ -253,6 +266,7 @@ enum Commands { }, /// Summarize project dependencies + #[command(next_display_order = None)] Deps { /// Project path #[arg(default_value = ".")] @@ -260,6 +274,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)] @@ -270,6 +285,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)] @@ -277,6 +293,7 @@ enum Commands { }, /// Ultra-condensed diff (only changed lines) + #[command(next_display_order = None)] Diff { /// First file or - for stdin (unified diff) file1: PathBuf, @@ -285,30 +302,35 @@ enum Commands { }, /// Filter and deduplicate log output + #[command(next_display_order = None)] Log { /// Log file (omit for stdin) file: Option, }, /// .NET commands with compact output (build/test/restore/format) + #[command(next_display_order = None)] Dotnet { #[command(subcommand)] command: DotnetCommands, }, /// 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)] @@ -316,6 +338,7 @@ enum Commands { }, /// Compact grep - strips whitespace, truncates, groups by file + #[command(next_display_order = None)] Grep { /// Pattern to search pattern: String, @@ -343,6 +366,7 @@ enum Commands { }, /// Initialize rtk instructions for assistant CLI usage + #[command(next_display_order = None)] Init { /// Add to global assistant config directory instead of local project file #[arg(short, long)] @@ -390,6 +414,7 @@ enum Commands { }, /// Download with compact output (strips progress bars) + #[command(next_display_order = None)] Wget { /// URL to download url: String, @@ -402,6 +427,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)] @@ -409,8 +435,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 @@ -446,6 +473,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)] @@ -465,6 +493,7 @@ enum Commands { }, /// Show or create configuration file + #[command(next_display_order = None)] Config { /// Create default config file #[arg(long)] @@ -472,18 +501,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)] @@ -491,6 +523,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)] @@ -498,6 +531,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)] @@ -505,6 +539,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)] @@ -512,6 +547,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)] @@ -519,6 +555,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)] @@ -526,12 +563,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)] @@ -539,6 +578,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)] @@ -546,6 +586,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)] @@ -553,6 +594,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)] @@ -572,9 +614,11 @@ enum Commands { }, /// Show RTK adoption across Claude Code sessions + #[command(next_display_order = None)] Session {}, /// Learn CLI corrections from Claude Code error history + #[command(next_display_order = None)] Learn { /// Filter by project path (substring match) #[arg(short, long)] @@ -600,6 +644,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)] @@ -607,6 +652,7 @@ enum Commands { }, /// Trust project-local TOML filters in current directory + #[command(next_display_order = None)] Trust { /// List all trusted projects #[arg(long)] @@ -614,9 +660,11 @@ enum Commands { }, /// Revoke trust for project-local TOML filters + #[command(next_display_order = None)] Untrust, /// Verify hook integrity and run TOML filter inline tests + #[command(next_display_order = None)] Verify { /// Run tests only for this filter name #[arg(long)] @@ -627,6 +675,7 @@ enum Commands { }, /// 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)] @@ -634,6 +683,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)] @@ -641,6 +691,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)] @@ -648,6 +699,7 @@ enum Commands { }, /// Rake/Rails test with compact Minitest output (Ruby) + #[command(next_display_order = None)] Rake { /// Rake arguments (e.g., test, test TEST=path/to/test.rb) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -655,6 +707,7 @@ enum Commands { }, /// RuboCop linter with compact output (Ruby) + #[command(next_display_order = None)] Rubocop { /// RuboCop arguments (e.g., --auto-correct, -A) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -662,6 +715,7 @@ enum Commands { }, /// RSpec test runner with compact output (Rails/Ruby) + #[command(next_display_order = None)] Rspec { /// RSpec arguments (e.g., spec/models, --tag focus) #[arg(trailing_var_arg = true, allow_hyphen_values = true)] @@ -669,6 +723,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)] @@ -676,19 +731,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)] @@ -696,7 +753,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")] @@ -710,6 +767,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") /// Accepts multiple args: `rtk rewrite ls -al` is equivalent to `rtk rewrite "ls -al"` @@ -718,6 +776,7 @@ enum Commands { }, /// Hook processors for LLM CLI tools (Gemini CLI, Copilot, etc.) + #[command(next_display_order = None)] Hook { #[command(subcommand)] command: HookCommands, @@ -727,74 +786,87 @@ enum Commands { #[derive(Subcommand)] enum HookCommands { /// Process Gemini CLI BeforeTool hook (reads JSON from stdin) + #[command(next_display_order = None)] Gemini, /// Process Copilot preToolUse hook (VS Code + Copilot CLI, reads JSON from stdin) + #[command(next_display_order = None)] Copilot, } #[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, @@ -803,6 +875,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)] @@ -816,6 +889,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")] @@ -825,12 +899,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, @@ -839,12 +915,14 @@ enum PnpmCommands { args: Vec, }, /// Build (generic passthrough, no framework-specific 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)] @@ -858,12 +936,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, @@ -876,13 +958,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, @@ -895,6 +980,7 @@ enum ComposeCommands { #[derive(Subcommand)] enum KubectlCommands { /// List pods + #[command(next_display_order = None)] Pods { #[arg(short, long)] namespace: Option, @@ -903,6 +989,7 @@ enum KubectlCommands { all: bool, }, /// List services + #[command(next_display_order = None)] Services { #[arg(short, long)] namespace: Option, @@ -911,6 +998,7 @@ enum KubectlCommands { all: bool, }, /// Show pod logs (deduplicated) + #[command(next_display_order = None)] Logs { pod: String, #[arg(short, long)] @@ -924,6 +1012,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)] @@ -934,17 +1023,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)] @@ -955,6 +1047,7 @@ enum PrismaCommands { #[derive(Subcommand)] enum PrismaMigrateCommands { /// Create and apply migration + #[command(next_display_order = None)] Dev { /// Migration name #[arg(short, long)] @@ -964,12 +1057,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)] @@ -980,36 +1075,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)] @@ -1023,21 +1124,25 @@ enum CargoCommands { #[derive(Subcommand)] enum DotnetCommands { /// Build with compact output + #[command(next_display_order = None)] Build { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Test with compact output + #[command(next_display_order = None)] Test { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Restore with compact output + #[command(next_display_order = None)] Restore { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, }, /// Format with compact output + #[command(next_display_order = None)] Format { #[arg(trailing_var_arg = true, allow_hyphen_values = true)] args: Vec, @@ -1050,18 +1155,21 @@ enum DotnetCommands { #[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)] @@ -1207,31 +1315,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,