@ev-ai/agent-hook 1.3.2 → 1.3.3
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/README.md +2 -0
- package/dist/cli.mjs +38 -36
- package/dist/hook.mjs +35 -33
- package/dist/launcher-update.mjs +4 -4
- package/dist/launcher.mjs +3 -3
- package/dist/managed-hooks-snippet.cjs +1 -1
- package/dist/managed-hooks-snippet.mjs +1 -1
- package/dist/plugin-hooks.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -2,52 +2,54 @@
|
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module';
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
var Ud=Object.create;var Xs=Object.defineProperty;var Dd=Object.getOwnPropertyDescriptor;var Fd=Object.getOwnPropertyNames;var $d=Object.getPrototypeOf,jd=Object.prototype.hasOwnProperty;var ze=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Bd=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fd(t))!jd.call(e,o)&&o!==n&&Xs(e,o,{get:()=>t[o],enumerable:!(r=Dd(t,o))||r.enumerable});return e};var Ve=(e,t,n)=>(n=e!=null?Ud($d(e)):{},Bd(t||!e||!e.__esModule?Xs(n,"default",{value:e,enumerable:!0}):n,e));var Wn=V(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.MCP_MISSING_LAUNCH_SERIALIZED=Z.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Z.foldMcpName=Ya;Z.buildMcpFamilyCanonicalKey=Ug;Z.launchContainsCredentials=Fg;Z.serializeMcpLaunchIdentity=Xa;Z.hashMcpLaunchIdentity=Wt;Z.projectMcpMissingLaunchIdentity=Bg;Z.projectMcpLaunchIdentity=Kg;Z.maskMcpLaunchForDisplay=Wg;Z.normalizeMcpToolNames=zg;var Hg=ze("node:crypto");Z.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Z.MCP_MISSING_LAUNCH_SERIALIZED=`${Z.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function $e(e){return e.toLocaleLowerCase("en-US")}function Ya(e){return $e(e)}function Ug(e){return`interface:${Ya(e)}`}var Ja=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),Dg=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function bt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Fg(e){return e.kind==="url"?$g(e.url):e.kind==="command"?e.arguments.some(t=>Dg.test(t)):!1}function $g(e){try{let t=new URL(e);if(t.username.length>0||t.password.length>0)return!0;for(let n of t.searchParams.keys())if(Ja.has($e(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let s=e.split("?",2)[1];return s===void 0?!1:s.split("&").some(i=>{let a=$e(i.split("=",1)[0]??"");return Ja.has(a)})}}function Xa(e){if(e.kind==="url")return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",bt($e(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>$e(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",bt($e(e.command)),String(t.length),...t.map(bt)].join("|")}return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",bt(e.installationRootExternalKey),bt(e.sourcePath),bt(e.nativeKey)].join("|")}function Wt(e){return(0,Hg.createHash)("sha256").update(e).digest("hex")}var jg=Wt(Z.MCP_MISSING_LAUNCH_SERIALIZED);function Bg(){return{kind:"unknown",arguments:[],serialized:Z.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:jg}}function Kg(e){let t=Xa(e);return e.kind==="url"?{kind:"url",url:$e(e.url),arguments:[],serialized:t,contentHash:Wt(t)}:e.kind==="command"?{kind:"command",command:$e(e.command),arguments:[...e.arguments].map(n=>$e(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:Wt(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:Wt(t)}}var Gg=/^(https?:\/\/)([^/?#]*@)/i;function Wg(e){return e.replace(Gg,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function zg(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}});var Vn=V(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.PACKAGE_FIELD_MAX=void 0;Te.npxExecBin=qa;Te.packageNameFromSpec=zn;Te.pinnedPackageVersionFromSpec=Za;Te.pinnedPackageVersionFromNpx=th;Te.npxPackageSpecs=Qa;Te.PACKAGE_FIELD_MAX=128;var Vg=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,Jg=new Set(["-p","--package"]),Yg=new Set(["-c","--call"]),Xg=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),qg=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),Zg=/^--no-/;function Qg(e){return qg.has(e)||Zg.test(e)}function qa(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var eh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function zn(e){if(e.length===0||e.length>Te.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return Vg.test(n)?n:null}function Za(e){let t=zn(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return eh.test(n)?n:void 0}function th(e,t){for(let n of Qa(e,t)){let r=Za(n);if(r!==void 0)return r}}function Qa(e,t){let n=qa(e);if(n===null)return[];let r=[...t];if(n==="npm"){let i=r[0]?.toLowerCase();if(i!=="exec"&&i!=="x")return[];r=r.slice(1)}let o=[],s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(Yg.has(l))return[];if(Jg.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&o.push(u),c===-1&&(i+=1);continue}if(!(c!==-1||Qg(l))){if(Xg.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>zn(i)!==null)?o:[]:s===null||zn(s)===null?[]:[s]}});var ec=V(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.McpPackageEcosystem=void 0;ut.resolveMcpPackageIdentity=mh;var nh=Wn(),Eo=Vn();ut.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var rh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,oh=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,sh=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function ih(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var ah=new Set(["--from","--spec"]),ch=new Set(["--python","-p","--with","--with-editable","--with-requirements","--index","--index-url","--default-index","--extra-index-url","--find-links","-f","--constraint","-c","--override","--refresh-package","--cache-dir","--directory","--project","--config-file","--color","--exclude-newer","--pip-args","--verbose-pip"]),uh=new Set(["-q","--quiet","-v","--verbose","-n","--native-tls","--offline","--isolated","--preview","--refresh","--reinstall","--upgrade","-U","--force","--system","--system-site-packages","--path","--managed-python","--progress"]),lh=/^--no-/;function fh(e,t){let n=ih(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(ah.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&(o=u),c===-1&&(i+=1);continue}if(!(c!==-1||uh.has(l)||lh.test(l))){if(ch.has(l)){i+=1;continue}return null}}return o??s}function dh(e){if(e.length===0||e.length>Eo.PACKAGE_FIELD_MAX)return null;let t=e.includes("==")?"==":e.includes("@")?"@":null;if(t===null)return null;let n=e.indexOf(t),r=e.slice(0,n),o=e.slice(n+t.length);return!oh.test(r)||!sh.test(o)?null:{ecosystem:ut.McpPackageEcosystem.PYPI,packageName:r,version:o}}function ph(e){let t=(0,Eo.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return rh.test(n)?{ecosystem:ut.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function mh(e){if(e?.kind!=="command"||(0,nh.launchContainsCredentials)(e))return;for(let n of(0,Eo.npxPackageSpecs)(e.command,e.arguments)){let r=ph(n);if(r!==null)return r}let t=fh(e.command,e.arguments);if(t!==null)return dh(t)??void 0}});var ic=V(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.EMPTY_NPM_PUBLISHER=void 0;je.isNpmRegistryPublisher=hh;je.displayPublisherName=_h;je.classifyMcpProvenance=xh;var rc=Wn(),yo=Vn();je.EMPTY_NPM_PUBLISHER="npm:";var tc="npm:",gh=/^[A-Za-z0-9._-]+$/;function hh(e){return e.startsWith(tc)&&e!==je.EMPTY_NPM_PUBLISHER&&gh.test(e.slice(tc.length))}function _h(e){if(!(e==null||e===""||e===je.EMPTY_NPM_PUBLISHER))return e}function nc(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}function Sh(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}function Ro(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function Eh(e){let t=Ro(e),n=Sh(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||nc(t)||n!==void 0&&nc(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function yh(e){let t=Ro(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function Rh(e){let t=Ro(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function oc(e){let t={kind:"url",url:e};if((0,rc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||Eh(n.hostname))return{origin:"UNKNOWN"};let r=yh(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:Rh(n)}}catch{return{origin:"UNKNOWN"}}}var sc="mcp-remote";function Ch(e,t){if(e===sc)return t.find(n=>/^https?:\/\//i.test(n))}function Ah(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function kh(e,t,n){let r=Ch(e,t);return r!==void 0?oc(r):e===sc?{origin:"UNKNOWN"}:Ah(e,n)}function bh(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}function xh(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,rc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return oc(t.url);let r=(0,yo.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,yo.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=kh(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,yo.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return bh(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var cc=V(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.mcpServerToolSegmentForms=ac;Jn.mcpServerNameMatchesToolSegment=Ih;function ac(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function Ih(e,t){let n=t.toLowerCase();return ac(e).some(r=>r.toLowerCase()===n)}});var uc=V(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.parseFrontmatterField=Re.parseFrontmatterDescription=Re.usableCatalogText=void 0;var Oh=/^(?:>|\|)[-+]?$/,Th=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,Ph=e=>{let t=e?.trim()??"";if(!(t.length===0||Oh.test(t)))return t};Re.usableCatalogText=Ph;var wh=e=>(0,Re.parseFrontmatterField)(e,"description");Re.parseFrontmatterDescription=wh;var Nh=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return Mh(n[1],t)};Re.parseFrontmatterField=Nh;var vh=e=>e.replace(/^["']|["']$/g,"");function Mh(e,t){let n=e.split(`
|
|
6
|
-
`),r=`${t}:`,o=n.findIndex(p=>p===r||p.startsWith(`${r} `)||p.startsWith(`${r} `));if(o<0)return;let s=(n[o]??"").slice(r.length).trim(),i=
|
|
5
|
+
var dp=Object.create;var si=Object.defineProperty;var pp=Object.getOwnPropertyDescriptor;var mp=Object.getOwnPropertyNames;var gp=Object.getPrototypeOf,hp=Object.prototype.hasOwnProperty;var ze=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var _p=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mp(t))!hp.call(e,o)&&o!==n&&si(e,o,{get:()=>t[o],enumerable:!(r=pp(t,o))||r.enumerable});return e};var Ve=(e,t,n)=>(n=e!=null?dp(gp(e)):{},_p(t||!e||!e.__esModule?si(n,"default",{value:e,enumerable:!0}):n,e));var Xn=V(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.MCP_MISSING_LAUNCH_SERIALIZED=Z.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Z.foldMcpName=sc;Z.buildMcpFamilyCanonicalKey=dh;Z.launchContainsCredentials=mh;Z.serializeMcpLaunchIdentity=ic;Z.hashMcpLaunchIdentity=Jt;Z.projectMcpMissingLaunchIdentity=_h;Z.projectMcpLaunchIdentity=Sh;Z.maskMcpLaunchForDisplay=yh;Z.normalizeMcpToolNames=Rh;var fh=ze("node:crypto");Z.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Z.MCP_MISSING_LAUNCH_SERIALIZED=`${Z.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function $e(e){return e.toLocaleLowerCase("en-US")}function sc(e){return $e(e)}function dh(e){return`interface:${sc(e)}`}var oc=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),ph=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function bt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function mh(e){return e.kind==="url"?gh(e.url):e.kind==="command"?e.arguments.some(t=>ph.test(t)):!1}function gh(e){try{let t=new URL(e);if(t.username.length>0||t.password.length>0)return!0;for(let n of t.searchParams.keys())if(oc.has($e(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let s=e.split("?",2)[1];return s===void 0?!1:s.split("&").some(i=>{let a=$e(i.split("=",1)[0]??"");return oc.has(a)})}}function ic(e){if(e.kind==="url")return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",bt($e(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>$e(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",bt($e(e.command)),String(t.length),...t.map(bt)].join("|")}return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",bt(e.installationRootExternalKey),bt(e.sourcePath),bt(e.nativeKey)].join("|")}function Jt(e){return(0,fh.createHash)("sha256").update(e).digest("hex")}var hh=Jt(Z.MCP_MISSING_LAUNCH_SERIALIZED);function _h(){return{kind:"unknown",arguments:[],serialized:Z.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:hh}}function Sh(e){let t=ic(e);return e.kind==="url"?{kind:"url",url:$e(e.url),arguments:[],serialized:t,contentHash:Jt(t)}:e.kind==="command"?{kind:"command",command:$e(e.command),arguments:[...e.arguments].map(n=>$e(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:Jt(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:Jt(t)}}var Eh=/^(https?:\/\/)([^/?#]*@)/i;function yh(e){return e.replace(Eh,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function Rh(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}});var Zn=V(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.PACKAGE_FIELD_MAX=void 0;Te.npxExecBin=ac;Te.packageNameFromSpec=qn;Te.pinnedPackageVersionFromSpec=cc;Te.pinnedPackageVersionFromNpx=Ph;Te.npxPackageSpecs=uc;Te.PACKAGE_FIELD_MAX=128;var Ch=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,Ah=new Set(["-p","--package"]),kh=new Set(["-c","--call"]),bh=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),xh=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),Ih=/^--no-/;function Oh(e){return xh.has(e)||Ih.test(e)}function ac(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var Th=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function qn(e){if(e.length===0||e.length>Te.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return Ch.test(n)?n:null}function cc(e){let t=qn(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return Th.test(n)?n:void 0}function Ph(e,t){for(let n of uc(e,t)){let r=cc(n);if(r!==void 0)return r}}function uc(e,t){let n=ac(e);if(n===null)return[];let r=[...t];if(n==="npm"){let i=r[0]?.toLowerCase();if(i!=="exec"&&i!=="x")return[];r=r.slice(1)}let o=[],s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(kh.has(l))return[];if(Ah.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&o.push(u),c===-1&&(i+=1);continue}if(!(c!==-1||Oh(l))){if(bh.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>qn(i)!==null)?o:[]:s===null||qn(s)===null?[]:[s]}});var lc=V(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.McpPackageEcosystem=void 0;ut.resolveMcpPackageIdentity=Kh;var wh=Xn(),Co=Zn();ut.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var Nh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,vh=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,Mh=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function Lh(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var Hh=new Set(["--from","--spec"]),Uh=new Set(["--python","-p","--with","--with-editable","--with-requirements","--index","--index-url","--default-index","--extra-index-url","--find-links","-f","--constraint","-c","--override","--refresh-package","--cache-dir","--directory","--project","--config-file","--color","--exclude-newer","--pip-args","--verbose-pip"]),Dh=new Set(["-q","--quiet","-v","--verbose","-n","--native-tls","--offline","--isolated","--preview","--refresh","--reinstall","--upgrade","-U","--force","--system","--system-site-packages","--path","--managed-python","--progress"]),Fh=/^--no-/;function $h(e,t){let n=Lh(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(Hh.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&(o=u),c===-1&&(i+=1);continue}if(!(c!==-1||Dh.has(l)||Fh.test(l))){if(Uh.has(l)){i+=1;continue}return null}}return o??s}function jh(e){if(e.length===0||e.length>Co.PACKAGE_FIELD_MAX)return null;let t=e.includes("==")?"==":e.includes("@")?"@":null;if(t===null)return null;let n=e.indexOf(t),r=e.slice(0,n),o=e.slice(n+t.length);return!vh.test(r)||!Mh.test(o)?null:{ecosystem:ut.McpPackageEcosystem.PYPI,packageName:r,version:o}}function Bh(e){let t=(0,Co.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return Nh.test(n)?{ecosystem:ut.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function Kh(e){if(e?.kind!=="command"||(0,wh.launchContainsCredentials)(e))return;for(let n of(0,Co.npxPackageSpecs)(e.command,e.arguments)){let r=Bh(n);if(r!==null)return r}let t=$h(e.command,e.arguments);if(t!==null)return jh(t)??void 0}});var hc=V(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.EMPTY_NPM_PUBLISHER=void 0;je.isNpmRegistryPublisher=Wh;je.displayPublisherName=zh;je.classifyMcpProvenance=t_;var pc=Xn(),Ao=Zn();je.EMPTY_NPM_PUBLISHER="npm:";var fc="npm:",Gh=/^[A-Za-z0-9._-]+$/;function Wh(e){return e.startsWith(fc)&&e!==je.EMPTY_NPM_PUBLISHER&&Gh.test(e.slice(fc.length))}function zh(e){if(!(e==null||e===""||e===je.EMPTY_NPM_PUBLISHER))return e}function dc(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}function Vh(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}function ko(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function Jh(e){let t=ko(e),n=Vh(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||dc(t)||n!==void 0&&dc(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function Yh(e){let t=ko(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function Xh(e){let t=ko(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function mc(e){let t={kind:"url",url:e};if((0,pc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||Jh(n.hostname))return{origin:"UNKNOWN"};let r=Yh(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:Xh(n)}}catch{return{origin:"UNKNOWN"}}}var gc="mcp-remote";function qh(e,t){if(e===gc)return t.find(n=>/^https?:\/\//i.test(n))}function Zh(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function Qh(e,t,n){let r=qh(e,t);return r!==void 0?mc(r):e===gc?{origin:"UNKNOWN"}:Zh(e,n)}function e_(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}function t_(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,pc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return mc(t.url);let r=(0,Ao.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Ao.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=Qh(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,Ao.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return e_(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var Sc=V(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});Qn.mcpServerToolSegmentForms=_c;Qn.mcpServerNameMatchesToolSegment=n_;function _c(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function n_(e,t){let n=t.toLowerCase();return _c(e).some(r=>r.toLowerCase()===n)}});var Ec=V(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.parseFrontmatterField=Re.parseFrontmatterDescription=Re.usableCatalogText=void 0;var r_=/^(?:>|\|)[-+]?$/,o_=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,s_=e=>{let t=e?.trim()??"";if(!(t.length===0||r_.test(t)))return t};Re.usableCatalogText=s_;var i_=e=>(0,Re.parseFrontmatterField)(e,"description");Re.parseFrontmatterDescription=i_;var a_=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return u_(n[1],t)};Re.parseFrontmatterField=a_;var c_=e=>e.replace(/^["']|["']$/g,"");function u_(e,t){let n=e.split(`
|
|
6
|
+
`),r=`${t}:`,o=n.findIndex(p=>p===r||p.startsWith(`${r} `)||p.startsWith(`${r} `));if(o<0)return;let s=(n[o]??"").slice(r.length).trim(),i=o_.exec(s);if(!i){let p=c_(s).trim();return(0,Re.usableCatalogText)(p)}let a=[];for(let p=o+1;p<n.length;p+=1){let g=n[p]??"";if(g.trim()===""){a.push("");continue}if(g.length===g.trimStart().length)break;a.push(g)}let c=a.reduce((p,g)=>g.trim()===""?p:Math.min(p,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),l=[],u=i[1]?.trim();u&&l.push(u);for(let p of a)l.push(p.trim()===""?"":p.slice(c));for(;l.length>0&&l[l.length-1]==="";)l.pop();let f=s.startsWith(">")?l.join(`
|
|
7
7
|
`).split(/\n{2,}/).map(p=>p.split(`
|
|
8
8
|
`).map(g=>g.trim()).filter(Boolean).join(" ")).filter(p=>p.length>0).join(`
|
|
9
9
|
|
|
10
10
|
`):l.join(`
|
|
11
|
-
`).trimEnd();return(0,Re.usableCatalogText)(f)}});var
|
|
12
|
-
`),n=!1;return t.map(o=>n?
|
|
13
|
-
`)}function Kh(e){return Co(e)!==e}});var rt=V(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.redactComponentSource=y.prepareComponentInspectionText=y.fitSnapshotInspectionTextBudget=y.componentSourceContainsRedactableSecret=y.capComponentTextBytes=y.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=y.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=y.COMPONENT_INSPECTION_TEXT_MAX_BYTES=y.usableCatalogText=y.parseFrontmatterField=y.parseFrontmatterDescription=y.mcpServerToolSegmentForms=y.mcpServerNameMatchesToolSegment=y.isNpmRegistryPublisher=y.EMPTY_NPM_PUBLISHER=y.displayPublisherName=y.classifyMcpProvenance=y.resolveMcpPackageIdentity=y.McpPackageEcosystem=y.pinnedPackageVersionFromSpec=y.pinnedPackageVersionFromNpx=y.packageNameFromSpec=y.npxPackageSpecs=y.npxExecBin=y.PACKAGE_FIELD_MAX=y.serializeMcpLaunchIdentity=y.projectMcpMissingLaunchIdentity=y.projectMcpLaunchIdentity=y.normalizeMcpToolNames=y.MCP_MISSING_LAUNCH_SERIALIZED=y.MCP_LAUNCH_IDENTITY_ALGORITHM=y.maskMcpLaunchForDisplay=y.launchContainsCredentials=y.hashMcpLaunchIdentity=y.foldMcpName=y.buildMcpFamilyCanonicalKey=y.ComponentKind=void 0;y.userConfigRootFromPath=Qh;y.installationRootExternalKey=e_;y.normalizeRepositoryRelativePath=pc;y.nativeKeyForSkillPath=t_;y.nativeKeyForRulePath=n_;y.nativeKeyForCommandPath=r_;y.serializeComponentIdentity=gc;y.buildComponentReference=s_;y.validateComponentReference=i_;var Gh=ze("node:crypto"),Wh=ze("node:path"),zh="cmp1_",Vh=/^cmp1_[A-Za-z0-9_-]{43}$/,Jh=["/skills/","/skills-cursor/"],Yh=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,Xh=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,qh=[".cursor",".claude",".codex"],Zh={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function Qh(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>qh.includes(o));return n||(t.map(o=>Zh[o]).find(o=>o!==void 0)??"unknown")}function e_(e,t){return`runtime-install:${e}/${t}`}function Yn(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function pc(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=Wh.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Yn(n,"sourcePath")}function t_(e){let t=e.replaceAll("\\","/");for(let n of Jh){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function mc(e,t,n){let r=e.replaceAll("\\","/"),s=t.exec(r)?.[1];if(!s||s.split("/").includes(".."))return null;let i=s.replace(n,"");return i.length>0?i:null}function n_(e){return mc(e,Yh,/\.(mdc|md|rules)$/i)}function r_(e){return mc(e,Xh,/\.(md|mdc|toml)$/i)}function o_(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function gc(e){let t=[Yn(e.installationRootExternalKey,"installationRootExternalKey"),Yn(e.installableKind,"installableKind"),pc(e.sourcePath),Yn(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(o_).join("|")}`,"utf8")}function s_(e){let t=(0,Gh.createHash)("sha256").update(gc(e)).digest("base64url");return`${zh}${t}`}function i_(e){return Vh.test(e)}var Ce=Wn();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return Ce.buildMcpFamilyCanonicalKey}});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:function(){return Ce.foldMcpName}});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.hashMcpLaunchIdentity}});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:function(){return Ce.launchContainsCredentials}});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return Ce.maskMcpLaunchForDisplay}});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return Ce.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return Ce.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:function(){return Ce.normalizeMcpToolNames}});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.projectMcpLaunchIdentity}});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return Ce.projectMcpMissingLaunchIdentity}});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.serializeMcpLaunchIdentity}});var xt=Vn();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return xt.PACKAGE_FIELD_MAX}});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:function(){return xt.npxExecBin}});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:function(){return xt.npxPackageSpecs}});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:function(){return xt.packageNameFromSpec}});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return xt.pinnedPackageVersionFromNpx}});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return xt.pinnedPackageVersionFromSpec}});var hc=ec();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:function(){return hc.McpPackageEcosystem}});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return hc.resolveMcpPackageIdentity}});var Xn=ic();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:function(){return Xn.classifyMcpProvenance}});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:function(){return Xn.displayPublisherName}});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return Xn.EMPTY_NPM_PUBLISHER}});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return Xn.isNpmRegistryPublisher}});var _c=cc();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return _c.mcpServerNameMatchesToolSegment}});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return _c.mcpServerToolSegmentForms}});var Ao=uc();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:function(){return Ao.parseFrontmatterDescription}});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:function(){return Ao.parseFrontmatterField}});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:function(){return Ao.usableCatalogText}});var nt=dc();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return nt.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return nt.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return nt.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:function(){return nt.capComponentTextBytes}});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return nt.componentSourceContainsRedactableSecret}});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return nt.fitSnapshotInspectionTextBudget}});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:function(){return nt.prepareComponentInspectionText}});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:function(){return nt.redactComponentSource}})});var lr=V(Se=>{"use strict";Se.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Se.find=(e,t)=>e.nodes.find(n=>n.type===t);Se.exceedsLimit=(e,t,n=1,r)=>r===!1||!Se.isInteger(e)||!Se.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Se.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Se.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Se.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;Se.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Se.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Se.flatten=(...e)=>{let t=[],n=r=>{for(let o=0;o<r.length;o++){let s=r[o];if(Array.isArray(s)){n(s);continue}s!==void 0&&t.push(s)}return t};return n(e),t}});var fr=V((DI,Lu)=>{"use strict";var Mu=lr();Lu.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&Mu.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&Mu.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(e)}});var Uu=V((FI,Hu)=>{"use strict";Hu.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var zu=V(($I,Wu)=>{"use strict";var Du=Uu(),ft=(e,t,n)=>{if(Du(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Du(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),s=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=e+":"+t+"="+o+s+i+a;if(ft.cache.hasOwnProperty(c))return ft.cache[c].result;let l=Math.min(e,t),u=Math.max(e,t);if(Math.abs(l-u)===1){let S=e+"|"+t;return r.capture?`(${S})`:r.wrap===!1?S:`(?:${S})`}let d=Gu(e)||Gu(t),f={min:e,max:t,a:l,b:u},p=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let S=u<0?Math.abs(u):1;g=Fu(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=Fu(l,u,f,r)),f.negatives=g,f.positives=p,f.result=OE(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),ft.cache[c]=f,f.result};function OE(e,t,n){let r=Xo(e,t,"-",!1,n)||[],o=Xo(t,e,"",!1,n)||[],s=Xo(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function TE(e,t){let n=1,r=1,o=ju(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=ju(e,n);for(o=Bu(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=Bu(t+1,r)-1;return s=[...s],s.sort(NE),s}function PE(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=wE(e,t),o=r.length,s="",i=0;for(let a=0;a<o;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=vE(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function Fu(e,t,n,r){let o=TE(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=PE(String(i),String(l),r),d="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Ku(a.count),i=l+1;continue}n.isPadded&&(d=ME(l,n,r)),u.string=d+u.pattern+Ku(u.count),s.push(u),i=l+1,a=u}return s}function Xo(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!$u(t,"string",a)&&s.push(n+a),r&&$u(t,"string",a)&&s.push(n+a)}return s}function wE(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function NE(e,t){return e>t?1:t>e?-1:0}function $u(e,t,n){return e.some(r=>r[t]===n)}function ju(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function Bu(e,t){return e-e%Math.pow(10,t)}function Ku(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function vE(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function Gu(e){return/^-?(0+)\d/.test(e)}function ME(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}ft.cache={};ft.clearCache=()=>ft.cache={};Wu.exports=ft});var Qo=V((jI,Qu)=>{"use strict";var LE=ze("util"),Ju=zu(),Vu=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),HE=e=>t=>e===!0?Number(t):String(t),qo=e=>typeof e=="number"||typeof e=="string"&&e!=="",en=e=>Number.isInteger(+e),Zo=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},UE=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,DE=(e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},pr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},FE=(e,t,n)=>{e.negatives.sort((a,c)=>a<c?-1:a>c?1:0),e.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=t.capture?"":"?:",o="",s="",i;return e.positives.length&&(o=e.positives.map(a=>pr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>pr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},Yu=(e,t,n,r)=>{if(n)return Ju(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},Xu=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Ju(e,t,n)},qu=(...e)=>new RangeError("Invalid range arguments: "+LE.inspect(...e)),Zu=(e,t,n)=>{if(n.strictRanges===!0)throw qu([e,t]);return[]},$E=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},jE=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw qu([e,t]);return[]}o===0&&(o=0),s===0&&(s=0);let i=o>s,a=String(e),c=String(t),l=String(n);n=Math.max(Math.abs(n),1);let u=Zo(a)||Zo(c)||Zo(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&UE(e,t,r)===!1,p=r.transform||HE(f);if(r.toRegex&&n===1)return Yu(pr(e,d),pr(t,d),!0,r);let g={negatives:[],positives:[]},S=O=>g[O<0?"negatives":"positives"].push(Math.abs(O)),A=[],k=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):A.push(DE(p(o,k),d,f)),o=i?o-n:o+n,k++;return r.toRegex===!0?n>1?FE(g,r,d):Xu(A,null,{wrap:!1,...r}):A},BE=(e,t,n=1,r={})=>{if(!en(e)&&e.length>1||!en(t)&&t.length>1)return Zu(e,t,r);let o=r.transform||(f=>String.fromCharCode(f)),s=`${e}`.charCodeAt(0),i=`${t}`.charCodeAt(0),a=s>i,c=Math.min(s,i),l=Math.max(s,i);if(r.toRegex&&n===1)return Yu(c,l,!1,r);let u=[],d=0;for(;a?s>=i:s<=i;)u.push(o(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?Xu(u,null,{wrap:!1,options:r}):u},dr=(e,t,n,r={})=>{if(t==null&&qo(e))return[e];if(!qo(e)||!qo(t))return Zu(e,t,r);if(typeof n=="function")return dr(e,t,1,{transform:n});if(Vu(n))return dr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,en(n)?en(e)&&en(t)?jE(e,t,n,o):BE(e,t,Math.max(Math.abs(n),1),o):n!=null&&!Vu(n)?$E(n,o):dr(e,t,1,n)};Qu.exports=dr});var nl=V((BI,tl)=>{"use strict";var KE=Qo(),el=lr(),GE=(e,t={})=>{let n=(r,o={})=>{let s=el.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a=s===!0||i===!0,c=t.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=el.reduce(r.nodes),d=KE(...u,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(e)};tl.exports=GE});var sl=V((KI,ol)=>{"use strict";var WE=Qo(),rl=fr(),Ot=lr(),dt=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Ot.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(dt(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?dt(o,s,n):o+s);return Ot.flatten(r)},zE=(e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=(o,s={})=>{o.queue=[];let i=s,a=s.queue;for(;i.type!=="brace"&&i.type!=="root"&&i.parent;)i=i.parent,a=i.queue;if(o.invalid||o.dollar){a.push(dt(a.pop(),rl(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(dt(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=Ot.reduce(o.nodes);if(Ot.exceedsLimit(...d,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=WE(...d,t);f.length===0&&(f=rl(o,t)),a.push(dt(a.pop(),f)),o.nodes=[];return}let c=Ot.encloseBrace(o),l=o.queue,u=o;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<o.nodes.length;d++){let f=o.nodes[d];if(f.type==="comma"&&o.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(dt(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(dt(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return Ot.flatten(r(e))};ol.exports=zE});var al=V((GI,il)=>{"use strict";il.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
14
|
-
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var dl=V((WI,fl)=>{"use strict";var VE=fr(),{MAX_LENGTH:cl,CHAR_BACKSLASH:es,CHAR_BACKTICK:JE,CHAR_COMMA:YE,CHAR_DOT:XE,CHAR_LEFT_PARENTHESES:qE,CHAR_RIGHT_PARENTHESES:ZE,CHAR_LEFT_CURLY_BRACE:QE,CHAR_RIGHT_CURLY_BRACE:ey,CHAR_LEFT_SQUARE_BRACKET:ul,CHAR_RIGHT_SQUARE_BRACKET:ll,CHAR_DOUBLE_QUOTE:ty,CHAR_SINGLE_QUOTE:ny,CHAR_NO_BREAK_SPACE:ry,CHAR_ZERO_WIDTH_NOBREAK_SPACE:oy}=al(),sy=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(cl,n.maxLength):cl;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},s=[o],i=o,a=o,c=0,l=e.length,u=0,d=0,f,p=()=>e[u++],g=S=>{if(S.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&S.type==="text"){a.value+=S.value;return}return i.nodes.push(S),S.parent=i,S.prev=a,a=S,S};for(g({type:"bos"});u<l;)if(i=s[s.length-1],f=p(),!(f===oy||f===ry)){if(f===es){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===ll){g({type:"text",value:"\\"+f});continue}if(f===ul){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===ul){c++;continue}if(S===es){f+=p();continue}if(S===ll&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===qE){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===ZE){if(i.type!=="paren"){g({type:"text",value:f});continue}i=s.pop(),g({type:"text",value:f}),i=s[s.length-1];continue}if(f===ty||f===ny||f===JE){let S=f,A;for(t.keepQuotes!==!0&&(f="");u<l&&(A=p());){if(A===es){f+=A+p();continue}if(A===S){t.keepQuotes===!0&&(f+=A);break}f+=A}g({type:"text",value:f});continue}if(f===QE){d++;let A={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=g(A),s.push(i),g({type:"open",value:f});continue}if(f===ey){if(i.type!=="brace"){g({type:"text",value:f});continue}let S="close";i=s.pop(),i.close=!0,g({type:S,value:f}),d--,i=s[s.length-1];continue}if(f===YE&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:VE(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===XE&&d>0&&i.commas===0){let S=i.nodes;if(d===0||S.length===0){g({type:"text",value:f});continue}if(a.type==="dot"){if(i.range=[],a.value+=f,a.type="range",i.nodes.length!==3&&i.nodes.length!==5){i.invalid=!0,i.ranges=0,a.type="text";continue}i.ranges++,i.args=[];continue}if(a.type==="range"){S.pop();let A=S[S.length-1];A.value+=a.value+f,a=A,i.ranges--;continue}g({type:"dot",value:f});continue}g({type:"text",value:f})}do if(i=s.pop(),i.type!=="root"){i.nodes.forEach(k=>{k.nodes||(k.type==="open"&&(k.isOpen=!0),k.type==="close"&&(k.isClose=!0),k.nodes||(k.type="text"),k.invalid=!0)});let S=s[s.length-1],A=S.nodes.indexOf(i);S.nodes.splice(A,1,...i.nodes)}while(s.length>0);return g({type:"eos"}),o};fl.exports=sy});var gl=V((zI,ml)=>{"use strict";var pl=fr(),iy=nl(),ay=sl(),cy=dl(),pe=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=pe.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(pe.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};pe.parse=(e,t={})=>cy(e,t);pe.stringify=(e,t={})=>pl(typeof e=="string"?pe.parse(e,t):e,t);pe.compile=(e,t={})=>(typeof e=="string"&&(e=pe.parse(e,t)),iy(e,t));pe.expand=(e,t={})=>{typeof e=="string"&&(e=pe.parse(e,t));let n=ay(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};pe.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?pe.compile(e,t):pe.expand(e,t);ml.exports=pe});var tn=V((VI,yl)=>{"use strict";var uy=ze("path"),we="\\\\/",hl=`[^${we}]`,ly=0,Ge="\\.",fy="\\+",dy="\\?",mr="\\/",py="(?=.)",_l="[^/]",ts=`(?:${mr}|$)`,Sl=`(?:^|${mr})`,ns=`${Ge}{1,2}${ts}`,my=`(?!${Ge})`,gy=`(?!${Sl}${ns})`,hy=`(?!${Ge}{0,1}${ts})`,_y=`(?!${ns})`,Sy=`[^.${mr}]`,Ey=`${_l}*?`,El={DOT_LITERAL:Ge,PLUS_LITERAL:fy,QMARK_LITERAL:dy,SLASH_LITERAL:mr,ONE_CHAR:py,QMARK:_l,END_ANCHOR:ts,DOTS_SLASH:ns,NO_DOT:my,NO_DOTS:gy,NO_DOT_SLASH:hy,NO_DOTS_SLASH:_y,QMARK_NO_DOT:Sy,STAR:Ey,START_ANCHOR:Sl},yy={...El,SLASH_LITERAL:`[${we}]`,QMARK:hl,STAR:`${hl}*?`,DOTS_SLASH:`${Ge}{1,2}(?:[${we}]|$)`,NO_DOT:`(?!${Ge})`,NO_DOTS:`(?!(?:^|[${we}])${Ge}{1,2}(?:[${we}]|$))`,NO_DOT_SLASH:`(?!${Ge}{0,1}(?:[${we}]|$))`,NO_DOTS_SLASH:`(?!${Ge}{1,2}(?:[${we}]|$))`,QMARK_NO_DOT:`[^.${we}]`,START_ANCHOR:`(?:^|[${we}])`,END_ANCHOR:`(?:[${we}]|$)`},Ry={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};yl.exports={DEFAULT_MAX_EXTGLOB_RECURSION:ly,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Ry,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:uy.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?yy:El}}});var nn=V(ce=>{"use strict";var Cy=ze("path"),Ay=process.platform==="win32",{REGEX_BACKSLASH:ky,REGEX_REMOVE_BACKSLASH:by,REGEX_SPECIAL_CHARS:xy,REGEX_SPECIAL_CHARS_GLOBAL:Iy}=tn();ce.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);ce.hasRegexChars=e=>xy.test(e);ce.isRegexChar=e=>e.length===1&&ce.hasRegexChars(e);ce.escapeRegex=e=>e.replace(Iy,"\\$1");ce.toPosixSlashes=e=>e.replace(ky,"/");ce.removeBackslashes=e=>e.replace(by,t=>t==="\\"?"":t);ce.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};ce.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:Ay===!0||Cy.sep==="\\";ce.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?ce.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};ce.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};ce.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var Ol=V((YI,Il)=>{"use strict";var Rl=nn(),{CHAR_ASTERISK:rs,CHAR_AT:Oy,CHAR_BACKWARD_SLASH:rn,CHAR_COMMA:Ty,CHAR_DOT:os,CHAR_EXCLAMATION_MARK:ss,CHAR_FORWARD_SLASH:xl,CHAR_LEFT_CURLY_BRACE:is,CHAR_LEFT_PARENTHESES:as,CHAR_LEFT_SQUARE_BRACKET:Py,CHAR_PLUS:wy,CHAR_QUESTION_MARK:Cl,CHAR_RIGHT_CURLY_BRACE:Ny,CHAR_RIGHT_PARENTHESES:Al,CHAR_RIGHT_SQUARE_BRACKET:vy}=tn(),kl=e=>e===xl||e===rn,bl=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},My=(e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],a=[],c=e,l=-1,u=0,d=0,f=!1,p=!1,g=!1,S=!1,A=!1,k=!1,O=!1,I=!1,v=!1,T=!1,K=0,D,x,w={value:"",depth:0,isGlob:!1},L=()=>l>=r,m=()=>c.charCodeAt(l+1),b=()=>(D=x,c.charCodeAt(++l));for(;l<r;){x=b();let ie;if(x===rn){O=w.backslashes=!0,x=b(),x===is&&(k=!0);continue}if(k===!0||x===is){for(K++;L()!==!0&&(x=b());){if(x===rn){O=w.backslashes=!0,b();continue}if(x===is){K++;continue}if(k!==!0&&x===os&&(x=b())===os){if(f=w.isBrace=!0,g=w.isGlob=!0,T=!0,o===!0)continue;break}if(k!==!0&&x===Ty){if(f=w.isBrace=!0,g=w.isGlob=!0,T=!0,o===!0)continue;break}if(x===Ny&&(K--,K===0)){k=!1,f=w.isBrace=!0,T=!0;break}}if(o===!0)continue;break}if(x===xl){if(s.push(l),i.push(w),w={value:"",depth:0,isGlob:!1},T===!0)continue;if(D===os&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(x===wy||x===Oy||x===rs||x===Cl||x===ss)===!0&&m()===as){if(g=w.isGlob=!0,S=w.isExtglob=!0,T=!0,x===ss&&l===u&&(v=!0),o===!0){for(;L()!==!0&&(x=b());){if(x===rn){O=w.backslashes=!0,x=b();continue}if(x===Al){g=w.isGlob=!0,T=!0;break}}continue}break}if(x===rs){if(D===rs&&(A=w.isGlobstar=!0),g=w.isGlob=!0,T=!0,o===!0)continue;break}if(x===Cl){if(g=w.isGlob=!0,T=!0,o===!0)continue;break}if(x===Py){for(;L()!==!0&&(ie=b());){if(ie===rn){O=w.backslashes=!0,b();continue}if(ie===vy){p=w.isBracket=!0,g=w.isGlob=!0,T=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===ss&&l===u){I=w.negated=!0,u++;continue}if(n.noparen!==!0&&x===as){if(g=w.isGlob=!0,o===!0){for(;L()!==!0&&(x=b());){if(x===as){O=w.backslashes=!0,x=b();continue}if(x===Al){T=!0;break}}continue}break}if(g===!0){if(T=!0,o===!0)continue;break}}n.noext===!0&&(S=!1,g=!1);let H=c,le="",h="";u>0&&(le=c.slice(0,u),c=c.slice(u),d-=u),H&&g===!0&&d>0?(H=c.slice(0,d),h=c.slice(d)):g===!0?(H="",h=c):H=c,H&&H!==""&&H!=="/"&&H!==c&&kl(H.charCodeAt(H.length-1))&&(H=H.slice(0,-1)),n.unescape===!0&&(h&&(h=Rl.removeBackslashes(h)),H&&O===!0&&(H=Rl.removeBackslashes(H)));let _={prefix:le,input:e,start:u,base:H,glob:h,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:A,negated:I,negatedExtglob:v};if(n.tokens===!0&&(_.maxDepth=0,kl(x)||i.push(w),_.tokens=i),n.parts===!0||n.tokens===!0){let ie;for(let F=0;F<s.length;F++){let Ae=ie?ie+1:u,ke=s[F],fe=e.slice(Ae,ke);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=le):i[F].value=fe,bl(i[F]),_.maxDepth+=i[F].depth),(F!==0||fe!=="")&&a.push(fe),ie=ke}if(ie&&ie+1<e.length){let F=e.slice(ie+1);a.push(F),n.tokens&&(i[i.length-1].value=F,bl(i[i.length-1]),_.maxDepth+=i[i.length-1].depth)}_.slashes=s,_.parts=a}return _};Il.exports=My});var vl=V((XI,Nl)=>{"use strict";var on=tn(),se=nn(),{MAX_LENGTH:gr,POSIX_REGEX_SOURCE:Ly,REGEX_NON_SPECIAL_CHARS:Hy,REGEX_SPECIAL_CHARS_BACKREF:Uy,REPLACEMENTS:Tl}=on,Dy=(e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>se.escapeRegex(o)).join("..")}return n},Tt=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,Pl=e=>{let t=[],n=0,r=0,o=0,s="",i=!1;for(let a of e){if(i===!0){s+=a,i=!1;continue}if(a==="\\"){s+=a,i=!0;continue}if(a==='"'){o=o===1?0:1,s+=a;continue}if(o===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(s),s="";continue}}}s+=a}return t.push(s),t},Fy=e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},wl=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(Fy(t))return t.replace(/\\(.)/g,"$1")},$y=e=>{let t=e.map(wl).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],s=t[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},cs=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<e.length;i++){let a=e[i];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){o=o===1?0:1;continue}if(o!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===!0&&i!==e.length-1?void 0:{type:e[0],body:e.slice(2,i),end:i}}}}},jy=e=>{let t=0,n=[];for(;t<e.length;){let o=cs(e.slice(t),!1);if(!o||o.type!=="*")return;let s=Pl(o.body).map(a=>a.trim());if(s.length!==1)return;let i=wl(s[0]);if(!i||i.length!==1)return;n.push(i),t+=o.end+1}return n.length<1?void 0:`${n.length===1?se.escapeRegex(n[0]):`[${n.map(o=>se.escapeRegex(o)).join("")}]`}*`},By=e=>{let t=0,n=e.trim(),r=cs(n);for(;r;)t++,n=r.body.trim(),r=cs(n);return t},Ky=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:on.DEFAULT_MAX_EXTGLOB_RECURSION,r=Pl(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||$y(r)))return{risky:!0};for(let o of r){let s=jy(o);if(s)return{risky:!0,safeOutput:s};if(By(o)>n)return{risky:!0}}return{risky:!1}},us=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=Tl[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(gr,n.maxLength):gr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],a=n.capture?"":"?:",c=se.isWindows(t),l=on.globChars(c),u=on.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:A,NO_DOT_SLASH:k,NO_DOTS_SLASH:O,QMARK:I,QMARK_NO_DOT:v,STAR:T,START_ANCHOR:K}=l,D=C=>`(${a}(?:(?!${K}${C.dot?S:d}).)*?)`,x=n.dot?"":A,w=n.dot?I:v,L=n.bash===!0?D(n):T;n.capture&&(L=`(${L})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};e=se.removePrefix(e,m),o=e.length;let b=[],H=[],le=[],h=s,_,ie=()=>m.index===o-1,F=m.peek=(C=1)=>e[m.index+C],Ae=m.advance=()=>e[++m.index]||"",ke=()=>e.slice(m.index+1),fe=(C="",Y=0)=>{m.consumed+=C,m.index+=Y},_n=C=>{m.output+=C.output!=null?C.output:C.value,fe(C.value)},Ld=()=>{let C=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)Ae(),m.start++,C++;return C%2===0?!1:(m.negated=!0,m.start++,!0)},Sn=C=>{m[C]++,le.push(C)},We=C=>{m[C]--,le.pop()},N=C=>{if(h.type==="globstar"){let Y=m.braces>0&&(C.type==="comma"||C.type==="brace"),R=C.extglob===!0||b.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!Y&&!R&&(m.output=m.output.slice(0,-h.output.length),h.type="star",h.value="*",h.output=L,m.output+=h.output)}if(b.length&&C.type!=="paren"&&(b[b.length-1].inner+=C.value),(C.value||C.output)&&_n(C),h&&h.type==="text"&&C.type==="text"){h.value+=C.value,h.output=(h.output||"")+C.value;return}C.prev=h,i.push(C),h=C},En=(C,Y)=>{let R={...u[Y],conditions:1,inner:""};R.prev=h,R.parens=m.parens,R.output=m.output,R.startIndex=m.index,R.tokensIndex=i.length;let P=(n.capture?"(":"")+R.open;Sn("parens"),N({type:C,value:Y,output:m.output?"":g}),N({type:"paren",extglob:!0,value:Ae(),output:P}),b.push(R)},Hd=C=>{let Y=e.slice(C.startIndex,m.index+1),R=e.slice(C.startIndex+2,m.index),P=Ky(R,n);if((C.type==="plus"||C.type==="star")&&P.risky){let G=P.safeOutput?(C.output?"":g)+(n.capture?`(${P.safeOutput})`:P.safeOutput):void 0,be=i[C.tokensIndex];be.type="text",be.value=Y,be.output=G||se.escapeRegex(Y);for(let xe=C.tokensIndex+1;xe<i.length;xe++)i[xe].value="",i[xe].output="",delete i[xe].suffix;m.output=C.output+be.output,m.backtrack=!0,N({type:"paren",extglob:!0,value:_,output:""}),We("parens");return}let z=C.close+(n.capture?")":""),re;if(C.type==="negate"){let G=L;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(G=D(n)),(G!==L||ie()||/^\)+$/.test(ke()))&&(z=C.close=`)$))${G}`),C.inner.includes("*")&&(re=ke())&&/^\.[^\\/.]+$/.test(re)){let be=us(re,{...t,fastpaths:!1}).output;z=C.close=`)${be})${G})`}C.prev.type==="bos"&&(m.negatedExtglob=!0)}N({type:"paren",extglob:!0,value:_,output:z}),We("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,Y=e.replace(Uy,(R,P,z,re,G,be)=>re==="\\"?(C=!0,R):re==="?"?P?P+re+(G?I.repeat(G.length):""):be===0?w+(G?I.repeat(G.length):""):I.repeat(z.length):re==="."?d.repeat(z.length):re==="*"?P?P+re+(G?L:""):L:P?R:`\\${R}`);return C===!0&&(n.unescape===!0?Y=Y.replace(/\\/g,""):Y=Y.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),Y===e&&n.contains===!0?(m.output=e,m):(m.output=se.wrapOutput(Y,m,t),m)}for(;!ie();){if(_=Ae(),_==="\0")continue;if(_==="\\"){let R=F();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){_+="\\",N({type:"text",value:_});continue}let P=/^\\+/.exec(ke()),z=0;if(P&&P[0].length>2&&(z=P[0].length,m.index+=z,z%2!==0&&(_+="\\")),n.unescape===!0?_=Ae():_+=Ae(),m.brackets===0){N({type:"text",value:_});continue}}if(m.brackets>0&&(_!=="]"||h.value==="["||h.value==="[^")){if(n.posix!==!1&&_===":"){let R=h.value.slice(1);if(R.includes("[")&&(h.posix=!0,R.includes(":"))){let P=h.value.lastIndexOf("["),z=h.value.slice(0,P),re=h.value.slice(P+2),G=Ly[re];if(G){h.value=z+G,m.backtrack=!0,Ae(),!s.output&&i.indexOf(h)===1&&(s.output=g);continue}}}(_==="["&&F()!==":"||_==="-"&&F()==="]")&&(_=`\\${_}`),_==="]"&&(h.value==="["||h.value==="[^")&&(_=`\\${_}`),n.posix===!0&&_==="!"&&h.value==="["&&(_="^"),h.value+=_,_n({value:_});continue}if(m.quotes===1&&_!=='"'){_=se.escapeRegex(_),h.value+=_,_n({value:_});continue}if(_==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&N({type:"text",value:_});continue}if(_==="("){Sn("parens"),N({type:"paren",value:_});continue}if(_===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Tt("opening","("));let R=b[b.length-1];if(R&&m.parens===R.parens+1){Hd(b.pop());continue}N({type:"paren",value:_,output:m.parens?")":"\\)"}),We("parens");continue}if(_==="["){if(n.nobracket===!0||!ke().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Tt("closing","]"));_=`\\${_}`}else Sn("brackets");N({type:"bracket",value:_});continue}if(_==="]"){if(n.nobracket===!0||h&&h.type==="bracket"&&h.value.length===1){N({type:"text",value:_,output:`\\${_}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Tt("opening","["));N({type:"text",value:_,output:`\\${_}`});continue}We("brackets");let R=h.value.slice(1);if(h.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(_=`/${_}`),h.value+=_,_n({value:_}),n.literalBrackets===!1||se.hasRegexChars(R))continue;let P=se.escapeRegex(h.value);if(m.output=m.output.slice(0,-h.value.length),n.literalBrackets===!0){m.output+=P,h.value=P;continue}h.value=`(${a}${P}|${h.value})`,m.output+=h.value;continue}if(_==="{"&&n.nobrace!==!0){Sn("braces");let R={type:"brace",value:_,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};H.push(R),N(R);continue}if(_==="}"){let R=H[H.length-1];if(n.nobrace===!0||!R){N({type:"text",value:_,output:_});continue}let P=")";if(R.dots===!0){let z=i.slice(),re=[];for(let G=z.length-1;G>=0&&(i.pop(),z[G].type!=="brace");G--)z[G].type!=="dots"&&re.unshift(z[G].value);P=Dy(re,n),m.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let z=m.output.slice(0,R.outputIndex),re=m.tokens.slice(R.tokensIndex);R.value=R.output="\\{",_=P="\\}",m.output=z;for(let G of re)m.output+=G.output||G.value}N({type:"brace",value:_,output:P}),We("braces"),H.pop();continue}if(_==="|"){b.length>0&&b[b.length-1].conditions++,N({type:"text",value:_});continue}if(_===","){let R=_,P=H[H.length-1];P&&le[le.length-1]==="braces"&&(P.comma=!0,R="|"),N({type:"comma",value:_,output:R});continue}if(_==="/"){if(h.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",i.pop(),h=s;continue}N({type:"slash",value:_,output:p});continue}if(_==="."){if(m.braces>0&&h.type==="dot"){h.value==="."&&(h.output=d);let R=H[H.length-1];h.type="dots",h.output+=_,h.value+=_,R.dots=!0;continue}if(m.braces+m.parens===0&&h.type!=="bos"&&h.type!=="slash"){N({type:"text",value:_,output:d});continue}N({type:"dot",value:_,output:d});continue}if(_==="?"){if(!(h&&h.value==="(")&&n.noextglob!==!0&&F()==="("&&F(2)!=="?"){En("qmark",_);continue}if(h&&h.type==="paren"){let P=F(),z=_;if(P==="<"&&!se.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(h.value==="("&&!/[!=<:]/.test(P)||P==="<"&&!/<([!=]|\w+>)/.test(ke()))&&(z=`\\${_}`),N({type:"text",value:_,output:z});continue}if(n.dot!==!0&&(h.type==="slash"||h.type==="bos")){N({type:"qmark",value:_,output:v});continue}N({type:"qmark",value:_,output:I});continue}if(_==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){En("negate",_);continue}if(n.nonegate!==!0&&m.index===0){Ld();continue}}if(_==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){En("plus",_);continue}if(h&&h.value==="("||n.regex===!1){N({type:"plus",value:_,output:f});continue}if(h&&(h.type==="bracket"||h.type==="paren"||h.type==="brace")||m.parens>0){N({type:"plus",value:_});continue}N({type:"plus",value:f});continue}if(_==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){N({type:"at",extglob:!0,value:_,output:""});continue}N({type:"text",value:_});continue}if(_!=="*"){(_==="$"||_==="^")&&(_=`\\${_}`);let R=Hy.exec(ke());R&&(_+=R[0],m.index+=R[0].length),N({type:"text",value:_});continue}if(h&&(h.type==="globstar"||h.star===!0)){h.type="star",h.star=!0,h.value+=_,h.output=L,m.backtrack=!0,m.globstar=!0,fe(_);continue}let C=ke();if(n.noextglob!==!0&&/^\([^?]/.test(C)){En("star",_);continue}if(h.type==="star"){if(n.noglobstar===!0){fe(_);continue}let R=h.prev,P=R.prev,z=R.type==="slash"||R.type==="bos",re=P&&(P.type==="star"||P.type==="globstar");if(n.bash===!0&&(!z||C[0]&&C[0]!=="/")){N({type:"star",value:_,output:""});continue}let G=m.braces>0&&(R.type==="comma"||R.type==="brace"),be=b.length&&(R.type==="pipe"||R.type==="paren");if(!z&&R.type!=="paren"&&!G&&!be){N({type:"star",value:_,output:""});continue}for(;C.slice(0,3)==="/**";){let xe=e[m.index+4];if(xe&&xe!=="/")break;C=C.slice(3),fe("/**",3)}if(R.type==="bos"&&ie()){h.type="globstar",h.value+=_,h.output=D(n),m.output=h.output,m.globstar=!0,fe(_);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&!re&&ie()){m.output=m.output.slice(0,-(R.output+h.output).length),R.output=`(?:${R.output}`,h.type="globstar",h.output=D(n)+(n.strictSlashes?")":"|$)"),h.value+=_,m.globstar=!0,m.output+=R.output+h.output,fe(_);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&C[0]==="/"){let xe=C[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(R.output+h.output).length),R.output=`(?:${R.output}`,h.type="globstar",h.output=`${D(n)}${p}|${p}${xe})`,h.value+=_,m.output+=R.output+h.output,m.globstar=!0,fe(_+Ae()),N({type:"slash",value:"/",output:""});continue}if(R.type==="bos"&&C[0]==="/"){h.type="globstar",h.value+=_,h.output=`(?:^|${p}|${D(n)}${p})`,m.output=h.output,m.globstar=!0,fe(_+Ae()),N({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-h.output.length),h.type="globstar",h.output=D(n),h.value+=_,m.output+=h.output,m.globstar=!0,fe(_);continue}let Y={type:"star",value:_,output:L};if(n.bash===!0){Y.output=".*?",(h.type==="bos"||h.type==="slash")&&(Y.output=x+Y.output),N(Y);continue}if(h&&(h.type==="bracket"||h.type==="paren")&&n.regex===!0){Y.output=_,N(Y);continue}(m.index===m.start||h.type==="slash"||h.type==="dot")&&(h.type==="dot"?(m.output+=k,h.output+=k):n.dot===!0?(m.output+=O,h.output+=O):(m.output+=x,h.output+=x),F()!=="*"&&(m.output+=g,h.output+=g)),N(Y)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing","]"));m.output=se.escapeLast(m.output,"["),We("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing",")"));m.output=se.escapeLast(m.output,"("),We("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing","}"));m.output=se.escapeLast(m.output,"{"),We("braces")}if(n.strictSlashes!==!0&&(h.type==="star"||h.type==="bracket")&&N({type:"maybe_slash",value:"",output:`${p}?`}),m.backtrack===!0){m.output="";for(let C of m.tokens)m.output+=C.output!=null?C.output:C.value,C.suffix&&(m.output+=C.suffix)}return m};us.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(gr,n.maxLength):gr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=Tl[e]||e;let s=se.isWindows(t),{DOT_LITERAL:i,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:g}=on.globChars(s),S=n.dot?d:u,A=n.dot?f:u,k=n.capture?"":"?:",O={negated:!1,prefix:""},I=n.bash===!0?".*?":p;n.capture&&(I=`(${I})`);let v=x=>x.noglobstar===!0?I:`(${k}(?:(?!${g}${x.dot?l:i}).)*?)`,T=x=>{switch(x){case"*":return`${S}${c}${I}`;case".*":return`${i}${c}${I}`;case"*.*":return`${S}${I}${i}${c}${I}`;case"*/*":return`${S}${I}${a}${c}${A}${I}`;case"**":return S+v(n);case"**/*":return`(?:${S}${v(n)}${a})?${A}${c}${I}`;case"**/*.*":return`(?:${S}${v(n)}${a})?${A}${I}${i}${c}${I}`;case"**/.*":return`(?:${S}${v(n)}${a})?${i}${c}${I}`;default:{let w=/^(.*?)\.(\w+)$/.exec(x);if(!w)return;let L=T(w[1]);return L?L+i+w[2]:void 0}}},K=se.removePrefix(e,O),D=T(K);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};Nl.exports=us});var Ll=V((qI,Ml)=>{"use strict";var Gy=ze("path"),Wy=Ol(),ls=vl(),fs=nn(),zy=tn(),Vy=e=>e&&typeof e=="object"&&!Array.isArray(e),ee=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(f=>ee(f,t,n));return f=>{for(let p of u){let g=p(f);if(g)return g}return!1}}let r=Vy(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},s=fs.isWindows(t),i=r?ee.compileRe(e,t):ee.makeRe(e,t,!1,!0),a=i.state;delete i.state;let c=()=>!1;if(o.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};c=ee(o.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:g}=ee.test(u,i,t,{glob:e,posix:s}),S={glob:e,state:a,regex:i,posix:s,input:u,output:g,match:p,isMatch:f};return typeof o.onResult=="function"&&o.onResult(S),f===!1?(S.isMatch=!1,d?S:!1):c(u)?(typeof o.onIgnore=="function"&&o.onIgnore(S),S.isMatch=!1,d?S:!1):(typeof o.onMatch=="function"&&o.onMatch(S),d?S:!0)};return n&&(l.state=a),l};ee.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let s=n||{},i=s.format||(o?fs.toPosixSlashes:null),a=e===r,c=a&&i?i(e):e;return a===!1&&(c=i?i(e):e,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=ee.matchBase(e,t,n,o):a=t.exec(c)),{isMatch:!!a,match:a,output:c}};ee.matchBase=(e,t,n,r=fs.isWindows(n))=>(t instanceof RegExp?t:ee.makeRe(t,n)).test(Gy.basename(e));ee.isMatch=(e,t,n)=>ee(t,n)(e);ee.parse=(e,t)=>Array.isArray(e)?e.map(n=>ee.parse(n,t)):ls(e,{...t,fastpaths:!1});ee.scan=(e,t)=>Wy(e,t);ee.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},s=o.contains?"":"^",i=o.contains?"":"$",a=`${s}(?:${e.output})${i}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let c=ee.toRegex(a,t);return r===!0&&(c.state=e),c};ee.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=ls.fastpaths(e,t)),o.output||(o=ls(e,t)),ee.compileRe(o,t,n,r)};ee.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};ee.constants=zy;Ml.exports=ee});var Ul=V((ZI,Hl)=>{"use strict";Hl.exports=Ll()});var Kl=V((QI,Bl)=>{"use strict";var Fl=ze("util"),$l=gl(),Ne=Ul(),ds=nn(),Dl=e=>e===""||e==="./",jl=e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},J=(e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,s=new Set,i=0,a=u=>{s.add(u.output),n&&n.onResult&&n.onResult(u)};for(let u=0;u<t.length;u++){let d=Ne(String(t[u]),{...n,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&i++;for(let p of e){let g=d(p,!0);(f?!g.isMatch:g.isMatch)&&(f?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let l=(i===t.length?[...s]:[...o]).filter(u=>!r.has(u));if(n&&l.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(u=>u.replace(/\\/g,"")):t}return l};J.match=J;J.matcher=(e,t)=>Ne(e,t);J.isMatch=(e,t,n)=>Ne(t,n)(e);J.any=J.isMatch;J.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],s=a=>{n.onResult&&n.onResult(a),o.push(a.output)},i=new Set(J(e,t,{...n,onResult:s}));for(let a of o)i.has(a)||r.add(a);return[...r]};J.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Fl.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>J.contains(e,r,n));if(typeof t=="string"){if(Dl(e)||Dl(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return J.isMatch(e,t,{...n,contains:!0})};J.matchKeys=(e,t,n)=>{if(!ds.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=J(Object.keys(e),t,n),o={};for(let s of r)o[s]=e[s];return o};J.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Ne(String(o),n);if(r.some(i=>s(i)))return!0}return!1};J.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Ne(String(o),n);if(!r.every(i=>s(i)))return!1}return!0};J.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Fl.inspect(e)}"`);return[].concat(t).every(r=>Ne(r,n)(e))};J.capture=(e,t,n)=>{let r=ds.isWindows(n),s=Ne.makeRe(String(e),{...n,capture:!0}).exec(r?ds.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};J.makeRe=(...e)=>Ne.makeRe(...e);J.scan=(...e)=>Ne.scan(...e);J.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of $l(String(r),t))n.push(Ne.parse(o,t));return n};J.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!jl(e)?[e]:$l(e,t)};J.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return J.braces(e,{...t,expand:!0})};J.hasBraces=jl;Bl.exports=J});import{realpathSync as VA}from"node:fs";import{resolve as JA}from"node:path";import{fileURLToPath as YA,pathToFileURL as XA}from"node:url";import{createHash as Kd}from"node:crypto";import{homedir as Gd}from"node:os";import{dirname as lk,join as Wd,parse as fk,resolve as dk}from"node:path";var qs="EV_AI_LAUNCHER_VERSION";var Zs="EV_AI_HOOK_SOURCE",Qs="EV_AI_HOOK_FALLBACK_REASON",ei="EV_AI_LAUNCHER_SCOPE",Mr="EV_AI_LAUNCHER_READY_FD";var ti="--defer-user-spec",ni=Buffer.from([1]);var ek=1024*1024,tk=4*1024*1024,nk=64*1024,rk=64*1024,ok=64*1024;var Lr=4096,sk=4*1024*1024;var oi="https://hooks.ev-ai.ai",Rn=".claude/ev-ai-runtime-report.json",si="config.json",mk=1024*1024,zd=new Set(["localhost","127.0.0.1","[::1]","::1"]),Vd=["claude","cursor","codex"],Cn=[Rn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Hr=/^[A-Za-z0-9._~-]+$/;function An(e){return e!==void 0&&Vd.includes(e)}function yn(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function Ur(e){let t,n,r,o,s;for(let i=0;i<e.length;i++){let a=e[i];if(a!==void 0){if(a==="--runner"){let c=yn(e,i);t=c.value,i=c.next;continue}if(a.startsWith("--runner=")){t=a.slice(9);continue}if(a==="--url"){let c=yn(e,i);c.value&&(r=c.value),i=c.next;continue}if(a.startsWith("--url=")){r=a.slice(6);continue}if(a==="--token"){let c=yn(e,i);c.value&&(o=c.value),i=c.next;continue}if(a.startsWith("--token=")){o=a.slice(8);continue}if(a==="--base-url"){let c=yn(e,i);c.value&&(s=c.value),i=c.next;continue}if(a.startsWith("--base-url=")){s=a.slice(11);continue}a!==ti&&!a.startsWith("-")&&n===void 0&&(n=a)}}return{runner:An(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s}}function kn(e,t=oi){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function Dr(e=Gd()){return Wd(e,".ev-ai",si)}function ii(e,t){return{...e,...t}}function ri(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}function bn(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?zd.has(t.hostname):!1}catch{return!1}}function Fr(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}function Et(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!bn(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Fr(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Hr.test(n))return`org token must match ${Hr.source} (got: ${n})`;if(ri(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(ri(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function Ut(e){return new URL(e).toString()}function $r(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?kn(n):""}function xn(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}function ai(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=kn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=Et(n);return r?{problem:r}:{url:Ut(n)}}function Dt(e){if(Et(e))return;let t;try{t=new URL(e)}catch{return}let n=Fr(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),s=o.length>0?`/${o.join("/")}`:"",i=`${t.origin}${s}/${n}`;return Kd("sha256").update(i).digest("hex").slice(0,32)}var Je=2,ci="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ie="ev-ai-agent-hook";function Jd(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function In(e){let t=Jd(e);return t===Ie||t===`${Ie}.exe`}var ui="https://cdn.ev-ai.ai/agent-hook";var jr=`current/${Ie}`,Br=`.ev-ai/agent-hook/${Ie}`,li=5e3,fi=5e3,Kr=3e3;var On=3e3,di=1500,pi=4*1024,Gr=256*1024,Yd=4*1024,mi=32*1024,Le="1.3.2",Tn=`@ev-ai/agent-hook@${Le}`,gi="ev-ai runtime report";import{chmodSync as ca,cpSync as ua,existsSync as Xe,mkdirSync as co,readFileSync as gm,rmSync as Fn,symlinkSync as hm,writeFileSync as _m}from"node:fs";import{homedir as De}from"node:os";import{dirname as uo,isAbsolute as Sm,join as W,relative as la,resolve as ia,sep as Em}from"node:path";import{fileURLToPath as ym}from"node:url";import{existsSync as Xd,readdirSync as hi}from"node:fs";import{homedir as Pn}from"node:os";import{join as ae}from"node:path";function _i(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ae(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Wr(e=process.platform){let t=_i(e),n=[ae(t,"managed-settings.json")],r=ae(t,"managed-settings.d");try{if(!Xd(r))return n;let o=hi(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ae(r,s));n.push(...o)}catch{}return n}function zr(e=process.platform,t=Pn()){return{serverManaged:ae(t,".claude","remote-settings.json"),fileBased:Wr(e)}}function qd(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ae(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function Zd(e=process.platform,t=Pn()){let n=[ae(qd(e),"hooks.json")],r=ae(t,".cursor","managed");try{for(let o of hi(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ae(r,o.name,"hooks.json"))}catch{}return n}function Qd(e=process.platform,t=Pn()){let n=e==="win32"?ae(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ae(n,"requirements.toml")];return e!=="win32"&&r.push(ae(n,"managed_config.toml")),r.push(ae(t,".codex","managed_config.toml"),ae(n,"config.toml")),r}function wn(e,t=process.platform,n=Pn()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=zr(t,n);return[r,...o]}case"cursor":return Zd(t,n);default:return Qd(t,n)}}import{createHash as Ui,randomBytes as bp}from"node:crypto";import{existsSync as Di,mkdirSync as Zr,readFileSync as Fi,unlinkSync as $i,writeFileSync as ji}from"node:fs";import{homedir as Qr}from"node:os";import{dirname as Ln,join as eo,resolve as xp}from"node:path";var ep=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),tp=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function de(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||tp.has(n)||r.includes("[bot]")||ep.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}import{existsSync as dp,readFileSync as pp}from"node:fs";import{hostname as Ii,userInfo as mp}from"node:os";import{createHash as np,randomBytes as rp}from"node:crypto";import{existsSync as Vr,mkdirSync as op,readdirSync as sp,readFileSync as ip,renameSync as Si,statSync as Ci,unlinkSync as Ei,writeFileSync as ap}from"node:fs";import{basename as cp,dirname as yi,join as Ai,relative as up}from"node:path";function E(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
|
|
15
|
-
`)}function Ft(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function $t(e){return np("sha256").update(e).digest("hex").slice(0,32)}function me(e,t){op(yi(e),{recursive:!0});let n=Ai(yi(e),`.${cp(e)}.${process.pid}.${rp(4).toString("hex")}.tmp`);try{ap(n,t,"utf8");try{Si(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){Ei(e),Si(n,e);return}throw r}}catch(r){try{Ei(n)}catch{}throw r}}function Nn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}function Jr(){process.stdout.write('{"continue":true}')}function U(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function jt(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}async function vn(e){return new Promise(t=>{let n="",r=!1,o=i=>{r||(r=!0,clearTimeout(s),t(i||"{}"))},s=setTimeout(()=>{o(n)},e);if(process.stdin.isTTY){o("{}");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",i=>{n+=i}),process.stdin.on("end",()=>{o(n)}),process.stdin.on("error",()=>{o(n)}),process.stdin.resume()})}async function Ee(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:s}=await import("node:util"),i=s(o);try{let{stdout:a}=await i(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:a.trim()}}catch(a){let c=a,l=typeof c.code=="number"?c.code:typeof c.status=="number"?c.status:void 0;return{ok:!1,code:l,spawnFailed:l===void 0}}}async function te(e,t,n=3e3,r={}){let o=await Ee(e,t,n,r);return o.ok?o.stdout:""}async function Yr(e=process.cwd()){let t=await Ee("git",["rev-parse","--show-toplevel"],2e3,{cwd:e});if(t.ok&&t.stdout)return{root:t.stdout,inGitRepo:!0};if(U("EV_AI_HOOK_DEBUG")){let r=t.ok?"empty stdout":t.spawnFailed?"spawn failed":`exit ${String(t.code??"unknown")}`;E(`DEBUG: git rev-parse --show-toplevel failed (${r}) cwd=${e}`)}let n=U("CURSOR_PROJECT_DIR")??U("CLAUDE_PROJECT_DIR");if(n&&Vr(n)){let r=await Ee("git",["rev-parse","--show-toplevel"],2e3,{cwd:n});return r.ok&&r.stdout?{root:r.stdout,inGitRepo:!0}:{root:n,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function He(e=process.cwd()){return(await Yr(e)).root}function ge(e,t){try{return JSON.parse(e)}catch{return t}}var Ri=new Map;function lp(e){return e.charCodeAt(0)===65279?e.slice(1):e}function fp(e){let t;try{t=ip(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(lp(t))}}catch{return{ok:!1,reason:"parse"}}}function ki(e){let t=Ri.get(e);if(t!==void 0)return t;let n=fp(e);return Ri.set(e,n),n}function bi(e){return ki(e)}function oe(e,t){let n=ki(e);return n.ok?n.value:t}function it(e){return typeof e=="string"?e:""}function Ue(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let s of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[s]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}function M(e,t){let n=Ue(e,t);return typeof n=="string"?n:""}var Ye=500;function xi(e,t=2){if(!Vr(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=sp(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=Ai(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:up(e,l),size:Ci(l).size})}catch{continue}if(n.length>=Ye){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function Xr(e){return Vr(e)?{present:!0,size:Ci(e).size}:{present:!1,size:0}}function yt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Oi(e=process.env){return yt(X("CURSOR_SANDBOX",e))}var gp=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function hp(e){return gp.some(t=>!!X(t,e))}function _p(e){if(X("KUBERNETES_SERVICE_HOST",e)||yt(X("REMOTE_CONTAINERS",e))||yt(X("DEVCONTAINER",e)))return!0;try{if(dp("/.dockerenv")||pp("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function Ti(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!X(t,e))}function Sp(e,t=process.platform){return Ti(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!X(n,e)):!1}function Ep(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function yp(e){return e==="linux"}function X(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return U(e)}function Rp(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Cp(X("CURSOR_VERSION",n))}function Cp(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function qr(e){if(Ep(e.sessionId))return!0;let t=e.hostname??Ii(),n=e.osUser??wi(e.env);return Rp(t,n,e.env)}function Ap(e){return yt(X("CURSOR_AGENT",e.env))?!0:qr(e)}function kp(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(X("TERM",e)??X("TERM_PROGRAM",e))||(X("SSH_TTY",e)??X("SSH_CONNECTION",e))||(X("__CFBundleIdentifier",e)??X("XPC_SERVICE_NAME",e))||Ti(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!X(t,e))||X("SESSIONNAME",e))}function Bt(e={}){let t=e.env;if(X("GITHUB_ACTIONS",t))return"github_actions";if(yt(X("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Sp(t,n)&&Ap(e)&&(yt(X("CURSOR_AGENT",t))||yp(n)))return"cursor_cloud";if(X("CODESPACES",t)||X("CODESPACE_NAME",t))return"codespaces";if(X("GITLAB_CI",t))return"gitlab_ci";if(hp(t))return"managed";let r=X("CI",t);return r&&r!=="false"&&r!=="0"?"managed":_p(t)?"container":kp(t)?"interactive":"unknown"}async function Pi(){return await te("systemd-detect-virt",[],1e3)}function wi(e=process.env,t=mp){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}async function Ni(){let e=process.platform==="darwin"?"Darwin":process.platform==="win32"?"Windows_NT":"Linux",t="";if(process.platform==="darwin")t=await te("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:s}=await import("node:fs"),i=s("/etc/os-release","utf8"),a=i.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],c=i.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];t=a??c??""}catch{t=await te("lsb_release",["-sd"],1e3).then(s=>s.replace(/^"|"$/g,""))}t||(t=await te("uname",["-r"],1e3))}else t=await te("ver",[],1e3);let n=wi(),r=(process.env.SHELL??"").split(/[/\\]/).pop()??"",o="";try{o=await te("tty",[],500),o.includes("not a tty")&&(o="")}catch{o=""}return{os:e,os_version:t||null,user:n||null,shell:r||null,tty:o||null}}function Mn(){return Ii()}var Ip="installation.json",Op="cloud-bootstrap.lock",Tp=6e4;function Bi(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function ye(e=Qr()){return eo(e,".ev-ai","agent-hook")}function Pp(e=Qr()){return eo(ye(e),Ip)}function Ki(e){return eo(Ln(e),Op)}function Gi(){return bp(8).toString("hex")}function Rt(e){return Ui("sha256").update(e).digest("hex").slice(0,16)}function $(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Wi(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function wp(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!Wi(t)){E(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function zi(e,t){return e&&Wi(e)?e:(e&&E(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),wp(t))}function Np(e){return/^[0-9a-f]{16}$/.test(e)}function vp(e=process.env){if($(e.GITHUB_ACTIONS)){let t=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),n=$(e.GITHUB_ACTOR)??$(e.GITHUB_TRIGGERING_ACTOR)??$(e.GITHUB_USER);if(t&&n)return Rt(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return Rt(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return Rt(`codespaces|${n}|${r}`)}if($(e.GITLAB_CI)){let t=$(e.CI_PROJECT_ID)??$(e.CI_PROJECT_PATH),n=$(e.GITLAB_USER_LOGIN)??$(e.GITLAB_USER_EMAIL)??$(e.GITLAB_USER_NAME);if(t&&n)return Rt(`gitlab|${t}|${n}`)}return null}var Mp="cursoragent@cursor.com";function Lp(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Mp?null:t}function Hp(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function Up(e){return Ft(e).replace(/\.git$/i,"").toLowerCase()}async function Dp(e){let t=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?Up(t):e}async function Fp(e){let t=$(await te("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!de(null,t))return t;let n=$(await te("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!de(null,n)?n:null}function $p(e,t){let n=Hp(e,t);return n?Rt(`cursor_cloud|${n}|${Lp(e)??""}`):null}async function jp(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Dp(n),o=await Fp(n);return Rt(`claude_remote|${r}|${o??""}`)}function vi(e,t){let n=zi(e,t);if(n)return n;let r=vp(t);return r||Gi()}async function Bp(e){let n=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||xp(e);return Ui("sha256").update(n).digest("hex").slice(0,16)}function Kp(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function Gp(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Kp(t.platform_agent_ids);return{installation_id:t.installation_id,...t.pinned===!0?{pinned:!0}:{},...n?{platform_agent_ids:n}:{},...typeof t.operator_identity_hash=="string"?{operator_identity_hash:t.operator_identity_hash}:{},...typeof t.operator_identity_sent_at=="string"?{operator_identity_sent_at:t.operator_identity_sent_at}:{}}}catch{return}}function at(e){if(Di(e))try{return Gp(Fi(e,"utf8"))}catch{}}function to(e){return at(e)}function Vi(e,t,n){let r=at(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{me(e,`${JSON.stringify(o,null,2)}
|
|
16
|
-
`)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: operator identity cache write failed open: ${i}`)}}function
|
|
17
|
-
`,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(
|
|
18
|
-
`)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: platform_agent_id cache write failed open: ${i}`)}}function
|
|
19
|
-
`,{encoding:"utf8",flag:"wx"})}function
|
|
20
|
-
`)}function
|
|
21
|
-
`),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(i){let a=i instanceof Error?i.message:String(i);return E(`WARN: hook config write failed open: ${a}`),"failed"}}function
|
|
22
|
-
To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=
|
|
23
|
-
curl -fsSL ${
|
|
11
|
+
`).trimEnd();return(0,Re.usableCatalogText)(f)}});var Cc=V(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES=Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;Q.fitSnapshotInspectionTextBudget=l_;Q.capComponentTextBytes=Rc;Q.prepareComponentInspectionText=f_;Q.redactComponentSource=bo;Q.componentSourceContainsRedactableSecret=S_;Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;Q.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function l_(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let s=Buffer.byteLength(o,"utf8");return t+s<=Q.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=s,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}function Rc(e,t){if(e==null||e.length===0)return;let n=Buffer.from(e,"utf8");if(n.byteLength<=t)return e;let r=new TextDecoder("utf-8",{fatal:!0});for(let o=t;o>0;o-=1)try{return r.decode(n.subarray(0,o))}catch{}}function f_(e){if(!(e==null||e.length===0))return Rc(bo(e),Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}var d_=[/\bsk-(?:proj-)?[A-Za-z0-9_-]{16,}/g,/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,/\bgithub_pat_[A-Za-z0-9_]{20,}/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}/g,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{35}\b/g,/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g],p_=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,m_=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,g_=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,h_=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,yc=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function __(e){let t=e.replace(m_,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(g_,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(p_,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of d_)t=t.replace(n,Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}function bo(e){if(e.length===0)return e;let t=e.split(`
|
|
12
|
+
`),n=!1;return t.map(o=>n?yc.test(o)?(n=!1,o):o.trim().length===0?o:Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:h_.test(o)&&!yc.test(o)?(n=!0,o):__(o)).join(`
|
|
13
|
+
`)}function S_(e){return bo(e)!==e}});var rt=V(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.redactComponentSource=y.prepareComponentInspectionText=y.fitSnapshotInspectionTextBudget=y.componentSourceContainsRedactableSecret=y.capComponentTextBytes=y.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=y.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=y.COMPONENT_INSPECTION_TEXT_MAX_BYTES=y.usableCatalogText=y.parseFrontmatterField=y.parseFrontmatterDescription=y.mcpServerToolSegmentForms=y.mcpServerNameMatchesToolSegment=y.isNpmRegistryPublisher=y.EMPTY_NPM_PUBLISHER=y.displayPublisherName=y.classifyMcpProvenance=y.resolveMcpPackageIdentity=y.McpPackageEcosystem=y.pinnedPackageVersionFromSpec=y.pinnedPackageVersionFromNpx=y.packageNameFromSpec=y.npxPackageSpecs=y.npxExecBin=y.PACKAGE_FIELD_MAX=y.serializeMcpLaunchIdentity=y.projectMcpMissingLaunchIdentity=y.projectMcpLaunchIdentity=y.normalizeMcpToolNames=y.MCP_MISSING_LAUNCH_SERIALIZED=y.MCP_LAUNCH_IDENTITY_ALGORITHM=y.maskMcpLaunchForDisplay=y.launchContainsCredentials=y.hashMcpLaunchIdentity=y.foldMcpName=y.buildMcpFamilyCanonicalKey=y.ComponentKind=void 0;y.userConfigRootFromPath=O_;y.installationRootExternalKey=T_;y.normalizeRepositoryRelativePath=Ac;y.nativeKeyForSkillPath=P_;y.nativeKeyForRulePath=w_;y.nativeKeyForCommandPath=N_;y.serializeComponentIdentity=bc;y.buildComponentReference=M_;y.validateComponentReference=L_;var E_=ze("node:crypto"),y_=ze("node:path"),R_="cmp1_",C_=/^cmp1_[A-Za-z0-9_-]{43}$/,A_=["/skills/","/skills-cursor/"],k_=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,b_=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,x_=[".cursor",".claude",".codex"],I_={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function O_(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>x_.includes(o));return n||(t.map(o=>I_[o]).find(o=>o!==void 0)??"unknown")}function T_(e,t){return`runtime-install:${e}/${t}`}function er(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Ac(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=y_.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return er(n,"sourcePath")}function P_(e){let t=e.replaceAll("\\","/");for(let n of A_){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function kc(e,t,n){let r=e.replaceAll("\\","/"),s=t.exec(r)?.[1];if(!s||s.split("/").includes(".."))return null;let i=s.replace(n,"");return i.length>0?i:null}function w_(e){return kc(e,k_,/\.(mdc|md|rules)$/i)}function N_(e){return kc(e,b_,/\.(md|mdc|toml)$/i)}function v_(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function bc(e){let t=[er(e.installationRootExternalKey,"installationRootExternalKey"),er(e.installableKind,"installableKind"),Ac(e.sourcePath),er(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(v_).join("|")}`,"utf8")}function M_(e){let t=(0,E_.createHash)("sha256").update(bc(e)).digest("base64url");return`${R_}${t}`}function L_(e){return C_.test(e)}var Ce=Xn();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return Ce.buildMcpFamilyCanonicalKey}});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:function(){return Ce.foldMcpName}});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.hashMcpLaunchIdentity}});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:function(){return Ce.launchContainsCredentials}});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return Ce.maskMcpLaunchForDisplay}});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return Ce.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return Ce.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:function(){return Ce.normalizeMcpToolNames}});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.projectMcpLaunchIdentity}});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return Ce.projectMcpMissingLaunchIdentity}});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.serializeMcpLaunchIdentity}});var xt=Zn();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return xt.PACKAGE_FIELD_MAX}});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:function(){return xt.npxExecBin}});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:function(){return xt.npxPackageSpecs}});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:function(){return xt.packageNameFromSpec}});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return xt.pinnedPackageVersionFromNpx}});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return xt.pinnedPackageVersionFromSpec}});var xc=lc();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:function(){return xc.McpPackageEcosystem}});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return xc.resolveMcpPackageIdentity}});var tr=hc();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:function(){return tr.classifyMcpProvenance}});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:function(){return tr.displayPublisherName}});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return tr.EMPTY_NPM_PUBLISHER}});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return tr.isNpmRegistryPublisher}});var Ic=Sc();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Ic.mcpServerNameMatchesToolSegment}});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Ic.mcpServerToolSegmentForms}});var xo=Ec();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:function(){return xo.parseFrontmatterDescription}});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:function(){return xo.parseFrontmatterField}});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:function(){return xo.usableCatalogText}});var nt=Cc();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return nt.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return nt.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return nt.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:function(){return nt.capComponentTextBytes}});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return nt.componentSourceContainsRedactableSecret}});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return nt.fitSnapshotInspectionTextBudget}});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:function(){return nt.prepareComponentInspectionText}});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:function(){return nt.redactComponentSource}})});var gr=V(Ee=>{"use strict";Ee.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Ee.find=(e,t)=>e.nodes.find(n=>n.type===t);Ee.exceedsLimit=(e,t,n=1,r)=>r===!1||!Ee.isInteger(e)||!Ee.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Ee.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Ee.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Ee.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;Ee.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Ee.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Ee.flatten=(...e)=>{let t=[],n=r=>{for(let o=0;o<r.length;o++){let s=r[o];if(Array.isArray(s)){n(s);continue}s!==void 0&&t.push(s)}return t};return n(e),t}});var hr=V((NO,cl)=>{"use strict";var al=gr();cl.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&al.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&al.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(e)}});var ll=V((vO,ul)=>{"use strict";ul.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var El=V((MO,Sl)=>{"use strict";var fl=ll(),ft=(e,t,n)=>{if(fl(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(fl(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),s=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=e+":"+t+"="+o+s+i+a;if(ft.cache.hasOwnProperty(c))return ft.cache[c].result;let l=Math.min(e,t),u=Math.max(e,t);if(Math.abs(l-u)===1){let S=e+"|"+t;return r.capture?`(${S})`:r.wrap===!1?S:`(?:${S})`}let d=_l(e)||_l(t),f={min:e,max:t,a:l,b:u},p=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let S=u<0?Math.abs(u):1;g=dl(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=dl(l,u,f,r)),f.negatives=g,f.positives=p,f.result=py(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),ft.cache[c]=f,f.result};function py(e,t,n){let r=ss(e,t,"-",!1,n)||[],o=ss(t,e,"",!1,n)||[],s=ss(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function my(e,t){let n=1,r=1,o=ml(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=ml(e,n);for(o=gl(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=gl(t+1,r)-1;return s=[...s],s.sort(_y),s}function gy(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=hy(e,t),o=r.length,s="",i=0;for(let a=0;a<o;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=Sy(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function dl(e,t,n,r){let o=my(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=gy(String(i),String(l),r),d="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+hl(a.count),i=l+1;continue}n.isPadded&&(d=Ey(l,n,r)),u.string=d+u.pattern+hl(u.count),s.push(u),i=l+1,a=u}return s}function ss(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!pl(t,"string",a)&&s.push(n+a),r&&pl(t,"string",a)&&s.push(n+a)}return s}function hy(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function _y(e,t){return e>t?1:t>e?-1:0}function pl(e,t,n){return e.some(r=>r[t]===n)}function ml(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function gl(e,t){return e-e%Math.pow(10,t)}function hl(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function Sy(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function _l(e){return/^-?(0+)\d/.test(e)}function Ey(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}ft.cache={};ft.clearCache=()=>ft.cache={};Sl.exports=ft});var cs=V((LO,xl)=>{"use strict";var yy=ze("util"),Rl=El(),yl=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ry=e=>t=>e===!0?Number(t):String(t),is=e=>typeof e=="number"||typeof e=="string"&&e!=="",rn=e=>Number.isInteger(+e),as=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},Cy=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,Ay=(e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},Sr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},ky=(e,t,n)=>{e.negatives.sort((a,c)=>a<c?-1:a>c?1:0),e.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=t.capture?"":"?:",o="",s="",i;return e.positives.length&&(o=e.positives.map(a=>Sr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>Sr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},Cl=(e,t,n,r)=>{if(n)return Rl(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},Al=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Rl(e,t,n)},kl=(...e)=>new RangeError("Invalid range arguments: "+yy.inspect(...e)),bl=(e,t,n)=>{if(n.strictRanges===!0)throw kl([e,t]);return[]},by=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},xy=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw kl([e,t]);return[]}o===0&&(o=0),s===0&&(s=0);let i=o>s,a=String(e),c=String(t),l=String(n);n=Math.max(Math.abs(n),1);let u=as(a)||as(c)||as(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&Cy(e,t,r)===!1,p=r.transform||Ry(f);if(r.toRegex&&n===1)return Cl(Sr(e,d),Sr(t,d),!0,r);let g={negatives:[],positives:[]},S=O=>g[O<0?"negatives":"positives"].push(Math.abs(O)),A=[],k=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):A.push(Ay(p(o,k),d,f)),o=i?o-n:o+n,k++;return r.toRegex===!0?n>1?ky(g,r,d):Al(A,null,{wrap:!1,...r}):A},Iy=(e,t,n=1,r={})=>{if(!rn(e)&&e.length>1||!rn(t)&&t.length>1)return bl(e,t,r);let o=r.transform||(f=>String.fromCharCode(f)),s=`${e}`.charCodeAt(0),i=`${t}`.charCodeAt(0),a=s>i,c=Math.min(s,i),l=Math.max(s,i);if(r.toRegex&&n===1)return Cl(c,l,!1,r);let u=[],d=0;for(;a?s>=i:s<=i;)u.push(o(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?Al(u,null,{wrap:!1,options:r}):u},_r=(e,t,n,r={})=>{if(t==null&&is(e))return[e];if(!is(e)||!is(t))return bl(e,t,r);if(typeof n=="function")return _r(e,t,1,{transform:n});if(yl(n))return _r(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,rn(n)?rn(e)&&rn(t)?xy(e,t,n,o):Iy(e,t,Math.max(Math.abs(n),1),o):n!=null&&!yl(n)?by(n,o):_r(e,t,1,n)};xl.exports=_r});var Tl=V((HO,Ol)=>{"use strict";var Oy=cs(),Il=gr(),Ty=(e,t={})=>{let n=(r,o={})=>{let s=Il.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a=s===!0||i===!0,c=t.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=Il.reduce(r.nodes),d=Oy(...u,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(e)};Ol.exports=Ty});var Nl=V((UO,wl)=>{"use strict";var Py=cs(),Pl=hr(),Ot=gr(),dt=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Ot.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(dt(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?dt(o,s,n):o+s);return Ot.flatten(r)},wy=(e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=(o,s={})=>{o.queue=[];let i=s,a=s.queue;for(;i.type!=="brace"&&i.type!=="root"&&i.parent;)i=i.parent,a=i.queue;if(o.invalid||o.dollar){a.push(dt(a.pop(),Pl(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(dt(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=Ot.reduce(o.nodes);if(Ot.exceedsLimit(...d,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=Py(...d,t);f.length===0&&(f=Pl(o,t)),a.push(dt(a.pop(),f)),o.nodes=[];return}let c=Ot.encloseBrace(o),l=o.queue,u=o;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<o.nodes.length;d++){let f=o.nodes[d];if(f.type==="comma"&&o.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(dt(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(dt(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return Ot.flatten(r(e))};wl.exports=wy});var Ml=V((DO,vl)=>{"use strict";vl.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
14
|
+
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Fl=V((FO,Dl)=>{"use strict";var Ny=hr(),{MAX_LENGTH:Ll,CHAR_BACKSLASH:us,CHAR_BACKTICK:vy,CHAR_COMMA:My,CHAR_DOT:Ly,CHAR_LEFT_PARENTHESES:Hy,CHAR_RIGHT_PARENTHESES:Uy,CHAR_LEFT_CURLY_BRACE:Dy,CHAR_RIGHT_CURLY_BRACE:Fy,CHAR_LEFT_SQUARE_BRACKET:Hl,CHAR_RIGHT_SQUARE_BRACKET:Ul,CHAR_DOUBLE_QUOTE:$y,CHAR_SINGLE_QUOTE:jy,CHAR_NO_BREAK_SPACE:By,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Ky}=Ml(),Gy=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Ll,n.maxLength):Ll;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},s=[o],i=o,a=o,c=0,l=e.length,u=0,d=0,f,p=()=>e[u++],g=S=>{if(S.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&S.type==="text"){a.value+=S.value;return}return i.nodes.push(S),S.parent=i,S.prev=a,a=S,S};for(g({type:"bos"});u<l;)if(i=s[s.length-1],f=p(),!(f===Ky||f===By)){if(f===us){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===Ul){g({type:"text",value:"\\"+f});continue}if(f===Hl){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===Hl){c++;continue}if(S===us){f+=p();continue}if(S===Ul&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===Hy){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===Uy){if(i.type!=="paren"){g({type:"text",value:f});continue}i=s.pop(),g({type:"text",value:f}),i=s[s.length-1];continue}if(f===$y||f===jy||f===vy){let S=f,A;for(t.keepQuotes!==!0&&(f="");u<l&&(A=p());){if(A===us){f+=A+p();continue}if(A===S){t.keepQuotes===!0&&(f+=A);break}f+=A}g({type:"text",value:f});continue}if(f===Dy){d++;let A={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=g(A),s.push(i),g({type:"open",value:f});continue}if(f===Fy){if(i.type!=="brace"){g({type:"text",value:f});continue}let S="close";i=s.pop(),i.close=!0,g({type:S,value:f}),d--,i=s[s.length-1];continue}if(f===My&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:Ny(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===Ly&&d>0&&i.commas===0){let S=i.nodes;if(d===0||S.length===0){g({type:"text",value:f});continue}if(a.type==="dot"){if(i.range=[],a.value+=f,a.type="range",i.nodes.length!==3&&i.nodes.length!==5){i.invalid=!0,i.ranges=0,a.type="text";continue}i.ranges++,i.args=[];continue}if(a.type==="range"){S.pop();let A=S[S.length-1];A.value+=a.value+f,a=A,i.ranges--;continue}g({type:"dot",value:f});continue}g({type:"text",value:f})}do if(i=s.pop(),i.type!=="root"){i.nodes.forEach(k=>{k.nodes||(k.type==="open"&&(k.isOpen=!0),k.type==="close"&&(k.isClose=!0),k.nodes||(k.type="text"),k.invalid=!0)});let S=s[s.length-1],A=S.nodes.indexOf(i);S.nodes.splice(A,1,...i.nodes)}while(s.length>0);return g({type:"eos"}),o};Dl.exports=Gy});var Bl=V(($O,jl)=>{"use strict";var $l=hr(),Wy=Tl(),zy=Nl(),Vy=Fl(),me=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=me.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(me.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};me.parse=(e,t={})=>Vy(e,t);me.stringify=(e,t={})=>$l(typeof e=="string"?me.parse(e,t):e,t);me.compile=(e,t={})=>(typeof e=="string"&&(e=me.parse(e,t)),Wy(e,t));me.expand=(e,t={})=>{typeof e=="string"&&(e=me.parse(e,t));let n=zy(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};me.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?me.compile(e,t):me.expand(e,t);jl.exports=me});var on=V((jO,Vl)=>{"use strict";var Jy=ze("path"),we="\\\\/",Kl=`[^${we}]`,Yy=0,Ge="\\.",Xy="\\+",qy="\\?",Er="\\/",Zy="(?=.)",Gl="[^/]",ls=`(?:${Er}|$)`,Wl=`(?:^|${Er})`,fs=`${Ge}{1,2}${ls}`,Qy=`(?!${Ge})`,eR=`(?!${Wl}${fs})`,tR=`(?!${Ge}{0,1}${ls})`,nR=`(?!${fs})`,rR=`[^.${Er}]`,oR=`${Gl}*?`,zl={DOT_LITERAL:Ge,PLUS_LITERAL:Xy,QMARK_LITERAL:qy,SLASH_LITERAL:Er,ONE_CHAR:Zy,QMARK:Gl,END_ANCHOR:ls,DOTS_SLASH:fs,NO_DOT:Qy,NO_DOTS:eR,NO_DOT_SLASH:tR,NO_DOTS_SLASH:nR,QMARK_NO_DOT:rR,STAR:oR,START_ANCHOR:Wl},sR={...zl,SLASH_LITERAL:`[${we}]`,QMARK:Kl,STAR:`${Kl}*?`,DOTS_SLASH:`${Ge}{1,2}(?:[${we}]|$)`,NO_DOT:`(?!${Ge})`,NO_DOTS:`(?!(?:^|[${we}])${Ge}{1,2}(?:[${we}]|$))`,NO_DOT_SLASH:`(?!${Ge}{0,1}(?:[${we}]|$))`,NO_DOTS_SLASH:`(?!${Ge}{1,2}(?:[${we}]|$))`,QMARK_NO_DOT:`[^.${we}]`,START_ANCHOR:`(?:^|[${we}])`,END_ANCHOR:`(?:[${we}]|$)`},iR={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Vl.exports={DEFAULT_MAX_EXTGLOB_RECURSION:Yy,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:iR,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:Jy.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?sR:zl}}});var sn=V(ce=>{"use strict";var aR=ze("path"),cR=process.platform==="win32",{REGEX_BACKSLASH:uR,REGEX_REMOVE_BACKSLASH:lR,REGEX_SPECIAL_CHARS:fR,REGEX_SPECIAL_CHARS_GLOBAL:dR}=on();ce.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);ce.hasRegexChars=e=>fR.test(e);ce.isRegexChar=e=>e.length===1&&ce.hasRegexChars(e);ce.escapeRegex=e=>e.replace(dR,"\\$1");ce.toPosixSlashes=e=>e.replace(uR,"/");ce.removeBackslashes=e=>e.replace(lR,t=>t==="\\"?"":t);ce.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};ce.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:cR===!0||aR.sep==="\\";ce.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?ce.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};ce.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};ce.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var tf=V((KO,ef)=>{"use strict";var Jl=sn(),{CHAR_ASTERISK:ds,CHAR_AT:pR,CHAR_BACKWARD_SLASH:an,CHAR_COMMA:mR,CHAR_DOT:ps,CHAR_EXCLAMATION_MARK:ms,CHAR_FORWARD_SLASH:Ql,CHAR_LEFT_CURLY_BRACE:gs,CHAR_LEFT_PARENTHESES:hs,CHAR_LEFT_SQUARE_BRACKET:gR,CHAR_PLUS:hR,CHAR_QUESTION_MARK:Yl,CHAR_RIGHT_CURLY_BRACE:_R,CHAR_RIGHT_PARENTHESES:Xl,CHAR_RIGHT_SQUARE_BRACKET:SR}=on(),ql=e=>e===Ql||e===an,Zl=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},ER=(e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],a=[],c=e,l=-1,u=0,d=0,f=!1,p=!1,g=!1,S=!1,A=!1,k=!1,O=!1,I=!1,v=!1,T=!1,K=0,D,x,w={value:"",depth:0,isGlob:!1},H=()=>l>=r,m=()=>c.charCodeAt(l+1),b=()=>(D=x,c.charCodeAt(++l));for(;l<r;){x=b();let ie;if(x===an){O=w.backslashes=!0,x=b(),x===gs&&(k=!0);continue}if(k===!0||x===gs){for(K++;H()!==!0&&(x=b());){if(x===an){O=w.backslashes=!0,b();continue}if(x===gs){K++;continue}if(k!==!0&&x===ps&&(x=b())===ps){if(f=w.isBrace=!0,g=w.isGlob=!0,T=!0,o===!0)continue;break}if(k!==!0&&x===mR){if(f=w.isBrace=!0,g=w.isGlob=!0,T=!0,o===!0)continue;break}if(x===_R&&(K--,K===0)){k=!1,f=w.isBrace=!0,T=!0;break}}if(o===!0)continue;break}if(x===Ql){if(s.push(l),i.push(w),w={value:"",depth:0,isGlob:!1},T===!0)continue;if(D===ps&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(x===hR||x===pR||x===ds||x===Yl||x===ms)===!0&&m()===hs){if(g=w.isGlob=!0,S=w.isExtglob=!0,T=!0,x===ms&&l===u&&(v=!0),o===!0){for(;H()!==!0&&(x=b());){if(x===an){O=w.backslashes=!0,x=b();continue}if(x===Xl){g=w.isGlob=!0,T=!0;break}}continue}break}if(x===ds){if(D===ds&&(A=w.isGlobstar=!0),g=w.isGlob=!0,T=!0,o===!0)continue;break}if(x===Yl){if(g=w.isGlob=!0,T=!0,o===!0)continue;break}if(x===gR){for(;H()!==!0&&(ie=b());){if(ie===an){O=w.backslashes=!0,b();continue}if(ie===SR){p=w.isBracket=!0,g=w.isGlob=!0,T=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===ms&&l===u){I=w.negated=!0,u++;continue}if(n.noparen!==!0&&x===hs){if(g=w.isGlob=!0,o===!0){for(;H()!==!0&&(x=b());){if(x===hs){O=w.backslashes=!0,x=b();continue}if(x===Xl){T=!0;break}}continue}break}if(g===!0){if(T=!0,o===!0)continue;break}}n.noext===!0&&(S=!1,g=!1);let U=c,le="",h="";u>0&&(le=c.slice(0,u),c=c.slice(u),d-=u),U&&g===!0&&d>0?(U=c.slice(0,d),h=c.slice(d)):g===!0?(U="",h=c):U=c,U&&U!==""&&U!=="/"&&U!==c&&ql(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(h&&(h=Jl.removeBackslashes(h)),U&&O===!0&&(U=Jl.removeBackslashes(U)));let _={prefix:le,input:e,start:u,base:U,glob:h,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:A,negated:I,negatedExtglob:v};if(n.tokens===!0&&(_.maxDepth=0,ql(x)||i.push(w),_.tokens=i),n.parts===!0||n.tokens===!0){let ie;for(let F=0;F<s.length;F++){let Ae=ie?ie+1:u,ke=s[F],fe=e.slice(Ae,ke);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=le):i[F].value=fe,Zl(i[F]),_.maxDepth+=i[F].depth),(F!==0||fe!=="")&&a.push(fe),ie=ke}if(ie&&ie+1<e.length){let F=e.slice(ie+1);a.push(F),n.tokens&&(i[i.length-1].value=F,Zl(i[i.length-1]),_.maxDepth+=i[i.length-1].depth)}_.slashes=s,_.parts=a}return _};ef.exports=ER});var af=V((GO,sf)=>{"use strict";var cn=on(),se=sn(),{MAX_LENGTH:yr,POSIX_REGEX_SOURCE:yR,REGEX_NON_SPECIAL_CHARS:RR,REGEX_SPECIAL_CHARS_BACKREF:CR,REPLACEMENTS:nf}=cn,AR=(e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>se.escapeRegex(o)).join("..")}return n},Tt=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,rf=e=>{let t=[],n=0,r=0,o=0,s="",i=!1;for(let a of e){if(i===!0){s+=a,i=!1;continue}if(a==="\\"){s+=a,i=!0;continue}if(a==='"'){o=o===1?0:1,s+=a;continue}if(o===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(s),s="";continue}}}s+=a}return t.push(s),t},kR=e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},of=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(kR(t))return t.replace(/\\(.)/g,"$1")},bR=e=>{let t=e.map(of).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],s=t[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},_s=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<e.length;i++){let a=e[i];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){o=o===1?0:1;continue}if(o!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===!0&&i!==e.length-1?void 0:{type:e[0],body:e.slice(2,i),end:i}}}}},xR=e=>{let t=0,n=[];for(;t<e.length;){let o=_s(e.slice(t),!1);if(!o||o.type!=="*")return;let s=rf(o.body).map(a=>a.trim());if(s.length!==1)return;let i=of(s[0]);if(!i||i.length!==1)return;n.push(i),t+=o.end+1}return n.length<1?void 0:`${n.length===1?se.escapeRegex(n[0]):`[${n.map(o=>se.escapeRegex(o)).join("")}]`}*`},IR=e=>{let t=0,n=e.trim(),r=_s(n);for(;r;)t++,n=r.body.trim(),r=_s(n);return t},OR=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:cn.DEFAULT_MAX_EXTGLOB_RECURSION,r=rf(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||bR(r)))return{risky:!0};for(let o of r){let s=xR(o);if(s)return{risky:!0,safeOutput:s};if(IR(o)>n)return{risky:!0}}return{risky:!1}},Ss=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=nf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(yr,n.maxLength):yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],a=n.capture?"":"?:",c=se.isWindows(t),l=cn.globChars(c),u=cn.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:A,NO_DOT_SLASH:k,NO_DOTS_SLASH:O,QMARK:I,QMARK_NO_DOT:v,STAR:T,START_ANCHOR:K}=l,D=C=>`(${a}(?:(?!${K}${C.dot?S:d}).)*?)`,x=n.dot?"":A,w=n.dot?I:v,H=n.bash===!0?D(n):T;n.capture&&(H=`(${H})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};e=se.removePrefix(e,m),o=e.length;let b=[],U=[],le=[],h=s,_,ie=()=>m.index===o-1,F=m.peek=(C=1)=>e[m.index+C],Ae=m.advance=()=>e[++m.index]||"",ke=()=>e.slice(m.index+1),fe=(C="",Y=0)=>{m.consumed+=C,m.index+=Y},yn=C=>{m.output+=C.output!=null?C.output:C.value,fe(C.value)},lp=()=>{let C=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)Ae(),m.start++,C++;return C%2===0?!1:(m.negated=!0,m.start++,!0)},Rn=C=>{m[C]++,le.push(C)},We=C=>{m[C]--,le.pop()},N=C=>{if(h.type==="globstar"){let Y=m.braces>0&&(C.type==="comma"||C.type==="brace"),R=C.extglob===!0||b.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!Y&&!R&&(m.output=m.output.slice(0,-h.output.length),h.type="star",h.value="*",h.output=H,m.output+=h.output)}if(b.length&&C.type!=="paren"&&(b[b.length-1].inner+=C.value),(C.value||C.output)&&yn(C),h&&h.type==="text"&&C.type==="text"){h.value+=C.value,h.output=(h.output||"")+C.value;return}C.prev=h,i.push(C),h=C},Cn=(C,Y)=>{let R={...u[Y],conditions:1,inner:""};R.prev=h,R.parens=m.parens,R.output=m.output,R.startIndex=m.index,R.tokensIndex=i.length;let P=(n.capture?"(":"")+R.open;Rn("parens"),N({type:C,value:Y,output:m.output?"":g}),N({type:"paren",extglob:!0,value:Ae(),output:P}),b.push(R)},fp=C=>{let Y=e.slice(C.startIndex,m.index+1),R=e.slice(C.startIndex+2,m.index),P=OR(R,n);if((C.type==="plus"||C.type==="star")&&P.risky){let G=P.safeOutput?(C.output?"":g)+(n.capture?`(${P.safeOutput})`:P.safeOutput):void 0,be=i[C.tokensIndex];be.type="text",be.value=Y,be.output=G||se.escapeRegex(Y);for(let xe=C.tokensIndex+1;xe<i.length;xe++)i[xe].value="",i[xe].output="",delete i[xe].suffix;m.output=C.output+be.output,m.backtrack=!0,N({type:"paren",extglob:!0,value:_,output:""}),We("parens");return}let z=C.close+(n.capture?")":""),oe;if(C.type==="negate"){let G=H;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(G=D(n)),(G!==H||ie()||/^\)+$/.test(ke()))&&(z=C.close=`)$))${G}`),C.inner.includes("*")&&(oe=ke())&&/^\.[^\\/.]+$/.test(oe)){let be=Ss(oe,{...t,fastpaths:!1}).output;z=C.close=`)${be})${G})`}C.prev.type==="bos"&&(m.negatedExtglob=!0)}N({type:"paren",extglob:!0,value:_,output:z}),We("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,Y=e.replace(CR,(R,P,z,oe,G,be)=>oe==="\\"?(C=!0,R):oe==="?"?P?P+oe+(G?I.repeat(G.length):""):be===0?w+(G?I.repeat(G.length):""):I.repeat(z.length):oe==="."?d.repeat(z.length):oe==="*"?P?P+oe+(G?H:""):H:P?R:`\\${R}`);return C===!0&&(n.unescape===!0?Y=Y.replace(/\\/g,""):Y=Y.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),Y===e&&n.contains===!0?(m.output=e,m):(m.output=se.wrapOutput(Y,m,t),m)}for(;!ie();){if(_=Ae(),_==="\0")continue;if(_==="\\"){let R=F();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){_+="\\",N({type:"text",value:_});continue}let P=/^\\+/.exec(ke()),z=0;if(P&&P[0].length>2&&(z=P[0].length,m.index+=z,z%2!==0&&(_+="\\")),n.unescape===!0?_=Ae():_+=Ae(),m.brackets===0){N({type:"text",value:_});continue}}if(m.brackets>0&&(_!=="]"||h.value==="["||h.value==="[^")){if(n.posix!==!1&&_===":"){let R=h.value.slice(1);if(R.includes("[")&&(h.posix=!0,R.includes(":"))){let P=h.value.lastIndexOf("["),z=h.value.slice(0,P),oe=h.value.slice(P+2),G=yR[oe];if(G){h.value=z+G,m.backtrack=!0,Ae(),!s.output&&i.indexOf(h)===1&&(s.output=g);continue}}}(_==="["&&F()!==":"||_==="-"&&F()==="]")&&(_=`\\${_}`),_==="]"&&(h.value==="["||h.value==="[^")&&(_=`\\${_}`),n.posix===!0&&_==="!"&&h.value==="["&&(_="^"),h.value+=_,yn({value:_});continue}if(m.quotes===1&&_!=='"'){_=se.escapeRegex(_),h.value+=_,yn({value:_});continue}if(_==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&N({type:"text",value:_});continue}if(_==="("){Rn("parens"),N({type:"paren",value:_});continue}if(_===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Tt("opening","("));let R=b[b.length-1];if(R&&m.parens===R.parens+1){fp(b.pop());continue}N({type:"paren",value:_,output:m.parens?")":"\\)"}),We("parens");continue}if(_==="["){if(n.nobracket===!0||!ke().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Tt("closing","]"));_=`\\${_}`}else Rn("brackets");N({type:"bracket",value:_});continue}if(_==="]"){if(n.nobracket===!0||h&&h.type==="bracket"&&h.value.length===1){N({type:"text",value:_,output:`\\${_}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Tt("opening","["));N({type:"text",value:_,output:`\\${_}`});continue}We("brackets");let R=h.value.slice(1);if(h.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(_=`/${_}`),h.value+=_,yn({value:_}),n.literalBrackets===!1||se.hasRegexChars(R))continue;let P=se.escapeRegex(h.value);if(m.output=m.output.slice(0,-h.value.length),n.literalBrackets===!0){m.output+=P,h.value=P;continue}h.value=`(${a}${P}|${h.value})`,m.output+=h.value;continue}if(_==="{"&&n.nobrace!==!0){Rn("braces");let R={type:"brace",value:_,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};U.push(R),N(R);continue}if(_==="}"){let R=U[U.length-1];if(n.nobrace===!0||!R){N({type:"text",value:_,output:_});continue}let P=")";if(R.dots===!0){let z=i.slice(),oe=[];for(let G=z.length-1;G>=0&&(i.pop(),z[G].type!=="brace");G--)z[G].type!=="dots"&&oe.unshift(z[G].value);P=AR(oe,n),m.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let z=m.output.slice(0,R.outputIndex),oe=m.tokens.slice(R.tokensIndex);R.value=R.output="\\{",_=P="\\}",m.output=z;for(let G of oe)m.output+=G.output||G.value}N({type:"brace",value:_,output:P}),We("braces"),U.pop();continue}if(_==="|"){b.length>0&&b[b.length-1].conditions++,N({type:"text",value:_});continue}if(_===","){let R=_,P=U[U.length-1];P&&le[le.length-1]==="braces"&&(P.comma=!0,R="|"),N({type:"comma",value:_,output:R});continue}if(_==="/"){if(h.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",i.pop(),h=s;continue}N({type:"slash",value:_,output:p});continue}if(_==="."){if(m.braces>0&&h.type==="dot"){h.value==="."&&(h.output=d);let R=U[U.length-1];h.type="dots",h.output+=_,h.value+=_,R.dots=!0;continue}if(m.braces+m.parens===0&&h.type!=="bos"&&h.type!=="slash"){N({type:"text",value:_,output:d});continue}N({type:"dot",value:_,output:d});continue}if(_==="?"){if(!(h&&h.value==="(")&&n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Cn("qmark",_);continue}if(h&&h.type==="paren"){let P=F(),z=_;if(P==="<"&&!se.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(h.value==="("&&!/[!=<:]/.test(P)||P==="<"&&!/<([!=]|\w+>)/.test(ke()))&&(z=`\\${_}`),N({type:"text",value:_,output:z});continue}if(n.dot!==!0&&(h.type==="slash"||h.type==="bos")){N({type:"qmark",value:_,output:v});continue}N({type:"qmark",value:_,output:I});continue}if(_==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){Cn("negate",_);continue}if(n.nonegate!==!0&&m.index===0){lp();continue}}if(_==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Cn("plus",_);continue}if(h&&h.value==="("||n.regex===!1){N({type:"plus",value:_,output:f});continue}if(h&&(h.type==="bracket"||h.type==="paren"||h.type==="brace")||m.parens>0){N({type:"plus",value:_});continue}N({type:"plus",value:f});continue}if(_==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){N({type:"at",extglob:!0,value:_,output:""});continue}N({type:"text",value:_});continue}if(_!=="*"){(_==="$"||_==="^")&&(_=`\\${_}`);let R=RR.exec(ke());R&&(_+=R[0],m.index+=R[0].length),N({type:"text",value:_});continue}if(h&&(h.type==="globstar"||h.star===!0)){h.type="star",h.star=!0,h.value+=_,h.output=H,m.backtrack=!0,m.globstar=!0,fe(_);continue}let C=ke();if(n.noextglob!==!0&&/^\([^?]/.test(C)){Cn("star",_);continue}if(h.type==="star"){if(n.noglobstar===!0){fe(_);continue}let R=h.prev,P=R.prev,z=R.type==="slash"||R.type==="bos",oe=P&&(P.type==="star"||P.type==="globstar");if(n.bash===!0&&(!z||C[0]&&C[0]!=="/")){N({type:"star",value:_,output:""});continue}let G=m.braces>0&&(R.type==="comma"||R.type==="brace"),be=b.length&&(R.type==="pipe"||R.type==="paren");if(!z&&R.type!=="paren"&&!G&&!be){N({type:"star",value:_,output:""});continue}for(;C.slice(0,3)==="/**";){let xe=e[m.index+4];if(xe&&xe!=="/")break;C=C.slice(3),fe("/**",3)}if(R.type==="bos"&&ie()){h.type="globstar",h.value+=_,h.output=D(n),m.output=h.output,m.globstar=!0,fe(_);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&!oe&&ie()){m.output=m.output.slice(0,-(R.output+h.output).length),R.output=`(?:${R.output}`,h.type="globstar",h.output=D(n)+(n.strictSlashes?")":"|$)"),h.value+=_,m.globstar=!0,m.output+=R.output+h.output,fe(_);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&C[0]==="/"){let xe=C[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(R.output+h.output).length),R.output=`(?:${R.output}`,h.type="globstar",h.output=`${D(n)}${p}|${p}${xe})`,h.value+=_,m.output+=R.output+h.output,m.globstar=!0,fe(_+Ae()),N({type:"slash",value:"/",output:""});continue}if(R.type==="bos"&&C[0]==="/"){h.type="globstar",h.value+=_,h.output=`(?:^|${p}|${D(n)}${p})`,m.output=h.output,m.globstar=!0,fe(_+Ae()),N({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-h.output.length),h.type="globstar",h.output=D(n),h.value+=_,m.output+=h.output,m.globstar=!0,fe(_);continue}let Y={type:"star",value:_,output:H};if(n.bash===!0){Y.output=".*?",(h.type==="bos"||h.type==="slash")&&(Y.output=x+Y.output),N(Y);continue}if(h&&(h.type==="bracket"||h.type==="paren")&&n.regex===!0){Y.output=_,N(Y);continue}(m.index===m.start||h.type==="slash"||h.type==="dot")&&(h.type==="dot"?(m.output+=k,h.output+=k):n.dot===!0?(m.output+=O,h.output+=O):(m.output+=x,h.output+=x),F()!=="*"&&(m.output+=g,h.output+=g)),N(Y)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing","]"));m.output=se.escapeLast(m.output,"["),We("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing",")"));m.output=se.escapeLast(m.output,"("),We("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing","}"));m.output=se.escapeLast(m.output,"{"),We("braces")}if(n.strictSlashes!==!0&&(h.type==="star"||h.type==="bracket")&&N({type:"maybe_slash",value:"",output:`${p}?`}),m.backtrack===!0){m.output="";for(let C of m.tokens)m.output+=C.output!=null?C.output:C.value,C.suffix&&(m.output+=C.suffix)}return m};Ss.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(yr,n.maxLength):yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=nf[e]||e;let s=se.isWindows(t),{DOT_LITERAL:i,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:g}=cn.globChars(s),S=n.dot?d:u,A=n.dot?f:u,k=n.capture?"":"?:",O={negated:!1,prefix:""},I=n.bash===!0?".*?":p;n.capture&&(I=`(${I})`);let v=x=>x.noglobstar===!0?I:`(${k}(?:(?!${g}${x.dot?l:i}).)*?)`,T=x=>{switch(x){case"*":return`${S}${c}${I}`;case".*":return`${i}${c}${I}`;case"*.*":return`${S}${I}${i}${c}${I}`;case"*/*":return`${S}${I}${a}${c}${A}${I}`;case"**":return S+v(n);case"**/*":return`(?:${S}${v(n)}${a})?${A}${c}${I}`;case"**/*.*":return`(?:${S}${v(n)}${a})?${A}${I}${i}${c}${I}`;case"**/.*":return`(?:${S}${v(n)}${a})?${i}${c}${I}`;default:{let w=/^(.*?)\.(\w+)$/.exec(x);if(!w)return;let H=T(w[1]);return H?H+i+w[2]:void 0}}},K=se.removePrefix(e,O),D=T(K);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};sf.exports=Ss});var uf=V((WO,cf)=>{"use strict";var TR=ze("path"),PR=tf(),Es=af(),ys=sn(),wR=on(),NR=e=>e&&typeof e=="object"&&!Array.isArray(e),ee=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(f=>ee(f,t,n));return f=>{for(let p of u){let g=p(f);if(g)return g}return!1}}let r=NR(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},s=ys.isWindows(t),i=r?ee.compileRe(e,t):ee.makeRe(e,t,!1,!0),a=i.state;delete i.state;let c=()=>!1;if(o.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};c=ee(o.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:g}=ee.test(u,i,t,{glob:e,posix:s}),S={glob:e,state:a,regex:i,posix:s,input:u,output:g,match:p,isMatch:f};return typeof o.onResult=="function"&&o.onResult(S),f===!1?(S.isMatch=!1,d?S:!1):c(u)?(typeof o.onIgnore=="function"&&o.onIgnore(S),S.isMatch=!1,d?S:!1):(typeof o.onMatch=="function"&&o.onMatch(S),d?S:!0)};return n&&(l.state=a),l};ee.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let s=n||{},i=s.format||(o?ys.toPosixSlashes:null),a=e===r,c=a&&i?i(e):e;return a===!1&&(c=i?i(e):e,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=ee.matchBase(e,t,n,o):a=t.exec(c)),{isMatch:!!a,match:a,output:c}};ee.matchBase=(e,t,n,r=ys.isWindows(n))=>(t instanceof RegExp?t:ee.makeRe(t,n)).test(TR.basename(e));ee.isMatch=(e,t,n)=>ee(t,n)(e);ee.parse=(e,t)=>Array.isArray(e)?e.map(n=>ee.parse(n,t)):Es(e,{...t,fastpaths:!1});ee.scan=(e,t)=>PR(e,t);ee.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},s=o.contains?"":"^",i=o.contains?"":"$",a=`${s}(?:${e.output})${i}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let c=ee.toRegex(a,t);return r===!0&&(c.state=e),c};ee.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=Es.fastpaths(e,t)),o.output||(o=Es(e,t)),ee.compileRe(o,t,n,r)};ee.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};ee.constants=wR;cf.exports=ee});var ff=V((zO,lf)=>{"use strict";lf.exports=uf()});var _f=V((VO,hf)=>{"use strict";var pf=ze("util"),mf=Bl(),Ne=ff(),Rs=sn(),df=e=>e===""||e==="./",gf=e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},J=(e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,s=new Set,i=0,a=u=>{s.add(u.output),n&&n.onResult&&n.onResult(u)};for(let u=0;u<t.length;u++){let d=Ne(String(t[u]),{...n,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&i++;for(let p of e){let g=d(p,!0);(f?!g.isMatch:g.isMatch)&&(f?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let l=(i===t.length?[...s]:[...o]).filter(u=>!r.has(u));if(n&&l.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(u=>u.replace(/\\/g,"")):t}return l};J.match=J;J.matcher=(e,t)=>Ne(e,t);J.isMatch=(e,t,n)=>Ne(t,n)(e);J.any=J.isMatch;J.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],s=a=>{n.onResult&&n.onResult(a),o.push(a.output)},i=new Set(J(e,t,{...n,onResult:s}));for(let a of o)i.has(a)||r.add(a);return[...r]};J.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${pf.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>J.contains(e,r,n));if(typeof t=="string"){if(df(e)||df(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return J.isMatch(e,t,{...n,contains:!0})};J.matchKeys=(e,t,n)=>{if(!Rs.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=J(Object.keys(e),t,n),o={};for(let s of r)o[s]=e[s];return o};J.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Ne(String(o),n);if(r.some(i=>s(i)))return!0}return!1};J.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Ne(String(o),n);if(!r.every(i=>s(i)))return!1}return!0};J.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${pf.inspect(e)}"`);return[].concat(t).every(r=>Ne(r,n)(e))};J.capture=(e,t,n)=>{let r=Rs.isWindows(n),s=Ne.makeRe(String(e),{...n,capture:!0}).exec(r?Rs.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};J.makeRe=(...e)=>Ne.makeRe(...e);J.scan=(...e)=>Ne.scan(...e);J.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of mf(String(r),t))n.push(Ne.parse(o,t));return n};J.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!gf(e)?[e]:mf(e,t)};J.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return J.braces(e,{...t,expand:!0})};J.hasBraces=gf;hf.exports=J});import{realpathSync as Nk}from"node:fs";import{resolve as vk}from"node:path";import{fileURLToPath as Mk,pathToFileURL as Lk}from"node:url";import{createHash as Ip}from"node:crypto";import{homedir as Op}from"node:os";import{dirname as Qk,join as Tp,parse as eb,resolve as tb}from"node:path";var ii="EV_AI_LAUNCHER_VERSION";var ai="EV_AI_HOOK_SOURCE",ci="EV_AI_HOOK_FALLBACK_REASON",ui="EV_AI_LAUNCHER_SCOPE",Fr="EV_AI_LAUNCHER_READY_FD";var li="--defer-user-spec",An="--cap",fi=Buffer.from([1]);var Fk=1024*1024,$k=4*1024*1024,jk=64*1024,Bk=64*1024,Kk=64*1024;var $r=4096,Gk=4*1024*1024;import{createHash as Sp,randomBytes as Ep}from"node:crypto";import{existsSync as jr,mkdirSync as yp,readdirSync as Rp,readFileSync as Cp,renameSync as di,statSync as hi,unlinkSync as pi,writeFileSync as Ap}from"node:fs";import{basename as kp,dirname as mi,join as _i,relative as bp}from"node:path";function E(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
|
|
15
|
+
`)}function Ut(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function Dt(e){return Sp("sha256").update(e).digest("hex").slice(0,32)}function ge(e,t){yp(mi(e),{recursive:!0});let n=_i(mi(e),`.${kp(e)}.${process.pid}.${Ep(4).toString("hex")}.tmp`);try{Ap(n,t,"utf8");try{di(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){pi(e),di(n,e);return}throw r}}catch(r){try{pi(n)}catch{}throw r}}function kn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}function Br(){process.stdout.write('{"continue":true}')}function M(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Ft(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}async function bn(e){return new Promise(t=>{let n="",r=!1,o=i=>{r||(r=!0,clearTimeout(s),t(i||"{}"))},s=setTimeout(()=>{o(n)},e);if(process.stdin.isTTY){o("{}");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",i=>{n+=i}),process.stdin.on("end",()=>{o(n)}),process.stdin.on("error",()=>{o(n)}),process.stdin.resume()})}async function ye(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:s}=await import("node:util"),i=s(o);try{let{stdout:a}=await i(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:a.trim()}}catch(a){let c=a,l=typeof c.code=="number"?c.code:typeof c.status=="number"?c.status:void 0;return{ok:!1,code:l,spawnFailed:l===void 0}}}async function te(e,t,n=3e3,r={}){let o=await ye(e,t,n,r);return o.ok?o.stdout:""}async function Kr(e=process.cwd()){let t=await ye("git",["rev-parse","--show-toplevel"],2e3,{cwd:e});if(t.ok&&t.stdout)return{root:t.stdout,inGitRepo:!0};if(M("EV_AI_HOOK_DEBUG")){let r=t.ok?"empty stdout":t.spawnFailed?"spawn failed":`exit ${String(t.code??"unknown")}`;E(`DEBUG: git rev-parse --show-toplevel failed (${r}) cwd=${e}`)}let n=M("CURSOR_PROJECT_DIR")??M("CLAUDE_PROJECT_DIR");if(n&&jr(n)){let r=await ye("git",["rev-parse","--show-toplevel"],2e3,{cwd:n});return r.ok&&r.stdout?{root:r.stdout,inGitRepo:!0}:{root:n,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function Le(e=process.cwd()){return(await Kr(e)).root}function he(e,t){try{return JSON.parse(e)}catch{return t}}var gi=new Map;function xn(e){return e.charCodeAt(0)===65279?e.slice(1):e}function xp(e){let t;try{t=Cp(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(xn(t))}}catch{return{ok:!1,reason:"parse"}}}function Si(e){let t=gi.get(e);if(t!==void 0)return t;let n=xp(e);return gi.set(e,n),n}function Ei(e){return Si(e)}function ne(e,t){let n=Si(e);return n.ok?n.value:t}function it(e){return typeof e=="string"?e:""}function He(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let s of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[s]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}function L(e,t){let n=He(e,t);return typeof n=="string"?n:""}var Je=500;function yi(e,t=2){if(!jr(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=Rp(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=_i(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:bp(e,l),size:hi(l).size})}catch{continue}if(n.length>=Je){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function Gr(e){return jr(e)?{present:!0,size:hi(e).size}:{present:!1,size:0}}var Ai="https://hooks.ev-ai.ai",In=".claude/ev-ai-runtime-report.json",ki="config.json",Pp="max_concurrent_hooks",ob=1024*1024,wp=new Set(["localhost","127.0.0.1","[::1]","::1"]),Np=["claude","cursor","codex"],On=[In,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Wr=/^[A-Za-z0-9._~-]+$/;function Tn(e){return e!==void 0&&Np.includes(e)}function bi(e){if(!e||typeof e!="object")return;let t=e[Pp];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function Ri(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function $t(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function zr(e){let t,n,r,o,s,i;for(let a=0;a<e.length;a++){let c=e[a];if(c!==void 0){if(c==="--runner"){let l=$t(e,a);t=l.value,a=l.next;continue}if(c.startsWith("--runner=")){t=c.slice(9);continue}if(c==="--url"){let l=$t(e,a);l.value&&(r=l.value),a=l.next;continue}if(c.startsWith("--url=")){r=c.slice(6);continue}if(c==="--token"){let l=$t(e,a);l.value&&(o=l.value),a=l.next;continue}if(c.startsWith("--token=")){o=c.slice(8);continue}if(c==="--base-url"){let l=$t(e,a);l.value&&(s=l.value),a=l.next;continue}if(c.startsWith("--base-url=")){s=c.slice(11);continue}if(c===An){let l=$t(e,a);i=Ri(l.value)??i,a=l.next;continue}if(c.startsWith(`${An}=`)){i=Ri(c.slice(An.length+1))??i;continue}c!==li&&!c.startsWith("-")&&n===void 0&&(n=c)}}return{runner:Tn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{}}}function Pn(e,t=Ai){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function jt(e=Op()){return Tp(e,".ev-ai",ki)}function xi(e,t){return{...e,...t}}function Ci(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}function wn(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?wp.has(t.hostname):!1}catch{return!1}}function Vr(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}function Et(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!wn(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Vr(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Wr.test(n))return`org token must match ${Wr.source} (got: ${n})`;if(Ci(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Ci(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function Bt(e){return new URL(e).toString()}function Jr(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?Pn(n):""}function Nn(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}function Ii(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Pn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=Et(n);return r?{problem:r}:{url:Bt(n)}}function Kt(e){if(Et(e))return;let t;try{t=new URL(e)}catch{return}let n=Vr(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),s=o.length>0?`/${o.join("/")}`:"",i=`${t.origin}${s}/${n}`;return Ip("sha256").update(i).digest("hex").slice(0,32)}var Ye=2,Oi="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ie="ev-ai-agent-hook";function vp(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function vn(e){let t=vp(e);return t===Ie||t===`${Ie}.exe`}var Ti="https://cdn.ev-ai.ai/agent-hook";var Yr=`current/${Ie}`,Xr=`.ev-ai/agent-hook/${Ie}`,Pi=5e3,wi=5e3,qr=3e3;var Mn=3e3,Ni=1500,vi=4*1024,Zr=256*1024,Mp=4*1024,Mi=32*1024,Ue="1.3.3",Ln=`@ev-ai/agent-hook@${Ue}`,Li="ev-ai runtime report";import{chmodSync as Ea,cpSync as ya,existsSync as Xe,mkdirSync as po,readFileSync as Gm,rmSync as Kn,symlinkSync as Wm,writeFileSync as zm}from"node:fs";import{homedir as De}from"node:os";import{dirname as mo,isAbsolute as Vm,join as W,relative as Ra,resolve as _a,sep as Jm}from"node:path";import{fileURLToPath as Ym}from"node:url";import{existsSync as Lp,readdirSync as Hi}from"node:fs";import{homedir as Hn}from"node:os";import{join as ae}from"node:path";function Ui(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ae(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Qr(e=process.platform){let t=Ui(e),n=[ae(t,"managed-settings.json")],r=ae(t,"managed-settings.d");try{if(!Lp(r))return n;let o=Hi(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ae(r,s));n.push(...o)}catch{}return n}function eo(e=process.platform,t=Hn()){return{serverManaged:ae(t,".claude","remote-settings.json"),fileBased:Qr(e)}}function Hp(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ae(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function Up(e=process.platform,t=Hn()){let n=[ae(Hp(e),"hooks.json")],r=ae(t,".cursor","managed");try{for(let o of Hi(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ae(r,o.name,"hooks.json"))}catch{}return n}function Dp(e=process.platform,t=Hn()){let n=e==="win32"?ae(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ae(n,"requirements.toml")];return e!=="win32"&&r.push(ae(n,"managed_config.toml")),r.push(ae(t,".codex","managed_config.toml"),ae(n,"config.toml")),r}function Un(e,t=process.platform,n=Hn()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=eo(t,n);return[r,...o]}case"cursor":return Up(t,n);default:return Dp(t,n)}}import{createHash as Ji,randomBytes as em}from"node:crypto";import{existsSync as Yi,mkdirSync as no,readFileSync as Xi,unlinkSync as qi,writeFileSync as Zi}from"node:fs";import{homedir as ro}from"node:os";import{dirname as Fn,join as oo,resolve as tm}from"node:path";var Fp=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),$p=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function de(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||$p.has(n)||r.includes("[bot]")||Fp.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}import{existsSync as jp,readFileSync as Bp}from"node:fs";import{hostname as Di,userInfo as Kp}from"node:os";function yt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Fi(e=process.env){return yt(X("CURSOR_SANDBOX",e))}var Gp=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Wp(e){return Gp.some(t=>!!X(t,e))}function zp(e){if(X("KUBERNETES_SERVICE_HOST",e)||yt(X("REMOTE_CONTAINERS",e))||yt(X("DEVCONTAINER",e)))return!0;try{if(jp("/.dockerenv")||Bp("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function $i(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!X(t,e))}function Vp(e,t=process.platform){return $i(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!X(n,e)):!1}function Jp(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function Yp(e){return e==="linux"}function X(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return M(e)}function Xp(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!qp(X("CURSOR_VERSION",n))}function qp(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function to(e){if(Jp(e.sessionId))return!0;let t=e.hostname??Di(),n=e.osUser??Bi(e.env);return Xp(t,n,e.env)}function Zp(e){return yt(X("CURSOR_AGENT",e.env))?!0:to(e)}function Qp(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(X("TERM",e)??X("TERM_PROGRAM",e))||(X("SSH_TTY",e)??X("SSH_CONNECTION",e))||(X("__CFBundleIdentifier",e)??X("XPC_SERVICE_NAME",e))||$i(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!X(t,e))||X("SESSIONNAME",e))}function Gt(e={}){let t=e.env;if(X("GITHUB_ACTIONS",t))return"github_actions";if(yt(X("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Vp(t,n)&&Zp(e)&&(yt(X("CURSOR_AGENT",t))||Yp(n)))return"cursor_cloud";if(X("CODESPACES",t)||X("CODESPACE_NAME",t))return"codespaces";if(X("GITLAB_CI",t))return"gitlab_ci";if(Wp(t))return"managed";let r=X("CI",t);return r&&r!=="false"&&r!=="0"?"managed":zp(t)?"container":Qp(t)?"interactive":"unknown"}async function ji(){return await te("systemd-detect-virt",[],1e3)}function Bi(e=process.env,t=Kp){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}async function Ki(){let e=process.platform==="darwin"?"Darwin":process.platform==="win32"?"Windows_NT":"Linux",t="";if(process.platform==="darwin")t=await te("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:s}=await import("node:fs"),i=s("/etc/os-release","utf8"),a=i.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],c=i.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];t=a??c??""}catch{t=await te("lsb_release",["-sd"],1e3).then(s=>s.replace(/^"|"$/g,""))}t||(t=await te("uname",["-r"],1e3))}else t=await te("ver",[],1e3);let n=Bi(),r=(process.env.SHELL??"").split(/[/\\]/).pop()??"",o="";try{o=await te("tty",[],500),o.includes("not a tty")&&(o="")}catch{o=""}return{os:e,os_version:t||null,user:n||null,shell:r||null,tty:o||null}}function Dn(){return Di()}var nm="installation.json",rm="cloud-bootstrap.lock",om=6e4;function Qi(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function pe(e=ro()){return oo(e,".ev-ai","agent-hook")}function sm(e=ro()){return oo(pe(e),nm)}function ea(e){return oo(Fn(e),rm)}function ta(){return em(8).toString("hex")}function Rt(e){return Ji("sha256").update(e).digest("hex").slice(0,16)}function $(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function na(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function im(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!na(t)){E(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function ra(e,t){return e&&na(e)?e:(e&&E(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),im(t))}function am(e){return/^[0-9a-f]{16}$/.test(e)}function cm(e=process.env){if($(e.GITHUB_ACTIONS)){let t=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),n=$(e.GITHUB_ACTOR)??$(e.GITHUB_TRIGGERING_ACTOR)??$(e.GITHUB_USER);if(t&&n)return Rt(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return Rt(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return Rt(`codespaces|${n}|${r}`)}if($(e.GITLAB_CI)){let t=$(e.CI_PROJECT_ID)??$(e.CI_PROJECT_PATH),n=$(e.GITLAB_USER_LOGIN)??$(e.GITLAB_USER_EMAIL)??$(e.GITLAB_USER_NAME);if(t&&n)return Rt(`gitlab|${t}|${n}`)}return null}var um="cursoragent@cursor.com";function lm(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===um?null:t}function fm(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function dm(e){return Ut(e).replace(/\.git$/i,"").toLowerCase()}async function pm(e){let t=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?dm(t):e}async function mm(e){let t=$(await te("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!de(null,t))return t;let n=$(await te("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!de(null,n)?n:null}function gm(e,t){let n=fm(e,t);return n?Rt(`cursor_cloud|${n}|${lm(e)??""}`):null}async function hm(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await pm(n),o=await mm(n);return Rt(`claude_remote|${r}|${o??""}`)}function Gi(e,t){let n=ra(e,t);if(n)return n;let r=cm(t);return r||ta()}async function _m(e){let n=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||tm(e);return Ji("sha256").update(n).digest("hex").slice(0,16)}function Sm(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function Em(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Sm(t.platform_agent_ids);return{installation_id:t.installation_id,...t.pinned===!0?{pinned:!0}:{},...n?{platform_agent_ids:n}:{},...typeof t.operator_identity_hash=="string"?{operator_identity_hash:t.operator_identity_hash}:{},...typeof t.operator_identity_sent_at=="string"?{operator_identity_sent_at:t.operator_identity_sent_at}:{}}}catch{return}}function at(e){if(Yi(e))try{return Em(Xi(e,"utf8"))}catch{}}function so(e){return at(e)}function oa(e,t,n){let r=at(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{ge(e,`${JSON.stringify(o,null,2)}
|
|
16
|
+
`)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: operator identity cache write failed open: ${i}`)}}function sa(e,t=Date.now()){if(!e)return!0;if(at(e)?.operator_identity_hash)return!1;let n=ea(e);try{if(Yi(n)){let r=Number.NaN;try{r=Number(Xi(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<om)return!1;try{qi(n)}catch{}}}catch{}try{return no(Fn(n),{recursive:!0}),Zi(n,`${t}
|
|
17
|
+
`,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(ua(r))return!1;let o=r instanceof Error?r.message:String(r);return E(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function ia(e){if(e)try{qi(ea(e))}catch{}}function aa(e,t){let r=at(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}function ca(e,t,n){if(!n)return;let r=at(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={installation_id:r.installation_id,platform_agent_ids:{...r.platform_agent_ids,[t]:n},...r.operator_identity_hash?{operator_identity_hash:r.operator_identity_hash}:{},...r.operator_identity_sent_at?{operator_identity_sent_at:r.operator_identity_sent_at}:{}};try{ge(e,`${JSON.stringify(o,null,2)}
|
|
18
|
+
`)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: platform_agent_id cache write failed open: ${i}`)}}function ua(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function ym(e,t){no(Fn(e),{recursive:!0}),Zi(e,`${JSON.stringify(t,null,2)}
|
|
19
|
+
`,{encoding:"utf8",flag:"wx"})}function Wi(e,t){try{return ym(e,t),t}catch(n){if(!ua(n))throw n;return at(e)}}function zi(e,t){no(Fn(e),{recursive:!0}),ge(e,`${JSON.stringify(t,null,2)}
|
|
20
|
+
`)}function Vi(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function $n(e,t={}){let n=t.home??ro(),r=t.env??process.env,o=await _m(e),s=sm(n),i={sessionId:t.sessionId,hostname:$(r.HOSTNAME)??void 0,osUser:$(r.USER)??$(r.LOGNAME)??$(r.USERNAME)??void 0,env:r},a=Gt(i),c=ra(t.overrideId,r),l=a==="cursor_cloud"&&to(i)?gm(r,e):a==="claude_remote"?await hm(r,e):null,u=at(s);if(u){let S=u;if(c&&c===u.installation_id&&u.pinned!==!0&&(S={...u,pinned:!0},zi(s,S)),!!l&&l!==S.installation_id&&!c&&S.pinned!==!0&&am(S.installation_id)&&l){let k={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return zi(s,k),{installationId:l,storePath:s,repoKey:o}}return{installationId:S.installation_id,storePath:s,repoKey:o}}let d=c??l??Gi(void 0,r),f=Wi(s,Vi(d,c));if(f)return{installationId:f.installation_id,storePath:s,repoKey:o};let p=c??l??Gi(void 0,r),g=Wi(s,Vi(p===d?ta():p,c));if(g)return{installationId:g.installation_id,storePath:s,repoKey:o};throw new Error(`Failed to create installation record at ${s}`)}import{existsSync as co,readFileSync as Nm}from"node:fs";import{dirname as vm,isAbsolute as Mm,join as Lm,relative as Hm}from"node:path";import{readFileSync as Rm,statSync as Cm}from"node:fs";import{homedir as io}from"node:os";import{join as Am}from"node:path";var km="hook-config.json",bm=10080*60*1e3,xm=1440*60*1e3,Im=2048,Om=1024*1024;function Ct(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function la(e=io()){return Am(pe(e),km)}function fa(e){let t=la(e);try{let n=Cm(t);if(!n.isFile()||n.size>Om)return;let r=JSON.parse(Rm(t,"utf8"));return Ct(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}function Tm(e){let t={};return typeof e.collect_prompt=="boolean"&&(t.collect_prompt=e.collect_prompt),t}function jn(e,t=io(),n=Date.now()){if(!e)return;let r=Kt(e);if(!r)return;let o=fa(t),s=o?o[r]:void 0;if(!Ct(s)||!Ct(s.config))return;let i=s.fetched_at_ms;if(!(typeof i!="number"||n-i>bm))return Tm(s.config)}function Pm(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!Ct(n)||!Ct(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>Im))return n.hook_config}function wm(e,t,n,r){let o={...e},s=o[t];if(Object.keys(n).length===0)return s===void 0?void 0:(delete o[t],o);if(!(Ct(s)&&JSON.stringify(s.config)===JSON.stringify(n)&&typeof s.fetched_at_ms=="number"&&s.fetched_at_ms<=r&&r-s.fetched_at_ms<xm))return o[t]={config:n,fetched_at_ms:r},o}function da(e,t,n=io(),r=Date.now()){let o=Pm(e),s=t?Kt(t):void 0;if(o===void 0||!s)return"skipped";try{let i=fa(n);if(i===void 0)return"skipped";let a=wm(i??{},s,o,r);return a?(ge(la(n),`${JSON.stringify(a,null,2)}
|
|
21
|
+
`),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(i){let a=i instanceof Error?i.message:String(i);return E(`WARN: hook config write failed open: ${a}`),"failed"}}function pa(e){for(let t of On){let n=Lm(e,t);if(co(n))return n}}async function Um(e=process.cwd(),t){let n=t??await Le(e);return pa(n)??pa(e)}async function Dm(e,t){let n=t??await Le(vm(e)),r=Hm(n,e);if(r.startsWith("..")||Mm(r))return!1;let o=await ye("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(E(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function ao(e){let t=Nm(e,"utf8");return he(xn(t),{})}function Fm(){return{schema_version:Ye,mcp_servers:[]}}function $m(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(E(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${t}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete e.capture_hook_input),e.debug===!0&&r.has("debug")&&(E(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}async function ma(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await Kr(e),o=M("EV_AI_HOOK_MANIFEST"),s=o&&co(o)?o:void 0,i=s?void 0:co(jt())?jt():void 0,a=s?void 0:await Um(e,n),c=i?ao(i):void 0,l=a?ao(a):void 0,u,d,f,p=new Set;if(s){u=ao(s),d=s,f=s;for(let I of Object.keys(u))p.add(I)}else if(c&&l){u=xi(l,c),d=i,f=a;for(let I of Object.keys(l))I in c||p.add(I)}else if(c)u=c,d=i;else if(l){u=l,d=a,f=a;for(let I of Object.keys(l))p.add(I)}else u=Fm();delete u.installation_id;let g=f?await Dm(f,n):!1;$m(u,f,g,p);let{installationId:S,storePath:A,repoKey:k}=await $n(n,{sessionId:t.sessionId}),O=Jr(u);return{manifestPath:d??A,manifest:u,installationId:S,installationStorePath:A,repoKey:k,collectorUrl:O,hookConfig:jn(O),platformAgentId:u.platform_agent_id??"",gitRoot:n,inGitRepo:r}}function ga(e){return{schema_version:Ye,...e?{collector_url:e}:{},mcp_servers:[]}}var jm=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function Bm(e){return e==="windows-x64"||e==="windows-arm64"}function uo(e=process.platform,t=process.arch){if(e==="darwin")return t==="arm64"?"darwin-arm64":t==="x64"?"darwin-x64":void 0;if(e==="linux")return t==="arm64"?"linux-arm64":t==="x64"?"linux-x64":void 0;if(e==="win32")return t==="x64"?"windows-x64":t==="arm64"?"windows-arm64":void 0}function ha(e=process.platform,t=process.arch){let n=uo(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${jm.join(", ")}.`);return n}function Km(e){return Bm(e)?`${Ie}.exe`:Ie}function lo(e){return`compile-out/bin/${e}/${Km(e)}`}function Xm(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://hooks.ev-ai.ai/{orgToken}/hook>`);let r=Et(n);if(r)throw new Error(`collector URL rejected: ${r}`);return Bt(n)}function qm(e){let t=e.collectorUrl?.trim();if(!t)return;let n=Et(t);if(n)throw new Error(`collector URL rejected: ${n}`);return Bt(t)}function Zm(e){return Xm(e,"install")}function Ca(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url")}return t}function Aa(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url");if(r==="--update")throw new Error("--update was removed; use the `update` command instead of `install --update`");if(r==="--delivery"){let o=e[n+1];(o==="npx"||o==="binary"||o==="local")&&(t.delivery=o,n+=1);continue}if(r==="--force"){t.force=!0;continue}if(r==="--no-claude"){t.skipClaude=!0;continue}if(r==="--no-cursor"){t.skipCursor=!0;continue}if(r==="--no-codex"){t.skipCodex=!0;continue}}return t}function ka(e=process.execPath){return ba(e)?"binary":"npx"}function Qm(){return W(De(),".ev-ai","agent-hook")}function eg(e=De()){return W(e,".ev-ai","agent-hook",Yr)}function tg(){let e=mo(Ym(import.meta.url)),t=W(e,"hook.mjs");return Xe(t)?t:W(e,"..","dist","hook.mjs")}function ba(e=process.execPath){return vn(e)}function xa(e,t){let n=Ra(_a(e),_a(t));return!n.startsWith("..")&&!Vm(n)}function Gn(e){return e.split(Jm).join("/")}function ng(e){return`node "$(git rev-parse --show-toplevel)/${Gn(e)}"`}function rg(e){return`"$(git rev-parse --show-toplevel)/${Gn(e)}"`}function og(e){return W(e,Xr)}function Ia(e,t){let n=og(e);po(mo(n),{recursive:!0}),ya(t,n,{force:!0});try{Ea(n,493)}catch{}return n}function sg(e){let t=W(Qm(),"current");try{Kn(t,{recursive:!0,force:!0})}catch{}Wm(e,t,process.platform==="win32"?"junction":"dir")}function Oa(e,t=Ue,n=De()){let r=W(n,".ev-ai","agent-hook",t),o=W(r,Ie);po(r,{recursive:!0}),ya(e,o,{force:!0});try{Ea(o,493)}catch{}return sg(r),W(n,".ev-ai","agent-hook",Yr)}function Ta(e){let t=uo();if(!t)return;let n=[W(e,lo(t)),W(e,"packages","agent-hook",lo(t))];for(let r of n)if(Xe(r)&&xa(e,r))return r}function ig(e=De()){let t=eg(e);return Xe(t)?t:void 0}function ag(e,t=De()){let n=ig(t);return n||(ba()?Oa(process.execPath,Ue,t):Ta(e))}function cg(e,t=De()){let n=Ta(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
|
|
22
|
+
To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=Oa(n,Ue,t),o=Ia(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}function Sa(e){let t=[W(e,"packages","agent-hook","dist","hook.mjs"),W(e,Oi)],n=tg();Xe(n)&&xa(e,n)&&t.unshift(n);for(let r of t){if(!Xe(r))continue;let o=Gn(Ra(e,r));return{command:ng(o),hookPath:o,strategy:"dev_mjs"}}}function ug(e){return e==="SessionStart"||e==="sessionStart"}function lg(e){return e.replace(/\s+--prefer-offline\b/g,"")}function Bn(e,t){return ug(e)?lg(t):t}function fg(e=Ln){return`npx -y --prefer-offline ${e}`}function dg(e,t=De(),n=ka()){if(n==="npx")return{command:fg(),hookPath:Ln,strategy:"npx"};if(n==="local"){let s=Sa(e);if(s)return s;throw new Error("local delivery requires packages/agent-hook/dist/hook.mjs (or node_modules/@ev-ai/agent-hook/dist/hook.mjs) under the git root \u2014 run yarn workspace @ev-ai/agent-hook build first")}let r=ag(e,t);if(r){Ia(e,r);let s=Gn(Xr);return{command:rg(s),hookPath:s,strategy:"project_binary"}}let o=Sa(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
|
|
23
|
+
curl -fsSL ${Ti}/install.sh | sh
|
|
24
24
|
Or use npx delivery:
|
|
25
|
-
npx ${
|
|
26
|
-
`,"utf8")}function Fe(e){if(Xe(e))try{return JSON.parse(gm(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}function Dm(e,t){let n=oa(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}function Fm(e){return(e.schema_version??Je)===Je&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}function ya(e,t){let n=W(e,Rn),r=Fe(n),o=Dm(r,t);return t.collectorUrl!==void 0||Xe(n)||!Fm(o)?(qe(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}function ao(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}function $m(e){if(ao(process.env))return!0;let t=De();return[...Wr(),W(t,".claude","settings.json"),W(t,".claude","remote-settings.json"),W(e,".claude","settings.json"),W(e,".claude","settings.local.json")].some(r=>{try{let o=Fe(r);return o?ao(o.env):!1}catch{return!1}})}function jm(e){try{let t=Fe(W(e,".claude","settings.json"));return t?ao(t.env):!1}catch{return!1}}function Ra(e){return Array.isArray(e)?e:[]}function jn(e){let t=[],n=r=>!!r&&typeof r=="object"&&Ea(r.command);for(let r of Ra(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],s=o.filter(i=>!n(i));if(!(s.length===0&&o.some(n))){if(s.length!==o.length){t.push({...r,hooks:s});continue}t.push(r)}}return t}function Ca(e,t){return[...jn(e),...t]}function fo(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!Ea(t.command)):[]}function Bm(e,t){return[...fo(e),{command:t}]}function Km(e){return typeof e=="string"?[e]:e}function Gm(e){let t=(n="")=>({hooks:Km(e).map(r=>({type:"command",command:Dn(n,r)}))});return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}function Wm(e){let t=typeof e=="string"?{command:e}:e,n=(r="")=>({hooks:[{type:"command",command:Dn(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:Dn(r,t.commandWindows)},statusMessage:gi}]});return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}var zm=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],Vm=["afterShellExecution","afterFileEdit"];function Jm(e,t=Vm){let n={...e};for(let r of t){if(!(r in n))continue;let o=fo(n[r]);o.length===0?delete n[r]:n[r]=o}return n}function Ym(e,t,n={}){let r=W(e,".claude/settings.json"),o=lo(t,"claude"),s=Fe(r)??{};if($m(e)&&!n.force){if(s.hooks&&typeof s.hooks=="object"){let u={...s.hooks};for(let d of Object.keys(u))u[d]=jn(u[d]),Ra(u[d]).length===0&&delete u[d];Object.keys(u).length===0?delete s.hooks:s.hooks=u,qe(r,s)}return!1}let a=s.hooks&&typeof s.hooks=="object"?s.hooks:{},c=Gm(o),l={...a};for(let[u,d]of Object.entries(c))l[u]=Ca(a[u],d);return s.hooks=l,qe(r,s),!0}function Xm(e,t){let n=W(e,".cursor/hooks.json"),r=lo(t,"cursor"),o=Fe(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=Jm({...s});for(let a of zm)i[a]=Bm(i[a],Dn(a,r));qe(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:i})}function qm(e,t){let n=W(e,".codex/hooks.json"),r=lo(t,"codex"),o=Fe(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=Wm(r),a={...s};for(let[c,l]of Object.entries(i))a[c]=Ca(s[c],l);qe(n,{...o,hooks:a})}function Zm(e){let t=W(e,".claude/settings.json"),n=Fe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let s of Object.keys(r)){let i=r[s],a=jn(i);JSON.stringify(i)!==JSON.stringify(a)&&(o=!0),a.length===0?delete r[s]:r[s]=a}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,qe(t,n),E(`Removed ev-ai hooks from ${t}`))}function Qm(e){let t=W(e,".cursor/hooks.json"),n=Fe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=fo(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks"&&a!=="version").length===0){Fn(t,{force:!0}),E(`Removed ${t}`);return}qe(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function eg(e){let t=W(e,".codex/hooks.json"),n=Fe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=jn(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks").length===0){Fn(t,{force:!0}),E(`Removed ${t}`);return}qe(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function po(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&sa(e,t)}async function Aa(e={}){let t=Am(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let s=e.delivery??pa();po(process.platform,process.arch,{requireBinaryArch:s==="binary"});let i=e.cwd??process.cwd(),a=await He(i),{command:c,hookPath:l,strategy:u}=Um(a,De(),s),{installationId:d,storePath:f}=await Hn(a,{overrideId:e.installationId}),{manifestPath:p,wrote:g}=ya(a,e),S=[];return n?E("Skipped Claude hook \u2014 --no-claude"):Ym(a,c,{force:e.force})?(S.push("Claude"),e.force&&jm(a)&&E("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):E("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?E("Skipped Cursor hook \u2014 --no-cursor"):(Xm(a,c),S.push("Cursor")),o?E("Skipped Codex hook \u2014 --no-codex"):(qm(a,c),S.push("Codex")),E(`Installed hook (${u}) at ${l}`),E(`Installation identity ${d} at ${f}`),g&&p?E(`Shared manifest written to ${p}`):E("Using package default collector config (no shared manifest file needed)"),E(S.length>0?`Wired ${S.join(", ")} hooks in ${a} (commands include --runner)`:`No runner hooks wired in ${a} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),u==="npx"?E("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):u==="project_binary"?E("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):u==="dev_mjs"&&E("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&p&&e.collectorUrl&&E("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:a,hookPath:l,manifestPath:p,installationStorePath:f,strategy:u}}async function ka(e=process.cwd()){po(process.platform,process.arch,{requireBinaryArch:!0});let t=await He(e),{projectPath:n,globalPath:r}=vm(t);E(`Refreshed ${r}`),E(`Refreshed ${n}`),E("Hook configs and shared manifest left unchanged")}async function ba(e={}){let t=Cm(e);e.collectorUrl=t,po(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await He(n),{manifestPath:o,wrote:s}=ya(r,e);if(t!==void 0&&(!o||!s))throw new Error("configure failed to write shared collector manifest");return s&&o?E(`Wrote ${o}`):t===void 0&&E("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),E("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}function xa(e){for(let t of[()=>Zm(e),()=>Qm(e),()=>eg(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: strip skipped a hook file: ${r}`)}}async function Ia(e=process.cwd()){let t=await He(e);return xa(t),E("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),E("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}async function Oa(e=process.cwd()){let t=await He(e);xa(t);for(let n of Cn){let r=W(t,n);if(Xe(r))try{Fn(r,{force:!0}),E(`Removed ${r}`)}catch(o){let s=o instanceof Error?o.message:String(o);E(`WARN: uninstall could not remove ${r}: ${s}`)}}}import{existsSync as U_,mkdirSync as D_,readdirSync as F_,readFileSync as $_,unlinkSync as Dc,writeFileSync as j_}from"node:fs";import{homedir as Fc}from"node:os";import{join as To}from"node:path";import{open as Ta,mkdir as tg,readFile as ng,readdir as rg,rename as og,stat as sg,rmdir as ig,unlink as ag,utimes as cg}from"node:fs/promises";var Bn=new WeakMap;function wa(e){if(e&&typeof e=="object"&&"code"in e)return e}function mo(e){return wa(e)?.code==="ENOENT"}function Na(e){return wa(e)?.code==="EEXIST"}async function va(e,t){try{return await e.readdir(t)}catch(n){if(mo(n))return[];throw n}}function Ma(){return{async open(e,t){let n=await Ta(e,t),r={path:e};return Bn.set(r,n),r},async write(e,t){let n=Pa(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Pa(e).sync()},async close(e){let t=Bn.get(e);Bn.delete(e),t&&await t.close()},rename:og,async readdir(e){return rg(e)},readFile:ng,async stat(e){let t=await sg(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await tg(e,t)},unlink:ag,rmdir:ig,utimes:cg,async fsyncDir(e){if(process.platform==="win32")return;let t=await Ta(e,"r");try{await t.sync()}finally{await t.close()}}}}function Pa(e){let t=Bn.get(e);if(!t)throw new Error("closed");return t}import{existsSync as Eg}from"node:fs";import{existsSync as ug}from"node:fs";import{homedir as Ha}from"node:os";import{join as lg}from"node:path";function Ua(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var fg={claude:{shared:{skillRoots:[".claude/skills"],dirs:[{dir:".claude/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".claude/commands",kind:"COMMAND",extensions:[".md"]},{dir:".claude/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["CLAUDE.md"],["CLAUDE.local.md"],[".claude/CLAUDE.md"]],settings:[".claude/settings.json",".claude/settings.local.json",".claude/hooks.json"]},homeOnly:{mcpJson:[".claude.json"],plugins:"claude",managed:"claude"},projectOnly:{mcpJson:[".mcp.json","mcp.json"]}},cursor:{shared:{skillRoots:[".cursor/skills"],dirs:[{dir:".cursor/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".cursor/commands",kind:"COMMAND",extensions:[".md"]},{dir:".cursor/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["AGENTS.md"]],settings:[".cursor/hooks.json",".cursor/sandbox.json",".cursor/permissions.json"],mcpJson:[".cursor/mcp.json"]},homeOnly:{skillRoots:[".cursor/skills-cursor"],memory:[[".cursor/AGENTS.md"]],settings:[".cursor/cli-config.json"],plugins:"cursor",managed:"cursor"},projectOnly:{skillRoots:[".agents/skills"],settings:[".cursor/cli.json"]}},codex:{shared:{skillRoots:[".agents/skills",".codex/skills"],dirs:[{dir:".codex/agents",kind:"SUBAGENT",extensions:[".toml",".md"]},{dir:".codex/prompts",kind:"COMMAND",extensions:[".md"]},{dir:".codex/rules",kind:"RULE",extensions:[".md",".rules"]}],memory:[["AGENTS.override.md","AGENTS.md"]],settings:[".codex/hooks.json",".codex/config.toml"],mcpToml:[".codex/config.toml"]},homeOnly:{memory:[[".codex/AGENTS.override.md",".codex/AGENTS.md"]],managed:"codex"}}};function La(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function dg(e,t={}){let{shared:n}=e;return{skillRoots:[...n.skillRoots,...t.skillRoots??[]],dirs:n.dirs,memory:[...n.memory,...t.memory??[]],settings:[...n.settings,...t.settings??[]],mcpJson:La(n.mcpJson,t.mcpJson),mcpToml:La(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Da(e){return Object.fromEntries(Object.entries(fg).map(([t,n])=>[t,dg(n,n[e])]))}var At=Da("homeOnly"),Qe=Da("projectOnly");function pg(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function mg(e,t){return pg(e).some(n=>ug(lg(t,n)))}function Fa(e,t){for(let n of e)if(mg(n,t))return!0;return!1}function Ze(e){return[...new Set(e)]}function et(e){let t=[],n=[],r=[],o=[],s=[],i=[],a=[];for(let c of e){t.push(...c.skillRoots);for(let l of c.dirs)l.kind==="SUBAGENT"?n.push(l.dir):l.kind==="COMMAND"?r.push(l.dir):o.push(l.dir);s.push(...c.memory.flat()),i.push(...c.settings),a.push(...c.mcpJson??[],...c.mcpToml??[])}return{skills:Ze(t),subagents:Ze(n),commands:Ze(r),rules:Ze(o),memory:Ze(s),settings:Ze(i),mcp:Ze(a)}}function gg(e,t=Ha(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...wn(o.managed,n,t));return Ze(r)}var tt=et(Object.values(At));function $a(e=Ha(),t=process.platform){return gg(Object.values(At),e,t)}import{existsSync as hg}from"node:fs";import{resolve as go}from"node:path";function he(e){return go(e).replaceAll("\\","/").replace(/\/$/,"")}function ct(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}function Kn(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let s of t)s===e||s.startsWith(n)?r.push(s):o.push(s);return r.length===0?t:[...r,...o]}var _g=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function Kt(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!_g.test(t)?null:t}function kt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=he(o);n.has(s)||(n.add(s),r.push(s))}return r}function Sg(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Oe(e,t,n,r=hg){for(let o of e)for(let s of t){let i=he(go(o,s)),a=go(o,s,n).replaceAll("\\","/");if(Sg(i,a)&&r(a))return a}return null}var Ba=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Ka=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,yg=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,ja=new Set(["applications","app","bin","boot","data","dev","etc","home","lib","media","mnt","node_modules","opt","pkg","private","proc","projects","repos","run","sbin","src","srv","sys","tmp","usr","users","var","volumes","workspace","workspaces"]),Rg=/^[a-z][a-z0-9-]{1,63}$/,Cg=[".cursor/skills",".claude/skills",".agents/skills"],Ag=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],kg=ct(Cg,et(Object.values(Qe)).skills),bg=ct(Ag,et(Object.values(At)).skills),xg=new Set(["read","read_file","view"]),Ig=new Set(["bash","shell","zsh"]);function ho(e){let t=e.replace(/\\/g,"/");return Ba.exec(t)?.[1]??null}function Og(e){let t=e.replace(/\\/g,"/"),r=Ka.exec(t)?.[1];return r?r.toLowerCase():null}function Tg(e){return ho(e)??Og(e)}function Pg(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}function Gn(e){return typeof e=="string"?Gn(ge(e,null)):!e||typeof e!="object"?null:Pg(e)}function Ga(e){if(typeof e=="string")return Ga(ge(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function _o(e){let t=Ga(e.tool_input);if(t)return t;let n=it(e.command);return n.length>0?n:null}function wg(e){let t=e.replace(/\\/g,"/"),n=Ba.exec(t);if(n?.[1])return n[1];let o=Ka.exec(t)?.[1];return o?o.toLowerCase():null}function Ng(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function So(e){let t=Gn(e.tool_input)??it(e.file_path);return t.length>0?t:null}function Gt(e,t,n){let r=Ng(e).toLowerCase();if(xg.has(r)){let o=So(e);return o?t(o):null}if(Ig.has(r)){let o=_o(e);return o?n(o):null}return null}function Wa(e){return Gt(e,Tg,wg)}function vg(e){let t=new Set,n=[];for(let r of e.matchAll(yg)){let o=r[1]?.toLowerCase();!o||t.has(o)||Mg(o)||(t.add(o),n.push(o))}return n}function Mg(e){let t=e.split("/")[0];return ja.has(e)||t!==void 0&&ja.has(t)}function za(e){let t=e.skillId.toLowerCase();if(!Rg.test(t))return null;let n=e.exists??Eg,r=`${t}/SKILL.md`,o=Oe(kt(e.launchCwd,e.gitRoot),kg,r,n);return o!==null?o:e.home?Oe([he(e.home)],bg,r,n):null}function Lg(e){return it(e.prompt)}function Va(e){let t=M(e,"command_name");if(t){let r=M(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=Lg(e);return n?vg(n):[]}var ko=Ve(rt(),1);import{existsSync as c_}from"node:fs";var lt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function zt(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function a_(e){if(!e)return"";let t=Ft(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return zt(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return zt(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?zt(o[1]):zt(t)}async function qn(e=process.cwd()){let t=await Ee("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,s]=await Promise.all([Ee("git",["remote","get-url","origin"],2e3,{cwd:e}),Ee("git",["branch","--show-current"],2e3,{cwd:e}),Ee("git",["rev-parse","HEAD"],2e3,{cwd:e}),Ee("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Ft(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function Sc(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=lt[n];if(!a)return"";let c=Bi(n,e.scope_path,i);if(s){let g=Xi(s,c);if(g)return g}let l=o??await qn(r),u=l?.remote?a_(l.remote):"";if(u||(u=zt(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&qi(s,c,p),p}var u_=[".cursor/rules",".claude/rules",".codex/rules"],l_=et(Object.values(Qe)).rules;function f_(e){return ct(Kn(e?lt[e]:void 0,u_),l_)}var d_=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Ec(e){let t=Kt(e.relativePath);if(!t)return null;let n=e.exists??c_,r=kt(e.launchCwd,e.gitRoot),o=f_(e.runnerPlatform),s=Oe(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=Oe(r,["."],t,n);if(i!==null)return i}return e.home?Oe([he(e.home)],o,t,n):null}function p_(e){let t=e.replace(/\\/g,"/"),r=d_.exec(t)?.[1];return r?(0,ko.nativeKeyForRulePath)(r):null}function yc(e){return Gt(e,ko.nativeKeyForRulePath,p_)}function Rc(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function Cc(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let s=o;if(s.type!=="rule")continue;let i=typeof s.file_path=="string"?s.file_path:"",a=Kt(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var bo=Ve(rt(),1);import{existsSync as m_}from"node:fs";var g_=[".cursor/commands",".claude/commands",".codex/prompts"],h_=et(Object.values(Qe)).commands;function __(e){return ct(Kn(e?lt[e]:void 0,g_),h_)}var S_=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Ac(e){let t=Kt(e.commandId);if(!t)return null;let n=e.exists??m_,r=`${t}.md`,o=__(e.runnerPlatform),s=Oe(kt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Oe([he(e.home)],o,r,n):null}function E_(e){let t=e.replace(/\\/g,"/"),r=S_.exec(t)?.[1];return r?(0,bo.nativeKeyForCommandPath)(r):null}function kc(e){return Gt(e,bo.nativeKeyForCommandPath,E_)}var Zn=Ve(rt(),1);function xo(e){let t=ai(e);if(t.problem){E(`WARN: ignoring --url/--token collector override: ${t.problem}`);return}return t.url}function bc(e,t){if(M(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function y_(){return!!(U("CURSOR_VERSION")??U("CURSOR_PROJECT_DIR"))}function xc(e,t,n){return e!=="claude"&&e!=="codex"?!1:bc(t,n)?!0:y_()}var R_=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Vt(e,t,n,r){return bc(e,t)?"cursor":An(r)?r:An(n)?n:M(e,"turn_id")?"codex":M(e,"session_id")||R_.has(t.toLowerCase())?"claude":"unknown"}function Qn(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function C_(e){switch(e){case"sessionstart":return"session_start";case"stop":case"sessionend":case"stopfailure":return"session_end";case"pretooluse":case"posttooluse":case"posttoolusefailure":case"permissiondenied":case"beforemcpexecution":case"beforeshellexecution":case"aftershellexecution":case"beforereadfile":case"afterfileedit":case"subagentstart":case"subagentstop":return"tool_invoked";case"beforesubmitprompt":case"userpromptexpansion":case"userpromptsubmit":return"skill_invoked";default:return""}}function Ic(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Oc(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function Tc(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function Jt(e){return M(e,"session_id")||M(e,"conversation_id")}function Io(e){return M(e,"prompt.id")||M(e,"prompt_id")||M(e,"generation_id")||M(e,"turn_id")}function Oo(e){return M(e,"hook_event_name")||M(e,"event")}function Pc(e,t,n){let r=Jt(e),o=Io(e),s=Oo(e),i=M(e,"source"),a=Vt(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var A_=["session_start","session_end","tool_invoked","skill_invoked"];function k_(e){return A_.includes(e)}function wc(e,t){return e&&k_(e)?e:C_(t.toLowerCase())}var b_={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function er(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Nc(e,t=""){let n=M(e,"tool_name")||M(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!er(n)&&(n=`MCP:${n}`):n=b_[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?it(o.skill)||it(o.skill_name):"")||M(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=Wa(a);let c=yc(a),l=kc(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var x_=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function vc(e){for(let t of["subagent_type","agent_type"]){let n=M(e,t);if(n&&x_.test(n))return n}return null}function Mc(e){let t=Ue(e,"duration_ms");if(typeof t=="number")return t;let n=Ue(e,"duration");return typeof n=="number"?n:null}var I_="error",O_="interrupted",T_="permission_denied",P_=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function Yt(e){return P_.test(e)?e:null}function w_(e){for(let t of["failure_type","error_type"]){let n=Yt(M(e,t));if(n)return n}return null}function Lc(e,t){return Ue(e,"is_interrupt")===!0?O_:t.toLowerCase()==="permissiondenied"?T_:w_(e)??I_}function Hc(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function N_(e,t){return Hc(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function v_(e,t){return Hc(t,n=>(0,Zn.mcpServerNameMatchesToolSegment)(n,e))}function M_(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,Zn.mcpServerToolSegmentForms)(s)){let a=`${i}__`;e.length>a.length&&e.slice(0,a.length).toLowerCase()===a.toLowerCase()&&i.length>r&&(n={mcpServer:s,mcpTool:e.slice(a.length)},r=i.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:v_(o[1],t)??o[1],mcpTool:o[2]}}function L_(e,t){if(/^mcp__/i.test(e))return M_(e.slice(5),t);if(/^MCP:/i.test(e)){let n=e.slice(4);if(!n)return{mcpServer:null,mcpTool:null};let r=n.indexOf(":");if(r>0)return{mcpServer:n.slice(0,r),mcpTool:n.slice(r+1)||null};let o=n.indexOf("__");return o>0?{mcpServer:n.slice(0,o),mcpTool:n.slice(o+2)||null}:{mcpServer:N_(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function H_(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function Uc(e,t=[],n=""){let r=e?L_(e,t):{mcpServer:null,mcpTool:null},o=Yt(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!er(e)&&(s=e),s&&(s=H_(s,o)),{mcpServer:o,mcpTool:s}}var $c=3e4,B_="claims",K_=!0,G_=100,W_=new Set(["sessionstart","sessionend","stopfailure"]),z_=["tool_name","tool","command","file_path","url"];function V_(e=Fc()){return To(ye(e),B_)}function jc(e,t){try{let n=$_(e,"utf8").split(`
|
|
27
|
-
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function
|
|
28
|
-
`,{encoding:"utf8",flag:"wx"})}catch(o){if(
|
|
29
|
-
|
|
30
|
-
`)}catch(n){let r=n instanceof Error?
|
|
25
|
+
npx ${Ln} install`)}function Pa(e){return typeof e!="string"?!1:e.includes("@ev-ai/agent-hook")||e.includes("agent-hook/dist/hook")||e.includes(".ev-ai/agent-hook")||e.includes(Ie)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}function go(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}function qe(e,t){po(mo(e),{recursive:!0}),zm(e,`${JSON.stringify(t,null,2)}
|
|
26
|
+
`,"utf8")}function Fe(e){if(Xe(e))try{return JSON.parse(Gm(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}function pg(e,t){let n=ga(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}function mg(e){return(e.schema_version??Ye)===Ye&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}function wa(e,t){let n=W(e,In),r=Fe(n),o=pg(r,t);return t.collectorUrl!==void 0||Xe(n)||!mg(o)?(qe(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}function fo(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}function gg(e){if(fo(process.env))return!0;let t=De();return[...Qr(),W(t,".claude","settings.json"),W(t,".claude","remote-settings.json"),W(e,".claude","settings.json"),W(e,".claude","settings.local.json")].some(r=>{try{let o=Fe(r);return o?fo(o.env):!1}catch{return!1}})}function hg(e){try{let t=Fe(W(e,".claude","settings.json"));return t?fo(t.env):!1}catch{return!1}}function Na(e){return Array.isArray(e)?e:[]}function Wn(e){let t=[],n=r=>!!r&&typeof r=="object"&&Pa(r.command);for(let r of Na(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],s=o.filter(i=>!n(i));if(!(s.length===0&&o.some(n))){if(s.length!==o.length){t.push({...r,hooks:s});continue}t.push(r)}}return t}function va(e,t){return[...Wn(e),...t]}function ho(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!Pa(t.command)):[]}function _g(e,t){return[...ho(e),{command:t}]}function Sg(e){return typeof e=="string"?[e]:e}function Eg(e){let t=(n="")=>({hooks:Sg(e).map(r=>({type:"command",command:Bn(n,r)}))});return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}function yg(e){let t=typeof e=="string"?{command:e}:e,n=(r="")=>({hooks:[{type:"command",command:Bn(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:Bn(r,t.commandWindows)},statusMessage:Li}]});return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}var Rg=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],Cg=["afterShellExecution","afterFileEdit"];function Ag(e,t=Cg){let n={...e};for(let r of t){if(!(r in n))continue;let o=ho(n[r]);o.length===0?delete n[r]:n[r]=o}return n}function kg(e,t,n={}){let r=W(e,".claude/settings.json"),o=go(t,"claude"),s=Fe(r)??{};if(gg(e)&&!n.force){if(s.hooks&&typeof s.hooks=="object"){let u={...s.hooks};for(let d of Object.keys(u))u[d]=Wn(u[d]),Na(u[d]).length===0&&delete u[d];Object.keys(u).length===0?delete s.hooks:s.hooks=u,qe(r,s)}return!1}let a=s.hooks&&typeof s.hooks=="object"?s.hooks:{},c=Eg(o),l={...a};for(let[u,d]of Object.entries(c))l[u]=va(a[u],d);return s.hooks=l,qe(r,s),!0}function bg(e,t){let n=W(e,".cursor/hooks.json"),r=go(t,"cursor"),o=Fe(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=Ag({...s});for(let a of Rg)i[a]=_g(i[a],Bn(a,r));qe(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:i})}function xg(e,t){let n=W(e,".codex/hooks.json"),r=go(t,"codex"),o=Fe(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=yg(r),a={...s};for(let[c,l]of Object.entries(i))a[c]=va(s[c],l);qe(n,{...o,hooks:a})}function Ig(e){let t=W(e,".claude/settings.json"),n=Fe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let s of Object.keys(r)){let i=r[s],a=Wn(i);JSON.stringify(i)!==JSON.stringify(a)&&(o=!0),a.length===0?delete r[s]:r[s]=a}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,qe(t,n),E(`Removed ev-ai hooks from ${t}`))}function Og(e){let t=W(e,".cursor/hooks.json"),n=Fe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=ho(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks"&&a!=="version").length===0){Kn(t,{force:!0}),E(`Removed ${t}`);return}qe(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function Tg(e){let t=W(e,".codex/hooks.json"),n=Fe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=Wn(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks").length===0){Kn(t,{force:!0}),E(`Removed ${t}`);return}qe(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function _o(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&ha(e,t)}async function Ma(e={}){let t=Zm(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let s=e.delivery??ka();_o(process.platform,process.arch,{requireBinaryArch:s==="binary"});let i=e.cwd??process.cwd(),a=await Le(i),{command:c,hookPath:l,strategy:u}=dg(a,De(),s),{installationId:d,storePath:f}=await $n(a,{overrideId:e.installationId}),{manifestPath:p,wrote:g}=wa(a,e),S=[];return n?E("Skipped Claude hook \u2014 --no-claude"):kg(a,c,{force:e.force})?(S.push("Claude"),e.force&&hg(a)&&E("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):E("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?E("Skipped Cursor hook \u2014 --no-cursor"):(bg(a,c),S.push("Cursor")),o?E("Skipped Codex hook \u2014 --no-codex"):(xg(a,c),S.push("Codex")),E(`Installed hook (${u}) at ${l}`),E(`Installation identity ${d} at ${f}`),g&&p?E(`Shared manifest written to ${p}`):E("Using package default collector config (no shared manifest file needed)"),E(S.length>0?`Wired ${S.join(", ")} hooks in ${a} (commands include --runner)`:`No runner hooks wired in ${a} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),u==="npx"?E("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):u==="project_binary"?E("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):u==="dev_mjs"&&E("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&p&&e.collectorUrl&&E("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:a,hookPath:l,manifestPath:p,installationStorePath:f,strategy:u}}async function La(e=process.cwd()){_o(process.platform,process.arch,{requireBinaryArch:!0});let t=await Le(e),{projectPath:n,globalPath:r}=cg(t);E(`Refreshed ${r}`),E(`Refreshed ${n}`),E("Hook configs and shared manifest left unchanged")}async function Ha(e={}){let t=qm(e);e.collectorUrl=t,_o(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await Le(n),{manifestPath:o,wrote:s}=wa(r,e);if(t!==void 0&&(!o||!s))throw new Error("configure failed to write shared collector manifest");return s&&o?E(`Wrote ${o}`):t===void 0&&E("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),E("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}function Ua(e){for(let t of[()=>Ig(e),()=>Og(e),()=>Tg(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: strip skipped a hook file: ${r}`)}}async function Da(e=process.cwd()){let t=await Le(e);return Ua(t),E("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),E("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}async function Fa(e=process.cwd()){let t=await Le(e);Ua(t);for(let n of On){let r=W(t,n);if(Xe(r))try{Kn(r,{force:!0}),E(`Removed ${r}`)}catch(o){let s=o instanceof Error?o.message:String(o);E(`WARN: uninstall could not remove ${r}: ${s}`)}}}import{existsSync as dS,mkdirSync as pS,readdirSync as mS,readFileSync as gS,unlinkSync as Vc,writeFileSync as hS}from"node:fs";import{homedir as Jc}from"node:os";import{join as vo}from"node:path";import{open as $a,mkdir as Pg,readFile as wg,readdir as Ng,rename as vg,stat as Mg,rmdir as Lg,unlink as Hg,utimes as Ug}from"node:fs/promises";var zn=new WeakMap;function Ba(e){if(e&&typeof e=="object"&&"code"in e)return e}function Wt(e){return Ba(e)?.code==="ENOENT"}function Vn(e){return Ba(e)?.code==="EEXIST"}async function Ka(e,t){try{return await e.readdir(t)}catch(n){if(Wt(n))return[];throw n}}function Ga(){return{async open(e,t){let n=await $a(e,t),r={path:e};return zn.set(r,n),r},async write(e,t){let n=ja(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await ja(e).sync()},async close(e){let t=zn.get(e);zn.delete(e),t&&await t.close()},rename:vg,async readdir(e){return Ng(e)},readFile:wg,async stat(e){let t=await Mg(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await Pg(e,t)},unlink:Hg,rmdir:Lg,utimes:Ug,async fsyncDir(e){if(process.platform==="win32")return;let t=await $a(e,"r");try{await t.sync()}finally{await t.close()}}}}function ja(e){let t=zn.get(e);if(!t)throw new Error("closed");return t}import{existsSync as Jg}from"node:fs";import{existsSync as Dg}from"node:fs";import{homedir as za}from"node:os";import{join as Fg}from"node:path";function Va(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var $g={claude:{shared:{skillRoots:[".claude/skills"],dirs:[{dir:".claude/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".claude/commands",kind:"COMMAND",extensions:[".md"]},{dir:".claude/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["CLAUDE.md"],["CLAUDE.local.md"],[".claude/CLAUDE.md"]],settings:[".claude/settings.json",".claude/settings.local.json",".claude/hooks.json"]},homeOnly:{mcpJson:[".claude.json"],plugins:"claude",managed:"claude"},projectOnly:{mcpJson:[".mcp.json","mcp.json"]}},cursor:{shared:{skillRoots:[".cursor/skills"],dirs:[{dir:".cursor/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".cursor/commands",kind:"COMMAND",extensions:[".md"]},{dir:".cursor/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["AGENTS.md"]],settings:[".cursor/hooks.json",".cursor/sandbox.json",".cursor/permissions.json"],mcpJson:[".cursor/mcp.json"]},homeOnly:{skillRoots:[".cursor/skills-cursor"],memory:[[".cursor/AGENTS.md"]],settings:[".cursor/cli-config.json"],plugins:"cursor",managed:"cursor"},projectOnly:{skillRoots:[".agents/skills"],settings:[".cursor/cli.json"]}},codex:{shared:{skillRoots:[".agents/skills",".codex/skills"],dirs:[{dir:".codex/agents",kind:"SUBAGENT",extensions:[".toml",".md"]},{dir:".codex/prompts",kind:"COMMAND",extensions:[".md"]},{dir:".codex/rules",kind:"RULE",extensions:[".md",".rules"]}],memory:[["AGENTS.override.md","AGENTS.md"]],settings:[".codex/hooks.json",".codex/config.toml"],mcpToml:[".codex/config.toml"]},homeOnly:{memory:[[".codex/AGENTS.override.md",".codex/AGENTS.md"]],managed:"codex"}}};function Wa(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function jg(e,t={}){let{shared:n}=e;return{skillRoots:[...n.skillRoots,...t.skillRoots??[]],dirs:n.dirs,memory:[...n.memory,...t.memory??[]],settings:[...n.settings,...t.settings??[]],mcpJson:Wa(n.mcpJson,t.mcpJson),mcpToml:Wa(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Ja(e){return Object.fromEntries(Object.entries($g).map(([t,n])=>[t,jg(n,n[e])]))}var At=Ja("homeOnly"),Qe=Ja("projectOnly");function Bg(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function Kg(e,t){return Bg(e).some(n=>Dg(Fg(t,n)))}function Ya(e,t){for(let n of e)if(Kg(n,t))return!0;return!1}function Ze(e){return[...new Set(e)]}function et(e){let t=[],n=[],r=[],o=[],s=[],i=[],a=[];for(let c of e){t.push(...c.skillRoots);for(let l of c.dirs)l.kind==="SUBAGENT"?n.push(l.dir):l.kind==="COMMAND"?r.push(l.dir):o.push(l.dir);s.push(...c.memory.flat()),i.push(...c.settings),a.push(...c.mcpJson??[],...c.mcpToml??[])}return{skills:Ze(t),subagents:Ze(n),commands:Ze(r),rules:Ze(o),memory:Ze(s),settings:Ze(i),mcp:Ze(a)}}function Gg(e,t=za(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Un(o.managed,n,t));return Ze(r)}var tt=et(Object.values(At));function Xa(e=za(),t=process.platform){return Gg(Object.values(At),e,t)}import{existsSync as Wg}from"node:fs";import{resolve as So}from"node:path";function _e(e){return So(e).replaceAll("\\","/").replace(/\/$/,"")}function ct(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}function Jn(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let s of t)s===e||s.startsWith(n)?r.push(s):o.push(s);return r.length===0?t:[...r,...o]}var zg=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function zt(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!zg.test(t)?null:t}function kt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=_e(o);n.has(s)||(n.add(s),r.push(s))}return r}function Vg(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Oe(e,t,n,r=Wg){for(let o of e)for(let s of t){let i=_e(So(o,s)),a=So(o,s,n).replaceAll("\\","/");if(Vg(i,a)&&r(a))return a}return null}var Za=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Qa=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,Yg=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,qa=new Set(["applications","app","bin","boot","data","dev","etc","home","lib","media","mnt","node_modules","opt","pkg","private","proc","projects","repos","run","sbin","src","srv","sys","tmp","usr","users","var","volumes","workspace","workspaces"]),Xg=/^[a-z][a-z0-9-]{1,63}$/,qg=[".cursor/skills",".claude/skills",".agents/skills"],Zg=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],Qg=ct(qg,et(Object.values(Qe)).skills),eh=ct(Zg,et(Object.values(At)).skills),th=new Set(["read","read_file","view"]),nh=new Set(["bash","shell","zsh"]);function Eo(e){let t=e.replace(/\\/g,"/");return Za.exec(t)?.[1]??null}function rh(e){let t=e.replace(/\\/g,"/"),r=Qa.exec(t)?.[1];return r?r.toLowerCase():null}function oh(e){return Eo(e)??rh(e)}function sh(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}function Yn(e){return typeof e=="string"?Yn(he(e,null)):!e||typeof e!="object"?null:sh(e)}function ec(e){if(typeof e=="string")return ec(he(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function yo(e){let t=ec(e.tool_input);if(t)return t;let n=it(e.command);return n.length>0?n:null}function ih(e){let t=e.replace(/\\/g,"/"),n=Za.exec(t);if(n?.[1])return n[1];let o=Qa.exec(t)?.[1];return o?o.toLowerCase():null}function ah(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Ro(e){let t=Yn(e.tool_input)??it(e.file_path);return t.length>0?t:null}function Vt(e,t,n){let r=ah(e).toLowerCase();if(th.has(r)){let o=Ro(e);return o?t(o):null}if(nh.has(r)){let o=yo(e);return o?n(o):null}return null}function tc(e){return Vt(e,oh,ih)}function ch(e){let t=new Set,n=[];for(let r of e.matchAll(Yg)){let o=r[1]?.toLowerCase();!o||t.has(o)||uh(o)||(t.add(o),n.push(o))}return n}function uh(e){let t=e.split("/")[0];return qa.has(e)||t!==void 0&&qa.has(t)}function nc(e){let t=e.skillId.toLowerCase();if(!Xg.test(t))return null;let n=e.exists??Jg,r=`${t}/SKILL.md`,o=Oe(kt(e.launchCwd,e.gitRoot),Qg,r,n);return o!==null?o:e.home?Oe([_e(e.home)],eh,r,n):null}function lh(e){return it(e.prompt)}function rc(e){let t=L(e,"command_name");if(t){let r=L(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=lh(e);return n?ch(n):[]}var Io=Ve(rt(),1);import{existsSync as U_}from"node:fs";var lt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function Yt(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function H_(e){if(!e)return"";let t=Ut(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return Yt(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return Yt(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?Yt(o[1]):Yt(t)}async function nr(e=process.cwd()){let t=await ye("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,s]=await Promise.all([ye("git",["remote","get-url","origin"],2e3,{cwd:e}),ye("git",["branch","--show-current"],2e3,{cwd:e}),ye("git",["rev-parse","HEAD"],2e3,{cwd:e}),ye("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Ut(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function Oc(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=lt[n];if(!a)return"";let c=Qi(n,e.scope_path,i);if(s){let g=aa(s,c);if(g)return g}let l=o??await nr(r),u=l?.remote?H_(l.remote):"";if(u||(u=Yt(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&ca(s,c,p),p}var D_=[".cursor/rules",".claude/rules",".codex/rules"],F_=et(Object.values(Qe)).rules;function $_(e){return ct(Jn(e?lt[e]:void 0,D_),F_)}var j_=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Tc(e){let t=zt(e.relativePath);if(!t)return null;let n=e.exists??U_,r=kt(e.launchCwd,e.gitRoot),o=$_(e.runnerPlatform),s=Oe(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=Oe(r,["."],t,n);if(i!==null)return i}return e.home?Oe([_e(e.home)],o,t,n):null}function B_(e){let t=e.replace(/\\/g,"/"),r=j_.exec(t)?.[1];return r?(0,Io.nativeKeyForRulePath)(r):null}function Pc(e){return Vt(e,Io.nativeKeyForRulePath,B_)}function wc(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function Nc(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let s=o;if(s.type!=="rule")continue;let i=typeof s.file_path=="string"?s.file_path:"",a=zt(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var Oo=Ve(rt(),1);import{existsSync as K_}from"node:fs";var G_=[".cursor/commands",".claude/commands",".codex/prompts"],W_=et(Object.values(Qe)).commands;function z_(e){return ct(Jn(e?lt[e]:void 0,G_),W_)}var V_=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function vc(e){let t=zt(e.commandId);if(!t)return null;let n=e.exists??K_,r=`${t}.md`,o=z_(e.runnerPlatform),s=Oe(kt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Oe([_e(e.home)],o,r,n):null}function J_(e){let t=e.replace(/\\/g,"/"),r=V_.exec(t)?.[1];return r?(0,Oo.nativeKeyForCommandPath)(r):null}function Mc(e){return Vt(e,Oo.nativeKeyForCommandPath,J_)}var rr=Ve(rt(),1);function To(e){let t=Ii(e);if(t.problem){E(`WARN: ignoring --url/--token collector override: ${t.problem}`);return}return t.url}function Lc(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function Y_(){return!!(M("CURSOR_VERSION")??M("CURSOR_PROJECT_DIR"))}function Hc(e,t,n){return e!=="claude"&&e!=="codex"?!1:Lc(t,n)?!0:Y_()}var X_=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Xt(e,t,n,r){return Lc(e,t)?"cursor":Tn(r)?r:Tn(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||X_.has(t.toLowerCase())?"claude":"unknown"}function or(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function q_(e){switch(e){case"sessionstart":return"session_start";case"stop":case"sessionend":case"stopfailure":return"session_end";case"pretooluse":case"posttooluse":case"posttoolusefailure":case"permissiondenied":case"beforemcpexecution":case"beforeshellexecution":case"aftershellexecution":case"beforereadfile":case"afterfileedit":case"subagentstart":case"subagentstop":return"tool_invoked";case"beforesubmitprompt":case"userpromptexpansion":case"userpromptsubmit":return"skill_invoked";default:return""}}function Uc(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Dc(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function Fc(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function qt(e){return L(e,"session_id")||L(e,"conversation_id")}function Po(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function wo(e){return L(e,"hook_event_name")||L(e,"event")}function $c(e,t,n){let r=qt(e),o=Po(e),s=wo(e),i=L(e,"source"),a=Xt(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var Z_=["session_start","session_end","tool_invoked","skill_invoked"];function Q_(e){return Z_.includes(e)}function No(e,t){return e&&Q_(e)?e:q_(t.toLowerCase())}var eS={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function sr(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function jc(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!sr(n)&&(n=`MCP:${n}`):n=eS[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?it(o.skill)||it(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=tc(a);let c=Pc(a),l=Mc(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var tS=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Bc(e){for(let t of["subagent_type","agent_type"]){let n=L(e,t);if(n&&tS.test(n))return n}return null}function Kc(e){let t=He(e,"duration_ms");if(typeof t=="number")return t;let n=He(e,"duration");return typeof n=="number"?n:null}var nS="error",rS="interrupted",oS="permission_denied",sS=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function Zt(e){return sS.test(e)?e:null}function iS(e){for(let t of["failure_type","error_type"]){let n=Zt(L(e,t));if(n)return n}return null}function Gc(e,t){return He(e,"is_interrupt")===!0?rS:t.toLowerCase()==="permissiondenied"?oS:iS(e)??nS}function Wc(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function aS(e,t){return Wc(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function cS(e,t){return Wc(t,n=>(0,rr.mcpServerNameMatchesToolSegment)(n,e))}function uS(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,rr.mcpServerToolSegmentForms)(s)){let a=`${i}__`;e.length>a.length&&e.slice(0,a.length).toLowerCase()===a.toLowerCase()&&i.length>r&&(n={mcpServer:s,mcpTool:e.slice(a.length)},r=i.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:cS(o[1],t)??o[1],mcpTool:o[2]}}function lS(e,t){if(/^mcp__/i.test(e))return uS(e.slice(5),t);if(/^MCP:/i.test(e)){let n=e.slice(4);if(!n)return{mcpServer:null,mcpTool:null};let r=n.indexOf(":");if(r>0)return{mcpServer:n.slice(0,r),mcpTool:n.slice(r+1)||null};let o=n.indexOf("__");return o>0?{mcpServer:n.slice(0,o),mcpTool:n.slice(o+2)||null}:{mcpServer:aS(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function fS(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function zc(e,t=[],n=""){let r=e?lS(e,t):{mcpServer:null,mcpTool:null},o=Zt(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!sr(e)&&(s=e),s&&(s=fS(s,o)),{mcpServer:o,mcpTool:s}}var Yc=3e4,_S="claims",SS=!0,ES=100,yS=new Set(["sessionstart","sessionend","stopfailure"]),RS=["tool_name","tool","command","file_path","url"];function CS(e=Jc()){return vo(pe(e),_S)}function Xc(e,t){try{let n=gS(e,"utf8").split(`
|
|
27
|
+
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function AS(e){let t=[];for(let n of RS){let r=L(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":Dt(t.join("\0"))}function kS(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),s=e.subagentId?.trim()??"",i=e.callFingerprint?.trim()??"",a=!!(o||r||s),c=yS.has(n);if(!a&&!c)return;let l=e.runnerPlatform.trim()||"unknown";return Dt(`${l}|${t}|${n}|${r}|${o}|${i}|${s}`)}function bS(e,t=Date.now()){let n;try{n=mS(e)}catch{return}let r=0;for(let o of n){if(r>=ES)break;r+=1;let s=vo(e,o),i=Xc(s,t);if(!(!Number.isFinite(i)||i<Yc))try{Vc(s)}catch{}}}function xS(e,t,n=Date.now()){let r=vo(t,e);try{if(dS(r)){let o=Xc(r,n);if(Number.isFinite(o)&&o>=0&&o<Yc)return!1;try{Vc(r)}catch{}}}catch{}try{pS(t,{recursive:!0}),hS(r,`${n}
|
|
28
|
+
`,{encoding:"utf8",flag:"wx"})}catch(o){if(Vn(o))return!1;let s=o instanceof Error?o.message:String(o);return E(`WARN: event claim failed open: ${s}`),!0}return bS(t,n),!0}function IS(e,t,n){let r=qt(e),o=Po(e),s=L(e,"tool_use_id"),i=L(e,"subagent_id")||L(e,"agent_id"),a=Xt(e,t,void 0,n),c=AS(e);return{runnerPlatform:a,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:i,callFingerprint:c}}function qc(e,t,n,r=Jc(),o=Date.now()){if(!SS)return!0;let s=kS(IS(e,t,n));if(!s)return!0;let i=xS(s,CS(r),o);return!i&&M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),i}import{mkdirSync as OS,readFileSync as ru,statSync as TS,unlinkSync as ou,writeFileSync as PS}from"node:fs";import{homedir as su}from"node:os";import{join as iu}from"node:path";var wS=4,NS=10;function Zc(e=process.platform){return e==="win32"?wS:NS}function au(e){return e==="session_start"||e==="session_end"}var cu=6e4,Mo=2e3,vS="slots",Lo=new Set,Qc=!1;function uu(e=su()){return iu(pe(e),vS)}function Ho(e,t=su(),n=process.platform){if(e!==void 0)return e>0?e:Zc(n);let r=ne(jt(t),{});return bi(r)??Zc(n)}function MS(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function lu(e,t){return iu(e,`slot-${t}`)}function fu(e){return`${e.pid}
|
|
29
|
+
${e.acquiredAtMs}
|
|
30
|
+
`}var LS=/^(\d+)\n(\d+)\n$/,HS=64;function US(e){let t=LS.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&n>0&&Number.isSafeInteger(r)?{pid:n,acquiredAtMs:r}:void 0}function du(e,t=Date.now()){let n,r;try{let i=TS(e);if(!i.isFile())return!1;r=i.mtimeMs,n=i.size<=HS?ru(e,"utf8"):""}catch{return!1}let o=US(n);if(!o)return Math.abs(t-r)<Mo;let s=t-o.acquiredAtMs;return s<-Mo||s>=cu?!1:MS(o.pid)}function pu(e,t=uu(),n=Date.now){for(let r=0;r<e;r+=1)if(!du(lu(t,r),n()))return!0;return e<=0}function mu(e){return{pid:process.pid,acquiredAtMs:e}}function eu(e,t){let n=e instanceof Error?e.message:String(e);return E(`WARN: hook process slot failed open: ${n}`),mu(t)}function tu(e){return Lo.add(e),Qc||(Qc=!0,process.once("exit",()=>{for(let t of[...Lo])Uo(t)})),e}function nu(e){try{return PS(e.path,fu(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(Vn(t))return!1;throw t}}function gu(e,t=uu(),n=Date.now){if(e<=0)return mu(n());let r;try{OS(t,{recursive:!0});for(let o=0;o<e;o+=1){let s={path:lu(t,o),pid:process.pid,acquiredAtMs:n()};if(nu(s))return tu(s);if(!du(s.path,n())){try{ou(s.path)}catch(i){if(!Wt(i)){r??=i;continue}}if(s.acquiredAtMs=n(),nu(s))return tu(s)}}}catch(o){return eu(o,n())}return r===void 0?null:eu(r,n())}function Uo(e,t=Date.now()){if(Lo.delete(e),!(!e.path||t-e.acquiredAtMs>=cu-Mo))try{ru(e.path,"utf8")===fu(e)&&ou(e.path)}catch{}}function Do(e){M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}import{closeSync as DS,writeSync as FS}from"node:fs";function hu(e=process.env){let t=e[Fr];if(delete e[Fr],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{FS(n,fi)}catch{}try{DS(n)}catch{}}}function Fo(e=process.env){let t=e[ii];if(t)return{launcherVersion:t,hookSource:e[ai]??"",fallbackReason:e[ci],launcherScope:e[ui]}}function _u(e,t){return(e?Kt(e):void 0)===t}import{realpathSync as ZA}from"node:fs";import{homedir as QA}from"node:os";var B=Ve(rt(),1);import{existsSync as $S,readFileSync as jS}from"node:fs";import{homedir as Su}from"node:os";import{join as BS}from"node:path";var KS="cloud-cache.json",GS=1440*60*1e3,WS=900*1e3;function zS(e=Su()){return BS(pe(e),KS)}function VS(e){if(!$S(e))return;let t=he(jS(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}function JS(e,t){try{ge(e,`${JSON.stringify(t)}
|
|
31
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cloud cache write failed open: ${r}`)}}function YS(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?WS:GS;return n-e.probed_at<r}async function XS(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,s]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!s?.ok)return;let i=o?.ok?(await o.text()).trim():"",a=s?.ok?(await s.text()).trim():"";if(!(!i&&!a))return{provider:"aws",region:i,instance_id:a}}async function qS(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}async function ZS(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}async function QS(e){let t=await Promise.allSettled([XS(e),qS(e),ZS(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function Eu(e,t){if(e==="interactive")return null;let n=t?.home??Su(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=zS(n),i=VS(s);if(YS(i,e,o))return i.result;let a=await QS(r);return JS(s,{context:e,probed_at:o,result:a}),a}var Au=Ve(rt(),1);import{existsSync as Ru}from"node:fs";import{homedir as Cu}from"node:os";import{join as Qt,resolve as $o,sep as yu}from"node:path";function ir(e,t,n){if(!Ru(e))return;let r=ne(e,{});for(let[o,s]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:s})}function eE(e,t,n){if(!Ru(e))return;let r=ne(e,{}),o=$o(t),s=null;for(let a of Object.keys(r.projects??{})){let c=$o(a);(o===c||o.startsWith(c.endsWith(yu)?c:c+yu))&&(s===null||c.length>$o(s).length)&&(s=a)}if(s===null)return;let i=r.projects?.[s]?.mcpServers??{};for(let[a,c]of Object.entries(i))n.set(a,{declared:{name:a,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:c})}function ku(e,t,n,r){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{declared:{name:s.name,source:"manifest"}});return n==="claude"?(ir(Qt(r,".claude.json"),{source:"claude_json_user"},o),eE(Qt(r,".claude.json"),t,o)):n==="cursor"&&ir(Qt(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),ir(Qt(t,".mcp.json"),{source:"mcp_json"},o),ir(Qt(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function jo(e,t=process.cwd(),n="claude",r=Cu()){return[...ku(e,t,n,r).values()].map(o=>o.declared)}function bu(e,t,n=process.cwd(),r="claude",o=Cu()){let s=ku(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[a,c]of s)if((0,Au.mcpServerNameMatchesToolSegment)(a,e))return c.config??null;return null}var tE=["CI","GITHUB_ACTIONS","GITLAB_CI","CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER","KUBERNETES_SERVICE_HOST","REMOTE_CONTAINERS","DEVCONTAINER","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_REF","GITHUB_SHA","GITHUB_RUN_ID","GITHUB_WORKFLOW","GITHUB_ACTOR","GITHUB_TRIGGERING_ACTOR","GITHUB_ACTOR_ID","GITHUB_USER","GITLAB_USER_LOGIN","GITLAB_USER_NAME","GITLAB_USER_EMAIL","BUILD_REQUESTEDFOR","BUILD_REQUESTEDFOREMAIL","BUILD_REQUESTEDFORID","BUILDKITE_BUILD_CREATOR","BUILDKITE_BUILD_CREATOR_EMAIL","BUILD_USER","BUILD_USER_ID","BUILD_USER_EMAIL","CHANGE_AUTHOR","CHANGE_AUTHOR_EMAIL","CIRCLE_USERNAME","CODEBUILD_INITIATOR","DRONE_COMMIT_AUTHOR","DRONE_COMMIT_AUTHOR_NAME","DRONE_COMMIT_AUTHOR_EMAIL","EV_AI_HOOK_OPERATOR_NAME","EV_AI_HOOK_OPERATOR_EMAIL","EV_AI_HOOK_OPERATOR_LOGIN","GIT_AUTHOR_NAME","GIT_AUTHOR_EMAIL","GIT_COMMITTER_NAME","GIT_COMMITTER_EMAIL","EMAIL","RUNNER_OS","RUNNER_ARCH","NODE_ENV","TERM_PROGRAM","CLAUDE_CODE_REMOTE","CLAUDE_CODE_REMOTE_SESSION_ID","CURSOR_AGENT","CURSOR_VERSION","CURSOR_CODE_REMOTE","CURSOR_USER_EMAIL","CODESPACES","CODESPACE_NAME","ANTHROPIC_BASE_URL","OPENAI_BASE_URL","OPENAI_API_BASE","AZURE_OPENAI_ENDPOINT","GOOGLE_GEMINI_BASE_URL","GEMINI_API_BASE","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX"],nE=["CURSOR_PROJECT_DIR"],rE=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function oE(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)rE.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function xu(e=process.env){let t=tE.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:oE(e[r]??"")}:{name:r,present:!1}),n=nE.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{homedir as ME}from"node:os";import{homedir as Iu}from"node:os";import{join as sE}from"node:path";function iE(e=Iu()){return sE(e,".claude.json")}function ar(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Ou(e=Iu()){let n=ne(iE(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=ar(n.emailAddress),o=ar(n.fullName)??ar(n.displayName),s=ar(n.accountUuid),i=r??s;return!i||de(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:i,identity_source:"claude_oauth"}}import{homedir as wu}from"node:os";import{join as Tu}from"node:path";var aE="https://api.openai.com/auth";function It(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Nu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function cE(e){let t=e.split(".");if(t.length!==3||t.some(r=>r.length===0))return null;let n=t[1];if(!n)return null;try{let r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"));return Nu(r)}catch{return null}}function Pu(e,t,n){return It(e[n])??It(t?.[n])}function uE(e=process.env,t=wu()){let n=It(e.CODEX_HOME)??Tu(t,".codex");return Tu(n,"auth.json")}function vu(e=process.env,t=wu()){let n=ne(uE(e,t),{}),r=It(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&It(n.OPENAI_API_KEY))return null;let o=It(n.tokens?.id_token);if(!o)return null;let s=cE(o);if(!s)return null;let i=Nu(s[aE]),a=Pu(s,i,"name"),c=Pu(s,i,"email");return!c||de(a,c)?null:{git_user_name:null,git_user_email:null,platform_login:c,identity_source:"codex_oauth"}}import{homedir as lr}from"node:os";import{join as Be}from"node:path";import{join as lE}from"node:path";var fE="cursor-ide-identity.json",dE=840*60*1e3;function Lu(e){return lE(pe(e),fE)}function Mu(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Hu(e){let t=ne(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:Mu(t.email),auth_id:Mu(t.auth_id)}}function Uu(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<dE}function Du(e,t){try{ge(e,`${JSON.stringify(t)}
|
|
32
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cursor IDE identity cache write failed open: ${r}`)}}import{execFileSync as pE}from"node:child_process";import{existsSync as mE}from"node:fs";import{createRequire as gE}from"node:module";import{pathToFileURL as hE}from"node:url";var $u=gE(import.meta.url),cr=`
|
|
31
33
|
SELECT key, value
|
|
32
34
|
FROM ItemTable
|
|
33
35
|
WHERE key LIKE 'cursorAuth/%'
|
|
34
36
|
AND key NOT LIKE '%Token%'
|
|
35
37
|
AND key NOT LIKE '%token%'
|
|
36
38
|
ORDER BY key
|
|
37
|
-
`.trim(),
|
|
38
|
-
`)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&i&&!
|
|
39
|
-
`);return q(n)}function
|
|
40
|
-
`)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),a=o.slice(s+1).trim();a&&(i==="user.name"?t=a:i==="user.email"&&(n=a))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function ZS(e,t=te){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return qS(n)}function QS(e=process.env){let t=j(e.GIT_AUTHOR_NAME),n=j(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=j(e.GIT_COMMITTER_NAME),o=j(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let s=j(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function Ke(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}function eE(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Ke(j(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=j(e.GITHUB_ACTOR)??j(e.GITHUB_TRIGGERING_ACTOR)??j(e.GITHUB_USER),s=Ke(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=Ke(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=Ke(j(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??j(e.BUILD_REQUESTEDFORID));if(u)return u;let d=j(e.BUILDKITE_BUILD_CREATOR_EMAIL),f=Ke(j(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(f)return f;let p=j(e.BUILD_USER_EMAIL)??j(e.CHANGE_AUTHOR_EMAIL),g=Ke(j(e.BUILD_USER)??j(e.CHANGE_AUTHOR),p,"jenkins",p??j(e.BUILD_USER_ID));if(g)return g;let S=j(e.CIRCLE_USERNAME),A=Ke(S,null,"circleci",S);if(A)return A;let k=j(e.CODEBUILD_INITIATOR),O=Ke(k,null,"codebuild",k);if(O)return O;let I=j(e.DRONE_COMMIT_AUTHOR_EMAIL),v=j(e.DRONE_COMMIT_AUTHOR),T=Ke(v??j(e.DRONE_COMMIT_AUTHOR_NAME),I,"drone",I??v);if(T)return T;if(Eu(e.CLAUDE_CODE_REMOTE)||Eu(e.CURSOR_AGENT)){let K=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:K&&!de(null,K)?K:null,identity_source:"cloud"}}return null}function Ho(e){return!!((e.git_user_name??e.git_user_email)&&!de(e.git_user_name,e.git_user_email))}function j(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Eu(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function tE(e,t,n){return e==="claude"?tu(t):e==="cursor"?_u(t,n):e==="codex"?iu(n,t):null}async function Uo(e,t=te,n=process.env,r={}){let o=await ZS(e,t),s=QS(n),i=Ho(o)?o:s&&Ho(s)?s:null,a=tE(r.runnerPlatform,r.home??YS(),n);if(a)return{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:a.platform_login,identity_source:a.identity_source};let c=eE(n);return c?.platform_login?{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source}:i?{...i,platform_login:null,identity_source:Ho(o)?"git_config":"git_env"}:c||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:s||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function Do(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??te,s=e.env??process.env,i=await Uo(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=XS(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?to(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&Vi(p,a,Nn())}}}function Fo(e){return e?!to(e)?.operator_identity_hash:!0}function yu(e){return!0}import{existsSync as hC,readFileSync as _C}from"node:fs";import{homedir as Vf}from"node:os";import{join as vt,resolve as SC}from"node:path";import{basename as cC,join as Nt}from"node:path";import{dirname as Nu,resolve as cr}from"node:path";import{existsSync as nE}from"node:fs";import{homedir as Au}from"node:os";import{relative as ku,resolve as Pe,sep as ot}from"node:path";var rE=["session_id","conversation_id","turn_id","generation_id","prompt.id","prompt_id","hook_event_name","event","source","status","stop_reason","reason","tool_name","tool","tool_use_id","skill_name","command_name","expansion_type","command_source","permission_mode","model","model_id","agent_id","agent_type","subagent_id","subagent_type","subagent_model","is_parallel_worker","effort","effort.level","duration_ms","duration","sandbox","failure_type","is_interrupt"],oE=["prompt","tool_input","tool_response","last_assistant_message","command"],sE=new Set;function iE(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return sE}}var bu=new Set(["on","1","true"]);function Go(e){let t=U("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?bu.has(t.toLowerCase()):e?.collect_prompt===!0}function xu(e,t){let n=Wo(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=U("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?bu.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function Iu(e){return Wo(e)==="allowlist"}function Wo(e){return U("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||e.debug===!0||U("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function aE(e){let t={};for(let n of rE){let r=Ue(e,n);r!==void 0&&(t[n]=r)}return t}function ir(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Pe(e),r=Pe(t),o=ku(r,n);return!o||o==="."?".":o.startsWith(`..${ot}`)||o===".."||Pe(r,o)!==n?null:o.split(ot).join("/")}function Ou(e,t){let n=ku(Pe(t),Pe(e)).split(ot).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function Tu(e){return typeof e!="string"||e.length===0?null:Pe(e).split(ot).join("/")}function cE(){let e=U("CURSOR_PROJECT_DIR");if(!e)return null;let t=Pe(e);return nE(t)?t.split(ot).join("/"):null}function jo(e,t){return ir(e,t)!==null}function uE(e,t){let n=Pe(t??Au(),".cursor").split(ot).join("/");return jo(e,n)}function lE(e,t,n){return t!==null&&jo(e,t)?!0:t!==null&&uE(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&jo(e,n.gitRoot)?!0:t===null}function Pu(e,t){let n=Tu(e.cwd);if(n!==null)return n;let r=Pe(process.cwd()).split(ot).join("/"),o=cE();return lE(r,o,t)?r:o??r}function zo(e,t={}){return Pu(e,t)}function Vo(e,t=Au()){let n=Pe(t).split(ot).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function Ru(e,t,n){let r=Tu(n.launchCwd)??Pu(t,n);e.cwd=Vo(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?ir(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var wu="\u2026[truncated]\u2026",Bo=Buffer.byteLength(wu,"utf8"),fE=8;function Qt(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Cu(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function dE(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}function pE(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=Bo)return Cu(e,t);let r=t-Bo,o=Math.ceil(r/2),s=Math.floor(r/2);return`${Cu(e,o)}${wu}${dE(e,s)}`}function Ko(e,t,n){if(typeof e=="string"){n.push({path:t,value:e,bytes:Buffer.byteLength(e,"utf8")});return}if(Array.isArray(e)){e.forEach((r,o)=>{Ko(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Ko(o,[...t,r],n)}function mE(e,t,n){let r=e;for(let s=0;s<t.length-1;s++){let i=t[s];if(i===void 0)return;r=(Array.isArray(r),r[i])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}var gE=256;function hE(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let s=Math.ceil((r+o)/2),i=0;for(let a of e)a.bytes>s&&(i+=a.bytes-s);i>=t?r=s:o=s-1}return r}function _E(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=Qt(e);if(s<=t)return;let i=[];Ko(e,[],i),i.sort((u,d)=>d.bytes-u.bytes);let a=i.filter(u=>u.bytes>n);if(a.length===0)return;let c=hE(a,s-t,n),l=Math.max(n,Math.min(c,r-1));if(l>=r)return;r=l;for(let u of a)u.bytes>r&&mE(e,u.path,pE(u.value,r))}}function SE(e,t){let n=Math.max(0,t-gE),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:Qt(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(Qt(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function $o(e,t){let n=Qt(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,_E(r,t,Bo+fE),Qt(r)>t&&SE(r,t),r}function EE(e,t,n){let r=iE(n.runnerEvent),o=n.promptCapture??Go();for(let s of oE){if(r.has(s)||s==="prompt"&&!o)continue;let i=t[s];i!==void 0&&(e[s]=i)}}function ar(e,t,n={}){let r=Wo(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,Ru(s,e,n),$o(s,Gr)}let o=aE(e);return Ru(o,e,n),r==="content"?(EE(o,e,n),$o(o,Gr)):$o(o,pi)}function yE(e){return typeof e=="string"&&e.length>0}function Jo(e){let t=cr(e.home),n=cr(e.launchCwd),r=e.gitRoot?cr(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&yE(e.remote)&&r!==null&&r!==t&&(i=r,o.add(r)),n!==t&&!o.has(n)&&(s.push({scope:"cwd",dir:n}),o.add(n)),i!==null&&s.push({scope:"repo",dir:i});let a=null,c=r!==null&&ir(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=Nu(r);for(;;){let u=cr(l);if(u===t)break;let d=Nu(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=Ou(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as vu,readdirSync as RE,realpathSync as CE}from"node:fs";import{basename as AE,dirname as kE,relative as bE,resolve as xE,sep as IE}from"node:path";var Yo=400,ur=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??Ye}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=xE(t).split(IE).join("/");return Vo(r,this.home)}let n=bE(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(kE(t))}/${AE(t)}`:n}claimFile(t){try{let n=CE(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!vu(t))return[];try{return RE(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(vu(t))return oe(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),s=t-(this.pluginExpandRemaining??0);return{result:o,expanded:s}}finally{this.pluginExpandRemaining=r}}};import{existsSync as ps,readFileSync as Xy,statSync as qy}from"node:fs";import{basename as Jl,join as pt,relative as ms}from"node:path";var Gl=Ve(Kl());var Jy=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Wl=Jy.map(e=>Gl.default.matcher(e,{dot:!0}));function Yy(e){return e===""?!1:Wl.some(t=>t(`${e}/`))}function zl(e,t){if(t==="")return!1;if(e==="")return Yy(t);let n=e.replace(/\/+$/,"");return Wl.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var gs=100*1024,Zy=4;function Qy(e){return e.length<=gs?e:`${e.slice(0,gs-1)}\u2026`}function eR(e){try{let t=Xy(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:Qy(n)}}catch{return null}}var Vl={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function tR(e){return e in Vl?Vl[e]:"UNSPECIFIED"}function Pt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=eR(t.absolutePath);if(!n)return!1;let r=t.name??Jl(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},s=tR(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function nR(e,t,n){let r=ms(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Jl(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function mt(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;hs(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function hs(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>Zy))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&zl(n.replace(/\\/g,"/"),ms(n,pt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(pt(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=pt(r,d.name,c);if(ps(g)){let S=ms(n,pt(r,d.name)).replace(/\\/g,"/");Pt(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}hs(e,{walkRoot:n,currentDir:pt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){hs(e,{walkRoot:n,currentDir:pt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(!d.isFile()||!l)continue;let f=d.name.toLowerCase();if(!l.some(g=>f.endsWith(g)))continue;let p=pt(r,d.name);Pt(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:nR(n,p,!0)})}}function Yl(e){for(let t of e)if(ps(t))try{if(qy(t).size>0)return t}catch{continue}return e.find(t=>ps(t))}import{existsSync as NR,readFileSync as vR}from"node:fs";var hr=Ve(rt(),1);var rR="<omitted>",oR=["package_name","package_spec","package_version","package_version_source"],Xl=100,ql=120,_r=[{raw:"tools",attr:"tools"},{raw:"autoApprove",attr:"auto_approve"},{raw:"auto_approve",attr:"auto_approve"},{raw:"alwaysAllow",attr:"always_allow"},{raw:"always_allow",attr:"always_allow"},{raw:"enabledTools",attr:"enabled_tools"},{raw:"enabled_tools",attr:"enabled_tools"},{raw:"disabledTools",attr:"disabled_tools"},{raw:"disabled_tools",attr:"disabled_tools"}],Zl=new Set(_r.map(e=>e.attr)),sR=["enabled","disabled"],iR=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],aR=new Set(["type","command","url","args","env","envVars","headers",...sR,...iR,..._r.map(e=>e.raw)]),cR=new Set(["transport","command_or_url","args","env_var_names","headers_present","auth","bearer_token_env_var","default_tools_approval_mode","env_http_header_names",...oR,...Zl,...[...Zl].map(e=>`${e}_truncated`)]);function Ql(e,t){for(let n of t)aR.has(n)||cR.has(n)||(e[n]=rR)}var uR=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,lR=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,fR=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,dR=/^bearer(?:\s+|$)/i;function Sr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function ef(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function _s(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=Sr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function gt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function pR(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,hr.launchContainsCredentials)({kind:"url",url:e})||(0,hr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=an([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,hr.launchContainsCredentials)({kind:"url",url:r}):!0)}function tf(e,t,n){pR(t,n)&&(e.launch_had_credentials=!0)}function mR(e){return fR.test(e)||dR.test(e)?"<redacted>":e.includes("://")?gt(e):e}function nf(e){if(/^https?:\/\//i.test(e))return gt(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${nf(e.slice(t+1))}`:mR(e)}function gR(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return uR.test(t)||lR.test(t)}function an(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(gR(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(nf(r))}return t}function hR(e){let t=ef(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>ql?r.slice(0,ql):r))].sort();if(n.length!==0)return n.length>Xl?{names:n.slice(0,Xl),truncated:!0}:{names:n,truncated:!1}}function _R(e){let t=Sr(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,s]of Object.entries(t))o.length>0&&n.push(o),typeof s=="string"&&s.length>0&&r.push(s);return{headers:n,envVars:r}}function rf(e,t){let n=new Set;for(let{raw:r,attr:o}of _r){if(n.has(o)||!(r in t))continue;let s=t[r];if(o==="auto_approve"&&typeof s=="boolean"){e.auto_approve=s,n.add(o);continue}let i=hR(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function of(e,t){let n=Sr(e),r={transport:t};if(!n)return r;Ql(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,s=typeof n.url=="string"?n.url:void 0,i=typeof n.serverUrl=="string"?n.serverUrl:void 0,a=o??s??i,c=ef(n.args);a&&(r.command_or_url=gt(a));let l=an(c);l.length>0&&(r.args=l),tf(r,a,c);let u=_R(n.env_http_headers),d=[...new Set([..._s(n.env),..._s(n.envVars),..._s(n.env_vars),...u.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();d.length>0&&(r.env_var_names=d),u.headers.length>0&&(r.env_http_header_names=[...new Set(u.headers)].sort());for(let S of["headers","http_headers","env_http_headers"])if(n[S]!==void 0&&n[S]!==null){r.headers_present=!0;break}let f=typeof n.auth=="string"?n.auth:void 0;f&&(r.auth=f);let p=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;p&&(r.bearer_token_env_var=p);let g=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return g&&(r.default_tools_approval_mode=g),rf(r,n),r}function sf(e){let t=Sr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function ys(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return q(JSON.stringify({name:e,attributes:r,enabled:n}))}function wt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function sn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}function Es(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function Ss(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=wt(n[1]);return r.length>0?r:void 0}function SR(e,t){let n=[],r=i=>{for(let a of i.split(/[,\n]/)){let c=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(a);c?.[1]&&n.push([c[1],wt(c[2]??"")])}},o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let s=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
|
|
41
|
-
${e}`);return s?.[1]&&r(s[1]),n}function
|
|
42
|
-
`)){let s=
|
|
39
|
+
`.trim(),Bo=new Map;function Fu(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:null}if(e instanceof Uint8Array){let t=Buffer.from(e).toString("utf8").trim();return t.length>0?t:null}return null}function ju(e){return e.toLowerCase().includes("token")}function Bu(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=Fu(r.key),s=Fu(r.value);o&&s&&!ju(o)&&t.set(o,s)}return t}function _E(e){let t=hE(e);return t.search="mode=ro&immutable=1",t.href}function SE(e){try{let t=$u("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(cr)??n.prepare(cr);return Bu(r.all?.())}finally{n.close?.()}}catch{return null}}function EE(e){let t=process.emitWarning.bind(process);process.emitWarning=((n,...r)=>{(typeof n=="string"?n:n instanceof Error?n.message:"").includes("SQLite is an experimental feature")||t(n,...r)});try{return e()}finally{process.emitWarning=t}}function yE(e){try{return EE(()=>{let t=$u("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return Bu(n.prepare(cr).all?.())}finally{n.close?.()}})}catch{return null}}function RE(e){let t=new Map;for(let n of e.split(`
|
|
40
|
+
`)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&i&&!ju(s)&&t.set(s,i)}return t}function CE(e){try{let t=pE("sqlite3",["-noheader","-batch","-separator"," ",e,cr],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return RE(t)}catch{return null}}function Ku(e){let t=Bo.get(e);if(t)return t;if(!mE(e)){let o=new Map;return Bo.set(e,o),o}let n=_E(e),r=SE(n)??CE(n)??yE(n)??new Map;return Bo.set(e,r),r}var AE="cursorAuth/cachedEmail",kE="cursorAuth/stripeMembershipAuthId";function ur(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function bE(e=lr(),t=process.platform,n=process.env){let r=ur(n.VSCODE_PORTABLE);if(r)return Be(r,"user-data");let o=ur(n.VSCODE_APPDATA);if(o)return Be(o,"Cursor");switch(t){case"darwin":return Be(e,"Library","Application Support","Cursor");case"win32":return Be(ur(n.APPDATA)??Be(e,"AppData","Roaming"),"Cursor");default:return Be(ur(n.XDG_CONFIG_HOME)??Be(e,".config"),"Cursor")}}function xE(e=lr()){return Be(e,".cursor","cli-config.json")}function IE(e=lr(),t=process.platform,n=process.env){return Be(bE(e,t,n),"User","globalStorage","state.vscdb")}function en(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function OE(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):en(e.userId)}function TE(e){return en(e.email)??en(e.authId)??OE(e)}function Ko(e){let t=en(e.email),n=en(e.displayName),r=TE(e);return!r||de(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}function PE(e){let n=ne(xE(e),{}).authInfo;return!n||typeof n!="object"?null:Ko(n)}function wE(e,t,n){let r=IE(e,process.platform,t),o=Lu(e),s=Hu(o);if(Uu(s,r,n))return Ko({email:s?.email,authId:s?.auth_id});let i=Ku(r),a=i.get(AE)??null,c=i.get(kE)??null;return Du(o,{read_at_ms:n,db_path:r,email:a,auth_id:c}),Ko({email:a,authId:c})}function Gu(e=lr(),t=process.env,n=Date.now()){return PE(e)??wE(e,t,n)}import{createHash as NE}from"node:crypto";import{resolve as vE}from"node:path";function q(e){return NE("sha256").update(e).digest("hex").slice(0,16)}function Go(e){return q(vE(e))}function Se(e,t){return`${e}\0${t}`}function Wu(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function tn(e){let n=[...e].sort((r,o)=>{let s=r.path.localeCompare(o.path);return s!==0?s:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
|
|
41
|
+
`);return q(n)}function LE(e,t,n="git_config",r=null){return q(`${e??""}|${t??""}|${r??""}|${n}`)}function HE(e){let t=null,n=null;for(let r of e.split(`
|
|
42
|
+
`)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),a=o.slice(s+1).trim();a&&(i==="user.name"?t=a:i==="user.email"&&(n=a))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function UE(e,t=te){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return HE(n)}function DE(e=process.env){let t=j(e.GIT_AUTHOR_NAME),n=j(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=j(e.GIT_COMMITTER_NAME),o=j(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let s=j(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function Ke(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}function FE(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Ke(j(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=j(e.GITHUB_ACTOR)??j(e.GITHUB_TRIGGERING_ACTOR)??j(e.GITHUB_USER),s=Ke(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=Ke(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=Ke(j(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??j(e.BUILD_REQUESTEDFORID));if(u)return u;let d=j(e.BUILDKITE_BUILD_CREATOR_EMAIL),f=Ke(j(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(f)return f;let p=j(e.BUILD_USER_EMAIL)??j(e.CHANGE_AUTHOR_EMAIL),g=Ke(j(e.BUILD_USER)??j(e.CHANGE_AUTHOR),p,"jenkins",p??j(e.BUILD_USER_ID));if(g)return g;let S=j(e.CIRCLE_USERNAME),A=Ke(S,null,"circleci",S);if(A)return A;let k=j(e.CODEBUILD_INITIATOR),O=Ke(k,null,"codebuild",k);if(O)return O;let I=j(e.DRONE_COMMIT_AUTHOR_EMAIL),v=j(e.DRONE_COMMIT_AUTHOR),T=Ke(v??j(e.DRONE_COMMIT_AUTHOR_NAME),I,"drone",I??v);if(T)return T;if(zu(e.CLAUDE_CODE_REMOTE)||zu(e.CURSOR_AGENT)){let K=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:K&&!de(null,K)?K:null,identity_source:"cloud"}}return null}function Wo(e){return!!((e.git_user_name??e.git_user_email)&&!de(e.git_user_name,e.git_user_email))}function j(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function zu(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function $E(e,t,n){return e==="claude"?Ou(t):e==="cursor"?Gu(t,n):e==="codex"?vu(n,t):null}async function zo(e,t=te,n=process.env,r={}){let o=await UE(e,t),s=DE(n),i=Wo(o)?o:s&&Wo(s)?s:null,a=$E(r.runnerPlatform,r.home??ME(),n);if(a)return{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:a.platform_login,identity_source:a.identity_source};let c=FE(n);return c?.platform_login?{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source}:i?{...i,platform_login:null,identity_source:Wo(o)?"git_config":"git_env"}:c||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:s||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function Vo(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??te,s=e.env??process.env,i=await zo(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=LE(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?so(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&oa(p,a,kn())}}}function Jo(e){return e?!so(e)?.operator_identity_hash:!0}function Vu(e){return!0}import{existsSync as tA,readFileSync as nA}from"node:fs";import{homedir as yd}from"node:os";import{join as vt,resolve as rA}from"node:path";import{basename as VC,join as Nt}from"node:path";import{dirname as sl,resolve as pr}from"node:path";import{existsSync as jE}from"node:fs";import{homedir as Xu}from"node:os";import{relative as qu,resolve as Pe,sep as ot}from"node:path";var BE=["session_id","conversation_id","turn_id","generation_id","prompt.id","prompt_id","hook_event_name","event","source","status","stop_reason","reason","tool_name","tool","tool_use_id","skill_name","command_name","expansion_type","command_source","permission_mode","model","model_id","agent_id","agent_type","subagent_id","subagent_type","subagent_model","is_parallel_worker","effort","effort.level","duration_ms","duration","sandbox","failure_type","is_interrupt"],KE=["prompt","tool_input","tool_response","last_assistant_message","command"],GE=new Set;function WE(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return GE}}var Zu=new Set(["on","1","true"]);function Qo(e){let t=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Zu.has(t.toLowerCase()):e?.collect_prompt===!0}function Qu(e,t){let n=es(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Zu.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function el(e){return es(e)==="allowlist"}function es(e){return M("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||e.debug===!0||M("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function zE(e){let t={};for(let n of BE){let r=He(e,n);r!==void 0&&(t[n]=r)}return t}function fr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Pe(e),r=Pe(t),o=qu(r,n);return!o||o==="."?".":o.startsWith(`..${ot}`)||o===".."||Pe(r,o)!==n?null:o.split(ot).join("/")}function tl(e,t){let n=qu(Pe(t),Pe(e)).split(ot).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function nl(e){return typeof e!="string"||e.length===0?null:Pe(e).split(ot).join("/")}function VE(){let e=M("CURSOR_PROJECT_DIR");if(!e)return null;let t=Pe(e);return jE(t)?t.split(ot).join("/"):null}function Xo(e,t){return fr(e,t)!==null}function JE(e,t){let n=Pe(t??Xu(),".cursor").split(ot).join("/");return Xo(e,n)}function YE(e,t,n){return t!==null&&Xo(e,t)?!0:t!==null&&JE(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Xo(e,n.gitRoot)?!0:t===null}function rl(e,t){let n=nl(e.cwd);if(n!==null)return n;let r=Pe(process.cwd()).split(ot).join("/"),o=VE();return YE(r,o,t)?r:o??r}function ts(e,t={}){return rl(e,t)}function ns(e,t=Xu()){let n=Pe(t).split(ot).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function Ju(e,t,n){let r=nl(n.launchCwd)??rl(t,n);e.cwd=ns(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?fr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var ol="\u2026[truncated]\u2026",qo=Buffer.byteLength(ol,"utf8"),XE=8;function nn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Yu(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function qE(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}function ZE(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=qo)return Yu(e,t);let r=t-qo,o=Math.ceil(r/2),s=Math.floor(r/2);return`${Yu(e,o)}${ol}${qE(e,s)}`}function Zo(e,t,n){if(typeof e=="string"){n.push({path:t,value:e,bytes:Buffer.byteLength(e,"utf8")});return}if(Array.isArray(e)){e.forEach((r,o)=>{Zo(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Zo(o,[...t,r],n)}function QE(e,t,n){let r=e;for(let s=0;s<t.length-1;s++){let i=t[s];if(i===void 0)return;r=(Array.isArray(r),r[i])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}var ey=256;function ty(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let s=Math.ceil((r+o)/2),i=0;for(let a of e)a.bytes>s&&(i+=a.bytes-s);i>=t?r=s:o=s-1}return r}function ny(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=nn(e);if(s<=t)return;let i=[];Zo(e,[],i),i.sort((u,d)=>d.bytes-u.bytes);let a=i.filter(u=>u.bytes>n);if(a.length===0)return;let c=ty(a,s-t,n),l=Math.max(n,Math.min(c,r-1));if(l>=r)return;r=l;for(let u of a)u.bytes>r&&QE(e,u.path,ZE(u.value,r))}}function ry(e,t){let n=Math.max(0,t-ey),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:nn(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(nn(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function Yo(e,t){let n=nn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,ny(r,t,qo+XE),nn(r)>t&&ry(r,t),r}function oy(e,t,n){let r=WE(n.runnerEvent),o=n.promptCapture??Qo();for(let s of KE){if(r.has(s)||s==="prompt"&&!o)continue;let i=t[s];i!==void 0&&(e[s]=i)}}function dr(e,t,n={}){let r=es(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,Ju(s,e,n),Yo(s,Zr)}let o=zE(e);return Ju(o,e,n),r==="content"?(oy(o,e,n),Yo(o,Zr)):Yo(o,vi)}function sy(e){return typeof e=="string"&&e.length>0}function rs(e){let t=pr(e.home),n=pr(e.launchCwd),r=e.gitRoot?pr(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&sy(e.remote)&&r!==null&&r!==t&&(i=r,o.add(r)),n!==t&&!o.has(n)&&(s.push({scope:"cwd",dir:n}),o.add(n)),i!==null&&s.push({scope:"repo",dir:i});let a=null,c=r!==null&&fr(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=sl(r);for(;;){let u=pr(l);if(u===t)break;let d=sl(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=tl(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as il,readdirSync as iy,realpathSync as ay}from"node:fs";import{basename as cy,dirname as uy,relative as ly,resolve as fy,sep as dy}from"node:path";var os=400,mr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??Je}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=fy(t).split(dy).join("/");return ns(r,this.home)}let n=ly(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(uy(t))}/${cy(t)}`:n}claimFile(t){try{let n=ay(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!il(t))return[];try{return iy(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(il(t))return ne(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),s=t-(this.pluginExpandRemaining??0);return{result:o,expanded:s}}finally{this.pluginExpandRemaining=r}}};import{existsSync as Cs,readFileSync as LR,statSync as HR}from"node:fs";import{basename as Cf,join as pt,relative as As}from"node:path";var Sf=Ve(_f());var vR=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Ef=vR.map(e=>Sf.default.matcher(e,{dot:!0}));function MR(e){return e===""?!1:Ef.some(t=>t(`${e}/`))}function yf(e,t){if(t==="")return!1;if(e==="")return MR(t);let n=e.replace(/\/+$/,"");return Ef.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var ks=100*1024,UR=4;function DR(e){return e.length<=ks?e:`${e.slice(0,ks-1)}\u2026`}function FR(e){try{let t=LR(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:DR(n)}}catch{return null}}var Rf={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function $R(e){return e in Rf?Rf[e]:"UNSPECIFIED"}function Pt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=FR(t.absolutePath);if(!n)return!1;let r=t.name??Cf(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},s=$R(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function jR(e,t,n){let r=As(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Cf(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function mt(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;bs(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function bs(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>UR))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&yf(n.replace(/\\/g,"/"),As(n,pt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(pt(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=pt(r,d.name,c);if(Cs(g)){let S=As(n,pt(r,d.name)).replace(/\\/g,"/");Pt(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}bs(e,{walkRoot:n,currentDir:pt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){bs(e,{walkRoot:n,currentDir:pt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(!d.isFile()||!l)continue;let f=d.name.toLowerCase();if(!l.some(g=>f.endsWith(g)))continue;let p=pt(r,d.name);Pt(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:jR(n,p,!0)})}}function Af(e){for(let t of e)if(Cs(t))try{if(HR(t).size>0)return t}catch{continue}return e.find(t=>Cs(t))}import{existsSync as _C,readFileSync as SC}from"node:fs";var Rr=Ve(rt(),1);var BR="<omitted>",KR=["package_name","package_spec","package_version","package_version_source"],kf=100,bf=120,Cr=[{raw:"tools",attr:"tools"},{raw:"autoApprove",attr:"auto_approve"},{raw:"auto_approve",attr:"auto_approve"},{raw:"alwaysAllow",attr:"always_allow"},{raw:"always_allow",attr:"always_allow"},{raw:"enabledTools",attr:"enabled_tools"},{raw:"enabled_tools",attr:"enabled_tools"},{raw:"disabledTools",attr:"disabled_tools"},{raw:"disabled_tools",attr:"disabled_tools"}],xf=new Set(Cr.map(e=>e.attr)),GR=["enabled","disabled"],WR=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],zR=new Set(["type","command","url","args","env","envVars","headers",...GR,...WR,...Cr.map(e=>e.raw)]),VR=new Set(["transport","command_or_url","args","env_var_names","headers_present","auth","bearer_token_env_var","default_tools_approval_mode","env_http_header_names",...KR,...xf,...[...xf].map(e=>`${e}_truncated`)]);function If(e,t){for(let n of t)zR.has(n)||VR.has(n)||(e[n]=BR)}var JR=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,YR=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,XR=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,qR=/^bearer(?:\s+|$)/i;function Ar(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Of(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function xs(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=Ar(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function gt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function ZR(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Rr.launchContainsCredentials)({kind:"url",url:e})||(0,Rr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=ln([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Rr.launchContainsCredentials)({kind:"url",url:r}):!0)}function Tf(e,t,n){ZR(t,n)&&(e.launch_had_credentials=!0)}function QR(e){return XR.test(e)||qR.test(e)?"<redacted>":e.includes("://")?gt(e):e}function Pf(e){if(/^https?:\/\//i.test(e))return gt(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Pf(e.slice(t+1))}`:QR(e)}function eC(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return JR.test(t)||YR.test(t)}function ln(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(eC(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Pf(r))}return t}function tC(e){let t=Of(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>bf?r.slice(0,bf):r))].sort();if(n.length!==0)return n.length>kf?{names:n.slice(0,kf),truncated:!0}:{names:n,truncated:!1}}function nC(e){let t=Ar(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,s]of Object.entries(t))o.length>0&&n.push(o),typeof s=="string"&&s.length>0&&r.push(s);return{headers:n,envVars:r}}function wf(e,t){let n=new Set;for(let{raw:r,attr:o}of Cr){if(n.has(o)||!(r in t))continue;let s=t[r];if(o==="auto_approve"&&typeof s=="boolean"){e.auto_approve=s,n.add(o);continue}let i=tC(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Nf(e,t){let n=Ar(e),r={transport:t};if(!n)return r;If(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,s=typeof n.url=="string"?n.url:void 0,i=typeof n.serverUrl=="string"?n.serverUrl:void 0,a=o??s??i,c=Of(n.args);a&&(r.command_or_url=gt(a));let l=ln(c);l.length>0&&(r.args=l),Tf(r,a,c);let u=nC(n.env_http_headers),d=[...new Set([...xs(n.env),...xs(n.envVars),...xs(n.env_vars),...u.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();d.length>0&&(r.env_var_names=d),u.headers.length>0&&(r.env_http_header_names=[...new Set(u.headers)].sort());for(let S of["headers","http_headers","env_http_headers"])if(n[S]!==void 0&&n[S]!==null){r.headers_present=!0;break}let f=typeof n.auth=="string"?n.auth:void 0;f&&(r.auth=f);let p=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;p&&(r.bearer_token_env_var=p);let g=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return g&&(r.default_tools_approval_mode=g),wf(r,n),r}function vf(e){let t=Ar(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function Ts(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return q(JSON.stringify({name:e,attributes:r,enabled:n}))}function wt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function un(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}function Os(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function Is(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=wt(n[1]);return r.length>0?r:void 0}function rC(e,t){let n=[],r=i=>{for(let a of i.split(/[,\n]/)){let c=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(a);c?.[1]&&n.push([c[1],wt(c[2]??"")])}},o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let s=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
|
|
43
|
+
${e}`);return s?.[1]&&r(s[1]),n}function Mf(e){return Os(e,"enabled")===!1?!1:Os(e,"disabled")!==!0}function oC(e,t){let n={};for(let{raw:r,attr:o}of Cr){if(o==="auto_approve"){let i=Os(t,r);if(i!==void 0){n[r]=i;continue}}let s=un(t,r);s.length>0&&(n[r]=s)}wf(e,n)}var sC=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,iC=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function aC(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
|
|
44
|
+
`)){let s=sC.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(iC))o[1]&&t.add(o[1]);return[...t]}function Lf(e,t){let n={transport:t};If(n,aC(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?wt(r[1]??""):void 0,i=o?wt(o[1]??""):void 0,a=s!==void 0&&s.length>0?s:i,c=un(e,"args");a&&(n.command_or_url=gt(a));let l=ln(c);l.length>0&&(n.args=l),Tf(n,a,c);let u=new Set;for(let k of e.split(`
|
|
43
45
|
`)){let O=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);O?.[1]&&u.add(O[1])}let d=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(d?.[1])for(let k of d[1].split(",")){let O=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);O?.[1]&&u.add(O[1])}let f=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
|
|
44
46
|
${e}`);if(f?.[1])for(let k of f[1].split(`
|
|
45
|
-
`)){let O=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);O?.[1]&&u.add(O[1])}for(let k of
|
|
46
|
-
`);return xR("sha512").update(t).digest("hex").slice(0,16)}function TR(e){let t=process.platform==="win32"?cn(U("LOCALAPPDATA")??e,"npm-cache"):cn(e,".npm"),n=U("npm_config_cache")??U("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function pf(e){return typeof e=="string"&&e.length>0&&e.length<=ve.PACKAGE_FIELD_MAX?e:null}function PR(e,t,n){let r=OR(e);for(let o of TR(n)){let s=cn(o,"_npx",r),i=oe(cn(s,"node_modules",...t.split("/"),"package.json"),{}),a=pf(i.version);if(a!==null)return a;let c=oe(cn(s,"package-lock.json"),{}),l=pf(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function wR(e){return e.length<=ve.PACKAGE_FIELD_MAX?e:`${e.slice(0,ve.PACKAGE_FIELD_MAX-1)}\u2026`}function Rs(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,ve.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,ve.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:wR(o),...IR(o,PR(r,s,n))}}function mf(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Er(e.trim());return n===void 0?null:Rs(n,r,t)}function yr(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e,r=Array.isArray(n.args)?n.args.filter(o=>typeof o=="string"):[];return Rs(typeof n.command=="string"?n.command:null,r,t)}function gf(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Rs(wt(n[1]??""),sn(e,"args"),t)}function MR(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}function hf(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let s=e.componentPath(t);for(let[i,a]of Object.entries(o)){if(e.truncated)return;let c=MR(a),l=of(a,c);Object.assign(l,yr(a,e.home)??{});let u=sf(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:ys(i,l,u),origin:n,enabled:u,attributes:l})}}function _f(e,t,n){if(!NR(t)||!e.claimFile(t))return;let r;try{r=vR(t,"utf8")}catch{return}let o=e.componentPath(t),s=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,i;for(;(i=s.exec(r))!==null;){if(e.truncated)return;let a=i[1]??i[2]??i[3];if(!a)continue;let c=r.slice(i.index+i[0].length),l=c.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),u=l===-1?c:c.slice(0,l),d="unknown";/^\s*url\s*=/m.test(u)?d="http":/^\s*command\s*=/m.test(u)&&(d="stdio");let f=cf(u,d);Object.assign(f,gf(u,e.home)??{});let p=af(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:ys(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as UR,readdirSync as DR}from"node:fs";import{join as ue}from"node:path";function LR(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}function HR(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}function Cs(e,t,n,r){let o=e.componentPath(t);for(let[s,i]of Object.entries(n))if(!(!Array.isArray(i)||e.truncated))for(let a of i){if(!a||typeof a!="object"||e.truncated)continue;let c=a;for(let l of HR(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=LR({type:l.type??c.type,command:l.command??c.command,bash:l.bash??c.bash,powershell:l.powershell??c.powershell,prompt:l.prompt??c.prompt}),f=typeof c.matcher=="string"?c.matcher:"",p=q(u),g=f?`${s}:${f}:${d}:${p}`:`${s}:${d}:${p}`,S=`${s}|${f}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:q(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:ff(u,e.home)}:{}}})}}}function As(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||Cs(e,t,r.hooks,n)}var Sf=50;function un(e,t,n,r){if(!UR(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(Sf,()=>{mt(e,{dir:ue(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),mt(e,{dir:ue(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),mt(e,{dir:ue(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});As(e,ue(t,"hooks","hooks.json"),n),As(e,ue(t,"hooks.json"),n);let i=e.components.length-o,a=s>=Sf;return{componentCount:i,expandTruncated:a}}function ln(e,t){e.push({kind:"PLUGIN",name:t.pluginKey,path:t.rowPath,content_hash:t.contentHash,origin:"user",enabled:t.enabled,attributes:{...t.marketplace?{marketplace:t.marketplace}:{},...t.version?{version:t.version}:{},scope:t.scope,component_count:t.componentCount,...t.expandTruncated?{expand_truncated:!0}:{}}})}function Ef(e){let t=ue(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},s=e.readJson(ue(e.home,".claude/settings.json"),{})?.enabledPlugins??{},i=e.componentPath(t);for(let[a,c]of Object.entries(r)){if(e.truncated)return;let l=Array.isArray(c)?c:[c],u=l[0]??{},d=s[a]===!0,f=a.includes("@")?a.split("@").slice(1).join("@"):"",p=typeof u.version=="string"?u.version:"",g=typeof u.scope=="string"?u.scope:"user",S=`plugin:${a}`,A=0,k=!1;for(let O of l)if(typeof O.installPath=="string"&&O.installPath.length>0){let I=un(e,O.installPath,S,d);A+=I.componentCount,k=k||I.expandTruncated}ln(e,{pluginKey:a,rowPath:i,enabled:d,scope:g,version:p||void 0,marketplace:f||void 0,componentCount:A,expandTruncated:k,contentHash:q(`${a}|${p}|${g}|${d}|${A}`)})}}function FR(e){let t=e,n="";try{let r=DR(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=ue(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=ue(e,s),n=s)}}catch{}return{installPath:t,version:n}}var $R=/^\d+$/;function jR(e){let t=e.filter(n=>!$R.test(n.pluginId));return t.length>0?t:e}function yf(e){let t=[{base:ue(e.home,".cursor/plugins/local"),scope:"local"},{base:ue(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let a=o.name,c=ue(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=un(e,c,l,!0);ln(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:q(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(ue(n,s))){if(!a.isDirectory())continue;let c=ue(n,s,a.name),{installPath:l,version:u}=FR(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of jR(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=un(e,a.installPath,l,!0);ln(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:q(`${c}|${a.version}|${u}`)})}}}import{existsSync as GR}from"node:fs";var BR=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,ks="<path>",KR=new RegExp(`${ks}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Rr(e){let t=e.replace(BR,ks).replace(KR,ks);return t.length>200?`${t.slice(0,200)}...`:t}var Rf=200,Cf=200,bs=16*1024,Af=6,WR=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),zR=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),VR=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),JR=new Set(["permissions"]),YR={claude:WR,cursor_sandbox:zR,cursor_permissions:VR,cursor_cli:JR},XR=new Set(["allow","deny","ask"]);function st(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Cr(e){return e.replace(/\\/g,"/")}function xs(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>xs(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${xs(t[r])}`).join(",")}}`}function qR(e){return q(`${xs(e)}|settings1`)}function Of(e){let t=Cr(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}function Tf(e,t){if(e!=="claude")return{};let n=Cr(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}function Pf(e){let t=Cr(e).replace(/\/+$/,"");return t.length<=1?"":t}function wf(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function ZR(e,t){let n=Cr(e);if(n==="~"||n.startsWith("~/"))return n;let r=Pf(t);if(!r)return n;let o=n.slice(0,r.length);if(!(wf(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var kf=new Map;function QR(e){let t=kf.get(e);if(t!==void 0)return t;let n=Pf(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,wf(e)?"gi":"g")}return kf.set(e,r),r}function eC(e,t){let n=QR(t);return n?e.replace(n,"~"):e}function bf(e,t){return e.length<=Cf?e:(t.truncated=!0,e.slice(0,Cf))}function Nf(e,t){return e.length<=Rf?e:(t.truncated=!0,e.slice(0,Rf))}function ne(e,t,n,r){if(typeof e=="string"){if(t==="path")return bf(ZR(e,n),r);let o=t==="rule"?Rr(e):e;return bf(eC(o,n),r)}if(typeof e=="number"||typeof e=="boolean"||e===null)return typeof e=="number"&&!Number.isFinite(e)?void 0:e;if(Array.isArray(e)){let o=Nf(e,r),s=[];for(let i of o){let a=ne(i,t,n,r);a!==void 0&&s.push(a)}return s}if(st(e)){let o={};for(let[s,i]of Object.entries(e)){let a=ne(i,t,n,r);a!==void 0&&(o[s]=a)}return o}}function xf(e,t,n){if(!st(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";XR.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=ne(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function tC(e,t,n){if(!st(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){if(o==="files"&&Array.isArray(s)){let a=Nf(s,n);r[o]=a.map(c=>{if(!st(c))return ne(c,"plain",t,n);let l={};for(let[u,d]of Object.entries(c)){let p=ne(d,u==="path"?"path":"plain",t,n);p!==void 0&&(l[u]=p)}return l});continue}let i=ne(s,"plain",t,n);i!==void 0&&(r[o]=i)}return r}function nC(e,t,n){if(!st(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let a=ne(s,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}function rC(e,t,n){if(!st(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i;o==="excludedCommands"?i=ne(s,"rule",t,n):o==="filesystem"?i=ne(s,"path",t,n):o==="network"?i=nC(s,t,n):o==="credentials"?i=tC(s,t,n):i=ne(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function oC(e,t,n,r,o){return n==="claude"?e==="permissions"?xf(t,r,o):e==="sandbox"?rC(t,r,o):ne(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?ne(t,"path",r,o):ne(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?ne(t,"rule",r,o):ne(t,"plain",r,o):e==="permissions"?xf(t,r,o):ne(t,"plain",r,o)}function fn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Is(e,t){return e?`${e}.${t}`:t}function Os(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let s=e[o];s!==null&&typeof s=="object"&&(t+1>=Af?(e.splice(o,1),r.add(n)):Os(s,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,s]of Object.entries(e))s!==null&&typeof s=="object"&&(t+1>=Af?(delete e[o],r.add(Is(n,o))):Os(s,t+1,Is(n,o),r))}function vf(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:fn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))vf(o,Is(t,r),n)}function sC(e,t,n){let r=fn(e);if(r<=bs)return;t.truncated=!0;let o=[];for(vf(e,"",o);r>bs;){let s;for(let c of o)c.items.length>0&&(!s||c.bytes>s.bytes)&&(s=c);if(!s)break;let i=s.items.pop(),a=fn(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;fn(e)>bs;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=fn(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function iC(e,t,n){let r=YR[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=oC(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return Os(s,1,"",a),a.size>0&&(o.truncated=!0),sC(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function If(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:qR(t.attributes),attributes:t.attributes};e.push(n)}function Ts(e,t,n,r){if(!e.claimFile(t)||!GR(t))return;let o=bi(t);if(!o.ok||!st(o.value)){if(r.profile){let l=!o.ok&&o.reason==="read"?"read_error":"parse_error",u={profile:r.profile,[l]:!0};r.managedSource&&(u.managed_source=r.managedSource),If(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(st(i)&&Cs(e,t,i,n),!r.profile)return;let a=iC(s,r.profile,e.home),c={profile:r.profile,settings:a.settings,keys_omitted:a.keys_omitted};a.truncated&&(c.truncated=!0),a.trimmed_paths.length>0&&(c.trimmed_paths=a.trimmed_paths),r.managedSource&&(c.managed_source=r.managedSource),If(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as aC}from"node:fs";import{join as Me}from"node:path";var Mf=".claude/skills/synced",Lf=".claude/plugins/synced";function Hf(e){return[Me(e,Mf),Me(e,Lf)]}function Ar(e){return typeof e=="string"&&e.length>0?e:void 0}function Uf(e){let t=Me(e.home,Mf);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Me(t,n.name),o=e.readJson(Me(r,"manifest.json"),{}),s=new Map((o?.skills??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let a=Me(r,i.name,"SKILL.md");if(!i.isDirectory()||!aC(a))continue;let c=s.get(i.name),l=Ar(c?.source),u=Ar(c?.creatorType);Pt(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function Df(e){let t=Me(e.home,Lf);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Me(t,n.name),o=e.readJson(Me(r,"manifest.json"),{}),s=new Map((o?.plugins??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.truncated)return;if(!i.isDirectory()||i.name.startsWith("."))continue;let a=s.get(i.name),c=Ar(a?.marketplaceName),l=Ar(a?.version),u=c?`${i.name}@${c}`:i.name,d=Me(r,i.name),{componentCount:f,expandTruncated:p}=un(e,d,`plugin:${u}`,!0);ln(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:q(`${u}|${l??""}|synced|${f}`)})}}}function uC(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)mt(e,{dir:Nt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Hf(e.home)});for(let i of n.dirs)mt(e,{dir:Nt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=Yl(i.map(c=>Nt(r,c)));a&&Pt(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:cC(a)})}for(let i of Ua(n))Ts(e,Nt(r,i),o,{kind:"SETTINGS",profile:Of(i)});for(let i of n.mcpJson??[])hf(e,Nt(r,i),o);for(let i of n.mcpToml??[])_f(e,Nt(r,i),o);if(s){if(n.managed){for(let i of wn(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=Tf(n.managed,i);Ts(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(Ef(e),Df(e),Uf(e)):n.plugins==="cursor"&&yf(e)}}function Ff(e,t){try{let n=new ur(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)uC(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch{return}}function Ps(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=Ff(t,{layouts:Object.values(At),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:Ye,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(Qe),l=Jo({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>Fa(c,u)});i=l.parentRel;for(let u of l.anchors){let d=Lo(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=Ff(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Yo,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function ws(e,t,n={}){let r=n.truncated===!0,o=Zt(e),s=new Set(e.map(u=>_e(u.path,u.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let a=[],c=t;for(let u of e){let d=_e(u.path,u.name);c[d]!==u.content_hash&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=Su(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:a,removed:l,unchanged:a.length===0&&l.length===0}}var jf=2*1024*1024,lC=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ns(e,t,n){let r=new Set(t.map(s=>_e(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(_e(s.path,s.name))||o.push(s));return o}function vs(e,t,n){let r=new Set(e);for(let s of t)r.add(s);let o=new Set(n.map(s=>s.content_hash));return[...r].filter(s=>o.has(s))}function $f(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Bf(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Ms(e,t=jf){let n=[],r=[];for(let u of e)lC.has(u.kind)?n.push(u):r.push(u);r.sort((u,d)=>(u.text?.length??0)-(d.text?.length??0));let o=[...n,...r],s=[],i=2,a=0,c=0,l=[];for(let u of o){let d=s.length>0?1:0,f=$f(u)+d;if(i+f<=t){s.push(u),i+=f,u.text!==void 0&&l.push(u.content_hash);continue}if(u.text!==void 0){let p=Bf(u),g=$f(p)+d;if(i+g<=t){s.push(p),i+=g,a+=1;continue}}c+=1}return{components:s,textDeferredCount:a,droppedCount:c,textHashesSent:l}}function Ls(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:Bf(n))}var fC=["user","cwd","repo","parent"];function Hs(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let v of fC){let T=t.scopes[v];if(!T)continue;let K=n(v,T.scopeRef),D=K.components,x=ws(T.components,D,{forceFull:D===void 0,truncated:T.truncated}),w=new Set(K.textHashes),L=Ns(T.components,x.upserts,w),m=Ls([...x.upserts,...L],w);s.push({scope:v,walk:T,delta:x,outgoing:m,outgoingKeys:new Set(m.map(b=>_e(b.path,b.name))),deliveredTextHashes:w,cachedComponents:D})}let i=s.flatMap(v=>v.outgoing),a=Ms(i,o),c=new Set(a.components.map(v=>_e(v.path,v.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let v of s){let{scope:T,walk:K,delta:D}=v;g.push(...K.components),l.push(T);let x=a.components.filter(b=>v.outgoingKeys.has(_e(b.path,b.name))),w=[...v.outgoingKeys].some(b=>!c.has(b)),L=D.truncated||w;L?d.push(T):D.full&&u.push(T),f.push(...x),!D.full&&!L&&p.push(...D.removed);let m=D.full?{}:{...v.cachedComponents??{}};if(!L)for(let b of D.removed)delete m[_e(b.path,b.name)];for(let b of x)m[_e(b.path,b.name)]=b.content_hash;S.push({scope:T,scopeRef:K.scopeRef,components:m,textHashes:vs(v.deliveredTextHashes,x.filter(b=>b.text!==void 0).map(b=>b.content_hash),K.components),collectedAtMs:r,included:x.length>0||D.removed.length>0&&!L||D.full})}let A={user_spec_hash:Zt(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(A.user_spec_scopes=l,A.user_spec_full_scopes=u,A.user_spec_truncated_scopes=d,A.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(A.user_spec_full=!0),f.length>0&&(A.user_spec=f),p.length>0&&(A.user_spec_removed=p),a.textDeferredCount>0&&(A.user_spec_text_deferred=a.textDeferredCount);let k=t.scopes.cwd;k&&(A.user_spec_cwd_scope_ref=k.scopeRef);let O=t.scopes.repo;O&&(A.user_spec_repo_scope_ref=O.scopeRef);let I=t.scopes.parent;return I&&(A.user_spec_parent_scope_ref=I.scopeRef,t.parentRel&&(A.user_spec_parent_rel=t.parentRel)),{fields:A,scopes:S}}var kr={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function Us(e){return e==="cwd"||e==="repo"||e==="parent"}function dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ds(e){return!dn(e)||!dn(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}function Kf(e){return dC(e)}function Gf(e){return pC(e)}function Wf(e){return mC(e)}function dC(e){if(!dn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function pC(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function zf(e,t){if(!dn(e))return;let n=e[t];return Ds(n)?n:void 0}function mC(e){if(!dn(e))return{};let t={};for(let[n,r]of Object.entries(e))Ds(r)&&(t[n]=r);return t}function Fs(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Ds(o)&&n.push([r,o]);return n.sort((r,o)=>o[1].collected_at_ms-r[1].collected_at_ms),Object.fromEntries(n.slice(0,t))}var EC=["allow","deny","ask"];function xr(e){let t=oe(e,{}),n=[];for(let r of EC)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Rr(o),mode:r});return{model:t.model??"",permissionKeys:n}}function yC(e){let{serverManaged:t,fileBased:n}=zr(process.platform,e),r=xr(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=xr(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function RC(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}var CC=10,AC="self-config-cache.json",Jf=4;function Mt(){return U("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function kC(){return U("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var bC={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function xC(e,t=te){let n=bC[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let a=((await t(s,["--version"],2e3)).split(`
|
|
47
|
-
`)[0]??"").trim();return a||r(o+1)};return r(0)}function
|
|
48
|
-
`);return q(n)}function
|
|
49
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: self-config cache write failed open: ${r}`)}}function
|
|
50
|
-
${n}`}function
|
|
51
|
-
`);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}async function
|
|
52
|
-
`,d=U("EV_AI_HOOK_DEBUG");d==="full"?E(`DEBUG envelope=${l}`):d==="1"&&E(`DEBUG summary=${eA(c,Ks(u))}`);let f=process.argv.includes(Tr),p=U("EV_AI_HOOK_SYNC")==="1";return Qn(n.runnerEvent,n.runnerPlatform)||f||p?oA(e,u,o):(await sA(e,u,o),!1)}import{createReadStream as iA}from"node:fs";import{stat as aA}from"node:fs/promises";import{basename as cA,resolve as uA}from"node:path";import{createInterface as lA}from"node:readline";var fA=1024*1024;function dA(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&cA(t).endsWith(".jsonl")}async function md(e){if(!e||!dA(e))return null;try{let t=uA(e),n=await aA(t);if(!n.isFile())return null;let r=Math.max(0,n.size-fA),o=[],s=lA({input:iA(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let i of s)i.length!==0&&o.push(i);r>0&&o.length>0&&o.shift();for(let i=o.length-1;i>=0;i--){let a=o[i];if(a)try{let c=JSON.parse(a);if(c.type!=="assistant")continue;let l=c.message;if(!l||typeof l!="object")continue;let u=l.model;if(typeof u=="string"&&u.length>0)return u}catch{continue}}return null}catch{return null}}function wr(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:xu(e.manifest.manifest,e.manifest.hookConfig)}}function hn(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function Ws(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:Go(e.manifest.hookConfig)}}async function _d(e){let t=Date.now();await kA(e);let{gitRoot:n}=e.manifest;await Vs(e,n);let r=Ws(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:ar(e.hookInput,e.manifest.manifest,r),envelopeFields:wr(e),launchCwd:zo(e.hookInput,r),home:mA()}}function gd(e){try{return he(pA(e))}catch{return null}}function Sd(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function hd(e,t){let n=e.replaceAll("\\","/");if(!Sd(n))return null;let r=he(e),o=he(t),s=gd(e)??r,i=gd(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function Ed(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=hd(e,t)??(Sd(r)?null:r),i=hd(e,n);return{repositorySourcePath:s,userSourcePath:i}}function Gs(e,t,n,r,o){return yd(e,Ed(n,t.gitRoot,t.home),r,o)}function yd(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?gA({installableKind:r,sourcePath:s,nativeKey:i,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:s,nativeKey:i,componentReference:a}}function gA(e){try{let t=e.inRepository?SA(e.platformAgentId,e.sourcePath):(0,B.installationRootExternalKey)(e.installationId,(0,B.userConfigRootFromPath)(e.sourcePath));return t?(0,B.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function Rd(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}function zs(e,t,n){return Ht("tool_invoked",{...n,...Rd(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Lt,e.manifest.collectorUrl,t.buildStartedAtMs,hn(e,t.home))}function hA(e){return Oc(e.runnerEvent,e.runnerPlatform)?[]:Va(e.hookInput)}function _A(e,t){return zs(e,t,{})}var Cd=new Set([...Object.values(lt),".github"]);function SA(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),s=o.findIndex(i=>Cd.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var Ad=".codex/config.toml",EA=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",Ad]]);function yA(e,t,n,r,o,s,i){if(e===null||t===null||!(i!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let c=s.find(S=>S.name.toLowerCase()===t.toLowerCase()),l=c?EA.get(c.source):o==="codex"?Ad:void 0,u=c?.sourcePath??l;if((c?.scope==="user"||l!==void 0)&&u)try{let S=(0,B.userConfigRootFromPath)(u);return(0,B.buildComponentReference)({installationRootExternalKey:(0,B.installationRootExternalKey)(r,S),installableKind:B.ComponentKind.INTERFACE,sourcePath:u,nativeKey:c?.name??t})}catch{return}if(n===null)return;let f=n.indexOf(":");if(f<=0||f===n.length-1)return;let p=n.slice(f+1),g=p.replaceAll("\\","/").split("/").at(-1);if(!(g===void 0||!Cd.has(g)))try{return(0,B.buildComponentReference)({installationRootExternalKey:n,installableKind:B.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function RA(...e){for(let t of e)if(t)return t;return null}function St(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return E(`WARN: ${n} failed open: ${r}`),t}function CA(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:()=>{}}}function AA(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var _t=new Set,gn=null;async function kA(e){if(Mt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(_t.has(t))return;if(!Fo(n)){_t.add(t);return}let r=Bt({sessionId:e.sessionId,hostname:Mn()});if(yu(r)){if(gn){await gn;return}gn=(async()=>{if(_t.has(t)||!Fo(n)){_t.add(t);return}if(!Ji(n)){_t.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await kd(e,r,qn(i),Do({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a})),u={...l,self_config:AA(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Ht("session_start",u,wr(e),Lt,e.manifest.collectorUrl,s,hn(e)),o&&(c.commit(),_t.add(t))}finally{Yi(n)}})().finally(()=>{gn=null}),await gn}}async function Vs(e,t,n){try{e.platformAgentId=await Sc(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);E(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function kd(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,Pi(),zc(t),Ni(),r]),l=St(o,null,"gitSnapshot"),u=St(s,"","detectVirt"),d=St(i,null,"probeCloud"),f=St(a,{},"hostEnv"),p=St(c,{commit:()=>{}},"resolveOperatorForSend");return await Vs(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:Mn(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Qc()}}}async function bA(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Bt({sessionId:e.sessionId,hostname:Mn()}),o=String(e.runnerPlatform),s=Ws(e),i=zo(e.hookInput,s),a=qn(n),c=id().catch(()=>({})),l=Mt()?Promise.resolve({commit:()=>{}}):Do({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o}),u=kd(e,r,a,l),[d,f]=await Promise.allSettled([No(e.manifest.manifest,n,o),a.catch(()=>null).then(K=>Yf(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:K?.remote??null}))]),{operatorResolved:p,fields:g}=await u,S=St(d,[],"mcpDeclared"),A=St(f,CA(o),"selfConfig"),k=A.config,O=M(e.hookInput,"model");O&&(k.model=O);let I={...g,mcp:{declared:S},self_config:k,run_meta:{trigger:e.hookSource||"startup"},hook_input:ar(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},v=await c;await Ht("session_start",I,{...wr(e),...v},Lt,e.manifest.collectorUrl,t,hn(e))&&(A.commit(),p.commit(),_t.add(e.manifest.installationId))}async function xA(e){let t=Date.now(),[,n]=await Promise.all([Vs(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?md(M(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=RA(M(e.hookInput,"status"),M(e.hookInput,"stop_reason"),M(e.hookInput,"reason"),Yt(M(e.hookInput,"error")),r==="stop"?Ue(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=ar(e.hookInput,e.manifest.manifest,Ws(e));n&&(s.model=n),r!=="stopfailure"&&!Iu(e.manifest.manifest)&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Ht("session_end",{status:o,...n?{model:n}:{},hook_input:s},wr(e),Lt,e.manifest.collectorUrl,t,hn(e))}async function IA(e){let t=hA(e),n=Cc(e.hookInput),r=Ic(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r)return;let s=await _d(e);await Promise.all([o?_A(e,s):void 0,t.length===0?void 0:OA(e,s,t),n.length===0?void 0:TA(e,s,n)])}function bd(e,t,n,r){let o=r??za({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=Gs(e,t,o,B.ComponentKind.SKILL,B.nativeKeyForSkillPath);if(s.sourcePath!==null&&ho(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??Ac({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=Gs(e,t,i,B.ComponentKind.COMMAND,B.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}function OA(e,t,n){let r=Gn(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=bd(e,t,o,r);return zs(e,t,{tool_name:"Skill",skill_name:o,...s.commandName===void 0?{}:{command_name:s.commandName},...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}function TA(e,t,n){return Promise.all(n.map(r=>{let o=Ec({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=Gs(e,t,o,B.ComponentKind.RULE,B.nativeKeyForRulePath),i=s.nativeKey??Rc(r);return zs(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var PA=[{kind:B.ComponentKind.SKILL,nativeKeyFn:B.nativeKeyForSkillPath},{kind:B.ComponentKind.RULE,nativeKeyFn:B.nativeKeyForRulePath},{kind:B.ComponentKind.COMMAND,nativeKeyFn:B.nativeKeyForCommandPath}];function wA(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=So(e.hookInput);if(r===null)return n.skillName===null?{}:bd(e,t,n.skillName,null);let o=Ed(r,t.gitRoot,t.home);for(let s of PA){let i=yd(e,o,s.kind,s.nativeKeyFn);if(i.nativeKey!==null)return{...i.componentReference===void 0?{}:{componentReference:i.componentReference},...s.kind===B.ComponentKind.RULE?{ruleName:i.nativeKey}:{},...s.kind===B.ComponentKind.COMMAND?{commandName:i.nativeKey}:{}}}return{}}var NA=/mcp/i;function vA(e,t,n,r){let o=NA.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?mf(t,n):yr(r.declaredConfig,n);return s===null?{}:Object.fromEntries(Object.entries(s).filter(i=>typeof i[1]=="string").map(([i,a])=>[`mcp_${i}`,a]))}async function MA(e){let t=await _d(e),n=Nc(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=_o(e.hookInput),i=df(s,t.home),a=Mc(e.hookInput),c=Tc(e.runnerEvent),l=c===!1?Lc(e.hookInput,e.runnerEvent):null,u=Yt(M(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&er(r)?await No(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=Uc(r,d.map(K=>K.name),u??""),g=yA(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?wA(e,t,n):{},A=f===null?null:Zc(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),k=vA(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:A}),O=g??S.componentReference,I=S.ruleName??n.ruleName,v=S.commandName??n.commandName,T=vc(e.hookInput);await Ht("tool_invoked",{tool_name:r,skill_name:o,...I?{rule_name:I}:{},...v?{command_name:v}:{},success:c,duration_ms:a,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...k,...O?{component_reference:O}:{},...T?{subagent_type:T}:{},...Rd(e),hook_input:t.hookInput},t.envelopeFields,Lt,e.manifest.collectorUrl,t.buildStartedAtMs,hn(e,t.home))}async function xd(e){switch(e.internalEvent){case"session_start":await bA(e);return;case"session_end":await xA(e);return;case"skill_invoked":await IA(e);return;case"tool_invoked":await MA(e);return;default:return}}import{mkdirSync as LA,readdirSync as HA,readFileSync as UA,statSync as Id,unlinkSync as DA,writeFileSync as FA}from"node:fs";import{homedir as Nr}from"node:os";import{join as Js}from"node:path";var $A="turns",Od=1440*60*1e3,jA=100,BA=new Set(["stop","stopfailure","sessionend"]);function Ys(e=Nr()){return Js(ye(e),$A)}function Td(e,t){return Js(e,$t(t))}function KA(e,t=Date.now()){let n;try{n=HA(e)}catch{return}let r=0;for(let o of n){if(r>=jA)return;r+=1;try{let s=Js(e,o);t-Id(s).mtimeMs>Od&&DA(s)}catch{}}}function GA(e,t,n=Nr()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=Ys(n);LA(s,{recursive:!0}),FA(Td(s,r),o,"utf8")}catch{}}function WA(e,t=Nr()){let n=e.trim();if(!n)return"";try{let r=Td(Ys(t),n);return Date.now()-Id(r).mtimeMs>Od?"":UA(r,"utf8").trim()}catch{return""}}function Pd(e,t,n,r=Nr()){let o=t.trim(),s=BA.has(n.trim().toLowerCase());return s&&KA(Ys(r)),o?(GA(e,o,r),o):s?WA(e,r):""}async function wd(e,t,n,r){let o=t??await vn(On),s=ge(o,{}),i=await ra(process.cwd(),{sessionId:Jt(s)});if(!i)return;r&&(i.collectorUrl=r,i.hookConfig=Un(r));let a=Pc(s,i.manifest.platform,n),c=wc(e,a.runnerEvent);if(!c){E(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`);return}let l={hookInput:s,sessionId:a.sessionId,turnId:Pd(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await xd(l)}function zA(e,t=!1){if(U("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=Vt(r,o,void 0,n.runner);return Qn(o,s)?!0:t}function Nd(e,t){let n=Ur(e),r=ge(t,{}),o=n.event??Oo(r);return Oi()||xc(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}async function vd(e=process.argv.slice(2)){if(Kc(),U("EV_AI_HOOK_JUDGE")==="1"){try{await vn(On)}catch{}return Jr(),0}if(e[0]===mn){try{await Pr(jt)}catch{}return 0}if(e[0]===Tr){try{let t=await jt(),n=Nd(e.slice(1),t);if(!n)return 0;let{parsed:r}=n;await wd(r.event,t,r.runner,xo(r))}catch(t){let n=t instanceof Error?t.message:String(t);E(`WARN: detached work failed open: ${n}`)}return 0}try{let t=await vn(On),n=Nd(e,t);if(!n)return 0;let{parsed:r,hookInput:o,runnerEvent:s}=n;if(!Bc(o,s,r.runner))return 0;zA(n)?await wd(r.event,t,r.runner,xo(r)):await pd(t,e)}catch(t){let n=t instanceof Error?t.message:String(t);E(`WARN: hook failed open: ${n}`)}finally{Jr()}return 0}function vr(){E("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),E(" configure [--url <\u2026/{orgToken}/hook>]"),E(" (manifest only \u2014 pair with marketplace plugins)"),E(" install --url <\u2026/{orgToken}/hook>"),E(" [--delivery npx|binary|local] [--force]"),E(" [--no-claude] [--no-cursor] [--no-codex]"),E(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),E(" (writes collector_url to shared manifest; hook commands use --runner only)"),E(" migrate-to-plugin"),E(" (strip ev-ai file hooks; keep collector manifest)"),E(" update (refresh binary pins from a local build; leaves hook configs alone)"),E(" uninstall"),E("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),E(" (--url/--token optional overrides; else collector_url from manifest)")}function Md(e){return e.includes("--help")||e.includes("-h")}async function qA(e=process.argv.slice(2)){let[t,...n]=e;if(t===mn){try{await Pr(jt)}catch{}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${Le}
|
|
53
|
-
`),0):t==="configure"?
|
|
47
|
+
`)){let O=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);O?.[1]&&u.add(O[1])}for(let k of un(e,"env_vars"))u.add(k);let p=rC(e,"env_http_headers");for(let[,k]of p)k.length>0&&u.add(k);let g=Is(e,"bearer_token_env_var");g&&(u.add(g),n.bearer_token_env_var=g),u.size>0&&(n.env_var_names=[...u].sort()),p.length>0&&(n.env_http_header_names=[...new Set(p.map(([k])=>k))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let S=Is(e,"auth");S&&(n.auth=S);let A=Is(e,"default_tools_approval_mode");return A&&(n.default_tools_approval_mode=A),oC(n,e),n}var ve=Ve(rt(),1);import{createHash as fC}from"node:crypto";import{join as fn}from"node:path";var cC=300,uC=256;function Hf(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}function kr(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}function Uf(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function lC(e){return Uf(e,cC)}function Df(e,t){let n=Hf(e.trim(),t),r=kr(n);if(r.length===0)return"";let[o,...s]=r,i=gt(o),a=ln(s);return lC([i,...a].join(" "))}function Ff(e,t){if(typeof e!="string")return null;let n=Hf(e.trim(),t),r=kr(n)[0];if(!r)return null;let o=gt(r);return o.length===0?null:Uf(o,uC)}function dC(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,ve.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}function pC(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
|
|
48
|
+
`);return fC("sha512").update(t).digest("hex").slice(0,16)}function mC(e){let t=process.platform==="win32"?fn(M("LOCALAPPDATA")??e,"npm-cache"):fn(e,".npm"),n=M("npm_config_cache")??M("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function $f(e){return typeof e=="string"&&e.length>0&&e.length<=ve.PACKAGE_FIELD_MAX?e:null}function gC(e,t,n){let r=pC(e);for(let o of mC(n)){let s=fn(o,"_npx",r),i=ne(fn(s,"node_modules",...t.split("/"),"package.json"),{}),a=$f(i.version);if(a!==null)return a;let c=ne(fn(s,"package-lock.json"),{}),l=$f(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function hC(e){return e.length<=ve.PACKAGE_FIELD_MAX?e:`${e.slice(0,ve.PACKAGE_FIELD_MAX-1)}\u2026`}function Ps(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,ve.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,ve.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:hC(o),...dC(o,gC(r,s,n))}}function jf(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=kr(e.trim());return n===void 0?null:Ps(n,r,t)}function br(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e,r=Array.isArray(n.args)?n.args.filter(o=>typeof o=="string"):[];return Ps(typeof n.command=="string"?n.command:null,r,t)}function Bf(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Ps(wt(n[1]??""),un(e,"args"),t)}function EC(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}function Kf(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let s=e.componentPath(t);for(let[i,a]of Object.entries(o)){if(e.truncated)return;let c=EC(a),l=Nf(a,c);Object.assign(l,br(a,e.home)??{});let u=vf(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:Ts(i,l,u),origin:n,enabled:u,attributes:l})}}function Gf(e,t,n){if(!_C(t)||!e.claimFile(t))return;let r;try{r=SC(t,"utf8")}catch{return}let o=e.componentPath(t),s=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,i;for(;(i=s.exec(r))!==null;){if(e.truncated)return;let a=i[1]??i[2]??i[3];if(!a)continue;let c=r.slice(i.index+i[0].length),l=c.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),u=l===-1?c:c.slice(0,l),d="unknown";/^\s*url\s*=/m.test(u)?d="http":/^\s*command\s*=/m.test(u)&&(d="stdio");let f=Lf(u,d);Object.assign(f,Bf(u,e.home)??{});let p=Mf(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:Ts(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as CC,readdirSync as AC}from"node:fs";import{join as ue}from"node:path";function yC(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}function RC(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}function ws(e,t,n,r){let o=e.componentPath(t);for(let[s,i]of Object.entries(n))if(!(!Array.isArray(i)||e.truncated))for(let a of i){if(!a||typeof a!="object"||e.truncated)continue;let c=a;for(let l of RC(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=yC({type:l.type??c.type,command:l.command??c.command,bash:l.bash??c.bash,powershell:l.powershell??c.powershell,prompt:l.prompt??c.prompt}),f=typeof c.matcher=="string"?c.matcher:"",p=q(u),g=f?`${s}:${f}:${d}:${p}`:`${s}:${d}:${p}`,S=`${s}|${f}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:q(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:Df(u,e.home)}:{}}})}}}function Ns(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||ws(e,t,r.hooks,n)}var Wf=50;function dn(e,t,n,r){if(!CC(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(Wf,()=>{mt(e,{dir:ue(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),mt(e,{dir:ue(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),mt(e,{dir:ue(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Ns(e,ue(t,"hooks","hooks.json"),n),Ns(e,ue(t,"hooks.json"),n);let i=e.components.length-o,a=s>=Wf;return{componentCount:i,expandTruncated:a}}function pn(e,t){e.push({kind:"PLUGIN",name:t.pluginKey,path:t.rowPath,content_hash:t.contentHash,origin:"user",enabled:t.enabled,attributes:{...t.marketplace?{marketplace:t.marketplace}:{},...t.version?{version:t.version}:{},scope:t.scope,component_count:t.componentCount,...t.expandTruncated?{expand_truncated:!0}:{}}})}function zf(e){let t=ue(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},s=e.readJson(ue(e.home,".claude/settings.json"),{})?.enabledPlugins??{},i=e.componentPath(t);for(let[a,c]of Object.entries(r)){if(e.truncated)return;let l=Array.isArray(c)?c:[c],u=l[0]??{},d=s[a]===!0,f=a.includes("@")?a.split("@").slice(1).join("@"):"",p=typeof u.version=="string"?u.version:"",g=typeof u.scope=="string"?u.scope:"user",S=`plugin:${a}`,A=0,k=!1;for(let O of l)if(typeof O.installPath=="string"&&O.installPath.length>0){let I=dn(e,O.installPath,S,d);A+=I.componentCount,k=k||I.expandTruncated}pn(e,{pluginKey:a,rowPath:i,enabled:d,scope:g,version:p||void 0,marketplace:f||void 0,componentCount:A,expandTruncated:k,contentHash:q(`${a}|${p}|${g}|${d}|${A}`)})}}function kC(e){let t=e,n="";try{let r=AC(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=ue(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=ue(e,s),n=s)}}catch{}return{installPath:t,version:n}}var bC=/^\d+$/;function xC(e){let t=e.filter(n=>!bC.test(n.pluginId));return t.length>0?t:e}function Vf(e){let t=[{base:ue(e.home,".cursor/plugins/local"),scope:"local"},{base:ue(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let a=o.name,c=ue(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=dn(e,c,l,!0);pn(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:q(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(ue(n,s))){if(!a.isDirectory())continue;let c=ue(n,s,a.name),{installPath:l,version:u}=kC(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of xC(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=dn(e,a.installPath,l,!0);pn(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:q(`${c}|${a.version}|${u}`)})}}}import{existsSync as TC}from"node:fs";var IC=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,vs="<path>",OC=new RegExp(`${vs}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function xr(e){let t=e.replace(IC,vs).replace(OC,vs);return t.length>200?`${t.slice(0,200)}...`:t}var Jf=200,Yf=200,Ms=16*1024,Xf=6,PC=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),wC=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),NC=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),vC=new Set(["permissions"]),MC={claude:PC,cursor_sandbox:wC,cursor_permissions:NC,cursor_cli:vC},LC=new Set(["allow","deny","ask"]);function st(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ir(e){return e.replace(/\\/g,"/")}function Ls(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Ls(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Ls(t[r])}`).join(",")}}`}function HC(e){return q(`${Ls(e)}|settings1`)}function td(e){let t=Ir(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}function nd(e,t){if(e!=="claude")return{};let n=Ir(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}function rd(e){let t=Ir(e).replace(/\/+$/,"");return t.length<=1?"":t}function od(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function UC(e,t){let n=Ir(e);if(n==="~"||n.startsWith("~/"))return n;let r=rd(t);if(!r)return n;let o=n.slice(0,r.length);if(!(od(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var qf=new Map;function DC(e){let t=qf.get(e);if(t!==void 0)return t;let n=rd(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,od(e)?"gi":"g")}return qf.set(e,r),r}function FC(e,t){let n=DC(t);return n?e.replace(n,"~"):e}function Zf(e,t){return e.length<=Yf?e:(t.truncated=!0,e.slice(0,Yf))}function sd(e,t){return e.length<=Jf?e:(t.truncated=!0,e.slice(0,Jf))}function re(e,t,n,r){if(typeof e=="string"){if(t==="path")return Zf(UC(e,n),r);let o=t==="rule"?xr(e):e;return Zf(FC(o,n),r)}if(typeof e=="number"||typeof e=="boolean"||e===null)return typeof e=="number"&&!Number.isFinite(e)?void 0:e;if(Array.isArray(e)){let o=sd(e,r),s=[];for(let i of o){let a=re(i,t,n,r);a!==void 0&&s.push(a)}return s}if(st(e)){let o={};for(let[s,i]of Object.entries(e)){let a=re(i,t,n,r);a!==void 0&&(o[s]=a)}return o}}function Qf(e,t,n){if(!st(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";LC.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=re(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function $C(e,t,n){if(!st(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){if(o==="files"&&Array.isArray(s)){let a=sd(s,n);r[o]=a.map(c=>{if(!st(c))return re(c,"plain",t,n);let l={};for(let[u,d]of Object.entries(c)){let p=re(d,u==="path"?"path":"plain",t,n);p!==void 0&&(l[u]=p)}return l});continue}let i=re(s,"plain",t,n);i!==void 0&&(r[o]=i)}return r}function jC(e,t,n){if(!st(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let a=re(s,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}function BC(e,t,n){if(!st(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i;o==="excludedCommands"?i=re(s,"rule",t,n):o==="filesystem"?i=re(s,"path",t,n):o==="network"?i=jC(s,t,n):o==="credentials"?i=$C(s,t,n):i=re(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function KC(e,t,n,r,o){return n==="claude"?e==="permissions"?Qf(t,r,o):e==="sandbox"?BC(t,r,o):re(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?re(t,"path",r,o):re(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?re(t,"rule",r,o):re(t,"plain",r,o):e==="permissions"?Qf(t,r,o):re(t,"plain",r,o)}function mn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Hs(e,t){return e?`${e}.${t}`:t}function Us(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let s=e[o];s!==null&&typeof s=="object"&&(t+1>=Xf?(e.splice(o,1),r.add(n)):Us(s,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,s]of Object.entries(e))s!==null&&typeof s=="object"&&(t+1>=Xf?(delete e[o],r.add(Hs(n,o))):Us(s,t+1,Hs(n,o),r))}function id(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:mn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))id(o,Hs(t,r),n)}function GC(e,t,n){let r=mn(e);if(r<=Ms)return;t.truncated=!0;let o=[];for(id(e,"",o);r>Ms;){let s;for(let c of o)c.items.length>0&&(!s||c.bytes>s.bytes)&&(s=c);if(!s)break;let i=s.items.pop(),a=mn(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;mn(e)>Ms;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=mn(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function WC(e,t,n){let r=MC[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=KC(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return Us(s,1,"",a),a.size>0&&(o.truncated=!0),GC(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function ed(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:HC(t.attributes),attributes:t.attributes};e.push(n)}function Ds(e,t,n,r){if(!e.claimFile(t)||!TC(t))return;let o=Ei(t);if(!o.ok||!st(o.value)){if(r.profile){let l=!o.ok&&o.reason==="read"?"read_error":"parse_error",u={profile:r.profile,[l]:!0};r.managedSource&&(u.managed_source=r.managedSource),ed(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(st(i)&&ws(e,t,i,n),!r.profile)return;let a=WC(s,r.profile,e.home),c={profile:r.profile,settings:a.settings,keys_omitted:a.keys_omitted};a.truncated&&(c.truncated=!0),a.trimmed_paths.length>0&&(c.trimmed_paths=a.trimmed_paths),r.managedSource&&(c.managed_source=r.managedSource),ed(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as zC}from"node:fs";import{join as Me}from"node:path";var ad=".claude/skills/synced",cd=".claude/plugins/synced";function ud(e){return[Me(e,ad),Me(e,cd)]}function Or(e){return typeof e=="string"&&e.length>0?e:void 0}function ld(e){let t=Me(e.home,ad);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Me(t,n.name),o=e.readJson(Me(r,"manifest.json"),{}),s=new Map((o?.skills??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let a=Me(r,i.name,"SKILL.md");if(!i.isDirectory()||!zC(a))continue;let c=s.get(i.name),l=Or(c?.source),u=Or(c?.creatorType);Pt(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function fd(e){let t=Me(e.home,cd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Me(t,n.name),o=e.readJson(Me(r,"manifest.json"),{}),s=new Map((o?.plugins??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.truncated)return;if(!i.isDirectory()||i.name.startsWith("."))continue;let a=s.get(i.name),c=Or(a?.marketplaceName),l=Or(a?.version),u=c?`${i.name}@${c}`:i.name,d=Me(r,i.name),{componentCount:f,expandTruncated:p}=dn(e,d,`plugin:${u}`,!0);pn(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:q(`${u}|${l??""}|synced|${f}`)})}}}function JC(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)mt(e,{dir:Nt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:ud(e.home)});for(let i of n.dirs)mt(e,{dir:Nt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=Af(i.map(c=>Nt(r,c)));a&&Pt(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:VC(a)})}for(let i of Va(n))Ds(e,Nt(r,i),o,{kind:"SETTINGS",profile:td(i)});for(let i of n.mcpJson??[])Kf(e,Nt(r,i),o);for(let i of n.mcpToml??[])Gf(e,Nt(r,i),o);if(s){if(n.managed){for(let i of Un(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=nd(n.managed,i);Ds(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(zf(e),fd(e),ld(e)):n.plugins==="cursor"&&Vf(e)}}function dd(e,t){try{let n=new mr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)JC(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch{return}}function Fs(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=dd(t,{layouts:Object.values(At),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:Je,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(Qe),l=rs({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>Ya(c,u)});i=l.parentRel;for(let u of l.anchors){let d=Go(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=dd(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:os,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function $s(e,t,n={}){let r=n.truncated===!0,o=tn(e),s=new Set(e.map(u=>Se(u.path,u.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let a=[],c=t;for(let u of e){let d=Se(u.path,u.name);c[d]!==u.content_hash&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=Wu(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:a,removed:l,unchanged:a.length===0&&l.length===0}}var md=2*1024*1024,YC=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function js(e,t,n){let r=new Set(t.map(s=>Se(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(Se(s.path,s.name))||o.push(s));return o}function Bs(e,t,n){let r=new Set(e);for(let s of t)r.add(s);let o=new Set(n.map(s=>s.content_hash));return[...r].filter(s=>o.has(s))}function pd(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function gd(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Ks(e,t=md){let n=[],r=[];for(let u of e)YC.has(u.kind)?n.push(u):r.push(u);r.sort((u,d)=>(u.text?.length??0)-(d.text?.length??0));let o=[...n,...r],s=[],i=2,a=0,c=0,l=[];for(let u of o){let d=s.length>0?1:0,f=pd(u)+d;if(i+f<=t){s.push(u),i+=f,u.text!==void 0&&l.push(u.content_hash);continue}if(u.text!==void 0){let p=gd(u),g=pd(p)+d;if(i+g<=t){s.push(p),i+=g,a+=1;continue}}c+=1}return{components:s,textDeferredCount:a,droppedCount:c,textHashesSent:l}}function Gs(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:gd(n))}var XC=["user","cwd","repo","parent"];function Ws(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let v of XC){let T=t.scopes[v];if(!T)continue;let K=n(v,T.scopeRef),D=K.components,x=$s(T.components,D,{forceFull:D===void 0,truncated:T.truncated}),w=new Set(K.textHashes),H=js(T.components,x.upserts,w),m=Gs([...x.upserts,...H],w);s.push({scope:v,walk:T,delta:x,outgoing:m,outgoingKeys:new Set(m.map(b=>Se(b.path,b.name))),deliveredTextHashes:w,cachedComponents:D})}let i=s.flatMap(v=>v.outgoing),a=Ks(i,o),c=new Set(a.components.map(v=>Se(v.path,v.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let v of s){let{scope:T,walk:K,delta:D}=v;g.push(...K.components),l.push(T);let x=a.components.filter(b=>v.outgoingKeys.has(Se(b.path,b.name))),w=[...v.outgoingKeys].some(b=>!c.has(b)),H=D.truncated||w;H?d.push(T):D.full&&u.push(T),f.push(...x),!D.full&&!H&&p.push(...D.removed);let m=D.full?{}:{...v.cachedComponents??{}};if(!H)for(let b of D.removed)delete m[Se(b.path,b.name)];for(let b of x)m[Se(b.path,b.name)]=b.content_hash;S.push({scope:T,scopeRef:K.scopeRef,components:m,textHashes:Bs(v.deliveredTextHashes,x.filter(b=>b.text!==void 0).map(b=>b.content_hash),K.components),collectedAtMs:r,included:x.length>0||D.removed.length>0&&!H||D.full})}let A={user_spec_hash:tn(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(A.user_spec_scopes=l,A.user_spec_full_scopes=u,A.user_spec_truncated_scopes=d,A.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(A.user_spec_full=!0),f.length>0&&(A.user_spec=f),p.length>0&&(A.user_spec_removed=p),a.textDeferredCount>0&&(A.user_spec_text_deferred=a.textDeferredCount);let k=t.scopes.cwd;k&&(A.user_spec_cwd_scope_ref=k.scopeRef);let O=t.scopes.repo;O&&(A.user_spec_repo_scope_ref=O.scopeRef);let I=t.scopes.parent;return I&&(A.user_spec_parent_scope_ref=I.scopeRef,t.parentRel&&(A.user_spec_parent_rel=t.parentRel)),{fields:A,scopes:S}}var Tr={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function zs(e){return e==="cwd"||e==="repo"||e==="parent"}function gn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Vs(e){return!gn(e)||!gn(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}function hd(e){return qC(e)}function _d(e){return ZC(e)}function Sd(e){return QC(e)}function qC(e){if(!gn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function ZC(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Ed(e,t){if(!gn(e))return;let n=e[t];return Vs(n)?n:void 0}function QC(e){if(!gn(e))return{};let t={};for(let[n,r]of Object.entries(e))Vs(r)&&(t[n]=r);return t}function Js(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Vs(o)&&n.push([r,o]);return n.sort((r,o)=>o[1].collected_at_ms-r[1].collected_at_ms),Object.fromEntries(n.slice(0,t))}var oA=["allow","deny","ask"];function wr(e){let t=ne(e,{}),n=[];for(let r of oA)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:xr(o),mode:r});return{model:t.model??"",permissionKeys:n}}function sA(e){let{serverManaged:t,fileBased:n}=eo(process.platform,e),r=wr(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=wr(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function iA(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}var aA=10,cA="self-config-cache.json",Rd=4;function Mt(){return M("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function uA(){return M("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var lA={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function fA(e,t=te){let n=lA[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let a=((await t(s,["--version"],2e3)).split(`
|
|
49
|
+
`)[0]??"").trim();return a||r(o+1)};return r(0)}function dA(e=yd()){return vt(e,".ev-ai","agent-hook",cA)}function pA(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
|
|
50
|
+
`);return q(n)}function Pr(e,t,n=!1){let r=pA(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}function Ys(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(a=>vt(e,a)),...n]){let a=rA(i);if(s.has(a))continue;s.add(a);let c=Gr(i);c.present&&(o=!0,r+=c.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function mA(e){return tA(e)?he(nA(e,"utf8"),{}):{}}function gA(e,t){try{ge(e,`${JSON.stringify(t)}
|
|
51
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: self-config cache write failed open: ${r}`)}}function hA(e,t,n){if(t==="user")return{components:hd(e.user_spec_components),textHashes:_d(e.user_spec_text_hashes)};if(!zs(t))return{components:void 0,textHashes:[]};let r=Ed(e[Tr[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function _A(e,t,n,r){let o={...e,send_count:n};for(let s of Object.keys(t)){let i=t[s];i.entries!==void 0&&(o[s]=i.hash)}if(r){o.user_spec_layout_version=Rd,r.home&&(o.user_spec_collected_at_ms=r.home.collectedAtMs,r.home.included&&(o.user_spec=r.hash,o.user_spec_components=r.home.components),o.user_spec_text_hashes=r.home.textHashes);for(let s of r.project){if(!zs(s.scope))continue;let i=Tr[s.scope],a=Sd(o[i]),c=a[s.scopeRef];a[s.scopeRef]={components:s.included?s.components:c?.components??{},text_hashes:s.textHashes,collected_at_ms:s.collectedAtMs},o[i]=Js(a)}}return o}async function Cd(e,t=process.cwd(),n=yd(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await fA(e),a="",c=[];if(o){let H=sA(n),m=wr(vt(n,".claude/settings.json")),b=wr(vt(t,".claude/settings.local.json"));a=H.model||b.model||m.model,c=iA([...H.permissionKeys,...m.permissionKeys,...b.permissionKeys]).slice(0,200)}let l={present:!1,size:0},u=H=>{let m=[],b=!1;for(let U of H){let le=yi(vt(n,U));if(m=m.concat(le.entries),b=b||le.truncated,m.length>=Je){m=m.slice(0,Je),b=!0;break}}return{entries:m,truncated:b}},d=dA(n),f=mA(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%aA===0,A=H=>S?void 0:p[H],k=u(tt.skills),O=u(tt.subagents),I=u(tt.commands),v=u(tt.rules),T={skills:Pr(k.entries,A("skills"),k.truncated),subagents:Pr(O.entries,A("subagents"),O.truncated),commands:Pr(I.entries,A("commands"),I.truncated),rules:Pr(v.entries,A("rules"),v.truncated)},K={runner_platform:e,config_scope:"user",cli_version:i,claude_version:o?i:null,model:o&&a||null,permission_keys:c,user_scope:{skills:T.skills,subagents:T.subagents,commands:T.commands,rules:T.rules,memory:Ys(n,tt.memory),settings:Ys(n,tt.settings,Xa(n)),mcp:Ys(n,tt.mcp)},local_settings:o?Gr(vt(t,".claude/settings.local.json")):l},D=null,x=r.nowMs??Date.now();if(!Mt()){let H=p.user_spec_layout_version!==Rd,m=Fs(e,n,{launchCwd:uA()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let b=Ws({collected:m,cacheFor:(U,le)=>H?{components:void 0,textHashes:[]}:hA(p,U,le),nowMs:x});Object.assign(K,b.fields),D={hash:b.fields.user_spec_hash,home:b.scopes.find(U=>U.scope==="user")??null,project:b.scopes.filter(U=>U.scope!=="user")}}}let w=_A(p,T,g,D);return{config:K,commit:()=>{f[e]=w,gA(d,f)}}}import{homedir as LA}from"node:os";import{join as bd}from"node:path";function ht(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as Nr}from"node:path";function SA(e){return Nr(e,".ev-ai","agent-hook","js","signed-v1")}function EA(e){return Nr(SA(e),"scopes")}function Ad(e,t){return Nr(EA(e),t)}function kd(e){return Nr(e,"attempts")}function Xs(e){return String(e).padStart(10,"0")}var yA=/^(\d{10})$/,RA=/^(\d{10})\.done$/,CA=/^[0-9a-f]{128}$/,AA=64;async function Td(e,t,n=!1){let r=kd(t),o=await Ka(e,r),s=new Map,i=new Map,a=xd(o,yA),c=xd(o,RA),l=async f=>{let p=await Od(e,bd(r,kA(f)));return p&&s.set(f,{record:xA(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=IA((await Od(e,bd(r,bA(f))))?.value);return p&&i.set(f,p),p!==void 0};if(!n)return await Promise.all([...a.map(l),...c.map(u)]),{claims:s,dones:i};await Promise.all([Id(a,l),Id(c,u)]);let d=hn(s);return d<hn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function xd(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Id(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function hn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function Pd(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}function kA(e){return Xs(e)}function bA(e){return`${Xs(e)}.done`}async function Od(e,t){let n;try{n=await e.stat(t)}catch(o){if(Wt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>$r)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>$r?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function xA(e){if(!ht(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}function IA(e){if(!ht(e))return;let t=e;if(typeof t.finished_at!="string"||typeof t.outcome!="string"||typeof t.interval_s!="number"||!Number.isFinite(t.interval_s))return;let n=OA(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n}}function OA(e){if(!ht(e))return;let t=e;if(t.kind==="bundled")return t.why==="server"||t.why==="bootstrap_failed"?{kind:"bundled",why:t.why}:void 0;if(t.kind==="cached"&&typeof t.digest=="string"&&CA.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&TA(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function TA(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==AA||t.toString("base64")!==e))return t.toString("hex")}function vA(e){return e==="bootstrap"?3e3:6e4}function MA(e,t){let n=hn(e.claims);if(n===0)return;let r=hn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=Pd(o),c=o.record==="empty"?void 0:o.record.owner,l=vA(c)+3e4;if(t-a>l)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:wd(e.dones.get(r)?.selection)}}if(r===0)return;let i=e.dones.get(r);if(i)return{n:r,latest_claim:n,outcome:i.outcome,finished_at:i.finished_at,selection_version:wd(i.selection)}}async function Nd(e,t,n){try{let r=await Td(Ga(),Ad(e,t),!0);return MA(r,n)}catch{return}}function wd(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}async function vd(e=LA()){let t=Fo()?.launcherScope;if(!t)return{};let n=await Nd(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function Lt(e,t,n){let r={installation_id:n.installationId};n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId);let o={schema_version:Ye,event:e,timestamp:kn(),session_id:n.sessionId||null,turn_id:n.turnId||null,installation_id:n.installationId,platform:n.runnerPlatform,platform_agent_id:n.platformAgentId||null,runner_event:n.runnerEvent||null,agent_hook_version:Ue,host_arch:process.arch,node_version:process.version,policy_version:null,policy_capabilities:[],...n.promptCaptureSource!==void 0?{prompt_capture_source:n.promptCaptureSource}:{},correlation:r,payload:t},s=Fo();return s&&(o.launcher_version=s.launcherVersion,o.hook_source=s.hookSource,o.hook_fallback_reason=s.fallbackReason??null,o.launcher_scope_match=_u(n.collectorUrl,s.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}import{existsSync as Md}from"node:fs";import{spawn as Ld}from"node:child_process";import{fileURLToPath as UA}from"node:url";import{gzipSync as HA}from"node:zlib";function qs(e){return M("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<Mi?{body:e}:{body:HA(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function vr(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function Zs(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}var _n="__post",Mr="__work";async function DA(e,t,n={}){if(Mt())return e;let r=await zo(n.gitRoot??process.cwd(),te,process.env,{runnerPlatform:t,home:n.home}),o=ht(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}function FA(e,t){let n=ht(e.payload)?Object.keys(e.payload):[],r=e.correlation&&typeof e.correlation=="object"?Object.keys(e.correlation):[];return JSON.stringify({event:e.event,schema_version:e.schema_version,agent_hook_version:e.agent_hook_version,host_arch:e.host_arch,node_version:e.node_version,build_ms:e.build_ms,body_bytes:t,correlation_keys:r,payload_keys:n})}function Hd(e){switch(e){case"session_start":return Pi;case"session_end":return wi;case"tool_invoked":case"skill_invoked":return qr;default:return qr}}function $A(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
|
|
52
|
+
${n}`}function Ud(e,t=[],n=process.execPath,r=import.meta.url,o=Md){if(vn(n))return{command:n,args:[e,...t]};let s=UA(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function jA(e=process.execPath,t=import.meta.url,n=Md){return Ud(_n,[],e,t,n)}function BA(e){let t=e.indexOf(`
|
|
53
|
+
`);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}async function Dd(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();da(n,t)}catch{}}async function Lr(e,t=fetch){let n=await e(),r=BA(n);if(!r)return;let{meta:o,body:s}=r,i=qs(s),a=vr(i.contentEncoding);try{let c=await t(o.url,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(Number(o.timeoutMs))});await Dd(c,o.url)}catch{}}async function KA(e,t,n,r=fetch){let o=Hd(e),s=qs(t),i=vr(s.contentEncoding),a=Zs(s.body);E(`POST event=${e} url=${Nn(n)} size=${a} encoding=${s.contentEncoding??"identity"} platform=${process.platform}`);let c=Date.now();try{let l=await r(n,{method:"POST",headers:i,body:s.body,signal:AbortSignal.timeout(o)});if(!l.ok&&s.contentEncoding==="gzip"&&(l.status===400||l.status===415)){try{await l.text()}catch{}E(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:vr(),body:t,signal:AbortSignal.timeout(o)})}let u=Date.now()-c;if(l.ok)return E(`POST outcome=ok elapsed_ms=${u} http=${l.status}`),await Dd(l,n),!0;let d=(await l.text()).slice(0,200).replace(/[\n\r]/g,"");return E(`POST outcome=fail elapsed_ms=${u} http=${l.status} body=${d}`),!1}catch(l){let u=Date.now()-c,d=l instanceof Error?l.message:String(l);return E(`POST outcome=fail elapsed_ms=${u} http=000 body=${d}`),!1}}async function Fd(e,t,n,r,o){try{let s=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{}),s.stdin.on("error",()=>{});let i=!1;return await new Promise(a=>{let c=setTimeout(()=>{if(!i){E(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}a()},Ni),l=()=>{i=!0,clearTimeout(c),a()};s.stdin.end(n,()=>l()),s.stdin.once("error",()=>l())}),s.unref(),s}catch(s){let i=s instanceof Error?s.message:String(s);return E(`WARN: ${o} spawn failed open: ${i}`),null}}async function GA(e,t,n,r=Ld,o=jA){let s=Hd(e),i=$A(n,s,t),{command:a,args:c}=o();return Fd(a,c,i,r,"detached post")}async function $d(e,t,n=Ld,r=Ud){let{command:o,args:s}=r(Mr,t);return Fd(o,s,e,n,"detached work")}async function Ht(e,t,n,r,o,s,i){if(!o)return E("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),!1;if(!wn(o))return E(`WARN: collector URL blocked (https required): ${Nn(o)}`),!1;let a=await DA(t,n.runnerPlatform,i),c=r(e,a,{...n,collectorUrl:o});s!==void 0&&(c.build_ms=Math.max(0,Date.now()-s));let l=JSON.stringify(c),u=`${l}
|
|
54
|
+
`,d=M("EV_AI_HOOK_DEBUG");d==="full"?E(`DEBUG envelope=${l}`):d==="1"&&E(`DEBUG summary=${FA(c,Zs(u))}`);let f=process.argv.includes(Mr),p=M("EV_AI_HOOK_SYNC")==="1";return or(n.runnerEvent,n.runnerPlatform)||f||p?KA(e,u,o):(await GA(e,u,o),!1)}import{createReadStream as WA}from"node:fs";import{stat as zA}from"node:fs/promises";import{basename as VA,resolve as JA}from"node:path";import{createInterface as YA}from"node:readline";var XA=1024*1024;function qA(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&VA(t).endsWith(".jsonl")}async function jd(e){if(!e||!qA(e))return null;try{let t=JA(e),n=await zA(t);if(!n.isFile())return null;let r=Math.max(0,n.size-XA),o=[],s=YA({input:WA(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let i of s)i.length!==0&&o.push(i);r>0&&o.length>0&&o.shift();for(let i=o.length-1;i>=0;i--){let a=o[i];if(a)try{let c=JSON.parse(a);if(c.type!=="assistant")continue;let l=c.message;if(!l||typeof l!="object")continue;let u=l.model;if(typeof u=="string"&&u.length>0)return u}catch{continue}}return null}catch{return null}}function Hr(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Qu(e.manifest.manifest,e.manifest.hookConfig)}}function En(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function ei(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:Qo(e.manifest.hookConfig)}}async function Gd(e){let t=Date.now();await uk(e);let{gitRoot:n}=e.manifest;await ni(e,n);let r=ei(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:dr(e.hookInput,e.manifest.manifest,r),envelopeFields:Hr(e),launchCwd:ts(e.hookInput,r),home:QA()}}function Bd(e){try{return _e(ZA(e))}catch{return null}}function Wd(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function Kd(e,t){let n=e.replaceAll("\\","/");if(!Wd(n))return null;let r=_e(e),o=_e(t),s=Bd(e)??r,i=Bd(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function zd(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=Kd(e,t)??(Wd(r)?null:r),i=Kd(e,n);return{repositorySourcePath:s,userSourcePath:i}}function Qs(e,t,n,r,o){return Vd(e,zd(n,t.gitRoot,t.home),r,o)}function Vd(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?ek({installableKind:r,sourcePath:s,nativeKey:i,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:s,nativeKey:i,componentReference:a}}function ek(e){try{let t=e.inRepository?rk(e.platformAgentId,e.sourcePath):(0,B.installationRootExternalKey)(e.installationId,(0,B.userConfigRootFromPath)(e.sourcePath));return t?(0,B.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function Jd(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}function ti(e,t,n){return Ht("tool_invoked",{...n,...Jd(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Lt,e.manifest.collectorUrl,t.buildStartedAtMs,En(e,t.home))}function tk(e){return Dc(e.runnerEvent,e.runnerPlatform)?[]:rc(e.hookInput)}function nk(e,t){return ti(e,t,{})}var Yd=new Set([...Object.values(lt),".github"]);function rk(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),s=o.findIndex(i=>Yd.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var Xd=".codex/config.toml",ok=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",Xd]]);function sk(e,t,n,r,o,s,i){if(e===null||t===null||!(i!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let c=s.find(S=>S.name.toLowerCase()===t.toLowerCase()),l=c?ok.get(c.source):o==="codex"?Xd:void 0,u=c?.sourcePath??l;if((c?.scope==="user"||l!==void 0)&&u)try{let S=(0,B.userConfigRootFromPath)(u);return(0,B.buildComponentReference)({installationRootExternalKey:(0,B.installationRootExternalKey)(r,S),installableKind:B.ComponentKind.INTERFACE,sourcePath:u,nativeKey:c?.name??t})}catch{return}if(n===null)return;let f=n.indexOf(":");if(f<=0||f===n.length-1)return;let p=n.slice(f+1),g=p.replaceAll("\\","/").split("/").at(-1);if(!(g===void 0||!Yd.has(g)))try{return(0,B.buildComponentReference)({installationRootExternalKey:n,installableKind:B.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function ik(...e){for(let t of e)if(t)return t;return null}function St(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return E(`WARN: ${n} failed open: ${r}`),t}function ak(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:()=>{}}}function ck(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var _t=new Set,Sn=null;async function uk(e){if(Mt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(_t.has(t))return;if(!Jo(n)){_t.add(t);return}let r=Gt({sessionId:e.sessionId,hostname:Dn()});if(Vu(r)){if(Sn){await Sn;return}Sn=(async()=>{if(_t.has(t)||!Jo(n)){_t.add(t);return}if(!sa(n)){_t.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await qd(e,r,nr(i),Vo({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a})),u={...l,self_config:ck(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Ht("session_start",u,Hr(e),Lt,e.manifest.collectorUrl,s,En(e)),o&&(c.commit(),_t.add(t))}finally{ia(n)}})().finally(()=>{Sn=null}),await Sn}}async function ni(e,t,n){try{e.platformAgentId=await Oc(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);E(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function qd(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,ji(),Eu(t),Ki(),r]),l=St(o,null,"gitSnapshot"),u=St(s,"","detectVirt"),d=St(i,null,"probeCloud"),f=St(a,{},"hostEnv"),p=St(c,{commit:()=>{}},"resolveOperatorForSend");return await ni(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:Dn(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:xu()}}}async function lk(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Gt({sessionId:e.sessionId,hostname:Dn()}),o=String(e.runnerPlatform),s=ei(e),i=ts(e.hookInput,s),a=nr(n),c=vd().catch(()=>({})),l=Mt()?Promise.resolve({commit:()=>{}}):Vo({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o}),u=qd(e,r,a,l),[d,f]=await Promise.allSettled([jo(e.manifest.manifest,n,o),a.catch(()=>null).then(K=>Cd(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:K?.remote??null}))]),{operatorResolved:p,fields:g}=await u,S=St(d,[],"mcpDeclared"),A=St(f,ak(o),"selfConfig"),k=A.config,O=L(e.hookInput,"model");O&&(k.model=O);let I={...g,mcp:{declared:S},self_config:k,run_meta:{trigger:e.hookSource||"startup"},hook_input:dr(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},v=await c;await Ht("session_start",I,{...Hr(e),...v},Lt,e.manifest.collectorUrl,t,En(e))&&(A.commit(),p.commit(),_t.add(e.manifest.installationId))}async function fk(e){let t=Date.now(),[,n]=await Promise.all([ni(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?jd(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=ik(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),Zt(L(e.hookInput,"error")),r==="stop"?He(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=dr(e.hookInput,e.manifest.manifest,ei(e));n&&(s.model=n),r!=="stopfailure"&&!el(e.manifest.manifest)&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Ht("session_end",{status:o,...n?{model:n}:{},hook_input:s},Hr(e),Lt,e.manifest.collectorUrl,t,En(e))}async function dk(e){let t=tk(e),n=Nc(e.hookInput),r=Uc(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r)return;let s=await Gd(e);await Promise.all([o?nk(e,s):void 0,t.length===0?void 0:pk(e,s,t),n.length===0?void 0:mk(e,s,n)])}function Zd(e,t,n,r){let o=r??nc({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=Qs(e,t,o,B.ComponentKind.SKILL,B.nativeKeyForSkillPath);if(s.sourcePath!==null&&Eo(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??vc({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=Qs(e,t,i,B.ComponentKind.COMMAND,B.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}function pk(e,t,n){let r=Yn(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=Zd(e,t,o,r);return ti(e,t,{tool_name:"Skill",skill_name:o,...s.commandName===void 0?{}:{command_name:s.commandName},...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}function mk(e,t,n){return Promise.all(n.map(r=>{let o=Tc({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=Qs(e,t,o,B.ComponentKind.RULE,B.nativeKeyForRulePath),i=s.nativeKey??wc(r);return ti(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var gk=[{kind:B.ComponentKind.SKILL,nativeKeyFn:B.nativeKeyForSkillPath},{kind:B.ComponentKind.RULE,nativeKeyFn:B.nativeKeyForRulePath},{kind:B.ComponentKind.COMMAND,nativeKeyFn:B.nativeKeyForCommandPath}];function hk(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Ro(e.hookInput);if(r===null)return n.skillName===null?{}:Zd(e,t,n.skillName,null);let o=zd(r,t.gitRoot,t.home);for(let s of gk){let i=Vd(e,o,s.kind,s.nativeKeyFn);if(i.nativeKey!==null)return{...i.componentReference===void 0?{}:{componentReference:i.componentReference},...s.kind===B.ComponentKind.RULE?{ruleName:i.nativeKey}:{},...s.kind===B.ComponentKind.COMMAND?{commandName:i.nativeKey}:{}}}return{}}var _k=/mcp/i;function Sk(e,t,n,r){let o=_k.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?jf(t,n):br(r.declaredConfig,n);return s===null?{}:Object.fromEntries(Object.entries(s).filter(i=>typeof i[1]=="string").map(([i,a])=>[`mcp_${i}`,a]))}async function Ek(e){let t=await Gd(e),n=jc(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=yo(e.hookInput),i=Ff(s,t.home),a=Kc(e.hookInput),c=Fc(e.runnerEvent),l=c===!1?Gc(e.hookInput,e.runnerEvent):null,u=Zt(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&sr(r)?await jo(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=zc(r,d.map(K=>K.name),u??""),g=sk(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?hk(e,t,n):{},A=f===null?null:bu(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),k=Sk(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:A}),O=g??S.componentReference,I=S.ruleName??n.ruleName,v=S.commandName??n.commandName,T=Bc(e.hookInput);await Ht("tool_invoked",{tool_name:r,skill_name:o,...I?{rule_name:I}:{},...v?{command_name:v}:{},success:c,duration_ms:a,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...k,...O?{component_reference:O}:{},...T?{subagent_type:T}:{},...Jd(e),hook_input:t.hookInput},t.envelopeFields,Lt,e.manifest.collectorUrl,t.buildStartedAtMs,En(e,t.home))}async function Qd(e){switch(e.internalEvent){case"session_start":await lk(e);return;case"session_end":await fk(e);return;case"skill_invoked":await dk(e);return;case"tool_invoked":await Ek(e);return;default:return}}import{mkdirSync as yk,readdirSync as Rk,readFileSync as Ck,statSync as ep,unlinkSync as Ak,writeFileSync as kk}from"node:fs";import{homedir as Ur}from"node:os";import{join as ri}from"node:path";var bk="turns",tp=1440*60*1e3,xk=100,Ik=new Set(["stop","stopfailure","sessionend"]);function oi(e=Ur()){return ri(pe(e),bk)}function np(e,t){return ri(e,Dt(t))}function Ok(e,t=Date.now()){let n;try{n=Rk(e)}catch{return}let r=0;for(let o of n){if(r>=xk)return;r+=1;try{let s=ri(e,o);t-ep(s).mtimeMs>tp&&Ak(s)}catch{}}}function Tk(e,t,n=Ur()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=oi(n);yk(s,{recursive:!0}),kk(np(s,r),o,"utf8")}catch{}}function Pk(e,t=Ur()){let n=e.trim();if(!n)return"";try{let r=np(oi(t),n);return Date.now()-ep(r).mtimeMs>tp?"":Ck(r,"utf8").trim()}catch{return""}}function rp(e,t,n,r=Ur()){let o=t.trim(),s=Ik.has(n.trim().toLowerCase());return s&&Ok(oi(r)),o?(Tk(e,o,r),o):s?Pk(e,r):""}async function op(e,t,n,r){let o=t??await bn(Mn),s=he(o,{}),i=await ma(process.cwd(),{sessionId:qt(s)});if(!i)return;r&&(i.collectorUrl=r,i.hookConfig=jn(r));let a=$c(s,i.manifest.platform,n),c=No(e,a.runnerEvent);if(!c){E(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`);return}let l={hookInput:s,sessionId:a.sessionId,turnId:rp(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await Qd(l)}function wk(e,t=!1){if(M("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=Xt(r,o,void 0,n.runner);return or(o,s)?!0:t}function sp(e,t){let n=zr(e),r=he(t,{}),o=n.event??wo(r);return Fi()||Hc(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function ap(e){return au(No(e.parsed.event,e.runnerEvent))}async function ip(e,t){let{parsed:n}=e;if(ap(e)){await op(n.event,t,n.runner,To(n));return}let r=Ho(n.cap),o=gu(r);if(!o){Do(r);return}try{await op(n.event,t,n.runner,To(n))}finally{Uo(o)}}async function cp(e=process.argv.slice(2)){if(hu(),M("EV_AI_HOOK_JUDGE")==="1"){try{await bn(Mn)}catch{}return Br(),0}if(e[0]===_n){try{await Lr(Ft)}catch{}return 0}if(e[0]===Mr){try{let t=await Ft(),n=sp(e.slice(1),t);if(!n)return 0;await ip(n,t)}catch(t){let n=t instanceof Error?t.message:String(t);E(`WARN: detached work failed open: ${n}`)}return 0}try{let t=await bn(Mn),n=sp(e,t);if(!n)return 0;let{parsed:r,hookInput:o,runnerEvent:s}=n;if(!qc(o,s,r.runner))return 0;if(wk(n))await ip(n,t);else{let i=ap(n)?void 0:Ho(r.cap);i===void 0||pu(i)?await $d(t,e):Do(i)}}catch(t){let n=t instanceof Error?t.message:String(t);E(`WARN: hook failed open: ${n}`)}finally{Br()}return 0}function Dr(){E("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),E(" configure [--url <\u2026/{orgToken}/hook>]"),E(" (manifest only \u2014 pair with marketplace plugins)"),E(" install --url <\u2026/{orgToken}/hook>"),E(" [--delivery npx|binary|local] [--force]"),E(" [--no-claude] [--no-cursor] [--no-codex]"),E(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),E(" (writes collector_url to shared manifest; hook commands use --runner only)"),E(" migrate-to-plugin"),E(" (strip ev-ai file hooks; keep collector manifest)"),E(" update (refresh binary pins from a local build; leaves hook configs alone)"),E(" uninstall"),E("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),E(" (--url/--token optional overrides; else collector_url from manifest)")}function up(e){return e.includes("--help")||e.includes("-h")}async function Hk(e=process.argv.slice(2)){let[t,...n]=e;if(t===_n){try{await Lr(Ft)}catch{}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${Ue}
|
|
55
|
+
`),0):t==="configure"?up(n)?(Dr(),0):(await Ha(Ca(n)),0):t==="install"?up(n)?(Dr(),0):(await Ma(Aa(n)),0):t==="migrate-to-plugin"?(await Da(),0):t==="update"?(await La(),0):t==="uninstall"?(await Fa(),0):t==="help"||t==="--help"||t==="-h"?(Dr(),0):t===void 0?(Dr(),1):cp(e)}function Uk(e,t,n=Nk){if(!t)return!1;try{return e===Lk(vk(t)).href?!0:n(Mk(e))===n(t)}catch{return!1}}Uk(import.meta.url,process.argv[1])&&process.env.VITEST===void 0&&Hk().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);E(t),process.exit(1)});export{Uk as isCliEntrypoint,Hk as main};
|