Skip to content

v2026.5.0 — 4 compression modes, auto mode, RTK-beating compression

Choose a tag to compare

@jiunbae jiunbae released this 10 May 05:22
v2026.5.0
d3270b5

Major feature release. Headline numbers on this repo, head-to-head with RTK 0.39.0:

RTK conservative balanced aggressive auto
Token reduction 82.5% 6.0% 75.4% 93.0% 77.9%

Aggressive beats RTK by 10.5pp on the same commands. auto mode lets an LLM pick contextually appropriate compression per output (Anthropic API → claude -p fallback → heuristic).

What's new

Compression

  • Three explicit modesconservative (ANSI-only), balanced (default; strips noise, preserves metadata), aggressive (drops metadata for max compression). Pass --mode or set CONTEXT_COMPRESS_MODE.
  • auto mode — LLM picks the mode per command. Decisions cached at ~/.context-compress/auto-cache.json with 24h TTL.
  • Aggressive command filters for git log/diff/status, ls -la*, find, grep/rg, npm ls, df, du, ps aux.
  • Balanced now compresses meaningfully — was 0% on git log/ls/find. Now 75% byte-weighted on this repo without dropping any metadata.

Standalone CLI (RTK-compatible)

  • context-compress wrap "<cmd>" — runs a shell command and pipes stdout through the pipeline.
  • context-compress filter [--cmd '<orig>'] — stdin → compressed → stdout.
  • --stream mode for wrap — line-by-line filtered output for tail -f, watch builds.
  • Single-binary lite CLInpm run build:bin cross-compiles via Bun for darwin-arm64/x64, linux-x64/arm64.

Setup

  • context-compress setup --auto (alias init --auto) — one-line install: writes ~/.claude/settings.json, registers MCP server, installs PreToolUse hook, enables transparent Bash compression. Idempotent. Preserves unrelated user settings.
  • PreToolUse hook auto-wrapCONTEXT_COMPRESS_FILTER_BASH=1 routes Bash calls through wrap automatically.
  • Mode forwarding — hook propagates CONTEXT_COMPRESS_MODE to wrapped commands.

MCP server

  • 8th tool: discover — lists indexed sources, top searchable terms, optimization suggestions.
  • isError: true on all error responses (MCP protocol compliance).
  • server.ts modularized: 845 lines → 132. Tool handlers extracted to src/tools/*.ts, utilities to src/util/*.ts.

Security & performance

  • IPv6 hex-mapped SSRF gap closed — blocks ::ffff:7f00:1, ::ffff:c0a8:101, etc.
  • getDistinctiveTerms cached per source — was scanning up to 500 chunks per call.
  • buildFetchCode IPv6 fix — properly brackets IPv6 hostnames for URL.hostname.
  • ANSI stripping order fix — was hiding PASS/FAIL// markers from command filters when output had color codes.

CI / DX

  • CI restored — Node 20 + 22 matrix; typecheck + lint + tests + build.
  • Tests: 119 → 213 (+94). 18 unit test files + 3 integration.
  • README modernized — featured-numbers hero, RTK comparison table, updated project structure.
  • Three benchmark scriptsbenchmark.ts (synthetic), benchmark-real.ts (this repo), benchmark-vs-rtk.ts (head-to-head with --auto and --json).

Install / upgrade

npm install -g context-compress@2026.5.0
context-compress setup --auto

Reproducing the benchmark

git clone https://github.com/rtk-ai/rtk /tmp/rtk
(cd /tmp/rtk && cargo build --release)
RTK_BIN=/tmp/rtk/target/release/rtk tsx scripts/benchmark-vs-rtk.ts --auto

Full changelog

See CHANGELOG.md.