@visulima/cerebro 3.1.2 → 4.0.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 (28) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/MIGRATION-GUIDE.md +29 -7
  3. package/README.md +5 -6
  4. package/dist/commands/completion-command.d.ts +1 -1
  5. package/dist/commands/completion-command.js +4 -4
  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 +1 -1
  10. package/dist/commands/version-command.d.ts +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.js +1 -1
  14. package/dist/packem_shared/{Cerebro-B02RU3RC.js → Cerebro-ggJmXJrF.js} +3 -3
  15. package/dist/packem_shared/{command.d-Dz7hkMI0.d.ts → command.d-DNTe-FYX.d.ts} +2 -2
  16. package/dist/packem_shared/constants-BGGeBKGT-C4poKWYI.js +1 -0
  17. package/dist/packem_shared/{format-positional-usage-DWL9qN10.js → format-positional-usage-Cm4bukjQ.js} +3 -3
  18. package/dist/packem_shared/runtime-process-BLYbrTb0.js +1 -0
  19. package/dist/plugins/error-handler-plugin.d.ts +1 -1
  20. package/dist/plugins/error-handler-plugin.js +1 -1
  21. package/dist/plugins/runtime-version-check-plugin.d.ts +3 -5
  22. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  23. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +1 -1
  24. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  25. package/dist/util/general/heap-tuning.js +1 -1
  26. package/package.json +6 -6
  27. package/dist/packem_shared/constants-BKuEbBw1-BRv49X2l.js +0 -1
  28. package/dist/packem_shared/runtime-process-BN-eTlwy.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,121 @@
1
+ ## @visulima/cerebro [4.0.0](https://github.com/visulima/visulima/compare/@visulima/cerebro@3.1.3...@visulima/cerebro@4.0.0) (2026-10-15)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ * Deno is no longer a supported runtime or package manager.
6
+ vis targets node/bun runtimes and aube/npm/pnpm/yarn package managers; the
7
+ deno-lint/deno-fmt adapters and deno inference targets are removed.
8
+
9
+ * fix: resolve eslint errors after deno removal
10
+
11
+ - vis: use a block body for applyIgnoreScripts (arrow-body-style)
12
+ - is-ansi-color-supported: drop stale eslint-disable directives and
13
+ replace the raw-release if/else with a ternary (unicorn/prefer-ternary)
14
+
15
+ * docs(cron-parser): remove remaining deno runtime mentions
16
+
17
+ These doc/config files arrived with main's dialect-gating commit after this
18
+ branch's base, so they still listed Deno as a supported runtime.
19
+
20
+ * feat!: remove deno runtime and tooling support
21
+
22
+ Deno is being wound down: Cloudflare is acquiring the Deno team, the runtime
23
+ gets one more year of monthly maintenance before development ends, and Deno
24
+ Deploy shuts down. Drop Deno as a supported runtime, package manager, and
25
+ lint/fmt/inference target across the monorepo.
26
+
27
+ - vis: remove the deno runtime path, deno-lint/deno-fmt adapters, the
28
+ deno.json inference detector, Deno PM handling (TypeScript + Rust native
29
+ resolver), and the devcontainer deno mount; regenerate the JSON schemas.
30
+ - libraries: drop Deno runtime detection from cerebro, ono,
31
+ is-ansi-color-supported, and task-runner command parsing; remove Deno
32
+ wording from package docs and READMEs.
33
+ - delete the examples/deno directories (ono, pail, storage) and Deno docs.
34
+ - keep JSR publishing (registry usable from Node), license/attribution
35
+ comments, the secret-scanner Deno-token rule, and the historical RFCs.
36
+ * Deno is no longer a supported runtime or package manager.
37
+ vis targets node/bun runtimes and aube/npm/pnpm/yarn package managers; the
38
+ deno-lint/deno-fmt adapters and deno inference targets are removed.
39
+
40
+ * fix: resolve eslint errors after deno removal
41
+
42
+ - vis: use a block body for applyIgnoreScripts (arrow-body-style)
43
+ - is-ansi-color-supported: drop stale eslint-disable directives and
44
+ replace the raw-release if/else with a ternary (unicorn/prefer-ternary)
45
+
46
+ * chore(vis): tidy deno-removal leftovers from review
47
+
48
+ * fix(vis): drop unused logger from x handler, restore bun typing
49
+
50
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
51
+
52
+ * docs: add migration notes for removed deno exports
53
+
54
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
55
+
56
+ * feat(vis): warn on stale adapter ids and deno-only projects
57
+
58
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
59
+
60
+ * refactor(vis): derive runtime ids and reuse bun detection
61
+
62
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
63
+
64
+ * refactor(vis): drop jsr deno option and deno auth reference
65
+
66
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
67
+
68
+ * fix(vis): restore runtime id schema description
69
+
70
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
71
+
72
+ * refactor(vis): remove jsr publishing support
73
+
74
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
75
+
76
+ * feat(bytes): port @std/bytes helpers back in
77
+
78
+ Carries the Uint8Array helpers from @std/bytes@1.0.6 (MIT, Copyright the Deno authors)
79
+ into src/std-bytes.ts and re-exports them from the package entry. Keeps the public API that
80
+ the Deno-removal commit dropped, without the jsr: devDependency. Docs and AGENTS notes are
81
+ restored to describe the ported functions.
82
+
83
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
84
+
85
+ * docs(bytes): attribute ported @std/bytes source
86
+
87
+ The license file still listed @jsr/std__bytes as a bundled dependency.
88
+ Replace it with the MIT notice for the ported src/std-bytes.ts, placed outside
89
+ the generated dependency blocks.
90
+
91
+ Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
92
+
93
+ * fix(cron-parser): keep reviewed docs and 1.1.0 version
94
+
95
+ The rebase onto the remote branch dropped the reviewed dialect sentence in the README and
96
+ the installation table row, and the release commit's 1.1.0 version bump.
97
+
98
+ ### Features
99
+
100
+ * remove deno runtime and tooling support ([#973](https://github.com/visulima/visulima/issues/973)) ([26fada1](https://github.com/visulima/visulima/commit/26fada1ac04731cba9db8f74fe20849c0a15db74))
101
+
102
+
103
+ ### Dependencies
104
+
105
+ * **@visulima/colorize:** upgraded to 3.0.0
106
+ * **@visulima/boxen:** upgraded to 6.0.0
107
+ * **@visulima/find-cache-dir:** upgraded to 4.0.0
108
+ * **@visulima/pail:** upgraded to 6.0.0
109
+ * **@visulima/path:** upgraded to 5.0.0
110
+
111
+ ## @visulima/cerebro [3.1.3](https://github.com/visulima/visulima/compare/@visulima/cerebro@3.1.2...@visulima/cerebro@3.1.3) (2026-10-13)
112
+
113
+
114
+ ### Dependencies
115
+
116
+ * **@visulima/colorize:** upgraded to 2.2.0
117
+ * **@visulima/pail:** upgraded to 5.0.1
118
+
1
119
  ## @visulima/cerebro [3.1.2](https://github.com/visulima/visulima/compare/@visulima/cerebro@3.1.1...@visulima/cerebro@3.1.2) (2026-09-21)
2
120
 
3
121
  ### Bug Fixes
@@ -6,14 +6,36 @@ This guide documents breaking changes and migration steps for the `@visulima/cer
6
6
 
7
7
  ### Breaking Changes Summary
8
8
 
9
- - **Supported runtimes**: Node.js 20.19+, Deno 1.0+, Bun 1.0+
9
+ - **Supported runtimes**: Node.js 20.19+, Bun 1.0+
10
10
  - **Module format**: ESM-only (CommonJS removed)
11
11
  - **Import structure**: Granular plugin and command exports
12
12
  - **Error handling**: Enhanced error types and validation
13
13
 
14
+ ### Deno runtime removed
15
+
16
+ Deno is no longer a supported runtime. Three public types changed with it:
17
+
18
+ - `RuntimeType` is now `"bun" | "node"`. `"deno"` is gone.
19
+ - `runtimeVersionCheckPlugin({ runtimes })` no longer accepts `runtimes.deno`. Remove that key. Passing it is a type error.
20
+ - The plugin no longer detects Deno. A Deno process falls through to the Node branch.
21
+
22
+ #### Before
23
+
24
+ ```ts
25
+ runtimeVersionCheckPlugin({ runtimes: { bun: { minVersion: 1 }, deno: { minVersion: 2 }, node: { minVersion: 20 } } });
26
+ ```
27
+
28
+ #### After
29
+
30
+ ```ts
31
+ runtimeVersionCheckPlugin({ runtimes: { bun: { minVersion: 1 }, node: { minVersion: 20 } } });
32
+ ```
33
+
34
+ If you match on the detected runtime type, drop the `"deno"` branch.
35
+
14
36
  ### CommonJS (CJS) Export Removed
15
37
 
16
- The CommonJS (CJS) export has been removed in favor of ECMAScript Modules (ESM) only. Cerebro now supports Node.js, Deno, and Bun runtimes. For CJS compatibility in Node.js 20.19+, use dynamic imports.
38
+ The CommonJS (CJS) export has been removed in favor of ECMAScript Modules (ESM) only. Cerebro now supports Node.js and Bun runtimes. For CJS compatibility in Node.js 20.19+, use dynamic imports.
17
39
 
18
40
  #### Before (v1.x)
19
41
 
@@ -22,14 +44,14 @@ The CommonJS (CJS) export has been removed in favor of ECMAScript Modules (ESM)
22
44
  const { Cerebro, createCerebro } = require("@visulima/cerebro");
23
45
  ```
24
46
 
25
- #### After (v2.x) - Node.js 20.19+, Deno 1.0+, Bun 1.0+
47
+ #### After (v2.x) - Node.js 20.19+, Bun 1.0+
26
48
 
27
49
  ```javascript
28
50
  // Use dynamic import for ESM modules from CJS (Node.js only)
29
51
  const { Cerebro, createCerebro } = await import("@visulima/cerebro");
30
52
  ```
31
53
 
32
- **Note**: Deno and Bun natively support ESM, so you can use standard `import` statements directly.
54
+ **Note**: Bun natively supports ESM, so you can use standard `import` statements directly.
33
55
 
34
56
  #### Alternative: Convert to ESM
35
57
 
@@ -271,7 +293,7 @@ Ensure your `package.json` uses ESM:
271
293
  }
272
294
  ```
273
295
 
274
- > **Note**: Deno and Bun don't use the `package.json` engines field. Deno uses `deno.json`, and Bun supports both `package.json` and `bunfig.toml`.
296
+ > **Note**: Bun doesn't use the `package.json` engines field; it supports both `package.json` and `bunfig.toml`.
275
297
 
276
298
  #### 2. Update Imports
277
299
 
@@ -709,8 +731,8 @@ cli.addPlugin(
709
731
 
710
732
  ### ESM Migration Benefits
711
733
 
712
- - **Better Performance**: ESM's improved module caching in Node.js 20.19+, native ESM support in Deno and Bun
713
- - **Cross-Runtime Support**: Works seamlessly across Node.js, Deno, and Bun
734
+ - **Better Performance**: ESM's improved module caching in Node.js 20.19+, native ESM support in Bun
735
+ - **Cross-Runtime Support**: Works seamlessly across Node.js and Bun
714
736
  - **Modern JavaScript**: Consistent module syntax across environments
715
737
  - **Bundle Optimization**: Better tree-shaking and dead code elimination
716
738
  - **Developer Experience**: Improved IDE support and error messages
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  </a>
8
8
 
9
- <h3 align="center">A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.</h3>
9
+ <h3 align="center">A delightful toolkit for building cross-runtime CLIs for Node.js and Bun.</h3>
10
10
 
11
11
  <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
12
12
 
@@ -135,7 +135,7 @@ cli.addCommand({
135
135
  await cli.run();
136
136
  ```
137
137
 
138
- Now you can run your CLI with `node index.js` (or `deno run index.js`, `bun index.js`). Here are some example usages:
138
+ Now you can run your CLI with `node index.js` (or `bun index.js`). Here are some example usages:
139
139
 
140
140
  ```bash
141
141
  # Show help
@@ -237,7 +237,7 @@ When your command's `execute` function is called, it receives a toolbox object w
237
237
  - **`args`**: Named positional arguments (camelCase keys) from the command's `arguments: [ ... ]` definitions; empty when none are declared
238
238
  - **`env`**: Environment variables (camelCase keys) processed from the command's `env: [...]` definitions
239
239
  - **`fs`**: Injected filesystem adapter (subset of `node:fs/promises`). Swap via `CliOptions.fs` for tests or sandboxed runtimes.
240
- - **`process`**: Runtime snapshot — `cwd`, `env`, `argv`, `stdin`, `exit`, `platform`, `arch`. Prefer this over the global `process` so commands stay portable across Node, Deno, Bun, and mocked test runtimes.
240
+ - **`process`**: Runtime snapshot — `cwd`, `env`, `argv`, `stdin`, `exit`, `platform`, `arch`. Prefer this over the global `process` so commands stay portable across Node, Bun, and mocked test runtimes.
241
241
  - **`runtime`**: Reference to the CLI instance
242
242
  - **`argv`**: Original command-line arguments array
243
243
 
@@ -287,7 +287,7 @@ cli.addCommand({
287
287
 
288
288
  ## Runtime Injection
289
289
 
290
- Commands receive an injected `{ fs, console, process }` context on the toolbox. Prefer reading from these over reaching for `node:fs/promises`, the global `console`, or the global `process` — commands written against the injected context stay testable, portable across Node/Deno/Bun, and ready to run inside sandboxed environments like MCP servers.
290
+ Commands receive an injected `{ fs, console, process }` context on the toolbox. Prefer reading from these over reaching for `node:fs/promises`, the global `console`, or the global `process` — commands written against the injected context stay testable, portable across Node/Bun, and ready to run inside sandboxed environments like MCP servers.
291
291
 
292
292
  ```ts
293
293
  import { Cerebro } from "@visulima/cerebro";
@@ -513,7 +513,7 @@ yarn add @bomb.sh/tab
513
513
  Import and add the completion command to your CLI. The completion command supports two options:
514
514
 
515
515
  - **`--shell`**: Shell type (bash, zsh, fish, powershell) - auto-detected by default
516
- - **`--runtime`**: JavaScript runtime (node, bun, deno) - auto-detected by default
516
+ - **`--runtime`**: JavaScript runtime (node, bun) - auto-detected by default
517
517
 
518
518
  ```ts
519
519
  import { Cerebro } from "@visulima/cerebro";
@@ -621,7 +621,6 @@ If completions don't work:
621
621
  Cerebro supports multiple JavaScript runtimes:
622
622
 
623
623
  - **Node.js**: >=20.19 <=25.x (follows [Node.js' release schedule](https://github.com/nodejs/release#release-schedule))
624
- - **Deno**: 1.0+
625
624
  - **Bun**: 1.0+
626
625
 
627
626
  The library uses runtime-agnostic APIs to ensure compatibility across all supported runtimes. Here's [a post on why we think tracking Node.js releases is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
@@ -1,4 +1,4 @@
1
- import { C as Command } from "../packem_shared/command.d-Dz7hkMI0.js";
1
+ import { C as Command } from "../packem_shared/command.d-DNTe-FYX.js";
2
2
  import '@visulima/tabular';
3
3
  /**
4
4
  * Generates shell completion scripts for the CLI application.
@@ -1,5 +1,5 @@
1
- import{C as u}from"../packem_shared/cerebro-error-Dv3FuXO8.js";class d extends u{troubleshooting;constructor(t,n,o=[]){super(t,n,{troubleshooting:o}),this.name="CompletionError",this.troubleshooting=o,o.length>0&&(this.hint=o.join(`
2
- `))}}const c=["bash","zsh","fish","powershell"],h=["node","bun","deno"],f=e=>"Deno"in e,S=e=>"Bun"in e,p=()=>f(globalThis)?"deno":S(globalThis)?"bun":"node",m=e=>{const n=e?.starshipShell??e?.shell;if(n){const s=n.toLowerCase();if(s.includes("zsh"))return"zsh";if(s.includes("bash"))return"bash";if(s.includes("fish"))return"fish"}const o=e?.psModulePath,i=e?.prompt;if(o||i?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},b=async()=>(await import("@bomb.sh/tab")).default,g=(e,t)=>{for(const n of t)n.hidden||(n.name&&e.option(n.name,n.description??""),n.alias&&e.option(n.alias,n.description??""))},w=(e,t)=>{for(const[n,o]of t){if(o.name!==n||o.hidden)continue;const i=e.command(o.name,o.description??"");o.options&&g(i,o.options)}},$=e=>{if(!c.includes(e))throw new d(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${c.join(", ")}`,"Shell will be auto-detected if not specified"])},y=e=>{if(e&&!h.includes(e))throw new d(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${h.join(", ")}`,"Runtime will be auto-detected if not specified"])},C=(e,t)=>{e.error("Could not detect current shell");const n=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
3
- `);e.info(n)},L={description:"Generate shell completion scripts",env:[{description:"Shell path (Unix-like systems). Used for shell detection.",name:"SHELL",type:String},{description:"Starship shell configuration. Takes precedence over SHELL for detection.",name:"STARSHIP_SHELL",type:String},{description:"PowerShell module path (Windows). Used for PowerShell detection.",name:"PSModulePath",type:String},{description:"Command prompt variable (Windows). Used for PowerShell detection.",name:"PROMPT",type:String},{description:"Command processor (Windows). Used for Windows Command Prompt detection.",name:"ComSpec",type:String}],execute:async({env:e,logger:t,options:n,runtime:o})=>{const i=o.getCliName(),l=n.shell??m(e);if(!l){C(t,i);return}try{$(l),y(n.runtime);const s=await b();w(s,o.getCommands());const r=`${n.runtime??p()} ${i}`;s.setup(i,r,l)}catch(s){if(s instanceof d){const a=[`Failed to generate completion script: ${s.message}`,`Error code: ${s.code}`];throw s.troubleshooting.length>0&&a.push("","Troubleshooting:",...s.troubleshooting.map(r=>` • ${r}`)),t.error(a.join(`
1
+ import{C as u}from"../packem_shared/cerebro-error-Dv3FuXO8.js";import{h as f}from"../packem_shared/runtime-process-BLYbrTb0.js";class d extends u{troubleshooting;constructor(t,n,o=[]){super(t,n,{troubleshooting:o}),this.name="CompletionError",this.troubleshooting=o,o.length>0&&(this.hint=o.join(`
2
+ `))}}const c=["bash","zsh","fish","powershell"],h=["node","bun"],p=()=>f(globalThis)?"bun":"node",m=e=>{const n=e?.starshipShell??e?.shell;if(n){const s=n.toLowerCase();if(s.includes("zsh"))return"zsh";if(s.includes("bash"))return"bash";if(s.includes("fish"))return"fish"}const o=e?.psModulePath,i=e?.prompt;if(o||i?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},S=async()=>(await import("@bomb.sh/tab")).default,b=(e,t)=>{for(const n of t)n.hidden||(n.name&&e.option(n.name,n.description??""),n.alias&&e.option(n.alias,n.description??""))},g=(e,t)=>{for(const[n,o]of t){if(o.name!==n||o.hidden)continue;const i=e.command(o.name,o.description??"");o.options&&b(i,o.options)}},w=e=>{if(!c.includes(e))throw new d(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${c.join(", ")}`,"Shell will be auto-detected if not specified"])},$=e=>{if(e&&!h.includes(e))throw new d(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${h.join(", ")}`,"Runtime will be auto-detected if not specified"])},y=(e,t)=>{e.error("Could not detect current shell");const n=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
3
+ `);e.info(n)},L={description:"Generate shell completion scripts",env:[{description:"Shell path (Unix-like systems). Used for shell detection.",name:"SHELL",type:String},{description:"Starship shell configuration. Takes precedence over SHELL for detection.",name:"STARSHIP_SHELL",type:String},{description:"PowerShell module path (Windows). Used for PowerShell detection.",name:"PSModulePath",type:String},{description:"Command prompt variable (Windows). Used for PowerShell detection.",name:"PROMPT",type:String},{description:"Command processor (Windows). Used for Windows Command Prompt detection.",name:"ComSpec",type:String}],execute:async({env:e,logger:t,options:n,runtime:o})=>{const i=o.getCliName(),l=n.shell??m(e);if(!l){y(t,i);return}try{w(l),$(n.runtime);const s=await S();g(s,o.getCommands());const r=`${n.runtime??p()} ${i}`;s.setup(i,r,l)}catch(s){if(s instanceof d){const a=[`Failed to generate completion script: ${s.message}`,`Error code: ${s.code}`];throw s.troubleshooting.length>0&&a.push("","Troubleshooting:",...s.troubleshooting.map(r=>` • ${r}`)),t.error(a.join(`
4
4
  `)),s}else{const r=["Failed to generate completion script",`Error: ${s instanceof Error?s.message:String(s)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${c.join(", ")}`,` • Verify runtime is supported: ${h.join(", ")}`," • Check that your CLI name is correct"];t.error(r.join(`
5
- `))}}},name:"completion",options:[{defaultOption:!0,defaultValue:m(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultValue:p(),description:"JavaScript runtime (node, bun, deno). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]};export{L as default};
5
+ `))}}},name:"completion",options:[{defaultOption:!0,defaultValue:m(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultValue:p(),description:"JavaScript runtime (node, bun). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]};export{L as default};
@@ -1,4 +1,4 @@
1
- import { O as OptionDefinition, A as ArgumentDefinition, C as Command, T as Toolbox } from "../packem_shared/command.d-Dz7hkMI0.js";
1
+ import { O as OptionDefinition, A as ArgumentDefinition, C as Command, T as Toolbox } from "../packem_shared/command.d-DNTe-FYX.js";
2
2
  import '@visulima/tabular';
3
3
  declare class HelpCommand<TLogger extends Console = Console> implements Command<OptionDefinition<string>, TLogger> {
4
4
  argument: ArgumentDefinition<string>;
@@ -1 +1 @@
1
- import{inverse as d,cyan as f,green as h,yellow as y}from"@visulima/colorize";import{t as v,c as b,f as E}from"../packem_shared/format-positional-usage-DWL9qN10.js";const N=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],$="__Other",C=r=>r.charAt(0).toUpperCase()+r.slice(1),w=(r,s,l,o)=>{r.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(t=>!t.hidden);o&&(m=m.filter(t=>t.group===o));const e=m.reduce((t,i)=>{const p=i.group??$;return t[p]??=[],t[p].push(i),t},{}),a=t=>t.map(i=>{let p="";typeof i.alias=="string"?p=i.alias:Array.isArray(i.alias)&&(p=i.alias.join(", ")),p!==""&&(p=` [${p}]`);let u=i.name;return i.commandPath&&i.commandPath.length>0&&(u=`${i.commandPath.join(" ")} ${i.name}`),[`${h(u)}${p}`,i.description??""]});(r.raw??r.log)(b([{content:`${f(s.getCliName())} ${h("<command>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},...Object.keys(e).map(t=>{const i=o?` ${C(o)}`:"";return{content:a(e[t]),header:t===$||o?d.green(` Available${i} Commands `):` ${d.green(` ${C(t)} `)}`}}),l.has("help")?{header:d.yellow(" Command Options "),optionList:l.get("help").options?.filter(t=>!t.hidden)}:void 0,{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:N.filter(t=>!t.hidden).map(t=>[t.name,t.description??""]),header:d.magenta(" Environment Variables ")},{content:`Run "${f(s.getCliName())} ${h("help <command>")}" or "${f(s.getCliName())} ${h("<command>")} ${y("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},P=(r,s)=>{const l=[];for(const o of r.values()){if(o.hidden)continue;const m=o.commandPath??[];if(m.length<s.length)continue;let e=!0;for(const[a,t]of s.entries())if(m[a]!==t){e=!1;break}e&&l.push(o)}return l},O=(r,s,l,o)=>{const m=l.join(" "),e=[{content:`${f(s.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},{content:o.map(a=>{const t=[...a.commandPath??[],a.name].join(" ");return[h(t),a.description??""]}),header:d.green(" Subcommands ")},{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:`Run "${f(s.getCliName())} ${h(`${m} <subcommand>`)} ${y("--help")}" for help with a specific subcommand.`,raw:!0}];(r.raw??r.log)(b(e))},A=(r,s,l,o,m)=>{let e=m??l.get(o);if(!e)for(const n of l.values()){const c=n.commandPath?[...n.commandPath,n.name]:[n.name];if(c.at(-1)===o||c.join(" ")===o){e=n;break}}if(!e){const n=o.split(" ").filter(Boolean),c=n.length>0?P(l,n):[];if(c.length>0){O(r,s,n,c);return}r.error(`Command "${o}" not found`);return}const a=[],i=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");a.push({content:`${f(s.getCliName())} ${h(i)}${E(e)}${e.options?" [options]":""}`,header:d.cyan(" Usage ")}),e.description&&a.push({content:e.description,header:d.green(" Description ")});const p=(e.argument?[e.argument]:e.arguments??[]).filter(n=>!n.hidden);if(p.length>0&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:p}),Array.isArray(e.options)&&e.options.length>0&&a.push({header:d.yellow(" Command Options "),optionList:e.options.filter(n=>!n.hidden)}),a.push({header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const n=e.env.filter(c=>!c.hidden);n.length>0&&a.push({content:n.map(c=>[c.name,c.description??""]),header:d.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let n=e.alias;typeof e.alias=="string"&&(n=[e.alias]),a.splice(1,0,{content:n,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&a.push({content:e.examples,header:"Examples"});const u=[...e.commandPath??[],e.name],g=P(l,u);g.length>0&&a.push({content:g.map(n=>{const c=[...n.commandPath??[],n.name].join(" ");return[h(c),n.description??""]}),header:d.green(" Subcommands ")}),(r.raw??r.log)(b(a))};class S{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(s){this.commands=s}execute(s){const{argument:l,command:o,commandName:m,logger:e,options:a,runtime:t}=s,{footer:i,header:p}=t.getCommandSection();p&&(e.raw??e.log)(v(p));const u=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&u===void 0)w(e,t,this.commands,typeof a?.group=="string"?a.group:void 0);else{const g=u!==void 0||o===void 0||o.name==="help"?void 0:o;A(e,t,this.commands,u??m,g)}i&&(e.raw??e.log)(v(i))}}export{S as default};
1
+ import{inverse as d,cyan as f,green as h,yellow as y}from"@visulima/colorize";import{t as v,c as b,f as E}from"../packem_shared/format-positional-usage-Cm4bukjQ.js";const N=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],$="__Other",C=r=>r.charAt(0).toUpperCase()+r.slice(1),w=(r,s,l,o)=>{r.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(t=>!t.hidden);o&&(m=m.filter(t=>t.group===o));const e=m.reduce((t,i)=>{const p=i.group??$;return t[p]??=[],t[p].push(i),t},{}),a=t=>t.map(i=>{let p="";typeof i.alias=="string"?p=i.alias:Array.isArray(i.alias)&&(p=i.alias.join(", ")),p!==""&&(p=` [${p}]`);let u=i.name;return i.commandPath&&i.commandPath.length>0&&(u=`${i.commandPath.join(" ")} ${i.name}`),[`${h(u)}${p}`,i.description??""]});(r.raw??r.log)(b([{content:`${f(s.getCliName())} ${h("<command>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},...Object.keys(e).map(t=>{const i=o?` ${C(o)}`:"";return{content:a(e[t]),header:t===$||o?d.green(` Available${i} Commands `):` ${d.green(` ${C(t)} `)}`}}),l.has("help")?{header:d.yellow(" Command Options "),optionList:l.get("help").options?.filter(t=>!t.hidden)}:void 0,{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:N.filter(t=>!t.hidden).map(t=>[t.name,t.description??""]),header:d.magenta(" Environment Variables ")},{content:`Run "${f(s.getCliName())} ${h("help <command>")}" or "${f(s.getCliName())} ${h("<command>")} ${y("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},P=(r,s)=>{const l=[];for(const o of r.values()){if(o.hidden)continue;const m=o.commandPath??[];if(m.length<s.length)continue;let e=!0;for(const[a,t]of s.entries())if(m[a]!==t){e=!1;break}e&&l.push(o)}return l},O=(r,s,l,o)=>{const m=l.join(" "),e=[{content:`${f(s.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},{content:o.map(a=>{const t=[...a.commandPath??[],a.name].join(" ");return[h(t),a.description??""]}),header:d.green(" Subcommands ")},{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:`Run "${f(s.getCliName())} ${h(`${m} <subcommand>`)} ${y("--help")}" for help with a specific subcommand.`,raw:!0}];(r.raw??r.log)(b(e))},A=(r,s,l,o,m)=>{let e=m??l.get(o);if(!e)for(const n of l.values()){const c=n.commandPath?[...n.commandPath,n.name]:[n.name];if(c.at(-1)===o||c.join(" ")===o){e=n;break}}if(!e){const n=o.split(" ").filter(Boolean),c=n.length>0?P(l,n):[];if(c.length>0){O(r,s,n,c);return}r.error(`Command "${o}" not found`);return}const a=[],i=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");a.push({content:`${f(s.getCliName())} ${h(i)}${E(e)}${e.options?" [options]":""}`,header:d.cyan(" Usage ")}),e.description&&a.push({content:e.description,header:d.green(" Description ")});const p=(e.argument?[e.argument]:e.arguments??[]).filter(n=>!n.hidden);if(p.length>0&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:p}),Array.isArray(e.options)&&e.options.length>0&&a.push({header:d.yellow(" Command Options "),optionList:e.options.filter(n=>!n.hidden)}),a.push({header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const n=e.env.filter(c=>!c.hidden);n.length>0&&a.push({content:n.map(c=>[c.name,c.description??""]),header:d.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let n=e.alias;typeof e.alias=="string"&&(n=[e.alias]),a.splice(1,0,{content:n,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&a.push({content:e.examples,header:"Examples"});const u=[...e.commandPath??[],e.name],g=P(l,u);g.length>0&&a.push({content:g.map(n=>{const c=[...n.commandPath??[],n.name].join(" ");return[h(c),n.description??""]}),header:d.green(" Subcommands ")}),(r.raw??r.log)(b(a))};class S{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(s){this.commands=s}execute(s){const{argument:l,command:o,commandName:m,logger:e,options:a,runtime:t}=s,{footer:i,header:p}=t.getCommandSection();p&&(e.raw??e.log)(v(p));const u=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&u===void 0)w(e,t,this.commands,typeof a?.group=="string"?a.group:void 0);else{const g=u!==void 0||o===void 0||o.name==="help"?void 0:o;A(e,t,this.commands,u??m,g)}i&&(e.raw??e.log)(v(i))}}export{S as default};
@@ -1,4 +1,4 @@
1
- import { C as Command } from "../packem_shared/command.d-Dz7hkMI0.js";
1
+ import { C as Command } from "../packem_shared/command.d-DNTe-FYX.js";
2
2
  import '@visulima/tabular';
3
3
  /**
4
4
  * Generates README documentation for cerebro CLI commands.
@@ -1,4 +1,4 @@
1
- import{createRequire as L}from"node:module";import{f as R,c as F}from"../packem_shared/format-positional-usage-DWL9qN10.js";import{g as q,a as G,b as U}from"../packem_shared/runtime-process-BN-eTlwy.js";let k;const O=e=>(k??=L(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,t]=$.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return $.getBuiltinModule(e)}return O(e)},{resolve:v,join:V,dirname:B}=T("node:path"),C=async(e,n)=>{try{return await e.access(n),!0}catch{return!1}},z=async()=>{const{default:e}=await import("github-slugger"),n=new e;return t=>n.slug(t)},I=e=>e.filter(Boolean),W=(e,n)=>{const t=new Set,o=[];for(const s of e){const r=n(s);t.has(r)||(t.add(r),o.push(s))}return o},D=(e,n)=>{const o=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");return`${n} ${o}${R(e,"readme")}`},H=(e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(o=>!o.hidden);t.length>0&&n.push({content:t.map(o=>[o.name,o.description??""]),header:" Environment Variables "})},N=(e,n)=>{const t=[],s=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.options;t.push({content:`${n} ${s}${R(e)}${r?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "});const c=(e.argument?[e.argument]:e.arguments??[]).filter(a=>!a.hidden);if(c.length>0&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:c}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(a=>!a.hidden)}),H(e,t),e.alias!==void 0&&e.alias.length>0){const a=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:a,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),F(t)},J=(e,n)=>{const t=e.description?.trim().split(`
1
+ import{createRequire as L}from"node:module";import{f as R,c as F}from"../packem_shared/format-positional-usage-Cm4bukjQ.js";import{g as q,a as G,b as U}from"../packem_shared/runtime-process-BLYbrTb0.js";let k;const O=e=>(k??=L(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,t]=$.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return $.getBuiltinModule(e)}return O(e)},{resolve:v,join:V,dirname:B}=T("node:path"),C=async(e,n)=>{try{return await e.access(n),!0}catch{return!1}},z=async()=>{const{default:e}=await import("github-slugger"),n=new e;return t=>n.slug(t)},I=e=>e.filter(Boolean),W=(e,n)=>{const t=new Set,o=[];for(const s of e){const r=n(s);t.has(r)||(t.add(r),o.push(s))}return o},D=(e,n)=>{const o=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");return`${n} ${o}${R(e,"readme")}`},H=(e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(o=>!o.hidden);t.length>0&&n.push({content:t.map(o=>[o.name,o.description??""]),header:" Environment Variables "})},N=(e,n)=>{const t=[],s=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.options;t.push({content:`${n} ${s}${R(e)}${r?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "});const c=(e.argument?[e.argument]:e.arguments??[]).filter(a=>!a.hidden);if(c.length>0&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:c}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(a=>!a.hidden)}),H(e,t),e.alias!==void 0&&e.alias.length>0){const a=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:a,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),F(t)},J=(e,n)=>{const t=e.description?.trim().split(`
2
2
  `)[0]??"",o=D(e,n),s=N(e,n);return I([`## \`${o}\``,t,`\`\`\`
3
3
  ${s.trim()}
4
4
  \`\`\``]).join(`
@@ -1,4 +1,4 @@
1
- import { C as Command } from "../packem_shared/command.d-Dz7hkMI0.js";
1
+ import { C as Command } from "../packem_shared/command.d-DNTe-FYX.js";
2
2
  import '@visulima/tabular';
3
3
  declare const _default: Command;
4
4
  export { _default as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CerebroFs, b as CommandSection, O as OptionDefinition, T as Toolbox, c as CommandInput, P as Plugin, d as PluginManager, C as Command, e as CliRunOptions, R as RunCommandOptions, f as CommandExecute, g as Cli$1, h as OptionDefinitionRecord, E as EnvDefinitionRecord, A as ArgumentDefinition, L as LazyCommandModule } from "./packem_shared/command.d-Dz7hkMI0.js";
2
- export type { i as AnyCommandInput, j as CerebroProcess, k as EnvDefinition, l as OutputType, m as PluginContext, V as VERBOSITY_LEVEL } from "./packem_shared/command.d-Dz7hkMI0.js";
1
+ import { a as CerebroFs, b as CommandSection, O as OptionDefinition, T as Toolbox, c as CommandInput, P as Plugin, d as PluginManager, C as Command, e as CliRunOptions, R as RunCommandOptions, f as CommandExecute, g as Cli$1, h as OptionDefinitionRecord, E as EnvDefinitionRecord, A as ArgumentDefinition, L as LazyCommandModule } from "./packem_shared/command.d-DNTe-FYX.js";
2
+ export type { i as AnyCommandInput, j as CerebroProcess, k as EnvDefinition, l as OutputType, m as PluginContext, V as VERBOSITY_LEVEL } from "./packem_shared/command.d-DNTe-FYX.js";
3
3
  import { V as VisulimaError } from "./packem_shared/index.d-CnnVYgSZ.js";
4
4
  import '@visulima/tabular';
5
5
  type CliOptions<T extends Console = Console> = {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Cli as o}from"./packem_shared/Cerebro-B02RU3RC.js";import{VERBOSITY_DEBUG as E,VERBOSITY_NORMAL as s,VERBOSITY_QUIET as p,VERBOSITY_VERBOSE as u}from"./packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js";import{default as l}from"./packem_shared/defineCommand-C_isHeEs.js";import{default as d}from"./packem_shared/InvalidArgumentChoiceError-BpovuqrZ.js";import{default as B}from"./packem_shared/MissingArgumentError-D78kza2a.js";import{default as O}from"./packem_shared/SurplusArgumentError-BLwT9lo0.js";import{lazyNamed as S}from"./packem_shared/lazyNamed-BKSCmVsV.js";import{c as C}from"./packem_shared/VisulimaError-BDqtOVL5-Db_MJ_p7.js";const a=(r,e)=>new o(r,e);export{o as Cerebro,d as InvalidArgumentChoiceError,B as MissingArgumentError,O as SurplusArgumentError,E as VERBOSITY_DEBUG,s as VERBOSITY_NORMAL,p as VERBOSITY_QUIET,u as VERBOSITY_VERBOSE,C as VisulimaError,a as createCerebro,l as defineCommand,S as lazyNamed};
1
+ import{Cli as o}from"./packem_shared/Cerebro-ggJmXJrF.js";import{VERBOSITY_DEBUG as E,VERBOSITY_NORMAL as s,VERBOSITY_QUIET as p,VERBOSITY_VERBOSE as u}from"./packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js";import{default as l}from"./packem_shared/defineCommand-C_isHeEs.js";import{default as d}from"./packem_shared/InvalidArgumentChoiceError-BpovuqrZ.js";import{default as B}from"./packem_shared/MissingArgumentError-D78kza2a.js";import{default as O}from"./packem_shared/SurplusArgumentError-BLwT9lo0.js";import{lazyNamed as S}from"./packem_shared/lazyNamed-BKSCmVsV.js";import{c as C}from"./packem_shared/VisulimaError-BDqtOVL5-Db_MJ_p7.js";const a=(r,e)=>new o(r,e);export{o as Cerebro,d as InvalidArgumentChoiceError,B as MissingArgumentError,O as SurplusArgumentError,E as VERBOSITY_DEBUG,s as VERBOSITY_NORMAL,p as VERBOSITY_QUIET,u as VERBOSITY_VERBOSE,C as VisulimaError,a as createCerebro,l as defineCommand,S as lazyNamed};
@@ -1 +1 @@
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
+ 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-BLYbrTb0.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,4 +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 b}from"./cerebro-error-Dv3FuXO8.js";import{c as re,d as we,o as be,e as F,a as Ct,b as Nt,f as bt,h as Ot,i as _t}from"./runtime-process-BN-eTlwy.js";import{c as ee}from"./VisulimaError-BDqtOVL5-Db_MJ_p7.js";import Et from"./InvalidArgumentChoiceError-BpovuqrZ.js";import xt 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 Ee,$ as Lt,W as xe,d as ke,C as Ie,D as Ut,G as Mt,P as Tt,l as St,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 Kt,h as Gt,V as Ht}from"./constants-BKuEbBw1-BRv49X2l.js";import{E as Xt,f as Yt}from"./format-user-facing-error-Cb7ySnUi.js";import{distance as Jt}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:Ne,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 b{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 Ge extends b{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 Zt extends b{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 Qt extends b{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 en{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 Qt(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 l=o[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${o.name}`);try{await(e==="afterCommand"?l(n,s):l(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 l=this.plugins.get(o);if(!l)throw new Error(`Plugin "${o}" not found`);if(s.add(o),l.dependencies)for(const a of l.dependencies)i(a);s.delete(o),n.add(o),e.push(l)};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",tn=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??tn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),nn=new RegExp(/^-([^\d-])$/),sn=new RegExp(/^--(\S+)/),on=new RegExp(/^-([^\d-]{2,})$/),rn=t=>nn.test(t)||sn.test(t)||on.test(t),an=(t,e)=>{const n=e[0]&&rn(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 ln=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 K=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},cn=(t,e,n={})=>{const{optionName:s,strictTypes:i}=n;return Array.isArray(t)?K(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:K(e)?!!t:ye(e)?Ue(t,i,s):Le(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},x=(t,e,n,...s)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...s)},hn=/-([a-z])/g,un=/^\d+$/,pn=t=>t.codePointAt(0)===95,Me=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Te=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]},Se=(t,e,n,s,i)=>{let o=e.get(t)??n.get(t);if(!o&&s){const l=t.toLowerCase();o=s.get(l)??i?.get(l)}return o},fn=(t,e,n,s)=>{const i=n.debug??!1;x(i,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(i,"Starting argument resolution","resolver"),x(i,"Tokens:","resolver",t),x(i,"Definitions:","resolver",e),x(i,"Processing tokens...","resolver");const o=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const f of e)if(o.set(f.name,f),f.alias&&l.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&&c){const w=f.name.replaceAll(hn,(v,I)=>I.toUpperCase());r.set(f.name,w),c.set(w,f.name)}const p=Object.create(null),h=Object.create(null),m=[],g=[],y=new Set;let A=!1;const d=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=Se(w.name,o,l,a,u);!v&&w.value===void 0&&O&&un.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=Se(_,o,l,a,u);M?.type&&K(M.type)&&(v=M,I=!0)}const N=v?v.name:w.name,$=v?.multiple,U=v?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!$&&!U&&!n.partial)throw new ln(N);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,S=_&&v&&!(v.type&&K(v.type))&&(_.kind==="positional"||M),lt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(S&&(!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[N]=h[N]===void 0?ae:Me(h[N],ae),f=D-1}else U?(he(h,N,_.value,!0),y.add(_.index),f++):(h[N]=_.value,y.add(_.index),f++);else v?.type&&K(v.type)?he(h,N,!I,$):($||U)&&h[N]!==void 0?he(h,N,null,!0):h[N]=$?[]:null}else{let{value:_}=w;if(v?.type&&K(v.type))switch(_){case"":{if(n.partial){const S=`${w.rawName??`--${w.name}`}${w.value?`=${w.value}`:""}`;g.push({index:w.index,value:S}),_=!0}else throw new Pe(w.name);break}case"false":{_=!1;break}case"true":{_=!0;break}default:_=!0}const M=[_];if($){let S=f+1;for(;S<t.length&&t[S].kind==="positional";)M.push(t[S].value),y.add(t[S].index),S++;f=S-1}h[N]===void 0?h[N]=$||U?M:_:$||U?h[N]=Me(h[N],M):h[N]=_}}else if(w.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(w.index)&&!d){x(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??"")&&!l.has(f.name??"")&&(!n.caseInsensitive||!a?.has(f.name?.toLowerCase()??"")&&!u?.has(f.name?.toLowerCase()??""));let E=-1,H=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!A&&(E=t.findIndex(f=>k(f)),E!==-1&&(H=t[E].index)),d){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[d.name],I=d.multiple??d.lazyMultiple;v===void 0?I?(w.forEach(N=>y.add(N.index)),h[d.name]=f):(y.add(w[0].index),h[d.name]=f[0]):I&&(w.forEach(N=>y.add(N.index)),h[d.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 g)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(E!==-1&&f!==-1?w=Math.min(E,f):E!==-1?w=E: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]=cn(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 N of e)if(N.group){const $=Array.isArray(N.group)?N.group:[N.group];for(const U of $)Te(U)||(f[U]??={})}for(const N of Object.keys(p))if(!pn(N)){w[N]=p[N];let $=N;n.camelCase&&($=c?.get(N)??N);const U=o.get($);if(U?.group){const _=Array.isArray(U.group)?U.group:[U.group];for(const M of _)Te(M)||f[M]&&(f[M][N]=p[N])}else v[N]=p[N]}const I={_all:w};for(const[N,$]of Object.entries(f))I[N]=$;Object.keys(v).length>0&&(I._none=v),p._unknown&&(I._unknown=p._unknown),Object.keys(p).forEach(N=>delete p[N]),Object.assign(p,I)}const T=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));return x(i,"Final parsed result:","resolver",T),T},Je="-",J=Je.codePointAt(0),G="=",dn=G.codePointAt(0),gn="--",mn=Je,wn="--",Ze=t=>t.length>2&&t.startsWith(wn),yn=t=>Ze(t)&&!t.includes(G,3),vn=t=>Ze(t)&&t.includes(G,3),An=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)},Cn=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)},Nn=t=>{const e=[];let n=0,s=[],i=0,o=-1,l=0;for(;i<s.length||n<t.length;){let a;if(i<s.length?(a=s[i],i++):(a=t[n],n++),l>0?l--:o++,a===gn){e.push({index:o,kind:"option-terminator"});const u=[...s.slice(i),...t.slice(n)],r=u.map((c,p)=>({index:o+p+1,kind:"positional",value:c}));e.push(...r),o+=u.length;break}if(An(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Cn(a)&&!a.includes(G)){const u=[];let r="",c=!1;for(let p=1;p<a.length;p++){const h=a.charAt(p);c?r+=h:h.codePointAt(0)===dn?c=!0:u.push(`${mn}${h}`)}if(c)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,l=u.length;continue}if(yn(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(vn(a)){const u=a.indexOf(G),r=a.slice(2,u),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}if(a.length>2&&a.codePointAt(0)===J&&a.codePointAt(1)!==J&&a.includes(G)){const u=a.indexOf(G),r=a.charAt(1),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}e.push({index:o,kind:"positional",value:a})}return e},bn=/\d/,On=t=>typeof t=="function",_n=(t,e,n)=>{const s=n?.debug??!1;x(s,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,o=new Set,l=new Set,a=new Set;let u=0;for(const r of t){if(x(s,"Checking definition:","validation",r),!r.name)throw x(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 c=e?r.name.toLowerCase():"";if(i.has(r.name)||e&&l.has(c))throw new L(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(c))throw new L(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(i.add(r.name),e&&l.add(c),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(bn.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&&l.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&&K(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"&&On(r.type)))throw new L("Invalid option definition: invalid type")}if(u>1)throw x(s,"Validation failed: multiple defaultOptions not allowed","validation"),new L("Invalid option definition: multiple defaultOptions not allowed");x(s,"Validation completed successfully","validation")};function En(t,e={}){const n=e.debug??!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const s={...e};s.stopAtFirstUnknown&&(s.partial=!0);const i=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",i),_n(i,s.caseInsensitive,n?s:void 0);let{argv:o}=s;o??=process.argv.slice(2),x(n,"Using argv:","index",o);let l=o;s.caseInsensitive&&(l=o.map(r=>{if(r.startsWith("--")){const c=r.indexOf("="),p=(c===-1?r.slice(2):r.slice(2,c)).toLowerCase();return c===-1?`--${p}`:`--${p}${r.slice(c)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const c=r.indexOf("="),p=c===-1?r.slice(1):r.slice(1,c);if(!p)return r;const h=p.toLowerCase();return c===-1?`-${h}`:`-${h}${r.slice(c)}`}return r}));const a=Nn(l.map(String));x(n,"Tokenized arguments:","index",a);const u=fn(a,i,s,o);return x(n,"Command-line-args parsing completed","index"),u}class xn{result;argv;options;argument;args;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;rawArgv;constructor(e,n){this.commandName=e,this.command=n}}class ue extends b{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 kn=/^-{1,2}(\w+)(=(.+))?$/,Qe=(t,e,n,s)=>{const i=kn.exec(t);if(i===null)return{};const o=i[1];if(!o)return{};const l=n&&s?n.get(o)??s.get(o):e.find(a=>a.name===o||a.alias===o);return l!==void 0?{argName:l.name,argValue:i[3],option:l}:{}},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)},In=new Set(["0","1","false","true"]),$n=(t,e,n,s)=>{if(e.length===0||t.length===0)return{};const i=(o,l)=>{const{argName:a,argValue:u,option:r}=Qe(l,e,n,s),{lastOption:c}=o;return r&&Q(r)&&u&&a?o.partial[a]=De(u,r):o.lastName&&c&&Q(c)&&In.has(l)&&(o.partial[o.lastName]=De(l,c)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(i,{partial:{}}).partial},Pn=new Set(["0","1","false","true"]),Ln=(t,e,n,s)=>{if(e.length===0||t.length===0)return t;const i=(o,l)=>{const{argValue:a,option:u}=Qe(l,e,n,s),{lastOption:r}=o;if(r&&Q(r)&&Pn.has(l)){const{args:p}=o;return{args:p.slice(0,-1)}}return u&&Q(u)&&a?{args:o.args}:{args:[...o.args,l],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()]},Un=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Mn=(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 Un(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)},Tn=/_./g,Sn=/^[A-Z]/,Dn=t=>t.toLowerCase().replaceAll(Tn,e=>e[1]?.toUpperCase()??e).replace(Sn,e=>e.toLowerCase()),Vn=(t,e=re())=>{if(!t||t.length===0)return{};const n={};for(const s of t){const i=e[s.name],o=Mn(s,i),l=o===void 0?s.defaultValue:o,a=Dn(s.name);n[a]=l}return n},jn=/-([a-z])/g,et=t=>t.replaceAll(jn,(e,n)=>n.toUpperCase()),je=(t,e)=>t.type===void 0?e:t.type(e),Rn=(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},Bn=(t,e)=>e&&t.defaultValue!==void 0&&!Array.isArray(t.defaultValue)?[t.defaultValue]:t.defaultValue,zn=(t,e)=>{const n={},s=[],i=[],o=t.length-1;let l=0;for(const[a,u]of t.entries()){const r=et(u.name),c=a===o&&u.multiple===!0,p=c?e.slice(a):e.slice(a,a+1);if(p.length===0){u.required===!0&&s.push(u.name),n[r]=Bn(u,c);continue}i.push(...Rn(u,p)),l=a+p.length,n[r]=c?p.map(h=>je(u,h)):je(u,p[0])}return{invalid:i,missing:s,resolved:n,surplus:e.slice(l)}},Fn=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},Wn=(t,e,n,s,i,o=[])=>{const l=new xn(t.name,t),{_all:a,_unknown:u,positionals:r}=e,p=Object.keys(n).length>0?{...a,...n}:a;oe in p&&delete p[oe],l.argument=r?.[oe]??[],l.args={},l.rawUnknown=[...u??[]],l.rawArgv=[...o];const h=Object.keys(s).length>0;return l.options=h?{...p,...s}:p,l.env=Vn(t.env,i),l},qn=(t,e,n)=>{const s=t.options??[],i=s.length>0;let o=Ve(i?[...s,...n]:n);if(o.length>0){for(const c of o)if(c.multiple&&c.lazyMultiple)throw new Error(`Argument "${c.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}const l=t.arguments!==void 0&&t.arguments.length>0;(t.argument||l)&&(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:c,optionMapByName:p}=Fn(s);a=Ln(e,s,p,c),u=$n(e,s,p,c)}else a=e,u={};const r=En(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),Kn=(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=zn(t.arguments,i);if(e.args=o.resolved,o.missing.length>0)throw new xt(t.name,o.missing);const[l]=o.invalid;if(l)throw new Et(l.name,l.value,l.choices);if(o.surplus.length>0)throw new kt(t.name,o.surplus,t.arguments.length)};let Gn=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 Hn=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Xn=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"),Yn=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(Xn,"")},fe=new Gn(1e3),Jn=/[.*+?^${}()|[\]\\]/g,Zn=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(Jn,String.raw`\$&`)).join("|"),s=new RegExp(n,"g");return fe.set(e,s),s},Qn=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)},es=/[ČŠŽĐ]/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 l=Object.values(e);for(const m of l)if(m(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],c="other";const p=Object.entries(e);for(const m of p){const[g,y]=m;if(y(a[0])){c=g;break}}let h=n&&s?a[0]===a[0].toLocaleUpperCase(s):!1;for(let m=1;m<a.length;m++){const g=a[m];let y="other";for(const C of p){const[O,k]=C;if(k(g)){y=O;break}}const A=n&&s?g===g.toLocaleUpperCase(s):!1;let d=!1;i?d=i(c,y,h,A,g,m,a):(c!==y&&c!=="other"&&y!=="other"&&(d=!0),n&&y!=="other"&&!h&&A&&(d=!0)),d?(u.push(r),r=g):r+=g,c=y,n&&(h=A)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},ts=(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 l=ts(t,n,e,s);if(l!==n){n=l,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&de(a),c=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&&c){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 g=!1,y=!1;if(o+1<i){const A=t.codePointAt(o+1);g=A&&A<128&&de(A),y=A&&A<128&&ge(A)}if(!y&&g){s.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<i){const g=t.codePointAt(o+1),y=g&&g<128&&Re(g);if(r&&c&&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],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e),g=m,y=m?0:-1;for(let A=1;A<c;A++){const d=r[A],C=d===d.toLocaleUpperCase(e);if(C===m)h+=d;else if(C)h&&h.length>0&&(p.push(h),h=d),g=!0,y=A;else{if(g&&A-y>1){const O=r[A-1],k=h.slice(0,-1);k&&k.length>0&&p.push(k),h=O+d}else h+=d;g=!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],c=r.length,p=[];let h=r[0];const m=r[0];let g;X.test(m)?g=1:P.test(m)?g=2:g=0;let y=m===m.toLocaleUpperCase(e);for(let d=1;d<c;d++){const C=r[d];let O;X.test(C)?O=1:P.test(C)?O=2:O=0;const k=C===C.toLocaleUpperCase(e);g!==O&&(g===1||g===2)&&(O===1||O===2)||O===g&&!y&&k?(p.push(h),h=C):h+=C,g=O,y=k}h&&h.length>0&&p.push(h);const A=[];for(let d=0;d<p.length;d++)d<p.length-1&&p[d].length===1&&P.test(p[d])&&X.test(p[d+1][0])?(A.push(p[d]+p[d+1]),d+=1):A.push(p[d]);return A}if(e.startsWith("el")){if(!ce.test(t)&&!P.test(t))return[t];const r=[];Oe.lastIndex=0;let c;for(;(c=Oe.exec(t))!==null;)r.push(c[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 g=h[0],y=h[0]===h[0].toLocaleUpperCase(e);for(let A=1;A<m;A++){const d=h[A],C=d===d.toLocaleUpperCase(e);!y&&C?(p.push(g),g=d):g+=d,y=C}g&&p.push(g)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),c=r?{hiragana:h=>Lt.test(h),kanji:h=>Ee.test(h),katakana:h=>Pt.test(h),latin:h=>P.test(h)}:{hangul:h=>xe.test(h),latin:h=>P.test(h)},p=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=j(t,c,!1,e,(g,y)=>g==="hiragana"&&y==="katakana"||g==="katakana"&&y==="hiragana"||g==="hiragana"&&y==="latin"||g==="katakana"&&y==="latin"||g==="kanji"&&y==="latin"||g==="latin"&&(y==="hiragana"||y==="katakana"||y==="kanji")),m=[];for(const g of h){const y=g;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,c,!1,e,(h,m)=>h==="hangul"&&m==="latin"||h==="latin"&&m==="hangul")}if(e.startsWith("sl")){const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e),d=es.test(y),C=g<c-1&&r[g+1]===r[g+1].toLocaleUpperCase(e);!m&&A||d&&C?(p.push(h),h=y,d&&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=>Ee.test(r),latin:r=>P.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=c=>ke.test(c)||Ie.test(c);return j(t,{latin:c=>P.test(c),rtl:c=>r(c)},!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=c=>Ut.test(c)||Mt.test(c)||Tt.test(c)||St.test(c)||Dt.test(c)||Vt.test(c)||jt.test(c)||Rt.test(c)||Bt.test(c)||zt.test(c)||Ft.test(c)||Wt.test(c)||qt.test(c)||Kt.test(c)||Gt.test(c)||Ht.test(c);return j(t,{indic:c=>r(c),latin:c=>P.test(c)},!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=>xe.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],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e);if(_e.test(y)||_e.test(r[g-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,l=[];let a=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){l.push(r),a=i[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const c=i[r],p=c===c.toLocaleUpperCase(e);let h=0;for(const m of n)if(t.startsWith(m,r)){l.push(a,m),h=m.length,a="";const g=m.at(-1);g&&(u=g===g.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&p?(l.push(a),a=c):a+=c,u=p}return a&&l.push(a),l},ns=(t,e,n)=>{const s=[],i=ie.test(t)?t.split(ie).filter(Boolean):[t];for(const o of i){const l=o;if(ie.test(l))s.push(l);else{q.lastIndex=0;const a=q.test(l)?Qn(l).filter(Boolean):[l];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},ss=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:s=!1,knownAcronyms:i=[],locale:o,normalize:l=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,c=new Set([...i].toSorted((d,C)=>C.length-d.length));let p=t;u&&(p=Yn(p)),r&&(p=It(p));let h;Array.isArray(a)?h=Zn(a):a instanceof RegExp?h=a:h=$t;const m=[];let g=p;const y=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;g.length>0;){const d=y.exec(g);if(!d){g===".."?m.push(".."):g==="."?m.push("."):g.length>0&&m.push(g);break}const C=d.index,O=d[0],k=O.length,E=g.slice(0,C),H=g.slice(C+k);if(O.startsWith("../"))m.push(".."),g=g.slice(C+3);else if(O.startsWith("./"))m.push("."),g=g.slice(C+2);else if(C===0&&O==="..")m.push(".."),g=g.slice(2);else if(C===0&&O===".")m.push("."),g=g.slice(1);else{E.length>0&&m.push(E);let T=0;for(;(T=O.indexOf("../",T))!==-1;)m.push(".."),T+=3;for(T=0;(T=O.indexOf("./",T))!==-1;)(T===0||O[T-1]!==".")&&m.push("."),T+=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 g=f}y.lastIndex=0}if(m.length===0){const d=p.split(h).filter(Boolean);m.push(...d)}let A=[];for(const d of m)n||s?A.push(...ns(d,o,c)):o?A.push(...rt(d,o,c)):A.push(...it(d,c));return l&&(A=A.map(d=>c.has(d)?d:o&&d===d.toLocaleUpperCase(o)?d[0]+d.slice(1).toLocaleLowerCase(o):d.toUpperCase()===d&&!c.has(d)?d.slice(0,1)+d.slice(1).toLowerCase():d)),A},os=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),is=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const s=[];let i="",o="";for(let l=0;l<n;l++){const a=t[l];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 is(ss(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,l=o.toLowerCase();return n?(n=!1,Hn(l)):os(l)}),"")};class rs extends b{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 as extends b{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 l=o.__camelCaseName__??o.name;if(i[l]===void 0){if(o.type?.name==="Boolean"){e[l]=!1;continue}s.push(o)}}return s},ls=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Jt(t,e)<=t.length/3,R=(t,e)=>{const n=t.toLowerCase();return e.filter(s=>ls(s.toLowerCase(),n))},cs=(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 l=R(s.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...u]=l.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 b(n.join(`
1
+ import{createRequire as ct}from"node:module";import{VERBOSITY_DEBUG as j,POSITIONALS_KEY as oe,VERBOSITY_NORMAL as le,VERBOSITY_QUIET as vt,VERBOSITY_VERBOSE as At}from"./VERBOSITY_DEBUG-D7HfSD5l.js";import{C as b}from"./cerebro-error-Dv3FuXO8.js";import{c as re,d as we,o as be,e as F,a as Ct,b as Nt,f as bt,i as Ot,j as _t}from"./runtime-process-BLYbrTb0.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{f as It,L as $t,T as ie,R as q,B as X,U as P,O as ce,K as Oe,Z as _e,W as Pt,m as xe,l as Lt,F as Ee,D as ke,x as Ie,H as Ut,w as Mt,M as Tt,C as St,P as Dt,j as jt,b as Vt,Y as Rt,k as Bt,J as zt,y as Ft,V as Wt,$ as qt,G as Kt,d as Gt,h as Ht}from"./constants-BGGeBKGT-C4poKWYI.js";import{E as Xt,f as Yt}from"./format-user-facing-error-Cb7ySnUi.js";import{distance as Jt}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:Ne,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 b{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 Ge extends b{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 Zt extends b{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 Qt extends b{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 en{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(j)&&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 Qt(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 l=o[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${o.name}`);try{await(e==="afterCommand"?l(n,s):l(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 l=this.plugins.get(o);if(!l)throw new Error(`Plugin "${o}" not found`);if(s.add(o),l.dependencies)for(const a of l.dependencies)i(a);s.delete(o),n.add(o),e.push(l)};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",tn=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??tn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),nn=new RegExp(/^-([^\d-])$/),sn=new RegExp(/^--(\S+)/),on=new RegExp(/^-([^\d-]{2,})$/),rn=t=>nn.test(t)||sn.test(t)||on.test(t),an=(t,e)=>{const n=e[0]&&rn(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 ln=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 K=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},cn=(t,e,n={})=>{const{optionName:s,strictTypes:i}=n;return Array.isArray(t)?K(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:K(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)},hn=/-([a-z])/g,un=/^\d+$/,pn=t=>t.codePointAt(0)===95,Me=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Te=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]},Se=(t,e,n,s,i)=>{let o=e.get(t)??n.get(t);if(!o&&s){const l=t.toLowerCase();o=s.get(l)??i?.get(l)}return o},fn=(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,l=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const f of e)if(o.set(f.name,f),f.alias&&l.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&&c){const w=f.name.replaceAll(hn,(v,I)=>I.toUpperCase());r.set(f.name,w),c.set(w,f.name)}const p=Object.create(null),h=Object.create(null),m=[],g=[],y=new Set;let A=!1;const d=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=Se(w.name,o,l,a,u);!v&&w.value===void 0&&O&&un.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=Se(_,o,l,a,u);M?.type&&K(M.type)&&(v=M,I=!0)}const N=v?v.name:w.name,$=v?.multiple,U=v?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!$&&!U&&!n.partial)throw new ln(N);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,S=_&&v&&!(v.type&&K(v.type))&&(_.kind==="positional"||M),lt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(S&&(!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[N]=h[N]===void 0?ae:Me(h[N],ae),f=D-1}else U?(he(h,N,_.value,!0),y.add(_.index),f++):(h[N]=_.value,y.add(_.index),f++);else v?.type&&K(v.type)?he(h,N,!I,$):($||U)&&h[N]!==void 0?he(h,N,null,!0):h[N]=$?[]:null}else{let{value:_}=w;if(v?.type&&K(v.type))switch(_){case"":{if(n.partial){const S=`${w.rawName??`--${w.name}`}${w.value?`=${w.value}`:""}`;g.push({index:w.index,value:S}),_=!0}else throw new Pe(w.name);break}case"false":{_=!1;break}case"true":{_=!0;break}default:_=!0}const M=[_];if($){let S=f+1;for(;S<t.length&&t[S].kind==="positional";)M.push(t[S].value),y.add(t[S].index),S++;f=S-1}h[N]===void 0?h[N]=$||U?M:_:$||U?h[N]=Me(h[N],M):h[N]=_}}else if(w.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(w.index)&&!d){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??"")&&!l.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)),d){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[d.name],I=d.multiple??d.lazyMultiple;v===void 0?I?(w.forEach(N=>y.add(N.index)),h[d.name]=f):(y.add(w[0].index),h[d.name]=f[0]):I&&(w.forEach(N=>y.add(N.index)),h[d.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 g)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]=cn(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 N of e)if(N.group){const $=Array.isArray(N.group)?N.group:[N.group];for(const U of $)Te(U)||(f[U]??={})}for(const N of Object.keys(p))if(!pn(N)){w[N]=p[N];let $=N;n.camelCase&&($=c?.get(N)??N);const U=o.get($);if(U?.group){const _=Array.isArray(U.group)?U.group:[U.group];for(const M of _)Te(M)||f[M]&&(f[M][N]=p[N])}else v[N]=p[N]}const I={_all:w};for(const[N,$]of Object.entries(f))I[N]=$;Object.keys(v).length>0&&(I._none=v),p._unknown&&(I._unknown=p._unknown),Object.keys(p).forEach(N=>delete p[N]),Object.assign(p,I)}const T=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));return E(i,"Final parsed result:","resolver",T),T},Je="-",J=Je.codePointAt(0),G="=",dn=G.codePointAt(0),gn="--",mn=Je,wn="--",Ze=t=>t.length>2&&t.startsWith(wn),yn=t=>Ze(t)&&!t.includes(G,3),vn=t=>Ze(t)&&t.includes(G,3),An=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)},Cn=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)},Nn=t=>{const e=[];let n=0,s=[],i=0,o=-1,l=0;for(;i<s.length||n<t.length;){let a;if(i<s.length?(a=s[i],i++):(a=t[n],n++),l>0?l--:o++,a===gn){e.push({index:o,kind:"option-terminator"});const u=[...s.slice(i),...t.slice(n)],r=u.map((c,p)=>({index:o+p+1,kind:"positional",value:c}));e.push(...r),o+=u.length;break}if(An(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Cn(a)&&!a.includes(G)){const u=[];let r="",c=!1;for(let p=1;p<a.length;p++){const h=a.charAt(p);c?r+=h:h.codePointAt(0)===dn?c=!0:u.push(`${mn}${h}`)}if(c)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,l=u.length;continue}if(yn(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(vn(a)){const u=a.indexOf(G),r=a.slice(2,u),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}if(a.length>2&&a.codePointAt(0)===J&&a.codePointAt(1)!==J&&a.includes(G)){const u=a.indexOf(G),r=a.charAt(1),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}e.push({index:o,kind:"positional",value:a})}return e},bn=/\d/,On=t=>typeof t=="function",_n=(t,e,n)=>{const s=n?.debug??!1;E(s,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,o=new Set,l=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 c=e?r.name.toLowerCase():"";if(i.has(r.name)||e&&l.has(c))throw new L(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(c))throw new L(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(i.add(r.name),e&&l.add(c),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(bn.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&&l.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&&K(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"&&On(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 xn(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),_n(i,s.caseInsensitive,n?s:void 0);let{argv:o}=s;o??=process.argv.slice(2),E(n,"Using argv:","index",o);let l=o;s.caseInsensitive&&(l=o.map(r=>{if(r.startsWith("--")){const c=r.indexOf("="),p=(c===-1?r.slice(2):r.slice(2,c)).toLowerCase();return c===-1?`--${p}`:`--${p}${r.slice(c)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const c=r.indexOf("="),p=c===-1?r.slice(1):r.slice(1,c);if(!p)return r;const h=p.toLowerCase();return c===-1?`-${h}`:`-${h}${r.slice(c)}`}return r}));const a=Nn(l.map(String));E(n,"Tokenized arguments:","index",a);const u=fn(a,i,s,o);return E(n,"Command-line-args parsing completed","index"),u}class En{result;argv;options;argument;args;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;rawArgv;constructor(e,n){this.commandName=e,this.command=n}}class ue extends b{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 kn=/^-{1,2}(\w+)(=(.+))?$/,Qe=(t,e,n,s)=>{const i=kn.exec(t);if(i===null)return{};const o=i[1];if(!o)return{};const l=n&&s?n.get(o)??s.get(o):e.find(a=>a.name===o||a.alias===o);return l!==void 0?{argName:l.name,argValue:i[3],option:l}:{}},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)},In=new Set(["0","1","false","true"]),$n=(t,e,n,s)=>{if(e.length===0||t.length===0)return{};const i=(o,l)=>{const{argName:a,argValue:u,option:r}=Qe(l,e,n,s),{lastOption:c}=o;return r&&Q(r)&&u&&a?o.partial[a]=De(u,r):o.lastName&&c&&Q(c)&&In.has(l)&&(o.partial[o.lastName]=De(l,c)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(i,{partial:{}}).partial},Pn=new Set(["0","1","false","true"]),Ln=(t,e,n,s)=>{if(e.length===0||t.length===0)return t;const i=(o,l)=>{const{argValue:a,option:u}=Qe(l,e,n,s),{lastOption:r}=o;if(r&&Q(r)&&Pn.has(l)){const{args:p}=o;return{args:p.slice(0,-1)}}return u&&Q(u)&&a?{args:o.args}:{args:[...o.args,l],lastOption:u}};return t.reduce(i,{args:[]}).args},je=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()]},Un=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Mn=(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 Un(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)},Tn=/_./g,Sn=/^[A-Z]/,Dn=t=>t.toLowerCase().replaceAll(Tn,e=>e[1]?.toUpperCase()??e).replace(Sn,e=>e.toLowerCase()),jn=(t,e=re())=>{if(!t||t.length===0)return{};const n={};for(const s of t){const i=e[s.name],o=Mn(s,i),l=o===void 0?s.defaultValue:o,a=Dn(s.name);n[a]=l}return n},Vn=/-([a-z])/g,et=t=>t.replaceAll(Vn,(e,n)=>n.toUpperCase()),Ve=(t,e)=>t.type===void 0?e:t.type(e),Rn=(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},Bn=(t,e)=>e&&t.defaultValue!==void 0&&!Array.isArray(t.defaultValue)?[t.defaultValue]:t.defaultValue,zn=(t,e)=>{const n={},s=[],i=[],o=t.length-1;let l=0;for(const[a,u]of t.entries()){const r=et(u.name),c=a===o&&u.multiple===!0,p=c?e.slice(a):e.slice(a,a+1);if(p.length===0){u.required===!0&&s.push(u.name),n[r]=Bn(u,c);continue}i.push(...Rn(u,p)),l=a+p.length,n[r]=c?p.map(h=>Ve(u,h)):Ve(u,p[0])}return{invalid:i,missing:s,resolved:n,surplus:e.slice(l)}},Fn=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},Wn=(t,e,n,s,i,o=[])=>{const l=new En(t.name,t),{_all:a,_unknown:u,positionals:r}=e,p=Object.keys(n).length>0?{...a,...n}:a;oe in p&&delete p[oe],l.argument=r?.[oe]??[],l.args={},l.rawUnknown=[...u??[]],l.rawArgv=[...o];const h=Object.keys(s).length>0;return l.options=h?{...p,...s}:p,l.env=jn(t.env,i),l},qn=(t,e,n)=>{const s=t.options??[],i=s.length>0;let o=je(i?[...s,...n]:n);if(o.length>0){for(const c of o)if(c.multiple&&c.lazyMultiple)throw new Error(`Argument "${c.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}const l=t.arguments!==void 0&&t.arguments.length>0;(t.argument||l)&&(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:c,optionMapByName:p}=Fn(s);a=Ln(e,s,p,c),u=$n(e,s,p,c)}else a=e,u={};const r=xn(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),Kn=(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=zn(t.arguments,i);if(e.args=o.resolved,o.missing.length>0)throw new Et(t.name,o.missing);const[l]=o.invalid;if(l)throw new xt(l.name,l.value,l.choices);if(o.surplus.length>0)throw new kt(t.name,o.surplus,t.arguments.length)};let Gn=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 Hn=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Xn=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"),Yn=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(Xn,"")},fe=new Gn(1e3),Jn=/[.*+?^${}()|[\]\\]/g,Zn=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(Jn,String.raw`\$&`)).join("|"),s=new RegExp(n,"g");return fe.set(e,s),s},Qn=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)},es=/[ČŠŽĐ]/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],V=(t,e,n,s,i)=>{if(t.length===0)return[];let o=!1;const l=Object.values(e);for(const m of l)if(m(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],c="other";const p=Object.entries(e);for(const m of p){const[g,y]=m;if(y(a[0])){c=g;break}}let h=n&&s?a[0]===a[0].toLocaleUpperCase(s):!1;for(let m=1;m<a.length;m++){const g=a[m];let y="other";for(const C of p){const[O,k]=C;if(k(g)){y=O;break}}const A=n&&s?g===g.toLocaleUpperCase(s):!1;let d=!1;i?d=i(c,y,h,A,g,m,a):(c!==y&&c!=="other"&&y!=="other"&&(d=!0),n&&y!=="other"&&!h&&A&&(d=!0)),d?(u.push(r),r=g):r+=g,c=y,n&&(h=A)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},ts=(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 l=ts(t,n,e,s);if(l!==n){n=l,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&de(a),c=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&&c){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 g=!1,y=!1;if(o+1<i){const A=t.codePointAt(o+1);g=A&&A<128&&de(A),y=A&&A<128&&ge(A)}if(!y&&g){s.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<i){const g=t.codePointAt(o+1),y=g&&g<128&&Re(g);if(r&&c&&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],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e),g=m,y=m?0:-1;for(let A=1;A<c;A++){const d=r[A],C=d===d.toLocaleUpperCase(e);if(C===m)h+=d;else if(C)h&&h.length>0&&(p.push(h),h=d),g=!0,y=A;else{if(g&&A-y>1){const O=r[A-1],k=h.slice(0,-1);k&&k.length>0&&p.push(k),h=O+d}else h+=d;g=!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],c=r.length,p=[];let h=r[0];const m=r[0];let g;X.test(m)?g=1:P.test(m)?g=2:g=0;let y=m===m.toLocaleUpperCase(e);for(let d=1;d<c;d++){const C=r[d];let O;X.test(C)?O=1:P.test(C)?O=2:O=0;const k=C===C.toLocaleUpperCase(e);g!==O&&(g===1||g===2)&&(O===1||O===2)||O===g&&!y&&k?(p.push(h),h=C):h+=C,g=O,y=k}h&&h.length>0&&p.push(h);const A=[];for(let d=0;d<p.length;d++)d<p.length-1&&p[d].length===1&&P.test(p[d])&&X.test(p[d+1][0])?(A.push(p[d]+p[d+1]),d+=1):A.push(p[d]);return A}if(e.startsWith("el")){if(!ce.test(t)&&!P.test(t))return[t];const r=[];Oe.lastIndex=0;let c;for(;(c=Oe.exec(t))!==null;)r.push(c[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 g=h[0],y=h[0]===h[0].toLocaleUpperCase(e);for(let A=1;A<m;A++){const d=h[A],C=d===d.toLocaleUpperCase(e);!y&&C?(p.push(g),g=d):g+=d,y=C}g&&p.push(g)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),c=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=V(t,c,!1,e,(g,y)=>g==="hiragana"&&y==="katakana"||g==="katakana"&&y==="hiragana"||g==="hiragana"&&y==="latin"||g==="katakana"&&y==="latin"||g==="kanji"&&y==="latin"||g==="latin"&&(y==="hiragana"||y==="katakana"||y==="kanji")),m=[];for(const g of h){const y=g;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 V(t,c,!1,e,(h,m)=>h==="hangul"&&m==="latin"||h==="latin"&&m==="hangul")}if(e.startsWith("sl")){const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e),d=es.test(y),C=g<c-1&&r[g+1]===r[g+1].toLocaleUpperCase(e);!m&&A||d&&C?(p.push(h),h=y,d&&C&&(p.push(h),h="")):h+=y,m=A}return h&&h.length>0&&p.push(h),p}if(e.startsWith("zh"))return V(t,{han:r=>xe.test(r),latin:r=>P.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=c=>ke.test(c)||Ie.test(c);return V(t,{latin:c=>P.test(c),rtl:c=>r(c)},!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=c=>Ut.test(c)||Mt.test(c)||Tt.test(c)||St.test(c)||Dt.test(c)||jt.test(c)||Vt.test(c)||Rt.test(c)||Bt.test(c)||zt.test(c)||Ft.test(c)||Wt.test(c)||qt.test(c)||Kt.test(c)||Gt.test(c)||Ht.test(c);return V(t,{indic:c=>r(c),latin:c=>P.test(c)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return V(t,{cyrillic:r=>X.test(r),latin:r=>P.test(r)},!0,e);if(["ar","fa","he"].includes(e))return V(t,{latin:r=>P.test(r),rtl:r=>ke.test(r)||Ie.test(r)},!1,e);if(e.startsWith("ko"))return V(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],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e);if(_e.test(y)||_e.test(r[g-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,l=[];let a=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){l.push(r),a=i[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const c=i[r],p=c===c.toLocaleUpperCase(e);let h=0;for(const m of n)if(t.startsWith(m,r)){l.push(a,m),h=m.length,a="";const g=m.at(-1);g&&(u=g===g.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&p?(l.push(a),a=c):a+=c,u=p}return a&&l.push(a),l},ns=(t,e,n)=>{const s=[],i=ie.test(t)?t.split(ie).filter(Boolean):[t];for(const o of i){const l=o;if(ie.test(l))s.push(l);else{q.lastIndex=0;const a=q.test(l)?Qn(l).filter(Boolean):[l];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},ss=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:s=!1,knownAcronyms:i=[],locale:o,normalize:l=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,c=new Set([...i].toSorted((d,C)=>C.length-d.length));let p=t;u&&(p=Yn(p)),r&&(p=It(p));let h;Array.isArray(a)?h=Zn(a):a instanceof RegExp?h=a:h=$t;const m=[];let g=p;const y=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;g.length>0;){const d=y.exec(g);if(!d){g===".."?m.push(".."):g==="."?m.push("."):g.length>0&&m.push(g);break}const C=d.index,O=d[0],k=O.length,x=g.slice(0,C),H=g.slice(C+k);if(O.startsWith("../"))m.push(".."),g=g.slice(C+3);else if(O.startsWith("./"))m.push("."),g=g.slice(C+2);else if(C===0&&O==="..")m.push(".."),g=g.slice(2);else if(C===0&&O===".")m.push("."),g=g.slice(1);else{x.length>0&&m.push(x);let T=0;for(;(T=O.indexOf("../",T))!==-1;)m.push(".."),T+=3;for(T=0;(T=O.indexOf("./",T))!==-1;)(T===0||O[T-1]!==".")&&m.push("."),T+=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 g=f}y.lastIndex=0}if(m.length===0){const d=p.split(h).filter(Boolean);m.push(...d)}let A=[];for(const d of m)n||s?A.push(...ns(d,o,c)):o?A.push(...rt(d,o,c)):A.push(...it(d,c));return l&&(A=A.map(d=>c.has(d)?d:o&&d===d.toLocaleUpperCase(o)?d[0]+d.slice(1).toLocaleLowerCase(o):d.toUpperCase()===d&&!c.has(d)?d.slice(0,1)+d.slice(1).toLowerCase():d)),A},os=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),is=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const s=[];let i="",o="";for(let l=0;l<n;l++){const a=t[l];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 is(ss(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,l=o.toLowerCase();return n?(n=!1,Hn(l)):os(l)}),"")};class rs extends b{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 as extends b{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 l=o.__camelCaseName__??o.name;if(i[l]===void 0){if(o.type?.name==="Boolean"){e[l]=!1;continue}s.push(o)}}return s},ls=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Jt(t,e)<=t.length/3,R=(t,e)=>{const n=t.toLowerCase();return e.filter(s=>ls(s.toLowerCase(),n))},cs=(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 l=R(s.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...u]=l.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 b(n.join(`
2
2
  `),Xt.UNKNOWN_OPTION,{unknownOptions:[...t._unknown??[]]})},W=(t,e)=>new b(`Command "${t}" ${e}`,"INVALID_COMMAND",{commandName:t}),hs=(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 l=et(o);if(n.has(l))throw W(e,`declares duplicate positional argument "${o}"`);n.add(l);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`)}},us=(t,e,n)=>{const s=n.__requiredOptions__,i=s?Be(s,e,!0):Be(t,e,!1);if(i.length>0)throw new rs(n.name,i.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&!n.arguments?.length&&cs(e,n)},ps=(t,e,n)=>{const s=n.__conflictingOptions__??t.filter(i=>i.conflicts!==void 0);if(s.length>0){const i=s.find(o=>{const l=o.__camelCaseName__??Y(o.name);return Array.isArray(o.conflicts)?o.conflicts.some(a=>e[Y(a)]!==void 0)&&e[l]!==void 0:e[Y(o.conflicts)]!==void 0&&e[l]!==void 0});if(i)throw new Ge(i.name,typeof i.conflicts=="string"?i.conflicts:i.conflicts?.[0]??"unknown")}},fs=(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 l=Array.isArray(o)?o:[o];for(const a of l){const u=String(a);if(!s.choices.includes(u))throw new as(s.name,u,s.choices)}}},ds=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 l=n.get(o)??[];l.push(i),n.set(o,l)}}}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(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(s.length>0)throw new Error(s.join(`
3
- `))},gs=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');hs(e,t.name)}},ms=(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 l=n.join(" ");t.has(l)&&(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})),ws=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})},ys=/^no-/,vs=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Y(e.name)})},As=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(ys,"");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,alias:void 0,defaultValue:s.defaultValue===void 0?!0:!s.defaultValue,description:`Inverse of --${s.name}.`,name:i};n.push(o),e.add(i)}}n.length>0&&t.options.push(...n)},Cs=(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 l=Y(o.name);s.set(l,o)}const i=Object.keys(n).filter(o=>s.has(o));if(i.length!==0)for(const o of i){const l=o.charAt(2);if(!l)continue;const a=l.toLowerCase()+o.slice(3),u=s.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},Ns=(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:l}=o;for(const[a,u]of Object.entries(l))s[a]===void 0&&(s[a]=u)}}},bs=()=>!!process.versions.electron,Os=()=>bs()&&!process.defaultApp,_s=()=>Os()?0:1,Es=t=>t.slice(_s()+1),xs=" ",ks=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,s)=>n===e[s]),Is=t=>{if(typeof t=="string")return t.split(xs);const e=we();return ks(t,e)?Es(t):t},$s=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),F(1)},n=(o,l)=>{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=be("uncaughtException",e),i=be("unhandledRejection",n);return()=>{s(),i()}},We=100,Ps=/^[a-z][\w-]*$/i,ve=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new b(`${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 b(`${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 b(`${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 b(`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 b(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Ps.test(e))throw new b(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Ls=1e6,Us=1e5,Ms=new Set([`
4
- `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Ts=(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??Ls;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(Ms.has(i))throw new Error(`Argument contains dangerous character: ${i}`)}return n.trim?t.trim():t},Ke=(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??Us;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Too many arguments (maximum ${String(s)})`);return t.map(i=>Ts(i,n))},Ss=/^-([^\d-])$/,Ds=/^--(\S+)/,Vs=/^-([^\d-]{2,})$/,me=t=>Ss.test(t)||Ds.test(t)||Vs.test(t),js={access:(t,e)=>yt(t,e),mkdir:(t,e)=>wt(t,e),readdir:t=>mt(t),readFile:(async(t,e)=>e===void 0?Ne(t):Ne(t,e)),rm:(t,e)=>gt(t,e),stat:t=>dt(t),writeFile:(t,e,n)=>ft(t,e,n)},Rs=(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 l=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>R(u.slice(2),l).map(r=>`--${r}`));throw new Zt(o,a)};class at{#t;#e;#h;#p;#f;#d;#O;#_;#E;#A;#x;#C;#k;#N=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}#b(){if(this.#h===void 0){const e=Is(this.#e.argv);this.#h=Ke(e,{maxArguments:this.#C}),this.#V()}return this.#h}#y(){return this.#A??re()}#v(e){this.#N=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#N}#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.#$=$s(this.#t),this.#P=!0)}#R(){return{arch:Nt(),argv:this.#b(),cwd:this.#p,env:this.#A??re(),exit:this.#E??(e=>F(e??0)),platform:Ct(),stdin:this.#x}}#T(e,n,s,i){this.#c()===V&&this.#t.debug(`command '${i}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:l,parsedArgs:a}=qn(e,n,this.#U()),u=Object.keys(l).length>0;let r=a;u&&(r={...a,_all:{...a._all,...l}}),us(o,r,e);const c=Wn(e,a,l,s,this.#y(),n);c.runtime=this,c.argv=this.#b(),c.fs=this.#_??js,c.process=this.#R(),c.console=this.#t,Kn(e,c);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 g=m.name.slice(3),y=`--${m.name}`,A=`--${g}`,d=n.includes(y),C=n.includes(A);if(d&&C)throw new Ge(g,m.name)}}return p&&(Cs(c,e),Ns(c,e)),ps(o,c.options,e),fs(c.options,e),this.#k&&Rs(e,n,c.rawUnknown),this.#c()===V&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:o,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:c}}async#S(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 l=s.global;if(l?.help){const a=this.#n.get("help");if(!a)throw new b("Help command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else if(l?.version??l?.V){const a=this.#n.get("version");if(!a)throw new b("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 b("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const s=n.argv??we(),i=n.cwd??bt();if(this.#e={...n,argv:s,cwd:i},this.#e.argv&&!Array.isArray(this.#e.argv))throw new b("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 b("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new b("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new b("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 g of p)typeof m[g]!="function"&&h.push(g);if(h.length>0)throw new b(`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 b("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new b("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 b("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 b("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#_=n.fs,this.#E=n.exit,this.#A=n.env,this.#x=n.stdin??"",this.#C=n.maxArguments,this.#k=n.strictOptions??!1;const r=this.#y().CEREBRO_OUTPUT_LEVEL,c=r===void 0?Number.NaN:Number(r);this.#N=Number.isNaN(c)?le:c,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"),gs(e);const n=ws(e),s=typeof n.execute=="function",i=typeof n.loader=="function";if(s&&i)throw new b(`Command "${n.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:n.name});if(!s&&!i)throw new b(`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(c=>se(c))),n.argument&&ne(n.argument,"Command argument"),n.commandPath&&(qe(n.commandPath,"Command commandPath"),n.commandPath.forEach(c=>{se(c)}));const o=ze(n.name,n.commandPath),l=z(o);if(this.#s.has(l))throw new b(`Command with path "${l}" 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 b(`Command with name "${n.name}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name});if(n.options)for(const c of n.options)$e(c);if(ds(n),As(n),vs(n),n.options&&(n.__conflictingOptions__=n.options.filter(c=>c.conflicts!==void 0),n.__requiredOptions__=n.options.filter(c=>c.required===!0)),a&&u!==void 0)this.#n.set(l,n);else{if(!a&&u!==void 0&&!r){const c=ze(u.name,u.commandPath);this.#n.set(z(c),u)}this.#n.set(n.name,n)}if(this.#s.set(l,o),this.#o.set(l,n),this.#M(),n.alias!==void 0){const c=typeof n.alias=="string"?[n.alias]:n.alias;for(const p of c){if(this.#c()===V&&this.#t.debug("adding alias",p),this.#n.has(p))throw new b(`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(l=>l.name)),i=new Set(te.map(l=>l.alias).filter(Boolean));if(s.has(n.name))throw new b(`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 b(`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(l=>l.name)).has(n.name))throw new b(`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 en(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:d}=await import("../commands/help-command.js");this.addCommand(new d(this.#n))}const o=this.#L(),l=this.#s;this.#j();const a=this.#b();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 c=ms(l,[...a]);if(c.commandPath)u=c.commandPath,r=c.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 E=a[O];if(!E||me(E))break;C.push(E),O+=1}const k=z(C);if(C[0]&&!o.includes(C[0])){const E=this.#a(),H=R(k,E);throw new B(k,H)}}let d;try{d=an([null,...o],[...a])}catch(C){if(C instanceof Error&&C.name==="INVALID_COMMAND"&&"command"in C){const O=C.command,k=this.#a(),E=R(O,k);throw new B(O,E)}throw C}d.command&&(u=[d.command],r=d.argv)}if(!u)if(this.#i)u=[this.#i];else{const d=this.#a();throw new B("",d)}const p=z(u),h=this.#s.get(p);let m;if(h){if(m=this.#o.get(p),!m||z(h)!==p){const d=this.#a(),C=R(p,d);throw new B(p,C)}}else{const d=u.at(-1);if(m=d?this.#n.get(d):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 g=r;let y,A;try{({commandArgs:y,toolbox:A}=this.#T(m,g,i,p))}catch(d){const C=Yt(d);if(this.#t.error(C??d),s)return F(1);throw d}try{return await this.#S(m,A,y),s?F(0):void 0}catch(d){if(s)return this.#t.error(d),F(1);throw d}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:s=[],...i}=n;ve(e,"Command name");const o=e.split(" ").filter(Boolean),l=z(o),u=this.#s.get(l)?this.#o.get(l):this.#n.get(e);if(!u){const m=this.#a(),g=R(l||e,m);throw new B(e,g)}if(typeof u.execute!="function"&&typeof u.loader!="function")throw new b(`Command "${u.name}" has no function to execute`,"INVALID_COMMAND",{commandName:u.name});const c=[...Ke(s,{maxArguments:this.#C})];this.#c()===V&&this.#t.debug(`running command '${e}' programmatically with args: ${c.join(", ")}`);const{commandArgs:p,toolbox:h}=this.#T(u,c,i,l||e);return this.#S(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 l=this.#a(),a=R(s||e,l);throw new B(e,a)}if(typeof o.execute=="function")return o.execute;if(typeof o.loader=="function")return tt(o);throw new b(`Command "${o.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:o.name})}}export{at as Cli};
3
+ `))},gs=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');hs(e,t.name)}},ms=(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 l=n.join(" ");t.has(l)&&(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})),ws=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})},ys=/^no-/,vs=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Y(e.name)})},As=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(ys,"");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,alias:void 0,defaultValue:s.defaultValue===void 0?!0:!s.defaultValue,description:`Inverse of --${s.name}.`,name:i};n.push(o),e.add(i)}}n.length>0&&t.options.push(...n)},Cs=(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 l=Y(o.name);s.set(l,o)}const i=Object.keys(n).filter(o=>s.has(o));if(i.length!==0)for(const o of i){const l=o.charAt(2);if(!l)continue;const a=l.toLowerCase()+o.slice(3),u=s.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},Ns=(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:l}=o;for(const[a,u]of Object.entries(l))s[a]===void 0&&(s[a]=u)}}},bs=()=>!!process.versions.electron,Os=()=>bs()&&!process.defaultApp,_s=()=>Os()?0:1,xs=t=>t.slice(_s()+1),Es=" ",ks=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,s)=>n===e[s]),Is=t=>{if(typeof t=="string")return t.split(Es);const e=we();return ks(t,e)?xs(t):t},$s=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),F(1)},n=(o,l)=>{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=be("uncaughtException",e),i=be("unhandledRejection",n);return()=>{s(),i()}},We=100,Ps=/^[a-z][\w-]*$/i,ve=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new b(`${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 b(`${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 b(`${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 b(`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 b(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Ps.test(e))throw new b(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Ls=1e6,Us=1e5,Ms=new Set([`
4
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Ts=(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??Ls;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(Ms.has(i))throw new Error(`Argument contains dangerous character: ${i}`)}return n.trim?t.trim():t},Ke=(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??Us;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Too many arguments (maximum ${String(s)})`);return t.map(i=>Ts(i,n))},Ss=/^-([^\d-])$/,Ds=/^--(\S+)/,js=/^-([^\d-]{2,})$/,me=t=>Ss.test(t)||Ds.test(t)||js.test(t),Vs={access:(t,e)=>yt(t,e),mkdir:(t,e)=>wt(t,e),readdir:t=>mt(t),readFile:(async(t,e)=>e===void 0?Ne(t):Ne(t,e)),rm:(t,e)=>gt(t,e),stat:t=>dt(t),writeFile:(t,e,n)=>ft(t,e,n)},Rs=(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 l=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>R(u.slice(2),l).map(r=>`--${r}`));throw new Zt(o,a)};class at{#t;#e;#h;#p;#f;#d;#O;#_;#x;#A;#E;#C;#k;#N=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}#b(){if(this.#h===void 0){const e=Is(this.#e.argv);this.#h=Ke(e,{maxArguments:this.#C}),this.#j()}return this.#h}#y(){return this.#A??re()}#v(e){this.#N=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#N}#j(){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(j),e=!0;break}}e||this.#v(Object.hasOwn(this.#y(),"DEBUG")?j:le)}#V(){this.#P||(this.#$=$s(this.#t),this.#P=!0)}#R(){return{arch:Nt(),argv:this.#b(),cwd:this.#p,env:this.#A??re(),exit:this.#x??(e=>F(e??0)),platform:Ct(),stdin:this.#E}}#T(e,n,s,i){this.#c()===j&&this.#t.debug(`command '${i}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:l,parsedArgs:a}=qn(e,n,this.#U()),u=Object.keys(l).length>0;let r=a;u&&(r={...a,_all:{...a._all,...l}}),us(o,r,e);const c=Wn(e,a,l,s,this.#y(),n);c.runtime=this,c.argv=this.#b(),c.fs=this.#_??Vs,c.process=this.#R(),c.console=this.#t,Kn(e,c);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 g=m.name.slice(3),y=`--${m.name}`,A=`--${g}`,d=n.includes(y),C=n.includes(A);if(d&&C)throw new Ge(g,m.name)}}return p&&(Cs(c,e),Ns(c,e)),ps(o,c.options,e),fs(c.options,e),this.#k&&Rs(e,n,c.rawUnknown),this.#c()===j&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:o,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:c}}async#S(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 l=s.global;if(l?.help){const a=this.#n.get("help");if(!a)throw new b("Help command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else if(l?.version??l?.V){const a=this.#n.get("version");if(!a)throw new b("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 b("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const s=n.argv??we(),i=n.cwd??bt();if(this.#e={...n,argv:s,cwd:i},this.#e.argv&&!Array.isArray(this.#e.argv))throw new b("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 b("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new b("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new b("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 g of p)typeof m[g]!="function"&&h.push(g);if(h.length>0)throw new b(`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()===j&&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 b("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new b("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 b("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 b("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,c=r===void 0?Number.NaN:Number(r);this.#N=Number.isNaN(c)?le:c,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"),gs(e);const n=ws(e),s=typeof n.execute=="function",i=typeof n.loader=="function";if(s&&i)throw new b(`Command "${n.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:n.name});if(!s&&!i)throw new b(`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(c=>se(c))),n.argument&&ne(n.argument,"Command argument"),n.commandPath&&(qe(n.commandPath,"Command commandPath"),n.commandPath.forEach(c=>{se(c)}));const o=ze(n.name,n.commandPath),l=z(o);if(this.#s.has(l))throw new b(`Command with path "${l}" 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 b(`Command with name "${n.name}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name});if(n.options)for(const c of n.options)$e(c);if(ds(n),As(n),vs(n),n.options&&(n.__conflictingOptions__=n.options.filter(c=>c.conflicts!==void 0),n.__requiredOptions__=n.options.filter(c=>c.required===!0)),a&&u!==void 0)this.#n.set(l,n);else{if(!a&&u!==void 0&&!r){const c=ze(u.name,u.commandPath);this.#n.set(z(c),u)}this.#n.set(n.name,n)}if(this.#s.set(l,o),this.#o.set(l,n),this.#M(),n.alias!==void 0){const c=typeof n.alias=="string"?[n.alias]:n.alias;for(const p of c){if(this.#c()===j&&this.#t.debug("adding alias",p),this.#n.has(p))throw new b(`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(l=>l.name)),i=new Set(te.map(l=>l.alias).filter(Boolean));if(s.has(n.name))throw new b(`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 b(`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(l=>l.name)).has(n.name))throw new b(`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 en(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:d}=await import("../commands/help-command.js");this.addCommand(new d(this.#n))}const o=this.#L(),l=this.#s;this.#V();const a=this.#b();let u,r=[...a];this.#c()===j&&(this.#t.debug(`process.execPath: ${Ot()}`),this.#t.debug(`process.execArgv: ${_t().join(" ")}`),this.#t.debug(`process.argv: ${we().join(" ")}`));const c=ms(l,[...a]);if(c.commandPath)u=c.commandPath,r=c.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 d;try{d=an([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}d.command&&(u=[d.command],r=d.argv)}if(!u)if(this.#i)u=[this.#i];else{const d=this.#a();throw new B("",d)}const p=z(u),h=this.#s.get(p);let m;if(h){if(m=this.#o.get(p),!m||z(h)!==p){const d=this.#a(),C=R(p,d);throw new B(p,C)}}else{const d=u.at(-1);if(m=d?this.#n.get(d):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 g=r;let y,A;try{({commandArgs:y,toolbox:A}=this.#T(m,g,i,p))}catch(d){const C=Yt(d);if(this.#t.error(C??d),s)return F(1);throw d}try{return await this.#S(m,A,y),s?F(0):void 0}catch(d){if(s)return this.#t.error(d),F(1);throw d}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:s=[],...i}=n;ve(e,"Command name");const o=e.split(" ").filter(Boolean),l=z(o),u=this.#s.get(l)?this.#o.get(l):this.#n.get(e);if(!u){const m=this.#a(),g=R(l||e,m);throw new B(e,g)}if(typeof u.execute!="function"&&typeof u.loader!="function")throw new b(`Command "${u.name}" has no function to execute`,"INVALID_COMMAND",{commandName:u.name});const c=[...Ke(s,{maxArguments:this.#C})];this.#c()===j&&this.#t.debug(`running command '${e}' programmatically with args: ${c.join(", ")}`);const{commandArgs:p,toolbox:h}=this.#T(u,c,i,l||e);return this.#S(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 l=this.#a(),a=R(s||e,l);throw new B(e,a)}if(typeof o.execute=="function")return o.execute;if(typeof o.loader=="function")return tt(o);throw new b(`Command "${o.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:o.name})}}export{at as Cli};
@@ -304,7 +304,7 @@ interface CerebroFs {
304
304
  * buffer for tests and sandbox runtimes.
305
305
  *
306
306
  * Prefer reading these from the toolbox over reaching for global `process` so
307
- * commands stay portable across Node, Deno, Bun, and mocked test runtimes.
307
+ * commands stay portable across Node, Bun, and mocked test runtimes.
308
308
  */
309
309
  interface CerebroProcess {
310
310
  /** CPU architecture, e.g. "x64", "arm64". */
@@ -455,7 +455,7 @@ interface Toolbox<TLogger extends Console = Console, TOptions extends Record<str
455
455
  /**
456
456
  * Runtime process info — cwd, env, argv, exit, platform, arch, stdin —
457
457
  * captured at CLI construction. Prefer `toolbox.process` over reaching for
458
- * the global `process` so commands stay portable across Node, Deno, Bun,
458
+ * the global `process` so commands stay portable across Node, Bun,
459
459
  * and mocked test runtimes. `process.exit` honors the `CliOptions.exit`
460
460
  * override, which lets tests assert exit codes without killing the runner.
461
461
  */
@@ -0,0 +1 @@
1
+ const n=String.raw,p=n`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,c=()=>new RegExp(n`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${p}(?:\u200D${p})*`,"gu"),u=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\)|\][^\u0007\u001B]{0,1000}(?:\u0007|\u001B\\))/g,i=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,e=c(),r=/[-_./\s]+/g,o=/(\u001B\[[0-9;]*[a-z])/i,E=new RegExp("\\p{Script=Arabic}","u"),a=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"),B=new RegExp("\\p{Script=Gurmukhi}","u"),l=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"),H=new RegExp("\\p{Script=Latin}","u"),L=new RegExp("\\p{Script=Malayalam}","u"),T=new RegExp("\\p{Script=Myanmar}","u"),b=new RegExp("\\p{Script=Oriya}","u"),K=new RegExp("\\p{Script=Sinhala}","u"),M=new RegExp("\\p{Script=Tamil}","u"),j=new RegExp("\\p{Script=Telugu}","u"),C=new RegExp("\\p{Script=Thai}","u"),D=new RegExp("\\p{Script=Tibetan}","u"),O=/[\u02BB\u02BC\u0027]/u,$=t=>t.replace(e,"");export{T as $,g as B,B as C,F as D,l as F,S as G,s as H,C as J,R as K,r as L,x as M,i as N,w as O,d as P,e as R,o as T,H as U,D as V,h as W,L as Y,O as Z,j as b,k as d,$ as f,b as h,u as i,M as j,K as k,m as l,y as m,a as w,E as x,G as y};
@@ -1,6 +1,6 @@
1
- import{createRequire as te}from"node:module";import{L as U,B as v,c as ie}from"./constants-BKuEbBw1-BRv49X2l.js";import{createTable as A}from"@visulima/tabular";import{NO_BORDER as M}from"@visulima/tabular/style";import ae from"@visulima/colorize/template";import{c as le}from"./runtime-process-BN-eTlwy.js";import{bold as $,underline as ue}from"@visulima/colorize";let re;const ne=e=>(re??=te(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:w,T=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return ne(e)},w=b,{execFileSync:se}=T("node:child_process"),W=T("node:fs"),oe=T("node:tty"),ce=T("node:os"),de=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],fe=12288,he=65510,pe=[12288,12288,65281,65376,65504,65510],me=8361,we=65518,ge=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],be=32,ye=10630,Ne=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Ie=4352,We=262141,Y=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],O=(e,t)=>{let r=0,i=Math.floor(e.length/2)-1;for(;r<=i;){const o=Math.floor((r+i)/2),c=o*2;if(t<e[c])i=o-1;else if(t>e[c+1])r=o+1;else return!0}return!1},P=19968,[Oe,ve]=xe(Y);function xe(e){let t=e[0],r=e[1];for(let i=0;i<e.length;i+=2){const o=e[i],c=e[i+1];if(P>=o&&P<=c)return[o,c];c-o>r-t&&(t=o,r=c)}return[t,r]}const Ee=e=>e<161||e>1114109?!1:O(de,e),Ae=e=>e<fe||e>he?!1:O(pe,e),Me=e=>e<me||e>we?!1:O(ge,e),$e=e=>e<be||e>ye?!1:O(Ne,e),Se=e=>e>=Oe&&e<=ve?!0:e<Ie||e>We?!1:O(Y,e);function Ce(e){return Ee(e)?"ambiguous":Ae(e)?"fullwidth":Me(e)?"halfwidth":$e(e)?"narrow":Se(e)?"wide":"neutral"}function Te(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function G(e){return Te(e),Ce(e)}const D=new Map,ke=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),Le=e=>{const t=ke(e.width);let r=D.get(t);return r||(r=new Map,D.set(t,r)),r},x=new RegExp(U.source,"y"),_=new RegExp(ie.source,"uy"),E=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,V=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",Re=(e,t)=>{const r=Le(t),i=Math.floor(e/65536),o=e%65536;let c=r.get(i);if(c||(c=new Map,r.set(i,c)),c.has(o))return c.get(o);let n;switch(V(e)){case"control":{n=t.width.control;break}case"latin":{n=t.width.regular;break}case"wide":{n=t.width.wide;break}case"zero":{n=0;break}default:switch(G(e)){case"ambiguous":{n=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{n=t.width.fullWidth;break}case"wide":{n=t.width.wide;break}default:n=t.width.regular}}return c.set(o,n),n},_e=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,F=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?F(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},i=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,c=o>1e4;let n=0,s=0,l=o,a=!1;const u=e.includes("\x1B")||e.includes("›");for(;n<o;){if(u&&(e[n]==="\x1B"||e[n]==="›")){if(e.startsWith("\x1B]8;;",n)){const f="\x1B]8;;\x07",p=f.length,k=e.indexOf("\x07",n+5);if(k!==-1){const L=e.indexOf(f,k+1);if(L!==-1){const Q=L+p,ee=e.slice(k+1,L).replace(U,""),z=F(ee,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,i-s),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),R=z.width;if(z.truncated)a=!0,l=Math.min(l,n);else if(s+R>i&&(l=Math.min(l,n),a=!0,s+R>r.truncation.limit))break;if(s+=R,n=Q,a&&s>=r.truncation.limit)break;continue}}}if(x.lastIndex=n,x.test(e)){const f=x.lastIndex-n,p=r.truncation.countAnsiEscapeCodes?f:r.width.ansi;if(s+p>i&&(l=Math.min(l,n),s+p>r.truncation.limit)){a=!0;break}s+=p,n=x.lastIndex;continue}}const m=e.codePointAt(n);if(m===8203||m===65279||m>=8288&&m<=8292){n+=1;continue}if(m===9){if(s+r.width.tab>i&&(l=Math.min(l,n),s+r.width.tab>r.truncation.limit)){a=!0;break}s+=r.width.tab,n+=1;continue}if(E.lastIndex=n,E.test(e)){const f=(E.lastIndex-n)*r.width.regular;if(s+f>i){const p=r.width.regular>0?Math.floor((i-s)/r.width.regular):0;if(l=Math.min(l,n+p),s+f>r.truncation.limit){a=!0;break}}s+=f,n=E.lastIndex;continue}if((m<=31||m>=127&&m<=159)&&(v.lastIndex=n,v.test(e))){const f=(v.lastIndex-n)*r.width.control;if(s+f>i){const p=r.width.control>0?Math.floor((i-s)/r.width.control):0;if(l=Math.min(l,n+p),s+f>r.truncation.limit){a=!0;break}}s+=f,n=v.lastIndex;continue}if(_.lastIndex=n,_.test(e)){if(s+r.width.emoji>i&&(l=Math.min(l,n),s+r.width.emoji>r.truncation.limit)){a=!0;break}s+=r.width.emoji,n=_.lastIndex;continue}const g=e.codePointAt(n)??0;if(_e(g)){n+=g>65535?2:1;continue}let d;if(c)d=Re(g,r);else switch(V(g)){case"control":{d=r.width.control;break}case"latin":{d=r.width.regular;break}case"wide":{d=r.width.wide;break}case"zero":{d=0;break}default:switch(G(g)){case"ambiguous":{d=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{d=r.width.fullWidth;break}case"wide":{d=r.width.wide;break}default:d=r.width.regular}}if(s+d>i&&(l=Math.min(l,n),s+d>r.truncation.limit)){a=!0;break}s+=d,n+=g>65535?2:1}let y=s,N=!1;return a&&r.truncation.limit>=r.truncation.ellipsisWidth&&(y=r.truncation.limit,N=!0),{ellipsed:N,index:a?l:o,truncated:a,width:y}},je=(e,t={})=>F(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,K=80,J=24,B=(e,t,{shell:r,env:i}={})=>se(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:i}).trim(),S=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),X=(e,t)=>{const{columns:r,rows:i}=S(e,t);if(!(Number.isNaN(r)||Number.isNaN(i))&&!(r===K&&i===J))return{columns:r,rows:i}},Fe=()=>{if(w.platform!=="linux")return!0;try{const e=W.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const r=e.slice(t+2).trim().split(/\s+/),i=Number.parseInt(r[2],10),o=Number.parseInt(r[5],10);return Number.isNaN(i)||Number.isNaN(o)||o<=0?!1:i===o}catch{return!1}};function Be(){const{env:e,stdout:t,stderr:r}=w;if(t?.columns&&t?.rows)return S(t.columns,t.rows);if(r?.columns&&r?.rows)return S(r.columns,r.rows);if(e.COLUMNS&&e.LINES)return S(e.COLUMNS,e.LINES);const i={columns:K,rows:J};return w.platform==="win32"?j()??i:w.platform==="darwin"?q()??j()??i:q()??j()??ze()??i}const q=()=>{try{const e=w.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:t,rows:r}=oe.WriteStream(W.openSync("/dev/tty",e));return{columns:t,rows:r}}catch{}},j=()=>{try{const e=B("tput",["cols"],{env:{TERM:"dumb",...w.env}}),t=B("tput",["lines"],{env:{TERM:"dumb",...w.env}});if(e&&t)return X(e,t)}catch{}},ze=()=>{try{if(!Fe())return;const e=B("resize",["-u"]).match(/\d+/g);if(e.length===2)return X(e[0],e[1])}catch{}},I=new Map,Pe=500,h=e=>{if(!e||e==="")return"";const t=I.get(e);if(t!==void 0)return t;let r;try{r=ae(Object.assign([],{raw:[e]}))}catch{r=e}if(I.size>=Pe){const i=I.keys().next().value;i!==void 0&&I.delete(i)}return I.set(e,r),r},C=()=>{const t=le().CEREBRO_TERMINAL_WIDTH;if(t===void 0)return;const r=Number.parseInt(t,10);if(!(Number.isNaN(r)||r<=0))return r};class Z{lines;constructor(){this.lines=[]}add(t){this.lines.push(t)}toString(){return this.lines.join(ce.EOL)}header(t){this.add($(t)),this.lines.push("")}}const De=e=>e!==void 0&&e>0?e:Be().columns,qe=(e,t,r,i)=>{if(e.length===0||e.some(u=>u.length!==2))return;let o=0;for(const u of e){const y=u[0];if(y===void 0)continue;const N=je(y);N>o&&(o=N)}if(o===0)return;const c=r+i,n=o+c,l=20+c;if(n+l>t)return;const a=t-n;return[n,a]};class He extends Z{constructor(t){if(super(),t.header&&this.header(h(t.header)),t.content){if(t.raw)if(Array.isArray(t.content)&&t.content.every(r=>typeof r=="string"))t.content.forEach(r=>{Array.isArray(r)?r.forEach(i=>{this.add(h(i))}):this.add(h(r))});else if(typeof t.content=="string")this.add(h(t.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(t.content));this.add("")}}getContentLines(t){if(typeof t=="string"){const r=A({showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:C(),truncateOverflow:!1,wordWrap:!0});return r.addRow([h(t)]),r.toString()}if(Array.isArray(t)&&t.every(r=>typeof r=="string"||Array.isArray(r)&&r.every(i=>typeof i=="string"))){const o=De(C()),c=a=>Array.isArray(a)?a.map(u=>h(u)):[h(a)],n=t.map(a=>c(a)),s=qe(n,o,4,1),l=A({columnWidths:s,showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:o,truncateOverflow:!1,wordWrap:!0});return n.forEach(a=>{s!==void 0&&a.length===2?l.addRow([{content:a[0],wordWrap:!1},a[1]]):l.addRow(a)}),l.toString()}if(typeof t=="object"){const r=t;if(!r.options||!r.data)throw new Error(`Must have an "options" or "data" property
2
- ${JSON.stringify(t)}`);const i=A({showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:C(),truncateOverflow:!1,wordWrap:!0});return r.data.forEach(o=>{Array.isArray(o)?i.addRow(o.map(c=>h(c))):i.addRow([h(o)])}),i.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
1
+ import{createRequire as te}from"node:module";import{i as U,N as v,R as ie}from"./constants-BGGeBKGT-C4poKWYI.js";import{createTable as A}from"@visulima/tabular";import{NO_BORDER as M}from"@visulima/tabular/style";import ae from"@visulima/colorize/template";import{c as le}from"./runtime-process-BLYbrTb0.js";import{bold as $,underline as ue}from"@visulima/colorize";let re;const ne=e=>(re??=te(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:w,C=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return ne(e)},w=b,{execFileSync:se}=C("node:child_process"),W=C("node:fs"),oe=C("node:tty"),ce=C("node:os"),de=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],fe=12288,he=65510,pe=[12288,12288,65281,65376,65504,65510],me=8361,we=65518,ge=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],be=32,ye=10630,Ne=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Ie=4352,We=262141,Y=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],O=(e,t)=>{let r=0,i=Math.floor(e.length/2)-1;for(;r<=i;){const o=Math.floor((r+i)/2),c=o*2;if(t<e[c])i=o-1;else if(t>e[c+1])r=o+1;else return!0}return!1},P=19968,[Oe,ve]=xe(Y);function xe(e){let t=e[0],r=e[1];for(let i=0;i<e.length;i+=2){const o=e[i],c=e[i+1];if(P>=o&&P<=c)return[o,c];c-o>r-t&&(t=o,r=c)}return[t,r]}const Ee=e=>e<161||e>1114109?!1:O(de,e),Ae=e=>e<fe||e>he?!1:O(pe,e),Me=e=>e<me||e>we?!1:O(ge,e),$e=e=>e<be||e>ye?!1:O(Ne,e),Re=e=>e>=Oe&&e<=ve?!0:e<Ie||e>We?!1:O(Y,e);function Se(e){return Ee(e)?"ambiguous":Ae(e)?"fullwidth":Me(e)?"halfwidth":$e(e)?"narrow":Re(e)?"wide":"neutral"}function Ce(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function G(e){return Ce(e),Se(e)}const D=new Map,Te=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),ke=e=>{const t=Te(e.width);let r=D.get(t);return r||(r=new Map,D.set(t,r)),r},x=new RegExp(U.source,"y"),_=new RegExp(ie.source,"uy"),E=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,V=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",Le=(e,t)=>{const r=ke(t),i=Math.floor(e/65536),o=e%65536;let c=r.get(i);if(c||(c=new Map,r.set(i,c)),c.has(o))return c.get(o);let n;switch(V(e)){case"control":{n=t.width.control;break}case"latin":{n=t.width.regular;break}case"wide":{n=t.width.wide;break}case"zero":{n=0;break}default:switch(G(e)){case"ambiguous":{n=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{n=t.width.fullWidth;break}case"wide":{n=t.width.wide;break}default:n=t.width.regular}}return c.set(o,n),n},_e=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,F=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?F(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},i=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,c=o>1e4;let n=0,s=0,l=o,a=!1;const u=e.includes("\x1B")||e.includes("›");for(;n<o;){if(u&&(e[n]==="\x1B"||e[n]==="›")){if(e.startsWith("\x1B]8;;",n)){const f="\x1B]8;;\x07",p=f.length,T=e.indexOf("\x07",n+5);if(T!==-1){const k=e.indexOf(f,T+1);if(k!==-1){const Q=k+p,ee=e.slice(T+1,k).replace(U,""),z=F(ee,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,i-s),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),L=z.width;if(z.truncated)a=!0,l=Math.min(l,n);else if(s+L>i&&(l=Math.min(l,n),a=!0,s+L>r.truncation.limit))break;if(s+=L,n=Q,a&&s>=r.truncation.limit)break;continue}}}if(x.lastIndex=n,x.test(e)){const f=x.lastIndex-n,p=r.truncation.countAnsiEscapeCodes?f:r.width.ansi;if(s+p>i&&(l=Math.min(l,n),s+p>r.truncation.limit)){a=!0;break}s+=p,n=x.lastIndex;continue}}const m=e.codePointAt(n);if(m===8203||m===65279||m>=8288&&m<=8292){n+=1;continue}if(m===9){if(s+r.width.tab>i&&(l=Math.min(l,n),s+r.width.tab>r.truncation.limit)){a=!0;break}s+=r.width.tab,n+=1;continue}if(E.lastIndex=n,E.test(e)){const f=(E.lastIndex-n)*r.width.regular;if(s+f>i){const p=r.width.regular>0?Math.floor((i-s)/r.width.regular):0;if(l=Math.min(l,n+p),s+f>r.truncation.limit){a=!0;break}}s+=f,n=E.lastIndex;continue}if((m<=31||m>=127&&m<=159)&&(v.lastIndex=n,v.test(e))){const f=(v.lastIndex-n)*r.width.control;if(s+f>i){const p=r.width.control>0?Math.floor((i-s)/r.width.control):0;if(l=Math.min(l,n+p),s+f>r.truncation.limit){a=!0;break}}s+=f,n=v.lastIndex;continue}if(_.lastIndex=n,_.test(e)){if(s+r.width.emoji>i&&(l=Math.min(l,n),s+r.width.emoji>r.truncation.limit)){a=!0;break}s+=r.width.emoji,n=_.lastIndex;continue}const g=e.codePointAt(n)??0;if(_e(g)){n+=g>65535?2:1;continue}let d;if(c)d=Le(g,r);else switch(V(g)){case"control":{d=r.width.control;break}case"latin":{d=r.width.regular;break}case"wide":{d=r.width.wide;break}case"zero":{d=0;break}default:switch(G(g)){case"ambiguous":{d=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{d=r.width.fullWidth;break}case"wide":{d=r.width.wide;break}default:d=r.width.regular}}if(s+d>i&&(l=Math.min(l,n),s+d>r.truncation.limit)){a=!0;break}s+=d,n+=g>65535?2:1}let y=s,N=!1;return a&&r.truncation.limit>=r.truncation.ellipsisWidth&&(y=r.truncation.limit,N=!0),{ellipsed:N,index:a?l:o,truncated:a,width:y}},je=(e,t={})=>F(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,K=80,J=24,B=(e,t,{shell:r,env:i}={})=>se(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:i}).trim(),R=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),X=(e,t)=>{const{columns:r,rows:i}=R(e,t);if(!(Number.isNaN(r)||Number.isNaN(i))&&!(r===K&&i===J))return{columns:r,rows:i}},Fe=()=>{if(w.platform!=="linux")return!0;try{const e=W.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const r=e.slice(t+2).trim().split(/\s+/),i=Number.parseInt(r[2],10),o=Number.parseInt(r[5],10);return Number.isNaN(i)||Number.isNaN(o)||o<=0?!1:i===o}catch{return!1}};function Be(){const{env:e,stdout:t,stderr:r}=w;if(t?.columns&&t?.rows)return R(t.columns,t.rows);if(r?.columns&&r?.rows)return R(r.columns,r.rows);if(e.COLUMNS&&e.LINES)return R(e.COLUMNS,e.LINES);const i={columns:K,rows:J};return w.platform==="win32"?j()??i:w.platform==="darwin"?q()??j()??i:q()??j()??ze()??i}const q=()=>{try{const e=w.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:t,rows:r}=oe.WriteStream(W.openSync("/dev/tty",e));return{columns:t,rows:r}}catch{}},j=()=>{try{const e=B("tput",["cols"],{env:{TERM:"dumb",...w.env}}),t=B("tput",["lines"],{env:{TERM:"dumb",...w.env}});if(e&&t)return X(e,t)}catch{}},ze=()=>{try{if(!Fe())return;const e=B("resize",["-u"]).match(/\d+/g);if(e.length===2)return X(e[0],e[1])}catch{}},I=new Map,Pe=500,h=e=>{if(!e||e==="")return"";const t=I.get(e);if(t!==void 0)return t;let r;try{r=ae(Object.assign([],{raw:[e]}))}catch{r=e}if(I.size>=Pe){const i=I.keys().next().value;i!==void 0&&I.delete(i)}return I.set(e,r),r},S=()=>{const t=le().CEREBRO_TERMINAL_WIDTH;if(t===void 0)return;const r=Number.parseInt(t,10);if(!(Number.isNaN(r)||r<=0))return r};class Z{lines;constructor(){this.lines=[]}add(t){this.lines.push(t)}toString(){return this.lines.join(ce.EOL)}header(t){this.add($(t)),this.lines.push("")}}const De=e=>e!==void 0&&e>0?e:Be().columns,qe=(e,t,r,i)=>{if(e.length===0||e.some(u=>u.length!==2))return;let o=0;for(const u of e){const y=u[0];if(y===void 0)continue;const N=je(y);N>o&&(o=N)}if(o===0)return;const c=r+i,n=o+c,l=20+c;if(n+l>t)return;const a=t-n;return[n,a]};class He extends Z{constructor(t){if(super(),t.header&&this.header(h(t.header)),t.content){if(t.raw)if(Array.isArray(t.content)&&t.content.every(r=>typeof r=="string"))t.content.forEach(r=>{Array.isArray(r)?r.forEach(i=>{this.add(h(i))}):this.add(h(r))});else if(typeof t.content=="string")this.add(h(t.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(t.content));this.add("")}}getContentLines(t){if(typeof t=="string"){const r=A({showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:S(),truncateOverflow:!1,wordWrap:!0});return r.addRow([h(t)]),r.toString()}if(Array.isArray(t)&&t.every(r=>typeof r=="string"||Array.isArray(r)&&r.every(i=>typeof i=="string"))){const o=De(S()),c=a=>Array.isArray(a)?a.map(u=>h(u)):[h(a)],n=t.map(a=>c(a)),s=qe(n,o,4,1),l=A({columnWidths:s,showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:o,truncateOverflow:!1,wordWrap:!0});return n.forEach(a=>{s!==void 0&&a.length===2?l.addRow([{content:a[0],wordWrap:!1},a[1]]):l.addRow(a)}),l.toString()}if(typeof t=="object"){const r=t;if(!r.options||!r.data)throw new Error(`Must have an "options" or "data" property
2
+ ${JSON.stringify(t)}`);const i=A({showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:S(),truncateOverflow:!1,wordWrap:!0});return r.data.forEach(o=>{Array.isArray(o)?i.addRow(o.map(c=>h(c))):i.addRow([h(o)])}),i.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
3
3
 
4
- ${JSON.stringify(t)}`)}}class Ue extends Z{constructor(t){super();let r=t.optionList??[];const i=Array.isArray(t.hide)?t.hide:[t.hide].filter(n=>typeof n=="string"),o=Array.isArray(t.group)?t.group:[t.group].filter(n=>typeof n=="string");i.length>0&&(r=r.filter(n=>!i.includes(n.name))),t.header&&this.header(h(t.header)),o.length>0&&(r=r.filter(n=>{const s=n,l=o.includes("_none")&&!s.group,a=s.group,u=this.intersect(Array.isArray(a)?a:[a],o);return l||u?n:void 0}));const c=A({showHeader:!1,style:{border:M,paddingLeft:2,paddingRight:1,...t.tableOptions?.style},terminalWidth:C()??t.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:t.tableOptions?.wordWrap??!0,...t.tableOptions});r.forEach(n=>{const s=n;c.addRow([this.getOptionNames(s,t.reverseNameOrder??!1,t.isArgument??!1),h(s.description)])}),this.add(c.toString()),this.lines.push("")}getOptionNames(t,r,i){if(!t.name)throw new TypeError("Invalid option definition, name is required.");const o=t.type?t.type.name.toLowerCase():"string",{lazyMultiple:c}=t,n=t.multiple||c?"[]":"",s=t.typeLabel===void 0?ue(`${o}${n}`):h(t.typeLabel),l=i?$(t.name):$.yellow(`--${t.name}`),a=t.alias;if(a){const u=$(`-${a}`);return r?`${l}, ${u} ${s}`:`${u}, ${l} ${s}`}return`${l} ${s}`}intersect(t,r){return t.some(i=>r.includes(i))}}const Qe=e=>(Array.isArray(e)?e:[e]).length===0?"":`
4
+ ${JSON.stringify(t)}`)}}class Ue extends Z{constructor(t){super();let r=t.optionList??[];const i=Array.isArray(t.hide)?t.hide:[t.hide].filter(n=>typeof n=="string"),o=Array.isArray(t.group)?t.group:[t.group].filter(n=>typeof n=="string");i.length>0&&(r=r.filter(n=>!i.includes(n.name))),t.header&&this.header(h(t.header)),o.length>0&&(r=r.filter(n=>{const s=n,l=o.includes("_none")&&!s.group,a=s.group,u=this.intersect(Array.isArray(a)?a:[a],o);return l||u?n:void 0}));const c=A({showHeader:!1,style:{border:M,paddingLeft:2,paddingRight:1,...t.tableOptions?.style},terminalWidth:S()??t.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:t.tableOptions?.wordWrap??!0,...t.tableOptions});r.forEach(n=>{const s=n;c.addRow([this.getOptionNames(s,t.reverseNameOrder??!1,t.isArgument??!1),h(s.description)])}),this.add(c.toString()),this.lines.push("")}getOptionNames(t,r,i){if(!t.name)throw new TypeError("Invalid option definition, name is required.");const o=t.type?t.type.name.toLowerCase():"string",{lazyMultiple:c}=t,n=t.multiple||c?"[]":"",s=t.typeLabel===void 0?ue(`${o}${n}`):h(t.typeLabel),l=i?$(t.name):$.yellow(`--${t.name}`),a=t.alias;if(a){const u=$(`-${a}`);return r?`${l}, ${u} ${s}`:`${u}, ${l} ${s}`}return`${l} ${s}`}intersect(t,r){return t.some(i=>r.includes(i))}}const Qe=e=>(Array.isArray(e)?e:[e]).length===0?"":`
5
5
  ${e.map(r=>r.optionList?new Ue(r).toString():new He(r).toString()).join(`
6
6
  `)}`,H=(e,t)=>{const i=`${t==="readme"?e.name.toUpperCase():e.name}${e.multiple===!0?"...":""}`;return e.required===!0?t==="readme"?i:`<${i}>`:`[${i}]`},et=(e,t="help")=>e.argument?e.argument.hidden?"":t==="readme"?` ${H(e.argument,t)}`:" [positional arguments]":!e.arguments||e.arguments.length===0?"":e.arguments.filter(r=>!r.hidden).map(r=>` ${H(r,t)}`).join("");export{Qe as c,et as f,h as t};
@@ -0,0 +1 @@
1
+ const r=s=>"Bun"in s,c=()=>process.argv,n=()=>process.cwd(),t=()=>process.env,a=()=>process.execArgv,i=()=>process.execPath,g=()=>process.platform,p=()=>process.arch,v=()=>{if(r(globalThis)){const{Bun:s}=globalThis,e={...process.versions};return s?.version&&(e.bun=s.version),e}return process.versions},u=(s=0)=>{process.exit(s)},P=(s,e)=>{const o=process;return o.on(s,e),()=>{o.removeListener(s,e)}};export{g as a,p as b,t as c,c as d,u as e,n as f,v as g,r as h,i,a as j,P as o};
@@ -1,4 +1,4 @@
1
- import { P as Plugin } from "../packem_shared/command.d-Dz7hkMI0.js";
1
+ import { P as Plugin } from "../packem_shared/command.d-DNTe-FYX.js";
2
2
  import { O as Options$1 } from "../packem_shared/index.d-CnnVYgSZ.js";
3
3
  import '@visulima/tabular';
4
4
  type ErrorHandlerOptions = {
@@ -1 +1 @@
1
- import{z as E}from"../packem_shared/renderError-CIIYTTfx-BdX-afLI.js";import{f as n}from"../packem_shared/format-user-facing-error-Cb7ySnUi.js";import{e as h}from"../packem_shared/runtime-process-BN-eTlwy.js";const x=(s={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(r,t)=>{const{logger:e,runtime:a}=t,{concise:d,detailed:o=!1,exitOnError:l=!0,formatter:i,logErrors:f=!0,renderOptions:c={}}=s;if(f)if(i)e.error(i(r));else if(!o&&(d?.(r)||n(r)!==void 0))e.error(n(r)??r.message);else if(o){const m=a.getCwd(),g=E(r,{cwd:m,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...c});e.error(g)}else e.error(r);l&&h(1)},version:"1.0.0"});export{x as errorHandlerPlugin};
1
+ import{z as E}from"../packem_shared/renderError-CIIYTTfx-BdX-afLI.js";import{f as n}from"../packem_shared/format-user-facing-error-Cb7ySnUi.js";import{e as h}from"../packem_shared/runtime-process-BLYbrTb0.js";const x=(s={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(r,t)=>{const{logger:e,runtime:a}=t,{concise:d,detailed:o=!1,exitOnError:l=!0,formatter:i,logErrors:f=!0,renderOptions:c={}}=s;if(f)if(i)e.error(i(r));else if(!o&&(d?.(r)||n(r)!==void 0))e.error(n(r)??r.message);else if(o){const m=a.getCwd(),g=E(r,{cwd:m,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...c});e.error(g)}else e.error(r);l&&h(1)},version:"1.0.0"});export{x as errorHandlerPlugin};
@@ -1,6 +1,6 @@
1
- import { P as Plugin } from "../packem_shared/command.d-Dz7hkMI0.js";
1
+ import { P as Plugin } from "../packem_shared/command.d-DNTe-FYX.js";
2
2
  import '@visulima/tabular';
3
- type RuntimeType = "bun" | "deno" | "node";
3
+ type RuntimeType = "bun" | "node";
4
4
  type RuntimeVersionRequirement = {
5
5
  /** Minimum version required */
6
6
  minVersion: number;
@@ -10,14 +10,12 @@ type RuntimeVersionCheckOptions = {
10
10
  runtimes?: {
11
11
  /** Minimum Bun version requirement */
12
12
  bun?: RuntimeVersionRequirement;
13
- /** Minimum Deno version requirement */
14
- deno?: RuntimeVersionRequirement;
15
13
  /** Minimum Node.js version requirement */
16
14
  node?: RuntimeVersionRequirement;
17
15
  };
18
16
  };
19
17
  /**
20
- * Create a runtime version check plugin that supports Node.js, Bun, and Deno.
18
+ * Create a runtime version check plugin that supports Node.js and Bun.
21
19
  * @param options Configuration for runtime version requirements
22
20
  * @returns Plugin instance that validates runtime version on initialization
23
21
  */
@@ -1 +1 @@
1
- import{c,e as a,g as v}from"../packem_shared/runtime-process-BN-eTlwy.js";const i=n=>{if(!n||typeof n!="string")return 0;const o=n.split(".");if(o.length===0||!o[0])return 0;const e=Number.parseInt(o[0],10);return Number.isNaN(e)?0:e},p=n=>!n||typeof n!="string"?"":n.replace("v",""),d=()=>{if(typeof Bun<"u"){const r=Bun.version||"";return{major:i(r),type:"bun",version:r}}if(typeof Deno<"u"){const r=Deno.version?.deno||"";return{major:i(r),type:"deno",version:r}}const o=v().node??"",e=p(o);return{major:i(e),type:"node",version:e}},g=(n={})=>({description:"Checks if the current runtime version meets the minimum requirement",init:o=>{const e=d(),s={bun:1,deno:1,node:18};let r;try{const u=c().CEREBRO_MIN_NODE_VERSION,m=u===void 0?void 0:Number.parseInt(u,10);r=Number.isNaN(m)?void 0:m}catch{r=void 0}let t;n.runtimes?.[e.type]?.minVersion!==void 0?t=n.runtimes[e.type].minVersion:e.type==="node"&&r!==void 0?t=r:t=s[e.type],e.major<t&&(o.logger.error(`cerebro requires ${e.type} version ${String(t)} or higher. You have ${e.type} ${e.version}. Read our version support policy: https://github.com/visulima/visulima#supported-runtimes`),a(1)),o.logger.debug(`Runtime version check passed: ${e.type} ${e.version} >= ${String(t)}`)},name:"runtime-version-check",version:"1.0.0"});export{g as runtimeVersionCheckPlugin};
1
+ import{c as a,e as c,g as p,h as v}from"../packem_shared/runtime-process-BLYbrTb0.js";const m=r=>{if(!r||typeof r!="string")return 0;const n=r.split(".");if(n.length===0||!n[0])return 0;const e=Number.parseInt(n[0],10);return Number.isNaN(e)?0:e},d=r=>!r||typeof r!="string"?"":r.replace("v",""),h=()=>{const r=p();if(v(globalThis)){const i=r.bun??"";return{major:m(i),type:"bun",version:i}}const n=d(r.node);return{major:m(n),type:"node",version:n}},y=(r={})=>({description:"Checks if the current runtime version meets the minimum requirement",init:n=>{const e=h(),i={bun:1,node:18};let s;try{const o=a().CEREBRO_MIN_NODE_VERSION,u=o===void 0?void 0:Number.parseInt(o,10);s=Number.isNaN(u)?void 0:u}catch{s=void 0}let t;r.runtimes?.[e.type]?.minVersion!==void 0?t=r.runtimes[e.type].minVersion:e.type==="node"&&s!==void 0?t=s:t=i[e.type],e.major<t&&(n.logger.error(`cerebro requires ${e.type} version ${String(t)} or higher. You have ${e.type} ${e.version}. Read our version support policy: https://github.com/visulima/visulima#supported-runtimes`),c(1)),n.logger.debug(`Runtime version check passed: ${e.type} ${e.version} >= ${String(t)}`)},name:"runtime-version-check",version:"1.0.0"});export{y as runtimeVersionCheckPlugin};
@@ -1,4 +1,4 @@
1
- import { a as CerebroFs, P as Plugin } from "../../packem_shared/command.d-Dz7hkMI0.js";
1
+ import { a as CerebroFs, P as Plugin } from "../../packem_shared/command.d-DNTe-FYX.js";
2
2
  import '@visulima/tabular';
3
3
  type UpdateNotifierOptions = {
4
4
  alwaysRun?: boolean;
@@ -1 +1 @@
1
- import{VERBOSITY_DEBUG as m}from"../../packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js";import{c as l}from"../../packem_shared/runtime-process-BN-eTlwy.js";var i={},R,U;function v(){return U||(U=1,R=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Alpic",constant:"ALPIC",env:"ALPIC_HOST"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]),R}var L;function P(){return L||(L=1,(function(a){const s=v(),e=process.env;Object.defineProperty(a,"_vendors",{value:s.map(function(n){return n.constant})}),a.name=null,a.isPR=null,a.id=null,e.CI!=="false"&&s.forEach(function(n){const r=(Array.isArray(n.env)?n.env:[n.env]).every(function(o){return E(o)});a[n.constant]=r,r&&(a.name=n.name,a.isPR=I(n),a.id=n.constant)}),a.isCI=!!(e.CI!=="false"&&(e.BUILD_ID||e.BUILD_NUMBER||e.CI||e.CI_APP_ID||e.CI_BUILD_ID||e.CI_BUILD_NUMBER||e.CI_NAME||e.CONTINUOUS_INTEGRATION||e.RUN_ID||a.name));function E(n){return typeof n=="string"?!!e[n]:"env"in n?e[n.env]&&e[n.env].includes(n.includes):"any"in n?n.any.some(function(t){return!!e[t]}):Object.keys(n).every(function(t){return e[t]===n[t]})}function I(n){switch(typeof n.pr){case"string":return!!e[n.pr];case"object":return"env"in n.pr?"any"in n.pr?n.pr.any.some(function(t){return e[n.pr.env]===t}):n.pr.env in e&&e[n.pr.env]!==n.pr.ne:"any"in n.pr?n.pr.any.some(function(t){return!!e[t]}):E(n.pr);default:return null}}})(i)),i}var O=P();const N=5e3,g=(a={})=>({beforeCommand:async s=>{const{fs:e,logger:E,runtime:I}=s,n=I.getPackageName(),t=I.getPackageVersion();if(!n||!t){E.debug("Update notifier: package name or version not provided, skipping...");return}const r=l(),o={alwaysRun:!1,debug:r.CEREBRO_OUTPUT_LEVEL===String(m),distTag:"latest",fs:e,pkg:{name:n,version:t},timeout:N,updateCheckInterval:1e3*60*60*24,...a};if(!(!!o.alwaysRun||!(r.NO_UPDATE_NOTIFIER||r.NODE_ENV==="test"||s.argv.includes("--no-update-notifier")||O.isCI))){E.debug("Update notifier: skipping check (disabled by environment or flags)");return}try{const C=await(await import("../../packem_chunks/has-new-version.js").then(_=>_.default))(o);if(C){const[{boxen:_},{dim:u,green:T,reset:D,yellow:p}]=await Promise.all([import("@visulima/boxen"),import("@visulima/colorize")]),S=`Update available ${u(t)}${D(" → ")}${T(C)}`;E.log(_(S,{borderColor:A=>p(A),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}catch(c){E.debug("Update notifier: failed to check for updates",c)}},description:"Checks for package updates and notifies users",name:"update-notifier",version:"1.0.0"});export{g as updateNotifierPlugin};
1
+ import{VERBOSITY_DEBUG as m}from"../../packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js";import{c as l}from"../../packem_shared/runtime-process-BLYbrTb0.js";var i={},R,U;function v(){return U||(U=1,R=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Alpic",constant:"ALPIC",env:"ALPIC_HOST"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]),R}var L;function P(){return L||(L=1,(function(a){const s=v(),e=process.env;Object.defineProperty(a,"_vendors",{value:s.map(function(n){return n.constant})}),a.name=null,a.isPR=null,a.id=null,e.CI!=="false"&&s.forEach(function(n){const r=(Array.isArray(n.env)?n.env:[n.env]).every(function(o){return E(o)});a[n.constant]=r,r&&(a.name=n.name,a.isPR=I(n),a.id=n.constant)}),a.isCI=!!(e.CI!=="false"&&(e.BUILD_ID||e.BUILD_NUMBER||e.CI||e.CI_APP_ID||e.CI_BUILD_ID||e.CI_BUILD_NUMBER||e.CI_NAME||e.CONTINUOUS_INTEGRATION||e.RUN_ID||a.name));function E(n){return typeof n=="string"?!!e[n]:"env"in n?e[n.env]&&e[n.env].includes(n.includes):"any"in n?n.any.some(function(t){return!!e[t]}):Object.keys(n).every(function(t){return e[t]===n[t]})}function I(n){switch(typeof n.pr){case"string":return!!e[n.pr];case"object":return"env"in n.pr?"any"in n.pr?n.pr.any.some(function(t){return e[n.pr.env]===t}):n.pr.env in e&&e[n.pr.env]!==n.pr.ne:"any"in n.pr?n.pr.any.some(function(t){return!!e[t]}):E(n.pr);default:return null}}})(i)),i}var O=P();const N=5e3,g=(a={})=>({beforeCommand:async s=>{const{fs:e,logger:E,runtime:I}=s,n=I.getPackageName(),t=I.getPackageVersion();if(!n||!t){E.debug("Update notifier: package name or version not provided, skipping...");return}const r=l(),o={alwaysRun:!1,debug:r.CEREBRO_OUTPUT_LEVEL===String(m),distTag:"latest",fs:e,pkg:{name:n,version:t},timeout:N,updateCheckInterval:1e3*60*60*24,...a};if(!(!!o.alwaysRun||!(r.NO_UPDATE_NOTIFIER||r.NODE_ENV==="test"||s.argv.includes("--no-update-notifier")||O.isCI))){E.debug("Update notifier: skipping check (disabled by environment or flags)");return}try{const C=await(await import("../../packem_chunks/has-new-version.js").then(_=>_.default))(o);if(C){const[{boxen:_},{dim:u,green:T,reset:D,yellow:p}]=await Promise.all([import("@visulima/boxen"),import("@visulima/colorize")]),S=`Update available ${u(t)}${D(" → ")}${T(C)}`;E.log(_(S,{borderColor:A=>p(A),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}catch(c){E.debug("Update notifier: failed to check for updates",c)}},description:"Checks for package updates and notifies users",name:"update-notifier",version:"1.0.0"});export{g as updateNotifierPlugin};
@@ -1 +1 @@
1
- import{createRequire as _}from"node:module";import{i as S,d as E,h as y,c as A,e as p}from"../../packem_shared/runtime-process-BN-eTlwy.js";let m;const h=e=>(m??=_(import.meta.url))(e),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[s,t]=r.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return r.getBuiltinModule(e)}return h(e)},{execFileSync:v}=g("node:child_process"),{totalmem:x}=g("node:os"),b=/--max-old-space-size=(\d+)/,j=/--max-semi-space-size=(\d+)/,z=e=>Math.floor(x()/1024/1024*e),P=e=>e<=512?4:e<=1024?8:e<=2048?16:e<=4096?32:e<=8192?64:Math.floor(Math.log2(e))*8,f=(e,s)=>{for(const t of s){const o=e.exec(t);if(o)return Number.parseInt(o[1],10)}},M=e=>{const s=e?.maxOldSpacePercent??.75,t=[...S()],o=[...E()],c=f(b,t),i=f(j,t);if(c!==void 0&&i!==void 0)return;const a=c??z(s),l=i??P(a),n=[];if(c===void 0&&n.push(`--max-old-space-size=${String(a)}`),i===void 0&&n.push(`--max-semi-space-size=${String(l)}`),n.length!==0)try{v(y(),[...n,...t,...o.slice(1)],{env:A(),stdio:"inherit"}),p(0)}catch(d){const u=d.status;p(typeof u=="number"?u:1)}};export{M as applyHeapTuning};
1
+ import{createRequire as _}from"node:module";import{j as S,d as E,i as j,c as y,e as p}from"../../packem_shared/runtime-process-BLYbrTb0.js";let m;const h=e=>(m??=_(import.meta.url))(e),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[s,t]=r.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return r.getBuiltinModule(e)}return h(e)},{execFileSync:v}=g("node:child_process"),{totalmem:x}=g("node:os"),A=/--max-old-space-size=(\d+)/,b=/--max-semi-space-size=(\d+)/,z=e=>Math.floor(x()/1024/1024*e),P=e=>e<=512?4:e<=1024?8:e<=2048?16:e<=4096?32:e<=8192?64:Math.floor(Math.log2(e))*8,f=(e,s)=>{for(const t of s){const o=e.exec(t);if(o)return Number.parseInt(o[1],10)}},M=e=>{const s=e?.maxOldSpacePercent??.75,t=[...S()],o=[...E()],c=f(A,t),i=f(b,t);if(c!==void 0&&i!==void 0)return;const a=c??z(s),l=i??P(a),n=[];if(c===void 0&&n.push(`--max-old-space-size=${String(a)}`),i===void 0&&n.push(`--max-semi-space-size=${String(l)}`),n.length!==0)try{v(j(),[...n,...t,...o.slice(1)],{env:y(),stdio:"inherit"}),p(0)}catch(d){const u=d.status;p(typeof u=="number"?u:1)}};export{M as applyHeapTuning};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@visulima/cerebro",
3
- "version": "3.1.2",
4
- "description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
3
+ "version": "4.0.0",
4
+ "description": "A delightful toolkit for building cross-runtime CLIs for Node.js and Bun.",
5
5
  "keywords": [
6
6
  "ansi",
7
7
  "args",
@@ -119,15 +119,15 @@
119
119
  "provenance": true
120
120
  },
121
121
  "dependencies": {
122
- "@visulima/colorize": "2.1.1",
122
+ "@visulima/colorize": "3.0.0",
123
123
  "@visulima/tabular": "4.1.0",
124
124
  "fastest-levenshtein": "^1.0.16"
125
125
  },
126
126
  "peerDependencies": {
127
127
  "@bomb.sh/tab": ">=0.0.22",
128
- "@visulima/boxen": "5.0.0",
129
- "@visulima/find-cache-dir": "3.0.1",
130
- "@visulima/pail": "5.0.0",
128
+ "@visulima/boxen": "6.0.0",
129
+ "@visulima/find-cache-dir": "4.0.0",
130
+ "@visulima/pail": "6.0.0",
131
131
  "github-slugger": ">=2.0.0"
132
132
  },
133
133
  "peerDependenciesMeta": {
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
1
- const o=e=>"Deno"in e,t=e=>"Bun"in e,i=()=>{if(o(globalThis)){const e=globalThis.Deno,n=e.execPath();let s=n;try{const{importMeta:r}=globalThis;r?.url&&(s=r.url)}catch{}return[n,s,...e.args]}return process.argv},c=()=>o(globalThis)?globalThis.Deno.cwd():process.cwd(),a=()=>{if(o(globalThis)){const e=globalThis.Deno;return new Proxy(e.env.toObject(),{get:(n,s)=>typeof s=="string"?e.env.get(s):n[s],has:(n,s)=>typeof s=="string"?e.env.has(s):s in n,set:(n,s,r)=>typeof s=="string"?(r===void 0||e.env.set(s,r),!0):!1})}return process.env},l=()=>o(globalThis)?[]:process.execArgv,g=()=>o(globalThis)?globalThis.Deno.execPath():process.execPath,u=()=>{if(o(globalThis)){const n=globalThis.Deno.build?.os??"unknown";return n==="windows"?"win32":n}return process.platform},h=()=>{if(o(globalThis)){const n=globalThis.Deno.build?.arch??"unknown";return n==="x86_64"?"x64":n==="aarch64"?"arm64":n}return process.arch},f=()=>{if(o(globalThis)){const e=globalThis.Deno,n={};return e.version?.deno&&(n.deno=e.version.deno),e.version?.v8&&(n.v8=e.version.v8),e.version?.typescript&&(n.typescript=e.version.typescript),n}if(t(globalThis)){const e=globalThis.Bun,n={...process.versions};return e.version&&(n.bun=e.version),n}return process.versions},b=(e=0)=>{if(o(globalThis))throw globalThis.Deno.exit(e),new Error("Deno exit failed");process.exit(e)},d=(e,n)=>{if(o(globalThis))return()=>{};const s=process;return s.on(e,n),()=>{s.removeListener(e,n)}};export{u as a,h as b,a as c,i as d,b as e,c as f,f as g,g as h,l as i,d as o};