Stop context bloat. Save 90%+ of your prompt tokens. Keep your agent fast, focused, and sharp.
Antigravity Context Mode is a free, local-first plugin built specifically for the Google Antigravity App. It prevents terminal commands, build logs, and multi-megabyte source files from flooding your conversation history — saving thousands of tokens per turn and stopping "agent amnesia" in its tracks.
🌐 Interactive Live Simulator & Documentation: domush.github.io/antigravity-plugin-context-mode
---
Install directly into Google Antigravity using npx:
# Global install (available across all Antigravity chats)
npx antigravity-plugin-context-mode install
# Or per-project install (scoped to current workspace only)
npx antigravity-plugin-context-mode install --workspaceRestart or open the Google Antigravity App, and Context Mode is active immediately.
When an AI coding agent executes tools, standard workflows dump everything directly into your conversation context:
- Running
Get-Content Logs/Editor.logdumps 65 KB (~16,000 tokens) into your prompt. - Running test suites, compiler outputs, or git diffs dumps 100+ KB of repetitive text.
- Reading large files or documentation dumps thousands of lines of irrelevant boilerplate.
- Agent Amnesia: Important system instructions, user constraints, and earlier architectural decisions get drowned out.
- Slower Responses: Generation times climb as the context window fills up with raw text.
- Burned Quota: You hit model context ceilings and rate limits after only a few turns.
┌────────────────────────────────────────────────────────┐
│ 1. Agent attempts to read a large file or command │
│ (e.g. 5,000-line build log or 40 KB source file) │
└───────────────────────────┬────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────┐
│ 2. Pre-Tool Lifecycle Hook Intercepts Unbounded Dumps │
│ • Files under 8 KB pass through normally │
│ • Un-paged dumps over 8 KB are safely intercepted │
│ • Images, docs, and chat attachments are exempted │
└───────────────────────────┬────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────┐
│ 3. Sandboxed Execution ("Thinking in Code") │
│ • Agent filters data locally using Node/Python │
│ • Indexes text into local SQLite FTS5 BM25 database │
│ • Returns only the exact answer or error to chat! │
└────────────────────────────────────────────────────────┘
Tested live on real-world build logs and source files in the Antigravity App:
| Operation | Without Context Mode | With Context Mode | Savings |
|---|---|---|---|
| Parsing 665-line Unity Editor.log | 65,242 B (~16,300 tokens) | 550 B (~137 tokens) | 99.2% saved |
| Full File Read on 40 KB component | 40,960 B (~10,240 tokens) | Intercepted & paged to 50 lines (~800 tokens) | 92.1% saved |
| Searching Compiler Warnings | Entire log dumped into chat | Top 2 ranked FTS5 snippets (~350 tokens) | 97.8% saved |
- 🛡️ Automated Interception: Blocks unbounded file dumps and commands before they bloat your context window.
- 🧠 Intelligent Language-Aware Chunking (v2.0): Intelligently chunks source code (JS, TS, Python, Java, C#, Go, Rust, Ruby, PHP, C/C++, Shell, SQL), Markdown, JSON, YAML, TOML, HTML/XML, and logs. Never slices methods, headings, or stack traces mid-block.
- 🎯 Context-Expanding Search Results:
ctx_searchreturns complete source code methods, paragraphs, or markdown sections intact, along withstartLine,endLine, and enclosing scope metadata. - ⚡ Thinking in Code: Filters multi-thousand-line outputs in 50 ms via local sandboxed scripts.
- 🔍 Local SQLite FTS5 Search: Indexes files and logs locally on your machine with BM25 keyword matching and trigram search.
- 📊 Built-In Sidecar Dashboard: Real-time stats pane inside Antigravity showing tokens kept out of context.
- 🔒 100% Local & Private: All indexed data stays on your machine in
~/.context-mode/context.db. Zero network calls. - 📦 Zero Dependencies: Pure native Node.js (
node:sqlite). No native builds, nonode-gyp.
| Feature / Capability | v1.4.0 | v1.5.0 | v2.0.0 |
|---|---|---|---|
| Tool Read Cutoff & Hook Interception | ✅ Dynamic line scaling | ✅ Auto-index on hook | ✅ Auto-index on hook |
| File Exemption Controls | ✅ 1-click category pills | ✅ Injected into agent context | ✅ Injected into agent context |
| Indexing Model | Manual (ctx_index) |
✅ Just-In-Time (ctx_search) |
✅ Just-In-Time (ctx_search) |
| MCP Tool Surface | 8 tools (with ctx_index) |
✅ 7 streamlined tools | ✅ 7 streamlined tools |
| Log Search Strategy | Standard | ✅ Reverse / Tail-First | ✅ Tail-First + Stack Trace Grouping |
| Chunking Engine | Byte & line buckets | Byte & line buckets | ✅ AST & Syntax-Aware Semantic Engine |
| Code Structure Preservation | Partial | Partial | ✅ 15+ Languages, Classes & Methods Intact |
| Markdown Chunking | Line-based | Line-based | ✅ Heading Breadcrumbs (# H1 > ## H2) |
| Search Result Snippets | Centered window slice | Centered window slice | ✅ Complete Intact Method (up to 2 KB) |
| Search Metadata | Score & source | Path & score | ✅ Lines X–Y, Enclosing Scope Context |
| SQLite Schema | Schema v2 | Schema v3 (path PK) |
✅ Schema v4 (Unindexed Scope Metadata) |
Once installed, Context Mode provides 7 specialized tools for your agent:
| Tool | What It Does |
|---|---|
ctx_execute |
Runs sandboxed Node.js, Python, or PowerShell scripts to inspect files and extract answers without context dumps. |
ctx_search |
Searches files, directories, or URLs with Just-In-Time auto-indexing using local SQLite FTS5 BM25 + Trigram RRF. |
ctx_batch |
Runs multiple terminal commands in batch and indexes the combined output. |
ctx_stats |
Displays a formatted context savings report and token metrics. |
ctx_resume |
Returns recent indexed sources and state pointers after context compactions. |
ctx_doctor |
Checks SQLite database health, WAL mode, and platform runtimes. |
ctx_purge |
Clears stored sources and events from SQLite. |
Open the Google Antigravity App → Customizations → Plugins, and toggle Context Mode on or off with one click.
You can adjust the file read cutoff directly in the sidecar dashboard dropdown (2 KB, 4 KB, 8 KB, 16 KB, 32 KB, 64 KB, or none).
To remove the plugin from your system:
# Remove global plugin
npx antigravity-plugin-context-mode uninstall
# Remove per-project plugin
npx antigravity-plugin-context-mode uninstall --workspaceMIT © Phillip Webber