@polka-codes/runner 0.9.23 → 0.9.25

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 +99 -61
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -30458,7 +30458,7 @@ var {
30458
30458
  Help
30459
30459
  } = import__.default;
30460
30460
  // package.json
30461
- var version = "0.9.23";
30461
+ var version = "0.9.25";
30462
30462
 
30463
30463
  // src/runner.ts
30464
30464
  import { execSync } from "node:child_process";
@@ -66765,13 +66765,14 @@ Retrying request ${i + 2} of ${retryCount}`);
66765
66765
  return resp;
66766
66766
  };
66767
66767
  let hasPause = false;
66768
+ const toolUseContents = response.filter((c) => c.type === "tool_use");
66768
66769
  outer:
66769
66770
  for (const content of response) {
66770
66771
  switch (content.type) {
66771
66772
  case "text":
66772
66773
  break;
66773
66774
  case "tool_use": {
66774
- await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
66775
+ await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, params: content.params });
66775
66776
  const toolResp = await this.#invokeTool(content.name, content.params);
66776
66777
  switch (toolResp.type) {
66777
66778
  case "Reply" /* Reply */: {
@@ -66780,52 +66781,73 @@ Retrying request ${i + 2} of ${retryCount}`);
66780
66781
  break;
66781
66782
  }
66782
66783
  case "Exit" /* Exit */:
66784
+ case "HandOver" /* HandOver */:
66785
+ case "Delegate" /* Delegate */: {
66786
+ if (this.config.toolFormat === "native" && toolUseContents.length > 1) {
66787
+ const message = {
66788
+ type: "Error" /* Error */,
66789
+ message: {
66790
+ type: "error-text",
66791
+ value: `Error: The tool '${content.name}' must be called alone, but it was called with other tools.`
66792
+ },
66793
+ canRetry: false
66794
+ };
66795
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: message });
66796
+ toolResponses.push({
66797
+ type: "response",
66798
+ tool: content.name,
66799
+ response: processResponse(message.message),
66800
+ id: content.id
66801
+ });
66802
+ break;
66803
+ }
66783
66804
  if (toolResponses.length > 0) {
66784
66805
  break outer;
66785
66806
  }
66786
- return { type: "exit", reason: toolResp };
66807
+ if (toolResp.type === "Exit" /* Exit */) {
66808
+ return { type: "exit", reason: toolResp };
66809
+ }
66810
+ if (toolResp.type === "HandOver" /* HandOver */) {
66811
+ await this.#callback({
66812
+ kind: "ToolHandOver" /* ToolHandOver */,
66813
+ agent: this,
66814
+ tool: content.name,
66815
+ agentName: toolResp.agentName,
66816
+ task: toolResp.task,
66817
+ context: toolResp.context,
66818
+ files: toolResp.files
66819
+ });
66820
+ return { type: "exit", reason: toolResp };
66821
+ }
66822
+ if (toolResp.type === "Delegate" /* Delegate */) {
66823
+ await this.#callback({
66824
+ kind: "ToolDelegate" /* ToolDelegate */,
66825
+ agent: this,
66826
+ tool: content.name,
66827
+ agentName: toolResp.agentName,
66828
+ task: toolResp.task,
66829
+ context: toolResp.context,
66830
+ files: toolResp.files
66831
+ });
66832
+ return { type: "exit", reason: toolResp };
66833
+ }
66834
+ break;
66835
+ }
66787
66836
  case "Invalid" /* Invalid */: {
66788
66837
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
66789
66838
  toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
66790
- break outer;
66791
- }
66792
- case "Error" /* Error */: {
66793
- await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
66794
- toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
66795
- break outer;
66796
- }
66797
- case "Interrupted" /* Interrupted */:
66798
- await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
66799
- return { type: "exit", reason: toolResp };
66800
- case "HandOver" /* HandOver */: {
66801
- if (toolResponses.length > 0) {
66839
+ if (this.config.toolFormat !== "native") {
66802
66840
  break outer;
66803
66841
  }
66804
- await this.#callback({
66805
- kind: "ToolHandOver" /* ToolHandOver */,
66806
- agent: this,
66807
- tool: content.name,
66808
- agentName: toolResp.agentName,
66809
- task: toolResp.task,
66810
- context: toolResp.context,
66811
- files: toolResp.files
66812
- });
66813
- return { type: "exit", reason: toolResp };
66842
+ break;
66814
66843
  }
66815
- case "Delegate" /* Delegate */: {
66816
- if (toolResponses.length > 0) {
66844
+ case "Error" /* Error */: {
66845
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: toolResp.message });
66846
+ toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
66847
+ if (this.config.toolFormat !== "native") {
66817
66848
  break outer;
66818
66849
  }
66819
- await this.#callback({
66820
- kind: "ToolDelegate" /* ToolDelegate */,
66821
- agent: this,
66822
- tool: content.name,
66823
- agentName: toolResp.agentName,
66824
- task: toolResp.task,
66825
- context: toolResp.context,
66826
- files: toolResp.files
66827
- });
66828
- return { type: "exit", reason: toolResp };
66850
+ break;
66829
66851
  }
66830
66852
  case "Pause" /* Pause */: {
66831
66853
  await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
@@ -67930,7 +67952,7 @@ var toolInfo15 = {
67930
67952
  return val;
67931
67953
  }, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
67932
67954
  commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
67933
- file: exports_external.string().optional().describe("Get the diff for a specific file."),
67955
+ file: exports_external.string().describe("Get the diff for a specific file."),
67934
67956
  contextLines: exports_external.coerce.number().optional().default(5).describe("Number of context lines to include around changes."),
67935
67957
  includeLineNumbers: exports_external.preprocess((val) => {
67936
67958
  if (typeof val === "string") {
@@ -67964,7 +67986,7 @@ var handler15 = async (provider2, args) => {
67964
67986
  commandParts.push(commitRange);
67965
67987
  }
67966
67988
  if (file3) {
67967
- commandParts.push("--", file3);
67989
+ commandParts.push("--", `'${file3}'`);
67968
67990
  }
67969
67991
  const command = commandParts.join(" ");
67970
67992
  try {
@@ -68027,42 +68049,58 @@ var prompt5 = `
68027
68049
  You are a senior software engineer reviewing code changes.
68028
68050
 
68029
68051
  ## Critical Instructions
68030
- **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
68052
+ - **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
68053
+ - **ONLY run git_diff on files that are reviewable source/config files** per the "File Selection for git_diff" rules below. Do not pass excluded files to git_diff.
68054
+
68055
+ ## File Selection for git_diff
68056
+ Use <file_status> to decide which files to diff. Include only files likely to contain human-authored source or meaningful configuration.
68057
+
68058
+ Include (run git_diff):
68059
+ - Application/source code
68060
+ - UI/templates/assets code
68061
+ - Infra/config that affects behavior
68062
+
68063
+ Exclude (do NOT run git_diff; do not review):
68064
+ - Lockfiles
68065
+ - Generated/build artifacts & deps
68066
+ - Test artifacts/snapshots
68067
+ - Data and fixtures
68068
+ - Binary/media/minified/maps
68031
68069
 
68032
68070
  ## Viewing Changes
68033
- - **Use git_diff** to inspect the actual code changes for each relevant file.
68034
- - **Pull request**: use the provided commit range for the git_diff tool with contextLines: 5 and includeLineNumbers: true
68035
- - **Local changes**: diff staged or unstaged files using the git_diff tool with contextLines: 5 and includeLineNumbers: true
68036
- - The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions
68037
- - If a pull request is present you may receive:
68071
+ - For each included file, **use git_diff** to inspect the actual code changes:
68072
+ - **Pull request:** use the provided commit range for the git_diff tool with contextLines: 5 and includeLineNumbers: true, but only surface and review the included files.
68073
+ - **Local changes:** diff staged or unstaged included files using git_diff with contextLines: 5 and includeLineNumbers: true.
68074
+ - The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions.
68075
+ - You may receive:
68038
68076
  - <pr_title>
68039
68077
  - <pr_description>
68040
68078
  - <commit_messages>
68041
68079
  - A <review_instructions> tag tells you the focus of the review.
68042
- - File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.
68080
+ - Use <file_status> to understand which files were modified, added, deleted, or renamed and to apply the inclusion/exclusion rules above.
68043
68081
 
68044
68082
  ## Line Number Reporting
68045
- - **IMPORTANT**: Use the line numbers from the annotations in the diff output
68046
- - For additions: Look for [Line N] annotations after the + lines
68047
- - For deletions: Look for [Line N removed] annotations after the - lines
68048
- - For modifications: Report the line number of the new/current code (from [Line N] annotations)
68049
- - Report single lines as "N" and ranges as "N-M"
68083
+ - Use the line numbers from the annotations in the diff output.
68084
+ - For additions: use the number from the [Line N] annotation after the + line.
68085
+ - For deletions: use the number from the [Line N removed] annotation after the - line.
68086
+ - For modifications: report the line number of the new/current code (from [Line N]).
68087
+ - Report single lines as "N" and ranges as "N-M".
68050
68088
 
68051
68089
  ## Review Guidelines
68052
68090
  Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
68053
- - **Specific issues**: Point to exact problems in the changed code with accurate line references from the annotations
68054
- - **Actionable fixes**: Provide concrete solutions, not vague suggestions
68055
- - **Clear reasoning**: Explain why each issue matters and how to fix it
68056
- - **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
68091
+ - **Specific issues:** Point to exact problems in the changed code with accurate line references from the annotations.
68092
+ - **Actionable fixes:** Provide concrete solutions, not vague suggestions.
68093
+ - **Clear reasoning:** Explain why each issue matters and how to fix it.
68094
+ - **Avoid generic advice** unless directly tied to a specific problem visible in the diff.
68057
68095
 
68058
68096
  ## What NOT to review
68059
- - Existing unchanged code
68060
- - Overall project structure or architecture (unless directly impacted by changes)
68061
- - Generic best practices unrelated to the specific changes
68062
- - Missing features or functionality not part of this diff
68097
+ - Files excluded by the "File Selection for git_diff" rules (do not diff or comment on them).
68098
+ - Existing unchanged code.
68099
+ - Overall project structure/architecture unless directly impacted by the changes.
68100
+ - Missing features or functionality not part of this diff.
68063
68101
 
68064
68102
  ## Output Format
68065
- Do **not** include praise or positive feedback. Ignore generated files such as lock files.
68103
+ Do not include praise or positive feedback.
68066
68104
  Only include reviews for actual issues found in the changed code.
68067
68105
 
68068
68106
  Return your review as a JSON object inside a \`\`\`json block, wrapped like:
@@ -68070,7 +68108,7 @@ Return your review as a JSON object inside a \`\`\`json block, wrapped like:
68070
68108
  <tool_parameter_result>
68071
68109
  \`\`\`json
68072
68110
  {
68073
- "overview": "Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.",
68111
+ "overview": "Summary of specific issues found in the diff changes, 'No issues found', or 'No reviewable changes' if all modified files were excluded.",
68074
68112
  "specificReviews": [
68075
68113
  {
68076
68114
  "file": "path/filename.ext",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.9.23",
3
+ "version": "0.9.25",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",