@polka-codes/cli 0.9.41 → 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.
- package/dist/index.js +846 -752
- 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.
|
|
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
|
-
|
|
532
|
+
_collectValue(value, previous) {
|
|
533
533
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
534
534
|
return [value];
|
|
535
535
|
}
|
|
536
|
-
|
|
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.
|
|
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
|
-
|
|
1002
|
+
_collectValue(value, previous) {
|
|
1002
1003
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
1003
1004
|
return [value];
|
|
1004
1005
|
}
|
|
1005
|
-
|
|
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.
|
|
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 =
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
2053
|
-
|
|
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
|
|
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
|
|
2076
|
-
value = args
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
56859
|
+
const fs3 = this.flowScalar(this.type);
|
|
56437
56860
|
if (atNextItem || it.value) {
|
|
56438
|
-
map2.items.push({ start, key:
|
|
56861
|
+
map2.items.push({ start, key: fs3, sep: [] });
|
|
56439
56862
|
this.onKeyLine = true;
|
|
56440
56863
|
} else if (it.sep) {
|
|
56441
|
-
this.stack.push(
|
|
56864
|
+
this.stack.push(fs3);
|
|
56442
56865
|
} else {
|
|
56443
|
-
Object.assign(it, { key:
|
|
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
|
|
56994
|
+
const fs3 = this.flowScalar(this.type);
|
|
56572
56995
|
if (!it || it.value)
|
|
56573
|
-
fc.items.push({ start: [], key:
|
|
56996
|
+
fc.items.push({ start: [], key: fs3, sep: [] });
|
|
56574
56997
|
else if (it.sep)
|
|
56575
|
-
this.stack.push(
|
|
56998
|
+
this.stack.push(fs3);
|
|
56576
56999
|
else
|
|
56577
|
-
Object.assign(it, { key:
|
|
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.
|
|
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.
|
|
99628
|
-
"deepseek-reasoner": { inputPrice: 0.
|
|
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:
|
|
99638
|
-
"gemini-2.5-flash": { inputPrice: 0.3, outputPrice: 2.5, cacheWritesPrice: 0, cacheReadsPrice: 0, supportsThinking:
|
|
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
|
|
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(
|
|
104549
|
+
customConsole.log(import_chalk.default.yellow(`[Image content from URL: ${content.image}]`));
|
|
104604
104550
|
} else {
|
|
104605
|
-
customConsole.log(
|
|
104551
|
+
customConsole.log(import_chalk.default.yellow(`[Image content: ${content.mediaType}]`));
|
|
104606
104552
|
}
|
|
104607
104553
|
break;
|
|
104608
104554
|
case "file":
|
|
104609
|
-
customConsole.log(
|
|
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(
|
|
104558
|
+
customConsole.log(import_chalk.default.yellow(`[Tool call: ${content.toolName}]`));
|
|
104613
104559
|
break;
|
|
104614
104560
|
case "tool-result":
|
|
104615
|
-
customConsole.log(
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
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 ||
|
|
104765
|
-
const defaultModel = options.model ||
|
|
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 ||
|
|
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 (
|
|
104777
|
-
import_lodash3.set(config4, ["providers", "anthropic" /* Anthropic */, "apiKey"],
|
|
104722
|
+
if (env.ANTHROPIC_API_KEY) {
|
|
104723
|
+
import_lodash3.set(config4, ["providers", "anthropic" /* Anthropic */, "apiKey"], env.ANTHROPIC_API_KEY);
|
|
104778
104724
|
}
|
|
104779
|
-
if (
|
|
104780
|
-
import_lodash3.set(config4, ["providers", "deepseek" /* DeepSeek */, "apiKey"],
|
|
104725
|
+
if (env.DEEPSEEK_API_KEY) {
|
|
104726
|
+
import_lodash3.set(config4, ["providers", "deepseek" /* DeepSeek */, "apiKey"], env.DEEPSEEK_API_KEY);
|
|
104781
104727
|
}
|
|
104782
|
-
if (
|
|
104783
|
-
import_lodash3.set(config4, ["providers", "openrouter" /* OpenRouter */, "apiKey"],
|
|
104728
|
+
if (env.OPENROUTER_API_KEY) {
|
|
104729
|
+
import_lodash3.set(config4, ["providers", "openrouter" /* OpenRouter */, "apiKey"], env.OPENROUTER_API_KEY);
|
|
104784
104730
|
}
|
|
104785
|
-
if (
|
|
104786
|
-
import_lodash3.set(config4, ["providers", "openai" /* OpenAI */, "apiKey"],
|
|
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 ?? (
|
|
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
|
|
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 =
|
|
104941
|
+
const platform = os2.platform();
|
|
104996
104942
|
const llms = {};
|
|
104997
104943
|
const getOrCreateLlm = (agentName) => {
|
|
104998
104944
|
const config4 = this.#options.providerConfig.getConfigForAgent(agentName);
|
|
@@ -105278,15 +105224,21 @@ var runChat = async (opts, command) => {
|
|
|
105278
105224
|
|
|
105279
105225
|
// src/runWorkflow.ts
|
|
105280
105226
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
105281
|
-
import
|
|
105227
|
+
import fs2 from "node:fs/promises";
|
|
105228
|
+
import os4 from "node:os";
|
|
105282
105229
|
|
|
105283
105230
|
// ../workflow/src/helpers.ts
|
|
105284
105231
|
var makeStepFn = (fns) => {
|
|
105285
|
-
|
|
105232
|
+
const resolvedFns = fns ?? (() => {
|
|
105286
105233
|
const results = {};
|
|
105287
105234
|
const counts = {};
|
|
105288
|
-
|
|
105289
|
-
getStepResult: async (key2) =>
|
|
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
|
+
},
|
|
105290
105242
|
setStepResult: async (key2, value) => {
|
|
105291
105243
|
results[key2] = value;
|
|
105292
105244
|
},
|
|
@@ -105295,16 +105247,16 @@ var makeStepFn = (fns) => {
|
|
|
105295
105247
|
return counts[key2];
|
|
105296
105248
|
}
|
|
105297
105249
|
};
|
|
105298
|
-
}
|
|
105250
|
+
})();
|
|
105299
105251
|
return async (name18, fn) => {
|
|
105300
|
-
const currentCounts = await
|
|
105252
|
+
const currentCounts = await resolvedFns.getAndIncrementCounts(name18);
|
|
105301
105253
|
const key2 = `${name18}#${currentCounts}`;
|
|
105302
|
-
const existingResult = await
|
|
105303
|
-
if (existingResult
|
|
105304
|
-
return existingResult;
|
|
105254
|
+
const existingResult = await resolvedFns.getStepResult(key2);
|
|
105255
|
+
if (existingResult.found) {
|
|
105256
|
+
return existingResult.value;
|
|
105305
105257
|
}
|
|
105306
105258
|
const result = await fn();
|
|
105307
|
-
await
|
|
105259
|
+
await resolvedFns.setStepResult(key2, result ?? undefined);
|
|
105308
105260
|
return result;
|
|
105309
105261
|
};
|
|
105310
105262
|
};
|
|
@@ -105367,14 +105319,14 @@ async function run(workflow, input, stepFn) {
|
|
|
105367
105319
|
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
105368
105320
|
|
|
105369
105321
|
// ../../node_modules/ora/index.js
|
|
105370
|
-
import
|
|
105322
|
+
import process9 from "node:process";
|
|
105371
105323
|
|
|
105372
105324
|
// ../../node_modules/ora/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
105373
|
-
var
|
|
105374
|
-
var
|
|
105375
|
-
var
|
|
105376
|
-
var
|
|
105377
|
-
var
|
|
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 = {
|
|
105378
105330
|
modifier: {
|
|
105379
105331
|
reset: [0, 0],
|
|
105380
105332
|
bold: [1, 22],
|
|
@@ -105427,39 +105379,39 @@ var styles3 = {
|
|
|
105427
105379
|
bgWhiteBright: [107, 49]
|
|
105428
105380
|
}
|
|
105429
105381
|
};
|
|
105430
|
-
var
|
|
105431
|
-
var
|
|
105432
|
-
var
|
|
105433
|
-
var
|
|
105434
|
-
function
|
|
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() {
|
|
105435
105387
|
const codes = new Map;
|
|
105436
|
-
for (const [groupName, group] of Object.entries(
|
|
105388
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
105437
105389
|
for (const [styleName, style] of Object.entries(group)) {
|
|
105438
|
-
|
|
105390
|
+
styles[styleName] = {
|
|
105439
105391
|
open: `\x1B[${style[0]}m`,
|
|
105440
105392
|
close: `\x1B[${style[1]}m`
|
|
105441
105393
|
};
|
|
105442
|
-
group[styleName] =
|
|
105394
|
+
group[styleName] = styles[styleName];
|
|
105443
105395
|
codes.set(style[0], style[1]);
|
|
105444
105396
|
}
|
|
105445
|
-
Object.defineProperty(
|
|
105397
|
+
Object.defineProperty(styles, groupName, {
|
|
105446
105398
|
value: group,
|
|
105447
105399
|
enumerable: false
|
|
105448
105400
|
});
|
|
105449
105401
|
}
|
|
105450
|
-
Object.defineProperty(
|
|
105402
|
+
Object.defineProperty(styles, "codes", {
|
|
105451
105403
|
value: codes,
|
|
105452
105404
|
enumerable: false
|
|
105453
105405
|
});
|
|
105454
|
-
|
|
105455
|
-
|
|
105456
|
-
|
|
105457
|
-
|
|
105458
|
-
|
|
105459
|
-
|
|
105460
|
-
|
|
105461
|
-
|
|
105462
|
-
Object.defineProperties(
|
|
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, {
|
|
105463
105415
|
rgbToAnsi256: {
|
|
105464
105416
|
value(red, green, blue) {
|
|
105465
105417
|
if (red === green && green === blue) {
|
|
@@ -105495,7 +105447,7 @@ function assembleStyles2() {
|
|
|
105495
105447
|
enumerable: false
|
|
105496
105448
|
},
|
|
105497
105449
|
hexToAnsi256: {
|
|
105498
|
-
value: (hex3) =>
|
|
105450
|
+
value: (hex3) => styles.rgbToAnsi256(...styles.hexToRgb(hex3)),
|
|
105499
105451
|
enumerable: false
|
|
105500
105452
|
},
|
|
105501
105453
|
ansi256ToAnsi: {
|
|
@@ -105533,48 +105485,48 @@ function assembleStyles2() {
|
|
|
105533
105485
|
enumerable: false
|
|
105534
105486
|
},
|
|
105535
105487
|
rgbToAnsi: {
|
|
105536
|
-
value: (red, green, blue) =>
|
|
105488
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
105537
105489
|
enumerable: false
|
|
105538
105490
|
},
|
|
105539
105491
|
hexToAnsi: {
|
|
105540
|
-
value: (hex3) =>
|
|
105492
|
+
value: (hex3) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex3)),
|
|
105541
105493
|
enumerable: false
|
|
105542
105494
|
}
|
|
105543
105495
|
});
|
|
105544
|
-
return
|
|
105496
|
+
return styles;
|
|
105545
105497
|
}
|
|
105546
|
-
var
|
|
105547
|
-
var
|
|
105498
|
+
var ansiStyles = assembleStyles();
|
|
105499
|
+
var ansi_styles_default = ansiStyles;
|
|
105548
105500
|
|
|
105549
105501
|
// ../../node_modules/ora/node_modules/chalk/source/vendor/supports-color/index.js
|
|
105550
|
-
import
|
|
105551
|
-
import
|
|
105552
|
-
import
|
|
105553
|
-
function
|
|
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) {
|
|
105554
105506
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
105555
105507
|
const position = argv.indexOf(prefix + flag);
|
|
105556
105508
|
const terminatorPosition = argv.indexOf("--");
|
|
105557
105509
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
105558
105510
|
}
|
|
105559
|
-
var { env
|
|
105560
|
-
var
|
|
105561
|
-
if (
|
|
105562
|
-
|
|
105563
|
-
} else if (
|
|
105564
|
-
|
|
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;
|
|
105565
105517
|
}
|
|
105566
|
-
function
|
|
105567
|
-
if ("FORCE_COLOR" in
|
|
105568
|
-
if (
|
|
105518
|
+
function envForceColor() {
|
|
105519
|
+
if ("FORCE_COLOR" in env) {
|
|
105520
|
+
if (env.FORCE_COLOR === "true") {
|
|
105569
105521
|
return 1;
|
|
105570
105522
|
}
|
|
105571
|
-
if (
|
|
105523
|
+
if (env.FORCE_COLOR === "false") {
|
|
105572
105524
|
return 0;
|
|
105573
105525
|
}
|
|
105574
|
-
return
|
|
105526
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
105575
105527
|
}
|
|
105576
105528
|
}
|
|
105577
|
-
function
|
|
105529
|
+
function translateLevel(level) {
|
|
105578
105530
|
if (level === 0) {
|
|
105579
105531
|
return false;
|
|
105580
105532
|
}
|
|
@@ -105585,67 +105537,67 @@ function translateLevel2(level) {
|
|
|
105585
105537
|
has16m: level >= 3
|
|
105586
105538
|
};
|
|
105587
105539
|
}
|
|
105588
|
-
function
|
|
105589
|
-
const noFlagForceColor =
|
|
105540
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
105541
|
+
const noFlagForceColor = envForceColor();
|
|
105590
105542
|
if (noFlagForceColor !== undefined) {
|
|
105591
|
-
|
|
105543
|
+
flagForceColor = noFlagForceColor;
|
|
105592
105544
|
}
|
|
105593
|
-
const forceColor = sniffFlags ?
|
|
105545
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
105594
105546
|
if (forceColor === 0) {
|
|
105595
105547
|
return 0;
|
|
105596
105548
|
}
|
|
105597
105549
|
if (sniffFlags) {
|
|
105598
|
-
if (
|
|
105550
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
105599
105551
|
return 3;
|
|
105600
105552
|
}
|
|
105601
|
-
if (
|
|
105553
|
+
if (hasFlag("color=256")) {
|
|
105602
105554
|
return 2;
|
|
105603
105555
|
}
|
|
105604
105556
|
}
|
|
105605
|
-
if ("TF_BUILD" in
|
|
105557
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
105606
105558
|
return 1;
|
|
105607
105559
|
}
|
|
105608
105560
|
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
105609
105561
|
return 0;
|
|
105610
105562
|
}
|
|
105611
105563
|
const min = forceColor || 0;
|
|
105612
|
-
if (
|
|
105564
|
+
if (env.TERM === "dumb") {
|
|
105613
105565
|
return min;
|
|
105614
105566
|
}
|
|
105615
|
-
if (
|
|
105616
|
-
const osRelease =
|
|
105567
|
+
if (process4.platform === "win32") {
|
|
105568
|
+
const osRelease = os3.release().split(".");
|
|
105617
105569
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
105618
105570
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
105619
105571
|
}
|
|
105620
105572
|
return 1;
|
|
105621
105573
|
}
|
|
105622
|
-
if ("CI" in
|
|
105623
|
-
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key2) => (key2 in
|
|
105574
|
+
if ("CI" in env) {
|
|
105575
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key2) => (key2 in env))) {
|
|
105624
105576
|
return 3;
|
|
105625
105577
|
}
|
|
105626
|
-
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in
|
|
105578
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
|
|
105627
105579
|
return 1;
|
|
105628
105580
|
}
|
|
105629
105581
|
return min;
|
|
105630
105582
|
}
|
|
105631
|
-
if ("TEAMCITY_VERSION" in
|
|
105632
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(
|
|
105583
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
105584
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
105633
105585
|
}
|
|
105634
|
-
if (
|
|
105586
|
+
if (env.COLORTERM === "truecolor") {
|
|
105635
105587
|
return 3;
|
|
105636
105588
|
}
|
|
105637
|
-
if (
|
|
105589
|
+
if (env.TERM === "xterm-kitty") {
|
|
105638
105590
|
return 3;
|
|
105639
105591
|
}
|
|
105640
|
-
if (
|
|
105592
|
+
if (env.TERM === "xterm-ghostty") {
|
|
105641
105593
|
return 3;
|
|
105642
105594
|
}
|
|
105643
|
-
if (
|
|
105595
|
+
if (env.TERM === "wezterm") {
|
|
105644
105596
|
return 3;
|
|
105645
105597
|
}
|
|
105646
|
-
if ("TERM_PROGRAM" in
|
|
105647
|
-
const version3 = Number.parseInt((
|
|
105648
|
-
switch (
|
|
105598
|
+
if ("TERM_PROGRAM" in env) {
|
|
105599
|
+
const version3 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
105600
|
+
switch (env.TERM_PROGRAM) {
|
|
105649
105601
|
case "iTerm.app": {
|
|
105650
105602
|
return version3 >= 3 ? 3 : 2;
|
|
105651
105603
|
}
|
|
@@ -105654,32 +105606,32 @@ function _supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
105654
105606
|
}
|
|
105655
105607
|
}
|
|
105656
105608
|
}
|
|
105657
|
-
if (/-256(color)?$/i.test(
|
|
105609
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
105658
105610
|
return 2;
|
|
105659
105611
|
}
|
|
105660
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
|
|
105612
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
105661
105613
|
return 1;
|
|
105662
105614
|
}
|
|
105663
|
-
if ("COLORTERM" in
|
|
105615
|
+
if ("COLORTERM" in env) {
|
|
105664
105616
|
return 1;
|
|
105665
105617
|
}
|
|
105666
105618
|
return min;
|
|
105667
105619
|
}
|
|
105668
|
-
function
|
|
105669
|
-
const level =
|
|
105620
|
+
function createSupportsColor(stream, options = {}) {
|
|
105621
|
+
const level = _supportsColor(stream, {
|
|
105670
105622
|
streamIsTTY: stream && stream.isTTY,
|
|
105671
105623
|
...options
|
|
105672
105624
|
});
|
|
105673
|
-
return
|
|
105625
|
+
return translateLevel(level);
|
|
105674
105626
|
}
|
|
105675
|
-
var
|
|
105676
|
-
stdout:
|
|
105677
|
-
stderr:
|
|
105627
|
+
var supportsColor = {
|
|
105628
|
+
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
105629
|
+
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
105678
105630
|
};
|
|
105679
|
-
var
|
|
105631
|
+
var supports_color_default = supportsColor;
|
|
105680
105632
|
|
|
105681
105633
|
// ../../node_modules/ora/node_modules/chalk/source/utilities.js
|
|
105682
|
-
function
|
|
105634
|
+
function stringReplaceAll(string4, substring, replacer) {
|
|
105683
105635
|
let index = string4.indexOf(substring);
|
|
105684
105636
|
if (index === -1) {
|
|
105685
105637
|
return string4;
|
|
@@ -105695,7 +105647,7 @@ function stringReplaceAll2(string4, substring, replacer) {
|
|
|
105695
105647
|
returnValue += string4.slice(endIndex);
|
|
105696
105648
|
return returnValue;
|
|
105697
105649
|
}
|
|
105698
|
-
function
|
|
105650
|
+
function stringEncaseCRLFWithFirstIndex(string4, prefix, postfix, index) {
|
|
105699
105651
|
let endIndex = 0;
|
|
105700
105652
|
let returnValue = "";
|
|
105701
105653
|
do {
|
|
@@ -105712,100 +105664,100 @@ function stringEncaseCRLFWithFirstIndex2(string4, prefix, postfix, index) {
|
|
|
105712
105664
|
}
|
|
105713
105665
|
|
|
105714
105666
|
// ../../node_modules/ora/node_modules/chalk/source/index.js
|
|
105715
|
-
var { stdout:
|
|
105716
|
-
var
|
|
105717
|
-
var
|
|
105718
|
-
var
|
|
105719
|
-
var
|
|
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 = [
|
|
105720
105672
|
"ansi",
|
|
105721
105673
|
"ansi",
|
|
105722
105674
|
"ansi256",
|
|
105723
105675
|
"ansi16m"
|
|
105724
105676
|
];
|
|
105725
|
-
var
|
|
105726
|
-
var
|
|
105677
|
+
var styles2 = Object.create(null);
|
|
105678
|
+
var applyOptions = (object3, options = {}) => {
|
|
105727
105679
|
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
105728
105680
|
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
105729
105681
|
}
|
|
105730
|
-
const colorLevel =
|
|
105682
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
105731
105683
|
object3.level = options.level === undefined ? colorLevel : options.level;
|
|
105732
105684
|
};
|
|
105733
|
-
var
|
|
105685
|
+
var chalkFactory = (options) => {
|
|
105734
105686
|
const chalk2 = (...strings) => strings.join(" ");
|
|
105735
|
-
|
|
105736
|
-
Object.setPrototypeOf(chalk2,
|
|
105687
|
+
applyOptions(chalk2, options);
|
|
105688
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
105737
105689
|
return chalk2;
|
|
105738
105690
|
};
|
|
105739
|
-
function
|
|
105740
|
-
return
|
|
105691
|
+
function createChalk(options) {
|
|
105692
|
+
return chalkFactory(options);
|
|
105741
105693
|
}
|
|
105742
|
-
Object.setPrototypeOf(
|
|
105743
|
-
for (const [styleName, style] of Object.entries(
|
|
105744
|
-
|
|
105694
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
105695
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
105696
|
+
styles2[styleName] = {
|
|
105745
105697
|
get() {
|
|
105746
|
-
const builder =
|
|
105698
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
105747
105699
|
Object.defineProperty(this, styleName, { value: builder });
|
|
105748
105700
|
return builder;
|
|
105749
105701
|
}
|
|
105750
105702
|
};
|
|
105751
105703
|
}
|
|
105752
|
-
|
|
105704
|
+
styles2.visible = {
|
|
105753
105705
|
get() {
|
|
105754
|
-
const builder =
|
|
105706
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
105755
105707
|
Object.defineProperty(this, "visible", { value: builder });
|
|
105756
105708
|
return builder;
|
|
105757
105709
|
}
|
|
105758
105710
|
};
|
|
105759
|
-
var
|
|
105711
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
105760
105712
|
if (model === "rgb") {
|
|
105761
105713
|
if (level === "ansi16m") {
|
|
105762
|
-
return
|
|
105714
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
105763
105715
|
}
|
|
105764
105716
|
if (level === "ansi256") {
|
|
105765
|
-
return
|
|
105717
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
105766
105718
|
}
|
|
105767
|
-
return
|
|
105719
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
105768
105720
|
}
|
|
105769
105721
|
if (model === "hex") {
|
|
105770
|
-
return
|
|
105722
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
105771
105723
|
}
|
|
105772
|
-
return
|
|
105724
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
105773
105725
|
};
|
|
105774
|
-
var
|
|
105775
|
-
for (const model of
|
|
105776
|
-
|
|
105726
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
105727
|
+
for (const model of usedModels) {
|
|
105728
|
+
styles2[model] = {
|
|
105777
105729
|
get() {
|
|
105778
105730
|
const { level } = this;
|
|
105779
105731
|
return function(...arguments_) {
|
|
105780
|
-
const styler =
|
|
105781
|
-
return
|
|
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]);
|
|
105782
105734
|
};
|
|
105783
105735
|
}
|
|
105784
105736
|
};
|
|
105785
105737
|
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
105786
|
-
|
|
105738
|
+
styles2[bgModel] = {
|
|
105787
105739
|
get() {
|
|
105788
105740
|
const { level } = this;
|
|
105789
105741
|
return function(...arguments_) {
|
|
105790
|
-
const styler =
|
|
105791
|
-
return
|
|
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]);
|
|
105792
105744
|
};
|
|
105793
105745
|
}
|
|
105794
105746
|
};
|
|
105795
105747
|
}
|
|
105796
|
-
var
|
|
105797
|
-
...
|
|
105748
|
+
var proto = Object.defineProperties(() => {}, {
|
|
105749
|
+
...styles2,
|
|
105798
105750
|
level: {
|
|
105799
105751
|
enumerable: true,
|
|
105800
105752
|
get() {
|
|
105801
|
-
return this[
|
|
105753
|
+
return this[GENERATOR].level;
|
|
105802
105754
|
},
|
|
105803
105755
|
set(level) {
|
|
105804
|
-
this[
|
|
105756
|
+
this[GENERATOR].level = level;
|
|
105805
105757
|
}
|
|
105806
105758
|
}
|
|
105807
105759
|
});
|
|
105808
|
-
var
|
|
105760
|
+
var createStyler = (open, close, parent) => {
|
|
105809
105761
|
let openAll;
|
|
105810
105762
|
let closeAll;
|
|
105811
105763
|
if (parent === undefined) {
|
|
@@ -105823,46 +105775,46 @@ var createStyler2 = (open, close, parent) => {
|
|
|
105823
105775
|
parent
|
|
105824
105776
|
};
|
|
105825
105777
|
};
|
|
105826
|
-
var
|
|
105827
|
-
const builder = (...arguments_) =>
|
|
105828
|
-
Object.setPrototypeOf(builder,
|
|
105829
|
-
builder[
|
|
105830
|
-
builder[
|
|
105831
|
-
builder[
|
|
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;
|
|
105832
105784
|
return builder;
|
|
105833
105785
|
};
|
|
105834
|
-
var
|
|
105786
|
+
var applyStyle = (self2, string4) => {
|
|
105835
105787
|
if (self2.level <= 0 || !string4) {
|
|
105836
|
-
return self2[
|
|
105788
|
+
return self2[IS_EMPTY] ? "" : string4;
|
|
105837
105789
|
}
|
|
105838
|
-
let styler = self2[
|
|
105790
|
+
let styler = self2[STYLER];
|
|
105839
105791
|
if (styler === undefined) {
|
|
105840
105792
|
return string4;
|
|
105841
105793
|
}
|
|
105842
105794
|
const { openAll, closeAll } = styler;
|
|
105843
105795
|
if (string4.includes("\x1B")) {
|
|
105844
105796
|
while (styler !== undefined) {
|
|
105845
|
-
string4 =
|
|
105797
|
+
string4 = stringReplaceAll(string4, styler.close, styler.open);
|
|
105846
105798
|
styler = styler.parent;
|
|
105847
105799
|
}
|
|
105848
105800
|
}
|
|
105849
105801
|
const lfIndex = string4.indexOf(`
|
|
105850
105802
|
`);
|
|
105851
105803
|
if (lfIndex !== -1) {
|
|
105852
|
-
string4 =
|
|
105804
|
+
string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
|
|
105853
105805
|
}
|
|
105854
105806
|
return openAll + string4 + closeAll;
|
|
105855
105807
|
};
|
|
105856
|
-
Object.defineProperties(
|
|
105857
|
-
var chalk2 =
|
|
105858
|
-
var
|
|
105859
|
-
var
|
|
105808
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
105809
|
+
var chalk2 = createChalk();
|
|
105810
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
105811
|
+
var source_default = chalk2;
|
|
105860
105812
|
|
|
105861
105813
|
// ../../node_modules/cli-cursor/index.js
|
|
105862
|
-
import
|
|
105814
|
+
import process6 from "node:process";
|
|
105863
105815
|
|
|
105864
105816
|
// ../../node_modules/restore-cursor/index.js
|
|
105865
|
-
import
|
|
105817
|
+
import process5 from "node:process";
|
|
105866
105818
|
|
|
105867
105819
|
// ../../node_modules/mimic-function/index.js
|
|
105868
105820
|
var copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
|
@@ -105942,7 +105894,7 @@ onetime.callCount = (function_) => {
|
|
|
105942
105894
|
var onetime_default = onetime;
|
|
105943
105895
|
|
|
105944
105896
|
// ../../node_modules/restore-cursor/index.js
|
|
105945
|
-
var terminal =
|
|
105897
|
+
var terminal = process5.stderr.isTTY ? process5.stderr : process5.stdout.isTTY ? process5.stdout : undefined;
|
|
105946
105898
|
var restoreCursor = terminal ? onetime_default(() => {
|
|
105947
105899
|
onExit(() => {
|
|
105948
105900
|
terminal.write("\x1B[?25h");
|
|
@@ -105953,14 +105905,14 @@ var restore_cursor_default = restoreCursor;
|
|
|
105953
105905
|
// ../../node_modules/cli-cursor/index.js
|
|
105954
105906
|
var isHidden = false;
|
|
105955
105907
|
var cliCursor = {};
|
|
105956
|
-
cliCursor.show = (writableStream =
|
|
105908
|
+
cliCursor.show = (writableStream = process6.stderr) => {
|
|
105957
105909
|
if (!writableStream.isTTY) {
|
|
105958
105910
|
return;
|
|
105959
105911
|
}
|
|
105960
105912
|
isHidden = false;
|
|
105961
105913
|
writableStream.write("\x1B[?25h");
|
|
105962
105914
|
};
|
|
105963
|
-
cliCursor.hide = (writableStream =
|
|
105915
|
+
cliCursor.hide = (writableStream = process6.stderr) => {
|
|
105964
105916
|
if (!writableStream.isTTY) {
|
|
105965
105917
|
return;
|
|
105966
105918
|
}
|
|
@@ -107660,8 +107612,8 @@ __export(exports_symbols, {
|
|
|
107660
107612
|
});
|
|
107661
107613
|
|
|
107662
107614
|
// ../../node_modules/yoctocolors/base.js
|
|
107663
|
-
import
|
|
107664
|
-
var hasColors =
|
|
107615
|
+
import tty2 from "node:tty";
|
|
107616
|
+
var hasColors = tty2?.WriteStream?.prototype?.hasColors?.() ?? false;
|
|
107665
107617
|
var format = (open, close) => {
|
|
107666
107618
|
if (!hasColors) {
|
|
107667
107619
|
return (input) => input;
|
|
@@ -107730,14 +107682,14 @@ var bgCyanBright = format(106, 49);
|
|
|
107730
107682
|
var bgWhiteBright = format(107, 49);
|
|
107731
107683
|
|
|
107732
107684
|
// ../../node_modules/is-unicode-supported/index.js
|
|
107733
|
-
import
|
|
107685
|
+
import process7 from "node:process";
|
|
107734
107686
|
function isUnicodeSupported2() {
|
|
107735
|
-
const { env:
|
|
107736
|
-
const { TERM, TERM_PROGRAM } =
|
|
107737
|
-
if (
|
|
107687
|
+
const { env: env2 } = process7;
|
|
107688
|
+
const { TERM, TERM_PROGRAM } = env2;
|
|
107689
|
+
if (process7.platform !== "win32") {
|
|
107738
107690
|
return TERM !== "linux";
|
|
107739
107691
|
}
|
|
107740
|
-
return Boolean(
|
|
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";
|
|
107741
107693
|
}
|
|
107742
107694
|
|
|
107743
107695
|
// ../../node_modules/ora/node_modules/log-symbols/symbols.js
|
|
@@ -107850,7 +107802,7 @@ function isInteractive({ stream = process.stdout } = {}) {
|
|
|
107850
107802
|
}
|
|
107851
107803
|
|
|
107852
107804
|
// ../../node_modules/stdin-discarder/index.js
|
|
107853
|
-
import
|
|
107805
|
+
import process8 from "node:process";
|
|
107854
107806
|
var ASCII_ETX_CODE = 3;
|
|
107855
107807
|
|
|
107856
107808
|
class StdinDiscarder {
|
|
@@ -107871,24 +107823,24 @@ class StdinDiscarder {
|
|
|
107871
107823
|
}
|
|
107872
107824
|
}
|
|
107873
107825
|
#realStart() {
|
|
107874
|
-
if (
|
|
107826
|
+
if (process8.platform === "win32" || !process8.stdin.isTTY) {
|
|
107875
107827
|
return;
|
|
107876
107828
|
}
|
|
107877
|
-
|
|
107878
|
-
|
|
107879
|
-
|
|
107829
|
+
process8.stdin.setRawMode(true);
|
|
107830
|
+
process8.stdin.on("data", this.#handleInput);
|
|
107831
|
+
process8.stdin.resume();
|
|
107880
107832
|
}
|
|
107881
107833
|
#realStop() {
|
|
107882
|
-
if (!
|
|
107834
|
+
if (!process8.stdin.isTTY) {
|
|
107883
107835
|
return;
|
|
107884
107836
|
}
|
|
107885
|
-
|
|
107886
|
-
|
|
107887
|
-
|
|
107837
|
+
process8.stdin.off("data", this.#handleInput);
|
|
107838
|
+
process8.stdin.pause();
|
|
107839
|
+
process8.stdin.setRawMode(false);
|
|
107888
107840
|
}
|
|
107889
107841
|
#handleInput(chunk) {
|
|
107890
107842
|
if (chunk[0] === ASCII_ETX_CODE) {
|
|
107891
|
-
|
|
107843
|
+
process8.emit("SIGINT");
|
|
107892
107844
|
}
|
|
107893
107845
|
}
|
|
107894
107846
|
}
|
|
@@ -107923,7 +107875,7 @@ class Ora {
|
|
|
107923
107875
|
}
|
|
107924
107876
|
this.#options = {
|
|
107925
107877
|
color: "cyan",
|
|
107926
|
-
stream:
|
|
107878
|
+
stream: process9.stderr,
|
|
107927
107879
|
discardStdin: true,
|
|
107928
107880
|
hideCursor: true,
|
|
107929
107881
|
...options
|
|
@@ -107938,7 +107890,7 @@ class Ora {
|
|
|
107938
107890
|
this.prefixText = this.#options.prefixText;
|
|
107939
107891
|
this.suffixText = this.#options.suffixText;
|
|
107940
107892
|
this.indent = this.#options.indent;
|
|
107941
|
-
if (
|
|
107893
|
+
if (process9.env.NODE_ENV === "test") {
|
|
107942
107894
|
this._stream = this.#stream;
|
|
107943
107895
|
this._isEnabled = this.#isEnabled;
|
|
107944
107896
|
Object.defineProperty(this, "_linesToClear", {
|
|
@@ -108080,7 +108032,7 @@ class Ora {
|
|
|
108080
108032
|
const { frames } = this.#spinner;
|
|
108081
108033
|
let frame = frames[this.#frameIndex];
|
|
108082
108034
|
if (this.color) {
|
|
108083
|
-
frame =
|
|
108035
|
+
frame = source_default[this.color](frame);
|
|
108084
108036
|
}
|
|
108085
108037
|
const fullPrefixText = this.#getFullPrefixText(this.#prefixText, " ");
|
|
108086
108038
|
const fullText = typeof this.text === "string" ? " " + this.text : "";
|
|
@@ -108146,7 +108098,7 @@ class Ora {
|
|
|
108146
108098
|
if (this.#options.hideCursor) {
|
|
108147
108099
|
cli_cursor_default.hide(this.#stream);
|
|
108148
108100
|
}
|
|
108149
|
-
if (this.#options.discardStdin &&
|
|
108101
|
+
if (this.#options.discardStdin && process9.stdin.isTTY) {
|
|
108150
108102
|
this.#isDiscardingStdin = true;
|
|
108151
108103
|
stdin_discarder_default.start();
|
|
108152
108104
|
}
|
|
@@ -108164,7 +108116,7 @@ class Ora {
|
|
|
108164
108116
|
cli_cursor_default.show(this.#stream);
|
|
108165
108117
|
}
|
|
108166
108118
|
}
|
|
108167
|
-
if (this.#options.discardStdin &&
|
|
108119
|
+
if (this.#options.discardStdin && process9.stdin.isTTY && this.#isDiscardingStdin) {
|
|
108168
108120
|
stdin_discarder_default.stop();
|
|
108169
108121
|
this.#isDiscardingStdin = false;
|
|
108170
108122
|
}
|
|
@@ -108413,7 +108365,6 @@ async function handleToolCall(toolCall, context) {
|
|
|
108413
108365
|
switch (toolCall.tool) {
|
|
108414
108366
|
case "invokeAgent": {
|
|
108415
108367
|
context.spinner.stop();
|
|
108416
|
-
console.log();
|
|
108417
108368
|
const input = toolCall.input;
|
|
108418
108369
|
const model = await context.getModel(input.agent);
|
|
108419
108370
|
const AgentClass = agentRegistry[input.agent] ?? WorkflowAgent;
|
|
@@ -108435,23 +108386,42 @@ async function handleToolCall(toolCall, context) {
|
|
|
108435
108386
|
const userPrompt = input.messages.filter((m) => typeof m === "string" || m.type !== "system").map((m) => typeof m === "string" ? m : m.content).join(`
|
|
108436
108387
|
|
|
108437
108388
|
`);
|
|
108438
|
-
|
|
108389
|
+
let exitReason = await agent.start(userPrompt);
|
|
108439
108390
|
context.spinner.start();
|
|
108440
|
-
|
|
108441
|
-
|
|
108442
|
-
|
|
108443
|
-
|
|
108444
|
-
|
|
108445
|
-
|
|
108446
|
-
|
|
108447
|
-
|
|
108448
|
-
|
|
108449
|
-
|
|
108450
|
-
|
|
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;
|
|
108451
108421
|
}
|
|
108452
|
-
return
|
|
108422
|
+
return parsed.data;
|
|
108453
108423
|
}
|
|
108454
|
-
|
|
108424
|
+
throw new Error("Agent failed to produce valid output after 5 retries.");
|
|
108455
108425
|
}
|
|
108456
108426
|
case "createPullRequest": {
|
|
108457
108427
|
const { title, description } = toolCall.input;
|
|
@@ -108463,7 +108433,6 @@ async function handleToolCall(toolCall, context) {
|
|
|
108463
108433
|
case "createCommit": {
|
|
108464
108434
|
const { message } = toolCall.input;
|
|
108465
108435
|
context.spinner.stop();
|
|
108466
|
-
console.log();
|
|
108467
108436
|
const result = spawnSync2("git", ["commit", "-m", message], { stdio: "inherit" });
|
|
108468
108437
|
if (result.status !== 0) {
|
|
108469
108438
|
throw new Error("Commit failed");
|
|
@@ -108473,7 +108442,6 @@ async function handleToolCall(toolCall, context) {
|
|
|
108473
108442
|
}
|
|
108474
108443
|
case "printChangeFile": {
|
|
108475
108444
|
context.spinner.stop();
|
|
108476
|
-
console.log();
|
|
108477
108445
|
const { stagedFiles, unstagedFiles } = getLocalChanges();
|
|
108478
108446
|
if (stagedFiles.length === 0 && unstagedFiles.length === 0) {
|
|
108479
108447
|
console.log("No changes to commit.");
|
|
@@ -108498,7 +108466,6 @@ Unstaged files:`);
|
|
|
108498
108466
|
case "confirm": {
|
|
108499
108467
|
const { message } = toolCall.input;
|
|
108500
108468
|
context.spinner.stop();
|
|
108501
|
-
console.log();
|
|
108502
108469
|
await new Promise((resolve7) => setTimeout(resolve7, 50));
|
|
108503
108470
|
try {
|
|
108504
108471
|
const result = await esm_default2({ message });
|
|
@@ -108508,6 +108475,23 @@ Unstaged files:`);
|
|
|
108508
108475
|
throw new UserCancelledError;
|
|
108509
108476
|
}
|
|
108510
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
|
+
}
|
|
108511
108495
|
default:
|
|
108512
108496
|
throw new Error(`Unknown tool: ${String(toolCall.tool)}`);
|
|
108513
108497
|
}
|
|
@@ -108532,7 +108516,7 @@ async function runWorkflow(commandName, workflow2, command, workflowInput, requi
|
|
|
108532
108516
|
const agentConfig = providerConfig.getConfigForCommand(commandName);
|
|
108533
108517
|
const parameters = {
|
|
108534
108518
|
toolFormat: config4.toolFormat,
|
|
108535
|
-
os:
|
|
108519
|
+
os: os4.platform(),
|
|
108536
108520
|
policies: [EnableCachePolicy],
|
|
108537
108521
|
modelParameters: agentConfig?.parameters,
|
|
108538
108522
|
scripts: config4.scripts,
|
|
@@ -108588,9 +108572,7 @@ async function runWorkflow(commandName, workflow2, command, workflowInput, requi
|
|
|
108588
108572
|
spinner.warn("Workflow cancelled by user.");
|
|
108589
108573
|
} else {
|
|
108590
108574
|
spinner.fail(`Workflow failed: ${error44.message}`);
|
|
108591
|
-
|
|
108592
|
-
logger.error(error44);
|
|
108593
|
-
}
|
|
108575
|
+
logger.error(error44);
|
|
108594
108576
|
}
|
|
108595
108577
|
}
|
|
108596
108578
|
spinner.stop();
|
|
@@ -108917,6 +108899,96 @@ ${provider3.toUpperCase()}_API_KEY=${providerConfig.apiKey}`;
|
|
|
108917
108899
|
return { configPath };
|
|
108918
108900
|
}
|
|
108919
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
|
+
};
|
|
108920
108992
|
// src/workflows/pr.workflow.ts
|
|
108921
108993
|
import { execSync as execSync3 } from "node:child_process";
|
|
108922
108994
|
var prDetailsSchema = exports_external.object({
|
|
@@ -109461,6 +109533,27 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
109461
109533
|
}, false);
|
|
109462
109534
|
});
|
|
109463
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
|
+
|
|
109464
109557
|
// src/commands/pr.ts
|
|
109465
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) => {
|
|
109466
109559
|
const input = { ...message && { context: message } };
|
|
@@ -109666,6 +109759,7 @@ program2.addCommand(commitCommand);
|
|
|
109666
109759
|
program2.addCommand(prCommand);
|
|
109667
109760
|
program2.addCommand(reviewCommand);
|
|
109668
109761
|
program2.addCommand(createCommand2);
|
|
109762
|
+
program2.addCommand(planCommand);
|
|
109669
109763
|
addSharedOptions(program2);
|
|
109670
109764
|
program2.parse();
|
|
109671
109765
|
process.on("uncaughtException", (error44) => {
|