@polka-codes/cli 0.9.5 → 0.9.7
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 +72 -51
- package/package.json +4 -4
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.7";
|
|
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 (
|
|
77471
|
-
try {
|
|
77472
|
-
await executeCommand(formatCommand, false);
|
|
77473
|
-
} catch (error81) {
|
|
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) {
|
|
77479
|
+
const script = this.config.scripts?.[scriptName];
|
|
77480
|
+
const command = typeof script === "string" ? script : script?.command;
|
|
77481
|
+
if (command) {
|
|
77480
77482
|
try {
|
|
77481
|
-
const { exitCode, stdout, stderr } = await executeCommand(
|
|
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
|
|
78018
|
+
|
|
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\`.
|
|
78014
78022
|
|
|
78015
|
-
|
|
78016
|
-
|
|
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
|
|
|
@@ -110740,15 +110749,9 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110740
110749
|
try {
|
|
110741
110750
|
spinner.text = `Checking out PR #${prNumber}...`;
|
|
110742
110751
|
execSync3(`gh pr checkout ${prNumber}`, { stdio: "pipe" });
|
|
110743
|
-
} catch (
|
|
110752
|
+
} catch (error120) {
|
|
110744
110753
|
spinner.fail(`Error checking out PR #${prNumber}. Make sure the PR number is correct and you have access to the repository.`);
|
|
110745
|
-
|
|
110746
|
-
}
|
|
110747
|
-
const gitRoot = execSync3("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
|
|
110748
|
-
const remoteUrl = execSync3("git remote get-url origin", { cwd: gitRoot, encoding: "utf-8" }).trim();
|
|
110749
|
-
const remoteMatch = remoteUrl.match(/github\.com[/:](?<owner>[^/]+)\/(?<repo>[^/]+)\.git$/);
|
|
110750
|
-
if (!remoteMatch?.groups) {
|
|
110751
|
-
spinner.fail("Could not determine GitHub repository owner and repo from remote URL.");
|
|
110754
|
+
console.error(error120);
|
|
110752
110755
|
process.exit(1);
|
|
110753
110756
|
}
|
|
110754
110757
|
spinner.text = "Fetching pull request details...";
|
|
@@ -110767,6 +110770,7 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110767
110770
|
} catch (_error) {
|
|
110768
110771
|
console.warn("Warning: Could not retrieve file changes list");
|
|
110769
110772
|
}
|
|
110773
|
+
printChangedFiles(changedFiles, spinner, isJsonOutput);
|
|
110770
110774
|
spinner.text = "Generating review...";
|
|
110771
110775
|
const result = await reviewDiff(sharedAiOptions, {
|
|
110772
110776
|
commitRange: `${defaultBranch}...HEAD`,
|
|
@@ -110792,6 +110796,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110792
110796
|
if (hasStagedChanges) {
|
|
110793
110797
|
spinner.text = "Generating review for staged changes...";
|
|
110794
110798
|
const stagedFiles = changedFiles.filter((file4) => file4.status.includes("staged"));
|
|
110799
|
+
printChangedFiles(stagedFiles, spinner, isJsonOutput);
|
|
110795
110800
|
const result2 = await reviewDiff(sharedAiOptions, {
|
|
110796
110801
|
staged: true,
|
|
110797
110802
|
changedFiles: stagedFiles
|
|
@@ -110807,6 +110812,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110807
110812
|
if (hasUnstagedChanges) {
|
|
110808
110813
|
spinner.text = "Generating review for unstaged changes...";
|
|
110809
110814
|
const unstagedFiles = changedFiles.filter((file4) => file4.status.includes("unstaged") || file4.status.includes("Untracked"));
|
|
110815
|
+
printChangedFiles(unstagedFiles, spinner, isJsonOutput);
|
|
110810
110816
|
const result2 = await reviewDiff(sharedAiOptions, {
|
|
110811
110817
|
staged: false,
|
|
110812
110818
|
changedFiles: unstagedFiles
|
|
@@ -110843,6 +110849,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
|
|
|
110843
110849
|
} catch (_error) {
|
|
110844
110850
|
console.warn("Warning: Could not retrieve file changes list");
|
|
110845
110851
|
}
|
|
110852
|
+
printChangedFiles(branchChangedFiles, spinner, isJsonOutput);
|
|
110846
110853
|
spinner.text = `Generating review for changes between '${defaultBranch}' and '${currentBranch}'...`;
|
|
110847
110854
|
const result = await reviewDiff(sharedAiOptions, {
|
|
110848
110855
|
commitRange: `${defaultBranch}...${currentBranch}`,
|
|
@@ -110874,6 +110881,20 @@ ${item.review}
|
|
|
110874
110881
|
}
|
|
110875
110882
|
return formatted;
|
|
110876
110883
|
}
|
|
110884
|
+
function printChangedFiles(changedFiles, spinner, isJsonOutput) {
|
|
110885
|
+
if (changedFiles.length === 0) {
|
|
110886
|
+
return;
|
|
110887
|
+
}
|
|
110888
|
+
spinner.stop();
|
|
110889
|
+
const stream = isJsonOutput ? process.stderr : process.stdout;
|
|
110890
|
+
const log = (message) => stream.write(`${message}
|
|
110891
|
+
`);
|
|
110892
|
+
log("Changed files:");
|
|
110893
|
+
for (const file4 of changedFiles) {
|
|
110894
|
+
log(`- ${file4.status}: ${file4.path}`);
|
|
110895
|
+
}
|
|
110896
|
+
spinner.start();
|
|
110897
|
+
}
|
|
110877
110898
|
|
|
110878
110899
|
// src/commands/task.ts
|
|
110879
110900
|
var readStdin = async (timeoutMs = 30000) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"@ai-sdk/openai": "2.0.0-beta.11",
|
|
24
24
|
"@ai-sdk/provider": "2.0.0-beta.1",
|
|
25
25
|
"@ai-sdk/provider-utils": "3.0.0-beta.5",
|
|
26
|
-
"@inquirer/prompts": "^7.
|
|
26
|
+
"@inquirer/prompts": "^7.8.0",
|
|
27
27
|
"@openrouter/ai-sdk-provider": "^1.0.0-beta.6",
|
|
28
|
-
"@polka-codes/cli-shared": "0.9.
|
|
29
|
-
"@polka-codes/core": "0.9.
|
|
28
|
+
"@polka-codes/cli-shared": "0.9.6",
|
|
29
|
+
"@polka-codes/core": "0.9.6",
|
|
30
30
|
"ai": "5.0.0-beta.24",
|
|
31
31
|
"commander": "^13.0.0",
|
|
32
32
|
"dotenv": "^16.4.7",
|