@polka-codes/core 0.9.4 → 0.9.6
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 +12 -5
- package/dist/index.js +85 -51
- package/package.json +1 -1
|
@@ -246,6 +246,7 @@ export declare const codeFixingStrategies = "\n====\n\nCODE FIXING STRATEGIES\n\
|
|
|
246
246
|
* Using Scripts: format, check, test
|
|
247
247
|
*/
|
|
248
248
|
declare class CoderAgent extends AgentBase {
|
|
249
|
+
#private;
|
|
249
250
|
constructor(options: CoderAgentOptions);
|
|
250
251
|
protected onBeforeInvokeTool(name: string, _args: Record<string, string>): Promise<ToolResponse | undefined>;
|
|
251
252
|
}
|
|
@@ -628,6 +629,7 @@ declare const _default_7: {
|
|
|
628
629
|
path: z.ZodString;
|
|
629
630
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
630
631
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
632
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
631
633
|
}, z.core.$strip>;
|
|
632
634
|
readonly permissionLevel: PermissionLevel.Read;
|
|
633
635
|
}, FilesystemProvider>;
|
|
@@ -638,6 +640,7 @@ declare const _default_7: {
|
|
|
638
640
|
path: z.ZodString;
|
|
639
641
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
640
642
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
643
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
641
644
|
}, z.core.$strip>;
|
|
642
645
|
permissionLevel: PermissionLevel.Read;
|
|
643
646
|
};
|
|
@@ -652,6 +655,7 @@ declare const _default_8: {
|
|
|
652
655
|
readonly 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.";
|
|
653
656
|
readonly parameters: z.ZodObject<{
|
|
654
657
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
658
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
655
659
|
}, z.core.$strip>;
|
|
656
660
|
readonly permissionLevel: PermissionLevel.Read;
|
|
657
661
|
}, FilesystemProvider>;
|
|
@@ -660,6 +664,7 @@ declare const _default_8: {
|
|
|
660
664
|
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.";
|
|
661
665
|
parameters: z.ZodObject<{
|
|
662
666
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
667
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
663
668
|
}, z.core.$strip>;
|
|
664
669
|
permissionLevel: PermissionLevel.Read;
|
|
665
670
|
};
|
|
@@ -717,7 +722,7 @@ export declare const default_alias_1: {
|
|
|
717
722
|
export declare const default_alias_2: {
|
|
718
723
|
readonly name: "generateGithubPullRequestDetails";
|
|
719
724
|
readonly description: "Generates a GitHub pull request title and description from git commits";
|
|
720
|
-
readonly prompt: "\n# Generate Github Pull Request Details\n\nYou are given:\n- A branch name in <tool_input_branch_name>.\n- An optional context message in <tool_input_context> (which may or may not be present).\n- All commit messages combined in <tool_input_commit_messages>.\n- All diffs combined in <tool_input_commit_diff>.\n\nYour task:\n1. Consider the optional context (if provided).\n - If an issue number is found, add \"Closes #xxx\" at the beginning of the PR description\n - IMPORTANT: Use ONLY the exact format \"Closes #xxx\" at the beginning of the description\n - DO NOT use variations like \"Closes issue #xxx\" or other formats\n2. Analyze the combined commit messages and diffs.\n3. Produce a single GitHub Pull Request title.\n4. Produce a Pull Request description that explains the changes.\n\nUse the following template for the Pull Request description:\n\n---\n**Context (if provided)**:\n- Acknowledge any guiding concerns or instructions.\n\n**Summary of Changes**:\n- Provide a concise list or overview of what changed.\n\n**Highlights of Changed Code**:\n- Mention only the specific sections or functionalities updated, without showing full surrounding context.\n\n**Additional Information (if needed)**:\n- Testing steps (if applicable).\n- Any notes or caveats.\n\n---\n\nOutput format:\n<tool_output>\n <tool_output_pr_title>YOUR PR TITLE HERE</tool_output_pr_title>\n <tool_output_pr_description>\n YOUR PR DESCRIPTION HERE\n </tool_output_pr_description>\n</tool_output>\n\nBelow is an **example** of the input and output:\n\nExample Input:\n<tool_input>\n<tool_input_branch_name>feature/refactor-logging</tool_input_branch_name>\n<tool_input_context>Implementing changes for issue #123 - Focus on clean code and maintainability</tool_input_context>\n<tool_input_commit_messages>\nRemove debug logs\nRefactor order validation logic\n</tool_input_commit_messages>\n<tool_input_commit_diff>\ndiff --git a/user_service.py b/user_service.py\n- print(\"Debug info\")\n+ # Removed debug print statements\n\ndiff --git a/order_service.py b/order_service.py\n- if is_valid_order(order):\n- process_order(order)\n+ validate_and_process(order)\n</tool_input_commit_diff>\n</tool_input>\n\nExample Output:\n<tool_output>\n<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>\n<tool_output_pr_description>\
|
|
725
|
+
readonly prompt: "\n# Generate Github Pull Request Details\n\nYou are given:\n- A branch name in <tool_input_branch_name>.\n- An optional context message in <tool_input_context> (which may or may not be present).\n- All commit messages combined in <tool_input_commit_messages>.\n- All diffs combined in <tool_input_commit_diff>.\n\nYour task:\n1. Consider the optional context (if provided).\n - If an issue number is found, add \"Closes #xxx\" at the beginning of the PR description\n - IMPORTANT: Use ONLY the exact format \"Closes #xxx\" at the beginning of the description\n - DO NOT use variations like \"Closes issue #xxx\" or other formats\n2. Analyze the combined commit messages and diffs.\n3. Produce a single GitHub Pull Request title.\n4. Produce a Pull Request description that explains the changes.\n\nUse the following template for the Pull Request description:\n\n---\n**Context (if provided)**:\n- Acknowledge any guiding concerns or instructions.\n\n**Summary of Changes**:\n- Provide a concise list or overview of what changed.\n\n**Highlights of Changed Code**:\n- Mention only the specific sections or functionalities updated, without showing full surrounding context.\n\n**Additional Information (if needed)**:\n- Testing steps (if applicable).\n- Any notes or caveats.\n\n---\n\nOutput format:\n<tool_output>\n <tool_output_pr_title>YOUR PR TITLE HERE</tool_output_pr_title>\n <tool_output_pr_description>\n YOUR PR DESCRIPTION HERE\n </tool_output_pr_description>\n</tool_output>\n\nBelow is an **example** of the input and output:\n\nExample Input:\n<tool_input>\n<tool_input_branch_name>feature/refactor-logging</tool_input_branch_name>\n<tool_input_context>Implementing changes for issue #123 - Focus on clean code and maintainability</tool_input_context>\n<tool_input_commit_messages>\nRemove debug logs\nRefactor order validation logic\n</tool_input_commit_messages>\n<tool_input_commit_diff>\ndiff --git a/user_service.py b/user_service.py\n- print(\"Debug info\")\n+ # Removed debug print statements\n\ndiff --git a/order_service.py b/order_service.py\n- if is_valid_order(order):\n- process_order(order)\n+ validate_and_process(order)\n</tool_input_commit_diff>\n</tool_input>\n\nExample Output:\n<tool_output>\n<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>\n<tool_output_pr_description>\nCloses #123\n\n**Context**:\n- Implementing changes for issue #123 - Focus on clean code and maintainability\n\n**Summary of Changes**:\n- Refactored order validation logic to use a new `validate_and_process` method.\n- Removed debug print statements from `user_service.py`.\n\n**Highlights of Changed Code**:\n- `order_service.py`: Replaced direct call to `process_order` with `validate_and_process`.\n- `user_service.py`: Removed `print(\"Debug info\")`.\n</tool_output_pr_description>\n</tool_output>\n\n---\n\nUse the above format whenever you receive <tool_input> that may include a branch name, an optional context, aggregated commit messages in a single tag, and a combined diff in a single tag. Provide your final output strictly in <tool_output> with <tool_output_pr_title> and <tool_output_pr_description>. Only highlight the changed code and avoid including the context around the changes in the description.\n";
|
|
721
726
|
readonly formatInput: (params: Input) => string;
|
|
722
727
|
readonly parseOutput: (output: string) => Output;
|
|
723
728
|
};
|
|
@@ -807,11 +812,11 @@ export { ExitReason as ExitReason_alias_1 }
|
|
|
807
812
|
export { ExitReason as ExitReason_alias_2 }
|
|
808
813
|
|
|
809
814
|
declare type FilesystemProvider = {
|
|
810
|
-
readFile?: (path: string) => Promise<string | undefined>;
|
|
815
|
+
readFile?: (path: string, includeIgnored: boolean) => Promise<string | undefined>;
|
|
811
816
|
writeFile?: (path: string, content: string) => Promise<void>;
|
|
812
817
|
removeFile?: (path: string) => Promise<void>;
|
|
813
818
|
renameFile?: (sourcePath: string, targetPath: string) => Promise<void>;
|
|
814
|
-
listFiles?: (path: string, recursive: boolean, maxCount: number) => Promise<[string[], boolean]>;
|
|
819
|
+
listFiles?: (path: string, recursive: boolean, maxCount: number, includeIgnored: boolean) => Promise<[string[], boolean]>;
|
|
815
820
|
searchFiles?: (path: string, regex: string, filePattern: string) => Promise<string[]>;
|
|
816
821
|
};
|
|
817
822
|
export { FilesystemProvider }
|
|
@@ -1023,11 +1028,11 @@ export { makeTool }
|
|
|
1023
1028
|
export { makeTool as makeTool_alias_1 }
|
|
1024
1029
|
|
|
1025
1030
|
declare class MockProvider implements ToolProvider {
|
|
1026
|
-
readFile(_path: string): Promise<string>;
|
|
1031
|
+
readFile(_path: string, _includeIgnored?: boolean): Promise<string>;
|
|
1027
1032
|
writeFile(_path: string, _content: string): Promise<void>;
|
|
1028
1033
|
removeFile(_path: string): Promise<void>;
|
|
1029
1034
|
renameFile(_sourcePath: string, _targetPath: string): Promise<void>;
|
|
1030
|
-
listFiles(_path: string, _recursive: boolean, _maxCount: number): Promise<[string[], boolean]>;
|
|
1035
|
+
listFiles(_path: string, _recursive: boolean, _maxCount: number, _includeIgnored?: boolean): Promise<[string[], boolean]>;
|
|
1031
1036
|
searchFiles(_path: string, _regex: string, _filePattern: string): Promise<string[]>;
|
|
1032
1037
|
executeCommand(_command: string, _needApprove: boolean): Promise<{
|
|
1033
1038
|
stdout: string;
|
|
@@ -1571,6 +1576,7 @@ export declare const toolInfo_alias_7: {
|
|
|
1571
1576
|
path: z.ZodString;
|
|
1572
1577
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
1573
1578
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1579
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1574
1580
|
}, z.core.$strip>;
|
|
1575
1581
|
readonly permissionLevel: PermissionLevel.Read;
|
|
1576
1582
|
};
|
|
@@ -1580,6 +1586,7 @@ export declare const toolInfo_alias_8: {
|
|
|
1580
1586
|
readonly 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.";
|
|
1581
1587
|
readonly parameters: z.ZodObject<{
|
|
1582
1588
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
1589
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1583
1590
|
}, z.core.$strip>;
|
|
1584
1591
|
readonly permissionLevel: PermissionLevel.Read;
|
|
1585
1592
|
};
|
package/dist/index.js
CHANGED
|
@@ -458,7 +458,15 @@ var toolInfo7 = {
|
|
|
458
458
|
if (lower === "true") return true;
|
|
459
459
|
}
|
|
460
460
|
return val;
|
|
461
|
-
}, z7.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)" })
|
|
461
|
+
}, z7.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)" }),
|
|
462
|
+
includeIgnored: z7.preprocess((val) => {
|
|
463
|
+
if (typeof val === "string") {
|
|
464
|
+
const lower = val.toLowerCase();
|
|
465
|
+
if (lower === "false") return false;
|
|
466
|
+
if (lower === "true") return true;
|
|
467
|
+
}
|
|
468
|
+
return val;
|
|
469
|
+
}, z7.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
462
470
|
}).meta({
|
|
463
471
|
examples: [
|
|
464
472
|
{
|
|
@@ -479,8 +487,8 @@ var handler7 = async (provider, args) => {
|
|
|
479
487
|
message: "Not possible to list files. Abort."
|
|
480
488
|
};
|
|
481
489
|
}
|
|
482
|
-
const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
|
|
483
|
-
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
|
|
490
|
+
const { path, maxCount, recursive, includeIgnored } = toolInfo7.parameters.parse(args);
|
|
491
|
+
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount, includeIgnored);
|
|
484
492
|
return {
|
|
485
493
|
type: "Reply" /* Reply */,
|
|
486
494
|
message: `<list_files_path>${path}</list_files_path>
|
|
@@ -509,7 +517,15 @@ var toolInfo8 = {
|
|
|
509
517
|
if (!val) return [];
|
|
510
518
|
const values = Array.isArray(val) ? val : [val];
|
|
511
519
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
512
|
-
}, z8.array(z8.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
520
|
+
}, z8.array(z8.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
521
|
+
includeIgnored: z8.preprocess((val) => {
|
|
522
|
+
if (typeof val === "string") {
|
|
523
|
+
const lower = val.toLowerCase();
|
|
524
|
+
if (lower === "false") return false;
|
|
525
|
+
if (lower === "true") return true;
|
|
526
|
+
}
|
|
527
|
+
return val;
|
|
528
|
+
}, z8.boolean().optional().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
513
529
|
}).meta({
|
|
514
530
|
examples: [
|
|
515
531
|
{
|
|
@@ -535,10 +551,10 @@ var handler8 = async (provider, args) => {
|
|
|
535
551
|
message: "Not possible to read file. Abort."
|
|
536
552
|
};
|
|
537
553
|
}
|
|
538
|
-
const { path: paths } = toolInfo8.parameters.parse(args);
|
|
554
|
+
const { path: paths, includeIgnored } = toolInfo8.parameters.parse(args);
|
|
539
555
|
const resp = [];
|
|
540
556
|
for (const path of paths) {
|
|
541
|
-
const fileContent = await provider.readFile(path);
|
|
557
|
+
const fileContent = await provider.readFile(path, includeIgnored);
|
|
542
558
|
if (!fileContent) {
|
|
543
559
|
resp.push(`<read_file_file_content path="${path}" file_not_found="true" />`);
|
|
544
560
|
} else {
|
|
@@ -546,7 +562,7 @@ var handler8 = async (provider, args) => {
|
|
|
546
562
|
if (isEmpty) {
|
|
547
563
|
resp.push(`<read_file_file_content path="${path}" is_empty="true" />`);
|
|
548
564
|
} else {
|
|
549
|
-
resp.push(`<
|
|
565
|
+
resp.push(`<read_file_file_content path="${path}">${fileContent}</read_file_file_content>`);
|
|
550
566
|
}
|
|
551
567
|
}
|
|
552
568
|
}
|
|
@@ -855,9 +871,16 @@ var handler11 = async (provider, args) => {
|
|
|
855
871
|
message: "Not possible to replace in file. Abort."
|
|
856
872
|
};
|
|
857
873
|
}
|
|
874
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
875
|
+
if (!parsed.success) {
|
|
876
|
+
return {
|
|
877
|
+
type: "Invalid" /* Invalid */,
|
|
878
|
+
message: `Invalid arguments for replace_in_file: ${parsed.error.message}`
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
const { path, diff } = parsed.data;
|
|
858
882
|
try {
|
|
859
|
-
const
|
|
860
|
-
const fileContent = await provider.readFile(path);
|
|
883
|
+
const fileContent = await provider.readFile(path, false);
|
|
861
884
|
if (fileContent == null) {
|
|
862
885
|
return {
|
|
863
886
|
type: "Error" /* Error */,
|
|
@@ -940,8 +963,15 @@ var handler12 = async (provider, args) => {
|
|
|
940
963
|
message: "Not possible to search files. Abort."
|
|
941
964
|
};
|
|
942
965
|
}
|
|
966
|
+
const parsed = toolInfo12.parameters.safeParse(args);
|
|
967
|
+
if (!parsed.success) {
|
|
968
|
+
return {
|
|
969
|
+
type: "Invalid" /* Invalid */,
|
|
970
|
+
message: `Invalid arguments for search_files: ${parsed.error.message}`
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
const { path, regex, filePattern } = parsed.data;
|
|
943
974
|
try {
|
|
944
|
-
const { path, regex, filePattern } = toolInfo12.parameters.parse(args);
|
|
945
975
|
const files = await provider.searchFiles(path, regex, filePattern ?? "*");
|
|
946
976
|
return {
|
|
947
977
|
type: "Reply" /* Reply */,
|
|
@@ -955,8 +985,8 @@ ${files.join("\n")}
|
|
|
955
985
|
};
|
|
956
986
|
} catch (error) {
|
|
957
987
|
return {
|
|
958
|
-
type: "
|
|
959
|
-
message: `
|
|
988
|
+
type: "Error" /* Error */,
|
|
989
|
+
message: `Error searching files: ${error}`
|
|
960
990
|
};
|
|
961
991
|
}
|
|
962
992
|
};
|
|
@@ -1037,7 +1067,7 @@ var writeToFile_default = {
|
|
|
1037
1067
|
|
|
1038
1068
|
// src/tools/provider.ts
|
|
1039
1069
|
var MockProvider = class {
|
|
1040
|
-
async readFile(_path) {
|
|
1070
|
+
async readFile(_path, _includeIgnored) {
|
|
1041
1071
|
return "mock content";
|
|
1042
1072
|
}
|
|
1043
1073
|
async writeFile(_path, _content) {
|
|
@@ -1049,7 +1079,7 @@ var MockProvider = class {
|
|
|
1049
1079
|
async renameFile(_sourcePath, _targetPath) {
|
|
1050
1080
|
return;
|
|
1051
1081
|
}
|
|
1052
|
-
async listFiles(_path, _recursive, _maxCount) {
|
|
1082
|
+
async listFiles(_path, _recursive, _maxCount, _includeIgnored) {
|
|
1053
1083
|
return [["mock-file.txt"], false];
|
|
1054
1084
|
}
|
|
1055
1085
|
async searchFiles(_path, _regex, _filePattern) {
|
|
@@ -1836,6 +1866,7 @@ ${instance.prompt}`;
|
|
|
1836
1866
|
resetTimeout();
|
|
1837
1867
|
const streamTextOptions = {
|
|
1838
1868
|
model: this.ai,
|
|
1869
|
+
temperature: 0,
|
|
1839
1870
|
messages,
|
|
1840
1871
|
providerOptions: this.config.parameters?.providerOptions,
|
|
1841
1872
|
onChunk: async ({ chunk }) => {
|
|
@@ -1904,6 +1935,13 @@ ${instance.prompt}`;
|
|
|
1904
1935
|
}
|
|
1905
1936
|
this.#messages.push(...respMessages);
|
|
1906
1937
|
if (this.config.toolFormat === "native") {
|
|
1938
|
+
const assistantText = respMessages.map((msg) => {
|
|
1939
|
+
if (typeof msg.content === "string") {
|
|
1940
|
+
return msg.content;
|
|
1941
|
+
}
|
|
1942
|
+
return msg.content.map((part) => part.type === "text" || part.type === "reasoning" ? part.text : "").join("");
|
|
1943
|
+
}).join("\n");
|
|
1944
|
+
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: assistantText });
|
|
1907
1945
|
return respMessages.flatMap((msg) => {
|
|
1908
1946
|
if (msg.role === "assistant") {
|
|
1909
1947
|
const content = msg.content;
|
|
@@ -2598,52 +2636,39 @@ var CoderAgent = class extends AgentBase {
|
|
|
2598
2636
|
usageMeter: options.usageMeter ?? new UsageMeter()
|
|
2599
2637
|
});
|
|
2600
2638
|
}
|
|
2601
|
-
async
|
|
2602
|
-
if (name !== attemptCompletion_default.name) {
|
|
2603
|
-
return;
|
|
2604
|
-
}
|
|
2639
|
+
async #runScript(scriptName, shouldReplyWithError) {
|
|
2605
2640
|
const executeCommand = this.config.provider.executeCommand;
|
|
2606
2641
|
if (!executeCommand) {
|
|
2607
2642
|
return;
|
|
2608
2643
|
}
|
|
2609
|
-
const
|
|
2610
|
-
const
|
|
2611
|
-
if (
|
|
2644
|
+
const script = this.config.scripts?.[scriptName];
|
|
2645
|
+
const command = typeof script === "string" ? script : script?.command;
|
|
2646
|
+
if (command) {
|
|
2612
2647
|
try {
|
|
2613
|
-
await executeCommand(
|
|
2614
|
-
|
|
2615
|
-
console.warn(`Failed to format code using command: ${formatCommand}`, error);
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
const check = this.config.scripts?.check;
|
|
2619
|
-
const checkCommand = typeof check === "string" ? check : check?.command;
|
|
2620
|
-
if (checkCommand) {
|
|
2621
|
-
try {
|
|
2622
|
-
const { exitCode, stdout, stderr } = await executeCommand(checkCommand, false);
|
|
2623
|
-
if (exitCode !== 0) {
|
|
2648
|
+
const { exitCode, stdout, stderr } = await executeCommand(command, false);
|
|
2649
|
+
if (exitCode !== 0 && shouldReplyWithError) {
|
|
2624
2650
|
return {
|
|
2625
2651
|
type: "Reply" /* Reply */,
|
|
2626
|
-
message: responsePrompts.commandResult(
|
|
2652
|
+
message: responsePrompts.commandResult(command, exitCode, stdout, stderr)
|
|
2627
2653
|
};
|
|
2628
2654
|
}
|
|
2629
2655
|
} catch (error) {
|
|
2630
|
-
console.warn(`Failed to
|
|
2656
|
+
console.warn(`Failed to run ${scriptName} using command: ${command}`, error);
|
|
2631
2657
|
}
|
|
2632
2658
|
}
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
if (
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
}
|
|
2659
|
+
}
|
|
2660
|
+
async onBeforeInvokeTool(name, _args) {
|
|
2661
|
+
if (name !== attemptCompletion_default.name) {
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
await this.#runScript("format", false);
|
|
2665
|
+
const checkResult = await this.#runScript("check", true);
|
|
2666
|
+
if (checkResult) {
|
|
2667
|
+
return checkResult;
|
|
2668
|
+
}
|
|
2669
|
+
const testResult = await this.#runScript("test", true);
|
|
2670
|
+
if (testResult) {
|
|
2671
|
+
return testResult;
|
|
2647
2672
|
}
|
|
2648
2673
|
}
|
|
2649
2674
|
};
|
|
@@ -3193,10 +3218,18 @@ Example Output:
|
|
|
3193
3218
|
<tool_output>
|
|
3194
3219
|
<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>
|
|
3195
3220
|
<tool_output_pr_description>
|
|
3196
|
-
|
|
3221
|
+
Closes #123
|
|
3222
|
+
|
|
3223
|
+
**Context**:
|
|
3224
|
+
- Implementing changes for issue #123 - Focus on clean code and maintainability
|
|
3197
3225
|
|
|
3198
|
-
|
|
3199
|
-
to use
|
|
3226
|
+
**Summary of Changes**:
|
|
3227
|
+
- Refactored order validation logic to use a new \`validate_and_process\` method.
|
|
3228
|
+
- Removed debug print statements from \`user_service.py\`.
|
|
3229
|
+
|
|
3230
|
+
**Highlights of Changed Code**:
|
|
3231
|
+
- \`order_service.py\`: Replaced direct call to \`process_order\` with \`validate_and_process\`.
|
|
3232
|
+
- \`user_service.py\`: Removed \`print("Debug info")\`.
|
|
3200
3233
|
</tool_output_pr_description>
|
|
3201
3234
|
</tool_output>
|
|
3202
3235
|
|
|
@@ -3494,6 +3527,7 @@ ${output}`,
|
|
|
3494
3527
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
3495
3528
|
const resp = await generateText({
|
|
3496
3529
|
model: ai,
|
|
3530
|
+
temperature: 0,
|
|
3497
3531
|
system: definition.prompt,
|
|
3498
3532
|
messages: [
|
|
3499
3533
|
{
|