@polka-codes/cli-shared 0.9.3 → 0.9.4
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 +58 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50997,21 +50997,27 @@ ${instance.prompt}`;
|
|
|
50997
50997
|
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
|
|
50998
50998
|
let respMessages = [];
|
|
50999
50999
|
for (let i = 0;i < retryCount; i++) {
|
|
51000
|
+
if (this.#aborted) {
|
|
51001
|
+
break;
|
|
51002
|
+
}
|
|
51000
51003
|
respMessages = [];
|
|
51001
51004
|
let timeout;
|
|
51005
|
+
let requestAbortController;
|
|
51006
|
+
requestAbortController = new AbortController;
|
|
51007
|
+
this.#abortController = requestAbortController;
|
|
51002
51008
|
const resetTimeout = () => {
|
|
51003
51009
|
if (timeout) {
|
|
51004
51010
|
clearTimeout(timeout);
|
|
51005
51011
|
}
|
|
51006
|
-
if (requestTimeoutSeconds > 0) {
|
|
51012
|
+
if (requestTimeoutSeconds > 0 && requestAbortController) {
|
|
51007
51013
|
timeout = setTimeout(() => {
|
|
51008
|
-
console.debug(`
|
|
51009
|
-
|
|
51014
|
+
console.debug(`Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`);
|
|
51015
|
+
requestAbortController?.abort();
|
|
51010
51016
|
}, requestTimeoutSeconds * 1000);
|
|
51011
51017
|
}
|
|
51012
51018
|
};
|
|
51013
|
-
this.#abortController = new AbortController;
|
|
51014
51019
|
try {
|
|
51020
|
+
resetTimeout();
|
|
51015
51021
|
const streamTextOptions = {
|
|
51016
51022
|
model: this.ai,
|
|
51017
51023
|
messages,
|
|
@@ -51033,7 +51039,7 @@ ${instance.prompt}`;
|
|
|
51033
51039
|
onError: async (error81) => {
|
|
51034
51040
|
console.error("Error in stream:", error81);
|
|
51035
51041
|
},
|
|
51036
|
-
abortSignal:
|
|
51042
|
+
abortSignal: requestAbortController.signal
|
|
51037
51043
|
};
|
|
51038
51044
|
if (this.config.toolFormat === "native") {
|
|
51039
51045
|
streamTextOptions.tools = this.#toolSet;
|
|
@@ -51046,11 +51052,19 @@ ${instance.prompt}`;
|
|
|
51046
51052
|
});
|
|
51047
51053
|
const resp = await stream.response;
|
|
51048
51054
|
respMessages = resp.messages;
|
|
51055
|
+
if (timeout) {
|
|
51056
|
+
clearTimeout(timeout);
|
|
51057
|
+
timeout = undefined;
|
|
51058
|
+
}
|
|
51049
51059
|
} catch (error81) {
|
|
51050
51060
|
if (error81 instanceof Error && error81.name === "AbortError") {
|
|
51051
|
-
|
|
51061
|
+
if (this.#aborted) {
|
|
51062
|
+
break;
|
|
51063
|
+
}
|
|
51064
|
+
console.debug(`Request attempt ${i + 1} timed out, will retry`);
|
|
51065
|
+
} else {
|
|
51066
|
+
console.error("Error in stream:", error81);
|
|
51052
51067
|
}
|
|
51053
|
-
console.error("Error in stream:", error81);
|
|
51054
51068
|
} finally {
|
|
51055
51069
|
if (timeout) {
|
|
51056
51070
|
clearTimeout(timeout);
|
|
@@ -51062,13 +51076,15 @@ ${instance.prompt}`;
|
|
|
51062
51076
|
if (this.#aborted) {
|
|
51063
51077
|
break;
|
|
51064
51078
|
}
|
|
51065
|
-
|
|
51079
|
+
if (i < retryCount - 1) {
|
|
51080
|
+
console.debug(`Retrying request ${i + 2} of ${retryCount}`);
|
|
51081
|
+
}
|
|
51066
51082
|
}
|
|
51067
51083
|
if (respMessages.length === 0) {
|
|
51068
51084
|
if (this.#aborted) {
|
|
51069
51085
|
return [];
|
|
51070
51086
|
}
|
|
51071
|
-
throw new Error("No assistant message received");
|
|
51087
|
+
throw new Error("No assistant message received after all retry attempts");
|
|
51072
51088
|
}
|
|
51073
51089
|
this.#messages.push(...respMessages);
|
|
51074
51090
|
if (this.config.toolFormat === "native") {
|
|
@@ -51079,7 +51095,7 @@ ${instance.prompt}`;
|
|
|
51079
51095
|
return [{ type: "text", content }];
|
|
51080
51096
|
}
|
|
51081
51097
|
return content.flatMap((part) => {
|
|
51082
|
-
if (part.type === "text") {
|
|
51098
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
51083
51099
|
return [{ type: "text", content: part.text }];
|
|
51084
51100
|
}
|
|
51085
51101
|
if (part.type === "tool-call") {
|
|
@@ -52035,37 +52051,48 @@ var prompt5 = `
|
|
|
52035
52051
|
|
|
52036
52052
|
You are a senior software engineer reviewing code changes.
|
|
52037
52053
|
|
|
52054
|
+
## Critical Instructions
|
|
52055
|
+
**ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
|
|
52056
|
+
|
|
52038
52057
|
## Viewing Changes
|
|
52039
|
-
- Use
|
|
52040
|
-
- **Pull request**: use the provided commit range.
|
|
52041
|
-
- **Local changes**: diff staged or unstaged files.
|
|
52058
|
+
- **Use git_diff** to inspect the actual code changes for each relevant file.
|
|
52059
|
+
- **Pull request**: use the provided commit range for the git_diff tool.
|
|
52060
|
+
- **Local changes**: diff staged or unstaged files using the git_diff tool.
|
|
52042
52061
|
- If a pull request is present you may receive:
|
|
52043
52062
|
- <pr_title>
|
|
52044
52063
|
- <pr_description>
|
|
52045
52064
|
- <commit_messages>
|
|
52046
52065
|
- A <review_instructions> tag tells you the focus of the review.
|
|
52066
|
+
- File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.
|
|
52047
52067
|
|
|
52048
|
-
##
|
|
52049
|
-
-
|
|
52050
|
-
-
|
|
52051
|
-
-
|
|
52052
|
-
-
|
|
52053
|
-
-
|
|
52068
|
+
## Review Guidelines
|
|
52069
|
+
Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
|
|
52070
|
+
- **Specific issues**: Point to exact problems in the changed code with line references
|
|
52071
|
+
- **Actionable fixes**: Provide concrete solutions, not vague suggestions
|
|
52072
|
+
- **Clear reasoning**: Explain why each issue matters and how to fix it
|
|
52073
|
+
- **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
|
|
52074
|
+
|
|
52075
|
+
## What NOT to review
|
|
52076
|
+
- Existing unchanged code
|
|
52077
|
+
- Overall project structure or architecture (unless directly impacted by changes)
|
|
52078
|
+
- Generic best practices unrelated to the specific changes
|
|
52079
|
+
- Missing features or functionality not part of this diff
|
|
52054
52080
|
|
|
52055
52081
|
## Output Format
|
|
52056
52082
|
Do **not** include praise or positive feedback. Ignore generated files such as lock files.
|
|
52083
|
+
Only include reviews for actual issues found in the changed code.
|
|
52057
52084
|
|
|
52058
52085
|
Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
52059
52086
|
<tool_attempt_completion>
|
|
52060
52087
|
<tool_parameter_result>
|
|
52061
52088
|
\`\`\`json
|
|
52062
52089
|
{
|
|
52063
|
-
"overview": "Summary of
|
|
52090
|
+
"overview": "Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.",
|
|
52064
52091
|
"specificReviews": [
|
|
52065
52092
|
{
|
|
52066
52093
|
"file": "path/filename.ext",
|
|
52067
52094
|
"lines": "N or N-M",
|
|
52068
|
-
"review": "
|
|
52095
|
+
"review": "Specific issue with the changed code and exact actionable fix."
|
|
52069
52096
|
}
|
|
52070
52097
|
]
|
|
52071
52098
|
}
|
|
@@ -52093,14 +52120,21 @@ ${params.pullRequestDescription}
|
|
|
52093
52120
|
parts.push(`<commit_messages>
|
|
52094
52121
|
${params.commitMessages}
|
|
52095
52122
|
</commit_messages>`);
|
|
52123
|
+
}
|
|
52124
|
+
if (params.changedFiles && params.changedFiles.length > 0) {
|
|
52125
|
+
const fileList = params.changedFiles.map((file3) => `${file3.status}: ${file3.path}`).join(`
|
|
52126
|
+
`);
|
|
52127
|
+
parts.push(`<file_status>
|
|
52128
|
+
${fileList}
|
|
52129
|
+
</file_status>`);
|
|
52096
52130
|
}
|
|
52097
52131
|
let instructions = "";
|
|
52098
52132
|
if (params.commitRange) {
|
|
52099
|
-
instructions = `Review the pull request.
|
|
52133
|
+
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.`;
|
|
52100
52134
|
} else if (params.staged) {
|
|
52101
|
-
instructions = "Review the staged changes.
|
|
52135
|
+
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.";
|
|
52102
52136
|
} else {
|
|
52103
|
-
instructions = "Review the unstaged changes.
|
|
52137
|
+
instructions = "Review the unstaged changes. Use the git_diff tool to inspect the actual code changes. File status information is already provided above.";
|
|
52104
52138
|
}
|
|
52105
52139
|
parts.push(`<review_instructions>
|
|
52106
52140
|
${instructions}
|