@bobbyg603/mog 1.5.0 → 1.5.1
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/package.json +1 -1
- package/src/index.ts +16 -7
- package/src/worktree.ts +3 -3
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -216,16 +216,18 @@ async function main() {
|
|
|
216
216
|
const { defaultBranch } = ensureRepo(repo, owner, repoName, reposDir);
|
|
217
217
|
log.info(`Default branch: ${defaultBranch}`);
|
|
218
218
|
|
|
219
|
-
const { worktreeDir, branchName } = createWorktree(
|
|
219
|
+
const { worktreeDir, branchName, reused } = createWorktree(
|
|
220
220
|
reposDir, owner, repoName, defaultBranch, issueNum, issue.title
|
|
221
221
|
);
|
|
222
222
|
|
|
223
223
|
// Check for existing PR (unless --fresh)
|
|
224
224
|
let existingPR: PRFeedback | undefined;
|
|
225
|
+
let isRetry = reused;
|
|
225
226
|
if (!fresh) {
|
|
226
227
|
const pr = fetchPRFeedback(repo, branchName);
|
|
227
228
|
if (pr) {
|
|
228
229
|
existingPR = pr;
|
|
230
|
+
isRetry = true;
|
|
229
231
|
log.ok(`Found existing PR #${pr.prNumber} — will include review feedback and update it.`);
|
|
230
232
|
}
|
|
231
233
|
}
|
|
@@ -242,7 +244,7 @@ async function main() {
|
|
|
242
244
|
|
|
243
245
|
// Build prompts
|
|
244
246
|
const prFeedback = existingPR?.reviews || "";
|
|
245
|
-
const planningPrompt = buildPlanningPrompt(repo, issueNum, issue, prFeedback);
|
|
247
|
+
const planningPrompt = buildPlanningPrompt(repo, issueNum, issue, prFeedback, isRetry);
|
|
246
248
|
const buildingPromptFn = (remaining: string[], plan: string) =>
|
|
247
249
|
buildBuildingPrompt(repo, issueNum, issue, remaining, plan);
|
|
248
250
|
const reviewPrompt = buildReviewPrompt(repo, issueNum, issue);
|
|
@@ -319,7 +321,7 @@ function tryRecoverSandbox(reposDir: string): boolean {
|
|
|
319
321
|
return true;
|
|
320
322
|
}
|
|
321
323
|
|
|
322
|
-
function formatIssueContext(issueNum: string, issue: { title: string; body: string; labels: string; comments: string }, prFeedback?: string): string {
|
|
324
|
+
function formatIssueContext(issueNum: string, issue: { title: string; body: string; labels: string; comments: string }, prFeedback?: string, isRetry?: boolean): string {
|
|
323
325
|
let context = `## Issue: ${issue.title}
|
|
324
326
|
|
|
325
327
|
### Description
|
|
@@ -335,22 +337,29 @@ ${issue.labels}`;
|
|
|
335
337
|
${issue.comments}`;
|
|
336
338
|
}
|
|
337
339
|
|
|
338
|
-
if (
|
|
340
|
+
if (isRetry) {
|
|
339
341
|
context += `
|
|
340
342
|
|
|
343
|
+
### Re-attempt Notice
|
|
344
|
+
**This is a re-attempt of a previous run.** The issue description, comments, or requirements may have been updated since the last attempt. Carefully review ALL context above to catch anything that may have changed.`;
|
|
345
|
+
|
|
346
|
+
if (prFeedback) {
|
|
347
|
+
context += `
|
|
348
|
+
|
|
341
349
|
### Previous PR Review Feedback
|
|
342
|
-
|
|
350
|
+
Address the following reviewer feedback in your implementation:
|
|
343
351
|
|
|
344
352
|
${prFeedback}`;
|
|
353
|
+
}
|
|
345
354
|
}
|
|
346
355
|
|
|
347
356
|
return context;
|
|
348
357
|
}
|
|
349
358
|
|
|
350
|
-
function buildPlanningPrompt(repo: string, issueNum: string, issue: { title: string; body: string; labels: string; comments: string }, prFeedback?: string): string {
|
|
359
|
+
function buildPlanningPrompt(repo: string, issueNum: string, issue: { title: string; body: string; labels: string; comments: string }, prFeedback?: string, isRetry?: boolean): string {
|
|
351
360
|
return `You are working on GitHub issue #${issueNum} for the repository ${repo}.
|
|
352
361
|
|
|
353
|
-
${formatIssueContext(issueNum, issue, prFeedback)}
|
|
362
|
+
${formatIssueContext(issueNum, issue, prFeedback, isRetry)}
|
|
354
363
|
|
|
355
364
|
## Instructions
|
|
356
365
|
|
package/src/worktree.ts
CHANGED
|
@@ -73,7 +73,7 @@ export function createWorktree(
|
|
|
73
73
|
defaultBranch: string,
|
|
74
74
|
issueNum: string,
|
|
75
75
|
issueTitle: string
|
|
76
|
-
): { worktreeDir: string; branchName: string } {
|
|
76
|
+
): { worktreeDir: string; branchName: string; reused: boolean } {
|
|
77
77
|
const safeTitle = issueTitle
|
|
78
78
|
.toLowerCase()
|
|
79
79
|
.replace(/[^a-z0-9]/g, "-")
|
|
@@ -87,7 +87,7 @@ export function createWorktree(
|
|
|
87
87
|
|
|
88
88
|
if (fs.existsSync(worktreeDir)) {
|
|
89
89
|
log.warn(`Worktree already exists at ${worktreeDir}, reusing.`);
|
|
90
|
-
return { worktreeDir, branchName };
|
|
90
|
+
return { worktreeDir, branchName, reused: true };
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
log.info(`Creating worktree for branch '${branchName}'...`);
|
|
@@ -120,5 +120,5 @@ export function createWorktree(
|
|
|
120
120
|
Bun.spawnSync(["git", "submodule", "update", "--init", "--recursive"], { cwd: worktreeDir });
|
|
121
121
|
|
|
122
122
|
log.ok(`Worktree created at ${worktreeDir}`);
|
|
123
|
-
return { worktreeDir, branchName };
|
|
123
|
+
return { worktreeDir, branchName, reused: false };
|
|
124
124
|
}
|