How ppgranger/token-saver works
Token-Saver locally compresses terminal output before it reaches an AI coding assistant. The main workflow intercepts command output, checks whether the command is eligible, routes it through a specialized processor, and returns compressed output; hooks provide automatic integration, while Codex can use an explicit wrapper. Separate capabilities include Delta comparisons across runs, savings tracking and statistics, and quality contracts. Edges reflect the supplied excerpts, SOURCE INDEX references, and README; some subsystem internals were not sampled.
Main entry points: engine.py Processor engine · delta.py Delta comparison · core.py Compression core · cli.py CLI commands
Components 20
Assistant integrations
- Host hooks
src/platforms.py - Output wrapper
scripts/wrap.py - CLI commands
src/cli.py
Compression runtime
- Command policy
src/command_policy.py - Compression core
src/core.py - Processor engine
src/engine.py - Processor registry
src/registry.py - Command processors
src/processors - Configuration
src/config.py
Delta comparisons
- Delta comparison
src/delta.py - Diagnostic comparison
src/diagnostics.py - Delta run store
src/delta_store.py - Delta commands
src/delta_cli.py
Tracking and quality
- Savings tracker
src/tracker.py - Savings database
src/tracker.py - Savings statistics
src/stats.py - Quality contracts
src/quality_cli.py
Other components
- Developer
- AI assistant
- Terminal commands
Connections 24
- Developer → AI assistant: requests work
- AI assistant → Terminal commands: runs commands
- Terminal commands → Host hooks: provides output
- Host hooks → Compression core: compresses output
- Terminal commands → Output wrapper: pipes output
- Output wrapper → Command policy: checks command
scripts/wrap.py - Output wrapper → Compression core: requests compression
scripts/wrap.py - Compression core → Command policy: checks eligibility
src/core.py - Compression core → Processor engine: compresses output
src/core.py - Processor engine → Processor registry: loads processors
src/engine.py - Processor engine → Command processors: dispatches processing
src/engine.py - Processor engine → Configuration: reads settings
src/engine.py - CLI commands → Processor engine: benchmarks output
src/cli.py - CLI commands → Delta commands: routes commands
src/cli.py - CLI commands → Savings statistics: shows savings
src/cli.py - Delta commands → Delta comparison: requests comparison
src/delta_cli.py - Delta comparison → Diagnostic comparison: compares snapshots
src/delta.py - Delta comparison → Delta run store: stores run history
src/delta.py - Delta comparison → Processor engine: checks redaction state
src/delta.py - Delta comparison → Configuration: reads Delta settings
src/delta.py - Savings tracker → Savings database: records savings
src/tracker.py - Savings statistics → Savings tracker: reads totals
src/stats.py - Quality contracts → Processor engine: checks compression
- Host hooks → Savings tracker: shows session savings