feat(pr2): compress-md, caveman persona, squeez update, track-result hook#11
Closed
claudioemmanuel wants to merge 1 commit intofeat/context-enginefrom
Closed
feat(pr2): compress-md, caveman persona, squeez update, track-result hook#11claudioemmanuel wants to merge 1 commit intofeat/context-enginefrom
claudioemmanuel wants to merge 1 commit intofeat/context-enginefrom
Conversation
PR2 of two. Stacks on the context engine from PR1 and lands the user-facing features that make squeez attack input + output + memory-file tokens at maximum aggression by default. Highlights: - squeez compress-md — pure-Rust, zero-LLM caveman-style markdown compressor. Line-based state machine preserves fenced code blocks, inline code, URLs (bare + markdown link targets), headings, tables, list markers, and version strings; only natural-language prose is compressed. Drops articles + fillers + pleasantries + hedging everywhere. --ultra additionally substitutes with→w/, function→fn, configuration→config, repository→repo, etc. Damage heuristic aborts the write if any code block, URL, or heading was lost. Backups go to <stem>.original.md and are never overwritten. - Caveman persona — three intensity levels (lite/full/ultra) shipped via include_str!. Default is Ultra. Injected into the squeez init banner (Claude Code) and into the <!-- squeez:start --> block in ~/.copilot/copilot-instructions.md (Copilot CLI). - auto_compress_md=true — squeez init runs compress-md --all silently on every session start. Idempotent: backup is only written once and the integrity check guarantees safety. - squeez update — self-updater. Shells out to curl + sha256sum/shasum (both already required by install.sh) so we stay zero-dep. Atomic on Unix via .new + rename; documented .new + manual move on Windows. Override base URL via SQUEEZ_UPDATE_URL_OVERRIDE for tests. --check reports without installing; --insecure skips checksum. - squeez track-result + posttooluse hook update — PostToolUse now pipes the raw JSON for every tool call (Read, Grep, LS, Glob, ...) into squeez track-result, which extracts file paths + errors from the result content and feeds them into SessionContext. Future bash calls dedup against this state via the cross-call hint added in PR1. - Config additions: persona (default Ultra), auto_compress_md (default true). Both opt-out via config.ini. Tests: 230 passing (was 162). New integration tests for compress_md (13), persona (8), track_result (6), update (8). New mdcompress_* bench fixtures show ~22-27% reduction (caveman LLM gets ~45% with API calls; we get ~25% with zero API calls in <5ms). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR2 of two implementing the squeez token-optimizer roadmap. Stacks on #10 (PR1: context engine). Lands the user-facing pieces that make squeez attack input + output + memory-file tokens at maximum aggression by default.
What's in PR2
squeez compress-md— pure-Rust caveman markdown compressorText/FencedCode/Table) walks input once--ultraadds substitutions:with→w/,function→fn,configuration→config,repository→repo,because→b/c, etc.<stem>.original.md; never overwritten on subsequent runs--all:~/.claude/CLAUDE.md,~/.copilot/copilot-instructions.md,$PWD/CLAUDE.md,$PWD/AGENTS.md,$PWD/.github/copilot-instructions.mdCaveman persona (default Ultra)
lite/full/ultra) shipped viainclude_str!fromassets/persona_*.mdsqueez initbanner (Claude Code) and<!-- squeez:start --> ... <!-- squeez:end -->block in~/.copilot/copilot-instructions.mdauto_compress_md=true(default)squeez initrunscompress-md --allsilently on every session startsqueez updatecurl+sha256sum/shasum -a 256(both already required byinstall.sh) — zero new dependencies.new+rename); on Windows, writes.new+ printsmoveinstructions--checkreports without installing;--insecureskips checksum verificationSQUEEZ_UPDATE_URL_OVERRIDEfor test injectionsqueez track-result+posttooluse.shextensionPostToolUsehook tail pipes raw tool JSON intosqueez track-result <tool>Read/Grep/LS/Glob/Bashresults intoSessionContextConfig additions
Both opt-out — set
persona = offandauto_compress_md = falseto disable.Test plan
cargo test— 230 passing (was 162). Added:test_compress_md.rs(13),test_persona.rs(8),test_track_result.rs(6),test_update.rs(8) + inline unit tests in each new module.cargo build --release— cleanbench/run.sh— 14/14 fixtures pass, including newmdcompress_claude_md(23%) andmdcompress_prose(27%) at <5ms latencybench/run_context.sh— 3/3 (PR1 features still work)target/release/squeez init— banner showsPersona: ultra+ the full persona texttarget/release/squeez compress-md --dry-run --ultra <file>— preserves code/URLs/headings, compresses prose, reports statstarget/release/squeez track-result Readwith synthetic stdin — file path lands inseen_filestarget/release/squeez update --check— fails gracefully (no GitHub releases yet); will work after first release publishedCompression numbers
mdcompress_claude_md.txt(mixed prose + code)mdcompress_prose.txt(pure prose)Caveman's LLM-based compressor reports ~45% on similar files, but at the cost of an Anthropic API roundtrip per file. squeez does the local pass deterministically in <5ms with no network call.
Risks & mitigations
compress-mdcorruptingCLAUDE.mdpersona = lite|full|offsqueez updateon Windows can't replace running .exe.new+ manualmoveshimtrack-resultslowing PostToolUse🤖 Generated with Claude Code