shared-context-ai 0.1.9 → 0.1.11

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 +54 -53
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,40 +1,41 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var Ns=Object.create;var ut=Object.defineProperty;var Ms=Object.getOwnPropertyDescriptor;var Hs=Object.getOwnPropertyNames;var Ls=Object.getPrototypeOf,Ws=Object.prototype.hasOwnProperty;var B=(n,e)=>()=>(n&&(e=n(n=0)),e);var de=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),pt=(n,e)=>{for(var t in e)ut(n,t,{get:e[t],enumerable:!0})},Vs=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Hs(e))!Ws.call(n,s)&&s!==t&&ut(n,s,{get:()=>e[s],enumerable:!(r=Ms(e,s))||r.enumerable});return n};var N=(n,e,t)=>(t=n!=null?Ns(Ls(n)):{},Vs(e||!n||!n.__esModule?ut(t,"default",{value:n,enumerable:!0}):t,n));var $e=de(dt=>{"use strict";var Fe=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},mt=class extends Fe{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};dt.CommanderError=Fe;dt.InvalidArgumentError=mt});var De=de(ft=>{"use strict";var{InvalidArgumentError:Us}=$e(),ht=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new Us(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Bs(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}ft.Argument=ht;ft.humanReadableArgName=Bs});var bt=de(yt=>{"use strict";var{humanReadableArgName:qs}=De(),gt=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(s=>!s._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((s,i)=>s.name().localeCompare(i.name())),t}compareOptions(e,t){let r=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),r=e._getHelpOption();if(r&&!r.hidden){let s=r.short&&e._findOption(r.short),i=r.long&&e._findOption(r.long);!s&&!i?t.push(r):r.long&&!i?t.push(e.createOption(r.long,r.description)):r.short&&!s&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let s=r.options.filter(i=>!i.hidden);t.push(...s)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>qs(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(s)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(s)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let s=e.parent;s;s=s.parent)r=s.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),s=t.helpWidth??80;function i(p,d){return t.formatItem(p,r,d,t)}let a=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(c),s),""]));let l=t.visibleArguments(e).map(p=>i(t.styleArgumentTerm(t.argumentTerm(p)),t.styleArgumentDescription(t.argumentDescription(p))));l.length>0&&(a=a.concat([t.styleTitle("Arguments:"),...l,""]));let o=t.visibleOptions(e).map(p=>i(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));if(o.length>0&&(a=a.concat([t.styleTitle("Options:"),...o,""])),t.showGlobalOptions){let p=t.visibleGlobalOptions(e).map(d=>i(t.styleOptionTerm(t.optionTerm(d)),t.styleOptionDescription(t.optionDescription(d))));p.length>0&&(a=a.concat([t.styleTitle("Global Options:"),...p,""]))}let u=t.visibleCommands(e).map(p=>i(t.styleSubcommandTerm(t.subcommandTerm(p)),t.styleSubcommandDescription(t.subcommandDescription(p))));return u.length>0&&(a=a.concat([t.styleTitle("Commands:"),...u,""])),a.join(`
3
- `)}displayWidth(e){return or(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,s){let a=" ".repeat(2);if(!r)return a+e;let c=e.padEnd(t+e.length-s.displayWidth(e)),l=2,u=(this.helpWidth??80)-t-l-2,p;return u<this.minWidthToWrap||s.preformatted(r)?p=r:p=s.boxWrap(r,u).replace(/\n/g,`
4
- `+" ".repeat(t+l)),a+c+" ".repeat(l)+p.replace(/\n/g,`
5
- ${a}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,i=[];return r.forEach(a=>{let c=a.match(s);if(c===null){i.push("");return}let l=[c.shift()],o=this.displayWidth(l[0]);c.forEach(u=>{let p=this.displayWidth(u);if(o+p<=t){l.push(u),o+=p;return}i.push(l.join(""));let d=u.trimStart();l=[d],o=this.displayWidth(d)}),i.push(l.join(""))}),i.join(`
6
- `)}};function or(n){let e=/\x1b\[\d*(;\d*)*m/g;return n.replace(e,"")}yt.Help=gt;yt.stripColor=or});var At=de(xt=>{"use strict";var{InvalidArgumentError:Js}=$e(),St=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=Gs(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new Js(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?ar(this.name().replace(/^no-/,"")):ar(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},wt=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let s=this.negativeOptions.get(r).presetArg,i=s!==void 0?s:!1;return t.negate===(i===e)}};function ar(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Gs(n){let e,t,r=/^-[^-]$/,s=/^--[^-]/,i=n.split(/[ |,]+/).concat("guard");if(r.test(i[0])&&(e=i.shift()),s.test(i[0])&&(t=i.shift()),!e&&r.test(i[0])&&(e=i.shift()),!e&&s.test(i[0])&&(e=t,t=i.shift()),i[0].startsWith("-")){let a=i[0],c=`option creation failed due to '${a}' in option flags '${n}'`;throw/^-[^-][^-]/.test(a)?new Error(`${c}
2
+ "use strict";var Qs=Object.create;var bt=Object.defineProperty;var Zs=Object.getOwnPropertyDescriptor;var en=Object.getOwnPropertyNames;var tn=Object.getPrototypeOf,rn=Object.prototype.hasOwnProperty;var X=(n,e)=>()=>(n&&(e=n(n=0)),e);var xe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),St=(n,e)=>{for(var t in e)bt(n,t,{get:e[t],enumerable:!0})},sn=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of en(e))!rn.call(n,s)&&s!==t&&bt(n,s,{get:()=>e[s],enumerable:!(r=Zs(e,s))||r.enumerable});return n};var q=(n,e,t)=>(t=n!=null?Qs(tn(n)):{},sn(e||!n||!n.__esModule?bt(t,"default",{value:n,enumerable:!0}):t,n));var Ne=xe(At=>{"use strict";var Ge=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},wt=class extends Ge{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};At.CommanderError=Ge;At.InvalidArgumentError=wt});var Je=xe(Ct=>{"use strict";var{InvalidArgumentError:nn}=Ne(),xt=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new nn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function on(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}Ct.Argument=xt;Ct.humanReadableArgName=on});var _t=xe(Ot=>{"use strict";var{humanReadableArgName:an}=Je(),kt=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(s=>!s._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((s,i)=>s.name().localeCompare(i.name())),t}compareOptions(e,t){let r=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),r=e._getHelpOption();if(r&&!r.hidden){let s=r.short&&e._findOption(r.short),i=r.long&&e._findOption(r.long);!s&&!i?t.push(r):r.long&&!i?t.push(e.createOption(r.long,r.description)):r.short&&!s&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let s=r.options.filter(i=>!i.hidden);t.push(...s)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>an(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(s)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,s)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(s)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let s=e.parent;s;s=s.parent)r=s.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),s=t.helpWidth??80;function i(u,d){return t.formatItem(u,r,d,t)}let a=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),s),""]));let l=t.visibleArguments(e).map(u=>i(t.styleArgumentTerm(t.argumentTerm(u)),t.styleArgumentDescription(t.argumentDescription(u))));l.length>0&&(a=a.concat([t.styleTitle("Arguments:"),...l,""]));let c=t.visibleOptions(e).map(u=>i(t.styleOptionTerm(t.optionTerm(u)),t.styleOptionDescription(t.optionDescription(u))));if(c.length>0&&(a=a.concat([t.styleTitle("Options:"),...c,""])),t.showGlobalOptions){let u=t.visibleGlobalOptions(e).map(d=>i(t.styleOptionTerm(t.optionTerm(d)),t.styleOptionDescription(t.optionDescription(d))));u.length>0&&(a=a.concat([t.styleTitle("Global Options:"),...u,""]))}let p=t.visibleCommands(e).map(u=>i(t.styleSubcommandTerm(t.subcommandTerm(u)),t.styleSubcommandDescription(t.subcommandDescription(u))));return p.length>0&&(a=a.concat([t.styleTitle("Commands:"),...p,""])),a.join(`
3
+ `)}displayWidth(e){return yr(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,s){let a=" ".repeat(2);if(!r)return a+e;let o=e.padEnd(t+e.length-s.displayWidth(e)),l=2,p=(this.helpWidth??80)-t-l-2,u;return p<this.minWidthToWrap||s.preformatted(r)?u=r:u=s.boxWrap(r,p).replace(/\n/g,`
4
+ `+" ".repeat(t+l)),a+o+" ".repeat(l)+u.replace(/\n/g,`
5
+ ${a}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,i=[];return r.forEach(a=>{let o=a.match(s);if(o===null){i.push("");return}let l=[o.shift()],c=this.displayWidth(l[0]);o.forEach(p=>{let u=this.displayWidth(p);if(c+u<=t){l.push(p),c+=u;return}i.push(l.join(""));let d=p.trimStart();l=[d],c=this.displayWidth(d)}),i.push(l.join(""))}),i.join(`
6
+ `)}};function yr(n){let e=/\x1b\[\d*(;\d*)*m/g;return n.replace(e,"")}Ot.Help=kt;Ot.stripColor=yr});var $t=xe(Pt=>{"use strict";var{InvalidArgumentError:cn}=Ne(),vt=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=ln(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new cn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?br(this.name().replace(/^no-/,"")):br(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Et=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let s=this.negativeOptions.get(r).presetArg,i=s!==void 0?s:!1;return t.negate===(i===e)}};function br(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ln(n){let e,t,r=/^-[^-]$/,s=/^--[^-]/,i=n.split(/[ |,]+/).concat("guard");if(r.test(i[0])&&(e=i.shift()),s.test(i[0])&&(t=i.shift()),!e&&r.test(i[0])&&(e=i.shift()),!e&&s.test(i[0])&&(e=t,t=i.shift()),i[0].startsWith("-")){let a=i[0],o=`option creation failed due to '${a}' in option flags '${n}'`;throw/^-[^-][^-]/.test(a)?new Error(`${o}
7
7
  - a short flag is a single dash and a single character
8
8
  - either use a single dash and a single character (for a short flag)
9
- - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(a)?new Error(`${c}
10
- - too many short flags`):s.test(a)?new Error(`${c}
11
- - too many long flags`):new Error(`${c}
12
- - unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:e,longFlag:t}}xt.Option=St;xt.DualOptions=wt});var cr=de(lr=>{"use strict";function Ys(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let r=0;r<=n.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=n.length;s++){let i=1;n[s-1]===e[r-1]?i=0:i=1,t[s][r]=Math.min(t[s-1][r]+1,t[s][r-1]+1,t[s-1][r-1]+i),s>1&&r>1&&n[s-1]===e[r-2]&&n[s-2]===e[r-1]&&(t[s][r]=Math.min(t[s][r],t[s-2][r-2]+1))}return t[n.length][e.length]}function Ks(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(a=>a.slice(2)));let r=[],s=3,i=.4;return e.forEach(a=>{if(a.length<=1)return;let c=Ys(n,a),l=Math.max(n.length,a.length);(l-c)/l>i&&(c<s?(s=c,r=[a]):c===s&&r.push(a))}),r.sort((a,c)=>a.localeCompare(c)),t&&(r=r.map(a=>`--${a}`)),r.length>1?`
9
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(a)?new Error(`${o}
10
+ - too many short flags`):s.test(a)?new Error(`${o}
11
+ - too many long flags`):new Error(`${o}
12
+ - unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:e,longFlag:t}}Pt.Option=vt;Pt.DualOptions=Et});var wr=xe(Sr=>{"use strict";function un(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let r=0;r<=n.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=n.length;s++){let i=1;n[s-1]===e[r-1]?i=0:i=1,t[s][r]=Math.min(t[s-1][r]+1,t[s][r-1]+1,t[s-1][r-1]+i),s>1&&r>1&&n[s-1]===e[r-2]&&n[s-2]===e[r-1]&&(t[s][r]=Math.min(t[s][r],t[s-2][r-2]+1))}return t[n.length][e.length]}function pn(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(a=>a.slice(2)));let r=[],s=3,i=.4;return e.forEach(a=>{if(a.length<=1)return;let o=un(n,a),l=Math.max(n.length,a.length);(l-o)/l>i&&(o<s?(s=o,r=[a]):o===s&&r.push(a))}),r.sort((a,o)=>a.localeCompare(o)),t&&(r=r.map(a=>`--${a}`)),r.length>1?`
13
13
  (Did you mean one of ${r.join(", ")}?)`:r.length===1?`
14
- (Did you mean ${r[0]}?)`:""}lr.suggestSimilar=Ks});var dr=de(vt=>{"use strict";var zs=require("events").EventEmitter,Ct=require("child_process"),oe=require("path"),Ne=require("fs"),O=require("process"),{Argument:Xs,humanReadableArgName:Qs}=De(),{CommanderError:Ot}=$e(),{Help:Zs,stripColor:en}=bt(),{Option:ur,DualOptions:tn}=At(),{suggestSimilar:pr}=cr(),_t=class n extends zs{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>O.stdout.write(t),writeErr:t=>O.stderr.write(t),outputError:(t,r)=>r(t),getOutHelpWidth:()=>O.stdout.isTTY?O.stdout.columns:void 0,getErrHelpWidth:()=>O.stderr.isTTY?O.stderr.columns:void 0,getOutHasColors:()=>kt()??(O.stdout.isTTY&&O.stdout.hasColors?.()),getErrHasColors:()=>kt()??(O.stderr.isTTY&&O.stderr.hasColors?.()),stripColor:t=>en(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let s=t,i=r;typeof s=="object"&&s!==null&&(i=s,s=null),i=i||{};let[,a,c]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(a);return s&&(l.description(s),l._executableHandler=!0),i.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(i.noHelp||i.hidden),l._executableFile=i.executableFile||null,c&&l.arguments(c),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),s?this:l}createCommand(e){return new n(e)}createHelp(){return Object.assign(new Zs,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
15
- - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Xs(e,t)}argument(e,t,r,s){let i=this.createArgument(e,t);return typeof r=="function"?i.default(s).argParser(r):i.default(r),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,r,s]=e.match(/([^ ]+) *(.*)/),i=t??"display help for command",a=this.createCommand(r);return a.helpOption(!1),s&&a.arguments(s),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
16
- Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new Ot(e,t,r)),O.exit(e)}action(e){let t=r=>{let s=this.registeredArguments.length,i=r.slice(0,s);return this._storeOptionsAsProperties?i[s]=this:i[s]=this.opts(),i.push(this),e.apply(this,i)};return this._actionHandler=t,this}createOption(e,t){return new ur(e,t)}_callParseArg(e,t,r,s){try{return e.parseArg(t,r)}catch(i){if(i.code==="commander.invalidArgument"){let a=`${s} ${i.message}`;this.error(a,{exitCode:i.exitCode,code:i.code})}throw i}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
17
- - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),r=t(e).find(s=>this._findCommand(s));if(r){let s=t(this._findCommand(r)).join("|"),i=t(e).join("|");throw new Error(`cannot add command '${i}' as already have command '${s}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let i=e.long.replace(/^--no-/,"--");this._findOption(i)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let s=(i,a,c)=>{i==null&&e.presetArg!==void 0&&(i=e.presetArg);let l=this.getOptionValue(r);i!==null&&e.parseArg?i=this._callParseArg(e,i,l,a):i!==null&&e.variadic&&(i=e._concatValue(i,l)),i==null&&(e.negate?i=!1:e.isBoolean()||e.optional?i=!0:i=""),this.setOptionValueWithSource(r,i,c)};return this.on("option:"+t,i=>{let a=`error: option '${e.flags}' argument '${i}' is invalid.`;s(i,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,i=>{let a=`error: option '${e.flags}' value '${i}' from env '${e.envVar}' is invalid.`;s(i,a,"env")}),this}_optionEx(e,t,r,s,i){if(typeof t=="object"&&t instanceof ur)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,r);if(a.makeOptionMandatory(!!e.mandatory),typeof s=="function")a.default(i).argParser(s);else if(s instanceof RegExp){let c=s;s=(l,o)=>{let u=c.exec(l);return u?u[0]:o},a.default(i).argParser(s)}else a.default(s);return this.addOption(a)}option(e,t,r,s){return this._optionEx({},e,t,r,s)}requiredOption(e,t,r,s){return this._optionEx({mandatory:!0},e,t,r,s)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){O.versions?.electron&&(t.from="electron");let s=O.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(t.from="eval")}e===void 0&&(e=O.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":O.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
- - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,r){if(Ne.existsSync(e))return;let s=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${e}' does not exist
14
+ (Did you mean ${r[0]}?)`:""}Sr.suggestSimilar=pn});var kr=xe(Ft=>{"use strict";var mn=require("events").EventEmitter,Rt=require("child_process"),me=require("path"),Ye=require("fs"),k=require("process"),{Argument:dn,humanReadableArgName:hn}=Je(),{CommanderError:Tt}=Ne(),{Help:fn,stripColor:gn}=_t(),{Option:Ar,DualOptions:yn}=$t(),{suggestSimilar:xr}=wr(),It=class n extends mn{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>k.stdout.write(t),writeErr:t=>k.stderr.write(t),outputError:(t,r)=>r(t),getOutHelpWidth:()=>k.stdout.isTTY?k.stdout.columns:void 0,getErrHelpWidth:()=>k.stderr.isTTY?k.stderr.columns:void 0,getOutHasColors:()=>jt()??(k.stdout.isTTY&&k.stdout.hasColors?.()),getErrHasColors:()=>jt()??(k.stderr.isTTY&&k.stderr.hasColors?.()),stripColor:t=>gn(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let s=t,i=r;typeof s=="object"&&s!==null&&(i=s,s=null),i=i||{};let[,a,o]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(a);return s&&(l.description(s),l._executableHandler=!0),i.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(i.noHelp||i.hidden),l._executableFile=i.executableFile||null,o&&l.arguments(o),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),s?this:l}createCommand(e){return new n(e)}createHelp(){return Object.assign(new fn,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new dn(e,t)}argument(e,t,r,s){let i=this.createArgument(e,t);return typeof r=="function"?i.default(s).argParser(r):i.default(r),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,r,s]=e.match(/([^ ]+) *(.*)/),i=t??"display help for command",a=this.createCommand(r);return a.helpOption(!1),s&&a.arguments(s),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
16
+ Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new Tt(e,t,r)),k.exit(e)}action(e){let t=r=>{let s=this.registeredArguments.length,i=r.slice(0,s);return this._storeOptionsAsProperties?i[s]=this:i[s]=this.opts(),i.push(this),e.apply(this,i)};return this._actionHandler=t,this}createOption(e,t){return new Ar(e,t)}_callParseArg(e,t,r,s){try{return e.parseArg(t,r)}catch(i){if(i.code==="commander.invalidArgument"){let a=`${s} ${i.message}`;this.error(a,{exitCode:i.exitCode,code:i.code})}throw i}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
17
+ - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),r=t(e).find(s=>this._findCommand(s));if(r){let s=t(this._findCommand(r)).join("|"),i=t(e).join("|");throw new Error(`cannot add command '${i}' as already have command '${s}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let i=e.long.replace(/^--no-/,"--");this._findOption(i)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let s=(i,a,o)=>{i==null&&e.presetArg!==void 0&&(i=e.presetArg);let l=this.getOptionValue(r);i!==null&&e.parseArg?i=this._callParseArg(e,i,l,a):i!==null&&e.variadic&&(i=e._concatValue(i,l)),i==null&&(e.negate?i=!1:e.isBoolean()||e.optional?i=!0:i=""),this.setOptionValueWithSource(r,i,o)};return this.on("option:"+t,i=>{let a=`error: option '${e.flags}' argument '${i}' is invalid.`;s(i,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,i=>{let a=`error: option '${e.flags}' value '${i}' from env '${e.envVar}' is invalid.`;s(i,a,"env")}),this}_optionEx(e,t,r,s,i){if(typeof t=="object"&&t instanceof Ar)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,r);if(a.makeOptionMandatory(!!e.mandatory),typeof s=="function")a.default(i).argParser(s);else if(s instanceof RegExp){let o=s;s=(l,c)=>{let p=o.exec(l);return p?p[0]:c},a.default(i).argParser(s)}else a.default(s);return this.addOption(a)}option(e,t,r,s){return this._optionEx({},e,t,r,s)}requiredOption(e,t,r,s){return this._optionEx({mandatory:!0},e,t,r,s)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){k.versions?.electron&&(t.from="electron");let s=k.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(t.from="eval")}e===void 0&&(e=k.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":k.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,r){if(Ye.existsSync(e))return;let s=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${e}' does not exist
19
19
  - if '${r}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
20
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
- - ${s}`;throw new Error(i)}_executeSubCommand(e,t){t=t.slice();let r=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function i(u,p){let d=oe.resolve(u,p);if(Ne.existsSync(d))return d;if(s.includes(oe.extname(p)))return;let b=s.find(f=>Ne.existsSync(`${d}${f}`));if(b)return`${d}${b}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let u;try{u=Ne.realpathSync(this._scriptPath)}catch{u=this._scriptPath}c=oe.resolve(oe.dirname(u),c)}if(c){let u=i(c,a);if(!u&&!e._executableFile&&this._scriptPath){let p=oe.basename(this._scriptPath,oe.extname(this._scriptPath));p!==this._name&&(u=i(c,`${p}-${e._name}`))}a=u||a}r=s.includes(oe.extname(a));let l;O.platform!=="win32"?r?(t.unshift(a),t=mr(O.execArgv).concat(t),l=Ct.spawn(O.argv[0],t,{stdio:"inherit"})):l=Ct.spawn(a,t,{stdio:"inherit"}):(this._checkForMissingExecutable(a,c,e._name),t.unshift(a),t=mr(O.execArgv).concat(t),l=Ct.spawn(O.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{O.on(p,()=>{l.killed===!1&&l.exitCode===null&&l.kill(p)})});let o=this._exitCallback;l.on("close",u=>{u=u??1,o?o(new Ot(u,"commander.executeSubCommandAsync","(close)")):O.exit(u)}),l.on("error",u=>{if(u.code==="ENOENT")this._checkForMissingExecutable(a,c,e._name);else if(u.code==="EACCES")throw new Error(`'${a}' not executable`);if(!o)O.exit(1);else{let p=new Ot(1,"commander.executeSubCommandAsync","(error)");p.nestedError=u,o(p)}}),this.runningCommand=l}_dispatchSubcommand(e,t,r){let s=this._findCommand(e);s||this.help({error:!0}),s._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,s,"preSubcommand"),i=this._chainOrCall(i,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(r));else return s._parseCommand(t,r)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,s,i)=>{let a=s;if(s!==null&&r.parseArg){let c=`error: command-argument value '${s}' is invalid for argument '${r.name()}'.`;a=this._callParseArg(r,s,i,c)}return a};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,s)=>{let i=r.defaultValue;r.variadic?s<this.args.length?(i=this.args.slice(s),r.parseArg&&(i=i.reduce((a,c)=>e(r,c,a),r.defaultValue))):i===void 0&&(i=[]):s<this.args.length&&(i=this.args[s],r.parseArg&&(i=e(r,i,r.defaultValue))),t[s]=i}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,s=[];return this._getCommandAndAncestors().reverse().filter(i=>i._lifeCycleHooks[t]!==void 0).forEach(i=>{i._lifeCycleHooks[t].forEach(a=>{s.push({hookedCommand:i,callback:a})})}),t==="postAction"&&s.reverse(),s.forEach(i=>{r=this._chainOrCall(r,()=>i.callback(i.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let s=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(i=>{s=this._chainOrCall(s,()=>i(this,t))}),s}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let a;return a=this._chainOrCallHooks(a,"preAction"),a=this._chainOrCall(a,()=>this._actionHandler(this.processedArgs)),this.parent&&(a=this._chainOrCall(a,()=>{this.parent.emit(i,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent&&this.parent.listenerCount(i))s(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let s=r.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let s=e.find(i=>r.conflictsWith.includes(i.attributeName()));s&&this._conflictingOption(r,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],s=t,i=e.slice();function a(l){return l.length>1&&l[0]==="-"}let c=null;for(;i.length;){let l=i.shift();if(l==="--"){s===r&&s.push(l),s.push(...i);break}if(c&&!a(l)){this.emit(`option:${c.name()}`,l);continue}if(c=null,a(l)){let o=this._findOption(l);if(o){if(o.required){let u=i.shift();u===void 0&&this.optionMissingArgument(o),this.emit(`option:${o.name()}`,u)}else if(o.optional){let u=null;i.length>0&&!a(i[0])&&(u=i.shift()),this.emit(`option:${o.name()}`,u)}else this.emit(`option:${o.name()}`);c=o.variadic?o:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let o=this._findOption(`-${l[1]}`);if(o){o.required||o.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${o.name()}`,l.slice(2)):(this.emit(`option:${o.name()}`),i.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let o=l.indexOf("="),u=this._findOption(l.slice(0,o));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,l.slice(o+1));continue}}if(a(l)&&(s=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(l)){t.push(l),i.length>0&&r.push(...i);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),i.length>0&&t.push(...i);break}else if(this._defaultCommandName){r.push(l),i.length>0&&r.push(...i);break}}if(this._passThroughOptions){s.push(l),i.length>0&&s.push(...i);break}s.push(l)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let s=this.options[r].attributeName();e[s]=s===this._versionOptionName?this._version:this[s]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
21
+ - ${s}`;throw new Error(i)}_executeSubCommand(e,t){t=t.slice();let r=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function i(p,u){let d=me.resolve(p,u);if(Ye.existsSync(d))return d;if(s.includes(me.extname(u)))return;let b=s.find(g=>Ye.existsSync(`${d}${g}`));if(b)return`${d}${b}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||"";if(this._scriptPath){let p;try{p=Ye.realpathSync(this._scriptPath)}catch{p=this._scriptPath}o=me.resolve(me.dirname(p),o)}if(o){let p=i(o,a);if(!p&&!e._executableFile&&this._scriptPath){let u=me.basename(this._scriptPath,me.extname(this._scriptPath));u!==this._name&&(p=i(o,`${u}-${e._name}`))}a=p||a}r=s.includes(me.extname(a));let l;k.platform!=="win32"?r?(t.unshift(a),t=Cr(k.execArgv).concat(t),l=Rt.spawn(k.argv[0],t,{stdio:"inherit"})):l=Rt.spawn(a,t,{stdio:"inherit"}):(this._checkForMissingExecutable(a,o,e._name),t.unshift(a),t=Cr(k.execArgv).concat(t),l=Rt.spawn(k.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{k.on(u,()=>{l.killed===!1&&l.exitCode===null&&l.kill(u)})});let c=this._exitCallback;l.on("close",p=>{p=p??1,c?c(new Tt(p,"commander.executeSubCommandAsync","(close)")):k.exit(p)}),l.on("error",p=>{if(p.code==="ENOENT")this._checkForMissingExecutable(a,o,e._name);else if(p.code==="EACCES")throw new Error(`'${a}' not executable`);if(!c)k.exit(1);else{let u=new Tt(1,"commander.executeSubCommandAsync","(error)");u.nestedError=p,c(u)}}),this.runningCommand=l}_dispatchSubcommand(e,t,r){let s=this._findCommand(e);s||this.help({error:!0}),s._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,s,"preSubcommand"),i=this._chainOrCall(i,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(r));else return s._parseCommand(t,r)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,s,i)=>{let a=s;if(s!==null&&r.parseArg){let o=`error: command-argument value '${s}' is invalid for argument '${r.name()}'.`;a=this._callParseArg(r,s,i,o)}return a};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,s)=>{let i=r.defaultValue;r.variadic?s<this.args.length?(i=this.args.slice(s),r.parseArg&&(i=i.reduce((a,o)=>e(r,o,a),r.defaultValue))):i===void 0&&(i=[]):s<this.args.length&&(i=this.args[s],r.parseArg&&(i=e(r,i,r.defaultValue))),t[s]=i}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,s=[];return this._getCommandAndAncestors().reverse().filter(i=>i._lifeCycleHooks[t]!==void 0).forEach(i=>{i._lifeCycleHooks[t].forEach(a=>{s.push({hookedCommand:i,callback:a})})}),t==="postAction"&&s.reverse(),s.forEach(i=>{r=this._chainOrCall(r,()=>i.callback(i.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let s=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(i=>{s=this._chainOrCall(s,()=>i(this,t))}),s}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let a;return a=this._chainOrCallHooks(a,"preAction"),a=this._chainOrCall(a,()=>this._actionHandler(this.processedArgs)),this.parent&&(a=this._chainOrCall(a,()=>{this.parent.emit(i,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent&&this.parent.listenerCount(i))s(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let s=r.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let s=e.find(i=>r.conflictsWith.includes(i.attributeName()));s&&this._conflictingOption(r,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],s=t,i=e.slice();function a(l){return l.length>1&&l[0]==="-"}let o=null;for(;i.length;){let l=i.shift();if(l==="--"){s===r&&s.push(l),s.push(...i);break}if(o&&!a(l)){this.emit(`option:${o.name()}`,l);continue}if(o=null,a(l)){let c=this._findOption(l);if(c){if(c.required){let p=i.shift();p===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,p)}else if(c.optional){let p=null;i.length>0&&!a(i[0])&&(p=i.shift()),this.emit(`option:${c.name()}`,p)}else this.emit(`option:${c.name()}`);o=c.variadic?c:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let c=this._findOption(`-${l[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,l.slice(2)):(this.emit(`option:${c.name()}`),i.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let c=l.indexOf("="),p=this._findOption(l.slice(0,c));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,l.slice(c+1));continue}}if(a(l)&&(s=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(l)){t.push(l),i.length>0&&r.push(...i);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),i.length>0&&t.push(...i);break}else if(this._defaultCommandName){r.push(l),i.length>0&&r.push(...i);break}}if(this._passThroughOptions){s.push(l),i.length>0&&s.push(...i);break}s.push(l)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let s=this.options[r].attributeName();e[s]=s===this._versionOptionName?this._version:this[s]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
22
22
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
23
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
24
- `),this.outputHelp({error:!0}));let r=t||{},s=r.exitCode||1,i=r.code||"commander.error";this._exit(s,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in O.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,O.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new tn(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(s=>!t(s)).forEach(s=>{this.setOptionValueWithSource(s,r.implied[s],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=a=>{let c=a.attributeName(),l=this.getOptionValue(c),o=this.options.find(p=>p.negate&&c===p.attributeName()),u=this.options.find(p=>!p.negate&&c===p.attributeName());return o&&(o.presetArg===void 0&&l===!1||o.presetArg!==void 0&&l===o.presetArg)?o:u||a},s=a=>{let c=r(a),l=c.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${c.envVar}'`:`option '${c.flags}'`},i=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],i=this;do{let a=i.createHelp().visibleOptions(i).filter(c=>c.long).map(c=>c.long);s=s.concat(a),i=i.parent}while(i&&!i._enablePositionalOptions);t=pr(e,s)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(i=>{s.push(i.name()),i.alias()&&s.push(i.alias())}),t=pr(e,s)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let s=this.createOption(t,r);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${e}
25
- `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let s=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r=>Qs(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=oe.basename(e,oe.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});let s=t.formatHelp(this,t);return r.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(e){e=e||{};let t=!!e.error,r,s,i;return t?(r=c=>this._outputConfiguration.writeErr(c),s=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(r=c=>this._outputConfiguration.writeOut(c),s=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:c=>(s||(c=this._outputConfiguration.stripColor(c)),r(c)),hasColors:s,helpWidth:i}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getOutputContext(e),s={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let i=this.helpInformation({error:r.error});if(t&&(i=t(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(a=>a.emit("afterAllHelp",s))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=Number(O.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
24
+ `),this.outputHelp({error:!0}));let r=t||{},s=r.exitCode||1,i=r.code||"commander.error";this._exit(s,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in k.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,k.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new yn(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(s=>!t(s)).forEach(s=>{this.setOptionValueWithSource(s,r.implied[s],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=a=>{let o=a.attributeName(),l=this.getOptionValue(o),c=this.options.find(u=>u.negate&&o===u.attributeName()),p=this.options.find(u=>!u.negate&&o===u.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:p||a},s=a=>{let o=r(a),l=o.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${o.envVar}'`:`option '${o.flags}'`},i=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],i=this;do{let a=i.createHelp().visibleOptions(i).filter(o=>o.long).map(o=>o.long);s=s.concat(a),i=i.parent}while(i&&!i._enablePositionalOptions);t=xr(e,s)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(i=>{s.push(i.name()),i.alias()&&s.push(i.alias())}),t=xr(e,s)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let s=this.createOption(t,r);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${e}
25
+ `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let s=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r=>hn(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=me.basename(e,me.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});let s=t.formatHelp(this,t);return r.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(e){e=e||{};let t=!!e.error,r,s,i;return t?(r=o=>this._outputConfiguration.writeErr(o),s=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(r=o=>this._outputConfiguration.writeOut(o),s=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:o=>(s||(o=this._outputConfiguration.stripColor(o)),r(o)),hasColors:s,helpWidth:i}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getOutputContext(e),s={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let i=this.helpInformation({error:r.error});if(t&&(i=t(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(a=>a.emit("afterAllHelp",s))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=Number(k.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
26
26
  Expecting one of '${r.join("', '")}'`);let s=`${e}Help`;return this.on(s,i=>{let a;typeof t=="function"?a=t({error:i.error,command:i.command}):a=t,a&&i.write(`${a}
27
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function mr(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",s="9229",i;return(i=e.match(/^(--inspect(-brk)?)$/))!==null?t=i[1]:(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=i[1],/^\d+$/.test(i[3])?s=i[3]:r=i[3]):(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],r=i[3],s=i[4]),t&&s!=="0"?`${t}=${r}:${parseInt(s)+1}`:e})}function kt(){if(O.env.NO_COLOR||O.env.FORCE_COLOR==="0"||O.env.FORCE_COLOR==="false")return!1;if(O.env.FORCE_COLOR||O.env.CLICOLOR_FORCE!==void 0)return!0}vt.Command=_t;vt.useColor=kt});var yr=de(Y=>{"use strict";var{Argument:hr}=De(),{Command:Et}=dr(),{CommanderError:rn,InvalidArgumentError:fr}=$e(),{Help:sn}=bt(),{Option:gr}=At();Y.program=new Et;Y.createCommand=n=>new Et(n);Y.createOption=(n,e)=>new gr(n,e);Y.createArgument=(n,e)=>new hr(n,e);Y.Command=Et;Y.Option=gr;Y.Argument=hr;Y.Help=sn;Y.CommanderError=rn;Y.InvalidArgumentError=fr;Y.InvalidOptionArgumentError=fr});var $r={};pt($r,{addToManifest:()=>X,clearAuth:()=>Rt,getAuth:()=>ee,getConfig:()=>le,getManifest:()=>V,getSyncState:()=>We,removeFromManifest:()=>Le,saveAuth:()=>Pt,saveConfig:()=>vr,saveManifest:()=>Tt,saveSyncState:()=>Re,shouldSync:()=>It,updateConfig:()=>an});function Pe(){let n=process.env.SC_PROFILE;return n?(0,he.join)(Cr,"profiles",n):Cr}function $t(){return(0,he.join)(Pe(),"auth.json")}function _r(){return(0,he.join)(Pe(),"config.json")}function kr(){return(0,he.join)(Pe(),"manifest.json")}function nn(){(0,z.mkdirSync)(Pe(),{recursive:!0})}function Me(n,e){try{return(0,z.existsSync)(n)?JSON.parse((0,z.readFileSync)(n,"utf-8")):e}catch{return e}}function He(n,e,t=!1){if(nn(),(0,z.writeFileSync)(n,JSON.stringify(e,null,2)+`
28
- `,"utf-8"),t)try{(0,z.chmodSync)(n,384)}catch{}}function ee(){return Me($t(),null)}function Pt(n){He($t(),n,!0)}function Rt(){try{(0,z.writeFileSync)($t(),"{}","utf-8")}catch{}}function le(){return Me(_r(),on)}function vr(n){He(_r(),n)}function an(n){let e=le();vr({...e,...n})}function V(){return Me(kr(),ln)}function Tt(n){He(kr(),n)}function X(n){let e=V(),t=e.installations.findIndex(r=>r.resourceId===n.resourceId&&r.agent===n.agent);t>=0?e.installations[t]=n:e.installations.push(n),Tt(e)}function Le(n,e){let t=V();t.installations=t.installations.filter(r=>!(r.resourceId===n&&(!e||r.agent===e))),Tt(t)}function Er(){return(0,he.join)(Pe(),"last-sync.json")}function We(){return Me(Er(),null)}function Re(n){He(Er(),n)}function It(n=cn){let e=We();return e?.lastSyncAt?Date.now()-new Date(e.lastSyncAt).getTime()>=n:!0}var z,he,Or,Cr,on,ln,cn,q=B(()=>{"use strict";z=require("fs"),he=require("path"),Or=require("os"),Cr=(0,he.join)((0,Or.homedir)(),".config","shared-context");on={apiBase:"https://sharedcontext.ai"};ln={installations:[]};cn=720*60*1e3});var Pr={};pt(Pr,{del:()=>jt,get:()=>I,isAuthenticated:()=>E,patch:()=>mn,post:()=>P});function un(){return le().apiBase||"https://sharedcontext.ai"}function pn(){let n={"Content-Type":"application/json"},e=ee();return e?.token&&(n.Authorization=`Bearer ${e.token}`),n}function E(){return!!ee()?.token}async function Ve(n,e,t,r){let s=`${un()}${e}`;try{let i={method:n,headers:pn(),body:t?JSON.stringify(t):void 0};r&&(i.signal=AbortSignal.timeout(r));let a=await fetch(s,i),c=a.headers.get("content-type")||"";if(!c.includes("application/json"))return a.ok?{ok:!1,error:{code:"INVALID_RESPONSE",message:`Expected JSON, got ${c||"unknown content type"}`}}:{ok:!1,error:{code:`HTTP_${a.status}`,message:a.statusText}};let l=await a.json();return a.ok?{ok:!0,data:l.data??l}:{ok:!1,error:{code:l?.error?.code||`HTTP_${a.status}`,message:l?.error?.message||l?.message||a.statusText}}}catch(i){return{ok:!1,error:{code:"NETWORK_ERROR",message:i instanceof Error?i.message:"Network request failed"}}}}function I(n){return Ve("GET",n)}function P(n,e,t){return Ve("POST",n,e,t)}function mn(n,e){return Ve("PATCH",n,e)}function jt(n,e){return Ve("DELETE",n,e)}var U=B(()=>{"use strict";q()});function Dn(){try{return Lt.default.statSync("/.dockerenv"),!0}catch{return!1}}function Nn(){try{return Lt.default.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function Wt(){return Ht===void 0&&(Ht=Dn()||Nn()),Ht}var Lt,Ht,Hr=B(()=>{"use strict";Lt=N(require("fs"),1)});function ye(){return Vt===void 0&&(Vt=Mn()||Wt()),Vt}var Lr,Vt,Mn,Ut=B(()=>{"use strict";Lr=N(require("fs"),1);Hr();Mn=()=>{try{return Lr.default.statSync("/run/.containerenv"),!0}catch{return!1}}});var Bt,Vr,rt,Wr,ue,qt=B(()=>{"use strict";Bt=N(require("process"),1),Vr=N(require("os"),1),rt=N(require("fs"),1);Ut();Wr=()=>{if(Bt.default.platform!=="linux")return!1;if(Vr.default.release().toLowerCase().includes("microsoft"))return!ye();try{if(rt.default.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!ye()}catch{}return rt.default.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||rt.default.existsSync("/run/WSL")?!ye():!1},ue=Bt.default.env.__IS_WSL_TEST__?Wr:Wr()});var Jt,Ie,Hn,Ln,Gt,Ur=B(()=>{"use strict";Jt=N(require("process"),1),Ie=N(require("fs/promises"),1);qt();qt();Hn=(()=>{let n="/mnt/",e;return async function(){if(e)return e;let t="/etc/wsl.conf",r=!1;try{await Ie.default.access(t,Ie.constants.F_OK),r=!0}catch{}if(!r)return n;let s=await Ie.default.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(s);return i?(e=i.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):n}})(),Ln=async()=>`${await Hn()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Gt=async()=>ue?Ln():`${Jt.default.env.SYSTEMROOT||Jt.default.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`});function pe(n,e,t){let r=s=>Object.defineProperty(n,e,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get(){let s=t();return r(s),s},set(s){r(s)}}),n}var Br=B(()=>{"use strict"});async function Yt(){if(Jr.default.platform!=="darwin")throw new Error("macOS only");let{stdout:n}=await Wn("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(n)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}var qr,Jr,Gr,Wn,Yr=B(()=>{"use strict";qr=require("util"),Jr=N(require("process"),1),Gr=require("child_process"),Wn=(0,qr.promisify)(Gr.execFile)});async function Xr(n,{humanReadableOutput:e=!0,signal:t}={}){if(Kr.default.platform!=="darwin")throw new Error("macOS only");let r=e?[]:["-ss"],s={};t&&(s.signal=t);let{stdout:i}=await Vn("osascript",["-e",n,r],s);return i.trim()}var Kr,zr,Kt,Vn,Qr=B(()=>{"use strict";Kr=N(require("process"),1),zr=require("util"),Kt=require("child_process"),Vn=(0,zr.promisify)(Kt.execFile)});async function zt(n){return Xr(`tell application "Finder" to set app_path to application file id "${n}" as string
29
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var Zr=B(()=>{"use strict";Qr()});async function Qt(n=Un){let{stdout:e}=await n("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(e);if(!t)throw new Xt(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:r}=t.groups,s=r.lastIndexOf("."),i=r.lastIndexOf("-"),a=s===-1?void 0:r.slice(0,s),c=i===-1?void 0:r.slice(0,i);return st[r]??st[a]??st[c]??{name:r,id:r}}var es,ts,Un,st,Ao,Xt,rs=B(()=>{"use strict";es=require("util"),ts=require("child_process"),Un=(0,es.promisify)(ts.execFile),st={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},Ao=new Map(Object.entries(st)),Xt=class extends Error{}});async function Zt(){if(nt.default.platform==="darwin"){let n=await Yt();return{name:await zt(n),id:n}}if(nt.default.platform==="linux"){let{stdout:n}=await Bn("xdg-mime",["query","default","x-scheme-handler/http"]),e=n.trim();return{name:qn(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(nt.default.platform==="win32")return Qt();throw new Error("Only macOS, Linux, and Windows are supported")}var ss,nt,ns,Bn,qn,is=B(()=>{"use strict";ss=require("util"),nt=N(require("process"),1),ns=require("child_process");Yr();Zr();rs();Bn=(0,ss.promisify)(ns.execFile),qn=n=>n.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())});var ms={};pt(ms,{apps:()=>me,default:()=>zn,openApp:()=>Kn});async function Gn(){let n=await Gt(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=rr.Buffer.from(e,"utf16le").toString("base64"),{stdout:r}=await Jn(n,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),s=r.trim(),i={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return i[s]?{id:i[s]}:{}}function cs(n){if(typeof n=="string"||Array.isArray(n))return n;let{[as]:e}=n;if(!e)throw new Error(`${as} is not supported`);return e}function ot({[ve]:n},{wsl:e}){if(e&&ue)return cs(e);if(!n)throw new Error(`${ve} is not supported`);return cs(n)}var tr,rr,sr,us,ps,nr,it,Xn,Jn,er,os,ve,as,ls,je,Yn,Kn,me,zn,ds=B(()=>{"use strict";tr=N(require("process"),1),rr=require("buffer"),sr=N(require("path"),1),us=require("url"),ps=require("util"),nr=N(require("child_process"),1),it=N(require("fs/promises"),1);Ur();Br();is();Ut();Xn={},Jn=(0,ps.promisify)(nr.default.execFile),er=sr.default.dirname((0,us.fileURLToPath)(Xn.url)),os=sr.default.join(er,"xdg-open"),{platform:ve,arch:as}=tr.default;ls=async(n,e)=>{let t;for(let r of n)try{return await e(r)}catch(s){t=s}throw t},je=async n=>{if(n={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...n},Array.isArray(n.app))return ls(n.app,c=>je({...n,app:c}));let{name:e,arguments:t=[]}=n.app??{};if(t=[...t],Array.isArray(e))return ls(e,c=>je({...n,app:{name:c,arguments:t}}));if(e==="browser"||e==="browserPrivate"){let c={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},l={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},o=ue?await Gn():await Zt();if(o.id in c){let u=c[o.id];return e==="browserPrivate"&&t.push(l[u]),je({...n,app:{name:me[u],arguments:t}})}throw new Error(`${o.name} is not supported as a default browser`)}let r,s=[],i={};if(ve==="darwin")r="open",n.wait&&s.push("--wait-apps"),n.background&&s.push("--background"),n.newInstance&&s.push("--new"),e&&s.push("-a",e);else if(ve==="win32"||ue&&!ye()&&!e){r=await Gt(),s.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),ue||(i.windowsVerbatimArguments=!0);let c=["Start"];n.wait&&c.push("-Wait"),e?(c.push(`"\`"${e}\`""`),n.target&&t.push(n.target)):n.target&&c.push(`"${n.target}"`),t.length>0&&(t=t.map(l=>`"\`"${l}\`""`),c.push("-ArgumentList",t.join(","))),n.target=rr.Buffer.from(c.join(" "),"utf16le").toString("base64")}else{if(e)r=e;else{let c=!er||er==="/",l=!1;try{await it.default.access(os,it.constants.X_OK),l=!0}catch{}r=tr.default.versions.electron??(ve==="android"||c||!l)?"xdg-open":os}t.length>0&&s.push(...t),n.wait||(i.stdio="ignore",i.detached=!0)}ve==="darwin"&&t.length>0&&s.push("--args",...t),n.target&&s.push(n.target);let a=nr.default.spawn(r,s,i);return n.wait?new Promise((c,l)=>{a.once("error",l),a.once("close",o=>{if(!n.allowNonzeroExitCode&&o>0){l(new Error(`Exited with code ${o}`));return}c(a)})}):(a.unref(),a)},Yn=(n,e)=>{if(typeof n!="string")throw new TypeError("Expected a `target`");return je({...e,target:n})},Kn=(n,e)=>{if(typeof n!="string"&&!Array.isArray(n))throw new TypeError("Expected a valid `name`");let{arguments:t=[]}=e??{};if(t!=null&&!Array.isArray(t))throw new TypeError("Expected `appArguments` as Array type");return je({...e,app:{name:n,arguments:t}})};me={};pe(me,"chrome",()=>ot({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));pe(me,"brave",()=>ot({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));pe(me,"firefox",()=>ot({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));pe(me,"edge",()=>ot({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));pe(me,"browser",()=>"browser");pe(me,"browserPrivate",()=>"browserPrivate");zn=Yn});var br=N(yr(),1),{program:ci,createCommand:ui,createArgument:pi,createOption:mi,CommanderError:di,InvalidArgumentError:hi,InvalidOptionArgumentError:fi,Command:Sr,Argument:gi,Option:yi,Help:bi}=br.default;var wr=!1,xr=!1;function Ar(n,e){wr=n,xr=e}function g(){return wr?!0:xr?!1:!process.stdout.isTTY}function _(n,e){console.log(JSON.stringify({ok:!0,command:n,data:e}))}function w(n,e,t){console.log(JSON.stringify({ok:!1,command:n,errors:[{code:e,message:t}]}))}function m(n){console.log(n)}function S(n){console.error(n)}function K(n,e=2){if(n.length===0)return"";let t=[];for(let r of n)for(let s=0;s<r.length;s++)t[s]=Math.max(t[s]||0,r[s].length);return n.map(r=>r.map((s,i)=>i<r.length-1?s.padEnd(t[i]+e):s).join("")).join(`
30
- `)}var tt=require("fs"),Te=require("path"),Nr=require("os");q();U();var Ft=require("fs"),J=require("path"),ce=require("os"),we=[{id:"claude-code",label:"Claude Code",envVars:["CLAUDE_CODE"],dir:".claude",skillsSubdir:"skills",platform:"claude_code"},{id:"cursor",label:"Cursor",envVars:["CURSOR","CURSOR_TRACE_ID"],dir:".cursor",skillsSubdir:"skills",platform:"custom"},{id:"codex",label:"Codex",envVars:["CODEX","CODEX_CI"],dir:".codex",skillsSubdir:"skills",platform:"codex"},{id:"opencode",label:"OpenCode",envVars:["OPENCODE"],dir:".opencode",skillsSubdir:"skills",platform:"custom"},{id:"gemini-cli",label:"Gemini CLI",envVars:["GEMINI_CLI"],dir:".gemini",skillsSubdir:"skills",platform:"gemini"},{id:"antigravity",label:"Antigravity",envVars:["GEMINI_CLI_IDE_WORKSPACE_PATH","GEMINI_CLI_IDE_PID"],dir:".gemini/antigravity",skillsSubdir:"skills",platform:"gemini"}];function te(n){if(n){let r=we.find(i=>i.id===n);if(r)return r;let s=we.find(i=>i.dir===`.${n}`||i.dir===n);return s||null}for(let r of we)if(r.envVars.some(s=>process.env[s]))return r;let e=(0,ce.homedir)(),t=[];for(let r of we)(0,Ft.existsSync)((0,J.join)(e,r.dir))&&t.push(r);return t.length===1?t[0]:null}function Dt(){let n=[],e=(0,ce.homedir)();for(let t of we)(t.envVars.some(r=>process.env[r])||(0,Ft.existsSync)((0,J.join)(e,t.dir)))&&n.push(t);return n}function re(){let n=Dt();return n.length>1?`Multiple AI agents detected (${n.map(e=>e.label).join(", ")}). Use --agent to specify: ${n.map(e=>e.id).join(", ")}`:`No AI agent detected. Use --agent to specify one (${we.map(e=>e.id).join(", ")})`}function k(n,e){return e?(0,J.join)(process.cwd(),n.dir,n.skillsSubdir):(0,J.join)((0,ce.homedir)(),n.dir,n.skillsSubdir)}function F(n,e){return e?(0,J.join)(process.cwd(),n.dir,"agents"):(0,J.join)((0,ce.homedir)(),n.dir,"agents")}function M(n,e){return e?(0,J.join)(process.cwd(),".mcp.json"):n.id==="claude-code"?(0,J.join)((0,ce.homedir)(),".claude.json"):n.id==="cursor"?(0,J.join)((0,ce.homedir)(),".cursor","mcp.json"):(0,J.join)(process.cwd(),".mcp.json")}function Ue(n,e){return e?(0,J.join)(process.cwd(),n.dir,"settings.json"):(0,J.join)((0,ce.homedir)(),n.dir,"settings.json")}var H=require("fs"),fe=require("path");var ne=require("fs"),se=require("path");U();q();var Tr={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function v(n,e){let t=(0,se.resolve)(n);for(let r of e){let s=(0,se.resolve)((0,se.join)(n,r.path));if(!s.startsWith(t+"/")&&s!==t)throw new Error(`Invalid file path: ${r.path}`);(0,ne.mkdirSync)((0,se.dirname)(s),{recursive:!0}),(0,ne.writeFileSync)(s,r.content,"utf-8")}}function dn(n){let e=n.resource.slug||n.resource.id,t=Tr[n.resource.resourceType]||n.resource.resourceType+"s";return n.resource.storageType==="github"&&n.resource.githubOwner?`${t}/external/${n.resource.githubOwner}/${e}`:n.resource.orgSlug?`${t}/${n.resource.orgSlug}/${e}`:`${t}/${e}`}function Rr(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}function Nt(n,e,t){let r=t.files.find(o=>o.path.endsWith(".json")&&!o.path.includes("/"))||t.files.find(o=>o.path.endsWith(".json")&&o.path.includes("resources/"));if(!r)throw new Error("MCP package does not contain a config file");let s=JSON.parse(r.content),i=M(n,e),a=t.resource.slug||t.resource.id,c={};if((0,ne.existsSync)(i))try{c=JSON.parse((0,ne.readFileSync)(i,"utf-8"))}catch{c={}}let l=typeof c.mcpServers=="object"&&c.mcpServers&&!Array.isArray(c.mcpServers)?c.mcpServers:{};s.mcpServers&&typeof s.mcpServers=="object"?Object.assign(l,s.mcpServers):l[a]=s,c.mcpServers=l,(0,ne.mkdirSync)((0,se.dirname)(i),{recursive:!0}),(0,ne.writeFileSync)(i,JSON.stringify(c,null,2)+`
31
- `,"utf-8")}function Ir(n){n.command("install <path>").description("Install a resource (e.g., skills/acme/api-testing)").action(async(e,t,r)=>{let s=r.optsWithGlobals(),i=te(s.agent);if(!i){let h=re();g()?w("install","NO_AGENTS",h):S(h),process.exit(1)}let a=E(),l=await I(`${a?"/api/cli/resource":"/api/public/resource"}/${e}`);l.ok||(g()?w("install",l.error.code,l.error.message):S(`Install failed: ${l.error.message}`),process.exit(1));let o=l.data,u=o.resource.slug||o.resource.id,p=dn(o),d;if(o.resource.resourceType==="agent"){let h=F(i,!!s.project);d=(0,se.join)(h,...Rr(o));try{v(d,o.files)}catch(C){g()?w("install","WRITE_FAILED",`Failed to write files: ${C}`):S(`Failed to write files: ${C}`),process.exit(1)}}else if(o.resource.resourceType==="mcp"){d="";try{Nt(i,!!s.project,o)}catch(h){g()?w("install","WRITE_FAILED",`Failed to install MCP config: ${h}`):S(`Failed to install MCP config: ${h}`),process.exit(1)}}else{let h=k(i,!!s.project);d=(0,se.join)(h,...Rr(o));try{if(o.resource.resourceType==="collection"){let A=await xe(i).install(o,s.project?"project":"user",i);if(d=A.installDir,!g())for(let x of A.warnings)S(`Warning: ${x}`)}else v(d,o.files)}catch(C){g()?w("install","WRITE_FAILED",`Failed to write files: ${C}`):S(`Failed to write files: ${C}`),process.exit(1)}}let b;if(a&&o.resource.latestSha){let h=await P("/api/cli/install",{resourceId:o.resource.id,agentPlatform:i.platform,installedSha:o.resource.latestSha});h.ok||(b=`Could not record install on server: ${h.error.message}`,g()||S(`Warning: ${b}`))}let f={"claude-code":"claude-plugin","gemini-cli":"gemini-extension",antigravity:"gemini-extension",cursor:"cursor",codex:"codex"},y=o.resource.resourceType==="collection";if(X({resourceId:o.resource.id,slug:u,installPath:p,title:o.resource.title,sha:o.resource.latestSha||"",scope:s.project?"project":"global",agent:i.id,installedAt:new Date().toISOString(),...y?{pluginFormat:f[i.id]||"directory",memberCount:o.memberResources?.length}:{}}),o.memberResources&&o.resource.resourceType==="collection")for(let h of o.memberResources){let C=h.slug||h.id,A=Tr[h.resourceType]||h.resourceType+"s",x=h.orgSlug||o.resource.orgSlug,Z=x?`${A}/${x}/${C}`:`${A}/${C}`;X({resourceId:h.id,slug:C,installPath:Z,title:h.title,sha:h.latestSha||"",scope:s.project?"project":"global",agent:i.id,installedAt:new Date().toISOString(),collectionId:o.resource.id}),a&&h.latestSha&&await P("/api/cli/install",{resourceId:h.id,agentPlatform:i.platform,installedSha:h.latestSha}).catch(()=>{})}if(g())_("install",{installPath:p,title:o.resource.title,path:d||void 0,files:o.files.length,...o.resource.resourceType==="mcp"?{mcpConfigPath:M(i,!!s.project)}:{},...o.memberResources?{memberResources:o.memberResources.map(h=>({title:h.title,resourceType:h.resourceType,slug:h.slug}))}:{},...b&&{warning:b}});else{if(o.resource.resourceType==="mcp"?m(`Installed MCP "${o.resource.title}" to ${M(i,!!s.project)}`):o.memberResources&&o.memberResources.length>0?m(`Installed "${o.resource.title}" (${o.memberResources.length} resources)`):m(`Installed "${o.resource.title}" to ${d}`),o.resource.resourceType!=="mcp"&&!(o.memberResources&&o.memberResources.length>0)&&m(` ${o.files.length} file${o.files.length===1?"":"s"} written`),o.memberResources&&o.memberResources.length>0){let h={};for(let A of o.memberResources){let x=A.resourceType||"other";h[x]||(h[x]=[]),h[x].push(A.title)}let C={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections",file:"Files"};m("");for(let[A,x]of Object.entries(h)){let Z=C[A]||A;m(` ${Z}: ${x.join(", ")}`)}}a||(m(""),m("Tip: Sign up at sharedcontext.ai to track installations and get updates."))}})}var Be=class{buildFiles(e){let t=[],r=[],s=[],i={},a={};for(let c of e.files){let l=c.path.split("/"),o=l[0];if(o==="agents")s.push({path:c.path.slice(7),content:c.content});else if(o==="mcps"){if(c.path.endsWith(".json"))try{let u=JSON.parse(c.content);if(u.mcpServers&&typeof u.mcpServers=="object")Object.assign(i,u.mcpServers);else if(c.path.includes("resources/")){let p=l.indexOf("resources"),d=p>0?l[p-1]:l[1];i[d]=u}}catch{t.push(`Failed to parse MCP config: ${c.path}`)}}else if(o==="hooks"){if(c.path.endsWith(".json"))try{let u=JSON.parse(c.content);hn(u,a)}catch{t.push(`Failed to parse hook config: ${c.path}`)}}else o==="skills"||o==="commands"||o==="files"?r.push({path:c.path.slice(o.length+1),content:c.content}):r.push(c)}return{mainFiles:r,agentFiles:s,mcpEntries:i,hookEntries:a,customFiles:[],warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=e.resource.slug||e.resource.id,c=k(r,i),l=yn(e),o=(0,fe.join)(c,...l),u=0;if(s.mainFiles.length>0){let p=s.mainFiles.filter(b=>!b.path.includes("/")),d=s.mainFiles.filter(b=>b.path.includes("/"));p.length>0&&(v(o,p),u+=p.length),d.length>0&&(v(c,d),u+=d.length)}if(s.agentFiles.length>0){let p=F(r,i);v(p,s.agentFiles),u+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&gn(M(r,i),s.mcpEntries),Object.keys(s.hookEntries).length>0&&fn(Ue(r,i),s.hookEntries),{installDir:o,filesWritten:u,warnings:s.warnings}}async uninstall(e,t,r,s){let i=[],c=k(r,t==="project"),l=(0,fe.join)(c,e),o=!1;return(0,H.existsSync)(l)&&((0,H.rmSync)(l,{recursive:!0,force:!0}),o=!0),o||i.push(`Collection directory not found at ${l}`),{removed:o,warnings:i}}describeLocation(e,t,r){let s=k(r,t==="project");return(0,fe.join)(s,e)}};function hn(n,e){if(!n||typeof n!="object")return;let t=n,r=t.hooks&&typeof t.hooks=="object"&&!Array.isArray(t.hooks)?t.hooks:t;for(let[s,i]of Object.entries(r))if(!(s==="name"||s==="description")&&Array.isArray(i)){e[s]||(e[s]=[]);for(let a of i)e[s].push(a)}}function fn(n,e){let t={};if((0,H.existsSync)(n))try{t=JSON.parse((0,H.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.hooks=="object"&&t.hooks&&!Array.isArray(t.hooks)?t.hooks:{};for(let[s,i]of Object.entries(e)){Array.isArray(r[s])||(r[s]=[]);for(let a of i){let c=JSON.stringify(a);r[s].some(o=>JSON.stringify(o)===c)||r[s].push(a)}}t.hooks=r,(0,H.mkdirSync)((0,fe.dirname)(n),{recursive:!0}),(0,H.writeFileSync)(n,JSON.stringify(t,null,2)+`
32
- `,"utf-8")}function gn(n,e){let t={};if((0,H.existsSync)(n))try{t=JSON.parse((0,H.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,H.mkdirSync)((0,fe.dirname)(n),{recursive:!0}),(0,H.writeFileSync)(n,JSON.stringify(t,null,2)+`
33
- `,"utf-8")}function yn(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var L=require("fs"),ge=require("path");var bn={SessionStart:"SessionStart",PreToolUse:"BeforeTool",PostToolUse:"AfterTool",Stop:"AfterAgent",UserPromptSubmit:"BeforeAgent",PreCompact:"PreCompress"},qe=class{buildFiles(e){let t=[],r=[],s=[],i={},a={};for(let c of e.files){let l=c.path.split("/"),o=l[0];if(o==="agents")s.push({path:c.path.slice(7),content:c.content});else if(o==="mcps"){if(c.path.endsWith(".json"))try{let u=JSON.parse(c.content);if(u.mcpServers&&typeof u.mcpServers=="object")Object.assign(i,u.mcpServers);else if(c.path.includes("resources/")){let p=l.indexOf("resources"),d=p>0?l[p-1]:l[1];i[d]=u}}catch{t.push(`Failed to parse MCP config: ${c.path}`)}}else if(o==="hooks"){if(c.path.endsWith(".json"))try{let u=JSON.parse(c.content);Sn(u,a)}catch{t.push(`Failed to parse hook config: ${c.path}`)}}else o==="skills"||o==="commands"||o==="files"?r.push({path:c.path.slice(o.length+1),content:c.content}):r.push(c)}return{mainFiles:r,agentFiles:s,mcpEntries:i,hookEntries:a,customFiles:[],warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=e.resource.slug||e.resource.id,c=k(r,i),l=An(e),o=(0,ge.join)(c,...l),u=0;if(s.mainFiles.length>0){let p=s.mainFiles.filter(b=>!b.path.includes("/")),d=s.mainFiles.filter(b=>b.path.includes("/"));p.length>0&&(v(o,p),u+=p.length),d.length>0&&(v(c,d),u+=d.length)}if(s.agentFiles.length>0){let p=F(r,i);v(p,s.agentFiles),u+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&xn(M(r,i),s.mcpEntries),Object.keys(s.hookEntries).length>0&&wn(Ue(r,i),s.hookEntries),{installDir:o,filesWritten:u,warnings:s.warnings}}async uninstall(e,t,r){let s=[],a=k(r,t==="project"),c=(0,ge.join)(a,e),l=!1;return(0,L.existsSync)(c)&&((0,L.rmSync)(c,{recursive:!0,force:!0}),l=!0),l||s.push(`Collection directory not found at ${c}`),{removed:l,warnings:s}}describeLocation(e,t,r){let s=k(r,t==="project");return(0,ge.join)(s,e)}};function Sn(n,e){if(!n||typeof n!="object")return;let t=n,r=t.hooks&&typeof t.hooks=="object"&&!Array.isArray(t.hooks)?t.hooks:t;for(let[s,i]of Object.entries(r)){if(s==="name"||s==="description"||!Array.isArray(i))continue;let a=bn[s]||s;e[a]||(e[a]=[]);for(let c of i)e[a].push(c)}}function wn(n,e){let t={};if((0,L.existsSync)(n))try{t=JSON.parse((0,L.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.hooks=="object"&&t.hooks&&!Array.isArray(t.hooks)?t.hooks:{};for(let[s,i]of Object.entries(e)){Array.isArray(r[s])||(r[s]=[]);for(let a of i){let c=JSON.stringify(a);r[s].some(o=>JSON.stringify(o)===c)||r[s].push(a)}}t.hooks=r,(0,L.mkdirSync)((0,ge.dirname)(n),{recursive:!0}),(0,L.writeFileSync)(n,JSON.stringify(t,null,2)+`
34
- `,"utf-8")}function xn(n,e){let t={};if((0,L.existsSync)(n))try{t=JSON.parse((0,L.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,L.mkdirSync)((0,ge.dirname)(n),{recursive:!0}),(0,L.writeFileSync)(n,JSON.stringify(t,null,2)+`
35
- `,"utf-8")}function An(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var j=require("fs"),ae=require("path");var Je=class{buildFiles(e){let t=[],r=[],s=[],i={},a=[],c=e.resource.slug||e.resource.id;for(let l of e.files){let o=l.path.split("/"),u=o[0];if(u==="agents")s.push({path:l.path.slice(7),content:l.content});else if(u==="mcps"){if(l.path.endsWith(".json"))try{let p=JSON.parse(l.content);if(p.mcpServers&&typeof p.mcpServers=="object")Object.assign(i,p.mcpServers);else if(l.path.includes("resources/")){let d=o.indexOf("resources"),b=d>0?o[d-1]:o[1];i[b]=p}}catch{t.push(`Failed to parse MCP config: ${l.path}`)}}else u==="hooks"?t.push(`Hooks are not supported by Cursor (skipped: ${l.path})`):u==="skills"||u==="commands"||u==="files"?r.push({path:l.path.slice(u.length+1),content:l.content}):r.push(l)}return{mainFiles:r,agentFiles:s,mcpEntries:i,hookEntries:{},customFiles:a,warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=k(r,i),c=On(e),l=(0,ae.join)(a,...c),o=0;if(s.mainFiles.length>0){let u=s.mainFiles.filter(d=>!d.path.includes("/")),p=s.mainFiles.filter(d=>d.path.includes("/"));u.length>0&&(v(l,u),o+=u.length),p.length>0&&(v(a,p),o+=p.length)}if(s.agentFiles.length>0){let u=F(r,i);v(u,s.agentFiles),o+=s.agentFiles.length}for(let u of s.customFiles)(0,j.mkdirSync)((0,ae.dirname)(u.absolutePath),{recursive:!0}),(0,j.writeFileSync)(u.absolutePath,u.content,"utf-8"),o++;return Object.keys(s.mcpEntries).length>0&&Cn(M(r,i),s.mcpEntries),{installDir:l,filesWritten:o,warnings:s.warnings}}async uninstall(e,t,r){let s=[],a=k(r,t==="project"),c=(0,ae.join)(a,e),l=!1;(0,j.existsSync)(c)&&((0,j.rmSync)(c,{recursive:!0,force:!0}),l=!0);let o=(0,ae.join)(homedir(),".cursor","rules");if((0,j.existsSync)(o))try{let u=(0,j.readdirSync)(o);for(let p of u)p.startsWith(`${e}-`)&&p.endsWith(".mdc")&&((0,j.unlinkSync)((0,ae.join)(o,p)),l=!0)}catch{s.push("Could not clean up Cursor rules")}return l||s.push(`Collection not found for Cursor at ${c}`),{removed:l,warnings:s}}describeLocation(e,t,r){let s=k(r,t==="project");return(0,ae.join)(s,e)}};function Cn(n,e){let t={};if((0,j.existsSync)(n))try{t=JSON.parse((0,j.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,j.mkdirSync)((0,ae.dirname)(n),{recursive:!0}),(0,j.writeFileSync)(n,JSON.stringify(t,null,2)+`
36
- `,"utf-8")}function On(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var Ke=require("fs"),Ge=require("path");var Ye=class{buildFiles(e){let t=[],r=[],s=[];for(let i of e.files){let c=i.path.split("/")[0];c==="agents"?s.push({path:i.path.slice(7),content:i.content}):c==="mcps"?t.push(`MCP servers are not yet supported by Codex adapter (skipped: ${i.path})`):c==="hooks"?t.push(`Hooks are not supported by Codex (skipped: ${i.path})`):c==="commands"?t.push(`Commands are not supported by Codex (skipped: ${i.path})`):c==="skills"||c==="files"?r.push({path:i.path.slice(c.length+1),content:i.content}):r.push(i)}return{mainFiles:r,agentFiles:s,mcpEntries:{},hookEntries:{},customFiles:[],warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=k(r,i),c=_n(e),l=(0,Ge.join)(a,...c),o=0;if(s.mainFiles.length>0){let u=s.mainFiles.filter(d=>!d.path.includes("/")),p=s.mainFiles.filter(d=>d.path.includes("/"));u.length>0&&(v(l,u),o+=u.length),p.length>0&&(v(a,p),o+=p.length)}if(s.agentFiles.length>0){let u=F(r,i);v(u,s.agentFiles),o+=s.agentFiles.length}return{installDir:l,filesWritten:o,warnings:s.warnings}}async uninstall(e,t,r){let s=[],a=k(r,t==="project"),c=(0,Ge.join)(a,e),l=!1;return(0,Ke.existsSync)(c)&&((0,Ke.rmSync)(c,{recursive:!0,force:!0}),l=!0),l||s.push(`Collection directory not found at ${c}`),{removed:l,warnings:s}}describeLocation(e,t,r){let s=k(r,t==="project");return(0,Ge.join)(s,e)}};function _n(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var Q=require("fs"),Ae=require("path");var ze=class{buildFiles(e){let t=[],r=[],s={};for(let i of e.files){let a=i.path.split("/"),c=a[0];if(c==="agents")r.push({path:i.path.slice(7),content:i.content});else if(c==="mcps"){if(i.path.endsWith(".json"))try{let l=JSON.parse(i.content);if(l.mcpServers&&typeof l.mcpServers=="object")Object.assign(s,l.mcpServers);else if(i.path.includes("resources/")){let o=a.indexOf("resources"),u=o>0?a[o-1]:a[1];s[u]=l}}catch{}}else c==="skills"||c==="commands"||c==="hooks"||c==="files"?t.push({path:i.path.slice(c.length+1),content:i.content}):t.push(i)}return{mainFiles:t,agentFiles:r,mcpEntries:s,hookEntries:{},customFiles:[],warnings:[]}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=k(r,i),c=vn(e),l=(0,Ae.join)(a,...c),o=0;if(s.mainFiles.length>0){let u=s.mainFiles.filter(d=>!d.path.includes("/")),p=s.mainFiles.filter(d=>d.path.includes("/"));u.length>0&&(v(l,u),o+=u.length),p.length>0&&(v(a,p),o+=p.length)}if(s.agentFiles.length>0){let u=F(r,i);v(u,s.agentFiles),o+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&kn(M(r,i),s.mcpEntries),{installDir:l,filesWritten:o,warnings:s.warnings}}async uninstall(e,t,r){let i=k(r,t==="project"),a=(0,Ae.join)(i,e),c=!1;return(0,Q.existsSync)(a)&&((0,Q.rmSync)(a,{recursive:!0,force:!0}),c=!0),{removed:c,warnings:[]}}describeLocation(e,t,r){let s=k(r,t==="project");return(0,Ae.join)(s,e)}};function kn(n,e){let t={};if((0,Q.existsSync)(n))try{t=JSON.parse((0,Q.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,Q.mkdirSync)((0,Ae.dirname)(n),{recursive:!0}),(0,Q.writeFileSync)(n,JSON.stringify(t,null,2)+`
37
- `,"utf-8")}function vn(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}function xe(n){switch(n.id){case"claude-code":return new Be;case"gemini-cli":case"antigravity":return new qe;case"cursor":return new Je;case"codex":return new Ye;default:return new ze}}var jr=`---
27
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Cr(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",s="9229",i;return(i=e.match(/^(--inspect(-brk)?)$/))!==null?t=i[1]:(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=i[1],/^\d+$/.test(i[3])?s=i[3]:r=i[3]):(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],r=i[3],s=i[4]),t&&s!=="0"?`${t}=${r}:${parseInt(s)+1}`:e})}function jt(){if(k.env.NO_COLOR||k.env.FORCE_COLOR==="0"||k.env.FORCE_COLOR==="false")return!1;if(k.env.FORCE_COLOR||k.env.CLICOLOR_FORCE!==void 0)return!0}Ft.Command=It;Ft.useColor=jt});var Er=xe(ee=>{"use strict";var{Argument:Or}=Je(),{Command:Dt}=kr(),{CommanderError:bn,InvalidArgumentError:_r}=Ne(),{Help:Sn}=_t(),{Option:vr}=$t();ee.program=new Dt;ee.createCommand=n=>new Dt(n);ee.createOption=(n,e)=>new vr(n,e);ee.createArgument=(n,e)=>new Or(n,e);ee.Command=Dt;ee.Option=vr;ee.Argument=Or;ee.Help=Sn;ee.CommanderError=bn;ee.InvalidArgumentError=_r;ee.InvalidOptionArgumentError=_r});var Lr={};St(Lr,{addToManifest:()=>ne,clearAuth:()=>Ht,getAuth:()=>ae,getConfig:()=>ge,getManifest:()=>K,getSyncState:()=>Qe,removeFromManifest:()=>Xe,saveAuth:()=>Mt,saveConfig:()=>Mr,saveManifest:()=>Lt,saveSyncState:()=>He,shouldSync:()=>Wt,updateConfig:()=>xn});function Me(){let n=process.env.SC_PROFILE;return n?(0,Ce.join)(jr,"profiles",n):jr}function Nt(){return(0,Ce.join)(Me(),"auth.json")}function Dr(){return(0,Ce.join)(Me(),"config.json")}function Nr(){return(0,Ce.join)(Me(),"manifest.json")}function wn(){(0,se.mkdirSync)(Me(),{recursive:!0})}function Ke(n,e){try{return(0,se.existsSync)(n)?JSON.parse((0,se.readFileSync)(n,"utf-8")):e}catch{return e}}function ze(n,e,t=!1){if(wn(),(0,se.writeFileSync)(n,JSON.stringify(e,null,2)+`
28
+ `,"utf-8"),t)try{(0,se.chmodSync)(n,384)}catch{}}function ae(){return Ke(Nt(),null)}function Mt(n){ze(Nt(),n,!0)}function Ht(){try{(0,se.writeFileSync)(Nt(),"{}","utf-8")}catch{}}function ge(){return Ke(Dr(),An)}function Mr(n){ze(Dr(),n)}function xn(n){let e=ge();Mr({...e,...n})}function K(){return Ke(Nr(),Cn)}function Lt(n){ze(Nr(),n)}function ne(n){let e=K(),t=e.installations.findIndex(r=>r.resourceId===n.resourceId&&r.agent===n.agent);t>=0?e.installations[t]=n:e.installations.push(n),Lt(e)}function Xe(n,e){let t=K();t.installations=t.installations.filter(r=>!(r.resourceId===n&&(!e||r.agent===e))),Lt(t)}function Hr(){return(0,Ce.join)(Me(),"last-sync.json")}function Qe(){return Ke(Hr(),null)}function He(n){ze(Hr(),n)}function Wt(n=kn){let e=Qe();return e?.lastSyncAt?Date.now()-new Date(e.lastSyncAt).getTime()>=n:!0}var se,Ce,Fr,jr,An,Cn,kn,Q=X(()=>{"use strict";se=require("fs"),Ce=require("path"),Fr=require("os"),jr=(0,Ce.join)((0,Fr.homedir)(),".config","shared-context");An={apiBase:"https://sharedcontext.ai"};Cn={installations:[]};kn=720*60*1e3});var Wr={};St(Wr,{del:()=>Ut,get:()=>H,isAuthenticated:()=>T,patch:()=>vn,post:()=>F});function On(){return ge().apiBase||"https://sharedcontext.ai"}function _n(){let n={"Content-Type":"application/json"},e=ae();return e?.token&&(n.Authorization=`Bearer ${e.token}`),n}function T(){return!!ae()?.token}async function Ze(n,e,t,r){let s=`${On()}${e}`;try{let i={method:n,headers:_n(),body:t?JSON.stringify(t):void 0};r&&(i.signal=AbortSignal.timeout(r));let a=await fetch(s,i),o=a.headers.get("content-type")||"";if(!o.includes("application/json"))return a.ok?{ok:!1,error:{code:"INVALID_RESPONSE",message:`Expected JSON, got ${o||"unknown content type"}`}}:{ok:!1,error:{code:`HTTP_${a.status}`,message:a.statusText}};let l=await a.json();return a.ok?{ok:!0,data:l.data??l}:{ok:!1,error:{code:l?.error?.code||`HTTP_${a.status}`,message:l?.error?.message||l?.message||a.statusText}}}catch(i){return{ok:!1,error:{code:"NETWORK_ERROR",message:i instanceof Error?i.message:"Network request failed"}}}}function H(n){return Ze("GET",n)}function F(n,e,t){return Ze("POST",n,e,t)}function vn(n,e){return Ze("PATCH",n,e)}function Ut(n,e){return Ze("DELETE",n,e)}var z=X(()=>{"use strict";Q()});function Xn(){try{return Xt.default.statSync("/.dockerenv"),!0}catch{return!1}}function Qn(){try{return Xt.default.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function Qt(){return zt===void 0&&(zt=Xn()||Qn()),zt}var Xt,zt,es=X(()=>{"use strict";Xt=q(require("fs"),1)});function _e(){return Zt===void 0&&(Zt=Zn()||Qt()),Zt}var ts,Zt,Zn,er=X(()=>{"use strict";ts=q(require("fs"),1);es();Zn=()=>{try{return ts.default.statSync("/run/.containerenv"),!0}catch{return!1}}});var tr,ss,pt,rs,be,rr=X(()=>{"use strict";tr=q(require("process"),1),ss=q(require("os"),1),pt=q(require("fs"),1);er();rs=()=>{if(tr.default.platform!=="linux")return!1;if(ss.default.release().toLowerCase().includes("microsoft"))return!_e();try{if(pt.default.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!_e()}catch{}return pt.default.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||pt.default.existsSync("/run/WSL")?!_e():!1},be=tr.default.env.__IS_WSL_TEST__?rs:rs()});var sr,Ue,ei,ti,nr,ns=X(()=>{"use strict";sr=q(require("process"),1),Ue=q(require("fs/promises"),1);rr();rr();ei=(()=>{let n="/mnt/",e;return async function(){if(e)return e;let t="/etc/wsl.conf",r=!1;try{await Ue.default.access(t,Ue.constants.F_OK),r=!0}catch{}if(!r)return n;let s=await Ue.default.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(s);return i?(e=i.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):n}})(),ti=async()=>`${await ei()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,nr=async()=>be?ti():`${sr.default.env.SYSTEMROOT||sr.default.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`});function Se(n,e,t){let r=s=>Object.defineProperty(n,e,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get(){let s=t();return r(s),s},set(s){r(s)}}),n}var is=X(()=>{"use strict"});async function ir(){if(as.default.platform!=="darwin")throw new Error("macOS only");let{stdout:n}=await ri("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(n)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}var os,as,cs,ri,ls=X(()=>{"use strict";os=require("util"),as=q(require("process"),1),cs=require("child_process"),ri=(0,os.promisify)(cs.execFile)});async function ms(n,{humanReadableOutput:e=!0,signal:t}={}){if(us.default.platform!=="darwin")throw new Error("macOS only");let r=e?[]:["-ss"],s={};t&&(s.signal=t);let{stdout:i}=await si("osascript",["-e",n,r],s);return i.trim()}var us,ps,or,si,ds=X(()=>{"use strict";us=q(require("process"),1),ps=require("util"),or=require("child_process"),si=(0,ps.promisify)(or.execFile)});async function ar(n){return ms(`tell application "Finder" to set app_path to application file id "${n}" as string
29
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var hs=X(()=>{"use strict";ds()});async function lr(n=ni){let{stdout:e}=await n("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(e);if(!t)throw new cr(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:r}=t.groups,s=r.lastIndexOf("."),i=r.lastIndexOf("-"),a=s===-1?void 0:r.slice(0,s),o=i===-1?void 0:r.slice(0,i);return mt[r]??mt[a]??mt[o]??{name:r,id:r}}var fs,gs,ni,mt,Lo,cr,ys=X(()=>{"use strict";fs=require("util"),gs=require("child_process"),ni=(0,fs.promisify)(gs.execFile),mt={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},Lo=new Map(Object.entries(mt)),cr=class extends Error{}});async function ur(){if(dt.default.platform==="darwin"){let n=await ir();return{name:await ar(n),id:n}}if(dt.default.platform==="linux"){let{stdout:n}=await ii("xdg-mime",["query","default","x-scheme-handler/http"]),e=n.trim();return{name:oi(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(dt.default.platform==="win32")return lr();throw new Error("Only macOS, Linux, and Windows are supported")}var bs,dt,Ss,ii,oi,ws=X(()=>{"use strict";bs=require("util"),dt=q(require("process"),1),Ss=require("child_process");ls();hs();ys();ii=(0,bs.promisify)(Ss.execFile),oi=n=>n.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())});var vs={};St(vs,{apps:()=>we,default:()=>pi,openApp:()=>ui});async function ci(){let n=await nr(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=dr.Buffer.from(e,"utf16le").toString("base64"),{stdout:r}=await ai(n,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),s=r.trim(),i={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return i[s]?{id:i[s]}:{}}function ks(n){if(typeof n=="string"||Array.isArray(n))return n;let{[xs]:e}=n;if(!e)throw new Error(`${xs} is not supported`);return e}function ft({[Fe]:n},{wsl:e}){if(e&&be)return ks(e);if(!n)throw new Error(`${Fe} is not supported`);return ks(n)}var mr,dr,hr,Os,_s,fr,ht,mi,ai,pr,As,Fe,xs,Cs,Ve,li,ui,we,pi,Es=X(()=>{"use strict";mr=q(require("process"),1),dr=require("buffer"),hr=q(require("path"),1),Os=require("url"),_s=require("util"),fr=q(require("child_process"),1),ht=q(require("fs/promises"),1);ns();is();ws();er();mi={},ai=(0,_s.promisify)(fr.default.execFile),pr=hr.default.dirname((0,Os.fileURLToPath)(mi.url)),As=hr.default.join(pr,"xdg-open"),{platform:Fe,arch:xs}=mr.default;Cs=async(n,e)=>{let t;for(let r of n)try{return await e(r)}catch(s){t=s}throw t},Ve=async n=>{if(n={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...n},Array.isArray(n.app))return Cs(n.app,o=>Ve({...n,app:o}));let{name:e,arguments:t=[]}=n.app??{};if(t=[...t],Array.isArray(e))return Cs(e,o=>Ve({...n,app:{name:o,arguments:t}}));if(e==="browser"||e==="browserPrivate"){let o={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},l={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},c=be?await ci():await ur();if(c.id in o){let p=o[c.id];return e==="browserPrivate"&&t.push(l[p]),Ve({...n,app:{name:we[p],arguments:t}})}throw new Error(`${c.name} is not supported as a default browser`)}let r,s=[],i={};if(Fe==="darwin")r="open",n.wait&&s.push("--wait-apps"),n.background&&s.push("--background"),n.newInstance&&s.push("--new"),e&&s.push("-a",e);else if(Fe==="win32"||be&&!_e()&&!e){r=await nr(),s.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),be||(i.windowsVerbatimArguments=!0);let o=["Start"];n.wait&&o.push("-Wait"),e?(o.push(`"\`"${e}\`""`),n.target&&t.push(n.target)):n.target&&o.push(`"${n.target}"`),t.length>0&&(t=t.map(l=>`"\`"${l}\`""`),o.push("-ArgumentList",t.join(","))),n.target=dr.Buffer.from(o.join(" "),"utf16le").toString("base64")}else{if(e)r=e;else{let o=!pr||pr==="/",l=!1;try{await ht.default.access(As,ht.constants.X_OK),l=!0}catch{}r=mr.default.versions.electron??(Fe==="android"||o||!l)?"xdg-open":As}t.length>0&&s.push(...t),n.wait||(i.stdio="ignore",i.detached=!0)}Fe==="darwin"&&t.length>0&&s.push("--args",...t),n.target&&s.push(n.target);let a=fr.default.spawn(r,s,i);return n.wait?new Promise((o,l)=>{a.once("error",l),a.once("close",c=>{if(!n.allowNonzeroExitCode&&c>0){l(new Error(`Exited with code ${c}`));return}o(a)})}):(a.unref(),a)},li=(n,e)=>{if(typeof n!="string")throw new TypeError("Expected a `target`");return Ve({...e,target:n})},ui=(n,e)=>{if(typeof n!="string"&&!Array.isArray(n))throw new TypeError("Expected a valid `name`");let{arguments:t=[]}=e??{};if(t!=null&&!Array.isArray(t))throw new TypeError("Expected `appArguments` as Array type");return Ve({...e,app:{name:n,arguments:t}})};we={};Se(we,"chrome",()=>ft({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Se(we,"brave",()=>ft({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));Se(we,"firefox",()=>ft({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Se(we,"edge",()=>ft({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Se(we,"browser",()=>"browser");Se(we,"browserPrivate",()=>"browserPrivate");pi=li});var Pr=q(Er(),1),{program:ki,createCommand:Oi,createArgument:_i,createOption:vi,CommanderError:Ei,InvalidArgumentError:Pi,InvalidOptionArgumentError:$i,Command:$r,Argument:Ri,Option:Ti,Help:Ii}=Pr.default;var Rr=!1,Tr=!1;function Ir(n,e){Rr=n,Tr=e}function y(){return Rr?!0:Tr?!1:!process.stdout.isTTY}function O(n,e){console.log(JSON.stringify({ok:!0,command:n,data:e}))}function x(n,e,t){console.log(JSON.stringify({ok:!1,command:n,errors:[{code:e,message:t}]}))}function h(n){console.log(n)}function w(n){console.error(n)}function re(n,e=2){if(n.length===0)return"";let t=[];for(let r of n)for(let s=0;s<r.length;s++)t[s]=Math.max(t[s]||0,r[s].length);return n.map(r=>r.map((s,i)=>i<r.length-1?s.padEnd(t[i]+e):s).join("")).join(`
30
+ `)}var ut=require("fs"),We=require("path"),Qr=require("os");Q();z();var Vt=require("fs"),Z=require("path"),ye=require("os"),ve=[{id:"claude-code",label:"Claude Code",envVars:["CLAUDE_CODE"],dir:".claude",skillsSubdir:"skills",platform:"claude_code"},{id:"cursor",label:"Cursor",envVars:["CURSOR","CURSOR_TRACE_ID"],dir:".cursor",skillsSubdir:"skills",platform:"custom"},{id:"codex",label:"Codex",envVars:["CODEX","CODEX_CI"],dir:".codex",skillsSubdir:"skills",platform:"codex"},{id:"opencode",label:"OpenCode",envVars:["OPENCODE"],dir:".opencode",skillsSubdir:"skills",platform:"custom"},{id:"gemini-cli",label:"Gemini CLI",envVars:["GEMINI_CLI"],dir:".gemini",skillsSubdir:"skills",platform:"gemini"},{id:"antigravity",label:"Antigravity",envVars:["GEMINI_CLI_IDE_WORKSPACE_PATH","GEMINI_CLI_IDE_PID"],dir:".gemini/antigravity",skillsSubdir:"skills",platform:"gemini"}];function ce(n){if(n){let r=ve.find(i=>i.id===n);if(r)return r;let s=ve.find(i=>i.dir===`.${n}`||i.dir===n);return s||null}for(let r of ve)if(r.envVars.some(s=>process.env[s]))return r;let e=(0,ye.homedir)(),t=[];for(let r of ve)(0,Vt.existsSync)((0,Z.join)(e,r.dir))&&t.push(r);return t.length===1?t[0]:null}function Bt(){let n=[],e=(0,ye.homedir)();for(let t of ve)(t.envVars.some(r=>process.env[r])||(0,Vt.existsSync)((0,Z.join)(e,t.dir)))&&n.push(t);return n}function le(){let n=Bt();return n.length>1?`Multiple AI agents detected (${n.map(e=>e.label).join(", ")}). Use --agent to specify: ${n.map(e=>e.id).join(", ")}`:`No AI agent detected. Use --agent to specify one (${ve.map(e=>e.id).join(", ")})`}function _(n,e){return e?(0,Z.join)(process.cwd(),n.dir,n.skillsSubdir):(0,Z.join)((0,ye.homedir)(),n.dir,n.skillsSubdir)}function U(n,e){return e?(0,Z.join)(process.cwd(),n.dir,"agents"):(0,Z.join)((0,ye.homedir)(),n.dir,"agents")}function G(n,e){return e?(0,Z.join)(process.cwd(),".mcp.json"):n.id==="claude-code"?(0,Z.join)((0,ye.homedir)(),".claude.json"):n.id==="cursor"?(0,Z.join)((0,ye.homedir)(),".cursor","mcp.json"):(0,Z.join)(process.cwd(),".mcp.json")}function ie(n,e){return e?(0,Z.join)(process.cwd(),n.dir,"settings.json"):(0,Z.join)((0,ye.homedir)(),n.dir,"settings.json")}var L=require("fs"),ke=require("path");var pe=require("fs"),ue=require("path");z();Q();var Vr={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function $(n,e){let t=(0,ue.resolve)(n);for(let r of e){let s=(0,ue.resolve)((0,ue.join)(n,r.path));if(!s.startsWith(t+"/")&&s!==t)throw new Error(`Invalid file path: ${r.path}`);(0,pe.mkdirSync)((0,ue.dirname)(s),{recursive:!0}),(0,pe.writeFileSync)(s,r.content,"utf-8")}}function En(n){let e=n.resource.slug||n.resource.id,t=Vr[n.resource.resourceType]||n.resource.resourceType+"s";return n.resource.storageType==="github"&&n.resource.githubOwner?`${t}/external/${n.resource.githubOwner}/${e}`:n.resource.orgSlug?`${t}/${n.resource.orgSlug}/${e}`:`${t}/${e}`}function Ur(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}function qt(n,e,t){let r=t.files.find(c=>c.path.endsWith(".json")&&!c.path.includes("/"))||t.files.find(c=>c.path.endsWith(".json")&&c.path.includes("resources/"));if(!r)throw new Error("MCP package does not contain a config file");let s=JSON.parse(r.content),i=G(n,e),a=t.resource.slug||t.resource.id,o={};if((0,pe.existsSync)(i))try{o=JSON.parse((0,pe.readFileSync)(i,"utf-8"))}catch{o={}}let l=typeof o.mcpServers=="object"&&o.mcpServers&&!Array.isArray(o.mcpServers)?o.mcpServers:{};s.mcpServers&&typeof s.mcpServers=="object"?Object.assign(l,s.mcpServers):l[a]=s,o.mcpServers=l,(0,pe.mkdirSync)((0,ue.dirname)(i),{recursive:!0}),(0,pe.writeFileSync)(i,JSON.stringify(o,null,2)+`
31
+ `,"utf-8")}function Pn(n,e,t,r){let s=t.files.find(c=>c.path.endsWith(".json")&&!c.path.includes("/"));if(!s)throw new Error("Hook package does not contain a hook.json file");let i=JSON.parse(s.content),a=ie(n,e),o={},l=i.hooks&&typeof i.hooks=="object"&&!Array.isArray(i.hooks)?i.hooks:i;for(let[c,p]of Object.entries(l))if(!(c==="name"||c==="description")&&Array.isArray(p)){o[c]||(o[c]=[]);for(let u of p)o[c].push(u)}if(Object.keys(o).length===0)throw new Error("Hook package does not contain any hook event handlers");return Gt(a,o,r),a}function Br(n){n.command("install <path>").description("Install a resource (e.g., skills/acme/api-testing)").action(async(e,t,r)=>{let s=r.optsWithGlobals(),i=ce(s.agent);if(!i){let m=le();y()?x("install","NO_AGENTS",m):w(m),process.exit(1)}let a=T(),l=await H(`${a?"/api/cli/resource":"/api/public/resource"}/${e}`);l.ok||(y()?x("install",l.error.code,l.error.message):w(`Install failed: ${l.error.message}`),process.exit(1));let c=l.data,p=c.resource.slug||c.resource.id,u=En(c),d;if(c.resource.resourceType==="agent"){let m=U(i,!!s.project);d=(0,ue.join)(m,...Ur(c));try{$(d,c.files)}catch(A){y()?x("install","WRITE_FAILED",`Failed to write files: ${A}`):w(`Failed to write files: ${A}`),process.exit(1)}}else if(c.resource.resourceType==="mcp"){d="";try{qt(i,!!s.project,c)}catch(m){y()?x("install","WRITE_FAILED",`Failed to install MCP config: ${m}`):w(`Failed to install MCP config: ${m}`),process.exit(1)}}else if(c.resource.resourceType==="hook"){d="";try{Pn(i,!!s.project,c,u)}catch(m){y()?x("install","WRITE_FAILED",`Failed to install hook config: ${m}`):w(`Failed to install hook config: ${m}`),process.exit(1)}}else{let m=_(i,!!s.project);d=(0,ue.join)(m,...Ur(c));try{if(c.resource.resourceType==="collection"){let S=await Ee(i).install(c,s.project?"project":"user",i);if(d=S.installDir,!y())for(let C of S.warnings)w(`Warning: ${C}`)}else $(d,c.files)}catch(A){y()?x("install","WRITE_FAILED",`Failed to write files: ${A}`):w(`Failed to write files: ${A}`),process.exit(1)}}let b;if(a&&c.resource.latestSha){let m=await F("/api/cli/install",{resourceId:c.resource.id,agentPlatform:i.platform,installedSha:c.resource.latestSha});m.ok||(b=`Could not record install on server: ${m.error.message}`,y()||w(`Warning: ${b}`))}let g={"claude-code":"claude-plugin","gemini-cli":"gemini-extension",antigravity:"gemini-extension",cursor:"cursor",codex:"codex"},f=c.resource.resourceType==="collection";if(ne({resourceId:c.resource.id,slug:p,installPath:u,title:c.resource.title,sha:c.resource.latestSha||"",scope:s.project?"project":"global",agent:i.id,installedAt:new Date().toISOString(),...f?{pluginFormat:g[i.id]||"directory",memberCount:c.memberResources?.length}:{}}),c.memberResources&&c.resource.resourceType==="collection")for(let m of c.memberResources){let A=m.slug||m.id,S=Vr[m.resourceType]||m.resourceType+"s",C=m.orgSlug||c.resource.orgSlug,N=C?`${S}/${C}/${A}`:`${S}/${A}`;ne({resourceId:m.id,slug:A,installPath:N,title:m.title,sha:m.latestSha||"",scope:s.project?"project":"global",agent:i.id,installedAt:new Date().toISOString(),collectionId:c.resource.id}),a&&m.latestSha&&await F("/api/cli/install",{resourceId:m.id,agentPlatform:i.platform,installedSha:m.latestSha}).catch(()=>{})}if(y())O("install",{installPath:u,title:c.resource.title,path:d||void 0,files:c.files.length,...c.resource.resourceType==="mcp"?{mcpConfigPath:G(i,!!s.project)}:{},...c.resource.resourceType==="hook"?{settingsPath:ie(i,!!s.project)}:{},...c.memberResources?{memberResources:c.memberResources.map(m=>({title:m.title,resourceType:m.resourceType,slug:m.slug}))}:{},...b&&{warning:b}});else{if(c.resource.resourceType==="mcp"?h(`Installed MCP "${c.resource.title}" to ${G(i,!!s.project)}`):c.resource.resourceType==="hook"?h(`Installed hook "${c.resource.title}" to ${ie(i,!!s.project)}`):c.memberResources&&c.memberResources.length>0?h(`Installed "${c.resource.title}" (${c.memberResources.length} resources)`):h(`Installed "${c.resource.title}" to ${d}`),c.resource.resourceType!=="mcp"&&c.resource.resourceType!=="hook"&&!(c.memberResources&&c.memberResources.length>0)&&h(` ${c.files.length} file${c.files.length===1?"":"s"} written`),c.memberResources&&c.memberResources.length>0){let m={};for(let S of c.memberResources){let C=S.resourceType||"other";m[C]||(m[C]=[]),m[C].push(S.title)}let A={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections",file:"Files"};h("");for(let[S,C]of Object.entries(m)){let N=A[S]||S;h(` ${N}: ${C.join(", ")}`)}}a||(h(""),h("Tip: Sign up at sharedcontext.ai to track installations and get updates."))}})}var et=class{buildFiles(e){let t=[],r=[],s=[],i={},a={};for(let o of e.files){let l=o.path.split("/"),c=l[0];if(c==="agents")s.push({path:o.path.slice(7),content:o.content});else if(c==="mcps"){if(o.path.endsWith(".json"))try{let p=JSON.parse(o.content);if(p.mcpServers&&typeof p.mcpServers=="object")Object.assign(i,p.mcpServers);else if(o.path.includes("resources/")){let u=l.indexOf("resources"),d=u>0?l[u-1]:l[1];i[d]=p}}catch{t.push(`Failed to parse MCP config: ${o.path}`)}}else if(c==="hooks"){if(o.path.endsWith(".json"))try{let p=JSON.parse(o.content),u=o.path.replace(/\/[^/]+$/,"");$n(p,a,u)}catch{t.push(`Failed to parse hook config: ${o.path}`)}}else c==="skills"||c==="commands"||c==="files"?r.push({path:o.path.slice(c.length+1),content:o.content}):r.push(o)}return{mainFiles:r,agentFiles:s,mcpEntries:i,hookEntries:a,customFiles:[],warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=e.resource.slug||e.resource.id,o=_(r,i),l=Tn(e),c=(0,ke.join)(o,...l),p=0;if(s.mainFiles.length>0){let u=s.mainFiles.filter(b=>!b.path.includes("/")),d=s.mainFiles.filter(b=>b.path.includes("/"));u.length>0&&($(c,u),p+=u.length),d.length>0&&($(o,d),p+=d.length)}if(s.agentFiles.length>0){let u=U(r,i);$(u,s.agentFiles),p+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&Rn(G(r,i),s.mcpEntries),Object.keys(s.hookEntries).length>0&&Gt(ie(r,i),s.hookEntries),{installDir:c,filesWritten:p,warnings:s.warnings}}async uninstall(e,t,r,s){let i=[],o=_(r,t==="project"),l=(0,ke.join)(o,e),c=!1;return(0,L.existsSync)(l)&&((0,L.rmSync)(l,{recursive:!0,force:!0}),c=!0),c||i.push(`Collection directory not found at ${l}`),{removed:c,warnings:i}}describeLocation(e,t,r){let s=_(r,t==="project");return(0,ke.join)(s,e)}};function $n(n,e,t){if(!n||typeof n!="object")return;let r=n,s=r.hooks&&typeof r.hooks=="object"&&!Array.isArray(r.hooks)?r.hooks:r;for(let[i,a]of Object.entries(s))if(!(i==="name"||i==="description")&&Array.isArray(a)){e[i]||(e[i]=[]);for(let o of a){let l=t&&typeof o=="object"&&o!==null?{...o,_sc:t}:o;e[i].push(l)}}}function Gt(n,e,t){let r={};if((0,L.existsSync)(n))try{r=JSON.parse((0,L.readFileSync)(n,"utf-8"))}catch{r={}}let s=typeof r.hooks=="object"&&r.hooks&&!Array.isArray(r.hooks)?r.hooks:{};if(t)for(let[i,a]of Object.entries(s))Array.isArray(a)&&(s[i]=a.filter(o=>!o||typeof o!="object"||o._sc!==t),s[i].length===0&&delete s[i]);for(let[i,a]of Object.entries(e)){Array.isArray(s[i])||(s[i]=[]);for(let o of a){let l=t&&typeof o=="object"&&o!==null?{...o,_sc:t}:o,c=JSON.stringify(l);s[i].some(u=>JSON.stringify(u)===c)||s[i].push(l)}}r.hooks=s,(0,L.mkdirSync)((0,ke.dirname)(n),{recursive:!0}),(0,L.writeFileSync)(n,JSON.stringify(r,null,2)+`
32
+ `,"utf-8")}function Jt(n,e){if(!(0,L.existsSync)(n))return!1;let t;try{t=JSON.parse((0,L.readFileSync)(n,"utf-8"))}catch{return!1}let r=typeof t.hooks=="object"&&t.hooks&&!Array.isArray(t.hooks)?t.hooks:null;if(!r)return!1;let s=!1;for(let[i,a]of Object.entries(r)){if(!Array.isArray(a))continue;let o=a.filter(l=>!l||typeof l!="object"||l._sc!==e);o.length!==a.length&&(s=!0,o.length===0?delete r[i]:r[i]=o)}return s&&(t.hooks=r,(0,L.writeFileSync)(n,JSON.stringify(t,null,2)+`
33
+ `,"utf-8")),s}function Rn(n,e){let t={};if((0,L.existsSync)(n))try{t=JSON.parse((0,L.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,L.mkdirSync)((0,ke.dirname)(n),{recursive:!0}),(0,L.writeFileSync)(n,JSON.stringify(t,null,2)+`
34
+ `,"utf-8")}function Tn(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var J=require("fs"),Oe=require("path");var In={SessionStart:"SessionStart",PreToolUse:"BeforeTool",PostToolUse:"AfterTool",Stop:"AfterAgent",UserPromptSubmit:"BeforeAgent",PreCompact:"PreCompress"},tt=class{buildFiles(e){let t=[],r=[],s=[],i={},a={};for(let o of e.files){let l=o.path.split("/"),c=l[0];if(c==="agents")s.push({path:o.path.slice(7),content:o.content});else if(c==="mcps"){if(o.path.endsWith(".json"))try{let p=JSON.parse(o.content);if(p.mcpServers&&typeof p.mcpServers=="object")Object.assign(i,p.mcpServers);else if(o.path.includes("resources/")){let u=l.indexOf("resources"),d=u>0?l[u-1]:l[1];i[d]=p}}catch{t.push(`Failed to parse MCP config: ${o.path}`)}}else if(c==="hooks"){if(o.path.endsWith(".json"))try{let p=JSON.parse(o.content);jn(p,a)}catch{t.push(`Failed to parse hook config: ${o.path}`)}}else c==="skills"||c==="commands"||c==="files"?r.push({path:o.path.slice(c.length+1),content:o.content}):r.push(o)}return{mainFiles:r,agentFiles:s,mcpEntries:i,hookEntries:a,customFiles:[],warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=e.resource.slug||e.resource.id,o=_(r,i),l=Nn(e),c=(0,Oe.join)(o,...l),p=0;if(s.mainFiles.length>0){let u=s.mainFiles.filter(b=>!b.path.includes("/")),d=s.mainFiles.filter(b=>b.path.includes("/"));u.length>0&&($(c,u),p+=u.length),d.length>0&&($(o,d),p+=d.length)}if(s.agentFiles.length>0){let u=U(r,i);$(u,s.agentFiles),p+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&Dn(G(r,i),s.mcpEntries),Object.keys(s.hookEntries).length>0&&Fn(ie(r,i),s.hookEntries),{installDir:c,filesWritten:p,warnings:s.warnings}}async uninstall(e,t,r){let s=[],a=_(r,t==="project"),o=(0,Oe.join)(a,e),l=!1;return(0,J.existsSync)(o)&&((0,J.rmSync)(o,{recursive:!0,force:!0}),l=!0),l||s.push(`Collection directory not found at ${o}`),{removed:l,warnings:s}}describeLocation(e,t,r){let s=_(r,t==="project");return(0,Oe.join)(s,e)}};function jn(n,e){if(!n||typeof n!="object")return;let t=n,r=t.hooks&&typeof t.hooks=="object"&&!Array.isArray(t.hooks)?t.hooks:t;for(let[s,i]of Object.entries(r)){if(s==="name"||s==="description"||!Array.isArray(i))continue;let a=In[s]||s;e[a]||(e[a]=[]);for(let o of i)e[a].push(o)}}function Fn(n,e){let t={};if((0,J.existsSync)(n))try{t=JSON.parse((0,J.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.hooks=="object"&&t.hooks&&!Array.isArray(t.hooks)?t.hooks:{};for(let[s,i]of Object.entries(e)){Array.isArray(r[s])||(r[s]=[]);for(let a of i){let o=JSON.stringify(a);r[s].some(c=>JSON.stringify(c)===o)||r[s].push(a)}}t.hooks=r,(0,J.mkdirSync)((0,Oe.dirname)(n),{recursive:!0}),(0,J.writeFileSync)(n,JSON.stringify(t,null,2)+`
35
+ `,"utf-8")}function Dn(n,e){let t={};if((0,J.existsSync)(n))try{t=JSON.parse((0,J.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,J.mkdirSync)((0,Oe.dirname)(n),{recursive:!0}),(0,J.writeFileSync)(n,JSON.stringify(t,null,2)+`
36
+ `,"utf-8")}function Nn(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var W=require("fs"),de=require("path");var rt=class{buildFiles(e){let t=[],r=[],s=[],i={},a=[],o=e.resource.slug||e.resource.id;for(let l of e.files){let c=l.path.split("/"),p=c[0];if(p==="agents")s.push({path:l.path.slice(7),content:l.content});else if(p==="mcps"){if(l.path.endsWith(".json"))try{let u=JSON.parse(l.content);if(u.mcpServers&&typeof u.mcpServers=="object")Object.assign(i,u.mcpServers);else if(l.path.includes("resources/")){let d=c.indexOf("resources"),b=d>0?c[d-1]:c[1];i[b]=u}}catch{t.push(`Failed to parse MCP config: ${l.path}`)}}else p==="hooks"?t.push(`Hooks are not supported by Cursor (skipped: ${l.path})`):p==="skills"||p==="commands"||p==="files"?r.push({path:l.path.slice(p.length+1),content:l.content}):r.push(l)}return{mainFiles:r,agentFiles:s,mcpEntries:i,hookEntries:{},customFiles:a,warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=_(r,i),o=Hn(e),l=(0,de.join)(a,...o),c=0;if(s.mainFiles.length>0){let p=s.mainFiles.filter(d=>!d.path.includes("/")),u=s.mainFiles.filter(d=>d.path.includes("/"));p.length>0&&($(l,p),c+=p.length),u.length>0&&($(a,u),c+=u.length)}if(s.agentFiles.length>0){let p=U(r,i);$(p,s.agentFiles),c+=s.agentFiles.length}for(let p of s.customFiles)(0,W.mkdirSync)((0,de.dirname)(p.absolutePath),{recursive:!0}),(0,W.writeFileSync)(p.absolutePath,p.content,"utf-8"),c++;return Object.keys(s.mcpEntries).length>0&&Mn(G(r,i),s.mcpEntries),{installDir:l,filesWritten:c,warnings:s.warnings}}async uninstall(e,t,r){let s=[],a=_(r,t==="project"),o=(0,de.join)(a,e),l=!1;(0,W.existsSync)(o)&&((0,W.rmSync)(o,{recursive:!0,force:!0}),l=!0);let c=(0,de.join)(homedir(),".cursor","rules");if((0,W.existsSync)(c))try{let p=(0,W.readdirSync)(c);for(let u of p)u.startsWith(`${e}-`)&&u.endsWith(".mdc")&&((0,W.unlinkSync)((0,de.join)(c,u)),l=!0)}catch{s.push("Could not clean up Cursor rules")}return l||s.push(`Collection not found for Cursor at ${o}`),{removed:l,warnings:s}}describeLocation(e,t,r){let s=_(r,t==="project");return(0,de.join)(s,e)}};function Mn(n,e){let t={};if((0,W.existsSync)(n))try{t=JSON.parse((0,W.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,W.mkdirSync)((0,de.dirname)(n),{recursive:!0}),(0,W.writeFileSync)(n,JSON.stringify(t,null,2)+`
37
+ `,"utf-8")}function Hn(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var it=require("fs"),st=require("path");var nt=class{buildFiles(e){let t=[],r=[],s=[];for(let i of e.files){let o=i.path.split("/")[0];o==="agents"?s.push({path:i.path.slice(7),content:i.content}):o==="mcps"?t.push(`MCP servers are not yet supported by Codex adapter (skipped: ${i.path})`):o==="hooks"?t.push(`Hooks are not supported by Codex (skipped: ${i.path})`):o==="commands"?t.push(`Commands are not supported by Codex (skipped: ${i.path})`):o==="skills"||o==="files"?r.push({path:i.path.slice(o.length+1),content:i.content}):r.push(i)}return{mainFiles:r,agentFiles:s,mcpEntries:{},hookEntries:{},customFiles:[],warnings:t}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=_(r,i),o=Ln(e),l=(0,st.join)(a,...o),c=0;if(s.mainFiles.length>0){let p=s.mainFiles.filter(d=>!d.path.includes("/")),u=s.mainFiles.filter(d=>d.path.includes("/"));p.length>0&&($(l,p),c+=p.length),u.length>0&&($(a,u),c+=u.length)}if(s.agentFiles.length>0){let p=U(r,i);$(p,s.agentFiles),c+=s.agentFiles.length}return{installDir:l,filesWritten:c,warnings:s.warnings}}async uninstall(e,t,r){let s=[],a=_(r,t==="project"),o=(0,st.join)(a,e),l=!1;return(0,it.existsSync)(o)&&((0,it.rmSync)(o,{recursive:!0,force:!0}),l=!0),l||s.push(`Collection directory not found at ${o}`),{removed:l,warnings:s}}describeLocation(e,t,r){let s=_(r,t==="project");return(0,st.join)(s,e)}};function Ln(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}var oe=require("fs"),Pe=require("path");var ot=class{buildFiles(e){let t=[],r=[],s={};for(let i of e.files){let a=i.path.split("/"),o=a[0];if(o==="agents")r.push({path:i.path.slice(7),content:i.content});else if(o==="mcps"){if(i.path.endsWith(".json"))try{let l=JSON.parse(i.content);if(l.mcpServers&&typeof l.mcpServers=="object")Object.assign(s,l.mcpServers);else if(i.path.includes("resources/")){let c=a.indexOf("resources"),p=c>0?a[c-1]:a[1];s[p]=l}}catch{}}else o==="skills"||o==="commands"||o==="hooks"||o==="files"?t.push({path:i.path.slice(o.length+1),content:i.content}):t.push(i)}return{mainFiles:t,agentFiles:r,mcpEntries:s,hookEntries:{},customFiles:[],warnings:[]}}async install(e,t,r){let s=this.buildFiles(e),i=t==="project",a=_(r,i),o=Un(e),l=(0,Pe.join)(a,...o),c=0;if(s.mainFiles.length>0){let p=s.mainFiles.filter(d=>!d.path.includes("/")),u=s.mainFiles.filter(d=>d.path.includes("/"));p.length>0&&($(l,p),c+=p.length),u.length>0&&($(a,u),c+=u.length)}if(s.agentFiles.length>0){let p=U(r,i);$(p,s.agentFiles),c+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&Wn(G(r,i),s.mcpEntries),{installDir:l,filesWritten:c,warnings:s.warnings}}async uninstall(e,t,r){let i=_(r,t==="project"),a=(0,Pe.join)(i,e),o=!1;return(0,oe.existsSync)(a)&&((0,oe.rmSync)(a,{recursive:!0,force:!0}),o=!0),{removed:o,warnings:[]}}describeLocation(e,t,r){let s=_(r,t==="project");return(0,Pe.join)(s,e)}};function Wn(n,e){let t={};if((0,oe.existsSync)(n))try{t=JSON.parse((0,oe.readFileSync)(n,"utf-8"))}catch{t={}}let r=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(r,e),t.mcpServers=r,(0,oe.mkdirSync)((0,Pe.dirname)(n),{recursive:!0}),(0,oe.writeFileSync)(n,JSON.stringify(t,null,2)+`
38
+ `,"utf-8")}function Un(n){let e=n.resource.slug||n.resource.id;return n.resource.storageType==="github"&&n.resource.githubOwner?["external",n.resource.githubOwner,e]:n.resource.orgSlug?[n.resource.orgSlug,e]:[e]}function Ee(n){switch(n.id){case"claude-code":return new et;case"gemini-cli":case"antigravity":return new tt;case"cursor":return new rt;case"codex":return new nt;default:return new ot}}var qr=`---
38
39
  title: Resource Manager
39
40
  description: Search, install, and manage AI resources from the Shared Context library
40
41
  ---
@@ -180,30 +181,30 @@ npx shared-context-ai status # Auth status, detected agents, install
180
181
  \`\`\`
181
182
 
182
183
  **Error codes:** \`NOT_FOUND\`, \`AUTH_MISSING\`, \`NO_AGENTS\`, \`SKILL_NOT_FOUND\`, \`WRITE_FAILED\`, \`API_ERROR\`, \`UNEXPECTED\`
183
- `;var R=require("fs"),$=require("path"),Fr=require("crypto"),En=[{folder:"skills",mainFile:"SKILL.md",resourceType:"skill",canHaveChildren:!0},{folder:"commands",mainFile:null,resourceType:"skill",canHaveChildren:!0},{folder:"hooks",mainFile:"hook.json",resourceType:"hook",canHaveChildren:!1},{folder:"agents",mainFile:null,resourceType:"agent",canHaveChildren:!0},{folder:"mcps",mainFile:"mcp.json",resourceType:"mcp",canHaveChildren:!0},{folder:"collections",mainFile:"README.md",resourceType:"collection",canHaveChildren:!1}],$n=new Set(["py","sh","js","ts","rb","go","rs","bash","zsh"]),Pn=new Set(["json","yaml","yml","toml","xml","csv","txt","env","ini","cfg"]);function Ze(n){let e={name:"",description:"",body:n};if(!n.startsWith(`---
184
+ `;var v=require("fs"),E=require("path"),zr=require("crypto");var at=".context-collection",ct="manifest.json";function Gr(n,e){return{version:1,name:n.name||"Untitled Plugin",description:n.description||void 0,resources:e.map(t=>t.resourceRef),...n.author?{author:typeof n.author=="string"?{name:n.author}:{name:n.author.name||"",url:n.author.url}}:{},...n.homepage?{homepage:n.homepage}:{},...n.license?{license:n.license}:{}}}function Vn(n,e){return{version:1,name:n.name||"Untitled Extension",description:n.description||void 0,resources:e.map(t=>t.resourceRef),...n.author?{author:typeof n.author=="string"?{name:n.author}:{name:n.author.name||"",url:n.author.url}}:{},...n.homepage?{homepage:n.homepage}:{},...n.license?{license:n.license}:{}}}function Bn(n,e){return{version:1,name:n.name||"Untitled Plugin",description:n.description||void 0,resources:e.map(t=>t.resourceRef),...n.author?{author:typeof n.author=="string"?{name:n.author}:{name:n.author.name||"",url:n.author.url}}:{},...n.homepage?{homepage:n.homepage}:{},...n.license?{license:n.license}:{}}}var Yt=[{path:`${at}/${ct}`,converter:()=>{throw new Error("Use parseCollectionManifest for native format")},formatLabel:"Shared Context"},{path:".claude-plugin/plugin.json",converter:Gr,formatLabel:"Claude Plugin"},{path:".claude/plugin.json",converter:Gr,formatLabel:"Claude Plugin"},{path:"gemini-extension.json",converter:Vn,formatLabel:"Gemini Extension"},{path:".cursor-plugin/plugin.json",converter:Bn,formatLabel:"Cursor Plugin"}];var Jr=[{folder:"skills",mainFile:"SKILL.md",resourceType:"skill",canHaveChildren:!0},{folder:"commands",mainFile:null,resourceType:"skill",canHaveChildren:!0},{folder:"hooks",mainFile:"hook.json",resourceType:"hook",canHaveChildren:!1},{folder:"agents",mainFile:null,resourceType:"agent",canHaveChildren:!0},{folder:"mcps",mainFile:"mcp.json",resourceType:"mcp",canHaveChildren:!0},{folder:"collections",mainFile:"README.md",resourceType:"collection",canHaveChildren:!1}],Yr=`${at}/${ct}`,qn=new Set(["py","sh","js","ts","rb","go","rs","bash","zsh"]),Gn=new Set(["json","yaml","yml","toml","xml","csv","txt","env","ini","cfg"]);function Le(n){let e={name:"",description:"",body:n};if(!n.startsWith(`---
184
185
  `)&&!n.startsWith(`---\r
185
186
  `))return e;let t=n.indexOf(`
186
- ---`,3);if(t===-1)return e;let r=n.slice(4,t),s=n.slice(t+4);e.body=s.replace(/^\r?\n/,"").replace(/^\r?\n/,"");let i={},a={},c=new Set(["requires","tools"]),l={},o=r.split(`
187
- `),u=null,p=!1;for(let d=0;d<o.length;d++){let b=o[d];if(u&&/^\s+-\s/.test(b)){let C=b.replace(/^\s+-\s/,"").trim();if(C){let A=Ce(C);p?l[u].push(A):a[u].push(A)}continue}u=null,p=!1;let f=b.indexOf(":");if(f===-1)continue;let y=b.slice(0,f).trim(),h=b.slice(f+1).trim();if(!h&&y&&d+1<o.length&&/^\s+-\s/.test(o[d+1])){u=y,c.has(y)?(p=!0,l[y]=[]):(p=!1,a[y]=[]);continue}y==="name"||y==="title"?e.name=Ce(h):y==="description"?e.description=Ce(h):y==="skill_class"?e.skillClass=Ce(h):y==="service"?e.service=Ce(h):y&&h&&(i[y]=Ce(h))}return l.requires?.length&&(e.requires=l.requires),l.tools?.length&&(e.tools=l.tools),Object.keys(i).length&&(e.fields=i),Object.keys(a).length&&(e.arrayFields=a),e}function Ce(n){let e=n.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")){let t=e.slice(1,-1);return e.startsWith('"')?t.replace(/\\"/g,'"').replace(/\\\\/g,"\\"):t.replace(/''/g,"'")}return e}function Rn(n){let{body:e}=Ze(n);return e.replace(/\r\n/g,`
188
- `).replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function Xe(n){let e=Rn(n);return`sha256:${(0,Fr.createHash)("sha256").update(e,"utf8").digest("hex")}`}function Qe(n){return n.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Oe(n){try{return(0,R.statSync)(n).isDirectory()}catch{return!1}}function Tn(n){try{return(0,R.readdirSync)(n).filter(e=>!e.startsWith(".")&&Oe((0,$.join)(n,e)))}catch{return[]}}function et(n){try{return(0,R.readdirSync)(n).filter(e=>!e.startsWith(".")&&!Oe((0,$.join)(n,e)))}catch{return[]}}function In(n){let e=[],t=(0,$.join)(n,"scripts");if((0,R.existsSync)(t)&&Oe(t))for(let s of et(t)){let i=(0,$.extname)(s).slice(1);$n.has(i)&&e.push({category:"script",extension:i,filename:s,content:(0,R.readFileSync)((0,$.join)(t,s),"utf-8")})}let r=(0,$.join)(n,"resources");if((0,R.existsSync)(r)&&Oe(r))for(let s of et(r)){let i=(0,$.extname)(s).slice(1);Pn.has(i)&&e.push({category:"resource",extension:i,filename:s,content:(0,R.readFileSync)((0,$.join)(r,s),"utf-8")})}return e}function _e(n){let e=[],t=[],r,s=(0,$.join)(n,".claude-plugin","plugin.json");if((0,R.existsSync)(s))try{r=JSON.parse((0,R.readFileSync)(s,"utf-8")).name||void 0}catch{}for(let l of En){let o=(0,$.join)(n,l.folder);if(!(!(0,R.existsSync)(o)||!Oe(o))){if(l.folder==="files"){for(let u of et(o)){if(!u.endsWith(".md"))continue;let p=(0,$.join)(o,u),d=(0,R.readFileSync)(p,"utf-8"),b=Ze(d),f=b.name||(0,$.basename)(u,".md"),y=`files/${(0,$.basename)(u,".md")}`;e.push({importPath:y,resourceType:"file",title:f,description:b.description||null,body:b.body,bodyHash:Xe(d),metadata:{},attachments:[]})}continue}for(let u of Tn(o)){let p=l.mainFile||`${u}.md`,d=(0,$.join)(o,u,p);if(!(0,R.existsSync)(d))continue;let b=(0,R.readFileSync)(d,"utf-8"),f=`${l.folder}/${u}`,y,h,C,A={},x=null;if(l.resourceType==="hook"||l.resourceType==="mcp"){try{let D=JSON.parse(b);y=D.name||Qe(u),h=D.description||null}catch{y=Qe(u),h=null}C=b}else x=Ze(b),y=x.name||Qe(u),h=x.description||null,C=x.body,x.skillClass&&(A.skillClass=x.skillClass),x.service&&(A.service=x.service),x.requires?.length&&(A.requires=x.requires),x.tools?.length&&(A.tools=x.tools),x.fields&&Object.keys(x.fields).length&&(A.fields=x.fields);l.folder==="commands"&&(A.fields||(A.fields={}),A.fields["user-invocable"]="true");let Z=l.canHaveChildren?In((0,$.join)(o,u)):[];e.push({importPath:f,resourceType:l.resourceType,title:y,description:h,body:C,bodyHash:Xe(b),metadata:A,attachments:Z}),l.resourceType==="collection"&&x?.arrayFields?.resources&&t.push({collectionImportPath:f,memberImportPaths:x.arrayFields.resources.map(D=>{let G=D.split("/");return G.length>=3?`${G[0]}/${G[G.length-1]}`:D})})}}}let i=(0,$.join)(n,".mcp.json");if((0,R.existsSync)(i))try{let l=JSON.parse((0,R.readFileSync)(i,"utf-8"));if(l.mcpServers&&typeof l.mcpServers=="object")for(let[o,u]of Object.entries(l.mcpServers)){let p=`mcps/${o}`;if(e.some(f=>f.importPath===p))continue;let d=Qe(o),b=JSON.stringify({name:d,description:`MCP server: ${o}`,mcpServers:{[o]:u}},null,2);e.push({importPath:p,resourceType:"mcp",title:d,description:`MCP server: ${o}`,body:b,bodyHash:Xe(b),metadata:{},attachments:[]})}}catch{}let a=(0,$.join)(n,"files");if((0,R.existsSync)(a)&&Oe(a)&&!e.some(l=>l.resourceType==="file"))for(let l of et(a)){if(!l.endsWith(".md"))continue;let o=(0,$.join)(a,l),u=(0,R.readFileSync)(o,"utf-8"),p=Ze(u),d=p.name||(0,$.basename)(l,".md"),b=`files/${(0,$.basename)(l,".md")}`;e.some(f=>f.importPath===b)||e.push({importPath:b,resourceType:"file",title:d,description:p.description||null,body:p.body,bodyHash:Xe(u),metadata:{},attachments:[]})}return{resources:[...e.filter(l=>l.resourceType!=="collection"),...e.filter(l=>l.resourceType==="collection")],collectionMemberships:t,pluginName:r}}var ke="resource-manager",Dr="Resource Manager",Mt="collections/shared-context/essentials";function jn(n,e){let t=k(n,e),r=(0,Te.join)(t,ke);return(0,tt.mkdirSync)(r,{recursive:!0}),(0,tt.writeFileSync)((0,Te.join)(r,"SKILL.md"),jr,"utf-8"),(0,Te.join)(r,"SKILL.md")}var Fn={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Mr(n){n.command("init").description("Initialize Shared Context CLI for your agent").option("--code <code>","Auth code from the web app").action(async(e,t)=>{let r={...e,...t.optsWithGlobals()};if(r.code){let{post:o}=await Promise.resolve().then(()=>(U(),Pr)),{saveAuth:u}=await Promise.resolve().then(()=>(q(),$r)),p=await o("/api/cli/auth",{code:r.code});p.ok||(g()?w("init",p.error.code,p.error.message):S(`Auth failed: ${p.error.message}`),process.exit(1)),u({token:p.data.token,email:p.data.user.email,orgId:p.data.org.id,orgSlug:p.data.org.slug,orgName:p.data.org.name,createdAt:new Date().toISOString()}),g()||m(`Authenticated as ${p.data.user.email}`)}else E()||(g()?(w("init","AUTH_MISSING","Not authenticated. Run 'shared-context-ai login' first or pass --code."),process.exit(1)):(S("Not authenticated. Run 'shared-context-ai login' first or pass --code <code>."),process.exit(1)));let s=te(r.agent);if(!s){let o=re();g()?w("init","NO_AGENTS",o):S(o),process.exit(1)}let i=ee();if(i?.token){let o=(await import("os")).hostname(),u=await P("/api/cli/register-agent",{platform:s.platform,name:`CLI (${o})`});!u.ok&&!g()&&S(`Warning: Could not register agent connection: ${u.error.message}`)}let a=!1,c=[];if(i?.token)try{let o=await I(`/api/cli/resource/${Mt}`);if(o.ok){let u=o.data,d=await xe(s).install(u,r.project?"project":"user",s),b={"claude-code":"claude-plugin","gemini-cli":"gemini-extension",antigravity:"gemini-extension",cursor:"cursor",codex:"codex"};if(X({resourceId:u.resource.id,slug:u.resource.slug||"essentials",installPath:Mt,title:u.resource.title,sha:u.resource.latestSha||"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString(),pluginFormat:b[s.id]||"directory",memberCount:u.memberResources?.length}),u.resource.latestSha&&await P("/api/cli/install",{resourceId:u.resource.id,agentPlatform:s.platform,installedSha:u.resource.latestSha}).catch(()=>{}),u.memberResources)for(let f of u.memberResources){let y=f.slug||f.id,h=Fn[f.resourceType]||f.resourceType+"s",C=f.orgSlug||u.resource.orgSlug,A=C?`${h}/${C}/${y}`:`${h}/${y}`;X({resourceId:f.id,slug:y,installPath:A,title:f.title,sha:f.latestSha||"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString(),collectionId:u.resource.id}),c.push({title:f.title,resourceType:f.resourceType}),f.latestSha&&await P("/api/cli/install",{resourceId:f.id,agentPlatform:s.platform,installedSha:f.latestSha}).catch(()=>{})}if(a=!0,!g()&&d.warnings.length>0)for(let f of d.warnings)S(`Warning: ${f}`)}}catch{}if(!a&&(jn(s,!!r.project),X({resourceId:"resource-manager",slug:ke,installPath:`skills/${ke}`,title:Dr,sha:"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString()}),i?.token))try{let o=`skills/shared-context/${ke}`,u=await I(`/api/cli/resource/${o}`);if(u.ok&&u.data.resource){let p=u.data.resource;p.latestSha&&await P("/api/cli/install",{resourceId:p.id,agentPlatform:s.platform,installedSha:p.latestSha}),X({resourceId:p.id,slug:p.slug||ke,installPath:`skills/shared-context/${p.slug||ke}`,title:p.title||Dr,sha:p.latestSha||"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString()})}}catch{}let l=[];if(i?.token)try{let o=(0,Te.join)((0,Nr.homedir)(),s.dir),u=_e(o),p=V(),d=new Set(p.installations.map(y=>y.installPath)),b=new Set(["resource-manager",".claude-plugin"]),f=u.resources.filter(y=>{if(d.has(y.importPath)||y.importPath.startsWith("."))return!1;let h=y.importPath.split("/").pop()||"";return!b.has(h)});if(f.length>0){let h=await P("/api/cli/import",{dryRun:!1,onConflict:"auto",visibility:"org",resources:f,collectionMemberships:[]},12e4);h.ok&&(l=[...h.data.created,...h.data.updated,...h.data.installed].map(A=>({resourceType:A.resourceType||A.importPath.split("/")[0]?.replace(/s$/,"")||"unknown",slug:A.slug||A.importPath.split("/").pop()||"",title:A.importPath.split("/").pop()||""})))}Re({lastSyncAt:new Date().toISOString(),lastResult:{updatesAvailable:0,untrackedResources:0}})}catch{}if(g())_("init",{agent:s.id,collection:a?Mt:void 0,resourceManagerOnly:!a,...a?{membersInstalled:c.map(o=>({title:o.title,resourceType:o.resourceType}))}:{},...l.length>0?{importedResources:l.map(o=>({resourceType:o.resourceType,slug:o.slug,title:o.title}))}:{},authenticated:E()});else{if(m(""),a){m(`Shared Context Essentials installed for ${s.label} (${c.length} resources)`);let o={};for(let p of c)o[p.resourceType]||(o[p.resourceType]=[]),o[p.resourceType].push(p.title);let u={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections"};m("");for(let[p,d]of Object.entries(o)){let b=u[p]||p;m(` ${b}: ${d.join(", ")}`)}}else m(`Shared Context initialized for ${s.label}`),m("Resource Manager installed");if(l.length>0){m(""),m(`Imported ${l.length} existing resource${l.length===1?"":"s"}:`);for(let o of l)m(` ${o.resourceType.padEnd(12)} ${o.slug.padEnd(24)} ${o.title}`)}m(""),m("Quick reference:"),m(' shared-context-ai search "query" Search for resources'),m(" shared-context-ai install <installPath> Install a resource"),m(" shared-context-ai list List installed resources"),m(" shared-context-ai sync Check updates & discover resources"),m(" shared-context-ai preview <installPath> Preview before installing")}})}var hs=require("http"),fs=require("crypto");q();U();q();async function gs(n){let e=await P("/api/cli/auth",{code:n});return e.ok?(Pt({token:e.data.token,email:e.data.user.email,orgId:e.data.org.id,orgSlug:e.data.org.slug,orgName:e.data.org.name,createdAt:new Date().toISOString()}),g()?_("login",{email:e.data.user.email,org:e.data.org.slug}):m(`Logged in as ${e.data.user.email} (org: ${e.data.org.name})`),!0):(g()?w("login",e.error.code,e.error.message):S(`Login failed: ${e.error.message}`),!1)}async function Qn(){let n=(0,fs.randomBytes)(16).toString("hex");return new Promise(e=>{let t=(0,hs.createServer)((r,s)=>{let i=new URL(r.url||"/","http://localhost"),a=i.searchParams.get("code"),c=i.searchParams.get("state");if(!a||c!==n){s.writeHead(400,{"Content-Type":"text/html"}),s.end("<h1>Authentication failed</h1><p>Invalid state. Please try again.</p>"),t.close(),e(!1);return}s.writeHead(200,{"Content-Type":"text/html"}),s.end("<h1>Authentication successful!</h1><p>You can close this tab and return to your terminal.</p>"),t.close(),gs(a).then(e)});t.listen(0,"127.0.0.1",async()=>{let r=t.address();if(!r||typeof r=="string"){t.close(),e(!1);return}let s=r.port,a=`${le().apiBase||"https://sharedcontext.ai"}/cli/login?port=${s}&state=${n}`;g()||(m("Opening browser for authentication..."),m(`If the browser doesn't open, visit: ${a}`));try{let c=(await Promise.resolve().then(()=>(ds(),ms))).default;await c(a)}catch{g()||m(`Could not open browser. Please visit:
189
- ${a}`)}setTimeout(()=>{t.close(),g()||S("Login timed out after 5 minutes."),e(!1)},300*1e3)})})}function ys(n){n.command("login").description("Authenticate with Shared Context").option("--code <code>","Use an auth code directly (skip browser)").action(async e=>{let t;e.code?t=await gs(e.code):t=await Qn(),process.exit(t?0:1)})}U();var Zn={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function bs(n){let e=Zn[n.resourceType]||n.resourceType+"s";return n.storageType==="github"&&n.githubOwner?`${e}/external/${n.githubOwner}/${n.slug}`:n.orgSlug?`${e}/${n.orgSlug}/${n.slug}`:`${e}/${n.slug}`}function Ss(n){n.command("search <query>").description("Search for skills in the library").option("--type <type>","Filter by resource type (skill, command, hook, collection, agent, mcp, file)").option("--tag <tag>","Filter by topic tag").option("--limit <n>","Max results","20").action(async(e,t)=>{let r=new URLSearchParams({q:e});t.type&&r.set("type",t.type),t.tag&&r.set("tag",t.tag),t.limit&&r.set("limit",t.limit);let s=E()?`/api/cli/search?${r}`:`/api/public/search?${r}`,i=await I(s);i.ok||(g()?w("search",i.error.code,i.error.message):m(`Search failed: ${i.error.message}`),process.exit(1));let a=i.data.results;if(g()){let l=a.map(o=>{let u=bs(o);return{installPath:u,installCommand:`npx shared-context-ai install ${u}`,title:o.title,description:o.description,resourceType:o.resourceType,installCount:o.installCount,topicTags:o.topicTags}});_("search",{results:l,count:l.length});return}if(a.length===0){let l=t.type?`${t.type}s`:"results";m(`No ${l} found.`);return}m(`Found ${a.length} result${a.length===1?"":"s"}:
190
- `);let c=a.map(l=>[bs(l),l.title,`\u2193${l.installCount}`]);m(K(c)),m(`
191
- Install a skill: npx shared-context-ai install <installPath>`)})}U();q();function ws(n){let e=n.slug||n.resourceId;return n.storageType==="github"&&n.githubOwner?`skills/external/${n.githubOwner}/${e}`:n.orgSlug?`skills/${n.orgSlug}/${e}`:`skills/${e}`}function xs(n){n.command("list").description("List installed skills").alias("ls").action(async()=>{if(E()){let e=await I("/api/cli/installed");e.ok||(g()?w("list",e.error.code,e.error.message):m(`Failed to fetch installations: ${e.error.message}`),process.exit(1));let t=e.data.installations;if(g()){let s=t.map(i=>({...i,installPath:ws(i)}));_("list",{installations:s,count:s.length});return}if(t.length===0){m("No skills installed."),m("Use 'shared-context-ai search' to find skills to install.");return}m(`${t.length} skill${t.length===1?"":"s"} installed:
192
- `);let r=t.map(s=>[ws(s),s.title,s.hasUpdate?"(update available)":"(current)"]);m(K(r))}else{let t=V().installations;if(g()){_("list",{installations:t,count:t.length});return}if(t.length===0){m("No skills installed locally.");return}m(`${t.length} skill${t.length===1?"":"s"} installed locally:
193
- `);let r=t.map(s=>[s.installPath||s.slug,s.title,`(${s.agent})`]);m(K(r)),m(`
194
- Tip: Run 'shared-context-ai login' to sync with sharedcontext.ai and check for updates.`)}})}U();function As(n){n.command("preview <path>").description("Preview a skill's content (e.g., skills/acme/api-testing)").action(async e=>{let r=E()?"/api/cli/resource":"/api/public/resource",s=await I(`${r}/${e}/preview`);s.ok||(g()?w("preview",s.error.code,s.error.message):S(`Preview failed: ${s.error.message}`),process.exit(1)),g()?_("preview",s.data):m(s.data.content)})}U();function Cs(n){n.command("check").description("Check for skill updates").action(async()=>{E()||(g()?w("check","AUTH_MISSING","Login required to check for updates."):S("Login required to check for updates. Run 'shared-context-ai login'."),process.exit(1));let e=await I("/api/cli/updates");e.ok||(g()?w("check",e.error.code,e.error.message):S(`Check failed: ${e.error.message}`),process.exit(1));let{updates:t,count:r}=e.data;if(g()){_("check",{updates:t,count:r});return}if(r===0){m("All skills are up to date.");return}m(`${r} update${r===1?"":"s"} available:
195
- `);let s=t.map(i=>{let a=i.slug||i.resourceId;return[i.storageType==="github"&&i.githubOwner?`skills/external/${i.githubOwner}/${a}`:i.orgSlug?`skills/${i.orgSlug}/${a}`:`skills/${a}`,i.title,`${i.installedSha.slice(0,7)} \u2192 ${i.latestSha.slice(0,7)}`]});m(K(s)),m(`
196
- Run 'shared-context-ai update' to update all, or 'shared-context-ai update <installPath>' to update one.`)})}var ir=require("path");U();q();var ei={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Os(n){let e=n.slug||n.resourceId,t=ei[n.resourceType]||n.resourceType+"s";return n.storageType==="github"&&n.githubOwner?`${t}/external/${n.githubOwner}/${e}`:n.orgSlug?`${t}/${n.orgSlug}/${e}`:`${t}/${e}`}function _s(n){n.command("update [path]").description("Update installed resources (all or by install path)").action(async(e,t,r)=>{let s=r.optsWithGlobals();E()||(g()?w("update","AUTH_MISSING","Login required to update resources."):S("Login required to update resources. Run 'shared-context-ai login'."),process.exit(1));let i=te(s.agent);if(!i){let o=re();g()?w("update","NO_AGENTS",o):S(o),process.exit(1)}let a=await I("/api/cli/updates");a.ok||(g()?w("update",a.error.code,a.error.message):S(`Failed to check updates: ${a.error.message}`),process.exit(1));let c=a.data.updates;if(e&&(c=c.filter(o=>Os(o)===e||o.slug===e||o.resourceId===e),c.length===0)){g()?w("update","SKILL_NOT_FOUND",`No update available for "${e}".`):m(`No update available for "${e}".`);return}if(c.length===0){g()?_("update",{updated:[],count:0}):m("All resources are up to date.");return}let l=[];for(let o of c){let u=Os(o),p=await I(`/api/cli/resource/${u}`);if(!p.ok){g()||S(` Failed to fetch ${u}: ${p.error.message}`);continue}let d=p.data,b=u.split("/").slice(1);if(d.resource.resourceType==="agent"){let f=F(i,!!s.project),y=(0,ir.join)(f,...b);v(y,d.files)}else if(d.resource.resourceType==="mcp")Nt(i,!!s.project,d);else{let f=k(i,!!s.project),y=(0,ir.join)(f,...b);v(y,d.files)}d.resource.latestSha&&await P("/api/cli/update",{resourceId:d.resource.id,installedSha:d.resource.latestSha}),X({resourceId:d.resource.id,slug:d.resource.slug||d.resource.id,installPath:u,title:d.resource.title,sha:d.resource.latestSha||"",scope:s.project?"project":"global",agent:i.id,installedAt:new Date().toISOString()}),l.push({installPath:u,title:d.resource.title}),g()||m(` Updated ${u}`)}g()?_("update",{updated:l,count:l.length}):l.length>0&&m(`
197
- ${l.length} resource${l.length===1?"":"s"} updated.`)})}var T=require("fs"),Ee=require("path");U();q();function ks(n){n.command("uninstall <path>").description("Uninstall a resource by install path (e.g., skills/acme/api-testing)").action(async(e,t,r)=>{let s=r.optsWithGlobals(),i=te(s.agent);if(!i){let b=re();g()?w("uninstall","NO_AGENTS",b):S(b),process.exit(1)}let c=V().installations.find(b=>b.installPath===e||b.slug===e||b.resourceId===e),l=e.split("/"),u=["skills","files","commands","hooks","collections","agents","mcps"].includes(l[0])?l[0]:null,p=u?l.slice(1):l,d=!1;if(u==="collections"){let b=xe(i),f=p[p.length-1],y=s.project?"project":"user",h=await b.uninstall(f,y,i,c?.resourceId);if(d=h.removed,!g())for(let C of h.warnings)S(`Warning: ${C}`);if(c){let A=V().installations.filter(x=>x.collectionId===c.resourceId&&x.agent===i.id);for(let x of A){let Z=x.installPath.split("/"),D=Z[0],G=Z.slice(1);if(D==="agents"){let be=F(i,!!s.project),ie=(0,Ee.join)(be,...G);(0,T.existsSync)(ie)&&(0,T.rmSync)(ie,{recursive:!0,force:!0})}else if(D==="mcps"){let be=G[G.length-1],ie=M(i,!!s.project);if((0,T.existsSync)(ie))try{let Se=JSON.parse((0,T.readFileSync)(ie,"utf-8"));if(typeof Se.mcpServers=="object"&&Se.mcpServers&&!Array.isArray(Se.mcpServers)){let ct=Se.mcpServers;be in ct&&(delete ct[be],Se.mcpServers=ct,(0,T.writeFileSync)(ie,JSON.stringify(Se,null,2)+`
198
- `,"utf-8"))}}catch{}}else{let be=k(i,!!s.project),ie=(0,Ee.join)(be,...G);(0,T.existsSync)(ie)&&(0,T.rmSync)(ie,{recursive:!0,force:!0})}Le(x.resourceId,i.id)}}}else if(u==="agents"){let b=F(i,!!s.project),f=(0,Ee.join)(b,...p);d=(0,T.existsSync)(f),d&&(0,T.rmSync)(f,{recursive:!0,force:!0})}else if(u==="mcps"){let b=p[p.length-1],f=M(i,!!s.project);if((0,T.existsSync)(f))try{let y=JSON.parse((0,T.readFileSync)(f,"utf-8"));if(typeof y.mcpServers=="object"&&y.mcpServers&&!Array.isArray(y.mcpServers)){let h=y.mcpServers;b in h&&(delete h[b],y.mcpServers=h,(0,T.writeFileSync)(f,JSON.stringify(y,null,2)+`
199
- `,"utf-8"),d=!0)}}catch{}}else{let b=k(i,!!s.project),f=(0,Ee.join)(b,...p);if(d=(0,T.existsSync)(f),d&&(0,T.rmSync)(f,{recursive:!0,force:!0}),!d&&c?.slug){let y=(0,Ee.join)(b,c.slug);(0,T.existsSync)(y)&&(0,T.rmSync)(y,{recursive:!0,force:!0})}}if(E()&&c){let b=await P("/api/cli/uninstall",{resourceId:c.resourceId});!b.ok&&!g()&&S(`Warning: Could not record uninstall on server: ${b.error.message}`)}c&&Le(c.resourceId,i.id),g()?_("uninstall",{path:e,removed:!0}):m(`Uninstalled "${e}"`)})}q();function vs(n){n.command("status").description("Show CLI status: auth, agents, installed skill counts").action(async()=>{let e=ee(),t=le(),r=V(),s=Dt(),i={authenticated:!!e?.token,email:e?.email||null,org:e?.orgSlug||null,apiBase:t.apiBase,detectedAgents:s.map(a=>a.id),installedCount:r.installations.length};if(g()){_("status",i);return}m("Shared Context CLI Status"),m("\u2500".repeat(30)),e?.token?m(` Auth: ${e.email} (${e.orgSlug})`):m(" Auth: Not logged in"),m(` API: ${t.apiBase}`),s.length>0?m(` Agents: ${s.map(a=>a.label).join(", ")}`):m(" Agents: None detected"),m(` Skills: ${r.installations.length} installed`)})}q();U();function Es(n){n.command("logout").description("Clear saved credentials").option("--revoke","Also revoke the token on the server").action(async e=>{let t=ee();e.revoke&&E()&&await jt("/api/cli/auth"),Rt(),g()?_("logout",{email:t?.email||null}):m("Logged out.")})}var at=require("fs"),$s=require("path");U();function Ps(n){n.command("import [path]").description("Import resources from a local directory or GitHub URL").option("--github <url>","Import a single resource from a GitHub URL").option("--resource-type <type>","Resource type (skill|command|hook|agent|mcp) \u2014 for GitHub import disambiguation").option("--visibility <level>","Visibility for created resources","org").option("--dry-run","Preview what would happen without making changes",!1).option("--no-recursive","Do not recursively scan subdirectories").option("--tags <tags>","Comma-separated topic tags").option("--on-conflict <strategy>","Conflict resolution strategy (auto|skip|update|clone|error)","auto").action(async(e,t,r)=>{let s=r.optsWithGlobals(),i=t.github;if(i&&e&&(g()?w("import","INVALID_ARGS","Cannot use --github with a local path"):S("Error: Cannot use --github with a local path. Use one or the other."),process.exit(1)),!i&&!e&&(g()?w("import","INVALID_ARGS","Provide a local path or --github <url>"):S("Error: Provide a local path or --github <url>"),process.exit(1)),E()||(g()?w("import","AUTH_MISSING","Authentication required for import"):S("Error: Authentication required. Run 'shared-context-ai login' first."),process.exit(1)),i){t.onConflict&&t.onConflict!=="auto"&&(g()?w("import","INVALID_ARGS","--on-conflict is not supported with --github"):S("Error: --on-conflict is not supported with --github"),process.exit(1)),t.dryRun&&(g()?w("import","INVALID_ARGS","--dry-run is not supported with --github"):S("Error: --dry-run is not supported with --github"),process.exit(1));let f={url:i};t.resourceType&&(f.resourceType=t.resourceType),g()||m(`
200
- Importing from GitHub: ${i}`);let y=await P("/api/cli/github-import",f);y.ok||(g()?w("import",y.error.code,y.error.message):S(`
201
- Import failed: ${y.error.message}`),process.exit(1));let h=y.data;if(g()){_("import",h);return}m(""),m(` Source: ${h.source.owner}/${h.source.repo}`),m(` Type: ${h.resourceType}`),m(` Title: ${h.title}`),h.slug&&m(` Slug: ${h.slug}`),m(` URL: ${h.url}`),m(""),m("Import complete: 1 created");return}let a=(0,$s.resolve)(e);(!(0,at.existsSync)(a)||!(0,at.statSync)(a).isDirectory())&&(g()?w("import","INVALID_PATH",`Not a directory: ${a}`):S(`Error: Not a directory: ${a}`),process.exit(1));let c=_e(a);if(c.resources.length===0){g()?_("import",{resources:[],message:"No resources found"}):m("No resources found in the specified directory.");return}if(!g()){let f=new Map;for(let h of c.resources)f.set(h.resourceType,(f.get(h.resourceType)||0)+1);let y=[...f.entries()].map(([h,C])=>`${C} ${h}${C===1?"":"s"}`).join(", ");m(`
202
- Discovered ${c.resources.length} resources in ${e}:`),m(` ${y}`),c.pluginName&&m(` Plugin: ${c.pluginName}`)}let l=t.tags?t.tags.split(",").map(f=>f.trim()).filter(Boolean):void 0,o={dryRun:!!t.dryRun,onConflict:t.onConflict||"auto",visibility:t.visibility||"org",topicTags:l,resources:c.resources,collectionMemberships:c.collectionMemberships.length>0?c.collectionMemberships:void 0};!g()&&!t.dryRun?m(`
203
- Executing import...`):g()||m(`
204
- Dry run \u2014 previewing changes...`);let u=await P("/api/cli/import",o,12e4);u.ok||(g()?w("import",u.error.code,u.error.message):S(`
205
- Import failed: ${u.error.message}`),process.exit(1));let p=u.data;if(g()){_("import",p);return}let d=[...p.created.map(f=>({...f,action:"created"})),...p.updated.map(f=>({...f,action:"updated"})),...p.installed.map(f=>({...f,action:"installed"})),...p.cloned.map(f=>({...f,action:"cloned"})),...p.skipped.map(f=>({...f,action:"skipped"})),...p.errors.map(f=>({...f,action:"error"}))];if(d.length>0){m("");let f=d.length,y=d.map((h,C)=>{let A=`[${String(C+1).padStart(String(f).length)}/${f}]`,x=(h.resourceType||"").padEnd(10),Z=(h.importPath.split("/").pop()||"").padEnd(24),D="";switch(h.action){case"created":D=`\u2713 created${h.slug?` (slug: ${h.slug})`:""}`;break;case"updated":D="\u2713 updated";break;case"installed":{let G=h.versionsBehind;D=`\u2713 installed${G?` (${G} versions behind)`:""}`;break}case"cloned":D=`\u2713 cloned${h.slug?` (slug: ${h.slug})`:""}`;break;case"skipped":D=`\u2713 skipped (${h.reason||"up to date"})`;break;case"error":D=`\u2717 error: ${h.error||"unknown"}`;break}return` ${A} ${x} ${Z} ${D}`});for(let h of y)m(h)}if(p.collections.length>0)for(let f of p.collections){let y=f.importPath.split("/").pop()||f.importPath;m(` collection ${y.padEnd(20)} \u2713 ${f.membersLinked} members linked${f.membersFailed>0?`, ${f.membersFailed} failed`:""}`)}m("");let b=[p.created.length>0?`${p.created.length} created`:null,p.installed.length>0?`${p.installed.length} installed`:null,p.cloned.length>0?`${p.cloned.length} cloned`:null,p.updated.length>0?`${p.updated.length} updated`:null,p.skipped.length>0?`${p.skipped.length} skipped`:null,p.errors.length>0?`${p.errors.length} errors`:null].filter(Boolean);t.dryRun?m(`Dry run complete: ${b.join(", ")}`):m(`Import complete: ${b.join(", ")}`),p.errors.length>0&&process.exit(1)})}var Is=require("path"),js=require("os");U();q();function Fs(n){n.command("sync").description("Synchronize resource state \u2014 check for updates and discover untracked resources").option("--quiet","Minimal output (one-line summary)").option("--force","Bypass throttle and sync now").option("--import","Auto-import untracked resources to your dashboard").action(async(e,t)=>{let r={...e,...t.optsWithGlobals()};if(!r.force&&!It()){let y=We();if(y){let h={...y.lastResult,updates:[],untracked:[],summary:Rs(y.lastResult.updatesAvailable,y.lastResult.untrackedResources),throttled:!0};Ts(h,!!r.quiet);return}}E()||(g()?w("sync","AUTH_MISSING","Login required to sync."):S("Login required. Run 'shared-context-ai login'."),process.exit(1));let s=te(r.agent);if(!s){let y=re();g()?w("sync","NO_AGENTS",y):S(y),process.exit(1)}let i=[],a=await I("/api/cli/updates");a.ok&&(i=a.data.updates);let c=(0,Is.join)((0,js.homedir)(),s.dir),l=_e(c),o=V(),u=new Set(o.installations.map(y=>y.installPath)),p=new Set(["resource-manager",".claude-plugin"]),d=l.resources.filter(y=>{if(u.has(y.importPath)||y.importPath.startsWith("."))return!1;let h=y.importPath.split("/").pop()||"";return!p.has(h)});if(r.import&&d.length>0){let h=await P("/api/cli/import",{dryRun:!1,onConflict:"auto",visibility:"org",resources:d,collectionMemberships:[]},12e4);if(h.ok){let C=[...h.data.created,...h.data.updated,...h.data.installed];if(!g()&&!r.quiet){if(C.length>0){m(`
206
- Imported ${C.length} resource${C.length===1?"":"s"}:`);let A=C.map(x=>[` ${(x.resourceType||"").padEnd(12)}`,(x.slug||x.importPath.split("/").pop()||"").padEnd(24),x.importPath]);m(K(A))}h.data.errors.length>0&&S(`
207
- ${h.data.errors.length} import error(s)`)}d.length=0}else g()||S(`Import failed: ${h.error.message}`)}let b={updatesAvailable:i.length,untrackedResources:d.length};Re({lastSyncAt:new Date().toISOString(),lastResult:b});let f={...b,updates:i,untracked:d.map(y=>({importPath:y.importPath,resourceType:y.resourceType,title:y.title})),summary:Rs(i.length,d.length),throttled:!1};Ts(f,!!r.quiet)})}function Rs(n,e){let t=[];return n>0&&t.push(`${n} update${n===1?"":"s"} available`),e>0&&t.push(`${e} untracked resource${e===1?"":"s"}`),t.length===0?"Everything is up to date.":t.join(", ")}function Ts(n,e){if(g()){_("sync",n);return}if(e){let t=n.summary;n.updatesAvailable>0&&(t+=" \u2014 run 'shared-context-ai update'"),n.untrackedResources>0&&(t+=" \u2014 run 'shared-context-ai sync --import' to import"),m(t);return}if(m(""),n.updates.length>0){m(`${n.updates.length} update${n.updates.length===1?"":"s"} available:
208
- `);let t=n.updates.map(r=>{let s=r.slug||r.resourceId,i=r.resourceType==="skill"?"skills":`${r.resourceType}s`;return[` ${r.storageType==="github"&&r.githubOwner?`${i}/external/${r.githubOwner}/${s}`:r.orgSlug?`${i}/${r.orgSlug}/${s}`:`${i}/${s}`}`,r.title,`${r.installedSha.slice(0,7)} \u2192 ${r.latestSha.slice(0,7)}`]});m(K(t)),m("")}if(n.untracked.length>0){m(`${n.untracked.length} untracked resource${n.untracked.length===1?"":"s"}:
209
- `);let t=n.untracked.map(r=>[` ${r.resourceType.padEnd(12)}`,r.importPath.padEnd(30),r.title]);m(K(t)),m("")}n.updatesAvailable===0&&n.untrackedResources===0?m("Everything is up to date."):(n.updatesAvailable>0&&m("Run 'shared-context-ai update' to update installed resources."),n.untrackedResources>0&&m("Run 'shared-context-ai sync --import' to import untracked resources.")),m("")}var Ds={AUTH_MISSING:"Run 'shared-context-ai login' to authenticate.",AUTH_EXPIRED:"Run 'shared-context-ai login' to re-authenticate.",SKILL_NOT_FOUND:"Check the skill slug and try again.",ALREADY_INSTALLED:"Use 'shared-context-ai update <slug>' to update instead.",NO_AGENTS:"No AI coding agents detected. Run 'shared-context-ai init --agent <name>' to set up manually.",API_ERROR:"The server returned an error. Try again later.",WRITE_FAILED:"Could not write files to disk. Check permissions."},lt=class extends Error{constructor(t,r){super(r||Ds[t]);this.code=t;this.name="CliError"}get recovery(){return Ds[this.code]}};var W=new Sr;W.name("shared-context-ai").description("CLI for Shared Context - search, install, and manage AI skills").version("0.1.0").option("--json","Output as JSON (default when piped)").option("--human","Output as human-readable text (default in TTY)").option("--agent <name>","Override agent detection").option("--project","Use project-local directory instead of global").hook("preAction",n=>{let e=n.opts();Ar(!!e.json,!!e.human)});Mr(W);ys(W);Ss(W);Ir(W);xs(W);As(W);Cs(W);_s(W);ks(W);vs(W);Es(W);Ps(W);Fs(W);process.on("uncaughtException",n=>{n instanceof lt?g()?w(process.argv[2]||"unknown",n.code,n.message):(S(`Error: ${n.message}`),S(n.recovery)):g()?w(process.argv[2]||"unknown","UNEXPECTED",n.message||"Unexpected error"):S(`Error: ${n.message||n}`),process.exit(1)});W.parse();
187
+ ---`,3);if(t===-1)return e;let r=n.slice(4,t),s=n.slice(t+4);e.body=s.replace(/^\r?\n/,"").replace(/^\r?\n/,"");let i={},a={},o=new Set(["requires","tools"]),l={},c=r.split(`
188
+ `),p=null,u=!1;for(let d=0;d<c.length;d++){let b=c[d];if(p&&/^\s+-\s/.test(b)){let A=b.replace(/^\s+-\s/,"").trim();if(A){let S=$e(A);u?l[p].push(S):a[p].push(S)}continue}p=null,u=!1;let g=b.indexOf(":");if(g===-1)continue;let f=b.slice(0,g).trim(),m=b.slice(g+1).trim();if(!m&&f&&d+1<c.length&&/^\s+-\s/.test(c[d+1])){p=f,o.has(f)?(u=!0,l[f]=[]):(u=!1,a[f]=[]);continue}f==="name"||f==="title"?e.name=$e(m):f==="description"?e.description=$e(m):f==="skill_class"?e.skillClass=$e(m):f==="service"?e.service=$e(m):f&&m&&(i[f]=$e(m))}return l.requires?.length&&(e.requires=l.requires),l.tools?.length&&(e.tools=l.tools),Object.keys(i).length&&(e.fields=i),Object.keys(a).length&&(e.arrayFields=a),e}function $e(n){let e=n.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")){let t=e.slice(1,-1);return e.startsWith('"')?t.replace(/\\"/g,'"').replace(/\\\\/g,"\\"):t.replace(/''/g,"'")}return e}function Jn(n){let{body:e}=Le(n);return e.replace(/\r\n/g,`
189
+ `).replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function Re(n){let e=Jn(n);return`sha256:${(0,zr.createHash)("sha256").update(e,"utf8").digest("hex")}`}function he(n){return n.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Te(n){try{return(0,v.statSync)(n).isDirectory()}catch{return!1}}function Kr(n){try{return(0,v.readdirSync)(n).filter(e=>!e.startsWith(".")&&Te((0,E.join)(n,e)))}catch{return[]}}function lt(n){try{return(0,v.readdirSync)(n).filter(e=>!e.startsWith(".")&&!Te((0,E.join)(n,e)))}catch{return[]}}function Yn(n){let e=[],t=(0,E.join)(n,"scripts");if((0,v.existsSync)(t)&&Te(t))for(let s of lt(t)){let i=(0,E.extname)(s).slice(1);qn.has(i)&&e.push({category:"script",extension:i,filename:s,content:(0,v.readFileSync)((0,E.join)(t,s),"utf-8")})}let r=(0,E.join)(n,"resources");if((0,v.existsSync)(r)&&Te(r))for(let s of lt(r)){let i=(0,E.extname)(s).slice(1);Gn.has(i)&&e.push({category:"resource",extension:i,filename:s,content:(0,v.readFileSync)((0,E.join)(r,s),"utf-8")})}return e}function Ie(n){let e=[],t=[],r,s;function i(u,d){let b=[],g=[];for(let f of Jr){let m=(0,E.join)(u,f.folder);if(!(0,v.existsSync)(m)||!Te(m))continue;let A=d?`${d}/${f.folder}`:f.folder;if(f.folder==="files"){for(let S of lt(m)){if(!S.endsWith(".md"))continue;let C=(0,E.join)(m,S),N=(0,v.readFileSync)(C,"utf-8"),P=Le(N),V=P.name||(0,E.basename)(S,".md"),I=`${A}/${(0,E.basename)(S,".md")}`;b.push({importPath:I,resourceType:"file",title:V,description:P.description||null,body:P.body,bodyHash:Re(N),metadata:{},attachments:[]})}continue}for(let S of Kr(m)){let C=f.mainFile||`${S}.md`,N=(0,E.join)(m,S,C);if(!(0,v.existsSync)(N))continue;let P=(0,v.readFileSync)(N,"utf-8"),V=`${A}/${S}`,I,M,j,B={},R=null;if(f.resourceType==="hook"||f.resourceType==="mcp"){try{let te=JSON.parse(P);I=te.name||he(S),M=te.description||null}catch{I=he(S),M=null}j=P}else if(f.resourceType==="collection"){let te=(0,E.join)(m,S,at,ct);if((0,v.existsSync)(te))try{let fe=JSON.parse((0,v.readFileSync)(te,"utf-8"));I=fe.name||he(S),M=fe.description||null,j=P,fe.resources&&Array.isArray(fe.resources)&&g.push({collectionImportPath:V,memberImportPaths:fe.resources.map(Ae=>{let qe=Ae.split("/");return qe.length>=3?`${qe[0]}/${qe[qe.length-1]}`:Ae})})}catch{I=he(S),M=null,j=P}else R=Le(P),I=R.name||he(S),M=R.description||null,j=R.body,R.arrayFields?.resources&&g.push({collectionImportPath:V,memberImportPaths:R.arrayFields.resources.map(fe=>{let Ae=fe.split("/");return Ae.length>=3?`${Ae[0]}/${Ae[Ae.length-1]}`:fe})})}else R=Le(P),I=R.name||he(S),M=R.description||null,j=R.body,R.skillClass&&(B.skillClass=R.skillClass),R.service&&(B.service=R.service),R.requires?.length&&(B.requires=R.requires),R.tools?.length&&(B.tools=R.tools),R.fields&&Object.keys(R.fields).length&&(B.fields=R.fields);f.folder==="commands"&&(B.fields||(B.fields={}),B.fields["user-invocable"]="true");let Be=f.canHaveChildren?Yn((0,E.join)(m,S)):[];b.push({importPath:V,resourceType:f.resourceType,title:I,description:M,body:j,bodyHash:Re(P),metadata:B,attachments:Be})}}return{resources:b,memberships:g}}let a=i(n,"");e.push(...a.resources),t.push(...a.memberships);let o=(0,E.join)(n,".mcp.json");if((0,v.existsSync)(o))try{let u=JSON.parse((0,v.readFileSync)(o,"utf-8"));if(u.mcpServers&&typeof u.mcpServers=="object")for(let[d,b]of Object.entries(u.mcpServers)){let g=`mcps/${d}`;if(e.some(A=>A.importPath===g))continue;let f=he(d),m=JSON.stringify({name:f,description:`MCP server: ${d}`,mcpServers:{[d]:b}},null,2);e.push({importPath:g,resourceType:"mcp",title:f,description:`MCP server: ${d}`,body:m,bodyHash:Re(m),metadata:{},attachments:[]})}}catch{}for(let u of Yt){if(u.path===Yr)continue;let d=(0,E.join)(n,u.path);if((0,v.existsSync)(d)){try{let b=JSON.parse((0,v.readFileSync)(d,"utf-8"));if(r=r||b.name||void 0,s=u.formatLabel,!e.some(g=>g.resourceType==="collection")){let g=e.filter(C=>C.resourceType!=="collection").map(C=>({resourceRef:C.importPath})),f=u.converter(b,g),m=(0,E.join)(n,"README.md"),A=(0,v.existsSync)(m)?(0,v.readFileSync)(m,"utf-8"):"",S="collections/_root";e.push({importPath:S,resourceType:"collection",title:he(f.name),description:f.description||null,body:A,bodyHash:Re(A),metadata:{},attachments:[],manifestMetadata:{...f.author?{author:f.author}:{},...f.homepage?{homepage:f.homepage}:{},...f.license?{license:f.license}:{}}}),f.resources.length>0&&t.push({collectionImportPath:S,memberImportPaths:f.resources})}}catch{}break}}{let b=function(g,f,m){if(!(m>4))for(let A of Kr(g)){if(d.has(A))continue;let S=(0,E.join)(g,A),C=f?`${f}/${A}`:A;for(let N of Yt){if(N.path===Yr)continue;let P=(0,E.join)(S,N.path);if((0,v.existsSync)(P)){if(u.has(C))break;u.add(C);try{let V=JSON.parse((0,v.readFileSync)(P,"utf-8")),I=i(S,C);if(I.resources.length===0)break;e.push(...I.resources),t.push(...I.memberships);let M=I.resources.filter(te=>te.resourceType!=="collection").map(te=>({resourceRef:te.importPath})),j=N.converter(V,M),B=(0,E.join)(S,"README.md"),R=(0,v.existsSync)(B)?(0,v.readFileSync)(B,"utf-8"):"",Be=`${C}/_collection`;e.push({importPath:Be,resourceType:"collection",title:he(j.name),description:j.description||null,body:R,bodyHash:Re(R),metadata:{},attachments:[],manifestMetadata:{...j.author?{author:j.author}:{},...j.homepage?{homepage:j.homepage}:{},...j.license?{license:j.license}:{}}}),t.push({collectionImportPath:Be,memberImportPaths:I.resources.map(te=>te.importPath)}),r||(r=V.name||void 0),s||(s=N.formatLabel)}catch{}break}}b(S,C,m+1)}};var p=b;let u=new Set,d=new Set(Jr.map(g=>g.folder));b(n,"",0)}let l=(0,E.join)(n,"files");if((0,v.existsSync)(l)&&Te(l)&&!e.some(u=>u.resourceType==="file"))for(let u of lt(l)){if(!u.endsWith(".md"))continue;let d=(0,E.join)(l,u),b=(0,v.readFileSync)(d,"utf-8"),g=Le(b),f=g.name||(0,E.basename)(u,".md"),m=`files/${(0,E.basename)(u,".md")}`;e.some(A=>A.importPath===m)||e.push({importPath:m,resourceType:"file",title:f,description:g.description||null,body:g.body,bodyHash:Re(b),metadata:{},attachments:[]})}return{resources:[...e.filter(u=>u.resourceType!=="collection"),...e.filter(u=>u.resourceType==="collection")],collectionMemberships:t,pluginName:r,formatLabel:s}}var je="resource-manager",Xr="Resource Manager",Kt="collections/shared-context/essentials";function Kn(n,e){let t=_(n,e),r=(0,We.join)(t,je);return(0,ut.mkdirSync)(r,{recursive:!0}),(0,ut.writeFileSync)((0,We.join)(r,"SKILL.md"),qr,"utf-8"),(0,We.join)(r,"SKILL.md")}var zn={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Zr(n){n.command("init").description("Initialize Shared Context CLI for your agent").option("--code <code>","Auth code from the web app").action(async(e,t)=>{let r={...e,...t.optsWithGlobals()};if(r.code){let{post:c}=await Promise.resolve().then(()=>(z(),Wr)),{saveAuth:p}=await Promise.resolve().then(()=>(Q(),Lr)),u=await c("/api/cli/auth",{code:r.code});u.ok||(y()?x("init",u.error.code,u.error.message):w(`Auth failed: ${u.error.message}`),process.exit(1)),p({token:u.data.token,email:u.data.user.email,orgId:u.data.org.id,orgSlug:u.data.org.slug,orgName:u.data.org.name,createdAt:new Date().toISOString()}),y()||h(`Authenticated as ${u.data.user.email}`)}else T()||(y()?(x("init","AUTH_MISSING","Not authenticated. Run 'shared-context-ai login' first or pass --code."),process.exit(1)):(w("Not authenticated. Run 'shared-context-ai login' first or pass --code <code>."),process.exit(1)));let s=ce(r.agent);if(!s){let c=le();y()?x("init","NO_AGENTS",c):w(c),process.exit(1)}let i=ae();if(i?.token){let c=(await import("os")).hostname(),p=await F("/api/cli/register-agent",{platform:s.platform,name:`CLI (${c})`});!p.ok&&!y()&&w(`Warning: Could not register agent connection: ${p.error.message}`)}let a=!1,o=[];if(i?.token)try{let c=await H(`/api/cli/resource/${Kt}`);if(c.ok){let p=c.data,d=await Ee(s).install(p,r.project?"project":"user",s),b={"claude-code":"claude-plugin","gemini-cli":"gemini-extension",antigravity:"gemini-extension",cursor:"cursor",codex:"codex"};if(ne({resourceId:p.resource.id,slug:p.resource.slug||"essentials",installPath:Kt,title:p.resource.title,sha:p.resource.latestSha||"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString(),pluginFormat:b[s.id]||"directory",memberCount:p.memberResources?.length}),p.resource.latestSha&&await F("/api/cli/install",{resourceId:p.resource.id,agentPlatform:s.platform,installedSha:p.resource.latestSha}).catch(()=>{}),p.memberResources)for(let g of p.memberResources){let f=g.slug||g.id,m=zn[g.resourceType]||g.resourceType+"s",A=g.orgSlug||p.resource.orgSlug,S=A?`${m}/${A}/${f}`:`${m}/${f}`;ne({resourceId:g.id,slug:f,installPath:S,title:g.title,sha:g.latestSha||"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString(),collectionId:p.resource.id}),o.push({title:g.title,resourceType:g.resourceType}),g.latestSha&&await F("/api/cli/install",{resourceId:g.id,agentPlatform:s.platform,installedSha:g.latestSha}).catch(()=>{})}if(a=!0,!y()&&d.warnings.length>0)for(let g of d.warnings)w(`Warning: ${g}`)}}catch{}if(!a&&(Kn(s,!!r.project),ne({resourceId:"resource-manager",slug:je,installPath:`skills/${je}`,title:Xr,sha:"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString()}),i?.token))try{let c=`skills/shared-context/${je}`,p=await H(`/api/cli/resource/${c}`);if(p.ok&&p.data.resource){let u=p.data.resource;u.latestSha&&await F("/api/cli/install",{resourceId:u.id,agentPlatform:s.platform,installedSha:u.latestSha}),ne({resourceId:u.id,slug:u.slug||je,installPath:`skills/shared-context/${u.slug||je}`,title:u.title||Xr,sha:u.latestSha||"",scope:r.project?"project":"global",agent:s.id,installedAt:new Date().toISOString()})}}catch{}let l=[];if(i?.token)try{let c=(0,We.join)((0,Qr.homedir)(),s.dir),p=Ie(c),u=K(),d=new Set(u.installations.map(f=>f.installPath)),b=new Set(["resource-manager",".claude-plugin"]),g=p.resources.filter(f=>{if(d.has(f.importPath)||f.importPath.startsWith("."))return!1;let m=f.importPath.split("/").pop()||"";return!b.has(m)});if(g.length>0){let f={dryRun:!1,onConflict:"auto",visibility:"org",resources:g,collectionMemberships:p.collectionMemberships},m=await F("/api/cli/import",f,12e4);m.ok&&(l=[...m.data.created,...m.data.updated,...m.data.installed].map(S=>({resourceType:S.resourceType||S.importPath.split("/")[0]?.replace(/s$/,"")||"unknown",slug:S.slug||S.importPath.split("/").pop()||"",title:S.importPath.split("/").pop()||""})))}He({lastSyncAt:new Date().toISOString(),lastResult:{updatesAvailable:0,untrackedResources:0}})}catch{}if(y())O("init",{agent:s.id,collection:a?Kt:void 0,resourceManagerOnly:!a,...a?{membersInstalled:o.map(c=>({title:c.title,resourceType:c.resourceType}))}:{},...l.length>0?{importedResources:l.map(c=>({resourceType:c.resourceType,slug:c.slug,title:c.title}))}:{},authenticated:T()});else{if(h(""),a){h(`Shared Context Essentials installed for ${s.label} (${o.length} resources)`);let c={};for(let u of o)c[u.resourceType]||(c[u.resourceType]=[]),c[u.resourceType].push(u.title);let p={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections"};h("");for(let[u,d]of Object.entries(c)){let b=p[u]||u;h(` ${b}: ${d.join(", ")}`)}}else h(`Shared Context initialized for ${s.label}`),h("Resource Manager installed");if(l.length>0){h(""),h(`Imported ${l.length} existing resource${l.length===1?"":"s"}:`);for(let c of l)h(` ${c.resourceType.padEnd(12)} ${c.slug.padEnd(24)} ${c.title}`)}h(""),h("Quick reference:"),h(' shared-context-ai search "query" Search for resources'),h(" shared-context-ai install <installPath> Install a resource"),h(" shared-context-ai list List installed resources"),h(" shared-context-ai sync Check updates & discover resources"),h(" shared-context-ai preview <installPath> Preview before installing")}})}var Ps=require("http"),$s=require("crypto");Q();z();Q();async function Rs(n){let e=await F("/api/cli/auth",{code:n});return e.ok?(Mt({token:e.data.token,email:e.data.user.email,orgId:e.data.org.id,orgSlug:e.data.org.slug,orgName:e.data.org.name,createdAt:new Date().toISOString()}),y()?O("login",{email:e.data.user.email,org:e.data.org.slug}):h(`Logged in as ${e.data.user.email} (org: ${e.data.org.name})`),!0):(y()?x("login",e.error.code,e.error.message):w(`Login failed: ${e.error.message}`),!1)}async function di(){let n=(0,$s.randomBytes)(16).toString("hex");return new Promise(e=>{let t=(0,Ps.createServer)((r,s)=>{let i=new URL(r.url||"/","http://localhost"),a=i.searchParams.get("code"),o=i.searchParams.get("state");if(!a||o!==n){s.writeHead(400,{"Content-Type":"text/html"}),s.end("<h1>Authentication failed</h1><p>Invalid state. Please try again.</p>"),t.close(),e(!1);return}s.writeHead(200,{"Content-Type":"text/html"}),s.end("<h1>Authentication successful!</h1><p>You can close this tab and return to your terminal.</p>"),t.close(),Rs(a).then(e)});t.listen(0,"127.0.0.1",async()=>{let r=t.address();if(!r||typeof r=="string"){t.close(),e(!1);return}let s=r.port,a=`${ge().apiBase||"https://sharedcontext.ai"}/cli/login?port=${s}&state=${n}`;y()||(h("Opening browser for authentication..."),h(`If the browser doesn't open, visit: ${a}`));try{let o=(await Promise.resolve().then(()=>(Es(),vs))).default;await o(a)}catch{y()||h(`Could not open browser. Please visit:
190
+ ${a}`)}setTimeout(()=>{t.close(),y()||w("Login timed out after 5 minutes."),e(!1)},300*1e3)})})}function Ts(n){n.command("login").description("Authenticate with Shared Context").option("--code <code>","Use an auth code directly (skip browser)").action(async e=>{let t;e.code?t=await Rs(e.code):t=await di(),process.exit(t?0:1)})}z();var hi={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Is(n){let e=hi[n.resourceType]||n.resourceType+"s";return n.storageType==="github"&&n.githubOwner?`${e}/external/${n.githubOwner}/${n.slug}`:n.orgSlug?`${e}/${n.orgSlug}/${n.slug}`:`${e}/${n.slug}`}function js(n){n.command("search <query>").description("Search for skills in the library").option("--type <type>","Filter by resource type (skill, command, hook, collection, agent, mcp, file)").option("--tag <tag>","Filter by topic tag").option("--limit <n>","Max results","20").action(async(e,t)=>{let r=new URLSearchParams({q:e});t.type&&r.set("type",t.type),t.tag&&r.set("tag",t.tag),t.limit&&r.set("limit",t.limit);let s=T()?`/api/cli/search?${r}`:`/api/public/search?${r}`,i=await H(s);i.ok||(y()?x("search",i.error.code,i.error.message):h(`Search failed: ${i.error.message}`),process.exit(1));let a=i.data.results;if(y()){let l=a.map(c=>{let p=Is(c);return{installPath:p,installCommand:`npx shared-context-ai install ${p}`,title:c.title,description:c.description,resourceType:c.resourceType,installCount:c.installCount,topicTags:c.topicTags}});O("search",{results:l,count:l.length});return}if(a.length===0){let l=t.type?`${t.type}s`:"results";h(`No ${l} found.`);return}h(`Found ${a.length} result${a.length===1?"":"s"}:
191
+ `);let o=a.map(l=>[Is(l),l.title,`\u2193${l.installCount}`]);h(re(o)),h(`
192
+ Install a skill: npx shared-context-ai install <installPath>`)})}z();Q();function Fs(n){let e=n.slug||n.resourceId;return n.storageType==="github"&&n.githubOwner?`skills/external/${n.githubOwner}/${e}`:n.orgSlug?`skills/${n.orgSlug}/${e}`:`skills/${e}`}function Ds(n){n.command("list").description("List installed skills").alias("ls").action(async()=>{if(T()){let e=await H("/api/cli/installed");e.ok||(y()?x("list",e.error.code,e.error.message):h(`Failed to fetch installations: ${e.error.message}`),process.exit(1));let t=e.data.installations;if(y()){let s=t.map(i=>({...i,installPath:Fs(i)}));O("list",{installations:s,count:s.length});return}if(t.length===0){h("No skills installed."),h("Use 'shared-context-ai search' to find skills to install.");return}h(`${t.length} skill${t.length===1?"":"s"} installed:
193
+ `);let r=t.map(s=>[Fs(s),s.title,s.hasUpdate?"(update available)":"(current)"]);h(re(r))}else{let t=K().installations;if(y()){O("list",{installations:t,count:t.length});return}if(t.length===0){h("No skills installed locally.");return}h(`${t.length} skill${t.length===1?"":"s"} installed locally:
194
+ `);let r=t.map(s=>[s.installPath||s.slug,s.title,`(${s.agent})`]);h(re(r)),h(`
195
+ Tip: Run 'shared-context-ai login' to sync with sharedcontext.ai and check for updates.`)}})}z();function Ns(n){n.command("preview <path>").description("Preview a skill's content (e.g., skills/acme/api-testing)").action(async e=>{let r=T()?"/api/cli/resource":"/api/public/resource",s=await H(`${r}/${e}/preview`);s.ok||(y()?x("preview",s.error.code,s.error.message):w(`Preview failed: ${s.error.message}`),process.exit(1)),y()?O("preview",s.data):h(s.data.content)})}z();function Ms(n){n.command("check").description("Check for skill updates").action(async()=>{T()||(y()?x("check","AUTH_MISSING","Login required to check for updates."):w("Login required to check for updates. Run 'shared-context-ai login'."),process.exit(1));let e=await H("/api/cli/updates");e.ok||(y()?x("check",e.error.code,e.error.message):w(`Check failed: ${e.error.message}`),process.exit(1));let{updates:t,count:r}=e.data;if(y()){O("check",{updates:t,count:r});return}if(r===0){h("All skills are up to date.");return}h(`${r} update${r===1?"":"s"} available:
196
+ `);let s=t.map(i=>{let a=i.slug||i.resourceId;return[i.storageType==="github"&&i.githubOwner?`skills/external/${i.githubOwner}/${a}`:i.orgSlug?`skills/${i.orgSlug}/${a}`:`skills/${a}`,i.title,`${i.installedSha.slice(0,7)} \u2192 ${i.latestSha.slice(0,7)}`]});h(re(s)),h(`
197
+ Run 'shared-context-ai update' to update all, or 'shared-context-ai update <installPath>' to update one.`)})}var gr=require("path");z();Q();var fi={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Hs(n){let e=n.slug||n.resourceId,t=fi[n.resourceType]||n.resourceType+"s";return n.storageType==="github"&&n.githubOwner?`${t}/external/${n.githubOwner}/${e}`:n.orgSlug?`${t}/${n.orgSlug}/${e}`:`${t}/${e}`}function Ls(n){n.command("update [path]").description("Update installed resources (all or by install path)").action(async(e,t,r)=>{let s=r.optsWithGlobals();T()||(y()?x("update","AUTH_MISSING","Login required to update resources."):w("Login required to update resources. Run 'shared-context-ai login'."),process.exit(1));let i=ce(s.agent);if(!i){let c=le();y()?x("update","NO_AGENTS",c):w(c),process.exit(1)}let a=await H("/api/cli/updates");a.ok||(y()?x("update",a.error.code,a.error.message):w(`Failed to check updates: ${a.error.message}`),process.exit(1));let o=a.data.updates;if(e&&(o=o.filter(c=>Hs(c)===e||c.slug===e||c.resourceId===e),o.length===0)){y()?x("update","SKILL_NOT_FOUND",`No update available for "${e}".`):h(`No update available for "${e}".`);return}if(o.length===0){y()?O("update",{updated:[],count:0}):h("All resources are up to date.");return}let l=[];for(let c of o){let p=Hs(c),u=await H(`/api/cli/resource/${p}`);if(!u.ok){y()||w(` Failed to fetch ${p}: ${u.error.message}`);continue}let d=u.data,b=p.split("/").slice(1);if(d.resource.resourceType==="agent"){let g=U(i,!!s.project),f=(0,gr.join)(g,...b);$(f,d.files)}else if(d.resource.resourceType==="mcp")qt(i,!!s.project,d);else{let g=_(i,!!s.project),f=(0,gr.join)(g,...b);$(f,d.files)}d.resource.latestSha&&await F("/api/cli/update",{resourceId:d.resource.id,installedSha:d.resource.latestSha}),ne({resourceId:d.resource.id,slug:d.resource.slug||d.resource.id,installPath:p,title:d.resource.title,sha:d.resource.latestSha||"",scope:s.project?"project":"global",agent:i.id,installedAt:new Date().toISOString()}),l.push({installPath:p,title:d.resource.title}),y()||h(` Updated ${p}`)}y()?O("update",{updated:l,count:l.length}):l.length>0&&h(`
198
+ ${l.length} resource${l.length===1?"":"s"} updated.`)})}var D=require("fs"),De=require("path");z();Q();function Ws(n){n.command("uninstall <path>").description("Uninstall a resource by install path (e.g., skills/acme/api-testing)").action(async(e,t,r)=>{let s=r.optsWithGlobals(),i=ce(s.agent);if(!i){let b=le();y()?x("uninstall","NO_AGENTS",b):w(b),process.exit(1)}let o=K().installations.find(b=>b.installPath===e||b.slug===e||b.resourceId===e),l=e.split("/"),p=["skills","files","commands","hooks","collections","agents","mcps"].includes(l[0])?l[0]:null,u=p?l.slice(1):l,d=!1;if(p==="collections"){let b=Ee(i),g=u[u.length-1],f=s.project?"project":"user",m=await b.uninstall(g,f,i,o?.resourceId);if(d=m.removed,!y())for(let A of m.warnings)w(`Warning: ${A}`);if(o){let S=K().installations.filter(C=>C.collectionId===o.resourceId&&C.agent===i.id);for(let C of S){let N=C.installPath.split("/"),P=N[0],V=N.slice(1);if(P==="agents"){let I=U(i,!!s.project),M=(0,De.join)(I,...V);(0,D.existsSync)(M)&&(0,D.rmSync)(M,{recursive:!0,force:!0})}else if(P==="mcps"){let I=V[V.length-1],M=G(i,!!s.project);if((0,D.existsSync)(M))try{let j=JSON.parse((0,D.readFileSync)(M,"utf-8"));if(typeof j.mcpServers=="object"&&j.mcpServers&&!Array.isArray(j.mcpServers)){let B=j.mcpServers;I in B&&(delete B[I],j.mcpServers=B,(0,D.writeFileSync)(M,JSON.stringify(j,null,2)+`
199
+ `,"utf-8"))}}catch{}}else if(P==="hooks")Jt(ie(i,!!s.project),C.installPath);else{let I=_(i,!!s.project),M=(0,De.join)(I,...V);(0,D.existsSync)(M)&&(0,D.rmSync)(M,{recursive:!0,force:!0})}Xe(C.resourceId,i.id)}}}else if(p==="agents"){let b=U(i,!!s.project),g=(0,De.join)(b,...u);d=(0,D.existsSync)(g),d&&(0,D.rmSync)(g,{recursive:!0,force:!0})}else if(p==="mcps"){let b=u[u.length-1],g=G(i,!!s.project);if((0,D.existsSync)(g))try{let f=JSON.parse((0,D.readFileSync)(g,"utf-8"));if(typeof f.mcpServers=="object"&&f.mcpServers&&!Array.isArray(f.mcpServers)){let m=f.mcpServers;b in m&&(delete m[b],f.mcpServers=m,(0,D.writeFileSync)(g,JSON.stringify(f,null,2)+`
200
+ `,"utf-8"),d=!0)}}catch{}}else if(p==="hooks"){let b=ie(i,!!s.project);d=Jt(b,e),!d&&!y()&&w(`Note: No tagged hook entries found in ${b} \u2014 may need manual removal if installed before v0.1.10`)}else{let b=_(i,!!s.project),g=(0,De.join)(b,...u);if(d=(0,D.existsSync)(g),d&&(0,D.rmSync)(g,{recursive:!0,force:!0}),!d&&o?.slug){let f=(0,De.join)(b,o.slug);(0,D.existsSync)(f)&&(0,D.rmSync)(f,{recursive:!0,force:!0})}}if(T()&&o){let b=await F("/api/cli/uninstall",{resourceId:o.resourceId});!b.ok&&!y()&&w(`Warning: Could not record uninstall on server: ${b.error.message}`)}o&&Xe(o.resourceId,i.id),y()?O("uninstall",{path:e,removed:!0}):h(`Uninstalled "${e}"`)})}Q();function Us(n){n.command("status").description("Show CLI status: auth, agents, installed skill counts").action(async()=>{let e=ae(),t=ge(),r=K(),s=Bt(),i={authenticated:!!e?.token,email:e?.email||null,org:e?.orgSlug||null,apiBase:t.apiBase,detectedAgents:s.map(a=>a.id),installedCount:r.installations.length};if(y()){O("status",i);return}h("Shared Context CLI Status"),h("\u2500".repeat(30)),e?.token?h(` Auth: ${e.email} (${e.orgSlug})`):h(" Auth: Not logged in"),h(` API: ${t.apiBase}`),s.length>0?h(` Agents: ${s.map(a=>a.label).join(", ")}`):h(" Agents: None detected"),h(` Skills: ${r.installations.length} installed`)})}Q();z();function Vs(n){n.command("logout").description("Clear saved credentials").option("--revoke","Also revoke the token on the server").action(async e=>{let t=ae();e.revoke&&T()&&await Ut("/api/cli/auth"),Ht(),y()?O("logout",{email:t?.email||null}):h("Logged out.")})}var gt=require("fs"),Bs=require("path");z();function qs(n){n.command("import [path]").description("Import resources from a local directory or GitHub URL").option("--github <url>","Import a single resource from a GitHub URL").option("--resource-type <type>","Resource type (skill|command|hook|agent|mcp) \u2014 for GitHub import disambiguation").option("--visibility <level>","Visibility for created resources","org").option("--dry-run","Preview what would happen without making changes",!1).option("--no-recursive","Do not recursively scan subdirectories").option("--tags <tags>","Comma-separated topic tags").option("--on-conflict <strategy>","Conflict resolution strategy (auto|skip|update|clone|error)","auto").action(async(e,t,r)=>{let s=r.optsWithGlobals(),i=t.github;if(i&&e&&(y()?x("import","INVALID_ARGS","Cannot use --github with a local path"):w("Error: Cannot use --github with a local path. Use one or the other."),process.exit(1)),!i&&!e&&(y()?x("import","INVALID_ARGS","Provide a local path or --github <url>"):w("Error: Provide a local path or --github <url>"),process.exit(1)),T()||(y()?x("import","AUTH_MISSING","Authentication required for import"):w("Error: Authentication required. Run 'shared-context-ai login' first."),process.exit(1)),i){t.onConflict&&t.onConflict!=="auto"&&(y()?x("import","INVALID_ARGS","--on-conflict is not supported with --github"):w("Error: --on-conflict is not supported with --github"),process.exit(1)),t.dryRun&&(y()?x("import","INVALID_ARGS","--dry-run is not supported with --github"):w("Error: --dry-run is not supported with --github"),process.exit(1));let g={url:i};t.resourceType&&(g.resourceType=t.resourceType),y()||h(`
201
+ Importing from GitHub: ${i}`);let f=await F("/api/cli/github-import",g);f.ok||(y()?x("import",f.error.code,f.error.message):w(`
202
+ Import failed: ${f.error.message}`),process.exit(1));let m=f.data;if(y()){O("import",m);return}h(""),h(` Source: ${m.source.owner}/${m.source.repo}`),h(` Type: ${m.resourceType}`),h(` Title: ${m.title}`),m.slug&&h(` Slug: ${m.slug}`),h(` URL: ${m.url}`),h(""),h("Import complete: 1 created");return}let a=(0,Bs.resolve)(e);(!(0,gt.existsSync)(a)||!(0,gt.statSync)(a).isDirectory())&&(y()?x("import","INVALID_PATH",`Not a directory: ${a}`):w(`Error: Not a directory: ${a}`),process.exit(1));let o=Ie(a);if(o.resources.length===0){y()?O("import",{resources:[],message:"No resources found"}):h("No resources found in the specified directory.");return}if(!y()){let g=new Map;for(let m of o.resources)g.set(m.resourceType,(g.get(m.resourceType)||0)+1);let f=[...g.entries()].map(([m,A])=>`${A} ${m}${A===1?"":"s"}`).join(", ");h(`
203
+ Discovered ${o.resources.length} resources in ${e}:`),h(` ${f}`),o.formatLabel&&o.pluginName?h(` ${o.formatLabel}: ${o.pluginName}`):o.pluginName&&h(` Plugin: ${o.pluginName}`)}let l=t.tags?t.tags.split(",").map(g=>g.trim()).filter(Boolean):void 0,c={dryRun:!!t.dryRun,onConflict:t.onConflict||"auto",visibility:t.visibility||"org",topicTags:l,resources:o.resources,collectionMemberships:o.collectionMemberships.length>0?o.collectionMemberships:void 0};!y()&&!t.dryRun?h(`
204
+ Executing import...`):y()||h(`
205
+ Dry run \u2014 previewing changes...`);let p=await F("/api/cli/import",c,12e4);p.ok||(y()?x("import",p.error.code,p.error.message):w(`
206
+ Import failed: ${p.error.message}`),process.exit(1));let u=p.data;if(y()){O("import",u);return}let d=[...u.created.map(g=>({...g,action:"created"})),...u.updated.map(g=>({...g,action:"updated"})),...u.installed.map(g=>({...g,action:"installed"})),...u.cloned.map(g=>({...g,action:"cloned"})),...u.skipped.map(g=>({...g,action:"skipped"})),...u.errors.map(g=>({...g,action:"error"}))];if(d.length>0){h("");let g=d.length,f=d.map((m,A)=>{let S=`[${String(A+1).padStart(String(g).length)}/${g}]`,C=(m.resourceType||"").padEnd(10),N=(m.importPath.split("/").pop()||"").padEnd(24),P="";switch(m.action){case"created":P=`\u2713 created${m.slug?` (slug: ${m.slug})`:""}`;break;case"updated":P="\u2713 updated";break;case"installed":{let V=m.versionsBehind;P=`\u2713 installed${V?` (${V} versions behind)`:""}`;break}case"cloned":P=`\u2713 cloned${m.slug?` (slug: ${m.slug})`:""}`;break;case"skipped":P=`\u2713 skipped (${m.reason||"up to date"})`;break;case"error":P=`\u2717 error: ${m.error||"unknown"}`;break}return` ${S} ${C} ${N} ${P}`});for(let m of f)h(m)}if(u.collections.length>0)for(let g of u.collections){let f=g.importPath.split("/").pop()||g.importPath;h(` collection ${f.padEnd(20)} \u2713 ${g.membersLinked} members linked${g.membersFailed>0?`, ${g.membersFailed} failed`:""}`)}h("");let b=[u.created.length>0?`${u.created.length} created`:null,u.installed.length>0?`${u.installed.length} installed`:null,u.cloned.length>0?`${u.cloned.length} cloned`:null,u.updated.length>0?`${u.updated.length} updated`:null,u.skipped.length>0?`${u.skipped.length} skipped`:null,u.errors.length>0?`${u.errors.length} errors`:null].filter(Boolean);t.dryRun?h(`Dry run complete: ${b.join(", ")}`):h(`Import complete: ${b.join(", ")}`),u.errors.length>0&&process.exit(1)})}var Ys=require("path"),Ks=require("os");z();Q();function zs(n){n.command("sync").description("Synchronize resource state \u2014 check for updates and discover untracked resources").option("--quiet","Minimal output (one-line summary)").option("--force","Bypass throttle and sync now").option("--import","Auto-import untracked resources to your dashboard").action(async(e,t)=>{let r={...e,...t.optsWithGlobals()};if(!r.force&&!Wt()){let f=Qe();if(f){let m={...f.lastResult,updates:[],untracked:[],summary:Gs(f.lastResult.updatesAvailable,f.lastResult.untrackedResources),throttled:!0};Js(m,!!r.quiet);return}}T()||(y()?x("sync","AUTH_MISSING","Login required to sync."):w("Login required. Run 'shared-context-ai login'."),process.exit(1));let s=ce(r.agent);if(!s){let f=le();y()?x("sync","NO_AGENTS",f):w(f),process.exit(1)}let i=[],a=await H("/api/cli/updates");a.ok&&(i=a.data.updates);let o=(0,Ys.join)((0,Ks.homedir)(),s.dir),l=Ie(o),c=K(),p=new Set(c.installations.map(f=>f.installPath)),u=new Set(["resource-manager",".claude-plugin"]),d=l.resources.filter(f=>{if(p.has(f.importPath)||f.importPath.startsWith("."))return!1;let m=f.importPath.split("/").pop()||"";return!u.has(m)});if(r.import&&d.length>0){let f={dryRun:!1,onConflict:"auto",visibility:"org",resources:d,collectionMemberships:l.collectionMemberships},m=await F("/api/cli/import",f,12e4);if(m.ok){let A=[...m.data.created,...m.data.updated,...m.data.installed];if(!y()&&!r.quiet){if(A.length>0){h(`
207
+ Imported ${A.length} resource${A.length===1?"":"s"}:`);let S=A.map(C=>[` ${(C.resourceType||"").padEnd(12)}`,(C.slug||C.importPath.split("/").pop()||"").padEnd(24),C.importPath]);h(re(S))}m.data.errors.length>0&&w(`
208
+ ${m.data.errors.length} import error(s)`)}d.length=0}else y()||w(`Import failed: ${m.error.message}`)}let b={updatesAvailable:i.length,untrackedResources:d.length};He({lastSyncAt:new Date().toISOString(),lastResult:b});let g={...b,updates:i,untracked:d.map(f=>({importPath:f.importPath,resourceType:f.resourceType,title:f.title})),summary:Gs(i.length,d.length),throttled:!1};Js(g,!!r.quiet)})}function Gs(n,e){let t=[];return n>0&&t.push(`${n} update${n===1?"":"s"} available`),e>0&&t.push(`${e} untracked resource${e===1?"":"s"}`),t.length===0?"Everything is up to date.":t.join(", ")}function Js(n,e){if(y()){O("sync",n);return}if(e){let t=n.summary;n.updatesAvailable>0&&(t+=" \u2014 run 'shared-context-ai update'"),n.untrackedResources>0&&(t+=" \u2014 run 'shared-context-ai sync --import' to import"),h(t);return}if(h(""),n.updates.length>0){h(`${n.updates.length} update${n.updates.length===1?"":"s"} available:
209
+ `);let t=n.updates.map(r=>{let s=r.slug||r.resourceId,i=r.resourceType==="skill"?"skills":`${r.resourceType}s`;return[` ${r.storageType==="github"&&r.githubOwner?`${i}/external/${r.githubOwner}/${s}`:r.orgSlug?`${i}/${r.orgSlug}/${s}`:`${i}/${s}`}`,r.title,`${r.installedSha.slice(0,7)} \u2192 ${r.latestSha.slice(0,7)}`]});h(re(t)),h("")}if(n.untracked.length>0){h(`${n.untracked.length} untracked resource${n.untracked.length===1?"":"s"}:
210
+ `);let t=n.untracked.map(r=>[` ${r.resourceType.padEnd(12)}`,r.importPath.padEnd(30),r.title]);h(re(t)),h("")}n.updatesAvailable===0&&n.untrackedResources===0?h("Everything is up to date."):(n.updatesAvailable>0&&h("Run 'shared-context-ai update' to update installed resources."),n.untrackedResources>0&&h("Run 'shared-context-ai sync --import' to import untracked resources.")),h("")}var Xs={AUTH_MISSING:"Run 'shared-context-ai login' to authenticate.",AUTH_EXPIRED:"Run 'shared-context-ai login' to re-authenticate.",SKILL_NOT_FOUND:"Check the skill slug and try again.",ALREADY_INSTALLED:"Use 'shared-context-ai update <slug>' to update instead.",NO_AGENTS:"No AI coding agents detected. Run 'shared-context-ai init --agent <name>' to set up manually.",API_ERROR:"The server returned an error. Try again later.",WRITE_FAILED:"Could not write files to disk. Check permissions."},yt=class extends Error{constructor(t,r){super(r||Xs[t]);this.code=t;this.name="CliError"}get recovery(){return Xs[this.code]}};var Y=new $r;Y.name("shared-context-ai").description("CLI for Shared Context - search, install, and manage AI skills").version("0.1.0").option("--json","Output as JSON (default when piped)").option("--human","Output as human-readable text (default in TTY)").option("--agent <name>","Override agent detection").option("--project","Use project-local directory instead of global").hook("preAction",n=>{let e=n.opts();Ir(!!e.json,!!e.human)});Zr(Y);Ts(Y);js(Y);Br(Y);Ds(Y);Ns(Y);Ms(Y);Ls(Y);Ws(Y);Us(Y);Vs(Y);qs(Y);zs(Y);process.on("uncaughtException",n=>{n instanceof yt?y()?x(process.argv[2]||"unknown",n.code,n.message):(w(`Error: ${n.message}`),w(n.recovery)):y()?x(process.argv[2]||"unknown","UNEXPECTED",n.message||"Unexpected error"):w(`Error: ${n.message||n}`),process.exit(1)});Y.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-context-ai",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "CLI for Shared Context - search, install, and manage AI skills",
5
5
  "bin": {
6
6
  "shared-context-ai": "dist/index.js"