@mdless/cli 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,4455 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ var __create = Object.create;
4
+ var __getProtoOf = Object.getPrototypeOf;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __toESM = (mod, isNodeMode, target) => {
9
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
10
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
+ for (let key of __getOwnPropNames(mod))
12
+ if (!__hasOwnProp.call(to, key))
13
+ __defProp(to, key, {
14
+ get: () => mod[key],
15
+ enumerable: true
16
+ });
17
+ return to;
18
+ };
19
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
20
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
21
+
22
+ // node_modules/commander/lib/error.js
23
+ var require_error = __commonJS((exports) => {
24
+ class CommanderError extends Error {
25
+ constructor(exitCode, code, message) {
26
+ super(message);
27
+ Error.captureStackTrace(this, this.constructor);
28
+ this.name = this.constructor.name;
29
+ this.code = code;
30
+ this.exitCode = exitCode;
31
+ this.nestedError = undefined;
32
+ }
33
+ }
34
+
35
+ class InvalidArgumentError extends CommanderError {
36
+ constructor(message) {
37
+ super(1, "commander.invalidArgument", message);
38
+ Error.captureStackTrace(this, this.constructor);
39
+ this.name = this.constructor.name;
40
+ }
41
+ }
42
+ exports.CommanderError = CommanderError;
43
+ exports.InvalidArgumentError = InvalidArgumentError;
44
+ });
45
+
46
+ // node_modules/commander/lib/argument.js
47
+ var require_argument = __commonJS((exports) => {
48
+ var { InvalidArgumentError } = require_error();
49
+
50
+ class Argument {
51
+ constructor(name, description) {
52
+ this.description = description || "";
53
+ this.variadic = false;
54
+ this.parseArg = undefined;
55
+ this.defaultValue = undefined;
56
+ this.defaultValueDescription = undefined;
57
+ this.argChoices = undefined;
58
+ switch (name[0]) {
59
+ case "<":
60
+ this.required = true;
61
+ this._name = name.slice(1, -1);
62
+ break;
63
+ case "[":
64
+ this.required = false;
65
+ this._name = name.slice(1, -1);
66
+ break;
67
+ default:
68
+ this.required = true;
69
+ this._name = name;
70
+ break;
71
+ }
72
+ if (this._name.endsWith("...")) {
73
+ this.variadic = true;
74
+ this._name = this._name.slice(0, -3);
75
+ }
76
+ }
77
+ name() {
78
+ return this._name;
79
+ }
80
+ _collectValue(value, previous) {
81
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
82
+ return [value];
83
+ }
84
+ previous.push(value);
85
+ return previous;
86
+ }
87
+ default(value, description) {
88
+ this.defaultValue = value;
89
+ this.defaultValueDescription = description;
90
+ return this;
91
+ }
92
+ argParser(fn) {
93
+ this.parseArg = fn;
94
+ return this;
95
+ }
96
+ choices(values) {
97
+ this.argChoices = values.slice();
98
+ this.parseArg = (arg, previous) => {
99
+ if (!this.argChoices.includes(arg)) {
100
+ throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
101
+ }
102
+ if (this.variadic) {
103
+ return this._collectValue(arg, previous);
104
+ }
105
+ return arg;
106
+ };
107
+ return this;
108
+ }
109
+ argRequired() {
110
+ this.required = true;
111
+ return this;
112
+ }
113
+ argOptional() {
114
+ this.required = false;
115
+ return this;
116
+ }
117
+ }
118
+ function humanReadableArgName(arg) {
119
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
120
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
121
+ }
122
+ exports.Argument = Argument;
123
+ exports.humanReadableArgName = humanReadableArgName;
124
+ });
125
+
126
+ // node_modules/commander/lib/help.js
127
+ var require_help = __commonJS((exports) => {
128
+ var { humanReadableArgName } = require_argument();
129
+
130
+ class Help {
131
+ constructor() {
132
+ this.helpWidth = undefined;
133
+ this.minWidthToWrap = 40;
134
+ this.sortSubcommands = false;
135
+ this.sortOptions = false;
136
+ this.showGlobalOptions = false;
137
+ }
138
+ prepareContext(contextOptions) {
139
+ this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
140
+ }
141
+ visibleCommands(cmd) {
142
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
143
+ const helpCommand = cmd._getHelpCommand();
144
+ if (helpCommand && !helpCommand._hidden) {
145
+ visibleCommands.push(helpCommand);
146
+ }
147
+ if (this.sortSubcommands) {
148
+ visibleCommands.sort((a, b) => {
149
+ return a.name().localeCompare(b.name());
150
+ });
151
+ }
152
+ return visibleCommands;
153
+ }
154
+ compareOptions(a, b) {
155
+ const getSortKey = (option) => {
156
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
157
+ };
158
+ return getSortKey(a).localeCompare(getSortKey(b));
159
+ }
160
+ visibleOptions(cmd) {
161
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
162
+ const helpOption = cmd._getHelpOption();
163
+ if (helpOption && !helpOption.hidden) {
164
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
165
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
166
+ if (!removeShort && !removeLong) {
167
+ visibleOptions.push(helpOption);
168
+ } else if (helpOption.long && !removeLong) {
169
+ visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
170
+ } else if (helpOption.short && !removeShort) {
171
+ visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
172
+ }
173
+ }
174
+ if (this.sortOptions) {
175
+ visibleOptions.sort(this.compareOptions);
176
+ }
177
+ return visibleOptions;
178
+ }
179
+ visibleGlobalOptions(cmd) {
180
+ if (!this.showGlobalOptions)
181
+ return [];
182
+ const globalOptions = [];
183
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
184
+ const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
185
+ globalOptions.push(...visibleOptions);
186
+ }
187
+ if (this.sortOptions) {
188
+ globalOptions.sort(this.compareOptions);
189
+ }
190
+ return globalOptions;
191
+ }
192
+ visibleArguments(cmd) {
193
+ if (cmd._argsDescription) {
194
+ cmd.registeredArguments.forEach((argument) => {
195
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
196
+ });
197
+ }
198
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
199
+ return cmd.registeredArguments;
200
+ }
201
+ return [];
202
+ }
203
+ subcommandTerm(cmd) {
204
+ const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
205
+ return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
206
+ }
207
+ optionTerm(option) {
208
+ return option.flags;
209
+ }
210
+ argumentTerm(argument) {
211
+ return argument.name();
212
+ }
213
+ longestSubcommandTermLength(cmd, helper) {
214
+ return helper.visibleCommands(cmd).reduce((max, command) => {
215
+ return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
216
+ }, 0);
217
+ }
218
+ longestOptionTermLength(cmd, helper) {
219
+ return helper.visibleOptions(cmd).reduce((max, option) => {
220
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
221
+ }, 0);
222
+ }
223
+ longestGlobalOptionTermLength(cmd, helper) {
224
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
225
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
226
+ }, 0);
227
+ }
228
+ longestArgumentTermLength(cmd, helper) {
229
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
230
+ return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
231
+ }, 0);
232
+ }
233
+ commandUsage(cmd) {
234
+ let cmdName = cmd._name;
235
+ if (cmd._aliases[0]) {
236
+ cmdName = cmdName + "|" + cmd._aliases[0];
237
+ }
238
+ let ancestorCmdNames = "";
239
+ for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
240
+ ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
241
+ }
242
+ return ancestorCmdNames + cmdName + " " + cmd.usage();
243
+ }
244
+ commandDescription(cmd) {
245
+ return cmd.description();
246
+ }
247
+ subcommandDescription(cmd) {
248
+ return cmd.summary() || cmd.description();
249
+ }
250
+ optionDescription(option) {
251
+ const extraInfo = [];
252
+ if (option.argChoices) {
253
+ extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
254
+ }
255
+ if (option.defaultValue !== undefined) {
256
+ const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
257
+ if (showDefault) {
258
+ extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
259
+ }
260
+ }
261
+ if (option.presetArg !== undefined && option.optional) {
262
+ extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
263
+ }
264
+ if (option.envVar !== undefined) {
265
+ extraInfo.push(`env: ${option.envVar}`);
266
+ }
267
+ if (extraInfo.length > 0) {
268
+ const extraDescription = `(${extraInfo.join(", ")})`;
269
+ if (option.description) {
270
+ return `${option.description} ${extraDescription}`;
271
+ }
272
+ return extraDescription;
273
+ }
274
+ return option.description;
275
+ }
276
+ argumentDescription(argument) {
277
+ const extraInfo = [];
278
+ if (argument.argChoices) {
279
+ extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
280
+ }
281
+ if (argument.defaultValue !== undefined) {
282
+ extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
283
+ }
284
+ if (extraInfo.length > 0) {
285
+ const extraDescription = `(${extraInfo.join(", ")})`;
286
+ if (argument.description) {
287
+ return `${argument.description} ${extraDescription}`;
288
+ }
289
+ return extraDescription;
290
+ }
291
+ return argument.description;
292
+ }
293
+ formatItemList(heading, items, helper) {
294
+ if (items.length === 0)
295
+ return [];
296
+ return [helper.styleTitle(heading), ...items, ""];
297
+ }
298
+ groupItems(unsortedItems, visibleItems, getGroup) {
299
+ const result = new Map;
300
+ unsortedItems.forEach((item) => {
301
+ const group = getGroup(item);
302
+ if (!result.has(group))
303
+ result.set(group, []);
304
+ });
305
+ visibleItems.forEach((item) => {
306
+ const group = getGroup(item);
307
+ if (!result.has(group)) {
308
+ result.set(group, []);
309
+ }
310
+ result.get(group).push(item);
311
+ });
312
+ return result;
313
+ }
314
+ formatHelp(cmd, helper) {
315
+ const termWidth = helper.padWidth(cmd, helper);
316
+ const helpWidth = helper.helpWidth ?? 80;
317
+ function callFormatItem(term, description) {
318
+ return helper.formatItem(term, termWidth, description, helper);
319
+ }
320
+ let output = [
321
+ `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
322
+ ""
323
+ ];
324
+ const commandDescription = helper.commandDescription(cmd);
325
+ if (commandDescription.length > 0) {
326
+ output = output.concat([
327
+ helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
328
+ ""
329
+ ]);
330
+ }
331
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
332
+ return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
333
+ });
334
+ output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
335
+ const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
336
+ optionGroups.forEach((options, group) => {
337
+ const optionList = options.map((option) => {
338
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
339
+ });
340
+ output = output.concat(this.formatItemList(group, optionList, helper));
341
+ });
342
+ if (helper.showGlobalOptions) {
343
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
344
+ return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
345
+ });
346
+ output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
347
+ }
348
+ const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
349
+ commandGroups.forEach((commands, group) => {
350
+ const commandList = commands.map((sub) => {
351
+ return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
352
+ });
353
+ output = output.concat(this.formatItemList(group, commandList, helper));
354
+ });
355
+ return output.join(`
356
+ `);
357
+ }
358
+ displayWidth(str) {
359
+ return stripColor(str).length;
360
+ }
361
+ styleTitle(str) {
362
+ return str;
363
+ }
364
+ styleUsage(str) {
365
+ return str.split(" ").map((word) => {
366
+ if (word === "[options]")
367
+ return this.styleOptionText(word);
368
+ if (word === "[command]")
369
+ return this.styleSubcommandText(word);
370
+ if (word[0] === "[" || word[0] === "<")
371
+ return this.styleArgumentText(word);
372
+ return this.styleCommandText(word);
373
+ }).join(" ");
374
+ }
375
+ styleCommandDescription(str) {
376
+ return this.styleDescriptionText(str);
377
+ }
378
+ styleOptionDescription(str) {
379
+ return this.styleDescriptionText(str);
380
+ }
381
+ styleSubcommandDescription(str) {
382
+ return this.styleDescriptionText(str);
383
+ }
384
+ styleArgumentDescription(str) {
385
+ return this.styleDescriptionText(str);
386
+ }
387
+ styleDescriptionText(str) {
388
+ return str;
389
+ }
390
+ styleOptionTerm(str) {
391
+ return this.styleOptionText(str);
392
+ }
393
+ styleSubcommandTerm(str) {
394
+ return str.split(" ").map((word) => {
395
+ if (word === "[options]")
396
+ return this.styleOptionText(word);
397
+ if (word[0] === "[" || word[0] === "<")
398
+ return this.styleArgumentText(word);
399
+ return this.styleSubcommandText(word);
400
+ }).join(" ");
401
+ }
402
+ styleArgumentTerm(str) {
403
+ return this.styleArgumentText(str);
404
+ }
405
+ styleOptionText(str) {
406
+ return str;
407
+ }
408
+ styleArgumentText(str) {
409
+ return str;
410
+ }
411
+ styleSubcommandText(str) {
412
+ return str;
413
+ }
414
+ styleCommandText(str) {
415
+ return str;
416
+ }
417
+ padWidth(cmd, helper) {
418
+ return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
419
+ }
420
+ preformatted(str) {
421
+ return /\n[^\S\r\n]/.test(str);
422
+ }
423
+ formatItem(term, termWidth, description, helper) {
424
+ const itemIndent = 2;
425
+ const itemIndentStr = " ".repeat(itemIndent);
426
+ if (!description)
427
+ return itemIndentStr + term;
428
+ const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
429
+ const spacerWidth = 2;
430
+ const helpWidth = this.helpWidth ?? 80;
431
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
432
+ let formattedDescription;
433
+ if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
434
+ formattedDescription = description;
435
+ } else {
436
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
437
+ formattedDescription = wrappedDescription.replace(/\n/g, `
438
+ ` + " ".repeat(termWidth + spacerWidth));
439
+ }
440
+ return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
441
+ ${itemIndentStr}`);
442
+ }
443
+ boxWrap(str, width) {
444
+ if (width < this.minWidthToWrap)
445
+ return str;
446
+ const rawLines = str.split(/\r\n|\n/);
447
+ const chunkPattern = /[\s]*[^\s]+/g;
448
+ const wrappedLines = [];
449
+ rawLines.forEach((line) => {
450
+ const chunks = line.match(chunkPattern);
451
+ if (chunks === null) {
452
+ wrappedLines.push("");
453
+ return;
454
+ }
455
+ let sumChunks = [chunks.shift()];
456
+ let sumWidth = this.displayWidth(sumChunks[0]);
457
+ chunks.forEach((chunk) => {
458
+ const visibleWidth = this.displayWidth(chunk);
459
+ if (sumWidth + visibleWidth <= width) {
460
+ sumChunks.push(chunk);
461
+ sumWidth += visibleWidth;
462
+ return;
463
+ }
464
+ wrappedLines.push(sumChunks.join(""));
465
+ const nextChunk = chunk.trimStart();
466
+ sumChunks = [nextChunk];
467
+ sumWidth = this.displayWidth(nextChunk);
468
+ });
469
+ wrappedLines.push(sumChunks.join(""));
470
+ });
471
+ return wrappedLines.join(`
472
+ `);
473
+ }
474
+ }
475
+ function stripColor(str) {
476
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
477
+ return str.replace(sgrPattern, "");
478
+ }
479
+ exports.Help = Help;
480
+ exports.stripColor = stripColor;
481
+ });
482
+
483
+ // node_modules/commander/lib/option.js
484
+ var require_option = __commonJS((exports) => {
485
+ var { InvalidArgumentError } = require_error();
486
+
487
+ class Option {
488
+ constructor(flags, description) {
489
+ this.flags = flags;
490
+ this.description = description || "";
491
+ this.required = flags.includes("<");
492
+ this.optional = flags.includes("[");
493
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
494
+ this.mandatory = false;
495
+ const optionFlags = splitOptionFlags(flags);
496
+ this.short = optionFlags.shortFlag;
497
+ this.long = optionFlags.longFlag;
498
+ this.negate = false;
499
+ if (this.long) {
500
+ this.negate = this.long.startsWith("--no-");
501
+ }
502
+ this.defaultValue = undefined;
503
+ this.defaultValueDescription = undefined;
504
+ this.presetArg = undefined;
505
+ this.envVar = undefined;
506
+ this.parseArg = undefined;
507
+ this.hidden = false;
508
+ this.argChoices = undefined;
509
+ this.conflictsWith = [];
510
+ this.implied = undefined;
511
+ this.helpGroupHeading = undefined;
512
+ }
513
+ default(value, description) {
514
+ this.defaultValue = value;
515
+ this.defaultValueDescription = description;
516
+ return this;
517
+ }
518
+ preset(arg) {
519
+ this.presetArg = arg;
520
+ return this;
521
+ }
522
+ conflicts(names) {
523
+ this.conflictsWith = this.conflictsWith.concat(names);
524
+ return this;
525
+ }
526
+ implies(impliedOptionValues) {
527
+ let newImplied = impliedOptionValues;
528
+ if (typeof impliedOptionValues === "string") {
529
+ newImplied = { [impliedOptionValues]: true };
530
+ }
531
+ this.implied = Object.assign(this.implied || {}, newImplied);
532
+ return this;
533
+ }
534
+ env(name) {
535
+ this.envVar = name;
536
+ return this;
537
+ }
538
+ argParser(fn) {
539
+ this.parseArg = fn;
540
+ return this;
541
+ }
542
+ makeOptionMandatory(mandatory = true) {
543
+ this.mandatory = !!mandatory;
544
+ return this;
545
+ }
546
+ hideHelp(hide = true) {
547
+ this.hidden = !!hide;
548
+ return this;
549
+ }
550
+ _collectValue(value, previous) {
551
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
552
+ return [value];
553
+ }
554
+ previous.push(value);
555
+ return previous;
556
+ }
557
+ choices(values) {
558
+ this.argChoices = values.slice();
559
+ this.parseArg = (arg, previous) => {
560
+ if (!this.argChoices.includes(arg)) {
561
+ throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
562
+ }
563
+ if (this.variadic) {
564
+ return this._collectValue(arg, previous);
565
+ }
566
+ return arg;
567
+ };
568
+ return this;
569
+ }
570
+ name() {
571
+ if (this.long) {
572
+ return this.long.replace(/^--/, "");
573
+ }
574
+ return this.short.replace(/^-/, "");
575
+ }
576
+ attributeName() {
577
+ if (this.negate) {
578
+ return camelcase(this.name().replace(/^no-/, ""));
579
+ }
580
+ return camelcase(this.name());
581
+ }
582
+ helpGroup(heading) {
583
+ this.helpGroupHeading = heading;
584
+ return this;
585
+ }
586
+ is(arg) {
587
+ return this.short === arg || this.long === arg;
588
+ }
589
+ isBoolean() {
590
+ return !this.required && !this.optional && !this.negate;
591
+ }
592
+ }
593
+
594
+ class DualOptions {
595
+ constructor(options) {
596
+ this.positiveOptions = new Map;
597
+ this.negativeOptions = new Map;
598
+ this.dualOptions = new Set;
599
+ options.forEach((option) => {
600
+ if (option.negate) {
601
+ this.negativeOptions.set(option.attributeName(), option);
602
+ } else {
603
+ this.positiveOptions.set(option.attributeName(), option);
604
+ }
605
+ });
606
+ this.negativeOptions.forEach((value, key) => {
607
+ if (this.positiveOptions.has(key)) {
608
+ this.dualOptions.add(key);
609
+ }
610
+ });
611
+ }
612
+ valueFromOption(value, option) {
613
+ const optionKey = option.attributeName();
614
+ if (!this.dualOptions.has(optionKey))
615
+ return true;
616
+ const preset = this.negativeOptions.get(optionKey).presetArg;
617
+ const negativeValue = preset !== undefined ? preset : false;
618
+ return option.negate === (negativeValue === value);
619
+ }
620
+ }
621
+ function camelcase(str) {
622
+ return str.split("-").reduce((str2, word) => {
623
+ return str2 + word[0].toUpperCase() + word.slice(1);
624
+ });
625
+ }
626
+ function splitOptionFlags(flags) {
627
+ let shortFlag;
628
+ let longFlag;
629
+ const shortFlagExp = /^-[^-]$/;
630
+ const longFlagExp = /^--[^-]/;
631
+ const flagParts = flags.split(/[ |,]+/).concat("guard");
632
+ if (shortFlagExp.test(flagParts[0]))
633
+ shortFlag = flagParts.shift();
634
+ if (longFlagExp.test(flagParts[0]))
635
+ longFlag = flagParts.shift();
636
+ if (!shortFlag && shortFlagExp.test(flagParts[0]))
637
+ shortFlag = flagParts.shift();
638
+ if (!shortFlag && longFlagExp.test(flagParts[0])) {
639
+ shortFlag = longFlag;
640
+ longFlag = flagParts.shift();
641
+ }
642
+ if (flagParts[0].startsWith("-")) {
643
+ const unsupportedFlag = flagParts[0];
644
+ const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
645
+ if (/^-[^-][^-]/.test(unsupportedFlag))
646
+ throw new Error(`${baseError}
647
+ - a short flag is a single dash and a single character
648
+ - either use a single dash and a single character (for a short flag)
649
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
650
+ if (shortFlagExp.test(unsupportedFlag))
651
+ throw new Error(`${baseError}
652
+ - too many short flags`);
653
+ if (longFlagExp.test(unsupportedFlag))
654
+ throw new Error(`${baseError}
655
+ - too many long flags`);
656
+ throw new Error(`${baseError}
657
+ - unrecognised flag format`);
658
+ }
659
+ if (shortFlag === undefined && longFlag === undefined)
660
+ throw new Error(`option creation failed due to no flags found in '${flags}'.`);
661
+ return { shortFlag, longFlag };
662
+ }
663
+ exports.Option = Option;
664
+ exports.DualOptions = DualOptions;
665
+ });
666
+
667
+ // node_modules/commander/lib/suggestSimilar.js
668
+ var require_suggestSimilar = __commonJS((exports) => {
669
+ var maxDistance = 3;
670
+ function editDistance(a, b) {
671
+ if (Math.abs(a.length - b.length) > maxDistance)
672
+ return Math.max(a.length, b.length);
673
+ const d = [];
674
+ for (let i = 0;i <= a.length; i++) {
675
+ d[i] = [i];
676
+ }
677
+ for (let j = 0;j <= b.length; j++) {
678
+ d[0][j] = j;
679
+ }
680
+ for (let j = 1;j <= b.length; j++) {
681
+ for (let i = 1;i <= a.length; i++) {
682
+ let cost = 1;
683
+ if (a[i - 1] === b[j - 1]) {
684
+ cost = 0;
685
+ } else {
686
+ cost = 1;
687
+ }
688
+ d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
689
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
690
+ d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
691
+ }
692
+ }
693
+ }
694
+ return d[a.length][b.length];
695
+ }
696
+ function suggestSimilar(word, candidates) {
697
+ if (!candidates || candidates.length === 0)
698
+ return "";
699
+ candidates = Array.from(new Set(candidates));
700
+ const searchingOptions = word.startsWith("--");
701
+ if (searchingOptions) {
702
+ word = word.slice(2);
703
+ candidates = candidates.map((candidate) => candidate.slice(2));
704
+ }
705
+ let similar = [];
706
+ let bestDistance = maxDistance;
707
+ const minSimilarity = 0.4;
708
+ candidates.forEach((candidate) => {
709
+ if (candidate.length <= 1)
710
+ return;
711
+ const distance = editDistance(word, candidate);
712
+ const length = Math.max(word.length, candidate.length);
713
+ const similarity = (length - distance) / length;
714
+ if (similarity > minSimilarity) {
715
+ if (distance < bestDistance) {
716
+ bestDistance = distance;
717
+ similar = [candidate];
718
+ } else if (distance === bestDistance) {
719
+ similar.push(candidate);
720
+ }
721
+ }
722
+ });
723
+ similar.sort((a, b) => a.localeCompare(b));
724
+ if (searchingOptions) {
725
+ similar = similar.map((candidate) => `--${candidate}`);
726
+ }
727
+ if (similar.length > 1) {
728
+ return `
729
+ (Did you mean one of ${similar.join(", ")}?)`;
730
+ }
731
+ if (similar.length === 1) {
732
+ return `
733
+ (Did you mean ${similar[0]}?)`;
734
+ }
735
+ return "";
736
+ }
737
+ exports.suggestSimilar = suggestSimilar;
738
+ });
739
+
740
+ // node_modules/commander/lib/command.js
741
+ var require_command = __commonJS((exports) => {
742
+ var EventEmitter = __require("node:events").EventEmitter;
743
+ var childProcess = __require("node:child_process");
744
+ var path = __require("node:path");
745
+ var fs = __require("node:fs");
746
+ var process2 = __require("node:process");
747
+ var { Argument, humanReadableArgName } = require_argument();
748
+ var { CommanderError } = require_error();
749
+ var { Help, stripColor } = require_help();
750
+ var { Option, DualOptions } = require_option();
751
+ var { suggestSimilar } = require_suggestSimilar();
752
+
753
+ class Command extends EventEmitter {
754
+ constructor(name) {
755
+ super();
756
+ this.commands = [];
757
+ this.options = [];
758
+ this.parent = null;
759
+ this._allowUnknownOption = false;
760
+ this._allowExcessArguments = false;
761
+ this.registeredArguments = [];
762
+ this._args = this.registeredArguments;
763
+ this.args = [];
764
+ this.rawArgs = [];
765
+ this.processedArgs = [];
766
+ this._scriptPath = null;
767
+ this._name = name || "";
768
+ this._optionValues = {};
769
+ this._optionValueSources = {};
770
+ this._storeOptionsAsProperties = false;
771
+ this._actionHandler = null;
772
+ this._executableHandler = false;
773
+ this._executableFile = null;
774
+ this._executableDir = null;
775
+ this._defaultCommandName = null;
776
+ this._exitCallback = null;
777
+ this._aliases = [];
778
+ this._combineFlagAndOptionalValue = true;
779
+ this._description = "";
780
+ this._summary = "";
781
+ this._argsDescription = undefined;
782
+ this._enablePositionalOptions = false;
783
+ this._passThroughOptions = false;
784
+ this._lifeCycleHooks = {};
785
+ this._showHelpAfterError = false;
786
+ this._showSuggestionAfterError = true;
787
+ this._savedState = null;
788
+ this._outputConfiguration = {
789
+ writeOut: (str) => process2.stdout.write(str),
790
+ writeErr: (str) => process2.stderr.write(str),
791
+ outputError: (str, write) => write(str),
792
+ getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
793
+ getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
794
+ getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()),
795
+ getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
796
+ stripColor: (str) => stripColor(str)
797
+ };
798
+ this._hidden = false;
799
+ this._helpOption = undefined;
800
+ this._addImplicitHelpCommand = undefined;
801
+ this._helpCommand = undefined;
802
+ this._helpConfiguration = {};
803
+ this._helpGroupHeading = undefined;
804
+ this._defaultCommandGroup = undefined;
805
+ this._defaultOptionGroup = undefined;
806
+ }
807
+ copyInheritedSettings(sourceCommand) {
808
+ this._outputConfiguration = sourceCommand._outputConfiguration;
809
+ this._helpOption = sourceCommand._helpOption;
810
+ this._helpCommand = sourceCommand._helpCommand;
811
+ this._helpConfiguration = sourceCommand._helpConfiguration;
812
+ this._exitCallback = sourceCommand._exitCallback;
813
+ this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
814
+ this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
815
+ this._allowExcessArguments = sourceCommand._allowExcessArguments;
816
+ this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
817
+ this._showHelpAfterError = sourceCommand._showHelpAfterError;
818
+ this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
819
+ return this;
820
+ }
821
+ _getCommandAndAncestors() {
822
+ const result = [];
823
+ for (let command = this;command; command = command.parent) {
824
+ result.push(command);
825
+ }
826
+ return result;
827
+ }
828
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
829
+ let desc = actionOptsOrExecDesc;
830
+ let opts = execOpts;
831
+ if (typeof desc === "object" && desc !== null) {
832
+ opts = desc;
833
+ desc = null;
834
+ }
835
+ opts = opts || {};
836
+ const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
837
+ const cmd = this.createCommand(name);
838
+ if (desc) {
839
+ cmd.description(desc);
840
+ cmd._executableHandler = true;
841
+ }
842
+ if (opts.isDefault)
843
+ this._defaultCommandName = cmd._name;
844
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
845
+ cmd._executableFile = opts.executableFile || null;
846
+ if (args)
847
+ cmd.arguments(args);
848
+ this._registerCommand(cmd);
849
+ cmd.parent = this;
850
+ cmd.copyInheritedSettings(this);
851
+ if (desc)
852
+ return this;
853
+ return cmd;
854
+ }
855
+ createCommand(name) {
856
+ return new Command(name);
857
+ }
858
+ createHelp() {
859
+ return Object.assign(new Help, this.configureHelp());
860
+ }
861
+ configureHelp(configuration) {
862
+ if (configuration === undefined)
863
+ return this._helpConfiguration;
864
+ this._helpConfiguration = configuration;
865
+ return this;
866
+ }
867
+ configureOutput(configuration) {
868
+ if (configuration === undefined)
869
+ return this._outputConfiguration;
870
+ this._outputConfiguration = {
871
+ ...this._outputConfiguration,
872
+ ...configuration
873
+ };
874
+ return this;
875
+ }
876
+ showHelpAfterError(displayHelp = true) {
877
+ if (typeof displayHelp !== "string")
878
+ displayHelp = !!displayHelp;
879
+ this._showHelpAfterError = displayHelp;
880
+ return this;
881
+ }
882
+ showSuggestionAfterError(displaySuggestion = true) {
883
+ this._showSuggestionAfterError = !!displaySuggestion;
884
+ return this;
885
+ }
886
+ addCommand(cmd, opts) {
887
+ if (!cmd._name) {
888
+ throw new Error(`Command passed to .addCommand() must have a name
889
+ - specify the name in Command constructor or using .name()`);
890
+ }
891
+ opts = opts || {};
892
+ if (opts.isDefault)
893
+ this._defaultCommandName = cmd._name;
894
+ if (opts.noHelp || opts.hidden)
895
+ cmd._hidden = true;
896
+ this._registerCommand(cmd);
897
+ cmd.parent = this;
898
+ cmd._checkForBrokenPassThrough();
899
+ return this;
900
+ }
901
+ createArgument(name, description) {
902
+ return new Argument(name, description);
903
+ }
904
+ argument(name, description, parseArg, defaultValue) {
905
+ const argument = this.createArgument(name, description);
906
+ if (typeof parseArg === "function") {
907
+ argument.default(defaultValue).argParser(parseArg);
908
+ } else {
909
+ argument.default(parseArg);
910
+ }
911
+ this.addArgument(argument);
912
+ return this;
913
+ }
914
+ arguments(names) {
915
+ names.trim().split(/ +/).forEach((detail) => {
916
+ this.argument(detail);
917
+ });
918
+ return this;
919
+ }
920
+ addArgument(argument) {
921
+ const previousArgument = this.registeredArguments.slice(-1)[0];
922
+ if (previousArgument?.variadic) {
923
+ throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
924
+ }
925
+ if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
926
+ throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
927
+ }
928
+ this.registeredArguments.push(argument);
929
+ return this;
930
+ }
931
+ helpCommand(enableOrNameAndArgs, description) {
932
+ if (typeof enableOrNameAndArgs === "boolean") {
933
+ this._addImplicitHelpCommand = enableOrNameAndArgs;
934
+ if (enableOrNameAndArgs && this._defaultCommandGroup) {
935
+ this._initCommandGroup(this._getHelpCommand());
936
+ }
937
+ return this;
938
+ }
939
+ const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
940
+ const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
941
+ const helpDescription = description ?? "display help for command";
942
+ const helpCommand = this.createCommand(helpName);
943
+ helpCommand.helpOption(false);
944
+ if (helpArgs)
945
+ helpCommand.arguments(helpArgs);
946
+ if (helpDescription)
947
+ helpCommand.description(helpDescription);
948
+ this._addImplicitHelpCommand = true;
949
+ this._helpCommand = helpCommand;
950
+ if (enableOrNameAndArgs || description)
951
+ this._initCommandGroup(helpCommand);
952
+ return this;
953
+ }
954
+ addHelpCommand(helpCommand, deprecatedDescription) {
955
+ if (typeof helpCommand !== "object") {
956
+ this.helpCommand(helpCommand, deprecatedDescription);
957
+ return this;
958
+ }
959
+ this._addImplicitHelpCommand = true;
960
+ this._helpCommand = helpCommand;
961
+ this._initCommandGroup(helpCommand);
962
+ return this;
963
+ }
964
+ _getHelpCommand() {
965
+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
966
+ if (hasImplicitHelpCommand) {
967
+ if (this._helpCommand === undefined) {
968
+ this.helpCommand(undefined, undefined);
969
+ }
970
+ return this._helpCommand;
971
+ }
972
+ return null;
973
+ }
974
+ hook(event, listener) {
975
+ const allowedValues = ["preSubcommand", "preAction", "postAction"];
976
+ if (!allowedValues.includes(event)) {
977
+ throw new Error(`Unexpected value for event passed to hook : '${event}'.
978
+ Expecting one of '${allowedValues.join("', '")}'`);
979
+ }
980
+ if (this._lifeCycleHooks[event]) {
981
+ this._lifeCycleHooks[event].push(listener);
982
+ } else {
983
+ this._lifeCycleHooks[event] = [listener];
984
+ }
985
+ return this;
986
+ }
987
+ exitOverride(fn) {
988
+ if (fn) {
989
+ this._exitCallback = fn;
990
+ } else {
991
+ this._exitCallback = (err) => {
992
+ if (err.code !== "commander.executeSubCommandAsync") {
993
+ throw err;
994
+ } else {}
995
+ };
996
+ }
997
+ return this;
998
+ }
999
+ _exit(exitCode, code, message) {
1000
+ if (this._exitCallback) {
1001
+ this._exitCallback(new CommanderError(exitCode, code, message));
1002
+ }
1003
+ process2.exit(exitCode);
1004
+ }
1005
+ action(fn) {
1006
+ const listener = (args) => {
1007
+ const expectedArgsCount = this.registeredArguments.length;
1008
+ const actionArgs = args.slice(0, expectedArgsCount);
1009
+ if (this._storeOptionsAsProperties) {
1010
+ actionArgs[expectedArgsCount] = this;
1011
+ } else {
1012
+ actionArgs[expectedArgsCount] = this.opts();
1013
+ }
1014
+ actionArgs.push(this);
1015
+ return fn.apply(this, actionArgs);
1016
+ };
1017
+ this._actionHandler = listener;
1018
+ return this;
1019
+ }
1020
+ createOption(flags, description) {
1021
+ return new Option(flags, description);
1022
+ }
1023
+ _callParseArg(target, value, previous, invalidArgumentMessage) {
1024
+ try {
1025
+ return target.parseArg(value, previous);
1026
+ } catch (err) {
1027
+ if (err.code === "commander.invalidArgument") {
1028
+ const message = `${invalidArgumentMessage} ${err.message}`;
1029
+ this.error(message, { exitCode: err.exitCode, code: err.code });
1030
+ }
1031
+ throw err;
1032
+ }
1033
+ }
1034
+ _registerOption(option) {
1035
+ const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
1036
+ if (matchingOption) {
1037
+ const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
1038
+ throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1039
+ - already used by option '${matchingOption.flags}'`);
1040
+ }
1041
+ this._initOptionGroup(option);
1042
+ this.options.push(option);
1043
+ }
1044
+ _registerCommand(command) {
1045
+ const knownBy = (cmd) => {
1046
+ return [cmd.name()].concat(cmd.aliases());
1047
+ };
1048
+ const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
1049
+ if (alreadyUsed) {
1050
+ const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
1051
+ const newCmd = knownBy(command).join("|");
1052
+ throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
1053
+ }
1054
+ this._initCommandGroup(command);
1055
+ this.commands.push(command);
1056
+ }
1057
+ addOption(option) {
1058
+ this._registerOption(option);
1059
+ const oname = option.name();
1060
+ const name = option.attributeName();
1061
+ if (option.negate) {
1062
+ const positiveLongFlag = option.long.replace(/^--no-/, "--");
1063
+ if (!this._findOption(positiveLongFlag)) {
1064
+ this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, "default");
1065
+ }
1066
+ } else if (option.defaultValue !== undefined) {
1067
+ this.setOptionValueWithSource(name, option.defaultValue, "default");
1068
+ }
1069
+ const handleOptionValue = (val, invalidValueMessage, valueSource) => {
1070
+ if (val == null && option.presetArg !== undefined) {
1071
+ val = option.presetArg;
1072
+ }
1073
+ const oldValue = this.getOptionValue(name);
1074
+ if (val !== null && option.parseArg) {
1075
+ val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1076
+ } else if (val !== null && option.variadic) {
1077
+ val = option._collectValue(val, oldValue);
1078
+ }
1079
+ if (val == null) {
1080
+ if (option.negate) {
1081
+ val = false;
1082
+ } else if (option.isBoolean() || option.optional) {
1083
+ val = true;
1084
+ } else {
1085
+ val = "";
1086
+ }
1087
+ }
1088
+ this.setOptionValueWithSource(name, val, valueSource);
1089
+ };
1090
+ this.on("option:" + oname, (val) => {
1091
+ const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1092
+ handleOptionValue(val, invalidValueMessage, "cli");
1093
+ });
1094
+ if (option.envVar) {
1095
+ this.on("optionEnv:" + oname, (val) => {
1096
+ const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1097
+ handleOptionValue(val, invalidValueMessage, "env");
1098
+ });
1099
+ }
1100
+ return this;
1101
+ }
1102
+ _optionEx(config, flags, description, fn, defaultValue) {
1103
+ if (typeof flags === "object" && flags instanceof Option) {
1104
+ throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
1105
+ }
1106
+ const option = this.createOption(flags, description);
1107
+ option.makeOptionMandatory(!!config.mandatory);
1108
+ if (typeof fn === "function") {
1109
+ option.default(defaultValue).argParser(fn);
1110
+ } else if (fn instanceof RegExp) {
1111
+ const regex = fn;
1112
+ fn = (val, def) => {
1113
+ const m = regex.exec(val);
1114
+ return m ? m[0] : def;
1115
+ };
1116
+ option.default(defaultValue).argParser(fn);
1117
+ } else {
1118
+ option.default(fn);
1119
+ }
1120
+ return this.addOption(option);
1121
+ }
1122
+ option(flags, description, parseArg, defaultValue) {
1123
+ return this._optionEx({}, flags, description, parseArg, defaultValue);
1124
+ }
1125
+ requiredOption(flags, description, parseArg, defaultValue) {
1126
+ return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
1127
+ }
1128
+ combineFlagAndOptionalValue(combine = true) {
1129
+ this._combineFlagAndOptionalValue = !!combine;
1130
+ return this;
1131
+ }
1132
+ allowUnknownOption(allowUnknown = true) {
1133
+ this._allowUnknownOption = !!allowUnknown;
1134
+ return this;
1135
+ }
1136
+ allowExcessArguments(allowExcess = true) {
1137
+ this._allowExcessArguments = !!allowExcess;
1138
+ return this;
1139
+ }
1140
+ enablePositionalOptions(positional = true) {
1141
+ this._enablePositionalOptions = !!positional;
1142
+ return this;
1143
+ }
1144
+ passThroughOptions(passThrough = true) {
1145
+ this._passThroughOptions = !!passThrough;
1146
+ this._checkForBrokenPassThrough();
1147
+ return this;
1148
+ }
1149
+ _checkForBrokenPassThrough() {
1150
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
1151
+ throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
1152
+ }
1153
+ }
1154
+ storeOptionsAsProperties(storeAsProperties = true) {
1155
+ if (this.options.length) {
1156
+ throw new Error("call .storeOptionsAsProperties() before adding options");
1157
+ }
1158
+ if (Object.keys(this._optionValues).length) {
1159
+ throw new Error("call .storeOptionsAsProperties() before setting option values");
1160
+ }
1161
+ this._storeOptionsAsProperties = !!storeAsProperties;
1162
+ return this;
1163
+ }
1164
+ getOptionValue(key) {
1165
+ if (this._storeOptionsAsProperties) {
1166
+ return this[key];
1167
+ }
1168
+ return this._optionValues[key];
1169
+ }
1170
+ setOptionValue(key, value) {
1171
+ return this.setOptionValueWithSource(key, value, undefined);
1172
+ }
1173
+ setOptionValueWithSource(key, value, source) {
1174
+ if (this._storeOptionsAsProperties) {
1175
+ this[key] = value;
1176
+ } else {
1177
+ this._optionValues[key] = value;
1178
+ }
1179
+ this._optionValueSources[key] = source;
1180
+ return this;
1181
+ }
1182
+ getOptionValueSource(key) {
1183
+ return this._optionValueSources[key];
1184
+ }
1185
+ getOptionValueSourceWithGlobals(key) {
1186
+ let source;
1187
+ this._getCommandAndAncestors().forEach((cmd) => {
1188
+ if (cmd.getOptionValueSource(key) !== undefined) {
1189
+ source = cmd.getOptionValueSource(key);
1190
+ }
1191
+ });
1192
+ return source;
1193
+ }
1194
+ _prepareUserArgs(argv, parseOptions) {
1195
+ if (argv !== undefined && !Array.isArray(argv)) {
1196
+ throw new Error("first parameter to parse must be array or undefined");
1197
+ }
1198
+ parseOptions = parseOptions || {};
1199
+ if (argv === undefined && parseOptions.from === undefined) {
1200
+ if (process2.versions?.electron) {
1201
+ parseOptions.from = "electron";
1202
+ }
1203
+ const execArgv = process2.execArgv ?? [];
1204
+ if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1205
+ parseOptions.from = "eval";
1206
+ }
1207
+ }
1208
+ if (argv === undefined) {
1209
+ argv = process2.argv;
1210
+ }
1211
+ this.rawArgs = argv.slice();
1212
+ let userArgs;
1213
+ switch (parseOptions.from) {
1214
+ case undefined:
1215
+ case "node":
1216
+ this._scriptPath = argv[1];
1217
+ userArgs = argv.slice(2);
1218
+ break;
1219
+ case "electron":
1220
+ if (process2.defaultApp) {
1221
+ this._scriptPath = argv[1];
1222
+ userArgs = argv.slice(2);
1223
+ } else {
1224
+ userArgs = argv.slice(1);
1225
+ }
1226
+ break;
1227
+ case "user":
1228
+ userArgs = argv.slice(0);
1229
+ break;
1230
+ case "eval":
1231
+ userArgs = argv.slice(1);
1232
+ break;
1233
+ default:
1234
+ throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
1235
+ }
1236
+ if (!this._name && this._scriptPath)
1237
+ this.nameFromFilename(this._scriptPath);
1238
+ this._name = this._name || "program";
1239
+ return userArgs;
1240
+ }
1241
+ parse(argv, parseOptions) {
1242
+ this._prepareForParse();
1243
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1244
+ this._parseCommand([], userArgs);
1245
+ return this;
1246
+ }
1247
+ async parseAsync(argv, parseOptions) {
1248
+ this._prepareForParse();
1249
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1250
+ await this._parseCommand([], userArgs);
1251
+ return this;
1252
+ }
1253
+ _prepareForParse() {
1254
+ if (this._savedState === null) {
1255
+ this.saveStateBeforeParse();
1256
+ } else {
1257
+ this.restoreStateBeforeParse();
1258
+ }
1259
+ }
1260
+ saveStateBeforeParse() {
1261
+ this._savedState = {
1262
+ _name: this._name,
1263
+ _optionValues: { ...this._optionValues },
1264
+ _optionValueSources: { ...this._optionValueSources }
1265
+ };
1266
+ }
1267
+ restoreStateBeforeParse() {
1268
+ if (this._storeOptionsAsProperties)
1269
+ throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
1270
+ - either make a new Command for each call to parse, or stop storing options as properties`);
1271
+ this._name = this._savedState._name;
1272
+ this._scriptPath = null;
1273
+ this.rawArgs = [];
1274
+ this._optionValues = { ...this._savedState._optionValues };
1275
+ this._optionValueSources = { ...this._savedState._optionValueSources };
1276
+ this.args = [];
1277
+ this.processedArgs = [];
1278
+ }
1279
+ _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
1280
+ if (fs.existsSync(executableFile))
1281
+ return;
1282
+ const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
1283
+ const executableMissing = `'${executableFile}' does not exist
1284
+ - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
1285
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
1286
+ - ${executableDirMessage}`;
1287
+ throw new Error(executableMissing);
1288
+ }
1289
+ _executeSubCommand(subcommand, args) {
1290
+ args = args.slice();
1291
+ let launchWithNode = false;
1292
+ const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1293
+ function findFile(baseDir, baseName) {
1294
+ const localBin = path.resolve(baseDir, baseName);
1295
+ if (fs.existsSync(localBin))
1296
+ return localBin;
1297
+ if (sourceExt.includes(path.extname(baseName)))
1298
+ return;
1299
+ const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
1300
+ if (foundExt)
1301
+ return `${localBin}${foundExt}`;
1302
+ return;
1303
+ }
1304
+ this._checkForMissingMandatoryOptions();
1305
+ this._checkForConflictingOptions();
1306
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
1307
+ let executableDir = this._executableDir || "";
1308
+ if (this._scriptPath) {
1309
+ let resolvedScriptPath;
1310
+ try {
1311
+ resolvedScriptPath = fs.realpathSync(this._scriptPath);
1312
+ } catch {
1313
+ resolvedScriptPath = this._scriptPath;
1314
+ }
1315
+ executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
1316
+ }
1317
+ if (executableDir) {
1318
+ let localFile = findFile(executableDir, executableFile);
1319
+ if (!localFile && !subcommand._executableFile && this._scriptPath) {
1320
+ const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
1321
+ if (legacyName !== this._name) {
1322
+ localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1323
+ }
1324
+ }
1325
+ executableFile = localFile || executableFile;
1326
+ }
1327
+ launchWithNode = sourceExt.includes(path.extname(executableFile));
1328
+ let proc;
1329
+ if (process2.platform !== "win32") {
1330
+ if (launchWithNode) {
1331
+ args.unshift(executableFile);
1332
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1333
+ proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
1334
+ } else {
1335
+ proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1336
+ }
1337
+ } else {
1338
+ this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
1339
+ args.unshift(executableFile);
1340
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1341
+ proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
1342
+ }
1343
+ if (!proc.killed) {
1344
+ const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1345
+ signals.forEach((signal) => {
1346
+ process2.on(signal, () => {
1347
+ if (proc.killed === false && proc.exitCode === null) {
1348
+ proc.kill(signal);
1349
+ }
1350
+ });
1351
+ });
1352
+ }
1353
+ const exitCallback = this._exitCallback;
1354
+ proc.on("close", (code) => {
1355
+ code = code ?? 1;
1356
+ if (!exitCallback) {
1357
+ process2.exit(code);
1358
+ } else {
1359
+ exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
1360
+ }
1361
+ });
1362
+ proc.on("error", (err) => {
1363
+ if (err.code === "ENOENT") {
1364
+ this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
1365
+ } else if (err.code === "EACCES") {
1366
+ throw new Error(`'${executableFile}' not executable`);
1367
+ }
1368
+ if (!exitCallback) {
1369
+ process2.exit(1);
1370
+ } else {
1371
+ const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
1372
+ wrappedError.nestedError = err;
1373
+ exitCallback(wrappedError);
1374
+ }
1375
+ });
1376
+ this.runningCommand = proc;
1377
+ }
1378
+ _dispatchSubcommand(commandName, operands, unknown) {
1379
+ const subCommand = this._findCommand(commandName);
1380
+ if (!subCommand)
1381
+ this.help({ error: true });
1382
+ subCommand._prepareForParse();
1383
+ let promiseChain;
1384
+ promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
1385
+ promiseChain = this._chainOrCall(promiseChain, () => {
1386
+ if (subCommand._executableHandler) {
1387
+ this._executeSubCommand(subCommand, operands.concat(unknown));
1388
+ } else {
1389
+ return subCommand._parseCommand(operands, unknown);
1390
+ }
1391
+ });
1392
+ return promiseChain;
1393
+ }
1394
+ _dispatchHelpCommand(subcommandName) {
1395
+ if (!subcommandName) {
1396
+ this.help();
1397
+ }
1398
+ const subCommand = this._findCommand(subcommandName);
1399
+ if (subCommand && !subCommand._executableHandler) {
1400
+ subCommand.help();
1401
+ }
1402
+ return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
1403
+ }
1404
+ _checkNumberOfArguments() {
1405
+ this.registeredArguments.forEach((arg, i) => {
1406
+ if (arg.required && this.args[i] == null) {
1407
+ this.missingArgument(arg.name());
1408
+ }
1409
+ });
1410
+ if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
1411
+ return;
1412
+ }
1413
+ if (this.args.length > this.registeredArguments.length) {
1414
+ this._excessArguments(this.args);
1415
+ }
1416
+ }
1417
+ _processArguments() {
1418
+ const myParseArg = (argument, value, previous) => {
1419
+ let parsedValue = value;
1420
+ if (value !== null && argument.parseArg) {
1421
+ const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
1422
+ parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
1423
+ }
1424
+ return parsedValue;
1425
+ };
1426
+ this._checkNumberOfArguments();
1427
+ const processedArgs = [];
1428
+ this.registeredArguments.forEach((declaredArg, index) => {
1429
+ let value = declaredArg.defaultValue;
1430
+ if (declaredArg.variadic) {
1431
+ if (index < this.args.length) {
1432
+ value = this.args.slice(index);
1433
+ if (declaredArg.parseArg) {
1434
+ value = value.reduce((processed, v) => {
1435
+ return myParseArg(declaredArg, v, processed);
1436
+ }, declaredArg.defaultValue);
1437
+ }
1438
+ } else if (value === undefined) {
1439
+ value = [];
1440
+ }
1441
+ } else if (index < this.args.length) {
1442
+ value = this.args[index];
1443
+ if (declaredArg.parseArg) {
1444
+ value = myParseArg(declaredArg, value, declaredArg.defaultValue);
1445
+ }
1446
+ }
1447
+ processedArgs[index] = value;
1448
+ });
1449
+ this.processedArgs = processedArgs;
1450
+ }
1451
+ _chainOrCall(promise, fn) {
1452
+ if (promise?.then && typeof promise.then === "function") {
1453
+ return promise.then(() => fn());
1454
+ }
1455
+ return fn();
1456
+ }
1457
+ _chainOrCallHooks(promise, event) {
1458
+ let result = promise;
1459
+ const hooks = [];
1460
+ this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
1461
+ hookedCommand._lifeCycleHooks[event].forEach((callback) => {
1462
+ hooks.push({ hookedCommand, callback });
1463
+ });
1464
+ });
1465
+ if (event === "postAction") {
1466
+ hooks.reverse();
1467
+ }
1468
+ hooks.forEach((hookDetail) => {
1469
+ result = this._chainOrCall(result, () => {
1470
+ return hookDetail.callback(hookDetail.hookedCommand, this);
1471
+ });
1472
+ });
1473
+ return result;
1474
+ }
1475
+ _chainOrCallSubCommandHook(promise, subCommand, event) {
1476
+ let result = promise;
1477
+ if (this._lifeCycleHooks[event] !== undefined) {
1478
+ this._lifeCycleHooks[event].forEach((hook) => {
1479
+ result = this._chainOrCall(result, () => {
1480
+ return hook(this, subCommand);
1481
+ });
1482
+ });
1483
+ }
1484
+ return result;
1485
+ }
1486
+ _parseCommand(operands, unknown) {
1487
+ const parsed = this.parseOptions(unknown);
1488
+ this._parseOptionsEnv();
1489
+ this._parseOptionsImplied();
1490
+ operands = operands.concat(parsed.operands);
1491
+ unknown = parsed.unknown;
1492
+ this.args = operands.concat(unknown);
1493
+ if (operands && this._findCommand(operands[0])) {
1494
+ return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
1495
+ }
1496
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
1497
+ return this._dispatchHelpCommand(operands[1]);
1498
+ }
1499
+ if (this._defaultCommandName) {
1500
+ this._outputHelpIfRequested(unknown);
1501
+ return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
1502
+ }
1503
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
1504
+ this.help({ error: true });
1505
+ }
1506
+ this._outputHelpIfRequested(parsed.unknown);
1507
+ this._checkForMissingMandatoryOptions();
1508
+ this._checkForConflictingOptions();
1509
+ const checkForUnknownOptions = () => {
1510
+ if (parsed.unknown.length > 0) {
1511
+ this.unknownOption(parsed.unknown[0]);
1512
+ }
1513
+ };
1514
+ const commandEvent = `command:${this.name()}`;
1515
+ if (this._actionHandler) {
1516
+ checkForUnknownOptions();
1517
+ this._processArguments();
1518
+ let promiseChain;
1519
+ promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
1520
+ promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
1521
+ if (this.parent) {
1522
+ promiseChain = this._chainOrCall(promiseChain, () => {
1523
+ this.parent.emit(commandEvent, operands, unknown);
1524
+ });
1525
+ }
1526
+ promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
1527
+ return promiseChain;
1528
+ }
1529
+ if (this.parent?.listenerCount(commandEvent)) {
1530
+ checkForUnknownOptions();
1531
+ this._processArguments();
1532
+ this.parent.emit(commandEvent, operands, unknown);
1533
+ } else if (operands.length) {
1534
+ if (this._findCommand("*")) {
1535
+ return this._dispatchSubcommand("*", operands, unknown);
1536
+ }
1537
+ if (this.listenerCount("command:*")) {
1538
+ this.emit("command:*", operands, unknown);
1539
+ } else if (this.commands.length) {
1540
+ this.unknownCommand();
1541
+ } else {
1542
+ checkForUnknownOptions();
1543
+ this._processArguments();
1544
+ }
1545
+ } else if (this.commands.length) {
1546
+ checkForUnknownOptions();
1547
+ this.help({ error: true });
1548
+ } else {
1549
+ checkForUnknownOptions();
1550
+ this._processArguments();
1551
+ }
1552
+ }
1553
+ _findCommand(name) {
1554
+ if (!name)
1555
+ return;
1556
+ return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
1557
+ }
1558
+ _findOption(arg) {
1559
+ return this.options.find((option) => option.is(arg));
1560
+ }
1561
+ _checkForMissingMandatoryOptions() {
1562
+ this._getCommandAndAncestors().forEach((cmd) => {
1563
+ cmd.options.forEach((anOption) => {
1564
+ if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) {
1565
+ cmd.missingMandatoryOptionValue(anOption);
1566
+ }
1567
+ });
1568
+ });
1569
+ }
1570
+ _checkForConflictingLocalOptions() {
1571
+ const definedNonDefaultOptions = this.options.filter((option) => {
1572
+ const optionKey = option.attributeName();
1573
+ if (this.getOptionValue(optionKey) === undefined) {
1574
+ return false;
1575
+ }
1576
+ return this.getOptionValueSource(optionKey) !== "default";
1577
+ });
1578
+ const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
1579
+ optionsWithConflicting.forEach((option) => {
1580
+ const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
1581
+ if (conflictingAndDefined) {
1582
+ this._conflictingOption(option, conflictingAndDefined);
1583
+ }
1584
+ });
1585
+ }
1586
+ _checkForConflictingOptions() {
1587
+ this._getCommandAndAncestors().forEach((cmd) => {
1588
+ cmd._checkForConflictingLocalOptions();
1589
+ });
1590
+ }
1591
+ parseOptions(args) {
1592
+ const operands = [];
1593
+ const unknown = [];
1594
+ let dest = operands;
1595
+ function maybeOption(arg) {
1596
+ return arg.length > 1 && arg[0] === "-";
1597
+ }
1598
+ const negativeNumberArg = (arg) => {
1599
+ if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
1600
+ return false;
1601
+ return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
1602
+ };
1603
+ let activeVariadicOption = null;
1604
+ let activeGroup = null;
1605
+ let i = 0;
1606
+ while (i < args.length || activeGroup) {
1607
+ const arg = activeGroup ?? args[i++];
1608
+ activeGroup = null;
1609
+ if (arg === "--") {
1610
+ if (dest === unknown)
1611
+ dest.push(arg);
1612
+ dest.push(...args.slice(i));
1613
+ break;
1614
+ }
1615
+ if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
1616
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
1617
+ continue;
1618
+ }
1619
+ activeVariadicOption = null;
1620
+ if (maybeOption(arg)) {
1621
+ const option = this._findOption(arg);
1622
+ if (option) {
1623
+ if (option.required) {
1624
+ const value = args[i++];
1625
+ if (value === undefined)
1626
+ this.optionMissingArgument(option);
1627
+ this.emit(`option:${option.name()}`, value);
1628
+ } else if (option.optional) {
1629
+ let value = null;
1630
+ if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
1631
+ value = args[i++];
1632
+ }
1633
+ this.emit(`option:${option.name()}`, value);
1634
+ } else {
1635
+ this.emit(`option:${option.name()}`);
1636
+ }
1637
+ activeVariadicOption = option.variadic ? option : null;
1638
+ continue;
1639
+ }
1640
+ }
1641
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
1642
+ const option = this._findOption(`-${arg[1]}`);
1643
+ if (option) {
1644
+ if (option.required || option.optional && this._combineFlagAndOptionalValue) {
1645
+ this.emit(`option:${option.name()}`, arg.slice(2));
1646
+ } else {
1647
+ this.emit(`option:${option.name()}`);
1648
+ activeGroup = `-${arg.slice(2)}`;
1649
+ }
1650
+ continue;
1651
+ }
1652
+ }
1653
+ if (/^--[^=]+=/.test(arg)) {
1654
+ const index = arg.indexOf("=");
1655
+ const option = this._findOption(arg.slice(0, index));
1656
+ if (option && (option.required || option.optional)) {
1657
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
1658
+ continue;
1659
+ }
1660
+ }
1661
+ if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
1662
+ dest = unknown;
1663
+ }
1664
+ if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
1665
+ if (this._findCommand(arg)) {
1666
+ operands.push(arg);
1667
+ unknown.push(...args.slice(i));
1668
+ break;
1669
+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
1670
+ operands.push(arg, ...args.slice(i));
1671
+ break;
1672
+ } else if (this._defaultCommandName) {
1673
+ unknown.push(arg, ...args.slice(i));
1674
+ break;
1675
+ }
1676
+ }
1677
+ if (this._passThroughOptions) {
1678
+ dest.push(arg, ...args.slice(i));
1679
+ break;
1680
+ }
1681
+ dest.push(arg);
1682
+ }
1683
+ return { operands, unknown };
1684
+ }
1685
+ opts() {
1686
+ if (this._storeOptionsAsProperties) {
1687
+ const result = {};
1688
+ const len = this.options.length;
1689
+ for (let i = 0;i < len; i++) {
1690
+ const key = this.options[i].attributeName();
1691
+ result[key] = key === this._versionOptionName ? this._version : this[key];
1692
+ }
1693
+ return result;
1694
+ }
1695
+ return this._optionValues;
1696
+ }
1697
+ optsWithGlobals() {
1698
+ return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
1699
+ }
1700
+ error(message, errorOptions) {
1701
+ this._outputConfiguration.outputError(`${message}
1702
+ `, this._outputConfiguration.writeErr);
1703
+ if (typeof this._showHelpAfterError === "string") {
1704
+ this._outputConfiguration.writeErr(`${this._showHelpAfterError}
1705
+ `);
1706
+ } else if (this._showHelpAfterError) {
1707
+ this._outputConfiguration.writeErr(`
1708
+ `);
1709
+ this.outputHelp({ error: true });
1710
+ }
1711
+ const config = errorOptions || {};
1712
+ const exitCode = config.exitCode || 1;
1713
+ const code = config.code || "commander.error";
1714
+ this._exit(exitCode, code, message);
1715
+ }
1716
+ _parseOptionsEnv() {
1717
+ this.options.forEach((option) => {
1718
+ if (option.envVar && option.envVar in process2.env) {
1719
+ const optionKey = option.attributeName();
1720
+ if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
1721
+ if (option.required || option.optional) {
1722
+ this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
1723
+ } else {
1724
+ this.emit(`optionEnv:${option.name()}`);
1725
+ }
1726
+ }
1727
+ }
1728
+ });
1729
+ }
1730
+ _parseOptionsImplied() {
1731
+ const dualHelper = new DualOptions(this.options);
1732
+ const hasCustomOptionValue = (optionKey) => {
1733
+ return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
1734
+ };
1735
+ this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
1736
+ Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
1737
+ this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
1738
+ });
1739
+ });
1740
+ }
1741
+ missingArgument(name) {
1742
+ const message = `error: missing required argument '${name}'`;
1743
+ this.error(message, { code: "commander.missingArgument" });
1744
+ }
1745
+ optionMissingArgument(option) {
1746
+ const message = `error: option '${option.flags}' argument missing`;
1747
+ this.error(message, { code: "commander.optionMissingArgument" });
1748
+ }
1749
+ missingMandatoryOptionValue(option) {
1750
+ const message = `error: required option '${option.flags}' not specified`;
1751
+ this.error(message, { code: "commander.missingMandatoryOptionValue" });
1752
+ }
1753
+ _conflictingOption(option, conflictingOption) {
1754
+ const findBestOptionFromValue = (option2) => {
1755
+ const optionKey = option2.attributeName();
1756
+ const optionValue = this.getOptionValue(optionKey);
1757
+ const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
1758
+ const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
1759
+ if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
1760
+ return negativeOption;
1761
+ }
1762
+ return positiveOption || option2;
1763
+ };
1764
+ const getErrorMessage = (option2) => {
1765
+ const bestOption = findBestOptionFromValue(option2);
1766
+ const optionKey = bestOption.attributeName();
1767
+ const source = this.getOptionValueSource(optionKey);
1768
+ if (source === "env") {
1769
+ return `environment variable '${bestOption.envVar}'`;
1770
+ }
1771
+ return `option '${bestOption.flags}'`;
1772
+ };
1773
+ const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
1774
+ this.error(message, { code: "commander.conflictingOption" });
1775
+ }
1776
+ unknownOption(flag) {
1777
+ if (this._allowUnknownOption)
1778
+ return;
1779
+ let suggestion = "";
1780
+ if (flag.startsWith("--") && this._showSuggestionAfterError) {
1781
+ let candidateFlags = [];
1782
+ let command = this;
1783
+ do {
1784
+ const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
1785
+ candidateFlags = candidateFlags.concat(moreFlags);
1786
+ command = command.parent;
1787
+ } while (command && !command._enablePositionalOptions);
1788
+ suggestion = suggestSimilar(flag, candidateFlags);
1789
+ }
1790
+ const message = `error: unknown option '${flag}'${suggestion}`;
1791
+ this.error(message, { code: "commander.unknownOption" });
1792
+ }
1793
+ _excessArguments(receivedArgs) {
1794
+ if (this._allowExcessArguments)
1795
+ return;
1796
+ const expected = this.registeredArguments.length;
1797
+ const s = expected === 1 ? "" : "s";
1798
+ const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
1799
+ const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
1800
+ this.error(message, { code: "commander.excessArguments" });
1801
+ }
1802
+ unknownCommand() {
1803
+ const unknownName = this.args[0];
1804
+ let suggestion = "";
1805
+ if (this._showSuggestionAfterError) {
1806
+ const candidateNames = [];
1807
+ this.createHelp().visibleCommands(this).forEach((command) => {
1808
+ candidateNames.push(command.name());
1809
+ if (command.alias())
1810
+ candidateNames.push(command.alias());
1811
+ });
1812
+ suggestion = suggestSimilar(unknownName, candidateNames);
1813
+ }
1814
+ const message = `error: unknown command '${unknownName}'${suggestion}`;
1815
+ this.error(message, { code: "commander.unknownCommand" });
1816
+ }
1817
+ version(str, flags, description) {
1818
+ if (str === undefined)
1819
+ return this._version;
1820
+ this._version = str;
1821
+ flags = flags || "-V, --version";
1822
+ description = description || "output the version number";
1823
+ const versionOption = this.createOption(flags, description);
1824
+ this._versionOptionName = versionOption.attributeName();
1825
+ this._registerOption(versionOption);
1826
+ this.on("option:" + versionOption.name(), () => {
1827
+ this._outputConfiguration.writeOut(`${str}
1828
+ `);
1829
+ this._exit(0, "commander.version", str);
1830
+ });
1831
+ return this;
1832
+ }
1833
+ description(str, argsDescription) {
1834
+ if (str === undefined && argsDescription === undefined)
1835
+ return this._description;
1836
+ this._description = str;
1837
+ if (argsDescription) {
1838
+ this._argsDescription = argsDescription;
1839
+ }
1840
+ return this;
1841
+ }
1842
+ summary(str) {
1843
+ if (str === undefined)
1844
+ return this._summary;
1845
+ this._summary = str;
1846
+ return this;
1847
+ }
1848
+ alias(alias) {
1849
+ if (alias === undefined)
1850
+ return this._aliases[0];
1851
+ let command = this;
1852
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
1853
+ command = this.commands[this.commands.length - 1];
1854
+ }
1855
+ if (alias === command._name)
1856
+ throw new Error("Command alias can't be the same as its name");
1857
+ const matchingCommand = this.parent?._findCommand(alias);
1858
+ if (matchingCommand) {
1859
+ const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
1860
+ throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
1861
+ }
1862
+ command._aliases.push(alias);
1863
+ return this;
1864
+ }
1865
+ aliases(aliases) {
1866
+ if (aliases === undefined)
1867
+ return this._aliases;
1868
+ aliases.forEach((alias) => this.alias(alias));
1869
+ return this;
1870
+ }
1871
+ usage(str) {
1872
+ if (str === undefined) {
1873
+ if (this._usage)
1874
+ return this._usage;
1875
+ const args = this.registeredArguments.map((arg) => {
1876
+ return humanReadableArgName(arg);
1877
+ });
1878
+ return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
1879
+ }
1880
+ this._usage = str;
1881
+ return this;
1882
+ }
1883
+ name(str) {
1884
+ if (str === undefined)
1885
+ return this._name;
1886
+ this._name = str;
1887
+ return this;
1888
+ }
1889
+ helpGroup(heading) {
1890
+ if (heading === undefined)
1891
+ return this._helpGroupHeading ?? "";
1892
+ this._helpGroupHeading = heading;
1893
+ return this;
1894
+ }
1895
+ commandsGroup(heading) {
1896
+ if (heading === undefined)
1897
+ return this._defaultCommandGroup ?? "";
1898
+ this._defaultCommandGroup = heading;
1899
+ return this;
1900
+ }
1901
+ optionsGroup(heading) {
1902
+ if (heading === undefined)
1903
+ return this._defaultOptionGroup ?? "";
1904
+ this._defaultOptionGroup = heading;
1905
+ return this;
1906
+ }
1907
+ _initOptionGroup(option) {
1908
+ if (this._defaultOptionGroup && !option.helpGroupHeading)
1909
+ option.helpGroup(this._defaultOptionGroup);
1910
+ }
1911
+ _initCommandGroup(cmd) {
1912
+ if (this._defaultCommandGroup && !cmd.helpGroup())
1913
+ cmd.helpGroup(this._defaultCommandGroup);
1914
+ }
1915
+ nameFromFilename(filename) {
1916
+ this._name = path.basename(filename, path.extname(filename));
1917
+ return this;
1918
+ }
1919
+ executableDir(path2) {
1920
+ if (path2 === undefined)
1921
+ return this._executableDir;
1922
+ this._executableDir = path2;
1923
+ return this;
1924
+ }
1925
+ helpInformation(contextOptions) {
1926
+ const helper = this.createHelp();
1927
+ const context = this._getOutputContext(contextOptions);
1928
+ helper.prepareContext({
1929
+ error: context.error,
1930
+ helpWidth: context.helpWidth,
1931
+ outputHasColors: context.hasColors
1932
+ });
1933
+ const text = helper.formatHelp(this, helper);
1934
+ if (context.hasColors)
1935
+ return text;
1936
+ return this._outputConfiguration.stripColor(text);
1937
+ }
1938
+ _getOutputContext(contextOptions) {
1939
+ contextOptions = contextOptions || {};
1940
+ const error = !!contextOptions.error;
1941
+ let baseWrite;
1942
+ let hasColors;
1943
+ let helpWidth;
1944
+ if (error) {
1945
+ baseWrite = (str) => this._outputConfiguration.writeErr(str);
1946
+ hasColors = this._outputConfiguration.getErrHasColors();
1947
+ helpWidth = this._outputConfiguration.getErrHelpWidth();
1948
+ } else {
1949
+ baseWrite = (str) => this._outputConfiguration.writeOut(str);
1950
+ hasColors = this._outputConfiguration.getOutHasColors();
1951
+ helpWidth = this._outputConfiguration.getOutHelpWidth();
1952
+ }
1953
+ const write = (str) => {
1954
+ if (!hasColors)
1955
+ str = this._outputConfiguration.stripColor(str);
1956
+ return baseWrite(str);
1957
+ };
1958
+ return { error, write, hasColors, helpWidth };
1959
+ }
1960
+ outputHelp(contextOptions) {
1961
+ let deprecatedCallback;
1962
+ if (typeof contextOptions === "function") {
1963
+ deprecatedCallback = contextOptions;
1964
+ contextOptions = undefined;
1965
+ }
1966
+ const outputContext = this._getOutputContext(contextOptions);
1967
+ const eventContext = {
1968
+ error: outputContext.error,
1969
+ write: outputContext.write,
1970
+ command: this
1971
+ };
1972
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
1973
+ this.emit("beforeHelp", eventContext);
1974
+ let helpInformation = this.helpInformation({ error: outputContext.error });
1975
+ if (deprecatedCallback) {
1976
+ helpInformation = deprecatedCallback(helpInformation);
1977
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
1978
+ throw new Error("outputHelp callback must return a string or a Buffer");
1979
+ }
1980
+ }
1981
+ outputContext.write(helpInformation);
1982
+ if (this._getHelpOption()?.long) {
1983
+ this.emit(this._getHelpOption().long);
1984
+ }
1985
+ this.emit("afterHelp", eventContext);
1986
+ this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
1987
+ }
1988
+ helpOption(flags, description) {
1989
+ if (typeof flags === "boolean") {
1990
+ if (flags) {
1991
+ if (this._helpOption === null)
1992
+ this._helpOption = undefined;
1993
+ if (this._defaultOptionGroup) {
1994
+ this._initOptionGroup(this._getHelpOption());
1995
+ }
1996
+ } else {
1997
+ this._helpOption = null;
1998
+ }
1999
+ return this;
2000
+ }
2001
+ this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
2002
+ if (flags || description)
2003
+ this._initOptionGroup(this._helpOption);
2004
+ return this;
2005
+ }
2006
+ _getHelpOption() {
2007
+ if (this._helpOption === undefined) {
2008
+ this.helpOption(undefined, undefined);
2009
+ }
2010
+ return this._helpOption;
2011
+ }
2012
+ addHelpOption(option) {
2013
+ this._helpOption = option;
2014
+ this._initOptionGroup(option);
2015
+ return this;
2016
+ }
2017
+ help(contextOptions) {
2018
+ this.outputHelp(contextOptions);
2019
+ let exitCode = Number(process2.exitCode ?? 0);
2020
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2021
+ exitCode = 1;
2022
+ }
2023
+ this._exit(exitCode, "commander.help", "(outputHelp)");
2024
+ }
2025
+ addHelpText(position, text) {
2026
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
2027
+ if (!allowedValues.includes(position)) {
2028
+ throw new Error(`Unexpected value for position to addHelpText.
2029
+ Expecting one of '${allowedValues.join("', '")}'`);
2030
+ }
2031
+ const helpEvent = `${position}Help`;
2032
+ this.on(helpEvent, (context) => {
2033
+ let helpStr;
2034
+ if (typeof text === "function") {
2035
+ helpStr = text({ error: context.error, command: context.command });
2036
+ } else {
2037
+ helpStr = text;
2038
+ }
2039
+ if (helpStr) {
2040
+ context.write(`${helpStr}
2041
+ `);
2042
+ }
2043
+ });
2044
+ return this;
2045
+ }
2046
+ _outputHelpIfRequested(args) {
2047
+ const helpOption = this._getHelpOption();
2048
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
2049
+ if (helpRequested) {
2050
+ this.outputHelp();
2051
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
2052
+ }
2053
+ }
2054
+ }
2055
+ function incrementNodeInspectorPort(args) {
2056
+ return args.map((arg) => {
2057
+ if (!arg.startsWith("--inspect")) {
2058
+ return arg;
2059
+ }
2060
+ let debugOption;
2061
+ let debugHost = "127.0.0.1";
2062
+ let debugPort = "9229";
2063
+ let match;
2064
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
2065
+ debugOption = match[1];
2066
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
2067
+ debugOption = match[1];
2068
+ if (/^\d+$/.test(match[3])) {
2069
+ debugPort = match[3];
2070
+ } else {
2071
+ debugHost = match[3];
2072
+ }
2073
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
2074
+ debugOption = match[1];
2075
+ debugHost = match[3];
2076
+ debugPort = match[4];
2077
+ }
2078
+ if (debugOption && debugPort !== "0") {
2079
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
2080
+ }
2081
+ return arg;
2082
+ });
2083
+ }
2084
+ function useColor() {
2085
+ if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
2086
+ return false;
2087
+ if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== undefined)
2088
+ return true;
2089
+ return;
2090
+ }
2091
+ exports.Command = Command;
2092
+ exports.useColor = useColor;
2093
+ });
2094
+
2095
+ // node_modules/commander/index.js
2096
+ var require_commander = __commonJS((exports) => {
2097
+ var { Argument } = require_argument();
2098
+ var { Command } = require_command();
2099
+ var { CommanderError, InvalidArgumentError } = require_error();
2100
+ var { Help } = require_help();
2101
+ var { Option } = require_option();
2102
+ exports.program = new Command;
2103
+ exports.createCommand = (name) => new Command(name);
2104
+ exports.createOption = (flags, description) => new Option(flags, description);
2105
+ exports.createArgument = (name, description) => new Argument(name, description);
2106
+ exports.Command = Command;
2107
+ exports.Option = Option;
2108
+ exports.Argument = Argument;
2109
+ exports.Help = Help;
2110
+ exports.CommanderError = CommanderError;
2111
+ exports.InvalidArgumentError = InvalidArgumentError;
2112
+ exports.InvalidOptionArgumentError = InvalidArgumentError;
2113
+ });
2114
+
2115
+ // node_modules/cli-width/index.js
2116
+ var require_cli_width = __commonJS((exports, module) => {
2117
+ module.exports = cliWidth;
2118
+ function normalizeOpts(options) {
2119
+ const defaultOpts = {
2120
+ defaultWidth: 0,
2121
+ output: process.stdout,
2122
+ tty: __require("tty")
2123
+ };
2124
+ if (!options) {
2125
+ return defaultOpts;
2126
+ }
2127
+ Object.keys(defaultOpts).forEach(function(key) {
2128
+ if (!options[key]) {
2129
+ options[key] = defaultOpts[key];
2130
+ }
2131
+ });
2132
+ return options;
2133
+ }
2134
+ function cliWidth(options) {
2135
+ const opts = normalizeOpts(options);
2136
+ if (opts.output.getWindowSize) {
2137
+ return opts.output.getWindowSize()[0] || opts.defaultWidth;
2138
+ }
2139
+ if (opts.tty.getWindowSize) {
2140
+ return opts.tty.getWindowSize()[1] || opts.defaultWidth;
2141
+ }
2142
+ if (opts.output.columns) {
2143
+ return opts.output.columns;
2144
+ }
2145
+ if (process.env.CLI_WIDTH) {
2146
+ const width = parseInt(process.env.CLI_WIDTH, 10);
2147
+ if (!isNaN(width) && width !== 0) {
2148
+ return width;
2149
+ }
2150
+ }
2151
+ return opts.defaultWidth;
2152
+ }
2153
+ });
2154
+
2155
+ // node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/index.js
2156
+ var require_emoji_regex = __commonJS((exports, module) => {
2157
+ module.exports = () => {
2158
+ return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
2159
+ };
2160
+ });
2161
+
2162
+ // node_modules/mute-stream/lib/index.js
2163
+ var require_lib = __commonJS((exports, module) => {
2164
+ var Stream = __require("stream");
2165
+
2166
+ class MuteStream extends Stream {
2167
+ #isTTY = null;
2168
+ constructor(opts = {}) {
2169
+ super(opts);
2170
+ this.writable = this.readable = true;
2171
+ this.muted = false;
2172
+ this.on("pipe", this._onpipe);
2173
+ this.replace = opts.replace;
2174
+ this._prompt = opts.prompt || null;
2175
+ this._hadControl = false;
2176
+ }
2177
+ #destSrc(key, def) {
2178
+ if (this._dest) {
2179
+ return this._dest[key];
2180
+ }
2181
+ if (this._src) {
2182
+ return this._src[key];
2183
+ }
2184
+ return def;
2185
+ }
2186
+ #proxy(method, ...args) {
2187
+ if (typeof this._dest?.[method] === "function") {
2188
+ this._dest[method](...args);
2189
+ }
2190
+ if (typeof this._src?.[method] === "function") {
2191
+ this._src[method](...args);
2192
+ }
2193
+ }
2194
+ get isTTY() {
2195
+ if (this.#isTTY !== null) {
2196
+ return this.#isTTY;
2197
+ }
2198
+ return this.#destSrc("isTTY", false);
2199
+ }
2200
+ set isTTY(val) {
2201
+ this.#isTTY = val;
2202
+ }
2203
+ get rows() {
2204
+ return this.#destSrc("rows");
2205
+ }
2206
+ get columns() {
2207
+ return this.#destSrc("columns");
2208
+ }
2209
+ mute() {
2210
+ this.muted = true;
2211
+ }
2212
+ unmute() {
2213
+ this.muted = false;
2214
+ }
2215
+ _onpipe(src) {
2216
+ this._src = src;
2217
+ }
2218
+ pipe(dest, options) {
2219
+ this._dest = dest;
2220
+ return super.pipe(dest, options);
2221
+ }
2222
+ pause() {
2223
+ if (this._src) {
2224
+ return this._src.pause();
2225
+ }
2226
+ }
2227
+ resume() {
2228
+ if (this._src) {
2229
+ return this._src.resume();
2230
+ }
2231
+ }
2232
+ write(c) {
2233
+ if (this.muted) {
2234
+ if (!this.replace) {
2235
+ return true;
2236
+ }
2237
+ if (c.match(/^\u001b/)) {
2238
+ if (c.indexOf(this._prompt) === 0) {
2239
+ c = c.slice(this._prompt.length);
2240
+ c = c.replace(/./g, this.replace);
2241
+ c = this._prompt + c;
2242
+ }
2243
+ this._hadControl = true;
2244
+ return this.emit("data", c);
2245
+ } else {
2246
+ if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
2247
+ this._hadControl = false;
2248
+ this.emit("data", this._prompt);
2249
+ c = c.slice(this._prompt.length);
2250
+ }
2251
+ c = c.toString().replace(/./g, this.replace);
2252
+ }
2253
+ }
2254
+ this.emit("data", c);
2255
+ }
2256
+ end(c) {
2257
+ if (this.muted) {
2258
+ if (c && this.replace) {
2259
+ c = c.toString().replace(/./g, this.replace);
2260
+ } else {
2261
+ c = null;
2262
+ }
2263
+ }
2264
+ if (c) {
2265
+ this.emit("data", c);
2266
+ }
2267
+ this.emit("end");
2268
+ }
2269
+ destroy(...args) {
2270
+ return this.#proxy("destroy", ...args);
2271
+ }
2272
+ destroySoon(...args) {
2273
+ return this.#proxy("destroySoon", ...args);
2274
+ }
2275
+ close(...args) {
2276
+ return this.#proxy("close", ...args);
2277
+ }
2278
+ }
2279
+ module.exports = MuteStream;
2280
+ });
2281
+
2282
+ // node_modules/commander/esm.mjs
2283
+ var import__ = __toESM(require_commander(), 1);
2284
+ var {
2285
+ program,
2286
+ createCommand,
2287
+ createArgument,
2288
+ createOption,
2289
+ CommanderError,
2290
+ InvalidArgumentError,
2291
+ InvalidOptionArgumentError,
2292
+ Command,
2293
+ Argument,
2294
+ Option,
2295
+ Help
2296
+ } = import__.default;
2297
+
2298
+ // node_modules/@inquirer/core/dist/lib/key.js
2299
+ var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
2300
+ var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
2301
+ var isBackspaceKey = (key) => key.name === "backspace";
2302
+ var isNumberKey = (key) => "1234567890".includes(key.name);
2303
+ var isEnterKey = (key) => key.name === "enter" || key.name === "return";
2304
+ // node_modules/@inquirer/core/dist/lib/errors.js
2305
+ class AbortPromptError extends Error {
2306
+ name = "AbortPromptError";
2307
+ message = "Prompt was aborted";
2308
+ constructor(options) {
2309
+ super();
2310
+ this.cause = options?.cause;
2311
+ }
2312
+ }
2313
+
2314
+ class CancelPromptError extends Error {
2315
+ name = "CancelPromptError";
2316
+ message = "Prompt was canceled";
2317
+ }
2318
+
2319
+ class ExitPromptError extends Error {
2320
+ name = "ExitPromptError";
2321
+ }
2322
+
2323
+ class HookError extends Error {
2324
+ name = "HookError";
2325
+ }
2326
+
2327
+ class ValidationError extends Error {
2328
+ name = "ValidationError";
2329
+ }
2330
+ // node_modules/@inquirer/core/dist/lib/use-state.js
2331
+ import { AsyncResource as AsyncResource2 } from "node:async_hooks";
2332
+
2333
+ // node_modules/@inquirer/core/dist/lib/hook-engine.js
2334
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
2335
+ var hookStorage = new AsyncLocalStorage;
2336
+ function createStore(rl) {
2337
+ const store = {
2338
+ rl,
2339
+ hooks: [],
2340
+ hooksCleanup: [],
2341
+ hooksEffect: [],
2342
+ index: 0,
2343
+ handleChange() {}
2344
+ };
2345
+ return store;
2346
+ }
2347
+ function withHooks(rl, cb) {
2348
+ const store = createStore(rl);
2349
+ return hookStorage.run(store, () => {
2350
+ function cycle(render) {
2351
+ store.handleChange = () => {
2352
+ store.index = 0;
2353
+ render();
2354
+ };
2355
+ store.handleChange();
2356
+ }
2357
+ return cb(cycle);
2358
+ });
2359
+ }
2360
+ function getStore() {
2361
+ const store = hookStorage.getStore();
2362
+ if (!store) {
2363
+ throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
2364
+ }
2365
+ return store;
2366
+ }
2367
+ function readline() {
2368
+ return getStore().rl;
2369
+ }
2370
+ function withUpdates(fn) {
2371
+ const wrapped = (...args) => {
2372
+ const store = getStore();
2373
+ let shouldUpdate = false;
2374
+ const oldHandleChange = store.handleChange;
2375
+ store.handleChange = () => {
2376
+ shouldUpdate = true;
2377
+ };
2378
+ const returnValue = fn(...args);
2379
+ if (shouldUpdate) {
2380
+ oldHandleChange();
2381
+ }
2382
+ store.handleChange = oldHandleChange;
2383
+ return returnValue;
2384
+ };
2385
+ return AsyncResource.bind(wrapped);
2386
+ }
2387
+ function withPointer(cb) {
2388
+ const store = getStore();
2389
+ const { index } = store;
2390
+ const pointer = {
2391
+ get() {
2392
+ return store.hooks[index];
2393
+ },
2394
+ set(value) {
2395
+ store.hooks[index] = value;
2396
+ },
2397
+ initialized: index in store.hooks
2398
+ };
2399
+ const returnValue = cb(pointer);
2400
+ store.index++;
2401
+ return returnValue;
2402
+ }
2403
+ function handleChange() {
2404
+ getStore().handleChange();
2405
+ }
2406
+ var effectScheduler = {
2407
+ queue(cb) {
2408
+ const store = getStore();
2409
+ const { index } = store;
2410
+ store.hooksEffect.push(() => {
2411
+ store.hooksCleanup[index]?.();
2412
+ const cleanFn = cb(readline());
2413
+ if (cleanFn != null && typeof cleanFn !== "function") {
2414
+ throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
2415
+ }
2416
+ store.hooksCleanup[index] = cleanFn;
2417
+ });
2418
+ },
2419
+ run() {
2420
+ const store = getStore();
2421
+ withUpdates(() => {
2422
+ store.hooksEffect.forEach((effect) => {
2423
+ effect();
2424
+ });
2425
+ store.hooksEffect.length = 0;
2426
+ })();
2427
+ },
2428
+ clearAll() {
2429
+ const store = getStore();
2430
+ store.hooksCleanup.forEach((cleanFn) => {
2431
+ cleanFn?.();
2432
+ });
2433
+ store.hooksEffect.length = 0;
2434
+ store.hooksCleanup.length = 0;
2435
+ }
2436
+ };
2437
+
2438
+ // node_modules/@inquirer/core/dist/lib/use-state.js
2439
+ function useState(defaultValue) {
2440
+ return withPointer((pointer) => {
2441
+ const setState = AsyncResource2.bind(function setState2(newValue) {
2442
+ if (pointer.get() !== newValue) {
2443
+ pointer.set(newValue);
2444
+ handleChange();
2445
+ }
2446
+ });
2447
+ if (pointer.initialized) {
2448
+ return [pointer.get(), setState];
2449
+ }
2450
+ const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
2451
+ pointer.set(value);
2452
+ return [value, setState];
2453
+ });
2454
+ }
2455
+
2456
+ // node_modules/@inquirer/core/dist/lib/use-effect.js
2457
+ function useEffect(cb, depArray) {
2458
+ withPointer((pointer) => {
2459
+ const oldDeps = pointer.get();
2460
+ const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
2461
+ if (hasChanged) {
2462
+ effectScheduler.queue(cb);
2463
+ }
2464
+ pointer.set(depArray);
2465
+ });
2466
+ }
2467
+
2468
+ // node_modules/@inquirer/core/dist/lib/theme.js
2469
+ import { styleText } from "node:util";
2470
+
2471
+ // node_modules/@inquirer/figures/dist/index.js
2472
+ import process2 from "node:process";
2473
+ function isUnicodeSupported() {
2474
+ if (process2.platform !== "win32") {
2475
+ return process2.env["TERM"] !== "linux";
2476
+ }
2477
+ return Boolean(process2.env["WT_SESSION"]) || Boolean(process2.env["TERMINUS_SUBLIME"]) || process2.env["ConEmuTask"] === "{cmd::Cmder}" || process2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process2.env["TERM_PROGRAM"] === "vscode" || process2.env["TERM"] === "xterm-256color" || process2.env["TERM"] === "alacritty" || process2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
2478
+ }
2479
+ var common = {
2480
+ circleQuestionMark: "(?)",
2481
+ questionMarkPrefix: "(?)",
2482
+ square: "█",
2483
+ squareDarkShade: "▓",
2484
+ squareMediumShade: "▒",
2485
+ squareLightShade: "░",
2486
+ squareTop: "▀",
2487
+ squareBottom: "▄",
2488
+ squareLeft: "▌",
2489
+ squareRight: "▐",
2490
+ squareCenter: "■",
2491
+ bullet: "●",
2492
+ dot: "․",
2493
+ ellipsis: "…",
2494
+ pointerSmall: "›",
2495
+ triangleUp: "▲",
2496
+ triangleUpSmall: "▴",
2497
+ triangleDown: "▼",
2498
+ triangleDownSmall: "▾",
2499
+ triangleLeftSmall: "◂",
2500
+ triangleRightSmall: "▸",
2501
+ home: "⌂",
2502
+ heart: "♥",
2503
+ musicNote: "♪",
2504
+ musicNoteBeamed: "♫",
2505
+ arrowUp: "↑",
2506
+ arrowDown: "↓",
2507
+ arrowLeft: "←",
2508
+ arrowRight: "→",
2509
+ arrowLeftRight: "↔",
2510
+ arrowUpDown: "↕",
2511
+ almostEqual: "≈",
2512
+ notEqual: "≠",
2513
+ lessOrEqual: "≤",
2514
+ greaterOrEqual: "≥",
2515
+ identical: "≡",
2516
+ infinity: "∞",
2517
+ subscriptZero: "₀",
2518
+ subscriptOne: "₁",
2519
+ subscriptTwo: "₂",
2520
+ subscriptThree: "₃",
2521
+ subscriptFour: "₄",
2522
+ subscriptFive: "₅",
2523
+ subscriptSix: "₆",
2524
+ subscriptSeven: "₇",
2525
+ subscriptEight: "₈",
2526
+ subscriptNine: "₉",
2527
+ oneHalf: "½",
2528
+ oneThird: "⅓",
2529
+ oneQuarter: "¼",
2530
+ oneFifth: "⅕",
2531
+ oneSixth: "⅙",
2532
+ oneEighth: "⅛",
2533
+ twoThirds: "⅔",
2534
+ twoFifths: "⅖",
2535
+ threeQuarters: "¾",
2536
+ threeFifths: "⅗",
2537
+ threeEighths: "⅜",
2538
+ fourFifths: "⅘",
2539
+ fiveSixths: "⅚",
2540
+ fiveEighths: "⅝",
2541
+ sevenEighths: "⅞",
2542
+ line: "─",
2543
+ lineBold: "━",
2544
+ lineDouble: "═",
2545
+ lineDashed0: "┄",
2546
+ lineDashed1: "┅",
2547
+ lineDashed2: "┈",
2548
+ lineDashed3: "┉",
2549
+ lineDashed4: "╌",
2550
+ lineDashed5: "╍",
2551
+ lineDashed6: "╴",
2552
+ lineDashed7: "╶",
2553
+ lineDashed8: "╸",
2554
+ lineDashed9: "╺",
2555
+ lineDashed10: "╼",
2556
+ lineDashed11: "╾",
2557
+ lineDashed12: "−",
2558
+ lineDashed13: "–",
2559
+ lineDashed14: "‐",
2560
+ lineDashed15: "⁃",
2561
+ lineVertical: "│",
2562
+ lineVerticalBold: "┃",
2563
+ lineVerticalDouble: "║",
2564
+ lineVerticalDashed0: "┆",
2565
+ lineVerticalDashed1: "┇",
2566
+ lineVerticalDashed2: "┊",
2567
+ lineVerticalDashed3: "┋",
2568
+ lineVerticalDashed4: "╎",
2569
+ lineVerticalDashed5: "╏",
2570
+ lineVerticalDashed6: "╵",
2571
+ lineVerticalDashed7: "╷",
2572
+ lineVerticalDashed8: "╹",
2573
+ lineVerticalDashed9: "╻",
2574
+ lineVerticalDashed10: "╽",
2575
+ lineVerticalDashed11: "╿",
2576
+ lineDownLeft: "┐",
2577
+ lineDownLeftArc: "╮",
2578
+ lineDownBoldLeftBold: "┓",
2579
+ lineDownBoldLeft: "┒",
2580
+ lineDownLeftBold: "┑",
2581
+ lineDownDoubleLeftDouble: "╗",
2582
+ lineDownDoubleLeft: "╖",
2583
+ lineDownLeftDouble: "╕",
2584
+ lineDownRight: "┌",
2585
+ lineDownRightArc: "╭",
2586
+ lineDownBoldRightBold: "┏",
2587
+ lineDownBoldRight: "┎",
2588
+ lineDownRightBold: "┍",
2589
+ lineDownDoubleRightDouble: "╔",
2590
+ lineDownDoubleRight: "╓",
2591
+ lineDownRightDouble: "╒",
2592
+ lineUpLeft: "┘",
2593
+ lineUpLeftArc: "╯",
2594
+ lineUpBoldLeftBold: "┛",
2595
+ lineUpBoldLeft: "┚",
2596
+ lineUpLeftBold: "┙",
2597
+ lineUpDoubleLeftDouble: "╝",
2598
+ lineUpDoubleLeft: "╜",
2599
+ lineUpLeftDouble: "╛",
2600
+ lineUpRight: "└",
2601
+ lineUpRightArc: "╰",
2602
+ lineUpBoldRightBold: "┗",
2603
+ lineUpBoldRight: "┖",
2604
+ lineUpRightBold: "┕",
2605
+ lineUpDoubleRightDouble: "╚",
2606
+ lineUpDoubleRight: "╙",
2607
+ lineUpRightDouble: "╘",
2608
+ lineUpDownLeft: "┤",
2609
+ lineUpBoldDownBoldLeftBold: "┫",
2610
+ lineUpBoldDownBoldLeft: "┨",
2611
+ lineUpDownLeftBold: "┥",
2612
+ lineUpBoldDownLeftBold: "┩",
2613
+ lineUpDownBoldLeftBold: "┪",
2614
+ lineUpDownBoldLeft: "┧",
2615
+ lineUpBoldDownLeft: "┦",
2616
+ lineUpDoubleDownDoubleLeftDouble: "╣",
2617
+ lineUpDoubleDownDoubleLeft: "╢",
2618
+ lineUpDownLeftDouble: "╡",
2619
+ lineUpDownRight: "├",
2620
+ lineUpBoldDownBoldRightBold: "┣",
2621
+ lineUpBoldDownBoldRight: "┠",
2622
+ lineUpDownRightBold: "┝",
2623
+ lineUpBoldDownRightBold: "┡",
2624
+ lineUpDownBoldRightBold: "┢",
2625
+ lineUpDownBoldRight: "┟",
2626
+ lineUpBoldDownRight: "┞",
2627
+ lineUpDoubleDownDoubleRightDouble: "╠",
2628
+ lineUpDoubleDownDoubleRight: "╟",
2629
+ lineUpDownRightDouble: "╞",
2630
+ lineDownLeftRight: "┬",
2631
+ lineDownBoldLeftBoldRightBold: "┳",
2632
+ lineDownLeftBoldRightBold: "┯",
2633
+ lineDownBoldLeftRight: "┰",
2634
+ lineDownBoldLeftBoldRight: "┱",
2635
+ lineDownBoldLeftRightBold: "┲",
2636
+ lineDownLeftRightBold: "┮",
2637
+ lineDownLeftBoldRight: "┭",
2638
+ lineDownDoubleLeftDoubleRightDouble: "╦",
2639
+ lineDownDoubleLeftRight: "╥",
2640
+ lineDownLeftDoubleRightDouble: "╤",
2641
+ lineUpLeftRight: "┴",
2642
+ lineUpBoldLeftBoldRightBold: "┻",
2643
+ lineUpLeftBoldRightBold: "┷",
2644
+ lineUpBoldLeftRight: "┸",
2645
+ lineUpBoldLeftBoldRight: "┹",
2646
+ lineUpBoldLeftRightBold: "┺",
2647
+ lineUpLeftRightBold: "┶",
2648
+ lineUpLeftBoldRight: "┵",
2649
+ lineUpDoubleLeftDoubleRightDouble: "╩",
2650
+ lineUpDoubleLeftRight: "╨",
2651
+ lineUpLeftDoubleRightDouble: "╧",
2652
+ lineUpDownLeftRight: "┼",
2653
+ lineUpBoldDownBoldLeftBoldRightBold: "╋",
2654
+ lineUpDownBoldLeftBoldRightBold: "╈",
2655
+ lineUpBoldDownLeftBoldRightBold: "╇",
2656
+ lineUpBoldDownBoldLeftRightBold: "╊",
2657
+ lineUpBoldDownBoldLeftBoldRight: "╉",
2658
+ lineUpBoldDownLeftRight: "╀",
2659
+ lineUpDownBoldLeftRight: "╁",
2660
+ lineUpDownLeftBoldRight: "┽",
2661
+ lineUpDownLeftRightBold: "┾",
2662
+ lineUpBoldDownBoldLeftRight: "╂",
2663
+ lineUpDownLeftBoldRightBold: "┿",
2664
+ lineUpBoldDownLeftBoldRight: "╃",
2665
+ lineUpBoldDownLeftRightBold: "╄",
2666
+ lineUpDownBoldLeftBoldRight: "╅",
2667
+ lineUpDownBoldLeftRightBold: "╆",
2668
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
2669
+ lineUpDoubleDownDoubleLeftRight: "╫",
2670
+ lineUpDownLeftDoubleRightDouble: "╪",
2671
+ lineCross: "╳",
2672
+ lineBackslash: "╲",
2673
+ lineSlash: "╱"
2674
+ };
2675
+ var specialMainSymbols = {
2676
+ tick: "✔",
2677
+ info: "ℹ",
2678
+ warning: "⚠",
2679
+ cross: "✘",
2680
+ squareSmall: "◻",
2681
+ squareSmallFilled: "◼",
2682
+ circle: "◯",
2683
+ circleFilled: "◉",
2684
+ circleDotted: "◌",
2685
+ circleDouble: "◎",
2686
+ circleCircle: "ⓞ",
2687
+ circleCross: "ⓧ",
2688
+ circlePipe: "Ⓘ",
2689
+ radioOn: "◉",
2690
+ radioOff: "◯",
2691
+ checkboxOn: "☒",
2692
+ checkboxOff: "☐",
2693
+ checkboxCircleOn: "ⓧ",
2694
+ checkboxCircleOff: "Ⓘ",
2695
+ pointer: "❯",
2696
+ triangleUpOutline: "△",
2697
+ triangleLeft: "◀",
2698
+ triangleRight: "▶",
2699
+ lozenge: "◆",
2700
+ lozengeOutline: "◇",
2701
+ hamburger: "☰",
2702
+ smiley: "㋡",
2703
+ mustache: "෴",
2704
+ star: "★",
2705
+ play: "▶",
2706
+ nodejs: "⬢",
2707
+ oneSeventh: "⅐",
2708
+ oneNinth: "⅑",
2709
+ oneTenth: "⅒"
2710
+ };
2711
+ var specialFallbackSymbols = {
2712
+ tick: "√",
2713
+ info: "i",
2714
+ warning: "‼",
2715
+ cross: "×",
2716
+ squareSmall: "□",
2717
+ squareSmallFilled: "■",
2718
+ circle: "( )",
2719
+ circleFilled: "(*)",
2720
+ circleDotted: "( )",
2721
+ circleDouble: "( )",
2722
+ circleCircle: "(○)",
2723
+ circleCross: "(×)",
2724
+ circlePipe: "(│)",
2725
+ radioOn: "(*)",
2726
+ radioOff: "( )",
2727
+ checkboxOn: "[×]",
2728
+ checkboxOff: "[ ]",
2729
+ checkboxCircleOn: "(×)",
2730
+ checkboxCircleOff: "( )",
2731
+ pointer: ">",
2732
+ triangleUpOutline: "∆",
2733
+ triangleLeft: "◄",
2734
+ triangleRight: "►",
2735
+ lozenge: "♦",
2736
+ lozengeOutline: "◊",
2737
+ hamburger: "≡",
2738
+ smiley: "☺",
2739
+ mustache: "┌─┐",
2740
+ star: "✶",
2741
+ play: "►",
2742
+ nodejs: "♦",
2743
+ oneSeventh: "1/7",
2744
+ oneNinth: "1/9",
2745
+ oneTenth: "1/10"
2746
+ };
2747
+ var mainSymbols = {
2748
+ ...common,
2749
+ ...specialMainSymbols
2750
+ };
2751
+ var fallbackSymbols = {
2752
+ ...common,
2753
+ ...specialFallbackSymbols
2754
+ };
2755
+ var shouldUseMain = isUnicodeSupported();
2756
+ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
2757
+ var dist_default = figures;
2758
+ var replacements = Object.entries(specialMainSymbols);
2759
+
2760
+ // node_modules/@inquirer/core/dist/lib/theme.js
2761
+ var defaultTheme = {
2762
+ prefix: {
2763
+ idle: styleText("blue", "?"),
2764
+ done: styleText("green", dist_default.tick)
2765
+ },
2766
+ spinner: {
2767
+ interval: 80,
2768
+ frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => styleText("yellow", frame))
2769
+ },
2770
+ style: {
2771
+ answer: (text) => styleText("cyan", text),
2772
+ message: (text) => styleText("bold", text),
2773
+ error: (text) => styleText("red", `> ${text}`),
2774
+ defaultAnswer: (text) => styleText("dim", `(${text})`),
2775
+ help: (text) => styleText("dim", text),
2776
+ highlight: (text) => styleText("cyan", text),
2777
+ key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
2778
+ }
2779
+ };
2780
+
2781
+ // node_modules/@inquirer/core/dist/lib/make-theme.js
2782
+ function isPlainObject(value) {
2783
+ if (typeof value !== "object" || value === null)
2784
+ return false;
2785
+ let proto = value;
2786
+ while (Object.getPrototypeOf(proto) !== null) {
2787
+ proto = Object.getPrototypeOf(proto);
2788
+ }
2789
+ return Object.getPrototypeOf(value) === proto;
2790
+ }
2791
+ function deepMerge(...objects) {
2792
+ const output = {};
2793
+ for (const obj of objects) {
2794
+ for (const [key, value] of Object.entries(obj)) {
2795
+ const prevValue = output[key];
2796
+ output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
2797
+ }
2798
+ }
2799
+ return output;
2800
+ }
2801
+ function makeTheme(...themes) {
2802
+ const themesToMerge = [
2803
+ defaultTheme,
2804
+ ...themes.filter((theme) => theme != null)
2805
+ ];
2806
+ return deepMerge(...themesToMerge);
2807
+ }
2808
+
2809
+ // node_modules/@inquirer/core/dist/lib/use-prefix.js
2810
+ function usePrefix({ status = "idle", theme }) {
2811
+ const [showLoader, setShowLoader] = useState(false);
2812
+ const [tick, setTick] = useState(0);
2813
+ const { prefix, spinner } = makeTheme(theme);
2814
+ useEffect(() => {
2815
+ if (status === "loading") {
2816
+ let tickInterval;
2817
+ let inc = -1;
2818
+ const delayTimeout = setTimeout(() => {
2819
+ setShowLoader(true);
2820
+ tickInterval = setInterval(() => {
2821
+ inc = inc + 1;
2822
+ setTick(inc % spinner.frames.length);
2823
+ }, spinner.interval);
2824
+ }, 300);
2825
+ return () => {
2826
+ clearTimeout(delayTimeout);
2827
+ clearInterval(tickInterval);
2828
+ };
2829
+ } else {
2830
+ setShowLoader(false);
2831
+ }
2832
+ }, [status]);
2833
+ if (showLoader) {
2834
+ return spinner.frames[tick];
2835
+ }
2836
+ const iconName = status === "loading" ? "idle" : status;
2837
+ return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
2838
+ }
2839
+ // node_modules/@inquirer/core/dist/lib/use-memo.js
2840
+ function useMemo(fn, dependencies) {
2841
+ return withPointer((pointer) => {
2842
+ const prev = pointer.get();
2843
+ if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
2844
+ const value = fn();
2845
+ pointer.set({ value, dependencies });
2846
+ return value;
2847
+ }
2848
+ return prev.value;
2849
+ });
2850
+ }
2851
+ // node_modules/@inquirer/core/dist/lib/use-ref.js
2852
+ function useRef(val) {
2853
+ return useState({ current: val })[0];
2854
+ }
2855
+ // node_modules/@inquirer/core/dist/lib/use-keypress.js
2856
+ function useKeypress(userHandler) {
2857
+ const signal = useRef(userHandler);
2858
+ signal.current = userHandler;
2859
+ useEffect((rl) => {
2860
+ let ignore = false;
2861
+ const handler = withUpdates((_input, event) => {
2862
+ if (ignore)
2863
+ return;
2864
+ signal.current(event, rl);
2865
+ });
2866
+ rl.input.on("keypress", handler);
2867
+ return () => {
2868
+ ignore = true;
2869
+ rl.input.removeListener("keypress", handler);
2870
+ };
2871
+ }, []);
2872
+ }
2873
+ // node_modules/@inquirer/core/dist/lib/utils.js
2874
+ var import_cli_width = __toESM(require_cli_width(), 1);
2875
+
2876
+ // node_modules/strip-ansi/node_modules/ansi-regex/index.js
2877
+ function ansiRegex({ onlyFirst = false } = {}) {
2878
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
2879
+ const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
2880
+ const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
2881
+ const pattern = `${osc}|${csi}`;
2882
+ return new RegExp(pattern, onlyFirst ? undefined : "g");
2883
+ }
2884
+
2885
+ // node_modules/strip-ansi/index.js
2886
+ var regex = ansiRegex();
2887
+ function stripAnsi(string) {
2888
+ if (typeof string !== "string") {
2889
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
2890
+ }
2891
+ return string.replace(regex, "");
2892
+ }
2893
+
2894
+ // node_modules/wrap-ansi/node_modules/string-width/node_modules/get-east-asian-width/lookup.js
2895
+ function isAmbiguous(x) {
2896
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
2897
+ }
2898
+ function isFullWidth(x) {
2899
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
2900
+ }
2901
+ function isWide(x) {
2902
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
2903
+ }
2904
+
2905
+ // node_modules/wrap-ansi/node_modules/string-width/node_modules/get-east-asian-width/index.js
2906
+ function validate(codePoint) {
2907
+ if (!Number.isSafeInteger(codePoint)) {
2908
+ throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
2909
+ }
2910
+ }
2911
+ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
2912
+ validate(codePoint);
2913
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
2914
+ return 2;
2915
+ }
2916
+ return 1;
2917
+ }
2918
+
2919
+ // node_modules/wrap-ansi/node_modules/string-width/index.js
2920
+ var import_emoji_regex = __toESM(require_emoji_regex(), 1);
2921
+ var segmenter = new Intl.Segmenter;
2922
+ var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
2923
+ function stringWidth(string, options = {}) {
2924
+ if (typeof string !== "string" || string.length === 0) {
2925
+ return 0;
2926
+ }
2927
+ const {
2928
+ ambiguousIsNarrow = true,
2929
+ countAnsiEscapeCodes = false
2930
+ } = options;
2931
+ if (!countAnsiEscapeCodes) {
2932
+ string = stripAnsi(string);
2933
+ }
2934
+ if (string.length === 0) {
2935
+ return 0;
2936
+ }
2937
+ let width = 0;
2938
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
2939
+ for (const { segment: character } of segmenter.segment(string)) {
2940
+ const codePoint = character.codePointAt(0);
2941
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
2942
+ continue;
2943
+ }
2944
+ if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
2945
+ continue;
2946
+ }
2947
+ if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
2948
+ continue;
2949
+ }
2950
+ if (codePoint >= 55296 && codePoint <= 57343) {
2951
+ continue;
2952
+ }
2953
+ if (codePoint >= 65024 && codePoint <= 65039) {
2954
+ continue;
2955
+ }
2956
+ if (defaultIgnorableCodePointRegex.test(character)) {
2957
+ continue;
2958
+ }
2959
+ if (import_emoji_regex.default().test(character)) {
2960
+ width += 2;
2961
+ continue;
2962
+ }
2963
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
2964
+ }
2965
+ return width;
2966
+ }
2967
+
2968
+ // node_modules/wrap-ansi/node_modules/ansi-styles/index.js
2969
+ var ANSI_BACKGROUND_OFFSET = 10;
2970
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
2971
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
2972
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
2973
+ var styles = {
2974
+ modifier: {
2975
+ reset: [0, 0],
2976
+ bold: [1, 22],
2977
+ dim: [2, 22],
2978
+ italic: [3, 23],
2979
+ underline: [4, 24],
2980
+ overline: [53, 55],
2981
+ inverse: [7, 27],
2982
+ hidden: [8, 28],
2983
+ strikethrough: [9, 29]
2984
+ },
2985
+ color: {
2986
+ black: [30, 39],
2987
+ red: [31, 39],
2988
+ green: [32, 39],
2989
+ yellow: [33, 39],
2990
+ blue: [34, 39],
2991
+ magenta: [35, 39],
2992
+ cyan: [36, 39],
2993
+ white: [37, 39],
2994
+ blackBright: [90, 39],
2995
+ gray: [90, 39],
2996
+ grey: [90, 39],
2997
+ redBright: [91, 39],
2998
+ greenBright: [92, 39],
2999
+ yellowBright: [93, 39],
3000
+ blueBright: [94, 39],
3001
+ magentaBright: [95, 39],
3002
+ cyanBright: [96, 39],
3003
+ whiteBright: [97, 39]
3004
+ },
3005
+ bgColor: {
3006
+ bgBlack: [40, 49],
3007
+ bgRed: [41, 49],
3008
+ bgGreen: [42, 49],
3009
+ bgYellow: [43, 49],
3010
+ bgBlue: [44, 49],
3011
+ bgMagenta: [45, 49],
3012
+ bgCyan: [46, 49],
3013
+ bgWhite: [47, 49],
3014
+ bgBlackBright: [100, 49],
3015
+ bgGray: [100, 49],
3016
+ bgGrey: [100, 49],
3017
+ bgRedBright: [101, 49],
3018
+ bgGreenBright: [102, 49],
3019
+ bgYellowBright: [103, 49],
3020
+ bgBlueBright: [104, 49],
3021
+ bgMagentaBright: [105, 49],
3022
+ bgCyanBright: [106, 49],
3023
+ bgWhiteBright: [107, 49]
3024
+ }
3025
+ };
3026
+ var modifierNames = Object.keys(styles.modifier);
3027
+ var foregroundColorNames = Object.keys(styles.color);
3028
+ var backgroundColorNames = Object.keys(styles.bgColor);
3029
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
3030
+ function assembleStyles() {
3031
+ const codes = new Map;
3032
+ for (const [groupName, group] of Object.entries(styles)) {
3033
+ for (const [styleName, style] of Object.entries(group)) {
3034
+ styles[styleName] = {
3035
+ open: `\x1B[${style[0]}m`,
3036
+ close: `\x1B[${style[1]}m`
3037
+ };
3038
+ group[styleName] = styles[styleName];
3039
+ codes.set(style[0], style[1]);
3040
+ }
3041
+ Object.defineProperty(styles, groupName, {
3042
+ value: group,
3043
+ enumerable: false
3044
+ });
3045
+ }
3046
+ Object.defineProperty(styles, "codes", {
3047
+ value: codes,
3048
+ enumerable: false
3049
+ });
3050
+ styles.color.close = "\x1B[39m";
3051
+ styles.bgColor.close = "\x1B[49m";
3052
+ styles.color.ansi = wrapAnsi16();
3053
+ styles.color.ansi256 = wrapAnsi256();
3054
+ styles.color.ansi16m = wrapAnsi16m();
3055
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
3056
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
3057
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
3058
+ Object.defineProperties(styles, {
3059
+ rgbToAnsi256: {
3060
+ value(red, green, blue) {
3061
+ if (red === green && green === blue) {
3062
+ if (red < 8) {
3063
+ return 16;
3064
+ }
3065
+ if (red > 248) {
3066
+ return 231;
3067
+ }
3068
+ return Math.round((red - 8) / 247 * 24) + 232;
3069
+ }
3070
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
3071
+ },
3072
+ enumerable: false
3073
+ },
3074
+ hexToRgb: {
3075
+ value(hex) {
3076
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
3077
+ if (!matches) {
3078
+ return [0, 0, 0];
3079
+ }
3080
+ let [colorString] = matches;
3081
+ if (colorString.length === 3) {
3082
+ colorString = [...colorString].map((character) => character + character).join("");
3083
+ }
3084
+ const integer = Number.parseInt(colorString, 16);
3085
+ return [
3086
+ integer >> 16 & 255,
3087
+ integer >> 8 & 255,
3088
+ integer & 255
3089
+ ];
3090
+ },
3091
+ enumerable: false
3092
+ },
3093
+ hexToAnsi256: {
3094
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
3095
+ enumerable: false
3096
+ },
3097
+ ansi256ToAnsi: {
3098
+ value(code) {
3099
+ if (code < 8) {
3100
+ return 30 + code;
3101
+ }
3102
+ if (code < 16) {
3103
+ return 90 + (code - 8);
3104
+ }
3105
+ let red;
3106
+ let green;
3107
+ let blue;
3108
+ if (code >= 232) {
3109
+ red = ((code - 232) * 10 + 8) / 255;
3110
+ green = red;
3111
+ blue = red;
3112
+ } else {
3113
+ code -= 16;
3114
+ const remainder = code % 36;
3115
+ red = Math.floor(code / 36) / 5;
3116
+ green = Math.floor(remainder / 6) / 5;
3117
+ blue = remainder % 6 / 5;
3118
+ }
3119
+ const value = Math.max(red, green, blue) * 2;
3120
+ if (value === 0) {
3121
+ return 30;
3122
+ }
3123
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
3124
+ if (value === 2) {
3125
+ result += 60;
3126
+ }
3127
+ return result;
3128
+ },
3129
+ enumerable: false
3130
+ },
3131
+ rgbToAnsi: {
3132
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
3133
+ enumerable: false
3134
+ },
3135
+ hexToAnsi: {
3136
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
3137
+ enumerable: false
3138
+ }
3139
+ });
3140
+ return styles;
3141
+ }
3142
+ var ansiStyles = assembleStyles();
3143
+ var ansi_styles_default = ansiStyles;
3144
+
3145
+ // node_modules/wrap-ansi/index.js
3146
+ var ESCAPES = new Set([
3147
+ "\x1B",
3148
+ "›"
3149
+ ]);
3150
+ var END_CODE = 39;
3151
+ var ANSI_ESCAPE_BELL = "\x07";
3152
+ var ANSI_CSI = "[";
3153
+ var ANSI_OSC = "]";
3154
+ var ANSI_SGR_TERMINATOR = "m";
3155
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
3156
+ var wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
3157
+ var wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
3158
+ var wordLengths = (string) => string.split(" ").map((character) => stringWidth(character));
3159
+ var wrapWord = (rows, word, columns) => {
3160
+ const characters = [...word];
3161
+ let isInsideEscape = false;
3162
+ let isInsideLinkEscape = false;
3163
+ let visible = stringWidth(stripAnsi(rows.at(-1)));
3164
+ for (const [index, character] of characters.entries()) {
3165
+ const characterLength = stringWidth(character);
3166
+ if (visible + characterLength <= columns) {
3167
+ rows[rows.length - 1] += character;
3168
+ } else {
3169
+ rows.push(character);
3170
+ visible = 0;
3171
+ }
3172
+ if (ESCAPES.has(character)) {
3173
+ isInsideEscape = true;
3174
+ const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("");
3175
+ isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
3176
+ }
3177
+ if (isInsideEscape) {
3178
+ if (isInsideLinkEscape) {
3179
+ if (character === ANSI_ESCAPE_BELL) {
3180
+ isInsideEscape = false;
3181
+ isInsideLinkEscape = false;
3182
+ }
3183
+ } else if (character === ANSI_SGR_TERMINATOR) {
3184
+ isInsideEscape = false;
3185
+ }
3186
+ continue;
3187
+ }
3188
+ visible += characterLength;
3189
+ if (visible === columns && index < characters.length - 1) {
3190
+ rows.push("");
3191
+ visible = 0;
3192
+ }
3193
+ }
3194
+ if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
3195
+ rows[rows.length - 2] += rows.pop();
3196
+ }
3197
+ };
3198
+ var stringVisibleTrimSpacesRight = (string) => {
3199
+ const words = string.split(" ");
3200
+ let last = words.length;
3201
+ while (last > 0) {
3202
+ if (stringWidth(words[last - 1]) > 0) {
3203
+ break;
3204
+ }
3205
+ last--;
3206
+ }
3207
+ if (last === words.length) {
3208
+ return string;
3209
+ }
3210
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
3211
+ };
3212
+ var exec = (string, columns, options = {}) => {
3213
+ if (options.trim !== false && string.trim() === "") {
3214
+ return "";
3215
+ }
3216
+ let returnValue = "";
3217
+ let escapeCode;
3218
+ let escapeUrl;
3219
+ const lengths = wordLengths(string);
3220
+ let rows = [""];
3221
+ for (const [index, word] of string.split(" ").entries()) {
3222
+ if (options.trim !== false) {
3223
+ rows[rows.length - 1] = rows.at(-1).trimStart();
3224
+ }
3225
+ let rowLength = stringWidth(rows.at(-1));
3226
+ if (index !== 0) {
3227
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
3228
+ rows.push("");
3229
+ rowLength = 0;
3230
+ }
3231
+ if (rowLength > 0 || options.trim === false) {
3232
+ rows[rows.length - 1] += " ";
3233
+ rowLength++;
3234
+ }
3235
+ }
3236
+ if (options.hard && lengths[index] > columns) {
3237
+ const remainingColumns = columns - rowLength;
3238
+ const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
3239
+ const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
3240
+ if (breaksStartingNextLine < breaksStartingThisLine) {
3241
+ rows.push("");
3242
+ }
3243
+ wrapWord(rows, word, columns);
3244
+ continue;
3245
+ }
3246
+ if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
3247
+ if (options.wordWrap === false && rowLength < columns) {
3248
+ wrapWord(rows, word, columns);
3249
+ continue;
3250
+ }
3251
+ rows.push("");
3252
+ }
3253
+ if (rowLength + lengths[index] > columns && options.wordWrap === false) {
3254
+ wrapWord(rows, word, columns);
3255
+ continue;
3256
+ }
3257
+ rows[rows.length - 1] += word;
3258
+ }
3259
+ if (options.trim !== false) {
3260
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
3261
+ }
3262
+ const preString = rows.join(`
3263
+ `);
3264
+ const pre = [...preString];
3265
+ let preStringIndex = 0;
3266
+ for (const [index, character] of pre.entries()) {
3267
+ returnValue += character;
3268
+ if (ESCAPES.has(character)) {
3269
+ const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
3270
+ if (groups.code !== undefined) {
3271
+ const code2 = Number.parseFloat(groups.code);
3272
+ escapeCode = code2 === END_CODE ? undefined : code2;
3273
+ } else if (groups.uri !== undefined) {
3274
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
3275
+ }
3276
+ }
3277
+ const code = ansi_styles_default.codes.get(Number(escapeCode));
3278
+ if (pre[index + 1] === `
3279
+ `) {
3280
+ if (escapeUrl) {
3281
+ returnValue += wrapAnsiHyperlink("");
3282
+ }
3283
+ if (escapeCode && code) {
3284
+ returnValue += wrapAnsiCode(code);
3285
+ }
3286
+ } else if (character === `
3287
+ `) {
3288
+ if (escapeCode && code) {
3289
+ returnValue += wrapAnsiCode(escapeCode);
3290
+ }
3291
+ if (escapeUrl) {
3292
+ returnValue += wrapAnsiHyperlink(escapeUrl);
3293
+ }
3294
+ }
3295
+ preStringIndex += character.length;
3296
+ }
3297
+ return returnValue;
3298
+ };
3299
+ function wrapAnsi(string, columns, options) {
3300
+ return String(string).normalize().replaceAll(`\r
3301
+ `, `
3302
+ `).split(`
3303
+ `).map((line) => exec(line, columns, options)).join(`
3304
+ `);
3305
+ }
3306
+
3307
+ // node_modules/@inquirer/core/dist/lib/utils.js
3308
+ function breakLines(content, width) {
3309
+ return content.split(`
3310
+ `).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
3311
+ `).map((str) => str.trimEnd())).join(`
3312
+ `);
3313
+ }
3314
+ function readlineWidth() {
3315
+ return import_cli_width.default({ defaultWidth: 80, output: readline().output });
3316
+ }
3317
+
3318
+ // node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
3319
+ function usePointerPosition({ active, renderedItems, pageSize, loop }) {
3320
+ const state = useRef({
3321
+ lastPointer: active,
3322
+ lastActive: undefined
3323
+ });
3324
+ const { lastPointer, lastActive } = state.current;
3325
+ const middle = Math.floor(pageSize / 2);
3326
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
3327
+ const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
3328
+ let pointer = defaultPointerPosition;
3329
+ if (renderedLength > pageSize) {
3330
+ if (loop) {
3331
+ pointer = lastPointer;
3332
+ if (lastActive != null && lastActive < active && active - lastActive < pageSize) {
3333
+ pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
3334
+ }
3335
+ } else {
3336
+ const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
3337
+ pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
3338
+ }
3339
+ }
3340
+ state.current.lastPointer = pointer;
3341
+ state.current.lastActive = active;
3342
+ return pointer;
3343
+ }
3344
+ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
3345
+ const width = readlineWidth();
3346
+ const bound = (num) => (num % items.length + items.length) % items.length;
3347
+ const renderedItems = items.map((item, index) => {
3348
+ if (item == null)
3349
+ return [];
3350
+ return breakLines(renderItem({ item, index, isActive: index === active }), width).split(`
3351
+ `);
3352
+ });
3353
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
3354
+ const renderItemAtIndex = (index) => renderedItems[index] ?? [];
3355
+ const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
3356
+ const activeItem = renderItemAtIndex(active).slice(0, pageSize);
3357
+ const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
3358
+ const pageBuffer = Array.from({ length: pageSize });
3359
+ pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
3360
+ const itemVisited = new Set([active]);
3361
+ let bufferPointer = activeItemPosition + activeItem.length;
3362
+ let itemPointer = bound(active + 1);
3363
+ while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
3364
+ const lines = renderItemAtIndex(itemPointer);
3365
+ const linesToAdd = lines.slice(0, pageSize - bufferPointer);
3366
+ pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
3367
+ itemVisited.add(itemPointer);
3368
+ bufferPointer += linesToAdd.length;
3369
+ itemPointer = bound(itemPointer + 1);
3370
+ }
3371
+ bufferPointer = activeItemPosition - 1;
3372
+ itemPointer = bound(active - 1);
3373
+ while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
3374
+ const lines = renderItemAtIndex(itemPointer);
3375
+ const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
3376
+ pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
3377
+ itemVisited.add(itemPointer);
3378
+ bufferPointer -= linesToAdd.length;
3379
+ itemPointer = bound(itemPointer - 1);
3380
+ }
3381
+ return pageBuffer.filter((line) => typeof line === "string").join(`
3382
+ `);
3383
+ }
3384
+ // node_modules/@inquirer/core/dist/lib/create-prompt.js
3385
+ var import_mute_stream = __toESM(require_lib(), 1);
3386
+ import * as readline2 from "node:readline";
3387
+ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
3388
+
3389
+ // node_modules/signal-exit/dist/mjs/signals.js
3390
+ var signals = [];
3391
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
3392
+ if (process.platform !== "win32") {
3393
+ signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
3394
+ }
3395
+ if (process.platform === "linux") {
3396
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
3397
+ }
3398
+
3399
+ // node_modules/signal-exit/dist/mjs/index.js
3400
+ var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
3401
+ var kExitEmitter = Symbol.for("signal-exit emitter");
3402
+ var global = globalThis;
3403
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
3404
+
3405
+ class Emitter {
3406
+ emitted = {
3407
+ afterExit: false,
3408
+ exit: false
3409
+ };
3410
+ listeners = {
3411
+ afterExit: [],
3412
+ exit: []
3413
+ };
3414
+ count = 0;
3415
+ id = Math.random();
3416
+ constructor() {
3417
+ if (global[kExitEmitter]) {
3418
+ return global[kExitEmitter];
3419
+ }
3420
+ ObjectDefineProperty(global, kExitEmitter, {
3421
+ value: this,
3422
+ writable: false,
3423
+ enumerable: false,
3424
+ configurable: false
3425
+ });
3426
+ }
3427
+ on(ev, fn) {
3428
+ this.listeners[ev].push(fn);
3429
+ }
3430
+ removeListener(ev, fn) {
3431
+ const list = this.listeners[ev];
3432
+ const i = list.indexOf(fn);
3433
+ if (i === -1) {
3434
+ return;
3435
+ }
3436
+ if (i === 0 && list.length === 1) {
3437
+ list.length = 0;
3438
+ } else {
3439
+ list.splice(i, 1);
3440
+ }
3441
+ }
3442
+ emit(ev, code, signal) {
3443
+ if (this.emitted[ev]) {
3444
+ return false;
3445
+ }
3446
+ this.emitted[ev] = true;
3447
+ let ret = false;
3448
+ for (const fn of this.listeners[ev]) {
3449
+ ret = fn(code, signal) === true || ret;
3450
+ }
3451
+ if (ev === "exit") {
3452
+ ret = this.emit("afterExit", code, signal) || ret;
3453
+ }
3454
+ return ret;
3455
+ }
3456
+ }
3457
+
3458
+ class SignalExitBase {
3459
+ }
3460
+ var signalExitWrap = (handler) => {
3461
+ return {
3462
+ onExit(cb, opts) {
3463
+ return handler.onExit(cb, opts);
3464
+ },
3465
+ load() {
3466
+ return handler.load();
3467
+ },
3468
+ unload() {
3469
+ return handler.unload();
3470
+ }
3471
+ };
3472
+ };
3473
+
3474
+ class SignalExitFallback extends SignalExitBase {
3475
+ onExit() {
3476
+ return () => {};
3477
+ }
3478
+ load() {}
3479
+ unload() {}
3480
+ }
3481
+
3482
+ class SignalExit extends SignalExitBase {
3483
+ #hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
3484
+ #emitter = new Emitter;
3485
+ #process;
3486
+ #originalProcessEmit;
3487
+ #originalProcessReallyExit;
3488
+ #sigListeners = {};
3489
+ #loaded = false;
3490
+ constructor(process3) {
3491
+ super();
3492
+ this.#process = process3;
3493
+ this.#sigListeners = {};
3494
+ for (const sig of signals) {
3495
+ this.#sigListeners[sig] = () => {
3496
+ const listeners = this.#process.listeners(sig);
3497
+ let { count } = this.#emitter;
3498
+ const p = process3;
3499
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
3500
+ count += p.__signal_exit_emitter__.count;
3501
+ }
3502
+ if (listeners.length === count) {
3503
+ this.unload();
3504
+ const ret = this.#emitter.emit("exit", null, sig);
3505
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
3506
+ if (!ret)
3507
+ process3.kill(process3.pid, s);
3508
+ }
3509
+ };
3510
+ }
3511
+ this.#originalProcessReallyExit = process3.reallyExit;
3512
+ this.#originalProcessEmit = process3.emit;
3513
+ }
3514
+ onExit(cb, opts) {
3515
+ if (!processOk(this.#process)) {
3516
+ return () => {};
3517
+ }
3518
+ if (this.#loaded === false) {
3519
+ this.load();
3520
+ }
3521
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
3522
+ this.#emitter.on(ev, cb);
3523
+ return () => {
3524
+ this.#emitter.removeListener(ev, cb);
3525
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
3526
+ this.unload();
3527
+ }
3528
+ };
3529
+ }
3530
+ load() {
3531
+ if (this.#loaded) {
3532
+ return;
3533
+ }
3534
+ this.#loaded = true;
3535
+ this.#emitter.count += 1;
3536
+ for (const sig of signals) {
3537
+ try {
3538
+ const fn = this.#sigListeners[sig];
3539
+ if (fn)
3540
+ this.#process.on(sig, fn);
3541
+ } catch (_) {}
3542
+ }
3543
+ this.#process.emit = (ev, ...a) => {
3544
+ return this.#processEmit(ev, ...a);
3545
+ };
3546
+ this.#process.reallyExit = (code) => {
3547
+ return this.#processReallyExit(code);
3548
+ };
3549
+ }
3550
+ unload() {
3551
+ if (!this.#loaded) {
3552
+ return;
3553
+ }
3554
+ this.#loaded = false;
3555
+ signals.forEach((sig) => {
3556
+ const listener = this.#sigListeners[sig];
3557
+ if (!listener) {
3558
+ throw new Error("Listener not defined for signal: " + sig);
3559
+ }
3560
+ try {
3561
+ this.#process.removeListener(sig, listener);
3562
+ } catch (_) {}
3563
+ });
3564
+ this.#process.emit = this.#originalProcessEmit;
3565
+ this.#process.reallyExit = this.#originalProcessReallyExit;
3566
+ this.#emitter.count -= 1;
3567
+ }
3568
+ #processReallyExit(code) {
3569
+ if (!processOk(this.#process)) {
3570
+ return 0;
3571
+ }
3572
+ this.#process.exitCode = code || 0;
3573
+ this.#emitter.emit("exit", this.#process.exitCode, null);
3574
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
3575
+ }
3576
+ #processEmit(ev, ...args) {
3577
+ const og = this.#originalProcessEmit;
3578
+ if (ev === "exit" && processOk(this.#process)) {
3579
+ if (typeof args[0] === "number") {
3580
+ this.#process.exitCode = args[0];
3581
+ }
3582
+ const ret = og.call(this.#process, ev, ...args);
3583
+ this.#emitter.emit("exit", this.#process.exitCode, null);
3584
+ return ret;
3585
+ } else {
3586
+ return og.call(this.#process, ev, ...args);
3587
+ }
3588
+ }
3589
+ }
3590
+ var process3 = globalThis.process;
3591
+ var {
3592
+ onExit,
3593
+ load,
3594
+ unload
3595
+ } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
3596
+
3597
+ // node_modules/@inquirer/core/dist/lib/screen-manager.js
3598
+ import { stripVTControlCharacters } from "node:util";
3599
+
3600
+ // node_modules/@inquirer/ansi/dist/index.js
3601
+ var ESC = "\x1B[";
3602
+ var cursorLeft = ESC + "G";
3603
+ var cursorHide = ESC + "?25l";
3604
+ var cursorShow = ESC + "?25h";
3605
+ var cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
3606
+ var cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
3607
+ var cursorTo = (x, y) => {
3608
+ if (typeof y === "number" && !Number.isNaN(y)) {
3609
+ return `${ESC}${y + 1};${x + 1}H`;
3610
+ }
3611
+ return `${ESC}${x + 1}G`;
3612
+ };
3613
+ var eraseLine = ESC + "2K";
3614
+ var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
3615
+
3616
+ // node_modules/@inquirer/core/dist/lib/screen-manager.js
3617
+ var height = (content) => content.split(`
3618
+ `).length;
3619
+ var lastLine = (content) => content.split(`
3620
+ `).pop() ?? "";
3621
+
3622
+ class ScreenManager {
3623
+ height = 0;
3624
+ extraLinesUnderPrompt = 0;
3625
+ cursorPos;
3626
+ rl;
3627
+ constructor(rl) {
3628
+ this.rl = rl;
3629
+ this.cursorPos = rl.getCursorPos();
3630
+ }
3631
+ write(content) {
3632
+ this.rl.output.unmute();
3633
+ this.rl.output.write(content);
3634
+ this.rl.output.mute();
3635
+ }
3636
+ render(content, bottomContent = "") {
3637
+ const promptLine = lastLine(content);
3638
+ const rawPromptLine = stripVTControlCharacters(promptLine);
3639
+ let prompt = rawPromptLine;
3640
+ if (this.rl.line.length > 0) {
3641
+ prompt = prompt.slice(0, -this.rl.line.length);
3642
+ }
3643
+ this.rl.setPrompt(prompt);
3644
+ this.cursorPos = this.rl.getCursorPos();
3645
+ const width = readlineWidth();
3646
+ content = breakLines(content, width);
3647
+ bottomContent = breakLines(bottomContent, width);
3648
+ if (rawPromptLine.length % width === 0) {
3649
+ content += `
3650
+ `;
3651
+ }
3652
+ let output = content + (bottomContent ? `
3653
+ ` + bottomContent : "");
3654
+ const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
3655
+ const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
3656
+ if (bottomContentHeight > 0)
3657
+ output += cursorUp(bottomContentHeight);
3658
+ output += cursorTo(this.cursorPos.cols);
3659
+ this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
3660
+ this.extraLinesUnderPrompt = bottomContentHeight;
3661
+ this.height = height(output);
3662
+ }
3663
+ checkCursorPos() {
3664
+ const cursorPos = this.rl.getCursorPos();
3665
+ if (cursorPos.cols !== this.cursorPos.cols) {
3666
+ this.write(cursorTo(cursorPos.cols));
3667
+ this.cursorPos = cursorPos;
3668
+ }
3669
+ }
3670
+ done({ clearContent }) {
3671
+ this.rl.setPrompt("");
3672
+ let output = cursorDown(this.extraLinesUnderPrompt);
3673
+ output += clearContent ? eraseLines(this.height) : `
3674
+ `;
3675
+ output += cursorShow;
3676
+ this.write(output);
3677
+ this.rl.close();
3678
+ }
3679
+ }
3680
+
3681
+ // node_modules/@inquirer/core/dist/lib/promise-polyfill.js
3682
+ class PromisePolyfill extends Promise {
3683
+ static withResolver() {
3684
+ let resolve;
3685
+ let reject;
3686
+ const promise = new Promise((res, rej) => {
3687
+ resolve = res;
3688
+ reject = rej;
3689
+ });
3690
+ return { promise, resolve, reject };
3691
+ }
3692
+ }
3693
+
3694
+ // node_modules/@inquirer/core/dist/lib/create-prompt.js
3695
+ function getCallSites() {
3696
+ const _prepareStackTrace = Error.prepareStackTrace;
3697
+ let result = [];
3698
+ try {
3699
+ Error.prepareStackTrace = (_, callSites) => {
3700
+ const callSitesWithoutCurrent = callSites.slice(1);
3701
+ result = callSitesWithoutCurrent;
3702
+ return callSitesWithoutCurrent;
3703
+ };
3704
+ new Error().stack;
3705
+ } catch {
3706
+ return result;
3707
+ }
3708
+ Error.prepareStackTrace = _prepareStackTrace;
3709
+ return result;
3710
+ }
3711
+ function createPrompt(view) {
3712
+ const callSites = getCallSites();
3713
+ const prompt = (config, context = {}) => {
3714
+ const { input = process.stdin, signal } = context;
3715
+ const cleanups = new Set;
3716
+ const output = new import_mute_stream.default;
3717
+ output.pipe(context.output ?? process.stdout);
3718
+ const rl = readline2.createInterface({
3719
+ terminal: true,
3720
+ input,
3721
+ output
3722
+ });
3723
+ const screen = new ScreenManager(rl);
3724
+ const { promise, resolve, reject } = PromisePolyfill.withResolver();
3725
+ const cancel = () => reject(new CancelPromptError);
3726
+ if (signal) {
3727
+ const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
3728
+ if (signal.aborted) {
3729
+ abort();
3730
+ return Object.assign(promise, { cancel });
3731
+ }
3732
+ signal.addEventListener("abort", abort);
3733
+ cleanups.add(() => signal.removeEventListener("abort", abort));
3734
+ }
3735
+ cleanups.add(onExit((code, signal2) => {
3736
+ reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
3737
+ }));
3738
+ const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
3739
+ rl.on("SIGINT", sigint);
3740
+ cleanups.add(() => rl.removeListener("SIGINT", sigint));
3741
+ const checkCursorPos = () => screen.checkCursorPos();
3742
+ rl.input.on("keypress", checkCursorPos);
3743
+ cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
3744
+ return withHooks(rl, (cycle) => {
3745
+ const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
3746
+ rl.on("close", hooksCleanup);
3747
+ cleanups.add(() => rl.removeListener("close", hooksCleanup));
3748
+ cycle(() => {
3749
+ try {
3750
+ const nextView = view(config, (value) => {
3751
+ setImmediate(() => resolve(value));
3752
+ });
3753
+ if (nextView === undefined) {
3754
+ const callerFilename = callSites[1]?.getFileName();
3755
+ throw new Error(`Prompt functions must return a string.
3756
+ at ${callerFilename}`);
3757
+ }
3758
+ const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
3759
+ screen.render(content, bottomContent);
3760
+ effectScheduler.run();
3761
+ } catch (error) {
3762
+ reject(error);
3763
+ }
3764
+ });
3765
+ return Object.assign(promise.then((answer) => {
3766
+ effectScheduler.clearAll();
3767
+ return answer;
3768
+ }, (error) => {
3769
+ effectScheduler.clearAll();
3770
+ throw error;
3771
+ }).finally(() => {
3772
+ cleanups.forEach((cleanup) => cleanup());
3773
+ screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
3774
+ output.end();
3775
+ }).then(() => promise), { cancel });
3776
+ });
3777
+ };
3778
+ return prompt;
3779
+ }
3780
+ // node_modules/@inquirer/core/dist/lib/Separator.js
3781
+ import { styleText as styleText2 } from "node:util";
3782
+ class Separator {
3783
+ separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
3784
+ type = "separator";
3785
+ constructor(separator) {
3786
+ if (separator) {
3787
+ this.separator = separator;
3788
+ }
3789
+ }
3790
+ static isSeparator(choice) {
3791
+ return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
3792
+ }
3793
+ }
3794
+ // node_modules/@inquirer/select/dist/index.js
3795
+ import { styleText as styleText3 } from "node:util";
3796
+ var selectTheme = {
3797
+ icon: { cursor: dist_default.pointer },
3798
+ style: {
3799
+ disabled: (text) => styleText3("dim", `- ${text}`),
3800
+ description: (text) => styleText3("cyan", text),
3801
+ keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " • "))
3802
+ },
3803
+ indexMode: "hidden",
3804
+ keybindings: []
3805
+ };
3806
+ function isSelectable(item) {
3807
+ return !Separator.isSeparator(item) && !item.disabled;
3808
+ }
3809
+ function normalizeChoices(choices) {
3810
+ return choices.map((choice) => {
3811
+ if (Separator.isSeparator(choice))
3812
+ return choice;
3813
+ if (typeof choice !== "object" || choice === null || !("value" in choice)) {
3814
+ const name2 = String(choice);
3815
+ return {
3816
+ value: choice,
3817
+ name: name2,
3818
+ short: name2,
3819
+ disabled: false
3820
+ };
3821
+ }
3822
+ const name = choice.name ?? String(choice.value);
3823
+ const normalizedChoice = {
3824
+ value: choice.value,
3825
+ name,
3826
+ short: choice.short ?? name,
3827
+ disabled: choice.disabled ?? false
3828
+ };
3829
+ if (choice.description) {
3830
+ normalizedChoice.description = choice.description;
3831
+ }
3832
+ return normalizedChoice;
3833
+ });
3834
+ }
3835
+ var dist_default2 = createPrompt((config, done) => {
3836
+ const { loop = true, pageSize = 7 } = config;
3837
+ const theme = makeTheme(selectTheme, config.theme);
3838
+ const { keybindings } = theme;
3839
+ const [status, setStatus] = useState("idle");
3840
+ const prefix = usePrefix({ status, theme });
3841
+ const searchTimeoutRef = useRef();
3842
+ const searchEnabled = !keybindings.includes("vim");
3843
+ const items = useMemo(() => normalizeChoices(config.choices), [config.choices]);
3844
+ const bounds = useMemo(() => {
3845
+ const first = items.findIndex(isSelectable);
3846
+ const last = items.findLastIndex(isSelectable);
3847
+ if (first === -1) {
3848
+ throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
3849
+ }
3850
+ return { first, last };
3851
+ }, [items]);
3852
+ const defaultItemIndex = useMemo(() => {
3853
+ if (!("default" in config))
3854
+ return -1;
3855
+ return items.findIndex((item) => isSelectable(item) && item.value === config.default);
3856
+ }, [config.default, items]);
3857
+ const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
3858
+ const selectedChoice = items[active];
3859
+ useKeypress((key, rl) => {
3860
+ clearTimeout(searchTimeoutRef.current);
3861
+ if (isEnterKey(key)) {
3862
+ setStatus("done");
3863
+ done(selectedChoice.value);
3864
+ } else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
3865
+ rl.clearLine(0);
3866
+ if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
3867
+ const offset = isUpKey(key, keybindings) ? -1 : 1;
3868
+ let next = active;
3869
+ do {
3870
+ next = (next + offset + items.length) % items.length;
3871
+ } while (!isSelectable(items[next]));
3872
+ setActive(next);
3873
+ }
3874
+ } else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
3875
+ const selectedIndex = Number(rl.line) - 1;
3876
+ let selectableIndex = -1;
3877
+ const position = items.findIndex((item2) => {
3878
+ if (Separator.isSeparator(item2))
3879
+ return false;
3880
+ selectableIndex++;
3881
+ return selectableIndex === selectedIndex;
3882
+ });
3883
+ const item = items[position];
3884
+ if (item != null && isSelectable(item)) {
3885
+ setActive(position);
3886
+ }
3887
+ searchTimeoutRef.current = setTimeout(() => {
3888
+ rl.clearLine(0);
3889
+ }, 700);
3890
+ } else if (isBackspaceKey(key)) {
3891
+ rl.clearLine(0);
3892
+ } else if (searchEnabled) {
3893
+ const searchTerm = rl.line.toLowerCase();
3894
+ const matchIndex = items.findIndex((item) => {
3895
+ if (Separator.isSeparator(item) || !isSelectable(item))
3896
+ return false;
3897
+ return item.name.toLowerCase().startsWith(searchTerm);
3898
+ });
3899
+ if (matchIndex !== -1) {
3900
+ setActive(matchIndex);
3901
+ }
3902
+ searchTimeoutRef.current = setTimeout(() => {
3903
+ rl.clearLine(0);
3904
+ }, 700);
3905
+ }
3906
+ });
3907
+ useEffect(() => () => {
3908
+ clearTimeout(searchTimeoutRef.current);
3909
+ }, []);
3910
+ const message = theme.style.message(config.message, status);
3911
+ const helpLine = theme.style.keysHelpTip([
3912
+ ["↑↓", "navigate"],
3913
+ ["⏎", "select"]
3914
+ ]);
3915
+ let separatorCount = 0;
3916
+ const page = usePagination({
3917
+ items,
3918
+ active,
3919
+ renderItem({ item, isActive, index }) {
3920
+ if (Separator.isSeparator(item)) {
3921
+ separatorCount++;
3922
+ return ` ${item.separator}`;
3923
+ }
3924
+ const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
3925
+ if (item.disabled) {
3926
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
3927
+ return theme.style.disabled(`${indexLabel}${item.name} ${disabledLabel}`);
3928
+ }
3929
+ const color = isActive ? theme.style.highlight : (x) => x;
3930
+ const cursor = isActive ? theme.icon.cursor : ` `;
3931
+ return color(`${cursor} ${indexLabel}${item.name}`);
3932
+ },
3933
+ pageSize,
3934
+ loop
3935
+ });
3936
+ if (status === "done") {
3937
+ return [prefix, message, theme.style.answer(selectedChoice.short)].filter(Boolean).join(" ");
3938
+ }
3939
+ const { description } = selectedChoice;
3940
+ const lines = [
3941
+ [prefix, message].filter(Boolean).join(" "),
3942
+ page,
3943
+ " ",
3944
+ description ? theme.style.description(description) : "",
3945
+ helpLine
3946
+ ].filter(Boolean).join(`
3947
+ `).trimEnd();
3948
+ return `${lines}${cursorHide}`;
3949
+ });
3950
+ // src/commands/agent.ts
3951
+ import { spawn as spawn2 } from "node:child_process";
3952
+ import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync } from "node:fs";
3953
+ import { join as join3 } from "node:path";
3954
+
3955
+ // src/playStartupSound.ts
3956
+ import { spawn, spawnSync } from "node:child_process";
3957
+ import { existsSync } from "node:fs";
3958
+ import { join as join2 } from "node:path";
3959
+ import { platform } from "node:os";
3960
+
3961
+ // src/paths.ts
3962
+ import { readFileSync } from "node:fs";
3963
+ import { join } from "node:path";
3964
+ var PACKAGE_ROOT = join(import.meta.dirname, "..");
3965
+ function packageVersion() {
3966
+ const pkg = JSON.parse(readFileSync(join(PACKAGE_ROOT, "package.json"), "utf8"));
3967
+ return pkg.version;
3968
+ }
3969
+
3970
+ // src/playStartupSound.ts
3971
+ function which(cmd) {
3972
+ const result = spawnSync("which", [cmd], { stdio: "ignore" });
3973
+ return result.status === 0;
3974
+ }
3975
+ function playStartupSound() {
3976
+ const sounds = ["ready-to-work.mp3", "work-work.mp3", "it-just-works.mp3", "we-cant-expect-god-to-do-all-the-work.mp3", "lets-go.mp3"];
3977
+ const pick = sounds[Math.floor(Math.random() * sounds.length)];
3978
+ const audioPath = join2(PACKAGE_ROOT, "assets", pick);
3979
+ if (!existsSync(audioPath))
3980
+ return;
3981
+ const player = platform() === "darwin" ? "afplay" : platform() === "linux" ? "mpg123" : null;
3982
+ if (!player || !which(player))
3983
+ return;
3984
+ spawn(player, [audioPath], { stdio: "ignore", detached: true }).unref();
3985
+ }
3986
+
3987
+ // src/commands/agent.ts
3988
+ var SLEEP_SECONDS = 60;
3989
+ function timestamp(d = new Date) {
3990
+ return d.toTimeString().slice(0, 8);
3991
+ }
3992
+ var AUTONOMY_PREAMBLE = `## You are running autonomously
3993
+
3994
+ No human is watching this session. No one will answer your questions or confirm your actions.
3995
+
3996
+ - Never stop to ask for approval, confirmation, or clarification.
3997
+ - When you need to make a decision, pick the most reasonable default and continue.
3998
+ - If you are genuinely blocked (missing credentials, task is ambiguous with no safe default), write a brief note to \`.mdless/learnings/<slug>.md\` explaining what you need, then exit cleanly.
3999
+
4000
+ ---
4001
+
4002
+ `;
4003
+ var LEARNINGS_PREAMBLE = `## Session setup
4004
+
4005
+ Before doing anything else, check if \`.mdless/learnings/\` exists in the current working directory. If it does, read every file in it — these are notes from past agent sessions documenting workarounds, environment quirks, and solutions to problems you are likely to encounter again. Use them to skip mistakes and avoid re-solving known issues.
4006
+
4007
+ ---
4008
+
4009
+ `;
4010
+ var LEARNINGS_POSTAMBLE = `
4011
+
4012
+ ---
4013
+
4014
+ ## Before you finish
4015
+
4016
+ Reflect on what happened this session. If you encountered any non-obvious problems, workarounds, API quirks, environment issues, or solutions that a future agent session in this codebase would benefit from knowing, save each one as a concise note:
4017
+
4018
+ .mdless/learnings/<descriptive-slug>.md
4019
+
4020
+ Each file should cover one specific finding: what the problem was, what you tried, and what worked. Skip task-specific details — only save knowledge that is reusable across sessions.
4021
+
4022
+ Also review any learnings you read at the start. If one is outdated, wrong, or no longer relevant, update or delete it — stale learnings are worse than no learnings.
4023
+ `;
4024
+ function listAgents(cwd = process.cwd()) {
4025
+ const agentsDir = join3(cwd, ".mdless", "agents");
4026
+ if (!existsSync2(agentsDir))
4027
+ return [];
4028
+ return readdirSync(agentsDir).filter((f) => f.endsWith(".md")).map((f) => f.slice(0, -3));
4029
+ }
4030
+ function loadPrompt(name) {
4031
+ const agentsDir = join3(process.cwd(), ".mdless", "agents");
4032
+ const promptPath = join3(agentsDir, `${name}.md`);
4033
+ if (!existsSync2(promptPath)) {
4034
+ let msg = `✗ no prompt found at ${promptPath}
4035
+ run \`mdless init\` to create the default prompts.`;
4036
+ const agents = listAgents();
4037
+ if (agents.length > 0) {
4038
+ msg += `
4039
+
4040
+ available agents:
4041
+ ${agents.map((a) => ` mdless agent ${a}`).join(`
4042
+ `)}`;
4043
+ }
4044
+ console.error(msg);
4045
+ process.exit(1);
4046
+ }
4047
+ const body = readFileSync2(promptPath, "utf8");
4048
+ return AUTONOMY_PREAMBLE + LEARNINGS_PREAMBLE + body + LEARNINGS_POSTAMBLE;
4049
+ }
4050
+ var RESET = "\x1B[0m";
4051
+ var DIM = "\x1B[2m";
4052
+ var BOLD = "\x1B[1m";
4053
+ var ITALIC = "\x1B[3m";
4054
+ var VIOLET = "\x1B[38;5;141m";
4055
+ var LAVENDER = "\x1B[38;5;147m";
4056
+ var DEEP_PURPLE = "\x1B[38;5;99m";
4057
+ var PINK_PURPLE = "\x1B[38;5;177m";
4058
+ var MAGENTA_PURPLE = "\x1B[38;5;171m";
4059
+ var PALE = "\x1B[38;5;153m";
4060
+ var SOFT_PINK = "\x1B[38;5;211m";
4061
+ var TOOL_COLORS = {
4062
+ Bash: VIOLET,
4063
+ Read: LAVENDER,
4064
+ Write: PINK_PURPLE,
4065
+ Edit: PINK_PURPLE,
4066
+ MultiEdit: PINK_PURPLE,
4067
+ Glob: DEEP_PURPLE,
4068
+ Grep: DEEP_PURPLE,
4069
+ WebFetch: PALE,
4070
+ WebSearch: PALE,
4071
+ Task: MAGENTA_PURPLE
4072
+ };
4073
+ var AGENT_COLOR = VIOLET;
4074
+ function toolColor(name) {
4075
+ return TOOL_COLORS[name] ?? VIOLET;
4076
+ }
4077
+ function truncate(s, n) {
4078
+ const clean = s.replace(/\s+/g, " ").trim();
4079
+ return clean.length > n ? clean.slice(0, n - 1) + "…" : clean;
4080
+ }
4081
+ function summarizeToolInput(name, input) {
4082
+ if (!input || typeof input !== "object")
4083
+ return "";
4084
+ switch (name) {
4085
+ case "Bash":
4086
+ return `$ ${truncate(input.command ?? "", 140)}`;
4087
+ case "Read":
4088
+ return input.file_path ?? "";
4089
+ case "Write":
4090
+ return input.file_path ?? "";
4091
+ case "Edit":
4092
+ case "MultiEdit":
4093
+ return input.file_path ?? "";
4094
+ case "Glob":
4095
+ return input.pattern ?? "";
4096
+ case "Grep": {
4097
+ const where = input.path ? ` in ${input.path}` : input.glob ? ` (${input.glob})` : "";
4098
+ return `"${truncate(input.pattern ?? "", 80)}"${where}`;
4099
+ }
4100
+ case "WebFetch":
4101
+ case "WebSearch":
4102
+ return input.url ?? input.query ?? "";
4103
+ case "Task":
4104
+ return truncate(input.description ?? input.prompt ?? "", 120);
4105
+ default: {
4106
+ const first = Object.values(input).find((v) => typeof v === "string");
4107
+ return typeof first === "string" ? truncate(first, 120) : truncate(JSON.stringify(input), 120);
4108
+ }
4109
+ }
4110
+ }
4111
+ function summarizeToolResult(raw, isError) {
4112
+ if (!raw.trim())
4113
+ return isError ? "(error, no output)" : "(no output)";
4114
+ const lines = raw.split(`
4115
+ `).map((l) => l.trim()).filter(Boolean);
4116
+ if (lines.length === 0)
4117
+ return "(empty)";
4118
+ const firstLine = lines[0];
4119
+ if (firstLine.startsWith("{") || firstLine.startsWith("[")) {
4120
+ try {
4121
+ const parsed = JSON.parse(raw);
4122
+ if (Array.isArray(parsed))
4123
+ return `[${parsed.length} items]`;
4124
+ if (parsed && typeof parsed === "object") {
4125
+ const keys = Object.keys(parsed);
4126
+ if (keys.length === 0)
4127
+ return "{}";
4128
+ return `{${keys.slice(0, 4).join(", ")}${keys.length > 4 ? ", …" : ""}}`;
4129
+ }
4130
+ } catch {}
4131
+ }
4132
+ const extra = lines.length > 1 ? ` (+${lines.length - 1} lines)` : "";
4133
+ return truncate(firstLine, 140) + extra;
4134
+ }
4135
+ function indent(text, prefix) {
4136
+ return text.split(`
4137
+ `).map((line) => prefix + line).join(`
4138
+ `);
4139
+ }
4140
+ function formatStreamEvent(line) {
4141
+ let evt;
4142
+ try {
4143
+ evt = JSON.parse(line);
4144
+ } catch {
4145
+ return line + `
4146
+ `;
4147
+ }
4148
+ if (evt.type === "system" && evt.subtype === "init") {
4149
+ const session = (evt.session_id ?? "?").toString().slice(0, 8);
4150
+ const tools = Array.isArray(evt.tools) ? evt.tools.length : 0;
4151
+ return `${DIM} session ${session} · ${tools} tools loaded${RESET}
4152
+
4153
+ `;
4154
+ }
4155
+ if (evt.type === "assistant" && evt.message?.content) {
4156
+ const out = [];
4157
+ for (const block of evt.message.content) {
4158
+ if (block.type === "text" && block.text?.trim()) {
4159
+ out.push(`
4160
+ ` + indent(block.text.trim(), " ") + `
4161
+ `);
4162
+ } else if (block.type === "tool_use") {
4163
+ const summary = summarizeToolInput(block.name, block.input);
4164
+ const color = toolColor(block.name);
4165
+ out.push(` ${color}▸${RESET} ${color}${block.name.padEnd(9)}${RESET} ${summary}`);
4166
+ } else if (block.type === "thinking" && block.thinking?.trim()) {
4167
+ out.push(` ${DIM}${ITALIC}~ ${truncate(block.thinking, 200)}${RESET}`);
4168
+ }
4169
+ }
4170
+ return out.length ? out.join(`
4171
+ `) + `
4172
+ ` : null;
4173
+ }
4174
+ if (evt.type === "user" && evt.message?.content) {
4175
+ const out = [];
4176
+ for (const block of evt.message.content) {
4177
+ if (block.type === "tool_result") {
4178
+ const raw = typeof block.content === "string" ? block.content : Array.isArray(block.content) ? block.content.map((c) => c.text ?? "").join(`
4179
+ `) : "";
4180
+ const summary = summarizeToolResult(raw, !!block.is_error);
4181
+ const arrow = block.is_error ? `${SOFT_PINK}└─ ✗${RESET}` : `${DIM}└─${RESET}`;
4182
+ out.push(` ${arrow} ${DIM}${summary}${RESET}`);
4183
+ }
4184
+ }
4185
+ return out.length ? out.join(`
4186
+ `) + `
4187
+ ` : null;
4188
+ }
4189
+ if (evt.type === "result") {
4190
+ const parts = [];
4191
+ if (evt.num_turns != null)
4192
+ parts.push(`${evt.num_turns} turns`);
4193
+ if (evt.duration_ms != null)
4194
+ parts.push(`${(evt.duration_ms / 1000).toFixed(1)}s`);
4195
+ if (evt.total_cost_usd != null)
4196
+ parts.push(`$${evt.total_cost_usd.toFixed(4)}`);
4197
+ const color = evt.is_error ? SOFT_PINK : LAVENDER;
4198
+ const mark = evt.is_error ? "✗" : "✓";
4199
+ return `
4200
+ ${color}${mark}${RESET} ${DIM}${parts.join(" · ")}${RESET}
4201
+ `;
4202
+ }
4203
+ return null;
4204
+ }
4205
+ function withTimestamps(text) {
4206
+ const gutter = `${DIM}${timestamp()}${RESET} `;
4207
+ return text.split(`
4208
+ `).map((line) => line.length ? gutter + line : line).join(`
4209
+ `);
4210
+ }
4211
+ function runClaude(prompt) {
4212
+ return new Promise((resolve) => {
4213
+ const child = spawn2("claude", [
4214
+ "-p",
4215
+ prompt,
4216
+ "--dangerously-skip-permissions",
4217
+ "--verbose",
4218
+ "--output-format",
4219
+ "stream-json"
4220
+ ], { stdio: ["ignore", "pipe", "pipe"] });
4221
+ let buf = "";
4222
+ child.stdout.on("data", (chunk) => {
4223
+ buf += chunk.toString();
4224
+ let nl;
4225
+ while ((nl = buf.indexOf(`
4226
+ `)) !== -1) {
4227
+ const line = buf.slice(0, nl);
4228
+ buf = buf.slice(nl + 1);
4229
+ if (!line.trim())
4230
+ continue;
4231
+ const formatted = formatStreamEvent(line);
4232
+ if (formatted)
4233
+ process.stdout.write(withTimestamps(formatted));
4234
+ }
4235
+ });
4236
+ child.stderr.on("data", (chunk) => process.stderr.write(chunk));
4237
+ child.on("error", (err) => {
4238
+ process.stderr.write(`
4239
+ [agent] failed to spawn claude: ${err.message}
4240
+ `);
4241
+ resolve(1);
4242
+ });
4243
+ child.on("exit", (code) => resolve(code ?? 0));
4244
+ });
4245
+ }
4246
+ var MAX_TIMEOUT_MS = 2 ** 31 - 1;
4247
+ async function sleep(seconds) {
4248
+ let remaining = seconds * 1000;
4249
+ while (remaining > 0) {
4250
+ const chunk = Math.min(remaining, MAX_TIMEOUT_MS);
4251
+ await new Promise((resolve) => setTimeout(resolve, chunk));
4252
+ remaining -= chunk;
4253
+ }
4254
+ }
4255
+ var UNIT_SECONDS = { s: 1, m: 60, h: 3600, d: 86400 };
4256
+ function parseInterval(text) {
4257
+ const trimmed = text.trim().toLowerCase();
4258
+ if (!/^(\d+(\.\d+)?[smhd])+$/.test(trimmed))
4259
+ return null;
4260
+ let total = 0;
4261
+ for (const [, value, unit] of trimmed.matchAll(/(\d+(?:\.\d+)?)([smhd])/g)) {
4262
+ total += Number(value) * UNIT_SECONDS[unit];
4263
+ }
4264
+ return total > 0 ? total : null;
4265
+ }
4266
+ function formatInterval(seconds) {
4267
+ let rest = Math.round(seconds);
4268
+ const parts = [];
4269
+ for (const [unit, size] of [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]]) {
4270
+ if (rest >= size) {
4271
+ parts.push(`${Math.floor(rest / size)}${unit}`);
4272
+ rest %= size;
4273
+ }
4274
+ }
4275
+ return parts.join("") || "0s";
4276
+ }
4277
+ async function agentCommand(name, options = {}) {
4278
+ const { loop, every } = options;
4279
+ if (typeof loop === "number" && (!Number.isInteger(loop) || loop < 1)) {
4280
+ console.error(`✗ --loop count must be a positive integer (got ${loop}).`);
4281
+ process.exit(1);
4282
+ }
4283
+ const parsedEvery = every === undefined ? undefined : parseInterval(every);
4284
+ if (parsedEvery === null) {
4285
+ console.error(`✗ invalid --every value "${every}".
4286
+ ` + ` Use a number followed by a unit: s (seconds), m (minutes), h (hours), d (days).
4287
+ ` + ` You can combine units. Examples: 30s, 10m, 2h, 1d, 1h30m.`);
4288
+ process.exit(1);
4289
+ }
4290
+ const waitSeconds = parsedEvery ?? SLEEP_SECONDS;
4291
+ const maxRuns = typeof loop === "number" ? loop : loop === true || every !== undefined ? Infinity : 1;
4292
+ const prompt = loadPrompt(name);
4293
+ playStartupSound();
4294
+ const waitLabel = formatInterval(waitSeconds);
4295
+ const runsLabel = maxRuns === Infinity ? `loop every ${waitLabel}` : maxRuns === 1 ? "1 run" : `${maxRuns} runs, every ${waitLabel}`;
4296
+ const titleColor = AGENT_COLOR;
4297
+ const banner = `
4298
+ ${titleColor}${BOLD} ✦ mdless · ${name}${RESET}
4299
+ ` + `${DIM} ${"─".repeat(40)}${RESET}
4300
+ ` + `${DIM} ${runsLabel}${RESET}
4301
+ `;
4302
+ process.stdout.write(banner);
4303
+ process.on("SIGINT", () => {
4304
+ process.stdout.write(`
4305
+ ${DIM}${name} stopped${RESET}
4306
+ `);
4307
+ process.exit(0);
4308
+ });
4309
+ for (let run = 1;run <= maxRuns; run++) {
4310
+ process.stdout.write(`
4311
+ ${DIM}── ${timestamp()} ─────────────────────────────${RESET}
4312
+ `);
4313
+ await runClaude(prompt);
4314
+ const isLast = run >= maxRuns;
4315
+ if (isLast)
4316
+ break;
4317
+ const nextRun = new Date(Date.now() + waitSeconds * 1000);
4318
+ process.stdout.write(`${DIM} sleeping ${waitLabel}, next run at ${timestamp(nextRun)}…${RESET}
4319
+ `);
4320
+ await sleep(waitSeconds);
4321
+ }
4322
+ }
4323
+
4324
+ // src/commands/init.ts
4325
+ import {
4326
+ appendFileSync,
4327
+ copyFileSync,
4328
+ existsSync as existsSync3,
4329
+ mkdirSync,
4330
+ readFileSync as readFileSync3,
4331
+ readdirSync as readdirSync2
4332
+ } from "node:fs";
4333
+ import { join as join4 } from "node:path";
4334
+ var BUNDLED_PROMPTS_DIR = join4(PACKAGE_ROOT, "src", "agents", "prompts");
4335
+ var GITIGNORE_ENTRIES = [".mdless/worktrees/"];
4336
+ function ensureGitignore() {
4337
+ const gitignore = join4(process.cwd(), ".gitignore");
4338
+ const existing = existsSync3(gitignore) ? readFileSync3(gitignore, "utf8") : "";
4339
+ const lines = new Set(existing.split(`
4340
+ `).map((l) => l.trim()));
4341
+ const missing = GITIGNORE_ENTRIES.filter((e) => !lines.has(e));
4342
+ if (missing.length === 0)
4343
+ return;
4344
+ const prefix = !existing || existing.endsWith(`
4345
+ `) ? "" : `
4346
+ `;
4347
+ appendFileSync(gitignore, prefix + missing.map((e) => `${e}
4348
+ `).join(""));
4349
+ for (const entry of missing) {
4350
+ console.log(`✓ added ${entry} to .gitignore`);
4351
+ }
4352
+ }
4353
+ async function initCommand() {
4354
+ const targetDir = join4(process.cwd(), ".mdless", "agents");
4355
+ mkdirSync(targetDir, { recursive: true });
4356
+ ensureGitignore();
4357
+ const files = readdirSync2(BUNDLED_PROMPTS_DIR).filter((f) => f.endsWith(".md"));
4358
+ if (files.length === 0) {
4359
+ console.error(`✗ no bundled prompts found at ${BUNDLED_PROMPTS_DIR}`);
4360
+ process.exit(1);
4361
+ }
4362
+ let copied = 0;
4363
+ let skipped = 0;
4364
+ for (const file of files) {
4365
+ const dest = join4(targetDir, file);
4366
+ if (existsSync3(dest)) {
4367
+ console.log(`! ${file} already exists in .mdless/agents/ (skipped)`);
4368
+ skipped++;
4369
+ continue;
4370
+ }
4371
+ copyFileSync(join4(BUNDLED_PROMPTS_DIR, file), dest);
4372
+ console.log(`✓ ${file}`);
4373
+ copied++;
4374
+ }
4375
+ console.log(`
4376
+ ${copied} copied, ${skipped} skipped → .mdless/agents/`);
4377
+ console.log(`Edit those files to customize prompts, then run \`mdless agent <name>\`.`);
4378
+ }
4379
+
4380
+ // src/utils.ts
4381
+ function exit() {
4382
+ console.log(`
4383
+ Aborted.`);
4384
+ process.exit(0);
4385
+ }
4386
+ function withExitHandler(promise) {
4387
+ return promise.catch((e) => {
4388
+ if (e.name === "ExitPromptError")
4389
+ exit();
4390
+ throw e;
4391
+ });
4392
+ }
4393
+
4394
+ // src/index.ts
4395
+ var banner = `
4396
+ \x1B[38;5;135m██╗\x1B[0m \x1B[38;5;141m███╗ ███╗\x1B[38;5;147m██████╗ \x1B[38;5;153m██╗ \x1B[38;5;159m███████╗\x1B[38;5;195m███████╗\x1B[38;5;231m███████╗
4397
+ \x1B[38;5;135m╚██╗\x1B[0m \x1B[38;5;141m████╗ ████║\x1B[38;5;147m██╔══██╗\x1B[38;5;153m██║ \x1B[38;5;159m██╔════╝\x1B[38;5;195m██╔════╝\x1B[38;5;231m██╔════╝
4398
+ \x1B[38;5;135m ╚██╗\x1B[0m \x1B[38;5;141m██╔████╔██║\x1B[38;5;147m██║ ██║\x1B[38;5;153m██║ \x1B[38;5;159m█████╗ \x1B[38;5;195m███████╗\x1B[38;5;231m███████╗
4399
+ \x1B[38;5;135m ██╔╝\x1B[0m \x1B[38;5;141m██║╚██╔╝██║\x1B[38;5;147m██║ ██║\x1B[38;5;153m██║ \x1B[38;5;159m██╔══╝ \x1B[38;5;195m╚════██║\x1B[38;5;231m╚════██║
4400
+ \x1B[38;5;135m██╔╝\x1B[0m \x1B[38;5;141m██║ ╚═╝ ██║\x1B[38;5;147m██████╔╝\x1B[38;5;153m███████╗\x1B[38;5;159m███████╗\x1B[38;5;195m███████║\x1B[38;5;231m███████║
4401
+ \x1B[38;5;135m╚═╝\x1B[0m \x1B[38;5;141m╚═╝ ╚═╝\x1B[38;5;147m╚═════╝ \x1B[38;5;153m╚══════╝\x1B[38;5;159m╚══════╝\x1B[38;5;195m╚══════╝\x1B[38;5;231m╚══════╝\x1B[0m
4402
+ `;
4403
+ var commands = [
4404
+ {
4405
+ name: "init",
4406
+ description: "Copy the default agent prompts into .mdless/agents/",
4407
+ action: initCommand
4408
+ }
4409
+ ];
4410
+ async function interactiveMode() {
4411
+ console.log(banner);
4412
+ console.log(`\x1B[2m Mind less, ship more. v${packageVersion()}\x1B[0m
4413
+ `);
4414
+ const choice = await withExitHandler(dist_default2({
4415
+ message: "What would you like to do?",
4416
+ choices: [
4417
+ ...commands.map((cmd) => ({
4418
+ name: cmd.name,
4419
+ value: cmd.name,
4420
+ description: cmd.description
4421
+ })),
4422
+ { name: "exit", value: "exit", description: "Exit the CLI" }
4423
+ ]
4424
+ }));
4425
+ if (choice === "exit") {
4426
+ process.exit(0);
4427
+ }
4428
+ const command = commands.find((cmd) => cmd.name === choice);
4429
+ if (command) {
4430
+ await command.action();
4431
+ }
4432
+ }
4433
+ var program2 = new Command().name("mdless").description("CLI tools for Claude Code hard-working devs").version(packageVersion());
4434
+ for (const cmd of commands) {
4435
+ program2.command(cmd.name).description(cmd.description).action(cmd.action);
4436
+ }
4437
+ program2.command("agent [name]").description("Run a single agent — reads the prompt from .mdless/agents/<name>.md").option("--loop [count]", "Run the agent on repeat — forever, or <count> times if given", (v) => parseInt(v, 10)).option("--every <interval>", "Run the agent on repeat and wait <interval> between runs, eg 30s, 10m, 2h, 1d").action(async (name, options) => {
4438
+ if (!name) {
4439
+ const agents = listAgents();
4440
+ if (agents.length === 0) {
4441
+ console.error("✗ no agents found — run `mdless init` to create the default prompts.");
4442
+ process.exit(1);
4443
+ }
4444
+ name = await withExitHandler(dist_default2({
4445
+ message: "Which agent would you like to run?",
4446
+ choices: agents.map((a) => ({ name: a, value: a }))
4447
+ }));
4448
+ }
4449
+ agentCommand(name, options);
4450
+ });
4451
+ if (process.argv.length <= 2) {
4452
+ interactiveMode();
4453
+ } else {
4454
+ program2.parse();
4455
+ }