@polka-codes/cli 0.9.56 → 0.9.57
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 -79
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35579,7 +35579,7 @@ var {
|
|
|
35579
35579
|
Help
|
|
35580
35580
|
} = import__.default;
|
|
35581
35581
|
// package.json
|
|
35582
|
-
var version = "0.9.
|
|
35582
|
+
var version = "0.9.57";
|
|
35583
35583
|
|
|
35584
35584
|
// src/commands/code.ts
|
|
35585
35585
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
@@ -77966,7 +77966,7 @@ var toolInfo18 = {
|
|
|
77966
77966
|
return true;
|
|
77967
77967
|
}
|
|
77968
77968
|
return val;
|
|
77969
|
-
}, exports_external.boolean().optional().default(
|
|
77969
|
+
}, exports_external.boolean().optional().default(true)).describe("Annotate the diff with line numbers for additions and deletions.")
|
|
77970
77970
|
})
|
|
77971
77971
|
};
|
|
77972
77972
|
var handler18 = async (provider3, args) => {
|
|
@@ -79259,13 +79259,18 @@ ${createJsonResponseInstruction({
|
|
|
79259
79259
|
bailReason: "Unable to identify the root cause of the error. The error message is ambiguous and requires human investigation."
|
|
79260
79260
|
})}
|
|
79261
79261
|
`;
|
|
79262
|
-
function getFixUserPrompt(command, exitCode, stdout, stderr, task) {
|
|
79262
|
+
function getFixUserPrompt(command, exitCode, stdout, stderr, task, context) {
|
|
79263
79263
|
const taskContext = task ? `
|
|
79264
79264
|
## Original Task
|
|
79265
79265
|
|
|
79266
79266
|
${task}
|
|
79267
79267
|
` : "";
|
|
79268
|
-
|
|
79268
|
+
const contextSection = context ? `
|
|
79269
|
+
## User Context
|
|
79270
|
+
|
|
79271
|
+
${context}
|
|
79272
|
+
` : "";
|
|
79273
|
+
return `## Context${taskContext}${contextSection}
|
|
79269
79274
|
|
|
79270
79275
|
The following command failed with exit code ${exitCode}:
|
|
79271
79276
|
\`${command}\`
|
|
@@ -79563,82 +79568,93 @@ ${createJsonResponseInstruction({
|
|
|
79563
79568
|
`;
|
|
79564
79569
|
// src/workflows/prompts/review.ts
|
|
79565
79570
|
var CODE_REVIEW_SYSTEM_PROMPT = `Role: Senior software engineer.
|
|
79566
|
-
Goal: Review code changes and provide
|
|
79571
|
+
Goal: Review code changes and provide comprehensive, actionable feedback on issues found.
|
|
79567
79572
|
|
|
79568
79573
|
${TOOL_USAGE_INSTRUCTION}
|
|
79569
79574
|
|
|
79570
|
-
|
|
79571
|
-
|
|
79572
|
-
|
|
79573
|
-
|
|
79574
|
-
|
|
79575
|
-
-
|
|
79576
|
-
|
|
79577
|
-
|
|
79578
|
-
|
|
79579
|
-
##
|
|
79580
|
-
|
|
79581
|
-
|
|
79582
|
-
|
|
79583
|
-
-
|
|
79584
|
-
-
|
|
79585
|
-
-
|
|
79586
|
-
|
|
79587
|
-
|
|
79588
|
-
-
|
|
79589
|
-
-
|
|
79590
|
-
-
|
|
79591
|
-
|
|
79592
|
-
|
|
79593
|
-
|
|
79594
|
-
|
|
79595
|
-
-
|
|
79596
|
-
|
|
79597
|
-
|
|
79598
|
-
- The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions.
|
|
79599
|
-
- You may receive:
|
|
79600
|
-
- <pr_title>
|
|
79601
|
-
- <pr_description>
|
|
79602
|
-
- <commit_messages>
|
|
79603
|
-
- A <review_instructions> tag tells you the focus of the review.
|
|
79604
|
-
- Use <file_status> to understand which files were modified, added, deleted, or renamed and to apply the inclusion/exclusion rules above.
|
|
79605
|
-
|
|
79606
|
-
|
|
79607
|
-
## Line Number Reporting
|
|
79608
|
-
- Use the line numbers from the annotations in the diff output.
|
|
79609
|
-
- For additions: use the number from the [Line N] annotation after the + line.
|
|
79610
|
-
- For deletions: use the number from the [Line N removed] annotation after the - line.
|
|
79611
|
-
- For modifications: report the line number of the new/current code (from [Line N]).
|
|
79612
|
-
- Report single lines as "N" and ranges as "N-M".
|
|
79613
|
-
|
|
79614
|
-
|
|
79615
|
-
## Review Guidelines
|
|
79616
|
-
Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
|
|
79617
|
-
- **Specific issues:** Point to exact problems in the changed code with accurate line references from the annotations.
|
|
79618
|
-
- **Actionable fixes:** Provide concrete solutions, not vague suggestions.
|
|
79619
|
-
- **Clear reasoning:** Explain why each issue matters and how to fix it.
|
|
79620
|
-
- **Avoid generic advice** unless directly tied to a specific problem visible in the diff.
|
|
79621
|
-
|
|
79622
|
-
## What NOT to review
|
|
79623
|
-
- Files excluded by the "File Selection for gitDiff" rules (do not diff or comment on them).
|
|
79624
|
-
- Existing unchanged code.
|
|
79625
|
-
- Overall project structure/architecture unless directly impacted by the changes.
|
|
79626
|
-
- Missing features or functionality not part of this diff.
|
|
79575
|
+
## Review Process
|
|
79576
|
+
|
|
79577
|
+
1. **Identify Reviewable Files**: Use the \`<file_status>\` list to determine which files have been modified.
|
|
79578
|
+
2. **Select Files for Diff**: From the modified files, select only the reviewable source and configuration files.
|
|
79579
|
+
- **Include**: Source code, config files, and template files.
|
|
79580
|
+
- **Exclude**: Lockfiles, build artifacts, test snapshots, binary/media files, data and fixtures and other generated files.
|
|
79581
|
+
3. **Inspect Changes**: Use the \`gitDiff\` tool on one file at a time to see the exact changes. When reviewing pull requests, use the \`commitRange\` parameter provided in the review instructions.
|
|
79582
|
+
4. **Analyze and Review**: Analyze only the modified lines (additions/deletions) for issues. Provide specific, actionable feedback with accurate line numbers.
|
|
79583
|
+
|
|
79584
|
+
## Critical Rules
|
|
79585
|
+
|
|
79586
|
+
- **Focus on Changes**: ONLY review the actual changes shown in the diff. Do not comment on existing, unmodified code.
|
|
79587
|
+
- **Focus Scope**: Do not comment on overall project structure or architecture unless directly impacted by the changes in the diff.
|
|
79588
|
+
- **No Feature Requests**: Do not comment on missing features or functionality that are not part of this diff.
|
|
79589
|
+
- **One File at a Time**: Review files individually using \`gitDiff\` with the specific file path.
|
|
79590
|
+
- **No Empty Diffs**: MUST NOT call \`gitDiff\` with an empty or omitted file parameter.
|
|
79591
|
+
- **Accurate Line Numbers**: Use the line numbers from the diff annotations (\`[Line N]\` for additions, \`[Line N removed]\` for deletions).
|
|
79592
|
+
- **No Praise**: Provide only reviews for actual issues found. Do not include praise or positive feedback.
|
|
79593
|
+
- **Clear Reasoning**: For each issue, provide clear reasoning explaining why it's a problem and what the impact could be.
|
|
79594
|
+
- **Specific Advice**: Avoid generic advice. Provide concrete, actionable suggestions specific to the code being reviewed.
|
|
79595
|
+
- **Assumptions**: Assume all changes have passed linter, type-checking, and unit tests. Do not check for compile errors.
|
|
79596
|
+
|
|
79597
|
+
You may receive the following context:
|
|
79598
|
+
- \`<pr_title>\` and \`<pr_description>\`: PR context
|
|
79599
|
+
- \`<commit_messages>\`: Commits in the change
|
|
79600
|
+
- \`<user_context>\`: Specific review focus from the user
|
|
79601
|
+
- \`<file_status>\`: List of modified files with their status
|
|
79602
|
+
- \`<review_instructions>\`: Specific instructions for this review
|
|
79627
79603
|
|
|
79628
79604
|
## Output Format
|
|
79629
|
-
Do not include praise or positive feedback.
|
|
79630
|
-
Only include reviews for actual issues found in the changed code.
|
|
79631
79605
|
|
|
79632
79606
|
${createJsonResponseInstruction({
|
|
79633
|
-
overview: "Summary of
|
|
79607
|
+
overview: "Summary of issues found, 'No issues found', or 'No reviewable changes' if all files were excluded.",
|
|
79634
79608
|
specificReviews: [
|
|
79635
79609
|
{
|
|
79636
|
-
file: "path/
|
|
79637
|
-
lines: "
|
|
79638
|
-
review: "Specific issue
|
|
79610
|
+
file: "path/to/file.ts",
|
|
79611
|
+
lines: "42 or 15-20",
|
|
79612
|
+
review: "Specific issue description and actionable fix."
|
|
79639
79613
|
}
|
|
79640
79614
|
]
|
|
79641
79615
|
})}
|
|
79616
|
+
|
|
79617
|
+
### Examples
|
|
79618
|
+
|
|
79619
|
+
**Example 1: Issues found**
|
|
79620
|
+
\`\`\`json
|
|
79621
|
+
{
|
|
79622
|
+
"overview": "Found 2 security and 1 logic issue in the authentication changes.",
|
|
79623
|
+
"specificReviews": [
|
|
79624
|
+
{
|
|
79625
|
+
"file": "src/auth/login.ts",
|
|
79626
|
+
"lines": "23",
|
|
79627
|
+
"review": "Password is logged in plaintext. Remove the console.log statement or hash the password before logging."
|
|
79628
|
+
},
|
|
79629
|
+
{
|
|
79630
|
+
"file": "src/auth/login.ts",
|
|
79631
|
+
"lines": "45-48",
|
|
79632
|
+
"review": "Missing input validation for email field. Add email format validation before processing the login request."
|
|
79633
|
+
},
|
|
79634
|
+
{
|
|
79635
|
+
"file": "src/utils/token.ts",
|
|
79636
|
+
"lines": "12",
|
|
79637
|
+
"review": "Token expiration is set to 365 days which is too long for security. Reduce to 24 hours or use refresh tokens."
|
|
79638
|
+
}
|
|
79639
|
+
]
|
|
79640
|
+
}
|
|
79641
|
+
\`\`\`
|
|
79642
|
+
|
|
79643
|
+
**Example 2: No issues**
|
|
79644
|
+
\`\`\`json
|
|
79645
|
+
{
|
|
79646
|
+
"overview": "No issues found.",
|
|
79647
|
+
"specificReviews": []
|
|
79648
|
+
}
|
|
79649
|
+
\`\`\`
|
|
79650
|
+
|
|
79651
|
+
**Example 3: No reviewable changes**
|
|
79652
|
+
\`\`\`json
|
|
79653
|
+
{
|
|
79654
|
+
"overview": "No reviewable changes. All modified files are lockfiles or generated artifacts.",
|
|
79655
|
+
"specificReviews": []
|
|
79656
|
+
}
|
|
79657
|
+
\`\`\`
|
|
79642
79658
|
`;
|
|
79643
79659
|
function formatReviewToolInput(params) {
|
|
79644
79660
|
const parts = [];
|
|
@@ -79656,6 +79672,11 @@ ${params.pullRequestDescription}
|
|
|
79656
79672
|
parts.push(`<commit_messages>
|
|
79657
79673
|
${params.commitMessages}
|
|
79658
79674
|
</commit_messages>`);
|
|
79675
|
+
}
|
|
79676
|
+
if (params.context) {
|
|
79677
|
+
parts.push(`<user_context>
|
|
79678
|
+
${params.context}
|
|
79679
|
+
</user_context>`);
|
|
79659
79680
|
}
|
|
79660
79681
|
if (params.changedFiles && params.changedFiles.length > 0) {
|
|
79661
79682
|
const fileList = params.changedFiles.map((file2) => `${file2.status}: ${file2.path}`).join(`
|
|
@@ -79687,7 +79708,7 @@ var FixIterationSummarySchema = exports_external.object({
|
|
|
79687
79708
|
});
|
|
79688
79709
|
var fixWorkflow = async (input2, context) => {
|
|
79689
79710
|
const { tools: tools2, logger, step } = context;
|
|
79690
|
-
const { command: inputCommand, task, interactive = true } = input2;
|
|
79711
|
+
const { command: inputCommand, task, context: userContext, interactive = true } = input2;
|
|
79691
79712
|
let command = inputCommand;
|
|
79692
79713
|
const summaries = [];
|
|
79693
79714
|
let formatCommand;
|
|
@@ -79755,7 +79776,7 @@ var fixWorkflow = async (input2, context) => {
|
|
|
79755
79776
|
const result = await step(`fix-${i}`, async () => {
|
|
79756
79777
|
const defaultContext = await getDefaultContext();
|
|
79757
79778
|
const memoryContext = await tools2.getMemoryContext();
|
|
79758
|
-
const userPrompt = getFixUserPrompt(command, exitCode, stdout, stderr, task);
|
|
79779
|
+
const userPrompt = getFixUserPrompt(command, exitCode, stdout, stderr, task, userContext);
|
|
79759
79780
|
return await agentWorkflow({
|
|
79760
79781
|
systemPrompt: FIX_SYSTEM_PROMPT,
|
|
79761
79782
|
userMessage: [
|
|
@@ -81336,7 +81357,7 @@ var prWorkflow = async (input2, context) => {
|
|
|
81336
81357
|
// src/workflows/review.workflow.ts
|
|
81337
81358
|
var reviewWorkflow = async (input2, context) => {
|
|
81338
81359
|
const { step, tools: tools2, logger } = context;
|
|
81339
|
-
const { pr: pr2 } = input2;
|
|
81360
|
+
const { pr: pr2, context: userContext } = input2;
|
|
81340
81361
|
let changeInfo;
|
|
81341
81362
|
if (pr2) {
|
|
81342
81363
|
const prNumberMatch = pr2.match(/\d+$/);
|
|
@@ -81385,7 +81406,8 @@ var reviewWorkflow = async (input2, context) => {
|
|
|
81385
81406
|
pullRequestTitle: prDetails.title,
|
|
81386
81407
|
pullRequestDescription: prDetails.body,
|
|
81387
81408
|
commitMessages,
|
|
81388
|
-
changedFiles
|
|
81409
|
+
changedFiles,
|
|
81410
|
+
context: userContext
|
|
81389
81411
|
};
|
|
81390
81412
|
} else {
|
|
81391
81413
|
const statusResult = await tools2.executeCommand({ command: "git", args: ["status", "--porcelain=v1"] });
|
|
@@ -81399,7 +81421,8 @@ var reviewWorkflow = async (input2, context) => {
|
|
|
81399
81421
|
printChangedFiles(logger, changedFiles);
|
|
81400
81422
|
changeInfo = {
|
|
81401
81423
|
staged: hasStagedChanges,
|
|
81402
|
-
changedFiles
|
|
81424
|
+
changedFiles,
|
|
81425
|
+
context: userContext
|
|
81403
81426
|
};
|
|
81404
81427
|
} else {
|
|
81405
81428
|
await step("No local changes detected. Falling back to branch diff...", async () => {});
|
|
@@ -81436,7 +81459,8 @@ var reviewWorkflow = async (input2, context) => {
|
|
|
81436
81459
|
printChangedFiles(logger, branchChangedFiles);
|
|
81437
81460
|
changeInfo = {
|
|
81438
81461
|
commitRange: `${defaultBranch}...${currentBranch}`,
|
|
81439
|
-
changedFiles: branchChangedFiles
|
|
81462
|
+
changedFiles: branchChangedFiles,
|
|
81463
|
+
context: userContext
|
|
81440
81464
|
};
|
|
81441
81465
|
}
|
|
81442
81466
|
}
|
|
@@ -81620,8 +81644,8 @@ async function runEpic(task2, _options, command) {
|
|
|
81620
81644
|
var epicCommand = new Command("epic").description("Orchestrates a large feature or epic, breaking it down into smaller tasks.").argument("[task]", "The epic to plan and implement.").action(runEpic);
|
|
81621
81645
|
|
|
81622
81646
|
// src/commands/fix.ts
|
|
81623
|
-
var fixCommand = new Command("fix").description("Fix issues by running a command and letting an agent fix it.").argument("[command]", "The command to run").option("-t, --task <task>", "The task to perform, providing specific instructions to the agent.").action(async (command, options, cmd) => {
|
|
81624
|
-
const workflowInput = { command, task: options.task };
|
|
81647
|
+
var fixCommand = new Command("fix").description("Fix issues by running a command and letting an agent fix it.").argument("[command]", "The command to run").argument("[context]", "Additional context for the fix").option("-t, --task <task>", "The task to perform, providing specific instructions to the agent.").action(async (command, context, options, cmd) => {
|
|
81648
|
+
const workflowInput = { command, task: options.task, context };
|
|
81625
81649
|
const globalOpts = (cmd.parent ?? cmd).opts();
|
|
81626
81650
|
const { verbose } = globalOpts;
|
|
81627
81651
|
const logger = createLogger({
|
|
@@ -81735,7 +81759,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
81735
81759
|
});
|
|
81736
81760
|
|
|
81737
81761
|
// src/commands/review.ts
|
|
81738
|
-
var reviewCommand = new Command("review").description("Review a GitHub pull request or local changes").option("--pr <pr>", "The pull request number or URL to review").option("--json", "Output the review in JSON format", false).option("-y, --yes", "Automatically apply review feedback", false).option("--loop [count]", "Re-review after changes are applied.", (value) => {
|
|
81762
|
+
var reviewCommand = new Command("review").description("Review a GitHub pull request or local changes").argument("[context]", "Additional context for the review").option("--pr <pr>", "The pull request number or URL to review").option("--json", "Output the review in JSON format", false).option("-y, --yes", "Automatically apply review feedback", false).option("--loop [count]", "Re-review after changes are applied.", (value) => {
|
|
81739
81763
|
if (value === undefined || value === null) {
|
|
81740
81764
|
return 1;
|
|
81741
81765
|
}
|
|
@@ -81744,7 +81768,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
81744
81768
|
throw new InvalidOptionArgumentError("Must be a positive number.");
|
|
81745
81769
|
}
|
|
81746
81770
|
return parsedValue;
|
|
81747
|
-
}, 1).action(async (options, command) => {
|
|
81771
|
+
}, 1).action(async (context, options, command) => {
|
|
81748
81772
|
const { json: json2, pr: pr3, loop: maxIterations, yes: yesOption } = options;
|
|
81749
81773
|
const yes = maxIterations > 1 || yesOption;
|
|
81750
81774
|
let changesAppliedInThisIteration = false;
|
|
@@ -81755,7 +81779,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
81755
81779
|
});
|
|
81756
81780
|
for (let i = 0;i < maxIterations; i++) {
|
|
81757
81781
|
changesAppliedInThisIteration = false;
|
|
81758
|
-
const input2 = { pr: pr3 };
|
|
81782
|
+
const input2 = { pr: pr3, context };
|
|
81759
81783
|
if (i > 0) {
|
|
81760
81784
|
logger.debug(`Re-running review (iteration ${i + 1} of ${maxIterations})...`);
|
|
81761
81785
|
}
|