@polka-codes/cli 0.9.40 → 0.9.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +867 -755
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -521,7 +521,7 @@ var require_argument = __commonJS((exports) => {
521
521
  this._name = name;
522
522
  break;
523
523
  }
524
- if (this._name.length > 3 && this._name.slice(-3) === "...") {
524
+ if (this._name.endsWith("...")) {
525
525
  this.variadic = true;
526
526
  this._name = this._name.slice(0, -3);
527
527
  }
@@ -529,11 +529,12 @@ var require_argument = __commonJS((exports) => {
529
529
  name() {
530
530
  return this._name;
531
531
  }
532
- _concatValue(value, previous) {
532
+ _collectValue(value, previous) {
533
533
  if (previous === this.defaultValue || !Array.isArray(previous)) {
534
534
  return [value];
535
535
  }
536
- return previous.concat(value);
536
+ previous.push(value);
537
+ return previous;
537
538
  }
538
539
  default(value, description) {
539
540
  this.defaultValue = value;
@@ -551,7 +552,7 @@ var require_argument = __commonJS((exports) => {
551
552
  throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
552
553
  }
553
554
  if (this.variadic) {
554
- return this._concatValue(arg, previous);
555
+ return this._collectValue(arg, previous);
555
556
  }
556
557
  return arg;
557
558
  };
@@ -998,11 +999,12 @@ var require_option = __commonJS((exports) => {
998
999
  this.hidden = !!hide;
999
1000
  return this;
1000
1001
  }
1001
- _concatValue(value, previous) {
1002
+ _collectValue(value, previous) {
1002
1003
  if (previous === this.defaultValue || !Array.isArray(previous)) {
1003
1004
  return [value];
1004
1005
  }
1005
- return previous.concat(value);
1006
+ previous.push(value);
1007
+ return previous;
1006
1008
  }
1007
1009
  choices(values) {
1008
1010
  this.argChoices = values.slice();
@@ -1011,7 +1013,7 @@ var require_option = __commonJS((exports) => {
1011
1013
  throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
1012
1014
  }
1013
1015
  if (this.variadic) {
1014
- return this._concatValue(arg, previous);
1016
+ return this._collectValue(arg, previous);
1015
1017
  }
1016
1018
  return arg;
1017
1019
  };
@@ -1317,7 +1319,10 @@ var require_command = __commonJS((exports) => {
1317
1319
  configureOutput(configuration) {
1318
1320
  if (configuration === undefined)
1319
1321
  return this._outputConfiguration;
1320
- this._outputConfiguration = Object.assign({}, this._outputConfiguration, configuration);
1322
+ this._outputConfiguration = {
1323
+ ...this._outputConfiguration,
1324
+ ...configuration
1325
+ };
1321
1326
  return this;
1322
1327
  }
1323
1328
  showHelpAfterError(displayHelp = true) {
@@ -1366,7 +1371,7 @@ var require_command = __commonJS((exports) => {
1366
1371
  }
1367
1372
  addArgument(argument) {
1368
1373
  const previousArgument = this.registeredArguments.slice(-1)[0];
1369
- if (previousArgument && previousArgument.variadic) {
1374
+ if (previousArgument?.variadic) {
1370
1375
  throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
1371
1376
  }
1372
1377
  if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
@@ -1521,7 +1526,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1521
1526
  if (val !== null && option.parseArg) {
1522
1527
  val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1523
1528
  } else if (val !== null && option.variadic) {
1524
- val = option._concatValue(val, oldValue);
1529
+ val = option._collectValue(val, oldValue);
1525
1530
  }
1526
1531
  if (val == null) {
1527
1532
  if (option.negate) {
@@ -1896,7 +1901,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1896
1901
  this.processedArgs = processedArgs;
1897
1902
  }
1898
1903
  _chainOrCall(promise, fn) {
1899
- if (promise && promise.then && typeof promise.then === "function") {
1904
+ if (promise?.then && typeof promise.then === "function") {
1900
1905
  return promise.then(() => fn());
1901
1906
  }
1902
1907
  return fn();
@@ -1973,7 +1978,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1973
1978
  promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
1974
1979
  return promiseChain;
1975
1980
  }
1976
- if (this.parent && this.parent.listenerCount(commandEvent)) {
1981
+ if (this.parent?.listenerCount(commandEvent)) {
1977
1982
  checkForUnknownOptions();
1978
1983
  this._processArguments();
1979
1984
  this.parent.emit(commandEvent, operands, unknown);
@@ -2035,11 +2040,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2035
2040
  cmd._checkForConflictingLocalOptions();
2036
2041
  });
2037
2042
  }
2038
- parseOptions(argv) {
2043
+ parseOptions(args) {
2039
2044
  const operands = [];
2040
2045
  const unknown = [];
2041
2046
  let dest = operands;
2042
- const args = argv.slice();
2043
2047
  function maybeOption(arg) {
2044
2048
  return arg.length > 1 && arg[0] === "-";
2045
2049
  }
@@ -2049,12 +2053,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
2049
2053
  return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
2050
2054
  };
2051
2055
  let activeVariadicOption = null;
2052
- while (args.length) {
2053
- const arg = args.shift();
2056
+ let activeGroup = null;
2057
+ let i = 0;
2058
+ while (i < args.length || activeGroup) {
2059
+ const arg = activeGroup ?? args[i++];
2060
+ activeGroup = null;
2054
2061
  if (arg === "--") {
2055
2062
  if (dest === unknown)
2056
2063
  dest.push(arg);
2057
- dest.push(...args);
2064
+ dest.push(...args.slice(i));
2058
2065
  break;
2059
2066
  }
2060
2067
  if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
@@ -2066,14 +2073,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2066
2073
  const option = this._findOption(arg);
2067
2074
  if (option) {
2068
2075
  if (option.required) {
2069
- const value = args.shift();
2076
+ const value = args[i++];
2070
2077
  if (value === undefined)
2071
2078
  this.optionMissingArgument(option);
2072
2079
  this.emit(`option:${option.name()}`, value);
2073
2080
  } else if (option.optional) {
2074
2081
  let value = null;
2075
- if (args.length > 0 && (!maybeOption(args[0]) || negativeNumberArg(args[0]))) {
2076
- value = args.shift();
2082
+ if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
2083
+ value = args[i++];
2077
2084
  }
2078
2085
  this.emit(`option:${option.name()}`, value);
2079
2086
  } else {
@@ -2090,7 +2097,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2090
2097
  this.emit(`option:${option.name()}`, arg.slice(2));
2091
2098
  } else {
2092
2099
  this.emit(`option:${option.name()}`);
2093
- args.unshift(`-${arg.slice(2)}`);
2100
+ activeGroup = `-${arg.slice(2)}`;
2094
2101
  }
2095
2102
  continue;
2096
2103
  }
@@ -2109,25 +2116,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2109
2116
  if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2110
2117
  if (this._findCommand(arg)) {
2111
2118
  operands.push(arg);
2112
- if (args.length > 0)
2113
- unknown.push(...args);
2119
+ unknown.push(...args.slice(i));
2114
2120
  break;
2115
2121
  } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
2116
- operands.push(arg);
2117
- if (args.length > 0)
2118
- operands.push(...args);
2122
+ operands.push(arg, ...args.slice(i));
2119
2123
  break;
2120
2124
  } else if (this._defaultCommandName) {
2121
- unknown.push(arg);
2122
- if (args.length > 0)
2123
- unknown.push(...args);
2125
+ unknown.push(arg, ...args.slice(i));
2124
2126
  break;
2125
2127
  }
2126
2128
  }
2127
2129
  if (this._passThroughOptions) {
2128
- dest.push(arg);
2129
- if (args.length > 0)
2130
- dest.push(...args);
2130
+ dest.push(arg, ...args.slice(i));
2131
2131
  break;
2132
2132
  }
2133
2133
  dest.push(arg);
@@ -49925,6 +49925,429 @@ var require_mimeScore2 = __commonJS((exports, module) => {
49925
49925
  };
49926
49926
  });
49927
49927
 
49928
+ // ../../node_modules/chalk/node_modules/supports-color/index.js
49929
+ var require_supports_color2 = __commonJS((exports, module) => {
49930
+ var os = __require("os");
49931
+ var tty = __require("tty");
49932
+ var hasFlag = require_has_flag();
49933
+ var { env } = process;
49934
+ var forceColor;
49935
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
49936
+ forceColor = 0;
49937
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
49938
+ forceColor = 1;
49939
+ }
49940
+ if ("FORCE_COLOR" in env) {
49941
+ if (env.FORCE_COLOR === "true") {
49942
+ forceColor = 1;
49943
+ } else if (env.FORCE_COLOR === "false") {
49944
+ forceColor = 0;
49945
+ } else {
49946
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
49947
+ }
49948
+ }
49949
+ function translateLevel(level) {
49950
+ if (level === 0) {
49951
+ return false;
49952
+ }
49953
+ return {
49954
+ level,
49955
+ hasBasic: true,
49956
+ has256: level >= 2,
49957
+ has16m: level >= 3
49958
+ };
49959
+ }
49960
+ function supportsColor(haveStream, streamIsTTY) {
49961
+ if (forceColor === 0) {
49962
+ return 0;
49963
+ }
49964
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
49965
+ return 3;
49966
+ }
49967
+ if (hasFlag("color=256")) {
49968
+ return 2;
49969
+ }
49970
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
49971
+ return 0;
49972
+ }
49973
+ const min = forceColor || 0;
49974
+ if (env.TERM === "dumb") {
49975
+ return min;
49976
+ }
49977
+ if (process.platform === "win32") {
49978
+ const osRelease = os.release().split(".");
49979
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
49980
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
49981
+ }
49982
+ return 1;
49983
+ }
49984
+ if ("CI" in env) {
49985
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
49986
+ return 1;
49987
+ }
49988
+ return min;
49989
+ }
49990
+ if ("TEAMCITY_VERSION" in env) {
49991
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
49992
+ }
49993
+ if (env.COLORTERM === "truecolor") {
49994
+ return 3;
49995
+ }
49996
+ if ("TERM_PROGRAM" in env) {
49997
+ const version3 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
49998
+ switch (env.TERM_PROGRAM) {
49999
+ case "iTerm.app":
50000
+ return version3 >= 3 ? 3 : 2;
50001
+ case "Apple_Terminal":
50002
+ return 2;
50003
+ }
50004
+ }
50005
+ if (/-256(color)?$/i.test(env.TERM)) {
50006
+ return 2;
50007
+ }
50008
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
50009
+ return 1;
50010
+ }
50011
+ if ("COLORTERM" in env) {
50012
+ return 1;
50013
+ }
50014
+ return min;
50015
+ }
50016
+ function getSupportLevel(stream) {
50017
+ const level = supportsColor(stream, stream && stream.isTTY);
50018
+ return translateLevel(level);
50019
+ }
50020
+ module.exports = {
50021
+ supportsColor: getSupportLevel,
50022
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
50023
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
50024
+ };
50025
+ });
50026
+
50027
+ // ../../node_modules/chalk/source/util.js
50028
+ var require_util3 = __commonJS((exports, module) => {
50029
+ var stringReplaceAll = (string4, substring, replacer) => {
50030
+ let index = string4.indexOf(substring);
50031
+ if (index === -1) {
50032
+ return string4;
50033
+ }
50034
+ const substringLength = substring.length;
50035
+ let endIndex = 0;
50036
+ let returnValue = "";
50037
+ do {
50038
+ returnValue += string4.substr(endIndex, index - endIndex) + substring + replacer;
50039
+ endIndex = index + substringLength;
50040
+ index = string4.indexOf(substring, endIndex);
50041
+ } while (index !== -1);
50042
+ returnValue += string4.substr(endIndex);
50043
+ return returnValue;
50044
+ };
50045
+ var stringEncaseCRLFWithFirstIndex = (string4, prefix, postfix, index) => {
50046
+ let endIndex = 0;
50047
+ let returnValue = "";
50048
+ do {
50049
+ const gotCR = string4[index - 1] === "\r";
50050
+ returnValue += string4.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? `\r
50051
+ ` : `
50052
+ `) + postfix;
50053
+ endIndex = index + 1;
50054
+ index = string4.indexOf(`
50055
+ `, endIndex);
50056
+ } while (index !== -1);
50057
+ returnValue += string4.substr(endIndex);
50058
+ return returnValue;
50059
+ };
50060
+ module.exports = {
50061
+ stringReplaceAll,
50062
+ stringEncaseCRLFWithFirstIndex
50063
+ };
50064
+ });
50065
+
50066
+ // ../../node_modules/chalk/source/templates.js
50067
+ var require_templates = __commonJS((exports, module) => {
50068
+ var TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
50069
+ var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
50070
+ var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
50071
+ var ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
50072
+ var ESCAPES = new Map([
50073
+ ["n", `
50074
+ `],
50075
+ ["r", "\r"],
50076
+ ["t", "\t"],
50077
+ ["b", "\b"],
50078
+ ["f", "\f"],
50079
+ ["v", "\v"],
50080
+ ["0", "\x00"],
50081
+ ["\\", "\\"],
50082
+ ["e", "\x1B"],
50083
+ ["a", "\x07"]
50084
+ ]);
50085
+ function unescape2(c) {
50086
+ const u = c[0] === "u";
50087
+ const bracket = c[1] === "{";
50088
+ if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
50089
+ return String.fromCharCode(parseInt(c.slice(1), 16));
50090
+ }
50091
+ if (u && bracket) {
50092
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
50093
+ }
50094
+ return ESCAPES.get(c) || c;
50095
+ }
50096
+ function parseArguments(name18, arguments_) {
50097
+ const results = [];
50098
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
50099
+ let matches;
50100
+ for (const chunk of chunks) {
50101
+ const number4 = Number(chunk);
50102
+ if (!Number.isNaN(number4)) {
50103
+ results.push(number4);
50104
+ } else if (matches = chunk.match(STRING_REGEX)) {
50105
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape2(escape) : character));
50106
+ } else {
50107
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name18}')`);
50108
+ }
50109
+ }
50110
+ return results;
50111
+ }
50112
+ function parseStyle(style) {
50113
+ STYLE_REGEX.lastIndex = 0;
50114
+ const results = [];
50115
+ let matches;
50116
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
50117
+ const name18 = matches[1];
50118
+ if (matches[2]) {
50119
+ const args = parseArguments(name18, matches[2]);
50120
+ results.push([name18].concat(args));
50121
+ } else {
50122
+ results.push([name18]);
50123
+ }
50124
+ }
50125
+ return results;
50126
+ }
50127
+ function buildStyle(chalk, styles) {
50128
+ const enabled = {};
50129
+ for (const layer of styles) {
50130
+ for (const style of layer.styles) {
50131
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
50132
+ }
50133
+ }
50134
+ let current = chalk;
50135
+ for (const [styleName, styles2] of Object.entries(enabled)) {
50136
+ if (!Array.isArray(styles2)) {
50137
+ continue;
50138
+ }
50139
+ if (!(styleName in current)) {
50140
+ throw new Error(`Unknown Chalk style: ${styleName}`);
50141
+ }
50142
+ current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
50143
+ }
50144
+ return current;
50145
+ }
50146
+ module.exports = (chalk, temporary) => {
50147
+ const styles = [];
50148
+ const chunks = [];
50149
+ let chunk = [];
50150
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
50151
+ if (escapeCharacter) {
50152
+ chunk.push(unescape2(escapeCharacter));
50153
+ } else if (style) {
50154
+ const string4 = chunk.join("");
50155
+ chunk = [];
50156
+ chunks.push(styles.length === 0 ? string4 : buildStyle(chalk, styles)(string4));
50157
+ styles.push({ inverse, styles: parseStyle(style) });
50158
+ } else if (close) {
50159
+ if (styles.length === 0) {
50160
+ throw new Error("Found extraneous } in Chalk template literal");
50161
+ }
50162
+ chunks.push(buildStyle(chalk, styles)(chunk.join("")));
50163
+ chunk = [];
50164
+ styles.pop();
50165
+ } else {
50166
+ chunk.push(character);
50167
+ }
50168
+ });
50169
+ chunks.push(chunk.join(""));
50170
+ if (styles.length > 0) {
50171
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
50172
+ throw new Error(errMessage);
50173
+ }
50174
+ return chunks.join("");
50175
+ };
50176
+ });
50177
+
50178
+ // ../../node_modules/chalk/source/index.js
50179
+ var require_source = __commonJS((exports, module) => {
50180
+ var ansiStyles = require_ansi_styles();
50181
+ var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color2();
50182
+ var {
50183
+ stringReplaceAll,
50184
+ stringEncaseCRLFWithFirstIndex
50185
+ } = require_util3();
50186
+ var { isArray } = Array;
50187
+ var levelMapping = [
50188
+ "ansi",
50189
+ "ansi",
50190
+ "ansi256",
50191
+ "ansi16m"
50192
+ ];
50193
+ var styles = Object.create(null);
50194
+ var applyOptions = (object3, options = {}) => {
50195
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
50196
+ throw new Error("The `level` option should be an integer from 0 to 3");
50197
+ }
50198
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
50199
+ object3.level = options.level === undefined ? colorLevel : options.level;
50200
+ };
50201
+
50202
+ class ChalkClass {
50203
+ constructor(options) {
50204
+ return chalkFactory(options);
50205
+ }
50206
+ }
50207
+ var chalkFactory = (options) => {
50208
+ const chalk2 = {};
50209
+ applyOptions(chalk2, options);
50210
+ chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
50211
+ Object.setPrototypeOf(chalk2, Chalk.prototype);
50212
+ Object.setPrototypeOf(chalk2.template, chalk2);
50213
+ chalk2.template.constructor = () => {
50214
+ throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
50215
+ };
50216
+ chalk2.template.Instance = ChalkClass;
50217
+ return chalk2.template;
50218
+ };
50219
+ function Chalk(options) {
50220
+ return chalkFactory(options);
50221
+ }
50222
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
50223
+ styles[styleName] = {
50224
+ get() {
50225
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
50226
+ Object.defineProperty(this, styleName, { value: builder });
50227
+ return builder;
50228
+ }
50229
+ };
50230
+ }
50231
+ styles.visible = {
50232
+ get() {
50233
+ const builder = createBuilder(this, this._styler, true);
50234
+ Object.defineProperty(this, "visible", { value: builder });
50235
+ return builder;
50236
+ }
50237
+ };
50238
+ var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
50239
+ for (const model of usedModels) {
50240
+ styles[model] = {
50241
+ get() {
50242
+ const { level } = this;
50243
+ return function(...arguments_) {
50244
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
50245
+ return createBuilder(this, styler, this._isEmpty);
50246
+ };
50247
+ }
50248
+ };
50249
+ }
50250
+ for (const model of usedModels) {
50251
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
50252
+ styles[bgModel] = {
50253
+ get() {
50254
+ const { level } = this;
50255
+ return function(...arguments_) {
50256
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
50257
+ return createBuilder(this, styler, this._isEmpty);
50258
+ };
50259
+ }
50260
+ };
50261
+ }
50262
+ var proto = Object.defineProperties(() => {}, {
50263
+ ...styles,
50264
+ level: {
50265
+ enumerable: true,
50266
+ get() {
50267
+ return this._generator.level;
50268
+ },
50269
+ set(level) {
50270
+ this._generator.level = level;
50271
+ }
50272
+ }
50273
+ });
50274
+ var createStyler = (open, close, parent) => {
50275
+ let openAll;
50276
+ let closeAll;
50277
+ if (parent === undefined) {
50278
+ openAll = open;
50279
+ closeAll = close;
50280
+ } else {
50281
+ openAll = parent.openAll + open;
50282
+ closeAll = close + parent.closeAll;
50283
+ }
50284
+ return {
50285
+ open,
50286
+ close,
50287
+ openAll,
50288
+ closeAll,
50289
+ parent
50290
+ };
50291
+ };
50292
+ var createBuilder = (self2, _styler, _isEmpty) => {
50293
+ const builder = (...arguments_) => {
50294
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
50295
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
50296
+ }
50297
+ return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
50298
+ };
50299
+ Object.setPrototypeOf(builder, proto);
50300
+ builder._generator = self2;
50301
+ builder._styler = _styler;
50302
+ builder._isEmpty = _isEmpty;
50303
+ return builder;
50304
+ };
50305
+ var applyStyle = (self2, string4) => {
50306
+ if (self2.level <= 0 || !string4) {
50307
+ return self2._isEmpty ? "" : string4;
50308
+ }
50309
+ let styler = self2._styler;
50310
+ if (styler === undefined) {
50311
+ return string4;
50312
+ }
50313
+ const { openAll, closeAll } = styler;
50314
+ if (string4.indexOf("\x1B") !== -1) {
50315
+ while (styler !== undefined) {
50316
+ string4 = stringReplaceAll(string4, styler.close, styler.open);
50317
+ styler = styler.parent;
50318
+ }
50319
+ }
50320
+ const lfIndex = string4.indexOf(`
50321
+ `);
50322
+ if (lfIndex !== -1) {
50323
+ string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
50324
+ }
50325
+ return openAll + string4 + closeAll;
50326
+ };
50327
+ var template;
50328
+ var chalkTag = (chalk2, ...strings) => {
50329
+ const [firstString] = strings;
50330
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
50331
+ return strings.join(" ");
50332
+ }
50333
+ const arguments_ = strings.slice(1);
50334
+ const parts = [firstString.raw[0]];
50335
+ for (let i = 1;i < firstString.length; i++) {
50336
+ parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"), String(firstString.raw[i]));
50337
+ }
50338
+ if (template === undefined) {
50339
+ template = require_templates();
50340
+ }
50341
+ return template(chalk2, parts.join(""));
50342
+ };
50343
+ Object.defineProperties(Chalk.prototype, styles);
50344
+ var chalk = Chalk();
50345
+ chalk.supportsColor = stdoutColor;
50346
+ chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
50347
+ chalk.stderr.supportsColor = stderrColor;
50348
+ module.exports = chalk;
50349
+ });
50350
+
49928
50351
  // ../../node_modules/yaml/dist/nodes/identity.js
49929
50352
  var require_identity2 = __commonJS((exports) => {
49930
50353
  var ALIAS = Symbol.for("yaml.alias");
@@ -56433,14 +56856,14 @@ var require_parser2 = __commonJS((exports) => {
56433
56856
  case "scalar":
56434
56857
  case "single-quoted-scalar":
56435
56858
  case "double-quoted-scalar": {
56436
- const fs2 = this.flowScalar(this.type);
56859
+ const fs3 = this.flowScalar(this.type);
56437
56860
  if (atNextItem || it.value) {
56438
- map2.items.push({ start, key: fs2, sep: [] });
56861
+ map2.items.push({ start, key: fs3, sep: [] });
56439
56862
  this.onKeyLine = true;
56440
56863
  } else if (it.sep) {
56441
- this.stack.push(fs2);
56864
+ this.stack.push(fs3);
56442
56865
  } else {
56443
- Object.assign(it, { key: fs2, sep: [] });
56866
+ Object.assign(it, { key: fs3, sep: [] });
56444
56867
  this.onKeyLine = true;
56445
56868
  }
56446
56869
  return;
@@ -56568,13 +56991,13 @@ var require_parser2 = __commonJS((exports) => {
56568
56991
  case "scalar":
56569
56992
  case "single-quoted-scalar":
56570
56993
  case "double-quoted-scalar": {
56571
- const fs2 = this.flowScalar(this.type);
56994
+ const fs3 = this.flowScalar(this.type);
56572
56995
  if (!it || it.value)
56573
- fc.items.push({ start: [], key: fs2, sep: [] });
56996
+ fc.items.push({ start: [], key: fs3, sep: [] });
56574
56997
  else if (it.sep)
56575
- this.stack.push(fs2);
56998
+ this.stack.push(fs3);
56576
56999
  else
56577
- Object.assign(it, { key: fs2, sep: [] });
57000
+ Object.assign(it, { key: fs3, sep: [] });
56578
57001
  return;
56579
57002
  }
56580
57003
  case "flow-map-end":
@@ -56846,7 +57269,7 @@ var {
56846
57269
  Help
56847
57270
  } = import__.default;
56848
57271
  // package.json
56849
- var version = "0.9.40";
57272
+ var version = "0.9.42";
56850
57273
 
56851
57274
  // src/commands/chat.ts
56852
57275
  import { readFile as readFile3 } from "node:fs/promises";
@@ -70140,6 +70563,9 @@ function date4(params) {
70140
70563
 
70141
70564
  // ../../node_modules/zod/v4/classic/external.js
70142
70565
  config(en_default());
70566
+ // ../../node_modules/zod/index.js
70567
+ var zod_default = exports_external;
70568
+
70143
70569
  // ../core/src/tools/askFollowupQuestion.ts
70144
70570
  var questionObject = exports_external.object({
70145
70571
  prompt: exports_external.string().describe("The text of the question.").meta({ usageValue: "question text here" }),
@@ -99615,6 +100041,7 @@ Aborting request...`);
99615
100041
  // src/prices.ts
99616
100042
  var prices_default = {
99617
100043
  ["anthropic" /* Anthropic */]: {
100044
+ "claude-sonnet-4-5-20250929": { inputPrice: 3, outputPrice: 15, cacheWritesPrice: 3.75, cacheReadsPrice: 0.3, supportsThinking: true },
99618
100045
  "claude-opus-4-20250514": { inputPrice: 15, outputPrice: 75, cacheWritesPrice: 18.75, cacheReadsPrice: 1.5, supportsThinking: true },
99619
100046
  "claude-opus-4-1-20250805": { inputPrice: 15, outputPrice: 75, cacheWritesPrice: 18.75, cacheReadsPrice: 1.5, supportsThinking: true },
99620
100047
  "claude-sonnet-4-20250514": { inputPrice: 3, outputPrice: 15, cacheWritesPrice: 3.75, cacheReadsPrice: 0.3, supportsThinking: true },
@@ -99624,8 +100051,8 @@ var prices_default = {
99624
100051
  },
99625
100052
  ["ollama" /* Ollama */]: {},
99626
100053
  ["deepseek" /* DeepSeek */]: {
99627
- "deepseek-chat": { inputPrice: 0.27, outputPrice: 1.1, cacheWritesPrice: 0, cacheReadsPrice: 0.07 },
99628
- "deepseek-reasoner": { inputPrice: 0.55, outputPrice: 2.19, cacheWritesPrice: 0, cacheReadsPrice: 0.14 }
100054
+ "deepseek-chat": { inputPrice: 0.28, outputPrice: 0.42, cacheWritesPrice: 0, cacheReadsPrice: 0.028 },
100055
+ "deepseek-reasoner": { inputPrice: 0.28, outputPrice: 0.42, cacheWritesPrice: 0, cacheReadsPrice: 0.028, supportsThinking: true }
99629
100056
  },
99630
100057
  ["openrouter" /* OpenRouter */]: {},
99631
100058
  ["openai" /* OpenAI */]: {
@@ -99634,9 +100061,16 @@ var prices_default = {
99634
100061
  "gpt-5-nano-2025-08-07": { inputPrice: 0.05, outputPrice: 0.4, cacheWritesPrice: 0, cacheReadsPrice: 0.005, supportsThinking: false }
99635
100062
  },
99636
100063
  ["google-vertex" /* GoogleVertex */]: {
99637
- "gemini-2.5-pro": { inputPrice: 2.5, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0, supportsThinking: true },
99638
- "gemini-2.5-flash": { inputPrice: 0.3, outputPrice: 2.5, cacheWritesPrice: 0, cacheReadsPrice: 0, supportsThinking: false },
99639
- "gemini-2.5-flash-lite": { inputPrice: 0.1, outputPrice: 0.4, cacheWritesPrice: 0, cacheReadsPrice: 0, supportsThinking: false }
100064
+ "gemini-2.5-pro": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0.31, supportsThinking: true },
100065
+ "gemini-2.5-flash": { inputPrice: 0.3, outputPrice: 2.5, cacheWritesPrice: 0, cacheReadsPrice: 0.075, supportsThinking: true },
100066
+ "gemini-2.5-flash-lite": { inputPrice: 0.1, outputPrice: 0.4, cacheWritesPrice: 0, cacheReadsPrice: 0.025, supportsThinking: false },
100067
+ "gemini-2.5-flash-preview-09-2025": {
100068
+ inputPrice: 0.3,
100069
+ outputPrice: 2.5,
100070
+ cacheWritesPrice: 0,
100071
+ cacheReadsPrice: 0.075,
100072
+ supportsThinking: true
100073
+ }
99640
100074
  }
99641
100075
  };
99642
100076
 
@@ -99706,7 +100140,7 @@ async function configPrompt(existingConfig) {
99706
100140
  }
99707
100141
 
99708
100142
  // src/options.ts
99709
- import os2 from "node:os";
100143
+ import os from "node:os";
99710
100144
 
99711
100145
  // ../cli-shared/src/config.ts
99712
100146
  import { existsSync as existsSync2, readFileSync } from "node:fs";
@@ -104075,496 +104509,8 @@ var getProvider = (options = {}) => {
104075
104509
  }
104076
104510
  return provider2;
104077
104511
  };
104078
- // ../../node_modules/chalk/source/vendor/ansi-styles/index.js
104079
- var ANSI_BACKGROUND_OFFSET = 10;
104080
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
104081
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
104082
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
104083
- var styles = {
104084
- modifier: {
104085
- reset: [0, 0],
104086
- bold: [1, 22],
104087
- dim: [2, 22],
104088
- italic: [3, 23],
104089
- underline: [4, 24],
104090
- overline: [53, 55],
104091
- inverse: [7, 27],
104092
- hidden: [8, 28],
104093
- strikethrough: [9, 29]
104094
- },
104095
- color: {
104096
- black: [30, 39],
104097
- red: [31, 39],
104098
- green: [32, 39],
104099
- yellow: [33, 39],
104100
- blue: [34, 39],
104101
- magenta: [35, 39],
104102
- cyan: [36, 39],
104103
- white: [37, 39],
104104
- blackBright: [90, 39],
104105
- gray: [90, 39],
104106
- grey: [90, 39],
104107
- redBright: [91, 39],
104108
- greenBright: [92, 39],
104109
- yellowBright: [93, 39],
104110
- blueBright: [94, 39],
104111
- magentaBright: [95, 39],
104112
- cyanBright: [96, 39],
104113
- whiteBright: [97, 39]
104114
- },
104115
- bgColor: {
104116
- bgBlack: [40, 49],
104117
- bgRed: [41, 49],
104118
- bgGreen: [42, 49],
104119
- bgYellow: [43, 49],
104120
- bgBlue: [44, 49],
104121
- bgMagenta: [45, 49],
104122
- bgCyan: [46, 49],
104123
- bgWhite: [47, 49],
104124
- bgBlackBright: [100, 49],
104125
- bgGray: [100, 49],
104126
- bgGrey: [100, 49],
104127
- bgRedBright: [101, 49],
104128
- bgGreenBright: [102, 49],
104129
- bgYellowBright: [103, 49],
104130
- bgBlueBright: [104, 49],
104131
- bgMagentaBright: [105, 49],
104132
- bgCyanBright: [106, 49],
104133
- bgWhiteBright: [107, 49]
104134
- }
104135
- };
104136
- var modifierNames = Object.keys(styles.modifier);
104137
- var foregroundColorNames = Object.keys(styles.color);
104138
- var backgroundColorNames = Object.keys(styles.bgColor);
104139
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
104140
- function assembleStyles() {
104141
- const codes = new Map;
104142
- for (const [groupName, group] of Object.entries(styles)) {
104143
- for (const [styleName, style] of Object.entries(group)) {
104144
- styles[styleName] = {
104145
- open: `\x1B[${style[0]}m`,
104146
- close: `\x1B[${style[1]}m`
104147
- };
104148
- group[styleName] = styles[styleName];
104149
- codes.set(style[0], style[1]);
104150
- }
104151
- Object.defineProperty(styles, groupName, {
104152
- value: group,
104153
- enumerable: false
104154
- });
104155
- }
104156
- Object.defineProperty(styles, "codes", {
104157
- value: codes,
104158
- enumerable: false
104159
- });
104160
- styles.color.close = "\x1B[39m";
104161
- styles.bgColor.close = "\x1B[49m";
104162
- styles.color.ansi = wrapAnsi16();
104163
- styles.color.ansi256 = wrapAnsi256();
104164
- styles.color.ansi16m = wrapAnsi16m();
104165
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
104166
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
104167
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
104168
- Object.defineProperties(styles, {
104169
- rgbToAnsi256: {
104170
- value(red, green, blue) {
104171
- if (red === green && green === blue) {
104172
- if (red < 8) {
104173
- return 16;
104174
- }
104175
- if (red > 248) {
104176
- return 231;
104177
- }
104178
- return Math.round((red - 8) / 247 * 24) + 232;
104179
- }
104180
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
104181
- },
104182
- enumerable: false
104183
- },
104184
- hexToRgb: {
104185
- value(hex3) {
104186
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex3.toString(16));
104187
- if (!matches) {
104188
- return [0, 0, 0];
104189
- }
104190
- let [colorString] = matches;
104191
- if (colorString.length === 3) {
104192
- colorString = [...colorString].map((character) => character + character).join("");
104193
- }
104194
- const integer2 = Number.parseInt(colorString, 16);
104195
- return [
104196
- integer2 >> 16 & 255,
104197
- integer2 >> 8 & 255,
104198
- integer2 & 255
104199
- ];
104200
- },
104201
- enumerable: false
104202
- },
104203
- hexToAnsi256: {
104204
- value: (hex3) => styles.rgbToAnsi256(...styles.hexToRgb(hex3)),
104205
- enumerable: false
104206
- },
104207
- ansi256ToAnsi: {
104208
- value(code) {
104209
- if (code < 8) {
104210
- return 30 + code;
104211
- }
104212
- if (code < 16) {
104213
- return 90 + (code - 8);
104214
- }
104215
- let red;
104216
- let green;
104217
- let blue;
104218
- if (code >= 232) {
104219
- red = ((code - 232) * 10 + 8) / 255;
104220
- green = red;
104221
- blue = red;
104222
- } else {
104223
- code -= 16;
104224
- const remainder = code % 36;
104225
- red = Math.floor(code / 36) / 5;
104226
- green = Math.floor(remainder / 6) / 5;
104227
- blue = remainder % 6 / 5;
104228
- }
104229
- const value = Math.max(red, green, blue) * 2;
104230
- if (value === 0) {
104231
- return 30;
104232
- }
104233
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
104234
- if (value === 2) {
104235
- result += 60;
104236
- }
104237
- return result;
104238
- },
104239
- enumerable: false
104240
- },
104241
- rgbToAnsi: {
104242
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
104243
- enumerable: false
104244
- },
104245
- hexToAnsi: {
104246
- value: (hex3) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex3)),
104247
- enumerable: false
104248
- }
104249
- });
104250
- return styles;
104251
- }
104252
- var ansiStyles = assembleStyles();
104253
- var ansi_styles_default = ansiStyles;
104254
-
104255
- // ../../node_modules/chalk/source/vendor/supports-color/index.js
104256
- import process4 from "node:process";
104257
- import os from "node:os";
104258
- import tty from "node:tty";
104259
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process4.argv) {
104260
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
104261
- const position = argv.indexOf(prefix + flag);
104262
- const terminatorPosition = argv.indexOf("--");
104263
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
104264
- }
104265
- var { env } = process4;
104266
- var flagForceColor;
104267
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
104268
- flagForceColor = 0;
104269
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
104270
- flagForceColor = 1;
104271
- }
104272
- function envForceColor() {
104273
- if ("FORCE_COLOR" in env) {
104274
- if (env.FORCE_COLOR === "true") {
104275
- return 1;
104276
- }
104277
- if (env.FORCE_COLOR === "false") {
104278
- return 0;
104279
- }
104280
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
104281
- }
104282
- }
104283
- function translateLevel(level) {
104284
- if (level === 0) {
104285
- return false;
104286
- }
104287
- return {
104288
- level,
104289
- hasBasic: true,
104290
- has256: level >= 2,
104291
- has16m: level >= 3
104292
- };
104293
- }
104294
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
104295
- const noFlagForceColor = envForceColor();
104296
- if (noFlagForceColor !== undefined) {
104297
- flagForceColor = noFlagForceColor;
104298
- }
104299
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
104300
- if (forceColor === 0) {
104301
- return 0;
104302
- }
104303
- if (sniffFlags) {
104304
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
104305
- return 3;
104306
- }
104307
- if (hasFlag("color=256")) {
104308
- return 2;
104309
- }
104310
- }
104311
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
104312
- return 1;
104313
- }
104314
- if (haveStream && !streamIsTTY && forceColor === undefined) {
104315
- return 0;
104316
- }
104317
- const min = forceColor || 0;
104318
- if (env.TERM === "dumb") {
104319
- return min;
104320
- }
104321
- if (process4.platform === "win32") {
104322
- const osRelease = os.release().split(".");
104323
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
104324
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
104325
- }
104326
- return 1;
104327
- }
104328
- if ("CI" in env) {
104329
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key2) => (key2 in env))) {
104330
- return 3;
104331
- }
104332
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
104333
- return 1;
104334
- }
104335
- return min;
104336
- }
104337
- if ("TEAMCITY_VERSION" in env) {
104338
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
104339
- }
104340
- if (env.COLORTERM === "truecolor") {
104341
- return 3;
104342
- }
104343
- if (env.TERM === "xterm-kitty") {
104344
- return 3;
104345
- }
104346
- if (env.TERM === "xterm-ghostty") {
104347
- return 3;
104348
- }
104349
- if (env.TERM === "wezterm") {
104350
- return 3;
104351
- }
104352
- if ("TERM_PROGRAM" in env) {
104353
- const version3 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
104354
- switch (env.TERM_PROGRAM) {
104355
- case "iTerm.app": {
104356
- return version3 >= 3 ? 3 : 2;
104357
- }
104358
- case "Apple_Terminal": {
104359
- return 2;
104360
- }
104361
- }
104362
- }
104363
- if (/-256(color)?$/i.test(env.TERM)) {
104364
- return 2;
104365
- }
104366
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
104367
- return 1;
104368
- }
104369
- if ("COLORTERM" in env) {
104370
- return 1;
104371
- }
104372
- return min;
104373
- }
104374
- function createSupportsColor(stream, options = {}) {
104375
- const level = _supportsColor(stream, {
104376
- streamIsTTY: stream && stream.isTTY,
104377
- ...options
104378
- });
104379
- return translateLevel(level);
104380
- }
104381
- var supportsColor = {
104382
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
104383
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
104384
- };
104385
- var supports_color_default = supportsColor;
104386
-
104387
- // ../../node_modules/chalk/source/utilities.js
104388
- function stringReplaceAll(string4, substring, replacer) {
104389
- let index = string4.indexOf(substring);
104390
- if (index === -1) {
104391
- return string4;
104392
- }
104393
- const substringLength = substring.length;
104394
- let endIndex = 0;
104395
- let returnValue = "";
104396
- do {
104397
- returnValue += string4.slice(endIndex, index) + substring + replacer;
104398
- endIndex = index + substringLength;
104399
- index = string4.indexOf(substring, endIndex);
104400
- } while (index !== -1);
104401
- returnValue += string4.slice(endIndex);
104402
- return returnValue;
104403
- }
104404
- function stringEncaseCRLFWithFirstIndex(string4, prefix, postfix, index) {
104405
- let endIndex = 0;
104406
- let returnValue = "";
104407
- do {
104408
- const gotCR = string4[index - 1] === "\r";
104409
- returnValue += string4.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r
104410
- ` : `
104411
- `) + postfix;
104412
- endIndex = index + 1;
104413
- index = string4.indexOf(`
104414
- `, endIndex);
104415
- } while (index !== -1);
104416
- returnValue += string4.slice(endIndex);
104417
- return returnValue;
104418
- }
104419
-
104420
- // ../../node_modules/chalk/source/index.js
104421
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
104422
- var GENERATOR = Symbol("GENERATOR");
104423
- var STYLER = Symbol("STYLER");
104424
- var IS_EMPTY = Symbol("IS_EMPTY");
104425
- var levelMapping = [
104426
- "ansi",
104427
- "ansi",
104428
- "ansi256",
104429
- "ansi16m"
104430
- ];
104431
- var styles2 = Object.create(null);
104432
- var applyOptions = (object3, options = {}) => {
104433
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
104434
- throw new Error("The `level` option should be an integer from 0 to 3");
104435
- }
104436
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
104437
- object3.level = options.level === undefined ? colorLevel : options.level;
104438
- };
104439
- var chalkFactory = (options) => {
104440
- const chalk = (...strings) => strings.join(" ");
104441
- applyOptions(chalk, options);
104442
- Object.setPrototypeOf(chalk, createChalk.prototype);
104443
- return chalk;
104444
- };
104445
- function createChalk(options) {
104446
- return chalkFactory(options);
104447
- }
104448
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
104449
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
104450
- styles2[styleName] = {
104451
- get() {
104452
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
104453
- Object.defineProperty(this, styleName, { value: builder });
104454
- return builder;
104455
- }
104456
- };
104457
- }
104458
- styles2.visible = {
104459
- get() {
104460
- const builder = createBuilder(this, this[STYLER], true);
104461
- Object.defineProperty(this, "visible", { value: builder });
104462
- return builder;
104463
- }
104464
- };
104465
- var getModelAnsi = (model, level, type, ...arguments_) => {
104466
- if (model === "rgb") {
104467
- if (level === "ansi16m") {
104468
- return ansi_styles_default[type].ansi16m(...arguments_);
104469
- }
104470
- if (level === "ansi256") {
104471
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
104472
- }
104473
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
104474
- }
104475
- if (model === "hex") {
104476
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
104477
- }
104478
- return ansi_styles_default[type][model](...arguments_);
104479
- };
104480
- var usedModels = ["rgb", "hex", "ansi256"];
104481
- for (const model of usedModels) {
104482
- styles2[model] = {
104483
- get() {
104484
- const { level } = this;
104485
- return function(...arguments_) {
104486
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
104487
- return createBuilder(this, styler, this[IS_EMPTY]);
104488
- };
104489
- }
104490
- };
104491
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
104492
- styles2[bgModel] = {
104493
- get() {
104494
- const { level } = this;
104495
- return function(...arguments_) {
104496
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
104497
- return createBuilder(this, styler, this[IS_EMPTY]);
104498
- };
104499
- }
104500
- };
104501
- }
104502
- var proto = Object.defineProperties(() => {}, {
104503
- ...styles2,
104504
- level: {
104505
- enumerable: true,
104506
- get() {
104507
- return this[GENERATOR].level;
104508
- },
104509
- set(level) {
104510
- this[GENERATOR].level = level;
104511
- }
104512
- }
104513
- });
104514
- var createStyler = (open, close, parent) => {
104515
- let openAll;
104516
- let closeAll;
104517
- if (parent === undefined) {
104518
- openAll = open;
104519
- closeAll = close;
104520
- } else {
104521
- openAll = parent.openAll + open;
104522
- closeAll = close + parent.closeAll;
104523
- }
104524
- return {
104525
- open,
104526
- close,
104527
- openAll,
104528
- closeAll,
104529
- parent
104530
- };
104531
- };
104532
- var createBuilder = (self2, _styler, _isEmpty) => {
104533
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
104534
- Object.setPrototypeOf(builder, proto);
104535
- builder[GENERATOR] = self2;
104536
- builder[STYLER] = _styler;
104537
- builder[IS_EMPTY] = _isEmpty;
104538
- return builder;
104539
- };
104540
- var applyStyle = (self2, string4) => {
104541
- if (self2.level <= 0 || !string4) {
104542
- return self2[IS_EMPTY] ? "" : string4;
104543
- }
104544
- let styler = self2[STYLER];
104545
- if (styler === undefined) {
104546
- return string4;
104547
- }
104548
- const { openAll, closeAll } = styler;
104549
- if (string4.includes("\x1B")) {
104550
- while (styler !== undefined) {
104551
- string4 = stringReplaceAll(string4, styler.close, styler.open);
104552
- styler = styler.parent;
104553
- }
104554
- }
104555
- const lfIndex = string4.indexOf(`
104556
- `);
104557
- if (lfIndex !== -1) {
104558
- string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
104559
- }
104560
- return openAll + string4 + closeAll;
104561
- };
104562
- Object.defineProperties(createChalk.prototype, styles2);
104563
- var chalk = createChalk();
104564
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
104565
- var source_default = chalk;
104566
-
104567
104512
  // ../cli-shared/src/utils/eventHandler.ts
104513
+ var import_chalk = __toESM(require_source(), 1);
104568
104514
  var toolCallStats = new Map;
104569
104515
  var printEvent = (verbose, usageMeter, customConsole = console) => {
104570
104516
  let hadReasoning = false;
@@ -104600,19 +104546,19 @@ ${event.systemPrompt}`);
104600
104546
  break;
104601
104547
  case "image":
104602
104548
  if (content.image instanceof URL) {
104603
- customConsole.log(source_default.yellow(`[Image content from URL: ${content.image}]`));
104549
+ customConsole.log(import_chalk.default.yellow(`[Image content from URL: ${content.image}]`));
104604
104550
  } else {
104605
- customConsole.log(source_default.yellow(`[Image content: ${content.mediaType}]`));
104551
+ customConsole.log(import_chalk.default.yellow(`[Image content: ${content.mediaType}]`));
104606
104552
  }
104607
104553
  break;
104608
104554
  case "file":
104609
- customConsole.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
104555
+ customConsole.log(import_chalk.default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
104610
104556
  break;
104611
104557
  case "tool-call":
104612
- customConsole.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
104558
+ customConsole.log(import_chalk.default.yellow(`[Tool call: ${content.toolName}]`));
104613
104559
  break;
104614
104560
  case "tool-result":
104615
- customConsole.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
104561
+ customConsole.log(import_chalk.default.yellow(`[Tool result: ${content.toolName}]`));
104616
104562
  if (verbose > 0) {
104617
104563
  customConsole.log(content.output);
104618
104564
  }
@@ -104651,12 +104597,12 @@ ${event.systemPrompt}`);
104651
104597
  break;
104652
104598
  }
104653
104599
  case "Reasoning" /* Reasoning */: {
104654
- customConsole.write(source_default.dim(event.newText));
104600
+ customConsole.write(import_chalk.default.dim(event.newText));
104655
104601
  hadReasoning = true;
104656
104602
  break;
104657
104603
  }
104658
104604
  case "ToolUse" /* ToolUse */: {
104659
- customConsole.log(source_default.yellow(`
104605
+ customConsole.log(import_chalk.default.yellow(`
104660
104606
 
104661
104607
  Tool use:`, event.tool), event.params);
104662
104608
  const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
@@ -104673,7 +104619,7 @@ Tool use:`, event.tool), event.params);
104673
104619
  case "ToolInvalid" /* ToolInvalid */:
104674
104620
  break;
104675
104621
  case "ToolError" /* ToolError */: {
104676
- customConsole.error(source_default.red(`
104622
+ customConsole.error(import_chalk.default.red(`
104677
104623
 
104678
104624
  Tool error:`, event.tool));
104679
104625
  customConsole.error(event.error);
@@ -104753,7 +104699,7 @@ var import_lodash3 = __toESM(require_lodash(), 1);
104753
104699
  function addSharedOptions(command) {
104754
104700
  return command.option("-c --config <paths>", "Path to config file(s)", (value, prev) => prev.concat(value), []).option("--api-provider <provider>", "API provider").option("--model <model>", "Model ID").option("--api-key <key>", "API key").option("--max-messages <iterations>", "Maximum number of messages to send.", Number.parseInt).option("--budget <budget>", "Budget for the AI service.", Number.parseFloat).option("-v --verbose", "Enable verbose output. Use -v for level 1, -vv for level 2", (_value, prev) => prev + 1, 0).option("-d --base-dir <path>", "Base directory to run commands in").option("--agent <agent>", "Initial agent to use (default: architect)").option("--file <path...>", "File to include in the task").option("--silent", "Enable silent mode");
104755
104701
  }
104756
- function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
104702
+ function parseOptions(options, cwdArg, home = os.homedir(), env = getEnv()) {
104757
104703
  let cwd = cwdArg;
104758
104704
  if (options.baseDir) {
104759
104705
  process.chdir(options.baseDir);
@@ -104761,29 +104707,29 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
104761
104707
  console.log("Changed working directory to", cwd);
104762
104708
  }
104763
104709
  const config4 = loadConfig(options.config, cwd, home) ?? {};
104764
- const defaultProvider = options.apiProvider || env2.POLKA_API_PROVIDER || config4.defaultProvider;
104765
- const defaultModel = options.model || env2.POLKA_MODEL || config4.defaultModel;
104710
+ const defaultProvider = options.apiProvider || env.POLKA_API_PROVIDER || config4.defaultProvider;
104711
+ const defaultModel = options.model || env.POLKA_MODEL || config4.defaultModel;
104766
104712
  if (defaultProvider && defaultModel) {
104767
104713
  import_lodash3.set(config4, ["providers", defaultProvider, "defaultModel"], defaultModel);
104768
104714
  }
104769
- const apiKey = options.apiKey || env2.POLKA_API_KEY;
104715
+ const apiKey = options.apiKey || env.POLKA_API_KEY;
104770
104716
  if (apiKey) {
104771
104717
  if (!defaultProvider) {
104772
104718
  throw new Error("Must specify a provider if providing an API key");
104773
104719
  }
104774
104720
  import_lodash3.set(config4, ["providers", defaultProvider, "apiKey"], apiKey);
104775
104721
  }
104776
- if (env2.ANTHROPIC_API_KEY) {
104777
- import_lodash3.set(config4, ["providers", "anthropic" /* Anthropic */, "apiKey"], env2.ANTHROPIC_API_KEY);
104722
+ if (env.ANTHROPIC_API_KEY) {
104723
+ import_lodash3.set(config4, ["providers", "anthropic" /* Anthropic */, "apiKey"], env.ANTHROPIC_API_KEY);
104778
104724
  }
104779
- if (env2.DEEPSEEK_API_KEY) {
104780
- import_lodash3.set(config4, ["providers", "deepseek" /* DeepSeek */, "apiKey"], env2.DEEPSEEK_API_KEY);
104725
+ if (env.DEEPSEEK_API_KEY) {
104726
+ import_lodash3.set(config4, ["providers", "deepseek" /* DeepSeek */, "apiKey"], env.DEEPSEEK_API_KEY);
104781
104727
  }
104782
- if (env2.OPENROUTER_API_KEY) {
104783
- import_lodash3.set(config4, ["providers", "openrouter" /* OpenRouter */, "apiKey"], env2.OPENROUTER_API_KEY);
104728
+ if (env.OPENROUTER_API_KEY) {
104729
+ import_lodash3.set(config4, ["providers", "openrouter" /* OpenRouter */, "apiKey"], env.OPENROUTER_API_KEY);
104784
104730
  }
104785
- if (env2.OPENAI_API_KEY) {
104786
- import_lodash3.set(config4, ["providers", "openai" /* OpenAI */, "apiKey"], env2.OPENAI_API_KEY);
104731
+ if (env.OPENAI_API_KEY) {
104732
+ import_lodash3.set(config4, ["providers", "openai" /* OpenAI */, "apiKey"], env.OPENAI_API_KEY);
104787
104733
  }
104788
104734
  const providerConfig = new ApiProviderConfig({
104789
104735
  defaultProvider,
@@ -104791,7 +104737,7 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
104791
104737
  });
104792
104738
  return {
104793
104739
  maxMessageCount: options.maxMessageCount ?? config4.maxMessageCount ?? 100,
104794
- budget: options.budget ?? (env2.POLKA_BUDGET ? Number.parseFloat(env2.POLKA_BUDGET) : undefined) ?? config4.budget ?? 10,
104740
+ budget: options.budget ?? (env.POLKA_BUDGET ? Number.parseFloat(env.POLKA_BUDGET) : undefined) ?? config4.budget ?? 10,
104795
104741
  verbose: options.verbose ?? 0,
104796
104742
  config: config4,
104797
104743
  providerConfig,
@@ -104803,7 +104749,7 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
104803
104749
 
104804
104750
  // src/Runner.ts
104805
104751
  import { readFile as readFile2 } from "node:fs/promises";
104806
- import os3 from "node:os";
104752
+ import os2 from "node:os";
104807
104753
  var import_lodash4 = __toESM(require_lodash(), 1);
104808
104754
 
104809
104755
  // src/commandSummarizer.ts
@@ -104992,7 +104938,7 @@ class Runner {
104992
104938
  excludeFiles: options.config.excludeFiles,
104993
104939
  summaryThreshold: options.config.summaryThreshold
104994
104940
  };
104995
- const platform = os3.platform();
104941
+ const platform = os2.platform();
104996
104942
  const llms = {};
104997
104943
  const getOrCreateLlm = (agentName) => {
104998
104944
  const config4 = this.#options.providerConfig.getConfigForAgent(agentName);
@@ -105278,22 +105224,46 @@ var runChat = async (opts, command) => {
105278
105224
 
105279
105225
  // src/runWorkflow.ts
105280
105226
  import { spawnSync as spawnSync2 } from "node:child_process";
105281
- import os5 from "node:os";
105282
- // ../workflow/src/workflow.ts
105283
- async function run(workflow, input, stepFn) {
105284
- if (!stepFn) {
105227
+ import fs2 from "node:fs/promises";
105228
+ import os4 from "node:os";
105229
+
105230
+ // ../workflow/src/helpers.ts
105231
+ var makeStepFn = (fns) => {
105232
+ const resolvedFns = fns ?? (() => {
105285
105233
  const results = {};
105286
105234
  const counts = {};
105287
- stepFn = async (name18, fn) => {
105288
- counts[name18] = (counts[name18] || 0) + 1;
105289
- const key2 = `${name18}#${counts[name18]}`;
105290
- if (key2 in results) {
105291
- return results[key2];
105292
- }
105293
- const result = await fn();
105294
- results[key2] = result;
105295
- return result;
105235
+ return {
105236
+ getStepResult: async (key2) => {
105237
+ if (Object.hasOwn(results, key2)) {
105238
+ return { found: true, value: results[key2] };
105239
+ }
105240
+ return { found: false };
105241
+ },
105242
+ setStepResult: async (key2, value) => {
105243
+ results[key2] = value;
105244
+ },
105245
+ getAndIncrementCounts: async (key2) => {
105246
+ counts[key2] = (counts[key2] || 0) + 1;
105247
+ return counts[key2];
105248
+ }
105296
105249
  };
105250
+ })();
105251
+ return async (name18, fn) => {
105252
+ const currentCounts = await resolvedFns.getAndIncrementCounts(name18);
105253
+ const key2 = `${name18}#${currentCounts}`;
105254
+ const existingResult = await resolvedFns.getStepResult(key2);
105255
+ if (existingResult.found) {
105256
+ return existingResult.value;
105257
+ }
105258
+ const result = await fn();
105259
+ await resolvedFns.setStepResult(key2, result ?? undefined);
105260
+ return result;
105261
+ };
105262
+ };
105263
+ // ../workflow/src/workflow.ts
105264
+ async function run(workflow, input, stepFn) {
105265
+ if (!stepFn) {
105266
+ stepFn = makeStepFn();
105297
105267
  }
105298
105268
  const tools2 = new Proxy({}, {
105299
105269
  get: (_target, tool6) => {
@@ -105349,14 +105319,14 @@ async function run(workflow, input, stepFn) {
105349
105319
  var import_lodash6 = __toESM(require_lodash(), 1);
105350
105320
 
105351
105321
  // ../../node_modules/ora/index.js
105352
- import process10 from "node:process";
105322
+ import process9 from "node:process";
105353
105323
 
105354
105324
  // ../../node_modules/ora/node_modules/chalk/source/vendor/ansi-styles/index.js
105355
- var ANSI_BACKGROUND_OFFSET2 = 10;
105356
- var wrapAnsi162 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
105357
- var wrapAnsi2562 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
105358
- var wrapAnsi16m2 = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
105359
- var styles3 = {
105325
+ var ANSI_BACKGROUND_OFFSET = 10;
105326
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
105327
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
105328
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
105329
+ var styles = {
105360
105330
  modifier: {
105361
105331
  reset: [0, 0],
105362
105332
  bold: [1, 22],
@@ -105409,39 +105379,39 @@ var styles3 = {
105409
105379
  bgWhiteBright: [107, 49]
105410
105380
  }
105411
105381
  };
105412
- var modifierNames2 = Object.keys(styles3.modifier);
105413
- var foregroundColorNames2 = Object.keys(styles3.color);
105414
- var backgroundColorNames2 = Object.keys(styles3.bgColor);
105415
- var colorNames2 = [...foregroundColorNames2, ...backgroundColorNames2];
105416
- function assembleStyles2() {
105382
+ var modifierNames = Object.keys(styles.modifier);
105383
+ var foregroundColorNames = Object.keys(styles.color);
105384
+ var backgroundColorNames = Object.keys(styles.bgColor);
105385
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
105386
+ function assembleStyles() {
105417
105387
  const codes = new Map;
105418
- for (const [groupName, group] of Object.entries(styles3)) {
105388
+ for (const [groupName, group] of Object.entries(styles)) {
105419
105389
  for (const [styleName, style] of Object.entries(group)) {
105420
- styles3[styleName] = {
105390
+ styles[styleName] = {
105421
105391
  open: `\x1B[${style[0]}m`,
105422
105392
  close: `\x1B[${style[1]}m`
105423
105393
  };
105424
- group[styleName] = styles3[styleName];
105394
+ group[styleName] = styles[styleName];
105425
105395
  codes.set(style[0], style[1]);
105426
105396
  }
105427
- Object.defineProperty(styles3, groupName, {
105397
+ Object.defineProperty(styles, groupName, {
105428
105398
  value: group,
105429
105399
  enumerable: false
105430
105400
  });
105431
105401
  }
105432
- Object.defineProperty(styles3, "codes", {
105402
+ Object.defineProperty(styles, "codes", {
105433
105403
  value: codes,
105434
105404
  enumerable: false
105435
105405
  });
105436
- styles3.color.close = "\x1B[39m";
105437
- styles3.bgColor.close = "\x1B[49m";
105438
- styles3.color.ansi = wrapAnsi162();
105439
- styles3.color.ansi256 = wrapAnsi2562();
105440
- styles3.color.ansi16m = wrapAnsi16m2();
105441
- styles3.bgColor.ansi = wrapAnsi162(ANSI_BACKGROUND_OFFSET2);
105442
- styles3.bgColor.ansi256 = wrapAnsi2562(ANSI_BACKGROUND_OFFSET2);
105443
- styles3.bgColor.ansi16m = wrapAnsi16m2(ANSI_BACKGROUND_OFFSET2);
105444
- Object.defineProperties(styles3, {
105406
+ styles.color.close = "\x1B[39m";
105407
+ styles.bgColor.close = "\x1B[49m";
105408
+ styles.color.ansi = wrapAnsi16();
105409
+ styles.color.ansi256 = wrapAnsi256();
105410
+ styles.color.ansi16m = wrapAnsi16m();
105411
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
105412
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
105413
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
105414
+ Object.defineProperties(styles, {
105445
105415
  rgbToAnsi256: {
105446
105416
  value(red, green, blue) {
105447
105417
  if (red === green && green === blue) {
@@ -105477,7 +105447,7 @@ function assembleStyles2() {
105477
105447
  enumerable: false
105478
105448
  },
105479
105449
  hexToAnsi256: {
105480
- value: (hex3) => styles3.rgbToAnsi256(...styles3.hexToRgb(hex3)),
105450
+ value: (hex3) => styles.rgbToAnsi256(...styles.hexToRgb(hex3)),
105481
105451
  enumerable: false
105482
105452
  },
105483
105453
  ansi256ToAnsi: {
@@ -105515,48 +105485,48 @@ function assembleStyles2() {
105515
105485
  enumerable: false
105516
105486
  },
105517
105487
  rgbToAnsi: {
105518
- value: (red, green, blue) => styles3.ansi256ToAnsi(styles3.rgbToAnsi256(red, green, blue)),
105488
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
105519
105489
  enumerable: false
105520
105490
  },
105521
105491
  hexToAnsi: {
105522
- value: (hex3) => styles3.ansi256ToAnsi(styles3.hexToAnsi256(hex3)),
105492
+ value: (hex3) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex3)),
105523
105493
  enumerable: false
105524
105494
  }
105525
105495
  });
105526
- return styles3;
105496
+ return styles;
105527
105497
  }
105528
- var ansiStyles2 = assembleStyles2();
105529
- var ansi_styles_default2 = ansiStyles2;
105498
+ var ansiStyles = assembleStyles();
105499
+ var ansi_styles_default = ansiStyles;
105530
105500
 
105531
105501
  // ../../node_modules/ora/node_modules/chalk/source/vendor/supports-color/index.js
105532
- import process5 from "node:process";
105533
- import os4 from "node:os";
105534
- import tty2 from "node:tty";
105535
- function hasFlag2(flag, argv = globalThis.Deno ? globalThis.Deno.args : process5.argv) {
105502
+ import process4 from "node:process";
105503
+ import os3 from "node:os";
105504
+ import tty from "node:tty";
105505
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process4.argv) {
105536
105506
  const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
105537
105507
  const position = argv.indexOf(prefix + flag);
105538
105508
  const terminatorPosition = argv.indexOf("--");
105539
105509
  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
105540
105510
  }
105541
- var { env: env2 } = process5;
105542
- var flagForceColor2;
105543
- if (hasFlag2("no-color") || hasFlag2("no-colors") || hasFlag2("color=false") || hasFlag2("color=never")) {
105544
- flagForceColor2 = 0;
105545
- } else if (hasFlag2("color") || hasFlag2("colors") || hasFlag2("color=true") || hasFlag2("color=always")) {
105546
- flagForceColor2 = 1;
105511
+ var { env } = process4;
105512
+ var flagForceColor;
105513
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
105514
+ flagForceColor = 0;
105515
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
105516
+ flagForceColor = 1;
105547
105517
  }
105548
- function envForceColor2() {
105549
- if ("FORCE_COLOR" in env2) {
105550
- if (env2.FORCE_COLOR === "true") {
105518
+ function envForceColor() {
105519
+ if ("FORCE_COLOR" in env) {
105520
+ if (env.FORCE_COLOR === "true") {
105551
105521
  return 1;
105552
105522
  }
105553
- if (env2.FORCE_COLOR === "false") {
105523
+ if (env.FORCE_COLOR === "false") {
105554
105524
  return 0;
105555
105525
  }
105556
- return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
105526
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
105557
105527
  }
105558
105528
  }
105559
- function translateLevel2(level) {
105529
+ function translateLevel(level) {
105560
105530
  if (level === 0) {
105561
105531
  return false;
105562
105532
  }
@@ -105567,67 +105537,67 @@ function translateLevel2(level) {
105567
105537
  has16m: level >= 3
105568
105538
  };
105569
105539
  }
105570
- function _supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
105571
- const noFlagForceColor = envForceColor2();
105540
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
105541
+ const noFlagForceColor = envForceColor();
105572
105542
  if (noFlagForceColor !== undefined) {
105573
- flagForceColor2 = noFlagForceColor;
105543
+ flagForceColor = noFlagForceColor;
105574
105544
  }
105575
- const forceColor = sniffFlags ? flagForceColor2 : noFlagForceColor;
105545
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
105576
105546
  if (forceColor === 0) {
105577
105547
  return 0;
105578
105548
  }
105579
105549
  if (sniffFlags) {
105580
- if (hasFlag2("color=16m") || hasFlag2("color=full") || hasFlag2("color=truecolor")) {
105550
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
105581
105551
  return 3;
105582
105552
  }
105583
- if (hasFlag2("color=256")) {
105553
+ if (hasFlag("color=256")) {
105584
105554
  return 2;
105585
105555
  }
105586
105556
  }
105587
- if ("TF_BUILD" in env2 && "AGENT_NAME" in env2) {
105557
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
105588
105558
  return 1;
105589
105559
  }
105590
105560
  if (haveStream && !streamIsTTY && forceColor === undefined) {
105591
105561
  return 0;
105592
105562
  }
105593
105563
  const min = forceColor || 0;
105594
- if (env2.TERM === "dumb") {
105564
+ if (env.TERM === "dumb") {
105595
105565
  return min;
105596
105566
  }
105597
- if (process5.platform === "win32") {
105598
- const osRelease = os4.release().split(".");
105567
+ if (process4.platform === "win32") {
105568
+ const osRelease = os3.release().split(".");
105599
105569
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
105600
105570
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
105601
105571
  }
105602
105572
  return 1;
105603
105573
  }
105604
- if ("CI" in env2) {
105605
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key2) => (key2 in env2))) {
105574
+ if ("CI" in env) {
105575
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key2) => (key2 in env))) {
105606
105576
  return 3;
105607
105577
  }
105608
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env2)) || env2.CI_NAME === "codeship") {
105578
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
105609
105579
  return 1;
105610
105580
  }
105611
105581
  return min;
105612
105582
  }
105613
- if ("TEAMCITY_VERSION" in env2) {
105614
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
105583
+ if ("TEAMCITY_VERSION" in env) {
105584
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
105615
105585
  }
105616
- if (env2.COLORTERM === "truecolor") {
105586
+ if (env.COLORTERM === "truecolor") {
105617
105587
  return 3;
105618
105588
  }
105619
- if (env2.TERM === "xterm-kitty") {
105589
+ if (env.TERM === "xterm-kitty") {
105620
105590
  return 3;
105621
105591
  }
105622
- if (env2.TERM === "xterm-ghostty") {
105592
+ if (env.TERM === "xterm-ghostty") {
105623
105593
  return 3;
105624
105594
  }
105625
- if (env2.TERM === "wezterm") {
105595
+ if (env.TERM === "wezterm") {
105626
105596
  return 3;
105627
105597
  }
105628
- if ("TERM_PROGRAM" in env2) {
105629
- const version3 = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
105630
- switch (env2.TERM_PROGRAM) {
105598
+ if ("TERM_PROGRAM" in env) {
105599
+ const version3 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
105600
+ switch (env.TERM_PROGRAM) {
105631
105601
  case "iTerm.app": {
105632
105602
  return version3 >= 3 ? 3 : 2;
105633
105603
  }
@@ -105636,32 +105606,32 @@ function _supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
105636
105606
  }
105637
105607
  }
105638
105608
  }
105639
- if (/-256(color)?$/i.test(env2.TERM)) {
105609
+ if (/-256(color)?$/i.test(env.TERM)) {
105640
105610
  return 2;
105641
105611
  }
105642
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
105612
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
105643
105613
  return 1;
105644
105614
  }
105645
- if ("COLORTERM" in env2) {
105615
+ if ("COLORTERM" in env) {
105646
105616
  return 1;
105647
105617
  }
105648
105618
  return min;
105649
105619
  }
105650
- function createSupportsColor2(stream, options = {}) {
105651
- const level = _supportsColor2(stream, {
105620
+ function createSupportsColor(stream, options = {}) {
105621
+ const level = _supportsColor(stream, {
105652
105622
  streamIsTTY: stream && stream.isTTY,
105653
105623
  ...options
105654
105624
  });
105655
- return translateLevel2(level);
105625
+ return translateLevel(level);
105656
105626
  }
105657
- var supportsColor2 = {
105658
- stdout: createSupportsColor2({ isTTY: tty2.isatty(1) }),
105659
- stderr: createSupportsColor2({ isTTY: tty2.isatty(2) })
105627
+ var supportsColor = {
105628
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
105629
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
105660
105630
  };
105661
- var supports_color_default2 = supportsColor2;
105631
+ var supports_color_default = supportsColor;
105662
105632
 
105663
105633
  // ../../node_modules/ora/node_modules/chalk/source/utilities.js
105664
- function stringReplaceAll2(string4, substring, replacer) {
105634
+ function stringReplaceAll(string4, substring, replacer) {
105665
105635
  let index = string4.indexOf(substring);
105666
105636
  if (index === -1) {
105667
105637
  return string4;
@@ -105677,7 +105647,7 @@ function stringReplaceAll2(string4, substring, replacer) {
105677
105647
  returnValue += string4.slice(endIndex);
105678
105648
  return returnValue;
105679
105649
  }
105680
- function stringEncaseCRLFWithFirstIndex2(string4, prefix, postfix, index) {
105650
+ function stringEncaseCRLFWithFirstIndex(string4, prefix, postfix, index) {
105681
105651
  let endIndex = 0;
105682
105652
  let returnValue = "";
105683
105653
  do {
@@ -105694,100 +105664,100 @@ function stringEncaseCRLFWithFirstIndex2(string4, prefix, postfix, index) {
105694
105664
  }
105695
105665
 
105696
105666
  // ../../node_modules/ora/node_modules/chalk/source/index.js
105697
- var { stdout: stdoutColor2, stderr: stderrColor2 } = supports_color_default2;
105698
- var GENERATOR2 = Symbol("GENERATOR");
105699
- var STYLER2 = Symbol("STYLER");
105700
- var IS_EMPTY2 = Symbol("IS_EMPTY");
105701
- var levelMapping2 = [
105667
+ var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
105668
+ var GENERATOR = Symbol("GENERATOR");
105669
+ var STYLER = Symbol("STYLER");
105670
+ var IS_EMPTY = Symbol("IS_EMPTY");
105671
+ var levelMapping = [
105702
105672
  "ansi",
105703
105673
  "ansi",
105704
105674
  "ansi256",
105705
105675
  "ansi16m"
105706
105676
  ];
105707
- var styles4 = Object.create(null);
105708
- var applyOptions2 = (object3, options = {}) => {
105677
+ var styles2 = Object.create(null);
105678
+ var applyOptions = (object3, options = {}) => {
105709
105679
  if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
105710
105680
  throw new Error("The `level` option should be an integer from 0 to 3");
105711
105681
  }
105712
- const colorLevel = stdoutColor2 ? stdoutColor2.level : 0;
105682
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
105713
105683
  object3.level = options.level === undefined ? colorLevel : options.level;
105714
105684
  };
105715
- var chalkFactory2 = (options) => {
105685
+ var chalkFactory = (options) => {
105716
105686
  const chalk2 = (...strings) => strings.join(" ");
105717
- applyOptions2(chalk2, options);
105718
- Object.setPrototypeOf(chalk2, createChalk2.prototype);
105687
+ applyOptions(chalk2, options);
105688
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
105719
105689
  return chalk2;
105720
105690
  };
105721
- function createChalk2(options) {
105722
- return chalkFactory2(options);
105691
+ function createChalk(options) {
105692
+ return chalkFactory(options);
105723
105693
  }
105724
- Object.setPrototypeOf(createChalk2.prototype, Function.prototype);
105725
- for (const [styleName, style] of Object.entries(ansi_styles_default2)) {
105726
- styles4[styleName] = {
105694
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
105695
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
105696
+ styles2[styleName] = {
105727
105697
  get() {
105728
- const builder = createBuilder2(this, createStyler2(style.open, style.close, this[STYLER2]), this[IS_EMPTY2]);
105698
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
105729
105699
  Object.defineProperty(this, styleName, { value: builder });
105730
105700
  return builder;
105731
105701
  }
105732
105702
  };
105733
105703
  }
105734
- styles4.visible = {
105704
+ styles2.visible = {
105735
105705
  get() {
105736
- const builder = createBuilder2(this, this[STYLER2], true);
105706
+ const builder = createBuilder(this, this[STYLER], true);
105737
105707
  Object.defineProperty(this, "visible", { value: builder });
105738
105708
  return builder;
105739
105709
  }
105740
105710
  };
105741
- var getModelAnsi2 = (model, level, type, ...arguments_) => {
105711
+ var getModelAnsi = (model, level, type, ...arguments_) => {
105742
105712
  if (model === "rgb") {
105743
105713
  if (level === "ansi16m") {
105744
- return ansi_styles_default2[type].ansi16m(...arguments_);
105714
+ return ansi_styles_default[type].ansi16m(...arguments_);
105745
105715
  }
105746
105716
  if (level === "ansi256") {
105747
- return ansi_styles_default2[type].ansi256(ansi_styles_default2.rgbToAnsi256(...arguments_));
105717
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
105748
105718
  }
105749
- return ansi_styles_default2[type].ansi(ansi_styles_default2.rgbToAnsi(...arguments_));
105719
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
105750
105720
  }
105751
105721
  if (model === "hex") {
105752
- return getModelAnsi2("rgb", level, type, ...ansi_styles_default2.hexToRgb(...arguments_));
105722
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
105753
105723
  }
105754
- return ansi_styles_default2[type][model](...arguments_);
105724
+ return ansi_styles_default[type][model](...arguments_);
105755
105725
  };
105756
- var usedModels2 = ["rgb", "hex", "ansi256"];
105757
- for (const model of usedModels2) {
105758
- styles4[model] = {
105726
+ var usedModels = ["rgb", "hex", "ansi256"];
105727
+ for (const model of usedModels) {
105728
+ styles2[model] = {
105759
105729
  get() {
105760
105730
  const { level } = this;
105761
105731
  return function(...arguments_) {
105762
- const styler = createStyler2(getModelAnsi2(model, levelMapping2[level], "color", ...arguments_), ansi_styles_default2.color.close, this[STYLER2]);
105763
- return createBuilder2(this, styler, this[IS_EMPTY2]);
105732
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
105733
+ return createBuilder(this, styler, this[IS_EMPTY]);
105764
105734
  };
105765
105735
  }
105766
105736
  };
105767
105737
  const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
105768
- styles4[bgModel] = {
105738
+ styles2[bgModel] = {
105769
105739
  get() {
105770
105740
  const { level } = this;
105771
105741
  return function(...arguments_) {
105772
- const styler = createStyler2(getModelAnsi2(model, levelMapping2[level], "bgColor", ...arguments_), ansi_styles_default2.bgColor.close, this[STYLER2]);
105773
- return createBuilder2(this, styler, this[IS_EMPTY2]);
105742
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
105743
+ return createBuilder(this, styler, this[IS_EMPTY]);
105774
105744
  };
105775
105745
  }
105776
105746
  };
105777
105747
  }
105778
- var proto2 = Object.defineProperties(() => {}, {
105779
- ...styles4,
105748
+ var proto = Object.defineProperties(() => {}, {
105749
+ ...styles2,
105780
105750
  level: {
105781
105751
  enumerable: true,
105782
105752
  get() {
105783
- return this[GENERATOR2].level;
105753
+ return this[GENERATOR].level;
105784
105754
  },
105785
105755
  set(level) {
105786
- this[GENERATOR2].level = level;
105756
+ this[GENERATOR].level = level;
105787
105757
  }
105788
105758
  }
105789
105759
  });
105790
- var createStyler2 = (open, close, parent) => {
105760
+ var createStyler = (open, close, parent) => {
105791
105761
  let openAll;
105792
105762
  let closeAll;
105793
105763
  if (parent === undefined) {
@@ -105805,46 +105775,46 @@ var createStyler2 = (open, close, parent) => {
105805
105775
  parent
105806
105776
  };
105807
105777
  };
105808
- var createBuilder2 = (self2, _styler, _isEmpty) => {
105809
- const builder = (...arguments_) => applyStyle2(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
105810
- Object.setPrototypeOf(builder, proto2);
105811
- builder[GENERATOR2] = self2;
105812
- builder[STYLER2] = _styler;
105813
- builder[IS_EMPTY2] = _isEmpty;
105778
+ var createBuilder = (self2, _styler, _isEmpty) => {
105779
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
105780
+ Object.setPrototypeOf(builder, proto);
105781
+ builder[GENERATOR] = self2;
105782
+ builder[STYLER] = _styler;
105783
+ builder[IS_EMPTY] = _isEmpty;
105814
105784
  return builder;
105815
105785
  };
105816
- var applyStyle2 = (self2, string4) => {
105786
+ var applyStyle = (self2, string4) => {
105817
105787
  if (self2.level <= 0 || !string4) {
105818
- return self2[IS_EMPTY2] ? "" : string4;
105788
+ return self2[IS_EMPTY] ? "" : string4;
105819
105789
  }
105820
- let styler = self2[STYLER2];
105790
+ let styler = self2[STYLER];
105821
105791
  if (styler === undefined) {
105822
105792
  return string4;
105823
105793
  }
105824
105794
  const { openAll, closeAll } = styler;
105825
105795
  if (string4.includes("\x1B")) {
105826
105796
  while (styler !== undefined) {
105827
- string4 = stringReplaceAll2(string4, styler.close, styler.open);
105797
+ string4 = stringReplaceAll(string4, styler.close, styler.open);
105828
105798
  styler = styler.parent;
105829
105799
  }
105830
105800
  }
105831
105801
  const lfIndex = string4.indexOf(`
105832
105802
  `);
105833
105803
  if (lfIndex !== -1) {
105834
- string4 = stringEncaseCRLFWithFirstIndex2(string4, closeAll, openAll, lfIndex);
105804
+ string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
105835
105805
  }
105836
105806
  return openAll + string4 + closeAll;
105837
105807
  };
105838
- Object.defineProperties(createChalk2.prototype, styles4);
105839
- var chalk2 = createChalk2();
105840
- var chalkStderr2 = createChalk2({ level: stderrColor2 ? stderrColor2.level : 0 });
105841
- var source_default2 = chalk2;
105808
+ Object.defineProperties(createChalk.prototype, styles2);
105809
+ var chalk2 = createChalk();
105810
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
105811
+ var source_default = chalk2;
105842
105812
 
105843
105813
  // ../../node_modules/cli-cursor/index.js
105844
- import process7 from "node:process";
105814
+ import process6 from "node:process";
105845
105815
 
105846
105816
  // ../../node_modules/restore-cursor/index.js
105847
- import process6 from "node:process";
105817
+ import process5 from "node:process";
105848
105818
 
105849
105819
  // ../../node_modules/mimic-function/index.js
105850
105820
  var copyProperty = (to, from, property, ignoreNonConfigurable) => {
@@ -105924,7 +105894,7 @@ onetime.callCount = (function_) => {
105924
105894
  var onetime_default = onetime;
105925
105895
 
105926
105896
  // ../../node_modules/restore-cursor/index.js
105927
- var terminal = process6.stderr.isTTY ? process6.stderr : process6.stdout.isTTY ? process6.stdout : undefined;
105897
+ var terminal = process5.stderr.isTTY ? process5.stderr : process5.stdout.isTTY ? process5.stdout : undefined;
105928
105898
  var restoreCursor = terminal ? onetime_default(() => {
105929
105899
  onExit(() => {
105930
105900
  terminal.write("\x1B[?25h");
@@ -105935,14 +105905,14 @@ var restore_cursor_default = restoreCursor;
105935
105905
  // ../../node_modules/cli-cursor/index.js
105936
105906
  var isHidden = false;
105937
105907
  var cliCursor = {};
105938
- cliCursor.show = (writableStream = process7.stderr) => {
105908
+ cliCursor.show = (writableStream = process6.stderr) => {
105939
105909
  if (!writableStream.isTTY) {
105940
105910
  return;
105941
105911
  }
105942
105912
  isHidden = false;
105943
105913
  writableStream.write("\x1B[?25h");
105944
105914
  };
105945
- cliCursor.hide = (writableStream = process7.stderr) => {
105915
+ cliCursor.hide = (writableStream = process6.stderr) => {
105946
105916
  if (!writableStream.isTTY) {
105947
105917
  return;
105948
105918
  }
@@ -107642,8 +107612,8 @@ __export(exports_symbols, {
107642
107612
  });
107643
107613
 
107644
107614
  // ../../node_modules/yoctocolors/base.js
107645
- import tty3 from "node:tty";
107646
- var hasColors = tty3?.WriteStream?.prototype?.hasColors?.() ?? false;
107615
+ import tty2 from "node:tty";
107616
+ var hasColors = tty2?.WriteStream?.prototype?.hasColors?.() ?? false;
107647
107617
  var format = (open, close) => {
107648
107618
  if (!hasColors) {
107649
107619
  return (input) => input;
@@ -107712,14 +107682,14 @@ var bgCyanBright = format(106, 49);
107712
107682
  var bgWhiteBright = format(107, 49);
107713
107683
 
107714
107684
  // ../../node_modules/is-unicode-supported/index.js
107715
- import process8 from "node:process";
107685
+ import process7 from "node:process";
107716
107686
  function isUnicodeSupported2() {
107717
- const { env: env3 } = process8;
107718
- const { TERM, TERM_PROGRAM } = env3;
107719
- if (process8.platform !== "win32") {
107687
+ const { env: env2 } = process7;
107688
+ const { TERM, TERM_PROGRAM } = env2;
107689
+ if (process7.platform !== "win32") {
107720
107690
  return TERM !== "linux";
107721
107691
  }
107722
- return Boolean(env3.WT_SESSION) || Boolean(env3.TERMINUS_SUBLIME) || env3.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env3.TERMINAL_EMULATOR === "JetBrains-JediTerm";
107692
+ return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
107723
107693
  }
107724
107694
 
107725
107695
  // ../../node_modules/ora/node_modules/log-symbols/symbols.js
@@ -107832,7 +107802,7 @@ function isInteractive({ stream = process.stdout } = {}) {
107832
107802
  }
107833
107803
 
107834
107804
  // ../../node_modules/stdin-discarder/index.js
107835
- import process9 from "node:process";
107805
+ import process8 from "node:process";
107836
107806
  var ASCII_ETX_CODE = 3;
107837
107807
 
107838
107808
  class StdinDiscarder {
@@ -107853,24 +107823,24 @@ class StdinDiscarder {
107853
107823
  }
107854
107824
  }
107855
107825
  #realStart() {
107856
- if (process9.platform === "win32" || !process9.stdin.isTTY) {
107826
+ if (process8.platform === "win32" || !process8.stdin.isTTY) {
107857
107827
  return;
107858
107828
  }
107859
- process9.stdin.setRawMode(true);
107860
- process9.stdin.on("data", this.#handleInput);
107861
- process9.stdin.resume();
107829
+ process8.stdin.setRawMode(true);
107830
+ process8.stdin.on("data", this.#handleInput);
107831
+ process8.stdin.resume();
107862
107832
  }
107863
107833
  #realStop() {
107864
- if (!process9.stdin.isTTY) {
107834
+ if (!process8.stdin.isTTY) {
107865
107835
  return;
107866
107836
  }
107867
- process9.stdin.off("data", this.#handleInput);
107868
- process9.stdin.pause();
107869
- process9.stdin.setRawMode(false);
107837
+ process8.stdin.off("data", this.#handleInput);
107838
+ process8.stdin.pause();
107839
+ process8.stdin.setRawMode(false);
107870
107840
  }
107871
107841
  #handleInput(chunk) {
107872
107842
  if (chunk[0] === ASCII_ETX_CODE) {
107873
- process9.emit("SIGINT");
107843
+ process8.emit("SIGINT");
107874
107844
  }
107875
107845
  }
107876
107846
  }
@@ -107905,7 +107875,7 @@ class Ora {
107905
107875
  }
107906
107876
  this.#options = {
107907
107877
  color: "cyan",
107908
- stream: process10.stderr,
107878
+ stream: process9.stderr,
107909
107879
  discardStdin: true,
107910
107880
  hideCursor: true,
107911
107881
  ...options
@@ -107920,7 +107890,7 @@ class Ora {
107920
107890
  this.prefixText = this.#options.prefixText;
107921
107891
  this.suffixText = this.#options.suffixText;
107922
107892
  this.indent = this.#options.indent;
107923
- if (process10.env.NODE_ENV === "test") {
107893
+ if (process9.env.NODE_ENV === "test") {
107924
107894
  this._stream = this.#stream;
107925
107895
  this._isEnabled = this.#isEnabled;
107926
107896
  Object.defineProperty(this, "_linesToClear", {
@@ -108062,7 +108032,7 @@ class Ora {
108062
108032
  const { frames } = this.#spinner;
108063
108033
  let frame = frames[this.#frameIndex];
108064
108034
  if (this.color) {
108065
- frame = source_default2[this.color](frame);
108035
+ frame = source_default[this.color](frame);
108066
108036
  }
108067
108037
  const fullPrefixText = this.#getFullPrefixText(this.#prefixText, " ");
108068
108038
  const fullText = typeof this.text === "string" ? " " + this.text : "";
@@ -108128,7 +108098,7 @@ class Ora {
108128
108098
  if (this.#options.hideCursor) {
108129
108099
  cli_cursor_default.hide(this.#stream);
108130
108100
  }
108131
- if (this.#options.discardStdin && process10.stdin.isTTY) {
108101
+ if (this.#options.discardStdin && process9.stdin.isTTY) {
108132
108102
  this.#isDiscardingStdin = true;
108133
108103
  stdin_discarder_default.start();
108134
108104
  }
@@ -108146,7 +108116,7 @@ class Ora {
108146
108116
  cli_cursor_default.show(this.#stream);
108147
108117
  }
108148
108118
  }
108149
- if (this.#options.discardStdin && process10.stdin.isTTY && this.#isDiscardingStdin) {
108119
+ if (this.#options.discardStdin && process9.stdin.isTTY && this.#isDiscardingStdin) {
108150
108120
  stdin_discarder_default.stop();
108151
108121
  this.#isDiscardingStdin = false;
108152
108122
  }
@@ -108395,7 +108365,6 @@ async function handleToolCall(toolCall, context) {
108395
108365
  switch (toolCall.tool) {
108396
108366
  case "invokeAgent": {
108397
108367
  context.spinner.stop();
108398
- console.log();
108399
108368
  const input = toolCall.input;
108400
108369
  const model = await context.getModel(input.agent);
108401
108370
  const AgentClass = agentRegistry[input.agent] ?? WorkflowAgent;
@@ -108417,23 +108386,42 @@ async function handleToolCall(toolCall, context) {
108417
108386
  const userPrompt = input.messages.filter((m) => typeof m === "string" || m.type !== "system").map((m) => typeof m === "string" ? m : m.content).join(`
108418
108387
 
108419
108388
  `);
108420
- const exitReason = await agent.start(userPrompt);
108389
+ let exitReason = await agent.start(userPrompt);
108421
108390
  context.spinner.start();
108422
- if (exitReason.type !== "Exit" /* Exit */) {
108423
- throw new Error(`Agent exited for an unhandled reason: ${JSON.stringify(exitReason)}`);
108424
- }
108425
- const parsed = parseJsonFromMarkdown(exitReason.message);
108426
- if (!parsed.success) {
108427
- throw new Error(parsed.error);
108428
- }
108429
- if (input.outputSchema) {
108430
- const validated = input.outputSchema.safeParse(parsed.data);
108431
- if (!validated.success) {
108432
- throw new Error(validated.error.message);
108391
+ for (let i = 0;i < 5; i++) {
108392
+ if (exitReason.type !== "Exit" /* Exit */) {
108393
+ throw new Error(`Agent exited for an unhandled reason: ${JSON.stringify(exitReason)}`);
108394
+ }
108395
+ const parsed = parseJsonFromMarkdown(exitReason.message);
108396
+ if (!parsed.success) {
108397
+ const errorMessage = `Failed to parse JSON from markdown. Error: ${parsed.error}. Please correct the output.`;
108398
+ if (i < 4) {
108399
+ context.spinner.stop();
108400
+ exitReason = await agent.continueTask(errorMessage);
108401
+ context.spinner.start();
108402
+ continue;
108403
+ } else {
108404
+ throw new Error(errorMessage);
108405
+ }
108406
+ }
108407
+ if (input.outputSchema) {
108408
+ const validated = input.outputSchema.safeParse(parsed.data);
108409
+ if (!validated.success) {
108410
+ const errorMessage = `Output validation failed. Error: ${zod_default.prettifyError(validated.error)}. Please correct the output.`;
108411
+ if (i < 4) {
108412
+ context.spinner.stop();
108413
+ exitReason = await agent.continueTask(errorMessage);
108414
+ context.spinner.start();
108415
+ continue;
108416
+ } else {
108417
+ throw new Error(zod_default.prettifyError(validated.error));
108418
+ }
108419
+ }
108420
+ return validated.data;
108433
108421
  }
108434
- return validated.data;
108422
+ return parsed.data;
108435
108423
  }
108436
- return parsed.data;
108424
+ throw new Error("Agent failed to produce valid output after 5 retries.");
108437
108425
  }
108438
108426
  case "createPullRequest": {
108439
108427
  const { title, description } = toolCall.input;
@@ -108445,7 +108433,6 @@ async function handleToolCall(toolCall, context) {
108445
108433
  case "createCommit": {
108446
108434
  const { message } = toolCall.input;
108447
108435
  context.spinner.stop();
108448
- console.log();
108449
108436
  const result = spawnSync2("git", ["commit", "-m", message], { stdio: "inherit" });
108450
108437
  if (result.status !== 0) {
108451
108438
  throw new Error("Commit failed");
@@ -108455,7 +108442,6 @@ async function handleToolCall(toolCall, context) {
108455
108442
  }
108456
108443
  case "printChangeFile": {
108457
108444
  context.spinner.stop();
108458
- console.log();
108459
108445
  const { stagedFiles, unstagedFiles } = getLocalChanges();
108460
108446
  if (stagedFiles.length === 0 && unstagedFiles.length === 0) {
108461
108447
  console.log("No changes to commit.");
@@ -108480,7 +108466,6 @@ Unstaged files:`);
108480
108466
  case "confirm": {
108481
108467
  const { message } = toolCall.input;
108482
108468
  context.spinner.stop();
108483
- console.log();
108484
108469
  await new Promise((resolve7) => setTimeout(resolve7, 50));
108485
108470
  try {
108486
108471
  const result = await esm_default2({ message });
@@ -108490,6 +108475,23 @@ Unstaged files:`);
108490
108475
  throw new UserCancelledError;
108491
108476
  }
108492
108477
  }
108478
+ case "input": {
108479
+ const { message, default: defaultValue } = toolCall.input;
108480
+ context.spinner.stop();
108481
+ await new Promise((resolve7) => setTimeout(resolve7, 50));
108482
+ try {
108483
+ const result = await esm_default3({ message, default: defaultValue });
108484
+ context.spinner.start();
108485
+ return result;
108486
+ } catch (_e) {
108487
+ throw new UserCancelledError;
108488
+ }
108489
+ }
108490
+ case "writeToFile": {
108491
+ const { path, content } = toolCall.input;
108492
+ await fs2.writeFile(path, content);
108493
+ return {};
108494
+ }
108493
108495
  default:
108494
108496
  throw new Error(`Unknown tool: ${String(toolCall.tool)}`);
108495
108497
  }
@@ -108514,7 +108516,7 @@ async function runWorkflow(commandName, workflow2, command, workflowInput, requi
108514
108516
  const agentConfig = providerConfig.getConfigForCommand(commandName);
108515
108517
  const parameters = {
108516
108518
  toolFormat: config4.toolFormat,
108517
- os: os5.platform(),
108519
+ os: os4.platform(),
108518
108520
  policies: [EnableCachePolicy],
108519
108521
  modelParameters: agentConfig?.parameters,
108520
108522
  scripts: config4.scripts,
@@ -108570,9 +108572,7 @@ async function runWorkflow(commandName, workflow2, command, workflowInput, requi
108570
108572
  spinner.warn("Workflow cancelled by user.");
108571
108573
  } else {
108572
108574
  spinner.fail(`Workflow failed: ${error44.message}`);
108573
- if (verbose > 1) {
108574
- logger.error(error44);
108575
- }
108575
+ logger.error(error44);
108576
108576
  }
108577
108577
  }
108578
108578
  spinner.stop();
@@ -108899,6 +108899,96 @@ ${provider3.toUpperCase()}_API_KEY=${providerConfig.apiKey}`;
108899
108899
  return { configPath };
108900
108900
  }
108901
108901
  };
108902
+ // src/workflows/plan.workflow.ts
108903
+ var PlanSchema = exports_external.object({
108904
+ plan: exports_external.string().optional(),
108905
+ ready: exports_external.boolean(),
108906
+ question: exports_external.string().optional()
108907
+ });
108908
+ var PLAN_PROMPT = `
108909
+ You are an expert planner. Your goal is to create a detailed plan for a given task.
108910
+
108911
+ The user has provided a task:
108912
+ <task>
108913
+ {task}
108914
+ </task>
108915
+
108916
+ And optionally, the content of an existing plan file:
108917
+ <plan_file>
108918
+ {fileContent}
108919
+ </plan_file>
108920
+
108921
+ Your tasks are:
108922
+ 1. Analyze the task and the existing plan (if any).
108923
+ 2. If the requirements are clear and you can generate or update the plan, set "ready" to true and provide the plan in the "plan" field.
108924
+ 3. If the requirements are not clear, set "ready" to false and ask a clarifying question in the "question" field.
108925
+
108926
+ Respond with a JSON object that matches the following schema:
108927
+ {
108928
+ "plan": "The generated or updated plan.",
108929
+ "ready": true,
108930
+ "question": "The clarifying question to ask the user."
108931
+ }
108932
+ `;
108933
+ var planWorkflow = {
108934
+ name: "Plan Task",
108935
+ description: "Create or update a plan for a given task.",
108936
+ async* fn(input, _step, tools3) {
108937
+ const { task, fileContent, filePath } = input;
108938
+ let plan = fileContent || "";
108939
+ let isPlanReady = false;
108940
+ let userFeedback = "";
108941
+ while (true) {
108942
+ const currentTask = userFeedback ? `${task}
108943
+
108944
+ User feedback: ${userFeedback}` : task;
108945
+ const prompt3 = PLAN_PROMPT.replace("{task}", currentTask).replace("{fileContent}", plan);
108946
+ const {
108947
+ plan: newPlan,
108948
+ ready,
108949
+ question
108950
+ } = yield* tools3.invokeAgent({
108951
+ agent: "architect",
108952
+ messages: [{ type: "user", content: prompt3 }],
108953
+ outputSchema: PlanSchema
108954
+ });
108955
+ if (newPlan !== undefined) {
108956
+ plan = newPlan;
108957
+ }
108958
+ isPlanReady = ready;
108959
+ if (!isPlanReady && question) {
108960
+ const answer = yield* tools3.input({ message: question });
108961
+ userFeedback = `Question: ${question}
108962
+ Answer: ${answer}`;
108963
+ continue;
108964
+ }
108965
+ console.log(`
108966
+ Generated Plan:
108967
+ `);
108968
+ console.log(plan);
108969
+ try {
108970
+ userFeedback = yield* tools3.input({
108971
+ message: "What changes do you want to make? (leave empty or press Ctrl+C to exit)"
108972
+ });
108973
+ } catch (_error) {
108974
+ userFeedback = "";
108975
+ }
108976
+ if (!userFeedback) {
108977
+ break;
108978
+ }
108979
+ }
108980
+ const savePlan = yield* tools3.confirm({ message: "Do you want to save the plan?", default: false });
108981
+ if (savePlan) {
108982
+ let savePath = filePath;
108983
+ if (!savePath) {
108984
+ savePath = yield* tools3.input({ message: "Where do you want to save the plan?", default: "docs/plan.md" });
108985
+ }
108986
+ yield* tools3.writeToFile({ path: savePath, content: plan });
108987
+ console.log(`Plan saved to ${savePath}`);
108988
+ }
108989
+ return {};
108990
+ }
108991
+ };
108902
108992
  // src/workflows/pr.workflow.ts
108903
108993
  import { execSync as execSync3 } from "node:child_process";
108904
108994
  var prDetailsSchema = exports_external.object({
@@ -109443,6 +109533,27 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
109443
109533
  }, false);
109444
109534
  });
109445
109535
 
109536
+ // src/commands/plan.ts
109537
+ import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
109538
+ var planCommand = new Command("plan").description("Create or update a plan for a task.").argument("[task]", "The task to plan.").option("-f, --file <path>", "The path to the plan file.").action(async (task, options, command) => {
109539
+ let taskInput = task;
109540
+ if (!taskInput) {
109541
+ try {
109542
+ taskInput = await esm_default3({ message: "What is the task you want to plan?" });
109543
+ } catch (error44) {
109544
+ if (error44 instanceof Error && error44.name === "ExitPromptError") {
109545
+ return;
109546
+ }
109547
+ throw error44;
109548
+ }
109549
+ }
109550
+ let fileContent;
109551
+ if (options.file && existsSync5(options.file)) {
109552
+ fileContent = readFileSync3(options.file, "utf-8");
109553
+ }
109554
+ await runWorkflow("plan", planWorkflow, command, { task: taskInput, fileContent, filePath: options.file });
109555
+ });
109556
+
109446
109557
  // src/commands/pr.ts
109447
109558
  var prCommand = new Command("pr").description("Create a GitHub pull request").argument("[message]", "Optional context for the pull request generation").action(async (message, _options, command) => {
109448
109559
  const input = { ...message && { context: message } };
@@ -109648,6 +109759,7 @@ program2.addCommand(commitCommand);
109648
109759
  program2.addCommand(prCommand);
109649
109760
  program2.addCommand(reviewCommand);
109650
109761
  program2.addCommand(createCommand2);
109762
+ program2.addCommand(planCommand);
109651
109763
  addSharedOptions(program2);
109652
109764
  program2.parse();
109653
109765
  process.on("uncaughtException", (error44) => {