@polka-codes/cli 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.
- package/dist/index.js +103 -65
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -58572,7 +58572,7 @@ var {
|
|
|
58572
58572
|
Help
|
|
58573
58573
|
} = import__.default;
|
|
58574
58574
|
// package.json
|
|
58575
|
-
var version = "0.9.
|
|
58575
|
+
var version = "0.9.25";
|
|
58576
58576
|
|
|
58577
58577
|
// src/commands/chat.ts
|
|
58578
58578
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
@@ -96532,13 +96532,14 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
96532
96532
|
return resp;
|
|
96533
96533
|
};
|
|
96534
96534
|
let hasPause = false;
|
|
96535
|
+
const toolUseContents = response.filter((c) => c.type === "tool_use");
|
|
96535
96536
|
outer:
|
|
96536
96537
|
for (const content of response) {
|
|
96537
96538
|
switch (content.type) {
|
|
96538
96539
|
case "text":
|
|
96539
96540
|
break;
|
|
96540
96541
|
case "tool_use": {
|
|
96541
|
-
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name,
|
|
96542
|
+
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, params: content.params });
|
|
96542
96543
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
96543
96544
|
switch (toolResp.type) {
|
|
96544
96545
|
case "Reply" /* Reply */: {
|
|
@@ -96547,52 +96548,73 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
96547
96548
|
break;
|
|
96548
96549
|
}
|
|
96549
96550
|
case "Exit" /* Exit */:
|
|
96551
|
+
case "HandOver" /* HandOver */:
|
|
96552
|
+
case "Delegate" /* Delegate */: {
|
|
96553
|
+
if (this.config.toolFormat === "native" && toolUseContents.length > 1) {
|
|
96554
|
+
const message = {
|
|
96555
|
+
type: "Error" /* Error */,
|
|
96556
|
+
message: {
|
|
96557
|
+
type: "error-text",
|
|
96558
|
+
value: `Error: The tool '${content.name}' must be called alone, but it was called with other tools.`
|
|
96559
|
+
},
|
|
96560
|
+
canRetry: false
|
|
96561
|
+
};
|
|
96562
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: message });
|
|
96563
|
+
toolResponses.push({
|
|
96564
|
+
type: "response",
|
|
96565
|
+
tool: content.name,
|
|
96566
|
+
response: processResponse(message.message),
|
|
96567
|
+
id: content.id
|
|
96568
|
+
});
|
|
96569
|
+
break;
|
|
96570
|
+
}
|
|
96550
96571
|
if (toolResponses.length > 0) {
|
|
96551
96572
|
break outer;
|
|
96552
96573
|
}
|
|
96553
|
-
|
|
96574
|
+
if (toolResp.type === "Exit" /* Exit */) {
|
|
96575
|
+
return { type: "exit", reason: toolResp };
|
|
96576
|
+
}
|
|
96577
|
+
if (toolResp.type === "HandOver" /* HandOver */) {
|
|
96578
|
+
await this.#callback({
|
|
96579
|
+
kind: "ToolHandOver" /* ToolHandOver */,
|
|
96580
|
+
agent: this,
|
|
96581
|
+
tool: content.name,
|
|
96582
|
+
agentName: toolResp.agentName,
|
|
96583
|
+
task: toolResp.task,
|
|
96584
|
+
context: toolResp.context,
|
|
96585
|
+
files: toolResp.files
|
|
96586
|
+
});
|
|
96587
|
+
return { type: "exit", reason: toolResp };
|
|
96588
|
+
}
|
|
96589
|
+
if (toolResp.type === "Delegate" /* Delegate */) {
|
|
96590
|
+
await this.#callback({
|
|
96591
|
+
kind: "ToolDelegate" /* ToolDelegate */,
|
|
96592
|
+
agent: this,
|
|
96593
|
+
tool: content.name,
|
|
96594
|
+
agentName: toolResp.agentName,
|
|
96595
|
+
task: toolResp.task,
|
|
96596
|
+
context: toolResp.context,
|
|
96597
|
+
files: toolResp.files
|
|
96598
|
+
});
|
|
96599
|
+
return { type: "exit", reason: toolResp };
|
|
96600
|
+
}
|
|
96601
|
+
break;
|
|
96602
|
+
}
|
|
96554
96603
|
case "Invalid" /* Invalid */: {
|
|
96555
96604
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
|
|
96556
96605
|
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
96557
|
-
|
|
96558
|
-
}
|
|
96559
|
-
case "Error" /* Error */: {
|
|
96560
|
-
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
|
|
96561
|
-
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
96562
|
-
break outer;
|
|
96563
|
-
}
|
|
96564
|
-
case "Interrupted" /* Interrupted */:
|
|
96565
|
-
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
|
|
96566
|
-
return { type: "exit", reason: toolResp };
|
|
96567
|
-
case "HandOver" /* HandOver */: {
|
|
96568
|
-
if (toolResponses.length > 0) {
|
|
96606
|
+
if (this.config.toolFormat !== "native") {
|
|
96569
96607
|
break outer;
|
|
96570
96608
|
}
|
|
96571
|
-
|
|
96572
|
-
kind: "ToolHandOver" /* ToolHandOver */,
|
|
96573
|
-
agent: this,
|
|
96574
|
-
tool: content.name,
|
|
96575
|
-
agentName: toolResp.agentName,
|
|
96576
|
-
task: toolResp.task,
|
|
96577
|
-
context: toolResp.context,
|
|
96578
|
-
files: toolResp.files
|
|
96579
|
-
});
|
|
96580
|
-
return { type: "exit", reason: toolResp };
|
|
96609
|
+
break;
|
|
96581
96610
|
}
|
|
96582
|
-
case "
|
|
96583
|
-
|
|
96611
|
+
case "Error" /* Error */: {
|
|
96612
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: toolResp.message });
|
|
96613
|
+
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
96614
|
+
if (this.config.toolFormat !== "native") {
|
|
96584
96615
|
break outer;
|
|
96585
96616
|
}
|
|
96586
|
-
|
|
96587
|
-
kind: "ToolDelegate" /* ToolDelegate */,
|
|
96588
|
-
agent: this,
|
|
96589
|
-
tool: content.name,
|
|
96590
|
-
agentName: toolResp.agentName,
|
|
96591
|
-
task: toolResp.task,
|
|
96592
|
-
context: toolResp.context,
|
|
96593
|
-
files: toolResp.files
|
|
96594
|
-
});
|
|
96595
|
-
return { type: "exit", reason: toolResp };
|
|
96617
|
+
break;
|
|
96596
96618
|
}
|
|
96597
96619
|
case "Pause" /* Pause */: {
|
|
96598
96620
|
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
@@ -97937,7 +97959,7 @@ var toolInfo15 = {
|
|
|
97937
97959
|
return val;
|
|
97938
97960
|
}, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
|
|
97939
97961
|
commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
|
|
97940
|
-
file: exports_external.string().
|
|
97962
|
+
file: exports_external.string().describe("Get the diff for a specific file."),
|
|
97941
97963
|
contextLines: exports_external.coerce.number().optional().default(5).describe("Number of context lines to include around changes."),
|
|
97942
97964
|
includeLineNumbers: exports_external.preprocess((val) => {
|
|
97943
97965
|
if (typeof val === "string") {
|
|
@@ -97971,7 +97993,7 @@ var handler15 = async (provider2, args) => {
|
|
|
97971
97993
|
commandParts.push(commitRange);
|
|
97972
97994
|
}
|
|
97973
97995
|
if (file3) {
|
|
97974
|
-
commandParts.push("--", file3);
|
|
97996
|
+
commandParts.push("--", `'${file3}'`);
|
|
97975
97997
|
}
|
|
97976
97998
|
const command = commandParts.join(" ");
|
|
97977
97999
|
try {
|
|
@@ -98034,42 +98056,58 @@ var prompt5 = `
|
|
|
98034
98056
|
You are a senior software engineer reviewing code changes.
|
|
98035
98057
|
|
|
98036
98058
|
## Critical Instructions
|
|
98037
|
-
**ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
|
|
98059
|
+
- **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
|
|
98060
|
+
- **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.
|
|
98061
|
+
|
|
98062
|
+
## File Selection for git_diff
|
|
98063
|
+
Use <file_status> to decide which files to diff. Include only files likely to contain human-authored source or meaningful configuration.
|
|
98064
|
+
|
|
98065
|
+
Include (run git_diff):
|
|
98066
|
+
- Application/source code
|
|
98067
|
+
- UI/templates/assets code
|
|
98068
|
+
- Infra/config that affects behavior
|
|
98069
|
+
|
|
98070
|
+
Exclude (do NOT run git_diff; do not review):
|
|
98071
|
+
- Lockfiles
|
|
98072
|
+
- Generated/build artifacts & deps
|
|
98073
|
+
- Test artifacts/snapshots
|
|
98074
|
+
- Data and fixtures
|
|
98075
|
+
- Binary/media/minified/maps
|
|
98038
98076
|
|
|
98039
98077
|
## Viewing Changes
|
|
98040
|
-
- **
|
|
98041
|
-
- **Pull request
|
|
98042
|
-
- **Local changes
|
|
98043
|
-
- The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions
|
|
98044
|
-
-
|
|
98078
|
+
- For each included file, **use git_diff** to inspect the actual code changes:
|
|
98079
|
+
- **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.
|
|
98080
|
+
- **Local changes:** diff staged or unstaged included files using git_diff with contextLines: 5 and includeLineNumbers: true.
|
|
98081
|
+
- The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions.
|
|
98082
|
+
- You may receive:
|
|
98045
98083
|
- <pr_title>
|
|
98046
98084
|
- <pr_description>
|
|
98047
98085
|
- <commit_messages>
|
|
98048
98086
|
- A <review_instructions> tag tells you the focus of the review.
|
|
98049
|
-
-
|
|
98087
|
+
- Use <file_status> to understand which files were modified, added, deleted, or renamed and to apply the inclusion/exclusion rules above.
|
|
98050
98088
|
|
|
98051
98089
|
## Line Number Reporting
|
|
98052
|
-
-
|
|
98053
|
-
- For additions:
|
|
98054
|
-
- For deletions:
|
|
98055
|
-
- For modifications:
|
|
98056
|
-
- Report single lines as "N" and ranges as "N-M"
|
|
98090
|
+
- Use the line numbers from the annotations in the diff output.
|
|
98091
|
+
- For additions: use the number from the [Line N] annotation after the + line.
|
|
98092
|
+
- For deletions: use the number from the [Line N removed] annotation after the - line.
|
|
98093
|
+
- For modifications: report the line number of the new/current code (from [Line N]).
|
|
98094
|
+
- Report single lines as "N" and ranges as "N-M".
|
|
98057
98095
|
|
|
98058
98096
|
## Review Guidelines
|
|
98059
98097
|
Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
|
|
98060
|
-
- **Specific issues
|
|
98061
|
-
- **Actionable fixes
|
|
98062
|
-
- **Clear reasoning
|
|
98063
|
-
- **Avoid generic advice
|
|
98098
|
+
- **Specific issues:** Point to exact problems in the changed code with accurate line references from the annotations.
|
|
98099
|
+
- **Actionable fixes:** Provide concrete solutions, not vague suggestions.
|
|
98100
|
+
- **Clear reasoning:** Explain why each issue matters and how to fix it.
|
|
98101
|
+
- **Avoid generic advice** unless directly tied to a specific problem visible in the diff.
|
|
98064
98102
|
|
|
98065
98103
|
## What NOT to review
|
|
98066
|
-
-
|
|
98067
|
-
-
|
|
98068
|
-
-
|
|
98069
|
-
- Missing features or functionality not part of this diff
|
|
98104
|
+
- Files excluded by the "File Selection for git_diff" rules (do not diff or comment on them).
|
|
98105
|
+
- Existing unchanged code.
|
|
98106
|
+
- Overall project structure/architecture unless directly impacted by the changes.
|
|
98107
|
+
- Missing features or functionality not part of this diff.
|
|
98070
98108
|
|
|
98071
98109
|
## Output Format
|
|
98072
|
-
Do
|
|
98110
|
+
Do not include praise or positive feedback.
|
|
98073
98111
|
Only include reviews for actual issues found in the changed code.
|
|
98074
98112
|
|
|
98075
98113
|
Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
@@ -98077,7 +98115,7 @@ Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
|
98077
98115
|
<tool_parameter_result>
|
|
98078
98116
|
\`\`\`json
|
|
98079
98117
|
{
|
|
98080
|
-
"overview": "Summary of specific issues found in the diff changes,
|
|
98118
|
+
"overview": "Summary of specific issues found in the diff changes, 'No issues found', or 'No reviewable changes' if all modified files were excluded.",
|
|
98081
98119
|
"specificReviews": [
|
|
98082
98120
|
{
|
|
98083
98121
|
"file": "path/filename.ext",
|
|
@@ -114582,7 +114620,7 @@ ${event.systemPrompt}`);
|
|
|
114582
114620
|
case "ToolUse" /* ToolUse */: {
|
|
114583
114621
|
customConsole.log(source_default.yellow(`
|
|
114584
114622
|
|
|
114585
|
-
Tool use:`, event.tool), event.
|
|
114623
|
+
Tool use:`, event.tool), event.params);
|
|
114586
114624
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
114587
114625
|
stats.calls++;
|
|
114588
114626
|
toolCallStats.set(event.tool, stats);
|
|
@@ -114600,7 +114638,7 @@ Tool use:`, event.tool), event.content);
|
|
|
114600
114638
|
customConsole.error(source_default.red(`
|
|
114601
114639
|
|
|
114602
114640
|
Tool error:`, event.tool));
|
|
114603
|
-
customConsole.error(
|
|
114641
|
+
customConsole.error(event.error);
|
|
114604
114642
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
114605
114643
|
stats.errors++;
|
|
114606
114644
|
toolCallStats.set(event.tool, stats);
|
|
@@ -116674,7 +116712,7 @@ async function runTask(taskArg, _options, command) {
|
|
|
116674
116712
|
console.log();
|
|
116675
116713
|
runner.printUsage();
|
|
116676
116714
|
}
|
|
116677
|
-
process.exit(
|
|
116715
|
+
process.exit(130);
|
|
116678
116716
|
};
|
|
116679
116717
|
process.on("SIGINT", sigintHandler);
|
|
116680
116718
|
const fileContents = [];
|
|
@@ -116978,7 +117016,7 @@ async function handleReviewResult(result, isJsonOutput, command) {
|
|
|
116978
117016
|
default: false
|
|
116979
117017
|
});
|
|
116980
117018
|
} catch {
|
|
116981
|
-
process.exit(
|
|
117019
|
+
process.exit(130);
|
|
116982
117020
|
}
|
|
116983
117021
|
}
|
|
116984
117022
|
if (shouldRunTask) {
|