antigravity-plugin-context-mode 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: context-mode
3
+ description: Protects the Antigravity agent context window by keeping massive tool outputs, logs, web pages, and bulk datasets out of context. Uses local SQLite FTS5 search (Porter BM25 + Trigram RRF) and sandboxed code execution (Thinking in Code). Use when analyzing large logs, inspecting multi-thousand line files, running bulk commands, or analyzing API data.
4
+ ---
5
+
6
+ # Antigravity Context Mode ("Thinking in Code")
7
+
8
+ **Context Mode** keeps large tool outputs, command results, and file dumps out of your context window.
9
+ Instead of dumping megabytes of text into the conversation, Context Mode indexes data into a local SQLite FTS5 database (`~/.context-mode/context.db`) and executes short sandboxed scripts that return only the exact answer or filtered snippets.
10
+
11
+ ---
12
+
13
+ ## When to Use Context Mode
14
+
15
+ | Task | Traditional Tool (High Bloat) | Context Mode Solution (Zero Bloat) |
16
+ | :--- | :--- | :--- |
17
+ | **Analyzing build or server logs** | `run_command("Get-Content Logs/Editor.log")` | `ctx_execute(code: "...", intent: "Find compile errors in Editor.log")` |
18
+ | **Searching huge documentation or code** | Full `read_file` (> 400 lines) | `ctx_index(path: "...")` $\rightarrow$ `ctx_search(queries: ["..."])` |
19
+ | **Processing API JSON responses** | Fetching and dumping 5,000 JSON items | `ctx_execute(language: "javascript", code: "fetch(...)")` |
20
+ | **Running multi-command batches** | Running 10 commands in separate tool calls | `ctx_batch(commands: [...], queries: [...])` |
21
+ | **Session recovery & token stats** | Re-reading entire past conversation | `ctx_resume()` / `ctx_stats()` |
22
+
23
+ ---
24
+
25
+ ## Tools Reference
26
+
27
+ ### 1. `ctx_execute` (Thinking in Code)
28
+ Executes a short script in a local sandbox (Node.js, Python, PowerShell, or Shell) with an execution cap and timeout. The full output is automatically indexed into SQLite FTS5, and only the compact result (or a preview if large) is returned to the context window.
29
+
30
+ ```json
31
+ {
32
+ "language": "javascript",
33
+ "code": "const fs = require('fs'); const lines = fs.readFileSync('Logs/Editor.log', 'utf8').split('\\n'); const errors = lines.filter(l => l.includes('error CS')); console.log(JSON.stringify(errors, null, 2));",
34
+ "intent": "Filter C# compiler errors from Editor.log"
35
+ }
36
+ ```
37
+
38
+ ### 2. `ctx_index`
39
+ Indexes a local file, web URL, or raw string into SQLite FTS5 chunks:
40
+ ```json
41
+ {
42
+ "path": "Documentation/Architecture.md",
43
+ "label": "Architecture Guide"
44
+ }
45
+ ```
46
+
47
+ ### 3. `ctx_search`
48
+ Queries indexed chunks using Reciprocal Rank Fusion (Porter BM25 stemming + Trigram matching). Returns ranked snippets:
49
+ ```json
50
+ {
51
+ "queries": ["NullReferenceException", "ShipMovementService"],
52
+ "limit": 5
53
+ }
54
+ ```
55
+
56
+ ### 4. `ctx_batch`
57
+ Executes multiple shell commands in batch. The combined outputs are indexed and filtered by your queries:
58
+ ```json
59
+ {
60
+ "commands": [
61
+ "git status -s",
62
+ "git log -n 5 --oneline",
63
+ "npm test"
64
+ ],
65
+ "queries": ["failing", "error"]
66
+ }
67
+ ```
68
+
69
+ ### 5. `ctx_stats`
70
+ Generates a token savings report showing how many raw bytes and estimated tokens were kept out of the model's context window:
71
+ ```json
72
+ {}
73
+ ```
74
+
75
+ ### 6. `ctx_doctor`
76
+ Checks SQLite database health, FTS5 availability, and active runtimes.
77
+
78
+ ---
79
+
80
+ ## Best Practices
81
+
82
+ 1. **Write focused extraction scripts**: In `ctx_execute`, print only the final data structures or count summaries rather than raw loops.
83
+ 2. **Never dump full logs**: If a log file is > 100 KB, never call `read_file` or bare `Get-Content`. Route it through `ctx_execute` or `ctx_index`.
84
+ 3. **Use Trigram for identifiers**: `ctx_search` matches code symbols, GUIDs, and file paths via trigram indexing even if English stemming does not match.