@polka-codes/cli-shared 0.9.48 → 0.9.50
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 +414 -82
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30922,8 +30922,40 @@ var fetchUrl_default = {
|
|
|
30922
30922
|
...toolInfo3,
|
|
30923
30923
|
handler: handler3
|
|
30924
30924
|
};
|
|
30925
|
-
// ../core/src/tools/
|
|
30925
|
+
// ../core/src/tools/getTodoItem.ts
|
|
30926
30926
|
var toolInfo4 = {
|
|
30927
|
+
name: "getTodoItem",
|
|
30928
|
+
description: "Get a to-do item by its ID.",
|
|
30929
|
+
parameters: exports_external.object({
|
|
30930
|
+
id: exports_external.string().describe("The ID of the to-do item.")
|
|
30931
|
+
})
|
|
30932
|
+
};
|
|
30933
|
+
var handler4 = async (provider, args) => {
|
|
30934
|
+
if (!provider.getTodoItem) {
|
|
30935
|
+
return {
|
|
30936
|
+
type: "Error" /* Error */,
|
|
30937
|
+
message: {
|
|
30938
|
+
type: "error-text",
|
|
30939
|
+
value: "Not possible to get a to-do item."
|
|
30940
|
+
}
|
|
30941
|
+
};
|
|
30942
|
+
}
|
|
30943
|
+
const { id } = toolInfo4.parameters.parse(args);
|
|
30944
|
+
const item = await provider.getTodoItem(id);
|
|
30945
|
+
return {
|
|
30946
|
+
type: "Reply" /* Reply */,
|
|
30947
|
+
message: {
|
|
30948
|
+
type: "json",
|
|
30949
|
+
value: item ?? null
|
|
30950
|
+
}
|
|
30951
|
+
};
|
|
30952
|
+
};
|
|
30953
|
+
var getTodoItem_default = {
|
|
30954
|
+
...toolInfo4,
|
|
30955
|
+
handler: handler4
|
|
30956
|
+
};
|
|
30957
|
+
// ../core/src/tools/listFiles.ts
|
|
30958
|
+
var toolInfo5 = {
|
|
30927
30959
|
name: "listFiles",
|
|
30928
30960
|
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.",
|
|
30929
30961
|
parameters: exports_external.object({
|
|
@@ -30961,7 +30993,7 @@ var toolInfo4 = {
|
|
|
30961
30993
|
]
|
|
30962
30994
|
})
|
|
30963
30995
|
};
|
|
30964
|
-
var
|
|
30996
|
+
var handler5 = async (provider, args) => {
|
|
30965
30997
|
if (!provider.listFiles) {
|
|
30966
30998
|
return {
|
|
30967
30999
|
type: "Error" /* Error */,
|
|
@@ -30971,7 +31003,7 @@ var handler4 = async (provider, args) => {
|
|
|
30971
31003
|
}
|
|
30972
31004
|
};
|
|
30973
31005
|
}
|
|
30974
|
-
const { path, maxCount, recursive, includeIgnored } =
|
|
31006
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo5.parameters.parse(args);
|
|
30975
31007
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
30976
31008
|
return {
|
|
30977
31009
|
type: "Reply" /* Reply */,
|
|
@@ -30987,16 +31019,16 @@ ${files.join(`
|
|
|
30987
31019
|
};
|
|
30988
31020
|
};
|
|
30989
31021
|
var listFiles_default = {
|
|
30990
|
-
...
|
|
30991
|
-
handler:
|
|
31022
|
+
...toolInfo5,
|
|
31023
|
+
handler: handler5
|
|
30992
31024
|
};
|
|
30993
31025
|
// ../core/src/tools/listMemoryTopics.ts
|
|
30994
|
-
var
|
|
31026
|
+
var toolInfo6 = {
|
|
30995
31027
|
name: "listMemoryTopics",
|
|
30996
|
-
description: "Lists all topics in memory.",
|
|
31028
|
+
description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.",
|
|
30997
31029
|
parameters: exports_external.object({})
|
|
30998
31030
|
};
|
|
30999
|
-
var
|
|
31031
|
+
var handler6 = async (provider, _args) => {
|
|
31000
31032
|
const topics = await provider.listMemoryTopics();
|
|
31001
31033
|
if (!topics.length) {
|
|
31002
31034
|
return { type: "Reply" /* Reply */, message: { type: "text", value: "No topics found." } };
|
|
@@ -31012,18 +31044,89 @@ ${topics.join(`
|
|
|
31012
31044
|
};
|
|
31013
31045
|
};
|
|
31014
31046
|
var listMemoryTopics_default = {
|
|
31015
|
-
...
|
|
31016
|
-
handler:
|
|
31047
|
+
...toolInfo6,
|
|
31048
|
+
handler: handler6
|
|
31049
|
+
};
|
|
31050
|
+
// ../core/src/tools/todo.ts
|
|
31051
|
+
var TodoStatus = exports_external.enum(["open", "completed", "closed"]);
|
|
31052
|
+
var TodoItemSchema = exports_external.object({
|
|
31053
|
+
id: exports_external.string(),
|
|
31054
|
+
title: exports_external.string(),
|
|
31055
|
+
description: exports_external.string(),
|
|
31056
|
+
status: TodoStatus
|
|
31057
|
+
});
|
|
31058
|
+
var UpdateTodoItemInputSchema = exports_external.object({
|
|
31059
|
+
operation: exports_external.enum(["add", "update"]),
|
|
31060
|
+
id: exports_external.string().nullish(),
|
|
31061
|
+
parentId: exports_external.string().nullish(),
|
|
31062
|
+
title: exports_external.string().nullish(),
|
|
31063
|
+
description: exports_external.string().nullish(),
|
|
31064
|
+
status: TodoStatus.nullish()
|
|
31065
|
+
}).superRefine((data, ctx) => {
|
|
31066
|
+
if (data.operation === "add") {
|
|
31067
|
+
if (!data.title) {
|
|
31068
|
+
ctx.addIssue({
|
|
31069
|
+
code: "custom",
|
|
31070
|
+
message: 'Title is required for "add" operation',
|
|
31071
|
+
path: ["title"]
|
|
31072
|
+
});
|
|
31073
|
+
}
|
|
31074
|
+
} else if (data.operation === "update") {
|
|
31075
|
+
if (!data.id) {
|
|
31076
|
+
ctx.addIssue({
|
|
31077
|
+
code: "custom",
|
|
31078
|
+
message: 'ID is required for "update" operation',
|
|
31079
|
+
path: ["id"]
|
|
31080
|
+
});
|
|
31081
|
+
}
|
|
31082
|
+
}
|
|
31083
|
+
});
|
|
31084
|
+
var UpdateTodoItemOutputSchema = exports_external.object({
|
|
31085
|
+
id: exports_external.string()
|
|
31086
|
+
});
|
|
31087
|
+
|
|
31088
|
+
// ../core/src/tools/listTodoItems.ts
|
|
31089
|
+
var toolInfo7 = {
|
|
31090
|
+
name: "listTodoItems",
|
|
31091
|
+
description: "List all to-do items, sorted by id. If an id is provided, it lists all sub-items for that id. Can be filtered by status.",
|
|
31092
|
+
parameters: exports_external.object({
|
|
31093
|
+
id: exports_external.string().nullish(),
|
|
31094
|
+
status: TodoStatus.nullish()
|
|
31095
|
+
})
|
|
31096
|
+
};
|
|
31097
|
+
var handler7 = async (provider, args) => {
|
|
31098
|
+
if (!provider.listTodoItems) {
|
|
31099
|
+
return {
|
|
31100
|
+
type: "Error" /* Error */,
|
|
31101
|
+
message: {
|
|
31102
|
+
type: "error-text",
|
|
31103
|
+
value: "Not possible to list to-do items."
|
|
31104
|
+
}
|
|
31105
|
+
};
|
|
31106
|
+
}
|
|
31107
|
+
const { id, status } = toolInfo7.parameters.parse(args);
|
|
31108
|
+
const items = await provider.listTodoItems(id, status);
|
|
31109
|
+
return {
|
|
31110
|
+
type: "Reply" /* Reply */,
|
|
31111
|
+
message: {
|
|
31112
|
+
type: "json",
|
|
31113
|
+
value: items
|
|
31114
|
+
}
|
|
31115
|
+
};
|
|
31116
|
+
};
|
|
31117
|
+
var listTodoItems_default = {
|
|
31118
|
+
...toolInfo7,
|
|
31119
|
+
handler: handler7
|
|
31017
31120
|
};
|
|
31018
31121
|
// ../core/src/tools/readBinaryFile.ts
|
|
31019
|
-
var
|
|
31122
|
+
var toolInfo8 = {
|
|
31020
31123
|
name: "readBinaryFile",
|
|
31021
31124
|
description: "Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.",
|
|
31022
31125
|
parameters: exports_external.object({
|
|
31023
31126
|
url: exports_external.string().describe("The URL or local path of the file to read.")
|
|
31024
31127
|
})
|
|
31025
31128
|
};
|
|
31026
|
-
var
|
|
31129
|
+
var handler8 = async (provider, args) => {
|
|
31027
31130
|
if (!provider.readBinaryFile) {
|
|
31028
31131
|
return {
|
|
31029
31132
|
type: "Error" /* Error */,
|
|
@@ -31033,7 +31136,7 @@ var handler6 = async (provider, args) => {
|
|
|
31033
31136
|
}
|
|
31034
31137
|
};
|
|
31035
31138
|
}
|
|
31036
|
-
const { url: url2 } =
|
|
31139
|
+
const { url: url2 } = toolInfo8.parameters.parse(args);
|
|
31037
31140
|
try {
|
|
31038
31141
|
const filePart = await provider.readBinaryFile(url2);
|
|
31039
31142
|
return {
|
|
@@ -31062,11 +31165,11 @@ var handler6 = async (provider, args) => {
|
|
|
31062
31165
|
}
|
|
31063
31166
|
};
|
|
31064
31167
|
var readBinaryFile_default = {
|
|
31065
|
-
...
|
|
31066
|
-
handler:
|
|
31168
|
+
...toolInfo8,
|
|
31169
|
+
handler: handler8
|
|
31067
31170
|
};
|
|
31068
31171
|
// ../core/src/tools/readFile.ts
|
|
31069
|
-
var
|
|
31172
|
+
var toolInfo9 = {
|
|
31070
31173
|
name: "readFile",
|
|
31071
31174
|
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.",
|
|
31072
31175
|
parameters: exports_external.object({
|
|
@@ -31103,7 +31206,7 @@ var toolInfo7 = {
|
|
|
31103
31206
|
]
|
|
31104
31207
|
})
|
|
31105
31208
|
};
|
|
31106
|
-
var
|
|
31209
|
+
var handler9 = async (provider, args) => {
|
|
31107
31210
|
if (!provider.readFile) {
|
|
31108
31211
|
return {
|
|
31109
31212
|
type: "Error" /* Error */,
|
|
@@ -31113,7 +31216,7 @@ var handler7 = async (provider, args) => {
|
|
|
31113
31216
|
}
|
|
31114
31217
|
};
|
|
31115
31218
|
}
|
|
31116
|
-
const { path: paths, includeIgnored } =
|
|
31219
|
+
const { path: paths, includeIgnored } = toolInfo9.parameters.parse(args);
|
|
31117
31220
|
const resp = [];
|
|
31118
31221
|
for (const path of paths) {
|
|
31119
31222
|
const fileContent = await provider.readFile(path, includeIgnored);
|
|
@@ -31138,19 +31241,19 @@ var handler7 = async (provider, args) => {
|
|
|
31138
31241
|
};
|
|
31139
31242
|
};
|
|
31140
31243
|
var readFile_default = {
|
|
31141
|
-
...
|
|
31142
|
-
handler:
|
|
31244
|
+
...toolInfo9,
|
|
31245
|
+
handler: handler9
|
|
31143
31246
|
};
|
|
31144
31247
|
// ../core/src/tools/readMemory.ts
|
|
31145
|
-
var
|
|
31248
|
+
var toolInfo10 = {
|
|
31146
31249
|
name: "readMemory",
|
|
31147
|
-
description: "Reads content from a memory topic.",
|
|
31250
|
+
description: "Reads content from a memory topic. Use this to retrieve information stored in previous steps. If no topic is specified, reads from the default topic.",
|
|
31148
31251
|
parameters: exports_external.object({
|
|
31149
31252
|
topic: exports_external.string().optional().describe('The topic to read from memory. Defaults to ":default:".')
|
|
31150
31253
|
})
|
|
31151
31254
|
};
|
|
31152
|
-
var
|
|
31153
|
-
const { topic } =
|
|
31255
|
+
var handler10 = async (provider, args) => {
|
|
31256
|
+
const { topic } = toolInfo10.parameters.parse(args);
|
|
31154
31257
|
const content = await provider.readMemory(topic);
|
|
31155
31258
|
if (content) {
|
|
31156
31259
|
return {
|
|
@@ -31172,11 +31275,11 @@ ${content}
|
|
|
31172
31275
|
};
|
|
31173
31276
|
};
|
|
31174
31277
|
var readMemory_default = {
|
|
31175
|
-
...
|
|
31176
|
-
handler:
|
|
31278
|
+
...toolInfo10,
|
|
31279
|
+
handler: handler10
|
|
31177
31280
|
};
|
|
31178
31281
|
// ../core/src/tools/removeFile.ts
|
|
31179
|
-
var
|
|
31282
|
+
var toolInfo11 = {
|
|
31180
31283
|
name: "removeFile",
|
|
31181
31284
|
description: "Request to remove a file at the specified path.",
|
|
31182
31285
|
parameters: exports_external.object({
|
|
@@ -31192,7 +31295,7 @@ var toolInfo9 = {
|
|
|
31192
31295
|
]
|
|
31193
31296
|
})
|
|
31194
31297
|
};
|
|
31195
|
-
var
|
|
31298
|
+
var handler11 = async (provider, args) => {
|
|
31196
31299
|
if (!provider.removeFile) {
|
|
31197
31300
|
return {
|
|
31198
31301
|
type: "Error" /* Error */,
|
|
@@ -31202,7 +31305,7 @@ var handler9 = async (provider, args) => {
|
|
|
31202
31305
|
}
|
|
31203
31306
|
};
|
|
31204
31307
|
}
|
|
31205
|
-
const parsed =
|
|
31308
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
31206
31309
|
if (!parsed.success) {
|
|
31207
31310
|
return {
|
|
31208
31311
|
type: "Error" /* Error */,
|
|
@@ -31223,11 +31326,11 @@ var handler9 = async (provider, args) => {
|
|
|
31223
31326
|
};
|
|
31224
31327
|
};
|
|
31225
31328
|
var removeFile_default = {
|
|
31226
|
-
...
|
|
31227
|
-
handler:
|
|
31329
|
+
...toolInfo11,
|
|
31330
|
+
handler: handler11
|
|
31228
31331
|
};
|
|
31229
31332
|
// ../core/src/tools/renameFile.ts
|
|
31230
|
-
var
|
|
31333
|
+
var toolInfo12 = {
|
|
31231
31334
|
name: "renameFile",
|
|
31232
31335
|
description: "Request to rename a file from source path to target path.",
|
|
31233
31336
|
parameters: exports_external.object({
|
|
@@ -31245,7 +31348,7 @@ var toolInfo10 = {
|
|
|
31245
31348
|
]
|
|
31246
31349
|
})
|
|
31247
31350
|
};
|
|
31248
|
-
var
|
|
31351
|
+
var handler12 = async (provider, args) => {
|
|
31249
31352
|
if (!provider.renameFile) {
|
|
31250
31353
|
return {
|
|
31251
31354
|
type: "Error" /* Error */,
|
|
@@ -31255,7 +31358,7 @@ var handler10 = async (provider, args) => {
|
|
|
31255
31358
|
}
|
|
31256
31359
|
};
|
|
31257
31360
|
}
|
|
31258
|
-
const { source_path, target_path } =
|
|
31361
|
+
const { source_path, target_path } = toolInfo12.parameters.parse(args);
|
|
31259
31362
|
await provider.renameFile(source_path, target_path);
|
|
31260
31363
|
return {
|
|
31261
31364
|
type: "Reply" /* Reply */,
|
|
@@ -31266,12 +31369,12 @@ var handler10 = async (provider, args) => {
|
|
|
31266
31369
|
};
|
|
31267
31370
|
};
|
|
31268
31371
|
var renameFile_default = {
|
|
31269
|
-
...
|
|
31270
|
-
handler:
|
|
31372
|
+
...toolInfo12,
|
|
31373
|
+
handler: handler12
|
|
31271
31374
|
};
|
|
31272
31375
|
// ../core/src/tools/utils/replaceInFile.ts
|
|
31273
31376
|
var replaceInFile = (fileContent, diff) => {
|
|
31274
|
-
const blockPattern =
|
|
31377
|
+
const blockPattern = /^\s*<<<<<+\s*SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+\s*REPLACE\s*$/gm;
|
|
31275
31378
|
const blocks = [];
|
|
31276
31379
|
for (let match = blockPattern.exec(diff);match !== null; match = blockPattern.exec(diff)) {
|
|
31277
31380
|
blocks.push({ search: match[1], replace: match[2] });
|
|
@@ -31344,7 +31447,7 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
31344
31447
|
};
|
|
31345
31448
|
|
|
31346
31449
|
// ../core/src/tools/replaceInFile.ts
|
|
31347
|
-
var
|
|
31450
|
+
var toolInfo13 = {
|
|
31348
31451
|
name: "replaceInFile",
|
|
31349
31452
|
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.",
|
|
31350
31453
|
parameters: exports_external.object({
|
|
@@ -31454,7 +31557,7 @@ function oldFeature() {
|
|
|
31454
31557
|
]
|
|
31455
31558
|
})
|
|
31456
31559
|
};
|
|
31457
|
-
var
|
|
31560
|
+
var handler13 = async (provider, args) => {
|
|
31458
31561
|
if (!provider.readFile || !provider.writeFile) {
|
|
31459
31562
|
return {
|
|
31460
31563
|
type: "Error" /* Error */,
|
|
@@ -31464,7 +31567,7 @@ var handler11 = async (provider, args) => {
|
|
|
31464
31567
|
}
|
|
31465
31568
|
};
|
|
31466
31569
|
}
|
|
31467
|
-
const parsed =
|
|
31570
|
+
const parsed = toolInfo13.parameters.safeParse(args);
|
|
31468
31571
|
if (!parsed.success) {
|
|
31469
31572
|
return {
|
|
31470
31573
|
type: "Error" /* Error */,
|
|
@@ -31528,11 +31631,11 @@ var handler11 = async (provider, args) => {
|
|
|
31528
31631
|
}
|
|
31529
31632
|
};
|
|
31530
31633
|
var replaceInFile_default = {
|
|
31531
|
-
...
|
|
31532
|
-
handler:
|
|
31634
|
+
...toolInfo13,
|
|
31635
|
+
handler: handler13
|
|
31533
31636
|
};
|
|
31534
31637
|
// ../core/src/tools/searchFiles.ts
|
|
31535
|
-
var
|
|
31638
|
+
var toolInfo14 = {
|
|
31536
31639
|
name: "searchFiles",
|
|
31537
31640
|
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.",
|
|
31538
31641
|
parameters: exports_external.object({
|
|
@@ -31556,7 +31659,7 @@ var toolInfo12 = {
|
|
|
31556
31659
|
]
|
|
31557
31660
|
})
|
|
31558
31661
|
};
|
|
31559
|
-
var
|
|
31662
|
+
var handler14 = async (provider, args) => {
|
|
31560
31663
|
if (!provider.searchFiles) {
|
|
31561
31664
|
return {
|
|
31562
31665
|
type: "Error" /* Error */,
|
|
@@ -31566,7 +31669,7 @@ var handler12 = async (provider, args) => {
|
|
|
31566
31669
|
}
|
|
31567
31670
|
};
|
|
31568
31671
|
}
|
|
31569
|
-
const parsed =
|
|
31672
|
+
const parsed = toolInfo14.parameters.safeParse(args);
|
|
31570
31673
|
if (!parsed.success) {
|
|
31571
31674
|
return {
|
|
31572
31675
|
type: "Error" /* Error */,
|
|
@@ -31604,13 +31707,13 @@ ${files.join(`
|
|
|
31604
31707
|
}
|
|
31605
31708
|
};
|
|
31606
31709
|
var searchFiles_default = {
|
|
31607
|
-
...
|
|
31608
|
-
handler:
|
|
31710
|
+
...toolInfo14,
|
|
31711
|
+
handler: handler14
|
|
31609
31712
|
};
|
|
31610
31713
|
// ../core/src/tools/updateMemory.ts
|
|
31611
|
-
var
|
|
31714
|
+
var toolInfo15 = {
|
|
31612
31715
|
name: "updateMemory",
|
|
31613
|
-
description:
|
|
31716
|
+
description: 'Appends, replaces, or removes content from a memory topic. Use "append" to add to existing content, "replace" to overwrite entirely, or "remove" to delete a topic. Memory persists across tool calls within a workflow.',
|
|
31614
31717
|
parameters: exports_external.object({
|
|
31615
31718
|
operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
31616
31719
|
topic: exports_external.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
@@ -31635,7 +31738,7 @@ var toolInfo13 = {
|
|
|
31635
31738
|
}
|
|
31636
31739
|
})
|
|
31637
31740
|
};
|
|
31638
|
-
var
|
|
31741
|
+
var handler15 = async (provider, args) => {
|
|
31639
31742
|
if (!provider.updateMemory) {
|
|
31640
31743
|
return {
|
|
31641
31744
|
type: "Error" /* Error */,
|
|
@@ -31645,7 +31748,7 @@ var handler13 = async (provider, args) => {
|
|
|
31645
31748
|
}
|
|
31646
31749
|
};
|
|
31647
31750
|
}
|
|
31648
|
-
const params =
|
|
31751
|
+
const params = toolInfo15.parameters.parse(args);
|
|
31649
31752
|
await provider.updateMemory(params.operation, params.topic ?? undefined, "content" in params ? params.content : undefined);
|
|
31650
31753
|
switch (params.operation) {
|
|
31651
31754
|
case "append":
|
|
@@ -31675,11 +31778,41 @@ var handler13 = async (provider, args) => {
|
|
|
31675
31778
|
}
|
|
31676
31779
|
};
|
|
31677
31780
|
var updateMemory_default = {
|
|
31678
|
-
...
|
|
31679
|
-
handler:
|
|
31781
|
+
...toolInfo15,
|
|
31782
|
+
handler: handler15
|
|
31783
|
+
};
|
|
31784
|
+
// ../core/src/tools/updateTodoItem.ts
|
|
31785
|
+
var toolInfo16 = {
|
|
31786
|
+
name: "updateTodoItem",
|
|
31787
|
+
description: "Add or update a to-do item.",
|
|
31788
|
+
parameters: UpdateTodoItemInputSchema
|
|
31789
|
+
};
|
|
31790
|
+
var handler16 = async (provider, args) => {
|
|
31791
|
+
if (!provider.updateTodoItem) {
|
|
31792
|
+
return {
|
|
31793
|
+
type: "Error" /* Error */,
|
|
31794
|
+
message: {
|
|
31795
|
+
type: "error-text",
|
|
31796
|
+
value: "Not possible to update a to-do item."
|
|
31797
|
+
}
|
|
31798
|
+
};
|
|
31799
|
+
}
|
|
31800
|
+
const input = toolInfo16.parameters.parse(args);
|
|
31801
|
+
const result = await provider.updateTodoItem(input);
|
|
31802
|
+
return {
|
|
31803
|
+
type: "Reply" /* Reply */,
|
|
31804
|
+
message: {
|
|
31805
|
+
type: "json",
|
|
31806
|
+
value: result
|
|
31807
|
+
}
|
|
31808
|
+
};
|
|
31809
|
+
};
|
|
31810
|
+
var updateTodoItem_default = {
|
|
31811
|
+
...toolInfo16,
|
|
31812
|
+
handler: handler16
|
|
31680
31813
|
};
|
|
31681
31814
|
// ../core/src/tools/writeToFile.ts
|
|
31682
|
-
var
|
|
31815
|
+
var toolInfo17 = {
|
|
31683
31816
|
name: "writeToFile",
|
|
31684
31817
|
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 `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.",
|
|
31685
31818
|
parameters: exports_external.object({
|
|
@@ -31708,7 +31841,7 @@ export default App;
|
|
|
31708
31841
|
]
|
|
31709
31842
|
})
|
|
31710
31843
|
};
|
|
31711
|
-
var
|
|
31844
|
+
var handler17 = async (provider, args) => {
|
|
31712
31845
|
if (!provider.writeFile) {
|
|
31713
31846
|
return {
|
|
31714
31847
|
type: "Error" /* Error */,
|
|
@@ -31718,7 +31851,7 @@ var handler14 = async (provider, args) => {
|
|
|
31718
31851
|
}
|
|
31719
31852
|
};
|
|
31720
31853
|
}
|
|
31721
|
-
const parsed =
|
|
31854
|
+
const parsed = toolInfo17.parameters.safeParse(args);
|
|
31722
31855
|
if (!parsed.success) {
|
|
31723
31856
|
return {
|
|
31724
31857
|
type: "Error" /* Error */,
|
|
@@ -31742,8 +31875,8 @@ var handler14 = async (provider, args) => {
|
|
|
31742
31875
|
};
|
|
31743
31876
|
};
|
|
31744
31877
|
var writeToFile_default = {
|
|
31745
|
-
...
|
|
31746
|
-
handler:
|
|
31878
|
+
...toolInfo17,
|
|
31879
|
+
handler: handler17
|
|
31747
31880
|
};
|
|
31748
31881
|
// ../core/src/UsageMeter.ts
|
|
31749
31882
|
class UsageMeter {
|
|
@@ -33633,15 +33766,15 @@ function useKeypress(userHandler) {
|
|
|
33633
33766
|
signal.current = userHandler;
|
|
33634
33767
|
useEffect((rl) => {
|
|
33635
33768
|
let ignore = false;
|
|
33636
|
-
const
|
|
33769
|
+
const handler18 = withUpdates((_input, event) => {
|
|
33637
33770
|
if (ignore)
|
|
33638
33771
|
return;
|
|
33639
33772
|
signal.current(event, rl);
|
|
33640
33773
|
});
|
|
33641
|
-
rl.input.on("keypress",
|
|
33774
|
+
rl.input.on("keypress", handler18);
|
|
33642
33775
|
return () => {
|
|
33643
33776
|
ignore = true;
|
|
33644
|
-
rl.input.removeListener("keypress",
|
|
33777
|
+
rl.input.removeListener("keypress", handler18);
|
|
33645
33778
|
};
|
|
33646
33779
|
}, []);
|
|
33647
33780
|
}
|
|
@@ -33800,16 +33933,16 @@ class Emitter {
|
|
|
33800
33933
|
|
|
33801
33934
|
class SignalExitBase {
|
|
33802
33935
|
}
|
|
33803
|
-
var signalExitWrap = (
|
|
33936
|
+
var signalExitWrap = (handler18) => {
|
|
33804
33937
|
return {
|
|
33805
33938
|
onExit(cb, opts) {
|
|
33806
|
-
return
|
|
33939
|
+
return handler18.onExit(cb, opts);
|
|
33807
33940
|
},
|
|
33808
33941
|
load() {
|
|
33809
|
-
return
|
|
33942
|
+
return handler18.load();
|
|
33810
33943
|
},
|
|
33811
33944
|
unload() {
|
|
33812
|
-
return
|
|
33945
|
+
return handler18.unload();
|
|
33813
33946
|
}
|
|
33814
33947
|
};
|
|
33815
33948
|
};
|
|
@@ -34607,36 +34740,147 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
34607
34740
|
}
|
|
34608
34741
|
|
|
34609
34742
|
// src/provider.ts
|
|
34743
|
+
class InMemoryStore {
|
|
34744
|
+
#data;
|
|
34745
|
+
async read() {
|
|
34746
|
+
return this.#data;
|
|
34747
|
+
}
|
|
34748
|
+
async write(data) {
|
|
34749
|
+
this.#data = data;
|
|
34750
|
+
}
|
|
34751
|
+
}
|
|
34610
34752
|
var getProvider = (options = {}) => {
|
|
34611
34753
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
34612
|
-
const memoryStore =
|
|
34754
|
+
const memoryStore = options.memoryStore ?? new InMemoryStore;
|
|
34755
|
+
const todoItemStore = options.todoItemStore ?? new InMemoryStore;
|
|
34613
34756
|
const defaultMemoryTopic = ":default:";
|
|
34614
34757
|
const provider2 = {
|
|
34758
|
+
listTodoItems: async (id, status) => {
|
|
34759
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
34760
|
+
let items;
|
|
34761
|
+
if (!id) {
|
|
34762
|
+
items = todoItems.filter((i) => !i.id.includes("."));
|
|
34763
|
+
} else {
|
|
34764
|
+
const parent = todoItems.find((i) => i.id === id);
|
|
34765
|
+
if (!parent) {
|
|
34766
|
+
throw new Error(`To-do item with id ${id} not found`);
|
|
34767
|
+
}
|
|
34768
|
+
items = todoItems.filter((i) => i.id.startsWith(`${id}.`) && i.id.split(".").length === id.split(".").length + 1);
|
|
34769
|
+
}
|
|
34770
|
+
if (status) {
|
|
34771
|
+
items = items.filter((item) => item.status === status);
|
|
34772
|
+
}
|
|
34773
|
+
items.sort((a, b) => {
|
|
34774
|
+
const aParts = a.id.split(".");
|
|
34775
|
+
const bParts = b.id.split(".");
|
|
34776
|
+
const len = Math.min(aParts.length, bParts.length);
|
|
34777
|
+
for (let i = 0;i < len; i++) {
|
|
34778
|
+
const comparison = aParts[i].localeCompare(bParts[i], undefined, { numeric: true });
|
|
34779
|
+
if (comparison !== 0) {
|
|
34780
|
+
return comparison;
|
|
34781
|
+
}
|
|
34782
|
+
}
|
|
34783
|
+
return aParts.length - bParts.length;
|
|
34784
|
+
});
|
|
34785
|
+
return items;
|
|
34786
|
+
},
|
|
34787
|
+
getTodoItem: async (id) => {
|
|
34788
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
34789
|
+
const item = todoItems.find((i) => i.id === id);
|
|
34790
|
+
if (!item) {
|
|
34791
|
+
throw new Error(`To-do item with id ${id} not found`);
|
|
34792
|
+
}
|
|
34793
|
+
const subItems = todoItems.filter((i) => i.id.startsWith(`${id}.`) && i.id.split(".").length === id.split(".").length + 1).map(({ id: id2, title }) => ({ id: id2, title }));
|
|
34794
|
+
return { ...item, subItems };
|
|
34795
|
+
},
|
|
34796
|
+
updateTodoItem: async (input) => {
|
|
34797
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
34798
|
+
if (input.operation === "add") {
|
|
34799
|
+
const { parentId, title, description, status } = input;
|
|
34800
|
+
if (!title) {
|
|
34801
|
+
throw new Error("Title is required for add operation");
|
|
34802
|
+
}
|
|
34803
|
+
let newId;
|
|
34804
|
+
if (parentId) {
|
|
34805
|
+
const parent = todoItems.find((i) => i.id === parentId);
|
|
34806
|
+
if (!parent) {
|
|
34807
|
+
throw new Error(`Parent to-do item with id ${parentId} not found`);
|
|
34808
|
+
}
|
|
34809
|
+
const childItems = todoItems.filter((i) => i.id.startsWith(`${parentId}.`) && i.id.split(".").length === parentId.split(".").length + 1);
|
|
34810
|
+
const maxId = childItems.reduce((max, item) => {
|
|
34811
|
+
const parts = item.id.split(".");
|
|
34812
|
+
const lastPart = parseInt(parts[parts.length - 1], 10);
|
|
34813
|
+
return Math.max(max, lastPart);
|
|
34814
|
+
}, 0);
|
|
34815
|
+
newId = `${parentId}.${maxId + 1}`;
|
|
34816
|
+
} else {
|
|
34817
|
+
const rootItems = todoItems.filter((i) => !i.id.includes("."));
|
|
34818
|
+
const maxId = rootItems.reduce((max, item) => {
|
|
34819
|
+
const idNum = parseInt(item.id, 10);
|
|
34820
|
+
return Math.max(max, idNum);
|
|
34821
|
+
}, 0);
|
|
34822
|
+
newId = `${maxId + 1}`;
|
|
34823
|
+
}
|
|
34824
|
+
const newItem = {
|
|
34825
|
+
id: newId,
|
|
34826
|
+
title,
|
|
34827
|
+
description: description ?? "",
|
|
34828
|
+
status: status ?? "open"
|
|
34829
|
+
};
|
|
34830
|
+
await todoItemStore.write([...todoItems, newItem]);
|
|
34831
|
+
return { id: newId };
|
|
34832
|
+
} else {
|
|
34833
|
+
const { id } = input;
|
|
34834
|
+
if (!id) {
|
|
34835
|
+
throw new Error("ID is required for update operation");
|
|
34836
|
+
}
|
|
34837
|
+
const item = todoItems.find((i) => i.id === id);
|
|
34838
|
+
if (!item) {
|
|
34839
|
+
throw new Error(`To-do item with id ${id} not found`);
|
|
34840
|
+
}
|
|
34841
|
+
if (input.title != null) {
|
|
34842
|
+
item.title = input.title;
|
|
34843
|
+
}
|
|
34844
|
+
if (input.description != null) {
|
|
34845
|
+
item.description = input.description ?? "";
|
|
34846
|
+
}
|
|
34847
|
+
if (input.status != null) {
|
|
34848
|
+
item.status = input.status;
|
|
34849
|
+
}
|
|
34850
|
+
await todoItemStore.write(todoItems);
|
|
34851
|
+
return { id };
|
|
34852
|
+
}
|
|
34853
|
+
},
|
|
34615
34854
|
listMemoryTopics: async () => {
|
|
34616
|
-
|
|
34855
|
+
const memory = await memoryStore.read() ?? {};
|
|
34856
|
+
return Object.keys(memory);
|
|
34617
34857
|
},
|
|
34618
34858
|
readMemory: async (topic = defaultMemoryTopic) => {
|
|
34619
|
-
|
|
34859
|
+
const memory = await memoryStore.read() ?? {};
|
|
34860
|
+
return memory[topic];
|
|
34620
34861
|
},
|
|
34621
34862
|
updateMemory: async (operation, topic, content) => {
|
|
34622
34863
|
const memoryTopic = topic ?? defaultMemoryTopic;
|
|
34864
|
+
const memory = await memoryStore.read() ?? {};
|
|
34623
34865
|
switch (operation) {
|
|
34624
34866
|
case "append":
|
|
34625
34867
|
if (content === undefined) {
|
|
34626
34868
|
throw new Error("Content is required for append operation.");
|
|
34627
34869
|
}
|
|
34628
|
-
|
|
34870
|
+
memory[memoryTopic] = `${memory[memoryTopic] || ""}
|
|
34871
|
+
${content}`;
|
|
34629
34872
|
break;
|
|
34630
34873
|
case "replace":
|
|
34631
34874
|
if (content === undefined) {
|
|
34632
34875
|
throw new Error("Content is required for replace operation.");
|
|
34633
34876
|
}
|
|
34634
|
-
|
|
34877
|
+
memory[memoryTopic] = content;
|
|
34635
34878
|
break;
|
|
34636
34879
|
case "remove":
|
|
34637
|
-
delete
|
|
34880
|
+
delete memory[memoryTopic];
|
|
34638
34881
|
break;
|
|
34639
34882
|
}
|
|
34883
|
+
await memoryStore.write(memory);
|
|
34640
34884
|
},
|
|
34641
34885
|
readFile: async (path, includeIgnored) => {
|
|
34642
34886
|
if (!includeIgnored && ig.ignores(path)) {
|
|
@@ -35275,6 +35519,53 @@ var chalk = createChalk();
|
|
|
35275
35519
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
35276
35520
|
var source_default = chalk;
|
|
35277
35521
|
|
|
35522
|
+
// src/utils/parameterSimplifier.ts
|
|
35523
|
+
function replaceInFileSimplifier(params) {
|
|
35524
|
+
return { path: params.path };
|
|
35525
|
+
}
|
|
35526
|
+
function writeToFileSimplifier(params) {
|
|
35527
|
+
return { path: params.path };
|
|
35528
|
+
}
|
|
35529
|
+
function readFileSimplifier(params) {
|
|
35530
|
+
return { path: params.path, includeIgnored: params.includeIgnored };
|
|
35531
|
+
}
|
|
35532
|
+
function listFilesSimplifier(params) {
|
|
35533
|
+
const maxCount = params.maxCount;
|
|
35534
|
+
return {
|
|
35535
|
+
path: params.path,
|
|
35536
|
+
recursive: params.recursive,
|
|
35537
|
+
...maxCount !== 2000 && { maxCount }
|
|
35538
|
+
};
|
|
35539
|
+
}
|
|
35540
|
+
function searchFilesSimplifier(params) {
|
|
35541
|
+
return { ...params };
|
|
35542
|
+
}
|
|
35543
|
+
function executeCommandSimplifier(params) {
|
|
35544
|
+
return { command: params.command, requiresApproval: params.requiresApproval };
|
|
35545
|
+
}
|
|
35546
|
+
function updateMemorySimplifier(params) {
|
|
35547
|
+
return { operation: params.operation, topic: params.topic };
|
|
35548
|
+
}
|
|
35549
|
+
var SIMPLIFIERS = {
|
|
35550
|
+
replaceInFile: replaceInFileSimplifier,
|
|
35551
|
+
writeToFile: writeToFileSimplifier,
|
|
35552
|
+
readFile: readFileSimplifier,
|
|
35553
|
+
listFiles: listFilesSimplifier,
|
|
35554
|
+
searchFiles: searchFilesSimplifier,
|
|
35555
|
+
executeCommand: executeCommandSimplifier,
|
|
35556
|
+
updateMemory: updateMemorySimplifier
|
|
35557
|
+
};
|
|
35558
|
+
function simplifyToolParameters(toolName, params) {
|
|
35559
|
+
if (params === undefined || params === null) {
|
|
35560
|
+
return {};
|
|
35561
|
+
}
|
|
35562
|
+
const simplifier = SIMPLIFIERS[toolName];
|
|
35563
|
+
if (simplifier) {
|
|
35564
|
+
return simplifier(params);
|
|
35565
|
+
}
|
|
35566
|
+
return { ...params };
|
|
35567
|
+
}
|
|
35568
|
+
|
|
35278
35569
|
// src/utils/eventHandler.ts
|
|
35279
35570
|
var taskToolCallStats = new Map;
|
|
35280
35571
|
var globalToolCallStats = new Map;
|
|
@@ -35299,8 +35590,26 @@ function logToolCallStats(stream, statsMap, title) {
|
|
|
35299
35590
|
customConsole.log("No tools were called.");
|
|
35300
35591
|
}
|
|
35301
35592
|
}
|
|
35593
|
+
var mergeToolCallStats = (a, b) => {
|
|
35594
|
+
const merged = new Map;
|
|
35595
|
+
for (const [tool2, stat] of a) {
|
|
35596
|
+
merged.set(tool2, { ...stat });
|
|
35597
|
+
}
|
|
35598
|
+
for (const [tool2, stat] of b) {
|
|
35599
|
+
const existing = merged.get(tool2);
|
|
35600
|
+
if (existing) {
|
|
35601
|
+
existing.calls += stat.calls;
|
|
35602
|
+
existing.success += stat.success;
|
|
35603
|
+
existing.errors += stat.errors;
|
|
35604
|
+
} else {
|
|
35605
|
+
merged.set(tool2, { ...stat });
|
|
35606
|
+
}
|
|
35607
|
+
}
|
|
35608
|
+
return merged;
|
|
35609
|
+
};
|
|
35302
35610
|
function logGlobalToolCallStats(stream) {
|
|
35303
|
-
|
|
35611
|
+
const merged = mergeToolCallStats(globalToolCallStats, taskToolCallStats);
|
|
35612
|
+
logToolCallStats(stream, merged, "Global Tool Call Stats");
|
|
35304
35613
|
}
|
|
35305
35614
|
var printEvent = (verbose, usageMeter, stream = process.stdout) => {
|
|
35306
35615
|
if (verbose < 0) {
|
|
@@ -35308,6 +35617,7 @@ var printEvent = (verbose, usageMeter, stream = process.stdout) => {
|
|
|
35308
35617
|
}
|
|
35309
35618
|
const customConsole = new Console(stream, stream);
|
|
35310
35619
|
let hadReasoning = false;
|
|
35620
|
+
let hasText = false;
|
|
35311
35621
|
const write = stream.write.bind(stream);
|
|
35312
35622
|
return (event) => {
|
|
35313
35623
|
switch (event.kind) {
|
|
@@ -35324,6 +35634,7 @@ ${event.systemPrompt}`);
|
|
|
35324
35634
|
}
|
|
35325
35635
|
break;
|
|
35326
35636
|
case "StartRequest" /* StartRequest */:
|
|
35637
|
+
hasText = false;
|
|
35327
35638
|
if (verbose > 0) {
|
|
35328
35639
|
customConsole.log(`
|
|
35329
35640
|
|
|
@@ -35377,6 +35688,11 @@ ${event.systemPrompt}`);
|
|
|
35377
35688
|
customConsole.log(`
|
|
35378
35689
|
|
|
35379
35690
|
======== Request Ended ========
|
|
35691
|
+
`);
|
|
35692
|
+
}
|
|
35693
|
+
if (verbose === 0 && hasText) {
|
|
35694
|
+
write(`
|
|
35695
|
+
|
|
35380
35696
|
`);
|
|
35381
35697
|
}
|
|
35382
35698
|
if (verbose > 1) {
|
|
@@ -35390,6 +35706,9 @@ ${event.systemPrompt}`);
|
|
|
35390
35706
|
`);
|
|
35391
35707
|
hadReasoning = false;
|
|
35392
35708
|
}
|
|
35709
|
+
if (event.newText.trim().length > 0) {
|
|
35710
|
+
hasText = true;
|
|
35711
|
+
}
|
|
35393
35712
|
write(event.newText);
|
|
35394
35713
|
break;
|
|
35395
35714
|
}
|
|
@@ -35402,9 +35721,10 @@ ${event.systemPrompt}`);
|
|
|
35402
35721
|
}
|
|
35403
35722
|
case "ToolUse" /* ToolUse */: {
|
|
35404
35723
|
if (verbose > 0) {
|
|
35724
|
+
const params = verbose > 1 ? event.params : simplifyToolParameters(event.tool, event.params);
|
|
35405
35725
|
customConsole.log(source_default.yellow(`
|
|
35406
35726
|
|
|
35407
|
-
Tool use:`, event.tool),
|
|
35727
|
+
Tool use:`, event.tool), params);
|
|
35408
35728
|
}
|
|
35409
35729
|
const stats = taskToolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
35410
35730
|
stats.calls++;
|
|
@@ -35440,18 +35760,28 @@ Tool error:`, event.tool));
|
|
|
35440
35760
|
`);
|
|
35441
35761
|
customConsole.log("Reason:", event.exitReason.type);
|
|
35442
35762
|
switch (event.exitReason.type) {
|
|
35763
|
+
case "Error": {
|
|
35764
|
+
const { error: error46 } = event.exitReason;
|
|
35765
|
+
customConsole.error(source_default.red(`Workflow failed: ${error46.message}`));
|
|
35766
|
+
if (verbose > 0 && error46.stack) {
|
|
35767
|
+
customConsole.error(source_default.red(error46.stack));
|
|
35768
|
+
}
|
|
35769
|
+
break;
|
|
35770
|
+
}
|
|
35443
35771
|
case "Exit" /* Exit */:
|
|
35444
|
-
|
|
35772
|
+
if (verbose > 0) {
|
|
35773
|
+
customConsole.log("Exit Message:", event.exitReason.message);
|
|
35774
|
+
}
|
|
35445
35775
|
break;
|
|
35446
35776
|
}
|
|
35777
|
+
for (const [tool2, taskStats] of taskToolCallStats.entries()) {
|
|
35778
|
+
const globalStats = globalToolCallStats.get(tool2) ?? { calls: 0, success: 0, errors: 0 };
|
|
35779
|
+
globalStats.calls += taskStats.calls;
|
|
35780
|
+
globalStats.success += taskStats.success;
|
|
35781
|
+
globalStats.errors += taskStats.errors;
|
|
35782
|
+
globalToolCallStats.set(tool2, globalStats);
|
|
35783
|
+
}
|
|
35447
35784
|
if (verbose > 0) {
|
|
35448
|
-
for (const [tool2, taskStats] of taskToolCallStats.entries()) {
|
|
35449
|
-
const globalStats = globalToolCallStats.get(tool2) ?? { calls: 0, success: 0, errors: 0 };
|
|
35450
|
-
globalStats.calls += taskStats.calls;
|
|
35451
|
-
globalStats.success += taskStats.success;
|
|
35452
|
-
globalStats.errors += taskStats.errors;
|
|
35453
|
-
globalToolCallStats.set(tool2, globalStats);
|
|
35454
|
-
}
|
|
35455
35785
|
logToolCallStats(stream, taskToolCallStats, "Task Tool Call Stats");
|
|
35456
35786
|
}
|
|
35457
35787
|
break;
|
|
@@ -35479,6 +35809,7 @@ function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
|
35479
35809
|
});
|
|
35480
35810
|
}
|
|
35481
35811
|
export {
|
|
35812
|
+
simplifyToolParameters,
|
|
35482
35813
|
searchFiles,
|
|
35483
35814
|
readMultiline,
|
|
35484
35815
|
readLocalConfig,
|
|
@@ -35494,5 +35825,6 @@ export {
|
|
|
35494
35825
|
getProvider,
|
|
35495
35826
|
getGlobalConfigPath,
|
|
35496
35827
|
configSchema,
|
|
35497
|
-
checkRipgrep
|
|
35828
|
+
checkRipgrep,
|
|
35829
|
+
InMemoryStore
|
|
35498
35830
|
};
|