@polka-codes/cli 0.9.47 → 0.9.48
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 +292 -256
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35579,7 +35579,7 @@ var {
|
|
|
35579
35579
|
Help
|
|
35580
35580
|
} = import__.default;
|
|
35581
35581
|
// package.json
|
|
35582
|
-
var version = "0.9.
|
|
35582
|
+
var version = "0.9.48";
|
|
35583
35583
|
|
|
35584
35584
|
// src/commands/code.ts
|
|
35585
35585
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
@@ -48216,36 +48216,12 @@ var configSchema = exports_external.object({
|
|
|
48216
48216
|
rules: exports_external.array(exports_external.string()).optional().or(exports_external.string()).optional(),
|
|
48217
48217
|
excludeFiles: exports_external.array(exports_external.string()).optional()
|
|
48218
48218
|
}).strict();
|
|
48219
|
-
// ../core/src/tools/appendMemory.ts
|
|
48220
|
-
var toolInfo = {
|
|
48221
|
-
name: "appendMemory",
|
|
48222
|
-
description: "Appends content to a memory topic.",
|
|
48223
|
-
parameters: exports_external.object({
|
|
48224
|
-
topic: exports_external.string().nullish().describe('The topic to append to in memory. Defaults to ":default:".'),
|
|
48225
|
-
content: exports_external.string().describe("The content to append.")
|
|
48226
|
-
})
|
|
48227
|
-
};
|
|
48228
|
-
var handler = async (provider, args) => {
|
|
48229
|
-
const { topic, content } = toolInfo.parameters.parse(args);
|
|
48230
|
-
await provider.appendMemory(topic ?? undefined, content);
|
|
48231
|
-
return {
|
|
48232
|
-
type: "Reply" /* Reply */,
|
|
48233
|
-
message: {
|
|
48234
|
-
type: "text",
|
|
48235
|
-
value: `Content appended to memory topic '${topic || ""}'.`
|
|
48236
|
-
}
|
|
48237
|
-
};
|
|
48238
|
-
};
|
|
48239
|
-
var appendMemory_default = {
|
|
48240
|
-
...toolInfo,
|
|
48241
|
-
handler
|
|
48242
|
-
};
|
|
48243
48219
|
// ../core/src/tools/askFollowupQuestion.ts
|
|
48244
48220
|
var questionObject = exports_external.object({
|
|
48245
48221
|
prompt: exports_external.string().describe("The text of the question.").meta({ usageValue: "question text here" }),
|
|
48246
48222
|
options: exports_external.array(exports_external.string()).default([]).describe("Ordered list of suggested answers (omit if none).").meta({ usageValue: "suggested answer here" })
|
|
48247
48223
|
});
|
|
48248
|
-
var
|
|
48224
|
+
var toolInfo = {
|
|
48249
48225
|
name: "askFollowupQuestion",
|
|
48250
48226
|
description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
|
|
48251
48227
|
parameters: exports_external.object({
|
|
@@ -48295,7 +48271,7 @@ var toolInfo2 = {
|
|
|
48295
48271
|
]
|
|
48296
48272
|
})
|
|
48297
48273
|
};
|
|
48298
|
-
var
|
|
48274
|
+
var handler = async (provider, args) => {
|
|
48299
48275
|
if (!provider.askFollowupQuestion) {
|
|
48300
48276
|
return {
|
|
48301
48277
|
type: "Error" /* Error */,
|
|
@@ -48305,7 +48281,7 @@ var handler2 = async (provider, args) => {
|
|
|
48305
48281
|
}
|
|
48306
48282
|
};
|
|
48307
48283
|
}
|
|
48308
|
-
const { questions } =
|
|
48284
|
+
const { questions } = toolInfo.parameters.parse(args);
|
|
48309
48285
|
if (questions.length === 0) {
|
|
48310
48286
|
return {
|
|
48311
48287
|
type: "Error" /* Error */,
|
|
@@ -48333,11 +48309,11 @@ ${answer}
|
|
|
48333
48309
|
};
|
|
48334
48310
|
};
|
|
48335
48311
|
var askFollowupQuestion_default = {
|
|
48336
|
-
...
|
|
48337
|
-
handler
|
|
48312
|
+
...toolInfo,
|
|
48313
|
+
handler
|
|
48338
48314
|
};
|
|
48339
48315
|
// ../core/src/tools/executeCommand.ts
|
|
48340
|
-
var
|
|
48316
|
+
var toolInfo2 = {
|
|
48341
48317
|
name: "executeCommand",
|
|
48342
48318
|
description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. **IMPORTANT**: After an `execute_command` call, you MUST stop and NOT allowed to make further tool calls in the same message.",
|
|
48343
48319
|
parameters: exports_external.object({
|
|
@@ -48364,7 +48340,7 @@ var toolInfo3 = {
|
|
|
48364
48340
|
]
|
|
48365
48341
|
})
|
|
48366
48342
|
};
|
|
48367
|
-
var
|
|
48343
|
+
var handler2 = async (provider, args) => {
|
|
48368
48344
|
if (!provider.executeCommand) {
|
|
48369
48345
|
return {
|
|
48370
48346
|
type: "Error" /* Error */,
|
|
@@ -48374,7 +48350,7 @@ var handler3 = async (provider, args) => {
|
|
|
48374
48350
|
}
|
|
48375
48351
|
};
|
|
48376
48352
|
}
|
|
48377
|
-
const { command, requiresApproval } =
|
|
48353
|
+
const { command, requiresApproval } = toolInfo2.parameters.parse(args);
|
|
48378
48354
|
try {
|
|
48379
48355
|
const result = await provider.executeCommand(command, requiresApproval);
|
|
48380
48356
|
let message = `<command>${command}</command>
|
|
@@ -48421,11 +48397,11 @@ ${result.stderr}
|
|
|
48421
48397
|
}
|
|
48422
48398
|
};
|
|
48423
48399
|
var executeCommand_default = {
|
|
48424
|
-
...
|
|
48425
|
-
handler:
|
|
48400
|
+
...toolInfo2,
|
|
48401
|
+
handler: handler2
|
|
48426
48402
|
};
|
|
48427
48403
|
// ../core/src/tools/fetchUrl.ts
|
|
48428
|
-
var
|
|
48404
|
+
var toolInfo3 = {
|
|
48429
48405
|
name: "fetchUrl",
|
|
48430
48406
|
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.",
|
|
48431
48407
|
parameters: exports_external.object({
|
|
@@ -48458,7 +48434,7 @@ var toolInfo4 = {
|
|
|
48458
48434
|
]
|
|
48459
48435
|
})
|
|
48460
48436
|
};
|
|
48461
|
-
var
|
|
48437
|
+
var handler3 = async (provider, args) => {
|
|
48462
48438
|
if (!provider.fetchUrl) {
|
|
48463
48439
|
return {
|
|
48464
48440
|
type: "Error" /* Error */,
|
|
@@ -48468,7 +48444,7 @@ var handler4 = async (provider, args) => {
|
|
|
48468
48444
|
}
|
|
48469
48445
|
};
|
|
48470
48446
|
}
|
|
48471
|
-
const { url: urls } =
|
|
48447
|
+
const { url: urls } = toolInfo3.parameters.parse(args);
|
|
48472
48448
|
if (urls.length === 0) {
|
|
48473
48449
|
return {
|
|
48474
48450
|
type: "Error" /* Error */,
|
|
@@ -48499,11 +48475,11 @@ var handler4 = async (provider, args) => {
|
|
|
48499
48475
|
};
|
|
48500
48476
|
};
|
|
48501
48477
|
var fetchUrl_default = {
|
|
48502
|
-
...
|
|
48503
|
-
handler:
|
|
48478
|
+
...toolInfo3,
|
|
48479
|
+
handler: handler3
|
|
48504
48480
|
};
|
|
48505
48481
|
// ../core/src/tools/listFiles.ts
|
|
48506
|
-
var
|
|
48482
|
+
var toolInfo4 = {
|
|
48507
48483
|
name: "listFiles",
|
|
48508
48484
|
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.",
|
|
48509
48485
|
parameters: exports_external.object({
|
|
@@ -48541,7 +48517,7 @@ var toolInfo5 = {
|
|
|
48541
48517
|
]
|
|
48542
48518
|
})
|
|
48543
48519
|
};
|
|
48544
|
-
var
|
|
48520
|
+
var handler4 = async (provider, args) => {
|
|
48545
48521
|
if (!provider.listFiles) {
|
|
48546
48522
|
return {
|
|
48547
48523
|
type: "Error" /* Error */,
|
|
@@ -48551,7 +48527,7 @@ var handler5 = async (provider, args) => {
|
|
|
48551
48527
|
}
|
|
48552
48528
|
};
|
|
48553
48529
|
}
|
|
48554
|
-
const { path, maxCount, recursive, includeIgnored } =
|
|
48530
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo4.parameters.parse(args);
|
|
48555
48531
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
48556
48532
|
return {
|
|
48557
48533
|
type: "Reply" /* Reply */,
|
|
@@ -48567,16 +48543,16 @@ ${files.join(`
|
|
|
48567
48543
|
};
|
|
48568
48544
|
};
|
|
48569
48545
|
var listFiles_default = {
|
|
48570
|
-
...
|
|
48571
|
-
handler:
|
|
48546
|
+
...toolInfo4,
|
|
48547
|
+
handler: handler4
|
|
48572
48548
|
};
|
|
48573
48549
|
// ../core/src/tools/listMemoryTopics.ts
|
|
48574
|
-
var
|
|
48550
|
+
var toolInfo5 = {
|
|
48575
48551
|
name: "listMemoryTopics",
|
|
48576
48552
|
description: "Lists all topics in memory.",
|
|
48577
48553
|
parameters: exports_external.object({})
|
|
48578
48554
|
};
|
|
48579
|
-
var
|
|
48555
|
+
var handler5 = async (provider, _args) => {
|
|
48580
48556
|
const topics = await provider.listMemoryTopics();
|
|
48581
48557
|
if (!topics.length) {
|
|
48582
48558
|
return { type: "Reply" /* Reply */, message: { type: "text", value: "No topics found." } };
|
|
@@ -48592,18 +48568,18 @@ ${topics.join(`
|
|
|
48592
48568
|
};
|
|
48593
48569
|
};
|
|
48594
48570
|
var listMemoryTopics_default = {
|
|
48595
|
-
...
|
|
48596
|
-
handler:
|
|
48571
|
+
...toolInfo5,
|
|
48572
|
+
handler: handler5
|
|
48597
48573
|
};
|
|
48598
48574
|
// ../core/src/tools/readBinaryFile.ts
|
|
48599
|
-
var
|
|
48575
|
+
var toolInfo6 = {
|
|
48600
48576
|
name: "readBinaryFile",
|
|
48601
48577
|
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.",
|
|
48602
48578
|
parameters: exports_external.object({
|
|
48603
48579
|
url: exports_external.string().describe("The URL or local path of the file to read.")
|
|
48604
48580
|
})
|
|
48605
48581
|
};
|
|
48606
|
-
var
|
|
48582
|
+
var handler6 = async (provider, args) => {
|
|
48607
48583
|
if (!provider.readBinaryFile) {
|
|
48608
48584
|
return {
|
|
48609
48585
|
type: "Error" /* Error */,
|
|
@@ -48613,7 +48589,7 @@ var handler7 = async (provider, args) => {
|
|
|
48613
48589
|
}
|
|
48614
48590
|
};
|
|
48615
48591
|
}
|
|
48616
|
-
const { url: url2 } =
|
|
48592
|
+
const { url: url2 } = toolInfo6.parameters.parse(args);
|
|
48617
48593
|
try {
|
|
48618
48594
|
const filePart = await provider.readBinaryFile(url2);
|
|
48619
48595
|
return {
|
|
@@ -48642,11 +48618,11 @@ var handler7 = async (provider, args) => {
|
|
|
48642
48618
|
}
|
|
48643
48619
|
};
|
|
48644
48620
|
var readBinaryFile_default = {
|
|
48645
|
-
...
|
|
48646
|
-
handler:
|
|
48621
|
+
...toolInfo6,
|
|
48622
|
+
handler: handler6
|
|
48647
48623
|
};
|
|
48648
48624
|
// ../core/src/tools/readFile.ts
|
|
48649
|
-
var
|
|
48625
|
+
var toolInfo7 = {
|
|
48650
48626
|
name: "readFile",
|
|
48651
48627
|
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.",
|
|
48652
48628
|
parameters: exports_external.object({
|
|
@@ -48683,7 +48659,7 @@ var toolInfo8 = {
|
|
|
48683
48659
|
]
|
|
48684
48660
|
})
|
|
48685
48661
|
};
|
|
48686
|
-
var
|
|
48662
|
+
var handler7 = async (provider, args) => {
|
|
48687
48663
|
if (!provider.readFile) {
|
|
48688
48664
|
return {
|
|
48689
48665
|
type: "Error" /* Error */,
|
|
@@ -48693,7 +48669,7 @@ var handler8 = async (provider, args) => {
|
|
|
48693
48669
|
}
|
|
48694
48670
|
};
|
|
48695
48671
|
}
|
|
48696
|
-
const { path: paths, includeIgnored } =
|
|
48672
|
+
const { path: paths, includeIgnored } = toolInfo7.parameters.parse(args);
|
|
48697
48673
|
const resp = [];
|
|
48698
48674
|
for (const path of paths) {
|
|
48699
48675
|
const fileContent = await provider.readFile(path, includeIgnored);
|
|
@@ -48718,19 +48694,19 @@ var handler8 = async (provider, args) => {
|
|
|
48718
48694
|
};
|
|
48719
48695
|
};
|
|
48720
48696
|
var readFile_default = {
|
|
48721
|
-
...
|
|
48722
|
-
handler:
|
|
48697
|
+
...toolInfo7,
|
|
48698
|
+
handler: handler7
|
|
48723
48699
|
};
|
|
48724
48700
|
// ../core/src/tools/readMemory.ts
|
|
48725
|
-
var
|
|
48701
|
+
var toolInfo8 = {
|
|
48726
48702
|
name: "readMemory",
|
|
48727
48703
|
description: "Reads content from a memory topic.",
|
|
48728
48704
|
parameters: exports_external.object({
|
|
48729
48705
|
topic: exports_external.string().optional().describe('The topic to read from memory. Defaults to ":default:".')
|
|
48730
48706
|
})
|
|
48731
48707
|
};
|
|
48732
|
-
var
|
|
48733
|
-
const { topic } =
|
|
48708
|
+
var handler8 = async (provider, args) => {
|
|
48709
|
+
const { topic } = toolInfo8.parameters.parse(args);
|
|
48734
48710
|
const content = await provider.readMemory(topic);
|
|
48735
48711
|
if (content) {
|
|
48736
48712
|
return {
|
|
@@ -48752,11 +48728,11 @@ ${content}
|
|
|
48752
48728
|
};
|
|
48753
48729
|
};
|
|
48754
48730
|
var readMemory_default = {
|
|
48755
|
-
...
|
|
48756
|
-
handler:
|
|
48731
|
+
...toolInfo8,
|
|
48732
|
+
handler: handler8
|
|
48757
48733
|
};
|
|
48758
48734
|
// ../core/src/tools/removeFile.ts
|
|
48759
|
-
var
|
|
48735
|
+
var toolInfo9 = {
|
|
48760
48736
|
name: "removeFile",
|
|
48761
48737
|
description: "Request to remove a file at the specified path.",
|
|
48762
48738
|
parameters: exports_external.object({
|
|
@@ -48772,7 +48748,7 @@ var toolInfo10 = {
|
|
|
48772
48748
|
]
|
|
48773
48749
|
})
|
|
48774
48750
|
};
|
|
48775
|
-
var
|
|
48751
|
+
var handler9 = async (provider, args) => {
|
|
48776
48752
|
if (!provider.removeFile) {
|
|
48777
48753
|
return {
|
|
48778
48754
|
type: "Error" /* Error */,
|
|
@@ -48782,7 +48758,7 @@ var handler10 = async (provider, args) => {
|
|
|
48782
48758
|
}
|
|
48783
48759
|
};
|
|
48784
48760
|
}
|
|
48785
|
-
const parsed =
|
|
48761
|
+
const parsed = toolInfo9.parameters.safeParse(args);
|
|
48786
48762
|
if (!parsed.success) {
|
|
48787
48763
|
return {
|
|
48788
48764
|
type: "Error" /* Error */,
|
|
@@ -48803,34 +48779,11 @@ var handler10 = async (provider, args) => {
|
|
|
48803
48779
|
};
|
|
48804
48780
|
};
|
|
48805
48781
|
var removeFile_default = {
|
|
48806
|
-
...
|
|
48807
|
-
handler:
|
|
48808
|
-
};
|
|
48809
|
-
// ../core/src/tools/removeMemory.ts
|
|
48810
|
-
var toolInfo11 = {
|
|
48811
|
-
name: "removeMemory",
|
|
48812
|
-
description: "Removes a topic from memory.",
|
|
48813
|
-
parameters: exports_external.object({
|
|
48814
|
-
topic: exports_external.string().optional().describe('The topic to remove from memory. Defaults to ":default:".')
|
|
48815
|
-
})
|
|
48816
|
-
};
|
|
48817
|
-
var handler11 = async (provider, args) => {
|
|
48818
|
-
const { topic } = toolInfo11.parameters.parse(args);
|
|
48819
|
-
await provider.removeMemory(topic);
|
|
48820
|
-
return {
|
|
48821
|
-
type: "Reply" /* Reply */,
|
|
48822
|
-
message: {
|
|
48823
|
-
type: "text",
|
|
48824
|
-
value: `Memory topic '${topic || ""}' removed.`
|
|
48825
|
-
}
|
|
48826
|
-
};
|
|
48827
|
-
};
|
|
48828
|
-
var removeMemory_default = {
|
|
48829
|
-
...toolInfo11,
|
|
48830
|
-
handler: handler11
|
|
48782
|
+
...toolInfo9,
|
|
48783
|
+
handler: handler9
|
|
48831
48784
|
};
|
|
48832
48785
|
// ../core/src/tools/renameFile.ts
|
|
48833
|
-
var
|
|
48786
|
+
var toolInfo10 = {
|
|
48834
48787
|
name: "renameFile",
|
|
48835
48788
|
description: "Request to rename a file from source path to target path.",
|
|
48836
48789
|
parameters: exports_external.object({
|
|
@@ -48848,7 +48801,7 @@ var toolInfo12 = {
|
|
|
48848
48801
|
]
|
|
48849
48802
|
})
|
|
48850
48803
|
};
|
|
48851
|
-
var
|
|
48804
|
+
var handler10 = async (provider, args) => {
|
|
48852
48805
|
if (!provider.renameFile) {
|
|
48853
48806
|
return {
|
|
48854
48807
|
type: "Error" /* Error */,
|
|
@@ -48858,7 +48811,7 @@ var handler12 = async (provider, args) => {
|
|
|
48858
48811
|
}
|
|
48859
48812
|
};
|
|
48860
48813
|
}
|
|
48861
|
-
const { source_path, target_path } =
|
|
48814
|
+
const { source_path, target_path } = toolInfo10.parameters.parse(args);
|
|
48862
48815
|
await provider.renameFile(source_path, target_path);
|
|
48863
48816
|
return {
|
|
48864
48817
|
type: "Reply" /* Reply */,
|
|
@@ -48869,8 +48822,8 @@ var handler12 = async (provider, args) => {
|
|
|
48869
48822
|
};
|
|
48870
48823
|
};
|
|
48871
48824
|
var renameFile_default = {
|
|
48872
|
-
...
|
|
48873
|
-
handler:
|
|
48825
|
+
...toolInfo10,
|
|
48826
|
+
handler: handler10
|
|
48874
48827
|
};
|
|
48875
48828
|
// ../core/src/tools/utils/replaceInFile.ts
|
|
48876
48829
|
var replaceInFile = (fileContent, diff) => {
|
|
@@ -48947,7 +48900,7 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
48947
48900
|
};
|
|
48948
48901
|
|
|
48949
48902
|
// ../core/src/tools/replaceInFile.ts
|
|
48950
|
-
var
|
|
48903
|
+
var toolInfo11 = {
|
|
48951
48904
|
name: "replaceInFile",
|
|
48952
48905
|
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.",
|
|
48953
48906
|
parameters: exports_external.object({
|
|
@@ -49057,7 +49010,7 @@ function oldFeature() {
|
|
|
49057
49010
|
]
|
|
49058
49011
|
})
|
|
49059
49012
|
};
|
|
49060
|
-
var
|
|
49013
|
+
var handler11 = async (provider, args) => {
|
|
49061
49014
|
if (!provider.readFile || !provider.writeFile) {
|
|
49062
49015
|
return {
|
|
49063
49016
|
type: "Error" /* Error */,
|
|
@@ -49067,7 +49020,7 @@ var handler13 = async (provider, args) => {
|
|
|
49067
49020
|
}
|
|
49068
49021
|
};
|
|
49069
49022
|
}
|
|
49070
|
-
const parsed =
|
|
49023
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
49071
49024
|
if (!parsed.success) {
|
|
49072
49025
|
return {
|
|
49073
49026
|
type: "Error" /* Error */,
|
|
@@ -49131,35 +49084,11 @@ var handler13 = async (provider, args) => {
|
|
|
49131
49084
|
}
|
|
49132
49085
|
};
|
|
49133
49086
|
var replaceInFile_default = {
|
|
49134
|
-
...
|
|
49135
|
-
handler:
|
|
49136
|
-
};
|
|
49137
|
-
// ../core/src/tools/replaceMemory.ts
|
|
49138
|
-
var toolInfo14 = {
|
|
49139
|
-
name: "replaceMemory",
|
|
49140
|
-
description: "Replaces content of a memory topic.",
|
|
49141
|
-
parameters: exports_external.object({
|
|
49142
|
-
topic: exports_external.string().optional().describe('The topic to replace in memory. Defaults to ":default:".'),
|
|
49143
|
-
content: exports_external.string().describe("The new content.")
|
|
49144
|
-
})
|
|
49145
|
-
};
|
|
49146
|
-
var handler14 = async (provider, args) => {
|
|
49147
|
-
const { topic, content } = toolInfo14.parameters.parse(args);
|
|
49148
|
-
await provider.replaceMemory(topic, content);
|
|
49149
|
-
return {
|
|
49150
|
-
type: "Reply" /* Reply */,
|
|
49151
|
-
message: {
|
|
49152
|
-
type: "text",
|
|
49153
|
-
value: `Memory topic '${topic || ""}' replaced.`
|
|
49154
|
-
}
|
|
49155
|
-
};
|
|
49156
|
-
};
|
|
49157
|
-
var replaceMemory_default = {
|
|
49158
|
-
...toolInfo14,
|
|
49159
|
-
handler: handler14
|
|
49087
|
+
...toolInfo11,
|
|
49088
|
+
handler: handler11
|
|
49160
49089
|
};
|
|
49161
49090
|
// ../core/src/tools/searchFiles.ts
|
|
49162
|
-
var
|
|
49091
|
+
var toolInfo12 = {
|
|
49163
49092
|
name: "searchFiles",
|
|
49164
49093
|
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.",
|
|
49165
49094
|
parameters: exports_external.object({
|
|
@@ -49183,7 +49112,7 @@ var toolInfo15 = {
|
|
|
49183
49112
|
]
|
|
49184
49113
|
})
|
|
49185
49114
|
};
|
|
49186
|
-
var
|
|
49115
|
+
var handler12 = async (provider, args) => {
|
|
49187
49116
|
if (!provider.searchFiles) {
|
|
49188
49117
|
return {
|
|
49189
49118
|
type: "Error" /* Error */,
|
|
@@ -49193,7 +49122,7 @@ var handler15 = async (provider, args) => {
|
|
|
49193
49122
|
}
|
|
49194
49123
|
};
|
|
49195
49124
|
}
|
|
49196
|
-
const parsed =
|
|
49125
|
+
const parsed = toolInfo12.parameters.safeParse(args);
|
|
49197
49126
|
if (!parsed.success) {
|
|
49198
49127
|
return {
|
|
49199
49128
|
type: "Error" /* Error */,
|
|
@@ -49231,11 +49160,82 @@ ${files.join(`
|
|
|
49231
49160
|
}
|
|
49232
49161
|
};
|
|
49233
49162
|
var searchFiles_default = {
|
|
49234
|
-
...
|
|
49235
|
-
handler:
|
|
49163
|
+
...toolInfo12,
|
|
49164
|
+
handler: handler12
|
|
49165
|
+
};
|
|
49166
|
+
// ../core/src/tools/updateMemory.ts
|
|
49167
|
+
var toolInfo13 = {
|
|
49168
|
+
name: "updateMemory",
|
|
49169
|
+
description: "Appends, replaces, or removes content from a memory topic.",
|
|
49170
|
+
parameters: exports_external.object({
|
|
49171
|
+
operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
49172
|
+
topic: exports_external.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
49173
|
+
content: exports_external.string().optional().describe("The content for append or replace operations. Must be omitted for remove operation.")
|
|
49174
|
+
}).superRefine((data, ctx) => {
|
|
49175
|
+
if (data.operation === "append" || data.operation === "replace") {
|
|
49176
|
+
if (data.content === undefined) {
|
|
49177
|
+
ctx.addIssue({
|
|
49178
|
+
code: "custom",
|
|
49179
|
+
message: 'Content is required for "append" and "replace" operations.',
|
|
49180
|
+
path: ["content"]
|
|
49181
|
+
});
|
|
49182
|
+
}
|
|
49183
|
+
} else if (data.operation === "remove") {
|
|
49184
|
+
if (data.content !== undefined) {
|
|
49185
|
+
ctx.addIssue({
|
|
49186
|
+
code: "custom",
|
|
49187
|
+
message: 'Content must not be provided for "remove" operation.',
|
|
49188
|
+
path: ["content"]
|
|
49189
|
+
});
|
|
49190
|
+
}
|
|
49191
|
+
}
|
|
49192
|
+
})
|
|
49193
|
+
};
|
|
49194
|
+
var handler13 = async (provider, args) => {
|
|
49195
|
+
if (!provider.updateMemory) {
|
|
49196
|
+
return {
|
|
49197
|
+
type: "Error" /* Error */,
|
|
49198
|
+
message: {
|
|
49199
|
+
type: "error-text",
|
|
49200
|
+
value: "Memory operations are not supported by the current provider."
|
|
49201
|
+
}
|
|
49202
|
+
};
|
|
49203
|
+
}
|
|
49204
|
+
const params = toolInfo13.parameters.parse(args);
|
|
49205
|
+
await provider.updateMemory(params.operation, params.topic ?? undefined, "content" in params ? params.content : undefined);
|
|
49206
|
+
switch (params.operation) {
|
|
49207
|
+
case "append":
|
|
49208
|
+
return {
|
|
49209
|
+
type: "Reply" /* Reply */,
|
|
49210
|
+
message: {
|
|
49211
|
+
type: "text",
|
|
49212
|
+
value: `Content appended to memory topic '${params.topic || ":default:"}'.`
|
|
49213
|
+
}
|
|
49214
|
+
};
|
|
49215
|
+
case "replace":
|
|
49216
|
+
return {
|
|
49217
|
+
type: "Reply" /* Reply */,
|
|
49218
|
+
message: {
|
|
49219
|
+
type: "text",
|
|
49220
|
+
value: `Memory topic '${params.topic || ":default:"}' replaced.`
|
|
49221
|
+
}
|
|
49222
|
+
};
|
|
49223
|
+
case "remove":
|
|
49224
|
+
return {
|
|
49225
|
+
type: "Reply" /* Reply */,
|
|
49226
|
+
message: {
|
|
49227
|
+
type: "text",
|
|
49228
|
+
value: `Memory topic '${params.topic || ":default:"}' removed.`
|
|
49229
|
+
}
|
|
49230
|
+
};
|
|
49231
|
+
}
|
|
49232
|
+
};
|
|
49233
|
+
var updateMemory_default = {
|
|
49234
|
+
...toolInfo13,
|
|
49235
|
+
handler: handler13
|
|
49236
49236
|
};
|
|
49237
49237
|
// ../core/src/tools/writeToFile.ts
|
|
49238
|
-
var
|
|
49238
|
+
var toolInfo14 = {
|
|
49239
49239
|
name: "writeToFile",
|
|
49240
49240
|
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.",
|
|
49241
49241
|
parameters: exports_external.object({
|
|
@@ -49264,7 +49264,7 @@ export default App;
|
|
|
49264
49264
|
]
|
|
49265
49265
|
})
|
|
49266
49266
|
};
|
|
49267
|
-
var
|
|
49267
|
+
var handler14 = async (provider, args) => {
|
|
49268
49268
|
if (!provider.writeFile) {
|
|
49269
49269
|
return {
|
|
49270
49270
|
type: "Error" /* Error */,
|
|
@@ -49274,7 +49274,7 @@ var handler16 = async (provider, args) => {
|
|
|
49274
49274
|
}
|
|
49275
49275
|
};
|
|
49276
49276
|
}
|
|
49277
|
-
const parsed =
|
|
49277
|
+
const parsed = toolInfo14.parameters.safeParse(args);
|
|
49278
49278
|
if (!parsed.success) {
|
|
49279
49279
|
return {
|
|
49280
49280
|
type: "Error" /* Error */,
|
|
@@ -49298,8 +49298,8 @@ var handler16 = async (provider, args) => {
|
|
|
49298
49298
|
};
|
|
49299
49299
|
};
|
|
49300
49300
|
var writeToFile_default = {
|
|
49301
|
-
...
|
|
49302
|
-
handler:
|
|
49301
|
+
...toolInfo14,
|
|
49302
|
+
handler: handler14
|
|
49303
49303
|
};
|
|
49304
49304
|
// ../core/src/UsageMeter.ts
|
|
49305
49305
|
class UsageMeter {
|
|
@@ -51340,15 +51340,15 @@ function useKeypress(userHandler) {
|
|
|
51340
51340
|
signal.current = userHandler;
|
|
51341
51341
|
useEffect((rl) => {
|
|
51342
51342
|
let ignore = false;
|
|
51343
|
-
const
|
|
51343
|
+
const handler15 = withUpdates((_input, event) => {
|
|
51344
51344
|
if (ignore)
|
|
51345
51345
|
return;
|
|
51346
51346
|
signal.current(event, rl);
|
|
51347
51347
|
});
|
|
51348
|
-
rl.input.on("keypress",
|
|
51348
|
+
rl.input.on("keypress", handler15);
|
|
51349
51349
|
return () => {
|
|
51350
51350
|
ignore = true;
|
|
51351
|
-
rl.input.removeListener("keypress",
|
|
51351
|
+
rl.input.removeListener("keypress", handler15);
|
|
51352
51352
|
};
|
|
51353
51353
|
}, []);
|
|
51354
51354
|
}
|
|
@@ -51507,16 +51507,16 @@ class Emitter {
|
|
|
51507
51507
|
|
|
51508
51508
|
class SignalExitBase {
|
|
51509
51509
|
}
|
|
51510
|
-
var signalExitWrap = (
|
|
51510
|
+
var signalExitWrap = (handler15) => {
|
|
51511
51511
|
return {
|
|
51512
51512
|
onExit(cb, opts) {
|
|
51513
|
-
return
|
|
51513
|
+
return handler15.onExit(cb, opts);
|
|
51514
51514
|
},
|
|
51515
51515
|
load() {
|
|
51516
|
-
return
|
|
51516
|
+
return handler15.load();
|
|
51517
51517
|
},
|
|
51518
51518
|
unload() {
|
|
51519
|
-
return
|
|
51519
|
+
return handler15.unload();
|
|
51520
51520
|
}
|
|
51521
51521
|
};
|
|
51522
51522
|
};
|
|
@@ -52348,19 +52348,26 @@ var getProvider = (options = {}) => {
|
|
|
52348
52348
|
readMemory: async (topic = defaultMemoryTopic) => {
|
|
52349
52349
|
return memoryStore[topic];
|
|
52350
52350
|
},
|
|
52351
|
-
|
|
52352
|
-
|
|
52353
|
-
|
|
52354
|
-
|
|
52355
|
-
|
|
52351
|
+
updateMemory: async (operation, topic, content) => {
|
|
52352
|
+
const memoryTopic = topic ?? defaultMemoryTopic;
|
|
52353
|
+
switch (operation) {
|
|
52354
|
+
case "append":
|
|
52355
|
+
if (content === undefined) {
|
|
52356
|
+
throw new Error("Content is required for append operation.");
|
|
52357
|
+
}
|
|
52358
|
+
memoryStore[memoryTopic] = (memoryStore[memoryTopic] || "") + content;
|
|
52359
|
+
break;
|
|
52360
|
+
case "replace":
|
|
52361
|
+
if (content === undefined) {
|
|
52362
|
+
throw new Error("Content is required for replace operation.");
|
|
52363
|
+
}
|
|
52364
|
+
memoryStore[memoryTopic] = content;
|
|
52365
|
+
break;
|
|
52366
|
+
case "remove":
|
|
52367
|
+
delete memoryStore[memoryTopic];
|
|
52368
|
+
break;
|
|
52356
52369
|
}
|
|
52357
52370
|
},
|
|
52358
|
-
replaceMemory: async (topic = defaultMemoryTopic, content) => {
|
|
52359
|
-
memoryStore[topic] = content;
|
|
52360
|
-
},
|
|
52361
|
-
removeMemory: async (topic = defaultMemoryTopic) => {
|
|
52362
|
-
delete memoryStore[topic];
|
|
52363
|
-
},
|
|
52364
52371
|
readFile: async (path, includeIgnored) => {
|
|
52365
52372
|
if (!includeIgnored && ig.ignores(path)) {
|
|
52366
52373
|
throw new Error(`Not allow to access file ${path}`);
|
|
@@ -64124,11 +64131,11 @@ var agentWorkflow = async (input, { step, tools: tools2 }) => {
|
|
|
64124
64131
|
await tools2.taskEvent(event2);
|
|
64125
64132
|
});
|
|
64126
64133
|
};
|
|
64127
|
-
const { tools:
|
|
64134
|
+
const { tools: toolInfo15, maxToolRoundTrips = 200 } = input;
|
|
64128
64135
|
const messages = "systemPrompt" in input ? [{ role: "system", content: input.systemPrompt }] : input.messages;
|
|
64129
64136
|
await event("start-task", { kind: "StartTask" /* StartTask */, systemPrompt: "systemPrompt" in input ? input.systemPrompt : "" });
|
|
64130
64137
|
const toolSet = {};
|
|
64131
|
-
for (const tool3 of
|
|
64138
|
+
for (const tool3 of toolInfo15) {
|
|
64132
64139
|
toolSet[tool3.name] = {
|
|
64133
64140
|
description: tool3.description,
|
|
64134
64141
|
inputSchema: jsonSchema(toJSONSchema(tool3.parameters))
|
|
@@ -64829,7 +64836,32 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
64829
64836
|
var source_default = chalk;
|
|
64830
64837
|
|
|
64831
64838
|
// ../cli-shared/src/utils/eventHandler.ts
|
|
64832
|
-
var
|
|
64839
|
+
var taskToolCallStats = new Map;
|
|
64840
|
+
var globalToolCallStats = new Map;
|
|
64841
|
+
function logToolCallStats(stream, statsMap, title) {
|
|
64842
|
+
const customConsole = new Console(stream, stream);
|
|
64843
|
+
customConsole.log(`
|
|
64844
|
+
|
|
64845
|
+
======== ${title} ========`);
|
|
64846
|
+
if (statsMap.size > 0) {
|
|
64847
|
+
const tableData = [...statsMap.entries()].map(([tool3, stats]) => {
|
|
64848
|
+
const successRate = stats.calls > 0 ? stats.success / stats.calls * 100 : 0;
|
|
64849
|
+
return {
|
|
64850
|
+
"Tool Name": tool3,
|
|
64851
|
+
Calls: stats.calls,
|
|
64852
|
+
Success: stats.success,
|
|
64853
|
+
Errors: stats.errors,
|
|
64854
|
+
"Success Rate": `${successRate.toFixed(2)}%`
|
|
64855
|
+
};
|
|
64856
|
+
});
|
|
64857
|
+
customConsole.table(tableData);
|
|
64858
|
+
} else {
|
|
64859
|
+
customConsole.log("No tools were called.");
|
|
64860
|
+
}
|
|
64861
|
+
}
|
|
64862
|
+
function logGlobalToolCallStats(stream) {
|
|
64863
|
+
logToolCallStats(stream, globalToolCallStats, "Global Tool Call Stats");
|
|
64864
|
+
}
|
|
64833
64865
|
var printEvent = (verbose, usageMeter, stream = process.stdout) => {
|
|
64834
64866
|
if (verbose < 0) {
|
|
64835
64867
|
return () => {};
|
|
@@ -64840,7 +64872,7 @@ var printEvent = (verbose, usageMeter, stream = process.stdout) => {
|
|
|
64840
64872
|
return (event) => {
|
|
64841
64873
|
switch (event.kind) {
|
|
64842
64874
|
case "StartTask" /* StartTask */:
|
|
64843
|
-
|
|
64875
|
+
taskToolCallStats.clear();
|
|
64844
64876
|
if (verbose > 2) {
|
|
64845
64877
|
customConsole.log(`
|
|
64846
64878
|
====== System Prompt ======
|
|
@@ -64852,10 +64884,12 @@ ${event.systemPrompt}`);
|
|
|
64852
64884
|
}
|
|
64853
64885
|
break;
|
|
64854
64886
|
case "StartRequest" /* StartRequest */:
|
|
64855
|
-
|
|
64887
|
+
if (verbose > 0) {
|
|
64888
|
+
customConsole.log(`
|
|
64856
64889
|
|
|
64857
64890
|
======== New Request ========
|
|
64858
64891
|
`);
|
|
64892
|
+
}
|
|
64859
64893
|
if (verbose > 1) {
|
|
64860
64894
|
for (const message of event.userMessage) {
|
|
64861
64895
|
const userMessage = message.content;
|
|
@@ -64899,10 +64933,12 @@ ${event.systemPrompt}`);
|
|
|
64899
64933
|
}
|
|
64900
64934
|
break;
|
|
64901
64935
|
case "EndRequest" /* EndRequest */:
|
|
64902
|
-
|
|
64936
|
+
if (verbose > 0) {
|
|
64937
|
+
customConsole.log(`
|
|
64903
64938
|
|
|
64904
64939
|
======== Request Ended ========
|
|
64905
64940
|
`);
|
|
64941
|
+
}
|
|
64906
64942
|
if (verbose > 1) {
|
|
64907
64943
|
customConsole.log(usageMeter.getUsageText());
|
|
64908
64944
|
}
|
|
@@ -64918,23 +64954,27 @@ ${event.systemPrompt}`);
|
|
|
64918
64954
|
break;
|
|
64919
64955
|
}
|
|
64920
64956
|
case "Reasoning" /* Reasoning */: {
|
|
64921
|
-
|
|
64922
|
-
|
|
64957
|
+
if (verbose > 0) {
|
|
64958
|
+
write(source_default.dim(event.newText));
|
|
64959
|
+
hadReasoning = true;
|
|
64960
|
+
}
|
|
64923
64961
|
break;
|
|
64924
64962
|
}
|
|
64925
64963
|
case "ToolUse" /* ToolUse */: {
|
|
64926
|
-
|
|
64964
|
+
if (verbose > 0) {
|
|
64965
|
+
customConsole.log(source_default.yellow(`
|
|
64927
64966
|
|
|
64928
64967
|
Tool use:`, event.tool), event.params);
|
|
64929
|
-
|
|
64968
|
+
}
|
|
64969
|
+
const stats = taskToolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
64930
64970
|
stats.calls++;
|
|
64931
|
-
|
|
64971
|
+
taskToolCallStats.set(event.tool, stats);
|
|
64932
64972
|
break;
|
|
64933
64973
|
}
|
|
64934
64974
|
case "ToolReply" /* ToolReply */: {
|
|
64935
|
-
const stats =
|
|
64975
|
+
const stats = taskToolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
64936
64976
|
stats.success++;
|
|
64937
|
-
|
|
64977
|
+
taskToolCallStats.set(event.tool, stats);
|
|
64938
64978
|
break;
|
|
64939
64979
|
}
|
|
64940
64980
|
case "ToolError" /* ToolError */: {
|
|
@@ -64942,9 +64982,9 @@ Tool use:`, event.tool), event.params);
|
|
|
64942
64982
|
|
|
64943
64983
|
Tool error:`, event.tool));
|
|
64944
64984
|
customConsole.error(event.error);
|
|
64945
|
-
const stats =
|
|
64985
|
+
const stats = taskToolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
64946
64986
|
stats.errors++;
|
|
64947
|
-
|
|
64987
|
+
taskToolCallStats.set(event.tool, stats);
|
|
64948
64988
|
break;
|
|
64949
64989
|
}
|
|
64950
64990
|
case "UsageExceeded" /* UsageExceeded */:
|
|
@@ -64964,23 +65004,15 @@ Tool error:`, event.tool));
|
|
|
64964
65004
|
customConsole.log("Exit Message:", event.exitReason.message);
|
|
64965
65005
|
break;
|
|
64966
65006
|
}
|
|
64967
|
-
|
|
64968
|
-
|
|
64969
|
-
|
|
64970
|
-
|
|
64971
|
-
|
|
64972
|
-
|
|
64973
|
-
|
|
64974
|
-
|
|
64975
|
-
|
|
64976
|
-
Success: stats.success,
|
|
64977
|
-
Errors: stats.errors,
|
|
64978
|
-
"Success Rate": `${successRate.toFixed(2)}%`
|
|
64979
|
-
};
|
|
64980
|
-
});
|
|
64981
|
-
customConsole.table(tableData);
|
|
64982
|
-
} else {
|
|
64983
|
-
customConsole.log("No tools were called.");
|
|
65007
|
+
if (verbose > 0) {
|
|
65008
|
+
for (const [tool3, taskStats] of taskToolCallStats.entries()) {
|
|
65009
|
+
const globalStats = globalToolCallStats.get(tool3) ?? { calls: 0, success: 0, errors: 0 };
|
|
65010
|
+
globalStats.calls += taskStats.calls;
|
|
65011
|
+
globalStats.success += taskStats.success;
|
|
65012
|
+
globalStats.errors += taskStats.errors;
|
|
65013
|
+
globalToolCallStats.set(tool3, globalStats);
|
|
65014
|
+
}
|
|
65015
|
+
logToolCallStats(stream, taskToolCallStats, "Task Tool Call Stats");
|
|
64984
65016
|
}
|
|
64985
65017
|
break;
|
|
64986
65018
|
}
|
|
@@ -77469,7 +77501,7 @@ function annotateDiffWithLineNumbers(diff) {
|
|
|
77469
77501
|
}
|
|
77470
77502
|
|
|
77471
77503
|
// src/tools/gitDiff.ts
|
|
77472
|
-
var
|
|
77504
|
+
var toolInfo15 = {
|
|
77473
77505
|
name: "git_diff",
|
|
77474
77506
|
description: "Get the git diff for the current repository. Can be used to get staged changes, unstaged changes, or changes between commits. By default, it returns unstaged changes.",
|
|
77475
77507
|
parameters: exports_external.object({
|
|
@@ -77498,7 +77530,7 @@ var toolInfo17 = {
|
|
|
77498
77530
|
}, exports_external.boolean().optional().default(false)).describe("Annotate the diff with line numbers for additions and deletions.")
|
|
77499
77531
|
})
|
|
77500
77532
|
};
|
|
77501
|
-
var
|
|
77533
|
+
var handler15 = async (provider3, args) => {
|
|
77502
77534
|
if (!provider3.executeCommand) {
|
|
77503
77535
|
return {
|
|
77504
77536
|
type: "Error" /* Error */,
|
|
@@ -77508,7 +77540,7 @@ var handler17 = async (provider3, args) => {
|
|
|
77508
77540
|
}
|
|
77509
77541
|
};
|
|
77510
77542
|
}
|
|
77511
|
-
const { staged, file: file2, commitRange, contextLines, includeLineNumbers } =
|
|
77543
|
+
const { staged, file: file2, commitRange, contextLines, includeLineNumbers } = toolInfo15.parameters.parse(args);
|
|
77512
77544
|
const commandParts = ["git", "diff", "--no-color", `-U${contextLines}`];
|
|
77513
77545
|
if (staged) {
|
|
77514
77546
|
commandParts.push("--staged");
|
|
@@ -77565,8 +77597,8 @@ ${result.stderr}`
|
|
|
77565
77597
|
}
|
|
77566
77598
|
};
|
|
77567
77599
|
var gitDiff_default = {
|
|
77568
|
-
...
|
|
77569
|
-
handler:
|
|
77600
|
+
...toolInfo15,
|
|
77601
|
+
handler: handler15
|
|
77570
77602
|
};
|
|
77571
77603
|
// src/utils/cacheControl.ts
|
|
77572
77604
|
var CACHEABLE_MODELS = ["sonnet", "opus", "haiku", "gemini"];
|
|
@@ -77889,11 +77921,9 @@ var allTools = [
|
|
|
77889
77921
|
listFiles_default,
|
|
77890
77922
|
readBinaryFile_default,
|
|
77891
77923
|
readFile_default,
|
|
77892
|
-
appendMemory_default,
|
|
77893
77924
|
readMemory_default,
|
|
77894
|
-
replaceMemory_default,
|
|
77895
|
-
removeMemory_default,
|
|
77896
77925
|
listMemoryTopics_default,
|
|
77926
|
+
updateMemory_default,
|
|
77897
77927
|
removeFile_default,
|
|
77898
77928
|
renameFile_default,
|
|
77899
77929
|
replaceInFile_default,
|
|
@@ -78158,17 +78188,10 @@ ${defaultContent}
|
|
|
78158
78188
|
return contextParts.join(`
|
|
78159
78189
|
`);
|
|
78160
78190
|
}
|
|
78161
|
-
async function
|
|
78162
|
-
const provider3 = context.toolProvider;
|
|
78163
|
-
await provider3.appendMemory(input2.topic, input2.content);
|
|
78164
|
-
}
|
|
78165
|
-
async function replaceMemory(input2, context) {
|
|
78191
|
+
async function updateMemory(input2, context) {
|
|
78166
78192
|
const provider3 = context.toolProvider;
|
|
78167
|
-
|
|
78168
|
-
|
|
78169
|
-
async function removeMemory(input2, context) {
|
|
78170
|
-
const provider3 = context.toolProvider;
|
|
78171
|
-
await provider3.removeMemory(input2.topic);
|
|
78193
|
+
const content = "content" in input2 ? input2.content : undefined;
|
|
78194
|
+
return provider3.updateMemory(input2.operation, input2.topic, content);
|
|
78172
78195
|
}
|
|
78173
78196
|
var localToolHandlers = {
|
|
78174
78197
|
createPullRequest,
|
|
@@ -78184,14 +78207,12 @@ var localToolHandlers = {
|
|
|
78184
78207
|
invokeTool,
|
|
78185
78208
|
taskEvent,
|
|
78186
78209
|
getMemoryContext,
|
|
78187
|
-
|
|
78188
|
-
replaceMemory,
|
|
78189
|
-
removeMemory
|
|
78210
|
+
updateMemory
|
|
78190
78211
|
};
|
|
78191
78212
|
async function toolCall(toolCall2, context) {
|
|
78192
|
-
const
|
|
78193
|
-
if (
|
|
78194
|
-
return
|
|
78213
|
+
const handler16 = localToolHandlers[toolCall2.tool];
|
|
78214
|
+
if (handler16) {
|
|
78215
|
+
return handler16(toolCall2.input, context);
|
|
78195
78216
|
}
|
|
78196
78217
|
throw new Error(`Unknown tool: ${toolCall2.tool}`);
|
|
78197
78218
|
}
|
|
@@ -78256,7 +78277,9 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
78256
78277
|
try {
|
|
78257
78278
|
logger.info("Running workflow...");
|
|
78258
78279
|
const output = await workflow2(workflowInput, context);
|
|
78259
|
-
logger.info(
|
|
78280
|
+
logger.info(`
|
|
78281
|
+
|
|
78282
|
+
Workflow completed successfully.`);
|
|
78260
78283
|
logger.info(usage.getUsageText());
|
|
78261
78284
|
return output;
|
|
78262
78285
|
} catch (e) {
|
|
@@ -78269,6 +78292,8 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
78269
78292
|
}
|
|
78270
78293
|
logger.info(usage.getUsageText());
|
|
78271
78294
|
return;
|
|
78295
|
+
} finally {
|
|
78296
|
+
logGlobalToolCallStats(process.stderr);
|
|
78272
78297
|
}
|
|
78273
78298
|
}
|
|
78274
78299
|
|
|
@@ -78303,7 +78328,8 @@ As a planner, your expertise lies in:
|
|
|
78303
78328
|
- Exploring codebases to identify patterns, conventions, and integration points
|
|
78304
78329
|
- Breaking down complex tasks into clear, logical sequences of steps
|
|
78305
78330
|
- Anticipating dependencies, edge cases, and potential challenges
|
|
78306
|
-
- Creating plans that
|
|
78331
|
+
- Creating plans that can be executed autonomously by an AI coding agent
|
|
78332
|
+
- Providing technical specificity required for autonomous implementation
|
|
78307
78333
|
|
|
78308
78334
|
## Planning Philosophy
|
|
78309
78335
|
|
|
@@ -78322,16 +78348,39 @@ Effective planning requires understanding before action:
|
|
|
78322
78348
|
- Understanding context prevents suggesting solutions that don't fit the project
|
|
78323
78349
|
|
|
78324
78350
|
3. **Specificity Over Generality**
|
|
78325
|
-
- Vague plans lead to implementation confusion
|
|
78351
|
+
- Vague plans lead to implementation confusion and prevent autonomous execution
|
|
78326
78352
|
- Instead of "implement the feature," specify which files to modify, what functions to add, and what logic to implement
|
|
78327
78353
|
- Name specific components, modules, or files when possible
|
|
78328
78354
|
- Describe what needs to change and why
|
|
78329
|
-
|
|
78330
|
-
|
|
78331
|
-
|
|
78332
|
-
|
|
78333
|
-
|
|
78355
|
+
- Examples:
|
|
78356
|
+
* ❌ Vague: "Implement the feature"
|
|
78357
|
+
* ✅ Specific: "Create \`src/components/LoginForm.tsx\` with a React component that includes email and password fields, using the existing \`useAuth\` hook from \`src/hooks/useAuth.ts\`"
|
|
78358
|
+
* ❌ Vague: "Add error handling"
|
|
78359
|
+
* ✅ Specific: "In \`src/api/client.ts\`, wrap the fetch call in a try-catch block and throw custom errors using the \`ApiError\` class from \`src/errors.ts\`"
|
|
78360
|
+
|
|
78361
|
+
4. **Clarity for AI Coding Agents**
|
|
78362
|
+
- Plans will be executed autonomously by an AI coding agent without human intervention
|
|
78363
|
+
- Break complex tasks into smaller, logical units that can be completed independently
|
|
78334
78364
|
- Use clear structure (numbered lists, narrative text, or combined formats) to organize steps
|
|
78365
|
+
- Include exact file paths, function names, and implementation patterns
|
|
78366
|
+
|
|
78367
|
+
## Planning for AI Implementation
|
|
78368
|
+
|
|
78369
|
+
Plans will be executed by an AI coding agent that operates autonomously with the following capabilities:
|
|
78370
|
+
|
|
78371
|
+
**Planning Requirements:**
|
|
78372
|
+
Plans should include specific technical details to enable autonomous implementation:
|
|
78373
|
+
- **Function/class names**: Name specific functions, classes, or components to implement
|
|
78374
|
+
- **Implementation patterns**: Reference existing patterns or provide clear guidance on approach
|
|
78375
|
+
- **Import statements**: Specify required dependencies and where to import them from
|
|
78376
|
+
- **Technical constraints**: Note any architectural decisions, performance requirements, or compatibility concerns
|
|
78377
|
+
|
|
78378
|
+
**What Makes a Good AI-Actionable Plan:**
|
|
78379
|
+
- Each step can be completed using the available tools
|
|
78380
|
+
- File paths and code structures are explicitly named
|
|
78381
|
+
- Dependencies between steps are clear
|
|
78382
|
+
- Implementation approach follows existing codebase patterns
|
|
78383
|
+
- Technical requirements are specific, not general
|
|
78335
78384
|
|
|
78336
78385
|
## Your Approach
|
|
78337
78386
|
|
|
@@ -78408,9 +78457,11 @@ When generating your plan, follow these formatting guidelines:
|
|
|
78408
78457
|
2. Implement feature B
|
|
78409
78458
|
3. Write tests
|
|
78410
78459
|
|
|
78411
|
-
5.
|
|
78412
|
-
a.
|
|
78413
|
-
b. Avoid steps that require human intervention or
|
|
78460
|
+
5. Include implementation-ready details for AI agents:
|
|
78461
|
+
a. Provide specific technical details the coding agent needs (file paths, function signatures, etc.)
|
|
78462
|
+
b. Avoid steps that require human intervention or manual processes
|
|
78463
|
+
c. Each step should be implementable using the AI agent's available tools
|
|
78464
|
+
d. Reference existing code patterns and conventions from the codebase
|
|
78414
78465
|
|
|
78415
78466
|
**Note**: Plans should use flexible formats such as numbered lists or narrative text. Checklist formats (markdown checkboxes) are NOT required and should only be used when specifically appropriate for tracking independent action items.
|
|
78416
78467
|
|
|
@@ -78613,7 +78664,7 @@ You will receive:
|
|
|
78613
78664
|
## Process
|
|
78614
78665
|
|
|
78615
78666
|
1. **Find the completed item**: Locate the item in the plan that matches the completed task
|
|
78616
|
-
2. **Mark it as complete**:
|
|
78667
|
+
2. **Mark it as complete**:
|
|
78617
78668
|
- If using checkboxes: Change \`- [ ]\` to \`- [x]\`
|
|
78618
78669
|
- If using numbered lists: Add a ✅ prefix (e.g., "1. Task" → "✅ 1. Task")
|
|
78619
78670
|
- If using narrative: Mark completion in context-appropriate way
|
|
@@ -79060,9 +79111,7 @@ ${memoryContext}`
|
|
|
79060
79111
|
removeFile_default,
|
|
79061
79112
|
renameFile_default,
|
|
79062
79113
|
readMemory_default,
|
|
79063
|
-
|
|
79064
|
-
replaceMemory_default,
|
|
79065
|
-
removeMemory_default,
|
|
79114
|
+
updateMemory_default,
|
|
79066
79115
|
listMemoryTopics_default
|
|
79067
79116
|
],
|
|
79068
79117
|
outputSchema: FixIterationSummarySchema
|
|
@@ -79077,7 +79126,7 @@ ${memoryContext}`
|
|
|
79077
79126
|
}
|
|
79078
79127
|
if (summary) {
|
|
79079
79128
|
summaries.push(summary);
|
|
79080
|
-
await tools2.
|
|
79129
|
+
await tools2.updateMemory({ operation: "append", content: `Summary of changes for fix attempt ${i + 1}: ${summary}` });
|
|
79081
79130
|
logger.info(`Summary of changes: ${summary}`);
|
|
79082
79131
|
}
|
|
79083
79132
|
}
|
|
@@ -79130,9 +79179,7 @@ ${defaultContext}`;
|
|
|
79130
79179
|
fetchUrl_default,
|
|
79131
79180
|
listMemoryTopics_default,
|
|
79132
79181
|
readMemory_default,
|
|
79133
|
-
|
|
79134
|
-
replaceMemory_default,
|
|
79135
|
-
removeMemory_default
|
|
79182
|
+
updateMemory_default
|
|
79136
79183
|
];
|
|
79137
79184
|
if (interactive) {
|
|
79138
79185
|
agentTools.push(askFollowupQuestion_default);
|
|
@@ -79373,9 +79420,7 @@ ${fileContentString}`;
|
|
|
79373
79420
|
removeFile_default,
|
|
79374
79421
|
renameFile_default,
|
|
79375
79422
|
readMemory_default,
|
|
79376
|
-
|
|
79377
|
-
replaceMemory_default,
|
|
79378
|
-
removeMemory_default,
|
|
79423
|
+
updateMemory_default,
|
|
79379
79424
|
listMemoryTopics_default
|
|
79380
79425
|
];
|
|
79381
79426
|
if (mode === "interactive") {
|
|
@@ -79419,7 +79464,8 @@ ${memoryContext}`
|
|
|
79419
79464
|
summaries.push(summary);
|
|
79420
79465
|
logger.info(`Summary: ${summary}`);
|
|
79421
79466
|
await step("summarize-implementation", async () => {
|
|
79422
|
-
await tools2.
|
|
79467
|
+
await tools2.updateMemory({
|
|
79468
|
+
operation: "append",
|
|
79423
79469
|
topic: "implementation-summary",
|
|
79424
79470
|
content: summary
|
|
79425
79471
|
});
|
|
@@ -79891,18 +79937,7 @@ ${formatReviewToolInput(changeInfo)}`;
|
|
|
79891
79937
|
return await agentWorkflow({
|
|
79892
79938
|
systemPrompt: CODE_REVIEW_SYSTEM_PROMPT,
|
|
79893
79939
|
userMessage: [{ role: "user", content: userMessage }],
|
|
79894
|
-
tools: [
|
|
79895
|
-
readFile_default,
|
|
79896
|
-
readBinaryFile_default,
|
|
79897
|
-
searchFiles_default,
|
|
79898
|
-
listFiles_default,
|
|
79899
|
-
gitDiff_default,
|
|
79900
|
-
readMemory_default,
|
|
79901
|
-
appendMemory_default,
|
|
79902
|
-
replaceMemory_default,
|
|
79903
|
-
removeMemory_default,
|
|
79904
|
-
listMemoryTopics_default
|
|
79905
|
-
],
|
|
79940
|
+
tools: [readFile_default, readBinaryFile_default, searchFiles_default, listFiles_default, gitDiff_default, readMemory_default, updateMemory_default, listMemoryTopics_default],
|
|
79906
79941
|
outputSchema: reviewOutputSchema
|
|
79907
79942
|
}, context);
|
|
79908
79943
|
});
|
|
@@ -79991,9 +80026,7 @@ ${feedback}`
|
|
|
79991
80026
|
readBinaryFile_default,
|
|
79992
80027
|
searchFiles_default,
|
|
79993
80028
|
readMemory_default,
|
|
79994
|
-
|
|
79995
|
-
replaceMemory_default,
|
|
79996
|
-
removeMemory_default,
|
|
80029
|
+
updateMemory_default,
|
|
79997
80030
|
listMemoryTopics_default
|
|
79998
80031
|
],
|
|
79999
80032
|
outputSchema: EpicPlanSchema
|
|
@@ -80075,9 +80108,11 @@ var epicWorkflow = async (input2, context) => {
|
|
|
80075
80108
|
let feedback;
|
|
80076
80109
|
let highLevelPlan2;
|
|
80077
80110
|
let branchName2;
|
|
80111
|
+
let planAttempt = 1;
|
|
80078
80112
|
try {
|
|
80079
80113
|
while (true) {
|
|
80080
|
-
const result = await step2(
|
|
80114
|
+
const result = await step2(`plan-${planAttempt}`, () => createPlan2({ task: task2, feedback }, context2));
|
|
80115
|
+
planAttempt++;
|
|
80081
80116
|
if (result.question) {
|
|
80082
80117
|
const answer = await tools3.input({
|
|
80083
80118
|
message: result.question.question,
|
|
@@ -80166,13 +80201,14 @@ ${result.plan}`);
|
|
|
80166
80201
|
await step2("createBranch", async () => await tools3.executeCommand({ command: "git", args: ["checkout", "-b", finalBranchName] }));
|
|
80167
80202
|
logger2.info(`✅ Branch '${finalBranchName}' created.
|
|
80168
80203
|
`);
|
|
80169
|
-
await tools3.
|
|
80204
|
+
await tools3.updateMemory({
|
|
80205
|
+
operation: "append",
|
|
80170
80206
|
topic: "epic-context",
|
|
80171
80207
|
content: `Epic: ${task2}
|
|
80172
80208
|
Branch: ${finalBranchName}
|
|
80173
80209
|
Started: ${new Date().toISOString()}`
|
|
80174
80210
|
});
|
|
80175
|
-
await tools3.
|
|
80211
|
+
await tools3.updateMemory({ operation: "append", topic: "epic-plan", content: plan });
|
|
80176
80212
|
return { success: true, branchName: finalBranchName };
|
|
80177
80213
|
}
|
|
80178
80214
|
const branchResult = await createFeatureBranch(branchName, task, highLevelPlan, context);
|
|
@@ -80244,7 +80280,7 @@ Focus only on this item, but use the plan for context.`;
|
|
|
80244
80280
|
currentPlan = updateResult.updatedPlan;
|
|
80245
80281
|
isComplete = updateResult.isComplete;
|
|
80246
80282
|
nextTask = updateResult.nextTask;
|
|
80247
|
-
await tools2.
|
|
80283
|
+
await tools2.updateMemory({ operation: "replace", topic: "epic-plan", content: currentPlan });
|
|
80248
80284
|
const checkboxCompleted = (currentPlan.match(/- \[x\]/g) || []).length;
|
|
80249
80285
|
const checkboxTotal = (currentPlan.match(/- \[[x ]\]/g) || []).length;
|
|
80250
80286
|
const checkmarkCompleted = (currentPlan.match(/^✅/gm) || []).length;
|
|
@@ -80277,8 +80313,8 @@ Focus only on this item, but use the plan for context.`;
|
|
|
80277
80313
|
Branch '${branchName}' was created but work is incomplete.`);
|
|
80278
80314
|
logger.info(`To cleanup: git checkout <previous-branch> && git branch -D ${branchName}
|
|
80279
80315
|
`);
|
|
80280
|
-
await tools2.
|
|
80281
|
-
await tools2.
|
|
80316
|
+
await tools2.updateMemory({ operation: "remove", topic: "epic-context" });
|
|
80317
|
+
await tools2.updateMemory({ operation: "remove", topic: "epic-plan" });
|
|
80282
80318
|
throw error46;
|
|
80283
80319
|
}
|
|
80284
80320
|
const totalElapsed = Date.now() - workflowStartTime;
|
|
@@ -80308,8 +80344,8 @@ ${"=".repeat(80)}`);
|
|
|
80308
80344
|
`);
|
|
80309
80345
|
logger.info(`${"=".repeat(80)}
|
|
80310
80346
|
`);
|
|
80311
|
-
await tools2.
|
|
80312
|
-
await tools2.
|
|
80347
|
+
await tools2.updateMemory({ operation: "remove", topic: "epic-context" });
|
|
80348
|
+
await tools2.updateMemory({ operation: "remove", topic: "epic-plan" });
|
|
80313
80349
|
};
|
|
80314
80350
|
|
|
80315
80351
|
// src/workflows/task.workflow.ts
|