context-mode 0.5.9 → 0.5.11

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.
@@ -13,7 +13,7 @@
13
13
  "name": "context-mode",
14
14
  "source": "./",
15
15
  "description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 10 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
16
- "version": "0.5.9",
16
+ "version": "0.5.10",
17
17
  "author": {
18
18
  "name": "Mert Koseoğlu"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 10 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
package/build/server.js CHANGED
@@ -5,7 +5,7 @@ import { z } from "zod";
5
5
  import { PolyglotExecutor } from "./executor.js";
6
6
  import { ContentStore } from "./store.js";
7
7
  import { detectRuntimes, getRuntimeSummary, getAvailableLanguages, hasBunRuntime, } from "./runtime.js";
8
- const VERSION = "0.5.9";
8
+ const VERSION = "0.5.10";
9
9
  const runtimes = detectRuntimes();
10
10
  const available = getAvailableLanguages(runtimes);
11
11
  const server = new McpServer({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "type": "module",
5
5
  "description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
6
6
  "author": "Mert Koseoğlu",
@@ -1,49 +1,21 @@
1
1
  ---
2
2
  name: context-mode
3
3
  description: |
4
- Use context-mode tools (execute, execute_file, fetch_and_index, index, search) instead of
5
- Bash/curl/cat when processing large outputs. The cost of routing through context-mode is near zero,
6
- but flooding context with 50KB+ of raw data is catastrophic.
7
-
8
- Use when the user's intent involves ANY of these categories (and similar variations):
9
-
10
- Documentation & APIs: fetch docs, look up docs, check API reference, find examples,
11
- index documentation, search docs, read the changelog, check release notes.
12
-
13
- Logs & Debugging: analyze logs, check logs, debug errors, find 500s, trace requests,
14
- inspect error output, review stack traces.
15
-
16
- Testing: run tests, check test results, test suite output, coverage report.
17
-
18
- Version Control: git history, recent commits, what changed, diff between branches,
19
- commit log, blame, changelog analysis.
20
-
21
- Data Processing: parse JSON, parse CSV, analyze output, summarize output, process data,
22
- filter results, extract patterns, transform data, count occurrences.
23
-
24
- Infrastructure & Containers: list containers, container resource usage, container stats,
25
- container memory, container CPU, pod status, service health, deployment status,
26
- cluster info, orchestration state, compose services.
27
-
28
- System & Processes: running processes, system resource usage, disk usage, memory usage,
29
- network connections, open ports, file descriptors, system load.
30
-
31
- Package & Dependency Management: list dependencies, outdated packages, dependency tree,
32
- installed packages, audit vulnerabilities, license check.
33
-
34
- Database: list databases, show tables, describe schema, explain query, query results.
35
-
36
- Cloud & DevOps: cloud resources, storage buckets, compute instances, cloud functions,
37
- DNS records, SSL certificates, CDN status, CI/CD pipeline output.
38
-
39
- Code Analysis: count lines, find TODOs, analyze codebase, security audit, code metrics,
40
- find patterns, codebase statistics.
41
-
42
- API Endpoints: hit endpoint, call API, check response, test endpoint, API debugging.
43
-
44
- Or ANY operation where output might exceed 20 lines.
45
- Also use when routing output from other MCP tools (Playwright snapshots, Context7 docs,
46
- GitHub API responses, Sentry data) through index → search to avoid context bloat.
4
+ Use context-mode tools (execute, execute_file) instead of Bash/cat when processing
5
+ large outputs. Trigger phrases: "analyze logs", "summarize output", "process data",
6
+ "parse JSON", "filter results", "extract errors", "check build output",
7
+ "analyze dependencies", "process API response", "large file analysis",
8
+ "extract elements", "page snapshot", "browser snapshot", "take a snapshot",
9
+ "DOM structure", "inspect page", "form fields", "element selectors",
10
+ "web page structure", "accessibility tree", "Playwright snapshot",
11
+ "run tests", "test output", "coverage report", "git log", "recent commits",
12
+ "diff between branches", "list containers", "pod status", "disk usage",
13
+ "fetch docs", "API reference", "index documentation", "hit endpoint",
14
+ "call API", "check response", "query results", "show tables",
15
+ "find TODOs", "count lines", "codebase statistics", "security audit",
16
+ "outdated packages", "dependency tree", "cloud resources", "CI/CD output".
17
+ Also triggers on ANY MCP tool output (Playwright, Context7, GitHub API) that
18
+ may exceed 20 lines, and any operation where output size is uncertain.
47
19
  ---
48
20
 
49
21
  # Context Mode: Default for All Large Output
@@ -72,8 +44,21 @@ About to run a command / read a file / call an API?
72
44
  ├── Fetching web documentation or HTML page?
73
45
  │ └── Use fetch_and_index → search
74
46
 
75
- ├── Processing output from another MCP tool (Playwright, Context7, etc.)?
76
- │ └── Use index search
47
+ ├── Using Playwright (navigate, snapshot, console, network)?
48
+ │ └── ALWAYS use filename parameter to save to file, then:
49
+ │ browser_snapshot(filename) → index(path) or execute_file(path)
50
+ │ browser_console_messages(filename) → execute_file(path)
51
+ │ browser_network_requests(filename) → execute_file(path)
52
+ │ ⚠ browser_navigate returns a snapshot automatically — ignore it,
53
+ │ use browser_snapshot(filename) for any inspection.
54
+
55
+ ├── Processing output from another MCP tool (Context7, GitHub API, etc.)?
56
+ │ ├── Output already in context from a previous tool call?
57
+ │ │ └── Use it directly. Do NOT re-index with index(content: ...).
58
+ │ ├── Need to search the output multiple times?
59
+ │ │ └── Save to file via execute, then index(path) → search
60
+ │ └── One-shot extraction?
61
+ │ └── Save to file via execute, then execute_file(path)
77
62
 
78
63
  └── Reading a file to analyze/summarize (not edit)?
79
64
  └── Use execute_file (file loads into FILE_CONTENT, not context)
@@ -92,7 +77,11 @@ About to run a command / read a file / call an API?
92
77
  | Read a data file | `execute_file` | Analyze CSV, JSON, YAML, XML |
93
78
  | Read source code to analyze | `execute_file` | Count functions, find patterns, extract metrics |
94
79
  | Fetch web docs | `fetch_and_index` | Index React/Next.js/Zod docs, then search |
95
- | Process large MCP output | `index` → `search` | Index Playwright snapshot, then query elements |
80
+ | Playwright snapshot | `browser_snapshot(filename)` `index(path)` → `search` | Save to file, index server-side, query |
81
+ | Playwright snapshot (one-shot) | `browser_snapshot(filename)` → `execute_file(path)` | Save to file, extract in sandbox |
82
+ | Playwright console/network | `browser_*(filename)` → `execute_file(path)` | Save to file, analyze in sandbox |
83
+ | MCP output (already in context) | Use directly | Don't re-index — it's already loaded |
84
+ | MCP output (need multi-query) | `execute` to save → `index(path)` → `search` | Save to file first, index server-side |
96
85
 
97
86
  ## Automatic Triggers
98
87
 
@@ -142,6 +131,9 @@ Use context-mode for ANY of these, without being asked:
142
131
  3. **Be specific in output.** Print bug details with IDs, line numbers, exact values — not just counts.
143
132
  4. **For files you need to EDIT**: Use the normal Read tool. context-mode is for analysis, not editing.
144
133
  5. **For tiny outputs (<5 lines guaranteed)**: Use Bash. Don't over-engineer `git status` through context-mode.
134
+ 6. **Never use `index(content: large_data)`.** Use `index(path: ...)` to read files server-side. The `content` parameter sends data through context as a tool parameter — use it only for small inline text.
135
+ 7. **Always use `filename` parameter** on Playwright tools (`browser_snapshot`, `browser_console_messages`, `browser_network_requests`). Without it, the full output enters context.
136
+ 8. **Don't re-index data already in context.** If an MCP tool returned data in a previous response, it's already loaded — use it directly or save to file first.
145
137
 
146
138
  ## Examples
147
139
 
@@ -181,6 +173,73 @@ print(f"Records: {len(data)}")
181
173
  # ... analyze and print findings
182
174
  ```
183
175
 
176
+ ## Browser & Playwright Integration
177
+
178
+ **When a task involves Playwright snapshots, screenshots, or page inspection, ALWAYS route through file → sandbox.**
179
+
180
+ Playwright `browser_snapshot` returns 10K–135K tokens of accessibility tree data. Calling it without `filename` dumps all of that into context. Passing the output to `index(content: ...)` sends it into context a SECOND time as a parameter. Both are wrong.
181
+
182
+ **The key insight**: `browser_snapshot` has a `filename` parameter that saves to file instead of returning to context. `index` has a `path` parameter that reads files server-side. `execute_file` processes files in a sandbox. **None of these touch context.**
183
+
184
+ ### Workflow A: Snapshot → File → Index → Search (multiple queries)
185
+
186
+ ```
187
+ Step 1: browser_snapshot(filename: "/tmp/playwright-snapshot.md")
188
+ → saves to file, returns ~50B confirmation (NOT 135K tokens)
189
+
190
+ Step 2: index(path: "/tmp/playwright-snapshot.md", source: "Playwright snapshot")
191
+ → reads file SERVER-SIDE, indexes into FTS5, returns ~80B confirmation
192
+
193
+ Step 3: search("login form email password", source: "Playwright")
194
+ → returns only matching chunks (~300B)
195
+ ```
196
+
197
+ **Total context: ~430B** instead of 270K tokens. Real 99% savings.
198
+
199
+ ### Workflow B: Snapshot → File → Execute File (one-shot extraction)
200
+
201
+ ```
202
+ Step 1: browser_snapshot(filename: "/tmp/playwright-snapshot.md")
203
+ → saves to file, returns ~50B confirmation
204
+
205
+ Step 2: execute_file(path: "/tmp/playwright-snapshot.md", language: "javascript", code: "
206
+ const links = [...FILE_CONTENT.matchAll(/- link \"([^\"]+)\"/g)].map(m => m[1]);
207
+ const buttons = [...FILE_CONTENT.matchAll(/- button \"([^\"]+)\"/g)].map(m => m[1]);
208
+ const inputs = [...FILE_CONTENT.matchAll(/- textbox|- checkbox|- radio/g)];
209
+ console.log('Links:', links.length, '| Buttons:', buttons.length, '| Inputs:', inputs.length);
210
+ console.log('Navigation:', links.slice(0, 10).join(', '));
211
+ ")
212
+ → processes in sandbox, returns ~200B summary
213
+ ```
214
+
215
+ **Total context: ~250B** instead of 135K tokens.
216
+
217
+ ### Workflow C: Console & Network (save to file if large)
218
+
219
+ ```
220
+ browser_console_messages(level: "error", filename: "/tmp/console.md")
221
+ → execute_file(path: "/tmp/console.md", ...) or index(path: "/tmp/console.md", ...)
222
+
223
+ browser_network_requests(includeStatic: false, filename: "/tmp/network.md")
224
+ → execute_file(path: "/tmp/network.md", ...) or index(path: "/tmp/network.md", ...)
225
+ ```
226
+
227
+ ### CRITICAL: Why `filename` + `path` is mandatory
228
+
229
+ | Approach | Context cost | Correct? |
230
+ |----------|-------------|----------|
231
+ | `browser_snapshot()` → raw into context | **135K tokens** | NO |
232
+ | `browser_snapshot()` → `index(content: raw)` | **270K tokens** (doubled!) | NO |
233
+ | `browser_snapshot(filename)` → `index(path)` → `search` | **~430B** | YES |
234
+ | `browser_snapshot(filename)` → `execute_file(path)` | **~250B** | YES |
235
+
236
+ ### Key Rule
237
+
238
+ > **ALWAYS use `filename` parameter when calling `browser_snapshot`, `browser_console_messages`, or `browser_network_requests`.**
239
+ > Then process via `index(path: ...)` or `execute_file(path: ...)` — never `index(content: ...)`.
240
+ >
241
+ > Data flow: **Playwright → file → server-side read → context**. Never: **Playwright → context → index(content) → context again**.
242
+
184
243
  ## Anti-Patterns
185
244
 
186
245
  - Using `curl http://api/endpoint` via Bash → 50KB floods context. Use `execute` with fetch instead.
@@ -188,6 +247,11 @@ print(f"Records: {len(data)}")
188
247
  - Using `gh pr list` via Bash → raw JSON in context. Use `execute` with `--jq` filter instead.
189
248
  - Piping Bash output through `| head -20` → you lose the rest. Use `execute` to analyze ALL data and print summary.
190
249
  - Running `npm test` via Bash → full test output in context. Use `execute` to capture and summarize.
250
+ - Calling `browser_snapshot()` WITHOUT `filename` parameter → 135K tokens flood context. **Always** use `browser_snapshot(filename: "/tmp/snap.md")`.
251
+ - Calling `browser_console_messages()` or `browser_network_requests()` WITHOUT `filename` → entire output floods context. **Always** use the `filename` parameter.
252
+ - Passing ANY large data to `index(content: ...)` → data enters context as a parameter. **Always** use `index(path: ...)` to read server-side. The `content` parameter should only be used for small inline text you're composing yourself.
253
+ - Calling an MCP tool (Context7 `query-docs`, GitHub API, etc.) then passing the response to `index(content: response)` → **doubles** context usage. The response is already in context — use it directly or save to file first.
254
+ - Ignoring `browser_navigate` auto-snapshot → navigation response includes a full page snapshot. Don't rely on it for inspection — call `browser_snapshot(filename)` separately.
191
255
 
192
256
  ## Reference Files
193
257