@polka-codes/cli-shared 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 +442 -497
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -24984,6 +24984,439 @@ var require_mimeScore = __commonJS((exports, module) => {
24984
24984
  };
24985
24985
  });
24986
24986
 
24987
+ // ../../node_modules/has-flag/index.js
24988
+ var require_has_flag = __commonJS((exports, module) => {
24989
+ module.exports = (flag, argv = process.argv) => {
24990
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
24991
+ const position = argv.indexOf(prefix + flag);
24992
+ const terminatorPosition = argv.indexOf("--");
24993
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
24994
+ };
24995
+ });
24996
+
24997
+ // ../../node_modules/chalk/node_modules/supports-color/index.js
24998
+ var require_supports_color = __commonJS((exports, module) => {
24999
+ var os = __require("os");
25000
+ var tty = __require("tty");
25001
+ var hasFlag = require_has_flag();
25002
+ var { env } = process;
25003
+ var forceColor;
25004
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
25005
+ forceColor = 0;
25006
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
25007
+ forceColor = 1;
25008
+ }
25009
+ if ("FORCE_COLOR" in env) {
25010
+ if (env.FORCE_COLOR === "true") {
25011
+ forceColor = 1;
25012
+ } else if (env.FORCE_COLOR === "false") {
25013
+ forceColor = 0;
25014
+ } else {
25015
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
25016
+ }
25017
+ }
25018
+ function translateLevel(level) {
25019
+ if (level === 0) {
25020
+ return false;
25021
+ }
25022
+ return {
25023
+ level,
25024
+ hasBasic: true,
25025
+ has256: level >= 2,
25026
+ has16m: level >= 3
25027
+ };
25028
+ }
25029
+ function supportsColor(haveStream, streamIsTTY) {
25030
+ if (forceColor === 0) {
25031
+ return 0;
25032
+ }
25033
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
25034
+ return 3;
25035
+ }
25036
+ if (hasFlag("color=256")) {
25037
+ return 2;
25038
+ }
25039
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
25040
+ return 0;
25041
+ }
25042
+ const min = forceColor || 0;
25043
+ if (env.TERM === "dumb") {
25044
+ return min;
25045
+ }
25046
+ if (process.platform === "win32") {
25047
+ const osRelease = os.release().split(".");
25048
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
25049
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
25050
+ }
25051
+ return 1;
25052
+ }
25053
+ if ("CI" in env) {
25054
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
25055
+ return 1;
25056
+ }
25057
+ return min;
25058
+ }
25059
+ if ("TEAMCITY_VERSION" in env) {
25060
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
25061
+ }
25062
+ if (env.COLORTERM === "truecolor") {
25063
+ return 3;
25064
+ }
25065
+ if ("TERM_PROGRAM" in env) {
25066
+ const version2 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
25067
+ switch (env.TERM_PROGRAM) {
25068
+ case "iTerm.app":
25069
+ return version2 >= 3 ? 3 : 2;
25070
+ case "Apple_Terminal":
25071
+ return 2;
25072
+ }
25073
+ }
25074
+ if (/-256(color)?$/i.test(env.TERM)) {
25075
+ return 2;
25076
+ }
25077
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
25078
+ return 1;
25079
+ }
25080
+ if ("COLORTERM" in env) {
25081
+ return 1;
25082
+ }
25083
+ return min;
25084
+ }
25085
+ function getSupportLevel(stream) {
25086
+ const level = supportsColor(stream, stream && stream.isTTY);
25087
+ return translateLevel(level);
25088
+ }
25089
+ module.exports = {
25090
+ supportsColor: getSupportLevel,
25091
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
25092
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
25093
+ };
25094
+ });
25095
+
25096
+ // ../../node_modules/chalk/source/util.js
25097
+ var require_util = __commonJS((exports, module) => {
25098
+ var stringReplaceAll = (string4, substring, replacer) => {
25099
+ let index = string4.indexOf(substring);
25100
+ if (index === -1) {
25101
+ return string4;
25102
+ }
25103
+ const substringLength = substring.length;
25104
+ let endIndex = 0;
25105
+ let returnValue = "";
25106
+ do {
25107
+ returnValue += string4.substr(endIndex, index - endIndex) + substring + replacer;
25108
+ endIndex = index + substringLength;
25109
+ index = string4.indexOf(substring, endIndex);
25110
+ } while (index !== -1);
25111
+ returnValue += string4.substr(endIndex);
25112
+ return returnValue;
25113
+ };
25114
+ var stringEncaseCRLFWithFirstIndex = (string4, prefix, postfix, index) => {
25115
+ let endIndex = 0;
25116
+ let returnValue = "";
25117
+ do {
25118
+ const gotCR = string4[index - 1] === "\r";
25119
+ returnValue += string4.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? `\r
25120
+ ` : `
25121
+ `) + postfix;
25122
+ endIndex = index + 1;
25123
+ index = string4.indexOf(`
25124
+ `, endIndex);
25125
+ } while (index !== -1);
25126
+ returnValue += string4.substr(endIndex);
25127
+ return returnValue;
25128
+ };
25129
+ module.exports = {
25130
+ stringReplaceAll,
25131
+ stringEncaseCRLFWithFirstIndex
25132
+ };
25133
+ });
25134
+
25135
+ // ../../node_modules/chalk/source/templates.js
25136
+ var require_templates = __commonJS((exports, module) => {
25137
+ 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;
25138
+ var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
25139
+ var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
25140
+ var ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
25141
+ var ESCAPES = new Map([
25142
+ ["n", `
25143
+ `],
25144
+ ["r", "\r"],
25145
+ ["t", "\t"],
25146
+ ["b", "\b"],
25147
+ ["f", "\f"],
25148
+ ["v", "\v"],
25149
+ ["0", "\x00"],
25150
+ ["\\", "\\"],
25151
+ ["e", "\x1B"],
25152
+ ["a", "\x07"]
25153
+ ]);
25154
+ function unescape(c) {
25155
+ const u = c[0] === "u";
25156
+ const bracket = c[1] === "{";
25157
+ if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
25158
+ return String.fromCharCode(parseInt(c.slice(1), 16));
25159
+ }
25160
+ if (u && bracket) {
25161
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
25162
+ }
25163
+ return ESCAPES.get(c) || c;
25164
+ }
25165
+ function parseArguments(name17, arguments_) {
25166
+ const results = [];
25167
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
25168
+ let matches;
25169
+ for (const chunk of chunks) {
25170
+ const number4 = Number(chunk);
25171
+ if (!Number.isNaN(number4)) {
25172
+ results.push(number4);
25173
+ } else if (matches = chunk.match(STRING_REGEX)) {
25174
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
25175
+ } else {
25176
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name17}')`);
25177
+ }
25178
+ }
25179
+ return results;
25180
+ }
25181
+ function parseStyle(style) {
25182
+ STYLE_REGEX.lastIndex = 0;
25183
+ const results = [];
25184
+ let matches;
25185
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
25186
+ const name17 = matches[1];
25187
+ if (matches[2]) {
25188
+ const args = parseArguments(name17, matches[2]);
25189
+ results.push([name17].concat(args));
25190
+ } else {
25191
+ results.push([name17]);
25192
+ }
25193
+ }
25194
+ return results;
25195
+ }
25196
+ function buildStyle(chalk, styles) {
25197
+ const enabled = {};
25198
+ for (const layer of styles) {
25199
+ for (const style of layer.styles) {
25200
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
25201
+ }
25202
+ }
25203
+ let current = chalk;
25204
+ for (const [styleName, styles2] of Object.entries(enabled)) {
25205
+ if (!Array.isArray(styles2)) {
25206
+ continue;
25207
+ }
25208
+ if (!(styleName in current)) {
25209
+ throw new Error(`Unknown Chalk style: ${styleName}`);
25210
+ }
25211
+ current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
25212
+ }
25213
+ return current;
25214
+ }
25215
+ module.exports = (chalk, temporary) => {
25216
+ const styles = [];
25217
+ const chunks = [];
25218
+ let chunk = [];
25219
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
25220
+ if (escapeCharacter) {
25221
+ chunk.push(unescape(escapeCharacter));
25222
+ } else if (style) {
25223
+ const string4 = chunk.join("");
25224
+ chunk = [];
25225
+ chunks.push(styles.length === 0 ? string4 : buildStyle(chalk, styles)(string4));
25226
+ styles.push({ inverse, styles: parseStyle(style) });
25227
+ } else if (close) {
25228
+ if (styles.length === 0) {
25229
+ throw new Error("Found extraneous } in Chalk template literal");
25230
+ }
25231
+ chunks.push(buildStyle(chalk, styles)(chunk.join("")));
25232
+ chunk = [];
25233
+ styles.pop();
25234
+ } else {
25235
+ chunk.push(character);
25236
+ }
25237
+ });
25238
+ chunks.push(chunk.join(""));
25239
+ if (styles.length > 0) {
25240
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
25241
+ throw new Error(errMessage);
25242
+ }
25243
+ return chunks.join("");
25244
+ };
25245
+ });
25246
+
25247
+ // ../../node_modules/chalk/source/index.js
25248
+ var require_source = __commonJS((exports, module) => {
25249
+ var ansiStyles = require_ansi_styles();
25250
+ var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
25251
+ var {
25252
+ stringReplaceAll,
25253
+ stringEncaseCRLFWithFirstIndex
25254
+ } = require_util();
25255
+ var { isArray } = Array;
25256
+ var levelMapping = [
25257
+ "ansi",
25258
+ "ansi",
25259
+ "ansi256",
25260
+ "ansi16m"
25261
+ ];
25262
+ var styles = Object.create(null);
25263
+ var applyOptions = (object3, options = {}) => {
25264
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
25265
+ throw new Error("The `level` option should be an integer from 0 to 3");
25266
+ }
25267
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
25268
+ object3.level = options.level === undefined ? colorLevel : options.level;
25269
+ };
25270
+
25271
+ class ChalkClass {
25272
+ constructor(options) {
25273
+ return chalkFactory(options);
25274
+ }
25275
+ }
25276
+ var chalkFactory = (options) => {
25277
+ const chalk2 = {};
25278
+ applyOptions(chalk2, options);
25279
+ chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
25280
+ Object.setPrototypeOf(chalk2, Chalk.prototype);
25281
+ Object.setPrototypeOf(chalk2.template, chalk2);
25282
+ chalk2.template.constructor = () => {
25283
+ throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
25284
+ };
25285
+ chalk2.template.Instance = ChalkClass;
25286
+ return chalk2.template;
25287
+ };
25288
+ function Chalk(options) {
25289
+ return chalkFactory(options);
25290
+ }
25291
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
25292
+ styles[styleName] = {
25293
+ get() {
25294
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
25295
+ Object.defineProperty(this, styleName, { value: builder });
25296
+ return builder;
25297
+ }
25298
+ };
25299
+ }
25300
+ styles.visible = {
25301
+ get() {
25302
+ const builder = createBuilder(this, this._styler, true);
25303
+ Object.defineProperty(this, "visible", { value: builder });
25304
+ return builder;
25305
+ }
25306
+ };
25307
+ var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
25308
+ for (const model of usedModels) {
25309
+ styles[model] = {
25310
+ get() {
25311
+ const { level } = this;
25312
+ return function(...arguments_) {
25313
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
25314
+ return createBuilder(this, styler, this._isEmpty);
25315
+ };
25316
+ }
25317
+ };
25318
+ }
25319
+ for (const model of usedModels) {
25320
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
25321
+ styles[bgModel] = {
25322
+ get() {
25323
+ const { level } = this;
25324
+ return function(...arguments_) {
25325
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
25326
+ return createBuilder(this, styler, this._isEmpty);
25327
+ };
25328
+ }
25329
+ };
25330
+ }
25331
+ var proto = Object.defineProperties(() => {}, {
25332
+ ...styles,
25333
+ level: {
25334
+ enumerable: true,
25335
+ get() {
25336
+ return this._generator.level;
25337
+ },
25338
+ set(level) {
25339
+ this._generator.level = level;
25340
+ }
25341
+ }
25342
+ });
25343
+ var createStyler = (open, close, parent) => {
25344
+ let openAll;
25345
+ let closeAll;
25346
+ if (parent === undefined) {
25347
+ openAll = open;
25348
+ closeAll = close;
25349
+ } else {
25350
+ openAll = parent.openAll + open;
25351
+ closeAll = close + parent.closeAll;
25352
+ }
25353
+ return {
25354
+ open,
25355
+ close,
25356
+ openAll,
25357
+ closeAll,
25358
+ parent
25359
+ };
25360
+ };
25361
+ var createBuilder = (self2, _styler, _isEmpty) => {
25362
+ const builder = (...arguments_) => {
25363
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
25364
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
25365
+ }
25366
+ return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
25367
+ };
25368
+ Object.setPrototypeOf(builder, proto);
25369
+ builder._generator = self2;
25370
+ builder._styler = _styler;
25371
+ builder._isEmpty = _isEmpty;
25372
+ return builder;
25373
+ };
25374
+ var applyStyle = (self2, string4) => {
25375
+ if (self2.level <= 0 || !string4) {
25376
+ return self2._isEmpty ? "" : string4;
25377
+ }
25378
+ let styler = self2._styler;
25379
+ if (styler === undefined) {
25380
+ return string4;
25381
+ }
25382
+ const { openAll, closeAll } = styler;
25383
+ if (string4.indexOf("\x1B") !== -1) {
25384
+ while (styler !== undefined) {
25385
+ string4 = stringReplaceAll(string4, styler.close, styler.open);
25386
+ styler = styler.parent;
25387
+ }
25388
+ }
25389
+ const lfIndex = string4.indexOf(`
25390
+ `);
25391
+ if (lfIndex !== -1) {
25392
+ string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
25393
+ }
25394
+ return openAll + string4 + closeAll;
25395
+ };
25396
+ var template;
25397
+ var chalkTag = (chalk2, ...strings) => {
25398
+ const [firstString] = strings;
25399
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
25400
+ return strings.join(" ");
25401
+ }
25402
+ const arguments_ = strings.slice(1);
25403
+ const parts = [firstString.raw[0]];
25404
+ for (let i = 1;i < firstString.length; i++) {
25405
+ parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"), String(firstString.raw[i]));
25406
+ }
25407
+ if (template === undefined) {
25408
+ template = require_templates();
25409
+ }
25410
+ return template(chalk2, parts.join(""));
25411
+ };
25412
+ Object.defineProperties(Chalk.prototype, styles);
25413
+ var chalk = Chalk();
25414
+ chalk.supportsColor = stdoutColor;
25415
+ chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
25416
+ chalk.stderr.supportsColor = stderrColor;
25417
+ module.exports = chalk;
25418
+ });
25419
+
24987
25420
  // src/config.ts
24988
25421
  import { existsSync, readFileSync } from "node:fs";
24989
25422
  import { homedir } from "node:os";
@@ -56889,496 +57322,8 @@ var getProvider = (options = {}) => {
56889
57322
  }
56890
57323
  return provider2;
56891
57324
  };
56892
- // ../../node_modules/chalk/source/vendor/ansi-styles/index.js
56893
- var ANSI_BACKGROUND_OFFSET = 10;
56894
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
56895
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
56896
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
56897
- var styles = {
56898
- modifier: {
56899
- reset: [0, 0],
56900
- bold: [1, 22],
56901
- dim: [2, 22],
56902
- italic: [3, 23],
56903
- underline: [4, 24],
56904
- overline: [53, 55],
56905
- inverse: [7, 27],
56906
- hidden: [8, 28],
56907
- strikethrough: [9, 29]
56908
- },
56909
- color: {
56910
- black: [30, 39],
56911
- red: [31, 39],
56912
- green: [32, 39],
56913
- yellow: [33, 39],
56914
- blue: [34, 39],
56915
- magenta: [35, 39],
56916
- cyan: [36, 39],
56917
- white: [37, 39],
56918
- blackBright: [90, 39],
56919
- gray: [90, 39],
56920
- grey: [90, 39],
56921
- redBright: [91, 39],
56922
- greenBright: [92, 39],
56923
- yellowBright: [93, 39],
56924
- blueBright: [94, 39],
56925
- magentaBright: [95, 39],
56926
- cyanBright: [96, 39],
56927
- whiteBright: [97, 39]
56928
- },
56929
- bgColor: {
56930
- bgBlack: [40, 49],
56931
- bgRed: [41, 49],
56932
- bgGreen: [42, 49],
56933
- bgYellow: [43, 49],
56934
- bgBlue: [44, 49],
56935
- bgMagenta: [45, 49],
56936
- bgCyan: [46, 49],
56937
- bgWhite: [47, 49],
56938
- bgBlackBright: [100, 49],
56939
- bgGray: [100, 49],
56940
- bgGrey: [100, 49],
56941
- bgRedBright: [101, 49],
56942
- bgGreenBright: [102, 49],
56943
- bgYellowBright: [103, 49],
56944
- bgBlueBright: [104, 49],
56945
- bgMagentaBright: [105, 49],
56946
- bgCyanBright: [106, 49],
56947
- bgWhiteBright: [107, 49]
56948
- }
56949
- };
56950
- var modifierNames = Object.keys(styles.modifier);
56951
- var foregroundColorNames = Object.keys(styles.color);
56952
- var backgroundColorNames = Object.keys(styles.bgColor);
56953
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
56954
- function assembleStyles() {
56955
- const codes = new Map;
56956
- for (const [groupName, group] of Object.entries(styles)) {
56957
- for (const [styleName, style] of Object.entries(group)) {
56958
- styles[styleName] = {
56959
- open: `\x1B[${style[0]}m`,
56960
- close: `\x1B[${style[1]}m`
56961
- };
56962
- group[styleName] = styles[styleName];
56963
- codes.set(style[0], style[1]);
56964
- }
56965
- Object.defineProperty(styles, groupName, {
56966
- value: group,
56967
- enumerable: false
56968
- });
56969
- }
56970
- Object.defineProperty(styles, "codes", {
56971
- value: codes,
56972
- enumerable: false
56973
- });
56974
- styles.color.close = "\x1B[39m";
56975
- styles.bgColor.close = "\x1B[49m";
56976
- styles.color.ansi = wrapAnsi16();
56977
- styles.color.ansi256 = wrapAnsi256();
56978
- styles.color.ansi16m = wrapAnsi16m();
56979
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
56980
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
56981
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
56982
- Object.defineProperties(styles, {
56983
- rgbToAnsi256: {
56984
- value(red, green, blue) {
56985
- if (red === green && green === blue) {
56986
- if (red < 8) {
56987
- return 16;
56988
- }
56989
- if (red > 248) {
56990
- return 231;
56991
- }
56992
- return Math.round((red - 8) / 247 * 24) + 232;
56993
- }
56994
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
56995
- },
56996
- enumerable: false
56997
- },
56998
- hexToRgb: {
56999
- value(hex3) {
57000
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex3.toString(16));
57001
- if (!matches) {
57002
- return [0, 0, 0];
57003
- }
57004
- let [colorString] = matches;
57005
- if (colorString.length === 3) {
57006
- colorString = [...colorString].map((character) => character + character).join("");
57007
- }
57008
- const integer2 = Number.parseInt(colorString, 16);
57009
- return [
57010
- integer2 >> 16 & 255,
57011
- integer2 >> 8 & 255,
57012
- integer2 & 255
57013
- ];
57014
- },
57015
- enumerable: false
57016
- },
57017
- hexToAnsi256: {
57018
- value: (hex3) => styles.rgbToAnsi256(...styles.hexToRgb(hex3)),
57019
- enumerable: false
57020
- },
57021
- ansi256ToAnsi: {
57022
- value(code) {
57023
- if (code < 8) {
57024
- return 30 + code;
57025
- }
57026
- if (code < 16) {
57027
- return 90 + (code - 8);
57028
- }
57029
- let red;
57030
- let green;
57031
- let blue;
57032
- if (code >= 232) {
57033
- red = ((code - 232) * 10 + 8) / 255;
57034
- green = red;
57035
- blue = red;
57036
- } else {
57037
- code -= 16;
57038
- const remainder = code % 36;
57039
- red = Math.floor(code / 36) / 5;
57040
- green = Math.floor(remainder / 6) / 5;
57041
- blue = remainder % 6 / 5;
57042
- }
57043
- const value = Math.max(red, green, blue) * 2;
57044
- if (value === 0) {
57045
- return 30;
57046
- }
57047
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
57048
- if (value === 2) {
57049
- result += 60;
57050
- }
57051
- return result;
57052
- },
57053
- enumerable: false
57054
- },
57055
- rgbToAnsi: {
57056
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
57057
- enumerable: false
57058
- },
57059
- hexToAnsi: {
57060
- value: (hex3) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex3)),
57061
- enumerable: false
57062
- }
57063
- });
57064
- return styles;
57065
- }
57066
- var ansiStyles = assembleStyles();
57067
- var ansi_styles_default = ansiStyles;
57068
-
57069
- // ../../node_modules/chalk/source/vendor/supports-color/index.js
57070
- import process4 from "node:process";
57071
- import os from "node:os";
57072
- import tty from "node:tty";
57073
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process4.argv) {
57074
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
57075
- const position = argv.indexOf(prefix + flag);
57076
- const terminatorPosition = argv.indexOf("--");
57077
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
57078
- }
57079
- var { env } = process4;
57080
- var flagForceColor;
57081
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
57082
- flagForceColor = 0;
57083
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
57084
- flagForceColor = 1;
57085
- }
57086
- function envForceColor() {
57087
- if ("FORCE_COLOR" in env) {
57088
- if (env.FORCE_COLOR === "true") {
57089
- return 1;
57090
- }
57091
- if (env.FORCE_COLOR === "false") {
57092
- return 0;
57093
- }
57094
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
57095
- }
57096
- }
57097
- function translateLevel(level) {
57098
- if (level === 0) {
57099
- return false;
57100
- }
57101
- return {
57102
- level,
57103
- hasBasic: true,
57104
- has256: level >= 2,
57105
- has16m: level >= 3
57106
- };
57107
- }
57108
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
57109
- const noFlagForceColor = envForceColor();
57110
- if (noFlagForceColor !== undefined) {
57111
- flagForceColor = noFlagForceColor;
57112
- }
57113
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
57114
- if (forceColor === 0) {
57115
- return 0;
57116
- }
57117
- if (sniffFlags) {
57118
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
57119
- return 3;
57120
- }
57121
- if (hasFlag("color=256")) {
57122
- return 2;
57123
- }
57124
- }
57125
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
57126
- return 1;
57127
- }
57128
- if (haveStream && !streamIsTTY && forceColor === undefined) {
57129
- return 0;
57130
- }
57131
- const min = forceColor || 0;
57132
- if (env.TERM === "dumb") {
57133
- return min;
57134
- }
57135
- if (process4.platform === "win32") {
57136
- const osRelease = os.release().split(".");
57137
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
57138
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
57139
- }
57140
- return 1;
57141
- }
57142
- if ("CI" in env) {
57143
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key2) => (key2 in env))) {
57144
- return 3;
57145
- }
57146
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
57147
- return 1;
57148
- }
57149
- return min;
57150
- }
57151
- if ("TEAMCITY_VERSION" in env) {
57152
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
57153
- }
57154
- if (env.COLORTERM === "truecolor") {
57155
- return 3;
57156
- }
57157
- if (env.TERM === "xterm-kitty") {
57158
- return 3;
57159
- }
57160
- if (env.TERM === "xterm-ghostty") {
57161
- return 3;
57162
- }
57163
- if (env.TERM === "wezterm") {
57164
- return 3;
57165
- }
57166
- if ("TERM_PROGRAM" in env) {
57167
- const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
57168
- switch (env.TERM_PROGRAM) {
57169
- case "iTerm.app": {
57170
- return version2 >= 3 ? 3 : 2;
57171
- }
57172
- case "Apple_Terminal": {
57173
- return 2;
57174
- }
57175
- }
57176
- }
57177
- if (/-256(color)?$/i.test(env.TERM)) {
57178
- return 2;
57179
- }
57180
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
57181
- return 1;
57182
- }
57183
- if ("COLORTERM" in env) {
57184
- return 1;
57185
- }
57186
- return min;
57187
- }
57188
- function createSupportsColor(stream, options = {}) {
57189
- const level = _supportsColor(stream, {
57190
- streamIsTTY: stream && stream.isTTY,
57191
- ...options
57192
- });
57193
- return translateLevel(level);
57194
- }
57195
- var supportsColor = {
57196
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
57197
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
57198
- };
57199
- var supports_color_default = supportsColor;
57200
-
57201
- // ../../node_modules/chalk/source/utilities.js
57202
- function stringReplaceAll(string4, substring, replacer) {
57203
- let index = string4.indexOf(substring);
57204
- if (index === -1) {
57205
- return string4;
57206
- }
57207
- const substringLength = substring.length;
57208
- let endIndex = 0;
57209
- let returnValue = "";
57210
- do {
57211
- returnValue += string4.slice(endIndex, index) + substring + replacer;
57212
- endIndex = index + substringLength;
57213
- index = string4.indexOf(substring, endIndex);
57214
- } while (index !== -1);
57215
- returnValue += string4.slice(endIndex);
57216
- return returnValue;
57217
- }
57218
- function stringEncaseCRLFWithFirstIndex(string4, prefix, postfix, index) {
57219
- let endIndex = 0;
57220
- let returnValue = "";
57221
- do {
57222
- const gotCR = string4[index - 1] === "\r";
57223
- returnValue += string4.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r
57224
- ` : `
57225
- `) + postfix;
57226
- endIndex = index + 1;
57227
- index = string4.indexOf(`
57228
- `, endIndex);
57229
- } while (index !== -1);
57230
- returnValue += string4.slice(endIndex);
57231
- return returnValue;
57232
- }
57233
-
57234
- // ../../node_modules/chalk/source/index.js
57235
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
57236
- var GENERATOR = Symbol("GENERATOR");
57237
- var STYLER = Symbol("STYLER");
57238
- var IS_EMPTY = Symbol("IS_EMPTY");
57239
- var levelMapping = [
57240
- "ansi",
57241
- "ansi",
57242
- "ansi256",
57243
- "ansi16m"
57244
- ];
57245
- var styles2 = Object.create(null);
57246
- var applyOptions = (object3, options = {}) => {
57247
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
57248
- throw new Error("The `level` option should be an integer from 0 to 3");
57249
- }
57250
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
57251
- object3.level = options.level === undefined ? colorLevel : options.level;
57252
- };
57253
- var chalkFactory = (options) => {
57254
- const chalk = (...strings) => strings.join(" ");
57255
- applyOptions(chalk, options);
57256
- Object.setPrototypeOf(chalk, createChalk.prototype);
57257
- return chalk;
57258
- };
57259
- function createChalk(options) {
57260
- return chalkFactory(options);
57261
- }
57262
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
57263
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
57264
- styles2[styleName] = {
57265
- get() {
57266
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
57267
- Object.defineProperty(this, styleName, { value: builder });
57268
- return builder;
57269
- }
57270
- };
57271
- }
57272
- styles2.visible = {
57273
- get() {
57274
- const builder = createBuilder(this, this[STYLER], true);
57275
- Object.defineProperty(this, "visible", { value: builder });
57276
- return builder;
57277
- }
57278
- };
57279
- var getModelAnsi = (model, level, type, ...arguments_) => {
57280
- if (model === "rgb") {
57281
- if (level === "ansi16m") {
57282
- return ansi_styles_default[type].ansi16m(...arguments_);
57283
- }
57284
- if (level === "ansi256") {
57285
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
57286
- }
57287
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
57288
- }
57289
- if (model === "hex") {
57290
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
57291
- }
57292
- return ansi_styles_default[type][model](...arguments_);
57293
- };
57294
- var usedModels = ["rgb", "hex", "ansi256"];
57295
- for (const model of usedModels) {
57296
- styles2[model] = {
57297
- get() {
57298
- const { level } = this;
57299
- return function(...arguments_) {
57300
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
57301
- return createBuilder(this, styler, this[IS_EMPTY]);
57302
- };
57303
- }
57304
- };
57305
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
57306
- styles2[bgModel] = {
57307
- get() {
57308
- const { level } = this;
57309
- return function(...arguments_) {
57310
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
57311
- return createBuilder(this, styler, this[IS_EMPTY]);
57312
- };
57313
- }
57314
- };
57315
- }
57316
- var proto = Object.defineProperties(() => {}, {
57317
- ...styles2,
57318
- level: {
57319
- enumerable: true,
57320
- get() {
57321
- return this[GENERATOR].level;
57322
- },
57323
- set(level) {
57324
- this[GENERATOR].level = level;
57325
- }
57326
- }
57327
- });
57328
- var createStyler = (open, close, parent) => {
57329
- let openAll;
57330
- let closeAll;
57331
- if (parent === undefined) {
57332
- openAll = open;
57333
- closeAll = close;
57334
- } else {
57335
- openAll = parent.openAll + open;
57336
- closeAll = close + parent.closeAll;
57337
- }
57338
- return {
57339
- open,
57340
- close,
57341
- openAll,
57342
- closeAll,
57343
- parent
57344
- };
57345
- };
57346
- var createBuilder = (self2, _styler, _isEmpty) => {
57347
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
57348
- Object.setPrototypeOf(builder, proto);
57349
- builder[GENERATOR] = self2;
57350
- builder[STYLER] = _styler;
57351
- builder[IS_EMPTY] = _isEmpty;
57352
- return builder;
57353
- };
57354
- var applyStyle = (self2, string4) => {
57355
- if (self2.level <= 0 || !string4) {
57356
- return self2[IS_EMPTY] ? "" : string4;
57357
- }
57358
- let styler = self2[STYLER];
57359
- if (styler === undefined) {
57360
- return string4;
57361
- }
57362
- const { openAll, closeAll } = styler;
57363
- if (string4.includes("\x1B")) {
57364
- while (styler !== undefined) {
57365
- string4 = stringReplaceAll(string4, styler.close, styler.open);
57366
- styler = styler.parent;
57367
- }
57368
- }
57369
- const lfIndex = string4.indexOf(`
57370
- `);
57371
- if (lfIndex !== -1) {
57372
- string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
57373
- }
57374
- return openAll + string4 + closeAll;
57375
- };
57376
- Object.defineProperties(createChalk.prototype, styles2);
57377
- var chalk = createChalk();
57378
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
57379
- var source_default = chalk;
57380
-
57381
57325
  // src/utils/eventHandler.ts
57326
+ var import_chalk = __toESM(require_source(), 1);
57382
57327
  var toolCallStats = new Map;
57383
57328
  var printEvent = (verbose, usageMeter, customConsole = console) => {
57384
57329
  let hadReasoning = false;
@@ -57414,19 +57359,19 @@ ${event.systemPrompt}`);
57414
57359
  break;
57415
57360
  case "image":
57416
57361
  if (content.image instanceof URL) {
57417
- customConsole.log(source_default.yellow(`[Image content from URL: ${content.image}]`));
57362
+ customConsole.log(import_chalk.default.yellow(`[Image content from URL: ${content.image}]`));
57418
57363
  } else {
57419
- customConsole.log(source_default.yellow(`[Image content: ${content.mediaType}]`));
57364
+ customConsole.log(import_chalk.default.yellow(`[Image content: ${content.mediaType}]`));
57420
57365
  }
57421
57366
  break;
57422
57367
  case "file":
57423
- customConsole.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
57368
+ customConsole.log(import_chalk.default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
57424
57369
  break;
57425
57370
  case "tool-call":
57426
- customConsole.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
57371
+ customConsole.log(import_chalk.default.yellow(`[Tool call: ${content.toolName}]`));
57427
57372
  break;
57428
57373
  case "tool-result":
57429
- customConsole.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
57374
+ customConsole.log(import_chalk.default.yellow(`[Tool result: ${content.toolName}]`));
57430
57375
  if (verbose > 0) {
57431
57376
  customConsole.log(content.output);
57432
57377
  }
@@ -57465,12 +57410,12 @@ ${event.systemPrompt}`);
57465
57410
  break;
57466
57411
  }
57467
57412
  case "Reasoning" /* Reasoning */: {
57468
- customConsole.write(source_default.dim(event.newText));
57413
+ customConsole.write(import_chalk.default.dim(event.newText));
57469
57414
  hadReasoning = true;
57470
57415
  break;
57471
57416
  }
57472
57417
  case "ToolUse" /* ToolUse */: {
57473
- customConsole.log(source_default.yellow(`
57418
+ customConsole.log(import_chalk.default.yellow(`
57474
57419
 
57475
57420
  Tool use:`, event.tool), event.params);
57476
57421
  const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
@@ -57487,7 +57432,7 @@ Tool use:`, event.tool), event.params);
57487
57432
  case "ToolInvalid" /* ToolInvalid */:
57488
57433
  break;
57489
57434
  case "ToolError" /* ToolError */: {
57490
- customConsole.error(source_default.red(`
57435
+ customConsole.error(import_chalk.default.red(`
57491
57436
 
57492
57437
  Tool error:`, event.tool));
57493
57438
  customConsole.error(event.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.9.40",
3
+ "version": "0.9.42",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@ai-sdk/provider-utils": "^3.0.0",
21
- "@polka-codes/core": "0.9.39",
21
+ "@polka-codes/core": "0.9.41",
22
22
  "ignore": "^7.0.3",
23
23
  "lodash": "^4.17.21",
24
24
  "mime-types": "^3.0.1",