shared-context-ai 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +75 -75
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,52 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`)}displayWidth(e){return Tn(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,n,s){let
|
|
4
|
-
`+" ".repeat(t+l)),c+
|
|
5
|
-
${
|
|
6
|
-
`)}};function Tn(r){let e=/\x1b\[\d*(;\d*)*m/g;return r.replace(e,"")}
|
|
2
|
+
"use strict";var ui=Object.create;var gr=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var Ee=(r,e)=>()=>(r&&(e=r(r=0)),e);var K=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),kt=(r,e)=>{for(var t in e)gr(r,t,{get:e[t],enumerable:!0})},gi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of di(e))!mi.call(r,s)&&s!==t&&gr(r,s,{get:()=>e[s],enumerable:!(n=fi(e,s))||n.enumerable});return r};var ge=(r,e,t)=>(t=r!=null?ui(pi(r)):{},gi(e||!r||!r.__esModule?gr(t,"default",{value:r,enumerable:!0}):t,r));var gt=K(yr=>{"use strict";var Rt=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},hr=class extends Rt{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};yr.CommanderError=Rt;yr.InvalidArgumentError=hr});var Tt=K(Er=>{"use strict";var{InvalidArgumentError:hi}=gt(),Sr=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,n)=>{if(!this.argChoices.includes(t))throw new hi(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function yi(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}Er.Argument=Sr;Er.humanReadableArgName=yi});var br=K(wr=>{"use strict";var{humanReadableArgName:Si}=Tt(),Cr=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),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((s,o)=>s.name().localeCompare(o.name())),t}compareOptions(e,t){let n=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),n=e._getHelpOption();if(n&&!n.hidden){let s=n.short&&e._findOption(n.short),o=n.long&&e._findOption(n.long);!s&&!o?t.push(n):n.long&&!o?t.push(e.createOption(n.long,n.description)):n.short&&!s&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let s=n.options.filter(o=>!o.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(n=>Si(n)).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((n,s)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(s)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,s)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,s)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(s)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,s)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(s)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let s=e.parent;s;s=s.parent)n=s.name()+" "+n;return n+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(n=>JSON.stringify(n)).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(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatHelp(e,t){let n=t.padWidth(e,t),s=t.helpWidth??80;function o(y,I){return t.formatItem(y,n,I,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(y=>o(t.styleArgumentTerm(t.argumentTerm(y)),t.styleArgumentDescription(t.argumentDescription(y))));l.length>0&&(a=a.concat([t.styleTitle("Arguments:"),...l,""]));let u=t.visibleOptions(e).map(y=>o(t.styleOptionTerm(t.optionTerm(y)),t.styleOptionDescription(t.optionDescription(y))));if(u.length>0&&(a=a.concat([t.styleTitle("Options:"),...u,""])),t.showGlobalOptions){let y=t.visibleGlobalOptions(e).map(I=>o(t.styleOptionTerm(t.optionTerm(I)),t.styleOptionDescription(t.optionDescription(I))));y.length>0&&(a=a.concat([t.styleTitle("Global Options:"),...y,""]))}let m=t.visibleCommands(e).map(y=>o(t.styleSubcommandTerm(t.subcommandTerm(y)),t.styleSubcommandDescription(t.subcommandDescription(y))));return m.length>0&&(a=a.concat([t.styleTitle("Commands:"),...m,""])),a.join(`
|
|
3
|
+
`)}displayWidth(e){return Tn(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,n,s){let a=" ".repeat(2);if(!n)return a+e;let c=e.padEnd(t+e.length-s.displayWidth(e)),l=2,m=(this.helpWidth??80)-t-l-2,y;return m<this.minWidthToWrap||s.preformatted(n)?y=n:y=s.boxWrap(n,m).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(t+l)),a+c+" ".repeat(l)+y.replace(/\n/g,`
|
|
5
|
+
${a}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,o=[];return n.forEach(a=>{let c=a.match(s);if(c===null){o.push("");return}let l=[c.shift()],u=this.displayWidth(l[0]);c.forEach(m=>{let y=this.displayWidth(m);if(u+y<=t){l.push(m),u+=y;return}o.push(l.join(""));let I=m.trimStart();l=[I],u=this.displayWidth(I)}),o.push(l.join(""))}),o.join(`
|
|
6
|
+
`)}};function Tn(r){let e=/\x1b\[\d*(;\d*)*m/g;return r.replace(e,"")}wr.Help=Cr;wr.stripColor=Tn});var xr=K(Ar=>{"use strict";var{InvalidArgumentError:Ei}=gt(),Ir=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 n=Ci(e);this.short=n.shortFlag,this.long=n.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,n)=>{if(!this.argChoices.includes(t))throw new Ei(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Pn(this.name().replace(/^no-/,"")):Pn(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},_r=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,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let s=this.negativeOptions.get(n).presetArg,o=s!==void 0?s:!1;return t.negate===(o===e)}};function Pn(r){return r.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Ci(r){let e,t,n=/^-[^-]$/,s=/^--[^-]/,o=r.split(/[ |,]+/).concat("guard");if(n.test(o[0])&&(e=o.shift()),s.test(o[0])&&(t=o.shift()),!e&&n.test(o[0])&&(e=o.shift()),!e&&s.test(o[0])&&(e=t,t=o.shift()),o[0].startsWith("-")){let a=o[0],c=`option creation failed due to '${a}' in option flags '${r}'`;throw/^-[^-][^-]/.test(a)?new Error(`${c}
|
|
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')`):n.test(
|
|
10
|
-
- too many short flags`):s.test(
|
|
11
|
-
- too many long flags`):new Error(`${
|
|
12
|
-
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:e,longFlag:t}}Ar.Option=
|
|
9
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.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 '${r}'.`);return{shortFlag:e,longFlag:t}}Ar.Option=Ir;Ar.DualOptions=_r});var Dn=K(jn=>{"use strict";function wi(r,e){if(Math.abs(r.length-e.length)>3)return Math.max(r.length,e.length);let t=[];for(let n=0;n<=r.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let s=1;s<=r.length;s++){let o=1;r[s-1]===e[n-1]?o=0:o=1,t[s][n]=Math.min(t[s-1][n]+1,t[s][n-1]+1,t[s-1][n-1]+o),s>1&&n>1&&r[s-1]===e[n-2]&&r[s-2]===e[n-1]&&(t[s][n]=Math.min(t[s][n],t[s-2][n-2]+1))}return t[r.length][e.length]}function bi(r,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=r.startsWith("--");t&&(r=r.slice(2),e=e.map(a=>a.slice(2)));let n=[],s=3,o=.4;return e.forEach(a=>{if(a.length<=1)return;let c=wi(r,a),l=Math.max(r.length,a.length);(l-c)/l>o&&(c<s?(s=c,n=[a]):c===s&&n.push(a))}),n.sort((a,c)=>a.localeCompare(c)),t&&(n=n.map(a=>`--${a}`)),n.length>1?`
|
|
13
13
|
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
14
|
-
(Did you mean ${n[0]}?)`:""}
|
|
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
|
|
16
|
-
Expecting one of '${n.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,n){this._exitCallback&&this._exitCallback(new
|
|
17
|
-
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),n=t(e).find(s=>this._findCommand(s));if(n){let s=t(this._findCommand(n)).join("|"),o=t(e).join("|");throw new Error(`cannot add command '${o}' as already have command '${s}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let o=e.long.replace(/^--no-/,"--");this._findOption(o)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let s=(o,c
|
|
14
|
+
(Did you mean ${n[0]}?)`:""}jn.suggestSimilar=bi});var Ln=K(Tr=>{"use strict";var Ii=require("events").EventEmitter,Or=require("child_process"),Fe=require("path"),Pt=require("fs"),H=require("process"),{Argument:_i,humanReadableArgName:Ai}=Tt(),{CommanderError:vr}=gt(),{Help:xi,stripColor:Oi}=br(),{Option:Nn,DualOptions:vi}=xr(),{suggestSimilar:$n}=Dn(),kr=class r extends Ii{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=>H.stdout.write(t),writeErr:t=>H.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>H.stdout.isTTY?H.stdout.columns:void 0,getErrHelpWidth:()=>H.stderr.isTTY?H.stderr.columns:void 0,getOutHasColors:()=>Rr()??(H.stdout.isTTY&&H.stdout.hasColors?.()),getErrHasColors:()=>Rr()??(H.stderr.isTTY&&H.stderr.hasColors?.()),stripColor:t=>Oi(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,n){let s=t,o=n;typeof s=="object"&&s!==null&&(o=s,s=null),o=o||{};let[,a,c]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(a);return s&&(l.description(s),l._executableHandler=!0),o.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(o.noHelp||o.hidden),l._executableFile=o.executableFile||null,c&&l.arguments(c),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),s?this:l}createCommand(e){return new r(e)}createHelp(){return Object.assign(new xi,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 _i(e,t)}argument(e,t,n,s){let o=this.createArgument(e,t);return typeof n=="function"?o.default(s).argParser(n):o.default(n),this.addArgument(o),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[,n,s]=e.match(/([^ ]+) *(.*)/),o=t??"display help for command",a=this.createCommand(n);return a.helpOption(!1),s&&a.arguments(s),o&&a.description(o),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 n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
16
|
+
Expecting one of '${n.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,n){this._exitCallback&&this._exitCallback(new vr(e,t,n)),H.exit(e)}action(e){let t=n=>{let s=this.registeredArguments.length,o=n.slice(0,s);return this._storeOptionsAsProperties?o[s]=this:o[s]=this.opts(),o.push(this),e.apply(this,o)};return this._actionHandler=t,this}createOption(e,t){return new Nn(e,t)}_callParseArg(e,t,n,s){try{return e.parseArg(t,n)}catch(o){if(o.code==="commander.invalidArgument"){let a=`${s} ${o.message}`;this.error(a,{exitCode:o.exitCode,code:o.code})}throw o}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=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 '${n}'
|
|
17
|
+
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),n=t(e).find(s=>this._findCommand(s));if(n){let s=t(this._findCommand(n)).join("|"),o=t(e).join("|");throw new Error(`cannot add command '${o}' as already have command '${s}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let o=e.long.replace(/^--no-/,"--");this._findOption(o)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let s=(o,a,c)=>{o==null&&e.presetArg!==void 0&&(o=e.presetArg);let l=this.getOptionValue(n);o!==null&&e.parseArg?o=this._callParseArg(e,o,l,a):o!==null&&e.variadic&&(o=e._concatValue(o,l)),o==null&&(e.negate?o=!1:e.isBoolean()||e.optional?o=!0:o=""),this.setOptionValueWithSource(n,o,c)};return this.on("option:"+t,o=>{let a=`error: option '${e.flags}' argument '${o}' is invalid.`;s(o,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,o=>{let a=`error: option '${e.flags}' value '${o}' from env '${e.envVar}' is invalid.`;s(o,a,"env")}),this}_optionEx(e,t,n,s,o){if(typeof t=="object"&&t instanceof Nn)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof s=="function")a.default(o).argParser(s);else if(s instanceof RegExp){let c=s;s=(l,u)=>{let m=c.exec(l);return m?m[0]:u},a.default(o).argParser(s)}else a.default(s);return this.addOption(a)}option(e,t,n,s){return this._optionEx({},e,t,n,s)}requiredOption(e,t,n,s){return this._optionEx({mandatory:!0},e,t,n,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,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.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){H.versions?.electron&&(t.from="electron");let s=H.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(t.from="eval")}e===void 0&&(e=H.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":H.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=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",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),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
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,n){if(Pt.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",o=`'${e}' does not exist
|
|
19
19
|
- if '${n}' 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(o)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function o(
|
|
21
|
+
- ${s}`;throw new Error(o)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function o(m,y){let I=Fe.resolve(m,y);if(Pt.existsSync(I))return I;if(s.includes(Fe.extname(y)))return;let f=s.find(p=>Pt.existsSync(`${I}${p}`));if(f)return`${I}${f}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let m;try{m=Pt.realpathSync(this._scriptPath)}catch{m=this._scriptPath}c=Fe.resolve(Fe.dirname(m),c)}if(c){let m=o(c,a);if(!m&&!e._executableFile&&this._scriptPath){let y=Fe.basename(this._scriptPath,Fe.extname(this._scriptPath));y!==this._name&&(m=o(c,`${y}-${e._name}`))}a=m||a}n=s.includes(Fe.extname(a));let l;H.platform!=="win32"?n?(t.unshift(a),t=Fn(H.execArgv).concat(t),l=Or.spawn(H.argv[0],t,{stdio:"inherit"})):l=Or.spawn(a,t,{stdio:"inherit"}):(this._checkForMissingExecutable(a,c,e._name),t.unshift(a),t=Fn(H.execArgv).concat(t),l=Or.spawn(H.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(y=>{H.on(y,()=>{l.killed===!1&&l.exitCode===null&&l.kill(y)})});let u=this._exitCallback;l.on("close",m=>{m=m??1,u?u(new vr(m,"commander.executeSubCommandAsync","(close)")):H.exit(m)}),l.on("error",m=>{if(m.code==="ENOENT")this._checkForMissingExecutable(a,c,e._name);else if(m.code==="EACCES")throw new Error(`'${a}' not executable`);if(!u)H.exit(1);else{let y=new vr(1,"commander.executeSubCommandAsync","(error)");y.nestedError=m,u(y)}}),this.runningCommand=l}_dispatchSubcommand(e,t,n){let s=this._findCommand(e);s||this.help({error:!0}),s._prepareForParse();let o;return o=this._chainOrCallSubCommandHook(o,s,"preSubcommand"),o=this._chainOrCall(o,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(n));else return s._parseCommand(t,n)}),o}_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=(n,s,o)=>{let a=s;if(s!==null&&n.parseArg){let c=`error: command-argument value '${s}' is invalid for argument '${n.name()}'.`;a=this._callParseArg(n,s,o,c)}return a};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,s)=>{let o=n.defaultValue;n.variadic?s<this.args.length?(o=this.args.slice(s),n.parseArg&&(o=o.reduce((a,c)=>e(n,c,a),n.defaultValue))):o===void 0&&(o=[]):s<this.args.length&&(o=this.args[s],n.parseArg&&(o=e(n,o,n.defaultValue))),t[s]=o}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,s=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[t]!==void 0).forEach(o=>{o._lifeCycleHooks[t].forEach(a=>{s.push({hookedCommand:o,callback:a})})}),t==="postAction"&&s.reverse(),s.forEach(o=>{n=this._chainOrCall(n,()=>o.callback(o.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let s=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(o=>{s=this._chainOrCall(s,()=>o(this,t))}),s}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.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(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},o=`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(o,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent&&this.parent.listenerCount(o))s(),this._processArguments(),this.parent.emit(o,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(n=>{let s=n.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let s=e.find(o=>n.conflictsWith.includes(o.attributeName()));s&&this._conflictingOption(n,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],s=t,o=e.slice();function a(l){return l.length>1&&l[0]==="-"}let c=null;for(;o.length;){let l=o.shift();if(l==="--"){s===n&&s.push(l),s.push(...o);break}if(c&&!a(l)){this.emit(`option:${c.name()}`,l);continue}if(c=null,a(l)){let u=this._findOption(l);if(u){if(u.required){let m=o.shift();m===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,m)}else if(u.optional){let m=null;o.length>0&&!a(o[0])&&(m=o.shift()),this.emit(`option:${u.name()}`,m)}else this.emit(`option:${u.name()}`);c=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),o.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),m=this._findOption(l.slice(0,u));if(m&&(m.required||m.optional)){this.emit(`option:${m.name()}`,l.slice(u+1));continue}}if(a(l)&&(s=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),o.length>0&&n.push(...o);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),o.length>0&&t.push(...o);break}else if(this._defaultCommandName){n.push(l),o.length>0&&n.push(...o);break}}if(this._passThroughOptions){s.push(l),o.length>0&&s.push(...o);break}s.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let s=this.options[n].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 n=t||{},s=n.exitCode||1,o=n.code||"commander.error";this._exit(s,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in H.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()}`,H.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new
|
|
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 n=this.parent?._findCommand(e);if(n){let s=[n.name()].concat(n.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(n=>
|
|
26
|
-
Expecting one of '${n.join("', '")}'`);let s=`${e}Help`;return this.on(s,o=>{let
|
|
27
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function
|
|
28
|
-
`)}var Gn,
|
|
29
|
-
`,"utf-8"),t)try{(0,Ae.chmodSync)(r,384)}catch{}}function ke(){return Ct(jr(),null)}function Dr(r){wt(jr(),r,!0)}function Nr(){try{(0,Ae.writeFileSync)(jr(),"{}","utf-8")}catch{}}function ve(){return Ct(Xn(),Di)}function Yn(r){wt(Xn(),r)}function Tt(r){let e=ve();Yn({...e,...r})}function $i(r){if(r.version&&r.version>=2)return r;let e={version:2,installations:r.installations.map(s=>({...s,serverSynced:!1}))},t=$r(),n=Ct(t,null);n?.lastSyncAt&&(e.lastSyncAt=n.lastSyncAt);try{(0,Ae.unlinkSync)(t)}catch{}return e}function q(){let r=Ct(Tr(),Ni),e=$i(r);return(!r.version||r.version<2)&&wt(Tr(),e),e}function Ue(r){wt(Tr(),r)}function le(r){let e=q(),t=e.installations.findIndex(n=>n.resourceId===r.resourceId&&n.agent===r.agent);t>=0?e.installations[t]=r:e.installations.push(r),Ue(e)}function bt(r,e){let t=q();t.installations=t.installations.filter(n=>!(n.resourceId===r&&(!e||n.agent===e))),Ue(t)}function He(){let r=q();delete r.lastSyncAt,Ue(r)}function jt(r){let e=q();r.lastSyncAt!==void 0&&(e.lastSyncAt=r.lastSyncAt),Ue(e)}function $r(){return(0,Qe.join)(Et(),"last-sync.json")}function Li(){return Ct($r(),null)}function Mi(r){wt($r(),r)}function Fr(){let r=parseInt(process.env.SC_SYNC_COOLDOWN||"",10),e=r>=0?r:Fi,t=q();return t.lastSyncAt?Date.now()-new Date(t.lastSyncAt).getTime()>=e:!0}var Ae,Qe,Kn,Jn,Di,Ni,Fi,ue=he(()=>{"use strict";Ae=require("fs"),Qe=require("path"),Kn=require("os"),Jn=(0,Qe.join)((0,Kn.homedir)(),".config","shared-context");Di={apiBase:"https://sharedcontext.ai"};Ni={version:2,installations:[]};Fi=720*60*1e3});var ts={};yt(ts,{del:()=>It,fetchRaw:()=>Lr,get:()=>Z,isAuthenticated:()=>U,patch:()=>Ui,post:()=>L});function Qn(){return ve().apiBase||"https://sharedcontext.ai"}function es(){let r={"Content-Type":"application/json"},e=ke();return e?.token&&(r.Authorization=`Bearer ${e.token}`),r}function U(){return!!ke()?.token}async function Nt(r,e,t,n){let s=`${Qn()}${e}`;try{let o={method:r,headers:es(),body:t?JSON.stringify(t):void 0};n&&(o.signal=AbortSignal.timeout(n));let c=await fetch(s,o),a=c.headers.get("content-type")||"";if(!a.includes("application/json"))return c.ok?{ok:!1,error:{code:"INVALID_RESPONSE",message:`Expected JSON, got ${a||"unknown content type"}`}}:{ok:!1,error:{code:`HTTP_${c.status}`,message:c.statusText}};let l=await c.json();return c.ok?{ok:!0,data:l.data??l}:{ok:!1,error:{code:l?.error?.code||`HTTP_${c.status}`,message:l?.error?.message||l?.message||c.statusText}}}catch(o){return{ok:!1,error:{code:"NETWORK_ERROR",message:o instanceof Error?o.message:"Network request failed"}}}}function Z(r){return Nt("GET",r)}function L(r,e,t){return Nt("POST",r,e,t)}function Ui(r,e){return Nt("PATCH",r,e)}function It(r,e){return Nt("DELETE",r,e)}async function Lr(r){let e=`${Qn()}${r}`,t=await fetch(e,{headers:es()});if(!t.ok)throw new Error(`Download failed: ${t.status} ${t.statusText}`);return Buffer.from(await t.arrayBuffer())}var oe=he(()=>{"use strict";ue()});var Ur=K((Pc,rs)=>{"use strict";rs.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var $t=K(ss=>{"use strict";var ns={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Hi(r){return function(...e){return e.length&&(r=r.replace(/\{(\d)\}/g,(t,n)=>e[n]||"")),new Error("ADM-ZIP: "+r)}}for(let r of Object.keys(ns))ss[r]=Hi(ns[r])});var ls=K((jc,cs)=>{"use strict";var Bi=require("fs"),ae=require("path"),os=Ur(),Wi=$t(),Vi=typeof process=="object"&&process.platform==="win32",is=r=>typeof r=="object"&&r!==null,as=new Uint32Array(256).map((r,e)=>{for(let t=0;t<8;t++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Q(r){this.sep=ae.sep,this.fs=Bi,is(r)&&is(r.fs)&&typeof r.fs.statSync=="function"&&(this.fs=r.fs)}cs.exports=Q;Q.prototype.makeDir=function(r){let e=this;function t(n){let s=n.split(e.sep)[0];n.split(e.sep).forEach(function(o){if(!(!o||o.substr(-1,1)===":")){s+=e.sep+o;var c;try{c=e.fs.statSync(s)}catch{e.fs.mkdirSync(s)}if(c&&c.isFile())throw Wi.FILE_IN_THE_WAY(`"${s}"`)}})}t(r)};Q.prototype.writeFileTo=function(r,e,t,n){let s=this;if(s.fs.existsSync(r)){if(!t)return!1;var o=s.fs.statSync(r);if(o.isDirectory())return!1}var c=ae.dirname(r);s.fs.existsSync(c)||s.makeDir(c);var a;try{a=s.fs.openSync(r,"w",438)}catch{s.fs.chmodSync(r,438),a=s.fs.openSync(r,"w",438)}if(a)try{s.fs.writeSync(a,e,0,e.length,0)}finally{s.fs.closeSync(a)}return s.fs.chmodSync(r,n||438),!0};Q.prototype.writeFileToAsync=function(r,e,t,n,s){typeof n=="function"&&(s=n,n=void 0);let o=this;o.fs.exists(r,function(c){if(c&&!t)return s(!1);o.fs.stat(r,function(a,l){if(c&&l.isDirectory())return s(!1);var u=ae.dirname(r);o.fs.exists(u,function(p){p||o.makeDir(u),o.fs.open(r,"w",438,function(y,b){y?o.fs.chmod(r,438,function(){o.fs.open(r,"w",438,function(f,m){o.fs.write(m,e,0,e.length,0,function(){o.fs.close(m,function(){o.fs.chmod(r,n||438,function(){s(!0)})})})})}):b?o.fs.write(b,e,0,e.length,0,function(){o.fs.close(b,function(){o.fs.chmod(r,n||438,function(){s(!0)})})}):o.fs.chmod(r,n||438,function(){s(!0)})})})})})};Q.prototype.findFiles=function(r){let e=this;function t(n,s,o){typeof s=="boolean"&&(o=s,s=void 0);let c=[];return e.fs.readdirSync(n).forEach(function(a){let l=ae.join(n,a),u=e.fs.statSync(l);(!s||s.test(l))&&c.push(ae.normalize(l)+(u.isDirectory()?e.sep:"")),u.isDirectory()&&o&&(c=c.concat(t(l,s,o)))}),c}return t(r,void 0,!0)};Q.prototype.findFilesAsync=function(r,e){let t=this,n=[];t.fs.readdir(r,function(s,o){if(s)return e(s);let c=o.length;if(!c)return e(null,n);o.forEach(function(a){a=ae.join(r,a),t.fs.stat(a,function(l,u){if(l)return e(l);u&&(n.push(ae.normalize(a)+(u.isDirectory()?t.sep:"")),u.isDirectory()?t.findFilesAsync(a,function(p,y){if(p)return e(p);n=n.concat(y),--c||e(null,n)}):--c||e(null,n))})})})};Q.prototype.getAttributes=function(){};Q.prototype.setAttributes=function(){};Q.crc32update=function(r,e){return as[(r^e)&255]^r>>>8};Q.crc32=function(r){typeof r=="string"&&(r=Buffer.from(r,"utf8"));let e=r.length,t=-1;for(let n=0;n<e;)t=Q.crc32update(t,r[n++]);return~t>>>0};Q.methodToString=function(r){switch(r){case os.STORED:return"STORED ("+r+")";case os.DEFLATED:return"DEFLATED ("+r+")";default:return"UNSUPPORTED ("+r+")"}};Q.canonical=function(r){if(!r)return"";let e=ae.posix.normalize("/"+r.split("\\").join("/"));return ae.join(".",e)};Q.zipnamefix=function(r){if(!r)return"";let e=ae.posix.normalize("/"+r.split("\\").join("/"));return ae.posix.join(".",e)};Q.findLast=function(r,e){if(!Array.isArray(r))throw new TypeError("arr is not array");let t=r.length>>>0;for(let n=t-1;n>=0;n--)if(e(r[n],n,r))return r[n]};Q.sanitize=function(r,e){r=ae.resolve(ae.normalize(r));for(var t=e.split("/"),n=0,s=t.length;n<s;n++){var o=ae.normalize(ae.join(r,t.slice(n,s).join(ae.sep)));if(o.indexOf(r)===0)return o}return ae.normalize(ae.join(r,ae.basename(e)))};Q.toBuffer=function(e,t){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?t(e):Buffer.alloc(0)};Q.readBigUInt64LE=function(r,e){var t=Buffer.from(r.slice(e,e+8));return t.swap64(),parseInt(`0x${t.toString("hex")}`)};Q.fromDOS2Date=function(r){return new Date((r>>25&127)+1980,Math.max((r>>21&15)-1,0),Math.max(r>>16&31,1),r>>11&31,r>>5&63,(r&31)<<1)};Q.fromDate2DOS=function(r){let e=0,t=0;return r.getFullYear()>1979&&(e=(r.getFullYear()-1980&127)<<9|r.getMonth()+1<<5|r.getDate(),t=r.getHours()<<11|r.getMinutes()<<5|r.getSeconds()>>1),e<<16|t};Q.isWin=Vi;Q.crcTable=as});var fs=K((Dc,us)=>{"use strict";var qi=require("path");us.exports=function(r,{fs:e}){var t=r||"",n=o(),s=null;function o(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return t&&e.existsSync(t)?(s=e.statSync(t),n.directory=s.isDirectory(),n.mtime=s.mtime,n.atime=s.atime,n.executable=(73&s.mode)!==0,n.readonly=(128&s.mode)===0,n.hidden=qi.basename(t)[0]==="."):console.warn("Invalid path: "+t),{get directory(){return n.directory},get readOnly(){return n.readonly},get hidden(){return n.hidden},get mtime(){return n.mtime},get atime(){return n.atime},get executable(){return n.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:t,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ps=K((Nc,ds)=>{"use strict";ds.exports={efs:!0,encode:r=>Buffer.from(r,"utf8"),decode:r=>r.toString("utf8")}});var ut=K(($c,lt)=>{"use strict";lt.exports=ls();lt.exports.Constants=Ur();lt.exports.Errors=$t();lt.exports.FileAttr=fs();lt.exports.decoder=ps()});var hs=K((Fc,ms)=>{"use strict";var qe=ut(),j=qe.Constants;ms.exports=function(){var r=20,e=10,t=0,n=0,s=0,o=0,c=0,a=0,l=0,u=0,p=0,y=0,b=0,f=0,m=0;r|=qe.isWin?2560:768,t|=j.FLG_EFS;let C={extraLen:0},h=i=>Math.max(0,i)>>>0,E=i=>Math.max(0,i)&65535,d=i=>Math.max(0,i)&255;return s=qe.fromDate2DOS(new Date),{get made(){return r},set made(i){r=i},get version(){return e},set version(i){e=i},get flags(){return t},set flags(i){t=i},get flags_efs(){return(t&j.FLG_EFS)>0},set flags_efs(i){i?t|=j.FLG_EFS:t&=~j.FLG_EFS},get flags_desc(){return(t&j.FLG_DESC)>0},set flags_desc(i){i?t|=j.FLG_DESC:t&=~j.FLG_DESC},get method(){return n},set method(i){switch(i){case j.STORED:this.version=10;case j.DEFLATED:default:this.version=20}n=i},get time(){return qe.fromDOS2Date(this.timeval)},set time(i){this.timeval=qe.fromDate2DOS(i)},get timeval(){return s},set timeval(i){s=h(i)},get timeHighByte(){return d(s>>>8)},get crc(){return o},set crc(i){o=h(i)},get compressedSize(){return c},set compressedSize(i){c=h(i)},get size(){return a},set size(i){a=h(i)},get fileNameLength(){return l},set fileNameLength(i){l=i},get extraLength(){return u},set extraLength(i){u=i},get extraLocalLength(){return C.extraLen},set extraLocalLength(i){C.extraLen=i},get commentLength(){return p},set commentLength(i){p=i},get diskNumStart(){return y},set diskNumStart(i){y=h(i)},get inAttr(){return b},set inAttr(i){b=h(i)},get attr(){return f},set attr(i){f=h(i)},get fileAttr(){return(f||0)>>16&4095},get offset(){return m},set offset(i){m=h(i)},get encrypted(){return(t&j.FLG_ENC)===j.FLG_ENC},get centralHeaderSize(){return j.CENHDR+l+u+p},get realDataOffset(){return m+j.LOCHDR+C.fnameLen+C.extraLen},get localHeader(){return C},loadLocalHeaderFromBinary:function(i){var g=i.slice(m,m+j.LOCHDR);if(g.readUInt32LE(0)!==j.LOCSIG)throw qe.Errors.INVALID_LOC();C.version=g.readUInt16LE(j.LOCVER),C.flags=g.readUInt16LE(j.LOCFLG),C.method=g.readUInt16LE(j.LOCHOW),C.time=g.readUInt32LE(j.LOCTIM),C.crc=g.readUInt32LE(j.LOCCRC),C.compressedSize=g.readUInt32LE(j.LOCSIZ),C.size=g.readUInt32LE(j.LOCLEN),C.fnameLen=g.readUInt16LE(j.LOCNAM),C.extraLen=g.readUInt16LE(j.LOCEXT);let S=m+j.LOCHDR+C.fnameLen,O=S+C.extraLen;return i.slice(S,O)},loadFromBinary:function(i){if(i.length!==j.CENHDR||i.readUInt32LE(0)!==j.CENSIG)throw qe.Errors.INVALID_CEN();r=i.readUInt16LE(j.CENVEM),e=i.readUInt16LE(j.CENVER),t=i.readUInt16LE(j.CENFLG),n=i.readUInt16LE(j.CENHOW),s=i.readUInt32LE(j.CENTIM),o=i.readUInt32LE(j.CENCRC),c=i.readUInt32LE(j.CENSIZ),a=i.readUInt32LE(j.CENLEN),l=i.readUInt16LE(j.CENNAM),u=i.readUInt16LE(j.CENEXT),p=i.readUInt16LE(j.CENCOM),y=i.readUInt16LE(j.CENDSK),b=i.readUInt16LE(j.CENATT),f=i.readUInt32LE(j.CENATX),m=i.readUInt32LE(j.CENOFF)},localHeaderToBinary:function(){var i=Buffer.alloc(j.LOCHDR);return i.writeUInt32LE(j.LOCSIG,0),i.writeUInt16LE(e,j.LOCVER),i.writeUInt16LE(t,j.LOCFLG),i.writeUInt16LE(n,j.LOCHOW),i.writeUInt32LE(s,j.LOCTIM),i.writeUInt32LE(o,j.LOCCRC),i.writeUInt32LE(c,j.LOCSIZ),i.writeUInt32LE(a,j.LOCLEN),i.writeUInt16LE(l,j.LOCNAM),i.writeUInt16LE(C.extraLen,j.LOCEXT),i},centralHeaderToBinary:function(){var i=Buffer.alloc(j.CENHDR+l+u+p);return i.writeUInt32LE(j.CENSIG,0),i.writeUInt16LE(r,j.CENVEM),i.writeUInt16LE(e,j.CENVER),i.writeUInt16LE(t,j.CENFLG),i.writeUInt16LE(n,j.CENHOW),i.writeUInt32LE(s,j.CENTIM),i.writeUInt32LE(o,j.CENCRC),i.writeUInt32LE(c,j.CENSIZ),i.writeUInt32LE(a,j.CENLEN),i.writeUInt16LE(l,j.CENNAM),i.writeUInt16LE(u,j.CENEXT),i.writeUInt16LE(p,j.CENCOM),i.writeUInt16LE(y,j.CENDSK),i.writeUInt16LE(b,j.CENATT),i.writeUInt32LE(f,j.CENATX),i.writeUInt32LE(m,j.CENOFF),i},toJSON:function(){let i=function(g){return g+" bytes"};return{made:r,version:e,flags:t,method:qe.methodToString(n),time:this.time,crc:"0x"+o.toString(16).toUpperCase(),compressedSize:i(c),size:i(a),fileNameLength:i(l),extraLength:i(u),commentLength:i(p),diskNumStart:y,inAttr:b,attr:f,offset:m,centralHeaderSize:i(j.CENHDR+l+u+p)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ys=K((Lc,gs)=>{"use strict";var ft=ut(),X=ft.Constants;gs.exports=function(){var r=0,e=0,t=0,n=0,s=0;return{get diskEntries(){return r},set diskEntries(o){r=e=o},get totalEntries(){return e},set totalEntries(o){e=r=o},get size(){return t},set size(o){t=o},get offset(){return n},set offset(o){n=o},get commentLength(){return s},set commentLength(o){s=o},get mainHeaderSize(){return X.ENDHDR+s},loadFromBinary:function(o){if((o.length!==X.ENDHDR||o.readUInt32LE(0)!==X.ENDSIG)&&(o.length<X.ZIP64HDR||o.readUInt32LE(0)!==X.ZIP64SIG))throw ft.Errors.INVALID_END();o.readUInt32LE(0)===X.ENDSIG?(r=o.readUInt16LE(X.ENDSUB),e=o.readUInt16LE(X.ENDTOT),t=o.readUInt32LE(X.ENDSIZ),n=o.readUInt32LE(X.ENDOFF),s=o.readUInt16LE(X.ENDCOM)):(r=ft.readBigUInt64LE(o,X.ZIP64SUB),e=ft.readBigUInt64LE(o,X.ZIP64TOT),t=ft.readBigUInt64LE(o,X.ZIP64SIZE),n=ft.readBigUInt64LE(o,X.ZIP64OFF),s=0)},toBinary:function(){var o=Buffer.alloc(X.ENDHDR+s);return o.writeUInt32LE(X.ENDSIG,0),o.writeUInt32LE(0,4),o.writeUInt16LE(r,X.ENDSUB),o.writeUInt16LE(e,X.ENDTOT),o.writeUInt32LE(t,X.ENDSIZ),o.writeUInt32LE(n,X.ENDOFF),o.writeUInt16LE(s,X.ENDCOM),o.fill(" ",X.ENDHDR),o},toJSON:function(){let o=function(c,a){let l=c.toString(16).toUpperCase();for(;l.length<a;)l="0"+l;return"0x"+l};return{diskEntries:r,totalEntries:e,size:t+" bytes",offset:o(n,4),commentLength:s}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Br=K(Hr=>{"use strict";Hr.EntryHeader=hs();Hr.MainHeader=ys()});var Es=K((Uc,Ss)=>{"use strict";Ss.exports=function(r){var e=require("zlib"),t={chunkSize:(parseInt(r.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(r,t)},deflateAsync:function(n){var s=e.createDeflateRaw(t),o=[],c=0;s.on("data",function(a){o.push(a),c+=a.length}),s.on("end",function(){var a=Buffer.alloc(c),l=0;a.fill(0);for(var u=0;u<o.length;u++){var p=o[u];p.copy(a,l),l+=p.length}n&&n(a)}),s.end(r)}}}});var ws=K((Hc,Cs)=>{"use strict";var Gi=+(process.versions?process.versions.node:"").split(".")[0]||0;Cs.exports=function(r,e){var t=require("zlib");let n=Gi>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return t.inflateRawSync(r,n)},inflateAsync:function(s){var o=t.createInflateRaw(n),c=[],a=0;o.on("data",function(l){c.push(l),a+=l.length}),o.on("end",function(){var l=Buffer.alloc(a),u=0;l.fill(0);for(var p=0;p<c.length;p++){var y=c[p];y.copy(l,u),u+=y.length}s&&s(l)}),o.end(r)}}}});var xs=K((Bc,_s)=>{"use strict";var{randomFillSync:bs}=require("crypto"),zi=$t(),Zi=new Uint32Array(256).map((r,e)=>{for(let t=0;t<8;t++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),As=(r,e)=>Math.imul(r,e)>>>0,Is=(r,e)=>Zi[(r^e)&255]^r>>>8,At=()=>typeof bs=="function"?bs(Buffer.alloc(12)):At.node();At.node=()=>{let r=Buffer.alloc(12),e=r.length;for(let t=0;t<e;t++)r[t]=Math.random()*256&255;return r};var Ft={genSalt:At};function Lt(r){let e=Buffer.isBuffer(r)?r:Buffer.from(r);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let t=0;t<e.length;t++)this.updateKeys(e[t])}Lt.prototype.updateKeys=function(r){let e=this.keys;return e[0]=Is(e[0],r),e[1]+=e[0]&255,e[1]=As(e[1],134775813)+1,e[2]=Is(e[2],e[1]>>>24),r};Lt.prototype.next=function(){let r=(this.keys[2]|2)>>>0;return As(r,r^1)>>8&255};function Ji(r){let e=new Lt(r);return function(t){let n=Buffer.alloc(t.length),s=0;for(let o of t)n[s++]=e.updateKeys(o^e.next());return n}}function Ki(r){let e=new Lt(r);return function(t,n,s=0){n||(n=Buffer.alloc(t.length));for(let o of t){let c=e.next();n[s++]=o^c,e.updateKeys(o)}return n}}function Xi(r,e,t){if(!r||!Buffer.isBuffer(r)||r.length<12)return Buffer.alloc(0);let n=Ji(t),s=n(r.slice(0,12)),o=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(s[11]!==o)throw zi.WRONG_PASSWORD();return n(r.slice(12))}function Yi(r){Buffer.isBuffer(r)&&r.length>=12?Ft.genSalt=function(){return r.slice(0,12)}:r==="node"?Ft.genSalt=At.node:Ft.genSalt=At}function Qi(r,e,t,n=!1){r==null&&(r=Buffer.alloc(0)),Buffer.isBuffer(r)||(r=Buffer.from(r.toString()));let s=Ki(t),o=Ft.genSalt();o[11]=e.crc>>>24&255,n&&(o[10]=e.crc>>>16&255);let c=Buffer.alloc(r.length+12);return s(o,c),s(r,c,12)}_s.exports={decrypt:Xi,encrypt:Qi,_salter:Yi}});var Os=K(Mt=>{"use strict";Mt.Deflater=Es();Mt.Inflater=ws();Mt.ZipCrypto=xs()});var Vr=K((Vc,ks)=>{"use strict";var V=ut(),ea=Br(),ee=V.Constants,Wr=Os();ks.exports=function(r,e){var t=new ea.EntryHeader,n=Buffer.alloc(0),s=Buffer.alloc(0),o=!1,c=null,a=Buffer.alloc(0),l=Buffer.alloc(0),u=!0;let p=r,y=typeof p.decoder=="object"?p.decoder:V.decoder;u=y.hasOwnProperty("efs")?y.efs:!1;function b(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(l=t.loadLocalHeaderFromBinary(e),e.slice(t.realDataOffset,t.realDataOffset+t.compressedSize))}function f(i){if(t.flags_desc){let g={},S=t.realDataOffset+t.compressedSize;if(e.readUInt32LE(S)==ee.LOCSIG||e.readUInt32LE(S)==ee.CENSIG)throw V.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(S)==ee.EXTSIG)g.crc=e.readUInt32LE(S+ee.EXTCRC),g.compressedSize=e.readUInt32LE(S+ee.EXTSIZ),g.size=e.readUInt32LE(S+ee.EXTLEN);else if(e.readUInt16LE(S+12)===19280)g.crc=e.readUInt32LE(S+ee.EXTCRC-4),g.compressedSize=e.readUInt32LE(S+ee.EXTSIZ-4),g.size=e.readUInt32LE(S+ee.EXTLEN-4);else throw V.Errors.DESCRIPTOR_UNKNOWN();if(g.compressedSize!==t.compressedSize||g.size!==t.size||g.crc!==t.crc)throw V.Errors.DESCRIPTOR_FAULTY();if(V.crc32(i)!==g.crc)return!1}else if(V.crc32(i)!==t.localHeader.crc)return!1;return!0}function m(i,g,S){if(typeof g>"u"&&typeof i=="string"&&(S=i,i=void 0),o)return i&&g&&g(Buffer.alloc(0),V.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var O=b();if(O.length===0)return i&&g&&g(O),O;if(t.encrypted){if(typeof S!="string"&&!Buffer.isBuffer(S))throw V.Errors.INVALID_PASS_PARAM();O=Wr.ZipCrypto.decrypt(O,t,S)}var _=Buffer.alloc(t.size);switch(t.method){case V.Constants.STORED:if(O.copy(_),f(_))return i&&g&&g(_),_;throw i&&g&&g(_,V.Errors.BAD_CRC()),V.Errors.BAD_CRC();case V.Constants.DEFLATED:var I=new Wr.Inflater(O,t.size);if(i)I.inflateAsync(function(k){k.copy(k,0),g&&(f(k)?g(k):g(k,V.Errors.BAD_CRC()))});else{if(I.inflate(_).copy(_,0),!f(_))throw V.Errors.BAD_CRC(`"${y.decode(n)}"`);return _}break;default:throw i&&g&&g(Buffer.alloc(0),V.Errors.UNKNOWN_METHOD()),V.Errors.UNKNOWN_METHOD()}}function C(i,g){if((!c||!c.length)&&Buffer.isBuffer(e))return i&&g&&g(b()),b();if(c.length&&!o){var S;switch(t.method){case V.Constants.STORED:return t.compressedSize=t.size,S=Buffer.alloc(c.length),c.copy(S),i&&g&&g(S),S;default:case V.Constants.DEFLATED:var O=new Wr.Deflater(c);if(i)O.deflateAsync(function(I){S=Buffer.alloc(I.length),t.compressedSize=I.length,I.copy(S),g&&g(S)});else{var _=O.deflate();return t.compressedSize=_.length,_}O=null;break}}else if(i&&g)g(Buffer.alloc(0));else return Buffer.alloc(0)}function h(i,g){return(i.readUInt32LE(g+4)<<4)+i.readUInt32LE(g)}function E(i){try{for(var g=0,S,O,_;g+4<i.length;)S=i.readUInt16LE(g),g+=2,O=i.readUInt16LE(g),g+=2,_=i.slice(g,g+O),g+=O,ee.ID_ZIP64===S&&d(_)}catch{throw V.Errors.EXTRA_FIELD_PARSE_ERROR()}}function d(i){var g,S,O,_;i.length>=ee.EF_ZIP64_SCOMP&&(g=h(i,ee.EF_ZIP64_SUNCOMP),t.size===ee.EF_ZIP64_OR_32&&(t.size=g)),i.length>=ee.EF_ZIP64_RHO&&(S=h(i,ee.EF_ZIP64_SCOMP),t.compressedSize===ee.EF_ZIP64_OR_32&&(t.compressedSize=S)),i.length>=ee.EF_ZIP64_DSN&&(O=h(i,ee.EF_ZIP64_RHO),t.offset===ee.EF_ZIP64_OR_32&&(t.offset=O)),i.length>=ee.EF_ZIP64_DSN+4&&(_=i.readUInt32LE(ee.EF_ZIP64_DSN),t.diskNumStart===ee.EF_ZIP64_OR_16&&(t.diskNumStart=_))}return{get entryName(){return y.decode(n)},get rawEntryName(){return n},set entryName(i){n=V.toBuffer(i,y.encode);var g=n[n.length-1];o=g===47||g===92,t.fileNameLength=n.length},get efs(){return typeof u=="function"?u(this.entryName):u},get extra(){return a},set extra(i){a=i,t.extraLength=i.length,E(i)},get comment(){return y.decode(s)},set comment(i){if(s=V.toBuffer(i,y.encode),t.commentLength=s.length,s.length>65535)throw V.Errors.COMMENT_TOO_LONG()},get name(){var i=y.decode(n);return o?i.substr(i.length-1).split("/").pop():i.split("/").pop()},get isDirectory(){return o},getCompressedData:function(){return C(!1,null)},getCompressedDataAsync:function(i){C(!0,i)},setData:function(i){c=V.toBuffer(i,V.decoder.encode),!o&&c.length?(t.size=c.length,t.method=V.Constants.DEFLATED,t.crc=V.crc32(i),t.changed=!0):t.method=V.Constants.STORED},getData:function(i){return t.changed?c:m(!1,null,i)},getDataAsync:function(i,g){t.changed?i(c):m(!0,i,g)},set attr(i){t.attr=i},get attr(){return t.attr},set header(i){t.loadFromBinary(i)},get header(){return t},packCentralHeader:function(){t.flags_efs=this.efs,t.extraLength=a.length;var i=t.centralHeaderToBinary(),g=V.Constants.CENHDR;return n.copy(i,g),g+=n.length,a.copy(i,g),g+=t.extraLength,s.copy(i,g),i},packLocalHeader:function(){let i=0;t.flags_efs=this.efs,t.extraLocalLength=l.length;let g=t.localHeaderToBinary(),S=Buffer.alloc(g.length+n.length+t.extraLocalLength);return g.copy(S,i),i+=g.length,n.copy(S,i),i+=n.length,l.copy(S,i),i+=l.length,S},toJSON:function(){let i=function(g){return"<"+(g&&g.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:t.toJSON(),compressedData:i(e),data:i(c)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ps=K((qc,Rs)=>{"use strict";var vs=Vr(),ta=Br(),me=ut();Rs.exports=function(r,e){var t=[],n={},s=Buffer.alloc(0),o=new ta.MainHeader,c=!1,a=null;let l=new Set,u=e,{noSort:p,decoder:y}=u;r?m(u.readEntries):c=!0;function b(){let h=new Set;for(let E of Object.keys(n)){let d=E.split("/");if(d.pop(),!!d.length)for(let i=0;i<d.length;i++){let g=d.slice(0,i+1).join("/")+"/";h.add(g)}}for(let E of h)if(!(E in n)){let d=new vs(u);d.entryName=E,d.attr=16,d.temporary=!0,t.push(d),n[d.entryName]=d,l.add(d)}}function f(){if(c=!0,n={},o.diskEntries>(r.length-o.offset)/me.Constants.CENHDR)throw me.Errors.DISK_ENTRY_TOO_LARGE();t=new Array(o.diskEntries);for(var h=o.offset,E=0;E<t.length;E++){var d=h,i=new vs(u,r);i.header=r.slice(d,d+=me.Constants.CENHDR),i.entryName=r.slice(d,d+=i.header.fileNameLength),i.header.extraLength&&(i.extra=r.slice(d,d+=i.header.extraLength)),i.header.commentLength&&(i.comment=r.slice(d,d+i.header.commentLength)),h+=i.header.centralHeaderSize,t[E]=i,n[i.entryName]=i}l.clear(),b()}function m(h){var E=r.length-me.Constants.ENDHDR,d=Math.max(0,E-65535),i=d,g=r.length,S=-1,O=0;for(typeof u.trailingSpace=="boolean"&&u.trailingSpace&&(d=0),E;E>=i;E--)if(r[E]===80){if(r.readUInt32LE(E)===me.Constants.ENDSIG){S=E,O=E,g=E+me.Constants.ENDHDR,i=E-me.Constants.END64HDR;continue}if(r.readUInt32LE(E)===me.Constants.END64SIG){i=d;continue}if(r.readUInt32LE(E)===me.Constants.ZIP64SIG){S=E,g=E+me.readBigUInt64LE(r,E+me.Constants.ZIP64SIZE)+me.Constants.ZIP64LEAD;break}}if(S==-1)throw me.Errors.INVALID_FORMAT();o.loadFromBinary(r.slice(S,g)),o.commentLength&&(s=r.slice(O+me.Constants.ENDHDR)),h&&f()}function C(){t.length>1&&!p&&t.sort((h,E)=>h.entryName.toLowerCase().localeCompare(E.entryName.toLowerCase()))}return{get entries(){return c||f(),t.filter(h=>!l.has(h))},get comment(){return y.decode(s)},set comment(h){s=me.toBuffer(h,y.encode),o.commentLength=s.length},getEntryCount:function(){return c?t.length:o.diskEntries},forEach:function(h){this.entries.forEach(h)},getEntry:function(h){return c||f(),n[h]||null},setEntry:function(h){c||f(),t.push(h),n[h.entryName]=h,o.totalEntries=t.length},deleteFile:function(h,E=!0){c||f();let d=n[h];this.getEntryChildren(d,E).map(g=>g.entryName).forEach(this.deleteEntry)},deleteEntry:function(h){c||f();let E=n[h],d=t.indexOf(E);d>=0&&(t.splice(d,1),delete n[h],o.totalEntries=t.length)},getEntryChildren:function(h,E=!0){if(c||f(),typeof h=="object")if(h.isDirectory&&E){let d=[],i=h.entryName;for(let g of t)g.entryName.startsWith(i)&&d.push(g);return d}else return[h];return[]},getChildCount:function(h){if(h&&h.isDirectory){let E=this.getEntryChildren(h);return E.includes(h)?E.length-1:E.length}return 0},compressToBuffer:function(){c||f(),C();let h=[],E=[],d=0,i=0;o.size=0,o.offset=0;let g=0;for(let _ of this.entries){let I=_.getCompressedData();_.header.offset=i;let k=_.packLocalHeader(),v=k.length+I.length;i+=v,h.push(k),h.push(I);let P=_.packCentralHeader();E.push(P),o.size+=P.length,d+=v+P.length,g++}d+=o.mainHeaderSize,o.offset=i,o.totalEntries=g,i=0;let S=Buffer.alloc(d);for(let _ of h)_.copy(S,i),i+=_.length;for(let _ of E)_.copy(S,i),i+=_.length;let O=o.toBinary();return s&&s.copy(O,me.Constants.ENDHDR),O.copy(S,i),r=S,c=!1,S},toAsyncBuffer:function(h,E,d,i){try{c||f(),C();let g=[],S=[],O=0,_=0,I=0;o.size=0,o.offset=0;let k=function(v){if(v.length>0){let P=v.shift(),x=P.entryName+P.extra.toString();d&&d(x),P.getCompressedDataAsync(function(T){i&&i(x),P.header.offset=_;let F=P.packLocalHeader(),$=F.length+T.length;_+=$,g.push(F),g.push(T);let M=P.packCentralHeader();S.push(M),o.size+=M.length,O+=$+M.length,I++,k(v)})}else{O+=o.mainHeaderSize,o.offset=_,o.totalEntries=I,_=0;let P=Buffer.alloc(O);g.forEach(function(T){T.copy(P,_),_+=T.length}),S.forEach(function(T){T.copy(P,_),_+=T.length});let x=o.toBinary();s&&s.copy(x,me.Constants.ENDHDR),x.copy(P,_),r=P,c=!1,h(P)}};k(Array.from(this.entries))}catch(g){E(g)}}}}});var Ds=K((Gc,js)=>{"use strict";var Y=ut(),te=require("path"),ra=Vr(),na=Ps(),et=(...r)=>Y.findLast(r,e=>typeof e=="boolean"),Ts=(...r)=>Y.findLast(r,e=>typeof e=="string"),sa=(...r)=>Y.findLast(r,e=>typeof e=="function"),oa={noSort:!1,readEntries:!1,method:Y.Constants.NONE,fs:null};js.exports=function(r,e){let t=null,n=Object.assign(Object.create(null),oa);r&&typeof r=="object"&&(r instanceof Uint8Array||(Object.assign(n,r),r=n.input?n.input:void 0,n.input&&delete n.input),Buffer.isBuffer(r)&&(t=r,n.method=Y.Constants.BUFFER,r=void 0)),Object.assign(n,e);let s=new Y(n);if((typeof n.decoder!="object"||typeof n.decoder.encode!="function"||typeof n.decoder.decode!="function")&&(n.decoder=Y.decoder),r&&typeof r=="string")if(s.fs.existsSync(r))n.method=Y.Constants.FILE,n.filename=r,t=s.fs.readFileSync(r);else throw Y.Errors.INVALID_FILENAME();let o=new na(t,n),{canonical:c,sanitize:a,zipnamefix:l}=Y;function u(f){if(f&&o){var m;if(typeof f=="string"&&(m=o.getEntry(te.posix.normalize(f))),typeof f=="object"&&typeof f.entryName<"u"&&typeof f.header<"u"&&(m=o.getEntry(f.entryName)),m)return m}return null}function p(f){let{join:m,normalize:C,sep:h}=te.posix;return m(".",C(h+f.split("\\").join(h)+h))}function y(f){return f instanceof RegExp?(function(m){return function(C){return m.test(C)}})(f):typeof f!="function"?()=>!0:f}let b=(f,m)=>{let C=m.slice(-1);return C=C===s.sep?s.sep:"",te.relative(f,m)+C};return{readFile:function(f,m){var C=u(f);return C&&C.getData(m)||null},childCount:function(f){let m=u(f);if(m)return o.getChildCount(m)},readFileAsync:function(f,m){var C=u(f);C?C.getDataAsync(m):m(null,"getEntry failed for:"+f)},readAsText:function(f,m){var C=u(f);if(C){var h=C.getData();if(h&&h.length)return h.toString(m||"utf8")}return""},readAsTextAsync:function(f,m,C){var h=u(f);h?h.getDataAsync(function(E,d){if(d){m(E,d);return}E&&E.length?m(E.toString(C||"utf8")):m("")}):m("")},deleteFile:function(f,m=!0){var C=u(f);C&&o.deleteFile(C.entryName,m)},deleteEntry:function(f){var m=u(f);m&&o.deleteEntry(m.entryName)},addZipComment:function(f){o.comment=f},getZipComment:function(){return o.comment||""},addZipEntryComment:function(f,m){var C=u(f);C&&(C.comment=m)},getZipEntryComment:function(f){var m=u(f);return m&&m.comment||""},updateFile:function(f,m){var C=u(f);C&&C.setData(m)},addLocalFile:function(f,m,C,h){if(s.fs.existsSync(f)){m=m?p(m):"";let E=te.win32.basename(te.win32.normalize(f));m+=C||E;let d=s.fs.statSync(f),i=d.isFile()?s.fs.readFileSync(f):Buffer.alloc(0);d.isDirectory()&&(m+=s.sep),this.addFile(m,i,h,d)}else throw Y.Errors.FILE_NOT_FOUND(f)},addLocalFileAsync:function(f,m){f=typeof f=="object"?f:{localPath:f};let C=te.resolve(f.localPath),{comment:h}=f,{zipPath:E,zipName:d}=f,i=this;s.fs.stat(C,function(g,S){if(g)return m(g,!1);E=E?p(E):"";let O=te.win32.basename(te.win32.normalize(C));if(E+=d||O,S.isFile())s.fs.readFile(C,function(_,I){return _?m(_,!1):(i.addFile(E,I,h,S),setImmediate(m,void 0,!0))});else if(S.isDirectory())return E+=s.sep,i.addFile(E,Buffer.alloc(0),h,S),setImmediate(m,void 0,!0)})},addLocalFolder:function(f,m,C){if(C=y(C),m=m?p(m):"",f=te.normalize(f),s.fs.existsSync(f)){let h=s.findFiles(f),E=this;if(h.length)for(let d of h){let i=te.join(m,b(f,d));C(i)&&E.addLocalFile(d,te.dirname(i))}}else throw Y.Errors.FILE_NOT_FOUND(f)},addLocalFolderAsync:function(f,m,C,h){h=y(h),C=C?p(C):"",f=te.normalize(f);var E=this;s.fs.open(f,"r",function(d){if(d&&d.code==="ENOENT")m(void 0,Y.Errors.FILE_NOT_FOUND(f));else if(d)m(void 0,d);else{var i=s.findFiles(f),g=-1,S=function(){if(g+=1,g<i.length){var O=i[g],_=b(f,O).split("\\").join("/");_=_.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),h(_)?s.fs.stat(O,function(I,k){I&&m(void 0,I),k.isFile()?s.fs.readFile(O,function(v,P){v?m(void 0,v):(E.addFile(C+_,P,"",k),S())}):(E.addFile(C+_+"/",Buffer.alloc(0),"",k),S())}):process.nextTick(()=>{S()})}else m(!0,void 0)};S()}})},addLocalFolderAsync2:function(f,m){let C=this;f=typeof f=="object"?f:{localPath:f},localPath=te.resolve(p(f.localPath));let{zipPath:h,filter:E,namefix:d}=f;E instanceof RegExp?E=(function(S){return function(O){return S.test(O)}})(E):typeof E!="function"&&(E=function(){return!0}),h=h?p(h):"",d=="latin1"&&(d=S=>S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof d!="function"&&(d=S=>S);let i=S=>te.join(h,d(b(localPath,S))),g=S=>te.win32.basename(te.win32.normalize(d(S)));s.fs.open(localPath,"r",function(S){S&&S.code==="ENOENT"?m(void 0,Y.Errors.FILE_NOT_FOUND(localPath)):S?m(void 0,S):s.findFilesAsync(localPath,function(O,_){if(O)return m(O);_=_.filter(I=>E(i(I))),_.length||m(void 0,!1),setImmediate(_.reverse().reduce(function(I,k){return function(v,P){if(v||P===!1)return setImmediate(I,v,!1);C.addLocalFileAsync({localPath:k,zipPath:te.dirname(i(k)),zipName:g(k)},I)}},m))})})},addLocalFolderPromise:function(f,m){return new Promise((C,h)=>{this.addLocalFolderAsync2(Object.assign({localPath:f},m),(E,d)=>{E&&h(E),d&&C(this)})})},addFile:function(f,m,C,h){f=l(f);let E=u(f),d=E!=null;d||(E=new ra(n),E.entryName=f),E.comment=C||"";let i=typeof h=="object"&&h instanceof s.fs.Stats;i&&(E.header.time=h.mtime);var g=E.isDirectory?16:0;let S=E.isDirectory?16384:32768;return i?S|=4095&h.mode:typeof h=="number"?S|=4095&h:S|=E.isDirectory?493:420,g=(g|S<<16)>>>0,E.attr=g,E.setData(m),d||o.setEntry(E),E},getEntries:function(f){return o.password=f,o?o.entries:[]},getEntry:function(f){return u(f)},getEntryCount:function(){return o.getEntryCount()},forEach:function(f){return o.forEach(f)},extractEntryTo:function(f,m,C,h,E,d){h=et(!1,h),E=et(!1,E),C=et(!0,C),d=Ts(E,d);var i=u(f);if(!i)throw Y.Errors.NO_ENTRY();var g=c(i.entryName),S=a(m,d&&!i.isDirectory?d:C?g:te.basename(g));if(i.isDirectory){var O=o.getEntryChildren(i);return O.forEach(function(k){if(k.isDirectory)return;var v=k.getData();if(!v)throw Y.Errors.CANT_EXTRACT_FILE();var P=c(k.entryName),x=a(m,C?P:te.basename(P));let T=E?k.header.fileAttr:void 0;s.writeFileTo(x,v,h,T)}),!0}var _=i.getData(o.password);if(!_)throw Y.Errors.CANT_EXTRACT_FILE();if(s.fs.existsSync(S)&&!h)throw Y.Errors.CANT_OVERRIDE();let I=E?f.header.fileAttr:void 0;return s.writeFileTo(S,_,h,I),!0},test:function(f){if(!o)return!1;for(var m in o.entries)try{if(m.isDirectory)continue;var C=o.entries[m].getData(f);if(!C)return!1}catch{return!1}return!0},extractAllTo:function(f,m,C,h){if(C=et(!1,C),h=Ts(C,h),m=et(!1,m),!o)throw Y.Errors.NO_ZIP();o.entries.forEach(function(E){var d=a(f,c(E.entryName));if(E.isDirectory){s.makeDir(d);return}var i=E.getData(h);if(!i)throw Y.Errors.CANT_EXTRACT_FILE();let g=C?E.header.fileAttr:void 0;s.writeFileTo(d,i,m,g);try{s.fs.utimesSync(d,E.header.time,E.header.time)}catch{throw Y.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(f,m,C,h){if(h=sa(m,C,h),C=et(!1,C),m=et(!1,m),!h)return new Promise((S,O)=>{this.extractAllToAsync(f,m,C,function(_){_?O(_):S(this)})});if(!o){h(Y.Errors.NO_ZIP());return}f=te.resolve(f);let E=S=>a(f,te.normalize(c(S.entryName))),d=(S,O)=>new Error(S+': "'+O+'"'),i=[],g=[];o.entries.forEach(S=>{S.isDirectory?i.push(S):g.push(S)});for(let S of i){let O=E(S),_=C?S.header.fileAttr:void 0;try{s.makeDir(O),_&&s.fs.chmodSync(O,_),s.fs.utimesSync(O,S.header.time,S.header.time)}catch{h(d("Unable to create folder",O))}}g.reverse().reduce(function(S,O){return function(_){if(_)S(_);else{let I=te.normalize(c(O.entryName)),k=a(f,I);O.getDataAsync(function(v,P){if(P)S(P);else if(!v)S(Y.Errors.CANT_EXTRACT_FILE());else{let x=C?O.header.fileAttr:void 0;s.writeFileToAsync(k,v,m,x,function(T){T||S(d("Unable to write file",k)),s.fs.utimes(k,O.header.time,O.header.time,function(F){F?S(d("Unable to set times",k)):S()})})}})}}},h)()},writeZip:function(f,m){if(arguments.length===1&&typeof f=="function"&&(m=f,f=""),!f&&n.filename&&(f=n.filename),!!f){var C=o.compressToBuffer();if(C){var h=s.writeFileTo(f,C,!0);typeof m=="function"&&m(h?null:new Error("failed"),"")}}},writeZipPromise:function(f,m){let{overwrite:C,perm:h}=Object.assign({overwrite:!0},m);return new Promise((E,d)=>{!f&&n.filename&&(f=n.filename),f||d("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(i=>{let g=S=>S?E(S):d("ADM-ZIP: Wasn't able to write zip file");s.writeFileToAsync(f,i,C,h,g)},d)})},toBufferPromise:function(){return new Promise((f,m)=>{o.toAsyncBuffer(f,m)})},toBuffer:function(f,m,C,h){return typeof f=="function"?(o.toAsyncBuffer(f,m,C,h),null):o.compressToBuffer()}}}});var Qs={};yt(Qs,{enableTelemetryHook:()=>Ys,registerConfig:()=>rn});function tn(){let r=process.env.SC_PROFILE;return r?(0,Me.join)((0,mt.homedir)(),".config","shared-context","profiles",r):(0,Me.join)((0,mt.homedir)(),".config","shared-context")}function Ys(){try{let r=(0,Me.join)((0,mt.homedir)(),".claude","settings.json"),{readFileSync:e,writeFileSync:t}=require("fs"),n={};try{(0,Ge.existsSync)(r)&&(n=JSON.parse(e(r,"utf8")))}catch{}n.hooks||(n.hooks={});let s=n.hooks;if(s.PostToolUse||(s.PostToolUse=[]),s.PostToolUse.some(p=>p._sc===Xs))return;let c=(0,Me.join)(tn(),"manifest.json"),a="";try{let y=(JSON.parse(e(c,"utf8")).installations||[]).find(b=>b.slug==="telemetry"||b.installPath?.includes("hooks/telemetry"));y?.installPath&&(a=(0,Me.join)((0,mt.homedir)(),".config","shared-context",y.installPath,"scripts","telemetry.js"))}catch{}if((!a||!(0,Ge.existsSync)(a))&&(a=(0,Me.join)(tn(),"hooks","telemetry","scripts","telemetry.js")),!(0,Ge.existsSync)(a))return;s.PostToolUse.push({hooks:[{type:"command",command:`node ${a}`}],_sc:Xs}),s.SessionStart||(s.SessionStart=[]);let l="platform/telemetry-push";s.SessionStart.some(p=>p._sc===l)||s.SessionStart.push({hooks:[{type:"command",command:"npx shared-context-ai telemetry push --quiet 2>/dev/null || true"}],_sc:l}),t(r,JSON.stringify(n,null,2)+`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`).filter(Boolean),t=[];for(let n of e)try{let s=JSON.parse(n);s.v&&s.ts&&s.event&&s.rid&&t.push(s)}catch{}return t}catch{return[]}}function sc(r){let e=ei();if((0,Ye.existsSync)(e))try{let t=(0,Ye.readFileSync)(e,"utf8").trim().split(`
|
|
34
|
-
`).filter(Boolean);if(t.length<=r)return;let n=t.slice(-r);(0,Ye.writeFileSync)(e,n.join(`
|
|
24
|
+
`),this.outputHelp({error:!0}));let n=t||{},s=n.exitCode||1,o=n.code||"commander.error";this._exit(s,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in H.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()}`,H.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new vi(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(s=>!t(s)).forEach(s=>{this.setOptionValueWithSource(s,n.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 n=a=>{let c=a.attributeName(),l=this.getOptionValue(c),u=this.options.find(y=>y.negate&&c===y.attributeName()),m=this.options.find(y=>!y.negate&&c===y.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:m||a},s=a=>{let c=n(a),l=c.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${c.envVar}'`:`option '${c.flags}'`},o=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],o=this;do{let a=o.createHelp().visibleOptions(o).filter(c=>c.long).map(c=>c.long);s=s.concat(a),o=o.parent}while(o&&!o._enablePositionalOptions);t=$n(e,s)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",o=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(o=>{s.push(o.name()),o.alias()&&s.push(o.alias())}),t=$n(e,s)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let s=this.createOption(t,n);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 n=this.parent?._findCommand(e);if(n){let s=[n.name()].concat(n.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(n=>Ai(n));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=Fe.basename(e,Fe.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let s=t.formatHelp(this,t);return n.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(e){e=e||{};let t=!!e.error,n,s,o;return t?(n=c=>this._outputConfiguration.writeErr(c),s=this._outputConfiguration.getErrHasColors(),o=this._outputConfiguration.getErrHelpWidth()):(n=c=>this._outputConfiguration.writeOut(c),s=this._outputConfiguration.getOutHasColors(),o=this._outputConfiguration.getOutHelpWidth()),{error:t,write:c=>(s||(c=this._outputConfiguration.stripColor(c)),n(c)),hasColors:s,helpWidth:o}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),s={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let o=this.helpInformation({error:n.error});if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(o),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(H.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${n.join("', '")}'`);let s=`${e}Help`;return this.on(s,o=>{let a;typeof t=="function"?a=t({error:o.error,command:o.command}):a=t,a&&o.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 Fn(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",s="9229",o;return(o=e.match(/^(--inspect(-brk)?)$/))!==null?t=o[1]:(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=o[1],/^\d+$/.test(o[3])?s=o[3]:n=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=o[1],n=o[3],s=o[4]),t&&s!=="0"?`${t}=${n}:${parseInt(s)+1}`:e})}function Rr(){if(H.env.NO_COLOR||H.env.FORCE_COLOR==="0"||H.env.FORCE_COLOR==="false")return!1;if(H.env.FORCE_COLOR||H.env.CLICOLOR_FORCE!==void 0)return!0}Tr.Command=kr;Tr.useColor=Rr});var Bn=K(ke=>{"use strict";var{Argument:Mn}=Tt(),{Command:Pr}=Ln(),{CommanderError:ki,InvalidArgumentError:Un}=gt(),{Help:Ri}=br(),{Option:Hn}=xr();ke.program=new Pr;ke.createCommand=r=>new Pr(r);ke.createOption=(r,e)=>new Hn(r,e);ke.createArgument=(r,e)=>new Mn(r,e);ke.Command=Pr;ke.Option=Hn;ke.Argument=Mn;ke.Help=Ri;ke.CommanderError=ki;ke.InvalidArgumentError=Un;ke.InvalidOptionArgumentError=Un});function zn(r,e){qn=r,Gn=e}function _(){return qn?!0:Gn?!1:!process.stdout.isTTY}function N(r,e){console.log(JSON.stringify({ok:!0,command:r,data:e}))}function D(r,e,t){console.log(JSON.stringify({ok:!1,command:r,errors:[{code:e,message:t}]}))}function w(r){console.log(r)}function R(r){console.error(r)}function he(r,e=2){if(r.length===0)return"";let t=[];for(let n of r)for(let s=0;s<n.length;s++)t[s]=Math.max(t[s]||0,n[s].length);return r.map(n=>n.map((s,o)=>o<n.length-1?s.padEnd(t[o]+e):s).join("")).join(`
|
|
28
|
+
`)}var qn,Gn,se=Ee(()=>{"use strict";qn=!1,Gn=!1});var Nt={};kt(Nt,{addToManifest:()=>le,clearAuth:()=>$r,clearLastSyncAt:()=>He,getAuth:()=>Re,getConfig:()=>xe,getManifest:()=>q,getSyncState:()=>$i,removeFromManifest:()=>Et,saveAuth:()=>Nr,saveConfig:()=>Xn,saveManifest:()=>Ue,saveSyncState:()=>Fi,shouldSync:()=>Lr,updateConfig:()=>jt,updateManifestMeta:()=>Dt});function ht(){let r=process.env.SC_PROFILE;return r?(0,Xe.join)(Zn,"profiles",r):Zn}function Dr(){return(0,Xe.join)(ht(),"auth.json")}function Kn(){return(0,Xe.join)(ht(),"config.json")}function jr(){return(0,Xe.join)(ht(),"manifest.json")}function Ti(){(0,Ae.mkdirSync)(ht(),{recursive:!0})}function yt(r,e){try{return(0,Ae.existsSync)(r)?JSON.parse((0,Ae.readFileSync)(r,"utf-8")):e}catch{return e}}function St(r,e,t=!1){if(Ti(),(0,Ae.writeFileSync)(r,JSON.stringify(e,null,2)+`
|
|
29
|
+
`,"utf-8"),t)try{(0,Ae.chmodSync)(r,384)}catch{}}function Re(){return yt(Dr(),null)}function Nr(r){St(Dr(),r,!0)}function $r(){try{(0,Ae.writeFileSync)(Dr(),"{}","utf-8")}catch{}}function xe(){return yt(Kn(),Pi)}function Xn(r){St(Kn(),r)}function jt(r){let e=xe();Xn({...e,...r})}function Di(r){if(r.version&&r.version>=2)return r;let e={version:2,installations:r.installations.map(s=>({...s,serverSynced:!1}))},t=Fr(),n=yt(t,null);n?.lastSyncAt&&(e.lastSyncAt=n.lastSyncAt);try{(0,Ae.unlinkSync)(t)}catch{}return e}function q(){let r=yt(jr(),ji),e=Di(r);return(!r.version||r.version<2)&&St(jr(),e),e}function Ue(r){St(jr(),r)}function le(r){let e=q(),t=e.installations.findIndex(n=>n.resourceId===r.resourceId&&n.agent===r.agent);t>=0?e.installations[t]=r:e.installations.push(r),Ue(e)}function Et(r,e){let t=q();t.installations=t.installations.filter(n=>!(n.resourceId===r&&(!e||n.agent===e))),Ue(t)}function He(){let r=q();delete r.lastSyncAt,Ue(r)}function Dt(r){let e=q();r.lastSyncAt!==void 0&&(e.lastSyncAt=r.lastSyncAt),Ue(e)}function Fr(){return(0,Xe.join)(ht(),"last-sync.json")}function $i(){return yt(Fr(),null)}function Fi(r){St(Fr(),r)}function Lr(){let r=parseInt(process.env.SC_SYNC_COOLDOWN||"",10),e=r>=0?r:Ni,t=q();return t.lastSyncAt?Date.now()-new Date(t.lastSyncAt).getTime()>=e:!0}var Ae,Xe,Jn,Zn,Pi,ji,Ni,ue=Ee(()=>{"use strict";Ae=require("fs"),Xe=require("path"),Jn=require("os"),Zn=(0,Xe.join)((0,Jn.homedir)(),".config","shared-context");Pi={apiBase:"https://sharedcontext.ai"};ji={version:2,installations:[]};Ni=720*60*1e3});var es={};kt(es,{del:()=>Ct,fetchRaw:()=>Mr,get:()=>Z,isAuthenticated:()=>U,patch:()=>Li,post:()=>L});function Yn(){return xe().apiBase||"https://sharedcontext.ai"}function Qn(){let r={"Content-Type":"application/json"},e=Re();return e?.token&&(r.Authorization=`Bearer ${e.token}`),r}function U(){return!!Re()?.token}async function $t(r,e,t,n){let s=`${Yn()}${e}`;try{let o={method:r,headers:Qn(),body:t?JSON.stringify(t):void 0};n&&(o.signal=AbortSignal.timeout(n));let a=await fetch(s,o),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(o){return{ok:!1,error:{code:"NETWORK_ERROR",message:o instanceof Error?o.message:"Network request failed"}}}}function Z(r){return $t("GET",r)}function L(r,e,t){return $t("POST",r,e,t)}function Li(r,e){return $t("PATCH",r,e)}function Ct(r,e){return $t("DELETE",r,e)}async function Mr(r){let e=`${Yn()}${r}`,t=await fetch(e,{headers:Qn()});if(!t.ok)throw new Error(`Download failed: ${t.status} ${t.statusText}`);return Buffer.from(await t.arrayBuffer())}var oe=Ee(()=>{"use strict";ue()});var Hr=K((jc,ts)=>{"use strict";ts.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ft=K(ns=>{"use strict";var rs={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Mi(r){return function(...e){return e.length&&(r=r.replace(/\{(\d)\}/g,(t,n)=>e[n]||"")),new Error("ADM-ZIP: "+r)}}for(let r of Object.keys(rs))ns[r]=Mi(rs[r])});var cs=K((Nc,as)=>{"use strict";var Ui=require("fs"),ae=require("path"),ss=Hr(),Hi=Ft(),Bi=typeof process=="object"&&process.platform==="win32",os=r=>typeof r=="object"&&r!==null,is=new Uint32Array(256).map((r,e)=>{for(let t=0;t<8;t++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Q(r){this.sep=ae.sep,this.fs=Ui,os(r)&&os(r.fs)&&typeof r.fs.statSync=="function"&&(this.fs=r.fs)}as.exports=Q;Q.prototype.makeDir=function(r){let e=this;function t(n){let s=n.split(e.sep)[0];n.split(e.sep).forEach(function(o){if(!(!o||o.substr(-1,1)===":")){s+=e.sep+o;var a;try{a=e.fs.statSync(s)}catch{e.fs.mkdirSync(s)}if(a&&a.isFile())throw Hi.FILE_IN_THE_WAY(`"${s}"`)}})}t(r)};Q.prototype.writeFileTo=function(r,e,t,n){let s=this;if(s.fs.existsSync(r)){if(!t)return!1;var o=s.fs.statSync(r);if(o.isDirectory())return!1}var a=ae.dirname(r);s.fs.existsSync(a)||s.makeDir(a);var c;try{c=s.fs.openSync(r,"w",438)}catch{s.fs.chmodSync(r,438),c=s.fs.openSync(r,"w",438)}if(c)try{s.fs.writeSync(c,e,0,e.length,0)}finally{s.fs.closeSync(c)}return s.fs.chmodSync(r,n||438),!0};Q.prototype.writeFileToAsync=function(r,e,t,n,s){typeof n=="function"&&(s=n,n=void 0);let o=this;o.fs.exists(r,function(a){if(a&&!t)return s(!1);o.fs.stat(r,function(c,l){if(a&&l.isDirectory())return s(!1);var u=ae.dirname(r);o.fs.exists(u,function(m){m||o.makeDir(u),o.fs.open(r,"w",438,function(y,I){y?o.fs.chmod(r,438,function(){o.fs.open(r,"w",438,function(f,p){o.fs.write(p,e,0,e.length,0,function(){o.fs.close(p,function(){o.fs.chmod(r,n||438,function(){s(!0)})})})})}):I?o.fs.write(I,e,0,e.length,0,function(){o.fs.close(I,function(){o.fs.chmod(r,n||438,function(){s(!0)})})}):o.fs.chmod(r,n||438,function(){s(!0)})})})})})};Q.prototype.findFiles=function(r){let e=this;function t(n,s,o){typeof s=="boolean"&&(o=s,s=void 0);let a=[];return e.fs.readdirSync(n).forEach(function(c){let l=ae.join(n,c),u=e.fs.statSync(l);(!s||s.test(l))&&a.push(ae.normalize(l)+(u.isDirectory()?e.sep:"")),u.isDirectory()&&o&&(a=a.concat(t(l,s,o)))}),a}return t(r,void 0,!0)};Q.prototype.findFilesAsync=function(r,e){let t=this,n=[];t.fs.readdir(r,function(s,o){if(s)return e(s);let a=o.length;if(!a)return e(null,n);o.forEach(function(c){c=ae.join(r,c),t.fs.stat(c,function(l,u){if(l)return e(l);u&&(n.push(ae.normalize(c)+(u.isDirectory()?t.sep:"")),u.isDirectory()?t.findFilesAsync(c,function(m,y){if(m)return e(m);n=n.concat(y),--a||e(null,n)}):--a||e(null,n))})})})};Q.prototype.getAttributes=function(){};Q.prototype.setAttributes=function(){};Q.crc32update=function(r,e){return is[(r^e)&255]^r>>>8};Q.crc32=function(r){typeof r=="string"&&(r=Buffer.from(r,"utf8"));let e=r.length,t=-1;for(let n=0;n<e;)t=Q.crc32update(t,r[n++]);return~t>>>0};Q.methodToString=function(r){switch(r){case ss.STORED:return"STORED ("+r+")";case ss.DEFLATED:return"DEFLATED ("+r+")";default:return"UNSUPPORTED ("+r+")"}};Q.canonical=function(r){if(!r)return"";let e=ae.posix.normalize("/"+r.split("\\").join("/"));return ae.join(".",e)};Q.zipnamefix=function(r){if(!r)return"";let e=ae.posix.normalize("/"+r.split("\\").join("/"));return ae.posix.join(".",e)};Q.findLast=function(r,e){if(!Array.isArray(r))throw new TypeError("arr is not array");let t=r.length>>>0;for(let n=t-1;n>=0;n--)if(e(r[n],n,r))return r[n]};Q.sanitize=function(r,e){r=ae.resolve(ae.normalize(r));for(var t=e.split("/"),n=0,s=t.length;n<s;n++){var o=ae.normalize(ae.join(r,t.slice(n,s).join(ae.sep)));if(o.indexOf(r)===0)return o}return ae.normalize(ae.join(r,ae.basename(e)))};Q.toBuffer=function(e,t){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?t(e):Buffer.alloc(0)};Q.readBigUInt64LE=function(r,e){var t=Buffer.from(r.slice(e,e+8));return t.swap64(),parseInt(`0x${t.toString("hex")}`)};Q.fromDOS2Date=function(r){return new Date((r>>25&127)+1980,Math.max((r>>21&15)-1,0),Math.max(r>>16&31,1),r>>11&31,r>>5&63,(r&31)<<1)};Q.fromDate2DOS=function(r){let e=0,t=0;return r.getFullYear()>1979&&(e=(r.getFullYear()-1980&127)<<9|r.getMonth()+1<<5|r.getDate(),t=r.getHours()<<11|r.getMinutes()<<5|r.getSeconds()>>1),e<<16|t};Q.isWin=Bi;Q.crcTable=is});var us=K(($c,ls)=>{"use strict";var Wi=require("path");ls.exports=function(r,{fs:e}){var t=r||"",n=o(),s=null;function o(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return t&&e.existsSync(t)?(s=e.statSync(t),n.directory=s.isDirectory(),n.mtime=s.mtime,n.atime=s.atime,n.executable=(73&s.mode)!==0,n.readonly=(128&s.mode)===0,n.hidden=Wi.basename(t)[0]==="."):console.warn("Invalid path: "+t),{get directory(){return n.directory},get readOnly(){return n.readonly},get hidden(){return n.hidden},get mtime(){return n.mtime},get atime(){return n.atime},get executable(){return n.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:t,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ds=K((Fc,fs)=>{"use strict";fs.exports={efs:!0,encode:r=>Buffer.from(r,"utf8"),decode:r=>r.toString("utf8")}});var ct=K((Lc,at)=>{"use strict";at.exports=cs();at.exports.Constants=Hr();at.exports.Errors=Ft();at.exports.FileAttr=us();at.exports.decoder=ds()});var ms=K((Mc,ps)=>{"use strict";var qe=ct(),j=qe.Constants;ps.exports=function(){var r=20,e=10,t=0,n=0,s=0,o=0,a=0,c=0,l=0,u=0,m=0,y=0,I=0,f=0,p=0;r|=qe.isWin?2560:768,t|=j.FLG_EFS;let C={extraLen:0},g=i=>Math.max(0,i)>>>0,E=i=>Math.max(0,i)&65535,d=i=>Math.max(0,i)&255;return s=qe.fromDate2DOS(new Date),{get made(){return r},set made(i){r=i},get version(){return e},set version(i){e=i},get flags(){return t},set flags(i){t=i},get flags_efs(){return(t&j.FLG_EFS)>0},set flags_efs(i){i?t|=j.FLG_EFS:t&=~j.FLG_EFS},get flags_desc(){return(t&j.FLG_DESC)>0},set flags_desc(i){i?t|=j.FLG_DESC:t&=~j.FLG_DESC},get method(){return n},set method(i){switch(i){case j.STORED:this.version=10;case j.DEFLATED:default:this.version=20}n=i},get time(){return qe.fromDOS2Date(this.timeval)},set time(i){this.timeval=qe.fromDate2DOS(i)},get timeval(){return s},set timeval(i){s=g(i)},get timeHighByte(){return d(s>>>8)},get crc(){return o},set crc(i){o=g(i)},get compressedSize(){return a},set compressedSize(i){a=g(i)},get size(){return c},set size(i){c=g(i)},get fileNameLength(){return l},set fileNameLength(i){l=i},get extraLength(){return u},set extraLength(i){u=i},get extraLocalLength(){return C.extraLen},set extraLocalLength(i){C.extraLen=i},get commentLength(){return m},set commentLength(i){m=i},get diskNumStart(){return y},set diskNumStart(i){y=g(i)},get inAttr(){return I},set inAttr(i){I=g(i)},get attr(){return f},set attr(i){f=g(i)},get fileAttr(){return(f||0)>>16&4095},get offset(){return p},set offset(i){p=g(i)},get encrypted(){return(t&j.FLG_ENC)===j.FLG_ENC},get centralHeaderSize(){return j.CENHDR+l+u+m},get realDataOffset(){return p+j.LOCHDR+C.fnameLen+C.extraLen},get localHeader(){return C},loadLocalHeaderFromBinary:function(i){var h=i.slice(p,p+j.LOCHDR);if(h.readUInt32LE(0)!==j.LOCSIG)throw qe.Errors.INVALID_LOC();C.version=h.readUInt16LE(j.LOCVER),C.flags=h.readUInt16LE(j.LOCFLG),C.method=h.readUInt16LE(j.LOCHOW),C.time=h.readUInt32LE(j.LOCTIM),C.crc=h.readUInt32LE(j.LOCCRC),C.compressedSize=h.readUInt32LE(j.LOCSIZ),C.size=h.readUInt32LE(j.LOCLEN),C.fnameLen=h.readUInt16LE(j.LOCNAM),C.extraLen=h.readUInt16LE(j.LOCEXT);let S=p+j.LOCHDR+C.fnameLen,O=S+C.extraLen;return i.slice(S,O)},loadFromBinary:function(i){if(i.length!==j.CENHDR||i.readUInt32LE(0)!==j.CENSIG)throw qe.Errors.INVALID_CEN();r=i.readUInt16LE(j.CENVEM),e=i.readUInt16LE(j.CENVER),t=i.readUInt16LE(j.CENFLG),n=i.readUInt16LE(j.CENHOW),s=i.readUInt32LE(j.CENTIM),o=i.readUInt32LE(j.CENCRC),a=i.readUInt32LE(j.CENSIZ),c=i.readUInt32LE(j.CENLEN),l=i.readUInt16LE(j.CENNAM),u=i.readUInt16LE(j.CENEXT),m=i.readUInt16LE(j.CENCOM),y=i.readUInt16LE(j.CENDSK),I=i.readUInt16LE(j.CENATT),f=i.readUInt32LE(j.CENATX),p=i.readUInt32LE(j.CENOFF)},localHeaderToBinary:function(){var i=Buffer.alloc(j.LOCHDR);return i.writeUInt32LE(j.LOCSIG,0),i.writeUInt16LE(e,j.LOCVER),i.writeUInt16LE(t,j.LOCFLG),i.writeUInt16LE(n,j.LOCHOW),i.writeUInt32LE(s,j.LOCTIM),i.writeUInt32LE(o,j.LOCCRC),i.writeUInt32LE(a,j.LOCSIZ),i.writeUInt32LE(c,j.LOCLEN),i.writeUInt16LE(l,j.LOCNAM),i.writeUInt16LE(C.extraLen,j.LOCEXT),i},centralHeaderToBinary:function(){var i=Buffer.alloc(j.CENHDR+l+u+m);return i.writeUInt32LE(j.CENSIG,0),i.writeUInt16LE(r,j.CENVEM),i.writeUInt16LE(e,j.CENVER),i.writeUInt16LE(t,j.CENFLG),i.writeUInt16LE(n,j.CENHOW),i.writeUInt32LE(s,j.CENTIM),i.writeUInt32LE(o,j.CENCRC),i.writeUInt32LE(a,j.CENSIZ),i.writeUInt32LE(c,j.CENLEN),i.writeUInt16LE(l,j.CENNAM),i.writeUInt16LE(u,j.CENEXT),i.writeUInt16LE(m,j.CENCOM),i.writeUInt16LE(y,j.CENDSK),i.writeUInt16LE(I,j.CENATT),i.writeUInt32LE(f,j.CENATX),i.writeUInt32LE(p,j.CENOFF),i},toJSON:function(){let i=function(h){return h+" bytes"};return{made:r,version:e,flags:t,method:qe.methodToString(n),time:this.time,crc:"0x"+o.toString(16).toUpperCase(),compressedSize:i(a),size:i(c),fileNameLength:i(l),extraLength:i(u),commentLength:i(m),diskNumStart:y,inAttr:I,attr:f,offset:p,centralHeaderSize:i(j.CENHDR+l+u+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var hs=K((Uc,gs)=>{"use strict";var lt=ct(),X=lt.Constants;gs.exports=function(){var r=0,e=0,t=0,n=0,s=0;return{get diskEntries(){return r},set diskEntries(o){r=e=o},get totalEntries(){return e},set totalEntries(o){e=r=o},get size(){return t},set size(o){t=o},get offset(){return n},set offset(o){n=o},get commentLength(){return s},set commentLength(o){s=o},get mainHeaderSize(){return X.ENDHDR+s},loadFromBinary:function(o){if((o.length!==X.ENDHDR||o.readUInt32LE(0)!==X.ENDSIG)&&(o.length<X.ZIP64HDR||o.readUInt32LE(0)!==X.ZIP64SIG))throw lt.Errors.INVALID_END();o.readUInt32LE(0)===X.ENDSIG?(r=o.readUInt16LE(X.ENDSUB),e=o.readUInt16LE(X.ENDTOT),t=o.readUInt32LE(X.ENDSIZ),n=o.readUInt32LE(X.ENDOFF),s=o.readUInt16LE(X.ENDCOM)):(r=lt.readBigUInt64LE(o,X.ZIP64SUB),e=lt.readBigUInt64LE(o,X.ZIP64TOT),t=lt.readBigUInt64LE(o,X.ZIP64SIZE),n=lt.readBigUInt64LE(o,X.ZIP64OFF),s=0)},toBinary:function(){var o=Buffer.alloc(X.ENDHDR+s);return o.writeUInt32LE(X.ENDSIG,0),o.writeUInt32LE(0,4),o.writeUInt16LE(r,X.ENDSUB),o.writeUInt16LE(e,X.ENDTOT),o.writeUInt32LE(t,X.ENDSIZ),o.writeUInt32LE(n,X.ENDOFF),o.writeUInt16LE(s,X.ENDCOM),o.fill(" ",X.ENDHDR),o},toJSON:function(){let o=function(a,c){let l=a.toString(16).toUpperCase();for(;l.length<c;)l="0"+l;return"0x"+l};return{diskEntries:r,totalEntries:e,size:t+" bytes",offset:o(n,4),commentLength:s}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Wr=K(Br=>{"use strict";Br.EntryHeader=ms();Br.MainHeader=hs()});var Ss=K((Bc,ys)=>{"use strict";ys.exports=function(r){var e=require("zlib"),t={chunkSize:(parseInt(r.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(r,t)},deflateAsync:function(n){var s=e.createDeflateRaw(t),o=[],a=0;s.on("data",function(c){o.push(c),a+=c.length}),s.on("end",function(){var c=Buffer.alloc(a),l=0;c.fill(0);for(var u=0;u<o.length;u++){var m=o[u];m.copy(c,l),l+=m.length}n&&n(c)}),s.end(r)}}}});var Cs=K((Wc,Es)=>{"use strict";var Vi=+(process.versions?process.versions.node:"").split(".")[0]||0;Es.exports=function(r,e){var t=require("zlib");let n=Vi>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return t.inflateRawSync(r,n)},inflateAsync:function(s){var o=t.createInflateRaw(n),a=[],c=0;o.on("data",function(l){a.push(l),c+=l.length}),o.on("end",function(){var l=Buffer.alloc(c),u=0;l.fill(0);for(var m=0;m<a.length;m++){var y=a[m];y.copy(l,u),u+=y.length}s&&s(l)}),o.end(r)}}}});var As=K((Vc,_s)=>{"use strict";var{randomFillSync:ws}=require("crypto"),qi=Ft(),Gi=new Uint32Array(256).map((r,e)=>{for(let t=0;t<8;t++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Is=(r,e)=>Math.imul(r,e)>>>0,bs=(r,e)=>Gi[(r^e)&255]^r>>>8,wt=()=>typeof ws=="function"?ws(Buffer.alloc(12)):wt.node();wt.node=()=>{let r=Buffer.alloc(12),e=r.length;for(let t=0;t<e;t++)r[t]=Math.random()*256&255;return r};var Lt={genSalt:wt};function Mt(r){let e=Buffer.isBuffer(r)?r:Buffer.from(r);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let t=0;t<e.length;t++)this.updateKeys(e[t])}Mt.prototype.updateKeys=function(r){let e=this.keys;return e[0]=bs(e[0],r),e[1]+=e[0]&255,e[1]=Is(e[1],134775813)+1,e[2]=bs(e[2],e[1]>>>24),r};Mt.prototype.next=function(){let r=(this.keys[2]|2)>>>0;return Is(r,r^1)>>8&255};function zi(r){let e=new Mt(r);return function(t){let n=Buffer.alloc(t.length),s=0;for(let o of t)n[s++]=e.updateKeys(o^e.next());return n}}function Zi(r){let e=new Mt(r);return function(t,n,s=0){n||(n=Buffer.alloc(t.length));for(let o of t){let a=e.next();n[s++]=o^a,e.updateKeys(o)}return n}}function Ji(r,e,t){if(!r||!Buffer.isBuffer(r)||r.length<12)return Buffer.alloc(0);let n=zi(t),s=n(r.slice(0,12)),o=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(s[11]!==o)throw qi.WRONG_PASSWORD();return n(r.slice(12))}function Ki(r){Buffer.isBuffer(r)&&r.length>=12?Lt.genSalt=function(){return r.slice(0,12)}:r==="node"?Lt.genSalt=wt.node:Lt.genSalt=wt}function Xi(r,e,t,n=!1){r==null&&(r=Buffer.alloc(0)),Buffer.isBuffer(r)||(r=Buffer.from(r.toString()));let s=Zi(t),o=Lt.genSalt();o[11]=e.crc>>>24&255,n&&(o[10]=e.crc>>>16&255);let a=Buffer.alloc(r.length+12);return s(o,a),s(r,a,12)}_s.exports={decrypt:Ji,encrypt:Xi,_salter:Ki}});var xs=K(Ut=>{"use strict";Ut.Deflater=Ss();Ut.Inflater=Cs();Ut.ZipCrypto=As()});var qr=K((Gc,Os)=>{"use strict";var V=ct(),Yi=Wr(),ee=V.Constants,Vr=xs();Os.exports=function(r,e){var t=new Yi.EntryHeader,n=Buffer.alloc(0),s=Buffer.alloc(0),o=!1,a=null,c=Buffer.alloc(0),l=Buffer.alloc(0),u=!0;let m=r,y=typeof m.decoder=="object"?m.decoder:V.decoder;u=y.hasOwnProperty("efs")?y.efs:!1;function I(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(l=t.loadLocalHeaderFromBinary(e),e.slice(t.realDataOffset,t.realDataOffset+t.compressedSize))}function f(i){if(t.flags_desc){let h={},S=t.realDataOffset+t.compressedSize;if(e.readUInt32LE(S)==ee.LOCSIG||e.readUInt32LE(S)==ee.CENSIG)throw V.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(S)==ee.EXTSIG)h.crc=e.readUInt32LE(S+ee.EXTCRC),h.compressedSize=e.readUInt32LE(S+ee.EXTSIZ),h.size=e.readUInt32LE(S+ee.EXTLEN);else if(e.readUInt16LE(S+12)===19280)h.crc=e.readUInt32LE(S+ee.EXTCRC-4),h.compressedSize=e.readUInt32LE(S+ee.EXTSIZ-4),h.size=e.readUInt32LE(S+ee.EXTLEN-4);else throw V.Errors.DESCRIPTOR_UNKNOWN();if(h.compressedSize!==t.compressedSize||h.size!==t.size||h.crc!==t.crc)throw V.Errors.DESCRIPTOR_FAULTY();if(V.crc32(i)!==h.crc)return!1}else if(V.crc32(i)!==t.localHeader.crc)return!1;return!0}function p(i,h,S){if(typeof h>"u"&&typeof i=="string"&&(S=i,i=void 0),o)return i&&h&&h(Buffer.alloc(0),V.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var O=I();if(O.length===0)return i&&h&&h(O),O;if(t.encrypted){if(typeof S!="string"&&!Buffer.isBuffer(S))throw V.Errors.INVALID_PASS_PARAM();O=Vr.ZipCrypto.decrypt(O,t,S)}var A=Buffer.alloc(t.size);switch(t.method){case V.Constants.STORED:if(O.copy(A),f(A))return i&&h&&h(A),A;throw i&&h&&h(A,V.Errors.BAD_CRC()),V.Errors.BAD_CRC();case V.Constants.DEFLATED:var b=new Vr.Inflater(O,t.size);if(i)b.inflateAsync(function(v){v.copy(v,0),h&&(f(v)?h(v):h(v,V.Errors.BAD_CRC()))});else{if(b.inflate(A).copy(A,0),!f(A))throw V.Errors.BAD_CRC(`"${y.decode(n)}"`);return A}break;default:throw i&&h&&h(Buffer.alloc(0),V.Errors.UNKNOWN_METHOD()),V.Errors.UNKNOWN_METHOD()}}function C(i,h){if((!a||!a.length)&&Buffer.isBuffer(e))return i&&h&&h(I()),I();if(a.length&&!o){var S;switch(t.method){case V.Constants.STORED:return t.compressedSize=t.size,S=Buffer.alloc(a.length),a.copy(S),i&&h&&h(S),S;default:case V.Constants.DEFLATED:var O=new Vr.Deflater(a);if(i)O.deflateAsync(function(b){S=Buffer.alloc(b.length),t.compressedSize=b.length,b.copy(S),h&&h(S)});else{var A=O.deflate();return t.compressedSize=A.length,A}O=null;break}}else if(i&&h)h(Buffer.alloc(0));else return Buffer.alloc(0)}function g(i,h){return(i.readUInt32LE(h+4)<<4)+i.readUInt32LE(h)}function E(i){try{for(var h=0,S,O,A;h+4<i.length;)S=i.readUInt16LE(h),h+=2,O=i.readUInt16LE(h),h+=2,A=i.slice(h,h+O),h+=O,ee.ID_ZIP64===S&&d(A)}catch{throw V.Errors.EXTRA_FIELD_PARSE_ERROR()}}function d(i){var h,S,O,A;i.length>=ee.EF_ZIP64_SCOMP&&(h=g(i,ee.EF_ZIP64_SUNCOMP),t.size===ee.EF_ZIP64_OR_32&&(t.size=h)),i.length>=ee.EF_ZIP64_RHO&&(S=g(i,ee.EF_ZIP64_SCOMP),t.compressedSize===ee.EF_ZIP64_OR_32&&(t.compressedSize=S)),i.length>=ee.EF_ZIP64_DSN&&(O=g(i,ee.EF_ZIP64_RHO),t.offset===ee.EF_ZIP64_OR_32&&(t.offset=O)),i.length>=ee.EF_ZIP64_DSN+4&&(A=i.readUInt32LE(ee.EF_ZIP64_DSN),t.diskNumStart===ee.EF_ZIP64_OR_16&&(t.diskNumStart=A))}return{get entryName(){return y.decode(n)},get rawEntryName(){return n},set entryName(i){n=V.toBuffer(i,y.encode);var h=n[n.length-1];o=h===47||h===92,t.fileNameLength=n.length},get efs(){return typeof u=="function"?u(this.entryName):u},get extra(){return c},set extra(i){c=i,t.extraLength=i.length,E(i)},get comment(){return y.decode(s)},set comment(i){if(s=V.toBuffer(i,y.encode),t.commentLength=s.length,s.length>65535)throw V.Errors.COMMENT_TOO_LONG()},get name(){var i=y.decode(n);return o?i.substr(i.length-1).split("/").pop():i.split("/").pop()},get isDirectory(){return o},getCompressedData:function(){return C(!1,null)},getCompressedDataAsync:function(i){C(!0,i)},setData:function(i){a=V.toBuffer(i,V.decoder.encode),!o&&a.length?(t.size=a.length,t.method=V.Constants.DEFLATED,t.crc=V.crc32(i),t.changed=!0):t.method=V.Constants.STORED},getData:function(i){return t.changed?a:p(!1,null,i)},getDataAsync:function(i,h){t.changed?i(a):p(!0,i,h)},set attr(i){t.attr=i},get attr(){return t.attr},set header(i){t.loadFromBinary(i)},get header(){return t},packCentralHeader:function(){t.flags_efs=this.efs,t.extraLength=c.length;var i=t.centralHeaderToBinary(),h=V.Constants.CENHDR;return n.copy(i,h),h+=n.length,c.copy(i,h),h+=t.extraLength,s.copy(i,h),i},packLocalHeader:function(){let i=0;t.flags_efs=this.efs,t.extraLocalLength=l.length;let h=t.localHeaderToBinary(),S=Buffer.alloc(h.length+n.length+t.extraLocalLength);return h.copy(S,i),i+=h.length,n.copy(S,i),i+=n.length,l.copy(S,i),i+=l.length,S},toJSON:function(){let i=function(h){return"<"+(h&&h.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:t.toJSON(),compressedData:i(e),data:i(a)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Rs=K((zc,ks)=>{"use strict";var vs=qr(),Qi=Wr(),me=ct();ks.exports=function(r,e){var t=[],n={},s=Buffer.alloc(0),o=new Qi.MainHeader,a=!1,c=null;let l=new Set,u=e,{noSort:m,decoder:y}=u;r?p(u.readEntries):a=!0;function I(){let g=new Set;for(let E of Object.keys(n)){let d=E.split("/");if(d.pop(),!!d.length)for(let i=0;i<d.length;i++){let h=d.slice(0,i+1).join("/")+"/";g.add(h)}}for(let E of g)if(!(E in n)){let d=new vs(u);d.entryName=E,d.attr=16,d.temporary=!0,t.push(d),n[d.entryName]=d,l.add(d)}}function f(){if(a=!0,n={},o.diskEntries>(r.length-o.offset)/me.Constants.CENHDR)throw me.Errors.DISK_ENTRY_TOO_LARGE();t=new Array(o.diskEntries);for(var g=o.offset,E=0;E<t.length;E++){var d=g,i=new vs(u,r);i.header=r.slice(d,d+=me.Constants.CENHDR),i.entryName=r.slice(d,d+=i.header.fileNameLength),i.header.extraLength&&(i.extra=r.slice(d,d+=i.header.extraLength)),i.header.commentLength&&(i.comment=r.slice(d,d+i.header.commentLength)),g+=i.header.centralHeaderSize,t[E]=i,n[i.entryName]=i}l.clear(),I()}function p(g){var E=r.length-me.Constants.ENDHDR,d=Math.max(0,E-65535),i=d,h=r.length,S=-1,O=0;for(typeof u.trailingSpace=="boolean"&&u.trailingSpace&&(d=0),E;E>=i;E--)if(r[E]===80){if(r.readUInt32LE(E)===me.Constants.ENDSIG){S=E,O=E,h=E+me.Constants.ENDHDR,i=E-me.Constants.END64HDR;continue}if(r.readUInt32LE(E)===me.Constants.END64SIG){i=d;continue}if(r.readUInt32LE(E)===me.Constants.ZIP64SIG){S=E,h=E+me.readBigUInt64LE(r,E+me.Constants.ZIP64SIZE)+me.Constants.ZIP64LEAD;break}}if(S==-1)throw me.Errors.INVALID_FORMAT();o.loadFromBinary(r.slice(S,h)),o.commentLength&&(s=r.slice(O+me.Constants.ENDHDR)),g&&f()}function C(){t.length>1&&!m&&t.sort((g,E)=>g.entryName.toLowerCase().localeCompare(E.entryName.toLowerCase()))}return{get entries(){return a||f(),t.filter(g=>!l.has(g))},get comment(){return y.decode(s)},set comment(g){s=me.toBuffer(g,y.encode),o.commentLength=s.length},getEntryCount:function(){return a?t.length:o.diskEntries},forEach:function(g){this.entries.forEach(g)},getEntry:function(g){return a||f(),n[g]||null},setEntry:function(g){a||f(),t.push(g),n[g.entryName]=g,o.totalEntries=t.length},deleteFile:function(g,E=!0){a||f();let d=n[g];this.getEntryChildren(d,E).map(h=>h.entryName).forEach(this.deleteEntry)},deleteEntry:function(g){a||f();let E=n[g],d=t.indexOf(E);d>=0&&(t.splice(d,1),delete n[g],o.totalEntries=t.length)},getEntryChildren:function(g,E=!0){if(a||f(),typeof g=="object")if(g.isDirectory&&E){let d=[],i=g.entryName;for(let h of t)h.entryName.startsWith(i)&&d.push(h);return d}else return[g];return[]},getChildCount:function(g){if(g&&g.isDirectory){let E=this.getEntryChildren(g);return E.includes(g)?E.length-1:E.length}return 0},compressToBuffer:function(){a||f(),C();let g=[],E=[],d=0,i=0;o.size=0,o.offset=0;let h=0;for(let A of this.entries){let b=A.getCompressedData();A.header.offset=i;let v=A.packLocalHeader(),k=v.length+b.length;i+=k,g.push(v),g.push(b);let T=A.packCentralHeader();E.push(T),o.size+=T.length,d+=k+T.length,h++}d+=o.mainHeaderSize,o.offset=i,o.totalEntries=h,i=0;let S=Buffer.alloc(d);for(let A of g)A.copy(S,i),i+=A.length;for(let A of E)A.copy(S,i),i+=A.length;let O=o.toBinary();return s&&s.copy(O,me.Constants.ENDHDR),O.copy(S,i),r=S,a=!1,S},toAsyncBuffer:function(g,E,d,i){try{a||f(),C();let h=[],S=[],O=0,A=0,b=0;o.size=0,o.offset=0;let v=function(k){if(k.length>0){let T=k.shift(),x=T.entryName+T.extra.toString();d&&d(x),T.getCompressedDataAsync(function(P){i&&i(x),T.header.offset=A;let F=T.packLocalHeader(),$=F.length+P.length;A+=$,h.push(F),h.push(P);let M=T.packCentralHeader();S.push(M),o.size+=M.length,O+=$+M.length,b++,v(k)})}else{O+=o.mainHeaderSize,o.offset=A,o.totalEntries=b,A=0;let T=Buffer.alloc(O);h.forEach(function(P){P.copy(T,A),A+=P.length}),S.forEach(function(P){P.copy(T,A),A+=P.length});let x=o.toBinary();s&&s.copy(x,me.Constants.ENDHDR),x.copy(T,A),r=T,a=!1,g(T)}};v(Array.from(this.entries))}catch(h){E(h)}}}}});var js=K((Zc,Ps)=>{"use strict";var Y=ct(),te=require("path"),ea=qr(),ta=Rs(),Ye=(...r)=>Y.findLast(r,e=>typeof e=="boolean"),Ts=(...r)=>Y.findLast(r,e=>typeof e=="string"),ra=(...r)=>Y.findLast(r,e=>typeof e=="function"),na={noSort:!1,readEntries:!1,method:Y.Constants.NONE,fs:null};Ps.exports=function(r,e){let t=null,n=Object.assign(Object.create(null),na);r&&typeof r=="object"&&(r instanceof Uint8Array||(Object.assign(n,r),r=n.input?n.input:void 0,n.input&&delete n.input),Buffer.isBuffer(r)&&(t=r,n.method=Y.Constants.BUFFER,r=void 0)),Object.assign(n,e);let s=new Y(n);if((typeof n.decoder!="object"||typeof n.decoder.encode!="function"||typeof n.decoder.decode!="function")&&(n.decoder=Y.decoder),r&&typeof r=="string")if(s.fs.existsSync(r))n.method=Y.Constants.FILE,n.filename=r,t=s.fs.readFileSync(r);else throw Y.Errors.INVALID_FILENAME();let o=new ta(t,n),{canonical:a,sanitize:c,zipnamefix:l}=Y;function u(f){if(f&&o){var p;if(typeof f=="string"&&(p=o.getEntry(te.posix.normalize(f))),typeof f=="object"&&typeof f.entryName<"u"&&typeof f.header<"u"&&(p=o.getEntry(f.entryName)),p)return p}return null}function m(f){let{join:p,normalize:C,sep:g}=te.posix;return p(".",C(g+f.split("\\").join(g)+g))}function y(f){return f instanceof RegExp?(function(p){return function(C){return p.test(C)}})(f):typeof f!="function"?()=>!0:f}let I=(f,p)=>{let C=p.slice(-1);return C=C===s.sep?s.sep:"",te.relative(f,p)+C};return{readFile:function(f,p){var C=u(f);return C&&C.getData(p)||null},childCount:function(f){let p=u(f);if(p)return o.getChildCount(p)},readFileAsync:function(f,p){var C=u(f);C?C.getDataAsync(p):p(null,"getEntry failed for:"+f)},readAsText:function(f,p){var C=u(f);if(C){var g=C.getData();if(g&&g.length)return g.toString(p||"utf8")}return""},readAsTextAsync:function(f,p,C){var g=u(f);g?g.getDataAsync(function(E,d){if(d){p(E,d);return}E&&E.length?p(E.toString(C||"utf8")):p("")}):p("")},deleteFile:function(f,p=!0){var C=u(f);C&&o.deleteFile(C.entryName,p)},deleteEntry:function(f){var p=u(f);p&&o.deleteEntry(p.entryName)},addZipComment:function(f){o.comment=f},getZipComment:function(){return o.comment||""},addZipEntryComment:function(f,p){var C=u(f);C&&(C.comment=p)},getZipEntryComment:function(f){var p=u(f);return p&&p.comment||""},updateFile:function(f,p){var C=u(f);C&&C.setData(p)},addLocalFile:function(f,p,C,g){if(s.fs.existsSync(f)){p=p?m(p):"";let E=te.win32.basename(te.win32.normalize(f));p+=C||E;let d=s.fs.statSync(f),i=d.isFile()?s.fs.readFileSync(f):Buffer.alloc(0);d.isDirectory()&&(p+=s.sep),this.addFile(p,i,g,d)}else throw Y.Errors.FILE_NOT_FOUND(f)},addLocalFileAsync:function(f,p){f=typeof f=="object"?f:{localPath:f};let C=te.resolve(f.localPath),{comment:g}=f,{zipPath:E,zipName:d}=f,i=this;s.fs.stat(C,function(h,S){if(h)return p(h,!1);E=E?m(E):"";let O=te.win32.basename(te.win32.normalize(C));if(E+=d||O,S.isFile())s.fs.readFile(C,function(A,b){return A?p(A,!1):(i.addFile(E,b,g,S),setImmediate(p,void 0,!0))});else if(S.isDirectory())return E+=s.sep,i.addFile(E,Buffer.alloc(0),g,S),setImmediate(p,void 0,!0)})},addLocalFolder:function(f,p,C){if(C=y(C),p=p?m(p):"",f=te.normalize(f),s.fs.existsSync(f)){let g=s.findFiles(f),E=this;if(g.length)for(let d of g){let i=te.join(p,I(f,d));C(i)&&E.addLocalFile(d,te.dirname(i))}}else throw Y.Errors.FILE_NOT_FOUND(f)},addLocalFolderAsync:function(f,p,C,g){g=y(g),C=C?m(C):"",f=te.normalize(f);var E=this;s.fs.open(f,"r",function(d){if(d&&d.code==="ENOENT")p(void 0,Y.Errors.FILE_NOT_FOUND(f));else if(d)p(void 0,d);else{var i=s.findFiles(f),h=-1,S=function(){if(h+=1,h<i.length){var O=i[h],A=I(f,O).split("\\").join("/");A=A.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),g(A)?s.fs.stat(O,function(b,v){b&&p(void 0,b),v.isFile()?s.fs.readFile(O,function(k,T){k?p(void 0,k):(E.addFile(C+A,T,"",v),S())}):(E.addFile(C+A+"/",Buffer.alloc(0),"",v),S())}):process.nextTick(()=>{S()})}else p(!0,void 0)};S()}})},addLocalFolderAsync2:function(f,p){let C=this;f=typeof f=="object"?f:{localPath:f},localPath=te.resolve(m(f.localPath));let{zipPath:g,filter:E,namefix:d}=f;E instanceof RegExp?E=(function(S){return function(O){return S.test(O)}})(E):typeof E!="function"&&(E=function(){return!0}),g=g?m(g):"",d=="latin1"&&(d=S=>S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof d!="function"&&(d=S=>S);let i=S=>te.join(g,d(I(localPath,S))),h=S=>te.win32.basename(te.win32.normalize(d(S)));s.fs.open(localPath,"r",function(S){S&&S.code==="ENOENT"?p(void 0,Y.Errors.FILE_NOT_FOUND(localPath)):S?p(void 0,S):s.findFilesAsync(localPath,function(O,A){if(O)return p(O);A=A.filter(b=>E(i(b))),A.length||p(void 0,!1),setImmediate(A.reverse().reduce(function(b,v){return function(k,T){if(k||T===!1)return setImmediate(b,k,!1);C.addLocalFileAsync({localPath:v,zipPath:te.dirname(i(v)),zipName:h(v)},b)}},p))})})},addLocalFolderPromise:function(f,p){return new Promise((C,g)=>{this.addLocalFolderAsync2(Object.assign({localPath:f},p),(E,d)=>{E&&g(E),d&&C(this)})})},addFile:function(f,p,C,g){f=l(f);let E=u(f),d=E!=null;d||(E=new ea(n),E.entryName=f),E.comment=C||"";let i=typeof g=="object"&&g instanceof s.fs.Stats;i&&(E.header.time=g.mtime);var h=E.isDirectory?16:0;let S=E.isDirectory?16384:32768;return i?S|=4095&g.mode:typeof g=="number"?S|=4095&g:S|=E.isDirectory?493:420,h=(h|S<<16)>>>0,E.attr=h,E.setData(p),d||o.setEntry(E),E},getEntries:function(f){return o.password=f,o?o.entries:[]},getEntry:function(f){return u(f)},getEntryCount:function(){return o.getEntryCount()},forEach:function(f){return o.forEach(f)},extractEntryTo:function(f,p,C,g,E,d){g=Ye(!1,g),E=Ye(!1,E),C=Ye(!0,C),d=Ts(E,d);var i=u(f);if(!i)throw Y.Errors.NO_ENTRY();var h=a(i.entryName),S=c(p,d&&!i.isDirectory?d:C?h:te.basename(h));if(i.isDirectory){var O=o.getEntryChildren(i);return O.forEach(function(v){if(v.isDirectory)return;var k=v.getData();if(!k)throw Y.Errors.CANT_EXTRACT_FILE();var T=a(v.entryName),x=c(p,C?T:te.basename(T));let P=E?v.header.fileAttr:void 0;s.writeFileTo(x,k,g,P)}),!0}var A=i.getData(o.password);if(!A)throw Y.Errors.CANT_EXTRACT_FILE();if(s.fs.existsSync(S)&&!g)throw Y.Errors.CANT_OVERRIDE();let b=E?f.header.fileAttr:void 0;return s.writeFileTo(S,A,g,b),!0},test:function(f){if(!o)return!1;for(var p in o.entries)try{if(p.isDirectory)continue;var C=o.entries[p].getData(f);if(!C)return!1}catch{return!1}return!0},extractAllTo:function(f,p,C,g){if(C=Ye(!1,C),g=Ts(C,g),p=Ye(!1,p),!o)throw Y.Errors.NO_ZIP();o.entries.forEach(function(E){var d=c(f,a(E.entryName));if(E.isDirectory){s.makeDir(d);return}var i=E.getData(g);if(!i)throw Y.Errors.CANT_EXTRACT_FILE();let h=C?E.header.fileAttr:void 0;s.writeFileTo(d,i,p,h);try{s.fs.utimesSync(d,E.header.time,E.header.time)}catch{throw Y.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(f,p,C,g){if(g=ra(p,C,g),C=Ye(!1,C),p=Ye(!1,p),!g)return new Promise((S,O)=>{this.extractAllToAsync(f,p,C,function(A){A?O(A):S(this)})});if(!o){g(Y.Errors.NO_ZIP());return}f=te.resolve(f);let E=S=>c(f,te.normalize(a(S.entryName))),d=(S,O)=>new Error(S+': "'+O+'"'),i=[],h=[];o.entries.forEach(S=>{S.isDirectory?i.push(S):h.push(S)});for(let S of i){let O=E(S),A=C?S.header.fileAttr:void 0;try{s.makeDir(O),A&&s.fs.chmodSync(O,A),s.fs.utimesSync(O,S.header.time,S.header.time)}catch{g(d("Unable to create folder",O))}}h.reverse().reduce(function(S,O){return function(A){if(A)S(A);else{let b=te.normalize(a(O.entryName)),v=c(f,b);O.getDataAsync(function(k,T){if(T)S(T);else if(!k)S(Y.Errors.CANT_EXTRACT_FILE());else{let x=C?O.header.fileAttr:void 0;s.writeFileToAsync(v,k,p,x,function(P){P||S(d("Unable to write file",v)),s.fs.utimes(v,O.header.time,O.header.time,function(F){F?S(d("Unable to set times",v)):S()})})}})}}},g)()},writeZip:function(f,p){if(arguments.length===1&&typeof f=="function"&&(p=f,f=""),!f&&n.filename&&(f=n.filename),!!f){var C=o.compressToBuffer();if(C){var g=s.writeFileTo(f,C,!0);typeof p=="function"&&p(g?null:new Error("failed"),"")}}},writeZipPromise:function(f,p){let{overwrite:C,perm:g}=Object.assign({overwrite:!0},p);return new Promise((E,d)=>{!f&&n.filename&&(f=n.filename),f||d("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(i=>{let h=S=>S?E(S):d("ADM-ZIP: Wasn't able to write zip file");s.writeFileToAsync(f,i,C,g,h)},d)})},toBufferPromise:function(){return new Promise((f,p)=>{o.toAsyncBuffer(f,p)})},toBuffer:function(f,p,C,g){return typeof f=="function"?(o.toAsyncBuffer(f,p,C,g),null):o.compressToBuffer()}}}});function ja(){try{return nn.default.statSync("/.dockerenv"),!0}catch{return!1}}function Da(){try{return nn.default.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function sn(){return rn===void 0&&(rn=ja()||Da()),rn}var nn,rn,eo=Ee(()=>{"use strict";nn=ge(require("fs"),1)});function st(){return on===void 0&&(on=Na()||sn()),on}var to,on,Na,an=Ee(()=>{"use strict";to=ge(require("fs"),1);eo();Na=()=>{try{return to.default.statSync("/run/.containerenv"),!0}catch{return!1}}});var cn,no,sr,ro,Ze,ln=Ee(()=>{"use strict";cn=ge(require("process"),1),no=ge(require("os"),1),sr=ge(require("fs"),1);an();ro=()=>{if(cn.default.platform!=="linux")return!1;if(no.default.release().toLowerCase().includes("microsoft"))return!st();try{if(sr.default.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!st()}catch{}return sr.default.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||sr.default.existsSync("/run/WSL")?!st():!1},Ze=cn.default.env.__IS_WSL_TEST__?ro:ro()});var un,_t,$a,Fa,fn,so=Ee(()=>{"use strict";un=ge(require("process"),1),_t=ge(require("fs/promises"),1);ln();ln();$a=(()=>{let r="/mnt/",e;return async function(){if(e)return e;let t="/etc/wsl.conf",n=!1;try{await _t.default.access(t,_t.constants.F_OK),n=!0}catch{}if(!n)return r;let s=await _t.default.readFile(t,{encoding:"utf8"}),o=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(s);return o?(e=o.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):r}})(),Fa=async()=>`${await $a()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,fn=async()=>Ze?Fa():`${un.default.env.SYSTEMROOT||un.default.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`});function Je(r,e,t){let n=s=>Object.defineProperty(r,e,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get(){let s=t();return n(s),s},set(s){n(s)}}),r}var oo=Ee(()=>{"use strict"});async function dn(){if(ao.default.platform!=="darwin")throw new Error("macOS only");let{stdout:r}=await La("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(r)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}var io,ao,co,La,lo=Ee(()=>{"use strict";io=require("util"),ao=ge(require("process"),1),co=require("child_process"),La=(0,io.promisify)(co.execFile)});async function po(r,{humanReadableOutput:e=!0,signal:t}={}){if(uo.default.platform!=="darwin")throw new Error("macOS only");let n=e?[]:["-ss"],s={};t&&(s.signal=t);let{stdout:o}=await Ma("osascript",["-e",r,n],s);return o.trim()}var uo,fo,pn,Ma,mo=Ee(()=>{"use strict";uo=ge(require("process"),1),fo=require("util"),pn=require("child_process"),Ma=(0,fo.promisify)(pn.execFile)});async function mn(r){return po(`tell application "Finder" to set app_path to application file id "${r}" as string
|
|
30
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var go=Ee(()=>{"use strict";mo()});async function hn(r=Ua){let{stdout:e}=await r("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 gn(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:n}=t.groups,s=n.lastIndexOf("."),o=n.lastIndexOf("-"),a=s===-1?void 0:n.slice(0,s),c=o===-1?void 0:n.slice(0,o);return or[n]??or[a]??or[c]??{name:n,id:n}}var ho,yo,Ua,or,hu,gn,So=Ee(()=>{"use strict";ho=require("util"),yo=require("child_process"),Ua=(0,ho.promisify)(yo.execFile),or={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"}},hu=new Map(Object.entries(or)),gn=class extends Error{}});async function yn(){if(ir.default.platform==="darwin"){let r=await dn();return{name:await mn(r),id:r}}if(ir.default.platform==="linux"){let{stdout:r}=await Ha("xdg-mime",["query","default","x-scheme-handler/http"]),e=r.trim();return{name:Ba(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(ir.default.platform==="win32")return hn();throw new Error("Only macOS, Linux, and Windows are supported")}var Eo,ir,Co,Ha,Ba,wo=Ee(()=>{"use strict";Eo=require("util"),ir=ge(require("process"),1),Co=require("child_process");lo();go();So();Ha=(0,Eo.promisify)(Co.execFile),Ba=r=>r.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())});var vo={};kt(vo,{apps:()=>Ke,default:()=>za,openApp:()=>Ga});async function Va(){let r=await fn(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=Cn.Buffer.from(e,"utf16le").toString("base64"),{stdout:n}=await Wa(r,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),s=n.trim(),o={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return o[s]?{id:o[s]}:{}}function Ao(r){if(typeof r=="string"||Array.isArray(r))return r;let{[Io]:e}=r;if(!e)throw new Error(`${Io} is not supported`);return e}function cr({[pt]:r},{wsl:e}){if(e&&Ze)return Ao(e);if(!r)throw new Error(`${pt} is not supported`);return Ao(r)}var En,Cn,wn,xo,Oo,bn,ar,Za,Wa,Sn,bo,pt,Io,_o,At,qa,Ga,Ke,za,ko=Ee(()=>{"use strict";En=ge(require("process"),1),Cn=require("buffer"),wn=ge(require("path"),1),xo=require("url"),Oo=require("util"),bn=ge(require("child_process"),1),ar=ge(require("fs/promises"),1);so();oo();wo();an();Za={},Wa=(0,Oo.promisify)(bn.default.execFile),Sn=wn.default.dirname((0,xo.fileURLToPath)(Za.url)),bo=wn.default.join(Sn,"xdg-open"),{platform:pt,arch:Io}=En.default;_o=async(r,e)=>{let t;for(let n of r)try{return await e(n)}catch(s){t=s}throw t},At=async r=>{if(r={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...r},Array.isArray(r.app))return _o(r.app,c=>At({...r,app:c}));let{name:e,arguments:t=[]}=r.app??{};if(t=[...t],Array.isArray(e))return _o(e,c=>At({...r,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"},u=Ze?await Va():await yn();if(u.id in c){let m=c[u.id];return e==="browserPrivate"&&t.push(l[m]),At({...r,app:{name:Ke[m],arguments:t}})}throw new Error(`${u.name} is not supported as a default browser`)}let n,s=[],o={};if(pt==="darwin")n="open",r.wait&&s.push("--wait-apps"),r.background&&s.push("--background"),r.newInstance&&s.push("--new"),e&&s.push("-a",e);else if(pt==="win32"||Ze&&!st()&&!e){n=await fn(),s.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),Ze||(o.windowsVerbatimArguments=!0);let c=["Start"];r.wait&&c.push("-Wait"),e?(c.push(`"\`"${e}\`""`),r.target&&t.push(r.target)):r.target&&c.push(`"${r.target}"`),t.length>0&&(t=t.map(l=>`"\`"${l}\`""`),c.push("-ArgumentList",t.join(","))),r.target=Cn.Buffer.from(c.join(" "),"utf16le").toString("base64")}else{if(e)n=e;else{let c=!Sn||Sn==="/",l=!1;try{await ar.default.access(bo,ar.constants.X_OK),l=!0}catch{}n=En.default.versions.electron??(pt==="android"||c||!l)?"xdg-open":bo}t.length>0&&s.push(...t),r.wait||(o.stdio="ignore",o.detached=!0)}pt==="darwin"&&t.length>0&&s.push("--args",...t),r.target&&s.push(r.target);let a=bn.default.spawn(n,s,o);return r.wait?new Promise((c,l)=>{a.once("error",l),a.once("close",u=>{if(!r.allowNonzeroExitCode&&u>0){l(new Error(`Exited with code ${u}`));return}c(a)})}):(a.unref(),a)},qa=(r,e)=>{if(typeof r!="string")throw new TypeError("Expected a `target`");return At({...e,target:r})},Ga=(r,e)=>{if(typeof r!="string"&&!Array.isArray(r))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 At({...e,app:{name:r,arguments:t}})};Ke={};Je(Ke,"chrome",()=>cr({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"]}}));Je(Ke,"brave",()=>cr({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"]}}));Je(Ke,"firefox",()=>cr({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Je(Ke,"edge",()=>cr({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Je(Ke,"browser",()=>"browser");Je(Ke,"browserPrivate",()=>"browserPrivate");za=qa});var Qo={};kt(Qo,{collectTelemetry:()=>Yo,pushTelemetry:()=>Xo,registerTelemetry:()=>An});function Ko(){let r=process.env.SC_PROFILE;return r?(0,xt.join)((0,In.homedir)(),".config","shared-context","profiles",r):(0,xt.join)((0,In.homedir)(),".config","shared-context")}function _n(){return(0,xt.join)(Ko(),"usage.jsonl")}function ec(){let r=_n();if(!(0,_e.existsSync)(r))return[];try{let e=(0,_e.readFileSync)(r,"utf8").trim().split(`
|
|
31
|
+
`).filter(Boolean),t=[];for(let n of e)try{let s=JSON.parse(n);s.v&&s.ts&&s.event&&s.rid&&t.push(s)}catch{}return t}catch{return[]}}function tc(r){let e=_n();if((0,_e.existsSync)(e))try{let t=(0,_e.readFileSync)(e,"utf8").trim().split(`
|
|
32
|
+
`).filter(Boolean);if(t.length<=r)return;let n=t.slice(-r);(0,_e.writeFileSync)(e,n.join(`
|
|
35
33
|
`)+`
|
|
36
|
-
`,"utf8")}catch{}}async function
|
|
37
|
-
`,"
|
|
38
|
-
`,"utf-8")}function
|
|
39
|
-
`,"utf-8")}function
|
|
40
|
-
`,"utf-8")
|
|
41
|
-
`,"utf-8")}function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`,"utf-8")}function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`)}function
|
|
49
|
-
|
|
34
|
+
`,"utf8")}catch{}}async function Xo(r=!1){if(!xe().telemetry)return{uploaded:0};if(!U())return{uploaded:0};let e=ec();if(e.length===0)return{uploaded:0};let t=e.slice(0,Xa),n=await L("/api/cli/telemetry",{events:t},1e4);if(n.ok){if(tc(Ya),!r){let s=n.data?.accepted??0;_()?N("telemetry",{uploaded:s}):s>0&&w(`Uploaded ${s} usage event${s===1?"":"s"}`)}return{uploaded:n.data?.accepted??0}}return!r&&!_()&&R("Telemetry upload failed \u2014 will retry next session"),{uploaded:0}}function rc(r){if(!r)return null;try{let e=(0,xt.join)(Ko(),"manifest.json"),t=(0,_e.readFileSync)(e,"utf8"),n=JSON.parse(t),s=r.toLowerCase();return n.installations?.find(o=>o.slug===s)??null}catch{return null}}function nc(r){let e=_n();try{if((0,_e.existsSync)(e)&&(0,_e.statSync)(e).size>Qa)return;(0,_e.appendFileSync)(e,JSON.stringify(r)+`
|
|
35
|
+
`,"utf8")}catch{}}async function Yo(){if(!xe().telemetry)return;let r=await new Promise(a=>{let c="";process.stdin.setEncoding("utf8"),process.stdin.on("data",l=>{c+=l}),process.stdin.on("end",()=>a(c)),setTimeout(()=>a(c),5e3)}),e;try{e=JSON.parse(r)}catch{return}let t=e.tool_name;if(t!=="Skill"&&t!=="Agent")return;let n=t==="Skill"?e.tool_input?.skill:e.tool_input?.subagent_type,s=rc(n);if(!s||!s.resourceId)return;let o={v:1,ts:new Date().toISOString(),sid:e.session_id??"",event:t==="Skill"?"skill_invoked":"agent_invoked",slug:s.slug??n??"",rid:s.resourceId,ver:s.sha??"",ok:t==="Skill"?e.tool_response?.success!==!1:e.tool_response?.status==="completed"};t==="Agent"&&(e.tool_response?.totalDurationMs!=null&&(o.dur_ms=e.tool_response.totalDurationMs),e.tool_response?.totalTokens!=null&&(o.tokens=e.tool_response.totalTokens)),nc(o)}function An(r){let e=r.command("telemetry").description("Manage usage telemetry");e.command("push").description("Upload local usage data to Shared Context").option("--quiet","Suppress output").action(async t=>{await Xo(t.quiet)}),e.command("collect").description("Append a PostToolUse event from stdin to local usage buffer").action(async()=>{try{await Yo()}catch{}process.exit(0)})}var _e,xt,In,Xa,Ya,Qa,xn=Ee(()=>{"use strict";_e=require("fs"),xt=require("path"),In=require("os");oe();ue();se();Xa=1e3,Ya=100,Qa=10*1024*1024});var Wn=ge(Bn(),1),{program:Ec,createCommand:Cc,createArgument:wc,createOption:bc,CommanderError:Ic,InvalidArgumentError:_c,InvalidOptionArgumentError:Ac,Command:Vn,Argument:xc,Option:Oc,Help:vc}=Wn.default;se();var nt=require("fs"),ze=require("path"),Xs=require("os");ue();oe();se();var Ur=require("fs"),Oe=require("path"),Be=require("os"),it=[{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 De(r){if(r){let n=it.find(o=>o.id===r);if(n)return n;let s=it.find(o=>o.dir===`.${r}`||o.dir===r);return s||null}for(let n of it)if(n.envVars.some(s=>process.env[s]))return n;let e=(0,Be.homedir)(),t=[];for(let n of it)(0,Ur.existsSync)((0,Oe.join)(e,n.dir))&&t.push(n);return t.length===1?t[0]:null}function We(){let r=[],e=(0,Be.homedir)();for(let t of it)(t.envVars.some(n=>process.env[n])||(0,Ur.existsSync)((0,Oe.join)(e,t.dir)))&&r.push(t);return r}function Ve(){let r=We();return r.length>1?`Multiple AI agents detected (${r.map(e=>e.label).join(", ")}). Use --agent to specify: ${r.map(e=>e.id).join(", ")}`:`No AI agent detected. Use --agent to specify one (${it.map(e=>e.id).join(", ")})`}function W(r,e){return e?(0,Oe.join)(process.cwd(),r.dir,r.skillsSubdir):(0,Oe.join)((0,Be.homedir)(),r.dir,r.skillsSubdir)}function re(r,e){return e?(0,Oe.join)(process.cwd(),r.dir,"agents"):(0,Oe.join)((0,Be.homedir)(),r.dir,"agents")}function pe(r,e){return e?(0,Oe.join)(process.cwd(),".mcp.json"):r.id==="claude-code"?(0,Oe.join)((0,Be.homedir)(),".claude.json"):r.id==="cursor"?(0,Oe.join)((0,Be.homedir)(),".cursor","mcp.json"):(0,Oe.join)(process.cwd(),".mcp.json")}function ve(r,e){return e?(0,Oe.join)(process.cwd(),r.dir,"settings.json"):(0,Oe.join)((0,Be.homedir)(),r.dir,"settings.json")}var fe=require("fs"),et=require("path");var we=require("fs"),ye=require("path");oe();var Ds=require("child_process"),Ns=require("fs"),$s=require("path"),Fs=require("os"),Ls=ge(js());oe();var sa={"claude-code":"claude-plugin","gemini-cli":"gemini-extension",antigravity:"gemini-extension",cursor:"cursor",codex:"codex"};function Ht(r){return sa[r]||"directory"}function Bt(r){let t={"claude-code":"claude",cursor:"cursor","gemini-cli":"gemini"}[r];if(!t)return null;try{return(0,Ds.execSync)(`which ${t}`,{stdio:"pipe"}),t}catch{return null}}async function Wt(r,e){let t=await Mr(r),n=(0,$s.join)((0,Fs.tmpdir)(),`sc-plugin-${e}-${Date.now()}`);return(0,Ns.mkdirSync)(n,{recursive:!0}),new Ls.default(t).extractAllTo(n,!0),n}function Vt(r){return{"claude-code":"claude","gemini-cli":"gemini",cursor:"cursor"}[r]||"claude"}ue();se();function ut(r){let e={};if(!r||typeof r!="object")return e;let t=r;if(Array.isArray(t.hooks)){for(let s of t.hooks){if(!s||typeof s!="object")continue;let o=s,a=typeof o.event=="string"?o.event:null,c=typeof o.command=="string"?o.command:null;!a||!c||(e[a]||(e[a]=[]),e[a].push({hooks:[{type:"command",command:c}]}))}return e}let n=t.hooks&&typeof t.hooks=="object"&&!Array.isArray(t.hooks)?t.hooks:t;for(let[s,o]of Object.entries(n))if(!(s==="name"||s==="description")&&Array.isArray(o)){e[s]||(e[s]=[]);for(let a of o)e[s].push(a)}return e}var Pe=require("fs"),bt=require("path"),Gr=".shared-context",zr="project.json";function Ce(){let r=(0,bt.join)(process.cwd(),Gr,zr);if(!(0,Pe.existsSync)(r))return null;try{let e=JSON.parse((0,Pe.readFileSync)(r,"utf-8"));return e.projectId&&e.projectName&&e.projectSlug?e:null}catch{return null}}function Qe(r){let e=(0,bt.join)(process.cwd(),Gr);(0,Pe.mkdirSync)(e,{recursive:!0}),(0,Pe.writeFileSync)((0,bt.join)(e,zr),JSON.stringify(r,null,2)+`
|
|
36
|
+
`,"utf-8")}function Ms(){let r=(0,bt.join)(process.cwd(),Gr,zr);return(0,Pe.existsSync)(r)?((0,Pe.unlinkSync)(r),!0):!1}var Ws={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function G(r,e){let t=(0,ye.resolve)(r);for(let n of e){let s=(0,ye.resolve)((0,ye.join)(r,n.path));if(!s.startsWith(t+"/")&&s!==t)throw new Error(`Invalid file path: ${n.path}`);(0,we.mkdirSync)((0,ye.dirname)(s),{recursive:!0}),(0,we.writeFileSync)(s,n.content,"utf-8")}}function Zr(r){let e=r.resource.slug||r.resource.id;return`${Ws[r.resource.resourceType]||r.resource.resourceType+"s"}/${e}`}function Us(r,e,t,n,s){let o=(0,ye.join)(r,e);if(!(0,we.existsSync)(o))return{slug:e,renamed:!1};if(!s.installations.find(l=>{let u=l.installPath.split("/");return u[u.length-1]===e&&l.resourceId!==t}))return{slug:e,renamed:!1};let c=n.resource.orgSlug||n.resource.githubOwner||n.resource.id.slice(0,8);return{slug:`${e}-${c}`,renamed:!0}}function qt(r,e,t){let n=t.files.find(u=>u.path.endsWith(".json")&&!u.path.includes("/"))||t.files.find(u=>u.path.endsWith(".json")&&u.path.includes("resources/"));if(!n)throw new Error("MCP package does not contain a config file");let s=JSON.parse(n.content),o=pe(r,e),a=t.resource.slug||t.resource.id,c={};if((0,we.existsSync)(o))try{c=JSON.parse((0,we.readFileSync)(o,"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,we.mkdirSync)((0,ye.dirname)(o),{recursive:!0}),(0,we.writeFileSync)(o,JSON.stringify(c,null,2)+`
|
|
37
|
+
`,"utf-8")}function oa(r,e,t,n){let s=t.files.find(l=>l.path.endsWith(".json")&&!l.path.includes("/"));if(!s)throw new Error("Hook package does not contain a hook.json file");let o=JSON.parse(s.content),a=ve(r,e),c=ut(o);if(Object.keys(c).length===0)throw new Error("Hook package does not contain any hook event handlers");return Xr(a,c,n),a}function Jr(r,e,t,n={}){let s=r.slug||r.id,o=Ws[r.resourceType]||r.resourceType+"s",a=e.orgSlug?`${e.orgSlug}/`:"";return{resourceId:r.id,slug:s,installPath:`${o}/${a}${s}`,title:r.title,sha:r.latestSha||"",scope:n.projectId?"project":"global",agent:t,installedAt:new Date().toISOString(),collectionId:e.id,resourceType:r.resourceType,latestSha:r.latestSha||void 0,serverSynced:!0,...n.projectId?{projectId:n.projectId}:{}}}async function Kr(r,e,t){let n=[],s=[],o=r.resource.slug||r.resource.id,a=Zr(r),c,l="decomposed",u,m=!1;if(r.resource.resourceType==="agent"){let y=re(e,t.project),I=Us(y,o,r.resource.id,r,t.manifest);I.renamed&&(o=I.slug,a=Zr({...r,resource:{...r.resource,slug:o}}),m=!0),c=(0,ye.join)(y,o),G(c,r.files)}else if(r.resource.resourceType==="mcp")c="",qt(e,t.project,r);else if(r.resource.resourceType==="hook")c="",oa(e,t.project,r,a);else{let y=W(e,t.project);if(r.resource.resourceType!=="collection"){let I=Us(y,o,r.resource.id,r,t.manifest);I.renamed&&(o=I.slug,a=Zr({...r,resource:{...r.resource,slug:o}}),m=!0)}if(c=(0,ye.join)(y,o),r.resource.resourceType==="collection"){let I=!1;try{let f=r.resource.slug||r.resource.id,p=r.resource.orgSlug||"",C=Vt(e.id),g=t.authed?`/api/cli/resource/collections/${p}/${f}?format=plugin&platform=${C}`:`/api/public/resource/collections/${p}/${f}?format=plugin&platform=${C}`,E=await Wt(g,f),d=aa(E,e.id);if(d.length>0){let i={...r,files:d},S=await Ne(e).install(i,t.project?"project":"user",e);c=S.installDir,l="plugin",u=E,I=!0,s.push("Installed from plugin package");for(let O of S.warnings)n.push(O)}}catch(f){n.push(`Plugin install failed, falling back to decomposed: ${f}`)}if(!I){let p=await Ne(e).install(r,t.project?"project":"user",e);c=p.installDir;for(let C of p.warnings)n.push(C)}}else G(c,r.files)}return{installDir:c,installPath:a,installMode:l,pluginDir:u,slug:o,renamed:m,warnings:n,notes:s}}function Vs(r){r.command("install <path>").description("Install a resource (e.g., skills/acme/api-testing)").action(async(e,t,n)=>{let s=n.optsWithGlobals(),o=De(s.agent);if(!o){let i=Ve();_()?D("install","NO_AGENTS",i):R(i),process.exit(1)}let a=U(),l=await Z(`${a?"/api/cli/resource":"/api/public/resource"}/${e}`);l.ok||(_()?D("install",l.error.code,l.error.message):R(`Install failed: ${l.error.message}`),process.exit(1));let u=l.data,m;try{m=await Kr(u,o,{project:!!s.project,manifest:q(),authed:a})}catch(i){_()?D("install","WRITE_FAILED",`Failed to install: ${i}`):R(`Failed to install: ${i}`),process.exit(1)}if(m.renamed&&!_()&&w(`Note: Renamed to "${m.slug}" (collision with existing resource)`),!_()){for(let i of m.notes)w(i);for(let i of m.warnings)R(`Warning: ${i}`)}let y=m.installDir,I=m.installPath,f=m.slug,p=m.installMode,C=m.pluginDir,g;if(a&&u.resource.latestSha){let i=await L("/api/cli/install",{resourceId:u.resource.id,agentPlatform:o.platform,installedSha:u.resource.latestSha});i.ok||(g=`Could not record install on server: ${i.error.message}`,_()||R(`Warning: ${g}`))}let E=s.project?Ce():null;E&&a&&await L(`/api/cli/projects/${E.projectId}/resources`,{resourceId:u.resource.id}).catch(()=>{});let d=u.resource.resourceType==="collection";if(le({resourceId:u.resource.id,slug:f,installPath:I,title:u.resource.title,sha:u.resource.latestSha||"",scope:s.project?"project":"global",agent:o.id,installedAt:new Date().toISOString(),latestSha:u.resource.latestSha||void 0,resourceType:u.resource.resourceType,serverSynced:!0,...d?{pluginFormat:Ht(o.id),memberCount:u.memberResources?.length,installMode:p,pluginDir:C}:{},...E?{projectId:E.projectId}:{}}),u.memberResources&&u.resource.resourceType==="collection"){if(p==="decomposed")for(let i of u.memberResources)le(Jr(i,u.resource,o.id,{projectId:E?.projectId}));for(let i of u.memberResources)a&&i.latestSha&&await L("/api/cli/install",{resourceId:i.id,agentPlatform:o.platform,installedSha:i.latestSha}).catch(()=>{})}if(He(),_())N("install",{installPath:I,title:u.resource.title,path:y||void 0,files:u.files.length,...u.resource.resourceType==="mcp"?{mcpConfigPath:pe(o,!!s.project)}:{},...u.resource.resourceType==="hook"?{settingsPath:ve(o,!!s.project)}:{},...u.memberResources?{memberResources:u.memberResources.map(i=>({title:i.title,resourceType:i.resourceType,slug:i.slug}))}:{},...g&&{warning:g}});else{if(u.resource.resourceType==="mcp"?w(`Installed MCP "${u.resource.title}" to ${pe(o,!!s.project)}`):u.resource.resourceType==="hook"?w(`Installed hook "${u.resource.title}" to ${ve(o,!!s.project)}`):u.memberResources&&u.memberResources.length>0?w(`Installed "${u.resource.title}" (${u.memberResources.length} resources)`):w(`Installed "${u.resource.title}" to ${y}`),u.resource.resourceType!=="mcp"&&u.resource.resourceType!=="hook"&&!(u.memberResources&&u.memberResources.length>0)&&w(` ${u.files.length} file${u.files.length===1?"":"s"} written`),u.memberResources&&u.memberResources.length>0){let i={};for(let S of u.memberResources){let O=S.resourceType||"other";i[O]||(i[O]=[]),i[O].push(S.title)}let h={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections",file:"Files"};w("");for(let[S,O]of Object.entries(i)){let A=h[S]||S;w(` ${A}: ${O.join(", ")}`)}}a||(w(""),w("Tip: Sign up at sharedcontext.ai to track installations and get updates."))}})}var ia={"claude-code":[".claude"],cursor:[".cursor"],"gemini-cli":[".gemini"],codex:[".codex"],antigravity:[".gemini"]},Hs=new Set(["skills","commands","agents","hooks","mcps"]);function aa(r,e){let t=ia[e]||[];for(let o of t){let a=(0,ye.join)(r,o);if((0,we.existsSync)(a)){let l=Bs(a).filter(u=>Hs.has(u.path.split("/")[0]));if(l.length>0)return l}}return Bs(r).filter(o=>Hs.has(o.path.split("/")[0]))}var ca=new Set([".git","node_modules","__pycache__",".venv"]);function Bs(r){let e=[];function t(n){let s;try{s=(0,we.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let o of s)if(o.isDirectory()){if(ca.has(o.name))continue;t((0,ye.join)(n,o.name))}else if(o.isFile()){let a=(0,ye.join)(n,o.name);try{let c=(0,we.readFileSync)(a,"utf-8");e.push({path:(0,ye.relative)(r,a),content:c})}catch{}}}return t(r),e}var Gt=class{buildFiles(e){let t=[],n=[],s=[],o={},a={};for(let c of e.files){let l=c.path.split("/"),u=l[0];if(u==="agents")s.push({path:c.path.slice(7),content:c.content});else if(u==="mcps"){if(c.path.endsWith(".json"))try{let m=JSON.parse(c.content);if(m.mcpServers&&typeof m.mcpServers=="object")Object.assign(o,m.mcpServers);else if(c.path.includes("resources/")){let y=l.indexOf("resources"),I=y>0?l[y-1]:l[1];o[I]=m}}catch{t.push(`Failed to parse MCP config: ${c.path}`)}}else if(u==="hooks"){if(c.path.endsWith(".json"))try{let m=JSON.parse(c.content),y=c.path.replace(/\/[^/]+$/,"");la(m,a,y)}catch{t.push(`Failed to parse hook config: ${c.path}`)}}else u==="skills"||u==="commands"||u==="files"?n.push({path:c.path.slice(u.length+1),content:c.content}):n.push(c)}return{mainFiles:n,agentFiles:s,mcpEntries:o,hookEntries:a,customFiles:[],warnings:t}}async install(e,t,n){let s=this.buildFiles(e),o=t==="project",a=e.resource.slug||e.resource.id,c=W(n,o),l=da(e),u=(0,et.join)(c,...l),m=0;if(s.mainFiles.length>0){let y=s.mainFiles.filter(f=>!f.path.includes("/")),I=s.mainFiles.filter(f=>f.path.includes("/"));if(y.length>0){let f=y.find(p=>p.path==="README.md");f&&y.push({path:"SKILL.md",content:fa(e,f.content)}),G(u,y),m+=y.length}I.length>0&&(G(c,I),m+=I.length)}if(s.agentFiles.length>0){let y=re(n,o);G(y,s.agentFiles),m+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&ua(pe(n,o),s.mcpEntries),Object.keys(s.hookEntries).length>0&&Xr(ve(n,o),s.hookEntries),{installDir:u,filesWritten:m,warnings:s.warnings}}async uninstall(e,t,n,s){let o=[],c=W(n,t==="project"),l=(0,et.join)(c,e),u=!1;return(0,fe.existsSync)(l)&&((0,fe.rmSync)(l,{recursive:!0,force:!0}),u=!0),u||o.push(`Collection directory not found at ${l}`),{removed:u,warnings:o}}describeLocation(e,t,n){let s=W(n,t==="project");return(0,et.join)(s,e)}};function la(r,e,t){let n=ut(r);for(let[s,o]of Object.entries(n)){e[s]||(e[s]=[]);for(let a of o){let c=t&&typeof a=="object"&&a!==null?{...a,_sc:t}:a;e[s].push(c)}}}function Xr(r,e,t){let n={};if((0,fe.existsSync)(r))try{n=JSON.parse((0,fe.readFileSync)(r,"utf-8"))}catch{n={}}let s=typeof n.hooks=="object"&&n.hooks&&!Array.isArray(n.hooks)?n.hooks:{},o=new Set;t&&o.add(t);for(let a of Object.values(e))for(let c of a)c&&typeof c=="object"&&typeof c._sc=="string"&&o.add(c._sc);if(o.size>0)for(let[a,c]of Object.entries(s))Array.isArray(c)&&(s[a]=c.filter(l=>!l||typeof l!="object"||!o.has(l._sc)),s[a].length===0&&delete s[a]);for(let[a,c]of Object.entries(e)){Array.isArray(s[a])||(s[a]=[]);for(let l of c){let u=t&&typeof l=="object"&&l!==null?{...l,_sc:t}:l,m=JSON.stringify(u);s[a].some(I=>JSON.stringify(I)===m)||s[a].push(u)}}n.hooks=s,(0,fe.mkdirSync)((0,et.dirname)(r),{recursive:!0}),(0,fe.writeFileSync)(r,JSON.stringify(n,null,2)+`
|
|
38
|
+
`,"utf-8")}function Yr(r,e){if(!(0,fe.existsSync)(r))return!1;let t;try{t=JSON.parse((0,fe.readFileSync)(r,"utf-8"))}catch{return!1}let n=typeof t.hooks=="object"&&t.hooks&&!Array.isArray(t.hooks)?t.hooks:null;if(!n)return!1;let s=!1;for(let[o,a]of Object.entries(n)){if(!Array.isArray(a))continue;let c=a.filter(l=>!l||typeof l!="object"||l._sc!==e);c.length!==a.length&&(s=!0,c.length===0?delete n[o]:n[o]=c)}return s&&(t.hooks=n,(0,fe.writeFileSync)(r,JSON.stringify(t,null,2)+`
|
|
39
|
+
`,"utf-8")),s}function ua(r,e){let t={};if((0,fe.existsSync)(r))try{t=JSON.parse((0,fe.readFileSync)(r,"utf-8"))}catch{t={}}let n=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(n,e),t.mcpServers=n,(0,fe.mkdirSync)((0,et.dirname)(r),{recursive:!0}),(0,fe.writeFileSync)(r,JSON.stringify(t,null,2)+`
|
|
40
|
+
`,"utf-8")}function fa(r,e){let t=r.resource.title,n=r.resource.description||"",s=["---",`name: ${t}`];return n&&s.push(`description: ${n}`),s.push("user-invocable: true"),s.push("---","",e),s.join(`
|
|
41
|
+
`)}function da(r){let e=r.resource.slug||r.resource.id;return r.resource.storageType==="github"&&r.resource.githubOwner?["external",r.resource.githubOwner,e]:r.resource.orgSlug?[r.resource.orgSlug,e]:[e]}var be=require("fs"),tt=require("path");var pa={SessionStart:"SessionStart",PreToolUse:"BeforeTool",PostToolUse:"AfterTool",Stop:"AfterAgent",UserPromptSubmit:"BeforeAgent",PreCompact:"PreCompress"},zt=class{buildFiles(e){let t=[],n=[],s=[],o={},a={};for(let c of e.files){let l=c.path.split("/"),u=l[0];if(u==="agents")s.push({path:c.path.slice(7),content:c.content});else if(u==="mcps"){if(c.path.endsWith(".json"))try{let m=JSON.parse(c.content);if(m.mcpServers&&typeof m.mcpServers=="object")Object.assign(o,m.mcpServers);else if(c.path.includes("resources/")){let y=l.indexOf("resources"),I=y>0?l[y-1]:l[1];o[I]=m}}catch{t.push(`Failed to parse MCP config: ${c.path}`)}}else if(u==="hooks"){if(c.path.endsWith(".json"))try{let m=JSON.parse(c.content),y=c.path.replace(/\/[^/]+$/,"");ma(m,a,y)}catch{t.push(`Failed to parse hook config: ${c.path}`)}}else u==="skills"||u==="commands"||u==="files"?n.push({path:c.path.slice(u.length+1),content:c.content}):n.push(c)}return{mainFiles:n,agentFiles:s,mcpEntries:o,hookEntries:a,customFiles:[],warnings:t}}async install(e,t,n){let s=this.buildFiles(e),o=t==="project",a=e.resource.slug||e.resource.id,c=W(n,o),l=Sa(e),u=(0,tt.join)(c,...l),m=0;if(s.mainFiles.length>0){let y=s.mainFiles.filter(f=>!f.path.includes("/")),I=s.mainFiles.filter(f=>f.path.includes("/"));if(y.length>0){let f=y.find(p=>p.path==="README.md");f&&y.push({path:"SKILL.md",content:ya(e,f.content)}),G(u,y),m+=y.length}I.length>0&&(G(c,I),m+=I.length)}if(s.agentFiles.length>0){let y=re(n,o);G(y,s.agentFiles),m+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&ha(pe(n,o),s.mcpEntries),Object.keys(s.hookEntries).length>0&&ga(ve(n,o),s.hookEntries),{installDir:u,filesWritten:m,warnings:s.warnings}}async uninstall(e,t,n){let s=[],a=W(n,t==="project"),c=(0,tt.join)(a,e),l=!1;return(0,be.existsSync)(c)&&((0,be.rmSync)(c,{recursive:!0,force:!0}),l=!0),l||s.push(`Collection directory not found at ${c}`),{removed:l,warnings:s}}describeLocation(e,t,n){let s=W(n,t==="project");return(0,tt.join)(s,e)}};function ma(r,e,t){let n=ut(r);for(let[s,o]of Object.entries(n)){let a=pa[s]||s;e[a]||(e[a]=[]);for(let c of o){let l=t&&typeof c=="object"&&c!==null?{...c,_sc:t}:c;e[a].push(l)}}}function ga(r,e){let t={};if((0,be.existsSync)(r))try{t=JSON.parse((0,be.readFileSync)(r,"utf-8"))}catch{t={}}let n=typeof t.hooks=="object"&&t.hooks&&!Array.isArray(t.hooks)?t.hooks:{},s=new Set;for(let o of Object.values(e))for(let a of o)a&&typeof a=="object"&&typeof a._sc=="string"&&s.add(a._sc);if(s.size>0)for(let[o,a]of Object.entries(n))Array.isArray(a)&&(n[o]=a.filter(c=>!c||typeof c!="object"||!s.has(c._sc)),n[o].length===0&&delete n[o]);for(let[o,a]of Object.entries(e)){Array.isArray(n[o])||(n[o]=[]);for(let c of a){let l=JSON.stringify(c);n[o].some(m=>JSON.stringify(m)===l)||n[o].push(c)}}t.hooks=n,(0,be.mkdirSync)((0,tt.dirname)(r),{recursive:!0}),(0,be.writeFileSync)(r,JSON.stringify(t,null,2)+`
|
|
42
|
+
`,"utf-8")}function ha(r,e){let t={};if((0,be.existsSync)(r))try{t=JSON.parse((0,be.readFileSync)(r,"utf-8"))}catch{t={}}let n=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(n,e),t.mcpServers=n,(0,be.mkdirSync)((0,tt.dirname)(r),{recursive:!0}),(0,be.writeFileSync)(r,JSON.stringify(t,null,2)+`
|
|
43
|
+
`,"utf-8")}function ya(r,e){let t=r.resource.title,n=r.resource.description||"",s=["---",`name: ${t}`];return n&&s.push(`description: ${n}`),s.push("user-invocable: true"),s.push("---","",e),s.join(`
|
|
44
|
+
`)}function Sa(r){let e=r.resource.slug||r.resource.id;return r.resource.storageType==="github"&&r.resource.githubOwner?["external",r.resource.githubOwner,e]:r.resource.orgSlug?[r.resource.orgSlug,e]:[e]}var de=require("fs"),Le=require("path");var Zt=class{buildFiles(e){let t=[],n=[],s=[],o={},a=[],c=e.resource.slug||e.resource.id;for(let l of e.files){let u=l.path.split("/"),m=u[0];if(m==="agents")s.push({path:l.path.slice(7),content:l.content});else if(m==="mcps"){if(l.path.endsWith(".json"))try{let y=JSON.parse(l.content);if(y.mcpServers&&typeof y.mcpServers=="object")Object.assign(o,y.mcpServers);else if(l.path.includes("resources/")){let I=u.indexOf("resources"),f=I>0?u[I-1]:u[1];o[f]=y}}catch{t.push(`Failed to parse MCP config: ${l.path}`)}}else m==="hooks"?t.push(`Hooks are not supported by Cursor (skipped: ${l.path})`):m==="skills"||m==="commands"||m==="files"?n.push({path:l.path.slice(m.length+1),content:l.content}):n.push(l)}return{mainFiles:n,agentFiles:s,mcpEntries:o,hookEntries:{},customFiles:a,warnings:t}}async install(e,t,n){let s=this.buildFiles(e),o=t==="project",a=W(n,o),c=wa(e),l=(0,Le.join)(a,...c),u=0;if(s.mainFiles.length>0){let m=s.mainFiles.filter(I=>!I.path.includes("/")),y=s.mainFiles.filter(I=>I.path.includes("/"));if(m.length>0){let I=m.find(f=>f.path==="README.md");I&&m.push({path:"SKILL.md",content:Ca(e,I.content)}),G(l,m),u+=m.length}y.length>0&&(G(a,y),u+=y.length)}if(s.agentFiles.length>0){let m=re(n,o);G(m,s.agentFiles),u+=s.agentFiles.length}for(let m of s.customFiles)(0,de.mkdirSync)((0,Le.dirname)(m.absolutePath),{recursive:!0}),(0,de.writeFileSync)(m.absolutePath,m.content,"utf-8"),u++;return Object.keys(s.mcpEntries).length>0&&Ea(pe(n,o),s.mcpEntries),{installDir:l,filesWritten:u,warnings:s.warnings}}async uninstall(e,t,n){let s=[],a=W(n,t==="project"),c=(0,Le.join)(a,e),l=!1;(0,de.existsSync)(c)&&((0,de.rmSync)(c,{recursive:!0,force:!0}),l=!0);let u=(0,Le.join)(homedir(),".cursor","rules");if((0,de.existsSync)(u))try{let m=(0,de.readdirSync)(u);for(let y of m)y.startsWith(`${e}-`)&&y.endsWith(".mdc")&&((0,de.unlinkSync)((0,Le.join)(u,y)),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,n){let s=W(n,t==="project");return(0,Le.join)(s,e)}};function Ea(r,e){let t={};if((0,de.existsSync)(r))try{t=JSON.parse((0,de.readFileSync)(r,"utf-8"))}catch{t={}}let n=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(n,e),t.mcpServers=n,(0,de.mkdirSync)((0,Le.dirname)(r),{recursive:!0}),(0,de.writeFileSync)(r,JSON.stringify(t,null,2)+`
|
|
45
|
+
`,"utf-8")}function Ca(r,e){let t=r.resource.title,n=r.resource.description||"",s=["---",`name: ${t}`];return n&&s.push(`description: ${n}`),s.push("user-invocable: true"),s.push("---","",e),s.join(`
|
|
46
|
+
`)}function wa(r){let e=r.resource.slug||r.resource.id;return r.resource.storageType==="github"&&r.resource.githubOwner?["external",r.resource.githubOwner,e]:r.resource.orgSlug?[r.resource.orgSlug,e]:[e]}var Xt=require("fs"),Jt=require("path");var Kt=class{buildFiles(e){let t=[],n=[],s=[];for(let o of e.files){let c=o.path.split("/")[0];c==="agents"?s.push({path:o.path.slice(7),content:o.content}):c==="mcps"?t.push(`MCP servers are not yet supported by Codex adapter (skipped: ${o.path})`):c==="hooks"?t.push(`Hooks are not supported by Codex (skipped: ${o.path})`):c==="commands"?t.push(`Commands are not supported by Codex (skipped: ${o.path})`):c==="skills"||c==="files"?n.push({path:o.path.slice(c.length+1),content:o.content}):n.push(o)}return{mainFiles:n,agentFiles:s,mcpEntries:{},hookEntries:{},customFiles:[],warnings:t}}async install(e,t,n){let s=this.buildFiles(e),o=t==="project",a=W(n,o),c=Ia(e),l=(0,Jt.join)(a,...c),u=0;if(s.mainFiles.length>0){let m=s.mainFiles.filter(I=>!I.path.includes("/")),y=s.mainFiles.filter(I=>I.path.includes("/"));if(m.length>0){let I=m.find(f=>f.path==="README.md");I&&m.push({path:"SKILL.md",content:ba(e,I.content)}),G(l,m),u+=m.length}y.length>0&&(G(a,y),u+=y.length)}if(s.agentFiles.length>0){let m=re(n,o);G(m,s.agentFiles),u+=s.agentFiles.length}return{installDir:l,filesWritten:u,warnings:s.warnings}}async uninstall(e,t,n){let s=[],a=W(n,t==="project"),c=(0,Jt.join)(a,e),l=!1;return(0,Xt.existsSync)(c)&&((0,Xt.rmSync)(c,{recursive:!0,force:!0}),l=!0),l||s.push(`Collection directory not found at ${c}`),{removed:l,warnings:s}}describeLocation(e,t,n){let s=W(n,t==="project");return(0,Jt.join)(s,e)}};function ba(r,e){let t=r.resource.title,n=r.resource.description||"",s=["---",`name: ${t}`];return n&&s.push(`description: ${n}`),s.push("user-invocable: true"),s.push("---","",e),s.join(`
|
|
47
|
+
`)}function Ia(r){let e=r.resource.slug||r.resource.id;return r.resource.storageType==="github"&&r.resource.githubOwner?["external",r.resource.githubOwner,e]:r.resource.orgSlug?[r.resource.orgSlug,e]:[e]}var je=require("fs"),ft=require("path");var Yt=class{buildFiles(e){let t=[],n=[],s={};for(let o of e.files){let a=o.path.split("/"),c=a[0];if(c==="agents")n.push({path:o.path.slice(7),content:o.content});else if(c==="mcps"){if(o.path.endsWith(".json"))try{let l=JSON.parse(o.content);if(l.mcpServers&&typeof l.mcpServers=="object")Object.assign(s,l.mcpServers);else if(o.path.includes("resources/")){let u=a.indexOf("resources"),m=u>0?a[u-1]:a[1];s[m]=l}}catch{}}else c==="skills"||c==="commands"||c==="hooks"||c==="files"?t.push({path:o.path.slice(c.length+1),content:o.content}):t.push(o)}return{mainFiles:t,agentFiles:n,mcpEntries:s,hookEntries:{},customFiles:[],warnings:[]}}async install(e,t,n){let s=this.buildFiles(e),o=t==="project",a=W(n,o),c=Aa(e),l=(0,ft.join)(a,...c),u=0;if(s.mainFiles.length>0){let m=s.mainFiles.filter(I=>!I.path.includes("/")),y=s.mainFiles.filter(I=>I.path.includes("/"));m.length>0&&(G(l,m),u+=m.length),y.length>0&&(G(a,y),u+=y.length)}if(s.agentFiles.length>0){let m=re(n,o);G(m,s.agentFiles),u+=s.agentFiles.length}return Object.keys(s.mcpEntries).length>0&&_a(pe(n,o),s.mcpEntries),{installDir:l,filesWritten:u,warnings:s.warnings}}async uninstall(e,t,n){let o=W(n,t==="project"),a=(0,ft.join)(o,e),c=!1;return(0,je.existsSync)(a)&&((0,je.rmSync)(a,{recursive:!0,force:!0}),c=!0),{removed:c,warnings:[]}}describeLocation(e,t,n){let s=W(n,t==="project");return(0,ft.join)(s,e)}};function _a(r,e){let t={};if((0,je.existsSync)(r))try{t=JSON.parse((0,je.readFileSync)(r,"utf-8"))}catch{t={}}let n=typeof t.mcpServers=="object"&&t.mcpServers&&!Array.isArray(t.mcpServers)?t.mcpServers:{};Object.assign(n,e),t.mcpServers=n,(0,je.mkdirSync)((0,ft.dirname)(r),{recursive:!0}),(0,je.writeFileSync)(r,JSON.stringify(t,null,2)+`
|
|
48
|
+
`,"utf-8")}function Aa(r){let e=r.resource.slug||r.resource.id;return r.resource.storageType==="github"&&r.resource.githubOwner?["external",r.resource.githubOwner,e]:r.resource.orgSlug?[r.resource.orgSlug,e]:[e]}function Ne(r){switch(r.id){case"claude-code":return new Gt;case"gemini-cli":case"antigravity":return new zt;case"cursor":return new Zt;case"codex":return new Kt;default:return new Yt}}var qs=`---
|
|
50
49
|
name: Context Manager
|
|
51
50
|
description: "Your AI chief of staff \u2014 distills expert knowledge into resources, finds off-the-shelf solutions, and manages your working context"
|
|
52
51
|
tools:
|
|
@@ -135,43 +134,44 @@ When building custom resources, follow these patterns:
|
|
|
135
134
|
- **Specificity over comprehensiveness** \u2014 Only include instructions that meaningfully change Claude's output
|
|
136
135
|
- **Filesystem as memory** \u2014 Design persistent storage so resources accumulate knowledge over time
|
|
137
136
|
- **Search before building** \u2014 Check the Shared Context library before creating from scratch
|
|
138
|
-
`;oe();ue();var B=require("fs"),J=require("path"),
|
|
137
|
+
`;oe();ue();var B=require("fs"),J=require("path"),Js=require("crypto");var Qt=".context-collection",er="manifest.json";function Gs(r,e){return{version:1,name:r.name||"Untitled Plugin",description:r.description||void 0,resources:e.map(t=>t.resourceRef),...r.author?{author:typeof r.author=="string"?{name:r.author}:{name:r.author.name||"",url:r.author.url}}:{},...r.homepage?{homepage:r.homepage}:{},...r.license?{license:r.license}:{}}}function xa(r,e){return{version:1,name:r.name||"Untitled Extension",description:r.description||void 0,resources:e.map(t=>t.resourceRef),...r.author?{author:typeof r.author=="string"?{name:r.author}:{name:r.author.name||"",url:r.author.url}}:{},...r.homepage?{homepage:r.homepage}:{},...r.license?{license:r.license}:{}}}function Oa(r,e){return{version:1,name:r.name||"Untitled Plugin",description:r.description||void 0,resources:e.map(t=>t.resourceRef),...r.author?{author:typeof r.author=="string"?{name:r.author}:{name:r.author.name||"",url:r.author.url}}:{},...r.homepage?{homepage:r.homepage}:{},...r.license?{license:r.license}:{}}}var Qr=[{path:`${Qt}/${er}`,converter:()=>{throw new Error("Use parseCollectionManifest for native format")},formatLabel:"Shared Context"},{path:".claude-plugin/plugin.json",converter:Gs,formatLabel:"Claude Plugin"},{path:".claude/plugin.json",converter:Gs,formatLabel:"Claude Plugin"},{path:"gemini-extension.json",converter:xa,formatLabel:"Gemini Extension"},{path:".cursor-plugin/plugin.json",converter:Oa,formatLabel:"Cursor Plugin"}];var zs=[{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}],Zs=`${Qt}/${er}`;function rt(r){let e={name:"",description:"",body:r};if(!r.startsWith(`---
|
|
139
138
|
`)&&!r.startsWith(`---\r
|
|
140
139
|
`))return e;let t=r.indexOf(`
|
|
141
|
-
---`,3);if(t===-1)return e;let n=r.slice(4,t),s=r.slice(t+4);e.body=s.replace(/^\r?\n/,"").replace(/^\r?\n/,"");let o={},
|
|
142
|
-
`),
|
|
143
|
-
`).replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function Le(r){let e=Ra(r);return`sha256:${(0,Ks.createHash)("sha256").update(e,"utf8").digest("hex")}`}function Re(r){return r.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function xt(r){try{return(0,B.statSync)(r).isDirectory()}catch{return!1}}function Qr(r){try{return(0,B.readdirSync)(r).filter(e=>!e.startsWith(".")&&xt((0,J.join)(r,e)))}catch{return[]}}function en(r){try{return(0,B.readdirSync)(r).filter(e=>!e.startsWith(".")&&!xt((0,J.join)(r,e)))}catch{return[]}}function er(r,e){let t=[],n=[],s,o;function c(f,m){let C=[],h=[];for(let E of Zs){let d=(0,J.join)(f,E.folder);if(!(0,B.existsSync)(d)||!xt(d))continue;let i=m?`${m}/${E.folder}`:E.folder;if(E.folder==="files"){for(let g of en(d)){if(!g.endsWith(".md"))continue;let S=(0,J.join)(d,g),O=(0,B.readFileSync)(S,"utf-8"),_=st(O),I=_.name||(0,J.basename)(g,".md"),k=`${i}/${(0,J.basename)(g,".md")}`;C.push({importPath:k,resourceType:"file",title:I,description:_.description||null,body:_.body,bodyHash:Le(O),metadata:{}})}continue}if(E.mainFile===null)for(let g of en(d)){if(!g.endsWith(".md"))continue;let S=(0,J.basename)(g,".md"),O=`${i}/${S}`;if(xt((0,J.join)(d,S)))continue;let _=(0,B.readFileSync)((0,J.join)(d,g),"utf-8"),I=st(_),k=I.name||Re(S),v={};I.skillClass&&(v.skillClass=I.skillClass),I.service&&(v.service=I.service),I.requires?.length&&(v.requires=I.requires),I.tools?.length&&(v.tools=I.tools),I.fields&&Object.keys(I.fields).length&&(v.fields=I.fields),E.folder==="commands"&&(v.fields||(v.fields={}),v.fields["user-invocable"]="true"),C.push({importPath:O,resourceType:E.resourceType,title:k,description:I.description||null,body:I.body,bodyHash:Le(_),metadata:v})}for(let g of Qr(d)){let S=E.mainFile||`${g}.md`,O=(0,J.join)(d,g,S);if(!(0,B.existsSync)(O)){if(E.mainFile===null)for(let F of Qr((0,J.join)(d,g))){let $=`${F}.md`,M=(0,J.join)(d,g,F,$);if(!(0,B.existsSync)(M))continue;let Ee=(0,B.readFileSync)(M,"utf-8"),z=st(Ee),ne=z.name||Re(F),Ie={};z.skillClass&&(Ie.skillClass=z.skillClass),z.service&&(Ie.service=z.service),z.requires?.length&&(Ie.requires=z.requires),z.tools?.length&&(Ie.tools=z.tools),z.fields&&Object.keys(z.fields).length&&(Ie.fields=z.fields),C.push({importPath:`${i}/${F}`,resourceType:E.resourceType,title:ne,description:z.description||null,body:z.body,bodyHash:Le(Ee),metadata:Ie})}continue}let _=(0,B.readFileSync)(O,"utf-8"),I=`${i}/${g}`,k,v,P,x={},T=null;if(E.resourceType==="hook"||E.resourceType==="mcp"){try{let F=JSON.parse(_);k=F.name||Re(g),v=F.description||null}catch{k=Re(g),v=null}P=_}else if(E.resourceType==="collection"){let F=(0,J.join)(d,g,Yt,Qt);if((0,B.existsSync)(F))try{let $=JSON.parse((0,B.readFileSync)(F,"utf-8"));k=$.name||Re(g),v=$.description||null,P=_,$.resources&&Array.isArray($.resources)&&h.push({collectionImportPath:I,memberImportPaths:$.resources.map(M=>{let Ee=M.split("/");return Ee.length>=3?`${Ee[0]}/${Ee[Ee.length-1]}`:M})})}catch{k=Re(g),v=null,P=_}else T=st(_),k=T.name||Re(g),v=T.description||null,P=T.body,T.arrayFields?.resources&&h.push({collectionImportPath:I,memberImportPaths:T.arrayFields.resources.map($=>{let M=$.split("/");return M.length>=3?`${M[0]}/${M[M.length-1]}`:$})})}else T=st(_),k=T.name||Re(g),v=T.description||null,P=T.body,T.skillClass&&(x.skillClass=T.skillClass),T.service&&(x.service=T.service),T.requires?.length&&(x.requires=T.requires),T.tools?.length&&(x.tools=T.tools),T.fields&&Object.keys(T.fields).length&&(x.fields=T.fields);E.folder==="commands"&&(x.fields||(x.fields={}),x.fields["user-invocable"]="true"),C.push({importPath:I,resourceType:E.resourceType,title:k,description:v,body:P,bodyHash:Le(_),metadata:x})}}return{resources:C,memberships:h}}let a=c(r,"");t.push(...a.resources),n.push(...a.memberships);let l=new Set;e?.mcpConfigPath&&l.add(e.mcpConfigPath);let u=(0,J.join)(r,".mcp.json");(0,B.existsSync)(u)&&l.add(u);for(let f of l)if((0,B.existsSync)(f))try{let m=JSON.parse((0,B.readFileSync)(f,"utf-8"));if(m.mcpServers&&typeof m.mcpServers=="object")for(let[C,h]of Object.entries(m.mcpServers)){let E=`mcps/${C}`;if(t.some(g=>g.importPath===E))continue;let d=Re(C),i=JSON.stringify({name:d,description:`MCP server: ${C}`,mcpServers:{[C]:h}},null,2);t.push({importPath:E,resourceType:"mcp",title:d,description:`MCP server: ${C}`,body:i,bodyHash:Le(i),metadata:{}})}}catch{}if(e?.settingsPath&&(0,B.existsSync)(e.settingsPath))try{let f=JSON.parse((0,B.readFileSync)(e.settingsPath,"utf-8"));if(f.hooks&&typeof f.hooks=="object"&&!Array.isArray(f.hooks)){let m={};for(let[C,h]of Object.entries(f.hooks))if(Array.isArray(h))for(let E of h){if(!E||typeof E!="object")continue;let d=E,i=d._sc;if(!i)continue;m[i]||(m[i]={}),m[i][C]||(m[i][C]=[]);let{_sc:g,...S}=d;m[i][C].push(S)}for(let[C,h]of Object.entries(m)){let E=C;if(t.some(S=>S.importPath===E))continue;let d=C.split("/").pop()||C,i=Re(d),g=JSON.stringify({name:i,description:`Hook: ${i}`,hooks:h},null,2);t.push({importPath:E,resourceType:"hook",title:i,description:`Hook: ${i}`,body:g,bodyHash:Le(g),metadata:{}})}}}catch{}for(let f of Yr){if(f.path===Js)continue;let m=(0,J.join)(r,f.path);if((0,B.existsSync)(m)){try{let C=JSON.parse((0,B.readFileSync)(m,"utf-8"));if(s=s||C.name||void 0,o=f.formatLabel,!t.some(h=>h.resourceType==="collection")){let h=t.filter(S=>S.resourceType!=="collection").map(S=>({resourceRef:S.importPath})),E=f.converter(C,h),d=(0,J.join)(r,"README.md"),i=(0,B.existsSync)(d)?(0,B.readFileSync)(d,"utf-8"):"",g="collections/_root";t.push({importPath:g,resourceType:"collection",title:Re(E.name),description:E.description||null,body:i,bodyHash:Le(i),metadata:{},manifestMetadata:{...E.author?{author:E.author}:{},...E.homepage?{homepage:E.homepage}:{},...E.license?{license:E.license}:{}}}),E.resources.length>0&&n.push({collectionImportPath:g,memberImportPaths:E.resources})}}catch{}break}}{let h=function(E,d,i){if(!(i>4))for(let g of Qr(E)){if(C.has(g))continue;let S=(0,J.join)(E,g),O=d?`${d}/${g}`:g;for(let _ of Yr){if(_.path===Js)continue;let I=(0,J.join)(S,_.path);if((0,B.existsSync)(I)){if(f.has(O))break;f.add(O);try{let k=JSON.parse((0,B.readFileSync)(I,"utf-8")),v=c(S,O);if(v.resources.length===0)break;t.push(...v.resources),n.push(...v.memberships);let P=v.resources.filter(M=>M.resourceType!=="collection").map(M=>({resourceRef:M.importPath})),x=_.converter(k,P),T=(0,J.join)(S,"README.md"),F=(0,B.existsSync)(T)?(0,B.readFileSync)(T,"utf-8"):"",$=`${O}/_collection`;t.push({importPath:$,resourceType:"collection",title:Re(x.name),description:x.description||null,body:F,bodyHash:Le(F),metadata:{},manifestMetadata:{...x.author?{author:x.author}:{},...x.homepage?{homepage:x.homepage}:{},...x.license?{license:x.license}:{}}}),n.push({collectionImportPath:$,memberImportPaths:v.resources.map(M=>M.importPath)}),s||(s=k.name||void 0),o||(o=_.formatLabel)}catch{}break}}h(S,O,i+1)}};var b=h;let f=new Set,m=new Set(Zs.map(E=>E.folder)),C=new Set([...m,"worktrees","plugins","node_modules","todos"]);h(r,"",0)}let p=(0,J.join)(r,"files");if((0,B.existsSync)(p)&&xt(p)&&!t.some(f=>f.resourceType==="file"))for(let f of en(p)){if(!f.endsWith(".md"))continue;let m=(0,J.join)(p,f),C=(0,B.readFileSync)(m,"utf-8"),h=st(C),E=h.name||(0,J.basename)(f,".md"),d=`files/${(0,J.basename)(f,".md")}`;t.some(i=>i.importPath===d)||t.push({importPath:d,resourceType:"file",title:E,description:h.description||null,body:h.body,bodyHash:Le(C),metadata:{}})}return{resources:[...t.filter(f=>f.resourceType!=="collection"),...t.filter(f=>f.resourceType==="collection")],collectionMemberships:n,pluginName:s,formatLabel:o}}async function tr(r){let{scanRoots:e,agentId:t,platformInternals:n=[".claude-plugin"],registerToProject:s=!1,skipImport:o=!1}=r,c=[],a=[],l=new Set;for(let{root:I,agent:k,isProject:v}of e){let P=er(I,{settingsPath:xe(k,v),mcpConfigPath:pe(k,v)});for(let x of P.resources)l.has(x.importPath)||(l.add(x.importPath),c.push({...x,scope:v?"project":"global"}));for(let x of P.collectionMemberships)l.has(`cm:${x.collectionImportPath}`)||(l.add(`cm:${x.collectionImportPath}`),a.push(x))}let u=c.map(I=>I.importPath),p=q(),y=new Set(p.installations.map(I=>I.installPath)),b=new Map;for(let I of p.installations){let k=I.installPath.split("/"),v=k[0],P=k[k.length-1];b.has(v)||b.set(v,new Set),b.get(v).add(P)}let f=new Set(n),m=c.filter(I=>{if(y.has(I.importPath))return!1;let k=I.importPath.split("/"),v=k[0],P=k[k.length-1];return!((v==="mcps"||v==="hooks")&&b.get(v)?.has(P)||I.importPath.startsWith(".")||f.has(P)||I.importPath.startsWith("plugins/"))});for(let I of m)I.description&&I.description.length>1e3&&(I.description=I.description.slice(0,997)+"...");let C=m.length,h=m.map(I=>({importPath:I.importPath,resourceType:I.resourceType,title:I.title}));if(m.length===0||o)return{imported:[],errors:0,projectRegistered:0,untrackedCount:C,discoveredPaths:u,untracked:h};let E={dryRun:!1,onConflict:"auto",visibility:"org",resources:m,collectionMemberships:a.length>0?a:void 0},d=await L("/api/cli/import",E,12e4);if(!d.ok)return{imported:[],errors:m.length,projectRegistered:0,untrackedCount:C,discoveredPaths:u,untracked:h};let i=[...d.data.created,...d.data.updated,...d.data.installed],g=new Map;for(let I of c)g.set(I.importPath,I.scope);let S=Ce();for(let I of i){if(!I.id)continue;let k=g.get(I.importPath)||"global";le({resourceId:I.id,slug:I.slug||I.importPath.split("/").pop()||I.id,installPath:I.importPath,title:I.importPath.split("/").pop()||I.id,sha:I.commitSha||"",scope:k,agent:t,installedAt:new Date().toISOString(),resourceType:I.resourceType,serverSynced:!0,...k==="project"&&S?{projectId:S.projectId}:{}})}let O=0;if(s&&S){let I=[...i,...d.data.skipped];for(let k of I){let v=k.id||k.existingId;if(!v||g.get(k.importPath)!=="project")continue;let x=await L(`/api/cli/projects/${S.projectId}/resources`,{resourceId:v});x.ok&&x.data.added&&O++}}return{imported:i.map(I=>({resourceType:I.resourceType||I.importPath.split("/")[0]?.replace(/s$/,"")||"unknown",slug:I.slug||I.importPath.split("/").pop()||"",title:I.importPath.split("/").pop()||"",importPath:I.importPath,id:I.id})),errors:d.data.errors.length,projectRegistered:O,untrackedCount:C,discoveredPaths:u,untracked:[]}}var ro=require("readline");function Ta(){if(process.platform==="darwin")try{let{execSync:r}=require("child_process"),e=r("scutil --get ComputerName",{encoding:"utf-8"}).trim();if(e)return e}catch{}return require("os").hostname()}var ze="context-manager",eo="Context Manager",rr="collections/shared-context/context-manager";function ja(r,e){let t=re(r,e),n=(0,Ze.join)(t,ze);return(0,ot.mkdirSync)(n,{recursive:!0}),(0,ot.writeFileSync)((0,Ze.join)(n,`${ze}.md`),Gs,"utf-8"),(0,Ze.join)(n,`${ze}.md`)}var Da={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Na(r){return q().installations.some(t=>t.installPath===rr&&t.agent===r)}function no(r){r.command("init").description("Initialize Shared Context CLI for your agent").option("--code <code>","Auth code from the web app").option("--link-project <id>","Link to a Shared Context project by ID").action(async(e,t)=>{let n={...e,...t.optsWithGlobals()};if(n.code){let{post:d}=await Promise.resolve().then(()=>(oe(),ts)),{saveAuth:i}=await Promise.resolve().then(()=>(ue(),Dt)),g=await d("/api/cli/auth",{code:n.code});g.ok?(i({token:g.data.token,email:g.data.user.email,orgId:g.data.org.id,orgSlug:g.data.org.slug,orgName:g.data.org.name,createdAt:new Date().toISOString()}),A()||w(`Authenticated as ${g.data.user.email}`)):U()?A()||w("Auth code already used, continuing with saved credentials."):(A()?D("init",g.error.code,g.error.message):R(`Auth failed: ${g.error.message}`),process.exit(1))}else U()||(A()?(D("init","AUTH_MISSING","Not authenticated. Run 'shared-context-ai login' first or pass --code."),process.exit(1)):(R("Not authenticated. Run 'shared-context-ai login' first or pass --code <code>."),process.exit(1)));let s;if(n.agent){let d=je(n.agent);if(!d){let i=`Unknown agent: ${n.agent}. Available: ${We().map(g=>g.id).join(", ")||"none detected"}`;A()?D("init","NO_AGENTS",i):R(i),process.exit(1)}s=[d]}else if(s=We(),s.length===0){let d=Ve();A()?D("init","NO_AGENTS",d):R(d),process.exit(1)}let o=ke(),c=Ta(),a;if(n.linkProject){if(!o?.token){let v="Authentication required for project linking. Run init with --code first.";A()?D("init","AUTH_REQUIRED",v):R(v),process.exit(1)}let d=s[0],i=await L("/api/cli/register-agent",{platform:d.platform,name:`CLI (${c})`});i.ok&&(a=i.data.connectionId);let g=await L(`/api/cli/projects/${n.linkProject}/join`,{localPath:process.cwd()});g.ok||(A()?D("init",g.error.code,g.error.message):R(`Failed to join project: ${g.error.message}`),process.exit(1));let{project:S,resources:O,members:_}=g.data;tt({projectId:S.id,projectName:S.name,projectSlug:S.slug});let I=De(d),k=[];for(let v of O)try{let P=v.installPath,x=await Z(`/api/cli/resource/${P}`);if(!x.ok)continue;let T=x.data;await I.install(T,"project",d),le({resourceId:v.id,slug:v.slug||v.id,installPath:P,title:v.title,sha:v.latestSha||"",scope:"project",agent:d.id,installedAt:new Date().toISOString(),projectId:S.id}),v.latestSha&&await L("/api/cli/install",{resourceId:v.id,agentPlatform:d.platform,installedSha:v.latestSha}).catch(()=>{}),k.push({title:v.title,resourceType:v.resourceType})}catch{}if(await L(`/api/cli/projects/${S.id}/sync`,{localPath:process.cwd()}).catch(()=>{}),jt({lastSyncAt:new Date().toISOString()}),A())N("init",{project:{id:S.id,name:S.name,slug:S.slug},agent:d.id,resourcesInstalled:k.length,memberCount:_.length});else{if(w(""),w(`Joined project: ${S.name}`),S.description&&w(`"${S.description}"`),w(""),k.length>0){w(`Installed ${k.length} resource${k.length===1?"":"s"}:`);let v={};for(let x of k)v[x.resourceType]||(v[x.resourceType]=[]),v[x.resourceType].push(x.title);let P={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections"};for(let[x,T]of Object.entries(v))w(` ${P[x]||x}: ${T.join(", ")}`)}else w("No resources to install (project is empty)");_.length>0&&(w(""),w(`Team (${_.length}): ${_.map(v=>v.name).join(", ")}`)),w(""),w("Quick reference:"),w(" shared-context-ai status View project sync status"),w(" shared-context-ai sync Check for resource updates")}return}let l=!1,u,p=(0,Ze.basename)(process.cwd()),y=Ce();if(o?.token&&!y&&p&&p!=="/")try{let d=await L("/api/cli/projects",{name:p});if(d.ok){let{id:i,name:g,slug:S}=d.data;tt({projectId:i,projectName:g,projectSlug:S}),l=!0,A()||w(`Created project: ${g}`)}else u=d.error.message,A()||R(`Project creation failed: ${u}`)}catch(d){u=d instanceof Error?d.message:String(d),A()||R(`Project creation error: ${u}`)}else y?l=!1:o?.token||(u="not authenticated");let b=[],f={"claude-code":"claude-plugin","gemini-cli":"gemini-extension",antigravity:"gemini-extension",cursor:"cursor",codex:"codex"};for(let d of s){let i=!1,g=!1,S=[],O=[];if(o?.token){let _=await L("/api/cli/register-agent",{platform:d.platform,name:`CLI (${c})`});if(_.ok){if(!a){a=_.data.connectionId;let{saveAuth:I}=await Promise.resolve().then(()=>(ue(),Dt));I({...o,connectionId:a})}}else A()||R(`Warning: Could not register ${d.label} connection: ${_.error.message}`)}if(o?.token&&Na(d.id))g=!0,i=!0;else if(o?.token)try{let _=await Z(`/api/cli/resource/${rr}`);if(_.ok){let I=_.data,v=await De(d).install(I,n.project?"project":"user",d);if(le({resourceId:I.resource.id,slug:I.resource.slug||"context-manager",installPath:rr,title:I.resource.title,sha:I.resource.latestSha||"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString(),pluginFormat:f[d.id]||"directory",memberCount:I.memberResources?.length}),I.resource.latestSha&&await L("/api/cli/install",{resourceId:I.resource.id,agentPlatform:d.platform,installedSha:I.resource.latestSha}).catch(()=>{}),I.memberResources)for(let P of I.memberResources){let x=P.slug||P.id,T=Da[P.resourceType]||P.resourceType+"s",F=P.orgSlug||I.resource.orgSlug,$=F?`${T}/${F}/${x}`:`${T}/${x}`;le({resourceId:P.id,slug:x,installPath:$,title:P.title,sha:P.latestSha||"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString(),collectionId:I.resource.id}),S.push({title:P.title,resourceType:P.resourceType}),P.latestSha&&await L("/api/cli/install",{resourceId:P.id,agentPlatform:d.platform,installedSha:P.latestSha}).catch(()=>{})}if(i=!0,!A()&&v.warnings.length>0)for(let P of v.warnings)R(`Warning: ${P}`)}}catch{}if(!i&&(ja(d,!!n.project),le({resourceId:"context-manager",slug:ze,installPath:`agents/${ze}`,title:eo,sha:"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString()}),o?.token))try{let _=`agents/shared-context/${ze}`,I=await Z(`/api/cli/resource/${_}`);if(I.ok&&I.data.resource){let k=I.data.resource;k.latestSha&&await L("/api/cli/install",{resourceId:k.id,agentPlatform:d.platform,installedSha:k.latestSha}),le({resourceId:k.id,slug:k.slug||ze,installPath:`agents/shared-context/${k.slug||ze}`,title:k.title||eo,sha:k.latestSha||"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString()})}}catch{}if(o?.token)try{let _=[],I=(0,Ze.join)(process.cwd(),d.dir),k=(0,Ze.join)((0,to.homedir)(),d.dir);(0,ot.existsSync)(I)&&_.push({root:I,agent:d,isProject:!0}),I!==k&&(0,ot.existsSync)(k)&&_.push({root:k,agent:d,isProject:!1}),_.length>0&&(O=(await tr({scanRoots:_,agentId:d.id,platformInternals:["context-manager",".claude-plugin"],registerToProject:!0})).imported.map(P=>({resourceType:P.resourceType,slug:P.slug,title:P.title})))}catch{}b.push({agent:d,collectionInstalled:i,installedMembers:S,importedResources:O,skippedEssentials:g})}if(jt({lastSyncAt:new Date().toISOString()}),b.some(d=>!d.skippedEssentials)&&!A()&&process.stdin.isTTY){let{getConfig:d,updateConfig:i}=await Promise.resolve().then(()=>(ue(),Dt));if(d().telemetry===void 0)try{if(await new Promise(O=>{let _=(0,ro.createInterface)({input:process.stdin,output:process.stdout});_.question(`
|
|
140
|
+
---`,3);if(t===-1)return e;let n=r.slice(4,t),s=r.slice(t+4);e.body=s.replace(/^\r?\n/,"").replace(/^\r?\n/,"");let o={},a={},c=new Set(["requires","tools"]),l={},u=n.split(`
|
|
141
|
+
`),m=null,y=!1;for(let I=0;I<u.length;I++){let f=u[I];if(m&&/^\s+-\s/.test(f)){let E=f.replace(/^\s+-\s/,"").trim();if(E){let d=dt(E);y?l[m].push(d):a[m].push(d)}continue}m=null,y=!1;let p=f.indexOf(":");if(p===-1)continue;let C=f.slice(0,p).trim(),g=f.slice(p+1).trim();if(!g&&C&&I+1<u.length&&/^\s+-\s/.test(u[I+1])){m=C,c.has(C)?(y=!0,l[C]=[]):(y=!1,a[C]=[]);continue}C==="name"||C==="title"?e.name=dt(g):C==="description"?e.description=dt(g):C==="skill_class"?e.skillClass=dt(g):C==="service"?e.service=dt(g):C&&g&&(o[C]=dt(g))}return l.requires?.length&&(e.requires=l.requires),l.tools?.length&&(e.tools=l.tools),Object.keys(o).length&&(e.fields=o),Object.keys(a).length&&(e.arrayFields=a),e}function dt(r){let e=r.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 va(r){let{body:e}=rt(r);return e.replace(/\r\n/g,`
|
|
142
|
+
`).replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function Me(r){let e=va(r);return`sha256:${(0,Js.createHash)("sha256").update(e,"utf8").digest("hex")}`}function Te(r){return r.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function It(r){try{return(0,B.statSync)(r).isDirectory()}catch{return!1}}function en(r){try{return(0,B.readdirSync)(r).filter(e=>!e.startsWith(".")&&It((0,J.join)(r,e)))}catch{return[]}}function tn(r){try{return(0,B.readdirSync)(r).filter(e=>!e.startsWith(".")&&!It((0,J.join)(r,e)))}catch{return[]}}function tr(r,e){let t=[],n=[],s,o;function a(f,p){let C=[],g=[];for(let E of zs){let d=(0,J.join)(f,E.folder);if(!(0,B.existsSync)(d)||!It(d))continue;let i=p?`${p}/${E.folder}`:E.folder;if(E.folder==="files"){for(let h of tn(d)){if(!h.endsWith(".md"))continue;let S=(0,J.join)(d,h),O=(0,B.readFileSync)(S,"utf-8"),A=rt(O),b=A.name||(0,J.basename)(h,".md"),v=`${i}/${(0,J.basename)(h,".md")}`;C.push({importPath:v,resourceType:"file",title:b,description:A.description||null,body:A.body,bodyHash:Me(O),metadata:{}})}continue}if(E.mainFile===null)for(let h of tn(d)){if(!h.endsWith(".md"))continue;let S=(0,J.basename)(h,".md"),O=`${i}/${S}`;if(It((0,J.join)(d,S)))continue;let A=(0,B.readFileSync)((0,J.join)(d,h),"utf-8"),b=rt(A),v=b.name||Te(S),k={};b.skillClass&&(k.skillClass=b.skillClass),b.service&&(k.service=b.service),b.requires?.length&&(k.requires=b.requires),b.tools?.length&&(k.tools=b.tools),b.fields&&Object.keys(b.fields).length&&(k.fields=b.fields),E.folder==="commands"&&(k.fields||(k.fields={}),k.fields["user-invocable"]="true"),C.push({importPath:O,resourceType:E.resourceType,title:v,description:b.description||null,body:b.body,bodyHash:Me(A),metadata:k})}for(let h of en(d)){let S=E.mainFile||`${h}.md`,O=(0,J.join)(d,h,S);if(!(0,B.existsSync)(O)){if(E.mainFile===null)for(let F of en((0,J.join)(d,h))){let $=`${F}.md`,M=(0,J.join)(d,h,F,$);if(!(0,B.existsSync)(M))continue;let Se=(0,B.readFileSync)(M,"utf-8"),z=rt(Se),ne=z.name||Te(F),Ie={};z.skillClass&&(Ie.skillClass=z.skillClass),z.service&&(Ie.service=z.service),z.requires?.length&&(Ie.requires=z.requires),z.tools?.length&&(Ie.tools=z.tools),z.fields&&Object.keys(z.fields).length&&(Ie.fields=z.fields),C.push({importPath:`${i}/${F}`,resourceType:E.resourceType,title:ne,description:z.description||null,body:z.body,bodyHash:Me(Se),metadata:Ie})}continue}let A=(0,B.readFileSync)(O,"utf-8"),b=`${i}/${h}`,v,k,T,x={},P=null;if(E.resourceType==="hook"||E.resourceType==="mcp"){try{let F=JSON.parse(A);v=F.name||Te(h),k=F.description||null}catch{v=Te(h),k=null}T=A}else if(E.resourceType==="collection"){let F=(0,J.join)(d,h,Qt,er);if((0,B.existsSync)(F))try{let $=JSON.parse((0,B.readFileSync)(F,"utf-8"));v=$.name||Te(h),k=$.description||null,T=A,$.resources&&Array.isArray($.resources)&&g.push({collectionImportPath:b,memberImportPaths:$.resources.map(M=>{let Se=M.split("/");return Se.length>=3?`${Se[0]}/${Se[Se.length-1]}`:M})})}catch{v=Te(h),k=null,T=A}else P=rt(A),v=P.name||Te(h),k=P.description||null,T=P.body,P.arrayFields?.resources&&g.push({collectionImportPath:b,memberImportPaths:P.arrayFields.resources.map($=>{let M=$.split("/");return M.length>=3?`${M[0]}/${M[M.length-1]}`:$})})}else P=rt(A),v=P.name||Te(h),k=P.description||null,T=P.body,P.skillClass&&(x.skillClass=P.skillClass),P.service&&(x.service=P.service),P.requires?.length&&(x.requires=P.requires),P.tools?.length&&(x.tools=P.tools),P.fields&&Object.keys(P.fields).length&&(x.fields=P.fields);E.folder==="commands"&&(x.fields||(x.fields={}),x.fields["user-invocable"]="true"),C.push({importPath:b,resourceType:E.resourceType,title:v,description:k,body:T,bodyHash:Me(A),metadata:x})}}return{resources:C,memberships:g}}let c=a(r,"");t.push(...c.resources),n.push(...c.memberships);let l=new Set;e?.mcpConfigPath&&l.add(e.mcpConfigPath);let u=(0,J.join)(r,".mcp.json");(0,B.existsSync)(u)&&l.add(u);for(let f of l)if((0,B.existsSync)(f))try{let p=JSON.parse((0,B.readFileSync)(f,"utf-8"));if(p.mcpServers&&typeof p.mcpServers=="object")for(let[C,g]of Object.entries(p.mcpServers)){let E=`mcps/${C}`;if(t.some(h=>h.importPath===E))continue;let d=Te(C),i=JSON.stringify({name:d,description:`MCP server: ${C}`,mcpServers:{[C]:g}},null,2);t.push({importPath:E,resourceType:"mcp",title:d,description:`MCP server: ${C}`,body:i,bodyHash:Me(i),metadata:{}})}}catch{}if(e?.settingsPath&&(0,B.existsSync)(e.settingsPath))try{let f=JSON.parse((0,B.readFileSync)(e.settingsPath,"utf-8"));if(f.hooks&&typeof f.hooks=="object"&&!Array.isArray(f.hooks)){let p={};for(let[C,g]of Object.entries(f.hooks))if(Array.isArray(g))for(let E of g){if(!E||typeof E!="object")continue;let d=E,i=d._sc;if(!i)continue;p[i]||(p[i]={}),p[i][C]||(p[i][C]=[]);let{_sc:h,...S}=d;p[i][C].push(S)}for(let[C,g]of Object.entries(p)){let E=C;if(t.some(S=>S.importPath===E))continue;let d=C.split("/").pop()||C,i=Te(d),h=JSON.stringify({name:i,description:`Hook: ${i}`,hooks:g},null,2);t.push({importPath:E,resourceType:"hook",title:i,description:`Hook: ${i}`,body:h,bodyHash:Me(h),metadata:{}})}}}catch{}for(let f of Qr){if(f.path===Zs)continue;let p=(0,J.join)(r,f.path);if((0,B.existsSync)(p)){try{let C=JSON.parse((0,B.readFileSync)(p,"utf-8"));if(s=s||C.name||void 0,o=f.formatLabel,!t.some(g=>g.resourceType==="collection")){let g=t.filter(S=>S.resourceType!=="collection").map(S=>({resourceRef:S.importPath})),E=f.converter(C,g),d=(0,J.join)(r,"README.md"),i=(0,B.existsSync)(d)?(0,B.readFileSync)(d,"utf-8"):"",h="collections/_root";t.push({importPath:h,resourceType:"collection",title:Te(E.name),description:E.description||null,body:i,bodyHash:Me(i),metadata:{},manifestMetadata:{...E.author?{author:E.author}:{},...E.homepage?{homepage:E.homepage}:{},...E.license?{license:E.license}:{}}}),E.resources.length>0&&n.push({collectionImportPath:h,memberImportPaths:E.resources})}}catch{}break}}{let g=function(E,d,i){if(!(i>4))for(let h of en(E)){if(C.has(h))continue;let S=(0,J.join)(E,h),O=d?`${d}/${h}`:h;for(let A of Qr){if(A.path===Zs)continue;let b=(0,J.join)(S,A.path);if((0,B.existsSync)(b)){if(f.has(O))break;f.add(O);try{let v=JSON.parse((0,B.readFileSync)(b,"utf-8")),k=a(S,O);if(k.resources.length===0)break;t.push(...k.resources),n.push(...k.memberships);let T=k.resources.filter(M=>M.resourceType!=="collection").map(M=>({resourceRef:M.importPath})),x=A.converter(v,T),P=(0,J.join)(S,"README.md"),F=(0,B.existsSync)(P)?(0,B.readFileSync)(P,"utf-8"):"",$=`${O}/_collection`;t.push({importPath:$,resourceType:"collection",title:Te(x.name),description:x.description||null,body:F,bodyHash:Me(F),metadata:{},manifestMetadata:{...x.author?{author:x.author}:{},...x.homepage?{homepage:x.homepage}:{},...x.license?{license:x.license}:{}}}),n.push({collectionImportPath:$,memberImportPaths:k.resources.map(M=>M.importPath)}),s||(s=v.name||void 0),o||(o=A.formatLabel)}catch{}break}}g(S,O,i+1)}};var I=g;let f=new Set,p=new Set(zs.map(E=>E.folder)),C=new Set([...p,"worktrees","plugins","node_modules","todos"]);g(r,"",0)}let m=(0,J.join)(r,"files");if((0,B.existsSync)(m)&&It(m)&&!t.some(f=>f.resourceType==="file"))for(let f of tn(m)){if(!f.endsWith(".md"))continue;let p=(0,J.join)(m,f),C=(0,B.readFileSync)(p,"utf-8"),g=rt(C),E=g.name||(0,J.basename)(f,".md"),d=`files/${(0,J.basename)(f,".md")}`;t.some(i=>i.importPath===d)||t.push({importPath:d,resourceType:"file",title:E,description:g.description||null,body:g.body,bodyHash:Me(C),metadata:{}})}return{resources:[...t.filter(f=>f.resourceType!=="collection"),...t.filter(f=>f.resourceType==="collection")],collectionMemberships:n,pluginName:s,formatLabel:o}}async function rr(r){let{scanRoots:e,agentId:t,platformInternals:n=[".claude-plugin"],registerToProject:s=!1,skipImport:o=!1}=r,a=[],c=[],l=new Set;for(let{root:b,agent:v,isProject:k}of e){let T=tr(b,{settingsPath:ve(v,k),mcpConfigPath:pe(v,k)});for(let x of T.resources)l.has(x.importPath)||(l.add(x.importPath),a.push({...x,scope:k?"project":"global"}));for(let x of T.collectionMemberships)l.has(`cm:${x.collectionImportPath}`)||(l.add(`cm:${x.collectionImportPath}`),c.push(x))}let u=a.map(b=>b.importPath),m=q(),y=new Set(m.installations.map(b=>b.installPath)),I=new Map;for(let b of m.installations){let v=b.installPath.split("/"),k=v[0],T=v[v.length-1];I.has(k)||I.set(k,new Set),I.get(k).add(T)}let f=new Set(n),p=a.filter(b=>{if(y.has(b.importPath))return!1;let v=b.importPath.split("/"),k=v[0],T=v[v.length-1];return!((k==="mcps"||k==="hooks")&&I.get(k)?.has(T)||b.importPath.startsWith(".")||f.has(T)||b.importPath.startsWith("plugins/"))});for(let b of p)b.description&&b.description.length>1e3&&(b.description=b.description.slice(0,997)+"...");let C=p.length,g=p.map(b=>({importPath:b.importPath,resourceType:b.resourceType,title:b.title}));if(p.length===0||o)return{imported:[],errors:0,projectRegistered:0,untrackedCount:C,discoveredPaths:u,untracked:g};let E={dryRun:!1,onConflict:"auto",visibility:"org",resources:p,collectionMemberships:c.length>0?c:void 0},d=await L("/api/cli/import",E,12e4);if(!d.ok)return{imported:[],errors:p.length,projectRegistered:0,untrackedCount:C,discoveredPaths:u,untracked:g};let i=[...d.data.created,...d.data.updated,...d.data.installed],h=new Map;for(let b of a)h.set(b.importPath,b.scope);let S=Ce();for(let b of i){if(!b.id)continue;let v=h.get(b.importPath)||"global";le({resourceId:b.id,slug:b.slug||b.importPath.split("/").pop()||b.id,installPath:b.importPath,title:b.importPath.split("/").pop()||b.id,sha:b.commitSha||"",scope:v,agent:t,installedAt:new Date().toISOString(),resourceType:b.resourceType,serverSynced:!0,...v==="project"&&S?{projectId:S.projectId}:{}})}let O=0;if(s&&S){let b=[...i,...d.data.skipped];for(let v of b){let k=v.id||v.existingId;if(!k||h.get(v.importPath)!=="project")continue;let x=await L(`/api/cli/projects/${S.projectId}/resources`,{resourceId:k});x.ok&&x.data.added&&O++}}return{imported:i.map(b=>({resourceType:b.resourceType||b.importPath.split("/")[0]?.replace(/s$/,"")||"unknown",slug:b.slug||b.importPath.split("/").pop()||"",title:b.importPath.split("/").pop()||"",importPath:b.importPath,id:b.id})),errors:d.data.errors.length,projectRegistered:O,untrackedCount:C,discoveredPaths:u,untracked:[]}}var Ys=require("readline");function ka(){if(process.platform==="darwin")try{let{execSync:r}=require("child_process"),e=r("scutil --get ComputerName",{encoding:"utf-8"}).trim();if(e)return e}catch{}return require("os").hostname()}var Ge="context-manager",Ks="Context Manager",nr="collections/shared-context/context-manager";function Ra(r,e){let t=re(r,e),n=(0,ze.join)(t,Ge);return(0,nt.mkdirSync)(n,{recursive:!0}),(0,nt.writeFileSync)((0,ze.join)(n,`${Ge}.md`),qs,"utf-8"),(0,ze.join)(n,`${Ge}.md`)}var Ta={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Pa(r){return q().installations.some(t=>t.installPath===nr&&t.agent===r)}function Qs(r){r.command("init").description("Initialize Shared Context CLI for your agent").option("--code <code>","Auth code from the web app").option("--link-project <id>","Link to a Shared Context project by ID").action(async(e,t)=>{let n={...e,...t.optsWithGlobals()};if(n.code){let{post:d}=await Promise.resolve().then(()=>(oe(),es)),{saveAuth:i}=await Promise.resolve().then(()=>(ue(),Nt)),h=await d("/api/cli/auth",{code:n.code});h.ok?(i({token:h.data.token,email:h.data.user.email,orgId:h.data.org.id,orgSlug:h.data.org.slug,orgName:h.data.org.name,createdAt:new Date().toISOString()}),_()||w(`Authenticated as ${h.data.user.email}`)):U()?_()||w("Auth code already used, continuing with saved credentials."):(_()?D("init",h.error.code,h.error.message):R(`Auth failed: ${h.error.message}`),process.exit(1))}else U()||(_()?(D("init","AUTH_MISSING","Not authenticated. Run 'shared-context-ai login' first or pass --code."),process.exit(1)):(R("Not authenticated. Run 'shared-context-ai login' first or pass --code <code>."),process.exit(1)));let s;if(n.agent){let d=De(n.agent);if(!d){let i=`Unknown agent: ${n.agent}. Available: ${We().map(h=>h.id).join(", ")||"none detected"}`;_()?D("init","NO_AGENTS",i):R(i),process.exit(1)}s=[d]}else if(s=We(),s.length===0){let d=Ve();_()?D("init","NO_AGENTS",d):R(d),process.exit(1)}let o=Re(),a=ka(),c;if(n.linkProject){if(!o?.token){let k="Authentication required for project linking. Run init with --code first.";_()?D("init","AUTH_REQUIRED",k):R(k),process.exit(1)}let d=s[0],i=await L("/api/cli/register-agent",{platform:d.platform,name:`CLI (${a})`});i.ok&&(c=i.data.connectionId);let h=await L(`/api/cli/projects/${n.linkProject}/join`,{localPath:process.cwd()});h.ok||(_()?D("init",h.error.code,h.error.message):R(`Failed to join project: ${h.error.message}`),process.exit(1));let{project:S,resources:O,members:A}=h.data;Qe({projectId:S.id,projectName:S.name,projectSlug:S.slug});let b=Ne(d),v=[];for(let k of O)try{let T=k.installPath,x=await Z(`/api/cli/resource/${T}`);if(!x.ok)continue;let P=x.data;await b.install(P,"project",d),le({resourceId:k.id,slug:k.slug||k.id,installPath:T,title:k.title,sha:k.latestSha||"",scope:"project",agent:d.id,installedAt:new Date().toISOString(),projectId:S.id}),k.latestSha&&await L("/api/cli/install",{resourceId:k.id,agentPlatform:d.platform,installedSha:k.latestSha}).catch(()=>{}),v.push({title:k.title,resourceType:k.resourceType})}catch{}if(await L(`/api/cli/projects/${S.id}/sync`,{localPath:process.cwd()}).catch(()=>{}),Dt({lastSyncAt:new Date().toISOString()}),_())N("init",{project:{id:S.id,name:S.name,slug:S.slug},agent:d.id,resourcesInstalled:v.length,memberCount:A.length});else{if(w(""),w(`Joined project: ${S.name}`),S.description&&w(`"${S.description}"`),w(""),v.length>0){w(`Installed ${v.length} resource${v.length===1?"":"s"}:`);let k={};for(let x of v)k[x.resourceType]||(k[x.resourceType]=[]),k[x.resourceType].push(x.title);let T={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections"};for(let[x,P]of Object.entries(k))w(` ${T[x]||x}: ${P.join(", ")}`)}else w("No resources to install (project is empty)");A.length>0&&(w(""),w(`Team (${A.length}): ${A.map(k=>k.name).join(", ")}`)),w(""),w("Quick reference:"),w(" shared-context-ai status View project sync status"),w(" shared-context-ai sync Check for resource updates")}return}let l=!1,u,m=(0,ze.basename)(process.cwd()),y=Ce();if(o?.token&&!y&&m&&m!=="/")try{let d=await L("/api/cli/projects",{name:m});if(d.ok){let{id:i,name:h,slug:S}=d.data;Qe({projectId:i,projectName:h,projectSlug:S}),l=!0,_()||w(`Created project: ${h}`)}else u=d.error.message,_()||R(`Project creation failed: ${u}`)}catch(d){u=d instanceof Error?d.message:String(d),_()||R(`Project creation error: ${u}`)}else y?l=!1:o?.token||(u="not authenticated");let I=[],f={"claude-code":"claude-plugin","gemini-cli":"gemini-extension",antigravity:"gemini-extension",cursor:"cursor",codex:"codex"};for(let d of s){let i=!1,h=!1,S=[],O=[];if(o?.token){let A=await L("/api/cli/register-agent",{platform:d.platform,name:`CLI (${a})`});if(A.ok){if(!c){c=A.data.connectionId;let{saveAuth:b}=await Promise.resolve().then(()=>(ue(),Nt));b({...o,connectionId:c})}}else _()||R(`Warning: Could not register ${d.label} connection: ${A.error.message}`)}if(o?.token&&Pa(d.id))h=!0,i=!0;else if(o?.token)try{let A=await Z(`/api/cli/resource/${nr}`);if(A.ok){let b=A.data,k=await Ne(d).install(b,n.project?"project":"user",d);if(le({resourceId:b.resource.id,slug:b.resource.slug||"context-manager",installPath:nr,title:b.resource.title,sha:b.resource.latestSha||"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString(),pluginFormat:f[d.id]||"directory",memberCount:b.memberResources?.length}),b.resource.latestSha&&await L("/api/cli/install",{resourceId:b.resource.id,agentPlatform:d.platform,installedSha:b.resource.latestSha}).catch(()=>{}),b.memberResources)for(let T of b.memberResources){let x=T.slug||T.id,P=Ta[T.resourceType]||T.resourceType+"s",F=T.orgSlug||b.resource.orgSlug,$=F?`${P}/${F}/${x}`:`${P}/${x}`;le({resourceId:T.id,slug:x,installPath:$,title:T.title,sha:T.latestSha||"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString(),collectionId:b.resource.id}),S.push({title:T.title,resourceType:T.resourceType}),T.latestSha&&await L("/api/cli/install",{resourceId:T.id,agentPlatform:d.platform,installedSha:T.latestSha}).catch(()=>{})}if(i=!0,!_()&&k.warnings.length>0)for(let T of k.warnings)R(`Warning: ${T}`)}}catch{}if(!i&&(Ra(d,!!n.project),le({resourceId:"context-manager",slug:Ge,installPath:`agents/${Ge}`,title:Ks,sha:"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString()}),o?.token))try{let A=`agents/shared-context/${Ge}`,b=await Z(`/api/cli/resource/${A}`);if(b.ok&&b.data.resource){let v=b.data.resource;v.latestSha&&await L("/api/cli/install",{resourceId:v.id,agentPlatform:d.platform,installedSha:v.latestSha}),le({resourceId:v.id,slug:v.slug||Ge,installPath:`agents/shared-context/${v.slug||Ge}`,title:v.title||Ks,sha:v.latestSha||"",scope:n.project?"project":"global",agent:d.id,installedAt:new Date().toISOString()})}}catch{}if(o?.token)try{let A=[],b=(0,ze.join)(process.cwd(),d.dir),v=(0,ze.join)((0,Xs.homedir)(),d.dir);(0,nt.existsSync)(b)&&A.push({root:b,agent:d,isProject:!0}),b!==v&&(0,nt.existsSync)(v)&&A.push({root:v,agent:d,isProject:!1}),A.length>0&&(O=(await rr({scanRoots:A,agentId:d.id,platformInternals:["context-manager",".claude-plugin"],registerToProject:!0})).imported.map(T=>({resourceType:T.resourceType,slug:T.slug,title:T.title})))}catch{}I.push({agent:d,collectionInstalled:i,installedMembers:S,importedResources:O,skippedEssentials:h})}if(Dt({lastSyncAt:new Date().toISOString()}),I.some(d=>!d.skippedEssentials)&&!_()&&process.stdin.isTTY){let{getConfig:d,updateConfig:i}=await Promise.resolve().then(()=>(ue(),Nt));if(d().telemetry===void 0)try{await new Promise(O=>{let A=(0,Ys.createInterface)({input:process.stdin,output:process.stdout});A.question(`
|
|
144
143
|
Help improve Shared Context skills? We collect anonymous usage data
|
|
145
144
|
(which skills you use, never conversation content). Change anytime with
|
|
146
|
-
\`shared-context-ai config set telemetry off\`. [y/N] `,
|
|
147
|
-
${
|
|
148
|
-
`);let a
|
|
149
|
-
Install a skill: npx shared-context-ai install <installPath>`)})}oe();ue();se();function
|
|
150
|
-
`);let n=t.map(s=>[
|
|
151
|
-
`);let n=t.map(s=>[s.installPath||s.slug,s.title,`(${s.agent})`]);w(
|
|
152
|
-
Tip: Run 'shared-context-ai login' to sync with sharedcontext.ai and check for updates.`)}})}oe();se();function
|
|
153
|
-
`);let s=t.map(o=>{let
|
|
154
|
-
Run 'shared-context-ai update' to update all, or 'shared-context-ai update <installPath>' to update one.`)})}var
|
|
155
|
-
${l.length} resource${l.length===1?"":"s"} updated.`)})}var ie=require("fs"),
|
|
156
|
-
`);let C=
|
|
157
|
-
Usage: shared-context-ai uninstall <path>`)}return}let s=n.optsWithGlobals(),o=
|
|
158
|
-
`,"utf-8"))}}catch{}}else if(S==="hooks")
|
|
159
|
-
`,"utf-8"),
|
|
160
|
-
Importing from GitHub: ${o}`);let C=await L("/api/cli/github-import",
|
|
161
|
-
Import failed: ${C.error.message}`),process.exit(1));let
|
|
162
|
-
Discovered ${
|
|
163
|
-
Executing import...`):
|
|
164
|
-
Dry run \u2014 previewing changes...`);let
|
|
165
|
-
Import failed: ${
|
|
166
|
-
Auto-installed ${y} resource${y===1?"":"s"} from web dashboard`)}else if(
|
|
167
|
-
${
|
|
168
|
-
Imported ${
|
|
169
|
-
${
|
|
170
|
-
Project "${x?.projectName}": registered ${
|
|
171
|
-
Project "${d.projectName}" has ${
|
|
172
|
-
Project "${d.projectName}": installed ${i} new resource${i===1?"":"s"}`)}if(n.project){let z=new Set(F.map(
|
|
173
|
-
Project "${d.projectName}": registered ${Ie} existing resource${Ie===1?"":"s"}`)}await L(`/api/cli/projects/${d.projectId}/sync`,{localPath:process.cwd()}).catch(()=>{})}}let g
|
|
174
|
-
`);let t=r.updates.map(n=>[` ${n.installPath}`,n.title,`${n.sha.slice(0,7)} \u2192 ${n.latestSha.slice(0,7)}`]);w(
|
|
175
|
-
`);let t=r.untracked.map(n=>[` ${n.resourceType.padEnd(12)}`,n.importPath.padEnd(30),n.title]);w(
|
|
176
|
-
`).filter(Boolean),t=[];for(let n of e)try{let s=JSON.parse(n);s.v&&s.ts&&s.event&&s.rid&&t.push(s)}catch{}return t}catch{return[]}}function
|
|
177
|
-
`),
|
|
145
|
+
\`shared-context-ai config set telemetry off\`. [y/N] `,b=>{A.close(),O(b.trim().toLowerCase()==="y"||b.trim().toLowerCase()==="yes")})})?(i({telemetry:!0}),w("Telemetry enabled.")):(i({telemetry:!1}),w("Telemetry disabled."))}catch{}}if(c){let d=I.reduce((i,h)=>i+h.importedResources.length,0);L("/api/cli/sync-report",{connectionId:c,lastSyncResult:{updatesAvailable:0,importedCount:d}}).catch(()=>{})}let C=I.every(d=>d.skippedEssentials),g=I.some(d=>!d.skippedEssentials),E=I.some(d=>d.importedResources.length>0);if(_()){let d=h=>({agent:h.agent.id,collection:h.collectionInstalled?nr:void 0,contextManagerOnly:!h.collectionInstalled,skipped:h.skippedEssentials,...h.collectionInstalled&&!h.skippedEssentials?{membersInstalled:h.installedMembers.map(S=>({title:S.title,resourceType:S.resourceType}))}:{},...h.importedResources.length>0?{importedResources:h.importedResources.map(S=>({resourceType:S.resourceType,slug:S.slug,title:S.title}))}:{}}),i=Ce();N("init",{...d(I[0]),agents:I.map(d),...l?{projectCreated:!0,projectId:i?.projectId}:{},...i&&!l?{projectLinked:!0,projectId:i.projectId}:{},...u?{projectError:u}:{},authenticated:U()})}else{for(let d of I)if(!d.skippedEssentials){if(w(""),d.collectionInstalled){w(`Context Manager installed for ${d.agent.label} (${d.installedMembers.length} resources)`);let i={};for(let S of d.installedMembers)i[S.resourceType]||(i[S.resourceType]=[]),i[S.resourceType].push(S.title);let h={skill:"Skills",agent:"Agents",hook:"Hooks",mcp:"MCPs",collection:"Collections"};w("");for(let[S,O]of Object.entries(i)){let A=h[S]||S;w(` ${A}: ${O.join(", ")}`)}}else w(`Context Manager installed for ${d.agent.label} (offline)`),w("Context Manager agent written locally");if(d.importedResources.length>0){w(""),w(`Imported ${d.importedResources.length} existing resource${d.importedResources.length===1?"":"s"}:`);for(let i of d.importedResources)w(` ${i.resourceType.padEnd(12)} ${i.slug.padEnd(24)} ${i.title}`)}}C&&!l&&!E&&(w(""),w("Already initialized. Nothing to do.")),(g||l||E)&&(w(""),w("Quick reference:"),w(' shared-context-ai search "query" Search for resources'),w(" shared-context-ai install <installPath> Install a resource"),w(" shared-context-ai list List installed resources"),w(" shared-context-ai sync Check updates & discover resources"),w(" shared-context-ai preview <installPath> Preview before installing"))}})}var Ro=require("http"),To=require("crypto");ue();oe();ue();se();async function Po(r){let e=await L("/api/cli/auth",{code:r});return e.ok?(Nr({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()}),_()?N("login",{email:e.data.user.email,org:e.data.org.slug}):w(`Logged in as ${e.data.user.email} (org: ${e.data.org.name})`),!0):(_()?D("login",e.error.code,e.error.message):R(`Login failed: ${e.error.message}`),!1)}async function Ja(){let r=(0,To.randomBytes)(16).toString("hex");return new Promise(e=>{let t=(0,Ro.createServer)((n,s)=>{let o=new URL(n.url||"/","http://localhost"),a=o.searchParams.get("code"),c=o.searchParams.get("state");if(!a||c!==r){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(),Po(a).then(e)});t.listen(0,"127.0.0.1",async()=>{let n=t.address();if(!n||typeof n=="string"){t.close(),e(!1);return}let s=n.port,a=`${xe().apiBase||"https://sharedcontext.ai"}/cli/login?port=${s}&state=${r}`;_()||(w("Opening browser for authentication..."),w(`If the browser doesn't open, visit: ${a}`));try{let c=(await Promise.resolve().then(()=>(ko(),vo))).default;await c(a)}catch{_()||w(`Could not open browser. Please visit:
|
|
146
|
+
${a}`)}setTimeout(()=>{t.close(),_()||R("Login timed out after 5 minutes."),e(!1)},300*1e3)})})}function jo(r){r.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 Po(e.code):t=await Ja(),process.exit(t?0:1)})}oe();se();var Ka={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Do(r){let e=Ka[r.resourceType]||r.resourceType+"s";return r.storageType==="github"&&r.githubOwner?`${e}/external/${r.githubOwner}/${r.slug}`:r.orgSlug?`${e}/${r.orgSlug}/${r.slug}`:`${e}/${r.slug}`}function No(r){r.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 n=new URLSearchParams({q:e});t.type&&n.set("type",t.type),t.tag&&n.set("tag",t.tag),t.limit&&n.set("limit",t.limit);let s=U()?`/api/cli/search?${n}`:`/api/public/search?${n}`,o=await Z(s);o.ok||(_()?D("search",o.error.code,o.error.message):w(`Search failed: ${o.error.message}`),process.exit(1));let a=o.data.results;if(_()){let l=a.map(u=>{let m=Do(u);return{installPath:m,installCommand:`npx shared-context-ai install ${m}`,title:u.title,description:u.description,resourceType:u.resourceType,installCount:u.installCount,topicTags:u.topicTags}});N("search",{results:l,count:l.length});return}if(a.length===0){let l=t.type?`${t.type}s`:"results";w(`No ${l} found.`);return}w(`Found ${a.length} result${a.length===1?"":"s"}:
|
|
147
|
+
`);let c=a.map(l=>[Do(l),l.title,`\u2193${l.installCount}`]);w(he(c)),w(`
|
|
148
|
+
Install a skill: npx shared-context-ai install <installPath>`)})}oe();ue();se();function $o(r){let e=r.slug||r.resourceId;return r.storageType==="github"&&r.githubOwner?`skills/external/${r.githubOwner}/${e}`:r.orgSlug?`skills/${r.orgSlug}/${e}`:`skills/${e}`}function Fo(r){r.command("list").description("List installed skills").alias("ls").action(async()=>{if(U()){let e=await Z("/api/cli/installed");e.ok||(_()?D("list",e.error.code,e.error.message):w(`Failed to fetch installations: ${e.error.message}`),process.exit(1));let t=e.data.installations;if(_()){let s=t.map(o=>({...o,installPath:$o(o)}));N("list",{installations:s,count:s.length});return}if(t.length===0){w("No skills installed."),w("Use 'shared-context-ai search' to find skills to install.");return}w(`${t.length} skill${t.length===1?"":"s"} installed:
|
|
149
|
+
`);let n=t.map(s=>[$o(s),s.title,s.hasUpdate?"(update available)":"(current)"]);w(he(n))}else{let t=q().installations;if(_()){N("list",{installations:t,count:t.length});return}if(t.length===0){w("No skills installed locally.");return}w(`${t.length} skill${t.length===1?"":"s"} installed locally:
|
|
150
|
+
`);let n=t.map(s=>[s.installPath||s.slug,s.title,`(${s.agent})`]);w(he(n)),w(`
|
|
151
|
+
Tip: Run 'shared-context-ai login' to sync with sharedcontext.ai and check for updates.`)}})}oe();se();function Lo(r){r.command("preview <path>").description("Preview a skill's content (e.g., skills/acme/api-testing)").action(async e=>{let n=U()?"/api/cli/resource":"/api/public/resource",s=await Z(`${n}/${e}/preview`);s.ok||(_()?D("preview",s.error.code,s.error.message):R(`Preview failed: ${s.error.message}`),process.exit(1)),_()?N("preview",s.data):w(s.data.content)})}oe();se();function Mo(r){r.command("check").description("Check for skill updates").action(async()=>{U()||(_()?D("check","AUTH_MISSING","Login required to check for updates."):R("Login required to check for updates. Run 'shared-context-ai login'."),process.exit(1));let e=await Z("/api/cli/updates");e.ok||(_()?D("check",e.error.code,e.error.message):R(`Check failed: ${e.error.message}`),process.exit(1));let{updates:t,count:n}=e.data;if(_()){N("check",{updates:t,count:n});return}if(n===0){w("All skills are up to date.");return}w(`${n} update${n===1?"":"s"} available:
|
|
152
|
+
`);let s=t.map(o=>{let a=o.slug||o.resourceId;return[o.storageType==="github"&&o.githubOwner?`skills/external/${o.githubOwner}/${a}`:o.orgSlug?`skills/${o.orgSlug}/${a}`:`skills/${a}`,o.title,`${o.installedSha.slice(0,7)} \u2192 ${o.latestSha.slice(0,7)}`]});w(he(s)),w(`
|
|
153
|
+
Run 'shared-context-ai update' to update all, or 'shared-context-ai update <installPath>' to update one.`)})}var ot=require("path"),lr=require("fs"),Ho=require("child_process");oe();ue();se();var Bo={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function Uo(r){let e=r.slug||r.resourceId;return`${Bo[r.resourceType]||r.resourceType+"s"}/${e}`}function Wo(r){r.command("update [path]").description("Update installed resources (all or by install path)").action(async(e,t,n)=>{let s=n.optsWithGlobals();U()||(_()?D("update","AUTH_MISSING","Login required to update resources."):R("Login required to update resources. Run 'shared-context-ai login'."),process.exit(1));let o=De(s.agent);if(!o){let u=Ve();_()?D("update","NO_AGENTS",u):R(u),process.exit(1)}let a=await Z("/api/cli/updates");a.ok||(_()?D("update",a.error.code,a.error.message):R(`Failed to check updates: ${a.error.message}`),process.exit(1));let c=a.data.updates;if(e&&(c=c.filter(u=>Uo(u)===e||u.slug===e||u.resourceId===e),c.length===0)){_()?D("update","SKILL_NOT_FOUND",`No update available for "${e}".`):w(`No update available for "${e}".`);return}if(c.length===0){_()?N("update",{updated:[],count:0}):w("All resources are up to date.");return}let l=[];for(let u of c){let y=q().installations.find(E=>E.resourceId===u.resourceId&&E.agent===o.id),I;if(y?.installPath){let E=y.installPath.split("/");E[E.length-1]=u.slug||u.resourceId,I=E.join("/")}else I=Uo(u);if(y?.installMode==="plugin"&&u.resourceType==="collection"){try{let E=u.orgSlug||"",d=u.slug||u.resourceId,i=Vt(o.id),h=`/api/cli/resource/collections/${E}/${d}?format=plugin&platform=${i}`,S=await Wt(h,d),O=Bt(o.id);O&&(0,Ho.execSync)(`${O} plugin install "${S}"`,{stdio:"pipe"}),u.latestSha&&await L("/api/cli/update",{resourceId:u.resourceId,installedSha:u.latestSha}),le({...y,sha:u.latestSha,installedAt:new Date().toISOString()}),l.push({installPath:I,title:u.title}),_()||w(` Updated plugin: ${I}`)}catch(E){_()||R(` Plugin update failed for ${I}: ${E}`)}continue}let f=await Z(`/api/cli/resource/${I}`);if(!f.ok){_()||R(` Failed to fetch ${I}: ${f.error.message}`);continue}let p=f.data,C=I.split("/").slice(1);if(p.resource.resourceType==="agent"){let E=re(o,!!s.project),d=(0,ot.join)(E,...C);G(d,p.files)}else if(p.resource.resourceType==="mcp")qt(o,!!s.project,p);else{let E=W(o,!!s.project),d=(0,ot.join)(E,...C);G(d,p.files)}if(y&&y.installPath&&y.installPath!==I){let E=y.installPath.split("/").slice(1),d;p.resource.resourceType==="agent"?d=(0,ot.join)(re(o,!!s.project),...E):p.resource.resourceType!=="mcp"&&(d=(0,ot.join)(W(o,!!s.project),...E)),d&&(0,lr.existsSync)(d)&&((0,lr.rmSync)(d,{recursive:!0}),_()||w(` Removed old path: ${y.installPath}`))}let g=u.latestSha||p.resource.latestSha;if(g&&await L("/api/cli/update",{resourceId:u.resourceId,installedSha:g}),le({...y||{},resourceId:u.resourceId,slug:u.slug||u.resourceId,installPath:I,title:p.resource.title,sha:g||"",scope:y?.scope||(s.project?"project":"global"),agent:o.id,installedAt:new Date().toISOString(),latestSha:g||void 0,resourceType:u.resourceType||p.resource.resourceType,serverSynced:!0}),l.push({installPath:I,title:p.resource.title}),_()||w(` Updated ${I}`),p.resource.resourceType==="collection"&&p.memberResources&&y?.installMode!=="plugin"){let E=q(),d=new Set(E.installations.map(i=>i.resourceId));for(let i of p.memberResources){if(d.has(i.id))continue;let h=i.slug||i.id,S=Bo[i.resourceType]||i.resourceType+"s",O=u.orgSlug?`${u.orgSlug}/`:"",A=`${S}/${O}${h}`,b=await Z(`/api/cli/resource/${A}`);if(!b.ok){_()||R(` Failed to fetch new member ${A}: ${b.error.message}`);continue}let v=b.data,k=A.split("/").slice(1);if(v.resource.resourceType==="agent"){let T=re(o,!!s.project);G((0,ot.join)(T,...k),v.files)}else if(v.resource.resourceType==="mcp")qt(o,!!s.project,v);else{let T=W(o,!!s.project);G((0,ot.join)(T,...k),v.files)}i.latestSha&&await L("/api/cli/install",{resourceId:i.id,agentPlatform:o.platform,installedSha:i.latestSha}).catch(()=>{}),le({resourceId:i.id,slug:h,installPath:A,title:i.title,sha:i.latestSha||"",scope:s.project?"project":"global",agent:o.id,installedAt:new Date().toISOString(),collectionId:p.resource.id,resourceType:i.resourceType,serverSynced:!0}),_()||w(` + New member: ${A}`)}}}l.length>0&&He(),_()?N("update",{updated:l,count:l.length}):l.length>0&&w(`
|
|
154
|
+
${l.length} resource${l.length===1?"":"s"} updated.`)})}var ie=require("fs"),mt=require("path"),Vo=require("child_process");oe();ue();se();function qo(r){r.command("uninstall [path]").description("Uninstall a resource by install path (e.g., skills/acme/api-testing)").action(async(e,t,n)=>{if(!e){let p=q().installations;if(p.length===0&&(_()?D("uninstall","NOTHING_INSTALLED","No resources installed."):w("No resources installed."),process.exit(0)),_())N("uninstall",{installations:p.map(C=>({path:C.installPath||C.slug,title:C.title,agent:C.agent}))});else{w(`Installed resources:
|
|
155
|
+
`);let C=p.map(g=>[g.installPath||g.slug,g.title||"",`(${g.agent})`]);w(he(C)),w(`
|
|
156
|
+
Usage: shared-context-ai uninstall <path>`)}return}let s=n.optsWithGlobals(),o=De(s.agent);if(!o){let f=Ve();_()?D("uninstall","NO_AGENTS",f):R(f),process.exit(1)}let c=q().installations.find(f=>f.installPath===e||f.slug===e||f.resourceId===e),l=e.split("/"),m=["skills","files","commands","hooks","collections","agents","mcps"].includes(l[0])?l[0]:null,y=m?l.slice(1):l,I=!1;if(m==="collections")if(c?.installMode==="plugin"){let f=Bt(o.id);if(f)try{(0,Vo.execSync)(`${f} plugin uninstall "${c.slug}"`,{stdio:"pipe"}),_()||w(`Uninstalled native ${f} plugin: ${c.slug}`)}catch(p){_()||R(`Native uninstall failed: ${p}. Removing tracking only.`)}Et(c.resourceId,o.id),U()&&await L("/api/cli/uninstall",{resourceId:c.resourceId,agentPlatform:o.platform}).catch(()=>{}),He(),_()?N("uninstall",{path:e,removed:!0}):w(`Uninstalled "${e}"`);return}else{let f=Ne(o),p=y[y.length-1],C=s.project?"project":"user",g=await f.uninstall(p,C,o,c?.resourceId);if(I=g.removed,!_())for(let E of g.warnings)R(`Warning: ${E}`);if(c){let d=q().installations.filter(i=>i.collectionId===c.resourceId&&i.agent===o.id);for(let i of d){let h=i.installPath.split("/"),S=h[0],O=h.slice(1);if(S==="agents"){let A=re(o,!!s.project),b=(0,mt.join)(A,...O);(0,ie.existsSync)(b)&&(0,ie.rmSync)(b,{recursive:!0,force:!0})}else if(S==="mcps"){let A=O[O.length-1],b=pe(o,!!s.project);if((0,ie.existsSync)(b))try{let v=JSON.parse((0,ie.readFileSync)(b,"utf-8"));if(typeof v.mcpServers=="object"&&v.mcpServers&&!Array.isArray(v.mcpServers)){let k=v.mcpServers;A in k&&(delete k[A],v.mcpServers=k,(0,ie.writeFileSync)(b,JSON.stringify(v,null,2)+`
|
|
157
|
+
`,"utf-8"))}}catch{}}else if(S==="hooks")Yr(ve(o,!!s.project),i.installPath);else{let A=W(o,!!s.project),b=(0,mt.join)(A,...O);(0,ie.existsSync)(b)&&(0,ie.rmSync)(b,{recursive:!0,force:!0})}Et(i.resourceId,o.id)}}}else if(m==="agents"){let f=re(o,!!s.project),p=(0,mt.join)(f,...y);I=(0,ie.existsSync)(p),I&&(0,ie.rmSync)(p,{recursive:!0,force:!0})}else if(m==="mcps"){let f=y[y.length-1],p=pe(o,!!s.project);if((0,ie.existsSync)(p))try{let C=JSON.parse((0,ie.readFileSync)(p,"utf-8"));if(typeof C.mcpServers=="object"&&C.mcpServers&&!Array.isArray(C.mcpServers)){let g=C.mcpServers;f in g&&(delete g[f],C.mcpServers=g,(0,ie.writeFileSync)(p,JSON.stringify(C,null,2)+`
|
|
158
|
+
`,"utf-8"),I=!0)}}catch{}}else if(m==="hooks"){let f=ve(o,!!s.project);I=Yr(f,e),!I&&!_()&&R(`Note: No tagged hook entries found in ${f} \u2014 may need manual removal if installed before v0.1.10`)}else{let f=W(o,!!s.project),p=(0,mt.join)(f,...y);if(I=(0,ie.existsSync)(p),I&&(0,ie.rmSync)(p,{recursive:!0,force:!0}),!I&&c?.slug){let C=(0,mt.join)(f,c.slug);(0,ie.existsSync)(C)&&(0,ie.rmSync)(C,{recursive:!0,force:!0})}}if(U()&&c){let f=await L("/api/cli/uninstall",{resourceId:c.resourceId});!f.ok&&!_()&&R(`Warning: Could not record uninstall on server: ${f.error.message}`)}c&&Et(c.resourceId,o.id),He(),_()?N("uninstall",{path:e,removed:!0}):w(`Uninstalled "${e}"`)})}ue();oe();se();function Go(r){r.command("status").description("Show CLI status: auth, agents, installed resources, project sync state").action(async()=>{let e=Re(),t=xe(),n=q(),s=We(),o=Ce(),a=n.installations.filter(y=>!y.projectId),c=n.installations.filter(y=>y.projectId),l=new Map;for(let y of c){let I=y.projectId;l.has(I)||l.set(I,[]),l.get(I).push(y)}let u=[];if(U()&&l.size>0)for(let[y,I]of l){let f=await Z(`/api/cli/projects/${y}/resources`).catch(()=>null),p=f&&f.ok?f.data.resources.length:I.length,C=o?.projectId===y?o.projectName:`Project ${y.slice(0,8)}`;u.push({projectId:y,projectName:C,localCount:I.length,serverCount:p,synced:I.length>=p})}let m={authenticated:!!e?.token,email:e?.email||null,org:e?.orgSlug||null,apiBase:t.apiBase,detectedAgents:s.map(y=>y.id),installedCount:n.installations.length,globalCount:a.length,projects:u};if(_()){N("status",m);return}if(w("Shared Context CLI Status"),w("\u2500".repeat(40)),e?.token?w(` Auth: ${e.email} (${e.orgSlug})`):w(" Auth: Not logged in"),w(` API: ${t.apiBase}`),s.length>0?w(` Agents: ${s.map(y=>y.label).join(", ")}`):w(" Agents: None detected"),w(` Global: ${a.length} resource${a.length===1?"":"s"} installed`),u.length>0){w(""),w("Projects:");for(let y of u){let I=y.synced?"\u2713 synced":`\u26A0 ${y.serverCount-y.localCount} new`;w(` ${y.projectName}: ${y.localCount}/${y.serverCount} resources (${I})`)}}else o&&(w(""),w(` Project: ${o.projectName} (linked)`))})}ue();oe();se();function zo(r){r.command("logout").description("Clear saved credentials").option("--revoke","Also revoke the token on the server").action(async e=>{let t=Re();e.revoke&&U()&&await Ct("/api/cli/auth"),$r(),_()?N("logout",{email:t?.email||null}):w("Logged out.")})}var ur=require("fs"),Zo=require("path");oe();se();function Jo(r){r.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,n)=>{let s=n.optsWithGlobals(),o=t.github;if(o&&e&&(_()?D("import","INVALID_ARGS","Cannot use --github with a local path"):R("Error: Cannot use --github with a local path. Use one or the other."),process.exit(1)),!o&&!e&&(_()?D("import","INVALID_ARGS","Provide a local path or --github <url>"):R("Error: Provide a local path or --github <url>"),process.exit(1)),U()||(_()?D("import","AUTH_MISSING","Authentication required for import"):R("Error: Authentication required. Run 'shared-context-ai login' first."),process.exit(1)),o){t.onConflict&&t.onConflict!=="auto"&&(_()?D("import","INVALID_ARGS","--on-conflict is not supported with --github"):R("Error: --on-conflict is not supported with --github"),process.exit(1)),t.dryRun&&(_()?D("import","INVALID_ARGS","--dry-run is not supported with --github"):R("Error: --dry-run is not supported with --github"),process.exit(1));let p={url:o};t.resourceType&&(p.resourceType=t.resourceType),_()||w(`
|
|
159
|
+
Importing from GitHub: ${o}`);let C=await L("/api/cli/github-import",p);C.ok||(_()?D("import",C.error.code,C.error.message):R(`
|
|
160
|
+
Import failed: ${C.error.message}`),process.exit(1));let g=C.data;if(_()){N("import",g);return}w(""),w(` Source: ${g.source.owner}/${g.source.repo}`),w(` Type: ${g.resourceType}`),w(` Title: ${g.title}`),g.slug&&w(` Slug: ${g.slug}`),w(` URL: ${g.url}`),w(""),w("Import complete: 1 created");return}let a=(0,Zo.resolve)(e);(!(0,ur.existsSync)(a)||!(0,ur.statSync)(a).isDirectory())&&(_()?D("import","INVALID_PATH",`Not a directory: ${a}`):R(`Error: Not a directory: ${a}`),process.exit(1));let c=tr(a);if(c.resources.length===0){_()?N("import",{resources:[],message:"No resources found"}):w("No resources found in the specified directory.");return}if(!_()){let p=new Map;for(let g of c.resources)p.set(g.resourceType,(p.get(g.resourceType)||0)+1);let C=[...p.entries()].map(([g,E])=>`${E} ${g}${E===1?"":"s"}`).join(", ");w(`
|
|
161
|
+
Discovered ${c.resources.length} resources in ${e}:`),w(` ${C}`),c.formatLabel&&c.pluginName?w(` ${c.formatLabel}: ${c.pluginName}`):c.pluginName&&w(` Plugin: ${c.pluginName}`)}let l=t.tags?t.tags.split(",").map(p=>p.trim()).filter(Boolean):void 0,u={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};!_()&&!t.dryRun?w(`
|
|
162
|
+
Executing import...`):_()||w(`
|
|
163
|
+
Dry run \u2014 previewing changes...`);let m=await L("/api/cli/import",u,12e4);m.ok||(_()?D("import",m.error.code,m.error.message):R(`
|
|
164
|
+
Import failed: ${m.error.message}`),process.exit(1));let y=m.data;if(_()){N("import",y);return}let I=[...y.created.map(p=>({...p,action:"created"})),...y.updated.map(p=>({...p,action:"updated"})),...y.installed.map(p=>({...p,action:"installed"})),...y.cloned.map(p=>({...p,action:"cloned"})),...y.skipped.map(p=>({...p,action:"skipped"})),...y.errors.map(p=>({...p,action:"error"}))];if(I.length>0){w("");let p=I.length,C=I.map((g,E)=>{let d=`[${String(E+1).padStart(String(p).length)}/${p}]`,i=(g.resourceType||"").padEnd(10),h=(g.importPath.split("/").pop()||"").padEnd(24),S="";switch(g.action){case"created":S=`\u2713 created${g.slug?` (slug: ${g.slug})`:""}`;break;case"updated":S="\u2713 updated";break;case"installed":{let O=g.versionsBehind;S=`\u2713 installed${O?` (${O} versions behind)`:""}`;break}case"cloned":S=`\u2713 cloned${g.slug?` (slug: ${g.slug})`:""}`;break;case"skipped":S=`\u2713 skipped (${g.reason||"up to date"})`;break;case"error":S=`\u2717 error: ${g.error||"unknown"}`;break}return` ${d} ${i} ${h} ${S}`});for(let g of C)w(g)}if(y.collections.length>0)for(let p of y.collections){let C=p.importPath.split("/").pop()||p.importPath;w(` collection ${C.padEnd(20)} \u2713 ${p.membersLinked} members linked${p.membersFailed>0?`, ${p.membersFailed} failed`:""}`)}w("");let f=[y.created.length>0?`${y.created.length} created`:null,y.installed.length>0?`${y.installed.length} installed`:null,y.cloned.length>0?`${y.cloned.length} cloned`:null,y.updated.length>0?`${y.updated.length} updated`:null,y.skipped.length>0?`${y.skipped.length} skipped`:null,y.errors.length>0?`${y.errors.length} errors`:null].filter(Boolean);t.dryRun?w(`Dry run complete: ${f.join(", ")}`):w(`Import complete: ${f.join(", ")}`),y.errors.length>0&&process.exit(1)})}var kn=require("path"),ri=require("os");oe();ue();se();var sc={skill:"skills",file:"files",command:"commands",hook:"hooks",collection:"collections",agent:"agents",mcp:"mcps"};function ei(r,e){let t=r.installations.findIndex(n=>n.resourceId===e.resourceId&&n.agent===e.agent);t>=0?r.installations[t]=e:r.installations.push(e)}function ti(r){let e=r.slug||r.resourceId,t=sc[r.resourceType]||r.resourceType+"s";return r.storageType==="github"&&r.githubOwner?`${t}/external/${r.githubOwner}/${e}`:r.orgSlug?`${t}/${r.orgSlug}/${e}`:`${t}/${e}`}function ni(r){r.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("--no-import","Skip auto-importing untracked resources").action(async(e,t)=>{let n={...e,...t.optsWithGlobals()};if(!n.force&&!Lr()){let x=q(),P=x.installations.filter(M=>M.latestSha&&M.sha&&M.latestSha!==M.sha),F=x.lastSyncAt?Math.floor((Date.now()-new Date(x.lastSyncAt).getTime())/6e4):void 0,$={updatesAvailable:P.length,untrackedResources:0,driftRepairs:0,autoInstalled:0,autoInstallFailures:0,updates:P.map(M=>({installPath:M.installPath,title:M.title,sha:M.sha,latestSha:M.latestSha})),untracked:[],summary:On(P.length,0)+(F!==void 0?` (cached ${F}m ago, run --force to refresh)`:""),throttled:!0,cacheAge:F};vn($,!!n.quiet);return}U()||(_()?D("sync","AUTH_MISSING","Login required to sync."):R("Login required. Run 'shared-context-ai login'."),process.exit(1));let s=De(n.agent),o=await Z("/api/cli/installed");if(!o.ok){let P=q().installations.filter($=>$.latestSha&&$.sha&&$.latestSha!==$.sha);!_()&&!n.quiet&&R(`Warning: Could not reach server (${o.error.message}). Showing cached state.`);let F={updatesAvailable:P.length,untrackedResources:0,driftRepairs:0,autoInstalled:0,autoInstallFailures:0,updates:P.map($=>({installPath:$.installPath,title:$.title,sha:$.sha,latestSha:$.latestSha})),untracked:[],summary:On(P.length,0)+" (offline)",throttled:!1};vn(F,!!n.quiet);return}let a=o.data.installations,c=new Map(a.map(x=>[x.resourceId,x])),l=q(),u=0;for(let x of l.installations){let P=c.get(x.resourceId);if(P)x.latestSha=P.latestSha||void 0,x.resourceType=x.resourceType||P.resourceType,x.serverSynced=!0,P.installedSha&&x.sha&&P.installedSha!==x.sha&&(!_()&&!n.quiet&&w(` Drift repaired: ${x.installPath} (local=${x.sha.slice(0,7)} \u2192 server=${P.installedSha.slice(0,7)})`),x.sha=P.installedSha,u++),c.delete(x.resourceId);else if(x.serverSynced!==!1){let F=await L("/api/cli/install",{resourceId:x.resourceId,agentPlatform:s?.platform||"claude_code",installedSha:x.sha});F.ok?x.serverSynced=!0:(F.error.code==="NOT_FOUND"||F.error.code==="RESOURCE_NOT_FOUND")&&(x.serverSynced=!1,x.resourceId="",u++)}}l.installations=l.installations.filter(x=>x.resourceId!=="");let m=Array.from(c.values()),y=0,I=0,f=!1;if(m.length>0&&s){for(let x of m){if(f){I++;continue}let P=ti(x);try{let F=await Z(`/api/cli/resource/${P}`);if(!F.ok){if(I++,F.error.code==="RATE_LIMITED"||F.error.code==="429"){f=!0,!_()&&!n.quiet&&R(` Auto-install rate-limited after ${y} resource(s). Remaining will retry on next sync.`);continue}!_()&&!n.quiet&&R(` Auto-install skipped: ${P} \u2014 ${F.error.message}`);continue}let $=F.data,M=await Kr($,s,{project:!1,manifest:l,authed:!0});for(let ne of M.warnings)!_()&&!n.quiet&&R(` Warning: ${ne}`);for(let ne of M.notes)!_()&&!n.quiet&&w(` ${ne}`);let Se=$.resource.resourceType==="collection",z={resourceId:$.resource.id,slug:M.slug,installPath:M.installPath,title:$.resource.title,sha:$.resource.latestSha||x.installedSha||"",scope:"global",agent:s.id,installedAt:new Date().toISOString(),latestSha:$.resource.latestSha||void 0,resourceType:$.resource.resourceType,serverSynced:!0,...Se?{pluginFormat:Ht(s.id),memberCount:$.memberResources?.length,installMode:M.installMode,pluginDir:M.pluginDir}:{}};if(ei(l,z),Se&&$.memberResources&&M.installMode==="decomposed")for(let ne of $.memberResources)ei(l,Jr(ne,$.resource,s.id));y++}catch(F){I++,!_()&&!n.quiet&&R(` Auto-install failed: ${P} \u2014 ${F}`)}}y>0&&!_()&&!n.quiet&&w(`
|
|
165
|
+
Auto-installed ${y} resource${y===1?"":"s"} from web dashboard`)}else if(m.length>0&&!_()&&!n.quiet){w(`
|
|
166
|
+
${m.length} resource${m.length===1?"":"s"} installed elsewhere (use --agent to auto-install):`);for(let x of m.slice(0,5))w(` ${ti(x)} \u2014 ${x.title}`);m.length>5&&w(` ...and ${m.length-5} more`)}Ue(l);let p=s?[s]:We();p.length===0&&!_()&&!n.quiet&&R("No AI agents detected \u2014 resource discovery skipped. Use --agent to specify one.");let C=p.map(x=>({root:n.project?(0,kn.join)(process.cwd(),x.dir):(0,kn.join)((0,ri.homedir)(),x.dir),agent:x,isProject:!!n.project})),g={imported:[],errors:0,projectRegistered:0,untrackedCount:0,discoveredPaths:[],untracked:[]};if(C.length>0){if(g=await rr({scanRoots:C,agentId:s?.id||p[0]?.id||"unknown",registerToProject:!!n.project,skipImport:n.import===!1}),g.imported.length>0&&!_()&&!n.quiet){w(`
|
|
167
|
+
Imported ${g.imported.length} resource${g.imported.length===1?"":"s"}:`);let x=g.imported.map(P=>[` ${(P.resourceType||"").padEnd(12)}`,(P.slug||P.importPath.split("/").pop()||"").padEnd(24),P.importPath]);w(he(x))}if(g.errors>0&&!_()&&R(`
|
|
168
|
+
${g.errors} import error(s)`),g.projectRegistered>0&&!_()&&!n.quiet){let x=Ce();w(`
|
|
169
|
+
Project "${x?.projectName}": registered ${g.projectRegistered} resource${g.projectRegistered===1?"":"s"}`)}}let E=g.untrackedCount,d=Ce(),i=0;if(d){let x=await Z(`/api/cli/projects/${d.projectId}/resources`);if(!x.ok)!_()&&!n.quiet&&(R(`Warning: Project "${d.projectName}" not found on server (may have been deleted).`),R(" Remove .shared-context/project.json to unlink this directory."));else{let P=x.data.project;P&&(P.name!==d.projectName||P.slug!==d.projectSlug)&&Qe({projectId:d.projectId,projectName:P.name,projectSlug:P.slug});let F=x.data.resources,$=l.installations.filter(z=>z.projectId===d.projectId),M=new Set($.map(z=>z.resourceId)),Se=F.filter(z=>!M.has(z.id));if(Se.length>0)if(!s)!_()&&!n.quiet&&R(`
|
|
170
|
+
Project "${d.projectName}" has ${Se.length} new resource${Se.length===1?"":"s"} \u2014 use --agent to install them.`);else{let z=Ne(s);for(let ne of Se){let Ie=ne.installPath;try{let $e=await Z(`/api/cli/resource/${Ie}`);if(!$e.ok)continue;await z.install($e.data,"project",s),le({resourceId:ne.id,slug:ne.slug||ne.id,installPath:Ie,title:ne.title,sha:ne.latestSha||"",scope:"project",agent:s.id,installedAt:new Date().toISOString(),projectId:d.projectId,resourceType:ne.resourceType,serverSynced:!0}),ne.latestSha&&await L("/api/cli/install",{resourceId:ne.id,agentPlatform:s.platform,installedSha:ne.latestSha}).catch(()=>{}),i++}catch{}}!_()&&!n.quiet&&i>0&&w(`
|
|
171
|
+
Project "${d.projectName}": installed ${i} new resource${i===1?"":"s"}`)}if(n.project){let z=new Set(F.map($e=>$e.id)),ne=new Set(g.discoveredPaths),Ie=0;for(let $e of l.installations){if(z.has($e.resourceId)||!ne.has($e.installPath))continue;(await L(`/api/cli/projects/${d.projectId}/resources`,{resourceId:$e.resourceId})).ok&&($e.projectId=d.projectId,Ie++)}Ie>0&&!_()&&!n.quiet&&w(`
|
|
172
|
+
Project "${d.projectName}": registered ${Ie} existing resource${Ie===1?"":"s"}`)}await L(`/api/cli/projects/${d.projectId}/sync`,{localPath:process.cwd()}).catch(()=>{})}}let h=g.imported.length,S=q(),O=new Set(S.installations.map(x=>`${x.resourceId}:${x.agent}`)),A=[...S.installations,...l.installations.filter(x=>!O.has(`${x.resourceId}:${x.agent}`))];if(l.installations=A,n.force){let x=l.lastSyncAt;l.lastSyncAt=x||new Date().toISOString()}else I===0&&(l.lastSyncAt=new Date().toISOString());Ue(l);let b=l.installations.filter(x=>x.latestSha&&x.sha&&x.latestSha!==x.sha),v=Re();v?.connectionId&&L("/api/cli/sync-report",{connectionId:v.connectionId,lastSyncResult:{updatesAvailable:b.length,importedCount:h}}).catch(()=>{});try{let{pushTelemetry:x}=await Promise.resolve().then(()=>(xn(),Qo));await x(!0)}catch{}let k=g.untracked,T={updatesAvailable:b.length,untrackedResources:k.length,driftRepairs:u,autoInstalled:y,autoInstallFailures:I,updates:b.map(x=>({installPath:x.installPath,title:x.title,sha:x.sha,latestSha:x.latestSha})),untracked:k,summary:On(b.length,k.length,u,y,I),throttled:!1};vn(T,!!n.quiet)})}function On(r,e,t=0,n=0,s=0){let o=[];return n>0&&o.push(`${n} auto-installed`),r>0&&o.push(`${r} update${r===1?"":"s"} available`),e>0&&o.push(`${e} untracked resource${e===1?"":"s"}`),t>0&&o.push(`${t} drift repair${t===1?"":"s"}`),s>0&&o.push(`${s} auto-install failure${s===1?"":"s"}`),o.length===0?"Everything is up to date.":o.join(", ")}function vn(r,e){if(_()){N("sync",r);return}if(e){let t=r.summary;r.updatesAvailable>0&&(t+=" \u2014 run 'shared-context-ai update'"),r.untrackedResources>0&&(t+=` \u2014 ${r.untrackedResources} untracked`),w(t);return}if(w(""),r.updates.length>0){w(`${r.updates.length} update${r.updates.length===1?"":"s"} available:
|
|
173
|
+
`);let t=r.updates.map(n=>[` ${n.installPath}`,n.title,`${n.sha.slice(0,7)} \u2192 ${n.latestSha.slice(0,7)}`]);w(he(t)),w("")}if(r.untracked.length>0){w(`${r.untracked.length} untracked resource${r.untracked.length===1?"":"s"}:
|
|
174
|
+
`);let t=r.untracked.map(n=>[` ${n.resourceType.padEnd(12)}`,n.importPath.padEnd(30),n.title]);w(he(t)),w("")}r.updatesAvailable===0&&r.untrackedResources===0?w("Everything is up to date."):(r.updatesAvailable>0&&w("Run 'shared-context-ai update' to update installed resources."),r.untrackedResources>0&&w("Run 'shared-context-ai sync --force' to re-sync and import untracked resources.")),w("")}var si=require("path"),oi=require("readline");oe();oe();se();function ii(r){let e=r.command("project").description("Manage projects");e.command("create").description("Create a project for the current folder").argument("[name]","Project name (defaults to folder name)").action(async t=>{if(!U()){let u="Not authenticated. Run 'shared-context-ai login' first.";_()?D("project create","AUTH_MISSING",u):R(u),process.exit(1)}let n=Ce();if(n){_()?N("project create",{alreadyExists:!0,project:{id:n.projectId,name:n.projectName,slug:n.projectSlug}}):w(`Project already linked: ${n.projectName}`);return}let s=t?.trim()||(0,si.basename)(process.cwd());if(!s||s==="/"){let u='Could not determine project name. Provide one: shared-context-ai project create "My Project"';_()?D("project create","INVALID_NAME",u):R(u),process.exit(1)}let o=await L("/api/cli/projects",{name:s});o.ok||(_()?D("project create",o.error.code,o.error.message):R(`Failed to create project: ${o.error.message}`),process.exit(1));let{id:a,name:c,slug:l}=o.data;Qe({projectId:a,projectName:c,projectSlug:l}),_()?N("project create",{id:a,name:c,slug:l}):(w(`Created project: ${c}`),w(""),w("Quick reference:"),w(" shared-context-ai install <installPath> Add a resource to this project"),w(" shared-context-ai sync Check for resource updates"),w(" shared-context-ai status View project sync status"))}),e.command("delete").description("Delete the project linked to the current folder").option("--id <projectId>","Project ID to delete (overrides local config)").option("--force","Skip confirmation prompt").action(async t=>{if(!U()){let c="Not authenticated. Run 'shared-context-ai login' first.";_()?D("project delete","AUTH_MISSING",c):R(c),process.exit(1)}let n=Ce(),s=t.id||n?.projectId,o=n?.projectName||s;if(!s){let c="No project linked to this folder. Use --id <projectId> to specify one.";_()?D("project delete","NO_PROJECT",c):R(c),process.exit(1)}if(!t.force&&!_()&&process.stdin.isTTY&&!await new Promise(l=>{let u=(0,oi.createInterface)({input:process.stdin,output:process.stdout});u.question(`Delete project "${o}"? This cannot be undone. [y/N] `,m=>{u.close(),l(m.trim().toLowerCase()==="y"||m.trim().toLowerCase()==="yes")})})){w("Cancelled.");return}let a=await Ct(`/api/cli/projects/${s}`);a.ok||(_()?D("project delete",a.error.code,a.error.message):R(`Failed to delete project: ${a.error.message}`),process.exit(1)),n?.projectId===s&&Ms(),_()?N("project delete",{deleted:!0,projectId:s}):w(`Deleted project: ${a.data.name}`)})}xn();var dr=require("fs"),fr=require("path"),Rn=require("os");se();function oc(){let r=process.env.SC_PROFILE;return r?(0,fr.join)((0,Rn.homedir)(),".config","shared-context","profiles",r):(0,fr.join)((0,Rn.homedir)(),".config","shared-context")}function ic(){let r=(0,fr.join)(oc(),"usage.jsonl");if(!(0,dr.existsSync)(r))return[];try{let e=(0,dr.readFileSync)(r,"utf8").trim().split(`
|
|
175
|
+
`).filter(Boolean),t=[];for(let n of e)try{let s=JSON.parse(n);s.v&&s.ts&&s.event&&s.rid&&t.push(s)}catch{}return t}catch{return[]}}function ai(r){r.command("stats").description("Show local usage statistics").option("--days <n>","Number of days to show","7").action(e=>{let t=parseInt(e.days,10)||7,n=new Date;n.setDate(n.getDate()-t);let o=ic().filter(l=>new Date(l.ts)>=n);if(o.length===0){_()?N("stats",{days:t,events:0,skills:[],agents:[]}):w("No usage data yet");return}let a=new Map,c=new Map;for(let l of o)if(l.event==="skill_invoked"){let u=a.get(l.slug)||{count:0,ok:0};u.count++,l.ok&&u.ok++,a.set(l.slug,u)}else if(l.event==="agent_invoked"){let u=c.get(l.slug)||{count:0,ok:0,totalMs:0,totalTokens:0};u.count++,l.ok&&u.ok++,l.dur_ms&&(u.totalMs+=l.dur_ms),l.tokens&&(u.totalTokens+=l.tokens),c.set(l.slug,u)}if(_()){N("stats",{days:t,events:o.length,skills:[...a.entries()].map(([l,u])=>({slug:l,...u})),agents:[...c.entries()].map(([l,u])=>({slug:l,...u,avgMs:u.count>0?Math.round(u.totalMs/u.count):0,avgTokens:u.count>0?Math.round(u.totalTokens/u.count):0}))});return}if(w(`Usage over the last ${t} day${t===1?"":"s"} (${o.length} event${o.length===1?"":"s"})
|
|
176
|
+
`),a.size>0){w("Skills:");let l=[...a.entries()].sort((u,m)=>m[1].count-u[1].count).map(([u,m])=>[` ${u}`,`${m.count} use${m.count===1?"":"s"}`,`${Math.round(m.ok/m.count*100)}% ok`]);w(he(l))}if(c.size>0){a.size>0&&w(""),w("Agents:");let l=[...c.entries()].sort((u,m)=>m[1].count-u[1].count).map(([u,m])=>{let y=m.count>0?Math.round(m.totalMs/m.count):0;return[` ${u}`,`${m.count} use${m.count===1?"":"s"}`,`${Math.round(m.ok/m.count*100)}% ok`,y>0?`avg ${(y/1e3).toFixed(1)}s`:""]});w(he(l))}})}var Ot=require("fs"),vt=require("path"),pr=require("os");ue();se();function ac(){let r=process.env.SC_PROFILE;return r?(0,vt.join)((0,pr.homedir)(),".config","shared-context","profiles",r):(0,vt.join)((0,pr.homedir)(),".config","shared-context")}var cc=new Set(["hooks/shared-context/telemetry","platform/telemetry-push"]);function lc(){jt({telemetry:!1});let r=(0,vt.join)(ac(),"usage.jsonl");try{(0,Ot.existsSync)(r)&&(0,Ot.unlinkSync)(r)}catch{}try{let e=(0,vt.join)((0,pr.homedir)(),".claude","settings.json");if((0,Ot.existsSync)(e)){let{readFileSync:t,writeFileSync:n}=require("fs"),s=JSON.parse(t(e,"utf8"));if(s.hooks){let o=!1;for(let[a,c]of Object.entries(s.hooks))if(Array.isArray(c)){let l=c.filter(u=>!cc.has(u._sc));l.length!==c.length&&(s.hooks[a]=l,o=!0)}for(let[a,c]of Object.entries(s.hooks))Array.isArray(c)&&c.length===0&&delete s.hooks[a];o&&n(e,JSON.stringify(s,null,2)+`
|
|
177
|
+
`,"utf8")}}}catch{}}function ci(r){let e=r.command("config").description("Manage CLI configuration");e.command("set <key> <value>").description("Set a configuration value (e.g., telemetry on/off)").action((t,n)=>{if(t==="telemetry"){let s=n==="on"||n==="true"||n==="1",o=n==="off"||n==="false"||n==="0";if(!s&&!o){_()?D("config","INVALID_VALUE","Telemetry value must be on or off"):R("Usage: shared-context-ai config set telemetry on|off");return}o?(lc(),_()?N("config",{key:"telemetry",value:!1}):w("Telemetry disabled. Usage data and hooks removed.")):(jt({telemetry:!0}),_()?N("config",{key:"telemetry",value:!0}):w("Telemetry enabled. Run `shared-context-ai sync` to install the telemetry hook if it is not already installed."));return}_()?D("config","UNKNOWN_KEY",`Unknown config key: ${t}`):R(`Unknown config key: ${t}. Available: telemetry`)}),e.command("get [key]").description("Show configuration values").action(t=>{let n=xe();if(t==="telemetry"){let s=n.telemetry??!1;_()?N("config",{key:"telemetry",value:s}):w(`telemetry: ${s?"on":"off"}`);return}if(t){_()?D("config","UNKNOWN_KEY",`Unknown config key: ${t}`):R(`Unknown config key: ${t}`);return}_()?N("config",{telemetry:n.telemetry??!1}):w(`telemetry: ${n.telemetry?"on":"off"}`)})}var li={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."},mr=class extends Error{constructor(t,n){super(n||li[t]);this.code=t;this.name="CliError"}get recovery(){return li[this.code]}};se();var ce=new Vn;ce.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",r=>{let e=r.opts();zn(!!e.json,!!e.human)});Qs(ce);jo(ce);No(ce);Vs(ce);Fo(ce);Lo(ce);Mo(ce);Wo(ce);qo(ce);Go(ce);zo(ce);Jo(ce);ni(ce);ii(ce);An(ce);ai(ce);ci(ce);process.on("uncaughtException",r=>{r instanceof mr?_()?D(process.argv[2]||"unknown",r.code,r.message):(R(`Error: ${r.message}`),R(r.recovery)):_()?D(process.argv[2]||"unknown","UNEXPECTED",r.message||"Unexpected error"):R(`Error: ${r.message||r}`),process.exit(1)});ce.parse();
|