@polka-codes/runner 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.
Files changed (2) hide show
  1. package/dist/index.js +59 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21008,7 +21008,7 @@ var {
21008
21008
  Help
21009
21009
  } = import__.default;
21010
21010
  // package.json
21011
- var version = "0.9.3";
21011
+ var version = "0.9.4";
21012
21012
 
21013
21013
  // src/runner.ts
21014
21014
  import { execSync } from "node:child_process";
@@ -56300,21 +56300,27 @@ ${instance.prompt}`;
56300
56300
  const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
56301
56301
  let respMessages = [];
56302
56302
  for (let i = 0;i < retryCount; i++) {
56303
+ if (this.#aborted) {
56304
+ break;
56305
+ }
56303
56306
  respMessages = [];
56304
56307
  let timeout;
56308
+ let requestAbortController;
56309
+ requestAbortController = new AbortController;
56310
+ this.#abortController = requestAbortController;
56305
56311
  const resetTimeout = () => {
56306
56312
  if (timeout) {
56307
56313
  clearTimeout(timeout);
56308
56314
  }
56309
- if (requestTimeoutSeconds > 0) {
56315
+ if (requestTimeoutSeconds > 0 && requestAbortController) {
56310
56316
  timeout = setTimeout(() => {
56311
- console.debug(`No data received for ${requestTimeoutSeconds} seconds. Aborting request.`);
56312
- this.abort();
56317
+ console.debug(`Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`);
56318
+ requestAbortController?.abort();
56313
56319
  }, requestTimeoutSeconds * 1000);
56314
56320
  }
56315
56321
  };
56316
- this.#abortController = new AbortController;
56317
56322
  try {
56323
+ resetTimeout();
56318
56324
  const streamTextOptions = {
56319
56325
  model: this.ai,
56320
56326
  messages,
@@ -56336,7 +56342,7 @@ ${instance.prompt}`;
56336
56342
  onError: async (error81) => {
56337
56343
  console.error("Error in stream:", error81);
56338
56344
  },
56339
- abortSignal: this.#abortController.signal
56345
+ abortSignal: requestAbortController.signal
56340
56346
  };
56341
56347
  if (this.config.toolFormat === "native") {
56342
56348
  streamTextOptions.tools = this.#toolSet;
@@ -56349,11 +56355,19 @@ ${instance.prompt}`;
56349
56355
  });
56350
56356
  const resp = await stream.response;
56351
56357
  respMessages = resp.messages;
56358
+ if (timeout) {
56359
+ clearTimeout(timeout);
56360
+ timeout = undefined;
56361
+ }
56352
56362
  } catch (error81) {
56353
56363
  if (error81 instanceof Error && error81.name === "AbortError") {
56354
- break;
56364
+ if (this.#aborted) {
56365
+ break;
56366
+ }
56367
+ console.debug(`Request attempt ${i + 1} timed out, will retry`);
56368
+ } else {
56369
+ console.error("Error in stream:", error81);
56355
56370
  }
56356
- console.error("Error in stream:", error81);
56357
56371
  } finally {
56358
56372
  if (timeout) {
56359
56373
  clearTimeout(timeout);
@@ -56365,13 +56379,15 @@ ${instance.prompt}`;
56365
56379
  if (this.#aborted) {
56366
56380
  break;
56367
56381
  }
56368
- console.debug(`Retrying request ${i + 1} of ${retryCount}`);
56382
+ if (i < retryCount - 1) {
56383
+ console.debug(`Retrying request ${i + 2} of ${retryCount}`);
56384
+ }
56369
56385
  }
56370
56386
  if (respMessages.length === 0) {
56371
56387
  if (this.#aborted) {
56372
56388
  return [];
56373
56389
  }
56374
- throw new Error("No assistant message received");
56390
+ throw new Error("No assistant message received after all retry attempts");
56375
56391
  }
56376
56392
  this.#messages.push(...respMessages);
56377
56393
  if (this.config.toolFormat === "native") {
@@ -56382,7 +56398,7 @@ ${instance.prompt}`;
56382
56398
  return [{ type: "text", content }];
56383
56399
  }
56384
56400
  return content.flatMap((part) => {
56385
- if (part.type === "text") {
56401
+ if (part.type === "text" || part.type === "reasoning") {
56386
56402
  return [{ type: "text", content: part.text }];
56387
56403
  }
56388
56404
  if (part.type === "tool-call") {
@@ -57338,37 +57354,48 @@ var prompt5 = `
57338
57354
 
57339
57355
  You are a senior software engineer reviewing code changes.
57340
57356
 
57357
+ ## Critical Instructions
57358
+ **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
57359
+
57341
57360
  ## Viewing Changes
57342
- - Use **git_diff** to inspect code.
57343
- - **Pull request**: use the provided commit range.
57344
- - **Local changes**: diff staged or unstaged files.
57361
+ - **Use git_diff** to inspect the actual code changes for each relevant file.
57362
+ - **Pull request**: use the provided commit range for the git_diff tool.
57363
+ - **Local changes**: diff staged or unstaged files using the git_diff tool.
57345
57364
  - If a pull request is present you may receive:
57346
57365
  - <pr_title>
57347
57366
  - <pr_description>
57348
57367
  - <commit_messages>
57349
57368
  - A <review_instructions> tag tells you the focus of the review.
57369
+ - File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.
57350
57370
 
57351
- ## Focus Areas
57352
- - Readability and maintainability
57353
- - Correctness, edge cases, potential bugs
57354
- - Performance implications
57355
- - Clarity of intent
57356
- - Best-practice adherence
57371
+ ## Review Guidelines
57372
+ Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
57373
+ - **Specific issues**: Point to exact problems in the changed code with line references
57374
+ - **Actionable fixes**: Provide concrete solutions, not vague suggestions
57375
+ - **Clear reasoning**: Explain why each issue matters and how to fix it
57376
+ - **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
57377
+
57378
+ ## What NOT to review
57379
+ - Existing unchanged code
57380
+ - Overall project structure or architecture (unless directly impacted by changes)
57381
+ - Generic best practices unrelated to the specific changes
57382
+ - Missing features or functionality not part of this diff
57357
57383
 
57358
57384
  ## Output Format
57359
57385
  Do **not** include praise or positive feedback. Ignore generated files such as lock files.
57386
+ Only include reviews for actual issues found in the changed code.
57360
57387
 
57361
57388
  Return your review as a JSON object inside a \`\`\`json block, wrapped like:
57362
57389
  <tool_attempt_completion>
57363
57390
  <tool_parameter_result>
57364
57391
  \`\`\`json
57365
57392
  {
57366
- "overview": "Summary of overall concerns.",
57393
+ "overview": "Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.",
57367
57394
  "specificReviews": [
57368
57395
  {
57369
57396
  "file": "path/filename.ext",
57370
57397
  "lines": "N or N-M",
57371
- "review": "Describe the issue and actionable fix or improvement."
57398
+ "review": "Specific issue with the changed code and exact actionable fix."
57372
57399
  }
57373
57400
  ]
57374
57401
  }
@@ -57396,14 +57423,21 @@ ${params.pullRequestDescription}
57396
57423
  parts.push(`<commit_messages>
57397
57424
  ${params.commitMessages}
57398
57425
  </commit_messages>`);
57426
+ }
57427
+ if (params.changedFiles && params.changedFiles.length > 0) {
57428
+ const fileList = params.changedFiles.map((file3) => `${file3.status}: ${file3.path}`).join(`
57429
+ `);
57430
+ parts.push(`<file_status>
57431
+ ${fileList}
57432
+ </file_status>`);
57399
57433
  }
57400
57434
  let instructions = "";
57401
57435
  if (params.commitRange) {
57402
- instructions = `Review the pull request. Get the diff using the git_diff tool with the commit range '${params.commitRange}'.`;
57436
+ 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.`;
57403
57437
  } else if (params.staged) {
57404
- instructions = "Review the staged changes. Get the diff using the git_diff tool with staged: true.";
57438
+ 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.";
57405
57439
  } else {
57406
- instructions = "Review the unstaged changes. Get the diff using the git_diff tool.";
57440
+ instructions = "Review the unstaged changes. Use the git_diff tool to inspect the actual code changes. File status information is already provided above.";
57407
57441
  }
57408
57442
  parts.push(`<review_instructions>
57409
57443
  ${instructions}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",