@polka-codes/cli 0.9.5 → 0.9.6
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 +70 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39731,7 +39731,7 @@ var {
|
|
|
39731
39731
|
Help
|
|
39732
39732
|
} = import__.default;
|
|
39733
39733
|
// package.json
|
|
39734
|
-
var version = "0.9.
|
|
39734
|
+
var version = "0.9.6";
|
|
39735
39735
|
|
|
39736
39736
|
// ../../node_modules/@inquirer/core/dist/esm/lib/key.js
|
|
39737
39737
|
var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
|
|
@@ -52675,7 +52675,7 @@ var handler8 = async (provider, args) => {
|
|
|
52675
52675
|
if (isEmpty) {
|
|
52676
52676
|
resp.push(`<read_file_file_content path="${path}" is_empty="true" />`);
|
|
52677
52677
|
} else {
|
|
52678
|
-
resp.push(`<
|
|
52678
|
+
resp.push(`<read_file_file_content path="${path}">${fileContent}</read_file_file_content>`);
|
|
52679
52679
|
}
|
|
52680
52680
|
}
|
|
52681
52681
|
}
|
|
@@ -52975,8 +52975,15 @@ var handler11 = async (provider, args) => {
|
|
|
52975
52975
|
message: "Not possible to replace in file. Abort."
|
|
52976
52976
|
};
|
|
52977
52977
|
}
|
|
52978
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
52979
|
+
if (!parsed.success) {
|
|
52980
|
+
return {
|
|
52981
|
+
type: "Invalid" /* Invalid */,
|
|
52982
|
+
message: `Invalid arguments for replace_in_file: ${parsed.error.message}`
|
|
52983
|
+
};
|
|
52984
|
+
}
|
|
52985
|
+
const { path, diff } = parsed.data;
|
|
52978
52986
|
try {
|
|
52979
|
-
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
52980
52987
|
const fileContent = await provider.readFile(path, false);
|
|
52981
52988
|
if (fileContent == null) {
|
|
52982
52989
|
return {
|
|
@@ -53054,8 +53061,15 @@ var handler12 = async (provider, args) => {
|
|
|
53054
53061
|
message: "Not possible to search files. Abort."
|
|
53055
53062
|
};
|
|
53056
53063
|
}
|
|
53064
|
+
const parsed = toolInfo12.parameters.safeParse(args);
|
|
53065
|
+
if (!parsed.success) {
|
|
53066
|
+
return {
|
|
53067
|
+
type: "Invalid" /* Invalid */,
|
|
53068
|
+
message: `Invalid arguments for search_files: ${parsed.error.message}`
|
|
53069
|
+
};
|
|
53070
|
+
}
|
|
53071
|
+
const { path, regex, filePattern } = parsed.data;
|
|
53057
53072
|
try {
|
|
53058
|
-
const { path, regex, filePattern } = toolInfo12.parameters.parse(args);
|
|
53059
53073
|
const files = await provider.searchFiles(path, regex, filePattern ?? "*");
|
|
53060
53074
|
return {
|
|
53061
53075
|
type: "Reply" /* Reply */,
|
|
@@ -53070,8 +53084,8 @@ ${files.join(`
|
|
|
53070
53084
|
};
|
|
53071
53085
|
} catch (error40) {
|
|
53072
53086
|
return {
|
|
53073
|
-
type: "
|
|
53074
|
-
message: `
|
|
53087
|
+
type: "Error" /* Error */,
|
|
53088
|
+
message: `Error searching files: ${error40}`
|
|
53075
53089
|
};
|
|
53076
53090
|
}
|
|
53077
53091
|
};
|
|
@@ -77457,52 +77471,39 @@ class CoderAgent extends AgentBase {
|
|
|
77457
77471
|
usageMeter: options.usageMeter ?? new UsageMeter
|
|
77458
77472
|
});
|
|
77459
77473
|
}
|
|
77460
|
-
async
|
|
77461
|
-
if (name17 !== attemptCompletion_default.name) {
|
|
77462
|
-
return;
|
|
77463
|
-
}
|
|
77474
|
+
async#runScript(scriptName, shouldReplyWithError) {
|
|
77464
77475
|
const executeCommand = this.config.provider.executeCommand;
|
|
77465
77476
|
if (!executeCommand) {
|
|
77466
77477
|
return;
|
|
77467
77478
|
}
|
|
77468
|
-
const
|
|
77469
|
-
const
|
|
77470
|
-
if (
|
|
77479
|
+
const script = this.config.scripts?.[scriptName];
|
|
77480
|
+
const command = typeof script === "string" ? script : script?.command;
|
|
77481
|
+
if (command) {
|
|
77471
77482
|
try {
|
|
77472
|
-
await executeCommand(
|
|
77473
|
-
|
|
77474
|
-
console.warn(`Failed to format code using command: ${formatCommand}`, error81);
|
|
77475
|
-
}
|
|
77476
|
-
}
|
|
77477
|
-
const check3 = this.config.scripts?.check;
|
|
77478
|
-
const checkCommand = typeof check3 === "string" ? check3 : check3?.command;
|
|
77479
|
-
if (checkCommand) {
|
|
77480
|
-
try {
|
|
77481
|
-
const { exitCode, stdout, stderr } = await executeCommand(checkCommand, false);
|
|
77482
|
-
if (exitCode !== 0) {
|
|
77483
|
+
const { exitCode, stdout, stderr } = await executeCommand(command, false);
|
|
77484
|
+
if (exitCode !== 0 && shouldReplyWithError) {
|
|
77483
77485
|
return {
|
|
77484
77486
|
type: "Reply" /* Reply */,
|
|
77485
|
-
message: responsePrompts.commandResult(
|
|
77487
|
+
message: responsePrompts.commandResult(command, exitCode, stdout, stderr)
|
|
77486
77488
|
};
|
|
77487
77489
|
}
|
|
77488
77490
|
} catch (error81) {
|
|
77489
|
-
console.warn(`Failed to
|
|
77491
|
+
console.warn(`Failed to run ${scriptName} using command: ${command}`, error81);
|
|
77490
77492
|
}
|
|
77491
77493
|
}
|
|
77492
|
-
|
|
77493
|
-
|
|
77494
|
-
if (
|
|
77495
|
-
|
|
77496
|
-
|
|
77497
|
-
|
|
77498
|
-
|
|
77499
|
-
|
|
77500
|
-
|
|
77501
|
-
|
|
77502
|
-
|
|
77503
|
-
|
|
77504
|
-
|
|
77505
|
-
}
|
|
77494
|
+
}
|
|
77495
|
+
async onBeforeInvokeTool(name17, _args) {
|
|
77496
|
+
if (name17 !== attemptCompletion_default.name) {
|
|
77497
|
+
return;
|
|
77498
|
+
}
|
|
77499
|
+
await this.#runScript("format", false);
|
|
77500
|
+
const checkResult = await this.#runScript("check", true);
|
|
77501
|
+
if (checkResult) {
|
|
77502
|
+
return checkResult;
|
|
77503
|
+
}
|
|
77504
|
+
const testResult = await this.#runScript("test", true);
|
|
77505
|
+
if (testResult) {
|
|
77506
|
+
return testResult;
|
|
77506
77507
|
}
|
|
77507
77508
|
}
|
|
77508
77509
|
}
|
|
@@ -78010,10 +78011,18 @@ Example Output:
|
|
|
78010
78011
|
<tool_output>
|
|
78011
78012
|
<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>
|
|
78012
78013
|
<tool_output_pr_description>
|
|
78013
|
-
|
|
78014
|
+
Closes #123
|
|
78015
|
+
|
|
78016
|
+
**Context**:
|
|
78017
|
+
- Implementing changes for issue #123 - Focus on clean code and maintainability
|
|
78014
78018
|
|
|
78015
|
-
|
|
78016
|
-
to use
|
|
78019
|
+
**Summary of Changes**:
|
|
78020
|
+
- Refactored order validation logic to use a new \`validate_and_process\` method.
|
|
78021
|
+
- Removed debug print statements from \`user_service.py\`.
|
|
78022
|
+
|
|
78023
|
+
**Highlights of Changed Code**:
|
|
78024
|
+
- \`order_service.py\`: Replaced direct call to \`process_order\` with \`validate_and_process\`.
|
|
78025
|
+
- \`user_service.py\`: Removed \`print("Debug info")\`.
|
|
78017
78026
|
</tool_output_pr_description>
|
|
78018
78027
|
</tool_output>
|
|
78019
78028
|
|
|
@@ -110767,6 +110776,7 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110767
110776
|
} catch (_error) {
|
|
110768
110777
|
console.warn("Warning: Could not retrieve file changes list");
|
|
110769
110778
|
}
|
|
110779
|
+
printChangedFiles(changedFiles, spinner, isJsonOutput);
|
|
110770
110780
|
spinner.text = "Generating review...";
|
|
110771
110781
|
const result = await reviewDiff(sharedAiOptions, {
|
|
110772
110782
|
commitRange: `${defaultBranch}...HEAD`,
|
|
@@ -110792,6 +110802,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110792
110802
|
if (hasStagedChanges) {
|
|
110793
110803
|
spinner.text = "Generating review for staged changes...";
|
|
110794
110804
|
const stagedFiles = changedFiles.filter((file4) => file4.status.includes("staged"));
|
|
110805
|
+
printChangedFiles(stagedFiles, spinner, isJsonOutput);
|
|
110795
110806
|
const result2 = await reviewDiff(sharedAiOptions, {
|
|
110796
110807
|
staged: true,
|
|
110797
110808
|
changedFiles: stagedFiles
|
|
@@ -110807,6 +110818,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110807
110818
|
if (hasUnstagedChanges) {
|
|
110808
110819
|
spinner.text = "Generating review for unstaged changes...";
|
|
110809
110820
|
const unstagedFiles = changedFiles.filter((file4) => file4.status.includes("unstaged") || file4.status.includes("Untracked"));
|
|
110821
|
+
printChangedFiles(unstagedFiles, spinner, isJsonOutput);
|
|
110810
110822
|
const result2 = await reviewDiff(sharedAiOptions, {
|
|
110811
110823
|
staged: false,
|
|
110812
110824
|
changedFiles: unstagedFiles
|
|
@@ -110843,6 +110855,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110843
110855
|
} catch (_error) {
|
|
110844
110856
|
console.warn("Warning: Could not retrieve file changes list");
|
|
110845
110857
|
}
|
|
110858
|
+
printChangedFiles(branchChangedFiles, spinner, isJsonOutput);
|
|
110846
110859
|
spinner.text = `Generating review for changes between '${defaultBranch}' and '${currentBranch}'...`;
|
|
110847
110860
|
const result = await reviewDiff(sharedAiOptions, {
|
|
110848
110861
|
commitRange: `${defaultBranch}...${currentBranch}`,
|
|
@@ -110874,6 +110887,20 @@ ${item.review}
|
|
|
110874
110887
|
}
|
|
110875
110888
|
return formatted;
|
|
110876
110889
|
}
|
|
110890
|
+
function printChangedFiles(changedFiles, spinner, isJsonOutput) {
|
|
110891
|
+
if (changedFiles.length === 0) {
|
|
110892
|
+
return;
|
|
110893
|
+
}
|
|
110894
|
+
spinner.stop();
|
|
110895
|
+
const stream = isJsonOutput ? process.stderr : process.stdout;
|
|
110896
|
+
const log = (message) => stream.write(`${message}
|
|
110897
|
+
`);
|
|
110898
|
+
log("Changed files:");
|
|
110899
|
+
for (const file4 of changedFiles) {
|
|
110900
|
+
log(`- ${file4.status}: ${file4.path}`);
|
|
110901
|
+
}
|
|
110902
|
+
spinner.start();
|
|
110903
|
+
}
|
|
110877
110904
|
|
|
110878
110905
|
// src/commands/task.ts
|
|
110879
110906
|
var readStdin = async (timeoutMs = 30000) => {
|