@polka-codes/cli 0.9.9 → 0.9.11
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 +192 -100
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -677,7 +677,11 @@ var require_help = __commonJS((exports) => {
|
|
|
677
677
|
extraInfo.push(`env: ${option.envVar}`);
|
|
678
678
|
}
|
|
679
679
|
if (extraInfo.length > 0) {
|
|
680
|
-
|
|
680
|
+
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
681
|
+
if (option.description) {
|
|
682
|
+
return `${option.description} ${extraDescription}`;
|
|
683
|
+
}
|
|
684
|
+
return extraDescription;
|
|
681
685
|
}
|
|
682
686
|
return option.description;
|
|
683
687
|
}
|
|
@@ -698,6 +702,27 @@ var require_help = __commonJS((exports) => {
|
|
|
698
702
|
}
|
|
699
703
|
return argument.description;
|
|
700
704
|
}
|
|
705
|
+
formatItemList(heading, items, helper) {
|
|
706
|
+
if (items.length === 0)
|
|
707
|
+
return [];
|
|
708
|
+
return [helper.styleTitle(heading), ...items, ""];
|
|
709
|
+
}
|
|
710
|
+
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
711
|
+
const result = new Map;
|
|
712
|
+
unsortedItems.forEach((item) => {
|
|
713
|
+
const group = getGroup(item);
|
|
714
|
+
if (!result.has(group))
|
|
715
|
+
result.set(group, []);
|
|
716
|
+
});
|
|
717
|
+
visibleItems.forEach((item) => {
|
|
718
|
+
const group = getGroup(item);
|
|
719
|
+
if (!result.has(group)) {
|
|
720
|
+
result.set(group, []);
|
|
721
|
+
}
|
|
722
|
+
result.get(group).push(item);
|
|
723
|
+
});
|
|
724
|
+
return result;
|
|
725
|
+
}
|
|
701
726
|
formatHelp(cmd, helper) {
|
|
702
727
|
const termWidth = helper.padWidth(cmd, helper);
|
|
703
728
|
const helpWidth = helper.helpWidth ?? 80;
|
|
@@ -718,45 +743,27 @@ var require_help = __commonJS((exports) => {
|
|
|
718
743
|
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
719
744
|
return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
|
|
720
745
|
});
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
const optionList = helper.visibleOptions(cmd).map((option) => {
|
|
729
|
-
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
746
|
+
output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
|
|
747
|
+
const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
|
|
748
|
+
optionGroups.forEach((options, group) => {
|
|
749
|
+
const optionList = options.map((option) => {
|
|
750
|
+
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
751
|
+
});
|
|
752
|
+
output = output.concat(this.formatItemList(group, optionList, helper));
|
|
730
753
|
});
|
|
731
|
-
if (optionList.length > 0) {
|
|
732
|
-
output = output.concat([
|
|
733
|
-
helper.styleTitle("Options:"),
|
|
734
|
-
...optionList,
|
|
735
|
-
""
|
|
736
|
-
]);
|
|
737
|
-
}
|
|
738
754
|
if (helper.showGlobalOptions) {
|
|
739
755
|
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
740
756
|
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
741
757
|
});
|
|
742
|
-
|
|
743
|
-
output = output.concat([
|
|
744
|
-
helper.styleTitle("Global Options:"),
|
|
745
|
-
...globalOptionList,
|
|
746
|
-
""
|
|
747
|
-
]);
|
|
748
|
-
}
|
|
758
|
+
output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
|
|
749
759
|
}
|
|
750
|
-
const
|
|
751
|
-
|
|
760
|
+
const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
|
|
761
|
+
commandGroups.forEach((commands, group) => {
|
|
762
|
+
const commandList = commands.map((sub) => {
|
|
763
|
+
return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
|
|
764
|
+
});
|
|
765
|
+
output = output.concat(this.formatItemList(group, commandList, helper));
|
|
752
766
|
});
|
|
753
|
-
if (commandList.length > 0) {
|
|
754
|
-
output = output.concat([
|
|
755
|
-
helper.styleTitle("Commands:"),
|
|
756
|
-
...commandList,
|
|
757
|
-
""
|
|
758
|
-
]);
|
|
759
|
-
}
|
|
760
767
|
return output.join(`
|
|
761
768
|
`);
|
|
762
769
|
}
|
|
@@ -913,6 +920,7 @@ var require_option = __commonJS((exports) => {
|
|
|
913
920
|
this.argChoices = undefined;
|
|
914
921
|
this.conflictsWith = [];
|
|
915
922
|
this.implied = undefined;
|
|
923
|
+
this.helpGroupHeading = undefined;
|
|
916
924
|
}
|
|
917
925
|
default(value, description) {
|
|
918
926
|
this.defaultValue = value;
|
|
@@ -982,6 +990,10 @@ var require_option = __commonJS((exports) => {
|
|
|
982
990
|
}
|
|
983
991
|
return camelcase(this.name());
|
|
984
992
|
}
|
|
993
|
+
helpGroup(heading) {
|
|
994
|
+
this.helpGroupHeading = heading;
|
|
995
|
+
return this;
|
|
996
|
+
}
|
|
985
997
|
is(arg) {
|
|
986
998
|
return this.short === arg || this.long === arg;
|
|
987
999
|
}
|
|
@@ -1199,6 +1211,9 @@ var require_command = __commonJS((exports) => {
|
|
|
1199
1211
|
this._addImplicitHelpCommand = undefined;
|
|
1200
1212
|
this._helpCommand = undefined;
|
|
1201
1213
|
this._helpConfiguration = {};
|
|
1214
|
+
this._helpGroupHeading = undefined;
|
|
1215
|
+
this._defaultCommandGroup = undefined;
|
|
1216
|
+
this._defaultOptionGroup = undefined;
|
|
1202
1217
|
}
|
|
1203
1218
|
copyInheritedSettings(sourceCommand) {
|
|
1204
1219
|
this._outputConfiguration = sourceCommand._outputConfiguration;
|
|
@@ -1263,7 +1278,7 @@ var require_command = __commonJS((exports) => {
|
|
|
1263
1278
|
configureOutput(configuration) {
|
|
1264
1279
|
if (configuration === undefined)
|
|
1265
1280
|
return this._outputConfiguration;
|
|
1266
|
-
Object.assign(this._outputConfiguration, configuration);
|
|
1281
|
+
this._outputConfiguration = Object.assign({}, this._outputConfiguration, configuration);
|
|
1267
1282
|
return this;
|
|
1268
1283
|
}
|
|
1269
1284
|
showHelpAfterError(displayHelp = true) {
|
|
@@ -1294,12 +1309,12 @@ var require_command = __commonJS((exports) => {
|
|
|
1294
1309
|
createArgument(name, description) {
|
|
1295
1310
|
return new Argument(name, description);
|
|
1296
1311
|
}
|
|
1297
|
-
argument(name, description,
|
|
1312
|
+
argument(name, description, parseArg, defaultValue) {
|
|
1298
1313
|
const argument = this.createArgument(name, description);
|
|
1299
|
-
if (typeof
|
|
1300
|
-
argument.default(defaultValue).argParser(
|
|
1314
|
+
if (typeof parseArg === "function") {
|
|
1315
|
+
argument.default(defaultValue).argParser(parseArg);
|
|
1301
1316
|
} else {
|
|
1302
|
-
argument.default(
|
|
1317
|
+
argument.default(parseArg);
|
|
1303
1318
|
}
|
|
1304
1319
|
this.addArgument(argument);
|
|
1305
1320
|
return this;
|
|
@@ -1324,10 +1339,13 @@ var require_command = __commonJS((exports) => {
|
|
|
1324
1339
|
helpCommand(enableOrNameAndArgs, description) {
|
|
1325
1340
|
if (typeof enableOrNameAndArgs === "boolean") {
|
|
1326
1341
|
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
1342
|
+
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
1343
|
+
this._initCommandGroup(this._getHelpCommand());
|
|
1344
|
+
}
|
|
1327
1345
|
return this;
|
|
1328
1346
|
}
|
|
1329
|
-
|
|
1330
|
-
const [, helpName, helpArgs] =
|
|
1347
|
+
const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
|
|
1348
|
+
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1331
1349
|
const helpDescription = description ?? "display help for command";
|
|
1332
1350
|
const helpCommand = this.createCommand(helpName);
|
|
1333
1351
|
helpCommand.helpOption(false);
|
|
@@ -1337,6 +1355,8 @@ var require_command = __commonJS((exports) => {
|
|
|
1337
1355
|
helpCommand.description(helpDescription);
|
|
1338
1356
|
this._addImplicitHelpCommand = true;
|
|
1339
1357
|
this._helpCommand = helpCommand;
|
|
1358
|
+
if (enableOrNameAndArgs || description)
|
|
1359
|
+
this._initCommandGroup(helpCommand);
|
|
1340
1360
|
return this;
|
|
1341
1361
|
}
|
|
1342
1362
|
addHelpCommand(helpCommand, deprecatedDescription) {
|
|
@@ -1346,6 +1366,7 @@ var require_command = __commonJS((exports) => {
|
|
|
1346
1366
|
}
|
|
1347
1367
|
this._addImplicitHelpCommand = true;
|
|
1348
1368
|
this._helpCommand = helpCommand;
|
|
1369
|
+
this._initCommandGroup(helpCommand);
|
|
1349
1370
|
return this;
|
|
1350
1371
|
}
|
|
1351
1372
|
_getHelpCommand() {
|
|
@@ -1425,6 +1446,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1425
1446
|
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
1426
1447
|
- already used by option '${matchingOption.flags}'`);
|
|
1427
1448
|
}
|
|
1449
|
+
this._initOptionGroup(option);
|
|
1428
1450
|
this.options.push(option);
|
|
1429
1451
|
}
|
|
1430
1452
|
_registerCommand(command) {
|
|
@@ -1437,6 +1459,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1437
1459
|
const newCmd = knownBy(command).join("|");
|
|
1438
1460
|
throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
|
|
1439
1461
|
}
|
|
1462
|
+
this._initCommandGroup(command);
|
|
1440
1463
|
this.commands.push(command);
|
|
1441
1464
|
}
|
|
1442
1465
|
addOption(option) {
|
|
@@ -1981,6 +2004,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1981
2004
|
function maybeOption(arg) {
|
|
1982
2005
|
return arg.length > 1 && arg[0] === "-";
|
|
1983
2006
|
}
|
|
2007
|
+
const negativeNumberArg = (arg) => {
|
|
2008
|
+
if (!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(arg))
|
|
2009
|
+
return false;
|
|
2010
|
+
return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
|
|
2011
|
+
};
|
|
1984
2012
|
let activeVariadicOption = null;
|
|
1985
2013
|
while (args.length) {
|
|
1986
2014
|
const arg = args.shift();
|
|
@@ -1990,7 +2018,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1990
2018
|
dest.push(...args);
|
|
1991
2019
|
break;
|
|
1992
2020
|
}
|
|
1993
|
-
if (activeVariadicOption && !maybeOption(arg)) {
|
|
2021
|
+
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
1994
2022
|
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
1995
2023
|
continue;
|
|
1996
2024
|
}
|
|
@@ -2005,7 +2033,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2005
2033
|
this.emit(`option:${option.name()}`, value);
|
|
2006
2034
|
} else if (option.optional) {
|
|
2007
2035
|
let value = null;
|
|
2008
|
-
if (args.length > 0 && !maybeOption(args[0])) {
|
|
2036
|
+
if (args.length > 0 && (!maybeOption(args[0]) || negativeNumberArg(args[0]))) {
|
|
2009
2037
|
value = args.shift();
|
|
2010
2038
|
}
|
|
2011
2039
|
this.emit(`option:${option.name()}`, value);
|
|
@@ -2036,7 +2064,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2036
2064
|
continue;
|
|
2037
2065
|
}
|
|
2038
2066
|
}
|
|
2039
|
-
if (maybeOption(arg)) {
|
|
2067
|
+
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
2040
2068
|
dest = unknown;
|
|
2041
2069
|
}
|
|
2042
2070
|
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
|
|
@@ -2271,6 +2299,32 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2271
2299
|
this._name = str;
|
|
2272
2300
|
return this;
|
|
2273
2301
|
}
|
|
2302
|
+
helpGroup(heading) {
|
|
2303
|
+
if (heading === undefined)
|
|
2304
|
+
return this._helpGroupHeading ?? "";
|
|
2305
|
+
this._helpGroupHeading = heading;
|
|
2306
|
+
return this;
|
|
2307
|
+
}
|
|
2308
|
+
commandsGroup(heading) {
|
|
2309
|
+
if (heading === undefined)
|
|
2310
|
+
return this._defaultCommandGroup ?? "";
|
|
2311
|
+
this._defaultCommandGroup = heading;
|
|
2312
|
+
return this;
|
|
2313
|
+
}
|
|
2314
|
+
optionsGroup(heading) {
|
|
2315
|
+
if (heading === undefined)
|
|
2316
|
+
return this._defaultOptionGroup ?? "";
|
|
2317
|
+
this._defaultOptionGroup = heading;
|
|
2318
|
+
return this;
|
|
2319
|
+
}
|
|
2320
|
+
_initOptionGroup(option) {
|
|
2321
|
+
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
2322
|
+
option.helpGroup(this._defaultOptionGroup);
|
|
2323
|
+
}
|
|
2324
|
+
_initCommandGroup(cmd) {
|
|
2325
|
+
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
2326
|
+
cmd.helpGroup(this._defaultCommandGroup);
|
|
2327
|
+
}
|
|
2274
2328
|
nameFromFilename(filename) {
|
|
2275
2329
|
this._name = path.basename(filename, path.extname(filename));
|
|
2276
2330
|
return this;
|
|
@@ -2347,15 +2401,19 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2347
2401
|
helpOption(flags, description) {
|
|
2348
2402
|
if (typeof flags === "boolean") {
|
|
2349
2403
|
if (flags) {
|
|
2350
|
-
|
|
2404
|
+
if (this._helpOption === null)
|
|
2405
|
+
this._helpOption = undefined;
|
|
2406
|
+
if (this._defaultOptionGroup) {
|
|
2407
|
+
this._initOptionGroup(this._getHelpOption());
|
|
2408
|
+
}
|
|
2351
2409
|
} else {
|
|
2352
2410
|
this._helpOption = null;
|
|
2353
2411
|
}
|
|
2354
2412
|
return this;
|
|
2355
2413
|
}
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2414
|
+
this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
|
|
2415
|
+
if (flags || description)
|
|
2416
|
+
this._initOptionGroup(this._helpOption);
|
|
2359
2417
|
return this;
|
|
2360
2418
|
}
|
|
2361
2419
|
_getHelpOption() {
|
|
@@ -2366,6 +2424,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2366
2424
|
}
|
|
2367
2425
|
addHelpOption(option) {
|
|
2368
2426
|
this._helpOption = option;
|
|
2427
|
+
this._initOptionGroup(option);
|
|
2369
2428
|
return this;
|
|
2370
2429
|
}
|
|
2371
2430
|
help(contextOptions) {
|
|
@@ -39731,7 +39790,7 @@ var {
|
|
|
39731
39790
|
Help
|
|
39732
39791
|
} = import__.default;
|
|
39733
39792
|
// package.json
|
|
39734
|
-
var version = "0.9.
|
|
39793
|
+
var version = "0.9.11";
|
|
39735
39794
|
|
|
39736
39795
|
// ../../node_modules/@inquirer/core/dist/esm/lib/key.js
|
|
39737
39796
|
var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
|
|
@@ -76369,7 +76428,17 @@ ${Object.entries(example.input).map(([name17, value]) => renderParameterValue(na
|
|
|
76369
76428
|
`)}
|
|
76370
76429
|
</${toolNamePrefix}${tool2.name}>
|
|
76371
76430
|
`;
|
|
76372
|
-
var toolUsePrompt = (tools, toolNamePrefix) => {
|
|
76431
|
+
var toolUsePrompt = (useNativeTool, tools, toolNamePrefix) => {
|
|
76432
|
+
if (useNativeTool) {
|
|
76433
|
+
return `
|
|
76434
|
+
====
|
|
76435
|
+
|
|
76436
|
+
TOOL USE
|
|
76437
|
+
|
|
76438
|
+
- You MUST use a tool.
|
|
76439
|
+
- Batch tool use when feasible; avoid redundant calls.
|
|
76440
|
+
`;
|
|
76441
|
+
}
|
|
76373
76442
|
if (tools.length === 0) {
|
|
76374
76443
|
return "";
|
|
76375
76444
|
}
|
|
@@ -76720,7 +76789,8 @@ ${instance.prompt}`;
|
|
|
76720
76789
|
}
|
|
76721
76790
|
if (requestTimeoutSeconds > 0 && requestAbortController) {
|
|
76722
76791
|
timeout = setTimeout(() => {
|
|
76723
|
-
console.debug(`
|
|
76792
|
+
console.debug(`
|
|
76793
|
+
Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`);
|
|
76724
76794
|
requestAbortController?.abort();
|
|
76725
76795
|
}, requestTimeoutSeconds * 1000);
|
|
76726
76796
|
}
|
|
@@ -76781,7 +76851,15 @@ ${instance.prompt}`;
|
|
|
76781
76851
|
}
|
|
76782
76852
|
}
|
|
76783
76853
|
if (this.config.toolFormat === "native") {
|
|
76784
|
-
if (respMessages.some((m) =>
|
|
76854
|
+
if (respMessages.some((m) => {
|
|
76855
|
+
if (m.role === "tool") {
|
|
76856
|
+
return true;
|
|
76857
|
+
}
|
|
76858
|
+
if (typeof m.content === "string") {
|
|
76859
|
+
return true;
|
|
76860
|
+
}
|
|
76861
|
+
return m.content.some((part) => part.type === "tool-call" || part.type === "tool-result" || part.type === "text");
|
|
76862
|
+
})) {
|
|
76785
76863
|
break;
|
|
76786
76864
|
}
|
|
76787
76865
|
} else {
|
|
@@ -76793,7 +76871,8 @@ ${instance.prompt}`;
|
|
|
76793
76871
|
break;
|
|
76794
76872
|
}
|
|
76795
76873
|
if (i < retryCount - 1) {
|
|
76796
|
-
console.debug(`
|
|
76874
|
+
console.debug(`
|
|
76875
|
+
Retrying request ${i + 2} of ${retryCount}`);
|
|
76797
76876
|
}
|
|
76798
76877
|
}
|
|
76799
76878
|
if (respMessages.length === 0) {
|
|
@@ -77031,7 +77110,7 @@ You are the **Analyzer** agent, responsible for:
|
|
|
77031
77110
|
5. **Documentation Assessment**: Review documentation quality and completeness.
|
|
77032
77111
|
6. **Non-Modification**: Never modify code or files - focus solely on analysis.
|
|
77033
77112
|
|
|
77034
|
-
${useNativeTool
|
|
77113
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
77035
77114
|
${capabilities(toolNamePrefix)}
|
|
77036
77115
|
${systemInformation(info)}
|
|
77037
77116
|
${customInstructions(instructions)}
|
|
@@ -77106,6 +77185,7 @@ You are the **Architect** agent, responsible for:
|
|
|
77106
77185
|
4. **Accuracy** - Ensure conclusions are verifiable.
|
|
77107
77186
|
5. **Clarity** - Present information in a structured format.
|
|
77108
77187
|
6. **Minimal Queries** - Ask questions only when truly needed.
|
|
77188
|
+
7. **Completion** - Only use the \`attemptCompletion\` tool if the user's request has been fully satisfied and no coding tasks need to be delegated to the Coder agent.
|
|
77109
77189
|
|
|
77110
77190
|
## Steps
|
|
77111
77191
|
1. **Analyze Task** - Capture goals, constraints, and success criteria.
|
|
@@ -77119,9 +77199,9 @@ You are the **Architect** agent, responsible for:
|
|
|
77119
77199
|
6. **Handover/Delegate**
|
|
77120
77200
|
- If the plan consists of a single self-contained step, hand it over as one task.
|
|
77121
77201
|
- If multiple steps are required, break them into numbered tasks to delegate to the **Coder** agent.
|
|
77122
|
-
-
|
|
77202
|
+
- When handing over or delegating, you MUST provide the full implementation plan. Include all necessary context, file references, and clarifications for successful execution.
|
|
77123
77203
|
|
|
77124
|
-
${useNativeTool
|
|
77204
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
77125
77205
|
${capabilities(toolNamePrefix)}
|
|
77126
77206
|
${systemInformation(info)}
|
|
77127
77207
|
${customInstructions(instructions)}
|
|
@@ -77241,7 +77321,7 @@ RETRY GUIDELINES
|
|
|
77241
77321
|
- Report any partial improvements`;
|
|
77242
77322
|
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
|
|
77243
77323
|
${basePrompt}
|
|
77244
|
-
${useNativeTool
|
|
77324
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
77245
77325
|
${codeFixingStrategies}
|
|
77246
77326
|
${retryGuidelines}
|
|
77247
77327
|
${capabilities(toolNamePrefix)}
|
|
@@ -77440,7 +77520,7 @@ You solve the user's task by working in small, verifiable steps.
|
|
|
77440
77520
|
`;
|
|
77441
77521
|
var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
|
|
77442
77522
|
${basePrompt2}
|
|
77443
|
-
${useNativeTool
|
|
77523
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
77444
77524
|
${editingFilesPrompt(toolNamePrefix)}
|
|
77445
77525
|
${capabilities(toolNamePrefix)}
|
|
77446
77526
|
${rules(toolNamePrefix)}
|
|
@@ -109082,54 +109162,54 @@ var source_default = chalk;
|
|
|
109082
109162
|
|
|
109083
109163
|
// ../cli-shared/src/utils/eventHandler.ts
|
|
109084
109164
|
var toolCallStats = new Map;
|
|
109085
|
-
var printEvent = (verbose, usageMeter) => {
|
|
109165
|
+
var printEvent = (verbose, usageMeter, customConsole = console) => {
|
|
109086
109166
|
let hadReasoning = false;
|
|
109087
109167
|
return (event) => {
|
|
109088
109168
|
switch (event.kind) {
|
|
109089
109169
|
case "StartTask" /* StartTask */:
|
|
109090
109170
|
toolCallStats.clear();
|
|
109091
109171
|
if (verbose > 1) {
|
|
109092
|
-
|
|
109172
|
+
customConsole.log(`
|
|
109093
109173
|
====== System Prompt ======
|
|
109094
109174
|
${event.systemPrompt}`);
|
|
109095
|
-
|
|
109175
|
+
customConsole.log(`
|
|
109096
109176
|
|
|
109097
109177
|
================
|
|
109098
109178
|
`);
|
|
109099
109179
|
}
|
|
109100
109180
|
break;
|
|
109101
109181
|
case "StartRequest" /* StartRequest */:
|
|
109102
|
-
|
|
109182
|
+
customConsole.log(`
|
|
109103
109183
|
|
|
109104
109184
|
======== New Request ========
|
|
109105
109185
|
`);
|
|
109106
109186
|
if (verbose) {
|
|
109107
109187
|
const userMessage = event.userMessage.content;
|
|
109108
109188
|
if (typeof userMessage === "string") {
|
|
109109
|
-
|
|
109189
|
+
customConsole.log(userMessage);
|
|
109110
109190
|
} else {
|
|
109111
109191
|
for (const content of userMessage) {
|
|
109112
109192
|
switch (content.type) {
|
|
109113
109193
|
case "text":
|
|
109114
|
-
|
|
109194
|
+
customConsole.log(content.text);
|
|
109115
109195
|
break;
|
|
109116
109196
|
case "image":
|
|
109117
109197
|
if (content.image instanceof URL) {
|
|
109118
|
-
|
|
109198
|
+
customConsole.log(source_default.yellow(`[Image content from URL: ${content.image}]`));
|
|
109119
109199
|
} else {
|
|
109120
|
-
|
|
109200
|
+
customConsole.log(source_default.yellow(`[Image content: ${content.mediaType}]`));
|
|
109121
109201
|
}
|
|
109122
109202
|
break;
|
|
109123
109203
|
case "file":
|
|
109124
|
-
|
|
109204
|
+
customConsole.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
|
|
109125
109205
|
break;
|
|
109126
109206
|
case "tool-call":
|
|
109127
|
-
|
|
109207
|
+
customConsole.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
|
|
109128
109208
|
break;
|
|
109129
109209
|
case "tool-result":
|
|
109130
|
-
|
|
109210
|
+
customConsole.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
|
|
109131
109211
|
if (verbose > 0) {
|
|
109132
|
-
|
|
109212
|
+
customConsole.log(content.output);
|
|
109133
109213
|
}
|
|
109134
109214
|
break;
|
|
109135
109215
|
case "reasoning":
|
|
@@ -109137,14 +109217,14 @@ ${event.systemPrompt}`);
|
|
|
109137
109217
|
}
|
|
109138
109218
|
}
|
|
109139
109219
|
}
|
|
109140
|
-
|
|
109220
|
+
customConsole.log(`
|
|
109141
109221
|
|
|
109142
109222
|
======== Request Message Ended ========
|
|
109143
109223
|
`);
|
|
109144
109224
|
}
|
|
109145
109225
|
break;
|
|
109146
109226
|
case "EndRequest" /* EndRequest */:
|
|
109147
|
-
|
|
109227
|
+
customConsole.log(`
|
|
109148
109228
|
|
|
109149
109229
|
======== Request Ended ========
|
|
109150
109230
|
`);
|
|
@@ -109155,6 +109235,9 @@ ${event.systemPrompt}`);
|
|
|
109155
109235
|
case "Usage" /* Usage */:
|
|
109156
109236
|
break;
|
|
109157
109237
|
case "Text" /* Text */:
|
|
109238
|
+
if (customConsole !== console) {
|
|
109239
|
+
break;
|
|
109240
|
+
}
|
|
109158
109241
|
if (hadReasoning) {
|
|
109159
109242
|
process.stdout.write(`
|
|
109160
109243
|
|
|
@@ -109164,11 +109247,14 @@ ${event.systemPrompt}`);
|
|
|
109164
109247
|
process.stdout.write(event.newText);
|
|
109165
109248
|
break;
|
|
109166
109249
|
case "Reasoning" /* Reasoning */:
|
|
109250
|
+
if (customConsole !== console) {
|
|
109251
|
+
break;
|
|
109252
|
+
}
|
|
109167
109253
|
process.stdout.write(source_default.dim(event.newText));
|
|
109168
109254
|
hadReasoning = true;
|
|
109169
109255
|
break;
|
|
109170
109256
|
case "ToolUse" /* ToolUse */: {
|
|
109171
|
-
|
|
109257
|
+
customConsole.log(source_default.yellow(`
|
|
109172
109258
|
|
|
109173
109259
|
Tool use:`, event.tool), event.content);
|
|
109174
109260
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
@@ -109185,10 +109271,10 @@ Tool use:`, event.tool), event.content);
|
|
|
109185
109271
|
case "ToolInvalid" /* ToolInvalid */:
|
|
109186
109272
|
break;
|
|
109187
109273
|
case "ToolError" /* ToolError */: {
|
|
109188
|
-
|
|
109274
|
+
customConsole.error(source_default.red(`
|
|
109189
109275
|
|
|
109190
109276
|
Tool error:`, event.tool));
|
|
109191
|
-
|
|
109277
|
+
customConsole.error(source_default.red(event.content));
|
|
109192
109278
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
109193
109279
|
stats.errors++;
|
|
109194
109280
|
toolCallStats.set(event.tool, stats);
|
|
@@ -109197,48 +109283,48 @@ Tool error:`, event.tool));
|
|
|
109197
109283
|
case "ToolInterrupted" /* ToolInterrupted */:
|
|
109198
109284
|
break;
|
|
109199
109285
|
case "ToolHandOver" /* ToolHandOver */:
|
|
109200
|
-
|
|
109286
|
+
customConsole.log(`
|
|
109201
109287
|
|
|
109202
109288
|
======== Task Handed Over ========
|
|
109203
109289
|
`);
|
|
109204
|
-
|
|
109205
|
-
|
|
109206
|
-
|
|
109207
|
-
|
|
109208
|
-
|
|
109290
|
+
customConsole.log("Agent:", event.agentName);
|
|
109291
|
+
customConsole.log("Task:", event.task);
|
|
109292
|
+
customConsole.log("Context:", event.context);
|
|
109293
|
+
customConsole.log("Files:", event.files);
|
|
109294
|
+
customConsole.log();
|
|
109209
109295
|
break;
|
|
109210
109296
|
case "ToolDelegate" /* ToolDelegate */:
|
|
109211
|
-
|
|
109297
|
+
customConsole.log(`
|
|
109212
109298
|
|
|
109213
109299
|
======== Task Delegated ========
|
|
109214
109300
|
`);
|
|
109215
|
-
|
|
109216
|
-
|
|
109217
|
-
|
|
109218
|
-
|
|
109219
|
-
|
|
109301
|
+
customConsole.log("Agent:", event.agentName);
|
|
109302
|
+
customConsole.log("Task:", event.task);
|
|
109303
|
+
customConsole.log("Context:", event.context);
|
|
109304
|
+
customConsole.log("Files:", event.files);
|
|
109305
|
+
customConsole.log();
|
|
109220
109306
|
break;
|
|
109221
109307
|
case "UsageExceeded" /* UsageExceeded */:
|
|
109222
|
-
|
|
109308
|
+
customConsole.log(`
|
|
109223
109309
|
|
|
109224
109310
|
======= Usage Exceeded ========
|
|
109225
109311
|
`);
|
|
109226
109312
|
break;
|
|
109227
109313
|
case "EndTask" /* EndTask */:
|
|
109228
|
-
|
|
109314
|
+
customConsole.log(`
|
|
109229
109315
|
|
|
109230
109316
|
======== Task Ended ========
|
|
109231
109317
|
`);
|
|
109232
|
-
|
|
109318
|
+
customConsole.log("Reason:", event.exitReason.type);
|
|
109233
109319
|
switch (event.exitReason.type) {
|
|
109234
109320
|
case "Exit" /* Exit */:
|
|
109235
|
-
|
|
109321
|
+
customConsole.log("Exit Message:", event.exitReason.message);
|
|
109236
109322
|
break;
|
|
109237
109323
|
case "Interrupted" /* Interrupted */:
|
|
109238
|
-
|
|
109324
|
+
customConsole.log("Interrupted Message:", event.exitReason.message);
|
|
109239
109325
|
break;
|
|
109240
109326
|
}
|
|
109241
|
-
|
|
109327
|
+
customConsole.log(`
|
|
109242
109328
|
|
|
109243
109329
|
======== Tool Call Stats ========`);
|
|
109244
109330
|
if (toolCallStats.size > 0) {
|
|
@@ -109252,9 +109338,9 @@ Tool error:`, event.tool));
|
|
|
109252
109338
|
"Success Rate": `${successRate.toFixed(2)}%`
|
|
109253
109339
|
};
|
|
109254
109340
|
});
|
|
109255
|
-
|
|
109341
|
+
customConsole.table(tableData);
|
|
109256
109342
|
} else {
|
|
109257
|
-
|
|
109343
|
+
customConsole.log("No tools were called.");
|
|
109258
109344
|
}
|
|
109259
109345
|
break;
|
|
109260
109346
|
}
|
|
@@ -109263,7 +109349,7 @@ Tool error:`, event.tool));
|
|
|
109263
109349
|
// src/options.ts
|
|
109264
109350
|
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
109265
109351
|
function addSharedOptions(command) {
|
|
109266
|
-
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.
|
|
109352
|
+
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("--retry-count <count>", "Number of retries for failed requests.", Number.parseInt).option("--request-timeout-seconds <seconds>", "Request timeout in seconds.", Number.parseInt).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)");
|
|
109267
109353
|
}
|
|
109268
109354
|
function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
|
|
109269
109355
|
let cwd = cwdArg;
|
|
@@ -109502,7 +109588,9 @@ class Runner {
|
|
|
109502
109588
|
ret += `
|
|
109503
109589
|
<file_content path="${file4}">${fileContent}</file_content>`;
|
|
109504
109590
|
} catch (error120) {
|
|
109505
|
-
|
|
109591
|
+
if (options.verbose > 0) {
|
|
109592
|
+
console.log(`Failed to read file: ${file4}`, error120);
|
|
109593
|
+
}
|
|
109506
109594
|
unreadableFiles.push(file4);
|
|
109507
109595
|
}
|
|
109508
109596
|
}
|
|
@@ -110661,6 +110749,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
110661
110749
|
|
|
110662
110750
|
// src/commands/review.ts
|
|
110663
110751
|
import { execSync as execSync3 } from "node:child_process";
|
|
110752
|
+
import { Console } from "node:console";
|
|
110664
110753
|
var import_lodash9 = __toESM(require_lodash(), 1);
|
|
110665
110754
|
function parseGitStatus(statusOutput) {
|
|
110666
110755
|
const statusLines = statusOutput.split(`
|
|
@@ -110759,9 +110848,11 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
110759
110848
|
}
|
|
110760
110849
|
const spinner = ora({
|
|
110761
110850
|
text: "Gathering information...",
|
|
110762
|
-
stream:
|
|
110851
|
+
stream: process.stderr
|
|
110763
110852
|
}).start();
|
|
110764
110853
|
const usage = new UsageMeter(import_lodash9.merge(prices_default, config6.prices ?? {}));
|
|
110854
|
+
const customConsole = options.json ? new Console(process.stderr, process.stderr) : console;
|
|
110855
|
+
const onEvent = printEvent(parentOptions.verbose, usage, customConsole);
|
|
110765
110856
|
const ai = getModel(commandConfig);
|
|
110766
110857
|
const toolProviderOptions = {
|
|
110767
110858
|
excludeFiles: parentOptions.config.excludeFiles,
|
|
@@ -110775,7 +110866,8 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
110775
110866
|
provider: toolProvider,
|
|
110776
110867
|
interactive: false,
|
|
110777
110868
|
policies: [],
|
|
110778
|
-
toolFormat: commandConfig.toolFormat
|
|
110869
|
+
toolFormat: commandConfig.toolFormat,
|
|
110870
|
+
callback: parentOptions.verbose > 0 ? onEvent : undefined
|
|
110779
110871
|
};
|
|
110780
110872
|
try {
|
|
110781
110873
|
if (options.pr) {
|
|
@@ -110846,7 +110938,7 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110846
110938
|
}
|
|
110847
110939
|
}
|
|
110848
110940
|
async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
110849
|
-
const gitStatus = execSync3("git status --porcelain=v1", { encoding: "utf-8" })
|
|
110941
|
+
const gitStatus = execSync3("git status --porcelain=v1", { encoding: "utf-8" });
|
|
110850
110942
|
const statusLines = gitStatus.split(`
|
|
110851
110943
|
`).filter((line) => line);
|
|
110852
110944
|
const hasStagedChanges = statusLines.some((line) => "MARC".includes(line[0]));
|
|
@@ -110932,7 +111024,7 @@ ${output.overview}`;
|
|
|
110932
111024
|
`;
|
|
110933
111025
|
for (const item of output.specificReviews) {
|
|
110934
111026
|
formatted += `
|
|
110935
|
-
|
|
111027
|
+
- ${item.file}#${item.lines}
|
|
110936
111028
|
|
|
110937
111029
|
${item.review}
|
|
110938
111030
|
`;
|