allagents 1.16.2-next.1 → 1.16.3-next.1

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.
Files changed (2) hide show
  1. package/dist/index.js +5 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ Did you mean ${Dpe.default.italic(u)}?`}throw Error(c)}},n=(0,zpe.positional)({d
16
16
  `+i),e.push(s+"m+"+hv.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Ede()+t+" "+e[0]}function Ede(){if(FF.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function Rde(...e){return process.stderr.write(mv.formatWithOptions(FF.inspectOpts,...e)+`
17
17
  `)}function Ade(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function Ide(){return process.env.DEBUG}function Ode(e){e.inspectOpts={};let t=Object.keys(FF.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=FF.inspectOpts[t[r]]}hv.exports=tP()(FF);var{formatters:DF}=hv.exports;DF.o=function(e){return this.inspectOpts.colors=this.useColors,mv.inspect(e,this.inspectOpts).split(`
18
18
  `).map((t)=>t.trim()).join(" ")};DF.O=function(e){return this.inspectOpts.colors=this.useColors,mv.inspect(e,this.inspectOpts)}});var gv=I(function(XXe,rP){if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)rP.exports=NF();else rP.exports=zF()});var UF=I(function(im){var Lde=im&&im.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(im,"__esModule",{value:!0});im.parse=Bde;var Ude=Lde(gv()),yv=(0,Ude.default)("cmd-ts:parser");function Bde(e,t){if(yv.enabled){let a={shortFlags:[...t.forceFlagShortNames],longFlags:[...t.forceFlagLongNames],shortOptions:[...t.forceOptionShortNames],longOptions:[...t.forceOptionLongNames]};yv("Registered:",JSON.stringify(a))}let r=[],n=0,s=!1;function i(){return e[n++]}function o(){return e[n]}while(n<e.length){let a=i();if(!a)break;if(a.type==="argumentDivider")continue;if(s){let c=a.raw,l=i();while(l&&(l===null||l===void 0?void 0:l.type)!=="argumentDivider")c+=l.raw,l=i();r.push({type:"positionalArgument",index:a.index,raw:c});continue}if(a.type==="char"){let c=a.raw,l=i();while(l&&(l===null||l===void 0?void 0:l.type)!=="argumentDivider")c+=l.raw,l=i();r.push({type:"positionalArgument",index:a.index,raw:c});continue}if(a.type==="longPrefix"){let c=i();if((c===null||c===void 0?void 0:c.type)==="argumentDivider"||!c){r.push({type:"forcePositional",index:a.index,raw:"--"}),s=!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=i();let u=LF({key:l,delimiterToken:c,forceFlag:t.forceFlagLongNames,getToken:i,peekToken:o,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=i();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=i();let u=c.pop(),p=LF({key:u.raw,delimiterToken:l,forceFlag:t.forceFlagShortNames,forceOption:t.forceOptionShortNames,getToken:i,peekToken:o}),d=[];for(let g of c)d.push({type:"shortOption",index:g.index,raw:g.raw,key:g.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((g)=>g.raw).join("")}${u.raw}`;if(p)m+=p.raw;let h={type:"shortOptions",index:a.index,raw:m,options:d};r.push(h);continue}n++}if(yv.enabled){let a=r.map((c)=>({[c.type]:c.raw}));yv("Parsed items:",JSON.stringify(a))}return r}function LF(e){var t;let{getToken:r,delimiterToken:n,forceFlag:s,key:i,forceOption:o}=e,c=!o.has(i)&&(s.has(i)||((t=e.peekToken())===null||t===void 0?void 0:t.type)!=="char");if(!n||n.raw!=="="&&c)return;let l=n.raw==="="?"=":" ",u=n.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:n.index,delimiter:{type:"delimiter",raw:l,index:u},node:{type:"value",raw:d,index:f},raw:`${l}${d}`}}});var qF=I(function(BF){Object.defineProperty(BF,"__esModule",{value:!0});BF.tokenize=Hde;var qde=tm();function Hde(e){let t=[],r=0,n=(s)=>{t.push(s),r+=s.raw.length};for(let[s,i]of(0,qde.enumerate)(e)){let o=[...i];for(let a=0;a<o.length;a++)if(o[a]==="-"&&o[a+1]==="-")n({type:"longPrefix",raw:"--",index:r}),a++;else if(o[a]==="-")n({type:"shortPrefix",raw:"-",index:r});else n({type:"char",raw:o[a],index:r});if(s+1!==e.length)n({type:"argumentDivider",raw:" ",index:r})}return t}});var GF=I(function(WF){Object.defineProperty(WF,"__esModule",{value:!0});WF.run=Kde;WF.runSafely=nP;WF.dryRun=Jde;WF.parse=Yde;var Qu=ps(),HF=G_(),Wde=AF(),Gde=UF(),Zde=qF();async function Kde(e,t){let r=await nP(e,t);if((0,Qu.isErr)(r))return r.error.run();return r.value}async function nP(e,t){let r=[],n=VF(e,t);try{let s=await e.run({nodes:n,visitedNodes:new Set,hotPath:r});if((0,Qu.isErr)(s))throw new HF.Exit({message:(0,Wde.errorBox)(n,s.error.errors,r),exitCode:1,into:"stderr"});return(0,Qu.ok)(s.value)}catch(s){if(s instanceof HF.Exit)return(0,Qu.err)(s);throw s}}async function Jde(e,t){let r=await nP(e,t);if((0,Qu.isErr)(r))return(0,Qu.err)(r.error.dryRun());return r}function Yde(e,t){let r=[],n=VF(e,t);return e.parse({nodes:n,visitedNodes:new Set,hotPath:r})}function VF(e,t){let o={forceFlagShortNames:new Set,forceFlagLongNames:new Set,forceOptionShortNames:new Set,forceOptionLongNames:new Set};e.register(o);let a=(0,Zde.tokenize)(t);return(0,Gde.parse)(a,o)}});var ZF=I(function($o){var rfe=$o&&$o.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),nfe=$o&&$o.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),sfe=$o&&$o.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")rfe(r,t,n[s])}return nfe(r,t),r}}();Object.defineProperty($o,"__esModule",{value:!0});$o.restPositionals=afe;var vv=sfe(ps()),ife=Kc();function ofe(e){return{helpTopics(){var t,r,n,s;return[{usage:`[...${(r=(t=e.displayName)!==null&&t!==void 0?t:e.type.displayName)!==null&&r!==void 0?r:"arg"}]`,category:"arguments",defaults:[],description:(s=(n=e.description)!==null&&n!==void 0?n:e.type.description)!==null&&s!==void 0?s:""}]},register(t){},async parse({nodes:t,visitedNodes:r}){let n=t.filter((o)=>o.type==="positionalArgument"&&!r.has(o)),s=[],i=[];for(let o of n){r.add(o);let a=await vv.safeAsync(e.type.from(o.raw));if(vv.isOk(a))s.push(a.value);else i.push({nodes:[o],message:a.error.message})}if(i.length>0)return vv.err({errors:i});return vv.ok(s)}}}function afe(e){return ofe({type:ife.string,...e})}});var KF=I(function(Eo){var cfe=Eo&&Eo.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),lfe=Eo&&Eo.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ufe=Eo&&Eo.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")cfe(r,t,n[s])}return lfe(r,t),r}}();Object.defineProperty(Eo,"__esModule",{value:!0});Eo.multiflag=ffe;var ep=ufe(ps()),pfe=lv(),dfe=Qf();function ffe(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 n,s;let i=(0,dfe.findOption)(t,{longNames:[e.long],shortNames:e.short?[e.short]:[]}).filter((l)=>!r.has(l));for(let l of i)r.add(l);let o=[],a=[];for(let l of i){let u=await ep.safeAsync(pfe.boolean.from((s=(n=l.value)===null||n===void 0?void 0:n.node.raw)!==null&&s!==void 0?s:"true"));if(ep.isErr(u))a.push({nodes:[l],message:u.error.message});else o.push(u.value)}if(a.length>0)return ep.err({errors:a});let c=await ep.safeAsync(e.type.from(o));if(ep.isErr(c))return ep.err({errors:[{nodes:i,message:c.error.message}]});return c}}}});var YF=I(function(fi){var mfe=fi&&fi.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),hfe=fi&&fi.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),gfe=fi&&fi.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")mfe(r,t,n[s])}return hfe(r,t),r}}(),yfe=fi&&fi.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(fi,"__esModule",{value:!0});fi.multioption=wfe;var JF=yfe((_o(),Li(xo))),Aa=gfe(ps()),vfe=Qf();function wfe(e){return{helpTopics(){var t,r;let n=(t=e.type.displayName)!==null&&t!==void 0?t:"value",s=`--${e.long} <${n}>`;if(e.short)s+=`, -${e.short}=<${n}>`;let i=[];if(e.defaultValue)try{let o=e.defaultValue();if(e.defaultValueIsSerializable)i.push(`default: ${JF.default.italic(o)}`);else i.push("[...optional]")}catch(o){}else if(e.type.defaultValue)try{let o=e.type.defaultValue();if(e.type.defaultValueIsSerializable)i.push(`default: ${JF.default.italic(o)}`);else i.push("[...optional]")}catch(o){}else if(e.onMissing||e.type.onMissing)i.push("[...optional]");return[{category:"options",usage:s,defaults:i,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 n;let s=(0,vfe.findOption)(t,{longNames:[e.long],shortNames:e.short?[e.short]:[]}).filter((p)=>!r.has(p)),i=e.defaultValue||e.type.defaultValue,o=e.onMissing||e.type.onMissing;if(s.length===0&&i)try{let p=i();return Aa.ok(p)}catch(p){let d=`Failed to resolve default value for '--${e.long}': ${p.message}`;return Aa.err({errors:[{nodes:[],message:d}]})}else if(s.length===0&&o)try{let p=await o();return Aa.ok(p)}catch(p){let d=`Failed to get missing value for '--${e.long}': ${p.message}`;return Aa.err({errors:[{nodes:[],message:d}]})}for(let p of s)r.add(p);let a=[],c=[],l=[];for(let p of s){let d=(n=p.value)===null||n===void 0?void 0:n.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 Aa.err({errors:c});let u=await Aa.safeAsync(e.type.from(a));if(Aa.isErr(u))return Aa.err({errors:[{nodes:s,message:u.error.message}]});return u}}}});var ej=I(function(Ro){var kfe=Ro&&Ro.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Sfe=Ro&&Ro.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),bfe=Ro&&Ro.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")kfe(r,t,n[s])}return Sfe(r,t),r}}();Object.defineProperty(Ro,"__esModule",{value:!0});Ro.union=xfe;var XF=bfe(ps()),QF=em();function xfe(e,{combineErrors:t=(r)=>r.join(`
19
- `)}={}){return{...Object.assign({},...e.map((n)=>(0,QF.typeDef)(n))),async from(n){let s=[];for(let i of e){let o=await XF.safeAsync((0,QF.fromFn)(i)(n));if(XF.isOk(o))return o.value;s.push(o.error.message)}throw Error(t(s))}}}});var rj=I(function(tj){Object.defineProperty(tj,"__esModule",{value:!0});tj.oneOf=Pfe;var _fe=Me("node:util");function Pfe(e){let t=e.map((r)=>(0,_fe.inspect)(r)).join(", ");return{async from(r){let n=e.find((s)=>s===r);if(!n)throw Error(`Invalid value '${r}'. Expected one of: ${t}`);return n},description:`One of ${t}`}}});var nj=I(function(Ao){var $fe=Ao&&Ao.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Efe=Ao&&Ao.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Rfe=Ao&&Ao.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")$fe(r,t,n[s])}return Efe(r,t),r}}();Object.defineProperty(Ao,"__esModule",{value:!0});Ao.rest=Ife;var Afe=Rfe(ps());function Ife(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((o)=>t.nodes.indexOf(o)).filter((o)=>o>-1),n=[],s=Math.max(-1,...r),i=t.nodes.slice(s+1);for(let o of i)switch(o.type){case"positionalArgument":{n.push(o.raw),t.visitedNodes.add(o);break}case"longOption":{n.push(...sP(o)),t.visitedNodes.add(o);break}case"shortOption":{n.push(...sP(o)),t.visitedNodes.add(o);break}case"forcePositional":{n.push(o.raw),t.visitedNodes.add(o);break}case"shortOptions":{let a=o.options.at(-1);t.visitedNodes.add(o),n.push(...sP({...o,value:a===null||a===void 0?void 0:a.value}));break}}return Afe.ok(n)}}}function sP(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 Vi=I(function(Ne){var Ofe=Ne&&Ne.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Tfe=Ne&&Ne.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Ofe(t,e,r)};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.rest=Ne.oneOf=Ne.union=Ne.multioption=Ne.multiflag=Ne.restPositionals=Ne.parse=Ne.run=Ne.runSafely=Ne.dryRun=Ne.positional=Ne.option=Ne.defaultHelpFormatter=Ne.resetHelpFormatter=Ne.setDefaultHelpFormatter=Ne.flag=Ne.command=Ne.binary=Ne.extendType=Ne.subcommands=void 0;var Mfe=SF();Object.defineProperty(Ne,"subcommands",{enumerable:!0,get:function(){return Mfe.subcommands}});var Nfe=em();Object.defineProperty(Ne,"extendType",{enumerable:!0,get:function(){return Nfe.extendType}});Tfe(Kc(),Ne);var Dfe=xF();Object.defineProperty(Ne,"binary",{enumerable:!0,get:function(){return Dfe.binary}});var Ffe=CF();Object.defineProperty(Ne,"command",{enumerable:!0,get:function(){return Ffe.command}});var jfe=lv();Object.defineProperty(Ne,"flag",{enumerable:!0,get:function(){return jfe.flag}});var iP=uv();Object.defineProperty(Ne,"setDefaultHelpFormatter",{enumerable:!0,get:function(){return iP.setDefaultHelpFormatter}});Object.defineProperty(Ne,"resetHelpFormatter",{enumerable:!0,get:function(){return iP.resetHelpFormatter}});Object.defineProperty(Ne,"defaultHelpFormatter",{enumerable:!0,get:function(){return iP.defaultHelpFormatter}});var zfe=$F();Object.defineProperty(Ne,"option",{enumerable:!0,get:function(){return zfe.option}});var Lfe=eP();Object.defineProperty(Ne,"positional",{enumerable:!0,get:function(){return Lfe.positional}});var wv=GF();Object.defineProperty(Ne,"dryRun",{enumerable:!0,get:function(){return wv.dryRun}});Object.defineProperty(Ne,"runSafely",{enumerable:!0,get:function(){return wv.runSafely}});Object.defineProperty(Ne,"run",{enumerable:!0,get:function(){return wv.run}});Object.defineProperty(Ne,"parse",{enumerable:!0,get:function(){return wv.parse}});var Ufe=ZF();Object.defineProperty(Ne,"restPositionals",{enumerable:!0,get:function(){return Ufe.restPositionals}});var Bfe=KF();Object.defineProperty(Ne,"multiflag",{enumerable:!0,get:function(){return Bfe.multiflag}});var qfe=YF();Object.defineProperty(Ne,"multioption",{enumerable:!0,get:function(){return qfe.multioption}});var Hfe=ej();Object.defineProperty(Ne,"union",{enumerable:!0,get:function(){return Hfe.union}});var Vfe=rj();Object.defineProperty(Ne,"oneOf",{enumerable:!0,get:function(){return Vfe.oneOf}});var Wfe=nj();Object.defineProperty(Ne,"rest",{enumerable:!0,get:function(){return Wfe.rest}})});var mi;var om=N(()=>{mi={name:"allagents",version:"1.16.2-next.1",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",release:"bun run scripts/release.ts","release:next":"bun run scripts/release.ts next","release:finalize":"bun run scripts/release.ts finalize",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:"^8.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":"^4.0.0","simple-git":"^3.36.0",typescript:"^7.0.2",zod:"^3.25.76","zod-to-json-schema":"3.25.2"},engines:{node:">=22.0.0",bun:">=1.0.0"}}});var sj,ij=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,oj=(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 aj=N(()=>{sj=(()=>{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 Zfe,Kfe,cj,Jfe,lj,Yfe,Xfe,Qfe,uj=(e,t={},r={})=>{let n=t.limit??1/0,s=t.ellipsis??"",i=t?.ellipsisWidth??(s?uj(s,Qfe,r).width:0),o=0,a=r.controlWidth??0,c=r.tabWidth??8,l=r.emojiWidth??2,u=2,p=r.regularWidth??1,d=r.wideWidth??2,f=[[Yfe,p],[Zfe,0],[Kfe,a],[Jfe,c],[lj,l],[cj,d]],m=0,h=0,g=e.length,y=0,v=!1,w=g,P=Math.max(0,n-i),b=0,S=0,_=0,E=0;e:while(!0){if(S>b||h>=g&&h>m){let C=e.slice(b,S)||e.slice(m,h);y=0;for(let A of C.replaceAll(Xfe,"")){let k=A.codePointAt(0)||0;if(ij(k))E=2;else if(oj(k))E=d;else E=p;if(_+E>P)w=Math.min(w,Math.max(b,m)+y);if(_+E>n){v=!0;break e}y+=A.length,_+=E}b=S=0}if(h>=g)break e;for(let C=0,A=f.length;C<A;C++){let[k,T]=f[C];if(k.lastIndex=h,k.test(e)){if(y=k===cj?sj(e.slice(h,k.lastIndex)):k===lj?1:k.lastIndex-h,E=y*T,_+E>P)w=Math.min(w,h+Math.floor((P-_)/T));if(_+E>n){v=!0;break e}_+=E,b=m,S=h,h=m=k.lastIndex;continue e}}h+=1}return{width:v?P:_,index:v?w:g,truncated:v,ellipsed:v&&n>=i}},pj;var dj=N(()=>{aj();Zfe=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Kfe=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,cj=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Jfe=/\t{1,1000}/y,lj=/[\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,Yfe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Xfe=/\p{M}+/gu,Qfe={limit:1/0,ellipsis:""},pj=uj});var eme,tme=(e,t={})=>pj(e,eme,t).width,gr;var oP=N(()=>{dj();eme={limit:1/0,ellipsis:"",ellipsisWidth:0},gr=tme});function hi(e,t,r){return String(e).normalize().split(ome).map((n)=>ime(n,t,r)).join(`
19
+ `)}={}){return{...Object.assign({},...e.map((n)=>(0,QF.typeDef)(n))),async from(n){let s=[];for(let i of e){let o=await XF.safeAsync((0,QF.fromFn)(i)(n));if(XF.isOk(o))return o.value;s.push(o.error.message)}throw Error(t(s))}}}});var rj=I(function(tj){Object.defineProperty(tj,"__esModule",{value:!0});tj.oneOf=Pfe;var _fe=Me("node:util");function Pfe(e){let t=e.map((r)=>(0,_fe.inspect)(r)).join(", ");return{async from(r){let n=e.find((s)=>s===r);if(!n)throw Error(`Invalid value '${r}'. Expected one of: ${t}`);return n},description:`One of ${t}`}}});var nj=I(function(Ao){var $fe=Ao&&Ao.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Efe=Ao&&Ao.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Rfe=Ao&&Ao.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))n[n.length]=s;return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null){for(var n=e(t),s=0;s<n.length;s++)if(n[s]!=="default")$fe(r,t,n[s])}return Efe(r,t),r}}();Object.defineProperty(Ao,"__esModule",{value:!0});Ao.rest=Ife;var Afe=Rfe(ps());function Ife(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((o)=>t.nodes.indexOf(o)).filter((o)=>o>-1),n=[],s=Math.max(-1,...r),i=t.nodes.slice(s+1);for(let o of i)switch(o.type){case"positionalArgument":{n.push(o.raw),t.visitedNodes.add(o);break}case"longOption":{n.push(...sP(o)),t.visitedNodes.add(o);break}case"shortOption":{n.push(...sP(o)),t.visitedNodes.add(o);break}case"forcePositional":{n.push(o.raw),t.visitedNodes.add(o);break}case"shortOptions":{let a=o.options.at(-1);t.visitedNodes.add(o),n.push(...sP({...o,value:a===null||a===void 0?void 0:a.value}));break}}return Afe.ok(n)}}}function sP(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 Vi=I(function(Ne){var Ofe=Ne&&Ne.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Tfe=Ne&&Ne.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Ofe(t,e,r)};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.rest=Ne.oneOf=Ne.union=Ne.multioption=Ne.multiflag=Ne.restPositionals=Ne.parse=Ne.run=Ne.runSafely=Ne.dryRun=Ne.positional=Ne.option=Ne.defaultHelpFormatter=Ne.resetHelpFormatter=Ne.setDefaultHelpFormatter=Ne.flag=Ne.command=Ne.binary=Ne.extendType=Ne.subcommands=void 0;var Mfe=SF();Object.defineProperty(Ne,"subcommands",{enumerable:!0,get:function(){return Mfe.subcommands}});var Nfe=em();Object.defineProperty(Ne,"extendType",{enumerable:!0,get:function(){return Nfe.extendType}});Tfe(Kc(),Ne);var Dfe=xF();Object.defineProperty(Ne,"binary",{enumerable:!0,get:function(){return Dfe.binary}});var Ffe=CF();Object.defineProperty(Ne,"command",{enumerable:!0,get:function(){return Ffe.command}});var jfe=lv();Object.defineProperty(Ne,"flag",{enumerable:!0,get:function(){return jfe.flag}});var iP=uv();Object.defineProperty(Ne,"setDefaultHelpFormatter",{enumerable:!0,get:function(){return iP.setDefaultHelpFormatter}});Object.defineProperty(Ne,"resetHelpFormatter",{enumerable:!0,get:function(){return iP.resetHelpFormatter}});Object.defineProperty(Ne,"defaultHelpFormatter",{enumerable:!0,get:function(){return iP.defaultHelpFormatter}});var zfe=$F();Object.defineProperty(Ne,"option",{enumerable:!0,get:function(){return zfe.option}});var Lfe=eP();Object.defineProperty(Ne,"positional",{enumerable:!0,get:function(){return Lfe.positional}});var wv=GF();Object.defineProperty(Ne,"dryRun",{enumerable:!0,get:function(){return wv.dryRun}});Object.defineProperty(Ne,"runSafely",{enumerable:!0,get:function(){return wv.runSafely}});Object.defineProperty(Ne,"run",{enumerable:!0,get:function(){return wv.run}});Object.defineProperty(Ne,"parse",{enumerable:!0,get:function(){return wv.parse}});var Ufe=ZF();Object.defineProperty(Ne,"restPositionals",{enumerable:!0,get:function(){return Ufe.restPositionals}});var Bfe=KF();Object.defineProperty(Ne,"multiflag",{enumerable:!0,get:function(){return Bfe.multiflag}});var qfe=YF();Object.defineProperty(Ne,"multioption",{enumerable:!0,get:function(){return qfe.multioption}});var Hfe=ej();Object.defineProperty(Ne,"union",{enumerable:!0,get:function(){return Hfe.union}});var Vfe=rj();Object.defineProperty(Ne,"oneOf",{enumerable:!0,get:function(){return Vfe.oneOf}});var Wfe=nj();Object.defineProperty(Ne,"rest",{enumerable:!0,get:function(){return Wfe.rest}})});var mi;var om=N(()=>{mi={name:"allagents",version:"1.16.3-next.1",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",release:"bun run scripts/release.ts","release:next":"bun run scripts/release.ts next","release:finalize":"bun run scripts/release.ts finalize",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:"^8.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":"^4.0.0","simple-git":"^3.36.0",typescript:"^7.0.2",zod:"^3.25.76","zod-to-json-schema":"3.25.2"},engines:{node:">=22.0.0",bun:">=1.0.0"}}});var sj,ij=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,oj=(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 aj=N(()=>{sj=(()=>{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 Zfe,Kfe,cj,Jfe,lj,Yfe,Xfe,Qfe,uj=(e,t={},r={})=>{let n=t.limit??1/0,s=t.ellipsis??"",i=t?.ellipsisWidth??(s?uj(s,Qfe,r).width:0),o=0,a=r.controlWidth??0,c=r.tabWidth??8,l=r.emojiWidth??2,u=2,p=r.regularWidth??1,d=r.wideWidth??2,f=[[Yfe,p],[Zfe,0],[Kfe,a],[Jfe,c],[lj,l],[cj,d]],m=0,h=0,g=e.length,y=0,v=!1,w=g,P=Math.max(0,n-i),b=0,S=0,_=0,E=0;e:while(!0){if(S>b||h>=g&&h>m){let C=e.slice(b,S)||e.slice(m,h);y=0;for(let A of C.replaceAll(Xfe,"")){let k=A.codePointAt(0)||0;if(ij(k))E=2;else if(oj(k))E=d;else E=p;if(_+E>P)w=Math.min(w,Math.max(b,m)+y);if(_+E>n){v=!0;break e}y+=A.length,_+=E}b=S=0}if(h>=g)break e;for(let C=0,A=f.length;C<A;C++){let[k,T]=f[C];if(k.lastIndex=h,k.test(e)){if(y=k===cj?sj(e.slice(h,k.lastIndex)):k===lj?1:k.lastIndex-h,E=y*T,_+E>P)w=Math.min(w,h+Math.floor((P-_)/T));if(_+E>n){v=!0;break e}_+=E,b=m,S=h,h=m=k.lastIndex;continue e}}h+=1}return{width:v?P:_,index:v?w:g,truncated:v,ellipsed:v&&n>=i}},pj;var dj=N(()=>{aj();Zfe=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Kfe=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,cj=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Jfe=/\t{1,1000}/y,lj=/[\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,Yfe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Xfe=/\p{M}+/gu,Qfe={limit:1/0,ellipsis:""},pj=uj});var eme,tme=(e,t={})=>pj(e,eme,t).width,gr;var oP=N(()=>{dj();eme={limit:1/0,ellipsis:"",ellipsisWidth:0},gr=tme});function hi(e,t,r){return String(e).normalize().split(ome).map((n)=>ime(n,t,r)).join(`
20
20
  `)}var kv="\x1B",yj="›",rme=39,cP="\x07",vj="[",nme="]",wj="m",lP,fj,mj=(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},hj=(e)=>`${kv}${vj}${e}${wj}`,gj=(e)=>`${kv}${lP}${e}${cP}`,aP=(e,t,r)=>{let n=t[Symbol.iterator](),s=!1,i=!1,o=e.at(-1),a=o===void 0?0:gr(o),c=n.next(),l=n.next(),u=0;while(!c.done){let p=c.value,d=gr(p);if(a+d<=r)e[e.length-1]+=p;else e.push(p),a=0;if(p===kv||p===yj)s=!0,i=t.startsWith(lP,u+1);if(s){if(i){if(p===cP)s=!1,i=!1}else if(p===wj)s=!1}else if(a+=d,a===r&&!l.done)e.push(""),a=0;c=l,l=n.next(),u+=p.length}if(o=e.at(-1),!a&&o!==void 0&&o.length&&e.length>1)e[e.length-2]+=e.pop()},sme=(e)=>{let t=e.split(" "),r=t.length;while(r){if(gr(t[r-1]))break;r--}if(r===t.length)return e;return t.slice(0,r).join(" ")+t.slice(r).join("")},ime=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",s,i,o=e.split(" "),a=[""],c=0;for(let p=0;p<o.length;p++){let d=o[p];if(r.trim!==!1){let m=a.at(-1)??"",h=m.trimStart();if(m.length!==h.length)a[a.length-1]=h,c=gr(h)}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=gr(d);if(r.hard&&f>t){let m=t-c,h=1+Math.floor((f-m-1)/t);if(Math.floor((f-1)/t)<h)a.push("");aP(a,d,t),c=gr(a.at(-1)??"");continue}if(c+f>t&&c&&f){if(r.wordWrap===!1&&c<t){aP(a,d,t),c=gr(a.at(-1)??"");continue}a.push(""),c=0}if(c+f>t&&r.wordWrap===!1){aP(a,d,t),c=gr(a.at(-1)??"");continue}a[a.length-1]+=d,c+=f}if(r.trim!==!1)a=a.map((p)=>sme(p));let l=a.join(`
21
21
  `),u=!1;for(let p=0;p<l.length;p++){let d=l[p];if(n+=d,!u){if(u=d>="\uD800"&&d<="\uDBFF",u)continue}else u=!1;if(d===kv||d===yj){fj.lastIndex=p+1;let m=fj.exec(l)?.groups;if(m?.code!==void 0){let h=Number.parseFloat(m.code);s=h===rme?void 0:h}else if(m?.uri!==void 0)i=m.uri.length===0?void 0:m.uri}if(l[p+1]===`
22
22
  `){if(i)n+=gj("");let f=s?mj(s):void 0;if(s&&f)n+=hj(f)}else if(d===`
@@ -536,7 +536,7 @@ ${o.join(`
536
536
  `)+r,s=n+1,n=e.indexOf(`
537
537
  `,s)}while(n!==-1);return i+=e.slice(s),i}function cZe(){let e=new Map;for(let[t,r]of Object.entries(xt)){for(let[n,s]of Object.entries(r))xt[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},r[n]=xt[n],e.set(Number.parseInt(s[0],10),s[1]);Object.defineProperty(xt,t,{value:r,enumerable:!1})}return Object.defineProperty(xt,"codes",{value:e,enumerable:!1}),xt.color.close="\x1B[39m",xt.bgColor.close="\x1B[49m",xt.underlineColor.close="\x1B[59m",xt.color.ansi=Moe(),xt.color.ansi256=w1(),xt.color.ansi16m=k1(),xt.bgColor.ansi=Moe(10),xt.bgColor.ansi256=w1(10),xt.bgColor.ansi16m=k1(10),xt.underlineColor.ansi=iZe,xt.underlineColor.ansi256=w1(20),xt.underlineColor.ansi16m=k1(20),Object.defineProperties(xt,{rgbToAnsi256:{value(t,r,n){if(t===r&&r===n){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[\da-f]{6}|[\da-f]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[n]=r;if(n.length===3)n=[...n].map((i)=>i+i).join("");let s=Number.parseInt(n,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>xt.rgbToAnsi256(...xt.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,n,s;if(t>=232)r=((t-232)*10+8)/255,n=r,s=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,n=Math.floor(a/6)/5,s=a%6/5}let i=Math.max(r,n,s)*2;if(i===0)return 30;let o=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(r));if(i===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,r,n)=>xt.ansi256ToAnsi(xt.rgbToAnsi256(t,r,n)),enumerable:!1},hexToAnsi:{value:(t)=>xt.ansi256ToAnsi(xt.hexToAnsi256(t)),enumerable:!1}}),xt}var Moe=(e=0)=>(t)=>`\x1B[${t+e}m`,w1=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,k1=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`,iZe=(e)=>`\x1B[58;5;${e<90?e-30:e-90+8}m`,xt,r0t,oZe,aZe,n0t,s0t,lZe,wo;var Noe=N(()=>{xt={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}},r0t=Object.keys(xt.modifier),oZe=Object.keys(xt.color),aZe=Object.keys(xt.bgColor),n0t=Object.keys(xt.underlineColor),s0t=[...oZe,...aZe];lZe=cZe(),wo=lZe});import S1 from"node:process";import uZe from"node:os";import Doe from"node:tty";function ii(e,t=globalThis.Deno?globalThis.Deno.args:S1.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),s=t.indexOf("--");return n!==-1&&(s===-1||n<s)}function joe(){return/^\d+$/.test(Bt.FORCE_COLOR)}function pZe(){if(!("FORCE_COLOR"in Bt))return;if(Bt.FORCE_COLOR==="false")return 0;if(Bt.FORCE_COLOR==="true"||Bt.FORCE_COLOR.length===0)return 1;if(!joe())return;return Math.min(Number.parseInt(Bt.FORCE_COLOR,10),3)}function dZe(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function fZe(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n=pZe();if(n!==void 0)Ux=n;let s=r?Ux:n;if(s===0)return 0;if(r){if(ii("color=16m")||ii("color=full")||ii("color=truecolor"))return 3;if(ii("color=256"))return 2}if(s!==void 0&&joe())return s;if("TF_BUILD"in Bt&&"AGENT_NAME"in Bt)return 1;if(e&&!t&&s===void 0)return 0;let i=s||0;if(Bt.TERM==="dumb")return i;if(S1.platform==="win32"){let o=uZe.release().split(".");if(Number(o[0])>=10&&Number(o[2])>=10586)return Number(o[2])>=14931?3:2;return 1}if("CI"in Bt){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((o)=>(o in Bt)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((o)=>(o in Bt))||Bt.CI_NAME==="codeship")return 1;return i}if("TEAMCITY_VERSION"in Bt)return/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(Bt.TEAMCITY_VERSION)?1:0;if(Bt.COLORTERM==="truecolor")return 3;if(Bt.TERM==="xterm-kitty")return 3;if(Bt.TERM==="xterm-ghostty")return 3;if(Bt.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Bt){let o=Number.parseInt((Bt.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(Bt.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(?:color)?$/i.test(Bt.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Bt.TERM))return 1;if("COLORTERM"in Bt)return 1;return i}function Foe(e,t={}){let r=fZe(e,{streamIsTTY:e&&e.isTTY,...t});return dZe(r)}var Bt,Ux,mZe,zoe;var Loe=N(()=>{({env:Bt}=S1);if(ii("no-color")||ii("no-colors")||ii("color=false")||ii("color=never"))Ux=0;else if(ii("color")||ii("colors")||ii("color=true")||ii("color=always"))Ux=1;mZe={stdout:Foe({isTTY:Doe.isatty(1)}),stderr:Foe({isTTY:Doe.isatty(2)})},zoe=mZe});function Ry(e){return yZe(e)}var Uoe,Boe,Cy,$y,qx,Bx,Ey,qoe=(e)=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")},hZe,gZe=(e,t={})=>{if(t.level!==void 0)qoe(t.level);let r=Uoe?Uoe.level:0;e[Bx]=t.level===void 0?r:t.level},yZe=(e)=>{let t=(...r)=>r.join(" ");return gZe(t,e),Object.setPrototypeOf(t,Ry.prototype),t},vZe=(e,t)=>{let r=wo[t];if(e==="rgb"){let s=(o,a,c)=>r.ansi(wo.rgbToAnsi(o,a,c));return[s,s,(o,a,c)=>r.ansi256(wo.rgbToAnsi256(o,a,c)),r.ansi16m]}if(e==="hex"){let s=(o)=>r.ansi(wo.hexToAnsi(o));return[s,s,(o)=>r.ansi256(wo.hexToAnsi256(o)),(o)=>r.ansi16m(...wo.hexToRgb(o))]}let n=(s)=>r.ansi(wo.ansi256ToAnsi(s));return[n,n,r.ansi256,r.ansi256]},wZe,kZe,Hoe=(e,t,r)=>{let n,s;if(r===void 0)n=e,s=t;else n=r.openAll+e,s=t+r.closeAll;return{open:e,close:t,openAll:n,closeAll:s,parent:r}},x1=(e,t,r)=>{let n=(...s)=>{if(s.length===1)return b1(n,""+s[0]);if(s.length===2)return b1(n,s[0]+" "+s[1]);return b1(n,s.join(" "))};return Object.setPrototypeOf(n,kZe),n[Cy]=e[Cy]??e,n[$y]=t,n[qx]=r,n},b1=(e,t)=>{if(e[Cy][Bx]<=0||!t)return e[qx]?"":t;let r=e[$y];if(r===void 0)return t;let{openAll:n,closeAll:s}=r;if(t.includes("\x1B"))while(r!==void 0)t=Ooe(t,r.close,r.open),r=r.parent;let i=t.indexOf(`
538
538
  `);if(i!==-1)t=Toe(t,s,n,i);return n+t+s},SZe,f0t,dt;var Ay=N(()=>{Noe();Loe();({stdout:Uoe,stderr:Boe}=zoe),Cy=Symbol("GENERATOR"),$y=Symbol("STYLER"),qx=Symbol("IS_EMPTY"),Bx=Symbol("LEVEL"),Ey=Object.create(null),hZe={enumerable:!0,get(){return this[Bx]},set(e){qoe(e),this[Bx]=e}};Object.setPrototypeOf(Ry.prototype,Function.prototype);for(let[e,t]of Object.entries(wo))Ey[e]={get(){let r=x1(this,Hoe(t.open,t.close,this[$y]),this[qx]);return Object.defineProperty(this,e,{value:r}),r}};Ey.visible={get(){let e=x1(this,this[$y],!0);return Object.defineProperty(this,"visible",{value:e}),e}};wZe=["rgb","hex","ansi256"];for(let e of wZe){let t=e[0].toUpperCase()+e.slice(1);for(let[r,n]of[[e,"color"],["bg"+t,"bgColor"],["underline"+t,"underlineColor"]]){let{close:s}=wo[n],i=vZe(e,n);Ey[r]={get(){let o=function(a,c,l){let u=i[this.level](a,c,l);return x1(this,Hoe(u,s,this[$y]),this[qx])};return Object.defineProperty(this,r,{value:o}),o}}}}kZe=Object.defineProperties(()=>{},{...Ey,level:{enumerable:!0,get(){return this[Cy].level},set(e){this[Cy].level=e}}});Object.defineProperties(Ry.prototype,{...Ey,level:hZe});SZe=Ry(),f0t=Ry({level:Boe?Boe.level:0}),dt=SZe});function PZe(e,t){if(e.trim().length<2)throw new ji("Search query must be at least 2 characters.","validation");if(t.page!==void 0&&t.page<1)throw new ji("--page must be >= 1.","validation");if(t.limit!==void 0&&(t.limit<1||t.limit>100))throw new ji("--limit must be between 1 and 100.","validation");if(t.owner!==void 0&&!bZe.test(t.owner))throw new ji(`Invalid --owner "${t.owner}": GitHub owners are alphanumeric + dashes, ≤ 39 chars.`,"validation")}function CZe(e){return _Ze.test(e)}function $Ze(e,t){let r=e.trim(),n=r.replace(/ /g,"-"),s=t?`user:${t}`:"",i=(...a)=>a.filter(Boolean).join(" "),o=[{priority:1,label:"path",q:i("filename:SKILL.md",`path:${n}`,s)}];if(n!==r)o.push({priority:2,label:"hyphen",q:i("filename:SKILL.md",n,s)});if(!t&&CZe(r))o.push({priority:3,label:"owner",q:`filename:SKILL.md user:${r}`});return o.push({priority:4,label:"primary",q:i("filename:SKILL.md",r,s)}),o}function EZe(e,t){let r=typeof t==="object"&&t!==null&&"message"in t?String(t.message??""):"";if(e===401)return new ji("GitHub Code Search requires authentication. Run `gh auth login` or set GITHUB_TOKEN.","api");if(e===403&&/rate limit/i.test(r))return new ji("GitHub Code Search rate limit exceeded. Authenticate with `gh auth login` or set GITHUB_TOKEN to raise the quota.","rate-limit");if(e===422)return new ji(`GitHub rejected the search query: ${r||"unprocessable entity"}.`,"api");return new ji(`GitHub Code Search returned ${e}${r?`: ${r}`:""}.`,"api")}async function RZe(){let e=process.env.GITHUB_TOKEN||process.env.GH_TOKEN;if(e)return e;try{let{execFile:t}=await import("node:child_process");return await new Promise((r)=>{t("gh",["auth","token"],{timeout:3000},(n,s)=>{r(n?void 0:s.trim()||void 0)})})}catch{return}}function $a(e){return e.namespace?`${e.namespace}/${e.name}`:e.name}function AZe(e,t){let r=e.split("/").filter(Boolean),n=r.lastIndexOf("skills");if(n!==-1){let o=r.slice(n+1),a=o[o.length-1]?.toLowerCase()==="skill.md"?o.slice(0,-1):o;if(a.length>=2){let c=a[0]??"",l=a[1]??"";if(c&&l)return{namespace:c,name:l}}if(a.length===1&&a[0])return{namespace:n>=2&&r[n-2]==="plugins"?r[n-1]??"":"",name:a[0]}}let i=(r[r.length-1]?.toLowerCase()??"").endsWith(".md")?r.length-2:r.length-1;if(i>=0){let o=r[i];if(o)return{namespace:"",name:o}}return{namespace:"",name:t}}async function Zoe(e,t,r,n,s){let i=new URL("https://api.github.com/search/code");i.searchParams.set("q",e),i.searchParams.set("per_page",String(r)),i.searchParams.set("page",String(t));let o={Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"allagents-cli"};if(n)o.Authorization=`token ${n}`;let a=await s(i.toString(),{headers:o}),c=null;try{c=await a.json()}catch{}if(!a.ok)throw EZe(a.status,c);let l=c,u=(l.items??[]).map((p)=>{let d=p.path??"",f=p.repository?.full_name??"",m=f.split("/").pop()??"",{namespace:h,name:g}=AZe(d,m);return{name:g,namespace:h,repo:f,path:d,description:p.repository?.description??"",sha:p.sha??"",stars:p.repository?.stargazers_count??0}});return{items:u,total:l.total_count??u.length,truncated:Boolean(l.incomplete_results)}}async function IZe(e,t,r,n,s){let i=t*r*3,o=Math.min(Math.max(1,Math.ceil(i/Iy)),xZe/Iy),a=[],c=0,l=!1;for(let u=1;u<=o;u+=1){let p=await Zoe(e,u,Iy,n,s);if(a.push(...p.items),c=p.total,l=l||p.truncated,p.items.length<Iy)break}return{items:a,total:c,truncated:l}}async function Hx(e,t={},r={}){PZe(e,t);let n=r.fetch??fetch,s=r.logger??((b)=>process.stderr.write(`${b}
539
- `)),i=t.page??1,o=t.limit??15,a=await(r.tokenResolver??RZe)(),c=$Ze(e,t.owner),l=await Promise.allSettled(c.map((b)=>b.priority===4?IZe(b.q,i,o,a,n):Zoe(b.q,1,Iy,a,n))),u=c.findIndex((b)=>b.priority===4),p=l[u];if(p?.status==="rejected")throw p.reason;let d=[];for(let b=0;b<c.length;b++){let S=c[b],_=l[b];if(!S||!_)continue;if(_.status==="fulfilled")d.push({priority:S.priority,result:_.value});else{let E=_.reason instanceof Error?_.reason.message:String(_.reason);s(`Warning: skill search "${S.label}" query failed: ${E}`)}}d.sort((b,S)=>b.priority-S.priority);let f=d.flatMap((b)=>b.result.items),h=OZe(f).filter((b)=>!(b.path.split("/")[0]??"").startsWith("."));Woe(h,e);let g=NZe(h,i,o);await Promise.all([jZe(g,a,n),zZe(g,a,n)]);let y=MZe(g,e);Woe(y,e);let v=DZe(y),{items:w,totalPages:P}=FZe(v,i,o);return{query:e,items:w,total:v.length,truncated:d.some((b)=>b.result.truncated)||P>i}}function OZe(e){let t=new Set,r=[];for(let n of e){let s=`${n.repo}#${$a(n)}`;if(t.has(s))continue;t.add(s),r.push(n)}return r}function TZe(e){let[t=e.repo,r=""]=e.repo.split("/",2);return{owner:t,repoName:r}}function Voe(e,t){let r=t.trim().toLowerCase(),n=r.replace(/ /g,"-"),s=e.name.toLowerCase(),i=e.namespace.toLowerCase(),o=e.description.toLowerCase(),a=0;if(s===r||s===n)a+=3000;else if(s.includes(r)||s.includes(n))a+=1000;if(i?.includes(r))a+=500;if(o.includes(r))a+=100;if(e.stars>0)a+=Math.floor(Math.sqrt(e.stars)*30);return a}function Woe(e,t){e.sort((r,n)=>Voe(n,t)-Voe(r,t))}function MZe(e,t){let r=t.trim().toLowerCase(),n=r.replace(/ /g,"-");return e.filter((s)=>{let{owner:i,repoName:o}=TZe(s);return s.name.toLowerCase().includes(r)||s.name.toLowerCase().includes(n)||s.namespace.toLowerCase().includes(r)||s.description.toLowerCase().includes(r)||i.toLowerCase().includes(r)||o.toLowerCase().includes(r)})}function NZe(e,t,r){let n=Math.max(t*r*3,r*3);return e.length>n?e.slice(0,n):e}function DZe(e){let r=new Map,n=[];for(let s of e){let i=$a(s).toLowerCase(),o=r.get(i)??0;if(o>=3)continue;r.set(i,o+1),n.push(s)}return n}function FZe(e,t,r){if(e.length===0)return{items:[],totalPages:0};let n=Math.ceil(e.length/r),s=(t-1)*r;return{items:e.slice(s,s+r),totalPages:n}}async function jZe(e,t,r){let n=[...new Set(e.map((o)=>o.repo))],s=Joe(t),i=new Map;await Koe(n,Goe,async(o)=>{try{let a=await r(`https://api.github.com/repos/${o}`,{headers:s});if(!a.ok)return;let c=await a.json();i.set(o,c.stargazers_count??0)}catch{}});for(let o of e){let a=i.get(o.repo);if(a!==void 0)o.stars=a}}async function zZe(e,t,r){let n=Joe(t),s=new Map,i=[...new Set(e.map((o)=>`${o.repo}#${o.sha}`))];await Koe(i,Goe,async(o)=>{let[a,c]=o.split("#");if(!a||!c)return;try{let l=await r(`https://api.github.com/repos/${a}/git/blobs/${c}`,{headers:n});if(!l.ok)return;let u=await l.json(),p=LZe(u.content,u.encoding);if(!p)return;let d=$s(p);if(!d?.description)return;s.set(o,d.description)}catch{}});for(let o of e){let a=s.get(`${o.repo}#${o.sha}`);if(a)o.description=a}}async function Koe(e,t,r){if(e.length===0)return;let n=0,s=async()=>{while(!0){let o=n++;if(o>=e.length)return;await r(e[o])}},i=Math.min(t,e.length);await Promise.all(Array.from({length:i},()=>s()))}function Joe(e){let t={Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"allagents-cli"};if(e)t.Authorization=`token ${e}`;return t}function LZe(e,t){if(!e)return;if(!t||t==="utf-8")return e;if(t!=="base64")return;return Buffer.from(e.replace(/\s+/g,""),"base64").toString("utf8")}var bZe,Iy=100,xZe=1000,_Ze,Goe=10,ji;var _1=N(()=>{tf();bZe=/^[A-Za-z0-9-]{1,39}$/,_Ze=/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?$/;ji=class ji extends Error{kind;constructor(e,t){super(e);this.kind=t;this.name="SkillSearchError"}}});import{join as UZe}from"node:path";function qZe(e){return!e.json&&!e.ci&&e.stdinIsTTY&&e.stdoutIsTTY}function HZe(e){if(typeof e!=="string")return[...e];let t=e.split(",").map((r)=>r.trim());if(t.some((r)=>r.length===0))throw new Ea("Client list must contain one or more comma-separated client names.");return t}function P1(e,t="Clients"){if(e.length===0)throw new Ea(`${t} must include at least one client.`);let r=new Set;for(let n of e){let s=Lr.safeParse(n);if(!s.success)throw new Ea(`Invalid client '${n}'. Expected one of: ${Qi.join(", ")}.`);r.add(s.data)}return Jo.filter((n)=>r.has(n))}function Yoe(e,t){return P1(fn([...e]),t)}function VZe(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function WZe(e,t,r){if(r==="override")return typeof e==="string"?{source:e,clients:[...t]}:{...e,clients:[...t]};if(typeof e==="string"||e.clients===void 0)return e;let{clients:n,...s}=e;return s}function Xoe(e,t){return e==="user"?gt():UZe(t,K,X)}function Qoe(e){if(e!=="project"&&e!=="user")throw new Ea(`Invalid scope '${e}'. Expected project or user.`);return e}async function GZe(e,t){let r=ce(t),n=e.find((i)=>ce(i)===r);if(n!==void 0)return n;let s=await Ir(r);if(!s)return;for(let i of e)if(await Ir(ce(i))===s)return i;return}async function Lf(e){let t=qZe(e.environment),r=t?e.prompts:void 0;if(t&&!r)throw new Ea("Interactive target resolution requires prompt ports.");let n=St(e.workspacePath),s=Xoe("project",e.workspacePath),i=Xoe("user",e.workspacePath),o=n?["user"]:["project","user"],a;if(e.scope!==void 0){if(a=Qoe(e.scope),n&&a==="project")throw new Ea(`Project scope is unavailable because ${s} is the user config. Use user scope instead.`)}else if(r){let A=e.defaultScope??"project",k=await r.selectScope({options:o.map((T)=>({scope:T,configPath:T==="project"?s:i,description:T==="project"?"this workspace":"all workspaces"})),initialValue:o.includes(A)?A:"user",...n&&{aliasNotice:"Project and user scope resolve to the same config; only user scope is available."}});if(k===null)return null;if(a=Qoe(k),!o.includes(a))throw new Ea(`Scope '${a}' is not available here.`)}else a=n?"user":e.defaultScope??"project";let c=a==="project"?s:i,l=e.scopeStates[a],u=typeof l==="function"?await l():l,p=u?.clients??[],d=u?.clients??e.defaultClients?.[a]??BZe[a],f;if(e.clients!==void 0)f=P1(HZe(e.clients),"Explicit clients");else{let A=d.length===0?[]:Yoe(d,"Initial clients");if(r)while(!0){let k=await r.selectClients({scope:a,configPath:c,initialValues:A,configuredClients:p});if(k===null)return null;if(k.length===0)continue;f=P1(k,"Selected clients");break}else f=A}if(a==="user"){let A=f.filter((k)=>!e6(k,"user"));if(A.length>0)throw new Ea(`User scope is unavailable for: ${A.join(", ")}`)}let m=u?u.clients.length===0?[]:Yoe(u.clients,"Configured clients"):null,h=m===null?"initialize":VZe(m,f)?"inherit":"override",g=WZe(e.declaration,f,h),y=u?[...u.clients]:[...f],v=await GZe(u?.plugins??[],e.declaration),w=og(v,g,ce(e.declaration),y),P=f.map((A)=>p.find((k)=>typeof k==="string"?k===A:k.name===A)??A),b=kn([w],y,a).plans[0],S=new Set(b?.clients??[]),_=new Set(b?.nativeClients??[]),E=f.flatMap((A)=>{if(S.has(A))return[{client:A,method:"file"}];if(_.has(A))return[{client:A,method:"native"}];return[]}),C={action:e.action,payload:e.payload,scope:a,configPath:c,clients:f,effectiveMethods:E,disposition:h};if(r){if(await r.showSummary(C),!e.yes){if(await r.confirm({summary:C,initialValue:!0})!==!0)return null}}return{scope:a,configPath:c,clients:f,disposition:h,prospectiveDeclaration:w,selectedClientEntries:P,summary:C}}var Ea,BZe;var Vx=N(()=>{st();As();ss();_r();et();Qn();Ea=class Ea extends Error{constructor(e){super(e);this.name="InstallTargetValidationError"}};BZe={project:["universal"],user:["copilot","codex","cursor","opencode","gemini","vscode"]}});var tae={};ai(tae,{buildClientOptions:()=>Uf,isInteractive:()=>eae,promptForClients:()=>C1});function Uf(e="project",t=[]){return t6(e).map((r)=>({value:r,label:r,hint:IA(t,r)==="native"?"Native install":Eh(r,e).skillsPath}))}function eae(){if(rl())return!1;return Boolean(process.stdin.isTTY&&process.stdout.isTTY)}async function C1(e={}){if(!eae())return["universal"];let t=e.clientEntries??[],r=Uf(e.scope,t),n=await ZZe({message:"Which AI clients do you use?",options:r,initialValues:[...e.initialValues??["universal","copilot","vscode"]],required:!0});if(ze(n))return null;return n}var ZZe;var Oy=N(()=>{jr();et();Qn();({autocompleteMultiselect:ZZe}=tr)});function Wx(e){return{json:e,ci:rl(),stdinIsTTY:Boolean(process.stdin.isTTY),stdoutIsTTY:Boolean(process.stdout.isTTY)}}function Gx(e){return!e.json&&!e.ci&&e.stdinIsTTY&&e.stdoutIsTTY}function JZe(e){let t=new Map(e.effectiveMethods.map(({client:s,method:i})=>[s,i])),r=e.clients.map((s)=>`${s} (${t.get(s)??"unsupported"})`).join(", "),n=e.scope==="project"?"Project":"User";return[`${e.action}: ${e.payload}`,`Scope: ${n} — ${e.configPath}`,`Clients: ${r}`,`Targeting: ${KZe[e.disposition]}`].join(`
539
+ `)),i=t.page??1,o=t.limit??15,a=await(r.tokenResolver??RZe)(),c=$Ze(e,t.owner),l=await Promise.allSettled(c.map((b)=>b.priority===4?IZe(b.q,i,o,a,n):Zoe(b.q,1,Iy,a,n))),u=c.findIndex((b)=>b.priority===4),p=l[u];if(p?.status==="rejected")throw p.reason;let d=[];for(let b=0;b<c.length;b++){let S=c[b],_=l[b];if(!S||!_)continue;if(_.status==="fulfilled")d.push({priority:S.priority,result:_.value});else{let E=_.reason instanceof Error?_.reason.message:String(_.reason);s(`Warning: skill search "${S.label}" query failed: ${E}`)}}d.sort((b,S)=>b.priority-S.priority);let f=d.flatMap((b)=>b.result.items),h=OZe(f).filter((b)=>!(b.path.split("/")[0]??"").startsWith("."));Woe(h,e);let g=NZe(h,i,o);await Promise.all([jZe(g,a,n),zZe(g,a,n)]);let y=MZe(g,e);Woe(y,e);let v=DZe(y),{items:w,totalPages:P}=FZe(v,i,o);return{query:e,items:w,total:v.length,truncated:d.some((b)=>b.result.truncated)||P>i}}function OZe(e){let t=new Set,r=[];for(let n of e){let s=`${n.repo}#${$a(n)}`;if(t.has(s))continue;t.add(s),r.push(n)}return r}function TZe(e){let[t=e.repo,r=""]=e.repo.split("/",2);return{owner:t,repoName:r}}function Voe(e,t){let r=t.trim().toLowerCase(),n=r.replace(/ /g,"-"),s=e.name.toLowerCase(),i=e.namespace.toLowerCase(),o=e.description.toLowerCase(),a=0;if(s===r||s===n)a+=3000;else if(s.includes(r)||s.includes(n))a+=1000;if(i?.includes(r))a+=500;if(o.includes(r))a+=100;if(e.stars>0)a+=Math.floor(Math.sqrt(e.stars)*30);return a}function Woe(e,t){e.sort((r,n)=>Voe(n,t)-Voe(r,t))}function MZe(e,t){let r=t.trim().toLowerCase(),n=r.replace(/ /g,"-");return e.filter((s)=>{let{owner:i,repoName:o}=TZe(s);return s.name.toLowerCase().includes(r)||s.name.toLowerCase().includes(n)||s.namespace.toLowerCase().includes(r)||s.description.toLowerCase().includes(r)||i.toLowerCase().includes(r)||o.toLowerCase().includes(r)})}function NZe(e,t,r){let n=Math.max(t*r*3,r*3);return e.length>n?e.slice(0,n):e}function DZe(e){let r=new Map,n=[];for(let s of e){let i=$a(s).toLowerCase(),o=r.get(i)??0;if(o>=3)continue;r.set(i,o+1),n.push(s)}return n}function FZe(e,t,r){if(e.length===0)return{items:[],totalPages:0};let n=Math.ceil(e.length/r),s=(t-1)*r;return{items:e.slice(s,s+r),totalPages:n}}async function jZe(e,t,r){let n=[...new Set(e.map((o)=>o.repo))],s=Joe(t),i=new Map;await Koe(n,Goe,async(o)=>{try{let a=await r(`https://api.github.com/repos/${o}`,{headers:s});if(!a.ok)return;let c=await a.json();i.set(o,c.stargazers_count??0)}catch{}});for(let o of e){let a=i.get(o.repo);if(a!==void 0)o.stars=a}}async function zZe(e,t,r){let n=Joe(t),s=new Map,i=[...new Set(e.map((o)=>`${o.repo}#${o.sha}`))];await Koe(i,Goe,async(o)=>{let[a,c]=o.split("#");if(!a||!c)return;try{let l=await r(`https://api.github.com/repos/${a}/git/blobs/${c}`,{headers:n});if(!l.ok)return;let u=await l.json(),p=LZe(u.content,u.encoding);if(!p)return;let d=$s(p);if(!d?.description)return;s.set(o,d.description)}catch{}});for(let o of e){let a=s.get(`${o.repo}#${o.sha}`);if(a)o.description=a}}async function Koe(e,t,r){if(e.length===0)return;let n=0,s=async()=>{while(!0){let o=n++;if(o>=e.length)return;await r(e[o])}},i=Math.min(t,e.length);await Promise.all(Array.from({length:i},()=>s()))}function Joe(e){let t={Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"allagents-cli"};if(e)t.Authorization=`token ${e}`;return t}function LZe(e,t){if(!e)return;if(!t||t==="utf-8")return e;if(t!=="base64")return;return Buffer.from(e.replace(/\s+/g,""),"base64").toString("utf8")}var bZe,Iy=100,xZe=1000,_Ze,Goe=10,ji;var _1=N(()=>{tf();bZe=/^[A-Za-z0-9-]{1,39}$/,_Ze=/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?$/;ji=class ji extends Error{kind;constructor(e,t){super(e);this.kind=t;this.name="SkillSearchError"}}});import{join as UZe}from"node:path";function qZe(e){return!e.json&&!e.ci&&e.stdinIsTTY&&e.stdoutIsTTY}function HZe(e){if(typeof e!=="string")return[...e];let t=e.split(",").map((r)=>r.trim());if(t.some((r)=>r.length===0))throw new Ea("Client list must contain one or more comma-separated client names.");return t}function P1(e,t="Clients"){if(e.length===0)throw new Ea(`${t} must include at least one client.`);let r=new Set;for(let n of e){let s=Lr.safeParse(n);if(!s.success)throw new Ea(`Invalid client '${n}'. Expected one of: ${Qi.join(", ")}.`);r.add(s.data)}return Jo.filter((n)=>r.has(n))}function Yoe(e,t){return P1(fn([...e]),t)}function VZe(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function WZe(e,t,r){if(r==="override")return typeof e==="string"?{source:e,clients:[...t]}:{...e,clients:[...t]};if(typeof e==="string"||e.clients===void 0)return e;let{clients:n,...s}=e;return s}function Xoe(e,t){return e==="user"?gt():UZe(t,K,X)}function Qoe(e){if(e!=="project"&&e!=="user")throw new Ea(`Invalid scope '${e}'. Expected project or user.`);return e}async function GZe(e,t){let r=ce(t),n=e.find((i)=>ce(i)===r);if(n!==void 0)return n;let s=await Ir(r);if(!s)return;for(let i of e)if(await Ir(ce(i))===s)return i;return}async function Lf(e){let t=qZe(e.environment)&&!e.yes,r=t?e.prompts:void 0;if(t&&!r)throw new Ea("Interactive target resolution requires prompt ports.");let n=St(e.workspacePath),s=Xoe("project",e.workspacePath),i=Xoe("user",e.workspacePath),o=n?["user"]:["project","user"],a;if(e.scope!==void 0){if(a=Qoe(e.scope),n&&a==="project")throw new Ea(`Project scope is unavailable because ${s} is the user config. Use user scope instead.`)}else if(r){let A=e.defaultScope??"project",k=await r.selectScope({options:o.map((T)=>({scope:T,configPath:T==="project"?s:i,description:T==="project"?"this workspace":"all workspaces"})),initialValue:o.includes(A)?A:"user",...n&&{aliasNotice:"Project and user scope resolve to the same config; only user scope is available."}});if(k===null)return null;if(a=Qoe(k),!o.includes(a))throw new Ea(`Scope '${a}' is not available here.`)}else a=n?"user":e.defaultScope??"project";let c=a==="project"?s:i,l=e.scopeStates[a],u=typeof l==="function"?await l():l,p=u?.clients??[],d=u?.clients??e.defaultClients?.[a]??BZe[a],f;if(e.clients!==void 0)f=P1(HZe(e.clients),"Explicit clients");else{let A=d.length===0?[]:Yoe(d,"Initial clients");if(r)while(!0){let k=await r.selectClients({scope:a,configPath:c,initialValues:A,configuredClients:p});if(k===null)return null;if(k.length===0)continue;f=P1(k,"Selected clients");break}else f=A}if(a==="user"){let A=f.filter((k)=>!e6(k,"user"));if(A.length>0)throw new Ea(`User scope is unavailable for: ${A.join(", ")}`)}let m=u?u.clients.length===0?[]:Yoe(u.clients,"Configured clients"):null,h=m===null?"initialize":VZe(m,f)?"inherit":"override",g=WZe(e.declaration,f,h),y=u?[...u.clients]:[...f],v=await GZe(u?.plugins??[],e.declaration),w=og(v,g,ce(e.declaration),y),P=f.map((A)=>p.find((k)=>typeof k==="string"?k===A:k.name===A)??A),b=kn([w],y,a).plans[0],S=new Set(b?.clients??[]),_=new Set(b?.nativeClients??[]),E=f.flatMap((A)=>{if(S.has(A))return[{client:A,method:"file"}];if(_.has(A))return[{client:A,method:"native"}];return[]}),C={action:e.action,payload:e.payload,scope:a,configPath:c,clients:f,effectiveMethods:E,disposition:h};if(r){if(await r.showSummary(C),!e.yes){if(await r.confirm({summary:C,initialValue:!0})!==!0)return null}}return{scope:a,configPath:c,clients:f,disposition:h,prospectiveDeclaration:w,selectedClientEntries:P,summary:C}}var Ea,BZe;var Vx=N(()=>{st();As();ss();_r();et();Qn();Ea=class Ea extends Error{constructor(e){super(e);this.name="InstallTargetValidationError"}};BZe={project:["universal"],user:["copilot","codex","cursor","opencode","gemini","vscode"]}});var tae={};ai(tae,{buildClientOptions:()=>Uf,isInteractive:()=>eae,promptForClients:()=>C1});function Uf(e="project",t=[]){return t6(e).map((r)=>({value:r,label:r,hint:IA(t,r)==="native"?"Native install":Eh(r,e).skillsPath}))}function eae(){if(rl())return!1;return Boolean(process.stdin.isTTY&&process.stdout.isTTY)}async function C1(e={}){if(!eae())return["universal"];let t=e.clientEntries??[],r=Uf(e.scope,t),n=await ZZe({message:"Which AI clients do you use?",options:r,initialValues:[...e.initialValues??["universal","copilot","vscode"]],required:!0});if(ze(n))return null;return n}var ZZe;var Oy=N(()=>{jr();et();Qn();({autocompleteMultiselect:ZZe}=tr)});function Wx(e){return{json:e,ci:rl(),stdinIsTTY:Boolean(process.stdin.isTTY),stdoutIsTTY:Boolean(process.stdout.isTTY)}}function Gx(e){return!e.json&&!e.ci&&e.stdinIsTTY&&e.stdoutIsTTY}function JZe(e){let t=new Map(e.effectiveMethods.map(({client:s,method:i})=>[s,i])),r=e.clients.map((s)=>`${s} (${t.get(s)??"unsupported"})`).join(", "),n=e.scope==="project"?"Project":"User";return[`${e.action}: ${e.payload}`,`Scope: ${n} — ${e.configPath}`,`Clients: ${r}`,`Targeting: ${KZe[e.disposition]}`].join(`
540
540
  `)}function Bf(){return{async selectScope(e){if(e.aliasNotice)ae(e.aliasNotice,"Install scope");let t=await il({message:"Install scope",options:e.options.map((r)=>({label:`${r.scope==="project"?"Project":"User"} — ${r.description}`,value:r.scope,hint:r.configPath})),initialValue:e.initialValue});return ze(t)?null:t},async selectClients(e){let t=await jP({message:`Clients for ${e.scope} scope`,options:Uf(e.scope,e.configuredClients),initialValues:[...e.initialValues],required:!0});return ze(t)?null:t},showSummary(e){ae(JZe(e),"Install summary")},async confirm(e){let t=await sl({message:"Install with this target?",initialValue:e.initialValue});return ze(t)?null:t}}}var KZe;var Zx=N(()=>{jr();Oy();KZe={initialize:"initializes scope defaults",inherit:"inherits scope defaults",override:"plugin override"}});async function qf(e){let{targetSkill:t,isUser:r,workspacePath:n}=e;if((e.allSkills??await Nr(n)).filter((l)=>l.pluginSource===t.pluginSource).filter((l)=>!l.disabled&&l.name!==t.name).length===0){let l=r?await Xl(t.pluginSource):await Od(t.pluginSource,n);return l.success?{success:!0,action:"removed-plugin"}:{success:!1,error:l.error??"Unknown error"}}let a=`${t.pluginName}:${t.name}`,c=t.pluginSkillsMode==="allowlist"?r?await fO(a):await bZ(a,n):r?await dO(a):await SZ(a,n);if(!c.success)return{success:!1,error:c.error??"Unknown error"};return{success:!0,action:t.pluginSkillsMode==="allowlist"?"removed-skill":"disabled-skill"}}var Kx=N(()=>{ya();_r();ss()});import{existsSync as YZe,realpathSync as rae}from"node:fs";import{isAbsolute as iae,relative as XZe,resolve as nae,sep as QZe}from"node:path";function sae(e,t){let r=XZe(e,t);return r===""||r!==".."&&!r.startsWith(`..${QZe}`)&&!iae(r)}function Ra(e,t){if(!t)return e;if(iae(t))throw Error(`Plugin subpath '${t}' must not be absolute`);let r=nae(e),n=nae(r,t);if(!sae(r,n))throw Error(`Plugin subpath '${t}' resolves outside its checkout`);if(YZe(n)){let s=rae(r),i=rae(n);if(!sae(s,i))throw Error(`Plugin subpath '${t}' resolves outside its checkout`)}return n}function oae(e){let t=ce(e.plugin),r=Ws(e.plugin),n=me(r);if(!n)return null;let s=br(n.owner,n.repo,n.branch),i={id:s,cachePath:s,remoteUrl:On(n.owner,n.repo),role:"root",currentSha:e.currentSha,...n.branch&&{ref:n.branch}};return{id:`${e.scope}:${e.configIndex}`,scope:e.scope,configIndex:e.configIndex,rawSource:t,effectiveSource:r,pluginName:e.pluginName,rootNodeId:i.id,rootSubpath:n.subpath??"",nodes:[i],skills:e.skills,...e.standaloneSkillSource&&{standaloneSkillSource:!0}}}function eKe(e){return[...new Map(e.map((t)=>[t.id,t])).values()]}function E1(e){let t=new Set(e.map((i)=>i.id)),r=new Map(e.map((i)=>[i.id,i])),n=new Map;for(let i of e)for(let o of i.nodes){let a=n.get(o.id)??new Set;a.add(i.id),n.set(o.id,a)}let s=[];while(t.size>0){let o=[t.values().next().value],a=0,c=[];while(a<o.length){let p=o[a++];if(!p||!t.delete(p))continue;let d=r.get(p);if(!d)continue;c.push(d);for(let f of d.nodes)for(let m of n.get(f.id)??[])if(t.has(m))o.push(m)}let l=eKe(c.flatMap((p)=>p.nodes)),u=l.map((p)=>p.id).sort((p,d)=>p.localeCompare(d)).join("::");s.push({id:u,nodes:l,installations:c})}return s}function R1(e,t){let r=t.toLocaleLowerCase();return e.skills.some((n)=>n.enabled&&(n.name.toLocaleLowerCase()===r||n.subpath.toLocaleLowerCase()===r||`${e.pluginName}:${n.subpath}`.toLocaleLowerCase()===r))}function $1(e,t){return{...t,installationId:e.id,scope:e.scope,pluginName:e.pluginName,source:e.rawSource}}async function Jx(e,t){let r=new Set(e.selectedScopes),n=e.filters?.filter(Boolean)??[],s=E1(e.installations).filter((a)=>a.installations.some((c)=>r.has(c.scope)&&c.nodes.length>0&&(n.length===0||n.some((l)=>R1(c,l))))),i=[];for(let a of s){let c=new Set(a.nodes.map((w)=>w.id)),l=(e.failures??[]).filter((w)=>w.nodeIds.some((P)=>c.has(P))),u,p=!1;if(l.length>0)u={outcome:"failed",nodes:[],installations:[],error:l.map((w)=>`${w.source}: ${w.error}`).join("; ")};else{let w=t.precheckNode?await Promise.all(a.nodes.map(async(b)=>{try{return await t.precheckNode?.(b,a)}catch{return}})):[];if(p=w.length===a.nodes.length&&w.every((b)=>b?.repositoryHealthy&&b.domainRootsHealthy),p&&w.every((b)=>b?.remoteEqual))u={outcome:"resolved",nodes:a.nodes.map((b)=>({nodeId:b.id,sha:b.currentSha})),installations:a.installations.map((b)=>({installationId:b.id,outcome:"resolved",skills:b.skills.map(({name:S,subpath:_})=>({name:S,subpath:_}))}))};else try{u=await t.inspectUnit(a)}catch(b){u={outcome:"failed",nodes:[],installations:[],error:b instanceof Error?b.message:String(b)}}}let d=[],f=[];if(u.outcome!=="failed"){let w=new Map(u.installations.map((P)=>[P.installationId,P]));for(let P of a.installations){let b=P.skills.filter((E)=>E.enabled),S=w.get(P.id);if(!S||S.outcome==="failed")continue;if(S.outcome==="plugin-removed"){d.push(...b.map((E)=>$1(P,E)));continue}if(S.outcome==="local"){f.push(...b.map((E)=>$1(P,E)));continue}let _=new Set(S.skills.map((E)=>E.subpath));for(let E of b)(_.has(E.subpath)?f:d).push($1(P,E))}}let m=u.installations.find((w)=>w.outcome==="failed"),h=u.installations.filter((w)=>w.outcome==="plugin-removed").map((w)=>w.installationId),g=m?"failed":u.outcome,y=u.error??(m?.outcome==="failed"?m.error:void 0),v=a.installations.some((w)=>!r.has(w.scope));i.push({...a,outcome:g,inspectedNodes:u.nodes,deleted:g==="failed"?[]:d,survivors:g==="failed"?[]:f,removedInstallationIds:g==="failed"?[]:h,blockedByOutOfScope:v,...p&&{safeToBypassTransaction:!0},...y&&{error:y}})}let o=new Set(s.flatMap((a)=>a.nodes.map((c)=>c.id)));for(let a of e.failures??[]){if(!r.has(a.scope))continue;if(a.nodeIds.some((c)=>o.has(c)))continue;i.push({id:a.id,nodes:[],installations:[],outcome:"failed",inspectedNodes:[],deleted:[],survivors:[],removedInstallationIds:[],blockedByOutOfScope:!1,error:`${a.source}: ${a.error}`})}return{selectedScopes:e.selectedScopes,units:i}}function Vc(e,t,r){let n={updated:t==="updated"||t==="removed"?e.survivors.length:0,removed:t==="removed"?e.deleted.length:0,retained:t==="retained"?e.deleted.length:0};return{id:e.id,status:t,skillCounts:n,...r&&{error:r}}}async function aae(e,t,r){if(Object.values(t).includes("cancel"))return{success:!1,cancelled:!0,units:e.units.map((o)=>Vc(o,"cancelled")),syncedScopes:[]};let n=[],s=new Set;for(let o of e.units){if(o.outcome==="failed"){n.push(Vc(o,"failed",o.error));continue}if(o.outcome==="local"){n.push(Vc(o,"skipped"));continue}if(o.blockedByOutOfScope){n.push(Vc(o,o.deleted.length>0?"retained":"skipped"));continue}if(o.deleted.length>0){if((t[o.id]??"retain")!=="remove"){n.push(Vc(o,"retained"));continue}}let a=new Map(o.inspectedNodes.map((d)=>[d.nodeId,d.sha])),c=o.nodes.length>0&&o.nodes.every((d)=>a.get(d.id)===d.currentSha);if(o.safeToBypassTransaction===!0&&c&&o.deleted.length===0&&o.removedInstallationIds.length===0){for(let d of o.installations)if(e.selectedScopes.includes(d.scope))s.add(d.scope);n.push(Vc(o,"updated"));continue}let l=o.nodes.filter((d)=>a.has(d.id)).sort((d,f)=>{if(d.role===f.role)return d.id.localeCompare(f.id);return d.role==="dependency"?-1:1}),u=[],p;try{p=await r.reconcileUnit(o);for(let d of l){let f=a.get(d.id);if(!f)throw Error(`Missing inspected revision for ${d.id}`);u.push(d),await r.advanceNode(d,f)}await p.commit();for(let d of o.installations)if(e.selectedScopes.includes(d.scope))s.add(d.scope);n.push(Vc(o,o.deleted.length>0?"removed":"updated"))}catch(d){let f=[d instanceof Error?d.message:String(d)];if(p)try{await p.rollback()}catch(m){f.push(`Config rollback failed: ${m instanceof Error?m.message:String(m)}`)}for(let m of u.reverse())try{await r.restoreNode(m,m.currentSha)}catch(h){f.push(`Checkout rollback failed for ${m.id}: ${h instanceof Error?h.message:String(h)}`)}n.push(Vc(o,"failed",f.join("; ")))}}let i=[];for(let o of e.selectedScopes){if(!s.has(o))continue;try{let a=await r.syncScope(o,{offline:!0});if(a.success){i.push(o);continue}n.push({id:`sync:${o}`,status:"failed",skillCounts:{updated:0,removed:0,retained:0},...a.error&&{error:a.error}})}catch(a){n.push({id:`sync:${o}`,status:"failed",skillCounts:{updated:0,removed:0,retained:0},error:a instanceof Error?a.message:String(a)})}}return{success:n.every((o)=>o.status!=="failed"),cancelled:!1,units:n,syncedScopes:i}}var A1=N(()=>{et();xr();to();ya()});import{randomUUID as tKe}from"node:crypto";import{readFile as I1,rename as cae,stat as lae,unlink as rKe,writeFile as nKe}from"node:fs/promises";import{basename as sKe,dirname as iKe,join as fae}from"node:path";function oKe(e,t){return e.scope==="project"?fae(t.workspacePath,K,X):t.userConfigPath??gt()}function uae(e,t,r){let n=vs(e);if(r==="user")jl(n,t);else Xo(n,t);return n}function aKe(e,t){let r=e.plugins[t];if(!r)throw Error(`Plugin entry at index ${t} not found`);let n=ce(r);e.plugins.splice(t,1),cg(e,n),ug(e,n)}function mae(e,t,r=!1){if(t.selector&&e.includes(t.selector))return t.selector;if(e.includes(t.subpath))return t.subpath;if(e.includes(t.name)&&(r||!e.some((n)=>n!==t.name&&n.split("/").at(-1)===t.name)))return t.name;return}function T1(e,t,r,n=""){let s=n?e.filter((l)=>l.startsWith(n)).map((l)=>l.slice(n.length)):e,i=new Map;for(let l of t){let u=mae(s,l,n.length>0);if(!u)continue;let p=u===l.name?r.filter((d)=>d.name===l.name&&d.subpath!==l.subpath).map((d)=>`${n}${d.subpath}`):[];i.set(`${n}${u}`,p)}if(i.size===0)return e;let o=new Set([...i.values()].flat()),a=new Set,c=[];for(let l of e){let u=i.get(l);if(u){for(let p of u){if(a.has(p))continue;c.push(p),a.add(p)}continue}if(o.has(l)&&a.has(l))continue;if(c.push(l),o.has(l))a.add(l)}return c}function cKe(e,t,r){if(e.version!==void 0&&e.version>=2)return;let n=new Map;for(let s of t){let i=n.get(s.pluginName)??new Set;i.add(s.id),n.set(s.pluginName,i)}for(let[s,i]of n){let o=r.deleted.filter((l)=>i.has(l.installationId));if(o.length===0)continue;let a=r.survivors.filter((l)=>i.has(l.installationId)),c=`${s}:`;if(e.enabledSkills){if(e.enabledSkills=T1(e.enabledSkills,o,a,c),e.enabledSkills.length===0)e.enabledSkills=void 0}if(e.disabledSkills){if(e.disabledSkills=T1(e.disabledSkills,o,a,c),e.disabledSkills.length===0)e.disabledSkills=void 0}}}function lKe(e,t,r,n){let s=r[0]?.scope;if(!s)throw Error(`No installations supplied for staged config ${t}`);if(r.some((p)=>p.scope!==s))throw Error(`Mixed user and project installations target ${t}`);let i=uae(e,t,s),o=new Set(n.removedInstallationIds??[]),a=new Set(n.survivors.map((p)=>p.installationId)),c=new Map;for(let p of n.deleted){let d=c.get(p.installationId)??[];d.push(p),c.set(p.installationId,d)}let l=new Set;for(let p of r){let d=i.plugins[p.configIndex];if(!d)throw Error(`Plugin entry ${p.configIndex} for ${p.rawSource} no longer exists in ${t}`);if(ce(d)!==p.rawSource)throw Error(`Plugin entry ${p.configIndex} changed in ${t}; expected ${p.rawSource}`);if(o.has(p.id)){l.add(p.configIndex);continue}let f=c.get(p.id)??[];if(f.length===0)continue;if(p.standaloneSkillSource&&!a.has(p.id)){l.add(p.configIndex);continue}if(typeof d==="string")continue;if(!Array.isArray(d.skills))continue;for(let h of f)if(!mae(d.skills,h))throw Error(`Configured selector for ${p.pluginName}:${h.subpath} no longer matches ${t}`);let m=n.survivors.filter((h)=>h.installationId===p.id);if(d.skills=T1(d.skills,f,m),d.skills.length===0&&p.standaloneSkillSource)l.add(p.configIndex)}cKe(i,r,n);for(let p of[...l].sort((d,f)=>f-d))aKe(i,p);let u=Le(i,{lineWidth:-1});return uae(u,t,s),u}function pae(e,t){return fae(iKe(e),`.${sKe(e)}.allagents-${t}-${tKe()}.tmp`)}async function dae(e,t,r){await nKe(e,t,{encoding:"utf-8",flag:"wx",mode:r})}async function O1(e){await rKe(e).catch((t)=>{if(t.code!=="ENOENT")throw t})}function hae(e){return async(t)=>{let r=new Set([...t.deleted.map((l)=>l.installationId),...t.removedInstallationIds??[]]),n=new Map;for(let l of t.installations){if(!r.has(l.id))continue;let u=oKe(l,e),p=n.get(u)??[];p.push(l),n.set(u,p)}let s=[];try{for(let[l,u]of n){let p=await I1(l,"utf-8"),d=lKe(p,l,u,t);if(d===p)continue;let f=pae(l,"next"),m=await lae(l);await dae(f,d,m.mode),s.push({path:l,original:p,tempPath:f})}}catch(l){throw await Promise.all(s.map((u)=>O1(u.tempPath))),l}let i="prepared",o=[],a=async(l)=>{if(await I1(l.path,"utf-8")===l.original)return;let p=pae(l.path,"rollback"),d=await lae(l.path);try{await dae(p,l.original,d.mode),await cae(p,l.path)}finally{await O1(p)}},c=async()=>{if(i==="rolled-back")return;for(let l of[...o].reverse())await a(l);await Promise.all(s.map((l)=>O1(l.tempPath))),i="rolled-back"};return{commit:async()=>{if(i!=="prepared")throw Error(`Config reconciliation is already ${i}`);for(let l of s)if(await I1(l.path,"utf-8")!==l.original)throw await c(),Error(`Workspace config changed during update: ${l.path}`);try{for(let l of s)await e.beforeReplace?.(l.path),await cae(l.tempPath,l.path),o.push(l);i="committed"}catch(l){throw await c(),l}},rollback:c}}}var gae=N(()=>{Wi();st();_r();ss();et();Ur();ad()});import{execFile as uKe}from"node:child_process";import{constants as yae,existsSync as Wc}from"node:fs";import{access as pKe,mkdtemp as dKe,rm as Sae}from"node:fs/promises";import{tmpdir as bae}from"node:os";import{basename as fKe,join as Hf,relative as vae,resolve as Vf}from"node:path";import{normalize as wae,sep as mKe}from"node:path";import{promisify as hKe}from"node:util";async function ko(e,t){try{let{stdout:r}=await gKe("git",[...vKe,...e],{...t&&{cwd:t},env:{...process.env,GIT_LFS_SKIP_SMUDGE:"1",GIT_TERMINAL_PROMPT:"0"},maxBuffer:4194304,timeout:yKe});return String(r).trim()}catch(r){let n=r&&typeof r==="object"&&"stderr"in r?String(r.stderr).trim():"";throw Error(`git ${e.join(" ")} failed${t?` in ${t}`:""}${n?`: ${n}`:""}`,{cause:r})}}function xae(e,t){return`https://github.com/${e}/${t}.git`}async function wKe(e,t){let r=await dKe(Hf(bae(),"allagents-skill-update-"));try{return await ko(["clone","--depth","1",...t?["--branch",t]:[],"--",e,r]),r}catch(n){throw await Sae(r,{recursive:!0,force:!0}).catch(()=>{}),n}}async function kKe(e){let t=wae(Vf(e)),r=wae(Vf(bae()));if(t===r||!t.startsWith(`${r}${mKe}`))throw Error("Refusing to clean a skill update checkout outside the temp directory");await Sae(e,{recursive:!0,force:!0})}function _ae(e){switch(e??"project"){case"project":return["project"];case"user":return["user"];case"all":return["project","user"];default:throw Error(`Invalid scope '${e}'. Expected project, user, or all.`)}}function Xx(e){return Object.fromEntries(e.units.filter((t)=>t.deleted.length>0).map((t)=>[t.id,"retain"]))}function Pae(e,t,r){let n=new Set(t);return r.filter((s)=>!e.installations.some((i)=>n.has(i.scope)&&R1(i,s)))}function Cae(e,t){return e==="project"?Hf(t,K,X):gt()}async function SKe(e,t){let r=Cae(e,t);if(!Wc(r))return null;return e==="user"?uc(r):wr(r)}async function Yx(e){if(!Wc(e))throw Error(`Checkout not found: ${e}`);let t=await ko(["rev-parse","HEAD"],e);if(!t)throw Error(`Could not resolve checkout revision: ${e}`);return t}function kae(e){return e.split(/[\\/]/).join("/")}function $ae(e,t,r,n){let s=r.version===void 0||r.version<2,i=new Set(r.disabledSkills??[]),o=r.enabledSkills?new Set(r.enabledSkills):void 0,a=s&&o!==void 0&&[...o].some((c)=>c.startsWith(`${t}:`));return e.map(({name:c,subpath:l})=>{let u=!0,p;if(Array.isArray(n))p=n.includes(l)?l:n.includes(c)?c:void 0,u=p!==void 0;else if(n)u=!n.exclude.includes(l)&&!n.exclude.includes(c);else if(s){let d=`${t}:${c}`,f=`${t}:${l}`;u=a?(o?.has(d)??!1)||(o?.has(f)??!1):!i.has(d)&&!i.has(f)}return{name:c,subpath:l,enabled:u,...p&&{selector:p}}})}function Eae(e){return typeof e==="string"?void 0:e.skills}function bKe(e,t){if(!Wc(Hf(e,"SKILL.md"))||t.length!==1||Vf(t[0]?.skillPath??"")!==Vf(e))return!1;return![".claude-plugin",".github",".mcp.json","commands","hooks","mcp.json"].some((r)=>Wc(Hf(e,r)))}function Rae(e){if(e.source.type==="local")return null;let t=Ra(Ti(),e.name);if(Vf(e.path)!==Vf(t))throw Error(`Remote marketplace '${e.name}' is outside the AllAgents-managed cache: ${e.path}`);if(e.source.type==="github"){let r=Hl(e.source.location);return{id:t,cachePath:t,remoteUrl:xae(r.owner,r.repo),role:"root",currentSha:"",...r.branch&&{ref:r.branch}}}return{id:t,cachePath:t,remoteUrl:e.source.location,role:"root",currentSha:""}}async function Aae(e,t,r,n){return QS(e,n,t==="project"?r:void 0)}async function xKe(e,t,r,n){let s=Ws(r),i=me(s);if(!i)return null;let o=br(i.owner,i.repo,i.branch),a=Ra(o,i.subpath??"");if(!Wc(a))throw Error(`Cached plugin root not found for ${s}: ${a}`);let c=await rf(a),l=Tn(a),u=$ae(c,l,n,Eae(r));if(!u.some((p)=>p.enabled))return null;return oae({scope:e,configIndex:t,plugin:r,pluginName:l,currentSha:await Yx(o),skills:u,standaloneSkillSource:bKe(a,c)})}async function _Ke(e,t,r,n,s){let i=ce(r),o=ht(i);if(!o)return null;let a=await Aae(o.marketplaceName,e,s,o.owner&&o.repo?`${o.owner}/${o.repo}`:void 0);if(!a)throw Error(`Marketplace '${o.marketplaceName}' for ${i} is not registered in ${e} scope`);let c=Rae(a);if(!c)return"local";c.currentSha=await Yx(c.cachePath);let l=await Kt(a.path);if(!l.success)throw Error(`Could not inventory marketplace '${a.name}': ${l.error}`);if(l.warnings.length>0)throw Error(`Could not safely inventory marketplace '${a.name}': ${l.warnings.join("; ")}`);let u=l.data.plugins.find((g)=>g.name===o.plugin),p,d=c,f=[c];if(u&&typeof u.source==="object"){let g=me(u.source.url);if(!g)throw Error(`External marketplace plugin '${i}' is not backed by a supported GitHub source`);let y=br(g.owner,g.repo,g.branch);d={id:y,cachePath:y,remoteUrl:xae(g.owner,g.repo),role:"dependency",currentSha:await Yx(y),...g.branch&&{ref:g.branch}},f.unshift(d),p=Ra(y,g.subpath??"")}else{let g=u&&typeof u.source==="string"?u.source:Hf(o.subpath??"plugins",o.plugin);p=Ra(c.cachePath,g)}if(!Wc(p))throw Error(`Installed marketplace plugin root not found: ${p}`);let m=await rf(p),h=$ae(m,o.plugin,n,Eae(r));if(!h.some((g)=>g.enabled))return null;return{id:`${e}:${t}`,scope:e,configIndex:t,rawSource:i,effectiveSource:i,pluginName:o.plugin,rootNodeId:d.id,rootSubpath:d.id===c.id?kae(vae(a.path,p)):kae(vae(d.cachePath,p)),nodes:f,skills:h,marketplace:{nodeId:c.id,pluginName:o.plugin}}}async function M1(e,t=["project","user"]){let r=[],n=[],s=[],i=[],o=[],a=[],c=new Set(t),l=async(f,m,h)=>{let g=me(Ws(m));if(g)return[br(g.owner,g.repo,g.branch)];let y=ht(f);if(!y)return[];let v=await Aae(y.marketplaceName,h,e,y.owner&&y.repo?`${y.owner}/${y.repo}`:void 0),w=v?Rae(v):null;return w?[w.id]:[]};for(let f of["project","user"]){let m;try{m=await SKe(f,e)}catch(h){if(c.has(f))s.push({id:`inventory:${f}:config`,scope:f,source:Cae(f,e),nodeIds:[],error:h instanceof Error?h.message:String(h)});continue}if(!m)continue;for(let[h,g]of m.plugins.entries()){let y=ce(g),v=Ws(g),w=ve(v)?me(v):null;if(w)i.push({scope:f,source:y,nodeId:br(w.owner,w.repo,w.branch)});let P;try{if(ve(v))P=await xKe(f,h,g,m);else if(ht(y))P=await _Ke(f,h,g,m,e);else P="local"}catch(b){let S={id:`inventory:${f}:${h}`,scope:f,source:y,nodeIds:[],error:b instanceof Error?b.message:String(b)};try{S.nodeIds=await l(y,g,f)}catch{}if(c.has(f))s.push(S);else a.push({...S,errorCause:b});continue}if(P==="local"){if(c.has(f))n.push(`${f}:${y}`)}else if(P)(c.has(f)?r:o).push(P)}}let u=new Set(r.flatMap((f)=>f.nodes.map((m)=>m.id))),p=!0;while(p){p=!1;for(let f=o.length-1;f>=0;f--){let m=o[f];if(!m?.nodes.some((h)=>u.has(h.id)))continue;o.splice(f,1),r.push(m);for(let h of m.nodes)u.add(h.id);p=!0}}let d=a.filter((f)=>f.nodeIds.some((m)=>u.has(m)));for(let f of d)s.push({id:f.id,scope:f.scope,source:f.source,nodeIds:f.nodeIds,error:`Could not safely inventory shared source: ${f.errorCause instanceof Error?f.errorCause.message:String(f.errorCause)}`});return{installations:r,skippedLocalSources:n,failures:s,directRemoteConsumers:i}}async function PKe(e,t){let r;if(e.marketplace){let i=t.get(e.marketplace.nodeId);if(!i)throw Error(`Inspected marketplace checkout missing for ${e.rawSource}`);let o=await Kt(i);if(!o.success)return{installationId:e.id,outcome:"failed",error:o.error};if(o.warnings.length>0)return{installationId:e.id,outcome:"failed",error:o.warnings.join("; ")};let a=o.data.plugins.find((c)=>c.name===e.marketplace?.pluginName);if(!a)return{installationId:e.id,outcome:"plugin-removed"};if(typeof a.source==="object"){let c=me(a.source.url);if(!c)return{installationId:e.id,outcome:"failed",error:`Unsupported external source for ${e.rawSource}`};let l=br(c.owner,c.repo,c.branch);if(l!==e.rootNodeId)return{installationId:e.id,outcome:"failed",error:`External source for ${e.rawSource} changed; run plugin update before skill update`};let u=t.get(l);if(!u)throw Error(`Inspected external checkout missing for ${l}`);r=Ra(u,c.subpath??"")}else r=Ra(i,a.source)}else{let i=t.get(e.rootNodeId);if(!i)throw Error(`Inspected checkout missing for ${e.rawSource}`);r=Ra(i,e.rootSubpath)}if(!Wc(r))return{installationId:e.id,outcome:"failed",error:`Declared plugin root no longer exists for ${e.rawSource}`};let n=[],s=await rf(r,n);if(n.length>0)return{installationId:e.id,outcome:"failed",error:n.join("; ")};return{installationId:e.id,outcome:"resolved",skills:s.map(({name:i,subpath:o})=>({name:i,subpath:o}))}}async function N1(e){let t=new Map;try{let r=[],n=async(c)=>{if(t.has(c.id))return;let l=await wKe(c.remoteUrl,c.ref);t.set(c.id,l),r.push({nodeId:c.id,sha:await Yx(l)})};for(let c of e.nodes.filter((l)=>l.role==="root"))await n(c);let s=[],i=new Set;for(let c of e.installations.filter((l)=>l.marketplace)){let l=t.get(c.marketplace?.nodeId??"");if(!l)continue;let u=await Kt(l);if(!u.success||u.warnings.length>0)continue;if(!u.data.plugins.find((d)=>d.name===c.marketplace?.pluginName))i.add(c.id),s.push({installationId:c.id,outcome:"plugin-removed"})}let o=new Set(e.installations.filter((c)=>!i.has(c.id)).flatMap((c)=>c.nodes.map((l)=>l.id)));for(let c of e.nodes.filter((l)=>l.role==="dependency"&&o.has(l.id)))await n(c);for(let c of e.installations){if(i.has(c.id))continue;s.push(await PKe(c,t))}let a=s.find((c)=>c.outcome==="failed");return a?.outcome==="failed"?{outcome:"failed",nodes:r,installations:s,error:a.error}:{outcome:"resolved",nodes:r,installations:s}}catch(r){return{outcome:"failed",nodes:[],installations:[],error:r instanceof Error?r.message:String(r)}}finally{await Promise.all([...t.values()].map((r)=>kKe(r).catch(()=>{})))}}async function CKe(e,t){let r=new Set,n=!1;for(let i of t.installations){if(i.rootNodeId===e.id)try{r.add(Ra(e.cachePath,i.rootSubpath))}catch{return!1}if(i.marketplace?.nodeId===e.id)r.add(e.cachePath),n=!0}if(r.size===0)return!1;if(n){let i=await Kt(e.cachePath);if(!i.success||i.warnings.length>0)return!1}return(await Promise.all([...r].map((i)=>pKe(i,yae.R_OK|yae.X_OK).then(()=>!0,()=>!1)))).every(Boolean)}function D1(e,t={}){let r=t.resolveRemoteRevision??wd,n=t.checkRepositoryHealth??kd,s=t.domainRootsReadable??CKe;return async(i,o)=>{let a=s(i,o).catch(()=>!1),c;try{c=await e.getRemote(i.remoteUrl,i.ref,()=>r(i.remoteUrl,i.ref))}catch{c={status:"unresolved",reason:"failed"}}let l=c.status==="resolved"?c.ref:i.ref,u={path:i.cachePath,source:i.remoteUrl,...l!==void 0&&{ref:l}},[p,d]=await Promise.all([e.getHealth(u,()=>n(i.cachePath,{source:i.remoteUrl,...l!==void 0&&{ref:l},head:i.currentSha})).catch((f)=>({status:"unhealthy",reason:"inspection-failed",error:f instanceof Error?f:Error(String(f))})),a]);return{remoteEqual:c.status==="resolved"&&c.commit.toLowerCase()===i.currentSha.toLowerCase(),repositoryHealthy:c.status==="resolved"&&p.status==="healthy",domainRootsHealthy:d}}}async function Iae(e,t={}){let r=await(t.buildInventory??M1)(e.workspacePath,e.scopes),n=new vo;try{let s=await Jx({installations:r.installations,selectedScopes:e.scopes,failures:r.failures,...e.filters&&{filters:e.filters}},{inspectUnit:t.inspectUnit??N1,precheckNode:D1(n,t)});return{inventory:r,plan:s}}finally{n.dispose()}}async function Oae(e){let t=await ko(["config","--get","remote.origin.url"],e.cachePath);if(Bl(t)!==Bl(e.remoteUrl))throw Error(`Refusing to update ${e.cachePath}: origin '${t}' does not match expected remote '${e.remoteUrl}'`)}async function $Ke(e,t){await Oae(e);try{await ko(["fetch","--depth","1","origin",e.ref??"HEAD"],e.cachePath)}catch(r){try{await ko(["fetch","--depth","1","origin",t],e.cachePath)}catch(n){throw Error(`Could not fetch ref '${e.ref??"HEAD"}' or inspected revision '${t}': ${r instanceof Error?r.message:String(r)}; ${n instanceof Error?n.message:String(n)}`)}}try{await ko(["cat-file","-e",`${t}^{commit}`],e.cachePath)}catch{await ko(["fetch","--depth","1","origin",t],e.cachePath)}await ko(["reset","--hard",t],e.cachePath)}async function EKe(e,t){await Oae(e),await ko(["cat-file","-e",`${t}^{commit}`],e.cachePath),await ko(["reset","--hard",t],e.cachePath)}async function Qx(e,t,r){return await aae(e.plan,t,{advanceNode:$Ke,restoreNode:EKe,reconcileUnit:hae({workspacePath:r}),syncScope:async(s)=>(bd(),(s==="project"?await pt(r,{offline:!0}):await yt({offline:!0})).success?{success:!0}:{success:!1,error:`Offline ${s} sync failed`})})}function Du(e){return Wc(Hf(e,K,X))}function jy(e){let t=[...new Set(e.installations.flatMap((r)=>r.standaloneSkillSource?r.skills.filter((n)=>n.enabled).map((n)=>n.name):[ta(r.rawSource)]))];return t.length>0?t.join(", "):fKe(e.id)}function Tae(e){let t={updated:0,removed:0,retained:0,skipped:0,failed:0,cancelled:0};for(let r of e.units)if(t.updated+=r.skillCounts.updated,t.removed+=r.skillCounts.removed,t.retained+=r.skillCounts.retained,r.status==="retained"||r.status==="skipped")t.skipped+=1;else if(r.status==="failed")t.failed+=1;else if(r.status==="cancelled")t.cancelled+=1;return t}function Mae(e){if(e.cancelled)return 0;return e.success?0:1}var gKe,yKe=300000,vKe;var e_=N(()=>{st();rn();to();sa();A1();Rx();ya();As();_r();et();yd();na();xr();Ur();gae();gKe=hKe(uKe),vKe=["-c","filter.lfs.required=false","-c","filter.lfs.smudge=","-c","filter.lfs.clean=","-c","filter.lfs.process="]});var Mce=I(function(zPt,Tce){var{PassThrough:pJe}=Me("stream");Tce.exports=function(){var e=[],t=new pJe({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",s),Array.prototype.slice.call(arguments).forEach(r),t;function r(i){if(Array.isArray(i))return i.forEach(r),this;return e.push(i),i.once("end",s.bind(null,i)),i.once("error",t.emit.bind(t,"error")),i.pipe(t,{end:!1}),this}function n(){return e.length==0}function s(i){if(e=e.filter(function(o){return o!==i}),!e.length&&t.readable)t.end()}}});import{existsSync as WJe,readFileSync as GJe}from"node:fs";import{join as ZJe}from"node:path";function P_(e,t){let r=ZJe(e,t);if(WJe(r))return GJe(r,"utf-8");return null}async function KJe(e,t){let r=t.split("/");for(let n=r.length-1;n>=1;n--){let s=r.slice(0,n).join("/"),i=r.slice(n).join("/");if(await V5(e,s))return{branch:s,...i&&{subpath:i}}}return null}async function rle(e){let t=me(e);if(!t)return{success:!1,error:"Invalid GitHub URL format. Expected: https://github.com/owner/repo"};let{owner:r,repo:n,branch:s}=t,i=t.subpath?.replace(/\/+$/,""),o=On(r,n),a=s,c=i;if(s&&i){let d=await KJe(o,`${s}/${i}`);if(d&&d.branch!==s)a=d.branch,c=d.subpath}if(c===K)c=void 0;else if(c?.endsWith(`/${K}`))c=c.slice(0,-(K.length+1));let l;try{l=await ql(o,a)}catch(d){if(d instanceof rs){if(d.isAuthError)return{success:!1,error:`Authentication failed for ${r}/${n}.
541
541
  Check your SSH keys or git credentials.`};if(d.isTimeout)return{success:!1,error:`Clone timed out for ${r}/${n}.
542
542
  Check your network connection.`}}return{success:!1,error:`Failed to access repository: ${d instanceof Error?d.message:String(d)}`}}let u=c||"",p=u?[`${u}/${K}/${X}`,`${u}/${X}`]:[`${K}/${X}`,X];for(let d of p){let f=P_(l,d);if(f){let m={success:!0,content:f,tempDir:l};if(u)m.resolvedSubpath=u;if(a)m.resolvedBranch=a;return m}}return await ea(l),{success:!1,error:`No workspace.yaml found in: ${r}/${n}${a?`@${a}`:""}${c?`/${c}`:""}
@@ -604,7 +604,7 @@ Output: ${e.expectedOutput}`,t}function Sn(e,t=[]){let r=Qie.subcommands(e),n=r.
604
604
  `);for(let i of s)process.stderr.write(` ${i}
605
605
  `);process.exit(2)}return e}var y5e=/^[a-z][a-z0-9-]*$/,v5e=/^-?(?:0|[1-9]\d*)$/,w5e=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/,ooe=/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y,k5e={h:!0,help:!0,input:!0,json:!0,jq:!0,profile:!0,project:!0,scope:!0,search:!0,server:!0,tool:!0,user:!0},S5e={["__proto__"]:!0,constructor:!0,prototype:!0},b5e=["$ref","allOf","anyOf","dependentSchemas","else","if","not","oneOf","patternProperties","then","unevaluatedProperties"];function vy(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function yy(e,t){return Object.hasOwn(e,t)}function yo(e){return{mode:"input-only",reason:e}}function u1(e){return b5e.find((t)=>yy(e,t))}function vx(e){if(typeof e==="string")return"string";if(typeof e==="boolean")return"boolean";if(typeof e==="number"&&Number.isFinite(e))return Number.isSafeInteger(e)?"integer":"number";return}function aoe(e){if(e==="string"||e==="number"||e==="integer"||e==="boolean")return e;return}function x5e(e,t,r){if(!vy(t))return`Property '${e}' is not an object schema`;let n=u1(t);if(n)return`Property '${e}' uses unsupported ${n}`;if(yy(t,"default"))return`Property '${e}' uses an unsupported default`;if(t.description!==void 0&&typeof t.description!=="string")return`Property '${e}' has a non-string description`;let s=t.description;if(t.type==="array"){if(!vy(t.items))return`Property '${e}' is not a homogeneous primitive array`;let o=u1(t.items);if(o)return`Property '${e}' array items use unsupported ${o}`;let a=aoe(t.items.type);if(!a)return`Property '${e}' is not a homogeneous primitive array`;if(yy(t.items,"enum")){let c=t.items.enum;if(!Array.isArray(c)||c.length===0)return`Property '${e}' has an invalid item enum`;for(let l of c)if(vx(l)!==a&&!(a==="number"&&vx(l)==="integer"))return`Property '${e}' has a heterogeneous item enum`;return{name:e,propertyName:e,kind:"array",valueKind:a,required:r,...s===void 0?{}:{description:s},enumValues:c}}return{name:e,propertyName:e,kind:"array",valueKind:a,required:r,...s===void 0?{}:{description:s}}}let i=aoe(t.type);if(!i)return`Property '${e}' has an unsupported type`;if(yy(t,"enum")){let o=t.enum;if(!Array.isArray(o)||o.length===0)return`Property '${e}' has an invalid enum`;for(let a of o)if(vx(a)!==i&&!(i==="number"&&vx(a)==="integer"))return`Property '${e}' has a heterogeneous enum`;return{name:e,propertyName:e,kind:"enum",valueKind:i,required:r,...s===void 0?{}:{description:s},enumValues:o}}return{name:e,propertyName:e,kind:i,valueKind:i,required:r,...s===void 0?{}:{description:s}}}function coe(e){if(!vy(e)||e.type!=="object")return yo("The input schema is not a top-level object");let t=u1(e);if(t)return yo(`The input schema uses unsupported ${t}`);if(e.properties!==void 0&&!vy(e.properties))return yo("The input schema properties are not an object");let r=e.properties??Object.create(null),n=e.required??[];if(!Array.isArray(n)||n.some((c)=>typeof c!=="string"))return yo("The input schema required list is invalid");let s=new Set(n);if(s.size!==n.length)return yo("The input schema required list contains duplicates");for(let c of s)if(!yy(r,c))return yo(`Required property '${c}' is not declared`);let i=Object.keys(r);for(let c of i){if(!y5e.test(c))return yo(`Property '${c}' is not a portable long option name`);if(k5e[c]||S5e[c])return yo(`Property '${c}' is reserved`)}let o=[],a=new Set;for(let c of i){let l=x5e(c,r[c],s.has(c));if(typeof l==="string")return yo(l);if(o.push(l),l.valueKind==="boolean"&&l.kind!=="array")a.add(`no-${l.name}`)}for(let c of i)if(a.has(c))return yo(`Property '${c}' collides with a boolean no-* option`);return{mode:"generated",options:o}}function _5e(e,t,r){if(e==="string")return t;if(e==="boolean"){if(t==="true")return!0;if(t==="false")return!1;throw Error(`Invalid value for --${r}: expected true or false`)}if(e==="integer"){if(!v5e.test(t))throw Error(`Invalid value for --${r}: expected an integer`);let s=Number(t);if(!Number.isSafeInteger(s))throw Error(`Invalid value for --${r}: integer is outside the safe range`);return s}if(!w5e.test(t))throw Error(`Invalid value for --${r}: expected a number`);let n=Number(t);if(!Number.isFinite(n))throw Error(`Invalid value for --${r}: expected a finite number`);return n}function P5e(e,t){let r=_5e(e.valueKind,t,e.name);if(e.enumValues&&!e.enumValues.some((n)=>Object.is(n,r)))throw Error(`Invalid value for --${e.name}: expected one of ${e.enumValues.map(String).join(", ")}`);return r}function C5e(e){let t=!1,r=!1;for(let n=0;n<e.length;){let s=e[n];if(t){if(r)r=!1;else if(s==="\\")r=!0;else if(s==='"')t=!1;n+=1;continue}if(s==='"'){t=!0,n+=1;continue}if(s==="-"||s!==void 0&&s>="0"&&s<="9"){ooe.lastIndex=n;let i=ooe.exec(e);if(i){let o=i[0],a=Number(o);if(!Number.isFinite(a))throw Error("JSON input contains a non-finite number");if(Number.isInteger(a)&&!Number.isSafeInteger(a))throw Error("JSON input contains an integer outside the safe range");n+=o.length;continue}}n+=1}}function $5e(e){C5e(e);let t;try{t=JSON.parse(e)}catch(r){let n=r instanceof Error?r.message:String(r);throw Error(`Invalid --input JSON: ${n}`)}if(!vy(t))throw Error("--input must be a JSON object");return t}function loe(e,t){let r,n=[];for(let o=0;o<t.length;o+=1){let a=t[o];if(a==="--input"){if(r!==void 0)throw Error("--input may only be specified once");let c=t[o+1];if(c===void 0)throw Error("Missing value for --input");r=c,o+=1;continue}if(a?.startsWith("--input=")){if(r!==void 0)throw Error("--input may only be specified once");r=a.slice(8);continue}if(a!==void 0)n.push(a)}if(r!==void 0){if(n.length>0)throw Error("--input cannot be combined with generated tool options");return $5e(r)}if(e.mode==="input-only"){if(n.length>0)throw Error(`Unknown tool option '${n[0]}'`);throw Error(`This tool requires --input: ${e.reason}`)}let s=new Map(e.options.map((o)=>[o.name,o])),i=new Map;for(let o=0;o<n.length;o+=1){let a=n[o];if(a===void 0||!a.startsWith("--")||a==="--")throw Error(`Unknown tool option '${a??""}'`);let c=a.indexOf("="),l=a.slice(2,c===-1?void 0:c),u=s.get(l);if(!u)throw Error(`Unknown tool option '--${l}'`);let p;if(c!==-1)p=a.slice(c+1);else{let f=n[o+1];if(f===void 0)throw Error(`Missing value for --${l}`);if(f.startsWith("-"))throw Error(`Flag-looking values for --${l} require --${l}=value syntax`);p=f,o+=1}let d=P5e(u,p);if(u.kind==="array"){let f=i.get(u.propertyName);if(f===void 0)i.set(u.propertyName,[d]);else if(Array.isArray(f))f.push(d);else throw Error(`Option --${l} has conflicting values`)}else{if(i.has(u.propertyName))throw Error(`Option --${l} may only be specified once`);i.set(u.propertyName,d)}}for(let o of e.options)if(o.required&&!i.has(o.propertyName))throw Error(`Missing required option --${o.name}`);return Object.fromEntries(i)}var Bc=[{flag:"--scope",type:"string",choices:["project","user"],description:"Declaration destination: 'project' (default) or ordinary 'user' configuration; cannot be combined with --profile"},{flag:"--profile",type:"string",description:"Named profile declaration destination; cannot be combined with --scope"}],Iu={kind:"project | user | profile",name:"string?"},p1={mcpResults:"object?",sync:"object?"},wx={command:"mcp add",description:"Add an MCP server, authenticate, and sync it to clients",whenToUse:"When adding or replacing an MCP server in the current project, ordinary user configuration, or a declared profile. Agent and non-interactive use works for public servers or valid cached credentials; fresh OAuth consent requires a human rerun.",examples:["allagents mcp add deepwiki https://mcp.deepwiki.com/mcp","allagents mcp add my-server npx --arg=-y --arg=@my/mcp-server","allagents mcp add gh-api npx -e GH_TOKEN=abc123 --arg=-y --arg=@modelcontextprotocol/server-github","allagents mcp add deepwiki https://mcp.deepwiki.com/mcp --client claude,copilot --client codex","allagents mcp add personal npx --scope user","allagents mcp add trading https://example.com/mcp --profile markets","allagents --json mcp add trading https://example.com/mcp --profile markets"],expectedOutput:"Validates and adds the declaration to the selected project, user, or profile destination, authenticates HTTP servers when needed, records proxy routing atomically, and reconciles installed clients. JSON output redacts credential values. Declared-only profiles are not implicitly installed. Exit 0 on success, 1 on failure.",interaction:"conditional",positionals:[{name:"name",type:"string",required:!0,description:"Server name (unique within the selected destination)"},{name:"commandOrUrl",type:"string",required:!0,description:"HTTP URL (http://, https://) for http transport, or a command for stdio transport"}],options:[{flag:"--transport",type:"string",description:"Transport type: 'http' or 'stdio' (auto-detected from URL by default)"},{flag:"--arg",type:"string",description:"Argument to pass to the stdio command (repeatable)"},{flag:"--env",short:"-e",type:"string",description:"Environment variable KEY=VALUE for stdio transport (repeatable)"},{flag:"--header",type:"string",description:"HTTP header KEY=VALUE for http transport (repeatable)"},{flag:"--client",type:"string",description:"Client filter (repeatable; each value may be comma-separated; duplicates are removed in first-seen order)"},{flag:"--force",short:"-f",type:"boolean",description:"Replace an existing server with the same name"},...Bc],outputSchema:{destination:Iu,name:"string",config:"object",...p1}},kx={command:"mcp remove",description:"Remove an MCP server from a project, user, or profile destination",whenToUse:"When you no longer need an MCP server declaration in the selected destination",examples:["allagents mcp remove deepwiki","allagents mcp remove deepwiki --scope user","allagents mcp remove trading --profile markets","allagents --json mcp remove trading --profile markets"],expectedOutput:"Removes the server declaration and proxy intent from the selected destination, then reconciles that destination. Declared-only profiles remain uninstalled. Exit 0 on success, 1 if the server is not defined.",positionals:[{name:"name",type:"string",required:!0,description:"Server name to remove from the selected destination"}],options:[...Bc],outputSchema:{destination:Iu,name:"string",...p1}},Sx={command:"mcp list",description:"List MCP servers declared in a project, user, or profile destination",whenToUse:"To inspect inline MCP declarations in exactly one selected destination without merging plugin-provided servers",examples:["allagents mcp list","allagents mcp list --scope user","allagents mcp list --profile markets","allagents --json mcp list --scope user"],expectedOutput:"Prints MCP declarations from the selected project, ordinary user, or named profile destination with transport, target, and client filter. Header, environment, URL credential, and sensitive query values are redacted in human and JSON output. Exit 0 on success.",options:[...Bc],outputSchema:{destination:Iu,servers:"record<string, redacted MCP server config>",total:"number"}},bx={command:"mcp get",description:"Show one MCP declaration from a project, user, or profile destination",whenToUse:"To inspect how one MCP server is declared in exactly one selected destination",examples:["allagents mcp get deepwiki","allagents mcp get deepwiki --scope user","allagents mcp get trading --profile markets","allagents --json mcp get trading --profile markets"],expectedOutput:"Prints the selected server declaration as YAML or structured JSON with header, environment, URL credential, and sensitive query values redacted. Exit 0 on success, 1 if it is not found in that destination.",positionals:[{name:"name",type:"string",required:!0,description:"Server name in the selected destination"}],options:[...Bc],outputSchema:{destination:Iu,name:"string",config:"redacted MCP server config"}},xx={command:"mcp reauth",description:"Reauthenticate a configured HTTP MCP server",whenToUse:"Human-operated only: use when an HTTP MCP server in a project, ordinary user, or named profile destination needs a fresh OAuth login. JSON and non-interactive execution are rejected.",examples:["allagents mcp reauth tradingview","allagents mcp reauth secure-api --scope user","allagents mcp reauth tradingview --profile markets"],expectedOutput:"Clears cached OAuth credentials owned by the selected destination, opens a browser for login, accepts a pasted callback URL when the browser is remote, and verifies the connection. Profile credentials remain isolated. Exit 0 on success, 1 on cancellation or failure.",positionals:[{name:"name",type:"string",required:!0,description:"HTTP MCP server name in the selected destination"}],options:[...Bc],interaction:"required"},_x={command:"mcp update",description:"Reconcile MCP servers for one project, user, or profile destination",whenToUse:"After editing MCP declarations for a project, ordinary user configuration, or named profile. Project and user destinations run MCP-only reconciliation; installed profiles use the full profile ownership planner. To modify a server definition use 'mcp add --force'.",examples:["allagents mcp update","allagents mcp update --scope user","allagents mcp update --profile markets","allagents mcp update --offline","allagents --json mcp update --profile markets"],expectedOutput:"Reconciles the selected destination and prints client results. A declared-only profile is reported as not installed and is not implicitly installed. Exit 0 on success, 1 on failure.",options:[{flag:"--offline",type:"boolean",description:"Use cached plugins without fetching from remote"},...Bc],outputSchema:{destination:Iu,...p1}},wy={command:"mcp tools",description:"List tools exposed by an MCP server",whenToUse:"To discover the complete live tool catalog from one configured MCP server in exactly one selected destination",examples:["allagents mcp tools deepwiki","allagents mcp tools deepwiki --search docs","allagents --json mcp tools deepwiki --scope user","allagents --json mcp tools trading --profile markets","allagents mcp tools -- --option-looking-server"],expectedOutput:"Connects directly to the selected configured server, lists every tool page, then closes the connection before rendering. Human output prints one block per matching tool. JSON output preserves complete parsed tool records. Exit 0 for a catalog or empty result, 1 for an operational or cleanup failure, and 2 for invalid usage.",positionals:[{name:"server",type:"string",required:!0,description:"Configured MCP server name in the selected destination"}],options:[{flag:"--search",type:"string",description:"Case-insensitive substring filter over tool name, title, and description"},...Bc],outputSchema:{destination:Iu,server:"string",search:"string?",tools:"complete parsed MCP tool[]",total:"number"},jsonFields:["name","title","description","inputSchema","outputSchema","annotations","execution","icons","_meta"],skipUpdateCheck:!0},ky={command:"mcp call",description:"Call a tool exposed by an MCP server",whenToUse:"To inspect live help for, or synchronously invoke, one exact tool on one configured MCP server in exactly one selected destination",examples:["allagents mcp call deepwiki ask_question --help",`allagents mcp call deepwiki ask_question --input '{"question":"How?"}'`,"allagents mcp call catalog search --query docs --limit 5","allagents --json mcp call trading quote --profile markets --symbol AAPL","allagents mcp call --help -- --option-looking-server --option-looking-tool"],expectedOutput:"Discovers the current tool descriptor on the same direct connection used for an invocation. Fully qualified --help reports the live input contract without invoking. Calls preserve content order and complete parsed JSON results. Exit 0 on success, 1 for tool, operational, or cleanup failure, and 2 for invalid usage.",positionals:[{name:"server",type:"string",required:!0,description:"Configured MCP server name in the selected destination"},{name:"tool",type:"string",required:!0,description:"Exact case-sensitive live tool name"}],options:[{flag:"--input",type:"string",description:"Exact JSON object input; mutually exclusive with live generated tool options"},...Bc],outputSchema:{destination:Iu,server:"string",tool:"string",result:"complete parsed MCP call result (invocation only)?",descriptor:"complete parsed MCP tool descriptor (live help only)?",input:{mode:"generated | input-only",required:"string[]",options:"generated tool option[]?",reason:"string?"}},skipUpdateCheck:!0};var Hc={scope:oe.option({type:oe.optional(oe.string),long:"scope",description:"Declaration scope: 'project' (default) or 'user'"}),profile:oe.option({type:oe.optional(oe.string),long:"profile",description:"Named profile declaration destination"})};function Mu(e,t){try{return fg({cwd:process.cwd(),...t.scope===void 0?{}:{scope:t.scope},...t.profile===void 0?{}:{profile:t.profile}})}catch(r){Os(e,r instanceof Error?r.message:String(r))}}function Tu(e){return e.kind==="profile"?{kind:"profile",name:e.name}:{kind:e.kind}}function zf(e){switch(e.kind){case"project":return"workspace.yaml";case"user":return"the user workspace";case"profile":return`profile '${J(e.name)}'`}}function E5e(e){if(e.length===0)return;let t=[],r=new Set;for(let n of e)for(let s of n.split(",")){let i=s.trim();if(!i)throw Error("--client values cannot contain empty segments");let o=Lr.safeParse(i);if(!o.success)throw Error(`Invalid client '${i}'. Valid clients: ${Qi.join(", ")}`);if(!r.has(o.data))r.add(o.data),t.push(o.data)}return t}var qc="[REDACTED]";function f1(e){let t=e.replace(/[^A-Za-z0-9]/g,"").toLowerCase();return t==="key"||/(?:authorization|auth|credentials?|password|passwd|secrets?|signature|tokens?|accesstoken|refreshtoken|apikey|accesskey|privatekey)$/.test(t)}function doe(e){try{let t=new URL(e);if(t.username)t.username=qc;if(t.password)t.password=qc;for(let r of t.searchParams.keys())if(f1(r))t.searchParams.set(r,qc);return t.toString()}catch{return e}}function R5e(e){let t=!1;return e.map((r)=>{if(t)return t=!1,qc;let n=/^([^=]+)=(.*)$/.exec(r);if(n&&f1(n[1]))return`${n[1]}=${qc}`;if(/^Bearer\s+\S+/i.test(r))return`Bearer ${qc}`;if(/^https?:\/\//i.test(r))return doe(r);if(r.startsWith("-")&&f1(r.replace(/^-+/,"")))t=!0;return r})}function m1(e){if("url"in e)return{...e,url:doe(e.url),...e.headers&&{headers:Object.fromEntries(Object.keys(e.headers).map((t)=>[t,qc]))}};return{...e,...e.args&&{args:R5e(e.args)},...e.env&&{env:Object.fromEntries(Object.keys(e.env).map((t)=>[t,qc]))}}}function Os(e,t){if(j())H({success:!1,command:e,error:t});else console.error(`Error: ${J(t)}`);process.exit(1)}function A5e(e,t,r,n,s,i,o){if(r&&r!=="http"&&r!=="stdio")Os(e,`Invalid transport '${r}'. Expected 'http' or 'stdio'.`);let a=mg(s,"-e/--env");if("error"in a)Os(e,a.error);let c=mg(i,"--header");if("error"in c)Os(e,c.error);let l;try{l=E5e(o)}catch(d){Os(e,d instanceof Error?d.message:String(d))}let u={commandOrUrl:t,args:n,env:a.values,headers:c.values};if(r)u.transport=r;if(l)u.clients=l;let p=UZ(u);if("error"in p)Os(e,p.error);return p.config}function foe(){return{output:console.log,readCallback:async({redirectUrl:e,state:t,signal:r})=>{let n=await pm({message:"Paste the OAuth callback URL if using another browser",signal:r,validate:(s)=>{if(!s)return"OAuth callback URL is required";try{HA(s,e,t);return}catch(i){return i instanceof Error?i.message:"Invalid OAuth callback URL"}}});if(ze(n))throw Error("OAuth authorization cancelled");return n}}}async function _y(e,t){try{return await t()}catch(r){Os(e,r instanceof Error?r.message:String(r))}}async function I5e(e,t,r){try{return await ru(t,r)}catch(n){Os(e,n instanceof Error?n.message:String(n))}}function moe(e){return e.result?Ru(e.result):{status:"not-installed"}}function O5e(e){for(let[t,r]of Object.entries(e.mcpResults)){if(!r)continue;let n=Pa(r,t);if(n.length>0){console.log("");for(let s of n)console.log(s)}}for(let t of e.warnings)console.log(` ⚠ ${t}`)}function hoe(e,t){if(!t.result){console.log(`Profile '${J(e.name)}' is not installed; skipped client reconciliation.`);return}console.log("");for(let r of Tf(t.result))console.log(r)}function goe(e,t,r,n,s){if(j()){H({success:!0,command:e,data:{...s,destination:Tu(t),...r.kind==="mcp"?{mcpResults:r.result.mcpResults}:{sync:moe(r)}}});return}if(console.log(n),r.kind==="mcp")O5e(r.result);else if(t.kind==="profile")hoe(t,r)}function T5e(e,t){let r=[`${e}:`],n="url"in t;if(r.push(` transport: ${n?"http":"stdio"}`),n){if(r.push(` url: ${t.url}`),t.headers&&Object.keys(t.headers).length>0){r.push(" headers:");for(let[s,i]of Object.entries(t.headers))r.push(` ${s}: ${i}`)}}else{if(r.push(` command: ${t.command}`),t.args&&t.args.length>0)r.push(` args: ${JSON.stringify(t.args)}`);if(t.env&&Object.keys(t.env).length>0){r.push(" env:");for(let[s,i]of Object.entries(t.env))r.push(` ${s}: ${i}`)}}if(t.clients&&t.clients.length>0)r.push(` clients: [${t.clients.join(", ")}]`);return r}class $r extends Error{constructor(e){super(e);this.name="McpRuntimeUsageError"}}var M5e={runManagedOperation:(e,t,r,n)=>Bie(e,t,r,n)};function N5e(e){let t=e.split(",").map((r)=>r.trim()).filter(Boolean);return t.length>0?t:void 0}function yoe(e){let t=0;while(t<e.length){let r=e[t];if(r==="--json"||r?.startsWith("--json=")){t+=1;continue}if(r==="--jq"){if(e[t+1]===void 0)return{index:t,legal:!1};t+=2;continue}break}return{index:t,legal:!0}}function Cx(e){let t=yoe(e);if(!t.legal||e[t.index]!=="mcp")return;let r=e[t.index+1];return r==="tools"||r==="call"?r:void 0}function Sy(e,t,r){let n=e[t+1];if(n===void 0)throw new $r(`Missing value for ${r}`);return n}function d1(e,t,r,n){if(e[t]!==void 0)throw new $r(`${n} may only be specified once`);e[t]=r}function uoe(e,t,r){let n=e[t];if(n==="--json")return r.json=!0,t;if(n?.startsWith("--json=")){r.json=!0;let s=N5e(n.slice(7));if(s===void 0)delete r.jsonFields;else r.jsonFields=s;return t}if(n==="--jq"){if(r.jqExpr!==void 0)throw new $r("--jq may only be specified once");return r.jqExpr=Sy(e,t,"--jq"),t+1}return}function voe(e){return{kind:e,help:!1,toolArguments:[],output:{json:!1}}}function woe(e,t){let r=Cx(e);if(!r)throw new $r("Not an MCP runtime command");let n=yoe(e),s=t??voe(r);for(let o=0;o<n.index;o+=1){let a=uoe(e,o,s.output);if(a===void 0)throw new $r(`Unknown output option '${e[o]}'`);o=a}let i=!1;for(let o=n.index+2;o<e.length;o+=1){let a=e[o];if(a===void 0)continue;if(!i&&a==="--"){i=!0;continue}if(i){if(s.server===void 0){s.server=a;continue}if(r==="call"&&s.tool===void 0){s.tool=a;continue}throw new $r(`Unexpected argument '${a}' for mcp ${r}`)}let c=uoe(e,o,s.output);if(c!==void 0){o=c;continue}if(a==="--help"||a==="-h"){s.help=!0;continue}if(a==="--scope"||a.startsWith("--scope=")){let l=a.startsWith("--scope="),u=l?a.slice(8):Sy(e,o,"--scope");if(d1(s,"scope",u,"--scope"),!l)o+=1;continue}if(a==="--profile"||a.startsWith("--profile=")){let l=a.startsWith("--profile="),u=l?a.slice(10):Sy(e,o,"--profile");if(d1(s,"profile",u,"--profile"),!l)o+=1;continue}if(r==="tools"&&(a==="--search"||a?.startsWith("--search="))){let l=a.startsWith("--search="),u=l?a.slice(9):Sy(e,o,"--search");if(d1(s,"search",u,"--search"),!l)o+=1;continue}if(r==="call"&&(a==="--input"||a.startsWith("--input="))){if(s.toolArguments.push(a),a==="--input")s.toolArguments.push(Sy(e,o,"--input")),o+=1;continue}if(!a.startsWith("-")){if(s.server===void 0){s.server=a;continue}if(r==="call"&&s.tool===void 0){s.tool=a;continue}if(r==="tools")throw new $r(`Unexpected argument '${a}' for mcp tools`);s.toolArguments.push(a);continue}if(r==="tools")throw new $r(`Unknown option '${a}' for mcp tools`);if(s.toolArguments.push(a),a.startsWith("--")&&!a.includes("=")){let l=e[o+1];if(l!==void 0)s.toolArguments.push(l),o+=1}}return s}function koe(e){if(!Cx(e))return!1;try{let r=woe(e);if(!r.help)return!0;return r.kind==="call"&&r.server!==void 0&&r.tool!==void 0}catch{return!0}}function D5e(e){if(e.output.jqExpr!==void 0&&!e.output.json)throw new $r("--jq requires --json");if(e.help&&e.output.jsonFields!==void 0)throw new $r("--json=<fields> is not supported with --help; use --json");if(e.output.jsonFields===void 0)return;let t=e.kind==="tools"?wy:ky,r=gy(t),n=e.output.jsonFields.find((s)=>!r.includes(s));if(n)throw new $r(`Unknown JSON field: "${n}". Available fields: ${[...r].sort().join(", ")}`)}function F5e(e){try{return fg({cwd:process.cwd(),...e.scope===void 0?{}:{scope:e.scope},...e.profile===void 0?{}:{profile:e.profile}})}catch(t){throw new $r(t instanceof Error?t.message:String(t))}}function Soe(e){return e==="SIGINT"?130:143}async function boe(e,t,r,n){let s=new AbortController,i,o=(l)=>{if(i!==void 0)process.exit(Soe(l));i=l,s.abort()},a=()=>o("SIGINT"),c=()=>o("SIGTERM");process.once("SIGINT",a),process.once("SIGTERM",c);try{return{result:await n.runManagedOperation(e,t,r,{signal:s.signal}),...i===void 0?{}:{signal:i}}}catch(l){return{error:l instanceof Error?l:Error(String(l)),...i===void 0?{}:{signal:i}}}finally{process.removeListener("SIGINT",a),process.removeListener("SIGTERM",c)}}function h1(e,t,r,n){H({success:e,command:t,...r===void 0?{}:{data:r},...n===void 0?{}:{error:n}})}function xy(e,t,r){if(r)h1(!1,e,void 0,t.message);else console.error(`Error: ${J(t.message)}`)}function $x(e){return`MCP cleanup failed: ${e.message}`}function jf(e,t){if(t!==void 0)process.exitCode=Soe(t);else if(e!==void 0)process.exitCode=e}function by(e){return J(e.replace(/[\r\n]+/g," ")).trim()}function Ou(e){let t=J(e);if(/^[A-Za-z0-9_./:@+-]+$/.test(t))return t;return`'${t.replaceAll("'","'\\''")}'`}function xoe(e){if(e.kind==="project")return[];if(e.kind==="user")return["--scope","user"];return["--profile",Ou(e.name)]}function j5e(e,t,r){let n=[t,r],s=xoe(e);if(n.some((i)=>i.startsWith("-")))return["allagents","mcp","call",...s,"--help","--",...n.map(Ou)].join(" ");return["allagents","mcp","call",Ou(t),Ou(r),"--help",...s].join(" ")}function z5e(e,t,r){let n=[t,r],s=xoe(e);if(n.some((i)=>i.startsWith("-")))return["allagents","mcp","call",...s,"[options]","--",...n.map(Ou)].join(" ");return["allagents","mcp","call",Ou(t),Ou(r),"[options]",...s].join(" ")}function Px(e){return JSON.stringify(e,null,2).split(`
606
606
  `).map((t)=>J(t)).join(`
607
- `)}function L5e(e,t,r,n){if(r.length===0){if(n===void 0)console.log(`MCP server '${J(t)}' exposes no tools.`);else console.log(`No MCP tools matched '${J(n)}' on server '${J(t)}'.`);return}for(let[s,i]of r.entries()){if(console.log(J(i.name)),i.title!==void 0)console.log(` Title: ${by(i.title)}`);if(i.description!==void 0)console.log(` Description: ${by(i.description)}`);if(console.log(` Help: ${j5e(e,t,i.name)}`),s<r.length-1)console.log("")}}function _oe(e){return e.inputSchema.required??[]}function U5e(e,t){let r=_oe(e);return t.mode==="generated"?{mode:"generated",required:r,options:t.options}:{mode:"input-only",required:r,reason:t.reason}}function B5e(e){let t=e.kind==="enum"?e.enumValues?.map(String).join(" | ")??e.valueKind:e.valueKind;return e.kind==="array"?`${t} (repeatable)`:t}function q5e(e,t,r,n){if(console.log(`Usage: ${z5e(e,t,r.name)}`),console.log(""),console.log(`Tool: ${J(r.name)}`),r.title!==void 0)console.log(`Title: ${by(r.title)}`);if(r.description!==void 0)console.log(`Description: ${by(r.description)}`);let s=_oe(r);if(console.log(`Required fields: ${s.length>0?s.map(J).join(", "):"none"}`),console.log("Input schema:"),console.log(Px(r.inputSchema)),console.log(""),console.log("Input options:"),console.log(" --input <json> Exact JSON object input"),n.mode==="input-only"){console.log(` Generated options unavailable: ${J(n.reason)}`);return}for(let i of n.options){let o=i.required?"required":"optional",a=i.description===void 0?"":` - ${by(i.description)}`;console.log(` --${J(i.name)} <${J(B5e(i))}> (${o})${a}`)}}function H5e(e){if(!Array.isArray(e.content)){console.log(Px(e.toolResult));return}let t=e;for(let r of t.content)if(r.type==="text")console.log(J(r.text));else console.log(Px(r));if(t.structuredContent!==void 0)console.log("Structured content:"),console.log(Px(t.structuredContent))}async function V5e(e,t,r){let n=e.server;if(n===void 0)throw new $r("Usage: allagents mcp tools <server> [options]");let s=await boe(t,n,({client:u,signal:p})=>i1(u,{signal:p}),r);if(s.error!==void 0){xy("mcp tools",s.error,e.output.json),jf(1,s.signal);return}let i=s.result;if(i.operation.status==="rejected"){if(xy("mcp tools",i.operation.error,e.output.json),i.cleanup.status==="rejected")console.error(`Error: ${J($x(i.cleanup.error))}`);jf(i.operation.error instanceof $r&&i.cleanup.status==="fulfilled"?2:1,s.signal);return}let o=e.search?.toLowerCase(),a=o===void 0?i.operation.value:i.operation.value.filter((u)=>u.name.toLowerCase().includes(o)||u.title?.toLowerCase().includes(o)===!0||u.description?.toLowerCase().includes(o)===!0),c={destination:Tu(t),server:n,...e.search===void 0?{}:{search:e.search},tools:a,total:a.length},l=i.cleanup.status==="rejected"?$x(i.cleanup.error):void 0;if(e.output.json)h1(l===void 0,"mcp tools",c,l);else L5e(t,n,a,e.search);if(l!==void 0)console.error(`Error: ${J(l)}`);jf(l===void 0?void 0:1,s.signal)}async function W5e(e,t,r){let{server:n,tool:s}=e;if(n===void 0||s===void 0)throw new $r("Usage: allagents mcp call <server> <tool> [options]");let i=await boe(t,n,async({client:p,signal:d})=>{let f=await i1(p,{signal:d}),m=zie(f,s),h=coe(m.inputSchema);if(e.help)return{kind:"help",tool:m,classification:h};let g;try{g=loe(h,e.toolArguments)}catch(v){throw new $r(v instanceof Error?v.message:String(v))}return{kind:"call",result:await Lie(p,m,g,{signal:d})}},r);if(i.error!==void 0){xy("mcp call",i.error,e.output.json),jf(1,i.signal);return}let o=i.result;if(o.operation.status==="rejected"){if(xy("mcp call",o.operation.error,e.output.json),o.cleanup.status==="rejected")console.error(`Error: ${J($x(o.cleanup.error))}`);jf(o.operation.error instanceof $r&&o.cleanup.status==="fulfilled"?2:1,i.signal);return}let a=o.operation.value,c=a.kind==="help"?{destination:Tu(t),server:n,tool:s,descriptor:a.tool,input:U5e(a.tool,a.classification)}:{destination:Tu(t),server:n,tool:s,result:a.result},l=o.cleanup.status==="rejected"?$x(o.cleanup.error):void 0,u=a.kind==="call"&&a.result.isError===!0;if(e.output.json)h1(!u&&l===void 0,"mcp call",c,l);else if(a.kind==="help")q5e(t,n,a.tool,a.classification);else H5e(a.result);if(l!==void 0)console.error(`Error: ${J(l)}`);jf(u||l!==void 0?1:void 0,i.signal)}function poe(e){yx(e.json,{...e.jsonFields===void 0?{}:{fields:e.jsonFields},...e.jqExpr===void 0?{}:{jqExpr:e.jqExpr}})}async function Ex(e,t=M5e){let r;try{let n=Cx(e);if(!n)throw new $r("Not an MCP runtime command");r=voe(n),r=woe(e,r),D5e(r),poe(r.output);let s=F5e(r);if(r.kind==="tools")await V5e(r,s,t);else await W5e(r,s,t)}catch(n){let s=n instanceof Error?n:Error(String(n)),i=Cx(e)==="tools"?"mcp tools":"mcp call",o=r?.output.json??!1;if(r!==void 0)poe(r.output);xy(i,s,o),process.exitCode=s instanceof $r?2:1}}var G5e=oe.command({name:"tools",description:qe(wy),args:{server:oe.positional({type:oe.string,displayName:"server"}),search:oe.option({type:oe.optional(oe.string),long:"search",description:"Case-insensitive substring filter over tool name, title, and description"}),...Hc},handler:async()=>Ex(process.argv.slice(2))}),Z5e=oe.command({name:"call",description:qe(ky),args:{server:oe.positional({type:oe.string,displayName:"server"}),tool:oe.positional({type:oe.string,displayName:"tool"}),input:oe.option({type:oe.optional(oe.string),long:"input",description:"Exact JSON object input; mutually exclusive with generated tool options"}),...Hc},handler:async()=>Ex(process.argv.slice(2))}),K5e={name:oe.positional({type:oe.string,displayName:"name"}),commandOrUrl:oe.positional({type:oe.string,displayName:"commandOrUrl"}),transport:oe.option({type:oe.optional(oe.string),long:"transport",description:"Transport: 'http' or 'stdio' (auto-detected from URL if omitted)"}),args:oe.multioption({type:oe.array(oe.string),long:"arg",description:"Argument for stdio command (repeatable)"}),env:oe.multioption({type:oe.array(oe.string),long:"env",short:"e",description:"Environment variable KEY=VALUE (repeatable)"}),header:oe.multioption({type:oe.array(oe.string),long:"header",description:"HTTP header KEY=VALUE (repeatable)"}),client:oe.multioption({type:oe.array(oe.string),long:"client",description:"Client filter (repeatable; comma-separated values accepted)"})},J5e=oe.command({name:"add",description:qe(wx),args:{...K5e,...Hc,force:oe.flag({long:"force",short:"f",description:"Replace an existing server with the same name"})},handler:async({name:e,commandOrUrl:t,transport:r,args:n,env:s,header:i,client:o,force:a,scope:c,profile:l})=>{let u=Mu("mcp add",{scope:c,profile:l}),p=A5e("mcp add",t,r,n,s,i,o),d=!j()&&process.stdin.isTTY?foe():void 0,f=await _y("mcp add",()=>ax({destination:u,name:e,config:p,force:a,...d?{authorization:d}:{}}));goe("mcp add",u,f.sync,`✓ Added MCP server '${J(e)}' to ${zf(u)}`,{name:e,config:m1(f.config)})}}),Y5e=oe.command({name:"remove",description:qe(kx),args:{name:oe.positional({type:oe.string,displayName:"name"}),...Hc},handler:async({name:e,scope:t,profile:r})=>{let n=Mu("mcp remove",{scope:t,profile:r}),s=await _y("mcp remove",()=>cx(n,e));goe("mcp remove",n,s,`✓ Removed MCP server '${J(e)}' from ${zf(n)}`,{name:e})}}),X5e=oe.command({name:"reauth",description:qe(xx),args:{name:oe.positional({type:oe.string,displayName:"name"}),...Hc},handler:async({name:e,scope:t,profile:r})=>{let n=Mu("mcp reauth",{scope:t,profile:r});if(j()||!process.stdin.isTTY)Os("mcp reauth","OAuth login requires an interactive terminal");await _y("mcp reauth",()=>lx(n,e,foe())),console.log(`✓ Reauthenticated MCP server '${J(e)}' in ${zf(n)}`)}}),Q5e=oe.command({name:"proxy",description:"Expose a remote HTTP MCP server locally over stdio",args:{serverUrl:oe.positional({type:oe.string,displayName:"serverUrl"}),header:oe.multioption({type:oe.array(oe.string),long:"header",description:"HTTP header KEY=VALUE (repeatable)"}),headerEnv:oe.multioption({type:oe.array(oe.string),long:"header-env",description:"HTTP header KEY=ENV_VAR reference (repeatable)"}),profile:oe.option({type:oe.optional(oe.string),long:"profile",description:"Profile-owned OAuth credential scope"})},handler:async({serverUrl:e,header:t,headerEnv:r,profile:n})=>{let s=mg(t,"--header");if("error"in s)Os("mcp proxy",s.error);let i=mg(r,"--header-env");if("error"in i)Os("mcp proxy",i.error);let o={};for(let[c,l]of Object.entries(i.values)){let p=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(l)?.[1]??l;if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(p))Os("mcp proxy",`Invalid environment variable '${l}' for header '${c}'`);o[c]=`\${${p}}`}let a=n===void 0?void 0:Mu("mcp proxy",{profile:n});await j6(e,{...s.values,...o},{...a?.kind==="profile"?{profile:a.name}:{}})}}),eZe=oe.command({name:"list",description:qe(Sx),args:Hc,handler:async({scope:e,profile:t})=>{let r=Mu("mcp list",{scope:e,profile:t}),n=await _y("mcp list",()=>ux(r)),s=Object.keys(n),i=Object.fromEntries(Object.entries(n).map(([o,a])=>[o,m1(a)]));if(j()){H({success:!0,command:"mcp list",data:{destination:Tu(r),servers:i,total:s.length}});return}if(s.length===0){console.log(`No MCP servers defined in ${zf(r)}.`),console.log(""),console.log("Add one with:"),console.log(" allagents mcp add <name> <commandOrUrl>");return}console.log(`MCP servers in ${zf(r)} (${s.length}):`),console.log("");for(let o of s){let a=i[o];if(!a)continue;for(let c of T5e(o,a))console.log(` ${c}`);console.log("")}}}),tZe=oe.command({name:"get",description:qe(bx),args:{name:oe.positional({type:oe.string,displayName:"name"}),...Hc},handler:async({name:e,scope:t,profile:r})=>{let n=Mu("mcp get",{scope:t,profile:r}),s=await I5e("mcp get",n,e);if(!s)Os("mcp get",`MCP server '${e}' not found in ${zf(n)}`);let i=m1(s);if(j()){H({success:!0,command:"mcp get",data:{destination:Tu(n),name:e,config:i}});return}console.log(Le({[e]:i},{lineWidth:-1}).trimEnd())}}),rZe=oe.command({name:"update",description:qe(_x),args:{offline:oe.flag({long:"offline",description:"Use cached plugins without fetching from remote"}),...Hc},handler:async({offline:e,scope:t,profile:r})=>{let n=Mu("mcp update",{scope:t,profile:r}),s=await _y("mcp update",()=>Rf(n,{offline:e}));if(j()){H({success:!0,command:"mcp update",data:{destination:Tu(n),...s.kind==="mcp"?{mcpResults:s.result.mcpResults,warnings:s.result.warnings}:{sync:moe(s)}}});return}if(s.kind==="profile"){if(n.kind==="profile")hoe(n,s);return}if(!Object.values(s.result.mcpResults).some((o)=>o&&(o.added>0||o.overwritten>0||o.removed>0||o.skipped>0)))console.log("No MCP server changes.");else for(let[o,a]of Object.entries(s.result.mcpResults)){if(!a)continue;let c=Pa(a,o);if(c.length>0){for(let l of c)console.log(l);console.log("")}}if(s.result.warnings.length>0){console.log("Warnings:");for(let o of s.result.warnings)console.log(` ⚠ ${o}`)}}}),Poe=Sn({name:"mcp",description:"Manage MCP servers for AI clients",cmds:{add:J5e,reauth:X5e,tools:G5e,call:Z5e,proxy:Q5e,remove:Y5e,list:eZe,get:tZe,update:rZe}},["proxy"]);rn();As();Sc();ss();_r();sa();Rx();ya();Nu();na();var le=vt(Vi(),1);var Ix={command:"plugin marketplace list",description:"List registered marketplaces",whenToUse:"To see which plugin marketplaces are currently registered on your system",examples:["allagents plugin marketplace list"],expectedOutput:"Shows each marketplace with source, path, and last updated date. If none registered, shows well-known marketplace suggestions.",outputSchema:{marketplaces:[{name:"string",source:{type:"string",location:"string"},path:"string",lastUpdated:"string | null"}]}},Ox={command:"plugin marketplace add",description:"Add a marketplace from GitHub URL, owner/repo, local path, or well-known name",whenToUse:"To register a new marketplace so its plugins become available for installation",examples:["allagents plugin marketplace add official","allagents plugin marketplace add https://github.com/user/marketplace","allagents plugin marketplace add user/marketplace --name custom","allagents plugin marketplace add ../local-marketplace","allagents plugin marketplace add owner/repo --branch feat/v2 --name custom"],expectedOutput:"Confirms the marketplace was added with its name and local path. Exit 1 if the source is invalid or unreachable.",positionals:[{name:"source",type:"string",required:!0,description:"GitHub URL, owner/repo, local path, or well-known marketplace name"}],options:[{flag:"--name",short:"-n",type:"string",description:"Custom name for the marketplace"},{flag:"--branch",short:"-b",type:"string",description:"Branch to checkout after cloning (requires --name)"},{flag:"--force",short:"-f",type:"boolean",description:"Replace marketplace if it already exists"}],outputSchema:{marketplace:{name:"string",path:"string"}}},Tx={command:"plugin marketplace remove",description:"Remove a marketplace from registry (does not delete files)",whenToUse:"To unregister a marketplace you no longer need, without deleting its cached files",examples:["allagents plugin marketplace remove official","allagents plugin marketplace remove custom"],expectedOutput:"Confirms removal from registry and notes that files were not deleted. Exit 1 if marketplace not found.",positionals:[{name:"name",type:"string",required:!0,description:"Name of the marketplace to remove"}],outputSchema:{name:"string",path:"string"}},Mx={command:"plugin marketplace update",description:"Update marketplace(s) from remote",whenToUse:"To pull the latest plugin definitions from remote marketplace repositories",examples:["allagents plugin marketplace update","allagents plugin marketplace update official"],expectedOutput:"Shows update status per marketplace. Exit 0 if all succeed, exit 1 if any fail.",positionals:[{name:"name",type:"string",required:!1,description:"Specific marketplace to update (updates all if omitted)"}],outputSchema:{results:[{name:"string",success:"boolean",error:"string | undefined"}],succeeded:"number",failed:"number"}},Nx={command:"plugin marketplace browse",description:"Browse available plugins in a marketplace",whenToUse:"To discover and browse available plugins in a specific marketplace before installing",examples:["allagents plugin marketplace browse official","allagents plugin marketplace browse superpowers"],expectedOutput:"Lists all plugins in the marketplace with descriptions and install status. Shows total count.",positionals:[{name:"name",type:"string",required:!0,description:"Name of the marketplace to browse"}],outputSchema:{marketplace:"string",plugins:[{name:"string",description:"string | null",installed:"boolean",scope:"string | null"}],total:"number",installed:"number"}},Dx={command:"plugin list",description:"List declared plugins with durable ownership and live state",whenToUse:"To distinguish configured files and Pi/OMP native resources from what is installed, disabled, missing, retained, or uncertain in each scope",examples:["allagents plugin list"],expectedOutput:"Merges declarations, AllAgents ownership/provenance, and exact live native observation. Native inspection failures retain partial results and exit 1.",outputSchema:{plugins:[{name:"string",spec:"string",marketplace:"string",scope:"string",kind:"string",clients:"string[] | undefined",nativeClients:"string[] | undefined",nativeResources:[{client:"string",scope:"user | project",kind:"plugin | package",requestedIdentity:"string",resolvedIdentity:"string",root:"string",action:"string",phase:"inspection",changed:"boolean",declared:"boolean",ownership:"managed | referenced | uncertain | none",error:"string | undefined"}]}],total:"number"}},Fx={command:"plugin validate",description:"Validate plugin structure at the given path",whenToUse:"When developing a plugin, to check that its structure conforms to the expected format",examples:["allagents plugin validate ./my-plugin","allagents plugin validate ../shared-plugins/eslint-config"],expectedOutput:"Reports validation results. Exit 0 if valid, exit 1 if structure errors are found.",positionals:[{name:"path",type:"string",required:!0,description:"Path to the plugin directory to validate"}],outputSchema:{path:"string",valid:"boolean",message:"string"}},jx={command:"plugin install",description:"Install a file plugin or ordinary Pi/OMP native resource with an explicit scope and client target.",whenToUse:"To review or explicitly select a plugin installation target before native preflight, declaration write, and sync",examples:["allagents plugin install my-plugin@official","allagents plugin install npm:pi-extension --scope user --client pi --yes","allagents plugin install my-plugin@official --scope project --client claude,codex"],expectedOutput:"Interactive human installs summarize and confirm the target; automation preserves the existing JSON and success output.",positionals:[{name:"plugin",type:"string",required:!0,description:"Plugin identifier (plugin@marketplace, GitHub URL, or local path)"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Installation scope: "project" (default) or "user"'},{flag:"--client",short:"-c",type:"string",description:"Comma-separated clients for this plugin"},{flag:"--yes",short:"-y",type:"boolean",description:"Skip final install confirmation"},{flag:"--skill",type:"string",description:"Only enable a specific skill (repeatable)"}],outputSchema:{plugin:"string",scope:"string",autoRegistered:"string | null",replaced:"boolean | undefined",syncResult:{copied:"number",generated:"number",failed:"number",skipped:"number",plugins:[{plugin:"string",success:"boolean",copied:"number",generated:"number",failed:"number"}]}}},zx={command:"plugin uninstall",description:"Remove a declaration and safely reconcile its scoped resources",whenToUse:"To remove a project/user declaration or retry retained native cleanup after the declaration is already absent",examples:["allagents plugin uninstall my-plugin@official","allagents plugin uninstall npm:pi-extension --scope user","allagents plugin uninstall my-plugin@official --scope user"],expectedOutput:"Reports declaration removal separately, removes only corroborated AllAgents-managed native resources in the selected scope, retains referenced/uncertain resources, and exits 1 on failed or unknown cleanup.",positionals:[{name:"plugin",type:"string",required:!0,description:"Plugin identifier to uninstall"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Installation scope: "project" (default) or "user"'}],outputSchema:{plugin:"string",scopes:["user | project"],declarations:[{scope:"user | project",action:"removed | absent | failed",error:"string | undefined"}],syncResults:{project:"sync result | undefined",user:"sync result | undefined"}}},Lx={command:"plugin update",description:"Update only selected file and ordinary native resources",whenToUse:"To update one declared plugin or all selected-scope plugins while targeting each Pi/OMP adapter by exact identity and scope",examples:["allagents plugin update","allagents plugin update my-plugin@official","allagents plugin update npm:pi-extension --scope user","allagents plugin update --scope all"],expectedOutput:"Preflights native targets before generic fetching, updates only requested identities/scopes, reports per-scope sync/native outcomes, and exits 1 if any pass fails.",positionals:[{name:"plugin",type:"string",required:!1,description:"Specific plugin to update (updates all if omitted)"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Installation scope: "project" (default), "user", or "all"'}],outputSchema:{results:[{plugin:"string",success:"boolean",action:"string",error:"string | undefined"}],updated:"number",skipped:"number",failed:"number",syncResults:{project:"sync result | undefined",user:"sync result | undefined"}}};Ay();st();rn();sa();_1();ya();Sc();As();_r();ss();na();xr();et();Ur();tf();Uc();var xe=vt(Vi(),1);import{existsSync as zae}from"node:fs";import{readFile as Lae}from"node:fs/promises";import{join as i_}from"node:path";Vx();Zx();var Ty={command:"skill list",description:"List all skills from installed plugins",whenToUse:"To see available skills and their enabled/disabled status",examples:["allagents skill list","allagents skill list --scope user","allagents --json=name,plugin skill list"],expectedOutput:"Lists skills grouped by plugin with enabled/disabled status",options:[{flag:"--scope",short:"-s",type:"string",description:'Scope: "project" (default) or "user"'}],outputSchema:{skills:[{name:"string",plugin:"string",disabled:"boolean"}]},jsonFields:["name","plugin","disabled"]},My={command:"skill remove",description:"Disable a skill (exclude from sync)",whenToUse:"To prevent a specific skill from being synced to your workspace",examples:["allagents skill remove brainstorming","allagents skill remove brainstorming --plugin superpowers","allagents skill remove brainstorming --scope user"],expectedOutput:"Confirms skill was disabled and runs sync",positionals:[{name:"skill",type:"string",required:!0,description:"Skill name to disable"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Scope: "project" (default) or "user"'},{flag:"--plugin",short:"-p",type:"string",description:"Plugin name (required if skill exists in multiple plugins)"}],outputSchema:{skill:"string",plugin:"string",syncResult:{copied:"number",failed:"number"}}},Ny={command:"skill update",description:"Update installed skills and safely reconcile skills deleted upstream",whenToUse:"To refresh project or user skills while preserving local copies unless an interactive deletion is explicitly confirmed",examples:["allagents skill update","allagents skill update code-review glow-api","allagents skill update --scope user","allagents skill update --scope all","allagents skill update --yes","allagents --json skill update --scope project"],expectedOutput:"Reports updated, removed, retained, skipped, failed, or cancelled refresh units",positionals:[{name:"skills",type:"string",required:!1,description:"Optional installed skill names or qualified subpaths to update"}],options:[{flag:"--scope",short:"-s",type:"string",description:"Scope: project, user, or all"},{flag:"--yes",short:"-y",type:"boolean",description:"Run without prompts (deleted-upstream skills are retained, not removed)"}],outputSchema:{scopes:["string"],results:[{id:"string",source:"string",status:"string",error:"string?"}],syncedScopes:["string"],skippedLocalSources:["string"],summary:{updated:"number",removed:"number",retained:"number",skipped:"number",failed:"number",cancelled:"number"}},jsonFields:["id","source","status","error"]},Dy={command:"skill search",description:"Search GitHub for skills by querying SKILL.md files via the Code Search API. Results are ranked by relevance, with skill-name matches first. In TTY mode, shows a filter-as-you-type multi-select picker and offers to install the selected skills.",whenToUse:'To discover available skills from public GitHub repositories without leaving the CLI. Bridges "I want a skill that does X" → install.',examples:["allagents skill search terraform","allagents skill pr-search",'allagents skill "pr search"',"allagents skill search terraform --owner hashicorp","allagents skill search docs --page 2 --limit 10","allagents --json skill search docs --limit 5"],expectedOutput:"Skills ranked by relevance: repo, skill name, stars, description. In TTY mode, followed by a searchable multi-select install prompt.",positionals:[{name:"query",type:"string",required:!0,description:"Search query (≥2 characters)."}],options:[{flag:"--owner",type:"string",description:"Scope to a single GitHub owner (org or user)."},{flag:"--page",type:"string",description:"Result page (1-indexed, default 1)."},{flag:"--limit",type:"string",description:"Results per page (1–100, default 15)."}],outputSchema:{query:"string",items:[{name:"string",namespace:"string",repo:"string",path:"string",description:"string",sha:"string",stars:"number"}],total:"number",truncated:"boolean"}},Fy={command:"skill add",description:"Add a skill from a plugin, or re-enable a previously disabled skill",whenToUse:"To add a skill from a GitHub repo or marketplace plugin, or to re-enable a skill that was previously disabled",examples:["allagents skill add ReScienceLab/opc-skills","allagents skill add reddit --from ReScienceLab/opc-skills","allagents skill add reddit --from ReScienceLab/opc-skills --ref v2","allagents skill add NousResearch/hermes-agent --skill llm-wiki","allagents skill add NousResearch/hermes-agent --skill llm-wiki,dogfood","allagents skill add NousResearch/hermes-agent --list","allagents skill add NousResearch/hermes-agent --all","allagents skill add https://github.com/owner/repo/tree/main/skills/my-skill","allagents skill add brainstorming","allagents skill add brainstorming --plugin superpowers","allagents skill add --list --from rstackjs/agent-skills","allagents skill add --all --from rstackjs/agent-skills"],expectedOutput:"Confirms skill was enabled and runs sync",positionals:[{name:"skill-or-source",type:"string",required:!1,description:"A skill name (re-enable an installed skill, or pair with --from to install from a source); "+"a plugin source without subpath (owner/repo, gh:owner/repo, or https://github.com/owner/repo — "+"installs all skills from that repo without needing any flags); or a deep GitHub URL with a subpath pointing to a specific skill file."}],options:[{flag:"--scope",short:"-s",type:"string",description:'Scope: "project" (default) or "user"'},{flag:"--client",short:"-c",type:"string",description:"Comma-separated clients for this skill source"},{flag:"--yes",short:"-y",type:"boolean",description:"Skip final install confirmation"},{flag:"--plugin",short:"-p",type:"string",description:"Plugin name (required if skill exists in multiple plugins)"},{flag:"--from",short:"-f",type:"string",description:"Plugin source (GitHub URL, owner/repo, or plugin@marketplace) to install the skill from. Omit when the positional is already a source."},{flag:"--skill",type:"string",description:"Comma-separated skill names to install when the positional is a plugin source (e.g., `skill add owner/repo --skill foo,bar`)."},{flag:"--ref",type:"string",description:"Git tag or branch to use for the source. Mutually exclusive with an inline @ref."},{flag:"--list",short:"-l",type:"boolean",description:"List skills available at the source without installing"},{flag:"--all",type:"boolean",description:"Install every skill from the source"}],outputSchema:{skill:"string",plugin:"string",syncResult:{copied:"number",failed:"number"},requestedRef:"string?"}};Kx();e_();Ay();var Ts=vt(Vi(),1);e_();class t_ extends Error{}var Nae=Ts.command({name:"update",description:qe(Ny),args:{skills:Ts.restPositionals({type:Ts.string,displayName:"skills"}),scope:Ts.option({type:Ts.optional(Ts.string),long:"scope",short:"s",description:"Scope: project, user, or all"}),yes:Ts.flag({long:"yes",short:"y",description:"Run without prompts (deleted-upstream skills are retained)"})},handler:async({skills:e,scope:t,yes:r})=>{try{let n=process.cwd(),s=Boolean(process.stdout.isTTY&&process.stdin.isTTY)&&!j()&&!r,i=t;if(i!==void 0&&!["project","user","all"].includes(i))throw new t_(`Invalid scope '${i}'. Expected project, user, or all.`);if(!i&&s){let h=await Promise.resolve().then(() => (jr(),tr)),g=await h.select({message:"Update scope",options:[{value:"project",label:"Project"},{value:"user",label:"User"},{value:"all",label:"All"}],initialValue:Du(n)?"project":"user"});if(h.isCancel(g)){h.cancel("Skill update cancelled");return}i=g}i??=Du(n)?"project":"user";let o=_ae(i);if(!j())console.log("Checking for skill updates…");let a=await Iae({workspacePath:n,scopes:o,...e.length>0&&{filters:e}}),c=Pae(a.inventory,o,e);if(c.length>0)throw new t_(`No enabled installed skill matched: ${c.join(", ")}`);let l=Xx(a.plan);if(s){l={};let h=await Promise.resolve().then(() => (jr(),tr));for(let g of a.plan.units){if(g.deleted.length===0)continue;let y=J(jy(g));if(g.blockedByOutOfScope){l[g.id]="retain",h.log.warn(`${y} also backs deleted skills outside the selected scope. Local copies will be kept and this source will not be updated. Rerun with --scope all to review them together.`);continue}let v=g.installations.filter((S)=>g.removedInstallationIds.includes(S.id)),w=v.length>0?`The following installed plugin entries were deleted from ${y} upstream:`:`The following skills from ${y} appear to have been deleted upstream:`,P=g.deleted.map((S)=>` • ${J(S.pluginName)}:${J(S.subpath)} (${J(S.scope)})`);h.log.warn(`${w}
607
+ `)}function L5e(e,t,r,n){if(r.length===0){if(n===void 0)console.log(`MCP server '${J(t)}' exposes no tools.`);else console.log(`No MCP tools matched '${J(n)}' on server '${J(t)}'.`);return}for(let[s,i]of r.entries()){if(console.log(J(i.name)),i.title!==void 0)console.log(` Title: ${by(i.title)}`);if(i.description!==void 0)console.log(` Description: ${by(i.description)}`);if(console.log(` Help: ${j5e(e,t,i.name)}`),s<r.length-1)console.log("")}}function _oe(e){return e.inputSchema.required??[]}function U5e(e,t){let r=_oe(e);return t.mode==="generated"?{mode:"generated",required:r,options:t.options}:{mode:"input-only",required:r,reason:t.reason}}function B5e(e){let t=e.kind==="enum"?e.enumValues?.map(String).join(" | ")??e.valueKind:e.valueKind;return e.kind==="array"?`${t} (repeatable)`:t}function q5e(e,t,r,n){if(console.log(`Usage: ${z5e(e,t,r.name)}`),console.log(""),console.log(`Tool: ${J(r.name)}`),r.title!==void 0)console.log(`Title: ${by(r.title)}`);if(r.description!==void 0)console.log(`Description: ${by(r.description)}`);let s=_oe(r);if(console.log(`Required fields: ${s.length>0?s.map(J).join(", "):"none"}`),console.log("Input schema:"),console.log(Px(r.inputSchema)),console.log(""),console.log("Input options:"),console.log(" --input <json> Exact JSON object input"),n.mode==="input-only"){console.log(` Generated options unavailable: ${J(n.reason)}`);return}for(let i of n.options){let o=i.required?"required":"optional",a=i.description===void 0?"":` - ${by(i.description)}`;console.log(` --${J(i.name)} <${J(B5e(i))}> (${o})${a}`)}}function H5e(e){if(!Array.isArray(e.content)){console.log(Px(e.toolResult));return}let t=e;for(let r of t.content)if(r.type==="text")console.log(J(r.text));else console.log(Px(r));if(t.structuredContent!==void 0)console.log("Structured content:"),console.log(Px(t.structuredContent))}async function V5e(e,t,r){let n=e.server;if(n===void 0)throw new $r("Usage: allagents mcp tools <server> [options]");let s=await boe(t,n,({client:u,signal:p})=>i1(u,{signal:p}),r);if(s.error!==void 0){xy("mcp tools",s.error,e.output.json),jf(1,s.signal);return}let i=s.result;if(i.operation.status==="rejected"){if(xy("mcp tools",i.operation.error,e.output.json),i.cleanup.status==="rejected")console.error(`Error: ${J($x(i.cleanup.error))}`);jf(i.operation.error instanceof $r&&i.cleanup.status==="fulfilled"?2:1,s.signal);return}let o=e.search?.toLowerCase(),a=o===void 0?i.operation.value:i.operation.value.filter((u)=>u.name.toLowerCase().includes(o)||u.title?.toLowerCase().includes(o)===!0||u.description?.toLowerCase().includes(o)===!0),c={destination:Tu(t),server:n,...e.search===void 0?{}:{search:e.search},tools:a,total:a.length},l=i.cleanup.status==="rejected"?$x(i.cleanup.error):void 0;if(e.output.json)h1(l===void 0,"mcp tools",c,l);else L5e(t,n,a,e.search);if(l!==void 0)console.error(`Error: ${J(l)}`);jf(l===void 0?void 0:1,s.signal)}async function W5e(e,t,r){let{server:n,tool:s}=e;if(n===void 0||s===void 0)throw new $r("Usage: allagents mcp call <server> <tool> [options]");let i=await boe(t,n,async({client:p,signal:d})=>{let f=await i1(p,{signal:d}),m=zie(f,s),h=coe(m.inputSchema);if(e.help)return{kind:"help",tool:m,classification:h};let g;try{g=loe(h,e.toolArguments)}catch(v){throw new $r(v instanceof Error?v.message:String(v))}return{kind:"call",result:await Lie(p,m,g,{signal:d})}},r);if(i.error!==void 0){xy("mcp call",i.error,e.output.json),jf(1,i.signal);return}let o=i.result;if(o.operation.status==="rejected"){if(xy("mcp call",o.operation.error,e.output.json),o.cleanup.status==="rejected")console.error(`Error: ${J($x(o.cleanup.error))}`);jf(o.operation.error instanceof $r&&o.cleanup.status==="fulfilled"?2:1,i.signal);return}let a=o.operation.value,c=a.kind==="help"?{destination:Tu(t),server:n,tool:s,descriptor:a.tool,input:U5e(a.tool,a.classification)}:{destination:Tu(t),server:n,tool:s,result:a.result},l=o.cleanup.status==="rejected"?$x(o.cleanup.error):void 0,u=a.kind==="call"&&a.result.isError===!0;if(e.output.json)h1(!u&&l===void 0,"mcp call",c,l);else if(a.kind==="help")q5e(t,n,a.tool,a.classification);else H5e(a.result);if(l!==void 0)console.error(`Error: ${J(l)}`);jf(u||l!==void 0?1:void 0,i.signal)}function poe(e){yx(e.json,{...e.jsonFields===void 0?{}:{fields:e.jsonFields},...e.jqExpr===void 0?{}:{jqExpr:e.jqExpr}})}async function Ex(e,t=M5e){let r;try{let n=Cx(e);if(!n)throw new $r("Not an MCP runtime command");r=voe(n),r=woe(e,r),D5e(r),poe(r.output);let s=F5e(r);if(r.kind==="tools")await V5e(r,s,t);else await W5e(r,s,t)}catch(n){let s=n instanceof Error?n:Error(String(n)),i=Cx(e)==="tools"?"mcp tools":"mcp call",o=r?.output.json??!1;if(r!==void 0)poe(r.output);xy(i,s,o),process.exitCode=s instanceof $r?2:1}}var G5e=oe.command({name:"tools",description:qe(wy),args:{server:oe.positional({type:oe.string,displayName:"server"}),search:oe.option({type:oe.optional(oe.string),long:"search",description:"Case-insensitive substring filter over tool name, title, and description"}),...Hc},handler:async()=>Ex(process.argv.slice(2))}),Z5e=oe.command({name:"call",description:qe(ky),args:{server:oe.positional({type:oe.string,displayName:"server"}),tool:oe.positional({type:oe.string,displayName:"tool"}),input:oe.option({type:oe.optional(oe.string),long:"input",description:"Exact JSON object input; mutually exclusive with generated tool options"}),...Hc},handler:async()=>Ex(process.argv.slice(2))}),K5e={name:oe.positional({type:oe.string,displayName:"name"}),commandOrUrl:oe.positional({type:oe.string,displayName:"commandOrUrl"}),transport:oe.option({type:oe.optional(oe.string),long:"transport",description:"Transport: 'http' or 'stdio' (auto-detected from URL if omitted)"}),args:oe.multioption({type:oe.array(oe.string),long:"arg",description:"Argument for stdio command (repeatable)"}),env:oe.multioption({type:oe.array(oe.string),long:"env",short:"e",description:"Environment variable KEY=VALUE (repeatable)"}),header:oe.multioption({type:oe.array(oe.string),long:"header",description:"HTTP header KEY=VALUE (repeatable)"}),client:oe.multioption({type:oe.array(oe.string),long:"client",description:"Client filter (repeatable; comma-separated values accepted)"})},J5e=oe.command({name:"add",description:qe(wx),args:{...K5e,...Hc,force:oe.flag({long:"force",short:"f",description:"Replace an existing server with the same name"})},handler:async({name:e,commandOrUrl:t,transport:r,args:n,env:s,header:i,client:o,force:a,scope:c,profile:l})=>{let u=Mu("mcp add",{scope:c,profile:l}),p=A5e("mcp add",t,r,n,s,i,o),d=!j()&&process.stdin.isTTY?foe():void 0,f=await _y("mcp add",()=>ax({destination:u,name:e,config:p,force:a,...d?{authorization:d}:{}}));goe("mcp add",u,f.sync,`✓ Added MCP server '${J(e)}' to ${zf(u)}`,{name:e,config:m1(f.config)})}}),Y5e=oe.command({name:"remove",description:qe(kx),args:{name:oe.positional({type:oe.string,displayName:"name"}),...Hc},handler:async({name:e,scope:t,profile:r})=>{let n=Mu("mcp remove",{scope:t,profile:r}),s=await _y("mcp remove",()=>cx(n,e));goe("mcp remove",n,s,`✓ Removed MCP server '${J(e)}' from ${zf(n)}`,{name:e})}}),X5e=oe.command({name:"reauth",description:qe(xx),args:{name:oe.positional({type:oe.string,displayName:"name"}),...Hc},handler:async({name:e,scope:t,profile:r})=>{let n=Mu("mcp reauth",{scope:t,profile:r});if(j()||!process.stdin.isTTY)Os("mcp reauth","OAuth login requires an interactive terminal");await _y("mcp reauth",()=>lx(n,e,foe())),console.log(`✓ Reauthenticated MCP server '${J(e)}' in ${zf(n)}`)}}),Q5e=oe.command({name:"proxy",description:"Expose a remote HTTP MCP server locally over stdio",args:{serverUrl:oe.positional({type:oe.string,displayName:"serverUrl"}),header:oe.multioption({type:oe.array(oe.string),long:"header",description:"HTTP header KEY=VALUE (repeatable)"}),headerEnv:oe.multioption({type:oe.array(oe.string),long:"header-env",description:"HTTP header KEY=ENV_VAR reference (repeatable)"}),profile:oe.option({type:oe.optional(oe.string),long:"profile",description:"Profile-owned OAuth credential scope"})},handler:async({serverUrl:e,header:t,headerEnv:r,profile:n})=>{let s=mg(t,"--header");if("error"in s)Os("mcp proxy",s.error);let i=mg(r,"--header-env");if("error"in i)Os("mcp proxy",i.error);let o={};for(let[c,l]of Object.entries(i.values)){let p=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(l)?.[1]??l;if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(p))Os("mcp proxy",`Invalid environment variable '${l}' for header '${c}'`);o[c]=`\${${p}}`}let a=n===void 0?void 0:Mu("mcp proxy",{profile:n});await j6(e,{...s.values,...o},{...a?.kind==="profile"?{profile:a.name}:{}})}}),eZe=oe.command({name:"list",description:qe(Sx),args:Hc,handler:async({scope:e,profile:t})=>{let r=Mu("mcp list",{scope:e,profile:t}),n=await _y("mcp list",()=>ux(r)),s=Object.keys(n),i=Object.fromEntries(Object.entries(n).map(([o,a])=>[o,m1(a)]));if(j()){H({success:!0,command:"mcp list",data:{destination:Tu(r),servers:i,total:s.length}});return}if(s.length===0){console.log(`No MCP servers defined in ${zf(r)}.`),console.log(""),console.log("Add one with:"),console.log(" allagents mcp add <name> <commandOrUrl>");return}console.log(`MCP servers in ${zf(r)} (${s.length}):`),console.log("");for(let o of s){let a=i[o];if(!a)continue;for(let c of T5e(o,a))console.log(` ${c}`);console.log("")}}}),tZe=oe.command({name:"get",description:qe(bx),args:{name:oe.positional({type:oe.string,displayName:"name"}),...Hc},handler:async({name:e,scope:t,profile:r})=>{let n=Mu("mcp get",{scope:t,profile:r}),s=await I5e("mcp get",n,e);if(!s)Os("mcp get",`MCP server '${e}' not found in ${zf(n)}`);let i=m1(s);if(j()){H({success:!0,command:"mcp get",data:{destination:Tu(n),name:e,config:i}});return}console.log(Le({[e]:i},{lineWidth:-1}).trimEnd())}}),rZe=oe.command({name:"update",description:qe(_x),args:{offline:oe.flag({long:"offline",description:"Use cached plugins without fetching from remote"}),...Hc},handler:async({offline:e,scope:t,profile:r})=>{let n=Mu("mcp update",{scope:t,profile:r}),s=await _y("mcp update",()=>Rf(n,{offline:e}));if(j()){H({success:!0,command:"mcp update",data:{destination:Tu(n),...s.kind==="mcp"?{mcpResults:s.result.mcpResults,warnings:s.result.warnings}:{sync:moe(s)}}});return}if(s.kind==="profile"){if(n.kind==="profile")hoe(n,s);return}if(!Object.values(s.result.mcpResults).some((o)=>o&&(o.added>0||o.overwritten>0||o.removed>0||o.skipped>0)))console.log("No MCP server changes.");else for(let[o,a]of Object.entries(s.result.mcpResults)){if(!a)continue;let c=Pa(a,o);if(c.length>0){for(let l of c)console.log(l);console.log("")}}if(s.result.warnings.length>0){console.log("Warnings:");for(let o of s.result.warnings)console.log(` ⚠ ${o}`)}}}),Poe=Sn({name:"mcp",description:"Manage MCP servers for AI clients",cmds:{add:J5e,reauth:X5e,tools:G5e,call:Z5e,proxy:Q5e,remove:Y5e,list:eZe,get:tZe,update:rZe}},["proxy"]);rn();As();Sc();ss();_r();sa();Rx();ya();Nu();na();var le=vt(Vi(),1);var Ix={command:"plugin marketplace list",description:"List registered marketplaces",whenToUse:"To see which plugin marketplaces are currently registered on your system",examples:["allagents plugin marketplace list"],expectedOutput:"Shows each marketplace with source, path, and last updated date. If none registered, shows well-known marketplace suggestions.",outputSchema:{marketplaces:[{name:"string",source:{type:"string",location:"string"},path:"string",lastUpdated:"string | null"}]}},Ox={command:"plugin marketplace add",description:"Add a marketplace from GitHub URL, owner/repo, local path, or well-known name",whenToUse:"To register a new marketplace so its plugins become available for installation",examples:["allagents plugin marketplace add official","allagents plugin marketplace add https://github.com/user/marketplace","allagents plugin marketplace add user/marketplace --name custom","allagents plugin marketplace add ../local-marketplace","allagents plugin marketplace add owner/repo --branch feat/v2 --name custom"],expectedOutput:"Confirms the marketplace was added with its name and local path. Exit 1 if the source is invalid or unreachable.",positionals:[{name:"source",type:"string",required:!0,description:"GitHub URL, owner/repo, local path, or well-known marketplace name"}],options:[{flag:"--name",short:"-n",type:"string",description:"Custom name for the marketplace"},{flag:"--branch",short:"-b",type:"string",description:"Branch to checkout after cloning (requires --name)"},{flag:"--force",short:"-f",type:"boolean",description:"Replace marketplace if it already exists"}],outputSchema:{marketplace:{name:"string",path:"string"}}},Tx={command:"plugin marketplace remove",description:"Remove a marketplace from registry (does not delete files)",whenToUse:"To unregister a marketplace you no longer need, without deleting its cached files",examples:["allagents plugin marketplace remove official","allagents plugin marketplace remove custom"],expectedOutput:"Confirms removal from registry and notes that files were not deleted. Exit 1 if marketplace not found.",positionals:[{name:"name",type:"string",required:!0,description:"Name of the marketplace to remove"}],outputSchema:{name:"string",path:"string"}},Mx={command:"plugin marketplace update",description:"Update marketplace(s) from remote",whenToUse:"To pull the latest plugin definitions from remote marketplace repositories",examples:["allagents plugin marketplace update","allagents plugin marketplace update official"],expectedOutput:"Shows update status per marketplace. Exit 0 if all succeed, exit 1 if any fail.",positionals:[{name:"name",type:"string",required:!1,description:"Specific marketplace to update (updates all if omitted)"}],outputSchema:{results:[{name:"string",success:"boolean",error:"string | undefined"}],succeeded:"number",failed:"number"}},Nx={command:"plugin marketplace browse",description:"Browse available plugins in a marketplace",whenToUse:"To discover and browse available plugins in a specific marketplace before installing",examples:["allagents plugin marketplace browse official","allagents plugin marketplace browse superpowers"],expectedOutput:"Lists all plugins in the marketplace with descriptions and install status. Shows total count.",positionals:[{name:"name",type:"string",required:!0,description:"Name of the marketplace to browse"}],outputSchema:{marketplace:"string",plugins:[{name:"string",description:"string | null",installed:"boolean",scope:"string | null"}],total:"number",installed:"number"}},Dx={command:"plugin list",description:"List declared plugins with durable ownership and live state",whenToUse:"To distinguish configured files and Pi/OMP native resources from what is installed, disabled, missing, retained, or uncertain in each scope",examples:["allagents plugin list"],expectedOutput:"Merges declarations, AllAgents ownership/provenance, and exact live native observation. Native inspection failures retain partial results and exit 1.",outputSchema:{plugins:[{name:"string",spec:"string",marketplace:"string",scope:"string",kind:"string",clients:"string[] | undefined",nativeClients:"string[] | undefined",nativeResources:[{client:"string",scope:"user | project",kind:"plugin | package",requestedIdentity:"string",resolvedIdentity:"string",root:"string",action:"string",phase:"inspection",changed:"boolean",declared:"boolean",ownership:"managed | referenced | uncertain | none",error:"string | undefined"}]}],total:"number"}},Fx={command:"plugin validate",description:"Validate plugin structure at the given path",whenToUse:"When developing a plugin, to check that its structure conforms to the expected format",examples:["allagents plugin validate ./my-plugin","allagents plugin validate ../shared-plugins/eslint-config"],expectedOutput:"Reports validation results. Exit 0 if valid, exit 1 if structure errors are found.",positionals:[{name:"path",type:"string",required:!0,description:"Path to the plugin directory to validate"}],outputSchema:{path:"string",valid:"boolean",message:"string"}},jx={command:"plugin install",description:"Install a file plugin or ordinary Pi/OMP native resource with an explicit scope and client target.",whenToUse:"To review or explicitly select a plugin installation target before native preflight, declaration write, and sync",examples:["allagents plugin install my-plugin@official","allagents plugin install npm:pi-extension --scope user --client pi --yes","allagents plugin install my-plugin@official --scope project --client claude,codex"],expectedOutput:"Interactive human installs summarize and confirm the target; automation preserves the existing JSON and success output.",positionals:[{name:"plugin",type:"string",required:!0,description:"Plugin identifier (plugin@marketplace, GitHub URL, or local path)"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Installation scope: "project" (default) or "user"'},{flag:"--client",short:"-c",type:"string",description:"Comma-separated clients for this plugin"},{flag:"--yes",short:"-y",type:"boolean",description:"Run without prompts using configured or default scope and clients"},{flag:"--skill",type:"string",description:"Only enable a specific skill (repeatable)"}],outputSchema:{plugin:"string",scope:"string",autoRegistered:"string | null",replaced:"boolean | undefined",syncResult:{copied:"number",generated:"number",failed:"number",skipped:"number",plugins:[{plugin:"string",success:"boolean",copied:"number",generated:"number",failed:"number"}]}}},zx={command:"plugin uninstall",description:"Remove a declaration and safely reconcile its scoped resources",whenToUse:"To remove a project/user declaration or retry retained native cleanup after the declaration is already absent",examples:["allagents plugin uninstall my-plugin@official","allagents plugin uninstall npm:pi-extension --scope user","allagents plugin uninstall my-plugin@official --scope user"],expectedOutput:"Reports declaration removal separately, removes only corroborated AllAgents-managed native resources in the selected scope, retains referenced/uncertain resources, and exits 1 on failed or unknown cleanup.",positionals:[{name:"plugin",type:"string",required:!0,description:"Plugin identifier to uninstall"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Installation scope: "project" (default) or "user"'}],outputSchema:{plugin:"string",scopes:["user | project"],declarations:[{scope:"user | project",action:"removed | absent | failed",error:"string | undefined"}],syncResults:{project:"sync result | undefined",user:"sync result | undefined"}}},Lx={command:"plugin update",description:"Update only selected file and ordinary native resources",whenToUse:"To update one declared plugin or all selected-scope plugins while targeting each Pi/OMP adapter by exact identity and scope",examples:["allagents plugin update","allagents plugin update my-plugin@official","allagents plugin update npm:pi-extension --scope user","allagents plugin update --scope all"],expectedOutput:"Preflights native targets before generic fetching, updates only requested identities/scopes, reports per-scope sync/native outcomes, and exits 1 if any pass fails.",positionals:[{name:"plugin",type:"string",required:!1,description:"Specific plugin to update (updates all if omitted)"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Installation scope: "project" (default), "user", or "all"'}],outputSchema:{results:[{plugin:"string",success:"boolean",action:"string",error:"string | undefined"}],updated:"number",skipped:"number",failed:"number",syncResults:{project:"sync result | undefined",user:"sync result | undefined"}}};Ay();st();rn();sa();_1();ya();Sc();As();_r();ss();na();xr();et();Ur();tf();Uc();var xe=vt(Vi(),1);import{existsSync as zae}from"node:fs";import{readFile as Lae}from"node:fs/promises";import{join as i_}from"node:path";Vx();Zx();var Ty={command:"skill list",description:"List all skills from installed plugins",whenToUse:"To see available skills and their enabled/disabled status",examples:["allagents skill list","allagents skill list --scope user","allagents --json=name,plugin skill list"],expectedOutput:"Lists skills grouped by plugin with enabled/disabled status",options:[{flag:"--scope",short:"-s",type:"string",description:'Scope: "project" (default) or "user"'}],outputSchema:{skills:[{name:"string",plugin:"string",disabled:"boolean"}]},jsonFields:["name","plugin","disabled"]},My={command:"skill remove",description:"Disable a skill (exclude from sync)",whenToUse:"To prevent a specific skill from being synced to your workspace",examples:["allagents skill remove brainstorming","allagents skill remove brainstorming --plugin superpowers","allagents skill remove brainstorming --scope user"],expectedOutput:"Confirms skill was disabled and runs sync",positionals:[{name:"skill",type:"string",required:!0,description:"Skill name to disable"}],options:[{flag:"--scope",short:"-s",type:"string",description:'Scope: "project" (default) or "user"'},{flag:"--plugin",short:"-p",type:"string",description:"Plugin name (required if skill exists in multiple plugins)"}],outputSchema:{skill:"string",plugin:"string",syncResult:{copied:"number",failed:"number"}}},Ny={command:"skill update",description:"Update installed skills and safely reconcile skills deleted upstream",whenToUse:"To refresh project or user skills while preserving local copies unless an interactive deletion is explicitly confirmed",examples:["allagents skill update","allagents skill update code-review glow-api","allagents skill update --scope user","allagents skill update --scope all","allagents skill update --yes","allagents --json skill update --scope project"],expectedOutput:"Reports updated, removed, retained, skipped, failed, or cancelled refresh units",positionals:[{name:"skills",type:"string",required:!1,description:"Optional installed skill names or qualified subpaths to update"}],options:[{flag:"--scope",short:"-s",type:"string",description:"Scope: project, user, or all"},{flag:"--yes",short:"-y",type:"boolean",description:"Run without prompts (deleted-upstream skills are retained, not removed)"}],outputSchema:{scopes:["string"],results:[{id:"string",source:"string",status:"string",error:"string?"}],syncedScopes:["string"],skippedLocalSources:["string"],summary:{updated:"number",removed:"number",retained:"number",skipped:"number",failed:"number",cancelled:"number"}},jsonFields:["id","source","status","error"]},Dy={command:"skill search",description:"Search GitHub for skills by querying SKILL.md files via the Code Search API. Results are ranked by relevance, with skill-name matches first. In TTY mode, shows a filter-as-you-type multi-select picker and offers to install the selected skills.",whenToUse:'To discover available skills from public GitHub repositories without leaving the CLI. Bridges "I want a skill that does X" → install.',examples:["allagents skill search terraform","allagents skill pr-search",'allagents skill "pr search"',"allagents skill search terraform --owner hashicorp","allagents skill search docs --page 2 --limit 10","allagents --json skill search docs --limit 5"],expectedOutput:"Skills ranked by relevance: repo, skill name, stars, description. In TTY mode, followed by a searchable multi-select install prompt.",positionals:[{name:"query",type:"string",required:!0,description:"Search query (≥2 characters)."}],options:[{flag:"--owner",type:"string",description:"Scope to a single GitHub owner (org or user)."},{flag:"--page",type:"string",description:"Result page (1-indexed, default 1)."},{flag:"--limit",type:"string",description:"Results per page (1–100, default 15)."}],outputSchema:{query:"string",items:[{name:"string",namespace:"string",repo:"string",path:"string",description:"string",sha:"string",stars:"number"}],total:"number",truncated:"boolean"}},Fy={command:"skill add",description:"Add a skill from a plugin, or re-enable a previously disabled skill",whenToUse:"To add a skill from a GitHub repo or marketplace plugin, or to re-enable a skill that was previously disabled",examples:["allagents skill add ReScienceLab/opc-skills","allagents skill add reddit --from ReScienceLab/opc-skills","allagents skill add reddit --from ReScienceLab/opc-skills --ref v2","allagents skill add NousResearch/hermes-agent --skill llm-wiki","allagents skill add NousResearch/hermes-agent --skill llm-wiki,dogfood","allagents skill add NousResearch/hermes-agent --list","allagents skill add NousResearch/hermes-agent --all","allagents skill add https://github.com/owner/repo/tree/main/skills/my-skill","allagents skill add brainstorming","allagents skill add brainstorming --plugin superpowers","allagents skill add --list --from rstackjs/agent-skills","allagents skill add --all --from rstackjs/agent-skills"],expectedOutput:"Confirms skill was enabled and runs sync",positionals:[{name:"skill-or-source",type:"string",required:!1,description:"A skill name (re-enable an installed skill, or pair with --from to install from a source); "+"a plugin source without subpath (owner/repo, gh:owner/repo, or https://github.com/owner/repo — "+"installs all skills from that repo without needing any flags); or a deep GitHub URL with a subpath pointing to a specific skill file."}],options:[{flag:"--scope",short:"-s",type:"string",description:'Scope: "project" (default) or "user"'},{flag:"--client",short:"-c",type:"string",description:"Comma-separated clients for this skill source"},{flag:"--yes",short:"-y",type:"boolean",description:"Run without prompts using configured or default scope and clients"},{flag:"--plugin",short:"-p",type:"string",description:"Plugin name (required if skill exists in multiple plugins)"},{flag:"--from",short:"-f",type:"string",description:"Plugin source (GitHub URL, owner/repo, or plugin@marketplace) to install the skill from. Omit when the positional is already a source."},{flag:"--skill",type:"string",description:"Comma-separated skill names to install when the positional is a plugin source (e.g., `skill add owner/repo --skill foo,bar`)."},{flag:"--ref",type:"string",description:"Git tag or branch to use for the source. Mutually exclusive with an inline @ref."},{flag:"--list",short:"-l",type:"boolean",description:"List skills available at the source without installing"},{flag:"--all",type:"boolean",description:"Install every skill from the source"}],outputSchema:{skill:"string",plugin:"string",syncResult:{copied:"number",failed:"number"},requestedRef:"string?"}};Kx();e_();Ay();var Ts=vt(Vi(),1);e_();class t_ extends Error{}var Nae=Ts.command({name:"update",description:qe(Ny),args:{skills:Ts.restPositionals({type:Ts.string,displayName:"skills"}),scope:Ts.option({type:Ts.optional(Ts.string),long:"scope",short:"s",description:"Scope: project, user, or all"}),yes:Ts.flag({long:"yes",short:"y",description:"Run without prompts (deleted-upstream skills are retained)"})},handler:async({skills:e,scope:t,yes:r})=>{try{let n=process.cwd(),s=Boolean(process.stdout.isTTY&&process.stdin.isTTY)&&!j()&&!r,i=t;if(i!==void 0&&!["project","user","all"].includes(i))throw new t_(`Invalid scope '${i}'. Expected project, user, or all.`);if(!i&&s){let h=await Promise.resolve().then(() => (jr(),tr)),g=await h.select({message:"Update scope",options:[{value:"project",label:"Project"},{value:"user",label:"User"},{value:"all",label:"All"}],initialValue:Du(n)?"project":"user"});if(h.isCancel(g)){h.cancel("Skill update cancelled");return}i=g}i??=Du(n)?"project":"user";let o=_ae(i);if(!j())console.log("Checking for skill updates…");let a=await Iae({workspacePath:n,scopes:o,...e.length>0&&{filters:e}}),c=Pae(a.inventory,o,e);if(c.length>0)throw new t_(`No enabled installed skill matched: ${c.join(", ")}`);let l=Xx(a.plan);if(s){l={};let h=await Promise.resolve().then(() => (jr(),tr));for(let g of a.plan.units){if(g.deleted.length===0)continue;let y=J(jy(g));if(g.blockedByOutOfScope){l[g.id]="retain",h.log.warn(`${y} also backs deleted skills outside the selected scope. Local copies will be kept and this source will not be updated. Rerun with --scope all to review them together.`);continue}let v=g.installations.filter((S)=>g.removedInstallationIds.includes(S.id)),w=v.length>0?`The following installed plugin entries were deleted from ${y} upstream:`:`The following skills from ${y} appear to have been deleted upstream:`,P=g.deleted.map((S)=>` • ${J(S.pluginName)}:${J(S.subpath)} (${J(S.scope)})`);h.log.warn(`${w}
608
608
  ${P.join(`
609
609
  `)}`);let b=await h.confirm({message:v.length>0?`Remove ${v.length} local plugin entr${v.length===1?"y":"ies"} and update the surviving skills? No keeps the local copies and skips every update from this source.`:`Remove ${g.deleted.length} local skill cop${g.deleted.length===1?"y":"ies"} and update the surviving skills? No keeps them and skips every update from this source.`,initialValue:!1});if(h.isCancel(b)){l[g.id]="cancel";break}l[g.id]=b?"remove":"retain"}}let u=await Qx(a,l,n),p=Tae(u),d=new Map(a.plan.units.map((h)=>[h.id,h])),f=u.units.map((h)=>{let g=d.get(h.id);return{...h,source:g?jy(g):h.id}});if(j())H({success:u.success,command:"skill update",data:{scopes:o,results:f,syncedScopes:u.syncedScopes,skippedLocalSources:a.inventory.skippedLocalSources,summary:p}});else{for(let h of a.inventory.skippedLocalSources)console.log(`${dt.dim("–")} Skipped local source ${J(h)}`);for(let h of f){let g=J(h.source);switch(h.status){case"updated":console.log(`${dt.green("✓")} Updated ${g}`);break;case"removed":console.log(`${dt.green("✓")} Removed deleted skills and updated ${g}`);break;case"retained":console.log(`${dt.yellow("!")} Kept local copies and skipped updates for ${g}`);break;case"skipped":console.log(`${dt.dim("–")} Skipped ${g}`);break;case"cancelled":console.log(`${dt.yellow("!")} Update cancelled before changes`);break;case"failed":console.error(`${dt.red("✗")} Failed ${g}${h.error?`: ${J(h.error)}`:""}`);break}}if(u.units.length===0)console.log("No skill updates found.");else if(u.success)console.log(`Done: ${p.updated} updated, ${p.removed} removed, ${p.retained} retained, ${p.skipped} skipped.`)}let m=Mae(u);if(m!==0)process.exit(m)}catch(n){let s=n instanceof Error?n.message:String(n),i=n instanceof t_?2:1;if(j())H({success:!1,command:"skill update",error:s});else console.error(`Error: ${J(s)}`);process.exit(i)}}});function Uae(e){if(St(e))return"user";if(Du(e))return"project";return"user"}function r_(e,t,r){let n,s,i,o=Wx(j()),a=()=>(s??=(async()=>{if(St(e))return null;let l=i_(e,K,X);if(!zae(l))return null;let u=await wr(l);return{clients:u.clients,plugins:u.plugins}})(),s),c=()=>(i??=(async()=>{let l=await bt();return l?{clients:l.clients,plugins:l.plugins}:null})(),i);return{workspacePath:e,options:r,payload:t,scopeState(l){return l==="user"?c():a()},resolve(l){return n??=Lf({workspacePath:e,declaration:l,action:"Install skills",payload:t,scopeStates:{project:a,user:c},environment:o,...Gx(o)&&{prompts:Bf()},...r.scope!==void 0&&{scope:r.scope},...r.clients!==void 0&&{clients:r.clients},...r.yes!==void 0&&{yes:r.yes},defaultScope:"project"}),n}}}function RKe(e,t){if(typeof t.prospectiveDeclaration!=="string"&&ce(t.prospectiveDeclaration)===e.source)return t.prospectiveDeclaration;if(t.disposition==="override")return{...e,clients:[...t.clients]};let{clients:r,...n}=e;return n}async function F1(e,t){if(!t)return!1;if(t.plugins?.some((n)=>ce(n)===e))return!0;let r=await Ir(e);if(!r)return!1;for(let n of t.plugins??[])if(await Ir(ce(n))===r)return!0;return!1}async function By(e,t){if(St(t.workspacePath))return await F1(e,await t.scopeState("user"))?"user":null;let[r,n]=await Promise.all([t.scopeState("project").then((s)=>F1(e,s)).catch(()=>!1),t.scopeState("user").then((s)=>F1(e,s)).catch(()=>!1)]);if(r&&n)return t.options.scope==="user"?"user":"project";if(r)return"project";if(n)return"user";return null}function Fu(e,t){return{scope:e,workspacePath:e==="user"?de():t}}function Bae(e,t){let r=[];if(e.has("user"))r.push(Fu("user",t));if(e.has("project"))r.push(Fu("project",t));return r}async function qae(e,t){let r=[];if(e.has("user"))r.push(await yt());if(e.has("project"))r.push(await pt(t));let[n,...s]=r;if(!n)throw Error("Cannot sync a skill install without an affected scope.");return s.reduce(ey,n)}async function Wf(e,t){let r=await t.resolve(e);if(!r)return{status:"cancelled"};let n=RKe(e,r),s={declaration:n,clients:r.clients,...ve(n.source)&&{sourceValidation:"declaration"}},i=r.scope==="user"?await Jl(s):await Ad(s,t.workspacePath);if(!i.success)return{status:"failed",error:i.error??"Unknown error"};return{status:"installed",scope:r.scope,...i.normalizedPlugin&&{normalizedPlugin:i.normalizedPlugin}}}async function AKe(e){let{from:t,requestedRef:r,workspacePath:n,isUser:s}=e;if(!ve(t))return;let i=me(t);if(!i)return;let o=await hn(t,{...i.branch&&{branch:i.branch}});if(!o.success||!o.resolvedSha)return;let a=s?de():n,c=zS(`${i.owner}/${i.repo}`);await $K(a,c,{pluginSpec:c,resolvedRef:o.resolvedRef??i.branch??"HEAD",resolvedSha:o.resolvedSha,...r&&{requestedRef:r}})}async function j1(e){let t=new Set;await Promise.all(e.locations.map((r)=>{let n=`${r.scope}:${r.workspacePath}`;if(t.has(n))return Promise.resolve();return t.add(n),AKe({from:e.from,requestedRef:e.requestedRef,workspacePath:r.workspacePath,isUser:r.scope==="user"})}))}function z1(){if(!j())console.log("Install cancelled. No changes made.")}function L1(e,t){if(!ve(e))return t;let r=me(e);return r?.subpath?i_(t,r.subpath):t}function IKe(e){let t=e.indexOf("/");if(t===-1)return;let r=e.indexOf("@",t);if(r===-1)return;let n=e.slice(r+1),s=n.indexOf("/"),i=s===-1?n:n.slice(0,s);return i.length>0?i:void 0}function OKe(e){if(!ve(e))return null;let t=me(e);if(!t)return null;if(t.subpath){let r=t.subpath.split("/").filter(Boolean);if(r.at(-1)==="SKILL.md"){let s=e.slice(0,-9),i=me(s);if(!i)return null;return{skill:r.at(-2)??t.repo,from:s,parsed:i}}let n=r.at(-1);if(!n)return null;return{skill:n,from:e,parsed:t}}return{skill:t.repo,from:e,parsed:t}}async function TKe(e,t,r,n=hn){let s=await n(e,{...t.branch&&{branch:t.branch}});if(!s.success)return r;try{let i=await Lae(i_(s.cachePath,"SKILL.md"),"utf-8");return $s(i)?.name??r}catch{return r}}function Dae(e){let t=new Map;for(let r of e){let n={name:r.name,subpath:r.skillSubpath??r.name,disabled:r.disabled},s=t.get(r.pluginName);if(s)s.skills.push(n);else t.set(r.pluginName,{source:r.pluginSource,skills:[n]})}return t}var MKe=xe.command({name:"list",description:qe(Ty),args:{scope:xe.option({type:xe.optional(xe.string),long:"scope",short:"s",description:'Scope: "project" (default) or "user"'})},handler:async({scope:e})=>{try{let t=process.cwd(),r=!St(t)&&Du(t),n=e!=="project",s=e==="project"||!e&&r,i=n?await Nr(de()):[],o=s?await Nr(t):[],a=new Set(i.map((l)=>`${l.pluginName}:${l.name}`)),c=o.filter((l)=>!a.has(`${l.pluginName}:${l.name}`));if(j()){let l=e==="user"?"user":e==="project"?"project":"all",u=[...i,...c];H({success:!0,command:"skill list",data:{scope:l,skills:u.map((p)=>({name:p.name,plugin:p.pluginName,disabled:p.disabled}))}});return}if(i.length===0&&c.length===0){console.log("No skills found. Install a plugin first with:"),console.log(" allagents plugin install <plugin>");return}if(i.length>0&&e!=="project"){console.log(`
610
610
  ${dt.whiteBright("User Skills:")}`);let l=Dae(i);for(let[u,p]of l){console.log(`
@@ -622,7 +622,7 @@ Available skills: ${f.join(", ")||"none"}`};let m=`${d}@${u}`,h=i?await By(m,i):
622
622
 
623
623
  Available skills: ${s||"none"}`}}async function zKe(e){let{isUser:t,workspacePath:r}=e,{skill:n,from:s,sourcePath:i,targetContext:o}=e,a=await o0(i),c=jKe(n,a);if("error"in c)return{success:!1,error:`${c.error}
624
624
 
625
- Tip: run \`allagents skill add --list --from ${s}\` to see all available skills.`};let l=c.canonical,u=ve(s)?Gc(s):Tn(i);if(o){let d=await By(s,o);if(d){if(t=d==="user",r=t?de():o.workspacePath,ve(s)){let h=[...await n_(s,r)];if(!h.includes(l))h.push(l);let g=t?await Nd(s,h):await lg(s,h,r);if(!g.success)return{success:!1,error:`Failed to update plugin '${s}': ${g.error??"Unknown error"}`};return Ly({skill:l,pluginName:Gc(g.normalizedPlugin??s),isUser:t,workspacePath:r})}return s_({skill:l,pluginName:u,isUser:t,workspacePath:r})}let f=await Wf({source:s,install:"file",skills:[l]},o);if(f.status==="cancelled")return{success:"cancelled"};if(f.status==="failed")return{success:!1,error:`Failed to install plugin '${s}': ${f.error}`};return t=f.scope==="user",r=t?de():o.workspacePath,Ly({skill:l,pluginName:Gc(f.normalizedPlugin??u),isUser:t,workspacePath:r})}if(ve(s)){let f=[...await n_(s,r)];if(!f.includes(l))f.push(l);let m=t?await Nd(s,f):await lg(s,f,r);if(!m.success)return{success:!1,error:`Failed to update plugin '${s}': ${m.error??"Unknown error"}`};return Ly({skill:l,pluginName:Gc(m.normalizedPlugin??s),isUser:t,workspacePath:r})}let p=t?await Md(s):await ag(s,r);if(!p.success){if(!p.error?.includes("already exists")&&!p.error?.includes("duplicates existing"))return{success:!1,error:`Failed to install plugin '${s}': ${p.error??"Unknown error"}`};if(!j())console.log("Plugin already installed.")}return s_({skill:l,pluginName:u,isUser:t,workspacePath:r})}function Gc(e){let t=ve(e)?me(e):null;if(t?.subpath){let r=t.subpath.split("/").filter(Boolean),n=r[r.length-1];if(n)return n}return Tn(e)}async function n_(e,t){let r=await Ir(e);if(!r)return[];let n=[],s=await Nr(t);for(let i of s){if(i.disabled)continue;if(await Ir(i.pluginSource)!==r)continue;if(!n.includes(i.name))n.push(i.name)}return n}async function s_(e){let{skill:t,pluginName:r,isUser:n,workspacePath:s}=e;if(((await Nr(s)).filter((c)=>c.pluginName===r)[0]?.pluginSkillsMode??"none")==="allowlist"){let c=`${r}:${t}`,l=n?await so(c):await aa(c,s);if(!l.success){if(!l.error?.includes("already enabled"))return{success:!1,error:`Failed to enable skill: ${l.error??"Unknown error"}`}}}else{let c=n?await ca(r,"allowlist",[t]):await vc(r,"allowlist",[t],s);if(!c.success)return{success:!1,error:`Failed to configure skill allowlist: ${c.error??"Unknown error"}`}}return Ly({skill:t,pluginName:r,isUser:n,workspacePath:s})}async function Ly(e){let{skill:t,pluginName:r,isUser:n,workspacePath:s}=e;if(!j())console.log(`✓ Enabled skill: ${t} (${r})`);let i=n?await yt():await pt(s);if(!i.success)return{success:!1,error:"Sync failed"};return{success:!0,pluginName:r,location:Fu(n?"user":"project",n?de():s),syncResult:{copied:i.totalCopied,failed:i.totalFailed}}}async function jae(e,t){let r=await o0(e),n=[];for(let s of r){let i=i_(s.skillPath,"SKILL.md"),o="";try{let a=await Lae(i,"utf-8");o=$s(a)?.description??""}catch{}n.push({name:s.name,subpath:s.subpath,description:o,...t&&{pluginName:t}})}return n}async function Vae(e){let t=ve(e)?me(e):null,r=await hn(e,{...t?.branch&&{branch:t.branch}});if(!r.success)return{success:!1,error:`Failed to fetch '${e}': ${r.error??"Unknown error"}`};let n=L1(e,r.cachePath),s=await Kt(n);if(s.success){let o=[];for(let a of s.data.plugins){if(typeof a.source==="object")continue;let c=BS(a.source,n);if(!zae(c))continue;let l=await jae(c,a.name);o.push(...l)}return{success:!0,skills:o,isMarketplace:!0}}return{success:!0,skills:await jae(n),isMarketplace:!1}}async function LKe(e){let{isUser:t,workspacePath:r}=e,{from:n,targetContext:s}=e;if(!(process.stdout.isTTY&&process.stdin.isTTY)||j())return zy(e);let o=await Vae(n);if(!o.success)return{success:!1,error:o.error};if(o.skills.length===0)return{success:!1,error:`No skills found in '${n}'.`};if(o.skills.length===1)return zy(e);let a=await Promise.resolve().then(() => (jr(),tr));if(o.isMarketplace){let w=o.skills.map((ie)=>ie.name),P={};for(let ie of o.skills){let Ye=ie.pluginName??"Other";if(!P[Ye])P[Ye]=[];P[Ye].push({label:ie.name,value:ie.name,...ie.description?{hint:ie.description}:{}})}let b=await a.groupMultiselect({message:`Select skills to install from ${dt.bold(n)}`,options:P,initialValues:w,required:!1});if(a.isCancel(b)||b.length===0)return{success:"cancelled"};let S=b;if(S.length===w.length)return zy(e);let _=ve(n)?me(n):null,E=_?`${_.owner}/${_.repo}`:void 0,C=s?.workspacePath??r,A=await qr(_?.repo??n,E,s?C:t?void 0:r),k=A?.key??(_?.branch?`${_.repo}-${_.branch}`:_?.repo??Tn(n));if(!A){let ie=t?"user":"project";if(s){let Xe=await s.resolve({source:n,install:"file",skills:S});if(!Xe)return{success:"cancelled"};ie=Xe.scope}let Ye=await Uy({from:n,marketplaceName:k,scope:ie,projectWorkspacePath:C});if(!Ye.success)return Ye;k=Ye.marketplaceName,A=await qr(k,E,ie==="user"?void 0:C),t=ie==="user",r=Ye.workspacePath}else t=A.scope==="user",r=t?de():C;let T=await no(k,t?void 0:r);if(T.plugins.length===0)return{success:!1,error:`No plugins found in marketplace '${k}'.`};let L=[];for(let ie of T.plugins){let Xe=(ie.skills?ie.skills.map((mt)=>mt.split("/").pop()??"").filter(Boolean):await ga(ie.path)).filter((mt)=>S.includes(mt));if(Xe.length>0)L.push({pluginName:ie.name,skills:Xe})}if(L.length===0)return{success:!1,error:"No matching skills found in marketplace plugins."};let F=await Hae({from:n,marketplaceName:k,registrationScope:A?.scope??(t?"user":"project"),selections:L,isUser:t,projectWorkspacePath:C,...s&&{targetContext:s}});if(F.success!==!0)return F;let{installed:D,changedScopes:O}=F;if(D.length===0)return{success:!1,error:"No matching skills found in marketplace plugins."};if(!j()){let ie=D.reduce((Ye,Xe)=>Ye+Xe.skills.length,0);console.log(`✓ Enabled ${ie} skill(s) across ${D.length} plugin(s)`)}let pe=await qae(O,C);if(!pe.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:D,syncResult:pe,locations:Bae(O,C)}}let c=o.skills.map((w)=>w.name),l=o.skills.map((w)=>({label:w.name,value:w.name,...w.description?{hint:w.description}:{}})),u=await a.autocompleteMultiselect({message:`Select skills to install from ${dt.bold(n)}`,options:l,initialValues:c,placeholder:"Type to filter · Space to toggle · Enter to confirm",required:!1});if(a.isCancel(u)||u.length===0)return{success:"cancelled"};let p=u;if(p.length===c.length)return zy(e);let d=ve(n)?me(n):null,f=await hn(n,{...d?.branch&&{branch:d.branch}});if(!f.success)return{success:!1,error:`Failed to fetch '${n}': ${f.error??"Unknown error"}`};let m=s?await By(n,s):null;if(m)t=m==="user",r=t?de():s?.workspacePath??r;let g=[...m?await n_(n,r):[]];for(let w of p)if(!g.includes(w))g.push(w);let y;if(!m&&s){let w=await Wf({source:n,install:"file",skills:g},s);if(w.status==="cancelled")return{success:"cancelled"};if(w.status==="failed")return{success:!1,error:`Failed to configure skill allowlist: ${w.error}`};t=w.scope==="user",r=t?de():s.workspacePath,y=Gc(w.normalizedPlugin??n)}else{let w=t?await Nd(n,g):await lg(n,g,r);if(!w.success)return{success:!1,error:`Failed to configure skill allowlist: ${w.error??"Unknown error"}`};y=Gc(w.normalizedPlugin??n)}console.log(`✓ Enabled ${p.length} skill(s) from ${y}: ${p.join(", ")}`);let v=t?await yt():await pt(r);if(!v.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:y,skills:g}],syncResult:v,locations:[Fu(t?"user":"project",r)]}}async function zy(e){let{isUser:t,workspacePath:r}=e,{from:n,targetContext:s}=e;if(!j())console.log(`Installing all skills from ${n}...`);let i=ve(n)?me(n):null,o=await hn(n,{...i?.branch&&{branch:i.branch}});if(!o.success)return{success:!1,error:`Failed to fetch '${n}': ${o.error??"Unknown error"}`};let a=L1(n,o.cachePath);if((await Kt(a)).success)return UKe({from:n,isUser:t,workspacePath:r,cachedPath:o.cachePath,targetContext:s});let l=await ga(a);if(l.length===0)return{success:!1,error:`No skills found in '${n}'.`};if(s){let m=await By(n,s);if(m)t=m==="user",r=t?de():s.workspacePath;else{let h=await Wf({source:n,install:"file",skills:l},s);if(h.status==="cancelled")return{success:"cancelled"};if(h.status==="failed")return{success:!1,error:`Failed to install plugin '${n}': ${h.error}`};t=h.scope==="user",r=t?de():s.workspacePath;let g=Gc(h.normalizedPlugin??(ve(n)?n:Tn(a)));if(!j())console.log(`✓ Enabled ${l.length} skill(s) from ${g}: ${l.join(", ")}`);let y=t?await yt():await pt(r);if(!y.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:g,skills:l}],syncResult:y,locations:[Fu(t?"user":"project",r)]}}}if(ve(n)){let h=[...await n_(n,r)];for(let w of l)if(!h.includes(w))h.push(w);let g=t?await Nd(n,h):await lg(n,h,r);if(!g.success)return{success:!1,error:`Failed to configure skill allowlist: ${g.error??"Unknown error"}`};let y=Gc(g.normalizedPlugin??n);if(!j())console.log(`✓ Enabled ${l.length} skill(s) from ${y}: ${l.join(", ")}`);let v=t?await yt():await pt(r);if(!v.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:y,skills:h}],syncResult:v,locations:[Fu(t?"user":"project",r)]}}let u=t?await Md(n):await ag(n,r);if(!u.success){if(!u.error?.includes("already exists")&&!u.error?.includes("duplicates existing"))return{success:!1,error:`Failed to install plugin '${n}': ${u.error??"Unknown error"}`};if(!j())console.log("Plugin already installed.")}let p=Tn(a),d=t?await ca(p,"allowlist",l):await vc(p,"allowlist",l,r);if(!d.success)return{success:!1,error:`Failed to configure skill allowlist: ${d.error??"Unknown error"}`};if(!j())console.log(`✓ Enabled ${l.length} skill(s) from ${p}: ${l.join(", ")}`);let f=t?await yt():await pt(r);if(!f.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:p,skills:l}],syncResult:f,locations:[Fu(t?"user":"project",r)]}}async function UKe(e){let{isUser:t,workspacePath:r}=e,{from:n,cachedPath:s,targetContext:i}=e,o=ve(n)?me(n):null,a=o?`${o.owner}/${o.repo}`:void 0,c=i?.workspacePath??r,l=await qr(o?.repo??n,a,i?c:t?void 0:r),u=l?.key??(o?.branch?`${o.repo}-${o.branch}`:o?.repo??Tn(n));if(!l){if(s)Qh(n,s);let y=t?"user":"project";if(i){let w=await i.resolve({source:n,install:"file"});if(!w)return{success:"cancelled"};y=w.scope}let v=await Uy({from:n,marketplaceName:u,scope:y,projectWorkspacePath:c});if(!v.success)return v;u=v.marketplaceName,l=await qr(u,a,y==="user"?void 0:c),t=y==="user",r=v.workspacePath}else t=l.scope==="user",r=t?de():c;let p=await no(u,t?void 0:r);if(p.plugins.length===0)return{success:!1,error:`No plugins found in marketplace '${u}'.`};let d=[];for(let y of p.plugins){let v=y.skills?y.skills.map((w)=>w.split("/").pop()??"").filter(Boolean):await ga(y.path);if(v.length>0)d.push({pluginName:y.name,skills:v})}if(d.length===0)return{success:!1,error:`No skills found across plugins in marketplace '${u}'.`};let f=await Hae({from:n,marketplaceName:u,registrationScope:l?.scope??(t?"user":"project"),selections:d,isUser:t,projectWorkspacePath:c,...i&&{targetContext:i}});if(f.success!==!0)return f;let{installed:m,changedScopes:h}=f;if(m.length===0)return{success:!1,error:`No skills found across plugins in marketplace '${u}'.`};if(!j()){let y=m.reduce((v,w)=>v+w.skills.length,0);console.log(`✓ Enabled ${y} skill(s) across ${m.length} plugin(s)`)}let g=await qae(h,c);if(!g.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:m,syncResult:g,locations:Bae(h,c)}}var BKe=xe.command({name:"add",description:qe(Fy),args:{skill:xe.positional({type:xe.optional(xe.string),displayName:"skill-or-source"}),scope:xe.option({type:xe.optional(xe.string),long:"scope",short:"s",description:'Scope: "project" (default) or "user"'}),client:xe.option({type:xe.optional(xe.string),long:"client",short:"c",description:"Comma-separated clients for this skill source"}),yes:xe.flag({long:"yes",short:"y",description:"Skip final install confirmation"}),plugin:xe.option({type:xe.optional(xe.string),long:"plugin",short:"p",description:"Plugin name (required if skill exists in multiple plugins)"}),from:xe.option({type:xe.optional(xe.string),long:"from",short:"f",description:"Plugin source to install if the skill is not already available"}),skillFlag:xe.option({type:xe.optional(xe.string),long:"skill",description:"Comma-separated skill names to install when the positional argument is a plugin source (e.g., owner/repo --skill foo,bar)"}),ref:xe.option({type:xe.optional(xe.string),long:"ref",description:"Git ref to use for the plugin (tag or branch). Mutually exclusive with inline @ref in --from."}),list:xe.flag({long:"list",short:"l",description:"List available skills at --from without installing"}),all:xe.flag({long:"all",description:"Install every skill from --from"})},handler:async({skill:e,scope:t,client:r,yes:n,plugin:s,from:i,skillFlag:o,ref:a,list:c,all:l})=>{try{let u=FKe(e,o,c,l),p=[],d=!1;if(u.shape==="source"||u.shape==="source-auto"){if(i){if(j())H({success:!1,command:"skill add",error:"Cannot use --from when the positional argument is already a plugin source."}),process.exit(1);console.error("Error: Cannot use --from when the positional argument is already a plugin source."),process.exit(1)}if(i=e,e=void 0,u.shape==="source")p=u.skills;else d=!0}else if(o){if(j())H({success:!1,command:"skill add",error:"--skill requires the positional argument to be a plugin source (e.g., `skill add owner/repo --skill foo`). To install a known skill, pass the skill name as the positional."}),process.exit(1);console.error("Error: --skill requires the positional argument to be a plugin source (e.g., `skill add owner/repo --skill foo`). To install a known skill, pass the skill name as the positional."),process.exit(1)}let f;if(a||i){let C=i?IKe(i):void 0;if(a&&C){if(j())H({success:!1,command:"skill add",error:"Cannot combine inline @ref in --from with --ref. Use one or the other."}),process.exit(1);console.error("Error: Cannot combine inline @ref in --from with --ref. Use one or the other."),process.exit(1)}if(a&&i)i=`${i}@${a}`,f=a;else if(C)f=C;else if(a&&!i){if(j())H({success:!1,command:"skill add",error:"--ref requires --from to specify a plugin source."}),process.exit(1);console.error("Error: --ref requires --from to specify a plugin source."),process.exit(1)}}if(c){if(e){if(j())H({success:!1,command:"skill add",error:"Cannot combine a skill argument with --list. Use --list alone to discover available skills."}),process.exit(1);console.error("Error: Cannot combine a skill argument with --list. Use --list alone to discover available skills."),process.exit(1)}if(!i){if(j())H({success:!1,command:"skill add",error:"--list requires --from to specify a plugin source."}),process.exit(1);console.error("Error: --list requires --from to specify a plugin source."),process.exit(1)}if(l){if(j())H({success:!1,command:"skill add",error:"--list and --all cannot be used together."}),process.exit(1);console.error("Error: --list and --all cannot be used together."),process.exit(1)}let C=await Vae(i);if(!C.success){if(j())H({success:!1,command:"skill add",error:C.error}),process.exit(1);console.error(`Error: ${C.error}`),process.exit(1)}if(j()){H({success:!0,command:"skill add",data:{source:i,isMarketplace:C.isMarketplace,skills:C.skills.map((A)=>({name:A.name,...A.subpath!==A.name&&{path:A.subpath},description:A.description,...A.pluginName&&{plugin:A.pluginName}}))}});return}if(C.skills.length===0){console.log(`No skills found in ${i}.`);return}console.log(`
625
+ Tip: run \`allagents skill add --list --from ${s}\` to see all available skills.`};let l=c.canonical,u=ve(s)?Gc(s):Tn(i);if(o){let d=await By(s,o);if(d){if(t=d==="user",r=t?de():o.workspacePath,ve(s)){let h=[...await n_(s,r)];if(!h.includes(l))h.push(l);let g=t?await Nd(s,h):await lg(s,h,r);if(!g.success)return{success:!1,error:`Failed to update plugin '${s}': ${g.error??"Unknown error"}`};return Ly({skill:l,pluginName:Gc(g.normalizedPlugin??s),isUser:t,workspacePath:r})}return s_({skill:l,pluginName:u,isUser:t,workspacePath:r})}let f=await Wf({source:s,install:"file",skills:[l]},o);if(f.status==="cancelled")return{success:"cancelled"};if(f.status==="failed")return{success:!1,error:`Failed to install plugin '${s}': ${f.error}`};return t=f.scope==="user",r=t?de():o.workspacePath,Ly({skill:l,pluginName:Gc(f.normalizedPlugin??u),isUser:t,workspacePath:r})}if(ve(s)){let f=[...await n_(s,r)];if(!f.includes(l))f.push(l);let m=t?await Nd(s,f):await lg(s,f,r);if(!m.success)return{success:!1,error:`Failed to update plugin '${s}': ${m.error??"Unknown error"}`};return Ly({skill:l,pluginName:Gc(m.normalizedPlugin??s),isUser:t,workspacePath:r})}let p=t?await Md(s):await ag(s,r);if(!p.success){if(!p.error?.includes("already exists")&&!p.error?.includes("duplicates existing"))return{success:!1,error:`Failed to install plugin '${s}': ${p.error??"Unknown error"}`};if(!j())console.log("Plugin already installed.")}return s_({skill:l,pluginName:u,isUser:t,workspacePath:r})}function Gc(e){let t=ve(e)?me(e):null;if(t?.subpath){let r=t.subpath.split("/").filter(Boolean),n=r[r.length-1];if(n)return n}return Tn(e)}async function n_(e,t){let r=await Ir(e);if(!r)return[];let n=[],s=await Nr(t);for(let i of s){if(i.disabled)continue;if(await Ir(i.pluginSource)!==r)continue;if(!n.includes(i.name))n.push(i.name)}return n}async function s_(e){let{skill:t,pluginName:r,isUser:n,workspacePath:s}=e;if(((await Nr(s)).filter((c)=>c.pluginName===r)[0]?.pluginSkillsMode??"none")==="allowlist"){let c=`${r}:${t}`,l=n?await so(c):await aa(c,s);if(!l.success){if(!l.error?.includes("already enabled"))return{success:!1,error:`Failed to enable skill: ${l.error??"Unknown error"}`}}}else{let c=n?await ca(r,"allowlist",[t]):await vc(r,"allowlist",[t],s);if(!c.success)return{success:!1,error:`Failed to configure skill allowlist: ${c.error??"Unknown error"}`}}return Ly({skill:t,pluginName:r,isUser:n,workspacePath:s})}async function Ly(e){let{skill:t,pluginName:r,isUser:n,workspacePath:s}=e;if(!j())console.log(`✓ Enabled skill: ${t} (${r})`);let i=n?await yt():await pt(s);if(!i.success)return{success:!1,error:"Sync failed"};return{success:!0,pluginName:r,location:Fu(n?"user":"project",n?de():s),syncResult:{copied:i.totalCopied,failed:i.totalFailed}}}async function jae(e,t){let r=await o0(e),n=[];for(let s of r){let i=i_(s.skillPath,"SKILL.md"),o="";try{let a=await Lae(i,"utf-8");o=$s(a)?.description??""}catch{}n.push({name:s.name,subpath:s.subpath,description:o,...t&&{pluginName:t}})}return n}async function Vae(e){let t=ve(e)?me(e):null,r=await hn(e,{...t?.branch&&{branch:t.branch}});if(!r.success)return{success:!1,error:`Failed to fetch '${e}': ${r.error??"Unknown error"}`};let n=L1(e,r.cachePath),s=await Kt(n);if(s.success){let o=[];for(let a of s.data.plugins){if(typeof a.source==="object")continue;let c=BS(a.source,n);if(!zae(c))continue;let l=await jae(c,a.name);o.push(...l)}return{success:!0,skills:o,isMarketplace:!0}}return{success:!0,skills:await jae(n),isMarketplace:!1}}async function LKe(e){let{isUser:t,workspacePath:r}=e,{from:n,targetContext:s}=e;if(!(process.stdout.isTTY&&process.stdin.isTTY)||j()||s?.options.yes)return zy(e);let o=await Vae(n);if(!o.success)return{success:!1,error:o.error};if(o.skills.length===0)return{success:!1,error:`No skills found in '${n}'.`};if(o.skills.length===1)return zy(e);let a=await Promise.resolve().then(() => (jr(),tr));if(o.isMarketplace){let w=o.skills.map((ie)=>ie.name),P={};for(let ie of o.skills){let Ye=ie.pluginName??"Other";if(!P[Ye])P[Ye]=[];P[Ye].push({label:ie.name,value:ie.name,...ie.description?{hint:ie.description}:{}})}let b=await a.groupMultiselect({message:`Select skills to install from ${dt.bold(n)}`,options:P,initialValues:w,required:!1});if(a.isCancel(b)||b.length===0)return{success:"cancelled"};let S=b;if(S.length===w.length)return zy(e);let _=ve(n)?me(n):null,E=_?`${_.owner}/${_.repo}`:void 0,C=s?.workspacePath??r,A=await qr(_?.repo??n,E,s?C:t?void 0:r),k=A?.key??(_?.branch?`${_.repo}-${_.branch}`:_?.repo??Tn(n));if(!A){let ie=t?"user":"project";if(s){let Xe=await s.resolve({source:n,install:"file",skills:S});if(!Xe)return{success:"cancelled"};ie=Xe.scope}let Ye=await Uy({from:n,marketplaceName:k,scope:ie,projectWorkspacePath:C});if(!Ye.success)return Ye;k=Ye.marketplaceName,A=await qr(k,E,ie==="user"?void 0:C),t=ie==="user",r=Ye.workspacePath}else t=A.scope==="user",r=t?de():C;let T=await no(k,t?void 0:r);if(T.plugins.length===0)return{success:!1,error:`No plugins found in marketplace '${k}'.`};let L=[];for(let ie of T.plugins){let Xe=(ie.skills?ie.skills.map((mt)=>mt.split("/").pop()??"").filter(Boolean):await ga(ie.path)).filter((mt)=>S.includes(mt));if(Xe.length>0)L.push({pluginName:ie.name,skills:Xe})}if(L.length===0)return{success:!1,error:"No matching skills found in marketplace plugins."};let F=await Hae({from:n,marketplaceName:k,registrationScope:A?.scope??(t?"user":"project"),selections:L,isUser:t,projectWorkspacePath:C,...s&&{targetContext:s}});if(F.success!==!0)return F;let{installed:D,changedScopes:O}=F;if(D.length===0)return{success:!1,error:"No matching skills found in marketplace plugins."};if(!j()){let ie=D.reduce((Ye,Xe)=>Ye+Xe.skills.length,0);console.log(`✓ Enabled ${ie} skill(s) across ${D.length} plugin(s)`)}let pe=await qae(O,C);if(!pe.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:D,syncResult:pe,locations:Bae(O,C)}}let c=o.skills.map((w)=>w.name),l=o.skills.map((w)=>({label:w.name,value:w.name,...w.description?{hint:w.description}:{}})),u=await a.autocompleteMultiselect({message:`Select skills to install from ${dt.bold(n)}`,options:l,initialValues:c,placeholder:"Type to filter · Space to toggle · Enter to confirm",required:!1});if(a.isCancel(u)||u.length===0)return{success:"cancelled"};let p=u;if(p.length===c.length)return zy(e);let d=ve(n)?me(n):null,f=await hn(n,{...d?.branch&&{branch:d.branch}});if(!f.success)return{success:!1,error:`Failed to fetch '${n}': ${f.error??"Unknown error"}`};let m=s?await By(n,s):null;if(m)t=m==="user",r=t?de():s?.workspacePath??r;let g=[...m?await n_(n,r):[]];for(let w of p)if(!g.includes(w))g.push(w);let y;if(!m&&s){let w=await Wf({source:n,install:"file",skills:g},s);if(w.status==="cancelled")return{success:"cancelled"};if(w.status==="failed")return{success:!1,error:`Failed to configure skill allowlist: ${w.error}`};t=w.scope==="user",r=t?de():s.workspacePath,y=Gc(w.normalizedPlugin??n)}else{let w=t?await Nd(n,g):await lg(n,g,r);if(!w.success)return{success:!1,error:`Failed to configure skill allowlist: ${w.error??"Unknown error"}`};y=Gc(w.normalizedPlugin??n)}console.log(`✓ Enabled ${p.length} skill(s) from ${y}: ${p.join(", ")}`);let v=t?await yt():await pt(r);if(!v.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:y,skills:g}],syncResult:v,locations:[Fu(t?"user":"project",r)]}}async function zy(e){let{isUser:t,workspacePath:r}=e,{from:n,targetContext:s}=e;if(!j())console.log(`Installing all skills from ${n}...`);let i=ve(n)?me(n):null,o=await hn(n,{...i?.branch&&{branch:i.branch}});if(!o.success)return{success:!1,error:`Failed to fetch '${n}': ${o.error??"Unknown error"}`};let a=L1(n,o.cachePath);if((await Kt(a)).success)return UKe({from:n,isUser:t,workspacePath:r,cachedPath:o.cachePath,targetContext:s});let l=await ga(a);if(l.length===0)return{success:!1,error:`No skills found in '${n}'.`};if(s){let m=await By(n,s);if(m)t=m==="user",r=t?de():s.workspacePath;else{let h=await Wf({source:n,install:"file",skills:l},s);if(h.status==="cancelled")return{success:"cancelled"};if(h.status==="failed")return{success:!1,error:`Failed to install plugin '${n}': ${h.error}`};t=h.scope==="user",r=t?de():s.workspacePath;let g=Gc(h.normalizedPlugin??(ve(n)?n:Tn(a)));if(!j())console.log(`✓ Enabled ${l.length} skill(s) from ${g}: ${l.join(", ")}`);let y=t?await yt():await pt(r);if(!y.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:g,skills:l}],syncResult:y,locations:[Fu(t?"user":"project",r)]}}}if(ve(n)){let h=[...await n_(n,r)];for(let w of l)if(!h.includes(w))h.push(w);let g=t?await Nd(n,h):await lg(n,h,r);if(!g.success)return{success:!1,error:`Failed to configure skill allowlist: ${g.error??"Unknown error"}`};let y=Gc(g.normalizedPlugin??n);if(!j())console.log(`✓ Enabled ${l.length} skill(s) from ${y}: ${l.join(", ")}`);let v=t?await yt():await pt(r);if(!v.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:y,skills:h}],syncResult:v,locations:[Fu(t?"user":"project",r)]}}let u=t?await Md(n):await ag(n,r);if(!u.success){if(!u.error?.includes("already exists")&&!u.error?.includes("duplicates existing"))return{success:!1,error:`Failed to install plugin '${n}': ${u.error??"Unknown error"}`};if(!j())console.log("Plugin already installed.")}let p=Tn(a),d=t?await ca(p,"allowlist",l):await vc(p,"allowlist",l,r);if(!d.success)return{success:!1,error:`Failed to configure skill allowlist: ${d.error??"Unknown error"}`};if(!j())console.log(`✓ Enabled ${l.length} skill(s) from ${p}: ${l.join(", ")}`);let f=t?await yt():await pt(r);if(!f.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:[{pluginName:p,skills:l}],syncResult:f,locations:[Fu(t?"user":"project",r)]}}async function UKe(e){let{isUser:t,workspacePath:r}=e,{from:n,cachedPath:s,targetContext:i}=e,o=ve(n)?me(n):null,a=o?`${o.owner}/${o.repo}`:void 0,c=i?.workspacePath??r,l=await qr(o?.repo??n,a,i?c:t?void 0:r),u=l?.key??(o?.branch?`${o.repo}-${o.branch}`:o?.repo??Tn(n));if(!l){if(s)Qh(n,s);let y=t?"user":"project";if(i){let w=await i.resolve({source:n,install:"file"});if(!w)return{success:"cancelled"};y=w.scope}let v=await Uy({from:n,marketplaceName:u,scope:y,projectWorkspacePath:c});if(!v.success)return v;u=v.marketplaceName,l=await qr(u,a,y==="user"?void 0:c),t=y==="user",r=v.workspacePath}else t=l.scope==="user",r=t?de():c;let p=await no(u,t?void 0:r);if(p.plugins.length===0)return{success:!1,error:`No plugins found in marketplace '${u}'.`};let d=[];for(let y of p.plugins){let v=y.skills?y.skills.map((w)=>w.split("/").pop()??"").filter(Boolean):await ga(y.path);if(v.length>0)d.push({pluginName:y.name,skills:v})}if(d.length===0)return{success:!1,error:`No skills found across plugins in marketplace '${u}'.`};let f=await Hae({from:n,marketplaceName:u,registrationScope:l?.scope??(t?"user":"project"),selections:d,isUser:t,projectWorkspacePath:c,...i&&{targetContext:i}});if(f.success!==!0)return f;let{installed:m,changedScopes:h}=f;if(m.length===0)return{success:!1,error:`No skills found across plugins in marketplace '${u}'.`};if(!j()){let y=m.reduce((v,w)=>v+w.skills.length,0);console.log(`✓ Enabled ${y} skill(s) across ${m.length} plugin(s)`)}let g=await qae(h,c);if(!g.success)return{success:!1,error:"Sync failed"};return{success:!0,installed:m,syncResult:g,locations:Bae(h,c)}}var BKe=xe.command({name:"add",description:qe(Fy),args:{skill:xe.positional({type:xe.optional(xe.string),displayName:"skill-or-source"}),scope:xe.option({type:xe.optional(xe.string),long:"scope",short:"s",description:'Scope: "project" (default) or "user"'}),client:xe.option({type:xe.optional(xe.string),long:"client",short:"c",description:"Comma-separated clients for this skill source"}),yes:xe.flag({long:"yes",short:"y",description:"Run without prompts using configured or default scope and clients"}),plugin:xe.option({type:xe.optional(xe.string),long:"plugin",short:"p",description:"Plugin name (required if skill exists in multiple plugins)"}),from:xe.option({type:xe.optional(xe.string),long:"from",short:"f",description:"Plugin source to install if the skill is not already available"}),skillFlag:xe.option({type:xe.optional(xe.string),long:"skill",description:"Comma-separated skill names to install when the positional argument is a plugin source (e.g., owner/repo --skill foo,bar)"}),ref:xe.option({type:xe.optional(xe.string),long:"ref",description:"Git ref to use for the plugin (tag or branch). Mutually exclusive with inline @ref in --from."}),list:xe.flag({long:"list",short:"l",description:"List available skills at --from without installing"}),all:xe.flag({long:"all",description:"Install every skill from --from"})},handler:async({skill:e,scope:t,client:r,yes:n,plugin:s,from:i,skillFlag:o,ref:a,list:c,all:l})=>{try{let u=FKe(e,o,c,l),p=[],d=!1;if(u.shape==="source"||u.shape==="source-auto"){if(i){if(j())H({success:!1,command:"skill add",error:"Cannot use --from when the positional argument is already a plugin source."}),process.exit(1);console.error("Error: Cannot use --from when the positional argument is already a plugin source."),process.exit(1)}if(i=e,e=void 0,u.shape==="source")p=u.skills;else d=!0}else if(o){if(j())H({success:!1,command:"skill add",error:"--skill requires the positional argument to be a plugin source (e.g., `skill add owner/repo --skill foo`). To install a known skill, pass the skill name as the positional."}),process.exit(1);console.error("Error: --skill requires the positional argument to be a plugin source (e.g., `skill add owner/repo --skill foo`). To install a known skill, pass the skill name as the positional."),process.exit(1)}let f;if(a||i){let C=i?IKe(i):void 0;if(a&&C){if(j())H({success:!1,command:"skill add",error:"Cannot combine inline @ref in --from with --ref. Use one or the other."}),process.exit(1);console.error("Error: Cannot combine inline @ref in --from with --ref. Use one or the other."),process.exit(1)}if(a&&i)i=`${i}@${a}`,f=a;else if(C)f=C;else if(a&&!i){if(j())H({success:!1,command:"skill add",error:"--ref requires --from to specify a plugin source."}),process.exit(1);console.error("Error: --ref requires --from to specify a plugin source."),process.exit(1)}}if(c){if(e){if(j())H({success:!1,command:"skill add",error:"Cannot combine a skill argument with --list. Use --list alone to discover available skills."}),process.exit(1);console.error("Error: Cannot combine a skill argument with --list. Use --list alone to discover available skills."),process.exit(1)}if(!i){if(j())H({success:!1,command:"skill add",error:"--list requires --from to specify a plugin source."}),process.exit(1);console.error("Error: --list requires --from to specify a plugin source."),process.exit(1)}if(l){if(j())H({success:!1,command:"skill add",error:"--list and --all cannot be used together."}),process.exit(1);console.error("Error: --list and --all cannot be used together."),process.exit(1)}let C=await Vae(i);if(!C.success){if(j())H({success:!1,command:"skill add",error:C.error}),process.exit(1);console.error(`Error: ${C.error}`),process.exit(1)}if(j()){H({success:!0,command:"skill add",data:{source:i,isMarketplace:C.isMarketplace,skills:C.skills.map((A)=>({name:A.name,...A.subpath!==A.name&&{path:A.subpath},description:A.description,...A.pluginName&&{plugin:A.pluginName}}))}});return}if(C.skills.length===0){console.log(`No skills found in ${i}.`);return}console.log(`
626
626
  Available skills in ${i}:
627
627
  `);for(let A of C.skills){let k=A.subpath!==A.name?A.subpath:A.name,T=A.pluginName?`${k} ${dt.gray(`(${A.pluginName})`)}`:k;if(console.log(` ${dt.hex("#89b4fa")(T)}`),A.description)console.log(` ${A.description}`);console.log()}return}if(l||d){if(!i){if(j())H({success:!1,command:"skill add",error:"--all requires --from to specify a plugin source."}),process.exit(1);console.error("Error: --all requires --from to specify a plugin source."),process.exit(1)}if(e){if(j())H({success:!1,command:"skill add",error:"Cannot combine a skill argument with --all. Use --all alone to install every skill."}),process.exit(1);console.error("Error: Cannot combine a skill argument with --all. Use --all alone to install every skill."),process.exit(1)}let C=t==="user",A=C?de():process.cwd(),k=r_(process.cwd(),`${i} (${d?"selected skills":"all skills"})`,{scope:t,clients:r,yes:n}),T=d?await LKe({from:i,isUser:C,workspacePath:A,targetContext:k}):await zy({from:i,isUser:C,workspacePath:A,targetContext:k});if(T.success==="cancelled"){z1();return}if(!T.success){if(j())H({success:!1,command:"skill add",error:T.error}),process.exit(1);console.error(`Error: ${T.error}`),process.exit(1)}if(await j1({from:i,requestedRef:f,locations:T.locations}),j()){H({success:!0,command:"skill add",data:{source:i,installed:T.installed,syncResult:{copied:T.syncResult.totalCopied,failed:T.syncResult.totalFailed},...f&&{requestedRef:f}}});return}for(let F of gx(T.syncResult))console.log(F);let L=Nf(T.syncResult);if(L.length>0){console.log("");for(let F of L)console.log(F)}return}if(p.length>0){if(!i){if(j())H({success:!1,command:"skill add",error:"--skill requires a plugin source positional argument."}),process.exit(1);console.error("Error: --skill requires a plugin source positional argument."),process.exit(1)}let C=t==="user",A=C?de():process.cwd(),k=r_(process.cwd(),`${i}: ${p.join(", ")}`,{scope:t,clients:r,yes:n}),T=[],L=[],F=[];for(let O of p){let pe=await Fae({skill:O,from:i,isUser:C,workspacePath:A,targetContext:k});if(pe.success==="cancelled"){z1();return}if(pe.success===!0)T.push({skill:O,plugin:pe.pluginName,copied:pe.syncResult.copied,failed:pe.syncResult.failed}),L.push(pe.location);else F.push({skill:O,error:pe.error})}if(T.length>0)await j1({from:i,requestedRef:f,locations:L});let D=T.length===0;if(j()){if(H({success:!D,command:"skill add",data:{source:i,installed:T,failed:F,...f&&{requestedRef:f}},...D&&{error:F.map((O)=>`${O.skill}: ${O.error}`).join("; ")}}),D)process.exit(1);return}for(let O of F)console.error(`Error installing '${O.skill}': ${O.error}`);if(f&&T.length>0)console.log(`Using ref ${f}.`);if(D)process.exit(1);return}if(!e){if(j())H({success:!1,command:"skill add",error:"A skill name is required. Use --list to discover available skills or --all to install everything."}),process.exit(1);console.error("Error: A skill name is required. Use --list to discover available skills or --all to install everything."),process.exit(1)}let m=e,h=i,g=OKe(m);if(g){if(h){if(j())H({success:!1,command:"skill add",error:"Cannot use --from when the skill argument is a GitHub URL. The URL is used as the plugin source automatically."}),process.exit(1);console.error("Error: Cannot use --from when the skill argument is a GitHub URL. The URL is used as the plugin source automatically."),process.exit(1)}if(h=g.from,g.parsed&&!g.parsed.subpath)m=await TKe(m,g.parsed,g.skill);else m=g.skill}let y=Boolean(h),v=t==="user"||!t&&!y&&Uae(process.cwd())==="user",w=v?de():process.cwd(),P=await ure(m,w);if(P.length===0){if(h){let T=r_(process.cwd(),`${h}: ${m}`,{scope:t,clients:r,yes:n}),L=await Fae({skill:m,from:h,isUser:v,workspacePath:w,targetContext:T});if(L.success==="cancelled"){z1();return}if(!L.success){if(j())H({success:!1,command:"skill add",error:L.error}),process.exit(1);console.error(`Error: ${L.error}`),process.exit(1)}if(await j1({from:h,requestedRef:f,locations:[L.location]}),j()){H({success:!0,command:"skill add",data:{skill:m,plugin:L.pluginName,syncResult:L.syncResult,...f&&{requestedRef:f}}});return}if(f)console.log(`Using ref ${f}.`);return}let C=await Nr(w),A=[...new Set(C.map((T)=>T.name))].join(", "),k=`Skill '${m}' not found in any installed plugin.
628
628
 
@@ -650,7 +650,7 @@ To see registered marketplaces:`),console.log(" allagents plugin marketplace li
650
650
  `);for(let u of c){let p=u.installed?` (installed - ${u.scope})`:"";if(console.log(` ❯ ${u.name}${p}`),u.description)console.log(` ${u.description}`);console.log()}console.log(`Total: ${c.length} plugins (${l} installed)`)}catch(t){if(t instanceof Error){if(j())H({success:!1,command:"plugin marketplace browse",error:t.message}),process.exit(1);console.error(`Error: ${t.message}`),process.exit(1)}throw t}}}),e7e=Sn({name:"marketplace",description:"Manage plugin marketplaces",cmds:{list:KKe,browse:QKe,add:JKe,remove:YKe,update:XKe}}),t7e=le.command({name:"list",description:qe(Dx),args:{},handler:async()=>{try{let t=function(w,P){return`source:${P}:${w}`},r=function(w,P,b){return`marketplace:${b}:${w}@${P}`},e=new Map;async function n(w,P){if(!qy(w))return;try{let b=P==="user"?await uc(w):await wr(w),{plans:S}=kn(b.plugins,b.clients,P);for(let _ of S)e.set(t(_.source,P),_.clients)}catch{}}let s=ju(oa(),X),i=ju(process.cwd(),K,X),o=St(process.cwd());if(await n(s,"user"),!o)await n(i,"project");let a=await gn(de()),c=o?null:await gn(process.cwd()),l=await eu(),u=await tu(process.cwd()),p=[...l,...u],d=new Map,f=await si(process.cwd());for(let w of[...f.plugins,...f.userPlugins??[]])d.set(w.source,w.kind);let m=new Map;for(let w of p){let P=w.marketplace?r(w.name,w.marketplace,w.scope):t(w.effectiveSpec,w.scope),b=e.get(t(w.effectiveSpec,w.scope))??[],S=m.get(P);if(S){for(let _ of b)if(!S.fileClients.includes(_))S.fileClients.push(_);continue}m.set(P,{spec:w.spec,effectiveSpec:w.effectiveSpec,name:w.name,marketplace:w.marketplace,scope:w.scope,kind:d.get(w.spec)??"plugin",fileClients:[...b],nativeClients:[],nativeResources:[]})}for(let[w,P]of[[a,"user"],[c,"project"]])for(let[b,S]of Object.entries(w?.nativePlugins??{}))for(let _ of S){if(f.nativeResources.some((T)=>T.client===b&&T.scope===P&&Mc(_,T.requestedIdentity,T.resolvedIdentity)))continue;let C=ht(_),A=C?r(C.plugin,C.marketplaceName,P):t(_,P),k=m.get(A);if(k){if(!k.nativeClients.includes(b))k.nativeClients.push(b);continue}m.set(A,{spec:_,effectiveSpec:_,name:C?.plugin??Jh(_),marketplace:C?.marketplaceName??"",scope:P,kind:d.get(_)??"plugin",fileClients:[],nativeClients:[b],nativeResources:[]})}for(let w of f.nativeResources){let P=w.requestedIdentity,b=ht(w.resolvedIdentity)??ht(P),S=b?r(b.plugin,b.marketplaceName,w.scope):t(P,w.scope),_=m.get(S);if(_){if(!_.nativeClients.includes(w.client))_.nativeClients.push(w.client);_.nativeResources.push(w);continue}m.set(S,{spec:P,effectiveSpec:P,name:b?.plugin??Jh(P),marketplace:b?.marketplaceName??"",scope:w.scope,kind:d.get(P)??"plugin",fileClients:[],nativeClients:[w.client],nativeResources:[w]})}let h=[...m.values()];if(j()){if(H({success:f.success,command:"plugin list",data:{plugins:h.map((w)=>({name:w.name,spec:w.spec,marketplace:w.marketplace,scope:w.scope,kind:w.kind,...w.fileClients.length>0&&{clients:w.fileClients},...w.nativeClients.length>0&&{nativeClients:w.nativeClients},...w.nativeResources.length>0&&{nativeResources:w.nativeResources}})),total:h.length},...!f.success&&{error:f.error??"Native inspection failed"}}),!f.success)process.exit(1);return}if(h.length===0){if(console.log(`No plugins installed.
651
651
  `),console.log("To discover available plugins:"),console.log(` allagents plugin marketplace browse <name>
652
652
  `),console.log("To see registered marketplaces:"),console.log(" allagents plugin marketplace list"),!f.success)console.error(`Error: ${f.error??"Native inspection failed"}`),process.exit(1);return}let g=h.filter((w)=>w.kind==="skill").length,y=h.length-g;console.log(`Plugins:
653
- `);for(let w of h){if(console.log(` ❯ ${w.marketplace?w.spec:w.name}`),console.log(` Type: ${w.kind}`),console.log(` Scope: ${w.scope}`),!w.marketplace)console.log(` Source: ${ta(w.effectiveSpec)}`);if(w.fileClients.length>0||w.nativeClients.length>0){let b=[...w.nativeClients.map((S)=>`native ${S}`),...w.fileClients];console.log(` Clients: ${b.join(", ")}`)}for(let b of w.nativeResources)console.log(`${my(b)} declared=${String(b.declared)} ownership=${b.ownership}${b.transition?` transition=${b.transition}`:""}`);console.log("")}let v=[];if(y>0)v.push(`${y} plugin${y===1?"":"s"}`);if(g>0)v.push(`${g} skill${g===1?"":"s"}`);if(console.log(`Total: ${v.join(", ")}`),!f.success)console.error(`Error: ${f.error??"Native inspection failed"}`),process.exit(1)}catch(e){if(e instanceof Error){if(j())H({success:!1,command:"plugin list",error:e.message}),process.exit(1);console.error(`Error: ${e.message}`),process.exit(1)}throw e}}}),r7e=le.command({name:"validate",description:qe(Fx),args:{path:le.positional({type:le.string,displayName:"path"})},handler:async({path:e})=>{if(j()){H({success:!0,command:"plugin validate",data:{path:e,valid:!1,message:"not yet implemented"}});return}console.log(`Validating plugin at: ${e}`),console.log("(validation not yet implemented)")}}),n7e=le.command({name:"install",description:qe(jx),args:{plugin:le.positional({type:le.string,displayName:"plugin"}),scope:le.option({type:le.optional(le.string),long:"scope",short:"s",description:'Installation scope: "project" (default) or "user"'}),client:le.option({type:le.optional(le.string),long:"client",short:"c",description:"Comma-separated clients for this plugin"}),yes:le.flag({long:"yes",short:"y",description:"Skip final install confirmation"}),skills:le.multioption({type:le.array(le.string),long:"skill",description:"Only enable specific skills (can be repeated)"})},handler:async({plugin:e,scope:t,client:r,yes:n,skills:s})=>{try{let i=process.cwd(),o=ju(i,K,X),a=Wx(j()),c=await Lf({workspacePath:i,declaration:e,action:"Install plugin",payload:e,scopeStates:{project:async()=>{if(St(i)||!qy(o))return null;let S=await wr(o);return{clients:S.clients,plugins:S.plugins}},user:async()=>{let S=await bt();return S?{clients:S.clients,plugins:S.plugins}:null}},environment:a,...Gx(a)&&{prompts:Bf()},...t!==void 0&&{scope:t},...r!==void 0&&{clients:r},yes:n});if(!c){if(!j())console.log("Install cancelled. No changes made.");return}let l=c.scope==="user",u=c.selectedClientEntries,p=jt(ce(c.prospectiveDeclaration)),d=c.prospectiveDeclaration,f;if(p){let S=await Gl(d,l?void 0:i);if(!S.success)throw Error(S.error);d=S.declaration,f=S.registeredAs}if(!l){let S=await eb(Br(),ro(i));for(let _ of S)console.warn(`Warning: Workspace marketplace '${_}' overrides user marketplace of the same name.`)}let m=await Sf(d,u,c.scope,i);if(m.length>0)throw Error(`Native preflight failed; workspace declaration was not changed: ${m.join("; ")}`);let h=kn([d],u,c.scope).plans[0],g=!!h&&h.clients.length===0&&h.nativeClients.length>0,y={declaration:d,clients:c.clients,...(p||g)&&{sourceValidation:"declaration"}},v=l?await Jl(y):await Ad(y,i);if(!v.success){if(j())H({success:!1,command:"plugin install",error:v.error??"Unknown error"}),process.exit(1);console.error(`Error: ${v.error}`),process.exit(1)}if(f)v.autoRegistered??=f;let w=v.normalizedPlugin??e;if(s.length>0){let S=l?de():process.cwd(),_=l?await yt():await pt(S);if(!_.success){let k=`Initial sync failed: ${_.error??"Unknown error"}`;if(j())H({success:!1,command:"plugin install",error:k}),process.exit(1);console.error(`Error: ${k}`),process.exit(1)}let E=await Nr(S),C=yc(w),A=E.filter((k)=>k.pluginSource===w||C.includes(k.pluginName));if(A.length===0){if(!j())console.error(`Warning: No skills found in plugin ${w}`)}else{let k=A[0]?.pluginName,T=A.map((F)=>F.name),L=s.filter((F)=>!T.includes(F));if(L.length>0){let F=`Unknown skills: ${L.join(", ")}. Available: ${T.join(", ")}`;if(j())H({success:!1,command:"plugin install",error:F}),process.exit(1);console.error(`Error: ${F}`),process.exit(1)}for(let F of s){let D=`${k}:${F}`,O=l?await so(D):await aa(D,S);if(!O.success&&!j())console.error(`Warning: ${O.error}`)}if(!j())console.log(`
653
+ `);for(let w of h){if(console.log(` ❯ ${w.marketplace?w.spec:w.name}`),console.log(` Type: ${w.kind}`),console.log(` Scope: ${w.scope}`),!w.marketplace)console.log(` Source: ${ta(w.effectiveSpec)}`);if(w.fileClients.length>0||w.nativeClients.length>0){let b=[...w.nativeClients.map((S)=>`native ${S}`),...w.fileClients];console.log(` Clients: ${b.join(", ")}`)}for(let b of w.nativeResources)console.log(`${my(b)} declared=${String(b.declared)} ownership=${b.ownership}${b.transition?` transition=${b.transition}`:""}`);console.log("")}let v=[];if(y>0)v.push(`${y} plugin${y===1?"":"s"}`);if(g>0)v.push(`${g} skill${g===1?"":"s"}`);if(console.log(`Total: ${v.join(", ")}`),!f.success)console.error(`Error: ${f.error??"Native inspection failed"}`),process.exit(1)}catch(e){if(e instanceof Error){if(j())H({success:!1,command:"plugin list",error:e.message}),process.exit(1);console.error(`Error: ${e.message}`),process.exit(1)}throw e}}}),r7e=le.command({name:"validate",description:qe(Fx),args:{path:le.positional({type:le.string,displayName:"path"})},handler:async({path:e})=>{if(j()){H({success:!0,command:"plugin validate",data:{path:e,valid:!1,message:"not yet implemented"}});return}console.log(`Validating plugin at: ${e}`),console.log("(validation not yet implemented)")}}),n7e=le.command({name:"install",description:qe(jx),args:{plugin:le.positional({type:le.string,displayName:"plugin"}),scope:le.option({type:le.optional(le.string),long:"scope",short:"s",description:'Installation scope: "project" (default) or "user"'}),client:le.option({type:le.optional(le.string),long:"client",short:"c",description:"Comma-separated clients for this plugin"}),yes:le.flag({long:"yes",short:"y",description:"Run without prompts using configured or default scope and clients"}),skills:le.multioption({type:le.array(le.string),long:"skill",description:"Only enable specific skills (can be repeated)"})},handler:async({plugin:e,scope:t,client:r,yes:n,skills:s})=>{try{let i=process.cwd(),o=ju(i,K,X),a=Wx(j()),c=await Lf({workspacePath:i,declaration:e,action:"Install plugin",payload:e,scopeStates:{project:async()=>{if(St(i)||!qy(o))return null;let S=await wr(o);return{clients:S.clients,plugins:S.plugins}},user:async()=>{let S=await bt();return S?{clients:S.clients,plugins:S.plugins}:null}},environment:a,...Gx(a)&&{prompts:Bf()},...t!==void 0&&{scope:t},...r!==void 0&&{clients:r},yes:n});if(!c){if(!j())console.log("Install cancelled. No changes made.");return}let l=c.scope==="user",u=c.selectedClientEntries,p=jt(ce(c.prospectiveDeclaration)),d=c.prospectiveDeclaration,f;if(p){let S=await Gl(d,l?void 0:i);if(!S.success)throw Error(S.error);d=S.declaration,f=S.registeredAs}if(!l){let S=await eb(Br(),ro(i));for(let _ of S)console.warn(`Warning: Workspace marketplace '${_}' overrides user marketplace of the same name.`)}let m=await Sf(d,u,c.scope,i);if(m.length>0)throw Error(`Native preflight failed; workspace declaration was not changed: ${m.join("; ")}`);let h=kn([d],u,c.scope).plans[0],g=!!h&&h.clients.length===0&&h.nativeClients.length>0,y={declaration:d,clients:c.clients,...(p||g)&&{sourceValidation:"declaration"}},v=l?await Jl(y):await Ad(y,i);if(!v.success){if(j())H({success:!1,command:"plugin install",error:v.error??"Unknown error"}),process.exit(1);console.error(`Error: ${v.error}`),process.exit(1)}if(f)v.autoRegistered??=f;let w=v.normalizedPlugin??e;if(s.length>0){let S=l?de():process.cwd(),_=l?await yt():await pt(S);if(!_.success){let k=`Initial sync failed: ${_.error??"Unknown error"}`;if(j())H({success:!1,command:"plugin install",error:k}),process.exit(1);console.error(`Error: ${k}`),process.exit(1)}let E=await Nr(S),C=yc(w),A=E.filter((k)=>k.pluginSource===w||C.includes(k.pluginName));if(A.length===0){if(!j())console.error(`Warning: No skills found in plugin ${w}`)}else{let k=A[0]?.pluginName,T=A.map((F)=>F.name),L=s.filter((F)=>!T.includes(F));if(L.length>0){let F=`Unknown skills: ${L.join(", ")}. Available: ${T.join(", ")}`;if(j())H({success:!1,command:"plugin install",error:F}),process.exit(1);console.error(`Error: ${F}`),process.exit(1)}for(let F of s){let D=`${k}:${F}`,O=l?await so(D):await aa(D,S);if(!O.success&&!j())console.error(`Warning: ${O.error}`)}if(!j())console.log(`
654
654
  Enabled skills: ${s.join(", ")}`)}}if(v.replaced&&!j())console.log(`Plugin '${w}' already exists. Replacing with new source.`);if(!j()){if(v.autoRegistered)console.log(` Resolved marketplace: ${v.autoRegistered}`);console.log(`Installing plugin "${w}"...
655
655
  `)}let{ok:P,syncData:b}=l?await B1():await U1();if(!j()&&P)console.log(`
656
656
  ✔ Successfully installed plugin: ${w} (scope: ${l?"user":"project"})`);if(j()){if(H({success:P,command:"plugin install",data:{plugin:w,scope:l?"user":"project",autoRegistered:v.autoRegistered??null,...s.length>0&&{enabledSkills:s},replaced:v.replaced??!1,syncResult:b},...!P&&{error:"Sync completed with failures"}}),!P)process.exit(1);return}if(!P)process.exit(1)}catch(i){if(i instanceof Error){if(j())H({success:!1,command:"plugin install",error:i.message}),process.exit(1);console.error(`Error: ${i.message}`),process.exit(1)}throw i}}}),s7e=le.command({name:"uninstall",description:qe(zx),aliases:["remove"],args:{plugin:le.positional({type:le.string,displayName:"plugin"}),scope:le.option({type:le.optional(le.string),long:"scope",short:"s",description:'Installation scope: "project" (default) or "user"'})},handler:async({plugin:e,scope:t})=>{try{if(t&&t!=="user"&&t!=="project")throw Error(`Invalid scope '${t}'. Must be 'user' or 'project'.`);let r=t==="user"?["user"]:t==="project"?["project"]:St(process.cwd())?["user"]:["project","user"],n=[],s={},i=!1,o=!0;for(let a of r){let c=await ZKe(e,a),l=c!==void 0,u=c??e,p=await GKe(u,a);if(!l&&!p)continue;if(i=!0,l){let m=a==="user"?await Xl(u):await Od(u);if(!m.success){if(o=!1,n.push({scope:a,action:"failed",error:m.error??"Declaration removal failed"}),!j())console.error(`✗ Declaration removal (${a}): ${m.error??"Unknown error"}`);continue}if(n.push({scope:a,action:"removed"}),!j())console.log(`✓ Declaration removed (${a} scope): ${e}`)}else if(n.push({scope:a,action:"absent"}),!j())console.log(`= Declaration already absent (${a} scope): ${e}`);let d={mode:"remove",targets:[u]},f=a==="user"?await B1({nativeSelection:d}):await U1({nativeSelection:d});if(s[a]=f.syncData,!f.ok)o=!1}if(!i){let a=`Plugin not found: ${e}`;if(j())H({success:!1,command:"plugin uninstall",error:a}),process.exit(1);console.error(`Error: ${a}`),process.exit(1)}if(j())H({success:o,command:"plugin uninstall",data:{plugin:e,scopes:n.map((a)=>a.scope),declarations:n,syncResults:s},...!o&&{error:"Declaration removal or native cleanup failed"}});if(!o)process.exit(1)}catch(r){if(r instanceof Error){if(j())H({success:!1,command:"plugin uninstall",error:r.message}),process.exit(1);console.error(`Error: ${r.message}`),process.exit(1)}throw r}}}),i7e=le.command({name:"update",description:qe(Lx),args:{plugin:le.positional({type:le.optional(le.string),displayName:"plugin"}),scope:le.option({type:le.optional(le.string),long:"scope",short:"s",description:'Installation scope: "project" (default), "user", or "all"'})},handler:async({plugin:e,scope:t})=>{let r=new vo;try{if(t&&t!=="user"&&t!=="project"&&t!=="all")throw Error(`Invalid scope '${t}'. Must be 'user', 'project', or 'all'.`);let n=t==="all",s=t==="user"||n,i=t==="project"||!t&&!n||n,o=[],a=(_,E)=>{if(!o.some((C)=>C.spec===_&&C.scope===E))o.push({spec:_,scope:E})};if(i&&!St(process.cwd())){let _=await tu(process.cwd());for(let E of _)a(E.spec,"project")}if(s){let _=await eu();for(let E of _)a(E.spec,"user")}let c={};if(i&&!St(process.cwd())){let _=ju(process.cwd(),K,X);if(qy(_)){let E=await wr(_);c.project=E;for(let C of E.plugins)a(ce(C),"project")}}if(s){let _=await bt();if(_){c.user=_;for(let E of _.plugins)a(ce(E),"user")}}let l=e?o.filter(({spec:_})=>Mc(e,_,_)):o;if(e&&l.length===0){let _=`Plugin not found: ${e}`;if(j())H({success:!1,command:"plugin update",error:_}),process.exit(1);console.error(`Error: ${_}`),process.exit(1)}if(l.length===0){if(j()){H({success:!0,command:"plugin update",data:{results:[],updated:0,skipped:0,failed:0}});return}console.log("No plugins to update.");return}let u={project:[],user:[]},p=new Set;for(let _ of l){let E=c[_.scope];if(!E)continue;let C=E.plugins.find((T)=>ce(T)===_.spec)??_.spec,A=await Sf(C,E.clients,_.scope,process.cwd());if(A.length>0)throw Error(`Native preflight failed before update: ${A.join("; ")}`);let k=kn([C],E.clients,_.scope).plans[0];if((k?.nativeClients.length??0)>0){if(u[_.scope].push(_.spec),k?.clients.length===0)p.add(`${_.scope}:${_.spec}`)}}if(!j())console.log(e?`Updating plugin: ${e}...`:"Updating plugins..."),console.log();let d=[],f=(_)=>{let E=_==="project"?process.cwd():void 0;return{parsePluginSpec:ht,getMarketplaceRegistration:(C,A)=>qr(C,A,E),validateMarketplaceAccess:bs,parseMarketplaceManifest:Kt,updateMarketplace:(C)=>Ys(C,E,{},r)}},m={project:f("project"),user:f("user")},h=new Set;for(let{spec:_,scope:E}of l){let C=p.has(`${E}:${_}`)?{plugin:_,success:!0,action:"skipped"}:await eg(_,m[E],r);if(C.action==="updated")h.add(E);d.push(C)}let g=!0,y={},v={},w={project:l.filter((_)=>_.scope==="project").map((_)=>_.spec),user:l.filter((_)=>_.scope==="user").map((_)=>_.spec)};if(w.project.length>0&&(h.has("project")||u.project.length>0)){let{ok:_,syncData:E}=await U1({skipAgentFiles:!0,nativeSelection:{mode:"update",targets:w.project}});if(y.project=E,!_)g=!1;v.project=E.nativeResources?.effects??[]}if(w.user.length>0&&(h.has("user")||u.user.length>0)){let{ok:_,syncData:E}=await B1({skipAgentFiles:!0,nativeSelection:{mode:"update",targets:w.user}});if(y.user=E,!_)g=!1;v.user=E.nativeResources?.effects??[]}for(let _=0;_<l.length;_++){let E=l[_];if(!E||!p.has(`${E.scope}:${E.spec}`))continue;let C=(v[E.scope]??[]).filter((k)=>Mc(E.spec,k.requestedIdentity,k.resolvedIdentity)),A=C.find((k)=>k.action==="failed"||k.action==="unknown");d[_]=A?{plugin:E.spec,success:!1,action:"failed",error:A.error??`Native ${A.phase} did not establish a known result`}:C.some((k)=>k.changed)?{plugin:E.spec,success:!0,action:"updated"}:C.length>0?{plugin:E.spec,success:!0,action:"skipped"}:{plugin:E.spec,success:!1,action:"failed",error:"Native update produced no matching lifecycle effect"}}for(let _ of d){if(j())continue;let E=_.success?_.action==="updated"?"✓":"-":"✗";if(console.log(`${E} ${_.plugin} (${_.action})`),_.error)console.log(` Error: ${_.error}`)}let P=d.filter((_)=>_.action==="updated").length,b=d.filter((_)=>_.action==="skipped").length,S=d.filter((_)=>_.action==="failed").length;if(j()){if(H({success:S===0&&g,command:"plugin update",data:{results:d.map((_)=>({plugin:_.plugin,success:_.success,action:_.action,..._.error&&{error:_.error}})),updated:P,skipped:b,failed:S,...Object.keys(y).length>0&&{syncResults:y}},...(S>0||!g)&&{error:S>0?`${S} plugin(s) failed to update`:"Native update or sync failed"}}),S>0||!g)process.exit(1);return}if(console.log(),console.log(`Update complete: ${P} updated, ${b} skipped, ${S} failed`),S>0||!g)process.exit(1)}catch(n){if(n instanceof Error){if(j())H({success:!1,command:"plugin update",error:n.message}),process.exit(1);console.error(`Error: ${n.message}`),process.exit(1)}throw n}finally{r.dispose()}}}),Gae=Sn({name:"plugin",description:"Manage plugins and marketplaces",cmds:{install:n7e,uninstall:s7e,update:i7e,marketplace:e7e,list:t7e,validate:r7e,skills:o_}});jr();ox();var Xt=vt(Vi(),1);var Zae=["profile","operation","status","declarationDigest","clients","plan","steps","warnings","error"],Kae=["profile","operation","status","declared","installed","declarationDigest","stateDigest","clients","steps","launchers","warnings","error"],q1=[{name:"name",type:"string",required:!1,description:"Profile name. In an interactive terminal, omit to choose from the available profiles."}],Jae=[{flag:"--yes",short:"-y",type:"boolean",description:"Apply the displayed plan without asking for confirmation."},{flag:"--dry-run",type:"boolean",description:"Display the plan without prompting or changing any files."},{flag:"--offline",type:"boolean",description:"Plan and apply using only locally available sources."}],H1=[{client:"string",mechanism:"string",root:"string",agentRoot:"string",launcher:{name:"string",command:{command:"string",args:["string"]},destinations:["string"]}}],V1=[{status:"created | updated | removed | unchanged | referenced | retained | failed",client:"string",kind:"string",identity:"string",requestedRef:"string?",resolvedRef:"string?",detail:{source:"string?",skills:["string"],commands:[{command:"string",args:["string"]}],mcpServers:[{name:"string",transport:"http | stdio",endpoint:"string?",command:{command:"string",args:["string"]},requestedSecrets:["string"]}]},error:"string?"}],Yae={profile:"string",operation:"install | remove",status:"planned",declarationDigest:"string",clients:H1,steps:V1,warnings:["string"]},a_={command:"profile install",description:"Install a declared global agent profile",whenToUse:"When you want AllAgents to materialize one user profile, its client resources, and its launchers from the user workspace declaration",examples:["allagents profile install work","allagents profile install work --dry-run","allagents profile install work --yes --offline","allagents --json profile install work --yes"],expectedOutput:"Displays a redacted deterministic plan, asks before applying unless --yes is supplied, and reports each created, updated, unchanged, referenced, retained, or failed step.",positionals:q1,options:Jae,outputSchema:{profile:"string",operation:"install",status:"string",declarationDigest:"string?",clients:H1,steps:V1,plan:Yae,warnings:["string"],error:"string?"},jsonFields:Zae},Xae={profile:"string",operation:"status",status:"string",declared:"boolean",installed:"boolean",declarationDigest:"string?",stateDigest:"string?",clients:["string"],steps:[{status:"created | updated | removed | unchanged | referenced | retained | failed",client:"string?",kind:"string?",identity:"string?",error:"string?"}],launchers:[{client:"string",name:"string",path:"string",onPath:"boolean"}],warnings:["string"],error:"string?"},c_={command:"profile list",description:"List declared and installed global profiles",whenToUse:"When you need a read-only inventory of every declared or installed profile, its clients, and launcher PATH status",examples:["allagents profile list","allagents --json profile list"],expectedOutput:"Lists every declared and declaration-missing installed profile with overall state, clients, and launcher paths without changing user files.",outputSchema:{profiles:[Xae],total:"number"},jsonFields:Kae,skipUpdateCheck:!0},l_={command:"profile status",description:"Inspect declared and installed global profiles",whenToUse:"When you need detailed read-only profile state, per-resource status, or launcher PATH diagnostics",examples:["allagents profile status work","allagents profile status","allagents --json profile status work"],expectedOutput:"Reports declared and installed state, detailed resource statuses, warnings, and whether the profile launcher directory is available on PATH without changing user files.",positionals:q1,outputSchema:Xae,jsonFields:Kae},u_={command:"profile remove",description:"Remove an installed or declared global profile safely",whenToUse:"When you want AllAgents to remove resources and profile-owned OAuth credentials for one installed or declared user profile while retaining referenced resources",examples:["allagents profile remove work","allagents profile remove work --dry-run","allagents profile remove work --yes","allagents --json profile remove work --yes"],expectedOutput:"Displays a redacted deterministic removal plan, asks before applying unless --yes is supplied, removes profile-owned OAuth credentials even for a declared-only profile, and reports removed, retained, unchanged, or failed resources.",positionals:q1,options:Jae,outputSchema:{profile:"string",operation:"remove",status:"string",declarationDigest:"string?",clients:H1,steps:V1,plan:Yae,warnings:["string"],error:"string?"},jsonFields:Zae};var o7e={planProfileOperation:Ef,applyProfilePlan:sx,getProfileStatus:ix,getProfileStatuses:VN},a7e={isInteractive:()=>Boolean(process.stdin.isTTY&&process.stdout.isTTY)&&!j(),isJson:j,print:(e)=>console.log(e),printError:(e)=>console.error(e),printJson:H,selectProfile:async({message:e,options:t})=>{let r=await il({message:e,options:t.map((n)=>({...n}))});return ze(r)?void 0:r},confirm:async({message:e})=>{let t=await sl({message:e,initialValue:!1});return ze(t)?void 0:t},exit:(e)=>process.exit(e)};class zu extends Error{exitCode;data;constructor(e,t,r){super(e);this.exitCode=t;this.data=r}}function c7e(e){return{...e.offline?{offline:!0}:{},...e.dryRun?{dryRun:!0}:{}}}function l7e(e){switch(e){case"install":return"Select a declared profile to install";case"remove":return"Select an installed profile to remove";case"status":return"Select a profile to inspect"}}function u7e(e,t){return t.filter((r)=>{switch(e){case"install":return r.declared;case"remove":return r.installed;case"status":return r.declared||r.installed}return!1}).sort((r,n)=>r.profile.localeCompare(n.profile))}async function rce(e,t,r,n,s){if(t)return t;if(!n.isInteractive()||n.isJson())throw new zu(`profile name is required in non-interactive and JSON modes; pass a name to profile ${e}`,2);let i=u7e(e,await r.getProfileStatuses(s));if(i.length===0)throw new zu(e==="install"?"No declared profiles are available to install":`No ${e==="remove"?"installed":"declared or installed"} profiles are available`,2);return n.selectProfile({message:l7e(e),options:i.map((o)=>({value:o.profile,label:`${o.profile} (${o.status})`}))})}function Qae(e,t){for(let r of Jie(e))t.print(r)}function nce(e,t,r,n,s){if(r.isJson()){r.printJson({success:n,command:e,data:{...Ru(t),...s?{plan:hx(s)}:{}},...!n&&{error:t.error??`Profile ${t.profile} ${t.status}`}});return}for(let i of Tf(t))r.print(i)}function ece(e){return{profile:e.profile,operation:e.operation,status:"failed",steps:[],warnings:e.warnings,plan:hx(e)}}async function tce(e,t,r,n){let s=c7e(t),i=await rce(e,t.name,r,n,s);if(!i){if(!n.isJson())n.print(`Profile ${e} cancelled.`);return 0}let o=await r.planProfileOperation(i,e,s);if(t.dryRun){if(n.isJson())n.printJson({success:!0,command:`profile ${e}`,data:hx(o)});else Qae(o,n),n.print("Dry run; no changes applied.");return 0}if(!n.isJson())Qae(o,n);if(!t.yes){if(!n.isInteractive()||n.isJson())throw new zu(`profile ${e} requires confirmation; rerun with --yes in non-interactive and JSON modes`,2,ece(o));if(await n.confirm({message:`${e==="install"?"Install":"Remove"} profile '${i}' using this plan?`})!==!0)return n.print(`Profile ${e} cancelled.`),0}let a;try{a=await r.applyProfilePlan(o,s)}catch(c){throw new zu(c instanceof Error?c.message:String(c),1,ece(o))}return nce(`profile ${e}`,a,n,a.success,o),a.success?0:1}async function p7e(e,t){let r=await e.getProfileStatuses({}),n=r.filter((o)=>o.error!==void 0).map((o)=>o.profile).sort((o,a)=>o.localeCompare(a)),s=n.length===0,i=s?void 0:`Failed to inspect profiles: ${n.join(", ")}`;if(t.isJson())return t.printJson({success:s,command:"profile list",data:Kie(r),...i&&{error:i}}),s?0:1;for(let o of Yie(r))t.print(o);if(i)t.printError(`Error: ${J(i)}`);return s?0:1}async function d7e(e,t,r){let n={},s=await rce("status",e,t,r,n);if(!s){if(!r.isJson())r.print("Profile status cancelled.");return 0}let i=await t.getProfileStatus(s,n),o=i.error===void 0;return nce("profile status",i,r,o),o?0:1}async function p_(e,t,r){let n=0;try{n=await r()}catch(s){let i=s instanceof Error?s.message:String(s);if(n=s instanceof zu?s.exitCode:1,t.isJson())t.printJson({success:!1,command:e,...s instanceof zu&&s.data?{data:{...s.data,error:i}}:{},error:i});else t.printError(`Error: ${J(i)}`)}if(n!==0)t.exit(n)}function f7e(e=o7e,t=a7e){let r=Xt.command({name:"install",description:qe(a_),args:{name:Xt.positional({type:Xt.optional(Xt.string),displayName:"name"}),yes:Xt.flag({long:"yes",short:"y",description:"Apply without asking for confirmation"}),dryRun:Xt.flag({long:"dry-run",description:"Display the plan without making changes"}),offline:Xt.flag({long:"offline",description:"Use only locally available sources"})},handler:(o)=>p_("profile install",t,()=>tce("install",o,e,t))}),n=Xt.command({name:"list",description:qe(c_),args:{},handler:()=>p_("profile list",t,()=>p7e(e,t))}),s=Xt.command({name:"status",description:qe(l_),args:{name:Xt.positional({type:Xt.optional(Xt.string),displayName:"name"})},handler:({name:o})=>p_("profile status",t,()=>d7e(o,e,t))}),i=Xt.command({name:"remove",description:qe(u_),args:{name:Xt.positional({type:Xt.optional(Xt.string),displayName:"name"}),yes:Xt.flag({long:"yes",short:"y",description:"Apply without asking for confirmation"}),dryRun:Xt.flag({long:"dry-run",description:"Display the plan without making changes"}),offline:Xt.flag({long:"offline",description:"Use only locally available sources"})},handler:(o)=>p_("profile remove",t,()=>tce("remove",o,e,t))});return Sn({name:"profile",description:"Manage global Pi and OMP profiles",cmds:{install:r,list:n,status:s,remove:i}})}var sce=f7e();var Ky=vt(Vi(),1);var Gce=vt(r1(),1);import{Buffer as RJe}from"node:buffer";import AJe from"node:path";import hD from"node:child_process";import x_ from"node:process";function W1(e){let t=typeof e==="string"?`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allagents",
3
- "version": "1.16.2-next.1",
3
+ "version": "1.16.3-next.1",
4
4
  "packageManager": "bun@1.4.0",
5
5
  "description": "CLI tool for managing multi-repo AI agent workspaces with plugin synchronization",
6
6
  "type": "module",