You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

step-05-generate-output.md 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. ---
  2. name: 'step-05-generate-output'
  3. description: 'Generate output documents with adaptive orchestration (agent-team, subagent, or sequential)'
  4. outputFile: '{test_artifacts}/test-design-epic-{epic_num}.md'
  5. progressFile: '{test_artifacts}/test-design-progress.md'
  6. ---
  7. # Step 5: Generate Outputs & Validate
  8. ## STEP GOAL
  9. Write the final test-design document(s) using the correct template(s), then validate against the checklist.
  10. ## MANDATORY EXECUTION RULES
  11. - 📖 Read the entire step file before acting
  12. - ✅ Speak in `{communication_language}`
  13. - ✅ Use the provided templates and output paths
  14. - ✅ Resolve execution mode from explicit user request first, then config
  15. - ✅ Apply fallback rules deterministically when requested mode is unsupported
  16. ---
  17. ## EXECUTION PROTOCOLS:
  18. - 🎯 Follow the MANDATORY SEQUENCE exactly
  19. - 💾 Record outputs before proceeding
  20. - 📖 Load the next step only when instructed
  21. ## CONTEXT BOUNDARIES:
  22. - Available context: config, loaded artifacts, and knowledge fragments
  23. - Focus: this step's goal only
  24. - Limits: do not execute future steps
  25. - Dependencies: prior steps' outputs (if any)
  26. ## MANDATORY SEQUENCE
  27. **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
  28. ## 0. Resolve Execution Mode (User Override First)
  29. ```javascript
  30. const orchestrationContext = {
  31. config: {
  32. execution_mode: config.tea_execution_mode || 'auto', // "auto" | "subagent" | "agent-team" | "sequential"
  33. capability_probe: config.tea_capability_probe !== false, // true by default
  34. },
  35. timestamp: new Date().toISOString().replace(/[:.]/g, '-'),
  36. };
  37. const normalizeUserExecutionMode = (mode) => {
  38. if (typeof mode !== 'string') return null;
  39. const normalized = mode.trim().toLowerCase().replace(/[-_]/g, ' ').replace(/\s+/g, ' ');
  40. if (normalized === 'auto') return 'auto';
  41. if (normalized === 'sequential') return 'sequential';
  42. if (normalized === 'subagent' || normalized === 'sub agent' || normalized === 'subagents' || normalized === 'sub agents') {
  43. return 'subagent';
  44. }
  45. if (normalized === 'agent team' || normalized === 'agent teams' || normalized === 'agentteam') {
  46. return 'agent-team';
  47. }
  48. return null;
  49. };
  50. const normalizeConfigExecutionMode = (mode) => {
  51. if (mode === 'subagent') return 'subagent';
  52. if (mode === 'auto' || mode === 'sequential' || mode === 'subagent' || mode === 'agent-team') {
  53. return mode;
  54. }
  55. return null;
  56. };
  57. // Explicit user instruction in the active run takes priority over config.
  58. const explicitModeFromUser = normalizeUserExecutionMode(runtime.getExplicitExecutionModeHint?.() || null);
  59. const requestedMode = explicitModeFromUser || normalizeConfigExecutionMode(orchestrationContext.config.execution_mode) || 'auto';
  60. const probeEnabled = orchestrationContext.config.capability_probe;
  61. const supports = { subagent: false, agentTeam: false };
  62. if (probeEnabled) {
  63. supports.subagent = runtime.canLaunchSubagents?.() === true;
  64. supports.agentTeam = runtime.canLaunchAgentTeams?.() === true;
  65. }
  66. let resolvedMode = requestedMode;
  67. if (requestedMode === 'auto') {
  68. if (supports.agentTeam) resolvedMode = 'agent-team';
  69. else if (supports.subagent) resolvedMode = 'subagent';
  70. else resolvedMode = 'sequential';
  71. } else if (probeEnabled && requestedMode === 'agent-team' && !supports.agentTeam) {
  72. resolvedMode = supports.subagent ? 'subagent' : 'sequential';
  73. } else if (probeEnabled && requestedMode === 'subagent' && !supports.subagent) {
  74. resolvedMode = 'sequential';
  75. }
  76. ```
  77. Resolution precedence:
  78. 1. Explicit user request in this run (`agent team` => `agent-team`; `subagent` => `subagent`; `sequential`; `auto`)
  79. 2. `tea_execution_mode` from config
  80. 3. Runtime capability fallback (when probing enabled)
  81. ## 1. Select Output Template(s)
  82. ### System-Level Mode (Phase 3)
  83. Generate **two** documents:
  84. - `{test_artifacts}/test-design-architecture.md` using `test-design-architecture-template.md`
  85. - `{test_artifacts}/test-design-qa.md` using `test-design-qa-template.md`
  86. If `resolvedMode` is `agent-team` or `subagent`, these two documents can be generated in parallel as independent workers, then reconciled for consistency.
  87. ### Epic-Level Mode (Phase 4)
  88. Generate **one** document:
  89. - `{outputFile}` using `test-design-template.md`
  90. - If `epic_num` is unclear, ask the user
  91. Epic-level mode remains single-worker by default (one output artifact).
  92. ---
  93. ## 2. Populate Templates
  94. Ensure the outputs include:
  95. - Risk assessment matrix
  96. - NFR planning summary (thresholds, missing thresholds, planned evidence, and NFR-derived risks) — when NFRs are in scope
  97. - Coverage matrix and priorities
  98. - NFR coverage and planned evidence mapping — when NFRs are in scope
  99. - Execution strategy
  100. - Resource estimates (ranges)
  101. - Quality gate criteria
  102. - Any mode-specific sections required by the template
  103. ---
  104. ## 3. Validation
  105. Validate the output(s) against:
  106. - `checklist.md` in this workflow folder
  107. - [ ] CLI sessions cleaned up (no orphaned browsers)
  108. - [ ] Temp artifacts stored in `{test_artifacts}/` not random locations
  109. If any checklist criteria are missing, fix before completion.
  110. ---
  111. ## 4. Generate BMAD Handoff Document (System-Level Mode Only)
  112. **If this is a system-level test design** (not component/feature level):
  113. 1. Copy `test-design-handoff-template.md` to `{test_artifacts}/test-design/{project_name}-handoff.md`
  114. 2. Populate all sections from the test design output:
  115. - Fill TEA Artifacts Inventory with actual paths
  116. - Extract P0/P1 risks into Epic-Level guidance
  117. - Map critical test scenarios to Story-Level guidance
  118. - Build risk-to-story mapping table from risk register
  119. 3. Save alongside the test design document
  120. > **Note**: The handoff document is designed for consumption by BMAD's `create-epics-and-stories` workflow. It is only generated for system-level test designs where epic/story decomposition is relevant.
  121. ---
  122. ## 5. Polish Output
  123. Before finalizing, review the complete output document for quality:
  124. 1. **Remove duplication**: Progressive-append workflow may have created repeated sections — consolidate
  125. 2. **Verify consistency**: Ensure terminology, risk scores, and references are consistent throughout
  126. 3. **Check completeness**: All template sections should be populated or explicitly marked N/A
  127. 4. **Format cleanup**: Ensure markdown formatting is clean (tables aligned, headers consistent, no orphaned references)
  128. ---
  129. ## 6. Completion Report
  130. Summarize:
  131. - Mode used
  132. - Output file paths
  133. - Key risks and gate thresholds
  134. - Any open assumptions
  135. ---
  136. ### 7. Save Progress
  137. **Save this step's accumulated work to `{progressFile}`.**
  138. - **If `{progressFile}` does not exist** (first save), create it with YAML frontmatter:
  139. ```yaml
  140. ---
  141. workflowStatus: 'completed'
  142. totalSteps: 5
  143. stepsCompleted: ['step-05-generate-output']
  144. lastStep: 'step-05-generate-output'
  145. nextStep: ''
  146. lastSaved: '{date}'
  147. ---
  148. ```
  149. Then write this step's output below the frontmatter.
  150. - **If `{progressFile}` already exists**, update:
  151. - Set `workflowStatus: 'completed'`
  152. - Set `totalSteps: 5`
  153. - Add `'step-05-generate-output'` to `stepsCompleted` array (only if not already present)
  154. - Set `lastStep: 'step-05-generate-output'`
  155. - Set `nextStep: ''`
  156. - Set `lastSaved: '{date}'`
  157. - Append this step's output to the appropriate section of the document.
  158. ## 🚨 SYSTEM SUCCESS/FAILURE METRICS:
  159. ### ✅ SUCCESS:
  160. - Step completed in full with required outputs
  161. ### ❌ SYSTEM FAILURE:
  162. - Skipped sequence steps or missing outputs
  163. **Master Rule:** Skipping steps is FORBIDDEN.
  164. ## On Complete
  165. Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete`
  166. If the resolver succeeds and returns a non-empty `workflow.on_complete`, execute that value as the final terminal instruction before exiting.
  167. If the resolver fails, returns no output, or resolves an empty value, skip the hook and exit normally.