@polka-codes/runner 0.8.19 → 0.8.21
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 +148 -257
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -31282,9 +31282,9 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
31282
31282
|
}
|
|
31283
31283
|
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
31284
31284
|
var EventTarget = {
|
|
31285
|
-
addEventListener(type,
|
|
31285
|
+
addEventListener(type, handler14, options = {}) {
|
|
31286
31286
|
for (const listener of this.listeners(type)) {
|
|
31287
|
-
if (!options[kForOnEventAttribute] && listener[kListener] ===
|
|
31287
|
+
if (!options[kForOnEventAttribute] && listener[kListener] === handler14 && !listener[kForOnEventAttribute]) {
|
|
31288
31288
|
return;
|
|
31289
31289
|
}
|
|
31290
31290
|
}
|
|
@@ -31295,7 +31295,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
31295
31295
|
data: isBinary ? data : data.toString()
|
|
31296
31296
|
});
|
|
31297
31297
|
event[kTarget] = this;
|
|
31298
|
-
callListener(
|
|
31298
|
+
callListener(handler14, this, event);
|
|
31299
31299
|
};
|
|
31300
31300
|
} else if (type === "close") {
|
|
31301
31301
|
wrapper = function onClose(code, message) {
|
|
@@ -31305,7 +31305,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
31305
31305
|
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
31306
31306
|
});
|
|
31307
31307
|
event[kTarget] = this;
|
|
31308
|
-
callListener(
|
|
31308
|
+
callListener(handler14, this, event);
|
|
31309
31309
|
};
|
|
31310
31310
|
} else if (type === "error") {
|
|
31311
31311
|
wrapper = function onError(error) {
|
|
@@ -31314,28 +31314,28 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
31314
31314
|
message: error.message
|
|
31315
31315
|
});
|
|
31316
31316
|
event[kTarget] = this;
|
|
31317
|
-
callListener(
|
|
31317
|
+
callListener(handler14, this, event);
|
|
31318
31318
|
};
|
|
31319
31319
|
} else if (type === "open") {
|
|
31320
31320
|
wrapper = function onOpen() {
|
|
31321
31321
|
const event = new Event("open");
|
|
31322
31322
|
event[kTarget] = this;
|
|
31323
|
-
callListener(
|
|
31323
|
+
callListener(handler14, this, event);
|
|
31324
31324
|
};
|
|
31325
31325
|
} else {
|
|
31326
31326
|
return;
|
|
31327
31327
|
}
|
|
31328
31328
|
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
31329
|
-
wrapper[kListener] =
|
|
31329
|
+
wrapper[kListener] = handler14;
|
|
31330
31330
|
if (options.once) {
|
|
31331
31331
|
this.once(type, wrapper);
|
|
31332
31332
|
} else {
|
|
31333
31333
|
this.on(type, wrapper);
|
|
31334
31334
|
}
|
|
31335
31335
|
},
|
|
31336
|
-
removeEventListener(type,
|
|
31336
|
+
removeEventListener(type, handler14) {
|
|
31337
31337
|
for (const listener of this.listeners(type)) {
|
|
31338
|
-
if (listener[kListener] ===
|
|
31338
|
+
if (listener[kListener] === handler14 && !listener[kForOnEventAttribute]) {
|
|
31339
31339
|
this.removeListener(type, listener);
|
|
31340
31340
|
break;
|
|
31341
31341
|
}
|
|
@@ -31861,16 +31861,16 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
31861
31861
|
}
|
|
31862
31862
|
return null;
|
|
31863
31863
|
},
|
|
31864
|
-
set(
|
|
31864
|
+
set(handler14) {
|
|
31865
31865
|
for (const listener of this.listeners(method)) {
|
|
31866
31866
|
if (listener[kForOnEventAttribute]) {
|
|
31867
31867
|
this.removeListener(method, listener);
|
|
31868
31868
|
break;
|
|
31869
31869
|
}
|
|
31870
31870
|
}
|
|
31871
|
-
if (typeof
|
|
31871
|
+
if (typeof handler14 !== "function")
|
|
31872
31872
|
return;
|
|
31873
|
-
this.addEventListener(method,
|
|
31873
|
+
this.addEventListener(method, handler14, {
|
|
31874
31874
|
[kForOnEventAttribute]: true
|
|
31875
31875
|
});
|
|
31876
31876
|
}
|
|
@@ -32748,7 +32748,7 @@ var {
|
|
|
32748
32748
|
Help
|
|
32749
32749
|
} = import__.default;
|
|
32750
32750
|
// package.json
|
|
32751
|
-
var version = "0.8.
|
|
32751
|
+
var version = "0.8.21";
|
|
32752
32752
|
|
|
32753
32753
|
// src/runner.ts
|
|
32754
32754
|
import { execSync } from "node:child_process";
|
|
@@ -42049,39 +42049,6 @@ __export(exports_allTools, {
|
|
|
42049
42049
|
askFollowupQuestion: () => askFollowupQuestion_default
|
|
42050
42050
|
});
|
|
42051
42051
|
|
|
42052
|
-
// ../core/src/tools/utils/editFile.ts
|
|
42053
|
-
var START_OF_FILE = "<<<START_OF_FILE>>>";
|
|
42054
|
-
var END_OF_FILE = "<<<END_OF_FILE>>>";
|
|
42055
|
-
var editFile = async (fileContent, operations) => {
|
|
42056
|
-
if (!operations || operations.length === 0) {
|
|
42057
|
-
throw new Error("At least one edit operation is required");
|
|
42058
|
-
}
|
|
42059
|
-
let updatedContent = fileContent;
|
|
42060
|
-
for (const operation of operations) {
|
|
42061
|
-
updatedContent = await applyEditOperation(updatedContent, operation);
|
|
42062
|
-
}
|
|
42063
|
-
return updatedContent;
|
|
42064
|
-
};
|
|
42065
|
-
async function applyEditOperation(fileContent, operation) {
|
|
42066
|
-
const { search, replace } = operation;
|
|
42067
|
-
if (search === START_OF_FILE && replace === END_OF_FILE) {
|
|
42068
|
-
throw new Error("Cannot search for START_OF_FILE and replace with END_OF_FILE");
|
|
42069
|
-
}
|
|
42070
|
-
if (search === END_OF_FILE && replace === START_OF_FILE) {
|
|
42071
|
-
throw new Error("Cannot search for END_OF_FILE and replace with START_OF_FILE");
|
|
42072
|
-
}
|
|
42073
|
-
if (search === START_OF_FILE) {
|
|
42074
|
-
return replace + fileContent;
|
|
42075
|
-
}
|
|
42076
|
-
if (search === END_OF_FILE) {
|
|
42077
|
-
return fileContent + replace;
|
|
42078
|
-
}
|
|
42079
|
-
const index = fileContent.indexOf(search);
|
|
42080
|
-
if (index === -1) {
|
|
42081
|
-
throw new Error(`Could not find text: ${search}`);
|
|
42082
|
-
}
|
|
42083
|
-
return fileContent.slice(0, index) + replace + fileContent.slice(index + search.length);
|
|
42084
|
-
}
|
|
42085
42052
|
// ../core/src/tools/utils/getArg.ts
|
|
42086
42053
|
var getString = (args, name, defaultValue) => {
|
|
42087
42054
|
if (typeof args !== "object" || Array.isArray(args)) {
|
|
@@ -42175,7 +42142,7 @@ var getArray = (args, name, defaultValue) => {
|
|
|
42175
42142
|
};
|
|
42176
42143
|
// ../core/src/tools/utils/replaceInFile.ts
|
|
42177
42144
|
var replaceInFile = async (fileContent, diff) => {
|
|
42178
|
-
const blockPattern = /<<<<<+ SEARCH
|
|
42145
|
+
const blockPattern = /<<<<<+ SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+ REPLACE/g;
|
|
42179
42146
|
const blocks = [];
|
|
42180
42147
|
for (let match = blockPattern.exec(diff);match !== null; match = blockPattern.exec(diff)) {
|
|
42181
42148
|
blocks.push({ search: match[1], replace: match[2] });
|
|
@@ -42688,29 +42655,29 @@ var toolInfo7 = {
|
|
|
42688
42655
|
{
|
|
42689
42656
|
name: "diff",
|
|
42690
42657
|
description: `One or more SEARCH/REPLACE blocks following this exact format:
|
|
42691
|
-
|
|
42692
|
-
|
|
42693
|
-
|
|
42694
|
-
|
|
42695
|
-
|
|
42696
|
-
|
|
42697
|
-
|
|
42698
|
-
|
|
42699
|
-
|
|
42700
|
-
|
|
42701
|
-
|
|
42702
|
-
|
|
42703
|
-
|
|
42704
|
-
|
|
42705
|
-
|
|
42706
|
-
|
|
42707
|
-
|
|
42708
|
-
|
|
42709
|
-
|
|
42710
|
-
|
|
42711
|
-
|
|
42712
|
-
|
|
42713
|
-
|
|
42658
|
+
\`\`\`
|
|
42659
|
+
<<<<<<< SEARCH
|
|
42660
|
+
[exact content to find]
|
|
42661
|
+
=======
|
|
42662
|
+
[new content to replace with]
|
|
42663
|
+
>>>>>>> REPLACE
|
|
42664
|
+
\`\`\`
|
|
42665
|
+
Critical rules:
|
|
42666
|
+
1. SEARCH content must match the associated file section to find EXACTLY:
|
|
42667
|
+
* Match character-for-character including whitespace, indentation, line endings
|
|
42668
|
+
* Include all comments, docstrings, etc.
|
|
42669
|
+
2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
|
|
42670
|
+
* Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
|
|
42671
|
+
* Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
|
|
42672
|
+
* When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
|
|
42673
|
+
3. Keep SEARCH/REPLACE blocks concise:
|
|
42674
|
+
* Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
|
|
42675
|
+
* Include just the changing lines, and a few surrounding lines if needed for uniqueness.
|
|
42676
|
+
* Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
|
|
42677
|
+
* Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
|
|
42678
|
+
4. Special operations:
|
|
42679
|
+
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
42680
|
+
* To delete code: Use empty REPLACE section`,
|
|
42714
42681
|
required: true,
|
|
42715
42682
|
usageValue: "Search and replace blocks here"
|
|
42716
42683
|
}
|
|
@@ -42753,6 +42720,73 @@ function handleSubmit() {
|
|
|
42753
42720
|
return (
|
|
42754
42721
|
<div>
|
|
42755
42722
|
>>>>>>> REPLACE
|
|
42723
|
+
`
|
|
42724
|
+
}
|
|
42725
|
+
]
|
|
42726
|
+
},
|
|
42727
|
+
{
|
|
42728
|
+
description: "Request to perform a simple, single-line replacement",
|
|
42729
|
+
parameters: [
|
|
42730
|
+
{
|
|
42731
|
+
name: "path",
|
|
42732
|
+
value: "src/config.js"
|
|
42733
|
+
},
|
|
42734
|
+
{
|
|
42735
|
+
name: "diff",
|
|
42736
|
+
value: `
|
|
42737
|
+
<<<<<<< SEARCH
|
|
42738
|
+
const API_URL = 'https://api.example.com';
|
|
42739
|
+
=======
|
|
42740
|
+
const API_URL = 'https://api.staging.example.com';
|
|
42741
|
+
>>>>>>> REPLACE
|
|
42742
|
+
`
|
|
42743
|
+
}
|
|
42744
|
+
]
|
|
42745
|
+
},
|
|
42746
|
+
{
|
|
42747
|
+
description: "Request to add a new function to a file",
|
|
42748
|
+
parameters: [
|
|
42749
|
+
{
|
|
42750
|
+
name: "path",
|
|
42751
|
+
value: "src/utils.js"
|
|
42752
|
+
},
|
|
42753
|
+
{
|
|
42754
|
+
name: "diff",
|
|
42755
|
+
value: `
|
|
42756
|
+
<<<<<<< SEARCH
|
|
42757
|
+
function helperA() {
|
|
42758
|
+
// ...
|
|
42759
|
+
}
|
|
42760
|
+
=======
|
|
42761
|
+
function helperA() {
|
|
42762
|
+
// ...
|
|
42763
|
+
}
|
|
42764
|
+
|
|
42765
|
+
function newHelper() {
|
|
42766
|
+
// implementation
|
|
42767
|
+
}
|
|
42768
|
+
>>>>>>> REPLACE
|
|
42769
|
+
`
|
|
42770
|
+
}
|
|
42771
|
+
]
|
|
42772
|
+
},
|
|
42773
|
+
{
|
|
42774
|
+
description: "Request to delete a block of code from a file",
|
|
42775
|
+
parameters: [
|
|
42776
|
+
{
|
|
42777
|
+
name: "path",
|
|
42778
|
+
value: "src/app.js"
|
|
42779
|
+
},
|
|
42780
|
+
{
|
|
42781
|
+
name: "diff",
|
|
42782
|
+
value: `
|
|
42783
|
+
<<<<<<< SEARCH
|
|
42784
|
+
function oldFeature() {
|
|
42785
|
+
// This is no longer needed
|
|
42786
|
+
}
|
|
42787
|
+
|
|
42788
|
+
=======
|
|
42789
|
+
>>>>>>> REPLACE
|
|
42756
42790
|
`
|
|
42757
42791
|
}
|
|
42758
42792
|
]
|
|
@@ -43377,167 +43411,6 @@ var renameFile_default = {
|
|
|
43377
43411
|
handler: handler13,
|
|
43378
43412
|
isAvailable: isAvailable13
|
|
43379
43413
|
};
|
|
43380
|
-
// ../core/src/tools/editFile.ts
|
|
43381
|
-
var toolInfo14 = {
|
|
43382
|
-
name: "edit_file",
|
|
43383
|
-
description: "Request to edit file contents using search/replace operations. Supports multiple edit operations in a single call.",
|
|
43384
|
-
parameters: [
|
|
43385
|
-
{
|
|
43386
|
-
name: "path",
|
|
43387
|
-
description: "The path of the file to edit",
|
|
43388
|
-
required: true,
|
|
43389
|
-
usageValue: "File path here"
|
|
43390
|
-
},
|
|
43391
|
-
{
|
|
43392
|
-
name: "operations",
|
|
43393
|
-
description: "Edit operation with search and replace parameters",
|
|
43394
|
-
required: true,
|
|
43395
|
-
allowMultiple: true,
|
|
43396
|
-
children: [
|
|
43397
|
-
{
|
|
43398
|
-
name: "search",
|
|
43399
|
-
description: `Text to search for and replace (use ${START_OF_FILE} to insert at file start, ${END_OF_FILE} to insert at file end)`,
|
|
43400
|
-
required: true,
|
|
43401
|
-
usageValue: "Text to find and replace"
|
|
43402
|
-
},
|
|
43403
|
-
{
|
|
43404
|
-
name: "replace",
|
|
43405
|
-
description: "Text to replace the search text with",
|
|
43406
|
-
required: true,
|
|
43407
|
-
usageValue: "Replacement text"
|
|
43408
|
-
}
|
|
43409
|
-
],
|
|
43410
|
-
usageValue: "operations here"
|
|
43411
|
-
}
|
|
43412
|
-
],
|
|
43413
|
-
examples: [
|
|
43414
|
-
{
|
|
43415
|
-
description: "Replace specific text",
|
|
43416
|
-
parameters: [
|
|
43417
|
-
{
|
|
43418
|
-
name: "path",
|
|
43419
|
-
value: "src/main.ts"
|
|
43420
|
-
},
|
|
43421
|
-
{
|
|
43422
|
-
name: "operations",
|
|
43423
|
-
value: {
|
|
43424
|
-
search: `function oldFunction() {
|
|
43425
|
-
return 42;
|
|
43426
|
-
}`,
|
|
43427
|
-
replace: `function newFunction() {
|
|
43428
|
-
return "new implementation";
|
|
43429
|
-
}`
|
|
43430
|
-
}
|
|
43431
|
-
}
|
|
43432
|
-
]
|
|
43433
|
-
},
|
|
43434
|
-
{
|
|
43435
|
-
description: "Insert at start of file",
|
|
43436
|
-
parameters: [
|
|
43437
|
-
{
|
|
43438
|
-
name: "path",
|
|
43439
|
-
value: "src/header.ts"
|
|
43440
|
-
},
|
|
43441
|
-
{
|
|
43442
|
-
name: "operations",
|
|
43443
|
-
value: {
|
|
43444
|
-
search: START_OF_FILE,
|
|
43445
|
-
replace: `// File header comment
|
|
43446
|
-
`
|
|
43447
|
-
}
|
|
43448
|
-
}
|
|
43449
|
-
]
|
|
43450
|
-
},
|
|
43451
|
-
{
|
|
43452
|
-
description: "Multiple operations in one call",
|
|
43453
|
-
parameters: [
|
|
43454
|
-
{
|
|
43455
|
-
name: "path",
|
|
43456
|
-
value: "src/utils.ts"
|
|
43457
|
-
},
|
|
43458
|
-
{
|
|
43459
|
-
name: "operations",
|
|
43460
|
-
value: [
|
|
43461
|
-
{
|
|
43462
|
-
search: 'import React from "react"',
|
|
43463
|
-
replace: 'import React, { useState } from "react"'
|
|
43464
|
-
},
|
|
43465
|
-
{
|
|
43466
|
-
search: `function Component() {
|
|
43467
|
-
return (`,
|
|
43468
|
-
replace: `function Component() {
|
|
43469
|
-
const [state, setState] = useState(false);
|
|
43470
|
-
return (`
|
|
43471
|
-
}
|
|
43472
|
-
]
|
|
43473
|
-
}
|
|
43474
|
-
]
|
|
43475
|
-
},
|
|
43476
|
-
{
|
|
43477
|
-
description: "Append content at end of file",
|
|
43478
|
-
parameters: [
|
|
43479
|
-
{
|
|
43480
|
-
name: "path",
|
|
43481
|
-
value: "src/footer.ts"
|
|
43482
|
-
},
|
|
43483
|
-
{
|
|
43484
|
-
name: "operations",
|
|
43485
|
-
value: {
|
|
43486
|
-
search: END_OF_FILE,
|
|
43487
|
-
replace: `
|
|
43488
|
-
// End of file appended comment
|
|
43489
|
-
`
|
|
43490
|
-
}
|
|
43491
|
-
}
|
|
43492
|
-
]
|
|
43493
|
-
}
|
|
43494
|
-
],
|
|
43495
|
-
permissionLevel: 2 /* Write */
|
|
43496
|
-
};
|
|
43497
|
-
var handler14 = async (provider, args) => {
|
|
43498
|
-
if (!provider.readFile || !provider.writeFile) {
|
|
43499
|
-
return {
|
|
43500
|
-
type: "Error" /* Error */,
|
|
43501
|
-
message: "Not possible to edit file. Abort."
|
|
43502
|
-
};
|
|
43503
|
-
}
|
|
43504
|
-
const path = getString(args, "path");
|
|
43505
|
-
const operations = getArray(args, "operations");
|
|
43506
|
-
if (!operations || operations.length === 0) {
|
|
43507
|
-
return {
|
|
43508
|
-
type: "Error" /* Error */,
|
|
43509
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>At least one edit operation is required</error_message></error>`
|
|
43510
|
-
};
|
|
43511
|
-
}
|
|
43512
|
-
const fileContent = await provider.readFile(path);
|
|
43513
|
-
if (fileContent == null) {
|
|
43514
|
-
return {
|
|
43515
|
-
type: "Error" /* Error */,
|
|
43516
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>File not found</error_message></error>`
|
|
43517
|
-
};
|
|
43518
|
-
}
|
|
43519
|
-
try {
|
|
43520
|
-
const result = await editFile(fileContent, operations);
|
|
43521
|
-
await provider.writeFile(path, result);
|
|
43522
|
-
return {
|
|
43523
|
-
type: "Reply" /* Reply */,
|
|
43524
|
-
message: `<edit_file_path>${path}</edit_file_path>`
|
|
43525
|
-
};
|
|
43526
|
-
} catch (error) {
|
|
43527
|
-
return {
|
|
43528
|
-
type: "Error" /* Error */,
|
|
43529
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>${error instanceof Error ? error.message : String(error)}</error_message></error>`
|
|
43530
|
-
};
|
|
43531
|
-
}
|
|
43532
|
-
};
|
|
43533
|
-
var isAvailable14 = (provider) => {
|
|
43534
|
-
return !!provider.readFile && !!provider.writeFile;
|
|
43535
|
-
};
|
|
43536
|
-
var editFile_default = {
|
|
43537
|
-
...toolInfo14,
|
|
43538
|
-
handler: handler14,
|
|
43539
|
-
isAvailable: isAvailable14
|
|
43540
|
-
};
|
|
43541
43414
|
// ../core/src/getAvailableTools.ts
|
|
43542
43415
|
var getAvailableTools = ({
|
|
43543
43416
|
provider: provider2,
|
|
@@ -43762,6 +43635,8 @@ Tool use is formatted using XML-style tags. The tool name is enclosed in opening
|
|
|
43762
43635
|
...
|
|
43763
43636
|
</${toolNamePrefix}tool_name>
|
|
43764
43637
|
|
|
43638
|
+
**It is crucial that all tags are correctly nested and closed.**
|
|
43639
|
+
|
|
43765
43640
|
## Array Parameters
|
|
43766
43641
|
|
|
43767
43642
|
To create an array of values for a parameter, repeat the parameter tag multiple times:
|
|
@@ -43796,7 +43671,7 @@ You can also combine array parameters with nested objects:
|
|
|
43796
43671
|
</${parameterPrefix}key>
|
|
43797
43672
|
</${toolNamePrefix}example_tool>
|
|
43798
43673
|
|
|
43799
|
-
Always adhere to this format
|
|
43674
|
+
Always adhere to this format, ensuring every opening tag has a matching closing tag, to ensure proper parsing and execution.
|
|
43800
43675
|
|
|
43801
43676
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
43802
43677
|
|
|
@@ -43814,18 +43689,14 @@ ${tools.map((tool) => {
|
|
|
43814
43689
|
}).join("")}
|
|
43815
43690
|
# Tool Use Guidelines
|
|
43816
43691
|
|
|
43817
|
-
1. **
|
|
43818
|
-
- Before using a tool, wrap your reasoning inside \`<thinking>\` tags. Be concise—just enough to clarify your plan and the rationale behind selecting a specific tool.
|
|
43819
|
-
2. **Wait for Feedback**
|
|
43692
|
+
1. **Wait for Feedback**
|
|
43820
43693
|
- After using a tool, wait for the user's response indicating success/failure or any output logs. Do not assume the result of a tool without explicit confirmation.
|
|
43821
|
-
|
|
43694
|
+
2. **Error Handling**
|
|
43822
43695
|
- If a tool fails or produces an unexpected result, analyze the error, decide on an alternative approach or tool, and proceed carefully.
|
|
43823
|
-
|
|
43696
|
+
3. **Avoid Repetition**
|
|
43824
43697
|
- Do not quote or repeat previous commands or prompts verbatim. Move the conversation forward by focusing on the latest required action.
|
|
43825
|
-
|
|
43826
|
-
-
|
|
43827
|
-
6. **Tool Call Limit**
|
|
43828
|
-
- Do not make more than 5 tool calls in a single message.`;
|
|
43698
|
+
4. **Tool Call Limit**
|
|
43699
|
+
- It is **STRIGHTLY FORBIDDEN** to make more than 5 tool calls in a single message.`;
|
|
43829
43700
|
};
|
|
43830
43701
|
var agentsPrompt = (agents, name) => `
|
|
43831
43702
|
====
|
|
@@ -44139,8 +44010,8 @@ ${instance.prompt}`;
|
|
|
44139
44010
|
}
|
|
44140
44011
|
async#invokeTool(name, args) {
|
|
44141
44012
|
try {
|
|
44142
|
-
const
|
|
44143
|
-
if (!
|
|
44013
|
+
const handler14 = this.handlers[name]?.handler;
|
|
44014
|
+
if (!handler14) {
|
|
44144
44015
|
return {
|
|
44145
44016
|
type: "Error" /* Error */,
|
|
44146
44017
|
message: responsePrompts.errorInvokeTool(name, "Tool not found"),
|
|
@@ -44159,7 +44030,7 @@ ${instance.prompt}`;
|
|
|
44159
44030
|
if (resp) {
|
|
44160
44031
|
return resp;
|
|
44161
44032
|
}
|
|
44162
|
-
return await
|
|
44033
|
+
return await handler14(this.config.provider, args);
|
|
44163
44034
|
} catch (error) {
|
|
44164
44035
|
return {
|
|
44165
44036
|
type: "Error" /* Error */,
|
|
@@ -53354,15 +53225,15 @@ function useKeypress(userHandler) {
|
|
|
53354
53225
|
signal.current = userHandler;
|
|
53355
53226
|
useEffect((rl) => {
|
|
53356
53227
|
let ignore = false;
|
|
53357
|
-
const
|
|
53228
|
+
const handler14 = withUpdates((_input, event) => {
|
|
53358
53229
|
if (ignore)
|
|
53359
53230
|
return;
|
|
53360
53231
|
signal.current(event, rl);
|
|
53361
53232
|
});
|
|
53362
|
-
rl.input.on("keypress",
|
|
53233
|
+
rl.input.on("keypress", handler14);
|
|
53363
53234
|
return () => {
|
|
53364
53235
|
ignore = true;
|
|
53365
|
-
rl.input.removeListener("keypress",
|
|
53236
|
+
rl.input.removeListener("keypress", handler14);
|
|
53366
53237
|
};
|
|
53367
53238
|
}, []);
|
|
53368
53239
|
}
|
|
@@ -53544,16 +53415,16 @@ class Emitter {
|
|
|
53544
53415
|
|
|
53545
53416
|
class SignalExitBase {
|
|
53546
53417
|
}
|
|
53547
|
-
var signalExitWrap = (
|
|
53418
|
+
var signalExitWrap = (handler14) => {
|
|
53548
53419
|
return {
|
|
53549
53420
|
onExit(cb, opts) {
|
|
53550
|
-
return
|
|
53421
|
+
return handler14.onExit(cb, opts);
|
|
53551
53422
|
},
|
|
53552
53423
|
load() {
|
|
53553
|
-
return
|
|
53424
|
+
return handler14.load();
|
|
53554
53425
|
},
|
|
53555
53426
|
unload() {
|
|
53556
|
-
return
|
|
53427
|
+
return handler14.unload();
|
|
53557
53428
|
}
|
|
53558
53429
|
};
|
|
53559
53430
|
};
|
|
@@ -54069,6 +53940,24 @@ ${theme.style.description(selectedChoice.description)}` : ``;
|
|
|
54069
53940
|
return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
|
|
54070
53941
|
${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursorHide}`;
|
|
54071
53942
|
});
|
|
53943
|
+
// ../cli-shared/src/utils/checkRipgrep.ts
|
|
53944
|
+
import { spawnSync } from "node:child_process";
|
|
53945
|
+
var rgAvailability = {
|
|
53946
|
+
isAvailable: null
|
|
53947
|
+
};
|
|
53948
|
+
function checkRipgrep() {
|
|
53949
|
+
if (rgAvailability.isAvailable !== null) {
|
|
53950
|
+
return rgAvailability.isAvailable;
|
|
53951
|
+
}
|
|
53952
|
+
const rg = spawnSync("rg", ["--version"]);
|
|
53953
|
+
if (rg.error || rg.status !== 0) {
|
|
53954
|
+
rgAvailability.isAvailable = false;
|
|
53955
|
+
return false;
|
|
53956
|
+
}
|
|
53957
|
+
rgAvailability.isAvailable = true;
|
|
53958
|
+
return true;
|
|
53959
|
+
}
|
|
53960
|
+
|
|
54072
53961
|
// ../cli-shared/src/utils/listFiles.ts
|
|
54073
53962
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
54074
53963
|
import { promises as fs2 } from "node:fs";
|
|
@@ -54166,7 +54055,6 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
54166
54055
|
|
|
54167
54056
|
// ../cli-shared/src/utils/searchFiles.ts
|
|
54168
54057
|
import { spawn } from "node:child_process";
|
|
54169
|
-
import { rgPath } from "@vscode/ripgrep";
|
|
54170
54058
|
async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
54171
54059
|
const args = [
|
|
54172
54060
|
"--line-number",
|
|
@@ -54191,7 +54079,7 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
54191
54079
|
args.push(regex, path);
|
|
54192
54080
|
return new Promise((resolve2, reject) => {
|
|
54193
54081
|
const results = [];
|
|
54194
|
-
const rg = spawn(
|
|
54082
|
+
const rg = spawn("rg", args, {
|
|
54195
54083
|
cwd,
|
|
54196
54084
|
stdio: ["ignore", "pipe", "pipe"]
|
|
54197
54085
|
});
|
|
@@ -54249,9 +54137,6 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
54249
54137
|
listFiles: async (path, recursive, maxCount) => {
|
|
54250
54138
|
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
54251
54139
|
},
|
|
54252
|
-
searchFiles: async (path, regex, filePattern) => {
|
|
54253
|
-
return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
|
|
54254
|
-
},
|
|
54255
54140
|
executeCommand: (command, needApprove) => {
|
|
54256
54141
|
return new Promise((resolve2, reject) => {
|
|
54257
54142
|
options.command?.onStarted(command);
|
|
@@ -54307,6 +54192,13 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
54307
54192
|
return;
|
|
54308
54193
|
}
|
|
54309
54194
|
};
|
|
54195
|
+
if (checkRipgrep()) {
|
|
54196
|
+
provider2.searchFiles = async (path, regex, filePattern) => {
|
|
54197
|
+
return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
|
|
54198
|
+
};
|
|
54199
|
+
} else {
|
|
54200
|
+
console.error("Error: ripgrep (rg) is not installed. Search file tool is disabled. Please install it from https://github.com/BurntSushi/ripgrep#installation");
|
|
54201
|
+
}
|
|
54310
54202
|
return provider2;
|
|
54311
54203
|
};
|
|
54312
54204
|
// ../../node_modules/ws/wrapper.mjs
|
|
@@ -58523,7 +58415,6 @@ class Runner {
|
|
|
58523
58415
|
[removeFile_default.name]: removeFile_default,
|
|
58524
58416
|
[renameFile_default.name]: renameFile_default,
|
|
58525
58417
|
[replaceInFile_default.name]: replaceInFile_default,
|
|
58526
|
-
[editFile_default.name]: editFile_default,
|
|
58527
58418
|
[searchFiles_default.name]: searchFiles_default,
|
|
58528
58419
|
[writeToFile_default.name]: writeToFile_default,
|
|
58529
58420
|
[updateKnowledge_default.name]: updateKnowledge_default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/runner",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.21",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "bun build src/index.ts --outdir dist --target node
|
|
17
|
+
"build": "bun build src/index.ts --outdir dist --target node"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@polka-codes/cli-shared": "0.8.10",
|
|
21
21
|
"@polka-codes/core": "0.8.10",
|
|
22
|
-
"@vscode/ripgrep": "^1.15.10",
|
|
23
22
|
"commander": "^13.0.0",
|
|
24
23
|
"dotenv": "^16.4.7",
|
|
25
24
|
"ignore": "^7.0.3",
|