@polka-codes/runner 0.8.20 → 0.8.22
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 +186 -250
- 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.22";
|
|
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)) {
|
|
@@ -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
|
]
|
|
@@ -42869,7 +42903,48 @@ var searchFiles_default = {
|
|
|
42869
42903
|
};
|
|
42870
42904
|
// ../core/src/tools/updateKnowledge.ts
|
|
42871
42905
|
var import_yaml = __toESM(require_dist(), 1);
|
|
42872
|
-
|
|
42906
|
+
|
|
42907
|
+
// ../core/src/path.ts
|
|
42908
|
+
function normalize(path) {
|
|
42909
|
+
const isAbsolute = path.startsWith("/");
|
|
42910
|
+
const segments = path.split("/").filter(Boolean);
|
|
42911
|
+
const stack = [];
|
|
42912
|
+
for (const seg of segments) {
|
|
42913
|
+
if (seg === ".")
|
|
42914
|
+
continue;
|
|
42915
|
+
if (seg === "..") {
|
|
42916
|
+
if (stack.length && stack[stack.length - 1] !== "..") {
|
|
42917
|
+
stack.pop();
|
|
42918
|
+
} else if (!isAbsolute) {
|
|
42919
|
+
stack.push("..");
|
|
42920
|
+
}
|
|
42921
|
+
} else {
|
|
42922
|
+
stack.push(seg);
|
|
42923
|
+
}
|
|
42924
|
+
}
|
|
42925
|
+
let result = stack.join("/");
|
|
42926
|
+
if (!result && !isAbsolute)
|
|
42927
|
+
return ".";
|
|
42928
|
+
if (result && path.endsWith("/"))
|
|
42929
|
+
result += "/";
|
|
42930
|
+
return (isAbsolute ? "/" : "") + result;
|
|
42931
|
+
}
|
|
42932
|
+
function join(...parts) {
|
|
42933
|
+
if (parts.length === 0)
|
|
42934
|
+
return ".";
|
|
42935
|
+
let combined = "";
|
|
42936
|
+
for (const p2 of parts) {
|
|
42937
|
+
if (typeof p2 !== "string") {
|
|
42938
|
+
throw new TypeError("Arguments to join must be strings");
|
|
42939
|
+
}
|
|
42940
|
+
if (p2) {
|
|
42941
|
+
combined = combined ? `${combined}/${p2}` : p2;
|
|
42942
|
+
}
|
|
42943
|
+
}
|
|
42944
|
+
return normalize(combined);
|
|
42945
|
+
}
|
|
42946
|
+
|
|
42947
|
+
// ../core/src/tools/updateKnowledge.ts
|
|
42873
42948
|
var toolInfo9 = {
|
|
42874
42949
|
name: "update_knowledge",
|
|
42875
42950
|
description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.",
|
|
@@ -43377,167 +43452,6 @@ var renameFile_default = {
|
|
|
43377
43452
|
handler: handler13,
|
|
43378
43453
|
isAvailable: isAvailable13
|
|
43379
43454
|
};
|
|
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
43455
|
// ../core/src/getAvailableTools.ts
|
|
43542
43456
|
var getAvailableTools = ({
|
|
43543
43457
|
provider: provider2,
|
|
@@ -43762,6 +43676,8 @@ Tool use is formatted using XML-style tags. The tool name is enclosed in opening
|
|
|
43762
43676
|
...
|
|
43763
43677
|
</${toolNamePrefix}tool_name>
|
|
43764
43678
|
|
|
43679
|
+
**It is crucial that all tags are correctly nested and closed.**
|
|
43680
|
+
|
|
43765
43681
|
## Array Parameters
|
|
43766
43682
|
|
|
43767
43683
|
To create an array of values for a parameter, repeat the parameter tag multiple times:
|
|
@@ -43796,7 +43712,7 @@ You can also combine array parameters with nested objects:
|
|
|
43796
43712
|
</${parameterPrefix}key>
|
|
43797
43713
|
</${toolNamePrefix}example_tool>
|
|
43798
43714
|
|
|
43799
|
-
Always adhere to this format
|
|
43715
|
+
Always adhere to this format, ensuring every opening tag has a matching closing tag, to ensure proper parsing and execution.
|
|
43800
43716
|
|
|
43801
43717
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
43802
43718
|
|
|
@@ -44135,8 +44051,8 @@ ${instance.prompt}`;
|
|
|
44135
44051
|
}
|
|
44136
44052
|
async#invokeTool(name, args) {
|
|
44137
44053
|
try {
|
|
44138
|
-
const
|
|
44139
|
-
if (!
|
|
44054
|
+
const handler14 = this.handlers[name]?.handler;
|
|
44055
|
+
if (!handler14) {
|
|
44140
44056
|
return {
|
|
44141
44057
|
type: "Error" /* Error */,
|
|
44142
44058
|
message: responsePrompts.errorInvokeTool(name, "Tool not found"),
|
|
@@ -44155,7 +44071,7 @@ ${instance.prompt}`;
|
|
|
44155
44071
|
if (resp) {
|
|
44156
44072
|
return resp;
|
|
44157
44073
|
}
|
|
44158
|
-
return await
|
|
44074
|
+
return await handler14(this.config.provider, args);
|
|
44159
44075
|
} catch (error) {
|
|
44160
44076
|
return {
|
|
44161
44077
|
type: "Error" /* Error */,
|
|
@@ -52788,7 +52704,7 @@ var readConfig = (path) => {
|
|
|
52788
52704
|
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
52789
52705
|
import { spawn as spawn2 } from "node:child_process";
|
|
52790
52706
|
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
52791
|
-
import { dirname } from "node:path";
|
|
52707
|
+
import { dirname as dirname2 } from "node:path";
|
|
52792
52708
|
|
|
52793
52709
|
// ../../node_modules/@inquirer/core/dist/esm/lib/key.js
|
|
52794
52710
|
var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
|
|
@@ -53350,15 +53266,15 @@ function useKeypress(userHandler) {
|
|
|
53350
53266
|
signal.current = userHandler;
|
|
53351
53267
|
useEffect((rl) => {
|
|
53352
53268
|
let ignore = false;
|
|
53353
|
-
const
|
|
53269
|
+
const handler14 = withUpdates((_input, event) => {
|
|
53354
53270
|
if (ignore)
|
|
53355
53271
|
return;
|
|
53356
53272
|
signal.current(event, rl);
|
|
53357
53273
|
});
|
|
53358
|
-
rl.input.on("keypress",
|
|
53274
|
+
rl.input.on("keypress", handler14);
|
|
53359
53275
|
return () => {
|
|
53360
53276
|
ignore = true;
|
|
53361
|
-
rl.input.removeListener("keypress",
|
|
53277
|
+
rl.input.removeListener("keypress", handler14);
|
|
53362
53278
|
};
|
|
53363
53279
|
}, []);
|
|
53364
53280
|
}
|
|
@@ -53540,16 +53456,16 @@ class Emitter {
|
|
|
53540
53456
|
|
|
53541
53457
|
class SignalExitBase {
|
|
53542
53458
|
}
|
|
53543
|
-
var signalExitWrap = (
|
|
53459
|
+
var signalExitWrap = (handler14) => {
|
|
53544
53460
|
return {
|
|
53545
53461
|
onExit(cb, opts) {
|
|
53546
|
-
return
|
|
53462
|
+
return handler14.onExit(cb, opts);
|
|
53547
53463
|
},
|
|
53548
53464
|
load() {
|
|
53549
|
-
return
|
|
53465
|
+
return handler14.load();
|
|
53550
53466
|
},
|
|
53551
53467
|
unload() {
|
|
53552
|
-
return
|
|
53468
|
+
return handler14.unload();
|
|
53553
53469
|
}
|
|
53554
53470
|
};
|
|
53555
53471
|
};
|
|
@@ -54065,6 +53981,24 @@ ${theme.style.description(selectedChoice.description)}` : ``;
|
|
|
54065
53981
|
return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
|
|
54066
53982
|
${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursorHide}`;
|
|
54067
53983
|
});
|
|
53984
|
+
// ../cli-shared/src/utils/checkRipgrep.ts
|
|
53985
|
+
import { spawnSync } from "node:child_process";
|
|
53986
|
+
var rgAvailability = {
|
|
53987
|
+
isAvailable: null
|
|
53988
|
+
};
|
|
53989
|
+
function checkRipgrep() {
|
|
53990
|
+
if (rgAvailability.isAvailable !== null) {
|
|
53991
|
+
return rgAvailability.isAvailable;
|
|
53992
|
+
}
|
|
53993
|
+
const rg = spawnSync("rg", ["--version"]);
|
|
53994
|
+
if (rg.error || rg.status !== 0) {
|
|
53995
|
+
rgAvailability.isAvailable = false;
|
|
53996
|
+
return false;
|
|
53997
|
+
}
|
|
53998
|
+
rgAvailability.isAvailable = true;
|
|
53999
|
+
return true;
|
|
54000
|
+
}
|
|
54001
|
+
|
|
54068
54002
|
// ../cli-shared/src/utils/listFiles.ts
|
|
54069
54003
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
54070
54004
|
import { promises as fs2 } from "node:fs";
|
|
@@ -54162,7 +54096,6 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
54162
54096
|
|
|
54163
54097
|
// ../cli-shared/src/utils/searchFiles.ts
|
|
54164
54098
|
import { spawn } from "node:child_process";
|
|
54165
|
-
import { rgPath } from "@vscode/ripgrep";
|
|
54166
54099
|
async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
54167
54100
|
const args = [
|
|
54168
54101
|
"--line-number",
|
|
@@ -54187,7 +54120,7 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
54187
54120
|
args.push(regex, path);
|
|
54188
54121
|
return new Promise((resolve2, reject) => {
|
|
54189
54122
|
const results = [];
|
|
54190
|
-
const rg = spawn(
|
|
54123
|
+
const rg = spawn("rg", args, {
|
|
54191
54124
|
cwd,
|
|
54192
54125
|
stdio: ["ignore", "pipe", "pipe"]
|
|
54193
54126
|
});
|
|
@@ -54227,7 +54160,7 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
54227
54160
|
if (ig.ignores(path)) {
|
|
54228
54161
|
throw new Error(`Not allow to access file ${path}`);
|
|
54229
54162
|
}
|
|
54230
|
-
await mkdir(
|
|
54163
|
+
await mkdir(dirname2(path), { recursive: true });
|
|
54231
54164
|
return await writeFile(path, content, "utf8");
|
|
54232
54165
|
},
|
|
54233
54166
|
removeFile: async (path) => {
|
|
@@ -54245,9 +54178,6 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
54245
54178
|
listFiles: async (path, recursive, maxCount) => {
|
|
54246
54179
|
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
54247
54180
|
},
|
|
54248
|
-
searchFiles: async (path, regex, filePattern) => {
|
|
54249
|
-
return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
|
|
54250
|
-
},
|
|
54251
54181
|
executeCommand: (command, needApprove) => {
|
|
54252
54182
|
return new Promise((resolve2, reject) => {
|
|
54253
54183
|
options.command?.onStarted(command);
|
|
@@ -54303,6 +54233,13 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
54303
54233
|
return;
|
|
54304
54234
|
}
|
|
54305
54235
|
};
|
|
54236
|
+
if (checkRipgrep()) {
|
|
54237
|
+
provider2.searchFiles = async (path, regex, filePattern) => {
|
|
54238
|
+
return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
|
|
54239
|
+
};
|
|
54240
|
+
} else {
|
|
54241
|
+
console.error("Error: ripgrep (rg) is not installed. Search file tool is disabled. Please install it from https://github.com/BurntSushi/ripgrep#installation");
|
|
54242
|
+
}
|
|
54306
54243
|
return provider2;
|
|
54307
54244
|
};
|
|
54308
54245
|
// ../../node_modules/ws/wrapper.mjs
|
|
@@ -58519,7 +58456,6 @@ class Runner {
|
|
|
58519
58456
|
[removeFile_default.name]: removeFile_default,
|
|
58520
58457
|
[renameFile_default.name]: renameFile_default,
|
|
58521
58458
|
[replaceInFile_default.name]: replaceInFile_default,
|
|
58522
|
-
[editFile_default.name]: editFile_default,
|
|
58523
58459
|
[searchFiles_default.name]: searchFiles_default,
|
|
58524
58460
|
[writeToFile_default.name]: writeToFile_default,
|
|
58525
58461
|
[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.22",
|
|
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",
|