{"id":49254680,"url":"https://github.com/neolambo/glyph-compress","last_synced_at":"2026-07-25T22:00:28.035Z","repository":{"id":353651587,"uuid":"1220381585","full_name":"Neolambo/glyph-compress","owner":"Neolambo","description":"⚡ Semantic compression for IDE↔LLM communication. Save 80%+ tokens with radical glyphs. Supports OpenAI, Claude, VS Code, Antigravity.","archived":false,"fork":false,"pushed_at":"2026-07-18T15:06:36.000Z","size":8162,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-07-18T22:00:13.064Z","etag":null,"topics":["ai","coding-agents","developer-tools","llm","prompt-engineering","semantic-compression","token-optimization","vscode-extension"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Neolambo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["Neolambo"],"custom":["https://buymeacoffee.com/neolambo","mailto:campiossasco1@gmail.com"]}},"created_at":"2026-04-24T20:57:39.000Z","updated_at":"2026-07-18T15:06:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"04f01b35-1759-4ba6-95d8-a9ba95f3df13","html_url":"https://github.com/Neolambo/glyph-compress","commit_stats":null,"previous_names":["neolambo/glyph-compress"],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/Neolambo/glyph-compress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neolambo%2Fglyph-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neolambo%2Fglyph-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neolambo%2Fglyph-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neolambo%2Fglyph-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neolambo","download_url":"https://codeload.github.com/Neolambo/glyph-compress/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neolambo%2Fglyph-compress/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35894020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-25T02:00:06.922Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","coding-agents","developer-tools","llm","prompt-engineering","semantic-compression","token-optimization","vscode-extension"],"created_at":"2026-04-25T02:10:55.536Z","updated_at":"2026-07-25T22:00:28.001Z","avatar_url":"https://github.com/Neolambo.png","language":"JavaScript","funding_links":["https://github.com/sponsors/Neolambo","https://buymeacoffee.com/neolambo","mailto:campiossasco1@gmail.com"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e⚡ GlyphCompress\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/logo.png\" alt=\"GlyphCompress Logo\" width=\"300\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/glyph-compress\"\u003e\u003cimg src=\"https://badgen.net/npm/v/glyph-compress\" alt=\"NPM Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/AGPL-3.0\"\u003e\u003cimg src=\"https://badgen.net/badge/License/AGPL-3.0-only/blue\" alt=\"License: AGPL-3.0-only\"\u003e\u003c/a\u003e\n  \u003ca href=\"COMMERCIAL_LICENSE.md\"\u003e\u003cimg src=\"https://badgen.net/badge/Commercial%20License/required%20for%20proprietary%20use/red\" alt=\"Commercial License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://marketplace.visualstudio.com/items?itemName=neolambo.glyph-compress\"\u003e\u003cimg src=\"https://badgen.net/badge/VS%20Code%20Marketplace/available/blue\" alt=\"VS Code Marketplace\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/Neolambo/glyph-compress/releases\"\u003e\u003cimg src=\"https://badgen.net/github/release/Neolambo/glyph-compress\" alt=\"GitHub Release\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eSemantic compression for IDE↔LLM communication — CLI, VS Code extension, and MCP server, with reversible-by-default compression calibrated against real provider tokenizers.\u003c/strong\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  Up to 90%+ savings on well-suited payloads (see benchmarks below); real aggregate savings on the project's own benchmark suite is a more modest, honestly-reported 22%.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#-quick-start\"\u003eQuick Start\u003c/a\u003e ·\n  \u003ca href=\"#-usage-command-line-cli\"\u003eCLI\u003c/a\u003e ·\n  \u003ca href=\"#-mcp-server-claude-code-claude-desktop--other-mcp-clients\"\u003eMCP Server\u003c/a\u003e ·\n  \u003ca href=\"#-when-to-use-glyphcompress-and-when-to-skip-it\"\u003eWhen to Use / Skip\u003c/a\u003e ·\n  \u003ca href=\"#-benchmarks\"\u003eBenchmarks\u003c/a\u003e ·\n  \u003ca href=\"https://github.com/Neolambo/glyph-compress/releases\"\u003eReleases\u003c/a\u003e ·\n  \u003ca href=\"ROADMAP.md\"\u003eRoadmap\u003c/a\u003e ·\n  \u003ca href=\"llms.txt\"\u003ellms.txt\u003c/a\u003e ·\n  \u003ca href=\"LICENSE\"\u003eLicense\u003c/a\u003e\n\u003c/p\u003e\n\nGlyphCompress uses a compositional radical-based encoding system (inspired by Chinese logograms) to compress the verbose context exchanged between IDEs and Large Language Models. A shared codebook injected into the LLM's system prompt enables it to decode compact glyph sequences back into full semantic concepts.\n\n### 🎬 See it in Action\n\nWatch the latest YouTube video to see how GlyphCompress achieves 90% token savings:\n\n- ⚙️ **[Data Flow Architecture](https://youtu.be/XRwRYEsReJU)**: A graphical animation showing how the engine minifies and translates verbose code into dense semantic glyphs.\n\n---\n\n## 📌 Table of Contents\n\n- [🎯 The Problem](#-the-problem)\n- [✨ The Solution](#-the-solution)\n- [🧭 When to Use GlyphCompress (and When to Skip It)](#-when-to-use-glyphcompress-and-when-to-skip-it)\n- [🔍 Realistic Session Showcase](#-realistic-session-showcase)\n- [🧠 Advanced Features: Holographic Folding, Intent Diffs \u0026 History Decay](#-advanced-features-holographic-folding-intent-diffs--history-decay)\n- [📊 Benchmarks](#-benchmarks)\n- [🚀 Usage: Command Line (CLI)](#-usage-command-line-cli)\n- [🚀 Quick Start (Code \u0026 Extension)](#-quick-start)\n- [👻 The Ultimate Magic: Zero-Command Transparent Proxy](#-the-ultimate-magic-zero-command-transparent-proxy-v050)\n- [🔌 MCP Server (Claude Code, Claude Desktop \u0026 other MCP clients)](#-mcp-server-claude-code-claude-desktop--other-mcp-clients)\n- [🔤 The Glyph Protocol](#-the-glyph-protocol)\n- [👥 Contributing](#-contributing)\n- [⚖️ Dual Licensing Model](#%EF%B8%8F-dual-licensing-model)\n\n---\n\n## 🎯 The Problem\n\nEvery IDE→LLM request carries massive, redundant context. As coding sessions grow longer, the **chat history** accumulates exponentially, causing token costs to explode, performance to lag, and LLMs to hit context window limits:\n\n```\nSystem prompt:             ~2,000 tokens (repeated every time)\nOpen files:                ~3,000 tokens\nErrors/diagnostics:        ~500 tokens  \nChat history (multi-turn): ~4,000 tokens (explodes exponentially)\nUser prompt:               ~500 tokens\n─────────────────────────────────────────\nTOTAL:                     ~10,000 tokens/request\n```\n\nAt 50 requests/day → **500K tokens/day** → $8-15/day on Claude/GPT-4.\n\n## ✨ The Solution\n\nGlyphCompress intercepts outgoing LLM requests, compresses context using a shared codebook, and utilizes **experimental Attentional Decay Compaction (ADC)** to progressively condense older history into summaries, saving **80-90% of tokens** and enabling **near-infinite multi-turn chats**:\n\n```\nBEFORE (1,734 chars):\n  { prompt: \"Fix the error in UserProfile.tsx\",\n    files: [{ path: \"src/components/UserProfile.tsx\", content: \"...44 lines...\" }],\n    diagnostics: [{ code: \"TS2339\", message: \"Property 'department' does not exist on type 'User'\" }] }\n\nAFTER (137 chars):\n  [F: ◈₍1₎=src/components/UserProfile.tsx]\n  ⺌✗ ◈₍1₎\n  ◈₍1₎ᵗ [imp:5 exp:1 ◇:4 ⟿:2 ⟳:5 44L]\n  ◈₍1₎:42 ✗∉prop 'department'∉User\n\n→ 12.7x compression, 92% saved\n```\n\n## 🧭 When to Use GlyphCompress (and When to Skip It)\n\nThis project reports honest numbers, not just best cases — so here's the direct answer on fit, backed by the measurements in [📏 Benchmark Snapshot](#-benchmark-snapshot-v1300) and [🧪 Realistic Benchmark Notes](#-realistic-benchmark-notes) below.\n\n**Good fit:**\n- **Code-heavy payloads** — source files, diffs, diagnostics. `ultra` shows real, structural token savings here (up to ~1.2x on this repository's own source), and identifiers/imports/structure survive intact via the source map.\n- **Multi-turn IDE chat sessions** — the shared codebook is a one-time cost amortized across turns; Anthropic's cache-adjusted estimate on this repo's fixtures is ~28% even though the raw transmitted payload alone is closer to break-even.\n- **Multi-file context** (Holographic Folding) and **git-diff review** (Intent Diffs) — structurally repetitive payloads where deterministic substitution has the most to work with.\n- **Long-running conversations** that would otherwise blow a context window — Attentional Decay Compaction trades old-turn fidelity for indefinite session length, on purpose.\n\n**Weak fit — GlyphCompress says so itself:**\n- **Short, Unicode-light prose requests.** The ~400-token codebook header can outweigh what a small payload saves; the net-negative fallback (as of v1.30.0, requiring a real measured 10% improvement) detects this and sends the original unchanged rather than risking a silent regression.\n- **One-off, single-turn requests on plain English text** — there's no repeated content for the dynamic dictionary to amortize, and no multi-turn cache to spread the codebook cost over.\n- **Anything where you need the LLM to see exact original text** (e.g., verbatim quoting requirements, legal/contract review) — use `trustPolicy: lossless` or skip compression for that specific payload; `lossy`/`ultra` levels are explicitly irreversible by design.\n\n**Not a substitute for:** provider-side prompt caching (Anthropic `cache_control`, OpenAI/Gemini implicit caching) — GlyphCompress **complements** caching (see the Anthropic hybrid wrapper) rather than replacing it; caching only helps repeated prefixes across calls, GlyphCompress reduces the token count of the content itself.\n\n## 🔍 Realistic Session Showcase\n\nGlyphCompress includes a built-in interactive demo benchmark (`npm run demo`) simulating real-world developer tasks (React debugging, SQL optimization, Python ML pipelines, YAML config) to measure character and token reduction. \n\nHere is what a typical compressed session telemetry looks like:\n\n### 1. Fix TypeScript diagnostic in React Component\n* **Original Context**: `1,734 chars` (includes `UserProfile.tsx` contents, history, and TS2339 error code).\n* **Compressed Output**: `137 chars` (**12.7x compression, 92% saved**).\n* **Emitted Payload**:\n  ```text\n  [F: ◈₍1₎=src/components/UserProfile.tsx]\n  ⺌✗ ◈₍2₎\n  ◈₍1₎ᵗ [imp:5 exp:1 ◇:4 ⟿:2 ⟳:5 44L]\n  ◈₍1₎:42 ✗∉prop 'department'∉User\n  [T1:U:⺍▲] [T2:A:⺍▲]\n  ```\n\n### 2. Optimize slow Prisma/SQL API endpoint\n* **Original Context**: `1,999 chars` (includes two TS controller/service files, Express imports, and history).\n* **Compressed Output**: `195 chars` (**10.3x compression, 90% saved**).\n* **Emitted Payload**:\n  ```text\n  [F: ⊜₍3₎=src/controllers/orders.controller.ts | ⊜₍4₎=src/services/order.service.ts]\n  ⺋ the orders API endpoint\n  ⊜₍3₎ᵗ [imp:3 exp:1 20L]\n  ⊜₍4₎ᵗ [imp:1 exp:1 26L]\n  [T1:U:The /api/orders endp] [T2:A:⺎▼]\n  ```\n\n### 3. Deploy application to Kubernetes\n* **Original Context**: `730 chars` (includes raw Kubernetes Deployment YAML block and prompt).\n* **Compressed Output**: `84 chars` (**8.7x compression, 88% saved**).\n* **Emitted Payload**:\n  ```text\n  [F: ◊₍5₎=k8s/deployment.yaml]\n  ⺏ the application→the production 𝒦 cluster\n  ◊₍5₎ [27L]\n  ```\n\n### 4. Debug Python ML preprocessing pipeline\n* **Original Context**: `1,925 chars` (includes `preprocess.py` content, scikit-learn imports, and active diagnostics).\n* **Compressed Output**: `249 chars` (**7.7x compression, 87% saved**).\n* **Emitted Payload**:\n  ```text\n  [F: ◇₍6₎=src/pipeline/preprocess.py]\n  ⺃ the data preprocessing pipeline\n  ◇₍6₎ᵖ [imp:2 𝒞:1 37L]\n  ◇₍6₎:18 ⚠⚠unused Unused import train_test_split\n  ◇₍6₎:25 ⚠ FutureWarning: DataFrame.fillna with 'method' is deprecated\n  [T1:U:The pipeline crashes] [T2:A:⺎▼]\n  ```\n\n### 📊 Session Aggregate Efficiency (Amortized Cost)\n* **Amortized Monthly Savings (Claude Sonnet @ $3/M tokens)**: Saves **$5.85/month** for a single developer at just 50 requests/day, scaling exponentially for teams.\n\n## 🧠 Advanced Features: Holographic Folding, Intent Diffs \u0026 History Decay\n\nGlyphCompress includes state-of-the-art context optimization layers designed for large, multi-turn, and multi-file developer workflows.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eShow all 4 advanced features in detail\u003c/strong\u003e (Holographic Folding, Intent Diffs, Attentional Decay, Team Codebook Registry)\u003c/summary\u003e\n\n### 1. Holographic Context Folding (v1.15.0)\nHolographic Folding analyzes import relationships across multiple files in your prompt. Instead of sending repetitive, boilerplated imports for each file, it extracts them into a single `Base` shared header and presents the files as structured overlays:\n* **How it works**: Detects mutual dependencies and group-folds files that share imports.\n* **Format**: `⟦Base: import A | import B⟧ ↷ [◈Ref struct ↷ ◈Ref struct]`\n* **Savings**: Up to 40% character/token reduction on multi-file contexts.\n* **Activation**:\n  * **CLI**: `--folding` (or `--holographic-folding`)\n  * **VS Code**: Toggle `\"glyphCompress.holographicFolding\": true` in settings.\n\n\u003e [!NOTE]\n\u003e For example, when reading two dependent React component files, the middleware extracts the common React imports and groups their core declarations to avoid LLM token overhead on repeating boilerplate.\n\n### 2. Generative Intent Diffs (v1.15.0)\nGenerative Intent Diffs intercept git/IDE unified diffs (which are traditionally very verbose and costly for LLMs) and translate them into a sequence of structural action lines:\n* **How it works**: Syntactically parses addition (`+`) and deletion (`-`) blocks to summarize added/deleted classes (`▲𝒞` / `▼𝒞`), functions (`▲ƒ` / `▼ƒ`), or packages (`▲📦` / `▼📦`).\n* **Format**: `⚡: ⊝₍1₎ ▼𝒞 OldClass | ⊝₍1₎ ▲𝒞 NewClass` (or `⚡: ◈ ±LineCount` for non-symbol changes).\n* **Savings**: Over 80% token savings on code refactoring context.\n* **Activation**:\n  * **CLI**: `--intents` (or `--intent-diffs`)\n  * **VS Code**: Toggle `\"glyphCompress.intentDiffs\": true` in settings.\n\n\u003e [!TIP]\n\u003e This feature is exceptionally powerful when using git diffs in Cline, RooCode, or Cursor chats. The engine strips the massive `+` and `-` source lines, sending only the semantic intention of the refactor.\n\n### 3. Attentional Decay Compaction (ADC) (v1.14.0)\nAttentional Decay simulates human memory inside the multi-turn chat transcript. As the conversation progresses, older messages are progressively compacted into dense, emoji-tagged summaries while keeping the latest turns in high-fidelity full text.\n* **How it works**: Categorizes chat history into 4 decay zones based on distance from the current turn:\n  * **Hot Zone** (turns 1-2): 100% full text.\n  * **Warm Zone** (turns 3-4): Light minification.\n  * **Cool Zone** (turns 5-6): Semantic summaries.\n  * **Cold Zone** (turns 7+): Highly compressed language-tagged bullet-point glyph summaries.\n* **Savings**: Prevents chat history token explosion, enabling near-infinite conversation length.\n* **Activation**:\n  * **CLI**: `--decay` (or `--experimental-decay`)\n  * **VS Code**: Toggle `\"glyphCompress.experimentalDecay\": true` in settings.\n\n### 4. Team Codebook Registry (v1.18.0)\nThe per-session dynamic dictionary (and its cross-session cache) is per-machine — without this, two teammates working on the same repository independently learn different `§N` glyph assignments for the same identifiers, which both wastes the learning and defeats org-wide provider-side prompt caching (implicit caching keys off byte-identical prefixes, which requires the same word to produce the same glyph everywhere).\n* **How it works**: `glyphcompress.team.json` — a small, git-committable file at the workspace root (unlike the gitignored `.glyphcompress/` cache dir) — lists dictionary entries in priority order. Every `GlyphCompressor` instance seeds its `§N` indices from it before any per-session learning happens.\n* **Workflow**: `glyph-compress team-codebook sync` promotes this machine's locally-learned dictionary into the shared file; commit it to git so the whole team (and every CLI/MCP/proxy entry point) assigns the same glyph to the same word.\n* **Activation**: Automatic once `glyphcompress.team.json` exists at the workspace root — no flag needed. Inspect with `glyph-compress team-codebook show`.\n\n\u003c/details\u003e\n\n***\n\n\n### New in v1.30.0 (Token Estimator Accuracy Fix)\n\nFixes the `src/token-estimator.js` bug found while building v1.29.0's benchmark below — it turned out to be two compounding issues. **(1)** An uncalibrated, double-counting Unicode penalty (fixed with codepoint-aware counting and class-calibrated costs). **(2)** The larger issue: OpenAI's base `charsPerToken` was only accurate for code, not prose — recalibrated to `4.2`, the char-weighted blended average across five real repository files, measured with real `js-tiktoken`. **(3)** Even recalibrated, a single heuristic number wasn't reliable enough on marginal content, so the net-negative fallback now requires a real 10% measured improvement, not just any nonzero one. Also found and fixed a third, unrelated bug while verifying this: `src/token-estimator.cjs` (used by the root package's CJS entry point) was never rebuilt by the build script at all. All three files that previously showed a masked real-token regression (`README.md`, `ROADMAP.md`, `docs/architecture.md`) now correctly fall back instead. New `test/token-estimator-accuracy.js` (13 tests). Full writeup in [docs/benchmark-methodology.md](docs/benchmark-methodology.md) and `RELEASE_NOTES.md`.\n\n\u003e **Full version history** (v0.5.0 → v1.29.0, 35+ releases) lives in [GitHub Releases](https://github.com/Neolambo/glyph-compress/releases) and [RELEASE_NOTES.md](RELEASE_NOTES.md) — not duplicated here. See [ROADMAP.md](ROADMAP.md) for what's planned next.\n\nFor contribution, licensing, and operational guidance, see [CONTRIBUTING.md](CONTRIBUTING.md), [docs/licensing.md](docs/licensing.md), [docs/release.md](docs/release.md), [docs/architecture.md](docs/architecture.md), [docs/benchmark-methodology.md](docs/benchmark-methodology.md), [SECURITY.md](SECURITY.md), [PRIVACY.md](PRIVACY.md), and [ENTERPRISE.md](ENTERPRISE.md).\n\n### 📏 Benchmark Snapshot (v1.30.0)\n\n`npm run benchmark` currently reports an aggregate payload compression ratio of **1.3x**, **22% genuine token savings**, **100% context fidelity score**, **100% edit success proxy**, and **0 hallucinated file references** across representative fixtures. These numbers are calibrated with Unicode token penalties and per-glyph breakeven logic — every reported saving is a real, net-positive token reduction. Disabling `TECH_GLYPHS` substitution on OpenAI when it measurably loses tokens (see \"New in v1.17.0\" above) did not move this number on these fixtures — it removes a systematic source of hidden waste with no observed downside, rather than trading it against measured savings.\n\n### 🧪 Realistic Benchmark Notes\n\n`npm run benchmark:realistic` measures four behaviors that the fixture benchmark does not capture by itself:\n\n1. **Real repository corpus compression** on files like `README.md`, `ROADMAP.md`, and core runtime sources.\n2. **Chat payload overhead** after the glyph codebook is injected for OpenAI and Anthropic-style requests.\n3. **Multi-turn chat amortization** across cumulative IDE-style conversations.\n4. **Enterprise nominal IDE usage** across professional workflows such as PR review, incident response, test planning, and release readiness.\n5. **Local throughput and latency** under repeated compression load.\n\nThe current realistic benchmark shows a more nuanced picture than the synthetic fixture table below:\n\n- Raw repository files at `light`, `standard`, and `aggressive` are now close to break-even (roughly **0.9x-1.0x**) on typical prose-and-code documentation. As of v1.16.0, the dynamic dictionary requires a word to repeat at least twice and accounts for the cost of transmitting its own definition, so it no longer inflates this number with single-occurrence substitutions that never actually paid for themselves.\n- `ultra` remains the level with real, structural savings on code-heavy files (up to roughly **1.2x** on this repository's own source), though not universally — dense single-file prose/code mixes can still land slightly negative.\n- The **user message alone** usually compresses well for chat prompts.\n- The **full first-turn chat payload** can still get worse on short requests because the injected codebook outweighs the user-message savings.\n- The **cumulative multi-turn payload** is now measured separately, so you can see whether repeated turns start to amortize the codebook or keep carrying a net overhead.\n- The new **enterprise nominal usage** section reports a weighted professional-IDE summary. In the current benchmark, OpenAI's weighted full-payload and isolated user-message savings are both roughly **break-even (~0%)** on this fixture set — the codebook overhead and the in-body savings largely cancel out.\n- Anthropic now uses a **hybrid wrapper strategy**: first-turn requests keep `system` lightweight, while multi-turn transcripts switch to structured cacheable blocks once assistant history exists.\n- Anthropic-oriented sections include both a transmitted **payloadSaved** metric and a **cache-adjusted estimate**. In the current benchmark, Anthropic remains slightly negative on weighted transmitted payload at about **-5%**, while the cache-adjusted weighted estimate (accounting for `cache_control` reuse of the system block and largest user block) is positive at about **28%**. This is a benchmark estimate, not a billing guarantee.\n\nUse `npm run benchmark` as the stable regression benchmark and `npm run benchmark:realistic` when you want a more honest estimate of repository-scale and chat-payload behavior.\n\n## 📊 Benchmarks\n\n\u003e [!NOTE]\n\u003e The table below measures the five curated per-scenario examples shown in [Realistic Session Showcase](#-realistic-session-showcase), in raw characters — it is a best-case illustration of what a well-suited payload can achieve, not the typical or aggregate result. For the honestly-reported, provider-token-aware aggregate across a representative fixture set, see [📏 Benchmark Snapshot](#-benchmark-snapshot-v1300) below (`npm run benchmark`: **1.3x ratio, 22% genuine savings**) and the [Realistic Benchmark Notes](#-realistic-benchmark-notes) (`npm run benchmark:realistic`) for real-repository and chat-payload numbers, which are more modest and sometimes break-even or negative on prose-heavy content.\n\n| Scenario | Original | Compressed | Ratio | Savings |\n|---|---|---|---|---|\n| Fix TypeScript error in React | 1,734 chars | 137 chars | **12.7x** | 92% |\n| Optimize API endpoint | 1,999 chars | 195 chars | **10.3x** | 90% |\n| Deploy to Kubernetes | 730 chars | 84 chars | **8.7x** | 88% |\n| Debug Python ML pipeline | 1,925 chars | 249 chars | **7.7x** | 87% |\n| Create React form | 116 chars | 33 chars | **3.5x** | 72% |\n| **Average** | | | **9.3x** | **89%** |\n\n### 🆚 Compared to Alternatives\n\nHonest positioning, not a sales table — reproduce these numbers yourself with `npm run benchmark:alternatives` (full methodology in [docs/benchmark-methodology.md](docs/benchmark-methodology.md)).\n\n| Approach | Reversible? | Extra runtime? | Real measured result (this repo, 5 files, `js-tiktoken`) |\n|---|---|---|---|\n| **No compression** | Yes (nothing changes) | None | Exceeds budget on 4 of 5 real files tested at 500-4000 tokens. |\n| **Naive truncation** | **No** — cut content is gone permanently | None | The common real-world fallback. Retains 24%-64% of original content depending on budget. |\n| **Provider-side prompt caching** (Anthropic `cache_control`, OpenAI/Gemini implicit) | Yes | None | Complementary, not a substitute — reduces *cost* on repeated prefixes across turns, not the *token count* of new content. GlyphCompress stacks with it (see the Anthropic hybrid wrapper below). |\n| [**LLMLingua**](https://github.com/microsoft/LLMLingua) | No — model-based, lossy by design | Python runtime | Intentionally not benchmarked here — a genuinely relevant comparison, but a separate dependency decision for a Node.js project's tooling, documented rather than approximated. |\n| **GlyphCompress** | Yes — source-map decodable, trust-policy gated | None (pure JS/Node) | Ties naive truncation exactly on Unicode-light prose (correctly falls back rather than risking a real-token loss) and beats it by a measured margin on code-heavy files — e.g. 83% vs. 78% retained at a 4,000-token budget on `src/compressor.js`. |\n\n### 🔎 Proof: Comprehension Preserved on Real Models\n\nToken savings are meaningless if the model can no longer understand the compressed context. The same bug-fix scenario — compressed exactly as the CLI actually sends it (full codebook + dynamic dictionary, not a simplified version) — was sent to a real model from each of the three primary providers and checked for whether it could still name the actual function/class (decoded from `§N` glyphs) and correctly describe the bug, without hallucinating:\n\n| Provider | Model | Named the function/class correctly | Identified the actual bug | Fix quality |\n|---|---|---|---|---|\n| Gemini | `gemini-2.5-flash-lite` | ✅ `calculateTotal`/`OrderProcessor` | ✅ | *(comprehension check only, no fix requested)* |\n| OpenAI | `gpt-4o-mini` | ✅ `calculateTotal`/`OrderProcessor` | ✅ | Reproduced the original code verbatim plus a working fix — OpenAI's measured-loss gating means compression barely touches identifiers on this provider. |\n| Anthropic | `claude-haiku-4-5` | ✅ `calculateTotal`/`OrderProcessor` | ✅ | Most complete of the three: correct percentage-based discount logic, not just a flat subtraction. |\n\n**Honest scope**: one scenario, one comprehension check per provider — a first, honestly-scoped step, not a statistical benchmark. These scripts (`npm run check:comprehension:gemini|openai|anthropic`) are dev-only/manual: they need a real, live API key and are deliberately excluded from `npm test`. Broader task coverage and real-repository evaluation remain open in [ROADMAP.md](ROADMAP.md)'s \"Real Task Evaluation\" item.\n\n## 🚀 Usage: Command Line (CLI)\n\nYou can run GlyphCompress directly from your terminal to quickly compress files for ChatGPT or Claude.\n\n```bash\n# Compress a Python/Rust/JS file and copy it to your clipboard\nnpx glyph-compress src/app.ts --level ultra --copy\n\n# Check the built-in help\nnpx glyph-compress --help\n\n# Explain what changed during compression\nnpx glyph-compress src/app.ts --level ultra --explain\n\n# Print reversible source map metadata\nnpx glyph-compress src/app.ts --level ultra --source-map\n\n# Redact secrets before printing or copying compressed output\nnpx glyph-compress .env --privacy --source-map\n\n# Build a persistent workspace codebook and rank relevant files\nnpx glyph-compress inspect \"fix AuthenticationManager error\"\n\n# Check repository readiness for GlyphCompress workflows\nnpx glyph-compress doctor\n\n# Run benchmark metrics through the CLI\nnpx glyph-compress benchmark\n```\n\n### Command Line (CLI): Available Commands\n\n```bash\nnpx glyph-compress [file|command] [options]\n```\n\n| Command | Purpose | Example |\n|---|---|---|\n| `[file]` | Compress a single file and print the compressed payload plus the shared codebook. | `npx glyph-compress src/app.ts` |\n| `inspect [query]` | Build `.glyphcompress/codebook.json`, detect intent, and rank relevant workspace files. | `npx glyph-compress inspect \"fix auth error\"` |\n| `doctor` | Check repository readiness plus optional local checks for installed extension version, Glyph settings, proxy config, and provider credentials. | `npx glyph-compress doctor` |\n| `benchmark` | Run the benchmark harness from the current repository. | `npx glyph-compress benchmark` |\n| `route \u003cquery\u003e` *(v1.17.0+)* | Context Router: rank workspace files relevant to a query and compress as many as fit inside a token budget, instead of manually picking which files to send. | `npx glyph-compress route \"fix the auth bug\" --budget 2000` |\n| `team-codebook show` *(v1.18.0+)* | Print the shared team codebook (`glyphcompress.team.json`), if any. | `npx glyph-compress team-codebook show` |\n| `team-codebook sync` *(v1.18.0+)* | Promote this machine's locally-learned dynamic dictionary into `glyphcompress.team.json` for the whole team. | `npx glyph-compress team-codebook sync` |\n\n### Command Line (CLI): Options\n\n| Option | Values | Purpose | Example |\n|---|---|---|---|\n| `-l, --level \u003clevel\u003e` | `light`, `standard`, `aggressive`, `ultra`, `auto` | Select compression aggressiveness, or let `auto` pick per request. Default: `standard`. | `npx glyph-compress src/app.ts --level ultra` |\n| `-c, --copy` | flag | Copy compressed output to the system clipboard. | `npx glyph-compress src/app.ts --copy` |\n| `-x, --explain` | flag | Print what was compressed, indexed, preserved, or transformed. | `npx glyph-compress src/app.ts --explain` |\n| `--source-map` | flag | Print reversible source map JSON, including file refs, dynamic entries, diagnostics, symbols, AST/code block metadata, privacy metadata, provider metadata, and trust metadata. | `npx glyph-compress src/app.ts --source-map` |\n| `--privacy` | flag | Redact common secrets and sensitive identifiers before compression/output. | `npx glyph-compress .env --privacy --source-map` |\n| `--provider \u003cprovider\u003e` | `raw`, `openai`, `anthropic`, `gemini`, `local` | Select provider-aware estimates and compression profile. Default: `raw`. | `npx glyph-compress src/app.ts --provider openai --explain` |\n| `--trust \u003cpolicy\u003e` | `lossless`, `reversible`, `privacy`, `lossy` | Select allowed transformation policy. Default: auto. | `npx glyph-compress src/app.ts --trust reversible --source-map` |\n| `--policy \u003cpolicy\u003e` | `lossless`, `reversible`, `privacy`, `lossy` | Alias for `--trust`. | `npx glyph-compress src/app.ts --policy privacy` |\n| `--decay` | flag | Enable Attentional Decay Compaction on chat history messages. | `npx glyph-compress --decay` |\n| `--folding` | flag | Enable holographic context folding for overlapping related files. | `npx glyph-compress --folding` |\n| `--intents` | flag | Enable generative intent diffs compression for code changes. | `npx glyph-compress --intents` |\n| `--budget \u003ctokens\u003e` | integer | Token budget for the `route` command. Default: `2000`. | `npx glyph-compress route \"fix the bug\" --budget 3000` |\n| `--max-files \u003cn\u003e` | integer | Max candidate files to rank for the `route` command. Default: `8`. | `npx glyph-compress route \"fix the bug\" --max-files 12` |\n| `--git-diff-only` | flag | Restrict `route` to git staged/unstaged files only, for \"review what I changed\" workflows. | `npx glyph-compress route \"review my changes\" --git-diff-only` |\n| `--json` | flag | Print machine-readable JSON for supported commands such as `inspect`, `doctor`, and `route`. | `npx glyph-compress inspect \"review diff\" --json` |\n| `-p, --proxy [port]` | optional port | Start the Zero-Command Transparent Proxy. Default port: `8080`. | `npx glyph-compress --proxy 8080` |\n| `--log-file \u003cpath\u003e` | file path | Append structured, redacted JSONL diagnostics from the proxy (timestamps, trust/routing metadata) to this file. | `npx glyph-compress --proxy --log-file ~/.glyphcompress/proxy.log` |\n| `-h, --help` | flag | Show built-in CLI help. | `npx glyph-compress --help` |\n\n### Command Line (CLI): Practical Examples\n\n```bash\n# Standard file compression\nnpx glyph-compress README.md\n\n# Maximum compression for a TypeScript source file\nnpx glyph-compress src/app.ts --level ultra\n\n# Provider-aware compression for OpenAI chat payloads\nnpx glyph-compress src/app.ts --provider openai --level standard --explain\n\n# Anthropic/cache-stable profile with reversible source map metadata\nnpx glyph-compress src/app.ts --provider anthropic --trust reversible --source-map\n\n# Exact-preservation mode: useful when you want metadata without transformations\nnpx glyph-compress src/app.ts --trust lossless --source-map\n\n# Privacy-first mode for files that may contain secrets or customer data\nnpx glyph-compress .env --privacy --trust privacy --source-map\n\n# JSON workspace inspection for automation or CI scripts\nnpx glyph-compress inspect \"implement billing validation\" --json\n\n# Repository readiness check in JSON form\nnpx glyph-compress doctor --json\n\n# Start the local OpenAI-compatible compression proxy\nnpx glyph-compress --proxy 8080\n```\n\n**Cost savings**: ~$200/month at 50 requests/day with Claude Sonnet.\n\n## 🚀 Quick Start\n\nGet up and running with GlyphCompress in under 60 seconds. We highly recommend starting with the **Automated (Invisible)** workflow:\n\n### 1. 🤖 Automated \u0026 Transparent Workflows (Recommended)\n\n* **Option A: Zero-Command Invisible Proxy (100% Automatic)**\n  Compresses all your outgoing IDE chat payloads automatically in the background without changing any of your development habits:\n  1. Install the extension **GlyphCompress** from the VS Code Marketplace (id: `neolambo.glyph-compress`).\n  2. Open the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`) and run: `GlyphCompress: Start Zero-Command Proxy`.\n  3. Configure your IDE (Cursor, Cline, Continue, etc.) to use the local proxy address `http://localhost:8080` (or `http://localhost:8080/v1`) as its OpenAI Base URL. *(See the [Step-by-Step IDE Integration Guide](#️-step-by-step-ide-integration-guide) below for exact configurations).*\n  *Every request is now automatically and transparently compressed on the fly!*\n\n* **Option B: Auto-Managed Workspace Rules**\n  Let the extension automatically inject the codebook instructions into your workspace:\n  1. Toggle `\"glyphCompress.autoUpdateWorkspaceRules\": true` in your VS Code settings.\n  2. The extension will automatically create and update `.cursorrules` and `.github/copilot-instructions.md` in your project root with the compression codebook.\n  3. Cursor and Copilot Chat models will **instantly understand** compressed glyphs natively!\n\n---\n\n### 2. 🎛️ Manual Workflows\n\n* **Option C: One-Click Extension Command (`Ctrl+Alt+G`)**\n  Manually compress files or code selections on demand:\n  1. Highlight any block of code in your editor (or leave unselected to compress the whole file).\n  2. Press `Ctrl+Alt+G` (or `Cmd+Alt+G` on Mac).\n  3. The extension instantly compresses your selection and automatically opens your VS Code Chat pre-filled. Just hit enter!\n\n* **Option D: Zero-Install CLI Tool**\n  Compress any project file in your terminal and copy the glyph payload directly to your clipboard:\n  ```bash\n  npx glyph-compress src/app.ts --copy\n  ```\n\n* **Option E: JS/TS Developer SDK**\n  Integrate semantic compression directly into your own API scripts or AI agents:\n  ```bash\n  npm install glyph-compress\n  ```\n  See the code templates below:\n\n### Standalone SDK Usage (Any project)\n\n```javascript\nimport { GlyphCompressor } from 'glyph-compress';\n\nconst gc = new GlyphCompressor({ level: 'standard' });\nconst { compressed, stats, sourceMap } = gc.compressText(\n  \"Fix the TypeScript error in src/components/UserProfile.tsx line 42: \" +\n  \"Property 'name' does not exist on type 'User'\"\n);\n\nconsole.log(compressed);\n// → \"⺌✗ ◈₍1₎:42 'name'∉User\"\nconsole.log(stats);\n// → { ratio: '5.5x', savedPct: '82%' }\nconsole.log(sourceMap.files);\n// → [{ ref: '◈₍1₎', path: 'src/components/UserProfile.tsx', domain: 'frontend' }]\n```\n\n### With OpenAI\n\n```javascript\nimport OpenAI from 'openai';\nimport { wrapOpenAI } from 'glyph-compress';\n\nconst client = wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));\n\n// Every call is automatically compressed — the codebook is injected into the system prompt\nconst response = await client.chat.completions.create({\n  model: 'gpt-4',\n  messages: [\n    { role: 'system', content: 'You are a senior developer.' },\n    { role: 'user', content: 'Fix the error in UserProfile.tsx' },\n  ],\n});\n```\n\n### With Anthropic Claude\n\n```javascript\nimport Anthropic from '@anthropic-ai/sdk';\nimport { wrapAnthropic } from 'glyph-compress';\n\nconst client = wrapAnthropic(new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY }));\n\nconst response = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  system: 'You are a senior developer.',\n  messages: [\n    { role: 'user', content: 'Fix the error in UserProfile.tsx' },\n  ],\n});\n```\n\n`wrapAnthropic()` now keeps first-turn requests lightweight and only promotes the system prompt into structured cacheable blocks when the transcript already contains assistant history. That reduces avoidable overhead on short requests while preserving cache-oriented behavior for longer IDE conversations.\n\n### With Antigravity (AI Coding Assistant)\n\nFor agentic IDEs like Antigravity, you can compress massive context payloads locally before passing them into the AI's prompt:\n\n```javascript\nimport { GlyphCompressor } from 'glyph-compress';\n\n// Use \"ultra\" level to obliterate code bodies and comments into semantic summaries\nconst gc = new GlyphCompressor({ level: 'ultra' });\n\n// 1. Inject this ONCE into your Antigravity System Prompt:\nconsole.log(gc.getCodebookPrompt());\n\n// 2. Compress and send massive files to Antigravity:\nconst { compressed, stats } = gc.compressText(massiveProjectContext);\nconsole.log(compressed); // Send this to the LLM\nconsole.log(stats);      // → { ratio: '12.7x', savedPct: '92%' }\n```\n\n### VS Code Extension\n\n1. Install from the **[VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=neolambo.glyph-compress)** with extension id `neolambo.glyph-compress`.\n2. For the exact latest GitHub release build, download `glyph-compress-\u003cversion\u003e.vsix` from **[GitHub Releases](https://github.com/Neolambo/glyph-compress/releases)** and install it locally:\n   ```powershell\n    code.cmd --install-extension .\\glyph-compress-1.17.0.vsix --force\n   code.cmd --list-extensions --show-versions | Select-String -Pattern 'neolambo.glyph-compress'\n   ```\n3. See live compression stats in the status bar: `⚡ GC: 3.5x | -1200 tok`\n\nThe Marketplace listing exists publicly; GitHub Releases are also published for users who need a specific VSIX version immediately after each release.\n\n#### Zero-Friction Chat Integration (Copilot / Claude / Cursor)\nGlyphCompress provides a fluid workflow for native IDE chats. The extension can optionally write workspace rules so Copilot and Cursor understand compressed glyph context.\n\n**The Magic Workflow:**\n1. **Optional Codebook Injection:** Enable `glyphCompress.autoUpdateWorkspaceRules` to let GlyphCompress create/update `.github/copilot-instructions.md` and `.cursorrules` in your project root. Copilot and Cursor can then learn the Glyph dictionary from workspace rules.\n2. **One-Click Ask (`Ctrl+Alt+G`):** Highlight a massive chunk of code (or leave unselected to compress the whole file) and press `Ctrl+Alt+G` (or run `GlyphCompress: Ask LLM (Auto-Compress)`).\n3. **Seamless Chat:** The extension instantly compresses the code and **automatically opens your VS Code Chat** with the compressed text pre-filled. Just type your question and hit enter! The AI will parse the `[imp:3 ƒ:2 34L]` glyphs perfectly, saving you 90% of your context window.\n\n**Available Commands:**\n- `GlyphCompress: Ask LLM (Auto-Compress)` (`Ctrl+Alt+G`) — Instantly compress and open VS Code Chat\n- `GlyphCompress: Copy System Codebook` — Instantly copy instructions for any LLM\n- `GlyphCompress: Compress Selection` — Compress code and auto-copy to clipboard\n- `GlyphCompress: Build Project Codebook` — Index your workspace files\n- `GlyphCompress: Toggle Compression On/Off`\n- `GlyphCompress: Show Compression Stats` — Dashboard with session statistics\n- `GlyphCompress: Start Zero-Command Proxy` — Start the local compression proxy\n- `GlyphCompress: Stop Zero-Command Proxy` — Stop the local compression proxy\n- `GlyphCompress: Compress Entire Workspace` — Generate a compressed workspace summary\n\n**Settings:**\n```json\n{\n  \"glyphCompress.enabled\": true,\n  \"glyphCompress.provider\": \"gemini\",        // \"auto\" | \"raw\" | \"openai\" | \"anthropic\" | \"antigravity\" | \"gemini\" | \"local\"\n  \"glyphCompress.compressionLevel\": \"standard\", // \"light\" | \"standard\" | \"aggressive\" | \"ultra\" | \"auto\"\n  \"glyphCompress.trustPolicy\": \"privacy\",     // \"auto\" | \"lossless\" | \"reversible\" | \"privacy\" | \"lossy\"\n  \"glyphCompress.showStatusBar\": true,\n  \"glyphCompress.autoUpdateWorkspaceRules\": false,\n  \"glyphCompress.targetApiUrl\": \"https://generativelanguage.googleapis.com\",\n  \"glyphCompress.experimentalDecay\": false,\n  \"glyphCompress.holographicFolding\": false,\n  \"glyphCompress.intentDiffs\": false\n}\n```\n\n`glyph-compress doctor` now reports repository basics first, then adds optional local environment checks for:\n\n- installed `neolambo.glyph-compress` extension version\n- detected `glyphCompress.*` VS Code settings\n- proxy config in local Continue config files\n- provider credential env vars such as `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, or `GOOGLE_API_KEY`\n\n## 👻 The Ultimate Magic: Zero-Command Transparent Proxy (v0.5.0+)\n\nIf you want **100% automatic, invisible** compression without pressing *any* shortcuts, you can use the GlyphProxy. It intercepts the API calls made by your IDE, compresses the prompt on the fly, and saves your API tokens.\n\n### How to use the Proxy:\n1. Start the proxy server using the CLI or VS Code:\n   ```bash\n   # From terminal\n   npx glyph-compress --proxy 8080\n   ```\n   *(Or from VS Code Command Palette: `GlyphCompress: Start Zero-Command Proxy`)*\n2. Configure your AI coding assistant to use the custom local endpoint:\n   - **API Base URL / Override API URL**: `http://localhost:8080/v1`\n   - **API Key**: *Your real OpenAI/Anthropic key*\n\n### 🛠️ Step-by-Step IDE Integration Guide\n\n**Cursor IDE**\n1. Open Cursor Settings (`Ctrl+Shift+J` or `Cmd+Shift+J`).\n2. Go to **Models** and choose an **OpenAI-compatible** entry.\n3. Under the provider settings, enter your real upstream API key.\n4. Set the **Base URL / Override OpenAI Base URL** to: `http://localhost:8080/v1`\n5. If you are proxying Gemini-compatible traffic, keep GlyphCompress VS Code settings aligned with:\n  - `glyphCompress.provider = gemini`\n  - `glyphCompress.targetApiUrl = https://generativelanguage.googleapis.com`\n6. If you are proxying Anthropic traffic, use:\n  - `glyphCompress.provider = anthropic`\n  - `glyphCompress.targetApiUrl = https://api.anthropic.com`\n  - **Model ID**: a real Anthropic model id (e.g. `claude-3-5-sonnet-20241022`), not an OpenAI one — the IDE still speaks OpenAI's chat/completions format to the local proxy, but the proxy translates the request and response to and from Anthropic's native Messages API on the wire (v1.24.0+; see \"New in v1.24.0\" below for why this matters).\n7. All Chat and Cmd+K requests will now flow through the local proxy.\n\n**Cline / RooCode (VS Code Extensions)**\n1. Open the Cline/RooCode settings panel.\n2. Select **OpenAI Compatible** as your API Provider.\n3. **Base URL**: `http://localhost:8080/v1`\n4. **API Key**: *Your real API key*\n5. **Model ID**: `gpt-4o` (or whichever you prefer).\n\n**Continue.dev**\n1. Open `~/.continue/config.yaml`.\n2. Add or edit your model configuration:\n```yaml\nmodels:\n  - title: Gemini 2.5 Flash (Glyph Proxy)\n    provider: openai\n    model: gemini-2.5-flash\n    apiKey: YOUR_REAL_API_KEY\n    apiBase: http://localhost:8080/v1\n```\n\nIf you prefer an OpenAI upstream, keep the same `apiBase` and swap only the upstream API key, model id, and GlyphCompress provider/target settings. For an Anthropic upstream, do the same but also set `glyphCompress.targetApiUrl = https://api.anthropic.com` and use a real Anthropic model id — the proxy translates the request/response shape for you (v1.24.0+).\n\n**GitHub Copilot Chat**\n*Note: Microsoft locks the API URL for the official Copilot extension for security reasons. To use GlyphCompress with the official Copilot, please use the `Ctrl+Alt+G` (One-Click Ask) shortcut provided by the GlyphCompress VS Code Extension.*\n\n### 3. Done! \nYou don't need to do anything else. When your IDE sends huge blocks of code to the LLM, the proxy intercepts the JSON request, minifies the code blocks, injects the codebook, and forwards the heavily compressed request to the real LLM API. \n\n## 🔌 MCP Server (Claude Code, Claude Desktop \u0026 other MCP clients)\n\nGlyphCompress ships an [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server, so any MCP-compatible client can call compression directly — no IDE-specific integration or proxy configuration needed.\n\n### Tools exposed\n\n| Tool | What it does |\n|---|---|\n| `compress_text` | Compress an arbitrary text/context blob. Returns the compressed text, the codebook needed to decode it, and stats. |\n| `compress_file` | Read a file from disk and compress its content. |\n| `route_context` | Context Router: rank workspace files relevant to a query and compress as many as fit inside a token budget. |\n| `get_codebook` | Return the glyph codebook prompt for manual injection into a system prompt. |\n\n### Add it to Claude Code\n\n```bash\nclaude mcp add glyph-compress -- npx glyph-compress-mcp\n```\n\n### Add it to Claude Desktop or another MCP client\n\nAdd to the client's MCP server config (for Claude Desktop, `claude_desktop_config.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"glyph-compress\": {\n      \"command\": \"npx\",\n      \"args\": [\"glyph-compress-mcp\"]\n    }\n  }\n}\n```\n\n### Run it directly\n\n```bash\nnpx glyph-compress-mcp\n```\n\nThe server communicates over stdio using the official `@modelcontextprotocol/sdk`. It has no network dependency beyond your MCP client's own transport — everything runs locally, same as the CLI and proxy.\n\n## 🔤 The Glyph Protocol\n\nThe system is built on 16 **base radicals** that encode fundamental semantic dimensions:\n\n```\nDOMAINS:    ◈ Frontend   ◉ AI/ML     ◊ DevOps    ◆ Database\n            ◇ Language   ⊕ Auto      ⊗ Arch      ⊙ Mobile\n            ⊘ Cloud      ⊚ Data      ⊛ Testing   ⊜ Backend\n            ⊝ Security   ⊞ Docs      ⊟ Perf      ⊠ Network\n\nACTIONS:    ▲ Create     ▼ Analyze   ► Test      ◄ Monitor\n            ■ Document   □ Connect   ▪ Deploy    ▫ Optimize\n            ● Transform  ○ Protect\n\nTECH:       ᵗ TypeScript  ᵖ Python   ʳ Rust     ℜ React\n            ℕ Next.js     𝒟 Docker   𝒦 K8s      ℙ Postgres\n\nSTRUCTURE:  ✗ Error   ⚠ Warning   ∉ Type mismatch   ∅ Not found\n            → Returns   ƒ Function   𝒞 Class   ◇ State   ⟿ Effect\n```\n\n### Compression Levels\n\n| Level | What it compresses | Use case |\n|---|---|---|\n| **light** | Prompt patterns, tech names | Low-risk, minimal changes |\n| **standard** | Prompt patterns, tech names, file paths, diagnostics, repeated identifiers | Default coding assistant payloads |\n| **aggressive** | Standard compression plus multi-language syntax minification inside code blocks | Debugging or review where code structure still matters |\n| **ultra** | Aggressive compression plus architectural code summaries and redundancy stripping | Maximum context savings when inner code logic is less important |\n| **auto** *(v1.16.0+)* | Picks light/standard/aggressive/ultra per request from content length and code density | You don't want to hand-pick a level per payload |\n\nUse `sourceMap` or `--source-map` whenever you need to inspect or reverse the compressed references after the payload is sent.\n\n## 🏗️ Architecture\n\n```\n+------------------+     +--------------------+     +-------------+\n|    IDE / Tool    |----\u003e|   GlyphCompress    |----\u003e|   LLM API   |\n|                  |     |                    |     |             |\n| VS Code          |     | 1. Index files     |     | OpenAI      |\n| Antigravity      |     | 2. Compress ctx    |     | Claude      |\n| CLI script       |     | 3. Inject codebook |     | Gemini      |\n| Custom app       |     | 4. Track stats     |     |             |\n+------------------+     +--------------------+     +-------------+\n```\n\nThe **codebook** (~150 tokens) is injected once into the system prompt. The LLM learns to decode the glyphs from it and responds normally in natural language.\n\n## 📦 Project Structure\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eShow the full directory layout\u003c/strong\u003e\u003c/summary\u003e\n\n```\nglyph-compress/\n├── bin/\n│   ├── cli.js                    # `glyph-compress` CLI (compress/inspect/doctor/benchmark/route/team-codebook)\n│   └── mcp-server.js             # `glyph-compress-mcp` MCP server (compress_text/compress_file/route_context/get_codebook)\n├── src/\n│   ├── index.js                  # Library entry point (ESM)\n│   ├── index.cjs / index.d.ts    # CommonJS entry point + stable TypeScript declarations\n│   ├── glyph-middleware.js       # Thin re-export of the compiled middleware (see vscode-ext/)\n│   ├── workspace-intelligence.js # Workspace codebook, intent detection, file ranking, and the Context Router's file reader\n│   ├── team-codebook.js          # Team Codebook Registry (glyphcompress.team.json read/write/merge)\n│   ├── token-estimator.js        # Provider-aware token estimators\n│   ├── radical-alphabet.js / compressor.js / system-prompt-generator.js  # Legacy standalone engine (used by `npm run demo`)\n│   └── workspace-intelligence.cjs, team-codebook.cjs, ...  # esbuild-generated CJS builds (see scripts/build-middleware.js)\n├── vscode-ext/\n│   ├── package.json              # VS Code extension manifest\n│   ├── extension.js              # Extension activation \u0026 commands\n│   └── glyph-middleware.js       # Core middleware: GlyphCompressor, wrapOpenAI/wrapAnthropic, routeAndCompress\n├── test/\n│   ├── run-suites.js             # Runs all 17 test suites\n│   ├── unit.js, cli.js, workspace.js, metadata.js, snapshots.js, integration.js, holographic-test.js, intent-test.js\n│   ├── codebook-completeness.js, auto-level.js, cache-prefix-stability.js, tech-glyph-economics.js\n│   ├── context-router.js, mcp-server.js, team-codebook.js  # newest suites — router, MCP protocol, shared dictionary\n│   ├── tokenizer-calibration.js  # real-tokenizer glyph-cost report (npm run calibrate:tokenizer)\n│   └── benchmark.js, benchmark-realistic.js\n├── examples/\n│   ├── openai-example.js, claude-example.js, antigravity-example.js\n├── package.json\n├── SECURITY.md, PRIVACY.md, ENTERPRISE.md, COMMERCIAL_LICENSE.md, NOTICE, LICENSE\n├── ROADMAP.md, RELEASE_NOTES.md\n└── README.md\n```\n\n\u003c/details\u003e\n\n## 🧪 Tests\n\n```bash\n# Run all 17 test suites\nnpm test\n\n# Run focused suites\nnpm run test:unit\nnpm run test:cli\nnpm run test:workspace\nnpm run test:extension\nnpm run test:proxy\nnpm run test:metadata\nnpm run test:snapshots\nnpm run test:holographic\nnpm run test:intent\nnpm run test:integration\nnpm run test:codebook           # codebook-completeness: every emitted glyph must be documented\nnpm run test:auto-level         # selectCompressionLevel() / level: 'auto'\nnpm run test:cache-prefix       # byte-stable codebook prefix for provider-side implicit caching\nnpm run test:tech-glyph-economics  # TECH_GLYPHS never lose real tokens on OpenAI\nnpm run test:context-router     # routeAndCompress() + CLI `route`\nnpm run test:mcp-server         # drives the real MCP server over stdio via the official SDK client\nnpm run test:team-codebook      # glyphcompress.team.json shared dictionary\n\n# Run the stable release validation bundle (build, full test suite, benchmark, link check, npm pack dry-run)\nnpm run check\n\n# Check local Markdown links\nnpm run check:links\n\n# Run trust and measurement benchmark\nnpm run benchmark\n\n# Run realistic corpus, payload, and throughput benchmark\nnpm run benchmark:realistic\n\n# Measure real per-glyph token cost against OpenAI tokenizers (cl100k_base/o200k_base)\nnpm run calibrate:tokenizer\n\n# Run interactive demo\nnpm run demo\n```\n\n## 🔬 Theory\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eShow the theoretical background\u003c/strong\u003e\u003c/summary\u003e\n\nGlyphCompress is grounded in information theory:\n\n- **Shannon entropy** tells us the theoretical compression limit for character-level encoding\n- **Kolmogorov complexity** tells us that compression = understanding\n- **Semantic compression** captures structural redundancy that standard algorithms (GZIP, Brotli) miss\n\nThe key insight: development communication is **highly structured** — the same patterns (`fix error`, `deploy to`, `create component`) repeat thousands of times with different parameters. By encoding these patterns as composable radicals, we achieve compression ratios far beyond what byte-level algorithms can reach.\n\n\u003e **Fundamental Law**: Perfect compression is equivalent to perfect understanding. Information is redistributed — not lost — among the message, the codebook, and the receiver's context.\n\n\u003c/details\u003e\n\n## ⚖️ Dual Licensing Model\n\nGlyphCompress is distributed under a **dual-license** model:\n\n1. **Open source: AGPL-3.0-only**. The public repository and npm package may be used under the AGPL-3.0-only terms in [LICENSE](LICENSE). If you modify, integrate, redistribute, or offer GlyphCompress over a network, make sure you can satisfy the AGPL obligations.\n2. **Commercial license**. Proprietary, closed-source, private redistribution, SaaS, hosted, embedded, OEM, marketplace, or enterprise use without AGPL obligations requires a separate written commercial agreement. Downloading, installing, forking, importing, or bundling the package does not grant commercial rights.\n\nSee [COMMERCIAL_LICENSE.md](COMMERCIAL_LICENSE.md), [docs/licensing.md](docs/licensing.md), and [NOTICE](NOTICE) for the project licensing position. For commercial terms, contact `campiossasco1@gmail.com`.\n\n## 🤝 Contributing\n\nContributions welcome! Areas of interest:\n\n- **New radicals** for emerging technologies\n- **Language support** for non-English prompts (Italian, German, French are already supported; Spanish, Portuguese, Japanese, and more are welcome)\n- **VS Code Marketplace** metadata, examples, and compatibility reports\n- **Benchmark data** from real-world IDE sessions\n- **LLM comprehension tests** with different models\n\nBy submitting a contribution, you confirm that it can be used under the project dual-license model described in [CONTRIBUTING.md](CONTRIBUTING.md). Participation in issues, pull requests, and discussions is governed by the [Code of Conduct](CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneolambo%2Fglyph-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneolambo%2Fglyph-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneolambo%2Fglyph-compress/lists"}