@polka-codes/runner 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 +134 -55
- 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) {
|
|
@@ -21008,7 +21067,7 @@ var {
|
|
|
21008
21067
|
Help
|
|
21009
21068
|
} = import__.default;
|
|
21010
21069
|
// package.json
|
|
21011
|
-
var version = "0.9.
|
|
21070
|
+
var version = "0.9.11";
|
|
21012
21071
|
|
|
21013
21072
|
// src/runner.ts
|
|
21014
21073
|
import { execSync } from "node:child_process";
|
|
@@ -55997,7 +56056,17 @@ ${Object.entries(example.input).map(([name17, value]) => renderParameterValue(na
|
|
|
55997
56056
|
`)}
|
|
55998
56057
|
</${toolNamePrefix}${tool.name}>
|
|
55999
56058
|
`;
|
|
56000
|
-
var toolUsePrompt = (tools, toolNamePrefix) => {
|
|
56059
|
+
var toolUsePrompt = (useNativeTool, tools, toolNamePrefix) => {
|
|
56060
|
+
if (useNativeTool) {
|
|
56061
|
+
return `
|
|
56062
|
+
====
|
|
56063
|
+
|
|
56064
|
+
TOOL USE
|
|
56065
|
+
|
|
56066
|
+
- You MUST use a tool.
|
|
56067
|
+
- Batch tool use when feasible; avoid redundant calls.
|
|
56068
|
+
`;
|
|
56069
|
+
}
|
|
56001
56070
|
if (tools.length === 0) {
|
|
56002
56071
|
return "";
|
|
56003
56072
|
}
|
|
@@ -56348,7 +56417,8 @@ ${instance.prompt}`;
|
|
|
56348
56417
|
}
|
|
56349
56418
|
if (requestTimeoutSeconds > 0 && requestAbortController) {
|
|
56350
56419
|
timeout = setTimeout(() => {
|
|
56351
|
-
console.debug(`
|
|
56420
|
+
console.debug(`
|
|
56421
|
+
Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`);
|
|
56352
56422
|
requestAbortController?.abort();
|
|
56353
56423
|
}, requestTimeoutSeconds * 1000);
|
|
56354
56424
|
}
|
|
@@ -56409,7 +56479,15 @@ ${instance.prompt}`;
|
|
|
56409
56479
|
}
|
|
56410
56480
|
}
|
|
56411
56481
|
if (this.config.toolFormat === "native") {
|
|
56412
|
-
if (respMessages.some((m) =>
|
|
56482
|
+
if (respMessages.some((m) => {
|
|
56483
|
+
if (m.role === "tool") {
|
|
56484
|
+
return true;
|
|
56485
|
+
}
|
|
56486
|
+
if (typeof m.content === "string") {
|
|
56487
|
+
return true;
|
|
56488
|
+
}
|
|
56489
|
+
return m.content.some((part) => part.type === "tool-call" || part.type === "tool-result" || part.type === "text");
|
|
56490
|
+
})) {
|
|
56413
56491
|
break;
|
|
56414
56492
|
}
|
|
56415
56493
|
} else {
|
|
@@ -56421,7 +56499,8 @@ ${instance.prompt}`;
|
|
|
56421
56499
|
break;
|
|
56422
56500
|
}
|
|
56423
56501
|
if (i < retryCount - 1) {
|
|
56424
|
-
console.debug(`
|
|
56502
|
+
console.debug(`
|
|
56503
|
+
Retrying request ${i + 2} of ${retryCount}`);
|
|
56425
56504
|
}
|
|
56426
56505
|
}
|
|
56427
56506
|
if (respMessages.length === 0) {
|
|
@@ -56659,7 +56738,7 @@ You are the **Analyzer** agent, responsible for:
|
|
|
56659
56738
|
5. **Documentation Assessment**: Review documentation quality and completeness.
|
|
56660
56739
|
6. **Non-Modification**: Never modify code or files - focus solely on analysis.
|
|
56661
56740
|
|
|
56662
|
-
${useNativeTool
|
|
56741
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
56663
56742
|
${capabilities(toolNamePrefix)}
|
|
56664
56743
|
${systemInformation(info)}
|
|
56665
56744
|
${customInstructions(instructions)}
|
|
@@ -56780,7 +56859,7 @@ RETRY GUIDELINES
|
|
|
56780
56859
|
- Report any partial improvements`;
|
|
56781
56860
|
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
|
|
56782
56861
|
${basePrompt}
|
|
56783
|
-
${useNativeTool
|
|
56862
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
56784
56863
|
${codeFixingStrategies}
|
|
56785
56864
|
${retryGuidelines}
|
|
56786
56865
|
${capabilities(toolNamePrefix)}
|
|
@@ -56979,7 +57058,7 @@ You solve the user's task by working in small, verifiable steps.
|
|
|
56979
57058
|
`;
|
|
56980
57059
|
var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
|
|
56981
57060
|
${basePrompt2}
|
|
56982
|
-
${useNativeTool
|
|
57061
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
56983
57062
|
${editingFilesPrompt(toolNamePrefix)}
|
|
56984
57063
|
${capabilities(toolNamePrefix)}
|
|
56985
57064
|
${rules(toolNamePrefix)}
|