@polka-codes/core 0.9.3 → 0.9.5
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 +19 -5
- package/dist/index.js +93 -33
- package/package.json +1 -1
|
@@ -628,6 +628,7 @@ declare const _default_7: {
|
|
|
628
628
|
path: z.ZodString;
|
|
629
629
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
630
630
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
631
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
631
632
|
}, z.core.$strip>;
|
|
632
633
|
readonly permissionLevel: PermissionLevel.Read;
|
|
633
634
|
}, FilesystemProvider>;
|
|
@@ -638,6 +639,7 @@ declare const _default_7: {
|
|
|
638
639
|
path: z.ZodString;
|
|
639
640
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
640
641
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
642
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
641
643
|
}, z.core.$strip>;
|
|
642
644
|
permissionLevel: PermissionLevel.Read;
|
|
643
645
|
};
|
|
@@ -652,6 +654,7 @@ declare const _default_8: {
|
|
|
652
654
|
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
655
|
readonly parameters: z.ZodObject<{
|
|
654
656
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
657
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
655
658
|
}, z.core.$strip>;
|
|
656
659
|
readonly permissionLevel: PermissionLevel.Read;
|
|
657
660
|
}, FilesystemProvider>;
|
|
@@ -660,6 +663,7 @@ declare const _default_8: {
|
|
|
660
663
|
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
664
|
parameters: z.ZodObject<{
|
|
662
665
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
666
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
663
667
|
}, z.core.$strip>;
|
|
664
668
|
permissionLevel: PermissionLevel.Read;
|
|
665
669
|
};
|
|
@@ -738,7 +742,7 @@ export declare const default_alias_3: {
|
|
|
738
742
|
export declare const default_alias_4: {
|
|
739
743
|
readonly name: "reviewDiff";
|
|
740
744
|
readonly description: "Reviews a git diff";
|
|
741
|
-
readonly prompt: "\n# Code Review Prompt\n\nYou are a senior software engineer reviewing code changes.\n\n## Viewing Changes\n- Use
|
|
745
|
+
readonly prompt: "\n# Code Review Prompt\n\nYou are a senior software engineer reviewing code changes.\n\n## Critical Instructions\n**ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.\n\n## Viewing Changes\n- **Use git_diff** to inspect the actual code changes for each relevant file.\n - **Pull request**: use the provided commit range for the git_diff tool.\n - **Local changes**: diff staged or unstaged files using the git_diff tool.\n- If a pull request is present you may receive:\n - <pr_title>\n - <pr_description>\n - <commit_messages>\n- A <review_instructions> tag tells you the focus of the review.\n- File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.\n\n## Review Guidelines\nFocus exclusively on the changed lines (+ additions, - deletions, modified lines):\n- **Specific issues**: Point to exact problems in the changed code with line references\n- **Actionable fixes**: Provide concrete solutions, not vague suggestions\n- **Clear reasoning**: Explain why each issue matters and how to fix it\n- **Avoid generic advice**: No generic suggestions like \"add more tests\", \"improve documentation\", or \"follow best practices\" unless directly related to a specific problem in the diff\n\n## What NOT to review\n- Existing unchanged code\n- Overall project structure or architecture (unless directly impacted by changes)\n- Generic best practices unrelated to the specific changes\n- Missing features or functionality not part of this diff\n\n## Output Format\nDo **not** include praise or positive feedback. Ignore generated files such as lock files.\nOnly include reviews for actual issues found in the changed code.\n\nReturn your review as a JSON object inside a ```json block, wrapped like:\n<tool_attempt_completion>\n<tool_parameter_result>\n```json\n{\n \"overview\": \"Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.\",\n \"specificReviews\": [\n {\n \"file\": \"path/filename.ext\",\n \"lines\": \"N or N-M\",\n \"review\": \"Specific issue with the changed code and exact actionable fix.\"\n }\n ]\n}\n```\n</tool_parameter_result>\n</tool_attempt_completion>\n";
|
|
742
746
|
readonly formatInput: (params: Input_2) => string;
|
|
743
747
|
readonly parseOutput: (output: string) => Output_2;
|
|
744
748
|
readonly agent: (options: SharedAgentOptions) => AnalyzerAgent;
|
|
@@ -807,11 +811,11 @@ export { ExitReason as ExitReason_alias_1 }
|
|
|
807
811
|
export { ExitReason as ExitReason_alias_2 }
|
|
808
812
|
|
|
809
813
|
declare type FilesystemProvider = {
|
|
810
|
-
readFile?: (path: string) => Promise<string | undefined>;
|
|
814
|
+
readFile?: (path: string, includeIgnored: boolean) => Promise<string | undefined>;
|
|
811
815
|
writeFile?: (path: string, content: string) => Promise<void>;
|
|
812
816
|
removeFile?: (path: string) => Promise<void>;
|
|
813
817
|
renameFile?: (sourcePath: string, targetPath: string) => Promise<void>;
|
|
814
|
-
listFiles?: (path: string, recursive: boolean, maxCount: number) => Promise<[string[], boolean]>;
|
|
818
|
+
listFiles?: (path: string, recursive: boolean, maxCount: number, includeIgnored: boolean) => Promise<[string[], boolean]>;
|
|
815
819
|
searchFiles?: (path: string, regex: string, filePattern: string) => Promise<string[]>;
|
|
816
820
|
};
|
|
817
821
|
export { FilesystemProvider }
|
|
@@ -963,6 +967,10 @@ declare type Input_2 = {
|
|
|
963
967
|
commitMessages?: string;
|
|
964
968
|
commitRange?: string;
|
|
965
969
|
staged?: boolean;
|
|
970
|
+
changedFiles?: Array<{
|
|
971
|
+
path: string;
|
|
972
|
+
status: string;
|
|
973
|
+
}>;
|
|
966
974
|
};
|
|
967
975
|
|
|
968
976
|
declare type InteractionProvider = {
|
|
@@ -1019,11 +1027,11 @@ export { makeTool }
|
|
|
1019
1027
|
export { makeTool as makeTool_alias_1 }
|
|
1020
1028
|
|
|
1021
1029
|
declare class MockProvider implements ToolProvider {
|
|
1022
|
-
readFile(_path: string): Promise<string>;
|
|
1030
|
+
readFile(_path: string, _includeIgnored?: boolean): Promise<string>;
|
|
1023
1031
|
writeFile(_path: string, _content: string): Promise<void>;
|
|
1024
1032
|
removeFile(_path: string): Promise<void>;
|
|
1025
1033
|
renameFile(_sourcePath: string, _targetPath: string): Promise<void>;
|
|
1026
|
-
listFiles(_path: string, _recursive: boolean, _maxCount: number): Promise<[string[], boolean]>;
|
|
1034
|
+
listFiles(_path: string, _recursive: boolean, _maxCount: number, _includeIgnored?: boolean): Promise<[string[], boolean]>;
|
|
1027
1035
|
searchFiles(_path: string, _regex: string, _filePattern: string): Promise<string[]>;
|
|
1028
1036
|
executeCommand(_command: string, _needApprove: boolean): Promise<{
|
|
1029
1037
|
stdout: string;
|
|
@@ -1197,6 +1205,10 @@ declare const reviewDiff: (options: SharedAgentOptions, params: {
|
|
|
1197
1205
|
commitMessages?: string;
|
|
1198
1206
|
commitRange?: string;
|
|
1199
1207
|
staged?: boolean;
|
|
1208
|
+
changedFiles?: Array<{
|
|
1209
|
+
path: string;
|
|
1210
|
+
status: string;
|
|
1211
|
+
}>;
|
|
1200
1212
|
}) => Promise<{
|
|
1201
1213
|
overview: string;
|
|
1202
1214
|
specificReviews: {
|
|
@@ -1563,6 +1575,7 @@ export declare const toolInfo_alias_7: {
|
|
|
1563
1575
|
path: z.ZodString;
|
|
1564
1576
|
maxCount: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
1565
1577
|
recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1578
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1566
1579
|
}, z.core.$strip>;
|
|
1567
1580
|
readonly permissionLevel: PermissionLevel.Read;
|
|
1568
1581
|
};
|
|
@@ -1572,6 +1585,7 @@ export declare const toolInfo_alias_8: {
|
|
|
1572
1585
|
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.";
|
|
1573
1586
|
readonly parameters: z.ZodObject<{
|
|
1574
1587
|
path: z.ZodPipe<z.ZodTransform<string[], unknown>, z.ZodArray<z.ZodString>>;
|
|
1588
|
+
includeIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
1575
1589
|
}, z.core.$strip>;
|
|
1576
1590
|
readonly permissionLevel: PermissionLevel.Read;
|
|
1577
1591
|
};
|
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 {
|
|
@@ -857,7 +873,7 @@ var handler11 = async (provider, args) => {
|
|
|
857
873
|
}
|
|
858
874
|
try {
|
|
859
875
|
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
860
|
-
const fileContent = await provider.readFile(path);
|
|
876
|
+
const fileContent = await provider.readFile(path, false);
|
|
861
877
|
if (fileContent == null) {
|
|
862
878
|
return {
|
|
863
879
|
type: "Error" /* Error */,
|
|
@@ -1037,7 +1053,7 @@ var writeToFile_default = {
|
|
|
1037
1053
|
|
|
1038
1054
|
// src/tools/provider.ts
|
|
1039
1055
|
var MockProvider = class {
|
|
1040
|
-
async readFile(_path) {
|
|
1056
|
+
async readFile(_path, _includeIgnored) {
|
|
1041
1057
|
return "mock content";
|
|
1042
1058
|
}
|
|
1043
1059
|
async writeFile(_path, _content) {
|
|
@@ -1049,7 +1065,7 @@ var MockProvider = class {
|
|
|
1049
1065
|
async renameFile(_sourcePath, _targetPath) {
|
|
1050
1066
|
return;
|
|
1051
1067
|
}
|
|
1052
|
-
async listFiles(_path, _recursive, _maxCount) {
|
|
1068
|
+
async listFiles(_path, _recursive, _maxCount, _includeIgnored) {
|
|
1053
1069
|
return [["mock-file.txt"], false];
|
|
1054
1070
|
}
|
|
1055
1071
|
async searchFiles(_path, _regex, _filePattern) {
|
|
@@ -1811,23 +1827,32 @@ ${instance.prompt}`;
|
|
|
1811
1827
|
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
|
|
1812
1828
|
let respMessages = [];
|
|
1813
1829
|
for (let i = 0; i < retryCount; i++) {
|
|
1830
|
+
if (this.#aborted) {
|
|
1831
|
+
break;
|
|
1832
|
+
}
|
|
1814
1833
|
respMessages = [];
|
|
1815
1834
|
let timeout;
|
|
1835
|
+
let requestAbortController;
|
|
1836
|
+
requestAbortController = new AbortController();
|
|
1837
|
+
this.#abortController = requestAbortController;
|
|
1816
1838
|
const resetTimeout = () => {
|
|
1817
1839
|
if (timeout) {
|
|
1818
1840
|
clearTimeout(timeout);
|
|
1819
1841
|
}
|
|
1820
|
-
if (requestTimeoutSeconds > 0) {
|
|
1842
|
+
if (requestTimeoutSeconds > 0 && requestAbortController) {
|
|
1821
1843
|
timeout = setTimeout(() => {
|
|
1822
|
-
console.debug(
|
|
1823
|
-
|
|
1844
|
+
console.debug(
|
|
1845
|
+
`Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`
|
|
1846
|
+
);
|
|
1847
|
+
requestAbortController?.abort();
|
|
1824
1848
|
}, requestTimeoutSeconds * 1e3);
|
|
1825
1849
|
}
|
|
1826
1850
|
};
|
|
1827
|
-
this.#abortController = new AbortController();
|
|
1828
1851
|
try {
|
|
1852
|
+
resetTimeout();
|
|
1829
1853
|
const streamTextOptions = {
|
|
1830
1854
|
model: this.ai,
|
|
1855
|
+
temperature: 0,
|
|
1831
1856
|
messages,
|
|
1832
1857
|
providerOptions: this.config.parameters?.providerOptions,
|
|
1833
1858
|
onChunk: async ({ chunk }) => {
|
|
@@ -1847,7 +1872,7 @@ ${instance.prompt}`;
|
|
|
1847
1872
|
onError: async (error) => {
|
|
1848
1873
|
console.error("Error in stream:", error);
|
|
1849
1874
|
},
|
|
1850
|
-
abortSignal:
|
|
1875
|
+
abortSignal: requestAbortController.signal
|
|
1851
1876
|
};
|
|
1852
1877
|
if (this.config.toolFormat === "native") {
|
|
1853
1878
|
streamTextOptions.tools = this.#toolSet;
|
|
@@ -1860,11 +1885,19 @@ ${instance.prompt}`;
|
|
|
1860
1885
|
});
|
|
1861
1886
|
const resp = await stream.response;
|
|
1862
1887
|
respMessages = resp.messages;
|
|
1888
|
+
if (timeout) {
|
|
1889
|
+
clearTimeout(timeout);
|
|
1890
|
+
timeout = void 0;
|
|
1891
|
+
}
|
|
1863
1892
|
} catch (error) {
|
|
1864
1893
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1865
|
-
|
|
1894
|
+
if (this.#aborted) {
|
|
1895
|
+
break;
|
|
1896
|
+
}
|
|
1897
|
+
console.debug(`Request attempt ${i + 1} timed out, will retry`);
|
|
1898
|
+
} else {
|
|
1899
|
+
console.error("Error in stream:", error);
|
|
1866
1900
|
}
|
|
1867
|
-
console.error("Error in stream:", error);
|
|
1868
1901
|
} finally {
|
|
1869
1902
|
if (timeout) {
|
|
1870
1903
|
clearTimeout(timeout);
|
|
@@ -1876,16 +1909,25 @@ ${instance.prompt}`;
|
|
|
1876
1909
|
if (this.#aborted) {
|
|
1877
1910
|
break;
|
|
1878
1911
|
}
|
|
1879
|
-
|
|
1912
|
+
if (i < retryCount - 1) {
|
|
1913
|
+
console.debug(`Retrying request ${i + 2} of ${retryCount}`);
|
|
1914
|
+
}
|
|
1880
1915
|
}
|
|
1881
1916
|
if (respMessages.length === 0) {
|
|
1882
1917
|
if (this.#aborted) {
|
|
1883
1918
|
return [];
|
|
1884
1919
|
}
|
|
1885
|
-
throw new Error("No assistant message received");
|
|
1920
|
+
throw new Error("No assistant message received after all retry attempts");
|
|
1886
1921
|
}
|
|
1887
1922
|
this.#messages.push(...respMessages);
|
|
1888
1923
|
if (this.config.toolFormat === "native") {
|
|
1924
|
+
const assistantText = respMessages.map((msg) => {
|
|
1925
|
+
if (typeof msg.content === "string") {
|
|
1926
|
+
return msg.content;
|
|
1927
|
+
}
|
|
1928
|
+
return msg.content.map((part) => part.type === "text" || part.type === "reasoning" ? part.text : "").join("");
|
|
1929
|
+
}).join("\n");
|
|
1930
|
+
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: assistantText });
|
|
1889
1931
|
return respMessages.flatMap((msg) => {
|
|
1890
1932
|
if (msg.role === "assistant") {
|
|
1891
1933
|
const content = msg.content;
|
|
@@ -1893,7 +1935,7 @@ ${instance.prompt}`;
|
|
|
1893
1935
|
return [{ type: "text", content }];
|
|
1894
1936
|
}
|
|
1895
1937
|
return content.flatMap((part) => {
|
|
1896
|
-
if (part.type === "text") {
|
|
1938
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
1897
1939
|
return [{ type: "text", content: part.text }];
|
|
1898
1940
|
}
|
|
1899
1941
|
if (part.type === "tool-call") {
|
|
@@ -3360,37 +3402,48 @@ var prompt5 = `
|
|
|
3360
3402
|
|
|
3361
3403
|
You are a senior software engineer reviewing code changes.
|
|
3362
3404
|
|
|
3405
|
+
## Critical Instructions
|
|
3406
|
+
**ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
|
|
3407
|
+
|
|
3363
3408
|
## Viewing Changes
|
|
3364
|
-
- Use
|
|
3365
|
-
- **Pull request**: use the provided commit range.
|
|
3366
|
-
- **Local changes**: diff staged or unstaged files.
|
|
3409
|
+
- **Use git_diff** to inspect the actual code changes for each relevant file.
|
|
3410
|
+
- **Pull request**: use the provided commit range for the git_diff tool.
|
|
3411
|
+
- **Local changes**: diff staged or unstaged files using the git_diff tool.
|
|
3367
3412
|
- If a pull request is present you may receive:
|
|
3368
3413
|
- <pr_title>
|
|
3369
3414
|
- <pr_description>
|
|
3370
3415
|
- <commit_messages>
|
|
3371
3416
|
- A <review_instructions> tag tells you the focus of the review.
|
|
3417
|
+
- File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.
|
|
3418
|
+
|
|
3419
|
+
## Review Guidelines
|
|
3420
|
+
Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
|
|
3421
|
+
- **Specific issues**: Point to exact problems in the changed code with line references
|
|
3422
|
+
- **Actionable fixes**: Provide concrete solutions, not vague suggestions
|
|
3423
|
+
- **Clear reasoning**: Explain why each issue matters and how to fix it
|
|
3424
|
+
- **Avoid generic advice**: No generic suggestions like "add more tests", "improve documentation", or "follow best practices" unless directly related to a specific problem in the diff
|
|
3372
3425
|
|
|
3373
|
-
##
|
|
3374
|
-
-
|
|
3375
|
-
-
|
|
3376
|
-
-
|
|
3377
|
-
-
|
|
3378
|
-
- Best-practice adherence
|
|
3426
|
+
## What NOT to review
|
|
3427
|
+
- Existing unchanged code
|
|
3428
|
+
- Overall project structure or architecture (unless directly impacted by changes)
|
|
3429
|
+
- Generic best practices unrelated to the specific changes
|
|
3430
|
+
- Missing features or functionality not part of this diff
|
|
3379
3431
|
|
|
3380
3432
|
## Output Format
|
|
3381
3433
|
Do **not** include praise or positive feedback. Ignore generated files such as lock files.
|
|
3434
|
+
Only include reviews for actual issues found in the changed code.
|
|
3382
3435
|
|
|
3383
3436
|
Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
3384
3437
|
<tool_attempt_completion>
|
|
3385
3438
|
<tool_parameter_result>
|
|
3386
3439
|
\`\`\`json
|
|
3387
3440
|
{
|
|
3388
|
-
"overview": "Summary of
|
|
3441
|
+
"overview": "Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.",
|
|
3389
3442
|
"specificReviews": [
|
|
3390
3443
|
{
|
|
3391
3444
|
"file": "path/filename.ext",
|
|
3392
3445
|
"lines": "N or N-M",
|
|
3393
|
-
"review": "
|
|
3446
|
+
"review": "Specific issue with the changed code and exact actionable fix."
|
|
3394
3447
|
}
|
|
3395
3448
|
]
|
|
3396
3449
|
}
|
|
@@ -3418,14 +3471,20 @@ ${params.pullRequestDescription}
|
|
|
3418
3471
|
parts.push(`<commit_messages>
|
|
3419
3472
|
${params.commitMessages}
|
|
3420
3473
|
</commit_messages>`);
|
|
3474
|
+
}
|
|
3475
|
+
if (params.changedFiles && params.changedFiles.length > 0) {
|
|
3476
|
+
const fileList = params.changedFiles.map((file) => `${file.status}: ${file.path}`).join("\n");
|
|
3477
|
+
parts.push(`<file_status>
|
|
3478
|
+
${fileList}
|
|
3479
|
+
</file_status>`);
|
|
3421
3480
|
}
|
|
3422
3481
|
let instructions = "";
|
|
3423
3482
|
if (params.commitRange) {
|
|
3424
|
-
instructions = `Review the pull request.
|
|
3483
|
+
instructions = `Review the pull request. Use the git_diff tool with commit range '${params.commitRange}' to inspect the actual code changes. File status information is already provided above.`;
|
|
3425
3484
|
} else if (params.staged) {
|
|
3426
|
-
instructions = "Review the staged changes.
|
|
3485
|
+
instructions = "Review the staged changes. Use the git_diff tool with staged: true to inspect the actual code changes. File status information is already provided above.";
|
|
3427
3486
|
} else {
|
|
3428
|
-
instructions = "Review the unstaged changes.
|
|
3487
|
+
instructions = "Review the unstaged changes. Use the git_diff tool to inspect the actual code changes. File status information is already provided above.";
|
|
3429
3488
|
}
|
|
3430
3489
|
parts.push(`<review_instructions>
|
|
3431
3490
|
${instructions}
|
|
@@ -3459,6 +3518,7 @@ ${output}`,
|
|
|
3459
3518
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
3460
3519
|
const resp = await generateText({
|
|
3461
3520
|
model: ai,
|
|
3521
|
+
temperature: 0,
|
|
3462
3522
|
system: definition.prompt,
|
|
3463
3523
|
messages: [
|
|
3464
3524
|
{
|