forge-terminal 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +35 -7
  2. package/dist/chunks/available-HEUREG6L.js +3 -0
  3. package/dist/chunks/{boot-ODZZHFUI.js → boot-BUGERSEB.js} +1 -1
  4. package/dist/chunks/catalog-NTACQH5V.js +3 -0
  5. package/dist/chunks/chunk-4YCO7S4K.js +3 -0
  6. package/dist/chunks/chunk-5B7WODWH.js +3 -0
  7. package/dist/chunks/chunk-C2WYXNRM.js +4 -0
  8. package/dist/chunks/chunk-C7OOWUMU.js +3 -0
  9. package/dist/chunks/chunk-G2D6BKOS.js +4 -0
  10. package/dist/chunks/{chunk-7YQR2MVH.js → chunk-HUAEVW2A.js} +1 -1
  11. package/dist/chunks/chunk-L76Q54MB.js +3 -0
  12. package/dist/chunks/chunk-PD5DFBCU.js +3 -0
  13. package/dist/chunks/{chunk-VB665HTV.js → chunk-PN73WK2S.js} +1 -1
  14. package/dist/chunks/chunk-TEGB7JRM.js +3 -0
  15. package/dist/chunks/{chunk-MHFY7HF6.js → chunk-VH5RWPGZ.js} +1 -1
  16. package/dist/chunks/{chunk-YHK5VE5R.js → chunk-XFEHJ4C7.js} +1 -1
  17. package/dist/chunks/chunk-YXDEOLNA.js +3 -0
  18. package/dist/chunks/colour-DE6N6AZO.js +3 -0
  19. package/dist/chunks/{config-command-UXJY623L.js → config-command-SQXRTBRO.js} +1 -1
  20. package/dist/chunks/execute-M3C3TTWB.js +3 -0
  21. package/dist/chunks/{extensions-command-6WZV2AES.js → extensions-command-HJDBUBYO.js} +1 -1
  22. package/dist/chunks/image-GYUUMS6H.js +3 -0
  23. package/dist/chunks/launch-WBUFRVQ7.js +65 -0
  24. package/dist/chunks/lock-XD4L3WFM.js +3 -0
  25. package/dist/chunks/manager-KBJTXZ27.js +4 -0
  26. package/dist/chunks/paths-JUM6GKQU.js +3 -0
  27. package/dist/chunks/run-RXVQD4DZ.js +4 -0
  28. package/dist/chunks/{server-5RWSVTOM.js → server-DU7QWDAH.js} +14 -14
  29. package/dist/chunks/theme-DESCJOCE.js +3 -0
  30. package/dist/index.js +29 -29
  31. package/package.json +2 -2
  32. package/skills/forge/SKILL.md +26 -5
  33. package/dist/chunks/available-2VX7K7W6.js +0 -3
  34. package/dist/chunks/chunk-4YHKTP7I.js +0 -3
  35. package/dist/chunks/chunk-5PYTOHLZ.js +0 -3
  36. package/dist/chunks/chunk-DRBA23IQ.js +0 -3
  37. package/dist/chunks/chunk-FQV57RMH.js +0 -3
  38. package/dist/chunks/chunk-IMKI5F4I.js +0 -4
  39. package/dist/chunks/chunk-L2WK7CJG.js +0 -3
  40. package/dist/chunks/chunk-V4GHQGQM.js +0 -4
  41. package/dist/chunks/colour-QV2C3R7R.js +0 -3
  42. package/dist/chunks/execute-4WJCUM7J.js +0 -3
  43. package/dist/chunks/launch-2OI4ZLBQ.js +0 -66
  44. package/dist/chunks/lock-R6GZXCCW.js +0 -3
  45. package/dist/chunks/manager-H52ENJOH.js +0 -4
  46. package/dist/chunks/paths-XY2345OS.js +0 -3
  47. package/dist/chunks/run-N3F4EM7E.js +0 -4
  48. package/dist/chunks/theme-GW7CQPUO.js +0 -3
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t}from"./chunk-G2D6BKOS.js";import"./chunk-TMUK2DD3.js";export{r as BAR,c as DARK,d as LIGHT,g as MODE_KEYS,i as MODE_MARKERS,f as MODE_ORDER,e as NEUTRAL,b as SYMBOLS,a as VERSION,t as applyColourPreference,s as colourEnabled,q as colourProp,n as commandsPalette,m as dotGradient,j as modeColours,h as modeForKey,k as modeGradient,o as modePalette,l as modeWash,p as paletteFor};
package/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __forgeCreateRequire } from 'node:module';
3
3
  const require = __forgeCreateRequire(import.meta.url);
4
- import{d as F}from"./chunks/chunk-VB665HTV.js";import{b as z,d as J}from"./chunks/chunk-2WYHI73Y.js";import{a as q}from"./chunks/chunk-QVACE4IE.js";import{a as U}from"./chunks/chunk-FQV57RMH.js";import{a as v}from"./chunks/chunk-V4GHQGQM.js";import{a as N}from"./chunks/chunk-7YQR2MVH.js";import"./chunks/chunk-EOYBXOCV.js";import{F as d,I,S as R,T as S,b as B,d as k}from"./chunks/chunk-DRBA23IQ.js";import{d as L}from"./chunks/chunk-J7FLFHQJ.js";import"./chunks/chunk-TMUK2DD3.js";import*as se from"node:module";var b=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}},C=class extends b{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var E=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.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}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 C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function T(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}import{EventEmitter as he}from"node:events";import j from"node:child_process";import O from"node:path";import V from"node:fs";import m from"node:process";import{stripVTControlCharacters as ce}from"node:util";import{stripVTControlCharacters as ae}from"node:util";var $=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(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!i&&!s?t.push(n):n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!i&&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 i=n.options.filter(s=>!s.hidden);t.push(...i)}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=>T(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,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(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){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return 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}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(s=>{let r=n(s);i.has(r)||i.set(r,[])}),t.forEach(s=>{let r=n(s);i.has(r)||i.set(r,[]),i.get(r).push(s)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function s(u,c){return t.formatItem(u,n,c,t)}let r=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],a=t.commandDescription(e);a.length>0&&(r=r.concat([t.boxWrap(t.styleCommandDescription(a),i),""]));let h=t.visibleArguments(e).map(u=>s(t.styleArgumentTerm(t.argumentTerm(u)),t.styleArgumentDescription(t.argumentDescription(u))));if(r=r.concat(this.formatItemList("Arguments:",h,t)),this.groupItems(e.options,t.visibleOptions(e),u=>u.helpGroupHeading??"Options:").forEach((u,c)=>{let g=u.map(f=>s(t.styleOptionTerm(t.optionTerm(f)),t.styleOptionDescription(t.optionDescription(f))));r=r.concat(this.formatItemList(c,g,t))}),t.showGlobalOptions){let u=t.visibleGlobalOptions(e).map(c=>s(t.styleOptionTerm(t.optionTerm(c)),t.styleOptionDescription(t.optionDescription(c))));r=r.concat(this.formatItemList("Global Options:",u,t))}return this.groupItems(e.commands,t.visibleCommands(e),u=>u.helpGroup()||"Commands:").forEach((u,c)=>{let g=u.map(f=>s(t.styleSubcommandTerm(t.subcommandTerm(f)),t.styleSubcommandDescription(t.subcommandDescription(f))));r=r.concat(this.formatItemList(c,g,t))}),r.join(`
5
- `)}displayWidth(e){return ae(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,i){let r=" ".repeat(2);if(!n)return r+e;let a=e.padEnd(t+e.length-i.displayWidth(e)),h=2,l=(this.helpWidth??80)-t-h-2,u;return l<this.minWidthToWrap||i.preformatted(n)?u=n:u=i.boxWrap(n,l).replace(/\n/g,`
4
+ import{d as W}from"./chunks/chunk-PN73WK2S.js";import{b as Y,d as X}from"./chunks/chunk-2WYHI73Y.js";import{a as R}from"./chunks/chunk-QVACE4IE.js";import{h as j}from"./chunks/chunk-5B7WODWH.js";import"./chunks/chunk-L76Q54MB.js";import{a as $}from"./chunks/chunk-G2D6BKOS.js";import{a as D}from"./chunks/chunk-HUAEVW2A.js";import"./chunks/chunk-EOYBXOCV.js";import{a as K}from"./chunks/chunk-YXDEOLNA.js";import{I as d,L as P,Z as J,_ as T,e as L,g as E}from"./chunks/chunk-PD5DFBCU.js";import{d as U}from"./chunks/chunk-J7FLFHQJ.js";import"./chunks/chunk-TMUK2DD3.js";import*as ae from"node:module";var w=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}},C=class extends w{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var k=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.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}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 C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function H(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as de}from"node:events";import B from"node:child_process";import O from"node:path";import I from"node:fs";import g from"node:process";import{stripVTControlCharacters as fe}from"node:util";import{stripVTControlCharacters as he}from"node:util";var S=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(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,o)=>i.name().localeCompare(o.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),o=n.long&&e._findOption(n.long);!i&&!o?t.push(n):n.long&&!o?t.push(e.createOption(n.long,n.description)):n.short&&!i&&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 i=n.options.filter(o=>!o.hidden);t.push(...i)}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=>H(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,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(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){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return 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}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(o=>{let r=n(o);i.has(r)||i.set(r,[])}),t.forEach(o=>{let r=n(o);i.has(r)||i.set(r,[]),i.get(r).push(o)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function o(u,p){return t.formatItem(u,n,p,t)}let r=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],a=t.commandDescription(e);a.length>0&&(r=r.concat([t.boxWrap(t.styleCommandDescription(a),i),""]));let h=t.visibleArguments(e).map(u=>o(t.styleArgumentTerm(t.argumentTerm(u)),t.styleArgumentDescription(t.argumentDescription(u))));if(r=r.concat(this.formatItemList("Arguments:",h,t)),this.groupItems(e.options,t.visibleOptions(e),u=>u.helpGroupHeading??"Options:").forEach((u,p)=>{let f=u.map(m=>o(t.styleOptionTerm(t.optionTerm(m)),t.styleOptionDescription(t.optionDescription(m))));r=r.concat(this.formatItemList(p,f,t))}),t.showGlobalOptions){let u=t.visibleGlobalOptions(e).map(p=>o(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));r=r.concat(this.formatItemList("Global Options:",u,t))}return this.groupItems(e.commands,t.visibleCommands(e),u=>u.helpGroup()||"Commands:").forEach((u,p)=>{let f=u.map(m=>o(t.styleSubcommandTerm(t.subcommandTerm(m)),t.styleSubcommandDescription(t.subcommandDescription(m))));r=r.concat(this.formatItemList(p,f,t))}),r.join(`
5
+ `)}displayWidth(e){return he(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,i){let r=" ".repeat(2);if(!n)return r+e;let a=e.padEnd(t+e.length-i.displayWidth(e)),h=2,l=(this.helpWidth??80)-t-h-2,u;return l<this.minWidthToWrap||i.preformatted(n)?u=n:u=i.boxWrap(n,l).replace(/\n/g,`
6
6
  `+" ".repeat(t+h)),r+a+" ".repeat(h)+u.replace(/\n/g,`
7
- ${r}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return n.forEach(r=>{let a=r.match(i);if(a===null){s.push("");return}let h=[a.shift()],p=this.displayWidth(h[0]);a.forEach(l=>{let u=this.displayWidth(l);if(p+u<=t){h.push(l),p+=u;return}s.push(h.join(""));let c=l.trimStart();h=[c],p=this.displayWidth(c)}),s.push(h.join(""))}),s.join(`
8
- `)}};var w=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=ue(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,this.helpGroupHeading=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}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?K(this.name().replace(/^no-/,"")):K(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},H=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 i=this.negativeOptions.get(n).presetArg,s=i!==void 0?i:!1;return t.negate===(s===e)}};function K(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ue(o){let e,t,n=/^-[^-]$/,i=/^--[^-]/,s=o.split(/[ |,]+/).concat("guard");if(n.test(s[0])&&(e=s.shift()),i.test(s[0])&&(t=s.shift()),!e&&n.test(s[0])&&(e=s.shift()),!e&&i.test(s[0])&&(e=t,t=s.shift()),s[0].startsWith("-")){let r=s[0],a=`option creation failed due to '${r}' in option flags '${o}'`;throw/^-[^-][^-]/.test(r)?new Error(`${a}
7
+ ${r}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,o=[];return n.forEach(r=>{let a=r.match(i);if(a===null){o.push("");return}let h=[a.shift()],c=this.displayWidth(h[0]);a.forEach(l=>{let u=this.displayWidth(l);if(c+u<=t){h.push(l),c+=u;return}o.push(h.join(""));let p=l.trimStart();h=[p],c=this.displayWidth(p)}),o.push(h.join(""))}),o.join(`
8
+ `)}};var y=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=ce(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,this.helpGroupHeading=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}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Q(this.name().replace(/^no-/,"")):Q(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},V=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 i=this.negativeOptions.get(n).presetArg,o=i!==void 0?i:!1;return t.negate===(o===e)}};function Q(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ce(s){let e,t,n=/^-[^-]$/,i=/^--[^-]/,o=s.split(/[ |,]+/).concat("guard");if(n.test(o[0])&&(e=o.shift()),i.test(o[0])&&(t=o.shift()),!e&&n.test(o[0])&&(e=o.shift()),!e&&i.test(o[0])&&(e=t,t=o.shift()),o[0].startsWith("-")){let r=o[0],a=`option creation failed due to '${r}' in option flags '${s}'`;throw/^-[^-][^-]/.test(r)?new Error(`${a}
9
9
  - a short flag is a single dash and a single character
10
10
  - either use a single dash and a single character (for a short flag)
11
11
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(r)?new Error(`${a}
12
12
  - too many short flags`):i.test(r)?new Error(`${a}
13
13
  - too many long flags`):new Error(`${a}
14
- - unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${o}'.`);return{shortFlag:e,longFlag:t}}function le(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let n=0;n<=o.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 i=1;i<=o.length;i++){let s;o[i-1]===e[n-1]?s=0:s=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+s),i>1&&n>1&&o[i-1]===e[n-2]&&o[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[o.length][e.length]}function P(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(r=>r.slice(2)));let n=[],i=3,s=.4;return e.forEach(r=>{if(r.length<=1)return;let a=le(o,r),h=Math.max(o.length,r.length);(h-a)/h>s&&(a<i?(i=a,n=[r]):a===i&&n.push(r))}),n.sort((r,a)=>r.localeCompare(a)),t&&(n=n.map(r=>`--${r}`)),n.length>1?`
14
+ - unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${s}'.`);return{shortFlag:e,longFlag:t}}function pe(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let n=0;n<=s.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 i=1;i<=s.length;i++){let o;s[i-1]===e[n-1]?o=0:o=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+o),i>1&&n>1&&s[i-1]===e[n-2]&&s[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[s.length][e.length]}function G(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(r=>r.slice(2)));let n=[],i=3,o=.4;return e.forEach(r=>{if(r.length<=1)return;let a=pe(s,r),h=Math.max(s.length,r.length);(h-a)/h>o&&(a<i?(i=a,n=[r]):a===i&&n.push(r))}),n.sort((r,a)=>r.localeCompare(a)),t&&(n=n.map(r=>`--${r}`)),n.length>1?`
15
15
  (Did you mean one of ${n.join(", ")}?)`:n.length===1?`
16
- (Did you mean ${n[0]}?)`:""}var x=class o extends he{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=>m.stdout.write(t),writeErr:t=>m.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>Q()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>Q()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>ce(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}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 i=t,s=n;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,r,a]=e.match(/([^ ]+) *(.*)/),h=this.createCommand(r);return i&&(h.description(i),h._executableHandler=!0),s.isDefault&&(this._defaultCommandName=h._name),h._hidden=!!(s.noHelp||s.hidden),h._executableFile=s.executableFile||null,a&&h.arguments(a),this._registerCommand(h),h.parent=this,h.copyInheritedSettings(this),i?this:h}createCommand(e){return new o(e)}createHelp(){return Object.assign(new $,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...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
17
- - 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 E(e,t)}argument(e,t,n,i){let s=this.createArgument(e,t);return typeof n=="function"?s.default(i).argParser(n):s.default(n),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(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,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,s]=n.match(/([^ ]+) *(.*)/),r=t??"display help for command",a=this.createCommand(i);return a.helpOption(!1),s&&a.arguments(s),r&&a.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(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}'.
18
- 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 b(e,t,n)),m.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,s=n.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new w(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(s){if(s.code==="commander.invalidArgument"){let r=`${i} ${s.message}`;this.error(r,{exitCode:s.exitCode,code:s.code})}throw s}}_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}'
19
- - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(s,r,a)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let h=this.getOptionValue(n);s!==null&&e.parseArg?s=this._callParseArg(e,s,h,r):s!==null&&e.variadic&&(s=e._collectValue(s,h)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(n,s,a)};return this.on("option:"+t,s=>{let r=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let r=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,r,"env")}),this}_optionEx(e,t,n,i,s){if(typeof t=="object"&&t instanceof w)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(t,n);if(r.makeOptionMandatory(!!e.mandatory),typeof i=="function")r.default(s).argParser(i);else if(i instanceof RegExp){let a=i;i=(h,p)=>{let l=a.exec(h);return l?l[0]:p},r.default(s).argParser(i)}else r.default(i);return this.addOption(r)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}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){m.versions?.electron&&(t.from="electron");let i=m.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=m.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":m.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.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),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.
20
- - 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(V.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${e}' does not exist
16
+ (Did you mean ${n[0]}?)`:""}var v=class s extends de{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=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,getOutHasColors:()=>ee()??(g.stdout.isTTY&&g.stdout.hasColors?.()),getErrHasColors:()=>ee()??(g.stderr.isTTY&&g.stderr.hasColors?.()),stripColor:t=>fe(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}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 i=t,o=n;typeof i=="object"&&i!==null&&(o=i,i=null),o=o||{};let[,r,a]=e.match(/([^ ]+) *(.*)/),h=this.createCommand(r);return i&&(h.description(i),h._executableHandler=!0),o.isDefault&&(this._defaultCommandName=h._name),h._hidden=!!(o.noHelp||o.hidden),h._executableFile=o.executableFile||null,a&&h.arguments(a),this._registerCommand(h),h.parent=this,h.copyInheritedSettings(this),i?this:h}createCommand(e){return new s(e)}createHelp(){return Object.assign(new S,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...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
17
+ - 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 k(e,t)}argument(e,t,n,i){let o=this.createArgument(e,t);return typeof n=="function"?o.default(i).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?.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,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,o]=n.match(/([^ ]+) *(.*)/),r=t??"display help for command",a=this.createCommand(i);return a.helpOption(!1),o&&a.arguments(o),r&&a.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(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}'.
18
+ 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 w(e,t,n)),g.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,o=n.slice(0,i);return this._storeOptionsAsProperties?o[i]=this:o[i]=this.opts(),o.push(this),e.apply(this,o)};return this._actionHandler=t,this}createOption(e,t){return new y(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(o){if(o.code==="commander.invalidArgument"){let r=`${i} ${o.message}`;this.error(r,{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}'
19
+ - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),o=t(e).join("|");throw new Error(`cannot add command '${o}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(o,r,a)=>{o==null&&e.presetArg!==void 0&&(o=e.presetArg);let h=this.getOptionValue(n);o!==null&&e.parseArg?o=this._callParseArg(e,o,h,r):o!==null&&e.variadic&&(o=e._collectValue(o,h)),o==null&&(e.negate?o=!1:e.isBoolean()||e.optional?o=!0:o=""),this.setOptionValueWithSource(n,o,a)};return this.on("option:"+t,o=>{let r=`error: option '${e.flags}' argument '${o}' is invalid.`;i(o,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,o=>{let r=`error: option '${e.flags}' value '${o}' from env '${e.envVar}' is invalid.`;i(o,r,"env")}),this}_optionEx(e,t,n,i,o){if(typeof t=="object"&&t instanceof y)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(t,n);if(r.makeOptionMandatory(!!e.mandatory),typeof i=="function")r.default(o).argParser(i);else if(i instanceof RegExp){let a=i;i=(h,c)=>{let l=a.exec(h);return l?l[0]:c},r.default(o).argParser(i)}else r.default(i);return this.addOption(r)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}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){g.versions?.electron&&(t.from="electron");let i=g.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=g.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":g.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.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),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.
20
+ - 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(I.existsSync(e))return;let i=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
21
21
  - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
22
22
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
23
- - ${i}`;throw new Error(s)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(l,u){let c=O.resolve(l,u);if(V.existsSync(c))return c;if(n.includes(O.extname(u)))return;let g=n.find(f=>V.existsSync(`${c}${f}`));if(g)return`${c}${g}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,r=this._executableDir||"";if(this._scriptPath){let l;try{l=V.realpathSync(this._scriptPath)}catch{l=this._scriptPath}r=O.resolve(O.dirname(l),r)}if(r){let l=i(r,s);if(!l&&!e._executableFile&&this._scriptPath){let u=O.basename(this._scriptPath,O.extname(this._scriptPath));u!==this._name&&(l=i(r,`${u}-${e._name}`))}s=l||s}let a=n.includes(O.extname(s)),h;m.platform!=="win32"?a?(t.unshift(s),t=Y(m.execArgv).concat(t),h=j.spawn(m.argv[0],t,{stdio:"inherit"})):h=j.spawn(s,t,{stdio:"inherit"}):(this._checkForMissingExecutable(s,r,e._name),t.unshift(s),t=Y(m.execArgv).concat(t),h=j.spawn(m.execPath,t,{stdio:"inherit"})),h.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{m.on(u,()=>{h.killed===!1&&h.exitCode===null&&h.kill(u)})});let p=this._exitCallback;h.on("close",l=>{l=l??1,p?p(new b(l,"commander.executeSubCommandAsync","(close)")):m.exit(l)}),h.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(s,r,e._name);else if(l.code==="EACCES")throw new Error(`'${s}' not executable`);if(!p)m.exit(1);else{let u=new b(1,"commander.executeSubCommandAsync","(error)");u.nestedError=l,p(u)}}),this.runningCommand=h}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,i,"preSubcommand"),s=this._chainOrCall(s,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),s}_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,i,s)=>{let r=i;if(i!==null&&n.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;r=this._callParseArg(n,i,s,a)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let s=n.defaultValue;n.variadic?i<this.args.length?(s=this.args.slice(i),n.parseArg&&(s=s.reduce((r,a)=>e(n,a,r),n.defaultValue))):s===void 0&&(s=[]):i<this.args.length&&(s=this.args[i],n.parseArg&&(s=e(n,s,n.defaultValue))),t[i]=s}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(r=>{i.push({hookedCommand:s,callback:r})})}),t==="postAction"&&i.reverse(),i.forEach(s=>{n=this._chainOrCall(n,()=>s.callback(s.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(s=>{i=this._chainOrCall(i,()=>s(this,t))}),i}_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 i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(s,e,t)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(s))i(),this._processArguments(),this.parent.emit(s,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():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),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 i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(s=>n.conflictsWith.includes(s.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function s(l){return l.length>1&&l[0]==="-"}let r=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(u=>u.options.map(c=>c.short).some(c=>/^-\d$/.test(c))):!1,a=null,h=null,p=0;for(;p<e.length||h;){let l=h??e[p++];if(h=null,l==="--"){i===n&&i.push(l),i.push(...e.slice(p));break}if(a&&(!s(l)||r(l))){this.emit(`option:${a.name()}`,l);continue}if(a=null,s(l)){let u=this._findOption(l);if(u){if(u.required){let c=e[p++];c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;p<e.length&&(!s(e[p])||r(e[p]))&&(c=e[p++]),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);a=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()}`),h=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),c=this._findOption(l.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,l.slice(u+1));continue}}if(i===t&&s(l)&&!(this.commands.length===0&&r(l))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(p));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(p));break}else if(this._defaultCommandName){n.push(l,...e.slice(p));break}}if(this._passThroughOptions){i.push(l,...e.slice(p));break}i.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 i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
23
+ - ${i}`;throw new Error(o)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(l,u){let p=O.resolve(l,u);if(I.existsSync(p))return p;if(n.includes(O.extname(u)))return;let f=n.find(m=>I.existsSync(`${p}${m}`));if(f)return`${p}${f}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,r=this._executableDir||"";if(this._scriptPath){let l;try{l=I.realpathSync(this._scriptPath)}catch{l=this._scriptPath}r=O.resolve(O.dirname(l),r)}if(r){let l=i(r,o);if(!l&&!e._executableFile&&this._scriptPath){let u=O.basename(this._scriptPath,O.extname(this._scriptPath));u!==this._name&&(l=i(r,`${u}-${e._name}`))}o=l||o}let a=n.includes(O.extname(o)),h;g.platform!=="win32"?a?(t.unshift(o),t=Z(g.execArgv).concat(t),h=B.spawn(g.argv[0],t,{stdio:"inherit"})):h=B.spawn(o,t,{stdio:"inherit"}):(this._checkForMissingExecutable(o,r,e._name),t.unshift(o),t=Z(g.execArgv).concat(t),h=B.spawn(g.execPath,t,{stdio:"inherit"})),h.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{g.on(u,()=>{h.killed===!1&&h.exitCode===null&&h.kill(u)})});let c=this._exitCallback;h.on("close",l=>{l=l??1,c?c(new w(l,"commander.executeSubCommandAsync","(close)")):g.exit(l)}),h.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(o,r,e._name);else if(l.code==="EACCES")throw new Error(`'${o}' not executable`);if(!c)g.exit(1);else{let u=new w(1,"commander.executeSubCommandAsync","(error)");u.nestedError=l,c(u)}}),this.runningCommand=h}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let o;return o=this._chainOrCallSubCommandHook(o,i,"preSubcommand"),o=this._chainOrCall(o,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._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,i,o)=>{let r=i;if(i!==null&&n.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;r=this._callParseArg(n,i,o,a)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let o=n.defaultValue;n.variadic?i<this.args.length?(o=this.args.slice(i),n.parseArg&&(o=o.reduce((r,a)=>e(n,a,r),n.defaultValue))):o===void 0&&(o=[]):i<this.args.length&&(o=this.args[i],n.parseArg&&(o=e(n,o,n.defaultValue))),t[i]=o}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[t]!==void 0).forEach(o=>{o._lifeCycleHooks[t].forEach(r=>{i.push({hookedCommand:o,callback:r})})}),t==="postAction"&&i.reverse(),i.forEach(o=>{n=this._chainOrCall(n,()=>o.callback(o.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(o=>{i=this._chainOrCall(i,()=>o(this,t))}),i}_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 i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},o=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(o,e,t)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(o))i(),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():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),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 i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(o=>n.conflictsWith.includes(o.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function o(l){return l.length>1&&l[0]==="-"}let r=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(u=>u.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,a=null,h=null,c=0;for(;c<e.length||h;){let l=h??e[c++];if(h=null,l==="--"){i===n&&i.push(l),i.push(...e.slice(c));break}if(a&&(!o(l)||r(l))){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let u=this._findOption(l);if(u){if(u.required){let p=e[c++];p===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,p)}else if(u.optional){let p=null;c<e.length&&(!o(e[c])||r(e[c]))&&(p=e[c++]),this.emit(`option:${u.name()}`,p)}else this.emit(`option:${u.name()}`);a=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()}`),h=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),p=this._findOption(l.slice(0,u));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,l.slice(u+1));continue}}if(i===t&&o(l)&&!(this.commands.length===0&&r(l))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){i.push(l,...e.slice(c));break}i.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 i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
24
24
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
25
25
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
26
- `),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,s=n.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in m.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()}`,m.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new H(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(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"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=r=>{let a=r.attributeName(),h=this.getOptionValue(a),p=this.options.find(u=>u.negate&&a===u.attributeName()),l=this.options.find(u=>!u.negate&&a===u.attributeName());return p&&(p.presetArg===void 0&&h===!1||p.presetArg!==void 0&&h===p.presetArg)?p:l||r},i=r=>{let a=n(r),h=a.attributeName();return this.getOptionValueSource(h)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let r=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);i=i.concat(r),s=s.parent}while(s&&!s._enablePositionalOptions);t=P(e,i)}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",i=e.length,s=this.parent?` for '${this.name()}'`:"",r=e.join(", "),a=`error: too many arguments${s}. Expected ${t} argument${n} but got ${i}: ${r}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),t=P(e,i)}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 i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
27
- `),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 i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}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=>T(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)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=O.basename(e,O.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 i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,s;return t?(n=a=>this._outputConfiguration.writeErr(a),i=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(n=a=>this._outputConfiguration.writeOut(a),i=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:t,write:a=>(i||(a=this._outputConfiguration.stripColor(a)),n(a)),hasColors:i,helpWidth:s}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let s=this.helpInformation({error:n.error});if(t&&(s=t(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(m.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.
28
- Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let r;typeof t=="function"?r=t({error:s.error,command:s.command}):r=t,r&&s.write(`${r}
29
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Y(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:n=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],n=s[3],i=s[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function Q(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var Qe=new x;function pe(o){let[,e,t,...n]=o;if(e===void 0||e==="list")return{kind:"config",action:"list"};if(e==="path")return{kind:"config",action:"path"};if(e==="set"){if(t===void 0||!N.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${N.join(", ")}.`);let i=n.join(" ");if(i.length===0)throw d(`forge config set ${t} needs a value.`);return{kind:"config",action:"set",key:t,value:i}}throw d(`Unknown config action ${e}.`,"Try: forge config list, forge config set <setting> <value>, or forge config path.")}var de={jpg:"jpeg",tif:"tiff",heif:"heic"};function X(o){let e=o.toLowerCase().replace(/^\./,""),t=B(de[e]??e);if(!t)throw d(`${o} is not a format Forge knows.`,"Run forge --formats to see what is available.");return t.id}function D(o){let e=Number(o);if(!Number.isInteger(e)||e<1||e>100)throw d(`Quality must be a whole number between 1 and 100, not ${o}.`);return e}function W(o){let e=Number(o);if(!Number.isInteger(e)||e<1)throw d(`Concurrency must be a positive whole number, not ${o}.`);return e}var fe=`
26
+ `),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,o=n.code||"commander.error";this._exit(i,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.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()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new V(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(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"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=r=>{let a=r.attributeName(),h=this.getOptionValue(a),c=this.options.find(u=>u.negate&&a===u.attributeName()),l=this.options.find(u=>!u.negate&&a===u.attributeName());return c&&(c.presetArg===void 0&&h===!1||c.presetArg!==void 0&&h===c.presetArg)?c:l||r},i=r=>{let a=n(r),h=a.attributeName();return this.getOptionValueSource(h)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},o=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],o=this;do{let r=o.createHelp().visibleOptions(o).filter(a=>a.long).map(a=>a.long);i=i.concat(r),o=o.parent}while(o&&!o._enablePositionalOptions);t=G(e,i)}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",i=e.length,o=this.parent?` for '${this.name()}'`:"",r=e.join(", "),a=`error: too many arguments${o}. Expected ${t} argument${n} but got ${i}: ${r}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(o=>{i.push(o.name()),o.alias()&&i.push(o.alias())}),t=G(e,i)}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 i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
27
+ `),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 i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}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=>H(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)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=O.basename(e,O.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 i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,o;return t?(n=a=>this._outputConfiguration.writeErr(a),i=this._outputConfiguration.getErrHasColors(),o=this._outputConfiguration.getErrHelpWidth()):(n=a=>this._outputConfiguration.writeOut(a),i=this._outputConfiguration.getOutHasColors(),o=this._outputConfiguration.getOutHelpWidth()),{error:t,write:a=>(i||(a=this._outputConfiguration.stripColor(a)),n(a)),hasColors:i,helpWidth:o}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);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",i),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(g.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.
28
+ Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,o=>{let r;typeof t=="function"?r=t({error:o.error,command:o.command}):r=t,r&&o.write(`${r}
29
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Z(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="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])?i=o[3]:n=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=o[1],n=o[3],i=o[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function ee(){if(g.env.NO_COLOR||g.env.FORCE_COLOR==="0"||g.env.FORCE_COLOR==="false")return!1;if(g.env.FORCE_COLOR||g.env.CLICOLOR_FORCE!==void 0)return!0}var tt=new v;function me(s){let[,e,t,...n]=s;if(e===void 0||e==="list")return{kind:"config",action:"list"};if(e==="path")return{kind:"config",action:"path"};if(e==="set"){if(t===void 0||!D.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${D.join(", ")}.`);let i=n.join(" ");if(i.length===0)throw d(`forge config set ${t} needs a value.`);return{kind:"config",action:"set",key:t,value:i}}throw d(`Unknown config action ${e}.`,"Try: forge config list, forge config set <setting> <value>, or forge config path.")}var ge={jpg:"jpeg",tif:"tiff",heif:"heic"};function M(s){let e=s.toLowerCase().replace(/^\./,""),t=L(ge[e]??e);if(!t)throw d(`${s} is not a format Forge knows.`,"Run forge --formats to see what is available.");return t.id}function N(s){let e=Number(s);if(!Number.isInteger(e)||e<1||e>100)throw d(`Quality must be a whole number between 1 and 100, not ${s}.`);return e}function te(s,e){let t=/^\d+$/.test(String(e))?Number(e):Number.NaN;if(!Number.isInteger(t)||t<1)throw d(`${s} takes a whole number of pixels, at least 1, not ${e}.`);return t}function _e(s){let e=String(s),t=/^\d+(\.\d+)?%?$/.test(e)?Number.parseFloat(e):Number.NaN;if(!(t>=1&&t<=j))throw d(`--resize takes a percent from 1 to ${j}, not ${s}.`,"Try --resize 50% to halve, or --width 1200 for an exact width.");return t}function F(s){let e=Number(s);if(!Number.isInteger(e)||e<1)throw d(`Concurrency must be a positive whole number, not ${s}.`);return e}var be=`
30
30
  Exit codes:
31
31
  0 every input succeeded
32
32
  1 the command was understood, and at least one input failed or was refused
33
- 2 the command itself was invalid: an unknown flag, a missing argument, contradictory flags`,me=`
33
+ 2 the command itself was invalid: an unknown flag, a missing argument, contradictory flags`,we=`
34
34
  Other commands:
35
35
  forge probe <files...> what each file is and what Forge can do with it
36
36
  forge palette <image> an image's main colours (--json, --svg, --inside <hex>)
37
37
  forge scale <colour> 50\u2013950 from one colour, with it at 500 (--json, --svg)
38
38
  forge config [list | path | set <setting> <value>]
39
39
  forge extensions [add | remove <id>] optional extras, such as boost and remove-background
40
- forge mcp run as a local MCP server over stdio, for AI agents`;function Z(o){let e=L(String(o));if(e===void 0)throw d(`${o} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function ge(o){let e=o.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function _e(o){let e=o.slice(1).filter(r=>r!=="--json"),t=e.find(r=>r.startsWith("-"));if(t!==void 0)throw d(`forge extensions does not take ${t}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");let[n,i,...s]=e;if(n===void 0)return{kind:"extensions",action:"list"};if(n!=="add"&&n!=="remove")throw d(`Unknown extensions action ${n}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");if(i===void 0||s.length>0)throw d(`forge extensions ${n} takes exactly one extension.`,`Try: forge extensions ${n} boost`);return{kind:"extensions",action:n,id:i}}function ee(o){if(o===void 0)throw d("No colour given.","Try: forge scale 6579FD \u2014 or quote it, '#6579FD', because an unquoted # starts a comment in the shell.");let e=q(o);if(!e)throw d(`${o} is not a colour.`,"Try a hex code, for example 6579FD or #6579FD.");return e}var be={palette:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
40
+ forge mcp run as a local MCP server over stdio, for AI agents`;function ne(s){let e=U(String(s));if(e===void 0)throw d(`${s} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function Oe(s){let e=s.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function xe(s){let e=s.slice(1).filter(r=>r!=="--json"),t=e.find(r=>r.startsWith("-"));if(t!==void 0)throw d(`forge extensions does not take ${t}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");let[n,i,...o]=e;if(n===void 0)return{kind:"extensions",action:"list"};if(n!=="add"&&n!=="remove")throw d(`Unknown extensions action ${n}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");if(i===void 0||o.length>0)throw d(`forge extensions ${n} takes exactly one extension.`,`Try: forge extensions ${n} boost`);return{kind:"extensions",action:n,id:i}}function ie(s){if(s===void 0)throw d("No colour given.","Try: forge scale 6579FD \u2014 or quote it, '#6579FD', because an unquoted # starts a comment in the shell.");let e=R(s);if(!e)throw d(`${s} is not a colour.`,"Try a hex code, for example 6579FD or #6579FD.");return e}var Ce={palette:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
41
41
 
42
42
  An image's main colours, most of the image first.
43
43
  --json one JSON document: palette.colours[] with hex, rgb, oklch, share
@@ -48,21 +48,21 @@ An image's main colours, most of the image first.
48
48
  50\u2013950 built in OKLCH, with <colour> at 500. Pass the hex without #, or quote it.
49
49
  --json one JSON document: scale.steps[] with hex, oklch, white, black
50
50
  --svg a card of swatches; pipe to pbcopy and paste into Figma
51
- `};function Oe(o){let[e,...t]=o;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(be[e==="scale"?"scale":"palette"]),new b(0,"commander.helpDisplayed","(outputHelp)");let n=t.filter(h=>h!=="--json"&&h!=="--svg"),i=t.includes("--svg"),s=n.indexOf("--inside"),r=s===-1?void 0:n[s+1];s!==-1&&n.splice(s,2);let a=n.find(h=>h.startsWith("-"));if(a!==void 0)throw d(`forge ${e} does not take ${a}.`,`Try: forge ${e} --help`);if(e==="scale"){if(s!==-1)throw d("--inside is for forge palette.","Try: forge palette photo.jpg --inside F26E69");if(n.length>1)throw d("forge scale takes one colour.","Try: forge scale 6579FD");return{kind:"scale",colour:ee(n[0]),svg:i}}if(n.length!==1)throw d(n.length===0?"No image given.":"forge palette takes one image.","Try: forge palette photo.jpg");return{kind:"palette",input:n[0],svg:i,...s===-1?{}:{inside:ee(r)}}}function G(o){let e=o.indexOf("--");return(e===-1?o:o.slice(0,e)).includes("--json")}function Ce(o){let e=o.indexOf("--"),t=e===-1?o:o.slice(0,e),n=e===-1?[]:o.slice(e),i=[],s;for(let r=0;r<t.length;r++){let a=t[r],h=a.startsWith("--boost=")?a.slice(8):void 0;if(a!=="--boost"&&h===void 0){i.push(a);continue}let p=h;if(p===void 0&&/^\d+$/.test(t[r+1]??"")&&(p=t[++r]),p!==void 0&&p!=="2"&&p!=="4")throw d(`--boost takes 2 or 4, not ${p}.`,"Try --boost, --boost 2 or --boost 4.");s=p==="4"?4:2}return{rest:[...i,...n],...s===void 0?{}:{scale:s}}}function te(o){let e=o;if(e[0]==="config"||e[0]==="probe"||e[0]==="extensions"||e[0]==="palette"||e[0]==="scale")return we(e);let t=Ce(e);return xe(t.rest,t.scale)}function we(o){return o[0]==="config"?pe(o.filter(e=>e!=="--json")):o[0]==="probe"?ge(o):o[0]==="palette"||o[0]==="scale"?Oe(o):_e(o)}function xe(o,e){let t=new x().name("forge").description("Convert \u2014 transform your files from the terminal").argument("[inputs...]","files, folders or globs").option("-t, --to <format>","target format").option("-o, --output <path>","output file or directory").option("-q, --quality <n>","quality for lossy formats, 1-100").option("--background <colour>","fill colour when flattening transparency","#ffffff").option("--keep-metadata","preserve EXIF and GPS data",!1).option("--recursive","descend into subfolders",!1).option("--force","allow overwriting existing files",!1).option("--max-size <size>","compress until the file fits, e.g. 500kb").option("--concurrency <n>","how many files to convert at once").option("--debug","show underlying errors",!1).option("--formats","list supported formats",!1).option("--merge","combine several PDFs into one").option("--split <mode>","every-page | every=N | at=N,N").option("--extract <pages>","keep only these pages, e.g. 3-7,12").option("--delete <pages>","drop these pages").option("--rotate <degrees>","90, 180 or 270").option("--separate","with --extract, write one file per page").option("--sharpen","sharpen at the same size; needs the boost extension").option("--boost [2|4]","sharpen and enlarge 2x (default) or 4x; needs the boost extension").option("--remove-bg","cut out the subject; needs the remove-background extension").option("--pages <ranges>","with --to, which pages to render, e.g. 3-7,12").option("--dpi <n>","rasterisation resolution, 36-600","150").option("--password-stdin","read an encrypted PDF's password from stdin").option("--json","print one JSON document on stdout instead of text").helpOption("-h, --help","show this help").version(v,"-V, --version","show the version").addHelpText("after",`${me}
52
- ${fe}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(o,{from:"user"})}catch(c){if(c instanceof b&&c.code!=="commander.helpDisplayed"&&c.code!=="commander.version"){let[g="",...f]=c.message.replace(/^error: /,"").split(`
53
- `),_=f.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${g.charAt(0).toUpperCase()}${g.slice(1).replace(/\.$/,"")}.`,_||"Run forge --help to see what Forge accepts.")}throw c}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};if(n.pages!==void 0&&n.to===void 0)throw d("--pages needs --to: it chooses which pages to render.");let s=["merge","split","extract","delete","rotate"].filter(c=>n[c]!==void 0);if(s.length>1)throw d(`Use one operation at a time \u2014 got ${s.map(c=>`--${c}`).join(" and ")}.`);let r=[...n.sharpen?["--sharpen"]:[],...e!==void 0?["--boost"]:[],...n.removeBg?["--remove-bg"]:[]],a=n.sharpen?1:e,h=a!==void 0?"boost":n.removeBg?"remove-background":null;if(h!==null){if(r.length>1)throw d(`Use one operation at a time \u2014 got ${r.join(" and ")}.`);let c=r[0];if(s.length>0)throw d(`${c} cannot be combined with --${s[0]}.`);if(n.maxSize!==void 0||n.pages!==void 0)throw d(`${c} cannot be combined with ${n.maxSize!==void 0?"--max-size":"--pages"}.`);if(i.length===0)throw d("No files given.",`Name an image, for example: forge photo.jpg ${c}`);let g=n.to?X(String(n.to)):"png";if(h==="remove-background"){let y=U(g);if(y)throw y}let f={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(f.quality=D(String(n.quality)));let _={kind:"extension-op",op:h,inputs:i,target:g,options:f,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return a!==void 0&&(_.scale=a),n.output!==void 0&&(_.output=String(n.output)),n.concurrency!==void 0&&(_.concurrency=W(String(n.concurrency))),_}if(s.length===1){let c=s[0];if(i.length===0)throw d("No files given.",`Name a PDF, for example: forge doc.pdf --${c}`);if(n.separate&&c!=="extract")throw d(`--separate only applies to --extract, not --${c}.`);if(n.output!==void 0)throw d(`--output does not apply to --${c}.`,"Page operations name their own outputs, beside the source. Rename the result afterwards.");let g={kind:"pageop",action:c,inputs:i,force:!!n.force,debug:!!n.debug};if(c==="rotate"){let f=Number(n.rotate);if(!Number.isInteger(f)||f%90!==0||f===0||f>=360)throw d(`--rotate takes a multiple of 90 below 360, not "${n.rotate}".`);g.rotate=f}if((c==="extract"||c==="delete")&&(g.pages=String(n[c]),c==="extract"&&n.separate&&(g.separate=!0)),c==="split"){let f=String(n.split),_=f.match(/^every=(\d+)$/),y=f.match(/^at=([\d,\s]+)$/);if(f==="every-page")g.split={mode:"every-page"};else if(_?.[1]!==void 0){let A=Number(_[1]);if(!Number.isInteger(A)||A<1)throw d(`--split every=N takes a whole number of pages, at least 1, not "${_[1]}".`);g.split={mode:"every-n",n:A}}else if(y?.[1])g.split={mode:"points",after:y[1].split(",").map(A=>Number(A.trim()))};else throw d(`--split takes every-page, every=N or at=N,N \u2014 not "${f}".`)}return g}if(i.length===0&&!n.to&&n.quality===void 0&&n.maxSize===void 0)return{kind:"shell"};if(n.quality!==void 0&&n.maxSize!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");if(!n.to&&(n.quality!==void 0||n.maxSize!==void 0)){if(i.length===0)throw d("No files given.","Name a file, for example: forge photo.jpg --max-size 500kb");let c={background:String(n.background),keepMetadata:!!n.keepMetadata},g={kind:"compress",inputs:i,options:c,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};if(n.quality!==void 0&&(g.quality=D(String(n.quality))),n.maxSize!==void 0&&(g.maxBytes=Z(n.maxSize)),n.output!==void 0&&(g.output=String(n.output)),t.getOptionValueSource("dpi")==="cli"){let f=Number(n.dpi);if(!Number.isInteger(f)||f<36||f>600)throw I(n.dpi);g.dpi=f}return n.concurrency!==void 0&&(g.concurrency=W(String(n.concurrency))),g}if(!n.to)throw d("No target format given.","Add --to <format>, for example: forge photo.jpg --to webp");if(i.length===0)throw d("No files given.","Name a file, a folder or a glob, for example: forge photo.jpg --to webp");let p={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(p.quality=D(String(n.quality)));let l=Number(n.dpi);if(!Number.isInteger(l)||l<36||l>600)throw I(n.dpi);let u={kind:"convert",inputs:i,target:X(String(n.to)),options:p,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug,dpi:l,passwordStdin:!!n.passwordStdin};return n.output!==void 0&&(u.output=String(n.output)),n.pages!==void 0&&(u.pages=String(n.pages)),n.maxSize!==void 0&&(u.maxBytes=Z(n.maxSize)),n.concurrency!==void 0&&(u.concurrency=W(String(n.concurrency))),u}function M(o){return k(o)?o:R(o)}function ne(o,e){return S(M(o),{debug:e})}function ie(o,e){process.once("beforeExit",()=>{o()||(e(new Error("Forge stopped before it finished: it was waiting for input that never came.")),process.exitCode=1)})}se.enableCompileCache?.();function ye({completed:o,total:e}){o===0?process.stderr.write(`Converting ${e} files
54
- `):process.stderr.write(` ${o}/${e}
55
- `)}async function Ae(){let o=process.argv.slice(2),e=o.includes("--debug"),t=G(o);try{if(o[0]==="mcp"){let{runMcpServer:u}=await import("./chunks/server-5RWSVTOM.js");await u(o.slice(1));return}let n=te(o);if(n.kind==="shell"){if(t)throw d("No files given.","Name a file, for example: forge photo.jpg --to webp --json");if(!process.stdout.isTTY||!process.stdin.isTTY){process.stderr.write(`Forge needs a file and a target format.
51
+ `};function ye(s){let[e,...t]=s;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(Ce[e==="scale"?"scale":"palette"]),new w(0,"commander.helpDisplayed","(outputHelp)");let n=t.filter(h=>h!=="--json"&&h!=="--svg"),i=t.includes("--svg"),o=n.indexOf("--inside"),r=o===-1?void 0:n[o+1];o!==-1&&n.splice(o,2);let a=n.find(h=>h.startsWith("-"));if(a!==void 0)throw d(`forge ${e} does not take ${a}.`,`Try: forge ${e} --help`);if(e==="scale"){if(o!==-1)throw d("--inside is for forge palette.","Try: forge palette photo.jpg --inside F26E69");if(n.length>1)throw d("forge scale takes one colour.","Try: forge scale 6579FD");return{kind:"scale",colour:ie(n[0]),svg:i}}if(n.length!==1)throw d(n.length===0?"No image given.":"forge palette takes one image.","Try: forge palette photo.jpg");return{kind:"palette",input:n[0],svg:i,...o===-1?{}:{inside:ie(r)}}}function q(s){let e=s.indexOf("--");return(e===-1?s:s.slice(0,e)).includes("--json")}function ve(s){let e=s.indexOf("--"),t=e===-1?s:s.slice(0,e),n=e===-1?[]:s.slice(e),i=[],o;for(let r=0;r<t.length;r++){let a=t[r],h=a.startsWith("--boost=")?a.slice(8):void 0;if(a!=="--boost"&&h===void 0){i.push(a);continue}let c=h;if(c===void 0&&/^\d+$/.test(t[r+1]??"")&&(c=t[++r]),c!==void 0&&c!=="2"&&c!=="3"&&c!=="4")throw d(`--boost takes 2, 3 or 4, not ${c}.`,"Try --boost, --boost 2, --boost 3 or --boost 4.");o=c==="4"?4:c==="3"?3:2}return{rest:[...i,...n],...o===void 0?{}:{scale:o}}}function oe(s){let e=s;if(e[0]==="config"||e[0]==="probe"||e[0]==="extensions"||e[0]==="palette"||e[0]==="scale")return Ae(e);let t=ve(e);return $e(t.rest,t.scale)}function Ae(s){return s[0]==="config"?me(s.filter(e=>e!=="--json")):s[0]==="probe"?Oe(s):s[0]==="palette"||s[0]==="scale"?ye(s):xe(s)}function $e(s,e){let t=new v().name("forge").description("Convert \u2014 transform your files from the terminal").argument("[inputs...]","files, folders or globs").option("-t, --to <format>","target format").option("-o, --output <path>","output file or directory").option("-q, --quality <n>","quality for lossy formats, 1-100").option("--background <colour>","fill colour when flattening transparency","#ffffff").option("--keep-metadata","preserve EXIF and GPS data",!1).option("--recursive","descend into subfolders",!1).option("--force","allow overwriting existing files",!1).option("--max-size <size>","compress until the file fits, e.g. 500kb").option("--concurrency <n>","how many files to convert at once").option("--debug","show underlying errors",!1).option("--formats","list supported formats",!1).option("--merge","combine several PDFs into one").option("--split <mode>","every-page | every=N | at=N,N").option("--extract <pages>","keep only these pages, e.g. 3-7,12").option("--delete <pages>","drop these pages").option("--rotate <degrees>","90, 180 or 270").option("--separate","with --extract, write one file per page").option("--sharpen","sharpen at the same size; needs the boost extension").option("--boost [2|3|4]","sharpen and enlarge 2x (default), 3x or 4x; needs the boost extension").option("--trim","cut transparent or solid-colour edges; keeps the format").option("--resize <percent>","resize to a percent of the size, 1-200, e.g. 50%").option("--width <px>","resize to this width; the height follows").option("--height <px>","resize to this height; the width follows").option("--remove-bg","cut out the subject; needs the remove-background extension").option("--pages <ranges>","with --to, which pages to render, e.g. 3-7,12").option("--dpi <n>","rasterisation resolution, 36-600","150").option("--password-stdin","read an encrypted PDF's password from stdin").option("--json","print one JSON document on stdout instead of text").helpOption("-h, --help","show this help").version($,"-V, --version","show the version").addHelpText("after",`${we}
52
+ ${be}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(s,{from:"user"})}catch(f){if(f instanceof w&&f.code!=="commander.helpDisplayed"&&f.code!=="commander.version"){let[m="",..._]=f.message.replace(/^error: /,"").split(`
53
+ `),b=_.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${m.charAt(0).toUpperCase()}${m.slice(1).replace(/\.$/,"")}.`,b||"Run forge --help to see what Forge accepts.")}throw f}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};if(n.pages!==void 0&&n.to===void 0)throw d("--pages needs --to: it chooses which pages to render.");let o=["merge","split","extract","delete","rotate"].filter(f=>n[f]!==void 0);if(o.length>1)throw d(`Use one operation at a time \u2014 got ${o.map(f=>`--${f}`).join(" and ")}.`);let r=[...n.sharpen?["--sharpen"]:[],...e!==void 0?["--boost"]:[],...n.removeBg?["--remove-bg"]:[]],a=[...n.resize!==void 0?["--resize"]:[],...n.width!==void 0?["--width"]:[],...n.height!==void 0?["--height"]:[]];if(n.trim||a.length>0){if(a.length>1)throw d(`Use one of --resize, --width and --height \u2014 got ${a.join(" and ")}.`);let f=[...r,...n.maxSize!==void 0?["--max-size"]:[],...n.pages!==void 0?["--pages"]:[],...o.map(x=>`--${x}`)][0];if(f!==void 0)throw d(`${a[0]??"--trim"} cannot be combined with ${f}.`,f==="--max-size"?"Resize first, then compress the result: forge photo-1200x900.jpg --max-size 500kb":"Run them one after the other.");let m=n.resize!==void 0?{percent:_e(n.resize)}:n.width!==void 0?{width:te("--width",n.width)}:n.height!==void 0?{height:te("--height",n.height)}:void 0;if(i.length===0)throw d("No files given.","Name an image, for example: forge photo.jpg --resize 50%");let _={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(_.quality=N(String(n.quality)));let b={kind:"edit",inputs:i,trim:!!n.trim,options:_,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return m!==void 0&&(b.resize=m),n.to&&(b.target=M(String(n.to))),n.output!==void 0&&(b.output=String(n.output)),n.concurrency!==void 0&&(b.concurrency=F(String(n.concurrency))),b}let h=n.sharpen?1:e,c=h!==void 0?"boost":n.removeBg?"remove-background":null;if(c!==null){if(r.length>1)throw d(`Use one operation at a time \u2014 got ${r.join(" and ")}.`);let f=r[0];if(o.length>0)throw d(`${f} cannot be combined with --${o[0]}.`);if(n.maxSize!==void 0||n.pages!==void 0)throw d(`${f} cannot be combined with ${n.maxSize!==void 0?"--max-size":"--pages"}.`);if(i.length===0)throw d("No files given.",`Name an image, for example: forge photo.jpg ${f}`);let m=n.to?M(String(n.to)):"png";if(c==="remove-background"){let x=K(m);if(x)throw x}let _={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(_.quality=N(String(n.quality)));let b={kind:"extension-op",op:c,inputs:i,target:m,options:_,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return h!==void 0&&(b.scale=h),n.output!==void 0&&(b.output=String(n.output)),n.concurrency!==void 0&&(b.concurrency=F(String(n.concurrency))),b}if(o.length===1){let f=o[0];if(i.length===0)throw d("No files given.",`Name a PDF, for example: forge doc.pdf --${f}`);if(n.separate&&f!=="extract")throw d(`--separate only applies to --extract, not --${f}.`);if(n.output!==void 0)throw d(`--output does not apply to --${f}.`,"Page operations name their own outputs, beside the source. Rename the result afterwards.");let m={kind:"pageop",action:f,inputs:i,force:!!n.force,debug:!!n.debug};if(f==="rotate"){let _=Number(n.rotate);if(!Number.isInteger(_)||_%90!==0||_===0||_>=360)throw d(`--rotate takes a multiple of 90 below 360, not "${n.rotate}".`);m.rotate=_}if((f==="extract"||f==="delete")&&(m.pages=String(n[f]),f==="extract"&&n.separate&&(m.separate=!0)),f==="split"){let _=String(n.split),b=_.match(/^every=(\d+)$/),x=_.match(/^at=([\d,\s]+)$/);if(_==="every-page")m.split={mode:"every-page"};else if(b?.[1]!==void 0){let A=Number(b[1]);if(!Number.isInteger(A)||A<1)throw d(`--split every=N takes a whole number of pages, at least 1, not "${b[1]}".`);m.split={mode:"every-n",n:A}}else if(x?.[1])m.split={mode:"points",after:x[1].split(",").map(A=>Number(A.trim()))};else throw d(`--split takes every-page, every=N or at=N,N \u2014 not "${_}".`)}return m}if(i.length===0&&!n.to&&n.quality===void 0&&n.maxSize===void 0)return{kind:"shell"};if(n.quality!==void 0&&n.maxSize!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");if(!n.to&&(n.quality!==void 0||n.maxSize!==void 0)){if(i.length===0)throw d("No files given.","Name a file, for example: forge photo.jpg --max-size 500kb");let f={background:String(n.background),keepMetadata:!!n.keepMetadata},m={kind:"compress",inputs:i,options:f,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};if(n.quality!==void 0&&(m.quality=N(String(n.quality))),n.maxSize!==void 0&&(m.maxBytes=ne(n.maxSize)),n.output!==void 0&&(m.output=String(n.output)),t.getOptionValueSource("dpi")==="cli"){let _=Number(n.dpi);if(!Number.isInteger(_)||_<36||_>600)throw P(n.dpi);m.dpi=_}return n.concurrency!==void 0&&(m.concurrency=F(String(n.concurrency))),m}if(!n.to)throw d("No target format given.","Add --to <format>, for example: forge photo.jpg --to webp");if(i.length===0)throw d("No files given.","Name a file, a folder or a glob, for example: forge photo.jpg --to webp");let l={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(l.quality=N(String(n.quality)));let u=Number(n.dpi);if(!Number.isInteger(u)||u<36||u>600)throw P(n.dpi);let p={kind:"convert",inputs:i,target:M(String(n.to)),options:l,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug,dpi:u,passwordStdin:!!n.passwordStdin};return n.output!==void 0&&(p.output=String(n.output)),n.pages!==void 0&&(p.pages=String(n.pages)),n.maxSize!==void 0&&(p.maxBytes=ne(n.maxSize)),n.concurrency!==void 0&&(p.concurrency=F(String(n.concurrency))),p}function z(s){return E(s)?s:J(s)}function re(s,e){return T(z(s),{debug:e})}function se(s,e){process.once("beforeExit",()=>{s()||(e(new Error("Forge stopped before it finished: it was waiting for input that never came.")),process.exitCode=1)})}ae.enableCompileCache?.();function ke({completed:s,total:e}){s===0?process.stderr.write(`Converting ${e} files
54
+ `):process.stderr.write(` ${s}/${e}
55
+ `)}async function Se(){let s=process.argv.slice(2),e=s.includes("--debug"),t=q(s);try{if(s[0]==="mcp"){let{runMcpServer:u}=await import("./chunks/server-DU7QWDAH.js");await u(s.slice(1));return}let n=oe(s);if(n.kind==="shell"){if(t)throw d("No files given.","Name a file, for example: forge photo.jpg --to webp --json");if(!process.stdout.isTTY||!process.stdin.isTTY){process.stderr.write(`Forge needs a file and a target format.
56
56
  Try: forge photo.jpg --to webp
57
- `),process.exitCode=2;return}let{applyColourPreference:u}=await import("./chunks/theme-GW7CQPUO.js");u();let{bootShell:c}=await import("./chunks/boot-ODZZHFUI.js");await c();return}let{execute:i}=await import("./chunks/execute-4WJCUM7J.js"),s,r=0,a=(u,c)=>{let g=Date.now();if(u<c&&g-r<100)return;r=g;let f=_=>(_/1e6).toFixed(1);process.stderr.write(`\r downloading ${f(u)} / ${f(c)} MB${u>=c?`
58
- `:""}`)},h=!!process.stderr.isTTY&&!t,p=new AbortController;n.kind==="extension-op"&&process.once("SIGINT",()=>p.abort());let l=await i(n,{json:t,signal:p.signal,...h?{onDownload:a}:{},colour:!!process.stdout.isTTY&&!t&&J(),onProgress:h?u=>{u.completed>0&&s?.stop(),ye(u)}:void 0,...h?{onSearch:u=>{s??=z(process.stderr,"finding the smallest that fits"),s.update(u)}}:{}});s?.stop(),l.stdout.length>0&&process.stdout.write(`${l.stdout.join(`
57
+ `),process.exitCode=2;return}let{applyColourPreference:u}=await import("./chunks/theme-DESCJOCE.js");u();let{bootShell:p}=await import("./chunks/boot-BUGERSEB.js");await p();return}let{execute:i}=await import("./chunks/execute-M3C3TTWB.js"),o,r=0,a=(u,p)=>{let f=Date.now();if(u<p&&f-r<100)return;r=f;let m=_=>(_/1e6).toFixed(1);process.stderr.write(`\r downloading ${m(u)} / ${m(p)} MB${u>=p?`
58
+ `:""}`)},h=!!process.stderr.isTTY&&!t,c=new AbortController;n.kind==="extension-op"&&process.once("SIGINT",()=>c.abort());let l=await i(n,{json:t,signal:c.signal,...h?{onDownload:a}:{},colour:!!process.stdout.isTTY&&!t&&X(),onProgress:h?u=>{u.completed>0&&o?.stop(),ke(u)}:void 0,...h?{onSearch:u=>{o??=Y(process.stderr,"finding the smallest that fits"),o.update(u)}}:{}});o?.stop(),l.stdout.length>0&&process.stdout.write(`${l.stdout.join(`
59
59
  `)}
60
60
  `),l.stderr.length>0&&process.stderr.write(`${l.stderr.join(`
61
61
  `)}
62
- `),process.exitCode=p.signal.aborted?130:l.exitCode}catch(n){if(k(n)){t?process.stdout.write(`${JSON.stringify(F(v,n))}
63
- `):process.stderr.write(`${S(n,{debug:e}).join(`
62
+ `),process.exitCode=c.signal.aborted?130:l.exitCode}catch(n){if(E(n)){t?process.stdout.write(`${JSON.stringify(W($,n))}
63
+ `):process.stderr.write(`${T(n,{debug:e}).join(`
64
64
  `)}
65
- `),process.exitCode=2;return}if(n instanceof Error&&"code"in n&&"exitCode"in n){let i=n.code;process.exitCode=i==="commander.helpDisplayed"||i==="commander.version"?0:2;return}throw n}}function re(o){let e=process.argv.slice(2);if(G(e)){process.stdout.write(`${JSON.stringify(F(v,M(o)))}
66
- `);return}process.stderr.write(`${ne(o,e.includes("--debug")).join(`
65
+ `),process.exitCode=2;return}if(n instanceof Error&&"code"in n&&"exitCode"in n){let i=n.code;process.exitCode=i==="commander.helpDisplayed"||i==="commander.version"?0:2;return}throw n}}function ue(s){let e=process.argv.slice(2);if(q(e)){process.stdout.write(`${JSON.stringify(W($,z(s)))}
66
+ `);return}process.stderr.write(`${re(s,e.includes("--debug")).join(`
67
67
  `)}
68
- `)}var oe=!1;ie(()=>oe,re);try{await Ae()}catch(o){re(o),process.exitCode=1}finally{oe=!0}export{v as VERSION};
68
+ `)}var le=!1;se(()=>le,ue);try{await Se()}catch(s){ue(s),process.exitCode=1}finally{le=!0}export{$ as VERSION};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-terminal",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A terminal-native file converter for macOS",
5
5
  "keywords": [
6
6
  "convert",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@hyzyla/pdfium": "^2.1.13",
56
- "sharp": "^0.35.3"
56
+ "sharp": "^0.35.5"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@biomejs/biome": "^2.5.9",
@@ -64,6 +64,23 @@ Outputs go beside the source unless `-o` names a folder (or, for one file, a
64
64
  filename). Page operations always write beside the source, take no `-o`, and
65
65
  never edit the original.
66
66
 
67
+ ## Resize and trim edges
68
+
69
+ Built in, images only, format kept unless `--to` is given:
70
+
71
+ ```bash
72
+ forge photo.jpg --resize 50% --json # photo-<W>x<H>.jpg (percent 1-200)
73
+ forge photo.jpg --width 1200 --json # height follows; --height 900 likewise
74
+ forge photo.jpg --trim --json # photo-trimmed.jpg
75
+ forge photo.jpg --trim --width 1200 --to webp --json # photo-trimmed-1200w.webp
76
+ ```
77
+
78
+ One of `--resize` / `--width` / `--height` at a time; not with `--max-size`,
79
+ `--sharpen`, `--boost`, `--remove-bg` or page operations (`invalid-arguments`).
80
+ Runtime refusals: `resize-too-large` (over 16,384 px a side or 100 MP),
81
+ `nothing-to-trim`, `animated-trim`. MCP: `forge_convert` with `trim: true`
82
+ and/or `resize: { percent | width | height }`; `to` is then optional.
83
+
67
84
  ## Optional extensions: boost and remove background
68
85
 
69
86
  Two image operations are not built in. They are small downloads, installed once,
@@ -71,10 +88,10 @@ and need macOS 14 or later:
71
88
 
72
89
  ```bash
73
90
  forge extensions # what is installed
74
- forge extensions add boost # about 15 MB; sharpen, 2x / 4x; Apple Silicon only for now
91
+ forge extensions add boost # about 15 MB; sharpen, 2x / 3x / 4x; Apple Silicon only for now
75
92
  forge extensions add remove-background # about 32 KB
76
93
  forge photo.jpg --sharpen --json # photo-sharp.png (same size, sharper)
77
- forge photo.jpg --boost --json # photo-2x.png (--boost 4 -> photo-4x.png)
94
+ forge photo.jpg --boost --json # photo-2x.png (--boost 3 -> photo-3x.png, --boost 4 -> photo-4x.png)
78
95
  forge photo.jpg --remove-bg --json # photo-cutout.png
79
96
  ```
80
97
 
@@ -85,9 +102,12 @@ a cutout needs one that carries transparency (png, webp, avif, tiff) and
85
102
  anything else is refused with `invalid-arguments`. If the extension is missing
86
103
  the failure code is `extension-missing`, its hint is the install command, and
87
104
  the exit code is 1: ask the user before installing, since it downloads.
88
- Other codes: `no-subject` (no foreground found) and `boost-too-large`
105
+ Other codes: `no-subject` (no foreground found), `boost-too-large`
89
106
  (the result would pass 16,384 px a side or 100 MP; the hint names the largest
90
- factor that fits).
107
+ factor that fits) and `extension-outdated` (`--boost 3` needs boost 1.1.0 or
108
+ later; the hint is the same `forge extensions add boost`, which updates it).
109
+ While no released boost makes 3x, `--boost 3` is refused with
110
+ `invalid-arguments` and a hint naming the factors that work; don't update then.
91
111
 
92
112
  ## Encrypted PDFs
93
113
 
@@ -113,6 +133,7 @@ exit 1 and a hint; a wrong password has its own hint.
113
133
  - `unsupported-operation`: that page operation does not fit those files (PDFs only; merge needs two or more).
114
134
  - `encrypted-source`: a password is needed, or the one given was wrong.
115
135
  - `extension-missing`: run the hint's `forge extensions add <id>` (with the user's agreement), then retry.
136
+ - `extension-outdated`: the same command updates it (with the user's agreement, it downloads), then retry.
116
137
  - `file-not-found`: check the path; probe reports it per file without failing the rest.
117
138
 
118
139
  ## MCP
@@ -122,7 +143,7 @@ If a `forge` MCP server is connected (tools `forge_probe`, `forge_formats`,
122
143
  `forge_scale`), prefer it. It takes absolute
123
144
  paths and returns the same JSON as `structuredContent`. It never overwrites
124
145
  unless you pass `overwrite: true`, and an encrypted PDF takes a `password`
125
- argument. `forge_convert` also takes `sharpen: true`, `boost: 2 | 4` and `removeBackground: true`
146
+ argument. `forge_convert` also takes `sharpen: true`, `boost: 2 | 3 | 4` and `removeBackground: true`
126
147
  (images only; `to` is then the output format); without the extension they fail
127
148
  with `extension-missing`. A hint that says `--force` means `overwrite: true` there;
128
149
  `--password-stdin` means `password`.
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as i,e as t}from"./chunk-5PYTOHLZ.js";import"./chunk-TMUK2DD3.js";async function l(){let e=await Promise.all(i.map(async n=>await t(n.id)?n.id:null));return new Set(e.filter(n=>n!==null))}export{l as installedExtensionIds};