rtk-ai / rtk-ai/rtk

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

Open
#569 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli effort-large enhancement help wanted priority:medium
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

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.).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named; start at the CLI entry point and inspect the existing grepai handling. Resolve which proposed integration path is in scope, how command and stdin inputs behave, and how the optional distill dependency is handled; done means the selected interface is implemented with coverage for its supported invocation modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, rust
Domain
ai, cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.