@polka-codes/core 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/_tsup-dts-rollup.d.ts +2 -1
- package/dist/index.js +51 -42
- package/package.json +1 -1
|
@@ -246,6 +246,7 @@ export declare const codeFixingStrategies = "\n====\n\nCODE FIXING STRATEGIES\n\
|
|
|
246
246
|
* Using Scripts: format, check, test
|
|
247
247
|
*/
|
|
248
248
|
declare class CoderAgent extends AgentBase {
|
|
249
|
+
#private;
|
|
249
250
|
constructor(options: CoderAgentOptions);
|
|
250
251
|
protected onBeforeInvokeTool(name: string, _args: Record<string, string>): Promise<ToolResponse | undefined>;
|
|
251
252
|
}
|
|
@@ -721,7 +722,7 @@ export declare const default_alias_1: {
|
|
|
721
722
|
export declare const default_alias_2: {
|
|
722
723
|
readonly name: "generateGithubPullRequestDetails";
|
|
723
724
|
readonly description: "Generates a GitHub pull request title and description from git commits";
|
|
724
|
-
readonly prompt: "\n# Generate Github Pull Request Details\n\nYou are given:\n- A branch name in <tool_input_branch_name>.\n- An optional context message in <tool_input_context> (which may or may not be present).\n- All commit messages combined in <tool_input_commit_messages>.\n- All diffs combined in <tool_input_commit_diff>.\n\nYour task:\n1. Consider the optional context (if provided).\n - If an issue number is found, add \"Closes #xxx\" at the beginning of the PR description\n - IMPORTANT: Use ONLY the exact format \"Closes #xxx\" at the beginning of the description\n - DO NOT use variations like \"Closes issue #xxx\" or other formats\n2. Analyze the combined commit messages and diffs.\n3. Produce a single GitHub Pull Request title.\n4. Produce a Pull Request description that explains the changes.\n\nUse the following template for the Pull Request description:\n\n---\n**Context (if provided)**:\n- Acknowledge any guiding concerns or instructions.\n\n**Summary of Changes**:\n- Provide a concise list or overview of what changed.\n\n**Highlights of Changed Code**:\n- Mention only the specific sections or functionalities updated, without showing full surrounding context.\n\n**Additional Information (if needed)**:\n- Testing steps (if applicable).\n- Any notes or caveats.\n\n---\n\nOutput format:\n<tool_output>\n <tool_output_pr_title>YOUR PR TITLE HERE</tool_output_pr_title>\n <tool_output_pr_description>\n YOUR PR DESCRIPTION HERE\n </tool_output_pr_description>\n</tool_output>\n\nBelow is an **example** of the input and output:\n\nExample Input:\n<tool_input>\n<tool_input_branch_name>feature/refactor-logging</tool_input_branch_name>\n<tool_input_context>Implementing changes for issue #123 - Focus on clean code and maintainability</tool_input_context>\n<tool_input_commit_messages>\nRemove debug logs\nRefactor order validation logic\n</tool_input_commit_messages>\n<tool_input_commit_diff>\ndiff --git a/user_service.py b/user_service.py\n- print(\"Debug info\")\n+ # Removed debug print statements\n\ndiff --git a/order_service.py b/order_service.py\n- if is_valid_order(order):\n- process_order(order)\n+ validate_and_process(order)\n</tool_input_commit_diff>\n</tool_input>\n\nExample Output:\n<tool_output>\n<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>\n<tool_output_pr_description>\
|
|
725
|
+
readonly prompt: "\n# Generate Github Pull Request Details\n\nYou are given:\n- A branch name in <tool_input_branch_name>.\n- An optional context message in <tool_input_context> (which may or may not be present).\n- All commit messages combined in <tool_input_commit_messages>.\n- All diffs combined in <tool_input_commit_diff>.\n\nYour task:\n1. Consider the optional context (if provided).\n - If an issue number is found, add \"Closes #xxx\" at the beginning of the PR description\n - IMPORTANT: Use ONLY the exact format \"Closes #xxx\" at the beginning of the description\n - DO NOT use variations like \"Closes issue #xxx\" or other formats\n2. Analyze the combined commit messages and diffs.\n3. Produce a single GitHub Pull Request title.\n4. Produce a Pull Request description that explains the changes.\n\nUse the following template for the Pull Request description:\n\n---\n**Context (if provided)**:\n- Acknowledge any guiding concerns or instructions.\n\n**Summary of Changes**:\n- Provide a concise list or overview of what changed.\n\n**Highlights of Changed Code**:\n- Mention only the specific sections or functionalities updated, without showing full surrounding context.\n\n**Additional Information (if needed)**:\n- Testing steps (if applicable).\n- Any notes or caveats.\n\n---\n\nOutput format:\n<tool_output>\n <tool_output_pr_title>YOUR PR TITLE HERE</tool_output_pr_title>\n <tool_output_pr_description>\n YOUR PR DESCRIPTION HERE\n </tool_output_pr_description>\n</tool_output>\n\nBelow is an **example** of the input and output:\n\nExample Input:\n<tool_input>\n<tool_input_branch_name>feature/refactor-logging</tool_input_branch_name>\n<tool_input_context>Implementing changes for issue #123 - Focus on clean code and maintainability</tool_input_context>\n<tool_input_commit_messages>\nRemove debug logs\nRefactor order validation logic\n</tool_input_commit_messages>\n<tool_input_commit_diff>\ndiff --git a/user_service.py b/user_service.py\n- print(\"Debug info\")\n+ # Removed debug print statements\n\ndiff --git a/order_service.py b/order_service.py\n- if is_valid_order(order):\n- process_order(order)\n+ validate_and_process(order)\n</tool_input_commit_diff>\n</tool_input>\n\nExample Output:\n<tool_output>\n<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>\n<tool_output_pr_description>\nCloses #123\n\n**Context**:\n- Implementing changes for issue #123 - Focus on clean code and maintainability\n\n**Summary of Changes**:\n- Refactored order validation logic to use a new `validate_and_process` method.\n- Removed debug print statements from `user_service.py`.\n\n**Highlights of Changed Code**:\n- `order_service.py`: Replaced direct call to `process_order` with `validate_and_process`.\n- `user_service.py`: Removed `print(\"Debug info\")`.\n</tool_output_pr_description>\n</tool_output>\n\n---\n\nUse the above format whenever you receive <tool_input> that may include a branch name, an optional context, aggregated commit messages in a single tag, and a combined diff in a single tag. Provide your final output strictly in <tool_output> with <tool_output_pr_title> and <tool_output_pr_description>. Only highlight the changed code and avoid including the context around the changes in the description.\n";
|
|
725
726
|
readonly formatInput: (params: Input) => string;
|
|
726
727
|
readonly parseOutput: (output: string) => Output;
|
|
727
728
|
};
|
package/dist/index.js
CHANGED
|
@@ -562,7 +562,7 @@ var handler8 = async (provider, args) => {
|
|
|
562
562
|
if (isEmpty) {
|
|
563
563
|
resp.push(`<read_file_file_content path="${path}" is_empty="true" />`);
|
|
564
564
|
} else {
|
|
565
|
-
resp.push(`<
|
|
565
|
+
resp.push(`<read_file_file_content path="${path}">${fileContent}</read_file_file_content>`);
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
}
|
|
@@ -871,8 +871,15 @@ var handler11 = async (provider, args) => {
|
|
|
871
871
|
message: "Not possible to replace in file. Abort."
|
|
872
872
|
};
|
|
873
873
|
}
|
|
874
|
+
const parsed = toolInfo11.parameters.safeParse(args);
|
|
875
|
+
if (!parsed.success) {
|
|
876
|
+
return {
|
|
877
|
+
type: "Invalid" /* Invalid */,
|
|
878
|
+
message: `Invalid arguments for replace_in_file: ${parsed.error.message}`
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
const { path, diff } = parsed.data;
|
|
874
882
|
try {
|
|
875
|
-
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
876
883
|
const fileContent = await provider.readFile(path, false);
|
|
877
884
|
if (fileContent == null) {
|
|
878
885
|
return {
|
|
@@ -956,8 +963,15 @@ var handler12 = async (provider, args) => {
|
|
|
956
963
|
message: "Not possible to search files. Abort."
|
|
957
964
|
};
|
|
958
965
|
}
|
|
966
|
+
const parsed = toolInfo12.parameters.safeParse(args);
|
|
967
|
+
if (!parsed.success) {
|
|
968
|
+
return {
|
|
969
|
+
type: "Invalid" /* Invalid */,
|
|
970
|
+
message: `Invalid arguments for search_files: ${parsed.error.message}`
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
const { path, regex, filePattern } = parsed.data;
|
|
959
974
|
try {
|
|
960
|
-
const { path, regex, filePattern } = toolInfo12.parameters.parse(args);
|
|
961
975
|
const files = await provider.searchFiles(path, regex, filePattern ?? "*");
|
|
962
976
|
return {
|
|
963
977
|
type: "Reply" /* Reply */,
|
|
@@ -971,8 +985,8 @@ ${files.join("\n")}
|
|
|
971
985
|
};
|
|
972
986
|
} catch (error) {
|
|
973
987
|
return {
|
|
974
|
-
type: "
|
|
975
|
-
message: `
|
|
988
|
+
type: "Error" /* Error */,
|
|
989
|
+
message: `Error searching files: ${error}`
|
|
976
990
|
};
|
|
977
991
|
}
|
|
978
992
|
};
|
|
@@ -2622,52 +2636,39 @@ var CoderAgent = class extends AgentBase {
|
|
|
2622
2636
|
usageMeter: options.usageMeter ?? new UsageMeter()
|
|
2623
2637
|
});
|
|
2624
2638
|
}
|
|
2625
|
-
async
|
|
2626
|
-
if (name !== attemptCompletion_default.name) {
|
|
2627
|
-
return;
|
|
2628
|
-
}
|
|
2639
|
+
async #runScript(scriptName, shouldReplyWithError) {
|
|
2629
2640
|
const executeCommand = this.config.provider.executeCommand;
|
|
2630
2641
|
if (!executeCommand) {
|
|
2631
2642
|
return;
|
|
2632
2643
|
}
|
|
2633
|
-
const
|
|
2634
|
-
const
|
|
2635
|
-
if (
|
|
2644
|
+
const script = this.config.scripts?.[scriptName];
|
|
2645
|
+
const command = typeof script === "string" ? script : script?.command;
|
|
2646
|
+
if (command) {
|
|
2636
2647
|
try {
|
|
2637
|
-
await executeCommand(
|
|
2638
|
-
|
|
2639
|
-
console.warn(`Failed to format code using command: ${formatCommand}`, error);
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
const check = this.config.scripts?.check;
|
|
2643
|
-
const checkCommand = typeof check === "string" ? check : check?.command;
|
|
2644
|
-
if (checkCommand) {
|
|
2645
|
-
try {
|
|
2646
|
-
const { exitCode, stdout, stderr } = await executeCommand(checkCommand, false);
|
|
2647
|
-
if (exitCode !== 0) {
|
|
2648
|
+
const { exitCode, stdout, stderr } = await executeCommand(command, false);
|
|
2649
|
+
if (exitCode !== 0 && shouldReplyWithError) {
|
|
2648
2650
|
return {
|
|
2649
2651
|
type: "Reply" /* Reply */,
|
|
2650
|
-
message: responsePrompts.commandResult(
|
|
2652
|
+
message: responsePrompts.commandResult(command, exitCode, stdout, stderr)
|
|
2651
2653
|
};
|
|
2652
2654
|
}
|
|
2653
2655
|
} catch (error) {
|
|
2654
|
-
console.warn(`Failed to
|
|
2656
|
+
console.warn(`Failed to run ${scriptName} using command: ${command}`, error);
|
|
2655
2657
|
}
|
|
2656
2658
|
}
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
if (
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
}
|
|
2659
|
+
}
|
|
2660
|
+
async onBeforeInvokeTool(name, _args) {
|
|
2661
|
+
if (name !== attemptCompletion_default.name) {
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
await this.#runScript("format", false);
|
|
2665
|
+
const checkResult = await this.#runScript("check", true);
|
|
2666
|
+
if (checkResult) {
|
|
2667
|
+
return checkResult;
|
|
2668
|
+
}
|
|
2669
|
+
const testResult = await this.#runScript("test", true);
|
|
2670
|
+
if (testResult) {
|
|
2671
|
+
return testResult;
|
|
2671
2672
|
}
|
|
2672
2673
|
}
|
|
2673
2674
|
};
|
|
@@ -3217,10 +3218,18 @@ Example Output:
|
|
|
3217
3218
|
<tool_output>
|
|
3218
3219
|
<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>
|
|
3219
3220
|
<tool_output_pr_description>
|
|
3220
|
-
|
|
3221
|
+
Closes #123
|
|
3221
3222
|
|
|
3222
|
-
|
|
3223
|
-
|
|
3223
|
+
**Context**:
|
|
3224
|
+
- Implementing changes for issue #123 - Focus on clean code and maintainability
|
|
3225
|
+
|
|
3226
|
+
**Summary of Changes**:
|
|
3227
|
+
- Refactored order validation logic to use a new \`validate_and_process\` method.
|
|
3228
|
+
- Removed debug print statements from \`user_service.py\`.
|
|
3229
|
+
|
|
3230
|
+
**Highlights of Changed Code**:
|
|
3231
|
+
- \`order_service.py\`: Replaced direct call to \`process_order\` with \`validate_and_process\`.
|
|
3232
|
+
- \`user_service.py\`: Removed \`print("Debug info")\`.
|
|
3224
3233
|
</tool_output_pr_description>
|
|
3225
3234
|
</tool_output>
|
|
3226
3235
|
|