allagents 1.16.7 → 2.0.0-next.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/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ Did you mean ${P_e.default.italic(u)}?`}throw Error(c)}},i=(0,R_e.positional)({d
|
|
|
16
16
|
`+o),e.push(n+"m+"+Mb.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=v0e()+t+" "+e[0]}function v0e(){if(MV.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function w0e(...e){return process.stderr.write(Db.formatWithOptions(MV.inspectOpts,...e)+`
|
|
17
17
|
`)}function b0e(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function k0e(){return process.env.DEBUG}function S0e(e){e.inspectOpts={};let t=Object.keys(MV.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=MV.inspectOpts[t[r]]}Mb.exports=FR()(MV);var{formatters:DV}=Mb.exports;DV.o=function(e){return this.inspectOpts.colors=this.useColors,Db.inspect(e,this.inspectOpts).split(`
|
|
18
18
|
`).map((t)=>t.trim()).join(" ")};DV.O=function(e){return this.inspectOpts.colors=this.useColors,Db.inspect(e,this.inspectOpts)}});var Nb=O(function(Pbt,jR){if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)jR.exports=TV();else jR.exports=FV()});var zV=O(function(Tg){var I0e=Tg&&Tg.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Tg,"__esModule",{value:!0});Tg.parse=O0e;var A0e=I0e(Nb()),Fb=(0,A0e.default)("cmd-ts:parser");function O0e(e,t){if(Fb.enabled){let a={shortFlags:[...t.forceFlagShortNames],longFlags:[...t.forceFlagLongNames],shortOptions:[...t.forceOptionShortNames],longOptions:[...t.forceOptionLongNames]};Fb("Registered:",JSON.stringify(a))}let r=[],i=0,n=!1;function o(){return e[i++]}function s(){return e[i]}while(i<e.length){let a=o();if(!a)break;if(a.type==="argumentDivider")continue;if(n){let c=a.raw,l=o();while(l&&(l===null||l===void 0?void 0:l.type)!=="argumentDivider")c+=l.raw,l=o();r.push({type:"positionalArgument",index:a.index,raw:c});continue}if(a.type==="char"){let c=a.raw,l=o();while(l&&(l===null||l===void 0?void 0:l.type)!=="argumentDivider")c+=l.raw,l=o();r.push({type:"positionalArgument",index:a.index,raw:c});continue}if(a.type==="longPrefix"){let c=o();if((c===null||c===void 0?void 0:c.type)==="argumentDivider"||!c){r.push({type:"forcePositional",index:a.index,raw:"--"}),n=!0;continue}let l="";while(c&&(c===null||c===void 0?void 0:c.raw)!=="="&&(c===null||c===void 0?void 0:c.type)!=="argumentDivider")l+=c.raw,c=o();let u=jV({key:l,delimiterToken:c,forceFlag:t.forceFlagLongNames,getToken:o,peekToken:s,forceOption:t.forceOptionLongNames}),p=`--${l}`;if(u)p+=u.raw;r.push({type:"longOption",key:l,index:a.index,raw:p,value:u});continue}if(a.type==="shortPrefix"){let c=[],l=o();if((l===null||l===void 0?void 0:l.type)==="argumentDivider"||!l){r.push({type:"positionalArgument",index:a.index,raw:"-"});continue}while(l&&(l===null||l===void 0?void 0:l.type)!=="argumentDivider"&&(l===null||l===void 0?void 0:l.raw)!=="=")c.push(l),l=o();let u=c.pop(),p=jV({key:u.raw,delimiterToken:l,forceFlag:t.forceFlagShortNames,forceOption:t.forceOptionShortNames,getToken:o,peekToken:s}),d=[];for(let h of c)d.push({type:"shortOption",index:h.index,raw:h.raw,key:h.raw});let f=u.raw;if(p)f+=p.raw;d.push({type:"shortOption",index:u.index,raw:f,value:p,key:u.raw});let m=`-${c.map((h)=>h.raw).join("")}${u.raw}`;if(p)m+=p.raw;let g={type:"shortOptions",index:a.index,raw:m,options:d};r.push(g);continue}i++}if(Fb.enabled){let a=r.map((c)=>({[c.type]:c.raw}));Fb("Parsed items:",JSON.stringify(a))}return r}function jV(e){var t;let{getToken:r,delimiterToken:i,forceFlag:n,key:o,forceOption:s}=e,c=!s.has(o)&&(n.has(o)||((t=e.peekToken())===null||t===void 0?void 0:t.type)!=="char");if(!i||i.raw!=="="&&c)return;let l=i.raw==="="?"=":" ",u=i.index,p=r();if(!p)return;let d="",f=p.index;while(p&&(p===null||p===void 0?void 0:p.type)!=="argumentDivider")d+=p.raw,p=r();return{type:"optionValue",index:i.index,delimiter:{type:"delimiter",raw:l,index:u},node:{type:"value",raw:d,index:f},raw:`${l}${d}`}}});var LV=O(function(UV){Object.defineProperty(UV,"__esModule",{value:!0});UV.tokenize=D0e;var T0e=Rg();function D0e(e){let t=[],r=0,i=(n)=>{t.push(n),r+=n.raw.length};for(let[n,o]of(0,T0e.enumerate)(e)){let s=[...o];for(let a=0;a<s.length;a++)if(s[a]==="-"&&s[a+1]==="-")i({type:"longPrefix",raw:"--",index:r}),a++;else if(s[a]==="-")i({type:"shortPrefix",raw:"-",index:r});else i({type:"char",raw:s[a],index:r});if(n+1!==e.length)i({type:"argumentDivider",raw:" ",index:r})}return t}});var HV=O(function(VV){Object.defineProperty(VV,"__esModule",{value:!0});VV.run=z0e;VV.runSafely=zR;VV.dryRun=U0e;VV.parse=L0e;var Gp=_i(),BV=RR(),N0e=EV(),F0e=zV(),j0e=LV();async function z0e(e,t){let r=await zR(e,t);if((0,Gp.isErr)(r))return r.error.run();return r.value}async function zR(e,t){let r=[],i=qV(e,t);try{let n=await e.run({nodes:i,visitedNodes:new Set,hotPath:r});if((0,Gp.isErr)(n))throw new BV.Exit({message:(0,N0e.errorBox)(i,n.error.errors,r),exitCode:1,into:"stderr"});return(0,Gp.ok)(n.value)}catch(n){if(n instanceof BV.Exit)return(0,Gp.err)(n);throw n}}async function U0e(e,t){let r=await zR(e,t);if((0,Gp.isErr)(r))return(0,Gp.err)(r.error.dryRun());return r}function L0e(e,t){let r=[],i=qV(e,t);return e.parse({nodes:i,visitedNodes:new Set,hotPath:r})}function qV(e,t){let s={forceFlagShortNames:new Set,forceFlagLongNames:new Set,forceOptionShortNames:new Set,forceOptionLongNames:new Set};e.register(s);let a=(0,j0e.tokenize)(t);return(0,F0e.parse)(a,s)}});var WV=O(function(Xs){var W0e=Xs&&Xs.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),G0e=Xs&&Xs.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Z0e=Xs&&Xs.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n))i[i.length]=n;return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var i=e(t),n=0;n<i.length;n++)if(i[n]!=="default")W0e(r,t,i[n])}return G0e(r,t),r}}();Object.defineProperty(Xs,"__esModule",{value:!0});Xs.restPositionals=Y0e;var jb=Z0e(_i()),K0e=_l();function J0e(e){return{helpTopics(){var t,r,i,n;return[{usage:`[...${(r=(t=e.displayName)!==null&&t!==void 0?t:e.type.displayName)!==null&&r!==void 0?r:"arg"}]`,category:"arguments",defaults:[],description:(n=(i=e.description)!==null&&i!==void 0?i:e.type.description)!==null&&n!==void 0?n:""}]},register(t){},async parse({nodes:t,visitedNodes:r}){let i=t.filter((s)=>s.type==="positionalArgument"&&!r.has(s)),n=[],o=[];for(let s of i){r.add(s);let a=await jb.safeAsync(e.type.from(s.raw));if(jb.isOk(a))n.push(a.value);else o.push({nodes:[s],message:a.error.message})}if(o.length>0)return jb.err({errors:o});return jb.ok(n)}}}function Y0e(e){return J0e({type:K0e.string,...e})}});var GV=O(function(Qs){var X0e=Qs&&Qs.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),Q0e=Qs&&Qs.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ePe=Qs&&Qs.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n))i[i.length]=n;return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var i=e(t),n=0;n<i.length;n++)if(i[n]!=="default")X0e(r,t,i[n])}return Q0e(r,t),r}}();Object.defineProperty(Qs,"__esModule",{value:!0});Qs.multiflag=nPe;var Zp=ePe(_i()),tPe=Rb(),rPe=Cg();function nPe(e){return{helpTopics(){var t;let r=`--${e.long}`;if(e.short)r+=`, -${e.short}`;return[{category:"flags",usage:r,defaults:[],description:(t=e.description)!==null&&t!==void 0?t:"self explanatory"}]},register(t){if(t.forceFlagLongNames.add(e.long),e.short)t.forceFlagShortNames.add(e.short)},async parse({nodes:t,visitedNodes:r}){var i,n;let o=(0,rPe.findOption)(t,{longNames:[e.long],shortNames:e.short?[e.short]:[]}).filter((l)=>!r.has(l));for(let l of o)r.add(l);let s=[],a=[];for(let l of o){let u=await Zp.safeAsync(tPe.boolean.from((n=(i=l.value)===null||i===void 0?void 0:i.node.raw)!==null&&n!==void 0?n:"true"));if(Zp.isErr(u))a.push({nodes:[l],message:u.error.message});else s.push(u.value)}if(a.length>0)return Zp.err({errors:a});let c=await Zp.safeAsync(e.type.from(s));if(Zp.isErr(c))return Zp.err({errors:[{nodes:o,message:c.error.message}]});return c}}}});var KV=O(function(To){var iPe=To&&To.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),oPe=To&&To.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),sPe=To&&To.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n))i[i.length]=n;return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var i=e(t),n=0;n<i.length;n++)if(i[n]!=="default")iPe(r,t,i[n])}return oPe(r,t),r}}(),aPe=To&&To.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(To,"__esModule",{value:!0});To.multioption=lPe;var ZV=aPe((Ks(),rs(Zs))),Qa=sPe(_i()),cPe=Cg();function lPe(e){return{helpTopics(){var t,r;let i=(t=e.type.displayName)!==null&&t!==void 0?t:"value",n=`--${e.long} <${i}>`;if(e.short)n+=`, -${e.short}=<${i}>`;let o=[];if(e.defaultValue)try{let s=e.defaultValue();if(e.defaultValueIsSerializable)o.push(`default: ${ZV.default.italic(s)}`);else o.push("[...optional]")}catch(s){}else if(e.type.defaultValue)try{let s=e.type.defaultValue();if(e.type.defaultValueIsSerializable)o.push(`default: ${ZV.default.italic(s)}`);else o.push("[...optional]")}catch(s){}else if(e.onMissing||e.type.onMissing)o.push("[...optional]");return[{category:"options",usage:n,defaults:o,description:(r=e.description)!==null&&r!==void 0?r:"self explanatory"}]},register(t){if(t.forceOptionLongNames.add(e.long),e.short)t.forceOptionShortNames.add(e.short)},async parse({nodes:t,visitedNodes:r}){var i;let n=(0,cPe.findOption)(t,{longNames:[e.long],shortNames:e.short?[e.short]:[]}).filter((p)=>!r.has(p)),o=e.defaultValue||e.type.defaultValue,s=e.onMissing||e.type.onMissing;if(n.length===0&&o)try{let p=o();return Qa.ok(p)}catch(p){let d=`Failed to resolve default value for '--${e.long}': ${p.message}`;return Qa.err({errors:[{nodes:[],message:d}]})}else if(n.length===0&&s)try{let p=await s();return Qa.ok(p)}catch(p){let d=`Failed to get missing value for '--${e.long}': ${p.message}`;return Qa.err({errors:[{nodes:[],message:d}]})}for(let p of n)r.add(p);let a=[],c=[],l=[];for(let p of n){let d=(i=p.value)===null||i===void 0?void 0:i.node.raw;if(d===void 0){l.push(p);continue}a.push(d)}if(l.length>0)c.push({nodes:l,message:"Expected to get a value, found a flag"});if(c.length>0)return Qa.err({errors:c});let u=await Qa.safeAsync(e.type.from(a));if(Qa.isErr(u))return Qa.err({errors:[{nodes:n,message:u.error.message}]});return u}}}});var XV=O(function(ea){var uPe=ea&&ea.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),pPe=ea&&ea.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),dPe=ea&&ea.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n))i[i.length]=n;return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var i=e(t),n=0;n<i.length;n++)if(i[n]!=="default")uPe(r,t,i[n])}return pPe(r,t),r}}();Object.defineProperty(ea,"__esModule",{value:!0});ea.union=fPe;var JV=dPe(_i()),YV=Eg();function fPe(e,{combineErrors:t=(r)=>r.join(`
|
|
19
|
-
`)}={}){return{...Object.assign({},...e.map((i)=>(0,YV.typeDef)(i))),async from(i){let n=[];for(let o of e){let s=await JV.safeAsync((0,YV.fromFn)(o)(i));if(JV.isOk(s))return s.value;n.push(s.error.message)}throw Error(t(n))}}}});var e3=O(function(QV){Object.defineProperty(QV,"__esModule",{value:!0});QV.oneOf=gPe;var mPe=Le("node:util");function gPe(e){let t=e.map((r)=>(0,mPe.inspect)(r)).join(", ");return{async from(r){let i=e.find((n)=>n===r);if(!i)throw Error(`Invalid value '${r}'. Expected one of: ${t}`);return i},description:`One of ${t}`}}});var t3=O(function(ta){var yPe=ta&&ta.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),vPe=ta&&ta.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),wPe=ta&&ta.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n))i[i.length]=n;return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var i=e(t),n=0;n<i.length;n++)if(i[n]!=="default")yPe(r,t,i[n])}return vPe(r,t),r}}();Object.defineProperty(ta,"__esModule",{value:!0});ta.rest=kPe;var bPe=wPe(_i());function kPe(e){return{helpTopics(){var t,r;return[{usage:`[...${(t=e===null||e===void 0?void 0:e.displayName)!==null&&t!==void 0?t:"arg"}]`,category:"arguments",defaults:[],description:(r=e===null||e===void 0?void 0:e.description)!==null&&r!==void 0?r:"catches the rest of the values"}]},register(){},async parse(t){let r=[...t.visitedNodes].map((s)=>t.nodes.indexOf(s)).filter((s)=>s>-1),i=[],n=Math.max(-1,...r),o=t.nodes.slice(n+1);for(let s of o)switch(s.type){case"positionalArgument":{i.push(s.raw),t.visitedNodes.add(s);break}case"longOption":{i.push(...UR(s)),t.visitedNodes.add(s);break}case"shortOption":{i.push(...UR(s)),t.visitedNodes.add(s);break}case"forcePositional":{i.push(s.raw),t.visitedNodes.add(s);break}case"shortOptions":{let a=s.options.at(-1);t.visitedNodes.add(s),i.push(...UR({...s,value:a===null||a===void 0?void 0:a.value}));break}}return bPe.ok(i)}}}function UR(e){if(!e.value)return[e.raw];if(e.value.delimiter.raw===" ")return[e.raw.slice(0,e.value.index-e.index),e.value.node.raw];return[e.raw]}});var as=O(function(je){var SPe=je&&je.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),xPe=je&&je.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))SPe(t,e,r)};Object.defineProperty(je,"__esModule",{value:!0});je.rest=je.oneOf=je.union=je.multioption=je.multiflag=je.restPositionals=je.parse=je.run=je.runSafely=je.dryRun=je.positional=je.option=je.defaultHelpFormatter=je.resetHelpFormatter=je.setDefaultHelpFormatter=je.flag=je.command=je.binary=je.extendType=je.subcommands=void 0;var $Pe=wV();Object.defineProperty(je,"subcommands",{enumerable:!0,get:function(){return $Pe.subcommands}});var _Pe=Eg();Object.defineProperty(je,"extendType",{enumerable:!0,get:function(){return _Pe.extendType}});xPe(_l(),je);var PPe=kV();Object.defineProperty(je,"binary",{enumerable:!0,get:function(){return PPe.binary}});var CPe=$V();Object.defineProperty(je,"command",{enumerable:!0,get:function(){return CPe.command}});var EPe=Rb();Object.defineProperty(je,"flag",{enumerable:!0,get:function(){return EPe.flag}});var LR=Ib();Object.defineProperty(je,"setDefaultHelpFormatter",{enumerable:!0,get:function(){return LR.setDefaultHelpFormatter}});Object.defineProperty(je,"resetHelpFormatter",{enumerable:!0,get:function(){return LR.resetHelpFormatter}});Object.defineProperty(je,"defaultHelpFormatter",{enumerable:!0,get:function(){return LR.defaultHelpFormatter}});var RPe=_V();Object.defineProperty(je,"option",{enumerable:!0,get:function(){return RPe.option}});var IPe=NR();Object.defineProperty(je,"positional",{enumerable:!0,get:function(){return IPe.positional}});var zb=HV();Object.defineProperty(je,"dryRun",{enumerable:!0,get:function(){return zb.dryRun}});Object.defineProperty(je,"runSafely",{enumerable:!0,get:function(){return zb.runSafely}});Object.defineProperty(je,"run",{enumerable:!0,get:function(){return zb.run}});Object.defineProperty(je,"parse",{enumerable:!0,get:function(){return zb.parse}});var APe=WV();Object.defineProperty(je,"restPositionals",{enumerable:!0,get:function(){return APe.restPositionals}});var OPe=GV();Object.defineProperty(je,"multiflag",{enumerable:!0,get:function(){return OPe.multiflag}});var TPe=KV();Object.defineProperty(je,"multioption",{enumerable:!0,get:function(){return TPe.multioption}});var DPe=XV();Object.defineProperty(je,"union",{enumerable:!0,get:function(){return DPe.union}});var MPe=e3();Object.defineProperty(je,"oneOf",{enumerable:!0,get:function(){return MPe.oneOf}});var NPe=t3();Object.defineProperty(je,"rest",{enumerable:!0,get:function(){return NPe.rest}})});var Do;var Dg=R(()=>{Do={name:"allagents",version:"1.16.7",packageManager:"bun@1.4.0",description:"CLI tool for managing multi-repo AI agent workspaces with plugin synchronization",type:"module",bin:{allagents:"dist/index.js"},files:["dist"],scripts:{build:"bun run scripts/build-package.ts","package:check":"bun run scripts/check-package-size.ts","package:smoke":"bun run scripts/smoke-packed-package.mjs","docs:install":"bun install --cwd docs --frozen-lockfile","docs:build":"bun run docs:install && bun run --cwd docs build",dev:"bun run src/cli/index.ts",test:"bun test","test:watch":"bun test --watch","test:coverage":"bun test --coverage","test:e2e":"bun test tests/e2e","bench:update":"bun run scripts/benchmark-update-noop.ts","smoke:mcp-oauth":"bun run scripts/smoke-mcp-oauth.ts","dev:mcp-server":"bun run scripts/dev-mcp-server.ts","schema:generate":"bun run scripts/generate-workspace-schemas.ts","schema:check":"bun run scripts/generate-workspace-schemas.ts --check",typecheck:"tsc --noEmit",lint:"biome lint src","lint:fix":"biome lint --write src",format:"biome format --write src",check:"biome check src","check:fix":"biome check --write src",prepare:"bun run build",prepublishOnly:`test "$ALLOW_PUBLISH" = '1' || (echo 'ERROR: Use the GitHub Actions Publish workflow' && exit 1)`,"publish:latest":"bun run build && bun scripts/publish.ts latest","publish:next":"bun run build && bun scripts/publish.ts next","promote:latest":"bun scripts/tag-channel.ts latest"},keywords:["cli","ai","agents","workspace","plugins","multi-repo","claude","copilot","codex"],author:"",license:"MIT",repository:{type:"git",url:"git+https://github.com/allagentsdev/allagents.git"},homepage:"https://allagents.dev",devDependencies:{"@biomejs/biome":"^2.5.13","@clack/prompts":"^1.8.1","@modelcontextprotocol/sdk":"^1.30.0","@types/bun":"1.4.2","@types/js-yaml":"^4.0.9","@types/micromatch":"^4.0.10","@types/node":"^22.0.0",ajv:"8.20.0",chalk:"^6.0.0","cmd-ts":"^0.15.0",execa:"^10.0.1","fast-glob":"^3.3.3","gray-matter":"^4.0.3","js-yaml":"^5.4.1",json5:"^2.2.3",micromatch:"^4.0.8","read-cmd-shim":"^7.0.0","simple-git":"^3.36.0",typescript:"^7.0.2",zod:"^4.6.5"},engines:{node:">=22.0.0",bun:">=1.0.0"}}});var r3,n3=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,i3=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var o3=R(()=>{r3=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let r=0;e.lastIndex=0;while(e.test(t))r+=1;return t.length-r}})()});var jPe,zPe,s3,UPe,a3,LPe,BPe,qPe,c3=(e,t={},r={})=>{let i=t.limit??1/0,n=t.ellipsis??"",o=t?.ellipsisWidth??(n?c3(n,qPe,r).width:0),s=0,a=r.controlWidth??0,c=r.tabWidth??8,l=r.emojiWidth??2,u=2,p=r.regularWidth??1,d=r.wideWidth??2,f=[[LPe,p],[jPe,0],[zPe,a],[UPe,c],[a3,l],[s3,d]],m=0,g=0,h=e.length,y=0,v=!1,w=h,_=Math.max(0,i-o),b=0,k=0,I=0,E=0;e:while(!0){if(k>b||g>=h&&g>m){let P=e.slice(b,k)||e.slice(m,g);y=0;for(let A of P.replaceAll(BPe,"")){let x=A.codePointAt(0)||0;if(n3(x))E=2;else if(i3(x))E=d;else E=p;if(I+E>_)w=Math.min(w,Math.max(b,m)+y);if(I+E>i){v=!0;break e}y+=A.length,I+=E}b=k=0}if(g>=h)break e;for(let P=0,A=f.length;P<A;P++){let[x,D]=f[P];if(x.lastIndex=g,x.test(e)){if(y=x===s3?r3(e.slice(g,x.lastIndex)):x===a3?1:x.lastIndex-g,E=y*D,I+E>_)w=Math.min(w,g+Math.floor((_-I)/D));if(I+E>i){v=!0;break e}I+=E,b=m,k=g,g=m=x.lastIndex;continue e}}g+=1}return{width:v?_:I,index:v?w:h,truncated:v,ellipsed:v&&i>=o}},l3;var u3=R(()=>{o3();jPe=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,zPe=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,s3=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,UPe=/\t{1,1000}/y,a3=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,LPe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,BPe=/\p{M}+/gu,qPe={limit:1/0,ellipsis:""},l3=c3});var VPe,HPe=(e,t={})=>l3(e,VPe,t).width,_r;var BR=R(()=>{u3();VPe={limit:1/0,ellipsis:"",ellipsisWidth:0},_r=HPe});function Mo(e,t,r){return String(e).normalize().split(JPe).map((i)=>KPe(i,t,r)).join(`
|
|
19
|
+
`)}={}){return{...Object.assign({},...e.map((i)=>(0,YV.typeDef)(i))),async from(i){let n=[];for(let o of e){let s=await JV.safeAsync((0,YV.fromFn)(o)(i));if(JV.isOk(s))return s.value;n.push(s.error.message)}throw Error(t(n))}}}});var e3=O(function(QV){Object.defineProperty(QV,"__esModule",{value:!0});QV.oneOf=gPe;var mPe=Le("node:util");function gPe(e){let t=e.map((r)=>(0,mPe.inspect)(r)).join(", ");return{async from(r){let i=e.find((n)=>n===r);if(!i)throw Error(`Invalid value '${r}'. Expected one of: ${t}`);return i},description:`One of ${t}`}}});var t3=O(function(ta){var yPe=ta&&ta.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),vPe=ta&&ta.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),wPe=ta&&ta.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n))i[i.length]=n;return i},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var i=e(t),n=0;n<i.length;n++)if(i[n]!=="default")yPe(r,t,i[n])}return vPe(r,t),r}}();Object.defineProperty(ta,"__esModule",{value:!0});ta.rest=kPe;var bPe=wPe(_i());function kPe(e){return{helpTopics(){var t,r;return[{usage:`[...${(t=e===null||e===void 0?void 0:e.displayName)!==null&&t!==void 0?t:"arg"}]`,category:"arguments",defaults:[],description:(r=e===null||e===void 0?void 0:e.description)!==null&&r!==void 0?r:"catches the rest of the values"}]},register(){},async parse(t){let r=[...t.visitedNodes].map((s)=>t.nodes.indexOf(s)).filter((s)=>s>-1),i=[],n=Math.max(-1,...r),o=t.nodes.slice(n+1);for(let s of o)switch(s.type){case"positionalArgument":{i.push(s.raw),t.visitedNodes.add(s);break}case"longOption":{i.push(...UR(s)),t.visitedNodes.add(s);break}case"shortOption":{i.push(...UR(s)),t.visitedNodes.add(s);break}case"forcePositional":{i.push(s.raw),t.visitedNodes.add(s);break}case"shortOptions":{let a=s.options.at(-1);t.visitedNodes.add(s),i.push(...UR({...s,value:a===null||a===void 0?void 0:a.value}));break}}return bPe.ok(i)}}}function UR(e){if(!e.value)return[e.raw];if(e.value.delimiter.raw===" ")return[e.raw.slice(0,e.value.index-e.index),e.value.node.raw];return[e.raw]}});var as=O(function(je){var SPe=je&&je.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),xPe=je&&je.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))SPe(t,e,r)};Object.defineProperty(je,"__esModule",{value:!0});je.rest=je.oneOf=je.union=je.multioption=je.multiflag=je.restPositionals=je.parse=je.run=je.runSafely=je.dryRun=je.positional=je.option=je.defaultHelpFormatter=je.resetHelpFormatter=je.setDefaultHelpFormatter=je.flag=je.command=je.binary=je.extendType=je.subcommands=void 0;var $Pe=wV();Object.defineProperty(je,"subcommands",{enumerable:!0,get:function(){return $Pe.subcommands}});var _Pe=Eg();Object.defineProperty(je,"extendType",{enumerable:!0,get:function(){return _Pe.extendType}});xPe(_l(),je);var PPe=kV();Object.defineProperty(je,"binary",{enumerable:!0,get:function(){return PPe.binary}});var CPe=$V();Object.defineProperty(je,"command",{enumerable:!0,get:function(){return CPe.command}});var EPe=Rb();Object.defineProperty(je,"flag",{enumerable:!0,get:function(){return EPe.flag}});var LR=Ib();Object.defineProperty(je,"setDefaultHelpFormatter",{enumerable:!0,get:function(){return LR.setDefaultHelpFormatter}});Object.defineProperty(je,"resetHelpFormatter",{enumerable:!0,get:function(){return LR.resetHelpFormatter}});Object.defineProperty(je,"defaultHelpFormatter",{enumerable:!0,get:function(){return LR.defaultHelpFormatter}});var RPe=_V();Object.defineProperty(je,"option",{enumerable:!0,get:function(){return RPe.option}});var IPe=NR();Object.defineProperty(je,"positional",{enumerable:!0,get:function(){return IPe.positional}});var zb=HV();Object.defineProperty(je,"dryRun",{enumerable:!0,get:function(){return zb.dryRun}});Object.defineProperty(je,"runSafely",{enumerable:!0,get:function(){return zb.runSafely}});Object.defineProperty(je,"run",{enumerable:!0,get:function(){return zb.run}});Object.defineProperty(je,"parse",{enumerable:!0,get:function(){return zb.parse}});var APe=WV();Object.defineProperty(je,"restPositionals",{enumerable:!0,get:function(){return APe.restPositionals}});var OPe=GV();Object.defineProperty(je,"multiflag",{enumerable:!0,get:function(){return OPe.multiflag}});var TPe=KV();Object.defineProperty(je,"multioption",{enumerable:!0,get:function(){return TPe.multioption}});var DPe=XV();Object.defineProperty(je,"union",{enumerable:!0,get:function(){return DPe.union}});var MPe=e3();Object.defineProperty(je,"oneOf",{enumerable:!0,get:function(){return MPe.oneOf}});var NPe=t3();Object.defineProperty(je,"rest",{enumerable:!0,get:function(){return NPe.rest}})});var Do;var Dg=R(()=>{Do={name:"allagents",version:"2.0.0-next.3",packageManager:"bun@1.4.0",description:"CLI tool for managing multi-repo AI agent workspaces with plugin synchronization",type:"module",bin:{allagents:"dist/index.js"},files:["dist"],scripts:{build:"bun run scripts/build-package.ts","package:check":"bun run scripts/check-package-size.ts","package:smoke":"bun run scripts/smoke-packed-package.mjs","docs:install":"bun install --cwd docs --frozen-lockfile","docs:build":"bun run docs:install && bun run --cwd docs build",dev:"bun run src/cli/index.ts",test:"bun test","test:watch":"bun test --watch","test:coverage":"bun test --coverage","test:e2e":"bun test tests/e2e","bench:update":"bun run scripts/benchmark-update-noop.ts","smoke:mcp-oauth":"bun run scripts/smoke-mcp-oauth.ts","dev:mcp-server":"bun run scripts/dev-mcp-server.ts","schema:generate":"bun run scripts/generate-workspace-schemas.ts","schema:check":"bun run scripts/generate-workspace-schemas.ts --check",typecheck:"tsc --noEmit",lint:"biome lint src","lint:fix":"biome lint --write src",format:"biome format --write src",check:"biome check src","check:fix":"biome check --write src",prepare:"bun run build",prepublishOnly:`test "$ALLOW_PUBLISH" = '1' || (echo 'ERROR: Use the GitHub Actions Publish workflow' && exit 1)`,"publish:latest":"bun run build && bun scripts/publish.ts latest","publish:next":"bun run build && bun scripts/publish.ts next","promote:latest":"bun scripts/tag-channel.ts latest"},keywords:["cli","ai","agents","workspace","plugins","multi-repo","claude","copilot","codex"],author:"",license:"MIT",repository:{type:"git",url:"git+https://github.com/allagentsdev/allagents.git"},homepage:"https://allagents.dev",devDependencies:{"@biomejs/biome":"^2.5.13","@clack/prompts":"^1.8.1","@modelcontextprotocol/sdk":"^1.30.0","@types/bun":"1.4.2","@types/js-yaml":"^4.0.9","@types/micromatch":"^4.0.10","@types/node":"^22.0.0",ajv:"8.20.0",chalk:"^6.0.0","cmd-ts":"^0.15.0",execa:"^10.0.1","fast-glob":"^3.3.3","gray-matter":"^4.0.3","js-yaml":"^5.4.1",json5:"^2.2.3",micromatch:"^4.0.8","read-cmd-shim":"^7.0.0","simple-git":"^3.36.0",typescript:"^7.0.2",zod:"^4.6.5"},engines:{node:">=22.0.0",bun:">=1.0.0"}}});var r3,n3=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,i3=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var o3=R(()=>{r3=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let r=0;e.lastIndex=0;while(e.test(t))r+=1;return t.length-r}})()});var jPe,zPe,s3,UPe,a3,LPe,BPe,qPe,c3=(e,t={},r={})=>{let i=t.limit??1/0,n=t.ellipsis??"",o=t?.ellipsisWidth??(n?c3(n,qPe,r).width:0),s=0,a=r.controlWidth??0,c=r.tabWidth??8,l=r.emojiWidth??2,u=2,p=r.regularWidth??1,d=r.wideWidth??2,f=[[LPe,p],[jPe,0],[zPe,a],[UPe,c],[a3,l],[s3,d]],m=0,g=0,h=e.length,y=0,v=!1,w=h,_=Math.max(0,i-o),b=0,k=0,I=0,E=0;e:while(!0){if(k>b||g>=h&&g>m){let P=e.slice(b,k)||e.slice(m,g);y=0;for(let A of P.replaceAll(BPe,"")){let x=A.codePointAt(0)||0;if(n3(x))E=2;else if(i3(x))E=d;else E=p;if(I+E>_)w=Math.min(w,Math.max(b,m)+y);if(I+E>i){v=!0;break e}y+=A.length,I+=E}b=k=0}if(g>=h)break e;for(let P=0,A=f.length;P<A;P++){let[x,D]=f[P];if(x.lastIndex=g,x.test(e)){if(y=x===s3?r3(e.slice(g,x.lastIndex)):x===a3?1:x.lastIndex-g,E=y*D,I+E>_)w=Math.min(w,g+Math.floor((_-I)/D));if(I+E>i){v=!0;break e}I+=E,b=m,k=g,g=m=x.lastIndex;continue e}}g+=1}return{width:v?_:I,index:v?w:h,truncated:v,ellipsed:v&&i>=o}},l3;var u3=R(()=>{o3();jPe=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,zPe=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,s3=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,UPe=/\t{1,1000}/y,a3=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,LPe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,BPe=/\p{M}+/gu,qPe={limit:1/0,ellipsis:""},l3=c3});var VPe,HPe=(e,t={})=>l3(e,VPe,t).width,_r;var BR=R(()=>{u3();VPe={limit:1/0,ellipsis:"",ellipsisWidth:0},_r=HPe});function Mo(e,t,r){return String(e).normalize().split(JPe).map((i)=>KPe(i,t,r)).join(`
|
|
20
20
|
`)}var Ub="\x1B",g3="",WPe=39,VR="\x07",h3="[",GPe="]",y3="m",HR,p3,d3=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},f3=(e)=>`${Ub}${h3}${e}${y3}`,m3=(e)=>`${Ub}${HR}${e}${VR}`,qR=(e,t,r)=>{let i=t[Symbol.iterator](),n=!1,o=!1,s=e.at(-1),a=s===void 0?0:_r(s),c=i.next(),l=i.next(),u=0;while(!c.done){let p=c.value,d=_r(p);if(a+d<=r)e[e.length-1]+=p;else e.push(p),a=0;if(p===Ub||p===g3)n=!0,o=t.startsWith(HR,u+1);if(n){if(o){if(p===VR)n=!1,o=!1}else if(p===y3)n=!1}else if(a+=d,a===r&&!l.done)e.push(""),a=0;c=l,l=i.next(),u+=p.length}if(s=e.at(-1),!a&&s!==void 0&&s.length&&e.length>1)e[e.length-2]+=e.pop()},ZPe=(e)=>{let t=e.split(" "),r=t.length;while(r){if(_r(t[r-1]))break;r--}if(r===t.length)return e;return t.slice(0,r).join(" ")+t.slice(r).join("")},KPe=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,o,s=e.split(" "),a=[""],c=0;for(let p=0;p<s.length;p++){let d=s[p];if(r.trim!==!1){let m=a.at(-1)??"",g=m.trimStart();if(m.length!==g.length)a[a.length-1]=g,c=_r(g)}if(p!==0){if(c>=t&&(r.wordWrap===!1||r.trim===!1))a.push(""),c=0;if(c||r.trim===!1)a[a.length-1]+=" ",c++}let f=_r(d);if(r.hard&&f>t){let m=t-c,g=1+Math.floor((f-m-1)/t);if(Math.floor((f-1)/t)<g)a.push("");qR(a,d,t),c=_r(a.at(-1)??"");continue}if(c+f>t&&c&&f){if(r.wordWrap===!1&&c<t){qR(a,d,t),c=_r(a.at(-1)??"");continue}a.push(""),c=0}if(c+f>t&&r.wordWrap===!1){qR(a,d,t),c=_r(a.at(-1)??"");continue}a[a.length-1]+=d,c+=f}if(r.trim!==!1)a=a.map((p)=>ZPe(p));let l=a.join(`
|
|
21
21
|
`),u=!1;for(let p=0;p<l.length;p++){let d=l[p];if(i+=d,!u){if(u=d>="\uD800"&&d<="\uDBFF",u)continue}else u=!1;if(d===Ub||d===g3){p3.lastIndex=p+1;let m=p3.exec(l)?.groups;if(m?.code!==void 0){let g=Number.parseFloat(m.code);n=g===WPe?void 0:g}else if(m?.uri!==void 0)o=m.uri.length===0?void 0:m.uri}if(l[p+1]===`
|
|
22
22
|
`){if(o)i+=m3("");let f=n?d3(n):void 0;if(n&&f)i+=f3(f)}else if(d===`
|
|
@@ -330,7 +330,7 @@ ${r}
|
|
|
330
330
|
TRIGGER: File operations (read, search, modify)
|
|
331
331
|
ACTION: Use the repository paths listed above, not assumptions
|
|
332
332
|
${i}<!-- WORKSPACE-RULES:END -->
|
|
333
|
-
`}var ee=".allagents",N$="sync-state.json",ie="workspace.yaml",KIt,Dy;var ut=R(()=>{KIt=`${ee}/${ie}`,Dy=["AGENTS.md","CLAUDE.md"]});var Ac=R(()=>{dx();dx()});function Ne(e,t,r,i){return{id:e,name:t,project:{skillsPath:r},...i?{user:{skillsPath:i}}:{}}}function gf(e){return WBe[e]??F$[e]}function WX(e){let t=gf(e);return t===void 0?void 0:Oc.find((r)=>r.id===t)}function My(e,t){let r=WX(e);if(!r)throw Error(`Unknown agent host: ${e} (no entry in AGENT_HOSTS)`);if(t==="project")return r.project;let i=r.user;if(!i)throw Error(`Client '${e}' does not support user scope`);return i}function GX(e,t){let r=WX(e);return t==="project"?r!==void 0:r?.user!==void 0}function ZX(e){return[...e==="project"?ga:mf]}function wu(e){return Oc.filter((t)=>t.mcp?.[e]).map((t)=>t.id)}function Ny(e){return e==="universal"}function bu(e,t){if(!e.includes("vscode")||!e.includes("copilot"))return t;let r=t.copilot;if(!r)return t;return{...t,vscode:{...r}}}function JX(e){let t=gf(e);if(!t)return e;return GBe[t]??t}var HBe,Oc,ga,mf,$z,_z,F$,WBe,lr,hf,KX=".agents/skills/",GBe;var fi=R(()=>{HBe=[{id:"claude",name:"Claude Code",project:{commandsPath:".claude/commands/",skillsPath:".claude/skills/",agentsPath:".claude/agents/",agentFile:"CLAUDE.md",agentFileFallback:"AGENTS.md",hooksPath:".claude/hooks/"},user:{commandsPath:".claude/commands/",skillsPath:".claude/skills/",agentsPath:".claude/agents/",agentFile:"CLAUDE.md",agentFileFallback:"AGENTS.md",hooksPath:".claude/hooks/"},mcp:{project:!0,user:!0},native:{project:!0,user:!0}},{id:"copilot",name:"GitHub Copilot",project:{skillsPath:".github/skills/",agentsPath:".github/agents/",hooksPath:".github/hooks/",agentFile:"AGENTS.md",githubPath:".github/"},user:{skillsPath:".copilot/skills/",agentsPath:".copilot/agents/",hooksPath:".copilot/hooks/",agentFile:"AGENTS.md",githubPath:".copilot/"},mcp:{project:!0,user:!0},native:{user:!0}},{id:"codex",name:"Codex",project:{skillsPath:".codex/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".codex/skills/",agentFile:"AGENTS.md"},mcp:{project:!0,user:!0},native:{user:!0}},{id:"pi",name:"Pi",project:{skillsPath:".pi/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".pi/agent/skills/",agentFile:".pi/agent/AGENTS.md"},native:{project:!0,user:!0}},{id:"omp",name:"OMP",project:{skillsPath:".omp/skills/",hooksPath:".omp/hooks/",agentFile:"AGENTS.md"},user:{skillsPath:".omp/agent/skills/",hooksPath:".omp/agent/hooks/",agentFile:".omp/agent/AGENTS.md"},native:{project:!0,user:!0}},{id:"cursor",name:"Cursor",project:{skillsPath:".cursor/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".cursor/skills/",agentFile:"AGENTS.md"}},{id:"opencode",name:"OpenCode",project:{commandsPath:".opencode/commands/",skillsPath:".opencode/skills/",agentFile:"AGENTS.md"},user:{commandsPath:".opencode/commands/",skillsPath:".opencode/skills/",agentFile:"AGENTS.md"}},{id:"gemini",name:"Gemini",project:{skillsPath:".gemini/skills/",agentFile:"GEMINI.md",agentFileFallback:"AGENTS.md"},user:{skillsPath:".gemini/skills/",agentFile:"GEMINI.md",agentFileFallback:"AGENTS.md"}},{id:"factory",name:"Factory",project:{skillsPath:".factory/skills/",agentFile:"AGENTS.md",hooksPath:".factory/hooks/"},user:{skillsPath:".factory/skills/",agentFile:"AGENTS.md",hooksPath:".factory/hooks/"}},{id:"ampcode",name:"AmpCode",project:{skillsPath:".ampcode/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".ampcode/skills/",agentFile:"AGENTS.md"}},{id:"vscode",name:"VS Code",project:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},mcp:{project:!0,user:!0}},{id:"openclaw",name:"OpenClaw",project:{skillsPath:"skills/",agentFile:"AGENTS.md"},user:{skillsPath:"skills/",agentFile:"AGENTS.md"}},{id:"windsurf",name:"Windsurf",project:{skillsPath:".windsurf/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".codeium/windsurf/skills/",agentFile:"AGENTS.md"}},{id:"cline",name:"Cline",project:{skillsPath:".cline/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".cline/skills/",agentFile:"AGENTS.md"}},{id:"continue",name:"Continue",project:{skillsPath:".continue/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".continue/skills/",agentFile:"AGENTS.md"}},{id:"roo",name:"Roo Code",project:{skillsPath:".roo/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".roo/skills/",agentFile:"AGENTS.md"}},{id:"kilo",name:"Kilo Code",project:{skillsPath:".kilocode/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".kilocode/skills/",agentFile:"AGENTS.md"}},{id:"trae",name:"Trae",project:{skillsPath:".trae/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".trae/skills/",agentFile:"AGENTS.md"}},{id:"augment",name:"Augment",project:{skillsPath:".augment/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".augment/skills/",agentFile:"AGENTS.md"}},{id:"zencoder",name:"Zencoder",project:{skillsPath:".zencoder/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".zencoder/skills/",agentFile:"AGENTS.md"}},{id:"junie",name:"Junie",project:{skillsPath:".junie/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".junie/skills/",agentFile:"AGENTS.md"}},{id:"openhands",name:"OpenHands",project:{skillsPath:".openhands/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".openhands/skills/",agentFile:"AGENTS.md"}},{id:"kiro",name:"Kiro",project:{skillsPath:".kiro/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".kiro/skills/",agentFile:"AGENTS.md"}},{id:"replit",name:"Replit",project:{skillsPath:".replit/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".replit/skills/",agentFile:"AGENTS.md"}},{id:"kimi",name:"Kimi",project:{skillsPath:".kimi/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".kimi/skills/",agentFile:"AGENTS.md"}},{id:"universal",name:"Universal",project:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},mcp:{project:!0,user:!0}},Ne("aider-desk","AiderDesk",".aider-desk/skills/",".aider-desk/skills/"),Ne("antigravity","Antigravity",".agents/skills/",".gemini/antigravity/skills/"),Ne("antigravity-cli","Antigravity CLI",".agents/skills/",".gemini/antigravity-cli/skills/"),Ne("autohand-code","Autohand Code CLI",".autohand/skills/",".autohand/skills/"),Ne("bob","IBM Bob",".bob/skills/",".bob/skills/"),Ne("codearts-agent","CodeArts Agent",".codeartsdoer/skills/",".codeartsdoer/skills/"),Ne("codebuddy","CodeBuddy",".codebuddy/skills/",".codebuddy/skills/"),Ne("codemaker","Codemaker",".codemaker/skills/",".codemaker/skills/"),Ne("codestudio","Code Studio",".codestudio/skills/",".codestudio/skills/"),Ne("command-code","Command Code",".commandcode/skills/",".commandcode/skills/"),Ne("cortex","Cortex Code",".cortex/skills/",".snowflake/cortex/skills/"),Ne("crush","Crush",".crush/skills/",".config/crush/skills/"),Ne("deepagents","Deep Agents",".agents/skills/",".deepagents/agent/skills/"),Ne("devin","Devin for Terminal",".devin/skills/",".config/devin/skills/"),Ne("dexto","Dexto",".agents/skills/",".agents/skills/"),Ne("eve","Eve","agent/skills/"),Ne("firebender","Firebender",".agents/skills/",".firebender/skills/"),Ne("forgecode","ForgeCode",".forge/skills/",".forge/skills/"),Ne("fx","fx",".fx/skills/",".fx/skills/"),Ne("goose","Goose",".agents/skills/",".agents/skills/"),Ne("grok","Grok Build",".grok/skills/",".grok/skills/"),Ne("hermes-agent","Hermes Agent",".hermes/skills/",".hermes/skills/"),Ne("iflow-cli","iFlow CLI",".iflow/skills/",".iflow/skills/"),Ne("jazz","Jazz",".jazz/skills/",".jazz/skills/"),Ne("kimchi","Kimchi",".kimchi/skills/",".config/kimchi/harness/skills/"),Ne("kode","Kode",".kode/skills/",".kode/skills/"),Ne("lingma","Lingma",".lingma/skills/",".lingma/skills/"),Ne("minimax-code","MiniMax Code",".minimax/skills/",".minimax/skills/"),Ne("mistral-vibe","Mistral Vibe",".vibe/skills/",".vibe/skills/"),Ne("moxby","Moxby",".moxby/skills/",".moxby/skills/"),Ne("mux","Mux",".mux/skills/",".mux/skills/"),Ne("neovate","Neovate",".neovate/skills/",".neovate/skills/"),Ne("ona","Ona",".ona/skills/",".ona/skills/"),Ne("posit-assistant","Posit Assistant",".posit/assistant/skills/",".posit/assistant/skills/"),Ne("qoder","Qoder",".qoder/skills/",".qoder/skills/"),Ne("qoder-cn","Qoder CN",".qoder/skills/",".qoder-cn/skills/"),Ne("qwen-code","Qwen Code",".qwen/skills/",".qwen/skills/"),Ne("reasonix","Reasonix",".reasonix/skills/",".reasonix/skills/"),Ne("rovodev","Rovo Dev",".rovodev/skills/",".rovodev/skills/"),Ne("sarvam-code","Sarvam Code",".agents/skills/",".agents/skills/"),Ne("tabnine-cli","Tabnine CLI",".tabnine/agent/skills/",".tabnine/agent/skills/"),Ne("terramind","Terramind",".terramind/skills/",".terramind/skills/"),Ne("trae-cn","Trae CN",".trae/skills/",".trae-cn/skills/"),Ne("warp","Warp",".agents/skills/",".agents/skills/"),Ne("zed","Zed",".agents/skills/",".agents/skills/"),Ne("zcode","ZCode",".zcode/skills/",".zcode/skills/"),Ne("zenflow","Zenflow",".zencoder/skills/",".zencoder/skills/"),Ne("pochi","Pochi",".pochi/skills/",".pochi/skills/"),Ne("adal","AdaL",".adal/skills/",".adal/skills/")],Oc=HBe,ga=Oc.map((e)=>e.id),mf=Oc.filter((e)=>e.user!==void 0).map((e)=>e.id),$z=Oc.filter((e)=>e.native?.project).map((e)=>e.id),_z=Oc.filter((e)=>e.native?.user).map((e)=>e.id),F$=Object.freeze({"claude-code":"claude","github-copilot":"copilot","gemini-cli":"gemini",droid:"factory",amp:"ampcode","kiro-cli":"kiro","kimi-code-cli":"kimi"}),WBe=Object.freeze(Object.fromEntries(ga.map((e)=>[e,e])));lr=Object.freeze(Object.fromEntries(Oc.map((e)=>[e.id,e.project]))),hf=Object.freeze(Object.fromEntries(Oc.flatMap((e)=>e.user?[[e.id,e.user]]:[])));GBe={vscode:"copilot"}});function Fy(e){let t=gf(e);if(!t)throw Error(`Unknown client '${e}'`);return t}function Pz(e){return YX.filter((t)=>e.includes(F$[t]))}function tQ(e){return[...new Set(e)]}function rQ(e,t){return[...e.map((r)=>`${r}:file`),...t.map((r)=>`${r}:native`)]}function nQ(e){let t=e.lastIndexOf(":");return{name:Fy(e.slice(0,t)),install:e.slice(t+1)}}function Tc(e){if(typeof e==="string")return{name:e,install:"file"};return{name:e.name,install:e.install??"file"}}function Uy(e){let t=new Set,r=[];for(let i of e){let{name:n}=Tc(i);if(t.has(n))continue;t.add(n),r.push(i)}return r}function $n(e){let t=new Set;for(let r of e)t.add(Tc(r).name);return[...t]}function Ez(e,t){for(let r of e){let i=Tc(r);if(i.name===t)return i.install}return"file"}var ZBe,YX,vs,Kr,KBe,XX,JBe,QX,YBe,eQ,ha,j$,jy,zy,ku,XBe,QBe,e6e,t6e,r6e,n6e,z$,i6e,Ly,Cz;var Rz=R(()=>{Ac();fi();fi();ZBe=S.enum(ga),YX=Object.keys(F$),vs=[...ga,...YX];Kr=S.enum(vs).transform(Fy);KBe=Pz(mf),XX=[...mf,...KBe],JBe=Pz($z),QX=[...$z,...JBe],YBe=Pz(_z),eQ=[..._z,...YBe],ha=S.enum(XX,{error:(e)=>{if(e.code!=="invalid_value"||typeof e.input!=="string")return;let t=gf(e.input);return t&&!mf.includes(t)?`Client '${e.input}' does not support user scope`:`Unknown client '${e.input}'`}}).transform(Fy),j$=S.array(S.string().transform((e)=>gf(e)??e));jy=S.array(Kr).transform(tQ),zy=S.array(ha).transform(tQ),ku=S.enum(["file","native"]);XBe=rQ(vs,QX),QBe=rQ(XX,eQ);e6e=S.enum(XBe).transform(nQ),t6e=S.enum(QBe).transform(nQ),r6e=S.enum(QX).transform(Fy),n6e=S.enum(eQ).transform(Fy),z$=S.union([Kr,e6e,S.object({name:Kr,install:S.literal("file").default("file")}),S.object({name:r6e,install:S.literal("native")})]),i6e=S.union([ha,t6e,S.object({name:ha,install:S.literal("file").default("file")}),S.object({name:n6e,install:S.literal("native")})]);Ly=S.array(z$).transform(Uy),Cz=S.array(i6e).transform(Uy)});function fe(e){return typeof e==="string"?e:e.source}function uo(e){let t=fe(e),r=Iz(e);if(!r)return t;if(t.startsWith(".")||t.startsWith("/")||t.includes("\\")||/^[a-zA-Z]:/.test(t)||/^[a-z]+:\/\//i.test(t)&&!/^https?:\/\/(?:www\.)?github\.com\//i.test(t)||t.slice(0,t.indexOf("/")).includes("@"))return t;if(/\/tree\/|\/blob\//.test(t))return t;let n=t.replace(/^https?:\/\/(?:www\.)?github\.com\//,"").replace(/^github\.com\//,"").replace(/^gh:/,"").split("/"),o=n[1];if(!o||o.includes("@"))return t;return n[1]=`${o}@${r}`,n.join("/")}function uQ(e){return typeof e==="string"?void 0:e.clients}function p6e(e){return typeof e==="string"?void 0:e.install}function pQ(e){return typeof e==="string"?void 0:e.exclude}function Iz(e){return typeof e==="string"?void 0:e.ref}function dQ(e,t){let r=p6e(e);if(r)return r;return t.install}function h6e(e){return e.toLowerCase().replace(/\.(?:cmd|ps1)$/i,"")}function Dc(e){return e!==void 0&&hQ.test(e)}var o6e,cQ,s6e,a6e,By,c6e,lQ,l6e,u6e,d6e,f6e,m6e,fQ,mQ,gQ,Az,g6e,hQ,iQ,zt,U$,oQ,Oz,Tz,Dz,Mz,yf,y6e,v6e,w6e,b6e,k6e,sQ,S6e,Oi,Nz,x6e,aQ,$6e,_6e,P6e,yQ,vQ,L$;var it=R(()=>{Ac();Rz();Rz();o6e=S.union([S.boolean(),S.enum(["clone","sync"])]),cQ=S.object({path:S.string(),name:S.string().optional(),source:S.string().optional(),repo:S.string().optional(),description:S.string().optional(),skills:S.union([S.boolean(),S.array(S.string())]).optional(),managed:o6e.optional(),branch:S.string().optional()}),s6e=S.union([S.string(),S.object({source:S.string().optional(),dest:S.string().optional()})]),a6e=S.object({source:S.string().optional(),files:S.array(s6e)}),By=S.string(),c6e=S.union([S.array(S.string()),S.object({exclude:S.array(S.string())})]),lQ=S.object({source:By,clients:jy.optional(),install:ku.optional(),exclude:S.array(S.string()).optional(),skills:c6e.optional(),ref:S.string().optional()}).strict(),l6e=S.union([By,lQ]),u6e=S.union([By,lQ.extend({clients:zy.optional()})]);d6e=S.object({output:S.string().optional()}),f6e=S.enum(["symlink","copy"]),m6e=S.object({proxy:j$}),fQ=S.object({clients:j$.default([]),servers:S.record(S.string(),m6e).optional()}),mQ=S.object({type:S.enum(["http"]).optional(),url:S.string(),headers:S.record(S.string(),S.string()).optional(),clients:jy.optional()}).strict(),gQ=S.object({type:S.enum(["stdio"]).optional(),command:S.string(),args:S.array(S.string()).optional(),env:S.record(S.string(),S.string()).optional(),clients:jy.optional()}).strict(),Az=S.union([mQ,gQ]),g6e=S.union([mQ.extend({clients:zy.optional()}),gQ.extend({clients:zy.optional()})]),hQ=/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/,iQ=S.string().regex(hQ,"Expected an exact ${ENV_VAR} reference"),zt=S.string().regex(/^(?!(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$))(?!.*\.$)[a-z0-9][a-z0-9._-]{0,63}$/,"Expected 1-64 portable lowercase ASCII characters starting with a letter or number"),U$=S.string().regex(/^[A-Za-z0-9_.-]{1,100}$/,"Expected 1-100 ASCII letters, numbers, dots, underscores, or hyphens");oQ=S.object({}).strict(),Oz=S.object({model:S.string().min(1).optional(),effortLevel:S.enum(["low","medium","high","xhigh"]).optional(),fallbackModel:S.array(S.string().min(1)).min(1).optional(),outputStyle:S.string().min(1).optional(),autoMemoryEnabled:S.boolean().optional(),spinnerTipsEnabled:S.boolean().optional(),autoUpdatesChannel:S.enum(["stable","latest"]).optional()}).strict(),Tz=S.object({model:S.string().min(1).optional(),small_model:S.string().min(1).optional(),default_agent:S.string().min(1).optional(),username:S.string().min(1).optional(),share:S.enum(["manual","auto","disabled"]).optional(),autoupdate:S.union([S.boolean(),S.literal("notify")]).optional(),snapshot:S.boolean().optional(),subagent_depth:S.number().int().nonnegative().optional(),logLevel:S.enum(["DEBUG","INFO","WARN","ERROR"]).optional(),disabled_providers:S.array(S.string().min(1)).optional(),enabled_providers:S.array(S.string().min(1)).optional()}).strict(),Dz=S.object({model:S.string().min(1).optional(),theme:S.enum(["default","github","dim","high-contrast","colorblind"]).optional(),autoUpdate:S.boolean().optional(),autoUpdatesChannel:S.enum(["stable","prerelease"]).optional(),banner:S.enum(["always","once","never"]).optional(),askUser:S.boolean().optional(),includeCoAuthoredBy:S.boolean().optional(),stream:S.boolean().optional(),streamerMode:S.boolean().optional(),toolSearch:S.boolean().optional(),updateTerminalTitle:S.boolean().optional(),respectGitignore:S.boolean().optional(),disableAllHooks:S.boolean().optional(),experimental:S.boolean().optional(),bashEnv:S.boolean().optional(),keepAlive:S.enum(["on","off","busy"]).optional(),commandHistoryMaxSize:S.number().int().min(1).max(1000).optional(),compactPaste:S.boolean().optional(),mouse:S.boolean().optional(),terminalProgress:S.boolean().optional(),remote:S.enum(["on","off"]).optional(),remoteExport:S.boolean().optional(),"ide.autoConnect":S.boolean().optional(),shellShortcut:S.boolean().optional(),"customAgents.defaultLocalOnly":S.boolean().optional(),storeTokenPlaintext:S.boolean().optional(),disabledMcpServers:S.array(S.string().min(1)).optional(),enabledMcpServers:S.array(S.string().min(1)).optional()}).strict(),Mz=S.object({model:S.string().min(1).optional(),model_reasoning_effort:S.enum(["minimal","low","medium","high","xhigh"]).optional(),model_reasoning_summary:S.enum(["auto","concise","detailed","none"]).optional(),model_verbosity:S.enum(["low","medium","high"]).optional(),approval_policy:S.enum(["on-request","never"]).optional(),sandbox_mode:S.enum(["read-only","workspace-write","danger-full-access"]).optional(),web_search:S.enum(["disabled","cached","indexed","live"]).optional(),personality:S.enum(["none","friendly","pragmatic"]).optional()}).strict(),yf={install:ku.default("file"),launcher:zt.optional()},y6e=S.enum(["claude","claude-code"]).transform(()=>"claude"),v6e=S.enum(["copilot","github-copilot"]).transform(()=>"copilot"),w6e=S.union([S.object({name:y6e,...yf,settings:Oz.default({})}).strict(),S.object({name:S.literal("opencode"),...yf,settings:Tz.default({})}).strict(),S.object({name:v6e,...yf,settings:Dz.default({})}).strict(),S.object({name:S.literal("codex"),...yf,settings:Mz.default({})}).strict(),S.object({name:S.enum(["pi","omp"]),...yf,settings:oQ.default({})}).strict(),S.object({name:ha,...yf,settings:oQ.default({})}).strict()]),b6e=S.union([S.array(S.string()),S.object({exclude:S.array(S.string())}).strict()]),k6e=S.union([By,S.object({source:By,ref:S.string().optional(),install:ku.optional(),clients:S.array(ha).optional(),skills:b6e.optional()}).strict()]),sQ=/(?:^|[-_.])(?:api[-_]?key|auth|authorization|credential|key|password|secret|signature|token)(?:$|[-_.])/i;S6e=S.array(S.string()).superRefine((e,t)=>{let r=new Set,i=(n)=>{if(r.has(n))return;r.add(n),t.addIssue({code:S.ZodIssueCode.custom,path:[n],message:"Secret arguments must be exact ${ENV_VAR} references"})};for(let[n,o]of e.entries()){if(e[n-1]==="--header-env"){if(!/^[^=:\s]+=[A-Za-z_][A-Za-z0-9_]*$/.test(o))i(n);continue}let a=o.match(/^(?:--?|\/)([^=:\s]+)$/)?.[1];if(a&&sQ.test(a)){let d=n+1;if(!Dc(e[d]))i(d<e.length?d:n);continue}if(/^bearer$/i.test(o)){let d=n+1;if(!Dc(e[d]))i(d<e.length?d:n);continue}let c=o.match(/^(?:--?|\/)?([^=:\s]+)[=:]\s*(.*)$/),l=c?.[1],u=l&&sQ.test(l)?c[2]:void 0,p=o.match(/\bbearer\s+(.+)$/i)?.[1];if(u!==void 0&&!Dc(u)&&!Dc(p)){i(n);continue}if(p!==void 0&&!Dc(p)){i(n);continue}if(o.includes("${")&&!Dc(o)&&!Dc(u)&&!Dc(p))i(n)}}),Oi=S.union([S.object({type:S.enum(["http"]).optional(),url:S.string(),headers:S.record(S.string(),iQ).optional(),clients:S.array(ha).optional()}).strict(),S.object({type:S.enum(["stdio"]).optional(),command:S.string(),args:S6e.optional(),env:S.record(S.string(),iQ).optional(),clients:S.array(ha).optional()}).strict()]),Nz=S.object({clients:S.array(w6e).min(1),plugins:S.array(k6e).default([]),mcpServers:S.record(U$,Oi).optional(),mcpProxy:fQ.optional()}).strict().superRefine((e,t)=>{let r=new Set;e.clients.forEach((n,o)=>{if(r.has(n.name))t.addIssue({code:S.ZodIssueCode.custom,path:["clients",o,"name"],message:`Client '${n.name}' is declared more than once`});r.add(n.name)});let i=(n,o,s=!1)=>{if(!n)return;let a=new Set;n.forEach((c,l)=>{if(a.has(c))t.addIssue({code:S.ZodIssueCode.custom,path:[...o,l],message:`Client selector '${c}' is duplicated`});else if(!(s&&c==="*")&&!r.has(c))t.addIssue({code:S.ZodIssueCode.custom,path:[...o,l],message:`Client selector '${c}' is not declared by this profile`});a.add(c)})};if(e.plugins.forEach((n,o)=>{if(typeof n!=="string")i(n.clients,["plugins",o,"clients"])}),e.mcpServers)for(let[n,o]of Object.entries(e.mcpServers))i(o.clients,["mcpServers",n,"clients"]);if(e.mcpProxy){if(i(e.mcpProxy.clients,["mcpProxy","clients"]),e.mcpProxy.servers)for(let[n,o]of Object.entries(e.mcpProxy.servers))i(o.proxy,["mcpProxy","servers",n,"proxy"],!0)}}),x6e=S.record(zt,Nz).superRefine((e,t)=>{let r=new Map;for(let[i,n]of Object.entries(e))n.clients.forEach((o,s)=>{if(!o.launcher)return;let a=h6e(o.launcher),c=r.get(a);if(c){t.addIssue({code:S.ZodIssueCode.custom,path:[i,"clients",s,"launcher"],message:`Launcher '${o.launcher}' collides with '${c}' on a supported platform`});return}r.set(a,o.launcher)})}),aQ=S.string().refine((e)=>e.trim().length>0,"Setup command cannot be blank"),$6e=S.enum(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]),_6e=S.enum(["arm","arm64","ia32","loong64","mips","mipsel","ppc","ppc64","riscv64","s390","s390x","x64"]),P6e=S.union([aQ,S.object({run:aQ,platforms:S.array($6e).min(1).optional(),architectures:S.array(_6e).min(1).optional()}).strict()]),yQ=S.object({version:S.number().optional(),setup:S.array(P6e).optional(),workspace:a6e.optional(),repositories:S.array(cQ),plugins:S.array(l6e),clients:Ly,vscode:d6e.optional(),syncMode:f6e.optional(),mcpProxy:fQ.optional(),mcpServers:S.record(S.string(),Az).optional(),disabledSkills:S.array(S.string()).optional(),enabledSkills:S.array(S.string()).optional()}),vQ=yQ.extend({profiles:S.never().optional()}),L$=yQ.extend({repositories:S.array(cQ).default([]),plugins:S.array(u6e).default([]),clients:Cz.default([]),mcpServers:S.record(S.string(),g6e).optional(),profiles:x6e.optional()})});import{spawn as C6e}from"node:child_process";import{createHash as E6e,randomUUID as bQ}from"node:crypto";import{constants as R6e}from"node:fs";import{access as I6e,mkdir as A6e,readFile as kQ,rename as wQ,rm as Fz,writeFile as O6e}from"node:fs/promises";import{createServer as SQ}from"node:http";import{dirname as T6e,join as xu}from"node:path";function Su(e,t,r){if(typeof e==="string"){for(let i of t)if(i&&e.includes(i))return!0;return!1}if(e===null||typeof e!=="object")return!1;if(r.has(e))return!1;if(r.add(e),e instanceof Error){if(Su(e.message,t,r)||Su(e.cause,t,r)||e instanceof AggregateError&&Su(e.errors,t,r))return!0}for(let[i,n]of Object.entries(e))if(Su(i,t,r)||Su(n,t,r))return!0;return!1}function V$(e){let t=e instanceof Set?e:new Set(e);return{assertSafe(r){if(Su(r,t,new Set))throw new jz},sanitizeError(r){if(Su(r,t,new Set))return new jz;return r instanceof Error?r:Error(String(r))}}}function $Q(e,t=process.env){return Object.fromEntries(Object.entries(e).map(([r,i])=>{let n=M6e.exec(i);if(!n)return[r,i];let o=n[1],s=t[o];if(s===void 0)throw Error(`MCP header '${r}' references missing environment variable '${o}'`);return[r,s]}))}function zz(e,t){if(e instanceof lo||e instanceof Rc||e instanceof H$)return!0;if(e===null||typeof e!=="object")return!1;if(t.has(e))return!1;t.add(e);let r=e;if(r.error==="invalid_grant"||r.errorCode==="invalid_grant")return!0;if(e instanceof Error&&e.message==="OAuth authorization requires an interactive terminal")return!0;if(zz(r.cause,t)||e instanceof AggregateError&&e.errors.some((i)=>zz(i,t)))return!0;return!1}function W$(e){return zz(e,new Set)}function _Q(e,t,r){let i;try{i=new URL(e.trim())}catch{throw Error("Invalid OAuth callback URL")}let n=new URL(t);if(i.username||i.password||i.origin!==n.origin||i.pathname!==n.pathname||i.hash)throw Error("OAuth callback URL does not match the registered redirect");let o=i.searchParams.getAll("state");if(o.length!==1||o[0]!==r)throw Error("OAuth state validation failed");let s=i.searchParams.getAll("error"),a=i.searchParams.getAll("code");if(s.length===1&&s[0]&&a.length===0)return{authorizationError:!0};if(s.length>0)throw Error("Invalid OAuth authorization response");if(a.length!==1||!a[0])throw Error("No OAuth authorization code received");return{code:a[0]}}function Lz(e,t,r){_Q(e,t,r)}function Uz(e,t,r){let i=_Q(e,t,r);if(i.authorizationError)throw new H$;return i.code}function PQ(e){return E6e("sha256").update(e).digest("hex").slice(0,16)}function G$(e,t){let r=PQ(e);if(!t)return xu(ye(),".allagents","oauth-proxy",r);return xu(ye(),".allagents","profiles",zt.parse(t),"oauth-proxy",r)}function N6e(e,t){if(!e.body)return e;let r=e.headers.get("content-type")?.toLowerCase().startsWith("text/event-stream"),i=0,n=0,o=0,s=!1,a=(l)=>{if(o===0){n=0;return}if(n+=o+l,o=0,n>t)throw Error(`MCP HTTP SSE event exceeds ${t} bytes`)},c=e.body.pipeThrough(new TransformStream({transform(l,u){if(!r){if(i+=l.byteLength,i>t)throw Error(`MCP HTTP response exceeds ${t} bytes`);u.enqueue(l);return}for(let p of l){if(s){if(a(p===10?2:1),s=!1,p===10)continue}if(p===13)s=!0;else if(p===10)a(1);else if(o+=1,n+o>t)throw Error(`MCP HTTP SSE event exceeds ${t} bytes`)}u.enqueue(l)},flush(){if(s)a(1)}}));return new Response(c,{headers:e.headers,status:e.status,statusText:e.statusText})}function F6e(e,t,r=fetch,i={}){let n=new URL(e).origin,o=new Headers;for(let[a,c]of Object.entries(t))if(!CQ[a.toLowerCase()])o.set(a,c);let s=i.maxResponseBytes;if(s!==void 0&&(!Number.isSafeInteger(s)||s<0))throw Error("MCP HTTP response byte limit must be a safe integer");return async(a,c)=>{let l=new URL(a.toString()),u=c;if(l.origin===n){let d=new Headers(o);new Headers(c?.headers).forEach((f,m)=>{d.set(m,f)}),u={...c,headers:d,redirect:"error"}}let p=await r(a,u);return s===void 0?p:N6e(p,s)}}async function EQ(e){try{return await I6e(e,R6e.F_OK),!0}catch{return!1}}async function q$(e){if(!await EQ(e))return;return JSON.parse(await kQ(e,"utf-8"))}async function B$(e,t){await A6e(T6e(e),{recursive:!0,mode:448}),await O6e(e,t,{encoding:"utf-8",mode:384})}function j6e(e){let t=e&&"redirect_uris"in e?e.redirect_uris?.[0]:void 0;if(!t)return;try{let r=new URL(t);if((r.hostname==="127.0.0.1"||r.hostname==="localhost")&&r.port)return Number(r.port)}catch{return}return}function z6e(){return new Promise((e,t)=>{let r=SQ();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let i=r.address(),n=typeof i==="object"&&i?i.port:void 0;r.close((o)=>{if(o){t(o);return}if(!n){t(Error("Failed to determine a free loopback port"));return}e(n)})})})}function RQ(e,t=process.platform){return t==="darwin"?[{command:"open",args:[e]}]:t==="win32"?[{command:"explorer.exe",args:[e]}]:[{command:"xdg-open",args:[e]},{command:"gio",args:["open",e]}]}function U6e(e){let t=RQ(e);return new Promise((r)=>{let i=(n)=>{if(n>=t.length){r();return}let o=t[n];if(!o){r();return}let{command:s,args:a}=o,c=C6e(s,a,{detached:!0,stdio:"ignore"});c.once("spawn",()=>{c.unref(),r()}),c.once("error",()=>{i(n+1)})};i(0)})}class IQ{port;clientInfoPath;tokensPath;verifierPath;discoveryPath;redirectUriValue;clientInfo=void 0;tokenSet=void 0;discovery=void 0;codeVerifierValue=void 0;pendingAuth=void 0;authorizationUnavailable=!1;callbackUrlReader;authorizationOutput;allowAuthorization;credentialValues;signal;stateValue=bQ();constructor(e,t,r={}){this.port=e;let i=G$(t,r.profile);this.clientInfoPath=xu(i,"client-info.json"),this.tokensPath=xu(i,"tokens.json"),this.verifierPath=xu(i,"code-verifier.txt"),this.discoveryPath=xu(i,"discovery.json"),this.redirectUriValue=`http://127.0.0.1:${e}/callback`,this.callbackUrlReader=r.callbackUrlReader,this.authorizationOutput=r.authorizationOutput??console.error,this.allowAuthorization=r.allowAuthorization??!0,this.credentialValues=r.credentialValues??new Set,this.signal=r.signal}get redirectUrl(){return this.redirectUriValue}get clientMetadata(){return{client_name:"AllAgents",redirect_uris:[this.redirectUriValue],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}}state(){return this.stateValue}async load(){if(this.clientInfo=await q$(this.clientInfoPath),this.tokenSet=await q$(this.tokensPath),this.discovery=await q$(this.discoveryPath),await EQ(this.verifierPath))this.codeVerifierValue=await kQ(this.verifierPath,"utf-8");let e=this.clientInfo?.client_secret;if(e)this.credentialValues.add(e);if(this.tokenSet?.access_token)this.credentialValues.add(this.tokenSet.access_token);if(this.tokenSet?.refresh_token)this.credentialValues.add(this.tokenSet.refresh_token);if(this.codeVerifierValue)this.credentialValues.add(this.codeVerifierValue)}clientInformation(){return this.clientInfo}async saveClientInformation(e){this.clientInfo=e;let t=e.client_secret;if(t)this.credentialValues.add(t);await B$(this.clientInfoPath,`${JSON.stringify(e,null,2)}
|
|
333
|
+
`}var ee=".allagents",N$="sync-state.json",ie="workspace.yaml",KIt,Dy;var ut=R(()=>{KIt=`${ee}/${ie}`,Dy=["AGENTS.md","CLAUDE.md"]});var Ac=R(()=>{dx();dx()});function Ne(e,t,r,i){return{id:e,name:t,project:{skillsPath:r},...i?{user:{skillsPath:i}}:{}}}function gf(e){return WBe[e]??F$[e]}function WX(e){let t=gf(e);return t===void 0?void 0:Oc.find((r)=>r.id===t)}function My(e,t){let r=WX(e);if(!r)throw Error(`Unknown agent host: ${e} (no entry in AGENT_HOSTS)`);if(t==="project")return r.project;let i=r.user;if(!i)throw Error(`Client '${e}' does not support user scope`);return i}function GX(e,t){let r=WX(e);return t==="project"?r!==void 0:r?.user!==void 0}function ZX(e){return[...e==="project"?ga:mf]}function wu(e){return Oc.filter((t)=>t.mcp?.[e]).map((t)=>t.id)}function Ny(e){return e==="universal"}function bu(e,t){if(!e.includes("vscode")||!e.includes("copilot"))return t;let r=t.copilot;if(!r)return t;return{...t,vscode:{...r}}}function JX(e){let t=gf(e);if(!t)return e;return GBe[t]??t}var HBe,Oc,ga,mf,$z,_z,F$,WBe,lr,hf,KX=".agents/skills/",GBe;var fi=R(()=>{HBe=[{id:"claude",name:"Claude Code",project:{commandsPath:".claude/commands/",skillsPath:".claude/skills/",agentsPath:".claude/agents/",agentFile:"CLAUDE.md",agentFileFallback:"AGENTS.md",hooksPath:".claude/hooks/"},user:{commandsPath:".claude/commands/",skillsPath:".claude/skills/",agentsPath:".claude/agents/",agentFile:"CLAUDE.md",agentFileFallback:"AGENTS.md",hooksPath:".claude/hooks/"},mcp:{project:!0,user:!0},native:{project:!0,user:!0}},{id:"copilot",name:"GitHub Copilot",project:{skillsPath:".github/skills/",agentsPath:".github/agents/",hooksPath:".github/hooks/",agentFile:"AGENTS.md",githubPath:".github/"},user:{skillsPath:".copilot/skills/",agentsPath:".copilot/agents/",hooksPath:".copilot/hooks/",agentFile:"AGENTS.md",githubPath:".copilot/"},mcp:{project:!0,user:!0},native:{user:!0}},{id:"codex",name:"Codex",project:{skillsPath:".codex/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".codex/skills/",agentFile:"AGENTS.md"},mcp:{project:!0,user:!0},native:{user:!0}},{id:"pi",name:"Pi",project:{skillsPath:".pi/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".pi/agent/skills/",agentFile:".pi/agent/AGENTS.md"},native:{project:!0,user:!0}},{id:"omp",name:"OMP",project:{skillsPath:".omp/skills/",hooksPath:".omp/hooks/",agentFile:"AGENTS.md"},user:{skillsPath:".omp/agent/skills/",hooksPath:".omp/agent/hooks/",agentFile:".omp/agent/AGENTS.md"},native:{project:!0,user:!0}},{id:"cursor",name:"Cursor",project:{skillsPath:".cursor/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".cursor/skills/",agentFile:"AGENTS.md"}},{id:"opencode",name:"OpenCode",project:{commandsPath:".opencode/commands/",skillsPath:".opencode/skills/",agentFile:"AGENTS.md"},user:{commandsPath:".opencode/commands/",skillsPath:".opencode/skills/",agentFile:"AGENTS.md"}},{id:"gemini",name:"Gemini",project:{skillsPath:".gemini/skills/",agentFile:"GEMINI.md",agentFileFallback:"AGENTS.md"},user:{skillsPath:".gemini/skills/",agentFile:"GEMINI.md",agentFileFallback:"AGENTS.md"}},{id:"factory",name:"Factory",project:{skillsPath:".factory/skills/",agentFile:"AGENTS.md",hooksPath:".factory/hooks/"},user:{skillsPath:".factory/skills/",agentFile:"AGENTS.md",hooksPath:".factory/hooks/"}},{id:"ampcode",name:"AmpCode",project:{skillsPath:".ampcode/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".ampcode/skills/",agentFile:"AGENTS.md"}},{id:"vscode",name:"VS Code",project:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},mcp:{project:!0,user:!0}},{id:"openclaw",name:"OpenClaw",project:{skillsPath:"skills/",agentFile:"AGENTS.md"},user:{skillsPath:"skills/",agentFile:"AGENTS.md"}},{id:"windsurf",name:"Windsurf",project:{skillsPath:".windsurf/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".codeium/windsurf/skills/",agentFile:"AGENTS.md"}},{id:"cline",name:"Cline",project:{skillsPath:".cline/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".cline/skills/",agentFile:"AGENTS.md"}},{id:"continue",name:"Continue",project:{skillsPath:".continue/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".continue/skills/",agentFile:"AGENTS.md"}},{id:"roo",name:"Roo Code",project:{skillsPath:".roo/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".roo/skills/",agentFile:"AGENTS.md"}},{id:"kilo",name:"Kilo Code",project:{skillsPath:".kilocode/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".kilocode/skills/",agentFile:"AGENTS.md"}},{id:"trae",name:"Trae",project:{skillsPath:".trae/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".trae/skills/",agentFile:"AGENTS.md"}},{id:"augment",name:"Augment",project:{skillsPath:".augment/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".augment/skills/",agentFile:"AGENTS.md"}},{id:"zencoder",name:"Zencoder",project:{skillsPath:".zencoder/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".zencoder/skills/",agentFile:"AGENTS.md"}},{id:"junie",name:"Junie",project:{skillsPath:".junie/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".junie/skills/",agentFile:"AGENTS.md"}},{id:"openhands",name:"OpenHands",project:{skillsPath:".openhands/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".openhands/skills/",agentFile:"AGENTS.md"}},{id:"kiro",name:"Kiro",project:{skillsPath:".kiro/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".kiro/skills/",agentFile:"AGENTS.md"}},{id:"replit",name:"Replit",project:{skillsPath:".replit/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".replit/skills/",agentFile:"AGENTS.md"}},{id:"kimi",name:"Kimi",project:{skillsPath:".kimi/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".kimi/skills/",agentFile:"AGENTS.md"}},{id:"universal",name:"Universal",project:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},user:{skillsPath:".agents/skills/",agentFile:"AGENTS.md"},mcp:{project:!0,user:!0}},Ne("aider-desk","AiderDesk",".aider-desk/skills/",".aider-desk/skills/"),Ne("antigravity","Antigravity",".agents/skills/",".gemini/antigravity/skills/"),Ne("antigravity-cli","Antigravity CLI",".agents/skills/",".gemini/antigravity-cli/skills/"),Ne("autohand-code","Autohand Code CLI",".autohand/skills/",".autohand/skills/"),Ne("bob","IBM Bob",".bob/skills/",".bob/skills/"),Ne("codearts-agent","CodeArts Agent",".codeartsdoer/skills/",".codeartsdoer/skills/"),Ne("codebuddy","CodeBuddy",".codebuddy/skills/",".codebuddy/skills/"),Ne("codemaker","Codemaker",".codemaker/skills/",".codemaker/skills/"),Ne("codestudio","Code Studio",".codestudio/skills/",".codestudio/skills/"),Ne("command-code","Command Code",".commandcode/skills/",".commandcode/skills/"),Ne("cortex","Cortex Code",".cortex/skills/",".snowflake/cortex/skills/"),Ne("crush","Crush",".crush/skills/",".config/crush/skills/"),Ne("deepagents","Deep Agents",".agents/skills/",".deepagents/agent/skills/"),Ne("devin","Devin for Terminal",".devin/skills/",".config/devin/skills/"),Ne("dexto","Dexto",".agents/skills/",".agents/skills/"),Ne("eve","Eve","agent/skills/"),Ne("firebender","Firebender",".agents/skills/",".firebender/skills/"),Ne("forgecode","ForgeCode",".forge/skills/",".forge/skills/"),Ne("fx","fx",".fx/skills/",".fx/skills/"),Ne("goose","Goose",".agents/skills/",".agents/skills/"),Ne("grok","Grok Build",".grok/skills/",".grok/skills/"),Ne("hermes-agent","Hermes Agent",".hermes/skills/",".hermes/skills/"),Ne("iflow-cli","iFlow CLI",".iflow/skills/",".iflow/skills/"),Ne("jazz","Jazz",".jazz/skills/",".jazz/skills/"),Ne("kimchi","Kimchi",".kimchi/skills/",".config/kimchi/harness/skills/"),Ne("kode","Kode",".kode/skills/",".kode/skills/"),Ne("lingma","Lingma",".lingma/skills/",".lingma/skills/"),Ne("minimax-code","MiniMax Code",".minimax/skills/",".minimax/skills/"),Ne("mistral-vibe","Mistral Vibe",".vibe/skills/",".vibe/skills/"),Ne("moxby","Moxby",".moxby/skills/",".moxby/skills/"),Ne("mux","Mux",".mux/skills/",".mux/skills/"),Ne("neovate","Neovate",".neovate/skills/",".neovate/skills/"),Ne("ona","Ona",".ona/skills/",".ona/skills/"),Ne("posit-assistant","Posit Assistant",".posit/assistant/skills/",".posit/assistant/skills/"),Ne("qoder","Qoder",".qoder/skills/",".qoder/skills/"),Ne("qoder-cn","Qoder CN",".qoder/skills/",".qoder-cn/skills/"),Ne("qwen-code","Qwen Code",".qwen/skills/",".qwen/skills/"),Ne("reasonix","Reasonix",".reasonix/skills/",".reasonix/skills/"),Ne("rovodev","Rovo Dev",".rovodev/skills/",".rovodev/skills/"),Ne("sarvam-code","Sarvam Code",".agents/skills/",".agents/skills/"),Ne("tabnine-cli","Tabnine CLI",".tabnine/agent/skills/",".tabnine/agent/skills/"),Ne("terramind","Terramind",".terramind/skills/",".terramind/skills/"),Ne("trae-cn","Trae CN",".trae/skills/",".trae-cn/skills/"),Ne("warp","Warp",".agents/skills/",".agents/skills/"),Ne("zed","Zed",".agents/skills/",".agents/skills/"),Ne("zcode","ZCode",".zcode/skills/",".zcode/skills/"),Ne("zenflow","Zenflow",".zencoder/skills/",".zencoder/skills/"),Ne("pochi","Pochi",".pochi/skills/",".pochi/skills/"),Ne("adal","AdaL",".adal/skills/",".adal/skills/")],Oc=HBe,ga=Oc.map((e)=>e.id),mf=Oc.filter((e)=>e.user!==void 0).map((e)=>e.id),$z=Oc.filter((e)=>e.native?.project).map((e)=>e.id),_z=Oc.filter((e)=>e.native?.user).map((e)=>e.id),F$=Object.freeze({"claude-code":"claude","github-copilot":"copilot","gemini-cli":"gemini",droid:"factory",amp:"ampcode","kiro-cli":"kiro","kimi-code-cli":"kimi"}),WBe=Object.freeze(Object.fromEntries(ga.map((e)=>[e,e])));lr=Object.freeze(Object.fromEntries(Oc.map((e)=>[e.id,e.project]))),hf=Object.freeze(Object.fromEntries(Oc.flatMap((e)=>e.user?[[e.id,e.user]]:[])));GBe={vscode:"copilot"}});function Fy(e){let t=gf(e);if(!t)throw Error(`Unknown client '${e}'`);return t}function Pz(e){return YX.filter((t)=>e.includes(F$[t]))}function tQ(e){return[...new Set(e)]}function rQ(e,t){return[...e.map((r)=>`${r}:file`),...t.map((r)=>`${r}:native`)]}function nQ(e){let t=e.lastIndexOf(":");return{name:Fy(e.slice(0,t)),install:e.slice(t+1)}}function Tc(e){if(typeof e==="string")return{name:e,install:"file"};return{name:e.name,install:e.install??"file"}}function Uy(e){let t=new Set,r=[];for(let i of e){let{name:n}=Tc(i);if(t.has(n))continue;t.add(n),r.push(i)}return r}function $n(e){let t=new Set;for(let r of e)t.add(Tc(r).name);return[...t]}function Ez(e,t){for(let r of e){let i=Tc(r);if(i.name===t)return i.install}return"file"}var ZBe,YX,vs,Kr,KBe,XX,JBe,QX,YBe,eQ,ha,j$,jy,zy,ku,XBe,QBe,e6e,t6e,r6e,n6e,z$,i6e,Ly,Cz;var Rz=R(()=>{Ac();fi();fi();ZBe=S.enum(ga),YX=Object.keys(F$),vs=[...ga,...YX];Kr=S.enum(vs).transform(Fy);KBe=Pz(mf),XX=[...mf,...KBe],JBe=Pz($z),QX=[...$z,...JBe],YBe=Pz(_z),eQ=[..._z,...YBe],ha=S.enum(XX,{error:(e)=>{if(e.code!=="invalid_value"||typeof e.input!=="string")return;let t=gf(e.input);return t&&!mf.includes(t)?`Client '${e.input}' does not support user scope`:`Unknown client '${e.input}'`}}).transform(Fy),j$=S.array(S.string().transform((e)=>gf(e)??e));jy=S.array(Kr).transform(tQ),zy=S.array(ha).transform(tQ),ku=S.enum(["file","native"]);XBe=rQ(vs,QX),QBe=rQ(XX,eQ);e6e=S.enum(XBe).transform(nQ),t6e=S.enum(QBe).transform(nQ),r6e=S.enum(QX).transform(Fy),n6e=S.enum(eQ).transform(Fy),z$=S.union([Kr,e6e,S.object({name:Kr,install:S.literal("file").default("file")}),S.object({name:r6e,install:S.literal("native")})]),i6e=S.union([ha,t6e,S.object({name:ha,install:S.literal("file").default("file")}),S.object({name:n6e,install:S.literal("native")})]);Ly=S.array(z$).transform(Uy),Cz=S.array(i6e).transform(Uy)});function fe(e){return typeof e==="string"?e:e.source}function uo(e){let t=fe(e),r=Iz(e);if(!r)return t;if(t.startsWith(".")||t.startsWith("/")||t.includes("\\")||/^[a-zA-Z]:/.test(t)||/^[a-z]+:\/\//i.test(t)&&!/^https?:\/\/(?:www\.)?github\.com\//i.test(t)||t.slice(0,t.indexOf("/")).includes("@"))return t;if(/\/tree\/|\/blob\//.test(t))return t;let n=t.replace(/^https?:\/\/(?:www\.)?github\.com\//,"").replace(/^github\.com\//,"").replace(/^gh:/,"").split("/"),o=n[1];if(!o||o.includes("@"))return t;return n[1]=`${o}@${r}`,n.join("/")}function uQ(e){return typeof e==="string"?void 0:e.clients}function p6e(e){return typeof e==="string"?void 0:e.install}function pQ(e){return typeof e==="string"?void 0:e.exclude}function Iz(e){return typeof e==="string"?void 0:e.ref}function dQ(e,t){let r=p6e(e);if(r)return r;return t.install}function h6e(e){return e.toLowerCase().replace(/\.(?:cmd|ps1)$/i,"")}function Dc(e){return e!==void 0&&hQ.test(e)}var o6e,cQ,s6e,a6e,By,c6e,lQ,l6e,u6e,d6e,f6e,m6e,fQ,mQ,gQ,Az,g6e,hQ,iQ,zt,U$,oQ,Oz,Tz,Dz,Mz,yf,y6e,v6e,w6e,b6e,k6e,sQ,S6e,Oi,Nz,x6e,aQ,$6e,_6e,P6e,yQ,vQ,L$;var it=R(()=>{Ac();Rz();Rz();o6e=S.union([S.boolean(),S.enum(["clone","sync"])]),cQ=S.object({path:S.string(),name:S.string().optional(),source:S.string().optional(),repo:S.string().optional(),description:S.string().optional(),skills:S.union([S.boolean(),S.array(S.string())]).optional(),managed:o6e.optional(),ref:S.string().optional(),branch:S.never({error:"has been renamed to 'ref'"}).optional().describe("Renamed to 'ref'")}),s6e=S.union([S.string(),S.object({source:S.string().optional(),dest:S.string().optional()})]),a6e=S.object({source:S.string().optional(),files:S.array(s6e)}),By=S.string(),c6e=S.union([S.array(S.string()),S.object({exclude:S.array(S.string())})]),lQ=S.object({source:By,clients:jy.optional(),install:ku.optional(),exclude:S.array(S.string()).optional(),skills:c6e.optional(),ref:S.string().optional()}).strict(),l6e=S.union([By,lQ]),u6e=S.union([By,lQ.extend({clients:zy.optional()})]);d6e=S.object({output:S.string().optional()}),f6e=S.enum(["symlink","copy"]),m6e=S.object({proxy:j$}),fQ=S.object({clients:j$.default([]),servers:S.record(S.string(),m6e).optional()}),mQ=S.object({type:S.enum(["http"]).optional(),url:S.string(),headers:S.record(S.string(),S.string()).optional(),clients:jy.optional()}).strict(),gQ=S.object({type:S.enum(["stdio"]).optional(),command:S.string(),args:S.array(S.string()).optional(),env:S.record(S.string(),S.string()).optional(),clients:jy.optional()}).strict(),Az=S.union([mQ,gQ]),g6e=S.union([mQ.extend({clients:zy.optional()}),gQ.extend({clients:zy.optional()})]),hQ=/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/,iQ=S.string().regex(hQ,"Expected an exact ${ENV_VAR} reference"),zt=S.string().regex(/^(?!(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$))(?!.*\.$)[a-z0-9][a-z0-9._-]{0,63}$/,"Expected 1-64 portable lowercase ASCII characters starting with a letter or number"),U$=S.string().regex(/^[A-Za-z0-9_.-]{1,100}$/,"Expected 1-100 ASCII letters, numbers, dots, underscores, or hyphens");oQ=S.object({}).strict(),Oz=S.object({model:S.string().min(1).optional(),effortLevel:S.enum(["low","medium","high","xhigh"]).optional(),fallbackModel:S.array(S.string().min(1)).min(1).optional(),outputStyle:S.string().min(1).optional(),autoMemoryEnabled:S.boolean().optional(),spinnerTipsEnabled:S.boolean().optional(),autoUpdatesChannel:S.enum(["stable","latest"]).optional()}).strict(),Tz=S.object({model:S.string().min(1).optional(),small_model:S.string().min(1).optional(),default_agent:S.string().min(1).optional(),username:S.string().min(1).optional(),share:S.enum(["manual","auto","disabled"]).optional(),autoupdate:S.union([S.boolean(),S.literal("notify")]).optional(),snapshot:S.boolean().optional(),subagent_depth:S.number().int().nonnegative().optional(),logLevel:S.enum(["DEBUG","INFO","WARN","ERROR"]).optional(),disabled_providers:S.array(S.string().min(1)).optional(),enabled_providers:S.array(S.string().min(1)).optional()}).strict(),Dz=S.object({model:S.string().min(1).optional(),theme:S.enum(["default","github","dim","high-contrast","colorblind"]).optional(),autoUpdate:S.boolean().optional(),autoUpdatesChannel:S.enum(["stable","prerelease"]).optional(),banner:S.enum(["always","once","never"]).optional(),askUser:S.boolean().optional(),includeCoAuthoredBy:S.boolean().optional(),stream:S.boolean().optional(),streamerMode:S.boolean().optional(),toolSearch:S.boolean().optional(),updateTerminalTitle:S.boolean().optional(),respectGitignore:S.boolean().optional(),disableAllHooks:S.boolean().optional(),experimental:S.boolean().optional(),bashEnv:S.boolean().optional(),keepAlive:S.enum(["on","off","busy"]).optional(),commandHistoryMaxSize:S.number().int().min(1).max(1000).optional(),compactPaste:S.boolean().optional(),mouse:S.boolean().optional(),terminalProgress:S.boolean().optional(),remote:S.enum(["on","off"]).optional(),remoteExport:S.boolean().optional(),"ide.autoConnect":S.boolean().optional(),shellShortcut:S.boolean().optional(),"customAgents.defaultLocalOnly":S.boolean().optional(),storeTokenPlaintext:S.boolean().optional(),disabledMcpServers:S.array(S.string().min(1)).optional(),enabledMcpServers:S.array(S.string().min(1)).optional()}).strict(),Mz=S.object({model:S.string().min(1).optional(),model_reasoning_effort:S.enum(["minimal","low","medium","high","xhigh"]).optional(),model_reasoning_summary:S.enum(["auto","concise","detailed","none"]).optional(),model_verbosity:S.enum(["low","medium","high"]).optional(),approval_policy:S.enum(["on-request","never"]).optional(),sandbox_mode:S.enum(["read-only","workspace-write","danger-full-access"]).optional(),web_search:S.enum(["disabled","cached","indexed","live"]).optional(),personality:S.enum(["none","friendly","pragmatic"]).optional()}).strict(),yf={install:ku.default("file"),launcher:zt.optional()},y6e=S.enum(["claude","claude-code"]).transform(()=>"claude"),v6e=S.enum(["copilot","github-copilot"]).transform(()=>"copilot"),w6e=S.union([S.object({name:y6e,...yf,settings:Oz.default({})}).strict(),S.object({name:S.literal("opencode"),...yf,settings:Tz.default({})}).strict(),S.object({name:v6e,...yf,settings:Dz.default({})}).strict(),S.object({name:S.literal("codex"),...yf,settings:Mz.default({})}).strict(),S.object({name:S.enum(["pi","omp"]),...yf,settings:oQ.default({})}).strict(),S.object({name:ha,...yf,settings:oQ.default({})}).strict()]),b6e=S.union([S.array(S.string()),S.object({exclude:S.array(S.string())}).strict()]),k6e=S.union([By,S.object({source:By,ref:S.string().optional(),install:ku.optional(),clients:S.array(ha).optional(),skills:b6e.optional()}).strict()]),sQ=/(?:^|[-_.])(?:api[-_]?key|auth|authorization|credential|key|password|secret|signature|token)(?:$|[-_.])/i;S6e=S.array(S.string()).superRefine((e,t)=>{let r=new Set,i=(n)=>{if(r.has(n))return;r.add(n),t.addIssue({code:S.ZodIssueCode.custom,path:[n],message:"Secret arguments must be exact ${ENV_VAR} references"})};for(let[n,o]of e.entries()){if(e[n-1]==="--header-env"){if(!/^[^=:\s]+=[A-Za-z_][A-Za-z0-9_]*$/.test(o))i(n);continue}let a=o.match(/^(?:--?|\/)([^=:\s]+)$/)?.[1];if(a&&sQ.test(a)){let d=n+1;if(!Dc(e[d]))i(d<e.length?d:n);continue}if(/^bearer$/i.test(o)){let d=n+1;if(!Dc(e[d]))i(d<e.length?d:n);continue}let c=o.match(/^(?:--?|\/)?([^=:\s]+)[=:]\s*(.*)$/),l=c?.[1],u=l&&sQ.test(l)?c[2]:void 0,p=o.match(/\bbearer\s+(.+)$/i)?.[1];if(u!==void 0&&!Dc(u)&&!Dc(p)){i(n);continue}if(p!==void 0&&!Dc(p)){i(n);continue}if(o.includes("${")&&!Dc(o)&&!Dc(u)&&!Dc(p))i(n)}}),Oi=S.union([S.object({type:S.enum(["http"]).optional(),url:S.string(),headers:S.record(S.string(),iQ).optional(),clients:S.array(ha).optional()}).strict(),S.object({type:S.enum(["stdio"]).optional(),command:S.string(),args:S6e.optional(),env:S.record(S.string(),iQ).optional(),clients:S.array(ha).optional()}).strict()]),Nz=S.object({clients:S.array(w6e).min(1),plugins:S.array(k6e).default([]),mcpServers:S.record(U$,Oi).optional(),mcpProxy:fQ.optional()}).strict().superRefine((e,t)=>{let r=new Set;e.clients.forEach((n,o)=>{if(r.has(n.name))t.addIssue({code:S.ZodIssueCode.custom,path:["clients",o,"name"],message:`Client '${n.name}' is declared more than once`});r.add(n.name)});let i=(n,o,s=!1)=>{if(!n)return;let a=new Set;n.forEach((c,l)=>{if(a.has(c))t.addIssue({code:S.ZodIssueCode.custom,path:[...o,l],message:`Client selector '${c}' is duplicated`});else if(!(s&&c==="*")&&!r.has(c))t.addIssue({code:S.ZodIssueCode.custom,path:[...o,l],message:`Client selector '${c}' is not declared by this profile`});a.add(c)})};if(e.plugins.forEach((n,o)=>{if(typeof n!=="string")i(n.clients,["plugins",o,"clients"])}),e.mcpServers)for(let[n,o]of Object.entries(e.mcpServers))i(o.clients,["mcpServers",n,"clients"]);if(e.mcpProxy){if(i(e.mcpProxy.clients,["mcpProxy","clients"]),e.mcpProxy.servers)for(let[n,o]of Object.entries(e.mcpProxy.servers))i(o.proxy,["mcpProxy","servers",n,"proxy"],!0)}}),x6e=S.record(zt,Nz).superRefine((e,t)=>{let r=new Map;for(let[i,n]of Object.entries(e))n.clients.forEach((o,s)=>{if(!o.launcher)return;let a=h6e(o.launcher),c=r.get(a);if(c){t.addIssue({code:S.ZodIssueCode.custom,path:[i,"clients",s,"launcher"],message:`Launcher '${o.launcher}' collides with '${c}' on a supported platform`});return}r.set(a,o.launcher)})}),aQ=S.string().refine((e)=>e.trim().length>0,"Setup command cannot be blank"),$6e=S.enum(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]),_6e=S.enum(["arm","arm64","ia32","loong64","mips","mipsel","ppc","ppc64","riscv64","s390","s390x","x64"]),P6e=S.union([aQ,S.object({run:aQ,platforms:S.array($6e).min(1).optional(),architectures:S.array(_6e).min(1).optional()}).strict()]),yQ=S.object({version:S.number().optional(),setup:S.array(P6e).optional(),workspace:a6e.optional(),repositories:S.array(cQ),plugins:S.array(l6e),clients:Ly,vscode:d6e.optional(),syncMode:f6e.optional(),mcpProxy:fQ.optional(),mcpServers:S.record(S.string(),Az).optional(),disabledSkills:S.array(S.string()).optional(),enabledSkills:S.array(S.string()).optional()}),vQ=yQ.extend({profiles:S.never().optional()}),L$=yQ.extend({repositories:S.array(cQ).default([]),plugins:S.array(u6e).default([]),clients:Cz.default([]),mcpServers:S.record(S.string(),g6e).optional(),profiles:x6e.optional()})});import{spawn as C6e}from"node:child_process";import{createHash as E6e,randomUUID as bQ}from"node:crypto";import{constants as R6e}from"node:fs";import{access as I6e,mkdir as A6e,readFile as kQ,rename as wQ,rm as Fz,writeFile as O6e}from"node:fs/promises";import{createServer as SQ}from"node:http";import{dirname as T6e,join as xu}from"node:path";function Su(e,t,r){if(typeof e==="string"){for(let i of t)if(i&&e.includes(i))return!0;return!1}if(e===null||typeof e!=="object")return!1;if(r.has(e))return!1;if(r.add(e),e instanceof Error){if(Su(e.message,t,r)||Su(e.cause,t,r)||e instanceof AggregateError&&Su(e.errors,t,r))return!0}for(let[i,n]of Object.entries(e))if(Su(i,t,r)||Su(n,t,r))return!0;return!1}function V$(e){let t=e instanceof Set?e:new Set(e);return{assertSafe(r){if(Su(r,t,new Set))throw new jz},sanitizeError(r){if(Su(r,t,new Set))return new jz;return r instanceof Error?r:Error(String(r))}}}function $Q(e,t=process.env){return Object.fromEntries(Object.entries(e).map(([r,i])=>{let n=M6e.exec(i);if(!n)return[r,i];let o=n[1],s=t[o];if(s===void 0)throw Error(`MCP header '${r}' references missing environment variable '${o}'`);return[r,s]}))}function zz(e,t){if(e instanceof lo||e instanceof Rc||e instanceof H$)return!0;if(e===null||typeof e!=="object")return!1;if(t.has(e))return!1;t.add(e);let r=e;if(r.error==="invalid_grant"||r.errorCode==="invalid_grant")return!0;if(e instanceof Error&&e.message==="OAuth authorization requires an interactive terminal")return!0;if(zz(r.cause,t)||e instanceof AggregateError&&e.errors.some((i)=>zz(i,t)))return!0;return!1}function W$(e){return zz(e,new Set)}function _Q(e,t,r){let i;try{i=new URL(e.trim())}catch{throw Error("Invalid OAuth callback URL")}let n=new URL(t);if(i.username||i.password||i.origin!==n.origin||i.pathname!==n.pathname||i.hash)throw Error("OAuth callback URL does not match the registered redirect");let o=i.searchParams.getAll("state");if(o.length!==1||o[0]!==r)throw Error("OAuth state validation failed");let s=i.searchParams.getAll("error"),a=i.searchParams.getAll("code");if(s.length===1&&s[0]&&a.length===0)return{authorizationError:!0};if(s.length>0)throw Error("Invalid OAuth authorization response");if(a.length!==1||!a[0])throw Error("No OAuth authorization code received");return{code:a[0]}}function Lz(e,t,r){_Q(e,t,r)}function Uz(e,t,r){let i=_Q(e,t,r);if(i.authorizationError)throw new H$;return i.code}function PQ(e){return E6e("sha256").update(e).digest("hex").slice(0,16)}function G$(e,t){let r=PQ(e);if(!t)return xu(ye(),".allagents","oauth-proxy",r);return xu(ye(),".allagents","profiles",zt.parse(t),"oauth-proxy",r)}function N6e(e,t){if(!e.body)return e;let r=e.headers.get("content-type")?.toLowerCase().startsWith("text/event-stream"),i=0,n=0,o=0,s=!1,a=(l)=>{if(o===0){n=0;return}if(n+=o+l,o=0,n>t)throw Error(`MCP HTTP SSE event exceeds ${t} bytes`)},c=e.body.pipeThrough(new TransformStream({transform(l,u){if(!r){if(i+=l.byteLength,i>t)throw Error(`MCP HTTP response exceeds ${t} bytes`);u.enqueue(l);return}for(let p of l){if(s){if(a(p===10?2:1),s=!1,p===10)continue}if(p===13)s=!0;else if(p===10)a(1);else if(o+=1,n+o>t)throw Error(`MCP HTTP SSE event exceeds ${t} bytes`)}u.enqueue(l)},flush(){if(s)a(1)}}));return new Response(c,{headers:e.headers,status:e.status,statusText:e.statusText})}function F6e(e,t,r=fetch,i={}){let n=new URL(e).origin,o=new Headers;for(let[a,c]of Object.entries(t))if(!CQ[a.toLowerCase()])o.set(a,c);let s=i.maxResponseBytes;if(s!==void 0&&(!Number.isSafeInteger(s)||s<0))throw Error("MCP HTTP response byte limit must be a safe integer");return async(a,c)=>{let l=new URL(a.toString()),u=c;if(l.origin===n){let d=new Headers(o);new Headers(c?.headers).forEach((f,m)=>{d.set(m,f)}),u={...c,headers:d,redirect:"error"}}let p=await r(a,u);return s===void 0?p:N6e(p,s)}}async function EQ(e){try{return await I6e(e,R6e.F_OK),!0}catch{return!1}}async function q$(e){if(!await EQ(e))return;return JSON.parse(await kQ(e,"utf-8"))}async function B$(e,t){await A6e(T6e(e),{recursive:!0,mode:448}),await O6e(e,t,{encoding:"utf-8",mode:384})}function j6e(e){let t=e&&"redirect_uris"in e?e.redirect_uris?.[0]:void 0;if(!t)return;try{let r=new URL(t);if((r.hostname==="127.0.0.1"||r.hostname==="localhost")&&r.port)return Number(r.port)}catch{return}return}function z6e(){return new Promise((e,t)=>{let r=SQ();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let i=r.address(),n=typeof i==="object"&&i?i.port:void 0;r.close((o)=>{if(o){t(o);return}if(!n){t(Error("Failed to determine a free loopback port"));return}e(n)})})})}function RQ(e,t=process.platform){return t==="darwin"?[{command:"open",args:[e]}]:t==="win32"?[{command:"explorer.exe",args:[e]}]:[{command:"xdg-open",args:[e]},{command:"gio",args:["open",e]}]}function U6e(e){let t=RQ(e);return new Promise((r)=>{let i=(n)=>{if(n>=t.length){r();return}let o=t[n];if(!o){r();return}let{command:s,args:a}=o,c=C6e(s,a,{detached:!0,stdio:"ignore"});c.once("spawn",()=>{c.unref(),r()}),c.once("error",()=>{i(n+1)})};i(0)})}class IQ{port;clientInfoPath;tokensPath;verifierPath;discoveryPath;redirectUriValue;clientInfo=void 0;tokenSet=void 0;discovery=void 0;codeVerifierValue=void 0;pendingAuth=void 0;authorizationUnavailable=!1;callbackUrlReader;authorizationOutput;allowAuthorization;credentialValues;signal;stateValue=bQ();constructor(e,t,r={}){this.port=e;let i=G$(t,r.profile);this.clientInfoPath=xu(i,"client-info.json"),this.tokensPath=xu(i,"tokens.json"),this.verifierPath=xu(i,"code-verifier.txt"),this.discoveryPath=xu(i,"discovery.json"),this.redirectUriValue=`http://127.0.0.1:${e}/callback`,this.callbackUrlReader=r.callbackUrlReader,this.authorizationOutput=r.authorizationOutput??console.error,this.allowAuthorization=r.allowAuthorization??!0,this.credentialValues=r.credentialValues??new Set,this.signal=r.signal}get redirectUrl(){return this.redirectUriValue}get clientMetadata(){return{client_name:"AllAgents",redirect_uris:[this.redirectUriValue],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}}state(){return this.stateValue}async load(){if(this.clientInfo=await q$(this.clientInfoPath),this.tokenSet=await q$(this.tokensPath),this.discovery=await q$(this.discoveryPath),await EQ(this.verifierPath))this.codeVerifierValue=await kQ(this.verifierPath,"utf-8");let e=this.clientInfo?.client_secret;if(e)this.credentialValues.add(e);if(this.tokenSet?.access_token)this.credentialValues.add(this.tokenSet.access_token);if(this.tokenSet?.refresh_token)this.credentialValues.add(this.tokenSet.refresh_token);if(this.codeVerifierValue)this.credentialValues.add(this.codeVerifierValue)}clientInformation(){return this.clientInfo}async saveClientInformation(e){this.clientInfo=e;let t=e.client_secret;if(t)this.credentialValues.add(t);await B$(this.clientInfoPath,`${JSON.stringify(e,null,2)}
|
|
334
334
|
`)}tokens(){return this.tokenSet}async saveTokens(e){if(this.tokenSet=e,this.credentialValues.add(e.access_token),e.refresh_token)this.credentialValues.add(e.refresh_token);await B$(this.tokensPath,`${JSON.stringify(e,null,2)}
|
|
335
335
|
`)}redirectToAuthorization(e){if(!this.allowAuthorization){this.authorizationUnavailable=!0;return}this.pendingAuth??=this.waitForAuthorizationCode(e)}async saveCodeVerifier(e){this.codeVerifierValue=e,this.credentialValues.add(e),await B$(this.verifierPath,e)}codeVerifier(){if(!this.codeVerifierValue)throw Error("No OAuth code verifier is available");return this.codeVerifierValue}async saveDiscoveryState(e){this.discovery=e,await B$(this.discoveryPath,`${JSON.stringify(e,null,2)}
|
|
336
336
|
`)}discoveryState(){return this.discovery}async invalidateCredentials(e){let t=e==="all"?[this.clientInfoPath,this.tokensPath,this.verifierPath,this.discoveryPath]:e==="client"?[this.clientInfoPath]:e==="tokens"?[this.tokensPath]:e==="verifier"?[this.verifierPath]:[this.discoveryPath];await Promise.all(t.map((r)=>Fz(r,{force:!0})))}async waitForAuthCode(){if(this.authorizationUnavailable)throw Error("OAuth authorization requires an interactive terminal");if(!this.pendingAuth)throw Error("OAuth authorization has not been started");let e=await this.pendingAuth;return this.credentialValues.add(e),e}waitForAuthorizationCode(e){let{promise:t,resolve:r,reject:i}=Promise.withResolvers(),n=new AbortController,o,s=!1,a=(p,d)=>{if(s)return;if(s=!0,clearTimeout(u),n.abort(),o)this.signal?.removeEventListener("abort",o);if(l.listening)l.close();if(p==="resolve")r(d);else i(d)},c=(p)=>{try{a("resolve",Uz(p,this.redirectUriValue,this.stateValue))}catch(d){a("reject",d instanceof Error?d:Error(String(d)))}},l=SQ((p,d)=>{try{let f=new URL(p.url??"/",this.redirectUriValue).toString(),m=Uz(f,this.redirectUriValue,this.stateValue);d.writeHead(200,{"content-type":"text/html; charset=utf-8"}),d.end("<html><body><h1>Authorization complete</h1><p>You can close this window.</p></body></html>"),a("resolve",m)}catch(f){d.writeHead(400,{"content-type":"text/html; charset=utf-8"}),d.end("<html><body><h1>Authorization failed</h1><p>The OAuth response was rejected.</p></body></html>"),a("reject",f instanceof Error?f:Error(String(f)))}}),u=setTimeout(()=>{a("reject",Error("Timed out waiting for OAuth authorization callback"))},D6e);if(o=()=>{let p=this.signal?.reason;a("reject",p instanceof Error?p:Error("MCP connection was cancelled"))},this.signal?.aborted)return o(),t;return this.signal?.addEventListener("abort",o,{once:!0}),l.on("error",(p)=>a("reject",p)),l.listen(this.port,"127.0.0.1",()=>{if(this.authorizationOutput("Opening browser for authorization..."),this.authorizationOutput(`${xQ}${e.toString()}`),this.authorizationOutput(this.callbackUrlReader?"Using a remote browser? Paste its callback URL in this terminal.":"Using a remote browser? Run `allagents mcp reauth <name>` in this workspace, then reconnect."),process.env.ALLAGENTS_MCP_OAUTH_NO_BROWSER==="1")this.authorizationOutput("Skipping automatic browser open (ALLAGENTS_MCP_OAUTH_NO_BROWSER=1).");else U6e(e.toString());if(this.callbackUrlReader)this.callbackUrlReader({authorizationUrl:e,redirectUrl:this.redirectUriValue,state:this.stateValue,signal:n.signal}).then(c).catch((p)=>{if(n.signal.aborted)return;a("reject",p instanceof Error?p:Error(String(p)))})}),t}}async function L6e(e,t={}){let r=G$(e,t.profile),i=await q$(xu(r,"client-info.json")),n=j6e(i);if(!n)n=await z6e();let o=new IQ(n,e,t);return await o.load(),o}async function qy(e,t={}){let r=new Set,i=$Q(t.headers??{},t.environment);for(let[u,p]of Object.entries(i)){if(CQ[u.toLowerCase()])continue;if(r.add(p),u.toLowerCase()==="authorization"||u.toLowerCase()==="proxy-authorization"){let d=/^\s*\S+\s+(.+?)\s*$/.exec(p)?.[1];if(d)r.add(d)}}let n=await L6e(e,{...t.callbackUrlReader&&{callbackUrlReader:t.callbackUrlReader},...t.authorizationOutput&&{authorizationOutput:t.authorizationOutput},...t.allowAuthorization===void 0?{}:{allowAuthorization:t.allowAuthorization},...t.profile===void 0?{}:{profile:t.profile},...t.signal===void 0?{}:{signal:t.signal},credentialValues:r}),o=new Ty({name:"AllAgents",version:"1.0.0"},{capabilities:{}}),s=()=>{let u=Object.keys(i).length>0||t.fetch||t.maxResponseBytes!==void 0?F6e(e,i,t.fetch,{...t.maxResponseBytes===void 0?{}:{maxResponseBytes:t.maxResponseBytes}}):void 0;return new xz(new URL(e),{authProvider:n,...u&&{fetch:u}})},a=s(),c,l=()=>(c??=o.close(),c);try{try{await o.connect(a,t.signal===void 0?void 0:{signal:t.signal})}catch(u){if(!(u instanceof lo))throw u;if(t.signal?.aborted)throw u;let p=await n.waitForAuthCode();await a.finishAuth(p),await a.close(),a=s(),await o.connect(a,t.signal===void 0?void 0:{signal:t.signal})}}catch(u){let p=V$(r),d=p.sanitizeError(u),f=W$(u)?new lo(d.message):d;try{await l()}catch(m){throw AggregateError([f,p.sanitizeError(m)],"MCP connection failed and its transport could not be closed")}throw f}return{client:o,transport:a,credentialGuard:V$(r),close:l}}async function Bz(e,t={}){let r=G$(e,t.profile),i=t.resetCredentials?`${r}.reauth-backup-${bQ()}`:void 0,n=!1;if(i)try{await wQ(r,i),n=!0}catch(o){if(!(o instanceof Error&&("code"in o)&&o.code==="ENOENT"))throw o}try{let o=await qy(e,t);try{await o.transport.terminateSession()}finally{await o.close()}}catch(o){if(i)try{if(await Fz(r,{recursive:!0,force:!0}),n)await wQ(i,r)}catch(s){throw AggregateError([o,s],"MCP reauthentication failed and the previous credentials could not be restored")}throw o}if(n&&i)await Fz(i,{recursive:!0,force:!0})}var D6e=300000,xQ="If the browser does not open, visit: ",M6e,jz,H$,CQ;var Vy=R(()=>{vz();pz();bz();VX();ut();it();M6e=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;jz=class jz extends Error{constructor(){super("MCP output contained a configured credential value");this.name="McpCredentialReflectionError"}};H$=class H$ extends Error{constructor(){super("OAuth authorization failed");this.name="OAuthAuthorizationError"}};CQ={connection:!0,"content-length":!0,host:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0}});function Ti(e){return SH(e,{schema:q6e})}var q6e;var vf=R(()=>{cs();q6e=QI.withTags(ZI,WI,GI,KI,JI,YI)});function H6e(e){return e.find((t)=>t.length>0&&t.every((r)=>V6e[r.code]===!0))}function ya(e){let t=new Map,r=(n)=>{t.set(`${n.path.join(".")}|${n.code}|${n.message}`,n)},i=(n,o)=>{let s=[...o,...n.path];if(n.code==="invalid_union"){let a=H6e(n.errors??[]);if(!a){r({...n,path:s});return}for(let c of a)i(c,s);return}if(n.code==="invalid_key"&&n.issues&&n.issues.length>0){for(let a of n.issues)i(a,s);return}r({...n,path:s})};for(let n of e.issues)i(n,[]);return[...t.values()]}var V6e;var wf=R(()=>{V6e={unrecognized_keys:!0,custom:!0}});import{readFile as W6e}from"node:fs/promises";function qz(e,t,r){let n=(t==="user"?L$:vQ).safeParse(r);if(n.success)return n.data;let o=ya(n.error).map((s)=>` - ${s.path.join(".")}: ${s.message}`);throw Error(`${e} validation failed:
|
|
@@ -483,7 +483,7 @@ return `+str.trim()+`;
|
|
|
483
483
|
* Released under the MIT License.
|
|
484
484
|
*/var OJe=jce(),zce={"{":"}","(":")","[":"]"},TJe=function(e){if(e[0]==="!")return!0;var t=0,r=-2,i=-2,n=-2,o=-2,s=-2;while(t<e.length){if(e[t]==="*")return!0;if(e[t+1]==="?"&&/[\].+)]/.test(e[t]))return!0;if(i!==-1&&e[t]==="["&&e[t+1]!=="]"){if(i<t)i=e.indexOf("]",t);if(i>t){if(s===-1||s>i)return!0;if(s=e.indexOf("\\",t),s===-1||s>i)return!0}}if(n!==-1&&e[t]==="{"&&e[t+1]!=="}"){if(n=e.indexOf("}",t),n>t){if(s=e.indexOf("\\",t),s===-1||s>n)return!0}}if(o!==-1&&e[t]==="("&&e[t+1]==="?"&&/[:!=]/.test(e[t+2])&&e[t+3]!==")"){if(o=e.indexOf(")",t),o>t){if(s=e.indexOf("\\",t),s===-1||s>o)return!0}}if(r!==-1&&e[t]==="("&&e[t+1]!=="|"){if(r<t)r=e.indexOf("|",t);if(r!==-1&&e[r+1]!==")"){if(o=e.indexOf(")",r),o>r){if(s=e.indexOf("\\",r),s===-1||s>o)return!0}}}if(e[t]==="\\"){var a=e[t+1];t+=2;var c=zce[a];if(c){var l=e.indexOf(c,t);if(l!==-1)t=l+1}if(e[t]==="!")return!0}else t++}return!1},DJe=function(e){if(e[0]==="!")return!0;var t=0;while(t<e.length){if(/[*?{}()[\]]/.test(e[t]))return!0;if(e[t]==="\\"){var r=e[t+1];t+=2;var i=zce[r];if(i){var n=e.indexOf(i,t);if(n!==-1)t=n+1}if(e[t]==="!")return!0}else t++}return!1};Uce.exports=function(t,r){if(typeof t!=="string"||t==="")return!1;if(OJe(t))return!0;var i=TJe;if(r&&r.strict===!1)i=DJe;return i(t)}});var qce=O(function(CNt,Bce){var MJe=Lce(),NJe=Le("path").posix.dirname,FJe=Le("os").platform()==="win32",A2="/",jJe=/\\/g,zJe=/[\{\[].*[\}\]]$/,UJe=/(^|[^\\])([\{\[]|\([^\)]+$)/,LJe=/\\([\!\*\?\|\[\]\(\)\{\}])/g;Bce.exports=function(t,r){var i=Object.assign({flipBackslashes:!0},r);if(i.flipBackslashes&&FJe&&t.indexOf(A2)<0)t=t.replace(jJe,A2);if(zJe.test(t))t+=A2;t+="a";do t=NJe(t);while(MJe(t)||UJe.test(t));return t.replace(LJe,"$1")}});var tle=O(function(Qce){Object.defineProperty(Qce,"__esModule",{value:!0});Qce.isAbsolute=Qce.partitionAbsoluteAndRelative=Qce.removeDuplicateSlashes=Qce.matchAny=Qce.convertPatternsToRe=Qce.makeRe=Qce.getPatternParts=Qce.expandBraceExpansion=Qce.expandPatternsWithBraceExpansion=Qce.isAffectDepthOfReadingPattern=Qce.endsWithSlashGlobStar=Qce.hasGlobStar=Qce.getBaseDirectory=Qce.isPatternRelatedToParentDirectory=Qce.getPatternsOutsideCurrentDirectory=Qce.getPatternsInsideCurrentDirectory=Qce.getPositivePatterns=Qce.getNegativePatterns=Qce.isPositivePattern=Qce.isNegativePattern=Qce.convertToNegativePattern=Qce.convertToPositivePattern=Qce.isDynamicPattern=Qce.isStaticPattern=void 0;var Vce=Le("path"),BJe=qce(),O2=x0(),Hce="**",qJe="\\",VJe=/[*?]|^!/,HJe=/\[[^[]*]/,WJe=/(?:^|[^!*+?@])\([^(]*\|[^|]*\)/,GJe=/[!*+?@]\([^(]*\)/,ZJe=/,|\.\./,KJe=/(?!^)\/{2,}/g;function Wce(e,t={}){return!Gce(e,t)}Qce.isStaticPattern=Wce;function Gce(e,t={}){if(e==="")return!1;if(t.caseSensitiveMatch===!1||e.includes(qJe))return!0;if(VJe.test(e)||HJe.test(e)||WJe.test(e))return!0;if(t.extglob!==!1&&GJe.test(e))return!0;if(t.braceExpansion!==!1&&JJe(e))return!0;return!1}Qce.isDynamicPattern=Gce;function JJe(e){let t=e.indexOf("{");if(t===-1)return!1;let r=e.indexOf("}",t+1);if(r===-1)return!1;let i=e.slice(t,r);return ZJe.test(i)}function YJe(e){return $0(e)?e.slice(1):e}Qce.convertToPositivePattern=YJe;function XJe(e){return"!"+e}Qce.convertToNegativePattern=XJe;function $0(e){return e.startsWith("!")&&e[1]!=="("}Qce.isNegativePattern=$0;function Zce(e){return!$0(e)}Qce.isPositivePattern=Zce;function QJe(e){return e.filter($0)}Qce.getNegativePatterns=QJe;function eYe(e){return e.filter(Zce)}Qce.getPositivePatterns=eYe;function tYe(e){return e.filter((t)=>!T2(t))}Qce.getPatternsInsideCurrentDirectory=tYe;function rYe(e){return e.filter(T2)}Qce.getPatternsOutsideCurrentDirectory=rYe;function T2(e){return e.startsWith("..")||e.startsWith("./..")}Qce.isPatternRelatedToParentDirectory=T2;function nYe(e){return BJe(e,{flipBackslashes:!1})}Qce.getBaseDirectory=nYe;function iYe(e){return e.includes(Hce)}Qce.hasGlobStar=iYe;function Kce(e){return e.endsWith("/"+Hce)}Qce.endsWithSlashGlobStar=Kce;function oYe(e){let t=Vce.basename(e);return Kce(e)||Wce(t)}Qce.isAffectDepthOfReadingPattern=oYe;function sYe(e){return e.reduce((t,r)=>t.concat(Jce(r)),[])}Qce.expandPatternsWithBraceExpansion=sYe;function Jce(e){let t=O2.braces(e,{expand:!0,nodupes:!0,keepEscaping:!0});return t.sort((r,i)=>r.length-i.length),t.filter((r)=>r!=="")}Qce.expandBraceExpansion=Jce;function aYe(e,t){let{parts:r}=O2.scan(e,Object.assign(Object.assign({},t),{parts:!0}));if(r.length===0)r=[e];if(r[0].startsWith("/"))r[0]=r[0].slice(1),r.unshift("");return r}Qce.getPatternParts=aYe;function Yce(e,t){return O2.makeRe(e,t)}Qce.makeRe=Yce;function cYe(e,t){return e.map((r)=>Yce(r,t))}Qce.convertPatternsToRe=cYe;function lYe(e,t){return t.some((r)=>r.test(e))}Qce.matchAny=lYe;function uYe(e){return e.replace(KJe,"/")}Qce.removeDuplicateSlashes=uYe;function pYe(e){let t=[],r=[];for(let i of e)if(Xce(i))t.push(i);else r.push(i);return[t,r]}Qce.partitionAbsoluteAndRelative=pYe;function Xce(e){return Vce.isAbsolute(e)}Qce.isAbsolute=Xce});var ole=O(function(RNt,ile){var MYe=Le("stream"),rle=MYe.PassThrough,NYe=Array.prototype.slice;ile.exports=FYe;function FYe(){let e=[],t=NYe.call(arguments),r=!1,i=t[t.length-1];if(i&&!Array.isArray(i)&&i.pipe==null)t.pop();else i={};let n=i.end!==!1,o=i.pipeError===!0;if(i.objectMode==null)i.objectMode=!0;if(i.highWaterMark==null)i.highWaterMark=65536;let s=rle(i);function a(){for(let u=0,p=arguments.length;u<p;u++)e.push(nle(arguments[u],i));return c(),this}function c(){if(r)return;r=!0;let u=e.shift();if(!u){process.nextTick(l);return}if(!Array.isArray(u))u=[u];let p=u.length+1;function d(){if(--p>0)return;r=!1,c()}function f(m){function g(){if(m.removeListener("merge2UnpipeEnd",g),m.removeListener("end",g),o)m.removeListener("error",h);d()}function h(y){s.emit("error",y)}if(m._readableState.endEmitted)return d();if(m.on("merge2UnpipeEnd",g),m.on("end",g),o)m.on("error",h);m.pipe(s,{end:!1}),m.resume()}for(let m=0;m<u.length;m++)f(u[m]);d()}function l(){if(r=!1,s.emit("queueDrain"),n)s.end()}if(s.setMaxListeners(0),s.add=a,s.on("unpipe",function(u){u.emit("merge2UnpipeEnd")}),t.length)a.apply(null,t);return s}function nle(e,t){if(!Array.isArray(e)){if(!e._readableState&&e.pipe)e=e.pipe(rle(t));if(!e._readableState||!e.pause||!e.pipe)throw Error("Only readable stream can be merged.");e.pause()}else for(let r=0,i=e.length;r<i;r++)e[r]=nle(e[r],t);return e}});var lle=O(function(ale){Object.defineProperty(ale,"__esModule",{value:!0});ale.merge=void 0;var jYe=ole();function zYe(e){let t=jYe(e);return e.forEach((r)=>{r.once("error",(i)=>t.emit("error",i))}),t.once("close",()=>sle(e)),t.once("end",()=>sle(e)),t}ale.merge=zYe;function sle(e){e.forEach((t)=>t.emit("close"))}});var dle=O(function(ule){Object.defineProperty(ule,"__esModule",{value:!0});ule.isEmpty=ule.isString=void 0;function UYe(e){return typeof e==="string"}ule.isString=UYe;function LYe(e){return e===""}ule.isEmpty=LYe});var Aa=O(function(fle){Object.defineProperty(fle,"__esModule",{value:!0});fle.string=fle.stream=fle.pattern=fle.path=fle.fs=fle.errno=fle.array=void 0;var qYe=xce();fle.array=qYe;var VYe=Pce();fle.errno=VYe;var HYe=Ice();fle.fs=HYe;var WYe=Nce();fle.path=WYe;var GYe=tle();fle.pattern=GYe;var ZYe=lle();fle.stream=ZYe;var KYe=dle();fle.string=KYe});var ble=O(function(vle){Object.defineProperty(vle,"__esModule",{value:!0});vle.convertPatternGroupToTask=vle.convertPatternGroupsToTasks=vle.groupPatternsByBaseDirectory=vle.getNegativePatternsAsPositive=vle.getPositivePatterns=vle.convertPatternsToTasks=vle.generate=void 0;var Jo=Aa();function rXe(e,t){let r=gle(e,t),i=gle(t.ignore,t),n=hle(r),o=yle(r,i),s=n.filter((u)=>Jo.pattern.isStaticPattern(u,t)),a=n.filter((u)=>Jo.pattern.isDynamicPattern(u,t)),c=D2(s,o,!1),l=D2(a,o,!0);return c.concat(l)}vle.generate=rXe;function gle(e,t){let r=e;if(t.braceExpansion)r=Jo.pattern.expandPatternsWithBraceExpansion(r);if(t.baseNameMatch)r=r.map((i)=>i.includes("/")?i:`**/${i}`);return r.map((i)=>Jo.pattern.removeDuplicateSlashes(i))}function D2(e,t,r){let i=[],n=Jo.pattern.getPatternsOutsideCurrentDirectory(e),o=Jo.pattern.getPatternsInsideCurrentDirectory(e),s=M2(n),a=M2(o);if(i.push(...N2(s,t,r)),"."in a)i.push(F2(".",o,t,r));else i.push(...N2(a,t,r));return i}vle.convertPatternsToTasks=D2;function hle(e){return Jo.pattern.getPositivePatterns(e)}vle.getPositivePatterns=hle;function yle(e,t){return Jo.pattern.getNegativePatterns(e).concat(t).map(Jo.pattern.convertToPositivePattern)}vle.getNegativePatternsAsPositive=yle;function M2(e){let t={};return e.reduce((r,i)=>{let n=Jo.pattern.getBaseDirectory(i);if(n in r)r[n].push(i);else r[n]=[i];return r},t)}vle.groupPatternsByBaseDirectory=M2;function N2(e,t,r){return Object.keys(e).map((i)=>F2(i,e[i],t,r))}vle.convertPatternGroupsToTasks=N2;function F2(e,t,r,i){return{dynamic:i,positive:t,negative:r,base:e,patterns:[].concat(t,r.map(Jo.pattern.convertToNegativePattern))}}vle.convertPatternGroupToTask=F2});var $le=O(function(Sle){Object.defineProperty(Sle,"__esModule",{value:!0});Sle.read=void 0;function lXe(e,t,r){t.fs.lstat(e,(i,n)=>{if(i!==null){kle(r,i);return}if(!n.isSymbolicLink()||!t.followSymbolicLink){j2(r,n);return}t.fs.stat(e,(o,s)=>{if(o!==null){if(t.throwErrorOnBrokenSymbolicLink){kle(r,o);return}j2(r,n);return}if(t.markSymbolicLink)s.isSymbolicLink=()=>!0;j2(r,s)})})}Sle.read=lXe;function kle(e,t){e(t)}function j2(e,t){e(null,t)}});var Cle=O(function(_le){Object.defineProperty(_le,"__esModule",{value:!0});_le.read=void 0;function uXe(e,t){let r=t.fs.lstatSync(e);if(!r.isSymbolicLink()||!t.followSymbolicLink)return r;try{let i=t.fs.statSync(e);if(t.markSymbolicLink)i.isSymbolicLink=()=>!0;return i}catch(i){if(!t.throwErrorOnBrokenSymbolicLink)return r;throw i}}_le.read=uXe});var Ile=O(function(Ele){Object.defineProperty(Ele,"__esModule",{value:!0});Ele.createFileSystemAdapter=Ele.FILE_SYSTEM_ADAPTER=void 0;var _0=Le("fs");Ele.FILE_SYSTEM_ADAPTER={lstat:_0.lstat,stat:_0.stat,lstatSync:_0.lstatSync,statSync:_0.statSync};function pXe(e){if(e===void 0)return Ele.FILE_SYSTEM_ADAPTER;return Object.assign(Object.assign({},Ele.FILE_SYSTEM_ADAPTER),e)}Ele.createFileSystemAdapter=pXe});var Tle=O(function(Ole){Object.defineProperty(Ole,"__esModule",{value:!0});var dXe=Ile();class Ale{constructor(e={}){this._options=e,this.followSymbolicLink=this._getValue(this._options.followSymbolicLink,!0),this.fs=dXe.createFileSystemAdapter(this._options.fs),this.markSymbolicLink=this._getValue(this._options.markSymbolicLink,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0)}_getValue(e,t){return e!==null&&e!==void 0?e:t}}Ole.default=Ale});var np=O(function(Mle){Object.defineProperty(Mle,"__esModule",{value:!0});Mle.statSync=Mle.stat=Mle.Settings=void 0;var Dle=$le(),mXe=Cle(),U2=Tle();Mle.Settings=U2.default;function gXe(e,t,r){if(typeof t==="function"){Dle.read(e,L2(),t);return}Dle.read(e,L2(t),r)}Mle.stat=gXe;function hXe(e,t){let r=L2(t);return mXe.read(e,r)}Mle.statSync=hXe;function L2(e={}){if(e instanceof U2.default)return e;return new U2.default(e)}});var zle=O(function(zNt,jle){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Fle;jle.exports=typeof queueMicrotask==="function"?queueMicrotask.bind(typeof window<"u"?window:global):(e)=>(Fle||(Fle=Promise.resolve())).then(e).catch((t)=>setTimeout(()=>{throw t},0))});var Lle=O(function(UNt,Ule){/*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */Ule.exports=bXe;var wXe=zle();function bXe(e,t){let r,i,n,o=!0;if(Array.isArray(e))r=[],i=e.length;else n=Object.keys(e),r={},i=n.length;function s(c){function l(){if(t)t(c,r);t=null}if(o)wXe(l);else l()}function a(c,l,u){if(r[c]=u,--i===0||l)s(l)}if(!i)s(null);else if(n)n.forEach(function(c){e[c](function(l,u){a(c,l,u)})});else e.forEach(function(c,l){c(function(u,p){a(l,u,p)})});o=!1}});var B2=O(function(Vle){Object.defineProperty(Vle,"__esModule",{value:!0});Vle.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;var P0=process.versions.node.split(".");if(P0[0]===void 0||P0[1]===void 0)throw Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);var Ble=Number.parseInt(P0[0],10),kXe=Number.parseInt(P0[1],10),qle=10,SXe=10,xXe=Ble>qle,$Xe=Ble===qle&&kXe>=SXe;Vle.IS_SUPPORT_READDIR_WITH_FILE_TYPES=xXe||$Xe});var Kle=O(function(Gle){Object.defineProperty(Gle,"__esModule",{value:!0});Gle.createDirentFromStats=void 0;class Wle{constructor(e,t){this.name=e,this.isBlockDevice=t.isBlockDevice.bind(t),this.isCharacterDevice=t.isCharacterDevice.bind(t),this.isDirectory=t.isDirectory.bind(t),this.isFIFO=t.isFIFO.bind(t),this.isFile=t.isFile.bind(t),this.isSocket=t.isSocket.bind(t),this.isSymbolicLink=t.isSymbolicLink.bind(t)}}function _Xe(e,t){return new Wle(e,t)}Gle.createDirentFromStats=_Xe});var q2=O(function(Jle){Object.defineProperty(Jle,"__esModule",{value:!0});Jle.fs=void 0;var PXe=Kle();Jle.fs=PXe});var V2=O(function(Xle){Object.defineProperty(Xle,"__esModule",{value:!0});Xle.joinPathSegments=void 0;function CXe(e,t,r){if(e.endsWith(r))return e+t;return e+r+t}Xle.joinPathSegments=CXe});var aue=O(function(oue){Object.defineProperty(oue,"__esModule",{value:!0});oue.readdir=oue.readdirWithFileTypes=oue.read=void 0;var EXe=np(),eue=Lle(),RXe=B2(),tue=q2(),rue=V2();function IXe(e,t,r){if(!t.stats&&RXe.IS_SUPPORT_READDIR_WITH_FILE_TYPES){nue(e,t,r);return}iue(e,t,r)}oue.read=IXe;function nue(e,t,r){t.fs.readdir(e,{withFileTypes:!0},(i,n)=>{if(i!==null){C0(r,i);return}let o=n.map((a)=>({dirent:a,name:a.name,path:rue.joinPathSegments(e,a.name,t.pathSegmentSeparator)}));if(!t.followSymbolicLinks){H2(r,o);return}let s=o.map((a)=>AXe(a,t));eue(s,(a,c)=>{if(a!==null){C0(r,a);return}H2(r,c)})})}oue.readdirWithFileTypes=nue;function AXe(e,t){return(r)=>{if(!e.dirent.isSymbolicLink()){r(null,e);return}t.fs.stat(e.path,(i,n)=>{if(i!==null){if(t.throwErrorOnBrokenSymbolicLink){r(i);return}r(null,e);return}e.dirent=tue.fs.createDirentFromStats(e.name,n),r(null,e)})}}function iue(e,t,r){t.fs.readdir(e,(i,n)=>{if(i!==null){C0(r,i);return}let o=n.map((s)=>{let a=rue.joinPathSegments(e,s,t.pathSegmentSeparator);return(c)=>{EXe.stat(a,t.fsStatSettings,(l,u)=>{if(l!==null){c(l);return}let p={name:s,path:a,dirent:tue.fs.createDirentFromStats(s,u)};if(t.stats)p.stats=u;c(null,p)})}});eue(o,(s,a)=>{if(s!==null){C0(r,s);return}H2(r,a)})})}oue.readdir=iue;function C0(e,t){e(t)}function H2(e,t){e(null,t)}});var mue=O(function(due){Object.defineProperty(due,"__esModule",{value:!0});due.readdir=due.readdirWithFileTypes=due.read=void 0;var DXe=np(),MXe=B2(),cue=q2(),lue=V2();function NXe(e,t){if(!t.stats&&MXe.IS_SUPPORT_READDIR_WITH_FILE_TYPES)return uue(e,t);return pue(e,t)}due.read=NXe;function uue(e,t){return t.fs.readdirSync(e,{withFileTypes:!0}).map((i)=>{let n={dirent:i,name:i.name,path:lue.joinPathSegments(e,i.name,t.pathSegmentSeparator)};if(n.dirent.isSymbolicLink()&&t.followSymbolicLinks)try{let o=t.fs.statSync(n.path);n.dirent=cue.fs.createDirentFromStats(n.name,o)}catch(o){if(t.throwErrorOnBrokenSymbolicLink)throw o}return n})}due.readdirWithFileTypes=uue;function pue(e,t){return t.fs.readdirSync(e).map((i)=>{let n=lue.joinPathSegments(e,i,t.pathSegmentSeparator),o=DXe.statSync(n,t.fsStatSettings),s={name:i,path:n,dirent:cue.fs.createDirentFromStats(i,o)};if(t.stats)s.stats=o;return s})}due.readdir=pue});var yue=O(function(gue){Object.defineProperty(gue,"__esModule",{value:!0});gue.createFileSystemAdapter=gue.FILE_SYSTEM_ADAPTER=void 0;var lm=Le("fs");gue.FILE_SYSTEM_ADAPTER={lstat:lm.lstat,stat:lm.stat,lstatSync:lm.lstatSync,statSync:lm.statSync,readdir:lm.readdir,readdirSync:lm.readdirSync};function zXe(e){if(e===void 0)return gue.FILE_SYSTEM_ADAPTER;return Object.assign(Object.assign({},gue.FILE_SYSTEM_ADAPTER),e)}gue.createFileSystemAdapter=zXe});var bue=O(function(wue){Object.defineProperty(wue,"__esModule",{value:!0});var UXe=Le("path"),LXe=np(),BXe=yue();class vue{constructor(e={}){this._options=e,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=BXe.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,UXe.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new LXe.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e!==null&&e!==void 0?e:t}}wue.default=vue});var E0=O(function(Sue){Object.defineProperty(Sue,"__esModule",{value:!0});Sue.Settings=Sue.scandirSync=Sue.scandir=void 0;var kue=aue(),VXe=mue(),G2=bue();Sue.Settings=G2.default;function HXe(e,t,r){if(typeof t==="function"){kue.read(e,Z2(),t);return}kue.read(e,Z2(t),r)}Sue.scandir=HXe;function WXe(e,t){let r=Z2(t);return VXe.read(e,r)}Sue.scandirSync=WXe;function Z2(e={}){if(e instanceof G2.default)return e;return new G2.default(e)}});var _ue=O(function(JNt,$ue){function KXe(e){var t=new e,r=t;function i(){var o=t;if(o.next)t=o.next;else t=new e,r=t;return o.next=null,o}function n(o){r.next=o,r=o}return{get:i,release:n}}$ue.exports=KXe});var Cue=O(function(YNt,K2){var JXe=_ue();function Pue(e,t,r){if(typeof e==="function")r=t,t=e,e=null;if(!(r>=1))throw Error("fastqueue concurrency must be equal to or greater than 1");var i=JXe(YXe),n=null,o=null,s=0,a=null,c={push:g,drain:bi,saturated:bi,pause:u,paused:!1,get concurrency(){return r},set concurrency(k){if(!(k>=1))throw Error("fastqueue concurrency must be equal to or greater than 1");if(r=k,c.paused)return;for(;n&&s<r;)s++,y()},running:l,resume:f,idle:m,length:p,getQueue:d,unshift:h,empty:bi,kill:v,killAndDrain:w,error:b,abort:_};return c;function l(){return s}function u(){c.paused=!0}function p(){var k=n,I=0;while(k)k=k.next,I++;return I}function d(){var k=n,I=[];while(k)I.push(k.value),k=k.next;return I}function f(){if(!c.paused)return;if(c.paused=!1,n===null){s++,y();return}for(;n&&s<r;)s++,y()}function m(){return s===0&&c.length()===0}function g(k,I){var E=i.get();if(E.context=e,E.release=y,E.value=k,E.callback=I||bi,E.errorHandler=a,s>=r||c.paused)if(o)o.next=E,o=E;else n=E,o=E,c.saturated();else s++,t.call(e,E.value,E.worked)}function h(k,I){var E=i.get();if(E.context=e,E.release=y,E.value=k,E.callback=I||bi,E.errorHandler=a,s>=r||c.paused)if(n)E.next=n,n=E;else n=E,o=E,c.saturated();else s++,t.call(e,E.value,E.worked)}function y(k){if(k)i.release(k);var I=n;if(I&&s<=r)if(!c.paused){if(o===n)o=null;if(n=I.next,I.next=null,t.call(e,I.value,I.worked),o===null)c.empty()}else s--;else if(--s===0)c.drain()}function v(){n=null,o=null,c.drain=bi}function w(){n=null,o=null,c.drain(),c.drain=bi}function _(){var k=n;n=null,o=null;while(k){var{next:I,callback:E,errorHandler:P,value:A,context:x}=k;if(k.value=null,k.callback=bi,k.errorHandler=null,k.next=null,P)P(Error("abort"),A);E.call(x,Error("abort")),i.release(k),k=I}c.drain=bi}function b(k){a=k}}function bi(){}function YXe(){this.value=null,this.callback=bi,this.next=null,this.release=bi,this.context=null,this.errorHandler=null;var e=this;this.worked=function(r,i){var{callback:n,errorHandler:o,value:s}=e;if(e.value=null,e.callback=bi,e.errorHandler)o(r,s);n.call(e.context,r,i),e.release(e)}}function XXe(e,t,r){if(typeof e==="function")r=t,t=e,e=null;function i(u,p){t.call(this,u).then(function(d){p(null,d)},p)}var n=Pue(e,i,r),o=n.push,s=n.unshift;return n.push=a,n.unshift=c,n.drained=l,n;function a(u){var p=new Promise(function(d,f){o(u,function(m,g){if(m){f(m);return}d(g)})});return p.catch(bi),p}function c(u){var p=new Promise(function(d,f){s(u,function(m,g){if(m){f(m);return}d(g)})});return p.catch(bi),p}function l(){var u=new Promise(function(p){process.nextTick(function(){if(n.idle())p();else{var d=n.drain;n.drain=function(){if(typeof d==="function")d();p(),n.drain=d}}})});return u}}K2.exports=Pue;K2.exports.promise=XXe});var R0=O(function(Eue){Object.defineProperty(Eue,"__esModule",{value:!0});Eue.joinPathSegments=Eue.replacePathSegmentSeparator=Eue.isAppliedFilter=Eue.isFatalError=void 0;function QXe(e,t){if(e.errorFilter===null)return!0;return!e.errorFilter(t)}Eue.isFatalError=QXe;function eQe(e,t){return e===null||e(t)}Eue.isAppliedFilter=eQe;function tQe(e,t){return e.split(/[/\\]/).join(t)}Eue.replacePathSegmentSeparator=tQe;function rQe(e,t,r){if(e==="")return t;if(e.endsWith(r))return e+t;return e+r+t}Eue.joinPathSegments=rQe});var J2=O(function(Aue){Object.defineProperty(Aue,"__esModule",{value:!0});var sQe=R0();class Iue{constructor(e,t){this._root=e,this._settings=t,this._root=sQe.replacePathSegmentSeparator(e,t.pathSegmentSeparator)}}Aue.default=Iue});var Y2=O(function(Tue){Object.defineProperty(Tue,"__esModule",{value:!0});var cQe=Le("events"),lQe=E0(),uQe=Cue(),I0=R0(),pQe=J2();class Oue extends pQe.default{constructor(e,t){super(e,t);this._settings=t,this._scandir=lQe.scandir,this._emitter=new cQe.EventEmitter,this._queue=uQe(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{if(!this._isFatalError)this._emitter.emit("end")}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw Error("The reader is already destroyed");this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(e){this._emitter.on("entry",e)}onError(e){this._emitter.once("error",e)}onEnd(e){this._emitter.once("end",e)}_pushToQueue(e,t){let r={directory:e,base:t};this._queue.push(r,(i)=>{if(i!==null)this._handleError(i)})}_worker(e,t){this._scandir(e.directory,this._settings.fsScandirSettings,(r,i)=>{if(r!==null){t(r,void 0);return}for(let n of i)this._handleEntry(n,e.base);t(null,void 0)})}_handleError(e){if(this._isDestroyed||!I0.isFatalError(this._settings,e))return;this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit("error",e)}_handleEntry(e,t){if(this._isDestroyed||this._isFatalError)return;let r=e.path;if(t!==void 0)e.path=I0.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator);if(I0.isAppliedFilter(this._settings.entryFilter,e))this._emitEntry(e);if(e.dirent.isDirectory()&&I0.isAppliedFilter(this._settings.deepFilter,e))this._pushToQueue(r,t===void 0?void 0:e.path)}_emitEntry(e){this._emitter.emit("entry",e)}}Tue.default=Oue});var Nue=O(function(Mue){Object.defineProperty(Mue,"__esModule",{value:!0});var fQe=Y2();class Due{constructor(e,t){this._root=e,this._settings=t,this._reader=new fQe.default(this._root,this._settings),this._storage=[]}read(e){this._reader.onError((t)=>{mQe(e,t)}),this._reader.onEntry((t)=>{this._storage.push(t)}),this._reader.onEnd(()=>{gQe(e,this._storage)}),this._reader.read()}}Mue.default=Due;function mQe(e,t){e(t)}function gQe(e,t){e(null,t)}});var zue=O(function(jue){Object.defineProperty(jue,"__esModule",{value:!0});var yQe=Le("stream"),vQe=Y2();class Fue{constructor(e,t){this._root=e,this._settings=t,this._reader=new vQe.default(this._root,this._settings),this._stream=new yQe.Readable({objectMode:!0,read:()=>{},destroy:()=>{if(!this._reader.isDestroyed)this._reader.destroy()}})}read(){return this._reader.onError((e)=>{this._stream.emit("error",e)}),this._reader.onEntry((e)=>{this._stream.push(e)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}}jue.default=Fue});var Bue=O(function(Lue){Object.defineProperty(Lue,"__esModule",{value:!0});var bQe=E0(),A0=R0(),kQe=J2();class Uue extends kQe.default{constructor(){super(...arguments);this._scandir=bQe.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(e,t){this._queue.add({directory:e,base:t})}_handleQueue(){for(let e of this._queue.values())this._handleDirectory(e.directory,e.base)}_handleDirectory(e,t){try{let r=this._scandir(e,this._settings.fsScandirSettings);for(let i of r)this._handleEntry(i,t)}catch(r){this._handleError(r)}}_handleError(e){if(!A0.isFatalError(this._settings,e))return;throw e}_handleEntry(e,t){let r=e.path;if(t!==void 0)e.path=A0.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator);if(A0.isAppliedFilter(this._settings.entryFilter,e))this._pushToStorage(e);if(e.dirent.isDirectory()&&A0.isAppliedFilter(this._settings.deepFilter,e))this._pushToQueue(r,t===void 0?void 0:e.path)}_pushToStorage(e){this._storage.push(e)}}Lue.default=Uue});var Hue=O(function(Vue){Object.defineProperty(Vue,"__esModule",{value:!0});var xQe=Bue();class que{constructor(e,t){this._root=e,this._settings=t,this._reader=new xQe.default(this._root,this._settings)}read(){return this._reader.read()}}Vue.default=que});var Zue=O(function(Gue){Object.defineProperty(Gue,"__esModule",{value:!0});var _Qe=Le("path"),PQe=E0();class Wue{constructor(e={}){this._options=e,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,Number.POSITIVE_INFINITY),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,_Qe.sep),this.fsScandirSettings=new PQe.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e!==null&&e!==void 0?e:t}}Gue.default=Wue});var T0=O(function(Jue){Object.defineProperty(Jue,"__esModule",{value:!0});Jue.Settings=Jue.walkStream=Jue.walkSync=Jue.walk=void 0;var Kue=Nue(),EQe=zue(),RQe=Hue(),X2=Zue();Jue.Settings=X2.default;function IQe(e,t,r){if(typeof t==="function"){new Kue.default(e,O0()).read(t);return}new Kue.default(e,O0(t)).read(r)}Jue.walk=IQe;function AQe(e,t){let r=O0(t);return new RQe.default(e,r).read()}Jue.walkSync=AQe;function OQe(e,t){let r=O0(t);return new EQe.default(e,r).read()}Jue.walkStream=OQe;function O0(e={}){if(e instanceof X2.default)return e;return new X2.default(e)}});var D0=O(function(epe){Object.defineProperty(epe,"__esModule",{value:!0});var NQe=Le("path"),FQe=np(),Xue=Aa();class Que{constructor(e){this._settings=e,this._fsStatSettings=new FQe.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return NQe.resolve(this._settings.cwd,e)}_makeEntry(e,t){let r={name:t,path:t,dirent:Xue.fs.createDirentFromStats(t,e)};if(this._settings.stats)r.stats=e;return r}_isFatalError(e){return!Xue.errno.isEnoentCodeError(e)&&!this._settings.suppressErrors}}epe.default=Que});var Q2=O(function(rpe){Object.defineProperty(rpe,"__esModule",{value:!0});var zQe=Le("stream"),UQe=np(),LQe=T0(),BQe=D0();class tpe extends BQe.default{constructor(){super(...arguments);this._walkStream=LQe.walkStream,this._stat=UQe.stat}dynamic(e,t){return this._walkStream(e,t)}static(e,t){let r=e.map(this._getFullEntryPath,this),i=new zQe.PassThrough({objectMode:!0});i._write=(n,o,s)=>this._getEntry(r[n],e[n],t).then((a)=>{if(a!==null&&t.entryFilter(a))i.push(a);if(n===r.length-1)i.end();s()}).catch(s);for(let n=0;n<r.length;n++)i.write(n);return i}_getEntry(e,t,r){return this._getStat(e).then((i)=>this._makeEntry(i,t)).catch((i)=>{if(r.errorFilter(i))return null;throw i})}_getStat(e){return new Promise((t,r)=>{this._stat(e,this._fsStatSettings,(i,n)=>i===null?t(n):r(i))})}}rpe.default=tpe});var ope=O(function(ipe){Object.defineProperty(ipe,"__esModule",{value:!0});var VQe=T0(),HQe=D0(),WQe=Q2();class npe extends HQe.default{constructor(){super(...arguments);this._walkAsync=VQe.walk,this._readerStream=new WQe.default(this._settings)}dynamic(e,t){return new Promise((r,i)=>{this._walkAsync(e,t,(n,o)=>{if(n===null)r(o);else i(n)})})}async static(e,t){let r=[],i=this._readerStream.static(e,t);return new Promise((n,o)=>{i.once("error",o),i.on("data",(s)=>r.push(s)),i.once("end",()=>n(r))})}}ipe.default=npe});var cpe=O(function(ape){Object.defineProperty(ape,"__esModule",{value:!0});var Vv=Aa();class spe{constructor(e,t,r){this._patterns=e,this._settings=t,this._micromatchOptions=r,this._storage=[],this._fillStorage()}_fillStorage(){for(let e of this._patterns){let t=this._getPatternSegments(e),r=this._splitSegmentsIntoSections(t);this._storage.push({complete:r.length<=1,pattern:e,segments:t,sections:r})}}_getPatternSegments(e){return Vv.pattern.getPatternParts(e,this._micromatchOptions).map((r)=>{if(!Vv.pattern.isDynamicPattern(r,this._settings))return{dynamic:!1,pattern:r};return{dynamic:!0,pattern:r,patternRe:Vv.pattern.makeRe(r,this._micromatchOptions)}})}_splitSegmentsIntoSections(e){return Vv.array.splitWhen(e,(t)=>t.dynamic&&Vv.pattern.hasGlobStar(t.pattern))}}ape.default=spe});var ppe=O(function(upe){Object.defineProperty(upe,"__esModule",{value:!0});var KQe=cpe();class lpe extends KQe.default{match(e){let t=e.split("/"),r=t.length,i=this._storage.filter((n)=>!n.complete||n.segments.length>r);for(let n of i){let o=n.sections[0];if(!n.complete&&r>o.length)return!0;if(t.every((a,c)=>{let l=n.segments[c];if(l.dynamic&&l.patternRe.test(a))return!0;if(!l.dynamic&&l.pattern===a)return!0;return!1}))return!0}return!1}}upe.default=lpe});var mpe=O(function(fpe){Object.defineProperty(fpe,"__esModule",{value:!0});var M0=Aa(),YQe=ppe();class dpe{constructor(e,t){this._settings=e,this._micromatchOptions=t}getFilter(e,t,r){let i=this._getMatcher(t),n=this._getNegativePatternsRe(r);return(o)=>this._filter(e,o,i,n)}_getMatcher(e){return new YQe.default(e,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){let t=e.filter(M0.pattern.isAffectDepthOfReadingPattern);return M0.pattern.convertPatternsToRe(t,this._micromatchOptions)}_filter(e,t,r,i){if(this._isSkippedByDeep(e,t.path))return!1;if(this._isSkippedSymbolicLink(t))return!1;let n=M0.path.removeLeadingDotSegment(t.path);if(this._isSkippedByPositivePatterns(n,r))return!1;return this._isSkippedByNegativePatterns(n,i)}_isSkippedByDeep(e,t){if(this._settings.deep===1/0)return!1;return this._getEntryLevel(e,t)>=this._settings.deep}_getEntryLevel(e,t){let r=t.split("/").length;if(e==="")return r;let i=e.split("/").length;return r-i}_isSkippedSymbolicLink(e){return!this._settings.followSymbolicLinks&&e.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(e,t){return!this._settings.baseNameMatch&&!t.match(e)}_isSkippedByNegativePatterns(e,t){return!M0.pattern.matchAny(e,t)}}fpe.default=dpe});var ype=O(function(hpe){Object.defineProperty(hpe,"__esModule",{value:!0});var Xc=Aa();class gpe{constructor(e,t){this._settings=e,this._micromatchOptions=t,this.index=new Map}getFilter(e,t){let[r,i]=Xc.pattern.partitionAbsoluteAndRelative(t),n={positive:{all:Xc.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:Xc.pattern.convertPatternsToRe(r,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:Xc.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return(o)=>this._filter(o,n)}_filter(e,t){let r=Xc.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(r))return!1;if(this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;let i=this._isMatchToPatternsSet(r,t,e.dirent.isDirectory());if(this._settings.unique&&i)this._createIndexRecord(r);return i}_isDuplicateEntry(e){return this.index.has(e)}_createIndexRecord(e){this.index.set(e,void 0)}_onlyFileFilter(e){return this._settings.onlyFiles&&!e.dirent.isFile()}_onlyDirectoryFilter(e){return this._settings.onlyDirectories&&!e.dirent.isDirectory()}_isMatchToPatternsSet(e,t,r){if(!this._isMatchToPatterns(e,t.positive.all,r))return!1;if(this._isMatchToPatterns(e,t.negative.relative,r))return!1;if(this._isMatchToAbsoluteNegative(e,t.negative.absolute,r))return!1;return!0}_isMatchToAbsoluteNegative(e,t,r){if(t.length===0)return!1;let i=Xc.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(i,t,r)}_isMatchToPatterns(e,t,r){if(t.length===0)return!1;let i=Xc.pattern.matchAny(e,t);if(!i&&r)return Xc.pattern.matchAny(e+"/",t);return i}}hpe.default=gpe});var bpe=O(function(wpe){Object.defineProperty(wpe,"__esModule",{value:!0});var eet=Aa();class vpe{constructor(e){this._settings=e}getFilter(){return(e)=>this._isNonFatalError(e)}_isNonFatalError(e){return eet.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}wpe.default=vpe});var $pe=O(function(xpe){Object.defineProperty(xpe,"__esModule",{value:!0});var kpe=Aa();class Spe{constructor(e){this._settings=e}getTransformer(){return(e)=>this._transform(e)}_transform(e){let t=e.path;if(this._settings.absolute)t=kpe.path.makeAbsolute(this._settings.cwd,t),t=kpe.path.unixify(t);if(this._settings.markDirectories&&e.dirent.isDirectory())t+="/";if(!this._settings.objectMode)return t;return Object.assign(Object.assign({},e),{path:t})}}xpe.default=Spe});var N0=O(function(Ppe){Object.defineProperty(Ppe,"__esModule",{value:!0});var net=Le("path"),iet=mpe(),oet=ype(),set=bpe(),aet=$pe();class _pe{constructor(e){this._settings=e,this.errorFilter=new set.default(this._settings),this.entryFilter=new oet.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new iet.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new aet.default(this._settings)}_getRootDirectory(e){return net.resolve(this._settings.cwd,e.base)}_getReaderOptions(e){let t=e.base==="."?"":e.base;return{basePath:t,pathSegmentSeparator:"/",concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(t,e.positive,e.negative),entryFilter:this.entryFilter.getFilter(e.positive,e.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}}Ppe.default=_pe});var Rpe=O(function(Epe){Object.defineProperty(Epe,"__esModule",{value:!0});var uet=ope(),pet=N0();class Cpe extends pet.default{constructor(){super(...arguments);this._reader=new uet.default(this._settings)}async read(e){let t=this._getRootDirectory(e),r=this._getReaderOptions(e);return(await this.api(t,e,r)).map((n)=>r.transform(n))}api(e,t,r){if(t.dynamic)return this._reader.dynamic(e,r);return this._reader.static(t.patterns,r)}}Epe.default=Cpe});var Ope=O(function(Ape){Object.defineProperty(Ape,"__esModule",{value:!0});var fet=Le("stream"),met=Q2(),get=N0();class Ipe extends get.default{constructor(){super(...arguments);this._reader=new met.default(this._settings)}read(e){let t=this._getRootDirectory(e),r=this._getReaderOptions(e),i=this.api(t,e,r),n=new fet.Readable({objectMode:!0,read:()=>{}});return i.once("error",(o)=>n.emit("error",o)).on("data",(o)=>n.emit("data",r.transform(o))).once("end",()=>n.emit("end")),n.once("close",()=>i.destroy()),n}api(e,t,r){if(t.dynamic)return this._reader.dynamic(e,r);return this._reader.static(t.patterns,r)}}Ape.default=Ipe});var Mpe=O(function(Dpe){Object.defineProperty(Dpe,"__esModule",{value:!0});var yet=np(),vet=T0(),wet=D0();class Tpe extends wet.default{constructor(){super(...arguments);this._walkSync=vet.walkSync,this._statSync=yet.statSync}dynamic(e,t){return this._walkSync(e,t)}static(e,t){let r=[];for(let i of e){let n=this._getFullEntryPath(i),o=this._getEntry(n,i,t);if(o===null||!t.entryFilter(o))continue;r.push(o)}return r}_getEntry(e,t,r){try{let i=this._getStat(e);return this._makeEntry(i,t)}catch(i){if(r.errorFilter(i))return null;throw i}}_getStat(e){return this._statSync(e,this._fsStatSettings)}}Dpe.default=Tpe});var jpe=O(function(Fpe){Object.defineProperty(Fpe,"__esModule",{value:!0});var ket=Mpe(),xet=N0();class Npe extends xet.default{constructor(){super(...arguments);this._reader=new ket.default(this._settings)}read(e){let t=this._getRootDirectory(e),r=this._getReaderOptions(e);return this.api(t,e,r).map(r.transform)}api(e,t,r){if(t.dynamic)return this._reader.dynamic(e,r);return this._reader.static(t.patterns,r)}}Fpe.default=Npe});var Lpe=O(function(Upe){Object.defineProperty(Upe,"__esModule",{value:!0});Upe.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;var um=Le("fs"),_et=Le("os"),Pet=Math.max(_et.cpus().length,1);Upe.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:um.lstat,lstatSync:um.lstatSync,stat:um.stat,statSync:um.statSync,readdir:um.readdir,readdirSync:um.readdirSync};class zpe{constructor(e={}){if(this._options=e,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,Pet),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories)this.onlyFiles=!1;if(this.stats)this.objectMode=!0;this.ignore=[].concat(this.ignore)}_getValue(e,t){return e===void 0?t:e}_getFileSystemMethods(e={}){return Object.assign(Object.assign({},Upe.DEFAULT_FILE_SYSTEM_ADAPTER),e)}}Upe.default=zpe});var Vpe=O(function(S1t,qpe){var Bpe=ble(),Eet=Rpe(),Ret=Ope(),Iet=jpe(),t4=Lpe(),wo=Aa();async function r4(e,t){Yo(e);let r=n4(e,Eet.default,t),i=await Promise.all(r);return wo.array.flatten(i)}(function(e){e.glob=e,e.globSync=t,e.globStream=r,e.async=e;function t(l,u){Yo(l);let p=n4(l,Iet.default,u);return wo.array.flatten(p)}e.sync=t;function r(l,u){Yo(l);let p=n4(l,Ret.default,u);return wo.stream.merge(p)}e.stream=r;function i(l,u){Yo(l);let p=[].concat(l),d=new t4.default(u);return Bpe.generate(p,d)}e.generateTasks=i;function n(l,u){Yo(l);let p=new t4.default(u);return wo.pattern.isDynamicPattern(l,p)}e.isDynamicPattern=n;function o(l){return Yo(l),wo.path.escape(l)}e.escapePath=o;function s(l){return Yo(l),wo.path.convertPathToPattern(l)}e.convertPathToPattern=s;let a;(function(l){function u(d){return Yo(d),wo.path.escapePosixPath(d)}l.escapePath=u;function p(d){return Yo(d),wo.path.convertPosixPathToPattern(d)}l.convertPathToPattern=p})(a=e.posix||(e.posix={}));let c;(function(l){function u(d){return Yo(d),wo.path.escapeWindowsPath(d)}l.escapePath=u;function p(d){return Yo(d),wo.path.convertWindowsPathToPattern(d)}l.convertPathToPattern=p})(c=e.win32||(e.win32={}))})(r4||(r4={}));function n4(e,t,r){let i=[].concat(e),n=new t4.default(r),o=Bpe.generate(i,n),s=new t(n);return o.map(s.read,s)}function Yo(e){if(![].concat(e).every((i)=>wo.string.isString(i)&&!wo.string.isEmpty(i)))throw TypeError("Patterns must be a string (non empty) or an array of strings")}qpe.exports=r4});import{join as Hpe}from"node:path";function Hv(e){let t=e.startsWith("!")?e.slice(1):e;return F0.default.isDynamicPattern(t)}function Aet(e){return e.startsWith("!")}async function Wpe(e,t){let r=new Map;for(let i of t)if(Aet(i)){let n=i.slice(1);if(Hv(n)){let o=await F0.default(n,{cwd:e,onlyFiles:!0,dot:!0});for(let s of o)r.delete(s)}else r.delete(n)}else if(Hv(i)){let n=await F0.default(i,{cwd:e,onlyFiles:!0,dot:!0});for(let o of n)r.set(o,{sourcePath:Hpe(e,o),relativePath:o})}else r.set(i,{sourcePath:Hpe(e,i),relativePath:i});return Array.from(r.values())}var F0;var Gpe=R(()=>{F0=Nt(Vpe(),1)});import{dirname as Oet,join as Tet,normalize as Det,isAbsolute as Met}from"node:path/posix";function Fet(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mailto:")||Met(e)}function Kpe(e,t,r){if(Fet(e))return e;if(!e.startsWith("../"))return e;let i=Det(e),n=Oet(t),o=n==="."?0:n.split("/").filter(Boolean).length,s=i.split("/").filter((d)=>d==="..").length;if(!(s>o))return e;let c=s-(o+1),p=i.split("/").slice(s).join("/");if(c>0)return e;for(let d of Net)if(p.startsWith(d.pattern)){let f=d.transform(p,r);return"../".repeat(o+1)+f}return e}function i4(e,t,r){let i=e;return i=i.replace(Zpe.fileReference,(n,o)=>`#file:${Kpe(o,t,r)}`),i=i.replace(Zpe.markdownLink,(n,o,s)=>{if(s.startsWith("#"))return n;let a=Kpe(s,t,r);return`[${o}](${a})`}),i}var Net,Zpe;var Jpe=R(()=>{Net=[{pattern:"skills/",transform:(e,t)=>{let n=e.substring(7).split("/"),o=n[0]??"",s=n.slice(1).join("/"),a=t.skillNameMap?.get(o)??o;return Tet(t.workspaceSkillsPath,a,s)}}],Zpe={fileReference:/#file:([^\s\])"'`]+)/g,markdownLink:/\[([^\]]*)\]\(([^)]+)\)/g}});import{symlink as jet,lstat as zet,readlink as Uet,rm as Let,mkdir as Bet,unlink as Ype}from"node:fs/promises";import{dirname as s4,relative as qet,resolve as j0}from"node:path";import{platform as Vet}from"node:os";import{realpath as Het}from"node:fs/promises";async function o4(e){let t=j0(e),r=s4(t),i=t.substring(r.length+1);try{return`${await Het(r)}/${i}`}catch{return t}}function Wet(e,t){return j0(s4(e),t)}async function Xpe(e,t){try{let r=j0(e),i=j0(t);if(r===i)return!0;let n=await o4(e),o=await o4(t);if(n===o)return!0;try{if((await zet(t)).isSymbolicLink()){let p=await Uet(t);if(Wet(t,p)===r)return!0;await Ype(t)}else await Let(t,{recursive:!0})}catch(u){if(u&&typeof u==="object"&&"code"in u&&u.code==="ELOOP")try{await Ype(t)}catch{}}let s=s4(t);await Bet(s,{recursive:!0});let a=await o4(s),c=qet(a,e),l=Vet()==="win32"?"junction":void 0;return await jet(c,t,l),!0}catch{return!1}}var Qpe=()=>{};var ede;var tde=R(()=>{Ac();ede=S.object({name:S.string().min(1,"Skill name is required").max(128,"Skill name too long"),description:S.string().min(1,"Description is required"),"allowed-tools":S.union([S.array(S.string()),S.string().transform((e)=>[e])]).optional(),model:S.string().optional()})});function Bi(e){try{let{data:t}=rde.default(e),r=ede.safeParse(t);return r.success?r.data:null}catch{return null}}var rde;var pm=R(()=>{tde();wf();rde=Nt(d2(),1)});import{existsSync as Oa,lstatSync as Get}from"node:fs";import{readFile as a4,readdir as Zet}from"node:fs/promises";import{basename as nde,join as Qc,relative as Ket,resolve as Jet}from"node:path";async function Yet(e,t){if(Wt(e)){let i=await jf(e,{offline:!0,workspacePath:t});if(!i.success||!i.path)return null;return{path:i.path,pluginName:i.pluginName}}if($e(e)){let i=we(e),n=await Cn(e,{offline:!0,...i?.branch&&{branch:i.branch}});if(!n.success)return null;let o=i?.subpath?Qc(n.cachePath,i.subpath):n.cachePath;return Oa(o)?{path:o}:null}let r=Jet(t,e);return Oa(r)?{path:r}:null}async function Ta(e,t=[]){return ide(e,e,t)}async function dm(e,t=[]){let r=Qc(e,"skills");if(Oa(r))return Ta(r,t);let i=await Ta(e,t);if(i.length>0)return i;let n=Qc(e,"SKILL.md");if(!Oa(n))return[];let o=await a4(n,"utf-8"),a=Bi(o)?.name??nde(e);return[{name:a,subpath:a,skillPath:e}]}async function ide(e,t,r){let i;try{i=await Zet(t,{withFileTypes:!0})}catch(o){let s=o&&typeof o==="object"&&"code"in o?String(o.code):void 0;return r.push(`Could not read '${t}'${s?` (${s})`:""} while scanning for skills. If this path looks unexpected (e.g. rooted near a drive root), check ~/.allagents/workspace.yaml for a stale plugin path, or rename ~/.allagents to ~/.allagents.bak and reinstall your plugins to reset it.`),[]}let n=[];for(let o of i){if(!o.isDirectory())continue;let s=Qc(t,o.name);try{if(Get(s).isSymbolicLink())continue}catch{continue}if(Oa(Qc(s,"SKILL.md"))){let a=Ket(e,s).split(/[\\/]/).join("/");n.push({name:o.name,subpath:a,skillPath:s});continue}n.push(...await ide(e,s,r))}return n}async function qr(e=process.cwd()){let t=Qc(e,ee,ie);if(!Oa(t))return[];let r=await a4(t,"utf-8"),i=Ti(r),n=i.version===void 0||i.version<2,o=n?new Set(i.disabledSkills??[]):new Set,s=n&&i.enabledSkills?new Set(i.enabledSkills):null,a=[];for(let c of i.plugins??[]){let l=fe(c),u=await Yet(l,e);if(!u)continue;let p=u.path,d=u.pluginName??Kn(p),f=typeof c==="string"?void 0:c.skills,m=!f&&s&&[...s].some((y)=>y.startsWith(`${d}`)),g=await dm(p),h=f===void 0?"none":Array.isArray(f)?"allowlist":"blocklist";for(let{name:y,subpath:v,skillPath:w}of g){let _=`${d}:${y}`,b=`${d}:${v}`,k;if(f!==void 0)if(Array.isArray(f))k=!f.includes(y)&&!f.includes(v);else k=f.exclude.includes(y)||f.exclude.includes(v);else if(n)k=m?!(s?.has(_)||s?.has(b)):o.has(_)||o.has(b);else k=!1;a.push({name:y,pluginName:d,pluginSource:l,path:w,disabled:k,pluginSkillsMode:h,skillSubpath:v})}}return a}async function ode(e,t=process.cwd()){return(await qr(t)).filter((i)=>i.name===e)}async function Da(e){return(await z0(e)).map((t)=>t.name)}async function z0(e){if(!Oa(e))return[];let t=Qc(e,"skills");if(Oa(t))return Ta(t);let r=await Ta(e);if(r.length>0)return r;let i=Qc(e,"SKILL.md");if(Oa(i)){let n=nde(e);try{let o=await a4(i,"utf-8"),s=Bi(o);if(s?.name)n=s.name}catch{}return[{name:n,subpath:n,skillPath:e}]}return[]}var Ma=R(()=>{ut();it();pr();vf();pm();fn();Sa()});import{existsSync as bo}from"node:fs";import{access as Xet,cp as Wv,mkdir as Na,readFile as Fa,readdir as op,unlink as Qet,writeFile as el}from"node:fs/promises";import{basename as L0,dirname as ip,join as Fe,relative as fm}from"node:path";async function mm(e,t,r=[]){let i=HX(t,r),n="<!-- WORKSPACE-RULES:START -->",o="<!-- WORKSPACE-RULES:END -->";if(!bo(e)){await el(e,`${i.trim()}
|
|
485
485
|
`,"utf-8");return}let s=await Fa(e,"utf-8"),a=s.indexOf("<!-- WORKSPACE-RULES:START -->"),c=s.indexOf("<!-- WORKSPACE-RULES:END -->");if(a!==-1&&c!==-1&&c>a){let l=s.substring(0,a),u=s.substring(c+28);await el(e,l+i.trim()+u,"utf-8")}else await el(e,s+i,"utf-8")}function qi(e,t,r){if(!r||r.length===0)return!1;let i=fm(e,t).replaceAll("\\","/");return dde.default.isMatch(i,r)}async function fde(e,t,r,i){await Na(t,{recursive:!0});let n=await op(e,{withFileTypes:!0});for(let o of n){let s=Fe(e,o.name),a=Fe(t,o.name);if(qi(r,s,i))continue;if(o.isDirectory())await fde(s,a,r,i);else await Wv(s,a)}}async function mde(e,t,r,i=""){let n=Fe(e,i),o=await op(n,{withFileTypes:!0});o.sort((a,c)=>a.name.localeCompare(c.name));let s=[];for(let a of o){let c=Fe(i,a.name),l=Fe(e,c);if(qi(t,l,r))continue;if(a.isDirectory())s.push(...await mde(e,t,r,c));else s.push(c)}return s}function Gv(e,t){let r=t?.clientMappings?t.clientMappings[e]:lr[e];if(!r)throw Error(`Client '${e}' has no mapping for this scope`);return r}async function ett(e,t,r,i={}){let{dryRun:n=!1}=i,o=Gv(r,i),s=[];if(!o.commandsPath)return s;let a=Fe(e,"commands");if(!bo(a))return s;let c=Lr(t,o.commandsPath);try{await Ps(i.writeRoot??t,c)}catch(d){return[{source:a,destination:c,action:"failed",error:d instanceof Error?d.message:"Unsafe destination",client:r,artifactType:"command"}]}if(!n)await Na(c,{recursive:!0});let p=(await op(a)).filter((d)=>d.endsWith(".md")).filter((d)=>!qi(e,Fe(a,d),i.exclude)).map(async(d)=>{let f=Fe(a,d),m=Fe(c,d);if(n)return{source:f,destination:m,action:"copied"};try{let g=await Fa(f,"utf-8");return await el(m,g,"utf-8"),{source:f,destination:m,action:"copied"}}catch(g){return{source:f,destination:m,action:"failed",error:g instanceof Error?g.message:"Unknown error"}}});return Promise.all(p)}async function ttt(e,t,r,i={}){let{dryRun:n=!1,skillNameMap:o,syncMode:s="copy",canonicalSkillsPath:a}=i,c=Gv(r,i),l=[];if(!c.skillsPath)return l;let u=Fe(e,"skills"),p;if(bo(u))p=(await Ta(u)).filter((y)=>!qi(e,y.skillPath,i.exclude)).map((y)=>({name:y.name,subpath:y.subpath,sourcePath:y.skillPath,isRootLevel:!1}));else{let h=(await Ta(e)).filter((y)=>!qi(e,y.skillPath,i.exclude)).map((y)=>({name:y.name,subpath:y.subpath,sourcePath:y.skillPath,isRootLevel:!1}));if(h.length>0)p=h;else{let y=Fe(e,"SKILL.md");if(bo(y)){let v=await Fa(y,"utf-8"),_=Bi(v)?.name??L0(e);p=[{name:_,subpath:_,sourcePath:e,isRootLevel:!0}]}else return l}}if(o)p=p.filter((h)=>o.has(h.name)||o.has(h.subpath));if(p.length===0)return l;let d=Lr(t,c.skillsPath),f=i.writeRoot??t;if(!n)try{await Ps(f,d),await Na(d,{recursive:!0})}catch(h){return p.map((y)=>({source:y.sourcePath,destination:Fe(d,y.name),action:"failed",error:h instanceof Error?h.message:"Unsafe destination",client:r,artifactType:"skill"}))}let m=s==="symlink"&&!Ny(r)&&a,g=p.map(async(h)=>{let y=o?.get(h.name)??h.name,v=Fe(d,y);if(n)return{source:h.sourcePath,destination:v,action:"copied",client:r,artifactType:"skill"};try{await Ps(f,v)}catch(w){return{source:h.sourcePath,destination:v,action:"failed",error:w instanceof Error?w.message:"Unsafe destination",client:r,artifactType:"skill"}}if(m){let w=Fe(t,a,y);if(await Xpe(w,v))return{source:w,destination:v,action:"copied",client:r,artifactType:"skill"}}try{if(h.isRootLevel)await Na(v,{recursive:!0}),await Wv(Fe(h.sourcePath,"SKILL.md"),Fe(v,"SKILL.md"));else if(i.exclude&&i.exclude.length>0)await fde(h.sourcePath,v,e,i.exclude);else await Wv(h.sourcePath,v,{recursive:!0});return{source:h.sourcePath,destination:v,action:"copied",client:r,artifactType:"skill"}}catch(w){return{source:h.sourcePath,destination:v,action:"failed",error:w instanceof Error?w.message:"Unknown error",client:r,artifactType:"skill"}}});return Promise.all(g)}async function Zv(e,t,r,i,n,o,s){let a=Fe(e,"skills"),c=[],l=!o&&n&&i&&[...n].some((f)=>f.startsWith(`${i}:`)),u;if(bo(a))u=(await Ta(a,c)).map((m)=>({name:m.name,subpath:m.subpath,path:m.skillPath}));else{let f=(await Ta(e,c)).map((m)=>({name:m.name,subpath:m.subpath,path:m.skillPath}));if(f.length>0)u=f;else{let m=Fe(e,"SKILL.md");if(bo(m)){let g=await Fa(m,"utf-8"),y=Bi(g)?.name??L0(e);u=[{name:y,subpath:y,path:e}]}else u=[]}}let p=(f,m)=>m.includes(f.name)||m.includes(f.subpath),d;if(o!==void 0)if(Array.isArray(o))d=u.filter((f)=>p(f,o));else d=u.filter((f)=>!p(f,o.exclude));else if(i)if(l)d=u.filter((f)=>n?.has(`${i}:${f.name}`)||n?.has(`${i}:${f.subpath}`));else if(r)d=u.filter((f)=>!r.has(`${i}:${f.name}`)&&!r.has(`${i}:${f.subpath}`));else d=u;else d=u;if(s&&c.length>0)s.push(...c.map((f)=>`Plugin '${t}': ${f}`));return d.map((f)=>({folderName:f.name,skillPath:f.path,pluginPath:e,pluginSource:t}))}async function rtt(e,t,r,i={}){let{dryRun:n=!1}=i,o=Gv(r,i);if(!o.hooksPath)return[];let s=Fe(e,"hooks");if(!bo(s))return[];let a=Lr(t,o.hooksPath),c=o.hooksPath===".github/hooks/"&&bo(Fe(s,"hooks.json"))?[...i.exclude??[],"hooks/hooks.json"]:i.exclude,l;try{l=await mde(s,e,c)}catch(f){return[{source:s,destination:a,action:"failed",error:f instanceof Error?f.message:"Unknown error",client:r,artifactType:"hook"}]}let u=i.writeRoot??t;try{await Ps(u,a)}catch(f){return[{source:s,destination:a,action:"failed",error:f instanceof Error?f.message:"Unsafe destination",client:r,artifactType:"hook"}]}let p=[],d=new Set;for(let f of l){let m=Fe(s,f),g=Fe(a,f);if(n){p.push({source:m,destination:g,action:"copied"});continue}try{await Ps(u,g);let h=ip(g);if(!d.has(h))await Na(h,{recursive:!0}),d.add(h);await Wv(m,g),p.push({source:m,destination:g,action:"copied"})}catch(h){p.push({source:m,destination:g,action:"failed",error:h instanceof Error?h.message:"Unknown error",client:r,artifactType:"hook"})}}return p}function sde(e,t){return fm(e,t).replaceAll("\\","/")}async function ade(e,t){if(t.has(e))return t.get(e);let r;try{let i=pde.default(await Fa(e,"utf-8")).data?.name;if(typeof i==="string"&&i.length>0)r=i}catch{}return t.set(e,r),r}function cde(e,t){let r=`${t.route}\x00${t.source}\x00${t.destination}`,i=e.get(r);if(i){let n=t.clients.filter((o)=>!i.clients.includes(o));if(n.length>0)e.set(r,{...i,clients:[...i.clients,...n]});return}e.set(r,t)}async function lde(e){if(!bo(e))return{files:[]};try{return{files:(await op(e,{withFileTypes:!0})).filter((t)=>!t.isDirectory()&&t.name.endsWith(".md")).sort((t,r)=>t.name.localeCompare(r.name))}}catch(t){return{files:[],error:t instanceof Error?t.message:"Unknown error"}}}async function B0(e,t,r=lr){let i=[],n=[],o=[],s=new Map,a=new Map,c=new Map,l=e.map((u,p)=>({plugin:u,order:p})).sort((u,p)=>u.plugin.configurationIndex-p.plugin.configurationIndex||u.order-p.order);for(let{plugin:u}of l){let p=bu([...u.clients],r),d=new Map,f=u.fileArtifacts?.agents??!0,m=u.fileArtifacts?.github??!0,g=u.clients.map((w)=>p[w]?.agentsPath).find((w)=>w!==void 0);if(f&&g){let w=Fe(u.pluginPath,"agents"),_=await lde(w);if(_.error)o.push({configurationIndex:u.configurationIndex,plugin:u.plugin,source:w,destination:Fe(t,g),error:_.error});for(let b of _.files){let k=Fe(w,b.name);if(qi(u.pluginPath,k,u.exclude))continue;let I=await ade(k,c);for(let E of u.clients){let P=p[E]?.agentsPath;if(!P)continue;let A=Fe(Lr(t,P),b.name);cde(d,{configurationIndex:u.configurationIndex,plugin:u.plugin,pluginPath:u.pluginPath,source:k,destination:A,workspaceRelativeDestination:sde(t,A),route:"portable",...I&&{logicalName:I},clients:[E]})}}}let h=u.clients.map((w)=>p[w]?.githubPath).find((w)=>w!==void 0);if(m&&h){let w=Fe(u.pluginPath,".github","agents"),_=await lde(w);if(_.error)o.push({configurationIndex:u.configurationIndex,plugin:u.plugin,source:w,destination:Fe(t,h,"agents"),error:_.error});for(let b of _.files){let k=Fe(w,b.name);if(qi(u.pluginPath,k,u.exclude))continue;let I=await ade(k,c);for(let E of u.clients){let P=p[E]?.githubPath;if(!P)continue;let A=Fe(t,P,"agents",b.name);cde(d,{configurationIndex:u.configurationIndex,plugin:u.plugin,pluginPath:u.pluginPath,source:k,destination:A,workspaceRelativeDestination:sde(t,A),route:"github",...I&&{logicalName:I},clients:[E]})}}}let y=new Map;for(let w of d.values()){let _=y.get(w.destination)??[];_.push(w),y.set(w.destination,_)}let v=[];for(let w of y.values()){let _=w.find((I)=>I.route==="github")??w[0];if(!_)continue;let b=[...new Set(w.flatMap((I)=>I.clients))],k={..._,clients:b};v.push(k);for(let I of w)if(I!==_)n.push({reason:"destination",winner:k,loser:I})}for(let w of v){let _=s.get(w.destination),b=w.logicalName?`${ip(w.destination)}\x00${w.logicalName}`:void 0,k=b?a.get(b):void 0,I=_&&_.configurationIndex!==w.configurationIndex?_:void 0,E=k&&k.configurationIndex!==w.configurationIndex?k:void 0,P=I??E;if(P){n.push({reason:_===P?"destination":"logical-name",winner:P,loser:w});continue}if(i.push(w),!_)s.set(w.destination,w);if(b&&!k)a.set(b,w)}}return{outputs:i,conflicts:n,failures:o}}async function gde(e,t,r={}){let i=new Map(t.filter((s)=>s.action==="copied").map((s)=>[`${s.source}\x00${s.destination}`,s])),n=new Map;for(let s of e.outputs){if(!s.logicalName)continue;let a=`${ip(s.destination)}\x00${s.logicalName}`,c=n.get(a)??{portable:[],github:[]};c[s.route].push(s),n.set(a,c)}let o=[];for(let s of n.values()){let a=s.github.find((c)=>c.destination.endsWith(".agent.md")&&i.has(`${c.source}\x00${c.destination}`));if(!a)continue;for(let c of s.portable){let l=c.logicalName,u=i.get(`${c.source}\x00${c.destination}`);if(c.destination.endsWith(".agent.md"))continue;if(!l||c.configurationIndex!==a.configurationIndex||!u)continue;if(!r.dryRun)try{await Qet(c.destination)}catch(p){let d=p instanceof Error?p.message:"Unknown error";r.onWarning?.(`Could not dedupe agent '${l}': failed to remove ${c.workspaceRelativeDestination}: ${d}`);continue}u.action="deduped",o.push({name:l,removedPath:c.workspaceRelativeDestination,keptPath:a.workspaceRelativeDestination})}}return o}function c4(e){return e.githubPath!==".github/"}function ntt(e,t){let r=[...t??[]];if(r.push(".github/agents/*.md",".github/agents/.*.md"),!c4(e))r.push(".github/plugin");if(c4(e))r.push(".github/hooks");return r.length>0?r:void 0}function ude(e){return typeof e==="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}async function hde(e,t,r,i={}){let n={found:[]},o=Gv(r,i);if(i.dryRun||!o.githubPath||!c4(o))return n;let s=Fe(Lr(t,o.githubPath),"hooks"),a=new Set;return await Promise.all(e.map(async({pluginPath:l,exclude:u})=>{let p=Fe(l,".github","hooks");async function d(f){let m;try{m=await op(f,{withFileTypes:!0})}catch(g){if(ude(g))return;throw g}await Promise.all(m.map(async(g)=>{let h=Fe(f,g.name);if(qi(l,h,u))return;if(g.isDirectory())return d(h);let y=fm(p,h);a.add(y)}))}await d(p)})),{found:(await Promise.all([...a].sort().map(async(l)=>{let u=Fe(s,l);try{return await Xet(u),u}catch(p){return ude(p)?void 0:u}}))).filter((l)=>l!==void 0)}}function yde(e,t,r){return!r.isDirectory()&&fm(e,t).replaceAll("\\","/")===".github/agents"}async function vde(e,t,r,i,n,o,s){await Na(t,{recursive:!0});let a=await op(e,{withFileTypes:!0});for(let c of a){let l=Fe(e,c.name),u=Fe(t,c.name);if(yde(i,l,c))continue;if(qi(i,l,s))continue;if(c.isDirectory())await vde(l,u,r,i,n,o,s);else{let p=fm(r,l).replaceAll("\\","/");if(c.name.endsWith(".md")||c.name.endsWith(".markdown")){let f=await Fa(l,"utf-8");f=i4(f,p,{...o&&{skillNameMap:o},workspaceSkillsPath:n}),await el(u,f,"utf-8")}else await Wv(l,u)}}}async function wde(e,t,r){for(let i of await op(e,{withFileTypes:!0})){let n=Fe(e,i.name);if(yde(t,n,i))continue;if(qi(t,n,r))continue;if(!i.isDirectory())return!0;if(await wde(n,t,r))return!0}return!1}async function l4(e,t){return Promise.all(e.map(async(r)=>{let i=r.clients[0];try{await Ps(t.writeRoot??ip(r.destination),r.destination)}catch(n){return{source:r.source,destination:r.destination,action:"failed",error:n instanceof Error?n.message:"Unsafe destination",...i&&{client:i},artifactType:"agent"}}if(t.dryRun)return{source:r.source,destination:r.destination,action:"copied",...i&&{client:i},artifactType:"agent"};try{await Na(ip(r.destination),{recursive:!0});let n=await Fa(r.source,"utf-8");if(r.route==="github"){let o=fm(Fe(r.pluginPath,".github"),r.source).replaceAll("\\","/"),s=i?t.clientMappings[i]?.skillsPath??"":"";n=i4(n,o,{...t.skillNameMap&&{skillNameMap:t.skillNameMap},workspaceSkillsPath:s})}return await el(r.destination,n,"utf-8"),{source:r.source,destination:r.destination,action:"copied",...i&&{client:i},artifactType:"agent"}}catch(n){return{source:r.source,destination:r.destination,action:"failed",error:n instanceof Error?n.message:"Unknown error",...i&&{client:i},artifactType:"agent"}}}))}async function itt(e,t,r,i={}){let{dryRun:n=!1,skillNameMap:o}=i,s=Gv(r,i),a=i.clientMappings??lr,c=[];if(!s.githubPath)return i.agentOutputs?l4(i.agentOutputs,{dryRun:n,clientMappings:a,...o&&{skillNameMap:o},...i.writeRoot&&{writeRoot:i.writeRoot}}):c;let l=Fe(e,".github");if(!bo(l))return c;let u=i.agentOutputs,p=[];if(u===void 0){let g=await B0([{configurationIndex:0,plugin:L0(e),pluginPath:e,clients:[r],...i.exclude&&{exclude:i.exclude}}],t,a);u=g.outputs.filter((h)=>h.route==="github"),p=g.failures}let d=Lr(t,s.githubPath),f=ntt(s,i.exclude),m=!1;try{m=await wde(l,e,f)}catch(g){c.push({source:l,destination:d,action:"failed",error:g instanceof Error?g.message:"Unknown error"})}if(m)if(n)c.push({source:l,destination:d,action:"copied"});else try{await vde(l,d,l,e,s.skillsPath,o,f),c.push({source:l,destination:d,action:"copied"})}catch(g){c.push({source:l,destination:d,action:"failed",error:g instanceof Error?g.message:"Unknown error"})}return c.push(...await l4(u,{dryRun:n,clientMappings:a,...o&&{skillNameMap:o},...i.writeRoot&&{writeRoot:i.writeRoot}})),c.push(...p.map((g)=>({source:g.source,destination:g.destination,action:"failed",error:g.error}))),c}async function gm(e,t,r,i={}){let{skillNameMap:n,syncMode:o,canonicalSkillsPath:s,fileArtifacts:a,agentOutputs:c,...l}=i,u=(k)=>a?.[k]??!0,p=i.clientMappings??lr,d=c,f=[],m=[];if(d===void 0){let k=await B0([{configurationIndex:0,plugin:L0(e),pluginPath:e,clients:[r],...l.exclude&&{exclude:l.exclude},...a&&{fileArtifacts:a}}],t,p);d=k.outputs,f=k.conflicts,m=k.failures}let[g,h,y,v]=await Promise.all([u("commands")?ett(e,t,r,l):[],u("skills")?ttt(e,t,r,{...l,...n&&{skillNameMap:n},...o&&{syncMode:o},...s&&{canonicalSkillsPath:s}}):[],u("hooks")?rtt(e,t,r,l):[],l4(d.filter((k)=>k.route==="portable"),{dryRun:l.dryRun??!1,clientMappings:p,...n&&{skillNameMap:n},...l.writeRoot&&{writeRoot:l.writeRoot}})]),w=u("github")?await itt(e,t,r,{...l,...n&&{skillNameMap:n},agentOutputs:d.filter((k)=>k.route==="github")}):[],_=f.map(({loser:k})=>({source:k.source,destination:k.destination,action:"skipped"})),b=m.map((k)=>({source:k.source,destination:k.destination,action:"failed",error:k.error}));return[...g,...h,...y,...v,...w,..._,...b]}function ott(e){if(e.startsWith("https://github.com/")||e.startsWith("http://github.com/")||e.startsWith("github.com/")||e.startsWith("gh:"))return!0;if(!e.startsWith(".")&&!e.startsWith("/")&&e.includes("/")){let t=e.split("/");if(t.length>=3){let r=/^[a-zA-Z0-9_.-]+$/;if(t[0]&&t[1]&&r.test(t[0])&&r.test(t[1]))return!0}}return!1}function stt(e,t,r){if(!ott(e)){if(e.startsWith("/"))return{path:e};if(e.startsWith("../"))return{path:Fe(process.cwd(),e)};if(t)return{path:Fe(t,e)};return{path:Fe(process.cwd(),e)}}let i=iv(e);if(i.type==="github"&&i.owner&&i.repo&&i.filePath){let n=`${i.owner}/${i.repo}`,o=r?.get(n);if(!o)return{path:"",error:`GitHub cache not found for ${n}. Ensure the repo is fetched.`};return{path:Fe(o,i.filePath)}}if(i.type==="github")return{path:"",error:`Invalid GitHub file source: ${e}. Must include path to file (e.g., owner/repo/path/to/file.md)`};return null}async function bde(e,t,r,i={}){let{dryRun:n=!1,githubCache:o,repositories:s=[],skillsIndexRefs:a=[]}=i,c=[],l=[],u=[],p=[];for(let d of r)if(typeof d==="string")l.push(d);else{let f=d.dest;if(!f&&d.source){let m=d.source.split("/");f=m[m.length-1]||d.source}if(!f){c.push({source:"unknown",destination:Fe(t,"unknown"),action:"failed",error:"File entry must have at least source or dest specified"});continue}u.push(d.source?{source:d.source,dest:f}:{dest:f})}if(l.length>0)if(!e){for(let d of l)if(!Hv(d)&&!d.startsWith("!"))c.push({source:d,destination:Fe(t,d),action:"failed",error:`Cannot resolve file '${d}' - no workspace.source configured and no explicit source provided`})}else{let d=await Wpe(e,l);for(let f of d){let m=Fe(t,f.relativePath);if(!bo(f.sourcePath)){if(l.some((h)=>!Hv(h)&&!h.startsWith("!")&&h===f.relativePath))c.push({source:f.sourcePath,destination:m,action:"failed",error:`Source file not found: ${f.sourcePath}`});continue}if(n){if(c.push({source:f.sourcePath,destination:m,action:"copied"}),U0.includes(f.relativePath))p.push(f.relativePath);continue}try{await Na(ip(m),{recursive:!0});let g=await Fa(f.sourcePath,"utf-8");if(await el(m,g,"utf-8"),c.push({source:f.sourcePath,destination:m,action:"copied"}),U0.includes(f.relativePath))p.push(f.relativePath)}catch(g){c.push({source:f.sourcePath,destination:m,action:"failed",error:g instanceof Error?g.message:"Unknown error"})}}}for(let d of u){let f=Fe(t,d.dest),m;if(d.source){let g=stt(d.source,e,o);if(!g){c.push({source:d.source,destination:f,action:"failed",error:`Failed to resolve source: ${d.source}`});continue}if(g.error){c.push({source:d.source,destination:f,action:"failed",error:g.error});continue}m=g.path}else{if(!e){c.push({source:d.dest,destination:f,action:"failed",error:`Cannot resolve file '${d.dest}' - no workspace.source configured and no explicit source provided`});continue}m=Fe(e,d.dest)}if(!bo(m)){c.push({source:m,destination:f,action:"failed",error:`Source file not found: ${m}`});continue}if(n){if(c.push({source:m,destination:f,action:"copied"}),U0.includes(d.dest))p.push(d.dest);continue}try{await Na(ip(f),{recursive:!0});let g=await Fa(m,"utf-8");if(await el(f,g,"utf-8"),c.push({source:m,destination:f,action:"copied"}),U0.includes(d.dest))p.push(d.dest)}catch(g){c.push({source:m,destination:f,action:"failed",error:g instanceof Error?g.message:"Unknown error"})}}if(!n&&s.length>0)for(let d of p){let f=Fe(t,d);try{await mm(f,s,a)}catch(m){c.push({source:"WORKSPACE-RULES",destination:f,action:"failed",error:m instanceof Error?m.message:"Failed to inject WORKSPACE-RULES"})}}return c}var pde,dde,U0;var hm=R(()=>{ut();fi();Gpe();Jpe();pr();Qpe();pm();Ma();Gu();pde=Nt(d2(),1),dde=Nt(x0(),1),U0=["AGENTS.md","CLAUDE.md"]});import{existsSync as u4}from"node:fs";import{mkdir as att,readFile as ctt,readdir as ltt,writeFile as utt}from"node:fs/promises";import{dirname as ptt,join as Kv}from"node:path";function V0(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ftt(e,t,r){let i;try{i=JSON.parse(e)}catch(o){return r.push(`Copilot hooks: failed to parse ${t}: ${o instanceof Error?o.message:String(o)}`),null}if(!V0(i)||i.version!==1||!V0(i.hooks))return r.push(`Copilot hooks: ${t} must contain version 1 and a hooks object`),null;if(i.disableAllHooks===!0)return{version:1,hooks:{}};let n={};for(let[o,s]of Object.entries(i.hooks)){if(!Array.isArray(s))return r.push(`Copilot hooks: event '${o}' in ${t} must be an array`),null;n[o]=s}return{version:1,hooks:n}}function mtt(e,t){return{version:1,hooks:Object.fromEntries(Object.entries(e.hooks).map(([i,n])=>[i,n.map((o)=>{if(!V0(o))return o;let s=V0(o.env)?o.env:{};return{...o,env:{...s,COPILOT_PLUGIN_ROOT:t}}})]))}}async function gtt(e,t){let r=dtt.find((o)=>u4(Kv(e.resolved,o)));if(!r)return null;let i=Kv(e.resolved,r);if(qi(e.resolved,i,e.exclude))return null;let n;try{n=ftt(await ctt(i,"utf-8"),i,t)}catch(o){return t.push(`Copilot hooks: failed to read ${i}: ${o instanceof Error?o.message:String(o)}`),null}if(!n)return null;if(await htt(e))return null;return mtt(n,e.resolved)}async function htt(e){if(!e.exclude||e.exclude.length===0)return!1;let t=Kv(e.resolved,"hooks");if(!u4(t))return!1;async function r(i){let n=await ltt(i,{withFileTypes:!0});for(let o of n){let s=Kv(i,o.name);if(qi(e.resolved,s,e.exclude))return!0;if(o.isDirectory()&&await r(s))return!0}return!1}return r(t)}function ytt(e){return e.success&&e.clients.includes("copilot")&&e.fileArtifacts?.hooks!==!1}function vtt(e){let t={};for(let r of e)for(let[i,n]of Object.entries(r.hooks)){if(n.length===0)continue;t[i]=[...t[i]??[],...n]}return{version:1,hooks:t}}async function kde(e,t,r={}){let i=[],n=await Promise.all(e.filter(ytt).map((a)=>gtt(a,i))),o=vtt(n.filter((a)=>a!==null));if(Object.keys(o.hooks).length===0)return{copyResults:[],warnings:i};let s=Kv(t,q0);if(u4(s)&&!r.previouslyManaged)return i.push(`Copilot hooks: not updating ${q0} because the existing file is not owned by AllAgents`),{copyResults:[],warnings:i};if(!r.dryRun)await att(ptt(s),{recursive:!0}),await utt(s,`${JSON.stringify(o,null,2)}
|
|
486
|
-
`,"utf-8");return{copyResults:[{source:"copilot-plugin-hooks",destination:s,action:"generated"}],warnings:i}}var q0=".github/hooks/allagents.json",dtt;var Sde=R(()=>{hm();dtt=["hooks.json","hooks/hooks.json"]});import{existsSync as wtt}from"node:fs";import{mkdir as btt}from"node:fs/promises";import{dirname as ktt,resolve as Stt}from"node:path";function xtt(e){if(e.startsWith("~/")||e==="~")return e.replace("~",ye());return e}function $tt(e){if(e===void 0||e===!1)return!1;return!0}function _tt(e){if(e===!0||e==="sync")return!0;return!1}function Ptt(e){return/^[\w.\-/]+$/.test(e)}function Ctt(e,t){if(!Ptt(t))throw Error(`Invalid repo identifier: ${t}`);switch(e){case"github":return`https://github.com/${t}.git`;case"gitlab":return`https://gitlab.com/${t}.git`;case"bitbucket":return`https://bitbucket.org/${t}.git`;case"azure-devops":{let r=t.split("/");if(r.length===3)return`https://dev.azure.com/${r[0]}/${r[1]}/_git/${r[2]}`;return`https://dev.azure.com/${t}`}default:return`https://${e}/${t}.git`}}async function Ett(e,t,r){await btt(ktt(t),{recursive:!0});let i=Ir(void 0,xde),n=r?["--branch",r]:[];await i.clone(e,t,n)}async function Rtt(e,t){let r=Ir(e,xde),i=await r.status();if(!i.isClean())return"uncommitted changes";if(t){let n=i.current;if(n!==t)return`on branch '${n}', expected '${t}'`}await r.pull();return}async function $de(e,t,r={}){if(r.skipManaged||r.offline||r.dryRun)return[];let i=e.filter((o)=>o.managed);if(i.length===0)return[];let n=[];for(let o of i){if(!o.source||!o.repo){n.push({path:o.path,repo:o.repo??o.path,action:"skipped",error:"managed requires both source and repo fields"});continue}let s=xtt(o.path),a=Stt(t,s);if(!wtt(a)){if(!$tt(o.managed)){n.push({path:o.path,repo:o.repo,action:"skipped"});continue}try{let c=Ctt(o.source,o.repo);await Ett(c,a,o.branch),n.push({path:o.path,repo:o.repo,action:"cloned"})}catch(c){n.push({path:o.path,repo:o.repo,action:"skipped",error:`clone failed: ${c instanceof Error?c.message:String(c)}`})}}else if(_tt(o.managed))try{let c=await Rtt(a,o.branch);if(c)n.push({path:o.path,repo:o.repo,action:"skipped",error:`pull skipped: ${c}`});else n.push({path:o.path,repo:o.repo,action:"pulled"})}catch(c){n.push({path:o.path,repo:o.repo,action:"skipped",error:`pull failed: ${c instanceof Error?c.message:String(c)}`})}else n.push({path:o.path,repo:o.repo,action:"skipped"})}return n}var xde=120000;var _de=R(()=>{ut();bs()});import{randomUUID as Itt}from"node:crypto";import{lstat as Ede,mkdtemp as Att,open as Ott,readFile as Ttt,rename as Dtt,rm as d4}from"node:fs/promises";import{tmpdir as Mtt}from"node:os";import{dirname as Ntt,join as G0}from"node:path";function ym(e){return{...e.cwd&&{cwd:e.cwd},...e.env&&{env:e.env}}}function ki(e){if(e.error)return e.error;if(e.signal)return`Claude CLI terminated by ${e.signal}`;return`Claude CLI exited with code ${e.exitCode??"unknown"}`}function Ftt(e){let t=/(?:^|\s)v?(\d+)\.(\d+)\.(\d+)(?=\D|$)/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}async function Pde(e){let t=await Ede(e.root).catch((r)=>{if(r.code==="ENOENT")return null;throw r});if(!t)return!1;if(!t.isDirectory()||t.isSymbolicLink())throw Error(`Claude configuration root is not a real directory: ${e.root}`);return!0}function jtt(e){try{let t=JSON.parse(e);return t&&typeof t==="object"&&!Array.isArray(t)?t:null}catch{return null}}function ztt(e){let t=e.split(/\r?\n/).map((r)=>r.trim()).filter(Boolean);for(let r=t.length-1;r>=0;r--){let i=jtt(t[r]??"");if(i)return i}return null}function Cde(e,t){if(typeof e==="string"&&!t)return Rs(e)?{id:e,enabled:!0}:null;if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e,i;for(let o of["id","pluginId","spec","plugin"])if(typeof r[o]==="string"&&r[o].length>0){i=r[o];break}if(!i&&typeof r.name==="string"&&typeof r.marketplaceName==="string")i=`${r.name}@${r.marketplaceName}`;if(!i&&typeof r.name==="string"&&Rs(r.name))i=r.name;if(!i||!Rs(i))return null;let n=r.scope==="user"||r.scope==="project"||r.scope==="local"||r.scope==="managed"?r.scope:void 0;if(!t&&r.scope!==void 0&&!n)return null;if(!t&&r.enabled!==void 0&&typeof r.enabled!=="boolean")return null;return{id:i,...n&&{scope:n},enabled:t?!1:r.enabled!==!1}}function W0(e){let t;try{t=JSON.parse(e)}catch{return null}let r=Array.isArray(t)?t:t&&typeof t==="object"?["installed","plugins","installedPlugins","installed_plugins"].map((s)=>t[s]).find(Array.isArray)??null:null,i=t&&typeof t==="object"&&!Array.isArray(t)&&Array.isArray(t.available)?t.available:[];if(!r)return null;let n=r.map((s)=>Cde(s,!1)),o=i.map((s)=>Cde(s,!0));return n.every((s)=>s!==null)&&o.every((s)=>s!==null)?{installed:n,available:o}:null}function Utt(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;if(typeof t.name!=="string"||typeof t.source!=="string")return null;let r;for(let i of["path","repo","url"])if(typeof t[i]==="string"&&t[i].length>0){r=t[i];break}if(!r&&typeof t.installLocation==="string")r=t.installLocation;if(!r)return null;return{name:t.name,sourceType:t.source,source:r,...typeof t.ref==="string"&&t.ref.length>0&&{ref:t.ref}}}function Rde(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Array.isArray(t))return null;let r=t.map(Utt);return r.every((i)=>i!==null)?r:null}function Rs(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("@")||r.includes("/")||r.includes("\\")||i.includes("/")||i.includes("\\")||i.includes("://"))return null;return{plugin:r,marketplace:i}}function p4(e,t,r,i){let n=ztt(e);return n?.command===t&&n.outcome==="ok"&&n.pluginId===r&&n.scope===i}function Jv(e){return e.nativeScope.startsWith("profile:")?"user":e.nativeScope}function H0(e){return e.nativeScope.startsWith("profile:")}function Ltt(e){let t=e.provenance.marketplaceSource;if(!t)return null;let r=e.provenance.resolvedRef;return r&&/^[^/:]+\/[^/]+$/.test(t)?`${t}@${r}`:t}async function Btt(e){if(!e.nativeScope.startsWith("profile:"))return null;let t=G0(e.roots?.config??e.root,"settings.json"),r=await Ede(t).catch((i)=>{if(i.code==="ENOENT")return null;throw i});if(!r)return{path:t,content:null};if(!r.isFile()||r.isSymbolicLink())throw Error(`Claude profile settings are not a regular file: ${t}`);return{path:t,content:await Ttt(t),mode:r.mode&511}}async function qtt(e){if(!e)return;if(!e.content){await d4(e.path,{force:!0});return}let t=G0(Ntt(e.path),`.allagents-settings-${Itt()}.tmp`),r;try{r=await Ott(t,"wx",e.mode??384),await r.writeFile(e.content),await r.chmod(e.mode??384),await r.sync(),await r.close(),r=void 0,await Dtt(t,e.path)}finally{await r?.close().catch(()=>{return}),await d4(t,{force:!0})}}class vm{client="claude";run;minimumVersion;constructor(e={}){this.run=e.execute??Qn,this.minimumVersion=e.minimumVersion}async runIsolated(e,t){let r=await Att(G0(Mtt(),"allagents-claude-inspection-"));try{return await this.run("claude",e,{...t?.cwd&&{cwd:t.cwd},env:{...t?.env,CLAUDE_CONFIG_DIR:r,CLAUDE_CODE_PLUGIN_CACHE_DIR:G0(r,"plugins"),CLAUDE_CODE_PLUGIN_SEED_DIR:void 0,CLAUDE_CODE_PROJECT_DIR_NAME:void 0}})}finally{await d4(r,{recursive:!0,force:!0})}}async runForInspection(e,t){return await Pde(t)?this.run("claude",e,ym(t)):this.runIsolated(e,t)}async runMutation(e,t){let r=await Btt(t);try{return await this.run("claude",e,ym(t))}finally{await qtt(r)}}async isAvailable(e){let t=await this.runIsolated(["--version"],e);if(!t.success)return!1;let r=Ftt(t.output);if(this.minimumVersion&&(!r||Ko(r,this.minimumVersion)<0))return!1;if(!this.minimumVersion)return!0;let i=await this.runIsolated(["plugin","--help"],e);return i.success&&["install","list","marketplace","uninstall","update"].every((n)=>i.output.includes(n))}supportsScope(e){return!0}toPluginSpec(e){if(Rs(e))return e;let r=e.lastIndexOf("@");if(r<=0||r===e.length-1)return null;let i=e.slice(0,r),n=e.slice(r+1);if(!n.includes("/")||n.includes("://"))return null;let[,o]=n.split("/");return o?`${i}@${o}`:null}extractMarketplaceSource(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(t+1);return r.includes("/")&&!r.includes("://")?r:null}resolveSource(e,t,r={}){let i=this.toPluginSpec(e);if(!i)return{success:!1,error:`Claude native install does not support source '${e}'`};let n=Rs(i);return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:i,context:t,provenance:{...n&&{marketplaceName:n.marketplace},...r}}}}async inspect(e){if(!await Pde(e))return{success:!0,resources:[]};let t=await this.runForInspection(["plugin","list","--json"],e);if(!t.success)return{success:!1,resources:[],error:ki(t)};if(!t.output.trim()&&!H0(e))return{success:!0,resources:[]};let r=W0(t.output);if(!r)return{success:!1,resources:[],error:"Could not parse Claude plugin inventory"};let i=[],n=[];for(let o of r.installed){let s=Jv(e);if(o.scope&&o.scope!==s&&!(s==="project"&&o.scope==="local"))continue;let a=Rs(o.id),c={kind:"plugin",requestedIdentity:o.id,resolvedIdentity:o.id,context:e,provenance:{...a&&{marketplaceName:a.marketplace}}};if(o.enabled)i.push(c);else n.push({resource:c,status:"disabled"})}return{success:!0,resources:i,...n.length>0&&{observations:n}}}async inspectMarketplaceRegistration(e,t){let r=await this.runForInspection(["plugin","marketplace","list","--json"],t);if(!r.success)return{success:!1,present:!1,error:ki(r)};let i=Rde(r.output);if(!i)return{success:!1,present:!1,error:"Could not parse Claude marketplace inventory"};let n=i.find((o)=>o.name===e);return{success:!0,present:Boolean(n),...n?.source&&{source:n.source},...n?.sourceType&&{sourceType:n.sourceType},...n?.ref&&{ref:n.ref}}}async inspectMarketplacePlugin(e,t,r){let i=await this.runForInspection(["plugin","list","--available","--json"],r);if(!i.success)return{success:!1,present:!1,error:ki(i)};let n=W0(i.output);if(!n)return{success:!1,present:!1,error:`Could not parse Claude marketplace '${e}'`};let o=`${t}@${e}`;return{success:!0,present:[...n.installed,...n.available].some((s)=>s.id===o)}}async install(e,t){let r=Jv(t);if(!H0(t)){let a=[],c=e.provenance.marketplaceSource;if(c){let u=await this.run("claude",["plugin","marketplace","add",c],ym(t));if(!u.success)return{success:!1,error:ki(u)};a.push(c)}let l=await this.run("claude",["plugin","install",e.resolvedIdentity,"--scope",r],ym(t));return l.success?{success:!0,...a.length>0&&{registrations:a}}:{success:!1,error:ki(l),...a.length>0&&{registrations:a}}}let i=e.provenance.marketplaceName;if(!i)return{success:!1,error:"Claude plugin marketplace is missing"};let n=[],o=await this.inspectMarketplaceRegistration(i,t);if(!o.success)return{success:!1,error:o.error??`Could not inspect Claude marketplace '${i}'`};if(!o.present){let a=Ltt(e);if(!a)return{success:!1,error:`Claude marketplace '${i}' is not registered and has no source`};let c=["plugin","marketplace","add",a,"--scope",r],l=e.provenance.marketplaceSparsePath;if(l)c.push("--sparse",l);let u=await this.runMutation(c,t);if(!u.success)return{success:!1,error:ki(u)};n.push(e.provenance.managedMarketplaceRegistration==="true"?i:a);let p=await this.inspectMarketplaceRegistration(i,t);if(!p.success||!p.present)return{success:!1,error:p.error??`Claude marketplace '${i}' registration could not be verified`,registrations:n}}if(e.provenance.managedMarketplaceRegistration==="true"&&n.length===0)n.push(i);let s=await this.runMutation(["plugin","install",e.resolvedIdentity,"--scope",r,"--yes","--json"],t);return s.success&&p4(s.output,"install",e.resolvedIdentity,r)?{success:!0,...n.length>0&&{registrations:n}}:{success:!1,error:s.success?`Could not parse Claude plugin '${e.resolvedIdentity}' install result`:ki(s),...n.length>0&&{registrations:n}}}async update(e,t,r){let i=Jv(r);if(!H0(r)){let s=await this.run("claude",["plugin","update",e.resolvedIdentity,"--scope",i],ym(r));return s.success?{success:!0}:{success:!1,error:ki(s)}}let n=e.provenance.marketplaceName;if(n){let s=await this.runMutation(["plugin","marketplace","update",n],r);if(!s.success)return{success:!1,error:ki(s)}}let o=await this.runMutation(["plugin","update",e.resolvedIdentity,"--scope",i,"--yes","--json"],r);return o.success&&p4(o.output,"update",e.resolvedIdentity,i)?{success:!0}:{success:!1,error:o.success?`Could not parse Claude plugin '${e.resolvedIdentity}' update result`:ki(o)}}async remove(e,t){let r=Jv(t);if(!H0(t)){let n=await this.run("claude",["plugin","uninstall",e.resolvedIdentity,"--scope",r],ym(t));return n.success?{success:!0}:{success:!1,error:ki(n)}}let i=await this.runMutation(["plugin","uninstall",e.resolvedIdentity,"--scope",r,"--yes","--json"],t);return i.success&&p4(i.output,"uninstall",e.resolvedIdentity,r)?{success:!0}:{success:!1,error:i.success?`Could not parse Claude plugin '${e.resolvedIdentity}' removal result`:ki(i)}}async removeMarketplaceRegistration(e,t){let r=Jv(t),i=await this.inspectMarketplaceRegistration(e,t);if(!i.success)return{success:!1,error:i.error??`Could not inspect Claude marketplace '${e}'`};if(!i.present)return{success:!0};let n=await this.runForInspection(["plugin","list","--json"],t);if(!n.success)return{success:!1,error:ki(n)};let o=W0(n.output);if(!o)return{success:!1,error:`Could not parse Claude marketplace '${e}' plugin inventory`};if(o.installed.some((c)=>Rs(c.id)?.marketplace===e))return{success:!1,error:`Claude marketplace '${e}' is still used by installed plugins`};let s=await this.runMutation(["plugin","marketplace","remove",e,"--scope",r],t);if(!s.success)return{success:!1,error:ki(s)};let a=await this.inspectMarketplaceRegistration(e,t);return a.success&&!a.present?{success:!0}:{success:!1,error:a.error??`Claude marketplace '${e}' removal could not be verified`}}}var f4=R(()=>{vo()});import{access as Vtt,mkdtemp as Htt,rm as Wtt}from"node:fs/promises";import{tmpdir as Gtt}from"node:os";import{basename as Ztt,join as m4}from"node:path";function wm(e){return{...e.cwd&&{cwd:e.cwd},...e.env&&{env:e.env}}}async function Ide(e){let t=e.roots?.config??e.root;return Vtt(t).then(()=>!0,(r)=>{if(r.code==="ENOENT")return!1;throw r})}function tl(e){if(e.error)return e.error;if(e.signal)return`Copilot CLI terminated by ${e.signal}`;return`Copilot CLI exited with code ${e.exitCode??"unknown"}`}function Xtt(e){let t=/(?:^|\s)v?(\d+)\.(\d+)\.(\d+)(?=\D|$)/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function Ade(e){if(e.includes("No plugins installed."))return[];if(!e.includes("Installed plugins:"))return null;return e.split(/\r?\n/).flatMap((t)=>Ktt.exec(t)?.[1]??[])}function Qtt(e){if(!e.includes("Included with GitHub Copilot:")&&!e.includes("Registered marketplaces:"))return null;let t=new Map;for(let r of e.split(/\r?\n/)){let i=Jtt.exec(r);if(i?.[1]&&i[2])t.set(i[1],i[2])}return t}function ert(e){if(!e.startsWith('Plugins in "'))return null;return e.split(/\r?\n/).flatMap((t)=>Ytt.exec(t)?.[1]??[])}function Yv(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("/")||r.includes("\\")||i.includes("/")||i.includes("\\")||i.includes("://"))return null;return{plugin:r,marketplace:i}}class bm{client="copilot";run;minimumVersion;constructor(e={}){this.run=e.execute??Qn,this.minimumVersion=e.minimumVersion}async runIsolated(e,t){let r=await Htt(m4(Gtt(),"allagents-copilot-inspection-"));try{return await this.run("copilot",e,{...t.cwd&&{cwd:t.cwd},env:{...t.env,COPILOT_HOME:m4(r,"home"),COPILOT_CACHE_HOME:m4(r,"cache")}})}finally{await Wtt(r,{recursive:!0,force:!0})}}async runForInspection(e,t){return await Ide(t)?this.run("copilot",e,wm(t)):this.runIsolated(e,t)}async isAvailable(e){let t=e?await this.runIsolated(["--version"],e):await this.run("copilot",["--version"]);if(!t.success)return!1;if(!this.minimumVersion)return!0;let r=Xtt(t.output);return Boolean(r&&Ko(r,this.minimumVersion)>=0)}supportsScope(e){return e==="user"}toPluginSpec(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("/")||r.includes("\\")||i.includes("://")||i.includes("\\"))return null;if(!i.includes("/"))return e;let n=i.split("/");if(n.length!==2||!n[0]||!n[1])return null;return`${r}@${Ztt(i)}`}extractMarketplaceSource(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(t+1);if(r.includes("/")&&!r.includes("://"))return r;return null}resolveSource(e,t,r={}){let i=this.toPluginSpec(e);if(!i)return{success:!1,error:`Copilot native install does not support source '${e}'`};let n=Yv(i),o=r.marketplaceSource??this.extractMarketplaceSource(e),s=r.marketplaceName??n?.marketplace;return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:i,context:t,provenance:{...r,...o&&{marketplaceSource:o},...s&&{marketplaceName:s}}}}}async inspect(e){if(!await Ide(e))return{success:!0,resources:[]};let t=await this.runForInspection(["plugin","list"],e);if(!t.success)return{success:!1,resources:[],error:tl(t)};let r=Ade(t.output);if(!r)return{success:!1,resources:[],error:"Could not parse Copilot plugin inventory"};return{success:!0,resources:r.map((i)=>{let n=Yv(i);return{kind:"plugin",requestedIdentity:i,resolvedIdentity:i,context:e,provenance:{...n&&{marketplaceName:n.marketplace}}}})}}async inspectMarketplaceRegistration(e,t){let r=await this.runForInspection(["plugin","marketplace","list"],t);if(!r.success)return{success:!1,present:!1,error:tl(r)};let i=Qtt(r.output);if(!i)return{success:!1,present:!1,error:"Could not parse Copilot marketplace inventory"};let n=i.get(e);return{success:!0,present:n!==void 0,...n&&{source:n}}}async inspectMarketplacePlugin(e,t,r){let i=await this.runForInspection(["plugin","marketplace","browse",e],r);if(!i.success)return{success:!1,present:!1,error:tl(i)};let n=ert(i.output);if(!n)return{success:!1,present:!1,error:`Could not parse Copilot marketplace '${e}'`};return{success:!0,present:n.includes(t)}}async install(e,t){let r=[],i=e.provenance.marketplaceSource,n=e.provenance.marketplaceName;if(i&&n){let c=await this.inspectMarketplaceRegistration(n,t);if(!c.success)return{success:!1,error:c.error??`Could not inspect Copilot marketplace '${n}'`};if(!c.present){let l=await this.run("copilot",["plugin","marketplace","add",i],wm(t));if(!l.success)return{success:!1,error:tl(l)}}if(e.provenance.managedMarketplaceRegistration==="true")r.push(n)}let o=await this.run("copilot",["plugin","install",e.resolvedIdentity],wm(t));if(o.success)return{success:!0,...r.length>0&&{registrations:r}};let s=tl(o);return{success:!1,error:s.includes("Plugin path escapes marketplace directory")?`${s} (Copilot rejected a plugin path from this marketplace manifest. Use file install for copilot to avoid native install for this plugin.)`:s,...r.length>0&&{registrations:r}}}async update(e,t,r){let i=await this.run("copilot",["plugin","update",e.resolvedIdentity],wm(r));return i.success?{success:!0}:{success:!1,error:tl(i)}}async remove(e,t){let r=await this.run("copilot",["plugin","uninstall",e.resolvedIdentity],wm(t));return r.success?{success:!0}:{success:!1,error:tl(r)}}async removeMarketplaceRegistration(e,t){let r=await this.inspectMarketplaceRegistration(e,t);if(!r.success)return{success:!1,error:r.error??`Could not inspect Copilot marketplace '${e}'`};if(!r.present)return{success:!0};let i=await this.run("copilot",["plugin","marketplace","remove",e],wm(t));return i.success?{success:!0}:{success:!1,error:tl(i)}}}var Ktt,Jtt,Ytt;var g4=R(()=>{vo();Ktt=/^\s*[•*-]\s+([^\s]+@[^\s]+?)(?:\s+\(v[^)]*\))?(?:\s+\[[^\]]+\])?\s*$/,Jtt=/^\s*[•◆*-]\s+([^\s]+)\s+\((?:GitHub|Directory|Git):\s*([^)]+)\)\s*$/,Ytt=/^\s*[•*-]\s+([^\s]+)\s+-\s+/});import{access as trt,mkdtemp as rrt,rm as nrt}from"node:fs/promises";import{tmpdir as irt}from"node:os";import{join as ort}from"node:path";function sp(e){return{...e.cwd&&{cwd:e.cwd},...e.env&&{env:e.env}}}async function Ode(e){return trt(e.root).then(()=>!0,(t)=>{if(t.code==="ENOENT")return!1;throw t})}function Is(e){if(e.error)return e.error;if(e.signal)return`Codex CLI terminated by ${e.signal}`;return`Codex CLI exited with code ${e.exitCode??"unknown"}`}function srt(e){let t=/(?:^|\s)v?(\d+)\.(\d+)\.(\d+)(?=\D|$)/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function km(e){try{let t=JSON.parse(e);return t&&typeof t==="object"&&!Array.isArray(t)?t:null}catch{return null}}function Dde(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let t=e;return typeof t.sourceType==="string"&&typeof t.source==="string"?{sourceType:t.sourceType,source:t.source}:void 0}function art(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;if(typeof t.name!=="string"||typeof t.root!=="string")return null;let r=Dde(t.marketplaceSource);return{name:t.name,root:t.root,...r&&{marketplaceSource:r}}}function Mde(e){let t=km(e);if(!t||!Array.isArray(t.marketplaces))return null;let r=t.marketplaces.map(art);return r.every((i)=>i!==null)?r:null}function Tde(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;if(typeof t.pluginId!=="string"||typeof t.name!=="string"||typeof t.marketplaceName!=="string"||typeof t.installed!=="boolean"||typeof t.enabled!=="boolean")return null;let r=Dde(t.marketplaceSource);return{pluginId:t.pluginId,name:t.name,marketplaceName:t.marketplaceName,installed:t.installed,enabled:t.enabled,...r&&{marketplaceSource:r}}}function Z0(e){let t=km(e);if(!t||!Array.isArray(t.installed)||!Array.isArray(t.available))return null;let r=t.installed.map(Tde),i=t.available.map(Tde);return r.every((n)=>n!==null)&&i.every((n)=>n!==null)?{installed:r,available:i}:null}function K0(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("/")||r.includes("\\")||i.includes("/")||i.includes("\\")||i.includes("://"))return null;return{plugin:r,marketplace:i}}function h4(e,t){return km(e)?.pluginId===t}function crt(e,t){let r=km(e);return r?.marketplaceName===t&&typeof r.alreadyAdded==="boolean"?{alreadyAdded:r.alreadyAdded}:null}function lrt(e,t){let r=km(e);return Boolean(r&&Array.isArray(r.selectedMarketplaces)&&r.selectedMarketplaces.includes(t)&&Array.isArray(r.upgradedRoots)&&Array.isArray(r.errors)&&r.errors.length===0)}class Sm{client="codex";run;minimumVersion;constructor(e={}){this.run=e.execute??Qn,this.minimumVersion=e.minimumVersion}async runIsolated(e,t){let r=await rrt(ort(irt(),"allagents-codex-inspection-"));try{return await this.run("codex",e,{...t?.cwd&&{cwd:t.cwd},env:{...t?.env,CODEX_HOME:r}})}finally{await nrt(r,{recursive:!0,force:!0})}}async runForInspection(e,t){return await Ode(t)?this.run("codex",e,sp(t)):this.runIsolated(e,t)}async isAvailable(e){let t=await this.runIsolated(["--version"],e);if(!t.success)return!1;let r=srt(t.output);if(this.minimumVersion&&(!r||Ko(r,this.minimumVersion)<0))return!1;let i=await this.runIsolated(["plugin","--help"],e);return i.success&&["add","list","marketplace","remove"].every((n)=>i.output.includes(n))}supportsScope(e){return e==="user"}resolveSource(e,t,r={}){let i=K0(e);if(!i)return{success:!1,error:`Codex native install does not support source '${e}'`};return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:`${i.plugin}@${i.marketplace}`,context:t,provenance:{...r,marketplaceName:r.marketplaceName??i.marketplace}}}}async inspect(e){if(!await Ode(e))return{success:!0,resources:[]};let t=await this.runForInspection(["plugin","list","--json"],e);if(!t.success)return{success:!1,resources:[],error:Is(t)};let r=Z0(t.output);if(!r)return{success:!1,resources:[],error:"Could not parse Codex plugin inventory"};let i=[],n=[];for(let o of r.installed){let s={kind:"plugin",requestedIdentity:o.pluginId,resolvedIdentity:o.pluginId,context:e,provenance:{marketplaceName:o.marketplaceName,...o.marketplaceSource?.source&&{marketplaceSource:o.marketplaceSource.source}}};if(o.installed&&o.enabled)i.push(s);else n.push({resource:s,status:o.installed?"disabled":"configured-missing"})}return{success:!0,resources:i,...n.length>0&&{observations:n}}}async inspectMarketplaceRegistration(e,t){let r=await this.runForInspection(["plugin","marketplace","list","--json"],t);if(!r.success)return{success:!1,present:!1,error:Is(r)};let i=Mde(r.output);if(!i)return{success:!1,present:!1,error:"Could not parse Codex marketplace inventory"};let n=i.find((o)=>o.name===e);return{success:!0,present:Boolean(n),...n?.root&&{root:n.root},...n?.marketplaceSource?.source&&{source:n.marketplaceSource.source},...n?.marketplaceSource?.sourceType&&{sourceType:n.marketplaceSource.sourceType}}}async inspectMarketplacePlugin(e,t,r){let i=await this.runForInspection(["plugin","list","--marketplace",e,"--available","--json"],r);if(!i.success)return{success:!1,present:!1,error:Is(i)};let n=Z0(i.output);if(!n)return{success:!1,present:!1,error:`Could not parse Codex marketplace '${e}'`};let o=`${t}@${e}`;return{success:!0,present:[...n.installed,...n.available].some((s)=>s.pluginId===o)}}async install(e,t){let r=e.provenance.marketplaceName;if(!r)return{success:!1,error:"Codex plugin marketplace is missing"};let i=[],n=await this.inspectMarketplaceRegistration(r,t);if(!n.success)return{success:!1,error:n.error??`Could not inspect Codex marketplace '${r}'`};if(!n.present){let s=e.provenance.marketplaceSource;if(!s)return{success:!1,error:`Codex marketplace '${r}' is not registered and has no source`};let a=["plugin","marketplace","add",s],c=e.provenance.resolvedRef;if(c)a.push("--ref",c);let l=e.provenance.marketplaceSparsePath;if(l)a.push("--sparse",l);a.push("--json");let u=await this.run("codex",a,sp(t));if(!u.success)return{success:!1,error:Is(u)};let p=crt(u.output,r);if(!p)return{success:!1,error:`Could not parse Codex marketplace '${r}' registration result`};if(!p.alreadyAdded&&e.provenance.managedMarketplaceRegistration==="true")i.push(r)}let o=await this.run("codex",["plugin","add",e.resolvedIdentity,"--json"],sp(t));if(!o.success)return{success:!1,error:Is(o),...i.length>0&&{registrations:i}};if(!h4(o.output,e.resolvedIdentity))return{success:!1,error:`Could not parse Codex plugin '${e.resolvedIdentity}' install result`,...i.length>0&&{registrations:i}};return{success:!0,...i.length>0&&{registrations:i}}}async update(e,t,r){let i=e.provenance.marketplaceName;if(!i)return{success:!1,error:"Codex plugin marketplace is missing"};let n=await this.inspectMarketplaceRegistration(i,r);if(!n.success||!n.present)return{success:!1,error:n.error??`Codex marketplace '${i}' is not registered`};if(n.sourceType==="git"){let s=await this.run("codex",["plugin","marketplace","upgrade",i,"--json"],sp(r));if(!s.success)return{success:!1,error:Is(s)};if(!lrt(s.output,i))return{success:!1,error:`Could not parse Codex marketplace '${i}' upgrade result`}}let o=await this.run("codex",["plugin","add",e.resolvedIdentity,"--json"],sp(r));return o.success&&h4(o.output,e.resolvedIdentity)?{success:!0}:{success:!1,error:o.success?`Could not parse Codex plugin '${e.resolvedIdentity}' update result`:Is(o)}}async remove(e,t){let r=await this.run("codex",["plugin","remove",e.resolvedIdentity,"--json"],sp(t));return r.success&&h4(r.output,e.resolvedIdentity)?{success:!0}:{success:!1,error:r.success?`Could not parse Codex plugin '${e.resolvedIdentity}' removal result`:Is(r)}}async removeMarketplaceRegistration(e,t){let r=await this.inspectMarketplaceRegistration(e,t);if(!r.success)return{success:!1,error:r.error??`Could not inspect Codex marketplace '${e}'`};if(!r.present)return{success:!0};let i=await this.runForInspection(["plugin","list","--marketplace",e,"--json"],t);if(!i.success)return{success:!1,error:Is(i)};let n=Z0(i.output);if(!n)return{success:!1,error:`Could not parse Codex marketplace '${e}' plugin inventory`};if(n.installed.length>0)return{success:!1,error:`Codex marketplace '${e}' is still used by installed plugins`};let o=await this.run("codex",["plugin","marketplace","remove",e,"--json"],sp(t));if(!o.success)return{success:!1,error:Is(o)};return km(o.output)?.marketplaceName===e?{success:!0}:{success:!1,error:`Could not parse Codex marketplace '${e}' removal result`}}}var y4=R(()=>{vo()});import{readFile as zde}from"node:fs/promises";import{isAbsolute as urt,join as xm,resolve as Qv,win32 as prt}from"node:path";function As(e){return typeof e==="string"&&e.length<=64&&frt.test(e)}function $m(e){if(!As(e)||e==="default"||e==="."||e===".."||e.endsWith("."))throw Error(`Invalid OMP profile name '${e}'`);return`profile:${e}`}function b4(e){if(!e?.startsWith("profile:"))return;let t=e.slice(8);return $m(t).slice(8)}function nl(e){return urt(e)||prt.isAbsolute(e)}function Ude(e){return Qv(e.cwd??process.cwd())}function brt(e){return{...e?.cwd&&{cwd:Ude(e)},env:{...e?.env,OMP_PROFILE:void 0,PI_PROFILE:void 0,PI_CONFIG_FILES:void 0}}}function ap(e){if(e.error)return e.error;if(e.signal)return`OMP CLI terminated by ${e.signal}`;return`OMP CLI exited with code ${e.exitCode??"unknown"}`}function krt(e){let t=/^(?:omp\/)?(\d+)\.(\d+)\.(\d+)(?:[-+][0-9A-Za-z.-]+)?$/.exec(e.trim());if(!t?.[1]||!t[2]||!t[3])return null;let r=[Number(t[1]),Number(t[2]),Number(t[3])];return r.every(Number.isSafeInteger)?r:null}function Os(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(!As(r)||!As(i))return null;let n=`${r}@${i}`;return n.length<=128?{id:n,name:r,marketplace:i}:null}function Srt(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(!As(r)||J0.test(i))return null;let n=i.split("/"),o=n[1];if(n.length<2||!n[0]||!o||o==="."||o==="..")return null;let s=o.replace(/\.git$/i,"").toLowerCase();if(!As(s))return null;let a=`${r}@${s}`;return a.length<=128?{id:a,name:r,marketplace:s}:null}function xrt(e,t){if(e!=="~"&&!e.startsWith("~/")&&!e.startsWith("~\\"))return e;let r=t.env?.HOME??t.env?.USERPROFILE;return r?xm(r,e.slice(2)):e}function k4(e){try{let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:"&&t.protocol!=="ssh:")return null;if(t.username||t.password)return null;for(let[r,i]of t.searchParams)if(i&&grt.test(r))return null;return t.hostname=t.hostname.toLowerCase(),t.searchParams.sort(),t.hash="",t.toString().replace(/\/$/,"")}catch{return null}}function S4(e){let t=e.trim(),r=mrt.exec(t);if(r?.[1]&&r[2])return`${r[1]}/${r[2].replace(/\.git$/i,"")}`.toLowerCase();let i=/^git@github\.com:([^/\s]+)\/([^/\s]+)$/i.exec(t);if(i?.[1]&&i[2])return`${i[1]}/${i[2].replace(/\.git$/i,"")}`.toLowerCase();let n=k4(t);if(!n)return null;let o=new URL(n);if(o.hostname!=="github.com"||o.search)return null;let s=o.pathname.replace(/^\/+|\/+$/g,"").split("/");if(!s[0]||!s[1]||s.length!==2)return null;return`${s[0]}/${s[1].replace(/\.git$/i,"")}`.toLowerCase()}function Nde(e){return k4(e)!==null}function X0(e,t,r){let i=e.trim();if(!i||J0.test(i))return null;let n=S4(i);if(n)return{identity:`github:${n}`,source:n};if(t==="local"||i==="~"||i.startsWith("~/")||i.startsWith("~\\")||i.startsWith("./")||i.startsWith("../")||nl(i)){let a=xrt(i,r);if(a.startsWith("~"))return null;let c=Qv(Ude(r),a);return{identity:`local:${c}`,source:c}}let s=k4(i);if(s)return{identity:`remote:${s}`,source:s};if(/^(?:git@|[^\s]+:[^\s]+$)/.test(i))return{identity:`git:${i}`,source:i};return t==="github"?null:{identity:`remote:${i}`,source:i}}function $rt(e,t,r){return X0(e,t,r)?.identity??null}function Y0(e){return typeof e==="string"&&e.length>0&&!Number.isNaN(Date.parse(e))}function Lde(e,t){let r=yrt.safeParse(e);if(!r.success||!As(r.data.name))return{error:`OMP marketplace catalog is malformed: ${t}`};let i=new Set,n=[];for(let o of r.data.plugins){if(!As(o.name))return{error:`OMP marketplace catalog contains an invalid plugin name: ${t}`};if(i.has(o.name))return{error:`OMP marketplace catalog contains duplicate plugin '${o.name}': ${t}`};i.add(o.name),n.push({name:o.name,source:o.source,...o.version&&{version:o.version}})}return{catalog:{name:r.data.name,plugins:n}}}function x4(e,t,r,i={}){let n=Lde(t,"<fetched marketplace>"),o=n.catalog;if(!o)return{success:!1,error:n.error??"Fetched OMP marketplace catalog is malformed"};let s=Os(e),a,c;if(s){if(s.marketplace!==o.name)return{success:!1,error:`OMP plugin marketplace '${s.marketplace}' does not match fetched catalog '${o.name}'`};if(a=o.plugins.find((u)=>u.name===s.name),!a)return{success:!1,error:`OMP catalog '${o.name}' has no plugin '${s.name}'`}}else{let u=e.trim(),p=u==="~"||u.startsWith("~/")||u.startsWith("~\\")||u.startsWith("./")||u.startsWith("../")||nl(u),d=S4(u)?"github":p?"local":void 0,f=d?X0(u,d,r):null;if(!f)return{success:!1,error:`OMP marketplace source must be an exact plugin id, GitHub repository, or local path: '${e}'`};if(o.plugins.length!==1)return{success:!1,error:`OMP marketplace source '${e}' must resolve exactly one plugin, but catalog '${o.name}' contains ${o.plugins.length}`};a=o.plugins[0],c=f.source}if(!a)return{success:!1,error:`OMP catalog '${o.name}' did not resolve a plugin`};let l=`${a.name}@${o.name}`;return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:l,context:r,provenance:{...i,pluginName:a.name,marketplaceName:o.name,...c&&{marketplaceSource:c},...a.version&&{catalogVersion:a.version}}}}}async function Fde(e,t){try{let r=await t(e);if(!r.trim())return{missing:!1,error:`OMP JSON file is empty: ${e}`};return{value:JSON.parse(r.replace(/^\uFEFF/,"")),missing:!1}}catch(r){if(r.code==="ENOENT")return{missing:!0};return{missing:!1,error:`Could not read OMP JSON file ${e}: ${r instanceof Error?r.message:String(r)}`}}}async function v4(e,t){try{return{contents:await t(e)}}catch(r){if(r.code==="ENOENT")return{};return{error:`Could not read OMP marketplace checkout ${e}: ${r instanceof Error?r.message:String(r)}`}}}async function _rt(e,t){if(e.sourceType==="url")return{error:`OMP marketplace '${e.name}' is not backed by a verifiable Git checkout`};let r=e.sourceType==="local"?e.sourceUri:Qv(e.catalogPath,"..");if(!nl(r))return{error:`OMP marketplace '${e.name}' checkout path is not absolute`};let i=xm(r,".git"),n=await v4(xm(i,"HEAD"),t);if(n.error)return{error:n.error};let o=n.contents?.trim();if(!o)return{error:`OMP marketplace '${e.name}' checkout has no readable HEAD`};if(/^[0-9a-f]{40,64}$/i.test(o))return{sha:o.toLowerCase()};let s=/^ref: (refs\/[A-Za-z0-9._/-]+)$/.exec(o)?.[1];if(!s||s.split("/").some((p)=>p==="."||p===".."))return{error:`OMP marketplace '${e.name}' checkout has an invalid HEAD`};let a=await v4(xm(i,...s.split("/")),t);if(a.error)return{error:a.error};let c=a.contents?.trim();if(c&&/^[0-9a-f]{40,64}$/i.test(c))return{sha:c.toLowerCase()};let l=await v4(xm(i,"packed-refs"),t);if(l.error)return{error:l.error};let u=l.contents?.split(/\r?\n/).map((p)=>p.trim().split(/\s+/,2)).find(([,p])=>p===s)?.[0];return u&&/^[0-9a-f]{40,64}$/i.test(u)?{sha:u.toLowerCase()}:{error:`OMP marketplace '${e.name}' checkout does not resolve HEAD`}}async function jde(e,t,r){let i=e.provenance.requestedRef,n=e.provenance.resolvedRef,o=e.provenance.resolvedSha;if(i&&i!==n)return`OMP marketplace requested ref '${i}' resolved as '${n??"unknown"}'`;if(n&&n!=="main")return`OMP CLI cannot enforce marketplace ref '${n}'`;if(!o)return i||n?`OMP marketplace ref '${i??n}' has no authoritative resolved revision`:null;if(!/^[0-9a-f]{40,64}$/i.test(o))return"OMP marketplace resolved revision is malformed";let s=await _rt(t,r);if(!s.sha)return s.error??`Could not verify OMP marketplace '${t.name}' revision`;return s.sha===o.toLowerCase()?null:`OMP marketplace '${t.name}' resolved revision does not match requested '${i??n??o}'`}function Bde(e){let t=e.roots?.data;return t&&nl(t)?xm(t,"marketplaces.json"):null}async function rl(e,t={}){let r=Bde(e);if(!r)return{success:!1,registryPath:"",marketplaces:[],missing:!1,error:"OMP operation context has no authoritative absolute data root"};let i=t.readFile??((u)=>zde(u,"utf8")),n=await Fde(r,i);if(n.error)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:n.error};if(n.missing)return t.allowMissing?{success:!0,registryPath:r,marketplaces:[],missing:!0}:{success:!1,registryPath:r,marketplaces:[],missing:!0,error:`OMP marketplace registry is missing: ${r}`};let o=vrt.safeParse(n.value);if(!o.success)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry has an unsupported or malformed version: ${r}`};let s=new Set,a=new Set,c=new Set,l=[];for(let u of o.data.marketplaces){if(!As(u.name))return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry contains an invalid name: ${r}`};let p=X0(u.sourceUri,u.sourceType,e);if(!p)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace '${u.name}' has an invalid or credential-bearing source identity`};let d=p.identity;if(s.has(u.name)||a.has(d)||c.has(u.catalogPath))return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry contains an ambiguous identity for '${u.name}'`};let f=await Fde(u.catalogPath,i);if(f.error||f.missing)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:f.error??`OMP marketplace catalog is missing: ${u.catalogPath}`};let m=Lde(f.value,u.catalogPath);if(!m.catalog)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:m.error??`Malformed OMP marketplace catalog: ${u.catalogPath}`};if(m.catalog.name!==u.name)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry name '${u.name}' conflicts with catalog name '${m.catalog.name}'`};s.add(u.name),a.add(d),c.add(u.catalogPath),l.push({name:u.name,sourceType:u.sourceType,sourceUri:p.source,sourceIdentity:d,catalogPath:u.catalogPath,catalog:m.catalog})}return{success:!0,registryPath:r,marketplaces:l,missing:!1}}function Prt(e){let t;try{if(!e.trim())throw Error("empty output");t=JSON.parse(e.replace(/^\uFEFF/,""))}catch(s){return{error:`OMP plugin inventory is not valid JSON: ${s instanceof Error?s.message:String(s)}`}}let r=wrt.safeParse(t);if(!r.success)return{error:"OMP plugin inventory has an unsupported shape"};let i=[],n=new Set,o=new Map;for(let s of r.data.marketplace){let a=s.entries[0];if(!Os(s.id)||s.entries.length!==1||!a)return{error:"OMP plugin inventory contains a malformed or ambiguous marketplace entry"};let c=`${s.scope}:${s.id}`;if(n.has(c))return{error:`OMP plugin inventory contains duplicate identity '${c}'`};if(n.add(c),a.scope!==s.scope)return{error:`OMP plugin inventory contains scope-conflicting details for '${c}'`};let l=o.get(a.installPath);if(l&&l!==c)return{error:`OMP plugin inventory reuses one install path for '${l}' and '${c}'`};o.set(a.installPath,c);let u=s.shadowedBy==="project";if(s.shadowedBy!==void 0&&!u)return{error:`OMP plugin inventory has an invalid shadow marker for '${c}'`};i.push({id:s.id,scope:s.scope,installPath:a.installPath,version:a.version,enabled:a.enabled!==!1,shadowedByProject:u})}for(let s of i){if(!s.shadowedByProject)continue;let a=i.find((c)=>c.id===s.id&&c.scope==="project");if(s.scope!=="user"||!a?.enabled)return{error:`OMP plugin inventory has an uncorroborated shadow marker for '${s.id}'`}}return{entries:i}}function qde(e){return Os(e.resolvedIdentity)}function Xv(e,t){if(e.client!=="omp")return`OMP adapter received context for '${e.client}'`;let r;try{r=b4(e.nativeScope)}catch(o){return o instanceof Error?o.message:String(o)}let i=t??r,n=i?`profile:${i}`:e.scope;if(e.nativeScope!==n)return`OMP native scope '${e.nativeScope}' conflicts with selected scope '${n}'`;if(i&&e.scope!=="user")return"OMP named profiles support only the AllAgents user scope";if(!nl(e.root))return"OMP operation context root must be absolute";if(!Bde(e))return"OMP operation context has no authoritative absolute data root";return null}function Crt(e,t,r){let i=Xv(t,r);if(i)return i;if(e.kind!=="plugin"||!qde(e))return"OMP mutation requires one valid marketplace plugin identity";if(e.context.client!==t.client||e.context.scope!==t.scope||e.context.nativeScope!==t.nativeScope||Qv(e.context.root)!==Qv(t.root))return"OMP resource context does not match the selected operation context";return null}function w4(e,t,r){let i=qde(e);if(!i)return{error:"OMP resource has no valid plugin identity"};let n=t.marketplaces.find((c)=>c.name===i.marketplace),o=e.provenance.marketplaceSource,s=o?$rt(o,void 0,r):null;if(o&&!s)return{error:`OMP marketplace source is invalid: ${o}`};if(!n){if(s){let c=t.marketplaces.find((l)=>l.sourceIdentity===s);if(c)return{error:`OMP marketplace source is already registered as '${c.name}', not '${i.marketplace}'`}}return{missing:!0,error:`OMP marketplace '${i.marketplace}' is not registered`}}if(s&&n.sourceIdentity!==s)return{error:`OMP marketplace '${i.marketplace}' is registered from a conflicting source`};if(n.catalog.plugins.filter((c)=>c.name===i.name).length!==1)return{error:`OMP catalog '${i.marketplace}' does not resolve exactly one plugin '${i.name}'`};return{marketplace:n}}class _m{client="omp";run;reader;profileName;versionResult;constructor(e={}){if(this.run=e.execute??Qn,this.reader=e.readFile??((t)=>zde(t,"utf8")),this.profileName=e.nativeScope?.name,this.profileName!==void 0)$m(this.profileName)}execute(e,t){let r=this.profileName??b4(t?.nativeScope);return this.run("omp",r?["--profile",r,...e]:e,brt(t))}async supportedVersion(e){if(this.versionResult)return this.versionResult;let t=await this.execute(["--version"],e);if(!t.success)return this.versionResult={success:!1,error:ap(t)},this.versionResult;let r=krt(t.output);if(!r)return this.versionResult={success:!1,error:`Could not parse OMP version: ${JSON.stringify(t.output)}`},this.versionResult;if(Ko(r,drt)<0)return this.versionResult={success:!1,error:`OMP ${r.join(".")} is unsupported; version 18.1.17 or newer is required`},this.versionResult;return this.versionResult={success:!0},this.versionResult}async isAvailable(e){if(e&&Xv(e,this.profileName))return!1;return(await this.supportedVersion(e)).success}supportsScope(e){return!0}resolveSource(e,t,r={}){let i=Os(e)??Srt(e);if(!i)return{success:!1,error:`OMP native install requires a valid plugin@marketplace source, not '${e}'`};return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:i.id,context:t,provenance:{...r,pluginName:i.name,marketplaceName:i.marketplace}}}}async inspect(e){let t=Xv(e,this.profileName);if(t)return{success:!1,resources:[],observations:[],error:t};let r=await this.supportedVersion(e);if(!r.success)return{success:!1,resources:[],observations:[],error:r.error??"OMP version inspection failed"};let i=await this.execute(["plugin","list","--json"],e);if(!i.success)return{success:!1,resources:[],observations:[],error:`Could not inspect OMP plugins: ${ap(i)}`};let n=Prt(i.output);if(!n.entries)return{success:!1,resources:[],observations:[],error:n.error??"Could not parse OMP plugin inventory"};let o=await rl(e,{readFile:this.reader,allowMissing:n.entries.length===0});if(!o.success)return{success:!1,resources:[],observations:[],error:o.error??"Could not inspect OMP marketplaces"};let s=[];for(let c of n.entries){let l=Os(c.id);if(!l)return{success:!1,resources:[],observations:s,error:`Installed OMP plugin '${c.id}' has invalid identity`};let u=o.marketplaces.find((m)=>m.name===l.marketplace);if(!u)return{success:!1,resources:[],observations:s,error:`Installed OMP plugin '${c.id}' references missing marketplace '${l.marketplace}'`};let p=u.catalog.plugins.filter((m)=>m.name===l.name),d=p[0];if(p.length!==1||!d)return{success:!1,resources:[],observations:s,error:`Installed OMP plugin '${c.id}' has no unambiguous catalog identity`};let f={kind:"plugin",requestedIdentity:c.id,resolvedIdentity:c.id,context:{...e,scope:c.scope,nativeScope:e.nativeScope.startsWith("profile:")?e.nativeScope:c.scope},provenance:{pluginName:l.name,marketplaceName:l.marketplace,marketplaceSource:u.sourceUri,installedVersion:c.version,installPath:c.installPath,...d.version&&{catalogVersion:d.version},...c.shadowedByProject&&{shadowedBy:"project"}}};s.push({resource:f,status:c.enabled?"installed":"disabled",installedPath:c.installPath})}let a=s.filter((c)=>c.resource.context.scope===e.scope);return{success:!0,resources:a.filter((c)=>c.status==="installed").map((c)=>c.resource),observations:a}}async inspectForMutation(e,t){let r=Crt(e,t,this.profileName);if(r)return{error:r};let i=await this.inspect(t);if(!i.success)return{error:i.error??"Could not inspect OMP native state"};if(i.observations?.find((o)=>o.resource.resolvedIdentity===e.resolvedIdentity&&o.status==="disabled"))return{error:`OMP plugin '${e.resolvedIdentity}' is installed but disabled in ${t.scope} scope`};return{inspection:i}}async registry(e,t){return rl(e,{readFile:this.reader,allowMissing:t})}async registerMarketplace(e,t){let r=Xv(t,this.profileName);if(r)return{success:!1,error:r};if(!As(e.name))return{success:!1,error:`Invalid OMP marketplace name '${e.name}'`};let i=X0(e.source,void 0,t);if(!i)return{success:!1,error:`OMP marketplace source is invalid: ${e.source}`};let n=await this.registry(t,!0);if(!n.success)return{success:!1,error:n.error??"Could not inspect OMP marketplace registrations"};let o=n.marketplaces.find(({name:u})=>u===e.name);if(o)return o.sourceIdentity===i.identity?{success:!0}:{success:!1,error:`OMP marketplace '${e.name}' is registered from a conflicting source`};let s=n.marketplaces.find(({sourceIdentity:u})=>u===i.identity);if(s)return{success:!1,error:`OMP marketplace source is already registered as '${s.name}', not '${e.name}'`};let a=await this.execute(["plugin","marketplace","add",e.source],t);if(!a.success)return{success:!1,error:`Could not register OMP marketplace '${e.source}': ${ap(a)}`};let c=await this.registry(t,!1);if(!c.success)return{success:!1,registrations:[e.source],error:`OMP marketplace registration completed but could not be verified: ${c.error??"registry inspection failed"}`};let l=c.marketplaces.find(({name:u})=>u===e.name);if(!l||l.sourceIdentity!==i.identity)return{success:!1,registrations:[e.source],error:`OMP marketplace registration completed with an unexpected identity for '${e.name}'`};return{success:!0,registrations:[e.source]}}async removeMarketplaceRegistration(e,t){let r=Xv(t,this.profileName);if(r)return{success:!1,error:r};if(!b4(t.nativeScope))return{success:!1,error:"OMP marketplace registration cleanup requires a named profile"};if(!As(e))return{success:!1,error:`Invalid OMP marketplace name '${e}'`};let i=await this.inspect(t);if(!i.success)return{success:!1,error:i.error??"Could not inspect OMP profile marketplace usage"};let n=i.observations?.find(({resource:c})=>c.provenance.marketplaceName===e);if(n)return{success:!1,error:`OMP marketplace '${e}' is still referenced by '${n.resource.resolvedIdentity}'`};let o=await this.registry(t,!0);if(!o.success)return{success:!1,error:o.error??"Could not inspect OMP marketplace registrations"};if(!o.marketplaces.some(({name:c})=>c===e))return{success:!0};let s=await this.execute(["plugin","marketplace","remove",e],t);if(!s.success)return{success:!1,error:`Could not remove OMP marketplace '${e}': ${ap(s)}`};let a=await this.registry(t,!0);if(!a.success)return{success:!1,error:a.error??`OMP marketplace '${e}' removal could not be verified`};return a.marketplaces.some(({name:c})=>c===e)?{success:!1,error:`OMP marketplace '${e}' remains registered after removal`}:{success:!0}}async install(e,t){let r=await this.inspectForMutation(e,t);if(!r.inspection)return{success:!1,error:r.error??"OMP preflight failed"};let i=await this.registry(t,!0);if(!i.success)return{success:!1,error:i.error??"OMP marketplace inspection failed"};let n=w4(e,i,t),o=r.inspection.resources.some((u)=>u.resolvedIdentity===e.resolvedIdentity);if(o&&!n.marketplace)return{success:!1,error:n.error??"OMP marketplace identity is unresolved"};let s=[];if(!n.marketplace){let u=e.provenance.marketplaceSource,p=e.provenance.marketplaceName;if(!u||!p||!n.missing)return{success:!1,error:n.error??"OMP marketplace identity is unresolved"};let d=await this.registerMarketplace({name:p,source:u},t);if(!d.success)return d;if(s.push(...d.registrations??[]),i=await this.registry(t,!1),!i.success)return{success:!1,error:i.error??"OMP marketplace registration verification failed",...s.length>0&&{registrations:s}};if(n=w4(e,i,t),!n.marketplace)return{success:!1,error:n.error??"OMP marketplace registration has an unexpected identity",...s.length>0&&{registrations:s}}}let a=n.marketplace?await jde(e,n.marketplace,this.reader):"OMP marketplace identity is unresolved";if(a)return{success:!1,error:a,...s.length>0&&{registrations:s}};if(o)return{success:!0};let c=await this.execute(["plugin","install","--scope",t.scope,e.resolvedIdentity],t);if(!c.success)return{success:!1,error:`Could not install OMP plugin '${e.resolvedIdentity}': ${ap(c)}`,...s.length>0&&{registrations:s}};let l=await this.inspect(t);if(!l.success||!l.resources.some((u)=>u.resolvedIdentity===e.resolvedIdentity))return{success:!1,error:l.error??`OMP install completed but '${e.resolvedIdentity}' is absent from ${t.scope} inventory`,...s.length>0&&{registrations:s}};return{success:!0,...s.length>0&&{registrations:s}}}async update(e,t,r){if(e.resolvedIdentity!==t.resolvedIdentity)return{success:!1,error:`Refusing OMP targeted update from '${t.resolvedIdentity}' to '${e.resolvedIdentity}'`};let i=await this.inspectForMutation(e,r);if(!i.inspection)return{success:!1,error:i.error??"OMP preflight failed"};if(!i.inspection.resources.some((l)=>l.resolvedIdentity===e.resolvedIdentity))return{success:!1,error:`OMP plugin '${e.resolvedIdentity}' is not installed in ${r.scope} scope`};let n=await this.registry(r,!1);if(!n.success)return{success:!1,error:n.error??"OMP marketplace inspection failed"};let o=w4(e,n,r);if(!o.marketplace)return{success:!1,error:o.error??"OMP marketplace identity is unresolved"};let s=await jde(e,o.marketplace,this.reader);if(s)return{success:!1,error:s};let a=await this.execute(["plugin","upgrade","--scope",r.scope,e.resolvedIdentity],r);if(!a.success)return{success:!1,error:`Could not upgrade OMP plugin '${e.resolvedIdentity}': ${ap(a)}`};let c=await this.inspect(r);return c.success&&c.resources.some((l)=>l.resolvedIdentity===e.resolvedIdentity)?{success:!0}:{success:!1,error:c.error??`OMP upgrade completed but '${e.resolvedIdentity}' is absent from ${r.scope} inventory`}}async remove(e,t){let r=await this.inspectForMutation(e,t);if(!r.inspection)return{success:!1,error:r.error??"OMP preflight failed"};if(!r.inspection.resources.some((o)=>o.resolvedIdentity===e.resolvedIdentity))return{success:!0};let i=await this.execute(["plugin","uninstall","--scope",t.scope,e.resolvedIdentity],t);if(!i.success)return{success:!1,error:`Could not uninstall OMP plugin '${e.resolvedIdentity}': ${ap(i)}`};let n=await this.inspect(t);if(!n.success)return{success:!1,error:n.error??"OMP removal verification failed"};if(n.resources.some((o)=>o.resolvedIdentity===e.resolvedIdentity))return{success:!1,error:`OMP uninstall completed but '${e.resolvedIdentity}' remains in ${t.scope} inventory`};return{success:!0}}}var drt,frt,mrt,J0,grt,hrt,yrt,vrt,wrt;var $4=R(()=>{Ac();vo();drt=[18,1,17],frt=/^[a-z0-9](?:[a-z0-9.-]{0,62}[a-z0-9])?$/,mrt=/^([^/\s]+)\/([^/\s]+)$/,J0=/[\0\r\n]/,grt=/(?:^|[-_.])(auth|credential|key|password|secret|signature|token)(?:$|[-_.])/i,hrt=S.union([S.string().refine((e)=>e.startsWith("./")&&!J0.test(e)),S.object({source:S.literal("github"),repo:S.string().min(1).refine((e)=>S4(e)!==null),ref:S.string().min(1).optional(),sha:S.string().min(1).optional()}).passthrough(),S.object({source:S.literal("url"),url:S.string().url().refine(Nde),ref:S.string().min(1).optional(),sha:S.string().min(1).optional()}).passthrough(),S.object({source:S.literal("git-subdir"),url:S.string().min(1).refine(Nde),path:S.string().min(1).refine((e)=>!nl(e)&&!e.split(/[\\/]/).includes("..")&&!J0.test(e)),ref:S.string().min(1).optional(),sha:S.string().min(1).optional()}).passthrough(),S.object({source:S.literal("npm"),package:S.string().min(1),version:S.string().min(1).optional(),registry:S.string().min(1).optional()}).passthrough()]),yrt=S.object({name:S.string(),owner:S.object({name:S.string().min(1)}).passthrough(),plugins:S.array(S.object({name:S.string(),source:hrt,version:S.string().min(1).optional()}).passthrough())}).passthrough(),vrt=S.object({version:S.literal(1),marketplaces:S.array(S.object({name:S.string(),sourceType:S.enum(["github","git","url","local"]),sourceUri:S.string().min(1),catalogPath:S.string().refine(nl),addedAt:S.string().refine(Y0),updatedAt:S.string().refine(Y0)}).passthrough())}).passthrough(),wrt=S.object({npm:S.array(S.object({}).passthrough()),marketplace:S.array(S.object({id:S.string(),scope:S.enum(["user","project"]),entries:S.array(S.object({scope:S.enum(["user","project"]),installPath:S.string().refine(nl),version:S.string().min(1),installedAt:S.string().refine(Y0),lastUpdated:S.string().refine(Y0),enabled:S.boolean().optional(),gitCommitSha:S.string().optional()}).passthrough()),shadowedBy:S.literal("project").optional()}).passthrough())}).passthrough()});import{homedir as Ert}from"node:os";import{dirname as Rrt,isAbsolute as Hde,join as ko,resolve as ja,win32 as Wde}from"node:path";import{readFile as I4,realpath as Irt,stat as R4}from"node:fs/promises";import{fileURLToPath as Art}from"node:url";function Pm(e){return ja(e.cwd??process.cwd())}function A4(e){let t=e.roots?.agent;if(t)return ja(t);if(e.scope==="user")return ja(e.root);let r=Pm(e),i=e.env?.PI_CODING_AGENT_DIR;if(i){if(i==="~")return rP(e);if(i.startsWith("~/")||i.startsWith("~\\"))return ja(rP(e),i.slice(2));return ja(r,i)}return ko(rP(e),".pi","agent")}function rP(e){return ja(e.env?.HOME??e.env?.USERPROFILE??Ert())}function Drt(e){return e.scope==="user"?A4(e):ko(Pm(e),".pi")}function Q0(e){return{cwd:Pm(e),...e.env&&{env:e.env}}}function _4(e){if(e.error)return e.error;if(e.signal)return`Pi CLI terminated by ${e.signal}`;return`Pi CLI exited with code ${e.exitCode??"unknown"}`}function Mrt(e){if(!e.startsWith("npm:"))return null;let t=e.slice(4).trim(),r=t.startsWith("@")?/^(@[^/@\s]+\/[^/@\s]+)(?:@([^\s]+))?$/.exec(t):/^([^/@\s]+)(?:@([^\s]+))?$/.exec(t);if(!r?.[1])return null;let i=r[1],n;try{n=decodeURIComponent(i)}catch{return null}if(n.includes("\x00")||n.includes("\\")||n.split("/").some((s)=>s==="."||s==="..")||n.split("/").length!==i.split("/").length)return null;let o=r[2];return{kind:"npm",requested:e,resolvedIdentity:`npm:${i}${o?`@${o}`:""}`,packageIdentity:`npm:${i}`,commandSource:`npm:${i}${o?`@${o}`:""}`,packageName:i}}function P4(e,t){let r;try{r=decodeURIComponent(e)}catch{return!0}for(let i of[e,r])if(i.length===0||i.includes("\x00")||i.includes("\\")||i.startsWith("/")||!t&&i.includes("/")||i.split("/").includes(".."))return!0;return!1}function Nrt(e){let t=e.indexOf("@");if(t<0)return{path:e};let r=e.slice(0,t),i=e.slice(t+1);return r&&i?{path:r,ref:i}:null}function C4(e,t,r){let i=Nrt(r.replace(/^\/+/,""));if(!i)return null;let n=i.path.replace(/\.git$/,"").replace(/\/$/,""),o=t.toLowerCase();if(P4(o,!1)||P4(n,!0)||n.split("/").length<2||i.ref&&P4(i.ref,!0))return null;let s=`${o}/${n}`;return{kind:"git",requested:e,resolvedIdentity:`git:${s}${i.ref?`@${i.ref}`:""}`,packageIdentity:`git:${s}`,commandSource:e,host:o,repositoryPath:n}}function Frt(e){let t=e.startsWith("git:"),r=(t?e.slice(4):e).trim();if(!r)return null;let i=/^git@([^:]+):(.+)$/.exec(r);if(i?.[1]&&i[2])return C4(e,i[1],i[2]);if(/^(?:https?|ssh|git):\/\//i.test(r))try{let s=new URL(r);if(s.password||s.username&&!(s.protocol==="ssh:"&&s.username==="git")||s.search||s.hash)return null;return C4(e,s.hostname,s.pathname)}catch{return null}if(!t)return null;let n=r.indexOf("/");if(n<=0)return null;let o=r.slice(0,n);if(!o.includes(".")&&o!=="localhost")return null;return C4(e,o,r.slice(n+1))}function jrt(e,t){if(e==="~")return t;if(e.startsWith("~/")||e.startsWith("~\\"))return ko(t,e.slice(2));return e}function zrt(e,t){let r=e.startsWith("file://"),i;try{i=r?Art(e):jrt(e,rP(t))}catch{return null}if(!r&&!Hde(i)&&!Wde.isAbsolute(i)&&!i.startsWith("./")&&!i.startsWith("../")&&!i.startsWith(".\\")&&!i.startsWith("..\\"))return null;let n=ja(Pm(t),i);return{kind:"local",requested:e,resolvedIdentity:`local:${n}`,packageIdentity:`local:${n}`,commandSource:n,localPath:n}}function tw(e,t,r={}){let i=e.trim();if(!i)return null;let n=Mrt(i);if(n)return n;let o=Frt(i);if(o)return o;let s=r.baseDir?{...t,cwd:r.baseDir}:t;return zrt(i,s)}function Urt(e,t){if(typeof e==="string"&&e.trim())return{source:e.trim()};if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`packages[${t}] must be a source string or object`);let r=e;if(typeof r.source!=="string"||!r.source.trim())throw Error(`packages[${t}].source must be a non-empty string`);if(r.autoload!==void 0&&typeof r.autoload!=="boolean")throw Error(`packages[${t}].autoload must be a boolean`);let i={source:r.source.trim()};if(typeof r.autoload==="boolean")i.autoload=r.autoload;for(let n of nP){let o=r[n];if(o===void 0)continue;if(!Array.isArray(o)||o.some((s)=>typeof s!=="string"))throw Error(`packages[${t}].${n} must be an array of strings`);i[n]=[...o]}return i}async function rw(e){let t;try{t=await I4(e,"utf8")}catch(o){if(o.code==="ENOENT")return{packages:[],defaultProjectTrust:"ask"};throw Error(`Could not read Pi settings ${e}: ${o instanceof Error?o.message:String(o)}`)}let r;try{r=JSON.parse(t.replace(/^\uFEFF/,""))}catch(o){throw Error(`Could not parse Pi settings ${e}: ${o instanceof Error?o.message:String(o)}`)}if(!r||typeof r!=="object"||Array.isArray(r))throw Error(`Invalid Pi settings ${e}: expected an object`);let i=r;if(i.packages!==void 0&&!Array.isArray(i.packages))throw Error(`Invalid Pi settings ${e}: packages must be an array`);let n=i.defaultProjectTrust??"ask";if(n!=="ask"&&n!=="always"&&n!=="never")throw Error(`Invalid Pi settings ${e}: defaultProjectTrust must be ask, always, or never`);return{packages:(i.packages??[]).map(Urt),defaultProjectTrust:n}}async function eP(e){try{return await Irt(ja(e))}catch(t){if(t.code==="ENOENT")return ja(e);throw t}}async function iP(e){let t=A4(e),r,i;try{r=await eP(e.root),i=await eP(t)}catch(d){return{status:"inspection-failed",allowed:!1,error:`Could not canonicalize Pi trust boundary: ${d instanceof Error?d.message:String(d)}`}}if(Or(r,i))return{status:"denied",allowed:!1,error:"Pi project trust cannot be authorized from an agent root inside the project boundary"};let n=ko(t,"settings.json"),o;try{o=await rw(n)}catch(d){return{status:"inspection-failed",allowed:!1,error:d instanceof Error?d.message:String(d)}}let s=ko(t,"trust.json"),a;try{a=await I4(s,"utf8")}catch(d){if(d.code!=="ENOENT")return{status:"inspection-failed",allowed:!1,error:`Could not read Pi trust store ${s}: ${d instanceof Error?d.message:String(d)}`};a="{}"}let c;try{c=JSON.parse(a.replace(/^\uFEFF/,""))}catch(d){return{status:"inspection-failed",allowed:!1,error:`Could not parse Pi trust store ${s}: ${d instanceof Error?d.message:String(d)}`}}if(!c||typeof c!=="object"||Array.isArray(c))return{status:"inspection-failed",allowed:!1,error:`Invalid Pi trust store ${s}: expected an object`};let l;try{l=await eP(Pm(e))}catch(d){return{status:"inspection-failed",allowed:!1,error:`Could not canonicalize Pi project cwd: ${d instanceof Error?d.message:String(d)}`}}let u=new Map;for(let[d,f]of Object.entries(c)){if(f!==!0&&f!==!1&&f!==null)return{status:"inspection-failed",allowed:!1,error:`Invalid Pi trust store ${s}: decision for ${JSON.stringify(d)} must be true, false, or null`};if(!Hde(d)&&!Wde.isAbsolute(d))return{status:"ambiguous",allowed:!1,error:`Pi trust store contains non-absolute path ${JSON.stringify(d)}`};let m;try{m=await eP(d)}catch(h){return{status:"inspection-failed",allowed:!1,error:`Could not canonicalize Pi trust path ${JSON.stringify(d)}: ${h instanceof Error?h.message:String(h)}`}}let g=u.get(m);if(g!==void 0&&f!==null&&g!==null&&g!==f)return{status:"ambiguous",allowed:!1,error:`Pi trust store has conflicting decisions for ${m}`};if(g===void 0||f!==null)u.set(m,f)}let p=l;while(!0){let d=u.get(p);if(d===!0||d===!1)return{status:d?"allowed":"denied",allowed:d,source:"saved",matchedPath:p,...!d&&{error:`Pi project trust is denied by saved decision ${p}`}};let f=Rrt(p);if(f===p)break;p=f}if(o.defaultProjectTrust==="always")return{status:"allowed",allowed:!0,source:"default"};if(o.defaultProjectTrust==="never")return{status:"denied",allowed:!1,source:"default",error:"Pi defaultProjectTrust is never"};return{status:"ask",allowed:!1,source:"default",error:"Pi project trust requires confirmation. Trust this project in Pi before running native package operations."}}function Lrt(e){if(e.autoload===!1)return!nP.some((t)=>(e[t]??[]).some((r)=>r.length>0&&!r.startsWith("!")&&!r.startsWith("-")));return nP.every((t)=>e[t]!==void 0&&e[t]?.length===0)}function Brt(e,t){if(e.kind==="npm")return ko(t,"npm","node_modules",e.packageName??"");if(e.kind==="git")return ko(t,"git",e.host??"",e.repositoryPath??"");return e.localPath??""}async function qrt(e,t){let r;try{r=await R4(t)}catch(o){return{status:"unusable",error:`Could not inspect installed Pi package ${t}: ${o instanceof Error?o.message:String(o)}`}}if(r.isFile())return e.kind==="local"&&/\.(?:[cm]?[jt]s)$/.test(t)?{status:"installed"}:{status:"unusable",error:`Pi package path is not a directory: ${t}`};if(!r.isDirectory())return{status:"unusable",error:`Pi package path is not a directory: ${t}`};let i=ko(t,"package.json"),n;try{n=await I4(i,"utf8")}catch(o){if(o.code==="ENOENT"){if(e.kind==="npm")return{status:"unusable",error:`Installed npm package has no manifest: ${i}`};for(let s of nP)try{if((await R4(ko(t,s))).isDirectory())return{status:"installed"}}catch{}return{status:"unusable",error:`Installed Pi package has no manifest or conventional resources: ${t}`}}return{status:"unusable",error:`Could not read installed Pi package manifest ${i}: ${o instanceof Error?o.message:String(o)}`}}try{let o=JSON.parse(n.replace(/^\uFEFF/,""));if(!o||typeof o!=="object"||Array.isArray(o))throw Error("expected an object");let s=o.name;if(typeof s!=="string"||!s)throw Error("missing package name");if(e.kind==="npm"&&s!==e.packageName)throw Error(`manifest name ${JSON.stringify(s)} does not match ${JSON.stringify(e.packageName)}`);return{status:"installed"}}catch(o){return{status:"unusable",error:`Invalid installed Pi package manifest ${i}: ${o instanceof Error?o.message:String(o)}`}}}async function tP(e){if(e.scope==="project"){let o=await iP(e);if(!o.allowed)return{success:!1,resources:[],observations:[],error:o.error??`Pi project trust is ${o.status}`}}let t=Drt(e),r;try{r=await rw(ko(t,"settings.json"))}catch(o){return{success:!1,resources:[],observations:[],error:o instanceof Error?o.message:String(o)}}let i=[],n=new Set;for(let o of r.packages){let s=tw(o.source,e,{baseDir:t});if(!s)return{success:!1,resources:[],observations:i,error:`Unsupported Pi package source in ${ko(t,"settings.json")}: ${o.source}`};if(n.has(s.packageIdentity))return{success:!1,resources:[],observations:i,error:`Ambiguous duplicate Pi package identity ${s.packageIdentity} in ${ko(t,"settings.json")}`};n.add(s.packageIdentity);let a=Brt(s,t),c={kind:"package",requestedIdentity:o.source,resolvedIdentity:s.resolvedIdentity,context:e,provenance:{sourceType:s.kind,packageIdentity:s.packageIdentity,commandSource:s.commandSource,installedPath:a}},l=!0;try{await R4(a)}catch(p){if(p.code==="ENOENT")l=!1;else{i.push({resource:c,status:"unusable",installedPath:a,error:`Could not inspect Pi package path ${a}: ${p instanceof Error?p.message:String(p)}`});continue}}if(!l){i.push({resource:c,status:"configured-missing",installedPath:a});continue}let u=await qrt(s,a);if(u.status==="unusable"){i.push({resource:c,status:"unusable",installedPath:a,...u.error&&{error:u.error}});continue}i.push({resource:c,status:Lrt(o)?"disabled":"installed",installedPath:a})}return{success:!0,resources:i.filter((o)=>o.status==="installed").map((o)=>o.resource),observations:i}}function Vrt(e){let t=/(?:^|\s)(\d+)\.(\d+)\.(\d+)(?:[-+\s]|$)/.exec(e.trim());return t?.[1]&&t[2]&&t[3]?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function ew(e){return e.provenance.commandSource??e.requestedIdentity}function Vde(e,t){return e.provenance.packageIdentity??tw(ew(e),t)?.packageIdentity}function E4(e,t,r){return r.scope==="project"?[e,t,"-l","--approve"]:[e,t,"--no-approve"]}class il{client="pi";run;constructor(e={}){this.run=e.execute??Qn}async isAvailable(e){let t=await this.run("pi",["--version"],e?Q0(e):void 0);if(!t.success)return!1;let r=Vrt(t.output);return Boolean(r&&Ko(r,Ort)>=0&&Ko(r,Trt)<0)}supportsScope(e){return!0}resolveSource(e,t,r={}){let i=tw(e,t);if(!i)return{success:!1,error:`Pi native install does not support source '${e}'`};return{success:!0,resource:{kind:"package",requestedIdentity:e,resolvedIdentity:i.resolvedIdentity,context:t,provenance:{...r,sourceType:i.kind,packageIdentity:i.packageIdentity,commandSource:i.commandSource}}}}inspect(e){return tP(e)}async preflightMutation(e,t){let r=await tP(t);if(!r.success)return r.error??"Could not inspect Pi packages";let i=Vde(e,t);if(!i)return"Pi package resource has no valid package identity";let n=r.observations?.find((o)=>o.resource.provenance.packageIdentity===i);if(n?.status==="disabled")return`${i} is configured but disabled in Pi settings; enable it with pi config before syncing`;if(n?.status==="unusable")return n.error??`${i} is unusable in Pi settings`;return null}async install(e,t){let r=await this.preflightMutation(e,t);if(r)return{success:!1,error:r};let i=await this.run("pi",E4("install",ew(e),t),Q0(t));return i.success?{success:!0}:{success:!1,error:_4(i)}}async update(e,t,r){let i=await this.preflightMutation(e,r);if(i)return{success:!1,error:i};let n=Vde(e,r);if(!n)return{success:!1,error:"Pi package resource has no valid package identity"};let o={...r,scope:r.scope==="user"?"project":"user",nativeScope:r.scope==="user"?"project":"user",root:r.scope==="user"?Pm(r):A4(r)};if(o.scope==="project"){if((await iP(o)).allowed){let l=await tP(o);if(!l.success)return{success:!1,error:`Could not prove Pi update scope isolation: ${l.error??"opposite scope inspection failed"}`};if(l.observations?.some((u)=>u.resource.provenance.packageIdentity===n))return{success:!1,error:`Refusing targeted Pi update for ${n}: the same package is configured in both user and project scopes`}}}else{let c=await tP(o);if(!c.success)return{success:!1,error:`Could not prove Pi update scope isolation: ${c.error??"opposite scope inspection failed"}`};if(c.observations?.some((l)=>l.resource.provenance.packageIdentity===n))return{success:!1,error:`Refusing targeted Pi update for ${n}: the same package is configured in both user and project scopes`}}let s;if(e.resolvedIdentity!==t.resolvedIdentity)s=E4("install",ew(e),r);else s=["update",ew(e),r.scope==="project"?"--approve":"--no-approve"];let a=await this.run("pi",s,Q0(r));return a.success?{success:!0}:{success:!1,error:_4(a)}}async remove(e,t){if(t.scope==="project"){let i=await iP(t);if(!i.allowed)return{success:!1,error:i.error??`Pi project trust is ${i.status}`}}let r=await this.run("pi",E4("remove",ew(e),t),Q0(t));return r.success?{success:!0}:{success:!1,error:_4(r)}}}var Ort,Trt,nP;var oP=R(()=>{vo();Gu();Ort=[0,85,1],Trt=[0,86,0],nP=["extensions","skills","prompts","themes"]});import{relative as Hrt,resolve as Cm}from"node:path";import{readFile as Gde,realpath as Wrt,stat as Grt}from"node:fs/promises";function Krt(e,t){return e.packages.find((r)=>r.source===t)}function Jrt(e){return(/^[!+-]/.test(e)?e.slice(1):e).replace(/^\.\//,"").replaceAll("\\","/")}function nw(e,t){let r=e.replaceAll("\\","/"),i=Jrt(t),n=r.split("/").at(-1)??r;return T4.default.isMatch(r,[i])||T4.default.isMatch(n,[i])}function Yrt(e,t){let r=e.extensions;if(e.autoload===!1){let o=!1;for(let s of r??[]){if(!nw(t,s))continue;o=!s.startsWith("!")&&!s.startsWith("-")}return o}if(r===void 0)return!0;if(r.length===0)return!1;let i=r.filter((o)=>!/^[!+-]/.test(o)),n=i.length===0||i.some((o)=>nw(t,o));if(r.some((o)=>o.startsWith("!")&&nw(t,o)))n=!1;if(r.some((o)=>o.startsWith("+")&&nw(t,o)))n=!0;if(r.some((o)=>o.startsWith("-")&&nw(t,o)))n=!1;return n}async function O4(e){return await Grt(e),Wrt(e)}function An(e,t,r={}){return{classification:"inspection-failed",root:e,...r,error:t}}function Xrt(e){if(e.resource.provenance.packageIdentity===Zrt)return!0;let r=e.resource.requestedIdentity;return/(?:^|[\\/])pi-mcp-adapter(?:\.git)?(?:@[^\\/]*)?$/.test(r)}async function D4(e){let t=Cm(e),r={client:"pi",scope:"user",nativeScope:"user",root:t,cwd:t,roots:{agent:t}},i;try{i=await rw(Cm(t,"settings.json"))}catch(y){return An(t,y instanceof Error?y.message:String(y))}let n=await new il().inspect(r);if(!n.success)return An(t,n.error??"Could not inspect selected Pi root");let o=[];for(let y of n.observations??[]){if(Xrt(y)){o.push(y);continue}if(!y.installedPath||y.status==="configured-missing")continue;try{let v=JSON.parse(await Gde(Cm(y.installedPath,"package.json"),"utf8"));if(v&&typeof v==="object"&&!Array.isArray(v)&&v.name===sP)o.push(y)}catch{}}if(o.length===0)return{classification:"absent",root:t};if(o.length>1)return An(t,"Multiple configured packages resolve to pi-mcp-adapter");let s=o[0];if(!s)return{classification:"absent",root:t};let a=s.resource.requestedIdentity,c=s.installedPath;if(!c||s.status==="configured-missing")return{classification:"configured-missing",root:t,packageSource:a,...c&&{packagePath:c}};if(s.status==="unusable")return An(t,s.error??"Configured adapter package is unusable",{packageSource:a,packagePath:c});let l,u;try{l=await O4(t),u=await O4(c)}catch(y){return An(t,`Could not resolve selected Pi package path: ${y instanceof Error?y.message:String(y)}`,{packageSource:a,packagePath:c})}if(!Or(l,u))return An(t,"Configured pi-mcp-adapter package escapes the selected Pi root",{packageSource:a,packagePath:c});let p=Cm(c,"package.json"),d;try{let y=JSON.parse(await Gde(p,"utf8"));if(!y||typeof y!=="object"||Array.isArray(y))throw Error("expected an object");d=y}catch(y){return An(t,`Could not parse pi-mcp-adapter manifest: ${y instanceof Error?y.message:String(y)}`,{packageSource:a,packagePath:c,manifestPath:p})}if(d.name!==sP)return An(t,`Configured adapter manifest name is not ${sP}`,{packageSource:a,packagePath:c,manifestPath:p});if(typeof d.version!=="string"||!d.version)return An(t,"Configured pi-mcp-adapter manifest has no version",{packageSource:a,packagePath:c,manifestPath:p});let f=d.pi;if(!f||typeof f!=="object"||Array.isArray(f))return An(t,"Configured pi-mcp-adapter manifest has no Pi resource declaration",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let m=f.extensions;if(!Array.isArray(m)||m.length===0||m.some((y)=>typeof y!=="string"||!y))return An(t,"Configured pi-mcp-adapter manifest has no valid extension path",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let g=Krt(i,a);if(!g)return An(t,"Configured adapter entry disappeared during inspection",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let h;for(let y of m){if(/[*?]/.test(y)||/^[!+-]/.test(y))return An(t,"pi-mcp-adapter extension path must resolve unambiguously",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let v=Cm(c,y);if(!Or(Cm(c),v))return An(t,"pi-mcp-adapter extension path escapes its package",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let w;try{w=await O4(v)}catch(b){return An(t,`Could not resolve pi-mcp-adapter extension: ${b instanceof Error?b.message:String(b)}`,{packageSource:a,packagePath:c,manifestPath:p,version:d.version})}if(!Or(u,w)||!Or(l,w))return An(t,"pi-mcp-adapter extension escapes the selected Pi root",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let _=Hrt(c,v).replaceAll("\\","/");if(Yrt(g,_))h=w}if(s.status==="disabled"||!h)return{classification:"installed-disabled",root:t,packageSource:a,packagePath:c,manifestPath:p,version:d.version};return{classification:"usable",root:t,packageSource:a,packagePath:c,manifestPath:p,version:d.version,extensionPath:h}}var T4,sP="pi-mcp-adapter",Zrt;var Zde=R(()=>{Gu();oP();T4=Nt(x0(),1),Zrt=`npm:${sP}`});function Ts(e){switch(e){case"claude":return new vm;case"copilot":return new bm;case"codex":return new Sm;case"pi":return new il;case"omp":return new _m;default:return null}}var Kde=R(()=>{f4();g4();y4();oP();$4()});var za=R(()=>{vo();f4();g4();y4();$4();oP();Zde();Kde()});import{existsSync as efe,lstatSync as Jde,mkdirSync as Qrt,readdirSync as Yde,rmSync as Xde,writeFileSync as ent}from"node:fs";import{readdir as tnt,readFile as rnt}from"node:fs/promises";import{basename as Qde,join as Em,relative as nnt,resolve as int}from"node:path";function M4(e,t){return e<t?-1:e>t?1:0}function aP(e){let t=e.replaceAll("\\","/");if(t.includes("/.pi/skills/")||t.includes("/.omp/skills/"))return 0;if(t.includes("/.agent/skills/")||t.includes("/.agents/skills/"))return 1;return 2}async function ont(e,t){if(t.disabled)return[];let r=new Set,i=t.clients?.some((c)=>c==="pi"||c==="omp")??!1;if(t.skillPaths)for(let c of t.skillPaths)r.add(Lr(e,c));else if(t.clients)for(let c of t.clients){if(c==="pi"||c==="omp"){let u=LL(c,"project",{cwd:e,repoRoot:e});for(let p of u.skillDiscoveryRoots)r.add(p);continue}let l=lr[c];if(l?.skillsPath)r.add(Lr(e,l.skillsPath))}let n=[],o=new Set,s=new Set,a=[...r].sort((c,l)=>i?aP(`${c}/`)-aP(`${l}/`)||M4(c,l):M4(c,l));for(let c of a){let l=c;try{if(Jde(l).isSymbolicLink())continue}catch{continue}let u;try{u=(await tnt(l,{withFileTypes:!0})).sort((p,d)=>M4(p.name,d.name))}catch{continue}for(let p of u){if(!p.isDirectory())continue;let d=Em(l,p.name);try{if(Jde(d).isSymbolicLink())continue}catch{continue}let f=Em(d,"SKILL.md");if(!efe(f))continue;let m=nnt(e,f);if(o.has(m))continue;try{let g=await rnt(f,"utf-8"),h=Bi(g);if(!h)continue;if(i&&s.has(h.name))continue;o.add(m),s.add(h.name),n.push({name:h.name,description:h.description,relativePath:m,fileSize:g.length})}catch{}}}return n}async function cP(e,t,r){let i=r.some((o)=>o==="pi"||o==="omp"),n=new Map;for(let o of t){if(o.skills===!1||o.skills===void 0)continue;let s=int(e,o.path),a=Array.isArray(o.skills)?{skillPaths:o.skills}:{clients:r},c=await ont(s,a);for(let l of c){let p=`${o.path.replace(/[/\\]+$/,"")}/${l.relativePath}`.replace(/\\/g,"/"),d={repoPath:o.path,name:l.name,description:l.description,location:p,fileSize:l.fileSize},f=n.get(l.name);if(!f){n.set(l.name,d);continue}let m=f.location.includes(".agents/"),g=d.location.includes(".agents/");if(i){let h=aP(f.location),y=aP(d.location);if(y<h||y===h&&d.fileSize>f.fileSize)n.set(l.name,d)}else if(g&&!m)n.set(l.name,d);else if(!g&&m);else if(d.fileSize>f.fileSize)n.set(l.name,d)}}return[...n.values()].map(({fileSize:o,...s})=>s)}function lP(e,t){if(t.size===0)return{writtenFiles:[],refs:[]};let r=Em(e,".allagents","skills-index");Qrt(r,{recursive:!0});let i=[],n=[];for(let[,{repoName:o,skills:s}]of t){let a=s.map((u)=>`<skill>
|
|
486
|
+
`,"utf-8");return{copyResults:[{source:"copilot-plugin-hooks",destination:s,action:"generated"}],warnings:i}}var q0=".github/hooks/allagents.json",dtt;var Sde=R(()=>{hm();dtt=["hooks.json","hooks/hooks.json"]});import{existsSync as wtt}from"node:fs";import{mkdir as btt}from"node:fs/promises";import{dirname as ktt,resolve as Stt}from"node:path";function xtt(e){if(e.startsWith("~/")||e==="~")return e.replace("~",ye());return e}function $tt(e){if(e===void 0||e===!1)return!1;return!0}function _tt(e){if(e===!0||e==="sync")return!0;return!1}function Ptt(e){return/^[\w.\-/]+$/.test(e)}function Ctt(e,t){if(!Ptt(t))throw Error(`Invalid repo identifier: ${t}`);switch(e){case"github":return`https://github.com/${t}.git`;case"gitlab":return`https://gitlab.com/${t}.git`;case"bitbucket":return`https://bitbucket.org/${t}.git`;case"azure-devops":{let r=t.split("/");if(r.length===3)return`https://dev.azure.com/${r[0]}/${r[1]}/_git/${r[2]}`;return`https://dev.azure.com/${t}`}default:return`https://${e}/${t}.git`}}async function Ett(e,t,r){await btt(ktt(t),{recursive:!0});let i=Ir(void 0,xde),n=r?["--branch",r]:[];await i.clone(e,t,n)}async function Rtt(e,t){let r=Ir(e,xde),i=await r.status();if(!i.isClean())return"uncommitted changes";if(t){let n=i.current;if(n!==t)return`on ref '${n}', expected '${t}'`}await r.pull();return}async function $de(e,t,r={}){if(r.skipManaged||r.offline||r.dryRun)return[];let i=e.filter((o)=>o.managed);if(i.length===0)return[];let n=[];for(let o of i){if(!o.source||!o.repo){n.push({path:o.path,repo:o.repo??o.path,action:"skipped",error:"managed requires both source and repo fields"});continue}let s=xtt(o.path),a=Stt(t,s);if(!wtt(a)){if(!$tt(o.managed)){n.push({path:o.path,repo:o.repo,action:"skipped"});continue}try{let c=Ctt(o.source,o.repo);await Ett(c,a,o.ref),n.push({path:o.path,repo:o.repo,action:"cloned"})}catch(c){n.push({path:o.path,repo:o.repo,action:"skipped",error:`clone failed: ${c instanceof Error?c.message:String(c)}`})}}else if(_tt(o.managed))try{let c=await Rtt(a,o.ref);if(c)n.push({path:o.path,repo:o.repo,action:"skipped",error:`pull skipped: ${c}`});else n.push({path:o.path,repo:o.repo,action:"pulled"})}catch(c){n.push({path:o.path,repo:o.repo,action:"skipped",error:`pull failed: ${c instanceof Error?c.message:String(c)}`})}else n.push({path:o.path,repo:o.repo,action:"skipped"})}return n}var xde=120000;var _de=R(()=>{ut();bs()});import{randomUUID as Itt}from"node:crypto";import{lstat as Ede,mkdtemp as Att,open as Ott,readFile as Ttt,rename as Dtt,rm as d4}from"node:fs/promises";import{tmpdir as Mtt}from"node:os";import{dirname as Ntt,join as G0}from"node:path";function ym(e){return{...e.cwd&&{cwd:e.cwd},...e.env&&{env:e.env}}}function ki(e){if(e.error)return e.error;if(e.signal)return`Claude CLI terminated by ${e.signal}`;return`Claude CLI exited with code ${e.exitCode??"unknown"}`}function Ftt(e){let t=/(?:^|\s)v?(\d+)\.(\d+)\.(\d+)(?=\D|$)/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}async function Pde(e){let t=await Ede(e.root).catch((r)=>{if(r.code==="ENOENT")return null;throw r});if(!t)return!1;if(!t.isDirectory()||t.isSymbolicLink())throw Error(`Claude configuration root is not a real directory: ${e.root}`);return!0}function jtt(e){try{let t=JSON.parse(e);return t&&typeof t==="object"&&!Array.isArray(t)?t:null}catch{return null}}function ztt(e){let t=e.split(/\r?\n/).map((r)=>r.trim()).filter(Boolean);for(let r=t.length-1;r>=0;r--){let i=jtt(t[r]??"");if(i)return i}return null}function Cde(e,t){if(typeof e==="string"&&!t)return Rs(e)?{id:e,enabled:!0}:null;if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e,i;for(let o of["id","pluginId","spec","plugin"])if(typeof r[o]==="string"&&r[o].length>0){i=r[o];break}if(!i&&typeof r.name==="string"&&typeof r.marketplaceName==="string")i=`${r.name}@${r.marketplaceName}`;if(!i&&typeof r.name==="string"&&Rs(r.name))i=r.name;if(!i||!Rs(i))return null;let n=r.scope==="user"||r.scope==="project"||r.scope==="local"||r.scope==="managed"?r.scope:void 0;if(!t&&r.scope!==void 0&&!n)return null;if(!t&&r.enabled!==void 0&&typeof r.enabled!=="boolean")return null;return{id:i,...n&&{scope:n},enabled:t?!1:r.enabled!==!1}}function W0(e){let t;try{t=JSON.parse(e)}catch{return null}let r=Array.isArray(t)?t:t&&typeof t==="object"?["installed","plugins","installedPlugins","installed_plugins"].map((s)=>t[s]).find(Array.isArray)??null:null,i=t&&typeof t==="object"&&!Array.isArray(t)&&Array.isArray(t.available)?t.available:[];if(!r)return null;let n=r.map((s)=>Cde(s,!1)),o=i.map((s)=>Cde(s,!0));return n.every((s)=>s!==null)&&o.every((s)=>s!==null)?{installed:n,available:o}:null}function Utt(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;if(typeof t.name!=="string"||typeof t.source!=="string")return null;let r;for(let i of["path","repo","url"])if(typeof t[i]==="string"&&t[i].length>0){r=t[i];break}if(!r&&typeof t.installLocation==="string")r=t.installLocation;if(!r)return null;return{name:t.name,sourceType:t.source,source:r,...typeof t.ref==="string"&&t.ref.length>0&&{ref:t.ref}}}function Rde(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Array.isArray(t))return null;let r=t.map(Utt);return r.every((i)=>i!==null)?r:null}function Rs(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("@")||r.includes("/")||r.includes("\\")||i.includes("/")||i.includes("\\")||i.includes("://"))return null;return{plugin:r,marketplace:i}}function p4(e,t,r,i){let n=ztt(e);return n?.command===t&&n.outcome==="ok"&&n.pluginId===r&&n.scope===i}function Jv(e){return e.nativeScope.startsWith("profile:")?"user":e.nativeScope}function H0(e){return e.nativeScope.startsWith("profile:")}function Ltt(e){let t=e.provenance.marketplaceSource;if(!t)return null;let r=e.provenance.resolvedRef;return r&&/^[^/:]+\/[^/]+$/.test(t)?`${t}@${r}`:t}async function Btt(e){if(!e.nativeScope.startsWith("profile:"))return null;let t=G0(e.roots?.config??e.root,"settings.json"),r=await Ede(t).catch((i)=>{if(i.code==="ENOENT")return null;throw i});if(!r)return{path:t,content:null};if(!r.isFile()||r.isSymbolicLink())throw Error(`Claude profile settings are not a regular file: ${t}`);return{path:t,content:await Ttt(t),mode:r.mode&511}}async function qtt(e){if(!e)return;if(!e.content){await d4(e.path,{force:!0});return}let t=G0(Ntt(e.path),`.allagents-settings-${Itt()}.tmp`),r;try{r=await Ott(t,"wx",e.mode??384),await r.writeFile(e.content),await r.chmod(e.mode??384),await r.sync(),await r.close(),r=void 0,await Dtt(t,e.path)}finally{await r?.close().catch(()=>{return}),await d4(t,{force:!0})}}class vm{client="claude";run;minimumVersion;constructor(e={}){this.run=e.execute??Qn,this.minimumVersion=e.minimumVersion}async runIsolated(e,t){let r=await Att(G0(Mtt(),"allagents-claude-inspection-"));try{return await this.run("claude",e,{...t?.cwd&&{cwd:t.cwd},env:{...t?.env,CLAUDE_CONFIG_DIR:r,CLAUDE_CODE_PLUGIN_CACHE_DIR:G0(r,"plugins"),CLAUDE_CODE_PLUGIN_SEED_DIR:void 0,CLAUDE_CODE_PROJECT_DIR_NAME:void 0}})}finally{await d4(r,{recursive:!0,force:!0})}}async runForInspection(e,t){return await Pde(t)?this.run("claude",e,ym(t)):this.runIsolated(e,t)}async runMutation(e,t){let r=await Btt(t);try{return await this.run("claude",e,ym(t))}finally{await qtt(r)}}async isAvailable(e){let t=await this.runIsolated(["--version"],e);if(!t.success)return!1;let r=Ftt(t.output);if(this.minimumVersion&&(!r||Ko(r,this.minimumVersion)<0))return!1;if(!this.minimumVersion)return!0;let i=await this.runIsolated(["plugin","--help"],e);return i.success&&["install","list","marketplace","uninstall","update"].every((n)=>i.output.includes(n))}supportsScope(e){return!0}toPluginSpec(e){if(Rs(e))return e;let r=e.lastIndexOf("@");if(r<=0||r===e.length-1)return null;let i=e.slice(0,r),n=e.slice(r+1);if(!n.includes("/")||n.includes("://"))return null;let[,o]=n.split("/");return o?`${i}@${o}`:null}extractMarketplaceSource(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(t+1);return r.includes("/")&&!r.includes("://")?r:null}resolveSource(e,t,r={}){let i=this.toPluginSpec(e);if(!i)return{success:!1,error:`Claude native install does not support source '${e}'`};let n=Rs(i);return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:i,context:t,provenance:{...n&&{marketplaceName:n.marketplace},...r}}}}async inspect(e){if(!await Pde(e))return{success:!0,resources:[]};let t=await this.runForInspection(["plugin","list","--json"],e);if(!t.success)return{success:!1,resources:[],error:ki(t)};if(!t.output.trim()&&!H0(e))return{success:!0,resources:[]};let r=W0(t.output);if(!r)return{success:!1,resources:[],error:"Could not parse Claude plugin inventory"};let i=[],n=[];for(let o of r.installed){let s=Jv(e);if(o.scope&&o.scope!==s&&!(s==="project"&&o.scope==="local"))continue;let a=Rs(o.id),c={kind:"plugin",requestedIdentity:o.id,resolvedIdentity:o.id,context:e,provenance:{...a&&{marketplaceName:a.marketplace}}};if(o.enabled)i.push(c);else n.push({resource:c,status:"disabled"})}return{success:!0,resources:i,...n.length>0&&{observations:n}}}async inspectMarketplaceRegistration(e,t){let r=await this.runForInspection(["plugin","marketplace","list","--json"],t);if(!r.success)return{success:!1,present:!1,error:ki(r)};let i=Rde(r.output);if(!i)return{success:!1,present:!1,error:"Could not parse Claude marketplace inventory"};let n=i.find((o)=>o.name===e);return{success:!0,present:Boolean(n),...n?.source&&{source:n.source},...n?.sourceType&&{sourceType:n.sourceType},...n?.ref&&{ref:n.ref}}}async inspectMarketplacePlugin(e,t,r){let i=await this.runForInspection(["plugin","list","--available","--json"],r);if(!i.success)return{success:!1,present:!1,error:ki(i)};let n=W0(i.output);if(!n)return{success:!1,present:!1,error:`Could not parse Claude marketplace '${e}'`};let o=`${t}@${e}`;return{success:!0,present:[...n.installed,...n.available].some((s)=>s.id===o)}}async install(e,t){let r=Jv(t);if(!H0(t)){let a=[],c=e.provenance.marketplaceSource;if(c){let u=await this.run("claude",["plugin","marketplace","add",c],ym(t));if(!u.success)return{success:!1,error:ki(u)};a.push(c)}let l=await this.run("claude",["plugin","install",e.resolvedIdentity,"--scope",r],ym(t));return l.success?{success:!0,...a.length>0&&{registrations:a}}:{success:!1,error:ki(l),...a.length>0&&{registrations:a}}}let i=e.provenance.marketplaceName;if(!i)return{success:!1,error:"Claude plugin marketplace is missing"};let n=[],o=await this.inspectMarketplaceRegistration(i,t);if(!o.success)return{success:!1,error:o.error??`Could not inspect Claude marketplace '${i}'`};if(!o.present){let a=Ltt(e);if(!a)return{success:!1,error:`Claude marketplace '${i}' is not registered and has no source`};let c=["plugin","marketplace","add",a,"--scope",r],l=e.provenance.marketplaceSparsePath;if(l)c.push("--sparse",l);let u=await this.runMutation(c,t);if(!u.success)return{success:!1,error:ki(u)};n.push(e.provenance.managedMarketplaceRegistration==="true"?i:a);let p=await this.inspectMarketplaceRegistration(i,t);if(!p.success||!p.present)return{success:!1,error:p.error??`Claude marketplace '${i}' registration could not be verified`,registrations:n}}if(e.provenance.managedMarketplaceRegistration==="true"&&n.length===0)n.push(i);let s=await this.runMutation(["plugin","install",e.resolvedIdentity,"--scope",r,"--yes","--json"],t);return s.success&&p4(s.output,"install",e.resolvedIdentity,r)?{success:!0,...n.length>0&&{registrations:n}}:{success:!1,error:s.success?`Could not parse Claude plugin '${e.resolvedIdentity}' install result`:ki(s),...n.length>0&&{registrations:n}}}async update(e,t,r){let i=Jv(r);if(!H0(r)){let s=await this.run("claude",["plugin","update",e.resolvedIdentity,"--scope",i],ym(r));return s.success?{success:!0}:{success:!1,error:ki(s)}}let n=e.provenance.marketplaceName;if(n){let s=await this.runMutation(["plugin","marketplace","update",n],r);if(!s.success)return{success:!1,error:ki(s)}}let o=await this.runMutation(["plugin","update",e.resolvedIdentity,"--scope",i,"--yes","--json"],r);return o.success&&p4(o.output,"update",e.resolvedIdentity,i)?{success:!0}:{success:!1,error:o.success?`Could not parse Claude plugin '${e.resolvedIdentity}' update result`:ki(o)}}async remove(e,t){let r=Jv(t);if(!H0(t)){let n=await this.run("claude",["plugin","uninstall",e.resolvedIdentity,"--scope",r],ym(t));return n.success?{success:!0}:{success:!1,error:ki(n)}}let i=await this.runMutation(["plugin","uninstall",e.resolvedIdentity,"--scope",r,"--yes","--json"],t);return i.success&&p4(i.output,"uninstall",e.resolvedIdentity,r)?{success:!0}:{success:!1,error:i.success?`Could not parse Claude plugin '${e.resolvedIdentity}' removal result`:ki(i)}}async removeMarketplaceRegistration(e,t){let r=Jv(t),i=await this.inspectMarketplaceRegistration(e,t);if(!i.success)return{success:!1,error:i.error??`Could not inspect Claude marketplace '${e}'`};if(!i.present)return{success:!0};let n=await this.runForInspection(["plugin","list","--json"],t);if(!n.success)return{success:!1,error:ki(n)};let o=W0(n.output);if(!o)return{success:!1,error:`Could not parse Claude marketplace '${e}' plugin inventory`};if(o.installed.some((c)=>Rs(c.id)?.marketplace===e))return{success:!1,error:`Claude marketplace '${e}' is still used by installed plugins`};let s=await this.runMutation(["plugin","marketplace","remove",e,"--scope",r],t);if(!s.success)return{success:!1,error:ki(s)};let a=await this.inspectMarketplaceRegistration(e,t);return a.success&&!a.present?{success:!0}:{success:!1,error:a.error??`Claude marketplace '${e}' removal could not be verified`}}}var f4=R(()=>{vo()});import{access as Vtt,mkdtemp as Htt,rm as Wtt}from"node:fs/promises";import{tmpdir as Gtt}from"node:os";import{basename as Ztt,join as m4}from"node:path";function wm(e){return{...e.cwd&&{cwd:e.cwd},...e.env&&{env:e.env}}}async function Ide(e){let t=e.roots?.config??e.root;return Vtt(t).then(()=>!0,(r)=>{if(r.code==="ENOENT")return!1;throw r})}function tl(e){if(e.error)return e.error;if(e.signal)return`Copilot CLI terminated by ${e.signal}`;return`Copilot CLI exited with code ${e.exitCode??"unknown"}`}function Xtt(e){let t=/(?:^|\s)v?(\d+)\.(\d+)\.(\d+)(?=\D|$)/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function Ade(e){if(e.includes("No plugins installed."))return[];if(!e.includes("Installed plugins:"))return null;return e.split(/\r?\n/).flatMap((t)=>Ktt.exec(t)?.[1]??[])}function Qtt(e){if(!e.includes("Included with GitHub Copilot:")&&!e.includes("Registered marketplaces:"))return null;let t=new Map;for(let r of e.split(/\r?\n/)){let i=Jtt.exec(r);if(i?.[1]&&i[2])t.set(i[1],i[2])}return t}function ert(e){if(!e.startsWith('Plugins in "'))return null;return e.split(/\r?\n/).flatMap((t)=>Ytt.exec(t)?.[1]??[])}function Yv(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("/")||r.includes("\\")||i.includes("/")||i.includes("\\")||i.includes("://"))return null;return{plugin:r,marketplace:i}}class bm{client="copilot";run;minimumVersion;constructor(e={}){this.run=e.execute??Qn,this.minimumVersion=e.minimumVersion}async runIsolated(e,t){let r=await Htt(m4(Gtt(),"allagents-copilot-inspection-"));try{return await this.run("copilot",e,{...t.cwd&&{cwd:t.cwd},env:{...t.env,COPILOT_HOME:m4(r,"home"),COPILOT_CACHE_HOME:m4(r,"cache")}})}finally{await Wtt(r,{recursive:!0,force:!0})}}async runForInspection(e,t){return await Ide(t)?this.run("copilot",e,wm(t)):this.runIsolated(e,t)}async isAvailable(e){let t=e?await this.runIsolated(["--version"],e):await this.run("copilot",["--version"]);if(!t.success)return!1;if(!this.minimumVersion)return!0;let r=Xtt(t.output);return Boolean(r&&Ko(r,this.minimumVersion)>=0)}supportsScope(e){return e==="user"}toPluginSpec(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("/")||r.includes("\\")||i.includes("://")||i.includes("\\"))return null;if(!i.includes("/"))return e;let n=i.split("/");if(n.length!==2||!n[0]||!n[1])return null;return`${r}@${Ztt(i)}`}extractMarketplaceSource(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(t+1);if(r.includes("/")&&!r.includes("://"))return r;return null}resolveSource(e,t,r={}){let i=this.toPluginSpec(e);if(!i)return{success:!1,error:`Copilot native install does not support source '${e}'`};let n=Yv(i),o=r.marketplaceSource??this.extractMarketplaceSource(e),s=r.marketplaceName??n?.marketplace;return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:i,context:t,provenance:{...r,...o&&{marketplaceSource:o},...s&&{marketplaceName:s}}}}}async inspect(e){if(!await Ide(e))return{success:!0,resources:[]};let t=await this.runForInspection(["plugin","list"],e);if(!t.success)return{success:!1,resources:[],error:tl(t)};let r=Ade(t.output);if(!r)return{success:!1,resources:[],error:"Could not parse Copilot plugin inventory"};return{success:!0,resources:r.map((i)=>{let n=Yv(i);return{kind:"plugin",requestedIdentity:i,resolvedIdentity:i,context:e,provenance:{...n&&{marketplaceName:n.marketplace}}}})}}async inspectMarketplaceRegistration(e,t){let r=await this.runForInspection(["plugin","marketplace","list"],t);if(!r.success)return{success:!1,present:!1,error:tl(r)};let i=Qtt(r.output);if(!i)return{success:!1,present:!1,error:"Could not parse Copilot marketplace inventory"};let n=i.get(e);return{success:!0,present:n!==void 0,...n&&{source:n}}}async inspectMarketplacePlugin(e,t,r){let i=await this.runForInspection(["plugin","marketplace","browse",e],r);if(!i.success)return{success:!1,present:!1,error:tl(i)};let n=ert(i.output);if(!n)return{success:!1,present:!1,error:`Could not parse Copilot marketplace '${e}'`};return{success:!0,present:n.includes(t)}}async install(e,t){let r=[],i=e.provenance.marketplaceSource,n=e.provenance.marketplaceName;if(i&&n){let c=await this.inspectMarketplaceRegistration(n,t);if(!c.success)return{success:!1,error:c.error??`Could not inspect Copilot marketplace '${n}'`};if(!c.present){let l=await this.run("copilot",["plugin","marketplace","add",i],wm(t));if(!l.success)return{success:!1,error:tl(l)}}if(e.provenance.managedMarketplaceRegistration==="true")r.push(n)}let o=await this.run("copilot",["plugin","install",e.resolvedIdentity],wm(t));if(o.success)return{success:!0,...r.length>0&&{registrations:r}};let s=tl(o);return{success:!1,error:s.includes("Plugin path escapes marketplace directory")?`${s} (Copilot rejected a plugin path from this marketplace manifest. Use file install for copilot to avoid native install for this plugin.)`:s,...r.length>0&&{registrations:r}}}async update(e,t,r){let i=await this.run("copilot",["plugin","update",e.resolvedIdentity],wm(r));return i.success?{success:!0}:{success:!1,error:tl(i)}}async remove(e,t){let r=await this.run("copilot",["plugin","uninstall",e.resolvedIdentity],wm(t));return r.success?{success:!0}:{success:!1,error:tl(r)}}async removeMarketplaceRegistration(e,t){let r=await this.inspectMarketplaceRegistration(e,t);if(!r.success)return{success:!1,error:r.error??`Could not inspect Copilot marketplace '${e}'`};if(!r.present)return{success:!0};let i=await this.run("copilot",["plugin","marketplace","remove",e],wm(t));return i.success?{success:!0}:{success:!1,error:tl(i)}}}var Ktt,Jtt,Ytt;var g4=R(()=>{vo();Ktt=/^\s*[•*-]\s+([^\s]+@[^\s]+?)(?:\s+\(v[^)]*\))?(?:\s+\[[^\]]+\])?\s*$/,Jtt=/^\s*[•◆*-]\s+([^\s]+)\s+\((?:GitHub|Directory|Git):\s*([^)]+)\)\s*$/,Ytt=/^\s*[•*-]\s+([^\s]+)\s+-\s+/});import{access as trt,mkdtemp as rrt,rm as nrt}from"node:fs/promises";import{tmpdir as irt}from"node:os";import{join as ort}from"node:path";function sp(e){return{...e.cwd&&{cwd:e.cwd},...e.env&&{env:e.env}}}async function Ode(e){return trt(e.root).then(()=>!0,(t)=>{if(t.code==="ENOENT")return!1;throw t})}function Is(e){if(e.error)return e.error;if(e.signal)return`Codex CLI terminated by ${e.signal}`;return`Codex CLI exited with code ${e.exitCode??"unknown"}`}function srt(e){let t=/(?:^|\s)v?(\d+)\.(\d+)\.(\d+)(?=\D|$)/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function km(e){try{let t=JSON.parse(e);return t&&typeof t==="object"&&!Array.isArray(t)?t:null}catch{return null}}function Dde(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let t=e;return typeof t.sourceType==="string"&&typeof t.source==="string"?{sourceType:t.sourceType,source:t.source}:void 0}function art(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;if(typeof t.name!=="string"||typeof t.root!=="string")return null;let r=Dde(t.marketplaceSource);return{name:t.name,root:t.root,...r&&{marketplaceSource:r}}}function Mde(e){let t=km(e);if(!t||!Array.isArray(t.marketplaces))return null;let r=t.marketplaces.map(art);return r.every((i)=>i!==null)?r:null}function Tde(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;if(typeof t.pluginId!=="string"||typeof t.name!=="string"||typeof t.marketplaceName!=="string"||typeof t.installed!=="boolean"||typeof t.enabled!=="boolean")return null;let r=Dde(t.marketplaceSource);return{pluginId:t.pluginId,name:t.name,marketplaceName:t.marketplaceName,installed:t.installed,enabled:t.enabled,...r&&{marketplaceSource:r}}}function Z0(e){let t=km(e);if(!t||!Array.isArray(t.installed)||!Array.isArray(t.available))return null;let r=t.installed.map(Tde),i=t.available.map(Tde);return r.every((n)=>n!==null)&&i.every((n)=>n!==null)?{installed:r,available:i}:null}function K0(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(r.includes("/")||r.includes("\\")||i.includes("/")||i.includes("\\")||i.includes("://"))return null;return{plugin:r,marketplace:i}}function h4(e,t){return km(e)?.pluginId===t}function crt(e,t){let r=km(e);return r?.marketplaceName===t&&typeof r.alreadyAdded==="boolean"?{alreadyAdded:r.alreadyAdded}:null}function lrt(e,t){let r=km(e);return Boolean(r&&Array.isArray(r.selectedMarketplaces)&&r.selectedMarketplaces.includes(t)&&Array.isArray(r.upgradedRoots)&&Array.isArray(r.errors)&&r.errors.length===0)}class Sm{client="codex";run;minimumVersion;constructor(e={}){this.run=e.execute??Qn,this.minimumVersion=e.minimumVersion}async runIsolated(e,t){let r=await rrt(ort(irt(),"allagents-codex-inspection-"));try{return await this.run("codex",e,{...t?.cwd&&{cwd:t.cwd},env:{...t?.env,CODEX_HOME:r}})}finally{await nrt(r,{recursive:!0,force:!0})}}async runForInspection(e,t){return await Ode(t)?this.run("codex",e,sp(t)):this.runIsolated(e,t)}async isAvailable(e){let t=await this.runIsolated(["--version"],e);if(!t.success)return!1;let r=srt(t.output);if(this.minimumVersion&&(!r||Ko(r,this.minimumVersion)<0))return!1;let i=await this.runIsolated(["plugin","--help"],e);return i.success&&["add","list","marketplace","remove"].every((n)=>i.output.includes(n))}supportsScope(e){return e==="user"}resolveSource(e,t,r={}){let i=K0(e);if(!i)return{success:!1,error:`Codex native install does not support source '${e}'`};return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:`${i.plugin}@${i.marketplace}`,context:t,provenance:{...r,marketplaceName:r.marketplaceName??i.marketplace}}}}async inspect(e){if(!await Ode(e))return{success:!0,resources:[]};let t=await this.runForInspection(["plugin","list","--json"],e);if(!t.success)return{success:!1,resources:[],error:Is(t)};let r=Z0(t.output);if(!r)return{success:!1,resources:[],error:"Could not parse Codex plugin inventory"};let i=[],n=[];for(let o of r.installed){let s={kind:"plugin",requestedIdentity:o.pluginId,resolvedIdentity:o.pluginId,context:e,provenance:{marketplaceName:o.marketplaceName,...o.marketplaceSource?.source&&{marketplaceSource:o.marketplaceSource.source}}};if(o.installed&&o.enabled)i.push(s);else n.push({resource:s,status:o.installed?"disabled":"configured-missing"})}return{success:!0,resources:i,...n.length>0&&{observations:n}}}async inspectMarketplaceRegistration(e,t){let r=await this.runForInspection(["plugin","marketplace","list","--json"],t);if(!r.success)return{success:!1,present:!1,error:Is(r)};let i=Mde(r.output);if(!i)return{success:!1,present:!1,error:"Could not parse Codex marketplace inventory"};let n=i.find((o)=>o.name===e);return{success:!0,present:Boolean(n),...n?.root&&{root:n.root},...n?.marketplaceSource?.source&&{source:n.marketplaceSource.source},...n?.marketplaceSource?.sourceType&&{sourceType:n.marketplaceSource.sourceType}}}async inspectMarketplacePlugin(e,t,r){let i=await this.runForInspection(["plugin","list","--marketplace",e,"--available","--json"],r);if(!i.success)return{success:!1,present:!1,error:Is(i)};let n=Z0(i.output);if(!n)return{success:!1,present:!1,error:`Could not parse Codex marketplace '${e}'`};let o=`${t}@${e}`;return{success:!0,present:[...n.installed,...n.available].some((s)=>s.pluginId===o)}}async install(e,t){let r=e.provenance.marketplaceName;if(!r)return{success:!1,error:"Codex plugin marketplace is missing"};let i=[],n=await this.inspectMarketplaceRegistration(r,t);if(!n.success)return{success:!1,error:n.error??`Could not inspect Codex marketplace '${r}'`};if(!n.present){let s=e.provenance.marketplaceSource;if(!s)return{success:!1,error:`Codex marketplace '${r}' is not registered and has no source`};let a=["plugin","marketplace","add",s],c=e.provenance.resolvedRef;if(c)a.push("--ref",c);let l=e.provenance.marketplaceSparsePath;if(l)a.push("--sparse",l);a.push("--json");let u=await this.run("codex",a,sp(t));if(!u.success)return{success:!1,error:Is(u)};let p=crt(u.output,r);if(!p)return{success:!1,error:`Could not parse Codex marketplace '${r}' registration result`};if(!p.alreadyAdded&&e.provenance.managedMarketplaceRegistration==="true")i.push(r)}let o=await this.run("codex",["plugin","add",e.resolvedIdentity,"--json"],sp(t));if(!o.success)return{success:!1,error:Is(o),...i.length>0&&{registrations:i}};if(!h4(o.output,e.resolvedIdentity))return{success:!1,error:`Could not parse Codex plugin '${e.resolvedIdentity}' install result`,...i.length>0&&{registrations:i}};return{success:!0,...i.length>0&&{registrations:i}}}async update(e,t,r){let i=e.provenance.marketplaceName;if(!i)return{success:!1,error:"Codex plugin marketplace is missing"};let n=await this.inspectMarketplaceRegistration(i,r);if(!n.success||!n.present)return{success:!1,error:n.error??`Codex marketplace '${i}' is not registered`};if(n.sourceType==="git"){let s=await this.run("codex",["plugin","marketplace","upgrade",i,"--json"],sp(r));if(!s.success)return{success:!1,error:Is(s)};if(!lrt(s.output,i))return{success:!1,error:`Could not parse Codex marketplace '${i}' upgrade result`}}let o=await this.run("codex",["plugin","add",e.resolvedIdentity,"--json"],sp(r));return o.success&&h4(o.output,e.resolvedIdentity)?{success:!0}:{success:!1,error:o.success?`Could not parse Codex plugin '${e.resolvedIdentity}' update result`:Is(o)}}async remove(e,t){let r=await this.run("codex",["plugin","remove",e.resolvedIdentity,"--json"],sp(t));return r.success&&h4(r.output,e.resolvedIdentity)?{success:!0}:{success:!1,error:r.success?`Could not parse Codex plugin '${e.resolvedIdentity}' removal result`:Is(r)}}async removeMarketplaceRegistration(e,t){let r=await this.inspectMarketplaceRegistration(e,t);if(!r.success)return{success:!1,error:r.error??`Could not inspect Codex marketplace '${e}'`};if(!r.present)return{success:!0};let i=await this.runForInspection(["plugin","list","--marketplace",e,"--json"],t);if(!i.success)return{success:!1,error:Is(i)};let n=Z0(i.output);if(!n)return{success:!1,error:`Could not parse Codex marketplace '${e}' plugin inventory`};if(n.installed.length>0)return{success:!1,error:`Codex marketplace '${e}' is still used by installed plugins`};let o=await this.run("codex",["plugin","marketplace","remove",e,"--json"],sp(t));if(!o.success)return{success:!1,error:Is(o)};return km(o.output)?.marketplaceName===e?{success:!0}:{success:!1,error:`Could not parse Codex marketplace '${e}' removal result`}}}var y4=R(()=>{vo()});import{readFile as zde}from"node:fs/promises";import{isAbsolute as urt,join as xm,resolve as Qv,win32 as prt}from"node:path";function As(e){return typeof e==="string"&&e.length<=64&&frt.test(e)}function $m(e){if(!As(e)||e==="default"||e==="."||e===".."||e.endsWith("."))throw Error(`Invalid OMP profile name '${e}'`);return`profile:${e}`}function b4(e){if(!e?.startsWith("profile:"))return;let t=e.slice(8);return $m(t).slice(8)}function nl(e){return urt(e)||prt.isAbsolute(e)}function Ude(e){return Qv(e.cwd??process.cwd())}function brt(e){return{...e?.cwd&&{cwd:Ude(e)},env:{...e?.env,OMP_PROFILE:void 0,PI_PROFILE:void 0,PI_CONFIG_FILES:void 0}}}function ap(e){if(e.error)return e.error;if(e.signal)return`OMP CLI terminated by ${e.signal}`;return`OMP CLI exited with code ${e.exitCode??"unknown"}`}function krt(e){let t=/^(?:omp\/)?(\d+)\.(\d+)\.(\d+)(?:[-+][0-9A-Za-z.-]+)?$/.exec(e.trim());if(!t?.[1]||!t[2]||!t[3])return null;let r=[Number(t[1]),Number(t[2]),Number(t[3])];return r.every(Number.isSafeInteger)?r:null}function Os(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(!As(r)||!As(i))return null;let n=`${r}@${i}`;return n.length<=128?{id:n,name:r,marketplace:i}:null}function Srt(e){let t=e.lastIndexOf("@");if(t<=0||t===e.length-1)return null;let r=e.slice(0,t),i=e.slice(t+1);if(!As(r)||J0.test(i))return null;let n=i.split("/"),o=n[1];if(n.length<2||!n[0]||!o||o==="."||o==="..")return null;let s=o.replace(/\.git$/i,"").toLowerCase();if(!As(s))return null;let a=`${r}@${s}`;return a.length<=128?{id:a,name:r,marketplace:s}:null}function xrt(e,t){if(e!=="~"&&!e.startsWith("~/")&&!e.startsWith("~\\"))return e;let r=t.env?.HOME??t.env?.USERPROFILE;return r?xm(r,e.slice(2)):e}function k4(e){try{let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:"&&t.protocol!=="ssh:")return null;if(t.username||t.password)return null;for(let[r,i]of t.searchParams)if(i&&grt.test(r))return null;return t.hostname=t.hostname.toLowerCase(),t.searchParams.sort(),t.hash="",t.toString().replace(/\/$/,"")}catch{return null}}function S4(e){let t=e.trim(),r=mrt.exec(t);if(r?.[1]&&r[2])return`${r[1]}/${r[2].replace(/\.git$/i,"")}`.toLowerCase();let i=/^git@github\.com:([^/\s]+)\/([^/\s]+)$/i.exec(t);if(i?.[1]&&i[2])return`${i[1]}/${i[2].replace(/\.git$/i,"")}`.toLowerCase();let n=k4(t);if(!n)return null;let o=new URL(n);if(o.hostname!=="github.com"||o.search)return null;let s=o.pathname.replace(/^\/+|\/+$/g,"").split("/");if(!s[0]||!s[1]||s.length!==2)return null;return`${s[0]}/${s[1].replace(/\.git$/i,"")}`.toLowerCase()}function Nde(e){return k4(e)!==null}function X0(e,t,r){let i=e.trim();if(!i||J0.test(i))return null;let n=S4(i);if(n)return{identity:`github:${n}`,source:n};if(t==="local"||i==="~"||i.startsWith("~/")||i.startsWith("~\\")||i.startsWith("./")||i.startsWith("../")||nl(i)){let a=xrt(i,r);if(a.startsWith("~"))return null;let c=Qv(Ude(r),a);return{identity:`local:${c}`,source:c}}let s=k4(i);if(s)return{identity:`remote:${s}`,source:s};if(/^(?:git@|[^\s]+:[^\s]+$)/.test(i))return{identity:`git:${i}`,source:i};return t==="github"?null:{identity:`remote:${i}`,source:i}}function $rt(e,t,r){return X0(e,t,r)?.identity??null}function Y0(e){return typeof e==="string"&&e.length>0&&!Number.isNaN(Date.parse(e))}function Lde(e,t){let r=yrt.safeParse(e);if(!r.success||!As(r.data.name))return{error:`OMP marketplace catalog is malformed: ${t}`};let i=new Set,n=[];for(let o of r.data.plugins){if(!As(o.name))return{error:`OMP marketplace catalog contains an invalid plugin name: ${t}`};if(i.has(o.name))return{error:`OMP marketplace catalog contains duplicate plugin '${o.name}': ${t}`};i.add(o.name),n.push({name:o.name,source:o.source,...o.version&&{version:o.version}})}return{catalog:{name:r.data.name,plugins:n}}}function x4(e,t,r,i={}){let n=Lde(t,"<fetched marketplace>"),o=n.catalog;if(!o)return{success:!1,error:n.error??"Fetched OMP marketplace catalog is malformed"};let s=Os(e),a,c;if(s){if(s.marketplace!==o.name)return{success:!1,error:`OMP plugin marketplace '${s.marketplace}' does not match fetched catalog '${o.name}'`};if(a=o.plugins.find((u)=>u.name===s.name),!a)return{success:!1,error:`OMP catalog '${o.name}' has no plugin '${s.name}'`}}else{let u=e.trim(),p=u==="~"||u.startsWith("~/")||u.startsWith("~\\")||u.startsWith("./")||u.startsWith("../")||nl(u),d=S4(u)?"github":p?"local":void 0,f=d?X0(u,d,r):null;if(!f)return{success:!1,error:`OMP marketplace source must be an exact plugin id, GitHub repository, or local path: '${e}'`};if(o.plugins.length!==1)return{success:!1,error:`OMP marketplace source '${e}' must resolve exactly one plugin, but catalog '${o.name}' contains ${o.plugins.length}`};a=o.plugins[0],c=f.source}if(!a)return{success:!1,error:`OMP catalog '${o.name}' did not resolve a plugin`};let l=`${a.name}@${o.name}`;return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:l,context:r,provenance:{...i,pluginName:a.name,marketplaceName:o.name,...c&&{marketplaceSource:c},...a.version&&{catalogVersion:a.version}}}}}async function Fde(e,t){try{let r=await t(e);if(!r.trim())return{missing:!1,error:`OMP JSON file is empty: ${e}`};return{value:JSON.parse(r.replace(/^\uFEFF/,"")),missing:!1}}catch(r){if(r.code==="ENOENT")return{missing:!0};return{missing:!1,error:`Could not read OMP JSON file ${e}: ${r instanceof Error?r.message:String(r)}`}}}async function v4(e,t){try{return{contents:await t(e)}}catch(r){if(r.code==="ENOENT")return{};return{error:`Could not read OMP marketplace checkout ${e}: ${r instanceof Error?r.message:String(r)}`}}}async function _rt(e,t){if(e.sourceType==="url")return{error:`OMP marketplace '${e.name}' is not backed by a verifiable Git checkout`};let r=e.sourceType==="local"?e.sourceUri:Qv(e.catalogPath,"..");if(!nl(r))return{error:`OMP marketplace '${e.name}' checkout path is not absolute`};let i=xm(r,".git"),n=await v4(xm(i,"HEAD"),t);if(n.error)return{error:n.error};let o=n.contents?.trim();if(!o)return{error:`OMP marketplace '${e.name}' checkout has no readable HEAD`};if(/^[0-9a-f]{40,64}$/i.test(o))return{sha:o.toLowerCase()};let s=/^ref: (refs\/[A-Za-z0-9._/-]+)$/.exec(o)?.[1];if(!s||s.split("/").some((p)=>p==="."||p===".."))return{error:`OMP marketplace '${e.name}' checkout has an invalid HEAD`};let a=await v4(xm(i,...s.split("/")),t);if(a.error)return{error:a.error};let c=a.contents?.trim();if(c&&/^[0-9a-f]{40,64}$/i.test(c))return{sha:c.toLowerCase()};let l=await v4(xm(i,"packed-refs"),t);if(l.error)return{error:l.error};let u=l.contents?.split(/\r?\n/).map((p)=>p.trim().split(/\s+/,2)).find(([,p])=>p===s)?.[0];return u&&/^[0-9a-f]{40,64}$/i.test(u)?{sha:u.toLowerCase()}:{error:`OMP marketplace '${e.name}' checkout does not resolve HEAD`}}async function jde(e,t,r){let i=e.provenance.requestedRef,n=e.provenance.resolvedRef,o=e.provenance.resolvedSha;if(i&&i!==n)return`OMP marketplace requested ref '${i}' resolved as '${n??"unknown"}'`;if(n&&n!=="main")return`OMP CLI cannot enforce marketplace ref '${n}'`;if(!o)return i||n?`OMP marketplace ref '${i??n}' has no authoritative resolved revision`:null;if(!/^[0-9a-f]{40,64}$/i.test(o))return"OMP marketplace resolved revision is malformed";let s=await _rt(t,r);if(!s.sha)return s.error??`Could not verify OMP marketplace '${t.name}' revision`;return s.sha===o.toLowerCase()?null:`OMP marketplace '${t.name}' resolved revision does not match requested '${i??n??o}'`}function Bde(e){let t=e.roots?.data;return t&&nl(t)?xm(t,"marketplaces.json"):null}async function rl(e,t={}){let r=Bde(e);if(!r)return{success:!1,registryPath:"",marketplaces:[],missing:!1,error:"OMP operation context has no authoritative absolute data root"};let i=t.readFile??((u)=>zde(u,"utf8")),n=await Fde(r,i);if(n.error)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:n.error};if(n.missing)return t.allowMissing?{success:!0,registryPath:r,marketplaces:[],missing:!0}:{success:!1,registryPath:r,marketplaces:[],missing:!0,error:`OMP marketplace registry is missing: ${r}`};let o=vrt.safeParse(n.value);if(!o.success)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry has an unsupported or malformed version: ${r}`};let s=new Set,a=new Set,c=new Set,l=[];for(let u of o.data.marketplaces){if(!As(u.name))return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry contains an invalid name: ${r}`};let p=X0(u.sourceUri,u.sourceType,e);if(!p)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace '${u.name}' has an invalid or credential-bearing source identity`};let d=p.identity;if(s.has(u.name)||a.has(d)||c.has(u.catalogPath))return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry contains an ambiguous identity for '${u.name}'`};let f=await Fde(u.catalogPath,i);if(f.error||f.missing)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:f.error??`OMP marketplace catalog is missing: ${u.catalogPath}`};let m=Lde(f.value,u.catalogPath);if(!m.catalog)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:m.error??`Malformed OMP marketplace catalog: ${u.catalogPath}`};if(m.catalog.name!==u.name)return{success:!1,registryPath:r,marketplaces:[],missing:!1,error:`OMP marketplace registry name '${u.name}' conflicts with catalog name '${m.catalog.name}'`};s.add(u.name),a.add(d),c.add(u.catalogPath),l.push({name:u.name,sourceType:u.sourceType,sourceUri:p.source,sourceIdentity:d,catalogPath:u.catalogPath,catalog:m.catalog})}return{success:!0,registryPath:r,marketplaces:l,missing:!1}}function Prt(e){let t;try{if(!e.trim())throw Error("empty output");t=JSON.parse(e.replace(/^\uFEFF/,""))}catch(s){return{error:`OMP plugin inventory is not valid JSON: ${s instanceof Error?s.message:String(s)}`}}let r=wrt.safeParse(t);if(!r.success)return{error:"OMP plugin inventory has an unsupported shape"};let i=[],n=new Set,o=new Map;for(let s of r.data.marketplace){let a=s.entries[0];if(!Os(s.id)||s.entries.length!==1||!a)return{error:"OMP plugin inventory contains a malformed or ambiguous marketplace entry"};let c=`${s.scope}:${s.id}`;if(n.has(c))return{error:`OMP plugin inventory contains duplicate identity '${c}'`};if(n.add(c),a.scope!==s.scope)return{error:`OMP plugin inventory contains scope-conflicting details for '${c}'`};let l=o.get(a.installPath);if(l&&l!==c)return{error:`OMP plugin inventory reuses one install path for '${l}' and '${c}'`};o.set(a.installPath,c);let u=s.shadowedBy==="project";if(s.shadowedBy!==void 0&&!u)return{error:`OMP plugin inventory has an invalid shadow marker for '${c}'`};i.push({id:s.id,scope:s.scope,installPath:a.installPath,version:a.version,enabled:a.enabled!==!1,shadowedByProject:u})}for(let s of i){if(!s.shadowedByProject)continue;let a=i.find((c)=>c.id===s.id&&c.scope==="project");if(s.scope!=="user"||!a?.enabled)return{error:`OMP plugin inventory has an uncorroborated shadow marker for '${s.id}'`}}return{entries:i}}function qde(e){return Os(e.resolvedIdentity)}function Xv(e,t){if(e.client!=="omp")return`OMP adapter received context for '${e.client}'`;let r;try{r=b4(e.nativeScope)}catch(o){return o instanceof Error?o.message:String(o)}let i=t??r,n=i?`profile:${i}`:e.scope;if(e.nativeScope!==n)return`OMP native scope '${e.nativeScope}' conflicts with selected scope '${n}'`;if(i&&e.scope!=="user")return"OMP named profiles support only the AllAgents user scope";if(!nl(e.root))return"OMP operation context root must be absolute";if(!Bde(e))return"OMP operation context has no authoritative absolute data root";return null}function Crt(e,t,r){let i=Xv(t,r);if(i)return i;if(e.kind!=="plugin"||!qde(e))return"OMP mutation requires one valid marketplace plugin identity";if(e.context.client!==t.client||e.context.scope!==t.scope||e.context.nativeScope!==t.nativeScope||Qv(e.context.root)!==Qv(t.root))return"OMP resource context does not match the selected operation context";return null}function w4(e,t,r){let i=qde(e);if(!i)return{error:"OMP resource has no valid plugin identity"};let n=t.marketplaces.find((c)=>c.name===i.marketplace),o=e.provenance.marketplaceSource,s=o?$rt(o,void 0,r):null;if(o&&!s)return{error:`OMP marketplace source is invalid: ${o}`};if(!n){if(s){let c=t.marketplaces.find((l)=>l.sourceIdentity===s);if(c)return{error:`OMP marketplace source is already registered as '${c.name}', not '${i.marketplace}'`}}return{missing:!0,error:`OMP marketplace '${i.marketplace}' is not registered`}}if(s&&n.sourceIdentity!==s)return{error:`OMP marketplace '${i.marketplace}' is registered from a conflicting source`};if(n.catalog.plugins.filter((c)=>c.name===i.name).length!==1)return{error:`OMP catalog '${i.marketplace}' does not resolve exactly one plugin '${i.name}'`};return{marketplace:n}}class _m{client="omp";run;reader;profileName;versionResult;constructor(e={}){if(this.run=e.execute??Qn,this.reader=e.readFile??((t)=>zde(t,"utf8")),this.profileName=e.nativeScope?.name,this.profileName!==void 0)$m(this.profileName)}execute(e,t){let r=this.profileName??b4(t?.nativeScope);return this.run("omp",r?["--profile",r,...e]:e,brt(t))}async supportedVersion(e){if(this.versionResult)return this.versionResult;let t=await this.execute(["--version"],e);if(!t.success)return this.versionResult={success:!1,error:ap(t)},this.versionResult;let r=krt(t.output);if(!r)return this.versionResult={success:!1,error:`Could not parse OMP version: ${JSON.stringify(t.output)}`},this.versionResult;if(Ko(r,drt)<0)return this.versionResult={success:!1,error:`OMP ${r.join(".")} is unsupported; version 18.1.17 or newer is required`},this.versionResult;return this.versionResult={success:!0},this.versionResult}async isAvailable(e){if(e&&Xv(e,this.profileName))return!1;return(await this.supportedVersion(e)).success}supportsScope(e){return!0}resolveSource(e,t,r={}){let i=Os(e)??Srt(e);if(!i)return{success:!1,error:`OMP native install requires a valid plugin@marketplace source, not '${e}'`};return{success:!0,resource:{kind:"plugin",requestedIdentity:e,resolvedIdentity:i.id,context:t,provenance:{...r,pluginName:i.name,marketplaceName:i.marketplace}}}}async inspect(e){let t=Xv(e,this.profileName);if(t)return{success:!1,resources:[],observations:[],error:t};let r=await this.supportedVersion(e);if(!r.success)return{success:!1,resources:[],observations:[],error:r.error??"OMP version inspection failed"};let i=await this.execute(["plugin","list","--json"],e);if(!i.success)return{success:!1,resources:[],observations:[],error:`Could not inspect OMP plugins: ${ap(i)}`};let n=Prt(i.output);if(!n.entries)return{success:!1,resources:[],observations:[],error:n.error??"Could not parse OMP plugin inventory"};let o=await rl(e,{readFile:this.reader,allowMissing:n.entries.length===0});if(!o.success)return{success:!1,resources:[],observations:[],error:o.error??"Could not inspect OMP marketplaces"};let s=[];for(let c of n.entries){let l=Os(c.id);if(!l)return{success:!1,resources:[],observations:s,error:`Installed OMP plugin '${c.id}' has invalid identity`};let u=o.marketplaces.find((m)=>m.name===l.marketplace);if(!u)return{success:!1,resources:[],observations:s,error:`Installed OMP plugin '${c.id}' references missing marketplace '${l.marketplace}'`};let p=u.catalog.plugins.filter((m)=>m.name===l.name),d=p[0];if(p.length!==1||!d)return{success:!1,resources:[],observations:s,error:`Installed OMP plugin '${c.id}' has no unambiguous catalog identity`};let f={kind:"plugin",requestedIdentity:c.id,resolvedIdentity:c.id,context:{...e,scope:c.scope,nativeScope:e.nativeScope.startsWith("profile:")?e.nativeScope:c.scope},provenance:{pluginName:l.name,marketplaceName:l.marketplace,marketplaceSource:u.sourceUri,installedVersion:c.version,installPath:c.installPath,...d.version&&{catalogVersion:d.version},...c.shadowedByProject&&{shadowedBy:"project"}}};s.push({resource:f,status:c.enabled?"installed":"disabled",installedPath:c.installPath})}let a=s.filter((c)=>c.resource.context.scope===e.scope);return{success:!0,resources:a.filter((c)=>c.status==="installed").map((c)=>c.resource),observations:a}}async inspectForMutation(e,t){let r=Crt(e,t,this.profileName);if(r)return{error:r};let i=await this.inspect(t);if(!i.success)return{error:i.error??"Could not inspect OMP native state"};if(i.observations?.find((o)=>o.resource.resolvedIdentity===e.resolvedIdentity&&o.status==="disabled"))return{error:`OMP plugin '${e.resolvedIdentity}' is installed but disabled in ${t.scope} scope`};return{inspection:i}}async registry(e,t){return rl(e,{readFile:this.reader,allowMissing:t})}async registerMarketplace(e,t){let r=Xv(t,this.profileName);if(r)return{success:!1,error:r};if(!As(e.name))return{success:!1,error:`Invalid OMP marketplace name '${e.name}'`};let i=X0(e.source,void 0,t);if(!i)return{success:!1,error:`OMP marketplace source is invalid: ${e.source}`};let n=await this.registry(t,!0);if(!n.success)return{success:!1,error:n.error??"Could not inspect OMP marketplace registrations"};let o=n.marketplaces.find(({name:u})=>u===e.name);if(o)return o.sourceIdentity===i.identity?{success:!0}:{success:!1,error:`OMP marketplace '${e.name}' is registered from a conflicting source`};let s=n.marketplaces.find(({sourceIdentity:u})=>u===i.identity);if(s)return{success:!1,error:`OMP marketplace source is already registered as '${s.name}', not '${e.name}'`};let a=await this.execute(["plugin","marketplace","add",e.source],t);if(!a.success)return{success:!1,error:`Could not register OMP marketplace '${e.source}': ${ap(a)}`};let c=await this.registry(t,!1);if(!c.success)return{success:!1,registrations:[e.source],error:`OMP marketplace registration completed but could not be verified: ${c.error??"registry inspection failed"}`};let l=c.marketplaces.find(({name:u})=>u===e.name);if(!l||l.sourceIdentity!==i.identity)return{success:!1,registrations:[e.source],error:`OMP marketplace registration completed with an unexpected identity for '${e.name}'`};return{success:!0,registrations:[e.source]}}async removeMarketplaceRegistration(e,t){let r=Xv(t,this.profileName);if(r)return{success:!1,error:r};if(!b4(t.nativeScope))return{success:!1,error:"OMP marketplace registration cleanup requires a named profile"};if(!As(e))return{success:!1,error:`Invalid OMP marketplace name '${e}'`};let i=await this.inspect(t);if(!i.success)return{success:!1,error:i.error??"Could not inspect OMP profile marketplace usage"};let n=i.observations?.find(({resource:c})=>c.provenance.marketplaceName===e);if(n)return{success:!1,error:`OMP marketplace '${e}' is still referenced by '${n.resource.resolvedIdentity}'`};let o=await this.registry(t,!0);if(!o.success)return{success:!1,error:o.error??"Could not inspect OMP marketplace registrations"};if(!o.marketplaces.some(({name:c})=>c===e))return{success:!0};let s=await this.execute(["plugin","marketplace","remove",e],t);if(!s.success)return{success:!1,error:`Could not remove OMP marketplace '${e}': ${ap(s)}`};let a=await this.registry(t,!0);if(!a.success)return{success:!1,error:a.error??`OMP marketplace '${e}' removal could not be verified`};return a.marketplaces.some(({name:c})=>c===e)?{success:!1,error:`OMP marketplace '${e}' remains registered after removal`}:{success:!0}}async install(e,t){let r=await this.inspectForMutation(e,t);if(!r.inspection)return{success:!1,error:r.error??"OMP preflight failed"};let i=await this.registry(t,!0);if(!i.success)return{success:!1,error:i.error??"OMP marketplace inspection failed"};let n=w4(e,i,t),o=r.inspection.resources.some((u)=>u.resolvedIdentity===e.resolvedIdentity);if(o&&!n.marketplace)return{success:!1,error:n.error??"OMP marketplace identity is unresolved"};let s=[];if(!n.marketplace){let u=e.provenance.marketplaceSource,p=e.provenance.marketplaceName;if(!u||!p||!n.missing)return{success:!1,error:n.error??"OMP marketplace identity is unresolved"};let d=await this.registerMarketplace({name:p,source:u},t);if(!d.success)return d;if(s.push(...d.registrations??[]),i=await this.registry(t,!1),!i.success)return{success:!1,error:i.error??"OMP marketplace registration verification failed",...s.length>0&&{registrations:s}};if(n=w4(e,i,t),!n.marketplace)return{success:!1,error:n.error??"OMP marketplace registration has an unexpected identity",...s.length>0&&{registrations:s}}}let a=n.marketplace?await jde(e,n.marketplace,this.reader):"OMP marketplace identity is unresolved";if(a)return{success:!1,error:a,...s.length>0&&{registrations:s}};if(o)return{success:!0};let c=await this.execute(["plugin","install","--scope",t.scope,e.resolvedIdentity],t);if(!c.success)return{success:!1,error:`Could not install OMP plugin '${e.resolvedIdentity}': ${ap(c)}`,...s.length>0&&{registrations:s}};let l=await this.inspect(t);if(!l.success||!l.resources.some((u)=>u.resolvedIdentity===e.resolvedIdentity))return{success:!1,error:l.error??`OMP install completed but '${e.resolvedIdentity}' is absent from ${t.scope} inventory`,...s.length>0&&{registrations:s}};return{success:!0,...s.length>0&&{registrations:s}}}async update(e,t,r){if(e.resolvedIdentity!==t.resolvedIdentity)return{success:!1,error:`Refusing OMP targeted update from '${t.resolvedIdentity}' to '${e.resolvedIdentity}'`};let i=await this.inspectForMutation(e,r);if(!i.inspection)return{success:!1,error:i.error??"OMP preflight failed"};if(!i.inspection.resources.some((l)=>l.resolvedIdentity===e.resolvedIdentity))return{success:!1,error:`OMP plugin '${e.resolvedIdentity}' is not installed in ${r.scope} scope`};let n=await this.registry(r,!1);if(!n.success)return{success:!1,error:n.error??"OMP marketplace inspection failed"};let o=w4(e,n,r);if(!o.marketplace)return{success:!1,error:o.error??"OMP marketplace identity is unresolved"};let s=await jde(e,o.marketplace,this.reader);if(s)return{success:!1,error:s};let a=await this.execute(["plugin","upgrade","--scope",r.scope,e.resolvedIdentity],r);if(!a.success)return{success:!1,error:`Could not upgrade OMP plugin '${e.resolvedIdentity}': ${ap(a)}`};let c=await this.inspect(r);return c.success&&c.resources.some((l)=>l.resolvedIdentity===e.resolvedIdentity)?{success:!0}:{success:!1,error:c.error??`OMP upgrade completed but '${e.resolvedIdentity}' is absent from ${r.scope} inventory`}}async remove(e,t){let r=await this.inspectForMutation(e,t);if(!r.inspection)return{success:!1,error:r.error??"OMP preflight failed"};if(!r.inspection.resources.some((o)=>o.resolvedIdentity===e.resolvedIdentity))return{success:!0};let i=await this.execute(["plugin","uninstall","--scope",t.scope,e.resolvedIdentity],t);if(!i.success)return{success:!1,error:`Could not uninstall OMP plugin '${e.resolvedIdentity}': ${ap(i)}`};let n=await this.inspect(t);if(!n.success)return{success:!1,error:n.error??"OMP removal verification failed"};if(n.resources.some((o)=>o.resolvedIdentity===e.resolvedIdentity))return{success:!1,error:`OMP uninstall completed but '${e.resolvedIdentity}' remains in ${t.scope} inventory`};return{success:!0}}}var drt,frt,mrt,J0,grt,hrt,yrt,vrt,wrt;var $4=R(()=>{Ac();vo();drt=[18,1,17],frt=/^[a-z0-9](?:[a-z0-9.-]{0,62}[a-z0-9])?$/,mrt=/^([^/\s]+)\/([^/\s]+)$/,J0=/[\0\r\n]/,grt=/(?:^|[-_.])(auth|credential|key|password|secret|signature|token)(?:$|[-_.])/i,hrt=S.union([S.string().refine((e)=>e.startsWith("./")&&!J0.test(e)),S.object({source:S.literal("github"),repo:S.string().min(1).refine((e)=>S4(e)!==null),ref:S.string().min(1).optional(),sha:S.string().min(1).optional()}).passthrough(),S.object({source:S.literal("url"),url:S.string().url().refine(Nde),ref:S.string().min(1).optional(),sha:S.string().min(1).optional()}).passthrough(),S.object({source:S.literal("git-subdir"),url:S.string().min(1).refine(Nde),path:S.string().min(1).refine((e)=>!nl(e)&&!e.split(/[\\/]/).includes("..")&&!J0.test(e)),ref:S.string().min(1).optional(),sha:S.string().min(1).optional()}).passthrough(),S.object({source:S.literal("npm"),package:S.string().min(1),version:S.string().min(1).optional(),registry:S.string().min(1).optional()}).passthrough()]),yrt=S.object({name:S.string(),owner:S.object({name:S.string().min(1)}).passthrough(),plugins:S.array(S.object({name:S.string(),source:hrt,version:S.string().min(1).optional()}).passthrough())}).passthrough(),vrt=S.object({version:S.literal(1),marketplaces:S.array(S.object({name:S.string(),sourceType:S.enum(["github","git","url","local"]),sourceUri:S.string().min(1),catalogPath:S.string().refine(nl),addedAt:S.string().refine(Y0),updatedAt:S.string().refine(Y0)}).passthrough())}).passthrough(),wrt=S.object({npm:S.array(S.object({}).passthrough()),marketplace:S.array(S.object({id:S.string(),scope:S.enum(["user","project"]),entries:S.array(S.object({scope:S.enum(["user","project"]),installPath:S.string().refine(nl),version:S.string().min(1),installedAt:S.string().refine(Y0),lastUpdated:S.string().refine(Y0),enabled:S.boolean().optional(),gitCommitSha:S.string().optional()}).passthrough()),shadowedBy:S.literal("project").optional()}).passthrough())}).passthrough()});import{homedir as Ert}from"node:os";import{dirname as Rrt,isAbsolute as Hde,join as ko,resolve as ja,win32 as Wde}from"node:path";import{readFile as I4,realpath as Irt,stat as R4}from"node:fs/promises";import{fileURLToPath as Art}from"node:url";function Pm(e){return ja(e.cwd??process.cwd())}function A4(e){let t=e.roots?.agent;if(t)return ja(t);if(e.scope==="user")return ja(e.root);let r=Pm(e),i=e.env?.PI_CODING_AGENT_DIR;if(i){if(i==="~")return rP(e);if(i.startsWith("~/")||i.startsWith("~\\"))return ja(rP(e),i.slice(2));return ja(r,i)}return ko(rP(e),".pi","agent")}function rP(e){return ja(e.env?.HOME??e.env?.USERPROFILE??Ert())}function Drt(e){return e.scope==="user"?A4(e):ko(Pm(e),".pi")}function Q0(e){return{cwd:Pm(e),...e.env&&{env:e.env}}}function _4(e){if(e.error)return e.error;if(e.signal)return`Pi CLI terminated by ${e.signal}`;return`Pi CLI exited with code ${e.exitCode??"unknown"}`}function Mrt(e){if(!e.startsWith("npm:"))return null;let t=e.slice(4).trim(),r=t.startsWith("@")?/^(@[^/@\s]+\/[^/@\s]+)(?:@([^\s]+))?$/.exec(t):/^([^/@\s]+)(?:@([^\s]+))?$/.exec(t);if(!r?.[1])return null;let i=r[1],n;try{n=decodeURIComponent(i)}catch{return null}if(n.includes("\x00")||n.includes("\\")||n.split("/").some((s)=>s==="."||s==="..")||n.split("/").length!==i.split("/").length)return null;let o=r[2];return{kind:"npm",requested:e,resolvedIdentity:`npm:${i}${o?`@${o}`:""}`,packageIdentity:`npm:${i}`,commandSource:`npm:${i}${o?`@${o}`:""}`,packageName:i}}function P4(e,t){let r;try{r=decodeURIComponent(e)}catch{return!0}for(let i of[e,r])if(i.length===0||i.includes("\x00")||i.includes("\\")||i.startsWith("/")||!t&&i.includes("/")||i.split("/").includes(".."))return!0;return!1}function Nrt(e){let t=e.indexOf("@");if(t<0)return{path:e};let r=e.slice(0,t),i=e.slice(t+1);return r&&i?{path:r,ref:i}:null}function C4(e,t,r){let i=Nrt(r.replace(/^\/+/,""));if(!i)return null;let n=i.path.replace(/\.git$/,"").replace(/\/$/,""),o=t.toLowerCase();if(P4(o,!1)||P4(n,!0)||n.split("/").length<2||i.ref&&P4(i.ref,!0))return null;let s=`${o}/${n}`;return{kind:"git",requested:e,resolvedIdentity:`git:${s}${i.ref?`@${i.ref}`:""}`,packageIdentity:`git:${s}`,commandSource:e,host:o,repositoryPath:n}}function Frt(e){let t=e.startsWith("git:"),r=(t?e.slice(4):e).trim();if(!r)return null;let i=/^git@([^:]+):(.+)$/.exec(r);if(i?.[1]&&i[2])return C4(e,i[1],i[2]);if(/^(?:https?|ssh|git):\/\//i.test(r))try{let s=new URL(r);if(s.password||s.username&&!(s.protocol==="ssh:"&&s.username==="git")||s.search||s.hash)return null;return C4(e,s.hostname,s.pathname)}catch{return null}if(!t)return null;let n=r.indexOf("/");if(n<=0)return null;let o=r.slice(0,n);if(!o.includes(".")&&o!=="localhost")return null;return C4(e,o,r.slice(n+1))}function jrt(e,t){if(e==="~")return t;if(e.startsWith("~/")||e.startsWith("~\\"))return ko(t,e.slice(2));return e}function zrt(e,t){let r=e.startsWith("file://"),i;try{i=r?Art(e):jrt(e,rP(t))}catch{return null}if(!r&&!Hde(i)&&!Wde.isAbsolute(i)&&!i.startsWith("./")&&!i.startsWith("../")&&!i.startsWith(".\\")&&!i.startsWith("..\\"))return null;let n=ja(Pm(t),i);return{kind:"local",requested:e,resolvedIdentity:`local:${n}`,packageIdentity:`local:${n}`,commandSource:n,localPath:n}}function tw(e,t,r={}){let i=e.trim();if(!i)return null;let n=Mrt(i);if(n)return n;let o=Frt(i);if(o)return o;let s=r.baseDir?{...t,cwd:r.baseDir}:t;return zrt(i,s)}function Urt(e,t){if(typeof e==="string"&&e.trim())return{source:e.trim()};if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`packages[${t}] must be a source string or object`);let r=e;if(typeof r.source!=="string"||!r.source.trim())throw Error(`packages[${t}].source must be a non-empty string`);if(r.autoload!==void 0&&typeof r.autoload!=="boolean")throw Error(`packages[${t}].autoload must be a boolean`);let i={source:r.source.trim()};if(typeof r.autoload==="boolean")i.autoload=r.autoload;for(let n of nP){let o=r[n];if(o===void 0)continue;if(!Array.isArray(o)||o.some((s)=>typeof s!=="string"))throw Error(`packages[${t}].${n} must be an array of strings`);i[n]=[...o]}return i}async function rw(e){let t;try{t=await I4(e,"utf8")}catch(o){if(o.code==="ENOENT")return{packages:[],defaultProjectTrust:"ask"};throw Error(`Could not read Pi settings ${e}: ${o instanceof Error?o.message:String(o)}`)}let r;try{r=JSON.parse(t.replace(/^\uFEFF/,""))}catch(o){throw Error(`Could not parse Pi settings ${e}: ${o instanceof Error?o.message:String(o)}`)}if(!r||typeof r!=="object"||Array.isArray(r))throw Error(`Invalid Pi settings ${e}: expected an object`);let i=r;if(i.packages!==void 0&&!Array.isArray(i.packages))throw Error(`Invalid Pi settings ${e}: packages must be an array`);let n=i.defaultProjectTrust??"ask";if(n!=="ask"&&n!=="always"&&n!=="never")throw Error(`Invalid Pi settings ${e}: defaultProjectTrust must be ask, always, or never`);return{packages:(i.packages??[]).map(Urt),defaultProjectTrust:n}}async function eP(e){try{return await Irt(ja(e))}catch(t){if(t.code==="ENOENT")return ja(e);throw t}}async function iP(e){let t=A4(e),r,i;try{r=await eP(e.root),i=await eP(t)}catch(d){return{status:"inspection-failed",allowed:!1,error:`Could not canonicalize Pi trust boundary: ${d instanceof Error?d.message:String(d)}`}}if(Or(r,i))return{status:"denied",allowed:!1,error:"Pi project trust cannot be authorized from an agent root inside the project boundary"};let n=ko(t,"settings.json"),o;try{o=await rw(n)}catch(d){return{status:"inspection-failed",allowed:!1,error:d instanceof Error?d.message:String(d)}}let s=ko(t,"trust.json"),a;try{a=await I4(s,"utf8")}catch(d){if(d.code!=="ENOENT")return{status:"inspection-failed",allowed:!1,error:`Could not read Pi trust store ${s}: ${d instanceof Error?d.message:String(d)}`};a="{}"}let c;try{c=JSON.parse(a.replace(/^\uFEFF/,""))}catch(d){return{status:"inspection-failed",allowed:!1,error:`Could not parse Pi trust store ${s}: ${d instanceof Error?d.message:String(d)}`}}if(!c||typeof c!=="object"||Array.isArray(c))return{status:"inspection-failed",allowed:!1,error:`Invalid Pi trust store ${s}: expected an object`};let l;try{l=await eP(Pm(e))}catch(d){return{status:"inspection-failed",allowed:!1,error:`Could not canonicalize Pi project cwd: ${d instanceof Error?d.message:String(d)}`}}let u=new Map;for(let[d,f]of Object.entries(c)){if(f!==!0&&f!==!1&&f!==null)return{status:"inspection-failed",allowed:!1,error:`Invalid Pi trust store ${s}: decision for ${JSON.stringify(d)} must be true, false, or null`};if(!Hde(d)&&!Wde.isAbsolute(d))return{status:"ambiguous",allowed:!1,error:`Pi trust store contains non-absolute path ${JSON.stringify(d)}`};let m;try{m=await eP(d)}catch(h){return{status:"inspection-failed",allowed:!1,error:`Could not canonicalize Pi trust path ${JSON.stringify(d)}: ${h instanceof Error?h.message:String(h)}`}}let g=u.get(m);if(g!==void 0&&f!==null&&g!==null&&g!==f)return{status:"ambiguous",allowed:!1,error:`Pi trust store has conflicting decisions for ${m}`};if(g===void 0||f!==null)u.set(m,f)}let p=l;while(!0){let d=u.get(p);if(d===!0||d===!1)return{status:d?"allowed":"denied",allowed:d,source:"saved",matchedPath:p,...!d&&{error:`Pi project trust is denied by saved decision ${p}`}};let f=Rrt(p);if(f===p)break;p=f}if(o.defaultProjectTrust==="always")return{status:"allowed",allowed:!0,source:"default"};if(o.defaultProjectTrust==="never")return{status:"denied",allowed:!1,source:"default",error:"Pi defaultProjectTrust is never"};return{status:"ask",allowed:!1,source:"default",error:"Pi project trust requires confirmation. Trust this project in Pi before running native package operations."}}function Lrt(e){if(e.autoload===!1)return!nP.some((t)=>(e[t]??[]).some((r)=>r.length>0&&!r.startsWith("!")&&!r.startsWith("-")));return nP.every((t)=>e[t]!==void 0&&e[t]?.length===0)}function Brt(e,t){if(e.kind==="npm")return ko(t,"npm","node_modules",e.packageName??"");if(e.kind==="git")return ko(t,"git",e.host??"",e.repositoryPath??"");return e.localPath??""}async function qrt(e,t){let r;try{r=await R4(t)}catch(o){return{status:"unusable",error:`Could not inspect installed Pi package ${t}: ${o instanceof Error?o.message:String(o)}`}}if(r.isFile())return e.kind==="local"&&/\.(?:[cm]?[jt]s)$/.test(t)?{status:"installed"}:{status:"unusable",error:`Pi package path is not a directory: ${t}`};if(!r.isDirectory())return{status:"unusable",error:`Pi package path is not a directory: ${t}`};let i=ko(t,"package.json"),n;try{n=await I4(i,"utf8")}catch(o){if(o.code==="ENOENT"){if(e.kind==="npm")return{status:"unusable",error:`Installed npm package has no manifest: ${i}`};for(let s of nP)try{if((await R4(ko(t,s))).isDirectory())return{status:"installed"}}catch{}return{status:"unusable",error:`Installed Pi package has no manifest or conventional resources: ${t}`}}return{status:"unusable",error:`Could not read installed Pi package manifest ${i}: ${o instanceof Error?o.message:String(o)}`}}try{let o=JSON.parse(n.replace(/^\uFEFF/,""));if(!o||typeof o!=="object"||Array.isArray(o))throw Error("expected an object");let s=o.name;if(typeof s!=="string"||!s)throw Error("missing package name");if(e.kind==="npm"&&s!==e.packageName)throw Error(`manifest name ${JSON.stringify(s)} does not match ${JSON.stringify(e.packageName)}`);return{status:"installed"}}catch(o){return{status:"unusable",error:`Invalid installed Pi package manifest ${i}: ${o instanceof Error?o.message:String(o)}`}}}async function tP(e){if(e.scope==="project"){let o=await iP(e);if(!o.allowed)return{success:!1,resources:[],observations:[],error:o.error??`Pi project trust is ${o.status}`}}let t=Drt(e),r;try{r=await rw(ko(t,"settings.json"))}catch(o){return{success:!1,resources:[],observations:[],error:o instanceof Error?o.message:String(o)}}let i=[],n=new Set;for(let o of r.packages){let s=tw(o.source,e,{baseDir:t});if(!s)return{success:!1,resources:[],observations:i,error:`Unsupported Pi package source in ${ko(t,"settings.json")}: ${o.source}`};if(n.has(s.packageIdentity))return{success:!1,resources:[],observations:i,error:`Ambiguous duplicate Pi package identity ${s.packageIdentity} in ${ko(t,"settings.json")}`};n.add(s.packageIdentity);let a=Brt(s,t),c={kind:"package",requestedIdentity:o.source,resolvedIdentity:s.resolvedIdentity,context:e,provenance:{sourceType:s.kind,packageIdentity:s.packageIdentity,commandSource:s.commandSource,installedPath:a}},l=!0;try{await R4(a)}catch(p){if(p.code==="ENOENT")l=!1;else{i.push({resource:c,status:"unusable",installedPath:a,error:`Could not inspect Pi package path ${a}: ${p instanceof Error?p.message:String(p)}`});continue}}if(!l){i.push({resource:c,status:"configured-missing",installedPath:a});continue}let u=await qrt(s,a);if(u.status==="unusable"){i.push({resource:c,status:"unusable",installedPath:a,...u.error&&{error:u.error}});continue}i.push({resource:c,status:Lrt(o)?"disabled":"installed",installedPath:a})}return{success:!0,resources:i.filter((o)=>o.status==="installed").map((o)=>o.resource),observations:i}}function Vrt(e){let t=/(?:^|\s)(\d+)\.(\d+)\.(\d+)(?:[-+\s]|$)/.exec(e.trim());return t?.[1]&&t[2]&&t[3]?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function ew(e){return e.provenance.commandSource??e.requestedIdentity}function Vde(e,t){return e.provenance.packageIdentity??tw(ew(e),t)?.packageIdentity}function E4(e,t,r){return r.scope==="project"?[e,t,"-l","--approve"]:[e,t,"--no-approve"]}class il{client="pi";run;constructor(e={}){this.run=e.execute??Qn}async isAvailable(e){let t=await this.run("pi",["--version"],e?Q0(e):void 0);if(!t.success)return!1;let r=Vrt(t.output);return Boolean(r&&Ko(r,Ort)>=0&&Ko(r,Trt)<0)}supportsScope(e){return!0}resolveSource(e,t,r={}){let i=tw(e,t);if(!i)return{success:!1,error:`Pi native install does not support source '${e}'`};return{success:!0,resource:{kind:"package",requestedIdentity:e,resolvedIdentity:i.resolvedIdentity,context:t,provenance:{...r,sourceType:i.kind,packageIdentity:i.packageIdentity,commandSource:i.commandSource}}}}inspect(e){return tP(e)}async preflightMutation(e,t){let r=await tP(t);if(!r.success)return r.error??"Could not inspect Pi packages";let i=Vde(e,t);if(!i)return"Pi package resource has no valid package identity";let n=r.observations?.find((o)=>o.resource.provenance.packageIdentity===i);if(n?.status==="disabled")return`${i} is configured but disabled in Pi settings; enable it with pi config before syncing`;if(n?.status==="unusable")return n.error??`${i} is unusable in Pi settings`;return null}async install(e,t){let r=await this.preflightMutation(e,t);if(r)return{success:!1,error:r};let i=await this.run("pi",E4("install",ew(e),t),Q0(t));return i.success?{success:!0}:{success:!1,error:_4(i)}}async update(e,t,r){let i=await this.preflightMutation(e,r);if(i)return{success:!1,error:i};let n=Vde(e,r);if(!n)return{success:!1,error:"Pi package resource has no valid package identity"};let o={...r,scope:r.scope==="user"?"project":"user",nativeScope:r.scope==="user"?"project":"user",root:r.scope==="user"?Pm(r):A4(r)};if(o.scope==="project"){if((await iP(o)).allowed){let l=await tP(o);if(!l.success)return{success:!1,error:`Could not prove Pi update scope isolation: ${l.error??"opposite scope inspection failed"}`};if(l.observations?.some((u)=>u.resource.provenance.packageIdentity===n))return{success:!1,error:`Refusing targeted Pi update for ${n}: the same package is configured in both user and project scopes`}}}else{let c=await tP(o);if(!c.success)return{success:!1,error:`Could not prove Pi update scope isolation: ${c.error??"opposite scope inspection failed"}`};if(c.observations?.some((l)=>l.resource.provenance.packageIdentity===n))return{success:!1,error:`Refusing targeted Pi update for ${n}: the same package is configured in both user and project scopes`}}let s;if(e.resolvedIdentity!==t.resolvedIdentity)s=E4("install",ew(e),r);else s=["update",ew(e),r.scope==="project"?"--approve":"--no-approve"];let a=await this.run("pi",s,Q0(r));return a.success?{success:!0}:{success:!1,error:_4(a)}}async remove(e,t){if(t.scope==="project"){let i=await iP(t);if(!i.allowed)return{success:!1,error:i.error??`Pi project trust is ${i.status}`}}let r=await this.run("pi",E4("remove",ew(e),t),Q0(t));return r.success?{success:!0}:{success:!1,error:_4(r)}}}var Ort,Trt,nP;var oP=R(()=>{vo();Gu();Ort=[0,85,1],Trt=[0,86,0],nP=["extensions","skills","prompts","themes"]});import{relative as Hrt,resolve as Cm}from"node:path";import{readFile as Gde,realpath as Wrt,stat as Grt}from"node:fs/promises";function Krt(e,t){return e.packages.find((r)=>r.source===t)}function Jrt(e){return(/^[!+-]/.test(e)?e.slice(1):e).replace(/^\.\//,"").replaceAll("\\","/")}function nw(e,t){let r=e.replaceAll("\\","/"),i=Jrt(t),n=r.split("/").at(-1)??r;return T4.default.isMatch(r,[i])||T4.default.isMatch(n,[i])}function Yrt(e,t){let r=e.extensions;if(e.autoload===!1){let o=!1;for(let s of r??[]){if(!nw(t,s))continue;o=!s.startsWith("!")&&!s.startsWith("-")}return o}if(r===void 0)return!0;if(r.length===0)return!1;let i=r.filter((o)=>!/^[!+-]/.test(o)),n=i.length===0||i.some((o)=>nw(t,o));if(r.some((o)=>o.startsWith("!")&&nw(t,o)))n=!1;if(r.some((o)=>o.startsWith("+")&&nw(t,o)))n=!0;if(r.some((o)=>o.startsWith("-")&&nw(t,o)))n=!1;return n}async function O4(e){return await Grt(e),Wrt(e)}function An(e,t,r={}){return{classification:"inspection-failed",root:e,...r,error:t}}function Xrt(e){if(e.resource.provenance.packageIdentity===Zrt)return!0;let r=e.resource.requestedIdentity;return/(?:^|[\\/])pi-mcp-adapter(?:\.git)?(?:@[^\\/]*)?$/.test(r)}async function D4(e){let t=Cm(e),r={client:"pi",scope:"user",nativeScope:"user",root:t,cwd:t,roots:{agent:t}},i;try{i=await rw(Cm(t,"settings.json"))}catch(y){return An(t,y instanceof Error?y.message:String(y))}let n=await new il().inspect(r);if(!n.success)return An(t,n.error??"Could not inspect selected Pi root");let o=[];for(let y of n.observations??[]){if(Xrt(y)){o.push(y);continue}if(!y.installedPath||y.status==="configured-missing")continue;try{let v=JSON.parse(await Gde(Cm(y.installedPath,"package.json"),"utf8"));if(v&&typeof v==="object"&&!Array.isArray(v)&&v.name===sP)o.push(y)}catch{}}if(o.length===0)return{classification:"absent",root:t};if(o.length>1)return An(t,"Multiple configured packages resolve to pi-mcp-adapter");let s=o[0];if(!s)return{classification:"absent",root:t};let a=s.resource.requestedIdentity,c=s.installedPath;if(!c||s.status==="configured-missing")return{classification:"configured-missing",root:t,packageSource:a,...c&&{packagePath:c}};if(s.status==="unusable")return An(t,s.error??"Configured adapter package is unusable",{packageSource:a,packagePath:c});let l,u;try{l=await O4(t),u=await O4(c)}catch(y){return An(t,`Could not resolve selected Pi package path: ${y instanceof Error?y.message:String(y)}`,{packageSource:a,packagePath:c})}if(!Or(l,u))return An(t,"Configured pi-mcp-adapter package escapes the selected Pi root",{packageSource:a,packagePath:c});let p=Cm(c,"package.json"),d;try{let y=JSON.parse(await Gde(p,"utf8"));if(!y||typeof y!=="object"||Array.isArray(y))throw Error("expected an object");d=y}catch(y){return An(t,`Could not parse pi-mcp-adapter manifest: ${y instanceof Error?y.message:String(y)}`,{packageSource:a,packagePath:c,manifestPath:p})}if(d.name!==sP)return An(t,`Configured adapter manifest name is not ${sP}`,{packageSource:a,packagePath:c,manifestPath:p});if(typeof d.version!=="string"||!d.version)return An(t,"Configured pi-mcp-adapter manifest has no version",{packageSource:a,packagePath:c,manifestPath:p});let f=d.pi;if(!f||typeof f!=="object"||Array.isArray(f))return An(t,"Configured pi-mcp-adapter manifest has no Pi resource declaration",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let m=f.extensions;if(!Array.isArray(m)||m.length===0||m.some((y)=>typeof y!=="string"||!y))return An(t,"Configured pi-mcp-adapter manifest has no valid extension path",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let g=Krt(i,a);if(!g)return An(t,"Configured adapter entry disappeared during inspection",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let h;for(let y of m){if(/[*?]/.test(y)||/^[!+-]/.test(y))return An(t,"pi-mcp-adapter extension path must resolve unambiguously",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let v=Cm(c,y);if(!Or(Cm(c),v))return An(t,"pi-mcp-adapter extension path escapes its package",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let w;try{w=await O4(v)}catch(b){return An(t,`Could not resolve pi-mcp-adapter extension: ${b instanceof Error?b.message:String(b)}`,{packageSource:a,packagePath:c,manifestPath:p,version:d.version})}if(!Or(u,w)||!Or(l,w))return An(t,"pi-mcp-adapter extension escapes the selected Pi root",{packageSource:a,packagePath:c,manifestPath:p,version:d.version});let _=Hrt(c,v).replaceAll("\\","/");if(Yrt(g,_))h=w}if(s.status==="disabled"||!h)return{classification:"installed-disabled",root:t,packageSource:a,packagePath:c,manifestPath:p,version:d.version};return{classification:"usable",root:t,packageSource:a,packagePath:c,manifestPath:p,version:d.version,extensionPath:h}}var T4,sP="pi-mcp-adapter",Zrt;var Zde=R(()=>{Gu();oP();T4=Nt(x0(),1),Zrt=`npm:${sP}`});function Ts(e){switch(e){case"claude":return new vm;case"copilot":return new bm;case"codex":return new Sm;case"pi":return new il;case"omp":return new _m;default:return null}}var Kde=R(()=>{f4();g4();y4();oP();$4()});var za=R(()=>{vo();f4();g4();y4();$4();oP();Zde();Kde()});import{existsSync as efe,lstatSync as Jde,mkdirSync as Qrt,readdirSync as Yde,rmSync as Xde,writeFileSync as ent}from"node:fs";import{readdir as tnt,readFile as rnt}from"node:fs/promises";import{basename as Qde,join as Em,relative as nnt,resolve as int}from"node:path";function M4(e,t){return e<t?-1:e>t?1:0}function aP(e){let t=e.replaceAll("\\","/");if(t.includes("/.pi/skills/")||t.includes("/.omp/skills/"))return 0;if(t.includes("/.agent/skills/")||t.includes("/.agents/skills/"))return 1;return 2}async function ont(e,t){if(t.disabled)return[];let r=new Set,i=t.clients?.some((c)=>c==="pi"||c==="omp")??!1;if(t.skillPaths)for(let c of t.skillPaths)r.add(Lr(e,c));else if(t.clients)for(let c of t.clients){if(c==="pi"||c==="omp"){let u=LL(c,"project",{cwd:e,repoRoot:e});for(let p of u.skillDiscoveryRoots)r.add(p);continue}let l=lr[c];if(l?.skillsPath)r.add(Lr(e,l.skillsPath))}let n=[],o=new Set,s=new Set,a=[...r].sort((c,l)=>i?aP(`${c}/`)-aP(`${l}/`)||M4(c,l):M4(c,l));for(let c of a){let l=c;try{if(Jde(l).isSymbolicLink())continue}catch{continue}let u;try{u=(await tnt(l,{withFileTypes:!0})).sort((p,d)=>M4(p.name,d.name))}catch{continue}for(let p of u){if(!p.isDirectory())continue;let d=Em(l,p.name);try{if(Jde(d).isSymbolicLink())continue}catch{continue}let f=Em(d,"SKILL.md");if(!efe(f))continue;let m=nnt(e,f);if(o.has(m))continue;try{let g=await rnt(f,"utf-8"),h=Bi(g);if(!h)continue;if(i&&s.has(h.name))continue;o.add(m),s.add(h.name),n.push({name:h.name,description:h.description,relativePath:m,fileSize:g.length})}catch{}}}return n}async function cP(e,t,r){let i=r.some((o)=>o==="pi"||o==="omp"),n=new Map;for(let o of t){if(o.skills===!1||o.skills===void 0)continue;let s=int(e,o.path),a=Array.isArray(o.skills)?{skillPaths:o.skills}:{clients:r},c=await ont(s,a);for(let l of c){let p=`${o.path.replace(/[/\\]+$/,"")}/${l.relativePath}`.replace(/\\/g,"/"),d={repoPath:o.path,name:l.name,description:l.description,location:p,fileSize:l.fileSize},f=n.get(l.name);if(!f){n.set(l.name,d);continue}let m=f.location.includes(".agents/"),g=d.location.includes(".agents/");if(i){let h=aP(f.location),y=aP(d.location);if(y<h||y===h&&d.fileSize>f.fileSize)n.set(l.name,d)}else if(g&&!m)n.set(l.name,d);else if(!g&&m);else if(d.fileSize>f.fileSize)n.set(l.name,d)}}return[...n.values()].map(({fileSize:o,...s})=>s)}function lP(e,t){if(t.size===0)return{writtenFiles:[],refs:[]};let r=Em(e,".allagents","skills-index");Qrt(r,{recursive:!0});let i=[],n=[];for(let[,{repoName:o,skills:s}]of t){let a=s.map((u)=>`<skill>
|
|
487
487
|
<name>${u.name}</name>
|
|
488
488
|
<description>${u.description}</description>
|
|
489
489
|
<location>${u.location}</location>
|