@polka-codes/cli 0.9.57 → 0.9.58

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 +30 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35579,7 +35579,7 @@ var {
35579
35579
  Help
35580
35580
  } = import__.default;
35581
35581
  // package.json
35582
- var version = "0.9.57";
35582
+ var version = "0.9.58";
35583
35583
 
35584
35584
  // src/commands/code.ts
35585
35585
  import { readFile as readFile3 } from "node:fs/promises";
@@ -78530,7 +78530,7 @@ async function generateText(input2, context) {
78530
78530
  const messages = applyCacheControl(input2.messages.map(fromJsonModelMessage), model.provider, model.modelId);
78531
78531
  for (let i = 0;i < retryCount; i++) {
78532
78532
  const abortController = new AbortController;
78533
- const timeout = setTimeout(() => abortController.abort(), requestTimeoutSeconds * 1000);
78533
+ let timeout = setTimeout(() => abortController.abort(), requestTimeoutSeconds * 1000);
78534
78534
  const usageMeterOnFinishHandler = context.parameters.usageMeter.onFinishHandler(model);
78535
78535
  try {
78536
78536
  const stream = streamText({
@@ -78539,6 +78539,8 @@ async function generateText(input2, context) {
78539
78539
  messages,
78540
78540
  tools: input2.tools,
78541
78541
  async onChunk({ chunk }) {
78542
+ clearTimeout(timeout);
78543
+ timeout = setTimeout(() => abortController.abort(), requestTimeoutSeconds * 1000);
78542
78544
  switch (chunk.type) {
78543
78545
  case "text-delta":
78544
78546
  agentCallback?.({
@@ -79656,47 +79658,35 @@ ${createJsonResponseInstruction({
79656
79658
  }
79657
79659
  \`\`\`
79658
79660
  `;
79659
- function formatReviewToolInput(params) {
79660
- const parts = [];
79661
- if (params.pullRequestTitle) {
79662
- parts.push(`<pr_title>
79663
- ${params.pullRequestTitle}
79664
- </pr_title>`);
79665
- }
79666
- if (params.pullRequestDescription) {
79667
- parts.push(`<pr_description>
79668
- ${params.pullRequestDescription}
79669
- </pr_description>`);
79670
- }
79671
- if (params.commitMessages) {
79672
- parts.push(`<commit_messages>
79673
- ${params.commitMessages}
79674
- </commit_messages>`);
79675
- }
79676
- if (params.context) {
79677
- parts.push(`<user_context>
79678
- ${params.context}
79679
- </user_context>`);
79680
- }
79681
- if (params.changedFiles && params.changedFiles.length > 0) {
79682
- const fileList = params.changedFiles.map((file2) => `${file2.status}: ${file2.path}`).join(`
79683
- `);
79684
- parts.push(`<file_status>
79685
- ${fileList}
79686
- </file_status>`);
79661
+ function formatContext(tag, value) {
79662
+ if (!value) {
79663
+ return;
79687
79664
  }
79688
- let instructions = "";
79665
+ return `<${tag}>
79666
+ ${value}
79667
+ </${tag}>`;
79668
+ }
79669
+ function getReviewInstructions(params) {
79689
79670
  if (params.commitRange) {
79690
- instructions = `Review the pull request. Use the gitDiff tool with commit range '${params.commitRange}', contextLines: 5, and includeLineNumbers: true to inspect the actual code changes. The diff will include line number annotations to help you report accurate line numbers. File status information is already provided above.`;
79691
- } else if (params.staged) {
79692
- instructions = "Review the staged changes. Use the gitDiff tool with staged: true, contextLines: 5, and includeLineNumbers: true to inspect the actual code changes. The diff will include line number annotations to help you report accurate line numbers. File status information is already provided above.";
79693
- } else {
79694
- instructions = "Review the unstaged changes. Use the gitDiff tool with contextLines: 5, and includeLineNumbers: true to inspect the actual code changes. The diff will include line number annotations to help you report accurate line numbers. File status information is already provided above.";
79671
+ return `Review the pull request. Use the gitDiff tool with commit range '${params.commitRange}' to inspect the actual code changes.`;
79672
+ }
79673
+ if (params.staged) {
79674
+ return "Review the staged changes. Use the gitDiff tool with staged: true to inspect the actual code changes.";
79695
79675
  }
79696
- parts.push(`<review_instructions>
79697
- ${instructions}
79698
- </review_instructions>`);
79699
- return parts.join(`
79676
+ return "Review the unstaged changes. Use the gitDiff tool to inspect the actual code changes.";
79677
+ }
79678
+ function formatReviewToolInput(params) {
79679
+ const fileList = params.changedFiles && params.changedFiles.length > 0 ? params.changedFiles.map((file2) => `${file2.status}: ${file2.path}`).join(`
79680
+ `) : undefined;
79681
+ const parts = [
79682
+ formatContext("pr_title", params.pullRequestTitle),
79683
+ formatContext("pr_description", params.pullRequestDescription),
79684
+ formatContext("commit_messages", params.commitMessages),
79685
+ formatContext("user_context", params.context),
79686
+ formatContext("file_status", fileList),
79687
+ formatContext("review_instructions", getReviewInstructions(params))
79688
+ ];
79689
+ return parts.filter(Boolean).join(`
79700
79690
  `);
79701
79691
  }
79702
79692
  // src/workflows/fix.workflow.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.57",
3
+ "version": "0.9.58",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",