[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-1548":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":13,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":42,"readmeContent":43,"aiSummary":44,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":45,"discoverSource":46},1548,"sqz","ojuschugh1\u002Fsqz","ojuschugh1","Compress LLM context to save tokens and reduce costs","https:\u002F\u002Fojuschugh1.github.io\u002Fsqz\u002F",null,"Rust",349,21,5,7,0,2,134,6,4.03,"Other",false,"main",true,[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"agentic-ai","ai","api","cli","context","cost-optimization","developer-tools","extensions","javascript","llms","open-source","python","rust","token","token-optimization","tokens","2026-06-12 02:00:29","\u003Cp align=\"center\">\n  \u003Cpre>\n  ███████╗ ██████╗ ███████╗\n  ██╔════╝██╔═══██╗╚══███╔╝\n  ███████╗██║   ██║  ███╔╝\n  ╚════██║██║▄▄ ██║ ███╔╝\n  ███████║╚██████╔╝███████╗\n  ╚══════╝ ╚══▀▀═╝ ╚══════╝\n  \u003C\u002Fpre>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Cstrong>Compress LLM context to save tokens and reduce costs\u003C\u002Fstrong>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Csub>\n    \u003Cstrong>Real session stats:\u003C\u002Fstrong>\n    3,003 compressions ·\n    \u003Cstrong>178,442 tokens saved\u003C\u002Fstrong> ·\n    24.7% avg reduction · up to\n    \u003Cstrong>92%\u003C\u002Fstrong> with dedup\n  \u003C\u002Fsub>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fthenextgentechinsider.com\u002Fpulse\u002Fsqz-tool-cuts-llm-token-use-by-92-for-file-heavy-ai-tasks\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%231_Featured-NextGen_Tech_Insider-ff6600?style=for-the-badge&logo=newspaper&logoColor=white\" alt=\"Featured\">\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fcrates.io\u002Fcrates\u002Fsqz-cli\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Fsqz-cli?logo=rust&logoColor=white&label=crates.io&color=e6522c\" alt=\"Crates.io\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fsqz-cli\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fv\u002Fsqz-cli?logo=npm&logoColor=white&label=npm&color=cb3837\" alt=\"npm\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpypi.org\u002Fproject\u002Fsqz\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fsqz?logo=python&logoColor=white&label=PyPI&color=3775a9\" alt=\"PyPI\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=ojuschugh1.sqz\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FVS%20Code-Marketplace-007acc?logo=visual-studio-code&logoColor=white\" alt=\"VS Code\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Faddons.mozilla.org\u002Fen-US\u002Ffirefox\u002Faddon\u002Fsqz-context-compression\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FFirefox-Add--on-ff7139?logo=firefox-browser&logoColor=white\" alt=\"Firefox\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fplugins.jetbrains.com\u002Fplugin\u002F31240-sqz--context-intelligence\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FJetBrains-Plugin-000000?logo=jetbrains&logoColor=white\" alt=\"JetBrains\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002Fj8EEyH5dSB\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F1493251029075235076?logo=discord&logoColor=white&label=Discord&color=5865F2\" alt=\"Discord\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fojuschugh1\u002Fhomebrew-sqz\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FHomebrew-tap-FBB040?logo=homebrew&logoColor=white\" alt=\"Homebrew\">\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"#install\">Install\u003C\u002Fa> ·\n  \u003Ca href=\"#how-it-works\">How It Works\u003C\u002Fa> ·\n  \u003Ca href=\"#supported-tools\">Supported Tools\u003C\u002Fa> ·\n  \u003Ca href=\"CHANGELOG.md\">Changelog\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002Fj8EEyH5dSB\">Discord\u003C\u002Fa>\n\u003C\u002Fp>\n\n---\n\nsqz compresses command output before it reaches your LLM. Single Rust binary, zero config.\n\nThe real win is dedup: when the same file gets read 5 times in a session, sqz sends it once and returns a 13-token reference for every repeat.\n\n```\nWithout sqz:                    With sqz:\n\nFile read #1:  2,000 tokens     File read #1:  ~800 tokens (compressed)\nFile read #2:  2,000 tokens     File read #2:  ~13 tokens  (dedup ref)\nFile read #3:  2,000 tokens     File read #3:  ~13 tokens  (dedup ref)\n───────────────────────         ───────────────────────\nTotal:         6,000 tokens     Total:         ~826 tokens (86% saved)\n```\n\n## Token Savings\n\n> **24.7%** average reduction across 3,003 real compressions ·\n> **92%** saved on repeated file reads ·\n> **86%** on shell\u002Fgit output ·\n> **13-token** refs for cached content\n\nOne developer's week, measured from actual `sqz gain` output:\n\n```\n$ sqz gain\nsqz token savings (last 7 days)\n──────────────────────────────────────────────────\n  04-13 │                              │   2,329 saved\n  04-14 │                              │       0 saved\n  04-15 │███                           │  12,954 saved\n  04-16 │██                            │   9,223 saved\n  04-17 │████                          │  14,752 saved\n  04-18 │██████████████████████████████│ 105,569 saved\n  04-19 │████████                      │  30,882 saved\n  04-20 │█                             │   4,334 saved\n──────────────────────────────────────────────────\n  Total: 3,003 compressions, 178,442 tokens saved (24.7% avg reduction)\n```\n\n### Per-command compression\n\nSingle-command compression (measured via `cargo test -p sqz-engine benchmarks`):\n\n| Content | Before | After | Saved |\n|---|---:|---:|---:|\n| Repeated log lines | 148 | 62 | **58%** |\n| Large JSON array | 259 | 142 | **45%** |\n| JSON API response | 64 | 53 | **17%** |\n| Git diff | 61 | 54 | **12%** |\n| Prose\u002Fdocs | 124 | 121 | **2%** |\n| Stack trace (safe mode) | 82 | 82 | **0%** |\n\n### Session-level with dedup\n\nWhere the real savings live — the cache sends each file once, repeats cost 13 tokens:\n\n| Scenario | Without sqz | With sqz | Saved |\n|---|---:|---:|---:|\n| Same file read 5× | 10,000 | 826 | **92%** |\n| Same JSON response 3× | 192 | 79 | **59%** |\n| Test-fix-test cycle (3 runs) | 15,000 | 5,186 | **65%** |\n\nSingle-command compression ranges from 2–58% depending on content. Repeated reads drop to 13 tokens each. Your mileage will vary with how repetitive your tool calls are — agentic sessions with many file re-reads see the biggest wins.\n\n## Install\n\n**Prebuilt binaries** (no compiler required — works on every platform):\n\n```sh\n# macOS \u002F Linux\ncurl -fsSL https:\u002F\u002Fraw.githubusercontent.com\u002Fojuschugh1\u002Fsqz\u002Fmain\u002Finstall.sh | sh\n\n# Windows (PowerShell)\nirm https:\u002F\u002Fraw.githubusercontent.com\u002Fojuschugh1\u002Fsqz\u002Fmain\u002Finstall.ps1 | iex\n\n# Any platform via npm\nnpm install -g sqz-cli\n\n# macOS \u002F Linux via Homebrew\nbrew tap ojuschugh1\u002Fsqz\nbrew install sqz\n```\n\n**Build from source via Cargo:**\n\n```sh\ncargo install sqz-cli sqz-mcp\n```\n\n`sqz-cli` provides the `sqz` binary; `sqz-mcp` provides the MCP server. `sqz-engine` is a library dependency — it compiles automatically and does not need to be installed separately.\n\n**Build from source** (`cargo install sqz-cli`) works too, but needs a C toolchain:\n\n- Linux: `build-essential` (apt) or equivalent\n- macOS: Xcode Command Line Tools (`xcode-select --install`)\n- **Windows: Visual Studio Build Tools with the \"Desktop development with C++\" workload.** Without these, `cargo install` fails with `linker link.exe not found`. If you don't already have them, use the PowerShell or npm install above instead.\n\nThen initialize:\n\n```sh\nsqz init --global     # hooks apply to every project on this machine\n# or\nsqz init              # hooks apply to just this project (.claude\u002Fsettings.local.json)\n```\n\n`--global` writes to `~\u002F.claude\u002Fsettings.json` (the user scope per the\n[Anthropic scope table](https:\u002F\u002Fdocs.claude.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fsettings)),\nso the sqz hook fires in every Claude Code session on this machine. This is\nthe common case on first install. Your existing `permissions`, `env`,\n`statusLine`, and unrelated hooks in `~\u002F.claude\u002Fsettings.json` are\npreserved — sqz merges its entries rather than overwriting.\n\nPlain `sqz init` (project scope) is useful when you want sqz active only\ninside one repo.\n\n**Only using one agent?** Pass `--only` (or `--skip`) to limit which\nconfigs are written:\n\n```sh\nsqz init --only opencode              # just OpenCode, nothing else\nsqz init --only opencode,codex        # OpenCode and Codex\nsqz init --skip cursor,windsurf       # everything except Cursor and Windsurf\n```\n\nAccepted names: `claude`, `cursor`, `windsurf`, `cline`, `gemini`,\n`opencode`, `codex`. Aliases (`claude-code`, `gemini-cli`, `roo`) also\nwork. `--only` and `--skip` can't be combined.\n\n### Manual installation (preserve comments in your config)\n\n`sqz init` round-trips your config file through a JSON parser to merge\nthe sqz entry, which drops any comments in your `opencode.jsonc` (and\nthe analogous JSON-with-comments files other tools accept). If you've\ncommented your config carefully and want to keep them, install by hand\ninstead.\n\n**OpenCode** — two steps:\n\n1. Drop the plugin file in place. `sqz` prints the generated TS to\n   stdout so you don't have to hand-write the path-escaping logic:\n\n   ```sh\n   mkdir -p ~\u002F.config\u002Fopencode\u002Fplugins\n   sqz print-opencode-plugin > ~\u002F.config\u002Fopencode\u002Fplugins\u002Fsqz.ts\n   ```\n\n2. Add the MCP entry to your existing `opencode.jsonc` yourself.\n   Append this block inside the top-level `mcp` object (create the\n   `mcp` object if it doesn't exist):\n\n   ```jsonc\n   \"sqz\": {\n     \"type\": \"local\",\n     \"command\": [\"sqz-mcp\", \"--transport\", \"stdio\"],\n     \"enabled\": true\n   }\n   ```\n\nComments in the rest of your file stay put. OpenCode auto-discovers\nthe plugin file; no `plugin` array entry needed (adding one causes\ndouble-loading, see issue #10).\n\n**Other tools** — Claude Code, Cursor, Windsurf, Cline, Gemini CLI,\nand Codex use plain JSON configs without comment support, so the\nautomated path is non-destructive there. Use `sqz init --only \u003Ctool>`\nfor those.\n\nThat's it. Shell hooks installed, AI tool hooks configured.\n\n## How It Works\n\nsqz installs a PreToolUse hook that intercepts bash commands before your AI tool runs them. The output gets compressed transparently — the AI tool never knows.\n\n```\nClaude → git status → [sqz hook rewrites] → compressed output (85% smaller)\n```\n\nWhat gets compressed:\n- **Shell output** — git, cargo, npm, docker, kubectl, ls, grep, etc.\n- **JSON** — strips nulls, compact encoding\n- **Logs** — collapses repeated lines\n- **Test output** — shows failures only\n\nWhat doesn't get compressed:\n- Stack traces, error messages, secrets — routed to safe mode (0% compression)\n- Your prompts and the AI's responses — controlled by the AI tool, not sqz\n\n## Supported Tools\n\n| Tool | Integration | Setup |\n|---|---|---|\n| Claude Code | PreToolUse hook (transparent) | `sqz init` |\n| Cursor | PreToolUse hook (transparent) | `sqz init` |\n| Windsurf | PreToolUse hook (transparent) | `sqz init` |\n| Cline | PreToolUse hook (transparent) | `sqz init` |\n| Gemini CLI | BeforeTool hook (transparent) | `sqz init` |\n| OpenCode | TypeScript plugin (transparent) | `sqz init` |\n| VS Code | [Extension](https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=ojuschugh1.sqz) | Install from Marketplace |\n| JetBrains | [Plugin](https:\u002F\u002Fplugins.jetbrains.com\u002Fplugin\u002F31240-sqz--context-intelligence\u002F) | Install from Marketplace |\n| Chrome | Browser extension | ChatGPT, Claude.ai, Gemini, Grok, Perplexity |\n| [Firefox](https:\u002F\u002Faddons.mozilla.org\u002Fen-US\u002Ffirefox\u002Faddon\u002Fsqz-context-compression\u002F) | Browser extension | Same sites |\n\n## CLI\n\n```sh\nsqz init --global             # Install hooks for every project on this machine\nsqz init                      # Install hooks for just this project\nsqz init --only opencode      # Only configure OpenCode (skip the rest)\nsqz init --skip cursor        # Configure every agent except Cursor\nsqz compress \u003Ctext>           # Compress (or pipe from stdin)\nsqz compress --no-cache       # Compress without dedup (always full output)\nsqz expand \u003Cref>              # Recover original content from a §ref:HASH§ token\nsqz compact                   # Evict stale context to free tokens\nsqz gain                      # Show daily token savings\nsqz stats                     # Cumulative report\nsqz discover                  # Find missed savings\nsqz resume                    # Re-inject session context after compaction\nsqz hook claude               # Process a PreToolUse hook\nsqz proxy --port 8080 # API proxy (compresses full request payloads)\n```\n\n### Dedup Escape Hatch\n\nWhen sqz sees the same content twice, it returns a compact `§ref:HASH§` token\ninstead of the full text. Most models handle this fine, but some (e.g., GLM 5.1)\ncan't parse the ref format and loop. Four ways to work around this:\n\n```sh\n# 1. Recover original content from a ref\nsqz expand a1b2c3d4              # prefix match\nsqz expand '§ref:a1b2c3d4§'     # paste the whole token\n\n# 2. Compress without dedup (per-invocation)\necho \"...\" | sqz compress --no-cache\n\n# 3. Disable dedup globally (env var)\nexport SQZ_NO_DEDUP=1\n\n# 4. MCP passthrough tool (returns input byte-exact, zero transforms)\n# Available via tools\u002Flist when sqz-mcp is running\n```\n\n## Track Your Own Savings\n\nRun `sqz gain` in your shell any time to see your own daily breakdown (see the\nToken Savings section above for what the output looks like), and `sqz stats`\nfor the full cumulative report:\n\n```sh\n$ sqz stats\n┌─────────────────────────┬──────────────────┐\n│           sqz compression stats            │\n├─────────────────────────┼──────────────────┤\n│ Total compressions      │            3,003 │\n│ Tokens saved            │          178,442 │\n│ Avg reduction           │            24.7% │\n│ Cache entries           │               43 │\n│ Cache size              │          39.1 KB │\n└─────────────────────────┴──────────────────┘\n```\n\nStats are stored locally in SQLite under `~\u002F.sqz\u002Fsessions.db` — nothing leaves your machine.\n\n## How Compression Works\n\n1. **Per-command formatters** — `git status` → compact summary, `cargo test` → failures only, `docker ps` → name\u002Fimage\u002Fstatus table\n2. **Structural summaries** — code files compressed to imports + function signatures + call graph (~70% reduction). The model sees the architecture, not implementation noise.\n3. **Dedup cache** — SHA-256 content hash, persistent across sessions. Second read = 13-token reference.\n4. **JSON pipeline** — strip nulls → project out debug fields → flatten → collapse arrays → TOON encoding (lossless compact format)\n5. **Safe mode** — stack traces, secrets, migrations detected by entropy analysis and routed through with 0% compression\n\nFor the full technical details, see [docs\u002F](docs\u002F).\n\n## Configuration\n\n```toml\n# ~\u002F.sqz\u002Fpresets\u002Fdefault.toml\n[preset]\nname = \"default\"\nversion = \"1.0\"\n\n[compression.condense]\nenabled = true\nmax_repeated_lines = 3\n\n[compression.strip_nulls]\nenabled = true\n\n[budget]\nwarning_threshold = 0.70\ndefault_window_size = 200000\n```\n\n## Privacy\n\n- Zero telemetry — no data transmitted, no crash reports\n- Fully offline — works in air-gapped environments\n- All processing local\n\n## Development\n\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002Fojuschugh1\u002Fsqz.git\ncd sqz\ncargo test --workspace\ncargo build --release\n```\n\n## License\n\n[Elastic License 2.0](LICENSE) (ELv2) — use, fork, modify freely. Two restrictions: no competing hosted service, no removing license notices.\n\n## Links\n\n- [Benchmark: sqz vs rtk](docs\u002Fbenchmark-vs-rtk.md)\n- [Discord](https:\u002F\u002Fdiscord.gg\u002Fj8EEyH5dSB)\n- [Changelog](CHANGELOG.md)\n\n## Star History\n\n\u003Ca href=\"https:\u002F\u002Fstar-history.com\u002F#ojuschugh1\u002Fsqz&Date\">\n \u003Cpicture>\n   \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=ojuschugh1\u002Fsqz&type=Date&theme=dark\" \u002F>\n   \u003Csource media=\"(prefers-color-scheme: light)\" srcset=\"https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=ojuschugh1\u002Fsqz&type=Date\" \u002F>\n   \u003Cimg alt=\"Star History Chart\" src=\"https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=ojuschugh1\u002Fsqz&type=Date\" width=\"600\" \u002F>\n \u003C\u002Fpicture>\n\u003C\u002Fa>\n","sqz 是一个用于压缩大型语言模型（LLM）上下文以节省令牌并降低成本的工具。它通过在命令输出到达LLM之前对其进行压缩来实现这一目标，特别擅长于去重处理，即当同一文件在一个会话中被多次读取时，sqz仅发送一次该文件，并为后续读取提供一个简短的引用，从而显著减少令牌使用量。项目采用Rust编写，提供单个二进制文件且无需配置，适用于需要频繁处理大量文本数据的AI应用场景，如文件密集型任务、开发者工具等，能够有效提升效率同时降低运行成本。","2026-06-11 02:44:36","CREATED_QUERY"]