@visulima/cerebro 3.0.5 → 3.1.0

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 (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +5 -811
  3. package/README.md +41 -0
  4. package/dist/commands/completion-command.d.ts +1 -1
  5. package/dist/commands/completion-command.js +5 -5
  6. package/dist/commands/help-command.d.ts +1 -1
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +1 -1
  9. package/dist/commands/readme-command.js +20 -20
  10. package/dist/commands/version-command.d.ts +1 -1
  11. package/dist/commands/version-command.js +1 -1
  12. package/dist/index.d.ts +284 -7
  13. package/dist/index.js +1 -1
  14. package/dist/logger/create-pail-logger.d.ts +36 -1
  15. package/dist/logger/create-pail-logger.js +1 -1
  16. package/dist/packem_chunks/has-new-version.js +1 -1
  17. package/dist/packem_shared/Cerebro-Dh8am0pz.js +4 -0
  18. package/dist/packem_shared/InvalidArgumentChoiceError-BpovuqrZ.js +1 -0
  19. package/dist/packem_shared/MissingArgumentError-D78kza2a.js +1 -0
  20. package/dist/packem_shared/SurplusArgumentError-BLwT9lo0.js +1 -0
  21. package/dist/packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js +1 -0
  22. package/dist/packem_shared/VisulimaError-BDqtOVL5-Db_MJ_p7.js +1 -0
  23. package/dist/packem_shared/VisulimaError-CuhG0hlQ.js +76 -0
  24. package/dist/packem_shared/cerebro-error-Dv3FuXO8.js +1 -0
  25. package/dist/packem_shared/{command.d-B_G9vIYJ.d.ts → command.d-CLlirnwR.d.ts} +148 -4
  26. package/dist/packem_shared/constants-BKuEbBw1-BRv49X2l.js +1 -0
  27. package/dist/packem_shared/defineCommand-C_isHeEs.js +1 -0
  28. package/dist/packem_shared/format-positional-usage-DWL9qN10.js +6 -0
  29. package/dist/packem_shared/lazyNamed-BKSCmVsV.js +1 -0
  30. package/dist/packem_shared/renderError-CIIYTTfx-BdX-afLI.js +27 -0
  31. package/dist/packem_shared/runtime-process-BN-eTlwy.js +1 -0
  32. package/dist/plugins/error-handler-plugin.d.ts +1 -1
  33. package/dist/plugins/error-handler-plugin.js +1 -1
  34. package/dist/plugins/runtime-version-check-plugin.d.ts +1 -1
  35. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  36. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +1 -1
  37. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  38. package/dist/util/general/heap-tuning.js +1 -1
  39. package/package.json +5 -5
  40. package/dist/packem_shared/Cerebro-58LHN3_T.js +0 -4
  41. package/dist/packem_shared/VERBOSITY_DEBUG-XPultrIA.js +0 -1
  42. package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +0 -1
  43. package/dist/packem_shared/VisulimaError-k1qGkvab.js +0 -76
  44. package/dist/packem_shared/cerebro-error-DWpjBY_M.js +0 -1
  45. package/dist/packem_shared/index-Dpm7gUHe.js +0 -29
  46. package/dist/packem_shared/lazyNamed-DMUm8mZe.js +0 -1
  47. package/dist/packem_shared/renderError-BISXNU8L-B47ZikMV.js +0 -27
  48. package/dist/packem_shared/runtime-process-BEw54Ar-.js +0 -1
  49. package/dist/packem_shared/split-by-case-BZ6XOTIf.js +0 -1
@@ -1,6 +1,41 @@
1
1
  import { InteractiveManager } from '@visulima/interactive-manager';
2
- import { LiteralUnion, Primitive } from 'type-fest';
3
2
  import { AnsiColors } from '@visulima/colorize';
3
+ /**
4
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
5
+
6
+ @category Type
7
+ */
8
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
9
+ /**
10
+ Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
11
+
12
+ Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
13
+
14
+ This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
15
+
16
+ @example
17
+ ```
18
+ import type {LiteralUnion} from 'type-fest';
19
+
20
+ // Before
21
+
22
+ type Pet = 'dog' | 'cat' | string;
23
+
24
+ const petWithoutAutocomplete: Pet = '';
25
+ // Start typing in your TypeScript-enabled IDE.
26
+ // You **will not** get auto-completion for `dog` and `cat` literals.
27
+
28
+ // After
29
+
30
+ type Pet2 = LiteralUnion<'dog' | 'cat', string>;
31
+
32
+ const petWithAutoComplete: Pet2 = '';
33
+ // You **will** get auto-completion for `dog` and `cat` literals.
34
+ ```
35
+
36
+ @category Type
37
+ */
38
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
4
39
  /**
5
40
  * Global namespace for extending Pail's metadata interface.
6
41
  *
@@ -1 +1 @@
1
- import a from"@visulima/pail/processor/caller";import m from"@visulima/pail/processor/message-formatter";import{createPail as l}from"@visulima/pail/server";import{VERBOSITY_DEBUG as p,VERBOSITY_QUIET as E}from"../packem_shared/VERBOSITY_DEBUG-XPultrIA.js";import{c}from"../packem_shared/runtime-process-BEw54Ar-.js";const d=o=>{const i={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},t=[new m],r=c().CEREBRO_OUTPUT_LEVEL;(r===String(128)||r===String(p))&&t.push(new a);const n=(r&&i[r])??"informational",s={...o,logLevel:o?.logLevel??n,processors:o?.processors?[...t,...o.processors]:t},e=l(s);return r===String(E)&&e.disable(),e};export{d as default};
1
+ import a from"@visulima/pail/processor/caller";import c from"@visulima/pail/processor/message-formatter";import{createPail as i}from"@visulima/pail/server";import{VERBOSITY_DEBUG as g,VERBOSITY_QUIET as m}from"../packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js";import{c as f}from"../packem_shared/runtime-process-BN-eTlwy.js";const T=o=>{const t={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},r=[new c],e=f().CEREBRO_OUTPUT_LEVEL;(e===String(128)||e===String(g))&&r.push(new a);const n=(e&&t[e])??"informational",l={...o,logLevel:o?.logLevel??n,processors:o?.processors?[...r,...o.processors]:r},s=i(l);return e===String(m)&&s.disable(),s};export{T as default};
@@ -1 +1 @@
1
- import{createRequire as T}from"node:module";import{findCacheDirSync as F}from"@visulima/find-cache-dir";import{t as U}from"../packem_shared/cerebro-error-DWpjBY_M.js";let b;const k=e=>(b??=T(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,t]=g.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return g.getBuiltinModule(e)}return k(e)},{writeFile:I,readFile:R,mkdir:S,access:$}=w("node:fs/promises"),{get:x}=w("node:https"),N=e=>{const[r,t]=e.split("-");return{nums:r.split(".").map(s=>Number.parseInt(s,10)||0),pre:t}},A=(e,r)=>{const t=N(e),s=N(r),o=Math.max(t.nums.length,s.nums.length);for(let i=0;i<o;i+=1){const n=t.nums[i]??0,l=s.nums[i]??0;if(n>l)return!0;if(n<l)return!1}if(t.pre===void 0&&s.pre!==void 0)return!0;if(t.pre!==void 0&&s.pre===void 0||t.pre===void 0&&s.pre===void 0)return!1;const c=t.pre.split("."),u=s.pre.split("."),a=Math.max(c.length,u.length);for(let i=0;i<a;i+=1){const n=c[i],l=u[i];if(n===void 0)return!1;if(l===void 0)return!0;if(n===l)continue;const f=Number.parseInt(n,10),d=Number.parseInt(l,10),h=!Number.isNaN(f)&&String(f)===n,_=!Number.isNaN(d)&&String(d)===l;return h&&_?f>d:h?!1:_?!0:n>l}return!1},j=/^[A-Z]:\//i,v=(e="")=>e&&e.replaceAll("\\","/").replace(j,r=>r.toUpperCase()),D=/^[/\\]{2}/,M=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,E=/^[A-Z]:$/i,q=/\/$/,H=(e,r)=>{let t="",s=0,o=-1,c=0,u;for(let a=0;a<=e.length;++a){if(a<e.length)u=e[a];else{if(u==="/")break;u="/"}if(u==="/"){if(!(o===a-1||c===1))if(c===2){if(t.length<2||s!==2||!t.endsWith(".")||t.at(-2)!=="."){if(t.length>2){const i=t.lastIndexOf("/");i===-1?(t="",s=0):(t=t.slice(0,i),s=t.length-1-t.lastIndexOf("/")),o=a,c=0;continue}else if(t.length>0){t="",s=0,o=a,c=0;continue}}r&&(t+=t.length>0?"/..":"..",s=2)}else t.length>0?t+=`/${e.slice(o+1,a)}`:t=e.slice(o+1,a),s=a-o-1;o=a,c=0}else u==="."&&c!==-1?++c:c=-1}return t},m=e=>M.test(e),V=function(e){if(e.length===0)return".";e=v(e);const r=D.exec(e),t=m(e),s=e.at(-1)==="/";return e=H(e,!t),e.length===0?t?"/":s?"./":".":(s&&(e+="/"),E.test(e)&&(e+="/"),r?t?`//${e}`:`//./${e}`:t&&!m(e)?`/${e}`:e)},J=(...e)=>{let r="";for(const t of e)if(t)if(r.length>0){const s=r.at(-1)==="/",o=t[0]==="/";s&&o?r+=t.slice(1):r+=s||o?t:`/${t}`}else r+=t;return V(r)},P=e=>{const r=v(e).replace(q,""),t=r.lastIndexOf("/");if(t===-1)return m(e)?"/":".";const s=r.slice(0,t);return E.test(s)?`${s}/`:s||(m(e)?"/":".")};class p extends U{constructor(r,t="UPDATE_NOTIFIER_ERROR",s){super(r,t,s),this.name="UpdateNotifierError"}}const B="last-update-check.json",y={access:(e,r)=>$(e,r),mkdir:(e,r)=>S(e,r),readFile:(async(e,r)=>r===void 0?R(e):R(e,r)),writeFile:(e,r,t)=>I(e,r,t)},O=async(e,r)=>{try{return await e.access(r),!0}catch{return!1}},C=e=>{const r=F(e);if(r===void 0)throw new p("Could not find cache directory","CACHE_DIRECTORY_NOT_FOUND",{packageName:e});return J(r,B)},L=async(e,r=y)=>{const t=C(e);try{if(!await O(r,t))return;const{lastUpdateCheck:s}=JSON.parse(await r.readFile(t,"utf8"));return s}catch{return}},Z=async(e,r=y)=>{const t=C(e),s=P(t);await O(r,s)||await r.mkdir(s,{recursive:!0}),await r.writeFile(t,JSON.stringify({lastUpdateCheck:Date.now()}),"utf8")},W=5e3,Y=async(e,r,t,s=W)=>{const o=t.replace("__NAME__",e),c=512*1024;return await new Promise((u,a)=>{const i=x(o,{timeout:s},n=>{if(n.statusCode!==void 0&&(n.statusCode<200||n.statusCode>=300)){a(new p(`Unexpected status code ${String(n.statusCode)}`,"VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.resume();return}let l="",f=!1;n.on("data",d=>{f||(l+=String(d),l.length>c&&(f=!0,a(new p("Response too large","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.destroy()))}),n.on("end",()=>{if(!f)try{const d=JSON.parse(l)[r];if(!d){a(new p("Error getting version","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}));return}u(d)}catch{a(new p("Could not parse version response","VERSION_PARSE_ERROR",{distributionTag:r,packageName:e}))}})});i.on("timeout",()=>{i.destroy(new p("Request timed out","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}))}),i.on("error",n=>{a(n)})})},Q=async({alwaysRun:e,debug:r,distTag:t="latest",fs:s,pkg:o,registryUrl:c="https://registry.npmjs.org/-/package/__NAME__/dist-tags",timeout:u,updateCheckInterval:a=1e3*60*60*24})=>{const i=await L(o.name,s);if(e||!i||i<Date.now()-a){const n=await Y(o.name,t,c,u);if(await Z(o.name,s),A(n,o.version))return n;r&&console.error(`Latest version (${n}) not newer than current version (${o.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${String(a)}ms but only ${String(Date.now()-i)}ms since last check.`)};export{Q as default};
1
+ import{createRequire as F}from"node:module";import{findCacheDirSync as $}from"@visulima/find-cache-dir";import{C as b}from"../packem_shared/cerebro-error-Dv3FuXO8.js";let S;const I=e=>(S??=F(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[r,t]=h.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return h.getBuiltinModule(e)}return I(e)},{writeFile:x,readFile:R,mkdir:A,access:U}=w("node:fs/promises"),{get:D}=w("node:https"),v=e=>{const[r,t]=e.split("-");return{nums:r.split(".").map(o=>Number.parseInt(o,10)||0),pre:t}},T=(e,r)=>{const t=v(e),n=v(r),o=Math.max(t.nums.length,n.nums.length);for(let c=0;c<o;c+=1){const s=t.nums[c]??0,u=n.nums[c]??0;if(s>u)return!0;if(s<u)return!1}if(t.pre===void 0&&n.pre!==void 0)return!0;if(t.pre!==void 0&&n.pre===void 0||t.pre===void 0&&n.pre===void 0)return!1;const a=t.pre.split("."),l=n.pre.split("."),i=Math.max(a.length,l.length);for(let c=0;c<i;c+=1){const s=a[c],u=l[c];if(s===void 0)return!1;if(u===void 0)return!0;if(s===u)continue;const f=Number.parseInt(s,10),d=Number.parseInt(u,10),_=!Number.isNaN(f)&&String(f)===s,E=!Number.isNaN(d)&&String(d)===u;return _&&E?f>d:_?!1:E?!0:s>u}return!1},M=/^[A-Z]:\//i,g=(e="")=>e&&e.replaceAll("\\","/").replace(M,r=>r.toUpperCase()),V=/^[/\\]{2}/,q=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,y=/^[A-Z]:$/i,B=/\/$/,j=(e,r)=>{let t="",n=0,o=-1,a=0,l;for(let i=0;i<=e.length;++i){if(i<e.length)l=e[i];else{if(l==="/")break;l="/"}if(l==="/"){if(!(o===i-1||a===1))if(a===2){if(t.length<2||n!==2||!t.endsWith(".")||t.at(-2)!=="."){if(t.length>2){const c=t.lastIndexOf("/");c===-1?(t="",n=0):(t=t.slice(0,c),n=t.length-1-t.lastIndexOf("/")),o=i,a=0;continue}else if(t.length>0){t="",n=0,o=i,a=0;continue}}r&&(t+=t.length>0?"/..":"..",n=2)}else t.length>0?t+=`/${e.slice(o+1,i)}`:t=e.slice(o+1,i),n=i-o-1;o=i,a=0}else l==="."&&a!==-1?++a:a=-1}return t},m=e=>q.test(e),H=function(e){if(e.length===0)return".";e=g(e);const r=V.exec(e),t=m(e),n=e.at(-1)==="/";return e=j(e,!t),e.length===0?t?"/":n?"./":".":(n&&(e+="/"),y.test(e)&&(e+="/"),r?t?`//${e}`:`//./${e}`:t&&!m(e)?`/${e}`:e)},L=(...e)=>{let r="";for(const t of e)if(t)if(r.length>0){const n=r.at(-1)==="/",o=t[0]==="/";n&&o?r+=t.slice(1):r+=n||o?t:`/${t}`}else r+=t;return H(r)},P=e=>{const r=g(e).replace(B,""),t=r.lastIndexOf("/");if(t===-1)return m(e)?"/":".";const n=r.slice(0,t);return y.test(n)?`${n}/`:n||(m(e)?"/":".")};class p extends b{constructor(r,t="UPDATE_NOTIFIER_ERROR",n){super(r,t,n),this.name="UpdateNotifierError"}}const Z="last-update-check.json",N={access:(e,r)=>U(e,r),mkdir:(e,r)=>A(e,r),readFile:(async(e,r)=>r===void 0?R(e):R(e,r)),writeFile:(e,r,t)=>x(e,r,t)},O=async(e,r)=>{try{return await e.access(r),!0}catch{return!1}},C=e=>{const r=$(e);if(r===void 0)throw new p("Could not find cache directory","CACHE_DIRECTORY_NOT_FOUND",{packageName:e});return L(r,Z)},J=async(e,r=N)=>{const t=C(e);try{if(!await O(r,t))return;const{lastUpdateCheck:o}=JSON.parse(await r.readFile(t,"utf8"));return o}catch{return}},G=async(e,r=N)=>{const t=C(e),n=P(t);await O(r,n)||await r.mkdir(n,{recursive:!0}),await r.writeFile(t,JSON.stringify({lastUpdateCheck:Date.now()}),"utf8")},X=5e3,Y=async(e,r,t,n=X)=>{const o=t.replace("__NAME__",e),a=512*1024;return await new Promise((l,i)=>{const c=D(o,{timeout:n},s=>{if(s.statusCode!==void 0&&(s.statusCode<200||s.statusCode>=300)){i(new p(`Unexpected status code ${String(s.statusCode)}`,"VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),s.resume();return}let u="",f=!1;s.on("data",d=>{f||(u+=String(d),u.length>a&&(f=!0,i(new p("Response too large","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),s.destroy()))}),s.on("end",()=>{if(!f)try{const _=JSON.parse(u)[r];if(!_){i(new p("Error getting version","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}));return}l(_)}catch{i(new p("Could not parse version response","VERSION_PARSE_ERROR",{distributionTag:r,packageName:e}))}})});c.on("timeout",()=>{c.destroy(new p("Request timed out","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}))}),c.on("error",s=>{i(s)})})},z=async({alwaysRun:e,debug:r,distTag:t="latest",fs:n,pkg:o,registryUrl:a="https://registry.npmjs.org/-/package/__NAME__/dist-tags",timeout:l,updateCheckInterval:i=1e3*60*60*24})=>{const c=await J(o.name,n);if(e||!c||c<Date.now()-i){const s=await Y(o.name,t,a,l);if(await G(o.name,n),T(s,o.version))return s;r&&console.error(`Latest version (${s}) not newer than current version (${o.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${String(i)}ms but only ${String(Date.now()-c)}ms since last check.`)};export{z as default};
@@ -0,0 +1,4 @@
1
+ import{createRequire as ct}from"node:module";import{VERBOSITY_DEBUG as V,POSITIONALS_KEY as oe,VERBOSITY_NORMAL as le,VERBOSITY_QUIET as vt,VERBOSITY_VERBOSE as At}from"./VERBOSITY_DEBUG-D7HfSD5l.js";import{C as N}from"./cerebro-error-Dv3FuXO8.js";import{c as re,d as we,o as Ne,e as F,a as Ct,b as bt,f as Nt,h as Ot,i as _t}from"./runtime-process-BN-eTlwy.js";import{c as ee}from"./VisulimaError-BDqtOVL5-Db_MJ_p7.js";import xt from"./InvalidArgumentChoiceError-BpovuqrZ.js";import Et from"./MissingArgumentError-D78kza2a.js";import kt from"./SurplusArgumentError-BLwT9lo0.js";import{X as It,O as $t,H as ie,c as q,M as X,k as P,F as ce,m as Oe,Q as _e,Y as Pt,U as xe,$ as Lt,W as Ee,d as ke,C as Ie,D as Ut,G as Mt,P as St,l as Tt,y as Dt,z as Vt,Z as jt,b as Rt,f as Bt,q as zt,j as Ft,v as Wt,J as qt,K as Gt,h as Kt,V as Ht}from"./constants-BKuEbBw1-BRv49X2l.js";import{distance as Xt}from"fastest-levenshtein";let ht;const ut=t=>(ht??=ct(import.meta.url))(t),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pt=t=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[e,n]=Z.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Z.getBuiltinModule(t)}return ut(t)},{writeFile:ft,stat:dt,rm:gt,readFile:be,readdir:mt,mkdir:wt,access:yt}=pt("node:fs/promises"),te=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];class B extends N{commandName;constructor(e,n=[]){const s=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(s,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}}class Ke extends N{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}}class Yt extends N{unknownOptions;constructor(e,n){const s=e.join(", "),i=`Found unknown ${e.length===1?"option":"options"}: ${s}`;super(i,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}}class Jt extends N{pluginName;constructor(e,n,s){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:s,pluginName:e}),this.name="PluginError",this.pluginName=e,s&&(this.cause=s)}}class Zt{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);re().CEREBRO_OUTPUT_LEVEL===String(V)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const s of n)if(typeof s.init=="function"){this.logger.debug(`initializing plugin: ${s.name}`);try{await s.init(e)}catch(i){const o=new Jt(s.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(o.message),o}}this.initialized=!0}async executeLifecycle(e,n,s){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const o of i){const c=o[e];if(typeof c=="function"){this.logger.debug(`executing ${e} hook for plugin: ${o.name}`);try{await(e==="afterCommand"?c(n,s):c(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${o.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const s=this.getDependencyOrder();for(const i of s)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(e,n)}catch(o){this.logger.error(`Error in error handler for plugin "${i.name}":`,o)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,s=new Set,i=o=>{if(n.has(o))return;if(s.has(o))throw new Error(`Circular dependency detected involving plugin "${o}"`);const c=this.plugins.get(o);if(!c)throw new Error(`Plugin "${o}" not found`);if(s.add(o),c.dependencies)for(const a of c.dependencies)i(a);s.delete(o),n.add(o),e.push(c)};for(const o of this.plugins.keys())i(o);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}}const Q=t=>t.type?.name==="Boolean",Qt=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},$e=t=>(Q(t)||(t.typeLabel=t.typeLabel??Qt(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),en=new RegExp(/^-([^\d-])$/),tn=new RegExp(/^--(\S+)/),nn=new RegExp(/^-([^\d-]{2,})$/),sn=t=>en.test(t)||tn.test(t)||nn.test(t),on=(t,e)=>{const n=e[0]&&sn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const s=new Error(`Command not recognised: ${String(n)}`);throw s.command=n,s.name="INVALID_COMMAND",s}return{argv:e,command:n}};class Ae extends ee{optionName;value;constructor(e,n,s){super({hint:`Pass a valid ${s} value for '${e}'.`,message:`Invalid ${s} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,Ae.prototype)}}let rn=class He extends ee{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,He.prototype)}},Pe=class Xe extends ee{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,Xe.prototype)}};class Ce extends ee{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,Ce.prototype)}}let L=class Ye extends ee{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,Ye.prototype)}};const G=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",ye=t=>t===Number||typeof t=="function"&&t.name==="Number",Le=t=>t===String||typeof t=="function"&&t.name==="String",Ue=(t,e,n)=>{const s=Number(t);if(e&&Number.isNaN(s)&&String(t).trim().toLowerCase()!=="nan")throw new Ae(n??"",String(t),"Number");return s},an=(t,e,n={})=>{const{optionName:s,strictTypes:i}=n;return Array.isArray(t)?G(e)?t.map(Boolean):ye(e)?t.map(o=>Ue(o,i,s)):Le(e)?t.map(String):t.map(o=>e(String(o))):t===null?null:G(e)?!!t:ye(e)?Ue(t,i,s):Le(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},E=(t,e,n,...s)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...s)},ln=/-([a-z])/g,cn=/^\d+$/,hn=t=>t.codePointAt(0)===95,Me=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Se=t=>t==="__proto__"||t==="constructor"||t==="prototype",he=(t,e,n,s=!1)=>{t[e]===void 0?t[e]=s?[n]:n:s&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},Te=(t,e,n,s,i)=>{let o=e.get(t)??n.get(t);if(!o&&s){const c=t.toLowerCase();o=s.get(c)??i?.get(c)}return o},un=(t,e,n,s)=>{const i=n.debug??!1;E(i,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),E(i,"Starting argument resolution","resolver"),E(i,"Tokens:","resolver",t),E(i,"Definitions:","resolver",e),E(i,"Processing tokens...","resolver");const o=new Map,c=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,l=n.camelCase?new Map:void 0;for(const f of e)if(o.set(f.name,f),f.alias&&c.set(f.alias,f),n.caseInsensitive&&a&&(a.set(f.name.toLowerCase(),f),f.alias&&u&&u.set(f.alias.toLowerCase(),f)),n.camelCase&&r&&l){const w=f.name.replaceAll(ln,(v,I)=>I.toUpperCase());r.set(f.name,w),l.set(w,f.name)}const p=Object.create(null),h=Object.create(null),m=[],d=[],y=new Set;let A=!1;const g=e.find(f=>f.defaultOption),C=e.some(f=>f.group),O=e.find(f=>ye(f.type));for(let f=0;f<t.length;f++){const w=t[f];if(w.kind==="option-terminator"){p._unknown=s.slice(w.index),A=!0;break}if(w.kind==="option"&&w.name){let v=Te(w.name,o,c,a,u);!v&&w.value===void 0&&O&&cn.test(w.name)&&(v=O,w.value=w.name,w.name=O.name);let I=!1;if(!v&&n.negation&&w.value===void 0&&w.name.startsWith("no-")){const _=w.name.slice(3),M=Te(_,o,c,a,u);M?.type&&G(M.type)&&(v=M,I=!0)}const b=v?v.name:w.name,$=v?.multiple,U=v?.lazyMultiple;if(Object.hasOwn(h,b)&&h[b]!==void 0&&!$&&!U&&!n.partial)throw new rn(b);if(!v&&n.partial){const _=w.rawName??`--${w.name}${w.value!==void 0&&w.inlineValue?`=${w.value}`:""}`;m.push({index:w.index,value:_});continue}if(!v&&n.stopAtFirstUnknown){p._unknown=s.slice(w.index);break}if(!v&&!n.partial)throw new Pe(w.name);if(w.value===void 0){const _=t[f+1],M=_?.kind==="option"&&!("name"in _)&&_.value!==void 0,T=_&&v&&!(v.type&&G(v.type))&&(_.kind==="positional"||M),lt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(T&&(!v?.defaultOption||lt))if($){let D=f+1;const ae=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)ae.push(t[D].value),y.add(t[D].index),D++;h[b]=h[b]===void 0?ae:Me(h[b],ae),f=D-1}else U?(he(h,b,_.value,!0),y.add(_.index),f++):(h[b]=_.value,y.add(_.index),f++);else v?.type&&G(v.type)?he(h,b,!I,$):($||U)&&h[b]!==void 0?he(h,b,null,!0):h[b]=$?[]:null}else{let{value:_}=w;if(v?.type&&G(v.type))switch(_){case"":{if(n.partial){const T=`${w.rawName??`--${w.name}`}${w.value?`=${w.value}`:""}`;d.push({index:w.index,value:T}),_=!0}else throw new Pe(w.name);break}case"false":{_=!1;break}case"true":{_=!0;break}default:_=!0}const M=[_];if($){let T=f+1;for(;T<t.length&&t[T].kind==="positional";)M.push(t[T].value),y.add(t[T].index),T++;f=T-1}h[b]===void 0?h[b]=$||U?M:_:$||U?h[b]=Me(h[b],M):h[b]=_}}else if(w.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(w.index)&&!g){E(i,`Found unconsumed positional token at index ${String(w.index)}, stopping processing`,"resolver"),p._unknown=s.slice(w.index);break}}for(const[f,w]of Object.entries(h)){const v=o.get(f);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(w)&&(h[f]=[w])}const k=f=>f.kind==="option"&&!o.has(f.name??"")&&!c.has(f.name??"")&&(!n.caseInsensitive||!a?.has(f.name?.toLowerCase()??"")&&!u?.has(f.name?.toLowerCase()??""));let x=-1,H=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!A&&(x=t.findIndex(f=>k(f)),x!==-1&&(H=t[x].index)),g){const f=[],w=[];for(const v of t)v.kind==="positional"&&!y.has(v.index)&&v.index<H&&(f.push(v.value),w.push(v));if(f.length>0){const v=h[g.name],I=g.multiple??g.lazyMultiple;v===void 0?I?(w.forEach(b=>y.add(b.index)),h[g.name]=f):(y.add(w[0].index),h[g.name]=f[0]):I&&(w.forEach(b=>y.add(b.index)),h[g.name]=Array.isArray(v)?[...f,...v]:[...f,v])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!y.has(f.index))throw new Ce(s[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...m];for(const w of d)f.push({index:w.index,value:w.value});for(const w of t)w.kind==="positional"&&!y.has(w.index)&&f.push({index:w.index,value:s[w.index]});f.length>0&&(f.sort((w,v)=>w.index-v.index),p._unknown=f.map(w=>w.value))}if(n.stopAtFirstUnknown&&!A){const f=t.findIndex(v=>v.kind==="positional"&&!y.has(v.index));let w=-1;if(x!==-1&&f!==-1?w=Math.min(x,f):x!==-1?w=x:f!==-1&&(w=f),w>=0){const v=t[w].index;p._unknown=s.slice(v)}}for(const[f,w]of Object.entries(h)){const v=n.camelCase?r?.get(f)??f:f,I=o.get(f);I?.type?p[v]=an(w,I.type,{optionName:I.name,strictTypes:n.strictTypes}):p[v]=w===void 0?null:w}for(const f of e){const w=n.camelCase?r?.get(f.name)??f.name:f.name;!(w in p)&&f.defaultValue!==void 0&&(f.multiple??f.lazyMultiple?p[w]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:p[w]=f.defaultValue)}if(C){const f={},w={},v={};for(const b of e)if(b.group){const $=Array.isArray(b.group)?b.group:[b.group];for(const U of $)Se(U)||(f[U]??={})}for(const b of Object.keys(p))if(!hn(b)){w[b]=p[b];let $=b;n.camelCase&&($=l?.get(b)??b);const U=o.get($);if(U?.group){const _=Array.isArray(U.group)?U.group:[U.group];for(const M of _)Se(M)||f[M]&&(f[M][b]=p[b])}else v[b]=p[b]}const I={_all:w};for(const[b,$]of Object.entries(f))I[b]=$;Object.keys(v).length>0&&(I._none=v),p._unknown&&(I._unknown=p._unknown),Object.keys(p).forEach(b=>delete p[b]),Object.assign(p,I)}const S=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));return E(i,"Final parsed result:","resolver",S),S},Je="-",J=Je.codePointAt(0),K="=",pn=K.codePointAt(0),fn="--",dn=Je,gn="--",Ze=t=>t.length>2&&t.startsWith(gn),mn=t=>Ze(t)&&!t.includes(K,3),wn=t=>Ze(t)&&t.includes(K,3),yn=t=>{if(t.length!==2||t.codePointAt(0)!==J||t.codePointAt(1)===J)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},vn=t=>{if(t.length<=2||t.codePointAt(0)!==J||t.codePointAt(1)===J)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},An=t=>{const e=[];let n=0,s=[],i=0,o=-1,c=0;for(;i<s.length||n<t.length;){let a;if(i<s.length?(a=s[i],i++):(a=t[n],n++),c>0?c--:o++,a===fn){e.push({index:o,kind:"option-terminator"});const u=[...s.slice(i),...t.slice(n)],r=u.map((l,p)=>({index:o+p+1,kind:"positional",value:l}));e.push(...r),o+=u.length;break}if(yn(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(vn(a)&&!a.includes(K)){const u=[];let r="",l=!1;for(let p=1;p<a.length;p++){const h=a.charAt(p);l?r+=h:h.codePointAt(0)===pn?l=!0:u.push(`${dn}${h}`)}if(l)if(u.length>0){const p=u.pop();u.push(`${p}=${r}`)}else u.push(r);s=i<s.length?[...u,...s.slice(i)]:u,i=0,c=u.length;continue}if(mn(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(wn(a)){const u=a.indexOf(K),r=a.slice(2,u),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}if(a.length>2&&a.codePointAt(0)===J&&a.codePointAt(1)!==J&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}e.push({index:o,kind:"positional",value:a})}return e},Cn=/\d/,bn=t=>typeof t=="function",Nn=(t,e,n)=>{const s=n?.debug??!1;E(s,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,o=new Set,c=new Set,a=new Set;let u=0;for(const r of t){if(E(s,"Checking definition:","validation",r),!r.name)throw E(s,"Validation failed: name is required","validation"),new L("Invalid option definition: name is required");if(typeof r.name!="string")throw new L("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new L("Invalid option definition: name cannot be empty");const l=e?r.name.toLowerCase():"";if(i.has(r.name)||e&&c.has(l))throw new L(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(l))throw new L(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(i.add(r.name),e&&c.add(l),r.alias!==void 0){if(typeof r.alias!="string")throw new L("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new L("Invalid option definition: alias must be a single character");if(Cn.test(r.alias))throw new L("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new L('Invalid option definition: alias cannot be "-"');const p=e?r.alias.toLowerCase():"";if(o.has(r.alias)||e&&a.has(p))throw new L(`Invalid option definition: duplicate alias '${r.alias}'`);if(i.has(r.alias)||e&&c.has(p))throw new L(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);o.add(r.alias),e&&a.add(p)}if(r.defaultOption&&(u++,r.type!==void 0&&G(r.type)))throw new L("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&bn(r.type)))throw new L("Invalid option definition: invalid type")}if(u>1)throw E(s,"Validation failed: multiple defaultOptions not allowed","validation"),new L("Invalid option definition: multiple defaultOptions not allowed");E(s,"Validation completed successfully","validation")};function On(t,e={}){const n=e.debug??!1;E(n,"Starting command-line-args parsing","index"),E(n,"Options:","index",e);const s={...e};s.stopAtFirstUnknown&&(s.partial=!0);const i=Array.isArray(t)?t:[t];E(n,"Normalized definitions:","index",i),Nn(i,s.caseInsensitive,n?s:void 0);let{argv:o}=s;o??=process.argv.slice(2),E(n,"Using argv:","index",o);let c=o;s.caseInsensitive&&(c=o.map(r=>{if(r.startsWith("--")){const l=r.indexOf("="),p=(l===-1?r.slice(2):r.slice(2,l)).toLowerCase();return l===-1?`--${p}`:`--${p}${r.slice(l)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const l=r.indexOf("="),p=l===-1?r.slice(1):r.slice(1,l);if(!p)return r;const h=p.toLowerCase();return l===-1?`-${h}`:`-${h}${r.slice(l)}`}return r}));const a=An(c.map(String));E(n,"Tokenized arguments:","index",a);const u=un(a,i,s,o);return E(n,"Command-line-args parsing completed","index"),u}class _n{result;argv;options;argument;args;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}class ue extends N{commandName;constructor(e,n,s){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",s!==void 0&&(this.cause=s)}}const xn=/^-{1,2}(\w+)(=(.+))?$/,Qe=(t,e,n,s)=>{const i=xn.exec(t);if(i===null)return{};const o=i[1];if(!o)return{};const c=n&&s?n.get(o)??s.get(o):e.find(a=>a.name===o||a.alias===o);return c!==void 0?{argName:c.name,argValue:i[3],option:c}:{}},De=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},En=new Set(["0","1","false","true"]),kn=(t,e,n,s)=>{if(e.length===0||t.length===0)return{};const i=(o,c)=>{const{argName:a,argValue:u,option:r}=Qe(c,e,n,s),{lastOption:l}=o;return r&&Q(r)&&u&&a?o.partial[a]=De(u,r):o.lastName&&l&&Q(l)&&En.has(c)&&(o.partial[o.lastName]=De(c,l)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(i,{partial:{}}).partial},In=new Set(["0","1","false","true"]),$n=(t,e,n,s)=>{if(e.length===0||t.length===0)return t;const i=(o,c)=>{const{argValue:a,option:u}=Qe(c,e,n,s),{lastOption:r}=o;if(r&&Q(r)&&In.has(c)){const{args:p}=o;return{args:p.slice(0,-1)}}return u&&Q(u)&&a?{args:o.args}:{args:[...o.args,c],lastOption:u}};return t.reduce(i,{args:[]}).args},Ve=t=>{const e=new Map;for(const n of t){const s=e.get(n.name);s?e.set(n.name,{...s,...n}):e.set(n.name,n)}return[...e.values()]},Pn=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Ln=(t,e)=>{if(!t.type)return e;if(e===void 0)return;if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return Pn(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const o=Number.parseFloat(e);return Number.isNaN(o)?void 0:o}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)},Un=/_./g,Mn=/^[A-Z]/,Sn=t=>t.toLowerCase().replaceAll(Un,e=>e[1]?.toUpperCase()??e).replace(Mn,e=>e.toLowerCase()),Tn=(t,e=re())=>{if(!t||t.length===0)return{};const n={};for(const s of t){const i=e[s.name],o=Ln(s,i),c=o===void 0?s.defaultValue:o,a=Sn(s.name);n[a]=c}return n},Dn=/-([a-z])/g,et=t=>t.replaceAll(Dn,(e,n)=>n.toUpperCase()),je=(t,e)=>t.type===void 0?e:t.type(e),Vn=(t,e)=>{const{choices:n}=t;if(!n||n.length===0)return[];const s=[];for(const i of e)n.includes(i)||s.push({choices:n,name:t.name,value:i});return s},jn=(t,e)=>e&&t.defaultValue!==void 0&&!Array.isArray(t.defaultValue)?[t.defaultValue]:t.defaultValue,Rn=(t,e)=>{const n={},s=[],i=[],o=t.length-1;let c=0;for(const[a,u]of t.entries()){const r=et(u.name),l=a===o&&u.multiple===!0,p=l?e.slice(a):e.slice(a,a+1);if(p.length===0){u.required===!0&&s.push(u.name),n[r]=jn(u,l);continue}i.push(...Vn(u,p)),c=a+p.length,n[r]=l?p.map(h=>je(u,h)):je(u,p[0])}return{invalid:i,missing:s,resolved:n,surplus:e.slice(c)}},Bn=t=>{const e=new Map,n=new Map;for(const s of t)if(e.set(s.name,s),s.alias){const i=Array.isArray(s.alias)?s.alias:[s.alias];for(const o of i)n.set(o,s)}return{optionMapByAlias:n,optionMapByName:e}},tt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ue(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(s){throw new ue(t.name,s instanceof Error?s.message:String(s),s)}const n=e.default;if(typeof n!="function")throw new ue(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},zn=(t,e,n,s,i)=>{const o=new _n(t.name,t),{_all:c,_unknown:a,positionals:u}=e,l=Object.keys(n).length>0?{...c,...n}:c;oe in l&&delete l[oe],o.argument=u?.[oe]??[],o.args={},o.rawUnknown=[...a??[]];const p=Object.keys(s).length>0;return o.options=p?{...l,...s}:l,o.env=Tn(t.env,i),o},Fn=(t,e,n)=>{const s=t.options??[],i=s.length>0;let o=Ve(i?[...s,...n]:n);if(o.length>0){for(const l of o)if(l.multiple&&l.lazyMultiple)throw new Error(`Argument "${l.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}const c=t.arguments!==void 0&&t.arguments.length>0;(t.argument||c)&&(o=[{defaultOption:!0,description:t.argument?.description,group:"positionals",multiple:!0,name:oe,type:t.argument?.type??String,typeLabel:t.argument?.typeLabel},...o]);let a,u;if(i){const{optionMapByAlias:l,optionMapByName:p}=Bn(s);a=$n(e,s,p,l),u=kn(e,s,p,l)}else a=e,u={};const r=On(o,{argv:a,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:u,parsedArgs:r}},pe=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await tt(t))(e),Wn=(t,e)=>{if(!t.arguments||t.arguments.length===0)return;const n=e.rawUnknown.indexOf("--"),s=n===-1?[]:e.rawUnknown.slice(n+1),i=s.length===0?e.argument:e.argument.slice(0,Math.max(0,e.argument.length-s.length)),o=Rn(t.arguments,i);if(e.args=o.resolved,o.missing.length>0)throw new Et(t.name,o.missing);const[c]=o.invalid;if(c)throw new xt(c.name,c.value,c.choices);if(o.surplus.length>0)throw new kt(t.name,o.surplus,t.arguments.length)};let qn=class{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};const Gn=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Kn=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),Hn=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(Kn,"")},fe=new qn(1e3),Xn=/[.*+?^${}()|[\]\\]/g,Yn=t=>{const e=t.join("");if(fe.has(e)){const i=fe.get(e);return i.lastIndex=0,i}const n=t.map(i=>i.replaceAll(Xn,String.raw`\$&`)).join("|"),s=new RegExp(n,"g");return fe.set(e,s),s},Jn=t=>{const e=[];let n=0,s;for(q.lastIndex=0;(s=q.exec(t))!==null;)s.index>n&&e.push(t.slice(n,s.index)),e.push(s[0]),n=q.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},Zn=/[ČŠŽĐ]/i,nt=new Uint8Array(128),st=new Uint8Array(128),ot=new Uint8Array(128);for(let t=0;t<128;t++)nt[t]=t>=65&&t<=90?1:0,st[t]=t>=97&&t<=122?1:0,ot[t]=t>=48&&t<=57?1:0;const de=t=>nt[t],Re=t=>st[t],ge=t=>ot[t],j=(t,e,n,s,i)=>{if(t.length===0)return[];let o=!1;const c=Object.values(e);for(const m of c)if(m(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],l="other";const p=Object.entries(e);for(const m of p){const[d,y]=m;if(y(a[0])){l=d;break}}let h=n&&s?a[0]===a[0].toLocaleUpperCase(s):!1;for(let m=1;m<a.length;m++){const d=a[m];let y="other";for(const C of p){const[O,k]=C;if(k(d)){y=O;break}}const A=n&&s?d===d.toLocaleUpperCase(s):!1;let g=!1;i?g=i(l,y,h,A,d,m,a):(l!==y&&l!=="other"&&y!=="other"&&(g=!0),n&&y!=="other"&&!h&&A&&(g=!0)),g?(u.push(r),r=d):r+=d,l=y,n&&(h=A)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},Qn=(t,e,n,s)=>{if(n.size===0)return e;for(const i of n)if(t.startsWith(i,e))return s.push(i),e+i.length;return e},it=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const s=[],i=t.length;for(let o=1;o<i;o++){const c=Qn(t,n,e,s);if(c!==n){n=c,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&de(a),l=u&&u<128&&de(u),p=a&&a<128&&Re(a),h=a&&a<128&&ge(a),m=u&&u<128&&ge(u);if(p&&l){s.push(t.slice(n,o)),n=o;continue}if(h&&!m||!h&&m){s.push(t.slice(n,o)),n=o;continue}if(m&&!h){let d=!1,y=!1;if(o+1<i){const A=t.codePointAt(o+1);d=A&&A<128&&de(A),y=A&&A<128&&ge(A)}if(!y&&d){s.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<i){const d=t.codePointAt(o+1),y=d&&d<128&&Re(d);if(r&&l&&y){const A=t.slice(n,o+1);e.has(A)||(s.push(t.slice(n,o)),n=o)}}}return n<i&&s.push(t.slice(n)),s.filter(o=>o!=="")},rt=(t,e,n)=>{if(t.length===0)return[];const s=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!s&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],l=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e),d=m,y=m?0:-1;for(let A=1;A<l;A++){const g=r[A],C=g===g.toLocaleUpperCase(e);if(C===m)h+=g;else if(C)h&&h.length>0&&(p.push(h),h=g),d=!0,y=A;else{if(d&&A-y>1){const O=r[A-1],k=h.slice(0,-1);k&&k.length>0&&p.push(k),h=O+g}else h+=g;d=!1,y=-1}m=C}return h&&h.length>0&&p.push(h),p}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!P.test(t))return[t];const r=[...t],l=r.length,p=[];let h=r[0];const m=r[0];let d;X.test(m)?d=1:P.test(m)?d=2:d=0;let y=m===m.toLocaleUpperCase(e);for(let g=1;g<l;g++){const C=r[g];let O;X.test(C)?O=1:P.test(C)?O=2:O=0;const k=C===C.toLocaleUpperCase(e);d!==O&&(d===1||d===2)&&(O===1||O===2)||O===d&&!y&&k?(p.push(h),h=C):h+=C,d=O,y=k}h&&h.length>0&&p.push(h);const A=[];for(let g=0;g<p.length;g++)g<p.length-1&&p[g].length===1&&P.test(p[g])&&X.test(p[g+1][0])?(A.push(p[g]+p[g+1]),g+=1):A.push(p[g]);return A}if(e.startsWith("el")){if(!ce.test(t)&&!P.test(t))return[t];const r=[];Oe.lastIndex=0;let l;for(;(l=Oe.exec(t))!==null;)r.push(l[0]);r.length===0&&r.push(t);const p=[];if(r.length===1){const h=r[0];if(!h||!ce.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!ce.test(h[0])||h.length===1){p.push(h);continue}const m=h.length;let d=h[0],y=h[0]===h[0].toLocaleUpperCase(e);for(let A=1;A<m;A++){const g=h[A],C=g===g.toLocaleUpperCase(e);!y&&C?(p.push(d),d=g):d+=g,y=C}d&&p.push(d)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),l=r?{hiragana:h=>Lt.test(h),kanji:h=>xe.test(h),katakana:h=>Pt.test(h),latin:h=>P.test(h)}:{hangul:h=>Ee.test(h),latin:h=>P.test(h)},p=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=j(t,l,!1,e,(d,y)=>d==="hiragana"&&y==="katakana"||d==="katakana"&&y==="hiragana"||d==="hiragana"&&y==="latin"||d==="katakana"&&y==="latin"||d==="kanji"&&y==="latin"||d==="latin"&&(y==="hiragana"||y==="katakana"||y==="kanji")),m=[];for(const d of h){const y=d;y.length===1&&p.has(y)&&m.length>0?m[m.length-1]=m.at(-1)+y:m.push(y)}return m.length>0?m:[t]}return j(t,l,!1,e,(h,m)=>h==="hangul"&&m==="latin"||h==="latin"&&m==="hangul")}if(e.startsWith("sl")){const r=[...t],l=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let d=1;d<l;d++){const y=r[d],A=y===y.toLocaleUpperCase(e),g=Zn.test(y),C=d<l-1&&r[d+1]===r[d+1].toLocaleUpperCase(e);!m&&A||g&&C?(p.push(h),h=y,g&&C&&(p.push(h),h="")):h+=y,m=A}return h&&h.length>0&&p.push(h),p}if(e.startsWith("zh"))return j(t,{han:r=>xe.test(r),latin:r=>P.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=l=>ke.test(l)||Ie.test(l);return j(t,{latin:l=>P.test(l),rtl:l=>r(l)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=l=>Ut.test(l)||Mt.test(l)||St.test(l)||Tt.test(l)||Dt.test(l)||Vt.test(l)||jt.test(l)||Rt.test(l)||Bt.test(l)||zt.test(l)||Ft.test(l)||Wt.test(l)||qt.test(l)||Gt.test(l)||Kt.test(l)||Ht.test(l);return j(t,{indic:l=>r(l),latin:l=>P.test(l)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return j(t,{cyrillic:r=>X.test(r),latin:r=>P.test(r)},!0,e);if(["ar","fa","he"].includes(e))return j(t,{latin:r=>P.test(r),rtl:r=>ke.test(r)||Ie.test(r)},!1,e);if(e.startsWith("ko"))return j(t,{hangul:r=>Ee.test(r),latin:r=>P.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!P.test(t))return[t];const r=[...t],l=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let d=1;d<l;d++){const y=r[d],A=y===y.toLocaleUpperCase(e);if(_e.test(y)||_e.test(r[d-1])){h+=y;continue}!m&&A?(p.push(h),h=y):h+=y,m=A}return h&&h.length>0&&p.push(h),p}const i=[...t],o=i.length,c=[];let a=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){c.push(r),a=i[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const l=i[r],p=l===l.toLocaleUpperCase(e);let h=0;for(const m of n)if(t.startsWith(m,r)){c.push(a,m),h=m.length,a="";const d=m.at(-1);d&&(u=d===d.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&p?(c.push(a),a=l):a+=l,u=p}return a&&c.push(a),c},es=(t,e,n)=>{const s=[],i=ie.test(t)?t.split(ie).filter(Boolean):[t];for(const o of i){const c=o;if(ie.test(c))s.push(c);else{q.lastIndex=0;const a=q.test(c)?Jn(c).filter(Boolean):[c];for(const u of a)if(q.lastIndex=0,q.test(u))s.push(u);else if(e){const r=e.toLowerCase().split("-")[0];s.push(...rt(u,r,n))}else s.push(...it(u,n))}}return s},ts=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:s=!1,knownAcronyms:i=[],locale:o,normalize:c=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,l=new Set([...i].toSorted((g,C)=>C.length-g.length));let p=t;u&&(p=Hn(p)),r&&(p=It(p));let h;Array.isArray(a)?h=Yn(a):a instanceof RegExp?h=a:h=$t;const m=[];let d=p;const y=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;d.length>0;){const g=y.exec(d);if(!g){d===".."?m.push(".."):d==="."?m.push("."):d.length>0&&m.push(d);break}const C=g.index,O=g[0],k=O.length,x=d.slice(0,C),H=d.slice(C+k);if(O.startsWith("../"))m.push(".."),d=d.slice(C+3);else if(O.startsWith("./"))m.push("."),d=d.slice(C+2);else if(C===0&&O==="..")m.push(".."),d=d.slice(2);else if(C===0&&O===".")m.push("."),d=d.slice(1);else{x.length>0&&m.push(x);let S=0;for(;(S=O.indexOf("../",S))!==-1;)m.push(".."),S+=3;for(S=0;(S=O.indexOf("./",S))!==-1;)(S===0||O[S-1]!==".")&&m.push("."),S+=2;let f=H;for(;f.startsWith("../");)m.push(".."),f=f.slice(3);for(;f.startsWith("./");)m.push("."),f=f.slice(2);if(f===".."){m.push("..");break}else if(f==="."){m.push(".");break}else d=f}y.lastIndex=0}if(m.length===0){const g=p.split(h).filter(Boolean);m.push(...g)}let A=[];for(const g of m)n||s?A.push(...es(g,o,l)):o?A.push(...rt(g,o,l)):A.push(...it(g,l));return c&&(A=A.map(g=>l.has(g)?g:o&&g===g.toLocaleUpperCase(o)?g[0]+g.slice(1).toLocaleLowerCase(o):g.toUpperCase()===g&&!l.has(g)?g.slice(0,1)+g.slice(1).toLowerCase():g)),A},ns=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),ss=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const s=[];let i="",o="";for(let c=0;c<n;c++){const a=t[c];if(ie.test(a)){i?(s.push(i+o+a),i="",o=""):(s.length>0&&s.push(e),i=a);continue}i?(o&&(o+=e),o+=a):(s.length>0&&s.push(e),s.push(a))}return s.join("")},Y=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return ss(ts(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(i=>{const o=i,c=o.toLowerCase();return n?(n=!1,Gn(c)):ns(c)}),"")};class os extends N{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}}class is extends N{choices;option;value;constructor(e,n,s){super(`Invalid value "${n}" for option "${e}". Allowed values: ${s.join(", ")}`,"INVALID_CHOICE",{choices:s,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=s,this.hint=`Use one of: ${s.map(i=>`--${e} ${i}`).join(", ")}`}}const Be=(t,e,n=!1)=>{const s=[],i=e._all??e;for(const o of t){if(!n&&!o.required)continue;const c=o.__camelCaseName__??o.name;if(i[c]===void 0){if(o.type?.name==="Boolean"){e[c]=!1;continue}s.push(o)}}return s},rs=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Xt(t,e)<=t.length/3,R=(t,e)=>{const n=t.toLowerCase();return e.filter(s=>rs(s.toLowerCase(),n))},as=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(s=>{const i=s.startsWith("--");let o=`Found unknown ${i?"option":"argument"} "${s}"`;if(i){const c=R(s.replace("--",""),(e.options??[]).map(a=>a.name));if(c.length>0){const[a,...u]=c.map(r=>`--${r}`);o+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
2
+ `))},W=(t,e)=>new N(`Command "${t}" ${e}`,"INVALID_COMMAND",{commandName:t}),ls=(t,e)=>{const n=new Set;for(const[s,i]of t.entries()){if(typeof i!="object"||i===null)throw W(e,`has a positional argument at index ${String(s)} that is not an object`);const{name:o}=i;if(typeof o!="string"||o.length===0)throw W(e,`has a positional argument at index ${String(s)} without a name`);const c=et(o);if(n.has(c))throw W(e,`declares duplicate positional argument "${o}"`);n.add(c);const a=s===0?void 0:t[s-1];if(i.required===!0&&a!==void 0&&a.required!==!0)throw W(e,`declares required positional "${o}" after an optional one, which can never be satisfied`);if(i.multiple===!0&&s!==t.length-1)throw W(e,`declares a variadic positional "${o}" that is not the last one`)}},cs=(t,e,n)=>{const s=n.__requiredOptions__,i=s?Be(s,e,!0):Be(t,e,!1);if(i.length>0)throw new os(n.name,i.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&!n.arguments?.length&&as(e,n)},hs=(t,e,n)=>{const s=n.__conflictingOptions__??t.filter(i=>i.conflicts!==void 0);if(s.length>0){const i=s.find(o=>{const c=o.__camelCaseName__??Y(o.name);return Array.isArray(o.conflicts)?o.conflicts.some(a=>e[Y(a)]!==void 0)&&e[c]!==void 0:e[Y(o.conflicts)]!==void 0&&e[c]!==void 0});if(i)throw new Ke(i.name,typeof i.conflicts=="string"?i.conflicts:i.conflicts?.[0]??"unknown")}},us=(t,e)=>{const n=e.options;if(n)for(const s of n){if(!s.choices||s.choices.length===0)continue;const i=s.__camelCaseName__??Y(s.name),o=t[i];if(o==null)continue;const c=Array.isArray(o)?o:[o];for(const a of c){const u=String(a);if(!s.choices.includes(u))throw new is(s.name,u,s.choices)}}},ps=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const i of t.options){if(i.name){const o=e.get(i.name)??[];o.push(i),e.set(i.name,o)}if(typeof i.alias=="string"&&i.alias.length>0){const o=n.get(i.alias)??[];o.push(i),n.set(i.alias,o)}else if(Array.isArray(i.alias)){for(const o of i.alias)if(o.length>0){const c=n.get(o)??[];c.push(i),n.set(o,c)}}}const s=[];for(const[i,o]of e)o.length>1&&s.push(`Duplicate option name "${i}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[i,o]of n)o.length>1&&s.push(`Duplicate option alias "-${i}" used by options ${o.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(s.length>0)throw new Error(s.join(`
3
+ `))},fs=t=>{const{arguments:e}=t;if(e!==void 0){if(!Array.isArray(e))throw W(t.name,'must declare "arguments" as an array — slot order is significant, so a record cannot express it');if(t.argument!==void 0)throw W(t.name,'cannot define both "argument" and "arguments" — choose one');ls(e,t.name)}},ds=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let s;for(let i=1;i<=e.length;i+=1){const o=e[i-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const c=n.join(" ");t.has(c)&&(s={commandPath:[...n],depth:i})}return s?{argv:e.slice(s.depth),commandPath:s.commandPath}:{argv:e,commandPath:void 0}},z=t=>t.join(" "),ze=(t,e)=>e&&e.length>0?[...e,t]:[t],Fe=t=>t===void 0||Array.isArray(t)?t:Object.entries(t).map(([e,n])=>({...n,name:e})),gs=t=>{const e=Fe(t.options),n=Fe(t.env);return e===t.options&&n===t.env?t:Object.assign(Object.create(Object.getPrototypeOf(t)),t,{env:n,options:e})},ms=/^no-/,ws=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Y(e.name)})},ys=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const s of t.options)e.add(s.name);const n=[];for(const s of t.options)if(s.name.startsWith("no-")){const i=s.name.replace(ms,"");if(!e.has(i)){if(s.type!==Boolean)throw new Error(`Cannot add negated option "${s.name}" to command "${t.name}" because it is not a boolean.`);const o={...s,defaultValue:s.defaultValue===void 0?!0:!s.defaultValue,name:i};n.push(o),e.add(i)}}n.length>0&&t.options.push(...n)},vs=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,s=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const c=Y(o.name);s.set(c,o)}const i=Object.keys(n).filter(o=>s.has(o));if(i.length!==0)for(const o of i){const c=o.charAt(2);if(!c)continue;const a=c.toLowerCase()+o.slice(3),u=s.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},As=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const i of e.options)i.__camelCaseName__&&i.__negated__===void 0&&i.implies!==void 0&&n.set(i.__camelCaseName__,i);if(n.size===0)return;const{options:s}=t;for(const i of Object.keys(s)){const o=n.get(i);if(o?.implies){const{implies:c}=o;for(const[a,u]of Object.entries(c))s[a]===void 0&&(s[a]=u)}}},Cs=()=>!!process.versions.electron,bs=()=>Cs()&&!process.defaultApp,Ns=()=>bs()?0:1,Os=t=>t.slice(Ns()+1),_s=" ",xs=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,s)=>n===e[s]),Es=t=>{if(typeof t=="string")return t.split(_s);const e=we();return xs(t,e)?Os(t):t},ks=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),F(1)},n=(o,c)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let a;if(typeof o=="string")a=o;else try{a=JSON.stringify(o)}catch{a=String(o)}t.error(`Promise rejection: ${a}`)}F(1)},s=Ne("uncaughtException",e),i=Ne("unhandledRejection",n);return()=>{s(),i()}},We=100,Is=/^[a-z][\w-]*$/i,ve=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new N(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},qe=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new N(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},ne=(t,e)=>{if(typeof t!="object"||t===null)throw new N(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},se=t=>{const e=ve(t,"Command name");if(e.length>We)throw new N(`Command name is too long (maximum ${String(We)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new N(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Is.test(e))throw new N(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},$s=1e6,Ps=1e5,Ls=new Set([`
4
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Us=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,s=n.maxArgumentLength??$s;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Argument is too long (maximum ${String(s)} characters)`);if(n.checkDangerousChars){for(const i of t)if(Ls.has(i))throw new Error(`Argument contains dangerous character: ${i}`)}return n.trim?t.trim():t},Ge=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,s=n.maxArguments??Ps;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Too many arguments (maximum ${String(s)})`);return t.map(i=>Us(i,n))},Ms=/^-([^\d-])$/,Ss=/^--(\S+)/,Ts=/^-([^\d-]{2,})$/,me=t=>Ms.test(t)||Ss.test(t)||Ts.test(t),Ds={access:(t,e)=>yt(t,e),mkdir:(t,e)=>wt(t,e),readdir:t=>mt(t),readFile:(async(t,e)=>e===void 0?be(t):be(t,e)),rm:(t,e)=>gt(t,e),stat:t=>dt(t),writeFile:(t,e,n)=>ft(t,e,n)},Vs=(t,e,n)=>{const s=e.indexOf("--"),i=s===-1?new Set:new Set(e.slice(s+1)),o=n.filter(u=>u.startsWith("--")&&u!=="--"&&!i.has(u));if(o.length===0)return;const c=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>R(u.slice(2),c).map(r=>`--${r}`));throw new Yt(o,a)};class at{#t;#e;#h;#p;#f;#d;#O;#_;#x;#A;#E;#C;#k;#b=le;#u;#n;#s;#o;#i;#r;#I=!1;#$;#P=!1;#g;#m;#w;#l=[];#D(){return this.#g===void 0&&(this.#g=[...this.#s.keys()]),this.#g}#L(){return this.#m===void 0&&(this.#m=[...this.#n.keys()]),this.#m}#a(){return this.#w===void 0&&(this.#w=[...this.#D(),...this.#L()]),this.#w}#U(){return this.#l.length===0?te:[...te,...this.#l]}#M(){this.#g=void 0,this.#m=void 0,this.#w=void 0}#N(){if(this.#h===void 0){const e=Es(this.#e.argv);this.#h=Ge(e,{maxArguments:this.#C}),this.#V()}return this.#h}#y(){return this.#A??re()}#v(e){this.#b=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#b}#V(){if(!this.#h)return;let e=!1;for(const n of this.#h){if(n==="--quiet"||n==="-q"){this.#v(vt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#v(At),e=!0;break}if(n==="--debug"){this.#v(V),e=!0;break}}e||this.#v(Object.hasOwn(this.#y(),"DEBUG")?V:le)}#j(){this.#P||(this.#$=ks(this.#t),this.#P=!0)}#R(){return{arch:bt(),argv:this.#N(),cwd:this.#p,env:this.#A??re(),exit:this.#x??(e=>F(e??0)),platform:Ct(),stdin:this.#E}}#S(e,n,s,i){this.#c()===V&&this.#t.debug(`command '${i}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:c,parsedArgs:a}=Fn(e,n,this.#U()),u=Object.keys(c).length>0;let r=a;u&&(r={...a,_all:{...a._all,...c}}),cs(o,r,e);const l=zn(e,a,c,s,this.#y());l.runtime=this,l.argv=this.#N(),l.fs=this.#_??Ds,l.process=this.#R(),l.console=this.#t,Wn(e,l);const p=e.options&&e.options.length>0;if(p&&e.options){const h=e.options.filter(m=>m.name.startsWith("no-"));for(const m of h){const d=m.name.slice(3),y=`--${m.name}`,A=`--${d}`,g=n.includes(y),C=n.includes(A);if(g&&C)throw new Ke(d,m.name)}}return p&&(vs(l,e),As(l,e)),hs(o,l.options,e),us(l.options,e),this.#k&&Vs(e,n,l.rawUnknown),this.#c()===V&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(l.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(l.argument,null,2))),{arguments_:o,booleanValues:c,commandArgs:r,parsedArgs:a,toolbox:l}}async#T(e,n,s){const i=this.getPluginManager();try{!this.#I&&i.hasPlugins()&&(await i.init({cli:this,cwd:this.#p,logger:this.#t}),this.#I=!0),await i.executeLifecycle("execute",n),await i.executeLifecycle("beforeCommand",n);let o;const c=s.global;if(c?.help){const a=this.#n.get("help");if(!a)throw new N("Help command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else if(c?.version??c?.V){const a=this.#n.get("version");if(!a)throw new N("Version command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else o=await pe(e,n,s);return await i.executeLifecycle("afterCommand",n,o),o}catch(o){throw await i.executeErrorHandlers(o,n),o}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new N("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const s=n.argv??we(),i=n.cwd??Nt();if(this.#e={...n,argv:s,cwd:i},this.#e.argv&&!Array.isArray(this.#e.argv))throw new N("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new N("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new N("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new N("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const p=["debug","error","info","log","warn"],h=[],m=this.#e.logger;for(const d of p)typeof m[d]!="function"&&h.push(d);if(h.length>0)throw new N(`Logger object is missing required methods: ${h.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:h});this.#t=this.#e.logger}else this.#t={...console,debug:(...p)=>{this.#c()===V&&console.debug(...p)}};this.#d=this.#e.packageVersion,this.#O=this.#e.packageName,this.#p=this.#e.cwd,this.#i="help",this.#r={};const o=n.fs;if(o!==void 0&&(typeof o!="object"||o===null))throw new N("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const c=n.exit;if(c!==void 0&&typeof c!="function")throw new N("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new N("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new N("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#_=n.fs,this.#x=n.exit,this.#A=n.env,this.#E=n.stdin??"",this.#C=n.maxArguments,this.#k=n.strictOptions??!1;const r=this.#y().CEREBRO_OUTPUT_LEVEL,l=r===void 0?Number.NaN:Number(r);this.#b=Number.isNaN(l)?le:l,this.#n=new Map,this.#s=new Map,this.#o=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#d?` v${this.#d}`:""}`),this.#r}setDefaultCommand(e){return this.#i=e,this}get defaultCommand(){return this.#i}addCommand(e){ne(e,"Command"),se(e.name),e.options!==void 0&&ne(e.options,"Command options"),e.env!==void 0&&ne(e.env,"Command env"),fs(e);const n=gs(e),s=typeof n.execute=="function",i=typeof n.loader=="function";if(s&&i)throw new N(`Command "${n.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:n.name});if(!s&&!i)throw new N(`Command "${n.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:n.name});n.alias&&(typeof n.alias=="string"?se(n.alias):qe(n.alias,"Command alias").forEach(l=>se(l))),n.argument&&ne(n.argument,"Command argument"),n.commandPath&&(qe(n.commandPath,"Command commandPath"),n.commandPath.forEach(l=>{se(l)}));const o=ze(n.name,n.commandPath),c=z(o);if(this.#s.has(c))throw new N(`Command with path "${c}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name,commandPath:n.commandPath});const a=Array.isArray(n.commandPath)&&n.commandPath.length>0,u=this.#n.get(n.name),r=u!==void 0&&(u.commandPath===void 0||u.commandPath.length===0);if(!a&&r)throw new N(`Command with name "${n.name}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name});if(n.options)for(const l of n.options)$e(l);if(ps(n),ys(n),ws(n),n.options&&(n.__conflictingOptions__=n.options.filter(l=>l.conflicts!==void 0),n.__requiredOptions__=n.options.filter(l=>l.required===!0)),a&&u!==void 0)this.#n.set(c,n);else{if(!a&&u!==void 0&&!r){const l=ze(u.name,u.commandPath);this.#n.set(z(l),u)}this.#n.set(n.name,n)}if(this.#s.set(c,o),this.#o.set(c,n),this.#M(),n.alias!==void 0){const l=typeof n.alias=="string"?[n.alias]:n.alias;for(const p of l){if(this.#c()===V&&this.#t.debug("adding alias",p),this.#n.has(p))throw new N(`Command alias "${p}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:p,commandName:n.name});this.#n.set(p,n)}}return this}addGlobalOption(e){const n=e,s=new Set(te.map(c=>c.name)),i=new Set(te.map(c=>c.alias).filter(Boolean));if(s.has(n.name))throw new N(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&i.has(n.alias))throw new N(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(c=>c.name)).has(n.name))throw new N(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",$e(n),this.#l.push(n),this}getGlobalOptions(){return this.#U()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#u?this.#u:(this.#u=new Zt(this.#t),this.#u.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#u)}getCliName(){return this.#f}getPackageVersion(){return this.#d}getPackageName(){return this.#O}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#$?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:s=!0,...i}=e;if(!this.#n.has("help")){const{default:g}=await import("../commands/help-command.js");this.addCommand(new g(this.#n))}const o=this.#L(),c=this.#s;this.#j();const a=this.#N();let u,r=[...a];this.#c()===V&&(this.#t.debug(`process.execPath: ${Ot()}`),this.#t.debug(`process.execArgv: ${_t().join(" ")}`),this.#t.debug(`process.argv: ${we().join(" ")}`));const l=ds(c,[...a]);if(l.commandPath)u=l.commandPath,r=l.argv;else{if(a.length>1&&a[0]&&a[1]&&!me(a[0])&&!me(a[1])){const C=[];let O=0;for(;O<a.length;){const x=a[O];if(!x||me(x))break;C.push(x),O+=1}const k=z(C);if(C[0]&&!o.includes(C[0])){const x=this.#a(),H=R(k,x);throw new B(k,H)}}let g;try{g=on([null,...o],[...a])}catch(C){if(C instanceof Error&&C.name==="INVALID_COMMAND"&&"command"in C){const O=C.command,k=this.#a(),x=R(O,k);throw new B(O,x)}throw C}g.command&&(u=[g.command],r=g.argv)}if(!u)if(this.#i)u=[this.#i];else{const g=this.#a();throw new B("",g)}const p=z(u),h=this.#s.get(p);let m;if(h){if(m=this.#o.get(p),!m||z(h)!==p){const g=this.#a(),C=R(p,g);throw new B(p,C)}}else{const g=u.at(-1);if(m=g?this.#n.get(g):void 0,!m){const C=this.#a(),O=R(p,C);throw new B(p,O)}}if(typeof m.execute!="function"&&typeof m.loader!="function")return this.#t.error(`Command "${m.name}" has no function to execute.`),s?F(1):void 0;const d=r;let y,A;try{({commandArgs:y,toolbox:A}=this.#S(m,d,i,p))}catch(g){if(this.#t.error(g),s)return F(1);throw g}try{return await this.#T(m,A,y),s?F(0):void 0}catch(g){if(s)return this.#t.error(g),F(1);throw g}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:s=[],...i}=n;ve(e,"Command name");const o=e.split(" ").filter(Boolean),c=z(o),u=this.#s.get(c)?this.#o.get(c):this.#n.get(e);if(!u){const m=this.#a(),d=R(c||e,m);throw new B(e,d)}if(typeof u.execute!="function"&&typeof u.loader!="function")throw new N(`Command "${u.name}" has no function to execute`,"INVALID_COMMAND",{commandName:u.name});const l=[...Ge(s,{maxArguments:this.#C})];this.#c()===V&&this.#t.debug(`running command '${e}' programmatically with args: ${l.join(", ")}`);const{commandArgs:p,toolbox:h}=this.#S(u,l,i,c||e);return this.#T(u,h,p)}clone(e){const n={...this.#e,...e},s=new at(this.#f,n);for(const[i,o]of this.#n)s.#n.set(i,o);for(const[i,o]of this.#s)s.#s.set(i,[...o]);for(const[i,o]of this.#o)s.#o.set(i,o);for(const i of this.#l)s.#l.push(i);return s.#i=this.#i,s.#r={...this.#r},s.#M(),s}async getAction(e){ve(e,"Command name");const n=e.split(" ").filter(Boolean),s=z(n),o=this.#s.get(s)?this.#o.get(s):this.#n.get(e);if(!o){const c=this.#a(),a=R(s||e,c);throw new B(e,a)}if(typeof o.execute=="function")return o.execute;if(typeof o.loader=="function")return tt(o);throw new N(`Command "${o.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:o.name})}}export{at as Cli};
@@ -0,0 +1 @@
1
+ import{C as t}from"./cerebro-error-Dv3FuXO8.js";class n extends t{argument;choices;value;constructor(e,o,r){super(`Invalid value "${o}" for argument "${e}". Allowed values: ${r.join(", ")}`,"INVALID_CHOICE",{argument:e,choices:r,value:o}),this.name="InvalidArgumentChoiceError",this.argument=e,this.value=o,this.choices=r,this.hint=`Pass one of: ${r.join(", ")}`}}export{n as default};
@@ -0,0 +1 @@
1
+ import{C as s}from"./cerebro-error-Dv3FuXO8.js";class e extends s{commandName;missingArguments;constructor(i,r){super(`Command "${i}" is missing required arguments: ${r.join(", ")}`,"MISSING_ARGUMENT",{commandName:i,missingArguments:r}),this.name="MissingArgumentError",this.commandName=i,this.missingArguments=r,this.hint=`Provide the following positional arguments: ${r.join(", ")}`}}export{e as default};
@@ -0,0 +1 @@
1
+ import{C as o}from"./cerebro-error-Dv3FuXO8.js";class i extends o{commandName;surplusArguments;constructor(r,t,e){super(`Command "${r}" accepts ${String(e)} positional argument${e===1?"":"s"}, but got ${String(t.length)} extra: ${t.join(", ")}`,"SURPLUS_ARGUMENT",{commandName:r,surplusArguments:[...t]}),this.name="SurplusArgumentError",this.commandName=r,this.surplusArguments=t,this.hint=`Remove the extra argument${t.length===1?"":"s"}, or declare a trailing "multiple: true" argument to collect them.`}}export{i as default};
@@ -0,0 +1 @@
1
+ const O=1,T=2,o=4,s=16,t=32,n=64,E=128,c="positionals";export{O as OUTPUT_NORMAL,o as OUTPUT_PLAIN,T as OUTPUT_RAW,c as POSITIONALS_KEY,E as VERBOSITY_DEBUG,t as VERBOSITY_NORMAL,s as VERBOSITY_QUIET,n as VERBOSITY_VERBOSE};
@@ -0,0 +1 @@
1
+ const r=s=>s instanceof Error&&s.type==="VisulimaError";class h extends Error{loc;title;hint;type="VisulimaError";constructor({cause:t,hint:e,location:i,message:a,name:c,stack:n,title:o}){super(a,{cause:t}),this.title=o,this.name=c,this.stack=n??this.stack,this.loc=i,this.hint=e}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}export{h as c,r as n};
@@ -0,0 +1,76 @@
1
+ import{r as P}from"./renderError-CIIYTTfx-BdX-afLI.js";import{y as fe,C as pe,q as me,Q as de,z as ye,Y as he}from"./renderError-CIIYTTfx-BdX-afLI.js";import{c as be,n as ve}from"./VisulimaError-BDqtOVL5-Db_MJ_p7.js";const E=(e,t)=>{let r=0,o=t.length-2;for(;r<o;){const n=r+(o-r>>1);if(e<t[n])o=n-1;else if(e>=t[n+1])r=n+1;else{r=n;break}}return r},T=/\n|\r(?!\n)/,I=e=>e.split(T).reduce((t,r)=>(t.push(t.at(-1)+r.length+1),t),[0]),Q=(e,t,r)=>{const o=r?.skipChecks??!1;if(!o&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return{column:0,line:0};if(!o&&(typeof t!="number"||typeof e=="string"&&t>=e.length||Array.isArray(e)&&t+1>=e.at(-1)))return{column:0,line:0};if(typeof e=="string"){const a=I(e),s=E(t,a);return{column:t-a[s]+1,line:s+1}}const n=E(t,e);return{column:t-e[n]+1,line:n+1}},G=({applicationType:e,error:t,file:r})=>`You are a very skilled ${r.language??"unknown"} programmer.
2
+
3
+ ${e?`You are working on a ${e} application.`:""}
4
+
5
+ Use the following context to find a possible fix for the exception message at the end. Limit your answer to 4 or 5 sentences. Also include a few links to documentation that might help.
6
+
7
+ Use this format in your answer, make sure links are json:
8
+
9
+ FIX
10
+ insert the possible fix here
11
+ ENDFIX
12
+ LINKS
13
+ {"title": "Title link 1", "url": "URL link 1"}
14
+ {"title": "Title link 2", "url": "URL link 2"}
15
+ ENDLINKS
16
+ ---
17
+
18
+ Here comes the context and the exception message:
19
+
20
+ Line: ${String(r.line)}
21
+
22
+ File:
23
+ ${r.file}
24
+
25
+ Snippet including line numbers:
26
+ ${r.snippet??""}
27
+
28
+ Exception class:
29
+ ${t.name}
30
+
31
+ Exception message:
32
+ ${t.message}`,d=e=>e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;"),C=e=>{try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}},j=(e,t,r)=>{const o=r.indexOf(e);if(o===-1)return"";const n=o+e.length,a=r.indexOf(t,n);return a===-1?"":r.slice(n,a).trim()},Z=e=>{const t=j("FIX","ENDFIX",e);if(!t)return["No solution found.",'Provide this response to the Maintainer of <a href="https://github.com/visulima/visulima/issues/new?assignees=&labels=s%3A+pending+triage%2Cc%3A+bug&projects=&template=bug_report.yml" target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline inline-flex items-center text-sm">@visulima/error</a>.',`"${d(e)}"`].join("</br></br>");const r=j("LINKS","ENDLINKS",e),o=r?r.split(`
33
+ `).map(a=>a.trim()).filter(Boolean).map(a=>{try{const s=JSON.parse(a);return typeof s.url=="string"&&typeof s.title=="string"&&C(s.url)?{title:s.title,url:s.url}:void 0}catch{return}}).filter(a=>a!==void 0):[],n=o.length>0?`
34
+
35
+ ## Links
36
+
37
+ ${o.map(a=>`- <a href="${d(a.url)}" target="_blank" rel="noopener noreferrer">${d(a.title)}</a>`).join(`
38
+ `)}`:"";return`${d(t).replaceAll(/&quot;(.*?)&quot;(?:\s|\.)/g,"<code>$1</code> ")}${n}
39
+
40
+ --------------------
41
+ This solution was generated with the <a href="https://sdk.vercel.ai/" target="_blank" rel="noopener noreferrer">AI SDK</a> and may not be 100% accurate.`},ee={handle:e=>e.hint===void 0?Promise.resolve(void 0):typeof e.hint=="string"&&e.hint!==""?Promise.resolve({body:e.hint}):typeof e.hint=="object"&&typeof e.hint.body=="string"?Promise.resolve(e.hint):Array.isArray(e.hint)?Promise.resolve({body:e.hint.join(`
42
+ `)}):Promise.resolve(void 0),name:"errorHint",priority:1},_=e=>`\`\`\`
43
+ ${e.trim()}
44
+ \`\`\``,y=e=>`\`\`\`bash
45
+ ${e.trim()}
46
+ \`\`\``,h=e=>`\`\`\`ts
47
+ ${e.trim()}
48
+ \`\`\``,D=e=>`\`\`\`js
49
+ ${e.trim()}
50
+ \`\`\``,l=(e,...t)=>{const r=e.toLowerCase();return t.some(o=>r.includes(o.toLowerCase()))},J=[{name:"esm-cjs-interop",test:e=>{const{message:t}=e;if(l(t,"err_require_esm","cannot use import statement outside a module","must use import to load es module","require() of es module","does not provide an export named"))return{md:["Your project or a dependency may be mixing CommonJS and ES Modules.","","Try:","- Ensure package.json has the correct `type` (either `module` or `commonjs`).","- Use dynamic `import()` when requiring ESM from CJS.","- Prefer ESM-compatible entrypoints from dependencies.","- In Node, align `module` resolution with your bundler config.","","Check Node resolution:",y(`node -v
51
+ cat package.json | jq .type`),"","Example dynamic import in CJS:",D("(async () => { const mod = await import('some-esm'); mod.default(); })();")].join(`
52
+ `),title:"ESM/CJS interop"}}},{name:"missing-default-export",test:e=>{const{message:t}=e;if(l(t,"default export not found","has no default export","does not provide an export named 'default'","is not exported from"))return{md:["Verify your import/export shapes.","","Default export example:",h(`export default function Component() {}
53
+ // import Component from './file'`),"","Named export example:",h(`export function Component() {}
54
+ // import { Component } from './file'`)].join(`
55
+ `),title:"Export mismatch (default vs named)"}}},{name:"port-in-use",test:e=>{const{message:t}=e;if(l(t,"eaddrinuse","address already in use","listen eaddrinuse"))return{md:["Another process is using the port.","","Change the port or stop the other process.","","On macOS/Linux:",y(`lsof -i :3000
56
+ kill -9 <PID>`),"","On Windows (PowerShell):",y(`netstat -ano | findstr :3000
57
+ taskkill /PID <PID> /F`)].join(`
58
+ `),title:"Port already in use"}}},{name:"file-not-found-or-case",test:(e,t)=>{const{message:r}=e;if(l(r,"enoent","module not found","cannot find module"))return{md:["Check the import path and filename case (Linux/macOS are case-sensitive).","If using TS path aliases, verify `tsconfig.paths` and bundler aliases.","","Current file:",_(`${t.file}:${String(t.line)}`)].join(`
59
+ `),title:"Missing file or path case mismatch"}}},{name:"ts-path-mapping",test:e=>{const{message:t}=e;if(l(t,"ts2307","cannot find module")||t.includes("TS2307"))return{md:["If you use path aliases, align TS `paths` with Vite/Webpack resolve aliases.","Ensure file extensions are correct and included in resolver.","","tsconfig.json excerpt:",h(`{
60
+ "compilerOptions": {
61
+ "baseUrl": ".",
62
+ "paths": { "@/*": ["src/*"] }
63
+ }
64
+ }`)].join(`
65
+ `),title:"TypeScript path mapping / resolution"}}},{name:"network-dns-enotfound",test:e=>{const{message:t}=e;if(l(t,"enotfound","getaddrinfo","dns lookup","fetch failed","econnrefused"))return{md:["The host may be unreachable or misconfigured.","","Try:","- Verify the hostname and protocol (http/https).","- Check VPN/proxy and firewall.","- Confirm the service is running and listening on the expected port.","",y(`ping <host>
66
+ nslookup <host>
67
+ curl -v http://<host>:<port>`)].join(`
68
+ `),title:"Network/DNS connection issue"}}},{name:"undefined-property",test:e=>{const{message:t}=e;if(l(t,"cannot read properties of undefined","reading '"))return{md:["A variable or function returned `undefined`.","","Mitigations:","- Add nullish checks before property access.","- Validate function return values and input props/state.","",h("const value = maybe?.prop; // or: if (maybe) { use(maybe.prop) }")].join(`
69
+ `),title:"Accessing property of undefined"}}}],te={handle:(e,t)=>{try{const r=J.map(n=>({match:n.test(e,t),rule:n})).filter(n=>!!n.match);if(r.length===0)return Promise.resolve(void 0);const o=r.toSorted((n,a)=>(n.match.priority??0)-(a.match.priority??0)).map(n=>`#### ${n.match.title}
70
+
71
+ ${n.match.md}`).join(`
72
+
73
+ ---
74
+
75
+ `);return o===""?Promise.resolve(void 0):Promise.resolve({body:o,header:"### Potential fixes detected"})}catch{return Promise.resolve(void 0)}},name:"ruleBasedHints",priority:0};let p=class extends Error{constructor(t){super(t),this.name="NonError"}};const oe=()=>{if(!Error.captureStackTrace)return;const e=new Error;return Error.captureStackTrace(e),e.stack},v=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError],...typeof AggregateError>"u"?[]:[["AggregateError",AggregateError]]]),ne=(e,t)=>{let r;try{r=new e}catch(n){throw new Error(`The error constructor "${e.name}" is not compatible`,{cause:n})}const o=t??r.name;if(v.has(o))throw new Error(`The error constructor "${o}" is already known.`);v.set(o,e)},x=e=>v.get(e),b=e=>e!==null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.message=="string"&&(x(e.name)!==void 0||e.name==="Error"),k=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},L={maxDepth:Number.POSITIVE_INFINITY},A=(e,t,r=0)=>b(e)?w(e,t,r):t.maxDepth!==void 0&&r>=t.maxDepth?new p(JSON.stringify(e)):new p(JSON.stringify(e)),F=(e,t,r,o,n)=>{const a=t.map(s=>u(s,o,n+1));return new e(a,r)},w=(e,t,r)=>{if(t.maxDepth!==void 0&&r>=t.maxDepth)return new p(JSON.stringify(e));const{cause:o,errors:n,message:a,name:s,stack:i,...m}=e,S=x(s)??Error,c=s==="AggregateError"&&Array.isArray(n)?F(S,n,a,t,r):new S(a);return!c.name&&s&&(c.name=s),a!==void 0&&(c.message=a),i&&(c.stack=i),R(c,m,o,s,t,r),o!==void 0&&(c.cause=u(o,t,r+1)),M(c,e),c},u=(e,t,r)=>{if(k(e)){if(e.__dataType==="Map"&&Array.isArray(e.value))return new Map(e.value.map(([n,a])=>[u(n,t,r+1),u(a,t,r+1)]));if(e.__dataType==="Set"&&Array.isArray(e.value))return new Set(e.value.map(n=>u(n,t,r+1)));if(b(e))return A(e,t,r);const o={};for(const[n,a]of Object.entries(e))n==="__proto__"||n==="constructor"||n==="prototype"||(o[n]=u(a,t,r+1));return o}return Array.isArray(e)?e.map(o=>u(o,t,r)):e},R=(e,t,r,o,n,a)=>{const s=e;for(const[i,m]of Object.entries(t))if(!(i==="__proto__"||i==="constructor"||i==="prototype")){if(i==="cause"&&r!==void 0||i==="errors"&&o==="AggregateError")continue;Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:u(m,n,a+1),writable:!0})}},M=(e,t)=>{const r=new Set(["message","name","stack"]);for(const o of Object.keys(t))r.add(o);for(const o of r)if(o in e){const n=Object.getOwnPropertyDescriptor(e,o);n&&!n.enumerable&&Object.defineProperty(e,o,{...n,enumerable:!0})}},$=e=>new p(JSON.stringify(e)),U=e=>new p(JSON.stringify(e)),V=(e,t)=>b(e)?w(e,t,0):A(e,t),ae=(e,t={})=>{const r={...L,...t};return e instanceof Error?e:e===null?$(null):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?$(e):Array.isArray(e)?U(e):b(e)?w(e,r,0):k(e)?V(e,r):new p(JSON.stringify(e))},q=P("node:util"),Y=e=>{try{return q().inspect(e)}catch{}try{return String(e)}catch{return"<unprintable>"}},se=e=>{const t=new Set,r=[];let o=e;for(;o;){if(t.has(o)){console.error(`Circular reference detected in error causes: ${Y(e)}`);break}if(r.push(o),t.add(o),typeof o!="object"||!("cause"in o))break;o=o.cause}return r},K=e=>{const t=e.methodName&&e.methodName!=="<unknown>"?`${e.methodName} `:"",r=e.file??"<unknown>",o=String(e.line??0),n=String(e.column??0);return t.trim()?` at ${t}(${r}:${o}:${n})`:` at ${r}:${o}:${n}`},ie=(e,t)=>{const r=[];if(t?.header&&(t.header.name||t.header.message)){const o=t.header.name??"Error",n=t.header.message??"";r.push(`${o}${n?": ":""}${n}`)}for(const o of e)r.push(K(o));return r.join(`
76
+ `)},B=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),H=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},O=new WeakSet,X=e=>{if(Object.hasOwn(e,"name")&&typeof e.name=="string"&&e.name!=="")return e.name;const t=e.constructor?.name;return typeof t=="string"&&t!==""?t:e.name},N=e=>{const t=Object.getOwnPropertyNames(e);for(const r of t){const o=Object.getOwnPropertyDescriptor(e,r);o&&(o.enumerable||Object.defineProperty(e,r,{...o,enumerable:!0}),o.value&&typeof o.value=="object"&&!Array.isArray(o.value)&&(Object.getPrototypeOf(o.value)===Object.prototype||Object.getPrototypeOf(o.value)===null)&&N(o.value))}},z=e=>{O.add(e);const t=e.toJSON();return O.delete(e),Object.isExtensible(t)&&N(t),t},f=(e,t,r,o,n=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.has(e)?"[Circular]":(r+=1,g(e,o,t,r));if(o.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const a=[];for(const[s,i]of e.entries())a.push([f(s,t,r,o,n),f(i,t,r,o,n)]);return{__dataType:"Map",value:a}}if(e instanceof Set){const a=[];for(const s of e.values())a.push(f(s,t,r,o,n));return{__dataType:"Set",value:a}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(H(e)){if(n.has(e))return"[Circular]";if(o.maxDepth!==void 0&&o.maxDepth!==Number.POSITIVE_INFINITY&&r+1>=o.maxDepth)return{};r+=1,n.add(e);const a={};for(const s in e)a[s]=f(e[s],t,r,o,n);return n.delete(e),a}try{return e}catch{return"[Not Available]"}},g=(e,t,r,o)=>{if(r.add(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!O.has(e))return z(e);const n=Object.create(B);if(Object.defineProperty(n,"name",{configurable:!0,enumerable:!0,value:X(e),writable:!0}),Object.defineProperty(n,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(n,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const s=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.has(i))return Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),n;s.push(g(i,t,r,o))}Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:s,writable:!0})}const a=e.cause;if(a!=null)if(a instanceof Error)r.has(a)?Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:g(a,t,r,o),writable:!0});else{const s=f(a,r,o,t);Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:s,writable:!0})}for(const s in e){if(s==="name"||s==="message"||s==="stack"||s==="cause"||s==="errors")continue;const i=e[s],m=f(i,r,o,t);Object.defineProperty(n,s,{configurable:!0,enumerable:!0,value:m,writable:!0})}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const s of t.exclude)try{delete n[s]}catch{}return n},ce=(e,t={})=>g(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},new Set,0);export{fe as CODE_FRAME_POINTER,p as NonError,be as VisulimaError,ne as addKnownErrorConstructor,G as aiPrompt,Z as aiSolutionResponse,oe as captureRawStackTrace,pe as codeFrame,me as composeFilters,ae as deserializeError,ee as errorHintFinder,K as formatStackFrameLine,ie as formatStacktrace,se as getErrorCauses,Q as indexToLineColumn,b as isErrorLike,ve as isVisulimaError,de as parseStacktrace,ye as renderError,te as ruleBasedFinder,ce as serializeError,he as stackFilters};
@@ -0,0 +1 @@
1
+ import{c as t}from"./VisulimaError-BDqtOVL5-Db_MJ_p7.js";class n extends t{code;context;constructor(r,e,o){super({message:r,name:"CerebroError"}),this.code=e,this.context=o}}export{n as C};
@@ -196,7 +196,7 @@ interface Cli<T extends Console> {
196
196
  * @param command The command to add.
197
197
  * @returns self
198
198
  */
199
- addCommand: <OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: Command<OD, T>) => this;
199
+ addCommand: <OD extends OptionDefinition<unknown> = OptionDefinition<unknown>, TContext extends Toolbox<T> = Toolbox<T>>(command: CommandInput<OD, T, TContext>) => this;
200
200
  /**
201
201
  * Add a global option available to all commands.
202
202
  * Global options are parsed alongside command options and shown in help output.
@@ -334,8 +334,29 @@ interface CerebroProcess {
334
334
  * @template TLogger - The logger type (defaults to Console)
335
335
  * @template TOptions - The options type (defaults to Options/Record&lt;string, unknown>)
336
336
  * @template TEnv - The environment variables type (defaults to Record&lt;string, unknown>)
337
+ * @template TArgs - The named positional arguments type (defaults to Record&lt;string, unknown>)
337
338
  */
338
- interface Toolbox<TLogger extends Console = Console, TOptions extends Record<string, unknown> = Options, TEnv extends Record<string, unknown> = Record<string, unknown>> extends Cerebro.ExtensionOverrides {
339
+ interface Toolbox<TLogger extends Console = Console, TOptions extends Record<string, unknown> = Options, TEnv extends Record<string, unknown> = Record<string, unknown>, TArgs extends Record<string, unknown> = Record<string, unknown>> extends Cerebro.ExtensionOverrides {
340
+ /**
341
+ * Named positional arguments, keyed by the camelCased names declared in the
342
+ * command's `arguments`. Empty when the command declares none — the raw
343
+ * token list is always available as `argument`.
344
+ * @example
345
+ * ```typescript
346
+ * cli.addCommand({
347
+ * name: "copy",
348
+ * arguments: [
349
+ * { name: "source", required: true, type: String },
350
+ * { multiple: true, name: "targets", required: true, type: String },
351
+ * ],
352
+ * execute: ({ args }) => {
353
+ * // `copy a.txt b/ c/` → args.source === "a.txt", args.targets === ["b/", "c/"]
354
+ * args.targets.forEach((target) => console.log(`${args.source} -> ${target}`));
355
+ * },
356
+ * });
357
+ * ```
358
+ */
359
+ args: TArgs;
339
360
  /**
340
361
  * The argument passed to the command.
341
362
  * For example, if you run `cerebro foo bar baz`, then this will be `["foo", "bar", "baz"]`.
@@ -513,7 +534,63 @@ type OptionDefinition<T> = MultiplePropertyOptions<T> & Omit<OptionDefinition$1,
513
534
  /** A string to replace the default type string (e.g. &lt;string>). It's often more useful to set a more descriptive type label, like &lt;ms>, &lt;files>, &lt;command>, etc.. */
514
535
  typeLabel?: string;
515
536
  };
516
- type ArgumentDefinition<T = unknown> = Omit<OptionDefinition<T>, "multiple|lazyMultiple|defaultOption|alias|group|defaultValue">;
537
+ /**
538
+ * A positional argument definition.
539
+ *
540
+ * Spelled out rather than derived from {@link OptionDefinition} via `Omit`: the
541
+ * fields a positional actually uses (`multiple`, `defaultValue`) are the ones a
542
+ * subtractive definition would be most tempted to remove, and the fields it has
543
+ * no meaning for (`alias`, `group`, `defaultOption`, `conflicts`, `implies`) are
544
+ * exactly what an inherited shape would drag in — they would then be handed
545
+ * straight to the help renderer's `optionList`.
546
+ */
547
+ interface ArgumentDefinition<T = unknown> {
548
+ /** Restricts the accepted values to a fixed set, validated at parse time. */
549
+ choices?: ReadonlyArray<string>;
550
+ /** Value used when the slot is not supplied. */
551
+ defaultValue?: T;
552
+ /** A string describing the argument. */
553
+ description?: string;
554
+ /** Argument is hidden from help. */
555
+ hidden?: boolean;
556
+ /**
557
+ * Collects every remaining positional into an array. Only valid on the last
558
+ * argument of a command.
559
+ */
560
+ multiple?: boolean;
561
+ /** The name of the argument; camelCased for `toolbox.args`. */
562
+ name: string;
563
+ /** Fails the command before `execute` runs when the slot is not supplied. */
564
+ required?: boolean;
565
+ /**
566
+ * A setter function enabling you to be specific about the type and value
567
+ * received. Typical values are `String`, `Number` and `Boolean`, but you can
568
+ * use a custom function.
569
+ */
570
+ type?: TypeConstructor<T>;
571
+ /** A string to replace the default type string (e.g. &lt;string>). */
572
+ typeLabel?: string;
573
+ }
574
+ /**
575
+ * Record form of `options`, keyed by option name.
576
+ *
577
+ * The key *is* the option name, so `name` is neither needed nor accepted — which
578
+ * also makes duplicate names impossible to express. `addCommand` normalizes this
579
+ * shape into the array form that the parser, help, readme and completion
580
+ * consumers read, so both forms behave identically at runtime.
581
+ * @example
582
+ * ```typescript
583
+ * cli.addCommand({
584
+ * name: "build",
585
+ * options: {
586
+ * "output-dir": { type: String, required: true },
587
+ * verbose: { alias: "v", type: Boolean },
588
+ * },
589
+ * execute: ({ options }) => console.log(options.outputDir),
590
+ * });
591
+ * ```
592
+ */
593
+ type OptionDefinitionRecord = Record<string, Omit<OptionDefinition<unknown>, "name">>;
517
594
  /**
518
595
  * Environment variable definition for commands.
519
596
  * Used to document and provide type-safe access to environment variables a command supports.
@@ -537,6 +614,22 @@ interface EnvDefinition<T = string> {
537
614
  /** A string to replace the default type string (e.g. &lt;string>). Useful for more descriptive type labels. */
538
615
  typeLabel?: string;
539
616
  }
617
+ /**
618
+ * Record form of `env`, keyed by environment variable name.
619
+ *
620
+ * The key *is* the variable name, so `name` is neither needed nor accepted.
621
+ * `addCommand` normalizes this shape into the array form `processEnvVariables`
622
+ * reads, so both forms behave identically at runtime.
623
+ * @example
624
+ * ```typescript
625
+ * cli.addCommand({
626
+ * name: "build",
627
+ * env: { API_KEY: { type: String }, DEBUG: { type: Boolean } },
628
+ * execute: ({ env }) => console.log(env.apiKey, env.debug),
629
+ * });
630
+ * ```
631
+ */
632
+ type EnvDefinitionRecord = Record<string, Omit<EnvDefinition<unknown>, "name">>;
540
633
  /**
541
634
  * Command interface with type-safe options and environment variables.
542
635
  * @template O - The option definition type
@@ -588,6 +681,26 @@ interface Command<O extends OptionDefinition<unknown> = OptionDefinition<unknown
588
681
  alias?: string[] | string;
589
682
  /** Positional argument */
590
683
  argument?: ArgumentDefinition;
684
+ /**
685
+ * Named positional arguments in slot order, surfaced on `toolbox.args`.
686
+ *
687
+ * An array rather than a record, because slot order is load-bearing: an
688
+ * alphabetical object-key sorter would silently renumber the positionals.
689
+ * Only the last entry may set `multiple: true`. Mutually exclusive with
690
+ * `argument`.
691
+ * @example
692
+ * ```typescript
693
+ * cli.addCommand({
694
+ * name: "copy",
695
+ * arguments: [
696
+ * { name: "source", required: true, type: String },
697
+ * { name: "targets", multiple: true, required: true, type: String },
698
+ * ],
699
+ * execute: ({ args }) => console.log(args.source, args.targets),
700
+ * });
701
+ * ```
702
+ */
703
+ arguments?: ReadonlyArray<ArgumentDefinition>;
591
704
  /** The command path, an array that describes how to get to this command */
592
705
  commandPath?: string[];
593
706
  /** A tweet-sized summary of your command */
@@ -630,4 +743,35 @@ interface Command<O extends OptionDefinition<unknown> = OptionDefinition<unknown
630
743
  options?: (O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>)[];
631
744
  usage?: Content[];
632
745
  }
633
- export { ArgumentDefinition as A, Command as C, EnvDefinition as E, LazyCommandModule as L, OptionDefinition as O, Plugin as P, RunCommandOptions as R, Toolbox as T, VERBOSITY_LEVEL as V, CerebroFs as a, CommandSection as b, PluginManager as c, CliRunOptions as d, CommandExecute as e, Cli as f, CerebroProcess as g, OutputType as h, PluginContext as i };
746
+ /**
747
+ * The shape `Cli.addCommand` accepts.
748
+ *
749
+ * Identical to {@link Command} except that `options` and `env` may additionally be
750
+ * given as records keyed by name. `addCommand` normalizes those into the array
751
+ * form before any other code sees the command, so everything downstream — and
752
+ * `toolbox.command` — keeps working with {@link Command}.
753
+ */
754
+ type CommandInput<O extends OptionDefinition<unknown> = OptionDefinition<unknown>, TLogger extends Console = Console, TContext extends Toolbox<TLogger> = Toolbox<TLogger>> = Omit<Command<O, TLogger, TContext>, "env" | "options"> & {
755
+ /** Environment variables supported by this command, as an array or keyed by name. */
756
+ env?: Command<O, TLogger, TContext>["env"] | EnvDefinitionRecord;
757
+ /** Options supported by this command, as an array or keyed by option name. */
758
+ options?: Command<O, TLogger, TContext>["options"] | OptionDefinitionRecord;
759
+ };
760
+ /**
761
+ * A command of any shape, for collections.
762
+ *
763
+ * Handlers are contravariant in their toolbox, so a `CommandInput[]` annotated
764
+ * with the default toolbox rejects every command whose handler was typed against
765
+ * the narrower toolbox `defineCommand` infers — which is all of them. Pinning
766
+ * `TContext` to `never` accepts any handler, because `never` is assignable to
767
+ * whatever toolbox that handler asked for.
768
+ *
769
+ * Use it for arrays and registries that carry commands from different sources.
770
+ * It says nothing about the toolbox, so it is not useful for declaring one.
771
+ * @example
772
+ * ```typescript
773
+ * const releaseCommands: AnyCommandInput[] = [addCommand, generateCommand, doctorCommand];
774
+ * ```
775
+ */
776
+ type AnyCommandInput<TLogger extends Console = Console> = CommandInput<OptionDefinition<unknown>, TLogger, never>;
777
+ export { ArgumentDefinition as A, Command as C, EnvDefinitionRecord as E, LazyCommandModule as L, OptionDefinition as O, Plugin as P, RunCommandOptions as R, Toolbox as T, VERBOSITY_LEVEL as V, CerebroFs as a, CommandSection as b, CommandInput as c, PluginManager as d, CliRunOptions as e, CommandExecute as f, Cli as g, OptionDefinitionRecord as h, AnyCommandInput as i, CerebroProcess as j, EnvDefinition as k, OutputType as l, PluginContext as m };
@@ -0,0 +1 @@
1
+ const n=String.raw,p=n`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,e=()=>new RegExp(n`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${p}(?:\u200D${p})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const u=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,i=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,c=e(),r=/[-_./\s]+/g,o=/(\u001B\[[0-9;]*[a-z])/i,a=new RegExp("\\p{Script=Arabic}","u"),E=new RegExp("\\p{Script=Bengali}","u"),g=new RegExp("\\p{Script=Cyrillic}","u"),s=new RegExp("\\p{Script=Devanagari}","u"),S=new RegExp("\\p{Script=Ethiopic}","u"),w=new RegExp("\\p{Script=Greek}","u"),R=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),x=new RegExp("\\p{Script=Gujarati}","u"),l=new RegExp("\\p{Script=Gurmukhi}","u"),B=new RegExp("\\p{Script=Hangul}","u"),F=new RegExp("\\p{Script=Hebrew}","u"),m=new RegExp("\\p{Script=Hiragana}","u"),y=new RegExp("\\p{Script=Han}","u"),d=new RegExp("\\p{Script=Kannada}","u"),h=new RegExp("\\p{Script=Katakana}","u"),k=new RegExp("\\p{Script=Khmer}","u"),G=new RegExp("\\p{Script=Lao}","u"),b=new RegExp("\\p{Script=Latin}","u"),H=new RegExp("\\p{Script=Malayalam}","u"),L=new RegExp("\\p{Script=Myanmar}","u"),M=new RegExp("\\p{Script=Oriya}","u"),j=new RegExp("\\p{Script=Sinhala}","u"),K=new RegExp("\\p{Script=Tamil}","u"),O=new RegExp("\\p{Script=Telugu}","u"),T=new RegExp("\\p{Script=Thai}","u"),f=new RegExp("\\p{Script=Tibetan}","u"),z=/[\u02BB\u02BC\u0027]/u,C=t=>t.replace(c,"");export{m as $,i as B,a as C,s as D,w as F,E as G,o as H,L as J,S as K,u as L,g as M,r as O,x as P,z as Q,y as U,M as V,B as W,C as X,h as Y,O as Z,H as b,c,F as d,j as f,k as h,G as j,b as k,l,R as m,T as q,f as v,d as y,K as z};
@@ -0,0 +1 @@
1
+ const a=e=>e;export{a as default};