@exaudeus/workrail 0.0.13 → 0.0.14

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "MCP server for structured workflow orchestration and step-by-step task guidance",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -94,8 +94,63 @@
94
94
  "default": false
95
95
  },
96
96
  "requireConfirmation": {
97
- "type": "boolean",
98
- "description": "Whether to require user confirmation before proceeding",
97
+ "oneOf": [
98
+ {
99
+ "type": "boolean",
100
+ "description": "Whether to require user confirmation before proceeding"
101
+ },
102
+ {
103
+ "type": "object",
104
+ "description": "Conditional logic that determines if confirmation is required based on context variables. Uses same expression format as runCondition.",
105
+ "properties": {
106
+ "var": {
107
+ "type": "string",
108
+ "description": "Variable name from execution context"
109
+ },
110
+ "equals": {
111
+ "description": "Check if variable equals this value"
112
+ },
113
+ "not_equals": {
114
+ "description": "Check if variable does not equal this value"
115
+ },
116
+ "gt": {
117
+ "type": "number",
118
+ "description": "Check if variable is greater than this number"
119
+ },
120
+ "gte": {
121
+ "type": "number",
122
+ "description": "Check if variable is greater than or equal to this number"
123
+ },
124
+ "lt": {
125
+ "type": "number",
126
+ "description": "Check if variable is less than this number"
127
+ },
128
+ "lte": {
129
+ "type": "number",
130
+ "description": "Check if variable is less than or equal to this number"
131
+ },
132
+ "and": {
133
+ "type": "array",
134
+ "description": "Logical AND of multiple conditions",
135
+ "items": {
136
+ "type": "object"
137
+ }
138
+ },
139
+ "or": {
140
+ "type": "array",
141
+ "description": "Logical OR of multiple conditions",
142
+ "items": {
143
+ "type": "object"
144
+ }
145
+ },
146
+ "not": {
147
+ "type": "object",
148
+ "description": "Logical NOT of a condition"
149
+ }
150
+ },
151
+ "additionalProperties": false
152
+ }
153
+ ],
99
154
  "default": false
100
155
  },
101
156
  "runCondition": {
@@ -1,167 +1,250 @@
1
1
  {
2
2
  "id": "coding-task-workflow",
3
3
  "name": "Excellent Adaptive Coding Workflow with Devil's Advocate Review",
4
- "version": "0.2.0",
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.",
4
+ "version": "0.5.0",
5
+ "description": "A comprehensive and resilient workflow for AI-assisted coding. It adaptively sizes tasks with dynamic re-triage, performs early codebase analysis to inform planning, includes intelligent requirements clarification, executes a critical self-review of its own plans, provides efficiency options with automation levels, enforces closed-loop validation with failure bounds, and defines a robust protocol for handling failures.",
6
6
  "preconditions": [
7
7
  "User has a clear task description (e.g., from Jira, a dev doc, or a BRD).",
8
8
  "The agent has access to necessary tools like `grep`, file readers/editors, and a terminal for commands.",
9
9
  "The agent has access to the relevant codebase files."
10
10
  ],
11
11
  "metaGuidance": [
12
- "This workflow follows the PREP -> IMPLEMENT -> VERIFY pattern for each step in the plan.",
12
+ "This workflow follows the ANALYZE -> CLARIFY -> PREP -> IMPLEMENT -> VERIFY pattern with dynamic re-triage capabilities.",
13
+ "Deep codebase analysis occurs early to inform intelligent requirements clarification and all subsequent planning phases.",
14
+ "Dynamic re-triage allows complexity upgrades based on new insights from analysis and clarifications.",
15
+ "Automation levels (Low/Medium/High) control confirmation requirements to balance autonomy with safety.",
16
+ "Failure bounds prevent resource waste: word limits (1500), step tracking (>20), and escalation protocols.",
13
17
  "Human approval is required after the Devil's Advocate review and before final completion.",
14
18
  "Each implementation step should be a small, logical, and committable chunk of work.",
15
19
  "The agent should never guess or assume. Always ask for clarification or use tools to find missing information.",
20
+ "If you fail to get test results or other tool outputs on the first attempt, ask the user to run it manually.",
16
21
  "Maintain existing coding conventions and architectural patterns found in the codebase."
17
22
  ],
18
23
  "steps": [
19
24
  {
20
25
  "id": "phase-0-intelligent-triage",
21
26
  "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.",
27
+ "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)\n6. Ask: \"What automation level would you prefer? High (auto-approve low-risk decisions), Medium (standard confirmations), or Low (extra confirmations for safety)?\" (sets automationLevel context variable)\n\n**VERIFY**: Confirm the complexity classification, optional analysis preferences, and automation level before proceeding.",
23
28
  "agentRole": "You are a technical assessment specialist with expertise in evaluating software development complexity. Your role is to accurately classify tasks based on technical risk, scope, and architectural impact. Be thorough in your analysis while remaining decisive and clear in your recommendations.",
24
29
  "guidance": [
25
30
  "Be thorough in your analysis - this determines the entire workflow path",
26
31
  "Consider both technical complexity and business risk",
27
32
  "When in doubt, err on the side of more thorough analysis (higher complexity)",
28
33
  "Always allow human override of your classification",
29
- "Set context variables that will be used for conditional step execution"
34
+ "Set context variables that will be used for conditional step execution and automation",
35
+ "Automation levels: High=auto-approve confidence >8, Medium=standard, Low=extra confirmations"
30
36
  ],
31
37
  "requireConfirmation": true
32
38
  },
33
- {
34
- "id": "phase-1-specification",
35
- "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
36
- "title": "Phase 1: Create Specification",
37
- "prompt": "Your first goal is to understand the task and create a specification document. Analyze the request, summarize your understanding, ask clarifying questions, and assess which parts of the codebase are relevant. The output of this step should be a formal specification.\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?'",
38
- "agentRole": "You are a senior business analyst and technical lead specializing in requirement gathering and scope definition. Your goal is to produce a clear, comprehensive `spec.md` file that will serve as the foundation for design and implementation.",
39
- "guidance": [
40
- "Provide a complete task description. Vague requests will lead to poor plans and wasted effort.",
41
- "The output of this step should be the content for `spec.md`.",
42
- "This step is automatically skipped for Small tasks based on the complexity classification"
43
- ],
44
- "requireConfirmation": false
45
- },
46
- {
47
- "id": "phase-1b-deep-analysis-mandatory",
48
- "runCondition": {"var": "taskComplexity", "equals": "Large"},
49
- "title": "Phase 1b: Mandatory Deep Codebase Analysis",
50
- "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.",
51
- "agentRole": "You are an expert codebase analyst with 10+ years of experience in software architecture and legacy system analysis. Your specialty is quickly understanding complex codebases and identifying architectural patterns, risks, and opportunities. Approach this with the thoroughness of a senior engineer conducting a technical due diligence review.",
52
- "askForFiles": true,
53
- "guidance": [
54
- "This step is mandatory for Large tasks due to their complexity and risk",
55
- "Ensure all relevant source files are attached or accessible to the agent before running this step",
56
- "Be thorough - this analysis will inform the entire implementation strategy"
57
- ],
58
- "requireConfirmation": false
59
- },
60
- {
61
- "id": "phase-1b-deep-analysis-optional",
62
- "runCondition": {
63
- "and": [
64
- {"var": "taskComplexity", "equals": "Medium"},
65
- {"var": "requestDeepAnalysis", "equals": true}
66
- ]
39
+ {
40
+ "id": "phase-1-deep-analysis-mandatory",
41
+ "runCondition": {"var": "taskComplexity", "equals": "Large"},
42
+ "title": "Phase 1: Mandatory Deep Codebase Analysis",
43
+ "prompt": "Your goal is to become an expert on the attached codebase before any planning begins. This deep analysis is mandatory for Large tasks due to their complexity and risk.\n\n**ANALYSIS BOUNDS: Limit output to 1500 words; prioritize task-relevant sections.**\n\nYour 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.\n7. **Task Relevance:** Identify which parts of the codebase are most relevant to the current task.\n8. **Potential Ambiguities:** Note areas where the initial task description might be unclear given the codebase structure.\n9. **Complexity Indicators:** Note any discoveries that might affect the initial complexity assessment.\n\nProvide summaries and code examples to illustrate your findings. Be exhaustive within the word limit, as if preparing onboarding documentation for a senior engineer. This analysis will inform all subsequent requirements clarification, specification, and design work.",
44
+ "agentRole": "You are an expert codebase analyst with 10+ years of experience in software architecture and legacy system analysis. Your specialty is quickly understanding complex codebases and identifying architectural patterns, risks, and opportunities. Approach this with the thoroughness of a senior engineer conducting a technical due diligence review.",
45
+ "askForFiles": true,
46
+ "guidance": [
47
+ "This step is mandatory for Large tasks due to their complexity and risk",
48
+ "Ensure all relevant source files are attached or accessible to the agent before running this step",
49
+ "Be thorough but respect the 1500-word limit - focus on task-relevant insights",
50
+ "This analysis will inform requirements clarification, specification, design, and implementation strategy",
51
+ "Pay special attention to areas of the codebase relevant to the current task",
52
+ "Note potential ambiguities in the task description that become apparent after understanding the codebase",
53
+ "Flag any complexity indicators that might warrant re-triaging the task complexity"
54
+ ],
55
+ "requireConfirmation": false
56
+ },
57
+ {
58
+ "id": "phase-1-deep-analysis-optional",
59
+ "runCondition": {
60
+ "and": [
61
+ {"var": "taskComplexity", "equals": "Medium"},
62
+ {"var": "requestDeepAnalysis", "equals": true}
63
+ ]
64
+ },
65
+ "title": "Phase 1: Optional Deep Codebase Analysis",
66
+ "prompt": "You requested optional deep analysis for this Medium task. Your goal is to become an expert on the attached codebase before planning begins.\n\n**ANALYSIS BOUNDS: Limit output to 1500 words; prioritize task-relevant sections.**\n\nYour 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.\n7. **Task Relevance:** Identify which parts of the codebase are most relevant to the current task.\n8. **Potential Ambiguities:** Note areas where the initial task description might be unclear given the codebase structure.\n9. **Complexity Indicators:** Note any discoveries that might affect the initial complexity assessment.\n\nProvide summaries and code examples to illustrate your findings. Focus on areas most relevant to the current task while maintaining architectural awareness. This analysis will inform all subsequent requirements clarification, specification, and design work.",
67
+ "agentRole": "You are a focused codebase analyst specializing in targeted technical analysis for medium-complexity projects. Your approach balances thoroughness with efficiency, focusing on areas most relevant to the current task while maintaining architectural awareness.",
68
+ "askForFiles": true,
69
+ "guidance": [
70
+ "This optional analysis was requested for a Medium task",
71
+ "Ensure all relevant source files are attached or accessible to the agent before running this step",
72
+ "Focus on areas most relevant to the current task while maintaining broader architectural context",
73
+ "Respect the 1500-word limit - prioritize task-relevant insights",
74
+ "This analysis will inform requirements clarification, specification, and design phases",
75
+ "Note potential ambiguities in the task description that become apparent after understanding the codebase",
76
+ "Flag any complexity indicators that might warrant re-triaging the task complexity"
77
+ ],
78
+ "requireConfirmation": false
79
+ },
80
+ {
81
+ "id": "phase-2-informed-clarification",
82
+ "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
83
+ "title": "Phase 2: Informed Requirements Clarification",
84
+ "prompt": "Based on your deep understanding of the codebase from Phase 1, you are now in a position to ask intelligent, targeted questions to clarify the requirements. Your codebase analysis may have revealed ambiguities, missing details, or potential issues that weren't apparent from the initial task description.\n\n**Your goal is to ask specific, informed questions that will lead to a clear, unambiguous specification. Consider:**\n\n1. **Technical Ambiguities:** Are there aspects of the task that could be implemented in multiple ways given the existing architecture? Which approach is preferred?\n\n2. **Integration Questions:** How should the new functionality integrate with existing systems, APIs, or workflows you discovered?\n\n3. **Scope Boundaries:** Given the existing codebase structure, what should be included/excluded from this task?\n\n4. **Convention Alignment:** Should the implementation follow existing patterns you observed, or is this an opportunity to establish new patterns?\n\n5. **Edge Cases:** What should happen in edge cases that are now apparent given the existing data models and business logic?\n\n6. **Dependencies:** Are there existing components, services, or data that the task should leverage or avoid?\n\n7. **Testing Strategy:** Given the existing test patterns, what level and type of testing is expected?\n\n8. **Complexity Concerns:** Based on your analysis, are there risk factors that might indicate this task is more complex than initially classified?\n\n**Present 3-7 well-formulated questions that will significantly improve the clarity and implementability of the final specification.**",
85
+ "agentRole": "You are a senior business analyst and technical consultant specializing in requirements elicitation. Your expertise lies in translating deep technical understanding into precise business questions that eliminate ambiguity and prevent costly rework. You excel at identifying the critical gaps between initial requirements and implementation reality.",
86
+ "guidance": [
87
+ "This step is automatically skipped for Small tasks based on complexity classification",
88
+ "Ask questions that could only be formulated after understanding the codebase",
89
+ "Focus on questions that will significantly impact the specification and implementation approach",
90
+ "Avoid generic questions - make them specific to the codebase and task at hand",
91
+ "Present questions in a clear, prioritized manner",
92
+ "Include questions about potential complexity changes based on your analysis"
93
+ ],
94
+ "requireConfirmation": {
95
+ "or": [
96
+ {"var": "automationLevel", "equals": "Low"},
97
+ {"var": "automationLevel", "equals": "Medium"}
98
+ ]
99
+ }
100
+ },
101
+ {
102
+ "id": "phase-2b-dynamic-retriage",
103
+ "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
104
+ "title": "Phase 2b: Dynamic Complexity Re-Triage",
105
+ "prompt": "Based on your codebase analysis and requirements clarification, re-evaluate the initial complexity classification. New insights may have revealed:\n\n- Hidden architectural dependencies\n- Unforeseen integration complexities\n- Risk factors not apparent in the initial description\n- Scope expansion based on clarified requirements\n- Technical constraints that increase difficulty\n\n**EVALUATE:**\n1. Review the original taskComplexity classification\n2. Consider new information from codebase analysis and clarifications\n3. Assess if the complexity should be upgraded (e.g., Medium → Large)\n4. Provide detailed reasoning for any recommended changes\n\n**If you recommend upgrading complexity:**\n- Clearly explain what new insights led to this recommendation\n- Describe the additional risks or complexity discovered\n- Justify why the higher complexity path would be beneficial\n- Ask for user confirmation to change the taskComplexity context variable\n\n**If current classification remains appropriate:**\n- Briefly confirm the classification is still accurate\n- Proceed without requesting changes\n\n**Note:** Complexity can only be upgraded (Small→Medium, Medium→Large), not downgraded, to maintain safety.",
106
+ "agentRole": "You are a senior technical risk assessor specializing in project complexity evaluation. Your expertise lies in identifying hidden risks and complexity factors that emerge during analysis phases. You excel at making decisive recommendations to ensure projects follow the appropriate rigor level.",
107
+ "guidance": [
108
+ "This step allows upgrading complexity based on new insights",
109
+ "Only upgrade complexity if there are clear, justifiable reasons",
110
+ "Complexity cannot be downgraded to maintain safety",
111
+ "Be specific about what new information led to the reassessment",
112
+ "If upgrading, the workflow will continue with the higher complexity path",
113
+ "For high automation levels, auto-approve upgrades if confidence is very high (>9)"
114
+ ],
115
+ "requireConfirmation": {
116
+ "or": [
117
+ {"var": "automationLevel", "equals": "Low"},
118
+ {"var": "automationLevel", "equals": "Medium"}
119
+ ]
120
+ }
121
+ },
122
+ {
123
+ "id": "phase-3-specification",
124
+ "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
125
+ "title": "Phase 3: Create Specification",
126
+ "prompt": "Using your codebase analysis from Phase 1, the clarified requirements from Phase 2, and any complexity re-assessment from Phase 2b, create a specification document that aligns with the existing system and addresses all identified ambiguities. Your specification should be precise, unambiguous, and fully implementable.\n\n**Task Description:**\n[Updated based on clarifications from Phase 2]\n\n**Key Objectives & Success Criteria:**\n[Refined based on codebase understanding and clarifications]\n\n**Scope and Constraints:**\n[Updated to reflect codebase realities and clarified boundaries]\n\n**IMPORTANT**: Your specification must consider:\n- Existing architectural patterns and conventions identified in your codebase analysis\n- How the proposed changes fit within the current system design\n- Potential impacts on existing components and workflows\n- Alignment with current testing strategies and code quality standards\n- All clarifications and decisions made in Phase 2\n- Any complexity insights from the re-triage assessment\n\nFinally, perform a sanity check on the current complexity classification. If you believe further adjustment is needed given your comprehensive understanding, state your reasoning and ask for confirmation before proceeding.",
127
+ "agentRole": "You are a senior business analyst and technical lead specializing in requirement gathering and scope definition. Your goal is to produce a clear, comprehensive `spec.md` file that leverages your deep understanding of the existing codebase and incorporates all clarified requirements to serve as an unambiguous foundation for design and implementation.",
128
+ "guidance": [
129
+ "Provide a complete task description based on all previous analysis and clarifications",
130
+ "The output of this step should be the content for `spec.md`",
131
+ "This step is automatically skipped for Small tasks based on the complexity classification",
132
+ "Leverage your codebase analysis and clarifications to ensure the specification is precise and implementable",
133
+ "Reference specific decisions made during the clarification phase",
134
+ "Consider any complexity changes from the re-triage phase"
135
+ ],
136
+ "requireConfirmation": false
137
+ },
138
+ {
139
+ "id": "phase-4-architectural-design",
140
+ "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
141
+ "title": "Phase 4: Architectural Design",
142
+ "prompt": "Using the `spec.md` from the previous step, your deep codebase analysis, and all clarified requirements, create a high-level architectural design that seamlessly integrates with the existing system. Your output should be a `design.md` document that includes:\n1. **High-Level Approach:** A summary of the proposed solution that builds on existing patterns.\n2. **Component Breakdown:** Identify new or modified components, classes, or modules, showing how they fit within the current architecture.\n3. **Data Models:** Describe any changes to data structures or database schemas, considering existing data patterns.\n4. **API Contracts:** Define any new or changed API endpoints, following existing API conventions and patterns.\n5. **Key Interactions:** A diagram or description of how the major components will interact, both new and existing.\n6. **Integration Points:** Clearly identify how new components will integrate with existing systems and workflows.\n7. **Clarification Decisions:** Reference how the clarified requirements from Phase 2 influenced design decisions.\n8. **Complexity Considerations:** Address any complexity factors identified during re-triage.",
143
+ "agentRole": "You are a software architect specializing in translating business requirements into robust and scalable technical designs that seamlessly integrate with existing systems. Your task is to create a clear and comprehensive `design.md` that leverages existing architectural patterns while introducing necessary changes and incorporating all clarified requirements.",
144
+ "guidance": [
145
+ "The `design.md` should be detailed enough for an engineer to write an implementation plan from it.",
146
+ "This step is automatically skipped for Small tasks.",
147
+ "Ensure the design builds upon and aligns with the existing codebase architecture identified in your analysis",
148
+ "Reference specific clarification decisions that influenced the design",
149
+ "Consider complexity factors identified during re-triage"
150
+ ],
151
+ "requireConfirmation": false
67
152
  },
68
- "title": "Phase 1b: Optional Deep Codebase Analysis",
69
- "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.",
70
- "agentRole": "You are a focused codebase analyst specializing in targeted technical analysis for medium-complexity projects. Your approach balances thoroughness with efficiency, focusing on areas most relevant to the current task while maintaining architectural awareness.",
71
- "askForFiles": true,
72
- "guidance": [
73
- "This optional analysis was requested for a Medium task",
74
- "Ensure all relevant source files are attached or accessible to the agent before running this step",
75
- "Focus on areas most relevant to the current task"
76
- ],
77
- "requireConfirmation": false
78
- },
79
- {
80
- "id": "phase-1c-architectural-design",
81
- "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
82
- "title": "Phase 1c: Architectural Design",
83
- "prompt": "Using the `spec.md` from the previous step and your codebase analysis, create a high-level architectural design. Your output should be a `design.md` document that includes:\n1. **High-Level Approach:** A summary of the proposed solution.\n2. **Component Breakdown:** Identify new or modified components, classes, or modules.\n3. **Data Models:** Describe any changes to data structures or database schemas.\n4. **API Contracts:** Define any new or changed API endpoints, including request/response formats.\n5. **Key Interactions:** A diagram or description of how the major components will interact.",
84
- "agentRole": "You are a software architect specializing in translating business requirements into robust and scalable technical designs. Your task is to create a clear and comprehensive `design.md` that guides the implementation.",
85
- "guidance": [
86
- "The `design.md` should be detailed enough for an engineer to write an implementation plan from it.",
87
- "This step is automatically skipped for Small tasks."
88
- ],
89
- "requireConfirmation": false
90
- },
91
- {
92
- "id": "phase-2-planning",
93
- "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
94
- "title": "Phase 2: Create Detailed Implementation Plan",
95
- "prompt": "Your goal is to produce a thorough and actionable `implementation_plan.md` based on the `spec.md` and `design.md`. 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 from the spec.\n2. **Impact Assessment:** Affected codebase parts, dependencies, and risks based on the design.\n3. **Implementation Strategy:** A list of discrete, actionable steps. Each step must detail the task, its rationale, inputs, and outputs.\n4. **Testing Strategy:** Describe how the changes will be tested (e.g., unit tests, integration tests, manual QA).\n5. **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.",
96
- "agentRole": "You are an experienced technical architect and project planner with expertise in breaking down complex development tasks into manageable, logical phases. Your strength is creating detailed, actionable plans that minimize risk while maximizing development efficiency and code quality.",
97
- "guidance": [
98
- "The agent will now proceed to critique its own plan in the next step. Withhold your final approval until after that critique.",
99
- "This step is automatically skipped for Small tasks based on the complexity classification"
100
- ],
101
- "requireConfirmation": false
102
- },
103
- {
104
- "id": "phase-2b-devil-advocate-review",
105
- "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
106
- "title": "Phase 2b: Devil's Advocate Plan Review",
107
- "prompt": "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.",
108
- "agentRole": "You are a skeptical but fair senior principal engineer with 15+ years of experience in critical system development. Your role is to identify potential failure points, hidden assumptions, and overlooked complexities in technical plans. You excel at constructive criticism that strengthens plans rather than destroys them. Approach this with the rigor of a senior engineer reviewing a mission-critical system design.",
109
- "guidance": [
110
- "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.",
111
- "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.",
112
- "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.",
113
- "This step is automatically skipped for Small tasks based on the complexity classification"
114
- ],
115
- "requireConfirmation": true
116
- },
117
- {
118
- "id": "phase-2c-finalize-plan",
119
- "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
120
- "title": "Phase 2c: Finalize Implementation Plan",
121
- "prompt": "Review the initial `implementation_plan.md` from Phase 2 and the Devil's Advocate critique from Phase 2b. Your task is to create a final, consolidated implementation plan that incorporates the valid feedback from the review.\n\nYour output must be the final `implementation_plan.md`.\n\nAdditionally, explicitly list any suggestions from the review that you believe are valuable but out-of-scope for the current task. These should be formatted as potential tickets for future work.",
122
- "agentRole": "You are a pragmatic technical project manager. Your goal is to synthesize feedback, make decisive trade-offs, and produce a final, actionable plan that is ready for execution.",
123
- "guidance": [
124
- "This is the final plan that will be executed. Ensure it is clear, actionable, and reflects the best path forward.",
125
- "The list of out-of-scope items helps capture valuable ideas without derailing the current task."
126
- ],
127
- "requireConfirmation": true
128
- },
129
- {
130
- "id": "phase-2d-plan-sanity-check",
131
- "runCondition": { "var": "taskComplexity", "not_equals": "Small" },
132
- "title": "Phase 2d: Plan Sanity Check",
133
- "prompt": "Before starting implementation, perform a sanity check on the final `implementation_plan.md`. Your goal is to use your tools to quickly verify the plan's core assumptions against the current codebase. This is not a deep analysis, but a quick check for obvious errors.\n\nFor the key files, functions, classes, or APIs mentioned in the plan, perform the following checks:\n1. **Existence Check:** Use tools like `grep` or `ls` to confirm that the files and primary functions/classes you plan to modify actually exist where you expect them to.\n2. **Signature/API Check (if applicable):** Briefly check the function signatures or API endpoints you intend to use. Do they match the plan's assumptions? For example, if the plan assumes a function takes two arguments, verify that.\n3. **Dependency Check:** If the plan relies on a specific library or module being available, quickly verify its presence (e.g., check `package.json`, `requirements.txt`, etc.).\n\n**Report your findings as a simple checklist:**\n- [✅ or ❌] File `src/example.js` exists.\n- [✅ or ❌] Function `calculateTotal()` found in `src/utils.js`.\n- [✅ or ❌] Dependency `moment` is listed in `package.json`.\n\nIf any check fails (❌), briefly explain the discrepancy and ask the user if the plan needs to be revised before proceeding.",
134
- "agentRole": "You are a pragmatic QA engineer double-checking a plan before the development team starts work. Your job is to be quick, efficient, and focused on verifying concrete facts using tools. You are not re-evaluating the plan's logic, only its tangible connection to the codebase.",
135
- "guidance": [
136
- "This is a quick verification step, not a full re-analysis. The goal is to catch glaring errors before implementation begins.",
137
- "Use your code-browsing tools (`grep`, `ls`) to validate the plan's assumptions.",
138
- "If a check fails, it's crucial to pause and get human confirmation before proceeding with a potentially flawed plan."
139
- ],
140
- "requireConfirmation": false
141
- },
142
- {
143
- "id": "phase-3-iterative-implementation",
144
- "title": "Phase 3: Iterative Implementation (PREP -> IMPLEMENT -> VERIFY)",
145
- "prompt": "The implementation phase has now begun. You will now execute the approved `implementation_plan.md` step-by-step. Announce which step you are starting.\n\nYou will execute each step using the PREP -> IMPLEMENT -> VERIFY cycle defined in the guidance below. This process will repeat until all steps in the plan are complete.",
146
- "agentRole": "You are a meticulous senior software engineer focused on high-quality implementation. Your approach emphasizes careful preparation, precise execution, and thorough verification. You excel at following plans while adapting to unexpected discoveries during implementation.",
147
- "guidance": [
148
- "**IMPORTANT**: Do not proceed to the next workflow phase (Final Review) until all steps in the `implementation_plan.md` are marked as complete and verified.",
149
- "**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.",
150
- "**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.",
151
- "**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.",
152
- "**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 (as per the testing strategy).\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')."
153
- ],
154
- "requireConfirmation": false
155
- },
156
- {
157
- "id": "phase-4-final-review",
158
- "title": "Phase 4: Final Review & Completion",
159
- "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'** from the `implementation_plan.md`.\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.",
160
- "agentRole": "You are a quality assurance specialist and technical lead responsible for final project validation. Your expertise lies in comprehensive system testing, requirement verification, and ensuring deliverables meet all specified criteria. Approach this with the thoroughness of a senior engineer conducting a final release review.",
161
- "guidance": [
162
- "This is the final quality check. Ensure the agent's summary and checklist validation align with your understanding of the completed work."
163
- ],
164
- "requireConfirmation": true
165
- }
153
+ {
154
+ "id": "phase-5-planning",
155
+ "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
156
+ "title": "Phase 5: Create Detailed Implementation Plan",
157
+ "prompt": "Your goal is to produce a thorough and actionable `implementation_plan.md` based on the `spec.md`, `design.md`, your deep codebase analysis, and all clarified requirements. 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 from the spec and clarifications.\n2. **Impact Assessment:** Affected codebase parts, dependencies, and risks based on the design, codebase analysis, and clarified requirements.\n3. **Implementation Strategy:** A list of discrete, actionable steps. Each step must detail the task, its rationale, inputs, and outputs.\n4. **Testing Strategy:** Describe how the changes will be tested, building on existing testing patterns identified in your codebase analysis.\n5. **Failure Handling:** Define what to do if tests fail, tools don't work, or unexpected issues arise.\n6. **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 that demonstrates deep understanding of the requirements, clarifications, and the existing codebase.",
158
+ "agentRole": "You are an experienced technical architect and project planner with expertise in breaking down complex development tasks into manageable, logical phases. Your strength is creating detailed, actionable plans that minimize risk while maximizing development efficiency and code quality, all while working within existing system constraints and incorporating all clarified requirements.",
159
+ "guidance": [
160
+ "The agent will now proceed to critique its own plan in the next step. Withhold your final approval until after that critique.",
161
+ "This step is automatically skipped for Small tasks based on the complexity classification",
162
+ "Leverage your codebase analysis and clarified requirements to ensure the plan works within existing architectural constraints",
163
+ "Reference how clarified requirements influenced the planning decisions",
164
+ "Include explicit failure handling protocols"
165
+ ],
166
+ "requireConfirmation": false
167
+ },
168
+ {
169
+ "id": "phase-5b-devil-advocate-review",
170
+ "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
171
+ "title": "Phase 5b: Devil's Advocate Plan Review",
172
+ "prompt": "Your task is to perform a 'devil's advocate' review of the implementation plan you just created in Phase 5. 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 analysis, clarified requirements, 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.",
173
+ "agentRole": "You are a skeptical but fair senior principal engineer with 15+ years of experience in critical system development. Your role is to identify potential failure points, hidden assumptions, and overlooked complexities in technical plans. You excel at constructive criticism that strengthens plans rather than destroys them. Approach this with the rigor of a senior engineer reviewing a mission-critical system design.",
174
+ "guidance": [
175
+ "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.",
176
+ "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.",
177
+ "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.",
178
+ "This step is automatically skipped for Small tasks based on the complexity classification",
179
+ "For high automation levels with confidence >8, auto-approve if no critical risks are identified"
180
+ ],
181
+ "requireConfirmation": {
182
+ "or": [
183
+ {"var": "automationLevel", "equals": "Low"},
184
+ {"and": [
185
+ {"var": "automationLevel", "equals": "Medium"}
186
+ ]},
187
+ {"and": [
188
+ {"var": "automationLevel", "equals": "High"},
189
+ {"var": "confidenceScore", "lt": 8}
190
+ ]}
191
+ ]
192
+ }
193
+ },
194
+ {
195
+ "id": "phase-5c-finalize-plan",
196
+ "runCondition": {"var": "taskComplexity", "not_equals": "Small"},
197
+ "title": "Phase 5c: Finalize Implementation Plan",
198
+ "prompt": "Review the initial `implementation_plan.md` from Phase 5 and the Devil's Advocate critique from Phase 5b. Your task is to create a final, consolidated implementation plan that incorporates the valid feedback from the review.\n\nYour output must be the final `implementation_plan.md`.\n\nAdditionally, explicitly list any suggestions from the review that you believe are valuable but out-of-scope for the current task. These should be formatted as potential tickets for future work.",
199
+ "agentRole": "You are a pragmatic technical project manager. Your goal is to synthesize feedback, make decisive trade-offs, and produce a final, actionable plan that is ready for execution.",
200
+ "guidance": [
201
+ "This is the final plan that will be executed. Ensure it is clear, actionable, and reflects the best path forward.",
202
+ "The list of out-of-scope items helps capture valuable ideas without derailing the current task."
203
+ ],
204
+ "requireConfirmation": {
205
+ "or": [
206
+ {"var": "automationLevel", "equals": "Low"},
207
+ {"var": "automationLevel", "equals": "Medium"}
208
+ ]
209
+ }
210
+ },
211
+ {
212
+ "id": "phase-5d-plan-sanity-check",
213
+ "runCondition": { "var": "taskComplexity", "not_equals": "Small" },
214
+ "title": "Phase 5d: Plan Sanity Check",
215
+ "prompt": "Before starting implementation, perform a sanity check on the final `implementation_plan.md`. Your goal is to use your tools to quickly verify the plan's core assumptions against the current codebase. This is not a deep analysis, but a quick check for obvious errors.\n\nFor the key files, functions, classes, or APIs mentioned in the plan, perform the following checks:\n1. **Existence Check:** Use tools like `grep` or `ls` to confirm that the files and primary functions/classes you plan to modify actually exist where you expect them to.\n2. **Signature/API Check (if applicable):** Briefly check the function signatures or API endpoints you intend to use. Do they match the plan's assumptions? For example, if the plan assumes a function takes two arguments, verify that.\n3. **Dependency Check:** If the plan relies on a specific library or module being available, quickly verify its presence (e.g., check `package.json`, `requirements.txt`, etc.).\n\n**Report your findings as a simple checklist:**\n- [✅ or ❌] File `src/example.js` exists.\n- [✅ or ❌] Function `calculateTotal()` found in `src/utils.js`.\n- [✅ or ❌] Dependency `moment` is listed in `package.json`.\n\nIf any check fails (❌), briefly explain the discrepancy and ask the user if the plan needs to be revised before proceeding.",
216
+ "agentRole": "You are a pragmatic QA engineer double-checking a plan before the development team starts work. Your job is to be quick, efficient, and focused on verifying concrete facts using tools. You are not re-evaluating the plan's logic, only its tangible connection to the codebase.",
217
+ "guidance": [
218
+ "This is a quick verification step, not a full re-analysis. The goal is to catch glaring errors before implementation begins.",
219
+ "Use your code-browsing tools (`grep`, `ls`) to validate the plan's assumptions.",
220
+ "If a check fails, it's crucial to pause and get human confirmation before proceeding with a potentially flawed plan."
221
+ ],
222
+ "requireConfirmation": false
223
+ },
224
+ {
225
+ "id": "phase-6-iterative-implementation",
226
+ "title": "Phase 6: Iterative Implementation (PREP -> IMPLEMENT -> VERIFY)",
227
+ "prompt": "The implementation phase has now begun. You will now execute the approved `implementation_plan.md` step-by-step. Announce which step you are starting.\n\n**STEP TRACKING:** Track total steps executed. If >20 steps without completion, pause and summarize progress for user intervention.\n\nYou will execute each step using the PREP -> IMPLEMENT -> VERIFY cycle defined in the guidance below. This process will repeat until all steps in the plan are complete.",
228
+ "agentRole": "You are a meticulous senior software engineer focused on high-quality implementation. Your approach emphasizes careful preparation, precise execution, and thorough verification. You excel at following plans while adapting to unexpected discoveries during implementation.",
229
+ "guidance": [
230
+ "**IMPORTANT**: Do not proceed to the next workflow phase (Final Review) until all steps in the `implementation_plan.md` are marked as complete and verified.",
231
+ "**STEP BOUNDS**: Track total steps executed. If >20 steps without completion, pause and ask user for guidance.",
232
+ "**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.",
233
+ "**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.",
234
+ "**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.",
235
+ "**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 (as per the testing strategy).\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**ENHANCED FAILURE PROTOCOL:** If a verification failure cannot be resolved after two attempts:\n1. **Do not try a third time**\n2. **If test failures occur:** Ask the user to run tests manually and provide output\n3. **If tool failures occur:** Ask the user to execute the failing command and share results\n4. **For critical failures:** Consider escalating by reverting changes using git reset\n5. **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 known issue')"
236
+ ],
237
+ "requireConfirmation": false
238
+ },
239
+ {
240
+ "id": "phase-7-final-review",
241
+ "title": "Phase 7: Final Review & Completion",
242
+ "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'** from the `implementation_plan.md`.\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.",
243
+ "agentRole": "You are a quality assurance specialist and technical lead responsible for final project validation. Your expertise lies in comprehensive system testing, requirement verification, and ensuring deliverables meet all specified criteria. Approach this with the thoroughness of a senior engineer conducting a final release review.",
244
+ "guidance": [
245
+ "This is the final quality check. Ensure the agent's summary and checklist validation align with your understanding of the completed work."
246
+ ],
247
+ "requireConfirmation": true
248
+ }
166
249
  ]
167
250
  }