@polka-codes/cli 0.8.21 → 0.8.23
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 +239 -83
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -38447,7 +38447,7 @@ var {
|
|
|
38447
38447
|
Help
|
|
38448
38448
|
} = import__.default;
|
|
38449
38449
|
// package.json
|
|
38450
|
-
var version = "0.8.
|
|
38450
|
+
var version = "0.8.23";
|
|
38451
38451
|
|
|
38452
38452
|
// ../core/src/AiService/AiServiceBase.ts
|
|
38453
38453
|
class AiServiceBase {
|
|
@@ -47752,6 +47752,7 @@ __export(exports_allTools, {
|
|
|
47752
47752
|
readFile: () => readFile_default,
|
|
47753
47753
|
listFiles: () => listFiles_default,
|
|
47754
47754
|
handOver: () => handOver_default,
|
|
47755
|
+
fetchUrl: () => fetchUrl_default,
|
|
47755
47756
|
executeCommand: () => executeCommand_default,
|
|
47756
47757
|
delegate: () => delegate_default,
|
|
47757
47758
|
attemptCompletion: () => attemptCompletion_default,
|
|
@@ -48210,8 +48211,89 @@ var executeCommand_default = {
|
|
|
48210
48211
|
handler: handler4,
|
|
48211
48212
|
isAvailable: isAvailable4
|
|
48212
48213
|
};
|
|
48213
|
-
// ../core/src/tools/
|
|
48214
|
+
// ../core/src/tools/fetchUrl.ts
|
|
48214
48215
|
var toolInfo5 = {
|
|
48216
|
+
name: "fetch_url",
|
|
48217
|
+
description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.",
|
|
48218
|
+
parameters: [
|
|
48219
|
+
{
|
|
48220
|
+
name: "url",
|
|
48221
|
+
description: "One or more URLs to fetch, separated by commas if multiple.",
|
|
48222
|
+
required: true
|
|
48223
|
+
}
|
|
48224
|
+
],
|
|
48225
|
+
examples: [
|
|
48226
|
+
{
|
|
48227
|
+
description: "Fetch a single webpage",
|
|
48228
|
+
parameters: [
|
|
48229
|
+
{
|
|
48230
|
+
name: "url",
|
|
48231
|
+
value: "https://example.com"
|
|
48232
|
+
}
|
|
48233
|
+
]
|
|
48234
|
+
},
|
|
48235
|
+
{
|
|
48236
|
+
description: "Fetch multiple webpages",
|
|
48237
|
+
parameters: [
|
|
48238
|
+
{
|
|
48239
|
+
name: "url",
|
|
48240
|
+
value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
|
|
48241
|
+
}
|
|
48242
|
+
]
|
|
48243
|
+
},
|
|
48244
|
+
{
|
|
48245
|
+
description: "Fetch a raw file from GitHub",
|
|
48246
|
+
parameters: [
|
|
48247
|
+
{
|
|
48248
|
+
name: "url",
|
|
48249
|
+
value: "https://raw.githubusercontent.com/user/repo/main/README.md"
|
|
48250
|
+
}
|
|
48251
|
+
]
|
|
48252
|
+
}
|
|
48253
|
+
],
|
|
48254
|
+
permissionLevel: 1 /* Read */
|
|
48255
|
+
};
|
|
48256
|
+
var handler5 = async (provider, args) => {
|
|
48257
|
+
if (!provider.fetchUrl) {
|
|
48258
|
+
return {
|
|
48259
|
+
type: "Error" /* Error */,
|
|
48260
|
+
message: "Not possible to fetch url. Abort."
|
|
48261
|
+
};
|
|
48262
|
+
}
|
|
48263
|
+
const urls = getStringArray(args, "url");
|
|
48264
|
+
if (urls.length === 0) {
|
|
48265
|
+
return {
|
|
48266
|
+
type: "Error" /* Error */,
|
|
48267
|
+
message: "No URLs provided. Please provide at least one URL to fetch."
|
|
48268
|
+
};
|
|
48269
|
+
}
|
|
48270
|
+
const results = [];
|
|
48271
|
+
for (const url of urls) {
|
|
48272
|
+
try {
|
|
48273
|
+
const content = provider.fetchUrl(url).then((res) => `<fetch_url_content url="${url}">${res}</fetch_url_content>`);
|
|
48274
|
+
results.push(content);
|
|
48275
|
+
} catch (error) {
|
|
48276
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
48277
|
+
results.push(Promise.resolve(`<fetch_url_error url="${url}">${errorMessage}</fetch_url_error>`));
|
|
48278
|
+
}
|
|
48279
|
+
}
|
|
48280
|
+
const resolvedResults = await Promise.all(results);
|
|
48281
|
+
return {
|
|
48282
|
+
type: "Reply" /* Reply */,
|
|
48283
|
+
message: resolvedResults.join(`
|
|
48284
|
+
`)
|
|
48285
|
+
};
|
|
48286
|
+
};
|
|
48287
|
+
var isAvailable5 = (provider) => {
|
|
48288
|
+
return typeof provider.fetchUrl === "function";
|
|
48289
|
+
};
|
|
48290
|
+
var fetchUrl_default = {
|
|
48291
|
+
...toolInfo5,
|
|
48292
|
+
handler: handler5,
|
|
48293
|
+
isAvailable: isAvailable5
|
|
48294
|
+
};
|
|
48295
|
+
// ../core/src/tools/listFiles.ts
|
|
48296
|
+
var toolInfo6 = {
|
|
48215
48297
|
name: "list_files",
|
|
48216
48298
|
description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.",
|
|
48217
48299
|
parameters: [
|
|
@@ -48251,7 +48333,7 @@ var toolInfo5 = {
|
|
|
48251
48333
|
],
|
|
48252
48334
|
permissionLevel: 1 /* Read */
|
|
48253
48335
|
};
|
|
48254
|
-
var
|
|
48336
|
+
var handler6 = async (provider, args) => {
|
|
48255
48337
|
if (!provider.listFiles) {
|
|
48256
48338
|
return {
|
|
48257
48339
|
type: "Error" /* Error */,
|
|
@@ -48272,16 +48354,16 @@ ${files.join(`
|
|
|
48272
48354
|
<list_files_truncated>${limitReached}</list_files_truncated>`
|
|
48273
48355
|
};
|
|
48274
48356
|
};
|
|
48275
|
-
var
|
|
48357
|
+
var isAvailable6 = (provider) => {
|
|
48276
48358
|
return !!provider.listFiles;
|
|
48277
48359
|
};
|
|
48278
48360
|
var listFiles_default = {
|
|
48279
|
-
...
|
|
48280
|
-
handler:
|
|
48281
|
-
isAvailable:
|
|
48361
|
+
...toolInfo6,
|
|
48362
|
+
handler: handler6,
|
|
48363
|
+
isAvailable: isAvailable6
|
|
48282
48364
|
};
|
|
48283
48365
|
// ../core/src/tools/readFile.ts
|
|
48284
|
-
var
|
|
48366
|
+
var toolInfo7 = {
|
|
48285
48367
|
name: "read_file",
|
|
48286
48368
|
description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.",
|
|
48287
48369
|
parameters: [
|
|
@@ -48314,7 +48396,7 @@ var toolInfo6 = {
|
|
|
48314
48396
|
],
|
|
48315
48397
|
permissionLevel: 1 /* Read */
|
|
48316
48398
|
};
|
|
48317
|
-
var
|
|
48399
|
+
var handler7 = async (provider, args) => {
|
|
48318
48400
|
if (!provider.readFile) {
|
|
48319
48401
|
return {
|
|
48320
48402
|
type: "Error" /* Error */,
|
|
@@ -48342,16 +48424,16 @@ var handler6 = async (provider, args) => {
|
|
|
48342
48424
|
`)
|
|
48343
48425
|
};
|
|
48344
48426
|
};
|
|
48345
|
-
var
|
|
48427
|
+
var isAvailable7 = (provider) => {
|
|
48346
48428
|
return !!provider.readFile;
|
|
48347
48429
|
};
|
|
48348
48430
|
var readFile_default = {
|
|
48349
|
-
...
|
|
48350
|
-
handler:
|
|
48351
|
-
isAvailable:
|
|
48431
|
+
...toolInfo7,
|
|
48432
|
+
handler: handler7,
|
|
48433
|
+
isAvailable: isAvailable7
|
|
48352
48434
|
};
|
|
48353
48435
|
// ../core/src/tools/replaceInFile.ts
|
|
48354
|
-
var
|
|
48436
|
+
var toolInfo8 = {
|
|
48355
48437
|
name: "replace_in_file",
|
|
48356
48438
|
description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.",
|
|
48357
48439
|
parameters: [
|
|
@@ -48503,7 +48585,7 @@ function oldFeature() {
|
|
|
48503
48585
|
],
|
|
48504
48586
|
permissionLevel: 2 /* Write */
|
|
48505
48587
|
};
|
|
48506
|
-
var
|
|
48588
|
+
var handler8 = async (provider, args) => {
|
|
48507
48589
|
if (!provider.readFile || !provider.writeFile) {
|
|
48508
48590
|
return {
|
|
48509
48591
|
type: "Error" /* Error */,
|
|
@@ -48526,16 +48608,16 @@ var handler7 = async (provider, args) => {
|
|
|
48526
48608
|
message: `<replace_in_file_path>${path}</replace_in_file_path>`
|
|
48527
48609
|
};
|
|
48528
48610
|
};
|
|
48529
|
-
var
|
|
48611
|
+
var isAvailable8 = (provider) => {
|
|
48530
48612
|
return !!provider.readFile && !!provider.writeFile;
|
|
48531
48613
|
};
|
|
48532
48614
|
var replaceInFile_default = {
|
|
48533
|
-
...
|
|
48534
|
-
handler:
|
|
48535
|
-
isAvailable:
|
|
48615
|
+
...toolInfo8,
|
|
48616
|
+
handler: handler8,
|
|
48617
|
+
isAvailable: isAvailable8
|
|
48536
48618
|
};
|
|
48537
48619
|
// ../core/src/tools/searchFiles.ts
|
|
48538
|
-
var
|
|
48620
|
+
var toolInfo9 = {
|
|
48539
48621
|
name: "search_files",
|
|
48540
48622
|
description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.",
|
|
48541
48623
|
parameters: [
|
|
@@ -48579,7 +48661,7 @@ var toolInfo8 = {
|
|
|
48579
48661
|
],
|
|
48580
48662
|
permissionLevel: 1 /* Read */
|
|
48581
48663
|
};
|
|
48582
|
-
var
|
|
48664
|
+
var handler9 = async (provider, args) => {
|
|
48583
48665
|
if (!provider.searchFiles) {
|
|
48584
48666
|
return {
|
|
48585
48667
|
type: "Error" /* Error */,
|
|
@@ -48602,18 +48684,75 @@ ${files.join(`
|
|
|
48602
48684
|
`
|
|
48603
48685
|
};
|
|
48604
48686
|
};
|
|
48605
|
-
var
|
|
48687
|
+
var isAvailable9 = (provider) => {
|
|
48606
48688
|
return !!provider.searchFiles;
|
|
48607
48689
|
};
|
|
48608
48690
|
var searchFiles_default = {
|
|
48609
|
-
...
|
|
48610
|
-
handler:
|
|
48611
|
-
isAvailable:
|
|
48691
|
+
...toolInfo9,
|
|
48692
|
+
handler: handler9,
|
|
48693
|
+
isAvailable: isAvailable9
|
|
48612
48694
|
};
|
|
48613
48695
|
// ../core/src/tools/updateKnowledge.ts
|
|
48614
48696
|
var import_yaml = __toESM(require_dist(), 1);
|
|
48615
|
-
|
|
48616
|
-
|
|
48697
|
+
|
|
48698
|
+
// ../core/src/path.ts
|
|
48699
|
+
function dirname(path) {
|
|
48700
|
+
if (path.length === 0)
|
|
48701
|
+
return ".";
|
|
48702
|
+
const isRooted = path[0] === "/";
|
|
48703
|
+
let end = path.length - 1;
|
|
48704
|
+
while (end > 0 && path[end] === "/")
|
|
48705
|
+
end--;
|
|
48706
|
+
const idx = path.lastIndexOf("/", end);
|
|
48707
|
+
if (idx < 0) {
|
|
48708
|
+
return isRooted ? "/" : ".";
|
|
48709
|
+
}
|
|
48710
|
+
if (isRooted && idx === 0) {
|
|
48711
|
+
return "/";
|
|
48712
|
+
}
|
|
48713
|
+
return path.slice(0, idx);
|
|
48714
|
+
}
|
|
48715
|
+
function normalize(path) {
|
|
48716
|
+
const isAbsolute = path.startsWith("/");
|
|
48717
|
+
const segments = path.split("/").filter(Boolean);
|
|
48718
|
+
const stack = [];
|
|
48719
|
+
for (const seg of segments) {
|
|
48720
|
+
if (seg === ".")
|
|
48721
|
+
continue;
|
|
48722
|
+
if (seg === "..") {
|
|
48723
|
+
if (stack.length && stack[stack.length - 1] !== "..") {
|
|
48724
|
+
stack.pop();
|
|
48725
|
+
} else if (!isAbsolute) {
|
|
48726
|
+
stack.push("..");
|
|
48727
|
+
}
|
|
48728
|
+
} else {
|
|
48729
|
+
stack.push(seg);
|
|
48730
|
+
}
|
|
48731
|
+
}
|
|
48732
|
+
let result = stack.join("/");
|
|
48733
|
+
if (!result && !isAbsolute)
|
|
48734
|
+
return ".";
|
|
48735
|
+
if (result && path.endsWith("/"))
|
|
48736
|
+
result += "/";
|
|
48737
|
+
return (isAbsolute ? "/" : "") + result;
|
|
48738
|
+
}
|
|
48739
|
+
function join(...parts) {
|
|
48740
|
+
if (parts.length === 0)
|
|
48741
|
+
return ".";
|
|
48742
|
+
let combined = "";
|
|
48743
|
+
for (const p2 of parts) {
|
|
48744
|
+
if (typeof p2 !== "string") {
|
|
48745
|
+
throw new TypeError("Arguments to join must be strings");
|
|
48746
|
+
}
|
|
48747
|
+
if (p2) {
|
|
48748
|
+
combined = combined ? `${combined}/${p2}` : p2;
|
|
48749
|
+
}
|
|
48750
|
+
}
|
|
48751
|
+
return normalize(combined);
|
|
48752
|
+
}
|
|
48753
|
+
|
|
48754
|
+
// ../core/src/tools/updateKnowledge.ts
|
|
48755
|
+
var toolInfo10 = {
|
|
48617
48756
|
name: "update_knowledge",
|
|
48618
48757
|
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.",
|
|
48619
48758
|
parameters: [
|
|
@@ -48790,7 +48929,7 @@ function deepMerge(target, source) {
|
|
|
48790
48929
|
}
|
|
48791
48930
|
return output;
|
|
48792
48931
|
}
|
|
48793
|
-
var
|
|
48932
|
+
var handler10 = async (provider, args) => {
|
|
48794
48933
|
if (!provider.readFile || !provider.writeFile) {
|
|
48795
48934
|
return {
|
|
48796
48935
|
type: "Error" /* Error */,
|
|
@@ -48862,16 +49001,16 @@ var handler9 = async (provider, args) => {
|
|
|
48862
49001
|
};
|
|
48863
49002
|
}
|
|
48864
49003
|
};
|
|
48865
|
-
var
|
|
49004
|
+
var isAvailable10 = (provider) => {
|
|
48866
49005
|
return !!provider.readFile && !!provider.writeFile;
|
|
48867
49006
|
};
|
|
48868
49007
|
var updateKnowledge_default = {
|
|
48869
|
-
...
|
|
48870
|
-
handler:
|
|
48871
|
-
isAvailable:
|
|
49008
|
+
...toolInfo10,
|
|
49009
|
+
handler: handler10,
|
|
49010
|
+
isAvailable: isAvailable10
|
|
48872
49011
|
};
|
|
48873
49012
|
// ../core/src/tools/writeToFile.ts
|
|
48874
|
-
var
|
|
49013
|
+
var toolInfo11 = {
|
|
48875
49014
|
name: "write_to_file",
|
|
48876
49015
|
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<` and `>`.",
|
|
48877
49016
|
parameters: [
|
|
@@ -48916,7 +49055,7 @@ export default App;
|
|
|
48916
49055
|
],
|
|
48917
49056
|
permissionLevel: 2 /* Write */
|
|
48918
49057
|
};
|
|
48919
|
-
var
|
|
49058
|
+
var handler11 = async (provider, args) => {
|
|
48920
49059
|
if (!provider.writeFile) {
|
|
48921
49060
|
return {
|
|
48922
49061
|
type: "Error" /* Error */,
|
|
@@ -48931,16 +49070,16 @@ var handler10 = async (provider, args) => {
|
|
|
48931
49070
|
message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
|
|
48932
49071
|
};
|
|
48933
49072
|
};
|
|
48934
|
-
var
|
|
49073
|
+
var isAvailable11 = (provider) => {
|
|
48935
49074
|
return !!provider.writeFile;
|
|
48936
49075
|
};
|
|
48937
49076
|
var writeToFile_default = {
|
|
48938
|
-
...
|
|
48939
|
-
handler:
|
|
48940
|
-
isAvailable:
|
|
49077
|
+
...toolInfo11,
|
|
49078
|
+
handler: handler11,
|
|
49079
|
+
isAvailable: isAvailable11
|
|
48941
49080
|
};
|
|
48942
49081
|
// ../core/src/tools/handOver.ts
|
|
48943
|
-
var
|
|
49082
|
+
var toolInfo12 = {
|
|
48944
49083
|
name: "hand_over",
|
|
48945
49084
|
description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
|
|
48946
49085
|
parameters: [
|
|
@@ -48994,7 +49133,7 @@ var toolInfo11 = {
|
|
|
48994
49133
|
],
|
|
48995
49134
|
permissionLevel: 0 /* None */
|
|
48996
49135
|
};
|
|
48997
|
-
var
|
|
49136
|
+
var handler12 = async (_provider, args) => {
|
|
48998
49137
|
const agentName = getString(args, "agent_name");
|
|
48999
49138
|
const task = getString(args, "task");
|
|
49000
49139
|
const context = getString(args, "context", undefined);
|
|
@@ -49007,16 +49146,16 @@ var handler11 = async (_provider, args) => {
|
|
|
49007
49146
|
files
|
|
49008
49147
|
};
|
|
49009
49148
|
};
|
|
49010
|
-
var
|
|
49149
|
+
var isAvailable12 = (_provider) => {
|
|
49011
49150
|
return true;
|
|
49012
49151
|
};
|
|
49013
49152
|
var handOver_default = {
|
|
49014
|
-
...
|
|
49015
|
-
handler:
|
|
49016
|
-
isAvailable:
|
|
49153
|
+
...toolInfo12,
|
|
49154
|
+
handler: handler12,
|
|
49155
|
+
isAvailable: isAvailable12
|
|
49017
49156
|
};
|
|
49018
49157
|
// ../core/src/tools/removeFile.ts
|
|
49019
|
-
var
|
|
49158
|
+
var toolInfo13 = {
|
|
49020
49159
|
name: "remove_file",
|
|
49021
49160
|
description: "Request to remove a file at the specified path.",
|
|
49022
49161
|
parameters: [
|
|
@@ -49040,7 +49179,7 @@ var toolInfo12 = {
|
|
|
49040
49179
|
],
|
|
49041
49180
|
permissionLevel: 2 /* Write */
|
|
49042
49181
|
};
|
|
49043
|
-
var
|
|
49182
|
+
var handler13 = async (provider, args) => {
|
|
49044
49183
|
if (!provider.removeFile) {
|
|
49045
49184
|
return {
|
|
49046
49185
|
type: "Error" /* Error */,
|
|
@@ -49054,16 +49193,16 @@ var handler12 = async (provider, args) => {
|
|
|
49054
49193
|
message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
|
|
49055
49194
|
};
|
|
49056
49195
|
};
|
|
49057
|
-
var
|
|
49196
|
+
var isAvailable13 = (provider) => {
|
|
49058
49197
|
return !!provider.removeFile;
|
|
49059
49198
|
};
|
|
49060
49199
|
var removeFile_default = {
|
|
49061
|
-
...
|
|
49062
|
-
handler:
|
|
49063
|
-
isAvailable:
|
|
49200
|
+
...toolInfo13,
|
|
49201
|
+
handler: handler13,
|
|
49202
|
+
isAvailable: isAvailable13
|
|
49064
49203
|
};
|
|
49065
49204
|
// ../core/src/tools/renameFile.ts
|
|
49066
|
-
var
|
|
49205
|
+
var toolInfo14 = {
|
|
49067
49206
|
name: "rename_file",
|
|
49068
49207
|
description: "Request to rename a file from source path to target path.",
|
|
49069
49208
|
parameters: [
|
|
@@ -49097,7 +49236,7 @@ var toolInfo13 = {
|
|
|
49097
49236
|
],
|
|
49098
49237
|
permissionLevel: 2 /* Write */
|
|
49099
49238
|
};
|
|
49100
|
-
var
|
|
49239
|
+
var handler14 = async (provider, args) => {
|
|
49101
49240
|
if (!provider.renameFile) {
|
|
49102
49241
|
return {
|
|
49103
49242
|
type: "Error" /* Error */,
|
|
@@ -49112,13 +49251,13 @@ var handler13 = async (provider, args) => {
|
|
|
49112
49251
|
message: `<rename_file_path>${targetPath}</rename_file_path><status>Success</status>`
|
|
49113
49252
|
};
|
|
49114
49253
|
};
|
|
49115
|
-
var
|
|
49254
|
+
var isAvailable14 = (provider) => {
|
|
49116
49255
|
return !!provider.renameFile;
|
|
49117
49256
|
};
|
|
49118
49257
|
var renameFile_default = {
|
|
49119
|
-
...
|
|
49120
|
-
handler:
|
|
49121
|
-
isAvailable:
|
|
49258
|
+
...toolInfo14,
|
|
49259
|
+
handler: handler14,
|
|
49260
|
+
isAvailable: isAvailable14
|
|
49122
49261
|
};
|
|
49123
49262
|
// ../core/src/getAvailableTools.ts
|
|
49124
49263
|
var getAvailableTools = ({
|
|
@@ -49476,7 +49615,13 @@ ${joined}`;
|
|
|
49476
49615
|
};
|
|
49477
49616
|
var responsePrompts = {
|
|
49478
49617
|
errorInvokeTool: (tool, error) => `An error occurred while invoking the tool "${tool}": ${error}`,
|
|
49479
|
-
requireUseTool:
|
|
49618
|
+
requireUseTool: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
49619
|
+
e.g. <tool_tool_name>tool_name</tool_tool_name>
|
|
49620
|
+
|
|
49621
|
+
Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
|
|
49622
|
+
Avoid unnecessary text or symbols before or after the tool use.
|
|
49623
|
+
Avoid unnecessary escape characters or special characters.
|
|
49624
|
+
`,
|
|
49480
49625
|
toolResults: (tool, result) => `<tool_response>
|
|
49481
49626
|
<tool_name>${tool}</tool_name>
|
|
49482
49627
|
<tool_result>
|
|
@@ -49719,8 +49864,8 @@ ${instance.prompt}`;
|
|
|
49719
49864
|
}
|
|
49720
49865
|
async#invokeTool(name, args) {
|
|
49721
49866
|
try {
|
|
49722
|
-
const
|
|
49723
|
-
if (!
|
|
49867
|
+
const handler15 = this.handlers[name]?.handler;
|
|
49868
|
+
if (!handler15) {
|
|
49724
49869
|
return {
|
|
49725
49870
|
type: "Error" /* Error */,
|
|
49726
49871
|
message: responsePrompts.errorInvokeTool(name, "Tool not found"),
|
|
@@ -49739,7 +49884,7 @@ ${instance.prompt}`;
|
|
|
49739
49884
|
if (resp) {
|
|
49740
49885
|
return resp;
|
|
49741
49886
|
}
|
|
49742
|
-
return await
|
|
49887
|
+
return await handler15(this.config.provider, args);
|
|
49743
49888
|
} catch (error) {
|
|
49744
49889
|
return {
|
|
49745
49890
|
type: "Error" /* Error */,
|
|
@@ -50333,9 +50478,6 @@ class MultiAgent {
|
|
|
50333
50478
|
return this.#agents.length > 0;
|
|
50334
50479
|
}
|
|
50335
50480
|
}
|
|
50336
|
-
// ../core/src/Agent/policies/KnowledgeManagement.ts
|
|
50337
|
-
import { dirname, join as join2 } from "node:path";
|
|
50338
|
-
|
|
50339
50481
|
// ../core/node_modules/zod/lib/index.mjs
|
|
50340
50482
|
var util;
|
|
50341
50483
|
(function(util2) {
|
|
@@ -54482,7 +54624,7 @@ var KnowledgeManagementPolicy = (tools) => {
|
|
|
54482
54624
|
if (path === ".") {
|
|
54483
54625
|
continue;
|
|
54484
54626
|
}
|
|
54485
|
-
const fullpath =
|
|
54627
|
+
const fullpath = join(path, "knowledge.ai.yml");
|
|
54486
54628
|
if (!readFiles.has(fullpath)) {
|
|
54487
54629
|
allFullPaths.push(fullpath);
|
|
54488
54630
|
readFiles.add(fullpath);
|
|
@@ -55101,12 +55243,12 @@ Available commands:
|
|
|
55101
55243
|
import { existsSync as existsSync2 } from "node:fs";
|
|
55102
55244
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
55103
55245
|
import os2 from "node:os";
|
|
55104
|
-
import { join as
|
|
55246
|
+
import { join as join4 } from "node:path";
|
|
55105
55247
|
|
|
55106
55248
|
// ../cli-shared/src/config.ts
|
|
55107
55249
|
import { existsSync, readFileSync } from "node:fs";
|
|
55108
55250
|
import { homedir } from "node:os";
|
|
55109
|
-
import { join as
|
|
55251
|
+
import { join as join2 } from "node:path";
|
|
55110
55252
|
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
55111
55253
|
|
|
55112
55254
|
// ../cli-shared/node_modules/yaml/dist/index.js
|
|
@@ -58991,7 +59133,7 @@ var pipelineType2 = ZodPipeline2.create;
|
|
|
58991
59133
|
|
|
58992
59134
|
// ../cli-shared/src/config.ts
|
|
58993
59135
|
function getGlobalConfigPath(home = homedir()) {
|
|
58994
|
-
return
|
|
59136
|
+
return join2(home, ".config", "polkacodes", "config.yml");
|
|
58995
59137
|
}
|
|
58996
59138
|
function loadConfigAtPath(path) {
|
|
58997
59139
|
try {
|
|
@@ -59058,7 +59200,7 @@ ${error}`);
|
|
|
59058
59200
|
}
|
|
59059
59201
|
}
|
|
59060
59202
|
} else {
|
|
59061
|
-
const configPath =
|
|
59203
|
+
const configPath = join2(cwd, localConfigFileName);
|
|
59062
59204
|
try {
|
|
59063
59205
|
const projectConfig = readConfig(configPath);
|
|
59064
59206
|
configs.push(projectConfig);
|
|
@@ -59643,15 +59785,15 @@ function useKeypress(userHandler) {
|
|
|
59643
59785
|
signal.current = userHandler;
|
|
59644
59786
|
useEffect((rl) => {
|
|
59645
59787
|
let ignore = false;
|
|
59646
|
-
const
|
|
59788
|
+
const handler15 = withUpdates((_input, event) => {
|
|
59647
59789
|
if (ignore)
|
|
59648
59790
|
return;
|
|
59649
59791
|
signal.current(event, rl);
|
|
59650
59792
|
});
|
|
59651
|
-
rl.input.on("keypress",
|
|
59793
|
+
rl.input.on("keypress", handler15);
|
|
59652
59794
|
return () => {
|
|
59653
59795
|
ignore = true;
|
|
59654
|
-
rl.input.removeListener("keypress",
|
|
59796
|
+
rl.input.removeListener("keypress", handler15);
|
|
59655
59797
|
};
|
|
59656
59798
|
}, []);
|
|
59657
59799
|
}
|
|
@@ -59833,16 +59975,16 @@ class Emitter {
|
|
|
59833
59975
|
|
|
59834
59976
|
class SignalExitBase {
|
|
59835
59977
|
}
|
|
59836
|
-
var signalExitWrap = (
|
|
59978
|
+
var signalExitWrap = (handler15) => {
|
|
59837
59979
|
return {
|
|
59838
59980
|
onExit(cb, opts) {
|
|
59839
|
-
return
|
|
59981
|
+
return handler15.onExit(cb, opts);
|
|
59840
59982
|
},
|
|
59841
59983
|
load() {
|
|
59842
|
-
return
|
|
59984
|
+
return handler15.load();
|
|
59843
59985
|
},
|
|
59844
59986
|
unload() {
|
|
59845
|
-
return
|
|
59987
|
+
return handler15.unload();
|
|
59846
59988
|
}
|
|
59847
59989
|
};
|
|
59848
59990
|
};
|
|
@@ -60471,7 +60613,7 @@ function checkRipgrep() {
|
|
|
60471
60613
|
// ../cli-shared/src/utils/listFiles.ts
|
|
60472
60614
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
60473
60615
|
import { promises as fs2 } from "node:fs";
|
|
60474
|
-
import { join as
|
|
60616
|
+
import { join as join3, relative, resolve } from "node:path";
|
|
60475
60617
|
var DEFAULT_IGNORES = [
|
|
60476
60618
|
"__pycache__",
|
|
60477
60619
|
".DS_Store",
|
|
@@ -60489,7 +60631,7 @@ var DEFAULT_IGNORES = [
|
|
|
60489
60631
|
];
|
|
60490
60632
|
async function extendPatterns(basePatterns, dirPath) {
|
|
60491
60633
|
try {
|
|
60492
|
-
const gitignorePath =
|
|
60634
|
+
const gitignorePath = join3(dirPath, ".gitignore");
|
|
60493
60635
|
const content = await fs2.readFile(gitignorePath, "utf8");
|
|
60494
60636
|
const lines2 = content.split(/\r?\n/).filter(Boolean);
|
|
60495
60637
|
return [...basePatterns, ...lines2];
|
|
@@ -60503,7 +60645,7 @@ function createIgnore(patterns) {
|
|
|
60503
60645
|
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
60504
60646
|
let rootPatterns = [...DEFAULT_IGNORES, ...excludeFiles || []];
|
|
60505
60647
|
try {
|
|
60506
|
-
const rootGitignore = await fs2.readFile(
|
|
60648
|
+
const rootGitignore = await fs2.readFile(join3(cwd, ".gitignore"), "utf8");
|
|
60507
60649
|
const lines2 = rootGitignore.split(/\r?\n/).filter(Boolean);
|
|
60508
60650
|
rootPatterns = [...rootPatterns, ...lines2];
|
|
60509
60651
|
} catch {}
|
|
@@ -60524,7 +60666,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
60524
60666
|
const entries = await fs2.readdir(currentPath, { withFileTypes: true });
|
|
60525
60667
|
entries.sort((a2, b2) => a2.name.localeCompare(b2.name));
|
|
60526
60668
|
for (const entry of entries) {
|
|
60527
|
-
const fullPath =
|
|
60669
|
+
const fullPath = join3(currentPath, entry.name);
|
|
60528
60670
|
const relPath = relative(cwd, fullPath).replace(/\\/g, "/");
|
|
60529
60671
|
if (folderIg.ignores(relPath)) {
|
|
60530
60672
|
continue;
|
|
@@ -60541,7 +60683,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
60541
60683
|
results.push(relPath);
|
|
60542
60684
|
if (results.length >= maxCount) {
|
|
60543
60685
|
const remainingEntries = entries.slice(entries.indexOf(entry) + 1);
|
|
60544
|
-
const hasRemainingFiles = remainingEntries.some((e2) => !e2.isDirectory() && !folderIg.ignores(relative(cwd,
|
|
60686
|
+
const hasRemainingFiles = remainingEntries.some((e2) => !e2.isDirectory() && !folderIg.ignores(relative(cwd, join3(currentPath, e2.name)).replace(/\\/g, "/")));
|
|
60545
60687
|
if (hasRemainingFiles) {
|
|
60546
60688
|
const marker = `${currentRelPath}/(files omitted)`;
|
|
60547
60689
|
results.push(marker);
|
|
@@ -60700,6 +60842,20 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
60700
60842
|
},
|
|
60701
60843
|
attemptCompletion: async (result) => {
|
|
60702
60844
|
return;
|
|
60845
|
+
},
|
|
60846
|
+
fetchUrl: async (url) => {
|
|
60847
|
+
const isRaw = url.startsWith("https://raw.githubusercontent.com/");
|
|
60848
|
+
const urlToFetch = isRaw ? url : `https://r.jina.ai/${url}`;
|
|
60849
|
+
try {
|
|
60850
|
+
const response = await fetch(urlToFetch);
|
|
60851
|
+
if (!response.ok) {
|
|
60852
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
60853
|
+
}
|
|
60854
|
+
return await response.text();
|
|
60855
|
+
} catch (error) {
|
|
60856
|
+
console.error("Error fetching URL:", error);
|
|
60857
|
+
throw error;
|
|
60858
|
+
}
|
|
60703
60859
|
}
|
|
60704
60860
|
};
|
|
60705
60861
|
if (checkRipgrep()) {
|
|
@@ -61478,7 +61634,7 @@ ${fileList.join(`
|
|
|
61478
61634
|
</files>`;
|
|
61479
61635
|
let knowledgeContent = "";
|
|
61480
61636
|
if (this.#hasKnowledgeManagementPolicy) {
|
|
61481
|
-
const knowledgeFilePath =
|
|
61637
|
+
const knowledgeFilePath = join4(cwd, "knowledge.ai.yml");
|
|
61482
61638
|
if (existsSync2(knowledgeFilePath)) {
|
|
61483
61639
|
try {
|
|
61484
61640
|
const content = await readFile2(knowledgeFilePath, "utf8");
|
|
@@ -62421,9 +62577,9 @@ ${result.response}`);
|
|
|
62421
62577
|
// src/commands/create.ts
|
|
62422
62578
|
import { existsSync as existsSync3 } from "node:fs";
|
|
62423
62579
|
import { mkdir as mkdir2, stat } from "node:fs/promises";
|
|
62424
|
-
import { join as
|
|
62580
|
+
import { join as join5 } from "node:path";
|
|
62425
62581
|
var askForPath = async (projectName) => {
|
|
62426
|
-
let targetPath =
|
|
62582
|
+
let targetPath = join5(process.cwd(), projectName);
|
|
62427
62583
|
while (true) {
|
|
62428
62584
|
const confirmPath = await esm_default2({
|
|
62429
62585
|
message: `Do you want to create project at ${targetPath}?`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.23",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@inquirer/prompts": "^7.2.3",
|
|
21
|
-
"@polka-codes/core": "0.8.
|
|
22
|
-
"@polka-codes/cli-shared": "0.8.
|
|
21
|
+
"@polka-codes/core": "0.8.22",
|
|
22
|
+
"@polka-codes/cli-shared": "0.8.22",
|
|
23
23
|
"commander": "^13.0.0",
|
|
24
24
|
"dotenv": "^16.4.7",
|
|
25
25
|
"lodash": "^4.17.21",
|