squeez 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +460 -0
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
# squeez
|
|
2
|
+
|
|
3
|
+
[](https://github.com/claudioemmanuel/squeez/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/squeez)
|
|
5
|
+
[](https://crates.io/crates/squeez)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[Changelog](CHANGELOG.md)
|
|
8
|
+
|
|
9
|
+
End-to-end token optimizer for Claude Code, OpenCode, and GitHub Copilot CLI. Compresses bash output up to **95%**, collapses redundant calls, and injects a terse prompt persona — automatically, with zero new runtime dependencies.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Three methods — all produce the same result (binary at `~/.claude/squeez/bin/squeez`, hooks registered).
|
|
16
|
+
|
|
17
|
+
### curl (recommended)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
curl -fsSL https://raw.githubusercontent.com/claudioemmanuel/squeez/main/install.sh | sh
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> **Windows:** requires [Git Bash](https://git-scm.com/downloads). Run the command above inside Git Bash — PowerShell/CMD are not supported.
|
|
24
|
+
|
|
25
|
+
### npm / npx
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Install globally
|
|
29
|
+
npm install -g squeez
|
|
30
|
+
|
|
31
|
+
# Or run once without installing
|
|
32
|
+
npx squeez
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Downloads the correct pre-built binary for your platform (macOS universal, Linux x86_64/aarch64, Windows x86_64). Requires Node ≥ 16.
|
|
36
|
+
|
|
37
|
+
### cargo (build from source)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cargo install squeez
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Builds from [crates.io](https://crates.io/crates/squeez). Requires Rust stable. On Windows you also need [MSVC C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### After install
|
|
48
|
+
|
|
49
|
+
| Platform | What to do |
|
|
50
|
+
|----------|-----------|
|
|
51
|
+
| **Claude Code** | Restart Claude Code — hooks activate automatically |
|
|
52
|
+
| **OpenCode** | Restart OpenCode — plugin auto-loads from `~/.config/opencode/plugins/` |
|
|
53
|
+
| **Copilot CLI** | Restart Copilot CLI — hooks registered in `~/.copilot/settings.json` |
|
|
54
|
+
|
|
55
|
+
### Uninstall
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
bash ~/.claude/squeez/uninstall.sh
|
|
59
|
+
# or, if you cloned the repo:
|
|
60
|
+
bash uninstall.sh
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Self-update
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
squeez update # download latest binary + verify SHA256
|
|
67
|
+
squeez update --check # check for update without installing
|
|
68
|
+
squeez update --insecure # skip checksum (not recommended)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## What it does
|
|
74
|
+
|
|
75
|
+
| Feature | Description |
|
|
76
|
+
|---------|-------------|
|
|
77
|
+
| **Bash compression** | Intercepts every command via `PreToolUse` hook, applies smart filter → dedup → grouping → truncation. Up to 95% reduction. |
|
|
78
|
+
| **Context engine** | Cross-call redundancy with two paths: exact-hash match (FNV-1a, fast) **and** fuzzy trigram-shingle Jaccard ≥0.85 (whitespace, timestamps, single-line edits no longer defeat dedup). |
|
|
79
|
+
| **Summarize fallback** | Outputs exceeding 500 lines are replaced with a ≤40-line dense summary (top errors, files, test result, tail). **Benign outputs get 2× the threshold** so successful builds stay verbatim. |
|
|
80
|
+
| **Adaptive intensity** | Truly adaptive: **Full** (×0.6 limits) below 80% of token budget, **Ultra** (×0.3) above. Used to be always-Ultra; now actually responds to session pressure. |
|
|
81
|
+
| **MCP server** | `squeez mcp` runs a JSON-RPC 2.0 server over stdio exposing 13 read-only tools so any MCP-compatible LLM can query session memory directly. Hand-rolled, no `mcp.server` dependency. |
|
|
82
|
+
| **Auto-teach payload** | `squeez protocol` (or the `squeez_protocol` MCP tool) prints a 2.4 KB self-describing payload — the LLM learns squeez's markers and protocol on first call. |
|
|
83
|
+
| **Caveman persona** | Injects an ultra-terse prompt at session start so the model responds with fewer tokens. |
|
|
84
|
+
| **Memory-file compression** | `squeez compress-md` compresses CLAUDE.md / AGENTS.md / copilot-instructions.md in-place — pure Rust, zero LLM. i18n-aware: set `lang = pt` (or `--lang pt`) for pt-BR article/filler/phrase dropping and Unicode-correct matching. |
|
|
85
|
+
| **Session memory** | On `SessionStart`, injects a structured summary of the previous session: files investigated, learned facts (errors + git events), completed work (builds, test passes), and next steps (unresolved errors, failing tests). Summaries carry temporal validity (`valid_from`/`valid_to`). |
|
|
86
|
+
| **Token tracking** | Every `PostToolUse` result (Bash, Read, Grep, Glob) feeds a `SessionContext` so squeez knows what the agent has already seen. |
|
|
87
|
+
| **Token economy** | Sub-agent cost tracking (~200K tokens/spawn), burn rate prediction (`[budget: ~N calls left]`), session efficiency scoring, tool result size budgets. |
|
|
88
|
+
| **Auto-calibration** | `squeez calibrate` runs benchmarks on install and generates an optimized `config.ini` (aggressive / balanced / conservative profiles). |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Benchmarks
|
|
93
|
+
|
|
94
|
+
<!-- BENCHMARK:START -->
|
|
95
|
+
Measured on macOS (Apple Silicon). Token count = `chars / 4` (matches Claude's ~4 chars/token). Run `squeez benchmark` to reproduce.
|
|
96
|
+
|
|
97
|
+
### Per-scenario results — 19 scenarios × 3 iterations
|
|
98
|
+
|
|
99
|
+
| Scenario | Before | After | Reduction | Latency |
|
|
100
|
+
|----------|--------|-------|-----------|---------|
|
|
101
|
+
| `summarize_huge` | 82,257 tk | 420 tk | **-99%** | 62.9 ms |
|
|
102
|
+
| `repetitive_output` | 4,692 tk | 37 tk | **-99%** | 102 µs |
|
|
103
|
+
| `ps_aux` | 40,373 tk | 2,352 tk | **-94%** | 702 µs |
|
|
104
|
+
| `git_log_200` | 2,692 tk | 289 tk | **-89%** | 75 µs |
|
|
105
|
+
| `tsc_errors` | 731 tk | 101 tk | **-86%** | 20 µs |
|
|
106
|
+
| `cargo_build_noisy` | 2,106 tk | 452 tk | **-79%** | 75 µs |
|
|
107
|
+
| `docker_logs` | 665 tk | 186 tk | **-72%** | 16 µs |
|
|
108
|
+
| `find_deep` | 424 tk | 134 tk | **-68%** | 29 µs |
|
|
109
|
+
| `git_status` | 50 tk | 16 tk | **-68%** | 5 µs |
|
|
110
|
+
| `verbose_app_log` | 4,957 tk | 1,991 tk | **-60%** | 93 µs |
|
|
111
|
+
| `npm_install` | 524 tk | 232 tk | **-56%** | 16 µs |
|
|
112
|
+
| `crosscall_redundancy_3x` | 486 tk | 241 tk | **-50%** | 57.7 ms |
|
|
113
|
+
| `ls_la` | 1,782 tk | 886 tk | **-50%** | 52 µs |
|
|
114
|
+
| `env_dump` | 441 tk | 287 tk | **-35%** | 9 µs |
|
|
115
|
+
| `git_copilot` | 640 tk | 421 tk | **-34%** | 28 µs |
|
|
116
|
+
| `md_prose` | 187 tk | 138 tk | **-26%** | 251 µs |
|
|
117
|
+
| `md_claude_md` | 316 tk | 247 tk | **-22%** | 299 µs |
|
|
118
|
+
| `git_diff` | 502 tk | 497 tk | **-1%** | 17 µs |
|
|
119
|
+
| `kubectl_pods` | 1,513 tk | 1,513 tk | **-0%** | 20 µs |
|
|
120
|
+
|
|
121
|
+
### Aggregate
|
|
122
|
+
|
|
123
|
+
| Metric | Value |
|
|
124
|
+
|--------|-------|
|
|
125
|
+
| **Total token reduction** | **92.8%** — 145,338 tk → 10,440 tk |
|
|
126
|
+
| Bash output | **-84.9%** |
|
|
127
|
+
| Markdown / context files | **-23.5%** |
|
|
128
|
+
| Wrap / cross-call engine | **-99.2%** |
|
|
129
|
+
| Quality (signal terms preserved) | **19 / 19 pass** |
|
|
130
|
+
| Latency p50 (filter mode) | **6.4 ms** |
|
|
131
|
+
| Latency p95 (incl. wrap/summarize) | **63 ms** |
|
|
132
|
+
|
|
133
|
+
### Estimated cost savings — Claude Sonnet 4.6 · $3.00 / MTok input
|
|
134
|
+
|
|
135
|
+
| Usage | Baseline / month | Saved / month |
|
|
136
|
+
|-------|-----------------|---------------|
|
|
137
|
+
| 100 calls / day | $18.00 | **$16.71 (93%)** |
|
|
138
|
+
| 1,000 calls / day | $180.00 | **$167.08 (93%)** |
|
|
139
|
+
| 10,000 calls / day | $1800.00 | **$1670.76 (93%)** |
|
|
140
|
+
<!-- BENCHMARK:END -->
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Commands
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
squeez wrap <cmd> # compress a command's output end-to-end
|
|
148
|
+
squeez filter <hint> # compress stdin (piped usage)
|
|
149
|
+
squeez compress-md [--ultra] [--dry-run] [--all] <file>... # compress markdown files
|
|
150
|
+
squeez benchmark [--json] [--output <file>] [--scenario <name>] [--iterations <n>]
|
|
151
|
+
squeez mcp # JSON-RPC 2.0 MCP server over stdin/stdout
|
|
152
|
+
squeez protocol # print the auto-teach payload (markers + protocol)
|
|
153
|
+
squeez update [--check] [--insecure] # self-update
|
|
154
|
+
squeez init [--copilot] # session-start hook (called by hook, not manually)
|
|
155
|
+
squeez calibrate # auto-tune config from benchmarks
|
|
156
|
+
squeez budget-params <tool> # output JSON budget patch for tool
|
|
157
|
+
squeez --version
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Escape hatch — bypass compression for one command
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
--no-squeez git log --all --graph
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Prefix any command with `--no-squeez` to run it raw without squeez touching it.
|
|
167
|
+
|
|
168
|
+
### `squeez wrap`
|
|
169
|
+
|
|
170
|
+
Runs a command, compresses its output, and prints a savings header:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
# squeez [git log] 2692→289 tokens (-89%) 0.2ms [adaptive: Ultra]
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### `squeez filter`
|
|
177
|
+
|
|
178
|
+
Reads from stdin. Use for manual pipelines:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
git log --oneline | squeez filter git
|
|
182
|
+
docker logs mycontainer 2>&1 | squeez filter docker
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### `squeez compress-md`
|
|
186
|
+
|
|
187
|
+
Pure-Rust, zero-LLM compressor for markdown files. Preserves code blocks, inline code, URLs, headings, file paths, and tables. Compresses prose only. Always writes a backup at `<stem>.original.md`.
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
squeez compress-md CLAUDE.md # Full mode (English default)
|
|
191
|
+
squeez compress-md --ultra CLAUDE.md # + abbreviations (with→w/, fn, cfg, etc.)
|
|
192
|
+
squeez compress-md --lang pt CLAUDE.md # pt-BR locale (articles, fillers, phrases)
|
|
193
|
+
squeez compress-md --dry-run CLAUDE.md # preview, no write
|
|
194
|
+
squeez compress-md --all # compress all known locations automatically
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
When `auto_compress_md = true` (default), `squeez init` runs `--all` silently on every session start.
|
|
198
|
+
|
|
199
|
+
### `squeez benchmark`
|
|
200
|
+
|
|
201
|
+
Reproducible measurement of token reduction, cost, latency, and quality across 19 scenarios:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
squeez benchmark # human-readable report
|
|
205
|
+
squeez benchmark --json # JSON to stdout
|
|
206
|
+
squeez benchmark --output report.json # save JSON report
|
|
207
|
+
squeez benchmark --scenario git # run only git scenarios
|
|
208
|
+
squeez benchmark --iterations 5 # more iterations per scenario
|
|
209
|
+
squeez benchmark --list # list all scenarios
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Quality is scored by checking that **signal terms** (words from error/warning/failed lines in the baseline) survive compression. 19/19 pass at ≥ 50% threshold.
|
|
213
|
+
|
|
214
|
+
### `squeez mcp`
|
|
215
|
+
|
|
216
|
+
Runs a Model Context Protocol JSON-RPC 2.0 server over stdin/stdout. Hand-rolled, no `mcp.server` / `fastmcp` dependency — keeps the `libc`-only constraint intact. Wire it into Claude Code:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
claude mcp add squeez -- /path/to/squeez mcp
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Thirteen read-only tools become available to the LLM:
|
|
223
|
+
|
|
224
|
+
| Tool | Returns |
|
|
225
|
+
|------|---------|
|
|
226
|
+
| `squeez_recent_calls` | Last N bash invocations with hash + length + cmd snippet — check before re-running |
|
|
227
|
+
| `squeez_seen_files` | Files this session has touched, with access type (Read/Write/Created/Deleted), sorted by recency |
|
|
228
|
+
| `squeez_seen_errors` | Distinct error fingerprints observed this session (FNV-1a hashes of normalized errors) |
|
|
229
|
+
| `squeez_seen_error_details` | Error fingerprints with the first 128 chars of message text — find *what* the error was |
|
|
230
|
+
| `squeez_session_summary` | Token accounting + call counts (tokens_bash / tokens_read / tokens_other / seen_files / seen_errors / seen_git_refs) |
|
|
231
|
+
| `squeez_session_stats` | Dedup hit counts (exact + fuzzy), summarize triggers, Ultra-mode calls, tokens saved per category |
|
|
232
|
+
| `squeez_agent_costs` | Sub-agent usage: spawn count, cumulative estimated tokens, per-call breakdown |
|
|
233
|
+
| `squeez_session_efficiency` | Session efficiency scores: compression ratio, tool choice, context reuse, budget conservation (basis points) |
|
|
234
|
+
| `squeez_prior_summaries` | Last N finalized prior-session summaries with structured fields: investigated / learned / completed / next_steps |
|
|
235
|
+
| `squeez_search_history` | Full-text search across all session summaries — find when you last saw an error or touched a file |
|
|
236
|
+
| `squeez_file_history` | Sessions where a given file path was touched, with token-savings and commit status |
|
|
237
|
+
| `squeez_session_detail` | Full structured view of a past session by date: calls, files, errors, git events, test summary |
|
|
238
|
+
| `squeez_protocol` | Auto-teach payload — read once per session to learn squeez's markers + memory protocol |
|
|
239
|
+
|
|
240
|
+
All read-only. Backed by `SessionContext::load()`, `memory::read_last_n()`, and `memory::search_history()`. No side effects.
|
|
241
|
+
|
|
242
|
+
### `squeez protocol`
|
|
243
|
+
|
|
244
|
+
Prints the auto-teach payload — a 2.4 KB self-describing block covering:
|
|
245
|
+
|
|
246
|
+
- The 5-rule **memory protocol** (what to do with `[squeez: ...]` markers, when to call the MCP tools)
|
|
247
|
+
- The **output marker spec** (`# squeez [...]`, `[squeez: identical to ...]`, `[squeez: ~95% similar to ...]`, `squeez:summary`, `# squeez hint:`)
|
|
248
|
+
|
|
249
|
+
Same content the MCP `squeez_protocol` tool returns. Pipe it into a `system` prompt or paste it into a one-shot session that doesn't have the MCP server connected.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Configuration
|
|
254
|
+
|
|
255
|
+
Optional config file — all fields have defaults, none are required.
|
|
256
|
+
|
|
257
|
+
| Platform | Config path |
|
|
258
|
+
|----------|------------|
|
|
259
|
+
| Claude Code / default | `~/.claude/squeez/config.ini` |
|
|
260
|
+
| Copilot CLI | `~/.copilot/squeez/config.ini` |
|
|
261
|
+
|
|
262
|
+
```ini
|
|
263
|
+
# ── Compression ────────────────────────────────────────────────
|
|
264
|
+
max_lines = 200 # generic truncation limit
|
|
265
|
+
dedup_min = 3 # collapse lines appearing ≥N times
|
|
266
|
+
git_log_max_commits = 20
|
|
267
|
+
git_diff_max_lines = 150
|
|
268
|
+
docker_logs_max_lines = 100
|
|
269
|
+
find_max_results = 50
|
|
270
|
+
bypass = docker exec, psql, mysql, ssh # never compress these
|
|
271
|
+
|
|
272
|
+
# ── Context engine ─────────────────────────────────────────────
|
|
273
|
+
adaptive_intensity = true # truly adaptive: Full <80% budget, Ultra ≥80%
|
|
274
|
+
context_cache_enabled = true # track seen files/errors across calls
|
|
275
|
+
redundancy_cache_enabled = true # collapse identical OR fuzzy-similar recent outputs
|
|
276
|
+
summarize_threshold_lines = 500 # outputs above this trigger summarize fallback (×2 if benign)
|
|
277
|
+
compact_threshold_tokens = 120000 # session token budget — drives adaptive intensity
|
|
278
|
+
|
|
279
|
+
# ── Session memory ─────────────────────────────────────────────
|
|
280
|
+
memory_retention_days = 30
|
|
281
|
+
|
|
282
|
+
# ── Output / persona ───────────────────────────────────────────
|
|
283
|
+
persona = ultra # off | lite | full | ultra
|
|
284
|
+
auto_compress_md = true # run compress-md on every session start
|
|
285
|
+
lang = en # compress-md locale: en | pt (pt-BR) — more languages extensible
|
|
286
|
+
|
|
287
|
+
# ── Advanced tuning (rarely needed) ───────────────────────────
|
|
288
|
+
max_call_log = 32 # rolling call log depth (also caps redundancy window)
|
|
289
|
+
recent_window = 16 # how many recent calls are eligible for redundancy lookup
|
|
290
|
+
similarity_threshold = 0.85 # Jaccard threshold for fuzzy dedup (0.0–1.0)
|
|
291
|
+
ultra_trigger_pct = 0.80 # fraction of context budget at which Full → Ultra
|
|
292
|
+
mcp_prior_summaries_default = 5 # default n for squeez_prior_summaries
|
|
293
|
+
mcp_recent_calls_default = 10 # default n for squeez_recent_calls
|
|
294
|
+
|
|
295
|
+
# ── Token economy ─────────────────────────────────────────────
|
|
296
|
+
agent_warn_threshold_pct = 0.50 # warn when agent cost > 50% of budget
|
|
297
|
+
burn_rate_warn_calls = 20 # warn when < 20 calls remaining
|
|
298
|
+
agent_spawn_cost = 200000 # estimated tokens per Agent/Task spawn
|
|
299
|
+
read_max_lines = 0 # max lines injected into Read tool_input (0 = off)
|
|
300
|
+
grep_max_results = 0 # max results injected into Grep tool_input (0 = off)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Adaptive intensity — Full / Ultra split
|
|
304
|
+
|
|
305
|
+
When `adaptive_intensity = true` (default), squeez **actually adapts** to session pressure rather than always running Ultra:
|
|
306
|
+
|
|
307
|
+
| Used / budget | Tier | Scaling |
|
|
308
|
+
|---|---|---|
|
|
309
|
+
| `< 80%` | **Full** | ×0.6 limits, dedup_min ×0.66 (floor 2) |
|
|
310
|
+
| `≥ 80%` | **Ultra** | ×0.3 limits, dedup_min ×0.5 (floor 2) |
|
|
311
|
+
| `adaptive_intensity = false` | **Lite** | passthrough — no scaling |
|
|
312
|
+
|
|
313
|
+
Floors are enforced so we never reduce to zero: `max_lines ≥ 20`, `git_diff_max_lines ≥ 20`, `dedup_min ≥ 2`, `summarize_threshold_lines ≥ 50`.
|
|
314
|
+
|
|
315
|
+
The active level is shown in every bash header: `[adaptive: Full]` or `[adaptive: Ultra]`.
|
|
316
|
+
|
|
317
|
+
Pre-0.3 squeez was effectively always-Ultra. The new behavior preserves more verbatim text in the common case (empty / mid-session) and only graduates to aggressive compression when the context budget is genuinely under pressure.
|
|
318
|
+
|
|
319
|
+
### Caveman persona
|
|
320
|
+
|
|
321
|
+
Three intensity levels (`lite`, `full`, `ultra`) and `off`. Default is `ultra`. The persona prompt is injected into:
|
|
322
|
+
- The Claude Code session banner (printed at `SessionStart`)
|
|
323
|
+
- The `<!-- squeez:start -->…<!-- squeez:end -->` block in `~/.copilot/copilot-instructions.md` for Copilot CLI
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## How it works
|
|
328
|
+
|
|
329
|
+
### Compression pipeline
|
|
330
|
+
|
|
331
|
+
Each bash command passes through four strategies in order:
|
|
332
|
+
|
|
333
|
+
1. **smart_filter** — strips ANSI codes, progress bars, spinner chars, timestamps, and tool-specific noise (npm download lines, stack frame noise, etc.)
|
|
334
|
+
2. **dedup** — lines appearing ≥ `dedup_min` times are collapsed to one entry annotated `[×N]`
|
|
335
|
+
3. **grouping** — files in the same directory (≥5 siblings) are collapsed to `dir/ N modified [squeez grouped]`
|
|
336
|
+
4. **truncation** — `Head` (keep first N) or `Tail` (keep last N) depending on handler; truncated portion noted
|
|
337
|
+
|
|
338
|
+
### Supported handlers
|
|
339
|
+
|
|
340
|
+
| Category | Commands |
|
|
341
|
+
|----------|----------|
|
|
342
|
+
| Git | `git` |
|
|
343
|
+
| Docker / containers | `docker`, `docker-compose`, `podman` |
|
|
344
|
+
| Package managers | `npm`, `pnpm`, `bun`, `yarn` |
|
|
345
|
+
| Build systems | `make`, `cmake`, `gradle`, `mvn`, `xcodebuild`, `cargo` (build) |
|
|
346
|
+
| Test runners | `cargo test`, `jest`, `vitest`, `pytest`, `nextest` |
|
|
347
|
+
| TypeScript / linters | `tsc`, `eslint`, `biome` |
|
|
348
|
+
| Cloud CLIs | `kubectl`, `gh`, `aws`, `gcloud`, `az` |
|
|
349
|
+
| Databases | `psql`, `prisma`, `mysql` |
|
|
350
|
+
| Filesystem | `find`, `ls`, `du`, `ps`, `env`, `lsof`, `netstat` |
|
|
351
|
+
| JSON / YAML / IaC | `jq`, `yq`, `terraform`, `tofu`, `helm`, `pulumi` |
|
|
352
|
+
| Text processing | `grep`, `rg`, `awk`, `sed` |
|
|
353
|
+
| Network | `curl`, `wget` |
|
|
354
|
+
| Runtimes | `node`, `python`, `ruby` |
|
|
355
|
+
| Generic fallback | everything else |
|
|
356
|
+
|
|
357
|
+
### Hooks (Claude Code & Copilot CLI)
|
|
358
|
+
|
|
359
|
+
Three hooks work together automatically after install:
|
|
360
|
+
|
|
361
|
+
- **`PreToolUse`** — rewrites every Bash call: `git status` → `squeez wrap git status`
|
|
362
|
+
- **`SessionStart`** — runs `squeez init`: finalizes previous session into a memory summary, injects the persona prompt
|
|
363
|
+
- **`PostToolUse`** — runs `squeez track-result`: scans every tool result (Bash, Read, Grep, Glob) for file paths and errors, feeding `SessionContext`
|
|
364
|
+
|
|
365
|
+
### Cross-call redundancy
|
|
366
|
+
|
|
367
|
+
Two-path dedup across the last 16 calls:
|
|
368
|
+
|
|
369
|
+
**Exact match** — FNV-1a hash of the compressed output. When a subsequent call produces the same bytes, it collapses to:
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
[squeez: identical to 515ba5b2 at bash#35 — re-run with --no-squeez]
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
**Fuzzy match** — bottom-k MinHash over whitespace-token trigrams (k=96, Jaccard ≥ 0.85, length-ratio guard ≥ 0.80). Survives timestamp changes, added/removed blank lines, and single-line edits. Collapses to:
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
[squeez: ~92% similar to 515ba5b2 at bash#35 — re-run with --no-squeez]
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Minimum 6 lines to attempt fuzzy match (below that, exact-only).
|
|
382
|
+
|
|
383
|
+
### Summarize fallback
|
|
384
|
+
|
|
385
|
+
When raw output exceeds `summarize_threshold_lines` (default 500), the full pipeline is bypassed and replaced with a ≤40-line dense summary:
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
squeez:summary cmd=docker logs app
|
|
389
|
+
total_lines=5003
|
|
390
|
+
top_errors:
|
|
391
|
+
- error: connection refused on tcp://10.0.0.1:5432
|
|
392
|
+
top_files:
|
|
393
|
+
- /var/log/app/error.log
|
|
394
|
+
test_summary=FAILED: 3 of 248
|
|
395
|
+
tail_preserved=20
|
|
396
|
+
[last 20 lines verbatim...]
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Benign-aware threshold:** before summarizing, squeez scans for error markers (`error:`, `panic`, `traceback`, `FAILED`, `EXCEPTION`, `Fatal`). If none are found, the threshold is doubled (1,000 lines default) so successful builds, clean test runs, and uneventful logs stay verbatim unless they are genuinely huge.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Platform notes
|
|
404
|
+
|
|
405
|
+
### OpenCode
|
|
406
|
+
|
|
407
|
+
Plugin installed at `~/.config/opencode/plugins/squeez.js`. OpenCode auto-loads plugins on startup. All Bash commands are automatically compressed via `squeez wrap`.
|
|
408
|
+
|
|
409
|
+
### GitHub Copilot CLI
|
|
410
|
+
|
|
411
|
+
Hooks registered in `~/.copilot/settings.json`. Session memory written to `~/.copilot/copilot-instructions.md` (Copilot CLI reads this automatically). State stored separately at `~/.copilot/squeez/`.
|
|
412
|
+
|
|
413
|
+
Refresh memory manually:
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
SQUEEZ_DIR=~/.copilot/squeez ~/.claude/squeez/bin/squeez init --copilot
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## Local development
|
|
422
|
+
|
|
423
|
+
Requires Rust stable. Windows requires Git Bash.
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
git clone https://github.com/claudioemmanuel/squeez.git
|
|
427
|
+
cd squeez
|
|
428
|
+
|
|
429
|
+
cargo test # run all tests (356 tests, 37 suites)
|
|
430
|
+
cargo build --release # build release binary
|
|
431
|
+
|
|
432
|
+
bash bench/run.sh # filter-mode benchmark (14 fixtures)
|
|
433
|
+
bash bench/run_context.sh # context-engine benchmark (3 wrap scenarios)
|
|
434
|
+
./target/release/squeez benchmark # full 19-scenario benchmark suite
|
|
435
|
+
|
|
436
|
+
bash build.sh # build + install to ~/.claude/squeez/bin/
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Contributing
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
git checkout -b feature/your-change
|
|
445
|
+
cargo test
|
|
446
|
+
cargo build --release
|
|
447
|
+
bash bench/run.sh
|
|
448
|
+
git push -u origin feature/your-change
|
|
449
|
+
gh pr create --base main --title "Short title" --body "Description"
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
CI runs `cargo test`, `bench/run.sh`, `bench/run_context.sh`, and `squeez benchmark` on every push and pull request.
|
|
453
|
+
|
|
454
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for coding standards.
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## License
|
|
459
|
+
|
|
460
|
+
MIT — see [LICENSE](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squeez",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Hook-based token compressor for Claude Code, Copilot CLI, and OpenCode. Compresses bash output up to 95%, collapses redundant calls, injects caveman persona.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"url": "https://github.com/claudioemmanuel/squeez.git"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
+
"readme": "README.md",
|
|
22
23
|
"author": "claudioemmanuel",
|
|
23
24
|
"bin": {
|
|
24
25
|
"squeez": "bin.js"
|