v2026.5.0 — 4 compression modes, auto mode, RTK-beating compression
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 modes —
conservative(ANSI-only),balanced(default; strips noise, preserves metadata),aggressive(drops metadata for max compression). Pass--modeor setCONTEXT_COMPRESS_MODE. automode — LLM picks the mode per command. Decisions cached at~/.context-compress/auto-cache.jsonwith 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.--streammode forwrap— line-by-line filtered output fortail -f, watch builds.- Single-binary lite CLI —
npm run build:bincross-compiles via Bun for darwin-arm64/x64, linux-x64/arm64.
Setup
context-compress setup --auto(aliasinit --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-wrap —
CONTEXT_COMPRESS_FILTER_BASH=1routesBashcalls throughwrapautomatically. - Mode forwarding — hook propagates
CONTEXT_COMPRESS_MODEto wrapped commands.
MCP server
- 8th tool:
discover— lists indexed sources, top searchable terms, optimization suggestions. isError: trueon all error responses (MCP protocol compliance).server.tsmodularized: 845 lines → 132. Tool handlers extracted tosrc/tools/*.ts, utilities tosrc/util/*.ts.
Security & performance
- IPv6 hex-mapped SSRF gap closed — blocks
::ffff:7f00:1,::ffff:c0a8:101, etc. getDistinctiveTermscached per source — was scanning up to 500 chunks per call.buildFetchCodeIPv6 fix — properly brackets IPv6 hostnames forURL.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 scripts —
benchmark.ts(synthetic),benchmark-real.ts(this repo),benchmark-vs-rtk.ts(head-to-head with--autoand--json).
Install / upgrade
npm install -g context-compress@2026.5.0
context-compress setup --autoReproducing 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 --autoFull changelog
See CHANGELOG.md.