context-mode 2.0.0-next.12 → 2.0.0-next.14

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/hook.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import{createRequire as __cmRequire}from"node:module";if(typeof process.getBuiltinModule!=="function")process.getBuiltinModule=(id)=>__cmRequire(import.meta.url)(id);
2
2
  var Se=["claude-code","codex","gemini","qwen","copilot-cli","vscode","kiro","zcode","pi","opencode"];var Z="context-mode",Ze=Object.freeze(["ctx_execute","ctx_batch","ctx_index","ctx_search","ctx_resume","ctx_stats","ctx_doctor","ctx_upgrade","ctx_purge"]);function I(e,t){if(t==="")return e;let n=e;for(let o of Ze)n=n.split(o).join(t+o);return n}var ee=16384,Po=2048;var Uo=640,Zt="</context_mode_state>",en=1048576,Mo=65536,Ho=4096,Fo=96,vo=256,jo=48;function Go(e,t,n,o="",r=""){let s=r===""?[e]:[e,r];return o+"ctx_search({queries:["+s.map(i=>JSON.stringify(i)).join(",")+"], source:"+JSON.stringify(t)+"}) searches the whole output ("+n+" B)."}var Bo=3,te=4096;var tn=85,nn=340,on=Object.freeze({toolerr:900,decision:700,prompt:500,edit:400,index:200});var Wo=.7,Ko=.7,Xo=.3,rn=Object.freeze([1e3,881,780,696,625,565,515,473,438,408,383,361,344,329,316,306,297,289,283,278,273,270,267,264,262,260,258,257,256,255,254,253,253,252,252,252,251,251,251,251,251,251,251,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250]),qo='context-mode: earlier work of this session is in ctx_resume (state block) and ctx_search(scope:"session", sort:"timeline").';var Ra=6e5;var le=5e3,et="-wal",tt="-shm",Yo=".tmp",Vo=255,Jo=11,zo=26;var M=5e3;var sn=0;var $o=16,Oe=5;var Qo="projects",Zo="context.db";var cn=".git",an="worktree ",ln="gitdir: ",er="commondir",tr="HEAD",nt="--workspace-folder",cx=Object.freeze(["shell","powershell","javascript","typescript","python"]);var nr=80;var ax=Object.freeze({NO_COLOR:"1",FORCE_COLOR:"0"});var lx=Object.freeze({"claude-code":"CLAUDE_CODE_SESSION_ID"}),Te="24.15.0",ot="~/.context-mode";var or="CONTEXT_MODE_REQUIRE_SECURITY",rr=".claude",rt="agents",st=".md",sr="plugins",ir="installed_plugins.json",ue=":",cr="@",un="---",ar="tools",lr="disallowedTools",dn="mcp__",fn="__",ur="mcp_",dr="_-.:",Lo=10;function Aa(e){if(e===void 0||e.trim()==="")return Lo;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:Lo}var ux=Aa(process.env.CTX_MCP_HINT_EVERY);var ne=32;var xn="context-mode: ",fr=Object.freeze({curl:"This curl/wget call",http:"This inline HTTP call",build:"This build command",webfetch:"WebFetch"}),xr=" sends its body into the conversation.",pr="Run it here instead; the full output is indexed and only the part that matches your intent comes back.",Er="Tool: ",_r="state what you need",mr="ctx_execute",gr=Object.freeze(["ctx_index","ctx_search"]),Re="Blocked by security policy: matches deny pattern ",it="context-mode: your deny rules could not be read. Fix: run ctx_doctor.",ct="context-mode: could not parse this command; it may be blocked by your own rules. Run it through ctx_execute instead.",hr="hook-errors.log";var Sr=Object.freeze(["tool_name","toolName","tool"]),br=Object.freeze(["hook_event_name","hookEventName","type"]),Or=Object.freeze(["tool_input","toolArgs","input","args"]),Tr=Object.freeze(["cwd","directory"]),Rr=Object.freeze(["pretooluse","beforetool","tool_call","execute.before","tool.execute.before"]),Ar="CM_HOOK_FAULT",dx=Object.freeze(["decode","project","policy","store","encode"]),Ae=Object.freeze({shell:Object.freeze(["Bash","bash","shell"]),read:Object.freeze(["Read","read_file"]),grep:Object.freeze(["Grep","grep_search"]),fetch:Object.freeze(["WebFetch","web_fetch","fetch"])});function Nr(e,t){return`${xn}the hook failed (${e}). Fix: run ${t}ctx_doctor.`}var pn=Object.freeze({read:"Read the file in parts with offset and limit, or process it with ctx_execute(language, code); only what you print comes back.",shell:"Run the command with ctx_execute(language, code) or ctx_batch instead; only the part that matches your intent comes back.",grep:"Search with ctx_execute(language, code), or index the files with ctx_index and query them with ctx_search.",fetch:"Index the URL with ctx_index and query it with ctx_search."});var fx=Object.freeze(["pwd","whoami","uname","id","realpath","ln"]),xx=Object.freeze(["status"]),px=Object.freeze(["--version","-v"]),Ex=Object.freeze(["cp","mv","rm"]),_x=Object.freeze(["-v","--verbose"]),D=Object.freeze({identity:".",length:"length",pipeLength:"| length",fieldSep:"."}),yr="{prefix}",Cr=", then ",kr="context-mode: your deny rules could not be read, so they are not applied. Fix: run ctx_doctor.",Ir=Object.freeze(["claude.ai","claude.site","claudeusercontent.com"]),Dr=Object.freeze(["curl","wget"]),wr=Object.freeze({curl:{short:"s",long:"--silent"},wget:{short:"q",long:"--quiet"}}),Lr=Object.freeze(["-v","--verbose","--trace","--trace-ascii"]),Pr="-D",Ur=Object.freeze(["gradlew","gradle","mvnw","mvn","sbt"]),Ne="fetch(",Mr="'\"`",Hr="http",Fr=Object.freeze(["requests.get(","requests.post(","requests.put(","http.get(","http.request("]),vr=Object.freeze(["cat","head","tail","sed","less","jq","bat","more"]),jr=Object.freeze(["head","tail"]),En=Object.freeze(["-n","-c","--lines","--bytes"]),at="sed",Gr=Object.freeze(["-n","--quiet","--silent"]),Br="jq",lt=Object.freeze(["file_path","absolute_path","path"]),ut="ctx_",Wr="Bash",Kr=Object.freeze(["Write","Edit"]),Xr=Object.freeze(["file_path","path"]),_n="Exit code ",ye="resume-hint",mn="compact-state",gn="pending-compact",dt="pending_compact:",hn="1",Sn=2048,bn=5,qr=340,On="compacted:",Yr="recall_units_seen:",Vr=64,Jr="recall_seen:",Tn="<context_mode_recall>",Rn="</context_mode_recall>",zr="recall",An="This session may have run before. Call {prefix}ctx_resume for a summary of what happened.",$r="subagent:",Qr="run.mjs",Zr="node",es=`context-mode: This command sends its body into the conversation.
3
- Run the command on the line above with Bash instead. It runs the same command in the same folder, indexes the full output and prints only the part that matches your intent, with the same exit code.`,ft="--agent",ts=1e3;var mx=Object.freeze(["Scope","Produced","Returned","Saved","Reduction %"]);var gx=Object.freeze(["session","source","project"]);var xt="decision";var Nn="AskUserQuestion",ns="answers",pt="option",os=" | ";var hx=Object.freeze(["D1","D2","D3","D4","D5","D5b","D6","D7","D8","D9","D10","D11"]),Sx=Object.freeze({D1:"version",D2:"node",D3:"host config",D4:"old entries",D5:"hook round trip",D5b:"double-fire",D6:"MCP",D7:"project and worktree",D8:"context.db",D9:"index",D10:"enforcement mode",D11:"shell"});var rs=256,Na="ctx_doctor:report";var bx=`ctx_search({queries:["FAIL","PASS","UNKNOWN"], source:${JSON.stringify(Na)}})`;var Ox=`install Node ${Te} or later`;var Tx=Object.freeze(["MCP entry","hook entries","hook timeout"]);var ss=Object.freeze({"claude-code":[".claude"],codex:[".codex"],gemini:[".gemini"],qwen:[".qwen"],"copilot-cli":[".copilot"],vscode:[".vscode"],kiro:[".kiro"],zcode:[".zcode"],pi:[".pi"],opencode:[".config","opencode"]});var Rx=Object.freeze(["upgrade","uninstall"]);var Ax=Object.freeze(["clone","--depth","1","--branch"]),Nx=Object.freeze(["rev-parse","HEAD"]);var yx=Object.freeze(["pi","opencode"]);var Cx=Object.freeze({GIT_TERMINAL_PROMPT:"0"}),kx=Object.freeze({GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"core.autocrlf",GIT_CONFIG_VALUE_0:"false"});var Ix=Object.freeze(["shell","bash","sh"]),Dx=Object.freeze([["..","bin","bash.exe"],["..","..","bin","bash.exe"]]);var wx=Object.freeze(["doctor-env.ts","doctor-config.ts","doctor-hook.ts","doctor-db.ts","doctor-heal.ts","release-fetch.ts","verify-sums.ts","plugin-swap.ts","host-write.ts","v1-remove.ts","uninstall.ts"]);var Lx=Object.freeze({"claude-code":{root:"plugin",file:["hooks","claude-code.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!0},codex:{root:"home",file:[".codex","hooks.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!0},gemini:{root:"plugin",file:["hooks","hooks.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!1},qwen:{root:"plugin",file:["hooks","qwen.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!0},"copilot-cli":{root:"home",file:[".copilot","hooks","context-mode.json"],key:["hooks"],shape:"flat",timeoutKey:"timeoutSec",matcher:!1},vscode:{root:"home",file:[".copilot","hooks","context-mode-vscode.json"],key:["hooks"],shape:"flat",timeoutKey:"timeout",matcher:!1},kiro:{root:"home",file:[".kiro","hooks","context-mode.json"],key:["hooks"],shape:"kiro",timeoutKey:"timeout",matcher:!1},zcode:{root:"home",file:[".zcode","cli","config.json"],key:["hooks","events"],shape:"zcode",timeoutKey:"timeoutMs",matcher:!0},pi:null,opencode:null}),Px=Object.freeze(["PreToolUse","PostToolUse"]);var Ux=Object.freeze([["@mcp","mcp"],["shell","shell"]]);var Mx=Object.freeze(["features","hooks"]);var Hx=Object.freeze(["",et,tt]);var Fx=Object.freeze({"claude-code":"claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",codex:"rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",gemini:"gemini extensions install https://github.com/mksglu/context-mode --ref release --auto-update",qwen:"qwen extensions install https://github.com/mksglu/context-mode --ref release --auto-update"});var vx=Object.freeze(["afteragentresponse.mjs","aftermodel.mjs","aftertool.mjs","agentspawn.mjs","beforeagent.mjs","beforetool.mjs","posttooluse.mjs","precompact.mjs","precompress.mjs","pretooluse.mjs","sessionend.mjs","sessionstart.mjs","stop.mjs","userpromptsubmit.mjs"]);var jx=Object.freeze(["hooks","codex"]);var Gx=Object.freeze([".mjs",".sh"]);var Et="CLAUDE_CONFIG_DIR";var ya=Object.freeze(["Code","User"]);var Ca="mcp.json",Bx=Object.freeze(["agents","default.json"]);var Wx=Object.freeze(["steering","KIRO.md"]);var Kx=Object.freeze(["opencode.jsonc","opencode.json"]);var Xx=Object.freeze(["content","platform.json"]);var is="custom";var ka=Object.freeze(["/","\\"]),Ia="${/}",qx=Object.freeze([...ka,Ia]),be=Object.freeze({hook:"old context-mode hook entry: command contains context-mode and an old script name or context-mode hook",cacheHealHook:"old context-mode cache-heal SessionStart hook entry",cacheHealFile:"old context-mode cache-heal script file",statusLine:"old context-mode statusLine (context-mode statusline): report only, never removed",mcpEntry:"old context-mode MCP entry mcpServers.context-mode",codexHook:"old context-mode Codex hook entry: context-mode hook codex or hooks/codex/*.mjs",codexToml:"old context-mode config.toml [mcp_servers.context-mode*] section",hookFile:"old context-mode hook file context-mode.json (runs context-mode hook)",vscodeMcp:"old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",kiroHook:"old Kiro hook entry: command contains context-mode and an old script name or context-mode hook",kiroAgentFile:"old context-mode Kiro agent file agents/*.json with name context-mode",kiroSteering:"old context-mode Kiro steering doc .kiro/steering/KIRO.md: manual review, report only, never removed",piNpm:"old context-mode Pi package npm:context-mode",opencodePlugin:"old context-mode OpenCode plugin spec context-mode",zcodeHook:"old context-mode ZCode hook entry: command contains context-mode hook",dataDir:"old context-mode data dir <agent home>/context-mode/",dataDirShared:"old context-mode data dir ~/.gemini/context-mode/: delete only after a prompt (Antigravity shares it)",dataRoot:"old context-mode content under ~/.context-mode/",tmpFile:"old context-mode temp file context-mode-* under the OS temp dir: report only, no action needed"}),Yx=Object.freeze([be.statusLine,be.vscodeMcp,be.dataDirShared,be.tmpFile,be.kiroSteering]);var Vx=Z+"_";var Da=Object.freeze(["features","mcp"]),wa="omit_tools_from",La=Object.freeze(["deferred"]),Pa="default_tools_approval_mode",Ua="approve",Jx=Object.freeze({codex:{file:[".codex","config.toml"],key:["mcp_servers",Z],fields:{[wa]:La,[Pa]:Ua}},vscode:{file:[Ca],key:["servers",Z]},kiro:{file:[".kiro","settings","mcp.json"],key:["mcpServers",Z]},zcode:{file:[".zcode","cli","config.json"],key:["mcp","servers",Z],fields:{type:"stdio",enabled:!0,timeoutMs:Ra},also:[[Da,!0]]}});var zx=Object.freeze({NODE_ENV:Object.freeze(["development","production","test"])});import{dirname as k0,join as I0}from"node:path";var yn="mcp__plugin_context-mode_context-mode__",Ma=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse"],cs="mcp__",as="__",Ha={startup:"startup",resume:"resume",clear:"clear",compact:"compact"};function Fa(e,t){if(e.startsWith(t))return e.slice(t.length);if(!e.startsWith(cs))return e;let n=e.slice(cs.length),o=n.indexOf(as);return o<0?e:"mcp:"+n.slice(0,o)+":"+n.slice(o+as.length)}function va(e){if(e===void 0)return"";if(typeof e=="string")return e;if(Array.isArray(e))return us(e).text;if(typeof e=="object"&&e!==null){let t=e;if(typeof t.stdout=="string"||typeof t.stderr=="string"){let n=typeof t.stdout=="string"?t.stdout:"",o=typeof t.stderr=="string"?t.stderr:"";return o===""?n:n===""?o:n+`
3
+ Run the command on the line above with Bash instead. It runs the same command in the same folder, indexes the full output and prints only the part that matches your intent, with the same exit code.`,ft="--agent",ts=1e3;var mx=Object.freeze(["Scope","Produced","Returned","Saved","Reduction %"]);var gx=Object.freeze(["session","source","project"]);var xt="decision";var Nn="AskUserQuestion",ns="answers",pt="option",os=" | ";var hx=Object.freeze(["D1","D2","D3","D4","D5","D5b","D6","D7","D8","D9","D10","D11"]),Sx=Object.freeze({D1:"version",D2:"node",D3:"host config",D4:"old entries",D5:"hook round trip",D5b:"double-fire",D6:"MCP",D7:"project and worktree",D8:"context.db",D9:"index",D10:"enforcement mode",D11:"shell"});var rs=256,Na="ctx_doctor:report";var bx=`ctx_search({queries:["FAIL","PASS","UNKNOWN"], source:${JSON.stringify(Na)}})`;var Ox=`install Node ${Te} or later`;var Tx=Object.freeze(["MCP entry","hook entries","hook timeout"]);var ss=Object.freeze({"claude-code":[".claude"],codex:[".codex"],gemini:[".gemini"],qwen:[".qwen"],"copilot-cli":[".copilot"],vscode:[".vscode"],kiro:[".kiro"],zcode:[".zcode"],pi:[".pi"],opencode:[".config","opencode"]});var Rx=Object.freeze(["upgrade","uninstall"]);var Ax=Object.freeze(["clone","--depth","1","--branch"]),Nx=Object.freeze(["rev-parse","HEAD"]);var yx=Object.freeze(["pi","opencode"]);var Cx=Object.freeze({GIT_TERMINAL_PROMPT:"0"}),kx=Object.freeze({GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"core.autocrlf",GIT_CONFIG_VALUE_0:"false"});var Ix=Object.freeze(["shell","bash","sh"]),Dx=Object.freeze([["..","bin","bash.exe"],["..","..","bin","bash.exe"]]);var wx=Object.freeze(["doctor-env.ts","doctor-config.ts","doctor-hook.ts","doctor-db.ts","doctor-heal.ts","release-fetch.ts","verify-sums.ts","plugin-swap.ts","host-write.ts","v1-remove.ts","uninstall.ts"]);var Lx=Object.freeze({"claude-code":{root:"plugin",file:["hooks","claude-code.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!0},codex:{root:"home",file:[".codex","hooks.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!0},gemini:{root:"plugin",file:["hooks","hooks.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!1},qwen:{root:"plugin",file:["hooks","qwen.json"],key:["hooks"],shape:"nested",timeoutKey:"timeout",matcher:!0},"copilot-cli":{root:"home",file:[".copilot","hooks","context-mode.json"],key:["hooks"],shape:"flat",timeoutKey:"timeoutSec",matcher:!1},vscode:{root:"home",file:[".copilot","hooks","context-mode-vscode.json"],key:["hooks"],shape:"flat",timeoutKey:"timeout",matcher:!1},kiro:{root:"home",file:[".kiro","hooks","context-mode.json"],key:["hooks"],shape:"kiro",timeoutKey:"timeout",matcher:!1},zcode:{root:"home",file:[".zcode","cli","config.json"],key:["hooks","events"],shape:"zcode",timeoutKey:"timeoutMs",matcher:!0},pi:null,opencode:null}),Px=Object.freeze(["PreToolUse","PostToolUse"]);var Ux=Object.freeze([["@mcp","mcp"],["shell","shell"]]);var Mx=Object.freeze(["features","hooks"]);var Hx=Object.freeze(["",et,tt]);var Fx=Object.freeze({"claude-code":"claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",codex:"rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",gemini:"gemini extensions install https://github.com/mksglu/context-mode --ref release --auto-update",qwen:"qwen extensions install https://github.com/mksglu/context-mode --ref release --auto-update"});var vx=Object.freeze(["afteragentresponse.mjs","aftermodel.mjs","aftertool.mjs","agentspawn.mjs","beforeagent.mjs","beforetool.mjs","posttooluse.mjs","precompact.mjs","precompress.mjs","pretooluse.mjs","sessionend.mjs","sessionstart.mjs","stop.mjs","userpromptsubmit.mjs"]);var jx=Object.freeze(["hooks","codex"]);var Gx=Object.freeze([".mjs",".sh"]);var Et="CLAUDE_CONFIG_DIR";var ya=Object.freeze(["Code","User"]);var Ca="mcp.json",Bx=Object.freeze(["agents","default.json"]);var Wx=Object.freeze(["steering","KIRO.md"]);var Kx=Object.freeze(["opencode.jsonc","opencode.json"]);var Xx=Object.freeze(["content","platform.json"]);var is="custom";var ka=Object.freeze(["/","\\"]),Ia="${/}",qx=Object.freeze([...ka,Ia]),be=Object.freeze({hook:"old context-mode hook entry: command contains context-mode and an old script name or context-mode hook",cacheHealHook:"old context-mode cache-heal SessionStart hook entry",cacheHealFile:"old context-mode cache-heal script file",statusLine:"old context-mode statusLine (context-mode statusline): report only, never removed",mcpEntry:"old context-mode MCP entry mcpServers.context-mode",codexHook:"old context-mode Codex hook entry: context-mode hook codex or hooks/codex/*.mjs",codexToml:"old context-mode config.toml [mcp_servers.context-mode*] section",hookFile:"old context-mode hook file context-mode.json (runs context-mode hook)",vscodeMcp:"old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",kiroHook:"old Kiro hook entry: command contains context-mode and an old script name or context-mode hook",kiroAgentFile:"old context-mode Kiro agent file agents/*.json with name context-mode",kiroSteering:"old context-mode Kiro steering doc .kiro/steering/KIRO.md: manual review, report only, never removed",piNpm:"old context-mode Pi package npm:context-mode",opencodePlugin:"old context-mode OpenCode plugin spec context-mode",zcodeHook:"old context-mode ZCode hook entry: command contains context-mode hook",dataDir:"old context-mode data dir <agent home>/context-mode/",dataDirShared:"old context-mode data dir ~/.gemini/context-mode/: delete only after a prompt (Antigravity shares it)",dataRoot:"old context-mode content under ~/.context-mode/",tmpFile:"old context-mode temp file context-mode-* under the OS temp dir: report only, no action needed"}),Yx=Object.freeze([be.statusLine,be.vscodeMcp,be.dataDirShared,be.tmpFile,be.kiroSteering]);var Vx=Z+"_";var Jx=Object.freeze(["opencode","plugin.js"]);var Da=Object.freeze(["features","mcp"]),wa="omit_tools_from",La=Object.freeze(["deferred"]),Pa="default_tools_approval_mode",Ua="approve",zx=Object.freeze({codex:{file:[".codex","config.toml"],key:["mcp_servers",Z],fields:{[wa]:La,[Pa]:Ua}},vscode:{file:[Ca],key:["servers",Z]},kiro:{file:[".kiro","settings","mcp.json"],key:["mcpServers",Z]},zcode:{file:[".zcode","cli","config.json"],key:["mcp","servers",Z],fields:{type:"stdio",enabled:!0,timeoutMs:Ra},also:[[Da,!0]]}});var $x=Object.freeze({NODE_ENV:Object.freeze(["development","production","test"])});import{dirname as k0,join as I0}from"node:path";var yn="mcp__plugin_context-mode_context-mode__",Ma=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse"],cs="mcp__",as="__",Ha={startup:"startup",resume:"resume",clear:"clear",compact:"compact"};function Fa(e,t){if(e.startsWith(t))return e.slice(t.length);if(!e.startsWith(cs))return e;let n=e.slice(cs.length),o=n.indexOf(as);return o<0?e:"mcp:"+n.slice(0,o)+":"+n.slice(o+as.length)}function va(e){if(e===void 0)return"";if(typeof e=="string")return e;if(Array.isArray(e))return us(e).text;if(typeof e=="object"&&e!==null){let t=e;if(typeof t.stdout=="string"||typeof t.stderr=="string"){let n=typeof t.stdout=="string"?t.stdout:"",o=typeof t.stderr=="string"?t.stderr:"";return o===""?n:n===""?o:n+`
4
4
  `+o}}return typeof e=="object"&&e!==null&&ls(e)?e.content:JSON.stringify(e)}function ls(e){let t=e;return t.mode==="content"&&typeof t.content=="string"}function us(e){let t=[],n=!1;for(let o of e){let r=typeof o=="object"&&o!==null?o:{};r.type==="text"&&typeof r.text=="string"?t.push(r.text):n=!0}return{text:t.join(`
5
5
  `),keep:n}}function ja(e){let t=va(e),o={isError:typeof e=="object"&&e!==null&&e.is_error===!0,bytes:Buffer.byteLength(t),text:t};if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&ls(e)&&(o.shape=e),Array.isArray(e)&&(o.blocks=!0,us(e).keep&&(o.keep=!0)),typeof e=="object"&&e!==null){let r=e;typeof r.persistedOutputPath=="string"&&r.persistedOutputPath!==""&&typeof r.persistedOutputSize=="number"&&r.persistedOutputSize>o.bytes&&(o.persistedPath=r.persistedOutputPath)}return o}function oe(e,t,n,o){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(t+": hook payload is not a JSON object");let r=e,s=Ma.find(c=>c===r.hook_event_name);if(s===void 0)throw new Error(t+": unknown hook event "+String(r.hook_event_name));let i={event:s,agent:t,sessionId:String(r.session_id??""),cwd:String(r.cwd??"")};if(typeof r.agent_id=="string"&&(i.agentId=r.agent_id,typeof r.agent_type=="string"&&(i.agentType=r.agent_type)),s==="SessionStart"&&typeof r.source=="string"&&o[r.source]!==void 0&&(i.source=o[r.source]),s==="UserPromptSubmit"&&typeof r.prompt=="string"&&(i.prompt=r.prompt),s==="PreToolUse"||s==="PostToolUse"){let c=String(r.tool_name??""),a=typeof r.tool_input=="object"&&r.tool_input!==null?r.tool_input:{},l={name:c,canonicalName:Fa(c,n),input:a};typeof r.tool_use_id=="string"&&r.tool_use_id!==""&&(l.callId=r.tool_use_id),i.tool=l}return s==="PostToolUse"&&(i.result=ja(r.tool_response)),i}function Ga(e,t){return e.tool?.canonicalName==="Bash"?{stdout:t,stderr:"",interrupted:!1}:e.result?.shape!==void 0?{...e.result.shape,content:t}:e.result?.blocks===!0?[{type:"text",text:t}]:t}function H(e,t,n){let o=r=>({stdout:JSON.stringify({hookSpecificOutput:{hookEventName:e.event,...r}}),exitCode:0});switch(t.kind){case"allow":return{stdout:"",exitCode:0};case"hint":return o({additionalContext:t.text});case"deny":return o({permissionDecision:"deny",permissionDecisionReason:t.rewritten===void 0?t.reason:t.rewritten+`
6
6
  `+t.reason});case"replace":return n&&e.event==="PostToolUse"?o({updatedToolOutput:Ga(e,t.output)}):{stdout:"",exitCode:0}}}var Ba={PreToolUse:["tool_name"],PostToolUse:["tool_name","tool_response"]};function Wa(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Ka(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(t.hook_event_name===void 0)throw new Error("claude-code: missing required field hook_event_name");for(let n of Ba[t.hook_event_name]??[])if(t[n]===void 0)throw new Error("claude-code: missing required field "+n)}function ds(e){Ka(e);let t=oe(e,"claude-code",yn,Ha);if(t.cwd===""&&(t.cwd=process.env.CLAUDE_PROJECT_DIR||process.cwd()),t.event==="PostToolUse"&&t.tool!==void 0&&t.tool.callId===void 0){let n=typeof t.tool.input.command=="string"?t.tool.input.command:JSON.stringify(t.tool.input);t.tool.callId="h"+Wa(t.tool.name+"\0"+n+"\0"+String(t.turn??0))}return t}function fs(e,t,n){return H(e,t,!0)}var Cn="mcp__context_mode__",qa={startup:"startup",resume:"resume",clear:"clear",compact:"compact",fork:"resume"};function xs(e){return oe(e,"codex",Cn,qa)}function ps(e,t,n){return H(e,t,!1)}var mt="mcp_context-mode_",Es={SessionStart:"SessionStart",BeforeAgent:"UserPromptSubmit",BeforeTool:"PreToolUse",AfterTool:"PostToolUse",PreCompress:"PreCompact"},_s={startup:"startup",resume:"resume",clear:"clear"},Va=["SessionStart","UserPromptSubmit","PostToolUse"],Ja=["UserPromptSubmit","PreToolUse"],_t={stdout:"",exitCode:0};function N(e,t){return Object.hasOwn(e,t)?e[t]:void 0}var ms={run_shell_command:"Bash",read_file:"Read",grep_search:"Grep",web_fetch:"WebFetch"};function za(e,t){if(e.startsWith(mt))return e.slice(mt.length);if(Object.hasOwn(ms,e))return ms[e];if(typeof t!="object"||t===null)return e;let n=t,o=N(n,"server_name"),r=N(n,"tool_name");return typeof o!="string"||typeof r!="string"?e:"mcp:"+o+":"+r}function $a(e){let t=typeof e=="object"&&e!==null?e:void 0,n=t===void 0?void 0:N(t,"llmContent"),o=e===void 0?"":typeof e=="string"?e:typeof n=="string"?n:JSON.stringify(e),r=t===void 0?void 0:N(t,"error");return{isError:r!=null,bytes:Buffer.byteLength(o),text:o}}function gs(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("gemini: hook payload is not a JSON object");let t=e,n=N(t,"hook_event_name"),o=typeof n=="string"&&Object.hasOwn(Es,n)?Es[n]:void 0;if(o===void 0)throw new Error("gemini: unknown hook event "+String(n));let r={event:o,agent:"gemini",sessionId:String(N(t,"session_id")??""),cwd:String(N(t,"cwd")??"")},s=N(t,"source");o==="SessionStart"&&typeof s=="string"&&Object.hasOwn(_s,s)&&(r.source=_s[s]);let i=N(t,"prompt");if(o==="UserPromptSubmit"&&typeof i=="string"&&(r.prompt=i),o==="PreToolUse"||o==="PostToolUse"){let c=String(N(t,"tool_name")??""),a=N(t,"tool_input");r.tool={name:c,canonicalName:za(c,N(t,"mcp_context")),input:typeof a=="object"&&a!==null&&!Array.isArray(a)?a:{}}}return o==="PostToolUse"&&(r.result=$a(N(t,"tool_response"))),r}function hs(e,t,n){switch(t.kind){case"allow":return _t;case"hint":return Va.includes(e.event)?{stdout:JSON.stringify({hookSpecificOutput:{additionalContext:t.text}}),exitCode:0}:_t;case"deny":return Ja.includes(e.event)?{stdout:JSON.stringify({decision:"deny",reason:t.rewritten===void 0?t.reason:t.rewritten+`
@@ -18,9 +18,9 @@ Run the command on the line above with Bash instead. It runs the same command in
18
18
  `||d==="\r"){let h=c;c+=i.startsWith(ai,c)?ai.length:1,F(r,"op",Kl,h,c),u=null,f.length>0&&(c=Zl(e,c,f,r,s));continue}if(d==="#"){for(;c<e.n&&i.charAt(c)!==`
19
19
  `&&i.charAt(c)!=="\r";)c++;continue}if(i.startsWith(Mn,c)||i.startsWith(Ei,c)){let h=Ct(e,c+Mn.length,!0,o+1,null,null);F(r,"unhandled",i.slice(c,h),c,h),c=h,u=null;continue}let E=$l(i,c);if(E!==null){F(r,"io",i.slice(c,E.end),c,E.end),u=E.op===Wl||E.op===ci?E.op===ci:null,c=E.end;continue}if(i.startsWith(de,c)&&Fn(i.charAt(c+de.length))){let h=zl(e,c,o);if(h>0){F(r,"unhandled",i.slice(c,h),c,h),c=h,u=null;continue}}if(i.startsWith(De,c)){let h=Gn(i,c);if(h>0){F(r,"unhandled",i.slice(c,h),c,h),c=h,u=null;continue}}let _=vl.find(h=>i.startsWith(h,c));if(_!==void 0){if(n&&_==="("&&a++,n&&_===")"){if(a>0)a--;else if(l===0)return c+1}F(r,"op",_,c,c+_.length),c+=_.length,u=null;continue}if(d==="$"&&x==="("||d==="`"){let h=d==="`"?xe(e,c):we(e,c,o);if(mi(i.charAt(h))){F(r,"unhandled",i.slice(c,h),c,h),c=h,u=null;continue}}let m=c;c=Ql(e,c,o);let b=i.slice(m,c);F(r,"word",b,m,c),u!==null&&(f.push({tag:pe(b),strip:u}),u=null),n&&b===Vl&&l++,n&&b===Jl&&l>0&&l--}return f.length>0&&fe(e,"unterminated-heredoc"),e.n}function hi(e){let t={s:e,n:e.length,end:"complete"},n=[],o=[];return Ct(t,0,!1,0,n,o),{tokens:n,heredocBodies:o,end:t.end}}function pe(e){let t="",n=0,o=e.length;for(;n<o;){let r=e.charAt(n);if(r==="\\"){t+=e.charAt(n+1),n+=w;continue}if(r==="'"){let s=e.indexOf("'",n+1),i=s<0?o:s;t+=e.slice(n+1,i),n=i+1;continue}if(r==="$"&&e.charAt(n+1)==="'"){let s=n+pi.length;for(;s<o&&e.charAt(s)!=="'";){if(e.charAt(s)==="\\"){t+=e.charAt(s+1),s+=w;continue}t+=e.charAt(s),s++}n=s+1;continue}if(r==='"'){let s=n+1;for(;s<o&&e.charAt(s)!=='"';){let i=e.charAt(s+1);if(e.charAt(s)==="\\"&&i!==""&&Yl.includes(i)){t+=i,s+=w;continue}t+=e.charAt(s),s++}n=s+1;continue}t+=r,n++}return t}function kt(e){let t={s:e,n:e.length,end:"complete"},n=[],o=!1,r=0;for(;r<t.n;){let s=e.charAt(r),i=e.charAt(r+1);if(s==="\\"){r+=w;continue}if(!o&&s==="'"){r=yt(t,r);continue}if(!o&&s==="$"&&i==="'"){r=gi(t,r);continue}if(s==='"'){o=!o,r++;continue}if(s==="$"&&i==="{"){r+=xi.length;continue}let c=e.startsWith(Mn,r);if(s==="$"&&i==="("||!o&&(c||e.startsWith(Ei,r))){let a=r+1;if(s==="$"&&e.startsWith(De,a)&&Gn(e,a)>0){r=a+De.length;continue}let l=Ct(t,a+1,!0,1,null,null),u=l>a+1&&e.charAt(l-1)===")"?l-1:l;n.push({wrapper:s==="$"?"$()":c?"<()":">()",body:e.slice(a+1,u)}),r=l;continue}if(s==="`"){let a=xe(t,r),l=a>r+1&&e.charAt(a-1)==="`"?a-1:a;n.push({wrapper:"`",body:e.slice(r+1,l)}),r=a;continue}r++}return n}function It(e){let t=e.charAt(0);if(!(fi(t)||t==="_"))return!1;for(let n=1;n<e.length;n++){let o=e.charAt(n);if(o==="="||o==="+"&&e.charAt(n+1)==="=")return!0;if(!(fi(o)||Hn(o)||o==="_"))return!1}return!1}var Ti=[";","&","&&","||"],Ri=["|","|&"],Le="(",Pe=")",Ai=";;",Kn=["(",")"],eu="!",S=Object.freeze({group:"{",groupEnd:"}",if:"if",then:"then",elif:"elif",else:"else",fi:"fi",while:"while",until:"until",for:"for",in:"in",do:"do",done:"done",case:"case",esac:"esac",function:"function",coproc:"coproc",select:"select"}),Ni=[],tu="[[",nu="((",yi=[">",">>",">|","&>","&>>",">&"],ou=[...yi,"<","<>","<<<","<<","<<-"],ru=["","1"],Ci=["-","/dev/stdout","/dev/stderr"],wt="-",Ue="--",Me="=",su="/",iu=Object.freeze({curl:{short:"o",long:"--output"},wget:{short:"O",long:"--output-document"}}),Dt=Object.freeze({head:"head",wc:"wc",grep:"grep",jq:"jq"}),Bn="-c",Wn="--bytes",cu="c",au="--count",se=()=>({cmds:[],simple:null}),O=(e,t=0)=>e.toks[e.i+t],W=(e,t)=>e!==void 0&&e.kind==="op"&&e.text===t,C=(e,t)=>e!==void 0&&e.kind==="word"&&e.text===t,Xn=e=>e!==""&&e>="0"&&e<="9",lu=e=>Xn(e)||e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_";function qn(e){let t=e.lastIndexOf(su);return t>=0&&t<e.length-1?e.slice(t+1):e}function Yn(e,t){let n=iu[e.toLowerCase()];if(n===void 0)return!1;for(let o=0;o<t.length;o++){let r=t[o];if(r===Ue)break;let s;if(r===n.long)s=t[o+1];else if(r.startsWith(n.long+Me))s=r.slice(n.long.length+Me.length);else if(r.startsWith(wt)&&!r.startsWith(Ue)){let i=r.indexOf(n.short,wt.length);if(i<0)continue;s=i+n.short.length<r.length?r.slice(i+n.short.length):t[o+1]}else continue;if(s!==void 0&&!Ci.includes(s))return!0}return!1}function uu(e){if(e==="")return!1;for(let t of e)if(!Xn(t))return!1;return!0}function du(e){for(let t=0;t<e.length;t++){let n=e[t],o;if(n===Bn||n===Wn?o=e[t+1]:n.startsWith(Wn+Me)?o=n.slice(Wn.length+Me.length):n.startsWith(Bn)&&!n.startsWith(Ue)&&(o=n.slice(Bn.length)),o!==void 0)return uu(o)&&Number(o)<=ee}return!1}function fu(e){for(let t of e){if(t===Ue)return!1;if(t===au||t.startsWith(wt)&&!t.startsWith(Ue)&&t.includes(cu))return!0}return!1}function Si(e){if(!e.startsWith(D.fieldSep))return!1;for(let t of e.slice(D.fieldSep.length).split(D.fieldSep)){if(t==="")return!1;for(let n of t)if(!lu(n))return!1}return!0}function xu(e){let t=e.trim();if(t===D.identity||t===D.length)return!0;let n=t.indexOf(D.pipeLength.charAt(0));if(n<0)return Si(t);let o=t.slice(0,n).trim(),r=D.pipeLength.slice(1).trim();return(o===D.identity||Si(o))&&t.slice(n+1).trim()===r}function pu(e){let t=e.argv0.toLowerCase();if(t===Dt.wc)return!0;if(t===Dt.head)return du(e.args);if(t===Dt.grep)return fu(e.args);if(t===Dt.jq){let n=e.args.filter(o=>!o.startsWith(wt));return n.length===1&&xu(n[0])}return!1}function Vn(e){return kt(e).length===0?[]:[{argv0:"",args:[],redirectsToFile:!1,endsInBoundedSink:!1,raw:e}]}function ki(e,t,n){return n<=t?[]:Vn(e.src.slice(e.toks[t].start,e.toks[n-1].end))}function Ii(e,t){for(let n of e)n.insideConstruct===void 0&&(n.insideConstruct=t)}function Eu(e){let t=0;for(;Xn(e.charAt(t));)t++;return{fd:e.slice(0,t),op:e.slice(t)}}function Di(e){let t=Eu(e.toks[e.i].text);if(e.i++,!ou.includes(t.op))return!1;let n=O(e);return n===void 0||n.kind==="op"||n.kind==="io"?!1:(e.i++,yi.includes(t.op)&&ru.includes(t.fd)&&!Ci.includes(pe(n.text)))}function wi(e){let t=!1;for(;O(e)?.kind==="io";)t=Di(e)||t;return t}function Li(e){for(;O(e)?.kind==="op"&&Ti.includes(O(e)?.text??"");)e.i++}function Ee(e,t){if(e.depth++,e.depth>ne)return e.err="nesting-too-deep",se();let n=t();if(e.depth--,wi(e))for(let o of n)o.redirectsToFile=!0;return{cmds:n,simple:null}}function Pi(e){if(Li(e),!C(O(e),S.do))return[];e.i++;let t=v(e,[S.done]);return C(O(e),S.done)&&e.i++,t}function _u(e){e.i++;let t=v(e,[S.then]);for(;e.err===null;){let n=O(e);if(C(n,S.then)||C(n,S.else)){e.i++,t.push(...v(e,[S.elif,S.else,S.fi]));continue}if(C(n,S.elif)){e.i++,t.push(...v(e,[S.then]));continue}C(n,S.fi)&&e.i++;break}return t}function mu(e){e.i++;let t=v(e,[S.do]);return t.push(...Pi(e)),t}function gu(e){e.i++;let t=[],n=O(e);if(n?.kind==="unhandled")e.i++;else if(n?.kind==="word"&&e.i++,C(O(e),S.in)){e.i++;let o=e.i;for(;(O(e)?.kind==="word"||O(e)?.kind==="unhandled")&&!C(O(e),S.do);)e.i++;t.push(...ki(e,o,e.i))}return t.push(...Pi(e)),t}function hu(e){e.i++;let t=[],n=O(e);for(n!==void 0&&n.kind!=="op"&&n.kind!=="io"&&(e.i++,t.push(...ki(e,e.i-1,e.i))),C(O(e),S.in)&&e.i++;e.i<e.toks.length&&e.err===null;){let o=e.toks[e.i];if(e.bodies.has(e.i)||o.kind==="op"&&(Ti.includes(o.text)||o.text===Ai)){e.i++;continue}if(C(o,S.esac)){e.i++;break}for(W(o,Le)&&e.i++;e.i<e.toks.length&&!W(O(e),Pe);){let s=e.toks[e.i];if(s.kind==="op"&&!Ri.includes(s.text))break;e.i++}if(!W(O(e),Pe))break;e.i++;let r=v(e,[S.esac]);Ii(r,S.case),t.push(...r)}return t}function bi(e,t){Li(e);let n=Ui(e);return Ii(n.cmds,t),{cmds:n.cmds,simple:null}}function Oi(e,t){return Kn.every((n,o)=>W(e.toks[t+o],n))}function Su(e){let t=e.i,n=[],o=!1;for(;e.i<e.toks.length;){let l=e.toks[e.i];if(l.kind==="op")break;if(l.kind==="io"){o=Di(e)||o;continue}if(n.length===0&&l.kind==="word"&&It(l.text)){e.i++;let u=O(e);if(l.text.endsWith(Me)&&u!==void 0&&W(u,Le)&&u.start===l.end){let f=0;for(;e.i<e.toks.length;){let d=e.toks[e.i];if(e.i++,W(d,Le)&&f++,W(d,Pe)&&--f===0)break}}continue}n.push(l),e.i++}if(e.i===t)return se();let r=e.src.slice(e.toks[t].start,e.toks[e.i-1].end);if(n.length===0)return{cmds:Vn(r),simple:null};let s=l=>l.kind==="word"?pe(l.text):l.text,i=qn(s(n[0])),c=n.slice(1).map(s),a={argv0:i,args:c,redirectsToFile:o||Yn(i,c),endsInBoundedSink:!1,raw:r};return{cmds:[a],simple:a}}function Ui(e){let t=O(e);if(t===void 0)return se();if(t.kind==="op")return t.text!==Le?se():Ee(e,()=>{e.i++;let n=v(e,Ni);return W(O(e),Pe)&&e.i++,n});if(t.kind==="unhandled"&&(t.text.startsWith(tu)||t.text.startsWith(nu)))return e.i++,wi(e),{cmds:Vn(t.text),simple:null};if(t.kind==="word")switch(t.text){case S.group:return Ee(e,()=>{e.i++;let n=v(e,[S.groupEnd]);return C(O(e),S.groupEnd)&&e.i++,n});case S.if:return Ee(e,()=>_u(e));case S.while:case S.until:return Ee(e,()=>mu(e));case S.for:return Ee(e,()=>gu(e));case S.case:return Ee(e,()=>hu(e));case S.coproc:return e.err="coproc",se();case S.select:return e.err="select",se();case S.function:{e.i++;let n=O(e),o="";return n?.kind==="word"&&(o=pe(n.text),e.i++),Oi(e,e.i)&&(e.i+=Kn.length),bi(e,o)}default:if(Oi(e,e.i+1))return e.i+=Kn.length+1,bi(e,pe(t.text))}return Su(e)}function bu(e){C(O(e),eu)&&e.i++;let t=[],n=se();for(;e.err===null;){n=Ui(e),t.push(...n.cmds);let o=O(e);if(o!==void 0&&o.kind==="op"&&Ri.includes(o.text)){for(let r of n.cmds)r.pipesOut=!0;e.i++;continue}break}if(n.simple!==null&&pu(n.simple))for(let o of t)o.endsInBoundedSink=!0;return t}function v(e,t){let n=[];for(;e.i<e.toks.length&&e.err===null;){let o=e.toks[e.i];if(e.bodies.has(e.i)){e.i++;continue}if(o.kind==="op"){if(o.text===Pe||o.text===Ai)return n;if(o.text!==Le){e.i++;continue}}if(o.kind==="word"&&t.includes(o.text))return n;let r=e.i;n.push(...bu(e)),e.i===r&&e.err===null&&e.i++}return n}function He(e){let t=hi(e);if(t.end==="unterminated-quote")return{ok:!1,construct:"unterminated-quote"};if(t.end==="unterminated-heredoc")return{ok:!1,construct:"unterminated-heredoc"};if(t.end==="too-deep")return{ok:!1,construct:"nesting-too-deep"};let n={toks:t.tokens,src:e,bodies:new Set(t.heredocBodies),i:0,depth:0,err:null},o=[];for(;n.i<n.toks.length&&n.err===null;)o.push(...v(n,Ni)),n.i<n.toks.length&&n.i++;return n.err!==null?{ok:!1,construct:n.err}:{ok:!0,commands:o}}import{join as Pt}from"node:path";var Mi=`\r
20
20
  `,Ou=`
21
- `;function Lt(e){let t=e.length>0&&e.charCodeAt(0)===65279?e.slice(1):e;return t.indexOf(Mi)<0?t:t.split(Mi).join(Ou)}import{join as Hi,posix as Op,win32 as Tp}from"node:path";var Tu=Object.freeze({NODE_TOO_OLD:"Node <v> is below 24.15.0. Fix: install Node 24.15.0 or later.",NO_SQLITE:"node:sqlite failed to load. Fix: run ctx_doctor.",DB_GONE:"context.db path vanished. Fix: run ctx_doctor.",NO_PROJECT:"Project source <kind> is missing. Fix: run ctx_doctor.",UNKNOWN_FIELD:'Unknown field "<f>". Fix: use "queries".',TIMEOUT:"Timed out after <ms> ms. Fix: pass background: true.",NO_GIT_BASH:"Git Bash not found. Fix: install Git for Windows.",NO_RUNTIME:"No <lang> runtime on PATH. Fix: install it or pick another language.",FETCH_FAILED:"Fetch failed: <code>. Fix: check the URL or proxy.",SSRF:"Blocked private address <host>. Fix: use a public URL.",OUTSIDE_ROOT:"Path <p> is outside the project. Fix: use a path inside <root>.",INVALID_ARGS:"Invalid argument <field>. Fix: <action>.",ONE_OF_INPUT:"Pass exactly one of <names>. Fix: drop the extra field.",SPAWN_FAILED:"Failed to start the process: <detail>. Fix: check the command and PATH.",DB_CORRUPT:"context.db failed integrity_check. Fix: run ctx_doctor.",SCHEMA_STALE:"context.db schema is version <found>, expected <want>. Fix: run ctx_doctor.",NO_GIT_DIR:"No git repository at <path>. Fix: run context-mode inside a git repository.",NO_HOME:"Env var <name> is not set. Fix: set <name> to your home directory.",PLUGIN_ROOT_MISSING:"Plugin root for <agent> not found at <path>. Fix: run ctx_upgrade.",BUNDLE_HASH_MISMATCH:"Fetched bundle hash does not match SHA256SUMS. Fix: run ctx_upgrade again.",CONFIG_PARSE_FAILED:"<agent> config at <path> did not parse as <format>. Fix: fix the syntax error and re-run ctx_upgrade."});function Ru(e,t){let n=Tu[e],o="",r=0;for(;r<n.length;){if(n[r]!=="<"){o+=n[r],r+=1;continue}let s=r+1;for(;s<n.length&&n[s]!=="<"&&n[s]!==">";)s+=1;if(s>=n.length){o+=n.slice(r);break}if(n[s]==="<"){o+="<",r+=1;continue}let i=n.slice(r+1,s),c=t[i];if(c===void 0)throw new Error("formatError: missing var "+i+" for "+e);o+=String(c),r=s+1}return o}var T=class extends Error{code;vars;constructor(t,n){super(Ru(t,n??{})),this.code=t,this.vars=n??{}}toLine(){return this.message}};var{mkdirSync:Au,realpathSync:Nu}=process.getBuiltinModule("node:fs");function _e(e,t=process.platform){let n=o=>o!==void 0&&o!=="";return t==="win32"?n(e.USERPROFILE)?e.USERPROFILE:n(e.HOMEDRIVE)&&n(e.HOMEPATH)?e.HOMEDRIVE+e.HOMEPATH:n(e.HOME)?e.HOME:null:n(e.HOME)?e.HOME:n(e.USERPROFILE)?e.USERPROFILE:null}function Fe(e,t){let n=e[Et];return n!==void 0&&n!==""?n:Hi(t,...ss["claude-code"])}function yu(e,t=process.platform){let n=_e(e,t);if(n!==null)return n;throw new T("NO_HOME",{name:t==="win32"?"USERPROFILE":"HOME"})}function Fi(e){let t=Hi(yu(e),ot.slice(1));return Au(t,{recursive:!0}),Nu.native(t)}var{readFileSync:Bi}=process.getBuiltinModule("node:fs");function me(e){return e.agentId!==void 0&&e.agentId!==""}function $n(e,t){if(t===null)return"C";let n=re(e.agent),o=new Set(t);for(let r of Ze)if(o.has(n.toolNamePrefix+r))return"A";for(let r of n.nativeTools.shell)if(o.has(r))return"B";return"C"}function Qn(e,t){if(!me(e))return null;let n=re(e.agent);if(t.manifestTools!==void 0)return Gi(t.manifestTools.map(c=>Jn(n,c)));let o=e.agentType??"",r=Cu(o,t);if(r===null)return null;let s=(r.tools??Lu(n)).map(c=>Jn(n,c)),i=r.disallowed.map(c=>Jn(n,c));return Gi(s.filter(c=>!i.some(a=>Uu(a,c))))}function Cu(e,t){if(!ku(e))return null;let n=Iu(t.env);if(e.indexOf(ue)>=0){if(n!==null){let s=Du(Fe(t.env,n),e);if(s!==null)return s}}else{let s=zn(Pt(t.projectDir,rr,rt,e+st));if(s!==null)return s;if(n!==null){let i=zn(Pt(Fe(t.env,n),rt,e+st));if(i!==null)return i}}let r=t.cliAgents;if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,e)){let s=r[e];return{tools:Array.isArray(s.tools)?s.tools:null,disallowed:Array.isArray(s.disallowedTools)?s.disallowedTools:[]}}return null}function ku(e){if(e===""||e==="."||e===".."||e.indexOf("/")>=0||e.indexOf("\\")>=0)return!1;for(let t of e.split(ue))if(t===""||t==="."||t==="..")return!1;return!0}function Iu(e){return _e(e)}function Du(e,t){let n=t.indexOf(ue),o=t.slice(0,n),r=t.slice(n+ue.length);if(r.indexOf(ue)>=0)return null;let s;try{s=JSON.parse(Lt(Bi(Pt(e,sr,ir),"utf8")))}catch{return null}let i=s?.plugins;if(i===null||typeof i!="object")return null;for(let c of Object.keys(i)){let a=c.indexOf(cr);if((a<0?c:c.slice(0,a))!==o)continue;let l=i[c];if(Array.isArray(l))for(let u of l){let f=u?.installPath;if(typeof f!="string"||f==="")continue;let d=zn(Pt(f,rt,r+st));if(d!==null)return d}}return null}function zn(e){let t;try{t=Bi(e,"utf8")}catch{return null}return wu(t)}function wu(e){let t=e.split(`
21
+ `;function Lt(e){let t=e.length>0&&e.charCodeAt(0)===65279?e.slice(1):e;return t.indexOf(Mi)<0?t:t.split(Mi).join(Ou)}import{join as Hi,posix as Tp,win32 as Rp}from"node:path";var Tu=Object.freeze({NODE_TOO_OLD:"Node <v> is below 24.15.0. Fix: install Node 24.15.0 or later.",NO_SQLITE:"node:sqlite failed to load. Fix: run ctx_doctor.",DB_GONE:"context.db path vanished. Fix: run ctx_doctor.",NO_PROJECT:"Project source <kind> is missing. Fix: run ctx_doctor.",UNKNOWN_FIELD:'Unknown field "<f>". Fix: use "queries".',TIMEOUT:"Timed out after <ms> ms. Fix: pass background: true.",NO_GIT_BASH:"Git Bash not found. Fix: install Git for Windows.",NO_RUNTIME:"No <lang> runtime on PATH. Fix: install it or pick another language.",FETCH_FAILED:"Fetch failed: <code>. Fix: check the URL or proxy.",SSRF:"Blocked private address <host>. Fix: use a public URL.",OUTSIDE_ROOT:"Path <p> is outside the project. Fix: use a path inside <root>.",INVALID_ARGS:"Invalid argument <field>. Fix: <action>.",ONE_OF_INPUT:"Pass exactly one of <names>. Fix: drop the extra field.",SPAWN_FAILED:"Failed to start the process: <detail>. Fix: check the command and PATH.",DB_CORRUPT:"context.db failed integrity_check. Fix: run ctx_doctor.",SCHEMA_STALE:"context.db schema is version <found>, expected <want>. Fix: run ctx_doctor.",NO_GIT_DIR:"No git repository at <path>. Fix: run context-mode inside a git repository.",NO_HOME:"Env var <name> is not set. Fix: set <name> to your home directory.",PLUGIN_ROOT_MISSING:"Plugin root for <agent> not found at <path>. Fix: run ctx_upgrade.",BUNDLE_HASH_MISMATCH:"Fetched bundle hash does not match SHA256SUMS. Fix: run ctx_upgrade again.",CONFIG_PARSE_FAILED:"<agent> config at <path> did not parse as <format>. Fix: fix the syntax error and re-run ctx_upgrade."});function Ru(e,t){let n=Tu[e],o="",r=0;for(;r<n.length;){if(n[r]!=="<"){o+=n[r],r+=1;continue}let s=r+1;for(;s<n.length&&n[s]!=="<"&&n[s]!==">";)s+=1;if(s>=n.length){o+=n.slice(r);break}if(n[s]==="<"){o+="<",r+=1;continue}let i=n.slice(r+1,s),c=t[i];if(c===void 0)throw new Error("formatError: missing var "+i+" for "+e);o+=String(c),r=s+1}return o}var T=class extends Error{code;vars;constructor(t,n){super(Ru(t,n??{})),this.code=t,this.vars=n??{}}toLine(){return this.message}};var{mkdirSync:Au,realpathSync:Nu}=process.getBuiltinModule("node:fs");function _e(e,t=process.platform){let n=o=>o!==void 0&&o!=="";return t==="win32"?n(e.USERPROFILE)?e.USERPROFILE:n(e.HOMEDRIVE)&&n(e.HOMEPATH)?e.HOMEDRIVE+e.HOMEPATH:n(e.HOME)?e.HOME:null:n(e.HOME)?e.HOME:n(e.USERPROFILE)?e.USERPROFILE:null}function Fe(e,t){let n=e[Et];return n!==void 0&&n!==""?n:Hi(t,...ss["claude-code"])}function yu(e,t=process.platform){let n=_e(e,t);if(n!==null)return n;throw new T("NO_HOME",{name:t==="win32"?"USERPROFILE":"HOME"})}function Fi(e){let t=Hi(yu(e),ot.slice(1));return Au(t,{recursive:!0}),Nu.native(t)}var{readFileSync:Bi}=process.getBuiltinModule("node:fs");function me(e){return e.agentId!==void 0&&e.agentId!==""}function $n(e,t){if(t===null)return"C";let n=re(e.agent),o=new Set(t);for(let r of Ze)if(o.has(n.toolNamePrefix+r))return"A";for(let r of n.nativeTools.shell)if(o.has(r))return"B";return"C"}function Qn(e,t){if(!me(e))return null;let n=re(e.agent);if(t.manifestTools!==void 0)return Gi(t.manifestTools.map(c=>Jn(n,c)));let o=e.agentType??"",r=Cu(o,t);if(r===null)return null;let s=(r.tools??Lu(n)).map(c=>Jn(n,c)),i=r.disallowed.map(c=>Jn(n,c));return Gi(s.filter(c=>!i.some(a=>Uu(a,c))))}function Cu(e,t){if(!ku(e))return null;let n=Iu(t.env);if(e.indexOf(ue)>=0){if(n!==null){let s=Du(Fe(t.env,n),e);if(s!==null)return s}}else{let s=zn(Pt(t.projectDir,rr,rt,e+st));if(s!==null)return s;if(n!==null){let i=zn(Pt(Fe(t.env,n),rt,e+st));if(i!==null)return i}}let r=t.cliAgents;if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,e)){let s=r[e];return{tools:Array.isArray(s.tools)?s.tools:null,disallowed:Array.isArray(s.disallowedTools)?s.disallowedTools:[]}}return null}function ku(e){if(e===""||e==="."||e===".."||e.indexOf("/")>=0||e.indexOf("\\")>=0)return!1;for(let t of e.split(ue))if(t===""||t==="."||t==="..")return!1;return!0}function Iu(e){return _e(e)}function Du(e,t){let n=t.indexOf(ue),o=t.slice(0,n),r=t.slice(n+ue.length);if(r.indexOf(ue)>=0)return null;let s;try{s=JSON.parse(Lt(Bi(Pt(e,sr,ir),"utf8")))}catch{return null}let i=s?.plugins;if(i===null||typeof i!="object")return null;for(let c of Object.keys(i)){let a=c.indexOf(cr);if((a<0?c:c.slice(0,a))!==o)continue;let l=i[c];if(Array.isArray(l))for(let u of l){let f=u?.installPath;if(typeof f!="string"||f==="")continue;let d=zn(Pt(f,rt,r+st));if(d!==null)return d}}return null}function zn(e){let t;try{t=Bi(e,"utf8")}catch{return null}return wu(t)}function wu(e){let t=e.split(`
22
22
  `).map(i=>i.endsWith("\r")?i.slice(0,-1):i);if(t.length===0||t[0].trim()!==un)return null;let n=-1;for(let i=1;i<t.length;i++)if(t[i].trim()===un){n=i;break}if(n<0)return null;let o=t.slice(1,n),r=vi(o,ar),s=vi(o,lr);return{tools:r!==null&&r.length>0?r:null,disallowed:s??[]}}function vi(e,t){for(let n=0;n<e.length;n++){let o=e[n];if(!o.startsWith(t+":"))continue;let r=o.slice(t.length+1).trim();if(r===""){let s=[];for(let i=n+1;i<e.length;i++){let c=e[i].trim();if(!c.startsWith("-"))break;s.push(ji(c.slice(1).trim()))}return s.filter(i=>i!=="")}return r.startsWith("[")&&r.endsWith("]")&&(r=r.slice(1,-1)),r.split(",").map(s=>ji(s.trim())).filter(s=>s!=="")}return null}function ji(e){return e.length>1&&(e[0]==='"'||e[0]==="'")&&e.endsWith(e[0])?e.slice(1,-1):e}function Lu(e){let t=e.nativeTools;return[...t.shell,...t.read??[],...t.grep??[],...t.webfetch??[],...t.edit??[],...Ze.map(n=>e.toolNamePrefix+n)]}function Jn(e,t){let n=t.indexOf("("),o=(n>=0?t.slice(0,n):t).trim();return e.id==="gemini"&&o.startsWith(ur)?Pu(o):o}function Pu(e){let t="";for(let n of e){let o=n>="a"&&n<="z"||n>="A"&&n<="Z"||n>="0"&&n<="9"||dr.indexOf(n)>=0;t+=o?n:"_"}return t}function Uu(e,t){if(e.endsWith("*"))return t.startsWith(e.slice(0,-1));if(e===t)return!0;if(e.startsWith(dn)){let n=e.slice(dn.length);if(n!==""&&n.indexOf(fn)<0)return t.startsWith(e+fn)}return!1}function Gi(e){return[...new Set(e.filter(t=>t!==""))]}var ie="",Wi=Object.freeze({sudo:{valueShorts:"ugpChDrtUTR",valueLongs:["--user","--group","--prompt","--chdir","--host"],assignments:!0,duration:!1,refuseShorts:ie},env:{valueShorts:"uCS",valueLongs:["--unset","--chdir","--split-string"],assignments:!0,duration:!1,refuseShorts:ie},time:{valueShorts:"fo",valueLongs:["--format","--output"],assignments:!1,duration:!1,refuseShorts:ie},nice:{valueShorts:"n",valueLongs:["--adjustment"],assignments:!1,duration:!1,refuseShorts:ie},timeout:{valueShorts:"sk",valueLongs:["--signal","--kill-after"],assignments:!1,duration:!0,refuseShorts:ie},command:{valueShorts:ie,valueLongs:[],assignments:!1,duration:!1,refuseShorts:"vV"},xargs:{valueShorts:"aEdILnPs",valueLongs:["--arg-file","--delimiter","--max-args","--max-procs","--max-chars"],assignments:!1,duration:!1,refuseShorts:ie}}),Mu=["bash","sh","zsh"],Hu="c",Fu=" -c",vu=["-o","+o","-O","+O"],Ut="-",ju="+",Zn="--",Gu="smhd",Bu=".",Ki=e=>e!==""&&e>="0"&&e<="9";function Wu(e){if(e===""||!Ki(e.charAt(0)))return!1;for(let t=0;t<e.length;t++){let n=e.charAt(t);if(!(Ki(n)||n===Bu))return t===e.length-1&&Gu.includes(n)}return!0}function Ku(e,t){let n=0;for(;n<t.length;){let o=t[n];if(o===Zn){n++;break}if(e.assignments&&It(o)){n++;continue}if(o.startsWith(Zn)){n++,e.valueLongs.includes(o)&&n++;continue}if(o.startsWith(Ut)&&o.length>Ut.length){n++;for(let r of e.refuseShorts)if(o.includes(r))return null;for(let r=Ut.length;r<o.length;r++)if(e.valueShorts.includes(o.charAt(r))){r===o.length-1&&n++;break}continue}break}if(e.duration){if(n>=t.length||!Wu(t[n]))return null;n++}return n<t.length?t.slice(n):null}function Xu(e){let t=!1;for(let n=0;n<e.length;n++){let o=e[n];if(!o.startsWith(Zn)){if(o.startsWith(Ut)||o.startsWith(ju)){o.includes(Hu)&&(t=!0),vu.includes(o)&&n++;continue}return t?o:null}}return null}function Xi(e,t){let n={...e};return n.insideConstruct===void 0&&t.insideConstruct!==void 0&&(n.insideConstruct=t.insideConstruct),n}function eo(e,t,n,o){let r=[...t],s=e.argv0,i=e.args,c=e.redirectsToFile;for(;;){let a=s.toLowerCase();if(Mu.includes(a)){let f=Xu(i),d=f!==null&&n<ne?He(f):null;if(d===null||!d.ok)break;for(let x of d.commands){let E=Xi(x,e);E.redirectsToFile=x.redirectsToFile||c,E.endsInBoundedSink=x.endsInBoundedSink||e.endsInBoundedSink,eo(E,[...r,a+Fu],n+1,o)}return}let l=Object.hasOwn(Wi,a)?Wi[a]:void 0,u=l===void 0?null:Ku(l,i);if(u===null)break;r.push(a),s=qn(u[0]),i=u.slice(1),c=c||Yn(s,i)}if(o.push({...e,argv0:s,args:i,redirectsToFile:c,wrappedBy:r}),!(n>=ne))for(let a of kt(e.raw)){let l=He(a.body);if(l.ok)for(let u of l.commands)eo(Xi(u,e),[...t,a.wrapper],n+1,o)}}function qi(e){let t=[];for(let n of e)eo(n,[],0,t);return t}import{isAbsolute as Yu,join as to,relative as Vu,sep as no}from"node:path";var{readFileSync:qu}=process.getBuiltinModule("node:fs"),Yi=".claude",Ju="settings.local.json",Vi="settings.json",zu="Bash",$u="Read",Ji=":*",zi="//",$i="~/",Qi="./",Zi="..",Qu=`
23
- \r`,Zu=Object.freeze({tool:zu});function ed(e,t){if(t!=="claude-code")return[];let n=_e(process.env),o=process.env[Et],r=o!==void 0&&o!==""?o:n===null?null:Fe(process.env,n),s=[to(e,Yi,Ju),to(e,Yi,Vi)];return r===null?s:[...s,to(r,Vi)]}function ec(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function td(e){let t;try{t=Lt(qu(e,"utf8"))}catch(s){return s.code==="ENOENT"?{kind:"absent"}:{kind:"bad"}}let n;try{n=JSON.parse(t)}catch{return{kind:"bad"}}if(!ec(n))return{kind:"bad"};let o=n.permissions;if(o===void 0)return{kind:"ok",deny:[]};if(!ec(o))return{kind:"bad"};let r=o.deny;return r===void 0?{kind:"ok",deny:[]}:!Array.isArray(r)||!r.every(s=>typeof s=="string")?{kind:"bad"}:{kind:"ok",deny:r}}function tc(e,t){let n=[];for(let o of ed(e,t)){let r=td(o);if(r.kind==="bad")return null;r.kind==="ok"&&n.push(...r.deny)}return n}function nd(e,t){let n=[],o=0;for(;o<e.length;){let r=e[o];if(r==="*"&&t&&e[o+1]==="*"){let s=e[o+2]==="/";n.push({t:s?"globstarDir":"globstar"}),o+=s?3:2;continue}r==="*"?(n.length===0||n[n.length-1].t!=="star")&&n.push({t:"star"}):r==="?"?n.push({t:"any1"}):n.push({t:"lit",c:r}),o++}return n}function K(e,t,n){let o=nd(e,n),r=t.length,s=new Uint8Array(r+1);s[r]=1;for(let i=o.length-1;i>=0;i--){let c=o[i],a=new Uint8Array(r+1),l=0;for(let u=r;u>=0;u--){let f=u<r,d=f?t[u]:"";switch(c.t){case"lit":a[u]=f&&d===c.c?s[u+1]:0;break;case"any1":a[u]=f&&!(n&&d==="/")?s[u+1]:0;break;case"star":a[u]=s[u]||(f&&!(n&&d==="/")?a[u+1]:0);break;case"globstar":a[u]=s[u]||(f?a[u+1]:0);break;case"globstarDir":f&&d==="/"&&s[u+1]&&(l=1),a[u]=s[u]||l;break}}s=a}return s[0]===1}function od(e){let t=e.indexOf("(");if(t<1||!e.endsWith(")"))return null;let n=e.slice(t+1,e.length-1);return n===""?null:{tool:e.slice(0,t),glob:n}}function rd(e,t){if(!e.endsWith(Ji))return K(e,t,!1);let n=e.slice(0,e.length-Ji.length);if(K(n,t,!1))return!0;for(let o=0;o<t.length;o++)if(Qu.includes(t[o])&&K(n,t.slice(0,o),!1))return!0;return!1}var sd=/^[A-Za-z]:(?=\/)/;function ve(e){return no==="/"?e:e.split(no).join("/")}function id(e,t,n){if(e.startsWith(Qi)){if(n===void 0)return!1;let r=Vu(n,t);return r===""||r===Zi||r.startsWith(Zi+no)||Yu(r)?!1:K(e.slice(Qi.length),ve(r),!0)}let o=ve(t);if(e.startsWith(zi)){let r=ve(e.slice(zi.length-1));return K(r,o,!0)||K(r,o.replace(sd,""),!0)}if(e.startsWith($i)){let r=_e(process.env);return r!==null&&K(ve(r)+e.slice($i.length-1),o,!0)}return K(ve(e),o,!0)}function X(e,t,n=Zu){for(let o of t){let r=od(o);if(r===null||r.tool!==n.tool)continue;if(n.tool===$u?id(r.glob,e,n.projectDir):rd(r.glob,e))return o}return null}var Bp=Object.freeze({ctx_execute:"Runs code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.\n",ctx_batch:"Runs several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.",ctx_index:"Stores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.",ctx_search:"Searches content stored with ctx_index and earlier sandbox output in this project. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.",ctx_resume:"Returns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",ctx_stats:"Reports how many bytes context-mode kept out of the conversation in this session and in this project, per agent, as a Markdown table. Show the table to the user as it is. Use it when the user asks what context-mode saved.",ctx_doctor:"Checks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause and the fix in one line. It changes nothing. Use it when the user asks whether context-mode works, or after a context-mode error.",ctx_upgrade:"Updates context-mode to the latest release for this agent and rewrites only context-mode's own entries in the host config. User entries and user settings such as hook timeouts are kept, and old entries are erased. Returns a table of what changed and whether a restart is needed. Use it only when the user asks to update context-mode.",ctx_purge:"Deletes stored data: one session, one indexed source, or everything stored for this project. This cannot be undone. Use it only when the user asks to forget or reset data."}),nc='context-mode: {size}-byte file, over the one-read limit. Run ctx_execute(language, code, file="{path}") and print only the answer.';var cd="{size}",ad="{path}";function oo(e,t,n=""){return I(nc,n).split(cd).join(String(t)).split(ad).join(e)}var{statSync:ld}=process.getBuiltinModule("node:fs"),sc="Bash",so="Read",ud="WebFetch",dd="ctx_execute",fd="ctx_batch",ic="shell",xd="1",q="-",io="--",pd="=",Ed=".",oc=",",ro="p",_d=["-e","--expression"],md=";&|(`\n\r",ae=Object.freeze({kind:"allow"}),Y=e=>({kind:"deny",reason:e}),ce=e=>typeof e=="string"?e:void 0,rc=e=>e!=null,V=(e,t)=>e.includes(t);function cc(e,t,n){let o=e.tool;if(o===void 0)return ae;let r=o.canonicalName,s=o.input,i;if(n===null){if(process.env[or]===xd)return Y(I(it,t.toolNamePrefix));process.stderr.write(kr+`
23
+ \r`,Zu=Object.freeze({tool:zu});function ed(e,t){if(t!=="claude-code")return[];let n=_e(process.env),o=process.env[Et],r=o!==void 0&&o!==""?o:n===null?null:Fe(process.env,n),s=[to(e,Yi,Ju),to(e,Yi,Vi)];return r===null?s:[...s,to(r,Vi)]}function ec(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function td(e){let t;try{t=Lt(qu(e,"utf8"))}catch(s){return s.code==="ENOENT"?{kind:"absent"}:{kind:"bad"}}let n;try{n=JSON.parse(t)}catch{return{kind:"bad"}}if(!ec(n))return{kind:"bad"};let o=n.permissions;if(o===void 0)return{kind:"ok",deny:[]};if(!ec(o))return{kind:"bad"};let r=o.deny;return r===void 0?{kind:"ok",deny:[]}:!Array.isArray(r)||!r.every(s=>typeof s=="string")?{kind:"bad"}:{kind:"ok",deny:r}}function tc(e,t){let n=[];for(let o of ed(e,t)){let r=td(o);if(r.kind==="bad")return null;r.kind==="ok"&&n.push(...r.deny)}return n}function nd(e,t){let n=[],o=0;for(;o<e.length;){let r=e[o];if(r==="*"&&t&&e[o+1]==="*"){let s=e[o+2]==="/";n.push({t:s?"globstarDir":"globstar"}),o+=s?3:2;continue}r==="*"?(n.length===0||n[n.length-1].t!=="star")&&n.push({t:"star"}):r==="?"?n.push({t:"any1"}):n.push({t:"lit",c:r}),o++}return n}function K(e,t,n){let o=nd(e,n),r=t.length,s=new Uint8Array(r+1);s[r]=1;for(let i=o.length-1;i>=0;i--){let c=o[i],a=new Uint8Array(r+1),l=0;for(let u=r;u>=0;u--){let f=u<r,d=f?t[u]:"";switch(c.t){case"lit":a[u]=f&&d===c.c?s[u+1]:0;break;case"any1":a[u]=f&&!(n&&d==="/")?s[u+1]:0;break;case"star":a[u]=s[u]||(f&&!(n&&d==="/")?a[u+1]:0);break;case"globstar":a[u]=s[u]||(f?a[u+1]:0);break;case"globstarDir":f&&d==="/"&&s[u+1]&&(l=1),a[u]=s[u]||l;break}}s=a}return s[0]===1}function od(e){let t=e.indexOf("(");if(t<1||!e.endsWith(")"))return null;let n=e.slice(t+1,e.length-1);return n===""?null:{tool:e.slice(0,t),glob:n}}function rd(e,t){if(!e.endsWith(Ji))return K(e,t,!1);let n=e.slice(0,e.length-Ji.length);if(K(n,t,!1))return!0;for(let o=0;o<t.length;o++)if(Qu.includes(t[o])&&K(n,t.slice(0,o),!1))return!0;return!1}var sd=/^[A-Za-z]:(?=\/)/;function ve(e){return no==="/"?e:e.split(no).join("/")}function id(e,t,n){if(e.startsWith(Qi)){if(n===void 0)return!1;let r=Vu(n,t);return r===""||r===Zi||r.startsWith(Zi+no)||Yu(r)?!1:K(e.slice(Qi.length),ve(r),!0)}let o=ve(t);if(e.startsWith(zi)){let r=ve(e.slice(zi.length-1));return K(r,o,!0)||K(r,o.replace(sd,""),!0)}if(e.startsWith($i)){let r=_e(process.env);return r!==null&&K(ve(r)+e.slice($i.length-1),o,!0)}return K(ve(e),o,!0)}function X(e,t,n=Zu){for(let o of t){let r=od(o);if(r===null||r.tool!==n.tool)continue;if(n.tool===$u?id(r.glob,e,n.projectDir):rd(r.glob,e))return o}return null}var Wp=Object.freeze({ctx_execute:"Runs code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.\n",ctx_batch:"Runs several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.",ctx_index:"Stores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.",ctx_search:"Searches content stored with ctx_index and earlier sandbox output in this project. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.",ctx_resume:"Returns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",ctx_stats:"Reports how many bytes context-mode kept out of the conversation in this session and in this project, per agent, as a Markdown table. Show the table to the user as it is. Use it when the user asks what context-mode saved.",ctx_doctor:"Checks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause and the fix in one line. It changes nothing. Use it when the user asks whether context-mode works, or after a context-mode error.",ctx_upgrade:"Updates context-mode to the latest release for this agent and rewrites only context-mode's own entries in the host config. User entries and user settings such as hook timeouts are kept, and old entries are erased. Returns a table of what changed and whether a restart is needed. Use it only when the user asks to update context-mode.",ctx_purge:"Deletes stored data: one session, one indexed source, or everything stored for this project. This cannot be undone. Use it only when the user asks to forget or reset data."}),nc='context-mode: {size}-byte file, over the one-read limit. Run ctx_execute(language, code, file="{path}") and print only the answer.';var cd="{size}",ad="{path}";function oo(e,t,n=""){return I(nc,n).split(cd).join(String(t)).split(ad).join(e)}var{statSync:ld}=process.getBuiltinModule("node:fs"),sc="Bash",so="Read",ud="WebFetch",dd="ctx_execute",fd="ctx_batch",ic="shell",xd="1",q="-",io="--",pd="=",Ed=".",oc=",",ro="p",_d=["-e","--expression"],md=";&|(`\n\r",ae=Object.freeze({kind:"allow"}),Y=e=>({kind:"deny",reason:e}),ce=e=>typeof e=="string"?e:void 0,rc=e=>e!=null,V=(e,t)=>e.includes(t);function cc(e,t,n){let o=e.tool;if(o===void 0)return ae;let r=o.canonicalName,s=o.input,i;if(n===null){if(process.env[or]===xd)return Y(I(it,t.toolNamePrefix));process.stderr.write(kr+`
24
24
  `),i=[]}else i=n;let c=gd(r,s,e.cwd,i);return c!==null?Y(Re+c):r===ud?Od(s,t):r===sc?Td(e,t,s,i):r===so?kd(e,t,s):ae}function ac(e,t,n,o){let r=e==="webfetch",s=r?gr.map(c=>n.toolNamePrefix+c).join(Cr):n.toolNamePrefix+mr,i=JSON.stringify(r?{url:t}:{language:ic,code:t,intent:o??_r});return[xn+fr[e]+xr,pr,Er+s,i].join(`
25
25
  `)}function lc(e){for(let t of lt){let n=ce(e[t]);if(n!==void 0&&n!=="")return n}}function gd(e,t,n,o){if(o.length===0)return null;let r=s=>X(Ht(n,s),o,{tool:so,projectDir:n});if(e===sc){let s=ce(t.command);return s===void 0?null:X(s,o)}if(e===so){let s=lc(t);return s===void 0?null:r(s)}if(e===dd){let s=ce(t.file),i=s===void 0||s===""?null:r(s);if(i!==null)return i;let c=ce(t.code);return t.language===ic&&c!==void 0?X(c,o):null}if(e===fd&&Array.isArray(t.commands))for(let s of t.commands){let i=typeof s=="string"?X(s,o):null;if(i!==null)return i}return null}function hd(e,t){return t.length===0?null:X([e.argv0,...e.args].join(" "),t)??X(e.raw,t)}function Sd(e,t){if(t.length===0)return!1;for(let n=0;n<=e.length;n++)if(!(n>0&&!md.includes(e.charAt(n-1)))&&X(e.slice(n).trimStart(),t)!==null)return!0;return!1}function bd(e){let t;try{t=new URL(e).hostname.toLowerCase()}catch{return!1}return Ir.some(n=>t===n||t.endsWith(Ed+n))}function Od(e,t){let n=ce(e.url)??"";return bd(n)?ae:Y(ac("webfetch",n,t))}function Td(e,t,n,o){let r=ce(n.command)??"",s=He(r);if(!s.ok)return Sd(r,o)?Y(I(ct,t.toolNamePrefix)):ae;let i=qi(s.commands);for(let c of i){let a=hd(c,o);if(a!==null)return Y(Re+a)}if(!Ie(t)||me(e))for(let c of i){let a=Rd(c);if(a!==null)return Y(ac(a,r,t,ce(n.description)))}return Id(i,e.cwd,t)??ae}function Rd(e){let t=e.argv0.toLowerCase();return V(Dr,t)&&Ad(t,e)?"curl":yd(e.raw)?"http":V(Ur,t)?"build":null}function Ad(e,t){return t.redirectsToFile?!Nd(e,t.args):!t.endsInBoundedSink}function Nd(e,t){let n=wr[e],o=!1;for(let r=0;r<t.length;r++){let s=t[r];if(s===io)break;if(V(Lr,s)||s===Pr&&t[r+1]===q)return!1;(s===n.long||s.startsWith(q)&&!s.startsWith(io)&&s.includes(n.short,q.length))&&(o=!0)}return o}function yd(e){let t=e.toLowerCase();for(let n of Fr)if(t.includes(n))return!0;for(let n=t.indexOf(Ne);n>=0;n=t.indexOf(Ne,n+1)){let o=t.charAt(n+Ne.length);if(o!==""&&Mr.includes(o)&&t.startsWith(Hr,n+Ne.length+o.length))return!0}return!1}var Cd="cd";function uc(e){try{let t=ld(e);return t.isFile()?t.size:-1}catch{return-1}}function kd(e,t,n){if(!rc(n.offset)&&!rc(n.limit)){let o=lc(n);if(o!==void 0){let r=Ht(e.cwd,o),s=uc(r);if(s>ee)return Y(oo(r,s,t.toolNamePrefix))}}return ae}function Id(e,t,n){if(n.nativeTools.read!==void 0&&n.nativeTools.read.length>0&&ii(n))return null;let o=t,r=null;for(let s of e){let i=s.argv0.toLowerCase();if(i===Cd&&s.args.length===1&&s.insideConstruct===void 0&&(o=Ht(o,s.args[0])),s.redirectsToFile||s.endsInBoundedSink||s.pipesOut===!0||s.insideConstruct!==void 0||!V(vr,i))continue;let c=Ld(i,s.args);if(c===null)continue;if(c.bounded){r=ae;continue}let a=Ht(o,c.file),l=uc(a);if(l>ee)return Y(oo(a,l,n.toolNamePrefix))}return r}var Mt=e=>e!==""&&[...e].every(t=>t>="0"&&t<="9");function Dd(e){if(V(En,e))return 1;for(let t of En)if(t.startsWith(io)?e.startsWith(t+pd):e.startsWith(t))return 0;return e.startsWith(q)&&Mt(e.slice(q.length))?0:-1}function wd(e){if(e===ro)return"all";if(!e.endsWith(ro))return null;let t=e.slice(0,e.length-ro.length),n=t.indexOf(oc);return(n<0?Mt(t):Mt(t.slice(0,n))&&Mt(t.slice(n+oc.length)))?"range":null}function Ld(e,t){let n=[],o=!1,r=!1,s;for(let i=0;i<t.length;i++){let c=t[i];if(V(jr,e)){let a=Dd(c);if(a>=0){o=!0,i+=a;continue}}if(e===at&&V(Gr,c)){r=!0;continue}if(e===at&&V(_d,c)){s=t[i+1],i++;continue}c.startsWith(q)&&c!==q||n.push(c)}if(e===at){if(!r)return null;s===void 0&&(s=n.shift());let i=s===void 0?null:wd(s);if(i===null)return null;o=i==="range"}return e===Br&&n.shift()!==D.identity?null:n.length===1&&n[0]!==q?{file:n[0],bounded:o}:null}import{basename as Bd,dirname as vt,join as Ge,resolve as Ec}from"node:path";import{dirname as dc,sep as Ud}from"node:path";var{realpathSync:Pd}=process.getBuiltinModule("node:fs");function Md(e){try{return Pd.native(e)}catch{return}}function Ft(e){return e.split(Ud).filter(t=>t!=="")}function fc(e){let t=e.map(Md).filter(s=>s!==void 0);if(t.length===0)throw new RangeError("commonRoot needs at least one existing path");let n=t[0],o=Ft(n).length;for(let s of t){let i=Ft(s),c=Ft(n),a=0;for(;a<o&&a<i.length&&i[a]===c[a];)a+=1;o=a}let r=n;for(;Ft(r).length>o&&dc(r)!==r;)r=dc(r);return r}var Hd=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Fd=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],L=(e,t)=>e>>>t|e<<32-t;function xc(e){let t=Buffer.from(e,"utf8"),n=t.length*8,o=Math.ceil((t.length+9)/64)*64,r=Buffer.alloc(o);t.copy(r),r[t.length]=128,r.writeUInt32BE(Math.floor(n/4294967296),o-8),r.writeUInt32BE(n>>>0,o-4);let s=Fd.slice(),i=new Uint32Array(64);for(let c=0;c<o;c+=64){for(let m=0;m<16;m++)i[m]=r.readUInt32BE(c+m*4);for(let m=16;m<64;m++){let b=L(i[m-15],7)^L(i[m-15],18)^i[m-15]>>>3,h=L(i[m-2],17)^L(i[m-2],19)^i[m-2]>>>10;i[m]=i[m-16]+b+i[m-7]+h>>>0}let[a,l,u,f,d,x,E,_]=s;for(let m=0;m<64;m++){let b=_+(L(d,6)^L(d,11)^L(d,25))+(d&x^~d&E)+Hd[m]+i[m]>>>0,h=(L(a,2)^L(a,13)^L(a,22))+(a&l^a&u^l&u)>>>0;_=E,E=x,x=d,d=f+b>>>0,f=u,u=l,l=a,a=b+h>>>0}s[0]=s[0]+a>>>0,s[1]=s[1]+l>>>0,s[2]=s[2]+u>>>0,s[3]=s[3]+f>>>0,s[4]=s[4]+d>>>0,s[5]=s[5]+x>>>0,s[6]=s[6]+E>>>0,s[7]=s[7]+_>>>0}return s.map(c=>c.toString(16).padStart(8,"0")).join("")}var{existsSync:vd,readFileSync:jd,realpathSync:pc,statSync:Gd}=process.getBuiltinModule("node:fs");function Wd(e){switch(e){case"claude-code":return"env:CLAUDE_PROJECT_DIR";case"codex":case"copilot-cli":case"kiro":return"arg:--agent+cwd";case"vscode":return"arg:workspaceFolder";case"gemini":case"qwen":case"zcode":case"opencode":return"spawn-cwd";case"pi":return"pi:ctx.cwd"}}function je(e){return e===void 0||e===""?void 0:e}function Kd(e,t){switch(e){case"env:CLAUDE_PROJECT_DIR":return je(t.env.CLAUDE_PROJECT_DIR)??je(t.cwd)??process.cwd();case"arg:--agent+cwd":case"spawn-cwd":return je(t.cwd);case"arg:workspaceFolder":{let n=t.argv.indexOf(nt);return n<0?void 0:je(t.argv[n+1])}case"pi:ctx.cwd":return je(t.piCwd)}}function Xd(e){let t;try{t=pc.native(e)}catch{throw new T("NO_GIT_DIR",{path:e})}let n=t;for(;;){let o=qd(Ge(t,cn));if(o!==null){let s=_c(Ge(o,er));return{commonDir:pc.native(s===null?o:Ec(o,s)),worktree:t,start:n}}let r=vt(t);if(r===t)return{commonDir:null,start:n};t=r}}function qd(e){let t;try{if(Gd(e).isDirectory())t=e;else{let n=_c(e);if(n===null||!n.startsWith(ln))return null;t=Ec(vt(e),n.slice(ln.length))}}catch{return null}return vd(Ge(t,tr))?t:null}function _c(e){let t;try{t=jd(e,"utf8")}catch{return null}let n=t.indexOf(`
26
26
  `),o=(n<0?t:t.slice(0,n)).trim();return o===""?null:o}function Yd(e,t){let{spawnSync:n}=process.getBuiltinModule("node:child_process"),o=n("git",t,{cwd:e,shell:!1,encoding:"utf8",stdio:["ignore","pipe","pipe"],windowsHide:!0});if(o.error!==void 0||o.status!==0)throw new T("NO_GIT_DIR",{path:e});return o.stdout.split(`
@@ -127,7 +127,7 @@ INSERT INTO chunks(source_id, session_id, worktree, agent, ord, body, title) VAL
127
127
  AND (:scope <> 'session' OR chunks.session_id = :session_id)
128
128
  AND (:scope <> 'worktree' OR chunks.worktree = :worktree)
129
129
  AND (:source IS NULL OR s.label = :source)`,Ic=`
130
- ORDER BY (session_id = :session_id) DESC, (worktree = :worktree) DESC, full DESC, score DESC, source_id DESC, ord ASC`,FE=`
130
+ ORDER BY (session_id = :session_id) DESC, (worktree = :worktree) DESC, full DESC, score DESC, source_id DESC, ord ASC`,vE=`
131
131
  WITH m AS (${kc}
132
132
  ), r AS (
133
133
  SELECT *,
@@ -136,11 +136,11 @@ WITH m AS (${kc}
136
136
  FROM m
137
137
  )
138
138
  SELECT rid, source_id, session_id, worktree, ord, full, 1.0 / (:k + rank_a) + 1.0 / (:k + rank_b) AS score
139
- FROM r${Ic}`,vE=`
139
+ FROM r${Ic}`,jE=`
140
140
  WITH m AS (${kc}
141
141
  )
142
142
  SELECT rid, source_id, session_id, worktree, ord, full, -bm AS score
143
- FROM m${Ic}`;var jE=`
143
+ FROM m${Ic}`;var GE=`
144
144
  SELECT t.rowid AS rid, c.source_id AS source_id, c.session_id AS session_id, c.worktree AS worktree, c.ord AS ord
145
145
  FROM chunks_tri t JOIN chunks c ON c.rowid = t.rowid JOIN sources s ON s.id = c.source_id
146
146
  WHERE chunks_tri MATCH :match
@@ -149,7 +149,7 @@ WHERE chunks_tri MATCH :match
149
149
  AND (:source IS NULL OR s.label = :source)
150
150
  ORDER BY bm25(chunks_tri, 1.0, ${Cc}) ASC, c.source_id DESC, c.ord ASC`;var hf="INSERT INTO chunks_tri(rowid, body, title) VALUES (?, ?, ?)",Sf="INSERT INTO chunks_tri(chunks_tri, rowid, body, title) SELECT 'delete', rowid, body, title FROM chunks";function Dc(e,t,n){let o=fo(e,t,n);return Lc(e,o,t,n),o}function fo(e,t,n){let o=0;for(let r of n)o+=r.bytes;return P(e,r=>{let s=r.raw.prepare(mf).get({session_id:t.sessionId,worktree:t.worktree,agent:t.agent,kind:t.kind,label:t.label,bytes_total:o,chunk_count:n.length,created_ts:t.createdAt,created_at:new Date(t.createdAt).toISOString()});return Number(s.id)})}function wc(e,t,n,o,r){try{Lc(e,t,n,o),po(e,t,n.sessionId,r)}catch(s){throw P(e,i=>{bf(i.raw,{sourceId:t}),i.raw.prepare("DELETE FROM sources WHERE id = ?").run(t)}),s}}function Lc(e,t,n,o){let r=[],s=[],i=0;for(let c of o)s.length>0&&i+c.bytes>en&&(r.push(s),s=[],i=0),s.push(c),i+=c.bytes;s.length>0&&r.push(s);for(let c of r)P(e,a=>{let l=a.raw.prepare(gf),u=a.raw.prepare(hf);for(let f of c){let d=f.title??"",x=l.run(t,n.sessionId,n.worktree,n.agent,f.ord,f.text,d).lastInsertRowid;u.run(x,f.text,d)}})}function bf(e,t){if(t==="all")return e.exec("INSERT INTO chunks_tri(chunks_tri) VALUES ('delete-all')"),e.exec("DELETE FROM line_units"),Number(e.prepare("DELETE FROM chunks").run().changes);let[n,o]="sourceId"in t?["source_id = ?",t.sourceId]:["source_id IN (SELECT id FROM sources WHERE label = ?)",t.label];return e.prepare(Sf+" WHERE "+n).run(o),e.prepare("DELETE FROM line_units WHERE "+n).run(o),Number(e.prepare("DELETE FROM chunks WHERE "+n).run(o).changes)}function xo(e){let t=[],n="";for(let o of e)o.trim()===""||o==="\0"?(n!==""&&t.push(n),n=""):n+=o==='"'?'""':o;return n!==""&&t.push(n),t.map(o=>`"${o}"*`).join(" ")}function Of(e){return[...new Set(xo(e).split(" ").filter(n=>n!==""))].join(" OR ")}var Tf=new Set(["a","an","the","and","or","of","to","in","on","at","by","is","be","it","as","do","i","for","are","but","not","you","all","can","had","her","was","one","our","out","has","his","how","its","may","who","did","get","got","let","she","too","will","with","this","that","from","they","been","have","some","them","than","each","into","your","could","would","about","which","their","there","other","should","also","very","when","what","then","these","those","being","does","both","while","where","here","were","much","any","my","me","we"]);function Rf(e){let t=[...new Set(xo(e).split(" ").filter(o=>o!==""))],n=t.filter(o=>!Tf.has(o.slice(1,-2).toLowerCase()));return n.length>0?n:t}var Kt=`
151
151
  AND (:scope <> 'session' OR session_id = :session_id)
152
- AND (:scope <> 'worktree' OR worktree = :worktree)`,GE=`
152
+ AND (:scope <> 'worktree' OR worktree = :worktree)`,BE=`
153
153
  WITH e AS (
154
154
  SELECT seq, kind, key, path, body, created_at FROM events
155
155
  WHERE created_at > :after${Kt}
@@ -157,7 +157,7 @@ WITH e AS (
157
157
  )
158
158
  SELECT seq, kind, key, path, body, created_at FROM e
159
159
  WHERE created_at <= IFNULL((SELECT created_at FROM e ORDER BY created_at, seq LIMIT 1 OFFSET :off), created_at)
160
- ORDER BY created_at ASC, seq ASC`,BE=`
160
+ ORDER BY created_at ASC, seq ASC`,WE=`
161
161
  WITH s AS (
162
162
  SELECT id, label, created_ts FROM sources
163
163
  WHERE created_ts > :after${Kt}
@@ -166,7 +166,7 @@ WITH s AS (
166
166
  )
167
167
  SELECT id, label, created_ts FROM s
168
168
  WHERE created_ts <= IFNULL((SELECT created_ts FROM s ORDER BY created_ts, id LIMIT 1 OFFSET :off), created_ts)
169
- ORDER BY created_ts ASC, id ASC`;var WE=`
169
+ ORDER BY created_ts ASC, id ASC`;var KE=`
170
170
  SELECT EXISTS(SELECT 1 FROM events WHERE created_at > :after${Kt} AND (:source IS NULL OR kind = :source))
171
171
  OR EXISTS(SELECT 1 FROM sources WHERE created_ts > :after${Kt} AND (:source IS NULL OR label = :source)
172
172
  AND label <> :reserved) AS more`;var Af=`CREATE VIRTUAL TABLE r USING fts5(body, ${Gt}, content='')`,Nf="INSERT INTO r(rowid, body) VALUES (?, ?)",yf="SELECT rowid AS id, bm25(r) AS bm FROM r WHERE r MATCH ?";function G(e,t,n="all"){let o=e.map(()=>0),r=n==="any"?Of(t):xo(t);if(r===""||e.length===0)return o;let s=process.getBuiltinModule("node:sqlite");if(s===void 0)throw new T("NO_SQLITE");let i=new s.DatabaseSync(":memory:");try{i.exec(Af);let c=i.prepare(Nf);i.exec("BEGIN");for(let a=0;a<e.length;a++)c.run(a+1,e[a]);i.exec("COMMIT");for(let a of i.prepare(yf).all(r))o[Number(a.id)-1]=-a.bm;return o}finally{i.close()}}var Cf="s";function Pc(e){return Cf+e.toString(36)}function po(e,t,n,o){let r=0;for(;r<o.length;){let s=r,i=0;for(;s<o.length&&(s===r||i+o[s].body.length<=en);)i+=o[s].body.length,s++;let c=r;P(e,a=>{let l=a.raw.prepare("INSERT INTO line_units(body, source_id, session_id, ord) VALUES (?, ?, ?, ?)");for(let u=c;u<s;u++){let f=o[u];l.run(f.body,t,n,f.ord)}}),r=s}}function Uc(e,t){return t===e?e:e+" "+t}function Mc(e,t,n,o){let r=Rf(n).join(" OR ");return r===""||t===""?[]:e.raw.prepare("SELECT u.source_id AS source_id, u.ord AS ord, u.body AS body, -bm25(line_units) AS score, s.label AS label FROM line_units u JOIN sources s ON s.id = u.source_id WHERE line_units MATCH ? AND u.session_id = ? ORDER BY bm25(line_units) LIMIT ?").all(r,t,o).map(i=>({sourceId:Number(i.source_id),ord:Number(i.ord),label:i.label,body:i.body,score:i.score}))}function kf(e){let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" ");)t++;return t}function Eo(e){let t=e.split(`
@@ -358,7 +358,7 @@ var DECISION_OPTION_KEY = "option";
358
358
  var DECISION_LABEL_JOIN = " | ";
359
359
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
360
360
  var RELEASE_BRANCH = "release";
361
- var BUNDLE_SHA = true ? "c8f6a68d0aea0fbe994c9e6a4c2d674a7f3260ac" : void 0;
361
+ var BUNDLE_SHA = true ? "a66617dc9637c129dbf43f4a8c07cdc689884a22" : void 0;
362
362
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
363
363
  var DOCTOR_LABEL = Object.freeze({
364
364
  D1: "version",
@@ -604,7 +604,7 @@ var V1_STATUSLINE_COMMAND = "context-mode statusline";
604
604
  var V1_PI_PACKAGE = "npm:context-mode";
605
605
  var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
606
606
  var V1_TMP_PREFIX = "context-mode-";
607
- var V1_TOML_SECTION_PREFIX = "[mcp_servers.context-mode";
607
+ var V1_TOML_SECTION_ROOT = "mcp_servers";
608
608
  var V1_HOOKS_DIR_NAME = "hooks";
609
609
  var SETTINGS_FILE = "settings.json";
610
610
  var CLAUDE_USER_CONFIG_FILE = ".claude.json";
@@ -678,6 +678,8 @@ var PLUGIN_ID = SERVER_KEY;
678
678
  var PLUGIN_NAME = SERVER_KEY;
679
679
  var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
680
680
  var SERVER_ENTRY_FILE = "server.mjs";
681
+ var VSCODE_WORKSPACE_VAR = "${workspaceFolder}";
682
+ var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
681
683
  var HOST_NODE_COMMAND = "node";
682
684
  var EXE_SUFFIX = ".exe";
683
685
  var HOST_CONFIG_TMP_SUFFIX = ".tmp";
@@ -22281,9 +22283,6 @@ function scanToml(text) {
22281
22283
  function tomlTableSpans(text) {
22282
22284
  return scanToml(text).tables;
22283
22285
  }
22284
- function tomlHeaderText(path5) {
22285
- return "[" + path5.map(tomlHeaderKey).join(".") + "]";
22286
- }
22287
22286
  function parseHostConfig(agent, path5, text, format) {
22288
22287
  try {
22289
22288
  return format === "toml" ? scanToml(text).value : scanJson(text, format).value;
@@ -22452,27 +22451,44 @@ function setText(agent, path5, text, format, key, value) {
22452
22451
  function serverScript() {
22453
22452
  return join8(dirname4(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
22454
22453
  }
22455
- function listTarget(key, own2, v1) {
22454
+ function isNodeCommand(command) {
22455
+ if (typeof command !== "string") return false;
22456
+ let at2 = -1;
22457
+ for (const sep4 of V1_PATH_SEPS) at2 = Math.max(at2, command.lastIndexOf(sep4));
22458
+ const exe = command.slice(at2 + 1).toLowerCase();
22459
+ return exe === HOST_NODE_COMMAND || exe === HOST_NODE_COMMAND + EXE_SUFFIX;
22460
+ }
22461
+ function ownMcpValue(agent, node, server2) {
22462
+ const mcp = OWN_MCP_ENTRY[agent];
22463
+ if (mcp === void 0) return void 0;
22464
+ const tail = agent === "vscode" ? [WORKSPACE_FOLDER_FLAG, VSCODE_WORKSPACE_VAR] : [];
22465
+ return { ...mcp.fields, [MCP_COMMAND_FIELD]: node, [MCP_ARGS_FIELD]: [server2, AGENT_ARG, agent, ...tail] };
22466
+ }
22467
+ function opencodePluginFile() {
22468
+ return join8(dirname4(process.argv[1] ?? ""), ...OPENCODE_PLUGIN_PATH);
22469
+ }
22470
+ function listTarget(key, own2, v1, alt = []) {
22456
22471
  return {
22457
22472
  key: [key],
22458
22473
  next(current) {
22459
22474
  const list3 = Array.isArray(current) ? current.filter((x) => x !== v1) : [];
22460
- return list3.includes(own2) ? list3 : [...list3, own2];
22475
+ return list3.includes(own2) || alt.some((a) => list3.includes(a)) ? list3 : [...list3, own2];
22461
22476
  }
22462
22477
  };
22463
22478
  }
22464
- function ownTargets(agent) {
22479
+ function ownTargets(agent, accept) {
22465
22480
  const mcp = OWN_MCP_ENTRY[agent];
22466
22481
  if (mcp !== void 0) {
22467
22482
  return [{
22468
22483
  key: mcp.key,
22469
22484
  next(current) {
22470
22485
  const keep = isPlainObject3(current) ? current : {};
22471
- return { ...keep, ...mcp.fields, [MCP_COMMAND_FIELD]: HOST_NODE_COMMAND, [MCP_ARGS_FIELD]: [serverScript(), AGENT_ARG, agent] };
22486
+ const node = accept.nodePath === true && isNodeCommand(keep[MCP_COMMAND_FIELD]) ? keep[MCP_COMMAND_FIELD] : HOST_NODE_COMMAND;
22487
+ return { ...keep, ...ownMcpValue(agent, node, serverScript()) };
22472
22488
  }
22473
22489
  }, ...(mcp.also ?? []).map(([key, value]) => ({ key, next: () => value }))];
22474
22490
  }
22475
- if (agent === "opencode") return [listTarget(OPENCODE_PLUGIN_KEY, OPENCODE_GIT_SPEC, V1_OPENCODE_PLUGIN_SPEC)];
22491
+ if (agent === "opencode") return [listTarget(OPENCODE_PLUGIN_KEY, OPENCODE_GIT_SPEC, V1_OPENCODE_PLUGIN_SPEC, accept.listEntries)];
22476
22492
  if (agent === "pi") return [listTarget(PI_PACKAGES_KEY, PI_GIT_PACKAGE, V1_PI_PACKAGE)];
22477
22493
  return [];
22478
22494
  }
@@ -22488,9 +22504,9 @@ function applyEdits(agent, path5, text, format, wanted) {
22488
22504
  }
22489
22505
  return { text: out, format, edits };
22490
22506
  }
22491
- function mergeOwnEntries(agent, current, format, row5) {
22507
+ function mergeOwnEntries(agent, current, format, row5, accept = {}) {
22492
22508
  const parsed = parseHostConfig(row5.id, HOST_CONFIG_TEXT_PATH, current, format);
22493
- const wanted = ownTargets(agent).map((t) => [t.key, t.next(hostConfigValueAt(parsed, t.key))]);
22509
+ const wanted = ownTargets(agent, accept).map((t) => [t.key, t.next(hostConfigValueAt(parsed, t.key))]);
22494
22510
  return applyEdits(agent, HOST_CONFIG_TEXT_PATH, current, format, wanted);
22495
22511
  }
22496
22512
  function writeHostConfigEdit(_requested, current, patch) {
@@ -22563,6 +22579,21 @@ function readTomlTables(file2) {
22563
22579
  return [];
22564
22580
  }
22565
22581
  }
22582
+ function readTomlValue(file2) {
22583
+ try {
22584
+ return parseHostConfig("codex", file2, readText(file2), "toml");
22585
+ } catch {
22586
+ return {};
22587
+ }
22588
+ }
22589
+ function isV2McpTable(v) {
22590
+ if (!isObj(v) || !isNodeCommand(v[MCP_COMMAND_FIELD])) return false;
22591
+ const first = Array.isArray(v[MCP_ARGS_FIELD]) ? v[MCP_ARGS_FIELD][0] : void 0;
22592
+ if (typeof first !== "string") return false;
22593
+ let at2 = -1;
22594
+ for (const sep4 of V1_PATH_SEPS) at2 = Math.max(at2, first.lastIndexOf(sep4));
22595
+ return first.slice(at2 + 1) === SERVER_ENTRY_FILE;
22596
+ }
22566
22597
  var listOf = (v) => Array.isArray(v) ? v : [];
22567
22598
  var commandOf = (v) => isObj(v) && typeof v.command === "string" ? v.command : null;
22568
22599
  function nestedCommands(doc) {
@@ -22636,8 +22667,11 @@ function scanCodex(agentHome, out) {
22636
22667
  }
22637
22668
  }
22638
22669
  const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
22670
+ const config2 = readTomlValue(tomlFile);
22639
22671
  for (const span of readTomlTables(tomlFile)) {
22640
- if (tomlHeaderText(span.path).startsWith(V1_TOML_SECTION_PREFIX)) out.push(finding(tomlFile, span.header.trim(), V1_REASON.codexToml));
22672
+ if (span.path[0] !== V1_TOML_SECTION_ROOT || span.path[1] !== SERVER_KEY) continue;
22673
+ if (span.path.length === 2 && isV2McpTable(hostConfigValueAt(config2, span.path))) continue;
22674
+ out.push(finding(tomlFile, span.header.trim(), V1_REASON.codexToml));
22641
22675
  }
22642
22676
  dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
22643
22677
  }
@@ -22749,7 +22783,7 @@ function scanAll(home, tmp, out) {
22749
22783
  function detectV1(agent, home, scope = {}) {
22750
22784
  const out = [];
22751
22785
  const project = scope.project;
22752
- const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join9(home, ...AGENT_HOME_DIR[agent]);
22786
+ const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join9(home, ...AGENT_HOME_DIR[agent]);
22753
22787
  switch (agent) {
22754
22788
  case "claude-code":
22755
22789
  scanClaudeCode(home, agentHome, out);
@@ -22983,7 +23017,7 @@ function mcpWrong(row5, home, env) {
22983
23017
  return false;
22984
23018
  }
22985
23019
  const cur = readHostConfig(row5.id, file2);
22986
- return mergeOwnEntries(row5.id, cur.text, cur.format, row5).edits.length > 0;
23020
+ return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
22987
23021
  } catch {
22988
23022
  return true;
22989
23023
  }
@@ -23482,7 +23516,7 @@ async function runDoctorChecks(ctx, adapter, host) {
23482
23516
  D1: () => checkVersion({ bundleSha: BUNDLE_SHA, env: buildChildEnv(env), cwd: project.worktree, signal: ctx.signal }),
23483
23517
  D2: () => checkNode({ nodeVersion: process.version, bunVersion: process.versions.bun }),
23484
23518
  D3: () => checkHostConfig(adapter, env, project.worktree),
23485
- D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
23519
+ D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), codexDir: codexDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
23486
23520
  D5: () => hookRow(ctx, adapter, host),
23487
23521
  D5b: () => checkDoubleFire(adapter.id, project.worktree),
23488
23522
  D6: () => checkMcp(ctx),
package/package.json CHANGED
@@ -63,5 +63,5 @@
63
63
  "url": "git+https://github.com/mksglu/context-mode.git"
64
64
  },
65
65
  "type": "module",
66
- "version": "2.0.0-next.12"
66
+ "version": "2.0.0-next.14"
67
67
  }
package/pi/index.js CHANGED
@@ -11504,7 +11504,7 @@ var DECISION_OPTION_KEY = "option";
11504
11504
  var DECISION_LABEL_JOIN = " | ";
11505
11505
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11506
11506
  var RELEASE_BRANCH = "release";
11507
- var BUNDLE_SHA = true ? "c8f6a68d0aea0fbe994c9e6a4c2d674a7f3260ac" : void 0;
11507
+ var BUNDLE_SHA = true ? "a66617dc9637c129dbf43f4a8c07cdc689884a22" : void 0;
11508
11508
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11509
11509
  var DOCTOR_LABEL = Object.freeze({
11510
11510
  D1: "version",
@@ -11751,7 +11751,7 @@ var V1_STATUSLINE_COMMAND = "context-mode statusline";
11751
11751
  var V1_PI_PACKAGE = "npm:context-mode";
11752
11752
  var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
11753
11753
  var V1_TMP_PREFIX = "context-mode-";
11754
- var V1_TOML_SECTION_PREFIX = "[mcp_servers.context-mode";
11754
+ var V1_TOML_SECTION_ROOT = "mcp_servers";
11755
11755
  var V1_HOOKS_DIR_NAME = "hooks";
11756
11756
  var SETTINGS_FILE = "settings.json";
11757
11757
  var CLAUDE_USER_CONFIG_FILE = ".claude.json";
@@ -11824,6 +11824,8 @@ var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON
11824
11824
  var PLUGIN_NAME = SERVER_KEY;
11825
11825
  var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
11826
11826
  var SERVER_ENTRY_FILE = "server.mjs";
11827
+ var VSCODE_WORKSPACE_VAR = "${workspaceFolder}";
11828
+ var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
11827
11829
  var HOST_NODE_COMMAND = "node";
11828
11830
  var EXE_SUFFIX = ".exe";
11829
11831
  var HOST_CONFIG_TMP_SUFFIX = ".tmp";
@@ -22288,9 +22290,6 @@ function scanToml(text) {
22288
22290
  function tomlTableSpans(text) {
22289
22291
  return scanToml(text).tables;
22290
22292
  }
22291
- function tomlHeaderText(path5) {
22292
- return "[" + path5.map(tomlHeaderKey).join(".") + "]";
22293
- }
22294
22293
  function parseHostConfig(agent, path5, text, format) {
22295
22294
  try {
22296
22295
  return format === "toml" ? scanToml(text).value : scanJson(text, format).value;
@@ -22459,27 +22458,44 @@ function setText(agent, path5, text, format, key, value) {
22459
22458
  function serverScript() {
22460
22459
  return join8(dirname4(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
22461
22460
  }
22462
- function listTarget(key, own4, v1) {
22461
+ function isNodeCommand(command) {
22462
+ if (typeof command !== "string") return false;
22463
+ let at2 = -1;
22464
+ for (const sep4 of V1_PATH_SEPS) at2 = Math.max(at2, command.lastIndexOf(sep4));
22465
+ const exe = command.slice(at2 + 1).toLowerCase();
22466
+ return exe === HOST_NODE_COMMAND || exe === HOST_NODE_COMMAND + EXE_SUFFIX;
22467
+ }
22468
+ function ownMcpValue(agent, node3, server) {
22469
+ const mcp = OWN_MCP_ENTRY[agent];
22470
+ if (mcp === void 0) return void 0;
22471
+ const tail = agent === "vscode" ? [WORKSPACE_FOLDER_FLAG, VSCODE_WORKSPACE_VAR] : [];
22472
+ return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
22473
+ }
22474
+ function opencodePluginFile() {
22475
+ return join8(dirname4(process.argv[1] ?? ""), ...OPENCODE_PLUGIN_PATH);
22476
+ }
22477
+ function listTarget(key, own4, v1, alt = []) {
22463
22478
  return {
22464
22479
  key: [key],
22465
22480
  next(current) {
22466
22481
  const list3 = Array.isArray(current) ? current.filter((x) => x !== v1) : [];
22467
- return list3.includes(own4) ? list3 : [...list3, own4];
22482
+ return list3.includes(own4) || alt.some((a) => list3.includes(a)) ? list3 : [...list3, own4];
22468
22483
  }
22469
22484
  };
22470
22485
  }
22471
- function ownTargets(agent) {
22486
+ function ownTargets(agent, accept) {
22472
22487
  const mcp = OWN_MCP_ENTRY[agent];
22473
22488
  if (mcp !== void 0) {
22474
22489
  return [{
22475
22490
  key: mcp.key,
22476
22491
  next(current) {
22477
22492
  const keep = isPlainObject3(current) ? current : {};
22478
- return { ...keep, ...mcp.fields, [MCP_COMMAND_FIELD]: HOST_NODE_COMMAND, [MCP_ARGS_FIELD]: [serverScript(), AGENT_ARG, agent] };
22493
+ const node3 = accept.nodePath === true && isNodeCommand(keep[MCP_COMMAND_FIELD]) ? keep[MCP_COMMAND_FIELD] : HOST_NODE_COMMAND;
22494
+ return { ...keep, ...ownMcpValue(agent, node3, serverScript()) };
22479
22495
  }
22480
22496
  }, ...(mcp.also ?? []).map(([key, value]) => ({ key, next: () => value }))];
22481
22497
  }
22482
- if (agent === "opencode") return [listTarget(OPENCODE_PLUGIN_KEY, OPENCODE_GIT_SPEC, V1_OPENCODE_PLUGIN_SPEC)];
22498
+ if (agent === "opencode") return [listTarget(OPENCODE_PLUGIN_KEY, OPENCODE_GIT_SPEC, V1_OPENCODE_PLUGIN_SPEC, accept.listEntries)];
22483
22499
  if (agent === "pi") return [listTarget(PI_PACKAGES_KEY, PI_GIT_PACKAGE, V1_PI_PACKAGE)];
22484
22500
  return [];
22485
22501
  }
@@ -22495,9 +22511,9 @@ function applyEdits(agent, path5, text, format, wanted) {
22495
22511
  }
22496
22512
  return { text: out, format, edits };
22497
22513
  }
22498
- function mergeOwnEntries(agent, current, format, row5) {
22514
+ function mergeOwnEntries(agent, current, format, row5, accept = {}) {
22499
22515
  const parsed = parseHostConfig(row5.id, HOST_CONFIG_TEXT_PATH, current, format);
22500
- const wanted = ownTargets(agent).map((t) => [t.key, t.next(hostConfigValueAt(parsed, t.key))]);
22516
+ const wanted = ownTargets(agent, accept).map((t) => [t.key, t.next(hostConfigValueAt(parsed, t.key))]);
22501
22517
  return applyEdits(agent, HOST_CONFIG_TEXT_PATH, current, format, wanted);
22502
22518
  }
22503
22519
  function writeHostConfigEdit(_requested, current, patch) {
@@ -22570,6 +22586,21 @@ function readTomlTables(file2) {
22570
22586
  return [];
22571
22587
  }
22572
22588
  }
22589
+ function readTomlValue(file2) {
22590
+ try {
22591
+ return parseHostConfig("codex", file2, readText(file2), "toml");
22592
+ } catch {
22593
+ return {};
22594
+ }
22595
+ }
22596
+ function isV2McpTable(v) {
22597
+ if (!isObj(v) || !isNodeCommand(v[MCP_COMMAND_FIELD])) return false;
22598
+ const first = Array.isArray(v[MCP_ARGS_FIELD]) ? v[MCP_ARGS_FIELD][0] : void 0;
22599
+ if (typeof first !== "string") return false;
22600
+ let at2 = -1;
22601
+ for (const sep4 of V1_PATH_SEPS) at2 = Math.max(at2, first.lastIndexOf(sep4));
22602
+ return first.slice(at2 + 1) === SERVER_ENTRY_FILE;
22603
+ }
22573
22604
  var listOf = (v) => Array.isArray(v) ? v : [];
22574
22605
  var commandOf = (v) => isObj(v) && typeof v.command === "string" ? v.command : null;
22575
22606
  function nestedCommands(doc) {
@@ -22643,8 +22674,11 @@ function scanCodex(agentHome, out) {
22643
22674
  }
22644
22675
  }
22645
22676
  const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
22677
+ const config4 = readTomlValue(tomlFile);
22646
22678
  for (const span of readTomlTables(tomlFile)) {
22647
- if (tomlHeaderText(span.path).startsWith(V1_TOML_SECTION_PREFIX)) out.push(finding(tomlFile, span.header.trim(), V1_REASON.codexToml));
22679
+ if (span.path[0] !== V1_TOML_SECTION_ROOT || span.path[1] !== SERVER_KEY) continue;
22680
+ if (span.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span.path))) continue;
22681
+ out.push(finding(tomlFile, span.header.trim(), V1_REASON.codexToml));
22648
22682
  }
22649
22683
  dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
22650
22684
  }
@@ -22756,7 +22790,7 @@ function scanAll(home, tmp, out) {
22756
22790
  function detectV1(agent, home, scope = {}) {
22757
22791
  const out = [];
22758
22792
  const project = scope.project;
22759
- const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join9(home, ...AGENT_HOME_DIR[agent]);
22793
+ const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join9(home, ...AGENT_HOME_DIR[agent]);
22760
22794
  switch (agent) {
22761
22795
  case "claude-code":
22762
22796
  scanClaudeCode(home, agentHome, out);
@@ -22990,7 +23024,7 @@ function mcpWrong(row5, home, env) {
22990
23024
  return false;
22991
23025
  }
22992
23026
  const cur = readHostConfig(row5.id, file2);
22993
- return mergeOwnEntries(row5.id, cur.text, cur.format, row5).edits.length > 0;
23027
+ return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
22994
23028
  } catch {
22995
23029
  return true;
22996
23030
  }
@@ -23499,7 +23533,7 @@ async function runDoctorChecks(ctx, adapter, host) {
23499
23533
  D1: () => checkVersion({ bundleSha: BUNDLE_SHA, env: buildChildEnv(env), cwd: project.worktree, signal: ctx.signal }),
23500
23534
  D2: () => checkNode({ nodeVersion: process.version, bunVersion: process.versions.bun }),
23501
23535
  D3: () => checkHostConfig(adapter, env, project.worktree),
23502
- D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
23536
+ D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), codexDir: codexDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
23503
23537
  D5: () => hookRow(ctx, adapter, host),
23504
23538
  D5b: () => checkDoubleFire(adapter.id, project.worktree),
23505
23539
  D6: () => checkMcp(ctx),
@@ -12,5 +12,5 @@
12
12
  }
13
13
  },
14
14
  "name": "context-mode",
15
- "version": "2.0.0-next.12"
15
+ "version": "2.0.0-next.14"
16
16
  }
package/run.mjs CHANGED
@@ -382,6 +382,7 @@ var V1_REASON = Object.freeze({
382
382
  });
383
383
  var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering]);
384
384
  var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
385
+ var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
385
386
  var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
386
387
  var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
387
388
  var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);