@mxalbert/context-mode 2.0.3 → 2.0.4
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/build/cli.js +2 -2
- package/build/security.d.ts +44 -10
- package/build/security.js +147 -32
- package/build/server.js +3 -4
- package/cli.bundle.mjs +196 -196
- package/configs/antigravity-cli/plugin.json +1 -1
- package/configs/copilot-cli/.github/plugin/plugin.json +1 -1
- package/hooks/core/routing.mjs +1 -1
- package/hooks/security.bundle.mjs +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +137 -137
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "context-mode for Antigravity CLI (agy): sandboxed code execution, FTS5 knowledge base, and session capture. Saves your context window by keeping raw bytes out of the conversation.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
3
|
"description": "context-mode for GitHub Copilot CLI: sandboxed code execution in 11 languages, an FTS5 knowledge base with BM25 ranking, and session capture. Saves your context window by keeping raw bytes out of the conversation.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.4",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
7
7
|
"context-window",
|
package/hooks/core/routing.mjs
CHANGED
|
@@ -1043,7 +1043,7 @@ export function routePreToolUse(toolName, toolInput, projectDir, platform, sessi
|
|
|
1043
1043
|
// Check file path against Read deny patterns
|
|
1044
1044
|
const filePath = toolInput.path ?? "";
|
|
1045
1045
|
const denyGlobs = security.readToolDenyPatterns("Read", projectDir, platformSettingsPath);
|
|
1046
|
-
const evalResult = security.evaluateFilePath(filePath, denyGlobs);
|
|
1046
|
+
const evalResult = security.evaluateFilePath(filePath, denyGlobs, undefined, projectDir);
|
|
1047
1047
|
if (evalResult.denied) {
|
|
1048
1048
|
return { action: "deny", reason: `Blocked by security policy: file path matches Read deny pattern ${evalResult.matchedPattern}` };
|
|
1049
1049
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`||
|
|
1
|
+
var E=(t,n)=>()=>(t&&(n=t(t=0)),n);var b,S=E(()=>{"use strict";b={"claude-code":"claude-code","gemini-cli-mcp-client":"gemini-cli","antigravity-client":"antigravity","antigravity-cli":"antigravity-cli",agy:"antigravity-cli","cursor-vscode":"cursor","Visual-Studio-Code":"vscode-copilot","copilot-cli":"copilot-cli","GitHub Copilot CLI":"copilot-cli","github-copilot-cli":"copilot-cli","JetBrains Client":"jetbrains-copilot","IntelliJ IDEA":"jetbrains-copilot",PyCharm:"jetbrains-copilot",Codex:"codex","codex-mcp-client":"codex","Kilo Code":"kilo","Kiro CLI":"kiro","Pi CLI":"pi","Pi Coding Agent":"pi","omp-coding-agent":"omp",Zed:"zed",zed:"zed","qwen-code":"qwen-code","qwen-cli-mcp-client":"qwen-code","kimi-code":"kimi",kimi:"kimi","Kimi Code":"kimi"}});import{existsSync as u,readFileSync as V}from"node:fs";import{resolve as f}from"node:path";import{homedir as R}from"node:os";function z(){if(w!==null)return w!=="miss"&&w.hasCM;try{let t=f(R(),".claude","plugins","installed_plugins.json"),n=V(t,"utf-8"),e=JSON.parse(n),r=[...Object.keys(e.plugins??{}),...Object.keys(e.enabledPlugins??{})].some(i=>i.includes("context-mode"));return w={hasCM:r},r}catch{return w="miss",!1}}function D(t){switch(t){case"claude-code":return[".claude"];case"gemini-cli":return[".gemini"];case"antigravity":return[".gemini"];case"antigravity-cli":return[".gemini"];case"openclaw":return[".openclaw"];case"codex":return[".codex"];case"cursor":return[".cursor"];case"vscode-copilot":return[".vscode"];case"copilot-cli":return[".copilot"];case"kiro":return[".kiro"];case"pi":return[".pi"];case"omp":return[".omp"];case"qwen-code":return[".qwen"];case"kimi":return[".kimi-code"];case"kilo":return[".config","kilo"];case"opencode":return[".config","opencode"];case"zed":return[".config","zed"];case"jetbrains-copilot":return[".config","JetBrains"];default:return null}}function T(t){if(t?.name){let i=b[t.name];if(i)return{platform:i,confidence:"high",reason:`MCP clientInfo.name="${t.name}"`};if(t.name.startsWith("qwen-cli-mcp-client"))return{platform:"qwen-code",confidence:"high",reason:`MCP clientInfo.name="${t.name}" (qwen-cli pattern)`}}let n=process.env.CONTEXT_MODE_PLATFORM;if(n&&["claude-code","gemini-cli","kilo","opencode","codex","vscode-copilot","jetbrains-copilot","copilot-cli","cursor","antigravity","antigravity-cli","kiro","pi","omp","zed","qwen-code","kimi"].includes(n))return{platform:n,confidence:"high",reason:`CONTEXT_MODE_PLATFORM=${n} override`};for(let[i,a]of B)if(a.some(c=>c.detect!==!1&&process.env[c.name]))return i==="vscode-copilot"&&z()?{platform:"claude-code",confidence:"high",reason:"VSCODE_PID set but ~/.claude/plugins/installed_plugins.json lists context-mode (issue #539 fallback)"}:{platform:i,confidence:"high",reason:`${a.filter(c=>c.detect!==!1).map(c=>c.name).join(" or ")} env var set`};let e=R(),o=(()=>{let i=process.env.COPILOT_HOME;return i&&i.trim()!==""?i.startsWith("~")?f(e,i.replace(/^~[/\\]?/,"")):f(i):f(e,".copilot")})(),r=u(f(o,"mcp-config.json"))||u(f(o,"hooks","context-mode.json"));return process.env.COPILOT_HOME?.trim()&&r?{platform:"copilot-cli",confidence:"medium",reason:"context-mode config in explicit COPILOT_HOME exists (mcp-config.json or hooks/context-mode.json)"}:u(f(e,".local","bin","agy"))||u(f(e,".gemini","antigravity-cli"))||u(f(e,".gemini","config","mcp_config.json"))?{platform:"antigravity-cli",confidence:"medium",reason:"Antigravity CLI marker exists (~/.local/bin/agy, ~/.gemini/antigravity-cli, or ~/.gemini/config/mcp_config.json)"}:r?{platform:"copilot-cli",confidence:"medium",reason:"context-mode config in Copilot CLI home exists (mcp-config.json or hooks/context-mode.json; honors COPILOT_HOME)"}:u(f(e,".claude"))?{platform:"claude-code",confidence:"medium",reason:"~/.claude/ directory exists"}:u(f(e,".gemini"))?{platform:"gemini-cli",confidence:"medium",reason:"~/.gemini/ directory exists"}:u(f(e,".codex"))?{platform:"codex",confidence:"medium",reason:"~/.codex/ directory exists"}:u(f(e,".kiro"))?{platform:"kiro",confidence:"medium",reason:"~/.kiro/ directory exists"}:u(f(e,".omp"))?{platform:"omp",confidence:"medium",reason:"~/.omp/ directory exists"}:u(f(e,".pi"))?{platform:"pi",confidence:"medium",reason:"~/.pi/ directory exists"}:u(f(e,".qwen"))?{platform:"qwen-code",confidence:"medium",reason:"~/.qwen/ directory exists"}:u(f(e,".kimi-code"))?{platform:"kimi",confidence:"medium",reason:"~/.kimi-code/ directory exists"}:u(f(e,".openclaw"))?{platform:"openclaw",confidence:"medium",reason:"~/.openclaw/ directory exists"}:u(f(e,".cursor"))?{platform:"cursor",confidence:"medium",reason:"~/.cursor/ directory exists"}:u(f(e,".config","kilo"))?{platform:"kilo",confidence:"medium",reason:"~/.config/kilo/ directory exists"}:u(f(e,".config","JetBrains"))?{platform:"jetbrains-copilot",confidence:"medium",reason:"~/.config/JetBrains/ directory exists"}:u(f(e,".config","opencode"))?{platform:"opencode",confidence:"medium",reason:"~/.config/opencode/ directory exists"}:u(f(e,".config","zed"))?{platform:"zed",confidence:"medium",reason:"~/.config/zed/ directory exists"}:{platform:"claude-code",confidence:"low",reason:"No platform detected, defaulting to Claude Code"}}var w,H,B,N=E(()=>{"use strict";S();w=null;H=[["claude-code",[{name:"CLAUDE_CODE_ENTRYPOINT",role:"identification"},{name:"CLAUDE_PLUGIN_ROOT",role:"identification"},{name:"CLAUDE_PROJECT_DIR",role:"workspace"},{name:"CLAUDE_SESSION_ID",role:"identification"}]],["antigravity",[{name:"ANTIGRAVITY_CLI_ALIAS",role:"identification"}]],["cursor",[{name:"CURSOR_CWD",role:"workspace"},{name:"CURSOR_TRACE_ID",role:"identification"},{name:"CURSOR_CLI",role:"identification"}]],["kilo",[{name:"KILO",role:"identification"},{name:"KILO_PID",role:"identification"}]],["opencode",[{name:"OPENCODE_PROJECT_DIR",role:"workspace"},{name:"OPENCODE_CLIENT",role:"identification"},{name:"OPENCODE_TERMINAL",role:"identification"},{name:"OPENCODE",role:"identification"},{name:"OPENCODE_PID",role:"identification"}]],["zed",[{name:"ZED_SESSION_ID",role:"identification"},{name:"ZED_TERM",role:"identification"}]],["codex",[{name:"CODEX_THREAD_ID",role:"identification"},{name:"CODEX_CI",role:"identification"}]],["gemini-cli",[{name:"GEMINI_PROJECT_DIR",role:"workspace"},{name:"GEMINI_CLI",role:"identification"}]],["vscode-copilot",[{name:"VSCODE_CWD",role:"workspace"},{name:"VSCODE_PID",role:"identification"}]],["jetbrains-copilot",[{name:"IDEA_INITIAL_DIRECTORY",role:"workspace"}]],["qwen-code",[{name:"QWEN_PROJECT_DIR",role:"workspace"}]],["omp",[{name:"PI_CODING_AGENT_DIR",role:"workspace"}]],["pi",[{name:"PI_WORKSPACE_DIR",role:"workspace",detect:!1},{name:"PI_PROJECT_DIR",role:"workspace",detect:!1},{name:"PI_CONFIG_DIR",role:"identification"},{name:"PI_SESSION_FILE",role:"identification"},{name:"PI_COMPILED",role:"identification"},{name:"PI_CODING_AGENT",role:"identification"}]]],B=new Map(H)});import{resolve as C}from"node:path";import{homedir as _}from"node:os";function U(t=process.env){let n=t.CLAUDE_CONFIG_DIR;return n&&n.trim()!==""?n.startsWith("~")?C(_(),n.replace(/^~[/\\]?/,"")):C(n):C(_(),".claude")}function K(t=process.env){return C(U(t),"settings.json")}function I(t=process.env){let n=[],e=T();if(e.platform!=="claude-code"){let r=D(e.platform);r&&r.length>0&&n.push(C(_(),...r,"settings.json"))}let o=K(t);return n.includes(o)||n.push(o),n}var L=E(()=>{"use strict";N()});L();import{readFileSync as F,realpathSync as x}from"node:fs";import{homedir as M}from"node:os";import{dirname as X,isAbsolute as Z,relative as Y,resolve as h,sep as A}from"node:path";function $(t){let n=t.match(/^Bash\((.+)\)$/);return n?n[1]:null}function Q(t){let n=t.match(/^(\w+)\((.+)\)$/);return n?{tool:n[1],glob:n[2]}:null}function ee(t){return t.replace(/[.*+?^${}()|[\]\\\/\-]/g,"\\$&")}function j(t){return t.replace(/[.+?^${}()|[\]\\\/\-]/g,"\\$&").replace(/\*/g,".*")}function te(t,n=!1){let e,o=t.indexOf(":");if(o!==-1){let r=t.slice(0,o),i=t.slice(o+1),a=ee(r),c=j(i);e=`^${a}(\\s${c})?$`}else e=`^${j(t)}$`;return new RegExp(e,n?"i":"")}function ne(t,n=!1){let e="",o=0;for(;o<t.length;)t[o]==="*"&&t[o+1]==="*"?o+2<t.length&&t[o+2]==="/"?(e+="(.*/)?",o+=3):(e+=".*",o+=2):t[o]==="*"?(e+="[^/]*",o++):t[o]==="?"?(e+="[^/]",o++):(e+=t[o].replace(/[.+^${}()|[\]\\\/\-]/g,"\\$&"),o++);return new RegExp(`^${e}$`,n?"i":"")}function P(t,n,e=!1){for(let o of n){let r=$(o);if(r&&te(r,e).test(t))return o}return null}function J(t,n){let e=0;for(let o=n-1;o>=0&&t[o]==="\\";o--)e++;return e%2===1}function oe(t){let n=[],e="",o=!1,r=!1,i=!1,a=0;for(let c=0;c<t.length;c++){let s=t[c],l=J(t,c);s==="'"&&!r&&!i&&!l?(o=!o,e+=s):s==='"'&&!o&&!i&&!l?(r=!r,e+=s):s==="`"&&!o&&!r&&!l?(i=!i,e+=s):!o&&!r&&!i?s==="$"&&t[c+1]==="("&&!l?(a++,e+=s+t[c+1],c++):a>0&&s==="("&&!l?(a++,e+=s):s===")"&&a>0&&!l?(a--,e+=s):a===0&&(s===";"||s===`
|
|
2
|
+
`||s==="\r")&&!l?(n.push(e.trim()),e=""):a===0&&s==="|"&&t[c+1]==="|"||a===0&&s==="&"&&t[c+1]==="&"?(n.push(e.trim()),e="",c++):a===0&&s==="&"&&!l||a===0&&s==="|"?(n.push(e.trim()),e=""):e+=s:e+=s}return e.trim()&&n.push(e.trim()),n.filter(c=>c.length>0)}function W(t){let n=[],e=!1,o=!1,r=-1,i=[],a=[],c=0;for(let s=0;s<t.length;s++){let l=t[s],d=J(t,s);if(l==="'"&&!o&&r===-1&&!d)e=!e;else if(l==='"'&&!e&&r===-1&&!d)o=!o;else if(l==="`"&&!e&&!o&&!d)if(r===-1)r=s+1;else{let p=t.slice(r,s);n.push(p),n.push(...W(p)),r=-1}else if(!e&&r===-1){if(l==="$"&&t[s+1]==="("&&!d)t[s+2]==="("?(c+=2,s+=2):(i.push(s+2),a.push(c),c++,s++);else if(l==="("&&!d)c++;else if(l===")"&&!d&&(c>0&&c--,a.length>0&&c===a[a.length-1])){a.pop();let p=i.pop(),g=t.slice(p,s);n.push(g)}}}return n}function v(t){let n=[],e=oe(t);for(let o of e){n.push(o);for(let r of W(o))n.push(...v(r))}return n}function k(t){let n;try{n=F(t,"utf-8")}catch{return null}let e;try{e=JSON.parse(n)}catch{return null}let o=e?.permissions;if(!o||typeof o!="object")return null;let r=i=>Array.isArray(i)?i.filter(a=>typeof a=="string"&&$(a)!==null):[];return{allow:r(o.allow),deny:r(o.deny),ask:r(o.ask)}}function Ae(t,n){let e=[];if(t){let r=h(t,".claude","settings.local.json"),i=k(r);i&&e.push(i);let a=h(t,".claude","settings.json"),c=k(a);c&&e.push(c)}let o=n!==void 0?[n]:I();for(let r of o){let i=k(r);i&&e.push(i)}return e}function Oe(t,n,e){return re(t,"deny",n,e)}function re(t,n,e,o){let r=[],i=(c,s)=>{let l;try{l=F(c,"utf-8")}catch{return null}let d;try{d=JSON.parse(l)}catch{return null}let p=d?.permissions?.[n];if(!Array.isArray(p))return[];let g=[];for(let y of p){if(typeof y!="string")continue;let m=Q(y);m&&m.tool===t&&(g.push(m.glob),s&&m.glob.startsWith("/")&&!m.glob.startsWith("//")&&g.push(h(s,"."+m.glob)))}return g};if(e){let c=i(h(e,".claude","settings.local.json"),e);c!==null&&r.push(c);let s=i(h(e,".claude","settings.json"),e);s!==null&&r.push(s)}let a=o!==void 0?[o]:I();for(let c of a){let s=i(c,X(c));s!==null&&r.push(s)}return r}function ve(t,n,e=process.platform==="win32"||process.platform==="darwin"){let o=v(t);for(let r of o)for(let i of n){let a=P(r,i.deny,e);if(a)return{decision:"deny",matchedPattern:a}}for(let r of n){let i=!0,a=!1,c,s;for(let l of o){let d=P(l,r.ask,e);if(d){a=!0,c=d;break}let p=P(l,r.allow,e);p?s=p:i=!1}if(a)return{decision:"ask",matchedPattern:c};if(i&&o.length>0)return{decision:"allow",matchedPattern:s}}return{decision:"ask"}}function be(t,n,e=process.platform==="win32"||process.platform==="darwin"){let o=v(t);for(let r of o)for(let i of n){let a=P(r,i.deny,e);if(a)return{decision:"deny",matchedPattern:a}}return{decision:"allow"}}function O(t){return t==="~"?M():t.startsWith("~/")||t.startsWith("~\\")?M()+t.slice(1):t}function G(t){return t.startsWith("//")?t.slice(1):t}function ie(t){let n=t.split(/[\\/]/),e=n.findIndex(r=>r.includes("*")||r.includes("?"));if(e===-1&&(e=n.length),e===0)return null;let o=n.slice(0,e).join(A);if(o.length===0)return null;try{return[x(o),...n.slice(e)].join(A)}catch{return null}}function se(t,n,e=process.platform==="win32"||process.platform==="darwin",o){let r=s=>s.replace(/\\/g,"/"),i=new Set;i.add(r(t));let a=O(t);a!==t&&i.add(r(a));let c=h(o??process.cwd(),a);i.add(r(c));try{i.add(r(x(c)))}catch{}for(let s of n)for(let l of s){let d=new Set;d.add(l),d.add(G(l));let p=O(l);p!==l&&(d.add(p),d.add(G(p))),!Z(l)&&!l.startsWith("~")&&d.add(h(o??process.cwd(),l));let g=new Set;for(let y of d){g.add(y);let m=ie(y);m!==null&&g.add(m)}for(let y of g){let m=ne(r(y),e);for(let q of i)if(m.test(q))return{denied:!0,matchedPattern:l}}}return{denied:!1}}function ce(t,n,e=process.platform==="win32"||process.platform==="darwin"){if(!n)return!0;let o=h(n),r=h(n,O(t)),i=(a,c)=>{let s=a,l=c;if(e&&(s=s.toLowerCase(),l=l.toLowerCase()),s===l)return!0;let d=Y(s,l);return d===""?!0:!(d===".."||d.startsWith(".."+A)||ae(d))};if(!i(o,r))return!1;try{let a=x(o),c=x(r);if(!i(a,c))return!1}catch{}return!0}function ae(t){if(t.startsWith("/"))return!0;if(t.length>=3&&t[1]===":"&&(t[2]==="\\"||t[2]==="/")){let n=t.charCodeAt(0);return n>=65&&n<=90||n>=97&&n<=122}return!1}function Se(t,n,e=[],o=process.platform==="win32"||process.platform==="darwin"){return ce(t,n,o)?{allowed:!0,reason:"inside"}:e.some(r=>r.length>0)&&se(t,e,o,n).denied?{allowed:!0,reason:"allow-rule"}:{allowed:!1,reason:"outside"}}var le={python:[/os\.system\(\s*(['"])(.*?)\1\s*\)/g,/subprocess\.(?:run|call|Popen|check_output|check_call)\(\s*(['"])(.*?)\1/g],javascript:[/exec(?:Sync|File|FileSync)?\(\s*(['"`])(.*?)\1/g,/spawn(?:Sync)?\(\s*(['"`])(.*?)\1/g],typescript:[/exec(?:Sync|File|FileSync)?\(\s*(['"`])(.*?)\1/g,/spawn(?:Sync)?\(\s*(['"`])(.*?)\1/g],ruby:[/system\(\s*(['"])(.*?)\1/g,/`(.*?)`/g],go:[/exec\.Command\(\s*(['"`])(.*?)\1/g],php:[/shell_exec\(\s*(['"`])(.*?)\1/g,/(?:^|[^.])exec\(\s*(['"`])(.*?)\1/g,/(?:^|[^.])system\(\s*(['"`])(.*?)\1/g,/passthru\(\s*(['"`])(.*?)\1/g,/proc_open\(\s*(['"`])(.*?)\1/g],rust:[/Command::new\(\s*(['"`])(.*?)\1/g]};function de(t){let n=[],e=/subprocess\.(?:run|call|Popen|check_output|check_call)\(\s*\[([^\]]+)\]/g,o;for(;(o=e.exec(t))!==null;){let i=[...o[1].matchAll(/(['"])(.*?)\1/g)].map(a=>a[2]);i.length>0&&n.push(i.join(" "))}return n}function Re(t,n){let e=le[n];if(!e&&n!=="python")return[];let o=[];if(e)for(let r of e){r.lastIndex=0;let i;for(;(i=r.exec(t))!==null;){let a=i[i.length-1];a&&o.push(a)}}return n==="python"&&o.push(...de(t)),o}export{ve as evaluateCommand,be as evaluateCommandDenyOnly,se as evaluateFilePath,Se as evaluateProjectContainment,Re as extractShellCommands,W as extractSubshellCommands,ne as fileGlobToRegex,te as globToRegex,ce as isPathInsideProject,P as matchesAnyPattern,$ as parseBashPattern,Q as parseToolPattern,Ae as readBashPolicies,Oe as readToolDenyPatterns,re as readToolPermissionPatterns,oe as splitChainedCommands};
|
package/openclaw.plugin.json
CHANGED
|
@@ -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": "2.0.
|
|
6
|
+
"version": "2.0.4",
|
|
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": "@mxalbert/context-mode",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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",
|