rtk-ai/rtk

Feature request: add support for distill to compress arbitrary command outputs

Open

#569 aberto em 13 de mar. de 2026

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Rust (2.914 forks)batch import
area:clieffort-largeenhancementhelp wantedpriority:medium

Métricas do repositório

Stars
 (48.085 stars)
Métricas de merge de PR
 (Mesclagem média 11d 1h) (45 fundiu PRs em 30d)

Description

Repository: https://github.com/samuelfaj/distill

Description

Summary

Add rtk distill command (or rtk <cmd> | distill integration) to pipe arbitrary CLI outputs through distill — a tool that uses an LLM to compress verbose command outputs into tiny, targeted answers, saving up to 99% tokens.

distill is very similar in spirit to what rtk already does for specific tools (grepai, etc.), but more general: it lets the user provide an explicit instruction to extract exactly what the LLM needs.

Motivation

Many developer workflows involve running commands that produce huge outputs:

  • bun test / cargo test / pytest → thousands of lines of stack traces, logs, diffs
  • terraform plan / git diff --stat / npm audit
  • docker logs, build logs, linter outputs, etc.

Even when rtk rewrites known tools, many commands remain unfiltered and eat tokens when passed to Claude / other agents.

distill solves this with one-line prompts like:

npm audit 2>&1 | distill "Extract the vulnerabilities. Return valid JSON only."
bun test 2>&1 | distill "Did the tests pass? Return only: PASS or FAIL, followed by failing test names if any."
terraform plan 2>&1 | distill "Is this safe? Return only: SAFE, REVIEW, or UNSAFE, followed by the exact risky changes."

Reported savings in the repo go up to ~98.7% (7,648 → 99 tokens).

Since rtk already acts as a smart proxy / rewriter for token-heavy commands, adding built-in support for distill would make it the natural place to compress any command output in LLM-driven coding sessions.

Proposed Integration Options

Option 1: Dedicated rtk distill subcommand (recommended)

rtk distill "Did tests pass? Return PASS/FAIL + failing names only" -- bun test
# or piped
bun test 2>&1 | rtk distill "Summarize failing tests only"

Under the hood: rtk runs the command (or reads stdin), pipes to distill with the provided instruction, and returns the tiny output.

Option 2: Automatic opt-in rewriting for high-volume commands

Detect common verbose tools (test runners, plans, audits, logs) and offer --distill "instruction" flag:

rtk --distill "PASS/FAIL + failures" test              # rewrites to rtk test → distill
rtk terraform plan --distill "SAFE/REVIEW/UNSAFE + risks"

Option 3: Passthrough + tracking mode

Like grepai: run original command → capture output → optionally compress with distill if user has it installed and a config flag is set.

Expected Savings (examples from distill repo + typical rtk usage)

Expected token savings examples:

  • bun test (failing suite)
    Input tokens: ~7,600
    Output tokens: ~99
    Savings: ~98.7%

  • npm audit (multiple vulns)
    Input tokens: ~4,200
    Output tokens: ~120
    Savings: ~97%

  • terraform plan (large)
    Input tokens: ~12,000
    Output tokens: ~150
    Savings: ~98.8%

  • git diff (many files)
    Input tokens: ~3,500
    Output tokens: ~80
    Savings: ~97.7%

Dependencies & Feasibility

  • distill is a simple npm global (npm i -g @samuelfaj/distill)
  • It supports many local OpenAI-compatible backends (LM Studio, LocalAI, llama.cpp, etc.)

Hook / Rewrite Strategy

Similar to grepai handling:

  • rtk distill <instruction> -- <cmd> → run cmd → pipe stdout/stderr to distill
  • Optional: rtk <known-verbose-cmd> --distill "<instruction>" → transparent rewrite

This would make rtk even more powerful for general agent workflows (Claude Code, Cursor, Aider, etc.).

Guia do colaborador