@polka-codes/core 0.9.48 → 0.9.49
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/_tsup-dts-rollup.d.ts +354 -108
- package/dist/index.d.ts +13 -0
- package/dist/index.js +276 -104
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -455,30 +455,64 @@ var fetchUrl_default = {
|
|
|
455
455
|
handler: handler3
|
|
456
456
|
};
|
|
457
457
|
|
|
458
|
-
// src/tools/
|
|
458
|
+
// src/tools/getTodoItem.ts
|
|
459
459
|
import { z as z5 } from "zod";
|
|
460
460
|
var toolInfo4 = {
|
|
461
|
+
name: "getTodoItem",
|
|
462
|
+
description: "Get a to-do item by its ID.",
|
|
463
|
+
parameters: z5.object({
|
|
464
|
+
id: z5.string().describe("The ID of the to-do item.")
|
|
465
|
+
})
|
|
466
|
+
};
|
|
467
|
+
var handler4 = async (provider, args) => {
|
|
468
|
+
if (!provider.getTodoItem) {
|
|
469
|
+
return {
|
|
470
|
+
type: "Error" /* Error */,
|
|
471
|
+
message: {
|
|
472
|
+
type: "error-text",
|
|
473
|
+
value: "Not possible to get a to-do item."
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const { id } = toolInfo4.parameters.parse(args);
|
|
478
|
+
const item = await provider.getTodoItem(id);
|
|
479
|
+
return {
|
|
480
|
+
type: "Reply" /* Reply */,
|
|
481
|
+
message: {
|
|
482
|
+
type: "json",
|
|
483
|
+
value: item ?? null
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
var getTodoItem_default = {
|
|
488
|
+
...toolInfo4,
|
|
489
|
+
handler: handler4
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// src/tools/listFiles.ts
|
|
493
|
+
import { z as z6 } from "zod";
|
|
494
|
+
var toolInfo5 = {
|
|
461
495
|
name: "listFiles",
|
|
462
496
|
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.",
|
|
463
|
-
parameters:
|
|
464
|
-
path:
|
|
465
|
-
maxCount:
|
|
466
|
-
recursive:
|
|
497
|
+
parameters: z6.object({
|
|
498
|
+
path: z6.string().describe("The path of the directory to list contents for (relative to the current working directory)").meta({ usageValue: "Directory path here" }),
|
|
499
|
+
maxCount: z6.coerce.number().optional().default(2e3).describe("The maximum number of files to list. Default to 2000").meta({ usageValue: "Maximum number of files to list (optional)" }),
|
|
500
|
+
recursive: z6.preprocess((val) => {
|
|
467
501
|
if (typeof val === "string") {
|
|
468
502
|
const lower = val.toLowerCase();
|
|
469
503
|
if (lower === "false") return false;
|
|
470
504
|
if (lower === "true") return true;
|
|
471
505
|
}
|
|
472
506
|
return val;
|
|
473
|
-
},
|
|
474
|
-
includeIgnored:
|
|
507
|
+
}, z6.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" }),
|
|
508
|
+
includeIgnored: z6.preprocess((val) => {
|
|
475
509
|
if (typeof val === "string") {
|
|
476
510
|
const lower = val.toLowerCase();
|
|
477
511
|
if (lower === "false") return false;
|
|
478
512
|
if (lower === "true") return true;
|
|
479
513
|
}
|
|
480
514
|
return val;
|
|
481
|
-
},
|
|
515
|
+
}, z6.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
482
516
|
}).meta({
|
|
483
517
|
examples: [
|
|
484
518
|
{
|
|
@@ -491,7 +525,7 @@ var toolInfo4 = {
|
|
|
491
525
|
]
|
|
492
526
|
})
|
|
493
527
|
};
|
|
494
|
-
var
|
|
528
|
+
var handler5 = async (provider, args) => {
|
|
495
529
|
if (!provider.listFiles) {
|
|
496
530
|
return {
|
|
497
531
|
type: "Error" /* Error */,
|
|
@@ -501,7 +535,7 @@ var handler4 = async (provider, args) => {
|
|
|
501
535
|
}
|
|
502
536
|
};
|
|
503
537
|
}
|
|
504
|
-
const { path, maxCount, recursive, includeIgnored } =
|
|
538
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo5.parameters.parse(args);
|
|
505
539
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
506
540
|
return {
|
|
507
541
|
type: "Reply" /* Reply */,
|
|
@@ -516,18 +550,18 @@ ${files.join("\n")}
|
|
|
516
550
|
};
|
|
517
551
|
};
|
|
518
552
|
var listFiles_default = {
|
|
519
|
-
...
|
|
520
|
-
handler:
|
|
553
|
+
...toolInfo5,
|
|
554
|
+
handler: handler5
|
|
521
555
|
};
|
|
522
556
|
|
|
523
557
|
// src/tools/listMemoryTopics.ts
|
|
524
|
-
import { z as
|
|
525
|
-
var
|
|
558
|
+
import { z as z7 } from "zod";
|
|
559
|
+
var toolInfo6 = {
|
|
526
560
|
name: "listMemoryTopics",
|
|
527
|
-
description: "Lists all topics in memory.",
|
|
528
|
-
parameters:
|
|
561
|
+
description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.",
|
|
562
|
+
parameters: z7.object({})
|
|
529
563
|
};
|
|
530
|
-
var
|
|
564
|
+
var handler6 = async (provider, _args) => {
|
|
531
565
|
const topics = await provider.listMemoryTopics();
|
|
532
566
|
if (!topics.length) {
|
|
533
567
|
return { type: "Reply" /* Reply */, message: { type: "text", value: "No topics found." } };
|
|
@@ -542,12 +576,112 @@ ${topics.join("\n")}`
|
|
|
542
576
|
};
|
|
543
577
|
};
|
|
544
578
|
var listMemoryTopics_default = {
|
|
545
|
-
...
|
|
546
|
-
handler:
|
|
579
|
+
...toolInfo6,
|
|
580
|
+
handler: handler6
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
// src/tools/listTodoItems.ts
|
|
584
|
+
import { z as z9 } from "zod";
|
|
585
|
+
|
|
586
|
+
// src/tools/todo.ts
|
|
587
|
+
import { z as z8 } from "zod";
|
|
588
|
+
var TodoStatus = z8.enum(["open", "completed", "closed"]);
|
|
589
|
+
var TodoItemSchema = z8.object({
|
|
590
|
+
id: z8.string(),
|
|
591
|
+
title: z8.string(),
|
|
592
|
+
description: z8.string(),
|
|
593
|
+
relevantFileList: z8.array(z8.string()),
|
|
594
|
+
status: TodoStatus
|
|
595
|
+
});
|
|
596
|
+
var UpdateTodoItemInputSchema = z8.object({
|
|
597
|
+
operation: z8.enum(["add", "update"]),
|
|
598
|
+
id: z8.string().nullish(),
|
|
599
|
+
parentId: z8.string().nullish(),
|
|
600
|
+
title: z8.string().nullish(),
|
|
601
|
+
description: z8.string().nullish(),
|
|
602
|
+
relevantFileList: z8.array(z8.string()).nullish(),
|
|
603
|
+
status: TodoStatus.nullish()
|
|
604
|
+
}).superRefine((data, ctx) => {
|
|
605
|
+
if (data.operation === "add") {
|
|
606
|
+
if (!data.title) {
|
|
607
|
+
ctx.addIssue({
|
|
608
|
+
code: "custom",
|
|
609
|
+
message: 'Title is required for "add" operation',
|
|
610
|
+
path: ["title"]
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
} else if (data.operation === "update") {
|
|
614
|
+
if (!data.id) {
|
|
615
|
+
ctx.addIssue({
|
|
616
|
+
code: "custom",
|
|
617
|
+
message: 'ID is required for "update" operation',
|
|
618
|
+
path: ["id"]
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
var UpdateTodoItemOutputSchema = z8.object({
|
|
624
|
+
id: z8.string()
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
// src/tools/listTodoItems.ts
|
|
628
|
+
var toolInfo7 = {
|
|
629
|
+
name: "listTodoItems",
|
|
630
|
+
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.",
|
|
631
|
+
parameters: z9.object({
|
|
632
|
+
id: z9.string().nullish(),
|
|
633
|
+
status: TodoStatus.nullish()
|
|
634
|
+
})
|
|
635
|
+
};
|
|
636
|
+
var handler7 = async (provider, args) => {
|
|
637
|
+
if (!provider.listTodoItems) {
|
|
638
|
+
return {
|
|
639
|
+
type: "Error" /* Error */,
|
|
640
|
+
message: {
|
|
641
|
+
type: "error-text",
|
|
642
|
+
value: "Not possible to list to-do items."
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
const { id, status } = toolInfo7.parameters.parse(args);
|
|
647
|
+
const items = await provider.listTodoItems(id, status);
|
|
648
|
+
return {
|
|
649
|
+
type: "Reply" /* Reply */,
|
|
650
|
+
message: {
|
|
651
|
+
type: "json",
|
|
652
|
+
value: items
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
var listTodoItems_default = {
|
|
657
|
+
...toolInfo7,
|
|
658
|
+
handler: handler7
|
|
547
659
|
};
|
|
548
660
|
|
|
549
661
|
// src/tools/provider.ts
|
|
550
662
|
var MockProvider = class {
|
|
663
|
+
async listTodoItems(id, _status) {
|
|
664
|
+
if (id) {
|
|
665
|
+
return [{ id: `${id}-1`, title: "mock sub item", status: "open", description: "", relevantFileList: [] }];
|
|
666
|
+
}
|
|
667
|
+
return [{ id: "1", title: "mock item", status: "open", description: "", relevantFileList: [] }];
|
|
668
|
+
}
|
|
669
|
+
async getTodoItem(id) {
|
|
670
|
+
return {
|
|
671
|
+
id,
|
|
672
|
+
title: "mock item",
|
|
673
|
+
description: "mock desc",
|
|
674
|
+
relevantFileList: [],
|
|
675
|
+
status: "open",
|
|
676
|
+
subItems: []
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
async updateTodoItem(input) {
|
|
680
|
+
if (input.operation === "add") {
|
|
681
|
+
return { id: "2" };
|
|
682
|
+
}
|
|
683
|
+
return { id: input.id };
|
|
684
|
+
}
|
|
551
685
|
async readFile(_path, _includeIgnored) {
|
|
552
686
|
return "mock content";
|
|
553
687
|
}
|
|
@@ -584,15 +718,15 @@ var MockProvider = class {
|
|
|
584
718
|
};
|
|
585
719
|
|
|
586
720
|
// src/tools/readBinaryFile.ts
|
|
587
|
-
import { z as
|
|
588
|
-
var
|
|
721
|
+
import { z as z10 } from "zod";
|
|
722
|
+
var toolInfo8 = {
|
|
589
723
|
name: "readBinaryFile",
|
|
590
724
|
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.",
|
|
591
|
-
parameters:
|
|
592
|
-
url:
|
|
725
|
+
parameters: z10.object({
|
|
726
|
+
url: z10.string().describe("The URL or local path of the file to read.")
|
|
593
727
|
})
|
|
594
728
|
};
|
|
595
|
-
var
|
|
729
|
+
var handler8 = async (provider, args) => {
|
|
596
730
|
if (!provider.readBinaryFile) {
|
|
597
731
|
return {
|
|
598
732
|
type: "Error" /* Error */,
|
|
@@ -602,7 +736,7 @@ var handler6 = async (provider, args) => {
|
|
|
602
736
|
}
|
|
603
737
|
};
|
|
604
738
|
}
|
|
605
|
-
const { url } =
|
|
739
|
+
const { url } = toolInfo8.parameters.parse(args);
|
|
606
740
|
try {
|
|
607
741
|
const filePart = await provider.readBinaryFile(url);
|
|
608
742
|
return {
|
|
@@ -631,29 +765,29 @@ var handler6 = async (provider, args) => {
|
|
|
631
765
|
}
|
|
632
766
|
};
|
|
633
767
|
var readBinaryFile_default = {
|
|
634
|
-
...
|
|
635
|
-
handler:
|
|
768
|
+
...toolInfo8,
|
|
769
|
+
handler: handler8
|
|
636
770
|
};
|
|
637
771
|
|
|
638
772
|
// src/tools/readFile.ts
|
|
639
|
-
import { z as
|
|
640
|
-
var
|
|
773
|
+
import { z as z11 } from "zod";
|
|
774
|
+
var toolInfo9 = {
|
|
641
775
|
name: "readFile",
|
|
642
776
|
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.",
|
|
643
|
-
parameters:
|
|
644
|
-
path:
|
|
777
|
+
parameters: z11.object({
|
|
778
|
+
path: z11.preprocess((val) => {
|
|
645
779
|
if (!val) return [];
|
|
646
780
|
const values = Array.isArray(val) ? val : [val];
|
|
647
781
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
648
|
-
},
|
|
649
|
-
includeIgnored:
|
|
782
|
+
}, z11.array(z11.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
783
|
+
includeIgnored: z11.preprocess((val) => {
|
|
650
784
|
if (typeof val === "string") {
|
|
651
785
|
const lower = val.toLowerCase();
|
|
652
786
|
if (lower === "false") return false;
|
|
653
787
|
if (lower === "true") return true;
|
|
654
788
|
}
|
|
655
789
|
return val;
|
|
656
|
-
},
|
|
790
|
+
}, z11.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
657
791
|
}).meta({
|
|
658
792
|
examples: [
|
|
659
793
|
{
|
|
@@ -671,7 +805,7 @@ var toolInfo7 = {
|
|
|
671
805
|
]
|
|
672
806
|
})
|
|
673
807
|
};
|
|
674
|
-
var
|
|
808
|
+
var handler9 = async (provider, args) => {
|
|
675
809
|
if (!provider.readFile) {
|
|
676
810
|
return {
|
|
677
811
|
type: "Error" /* Error */,
|
|
@@ -681,7 +815,7 @@ var handler7 = async (provider, args) => {
|
|
|
681
815
|
}
|
|
682
816
|
};
|
|
683
817
|
}
|
|
684
|
-
const { path: paths, includeIgnored } =
|
|
818
|
+
const { path: paths, includeIgnored } = toolInfo9.parameters.parse(args);
|
|
685
819
|
const resp = [];
|
|
686
820
|
for (const path of paths) {
|
|
687
821
|
const fileContent = await provider.readFile(path, includeIgnored);
|
|
@@ -705,21 +839,21 @@ var handler7 = async (provider, args) => {
|
|
|
705
839
|
};
|
|
706
840
|
};
|
|
707
841
|
var readFile_default = {
|
|
708
|
-
...
|
|
709
|
-
handler:
|
|
842
|
+
...toolInfo9,
|
|
843
|
+
handler: handler9
|
|
710
844
|
};
|
|
711
845
|
|
|
712
846
|
// src/tools/readMemory.ts
|
|
713
|
-
import { z as
|
|
714
|
-
var
|
|
847
|
+
import { z as z12 } from "zod";
|
|
848
|
+
var toolInfo10 = {
|
|
715
849
|
name: "readMemory",
|
|
716
|
-
description: "Reads content from a memory topic.",
|
|
717
|
-
parameters:
|
|
718
|
-
topic:
|
|
850
|
+
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.",
|
|
851
|
+
parameters: z12.object({
|
|
852
|
+
topic: z12.string().optional().describe('The topic to read from memory. Defaults to ":default:".')
|
|
719
853
|
})
|
|
720
854
|
};
|
|
721
|
-
var
|
|
722
|
-
const { topic } =
|
|
855
|
+
var handler10 = async (provider, args) => {
|
|
856
|
+
const { topic } = toolInfo10.parameters.parse(args);
|
|
723
857
|
const content = await provider.readMemory(topic);
|
|
724
858
|
if (content) {
|
|
725
859
|
return {
|
|
@@ -741,17 +875,17 @@ ${content}
|
|
|
741
875
|
};
|
|
742
876
|
};
|
|
743
877
|
var readMemory_default = {
|
|
744
|
-
...
|
|
745
|
-
handler:
|
|
878
|
+
...toolInfo10,
|
|
879
|
+
handler: handler10
|
|
746
880
|
};
|
|
747
881
|
|
|
748
882
|
// src/tools/removeFile.ts
|
|
749
|
-
import { z as
|
|
750
|
-
var
|
|
883
|
+
import { z as z13 } from "zod";
|
|
884
|
+
var toolInfo11 = {
|
|
751
885
|
name: "removeFile",
|
|
752
886
|
description: "Request to remove a file at the specified path.",
|
|
753
|
-
parameters:
|
|
754
|
-
path:
|
|
887
|
+
parameters: z13.object({
|
|
888
|
+
path: z13.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
755
889
|
}).meta({
|
|
756
890
|
examples: [
|
|
757
891
|
{
|
|
@@ -763,7 +897,7 @@ var toolInfo9 = {
|
|
|
763
897
|
]
|
|
764
898
|
})
|
|
765
899
|
};
|
|
766
|
-
var
|
|
900
|
+
var handler11 = async (provider, args) => {
|
|
767
901
|
if (!provider.removeFile) {
|
|
768
902
|
return {
|
|
769
903
|
type: "Error" /* Error */,
|
|
@@ -773,7 +907,7 @@ var handler9 = async (provider, args) => {
|
|
|
773
907
|
}
|
|
774
908
|
};
|
|
775
909
|
}
|
|
776
|
-
const parsed =
|
|
910
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
777
911
|
if (!parsed.success) {
|
|
778
912
|
return {
|
|
779
913
|
type: "Error" /* Error */,
|
|
@@ -794,18 +928,18 @@ var handler9 = async (provider, args) => {
|
|
|
794
928
|
};
|
|
795
929
|
};
|
|
796
930
|
var removeFile_default = {
|
|
797
|
-
...
|
|
798
|
-
handler:
|
|
931
|
+
...toolInfo11,
|
|
932
|
+
handler: handler11
|
|
799
933
|
};
|
|
800
934
|
|
|
801
935
|
// src/tools/renameFile.ts
|
|
802
|
-
import { z as
|
|
803
|
-
var
|
|
936
|
+
import { z as z14 } from "zod";
|
|
937
|
+
var toolInfo12 = {
|
|
804
938
|
name: "renameFile",
|
|
805
939
|
description: "Request to rename a file from source path to target path.",
|
|
806
|
-
parameters:
|
|
807
|
-
source_path:
|
|
808
|
-
target_path:
|
|
940
|
+
parameters: z14.object({
|
|
941
|
+
source_path: z14.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
942
|
+
target_path: z14.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
809
943
|
}).meta({
|
|
810
944
|
examples: [
|
|
811
945
|
{
|
|
@@ -818,7 +952,7 @@ var toolInfo10 = {
|
|
|
818
952
|
]
|
|
819
953
|
})
|
|
820
954
|
};
|
|
821
|
-
var
|
|
955
|
+
var handler12 = async (provider, args) => {
|
|
822
956
|
if (!provider.renameFile) {
|
|
823
957
|
return {
|
|
824
958
|
type: "Error" /* Error */,
|
|
@@ -828,7 +962,7 @@ var handler10 = async (provider, args) => {
|
|
|
828
962
|
}
|
|
829
963
|
};
|
|
830
964
|
}
|
|
831
|
-
const { source_path, target_path } =
|
|
965
|
+
const { source_path, target_path } = toolInfo12.parameters.parse(args);
|
|
832
966
|
await provider.renameFile(source_path, target_path);
|
|
833
967
|
return {
|
|
834
968
|
type: "Reply" /* Reply */,
|
|
@@ -839,16 +973,16 @@ var handler10 = async (provider, args) => {
|
|
|
839
973
|
};
|
|
840
974
|
};
|
|
841
975
|
var renameFile_default = {
|
|
842
|
-
...
|
|
843
|
-
handler:
|
|
976
|
+
...toolInfo12,
|
|
977
|
+
handler: handler12
|
|
844
978
|
};
|
|
845
979
|
|
|
846
980
|
// src/tools/replaceInFile.ts
|
|
847
|
-
import { z as
|
|
981
|
+
import { z as z15 } from "zod";
|
|
848
982
|
|
|
849
983
|
// src/tools/utils/replaceInFile.ts
|
|
850
984
|
var replaceInFile = (fileContent, diff) => {
|
|
851
|
-
const blockPattern =
|
|
985
|
+
const blockPattern = /^\s*<<<<<+\s*SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+\s*REPLACE\s*$/gm;
|
|
852
986
|
const blocks = [];
|
|
853
987
|
for (let match = blockPattern.exec(diff); match !== null; match = blockPattern.exec(diff)) {
|
|
854
988
|
blocks.push({ search: match[1], replace: match[2] });
|
|
@@ -921,12 +1055,12 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
921
1055
|
};
|
|
922
1056
|
|
|
923
1057
|
// src/tools/replaceInFile.ts
|
|
924
|
-
var
|
|
1058
|
+
var toolInfo13 = {
|
|
925
1059
|
name: "replaceInFile",
|
|
926
1060
|
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.",
|
|
927
|
-
parameters:
|
|
928
|
-
path:
|
|
929
|
-
diff:
|
|
1061
|
+
parameters: z15.object({
|
|
1062
|
+
path: z15.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
|
|
1063
|
+
diff: z15.string().describe(
|
|
930
1064
|
`One or more SEARCH/REPLACE blocks following this exact format:
|
|
931
1065
|
\`\`\`
|
|
932
1066
|
<<<<<<< SEARCH
|
|
@@ -1033,7 +1167,7 @@ function oldFeature() {
|
|
|
1033
1167
|
]
|
|
1034
1168
|
})
|
|
1035
1169
|
};
|
|
1036
|
-
var
|
|
1170
|
+
var handler13 = async (provider, args) => {
|
|
1037
1171
|
if (!provider.readFile || !provider.writeFile) {
|
|
1038
1172
|
return {
|
|
1039
1173
|
type: "Error" /* Error */,
|
|
@@ -1043,7 +1177,7 @@ var handler11 = async (provider, args) => {
|
|
|
1043
1177
|
}
|
|
1044
1178
|
};
|
|
1045
1179
|
}
|
|
1046
|
-
const parsed =
|
|
1180
|
+
const parsed = toolInfo13.parameters.safeParse(args);
|
|
1047
1181
|
if (!parsed.success) {
|
|
1048
1182
|
return {
|
|
1049
1183
|
type: "Error" /* Error */,
|
|
@@ -1107,23 +1241,23 @@ var handler11 = async (provider, args) => {
|
|
|
1107
1241
|
}
|
|
1108
1242
|
};
|
|
1109
1243
|
var replaceInFile_default = {
|
|
1110
|
-
...
|
|
1111
|
-
handler:
|
|
1244
|
+
...toolInfo13,
|
|
1245
|
+
handler: handler13
|
|
1112
1246
|
};
|
|
1113
1247
|
|
|
1114
1248
|
// src/tools/searchFiles.ts
|
|
1115
|
-
import { z as
|
|
1116
|
-
var
|
|
1249
|
+
import { z as z16 } from "zod";
|
|
1250
|
+
var toolInfo14 = {
|
|
1117
1251
|
name: "searchFiles",
|
|
1118
1252
|
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.",
|
|
1119
|
-
parameters:
|
|
1120
|
-
path:
|
|
1253
|
+
parameters: z16.object({
|
|
1254
|
+
path: z16.string().describe(
|
|
1121
1255
|
"The path of the directory to search in (relative to the current working directory). This directory will be recursively searched."
|
|
1122
1256
|
).meta({ usageValue: "Directory path here" }),
|
|
1123
|
-
regex:
|
|
1257
|
+
regex: z16.string().describe("The regular expression pattern to search for. Uses Rust regex syntax.").meta({
|
|
1124
1258
|
usageValue: "Your regex pattern here"
|
|
1125
1259
|
}),
|
|
1126
|
-
filePattern:
|
|
1260
|
+
filePattern: z16.string().optional().describe(
|
|
1127
1261
|
'Comma-separated glob pattern to filter files (e.g., "*.ts" for TypeScript files or "*.ts,*.js" for both TypeScript and JavaScript files). If not provided, it will search all files (*).'
|
|
1128
1262
|
).meta({
|
|
1129
1263
|
usageValue: "file pattern here (optional)"
|
|
@@ -1141,7 +1275,7 @@ var toolInfo12 = {
|
|
|
1141
1275
|
]
|
|
1142
1276
|
})
|
|
1143
1277
|
};
|
|
1144
|
-
var
|
|
1278
|
+
var handler14 = async (provider, args) => {
|
|
1145
1279
|
if (!provider.searchFiles) {
|
|
1146
1280
|
return {
|
|
1147
1281
|
type: "Error" /* Error */,
|
|
@@ -1151,7 +1285,7 @@ var handler12 = async (provider, args) => {
|
|
|
1151
1285
|
}
|
|
1152
1286
|
};
|
|
1153
1287
|
}
|
|
1154
|
-
const parsed =
|
|
1288
|
+
const parsed = toolInfo14.parameters.safeParse(args);
|
|
1155
1289
|
if (!parsed.success) {
|
|
1156
1290
|
return {
|
|
1157
1291
|
type: "Error" /* Error */,
|
|
@@ -1188,19 +1322,19 @@ ${files.join("\n")}
|
|
|
1188
1322
|
}
|
|
1189
1323
|
};
|
|
1190
1324
|
var searchFiles_default = {
|
|
1191
|
-
...
|
|
1192
|
-
handler:
|
|
1325
|
+
...toolInfo14,
|
|
1326
|
+
handler: handler14
|
|
1193
1327
|
};
|
|
1194
1328
|
|
|
1195
1329
|
// src/tools/updateMemory.ts
|
|
1196
|
-
import { z as
|
|
1197
|
-
var
|
|
1330
|
+
import { z as z17 } from "zod";
|
|
1331
|
+
var toolInfo15 = {
|
|
1198
1332
|
name: "updateMemory",
|
|
1199
|
-
description:
|
|
1200
|
-
parameters:
|
|
1201
|
-
operation:
|
|
1202
|
-
topic:
|
|
1203
|
-
content:
|
|
1333
|
+
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.',
|
|
1334
|
+
parameters: z17.object({
|
|
1335
|
+
operation: z17.enum(["append", "replace", "remove"]).describe("The operation to perform."),
|
|
1336
|
+
topic: z17.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
|
|
1337
|
+
content: z17.string().optional().describe("The content for append or replace operations. Must be omitted for remove operation.")
|
|
1204
1338
|
}).superRefine((data, ctx) => {
|
|
1205
1339
|
if (data.operation === "append" || data.operation === "replace") {
|
|
1206
1340
|
if (data.content === void 0) {
|
|
@@ -1221,7 +1355,7 @@ var toolInfo13 = {
|
|
|
1221
1355
|
}
|
|
1222
1356
|
})
|
|
1223
1357
|
};
|
|
1224
|
-
var
|
|
1358
|
+
var handler15 = async (provider, args) => {
|
|
1225
1359
|
if (!provider.updateMemory) {
|
|
1226
1360
|
return {
|
|
1227
1361
|
type: "Error" /* Error */,
|
|
@@ -1231,7 +1365,7 @@ var handler13 = async (provider, args) => {
|
|
|
1231
1365
|
}
|
|
1232
1366
|
};
|
|
1233
1367
|
}
|
|
1234
|
-
const params =
|
|
1368
|
+
const params = toolInfo15.parameters.parse(args);
|
|
1235
1369
|
await provider.updateMemory(params.operation, params.topic ?? void 0, "content" in params ? params.content : void 0);
|
|
1236
1370
|
switch (params.operation) {
|
|
1237
1371
|
case "append":
|
|
@@ -1261,18 +1395,49 @@ var handler13 = async (provider, args) => {
|
|
|
1261
1395
|
}
|
|
1262
1396
|
};
|
|
1263
1397
|
var updateMemory_default = {
|
|
1264
|
-
...
|
|
1265
|
-
handler:
|
|
1398
|
+
...toolInfo15,
|
|
1399
|
+
handler: handler15
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
// src/tools/updateTodoItem.ts
|
|
1403
|
+
var toolInfo16 = {
|
|
1404
|
+
name: "updateTodoItem",
|
|
1405
|
+
description: "Add or update a to-do item.",
|
|
1406
|
+
parameters: UpdateTodoItemInputSchema
|
|
1407
|
+
};
|
|
1408
|
+
var handler16 = async (provider, args) => {
|
|
1409
|
+
if (!provider.updateTodoItem) {
|
|
1410
|
+
return {
|
|
1411
|
+
type: "Error" /* Error */,
|
|
1412
|
+
message: {
|
|
1413
|
+
type: "error-text",
|
|
1414
|
+
value: "Not possible to update a to-do item."
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
const input = toolInfo16.parameters.parse(args);
|
|
1419
|
+
const result = await provider.updateTodoItem(input);
|
|
1420
|
+
return {
|
|
1421
|
+
type: "Reply" /* Reply */,
|
|
1422
|
+
message: {
|
|
1423
|
+
type: "json",
|
|
1424
|
+
value: result
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
};
|
|
1428
|
+
var updateTodoItem_default = {
|
|
1429
|
+
...toolInfo16,
|
|
1430
|
+
handler: handler16
|
|
1266
1431
|
};
|
|
1267
1432
|
|
|
1268
1433
|
// src/tools/writeToFile.ts
|
|
1269
|
-
import { z as
|
|
1270
|
-
var
|
|
1434
|
+
import { z as z18 } from "zod";
|
|
1435
|
+
var toolInfo17 = {
|
|
1271
1436
|
name: "writeToFile",
|
|
1272
1437
|
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.",
|
|
1273
|
-
parameters:
|
|
1274
|
-
path:
|
|
1275
|
-
content:
|
|
1438
|
+
parameters: z18.object({
|
|
1439
|
+
path: z18.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
1440
|
+
content: z18.string().describe(
|
|
1276
1441
|
"The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified."
|
|
1277
1442
|
).meta({ usageValue: "Your file content here" })
|
|
1278
1443
|
}).meta({
|
|
@@ -1298,7 +1463,7 @@ export default App;
|
|
|
1298
1463
|
]
|
|
1299
1464
|
})
|
|
1300
1465
|
};
|
|
1301
|
-
var
|
|
1466
|
+
var handler17 = async (provider, args) => {
|
|
1302
1467
|
if (!provider.writeFile) {
|
|
1303
1468
|
return {
|
|
1304
1469
|
type: "Error" /* Error */,
|
|
@@ -1308,7 +1473,7 @@ var handler14 = async (provider, args) => {
|
|
|
1308
1473
|
}
|
|
1309
1474
|
};
|
|
1310
1475
|
}
|
|
1311
|
-
const parsed =
|
|
1476
|
+
const parsed = toolInfo17.parameters.safeParse(args);
|
|
1312
1477
|
if (!parsed.success) {
|
|
1313
1478
|
return {
|
|
1314
1479
|
type: "Error" /* Error */,
|
|
@@ -1331,8 +1496,8 @@ var handler14 = async (provider, args) => {
|
|
|
1331
1496
|
};
|
|
1332
1497
|
};
|
|
1333
1498
|
var writeToFile_default = {
|
|
1334
|
-
...
|
|
1335
|
-
handler:
|
|
1499
|
+
...toolInfo17,
|
|
1500
|
+
handler: handler17
|
|
1336
1501
|
};
|
|
1337
1502
|
|
|
1338
1503
|
// src/UsageMeter.ts
|
|
@@ -1484,15 +1649,21 @@ var UsageMeter = class {
|
|
|
1484
1649
|
};
|
|
1485
1650
|
export {
|
|
1486
1651
|
MockProvider,
|
|
1652
|
+
TodoItemSchema,
|
|
1653
|
+
TodoStatus,
|
|
1487
1654
|
ToolResponseType,
|
|
1655
|
+
UpdateTodoItemInputSchema,
|
|
1656
|
+
UpdateTodoItemOutputSchema,
|
|
1488
1657
|
UsageMeter,
|
|
1489
1658
|
askFollowupQuestion_default as askFollowupQuestion,
|
|
1490
1659
|
computeRateLimitBackoffSeconds,
|
|
1491
1660
|
configSchema,
|
|
1492
1661
|
executeCommand_default as executeCommand,
|
|
1493
1662
|
fetchUrl_default as fetchUrl,
|
|
1663
|
+
getTodoItem_default as getTodoItem,
|
|
1494
1664
|
listFiles_default as listFiles,
|
|
1495
1665
|
listMemoryTopics_default as listMemoryTopics,
|
|
1666
|
+
listTodoItems_default as listTodoItems,
|
|
1496
1667
|
parseJsonFromMarkdown,
|
|
1497
1668
|
readBinaryFile_default as readBinaryFile,
|
|
1498
1669
|
readFile_default as readFile,
|
|
@@ -1504,5 +1675,6 @@ export {
|
|
|
1504
1675
|
responsePrompts,
|
|
1505
1676
|
searchFiles_default as searchFiles,
|
|
1506
1677
|
updateMemory_default as updateMemory,
|
|
1678
|
+
updateTodoItem_default as updateTodoItem,
|
|
1507
1679
|
writeToFile_default as writeToFile
|
|
1508
1680
|
};
|