Tokenjuice shrinks the terminal output that coding agents feed back into their context. When an agent runs a noisy command such as a git status, a test run, a container build, or a help page, Tokenjuice leaves the command itself unchanged, observes the output after execution, and returns a smaller payload produced by rule-driven reducers instead of the full wall of text.
The reduction is deterministic. Rules are inspectable JSON that classify command output, normalize lines, keep or drop patterns, count facts, and retain fixed head and tail slices. Built-in rules can be overridden per user or per project. Exact file-content reads stay raw, mixed command sequences that are unsafe to compact stay raw, and an explicit bypass returns untouched bytes when a reducer gets it wrong. Storing the raw output as an artifact is opt-in.
It has three surfaces: compacting text that already exists, running a command and compacting what it prints, and a JSON protocol for host adapters. Host integrations are thin wrappers that install a hook, extension, rule, or guidance file and call the shared compactor. Supported hosts include Claude Code, Codex CLI, Cursor, GitHub Copilot CLI, OpenCode, Pi, and VS Code Copilot Chat, with OpenClaw support bundled on the OpenClaw side and beta integrations for many more agents, including Goose, Qwen Code, Roo Code, Kilo Code, SWE-agent, and Open WebUI.
Features
- Deterministic compaction: rule-driven reducers return a smaller payload from command output without changing the command
- JSON rules: inspectable rules with built-in, user, and project layers that override each other by rule id
- Three surfaces: reduce existing text, wrap and compact a live command, or call a JSON adapter protocol
- Raw bypass: an explicit flag returns untouched bytes, and artifact storage of raw output is opt-in
- Safe-inventory policy: file-content reads and unsafe mixed command sequences are left uncompacted
- Host integrations: hooks or extensions for Claude Code, Codex CLI, Cursor, Copilot CLI, OpenCode, Pi, and others
- Beta integrations: rule or guidance files for dozens of further agents and review tools
- Diagnostics: commands to verify fixtures, check installed hook wiring per host, and discover integrations
- Usage statistics: bounded metadata on reductions, which can be switched off
