oh-my-opencode 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3745 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
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 = import.meta.require;
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("events").EventEmitter;
743
+ var childProcess = __require("child_process");
744
+ var path = __require("path");
745
+ var fs = __require("fs");
746
+ var process2 = __require("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/sisteransi/src/index.js
2116
+ var require_src = __commonJS((exports, module) => {
2117
+ var ESC = "\x1B";
2118
+ var CSI = `${ESC}[`;
2119
+ var beep = "\x07";
2120
+ var cursor = {
2121
+ to(x, y) {
2122
+ if (!y)
2123
+ return `${CSI}${x + 1}G`;
2124
+ return `${CSI}${y + 1};${x + 1}H`;
2125
+ },
2126
+ move(x, y) {
2127
+ let ret = "";
2128
+ if (x < 0)
2129
+ ret += `${CSI}${-x}D`;
2130
+ else if (x > 0)
2131
+ ret += `${CSI}${x}C`;
2132
+ if (y < 0)
2133
+ ret += `${CSI}${-y}A`;
2134
+ else if (y > 0)
2135
+ ret += `${CSI}${y}B`;
2136
+ return ret;
2137
+ },
2138
+ up: (count = 1) => `${CSI}${count}A`,
2139
+ down: (count = 1) => `${CSI}${count}B`,
2140
+ forward: (count = 1) => `${CSI}${count}C`,
2141
+ backward: (count = 1) => `${CSI}${count}D`,
2142
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
2143
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
2144
+ left: `${CSI}G`,
2145
+ hide: `${CSI}?25l`,
2146
+ show: `${CSI}?25h`,
2147
+ save: `${ESC}7`,
2148
+ restore: `${ESC}8`
2149
+ };
2150
+ var scroll = {
2151
+ up: (count = 1) => `${CSI}S`.repeat(count),
2152
+ down: (count = 1) => `${CSI}T`.repeat(count)
2153
+ };
2154
+ var erase = {
2155
+ screen: `${CSI}2J`,
2156
+ up: (count = 1) => `${CSI}1J`.repeat(count),
2157
+ down: (count = 1) => `${CSI}J`.repeat(count),
2158
+ line: `${CSI}2K`,
2159
+ lineEnd: `${CSI}K`,
2160
+ lineStart: `${CSI}1K`,
2161
+ lines(count) {
2162
+ let clear = "";
2163
+ for (let i = 0;i < count; i++)
2164
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
2165
+ if (count)
2166
+ clear += cursor.left;
2167
+ return clear;
2168
+ }
2169
+ };
2170
+ module.exports = { cursor, scroll, erase, beep };
2171
+ });
2172
+
2173
+ // node_modules/picocolors/picocolors.js
2174
+ var require_picocolors = __commonJS((exports, module) => {
2175
+ var p = process || {};
2176
+ var argv = p.argv || [];
2177
+ var env = p.env || {};
2178
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
2179
+ var formatter = (open, close, replace = open) => (input) => {
2180
+ let string = "" + input, index = string.indexOf(close, open.length);
2181
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
2182
+ };
2183
+ var replaceClose = (string, close, replace, index) => {
2184
+ let result = "", cursor = 0;
2185
+ do {
2186
+ result += string.substring(cursor, index) + replace;
2187
+ cursor = index + close.length;
2188
+ index = string.indexOf(close, cursor);
2189
+ } while (~index);
2190
+ return result + string.substring(cursor);
2191
+ };
2192
+ var createColors = (enabled = isColorSupported) => {
2193
+ let f = enabled ? formatter : () => String;
2194
+ return {
2195
+ isColorSupported: enabled,
2196
+ reset: f("\x1B[0m", "\x1B[0m"),
2197
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
2198
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
2199
+ italic: f("\x1B[3m", "\x1B[23m"),
2200
+ underline: f("\x1B[4m", "\x1B[24m"),
2201
+ inverse: f("\x1B[7m", "\x1B[27m"),
2202
+ hidden: f("\x1B[8m", "\x1B[28m"),
2203
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
2204
+ black: f("\x1B[30m", "\x1B[39m"),
2205
+ red: f("\x1B[31m", "\x1B[39m"),
2206
+ green: f("\x1B[32m", "\x1B[39m"),
2207
+ yellow: f("\x1B[33m", "\x1B[39m"),
2208
+ blue: f("\x1B[34m", "\x1B[39m"),
2209
+ magenta: f("\x1B[35m", "\x1B[39m"),
2210
+ cyan: f("\x1B[36m", "\x1B[39m"),
2211
+ white: f("\x1B[37m", "\x1B[39m"),
2212
+ gray: f("\x1B[90m", "\x1B[39m"),
2213
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
2214
+ bgRed: f("\x1B[41m", "\x1B[49m"),
2215
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
2216
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
2217
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
2218
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
2219
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
2220
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
2221
+ blackBright: f("\x1B[90m", "\x1B[39m"),
2222
+ redBright: f("\x1B[91m", "\x1B[39m"),
2223
+ greenBright: f("\x1B[92m", "\x1B[39m"),
2224
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
2225
+ blueBright: f("\x1B[94m", "\x1B[39m"),
2226
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
2227
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
2228
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
2229
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
2230
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
2231
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
2232
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
2233
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
2234
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
2235
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
2236
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
2237
+ };
2238
+ };
2239
+ module.exports = createColors();
2240
+ module.exports.createColors = createColors;
2241
+ });
2242
+
2243
+ // package.json
2244
+ var require_package = __commonJS((exports, module) => {
2245
+ module.exports = {
2246
+ name: "oh-my-opencode",
2247
+ version: "2.5.0",
2248
+ description: "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
2249
+ main: "dist/index.js",
2250
+ types: "dist/index.d.ts",
2251
+ type: "module",
2252
+ bin: {
2253
+ "oh-my-opencode": "./dist/cli/index.js"
2254
+ },
2255
+ files: [
2256
+ "dist"
2257
+ ],
2258
+ exports: {
2259
+ ".": {
2260
+ types: "./dist/index.d.ts",
2261
+ import: "./dist/index.js"
2262
+ },
2263
+ "./google-auth": {
2264
+ types: "./dist/google-auth.d.ts",
2265
+ import: "./dist/google-auth.js"
2266
+ },
2267
+ "./schema.json": "./dist/oh-my-opencode.schema.json"
2268
+ },
2269
+ scripts: {
2270
+ build: "bun build src/index.ts src/google-auth.ts --outdir dist --target bun --format esm --external @ast-grep/napi && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm && bun run build:schema",
2271
+ "build:schema": "bun run script/build-schema.ts",
2272
+ clean: "rm -rf dist",
2273
+ prepublishOnly: "bun run clean && bun run build",
2274
+ typecheck: "tsc --noEmit",
2275
+ test: "bun test"
2276
+ },
2277
+ keywords: [
2278
+ "opencode",
2279
+ "plugin",
2280
+ "oracle",
2281
+ "librarian",
2282
+ "agents",
2283
+ "ai",
2284
+ "llm"
2285
+ ],
2286
+ author: "YeonGyu-Kim",
2287
+ license: "MIT",
2288
+ repository: {
2289
+ type: "git",
2290
+ url: "git+https://github.com/code-yeongyu/oh-my-opencode.git"
2291
+ },
2292
+ bugs: {
2293
+ url: "https://github.com/code-yeongyu/oh-my-opencode/issues"
2294
+ },
2295
+ homepage: "https://github.com/code-yeongyu/oh-my-opencode#readme",
2296
+ dependencies: {
2297
+ "@ast-grep/cli": "^0.40.0",
2298
+ "@ast-grep/napi": "^0.40.0",
2299
+ "@clack/prompts": "^0.11.0",
2300
+ "@code-yeongyu/comment-checker": "^0.6.0",
2301
+ "@openauthjs/openauth": "^0.4.3",
2302
+ "@opencode-ai/plugin": "^1.0.162",
2303
+ commander: "^14.0.2",
2304
+ hono: "^4.10.4",
2305
+ picocolors: "^1.1.1",
2306
+ picomatch: "^4.0.2",
2307
+ "xdg-basedir": "^5.1.0",
2308
+ zod: "^4.1.8"
2309
+ },
2310
+ devDependencies: {
2311
+ "@types/picomatch": "^3.0.2",
2312
+ "bun-types": "latest",
2313
+ typescript: "^5.7.3"
2314
+ },
2315
+ trustedDependencies: [
2316
+ "@ast-grep/cli",
2317
+ "@ast-grep/napi",
2318
+ "@code-yeongyu/comment-checker"
2319
+ ]
2320
+ };
2321
+ });
2322
+
2323
+ // node_modules/commander/esm.mjs
2324
+ var import__ = __toESM(require_commander(), 1);
2325
+ var {
2326
+ program,
2327
+ createCommand,
2328
+ createArgument,
2329
+ createOption,
2330
+ CommanderError,
2331
+ InvalidArgumentError,
2332
+ InvalidOptionArgumentError,
2333
+ Command,
2334
+ Argument,
2335
+ Option,
2336
+ Help
2337
+ } = import__.default;
2338
+
2339
+ // node_modules/@clack/prompts/dist/index.mjs
2340
+ import { stripVTControlCharacters as S2 } from "util";
2341
+
2342
+ // node_modules/@clack/core/dist/index.mjs
2343
+ var import_sisteransi = __toESM(require_src(), 1);
2344
+ import { stdin as j, stdout as M } from "process";
2345
+ import * as g from "readline";
2346
+ import O from "readline";
2347
+ import { Writable as X } from "stream";
2348
+ function DD({ onlyFirst: e = false } = {}) {
2349
+ const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
2350
+ return new RegExp(t, e ? undefined : "g");
2351
+ }
2352
+ var uD = DD();
2353
+ function P(e) {
2354
+ if (typeof e != "string")
2355
+ throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);
2356
+ return e.replace(uD, "");
2357
+ }
2358
+ function L(e) {
2359
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
2360
+ }
2361
+ var W = { exports: {} };
2362
+ (function(e) {
2363
+ var u = {};
2364
+ e.exports = u, u.eastAsianWidth = function(F) {
2365
+ var s = F.charCodeAt(0), i = F.length == 2 ? F.charCodeAt(1) : 0, D = s;
2366
+ return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D = s << 10 | i, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
2367
+ }, u.characterLength = function(F) {
2368
+ var s = this.eastAsianWidth(F);
2369
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
2370
+ };
2371
+ function t(F) {
2372
+ return F.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
2373
+ }
2374
+ u.length = function(F) {
2375
+ for (var s = t(F), i = 0, D = 0;D < s.length; D++)
2376
+ i = i + this.characterLength(s[D]);
2377
+ return i;
2378
+ }, u.slice = function(F, s, i) {
2379
+ textLen = u.length(F), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
2380
+ for (var D = "", C = 0, n = t(F), E = 0;E < n.length; E++) {
2381
+ var a = n[E], o = u.length(a);
2382
+ if (C >= s - (o == 2 ? 1 : 0))
2383
+ if (C + o <= i)
2384
+ D += a;
2385
+ else
2386
+ break;
2387
+ C += o;
2388
+ }
2389
+ return D;
2390
+ };
2391
+ })(W);
2392
+ var tD = W.exports;
2393
+ var eD = L(tD);
2394
+ var FD = function() {
2395
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\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|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\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]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\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-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
2396
+ };
2397
+ var sD = L(FD);
2398
+ function p(e, u = {}) {
2399
+ if (typeof e != "string" || e.length === 0 || (u = { ambiguousIsNarrow: true, ...u }, e = P(e), e.length === 0))
2400
+ return 0;
2401
+ e = e.replace(sD(), " ");
2402
+ const t = u.ambiguousIsNarrow ? 1 : 2;
2403
+ let F = 0;
2404
+ for (const s of e) {
2405
+ const i = s.codePointAt(0);
2406
+ if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879)
2407
+ continue;
2408
+ switch (eD.eastAsianWidth(s)) {
2409
+ case "F":
2410
+ case "W":
2411
+ F += 2;
2412
+ break;
2413
+ case "A":
2414
+ F += t;
2415
+ break;
2416
+ default:
2417
+ F += 1;
2418
+ }
2419
+ }
2420
+ return F;
2421
+ }
2422
+ var w = 10;
2423
+ var N = (e = 0) => (u) => `\x1B[${u + e}m`;
2424
+ var I = (e = 0) => (u) => `\x1B[${38 + e};5;${u}m`;
2425
+ var R = (e = 0) => (u, t, F) => `\x1B[${38 + e};2;${u};${t};${F}m`;
2426
+ var r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
2427
+ Object.keys(r.modifier);
2428
+ var iD = Object.keys(r.color);
2429
+ var CD = Object.keys(r.bgColor);
2430
+ [...iD, ...CD];
2431
+ function rD() {
2432
+ const e = new Map;
2433
+ for (const [u, t] of Object.entries(r)) {
2434
+ for (const [F, s] of Object.entries(t))
2435
+ r[F] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, t[F] = r[F], e.set(s[0], s[1]);
2436
+ Object.defineProperty(r, u, { value: t, enumerable: false });
2437
+ }
2438
+ return Object.defineProperty(r, "codes", { value: e, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = N(), r.color.ansi256 = I(), r.color.ansi16m = R(), r.bgColor.ansi = N(w), r.bgColor.ansi256 = I(w), r.bgColor.ansi16m = R(w), Object.defineProperties(r, { rgbToAnsi256: { value: (u, t, F) => u === t && t === F ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
2439
+ const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
2440
+ if (!t)
2441
+ return [0, 0, 0];
2442
+ let [F] = t;
2443
+ F.length === 3 && (F = [...F].map((i) => i + i).join(""));
2444
+ const s = Number.parseInt(F, 16);
2445
+ return [s >> 16 & 255, s >> 8 & 255, s & 255];
2446
+ }, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
2447
+ if (u < 8)
2448
+ return 30 + u;
2449
+ if (u < 16)
2450
+ return 90 + (u - 8);
2451
+ let t, F, s;
2452
+ if (u >= 232)
2453
+ t = ((u - 232) * 10 + 8) / 255, F = t, s = t;
2454
+ else {
2455
+ u -= 16;
2456
+ const C = u % 36;
2457
+ t = Math.floor(u / 36) / 5, F = Math.floor(C / 6) / 5, s = C % 6 / 5;
2458
+ }
2459
+ const i = Math.max(t, F, s) * 2;
2460
+ if (i === 0)
2461
+ return 30;
2462
+ let D = 30 + (Math.round(s) << 2 | Math.round(F) << 1 | Math.round(t));
2463
+ return i === 2 && (D += 60), D;
2464
+ }, enumerable: false }, rgbToAnsi: { value: (u, t, F) => r.ansi256ToAnsi(r.rgbToAnsi256(u, t, F)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
2465
+ }
2466
+ var ED = rD();
2467
+ var d = new Set(["\x1B", "\x9B"]);
2468
+ var oD = 39;
2469
+ var y = "\x07";
2470
+ var V = "[";
2471
+ var nD = "]";
2472
+ var G = "m";
2473
+ var _ = `${nD}8;;`;
2474
+ var z = (e) => `${d.values().next().value}${V}${e}${G}`;
2475
+ var K = (e) => `${d.values().next().value}${_}${e}${y}`;
2476
+ var aD = (e) => e.split(" ").map((u) => p(u));
2477
+ var k = (e, u, t) => {
2478
+ const F = [...u];
2479
+ let s = false, i = false, D = p(P(e[e.length - 1]));
2480
+ for (const [C, n] of F.entries()) {
2481
+ const E = p(n);
2482
+ if (D + E <= t ? e[e.length - 1] += n : (e.push(n), D = 0), d.has(n) && (s = true, i = F.slice(C + 1).join("").startsWith(_)), s) {
2483
+ i ? n === y && (s = false, i = false) : n === G && (s = false);
2484
+ continue;
2485
+ }
2486
+ D += E, D === t && C < F.length - 1 && (e.push(""), D = 0);
2487
+ }
2488
+ !D && e[e.length - 1].length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
2489
+ };
2490
+ var hD = (e) => {
2491
+ const u = e.split(" ");
2492
+ let t = u.length;
2493
+ for (;t > 0 && !(p(u[t - 1]) > 0); )
2494
+ t--;
2495
+ return t === u.length ? e : u.slice(0, t).join(" ") + u.slice(t).join("");
2496
+ };
2497
+ var lD = (e, u, t = {}) => {
2498
+ if (t.trim !== false && e.trim() === "")
2499
+ return "";
2500
+ let F = "", s, i;
2501
+ const D = aD(e);
2502
+ let C = [""];
2503
+ for (const [E, a] of e.split(" ").entries()) {
2504
+ t.trim !== false && (C[C.length - 1] = C[C.length - 1].trimStart());
2505
+ let o = p(C[C.length - 1]);
2506
+ if (E !== 0 && (o >= u && (t.wordWrap === false || t.trim === false) && (C.push(""), o = 0), (o > 0 || t.trim === false) && (C[C.length - 1] += " ", o++)), t.hard && D[E] > u) {
2507
+ const c = u - o, f = 1 + Math.floor((D[E] - c - 1) / u);
2508
+ Math.floor((D[E] - 1) / u) < f && C.push(""), k(C, a, u);
2509
+ continue;
2510
+ }
2511
+ if (o + D[E] > u && o > 0 && D[E] > 0) {
2512
+ if (t.wordWrap === false && o < u) {
2513
+ k(C, a, u);
2514
+ continue;
2515
+ }
2516
+ C.push("");
2517
+ }
2518
+ if (o + D[E] > u && t.wordWrap === false) {
2519
+ k(C, a, u);
2520
+ continue;
2521
+ }
2522
+ C[C.length - 1] += a;
2523
+ }
2524
+ t.trim !== false && (C = C.map((E) => hD(E)));
2525
+ const n = [...C.join(`
2526
+ `)];
2527
+ for (const [E, a] of n.entries()) {
2528
+ if (F += a, d.has(a)) {
2529
+ const { groups: c } = new RegExp(`(?:\\${V}(?<code>\\d+)m|\\${_}(?<uri>.*)${y})`).exec(n.slice(E).join("")) || { groups: {} };
2530
+ if (c.code !== undefined) {
2531
+ const f = Number.parseFloat(c.code);
2532
+ s = f === oD ? undefined : f;
2533
+ } else
2534
+ c.uri !== undefined && (i = c.uri.length === 0 ? undefined : c.uri);
2535
+ }
2536
+ const o = ED.codes.get(Number(s));
2537
+ n[E + 1] === `
2538
+ ` ? (i && (F += K("")), s && o && (F += z(o))) : a === `
2539
+ ` && (s && o && (F += z(s)), i && (F += K(i)));
2540
+ }
2541
+ return F;
2542
+ };
2543
+ function Y(e, u, t) {
2544
+ return String(e).normalize().replace(/\r\n/g, `
2545
+ `).split(`
2546
+ `).map((F) => lD(F, u, t)).join(`
2547
+ `);
2548
+ }
2549
+ var xD = ["up", "down", "left", "right", "space", "enter", "cancel"];
2550
+ var B = { actions: new Set(xD), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]) };
2551
+ function $(e, u) {
2552
+ if (typeof e == "string")
2553
+ return B.aliases.get(e) === u;
2554
+ for (const t of e)
2555
+ if (t !== undefined && $(t, u))
2556
+ return true;
2557
+ return false;
2558
+ }
2559
+ function BD(e, u) {
2560
+ if (e === u)
2561
+ return;
2562
+ const t = e.split(`
2563
+ `), F = u.split(`
2564
+ `), s = [];
2565
+ for (let i = 0;i < Math.max(t.length, F.length); i++)
2566
+ t[i] !== F[i] && s.push(i);
2567
+ return s;
2568
+ }
2569
+ var AD = globalThis.process.platform.startsWith("win");
2570
+ var S = Symbol("clack:cancel");
2571
+ function pD(e) {
2572
+ return e === S;
2573
+ }
2574
+ function m(e, u) {
2575
+ const t = e;
2576
+ t.isTTY && t.setRawMode(u);
2577
+ }
2578
+ function fD({ input: e = j, output: u = M, overwrite: t = true, hideCursor: F = true } = {}) {
2579
+ const s = g.createInterface({ input: e, output: u, prompt: "", tabSize: 1 });
2580
+ g.emitKeypressEvents(e, s), e.isTTY && e.setRawMode(true);
2581
+ const i = (D, { name: C, sequence: n }) => {
2582
+ const E = String(D);
2583
+ if ($([E, C, n], "cancel")) {
2584
+ F && u.write(import_sisteransi.cursor.show), process.exit(0);
2585
+ return;
2586
+ }
2587
+ if (!t)
2588
+ return;
2589
+ const a = C === "return" ? 0 : -1, o = C === "return" ? -1 : 0;
2590
+ g.moveCursor(u, a, o, () => {
2591
+ g.clearLine(u, 1, () => {
2592
+ e.once("keypress", i);
2593
+ });
2594
+ });
2595
+ };
2596
+ return F && u.write(import_sisteransi.cursor.hide), e.once("keypress", i), () => {
2597
+ e.off("keypress", i), F && u.write(import_sisteransi.cursor.show), e.isTTY && !AD && e.setRawMode(false), s.terminal = false, s.close();
2598
+ };
2599
+ }
2600
+ var gD = Object.defineProperty;
2601
+ var vD = (e, u, t) => (u in e) ? gD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t;
2602
+ var h = (e, u, t) => (vD(e, typeof u != "symbol" ? u + "" : u, t), t);
2603
+
2604
+ class x {
2605
+ constructor(u, t = true) {
2606
+ h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", new Map), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
2607
+ const { input: F = j, output: s = M, render: i, signal: D, ...C } = u;
2608
+ this.opts = C, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = t, this._abortSignal = D, this.input = F, this.output = s;
2609
+ }
2610
+ unsubscribe() {
2611
+ this._subscribers.clear();
2612
+ }
2613
+ setSubscriber(u, t) {
2614
+ const F = this._subscribers.get(u) ?? [];
2615
+ F.push(t), this._subscribers.set(u, F);
2616
+ }
2617
+ on(u, t) {
2618
+ this.setSubscriber(u, { cb: t });
2619
+ }
2620
+ once(u, t) {
2621
+ this.setSubscriber(u, { cb: t, once: true });
2622
+ }
2623
+ emit(u, ...t) {
2624
+ const F = this._subscribers.get(u) ?? [], s = [];
2625
+ for (const i of F)
2626
+ i.cb(...t), i.once && s.push(() => F.splice(F.indexOf(i), 1));
2627
+ for (const i of s)
2628
+ i();
2629
+ }
2630
+ prompt() {
2631
+ return new Promise((u, t) => {
2632
+ if (this._abortSignal) {
2633
+ if (this._abortSignal.aborted)
2634
+ return this.state = "cancel", this.close(), u(S);
2635
+ this._abortSignal.addEventListener("abort", () => {
2636
+ this.state = "cancel", this.close();
2637
+ }, { once: true });
2638
+ }
2639
+ const F = new X;
2640
+ F._write = (s, i, D) => {
2641
+ this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
2642
+ }, this.input.pipe(F), this.rl = O.createInterface({ input: this.input, output: F, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), O.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== undefined && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), m(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
2643
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u(this.value);
2644
+ }), this.once("cancel", () => {
2645
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u(S);
2646
+ });
2647
+ });
2648
+ }
2649
+ onKeypress(u, t) {
2650
+ if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.name)), u && (u.toLowerCase() === "y" || u.toLowerCase() === "n") && this.emit("confirm", u.toLowerCase() === "y"), u === "\t" && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u && this.emit("key", u.toLowerCase()), t?.name === "return") {
2651
+ if (this.opts.validate) {
2652
+ const F = this.opts.validate(this.value);
2653
+ F && (this.error = F instanceof Error ? F.message : F, this.state = "error", this.rl?.write(this.value));
2654
+ }
2655
+ this.state !== "error" && (this.state = "submit");
2656
+ }
2657
+ $([u, t?.name, t?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
2658
+ }
2659
+ close() {
2660
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
2661
+ `), m(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
2662
+ }
2663
+ restoreCursor() {
2664
+ const u = Y(this._prevFrame, process.stdout.columns, { hard: true }).split(`
2665
+ `).length - 1;
2666
+ this.output.write(import_sisteransi.cursor.move(-999, u * -1));
2667
+ }
2668
+ render() {
2669
+ const u = Y(this._render(this) ?? "", process.stdout.columns, { hard: true });
2670
+ if (u !== this._prevFrame) {
2671
+ if (this.state === "initial")
2672
+ this.output.write(import_sisteransi.cursor.hide);
2673
+ else {
2674
+ const t = BD(this._prevFrame, u);
2675
+ if (this.restoreCursor(), t && t?.length === 1) {
2676
+ const F = t[0];
2677
+ this.output.write(import_sisteransi.cursor.move(0, F)), this.output.write(import_sisteransi.erase.lines(1));
2678
+ const s = u.split(`
2679
+ `);
2680
+ this.output.write(s[F]), this._prevFrame = u, this.output.write(import_sisteransi.cursor.move(0, s.length - F - 1));
2681
+ return;
2682
+ }
2683
+ if (t && t?.length > 1) {
2684
+ const F = t[0];
2685
+ this.output.write(import_sisteransi.cursor.move(0, F)), this.output.write(import_sisteransi.erase.down());
2686
+ const s = u.split(`
2687
+ `).slice(F);
2688
+ this.output.write(s.join(`
2689
+ `)), this._prevFrame = u;
2690
+ return;
2691
+ }
2692
+ this.output.write(import_sisteransi.erase.down());
2693
+ }
2694
+ this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
2695
+ }
2696
+ }
2697
+ }
2698
+ var A;
2699
+ A = new WeakMap;
2700
+ var OD = Object.defineProperty;
2701
+ var PD = (e, u, t) => (u in e) ? OD(e, u, { enumerable: true, configurable: true, writable: true, value: t }) : e[u] = t;
2702
+ var J = (e, u, t) => (PD(e, typeof u != "symbol" ? u + "" : u, t), t);
2703
+
2704
+ class LD extends x {
2705
+ constructor(u) {
2706
+ super(u, false), J(this, "options"), J(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: t }) => t === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
2707
+ switch (t) {
2708
+ case "left":
2709
+ case "up":
2710
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
2711
+ break;
2712
+ case "down":
2713
+ case "right":
2714
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
2715
+ break;
2716
+ }
2717
+ this.changeValue();
2718
+ });
2719
+ }
2720
+ get _value() {
2721
+ return this.options[this.cursor];
2722
+ }
2723
+ changeValue() {
2724
+ this.value = this._value.value;
2725
+ }
2726
+ }
2727
+
2728
+ // node_modules/@clack/prompts/dist/index.mjs
2729
+ var import_picocolors = __toESM(require_picocolors(), 1);
2730
+ var import_sisteransi2 = __toESM(require_src(), 1);
2731
+ import y2 from "process";
2732
+ function ce() {
2733
+ return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2734
+ }
2735
+ var V2 = ce();
2736
+ var u = (t, n) => V2 ? t : n;
2737
+ var le = u("\u25C6", "*");
2738
+ var L2 = u("\u25A0", "x");
2739
+ var W2 = u("\u25B2", "x");
2740
+ var C = u("\u25C7", "o");
2741
+ var ue = u("\u250C", "T");
2742
+ var o = u("\u2502", "|");
2743
+ var d2 = u("\u2514", "\u2014");
2744
+ var k2 = u("\u25CF", ">");
2745
+ var P2 = u("\u25CB", " ");
2746
+ var A2 = u("\u25FB", "[\u2022]");
2747
+ var T = u("\u25FC", "[+]");
2748
+ var F = u("\u25FB", "[ ]");
2749
+ var $e = u("\u25AA", "\u2022");
2750
+ var _2 = u("\u2500", "-");
2751
+ var me = u("\u256E", "+");
2752
+ var de = u("\u251C", "+");
2753
+ var pe = u("\u256F", "+");
2754
+ var q = u("\u25CF", "\u2022");
2755
+ var D = u("\u25C6", "*");
2756
+ var U = u("\u25B2", "!");
2757
+ var K2 = u("\u25A0", "x");
2758
+ var b2 = (t) => {
2759
+ switch (t) {
2760
+ case "initial":
2761
+ case "active":
2762
+ return import_picocolors.default.cyan(le);
2763
+ case "cancel":
2764
+ return import_picocolors.default.red(L2);
2765
+ case "error":
2766
+ return import_picocolors.default.yellow(W2);
2767
+ case "submit":
2768
+ return import_picocolors.default.green(C);
2769
+ }
2770
+ };
2771
+ var G2 = (t) => {
2772
+ const { cursor: n, options: r2, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
2773
+ let l2 = 0;
2774
+ n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
2775
+ const $2 = a < r2.length && l2 > 0, g2 = a < r2.length && l2 + a < r2.length;
2776
+ return r2.slice(l2, l2 + a).map((p2, v, f) => {
2777
+ const j2 = v === 0 && $2, E = v === f.length - 1 && g2;
2778
+ return j2 || E ? import_picocolors.default.dim("...") : i(p2, v + l2 === n);
2779
+ });
2780
+ };
2781
+ var ve = (t) => {
2782
+ const n = (r2, i) => {
2783
+ const s = r2.label ?? String(r2.value);
2784
+ switch (i) {
2785
+ case "selected":
2786
+ return `${import_picocolors.default.dim(s)}`;
2787
+ case "active":
2788
+ return `${import_picocolors.default.green(k2)} ${s} ${r2.hint ? import_picocolors.default.dim(`(${r2.hint})`) : ""}`;
2789
+ case "cancelled":
2790
+ return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
2791
+ default:
2792
+ return `${import_picocolors.default.dim(P2)} ${import_picocolors.default.dim(s)}`;
2793
+ }
2794
+ };
2795
+ return new LD({ options: t.options, initialValue: t.initialValue, render() {
2796
+ const r2 = `${import_picocolors.default.gray(o)}
2797
+ ${b2(this.state)} ${t.message}
2798
+ `;
2799
+ switch (this.state) {
2800
+ case "submit":
2801
+ return `${r2}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
2802
+ case "cancel":
2803
+ return `${r2}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
2804
+ ${import_picocolors.default.gray(o)}`;
2805
+ default:
2806
+ return `${r2}${import_picocolors.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
2807
+ ${import_picocolors.default.cyan(o)} `)}
2808
+ ${import_picocolors.default.cyan(d2)}
2809
+ `;
2810
+ }
2811
+ } }).prompt();
2812
+ };
2813
+ var Me = (t = "", n = "") => {
2814
+ const r2 = `
2815
+ ${t}
2816
+ `.split(`
2817
+ `), i = S2(n).length, s = Math.max(r2.reduce((a, l2) => {
2818
+ const $2 = S2(l2);
2819
+ return $2.length > a ? $2.length : a;
2820
+ }, 0), i) + 2, c = r2.map((a) => `${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(a)}${" ".repeat(s - S2(a).length)}${import_picocolors.default.gray(o)}`).join(`
2821
+ `);
2822
+ process.stdout.write(`${import_picocolors.default.gray(o)}
2823
+ ${import_picocolors.default.green(C)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(_2.repeat(Math.max(s - i - 1, 1)) + me)}
2824
+ ${c}
2825
+ ${import_picocolors.default.gray(de + _2.repeat(s + 2) + pe)}
2826
+ `);
2827
+ };
2828
+ var xe = (t = "") => {
2829
+ process.stdout.write(`${import_picocolors.default.gray(d2)} ${import_picocolors.default.red(t)}
2830
+
2831
+ `);
2832
+ };
2833
+ var Ie = (t = "") => {
2834
+ process.stdout.write(`${import_picocolors.default.gray(ue)} ${t}
2835
+ `);
2836
+ };
2837
+ var Se = (t = "") => {
2838
+ process.stdout.write(`${import_picocolors.default.gray(o)}
2839
+ ${import_picocolors.default.gray(d2)} ${t}
2840
+
2841
+ `);
2842
+ };
2843
+ var M2 = { message: (t = "", { symbol: n = import_picocolors.default.gray(o) } = {}) => {
2844
+ const r2 = [`${import_picocolors.default.gray(o)}`];
2845
+ if (t) {
2846
+ const [i, ...s] = t.split(`
2847
+ `);
2848
+ r2.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors.default.gray(o)} ${c}`));
2849
+ }
2850
+ process.stdout.write(`${r2.join(`
2851
+ `)}
2852
+ `);
2853
+ }, info: (t) => {
2854
+ M2.message(t, { symbol: import_picocolors.default.blue(q) });
2855
+ }, success: (t) => {
2856
+ M2.message(t, { symbol: import_picocolors.default.green(D) });
2857
+ }, step: (t) => {
2858
+ M2.message(t, { symbol: import_picocolors.default.green(C) });
2859
+ }, warn: (t) => {
2860
+ M2.message(t, { symbol: import_picocolors.default.yellow(U) });
2861
+ }, warning: (t) => {
2862
+ M2.warn(t);
2863
+ }, error: (t) => {
2864
+ M2.message(t, { symbol: import_picocolors.default.red(K2) });
2865
+ } };
2866
+ var J2 = `${import_picocolors.default.gray(o)} `;
2867
+ var Y2 = ({ indicator: t = "dots" } = {}) => {
2868
+ const n = V2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], r2 = V2 ? 80 : 120, i = process.env.CI === "true";
2869
+ let s, c, a = false, l2 = "", $2, g2 = performance.now();
2870
+ const p2 = (m2) => {
2871
+ const h2 = m2 > 1 ? "Something went wrong" : "Canceled";
2872
+ a && N2(h2, m2);
2873
+ }, v = () => p2(2), f = () => p2(1), j2 = () => {
2874
+ process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p2);
2875
+ }, E = () => {
2876
+ process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p2);
2877
+ }, B2 = () => {
2878
+ if ($2 === undefined)
2879
+ return;
2880
+ i && process.stdout.write(`
2881
+ `);
2882
+ const m2 = $2.split(`
2883
+ `);
2884
+ process.stdout.write(import_sisteransi2.cursor.move(-999, m2.length - 1)), process.stdout.write(import_sisteransi2.erase.down(m2.length));
2885
+ }, R2 = (m2) => m2.replace(/\.+$/, ""), O2 = (m2) => {
2886
+ const h2 = (performance.now() - m2) / 1000, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
2887
+ return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
2888
+ }, H = (m2 = "") => {
2889
+ a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
2890
+ `);
2891
+ let h2 = 0, w2 = 0;
2892
+ j2(), c = setInterval(() => {
2893
+ if (i && l2 === $2)
2894
+ return;
2895
+ B2(), $2 = l2;
2896
+ const I2 = import_picocolors.default.magenta(n[h2]);
2897
+ if (i)
2898
+ process.stdout.write(`${I2} ${l2}...`);
2899
+ else if (t === "timer")
2900
+ process.stdout.write(`${I2} ${l2} ${O2(g2)}`);
2901
+ else {
2902
+ const z2 = ".".repeat(Math.floor(w2)).slice(0, 3);
2903
+ process.stdout.write(`${I2} ${l2}${z2}`);
2904
+ }
2905
+ h2 = h2 + 1 < n.length ? h2 + 1 : 0, w2 = w2 < n.length ? w2 + 0.125 : 0;
2906
+ }, r2);
2907
+ }, N2 = (m2 = "", h2 = 0) => {
2908
+ a = false, clearInterval(c), B2();
2909
+ const w2 = h2 === 0 ? import_picocolors.default.green(C) : h2 === 1 ? import_picocolors.default.red(L2) : import_picocolors.default.red(W2);
2910
+ l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
2911
+ `) : process.stdout.write(`${w2} ${l2}
2912
+ `), E(), s();
2913
+ };
2914
+ return { start: H, stop: N2, message: (m2 = "") => {
2915
+ l2 = R2(m2 ?? l2);
2916
+ } };
2917
+ };
2918
+
2919
+ // src/cli/install.ts
2920
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
2921
+
2922
+ // src/cli/config-manager.ts
2923
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
2924
+ import { homedir } from "os";
2925
+ import { join } from "path";
2926
+ var OPENCODE_CONFIG_DIR = join(homedir(), ".config", "opencode");
2927
+ var OPENCODE_JSON = join(OPENCODE_CONFIG_DIR, "opencode.json");
2928
+ var OPENCODE_JSONC = join(OPENCODE_CONFIG_DIR, "opencode.jsonc");
2929
+ var OPENCODE_PACKAGE_JSON = join(OPENCODE_CONFIG_DIR, "package.json");
2930
+ var OMO_CONFIG = join(OPENCODE_CONFIG_DIR, "oh-my-opencode.json");
2931
+ var CHATGPT_HOTFIX_REPO = "code-yeongyu/opencode-openai-codex-auth#fix/orphaned-function-call-output-with-tools";
2932
+ async function fetchLatestVersion(packageName) {
2933
+ try {
2934
+ const res = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
2935
+ if (!res.ok)
2936
+ return null;
2937
+ const data = await res.json();
2938
+ return data.version;
2939
+ } catch {
2940
+ return null;
2941
+ }
2942
+ }
2943
+ function detectConfigFormat() {
2944
+ if (existsSync(OPENCODE_JSONC)) {
2945
+ return { format: "jsonc", path: OPENCODE_JSONC };
2946
+ }
2947
+ if (existsSync(OPENCODE_JSON)) {
2948
+ return { format: "json", path: OPENCODE_JSON };
2949
+ }
2950
+ return { format: "none", path: OPENCODE_JSON };
2951
+ }
2952
+ function stripJsoncComments(content) {
2953
+ let result = "";
2954
+ let i = 0;
2955
+ let inString = false;
2956
+ let escape = false;
2957
+ while (i < content.length) {
2958
+ const char = content[i];
2959
+ if (escape) {
2960
+ result += char;
2961
+ escape = false;
2962
+ i++;
2963
+ continue;
2964
+ }
2965
+ if (char === "\\") {
2966
+ result += char;
2967
+ escape = true;
2968
+ i++;
2969
+ continue;
2970
+ }
2971
+ if (char === '"' && !inString) {
2972
+ inString = true;
2973
+ result += char;
2974
+ i++;
2975
+ continue;
2976
+ }
2977
+ if (char === '"' && inString) {
2978
+ inString = false;
2979
+ result += char;
2980
+ i++;
2981
+ continue;
2982
+ }
2983
+ if (inString) {
2984
+ result += char;
2985
+ i++;
2986
+ continue;
2987
+ }
2988
+ if (char === "/" && content[i + 1] === "/") {
2989
+ while (i < content.length && content[i] !== `
2990
+ `) {
2991
+ i++;
2992
+ }
2993
+ continue;
2994
+ }
2995
+ if (char === "/" && content[i + 1] === "*") {
2996
+ i += 2;
2997
+ while (i < content.length - 1 && !(content[i] === "*" && content[i + 1] === "/")) {
2998
+ i++;
2999
+ }
3000
+ i += 2;
3001
+ continue;
3002
+ }
3003
+ result += char;
3004
+ i++;
3005
+ }
3006
+ return result.replace(/,(\s*[}\]])/g, "$1");
3007
+ }
3008
+ function parseConfig(path, isJsonc) {
3009
+ try {
3010
+ const content = readFileSync(path, "utf-8");
3011
+ const cleaned = isJsonc ? stripJsoncComments(content) : content;
3012
+ return JSON.parse(cleaned);
3013
+ } catch {
3014
+ return null;
3015
+ }
3016
+ }
3017
+ function ensureConfigDir() {
3018
+ if (!existsSync(OPENCODE_CONFIG_DIR)) {
3019
+ mkdirSync(OPENCODE_CONFIG_DIR, { recursive: true });
3020
+ }
3021
+ }
3022
+ function addPluginToOpenCodeConfig() {
3023
+ ensureConfigDir();
3024
+ const { format, path } = detectConfigFormat();
3025
+ const pluginName = "oh-my-opencode";
3026
+ try {
3027
+ if (format === "none") {
3028
+ const config2 = { plugin: [pluginName] };
3029
+ writeFileSync(path, JSON.stringify(config2, null, 2) + `
3030
+ `);
3031
+ return { success: true, configPath: path };
3032
+ }
3033
+ const config = parseConfig(path, format === "jsonc");
3034
+ if (!config) {
3035
+ return { success: false, configPath: path, error: "Failed to parse config" };
3036
+ }
3037
+ const plugins = config.plugin ?? [];
3038
+ if (plugins.some((p2) => p2.startsWith(pluginName))) {
3039
+ return { success: true, configPath: path };
3040
+ }
3041
+ config.plugin = [...plugins, pluginName];
3042
+ if (format === "jsonc") {
3043
+ const content = readFileSync(path, "utf-8");
3044
+ const pluginArrayRegex = /"plugin"\s*:\s*\[([\s\S]*?)\]/;
3045
+ const match = content.match(pluginArrayRegex);
3046
+ if (match) {
3047
+ const arrayContent = match[1].trim();
3048
+ const newArrayContent = arrayContent ? `${arrayContent},
3049
+ "${pluginName}"` : `"${pluginName}"`;
3050
+ const newContent = content.replace(pluginArrayRegex, `"plugin": [
3051
+ ${newArrayContent}
3052
+ ]`);
3053
+ writeFileSync(path, newContent);
3054
+ } else {
3055
+ const newContent = content.replace(/^(\s*\{)/, `$1
3056
+ "plugin": ["${pluginName}"],`);
3057
+ writeFileSync(path, newContent);
3058
+ }
3059
+ } else {
3060
+ writeFileSync(path, JSON.stringify(config, null, 2) + `
3061
+ `);
3062
+ }
3063
+ return { success: true, configPath: path };
3064
+ } catch (err) {
3065
+ return { success: false, configPath: path, error: String(err) };
3066
+ }
3067
+ }
3068
+ function deepMerge(target, source) {
3069
+ const result = { ...target };
3070
+ for (const key of Object.keys(source)) {
3071
+ const sourceValue = source[key];
3072
+ const targetValue = result[key];
3073
+ if (sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) && targetValue !== null && typeof targetValue === "object" && !Array.isArray(targetValue)) {
3074
+ result[key] = deepMerge(targetValue, sourceValue);
3075
+ } else if (sourceValue !== undefined) {
3076
+ result[key] = sourceValue;
3077
+ }
3078
+ }
3079
+ return result;
3080
+ }
3081
+ function generateOmoConfig(installConfig) {
3082
+ const config = {
3083
+ $schema: "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json"
3084
+ };
3085
+ if (installConfig.hasGemini) {
3086
+ config.google_auth = false;
3087
+ }
3088
+ const agents = {};
3089
+ if (!installConfig.hasClaude) {
3090
+ agents["Sisyphus"] = { model: "opencode/big-pickle" };
3091
+ agents["librarian"] = { model: "opencode/big-pickle" };
3092
+ } else if (!installConfig.isMax20) {
3093
+ agents["librarian"] = { model: "opencode/big-pickle" };
3094
+ }
3095
+ if (!installConfig.hasChatGPT) {
3096
+ agents["oracle"] = {
3097
+ model: installConfig.hasClaude ? "anthropic/claude-opus-4-5" : "opencode/big-pickle"
3098
+ };
3099
+ }
3100
+ if (installConfig.hasGemini) {
3101
+ agents["frontend-ui-ux-engineer"] = { model: "google/gemini-3-pro-high" };
3102
+ agents["document-writer"] = { model: "google/gemini-3-flash" };
3103
+ agents["multimodal-looker"] = { model: "google/gemini-3-flash" };
3104
+ } else {
3105
+ const fallbackModel = installConfig.hasClaude ? "anthropic/claude-opus-4-5" : "opencode/big-pickle";
3106
+ agents["frontend-ui-ux-engineer"] = { model: fallbackModel };
3107
+ agents["document-writer"] = { model: fallbackModel };
3108
+ agents["multimodal-looker"] = { model: fallbackModel };
3109
+ }
3110
+ if (Object.keys(agents).length > 0) {
3111
+ config.agents = agents;
3112
+ }
3113
+ return config;
3114
+ }
3115
+ function writeOmoConfig(installConfig) {
3116
+ ensureConfigDir();
3117
+ try {
3118
+ const newConfig = generateOmoConfig(installConfig);
3119
+ if (existsSync(OMO_CONFIG)) {
3120
+ const content = readFileSync(OMO_CONFIG, "utf-8");
3121
+ const cleaned = stripJsoncComments(content);
3122
+ const existing = JSON.parse(cleaned);
3123
+ delete existing.agents;
3124
+ const merged = deepMerge(existing, newConfig);
3125
+ writeFileSync(OMO_CONFIG, JSON.stringify(merged, null, 2) + `
3126
+ `);
3127
+ } else {
3128
+ writeFileSync(OMO_CONFIG, JSON.stringify(newConfig, null, 2) + `
3129
+ `);
3130
+ }
3131
+ return { success: true, configPath: OMO_CONFIG };
3132
+ } catch (err) {
3133
+ return { success: false, configPath: OMO_CONFIG, error: String(err) };
3134
+ }
3135
+ }
3136
+ async function isOpenCodeInstalled() {
3137
+ try {
3138
+ const proc = Bun.spawn(["opencode", "--version"], {
3139
+ stdout: "pipe",
3140
+ stderr: "pipe"
3141
+ });
3142
+ await proc.exited;
3143
+ return proc.exitCode === 0;
3144
+ } catch {
3145
+ return false;
3146
+ }
3147
+ }
3148
+ async function getOpenCodeVersion() {
3149
+ try {
3150
+ const proc = Bun.spawn(["opencode", "--version"], {
3151
+ stdout: "pipe",
3152
+ stderr: "pipe"
3153
+ });
3154
+ const output = await new Response(proc.stdout).text();
3155
+ await proc.exited;
3156
+ return proc.exitCode === 0 ? output.trim() : null;
3157
+ } catch {
3158
+ return null;
3159
+ }
3160
+ }
3161
+ async function addAuthPlugins(config) {
3162
+ ensureConfigDir();
3163
+ const { format, path } = detectConfigFormat();
3164
+ try {
3165
+ const existingConfig = format !== "none" ? parseConfig(path, format === "jsonc") : null;
3166
+ const plugins = existingConfig?.plugin ?? [];
3167
+ if (config.hasGemini) {
3168
+ const version = await fetchLatestVersion("opencode-antigravity-auth");
3169
+ const pluginEntry = version ? `opencode-antigravity-auth@${version}` : "opencode-antigravity-auth";
3170
+ if (!plugins.some((p2) => p2.startsWith("opencode-antigravity-auth"))) {
3171
+ plugins.push(pluginEntry);
3172
+ }
3173
+ }
3174
+ if (config.hasChatGPT) {
3175
+ if (!plugins.some((p2) => p2.startsWith("opencode-openai-codex-auth"))) {
3176
+ plugins.push("opencode-openai-codex-auth");
3177
+ }
3178
+ }
3179
+ const newConfig = { ...existingConfig ?? {}, plugin: plugins };
3180
+ writeFileSync(path, JSON.stringify(newConfig, null, 2) + `
3181
+ `);
3182
+ return { success: true, configPath: path };
3183
+ } catch (err) {
3184
+ return { success: false, configPath: path, error: String(err) };
3185
+ }
3186
+ }
3187
+ function setupChatGPTHotfix() {
3188
+ ensureConfigDir();
3189
+ try {
3190
+ let packageJson = {};
3191
+ if (existsSync(OPENCODE_PACKAGE_JSON)) {
3192
+ const content = readFileSync(OPENCODE_PACKAGE_JSON, "utf-8");
3193
+ packageJson = JSON.parse(content);
3194
+ }
3195
+ const deps = packageJson.dependencies ?? {};
3196
+ deps["opencode-openai-codex-auth"] = CHATGPT_HOTFIX_REPO;
3197
+ packageJson.dependencies = deps;
3198
+ writeFileSync(OPENCODE_PACKAGE_JSON, JSON.stringify(packageJson, null, 2) + `
3199
+ `);
3200
+ return { success: true, configPath: OPENCODE_PACKAGE_JSON };
3201
+ } catch (err) {
3202
+ return { success: false, configPath: OPENCODE_PACKAGE_JSON, error: String(err) };
3203
+ }
3204
+ }
3205
+ async function runBunInstall() {
3206
+ try {
3207
+ const proc = Bun.spawn(["bun", "install"], {
3208
+ cwd: OPENCODE_CONFIG_DIR,
3209
+ stdout: "pipe",
3210
+ stderr: "pipe"
3211
+ });
3212
+ await proc.exited;
3213
+ return proc.exitCode === 0;
3214
+ } catch {
3215
+ return false;
3216
+ }
3217
+ }
3218
+ var ANTIGRAVITY_PROVIDER_CONFIG = {
3219
+ google: {
3220
+ name: "Google",
3221
+ api: "antigravity",
3222
+ models: {
3223
+ "gemini-3-pro-high": {
3224
+ name: "Gemini 3 Pro High (Antigravity)",
3225
+ thinking: true,
3226
+ attachment: true,
3227
+ limit: { context: 1048576, output: 65535 },
3228
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] }
3229
+ },
3230
+ "gemini-3-pro-medium": {
3231
+ name: "Gemini 3 Pro Medium (Antigravity)",
3232
+ thinking: true,
3233
+ attachment: true,
3234
+ limit: { context: 1048576, output: 65535 },
3235
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] }
3236
+ },
3237
+ "gemini-3-pro-low": {
3238
+ name: "Gemini 3 Pro Low (Antigravity)",
3239
+ thinking: true,
3240
+ attachment: true,
3241
+ limit: { context: 1048576, output: 65535 },
3242
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] }
3243
+ },
3244
+ "gemini-3-flash": {
3245
+ name: "Gemini 3 Flash (Antigravity)",
3246
+ attachment: true,
3247
+ limit: { context: 1048576, output: 65536 },
3248
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] }
3249
+ },
3250
+ "gemini-3-flash-lite": {
3251
+ name: "Gemini 3 Flash Lite (Antigravity)",
3252
+ attachment: true,
3253
+ limit: { context: 1048576, output: 65536 },
3254
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] }
3255
+ }
3256
+ }
3257
+ }
3258
+ };
3259
+ var CODEX_PROVIDER_CONFIG = {
3260
+ openai: {
3261
+ name: "OpenAI",
3262
+ api: "codex",
3263
+ models: {
3264
+ "gpt-5.2": { name: "GPT-5.2" },
3265
+ o3: { name: "o3", thinking: true },
3266
+ "o4-mini": { name: "o4-mini", thinking: true },
3267
+ "codex-1": { name: "Codex-1" }
3268
+ }
3269
+ }
3270
+ };
3271
+ function addProviderConfig(config) {
3272
+ ensureConfigDir();
3273
+ const { format, path } = detectConfigFormat();
3274
+ try {
3275
+ const existingConfig = format !== "none" ? parseConfig(path, format === "jsonc") : null;
3276
+ const newConfig = { ...existingConfig ?? {} };
3277
+ const providers = newConfig.provider ?? {};
3278
+ if (config.hasGemini) {
3279
+ providers.google = ANTIGRAVITY_PROVIDER_CONFIG.google;
3280
+ }
3281
+ if (config.hasChatGPT) {
3282
+ providers.openai = CODEX_PROVIDER_CONFIG.openai;
3283
+ }
3284
+ if (Object.keys(providers).length > 0) {
3285
+ newConfig.provider = providers;
3286
+ }
3287
+ writeFileSync(path, JSON.stringify(newConfig, null, 2) + `
3288
+ `);
3289
+ return { success: true, configPath: path };
3290
+ } catch (err) {
3291
+ return { success: false, configPath: path, error: String(err) };
3292
+ }
3293
+ }
3294
+ function detectCurrentConfig() {
3295
+ const result = {
3296
+ isInstalled: false,
3297
+ hasClaude: true,
3298
+ isMax20: true,
3299
+ hasChatGPT: true,
3300
+ hasGemini: false
3301
+ };
3302
+ const { format, path } = detectConfigFormat();
3303
+ if (format === "none") {
3304
+ return result;
3305
+ }
3306
+ const openCodeConfig = parseConfig(path, format === "jsonc");
3307
+ if (!openCodeConfig) {
3308
+ return result;
3309
+ }
3310
+ const plugins = openCodeConfig.plugin ?? [];
3311
+ result.isInstalled = plugins.some((p2) => p2.startsWith("oh-my-opencode"));
3312
+ if (!result.isInstalled) {
3313
+ return result;
3314
+ }
3315
+ result.hasGemini = plugins.some((p2) => p2.startsWith("opencode-antigravity-auth"));
3316
+ result.hasChatGPT = plugins.some((p2) => p2.startsWith("opencode-openai-codex-auth"));
3317
+ if (!existsSync(OMO_CONFIG)) {
3318
+ return result;
3319
+ }
3320
+ try {
3321
+ const content = readFileSync(OMO_CONFIG, "utf-8");
3322
+ const omoConfig = JSON.parse(stripJsoncComments(content));
3323
+ const agents = omoConfig.agents ?? {};
3324
+ if (agents["Sisyphus"]?.model === "opencode/big-pickle") {
3325
+ result.hasClaude = false;
3326
+ result.isMax20 = false;
3327
+ } else if (agents["librarian"]?.model === "opencode/big-pickle") {
3328
+ result.hasClaude = true;
3329
+ result.isMax20 = false;
3330
+ }
3331
+ if (agents["oracle"]?.model?.startsWith("anthropic/")) {
3332
+ result.hasChatGPT = false;
3333
+ } else if (agents["oracle"]?.model === "opencode/big-pickle") {
3334
+ result.hasChatGPT = false;
3335
+ }
3336
+ if (omoConfig.google_auth === false) {
3337
+ result.hasGemini = plugins.some((p2) => p2.startsWith("opencode-antigravity-auth"));
3338
+ }
3339
+ } catch {}
3340
+ return result;
3341
+ }
3342
+
3343
+ // src/cli/install.ts
3344
+ var SYMBOLS = {
3345
+ check: import_picocolors2.default.green("\u2713"),
3346
+ cross: import_picocolors2.default.red("\u2717"),
3347
+ arrow: import_picocolors2.default.cyan("\u2192"),
3348
+ bullet: import_picocolors2.default.dim("\u2022"),
3349
+ info: import_picocolors2.default.blue("\u2139"),
3350
+ warn: import_picocolors2.default.yellow("\u26A0"),
3351
+ star: import_picocolors2.default.yellow("\u2605")
3352
+ };
3353
+ function formatProvider(name, enabled, detail) {
3354
+ const status = enabled ? SYMBOLS.check : import_picocolors2.default.dim("\u25CB");
3355
+ const label = enabled ? import_picocolors2.default.white(name) : import_picocolors2.default.dim(name);
3356
+ const suffix = detail ? import_picocolors2.default.dim(` (${detail})`) : "";
3357
+ return ` ${status} ${label}${suffix}`;
3358
+ }
3359
+ function formatConfigSummary(config) {
3360
+ const lines = [];
3361
+ lines.push(import_picocolors2.default.bold(import_picocolors2.default.white("Configuration Summary")));
3362
+ lines.push("");
3363
+ const claudeDetail = config.hasClaude ? config.isMax20 ? "max20" : "standard" : undefined;
3364
+ lines.push(formatProvider("Claude", config.hasClaude, claudeDetail));
3365
+ lines.push(formatProvider("ChatGPT", config.hasChatGPT));
3366
+ lines.push(formatProvider("Gemini", config.hasGemini));
3367
+ lines.push("");
3368
+ lines.push(import_picocolors2.default.dim("\u2500".repeat(40)));
3369
+ lines.push("");
3370
+ lines.push(import_picocolors2.default.bold(import_picocolors2.default.white("Agent Configuration")));
3371
+ lines.push("");
3372
+ const sisyphusModel = config.hasClaude ? "claude-opus-4-5" : "big-pickle";
3373
+ const oracleModel = config.hasChatGPT ? "gpt-5.2" : config.hasClaude ? "claude-opus-4-5" : "big-pickle";
3374
+ const librarianModel = config.hasClaude && config.isMax20 ? "claude-sonnet-4-5" : "big-pickle";
3375
+ const frontendModel = config.hasGemini ? "gemini-3-pro-high" : config.hasClaude ? "claude-opus-4-5" : "big-pickle";
3376
+ lines.push(` ${SYMBOLS.bullet} Sisyphus ${SYMBOLS.arrow} ${import_picocolors2.default.cyan(sisyphusModel)}`);
3377
+ lines.push(` ${SYMBOLS.bullet} Oracle ${SYMBOLS.arrow} ${import_picocolors2.default.cyan(oracleModel)}`);
3378
+ lines.push(` ${SYMBOLS.bullet} Librarian ${SYMBOLS.arrow} ${import_picocolors2.default.cyan(librarianModel)}`);
3379
+ lines.push(` ${SYMBOLS.bullet} Frontend ${SYMBOLS.arrow} ${import_picocolors2.default.cyan(frontendModel)}`);
3380
+ return lines.join(`
3381
+ `);
3382
+ }
3383
+ function printHeader(isUpdate) {
3384
+ const mode = isUpdate ? "Update" : "Install";
3385
+ console.log();
3386
+ console.log(import_picocolors2.default.bgMagenta(import_picocolors2.default.white(` oMoMoMoMo... ${mode} `)));
3387
+ console.log();
3388
+ }
3389
+ function printStep(step, total, message) {
3390
+ const progress = import_picocolors2.default.dim(`[${step}/${total}]`);
3391
+ console.log(`${progress} ${message}`);
3392
+ }
3393
+ function printSuccess(message) {
3394
+ console.log(`${SYMBOLS.check} ${message}`);
3395
+ }
3396
+ function printError(message) {
3397
+ console.log(`${SYMBOLS.cross} ${import_picocolors2.default.red(message)}`);
3398
+ }
3399
+ function printInfo(message) {
3400
+ console.log(`${SYMBOLS.info} ${message}`);
3401
+ }
3402
+ function printWarning(message) {
3403
+ console.log(`${SYMBOLS.warn} ${import_picocolors2.default.yellow(message)}`);
3404
+ }
3405
+ function printBox(content, title) {
3406
+ const lines = content.split(`
3407
+ `);
3408
+ const maxWidth = Math.max(...lines.map((l2) => l2.replace(/\x1b\[[0-9;]*m/g, "").length), title?.length ?? 0) + 4;
3409
+ const border = import_picocolors2.default.dim("\u2500".repeat(maxWidth));
3410
+ console.log();
3411
+ if (title) {
3412
+ console.log(import_picocolors2.default.dim("\u250C\u2500") + import_picocolors2.default.bold(` ${title} `) + import_picocolors2.default.dim("\u2500".repeat(maxWidth - title.length - 4)) + import_picocolors2.default.dim("\u2510"));
3413
+ } else {
3414
+ console.log(import_picocolors2.default.dim("\u250C") + border + import_picocolors2.default.dim("\u2510"));
3415
+ }
3416
+ for (const line of lines) {
3417
+ const stripped = line.replace(/\x1b\[[0-9;]*m/g, "");
3418
+ const padding = maxWidth - stripped.length;
3419
+ console.log(import_picocolors2.default.dim("\u2502") + ` ${line}${" ".repeat(padding - 1)}` + import_picocolors2.default.dim("\u2502"));
3420
+ }
3421
+ console.log(import_picocolors2.default.dim("\u2514") + border + import_picocolors2.default.dim("\u2518"));
3422
+ console.log();
3423
+ }
3424
+ function validateNonTuiArgs(args) {
3425
+ const errors = [];
3426
+ if (args.claude === undefined) {
3427
+ errors.push("--claude is required (values: no, yes, max20)");
3428
+ } else if (!["no", "yes", "max20"].includes(args.claude)) {
3429
+ errors.push(`Invalid --claude value: ${args.claude} (expected: no, yes, max20)`);
3430
+ }
3431
+ if (args.chatgpt === undefined) {
3432
+ errors.push("--chatgpt is required (values: no, yes)");
3433
+ } else if (!["no", "yes"].includes(args.chatgpt)) {
3434
+ errors.push(`Invalid --chatgpt value: ${args.chatgpt} (expected: no, yes)`);
3435
+ }
3436
+ if (args.gemini === undefined) {
3437
+ errors.push("--gemini is required (values: no, yes)");
3438
+ } else if (!["no", "yes"].includes(args.gemini)) {
3439
+ errors.push(`Invalid --gemini value: ${args.gemini} (expected: no, yes)`);
3440
+ }
3441
+ return { valid: errors.length === 0, errors };
3442
+ }
3443
+ function argsToConfig(args) {
3444
+ return {
3445
+ hasClaude: args.claude !== "no",
3446
+ isMax20: args.claude === "max20",
3447
+ hasChatGPT: args.chatgpt === "yes",
3448
+ hasGemini: args.gemini === "yes"
3449
+ };
3450
+ }
3451
+ function detectedToInitialValues(detected) {
3452
+ let claude = "no";
3453
+ if (detected.hasClaude) {
3454
+ claude = detected.isMax20 ? "max20" : "yes";
3455
+ }
3456
+ return {
3457
+ claude,
3458
+ chatgpt: detected.hasChatGPT ? "yes" : "no",
3459
+ gemini: detected.hasGemini ? "yes" : "no"
3460
+ };
3461
+ }
3462
+ async function runTuiMode(detected) {
3463
+ const initial = detectedToInitialValues(detected);
3464
+ const claude = await ve({
3465
+ message: "Do you have a Claude Pro/Max subscription?",
3466
+ options: [
3467
+ { value: "no", label: "No", hint: "Will use opencode/big-pickle as fallback" },
3468
+ { value: "yes", label: "Yes (standard)", hint: "Claude Opus 4.5 for orchestration" },
3469
+ { value: "max20", label: "Yes (max20 mode)", hint: "Full power with Claude Sonnet 4.5 for Librarian" }
3470
+ ],
3471
+ initialValue: initial.claude
3472
+ });
3473
+ if (pD(claude)) {
3474
+ xe("Installation cancelled.");
3475
+ return null;
3476
+ }
3477
+ const chatgpt = await ve({
3478
+ message: "Do you have a ChatGPT Plus/Pro subscription?",
3479
+ options: [
3480
+ { value: "no", label: "No", hint: "Oracle will use fallback model" },
3481
+ { value: "yes", label: "Yes", hint: "GPT-5.2 for debugging and architecture" }
3482
+ ],
3483
+ initialValue: initial.chatgpt
3484
+ });
3485
+ if (pD(chatgpt)) {
3486
+ xe("Installation cancelled.");
3487
+ return null;
3488
+ }
3489
+ const gemini = await ve({
3490
+ message: "Will you integrate Google Gemini?",
3491
+ options: [
3492
+ { value: "no", label: "No", hint: "Frontend/docs agents will use fallback" },
3493
+ { value: "yes", label: "Yes", hint: "Beautiful UI generation with Gemini 3 Pro" }
3494
+ ],
3495
+ initialValue: initial.gemini
3496
+ });
3497
+ if (pD(gemini)) {
3498
+ xe("Installation cancelled.");
3499
+ return null;
3500
+ }
3501
+ return {
3502
+ hasClaude: claude !== "no",
3503
+ isMax20: claude === "max20",
3504
+ hasChatGPT: chatgpt === "yes",
3505
+ hasGemini: gemini === "yes"
3506
+ };
3507
+ }
3508
+ async function runNonTuiInstall(args) {
3509
+ const validation = validateNonTuiArgs(args);
3510
+ if (!validation.valid) {
3511
+ printHeader(false);
3512
+ printError("Validation failed:");
3513
+ for (const err of validation.errors) {
3514
+ console.log(` ${SYMBOLS.bullet} ${err}`);
3515
+ }
3516
+ console.log();
3517
+ printInfo("Usage: bunx oh-my-opencode install --no-tui --claude=<no|yes|max20> --chatgpt=<no|yes> --gemini=<no|yes>");
3518
+ console.log();
3519
+ return 1;
3520
+ }
3521
+ const detected = detectCurrentConfig();
3522
+ const isUpdate = detected.isInstalled;
3523
+ printHeader(isUpdate);
3524
+ const totalSteps = 6;
3525
+ let step = 1;
3526
+ printStep(step++, totalSteps, "Checking OpenCode installation...");
3527
+ const installed = await isOpenCodeInstalled();
3528
+ if (!installed) {
3529
+ printError("OpenCode is not installed on this system.");
3530
+ printInfo("Visit https://opencode.ai/docs for installation instructions");
3531
+ return 1;
3532
+ }
3533
+ const version = await getOpenCodeVersion();
3534
+ printSuccess(`OpenCode ${version ?? ""} detected`);
3535
+ if (isUpdate) {
3536
+ const initial = detectedToInitialValues(detected);
3537
+ printInfo(`Current config: Claude=${initial.claude}, ChatGPT=${initial.chatgpt}, Gemini=${initial.gemini}`);
3538
+ }
3539
+ const config = argsToConfig(args);
3540
+ printStep(step++, totalSteps, "Adding oh-my-opencode plugin...");
3541
+ const pluginResult = addPluginToOpenCodeConfig();
3542
+ if (!pluginResult.success) {
3543
+ printError(`Failed: ${pluginResult.error}`);
3544
+ return 1;
3545
+ }
3546
+ printSuccess(`Plugin ${isUpdate ? "verified" : "added"} ${SYMBOLS.arrow} ${import_picocolors2.default.dim(pluginResult.configPath)}`);
3547
+ if (config.hasGemini || config.hasChatGPT) {
3548
+ printStep(step++, totalSteps, "Adding auth plugins...");
3549
+ const authResult = await addAuthPlugins(config);
3550
+ if (!authResult.success) {
3551
+ printError(`Failed: ${authResult.error}`);
3552
+ return 1;
3553
+ }
3554
+ printSuccess(`Auth plugins configured ${SYMBOLS.arrow} ${import_picocolors2.default.dim(authResult.configPath)}`);
3555
+ printStep(step++, totalSteps, "Adding provider configurations...");
3556
+ const providerResult = addProviderConfig(config);
3557
+ if (!providerResult.success) {
3558
+ printError(`Failed: ${providerResult.error}`);
3559
+ return 1;
3560
+ }
3561
+ printSuccess(`Providers configured ${SYMBOLS.arrow} ${import_picocolors2.default.dim(providerResult.configPath)}`);
3562
+ } else {
3563
+ step += 2;
3564
+ }
3565
+ if (config.hasChatGPT) {
3566
+ printStep(step++, totalSteps, "Setting up ChatGPT hotfix...");
3567
+ const hotfixResult = setupChatGPTHotfix();
3568
+ if (!hotfixResult.success) {
3569
+ printError(`Failed: ${hotfixResult.error}`);
3570
+ return 1;
3571
+ }
3572
+ printSuccess(`Hotfix configured ${SYMBOLS.arrow} ${import_picocolors2.default.dim(hotfixResult.configPath)}`);
3573
+ printInfo("Installing dependencies with bun...");
3574
+ const bunSuccess = await runBunInstall();
3575
+ if (bunSuccess) {
3576
+ printSuccess("Dependencies installed");
3577
+ } else {
3578
+ printWarning("bun install failed - run manually: cd ~/.config/opencode && bun i");
3579
+ }
3580
+ } else {
3581
+ step++;
3582
+ }
3583
+ printStep(step++, totalSteps, "Writing oh-my-opencode configuration...");
3584
+ const omoResult = writeOmoConfig(config);
3585
+ if (!omoResult.success) {
3586
+ printError(`Failed: ${omoResult.error}`);
3587
+ return 1;
3588
+ }
3589
+ printSuccess(`Config written ${SYMBOLS.arrow} ${import_picocolors2.default.dim(omoResult.configPath)}`);
3590
+ printBox(formatConfigSummary(config), isUpdate ? "Updated Configuration" : "Installation Complete");
3591
+ if (!config.hasClaude && !config.hasChatGPT && !config.hasGemini) {
3592
+ printWarning("No model providers configured. Using opencode/big-pickle as fallback.");
3593
+ }
3594
+ if ((config.hasClaude || config.hasChatGPT || config.hasGemini) && !args.skipAuth) {
3595
+ console.log(import_picocolors2.default.bold("Next Steps - Authenticate your providers:"));
3596
+ console.log();
3597
+ if (config.hasClaude) {
3598
+ console.log(` ${SYMBOLS.arrow} ${import_picocolors2.default.dim("opencode auth login")} ${import_picocolors2.default.gray("(select Anthropic \u2192 Claude Pro/Max)")}`);
3599
+ }
3600
+ if (config.hasChatGPT) {
3601
+ console.log(` ${SYMBOLS.arrow} ${import_picocolors2.default.dim("opencode auth login")} ${import_picocolors2.default.gray("(select OpenAI \u2192 ChatGPT Plus/Pro)")}`);
3602
+ }
3603
+ if (config.hasGemini) {
3604
+ console.log(` ${SYMBOLS.arrow} ${import_picocolors2.default.dim("opencode auth login")} ${import_picocolors2.default.gray("(select Google \u2192 OAuth with Antigravity)")}`);
3605
+ }
3606
+ console.log();
3607
+ }
3608
+ console.log(`${SYMBOLS.star} ${import_picocolors2.default.bold(import_picocolors2.default.green(isUpdate ? "Configuration updated!" : "Installation complete!"))}`);
3609
+ console.log(` Run ${import_picocolors2.default.cyan("opencode")} to start!`);
3610
+ console.log();
3611
+ console.log(import_picocolors2.default.dim("oMoMoMoMo... Enjoy!"));
3612
+ console.log();
3613
+ return 0;
3614
+ }
3615
+ async function install(args) {
3616
+ if (!args.tui) {
3617
+ return runNonTuiInstall(args);
3618
+ }
3619
+ const detected = detectCurrentConfig();
3620
+ const isUpdate = detected.isInstalled;
3621
+ Ie(import_picocolors2.default.bgMagenta(import_picocolors2.default.white(isUpdate ? " oMoMoMoMo... Update " : " oMoMoMoMo... ")));
3622
+ if (isUpdate) {
3623
+ const initial = detectedToInitialValues(detected);
3624
+ M2.info(`Existing configuration detected: Claude=${initial.claude}, ChatGPT=${initial.chatgpt}, Gemini=${initial.gemini}`);
3625
+ }
3626
+ const s = Y2();
3627
+ s.start("Checking OpenCode installation");
3628
+ const installed = await isOpenCodeInstalled();
3629
+ if (!installed) {
3630
+ s.stop("OpenCode is not installed");
3631
+ M2.error("OpenCode is not installed on this system.");
3632
+ Me("Visit https://opencode.ai/docs for installation instructions", "Installation Guide");
3633
+ Se(import_picocolors2.default.red("Please install OpenCode first."));
3634
+ return 1;
3635
+ }
3636
+ const version = await getOpenCodeVersion();
3637
+ s.stop(`OpenCode ${version ?? "installed"} ${import_picocolors2.default.green("\u2713")}`);
3638
+ const config = await runTuiMode(detected);
3639
+ if (!config)
3640
+ return 1;
3641
+ s.start("Adding oh-my-opencode to OpenCode config");
3642
+ const pluginResult = addPluginToOpenCodeConfig();
3643
+ if (!pluginResult.success) {
3644
+ s.stop(`Failed to add plugin: ${pluginResult.error}`);
3645
+ Se(import_picocolors2.default.red("Installation failed."));
3646
+ return 1;
3647
+ }
3648
+ s.stop(`Plugin added to ${import_picocolors2.default.cyan(pluginResult.configPath)}`);
3649
+ if (config.hasGemini || config.hasChatGPT) {
3650
+ s.start("Adding auth plugins (fetching latest versions)");
3651
+ const authResult = await addAuthPlugins(config);
3652
+ if (!authResult.success) {
3653
+ s.stop(`Failed to add auth plugins: ${authResult.error}`);
3654
+ Se(import_picocolors2.default.red("Installation failed."));
3655
+ return 1;
3656
+ }
3657
+ s.stop(`Auth plugins added to ${import_picocolors2.default.cyan(authResult.configPath)}`);
3658
+ s.start("Adding provider configurations");
3659
+ const providerResult = addProviderConfig(config);
3660
+ if (!providerResult.success) {
3661
+ s.stop(`Failed to add provider config: ${providerResult.error}`);
3662
+ Se(import_picocolors2.default.red("Installation failed."));
3663
+ return 1;
3664
+ }
3665
+ s.stop(`Provider config added to ${import_picocolors2.default.cyan(providerResult.configPath)}`);
3666
+ }
3667
+ if (config.hasChatGPT) {
3668
+ s.start("Setting up ChatGPT hotfix");
3669
+ const hotfixResult = setupChatGPTHotfix();
3670
+ if (!hotfixResult.success) {
3671
+ s.stop(`Failed to setup hotfix: ${hotfixResult.error}`);
3672
+ Se(import_picocolors2.default.red("Installation failed."));
3673
+ return 1;
3674
+ }
3675
+ s.stop(`Hotfix configured in ${import_picocolors2.default.cyan(hotfixResult.configPath)}`);
3676
+ s.start("Installing dependencies with bun");
3677
+ const bunSuccess = await runBunInstall();
3678
+ if (bunSuccess) {
3679
+ s.stop("Dependencies installed");
3680
+ } else {
3681
+ s.stop(import_picocolors2.default.yellow("bun install failed - run manually: cd ~/.config/opencode && bun i"));
3682
+ }
3683
+ }
3684
+ s.start("Writing oh-my-opencode configuration");
3685
+ const omoResult = writeOmoConfig(config);
3686
+ if (!omoResult.success) {
3687
+ s.stop(`Failed to write config: ${omoResult.error}`);
3688
+ Se(import_picocolors2.default.red("Installation failed."));
3689
+ return 1;
3690
+ }
3691
+ s.stop(`Config written to ${import_picocolors2.default.cyan(omoResult.configPath)}`);
3692
+ if (!config.hasClaude && !config.hasChatGPT && !config.hasGemini) {
3693
+ M2.warn("No model providers configured. Using opencode/big-pickle as fallback.");
3694
+ }
3695
+ Me(formatConfigSummary(config), isUpdate ? "Updated Configuration" : "Installation Complete");
3696
+ if ((config.hasClaude || config.hasChatGPT || config.hasGemini) && !args.skipAuth) {
3697
+ const steps = [];
3698
+ if (config.hasClaude) {
3699
+ steps.push(`${import_picocolors2.default.dim("opencode auth login")} ${import_picocolors2.default.gray("(select Anthropic \u2192 Claude Pro/Max)")}`);
3700
+ }
3701
+ if (config.hasChatGPT) {
3702
+ steps.push(`${import_picocolors2.default.dim("opencode auth login")} ${import_picocolors2.default.gray("(select OpenAI \u2192 ChatGPT Plus/Pro)")}`);
3703
+ }
3704
+ if (config.hasGemini) {
3705
+ steps.push(`${import_picocolors2.default.dim("opencode auth login")} ${import_picocolors2.default.gray("(select Google \u2192 OAuth with Antigravity)")}`);
3706
+ }
3707
+ Me(steps.join(`
3708
+ `), "Next Steps - Authenticate your providers");
3709
+ }
3710
+ M2.success(import_picocolors2.default.bold(isUpdate ? "Configuration updated!" : "Installation complete!"));
3711
+ M2.message(`Run ${import_picocolors2.default.cyan("opencode")} to start!`);
3712
+ Se(import_picocolors2.default.green("oMoMoMoMo... Enjoy!"));
3713
+ return 0;
3714
+ }
3715
+
3716
+ // src/cli/index.ts
3717
+ var packageJson = await Promise.resolve().then(() => __toESM(require_package(), 1));
3718
+ var VERSION = packageJson.version;
3719
+ var program2 = new Command;
3720
+ program2.name("oh-my-opencode").description("The ultimate OpenCode plugin - multi-model orchestration, LSP tools, and more").version(VERSION, "-v, --version", "Show version number");
3721
+ program2.command("install").description("Install and configure oh-my-opencode with interactive setup").option("--no-tui", "Run in non-interactive mode (requires all options)").option("--claude <value>", "Claude subscription: no, yes, max20").option("--chatgpt <value>", "ChatGPT subscription: no, yes").option("--gemini <value>", "Gemini integration: no, yes").option("--skip-auth", "Skip authentication setup hints").addHelpText("after", `
3722
+ Examples:
3723
+ $ bunx oh-my-opencode install
3724
+ $ bunx oh-my-opencode install --no-tui --claude=max20 --chatgpt=yes --gemini=yes
3725
+ $ bunx oh-my-opencode install --no-tui --claude=no --chatgpt=no --gemini=no
3726
+
3727
+ Model Providers:
3728
+ Claude Required for Sisyphus (main orchestrator) and Librarian agents
3729
+ ChatGPT Powers the Oracle agent for debugging and architecture
3730
+ Gemini Powers frontend, documentation, and multimodal agents
3731
+ `).action(async (options) => {
3732
+ const args = {
3733
+ tui: options.tui !== false,
3734
+ claude: options.claude,
3735
+ chatgpt: options.chatgpt,
3736
+ gemini: options.gemini,
3737
+ skipAuth: options.skipAuth ?? false
3738
+ };
3739
+ const exitCode = await install(args);
3740
+ process.exit(exitCode);
3741
+ });
3742
+ program2.command("version").description("Show version information").action(() => {
3743
+ console.log(`oh-my-opencode v${VERSION}`);
3744
+ });
3745
+ program2.parse();