context-mode 1.0.150 → 1.0.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/build/adapters/vscode-copilot/index.js +13 -1
- package/cli.bundle.mjs +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +1 -1
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Claude Code plugins by Mert Koseoğlu",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.151"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "context-mode",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
16
|
-
"version": "1.0.
|
|
16
|
+
"version": "1.0.151",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Mert Koseoğlu"
|
|
19
19
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.151",
|
|
4
4
|
"description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.151",
|
|
4
4
|
"description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "Context Mode",
|
|
4
4
|
"kind": "tool",
|
|
5
5
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.151",
|
|
7
7
|
"sandbox": {
|
|
8
8
|
"mode": "permissive",
|
|
9
9
|
"filesystem_access": "full",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.151",
|
|
4
4
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -43,7 +43,19 @@ export class VSCodeCopilotAdapter extends CopilotBaseAdapter {
|
|
|
43
43
|
return `pid-${process.ppid}`;
|
|
44
44
|
}
|
|
45
45
|
getProjectDir() {
|
|
46
|
-
|
|
46
|
+
// Cascade order (locked by tests/adapters/vscode-copilot.test.ts):
|
|
47
|
+
// 1. CLAUDE_PROJECT_DIR — top priority for users running VS Code under
|
|
48
|
+
// Claude Code CLI.
|
|
49
|
+
// 2. VSCODE_CWD — exported by VS Code's bootstrap into every child it
|
|
50
|
+
// spawns (refs/platforms/vscode-copilot/src/util/vs/base/common/
|
|
51
|
+
// process.ts:31). The MCP child inherits it. Was previously missing
|
|
52
|
+
// from this cascade — every direct VS Code Copilot session silently
|
|
53
|
+
// lost its workspace folder. PR #689 5-agent EM audit (Phase A
|
|
54
|
+
// claim verification) confirmed the gap; this is the minimal fix.
|
|
55
|
+
// 3. process.cwd() — last resort.
|
|
56
|
+
return (process.env.CLAUDE_PROJECT_DIR
|
|
57
|
+
|| process.env.VSCODE_CWD
|
|
58
|
+
|| process.cwd());
|
|
47
59
|
}
|
|
48
60
|
getSessionDir() {
|
|
49
61
|
// Issue #649: CONTEXT_MODE_DATA_DIR wins over both the .github project
|
package/cli.bundle.mjs
CHANGED
|
@@ -139,7 +139,7 @@ var CP=Object.create;var ed=Object.defineProperty;var OP=Object.getOwnPropertyDe
|
|
|
139
139
|
|
|
140
140
|
Use context-mode MCP tools (execute, execute_file, batch_execute, fetch_and_index, search) instead of bash/cat/curl for data-heavy operations.`}}getProjectDir(e){return e.cwd??process.env.CODEX_PROJECT_DIR??process.cwd()}getHooksPath(){return Kn(this.getConfigDir(),"hooks.json")}backupFile(e,r=""){let n=r?`${e}${r}-${new Date().toISOString().replace(/[:.]/g,"-")}.bak`:`${e}.bak`;return wC(e,n),n}readHooksConfig(){let e=this.getHooksPath();try{return{ok:!0,config:JSON.parse(Jo(e,"utf-8"))}}catch(r){let n=r instanceof Error?r.message:String(r);return(typeof r=="object"&&r!==null&&"code"in r?String(r.code??""):"")==="ENOENT"?{ok:!1,reason:"missing"}:r instanceof SyntaxError?{ok:!1,reason:"invalid_json",error:n}:{ok:!1,reason:"read_error",error:n}}}writeHooksConfig(e){let r=this.getHooksPath();Hd(Zd(r),{recursive:!0}),Zv(r,JSON.stringify(e,null,2)+`
|
|
141
141
|
`,"utf-8")}upsertManagedHookEntry(e,r,n,o){let s=Array.isArray(e[r])?[...e[r]]:[],i=s.map((c,u)=>this.isManagedContextModeEntry(r,c)?u:-1).filter(c=>c>=0);if(i.length===0){s.push(n),e[r]=s,o.push(`Added ${r} hook`);return}let a=i[0];JSON.stringify(s[a])!==JSON.stringify(n)&&(s[a]=n,o.push(`Updated ${r} hook`));for(let c of i.slice(1).reverse())s.splice(c,1),o.push(`Removed duplicate ${r} context-mode hook`);e[r]=s}isExpectedHookEntry(e,r,n){return!r||typeof r!="object"||e==="PreToolUse"&&r.matcher!==n.matcher?!1:this.entryContainsManagedCommand(e,r)}isManagedContextModeEntry(e,r){return!r||typeof r!="object"?!1:this.entryContainsManagedCommand(e,r)}entryContainsManagedCommand(e,r){let n=(Array.isArray(r.hooks)?r.hooks:[]).map(i=>this.normalizeCommand(i.command)).filter(i=>i.length>0),o=this.normalizeCommand(Jn[e]??""),s=RC[e]??[];return n.some(i=>i.includes(o)||s.some(a=>i.includes(a)))}normalizeCommand(e){return(e??"").replace(/\\/g,"/")}extractSessionId(e){return e.session_id?e.session_id:`pid-${process.ppid}`}}});import{readFileSync as Kv,writeFileSync as IC,mkdirSync as AC,accessSync as NC,chmodSync as DC,constants as MC}from"node:fs";import{resolve as mc,join as jC}from"node:path";var Yo,qd=S(()=>{"use strict";yt();Yo=class extends Se{paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!0,sessionStart:!0,canModifyArgs:!0,canModifyOutput:!0,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(),raw:e}}parsePostToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:r.tool_output,isError:r.is_error,sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(),raw:e}}parsePreCompactInput(e){let r=e;return{sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(),raw:e}}parseSessionStartInput(e){let r=e,n=r.source??"startup",o;switch(n){case"compact":o="compact";break;case"resume":o="resume";break;case"clear":o="clear";break;default:o="startup"}return{sessionId:this.extractSessionId(r),source:o,projectDir:this.getProjectDir(),raw:e}}formatPreToolUseResponse(e){if(e.decision==="deny")return{permissionDecision:"deny",reason:e.reason??"Blocked by context-mode hook"};if(e.decision==="modify"&&e.updatedInput)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.PRE_TOOL_USE,updatedInput:e.updatedInput}};if(e.decision==="context"&&e.additionalContext)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.PRE_TOOL_USE,additionalContext:e.additionalContext}};if(e.decision==="ask")return{permissionDecision:"deny",reason:e.reason??"Action requires user confirmation (security policy)"}}formatPostToolUseResponse(e){if(e.updatedOutput)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.POST_TOOL_USE,decision:"block",reason:e.updatedOutput}};if(e.additionalContext)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.POST_TOOL_USE,additionalContext:e.additionalContext}}}formatPreCompactResponse(e){return e.context??""}formatSessionStartResponse(e){return e.context??""}getSettingsPath(e){return mc(e??process.cwd(),".github","hooks","context-mode.json")}generateHookConfig(e){let{HOOK_TYPES:r,buildHookCommand:n}=this.hookModule;return{[r.PRE_TOOL_USE]:[{matcher:"",hooks:[{type:"command",command:n(r.PRE_TOOL_USE,e)}]}],[r.POST_TOOL_USE]:[{matcher:"",hooks:[{type:"command",command:n(r.POST_TOOL_USE,e)}]}],[r.PRE_COMPACT]:[{matcher:"",hooks:[{type:"command",command:n(r.PRE_COMPACT,e)}]}],[r.SESSION_START]:[{matcher:"",hooks:[{type:"command",command:n(r.SESSION_START,e)}]}]}}readSettings(){try{let e=Kv(this.getSettingsPath(),"utf-8");return JSON.parse(e)}catch{}try{let e=Kv(mc(".claude","settings.json"),"utf-8");return JSON.parse(e)}catch{return null}}writeSettings(e){let r=this.getSettingsPath();AC(mc(".github","hooks"),{recursive:!0}),IC(r,JSON.stringify(e,null,2)+`
|
|
142
|
-
`,"utf-8")}configureAllHooks(e){let r=[],n=this.readSettings()??{},o=n.hooks??{},{HOOK_TYPES:s,HOOK_SCRIPTS:i,buildHookCommand:a}=this.hookModule,c=[s.PRE_TOOL_USE,s.POST_TOOL_USE,s.PRE_COMPACT,s.SESSION_START];for(let u of c)i[u]&&(o[u]=[{matcher:"",hooks:[{type:"command",command:a(u,e)}]}],r.push(`Configured ${u} hook`));return n.hooks=o,this.writeSettings(n),r.push(`Wrote hook config to ${this.getSettingsPath()}`),r}setHookPermissions(e){let r=[],n=jC(e,"hooks",this.hookSubdir);for(let o of Object.values(this.hookModule.HOOK_SCRIPTS)){let s=mc(n,o);try{NC(s,MC.R_OK),DC(s,493),r.push(s)}catch{}}return r}updatePluginRegistry(e,r){}}});function Jv(t,e){if(!Vd[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook vscode-copilot ${t.toLowerCase()}`}var qt,Vd,Zq,Bq,Yv=S(()=>{"use strict";qt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart"},Vd={[qt.PRE_TOOL_USE]:"pretooluse.mjs",[qt.POST_TOOL_USE]:"posttooluse.mjs",[qt.PRE_COMPACT]:"precompact.mjs",[qt.SESSION_START]:"sessionstart.mjs"},Zq=[qt.PRE_TOOL_USE,qt.SESSION_START],Bq=[qt.POST_TOOL_USE,qt.PRE_COMPACT]});var Qv={};Le(Qv,{VSCodeCopilotAdapter:()=>Kd});import{readFileSync as Wd,mkdirSync as Xv,accessSync as zC,existsSync as LC,constants as FC}from"node:fs";import{resolve as Xo,join as hi}from"node:path";import{homedir as Gd}from"node:os";var Kd,eb=S(()=>{"use strict";qd();yt();Yv();Kd=class extends Yo{constructor(){super([".vscode"])}name="VS Code Copilot";hookModule={HOOK_TYPES:qt,HOOK_SCRIPTS:Vd,buildHookCommand:Jv};hookSubdir="vscode-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.VSCODE_PID?`vscode-${process.env.VSCODE_PID}`:`pid-${process.ppid}`}getProjectDir(){return process.env.CLAUDE_PROJECT_DIR||process.cwd()}getSessionDir(){let e=lr();if(e){let s=hi(e,"context-mode","sessions");return Xv(s,{recursive:!0}),s}let r=Xo(".github","context-mode","sessions"),n=hi(Gd(),".vscode","context-mode","sessions"),o=LC(Xo(".github"))?r:n;return Xv(o,{recursive:!0}),o}getConfigDir(e){return Xo(e??process.cwd(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[],n=Xo(".github","hooks");try{zC(n,FC.R_OK)}catch{return r.push({check:"Hooks directory",status:"fail",message:".github/hooks/ directory not found",fix:"context-mode upgrade"}),r}let o=Xo(n,"context-mode.json");try{let s=Wd(o,"utf-8"),a=JSON.parse(s).hooks;a?.[qt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in context-mode.json",fix:"context-mode upgrade"}),a?.[qt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"API stability",status:"warn",message:"VS Code Copilot hooks are in preview \u2014 API may change without notice"}),r.push({check:"Matcher support",status:"warn",message:"Matchers are parsed but IGNORED \u2014 all hooks fire on all tools"}),r}checkPluginRegistration(){try{let e=Xo(".vscode","mcp.json"),r=Wd(e,"utf-8"),o=JSON.parse(r).servers;return o&&Object.keys(o).some(i=>i.includes("context-mode"))?{check:"MCP registration",status:"pass",message:"context-mode found in .vscode/mcp.json"}:{check:"MCP registration",status:"fail",message:"context-mode not found in .vscode/mcp.json",fix:"Add context-mode server to .vscode/mcp.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read .vscode/mcp.json"}}}getInstalledVersion(){let e=[hi(Gd(),".vscode","extensions"),hi(Gd(),".vscode-insiders","extensions")];for(let r of e)try{let n=Wd(hi(r,"extensions.json"),"utf-8"),s=JSON.parse(n).find(i=>typeof i.identifier=="object"&&i.identifier!==null&&i.identifier.id?.toString().includes("context-mode"));if(s&&typeof s.version=="string")return s.version}catch{continue}return"not installed"}}});function tb(t,e){if(!Jd[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook jetbrains-copilot ${t.toLowerCase()}`}var Vt,Jd,Xq,Qq,rb=S(()=>{"use strict";Vt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart",STOP:"Stop",SUBAGENT_START:"SubagentStart",SUBAGENT_STOP:"SubagentStop"},Jd={[Vt.PRE_TOOL_USE]:"pretooluse.mjs",[Vt.POST_TOOL_USE]:"posttooluse.mjs",[Vt.PRE_COMPACT]:"precompact.mjs",[Vt.SESSION_START]:"sessionstart.mjs"},Xq=[Vt.PRE_TOOL_USE,Vt.SESSION_START],Qq=[Vt.POST_TOOL_USE,Vt.PRE_COMPACT]});var nb={};Le(nb,{JetBrainsCopilotAdapter:()=>Yd});import{readFileSync as UC}from"node:fs";import{resolve as HC}from"node:path";var Yd,ob=S(()=>{"use strict";qd();rb();Yd=class extends Yo{constructor(){super([".config","JetBrains"])}name="JetBrains Copilot";hookModule={HOOK_TYPES:Vt,HOOK_SCRIPTS:Jd,buildHookCommand:tb};hookSubdir="jetbrains-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.JETBRAINS_CLIENT_ID?`jetbrains-${process.env.JETBRAINS_CLIENT_ID}`:process.env.IDEA_HOME?`idea-${process.pid}`:`pid-${process.ppid}`}getProjectDir(){return process.env.IDEA_INITIAL_DIRECTORY||process.env.CLAUDE_PROJECT_DIR||process.cwd()}getConfigDir(e){return HC(e??this.getProjectDir(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[];try{let n=UC(this.getSettingsPath(),"utf-8"),s=JSON.parse(n).hooks;s?.[Vt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in .github/hooks/context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"}),s?.[Vt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in .github/hooks/context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"Hook scripts",status:"warn",message:`JetBrains hook wrappers should resolve to ${e}/hooks/jetbrains-copilot/*.mjs`}),r}checkPluginRegistration(){return{check:"MCP registration",status:"warn",message:"JetBrains stores MCP config via Settings UI \u2014 not CLI-inspectable",fix:"Verify in IDE: Settings > Tools > GitHub Copilot > MCP > ensure a context-mode server entry exists"}}getInstalledVersion(){let r=this.readSettings()?.hooks;return r&&Object.keys(r).length>0?"configured":"unknown"}}});function gi(t,e){let r=Xd[e],n=Wt(e);if("command"in t){let s=t.command??"";return r!=null&&s.includes(r)||s.includes(n)}return t.hooks?.some(s=>{let i=s.command??"";return r!=null&&i.includes(r)||i.includes(n)})??!1}function Wt(t){return`context-mode hook cursor ${t.toLowerCase()}`}var _e,Xd,ZC,BC,Qd,sb,ib,ab=S(()=>{"use strict";_e={PRE_TOOL_USE:"preToolUse",POST_TOOL_USE:"postToolUse",SESSION_START:"sessionStart",STOP:"stop",AFTER_AGENT_RESPONSE:"afterAgentResponse"},Xd={[_e.PRE_TOOL_USE]:"pretooluse.mjs",[_e.POST_TOOL_USE]:"posttooluse.mjs",[_e.SESSION_START]:"sessionstart.mjs",[_e.STOP]:"stop.mjs",[_e.AFTER_AGENT_RESPONSE]:"afteragentresponse.mjs"},ZC="MCP:(?!ctx_)",BC=["Shell","Read","Grep","WebFetch","mcp_web_fetch","mcp_fetch_tool","Task","MCP:ctx_execute","MCP:ctx_execute_file","MCP:ctx_batch_execute",ZC],Qd=BC.join("|"),sb=[_e.PRE_TOOL_USE],ib=[_e.POST_TOOL_USE]});var pb={};Le(pb,{CursorAdapter:()=>ep});import{readFileSync as fc,writeFileSync as qC,mkdirSync as VC,accessSync as cb,chmodSync as WC,constants as ub,existsSync as lb,readdirSync as GC}from"node:fs";import{execSync as KC}from"node:child_process";import{resolve as Yn,join as Xn}from"node:path";import{homedir as hc}from"node:os";var db,ep,mb=S(()=>{"use strict";yt();hn();ab();db="/Library/Application Support/Cursor/hooks.json",ep=class extends Se{constructor(){super([".cursor"])}name="Cursor";paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!1,sessionStart:!0,canModifyArgs:!0,canModifyOutput:!1,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parsePostToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:r.tool_output??r.error_message,isError:!!r.error_message,sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parseSessionStartInput(e){let r=e,n=r.source??r.trigger??"startup",o;switch(n){case"compact":o="compact";break;case"resume":o="resume";break;case"clear":o="clear";break;default:o="startup"}return{sessionId:this.extractSessionId(r),source:o,projectDir:this.getProjectDir(r),raw:e}}formatPreToolUseResponse(e){return e.decision==="deny"?{permission:"deny",user_message:e.reason??"Blocked by context-mode hook"}:e.decision==="modify"&&e.updatedInput?{updated_input:e.updatedInput}:e.decision==="context"&&e.additionalContext?{agent_message:e.additionalContext}:e.decision==="ask"?{permission:"ask",user_message:e.reason??"Action requires user confirmation (security policy)"}:{agent_message:""}}formatPostToolUseResponse(e){return{additional_context:e.additionalContext??""}}formatSessionStartResponse(e){return{additional_context:e.context??""}}parseStopInput(e){let r=e;return{sessionId:r.conversation_id??`pid-${process.ppid}`,status:r.status??"completed",loopCount:r.loop_count??0,generationId:r.generation_id,transcriptPath:r.transcript_path??void 0}}formatStopResponse(e){return e.followupMessage?{followup_message:e.followupMessage}:{}}parseAfterAgentResponseInput(e){return{text:e.text??""}}getSettingsPath(){return Yn(".cursor","hooks.json")}getConfigDir(e){return Yn(e??process.cwd(),".cursor")}getInstructionFiles(){return["context-mode.mdc"]}generateHookConfig(e){return{[_e.PRE_TOOL_USE]:[{type:"command",command:Wt(_e.PRE_TOOL_USE),matcher:Qd,loop_limit:null,failClosed:!1}],[_e.POST_TOOL_USE]:[{type:"command",command:Wt(_e.POST_TOOL_USE),loop_limit:null,failClosed:!1}],[_e.SESSION_START]:[{type:"command",command:Wt(_e.SESSION_START),loop_limit:null,failClosed:!1}],[_e.STOP]:[{type:"command",command:Wt(_e.STOP),loop_limit:null,failClosed:!1}],[_e.AFTER_AGENT_RESPONSE]:[{type:"command",command:Wt(_e.AFTER_AGENT_RESPONSE),loop_limit:null,failClosed:!1}]}}readSettings(){for(let e of this.getCandidateHookConfigPaths())try{let r=fc(e,"utf-8");return JSON.parse(r)}catch{continue}return null}writeSettings(e){let r=this.getSettingsPath();VC(Yn(".cursor"),{recursive:!0}),qC(r,JSON.stringify(e,null,2)+`
|
|
142
|
+
`,"utf-8")}configureAllHooks(e){let r=[],n=this.readSettings()??{},o=n.hooks??{},{HOOK_TYPES:s,HOOK_SCRIPTS:i,buildHookCommand:a}=this.hookModule,c=[s.PRE_TOOL_USE,s.POST_TOOL_USE,s.PRE_COMPACT,s.SESSION_START];for(let u of c)i[u]&&(o[u]=[{matcher:"",hooks:[{type:"command",command:a(u,e)}]}],r.push(`Configured ${u} hook`));return n.hooks=o,this.writeSettings(n),r.push(`Wrote hook config to ${this.getSettingsPath()}`),r}setHookPermissions(e){let r=[],n=jC(e,"hooks",this.hookSubdir);for(let o of Object.values(this.hookModule.HOOK_SCRIPTS)){let s=mc(n,o);try{NC(s,MC.R_OK),DC(s,493),r.push(s)}catch{}}return r}updatePluginRegistry(e,r){}}});function Jv(t,e){if(!Vd[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook vscode-copilot ${t.toLowerCase()}`}var qt,Vd,Zq,Bq,Yv=S(()=>{"use strict";qt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart"},Vd={[qt.PRE_TOOL_USE]:"pretooluse.mjs",[qt.POST_TOOL_USE]:"posttooluse.mjs",[qt.PRE_COMPACT]:"precompact.mjs",[qt.SESSION_START]:"sessionstart.mjs"},Zq=[qt.PRE_TOOL_USE,qt.SESSION_START],Bq=[qt.POST_TOOL_USE,qt.PRE_COMPACT]});var Qv={};Le(Qv,{VSCodeCopilotAdapter:()=>Kd});import{readFileSync as Wd,mkdirSync as Xv,accessSync as zC,existsSync as LC,constants as FC}from"node:fs";import{resolve as Xo,join as hi}from"node:path";import{homedir as Gd}from"node:os";var Kd,eb=S(()=>{"use strict";qd();yt();Yv();Kd=class extends Yo{constructor(){super([".vscode"])}name="VS Code Copilot";hookModule={HOOK_TYPES:qt,HOOK_SCRIPTS:Vd,buildHookCommand:Jv};hookSubdir="vscode-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.VSCODE_PID?`vscode-${process.env.VSCODE_PID}`:`pid-${process.ppid}`}getProjectDir(){return process.env.CLAUDE_PROJECT_DIR||process.env.VSCODE_CWD||process.cwd()}getSessionDir(){let e=lr();if(e){let s=hi(e,"context-mode","sessions");return Xv(s,{recursive:!0}),s}let r=Xo(".github","context-mode","sessions"),n=hi(Gd(),".vscode","context-mode","sessions"),o=LC(Xo(".github"))?r:n;return Xv(o,{recursive:!0}),o}getConfigDir(e){return Xo(e??process.cwd(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[],n=Xo(".github","hooks");try{zC(n,FC.R_OK)}catch{return r.push({check:"Hooks directory",status:"fail",message:".github/hooks/ directory not found",fix:"context-mode upgrade"}),r}let o=Xo(n,"context-mode.json");try{let s=Wd(o,"utf-8"),a=JSON.parse(s).hooks;a?.[qt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in context-mode.json",fix:"context-mode upgrade"}),a?.[qt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"API stability",status:"warn",message:"VS Code Copilot hooks are in preview \u2014 API may change without notice"}),r.push({check:"Matcher support",status:"warn",message:"Matchers are parsed but IGNORED \u2014 all hooks fire on all tools"}),r}checkPluginRegistration(){try{let e=Xo(".vscode","mcp.json"),r=Wd(e,"utf-8"),o=JSON.parse(r).servers;return o&&Object.keys(o).some(i=>i.includes("context-mode"))?{check:"MCP registration",status:"pass",message:"context-mode found in .vscode/mcp.json"}:{check:"MCP registration",status:"fail",message:"context-mode not found in .vscode/mcp.json",fix:"Add context-mode server to .vscode/mcp.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read .vscode/mcp.json"}}}getInstalledVersion(){let e=[hi(Gd(),".vscode","extensions"),hi(Gd(),".vscode-insiders","extensions")];for(let r of e)try{let n=Wd(hi(r,"extensions.json"),"utf-8"),s=JSON.parse(n).find(i=>typeof i.identifier=="object"&&i.identifier!==null&&i.identifier.id?.toString().includes("context-mode"));if(s&&typeof s.version=="string")return s.version}catch{continue}return"not installed"}}});function tb(t,e){if(!Jd[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook jetbrains-copilot ${t.toLowerCase()}`}var Vt,Jd,Xq,Qq,rb=S(()=>{"use strict";Vt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart",STOP:"Stop",SUBAGENT_START:"SubagentStart",SUBAGENT_STOP:"SubagentStop"},Jd={[Vt.PRE_TOOL_USE]:"pretooluse.mjs",[Vt.POST_TOOL_USE]:"posttooluse.mjs",[Vt.PRE_COMPACT]:"precompact.mjs",[Vt.SESSION_START]:"sessionstart.mjs"},Xq=[Vt.PRE_TOOL_USE,Vt.SESSION_START],Qq=[Vt.POST_TOOL_USE,Vt.PRE_COMPACT]});var nb={};Le(nb,{JetBrainsCopilotAdapter:()=>Yd});import{readFileSync as UC}from"node:fs";import{resolve as HC}from"node:path";var Yd,ob=S(()=>{"use strict";qd();rb();Yd=class extends Yo{constructor(){super([".config","JetBrains"])}name="JetBrains Copilot";hookModule={HOOK_TYPES:Vt,HOOK_SCRIPTS:Jd,buildHookCommand:tb};hookSubdir="jetbrains-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.JETBRAINS_CLIENT_ID?`jetbrains-${process.env.JETBRAINS_CLIENT_ID}`:process.env.IDEA_HOME?`idea-${process.pid}`:`pid-${process.ppid}`}getProjectDir(){return process.env.IDEA_INITIAL_DIRECTORY||process.env.CLAUDE_PROJECT_DIR||process.cwd()}getConfigDir(e){return HC(e??this.getProjectDir(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[];try{let n=UC(this.getSettingsPath(),"utf-8"),s=JSON.parse(n).hooks;s?.[Vt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in .github/hooks/context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"}),s?.[Vt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in .github/hooks/context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"Hook scripts",status:"warn",message:`JetBrains hook wrappers should resolve to ${e}/hooks/jetbrains-copilot/*.mjs`}),r}checkPluginRegistration(){return{check:"MCP registration",status:"warn",message:"JetBrains stores MCP config via Settings UI \u2014 not CLI-inspectable",fix:"Verify in IDE: Settings > Tools > GitHub Copilot > MCP > ensure a context-mode server entry exists"}}getInstalledVersion(){let r=this.readSettings()?.hooks;return r&&Object.keys(r).length>0?"configured":"unknown"}}});function gi(t,e){let r=Xd[e],n=Wt(e);if("command"in t){let s=t.command??"";return r!=null&&s.includes(r)||s.includes(n)}return t.hooks?.some(s=>{let i=s.command??"";return r!=null&&i.includes(r)||i.includes(n)})??!1}function Wt(t){return`context-mode hook cursor ${t.toLowerCase()}`}var _e,Xd,ZC,BC,Qd,sb,ib,ab=S(()=>{"use strict";_e={PRE_TOOL_USE:"preToolUse",POST_TOOL_USE:"postToolUse",SESSION_START:"sessionStart",STOP:"stop",AFTER_AGENT_RESPONSE:"afterAgentResponse"},Xd={[_e.PRE_TOOL_USE]:"pretooluse.mjs",[_e.POST_TOOL_USE]:"posttooluse.mjs",[_e.SESSION_START]:"sessionstart.mjs",[_e.STOP]:"stop.mjs",[_e.AFTER_AGENT_RESPONSE]:"afteragentresponse.mjs"},ZC="MCP:(?!ctx_)",BC=["Shell","Read","Grep","WebFetch","mcp_web_fetch","mcp_fetch_tool","Task","MCP:ctx_execute","MCP:ctx_execute_file","MCP:ctx_batch_execute",ZC],Qd=BC.join("|"),sb=[_e.PRE_TOOL_USE],ib=[_e.POST_TOOL_USE]});var pb={};Le(pb,{CursorAdapter:()=>ep});import{readFileSync as fc,writeFileSync as qC,mkdirSync as VC,accessSync as cb,chmodSync as WC,constants as ub,existsSync as lb,readdirSync as GC}from"node:fs";import{execSync as KC}from"node:child_process";import{resolve as Yn,join as Xn}from"node:path";import{homedir as hc}from"node:os";var db,ep,mb=S(()=>{"use strict";yt();hn();ab();db="/Library/Application Support/Cursor/hooks.json",ep=class extends Se{constructor(){super([".cursor"])}name="Cursor";paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!1,sessionStart:!0,canModifyArgs:!0,canModifyOutput:!1,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parsePostToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:r.tool_output??r.error_message,isError:!!r.error_message,sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parseSessionStartInput(e){let r=e,n=r.source??r.trigger??"startup",o;switch(n){case"compact":o="compact";break;case"resume":o="resume";break;case"clear":o="clear";break;default:o="startup"}return{sessionId:this.extractSessionId(r),source:o,projectDir:this.getProjectDir(r),raw:e}}formatPreToolUseResponse(e){return e.decision==="deny"?{permission:"deny",user_message:e.reason??"Blocked by context-mode hook"}:e.decision==="modify"&&e.updatedInput?{updated_input:e.updatedInput}:e.decision==="context"&&e.additionalContext?{agent_message:e.additionalContext}:e.decision==="ask"?{permission:"ask",user_message:e.reason??"Action requires user confirmation (security policy)"}:{agent_message:""}}formatPostToolUseResponse(e){return{additional_context:e.additionalContext??""}}formatSessionStartResponse(e){return{additional_context:e.context??""}}parseStopInput(e){let r=e;return{sessionId:r.conversation_id??`pid-${process.ppid}`,status:r.status??"completed",loopCount:r.loop_count??0,generationId:r.generation_id,transcriptPath:r.transcript_path??void 0}}formatStopResponse(e){return e.followupMessage?{followup_message:e.followupMessage}:{}}parseAfterAgentResponseInput(e){return{text:e.text??""}}getSettingsPath(){return Yn(".cursor","hooks.json")}getConfigDir(e){return Yn(e??process.cwd(),".cursor")}getInstructionFiles(){return["context-mode.mdc"]}generateHookConfig(e){return{[_e.PRE_TOOL_USE]:[{type:"command",command:Wt(_e.PRE_TOOL_USE),matcher:Qd,loop_limit:null,failClosed:!1}],[_e.POST_TOOL_USE]:[{type:"command",command:Wt(_e.POST_TOOL_USE),loop_limit:null,failClosed:!1}],[_e.SESSION_START]:[{type:"command",command:Wt(_e.SESSION_START),loop_limit:null,failClosed:!1}],[_e.STOP]:[{type:"command",command:Wt(_e.STOP),loop_limit:null,failClosed:!1}],[_e.AFTER_AGENT_RESPONSE]:[{type:"command",command:Wt(_e.AFTER_AGENT_RESPONSE),loop_limit:null,failClosed:!1}]}}readSettings(){for(let e of this.getCandidateHookConfigPaths())try{let r=fc(e,"utf-8");return JSON.parse(r)}catch{continue}return null}writeSettings(e){let r=this.getSettingsPath();VC(Yn(".cursor"),{recursive:!0}),qC(r,JSON.stringify(e,null,2)+`
|
|
143
143
|
`,"utf-8")}validateHooks(e){let r=[],n=this.loadNativeHookConfig();if(!n)r.push({check:"Native hook config",status:"fail",message:"No readable native Cursor hook config found in .cursor/hooks.json or ~/.cursor/hooks.json",fix:"context-mode upgrade"});else{let s=n.config.hooks??{};r.push({check:"Native hook config",status:"pass",message:`Loaded ${n.path}`});for(let i of sb){let a=s[i],c=Array.isArray(a)&&a.some(u=>gi(u,i));r.push({check:i,status:c?"pass":"fail",message:c?`${i} hook configured`:`${i} hook not configured in ${n.path}`,fix:c?void 0:"context-mode upgrade"})}for(let i of ib){let a=s[i],c=Array.isArray(a)&&a.some(u=>gi(u,i));r.push({check:i,status:c?"pass":"warn",message:c?`${i} hook configured`:`${i} hook missing \u2014 session event capture will be reduced`})}}lb(db)&&r.push({check:"Enterprise hook config",status:"warn",message:"Enterprise Cursor hook config detected at /Library/Application Support/Cursor/hooks.json (read-only informational layer)"}),this.hasClaudeCompatibilityHooks()&&r.push({check:"Claude compatibility",status:"warn",message:"Claude-compatible hooks detected; native Cursor hooks are the supported configuration"});let o=this.detectPluginInstalls();return o.length>0&&((n?Object.entries(n.config.hooks??{}).some(([i,a])=>Array.isArray(a)&&a.some(c=>gi(c,i))):!1)&&n?r.push({check:"Plugin/native hook duplication",status:"warn",message:`context-mode plugin detected at ${o[0]} alongside native hooks in ${n.path} \u2014 each event will fire twice. Remove one configuration to avoid duplicate routing.`,fix:"Remove the native .cursor/hooks.json entries OR uninstall the plugin"}):r.push({check:"Plugin install",status:"pass",message:`context-mode plugin installed at ${o[0]}`})),r}detectPluginInstalls(){let e=[Xn(hc(),".cursor","plugins","local"),Xn(hc(),".cursor","plugins","cache")],r=[];for(let n of e){try{cb(n,ub.F_OK)}catch{continue}let o=[];try{o=GC(n)}catch{continue}for(let s of o){let i=Xn(n,s,".cursor-plugin","plugin.json");try{let a=fc(i,"utf-8");JSON.parse(a)?.name==="context-mode"&&r.push(i)}catch{continue}}}return r}checkPluginRegistration(){let e=[Yn(".cursor","mcp.json"),Xn(hc(),".cursor","mcp.json")];for(let n of e)try{let o=fc(n,"utf-8"),s=JSON.parse(o),i=s.mcpServers??s.servers;if(!i)continue;if(Object.entries(i).some(([c,u])=>c.includes("context-mode")?!0:!u||typeof u!="object"?!1:u.command==="context-mode"))return{check:"MCP registration",status:"pass",message:`context-mode found in ${n}`}}catch{continue}let r=this.detectPluginInstalls();return r.length>0?{check:"MCP registration",status:"pass",message:`context-mode registered via plugin manifest at ${r[0]}`}:{check:"MCP registration",status:"warn",message:"Could not find context-mode in .cursor/mcp.json or ~/.cursor/mcp.json"}}getInstalledVersion(){try{return KC("cursor --version",{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim().split(/\r?\n/)[0]||"unknown"}catch{return"not installed"}}configureAllHooks(e){let r=this.readSettings()??{version:1,hooks:{}},n=r.hooks??{},o=[];return this.upsertHookEntry(n,_e.PRE_TOOL_USE,{type:"command",command:Wt(_e.PRE_TOOL_USE),matcher:Qd,loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,_e.POST_TOOL_USE,{type:"command",command:Wt(_e.POST_TOOL_USE),loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,_e.SESSION_START,{type:"command",command:Wt(_e.SESSION_START),loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,_e.STOP,{type:"command",command:Wt(_e.STOP),loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,_e.AFTER_AGENT_RESPONSE,{type:"command",command:Wt(_e.AFTER_AGENT_RESPONSE),loop_limit:null,failClosed:!1},o),r.version=1,r.hooks=n,this.writeSettings(r),o.push(`Wrote native Cursor hooks to ${this.getSettingsPath()}`),o}setHookPermissions(e){let r=[],n=Xn(e,"hooks","cursor");for(let o of Object.values(Xd)){let s=Yn(n,o);try{cb(s,ub.R_OK),WC(s,493),r.push(s)}catch{}}return r}updatePluginRegistry(e,r){}getCandidateHookConfigPaths(){let e=[this.getSettingsPath(),Xn(hc(),".cursor","hooks.json")];return process.platform==="darwin"&&e.push(db),e}getProjectDir(e){return e.cwd||e.workspace_roots?.[0]||process.env.CURSOR_CWD||process.cwd()}extractSessionId(e){return e.conversation_id?e.conversation_id:e.session_id?e.session_id:process.env.CURSOR_SESSION_ID?process.env.CURSOR_SESSION_ID:process.env.CURSOR_TRACE_ID?process.env.CURSOR_TRACE_ID:`pid-${process.ppid}`}loadNativeHookConfig(){for(let e of this.getCandidateHookConfigPaths())try{let r=fc(e,"utf-8"),n=JSON.parse(r);if(n&&typeof n=="object")return{path:e,config:n}}catch{continue}return null}hasClaudeCompatibilityHooks(){return[Yn(".claude","settings.json"),Yn(".claude","settings.local.json"),Xn(qe(),"settings.json")].some(r=>lb(r))}upsertHookEntry(e,r,n,o){let s=e[r],i=Array.isArray(s)?[...s]:[],a=i.findIndex(c=>gi(c,r));a>=0?(i[a]=n,o.push(`Updated existing ${r} hook entry`)):(i.push(n),o.push(`Added ${r} hook entry`)),e[r]=i}}});var hb={};Le(hb,{AntigravityAdapter:()=>rp});import{readFileSync as gc,writeFileSync as JC,mkdirSync as YC}from"node:fs";import{resolve as yc,dirname as fb}from"node:path";import{fileURLToPath as XC}from"node:url";import{homedir as tp}from"node:os";var rp,gb=S(()=>{"use strict";yt();rp=class extends Se{constructor(){super([".gemini"])}name="Antigravity";paradigm="mcp-only";capabilities={preToolUse:!1,postToolUse:!1,preCompact:!1,sessionStart:!1,canModifyArgs:!1,canModifyOutput:!1,canInjectSessionContext:!1};parsePreToolUseInput(e){throw new Error("Antigravity does not support hooks")}parsePostToolUseInput(e){throw new Error("Antigravity does not support hooks")}parsePreCompactInput(e){throw new Error("Antigravity does not support hooks")}parseSessionStartInput(e){throw new Error("Antigravity does not support hooks")}formatPreToolUseResponse(e){}formatPostToolUseResponse(e){}formatPreCompactResponse(e){}formatSessionStartResponse(e){}getSettingsPath(){return yc(tp(),".gemini","antigravity","mcp_config.json")}getConfigDir(e){return yc(tp(),".gemini","antigravity")}getInstructionFiles(){return["GEMINI.md"]}generateHookConfig(e){return{}}readSettings(){try{let e=gc(this.getSettingsPath(),"utf-8");return JSON.parse(e)}catch{return null}}writeSettings(e){let r=this.getSettingsPath();YC(fb(r),{recursive:!0}),JC(r,JSON.stringify(e,null,2),"utf-8")}validateHooks(e){return[{check:"Hook support",status:"warn",message:"Antigravity does not support hooks. Only MCP integration is available."}]}checkPluginRegistration(){try{let e=gc(this.getSettingsPath(),"utf-8");return"context-mode"in(JSON.parse(e)?.mcpServers??{})?{check:"MCP registration",status:"pass",message:"context-mode found in mcpServers config"}:{check:"MCP registration",status:"fail",message:"context-mode not found in mcpServers",fix:"Add context-mode to mcpServers in ~/.gemini/antigravity/mcp_config.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read ~/.gemini/antigravity/mcp_config.json"}}}getInstalledVersion(){try{let e=yc(tp(),".gemini","extensions","context-mode","package.json");return JSON.parse(gc(e,"utf-8")).version??"unknown"}catch{return"not installed"}}configureAllHooks(e){return[]}setHookPermissions(e){return[]}updatePluginRegistry(e,r){}getRoutingInstructions(){let e=yc(fb(XC(import.meta.url)),"..","..","..","configs","antigravity","GEMINI.md");try{return gc(e,"utf-8")}catch{return`# context-mode
|
|
144
144
|
|
|
145
145
|
Use context-mode MCP tools (execute, execute_file, batch_execute, fetch_and_index, search) instead of run_command/view_file for data-heavy operations.`}}}});function _c(t,e){let r=yb[e];return r&&(t.command?.includes(r)||t.command?.includes("context-mode hook kiro"))||!1}function Qo(t,e){let r=yb[t];return e&&r?Fe(`${e}/hooks/kiro/${r}`):`context-mode hook kiro ${t.toLowerCase()}`}var Ue,yb,QC,eO,np,b4,x4,_b=S(()=>{"use strict";cn();Ue={PRE_TOOL_USE:"preToolUse",POST_TOOL_USE:"postToolUse",AGENT_SPAWN:"agentSpawn",USER_PROMPT_SUBMIT:"userPromptSubmit"},yb={[Ue.PRE_TOOL_USE]:"pretooluse.mjs",[Ue.POST_TOOL_USE]:"posttooluse.mjs",[Ue.USER_PROMPT_SUBMIT]:"userpromptsubmit.mjs",[Ue.AGENT_SPAWN]:"agentspawn.mjs"},QC="@(?!context-mode/)",eO=["execute_bash","fs_read","@context-mode/ctx_execute","@context-mode/ctx_execute_file","@context-mode/ctx_batch_execute",QC],np=eO.join("|"),b4=[Ue.PRE_TOOL_USE,Ue.AGENT_SPAWN],x4=[Ue.POST_TOOL_USE,Ue.USER_PROMPT_SUBMIT]});var Sb={};Le(Sb,{KiroAdapter:()=>op});import{readFileSync as es,writeFileSync as vb,mkdirSync as bb}from"node:fs";import{resolve as Qn,dirname as xb}from"node:path";import{fileURLToPath as tO}from"node:url";import{homedir as vc}from"node:os";var op,kb=S(()=>{"use strict";yt();_b();op=class extends Se{constructor(){super([".kiro"])}name="Kiro";paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!1,sessionStart:!0,canModifyArgs:!1,canModifyOutput:!1,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:`pid-${process.ppid}`,projectDir:r.cwd??process.cwd(),raw:e}}parsePostToolUseInput(e){let r=e,n=r.tool_response;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:typeof n=="string"?n:JSON.stringify(n??""),sessionId:`pid-${process.ppid}`,projectDir:r.cwd??process.cwd(),raw:e}}parsePreCompactInput(e){throw new Error("Kiro does not support PreCompact hooks")}parseSessionStartInput(e){let r=e??{};return{source:r.source??"startup",sessionId:`pid-${process.ppid}`,projectDir:r.cwd??process.cwd(),raw:e}}formatPreToolUseResponse(e){switch(e.decision){case"deny":return{exitCode:2,stderr:e.reason??"Blocked by context-mode"};case"context":return{exitCode:0,stdout:e.additionalContext??""};default:return}}formatPostToolUseResponse(e){}formatPreCompactResponse(e){}formatSessionStartResponse(e){if(e?.context)return{hookSpecificOutput:{hookEventName:"agentSpawn",additionalContext:e.context}}}getSettingsPath(){return Qn(vc(),".kiro","settings","mcp.json")}getConfigDir(e){return Qn(e??process.cwd(),".kiro")}getInstructionFiles(){return["KIRO.md"]}generateHookConfig(e){return{[Ue.PRE_TOOL_USE]:[{matcher:np,hooks:[{type:"command",command:Qo(Ue.PRE_TOOL_USE,e)}]}],[Ue.POST_TOOL_USE]:[{matcher:"*",hooks:[{type:"command",command:Qo(Ue.POST_TOOL_USE,e)}]}],[Ue.AGENT_SPAWN]:[{matcher:"*",hooks:[{type:"command",command:Qo(Ue.AGENT_SPAWN,e)}]}],[Ue.USER_PROMPT_SUBMIT]:[{matcher:"*",hooks:[{type:"command",command:Qo(Ue.USER_PROMPT_SUBMIT,e)}]}]}}readSettings(){try{let e=es(this.getSettingsPath(),"utf-8");return JSON.parse(e)}catch{return null}}writeSettings(e){let r=this.getSettingsPath();bb(xb(r),{recursive:!0}),vb(r,JSON.stringify(e,null,2),"utf-8")}validateHooks(e){let r=[],n=Qn(vc(),".kiro","agents","default.json");try{let s=JSON.parse(es(n,"utf-8")).hooks??{};for(let i of[Ue.PRE_TOOL_USE]){let c=(s[i]??[]).some(u=>_c(u,i));r.push({check:`Hook: ${i}`,status:c?"pass":"fail",message:c?`context-mode ${i} hook found`:`context-mode ${i} hook not configured`,...c?{}:{fix:"Run: context-mode upgrade"}})}for(let i of[Ue.POST_TOOL_USE]){let c=(s[i]??[]).some(u=>_c(u,i));r.push({check:`Hook: ${i}`,status:c?"pass":"warn",message:c?`context-mode ${i} hook found`:`context-mode ${i} hook not configured (optional)`})}}catch{r.push({check:"Hook configuration",status:"warn",message:"Could not read ~/.kiro/agents/default.json",fix:"Run: context-mode upgrade"})}return r}checkPluginRegistration(){try{let e=es(this.getSettingsPath(),"utf-8");return"context-mode"in(JSON.parse(e)?.mcpServers??{})?{check:"MCP registration",status:"pass",message:"context-mode found in mcpServers config"}:{check:"MCP registration",status:"fail",message:"context-mode not found in mcpServers",fix:"Add context-mode to mcpServers in ~/.kiro/settings/mcp.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read ~/.kiro/settings/mcp.json"}}}getInstalledVersion(){try{let e=Qn(vc(),".kiro","extensions","context-mode","package.json");return JSON.parse(es(e,"utf-8")).version??"unknown"}catch{return"not installed"}}configureAllHooks(e){let r=[],n=Qn(vc(),".kiro","agents"),o=Qn(n,"default.json");try{bb(n,{recursive:!0});let s={};try{s=JSON.parse(es(o,"utf-8"))}catch{}let i=s.hooks??{},a=[[Ue.PRE_TOOL_USE,np],[Ue.POST_TOOL_USE,"*"],[Ue.AGENT_SPAWN,"*"],[Ue.USER_PROMPT_SUBMIT,"*"]];for(let[c,u]of a){let d=i[c]??[];d.some(l=>_c(l,c))||(d.push({matcher:u,command:Qo(c,e)}),i[c]=d,r.push(`Added ${c} hook to ${o}`))}s.hooks=i,vb(o,JSON.stringify(s,null,2),"utf-8")}catch(s){r.push(`Failed to configure hooks: ${s.message}`)}return r}setHookPermissions(e){return[]}updatePluginRegistry(e,r){}getRoutingInstructions(){let e=Qn(xb(tO(import.meta.url)),"..","..","..","configs","kiro","KIRO.md");try{return es(e,"utf-8")}catch{return`# context-mode
|
package/openclaw.plugin.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "Context Mode",
|
|
4
4
|
"kind": "tool",
|
|
5
5
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.151",
|
|
7
7
|
"sandbox": {
|
|
8
8
|
"mode": "permissive",
|
|
9
9
|
"filesystem_access": "full",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.151",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP plugin that saves 98% of your context window. Works with Claude Code, Gemini CLI, VS Code Copilot, OpenCode, and Codex CLI. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
|
|
6
6
|
"author": "Mert Koseoğlu",
|
package/server.bundle.mjs
CHANGED
|
@@ -145,7 +145,7 @@ var nw=Object.create;var wu=Object.defineProperty;var ow=Object.getOwnPropertyDe
|
|
|
145
145
|
|
|
146
146
|
Use context-mode MCP tools (execute, execute_file, batch_execute, fetch_and_index, search) instead of bash/cat/curl for data-heavy operations.`}}getProjectDir(e){return e.cwd??process.env.CODEX_PROJECT_DIR??process.cwd()}getHooksPath(){return Xn(this.getConfigDir(),"hooks.json")}backupFile(e,r=""){let n=r?`${e}${r}-${new Date().toISOString().replace(/[:.]/g,"-")}.bak`:`${e}.bak`;return LM(e,n),n}readHooksConfig(){let e=this.getHooksPath();try{return{ok:!0,config:JSON.parse(Qo(e,"utf-8"))}}catch(r){let n=r instanceof Error?r.message:String(r);return(typeof r=="object"&&r!==null&&"code"in r?String(r.code??""):"")==="ENOENT"?{ok:!1,reason:"missing"}:r instanceof SyntaxError?{ok:!1,reason:"invalid_json",error:n}:{ok:!1,reason:"read_error",error:n}}}writeHooksConfig(e){let r=this.getHooksPath();Hm(Fm(r),{recursive:!0}),rk(r,JSON.stringify(e,null,2)+`
|
|
147
147
|
`,"utf-8")}upsertManagedHookEntry(e,r,n,o){let s=Array.isArray(e[r])?[...e[r]]:[],i=s.map((c,u)=>this.isManagedContextModeEntry(r,c)?u:-1).filter(c=>c>=0);if(i.length===0){s.push(n),e[r]=s,o.push(`Added ${r} hook`);return}let a=i[0];JSON.stringify(s[a])!==JSON.stringify(n)&&(s[a]=n,o.push(`Updated ${r} hook`));for(let c of i.slice(1).reverse())s.splice(c,1),o.push(`Removed duplicate ${r} context-mode hook`);e[r]=s}isExpectedHookEntry(e,r,n){return!r||typeof r!="object"||e==="PreToolUse"&&r.matcher!==n.matcher?!1:this.entryContainsManagedCommand(e,r)}isManagedContextModeEntry(e,r){return!r||typeof r!="object"?!1:this.entryContainsManagedCommand(e,r)}entryContainsManagedCommand(e,r){let n=(Array.isArray(r.hooks)?r.hooks:[]).map(i=>this.normalizeCommand(i.command)).filter(i=>i.length>0),o=this.normalizeCommand(Yn[e]??""),s=qM[e]??[];return n.some(i=>i.includes(o)||s.some(a=>i.includes(a)))}normalizeCommand(e){return(e??"").replace(/\\/g,"/")}extractSessionId(e){return e.session_id?e.session_id:`pid-${process.ppid}`}}});import{readFileSync as ck,writeFileSync as WM,mkdirSync as KM,accessSync as GM,chmodSync as JM,constants as XM}from"node:fs";import{resolve as qc,join as YM}from"node:path";var es,qm=ce(()=>{"use strict";ut();es=class extends xe{paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!0,sessionStart:!0,canModifyArgs:!0,canModifyOutput:!0,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(),raw:e}}parsePostToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:r.tool_output,isError:r.is_error,sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(),raw:e}}parsePreCompactInput(e){let r=e;return{sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(),raw:e}}parseSessionStartInput(e){let r=e,n=r.source??"startup",o;switch(n){case"compact":o="compact";break;case"resume":o="resume";break;case"clear":o="clear";break;default:o="startup"}return{sessionId:this.extractSessionId(r),source:o,projectDir:this.getProjectDir(),raw:e}}formatPreToolUseResponse(e){if(e.decision==="deny")return{permissionDecision:"deny",reason:e.reason??"Blocked by context-mode hook"};if(e.decision==="modify"&&e.updatedInput)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.PRE_TOOL_USE,updatedInput:e.updatedInput}};if(e.decision==="context"&&e.additionalContext)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.PRE_TOOL_USE,additionalContext:e.additionalContext}};if(e.decision==="ask")return{permissionDecision:"deny",reason:e.reason??"Action requires user confirmation (security policy)"}}formatPostToolUseResponse(e){if(e.updatedOutput)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.POST_TOOL_USE,decision:"block",reason:e.updatedOutput}};if(e.additionalContext)return{hookSpecificOutput:{hookEventName:this.hookModule.HOOK_TYPES.POST_TOOL_USE,additionalContext:e.additionalContext}}}formatPreCompactResponse(e){return e.context??""}formatSessionStartResponse(e){return e.context??""}getSettingsPath(e){return qc(e??process.cwd(),".github","hooks","context-mode.json")}generateHookConfig(e){let{HOOK_TYPES:r,buildHookCommand:n}=this.hookModule;return{[r.PRE_TOOL_USE]:[{matcher:"",hooks:[{type:"command",command:n(r.PRE_TOOL_USE,e)}]}],[r.POST_TOOL_USE]:[{matcher:"",hooks:[{type:"command",command:n(r.POST_TOOL_USE,e)}]}],[r.PRE_COMPACT]:[{matcher:"",hooks:[{type:"command",command:n(r.PRE_COMPACT,e)}]}],[r.SESSION_START]:[{matcher:"",hooks:[{type:"command",command:n(r.SESSION_START,e)}]}]}}readSettings(){try{let e=ck(this.getSettingsPath(),"utf-8");return JSON.parse(e)}catch{}try{let e=ck(qc(".claude","settings.json"),"utf-8");return JSON.parse(e)}catch{return null}}writeSettings(e){let r=this.getSettingsPath();KM(qc(".github","hooks"),{recursive:!0}),WM(r,JSON.stringify(e,null,2)+`
|
|
148
|
-
`,"utf-8")}configureAllHooks(e){let r=[],n=this.readSettings()??{},o=n.hooks??{},{HOOK_TYPES:s,HOOK_SCRIPTS:i,buildHookCommand:a}=this.hookModule,c=[s.PRE_TOOL_USE,s.POST_TOOL_USE,s.PRE_COMPACT,s.SESSION_START];for(let u of c)i[u]&&(o[u]=[{matcher:"",hooks:[{type:"command",command:a(u,e)}]}],r.push(`Configured ${u} hook`));return n.hooks=o,this.writeSettings(n),r.push(`Wrote hook config to ${this.getSettingsPath()}`),r}setHookPermissions(e){let r=[],n=YM(e,"hooks",this.hookSubdir);for(let o of Object.values(this.hookModule.HOOK_SCRIPTS)){let s=qc(n,o);try{GM(s,XM.R_OK),JM(s,493),r.push(s)}catch{}}return r}updatePluginRegistry(e,r){}}});function uk(t,e){if(!Bm[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook vscode-copilot ${t.toLowerCase()}`}var zt,Bm,R4,P4,lk=ce(()=>{"use strict";zt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart"},Bm={[zt.PRE_TOOL_USE]:"pretooluse.mjs",[zt.POST_TOOL_USE]:"posttooluse.mjs",[zt.PRE_COMPACT]:"precompact.mjs",[zt.SESSION_START]:"sessionstart.mjs"},R4=[zt.PRE_TOOL_USE,zt.SESSION_START],P4=[zt.POST_TOOL_USE,zt.PRE_COMPACT]});var pk={};Fe(pk,{VSCodeCopilotAdapter:()=>Km});import{readFileSync as Vm,mkdirSync as dk,accessSync as QM,existsSync as ej,constants as tj}from"node:fs";import{resolve as ts,join as Ii}from"node:path";import{homedir as Wm}from"node:os";var Km,fk=ce(()=>{"use strict";qm();ut();lk();Km=class extends es{constructor(){super([".vscode"])}name="VS Code Copilot";hookModule={HOOK_TYPES:zt,HOOK_SCRIPTS:Bm,buildHookCommand:uk};hookSubdir="vscode-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.VSCODE_PID?`vscode-${process.env.VSCODE_PID}`:`pid-${process.ppid}`}getProjectDir(){return process.env.CLAUDE_PROJECT_DIR||process.cwd()}getSessionDir(){let e=er();if(e){let s=Ii(e,"context-mode","sessions");return dk(s,{recursive:!0}),s}let r=ts(".github","context-mode","sessions"),n=Ii(Wm(),".vscode","context-mode","sessions"),o=ej(ts(".github"))?r:n;return dk(o,{recursive:!0}),o}getConfigDir(e){return ts(e??process.cwd(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[],n=ts(".github","hooks");try{QM(n,tj.R_OK)}catch{return r.push({check:"Hooks directory",status:"fail",message:".github/hooks/ directory not found",fix:"context-mode upgrade"}),r}let o=ts(n,"context-mode.json");try{let s=Vm(o,"utf-8"),a=JSON.parse(s).hooks;a?.[zt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in context-mode.json",fix:"context-mode upgrade"}),a?.[zt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"API stability",status:"warn",message:"VS Code Copilot hooks are in preview \u2014 API may change without notice"}),r.push({check:"Matcher support",status:"warn",message:"Matchers are parsed but IGNORED \u2014 all hooks fire on all tools"}),r}checkPluginRegistration(){try{let e=ts(".vscode","mcp.json"),r=Vm(e,"utf-8"),o=JSON.parse(r).servers;return o&&Object.keys(o).some(i=>i.includes("context-mode"))?{check:"MCP registration",status:"pass",message:"context-mode found in .vscode/mcp.json"}:{check:"MCP registration",status:"fail",message:"context-mode not found in .vscode/mcp.json",fix:"Add context-mode server to .vscode/mcp.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read .vscode/mcp.json"}}}getInstalledVersion(){let e=[Ii(Wm(),".vscode","extensions"),Ii(Wm(),".vscode-insiders","extensions")];for(let r of e)try{let n=Vm(Ii(r,"extensions.json"),"utf-8"),s=JSON.parse(n).find(i=>typeof i.identifier=="object"&&i.identifier!==null&&i.identifier.id?.toString().includes("context-mode"));if(s&&typeof s.version=="string")return s.version}catch{continue}return"not installed"}}});function mk(t,e){if(!Gm[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook jetbrains-copilot ${t.toLowerCase()}`}var Lt,Gm,M4,j4,hk=ce(()=>{"use strict";Lt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart",STOP:"Stop",SUBAGENT_START:"SubagentStart",SUBAGENT_STOP:"SubagentStop"},Gm={[Lt.PRE_TOOL_USE]:"pretooluse.mjs",[Lt.POST_TOOL_USE]:"posttooluse.mjs",[Lt.PRE_COMPACT]:"precompact.mjs",[Lt.SESSION_START]:"sessionstart.mjs"},M4=[Lt.PRE_TOOL_USE,Lt.SESSION_START],j4=[Lt.POST_TOOL_USE,Lt.PRE_COMPACT]});var gk={};Fe(gk,{JetBrainsCopilotAdapter:()=>Jm});import{readFileSync as rj}from"node:fs";import{resolve as nj}from"node:path";var Jm,yk=ce(()=>{"use strict";qm();hk();Jm=class extends es{constructor(){super([".config","JetBrains"])}name="JetBrains Copilot";hookModule={HOOK_TYPES:Lt,HOOK_SCRIPTS:Gm,buildHookCommand:mk};hookSubdir="jetbrains-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.JETBRAINS_CLIENT_ID?`jetbrains-${process.env.JETBRAINS_CLIENT_ID}`:process.env.IDEA_HOME?`idea-${process.pid}`:`pid-${process.ppid}`}getProjectDir(){return process.env.IDEA_INITIAL_DIRECTORY||process.env.CLAUDE_PROJECT_DIR||process.cwd()}getConfigDir(e){return nj(e??this.getProjectDir(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[];try{let n=rj(this.getSettingsPath(),"utf-8"),s=JSON.parse(n).hooks;s?.[Lt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in .github/hooks/context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"}),s?.[Lt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in .github/hooks/context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"Hook scripts",status:"warn",message:`JetBrains hook wrappers should resolve to ${e}/hooks/jetbrains-copilot/*.mjs`}),r}checkPluginRegistration(){return{check:"MCP registration",status:"warn",message:"JetBrains stores MCP config via Settings UI \u2014 not CLI-inspectable",fix:"Verify in IDE: Settings > Tools > GitHub Copilot > MCP > ensure a context-mode server entry exists"}}getInstalledVersion(){let r=this.readSettings()?.hooks;return r&&Object.keys(r).length>0?"configured":"unknown"}}});function Ai(t,e){let r=Xm[e],n=Ut(e);if("command"in t){let s=t.command??"";return r!=null&&s.includes(r)||s.includes(n)}return t.hooks?.some(s=>{let i=s.command??"";return r!=null&&i.includes(r)||i.includes(n)})??!1}function Ut(t){return`context-mode hook cursor ${t.toLowerCase()}`}var he,Xm,oj,sj,Ym,_k,vk,xk=ce(()=>{"use strict";he={PRE_TOOL_USE:"preToolUse",POST_TOOL_USE:"postToolUse",SESSION_START:"sessionStart",STOP:"stop",AFTER_AGENT_RESPONSE:"afterAgentResponse"},Xm={[he.PRE_TOOL_USE]:"pretooluse.mjs",[he.POST_TOOL_USE]:"posttooluse.mjs",[he.SESSION_START]:"sessionstart.mjs",[he.STOP]:"stop.mjs",[he.AFTER_AGENT_RESPONSE]:"afteragentresponse.mjs"},oj="MCP:(?!ctx_)",sj=["Shell","Read","Grep","WebFetch","mcp_web_fetch","mcp_fetch_tool","Task","MCP:ctx_execute","MCP:ctx_execute_file","MCP:ctx_batch_execute",oj],Ym=sj.join("|"),_k=[he.PRE_TOOL_USE],vk=[he.POST_TOOL_USE]});var wk={};Fe(wk,{CursorAdapter:()=>Qm});import{readFileSync as Bc,writeFileSync as ij,mkdirSync as aj,accessSync as bk,chmodSync as cj,constants as Sk,existsSync as kk,readdirSync as uj}from"node:fs";import{execSync as lj}from"node:child_process";import{resolve as Qn,join as eo}from"node:path";import{homedir as Vc}from"node:os";var Ek,Qm,Tk=ce(()=>{"use strict";ut();Wn();xk();Ek="/Library/Application Support/Cursor/hooks.json",Qm=class extends xe{constructor(){super([".cursor"])}name="Cursor";paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!1,sessionStart:!0,canModifyArgs:!0,canModifyOutput:!1,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parsePostToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:r.tool_output??r.error_message,isError:!!r.error_message,sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parseSessionStartInput(e){let r=e,n=r.source??r.trigger??"startup",o;switch(n){case"compact":o="compact";break;case"resume":o="resume";break;case"clear":o="clear";break;default:o="startup"}return{sessionId:this.extractSessionId(r),source:o,projectDir:this.getProjectDir(r),raw:e}}formatPreToolUseResponse(e){return e.decision==="deny"?{permission:"deny",user_message:e.reason??"Blocked by context-mode hook"}:e.decision==="modify"&&e.updatedInput?{updated_input:e.updatedInput}:e.decision==="context"&&e.additionalContext?{agent_message:e.additionalContext}:e.decision==="ask"?{permission:"ask",user_message:e.reason??"Action requires user confirmation (security policy)"}:{agent_message:""}}formatPostToolUseResponse(e){return{additional_context:e.additionalContext??""}}formatSessionStartResponse(e){return{additional_context:e.context??""}}parseStopInput(e){let r=e;return{sessionId:r.conversation_id??`pid-${process.ppid}`,status:r.status??"completed",loopCount:r.loop_count??0,generationId:r.generation_id,transcriptPath:r.transcript_path??void 0}}formatStopResponse(e){return e.followupMessage?{followup_message:e.followupMessage}:{}}parseAfterAgentResponseInput(e){return{text:e.text??""}}getSettingsPath(){return Qn(".cursor","hooks.json")}getConfigDir(e){return Qn(e??process.cwd(),".cursor")}getInstructionFiles(){return["context-mode.mdc"]}generateHookConfig(e){return{[he.PRE_TOOL_USE]:[{type:"command",command:Ut(he.PRE_TOOL_USE),matcher:Ym,loop_limit:null,failClosed:!1}],[he.POST_TOOL_USE]:[{type:"command",command:Ut(he.POST_TOOL_USE),loop_limit:null,failClosed:!1}],[he.SESSION_START]:[{type:"command",command:Ut(he.SESSION_START),loop_limit:null,failClosed:!1}],[he.STOP]:[{type:"command",command:Ut(he.STOP),loop_limit:null,failClosed:!1}],[he.AFTER_AGENT_RESPONSE]:[{type:"command",command:Ut(he.AFTER_AGENT_RESPONSE),loop_limit:null,failClosed:!1}]}}readSettings(){for(let e of this.getCandidateHookConfigPaths())try{let r=Bc(e,"utf-8");return JSON.parse(r)}catch{continue}return null}writeSettings(e){let r=this.getSettingsPath();aj(Qn(".cursor"),{recursive:!0}),ij(r,JSON.stringify(e,null,2)+`
|
|
148
|
+
`,"utf-8")}configureAllHooks(e){let r=[],n=this.readSettings()??{},o=n.hooks??{},{HOOK_TYPES:s,HOOK_SCRIPTS:i,buildHookCommand:a}=this.hookModule,c=[s.PRE_TOOL_USE,s.POST_TOOL_USE,s.PRE_COMPACT,s.SESSION_START];for(let u of c)i[u]&&(o[u]=[{matcher:"",hooks:[{type:"command",command:a(u,e)}]}],r.push(`Configured ${u} hook`));return n.hooks=o,this.writeSettings(n),r.push(`Wrote hook config to ${this.getSettingsPath()}`),r}setHookPermissions(e){let r=[],n=YM(e,"hooks",this.hookSubdir);for(let o of Object.values(this.hookModule.HOOK_SCRIPTS)){let s=qc(n,o);try{GM(s,XM.R_OK),JM(s,493),r.push(s)}catch{}}return r}updatePluginRegistry(e,r){}}});function uk(t,e){if(!Bm[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook vscode-copilot ${t.toLowerCase()}`}var zt,Bm,R4,P4,lk=ce(()=>{"use strict";zt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart"},Bm={[zt.PRE_TOOL_USE]:"pretooluse.mjs",[zt.POST_TOOL_USE]:"posttooluse.mjs",[zt.PRE_COMPACT]:"precompact.mjs",[zt.SESSION_START]:"sessionstart.mjs"},R4=[zt.PRE_TOOL_USE,zt.SESSION_START],P4=[zt.POST_TOOL_USE,zt.PRE_COMPACT]});var pk={};Fe(pk,{VSCodeCopilotAdapter:()=>Km});import{readFileSync as Vm,mkdirSync as dk,accessSync as QM,existsSync as ej,constants as tj}from"node:fs";import{resolve as ts,join as Ii}from"node:path";import{homedir as Wm}from"node:os";var Km,fk=ce(()=>{"use strict";qm();ut();lk();Km=class extends es{constructor(){super([".vscode"])}name="VS Code Copilot";hookModule={HOOK_TYPES:zt,HOOK_SCRIPTS:Bm,buildHookCommand:uk};hookSubdir="vscode-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.VSCODE_PID?`vscode-${process.env.VSCODE_PID}`:`pid-${process.ppid}`}getProjectDir(){return process.env.CLAUDE_PROJECT_DIR||process.env.VSCODE_CWD||process.cwd()}getSessionDir(){let e=er();if(e){let s=Ii(e,"context-mode","sessions");return dk(s,{recursive:!0}),s}let r=ts(".github","context-mode","sessions"),n=Ii(Wm(),".vscode","context-mode","sessions"),o=ej(ts(".github"))?r:n;return dk(o,{recursive:!0}),o}getConfigDir(e){return ts(e??process.cwd(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[],n=ts(".github","hooks");try{QM(n,tj.R_OK)}catch{return r.push({check:"Hooks directory",status:"fail",message:".github/hooks/ directory not found",fix:"context-mode upgrade"}),r}let o=ts(n,"context-mode.json");try{let s=Vm(o,"utf-8"),a=JSON.parse(s).hooks;a?.[zt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in context-mode.json",fix:"context-mode upgrade"}),a?.[zt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"API stability",status:"warn",message:"VS Code Copilot hooks are in preview \u2014 API may change without notice"}),r.push({check:"Matcher support",status:"warn",message:"Matchers are parsed but IGNORED \u2014 all hooks fire on all tools"}),r}checkPluginRegistration(){try{let e=ts(".vscode","mcp.json"),r=Vm(e,"utf-8"),o=JSON.parse(r).servers;return o&&Object.keys(o).some(i=>i.includes("context-mode"))?{check:"MCP registration",status:"pass",message:"context-mode found in .vscode/mcp.json"}:{check:"MCP registration",status:"fail",message:"context-mode not found in .vscode/mcp.json",fix:"Add context-mode server to .vscode/mcp.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read .vscode/mcp.json"}}}getInstalledVersion(){let e=[Ii(Wm(),".vscode","extensions"),Ii(Wm(),".vscode-insiders","extensions")];for(let r of e)try{let n=Vm(Ii(r,"extensions.json"),"utf-8"),s=JSON.parse(n).find(i=>typeof i.identifier=="object"&&i.identifier!==null&&i.identifier.id?.toString().includes("context-mode"));if(s&&typeof s.version=="string")return s.version}catch{continue}return"not installed"}}});function mk(t,e){if(!Gm[t])throw new Error(`No script defined for hook type: ${t}`);return`context-mode hook jetbrains-copilot ${t.toLowerCase()}`}var Lt,Gm,M4,j4,hk=ce(()=>{"use strict";Lt={PRE_TOOL_USE:"PreToolUse",POST_TOOL_USE:"PostToolUse",PRE_COMPACT:"PreCompact",SESSION_START:"SessionStart",STOP:"Stop",SUBAGENT_START:"SubagentStart",SUBAGENT_STOP:"SubagentStop"},Gm={[Lt.PRE_TOOL_USE]:"pretooluse.mjs",[Lt.POST_TOOL_USE]:"posttooluse.mjs",[Lt.PRE_COMPACT]:"precompact.mjs",[Lt.SESSION_START]:"sessionstart.mjs"},M4=[Lt.PRE_TOOL_USE,Lt.SESSION_START],j4=[Lt.POST_TOOL_USE,Lt.PRE_COMPACT]});var gk={};Fe(gk,{JetBrainsCopilotAdapter:()=>Jm});import{readFileSync as rj}from"node:fs";import{resolve as nj}from"node:path";var Jm,yk=ce(()=>{"use strict";qm();hk();Jm=class extends es{constructor(){super([".config","JetBrains"])}name="JetBrains Copilot";hookModule={HOOK_TYPES:Lt,HOOK_SCRIPTS:Gm,buildHookCommand:mk};hookSubdir="jetbrains-copilot";extractSessionId(e){return e.sessionId?e.sessionId:process.env.JETBRAINS_CLIENT_ID?`jetbrains-${process.env.JETBRAINS_CLIENT_ID}`:process.env.IDEA_HOME?`idea-${process.pid}`:`pid-${process.ppid}`}getProjectDir(){return process.env.IDEA_INITIAL_DIRECTORY||process.env.CLAUDE_PROJECT_DIR||process.cwd()}getConfigDir(e){return nj(e??this.getProjectDir(),".github")}getInstructionFiles(){return["copilot-instructions.md"]}validateHooks(e){let r=[];try{let n=rj(this.getSettingsPath(),"utf-8"),s=JSON.parse(n).hooks;s?.[Lt.PRE_TOOL_USE]?r.push({check:"PreToolUse hook",status:"pass",message:"PreToolUse hook configured in .github/hooks/context-mode.json"}):r.push({check:"PreToolUse hook",status:"fail",message:"PreToolUse not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"}),s?.[Lt.SESSION_START]?r.push({check:"SessionStart hook",status:"pass",message:"SessionStart hook configured in .github/hooks/context-mode.json"}):r.push({check:"SessionStart hook",status:"fail",message:"SessionStart not found in .github/hooks/context-mode.json",fix:"context-mode upgrade"})}catch{r.push({check:"Hook configuration",status:"fail",message:"Could not read .github/hooks/context-mode.json",fix:"context-mode upgrade"})}return r.push({check:"Hook scripts",status:"warn",message:`JetBrains hook wrappers should resolve to ${e}/hooks/jetbrains-copilot/*.mjs`}),r}checkPluginRegistration(){return{check:"MCP registration",status:"warn",message:"JetBrains stores MCP config via Settings UI \u2014 not CLI-inspectable",fix:"Verify in IDE: Settings > Tools > GitHub Copilot > MCP > ensure a context-mode server entry exists"}}getInstalledVersion(){let r=this.readSettings()?.hooks;return r&&Object.keys(r).length>0?"configured":"unknown"}}});function Ai(t,e){let r=Xm[e],n=Ut(e);if("command"in t){let s=t.command??"";return r!=null&&s.includes(r)||s.includes(n)}return t.hooks?.some(s=>{let i=s.command??"";return r!=null&&i.includes(r)||i.includes(n)})??!1}function Ut(t){return`context-mode hook cursor ${t.toLowerCase()}`}var he,Xm,oj,sj,Ym,_k,vk,xk=ce(()=>{"use strict";he={PRE_TOOL_USE:"preToolUse",POST_TOOL_USE:"postToolUse",SESSION_START:"sessionStart",STOP:"stop",AFTER_AGENT_RESPONSE:"afterAgentResponse"},Xm={[he.PRE_TOOL_USE]:"pretooluse.mjs",[he.POST_TOOL_USE]:"posttooluse.mjs",[he.SESSION_START]:"sessionstart.mjs",[he.STOP]:"stop.mjs",[he.AFTER_AGENT_RESPONSE]:"afteragentresponse.mjs"},oj="MCP:(?!ctx_)",sj=["Shell","Read","Grep","WebFetch","mcp_web_fetch","mcp_fetch_tool","Task","MCP:ctx_execute","MCP:ctx_execute_file","MCP:ctx_batch_execute",oj],Ym=sj.join("|"),_k=[he.PRE_TOOL_USE],vk=[he.POST_TOOL_USE]});var wk={};Fe(wk,{CursorAdapter:()=>Qm});import{readFileSync as Bc,writeFileSync as ij,mkdirSync as aj,accessSync as bk,chmodSync as cj,constants as Sk,existsSync as kk,readdirSync as uj}from"node:fs";import{execSync as lj}from"node:child_process";import{resolve as Qn,join as eo}from"node:path";import{homedir as Vc}from"node:os";var Ek,Qm,Tk=ce(()=>{"use strict";ut();Wn();xk();Ek="/Library/Application Support/Cursor/hooks.json",Qm=class extends xe{constructor(){super([".cursor"])}name="Cursor";paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!1,sessionStart:!0,canModifyArgs:!0,canModifyOutput:!1,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parsePostToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:r.tool_output??r.error_message,isError:!!r.error_message,sessionId:this.extractSessionId(r),projectDir:this.getProjectDir(r),raw:e}}parseSessionStartInput(e){let r=e,n=r.source??r.trigger??"startup",o;switch(n){case"compact":o="compact";break;case"resume":o="resume";break;case"clear":o="clear";break;default:o="startup"}return{sessionId:this.extractSessionId(r),source:o,projectDir:this.getProjectDir(r),raw:e}}formatPreToolUseResponse(e){return e.decision==="deny"?{permission:"deny",user_message:e.reason??"Blocked by context-mode hook"}:e.decision==="modify"&&e.updatedInput?{updated_input:e.updatedInput}:e.decision==="context"&&e.additionalContext?{agent_message:e.additionalContext}:e.decision==="ask"?{permission:"ask",user_message:e.reason??"Action requires user confirmation (security policy)"}:{agent_message:""}}formatPostToolUseResponse(e){return{additional_context:e.additionalContext??""}}formatSessionStartResponse(e){return{additional_context:e.context??""}}parseStopInput(e){let r=e;return{sessionId:r.conversation_id??`pid-${process.ppid}`,status:r.status??"completed",loopCount:r.loop_count??0,generationId:r.generation_id,transcriptPath:r.transcript_path??void 0}}formatStopResponse(e){return e.followupMessage?{followup_message:e.followupMessage}:{}}parseAfterAgentResponseInput(e){return{text:e.text??""}}getSettingsPath(){return Qn(".cursor","hooks.json")}getConfigDir(e){return Qn(e??process.cwd(),".cursor")}getInstructionFiles(){return["context-mode.mdc"]}generateHookConfig(e){return{[he.PRE_TOOL_USE]:[{type:"command",command:Ut(he.PRE_TOOL_USE),matcher:Ym,loop_limit:null,failClosed:!1}],[he.POST_TOOL_USE]:[{type:"command",command:Ut(he.POST_TOOL_USE),loop_limit:null,failClosed:!1}],[he.SESSION_START]:[{type:"command",command:Ut(he.SESSION_START),loop_limit:null,failClosed:!1}],[he.STOP]:[{type:"command",command:Ut(he.STOP),loop_limit:null,failClosed:!1}],[he.AFTER_AGENT_RESPONSE]:[{type:"command",command:Ut(he.AFTER_AGENT_RESPONSE),loop_limit:null,failClosed:!1}]}}readSettings(){for(let e of this.getCandidateHookConfigPaths())try{let r=Bc(e,"utf-8");return JSON.parse(r)}catch{continue}return null}writeSettings(e){let r=this.getSettingsPath();aj(Qn(".cursor"),{recursive:!0}),ij(r,JSON.stringify(e,null,2)+`
|
|
149
149
|
`,"utf-8")}validateHooks(e){let r=[],n=this.loadNativeHookConfig();if(!n)r.push({check:"Native hook config",status:"fail",message:"No readable native Cursor hook config found in .cursor/hooks.json or ~/.cursor/hooks.json",fix:"context-mode upgrade"});else{let s=n.config.hooks??{};r.push({check:"Native hook config",status:"pass",message:`Loaded ${n.path}`});for(let i of _k){let a=s[i],c=Array.isArray(a)&&a.some(u=>Ai(u,i));r.push({check:i,status:c?"pass":"fail",message:c?`${i} hook configured`:`${i} hook not configured in ${n.path}`,fix:c?void 0:"context-mode upgrade"})}for(let i of vk){let a=s[i],c=Array.isArray(a)&&a.some(u=>Ai(u,i));r.push({check:i,status:c?"pass":"warn",message:c?`${i} hook configured`:`${i} hook missing \u2014 session event capture will be reduced`})}}kk(Ek)&&r.push({check:"Enterprise hook config",status:"warn",message:"Enterprise Cursor hook config detected at /Library/Application Support/Cursor/hooks.json (read-only informational layer)"}),this.hasClaudeCompatibilityHooks()&&r.push({check:"Claude compatibility",status:"warn",message:"Claude-compatible hooks detected; native Cursor hooks are the supported configuration"});let o=this.detectPluginInstalls();return o.length>0&&((n?Object.entries(n.config.hooks??{}).some(([i,a])=>Array.isArray(a)&&a.some(c=>Ai(c,i))):!1)&&n?r.push({check:"Plugin/native hook duplication",status:"warn",message:`context-mode plugin detected at ${o[0]} alongside native hooks in ${n.path} \u2014 each event will fire twice. Remove one configuration to avoid duplicate routing.`,fix:"Remove the native .cursor/hooks.json entries OR uninstall the plugin"}):r.push({check:"Plugin install",status:"pass",message:`context-mode plugin installed at ${o[0]}`})),r}detectPluginInstalls(){let e=[eo(Vc(),".cursor","plugins","local"),eo(Vc(),".cursor","plugins","cache")],r=[];for(let n of e){try{bk(n,Sk.F_OK)}catch{continue}let o=[];try{o=uj(n)}catch{continue}for(let s of o){let i=eo(n,s,".cursor-plugin","plugin.json");try{let a=Bc(i,"utf-8");JSON.parse(a)?.name==="context-mode"&&r.push(i)}catch{continue}}}return r}checkPluginRegistration(){let e=[Qn(".cursor","mcp.json"),eo(Vc(),".cursor","mcp.json")];for(let n of e)try{let o=Bc(n,"utf-8"),s=JSON.parse(o),i=s.mcpServers??s.servers;if(!i)continue;if(Object.entries(i).some(([c,u])=>c.includes("context-mode")?!0:!u||typeof u!="object"?!1:u.command==="context-mode"))return{check:"MCP registration",status:"pass",message:`context-mode found in ${n}`}}catch{continue}let r=this.detectPluginInstalls();return r.length>0?{check:"MCP registration",status:"pass",message:`context-mode registered via plugin manifest at ${r[0]}`}:{check:"MCP registration",status:"warn",message:"Could not find context-mode in .cursor/mcp.json or ~/.cursor/mcp.json"}}getInstalledVersion(){try{return lj("cursor --version",{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim().split(/\r?\n/)[0]||"unknown"}catch{return"not installed"}}configureAllHooks(e){let r=this.readSettings()??{version:1,hooks:{}},n=r.hooks??{},o=[];return this.upsertHookEntry(n,he.PRE_TOOL_USE,{type:"command",command:Ut(he.PRE_TOOL_USE),matcher:Ym,loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,he.POST_TOOL_USE,{type:"command",command:Ut(he.POST_TOOL_USE),loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,he.SESSION_START,{type:"command",command:Ut(he.SESSION_START),loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,he.STOP,{type:"command",command:Ut(he.STOP),loop_limit:null,failClosed:!1},o),this.upsertHookEntry(n,he.AFTER_AGENT_RESPONSE,{type:"command",command:Ut(he.AFTER_AGENT_RESPONSE),loop_limit:null,failClosed:!1},o),r.version=1,r.hooks=n,this.writeSettings(r),o.push(`Wrote native Cursor hooks to ${this.getSettingsPath()}`),o}setHookPermissions(e){let r=[],n=eo(e,"hooks","cursor");for(let o of Object.values(Xm)){let s=Qn(n,o);try{bk(s,Sk.R_OK),cj(s,493),r.push(s)}catch{}}return r}updatePluginRegistry(e,r){}getCandidateHookConfigPaths(){let e=[this.getSettingsPath(),eo(Vc(),".cursor","hooks.json")];return process.platform==="darwin"&&e.push(Ek),e}getProjectDir(e){return e.cwd||e.workspace_roots?.[0]||process.env.CURSOR_CWD||process.cwd()}extractSessionId(e){return e.conversation_id?e.conversation_id:e.session_id?e.session_id:process.env.CURSOR_SESSION_ID?process.env.CURSOR_SESSION_ID:process.env.CURSOR_TRACE_ID?process.env.CURSOR_TRACE_ID:`pid-${process.ppid}`}loadNativeHookConfig(){for(let e of this.getCandidateHookConfigPaths())try{let r=Bc(e,"utf-8"),n=JSON.parse(r);if(n&&typeof n=="object")return{path:e,config:n}}catch{continue}return null}hasClaudeCompatibilityHooks(){return[Qn(".claude","settings.json"),Qn(".claude","settings.local.json"),eo(St(),"settings.json")].some(r=>kk(r))}upsertHookEntry(e,r,n,o){let s=e[r],i=Array.isArray(s)?[...s]:[],a=i.findIndex(c=>Ai(c,r));a>=0?(i[a]=n,o.push(`Updated existing ${r} hook entry`)):(i.push(n),o.push(`Added ${r} hook entry`)),e[r]=i}}});var Pk={};Fe(Pk,{AntigravityAdapter:()=>th});import{readFileSync as Wc,writeFileSync as dj,mkdirSync as pj}from"node:fs";import{resolve as Kc,dirname as Rk}from"node:path";import{fileURLToPath as fj}from"node:url";import{homedir as eh}from"node:os";var th,$k=ce(()=>{"use strict";ut();th=class extends xe{constructor(){super([".gemini"])}name="Antigravity";paradigm="mcp-only";capabilities={preToolUse:!1,postToolUse:!1,preCompact:!1,sessionStart:!1,canModifyArgs:!1,canModifyOutput:!1,canInjectSessionContext:!1};parsePreToolUseInput(e){throw new Error("Antigravity does not support hooks")}parsePostToolUseInput(e){throw new Error("Antigravity does not support hooks")}parsePreCompactInput(e){throw new Error("Antigravity does not support hooks")}parseSessionStartInput(e){throw new Error("Antigravity does not support hooks")}formatPreToolUseResponse(e){}formatPostToolUseResponse(e){}formatPreCompactResponse(e){}formatSessionStartResponse(e){}getSettingsPath(){return Kc(eh(),".gemini","antigravity","mcp_config.json")}getConfigDir(e){return Kc(eh(),".gemini","antigravity")}getInstructionFiles(){return["GEMINI.md"]}generateHookConfig(e){return{}}readSettings(){try{let e=Wc(this.getSettingsPath(),"utf-8");return JSON.parse(e)}catch{return null}}writeSettings(e){let r=this.getSettingsPath();pj(Rk(r),{recursive:!0}),dj(r,JSON.stringify(e,null,2),"utf-8")}validateHooks(e){return[{check:"Hook support",status:"warn",message:"Antigravity does not support hooks. Only MCP integration is available."}]}checkPluginRegistration(){try{let e=Wc(this.getSettingsPath(),"utf-8");return"context-mode"in(JSON.parse(e)?.mcpServers??{})?{check:"MCP registration",status:"pass",message:"context-mode found in mcpServers config"}:{check:"MCP registration",status:"fail",message:"context-mode not found in mcpServers",fix:"Add context-mode to mcpServers in ~/.gemini/antigravity/mcp_config.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read ~/.gemini/antigravity/mcp_config.json"}}}getInstalledVersion(){try{let e=Kc(eh(),".gemini","extensions","context-mode","package.json");return JSON.parse(Wc(e,"utf-8")).version??"unknown"}catch{return"not installed"}}configureAllHooks(e){return[]}setHookPermissions(e){return[]}updatePluginRegistry(e,r){}getRoutingInstructions(){let e=Kc(Rk(fj(import.meta.url)),"..","..","..","configs","antigravity","GEMINI.md");try{return Wc(e,"utf-8")}catch{return`# context-mode
|
|
150
150
|
|
|
151
151
|
Use context-mode MCP tools (execute, execute_file, batch_execute, fetch_and_index, search) instead of run_command/view_file for data-heavy operations.`}}}});function Gc(t,e){let r=Ck[e];return r&&(t.command?.includes(r)||t.command?.includes("context-mode hook kiro"))||!1}function rs(t,e){let r=Ck[t];return e&&r?Ie(`${e}/hooks/kiro/${r}`):`context-mode hook kiro ${t.toLowerCase()}`}var Ae,Ck,mj,hj,rh,o9,s9,Ok=ce(()=>{"use strict";sn();Ae={PRE_TOOL_USE:"preToolUse",POST_TOOL_USE:"postToolUse",AGENT_SPAWN:"agentSpawn",USER_PROMPT_SUBMIT:"userPromptSubmit"},Ck={[Ae.PRE_TOOL_USE]:"pretooluse.mjs",[Ae.POST_TOOL_USE]:"posttooluse.mjs",[Ae.USER_PROMPT_SUBMIT]:"userpromptsubmit.mjs",[Ae.AGENT_SPAWN]:"agentspawn.mjs"},mj="@(?!context-mode/)",hj=["execute_bash","fs_read","@context-mode/ctx_execute","@context-mode/ctx_execute_file","@context-mode/ctx_batch_execute",mj],rh=hj.join("|"),o9=[Ae.PRE_TOOL_USE,Ae.AGENT_SPAWN],s9=[Ae.POST_TOOL_USE,Ae.USER_PROMPT_SUBMIT]});var Dk={};Fe(Dk,{KiroAdapter:()=>nh});import{readFileSync as ns,writeFileSync as Ik,mkdirSync as Ak}from"node:fs";import{resolve as to,dirname as Nk}from"node:path";import{fileURLToPath as gj}from"node:url";import{homedir as Jc}from"node:os";var nh,Mk=ce(()=>{"use strict";ut();Ok();nh=class extends xe{constructor(){super([".kiro"])}name="Kiro";paradigm="json-stdio";capabilities={preToolUse:!0,postToolUse:!0,preCompact:!1,sessionStart:!0,canModifyArgs:!1,canModifyOutput:!1,canInjectSessionContext:!0};parsePreToolUseInput(e){let r=e;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},sessionId:`pid-${process.ppid}`,projectDir:r.cwd??process.cwd(),raw:e}}parsePostToolUseInput(e){let r=e,n=r.tool_response;return{toolName:r.tool_name??"",toolInput:r.tool_input??{},toolOutput:typeof n=="string"?n:JSON.stringify(n??""),sessionId:`pid-${process.ppid}`,projectDir:r.cwd??process.cwd(),raw:e}}parsePreCompactInput(e){throw new Error("Kiro does not support PreCompact hooks")}parseSessionStartInput(e){let r=e??{};return{source:r.source??"startup",sessionId:`pid-${process.ppid}`,projectDir:r.cwd??process.cwd(),raw:e}}formatPreToolUseResponse(e){switch(e.decision){case"deny":return{exitCode:2,stderr:e.reason??"Blocked by context-mode"};case"context":return{exitCode:0,stdout:e.additionalContext??""};default:return}}formatPostToolUseResponse(e){}formatPreCompactResponse(e){}formatSessionStartResponse(e){if(e?.context)return{hookSpecificOutput:{hookEventName:"agentSpawn",additionalContext:e.context}}}getSettingsPath(){return to(Jc(),".kiro","settings","mcp.json")}getConfigDir(e){return to(e??process.cwd(),".kiro")}getInstructionFiles(){return["KIRO.md"]}generateHookConfig(e){return{[Ae.PRE_TOOL_USE]:[{matcher:rh,hooks:[{type:"command",command:rs(Ae.PRE_TOOL_USE,e)}]}],[Ae.POST_TOOL_USE]:[{matcher:"*",hooks:[{type:"command",command:rs(Ae.POST_TOOL_USE,e)}]}],[Ae.AGENT_SPAWN]:[{matcher:"*",hooks:[{type:"command",command:rs(Ae.AGENT_SPAWN,e)}]}],[Ae.USER_PROMPT_SUBMIT]:[{matcher:"*",hooks:[{type:"command",command:rs(Ae.USER_PROMPT_SUBMIT,e)}]}]}}readSettings(){try{let e=ns(this.getSettingsPath(),"utf-8");return JSON.parse(e)}catch{return null}}writeSettings(e){let r=this.getSettingsPath();Ak(Nk(r),{recursive:!0}),Ik(r,JSON.stringify(e,null,2),"utf-8")}validateHooks(e){let r=[],n=to(Jc(),".kiro","agents","default.json");try{let s=JSON.parse(ns(n,"utf-8")).hooks??{};for(let i of[Ae.PRE_TOOL_USE]){let c=(s[i]??[]).some(u=>Gc(u,i));r.push({check:`Hook: ${i}`,status:c?"pass":"fail",message:c?`context-mode ${i} hook found`:`context-mode ${i} hook not configured`,...c?{}:{fix:"Run: context-mode upgrade"}})}for(let i of[Ae.POST_TOOL_USE]){let c=(s[i]??[]).some(u=>Gc(u,i));r.push({check:`Hook: ${i}`,status:c?"pass":"warn",message:c?`context-mode ${i} hook found`:`context-mode ${i} hook not configured (optional)`})}}catch{r.push({check:"Hook configuration",status:"warn",message:"Could not read ~/.kiro/agents/default.json",fix:"Run: context-mode upgrade"})}return r}checkPluginRegistration(){try{let e=ns(this.getSettingsPath(),"utf-8");return"context-mode"in(JSON.parse(e)?.mcpServers??{})?{check:"MCP registration",status:"pass",message:"context-mode found in mcpServers config"}:{check:"MCP registration",status:"fail",message:"context-mode not found in mcpServers",fix:"Add context-mode to mcpServers in ~/.kiro/settings/mcp.json"}}catch{return{check:"MCP registration",status:"warn",message:"Could not read ~/.kiro/settings/mcp.json"}}}getInstalledVersion(){try{let e=to(Jc(),".kiro","extensions","context-mode","package.json");return JSON.parse(ns(e,"utf-8")).version??"unknown"}catch{return"not installed"}}configureAllHooks(e){let r=[],n=to(Jc(),".kiro","agents"),o=to(n,"default.json");try{Ak(n,{recursive:!0});let s={};try{s=JSON.parse(ns(o,"utf-8"))}catch{}let i=s.hooks??{},a=[[Ae.PRE_TOOL_USE,rh],[Ae.POST_TOOL_USE,"*"],[Ae.AGENT_SPAWN,"*"],[Ae.USER_PROMPT_SUBMIT,"*"]];for(let[c,u]of a){let l=i[c]??[];l.some(d=>Gc(d,c))||(l.push({matcher:u,command:rs(c,e)}),i[c]=l,r.push(`Added ${c} hook to ${o}`))}s.hooks=i,Ik(o,JSON.stringify(s,null,2),"utf-8")}catch(s){r.push(`Failed to configure hooks: ${s.message}`)}return r}setHookPermissions(e){return[]}updatePluginRegistry(e,r){}getRoutingInstructions(){let e=to(Nk(gj(import.meta.url)),"..","..","..","configs","kiro","KIRO.md");try{return ns(e,"utf-8")}catch{return`# context-mode
|