@polka-codes/cli 0.9.55 → 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 +185 -86
- 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) => {
|
|
@@ -78705,6 +78705,7 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
78705
78705
|
maxMessages: config4.maxMessageCount,
|
|
78706
78706
|
maxCost: config4.budget
|
|
78707
78707
|
});
|
|
78708
|
+
options.onUsageMeterCreated?.(usage);
|
|
78708
78709
|
const onEvent = printEvent(verbose, usage, process.stderr);
|
|
78709
78710
|
const excludeFiles = [".epic.yml", ...config4.excludeFiles ?? []];
|
|
78710
78711
|
const toolProvider = (options.getProvider ?? getProvider)({ excludeFiles });
|
|
@@ -78966,7 +78967,7 @@ When planning an epic:
|
|
|
78966
78967
|
Your plan must have two parts: task description and implementation plan.
|
|
78967
78968
|
|
|
78968
78969
|
### 1. Task Description
|
|
78969
|
-
|
|
78970
|
+
Start by providing a detailed description of the task and its expected outcome. This description should be a comprehensive summary based on the user's request, setting the stage for the detailed implementation plan that follows. It should clearly articulate the "what" and "why" of the epic before breaking it down into "how".
|
|
78970
78971
|
|
|
78971
78972
|
### 2. Implementation Plan
|
|
78972
78973
|
|
|
@@ -78997,7 +78998,14 @@ For epic-scale work, **use markdown checkboxes** to track progress through multi
|
|
|
78997
78998
|
\`\`\`
|
|
78998
78999
|
### 1. Task Description
|
|
78999
79000
|
|
|
79000
|
-
|
|
79001
|
+
This epic is to implement a complete user authentication system using JSON Web Tokens (JWT). The primary goal is to allow users to register for a new account and log in to receive a token that can be used to access protected resources. The system should handle password hashing for security and provide a way to manage user sessions on the frontend.
|
|
79002
|
+
|
|
79003
|
+
**Expected Outcome:**
|
|
79004
|
+
- A backend with registration and login endpoints.
|
|
79005
|
+
- Secure password storage using bcrypt.
|
|
79006
|
+
- JWT generation upon successful login.
|
|
79007
|
+
- Middleware to protect specific routes.
|
|
79008
|
+
- A frontend with a login form, registration form, and context for managing authentication state.
|
|
79001
79009
|
|
|
79002
79010
|
### 2. Implementation Plan
|
|
79003
79011
|
|
|
@@ -79251,13 +79259,18 @@ ${createJsonResponseInstruction({
|
|
|
79251
79259
|
bailReason: "Unable to identify the root cause of the error. The error message is ambiguous and requires human investigation."
|
|
79252
79260
|
})}
|
|
79253
79261
|
`;
|
|
79254
|
-
function getFixUserPrompt(command, exitCode, stdout, stderr, task) {
|
|
79262
|
+
function getFixUserPrompt(command, exitCode, stdout, stderr, task, context) {
|
|
79255
79263
|
const taskContext = task ? `
|
|
79256
79264
|
## Original Task
|
|
79257
79265
|
|
|
79258
79266
|
${task}
|
|
79259
79267
|
` : "";
|
|
79260
|
-
|
|
79268
|
+
const contextSection = context ? `
|
|
79269
|
+
## User Context
|
|
79270
|
+
|
|
79271
|
+
${context}
|
|
79272
|
+
` : "";
|
|
79273
|
+
return `## Context${taskContext}${contextSection}
|
|
79261
79274
|
|
|
79262
79275
|
The following command failed with exit code ${exitCode}:
|
|
79263
79276
|
\`${command}\`
|
|
@@ -79555,82 +79568,93 @@ ${createJsonResponseInstruction({
|
|
|
79555
79568
|
`;
|
|
79556
79569
|
// src/workflows/prompts/review.ts
|
|
79557
79570
|
var CODE_REVIEW_SYSTEM_PROMPT = `Role: Senior software engineer.
|
|
79558
|
-
Goal: Review code changes and provide
|
|
79571
|
+
Goal: Review code changes and provide comprehensive, actionable feedback on issues found.
|
|
79559
79572
|
|
|
79560
79573
|
${TOOL_USAGE_INSTRUCTION}
|
|
79561
79574
|
|
|
79562
|
-
|
|
79563
|
-
|
|
79564
|
-
|
|
79565
|
-
|
|
79566
|
-
|
|
79567
|
-
-
|
|
79568
|
-
|
|
79569
|
-
|
|
79570
|
-
|
|
79571
|
-
##
|
|
79572
|
-
|
|
79573
|
-
|
|
79574
|
-
|
|
79575
|
-
-
|
|
79576
|
-
-
|
|
79577
|
-
-
|
|
79578
|
-
|
|
79579
|
-
|
|
79580
|
-
-
|
|
79581
|
-
-
|
|
79582
|
-
-
|
|
79583
|
-
|
|
79584
|
-
|
|
79585
|
-
|
|
79586
|
-
|
|
79587
|
-
-
|
|
79588
|
-
|
|
79589
|
-
|
|
79590
|
-
- The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions.
|
|
79591
|
-
- You may receive:
|
|
79592
|
-
- <pr_title>
|
|
79593
|
-
- <pr_description>
|
|
79594
|
-
- <commit_messages>
|
|
79595
|
-
- A <review_instructions> tag tells you the focus of the review.
|
|
79596
|
-
- Use <file_status> to understand which files were modified, added, deleted, or renamed and to apply the inclusion/exclusion rules above.
|
|
79597
|
-
|
|
79598
|
-
|
|
79599
|
-
## Line Number Reporting
|
|
79600
|
-
- Use the line numbers from the annotations in the diff output.
|
|
79601
|
-
- For additions: use the number from the [Line N] annotation after the + line.
|
|
79602
|
-
- For deletions: use the number from the [Line N removed] annotation after the - line.
|
|
79603
|
-
- For modifications: report the line number of the new/current code (from [Line N]).
|
|
79604
|
-
- Report single lines as "N" and ranges as "N-M".
|
|
79605
|
-
|
|
79606
|
-
|
|
79607
|
-
## Review Guidelines
|
|
79608
|
-
Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
|
|
79609
|
-
- **Specific issues:** Point to exact problems in the changed code with accurate line references from the annotations.
|
|
79610
|
-
- **Actionable fixes:** Provide concrete solutions, not vague suggestions.
|
|
79611
|
-
- **Clear reasoning:** Explain why each issue matters and how to fix it.
|
|
79612
|
-
- **Avoid generic advice** unless directly tied to a specific problem visible in the diff.
|
|
79613
|
-
|
|
79614
|
-
## What NOT to review
|
|
79615
|
-
- Files excluded by the "File Selection for gitDiff" rules (do not diff or comment on them).
|
|
79616
|
-
- Existing unchanged code.
|
|
79617
|
-
- Overall project structure/architecture unless directly impacted by the changes.
|
|
79618
|
-
- 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
|
|
79619
79603
|
|
|
79620
79604
|
## Output Format
|
|
79621
|
-
Do not include praise or positive feedback.
|
|
79622
|
-
Only include reviews for actual issues found in the changed code.
|
|
79623
79605
|
|
|
79624
79606
|
${createJsonResponseInstruction({
|
|
79625
|
-
overview: "Summary of
|
|
79607
|
+
overview: "Summary of issues found, 'No issues found', or 'No reviewable changes' if all files were excluded.",
|
|
79626
79608
|
specificReviews: [
|
|
79627
79609
|
{
|
|
79628
|
-
file: "path/
|
|
79629
|
-
lines: "
|
|
79630
|
-
review: "Specific issue
|
|
79610
|
+
file: "path/to/file.ts",
|
|
79611
|
+
lines: "42 or 15-20",
|
|
79612
|
+
review: "Specific issue description and actionable fix."
|
|
79631
79613
|
}
|
|
79632
79614
|
]
|
|
79633
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
|
+
\`\`\`
|
|
79634
79658
|
`;
|
|
79635
79659
|
function formatReviewToolInput(params) {
|
|
79636
79660
|
const parts = [];
|
|
@@ -79648,6 +79672,11 @@ ${params.pullRequestDescription}
|
|
|
79648
79672
|
parts.push(`<commit_messages>
|
|
79649
79673
|
${params.commitMessages}
|
|
79650
79674
|
</commit_messages>`);
|
|
79675
|
+
}
|
|
79676
|
+
if (params.context) {
|
|
79677
|
+
parts.push(`<user_context>
|
|
79678
|
+
${params.context}
|
|
79679
|
+
</user_context>`);
|
|
79651
79680
|
}
|
|
79652
79681
|
if (params.changedFiles && params.changedFiles.length > 0) {
|
|
79653
79682
|
const fileList = params.changedFiles.map((file2) => `${file2.status}: ${file2.path}`).join(`
|
|
@@ -79679,7 +79708,7 @@ var FixIterationSummarySchema = exports_external.object({
|
|
|
79679
79708
|
});
|
|
79680
79709
|
var fixWorkflow = async (input2, context) => {
|
|
79681
79710
|
const { tools: tools2, logger, step } = context;
|
|
79682
|
-
const { command: inputCommand, task, interactive = true } = input2;
|
|
79711
|
+
const { command: inputCommand, task, context: userContext, interactive = true } = input2;
|
|
79683
79712
|
let command = inputCommand;
|
|
79684
79713
|
const summaries = [];
|
|
79685
79714
|
let formatCommand;
|
|
@@ -79747,7 +79776,7 @@ var fixWorkflow = async (input2, context) => {
|
|
|
79747
79776
|
const result = await step(`fix-${i}`, async () => {
|
|
79748
79777
|
const defaultContext = await getDefaultContext();
|
|
79749
79778
|
const memoryContext = await tools2.getMemoryContext();
|
|
79750
|
-
const userPrompt = getFixUserPrompt(command, exitCode, stdout, stderr, task);
|
|
79779
|
+
const userPrompt = getFixUserPrompt(command, exitCode, stdout, stderr, task, userContext);
|
|
79751
79780
|
return await agentWorkflow({
|
|
79752
79781
|
systemPrompt: FIX_SYSTEM_PROMPT,
|
|
79753
79782
|
userMessage: [
|
|
@@ -80580,6 +80609,7 @@ var MAX_REVIEW_RETRIES = 5;
|
|
|
80580
80609
|
var TODO_HANDLING_INSTRUCTIONS = `If you discover that a task is larger than you thought, or that a new task is required, you can add a // TODO comment in the code and create a todo item for it. This will allow you to continue with the current task and address the larger issue later.`;
|
|
80581
80610
|
async function createPlan2(input2, context) {
|
|
80582
80611
|
const { task, plan: plan2, files, feedback, messages } = input2;
|
|
80612
|
+
const { tools: tools2 } = context;
|
|
80583
80613
|
const agentTools = [
|
|
80584
80614
|
askFollowupQuestion_default,
|
|
80585
80615
|
fetchUrl_default,
|
|
@@ -80600,7 +80630,13 @@ async function createPlan2(input2, context) {
|
|
|
80600
80630
|
outputSchema: EpicPlanSchema
|
|
80601
80631
|
}, context);
|
|
80602
80632
|
}
|
|
80603
|
-
const
|
|
80633
|
+
const defaultContext = await getDefaultContext();
|
|
80634
|
+
const memoryContext = await tools2.getMemoryContext();
|
|
80635
|
+
const prompt = `${memoryContext}
|
|
80636
|
+
${getPlanPrompt(task, plan2)}
|
|
80637
|
+
|
|
80638
|
+
${defaultContext}`;
|
|
80639
|
+
const content = [{ type: "text", text: prompt }];
|
|
80604
80640
|
if (files) {
|
|
80605
80641
|
for (const file2 of files) {
|
|
80606
80642
|
if (file2.type === "file") {
|
|
@@ -81136,6 +81172,37 @@ Summary:`);
|
|
|
81136
81172
|
for (const [idx, msg] of commitMessages.entries()) {
|
|
81137
81173
|
logger.info(` ${idx + 1}. ${msg}`);
|
|
81138
81174
|
}
|
|
81175
|
+
if (input2.usages && input2.usages.length > 0) {
|
|
81176
|
+
const sortedUsages = [...input2.usages].sort((a, b) => a.timestamp - b.timestamp);
|
|
81177
|
+
let lastUsage = {
|
|
81178
|
+
input: 0,
|
|
81179
|
+
output: 0,
|
|
81180
|
+
cachedRead: 0,
|
|
81181
|
+
cost: 0,
|
|
81182
|
+
messageCount: 0
|
|
81183
|
+
};
|
|
81184
|
+
logger.info(`
|
|
81185
|
+
Usage Breakdown:`);
|
|
81186
|
+
sortedUsages.forEach((usage, index) => {
|
|
81187
|
+
const delta = {
|
|
81188
|
+
input: usage.input - lastUsage.input,
|
|
81189
|
+
output: usage.output - lastUsage.output,
|
|
81190
|
+
cachedRead: usage.cachedRead - lastUsage.cachedRead,
|
|
81191
|
+
cost: usage.cost - lastUsage.cost,
|
|
81192
|
+
messageCount: usage.messageCount - lastUsage.messageCount
|
|
81193
|
+
};
|
|
81194
|
+
const tempMeter = new UsageMeter;
|
|
81195
|
+
tempMeter.setUsage(delta);
|
|
81196
|
+
logger.info(` Step ${index + 1}: ${tempMeter.getUsageText()}`);
|
|
81197
|
+
lastUsage = usage;
|
|
81198
|
+
});
|
|
81199
|
+
const last = sortedUsages.at(-1);
|
|
81200
|
+
if (last) {
|
|
81201
|
+
const totalMeter = new UsageMeter;
|
|
81202
|
+
totalMeter.setUsage(last);
|
|
81203
|
+
logger.info(` Total: ${totalMeter.getUsageText()}`);
|
|
81204
|
+
}
|
|
81205
|
+
}
|
|
81139
81206
|
} catch (error46) {
|
|
81140
81207
|
logger.error(`
|
|
81141
81208
|
Epic workflow failed: ${error46 instanceof Error ? error46.message : String(error46)}`);
|
|
@@ -81290,7 +81357,7 @@ var prWorkflow = async (input2, context) => {
|
|
|
81290
81357
|
// src/workflows/review.workflow.ts
|
|
81291
81358
|
var reviewWorkflow = async (input2, context) => {
|
|
81292
81359
|
const { step, tools: tools2, logger } = context;
|
|
81293
|
-
const { pr: pr2 } = input2;
|
|
81360
|
+
const { pr: pr2, context: userContext } = input2;
|
|
81294
81361
|
let changeInfo;
|
|
81295
81362
|
if (pr2) {
|
|
81296
81363
|
const prNumberMatch = pr2.match(/\d+$/);
|
|
@@ -81339,7 +81406,8 @@ var reviewWorkflow = async (input2, context) => {
|
|
|
81339
81406
|
pullRequestTitle: prDetails.title,
|
|
81340
81407
|
pullRequestDescription: prDetails.body,
|
|
81341
81408
|
commitMessages,
|
|
81342
|
-
changedFiles
|
|
81409
|
+
changedFiles,
|
|
81410
|
+
context: userContext
|
|
81343
81411
|
};
|
|
81344
81412
|
} else {
|
|
81345
81413
|
const statusResult = await tools2.executeCommand({ command: "git", args: ["status", "--porcelain=v1"] });
|
|
@@ -81353,7 +81421,8 @@ var reviewWorkflow = async (input2, context) => {
|
|
|
81353
81421
|
printChangedFiles(logger, changedFiles);
|
|
81354
81422
|
changeInfo = {
|
|
81355
81423
|
staged: hasStagedChanges,
|
|
81356
|
-
changedFiles
|
|
81424
|
+
changedFiles,
|
|
81425
|
+
context: userContext
|
|
81357
81426
|
};
|
|
81358
81427
|
} else {
|
|
81359
81428
|
await step("No local changes detected. Falling back to branch diff...", async () => {});
|
|
@@ -81390,7 +81459,8 @@ var reviewWorkflow = async (input2, context) => {
|
|
|
81390
81459
|
printChangedFiles(logger, branchChangedFiles);
|
|
81391
81460
|
changeInfo = {
|
|
81392
81461
|
commitRange: `${defaultBranch}...${currentBranch}`,
|
|
81393
|
-
changedFiles: branchChangedFiles
|
|
81462
|
+
changedFiles: branchChangedFiles,
|
|
81463
|
+
context: userContext
|
|
81394
81464
|
};
|
|
81395
81465
|
}
|
|
81396
81466
|
}
|
|
@@ -81437,13 +81507,22 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
|
|
|
81437
81507
|
// src/workflows/epic-context.ts
|
|
81438
81508
|
import { promises as fs3 } from "node:fs";
|
|
81439
81509
|
var EPIC_CONTEXT_FILE = ".epic.yml";
|
|
81510
|
+
var EpicUsageSchema = exports_external.object({
|
|
81511
|
+
timestamp: exports_external.number(),
|
|
81512
|
+
input: exports_external.number(),
|
|
81513
|
+
output: exports_external.number(),
|
|
81514
|
+
cachedRead: exports_external.number(),
|
|
81515
|
+
cost: exports_external.number(),
|
|
81516
|
+
messageCount: exports_external.number()
|
|
81517
|
+
});
|
|
81440
81518
|
var EpicContextSchema = exports_external.object({
|
|
81441
81519
|
task: exports_external.string().nullish(),
|
|
81442
81520
|
plan: exports_external.string().nullish(),
|
|
81443
81521
|
branchName: exports_external.string().nullish(),
|
|
81444
81522
|
baseBranch: exports_external.string().nullish(),
|
|
81445
81523
|
todos: exports_external.array(TodoItemSchema).nullish(),
|
|
81446
|
-
memory: exports_external.record(exports_external.string(), exports_external.string()).nullish()
|
|
81524
|
+
memory: exports_external.record(exports_external.string(), exports_external.string()).nullish(),
|
|
81525
|
+
usages: exports_external.array(EpicUsageSchema).nullish()
|
|
81447
81526
|
});
|
|
81448
81527
|
var saveEpicContext = async (context) => {
|
|
81449
81528
|
const yamlString = $stringify({
|
|
@@ -81452,7 +81531,8 @@ var saveEpicContext = async (context) => {
|
|
|
81452
81531
|
branchName: context.branchName,
|
|
81453
81532
|
baseBranch: context.baseBranch,
|
|
81454
81533
|
todos: context.todos,
|
|
81455
|
-
memory: context.memory
|
|
81534
|
+
memory: context.memory,
|
|
81535
|
+
usages: context.usages
|
|
81456
81536
|
});
|
|
81457
81537
|
await fs3.writeFile(EPIC_CONTEXT_FILE, yamlString, "utf-8");
|
|
81458
81538
|
};
|
|
@@ -81526,10 +81606,26 @@ async function runEpic(task2, _options, command) {
|
|
|
81526
81606
|
}
|
|
81527
81607
|
epicContext.task = taskInput;
|
|
81528
81608
|
}
|
|
81609
|
+
let usageAppended = false;
|
|
81529
81610
|
const workflowInput = {
|
|
81530
81611
|
...epicContext,
|
|
81531
|
-
saveEpicContext
|
|
81612
|
+
async saveEpicContext(context) {
|
|
81613
|
+
if (usageMeter) {
|
|
81614
|
+
const currentUsage = usageMeter.usage;
|
|
81615
|
+
if (!context.usages) {
|
|
81616
|
+
context.usages = [];
|
|
81617
|
+
}
|
|
81618
|
+
if (!usageAppended) {
|
|
81619
|
+
context.usages.push({ ...currentUsage, timestamp: Date.now() });
|
|
81620
|
+
usageAppended = true;
|
|
81621
|
+
} else {
|
|
81622
|
+
context.usages[context.usages.length - 1] = { ...currentUsage, timestamp: Date.now() };
|
|
81623
|
+
}
|
|
81624
|
+
}
|
|
81625
|
+
await saveEpicContext(context);
|
|
81626
|
+
}
|
|
81532
81627
|
};
|
|
81628
|
+
let usageMeter;
|
|
81533
81629
|
await runWorkflow(epicWorkflow, workflowInput, {
|
|
81534
81630
|
commandName: "epic",
|
|
81535
81631
|
command,
|
|
@@ -81539,14 +81635,17 @@ async function runEpic(task2, _options, command) {
|
|
|
81539
81635
|
...opt,
|
|
81540
81636
|
todoItemStore: new EpicTodoItemStore(workflowInput),
|
|
81541
81637
|
memoryStore: new EpicMemoryStore(workflowInput)
|
|
81542
|
-
})
|
|
81638
|
+
}),
|
|
81639
|
+
onUsageMeterCreated: (meter) => {
|
|
81640
|
+
usageMeter = meter;
|
|
81641
|
+
}
|
|
81543
81642
|
});
|
|
81544
81643
|
}
|
|
81545
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);
|
|
81546
81645
|
|
|
81547
81646
|
// src/commands/fix.ts
|
|
81548
|
-
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) => {
|
|
81549
|
-
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 };
|
|
81550
81649
|
const globalOpts = (cmd.parent ?? cmd).opts();
|
|
81551
81650
|
const { verbose } = globalOpts;
|
|
81552
81651
|
const logger = createLogger({
|
|
@@ -81660,7 +81759,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
81660
81759
|
});
|
|
81661
81760
|
|
|
81662
81761
|
// src/commands/review.ts
|
|
81663
|
-
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) => {
|
|
81664
81763
|
if (value === undefined || value === null) {
|
|
81665
81764
|
return 1;
|
|
81666
81765
|
}
|
|
@@ -81669,7 +81768,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
81669
81768
|
throw new InvalidOptionArgumentError("Must be a positive number.");
|
|
81670
81769
|
}
|
|
81671
81770
|
return parsedValue;
|
|
81672
|
-
}, 1).action(async (options, command) => {
|
|
81771
|
+
}, 1).action(async (context, options, command) => {
|
|
81673
81772
|
const { json: json2, pr: pr3, loop: maxIterations, yes: yesOption } = options;
|
|
81674
81773
|
const yes = maxIterations > 1 || yesOption;
|
|
81675
81774
|
let changesAppliedInThisIteration = false;
|
|
@@ -81680,7 +81779,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
81680
81779
|
});
|
|
81681
81780
|
for (let i = 0;i < maxIterations; i++) {
|
|
81682
81781
|
changesAppliedInThisIteration = false;
|
|
81683
|
-
const input2 = { pr: pr3 };
|
|
81782
|
+
const input2 = { pr: pr3, context };
|
|
81684
81783
|
if (i > 0) {
|
|
81685
81784
|
logger.debug(`Re-running review (iteration ${i + 1} of ${maxIterations})...`);
|
|
81686
81785
|
}
|