-
Notifications
You must be signed in to change notification settings - Fork 516
refactor(auto-mode): Enhance revision prompt customization #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4597,21 +4597,54 @@ This mock response was generated because AUTOMAKER_MOCK_AGENT=true was set. | |
| planVersion, | ||
| }); | ||
|
|
||
| // Build revision prompt | ||
| let revisionPrompt = `The user has requested revisions to the plan/specification. | ||
|
|
||
| ## Previous Plan (v${planVersion - 1}) | ||
| ${hasEdits ? approvalResult.editedPlan : currentPlanContent} | ||
|
|
||
| ## User Feedback | ||
| ${approvalResult.feedback || 'Please revise the plan based on the edits above.'} | ||
| // Build revision prompt using customizable template | ||
| const revisionPrompts = await getPromptCustomization( | ||
| this.settingsService, | ||
| '[AutoMode]' | ||
| ); | ||
|
|
||
| ## Instructions | ||
| Please regenerate the specification incorporating the user's feedback. | ||
| Keep the same format with the \`\`\`tasks block for task definitions. | ||
| After generating the revised spec, output: | ||
| "[SPEC_GENERATED] Please review the revised specification above." | ||
| `; | ||
| // Get task format example based on planning mode | ||
| const taskFormatExample = | ||
| planningMode === 'full' | ||
| ? `\`\`\`tasks | ||
| ## Phase 1: Foundation | ||
| - [ ] T001: [Description] | File: [path/to/file] | ||
| - [ ] T002: [Description] | File: [path/to/file] | ||
|
|
||
| ## Phase 2: Core Implementation | ||
| - [ ] T003: [Description] | File: [path/to/file] | ||
| - [ ] T004: [Description] | File: [path/to/file] | ||
| \`\`\`` | ||
| : `\`\`\`tasks | ||
| - [ ] T001: [Description] | File: [path/to/file] | ||
| - [ ] T002: [Description] | File: [path/to/file] | ||
| - [ ] T003: [Description] | File: [path/to/file] | ||
| \`\`\``; | ||
|
|
||
| let revisionPrompt = revisionPrompts.taskExecution.planRevisionTemplate; | ||
| revisionPrompt = revisionPrompt.replace( | ||
| /\{\{planVersion\}\}/g, | ||
| String(planVersion - 1) | ||
| ); | ||
| revisionPrompt = revisionPrompt.replace( | ||
| /\{\{previousPlan\}\}/g, | ||
| hasEdits | ||
| ? approvalResult.editedPlan || currentPlanContent | ||
| : currentPlanContent | ||
| ); | ||
| revisionPrompt = revisionPrompt.replace( | ||
| /\{\{userFeedback\}\}/g, | ||
| approvalResult.feedback || | ||
| 'Please revise the plan based on the edits above.' | ||
| ); | ||
| revisionPrompt = revisionPrompt.replace( | ||
| /\{\{planningMode\}\}/g, | ||
| planningMode | ||
| ); | ||
| revisionPrompt = revisionPrompt.replace( | ||
| /\{\{taskFormatExample\}\}/g, | ||
| taskFormatExample | ||
| ); | ||
|
Comment on lines
+4600
to
+4647
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent Using regex 🔧 Suggested safe replacement- revisionPrompt = revisionPrompt.replace(
- /\{\{planVersion\}\}/g,
- String(planVersion - 1)
- );
+ revisionPrompt = revisionPrompt.replace(
+ /\{\{planVersion\}\}/g,
+ () => String(planVersion - 1)
+ );
revisionPrompt = revisionPrompt.replace(
/\{\{previousPlan\}\}/g,
- hasEdits
- ? approvalResult.editedPlan || currentPlanContent
- : currentPlanContent
+ () =>
+ hasEdits
+ ? approvalResult.editedPlan || currentPlanContent
+ : currentPlanContent
);
revisionPrompt = revisionPrompt.replace(
/\{\{userFeedback\}\}/g,
- approvalResult.feedback ||
- 'Please revise the plan based on the edits above.'
+ () =>
+ approvalResult.feedback ||
+ 'Please revise the plan based on the edits above.'
);
revisionPrompt = revisionPrompt.replace(
/\{\{planningMode\}\}/g,
- planningMode
+ () => planningMode
);
revisionPrompt = revisionPrompt.replace(
/\{\{taskFormatExample\}\}/g,
- taskFormatExample
+ () => taskFormatExample
);🤖 Prompt for AI Agents |
||
|
|
||
| // Update status to regenerating | ||
| await this.updateFeaturePlanSpec(projectPath, featureId, { | ||
|
|
@@ -4663,6 +4696,26 @@ After generating the revised spec, output: | |
| const revisedTasks = parseTasksFromSpec(currentPlanContent); | ||
| logger.info(`Revised plan has ${revisedTasks.length} tasks`); | ||
|
|
||
| // Warn if no tasks found in spec/full mode - this may cause fallback to single-agent | ||
| if ( | ||
| revisedTasks.length === 0 && | ||
| (planningMode === 'spec' || planningMode === 'full') | ||
| ) { | ||
| logger.warn( | ||
| `WARNING: Revised plan in ${planningMode} mode has no tasks! ` + | ||
| `This will cause fallback to single-agent execution. ` + | ||
| `The AI may have omitted the required \`\`\`tasks block.` | ||
|
Comment on lines
+4704
to
+4707
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning message uses string concatenation, which can be less readable for multi-line strings or when interpolating variables. Using a template literal ( `WARNING: Revised plan in ${planningMode} mode has no tasks!\nThis will cause fallback to single-agent execution.\nThe AI may have omitted the required \`\`\`tasks block.` |
||
| ); | ||
| this.emitAutoModeEvent('plan_revision_warning', { | ||
| featureId, | ||
| projectPath, | ||
| branchName, | ||
| planningMode, | ||
| warning: | ||
| 'Revised plan missing tasks block - will use single-agent execution', | ||
| }); | ||
| } | ||
|
|
||
| // Update planSpec with revised content | ||
| await this.updateFeaturePlanSpec(projectPath, featureId, { | ||
| status: 'generated', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repetitive use of
.replace()for each placeholder can make the code less readable and harder to maintain as the number of placeholders increases. Consider encapsulating this logic within a helper function or using a more declarative approach for string templating to make the code cleaner and more scalable.