@polka-codes/cli 0.9.8 → 0.9.10
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 +191 -98
- package/package.json +4 -4
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.10";
|
|
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)}
|
|
@@ -77121,7 +77200,7 @@ You are the **Architect** agent, responsible for:
|
|
|
77121
77200
|
- If multiple steps are required, break them into numbered tasks to delegate to the **Coder** agent.
|
|
77122
77201
|
- Provide all necessary context, implementation plan, file references, and clarifications for successful execution.
|
|
77123
77202
|
|
|
77124
|
-
${useNativeTool
|
|
77203
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
77125
77204
|
${capabilities(toolNamePrefix)}
|
|
77126
77205
|
${systemInformation(info)}
|
|
77127
77206
|
${customInstructions(instructions)}
|
|
@@ -77241,7 +77320,7 @@ RETRY GUIDELINES
|
|
|
77241
77320
|
- Report any partial improvements`;
|
|
77242
77321
|
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
|
|
77243
77322
|
${basePrompt}
|
|
77244
|
-
${useNativeTool
|
|
77323
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
77245
77324
|
${codeFixingStrategies}
|
|
77246
77325
|
${retryGuidelines}
|
|
77247
77326
|
${capabilities(toolNamePrefix)}
|
|
@@ -77440,7 +77519,7 @@ You solve the user's task by working in small, verifiable steps.
|
|
|
77440
77519
|
`;
|
|
77441
77520
|
var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
|
|
77442
77521
|
${basePrompt2}
|
|
77443
|
-
${useNativeTool
|
|
77522
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
77444
77523
|
${editingFilesPrompt(toolNamePrefix)}
|
|
77445
77524
|
${capabilities(toolNamePrefix)}
|
|
77446
77525
|
${rules(toolNamePrefix)}
|
|
@@ -103987,7 +104066,11 @@ var getModel = (config5, debugLogging = false) => {
|
|
|
103987
104066
|
const openrouter2 = createOpenRouter({
|
|
103988
104067
|
apiKey: config5.apiKey,
|
|
103989
104068
|
baseURL: config5.baseUrl,
|
|
103990
|
-
fetch: fetchOverride
|
|
104069
|
+
fetch: fetchOverride,
|
|
104070
|
+
headers: {
|
|
104071
|
+
"HTTP-Referer": "https://polka.codes",
|
|
104072
|
+
"X-Title": "Polka Codes"
|
|
104073
|
+
}
|
|
103991
104074
|
});
|
|
103992
104075
|
return openrouter2.chat(config5.model, {
|
|
103993
104076
|
usage: { include: true }
|
|
@@ -109078,54 +109161,54 @@ var source_default = chalk;
|
|
|
109078
109161
|
|
|
109079
109162
|
// ../cli-shared/src/utils/eventHandler.ts
|
|
109080
109163
|
var toolCallStats = new Map;
|
|
109081
|
-
var printEvent = (verbose, usageMeter) => {
|
|
109164
|
+
var printEvent = (verbose, usageMeter, customConsole = console) => {
|
|
109082
109165
|
let hadReasoning = false;
|
|
109083
109166
|
return (event) => {
|
|
109084
109167
|
switch (event.kind) {
|
|
109085
109168
|
case "StartTask" /* StartTask */:
|
|
109086
109169
|
toolCallStats.clear();
|
|
109087
109170
|
if (verbose > 1) {
|
|
109088
|
-
|
|
109171
|
+
customConsole.log(`
|
|
109089
109172
|
====== System Prompt ======
|
|
109090
109173
|
${event.systemPrompt}`);
|
|
109091
|
-
|
|
109174
|
+
customConsole.log(`
|
|
109092
109175
|
|
|
109093
109176
|
================
|
|
109094
109177
|
`);
|
|
109095
109178
|
}
|
|
109096
109179
|
break;
|
|
109097
109180
|
case "StartRequest" /* StartRequest */:
|
|
109098
|
-
|
|
109181
|
+
customConsole.log(`
|
|
109099
109182
|
|
|
109100
109183
|
======== New Request ========
|
|
109101
109184
|
`);
|
|
109102
109185
|
if (verbose) {
|
|
109103
109186
|
const userMessage = event.userMessage.content;
|
|
109104
109187
|
if (typeof userMessage === "string") {
|
|
109105
|
-
|
|
109188
|
+
customConsole.log(userMessage);
|
|
109106
109189
|
} else {
|
|
109107
109190
|
for (const content of userMessage) {
|
|
109108
109191
|
switch (content.type) {
|
|
109109
109192
|
case "text":
|
|
109110
|
-
|
|
109193
|
+
customConsole.log(content.text);
|
|
109111
109194
|
break;
|
|
109112
109195
|
case "image":
|
|
109113
109196
|
if (content.image instanceof URL) {
|
|
109114
|
-
|
|
109197
|
+
customConsole.log(source_default.yellow(`[Image content from URL: ${content.image}]`));
|
|
109115
109198
|
} else {
|
|
109116
|
-
|
|
109199
|
+
customConsole.log(source_default.yellow(`[Image content: ${content.mediaType}]`));
|
|
109117
109200
|
}
|
|
109118
109201
|
break;
|
|
109119
109202
|
case "file":
|
|
109120
|
-
|
|
109203
|
+
customConsole.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
|
|
109121
109204
|
break;
|
|
109122
109205
|
case "tool-call":
|
|
109123
|
-
|
|
109206
|
+
customConsole.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
|
|
109124
109207
|
break;
|
|
109125
109208
|
case "tool-result":
|
|
109126
|
-
|
|
109209
|
+
customConsole.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
|
|
109127
109210
|
if (verbose > 0) {
|
|
109128
|
-
|
|
109211
|
+
customConsole.log(content.output);
|
|
109129
109212
|
}
|
|
109130
109213
|
break;
|
|
109131
109214
|
case "reasoning":
|
|
@@ -109133,14 +109216,14 @@ ${event.systemPrompt}`);
|
|
|
109133
109216
|
}
|
|
109134
109217
|
}
|
|
109135
109218
|
}
|
|
109136
|
-
|
|
109219
|
+
customConsole.log(`
|
|
109137
109220
|
|
|
109138
109221
|
======== Request Message Ended ========
|
|
109139
109222
|
`);
|
|
109140
109223
|
}
|
|
109141
109224
|
break;
|
|
109142
109225
|
case "EndRequest" /* EndRequest */:
|
|
109143
|
-
|
|
109226
|
+
customConsole.log(`
|
|
109144
109227
|
|
|
109145
109228
|
======== Request Ended ========
|
|
109146
109229
|
`);
|
|
@@ -109151,6 +109234,9 @@ ${event.systemPrompt}`);
|
|
|
109151
109234
|
case "Usage" /* Usage */:
|
|
109152
109235
|
break;
|
|
109153
109236
|
case "Text" /* Text */:
|
|
109237
|
+
if (customConsole !== console) {
|
|
109238
|
+
break;
|
|
109239
|
+
}
|
|
109154
109240
|
if (hadReasoning) {
|
|
109155
109241
|
process.stdout.write(`
|
|
109156
109242
|
|
|
@@ -109160,11 +109246,14 @@ ${event.systemPrompt}`);
|
|
|
109160
109246
|
process.stdout.write(event.newText);
|
|
109161
109247
|
break;
|
|
109162
109248
|
case "Reasoning" /* Reasoning */:
|
|
109249
|
+
if (customConsole !== console) {
|
|
109250
|
+
break;
|
|
109251
|
+
}
|
|
109163
109252
|
process.stdout.write(source_default.dim(event.newText));
|
|
109164
109253
|
hadReasoning = true;
|
|
109165
109254
|
break;
|
|
109166
109255
|
case "ToolUse" /* ToolUse */: {
|
|
109167
|
-
|
|
109256
|
+
customConsole.log(source_default.yellow(`
|
|
109168
109257
|
|
|
109169
109258
|
Tool use:`, event.tool), event.content);
|
|
109170
109259
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
@@ -109181,10 +109270,10 @@ Tool use:`, event.tool), event.content);
|
|
|
109181
109270
|
case "ToolInvalid" /* ToolInvalid */:
|
|
109182
109271
|
break;
|
|
109183
109272
|
case "ToolError" /* ToolError */: {
|
|
109184
|
-
|
|
109273
|
+
customConsole.error(source_default.red(`
|
|
109185
109274
|
|
|
109186
109275
|
Tool error:`, event.tool));
|
|
109187
|
-
|
|
109276
|
+
customConsole.error(source_default.red(event.content));
|
|
109188
109277
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
109189
109278
|
stats.errors++;
|
|
109190
109279
|
toolCallStats.set(event.tool, stats);
|
|
@@ -109193,48 +109282,48 @@ Tool error:`, event.tool));
|
|
|
109193
109282
|
case "ToolInterrupted" /* ToolInterrupted */:
|
|
109194
109283
|
break;
|
|
109195
109284
|
case "ToolHandOver" /* ToolHandOver */:
|
|
109196
|
-
|
|
109285
|
+
customConsole.log(`
|
|
109197
109286
|
|
|
109198
109287
|
======== Task Handed Over ========
|
|
109199
109288
|
`);
|
|
109200
|
-
|
|
109201
|
-
|
|
109202
|
-
|
|
109203
|
-
|
|
109204
|
-
|
|
109289
|
+
customConsole.log("Agent:", event.agentName);
|
|
109290
|
+
customConsole.log("Task:", event.task);
|
|
109291
|
+
customConsole.log("Context:", event.context);
|
|
109292
|
+
customConsole.log("Files:", event.files);
|
|
109293
|
+
customConsole.log();
|
|
109205
109294
|
break;
|
|
109206
109295
|
case "ToolDelegate" /* ToolDelegate */:
|
|
109207
|
-
|
|
109296
|
+
customConsole.log(`
|
|
109208
109297
|
|
|
109209
109298
|
======== Task Delegated ========
|
|
109210
109299
|
`);
|
|
109211
|
-
|
|
109212
|
-
|
|
109213
|
-
|
|
109214
|
-
|
|
109215
|
-
|
|
109300
|
+
customConsole.log("Agent:", event.agentName);
|
|
109301
|
+
customConsole.log("Task:", event.task);
|
|
109302
|
+
customConsole.log("Context:", event.context);
|
|
109303
|
+
customConsole.log("Files:", event.files);
|
|
109304
|
+
customConsole.log();
|
|
109216
109305
|
break;
|
|
109217
109306
|
case "UsageExceeded" /* UsageExceeded */:
|
|
109218
|
-
|
|
109307
|
+
customConsole.log(`
|
|
109219
109308
|
|
|
109220
109309
|
======= Usage Exceeded ========
|
|
109221
109310
|
`);
|
|
109222
109311
|
break;
|
|
109223
109312
|
case "EndTask" /* EndTask */:
|
|
109224
|
-
|
|
109313
|
+
customConsole.log(`
|
|
109225
109314
|
|
|
109226
109315
|
======== Task Ended ========
|
|
109227
109316
|
`);
|
|
109228
|
-
|
|
109317
|
+
customConsole.log("Reason:", event.exitReason.type);
|
|
109229
109318
|
switch (event.exitReason.type) {
|
|
109230
109319
|
case "Exit" /* Exit */:
|
|
109231
|
-
|
|
109320
|
+
customConsole.log("Exit Message:", event.exitReason.message);
|
|
109232
109321
|
break;
|
|
109233
109322
|
case "Interrupted" /* Interrupted */:
|
|
109234
|
-
|
|
109323
|
+
customConsole.log("Interrupted Message:", event.exitReason.message);
|
|
109235
109324
|
break;
|
|
109236
109325
|
}
|
|
109237
|
-
|
|
109326
|
+
customConsole.log(`
|
|
109238
109327
|
|
|
109239
109328
|
======== Tool Call Stats ========`);
|
|
109240
109329
|
if (toolCallStats.size > 0) {
|
|
@@ -109248,9 +109337,9 @@ Tool error:`, event.tool));
|
|
|
109248
109337
|
"Success Rate": `${successRate.toFixed(2)}%`
|
|
109249
109338
|
};
|
|
109250
109339
|
});
|
|
109251
|
-
|
|
109340
|
+
customConsole.table(tableData);
|
|
109252
109341
|
} else {
|
|
109253
|
-
|
|
109342
|
+
customConsole.log("No tools were called.");
|
|
109254
109343
|
}
|
|
109255
109344
|
break;
|
|
109256
109345
|
}
|
|
@@ -109259,7 +109348,7 @@ Tool error:`, event.tool));
|
|
|
109259
109348
|
// src/options.ts
|
|
109260
109349
|
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
109261
109350
|
function addSharedOptions(command) {
|
|
109262
|
-
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.
|
|
109351
|
+
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)");
|
|
109263
109352
|
}
|
|
109264
109353
|
function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
|
|
109265
109354
|
let cwd = cwdArg;
|
|
@@ -110657,6 +110746,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
110657
110746
|
|
|
110658
110747
|
// src/commands/review.ts
|
|
110659
110748
|
import { execSync as execSync3 } from "node:child_process";
|
|
110749
|
+
import { Console } from "node:console";
|
|
110660
110750
|
var import_lodash9 = __toESM(require_lodash(), 1);
|
|
110661
110751
|
function parseGitStatus(statusOutput) {
|
|
110662
110752
|
const statusLines = statusOutput.split(`
|
|
@@ -110755,9 +110845,11 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
110755
110845
|
}
|
|
110756
110846
|
const spinner = ora({
|
|
110757
110847
|
text: "Gathering information...",
|
|
110758
|
-
stream:
|
|
110848
|
+
stream: process.stderr
|
|
110759
110849
|
}).start();
|
|
110760
110850
|
const usage = new UsageMeter(import_lodash9.merge(prices_default, config6.prices ?? {}));
|
|
110851
|
+
const customConsole = options.json ? new Console(process.stderr, process.stderr) : console;
|
|
110852
|
+
const onEvent = printEvent(parentOptions.verbose, usage, customConsole);
|
|
110761
110853
|
const ai = getModel(commandConfig);
|
|
110762
110854
|
const toolProviderOptions = {
|
|
110763
110855
|
excludeFiles: parentOptions.config.excludeFiles,
|
|
@@ -110771,7 +110863,8 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
110771
110863
|
provider: toolProvider,
|
|
110772
110864
|
interactive: false,
|
|
110773
110865
|
policies: [],
|
|
110774
|
-
toolFormat: commandConfig.toolFormat
|
|
110866
|
+
toolFormat: commandConfig.toolFormat,
|
|
110867
|
+
callback: parentOptions.verbose > 0 ? onEvent : undefined
|
|
110775
110868
|
};
|
|
110776
110869
|
try {
|
|
110777
110870
|
if (options.pr) {
|
|
@@ -110842,7 +110935,7 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110842
110935
|
}
|
|
110843
110936
|
}
|
|
110844
110937
|
async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
110845
|
-
const gitStatus = execSync3("git status --porcelain=v1", { encoding: "utf-8" })
|
|
110938
|
+
const gitStatus = execSync3("git status --porcelain=v1", { encoding: "utf-8" });
|
|
110846
110939
|
const statusLines = gitStatus.split(`
|
|
110847
110940
|
`).filter((line) => line);
|
|
110848
110941
|
const hasStagedChanges = statusLines.some((line) => "MARC".includes(line[0]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.10",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"@ai-sdk/provider-utils": "3.0.0-beta.5",
|
|
26
26
|
"@inquirer/prompts": "^7.8.0",
|
|
27
27
|
"@openrouter/ai-sdk-provider": "^1.0.0-beta.6",
|
|
28
|
-
"@polka-codes/cli-shared": "0.9.
|
|
29
|
-
"@polka-codes/core": "0.9.
|
|
28
|
+
"@polka-codes/cli-shared": "0.9.8",
|
|
29
|
+
"@polka-codes/core": "0.9.8",
|
|
30
30
|
"ai": "5.0.0-beta.24",
|
|
31
|
-
"commander": "^
|
|
31
|
+
"commander": "^14.0.0",
|
|
32
32
|
"dotenv": "^16.4.7",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
34
|
"ollama-ai-provider-v2": "1.0.0-alpha.3",
|