@exaudeus/workrail 0.1.9 → 0.2.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/dist/application/decorators/simple-output-decorator.js +1 -1
- package/dist/application/services/workflow-service.d.ts +2 -0
- package/dist/application/services/workflow-service.js +95 -0
- package/package.json +1 -1
- package/spec/mcp-api-v1.0.md +2 -2
- package/workflows/coding-task-workflow-with-loops.json +3 -3
- package/spec/examples/coding-task-workflow.json +0 -160
- package/workflows/coding-task-workflow.json +0 -352
- package/workflows/systemic-bug-investigation.json +0 -398
- package/workflows/systemic-bug-investigation.json.bak +0 -196
|
@@ -33,7 +33,7 @@ The MCP server is STATELESS. You MUST send required data with each request:
|
|
|
33
33
|
**EXAMPLE - Loop Context:**
|
|
34
34
|
\`\`\`json
|
|
35
35
|
{
|
|
36
|
-
"workflowId": "coding-task-workflow",
|
|
36
|
+
"workflowId": "coding-task-workflow-with-loops",
|
|
37
37
|
"completedSteps": ["phase-1", "phase-2", "loop-step-1"],
|
|
38
38
|
"context": {
|
|
39
39
|
// Required: condition/template variables
|
|
@@ -34,6 +34,8 @@ export declare class DefaultWorkflowService implements WorkflowService {
|
|
|
34
34
|
context?: ConditionContext;
|
|
35
35
|
}>;
|
|
36
36
|
private buildStepPrompt;
|
|
37
|
+
private collectConditionVars;
|
|
38
|
+
private collectEqualsValues;
|
|
37
39
|
private findLoopStepById;
|
|
38
40
|
validateStepOutput(workflowId: string, stepId: string, output: string): Promise<{
|
|
39
41
|
valid: boolean;
|
|
@@ -189,6 +189,61 @@ class DefaultWorkflowService {
|
|
|
189
189
|
}
|
|
190
190
|
return this.getNextStep(workflowId, completedSteps, loopStartSizeCheck.context);
|
|
191
191
|
}
|
|
192
|
+
if (!nextStep) {
|
|
193
|
+
const remainingConditionalSteps = workflow.steps.filter((step) => {
|
|
194
|
+
if (completed.includes(step.id))
|
|
195
|
+
return false;
|
|
196
|
+
if (loopBodySteps.has(step.id))
|
|
197
|
+
return false;
|
|
198
|
+
return !!step.runCondition;
|
|
199
|
+
});
|
|
200
|
+
if (remainingConditionalSteps.length > 0) {
|
|
201
|
+
const requiredVars = new Set();
|
|
202
|
+
const allowedValues = {};
|
|
203
|
+
for (const step of remainingConditionalSteps) {
|
|
204
|
+
const condition = step.runCondition;
|
|
205
|
+
this.collectConditionVars(condition, requiredVars);
|
|
206
|
+
this.collectEqualsValues(condition, allowedValues);
|
|
207
|
+
}
|
|
208
|
+
const issues = [];
|
|
209
|
+
for (const variableName of requiredVars) {
|
|
210
|
+
const currentValue = enhancedContext[variableName];
|
|
211
|
+
const allowed = allowedValues[variableName]
|
|
212
|
+
? Array.from(allowedValues[variableName])
|
|
213
|
+
: [];
|
|
214
|
+
if (currentValue === undefined || currentValue === null || currentValue === '') {
|
|
215
|
+
if (allowed.length > 0) {
|
|
216
|
+
issues.push(`Set '${variableName}' to one of: ${allowed.map(v => `'${v}'`).join(', ')}`);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
issues.push(`Provide a value for '${variableName}'`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if (allowed.length > 0) {
|
|
223
|
+
const matchesExactly = allowed.some(v => v === String(currentValue));
|
|
224
|
+
const matchesCaseInsensitive = allowed.some(v => v.toLowerCase() === String(currentValue).toLowerCase());
|
|
225
|
+
if (!matchesExactly) {
|
|
226
|
+
if (matchesCaseInsensitive) {
|
|
227
|
+
issues.push(`Normalize casing for '${variableName}': use one of ${allowed.map(v => `'${v}'`).join(', ')} (current '${currentValue}')`);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
issues.push(`Adjust '${variableName}' to one of: ${allowed.map(v => `'${v}'`).join(', ')} (current '${currentValue}')`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (issues.length > 0) {
|
|
236
|
+
return {
|
|
237
|
+
step: null,
|
|
238
|
+
guidance: {
|
|
239
|
+
prompt: `No eligible step due to unmet conditions. Please update context:\n- ${issues.join('\n- ')}`
|
|
240
|
+
},
|
|
241
|
+
isComplete: false,
|
|
242
|
+
context: enhancedContext
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
192
247
|
const isComplete = !nextStep;
|
|
193
248
|
let finalPrompt = 'Workflow complete.';
|
|
194
249
|
if (nextStep) {
|
|
@@ -232,6 +287,46 @@ class DefaultWorkflowService {
|
|
|
232
287
|
}
|
|
233
288
|
return finalPrompt;
|
|
234
289
|
}
|
|
290
|
+
collectConditionVars(condition, sink) {
|
|
291
|
+
if (!condition || typeof condition !== 'object')
|
|
292
|
+
return;
|
|
293
|
+
if (typeof condition.var === 'string' && condition.var.length > 0) {
|
|
294
|
+
sink.add(condition.var);
|
|
295
|
+
}
|
|
296
|
+
if (Array.isArray(condition.and)) {
|
|
297
|
+
for (const sub of condition.and)
|
|
298
|
+
this.collectConditionVars(sub, sink);
|
|
299
|
+
}
|
|
300
|
+
if (Array.isArray(condition.or)) {
|
|
301
|
+
for (const sub of condition.or)
|
|
302
|
+
this.collectConditionVars(sub, sink);
|
|
303
|
+
}
|
|
304
|
+
if (condition.not)
|
|
305
|
+
this.collectConditionVars(condition.not, sink);
|
|
306
|
+
}
|
|
307
|
+
collectEqualsValues(condition, sink) {
|
|
308
|
+
if (!condition || typeof condition !== 'object')
|
|
309
|
+
return;
|
|
310
|
+
if (typeof condition.var === 'string' && Object.prototype.hasOwnProperty.call(condition, 'equals')) {
|
|
311
|
+
const variableName = condition.var;
|
|
312
|
+
const value = condition.equals;
|
|
313
|
+
if (value !== undefined && value !== null) {
|
|
314
|
+
if (!sink[variableName])
|
|
315
|
+
sink[variableName] = new Set();
|
|
316
|
+
sink[variableName].add(String(value));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (Array.isArray(condition.and)) {
|
|
320
|
+
for (const sub of condition.and)
|
|
321
|
+
this.collectEqualsValues(sub, sink);
|
|
322
|
+
}
|
|
323
|
+
if (Array.isArray(condition.or)) {
|
|
324
|
+
for (const sub of condition.or)
|
|
325
|
+
this.collectEqualsValues(sub, sink);
|
|
326
|
+
}
|
|
327
|
+
if (condition.not)
|
|
328
|
+
this.collectEqualsValues(condition.not, sink);
|
|
329
|
+
}
|
|
235
330
|
findLoopStepById(workflow, stepId) {
|
|
236
331
|
const step = workflow.steps.find(s => s.id === stepId);
|
|
237
332
|
return step && (0, workflow_types_1.isLoopStep)(step) ? step : null;
|
package/package.json
CHANGED
package/spec/mcp-api-v1.0.md
CHANGED
|
@@ -175,7 +175,7 @@ Retrieves workflow information with configurable detail level. Supports progress
|
|
|
175
175
|
"jsonrpc": "2.0",
|
|
176
176
|
"id": 2,
|
|
177
177
|
"result": {
|
|
178
|
-
"id": "coding-task-workflow",
|
|
178
|
+
"id": "coding-task-workflow-with-loops",
|
|
179
179
|
"name": "Excellent Adaptive Coding Workflow",
|
|
180
180
|
"description": "A comprehensive workflow for AI-assisted coding",
|
|
181
181
|
"version": "0.1.0",
|
|
@@ -201,7 +201,7 @@ Retrieves workflow information with configurable detail level. Supports progress
|
|
|
201
201
|
"jsonrpc": "2.0",
|
|
202
202
|
"id": 2,
|
|
203
203
|
"result": {
|
|
204
|
-
"id": "coding-task-workflow",
|
|
204
|
+
"id": "coding-task-workflow-with-loops",
|
|
205
205
|
"name": "Excellent Adaptive Coding Workflow",
|
|
206
206
|
"description": "A comprehensive workflow for AI-assisted coding",
|
|
207
207
|
"version": "0.1.0",
|
|
@@ -431,7 +431,7 @@
|
|
|
431
431
|
{
|
|
432
432
|
"id": "phase-6-prep",
|
|
433
433
|
"title": "PREP: Prepare for Step {{currentStepNumber + 1}}",
|
|
434
|
-
"prompt": "**PREPARATION PHASE for Step {{currentStepNumber + 1}}/{{totalImplementationSteps}}**\n\nBefore implementing this step, you must first PREPARE:\n\n1. **Read implementation_plan.md** and locate step #{{currentStepNumber + 1}}\n2. **Extract step details**: Note the title, description, and expected outputs\n3. **Confirm prerequisites**: Verify the previous step (if any) was completed correctly\n4. **Validate current state**: Ensure the plan for this step is still valid in the current codebase\n5. **List requirements**: Identify all required inputs, files, or dependencies\n\n**BRANCH SETUP (first iteration only):** If this is the first implementation step ({{currentStepNumber}} === 0):\n- Check git availability with 'git status'\n- If available, create feature branch: 'git checkout -b wip-[unique-task-id]'\n- Track the featureBranch variable for later use\n- If git unavailable: Skip branching, log in CONTEXT.md\n\n**
|
|
434
|
+
"prompt": "**PREPARATION PHASE for Step {{currentStepNumber + 1}}/{{totalImplementationSteps}}**\n\nBefore implementing this step, you must first PREPARE:\n\n1. **Read implementation_plan.md** and locate step #{{currentStepNumber + 1}}\n2. **Extract step details**: Note the title, description, and expected outputs\n3. **Confirm prerequisites**: Verify the previous step (if any) was completed correctly\n4. **Validate current state**: Ensure the plan for this step is still valid in the current codebase\n5. **List requirements**: Identify all required inputs, files, or dependencies\n\n**BRANCH SETUP (first iteration only):** If this is the first implementation step ({{currentStepNumber}} === 0):\n- Check git availability with 'git status'\n- If available, create feature branch: 'git checkout -b wip-[unique-task-id]'\n- Track the featureBranch variable for later use\n- If git unavailable: Skip branching, log in CONTEXT.md\n\n**Do not proceed if anything is unclear or missing.**",
|
|
435
435
|
"agentRole": "You are preparing to implement a specific step from the plan. Be meticulous in verifying all prerequisites are met before proceeding.",
|
|
436
436
|
"guidance": [
|
|
437
437
|
"This is step {{currentStepNumber + 1}} of {{totalImplementationSteps}} total implementation steps",
|
|
@@ -444,7 +444,7 @@
|
|
|
444
444
|
{
|
|
445
445
|
"id": "phase-6-implement",
|
|
446
446
|
"title": "IMPLEMENT: Execute Step {{currentStepNumber + 1}}",
|
|
447
|
-
"prompt": "**IMPLEMENTATION PHASE for Step {{currentStepNumber + 1}}/{{totalImplementationSteps}}**\n\nNow implement the step you just prepared for:\n\n**Instructions:**\n1. Re-read step #{{currentStepNumber + 1}} from implementation_plan.md\n2. Focus only on this single step\n3. useTools() to make code changes\n4. Follow quality standards\n5. Adapt to unexpected discoveries\n6. createFile() for ALL code changes\n\n**Remember:** applyUserRules() and matchPatterns() throughout.\n\n**Progress Tracking:**\n- This is step {{currentStepNumber + 1}} of {{totalImplementationSteps}}\n- If we've done > 20 steps total, pause for user intervention\n\n**CONTEXT UPDATES:** If this is every 3rd step ({{currentStepNumber + 1}} % 3 === 0):\n- Update CONTEXT.md\n- addResumptionJson(phase-6-implement)\n- updateDecisionLog()\n- List files modified with line ranges\n\n
|
|
447
|
+
"prompt": "**IMPLEMENTATION PHASE for Step {{currentStepNumber + 1}}/{{totalImplementationSteps}}**\n\nNow implement the step you just prepared for:\n\n**Instructions:**\n1. Re-read step #{{currentStepNumber + 1}} from implementation_plan.md\n2. Focus only on this single step\n3. useTools() to make code changes\n4. Follow quality standards\n5. Adapt to unexpected discoveries\n6. createFile() for ALL code changes\n\n**Remember:** applyUserRules() and matchPatterns() throughout.\n\n**Progress Tracking:**\n- This is step {{currentStepNumber + 1}} of {{totalImplementationSteps}}\n- If we've done > 20 steps total, pause for user intervention\n\n**CONTEXT UPDATES:** If this is every 3rd step ({{currentStepNumber + 1}} % 3 === 0):\n- Update CONTEXT.md\n- addResumptionJson(phase-6-implement)\n- updateDecisionLog()\n- List files modified with line ranges\n\n",
|
|
448
448
|
"agentRole": "You are implementing a specific step from the approved plan. Focus on precise execution while maintaining code quality.",
|
|
449
449
|
"guidance": [
|
|
450
450
|
"Implement only what this step requires",
|
|
@@ -456,7 +456,7 @@
|
|
|
456
456
|
{
|
|
457
457
|
"id": "phase-6-verify",
|
|
458
458
|
"title": "VERIFY: Validate Step {{currentStepNumber + 1}}",
|
|
459
|
-
"prompt": "**VERIFICATION PHASE for Step {{currentStepNumber + 1}}/{{totalImplementationSteps}}**\n\nVerify the implementation is complete and correct:\n\n**Required:** verifyImplementation()\n\n**COMMIT Decision (if all passes):**\n- checkAutomation(commit)\n- gitCommit(type, scope: description)\n- If git unavailable: Log in CONTEXT.md\n\n**FAILURE PROTOCOL:** If verification fails after 2 attempts:\n1. Do not try a third time\n2. Fall back to alternative tools\n3. updateDecisionLog() with failure details\n4. Present summary and recommendations\n5. Set 'verificationFailed' context variable to true\n\n
|
|
459
|
+
"prompt": "**VERIFICATION PHASE for Step {{currentStepNumber + 1}}/{{totalImplementationSteps}}**\n\nVerify the implementation is complete and correct:\n\n**Required:** verifyImplementation()\n\n**COMMIT Decision (if all passes):**\n- checkAutomation(commit)\n- gitCommit(type, scope: description)\n- If git unavailable: Log in CONTEXT.md\n\n**FAILURE PROTOCOL:** If verification fails after 2 attempts:\n1. Do not try a third time\n2. Fall back to alternative tools\n3. updateDecisionLog() with failure details\n4. Present summary and recommendations\n5. Set 'verificationFailed' context variable to true\n\n",
|
|
460
460
|
"agentRole": "You are verifying the implementation meets all quality standards. Be thorough but respect failure bounds.",
|
|
461
461
|
"guidance": [
|
|
462
462
|
"All three verification steps must pass",
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "coding-task-workflow",
|
|
3
|
-
"name": "Excellent Adaptive Coding Workflow with Devil's Advocate Review",
|
|
4
|
-
"version": "0.0.1",
|
|
5
|
-
"description": "A comprehensive and resilient workflow for AI-assisted coding. It adaptively sizes tasks, performs a critical self-review of its own plans, provides efficiency options, enforces closed-loop validation, and defines a robust protocol for handling failures.",
|
|
6
|
-
"preconditions": [
|
|
7
|
-
"User has a clear task description (e.g., from Jira, a dev doc, or a BRD).",
|
|
8
|
-
"The agent has access to necessary tools like `grep`, file readers/editors, and a terminal for commands.",
|
|
9
|
-
"The agent has access to the relevant codebase files."
|
|
10
|
-
],
|
|
11
|
-
"metaGuidance": [
|
|
12
|
-
"This workflow follows the PREP -> IMPLEMENT -> VERIFY pattern for each step in the plan.",
|
|
13
|
-
"Human approval is required after the Devil's Advocate review and before final completion.",
|
|
14
|
-
"Each implementation step should be a small, logical, and committable chunk of work.",
|
|
15
|
-
"The agent should never guess or assume. Always ask for clarification or use tools to find missing information.",
|
|
16
|
-
"Maintain existing coding conventions and architectural patterns found in the codebase."
|
|
17
|
-
],
|
|
18
|
-
"steps": [
|
|
19
|
-
{
|
|
20
|
-
"id": "phase-0-intelligent-triage",
|
|
21
|
-
"title": "Phase 0: Intelligent Task Triage & Complexity Analysis",
|
|
22
|
-
"prompt": "**ANALYZE**: Evaluate the provided task for complexity indicators:\n\n**Small Path Indicators:**\n- Single function changes or minor refactoring\n- Clear bug fixes with obvious solutions\n- Simple configuration changes\n- Low risk of side effects\n- Well-defined, narrow scope\n\n**Medium Path Indicators:**\n- Multi-file changes or moderate features\n- Standard development work\n- Some unknowns but manageable scope\n- Moderate complexity with clear boundaries\n- Requires planning but not architectural analysis\n\n**Large Path Indicators:**\n- Architectural changes or major features\n- Unfamiliar codebase areas\n- High complexity or significant risk\n- Multiple system interactions\n- Requires deep analysis and careful planning\n\n**IMPLEMENT**: \n1. Analyze the task description for the above indicators\n2. Recommend a complexity level (Small/Medium/Large) with detailed reasoning\n3. Set the taskComplexity context variable\n4. Ask user if they agree or want to override your classification\n5. For Medium tasks, ask: \"Would you like optional deep codebase analysis?\" (sets requestDeepAnalysis context variable)\n\n**VERIFY**: Confirm the complexity classification and any optional analysis preferences before proceeding.",
|
|
23
|
-
"guidance": [
|
|
24
|
-
"Be thorough in your analysis - this determines the entire workflow path",
|
|
25
|
-
"Consider both technical complexity and business risk",
|
|
26
|
-
"When in doubt, err on the side of more thorough analysis (higher complexity)",
|
|
27
|
-
"Always allow human override of your classification",
|
|
28
|
-
"Set context variables that will be used for conditional step execution"
|
|
29
|
-
],
|
|
30
|
-
"requireConfirmation": true
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"id": "phase-1-scoping",
|
|
34
|
-
"runCondition": {
|
|
35
|
-
"var": "taskComplexity",
|
|
36
|
-
"not_equals": "Small"
|
|
37
|
-
},
|
|
38
|
-
"title": "Phase 1: Task Briefing & Scope Definition",
|
|
39
|
-
"prompt": "Your first goal is to understand the task. Analyze the following request, summarize your understanding, ask clarifying questions, and assess which parts of the codebase are relevant.\n\n**Task Description:**\n[User inserts detailed task description here]\n\n**Key Objectives & Success Criteria:**\n[User lists specific, measurable success criteria here]\n\n**Scope and Constraints:**\n[User defines boundaries or areas to avoid here]\n\nFinally, based on your analysis, perform a sanity check on the initial complexity sizing. If you believe the classification is incorrect, state your reasoning and ask for confirmation before proceeding. For example: 'You classified this as Medium, but my analysis shows it impacts several core architectural components. I recommend we upgrade to the Large path to perform a Deep Analysis. Do you agree?'",
|
|
40
|
-
"guidance": [
|
|
41
|
-
"Provide a complete task description. Vague requests will lead to poor plans and wasted effort.",
|
|
42
|
-
"This step is automatically skipped for Small tasks based on the complexity classification"
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"id": "phase-1b-deep-analysis-mandatory",
|
|
47
|
-
"runCondition": {
|
|
48
|
-
"var": "taskComplexity",
|
|
49
|
-
"equals": "Large"
|
|
50
|
-
},
|
|
51
|
-
"title": "Phase 1b: Mandatory Deep Codebase Analysis",
|
|
52
|
-
"prompt": "Your goal is to become an expert on the attached codebase. This deep analysis is mandatory for Large tasks due to their complexity and risk. Your analysis must include:\n1. **Architecture:** Main modules, layers, and patterns.\n2. **Key Concepts:** Core models, conventions, and important components.\n3. **Execution Flow:** Trace major features or entry points.\n4. **Code Quality Assessment:** Note maintainability, readability, or coupling issues.\n5. **Testing Strategy:** Describe how the code is tested.\n6. **Opportunities:** Suggest refactorings or improvements.\n\nProvide summaries and code examples to illustrate your findings. Be exhaustive, as if preparing onboarding documentation for a senior engineer.",
|
|
53
|
-
"askForFiles": true,
|
|
54
|
-
"guidance": [
|
|
55
|
-
"This step is mandatory for Large tasks due to their complexity and risk",
|
|
56
|
-
"Ensure all relevant source files are attached or accessible to the agent before running this step",
|
|
57
|
-
"Be thorough - this analysis will inform the entire implementation strategy"
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"id": "phase-1b-deep-analysis-optional",
|
|
62
|
-
"runCondition": {
|
|
63
|
-
"and": [
|
|
64
|
-
{
|
|
65
|
-
"var": "taskComplexity",
|
|
66
|
-
"equals": "Medium"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"var": "requestDeepAnalysis",
|
|
70
|
-
"equals": true
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"title": "Phase 1b: Optional Deep Codebase Analysis",
|
|
75
|
-
"prompt": "You requested optional deep analysis for this Medium task. Your goal is to become an expert on the attached codebase. Your analysis must include:\n1. **Architecture:** Main modules, layers, and patterns.\n2. **Key Concepts:** Core models, conventions, and important components.\n3. **Execution Flow:** Trace major features or entry points.\n4. **Code Quality Assessment:** Note maintainability, readability, or coupling issues.\n5. **Testing Strategy:** Describe how the code is tested.\n6. **Opportunities:** Suggest refactorings or improvements.\n\nProvide summaries and code examples to illustrate your findings. Be exhaustive, as if preparing onboarding documentation for a senior engineer.",
|
|
76
|
-
"askForFiles": true,
|
|
77
|
-
"guidance": [
|
|
78
|
-
"This optional analysis was requested for a Medium task",
|
|
79
|
-
"Ensure all relevant source files are attached or accessible to the agent before running this step",
|
|
80
|
-
"Focus on areas most relevant to the current task"
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"id": "phase-2-planning",
|
|
85
|
-
"runCondition": {
|
|
86
|
-
"var": "taskComplexity",
|
|
87
|
-
"not_equals": "Small"
|
|
88
|
-
},
|
|
89
|
-
"title": "Phase 2: Create Detailed Implementation Plan",
|
|
90
|
-
"prompt": "Your goal is to produce a thorough and actionable plan of attack. Do not write any code. Your plan must be detailed, broken into committable phases, and justified.\n\nYour plan must include these sections:\n1. **Goal Clarification:** Your understanding of the goal, assumptions, and success criteria.\n2. **Impact Assessment:** Affected codebase parts, dependencies, and risks.\n3. **Implementation Strategy:** A list of discrete, actionable steps. Each step must detail the task, its rationale, inputs, and outputs.\n4. **Final Review Checklist:** A specific checklist of items that must be verified to consider this entire task complete. This will be used in the final review phase.\n\nPresent this as a formal proposal.",
|
|
91
|
-
"guidance": [
|
|
92
|
-
"The agent will now proceed to critique its own plan in the next step. Withhold your final approval until after that critique.",
|
|
93
|
-
"This step is automatically skipped for Small tasks based on the complexity classification"
|
|
94
|
-
]
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"id": "phase-2b-devil-advocate-review",
|
|
98
|
-
"runCondition": {
|
|
99
|
-
"var": "taskComplexity",
|
|
100
|
-
"not_equals": "Small"
|
|
101
|
-
},
|
|
102
|
-
"title": "Phase 2b: Devil's Advocate Plan Review",
|
|
103
|
-
"prompt": "Your new goal is to act as a skeptical but fair senior principal engineer. Your task is to perform a 'devil's advocate' review of the implementation plan you just created in Phase 2. The objective is not to discard the plan, but to rigorously stress-test it and make it stronger. Your critique must be balanced and evidence-based.\n\nAnalyze the plan through the following lenses. For every point you make (positive or negative), you must cite specific evidence from the plan, the codebase, or the initial task description.\n\n1. **Hidden Assumptions:** What assumptions does this plan make about the codebase, user behavior, or existing data that might be incorrect?\n2. **Potential Risks & Unintended Side Effects:** What is the biggest risk of this plan? Could it impact performance, security, or another feature in a negative way?\n3. **Overlooked Complexities or Edge Cases:** What specific edge cases (e.g., empty states, invalid inputs, race conditions) does the plan fail to explicitly address?\n4. **Alternative Approaches:** Briefly propose at least one alternative technical approach. What are the pros and cons of the alternative versus the current plan?\n5. **Plan Strengths:** To ensure a balanced review, explicitly state the strongest parts of the plan. What aspects are well-thought-out and likely to succeed?\n\nConclude with a balanced summary. If you found issues, provide concrete suggestions for how to amend the plan. Finally, give a confidence score (1-10) for the plan *if* your suggestions are implemented.",
|
|
104
|
-
"guidance": [
|
|
105
|
-
"This is a critical thinking step. The agent's goal is to find weaknesses in its *own* prior work to improve it. This is a sign of a high-functioning process.",
|
|
106
|
-
"Evaluate the agent's points. Not all 'risks' it identifies may be realistic. Use your judgment to decide which suggestions to incorporate into the plan.",
|
|
107
|
-
"After this review, you can ask the agent to create a final, amended version of the plan before you give your final approval to proceed with implementation.",
|
|
108
|
-
"This step is automatically skipped for Small tasks based on the complexity classification"
|
|
109
|
-
],
|
|
110
|
-
"requireConfirmation": true
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"id": "phase-3-iterative-implementation",
|
|
114
|
-
"title": "Phase 3: Iterative Implementation (PREP -> IMPLEMENT -> VERIFY)",
|
|
115
|
-
"prompt": "The implementation phase has now begun. **Please provide me with the next single step from the approved plan.** If we are on the 'Small' path, provide a single, clear implementation instruction.\n\nI will execute *only* that step using the PREP -> IMPLEMENT -> VERIFY cycle defined in the guidance below, and then await your command for the subsequent step. This process will repeat until all steps are complete.",
|
|
116
|
-
"guidance": [
|
|
117
|
-
"**Efficiency Tip:** For high-confidence plans, you may provide multiple step instructions at once. I will execute them sequentially, performing the P->I->V cycle for each, and will only pause to ask for input if I encounter a verification failure or ambiguity.",
|
|
118
|
-
"**PREP:** Before implementing each step, you must first PREPARE. Re-read the step's description, confirm the previous step was completed correctly, verify the plan for this step is still valid in the current codebase, and list all required inputs or files. Do not proceed if anything is unclear.",
|
|
119
|
-
"**IMPLEMENT:** After preparation is confirmed, you will IMPLEMENT the step. Focus only on this single step. Use your tools to make the necessary code changes, adhering to all quality standards. Provide a commit message upon completion.",
|
|
120
|
-
"**VERIFY:** Immediately after implementation, you must VERIFY your work. Your verification for this step **is not complete until you have**:\n1. **Written necessary unit/integration tests** for the new logic.\n2. **Run the full test suite** to ensure no regressions were introduced.\n3. **Performed a critical self-review** of the changes against the plan, checking for code quality, side effects, and architectural alignment.\n\n**Failure Protocol:** If a verification failure cannot be resolved after two attempts, you must halt. Do not try a third time. Instead, present a summary of the problem, detail your failed attempts, and recommend a course of action to the user (e.g., 'revert this step and re-plan', 'request more information', 'proceed with a known issue')."
|
|
121
|
-
]
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"id": "phase-4-final-review",
|
|
125
|
-
"title": "Phase 4: Final Review & Completion",
|
|
126
|
-
"prompt": "All planned steps have been implemented and verified. Your final goal is to perform a holistic review by validating the work against the **'Final Review Checklist'** created and approved during Phase 2.\n\nFor each item on that checklist, provide a confirmation and evidence that it has been met. Conclude with a summary of any potential follow-ups or new dependencies to note.",
|
|
127
|
-
"guidance": [
|
|
128
|
-
"This is the final quality check. Ensure the agent's summary and checklist validation align with your understanding of the completed work."
|
|
129
|
-
],
|
|
130
|
-
"requireConfirmation": true,
|
|
131
|
-
"validationCriteria": [
|
|
132
|
-
{
|
|
133
|
-
"type": "contains",
|
|
134
|
-
"value": "checklist",
|
|
135
|
-
"message": "Should reference the final review checklist"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
"type": "contains",
|
|
139
|
-
"value": "complete",
|
|
140
|
-
"message": "Should confirm completion of all requirements"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
"type": "length",
|
|
144
|
-
"min": 150,
|
|
145
|
-
"condition": {
|
|
146
|
-
"var": "taskComplexity",
|
|
147
|
-
"not_equals": "Small"
|
|
148
|
-
},
|
|
149
|
-
"message": "Complex tasks require detailed final review"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"type": "regex",
|
|
153
|
-
"pattern": "(?!.*TODO)",
|
|
154
|
-
"message": "Should not contain TODO items"
|
|
155
|
-
}
|
|
156
|
-
],
|
|
157
|
-
"hasValidation": true
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
}
|