26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
lean-ctx Chrome Extension
Token compression for web-based AI chat tools. Automatically compresses code when pasting into ChatGPT, Claude.ai, Gemini, or GitHub Copilot Chat.
Features
- Auto-compress pastes — Code pasted into AI chat inputs is automatically compressed
- Token counter badge — Shows savings in real-time after each compression
- Native messaging — Connects to local lean-ctx binary for full compression (95+ patterns)
- Fallback compression — Basic comment/whitespace removal when native host unavailable
- Popup dashboard — Token savings stats + toggle controls
Supported Sites
- ChatGPT / chat.openai.com
- Claude.ai
- Gemini
- GitHub Copilot Chat
- Lovable
- Bolt.new
- v0.dev
- Poe
- Google AI Studio
- Perplexity Labs
Installation
1. Load Extension (Developer Mode)
- Open
chrome://extensions - Enable "Developer mode"
- Click "Load unpacked" and select this directory
- Note the Extension ID
2. Install Native Messaging Host (optional, for full compression)
cd native-host
chmod +x install.sh bridge.sh
./install.sh
Then edit the native messaging manifest to include your Extension ID.
3. Requirements
- lean-ctx binary for native messaging (
cargo install lean-ctx) - Python 3 for the native messaging bridge
How It Works
- When you paste text (>200 chars) into a supported AI chat input
- The extension intercepts the paste event
- Text is sent to the background service worker
- If native messaging is available, lean-ctx compresses it
- Otherwise, fallback compression removes comments and whitespace
- Compressed text replaces the paste, badge shows savings
Settings
Toggle via the popup (click extension icon):
- Auto-compress pastes — Enable/disable automatic compression
- Native messaging — Use lean-ctx binary for advanced compression
Enterprise-Managed Deployment
The extension supports Chrome Enterprise policies via chrome.storage.managed
(schema: managed_schema.json). Managed values override user choices; the
popup shows a "Managed by your organization" banner and locks those controls.
Available policy keys:
| Key | Type | Effect |
|---|---|---|
enabled |
boolean | Force compress-on-send on/off fleet-wide |
autoCompressPaste |
boolean | Force clipboard auto-compress on/off |
threshold |
integer | Minimum token estimate before compressing |
gatewayBaseUrl |
string | Org AI-gateway endpoint, surfaced in the popup for base-URL-capable tools |
Example policy (macOS: managed preferences plist, Windows: registry under
Software\Policies\Google\Chrome\3rdparty\extensions\<extension-id>\policy,
Linux: /etc/opt/chrome/policies/managed/*.json):
{
"3rdparty": {
"extensions": {
"<extension-id>": {
"enabled": true,
"autoCompressPaste": true,
"gatewayBaseUrl": "https://ai-gateway.example.com"
}
}
}
}
Honest boundary — what the extension can and cannot do
- Can: compress prompts you type/paste into supported web chats (client-side token reduction), and display your org's gateway endpoint so engineers configure their CLI/IDE tools correctly.
- Cannot: re-route first-party AI web/desktop apps (claude.ai, ChatGPT
web, Claude Desktop) through your gateway. Manifest V3 grants no
webRequest/declarativeNetRequesthere, and those apps pin their own backends. Org-side metering/routing covers only traffic that reaches the gateway via a base URL: Claude Code CLI, Cursor, IDE API clients, SDKs.gatewayBaseUrlis informational for the user — not a traffic redirect.