workflow.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <task id="_bmad/core/tasks/workflow.xml" name="Execute Workflow">
  2. <objective>Execute given workflow by loading its configuration, following instructions, and producing output</objective>
  3. <llm critical="true">
  4. <mandate>Always read COMPLETE files - NEVER use offset/limit when reading any workflow related files</mandate>
  5. <mandate>Instructions are MANDATORY - either as file path, steps or embedded list in YAML, XML or markdown</mandate>
  6. <mandate>Execute ALL steps in instructions IN EXACT ORDER</mandate>
  7. <mandate>Save to template output file after EVERY "template-output" tag</mandate>
  8. <mandate>NEVER skip a step - YOU are responsible for every steps execution without fail or excuse</mandate>
  9. </llm>
  10. <WORKFLOW-RULES critical="true">
  11. <rule n="1">Steps execute in exact numerical order (1, 2, 3...)</rule>
  12. <rule n="2">Optional steps: Ask user unless #yolo mode active</rule>
  13. <rule n="3">Template-output tags: Save content, discuss with the user the section completed, and NEVER proceed until the users indicates
  14. to proceed (unless YOLO mode has been activated)</rule>
  15. </WORKFLOW-RULES>
  16. <flow>
  17. <step n="1" title="Load and Initialize Workflow">
  18. <substep n="1a" title="Load Configuration and Resolve Variables">
  19. <action>Read workflow.yaml from provided path</action>
  20. <mandate>Load config_source (REQUIRED for all modules)</mandate>
  21. <phase n="1">Load external config from config_source path</phase>
  22. <phase n="2">Resolve all {config_source}: references with values from config</phase>
  23. <phase n="3">Resolve system variables (date:system-generated) and paths ({project-root}, {installed_path})</phase>
  24. <phase n="4">Ask user for input of any variables that are still unknown</phase>
  25. </substep>
  26. <substep n="1b" title="Load Required Components">
  27. <mandate>Instructions: Read COMPLETE file from path OR embedded list (REQUIRED)</mandate>
  28. <check>If template path → Read COMPLETE template file</check>
  29. <check>If validation path → Note path for later loading when needed</check>
  30. <check>If template: false → Mark as action-workflow (else template-workflow)</check>
  31. <note>Data files (csv, json) → Store paths only, load on-demand when instructions reference them</note>
  32. </substep>
  33. <substep n="1c" title="Initialize Output" if="template-workflow">
  34. <action>Resolve default_output_file path with all variables and {{date}}</action>
  35. <action>Create output directory if doesn't exist</action>
  36. <action>If template-workflow → Write template to output file with placeholders</action>
  37. <action>If action-workflow → Skip file creation</action>
  38. </substep>
  39. </step>
  40. <step n="2" title="Process Each Instruction Step in Order">
  41. <iterate>For each step in instructions:</iterate>
  42. <substep n="2a" title="Handle Step Attributes">
  43. <check>If optional="true" and NOT #yolo → Ask user to include</check>
  44. <check>If if="condition" → Evaluate condition</check>
  45. <check>If for-each="item" → Repeat step for each item</check>
  46. <check>If repeat="n" → Repeat step n times</check>
  47. </substep>
  48. <substep n="2b" title="Execute Step Content">
  49. <action>Process step instructions (markdown or XML tags)</action>
  50. <action>Replace {{variables}} with values (ask user if unknown)</action>
  51. <execute-tags>
  52. <tag>action xml tag → Perform the action</tag>
  53. <tag>check if="condition" xml tag → Conditional block wrapping actions (requires closing &lt;/check&gt;)</tag>
  54. <tag>ask xml tag → Prompt user and WAIT for response</tag>
  55. <tag>invoke-workflow xml tag → Execute another workflow with given inputs and the workflow.xml runner</tag>
  56. <tag>invoke-task xml tag → Execute specified task</tag>
  57. <tag>invoke-protocol name="protocol_name" xml tag → Execute reusable protocol from protocols section</tag>
  58. <tag>goto step="x" → Jump to specified step</tag>
  59. </execute-tags>
  60. </substep>
  61. <substep n="2c" title="Handle template-output Tags">
  62. <if tag="template-output">
  63. <mandate>Generate content for this section</mandate>
  64. <mandate>Save to file (Write first time, Edit subsequent)</mandate>
  65. <action>Display generated content</action>
  66. <ask> [a] Advanced Elicitation, [c] Continue, [p] Party-Mode, [y] YOLO the rest of this document only. WAIT for response. <if
  67. response="a">
  68. <action>Start the advanced elicitation workflow {project-root}/_bmad/core/workflows/advanced-elicitation/workflow.xml</action>
  69. </if>
  70. <if
  71. response="c">
  72. <action>Continue to next step</action>
  73. </if>
  74. <if response="p">
  75. <action>Start the party-mode workflow {project-root}/_bmad/core/workflows/party-mode/workflow.yaml</action>
  76. </if>
  77. <if
  78. response="y">
  79. <action>Enter #yolo mode for the rest of the workflow</action>
  80. </if>
  81. </ask>
  82. </if>
  83. </substep>
  84. <substep n="2d" title="Step Completion">
  85. <check>If no special tags and NOT #yolo:</check>
  86. <ask>Continue to next step? (y/n/edit)</ask>
  87. </substep>
  88. </step>
  89. <step n="3" title="Completion">
  90. <check>Confirm document saved to output path</check>
  91. <action>Report workflow completion</action>
  92. </step>
  93. </flow>
  94. <execution-modes>
  95. <mode name="normal">Full user interaction and confirmation of EVERY step at EVERY template output - NO EXCEPTIONS except yolo MODE</mode>
  96. <mode name="yolo">Skip all confirmations and elicitation, minimize prompts and try to produce all of the workflow automatically by
  97. simulating the remaining discussions with an simulated expert user</mode>
  98. </execution-modes>
  99. <supported-tags desc="Instructions can use these tags">
  100. <structural>
  101. <tag>step n="X" goal="..." - Define step with number and goal</tag>
  102. <tag>optional="true" - Step can be skipped</tag>
  103. <tag>if="condition" - Conditional execution</tag>
  104. <tag>for-each="collection" - Iterate over items</tag>
  105. <tag>repeat="n" - Repeat n times</tag>
  106. </structural>
  107. <execution>
  108. <tag>action - Required action to perform</tag>
  109. <tag>action if="condition" - Single conditional action (inline, no closing tag needed)</tag>
  110. <tag>check if="condition"&gt;...&lt;/check&gt; - Conditional block wrapping multiple items (closing tag required)</tag>
  111. <tag>ask - Get user input (ALWAYS wait for response before continuing)</tag>
  112. <tag>goto - Jump to another step</tag>
  113. <tag>invoke-workflow - Call another workflow</tag>
  114. <tag>invoke-task - Call a task</tag>
  115. <tag>invoke-protocol - Execute a reusable protocol (e.g., discover_inputs)</tag>
  116. </execution>
  117. <output>
  118. <tag>template-output - Save content checkpoint</tag>
  119. <tag>critical - Cannot be skipped</tag>
  120. <tag>example - Show example output</tag>
  121. </output>
  122. </supported-tags>
  123. <protocols desc="Reusable workflow protocols that can be invoked via invoke-protocol tag">
  124. <protocol name="discover_inputs" desc="Smart file discovery and loading based on input_file_patterns">
  125. <objective>Intelligently load project files (whole or sharded) based on workflow's input_file_patterns configuration</objective>
  126. <critical>Only execute if workflow.yaml contains input_file_patterns section</critical>
  127. <flow>
  128. <step n="1" title="Parse Input File Patterns">
  129. <action>Read input_file_patterns from loaded workflow.yaml</action>
  130. <action>For each pattern group (prd, architecture, epics, etc.), note the load_strategy if present</action>
  131. </step>
  132. <step n="2" title="Load Files Using Smart Strategies">
  133. <iterate>For each pattern in input_file_patterns:</iterate>
  134. <substep n="2a" title="Try Sharded Documents First">
  135. <check if="sharded pattern exists">
  136. <action>Determine load_strategy from pattern config (defaults to FULL_LOAD if not specified)</action>
  137. <strategy name="FULL_LOAD">
  138. <desc>Load ALL files in sharded directory - used for PRD, Architecture, UX, brownfield docs</desc>
  139. <action>Use glob pattern to find ALL .md files (e.g., "{output_folder}/*architecture*/*.md")</action>
  140. <action>Load EVERY matching file completely</action>
  141. <action>Concatenate content in logical order (index.md first if exists, then alphabetical)</action>
  142. <action>Store in variable: {pattern_name_content}</action>
  143. </strategy>
  144. <strategy name="SELECTIVE_LOAD">
  145. <desc>Load specific shard using template variable - example: used for epics with {{epic_num}}</desc>
  146. <action>Check for template variables in sharded_single pattern (e.g., {{epic_num}})</action>
  147. <action>If variable undefined, ask user for value OR infer from context</action>
  148. <action>Resolve template to specific file path</action>
  149. <action>Load that specific file</action>
  150. <action>Store in variable: {pattern_name_content}</action>
  151. </strategy>
  152. <strategy name="INDEX_GUIDED">
  153. <desc>Load index.md, analyze structure and description of each doc in the index, then intelligently load relevant docs</desc>
  154. <mandate>DO NOT BE LAZY - use best judgment to load documents that might have relevant information, even if only a 5% chance</mandate>
  155. <action>Load index.md from sharded directory</action>
  156. <action>Parse table of contents, links, section headers</action>
  157. <action>Analyze workflow's purpose and objective</action>
  158. <action>Identify which linked/referenced documents are likely relevant</action>
  159. <example>If workflow is about authentication and index shows "Auth Overview", "Payment Setup", "Deployment" → Load auth
  160. docs, consider deployment docs, skip payment</example>
  161. <action>Load all identified relevant documents</action>
  162. <action>Store combined content in variable: {pattern_name_content}</action>
  163. <note>When in doubt, LOAD IT - context is valuable, being thorough is better than missing critical info</note>
  164. </strategy>
  165. <action>Mark pattern as RESOLVED, skip to next pattern</action>
  166. </check>
  167. </substep>
  168. <substep n="2b" title="Try Whole Document if No Sharded Found">
  169. <check if="no sharded matches found OR no sharded pattern exists">
  170. <action>Attempt glob match on 'whole' pattern (e.g., "{output_folder}/*prd*.md")</action>
  171. <check if="matches found">
  172. <action>Load ALL matching files completely (no offset/limit)</action>
  173. <action>Store content in variable: {pattern_name_content} (e.g., {prd_content})</action>
  174. <action>Mark pattern as RESOLVED, skip to next pattern</action>
  175. </check>
  176. </check>
  177. </substep>
  178. <substep n="2c" title="Handle Not Found">
  179. <check if="no matches for sharded OR whole">
  180. <action>Set {pattern_name_content} to empty string</action>
  181. <action>Note in session: "No {pattern_name} files found" (not an error, just unavailable, offer use change to provide)</action>
  182. </check>
  183. </substep>
  184. </step>
  185. <step n="3" title="Report Discovery Results">
  186. <action>List all loaded content variables with file counts</action>
  187. <example>
  188. ✓ Loaded {prd_content} from 5 sharded files: prd/index.md, prd/requirements.md, ...
  189. ✓ Loaded {architecture_content} from 1 file: Architecture.md
  190. ✓ Loaded {epics_content} from selective load: epics/epic-3.md
  191. ○ No ux_design files found
  192. </example>
  193. <note>This gives workflow transparency into what context is available</note>
  194. </step>
  195. </flow>
  196. </protocol>
  197. </protocols>
  198. <llm final="true">
  199. <critical-rules>
  200. • This is the complete workflow execution engine
  201. • You MUST Follow instructions exactly as written
  202. • The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml
  203. • You MUST have already loaded and processed: {installed_path}/workflow.yaml
  204. • This workflow uses INTENT-DRIVEN PLANNING - adapt organically to product type and context
  205. • YOU ARE FACILITATING A CONVERSATION With a user to produce a final document step by step. The whole process is meant to be
  206. collaborative helping the user flesh out their ideas. Do not rush or optimize and skip any section.
  207. </critical-rules>
  208. </llm>
  209. </task>