create-crust 0.5.6 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # create-crust
2
2
 
3
- Scaffold a new Crust CLI project for Bun, Node.js, or Deno
3
+ Scaffold a new Crust CLI project for Bun or Node.js
4
4
 
5
5
  ## Usage
6
6
 
@@ -9,62 +9,33 @@ npm create crust@latest my-cli
9
9
  # or
10
10
  pnpm create crust@latest my-cli
11
11
  # or
12
- bunx create-crust@latest my-cli
13
- # or
14
12
  bun create crust@latest my-cli
15
- # or
16
- deno run -A npm:create-crust@latest my-cli
17
13
  ```
18
14
 
19
- The initializer collects the destination, any required overwrite decision, runtime, build output, dependency installation choice, and Git initialization choice. Explicit flags skip the corresponding prompts; prompts can also use defaults without rendering non-interactively. The package name is inferred from the directory name.
20
-
21
- ## Options
15
+ The initializer prompts for the runtime, build output, dependency installation, and Git initialization. Pass flags to skip the prompts:
22
16
 
23
- ```text
24
- create-crust [directory] [--runtime bun|node|deno] [--artifact package|binary] [--install|--no-install] [--git|--no-git] [--overwrite|--no-overwrite]
17
+ ```sh
18
+ npx create-crust@latest my-cli --runtime node --artifact binary --no-git
25
19
  ```
26
20
 
27
- - `directory` sets the destination; otherwise the directory prompt defaults to `my-cli`. Its basename (the current directory's for `.`) becomes the package and command name, so it must follow the [installed command name rule](https://crustjs.com/docs/modules/core#tooling-subpath): letters, digits, `.`, `_`, and `-`, starting with a letter or digit; anything else is rejected before any file is written.
28
- - `--runtime` selects the runtime the project develops and builds for: `bun`, `node`, or `deno`. The default is `bun`.
29
- - `--artifact` selects the build output independently of the runtime: `package` for a JavaScript bundle requiring the user's selected runtime, or `binary` for a standalone executable embedding that runtime. Defaults: `binary` for Bun/Deno, `package` for Node.js. Deno runtime-package bundling is experimental.
30
- - `--install` / `--no-install` installs or skips dependencies. The default is to install. Deno projects install with `deno install`; the other runtimes use the detected package manager. If installation is skipped, the next steps include the install command.
31
- - `--git` / `--no-git` initializes or skips a Git repository when the destination is not already inside one. The default is to initialize.
32
- - When the destination requires an overwrite decision, `--overwrite` overwrites conflicting files without confirmation; `--no-overwrite` aborts without prompting. The default is not to overwrite.
33
-
34
- Generated projects use the single-file starter (`src/cli.ts`). The generated README and next steps use the detected package manager for script commands (`bun run`, `npm run`, `pnpm run`, or `yarn run`), independently of the selected runtime. Detection checks the destination's lockfiles first, then the invoking package manager's user-agent, and defaults to npm. Deno projects always use `deno task`.
35
-
36
- Every generated project includes:
37
-
38
- - `src/cli.ts` — entry point with a sample command
39
- - `package.json` — configured for the selected runtime and artifact, with `$schema` pointing at the `crust` block schema shipped by `@crustjs/crust` for editor completion
40
- - `tsconfig.json` — strict TypeScript config
41
- - `README.md` — getting started instructions
42
- - `.gitignore` — sensible defaults for Node/Bun projects
43
-
44
- Every project has the same scripts: `build` (`crust build`) stages the publishable npm package(s) in `.crust/`, `start` runs the built CLI from `.crust/root/bin/<name>.js`, and `release` (`crust publish`) publishes them. The runtime decides how the project runs in development; the `crust.artifact` setting decides what `build` puts in `.crust/`. All six combinations are selectable; the defaults preserve each runtime's established output:
45
-
46
- | Runtime | `dev` | `build` output (`crust.artifact`) |
47
- | ------- | ------------------------ | --------------------------------------------------------------------------------------------- |
48
- | `bun` | `bun run src/cli.ts` | `binary`: a root package with a Node launcher plus one standalone binary package per platform |
49
- | `node` | `node src/cli.ts` | `package`: a root package containing one JavaScript bundle that needs Node 24+ |
50
- | `deno` | `deno run -A src/cli.ts` | `binary`: a root package with a Node launcher plus one standalone binary package per platform |
51
-
52
- Every runtime puts the Crust packages your code imports (`@crustjs/core`, `@crustjs/extensions`) in `dependencies` and the build tool (`@crustjs/crust`) in `devDependencies`, and writes your selections to `"crust": { "runtime": ..., "artifact": ... }` in `package.json` so `crust build` needs no additional flags.
53
-
54
- For example, scaffold a Node binary or an experimental Deno runtime package:
21
+ ## Options
55
22
 
56
- ```sh
57
- npx create-crust@latest my-node-cli --runtime node --artifact binary
58
- npx create-crust@latest my-deno-cli --runtime deno --artifact package
59
- ```
23
+ The initializer prompts for every option you don't pass. Without an interactive terminal, prompts take their defaults.
60
24
 
61
- Node binaries need Node 26+ and Bun at build time; Node runtime packages do not need the Node executable compiler. Deno packages need Deno 2.5+ to bundle. The wizard does not install or pin compilers. See [Build and distribution](https://crustjs.com/docs/guide/build-and-distribution) for complete requirements.
25
+ | Option | Default | Effect |
26
+ | ------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27
+ | `[directory]` | prompt, `my-cli` | Destination. Its basename (the current directory's for `.`) becomes the package and command name: letters, digits, `.`, `_`, and `-`, starting with a letter or digit |
28
+ | `--runtime` | `bun` | `bun` or `node`: the runtime used by the `dev` and `start` scripts and by `crust build`; saved as `crust.runtime` in `package.json` |
29
+ | `--artifact` | `binary` for Bun, `package` for Node.js | `binary`: a standalone executable with the runtime embedded. `package`: a JavaScript bundle that needs the runtime installed. Saved as `crust.artifact` |
30
+ | `--install`, `--no-install` | install | Install dependencies with the detected package manager |
31
+ | `--git`, `--no-git` | initialize | Initialize a Git repository; skipped inside an existing one |
32
+ | `--overwrite`, `--no-overwrite` | prompt, don't overwrite | When the destination exists (or the current directory is not empty), overwrite conflicting files or abort |
62
33
 
63
- Artifact choice is separate from distribution channel. `release` publishes to npm, but npm is optional: standalone executables plus adjacent assets can be shipped as downloads or through Homebrew/Scoop without a separate JavaScript runtime. The npm binary launcher requires Node.js. The generated README links to [custom distribution](https://crustjs.com/docs/guide/build-and-distribution#custom-distribution); the wizard does not generate installer definitions.
34
+ Scripts in the next steps and generated README use the package manager detected from the destination's lockfiles, then the one running `create-crust`, defaulting to npm. Node.js binaries have extra build requirements; see [Build and distribution](https://crustjs.com/docs/guide/build-and-distribution#nodejs-binaries).
64
35
 
65
36
  ## Documentation
66
37
 
67
- See the full docs at [crustjs.com](https://crustjs.com).
38
+ Full docs: [crustjs.com/docs/quick-start](https://crustjs.com/docs/quick-start)
68
39
 
69
40
  ## License
70
41
 
@@ -1,36 +1,45 @@
1
1
  #!/usr/bin/env node
2
- var Xn=Symbol.dispose||Symbol.for("Symbol.dispose"),Zn=Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose"),Qe=(e,t,n)=>{if(t!=null){if(typeof t!=="object"&&typeof t!=="function")throw TypeError('Object expected to be assigned to "using" declaration');var r;if(n)r=t[Zn];if(r===void 0)r=t[Xn];if(typeof r!=="function")throw TypeError("Object not disposable");e.push([n,r,t])}else if(n)e.push([n]);return t},et=(e,t,n)=>{var r=typeof SuppressedError==="function"?SuppressedError:function(i,a,c,l){return l=Error(c),l.name="SuppressedError",l.error=i,l.suppressed=a,l},s=(i)=>t=n?new r(i,t,"An error was suppressed during disposal"):(n=!0,i),o=(i)=>{while(i=e.pop())try{var a=i[1]&&i[1].call(i[2]);if(i[0])return Promise.resolve(a).then(o,(c)=>(s(c),o()))}catch(c){s(c)}if(n)throw t};return o()};import{existsSync as Hn,readdirSync as Ci}from"node:fs";import{basename as Kn,dirname as Gn,isAbsolute as ji,join as _i,resolve as Yn}from"node:path";import{dirname as Xi,join as Zi,posix as Qi,resolve as yr,win32 as ea}from"node:path";import{existsSync as tt,statSync as Qn}from"node:fs";import{dirname as nt,isAbsolute as Mi,join as er,resolve as tr}from"node:path";function rt(e){let t=tr(e);if(tt(t)&&!Qn(t).isDirectory())t=nt(t);while(!0){if(tt(er(t,"package.json")))return t;let n=nt(t);if(n===t)return null;t=n}}import{realpathSync as nr}from"node:fs";import{dirname as rr,join as pe,resolve as sr}from"node:path";import{fileURLToPath as or}from"node:url";var st="CRUST_INTERNAL_BUILD_OUT_DIR",ir="crustjs.packagedBuild",ar=Symbol.for(ir);function ge(){return globalThis[ar]===!0}function cr(){let{Bun:e,Deno:t}=globalThis,n=e?.main??"";return n.startsWith("/$bunfs/")||/^[A-Za-z]:[\\/]~BUN[\\/]/.test(n)||t?.build?.standalone===!0||process.getBuiltinModule?.("node:sea")?.isSea()===!0}function lr(){return ge()||!0}function he(e){if(e===""||e==="."||e===".."||/[\\/]/.test(e))throw Error(`Artifact name must be a single directory name, got ${JSON.stringify(e)}.`);if(cr())return pe(rr(process.execPath),e);if(lr())return sr(or(import.meta.url),"..","..",e);let t=process.env[st];if(t)return pe(t,e);let n=process.argv[1],r=n;if(n)try{r=nr(n)}catch(o){throw Error(`Could not resolve artifact "${e}": could not resolve source entrypoint "${n}".`,{cause:o})}let s=r?rt(r):null;if(!s)throw Error(`Could not resolve artifact "${e}": no package.json was found above ${n?`entrypoint "${n}"`:"process.argv[1] (unset)"}.`);return pe(s,".crust","root",e)}import{AsyncLocalStorage as ur}from"node:async_hooks";import{Writable as fr}from"node:stream";var dr=Symbol.for("crustjs.terminal.io"),mr=Symbol.for("crustjs.terminal.ambient-callbacks"),ot=globalThis,V=ot[dr]??=new ur,it=ot[mr]??=new WeakMap;function be(e,t){let n=V.getStore();return V.run({input:e.input??n?.input,output:e.output??n?.output},t)}function q(){return V.getStore()}function pr(e){let t="",n=new fr({decodeStrings:!1,write(r,s,o){t+=r.toString();let i=t.indexOf(`
2
+ var T=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var Ls=Symbol.dispose||Symbol.for("Symbol.dispose"),zs=Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose"),rn=(e,t,n)=>{if(t!=null){if(typeof t!=="object"&&typeof t!=="function")throw TypeError('Object expected to be assigned to "using" declaration');var r;if(n)r=t[zs];if(r===void 0)r=t[Ls];if(typeof r!=="function")throw TypeError("Object not disposable");e.push([n,r,t])}else if(n)e.push([n]);return t},sn=(e,t,n)=>{var r=typeof SuppressedError==="function"?SuppressedError:function(i,a,c,l){return l=Error(c),l.name="SuppressedError",l.error=i,l.suppressed=a,l},s=(i)=>t=n?new r(i,t,"An error was suppressed during disposal"):(n=!0,i),o=(i)=>{while(i=e.pop())try{var a=i[1]&&i[1].call(i[2]);if(i[0])return Promise.resolve(a).then(o,(c)=>(s(c),o()))}catch(c){s(c)}if(n)throw t};return o()};function J(e){if(process.platform!=="linux"||process.versions.bun===void 0)return!1;on??=Bs();let t=process.getBuiltinModule("node:os").constants.signals[e];return t!==void 0&&t<=32&&(on>>>t-1&1)===1}function Bs(){try{let e=process.getBuiltinModule("node:fs").readFileSync("/proc/self/status","utf8"),t=/^SigIgn:\s*([0-9a-f]+)$/m.exec(e)?.[1];return t?Number.parseInt(t.slice(-8),16):0}catch{return 0}}var on;var le=()=>{};function q(e){return e instanceof Error&&"code"in e&&typeof e.code==="string"}var ue=()=>{};function Us(e,t){let n=()=>{if(e.listenerCount("error")===0)e.once("error",an)};try{n(),e.write(t,(r)=>{if(r)n()})}catch{}finally{e.removeListener("error",an)}}function Vs(e,t){if(cn.has(e))return;let{writeSync:n}=process.getBuiltinModule("node:fs"),r=typeof t==="string"?Buffer.from(t):t,s=0;while(s<r.length)try{s+=n(e,r,s)}catch(o){let i=q(o)?o.code:void 0;if(i!=="EAGAIN"){if(i==="EPIPE"||i==="EBADF")cn.add(e);return}Atomics.wait(Ws??=new Int32Array(new SharedArrayBuffer(4)),0,0,1)}}function Z(e,t){let n=F[de];if(n===void 0||ze||!process.getBuiltinModule("node:tty").isatty(e)){Be(e,t);return}ze=!0;try{if(n.clear(),Be(e,t),typeof t==="string"?t.endsWith(`
3
+ `):t.at(-1)===10)n.redraw()}finally{ze=!1}}function Be(e,t){if(process.platform==="win32")Us(e===1?process.stdout:process.stderr,t);else Vs(e,t)}function ln(e){return F[de]=e,()=>{if(F[de]===e)F[de]=void 0}}function me(){return F[fn]??=new(process.getBuiltinModule("node:async_hooks")).AsyncLocalStorage}function dn(){return F[Hs]??=new WeakMap}function Ue(e,t){let n=me().getStore();return me().run({input:e.input??n?.input,output:e.output??n?.output,signal:e.signal??n?.signal},t)}function Y(){return F[fn]?.getStore()?.signal??F[fe]}async function mn(e,t){let n=F[fe];F[fe]=e;try{return await t()}finally{F[fe]=n}}function pe(){return me().getStore()}function Gs(e){let t="",n=new(process.getBuiltinModule("node:stream")).Writable({decodeStrings:!1,write(r,s,o){t+=r.toString();let i=t.indexOf(`
3
4
  `);while(i!==-1)e.stderr(t.slice(0,i)),t=t.slice(i+1),i=t.indexOf(`
4
- `);o()}});return it.set(n,e),n}function we(e,t){let n=V.getStore();return be({input:n?.input,output:n?.output&&!it.has(n.output)?n.output:pr(e)},t)}import{parseArgs as vr}from"node:util";import{isPromise as xr}from"node:util/types";function at(e){let t=Number(e);return Number.isNaN(t)?void 0:t}function H(e){return e==="true"||e==="1"}import{homedir as Sr}from"node:os";function gr(e){return typeof e==="number"}function hr(e){return e.map((t,n)=>gr(t)?`[${t}]`:n>0?`.${String(t)}`:String(t)).join("")}function br(e){return typeof e==="object"&&e!==null&&"key"in e}function wr(e){if(!e)return[];return e.map((t)=>br(t)?t.key:t)}function ct(e,t=[]){return e.map((n)=>{let r=wr(n.path),s=[...t,...r];return{message:n.message,path:hr(s)}})}var h=class extends Error{code;details;cause;constructor(e,t,...n){super(t);this.name="CrustError",this.code=e,this.details=n[0]}is(e){return Object.is(this.code,e)}withCause(e){return this.cause=e,this}toJSON(){return{code:this.code,message:this.message,details:this.details}}};function ye(e,t){if(e==="")throw new h("DEFINITION",`Flag ${t} spellings must be non-empty`,{subject:"flag",name:e,reason:"empty-spelling"});if(t!=="short"&&e.startsWith("no-"))throw new h("DEFINITION",`Flag ${t} "${e}" must not start with "no-"; the prefix is reserved for boolean negation`,{subject:"flag",name:e,reason:"reserved-no-prefix"});if(e==="__proto__")throw new h("DEFINITION",`Flag ${t} "__proto__" is a reserved spelling`,{subject:"flag",name:e,reason:"reserved-spelling"})}function pt(e,t){return[e,...t.short===void 0?[]:[t.short],...t.aliases??[]]}function gt(e){return e.type==="boolean"&&e.noNegate!==!0}function ht(e,t,n){if(e.choices&&e.default!==void 0){let r="multiple"in e&&e.multiple?e.default:[e.default];for(let s of r)if(!e.choices.includes(s))throw new h("DEFINITION",`${t==="flag"?"Flag":"Argument"} "${n}" default must be one of choices`,{subject:t,name:n,reason:"default-outside-choices"})}return Object.freeze({...e,..."aliases"in e&&e.aliases?{aliases:Object.freeze([...e.aliases])}:{},...e.choices?{choices:Object.freeze([...e.choices])}:{},..."env"in e&&e.env?{env:Object.freeze({name:e.env.name,delimiter:e.env.delimiter})}:{},..."multiple"in e&&e.multiple&&Array.isArray(e.default)?{default:Object.freeze([...e.default])}:{}})}function Or(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&"name"in e&&typeof e.name==="string"&&(!("delimiter"in e)||e.delimiter===void 0||typeof e.delimiter==="string")}function bt(e,t){if(ye(e,"canonical"),t.short!==void 0)ye(t.short,"short");for(let r of t.aliases??[])ye(r,"alias");let n=pt(e,t);if(new Set(n).size!==n.length)throw new h("DEFINITION",`Flag "${e}" repeats one of its own spellings`,{subject:"flag",name:e,reason:"flag-collision"});if(t.short!==void 0&&t.short.length!==1)throw new h("DEFINITION",`Flag "${e}" short "${t.short}" must be one character`,{subject:"flag",name:e,reason:"invalid-short"});if(t.env!==void 0&&!Or(t.env))throw new h("DEFINITION",`Flag "${e}" env must be an object with a string name and optional string delimiter`,{subject:"flag",name:e,reason:"invalid-env"});if(t.env?.name==="")throw new h("DEFINITION",`Flag "${e}" env variable name must be non-empty`,{subject:"flag",name:e,reason:"empty-env"});for(let[r,s]of[["delimiter",t.delimiter],["env.delimiter",t.env?.delimiter]]){if(s===void 0)continue;if(!t.multiple)throw new h("DEFINITION",`Flag "${e}" ${r} requires multiple: true`,{subject:"flag",name:e,reason:"delimiter-without-multiple"});if(s==="")throw new h("DEFINITION",`Flag "${e}" ${r} must be non-empty`,{subject:"flag",name:e,reason:"empty-delimiter"})}return ht(t,"flag",e)}function wt(e){if(e.name==="")throw new h("DEFINITION","Argument names must be non-empty",{subject:"argument",name:e.name,reason:"empty-name"});return ht(e,"argument",e.name)}function $r(e){return e.meta.hidden!==!0}var Er={command:"Command",context:"Context",extension:"Extension"};function Ir({subject:e,name:t}){let n=Er[e];return new h("DEFINITION",`${n} "${t}" contains invalid documentation sections`,{subject:e,name:t,reason:"invalid-sections"})}function yt(e,t){let{title:n,body:r,only:s,except:o}=e;if(!n.trim()||/[\r\n]/.test(n)||!r.trim()||s?.length===0||o?.length===0||s!==void 0&&o!==void 0)throw Ir(t);let i=(a)=>Object.freeze(a.map((c)=>typeof c==="string"?c:c.id));return Object.freeze({title:n,body:r,...s?{only:i(s)}:o?{except:i(o)}:{}})}function je(e,t,n="command"){return t.map((r)=>yt(r,{subject:n,name:e}))}var Cr=Symbol("crust.defining");function Y(e){return e[Cr]}var vt=Symbol.for("crust.contextSources");function xt(e){return"contextName"in e?e.contextName:e.name}function J(e,t){let n=new Set(e.map((o)=>o.name)),r=new Set,s=(o)=>{if(r.has(o))return;r.add(o);let i=xt(o);if(!n.has(i))throw new h("DEFINITION",`No provider for Context "${i}"`,{subject:"context",name:i,reason:"missing-context"});for(let a of o.use)s(a)};for(let o of t)s(o)}var jr=Object.freeze({[Symbol("crust.handled")]:!0});function Se(){return jr}function St(e){return{meta:{name:e},localFlags:{},ownedFlags:{},effectiveFlags:{},flagSpellings:new Map,args:[],subCommands:{},contexts:[],providedContexts:[],demands:[],extensions:[],run:void 0}}function N(e,t,n,r){n=bt(t,n);let s=pt(t,n),o=Object.hasOwn(e.effectiveFlags,t)?t:s.map((a)=>e.flagSpellings.get(a)?.canonicalName).find((a)=>a!==void 0);if(o!==void 0)throw new h("DEFINITION",`Flag "${t}" collides with existing flag "${o}" on command "${e.meta.name}"`,{subject:"flag",name:t,reason:"flag-collision"});(r==="local"?e.localFlags:e.ownedFlags)[t]=n,e.effectiveFlags[t]=n;let i={canonicalName:t,def:n,negatable:gt(n)};if(e.flagSpellings.set(t,{...i,kind:"canonical"}),n.short!==void 0)e.flagSpellings.set(n.short,{...i,kind:"short"});for(let a of n.aliases??[])e.flagSpellings.set(a,{...i,kind:"alias"})}function X(e){return{localFlags:{...e.localFlags},ownedFlags:{...e.ownedFlags},effectiveFlags:{...e.effectiveFlags},flagSpellings:new Map(e.flagSpellings)}}function P(e){let t={};for(let[n,r]of Object.entries(e.subCommands))t[n]=P(r);return{...e,meta:{...e.meta},...X(e),args:[...e.args],subCommands:t,contexts:e.contexts.map((n)=>({...n})),providedContexts:[...e.providedContexts],demands:[...e.demands],extensions:[...e.extensions]}}function Ot(e,t,n,r){if(N(e,t,n,"owned"),!r)return;for(let s of Object.values(e.subCommands))Ot(s,t,n,!0)}function _r(e,t,n){for(let r of t.commands)e.subCommands[r.name]=n(r,e,t.id)}function kr(e,t){for(let[n,r]of Object.entries(t.flags)){let{recursive:s=!0,...o}=r;Ot(e,n,o,s)}}function Nr(e,t,n){let r=e;for(let s of t){let o=Object.hasOwn(r.subCommands,s)?r.subCommands[s]:void 0;if(!o)throw new h("DEFINITION",`Extension "${n.id}" section target "${t.join(" ")}" is not a canonical command path`,{subject:"extension",name:n.id,reason:"invalid-section-path"});r=o}return r}function Ar(e,t,n){if(!t.sections)return;let r={subject:"extension",name:t.id},s=t.sections(n);for(let o of s){let i=yt(o,r),a=Nr(e,o.command,t);a.meta.sections=[...a.meta.sections??[],i]}}function Tr(e,t){let n=(r,s,o)=>{let i=[...new Map(o.map((a)=>[a.name,a])).values()];if(i.some((a)=>a.sections.length>0)){let a=new Set((r.meta.sections??[]).map(({title:c})=>c));for(let c of i){for(let{title:l}of c.sections)if(a.has(l))throw new h("DEFINITION",`Context "${c.name}" section "${l}" duplicates a section on command "${s}"`,{subject:"context",name:c.name,reason:"duplicate-section"});for(let{title:l}of c.sections)a.add(l)}r.meta.sections=[...r.meta.sections??[],...i.flatMap((c)=>c.sections)]}for(let[a,c]of Object.entries(r.subCommands))n(c,`${s} ${a}`,c.providedContexts)};n(e,e.meta.name,[...e.providedContexts,...t.flatMap((r)=>r.provide)])}function $t(e,t,n){let r=P(e),s=new Set(t.flatMap((i)=>!n.has(i.id)&&e.extensions.includes(i)?[i.id]:[])),o=(i)=>{i.contexts=i.contexts.filter((u)=>u.extensionId===void 0||s.has(u.extensionId));let a=Object.keys(i.effectiveFlags),c=i.localFlags,l={};for(let{instance:u}of i.contexts)Object.assign(l,u.ownedFlags);i.localFlags={},i.ownedFlags={},i.effectiveFlags={},i.flagSpellings=new Map;for(let u of a){let f=Object.hasOwn(l,u)?"owned":"local",d=f==="owned"?l:c;if(Object.hasOwn(d,u))N(i,u,d[u],f)}for(let u of Object.values(i.subCommands))o(u)};o(r);for(let i of t){if(s.has(i.id))continue;let a=i.provide;if(a.length===0)continue;let c=(l,u)=>{let f=a.filter((b)=>!u.has(b.name)),d=f.map((b)=>({instance:b,extensionId:i.id}));l.contexts.push(...d);for(let b of f)for(let[m,g]of Object.entries(b.ownedFlags))N(l,m,g,"owned");let p=new WeakSet(l.contexts.map(({instance:b})=>b));for(let b of Object.values(l.subCommands)){let m=new Set(u);for(let{instance:g}of b.contexts)if(!p.has(g))m.add(g.name);c(b,m)}};c(r,new Set)}return r}function Fr(e,t){try{return new URL(e)}catch(n){throw new h("PARSE",`Invalid URL for ${t}: "${e}"${/^[a-z][a-z0-9+.-]*:/i.test(e)?"":" (missing protocol — e.g. https://example.com)"}`).withCause(n)}}function Oe(e,t){if(e==="")throw new h("PARSE",`Path for ${t} cannot be empty`);let n=e.replace(/^~(?=\/|$)/,()=>Sr());return yr(process.cwd(),n)}function Pr(e,t){try{return JSON.parse(e)}catch(n){throw new h("PARSE",`Invalid JSON for ${t}: ${n instanceof Error?n.message:String(n)}. Tip: wrap JSON in single quotes on the command line, e.g. --flag '{"k":1}'`).withCause(n)}}async function lt(e,t,n,r){let s=await e["~standard"].validate(t);if(s.issues)return r.push(...ct(s.issues,n)),{ok:!1};return{ok:!0,value:s.value}}async function Rr(e,t){let n=[],r=new Map(Object.entries(t.args)),s=new Map(Object.entries(t.flags));for(let o of e.args){if(o.schema===void 0)continue;let i=await lt(o.schema,r.get(o.name),["args",o.name],n);if(i.ok)r.set(o.name,i.value)}for(let[o,i]of Object.entries(e.effectiveFlags)){if(i.schema===void 0)continue;let a=await lt(i.schema,s.get(o),["flags",o],n);if(a.ok)s.set(o,a.value)}if(n.length>0)throw new h("VALIDATION",`Invalid input:
5
+ `);o()}});return dn().set(n,e),n}function We(e,t,n){let r=me().getStore();return Ue({input:r?.input,output:r?.output&&!dn().has(r.output)?r.output:Gs(e),signal:n},t)}var an=()=>{},Ws,cn,ze=!1,un,fn,Hs,fe,de,F;var Q=T(()=>{ue();cn=new Set;un={get isTTY(){return process.getBuiltinModule("node:tty").isatty(2)},get columns(){return process.stderr.columns},write:(e)=>Be(2,e)},fn=Symbol.for("crustjs.terminal.io"),Hs=Symbol.for("crustjs.terminal.ambient-callbacks"),fe=Symbol.for("crustjs.terminal.process-signal"),de=Symbol.for("crustjs.terminal.live-frame"),F=globalThis});function pn(e){if(e.trim()==="")return;let t=Number(e);return Number.isNaN(t)?void 0:t}function he(e){return e==="true"||e==="1"}var hn=()=>{};function Js(e){return typeof e==="number"}function qs(e){return e.map((t,n)=>Js(t)?`[${t}]`:n>0?`.${String(t)}`:String(t)).join("")}function Ys(e){return typeof e==="object"&&e!==null&&"key"in e}function Ks(e){if(!e)return[];return e.map((t)=>Ys(t)?t.key:t)}function gn(e,t=[]){return e.map((n)=>{let r=Ks(n.path),s=[...t,...r];return{message:n.message,path:qs(s)}})}var bn=()=>{};function Se(e){return e!==""&&!/[ \t\n\r\v\f]/.test(e)&&!e.startsWith("-")}function Ve(e,t){if(e==="")throw new b("DEFINITION",`Flag ${t} spellings must be non-empty`,{subject:"flag",name:e,reason:"empty-spelling"});if(t==="canonical"&&Xs.test(e))throw new b("DEFINITION",`Flag name "${e}" must not be integer-like; JavaScript reorders such keys`,{subject:"flag",name:e,reason:"integer-like-name"});if(t!=="short"&&e.startsWith("no-"))throw new b("DEFINITION",`Flag ${t} "${e}" must not start with "no-"; the prefix is reserved for boolean negation`,{subject:"flag",name:e,reason:"reserved-no-prefix"});if(e==="__proto__")throw new b("DEFINITION",`Flag ${t} "__proto__" is a reserved spelling`,{subject:"flag",name:e,reason:"reserved-spelling"});if(!Se(e)||t!=="short"&&e.includes("="))throw new b("DEFINITION",`Flag ${t} "${e}" must not contain whitespace${t==="short"?"":' or "="'} or start with "-"`,{subject:"flag",name:e,reason:"invalid-spelling"})}function we(e,t){return[...e===void 0?[]:[e],...t.short===void 0?[]:[t.short],...t.aliases??[]]}function _n(e){return e.type==="boolean"&&e.noNegate!==!0}function Zs(e){return new b("DEFINITION",e,{subject:"flag",reason:"invalid-flags"})}function st(e){let t=e===null||e===void 0,n=t?void 0:Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw Zs(t?".flags() expects a plain object record":".flags() expects a plain object record; a `__proto__` key sets its prototype instead of naming a flag");let r=Object.entries(e);for(let[s,o]of r)if(o===void 0||o===null)throw new b("DEFINITION",`Flag "${s}" definition must be an object`,{subject:"flag",name:s,reason:"invalid-flags"});return r}function ot(e,t={}){let n={...t},r=new Set(Object.entries(t).flatMap(([s,o])=>we(s,o)));for(let[s,o]of e){let i=it(s,o);for(let a of we(s,i)){if(r.has(a))throw new b("DEFINITION",`Flag "${s}" collides with an existing flag`,{subject:"flag",name:s,reason:"flag-collision"});r.add(a)}n[s]=i}return n}function Ee(e,t,n){if(e.choices&&e.default!==void 0){let r="multiple"in e&&e.multiple?e.default:[e.default];for(let s of r)if(!e.choices.includes(s))throw new b("DEFINITION",`${t==="flag"?"Flag":"Argument"}${n===void 0?"":` "${n}"`} default must be one of choices`,{subject:t,...n===void 0?{}:{name:n},reason:"default-outside-choices"})}return Object.freeze({...e,..."aliases"in e&&e.aliases?{aliases:Object.freeze([...e.aliases])}:{},...e.choices?{choices:Object.freeze([...e.choices])}:{},..."env"in e&&e.env?{env:Object.freeze({name:e.env.name,delimiter:e.env.delimiter})}:{},..."multiple"in e&&e.multiple&&Array.isArray(e.default)?{default:Object.freeze([...e.default])}:{}})}function Qs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&"name"in e&&typeof e.name==="string"&&(!("delimiter"in e)||e.delimiter===void 0||typeof e.delimiter==="string")}function it(e,t){let n=e===void 0?"Flag":`Flag "${e}"`,r=e===void 0?{}:{name:e};if(e!==void 0)Ve(e,"canonical");if(t.short!==void 0)Ve(t.short,"short");for(let o of t.aliases??[])Ve(o,"alias");let s=we(e,t);if(new Set(s).size!==s.length)throw new b("DEFINITION",`${n} repeats one of its own spellings`,{subject:"flag",...r,reason:"flag-collision"});if(t.short!==void 0&&!/^.$/su.test(t.short))throw new b("DEFINITION",`${n} short "${t.short}" must be one character`,{subject:"flag",...r,reason:"invalid-short"});if(t.env!==void 0&&!Qs(t.env))throw new b("DEFINITION",`${n} env must be an object with a string name and optional string delimiter`,{subject:"flag",...r,reason:"invalid-env"});if(t.env?.name==="")throw new b("DEFINITION",`${n} env variable name must be non-empty`,{subject:"flag",...r,reason:"empty-env"});for(let[o,i]of[["delimiter",t.delimiter],["env.delimiter",t.env?.delimiter]]){if(i===void 0)continue;if(!t.multiple)throw new b("DEFINITION",`${n} ${o} requires multiple: true`,{subject:"flag",...r,reason:"delimiter-without-multiple"});if(i==="")throw new b("DEFINITION",`${n} ${o} must be non-empty`,{subject:"flag",...r,reason:"empty-delimiter"})}return Ee(t,"flag",e)}function An(e){if(e.name==="")throw new b("DEFINITION","Argument names must be non-empty",{subject:"argument",name:e.name,reason:"empty-name"});return Ee(e,"argument",e.name)}function at(e){return e.meta.hidden!==!0}function ct(e,t){let n=(e??[]).filter((s)=>{if(s.only)return s.only.includes(t);if(s.except)return!s.except.includes(t);return!0}),r=new Map;for(let s of n){let o=r.get(s.title);r.set(s.title,o?{title:s.title,body:`${o.body}
6
+ ${s.body}`}:s)}return[...r.values()]}function to({subject:e,name:t}){let n=eo[e];return new b("DEFINITION",`${n} "${t}" contains invalid documentation sections`,{subject:e,name:t,reason:"invalid-sections"})}function Tn(e,t){let{title:n,body:r,only:s,except:o}=e;if(!n.trim()||/[\r\n]/.test(n)||!r.trim()||s?.length===0||o?.length===0||s!==void 0&&o!==void 0)throw to(t);let i=(a)=>Object.freeze(a.map((c)=>typeof c==="string"?c:c.id));return Object.freeze({title:n,body:r,...s?{only:i(s)}:o?{except:i(o)}:{}})}function lt(e,t,n="command"){return t.map((r)=>Tn(r,{subject:n,name:e}))}function M(e){return e[kn]}function Fn(e,t){return Object.freeze(Object.assign(e,{[kn]:t}))}function Pn(e){return"contextName"in e?e.contextName:e.name}function Ce(e,t){let n=new Set(e.map((o)=>o.name)),r=new Set,s=(o)=>{if(r.has(o))return;r.add(o);let i=Pn(o);if(!n.has(i))throw new b("DEFINITION",`No provider for Context "${i}"`,{subject:"context",name:i,reason:"missing-context"});for(let a of o.use)s(a)};for(let o of t)s(o)}function Rn(e,t){try{return new URL(e)}catch{throw new b("PARSE",`Invalid URL for ${t}${/^[a-z][a-z0-9+.-]*:/i.test(e)?"":" (missing protocol — e.g. https://example.com)"}.`)}}function He(e,t){if(e==="")throw new b("PARSE",`Path for ${t} cannot be empty`);let n=e.replace(/^~(?=\/|$)/,()=>process.getBuiltinModule("node:os").homedir());return process.getBuiltinModule("node:path").resolve(process.cwd(),n)}function no(e,t){try{return JSON.parse(e)}catch{throw new b("PARSE",`Invalid JSON for ${t}. Tip: wrap JSON in single quotes on the command line, e.g. --flag '{"k":1}'`)}}async function Ge(e,t,n,r){let s=await e["~standard"].validate(t);if(s.issues)return r.push(...gn(s.issues,n)),{ok:!1};return{ok:!0,value:s.value}}async function ro(e,t){let n=[],r=new Map(Object.entries(t.args)),s=new Map(Object.entries(t.flags));for(let o of e.args){if(o.schema===void 0)continue;let i=await Ge(o.schema,r.get(o.name),["args",o.name],n);if(i.ok)r.set(o.name,i.value)}for(let[o,i]of Object.entries(e.effectiveFlags)){if(i.schema===void 0)continue;let a=await Ge(i.schema,s.get(o),["flags",o],n);if(a.ok)s.set(o,a.value)}if(n.length>0)throw new b("VALIDATION",`Invalid input:
5
7
  ${n.map((o)=>` - ${o.path}: ${o.message}`).join(`
6
- `)}`,{issues:n});return{args:Object.fromEntries(r),flags:Object.fromEntries(s)}}function Dr(e){let t={};for(let[n,r]of e){if(r.kind==="short")continue;let s={type:r.def.type==="boolean"?"boolean":"string"};if(r.def.multiple)s.multiple=!0;if(r.kind==="canonical"&&r.def.short)s.short=r.def.short;t[n]=s}return t}function Mr(e,t,n){if(t==="number"){let r=at(e);if(r===void 0)throw new h("PARSE",`Expected number for ${n}, got "${e}"`);return r}if(t==="boolean")return H(e);if(t==="url")return Fr(e,n);if(t==="path")return Oe(e,n);if(t==="json")return Pr(e,n);return e}function Lr(e,t,n){if(!t.includes(e))throw new h("PARSE",`Invalid value "${e}" for ${n}. Expected one of: ${t.join(", ")}`)}function $e(e,t,n,r){let s=r===void 0?n:`${n} element [${r}]`,o;try{o=e(t)}catch(i){throw new h("PARSE",`Failed to parse ${s}: ${i instanceof Error?i.message:String(i)}`).withCause(i)}if(xr(o))throw o.catch(()=>{}),new h("PARSE",`Failed to parse ${s}: parse must be synchronous`);return o}function Ee(e,t){let{default:n,parse:r}=e;if(n===void 0)return;if(r){if(Array.isArray(n))return n.map((s,o)=>$e(r,String(s),t,o));return $e(r,String(n),t)}if(e.type==="path"){if(Array.isArray(n))return n.map((s)=>Oe(String(s),t));return Oe(String(n),t)}return"multiple"in e&&e.multiple&&Array.isArray(n)?[...n]:n}function G(e,t,n,r){if(e.schema)return t;if(e.choices)Lr(t,e.choices,n);if(e.parse)return $e(e.parse,t,n,r);return Mr(t,e.type,n)}function zr(e,t,n){if(n.kind==="boolean")return n.value;let r=`--${e}`;return Array.isArray(n.value)?n.value.map((s,o)=>G(t,s,r,o)):G(t,n.value,r)}function Br(e,t){let n={};for(let r of e){if(r.kind!=="option")continue;let{canonicalName:s,def:o}=t.get(r.name),i=n[s];if(o.type==="boolean"){let a=!r.rawName.startsWith("--no-");if(o.multiple&&i?.kind==="boolean"&&Array.isArray(i.value))i.value.push(a);else n[s]={kind:"boolean",value:o.multiple?[a]:a}}else{let a=r.value;if(o.multiple&&i?.kind==="string"&&Array.isArray(i.value))i.value.push(a);else n[s]={kind:"string",value:o.multiple?[a]:a}}}return n}function Et(e,t){if(t===void 0)return[...e];return e.flatMap((n)=>n.split(t)).filter((n)=>n!=="")}function Wr(e,t,n){let r=t.multiple?Et([n],t.env?.delimiter):[n];if(t.multiple&&r.length===0)return;if(t.type!=="boolean")return{kind:"string",value:t.multiple?r:n};let s=r.map(H);if("noNegate"in t&&t.noNegate&&s.includes(!1))throw new h("PARSE",`Flag "--${e}" does not support negation (from ${t.env?.name})`);return{kind:"boolean",value:t.multiple?s:H(n)}}function Ur(e,t,n){let r={};for(let[s,o]of Object.entries(e)){let i=Object.hasOwn(t,s)?t[s]:void 0;if(i!==void 0){if(o.delimiter!==void 0&&i.kind==="string"&&Array.isArray(i.value)){let c=Et(i.value,o.delimiter);r[s]=c.length===0?void 0:{kind:"string",value:c}}else r[s]=i;continue}if(o.env===void 0||!Object.hasOwn(n,o.env.name))continue;let a=n[o.env.name];if(a!==void 0)r[s]=Wr(s,o,a)}return r}function Vr(e,t,n){let r={};for(let[s,o]of Object.entries(e)){let i=Object.hasOwn(t,s)?t[s]:void 0;if(!(i===void 0||o.multiple&&Array.isArray(i)&&i.length===0)){r[s]=n(s,o,i);continue}r[s]=Ee(o,`--${s}`)}return r}function qr(e,t){for(let[n,r]of Object.entries(e))if(r.required===!0&&r.default===void 0){if(t[n]===void 0)throw new h("VALIDATION",`Missing required flag "--${n}"`)}}function Hr(e,t){for(let n of e){if(n.required!==!0||n.default!==void 0)continue;let r=t[n.name];if(n.variadic?!Array.isArray(r)||r.length===0:r===void 0)throw new h("VALIDATION",`Missing required argument "<${n.name}>"`)}}function Gr(e,t,n){let r={},s=0;for(let o of e){let{name:i}=o,a=`<${i}>`;if(Object.defineProperty(r,i,{value:void 0,writable:!0,enumerable:!0,configurable:!0}),o.variadic){let c=t.slice(s);r[i]=c.length===0&&o.default!==void 0?[Ee(o,a)]:c.map((l,u)=>n(o,l,a,u)),s=t.length}else if(s<t.length)r[i]=n(o,t[s],a),s++;else r[i]=Ee(o,a)}return{args:r,consumed:s}}function Kr(e,t){for(let n of e){if(n==="--")return;if(!n.startsWith("--no-"))continue;let r=n.indexOf("="),s=r===-1?n.slice(5):n.slice(5,r),o=t.get(s);if(!o||o.def.type!=="boolean"||o.negatable)continue;throw new h("PARSE",`Flag "--${o.canonicalName}" does not support negation ("--no-${s}")`)}}function Yr(e,t){let n=e.flagSpellings,r=Dr(n);Kr(t,n);let s;try{s=vr({args:t,options:r,strict:!0,allowPositionals:!0,allowNegative:!0,tokens:!0})}catch(c){if(c instanceof Error){let l=c.message.match(/Unknown option '(.+?)'/)?.[1];if(l!==void 0)throw new h("PARSE",`Unknown flag "${l}"`,{flag:l.replace(/^-+|=.*$/g,""),reason:"unknown-flag"}).withCause(c);if("code"in c&&c.code==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"&&c.message.length>0)throw new h("PARSE",c.message).withCause(c)}throw new h("PARSE","Failed to parse command arguments").withCause(c)}let o=[],i=[],a=!1;for(let c of s.tokens){if(c.kind==="option-terminator"){a=!0;continue}if(c.kind==="positional")(a?o:i).push(c.value)}return{positionals:i,flagValues:Br(s.tokens,n),rawArgs:o}}function _e(e){return Array.isArray(e)}function Jr(e,t,n){let r=e.schema?e.type==="boolean"?"boolean":"string":e.type,s;if(r==="url")s=t instanceof URL;else if(r==="json"){let o=[t],i=new Set;s=!0;while(o.length>0){let a=o.pop();if(a instanceof URL){s=!1;break}if(_e(a)&&!i.has(a))i.add(a),o.push(...a)}}else s=typeof t===(r==="path"?"string":r);if(!s)throw new h("PARSE",`Expected ${r} for ${n}`);if(t===!1&&"noNegate"in e&&e.noNegate)throw new h("PARSE",`Flag "${n}" does not support negation`)}function Ie(e,t,n,r){if(Jr(e,t,n),e.type!=="string"&&e.type!=="path")return t;return G(e,String(t),n,r)}function Xr(e,t,n){let r=`--${e}`;if(t.multiple){if(!_e(n))throw new h("PARSE",`Expected an occurrence array for ${r}`);return n.map((s,o)=>Ie(t,s,r,o))}return Ie(t,n,r)}function It(e,t,n,r,s){let o=Vr(e.effectiveFlags,n,s);return{...Gr(e.args,t,r),flags:o}}function Zr(e,t,n=process.env){let{positionals:r,flagValues:s,rawArgs:o}=Yr(e,t),{args:i,flags:a,consumed:c}=It(e,r,Ur(e.effectiveFlags,s,n),G,zr);return{args:i,flags:a,excessArgs:r.slice(c),rawArgs:o}}function Qr(e,t){let{args:n,flags:r,raw:s}=t,o=[],i;for(let l of e.args){let u=n&&Object.hasOwn(n,l.name)?n[l.name]:void 0;if(u===void 0){i=l.name;continue}if(i!==void 0)throw new h("PARSE",`Argument <${l.name}> cannot be provided after omitted argument <${i}>`,{argument:l.name,reason:"positional-gap"});if(l.variadic){if(!_e(u))throw new h("PARSE",`Expected an occurrence array for <${l.name}>`);o.push(...u)}else o.push(u)}for(let l of Object.keys(n??{}))if(!e.args.some((u)=>u.name===l)&&n?.[l]!==void 0)throw new h("PARSE",`Unknown argument "${l}"`,{argument:l,reason:"unknown-argument"});for(let l of Object.keys(r??{}))if(!Object.hasOwn(e.effectiveFlags,l)&&r?.[l]!==void 0)throw new h("PARSE",`Unknown flag "--${l}"`,{flag:l,reason:"unknown-flag"});let{args:a,flags:c}=It(e,o,r??{},Ie,Xr);return{args:a,flags:c,excessArgs:[],rawArgs:[...s??[]]}}function es(e,t){if(t.excessArgs.length>0)throw new h("VALIDATION",`Unexpected positional argument${t.excessArgs.length===1?"":"s"}: ${t.excessArgs.map((n)=>JSON.stringify(n)).join(", ")}`);Hr(e.args,t.args),qr(e.effectiveFlags,t.flags)}function ts(e){if(e===null||typeof e!=="object"&&typeof e!=="function")return!1;let t=e;return typeof t[Symbol.asyncDispose]==="function"||typeof t[Symbol.dispose]==="function"}function ns(e,t,n){if(!ts(e)||n.has(e))return;n.add(e),t.use(e)}function rs(e,t,n,r){let s=new Map(e.map((m)=>[m.name,m])),o=new Map,i=new WeakSet,a,c=!0,l=!1;n.defer(()=>{l=!0});let u=(m,g,w=new Set)=>{if(m.name===g)return[m.name];if(w.has(m.name))return;w.add(m.name);for(let S of m.waitingOn){let x=o.get(S);if(!x)continue;let v=u(x,g,w);if(v)return[m.name,...v]}},f=(m)=>{try{let g=new Set;for(let w=m;w!=null&&!g.has(w);w=w.cause)if(g.add(w),w instanceof h&&w.code==="DEFINITION"&&w.details?.reason==="flags-before-validation")return!0;return!1}catch{return!1}};function d(m){let g=Promise.reject(m);return g.catch(()=>{}),g}let p=(m)=>(g)=>{let w=m?` (pulled while constructing Context "${m.name}")`:"";if(l)return d(new h("DEFINITION",`Context "${g}" cannot be pulled from onError because invocation Contexts have already been disposed.`,{subject:"context",name:g,reason:"context-after-disposal"}));let S=s.get(g);if(!S)return d(new h("DEFINITION",`No provider for Context "${g}". Add .provide(${g}(...)) to the app or an ancestor command.${w}`,{subject:"context",name:g,reason:"missing-context"}));if(!c&&!o.has(g))return d(new h("DEFINITION",`Context "${g}" cannot be constructed during invocation cleanup. Read it while setting up the Context whose cleanup needs it.`,{subject:"context",name:g,reason:"context-during-disposal"}));if(a===void 0&&Object.keys(S.ownedFlags).length>0)return d(new h("DEFINITION",`Context "${g}" owns flags and cannot be pulled before flag validation${w}. Pull it from an action or a postRun hook after a validated invocation.`,{subject:"context",name:g,reason:"flags-before-validation"}));let x=o.get(g);if(!x){let v=Promise.withResolvers();v.promise.catch(()=>{}),x={name:g,promise:v.promise,resolve:v.resolve,reject:v.reject,waitingOn:new Set,settled:!1},o.set(g,x);let E=x;(async()=>{try{let _=Object.fromEntries(Object.keys(S.ownedFlags).map((I)=>[I,a?.[I]])),C=await S.setup({...t,signal:r,flags:_,ctx:b(S.use,E),defer(I){if(E.settled)throw new h("DEFINITION",`Context "${g}" cannot register cleanup after its setup has finished.`,{subject:"context",name:g,reason:"context-defer-after-setup"});n.defer(I)}});ns(C,n,i),E.resolve(C)}catch(_){if(f(_))o.delete(g);E.reject(_)}finally{E.settled=!0}})()}if(m&&!x.settled){let v=u(x,m.name);if(v)return d(new h("DEFINITION",`Context dependency cycle: ${[m.name,...v].map((E)=>`"${E}"`).join(" -> ")}`,{subject:"context",name:m.name,reason:"context-cycle"}));return m.waitingOn.add(g),x.promise.finally(()=>m.waitingOn.delete(g))}return x.promise},b=(m,g)=>{let w={},S=(x)=>{let v=xt(x);if(Object.hasOwn(w,v))return;Object.defineProperty(w,v,{enumerable:!0,get:()=>p(g)(v)});for(let E of x.use)S(E)};for(let x of m)S(x);return Object.defineProperty(w,vt,{value:Object.freeze([...m])}),Object.freeze(w)};return{bag:(m)=>b(m,null),setValidatedFlags(m){a=m},async settle(){for(;;){let m=[...o.values()].filter((g)=>!g.settled);if(m.length===0){c=!1;return}await Promise.allSettled(m.map((g)=>g.promise))}}}}function K(e){for(let t of Object.keys(e))if(e[t]===void 0)delete e[t];return Object.freeze(e)}function ke(e){if(e instanceof URL)return e.href;if(Array.isArray(e))return Object.freeze(e.map(ke));return e}function ss(e){return K({name:e.name,type:e.type,description:e.description,required:e.required,variadic:e.variadic,choices:e.choices?Object.freeze([...e.choices]):void 0,default:ke(e.default)})}function os(e){return K({type:e.type,description:e.description,short:e.short,aliases:e.aliases?Object.freeze([...e.aliases]):void 0,required:e.required,multiple:e.multiple,negatable:gt(e),noNegate:"noNegate"in e?e.noNegate:void 0,choices:e.choices?Object.freeze([...e.choices]):void 0,default:ke(e.default),env:e.env?K({name:e.env.name,delimiter:e.env.delimiter}):void 0,delimiter:e.delimiter})}function A(e){let t={};for(let[r,s]of Object.entries(e.effectiveFlags))t[r]=os(s);let n={};for(let[r,s]of Object.entries(e.subCommands))n[r]=A(s);return Object.freeze({meta:K({name:e.meta.name,description:e.meta.description,version:e.meta.version,usage:e.meta.usage,sections:e.meta.sections?Object.freeze(e.meta.sections.map((r)=>Object.freeze({...r}))):void 0,aliases:e.meta.aliases?Object.freeze([...e.meta.aliases]):void 0,hidden:e.meta.hidden}),hasAction:e.run!==void 0,args:Object.freeze(e.args.map(ss)),flags:Object.freeze(t),subCommands:Object.freeze(n)})}function Ct(e,t,n){let r=A(e);return new h("COMMAND_NOT_FOUND",`Unknown command "${t}".`,{input:t,available:Object.entries(r.subCommands).flatMap(([s,o])=>$r(o)?[s]:[]),commandPath:[...n],parentCommand:r})}function is(e,t){for(let[n,r]of Object.entries(e)){let s=r.meta.aliases;if(!s)continue;if(s.includes(t))return{canonicalName:n,node:r}}return null}function ut(e,t){if(t==="--")return null;if(t.startsWith("--")){let r=t.indexOf("="),s=r===-1?t.slice(2):t.slice(2,r),o=e.get(s);if(o)return{consumesValue:o.def.type!=="boolean"&&r===-1};if(s.startsWith("no-")){if(e.get(s.slice(3))?.negatable)return{consumesValue:!1}}return null}let n=t.slice(1);if(n.length===0)return null;for(let r=0;r<n.length;r++){let s=e.get(n[r]);if(!s)return null;if(s.def.type!=="boolean")return{consumesValue:r===n.length-1}}return{consumesValue:!1}}function jt(e,t){let n=[e.meta.name],r=e,s=t,o=[],i=[],a=(c,l)=>{if(i.length===0)return;let u=c.flagSpellings;for(let{token:f,consumesValue:d}of i){let p=ut(u,f);if(p!==null&&p.consumesValue===d)continue;throw new h("PARSE",`Flag "${f}" cannot be used before subcommand "${l}" because "${l}" does not accept it.`,{flag:f,reason:"flag-not-forwardable"})}};while(s.length>0){let c=r.subCommands;if(Object.keys(c).length===0)break;let l=s[0];if(!l)break;if(l.startsWith("-")){let f=ut(r.flagSpellings,l);if(!f)break;o.push(l),i.push({token:l,consumesValue:f.consumesValue}),s=s.slice(1);let d=s[0];if(f.consumesValue&&d!==void 0)o.push(d),s=s.slice(1);continue}if(Object.hasOwn(c,l)&&c[l]){a(c[l],l),r=c[l],n.push(l),s=s.slice(1);continue}let u=is(c,l);if(u){a(u.node,l),r=u.node,n.push(u.canonicalName),s=s.slice(1);continue}if(r.run)break;throw Ct(r,l,n)}return{command:r,argv:[...o,...s],commandPath:n}}var ft=()=>{};function dt(e,t){let n=()=>{if(e.listenerCount("error")===0)e.once("error",ft)};try{n(),e.write(`${t}
7
- `,(r)=>{if(r)n()})}catch{}finally{e.removeListener("error",ft)}}var as={stdout:(e)=>dt(process.stdout,e),stderr:(e)=>dt(process.stderr,e)};var F=130;function ve(e){if(!(e instanceof Error))return!1;return e.name==="AbortError"}function _t(e){return kt(e)&&"error"in e&&"suppressed"in e&&e.name==="SuppressedError"}function kt(e){return typeof e==="object"&&e!==null}function Ce(e,t="Error"){let n=[],r=new Set,s=256,o=!1,i=(c)=>{if(o)return;if(s===0){o=!0,n.push("[additional failures omitted]");return}s--;let l;try{l=c()}catch{n.push("[unreadable failure]");return}a(l)},a=(c)=>{try{if(kt(c)){if(r.has(c))return;r.add(c)}let l=n.length;if(_t(c)){if(i(()=>c.error),i(()=>c.suppressed),n.length>l)return}else if(c instanceof AggregateError){let u=c.errors;if(Array.isArray(u)){for(let f=0;f<u.length;f++)if(i(()=>u[f]),o)break;if(n.length>l)return}}n.push(String(c instanceof Error&&c.message||c))}catch{n.push("[unreadable failure]")}};return i(()=>e),n.map((c)=>`${t}: ${c}`).join(`
8
- `)}function Nt(e){if(Object.freeze(e),Object.freeze(e.localFlags),Object.freeze(e.ownedFlags),Object.freeze(e.effectiveFlags),e.meta.sections)Object.freeze(e.meta.sections);Object.freeze(e.meta),Object.freeze(e.contexts),Object.freeze(e.extensions),Object.freeze(e.args);for(let t of Object.values(e.subCommands))Nt(t);Object.freeze(e.subCommands)}function cs(e){return typeof e==="symbol"}var mt=new WeakMap;function ls(e,t){let n=P(e),r=Object.freeze([...e.extensions]);for(let s of r)_r(n,s,t);for(let s of r)kr(n,s);return{rootNode:n,extensions:r}}function us(e,t){if(Tr(e,t),t.some((n)=>n.sections!==void 0)){let n=A(e);for(let r of t)Ar(e,r,n)}return Nt(e),e}function R(e,t){let n=mt.get(e);if(n)return n;let r=ls(e,t);return us(r.rootNode,r.extensions),mt.set(e,r),r}function fs(e,t){let n=jt(e,t);return{argv:t,route:n,parsed:Zr(n.command,n.argv)}}function Ne(e,t){let n=jt(e,t);if(n.argv.length>0)throw Ct(n.command,n.argv[0],n.commandPath);return n}function ds(e,t,n){let r=Ne(e,t);return{argv:t,route:r,parsed:Qr(r.command,n)}}async function At(e,t,n,r,s,o){let E=[];try{let{rootNode:i,extensions:a}=t;let{argv:c,route:l,parsed:u}="argv"in e?fs(i,e.argv):ds(i,e.path,e.input);let f=l.command;const d=Qe(E,new AsyncDisposableStack,1);let p=f.contexts.map(({instance:O})=>O);let b=rs(p,n,d,r);let m=A(i);let g=m;for(let O of l.commandPath.slice(1))g=g.subCommands[O];let w=Object.freeze({argv:[...c],rootCommand:m,command:g,commandPath:Object.freeze([...l.commandPath]),args:u.args,flags:u.flags,rawArgs:u.rawArgs,signal:r,ctx:b.bag(a.flatMap((O)=>O.use)),handled:Se,stdout:n.stdout,stderr:n.stderr});s?.(w);let S=async()=>{es(f,u);let O=await Rr(f,u);if(b.setValidatedFlags(O.flags),!f.run)return;let j={args:O.args,flags:O.flags,ctx:b.bag(p),rawArgs:u.rawArgs,signal:r,command:w.command,rootCommand:m,stdout:n.stdout,stderr:n.stderr};return await f.run(j)};let x;let v={status:"completed"};try{try{for(let j of a)if(await j.hooks?.preRun?.(w)===Se()){v={status:"handled",by:j.id};break}if(v.status!=="handled")x=await S()}catch(j){let U=await o?.(j,w);v={status:"failed",error:j,...U===void 0?{}:{by:U}}}Object.freeze(v);let O;for(let j of a.toReversed())try{await j.hooks?.postRun?.(w,v)}catch(U){if(v.status!=="failed")O??={error:U}}if(v.status==="failed")throw v.error;if(O)throw O.error}finally{await b.settle()}return v.status==="handled"?{status:"handled",by:v.by}:{status:"completed",result:x}}catch(_){var C=_,I=1}finally{var me=et(E,C,I);me&&await me}}async function xe(e,t,n,r,s,o,i=!1){let a=o;if(!a){let c=function(f){return Promise.reject(new h("DEFINITION",`Context "${String(f)}" cannot be pulled from onError because invocation Contexts have already been disposed.`,{subject:"context",name:String(f),reason:"context-after-disposal"}))},l=new Proxy({},{get:(f,d)=>d==="then"||cs(d)?void 0:c(d)}),u=A(n.rootNode);a=Object.freeze({argv:[...t],rootCommand:u,command:u,commandPath:Object.freeze([n.rootNode.meta.name]),args:Object.freeze({}),flags:Object.freeze({}),rawArgs:[],signal:s,handled:Se,stdout:r.stdout,stderr:r.stderr,ctx:l})}try{for(let c of n.extensions)if(await c.hooks?.onError?.(e,a))return c.id}catch{}if(!i)r.stderr(Ce(e))}function ms(e){return e!==void 0&&Object.keys(e).length>0}async function Tt(e,t,n,r){let s=[],o=[];try{let{signal:i=new AbortController().signal,...a}=n??{},c={stdout(l){s.push(l),a.stdout?.(l)},stderr(l){o.push(l),a.stderr?.(l)}};return{...await we(c,async()=>await At(t,R(e,r),c,i)),stdout:s.join(`
8
+ `)}`,{issues:n});return{args:Object.fromEntries(r),flags:Object.fromEntries(s)}}async function so(e,t){let n=[],r=await Ge(e,t,[],n);if(r.ok)return r.value;throw new b("OUTPUT",`Invalid command result:
9
+ ${n.map((s)=>s.path===""?` - ${s.message}`:` - ${s.path}: ${s.message}`).join(`
10
+ `)}`,{issues:n})}function Ie(e,t){let n=e["~standard"].jsonSchema;if(typeof n?.[t]!=="function")return;try{return JSON.parse(JSON.stringify(n[t]({target:"draft-2020-12"})))}catch{return}}function oo(e,t,n){if(t==="number"){let r=pn(e);if(r===void 0)throw new b("PARSE",`Expected a number for ${n}.`);return r}if(t==="boolean")return he(e);if(t==="url")return Rn(e,n);if(t==="path")return He(e,n);if(t==="json")return no(e,n);return e}function io(e,t,n){if(!t.includes(e))throw new b("PARSE",`Invalid value for ${n}. Expected one of: ${t.join(", ")}`)}function Je(e,t,n,r){let s=r===void 0?n:`${n} element [${r}]`,o;try{o=e(t)}catch(i){throw new b("PARSE",`Failed to parse ${s}: ${i instanceof Error?i.message:String(i)}`).withCause(i)}if(process.getBuiltinModule("node:util/types").isPromise(o))throw o.catch(()=>{}),new b("PARSE",`Failed to parse ${s}: parse must be synchronous`);return o}function qe(e,t){let{default:n,parse:r}=e;if(n===void 0)return;if(r){if(Array.isArray(n))return n.map((s,o)=>Je(r,String(s),t,o));return Je(r,String(n),t)}if(e.type==="path"){if(Array.isArray(n))return n.map((s)=>He(String(s),t));return He(String(n),t)}return"multiple"in e&&e.multiple&&Array.isArray(n)?[...n]:n}function ve(e,t,n,r){if(e.schema)return t;if(e.choices)io(t,e.choices,n);if(e.parse)return Je(e.parse,t,n,r);return oo(t,e.type,n)}function Ye(e,t,n){if(!t)return e();try{return e()}catch(r){if(!(r instanceof b))throw r;t(r,n);return}}function Mn(e,t,n){if(n.kind==="invalid")throw n.error;if(n.kind==="boolean")return n.value;let r=n.env===void 0?`--${e}`:`--${e} (from $${n.env})`;return Array.isArray(n.value)?n.value.map((s,o)=>ve(t,s,r,o)):ve(t,n.value,r)}function Ln(e,t){if(t===void 0)return[...e];return e.flatMap((n)=>n.split(t)).filter((n)=>n!=="")}function ao(e,t,n){let r=t.multiple?Ln([n],t.env?.delimiter):[n];if(t.multiple&&r.length===0)return;if(t.type!=="boolean")return{kind:"string",value:t.multiple?r:n,env:t.env?.name};let s=r.map(he);if("noNegate"in t&&t.noNegate&&s.includes(!1))return{kind:"invalid",error:new b("PARSE",`Flag "--${e}" does not support negation (from $${t.env?.name})`)};return{kind:"boolean",value:t.multiple?s:he(n)}}function zn(e,t,n){let r={};for(let[s,o]of Object.entries(e)){let i=Object.hasOwn(t,s)?t[s]:void 0;if(i!==void 0){if(o.delimiter!==void 0&&i.kind==="string"&&Array.isArray(i.value)){let c=Ln(i.value,o.delimiter);r[s]=c.length===0?void 0:{kind:"string",value:c}}else r[s]=i;continue}if(o.env===void 0||!Object.hasOwn(n,o.env.name))continue;let a=n[o.env.name];if(a!==void 0)r[s]=ao(s,o,a)}return r}function co(e,t,n,r,s){let o={};for(let[i,a]of Object.entries(e)){let c=Object.hasOwn(t,i)?t[i]:void 0;if(!(c===void 0||a.multiple&&Array.isArray(c)&&c.length===0)){s?.add(i),o[i]=Ye(()=>n(i,a,c),r,`--${i}`);continue}o[i]=qe(a,`--${i}`)}return o}function lo(e,t){for(let[n,r]of Object.entries(e))if(r.required===!0&&r.default===void 0){if(t[n]===void 0)throw new b("VALIDATION",`Missing required flag "--${n}"`)}}function uo(e,t){for(let n of e){if(n.required!==!0||n.default!==void 0)continue;let r=t[n.name],s=n.variadic?!Array.isArray(r)||r.length===0:r===void 0,o=n.afterDoubleDash?' (pass it after "--")':"";if(s)throw new b("VALIDATION",`Missing required argument "<${n.name}>"${o}`)}}function fo(e,t,n,r,s=[]){let o={},i=0,a=0;for(let c of e){let{name:l}=c,d=`<${l}>`;Object.defineProperty(o,l,{value:void 0,writable:!0,enumerable:!0,configurable:!0});let g=c.afterDoubleDash?s:t,p=c.afterDoubleDash?0:i,m=p;if(c.variadic){let w=g.slice(p);o[l]=w.length===0&&c.default!==void 0?[qe(c,d)]:Ye(()=>w.map((O,v)=>n(c,O,d,v)),r,d),m=g.length}else if(p<g.length)o[l]=Ye(()=>n(c,g[p],d),r,d),m++;else o[l]=qe(c,d);if(c.afterDoubleDash)a=m;else i=m}return{args:o,consumed:i,consumedAfterDoubleDash:a}}function wn(e,t){return new b("PARSE",`Unknown flag "${e}"`,{flag:t,reason:"unknown-flag"})}function vn(e){return new b("PARSE",`Flag "--${e}" does not take a value`,{flag:e,reason:"unexpected-value"})}function Bn(e,t){if(t.length<2||!t.startsWith("-")||t==="--")return;if(t[1]!=="-"){let a=[];for(let c=1;c<t.length;){let l=String.fromCodePoint(t.codePointAt(c));c+=l.length;let d=e.get(l);if(!d)return wn(l==="-"?t:`-${l}`,l);if(d.def.type==="boolean"){a.push({spelling:d,value:!0});continue}if(c===t.length)return{occurrences:a,pending:d};a.push({spelling:d,value:t.slice(c)});break}return{occurrences:a}}let n=t.indexOf("=",3),r=n===-1?t.slice(2):t.slice(2,n),s=n===-1?void 0:t.slice(n+1),o=e.get(r);if(o&&o.kind!=="short"){if(o.def.type!=="boolean")return s===void 0?{occurrences:[],pending:o}:{occurrences:[{spelling:o,value:s}]};if(s!==void 0)return vn(o.canonicalName);return{occurrences:[{spelling:o,value:!0}]}}let i=r.startsWith("no-")?e.get(r.slice(3)):void 0;if(i&&i.kind!=="short"&&i.def.type==="boolean"){if(!i.negatable)return new b("PARSE",`Flag "--${i.canonicalName}" does not support negation ("--${r}")`);if(s!==void 0)return vn(i.canonicalName);return{occurrences:[{spelling:i,value:!1}]}}return wn(`--${r}`,r)}function yn(e,{canonicalName:t,def:n},r){let s=e[t];if(typeof r==="boolean")if(n.multiple&&s?.kind==="boolean"&&Array.isArray(s.value))s.value.push(r);else e[t]={kind:"boolean",value:n.multiple?[r]:r};else if(n.multiple&&s?.kind==="string"&&Array.isArray(s.value))s.value.push(r);else e[t]={kind:"string",value:n.multiple?[r]:r}}function mo(e,t){let n=[],r={};for(let s=0;s<t.length;s++){let o=t[s];if(o==="--"){let l=n.length;return n.push(...t.slice(s+1)),{positionals:n,separatorIndex:l,flagValues:r}}let i=Bn(e.flagSpellings,o);if(i===void 0){n.push(o);continue}if(i instanceof b)throw i;for(let{spelling:l,value:d}of i.occurrences)yn(r,l,d);if(!i.pending)continue;let a=i.pending.canonicalName,c=t[s+1];if(c===void 0||c.length>1&&c.startsWith("-"))throw new b("PARSE",`Missing value for flag "--${a}"${c===void 0?"":`; to pass a value starting with "-", write --${a}=<value>`}`,{flag:a,reason:"missing-value"});yn(r,i.pending,c),s++}return{positionals:n,separatorIndex:n.length,flagValues:r}}function ut(e){return Array.isArray(e)}function ho(e,t,n){let r=e.schema?e.type==="boolean"?"boolean":"string":e.type,s;if(r==="url")s=t instanceof URL;else if(r==="json"){let o=[t],i=new Set;s=!0;while(o.length>0){let a=o.pop();if(a instanceof URL){s=!1;break}if(ut(a)&&!i.has(a))i.add(a),o.push(...a)}}else s=typeof t===(r==="path"?"string":r);if(!s)throw new b("PARSE",`Expected ${po[r]} for ${n}.`);if(t===!1&&"noNegate"in e&&e.noNegate)throw new b("PARSE",`Flag "${n}" does not support negation`)}function Ke(e,t,n,r){if(ho(e,t,n),e.type!=="string"&&e.type!=="path")return t;return ve(e,String(t),n,r)}function go(e,t,n){let r=`--${e}`;if(t.multiple){if(!ut(n))throw new b("PARSE",`Expected an occurrence array for ${r}`);return n.map((s,o)=>Ke(t,s,r,o))}return Ke(t,n,r)}function ye(e,t){let n=[];for(let[r,s]of e){let o=t(r)??(s.default===void 0?void 0:"default");if(o)n.push([r,o])}return Object.freeze(Object.fromEntries(n))}function Un(e,t,n,r,s,o,i){let a=new Set,c=co(e.effectiveFlags,n,s,o,a);return{...fo(e.args,t,r,o,i),flags:c,present:a}}function bo(e,t,n=process.env){let r=mo(e,t),{separatorIndex:s,flagValues:o}=r,i=e.args.at(-1),a=i?.afterDoubleDash===!0,c=a?r.positionals.slice(0,s):r.positionals,l=a?r.positionals.slice(s):[],d=new Map,g=zn(e.effectiveFlags,o,n),{args:p,flags:m,consumed:w,consumedAfterDoubleDash:O,present:v}=Un(e,c,g,ve,Mn,(y,S)=>d.set(S,y),l),u=a?l.slice(O):c.slice(Math.max(w,s)),f=new Set(e.args.filter(({afterDoubleDash:y})=>!y).slice(0,c.length).map(({name:y})=>y));if(a&&l.length>0)f.add(i.name);let h=Object.freeze({args:ye(e.args.map((y)=>[y.name,y]),(y)=>f.has(y)?"argv":void 0),flags:ye(Object.entries(e.effectiveFlags),(y)=>{if(Object.hasOwn(o,y))return"argv";return Object.hasOwn(g,y)&&g[y]!==void 0?"env":void 0}),raw:u.length>0?"argv":void 0});return{args:p,flags:m,excessArgs:c.slice(w,s),rawArgs:u,flagOrder:[...Object.keys(o).filter((y)=>v.has(y)),...[...v].filter((y)=>!Object.hasOwn(o,y)).sort()],...f.size>0&&{suppliedArgs:f},sources:h,...d.size>0&&{valueErrors:d}}}function Wn(e,t){return new b("PARSE",`Argument <${e}> cannot be provided after omitted argument <${t}>`,{argument:e,reason:"positional-gap"})}function Vn(e,t,n={}){let{args:r,flags:s,raw:o}=t,i=[],a=[],c=new Set,l;for(let f of e.args){let h=r&&Object.hasOwn(r,f.name)?r[f.name]:void 0;if(h===void 0){l=f.name;continue}let y=f.afterDoubleDash?a:i;if(l!==void 0&&!f.afterDoubleDash)throw Wn(f.name,l);if(f.variadic){if(!ut(h))throw new b("PARSE",`Expected an occurrence array for <${f.name}>`);if(y.push(...h),h.length>0)c.add(f.name)}else y.push(h),c.add(f.name)}for(let f of Object.keys(r??{}))if(!e.args.some((h)=>h.name===f)&&r?.[f]!==void 0)throw new b("PARSE",`Unknown argument "${f}"`,{argument:f,reason:"unknown-argument"});for(let f of Object.keys(s??{}))if(!Object.hasOwn(e.effectiveFlags,f)&&s?.[f]!==void 0)throw new b("PARSE",`Unknown flag "--${f}"`,{flag:f,reason:"unknown-flag"});let d={},g={};for(let[f,h]of Object.entries(e.effectiveFlags)){let y=s&&Object.hasOwn(s,f)?s[f]:void 0;if(y===void 0)g[f]=h;else d[f]=y}let p=new Set;for(let[f,h]of Object.entries(zn(g,{},n))){if(h===void 0)continue;d[f]=h,p.add(f)}let m=new Map,{args:w,flags:O,present:v}=Un(e,i,d,Ke,(f,h,y)=>p.has(f)?Mn(f,h,y):go(f,h,y),(f,h)=>{if(!h.startsWith("--")||!p.has(h.slice(2)))throw f;m.set(h,f)},a),u=[...Object.keys(s??{}).filter((f)=>v.has(f)&&!p.has(f)),...[...p].filter((f)=>v.has(f)).sort()];return{args:w,flags:O,excessArgs:[],rawArgs:[...o??[]],flagOrder:u,...c.size>0&&{suppliedArgs:c},sources:Object.freeze({args:ye(e.args.map((f)=>[f.name,f]),(f)=>c.has(f)?"run":void 0),flags:ye(Object.entries(e.effectiveFlags),(f)=>v.has(f)?p.has(f)?"env":"run":void 0),raw:o===void 0||o.length===0?void 0:"run"}),...m.size>0&&{valueErrors:m}}}function wo(e,t,n){let{sources:r}=t,s=(w,O)=>Object.fromEntries(Object.entries(w??{}).filter(([v,u])=>u!==void 0&&O[v]!=="argv")),o=s(n.args,r.args),i=s(n.flags,r.flags),a=r.raw==="argv"?void 0:n.raw,c;for(let{name:w,afterDoubleDash:O}of e.args)if(!t.suppliedArgs?.has(w)&&!Object.hasOwn(o,w))c=w;else if(c!==void 0&&!O)throw Wn(w,c);let l=Vn({...e,args:e.args.filter(({name:w})=>Object.hasOwn(o,w)),effectiveFlags:Object.fromEntries(Object.entries(e.effectiveFlags).filter(([w])=>Object.hasOwn(i,w)))},{args:o,flags:i,raw:a}),d=(w,O)=>Object.fromEntries(Object.keys(O).map((v)=>[v,w[v]])),g=(w,O,v)=>Object.freeze(Object.fromEntries([...Object.entries(w).filter(([u])=>!Object.hasOwn(O,u)),...Object.entries(v).map(([u,f])=>[u,f==="run"?"bound":f])])),p=new Set(Object.keys(i).map((w)=>`--${w}`)),m=new Map([...t.valueErrors??[]].filter(([w])=>!p.has(w)));return{...t,args:{...t.args,...d(l.args,o)},flags:{...t.flags,...d(l.flags,i)},rawArgs:a===void 0?t.rawArgs:l.rawArgs,sources:Object.freeze({args:g(r.args,o,l.sources.args),flags:g(r.flags,i,l.sources.flags),raw:a===void 0?r.raw:l.sources.raw&&"bound"}),valueErrors:m}}function vo(e,t){let[n]=t.valueErrors?.values()??[];if(n)throw n;if(t.excessArgs.length>0)throw new b("VALIDATION",`Unexpected positional argument${t.excessArgs.length===1?"":"s"}: ${t.excessArgs.map((r)=>JSON.stringify(r)).join(", ")}`);uo(e.args,t.args),lo(e.effectiveFlags,t.flags)}function yo(e){if(e===null||typeof e!=="object"&&typeof e!=="function")return!1;let t=e;return typeof t[Symbol.asyncDispose]==="function"||typeof t[Symbol.dispose]==="function"}function Oo(e,t,n){if(!yo(e)||n.has(e))return;n.add(e),t.use(e)}function xo(e,t,n,r,s){let o=new Map(e.map((v)=>[v.name,v])),i=new Map,a=new WeakSet,c,l=!0,d=!1;r.defer(()=>{d=!0});let g=(v,u,f=new Set)=>{if(v.name===u)return[v.name];if(f.has(v.name))return;f.add(v.name);for(let h of v.waitingOn){let y=i.get(h);if(!y)continue;let S=g(y,u,f);if(S)return[v.name,...S]}},p=(v)=>{try{let u=new Set;for(let f=v;f!=null&&!u.has(f);f=f.cause)if(u.add(f),f instanceof b&&f.code==="DEFINITION"&&f.details?.reason==="flags-before-validation")return!0;return!1}catch{return!1}};function m(v){let u=Promise.reject(v);return u.catch(()=>{}),u}let w=(v)=>(u)=>{let f=v?` (pulled while constructing Context "${v.name}")`:"";if(d)return m(new b("DEFINITION",`Context "${u}" cannot be pulled from onError because invocation Contexts have already been disposed.`,{subject:"context",name:u,reason:"context-after-disposal"}));let h=o.get(u);if(!h)return m(new b("DEFINITION",`No provider for Context "${u}". Add .provide(${u}(...)) to the app or an ancestor command.${f}`,{subject:"context",name:u,reason:"missing-context"}));if(!l&&!i.has(u))return m(new b("DEFINITION",`Context "${u}" cannot be constructed during invocation cleanup. Read it while setting up the Context whose cleanup needs it.`,{subject:"context",name:u,reason:"context-during-disposal"}));let y=Object.keys(h.ownedFlags).length>0;if(y&&!t.has(u))return m(new b("DEFINITION",`Context "${u}" owns flags that this command does not parse${f}. Declare it with .use(${u}) on the command that reads it.`,{subject:"context",name:u,reason:"context-flags-not-parsed"}));if(c===void 0&&y)return m(new b("DEFINITION",`Context "${u}" owns flags and cannot be pulled before flag validation${f}. Pull it from an action or a postRun hook after a validated invocation.`,{subject:"context",name:u,reason:"flags-before-validation"}));let S=i.get(u);if(!S){let I=Promise.withResolvers();I.promise.catch(()=>{}),S={name:u,promise:I.promise,resolve:I.resolve,reject:I.reject,waitingOn:new Set,settled:!1},i.set(u,S);let E=S;(async()=>{try{let x=Object.fromEntries(Object.keys(h.ownedFlags).map((C)=>[C,c?.[C]])),j=await h.setup({...n,signal:s,flags:x,ctx:O(h.use,E),defer(C){if(E.settled)throw new b("DEFINITION",`Context "${u}" cannot register cleanup after its setup has finished.`,{subject:"context",name:u,reason:"context-defer-after-setup"});r.defer(C)}});Oo(j,r,a),E.resolve(j)}catch(x){if(p(x))i.delete(u);E.reject(x)}finally{E.settled=!0}})()}if(v&&!S.settled){let I=g(S,v.name);if(I)return m(new b("DEFINITION",`Context dependency cycle: ${[v.name,...I].map((E)=>`"${E}"`).join(" -> ")}`,{subject:"context",name:v.name,reason:"context-cycle"}));return v.waitingOn.add(u),S.promise.finally(()=>v.waitingOn.delete(u))}return S.promise},O=(v,u)=>{let f={},h=(y)=>{let S=Pn(y);if(Object.hasOwn(f,S))return;Object.defineProperty(f,S,{enumerable:!0,get:()=>w(u)(S)});for(let I of y.use)h(I)};for(let y of v)h(y);return Object.defineProperty(f,Dn,{value:Object.freeze([...v])}),Object.freeze(f)};return{bag:(v)=>O(v,null),setValidatedFlags(v){c=v},async settle(){for(;;){let v=[...i.values()].filter((u)=>!u.settled);if(v.length===0){l=!1;return}await Promise.allSettled(v.map((u)=>u.promise))}}}}function Hn(e){return{meta:{name:e},localFlags:{},ownedFlags:{},flagContexts:new Map,effectiveFlags:{},flagSpellings:new Map,args:[],subCommands:{},contexts:[],providedContexts:[],demands:[],inheritedDemands:[],usedExtensions:[],extensions:[],run:void 0}}function R(e,t,n,r){n=it(t,n);let s=we(t,n),o=Object.hasOwn(e.effectiveFlags,t)?t:s.map((a)=>e.flagSpellings.get(a)?.canonicalName).find((a)=>a!==void 0);if(o!==void 0)throw new b("DEFINITION",`Flag "${t}" collides with existing flag "${o}" on command "${e.meta.name}"`,{subject:"flag",name:t,reason:"flag-collision"});(r==="local"?e.localFlags:e.ownedFlags)[t]=n,e.effectiveFlags[t]=n;let i={canonicalName:t,def:n,negatable:_n(n)};if(e.flagSpellings.set(t,{...i,kind:"canonical"}),n.short!==void 0)e.flagSpellings.set(n.short,{...i,kind:"short"});for(let a of n.aliases??[])e.flagSpellings.set(a,{...i,kind:"alias"})}function ft(e,t){let n;for(let{contextName:r,ownedFlags:s}of dt(t)){let o=(n??e.flagContexts).get(r)??[],i=Object.keys(s).filter((a)=>!o.includes(a));if(i.length===0)continue;for(let a of i)R(e,a,s[a],"owned");(n??=new Map(e.flagContexts)).set(r,[...o,...i])}if(n)e.flagContexts=n}function So(e,t){if(t.length===0)return;let n=new Map;for(let{instance:i}of e.contexts)n.set(i.name,i);let r=dt(t),s=new Set(r.map((i)=>i.contextName)),o=[];for(let i of r){let a=i.contextName;for(let[l,d]of Object.entries(i.ownedFlags)){if(Jn(e.ownedFlags[l],d))continue;throw new b("DEFINITION",`Flag "${l}" that command "${e.meta.name}" parses for Context "${a}" differs from the definition of the Context "${a}" it declares with .use(). Same-name Contexts on one command must own the same flags: change the declared Context, or use the same factory.`,{subject:"context",name:a,reason:"context-flags-not-parsed"})}let c=n.get(a);if(!c||c.factory===i)continue;if(!Eo(i.ownedFlags,c.ownedFlags))throw new b("DEFINITION",`Context "${a}" provided to command "${e.meta.name}" does not own the same flags as the Context "${a}" it declares with .use(). A provider of another factory must own exactly the declared flags: change the declared Context, or provide the same factory (for example its .of()).`,{subject:"context",name:a,reason:"context-flags-not-parsed"});o.push(...c.use)}for(let{contextName:i}of o){if(s.has(i))continue;s.add(i);let a=n.get(i);if(!a)continue;let c=e.flagContexts.get(i)??[],l=Object.keys(a.ownedFlags).find((d)=>!c.includes(d));if(l!==void 0)throw new b("DEFINITION",`Context "${i}", used by a replacement provider on command "${e.meta.name}", owns flag "${l}", which the command does not parse. Declare it with .use(${i}) too, or provide the declared Context's own factory.`,{subject:"context",name:i,reason:"context-flags-not-parsed"});o.push(...a.use)}}function ee(e){return e.map((t)=>("contextName"in t)?t:t.factory)}function dt(e){let t=new Set,n=(r)=>{for(let s of r){if(t.has(s))continue;t.add(s),n(s.use)}};return n(e),[...t]}function Gn(e){return new Set(dt(e).map((t)=>t.contextName))}function Eo(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every((r)=>Object.hasOwn(t,r)&&Jn(e[r],t[r]))}function Jn(e,t){let{schema:n,...r}=e,{schema:s,...o}=t;return n===s&&Xe(r,o)}function Xe(e,t){if(e===t)return!0;if(Array.isArray(e))return Array.isArray(t)&&e.length===t.length&&e.every((r,s)=>Xe(r,t[s]));if(!On(e)||!On(t))return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every((r)=>Object.hasOwn(t,r)&&Xe(e[r],t[r]))}function On(e){if(typeof e!=="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function K(e){return{localFlags:{...e.localFlags},ownedFlags:{...e.ownedFlags},effectiveFlags:{...e.effectiveFlags},flagSpellings:new Map(e.flagSpellings)}}function te(e){let t=e.subCommands,n=ht.get(t),r=[...gt(t)].map(([s,o])=>({name:s,meta:o,resolve:()=>t[s],definition:n?.get(s)}));return r.push(...qn(e)),r}function qn(e){let t=[];for(let r=e.addedChildren;r;r=r.next)t.push(r);let n=[];for(let r=t.length-1;r>=0;r--)n.push(t[r]);return n}function Yn(e,t){let n={},r=new Map,s=new Map,o=new Map;for(let i of e){if(i.definition)o.set(i.name,i.definition);Object.defineProperty(n,i.name,{enumerable:!0,get:()=>{let a=s.get(i.name);if(!a)s.set(i.name,a=t(i));return a}}),r.set(i.name,i.meta)}return mt.set(n,r),pt.set(n,s),ht.set(n,o),Object.freeze(n)}function Kn(e,t){let n=[{node:e,path:[e.meta.name]}];while(n.length>0){for(let{node:r,path:s}of n)for(let[o,i]of ht.get(r.subCommands)??[])if(i===t)return Object.freeze([...s,o]);n=n.flatMap(({node:r,path:s})=>te(r).map((o)=>({node:o.resolve(),path:[...s,o.name]})))}}function gt(e){return mt.get(e)??Object.entries(e).map(([t,n])=>[t,n.meta])}function Co(e,t){let n=pt.get(e);return n?n.get(t):e[t]}function Io(e){if(e.addedChildren)return;let t=pt.get(e.subCommands);if(!t)return Object.values(e.subCommands);return t.size===mt.get(e.subCommands).size?[...t.values()]:void 0}function bt(e){return{...e,meta:{...e.meta},...K(e),args:[...e.args],subCommands:Yn(te(e),(t)=>bt(t.resolve())),addedChildren:void 0,contexts:e.contexts.map((t)=>({...t})),providedContexts:[...e.providedContexts],demands:[...e.demands],extensions:[...e.extensions]}}function Oe(e){let t={};for(let n of Object.keys(e))if(e[n]!==void 0)t[n]=e[n];return Object.freeze(t)}function wt(e){if(e instanceof URL)return e.href;if(Array.isArray(e))return Object.freeze(e.map(wt));return e}function Xn(e){return e.default===void 0?e.required:void 0}function jo(e){return Oe({name:e.name,type:e.type,description:e.description,required:Xn(e),variadic:e.variadic,afterDoubleDash:e.afterDoubleDash,choices:e.choices?Object.freeze([...e.choices]):void 0,default:wt(e.default),inputSchema:e.schema&&Ie(e.schema,"input")})}function $o(e,t){return Oe({type:e.type,description:e.description,short:e.short,aliases:e.aliases?Object.freeze([...e.aliases]):void 0,required:Xn(e),multiple:e.multiple,negatable:_n(e),noNegate:"noNegate"in e?e.noNegate:void 0,choices:e.choices?Object.freeze([...e.choices]):void 0,default:wt(e.default),env:e.env?Oe({name:e.env.name,delimiter:e.env.delimiter}):void 0,delimiter:e.delimiter,inputSchema:e.schema&&Ie(e.schema,"input"),extension:t})}function vt(e){let t={};for(let[n,r]of Object.entries(e.subCommands))t[n]=vt(r);return tt(e,et(e),Object.freeze(t))}function Ze(e){if(e instanceof URL)return!0;if(Array.isArray(e))return!Object.isFrozen(e)||e.some(Ze);return!1}function No(e,t){Qe.set(e,[...Qe.get(e)??[],t])}function Zn(e){let t=xn.get(e);if(t!==void 0)return t;let n=!e.args.some((r)=>Ze(r.default))&&!Object.values(e.effectiveFlags).some((r)=>Ze(r.default));if(n){let r=Io(e);if(!r)return;for(let s of r){let o=Zn(s);if(o===void 0)return;n&&=o}}return xn.set(e,n),n}function yt(e,t=!1){let n=new Map,r,s=(c)=>{let l=Sn.get(c);if(l)return l;let d={};for(let[p,m]of Object.entries(c.subCommands))d[p]=s(m);let g=tt(c,et(c),Object.freeze(d));return Sn.set(c,g),g},o=(c)=>{if(r??=!t&&Zn(e)===!0,r)return s(c);let l=n.get(c);if(l)return l;let d=i(c);return n.set(c,d),d},i=(c)=>{let l={};for(let[d,g]of gt(c.subCommands)){let p;Object.defineProperty(l,d,{enumerable:!0,get:()=>p??=a(c,d,g)})}return tt(c,et(c),Object.freeze(l),t)},a=(c,l,d)=>{let g=Co(c.subCommands,l);if(g)return o(g);let p,m=()=>{if(p)return p;let O=c.subCommands[l];if(p=n.get(O)??i(O),!n.has(O))n.set(O,w);return p},w=Object.freeze(Object.defineProperties({},{meta:{enumerable:!0,value:Object.freeze(Object.defineProperty({...Qn(d,void 0)},"sections",{enumerable:!0,get:()=>m().meta.sections}))},hasAction:{enumerable:!0,get:()=>m().hasAction},args:{enumerable:!0,get:()=>m().args},flags:{enumerable:!0,get:()=>m().flags},outputSchema:{enumerable:!0,get:()=>m().outputSchema},output:{enumerable:!0,get:()=>m().output},extension:{enumerable:!0,get:()=>m().extension},subCommands:{enumerable:!0,get:()=>m().subCommands}}));return w};return o}function et(e){let t={};for(let[n,r]of Object.entries(e.effectiveFlags))t[n]=$o(r,e.extensionFlags?.get(n));return t}function Qn(e,t){return Oe({name:e.name,description:e.description,version:e.version,usage:e.usage,sections:t?Object.freeze(t.map((n)=>Object.freeze({...n}))):void 0,aliases:e.aliases?Object.freeze([...e.aliases]):void 0,hidden:e.hidden})}function tt(e,t,n,r=!1){let s=r?void 0:Qe.get(e),o=s?[...e.meta.sections??[],...s]:e.meta.sections,i=e.outputSchema&&Ie(e.outputSchema,"output");return Object.freeze({meta:Qn(e.meta,o),hasAction:e.run!==void 0,args:Object.freeze(e.args.map(jo)),flags:Object.freeze(t),...i?{outputSchema:i}:{},...e.outputSchema?{output:!0}:{},...e.extension?{extension:e.extension}:{},subCommands:n})}function _o(e,t,n){let r=e;for(let s of t){let o=Object.hasOwn(r.subCommands,s)?r.subCommands[s]:void 0;if(!o)throw new b("DEFINITION",`Extension "${n.id}" section target "${t.join(" ")}" is not a canonical command path`,{subject:"extension",name:n.id,reason:"invalid-section-path"});r=o}return r}function Ao(e,t){if(!t.some((r)=>r.sections!==void 0))return;let n=yt(e,!0)(e);for(let r of t){if(!r.sections)continue;let s={subject:"extension",name:r.id};for(let o of r.sections(n)){let i=Tn(o,s);No(_o(e,o.command,r),i)}}}function To(e,t,n){let r=[...new Map(n.map((o)=>[o.name,o])).values()];if(!r.some((o)=>o.sections.length>0))return;let s=new Set((e.meta.sections??[]).map(({title:o})=>o));for(let o of r){for(let{title:i}of o.sections)if(s.has(i))throw new b("DEFINITION",`Context "${o.name}" section "${i}" duplicates a section on command "${t}"`,{subject:"context",name:o.name,reason:"duplicate-section"});for(let{title:i}of o.sections)s.add(i)}e.meta.sections=[...e.meta.sections??[],...r.flatMap((o)=>o.sections)]}function ko(e,t){return t?e.contexts.map(({instance:n})=>n):e.providedContexts}function Fo(e,t){if(t.length===0)return e;let n=[],r=0;for(let{instance:i,position:a,extension:c}of t){while(r<a&&r<e.contexts.length)n.push({...e.contexts[r++]});n.push({instance:i,extension:c})}for(let i of e.contexts.slice(r))n.push({...i});let s=new Map;for(let[i,a]of[...t.map(({instance:c})=>[c.name,Object.keys(c.ownedFlags)]),...e.flagContexts])if(a.length>0)s.set(i,[...s.get(i)??[],...a]);let o={...e,localFlags:{},ownedFlags:{},flagContexts:s,effectiveFlags:{},flagSpellings:new Map,contexts:n};for(let{instance:i}of t)for(let[a,c]of Object.entries(i.ownedFlags))R(o,a,c,"owned");for(let[i,a]of Object.entries(e.effectiveFlags))R(o,i,a,Object.hasOwn(e.localFlags,i)?"local":"owned");return o}function er(e,t,n){let r=yt(e)(e);return new b("COMMAND_NOT_FOUND",`Unknown command "${t}".`,{input:t,available:Object.entries(r.subCommands).flatMap(([s,o])=>at(o)?[s]:[]),commandPath:[...n],parentCommand:r})}function Do(e,t){for(let[n,r]of gt(e))if(r.aliases?.includes(t))return{canonicalName:n,node:e[n]};return null}function En(e,t){let n=Bn(e,t);if(n===void 0||n instanceof b)return null;let r=n.occurrences.find(({value:o})=>typeof o==="string")?.value,s=typeof r==="string"?t.slice(0,t.length-r.length-(t.startsWith("--")?1:0)):t;return{consumesValue:n.pending!==void 0,spelling:s}}function Ot(e,t){let n=[e.meta.name],r=e,s=t,o=[],i=[],a=(c,l)=>{if(i.length===0)return;let d=c.flagSpellings;for(let{token:g,spelling:p,consumesValue:m}of i){let w=En(d,g);if(w!==null&&w.consumesValue===m)continue;throw new b("PARSE",`Flag "${p}" cannot be used before subcommand "${l}" because "${l}" does not accept it.`,{flag:p,reason:"flag-not-forwardable"})}};while(s.length>0){let c=r.subCommands;if(Object.keys(c).length===0)break;let l=s[0];if(!l)break;if(l.startsWith("-")){let g=En(r.flagSpellings,l);if(!g)break;o.push(l),i.push({token:l,spelling:g.spelling,consumesValue:g.consumesValue}),s=s.slice(1);let p=s[0];if(g.consumesValue&&p!==void 0)o.push(p),s=s.slice(1);continue}if(Object.hasOwn(c,l)&&c[l]){a(c[l],l),r=c[l],n.push(l),s=s.slice(1);continue}let d=Do(c,l);if(d){a(d.node,l),r=d.node,n.push(d.canonicalName),s=s.slice(1);continue}if(r.run)break;throw er(r,l,n)}return{command:r,argv:[...o,...s],commandPath:n}}function tr(e){let t=[],n,r=(s,o)=>{if(n)n[s](o);else t.push([s,o])};return{io:e,routed:{...e,stdout:(s)=>r("text",s),stderr:(s)=>r("diag",s)},get renderer(){return n},choose(s){let o=s??{text:e.stdout,diag:e.stderr};n=o;let i=t;t=[];for(let[a,c]of i)o[a](c)}}}function In(){let e=xe;if(xe=void 0,e&&process.exitCode===e.exitCode&&process.listenerCount(e.name)===0)process.kill(process.pid,e.name)}function nr(e){if(!(e instanceof Error))return!1;return e.name==="AbortError"}function xt(e){return rr(e)&&"error"in e&&"suppressed"in e&&e.name==="SuppressedError"}function rt(e){let t=[],n=new Set;try{let r=e;while(!nr(r)){if(!xt(r)||n.has(r))return;n.add(r),t.push(r.error),r=r.suppressed}}catch{return}return t}function rr(e){return typeof e==="object"&&e!==null}function sr(e){let t=[],n=new Set,r=256,s=!1,o=(a)=>{if(s)return;if(r===0){s=!0,t.push(Error("[additional failures omitted]"));return}r--;let c;try{c=a()}catch{t.push(Error("[unreadable failure]"));return}i(c)},i=(a)=>{try{if(rr(a)){if(n.has(a))return;n.add(a)}let c=t.length;if(xt(a)){if(o(()=>a.error),o(()=>a.suppressed),t.length>c)return}else if(a instanceof AggregateError){let l=a.errors;if(Array.isArray(l)){for(let d=0;d<l.length;d++)if(o(()=>l[d]),s)break;if(t.length>c)return}}t.push(a)}catch{t.push(Error("[unreadable failure]"))}};return o(()=>e),t}function or(e){try{return String(e instanceof Error&&e.message||e)}catch{return"[unreadable failure]"}}function St(e,t="Error"){return sr(e).map((n)=>`${t}: ${or(n)}`).join(`
11
+ `)}function Mo(e){if(Object.freeze(e),Object.freeze(e.localFlags),Object.freeze(e.ownedFlags),Object.freeze(e.effectiveFlags),e.meta.sections)Object.freeze(e.meta.sections);Object.freeze(e.meta),Object.freeze(e.contexts),Object.freeze(e.extensions),Object.freeze(e.args)}function Lo(e){return typeof e==="symbol"}function zo(e,t){let n=Object.freeze([...e.extensions]),r=n.flatMap((u)=>Object.entries(u.flags).map(([f,{recursive:h=!0,...y}])=>({name:f,def:y,recursive:h,by:u.id}))).sort((u,f)=>u.name<f.name?-1:u.name>f.name?1:0),s=(u)=>new Map(r.filter(({recursive:f})=>u||f).map(({name:f,by:h})=>[f,h])),o=s(!0),i=s(!1),a=new Map,c,l;for(let u of n){for(let[f,h]of Object.entries(u.handlers)){let y=u.flags[f];a.set(f,{...h,by:u.id,rootOnly:y?.recursive===!1,boolean:y?.type==="boolean"})}if(u.hooks.renderer){if(l)throw new b("DEFINITION",`Extensions "${l.by}" and "${u.id}" both set renderer; an application can have one`,{subject:"extension",name:u.id,reason:"duplicate-renderer"});l={by:u.id,select:u.hooks.renderer}}if(!u.hooks.noAction)continue;if(c)throw new b("DEFINITION",`Extensions "${c.by}" and "${u.id}" both set noAction; an application can have one`,{subject:"extension",name:u.id,reason:"duplicate-no-action"});c={by:u.id,run:u.hooks.noAction}}let d=n.flatMap((u)=>{let f=e.extensionPositions.get(u.id);return u.provide.map((h)=>({instance:h,position:f,extension:u.id}))}),g=n.flatMap((u)=>u.use),p=new Map,m=(u)=>{let f=p.get(u);if(!f)p.set(u,f=Fo(u,d));return f},w=(u)=>{if(d.length===0)return u.resolve();let f=$n.get(e.extensions);if(!f)$n.set(e.extensions,f=new WeakMap);let h=f.get(u);if(!h)h=t(u.definition,m(u.parent)),f.set(u,h);return h},O=(u,f,h,y)=>{for(let x of u.usedExtensions)if(!n.some((j)=>j.id===x))throw new b("DEFINITION",`Command "${f}" uses Extension "${x}", which the application does not extend`,{subject:"extension",name:x,reason:"missing-extension"});let S=new Map(h?qn(u).map((x)=>[x.name,{name:x.name,meta:x.meta,resolve:()=>w(x),definition:x.definition}]):te(u).map((x)=>[x.name,x])),I=new Map;if(h){let x=new Set;for(let{meta:j}of S.values()){x.add(j.name);for(let C of j.aliases??[])x.add(C)}for(let j of n)for(let C of j.commands){let W={name:C.name,...C[L].meta},D=[W.name,...W.aliases??[]];if(D.some((_)=>x.has(_)))throw new b("DEFINITION",`Extension "${j.id}" command "${C.name}" collides with an existing command`,{subject:"command",name:C.name,reason:"command-collision"});for(let _ of D)x.add(_);I.set(C.name,j.id);let N;S.set(C.name,{name:C.name,meta:W,resolve:()=>N??=t(C,u,j.id),definition:C})}}let E={...u,meta:{...u.meta},...K(u),args:[...u.args],subCommands:Yn(S.values(),(x)=>O(x.resolve(),`${f} ${x.name}`,!1,y??I.get(x.name))),addedChildren:void 0,contexts:u.contexts.map((x)=>({...x})),providedContexts:[...u.providedContexts],demands:[...u.demands],extensions:[...u.extensions],extensionFlags:h?o:i,extension:y};for(let{name:x,def:j,recursive:C}of r)if(h||C)R(E,x,j,"owned");return ft(E,g),So(E,[...E.inheritedDemands,...ee(E.demands),...g]),To(E,f,ko(E,h)),Mo(E),E},v=m(e);return Ce(v.contexts.map(({instance:u})=>u),n.flatMap((u)=>[...u.use,...u.provide])),{rootNode:O(v,e.meta.name,!0),extensions:n,handlers:a,...c&&{noAction:c},...l&&{renderer:l}}}function ne(e,t){let n=jn.get(e);if(n)return n;let r=zo(e,t);return Ao(r.rootNode,r.extensions),jn.set(e,r),r}function Bo(e,t,n){let r=Ot(e,t);return{argv:t,route:r,parsed:bo(r.command,r.argv,n)}}function Et(e,t){let n=Ot(e,t);if(n.argv.length>0)throw er(n.command,n.argv[0],n.commandPath);return n}function Uo(e,t,n,r){let s=Et(e,t);return{argv:t,route:s,parsed:Vn(s.command,n,r)}}function ir(e,t){let n=yt(e.rootNode);return{get rootCommand(){return n(e.rootNode)},get command(){return n(t)}}}function Wo(e,t,n){let r;for(let s of t.flagOrder){let o=e.get(s),i=t.flags[s];if(!o||o.rootOnly&&!n||i===void 0)continue;if(o.boolean&&(i===!1||Array.isArray(i)&&i.every((a)=>a===!1)))continue;if(o.eager)return o;r??=o}return r}function Vo(e){if(typeof e!=="object"||e===null)return!1;let t=e;try{return Symbol.asyncIterator in t&&typeof t[Symbol.asyncIterator]==="function"&&typeof t.next==="function"&&typeof t.return==="function"&&typeof t.throw==="function"}catch{return!1}}async function ar(e,t,n,r,s,o,i){let x=[];try{let{rootNode:a,extensions:c}=t;if(!t.renderer)n.choose(void 0);let l=e.env??process.env;let{argv:d,route:g,parsed:p}="argv"in e?Bo(a,e.argv,l):Uo(a,e.path,e.input,l);let m=g.command;let w=p;const O=rn(x,new AsyncDisposableStack,1);let v=m.contexts.map(({instance:N})=>N);let u=xo(v,m.flagContexts,n.routed,O,r);let f=ir(t,m);let h=!1;let y=Object.freeze({argv:[...d],get rootCommand(){return f.rootCommand},get command(){return f.command},commandPath:Object.freeze([...g.commandPath]),commandPathOf:(N)=>Kn(a,N),get args(){return w.args},get flags(){return w.flags},get rawArgs(){return w.rawArgs},get sources(){return w.sources},signal:r,ctx:u.bag(c.flatMap((N)=>N.use)),bindInput(N){w=wo(m,p,N)},stdout:n.io.stdout,stderr:n.io.stderr,defer(N){if(!h)throw new b("DEFINITION","Extension cleanup can only be registered while Extension setups run.",{subject:"extension",reason:"extension-defer-after-setup"});O.defer(N)}});o?.(y);let S=async()=>{vo(m,w);let N=await ro(m,w);u.setValidatedFlags(N.flags);let _;if(m.run){let k={args:N.args,flags:N.flags,ctx:u.bag(v),rawArgs:w.rawArgs,signal:r,get command(){return f.command},get rootCommand(){return f.rootCommand},stdout:n.routed.stdout,stderr:n.routed.stderr};if(_=await m.run(k),Vo(_))_=await I(_,s.events=[])}let A=m.outputSchema?await so(m.outputSchema,_):_;if(m.run)n.renderer?.result?.(A);return A};let I=async(N,_)=>{let A=!1;try{n.renderer?.stream?.();for(;;){r.throwIfAborted();let k=await N.next();if(A=k.done===!0,r.throwIfAborted(),k.done)return k.value;_.push(k.value),n.renderer?.event?.(k.value),s.onEvent?.(k.value)}}catch(k){if(A)throw k;try{for(let ce=await N.return(void 0);!ce.done;)ce=await N.next()}catch(ce){throw new SuppressedError(ce,k,"Closing the action's generator failed.")}throw k}};let E;try{try{h=!0;try{for(let A of c)await A.hooks.setup?.(y)}catch(A){h=!1;try{if(t.renderer)n.choose(await t.renderer.select(y))}catch{}throw A}finally{h=!1}if(t.renderer)n.choose(await t.renderer.select(y));let _=Wo(t.handlers,p,m===a)??(m.run?void 0:t.noAction);if(_)await _.run(y),E={status:"handled",by:_.by};else{if(m.run)for(let A of c)await A.hooks.preRun?.(y);E={status:"completed",result:await S(),...be(s)}}}catch(_){if(!n.renderer)n.choose(void 0);let A=await i?.(_,y);E={status:"failed",error:_,...A===void 0?{}:{by:A},...be(s)}}Object.freeze(E);let N;for(let _ of c.toReversed())try{await _.hooks?.postRun?.(y,E)}catch(A){if(E.status!=="failed")N??={error:A}}if(E.status==="failed")throw E.error;if(N)throw N.error}finally{await u.settle()}return E.status==="handled"?{status:"handled",by:E.by}:{status:"completed",result:E.result,...be(s)}}catch(j){var C=j,W=1}finally{var D=sn(x,C,W);D&&await D}}function be(e){return e.events?{events:Object.freeze(e.events)}:{}}async function Nn(e,t,n,r,s,o){let i=o;if(!i){let l=function(m){return Promise.reject(new b("DEFINITION",`Context "${String(m)}" cannot be pulled from onError because invocation Contexts have already been disposed.`,{subject:"context",name:String(m),reason:"context-after-disposal"}))},d=new Proxy({},{get:(m,w)=>w==="then"||Lo(w)?void 0:l(w)}),g;try{g=Ot(n.rootNode,t)}catch{}let p=ir(n,g?.command??n.rootNode);i=Object.freeze({argv:[...t],get rootCommand(){return p.rootCommand},get command(){return p.command},commandPath:Object.freeze(g?[...g.commandPath]:[n.rootNode.meta.name]),commandPathOf:(m)=>Kn(n.rootNode,m),args:Object.freeze({}),flags:Object.freeze({}),rawArgs:[],sources:Object.freeze({args:Object.freeze({}),flags:Object.freeze({}),raw:void 0}),signal:s,stdout:r.io.stdout,stderr:r.io.stderr,bindInput(){},ctx:d})}try{for(let l of n.extensions)if(await l.hooks?.onError?.(e,i))return l.id}catch{}let a=rt(e);if(a){for(let l of a)cr(l,r,"Error");return}let c=r.renderer;if(c?.error)try{c.error(e);return}catch{}r.io.stderr(St(e))}function cr(e,t,n){let r=t.renderer;if(!r?.cleanup){t.io.stderr(St(e,n));return}for(let s of sr(e))try{r.cleanup(s)}catch{t.io.stderr(`${n}: ${or(s)}`)}}function Ho(e){return e!==void 0&&Object.keys(e).length>0}async function lr(e,t,n,r){let s=[],o=[],i={onEvent:n?.onEvent};try{let{signal:a=new AbortController().signal,env:c,...l}=n??{},d={stdout(g){s.push(g),l.stdout?.(g)},stderr(g){o.push(g),l.stderr?.(g)}};return{...await We(d,async()=>{let g=ne(e,r);return await ar({...t,env:c},g,tr(d),a,i)},a),stdout:s.join(`
9
12
  `),stderr:o.join(`
10
- `)}}catch(i){return{status:"failed",error:i,stdout:s.join(`
13
+ `)}}catch(a){return{status:"failed",error:a,...be(i),stdout:s.join(`
11
14
  `),stderr:o.join(`
12
- `)}}}async function Ft(e,t,n){let r=t?.argv??process.argv.slice(2),s={...as,...t?.io},o=new AbortController,i=t?.signal?AbortSignal.any([t.signal,o.signal]):o.signal;if(!ge());let a=async()=>{let c;try{c=R(e,n)}catch(d){if(ve(d))return process.exitCode=F,F;return s.stderr(Ce(d)),process.exitCode=1,1}let l=()=>{if(!o.signal.aborted){o.abort(new DOMException("Interrupted by SIGINT.","AbortError"));return}if(process.removeListener("SIGINT",l),process.listenerCount("SIGINT")===0)process.kill(process.pid,"SIGINT")};process.on("SIGINT",l);let u,f;try{await At({argv:r},c,s,i,(d)=>{u=d},async(d,p)=>{f={error:d};let b=ve(d);return process.exitCode=b?F:1,xe(d,r,c,s,i,p,b)})}catch(d){let p;try{if(f&&!Object.is(d,f.error)&&_t(d)&&Object.is(d.suppressed,f.error))p={error:d.error}}catch{}if(p)s.stderr(Ce(p.error,"Cleanup failed"));if(ve(d)){if(!f)await xe(d,r,c,s,i,u,!0);return process.exitCode=F,F}if(process.exitCode=1,!f)await xe(d,r,c,s,i,u);return 1}finally{process.removeListener("SIGINT",l)}return 0};return await(ms(t?.io)?we(s,a):a())}var Te=Symbol.for("crust.commandDefinition");function D(e,t,n){let r=e[Te],s=e.name,o=n?`Extension "${n}" command "${s}"`:`Command "${s}"`,i=(u)=>({subject:n?"extension":"command",name:n??s,reason:u}),a=new Z(s);for(let[u,f]of Object.entries(t.ownedFlags))N(a._node,u,f,"owned");a._node.contexts=t.contexts.map((u)=>({...u}));let c=r.recipe(a);if(!(c instanceof Z)||c._ancestorOwnedFlags!==a._ancestorOwnedFlags)throw new h("DEFINITION",`${o} definition must return the same command builder it received`,i("foreign-command-builder"));if(c._node.extensions.length>0)throw new h("DEFINITION",`${o} cannot register Extensions inside command definitions`,i("nested-command-extension"));let l=P(c._node);return J(l.contexts.map(({instance:u})=>u),l.demands),l.meta={name:s,...r.meta},l}function Ae(e,t=[]){if(e.trim()==="")throw new h("DEFINITION","Command name must be a non-empty string",{subject:"command",name:e,reason:"empty-name"});if(e==="__proto__")throw new h("DEFINITION",'Command name "__proto__" is reserved',{subject:"command",name:e,reason:"reserved-name"});if(t.includes(e))throw new h("DEFINITION",`Command "${e}" must not list its own canonical name as an alias`,{subject:"command",name:e,reason:"alias-collision"});return e}function Pt(e){return typeof e==="function"}function ps(e,t,n){let r=!Pt(t),s=r?t:{},o=r?n:t,i=Ae(e,s.aliases);if(!Pt(o))throw new h("DEFINITION",`Command "${i}" requires a recipe`,{subject:"command",name:i,reason:"missing-recipe"});for(let p of s.aliases??[])if(p===""||/[ \t\n\r\v\f]/.test(p)||p.startsWith("-"))throw new h("DEFINITION",`Command "${i}" has an invalid alias "${p}"`,{subject:"command",name:i,reason:"invalid-alias"});let{sections:a,version:c,...l}=s,u={...l,...s.aliases?{aliases:[...s.aliases]}:{},...a?{sections:je(i,a)}:{}},f={name:i,recipe:o,meta:u},d=(p)=>Object.freeze({name:p,as:(b)=>d(Ae(b,u.aliases)),[Te]:Object.freeze({...f,name:p})});return d(i)}function gs(e){return e.filter((t,n)=>e.findLastIndex((r)=>r.id===t.id)===n)}async function Rt(e,t,n){let r=n[0]??{},s=n[1];return await Tt(e,{path:t,input:r},s,D)}var Z=class{_node;_ancestorOwnedFlags;constructor(e,...t){let n=t[0]??{},r=Ae(e);if(this._node=St(r),n.description!==void 0)this._node.meta.description=n.description;if(n.version!==void 0)this._node.meta.version=n.version;if(n.usage!==void 0)this._node.meta.usage=n.usage;if(n.sections!==void 0)this._node.meta.sections=je(r,n.sections);this._ancestorOwnedFlags={}}_clone(e){let t=Object.create(Object.getPrototypeOf(this));return t._node={...this._node,...e},t._ancestorOwnedFlags=this._ancestorOwnedFlags,t}flags(...e){let t=this._clone(X(this._node));for(let n of e){let{name:r,...s}=n;N(t._node,r,s,"local")}return t}args(...e){let t=[...this._node.args,...e.map(wt)],n=new Set;for(let[r,s]of t.entries()){if(n.has(s.name))throw new h("DEFINITION",`Argument name "${s.name}" is already defined`,{subject:"argument",name:s.name,reason:"duplicate-arg"});if(n.add(s.name),s.variadic===!0&&r!==t.length-1)throw new h("DEFINITION",`Only the last positional argument can be variadic; "${s.name}" is not last`,{subject:"argument",name:s.name,reason:"variadic-position"})}return this._clone({args:t})}use(...e){return this._clone({demands:[...this._node.demands,...e.map(Y)]})}provide(...e){let t=e.map(Y);J([...this._node.contexts.map(({instance:r})=>r),...t],t);let n=this._clone({...X(this._node),contexts:[...this._node.contexts,...t.map((r)=>({instance:r}))],providedContexts:[...this._node.providedContexts,...t]});for(let r of t)for(let[s,o]of Object.entries(r.ownedFlags))N(n._node,s,o,"owned");return n}action(e){return this._clone({run:e})}extend(...e){let t=e.map(Y),n=gs([...this._node.extensions,...t]),r=$t(this._node,n,new Set(t.map((s)=>s.id)));return J(r.contexts.map(({instance:s})=>s),n.flatMap((s)=>[...s.use,...s.provide])),this._clone({...r,extensions:n})}add(...e){return this._addDefinitions(e)}command(e,t){let n=ps(e,t);return this._addDefinitions([n])}_addDefinitions(e){let t={...this._node.subCommands};for(let n of e){let r=[n.name,...n[Te].meta.aliases??[]];for(let o of Object.values(t))if([o.meta.name,...o.meta.aliases??[]].some((i)=>r.includes(i)))throw new h("DEFINITION",`Command name "${n.name}" is already registered on this command`,{subject:"command",name:n.name,reason:"command-collision"});let s=D(n,this._node);t[n.name]=s}return this._clone({subCommands:t})}async snapshot(){return A(R(this._node,D).rootNode)}async run(e,...t){return await Rt(this._node,e,t)}at(e){Ne(R(this._node,D).rootNode,e);let t=this._node,n=Object.freeze([...e]);return{path:n,async run(...r){return await Rt(t,n,r)}}}async execute(e){return await Ft(this._node,e,D)}};var hs=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Dt='letters, digits, ".", "_", and "-", starting with a letter or digit';function Mt(e){return hs.test(e)}import{existsSync as Rs,lstatSync as Gt,mkdirSync as Ut,readFileSync as Ds,readdirSync as Kt,realpathSync as Re,statSync as Yt,writeFileSync as Ms}from"node:fs";import{dirname as Jt,join as T,resolve as Vt,sep as Ls}from"node:path";import{fileURLToPath as zs}from"node:url";function Q(e){return e instanceof Error&&"code"in e&&typeof e.code==="string"}import{isAbsolute as bs,relative as ws,sep as ys}from"node:path";function Lt(e,t){let n=ws(e,t);return n===""||!bs(n)&&n!==".."&&!n.startsWith(`..${ys}`)}import{spawn as Bs,spawnSync as Ws}from"node:child_process";import{once as Us}from"node:events";import{accessSync as vs,constants as xs,statSync as Ss}from"node:fs";import{delimiter as Os,extname as $s,join as Es,resolve as Is,sep as Cs,win32 as js}from"node:path";import{spawn as _s,spawnSync as ks}from"node:child_process";import{once as Ns}from"node:events";import{text as zt}from"node:stream/consumers";function Wt(e){if(e?.startsWith("bun"))return"bun";if(e?.startsWith("pnpm"))return"pnpm";if(e?.startsWith("yarn"))return"yarn";if(e?.startsWith("npm"))return"npm";return null}var As=/[\0\r\n"%!^`<>&|]/,Fe=/([()\][%!^"`<>&|;, *?])/g;function Ts(e){let t=e.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\"");return t=t.replace(/(?=(\\+?)?)\1$/g,"$1$1"),t=`"${t}"`.replace(Fe,"^$1"),t.replace(Fe,"^$1")}function Fs(e,t,n,r=process.platform){if(n||r!=="win32"||!/\.(cmd|bat)$/i.test(e))return null;let s=js.normalize(e);for(let[i,a]of[s,...t].entries())if(As.test(a)){let c=i===0?"command":`argument ${i}`;throw Error(`Windows command shim ${c} ${JSON.stringify(a)} contains unsafe shell characters`)}let o=[s.replace(Fe,"^$1"),...t.map(Ts)].join(" ");return{command:process.env.ComSpec??"cmd.exe",args:["/d","/s","/c",`"${o}"`],windowsVerbatimArguments:!0}}function Ps(e){if(e.pid===void 0)return;if(process.platform==="win32"){if(e.exitCode===null&&e.signalCode===null){let t=ks("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore",timeout:1e4});if(t.error||t.status!==0)e.kill("SIGKILL")}return}try{process.kill(-e.pid,"SIGKILL")}catch(t){if(Q(t)&&t.code==="ESRCH")return;throw e.kill("SIGKILL"),t}}async function M(e,t=[],n={}){let r=Fs(e,t,n.shell),s=(n.stdio??"collect")==="collect",o=s&&n.stdout!=="ignore",i=_s(r?.command??e,r?.args??t,{cwd:n.cwd,env:n.env,shell:n.shell,stdio:s?["ignore",o?"pipe":"ignore","pipe"]:"inherit",detached:n.timeout!==void 0&&process.platform!=="win32",windowsVerbatimArguments:r?.windowsVerbatimArguments}),a,c=new Promise((l,u)=>{if(n.timeout===void 0)return;let f=n.timeout;a=setTimeout(()=>{let d=Error(`${[e,...t].join(" ")} did not exit within ${f} ms and was killed.`);try{Ps(i)}catch(p){d=Error("Process-tree cleanup failed after timeout.",{cause:p})}i.stdout?.destroy(),i.stderr?.destroy(),u(d)},f)});try{let[l,u,[f]]=await Promise.race([Promise.all([o?zt(i.stdout):"",s?zt(i.stderr):"",Ns(i,"close")]),c]);return{exitCode:f,stdout:l,stderr:u}}finally{clearTimeout(a)}}function Bt(e){try{return vs(e,xs.X_OK),Ss(e).isFile()}catch{return!1}}function Pe(e){if(e.includes(Cs)||e.includes("/"))return Bt(e)?e:null;let t=process.platform==="win32"&&!$s(e)?(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";"):[""];for(let n of process.env.PATH?.split(Os)??[])for(let r of t){let s=Is(Es(n,e+r));if(Bt(s))return s}return null}function Vs(e,t){return e.replace(/\{\{\s*(\w+)\s*\}\}/g,(n,r)=>Object.hasOwn(t,r)?t[r]??n:n)}function qs(e){let t=Jt(e),n=e.slice(t==="."?0:t.length+1);if(n.startsWith("_")&&!n.startsWith("__")){let r=`.${n.slice(1)}`;return t==="."?r:T(t,r)}return e}function Hs(e){return Yt(e,{throwIfNoEntry:!1})?.isDirectory()===!0&&Kt(e).length>0}function qt(e,t){if(Re(e)!==e)throw Error(`Destination root "${e}" was redirected outside the destination.`);let n=e;for(let r of t.split(Ls)){n=T(n,r);let s;try{s=Gt(n).isSymbolicLink()}catch(i){if(Q(i)&&i.code==="ENOENT")return;throw i}if(!s)continue;let o;try{o=Re(n)}catch{}if(o===void 0||!Lt(e,o))throw Error(`Destination path "${n}" is a symlink${o===void 0?" to a missing target":` to "${o}"`} outside the destination "${e}". Remove the link or choose another destination.`)}}async function Xt(e){let{template:t,dest:n,context:r,conflict:s="abort",render:o=Vs}=e,i=t instanceof URL?zs(t):Vt(t),a=Vt(n),c=Yt(i,{throwIfNoEntry:!1});if(!c)throw Error(`Template directory "${i}" does not exist (from template: "${String(t)}").`);if(!c.isDirectory())throw Error(`Template path "${i}" is not a directory (from template: "${String(t)}").`);if(s==="abort"&&Hs(a))throw Error(`Destination directory "${a}" already exists and is non-empty. Use conflict: "overwrite" to proceed.`);let l=Kt(i,{recursive:!0,encoding:"utf8"}).filter((p)=>Gt(T(i,p)).isFile());Ut(a,{recursive:!0});let u=Re(a),f=l.map((p)=>({relFromTemplate:p,destRelPath:qs(p)}));for(let{destRelPath:p}of f)qt(u,p);let d=[];for(let{relFromTemplate:p,destRelPath:b}of f){let m=T(i,p),g=T(u,b),w=Ds(m),S=w.subarray(0,8192).includes(0)?w:await o(w.toString("utf-8"),r);qt(u,b),Ut(Jt(g),{recursive:!0}),Ms(g,S,"utf-8"),d.push(b)}return{files:d}}var Gs=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];function De(e){let t=e??process.cwd();for(let[n,r]of Gs)if(Rs(T(t,n)))return r;return Wt(process.env.npm_config_user_agent)??"npm"}function Zt(e){try{return Ws("git",["rev-parse","--is-inside-work-tree"],{cwd:e??process.cwd(),stdio:"ignore"}).status===0}catch{return!1}}async function Me(e,t){for(let n of e)switch(n.type){case"install":await Ks(t);break;case"git-init":await Ys(t,n.commit);break;case"open-editor":await Js(t);break;case"command":await Xs(n.cmd,n.cwd??t)}}async function Ks(e){let t=De(e),n=Pe(t);if(!n)throw Error(`Package manager "${t}" was not found on PATH. Install ${t} and try again.`);let{exitCode:r}=await M(n,["install"],{cwd:e,stdio:"inherit"});if(r!==0)throw Error(`"${t} install" exited with code ${r}`)}async function Ys(e,t){let n=Pe("git");if(!n)throw Error('"git" was not found on PATH. Install Git and try again.');if(await L(n,["init"],e,"git init"),t)await Zs(e,n),await L(n,["add","."],e,"git add"),await L(n,["commit","-m",t],e,"git commit")}async function Js(e){let t=process.env.EDITOR||"code";try{let n=Bs(t,[e],{stdio:"ignore",shell:process.platform==="win32"});n.unref();let r=await Promise.race([Us(n,"close").then(([s])=>({kind:"exited",code:s})),new Promise((s)=>setTimeout(()=>s({kind:"timeout"}),500))]);if(r.kind==="exited"&&r.code!==0)console.warn(`Warning: could not open editor "${t}" (exit code ${r.code})`)}catch{console.warn(`Warning: could not open editor "${t}"`)}}async function Xs(e,t){let{exitCode:n}=await M(e,[],{cwd:t,shell:!0,stdio:"inherit"});if(n!==0)throw Error(`Command "${e}" exited with code ${n}`)}async function Zs(e,t){if(!await Ht(t,"user.name",e))await L(t,["config","user.name","Crust"],e,"git config user.name");if(!await Ht(t,"user.email",e))await L(t,["config","user.email","crust@scaffolded.project"],e,"git config user.email")}async function Ht(e,t,n){let{exitCode:r}=await M(e,["config",t],{cwd:n,stdio:"collect",stdout:"ignore"});return r===0}async function L(e,t,n,r){let{exitCode:s,stderr:o}=await M(e,t,{cwd:n,stdio:"collect",stdout:"ignore"});if(s!==0)throw Error(`"${r}" failed with exit code ${s}${o?`: ${o.trim()}`:""}`)}var Qs=new Intl.Segmenter(void 0,{granularity:"grapheme"}),eo=/[\p{Cc}\p{Cf}\p{Mn}\p{Me}]/u,to=/\p{Emoji_Presentation}|\p{Emoji}\uFE0F/u,no=new RegExp([String.raw`(?:\x1b\[|\x9b)[^\x1b\x18\x1a\x9c\x40-\x7e]*[\x40-\x7e\x18\x1a\x9c]?`,String.raw`(?:\x1b\]|\x9d)[^\x07\x1b\x18\x1a\x9c]*(?:\x07|\x1b\\|[\x18\x1a\x9c])?`,String.raw`(?:\x1b[PX^_]|[\x90\x98\x9e\x9f])[^\x1b\x18\x1a\x9c]*(?:\x1b\\|[\x18\x1a\x9c])?`,String.raw`\x1b[\x20-\x2f][^\x1b]?`,String.raw`\x1b[\x18\x1a\x9c\x30-\x7e]?`].join("|"),"g");function ro(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=94176&&e<=111355||e>=127488&&e<=127743||e>=131072&&e<=262141)}function so(e){return eo.test(String.fromCodePoint(e))||e>=4448&&e<=4607||e>=55216&&e<=55295}function oo(e){if(!/[^\x20-\x7e]/.test(e))return e.length;let t=0;for(let{segment:n}of Qs.segment(e.replace(no,""))){if(to.test(n)){let r=n.codePointAt(0);t+=n.length===2&&r>=127462&&r<=127487?1:2;continue}for(let r of n){let s=r.codePointAt(0);if(so(s))continue;t+=ro(s)?2:1;break}}return t}function nn(e){return globalThis.Bun?.stringWidth(e,{countAnsiEscapeCodes:!1})??oo(e)}var rn={bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},io={black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBrightBlack:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49]},sn={...rn,...io},Le=Object.freeze(Object.keys(sn)),ao=Object.freeze(Object.fromEntries(Le.map((e)=>{let[t,n]=sn[e];return[e,{open:`\x1B[${t}m`,close:`\x1B[${n}m`}]})));function co(e){return Object.hasOwn(rn,e)}function z(e,t,n){return e!==void 0&&t in e?e[t]:n}function on(e){return z(e,"isTTY",process.stdout?.isTTY)??!1}function an(e){return z(e,"forceColor",process.env.FORCE_COLOR)}function cn(e){return e==="0"||e==="false"}function lo(e){let t=e.toLowerCase();return t.includes("24bit")||t.includes("truecolor")||t.endsWith("-direct")}function ln(e,t){if(e!==void 0){let n=e.toLowerCase();if(n==="truecolor"||n==="24bit")return!0}return t!==void 0&&lo(t)}function Qt(e,t){if(ln(e,t))return"truecolor";if(t!==void 0&&t.toLowerCase().includes("256color"))return"256";return"16"}function uo(e,t){if(e==="never")return"none";if(e==="always")return"truecolor";let n=z(t,"colorTerm",process.env.COLORTERM),r=z(t,"term",process.env.TERM),s=an(t);if(s!==void 0){if(cn(s))return"none";if(s==="1")return"16";if(s==="2")return"256";if(s==="3")return"truecolor";return Qt(n,r)}if(!on(t))return"none";let o=z(t,"noColor",process.env.NO_COLOR);if(o!==void 0&&o!=="")return"none";if(r!==void 0&&r.toLowerCase()==="dumb"&&!ln(n,r))return"none";return Qt(n,r)}function fo(e,t){if(e==="always")return!0;if(e==="never")return!1;let n=an(t);if(n!==void 0)return!cn(n);return on(t)}var un={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function ze(e,t){if(e==null)return"";let n=String(e);if(n==="")return"";let{open:r,close:s}=t;if(n.includes(s))n=n.replaceAll(s,s+r);return r+n+s}var mo="\x1B[39m",po="\x1B[49m",go="\x1B[38;",ho="\x1B[48;";function bo(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function wo(e){return Object.hasOwn(un,e)}function Be(e){if(Array.isArray(e)){if(e.length===3&&e.every((t)=>Number.isInteger(t)&&t>=0&&t<=255))return[e[0],e[1],e[2]]}else if(typeof e==="string"){let t=e.toLowerCase();if(wo(t))return un[t];let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t)?.[1];if(n){let s=n.length===3?n.split("").map((o)=>o+o).join(""):n;return[Number.parseInt(s.slice(0,2),16),Number.parseInt(s.slice(2,4),16),Number.parseInt(s.slice(4,6),16)]}let r=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/.exec(t)??/^rgb\(\s*(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})\s*\)$/.exec(t);if(r){let s=[Number(r[1]),Number(r[2]),Number(r[3])];if(s.every((o)=>o<=255))return s}}throw TypeError(`Invalid color input: ${bo(e)}`)}function yo(e,t,n){let r=[0,95,135,175,215,255],s=(f)=>r.reduce((d,p,b)=>Math.abs(p-f)<Math.abs(r[d]-f)?b:d,0),[o,i,a]=[s(e),s(t),s(n)],c=Math.min(23,Math.max(0,Math.round(((e+t+n)/3-8)/10))),l=8+c*10,u=(f,d,p)=>(e-f)**2+(t-d)**2+(n-p)**2;return u(l,l,l)<u(r[o],r[i],r[a])?232+c:16+36*o+6*i+a}function fn(e,t,n){let r=Math.round(Math.max(e,t,n)/127.5);if(r===0)return 30;let s=30+((Math.round(n/255)<<2|Math.round(t/255)<<1|Math.round(e/255))&7);if(r===2)s+=60;return s}function dn(e,t){let[n,r,s]=Be(e);if(t==="16")return`\x1B[${fn(n,r,s)}m`;if(t==="256")return`\x1B[38;5;${yo(n,r,s)}m`;return`\x1B[38;2;${n};${r};${s}m`}function vo(e,t){if(t==="16"){let[n,r,s]=Be(e);return`\x1B[${fn(n,r,s)+10}m`}return dn(e,t).replace(go,ho)}function mn(e,t,n){if(n==="none")return Be(t),{open:"",close:""};return{open:e==="fg"?dn(t,n):vo(t,n),close:e==="fg"?mo:po}}function xo(e,t,n,r){let s=mn(e,n,r);return r==="none"?t:ze(t,s)}var pn="\x1B]",gn="\x1B\\",So=`${pn}8;;${gn}`;function hn(e,t,n,r=""){if(!n.test(e))throw TypeError(`Invalid ${t}: ${JSON.stringify(e)} must contain only printable ASCII characters${r}.`)}function Oo(e){let t=e?.id;if(t===void 0||t==="")return"";if(hn(t,"hyperlink id",/^[\x20-\x7e]*$/),t.includes(":")||t.includes(";"))throw TypeError('Invalid hyperlink id: ":" and ";" are reserved by the OSC 8 format.');return`id=${t}`}function bn(e,t){hn(e,"hyperlink URL",/^[\x21-\x7e]*$/," without spaces");let n=Oo(t);return{open:`${pn}8;${n};${e}${gn}`,close:So}}function $o(e,t,n){return ze(e,bn(t,n))}var wn=["fg","bg"];function Eo(e){return e.kind==="named"&&co(e.name)}function ee(e,t){return e.kind==="named"?ao[e.name]:mn(e.kind,e.input,t)}function yn(e,t){let n={kind:e,input:t};return ee(n,"truecolor"),Array.isArray(t)?{kind:e,input:[t[0],t[1],t[2]]}:n}function en(e,t,n){if(e==null)return"";let r=String(e);if(r==="")return r;let s=n(),{modifiersEnabled:o,colorsEnabled:i}=s;for(let a=t.length-1;a>=0;a--){let c=t[a];if(c===void 0)continue;if(Eo(c)?!o:!i)continue;r=ze(r,ee(c,s.colorDepth))}return r}function Io(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)}function Co(e,t){let n=new Map,r=t?"truecolor":e().colorDepth;function s(o){let i=o.map((f)=>f.kind==="named"?f.name:`~${ee(f,"truecolor").open}`).join("|"),a=n.get(i);if(a)return a;let c=(f,...d)=>{if(Io(f)){let p="";for(let b=0;b<f.length;b++)if(p+=f[b]??"",b<d.length)p+=String(d[b]);return en(p,o,e)}return en(f,o,e)};if(n.size>=1024)n.delete(n.keys().next().value);n.set(i,c);for(let f of Le)Object.defineProperty(c,f,{configurable:!1,enumerable:!0,get(){return s([...o,{kind:"named",name:f}])}});for(let f of wn)Object.defineProperty(c,f,{configurable:!1,enumerable:!0,value:(d)=>s([...o,yn(f,d)]),writable:!1});let l="",u="";for(let f of o){let d=ee(f,r);l+=d.open,u=d.close+u}return Object.defineProperty(c,"open",{value:l,writable:!1,configurable:!1,enumerable:!0}),Object.defineProperty(c,"close",{value:u,writable:!1,configurable:!1,enumerable:!0}),Object.freeze(c)}return s}function jo(e){let t={};for(let n of Le)t[n]=e([{kind:"named",name:n}]);return t}function tn(e){let t=e?.mode??"auto",n=fo(t,e?.overrides),r=uo(t,e?.overrides);return{modifiersEnabled:n,colorDepth:r,colorsEnabled:r!=="none",trueColorEnabled:r==="truecolor"}}function _o(e,t){let n=t?tn:(()=>{let i=tn(e);return()=>i})(),r=Co(n,t),s=jo(r),o={get enabled(){let{modifiersEnabled:i,colorsEnabled:a}=n();return i||a},get colorsEnabled(){return n().colorsEnabled},get trueColorEnabled(){return n().trueColorEnabled},get colorDepth(){return n().colorDepth},link(i,a,c){if(n().modifiersEnabled)return $o(i,a,c);return bn(a,c),i},...Object.fromEntries(wn.map((i)=>[i,(...a)=>{if(a.length===1)return r([yn(i,a[0])]);return xo(i,a[0],a[1],n().colorDepth)}])),...s};return Object.freeze(o)}var y=_o(void 0,!0),{black:Da,red:te,green:ne,yellow:Ma,blue:La,magenta:vn,cyan:B,white:za,gray:Ba,brightRed:Wa,brightGreen:Ua,brightYellow:Va,brightBlue:qa,brightMagenta:Ha,brightCyan:Ga,brightWhite:Ka,bgBlack:Ya,bgRed:Ja,bgGreen:Xa,bgYellow:Za,bgBlue:Qa,bgMagenta:ec,bgCyan:tc,bgWhite:nc,bgBrightBlack:rc,bgBrightRed:sc,bgBrightGreen:oc,bgBrightYellow:ic,bgBrightBlue:ac,bgBrightMagenta:cc,bgBrightCyan:lc,bgBrightWhite:uc,bold:re,dim:se,italic:fc,underline:dc,inverse:mc,hidden:pc,strikethrough:gc,link:hc,fg:bc,bg:wc}=y;var xn={spinner:vn,message:re,success:ne,error:te},Ve="\x1B[",ko=`${Ve}?25l`,Sn=`${Ve}?25h`,$n=`${Ve}2K`,En="\r",On={dots:{frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],interval:80},line:{frames:["-","\\","|","/"],interval:130},arc:{frames:["◐","◓","◑","◒"],interval:100},bounce:{frames:["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"],interval:120}},No="✓",Ao="✗";function To(e){if(e===void 0)return On.dots;if(typeof e==="string")return On[e];if(e.frames.length===0)throw Error("A custom spinner requires at least one frame");return e}function We(e,t){let n=e[t];if(n===void 0)throw Error("Spinner frame index is out of bounds");return n}function Ue(e,t,n){return`${$n}${En}${n.spinner(e)} ${n.message(t)}`}function Fo(e,t,n,r){let s=n==="success"?No:Ao,o=`${(n==="success"?t.success:t.error)(s)} ${t.message(e)}
13
- `;return r?$n+En+o:o}function Po(e){let t=e.sink??q()?.output??process.stderr,n=e.theme?{...xn,...e.theme}:xn,r=t.isTTY??!1,{frames:s,interval:o}=To(e.spinner),i=e.sigint??"exit",a=e.message,c=0,l=!1,u=!1,f,d;function p(){if(f!==void 0)clearInterval(f),f=void 0;if(d)process.removeListener("SIGINT",d),d=void 0}return{start(){if(l||u)return;if(l=!0,!r)return;if(t.write(ko),t.write(Ue(We(s,0),a,n)),f=setInterval(()=>{c=(c+1)%s.length,t.write(Ue(We(s,c),a,n))},o),i==="exit")d=()=>{if(p(),u=!0,t.write(Sn),process.listenerCount("SIGINT")===0)process.kill(process.pid,"SIGINT")},process.once("SIGINT",d)},updateMessage(b){if(u)return;if(a=b,l&&r)t.write(Ue(We(s,c),a,n))},stop(b="success",m){if(u)return;if(u=!0,m!==void 0)a=m;p();let g;try{t.write(Fo(a,n,b,l&&r))}catch(w){g={error:w}}if(l&&r)try{t.write(Sn)}catch(w){if(!g)throw w}if(g)throw g.error}}}function qe(e){let t=Po(e),{task:n}=e;if(!n)return t;return t.start(),Promise.resolve().then(()=>n(t)).then((r)=>(t.stop("success"),r),(r)=>{throw t.stop("error"),r})}import*as k from"node:readline";var In={prefix:B,message:re,placeholder:se,cursor:B,selected:B,unselected:se,error:te,success:ne,hint:se,filterMatch:B};function ie(e){let t=q();return{input:e?.input??t?.input??process.stdin,output:e?.output??t?.output??process.stderr}}var Ke=Symbol("submit");function Ye(e){return{[Ke]:e}}var He=new WeakSet,Ge=new WeakSet,_n="\x1B[",Ro=`${_n}?25l`,Do=`${_n}?25h`;function Mo(e,t){let n=e.split(`
14
- `),r=0;for(let s of n){let o=nn(s);r+=o===0?1:Math.ceil(o/t)}return r}var Lo=class extends Error{constructor(e){super(e??"Prompts require an interactive terminal (TTY).");this.name="NonInteractiveError"}};function kn(e=ie().input){return!!e.isTTY}function zo(e=ie().input){if(!kn(e))throw new Lo}function Bo(e){return typeof e==="object"&&e!==null&&Ke in e}function Je(e,t){let{render:n,handleKey:r,initialState:s,renderSubmitted:o}=e,i=e.theme?{...In,...e.theme}:In,{input:a,output:c}=ie(t),l=c;return new Promise((u,f)=>{if(He.has(a)||Ge.has(c)){f(Error("Cannot run multiple prompts concurrently on the same input or output stream. Await each prompt before starting the next."));return}zo(a),He.add(a),Ge.add(c);let d=s,p=0,b=!1,m=!1;function g(){if(b)return;if(b=!0,He.delete(a),Ge.delete(c),a.removeListener("keypress",_),m)a.setRawMode?.(!1);a.pause(),c.write(Do)}function w(C){let I=c.columns||80;if(p>0)k.cursorTo(l,0),k.moveCursor(l,0,-(p-1)),k.clearScreenDown(l);c.write(C),p=Mo(C,I)}let S=Promise.resolve(),x=null;function v(){if(x!==null)return;x=setTimeout(()=>{if(x=null,b)return;try{w(n(d,i))}catch(C){g(),f(C)}},0)}function E(){if(x!==null)clearTimeout(x),x=null}function _(C,I){if(I?.ctrl&&I.name==="c"){E(),c.write(`
15
- `),g(),f(new DOMException("Prompt was cancelled.","AbortError"));return}let me={char:C??"",name:I?.name??"",ctrl:I?.ctrl??!1,meta:I?.meta??!1,shift:I?.shift??!1};S=S.then(async()=>{if(b)return;try{let O=await r(me,d);if(b)return;if(Bo(O)){E();let j=O[Ke];if(o)w(o(d,j,i));c.write(`
16
- `),g(),u(j)}else d=O,v()}catch(O){E(),g(),f(O)}})}try{if(k.emitKeypressEvents(a),a.setRawMode)a.setRawMode(!0),m=!0;a.resume(),c.write(Ro),w(n(d,i)),a.on("keypress",_)}catch(C){g(),f(C)}})}async function Nn(e,t){let n=await e["~standard"].validate(t),r=n.issues?.[0];if(r)return{ok:!1,error:r.message||"Validation failed"};if("value"in n)return{ok:!0,value:n.value};return{ok:!1,error:"Validation failed"}}async function Wo(e,t,n){if(t)return Nn(t,e);if(n)try{await n(e)}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Validation failed"}}return{ok:!0,value:e}}async function oe(e,t,n){if(e.initial!==void 0)return{shortCircuited:!0,value:n?await n(e.initial,"initial"):e.initial};let r=ie(t);if(!kn(r.input)&&e.default!==void 0)return{shortCircuited:!0,value:n?await n(e.default,"default"):e.default};return{shortCircuited:!1,promptIO:r}}async function Uo(e,t,n){if(t.schema!==void 0&&t.validate!==void 0)throw Error(`${e}() cannot combine "schema" with "validate"`);let r=t.schema;if(!r)return oe(t,n);return oe(t,n,async(s,o)=>{let i=await Nn(r,s);if(!i.ok)throw Error(`${o} value rejected by schema: ${i.error}`);return i.value})}function Xe(e,t,n){let r=[e];if(t)r.push(t);if(n)r.push(n);return r.join(" ")}function An(e,t,n,r){let s=t?`${e} ${t}`:e,o=r??"";if(t)return`${s}${o}
17
- ${n}`;return`${s}${o} ${n}`}function Vo(e,t,n,r,s){let o=Math.min(e.length,n),i=[];if(t>0)i.push(s("..."));for(let a=t;a<t+o;a++){let c=e[a];if(c===void 0)break;i.push(r(c,a))}if(t+o<e.length)i.push(s("..."));return i}function Tn(e,t,n,r){let s=Math.min(n,r);if(s===0)return 0;if(e<t)return e;if(e>=t+s)return e-s+1;return t}function qo(e,t,n,r,s){if(t===0)return{cursor:0,scrollOffset:0};let o=n===-1?e<=0?t-1:e-1:e>=t-1?0:e+1;return{cursor:o,scrollOffset:Tn(o,r,t,s)}}function Ho(e){return e.map((t)=>{if(typeof t==="string")return{label:t,value:t};return t})}function Go(e,t){if(e.name==="return")return Ye(t.value);if(e.name==="left"||e.name==="right"||e.name==="tab")return{value:!t.value};if(e.name==="h"||e.char==="y"||e.char==="Y")return{value:!0};if(e.name==="l"||e.char==="n"||e.char==="N")return{value:!1};return t}var Ko=" · ";function Yo(e,t,n,r,s){let o=t.prefix("┃"),i=t.message(n??"Are you sure?"),a=e.value?`${t.selected("●")} ${t.selected(r)}`:`${t.unselected("○")} ${t.unselected(r)}`,c=e.value?`${t.unselected("○")} ${t.unselected(s)}`:`${t.selected("●")} ${t.selected(s)}`;return An(o,i,`${a}${Ko}${c}`)}function Jo(e,t,n,r,s){let o=t.success("✓"),i=t.message(n??"Are you sure?"),a=e?r:s;return Xe(o,i,t.success(a))}async function ae(e,t){let n=await oe(e,t);if(n.shortCircuited)return n.value;let{promptIO:r}=n,s=e.active??"Yes",o=e.inactive??"No";return Je({initialState:{value:e.default??!0},theme:e.theme,render:(i,a)=>Yo(i,a,e.message,s,o),handleKey:Go,renderSubmitted:(i,a,c)=>Jo(a,c,e.message,s,o)},r)}function Xo(e,t,n,r){if(e==="")return r?n.placeholder(r):n.cursor("│");return`${e.slice(0,t)}${n.cursor("│")}${e.slice(t)}`}function Cn(e,t){return(e.codePointAt(t)??0)>65535?2:1}function jn(e,t){return t>=2&&(e.codePointAt(t-2)??0)>65535?2:1}function Zo(e){let t=e.codePointAt(0);return t!==void 0&&e.length===(t>65535?2:1)&&(t<55296||t>57343)}function Qo(e,t,n){if(e.name==="backspace"){if(n===0)return{text:t,cursorPos:n};let r=n-jn(t,n);return{text:t.slice(0,r)+t.slice(n),cursorPos:r}}if(e.name==="delete"){if(n>=t.length)return{text:t,cursorPos:n};let r=n+Cn(t,n);return{text:t.slice(0,n)+t.slice(r),cursorPos:n}}if(e.name==="left"){if(n===0)return{text:t,cursorPos:n};return{text:t,cursorPos:n-jn(t,n)}}if(e.name==="right"){if(n>=t.length)return{text:t,cursorPos:n};return{text:t,cursorPos:n+Cn(t,n)}}if(e.name==="home")return{text:t,cursorPos:0};if(e.name==="end")return{text:t,cursorPos:t.length};if(Zo(e.char)&&!e.ctrl&&!e.meta){let r=t.slice(0,n),s=t.slice(n);return{text:r+e.char+s,cursorPos:n+e.char.length}}return null}function ei(e,t,n){return async(r,s)=>{if(r.name==="return"){let i=await Wo(s.value===""&&n!==void 0?n:s.value,e,t);return i.ok?Ye(i.value):{...s,error:i.error}}let o=Qo(r,s.value,s.cursorPos);return o?{value:o.text,cursorPos:o.cursorPos,error:null}:s}}async function ti(e,t,n){let r=await oe(e,n);if(r.shortCircuited)return r;let s=Ho(e.choices),o=e.maxVisible??10,i=new Set(t.flatMap((l)=>{let u=s.findIndex((f)=>f.value===l);return u===-1?[]:[u]})),a=t.length===0?-1:s.findIndex((l)=>l.value===t[0]),c=a===-1?0:a;return{shortCircuited:!1,choices:s,maxVisible:o,cursor:c,scrollOffset:Tn(c,0,s.length,o),selected:i,promptIO:r.promptIO}}function ni(e,t,n,r,s){let o=t.prefix("┃"),i=t.message(n??"Enter a value"),a=r??s,c=s!==void 0&&r!==void 0&&e.value===""?` ${t.hint(`(${s})`)}`:"",l=An(o,i,Xo(e.value,e.cursorPos,t,a),c);if(e.error!==null)l+=`
18
- ${t.error(e.error)}`;return l}function ri(e,t,n){return Xe(t.success("✓"),t.message(n??"Enter a value"),t.success(String(e)))}async function Fn(e={},t){let n=await Uo("input",e,t);if(n.shortCircuited)return n.value;let{promptIO:r}=n;return Je({initialState:{value:"",cursorPos:0,error:null},theme:e.theme,render:(s,o)=>ni(s,o,e.message,e.placeholder,e.default),handleKey:ei(e.schema,e.validate,e.default),renderSubmitted:(s,o,i)=>ri(o,i,e.message)},r)}function si(e){return(t,n)=>{let r=n.choices.length;if(t.name==="return"){let s=n.choices[n.cursor];if(s)return Ye(s.value);return n}if(["up","down","k","j"].includes(t.name)){let s=t.name==="up"||t.name==="k"?-1:1;return{...n,...qo(n.cursor,r,s,n.scrollOffset,e)}}return n}}function oi(e,t,n,r){let s=[`${t.prefix("┃")} ${t.message(n??"Pick an option")}`];return s.push(...Vo(e.choices,e.scrollOffset,r,(o,i)=>{let a=o.hint?` ${t.hint(o.hint)}`:"";return i===e.cursor?`${t.cursor("›")} ${t.selected(o.label)}${a}`:` ${t.unselected(o.label)}${a}`},t.hint)),s.join(`
19
- `)}function ii(e,t,n){let r=t.success("✓"),s=t.message(n??"Pick an option"),o=e.choices[e.cursor],i=o?o.label:"";return Xe(r,s,t.success(i))}async function Ze(e,t){let n=await ti(e,e.default===void 0?[]:[e.default],t);if(n.shortCircuited)return n.value;let{choices:r,cursor:s,maxVisible:o,promptIO:i,scrollOffset:a}=n;return Je({initialState:{cursor:s,choices:r,scrollOffset:a},theme:e.theme,render:(c,l)=>oi(c,l,e.message,o),handleKey:si(o),renderSubmitted:(c,l,u)=>ii(c,u,e.message)},i)}var de=class extends Error{constructor(e){super(e),this.name="Eta Error"}},Dn=class extends de{constructor(e){super(e),this.name="EtaParser Error"}},ai=class extends de{constructor(e){super(e),this.name="EtaRuntime Error"}};var ci=class extends de{constructor(e){super(e),this.name="EtaNameResolution Error"}};function W(e,t,n){let r=t.slice(0,n).split(/\n/),s=r.length,o=r[s-1].length+1;throw e+=" at line "+s+" col "+o+`:
15
+ `)}}}async function ur(e,t,n){let r=t?.argv??process.argv.slice(2),s={...Po,...t?.io},o=new AbortController,i=t?.signal?AbortSignal.any([t.signal,o.signal]):o.signal,a=void 0,c=Ho(t?.io);xe=void 0,process.removeListener("beforeExit",In);let l=async()=>{let d;try{d=ne(e,n)}catch(h){if(nr(h))return process.exitCode=ge,ge;return s.stderr(St(h)),process.exitCode=1,1}let g=Number.NEGATIVE_INFINITY,p=ge,m,w=(h)=>{if(!o.signal.aborted){if(g=performance.now(),!i.aborted)m=h,p=nt[h].exitCode;o.abort(new DOMException(nt[h].message,"AbortError"));return}if(performance.now()-g<Ro)return;if(process.removeListener(h,w),process.listenerCount(h)===0)process.kill(process.pid,h)};for(let h of Cn)if(!J(h))process.on(h,w);let O=tr(s),v,u,f=0;try{await ar({argv:r,env:t?.env},d,O,i,{onEvent:t?.onEvent},(h)=>{v=h},async(h,y)=>{u={error:h};let S=rt(h)!==void 0;return process.exitCode=S?p:1,Nn(h,r,d,O,i,y)})}catch(h){let y;try{if(u&&!Object.is(h,u.error)&&xt(h)&&Object.is(h.suppressed,u.error))y={error:h.error}}catch{}if(y)cr(y.error,O,"Cleanup failed");if(f=rt(h)===void 0?1:p,process.exitCode=f,!u)await Nn(h,r,d,O,i,v),process.exitCode=f}finally{if(!c){let{setImmediate:h}=process.getBuiltinModule("node:timers");await new Promise((y)=>h(y))}for(let h of Cn)process.removeListener(h,w)}if(m===void 0)return f;if(process.exitCode=p,!c&&process.platform!=="win32")xe={name:m,exitCode:p},process.once("beforeExit",In);return p};return await(c?We(s,l,i):mn(i,l))}var b,Xs,eo,kn,Dn,po,L,mt,pt,ht,Qe,xn,Sn,Po,Ro=50,ge=130,nt,Cn,xe,jn,$n;var Ct=T(()=>{le();Q();hn();bn();b=class extends Error{code;details;cause;constructor(e,t,...n){super(t);this.name="CrustError",this.code=e,this.details=n[0]}static[Symbol.hasInstance](e){return Function.prototype[Symbol.hasInstance].call(this,e)}is(e){return Object.is(this.code,e)}withCause(e){return this.cause=e,this}toJSON(){return{code:this.code,message:this.message,details:this.details}}},Xs=/^(0|[1-9]\d*)$/;eo={command:"Command",context:"Context",extension:"Extension"};kn=Symbol("crust.defining");Dn=Symbol.for("crust.contextSources");po={string:"a string",path:"a string",number:"a number",boolean:"a boolean",url:"a URL",json:"a JSON value"};L=Symbol.for("crust.commandDefinition");mt=new WeakMap,pt=new WeakMap,ht=new WeakMap;Qe=new WeakMap;xn=new WeakMap,Sn=new WeakMap;Po={stdout:(e)=>Z(1,`${e}
16
+ `),stderr:(e)=>Z(2,`${e}
17
+ `)};nt={SIGINT:{message:"Interrupted by SIGINT.",exitCode:ge},SIGTERM:{message:"Terminated by SIGTERM.",exitCode:143}},Cn=Object.keys(nt);jn=new WeakMap,$n=new WeakMap});function fr(e){let{existsSync:t,statSync:n}=process.getBuiltinModule("node:fs"),{dirname:r,join:s,resolve:o}=process.getBuiltinModule("node:path"),i=o(e);if(t(i)&&!n(i).isDirectory())i=r(i);while(!0){if(t(s(i,"package.json")))return i;let a=r(i);if(a===i)return null;i=a}}var dr=()=>{};function Jo(){let{Bun:e}=globalThis,t=e?.main??"";return t.startsWith("/$bunfs/")||/^[A-Za-z]:[\\/]~BUN[\\/]/.test(t)||process.getBuiltinModule?.("node:sea")?.isSea()===!0}function qo(){return!0}function It(e){if(e===""||e==="."||e===".."||/[\\/]/.test(e))throw Error(`Artifact name must be a single directory name, got ${JSON.stringify(e)}.`);let{dirname:t,join:n,resolve:r}=process.getBuiltinModule("node:path");if(Jo())return n(t(process.execPath),e);if(qo())return r(process.getBuiltinModule("node:url").fileURLToPath(import.meta.url),"..","..",e);let s=process.env[Go];if(s)return n(s,e);let o=process.argv[1],i=o;if(o)try{i=process.getBuiltinModule("node:fs").realpathSync(o)}catch(c){throw Error(`Could not resolve artifact "${e}": could not resolve source entrypoint "${o}".`,{cause:c})}let a=i?fr(i):null;if(!a)throw Error(`Could not resolve artifact "${e}": no package.json was found above ${o?`entrypoint "${o}"`:"process.argv[1] (unset)"}.`);return n(a,".crust","root",e)}var Go="CRUST_INTERNAL_BUILD_OUT_DIR";var mr=T(()=>{dr()});function gr(e){let t=Object.freeze(ot(e.flags));ot(e.provide.flatMap((i)=>Object.entries(i.ownedFlags)),t);let n=Object.freeze({id:e.id,flags:t,commands:Object.freeze([...e.commands]),use:Object.freeze([...e.use]),provide:Object.freeze([...e.provide]),hooks:Object.freeze({...e.hooks}),handlers:Object.freeze({...e.handlers}),...e.sections?{sections:e.sections}:{},...e.build?{build:e.build}:{}}),r=(i)=>gr({...e,...i}),s={id:e.id,use:(...i)=>r({use:[...e.use,...i.map(M)]}),provide:(...i)=>r({provide:[...e.provide,...i.map(M)]}),flags:(i)=>r({flags:[...e.flags,...st(i).map(([a,c])=>[a,Ee(c,"flag",a)])]}),add:(...i)=>r({commands:[...e.commands,...i]}),setup:(i)=>r({hooks:{...e.hooks,setup:i}}),renderer:(i)=>r({hooks:{...e.hooks,renderer:i}}),preRun:(i)=>r({hooks:{...e.hooks,preRun:i}}),handle:(i,a,c={})=>{if(!Object.hasOwn(t,i))throw new b("DEFINITION",`Extension "${e.id}" handles flag "--${i}", which it does not own`,{subject:"extension",name:e.id,reason:"unknown-handle-flag"});return r({handlers:{...e.handlers,[i]:{eager:c.eager??!1,run:a}}})},noAction:(i)=>r({hooks:{...e.hooks,noAction:i}}),postRun:(i)=>r({hooks:{...e.hooks,postRun:i}}),onError:(i)=>r({hooks:{...e.hooks,onError:i}}),sections:(i)=>r({sections:i}),build:(i)=>r({build:i}),factory:(i)=>Object.assign((...a)=>{let c=i(o,...a),l=M(c).id;if(l!==e.id)throw new b("DEFINITION",`Extension factory "${e.id}" returned Extension "${l}"; return an Extension built from the handle it receives`,{subject:"extension",name:e.id,reason:"factory-id-mismatch"});return c},{id:e.id})},o=Fn(s,n);return o}function $t(e){return gr({id:e,use:[],provide:[],flags:[],commands:[],hooks:{},handlers:{}})}function Nt(e){if(!e||e!==e.trim())throw new b("DEFINITION","Extension id must be a non-empty, trimmed string",{subject:"extension",reason:"empty-id"});return e}function Ko(e){let t=e.addedChildren,n=t===void 0?void 0:jt.get(t);if(n!==void 0)return jt.delete(t),n;let r=new Set;for(let{meta:s}of te(e)){r.add(s.name);for(let o of s.aliases??[])r.add(o)}return r}function re(e,t,n){let r=e[L],s=e.name,o=n?`Extension "${n}" command "${s}"`:`Command "${s}"`,i=(d)=>({subject:n?"extension":"command",name:n??s,reason:d}),a=new je(s);if(r.inline){for(let[d,g]of Object.entries(t.ownedFlags))R(a._node,d,g,"owned");a._node.flagContexts=t.flagContexts,a._node.inheritedDemands=[...t.inheritedDemands,...ee(t.demands)]}a._node.contexts=t.contexts.map((d)=>({...d}));let c=r.recipe(a);if(!(c instanceof je)||c._ancestorOwnedFlags!==a._ancestorOwnedFlags)throw new b("DEFINITION",`${o} definition must return the same command builder it received`,i("foreign-command-builder"));if(c._node.extensions.length>0)throw new b("DEFINITION",`${o} cannot register Extensions inside command definitions`,i("nested-command-extension"));let l=bt(c._node);return Ce(l.contexts.map(({instance:d})=>d),l.demands),l.meta={name:s,...r.meta},l}function br(e,t=[]){if(e.trim()==="")throw new b("DEFINITION","Command name must be a non-empty string",{subject:"command",name:e,reason:"empty-name"});if(e==="__proto__")throw new b("DEFINITION",'Command name "__proto__" is reserved',{subject:"command",name:e,reason:"reserved-name"});if(t.includes(e))throw new b("DEFINITION",`Command "${e}" must not list its own canonical name as an alias`,{subject:"command",name:e,reason:"alias-collision"});return e}function pr(e,t=[]){if(br(e,t),!Se(e))throw new b("DEFINITION",`Command name "${e}" must not contain whitespace or start with "-"`,{subject:"command",name:e,reason:"invalid-name"});return e}function Xo(e){return typeof e==="function"}function wr(e,t,n){let r=!Xo(t),s=r?t:{},o=r?n:t,i=pr(e,s.aliases);for(let m of s.aliases??[])if(!Se(m))throw new b("DEFINITION",`Command "${i}" has an invalid alias "${m}"`,{subject:"command",name:i,reason:"invalid-alias"});let{sections:a,version:c,...l}=s,d={...l,...s.aliases?{aliases:[...s.aliases]}:{},...a?{sections:lt(i,a)}:{}},g={name:i,recipe:o,meta:d},p=(m)=>Object.freeze({name:m,as:(w)=>p(pr(w,d.aliases)),[L]:Object.freeze({...g,name:m})});return p(i)}function Zo(e){return e.filter((t,n)=>e.findLastIndex((r)=>r.id===t.id)===n)}async function hr(e,t,n){let r=n[0]??{},s=n[1];return await lr(e,{path:t,input:r},s,re)}var jt,je=class{_node;_ancestorOwnedFlags;constructor(e,...t){let n=t[0]??{},r=br(e);if(this._node=Hn(r),n.description!==void 0)this._node.meta.description=n.description;if(n.version!==void 0)this._node.meta.version=n.version;if(n.usage!==void 0)this._node.meta.usage=n.usage;if(n.sections!==void 0)this._node.meta.sections=lt(r,n.sections);this._ancestorOwnedFlags={}}_clone(e){let t=Object.create(Object.getPrototypeOf(this));return t._node={...this._node,...e},t._ancestorOwnedFlags=this._ancestorOwnedFlags,t}flags(e){let t=this._clone(K(this._node));for(let[n,r]of st(e))R(t._node,n,r,"local");return t}args(...e){let t=[...this._node.args,...e.map(An)],n=new Set;for(let[r,s]of t.entries()){if(n.has(s.name))throw new b("DEFINITION",`Argument name "${s.name}" is already defined`,{subject:"argument",name:s.name,reason:"duplicate-arg"});n.add(s.name);let o=r===t.length-1;if(s.afterDoubleDash===!0&&!o)throw new b("DEFINITION",`Only the last positional argument can take the tokens after "--"; "${s.name}" is not last`,{subject:"argument",name:s.name,reason:"after-double-dash-position"});let i=r===t.length-2&&t.at(-1)?.afterDoubleDash===!0;if(s.variadic===!0&&!o&&!i)throw new b("DEFINITION",`Only the last positional argument can be variadic; "${s.name}" is not last`,{subject:"argument",name:s.name,reason:"variadic-position"})}return this._clone({args:t})}use(...e){let t=[],n=[];for(let s of e){if("contextName"in s){t.push(M(s));continue}if(typeof s==="function"){n.push(s.id);for(let{instance:a,extension:c}of this._node.contexts)if(c===s.id)t.push(a);continue}let{id:o,provide:i}=M(s);n.push(o),t.push(...i)}let r=this._clone({...K(this._node),demands:[...this._node.demands,...t],usedExtensions:[...this._node.usedExtensions,...n]});return ft(r._node,ee(t)),r}provide(...e){let t=e.map(M);Ce([...this._node.extensions.flatMap((o)=>o.provide),...this._node.contexts.map(({instance:o})=>o),...t],t);let n=this._clone({...K(this._node),contexts:[...this._node.contexts,...t.map((o)=>({instance:o}))],providedContexts:[...this._node.providedContexts,...t]}),r=Gn([...this._node.inheritedDemands,...ee(this._node.demands)]),s;for(let o of t){let i=Object.keys(o.ownedFlags);if(i.length===0||r.has(o.name))continue;for(let a of i)R(n._node,a,o.ownedFlags[a],"owned");s??=new Map(this._node.flagContexts),s.set(o.name,[...s.get(o.name)??[],...i])}if(s)n._node.flagContexts=s;return n}output(e){return this._clone({outputSchema:e})}action(e){return this._clone({run:e})}extend(...e){let t=e.map(M),n=Zo([...this._node.extensions,...t]),r=new Map(this._node.extensionPositions);for(let s of t)r.set(s.id,this._node.contexts.length);return this._clone({extensions:n,extensionPositions:r})}add(...e){return this._addDefinitions(e)}command(e,t,n){let r=wr(e,t,n),s=Object.freeze({...r[L],inline:!0});return this._addDefinitions([{...r,[L]:s}])}_addDefinitions(e){let t=this._node.addedChildren,n=Ko(this._node),r=this._node;for(let s of e){let o=[s.name,...s[L].meta.aliases??[]];if(o.some((a)=>n.has(a)))throw new b("DEFINITION",`Command name "${s.name}" is already registered on this command`,{subject:"command",name:s.name,reason:"command-collision"});let i;t={name:s.name,meta:{name:s.name,...s[L].meta},resolve:()=>i??=re(s,r),next:t,definition:s,parent:r};for(let a of o)n.add(a)}if(t!==void 0)jt.set(t,n);return this._clone({addedChildren:t})}async snapshot(){return vt(ne(this._node,re).rootNode)}async run(e,...t){return await hr(this._node,e,t)}at(e){Et(ne(this._node,re).rootNode,e);let t=this._node,n=Object.freeze([...e]);return{path:n,async run(...r){return await hr(t,n,r)}}}async execute(e){return await ur(this._node,e,re)}};var _t=T(()=>{Ct();mr();jt=new WeakMap});function Qo(e){return typeof e==="number"&&!Number.isFinite(e)}function ei(e){if(Qo(e))return String(e);if(Array.isArray(e))return e.map(String).join(", ");return JSON.stringify(e)??String(e)}function At(e,t,n,r=(o)=>o,s){let o=e?[e]:[];if(s!==void 0)o.push(r(`[env: ${s}]`));if(t!==void 0)o.push(r(`[default: ${ei(t)}]`));if(n?.length)o.push(r(`[choices: ${n.join(", ")}]`));return o.join(" ")}function ti(e){if(e.afterDoubleDash){let n=`-- <${e.name}>${e.variadic?"...":""}`;return e.required?n:`[${n}]`}let t=e.variadic?`${e.name}...`:e.name;return e.required?`<${t}>`:`[${t}]`}function ni(e){return Object.entries(e).map(([t,n])=>{let r=[t,...n.aliases??[]];return Object.freeze({name:t,spellings:Object.freeze([...n.short?[`-${n.short}`]:[],...r.flatMap((s)=>s.length===1?[`-${s}`]:[]),...r.map((s)=>`--${s}`),...n.negatable?r.map((s)=>`--no-${s}`):[]]),short:n.short,aliases:Object.freeze([...n.aliases??[]]),negatable:n.negatable,type:n.type,description:n.description,required:n.required===!0,multiple:n.multiple===!0,choices:n.choices,default:n.default,env:n.env,delimiter:n.delimiter})})}function Tt(e,t=[e.meta.name]){let n=e.args.map((d)=>Object.freeze({...d,token:ti(d),required:d.required===!0,variadic:d.variadic===!0,afterDoubleDash:d.afterDoubleDash===!0})),r=n.at(-1)?.afterDoubleDash===!0?n.slice(-1):[],s=n.slice(0,n.length-r.length),o=(d)=>d.map((g)=>({kind:"arg",text:g.token,required:g.required})),i=Object.entries(e.subCommands).flatMap(([d,g])=>at(g)?[Tt(g,[...t,d])]:[]),a=ni(e.flags),c=e.meta.usage?[{kind:"custom",text:e.meta.usage}]:[{kind:"path",text:t.join(" ")},...i.length>0&&!e.hasAction?[{kind:"command",text:"<command>"}]:[],...o(s),...a.length>0?[{kind:"options",text:"[options]"}]:[],...o(r)],l=c.map((d)=>d.text).join(" ");return Object.freeze({name:e.meta.name,path:Object.freeze([...t]),description:e.meta.description,aliases:Object.freeze([...e.meta.aliases??[]]),usage:l,usageSegments:Object.freeze(c.map((d)=>Object.freeze(d))),hasAction:e.hasAction,args:Object.freeze(n),flags:Object.freeze(a),sections:Object.freeze([...e.meta.sections??[]]),children:Object.freeze(i)})}function yr(e){return ri.test(e)}var ri,vr='letters, digits, ".", "_", and "-", starting with a letter or digit';var kt=T(()=>{Ct();ri=/^[A-Za-z0-9][A-Za-z0-9._-]*$/});function Er(e){let t=[...V];V.clear(),Ir();for(let n of t)n.onSignal(e);if(process.listenerCount(e)===0)process.kill(process.pid,e)}function Cr(){for(let e of V)e.onExit()}function Ir(){for(let e of Sr)process.removeListener(e,Er);process.removeListener("exit",Cr)}function si(e){if(V.size===0){for(let t of Sr)if(!J(t))process.prependListener(t,Er);process.on("exit",Cr)}return V.add(e),()=>{if(V.delete(e)&&V.size===0)Ir()}}function ii(e){let t=e.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\"");return t=t.replace(/(?=(\\+?)?)\1$/g,"$1$1"),t=`"${t}"`.replace(Dt,"^$1"),t.replace(Dt,"^$1")}function ai(e,t,n,r=process.platform){if(n||r!=="win32"||!/\.(cmd|bat)$/i.test(e))return null;let s=process.getBuiltinModule("node:path").win32.normalize(e);for(let[i,a]of[s,...t].entries())if(oi.test(a)){let c=i===0?"command":`argument ${i}`;throw Error(`Windows command shim ${c} ${JSON.stringify(a)} contains unsafe shell characters`)}let o=[s.replace(Dt,"^$1"),...t.map(ii)].join(" ");return{command:process.env.ComSpec??"cmd.exe",args:["/d","/s","/c",`"${o}"`],windowsVerbatimArguments:!0}}function Ft(e){if(e.pid===void 0)return;if(process.platform==="win32"){if(e.exitCode===null&&e.signalCode===null){let{spawnSync:t}=process.getBuiltinModule("node:child_process"),n=t("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore",timeout:1e4});if(n.error||n.status!==0)e.kill("SIGKILL")}return}try{process.kill(-e.pid,"SIGKILL")}catch(t){if(q(t)&&t.code==="ESRCH")return;throw e.kill("SIGKILL"),t}}async function se(e,t=[],n={}){n.signal?.throwIfAborted();let r=ai(e,t,n.shell),s=(n.stdio??"collect")==="collect",o=s&&n.stdout!=="ignore",i=n.timeout!==void 0&&process.platform!=="win32",{spawn:a}=process.getBuiltinModule("node:child_process"),c=a(r?.command??e,r?.args??t,{cwd:n.cwd,env:n.env,shell:n.shell,stdio:s?["ignore",o?"pipe":"ignore","pipe"]:"inherit",detached:i,windowsVerbatimArguments:r?.windowsVerbatimArguments}),l=[e,...t].join(" "),d,g=new Promise((h,y)=>{d=(S,I)=>{let E=Error(S);try{Ft(c)}catch(x){E=Error(`Process-tree cleanup failed after ${I}.`,{cause:x})}c.stdout?.destroy(),c.stderr?.destroy(),y(E)}}),p=n.timeout,m=p===void 0?void 0:setTimeout(()=>d(`${l} did not exit within ${p} ms and was killed.`,"timeout"),p),w=i?si({onSignal:(h)=>d(`${l} was interrupted by ${h}.`,h),onExit:()=>{try{Ft(c)}catch{}}}):()=>{},O,v=()=>{try{if(i||process.platform==="win32")Ft(c);else c.kill("SIGTERM"),O=setTimeout(()=>c.kill("SIGKILL"),5000)}catch{}};n.signal?.addEventListener("abort",v,{once:!0});let{text:u}=process.getBuiltinModule("node:stream/consumers"),{once:f}=process.getBuiltinModule("node:events");try{let[h,y,[S]]=await Promise.race([Promise.all([o?u(c.stdout):"",s?u(c.stderr):"",f(c,"close")]),g]);return n.signal?.throwIfAborted(),{exitCode:S,stdout:h,stderr:y}}finally{clearTimeout(m),clearTimeout(O),w(),n.signal?.removeEventListener("abort",v)}}function xr(e){let{accessSync:t,constants:n,statSync:r}=process.getBuiltinModule("node:fs");try{return t(e,n.X_OK),r(e).isFile()}catch{return!1}}function Pt(e){let{delimiter:t,extname:n,join:r,resolve:s,sep:o}=process.getBuiltinModule("node:path");if(e.includes(o)||e.includes("/"))return xr(e)?e:null;let i=process.platform==="win32"&&!n(e)?(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";"):[""];for(let a of process.env.PATH?.split(t)??[])for(let c of i){let l=s(r(a,e+c));if(xr(l))return l}return null}var Sr,V,oi,Dt;var jr=T(()=>{ue();le();Sr=["SIGINT","SIGTERM","SIGHUP","SIGQUIT"],V=new Set;oi=/[\0\r\n"%!^`<>&|]/,Dt=/([()\][%!^"`<>&|;, *?])/g});function $r(e){if(e?.startsWith("bun"))return"bun";if(e?.startsWith("pnpm"))return"pnpm";if(e?.startsWith("yarn"))return"yarn";if(e?.startsWith("npm"))return"npm";return null}var Nr=()=>{};function $i(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=94176&&e<=111355||e>=127488&&e<=127743||e>=131072&&e<=262141)}function Ni(e){return Ci.test(String.fromCodePoint(e))||e>=4448&&e<=4607||e>=55216&&e<=55295}function _i(e){if(!Br.test(e))return e.length;let t=e.replace(ji,"");if(!Br.test(t))return t.length;zr??=new Intl.Segmenter(void 0,{granularity:"grapheme"});let n=0;for(let{segment:r}of zr.segment(t)){if(Ii.test(r)){let s=r.codePointAt(0);n+=r.length===2&&s>=127462&&s<=127487?1:2;continue}for(let s of r){let o=s.codePointAt(0);if(Ni(o))continue;n+=$i(o)?2:1;break}}return n}function z(e){return globalThis.Bun?.stringWidth(e,{countAnsiEscapeCodes:!1})??_i(e)}function Wr(e,t,n=" "){let r=z(e);if(r>=t)return e;return e+n.repeat(t-r)}function Ti(e){return Object.hasOwn(Vr,e)}function oe(e,t,n){return e!==void 0&&t in e?e[t]:n}function Jr(e){return(e!==void 0&&"isTTY"in e?e.isTTY:process.stdout?.isTTY)??!1}function qr(e){return oe(e,"forceColor",process.env.FORCE_COLOR)}function Yr(e){return e==="0"||e==="false"}function Kr(e){return e?.toLowerCase()==="dumb"}function ki(e){let t=e.toLowerCase();return t.includes("24bit")||t.includes("truecolor")||t.endsWith("-direct")}function Fi(e,t){if(e!==void 0){let n=e.toLowerCase();if(n==="truecolor"||n==="24bit")return!0}return t!==void 0&&ki(t)}function Ur(e,t){if(Fi(e,t))return"truecolor";if(t!==void 0&&t.toLowerCase().includes("256color"))return"256";return"16"}function Xr(e,t){if(e==="never")return"none";if(e==="always")return"truecolor";let n=oe(t,"colorTerm",process.env.COLORTERM),r=oe(t,"term",process.env.TERM),s=qr(t);if(s!==void 0){if(Yr(s))return"none";if(s==="1")return"16";if(s==="2")return"256";if(s==="3")return"truecolor";return Ur(n,r)}if(!Jr(t))return"none";let o=oe(t,"noColor",process.env.NO_COLOR);if(o!==void 0&&o!=="")return"none";if(Kr(r))return"none";return Ur(n,r)}function Zr(e,t){if(e==="always")return!0;if(e==="never")return!1;let n=qr(t);if(n!==void 0)return!Yr(n);return Jr(t)&&!Kr(oe(t,"term",process.env.TERM))}function Di(e,t){if(e==null)return"";let n=String(e);if(n==="")return"";let{open:r,close:s}=t;if(n.includes(s))n=n.replaceAll(s,s+r);return r+n+s}function Pi(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)}function Ri(e,t){if(!Pi(e))return e;let n="";for(let r=0;r<e.length;r++)if(n+=e[r]??"",r<t.length)n+=String(t[r]);return n}function Bt(e,t){return(n,...r)=>{let s=Ri(n,r);return t()?Di(s,e):s==null?"":String(s)}}function $e(e){let t=e?.mode??"auto",n=Zr(t,e?.overrides),r=Xr(t,e?.overrides)!=="none",s=()=>n,o=()=>r;return Object.freeze(Object.fromEntries(Gr.map((i)=>[i,Bt(Ai[i],Ti(i)?s:o)])))}function Qr(e,t){return Bt({open:`\x1B[${e}m`,close:`\x1B[${t}m`},zi)}function ie(e,t){return Bt({open:`\x1B[${e}m`,close:`\x1B[${t}m`},Bi)}var zr,Br,Ci,Ii,ji,Vr,Hr,Gr,Ai,Mi="\x1B]",Li="\x1B\\",Jc,zi=()=>Zr("auto"),Bi=()=>Xr("auto")!=="none",Ne,H,Ut,es,B,P,G;var _e=T(()=>{Br=/[^\x20-\x7e]/,Ci=/[\p{Cc}\p{Cf}\p{Mn}\p{Me}]/u,Ii=/\p{Emoji_Presentation}|\p{Emoji}\uFE0F/u,ji=new RegExp([String.raw`(?:\x1b\[|\x9b)[^\x1b\x18\x1a\x9c\x40-\x7e]*[\x40-\x7e\x18\x1a\x9c]?`,String.raw`(?:\x1b\]|\x9d)[^\x07\x1b\x18\x1a\x9c]*(?:\x07|\x1b\\|[\x18\x1a\x9c])?`,String.raw`(?:\x1b[PX^_]|[\x90\x98\x9e\x9f])[^\x1b\x18\x1a\x9c]*(?:\x1b\\|[\x18\x1a\x9c])?`,String.raw`\x1b[\x20-\x2f][^\x1b]?`,String.raw`\x1b[\x18\x1a\x9c\x30-\x7e]?`].join("|"),"g");Vr={bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},Hr=Object.assign({},Vr,{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBrightBlack:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49]}),Gr=Object.freeze(Object.keys(Hr)),Ai=Object.freeze(Object.fromEntries(Gr.map((e)=>{let[t,n]=Hr[e];return[e,{open:`\x1B[${t}m`,close:`\x1B[${n}m`}]})));Jc=`${Mi}8;;${Li}`;Ne=ie(31,39),H=ie(32,39),Ut=ie(33,39),es=ie(35,39),B=ie(36,39),P=Qr(1,22),G=Qr(2,22)});function ts(e,t){return t?Ut(e):G(Ut(e))}function Hi(e){switch(e.kind){case"path":case"custom":return H(e.text);case"command":case"options":return B(e.text);case"arg":return ts(e.text,e.required)}}function Wt(e,t,n){if(n.length===0)return[];let r=Math.max(t,...n.map(([s])=>z(s)+1));return[P(B(`${e}:`)),...n.map(([s,o])=>` ${Wr(s,r)} ${o}`.trimEnd())]}function Gi(e){let t=H(e.name);return e.aliases.length===0?t:`${t} (${e.aliases.join(", ")})`}function ns(e,t,n){let r=Tt({...e,subCommands:Object.fromEntries(Object.entries(e.subCommands).map(([i,{meta:a}])=>[i,{meta:{name:a.name,description:a.description,aliases:a.aliases,hidden:a.hidden},hasAction:!1,args:[],flags:{},subCommands:{}}]))},t),s=r.path.join(" "),o=[r.description?`${P(s)} - ${G(r.description)}`:P(s),"",P(B("Usage:")),` ${r.usageSegments.map(Hi).join(" ")}`];for(let i of[Wt("Commands",Vi,r.children.map((a)=>[Gi(a),a.description??""])),Wt("Arguments",Wi,r.args.map((a)=>[ts(a.token,a.required),At(a.description,a.default,a.choices,G)])),Wt("Options",Ui,r.flags.map((a)=>[B(a.spellings.join(", ")+(a.type==="boolean"?"":` <${a.type}>`)),At(a.description,a.default,a.choices,G,a.env?.name)]))])if(i.length>0)o.push("",...i);for(let i of ct(r.sections,n))o.push("",P(B(`${i.title}:`)),...i.body.split(`
18
+ `).map((a)=>` ${a}`));return o.join(`
19
+ `)}var Ui=28,Wi=18,Vi=10;var rs=T(()=>{kt();_e()});import*as U from"node:readline";function gs(e){return{prefix:e.cyan,message:e.bold,placeholder:e.dim,cursor:e.cyan,selected:e.cyan,unselected:e.dim,error:e.red,success:e.green,hint:e.dim,filterMatch:e.cyan}}function aa(e){if((e.isTTY??!1)===(process.stdout?.isTTY??!1))return ia;return gs($e({overrides:{isTTY:e.isTTY}}))}function ke(e){let t=pe();return{input:e?.input??t?.input??process.stdin,output:e?.output??t?.output??process.stderr,signal:e?.signal??Y()}}function Zt(e){return{[Xt]:e}}function ua(e,t){let n=e.split(`
20
+ `),r=0;for(let s of n){let o=z(s);r+=o===0?1:Math.ceil(o/t)}return r}function Kt(e=ke().input){return!!e.isTTY}function ms(e=ke().input){if(!Kt(e))throw new fa}function da(e){return typeof e==="object"&&e!==null&&Xt in e}function Qt(e,t){let{render:n,handleKey:r,initialState:s,renderSubmitted:o}=e,{input:i,output:a,signal:c}=ke(t),l={...aa(a),...e.theme},d=a;return new Promise((g,p)=>{if(c?.aborted){p(c.reason);return}if(qt.has(i)||Yt.has(a)){p(Error("Cannot run multiple prompts concurrently on the same input or output stream. Await each prompt before starting the next."));return}ms(i),ms(a),qt.add(i),Yt.add(a);let m=s,w=0,O=!1,v=!1;function u(){if(O)return;if(O=!0,process.removeListener("exit",u),c?.removeEventListener("abort",E),qt.delete(i),Yt.delete(a),i.removeListener("keypress",x),v)i.setRawMode?.(!1);i.pause(),a.write(la)}function f(j){let C=a.columns||80;if(w>0)U.cursorTo(d,0),U.moveCursor(d,0,-(w-1)),U.clearScreenDown(d);a.write(j),w=ua(j,C)}let h=Promise.resolve(),y=null;function S(){if(y!==null)return;y=setTimeout(()=>{if(y=null,O)return;try{f(n(m,l))}catch(j){u(),p(j)}},0)}function I(){if(y!==null)clearTimeout(y),y=null}function E(){I(),a.write(`
21
+ `),u(),p(c?.reason)}function x(j,C){if(C?.ctrl&&C.name==="c"){I(),a.write(`
22
+ `),u(),p(new DOMException("Prompt was cancelled.","AbortError"));return}let W={char:j??"",name:C?.name==="enter"?"return":C?.name??"",ctrl:C?.ctrl??!1,meta:C?.meta??!1,shift:C?.shift??!1};h=h.then(async()=>{if(O)return;try{let D=await r(W,m);if(O)return;if(da(D)){I();let N=D[Xt];if(o)f(o(m,N,l));a.write(`
23
+ `),u(),g(N)}else m=D,S()}catch(D){I(),u(),p(D)}})}try{if(U.emitKeypressEvents(i),i.setRawMode)i.setRawMode(!0),v=!0;i.resume(),a.write(ca),process.once("exit",u),f(n(m,l)),i.on("keypress",x),c?.addEventListener("abort",E,{once:!0})}catch(j){u(),p(j)}})}async function ma(e,t){let n=await e["~standard"].validate(t),r=n.issues?.[0];if(r)return{ok:!1,error:r.message||"Validation failed"};if("value"in n)return{ok:!0,value:n.value};return{ok:!1,error:"Validation failed"}}async function ws(e,t,n){if(t)return ma(t,e);if(n)try{await n(e)}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Validation failed"}}return{ok:!0,value:e}}async function Te(e,t,n){if(e.initial!==void 0)return{shortCircuited:!0,value:n?await n(e.initial,"initial"):e.initial};let r=ke(t);if(!(Kt(r.input)&&Kt(r.output))&&e.default!==void 0)return{shortCircuited:!0,value:n?await n(e.default,"default"):e.default};return{shortCircuited:!1,promptIO:r}}async function pa(e,t,n){if(t.schema!==void 0&&t.validate!==void 0)throw Error(`${e}() cannot combine "schema" with "validate"`);let{schema:r,validate:s}=t;if(!r&&!s)return Te(t,n);return Te(t,n,async(o,i)=>{let a=await ws(o,r,s);if(!a.ok)throw Error(`${i} value rejected${r?" by schema":""}: ${a.error}`);return a.value})}function en(e,t,n){let r=[e];if(t)r.push(t);if(n)r.push(n);return r.join(" ")}function vs(e,t,n,r){let s=t?`${e} ${t}`:e,o=r??"";if(t)return`${s}${o}
24
+ ${n}`;return`${s}${o} ${n}`}function ha(e,t,n,r,s){let o=Math.min(e.length,n),i=[];if(t>0)i.push(s("..."));for(let a=t;a<t+o;a++){let c=e[a];if(c===void 0)break;i.push(r(c,a))}if(t+o<e.length)i.push(s("..."));return i}function ys(e,t,n,r){let s=Math.min(n,r);if(s===0)return 0;if(e<t)return e;if(e>=t+s)return e-s+1;return t}function ga(e,t,n,r,s){if(t===0)return{cursor:0,scrollOffset:0};let o=n===-1?e<=0?t-1:e-1:e>=t-1?0:e+1;return{cursor:o,scrollOffset:ys(o,r,t,s)}}function ba(e){return e.map((t)=>{if(typeof t==="string")return{label:t,value:t};return t})}function wa(e,t){if(e.name==="return")return Zt(t.value);if(e.name==="left"||e.name==="right"||e.name==="tab")return{value:!t.value};if(e.name==="h"||e.char==="y"||e.char==="Y")return{value:!0};if(e.name==="l"||e.char==="n"||e.char==="N")return{value:!1};return t}function ya(e,t,n,r,s){let o=t.prefix("┃"),i=t.message(n??"Are you sure?"),a=e.value?`${t.selected("●")} ${t.selected(r)}`:`${t.unselected("○")} ${t.unselected(r)}`,c=e.value?`${t.unselected("○")} ${t.unselected(s)}`:`${t.selected("●")} ${t.selected(s)}`;return vs(o,i,`${a}${va}${c}`)}function Oa(e,t,n,r,s){let o=t.success("✓"),i=t.message(n??"Are you sure?"),a=e?r:s;return en(o,i,t.success(a))}async function Fe(e,t){let n=await Te(e,t);if(n.shortCircuited)return n.value;let{promptIO:r}=n,s=e.active??"Yes",o=e.inactive??"No";return Qt({initialState:{value:e.default??!0},theme:e.theme,render:(i,a)=>ya(i,a,e.message,s,o),handleKey:wa,renderSubmitted:(i,a,c)=>Oa(a,c,e.message,s,o)},r)}function xa(e,t,n,r){if(e==="")return r?n.placeholder(r):n.cursor("│");return`${e.slice(0,t)}${n.cursor("│")}${e.slice(t)}`}function ps(e,t){return(e.codePointAt(t)??0)>65535?2:1}function hs(e,t){return t>=2&&(e.codePointAt(t-2)??0)>65535?2:1}function Sa(e){let t=e.codePointAt(0);return t!==void 0&&e.length===(t>65535?2:1)&&(t<55296||t>57343)&&t>=32&&(t<127||t>159)}function Ea(e,t,n){if(e.name==="backspace"){if(n===0)return{text:t,cursorPos:n};let r=n-hs(t,n);return{text:t.slice(0,r)+t.slice(n),cursorPos:r}}if(e.name==="delete"){if(n>=t.length)return{text:t,cursorPos:n};let r=n+ps(t,n);return{text:t.slice(0,n)+t.slice(r),cursorPos:n}}if(e.name==="left"){if(n===0)return{text:t,cursorPos:n};return{text:t,cursorPos:n-hs(t,n)}}if(e.name==="right"){if(n>=t.length)return{text:t,cursorPos:n};return{text:t,cursorPos:n+ps(t,n)}}if(e.name==="home")return{text:t,cursorPos:0};if(e.name==="end")return{text:t,cursorPos:t.length};if(Sa(e.char)&&!e.ctrl&&!e.meta){let r=t.slice(0,n),s=t.slice(n);return{text:r+e.char+s,cursorPos:n+e.char.length}}return null}function Ca(e,t,n){return async(r,s)=>{if(r.name==="return"){let i=await ws(s.value===""&&n!==void 0?n:s.value,e,t);return i.ok?Zt(i.value):{...s,error:i.error}}let o=Ea(r,s.value,s.cursorPos);return o?{value:o.text,cursorPos:o.cursorPos,error:null}:s}}async function Ia(e,t,n){let r=await Te(e,n);if(r.shortCircuited)return r;let s=ba(e.choices),o=e.maxVisible??10,i=new Set(t.flatMap((l)=>{let d=s.findIndex((g)=>g.value===l);return d===-1?[]:[d]})),a=t.length===0?-1:s.findIndex((l)=>l.value===t[0]),c=a===-1?0:a;return{shortCircuited:!1,choices:s,maxVisible:o,cursor:c,scrollOffset:ys(c,0,s.length,o),selected:i,promptIO:r.promptIO}}function ja(e,t,n,r,s){let o=t.prefix("┃"),i=t.message(n??"Enter a value"),a=r??s,c=s!==void 0&&r!==void 0&&e.value===""?` ${t.hint(`(${s})`)}`:"",l=vs(o,i,xa(e.value,e.cursorPos,t,a),c);if(e.error!==null)l+=`
25
+ ${t.error(e.error)}`;return l}function $a(e,t,n){return en(t.success("✓"),t.message(n??"Enter a value"),t.success(e))}async function Os(e={},t){let n=await pa("input",e,t);if(n.shortCircuited)return n.value;let{promptIO:r}=n;return Qt({initialState:{value:"",cursorPos:0,error:null},theme:e.theme,render:(s,o)=>ja(s,o,e.message,e.placeholder,e.default),handleKey:Ca(e.schema,e.validate,e.default),renderSubmitted:(s,o,i)=>$a(s.value===""&&e.default!==void 0?e.default:s.value,i,e.message)},r)}function Na(e){return(t,n)=>{let r=n.choices.length;if(t.name==="return"){let s=n.choices[n.cursor];if(s)return Zt(s.value);return n}if(["up","down","k","j"].includes(t.name)){let s=t.name==="up"||t.name==="k"?-1:1;return{...n,...ga(n.cursor,r,s,n.scrollOffset,e)}}return n}}function _a(e,t,n,r){let s=[`${t.prefix("┃")} ${t.message(n??"Pick an option")}`];return s.push(...ha(e.choices,e.scrollOffset,r,(o,i)=>{let a=o.hint?` ${t.hint(o.hint)}`:"";return i===e.cursor?`${t.cursor("›")} ${t.selected(o.label)}${a}`:` ${t.unselected(o.label)}${a}`},t.hint)),s.join(`
26
+ `)}function Aa(e,t,n){let r=t.success("✓"),s=t.message(n??"Pick an option"),o=e.choices[e.cursor],i=o?o.label:"";return en(r,s,t.success(i))}async function tn(e,t){let n=await Ia(e,e.default===void 0?[]:[e.default],t);if(n.shortCircuited)return n.value;let{choices:r,cursor:s,maxVisible:o,promptIO:i,scrollOffset:a}=n;return Qt({initialState:{cursor:s,choices:r,scrollOffset:a},theme:e.theme,render:(c,l)=>_a(c,l,e.message,o),handleKey:Na(o),renderSubmitted:(c,l,d)=>Aa(c,d,e.message)},i)}var ia,Xt,qt,Yt,bs="\x1B[",ca,la,fa,va=" · ";var xs=T(()=>{_e();Q();ia=gs({bold:P,cyan:B,dim:G,green:H,red:Ne});Xt=Symbol("submit");qt=new WeakSet,Yt=new WeakSet,ca=`${bs}?25l`,la=`${bs}?25h`;fa=class extends Error{constructor(e){super(e??"Prompts require an interactive terminal (TTY).");this.name="NonInteractiveError"}}});_t();kt();import{existsSync as ks,readdirSync as Za}from"node:fs";import{basename as Ds,dirname as Fs,isAbsolute as Qa,join as ec,resolve as Ps}from"node:path";ue();import{existsSync as ci,lstatSync as Fr,mkdirSync as _r,readFileSync as li,readdirSync as Dr,realpathSync as Mt,statSync as Pr,writeFileSync as ui}from"node:fs";import{dirname as Rr,join as X,resolve as Ar,sep as fi}from"node:path";import{fileURLToPath as di}from"node:url";function Or(e,t){let{isAbsolute:n,relative:r,sep:s}=process.getBuiltinModule("node:path"),o=r(e,t);return o===""||!n(o)&&o!==".."&&!o.startsWith(`..${s}`)}jr();Q();Nr();import{spawn as mi,spawnSync as pi}from"node:child_process";import{once as hi}from"node:events";function gi(e,t){return e.replace(/\{\{\s*(\w+)\s*\}\}/g,(n,r)=>Object.hasOwn(t,r)?t[r]??n:n)}function bi(e){let t=Rr(e),n=e.slice(t==="."?0:t.length+1);if(n.startsWith("_")&&!n.startsWith("__")){let r=`.${n.slice(1)}`;return t==="."?r:X(t,r)}return e}function wi(e){return Pr(e,{throwIfNoEntry:!1})?.isDirectory()===!0&&Dr(e).length>0}function Tr(e,t){if(Mt(e)!==e)throw Error(`Destination root "${e}" was redirected outside the destination.`);let n=e;for(let r of t.split(fi)){n=X(n,r);let s;try{s=Fr(n).isSymbolicLink()}catch(i){if(q(i)&&i.code==="ENOENT")return;throw i}if(!s)continue;let o;try{o=Mt(n)}catch{}if(o===void 0||!Or(e,o))throw Error(`Destination path "${n}" is a symlink${o===void 0?" to a missing target":` to "${o}"`} outside the destination "${e}". Remove the link or choose another destination.`)}}async function Mr(e){let{template:t,dest:n,context:r,conflict:s="abort",render:o=gi}=e,i=t instanceof URL?di(t):Ar(t),a=Ar(n),c=Pr(i,{throwIfNoEntry:!1});if(!c)throw Error(`Template directory "${i}" does not exist (from template: "${String(t)}").`);if(!c.isDirectory())throw Error(`Template path "${i}" is not a directory (from template: "${String(t)}").`);if(s==="abort"&&wi(a))throw Error(`Destination directory "${a}" already exists and is non-empty. Use conflict: "overwrite" to proceed.`);let l=Dr(i,{recursive:!0,encoding:"utf8"}).filter((m)=>Fr(X(i,m)).isFile());_r(a,{recursive:!0});let d=Mt(a),g=l.map((m)=>({relFromTemplate:m,destRelPath:bi(m)}));for(let{destRelPath:m}of g)Tr(d,m);let p=[];for(let{relFromTemplate:m,destRelPath:w}of g){let O=X(i,m),v=X(d,w),u=li(O),f=u.subarray(0,8192).includes(0)?u:await o(u.toString("utf-8"),r);Tr(d,w),_r(Rr(v),{recursive:!0}),ui(v,f,"utf-8"),p.push(w)}return{files:p}}var vi=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];function Lt(e){let t=e??process.cwd();for(let[n,r]of vi)if(ci(X(t,n)))return r;return $r(process.env.npm_config_user_agent)??"npm"}function Lr(e){try{return pi("git",["rev-parse","--is-inside-work-tree"],{cwd:e??process.cwd(),stdio:"ignore"}).status===0}catch{return!1}}async function zt(e,t,n={}){let r=n.stderr??((o)=>Z(2,`${o}
27
+ `)),s=n.signal??Y();for(let o of e)switch(s?.throwIfAborted(),o.type){case"install":await yi(t,s);break;case"git-init":await Oi(t,o.commit,s);break;case"open-editor":await xi(t,r);break;case"command":await Si(o.cmd,o.cwd??t,s)}}async function yi(e,t){let n=Lt(e),r=Pt(n);if(!r)throw Error(`Package manager "${n}" was not found on PATH. Install ${n} and try again.`);let{exitCode:s}=await se(r,["install"],{cwd:e,stdio:"inherit",signal:t});if(s!==0)throw Error(`"${n} install" exited with code ${s}`)}async function Oi(e,t,n){let r=Pt("git");if(!r)throw Error('"git" was not found on PATH. Install Git and try again.');if(await Rt(r,["init"],e,"git init",n),t){let s=await Ei(e,r,n);await Rt(r,["add","."],e,"git add",n),await Rt(r,[...s,"commit","-m",t],e,"git commit",n)}}async function xi(e,t){let n=process.env.EDITOR||"code",r;try{let s=mi(n,[e],{stdio:"ignore",shell:process.platform==="win32"});s.unref();let o=await Promise.race([hi(s,"close").then(([i])=>({kind:"exited",code:i})),new Promise((i)=>setTimeout(()=>i({kind:"timeout"}),500))]);if(o.kind==="exited"&&o.code!==0)r=`Warning: could not open editor "${n}" (exit code ${o.code})`}catch{r=`Warning: could not open editor "${n}"`}if(r!==void 0)t(r)}async function Si(e,t,n){let{exitCode:r}=await se(e,[],{cwd:t,shell:!0,stdio:"inherit",signal:n});if(r!==0)throw Error(`Command "${e}" exited with code ${r}`)}async function Ei(e,t,n){let r=[];if(!await kr(t,"user.name",e,n))r.push("-c","user.name=Crust");if(!await kr(t,"user.email",e,n))r.push("-c","user.email=crust@scaffolded.project");return r}async function kr(e,t,n,r){let{exitCode:s}=await se(e,["config",t],{cwd:n,stdio:"collect",stdout:"ignore",signal:r});return s===0}async function Rt(e,t,n,r,s){let{exitCode:o,stderr:i}=await se(e,t,{cwd:n,stdio:"collect",stdout:"ignore",signal:s});if(o!==0)throw Error(`"${r}" failed with exit code ${o}${i?`: ${i.trim()}`:""}`)}_t();var os=Nt("crust:help");async function Ji(e,t){await Promise.resolve().then(() => rs());return ns(e,t,os)}var qi={help:{type:"boolean",short:"h",noNegate:!0,description:"Show help"}};async function ss(e){e.stdout(await Ji(e.command,e.commandPath))}var is=$t(os).factory((e)=>e.flags(qi).handle("help",ss,{eager:!0}).noAction(ss));var Yi=Nt("crust:version"),Ki={version:{type:"boolean",short:"v",noNegate:!0,description:"Show version number",recursive:!1}},as=$t(Yi).factory((e,t,n={})=>{let{format:r}=n;return e.flags(Ki).handle("version",(s)=>{let o=typeof t==="function"?t():t??s.rootCommand.meta.version,i=r==="plain"?o:r?r(o,s):`${s.rootCommand.meta.name} v${o}`;s.stdout(i)},{eager:!0})});_e();le();Q();function ds(e){return{spinner:e.magenta,message:e.bold,success:e.green,error:e.red}}var rl=ds({bold:P,green:H,magenta:es,red:Ne});function Xi(e){return ds($e({overrides:{isTTY:e.isTTY}}))}var Gt="\x1B[",Zi=`${Gt}?25l`,Ae=`${Gt}?25h`,Vt=`${Gt}2K`,Ht="\r",cs={dots:{frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],interval:80},line:{frames:["-","\\","|","/"],interval:130},arc:{frames:["◐","◓","◑","◒"],interval:100},bounce:{frames:["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"],interval:120}},Qi="✓",ea="✗";function ta(e){if(e===void 0)return cs.dots;if(typeof e==="string")return cs[e];if(e.frames.length===0)throw Error("A custom spinner requires at least one frame");return e}function na(e,t){let n=e[t];if(n===void 0)throw Error("Spinner frame index is out of bounds");return n}var ls,us=/\x1B\[[0-?]*[ -/]*[@-~]|\x1B\][^\x07\x1B]*(?:\x07|\x1B\\)/g,ra=/[\n\v\f\x85]/;function fs(e,t){ls??=new Intl.Segmenter;let n=0,r=0,s=0;for(let o of[...e.matchAll(us),void 0]){let i=o?.index??e.length;for(let{segment:a,index:c}of ls.segment(e.slice(s,i))){if(a==="\r")n=0;else if(ra.test(a)||(n+=z(a))>t){let l=e.slice(r).match(us)?.join("")??"";return`${e.slice(0,r)}${t>0?"…":""}${l}`}if(n<t)r=s+c+a.length}if(o)s=i+o[0].length}return e}function sa(e,t,n,r){let s=n==="success"?Qi:ea;return`${r}${(n==="success"?t.success:t.error)(s)} ${t.message(e)}
28
+ `}function oa(e,t=()=>""){let n=e.sink??pe()?.output??un,r={...Xi(n),...e.theme},s=n.isTTY??!1,{frames:o,interval:i}=ta(e.spinner),a=e.sigint??"exit",c=e.signal??Y(),l=e.message,d=0,g=!1,p=!1,m,w,O,v,u=()=>setImmediate(()=>y.stop("error"));function f(){let S=(n.columns||80)-1,I=`${r.spinner(na(o,d))} `,E=t(),x=S-z(I+r.message(E)),j=I+r.message(fs(l,x)+E);n.write(Vt+Ht+fs(j,S))}function h(){if(m!==void 0)clearInterval(m),m=void 0;if(w)process.removeListener("SIGINT",w),w=void 0;if(O)process.removeListener("exit",O),O=void 0;v?.(),v=void 0,c?.removeEventListener("abort",u)}let y={start(){if(g||p)return;if(g=!0,c&&!c.aborted)c.addEventListener("abort",u,{once:!0});if(!s)return;n.write(Zi),O=()=>n.write(Ae),process.once("exit",O);try{f()}catch(S){h();try{n.write(Ae)}catch{}throw S}if(m=setInterval(()=>{d=(d+1)%o.length,f()},i),v=ln({clear:()=>n.write(Vt+Ht),redraw:f}),a==="exit"&&!J("SIGINT")){let S=()=>{if(process.removeListener("SIGINT",S),w=void 0,process.listenerCount("SIGINT")>0){u();return}h(),p=!0,n.write(Ae),process.kill(process.pid,"SIGINT")};w=S,process.once("SIGINT",S)}},updateMessage(S){if(p)return;if(l=S,g&&s)f()},stop(S="success",I){if(p)return;if(p=!0,I!==void 0)l=I;h();let E;try{let x=g&&s?Vt+Ht:"";n.write(sa(l+t(),r,S,x))}catch(x){E={error:x}}if(g&&s)try{n.write(Ae)}catch(x){if(!E)throw x}if(E)throw E.error}};return y}function Jt(e){let t=oa(e),{task:n}=e;if(!n)return t;return t.start(),Promise.resolve().then(()=>n(t)).then((r)=>(t.stop("success"),r),(r)=>{throw t.stop("error"),r})}xs();var Le=class extends Error{constructor(e){super(e),this.name="Eta Error"}},Cs=class extends Le{constructor(e){super(e),this.name="EtaParser Error"}},Ta=class extends Le{constructor(e){super(e),this.name="EtaRuntime Error"}};var ka=class extends Le{constructor(e){super(e),this.name="EtaNameResolution Error"}};function ae(e,t,n){let r=t.slice(0,n).split(/\n/),s=r.length,o=r[s-1].length+1;throw e+=" at line "+s+" col "+o+`:
20
29
 
21
30
  `+t.split(/\n/)[s-1]+`
22
- `+Array(o).join(" ")+"^",new Dn(e)}function li(e,t,n,r){let s=t.split(`
23
- `),o=Math.max(n-3,0),i=Math.min(s.length,n+3),a=r,c=s.slice(o,i).map((u,f)=>{let d=f+o+1;return(d===n?" >> ":" ")+d+"| "+u}).join(`
24
- `),l=new ai((a?a+":"+n+`
31
+ `+Array(o).join(" ")+"^",new Cs(e)}function Fa(e,t,n,r){let s=t.split(`
32
+ `),o=Math.max(n-3,0),i=Math.min(s.length,n+3),a=r,c=s.slice(o,i).map((d,g)=>{let p=g+o+1;return(p===n?" >> ":" ")+p+"| "+d}).join(`
33
+ `),l=new Ta((a?a+":"+n+`
25
34
  `:"line "+n+`
26
35
  `)+c+`
27
36
 
28
- `+e.message);throw l.name=e.name,l.cause=e,l}var ui=(async()=>{}).constructor;function fi(e,t){let n=this.config,r=t?.async?ui:Function;try{return new r(n.varName,"options",this.compileToString.call(this,e,t))}catch(s){throw s instanceof SyntaxError?new Dn(`Bad template syntax
37
+ `+e.message);throw l.name=e.name,l.cause=e,l}var Da=(async()=>{}).constructor;function Pa(e,t){let n=this.config,r=t?.async?Da:Function;try{return new r(n.varName,"options",this.compileToString.call(this,e,t))}catch(s){throw s instanceof SyntaxError?new Cs(`Bad template syntax
29
38
 
30
39
  `+s.message+`
31
40
  `+Array(s.message.length+1).join("=")+`
32
41
  `+this.compileToString.call(this,e,t)+`
33
- `):s}}function di(e,t){let n=this.config,r=t?.async,s=this.compileBody,o=this.parse.call(this,e),i=`${n.functionHeader}
42
+ `):s}}function Ra(e,t){let n=this.config,r=t?.async,s=this.compileBody,o=this.parse.call(this,e),i=`${n.functionHeader}
34
43
  let include = (__eta_t, __eta_d) => this.render(__eta_t, {...${n.varName}, ...(__eta_d ?? {})}, options);
35
44
  let includeAsync = (__eta_t, __eta_d) => this.renderAsync(__eta_t, {...${n.varName}, ...(__eta_d ?? {})}, options);
36
45
 
@@ -53,15 +62,15 @@ if (__eta.layout) {
53
62
  }
54
63
  ${n.useWith?"}":""}${n.debug?"} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }":""}
55
64
  return __eta.res;
56
- `;if(n.plugins)for(let a=0;a<n.plugins.length;a++){let c=n.plugins[a];c.processFnString&&(i=c.processFnString(i,n))}return i}function mi(e){let t=this.config,n=0,r=e.length,s="";for(;n<r;n++){let o=e[n];if(typeof o=="string")s+="__eta.res+='"+o+`';
65
+ `;if(n.plugins)for(let a=0;a<n.plugins.length;a++){let c=n.plugins[a];c.processFnString&&(i=c.processFnString(i,n))}return i}function Ma(e){let t=this.config,n=0,r=e.length,s="";for(;n<r;n++){let o=e[n];if(typeof o=="string")s+="__eta.res+='"+o+`';
57
66
  `;else{let i=o.t,a=o.val||"";t.debug&&(s+="__eta.line="+o.lineNo+`
58
67
  `),i==="r"?(t.autoFilter&&(a="__eta.f("+a+")"),s+="__eta.res+="+a+`;
59
68
  `):i==="i"?(t.autoFilter&&(a="__eta.f("+a+")"),t.autoEscape&&(a="__eta.e("+a+")"),s+="__eta.res+="+a+`;
60
69
  `):i==="e"?s+=a+`
61
70
  `:Object.hasOwn(t.customTags,i)&&(s+=`__eta.res+=this.config.customTags[${JSON.stringify(i)}](${JSON.stringify(a)},${t.varName});
62
- `)}}return s}function pi(e,t,n,r){let s,o;return Array.isArray(t.autoTrim)?(s=t.autoTrim[1],o=t.autoTrim[0]):s=o=t.autoTrim,(n||n===!1)&&(s=n),(r||r===!1)&&(o=r),!o&&!s?e:s==="slurp"&&o==="slurp"?e.trim():(s==="_"||s==="slurp"?e=e.trimStart():(s==="-"||s==="nl")&&(e=e.replace(/^(?:\r\n|\n|\r)/,"")),o==="_"||o==="slurp"?e=e.trimEnd():(o==="-"||o==="nl")&&(e=e.replace(/(?:\r\n|\n|\r)$/,"")),e)}var gi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function hi(e){return gi[e]}function bi(e){let t=String(e);return/[&<>"']/.test(t)?t.replace(/[&<>"']/g,hi):t}var Pn={autoEscape:!0,autoFilter:!1,autoTrim:[!1,"nl"],cache:!1,cacheFilepaths:!0,customTags:{},debug:!1,escapeFunction:bi,filterFunction:(e)=>String(e),outputFunctionName:"output",functionHeader:"",parse:{exec:"",interpolate:"=",raw:"~"},plugins:[],rmWhitespace:!1,tags:["<%","%>"],useWith:!1,varName:"it",defaultExtension:".eta"},ce=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,le=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,ue=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function fe(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function wi(e,t){return e.slice(0,t).split(`
63
- `).length}function yi(e){let t=this.config,n=[],r=!1,s=0,o=t.parse,i=Object.keys(t.customTags);if(t.plugins)for(let d=0;d<t.plugins.length;d++){let p=t.plugins[d];p.processTemplate&&(e=p.processTemplate(e,t))}t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,`
64
- `).replace(/^\s+|\s+$/gm,"")),ce.lastIndex=0,le.lastIndex=0,ue.lastIndex=0;function a(d,p){d&&(d=pi(d,t,r,p),d&&(d=d.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),n.push(d)))}let c=[o.exec,o.interpolate,o.raw,...i].reduce((d,p)=>d&&p?d+"|"+fe(p):p?fe(p):d,""),l=RegExp(fe(t.tags[0])+"(-|_)?\\s*("+c+")?\\s*","g"),u=RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+fe(t.tags[1])+")","g"),f;for(;f=l.exec(e);){let d=e.slice(s,f.index);s=f[0].length+f.index;let p=f[1],b=f[2]||"";a(d,p),u.lastIndex=s;let m,g=!1;for(;m=u.exec(e);)if(m[1]){let w=e.slice(s,m.index);l.lastIndex=s=u.lastIndex,r=m[2],g={t:b===o.exec?"e":b===o.raw?"r":b===o.interpolate?"i":i.includes(b)?b:"",val:w};break}else{let w=m[0];if(w==="/*"){let S=e.indexOf("*/",u.lastIndex);S===-1&&W("unclosed comment",e,m.index),u.lastIndex=S}else w==="'"?(le.lastIndex=m.index,le.exec(e)?u.lastIndex=le.lastIndex:W("unclosed string",e,m.index)):w==='"'?(ue.lastIndex=m.index,ue.exec(e)?u.lastIndex=ue.lastIndex:W("unclosed string",e,m.index)):w==="`"&&(ce.lastIndex=m.index,ce.exec(e)?u.lastIndex=ce.lastIndex:W("unclosed string",e,m.index))}g?(t.debug&&(g.lineNo=wi(e,f.index)),n.push(g)):W("unclosed tag",e,f.index)}if(a(e.slice(s,e.length),!1),t.plugins)for(let d=0;d<t.plugins.length;d++){let p=t.plugins[d];p.processAST&&(n=p.processAST(n,t))}return n}function Mn(e,t){let n=t?.async?this.templatesAsync:this.templatesSync;if(this.resolvePath&&this.readFile&&!e.startsWith("@")){let r=t.filepath,s=n.get(r);if(this.config.cache&&s)return s;{let o=this.readFile(r),i=this.compile(o,t);return this.config.cache&&n.define(r,i),i}}else{let r=n.get(e);if(r)return r;throw new ci(`Failed to get template '${e}'`)}}function Ln(e,t,n){let r,s={...n,async:!1};return typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Mn.call(this,e,s)):r=e,r.call(this,t,s)}function zn(e,t,n){let r,s={...n,async:!0};typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Mn.call(this,e,s)):r=e;let o=r.call(this,t,s);return Promise.resolve(o)}function vi(e,t){let n=this.compile(e,{async:!1});return Ln.call(this,n,t)}function xi(e,t){let n=this.compile(e,{async:!0});return zn.call(this,n,t)}var Rn=class{constructor(e){this.cache=e}define(e,t){this.cache[e]=t}get(e){return this.cache[e]}remove(e){delete this.cache[e]}reset(){this.cache={}}load(e){this.cache={...this.cache,...e}}},Si=class{constructor(e){e?this.config={...Pn,...e}:this.config={...Pn};let t=[this.config.parse.exec,this.config.parse.interpolate,this.config.parse.raw,"-","_"];for(let n of Object.keys(this.config.customTags))if(t.includes(n))throw new de(`Custom tag prefix "${n}" conflicts with a built-in prefix`)}config;RuntimeErr=li;compile=fi;compileToString=di;compileBody=mi;parse=yi;render=Ln;renderAsync=zn;renderString=vi;renderStringAsync=xi;filepathCache={};templatesSync=new Rn({});templatesAsync=new Rn({});resolvePath=null;readFile=null;configure(e){this.config={...this.config,...e}}withConfig(e){return{...this,config:{...this.config,...e}}}loadTemplate(e,t,n){if(typeof t=="string")((n?.async)?this.templatesAsync:this.templatesSync).define(e,this.compile(t,n));else{let r=this.templatesSync;(t.constructor.name==="AsyncFunction"||n?.async)&&(r=this.templatesAsync),r.define(e,t)}}},Bn=class extends Si{};var Wn={name:"@crustjs/core",version:"0.5.6",description:"Define, parse, route, and run type-safe CLI commands with Contexts and Extensions",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/core"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","command","framework","parser","bun","typescript"],files:["dist"],types:"./dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./tooling":{types:"./dist/tooling.d.ts",import:"./dist/tooling.js"}},publishConfig:{access:"public"},scripts:{build:"vp run build:task",dev:"vp pack --watch","check:types":"vp run check:types:task",test:"vp run test:task",prepack:"cp ../../LICENSE LICENSE",postpack:"rm -f LICENSE"},dependencies:{"@crustjs/utils":"workspace:^"},devDependencies:{"@crustjs/config":"workspace:*","vite-plus":"catalog:"},peerDependencies:{typescript:"^7.0.0"},peerDependenciesMeta:{typescript:{optional:!0}},engines:{bun:">=1.4.0",node:">=24",deno:">=2.8"}};var Un={name:"@crustjs/crust",version:"0.5.6",description:"CLI to build and publish Crust apps as npm packages or standalone binaries",type:"module",license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/crust"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","build","compile","standalone","bun","typescript"],publishConfig:{access:"public"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},crust:{artifact:"binary",include:["schema","dist"]},bin:{crust:"src/cli.ts"},scripts:{build:"vp run build:task",release:"bun src/cli.ts publish",dev:"bun src/cli.ts",start:"bun .crust/root/bin/crust.js","check:types":"vp run check:types:task",test:"vp run test:task"},dependencies:{"@crustjs/core":"workspace:^","@crustjs/extensions":"workspace:^","@crustjs/style":"workspace:^"},optionalDependencies:{"@tsdown/exe":"0.23.1",tsdown:"0.23.1"},peerDependencies:{"@crustjs/core":"^0.5.0"},devDependencies:{"@arethetypeswrong/core":"^0.18.5","@crustjs/config":"workspace:*","@crustjs/testing":"workspace:*","@crustjs/utils":"workspace:*","@types/semver":"^7.8.0",publint:"^0.3.25",semver:"^7.8.5","vite-plus":"catalog:"},engines:{bun:">=1.4.0"}};var Vn={name:"@crustjs/extensions",version:"0.5.6",description:"Official Crust Extensions for help, version, completion, typo hints, color, and updates",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/extensions"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","extension","help","version","completion","did-you-mean","bun","typescript"],files:["dist"],exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},publishConfig:{access:"public"},scripts:{build:"vp run build:task",dev:"vp pack --watch","check:types":"vp run check:types:task",test:"vp run test:task",prepack:"cp ../../LICENSE LICENSE",postpack:"rm -f LICENSE"},dependencies:{"@crustjs/store":"workspace:^","@crustjs/style":"workspace:^","@crustjs/utils":"workspace:^"},devDependencies:{"@crustjs/config":"workspace:*","@crustjs/core":"workspace:*","@crustjs/testing":"workspace:*","vite-plus":"catalog:"},peerDependencies:{"@crustjs/core":"workspace:^",typescript:"^7.0.0"},peerDependenciesMeta:{typescript:{optional:!0}},engines:{bun:">=1.4.0",node:">=24",deno:">=2.8"}};var qn={name:"create-crust",version:"0.5.6",description:"Scaffold a new Crust CLI project for Bun, Node.js, or Deno",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/create-crust"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","scaffold","create","generator","bun","typescript","crust"],publishConfig:{access:"public"},crust:{runtime:"node",artifact:"package",include:["templates"]},bin:{"create-crust":"src/index.ts"},scripts:{build:"vp run build:task",dev:"pnpm run build && bun src/index.ts",release:"crust publish","check:types":"vp run check:types:task",test:"vp run test:task","test:smoke":"vp test tests/cli.smoke.test.ts"},dependencies:{"@crustjs/core":"workspace:^","@crustjs/create":"workspace:^","@crustjs/progress":"workspace:^","@crustjs/prompts":"workspace:^",eta:"^4.6.0"},devDependencies:{"@crustjs/config":"workspace:*","@crustjs/crust":"workspace:*","@crustjs/extensions":"workspace:*","vite-plus":"catalog:"},engines:{bun:">=1.4.0",node:">=24",deno:">=2.8"}};var ki={bun:{shebang:"#!/usr/bin/env bun",tsLib:'"ESNext"',tsTypes:'"bun"'},node:{shebang:"#!/usr/bin/env node",tsLib:'"ESNext"',tsTypes:'"node"'},deno:{shebang:"#!/usr/bin/env -S deno run -A",tsLib:'"ESNext", "deno.window"',tsTypes:""}},Ni=new Bn({autoEscape:!1,autoTrim:!1});function Jn(e){if(!Mt(e))throw Error(`Project name ${JSON.stringify(e)} is not safe for the generated project.
65
- The directory basename becomes the package and command name: use ${Dt}.`)}var Ai=/[<>:"|?*\\]/;function Ti(e){if(!e)throw Error("Project directory cannot be empty");if(Ai.test(e))throw Error(`Project directory contains invalid characters: ${e}`);Jn(Kn(Yn(e)))}var Fi=new Z("create-crust",{description:qn.description}).flags({name:"runtime",type:"string",choices:["bun","node","deno"],description:'Runtime to develop and build for ("bun", "node", or "deno")'},{name:"artifact",type:"string",choices:["package","binary"],description:"Build output: runtime package or standalone binary"},{name:"install",type:"boolean",description:"Install dependencies after scaffolding"},{name:"git",type:"boolean",description:"Initialize a git repository after scaffolding"},{name:"overwrite",type:"boolean",description:"Overwrite the destination directory if it already exists"}).args({name:"directory",type:"string",description:"Project directory to scaffold into"}).action(async({args:e,flags:t})=>{let n=e.directory??await Fn({message:"Project directory",default:"my-cli",validate:Ti}),r=Yn(process.cwd(),n),s=r===process.cwd(),o=Kn(r);Jn(o);let i=s?Ci(r).length>0:Hn(r),a=!1;if(i){if(a=await ae({message:s?"Current directory is not empty. Overwrite conflicting files?":`Directory "${o}" already exists. Overwrite?`,default:!1,initial:t.overwrite}),!a){console.log("Aborted.");return}}let c=await Ze({message:"Runtime",choices:[{label:"Bun (recommended)",value:"bun",hint:"Bun APIs and TypeScript execution"},{label:"Node.js",value:"node",hint:"Node.js APIs and ecosystem"},{label:"Deno",value:"deno",hint:"Deno APIs and permission model"}],default:"bun",initial:t.runtime}),l=await Ze({message:"Build output",choices:[{label:"Standalone binary",value:"binary",hint:"Embeds the runtime; users need no separate JavaScript runtime"},{label:"Runtime package",value:"package",hint:c==="deno"?"Requires Deno installed; experimental bundling":"JavaScript bundle; requires the selected runtime installed"}],default:c==="node"?"package":"binary",initial:t.artifact}),u=await ae({message:"Install dependencies?",default:!0,initial:t.install}),f=r;while(!Hn(f)&&Gn(f)!==f)f=Gn(f);let p=Zt(f)?!1:await ae({message:"Initialize a git repository?",default:!0,initial:t.git}),b=c==="deno"?"deno":De(r),m={name:o,runtime:c,artifact:l,run:b==="deno"?"deno task":`${b} run`,install:`${b} install`,...ki[c],coreVersion:Wn.version,extensionsVersion:Vn.version,crustVersion:Un.version};if(await qe({message:"Scaffolding project...",task:()=>Xt({template:_i(he("templates"),"base"),dest:r,context:m,render:(g,w)=>Ni.renderString(g,w),conflict:a?"overwrite":"abort"})}),u)await Me([c==="deno"?{type:"command",cmd:"deno install"}:{type:"install"}],r);if(p)await qe({message:"Initializing git repository...",task:()=>Me([{type:"git-init",commit:"chore: initial commit"}],r)});if(console.log(`
66
- Created ${o}!
67
- `),console.log("Next steps:"),!s){let g=ji(n)||n.startsWith(".")?n:`./${n}`;console.log(` cd ${g}`)}if(!u)console.log(` ${m.install}`);console.log(` ${m.run} dev`),console.log(` ${m.run} build`)});await Fi.execute();
71
+ `)}}return s}function La(e,t,n,r){let s,o;return Array.isArray(t.autoTrim)?(s=t.autoTrim[1],o=t.autoTrim[0]):s=o=t.autoTrim,(n||n===!1)&&(s=n),(r||r===!1)&&(o=r),!o&&!s?e:s==="slurp"&&o==="slurp"?e.trim():(s==="_"||s==="slurp"?e=e.trimStart():(s==="-"||s==="nl")&&(e=e.replace(/^(?:\r\n|\n|\r)/,"")),o==="_"||o==="slurp"?e=e.trimEnd():(o==="-"||o==="nl")&&(e=e.replace(/(?:\r\n|\n|\r)$/,"")),e)}var za={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Ba(e){return za[e]}function Ua(e){let t=String(e);return/[&<>"']/.test(t)?t.replace(/[&<>"']/g,Ba):t}var Ss={autoEscape:!0,autoFilter:!1,autoTrim:[!1,"nl"],cache:!1,cacheFilepaths:!0,customTags:{},debug:!1,escapeFunction:Ua,filterFunction:(e)=>String(e),outputFunctionName:"output",functionHeader:"",parse:{exec:"",interpolate:"=",raw:"~"},plugins:[],rmWhitespace:!1,tags:["<%","%>"],useWith:!1,varName:"it",defaultExtension:".eta"},De=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,Pe=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,Re=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function Me(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function Wa(e,t){return e.slice(0,t).split(`
72
+ `).length}function Va(e){let t=this.config,n=[],r=!1,s=0,o=t.parse,i=Object.keys(t.customTags);if(t.plugins)for(let p=0;p<t.plugins.length;p++){let m=t.plugins[p];m.processTemplate&&(e=m.processTemplate(e,t))}t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,`
73
+ `).replace(/^\s+|\s+$/gm,"")),De.lastIndex=0,Pe.lastIndex=0,Re.lastIndex=0;function a(p,m){p&&(p=La(p,t,r,m),p&&(p=p.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),n.push(p)))}let c=[o.exec,o.interpolate,o.raw,...i].reduce((p,m)=>p&&m?p+"|"+Me(m):m?Me(m):p,""),l=RegExp(Me(t.tags[0])+"(-|_)?\\s*("+c+")?\\s*","g"),d=RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+Me(t.tags[1])+")","g"),g;for(;g=l.exec(e);){let p=e.slice(s,g.index);s=g[0].length+g.index;let m=g[1],w=g[2]||"";a(p,m),d.lastIndex=s;let O,v=!1;for(;O=d.exec(e);)if(O[1]){let u=e.slice(s,O.index);l.lastIndex=s=d.lastIndex,r=O[2],v={t:w===o.exec?"e":w===o.raw?"r":w===o.interpolate?"i":i.includes(w)?w:"",val:u};break}else{let u=O[0];if(u==="/*"){let f=e.indexOf("*/",d.lastIndex);f===-1&&ae("unclosed comment",e,O.index),d.lastIndex=f}else u==="'"?(Pe.lastIndex=O.index,Pe.exec(e)?d.lastIndex=Pe.lastIndex:ae("unclosed string",e,O.index)):u==='"'?(Re.lastIndex=O.index,Re.exec(e)?d.lastIndex=Re.lastIndex:ae("unclosed string",e,O.index)):u==="`"&&(De.lastIndex=O.index,De.exec(e)?d.lastIndex=De.lastIndex:ae("unclosed string",e,O.index))}v?(t.debug&&(v.lineNo=Wa(e,g.index)),n.push(v)):ae("unclosed tag",e,g.index)}if(a(e.slice(s,e.length),!1),t.plugins)for(let p=0;p<t.plugins.length;p++){let m=t.plugins[p];m.processAST&&(n=m.processAST(n,t))}return n}function Is(e,t){let n=t?.async?this.templatesAsync:this.templatesSync;if(this.resolvePath&&this.readFile&&!e.startsWith("@")){let r=t.filepath,s=n.get(r);if(this.config.cache&&s)return s;{let o=this.readFile(r),i=this.compile(o,t);return this.config.cache&&n.define(r,i),i}}else{let r=n.get(e);if(r)return r;throw new ka(`Failed to get template '${e}'`)}}function js(e,t,n){let r,s={...n,async:!1};return typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Is.call(this,e,s)):r=e,r.call(this,t,s)}function $s(e,t,n){let r,s={...n,async:!0};typeof e=="string"?(this.resolvePath&&this.readFile&&!e.startsWith("@")&&(s.filepath=this.resolvePath(e,s)),r=Is.call(this,e,s)):r=e;let o=r.call(this,t,s);return Promise.resolve(o)}function Ha(e,t){let n=this.compile(e,{async:!1});return js.call(this,n,t)}function Ga(e,t){let n=this.compile(e,{async:!0});return $s.call(this,n,t)}var Es=class{constructor(e){this.cache=e}define(e,t){this.cache[e]=t}get(e){return this.cache[e]}remove(e){delete this.cache[e]}reset(){this.cache={}}load(e){this.cache={...this.cache,...e}}},Ja=class{constructor(e){e?this.config={...Ss,...e}:this.config={...Ss};let t=[this.config.parse.exec,this.config.parse.interpolate,this.config.parse.raw,"-","_"];for(let n of Object.keys(this.config.customTags))if(t.includes(n))throw new Le(`Custom tag prefix "${n}" conflicts with a built-in prefix`)}config;RuntimeErr=Fa;compile=Pa;compileToString=Ra;compileBody=Ma;parse=Va;render=js;renderAsync=$s;renderString=Ha;renderStringAsync=Ga;filepathCache={};templatesSync=new Es({});templatesAsync=new Es({});resolvePath=null;readFile=null;configure(e){this.config={...this.config,...e}}withConfig(e){return{...this,config:{...this.config,...e}}}loadTemplate(e,t,n){if(typeof t=="string")((n?.async)?this.templatesAsync:this.templatesSync).define(e,this.compile(t,n));else{let r=this.templatesSync;(t.constructor.name==="AsyncFunction"||n?.async)&&(r=this.templatesAsync),r.define(e,t)}}},Ns=class extends Ja{};var _s={name:"@crustjs/core",version:"0.6.1",description:"Define, parse, route, and run type-safe CLI commands with Contexts and Extensions",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/core"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","command","framework","parser","bun","typescript"],files:["dist"],exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./tooling":{types:"./dist/tooling.d.ts",import:"./dist/tooling.js"}},publishConfig:{access:"public"},scripts:{build:"vp run build:task",dev:"vp pack --watch","check:types":"vp run check:types:task",test:"vp run test:task",prepack:"cp ../../LICENSE LICENSE",postpack:"rm -f LICENSE"},dependencies:{"@crustjs/utils":"workspace:^"},devDependencies:{"@crustjs/config":"workspace:*","vite-plus":"catalog:",zod:"^4.6.7"},peerDependencies:{typescript:">=5.9.0"},peerDependenciesMeta:{typescript:{optional:!0}},engines:{bun:">=1.4.0",node:">=24"}};var As={name:"@crustjs/crust",version:"0.6.1",description:"CLI to build and publish Crust apps as npm packages or standalone binaries",type:"module",license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/crust"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","build","compile","standalone","bun","typescript"],publishConfig:{access:"public"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},crust:{artifact:"binary",include:["schema","dist"]},bin:{crust:"src/cli.ts"},scripts:{build:"vp run build:task",release:"bun src/cli.ts publish",dev:"bun src/cli.ts",start:"bun .crust/root/bin/crust.js","check:types":"vp run check:types:task",test:"vp run test:task"},dependencies:{"@crustjs/core":"workspace:^","@crustjs/extensions":"workspace:^","@crustjs/style":"workspace:^"},optionalDependencies:{"@tsdown/exe":"0.23.4",tsdown:"0.23.4"},peerDependencies:{"@crustjs/core":"^0.6.0"},devDependencies:{"@arethetypeswrong/core":"^0.18.5","@crustjs/config":"workspace:*","@crustjs/testing":"workspace:*","@crustjs/utils":"workspace:*","@types/semver":"^7.8.0",publint:"^0.3.25",semver:"^7.8.5","vite-plus":"catalog:"},engines:{bun:">=1.4.0"}};var Ts={name:"@crustjs/extensions",version:"0.6.1",description:"Official Crust Extensions for help, version, completion, typo hints, color, and updates",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/extensions"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","extension","help","version","completion","did-you-mean","bun","typescript"],files:["dist"],exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},publishConfig:{access:"public"},scripts:{build:"vp run build:task",dev:"vp pack --watch","check:types":"vp run check:types:task",test:"vp run test:task",prepack:"cp ../../LICENSE LICENSE",postpack:"rm -f LICENSE"},dependencies:{"@crustjs/prompts":"workspace:^","@crustjs/store":"workspace:^","@crustjs/style":"workspace:^","@crustjs/utils":"workspace:^"},devDependencies:{"@crustjs/config":"workspace:*","@crustjs/core":"workspace:*","@crustjs/testing":"workspace:*","vite-plus":"catalog:"},peerDependencies:{"@crustjs/core":"workspace:^",typescript:">=5.9.0"},peerDependenciesMeta:{typescript:{optional:!0}},engines:{bun:">=1.4.0",node:">=24"}};var nn={name:"create-crust",version:"0.6.1",description:"Scaffold a new Crust CLI project for Bun or Node.js",type:"module",sideEffects:!1,license:"MIT",author:"chenxin-yan",repository:{type:"git",url:"git+https://github.com/chenxin-yan/crust.git",directory:"packages/create-crust"},homepage:"https://crustjs.com",bugs:{url:"https://github.com/chenxin-yan/crust/issues"},keywords:["cli","scaffold","create","generator","bun","typescript","crust"],publishConfig:{access:"public"},crust:{runtime:"node",artifact:"package",include:["templates"]},bin:{"create-crust":"src/cli.ts"},scripts:{build:"vp run build:task",dev:"pnpm run build && bun src/cli.ts",release:"crust publish","check:types":"vp run check:types:task",test:"vp run test:task"},dependencies:{"@crustjs/core":"workspace:^","@crustjs/create":"workspace:^","@crustjs/progress":"workspace:^","@crustjs/prompts":"workspace:^",eta:"^4.6.0"},devDependencies:{"@crustjs/config":"workspace:*","@crustjs/crust":"workspace:*","@crustjs/extensions":"workspace:*","vite-plus":"catalog:"},engines:{bun:">=1.4.0",node:">=24"}};var tc={bun:{shebang:"#!/usr/bin/env bun",tsTypes:'"bun"'},node:{shebang:"#!/usr/bin/env node",tsTypes:'"node"'}},nc=new Ns({autoEscape:!1,autoTrim:!1});function Rs(e){if(!yr(e))throw Error(`Project name ${JSON.stringify(e)} is not safe for the generated project.
74
+ The directory basename becomes the package and command name: use ${vr}.`)}var rc=/[<>:"|?*\\]/;function sc(e){if(!e)throw Error("Project directory cannot be empty");if(rc.test(e))throw Error(`Project directory contains invalid characters: ${e}`);Rs(Ds(Ps(e)))}var Ms=new je("create-crust",{description:nn.description,version:nn.version}).extend(as(),is()).flags({runtime:{type:"string",choices:["bun","node"],description:'Runtime to develop and build for ("bun" or "node")'},artifact:{type:"string",choices:["package","binary"],description:"Build output: runtime package or standalone binary"},install:{type:"boolean",description:"Install dependencies after scaffolding"},git:{type:"boolean",description:"Initialize a git repository after scaffolding"},overwrite:{type:"boolean",description:"Overwrite the destination directory if it already exists"}}).args({name:"directory",type:"string",description:"Project directory to scaffold into"}).action(async({args:e,flags:t,stdout:n,stderr:r})=>{let s=e.directory??await Os({message:"Project directory",default:"my-cli",validate:sc}),o=Ps(process.cwd(),s),i=o===process.cwd(),a=Ds(o);Rs(a);let c=i?Za(o).length>0:ks(o),l=!1;if(c){if(l=await Fe({message:i?"Current directory is not empty. Overwrite conflicting files?":`Directory "${a}" already exists. Overwrite?`,default:!1,initial:t.overwrite}),!l){n("Aborted.");return}}let d=await tn({message:"Runtime",choices:[{label:"Bun (recommended)",value:"bun",hint:"Bun APIs and TypeScript execution"},{label:"Node.js",value:"node",hint:"Node.js APIs and ecosystem"}],default:"bun",initial:t.runtime}),g=await tn({message:"Build output",choices:[{label:"Standalone binary",value:"binary",hint:"Embeds the runtime; users need no separate JavaScript runtime"},{label:"Runtime package",value:"package",hint:"JavaScript bundle; requires the selected runtime installed"}],default:d==="node"?"package":"binary",initial:t.artifact}),p=await Fe({message:"Install dependencies?",default:!0,initial:t.install}),m=o;while(!ks(m)&&Fs(m)!==m)m=Fs(m);let O=Lr(m)?!1:await Fe({message:"Initialize a git repository?",default:!0,initial:t.git}),v=Lt(o),u={name:a,runtime:d,artifact:g,run:`${v} run`,install:`${v} install`,...tc[d],coreVersion:_s.version,extensionsVersion:Ts.version,crustVersion:As.version};if(await Jt({message:"Scaffolding project...",task:()=>Mr({template:ec(It("templates"),"base"),dest:o,context:u,render:(f,h)=>nc.renderString(f,h),conflict:l?"overwrite":"abort"})}),p)await zt([{type:"install"}],o,{stderr:r});if(O)await Jt({message:"Initializing git repository...",task:()=>zt([{type:"git-init",commit:"chore: initial commit"}],o,{stderr:r})});if(n(`
75
+ Created ${a}!
76
+ `),n("Next steps:"),!i){let f=Qa(s)||s.startsWith(".")?s:`./${s}`;n(` cd ${f}`)}if(!p)n(` ${u.install}`);n(` ${u.run} dev`),n(` ${u.run} build`)});await Ms.execute();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-crust",
3
- "version": "0.5.6",
4
- "description": "Scaffold a new Crust CLI project for Bun, Node.js, or Deno",
3
+ "version": "0.6.1",
4
+ "description": "Scaffold a new Crust CLI project for Bun or Node.js",
5
5
  "license": "MIT",
6
6
  "author": "chenxin-yan",
7
7
  "homepage": "https://crustjs.com",
@@ -27,8 +27,7 @@
27
27
  },
28
28
  "engines": {
29
29
  "bun": ">=1.4.0",
30
- "node": ">=24",
31
- "deno": ">=2.8"
30
+ "node": ">=24"
32
31
  },
33
32
  "type": "module",
34
33
  "files": [
@@ -34,7 +34,7 @@ Install dependencies if you skipped installation or just cloned the project:
34
34
  - `package`: a JavaScript bundle in `.crust/root/` that requires the selected runtime installed.
35
35
  - `binary`: a standalone executable per platform, with its runtime embedded. Pass `--target host` to `crust build` to build only this machine's target.
36
36
 
37
- Bun is used for build preparation and Bun/Node bundling. Node binaries additionally need Node 26+ and Crust's optional compiler backend; Deno builds need Deno on PATH, with Deno 2.5+ required for experimental runtime-package bundling. Crust does not install or upgrade compilers. See [compiler requirements](https://crustjs.com/docs/guide/build-and-distribution#binary-runtime-version).
37
+ Bun is used for build preparation and Bun/Node bundling. Node binaries additionally need Node 26+ and Crust's optional compiler backend. Crust does not install or upgrade compilers. See [compiler requirements](https://crustjs.com/docs/guide/build-and-distribution#binary-runtime-version).
38
38
 
39
39
  `<%~ it.run %> release` publishes the staged packages to npm, but npm is optional. For direct downloads, Homebrew or Scoop, distribute the executable and adjacent assets from `.crust/<platform>/bin/`. Direct binaries need no separately installed JavaScript runtime; the generated npm binary launcher needs Node.js. Crust does not generate installer definitions or publish release archives. See [custom distribution](https://crustjs.com/docs/guide/build-and-distribution#custom-distribution).
40
40
 
@@ -1,9 +1,7 @@
1
1
  <%
2
- /* `dev` runs the source and `start` runs the built bin with the selected runtime.
3
- Deno type-checks natively, so it needs no TypeScript packages. */
4
- const dev = { bun: "bun run src/cli.ts", node: "node src/cli.ts", deno: "deno run -A src/cli.ts" }[it.runtime];
5
- const startRunner = { bun: "bun", node: "node", deno: "deno run -A" }[it.runtime];
6
- const checkTypes = it.runtime === "deno" ? "deno check src/cli.ts" : "tsc --noEmit";
2
+ /* `dev` runs the source and `start` runs the built bin with the selected runtime. */
3
+ const dev = { bun: "bun run src/cli.ts", node: "node src/cli.ts" }[it.runtime];
4
+ const startRunner = { bun: "bun", node: "node" }[it.runtime];
7
5
  -%>
8
6
  {
9
7
  "$schema": "./node_modules/@crustjs/crust/schema/package.json",
@@ -24,7 +22,7 @@ const checkTypes = it.runtime === "deno" ? "deno check src/cli.ts" : "tsc --noEm
24
22
  "build": "crust build",
25
23
  "release": "crust publish",
26
24
  "start": <%~ JSON.stringify(`${startRunner} .crust/root/bin/${it.name}.js`) %>,
27
- "check:types": <%~ JSON.stringify(checkTypes) %>
25
+ "check:types": "tsc --noEmit"
28
26
  },
29
27
  <% if (it.runtime === "node") { -%>
30
28
  "engines": {
@@ -44,8 +42,6 @@ const checkTypes = it.runtime === "deno" ? "deno check src/cli.ts" : "tsc --noEm
44
42
  "@crustjs/crust": <%~ JSON.stringify(`^${it.crustVersion}`) %>,
45
43
  "@types/node": "^24",
46
44
  "typescript": "^7.0.2"
47
- <% } else { -%>
48
- "@crustjs/crust": <%~ JSON.stringify(`^${it.crustVersion}`) %>
49
45
  <% } -%>
50
46
  }
51
47
  }
@@ -13,11 +13,12 @@ const app = new Crust(<%~ JSON.stringify(it.name) %>, { description: "A CLI buil
13
13
  default: "world",
14
14
  })
15
15
  .flags({
16
- name: "greet",
17
- type: "string",
18
- description: "Greeting to use",
19
- default: "Hello",
20
- short: "g",
16
+ greet: {
17
+ type: "string",
18
+ description: "Greeting to use",
19
+ default: "Hello",
20
+ short: "g",
21
+ },
21
22
  })
22
23
  .action(({ args, flags, stdout }) => {
23
24
  stdout(`${flags.greet}, ${args.name}!`);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "lib": [<%~ it.tsLib %>],
3
+ "lib": ["ESNext"],
4
4
  "types": [<%~ it.tsTypes %>],
5
5
  "target": "ESNext",
6
6
  "module": "Preserve",