mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
refactor(auto-mode): Enhance revision prompt customization and task format validation
- Updated the revision prompt generation to utilize a customizable template, allowing for dynamic insertion of plan version, previous plan content, user feedback, and task format examples. - Added validation to ensure the presence of a tasks block in the revised specification, with clear instructions on the required format to prevent execution issues. - Introduced logging for scenarios where no tasks are found in the revised plan, warning about potential fallback to single-agent execution.
This commit is contained in:
@@ -4597,21 +4597,54 @@ This mock response was generated because AUTOMAKER_MOCK_AGENT=true was set.
|
|||||||
planVersion,
|
planVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build revision prompt
|
// Build revision prompt using customizable template
|
||||||
let revisionPrompt = `The user has requested revisions to the plan/specification.
|
const revisionPrompts = await getPromptCustomization(
|
||||||
|
this.settingsService,
|
||||||
|
'[AutoMode]'
|
||||||
|
);
|
||||||
|
|
||||||
## Previous Plan (v${planVersion - 1})
|
// Get task format example based on planning mode
|
||||||
${hasEdits ? approvalResult.editedPlan : currentPlanContent}
|
const taskFormatExample =
|
||||||
|
planningMode === 'full'
|
||||||
|
? `\`\`\`tasks
|
||||||
|
## Phase 1: Foundation
|
||||||
|
- [ ] T001: [Description] | File: [path/to/file]
|
||||||
|
- [ ] T002: [Description] | File: [path/to/file]
|
||||||
|
|
||||||
## User Feedback
|
## Phase 2: Core Implementation
|
||||||
${approvalResult.feedback || 'Please revise the plan based on the edits above.'}
|
- [ ] 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]
|
||||||
|
\`\`\``;
|
||||||
|
|
||||||
## Instructions
|
let revisionPrompt = revisionPrompts.taskExecution.planRevisionTemplate;
|
||||||
Please regenerate the specification incorporating the user's feedback.
|
revisionPrompt = revisionPrompt.replace(
|
||||||
Keep the same format with the \`\`\`tasks block for task definitions.
|
/\{\{planVersion\}\}/g,
|
||||||
After generating the revised spec, output:
|
String(planVersion - 1)
|
||||||
"[SPEC_GENERATED] Please review the revised specification above."
|
);
|
||||||
`;
|
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
|
||||||
|
);
|
||||||
|
|
||||||
// Update status to regenerating
|
// Update status to regenerating
|
||||||
await this.updateFeaturePlanSpec(projectPath, featureId, {
|
await this.updateFeaturePlanSpec(projectPath, featureId, {
|
||||||
@@ -4663,6 +4696,26 @@ After generating the revised spec, output:
|
|||||||
const revisedTasks = parseTasksFromSpec(currentPlanContent);
|
const revisedTasks = parseTasksFromSpec(currentPlanContent);
|
||||||
logger.info(`Revised plan has ${revisedTasks.length} tasks`);
|
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.`
|
||||||
|
);
|
||||||
|
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
|
// Update planSpec with revised content
|
||||||
await this.updateFeaturePlanSpec(projectPath, featureId, {
|
await this.updateFeaturePlanSpec(projectPath, featureId, {
|
||||||
status: 'generated',
|
status: 'generated',
|
||||||
|
|||||||
@@ -965,8 +965,20 @@ export const DEFAULT_PLAN_REVISION_TEMPLATE = `The user has requested revisions
|
|||||||
|
|
||||||
## Instructions
|
## Instructions
|
||||||
Please regenerate the specification incorporating the user's feedback.
|
Please regenerate the specification incorporating the user's feedback.
|
||||||
Keep the same format with the \`\`\`tasks block for task definitions.
|
**Current planning mode: {{planningMode}}**
|
||||||
After generating the revised spec, output:
|
|
||||||
|
**CRITICAL REQUIREMENT**: Your revised specification MUST include a \`\`\`tasks code block containing task definitions in the EXACT format shown below. This is MANDATORY - without the tasks block, the system cannot track or execute tasks properly.
|
||||||
|
|
||||||
|
### Required Task Format
|
||||||
|
{{taskFormatExample}}
|
||||||
|
|
||||||
|
**IMPORTANT**:
|
||||||
|
1. The \`\`\`tasks block must appear in your response
|
||||||
|
2. Each task MUST start with "- [ ] T###:" where ### is a sequential number (T001, T002, T003, etc.)
|
||||||
|
3. Each task MUST include "| File:" followed by the primary file path
|
||||||
|
4. Tasks should be ordered by dependencies (foundational tasks first)
|
||||||
|
|
||||||
|
After generating the revised spec with the tasks block, output:
|
||||||
"[SPEC_GENERATED] Please review the revised specification above."`;
|
"[SPEC_GENERATED] Please review the revised specification above."`;
|
||||||
|
|
||||||
export const DEFAULT_CONTINUATION_AFTER_APPROVAL_TEMPLATE = `The plan/specification has been approved. Now implement it.
|
export const DEFAULT_CONTINUATION_AFTER_APPROVAL_TEMPLATE = `The plan/specification has been approved. Now implement it.
|
||||||
|
|||||||
Reference in New Issue
Block a user