context-mode 1.0.63 → 1.0.64

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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Claude Code plugins by Mert Koseoğlu",
9
- "version": "1.0.63"
9
+ "version": "1.0.64"
10
10
  },
11
11
  "plugins": [
12
12
  {
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 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
16
- "version": "1.0.63",
16
+ "version": "1.0.64",
17
17
  "author": {
18
18
  "name": "Mert Koseoğlu"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
@@ -3,7 +3,7 @@
3
3
  "name": "Context Mode",
4
4
  "kind": "tool",
5
5
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
6
- "version": "1.0.63",
6
+ "version": "1.0.64",
7
7
  "sandbox": {
8
8
  "mode": "permissive",
9
9
  "filesystem_access": "full",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 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
@@ -389,7 +389,7 @@ export function formatBatchQueryResults(store, queries, source, maxOutput = 80 *
389
389
  // ─────────────────────────────────────────────────────────
390
390
  server.registerTool("ctx_execute", {
391
391
  title: "Execute Code",
392
- description: `MANDATORY: Use for any command where output exceeds 20 lines. Execute code in a sandboxed subprocess. Only stdout enters context — raw data stays in the subprocess.${bunNote} Available: ${langList}.\n\nPREFER THIS OVER BASH for: API calls (gh, curl, aws), test runners (npm test, pytest), git queries (git log, git diff), data processing, and ANY CLI command that may produce large output. Bash should only be used for file mutations, git writes, and navigation.`,
392
+ description: `MANDATORY: Use for any command where output exceeds 20 lines. Execute code in a sandboxed subprocess. Only stdout enters context — raw data stays in the subprocess.${bunNote} Available: ${langList}.\n\nPREFER THIS OVER BASH for: API calls (gh, curl, aws), test runners (npm test, pytest), git queries (git log, git diff), data processing, and ANY CLI command that may produce large output. Bash should only be used for file mutations, git writes, and navigation.\n\nTHINK IN CODE: When you need to analyze, count, filter, compare, or process data — write code that does the work and console.log() only the answer. Do NOT read raw data into context to process mentally. Program the analysis, don't compute it in your reasoning. Write robust, pure JavaScript (no npm dependencies). Use only Node.js built-ins (fs, path, child_process). Always wrap in try/catch. Handle null/undefined. Works on both Node.js and Bun.`,
393
393
  inputSchema: z.object({
394
394
  language: z
395
395
  .enum([
@@ -663,7 +663,7 @@ function intentSearch(stdout, intent, source, maxResults = 5) {
663
663
  // ─────────────────────────────────────────────────────────
664
664
  server.registerTool("ctx_execute_file", {
665
665
  title: "Execute File Processing",
666
- description: "Read a file and process it without loading contents into context. The file is read into a FILE_CONTENT variable inside the sandbox. Only your printed summary enters context.\n\nPREFER THIS OVER Read/cat for: log files, data files (CSV, JSON, XML), large source files for analysis, and any file where you need to extract specific information rather than read the entire content.",
666
+ description: "Read a file and process it without loading contents into context. The file is read into a FILE_CONTENT variable inside the sandbox. Only your printed summary enters context.\n\nPREFER THIS OVER Read/cat for: log files, data files (CSV, JSON, XML), large source files for analysis, and any file where you need to extract specific information rather than read the entire content.\n\nTHINK IN CODE: Write code that processes FILE_CONTENT and console.log() only the answer. Don't read files into context to analyze mentally. Write robust, pure JavaScript — no npm deps, try/catch, null-safe. Node.js + Bun compatible.",
667
667
  inputSchema: z.object({
668
668
  path: z
669
669
  .string()
@@ -1267,7 +1267,8 @@ server.registerTool("ctx_batch_execute", {
1267
1267
  "Returns search results directly — no follow-up calls needed.\n\n" +
1268
1268
  "THIS IS THE PRIMARY TOOL. Use this instead of multiple execute() calls.\n\n" +
1269
1269
  "One batch_execute call replaces 30+ execute calls + 10+ search calls.\n" +
1270
- "Provide all commands to run and all queries to search — everything happens in one round trip.",
1270
+ "Provide all commands to run and all queries to search — everything happens in one round trip.\n\n" +
1271
+ "THINK IN CODE: When commands produce data you need to analyze, add processing commands that filter and summarize. Don't pull raw output into context — let the sandbox do the work.",
1271
1272
  inputSchema: z.object({
1272
1273
  commands: z.preprocess(coerceCommandsArray, z
1273
1274
  .array(z.object({
package/cli.bundle.mjs CHANGED
@@ -397,7 +397,9 @@ Performance tip: Install Bun for 3-5x faster JS/TS execution`),console.error("
397
397
  `)});process.on("uncaughtException",t=>{process.stderr.write(`[context-mode] uncaughtException: ${t?.message??t}
398
398
  `)});zc=Dn(),Oc=gi(zc),rt=new Sc({name:"context-mode",version:hh});rt.server.registerCapabilities({prompts:{listChanged:!1},resources:{listChanged:!1}});rt.server.setRequestHandler(po,async()=>({prompts:[]}));rt.server.setRequestHandler(uo,async()=>({resources:[]}));rt.server.setRequestHandler(lo,async()=>({resourceTemplates:[]}));si=new Io({runtimes:zc,projectRoot:process.env.CLAUDE_PROJECT_DIR}),or=null;se={calls:{},bytesReturned:{},bytesIndexed:0,bytesSandboxed:0,cacheHits:0,cacheBytesSaved:0,sessionStart:Date.now()};VN=Oc.join(", "),WN=Ln()?" (Bun detected \u2014 JS/TS runs 3-5x faster)":"",GN="",KN="";rt.registerTool("ctx_execute",{title:"Execute Code",description:`MANDATORY: Use for any command where output exceeds 20 lines. Execute code in a sandboxed subprocess. Only stdout enters context \u2014 raw data stays in the subprocess.${WN} Available: ${VN}.
399
399
 
400
- PREFER THIS OVER BASH for: API calls (gh, curl, aws), test runners (npm test, pytest), git queries (git log, git diff), data processing, and ANY CLI command that may produce large output. Bash should only be used for file mutations, git writes, and navigation.`,inputSchema:U.object({language:U.enum(["javascript","typescript","python","shell","ruby","go","rust","php","perl","r","elixir"]).describe("Runtime language"),code:U.string().describe("Source code to execute. Use console.log (JS/TS), print (Python/Ruby/Perl/R), echo (Shell), echo (PHP), fmt.Println (Go), or IO.puts (Elixir) to output a summary to context."),timeout:U.number().optional().default(3e4).describe("Max execution time in ms"),background:U.boolean().optional().default(!1).describe("Keep process running after timeout (for servers/daemons). Returns partial output without killing the process. IMPORTANT: Do NOT add setTimeout/self-close timers in background scripts \u2014 the process must stay alive until the timeout detaches it. For server+fetch patterns, prefer putting both server and fetch in ONE ctx_execute call instead of using background."),intent:U.string().optional().describe(`What you're looking for in the output. When provided and output is large (>5KB), indexes output into knowledge base and returns section titles + previews \u2014 not full content. Use search(queries: [...]) to retrieve specific sections. Example: 'failing tests', 'HTTP 500 errors'.
400
+ PREFER THIS OVER BASH for: API calls (gh, curl, aws), test runners (npm test, pytest), git queries (git log, git diff), data processing, and ANY CLI command that may produce large output. Bash should only be used for file mutations, git writes, and navigation.
401
+
402
+ THINK IN CODE: When you need to analyze, count, filter, compare, or process data \u2014 write code that does the work and console.log() only the answer. Do NOT read raw data into context to process mentally. Program the analysis, don't compute it in your reasoning. Write robust, pure JavaScript (no npm dependencies). Use only Node.js built-ins (fs, path, child_process). Always wrap in try/catch. Handle null/undefined. Works on both Node.js and Bun.`,inputSchema:U.object({language:U.enum(["javascript","typescript","python","shell","ruby","go","rust","php","perl","r","elixir"]).describe("Runtime language"),code:U.string().describe("Source code to execute. Use console.log (JS/TS), print (Python/Ruby/Perl/R), echo (Shell), echo (PHP), fmt.Println (Go), or IO.puts (Elixir) to output a summary to context."),timeout:U.number().optional().default(3e4).describe("Max execution time in ms"),background:U.boolean().optional().default(!1).describe("Keep process running after timeout (for servers/daemons). Returns partial output without killing the process. IMPORTANT: Do NOT add setTimeout/self-close timers in background scripts \u2014 the process must stay alive until the timeout detaches it. For server+fetch patterns, prefer putting both server and fetch in ONE ctx_execute call instead of using background."),intent:U.string().optional().describe(`What you're looking for in the output. When provided and output is large (>5KB), indexes output into knowledge base and returns section titles + previews \u2014 not full content. Use search(queries: [...]) to retrieve specific sections. Example: 'failing tests', 'HTTP 500 errors'.
401
403
 
402
404
  TIP: Use specific technical terms, not just concepts. Check 'Searchable terms' in the response for available vocabulary.`)})},async({language:t,code:e,timeout:r,background:n,intent:o})=>{if(t==="shell"){let s=gh(e,"execute");if(s)return s}else{let s=fk(e,t,"execute");if(s)return s}try{let s=e;(t==="javascript"||t==="typescript")&&(s=`
403
405
  let __cm_net=0;
@@ -454,7 +456,9 @@ _(timed out after ${r}ms \u2014 partial output shown above)_`}]}):H("ctx_execute
454
456
  stderr:
455
457
  ${i.stderr}`}],isError:!0})}if(i.exitCode!==0){let{isError:u,output:l}=lh({language:t,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr});return o&&o.trim().length>0&&Buffer.byteLength(l)>Cc?(Zt(Buffer.byteLength(l)),H("ctx_execute",{content:[{type:"text",text:Ao(l,o,u?`execute:${t}:error`:`execute:${t}`)}],isError:u})):Buffer.byteLength(l)>Ic?(Zt(Buffer.byteLength(l)),H("ctx_execute",{content:[{type:"text",text:Ao(l,"errors failures exceptions",u?`execute:${t}:error`:`execute:${t}`)}],isError:u})):H("ctx_execute",{content:[{type:"text",text:l}],isError:u})}let c=i.stdout||"(no output)";return o&&o.trim().length>0&&Buffer.byteLength(c)>Cc?(Zt(Buffer.byteLength(c)),H("ctx_execute",{content:[{type:"text",text:Ao(c,o,`execute:${t}`)}]})):Buffer.byteLength(c)>Ic?H("ctx_execute",_k(c,`execute:${t}`)):H("ctx_execute",{content:[{type:"text",text:c}]})}catch(s){let i=s instanceof Error?s.message:String(s);return H("ctx_execute",{content:[{type:"text",text:`Runtime error: ${i}`}],isError:!0})}});Cc=5e3,Ic=102400;rt.registerTool("ctx_execute_file",{title:"Execute File Processing",description:`Read a file and process it without loading contents into context. The file is read into a FILE_CONTENT variable inside the sandbox. Only your printed summary enters context.
456
458
 
457
- PREFER THIS OVER Read/cat for: log files, data files (CSV, JSON, XML), large source files for analysis, and any file where you need to extract specific information rather than read the entire content.`,inputSchema:U.object({path:U.string().describe("Absolute file path or relative to project root"),language:U.enum(["javascript","typescript","python","shell","ruby","go","rust","php","perl","r","elixir"]).describe("Runtime language"),code:U.string().describe("Code to process FILE_CONTENT (file_content in Elixir). Print summary via console.log/print/echo/IO.puts."),timeout:U.number().optional().default(3e4).describe("Max execution time in ms"),intent:U.string().optional().describe("What you're looking for in the output. When provided and output is large (>5KB), returns only matching sections via BM25 search instead of truncated output.")})},async({path:t,language:e,code:r,timeout:n,intent:o})=>{let s=BN(t,"execute_file");if(s)return s;if(e==="shell"){let i=gh(r,"execute_file");if(i)return i}else{let i=fk(r,e,"execute_file");if(i)return i}try{let i=await si.executeFile({path:t,language:e,code:r,timeout:n});if(i.timedOut)return H("ctx_execute_file",{content:[{type:"text",text:`Timed out processing ${t} after ${n}ms`}],isError:!0});if(i.exitCode!==0){let{isError:c,output:u}=lh({language:e,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr});return o&&o.trim().length>0&&Buffer.byteLength(u)>Cc?(Zt(Buffer.byteLength(u)),H("ctx_execute_file",{content:[{type:"text",text:Ao(u,o,c?`file:${t}:error`:`file:${t}`)}],isError:c})):Buffer.byteLength(u)>Ic?(Zt(Buffer.byteLength(u)),H("ctx_execute_file",{content:[{type:"text",text:Ao(u,"errors failures exceptions",c?`file:${t}:error`:`file:${t}`)}],isError:c})):H("ctx_execute_file",{content:[{type:"text",text:u}],isError:c})}let a=i.stdout||"(no output)";return o&&o.trim().length>0&&Buffer.byteLength(a)>Cc?(Zt(Buffer.byteLength(a)),H("ctx_execute_file",{content:[{type:"text",text:Ao(a,o,`file:${t}`)}]})):Buffer.byteLength(a)>Ic?H("ctx_execute_file",_k(a,`file:${t}`)):H("ctx_execute_file",{content:[{type:"text",text:a}]})}catch(i){let a=i instanceof Error?i.message:String(i);return H("ctx_execute_file",{content:[{type:"text",text:`Runtime error: ${a}`}],isError:!0})}});rt.registerTool("ctx_index",{title:"Index Content",description:`Index documentation or knowledge content into a searchable BM25 knowledge base. Chunks markdown by headings (keeping code blocks intact) and stores in ephemeral FTS5 database. The full content does NOT stay in context \u2014 only a brief summary is returned.
459
+ PREFER THIS OVER Read/cat for: log files, data files (CSV, JSON, XML), large source files for analysis, and any file where you need to extract specific information rather than read the entire content.
460
+
461
+ THINK IN CODE: Write code that processes FILE_CONTENT and console.log() only the answer. Don't read files into context to analyze mentally. Write robust, pure JavaScript \u2014 no npm deps, try/catch, null-safe. Node.js + Bun compatible.`,inputSchema:U.object({path:U.string().describe("Absolute file path or relative to project root"),language:U.enum(["javascript","typescript","python","shell","ruby","go","rust","php","perl","r","elixir"]).describe("Runtime language"),code:U.string().describe("Code to process FILE_CONTENT (file_content in Elixir). Print summary via console.log/print/echo/IO.puts."),timeout:U.number().optional().default(3e4).describe("Max execution time in ms"),intent:U.string().optional().describe("What you're looking for in the output. When provided and output is large (>5KB), returns only matching sections via BM25 search instead of truncated output.")})},async({path:t,language:e,code:r,timeout:n,intent:o})=>{let s=BN(t,"execute_file");if(s)return s;if(e==="shell"){let i=gh(r,"execute_file");if(i)return i}else{let i=fk(r,e,"execute_file");if(i)return i}try{let i=await si.executeFile({path:t,language:e,code:r,timeout:n});if(i.timedOut)return H("ctx_execute_file",{content:[{type:"text",text:`Timed out processing ${t} after ${n}ms`}],isError:!0});if(i.exitCode!==0){let{isError:c,output:u}=lh({language:e,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr});return o&&o.trim().length>0&&Buffer.byteLength(u)>Cc?(Zt(Buffer.byteLength(u)),H("ctx_execute_file",{content:[{type:"text",text:Ao(u,o,c?`file:${t}:error`:`file:${t}`)}],isError:c})):Buffer.byteLength(u)>Ic?(Zt(Buffer.byteLength(u)),H("ctx_execute_file",{content:[{type:"text",text:Ao(u,"errors failures exceptions",c?`file:${t}:error`:`file:${t}`)}],isError:c})):H("ctx_execute_file",{content:[{type:"text",text:u}],isError:c})}let a=i.stdout||"(no output)";return o&&o.trim().length>0&&Buffer.byteLength(a)>Cc?(Zt(Buffer.byteLength(a)),H("ctx_execute_file",{content:[{type:"text",text:Ao(a,o,`file:${t}`)}]})):Buffer.byteLength(a)>Ic?H("ctx_execute_file",_k(a,`file:${t}`)):H("ctx_execute_file",{content:[{type:"text",text:a}]})}catch(i){let a=i instanceof Error?i.message:String(i);return H("ctx_execute_file",{content:[{type:"text",text:`Runtime error: ${a}`}],isError:!0})}});rt.registerTool("ctx_index",{title:"Index Content",description:`Index documentation or knowledge content into a searchable BM25 knowledge base. Chunks markdown by headings (keeping code blocks intact) and stores in ephemeral FTS5 database. The full content does NOT stay in context \u2014 only a brief summary is returned.
458
462
 
459
463
  WHEN TO USE:
460
464
  - Documentation from Context7, Skills, or MCP tools (API docs, framework guides, code examples)
@@ -508,7 +512,9 @@ Use: search(queries: [...], source: "${i.label}")`}]})}}}let n=xr(UN(),`ctx-fetc
508
512
  THIS IS THE PRIMARY TOOL. Use this instead of multiple execute() calls.
509
513
 
510
514
  One batch_execute call replaces 30+ execute calls + 10+ search calls.
511
- Provide all commands to run and all queries to search \u2014 everything happens in one round trip.`,inputSchema:U.object({commands:U.preprocess(YN,U.array(U.object({label:U.string().describe("Section header for this command's output (e.g., 'README', 'Package.json', 'Source Tree')"),command:U.string().describe("Shell command to execute")})).min(1).describe("Commands to execute as a batch. Each runs sequentially, output is labeled with the section header.")),queries:U.preprocess(yh,U.array(U.string()).min(1).describe("Search queries to extract information from indexed output. Use 5-8 comprehensive queries. Each returns top 5 matching sections with full content. This is your ONLY chance \u2014 put ALL your questions here. No follow-up calls needed.")),timeout:U.number().optional().default(6e4).describe("Max execution time in ms (default: 60s)")})},async({commands:t,queries:e,timeout:r})=>{for(let n of t){let o=gh(n.command,"batch_execute");if(o)return o}try{let n=[],o=Date.now(),s=!1;for(let y of t){let b=Date.now()-o,w=r-b;if(w<=0){n.push(`# ${y.label}
515
+ Provide all commands to run and all queries to search \u2014 everything happens in one round trip.
516
+
517
+ THINK IN CODE: When commands produce data you need to analyze, add processing commands that filter and summarize. Don't pull raw output into context \u2014 let the sandbox do the work.`,inputSchema:U.object({commands:U.preprocess(YN,U.array(U.object({label:U.string().describe("Section header for this command's output (e.g., 'README', 'Package.json', 'Source Tree')"),command:U.string().describe("Shell command to execute")})).min(1).describe("Commands to execute as a batch. Each runs sequentially, output is labeled with the section header.")),queries:U.preprocess(yh,U.array(U.string()).min(1).describe("Search queries to extract information from indexed output. Use 5-8 comprehensive queries. Each returns top 5 matching sections with full content. This is your ONLY chance \u2014 put ALL your questions here. No follow-up calls needed.")),timeout:U.number().optional().default(6e4).describe("Max execution time in ms (default: 60s)")})},async({commands:t,queries:e,timeout:r})=>{for(let n of t){let o=gh(n.command,"batch_execute");if(o)return o}try{let n=[],o=Date.now(),s=!1;for(let y of t){let b=Date.now()-o,w=r-b;if(w<=0){n.push(`# ${y.label}
512
518
 
513
519
  (skipped \u2014 batch timeout exceeded)
514
520
  `),s=!0;continue}let T=await si.execute({language:"shell",code:`${y.command} 2>&1`,timeout:w}),ae=T.stdout||"(no output)";if(n.push(`# ${y.label}
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session. Antigravity does NOT have hooks, so these instructions are your ONLY enforcement mechanism. Follow them strictly.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `mcp__context-mode__ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT use these
6
10
 
7
11
  ### curl / wget — FORBIDDEN
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT attempt these
6
10
 
7
11
  ### curl / wget — BLOCKED
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session. Codex CLI does NOT have hooks, so these instructions are your ONLY enforcement mechanism. Follow them strictly.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT use these
6
10
 
7
11
  ### curl / wget — FORBIDDEN
@@ -7,6 +7,10 @@ alwaysApply: true
7
7
 
8
8
  Raw tool output floods your context window. Use context-mode MCP tools to keep raw data in the sandbox.
9
9
 
10
+ ## Think in Code — MANDATORY
11
+
12
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
13
+
10
14
  ## Tool Selection
11
15
 
12
16
  1. **GATHER**: `ctx_batch_execute(commands, queries)` — Primary tool for research. Runs all commands, auto-indexes, and searches. ONE call replaces many individual steps.
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `mcp__context-mode__ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT attempt these
6
10
 
7
11
  ### curl / wget — BLOCKED
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `context-mode_ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT attempt these
6
10
 
7
11
  ### curl / wget — BLOCKED
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `@context-mode/ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT attempt these
6
10
 
7
11
  ### curl / wget — BLOCKED
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT attempt these
6
10
 
7
11
  ### curl / wget — BLOCKED
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `context-mode_ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT attempt these
6
10
 
7
11
  ### curl / wget — BLOCKED
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session. Pi enforces routing via hooks (`tool_call` blocks `curl`/`wget`) AND these instructions. Hooks provide hard enforcement at the tool level; these rules provide completeness — covering redirections and patterns that hooks alone cannot catch. Follow them strictly.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT use these
6
10
 
7
11
  ### curl / wget — FORBIDDEN (hook-enforced)
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT attempt these
6
10
 
7
11
  ### curl / wget — BLOCKED
@@ -2,6 +2,10 @@
2
2
 
3
3
  You have context-mode MCP tools available. These rules are NOT optional — they protect your context window from flooding. A single unrouted command can dump 56 KB into context and waste the entire session. Zed does NOT have hooks, so these instructions are your ONLY enforcement mechanism. Follow them strictly.
4
4
 
5
+ ## Think in Code — MANDATORY
6
+
7
+ When you need to analyze, count, filter, compare, search, parse, transform, or process data: **write code** that does the work via `mcp:context-mode:ctx_execute(language, code)` and `console.log()` only the answer. Do NOT read raw data into context to process mentally. Your role is to PROGRAM the analysis, not to COMPUTE it. Write robust, pure JavaScript — no npm dependencies, only Node.js built-ins (`fs`, `path`, `child_process`). Always use `try/catch`, handle `null`/`undefined`, and ensure compatibility with both Node.js and Bun. One script replaces ten tool calls and saves 100x context.
8
+
5
9
  ## BLOCKED commands — do NOT use these
6
10
 
7
11
  ### curl / wget — FORBIDDEN
@@ -220,7 +220,7 @@ export function routePreToolUse(toolName, toolInput, projectDir, platform) {
220
220
  return {
221
221
  action: "modify",
222
222
  updatedInput: {
223
- command: `echo "context-mode: curl/wget blocked. You MUST use ${t("ctx_fetch_and_index")}(url, source) to fetch URLs, or ${t("ctx_execute")}(language, code) to run HTTP calls in sandbox. Do NOT retry with curl/wget."`,
223
+ command: `echo "context-mode: curl/wget blocked. Think in Code — use ${t("ctx_execute")}(language, code) to write code that fetches, processes, and prints only the answer. Or use ${t("ctx_fetch_and_index")}(url, source) to fetch and index. Write pure JS with try/catch, no npm deps. Do NOT retry with curl/wget."`,
224
224
  },
225
225
  };
226
226
  }
@@ -242,7 +242,7 @@ export function routePreToolUse(toolName, toolInput, projectDir, platform) {
242
242
  return {
243
243
  action: "modify",
244
244
  updatedInput: {
245
- command: `echo "context-mode: Inline HTTP blocked. Use ${t("ctx_execute")}(language, code) to run HTTP calls in sandbox, or ${t("ctx_fetch_and_index")}(url, source) for web pages. Do NOT retry with Bash."`,
245
+ command: `echo "context-mode: Inline HTTP blocked. Think in Code — use ${t("ctx_execute")}(language, code) to write code that fetches, processes, and console.log() only the result. Write robust pure JS with try/catch, no npm deps. Do NOT retry with Bash."`,
246
246
  },
247
247
  };
248
248
  }
@@ -254,7 +254,7 @@ export function routePreToolUse(toolName, toolInput, projectDir, platform) {
254
254
  return {
255
255
  action: "modify",
256
256
  updatedInput: {
257
- command: `echo "context-mode: Build tool redirected to sandbox. Use ${t("ctx_execute")}(language: \\"shell\\", code: \\"${safeCmd}\\") to run this command. Do NOT retry with Bash."`,
257
+ command: `echo "context-mode: Build tool redirected. Think in Code — use ${t("ctx_execute")}(language: \\"shell\\", code: \\"${safeCmd} 2>&1 | tail -30\\") to run and print only errors/summary. Do NOT retry with Bash."`,
258
258
  },
259
259
  };
260
260
  }
@@ -278,7 +278,7 @@ export function routePreToolUse(toolName, toolInput, projectDir, platform) {
278
278
  const url = toolInput.url ?? "";
279
279
  return {
280
280
  action: "deny",
281
- reason: `context-mode: WebFetch blocked. Use ${t("ctx_fetch_and_index")}(url: "${url}", source: "...") to fetch this URL in sandbox. Then use ${t("ctx_search")}(queries: [...]) to query results. Do NOT use curl, wget, mcp_web_fetch, or mcp_fetch_tool.`,
281
+ reason: `context-mode: WebFetch blocked. Think in Code — use ${t("ctx_fetch_and_index")}(url: "${url}", source: "...") to fetch and index, then ${t("ctx_search")}(queries: [...]) to query. Or use ${t("ctx_execute")}(language, code) to fetch, process, and console.log() only what you need. Write pure JS, no npm deps. Do NOT use curl, wget, or WebFetch.`,
282
282
  };
283
283
  }
284
284
 
@@ -3,7 +3,7 @@
3
3
  "name": "Context Mode",
4
4
  "kind": "tool",
5
5
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
6
- "version": "1.0.63",
6
+ "version": "1.0.64",
7
7
  "sandbox": {
8
8
  "mode": "permissive",
9
9
  "filesystem_access": "full",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "type": "module",
5
5
  "description": "MCP plugin that saves 98% of your context window. Works with Claude Code, Gemini CLI, VS Code Copilot, OpenCode, and Codex CLI. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
6
6
  "author": "Mert Koseoğlu",