diff --git a/src/bmm/workflows/4-implementation/batch-super-dev/instructions.md b/src/bmm/workflows/4-implementation/batch-super-dev/instructions.md deleted file mode 100644 index c7fd4498..00000000 --- a/src/bmm/workflows/4-implementation/batch-super-dev/instructions.md +++ /dev/null @@ -1,1270 +0,0 @@ -# Batch Super-Dev - Interactive Story Selector -## AKA: "Mend the Gap" πŸš‡ - -**Primary Use Case:** Gap analysis and reconciliation workflow - -This workflow helps you "mind the gap" between story requirements and codebase reality, then "mend the gap" by building only what's truly missing. - -### What This Workflow Does - -1. **Scans codebase** to verify what's actually implemented vs what stories claim -2. **Finds the gap** between story requirements and reality -3. **Mends the gap** by building ONLY what's truly missing (no duplicate work) -4. **Updates tracking** to reflect actual completion status (check boxes, sprint-status) - -### Common Use Cases - -**Reconciliation Mode (Most Common):** -- Work was done but not properly tracked -- Stories say "build X" but X is 60-80% already done -- Need second set of eyes to find real gaps -- Update story checkboxes to match reality - -**Greenfield Mode:** -- Story says "build X", nothing exists -- Build 100% from scratch with full quality gates - -**Brownfield Mode:** -- Story says "modify X", X exists -- Refactor carefully, add only new requirements - -### Execution Modes - -**Sequential (Recommended for Gap Analysis):** -- Process stories ONE-BY-ONE in THIS SESSION -- After each story: verify existing code β†’ build only gaps β†’ check boxes β†’ move to next -- Easier to monitor, can intervene if issues found -- Best for reconciliation work - -**Parallel (For Greenfield Batch Implementation):** -- Spawn autonomous Task agents to process stories concurrently -- Faster completion but harder to monitor -- Best when stories are independent and greenfield - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/batch-super-dev/workflow.yaml - -βš•οΈ HOSPITAL-GRADE CODE STANDARDS βš•οΈ -This code may be used in healthcare settings where LIVES ARE AT STAKE. -Every line of code must meet hospital-grade reliability standards. -QUALITY >> SPEED. Take 5 hours to do it right, not 1 hour to do it poorly. - - - - - Read {sprint_status} file - Parse metadata: project, project_key, tracking_system - Parse development_status map - - Filter stories with status = "ready-for-dev" OR "backlog" - Exclude entries that are epics (keys starting with "epic-") or retrospectives (keys ending with "-retrospective") - Group by status: ready_for_dev_stories, backlog_stories - - - Further filter stories to only include those starting with "{filter_by_epic}-" - If filter_by_epic = "3", only include stories like "3-1-...", "3-2-...", etc. - - - Sort filtered stories by epic number, then story number (e.g., 1-1, 1-2, 2-1, 3-1) - Store as: ready_for_dev_stories (list of story keys) - - - βœ… No available stories found (ready-for-dev or backlog). - -All stories are either in-progress, review, or done! - -Run `/bmad_bmm_sprint-status` to see current status. - Exit workflow - - - Combine both lists: available_stories = ready_for_dev_stories + backlog_stories - - - - Read comment field for each story from sprint-status.yaml (text after # on the same line) - - For each story, verify story file exists using COMPREHENSIVE naming pattern detection: - - - Parse story_key (e.g., "20-9-megamenu-navigation" or "20-9") to extract: - - epic_num: first number (e.g., "20") - - story_num: second number (e.g., "9") - - optional_suffix: everything after second number (e.g., "-megamenu-navigation" or empty) - Input: "20-9-megamenu-navigation" β†’ epic=20, story=9, suffix="-megamenu-navigation" - Input: "20-11" β†’ epic=20, story=11, suffix="" - - - - Use Glob tool to search for files matching these patterns (in priority order): - - story-{epic_num}.{story_num}.md - story-20.9.md (DOT notation, no suffix) - - story-{epic_num}.{story_num}*.md - story-20.9-megamenu-navigation.md (DOT notation WITH suffix - use Glob wildcard) - - {epic_num}-{story_num}.md - 20-9.md (HYPHEN notation, no "story-" prefix) - - {epic_num}-{story_num}*.md - 20-9-megamenu-navigation.md (HYPHEN notation WITH suffix) - - story-{story_key}.md - story-20-9-megamenu-navigation.md (literal story_key with "story-" prefix) - - {story_key}.md - 20-9-megamenu-navigation.md (literal story_key) - - Stop at first match and store file_path - If NO match found after all 6 patterns β†’ file_status = ❌ MISSING - If match found β†’ file_status = βœ… EXISTS - - - Mark stories as: βœ… (file exists), ❌ (file missing), πŸ”„ (already implemented but not marked done) - - -## πŸ“¦ Available Stories ({{count}}) - -{{#if filter_by_epic}} -**Filtered by Epic {{filter_by_epic}}** -{{/if}} - -{{#if ready_for_dev_stories.length > 0}} -### Ready for Dev ({{ready_for_dev_stories.length}}) -{{#each ready_for_dev_stories}} -{{@index}}. **{{key}}** {{file_status_icon}} {{sprint_status}} - {{#if comment}}β†’ {{comment}}{{/if}} - {{#if file_path}} File: {{file_path}}{{/if}} -{{/each}} -{{/if}} - -{{#if backlog_stories.length > 0}} -### Backlog ({{backlog_stories.length}}) -{{#each backlog_stories}} -{{@index}}. **{{key}}** {{file_status_icon}} [BACKLOG] - {{#if comment}}β†’ {{comment}}{{/if}} - {{#if file_path}} File: {{file_path}}{{else}} Needs story creation{{/if}} -{{/each}} -{{/if}} - ---- -**Legend:** -- βœ… Story file exists, ready to implement -- πŸ”„ Already implemented, just needs status update -- ❌ Story file missing, needs creation first -- [BACKLOG] Story needs gap analysis before implementation - -**Total:** {{count}} stories available -**Max batch size:** {{max_stories}} stories - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” VALIDATING STORY FILES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each story in available_stories (ready_for_dev + backlog): - - - Check if story file exists (already done in Step 2) - - - - πŸ“ Story {{story_key}}: BACKLOG - will create basic story file - Mark story as needs_story_creation = true - Mark story.creation_workflow = "/create-story" (lightweight, no gap analysis) - Mark story as validated (will create in next step) - - - - ❌ Story {{story_key}}: File MISSING but status is ready-for-dev - Mark story for removal from selection - Add to skipped_stories list with reason: "Story file missing (status ready-for-dev but no file)" - - - - - Read story file: {{file_path}} - Parse sections and validate BMAD format - - Check for all 12 required sections: - 1. Business Context - 2. Current State - 3. Acceptance Criteria - 4. Tasks and Subtasks - 5. Technical Requirements - 6. Architecture Compliance - 7. Testing Requirements - 8. Dev Agent Guardrails - 9. Definition of Done - 10. References - 11. Dev Agent Record - 12. Change Log - - - Count sections present: sections_found - Check Current State content length (word count) - Check Acceptance Criteria item count: ac_count - Count unchecked tasks ([ ]) in Tasks/Subtasks: task_count - Look for gap analysis markers (βœ…/❌) in Current State - - - -❌ Story {{story_key}}: INVALID - Insufficient tasks ({{task_count}}/3 minimum) - -This story has TOO FEW TASKS to be a valid story (found {{task_count}}, need β‰₯3). - -Analysis: -- 0 tasks: Story is a stub or empty -- 1-2 tasks: Too small to represent meaningful feature work -- β‰₯3 tasks: Minimum valid (MICRO threshold) - -Possible causes: -- Story file is incomplete/stub -- Tasks section is empty or malformed -- Story needs proper task breakdown -- Story is too small and should be combined with another - -Required action: -- Run /validate-create-story to regenerate with proper task breakdown -- Or manually add tasks to reach minimum of 3 tasks -- Or combine this story with a related story - -This story will be SKIPPED. - - Mark story for removal from selection - Add to skipped_stories list with reason: "INVALID - Only {{task_count}} tasks (need β‰₯3)" - - - - - -⚠️ Story {{story_key}}: File incomplete or invalid - - Sections: {{sections_found}}/12 - {{#if Current State < 100 words}}- Current State: stub ({{word_count}} words, expected β‰₯100){{/if}} - {{#if no gap analysis}}- Gap analysis: missing{{/if}} - {{#if ac_count < 3}}- Acceptance Criteria: {{ac_count}} items (expected β‰₯3){{/if}} - {{#if task_count < 3}}- Tasks: {{task_count}} items (expected β‰₯3){{/if}} - - - Regenerate story with codebase scan? (yes/no): - - - -⚠️ STORY REGENERATION REQUIRES MANUAL WORKFLOW EXECUTION - -**Story:** {{story_key}} -**Status:** File incomplete or invalid ({{sections_found}}/12 sections) - -**Problem:** -Agents cannot invoke /create-story-with-gap-analysis workflow autonomously. -Story regeneration requires: -- Interactive user prompts -- Context-heavy codebase scanning -- Gap analysis decision-making - -**Required Action:** - -1. **Exit this batch execution:** - - This story will be skipped - - Batch will continue with valid stories only - -2. **Backup existing file (optional):** - ``` - cp {{file_path}} {{file_path}}.backup - ``` - -3. **Regenerate story manually:** - ``` - /create-story-with-gap-analysis - ``` - When prompted, provide: - - Story key: {{story_key}} - -4. **Validate story format:** - ``` - ./scripts/validate-all-stories.sh - ``` - -5. **Re-run batch-super-dev:** - - Story will now be properly formatted - -**Skipping story {{story_key}} from current batch execution.** - - - Mark story for removal from selection - Add to skipped_stories list with reason: "Story regeneration requires manual workflow (agents cannot invoke /create-story)" - Add to manual_actions_required list: "Regenerate {{story_key}} with /create-story-with-gap-analysis" - - - - ⏭️ Skipping story {{story_key}} (file incomplete) - Mark story for removal from selection - Add to skipped_stories list with reason: "User declined regeneration" - - - - - βœ… Story {{story_key}}: Valid (12/12 sections, gap analysis present) - Mark story as validated - - - - - βœ… Story {{story_key}}: Already implemented (will skip or reconcile only) - Mark story as validated (already done) - - - - Remove skipped stories from ready_for_dev_stories - Update count of available stories - - - -⏭️ Skipped Stories ({{skipped_count}}): -{{#each skipped_stories}} - - {{story_key}}: {{reason}} -{{/each}} - - - - - -❌ No valid stories remaining after validation. - -All stories were either: -- Missing files (user declined creation) -- Invalid/incomplete (user declined regeneration) -- Already implemented - -Run `/bmad:bmm:workflows:sprint-status` to see status. - - Exit workflow - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Story Validation Complete -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Validated:** {{validated_count}} stories ready to process -{{#if skipped_count > 0}}**Skipped:** {{skipped_count}} stories{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š SCORING STORY COMPLEXITY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each validated story: - - - Read story file: {{file_path}} - - Count unchecked tasks ([ ]) at top level only in Tasks/Subtasks section β†’ task_count - (See workflow.yaml complexity.task_counting.method = "top_level_only") - - - - -⚠️ Story {{story_key}}: Cannot score complexity - INSUFFICIENT TASKS ({{task_count}}/3 minimum) - -This story was not caught in Step 2.5 validation but has too few tasks. -It should have been rejected during validation. - -Skipping complexity scoring for this story - marking as INVALID. - - Set {{story_key}}.complexity = {level: "INVALID", score: 0, task_count: {{task_count}}, reason: "Insufficient tasks ({{task_count}}/3 minimum)"} - Continue to next story - - - Extract file paths mentioned in tasks β†’ file_count - Scan story title and task descriptions for risk keywords using rules from workflow.yaml: - - Case insensitive matching (require_word_boundaries: true) - - Include keyword variants (e.g., "authentication" matches "auth") - - Scan: story_title, task_descriptions, subtask_descriptions - - - Calculate complexity score: - - Base score = task_count - - Add 5 for each HIGH risk keyword match (auth, security, payment, migration, database, schema, encryption) - - Add 2 for each MEDIUM risk keyword match (api, integration, external, third-party, cache) - - Add 0 for LOW risk keywords (ui, style, config, docs, test) - - Count each keyword only once (no duplicates) - - - Assign complexity level using mutually exclusive decision tree (priority order): - - 1. Check COMPLEX first (highest priority): - IF (task_count β‰₯ 16 OR complexity_score β‰₯ 20 OR has ANY HIGH risk keyword) - THEN level = COMPLEX - - 2. Else check MICRO (lowest complexity): - ELSE IF (task_count ≀ 3 AND complexity_score ≀ 5 AND file_count ≀ 5) - THEN level = MICRO - - 3. Else default to STANDARD: - ELSE level = STANDARD - - This ensures no overlaps: - - Story with HIGH keyword β†’ COMPLEX (never MICRO or STANDARD) - - Story with 4-15 tasks or >5 files β†’ STANDARD (not MICRO or COMPLEX) - - Story with ≀3 tasks, ≀5 files, no HIGH keywords β†’ MICRO - - - Store complexity_level for story: {{story_key}}.complexity = {level, score, task_count, risk_keywords} - - - Group stories by complexity level - - Filter out INVALID stories (those with level="INVALID"): - For each INVALID story, add to skipped_stories with reason from complexity object - Remove INVALID stories from complexity_groups and ready_for_dev_stories - - - -❌ **Invalid Stories Skipped ({{invalid_count}}):** -{{#each invalid_stories}} - - {{story_key}}: {{reason}} -{{/each}} - -These stories need to be regenerated with /create-story or /validate-create-story before processing. - - - - -πŸ“Š **Complexity Analysis Complete** - -{{#each complexity_groups}} -**{{level}} Stories ({{count}}):** -{{#each stories}} - - {{story_key}}: {{task_count}} tasks, score {{score}}{{#if risk_keywords}}, risk: {{risk_keywords}}{{/if}} -{{/each}} -{{/each}} - ---- -**Pipeline Routing:** -- πŸš€ **MICRO** ({{micro_count}}): Lightweight path - skip gap analysis + code review -- βš™οΈ **STANDARD** ({{standard_count}}): Full pipeline with all quality gates -- πŸ”’ **COMPLEX** ({{complex_count}}): Enhanced validation + consider splitting - -{{#if complex_count > 0}} -⚠️ **Warning:** {{complex_count}} complex stories detected. Consider: -- Breaking into smaller stories before processing -- Running these separately with extra attention -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - -❌ No valid stories remaining after complexity analysis. - -All stories were either: -- Missing story files (Step 2.5) -- Invalid/incomplete (Step 2.5) -- Zero tasks (Step 2.6) - -Run /create-story or /validate-create-story to create proper story files, then rerun /batch-super-dev. - - Exit workflow - - - - - -**Select stories to process:** - -Enter story numbers to process (examples): - - Single: `1` - - Multiple: `1,3,5` - - Range: `1-5` (processes 1,2,3,4,5) - - Mixed: `1,3-5,8` (processes 1,3,4,5,8) - - All: `all` (processes all {{count}} stories) - -Or: - - `cancel` - Exit without processing - -**Your selection:** - - - Parse user input - - - ❌ Batch processing cancelled. - Exit workflow - - - - Set selected_stories = all ready_for_dev_stories - - - - Parse selection (handle commas, ranges) - Input "1,3-5,8" β†’ indexes [1,3,4,5,8] β†’ map to story keys - Map selected indexes to story keys from ready_for_dev_stories - Store as: selected_stories - - - - ⚠️ You selected {{count}} stories, but max_stories is {{max_stories}}. - -Only the first {{max_stories}} will be processed. - Truncate selected_stories to first max_stories entries - - - Display confirmation - -## πŸ“‹ Selected Stories ({{count}}) - -{{#each selected_stories}} -{{@index}}. {{key}} {{#if is_backlog}}[BACKLOG - needs story creation]{{/if}} -{{/each}} - -**Estimated time:** {{count}} stories Γ— 30-60 min/story = {{estimated_hours}} hours - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” IMPLEMENTATION READINESS CHECK -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Validating selected stories for quality and completeness... - - - For each selected story: - - - Read story file: {{story_file_path}} - - - - ⚠️ {{story_key}}: No story file (BACKLOG) - will create during execution - Mark story as needs_creation - Continue to next story - - - - ❌ {{story_key}}: Story file MISSING but status is ready-for-dev (inconsistent state) - Add to validation_failures list - Continue to next story - - - - - Validate story completeness: - - Count sections (need 12) - - Check Current State word count (need β‰₯100) - - Check gap analysis markers (βœ…/❌) - - Count Acceptance Criteria (need β‰₯3) - - Count unchecked tasks (need β‰₯3) - - - - ❌ {{story_key}}: INSUFFICIENT TASKS ({{task_count}}/3 minimum) - Add to validation_failures: "{{story_key}}: Only {{task_count}} tasks" - - - - ⚠️ {{story_key}}: Story incomplete ({{sections_found}}/12 sections{{#if !gap_analysis}}, no gap analysis{{/if}}) - Add to validation_warnings: "{{story_key}}: Needs regeneration" - - - - βœ… {{story_key}}: Valid and ready - Add to validated_stories list - - - - - - -❌ **Validation Failures ({{validation_failures.length}}):** - -{{#each validation_failures}} - - {{this}} -{{/each}} - -These stories CANNOT be processed. Options: -1. Remove them from selection -2. Fix them manually -3. Cancel batch execution - - - Remove failed stories and continue? (yes/no): - - - Remove validation_failures from selected_stories - βœ… Removed {{validation_failures.length}} invalid stories. Continuing with {{selected_stories.length}} valid stories. - - - - ❌ Batch processing cancelled. Please fix story validation issues first. - Exit workflow - - - - - -⚠️ **Validation Warnings ({{validation_warnings.length}}):** - -{{#each validation_warnings}} - - {{this}} -{{/each}} - -These stories have quality issues but can still be processed. -Recommend regenerating with /create-story-with-gap-analysis for better quality. - - - Continue with these stories anyway? (yes/no): - - - ❌ Batch processing cancelled. - Exit workflow - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Implementation Readiness: PASS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Validated:** {{validated_stories.length}} stories -**Needs Creation:** {{needs_creation.length}} stories (BACKLOG) -**Quality:** All stories meet minimum standards -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - βœ… All stories have files - skipping story creation - Jump to Step 3 - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“ BATCH STORY CREATION -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -{{needs_creation.length}} stories need creation (BACKLOG status): -{{#each needs_creation}} - - {{story_key}} -{{/each}} - -These will be created using /create-story (lightweight, no gap analysis). -Gap analysis will happen just-in-time during implementation (Step 2 of super-dev-pipeline). - - - Create these {{needs_creation.length}} story files now? (yes/no): - - - ⏭️ Skipping story creation. These stories will be removed from batch. - Remove needs_creation stories from selected_stories - - - ❌ No stories remaining after removing backlog stories. Exiting. - Exit workflow - - - - For each story in needs_creation: - - - πŸ“ Creating story {{@index}}/{{needs_creation.length}}: {{story_key}}... - - Invoke workflow: /bmad_bmm_create-story - Parameters: - - story_key: {{story_key}} - - epic_num: {{epic_num}} - - mode: batch (auto-approve, minimal prompts) - - - - βœ… Story created: {{story_key}} - Mark story.needs_story_creation = false - - - - ❌ Failed to create story: {{story_key}} - Add to failed_creations list - Remove from selected_stories - - - - - -⚠️ {{failed_creations.length}} stories failed creation: -{{#each failed_creations}} - - {{this}} -{{/each}} - -These will be skipped in batch execution. - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Story Creation Complete -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Created:** {{needs_creation.length - failed_creations.length}} stories -**Failed:** {{failed_creations.length}} stories -**Ready for implementation:** {{selected_stories.length}} stories - -Note: Gap analysis will happen just-in-time during implementation. -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -╔═══════════════════════════════════════════════════════════════════╗ -β•‘ BATCH SUPER-DEV: Execution Mode Selection β•‘ -β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• - -βš•οΈ HOSPITAL-GRADE CODE STANDARDS ACTIVE βš•οΈ -Lives are at stake. All code must meet safety-critical reliability standards. - - - -**Choose execution mode:** - -[I] INTERACTIVE CHECKPOINT MODE - - After each story completes, pause for your review - - You approve before proceeding to next story - - Allows course correction if issues detected - - Best for: When you want to monitor progress - -[A] FULLY AUTONOMOUS MODE - - Process all selected stories without pausing - - No human interaction until completion - - Best for: When stories are well-defined and you trust the process - -Which mode? [I/A]: - - - Read user input - - - Set execution_mode = "interactive_checkpoint" - -βœ… Interactive Checkpoint Mode Selected - -After each story implementation: -- Full quality report displayed -- You approve before next story begins -- Allows real-time oversight and intervention - - - - - Set execution_mode = "fully_autonomous" - -βš•οΈ Fully Autonomous Mode Selected - HOSPITAL-GRADE STANDARDS ENFORCED - -Quality enhancements for autonomous mode: -βœ… Double validation at each step -βœ… Comprehensive error checking -βœ… Detailed audit trail generation -βœ… Zero-tolerance for shortcuts -βœ… Hospital-grade code verification - -Processing will continue until ALL selected stories complete. -NO human interaction required until completion. - -QUALITY OVER SPEED: Taking time to ensure correctness. - - Activate hospital_grade_mode = true - Set quality_multiplier = 1.5 - - - -**How should these stories be processed?** - -Options: -- **sequential**: Run stories one-by-one in this session (slower, easier to monitor) -- **parallel**: Spawn Task agents to process stories concurrently (faster, autonomous) - -Enter: sequential or parallel - - - Capture response as: execution_mode - - - Set parallel_count = 1 - Set use_task_agents = false - βœ… Sequential mode selected - stories will be processed one-by-one in this session - - - - Set use_task_agents = true - - -**How many agents should run in parallel?** - -Options: -- **2**: Conservative (low resource usage, easier debugging) -- **4**: Moderate (balanced performance, recommended) -- **8**: Aggressive (higher throughput) -- **10**: Maximum (10 agent limit for safety) -- **all**: Use all stories (max 10 agents) - -Enter number (2-10) or 'all': - - - Capture response as: parallel_count - If parallel_count == 'all': set parallel_count = min(count of selected_stories, 10) - If parallel_count > 10: set parallel_count = 10 (safety limit) - - - ⚠️ Requested {{original_count}} agents, capped at 10 (safety limit) - - - - -## βš™οΈ Execution Plan - -**Mode:** {{execution_mode}} -{{#if use_task_agents}} -**Task Agents:** {{parallel_count}} running concurrently -**Agent Type:** general-purpose (autonomous) -{{else}} -**Sequential processing** in current session -{{/if}} - -**Stories to process:** {{count}} -**Estimated total time:** -{{#if use_task_agents}} -- With {{parallel_count}} agents: {{estimated_hours / parallel_count}} hours -{{else}} -- Sequential: {{estimated_hours}} hours -{{/if}} - - - Confirm execution plan? (yes/no): - - - ❌ Batch processing cancelled. - Exit workflow - - - - - Initialize counters: completed=0, failed=0, failed_stories=[], reconciliation_warnings=[], reconciliation_warnings_count=0 - Set start_time = current timestamp - - - Jump to Step 4-Parallel (Task Agent execution) - - - - Continue to Step 4-Sequential (In-session execution) - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸš€ SEQUENTIAL BATCH PROCESSING STARTED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories:** {{count}} -**Mode:** super-dev-pipeline (batch, sequential) -**Continue on failure:** {{continue_on_failure}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each story in selected_stories: - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“¦ Story {{current_index}}/{{total_count}}: {{story_key}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Invoke workflow: /bmad:bmm:workflows:super-dev-pipeline - Parameters: mode=batch, story_key={{story_key}}, complexity_level={{story_key}}.complexity.level - - - βœ… Implementation complete: {{story_key}} - - ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. - Do NOT delegate this to an agent. YOU do it. - - - 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit - 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed - 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks - 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work - 5. Use Edit: Fill Dev Agent Record with files/date/summary - 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) - 7. Use Edit: Update sprint-status.yaml to "done" or "review" - - - - βœ… COMPLETED: {{story_key}} (reconciled) - Increment completed counter - - - PAUSE FOR USER REVIEW - -╔═══════════════════════════════════════════════════════════════════╗ -β•‘ INTERACTIVE CHECKPOINT: Story {{story_key}} Complete β•‘ -β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• - -βœ… Story {{story_key}} successfully implemented and reconciled - -Quality Summary: -- All tests passing -- Type checks passing -- Linter passing -- Code review completed -- Sprint status updated - -Remaining stories: {{remaining}} - -Options: -[C] Continue to next story -[R] Review implementation details -[P] Pause batch (exit workflow) - -Your choice [C/R/P]: - - - Read user input - - - βœ… Continuing to next story... - - - - πŸ“‹ Implementation Details for {{story_key}} - Display story file, test results, review findings - -Press [C] to continue or [P] to pause: - - Read user input - - βœ… Continuing to next story... - - - ⏸️ Batch paused. Run batch-super-dev again to continue with remaining stories. - Jump to Step 5 (Summary) - - - - - ⏸️ Batch paused. Run batch-super-dev again to continue with remaining stories. - Jump to Step 5 (Summary) - - - - - βœ… {{story_key}} complete. Automatically continuing to next story (autonomous mode)... - - - - - ⚠️ WARNING: {{story_key}} completed but reconciliation failed - Increment completed counter (implementation was successful) - Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} - Increment reconciliation_warnings_count - - - - - ❌ FAILED: {{story_key}} - Increment failed counter - Add story_key to failed_stories list - - - ⚠️ Stopping batch due to failure (continue_on_failure=false) - Jump to Step 5 (Summary) - - - - - -**Progress:** {{completed}} completed, {{failed}} failed, {{remaining}} remaining - - - - - ⏸️ Pausing {{pause_between_stories}} seconds before next story... - Wait {{pause_between_stories}} seconds - - - - After all stories processed, jump to Step 5 (Summary) - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸš€ PARALLEL PROCESSING STARTED (Semaphore Pattern) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories:** {{count}} -**Mode:** Task agents (autonomous, continuous) -**Max concurrent agents:** {{parallel_count}} -**Continue on failure:** {{continue_on_failure}} -**Pattern:** Worker pool with {{parallel_count}} slots -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -πŸ“Š **Semaphore Pattern Benefits:** -- No idle time between batches -- Constant {{parallel_count}} agents running -- As soon as slot frees β†’ next story starts immediately -- Faster completion (no batch synchronization delays) - - - Initialize worker pool state: - - - story_queue = selected_stories (all stories to process) - - active_workers = {} (map of worker_id β†’ {story_key, task_id, started_at}) - - completed_stories = [] - - failed_stories = [] - - next_story_index = 0 - - max_workers = {{parallel_count}} - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ”§ Initializing {{max_workers}} worker slots... -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Spawn first {{max_workers}} agents (or fewer if less stories): - - While next_story_index < min(max_workers, story_queue.length): - - - story_key = story_queue[next_story_index] - worker_id = next_story_index + 1 - - Spawn Task agent: - - subagent_type: "general-purpose" - - description: "Implement story {{story_key}}" - - prompt: "Execute super-dev-pipeline workflow for story {{story_key}}. - - CRITICAL INSTRUCTIONS: - 1. Load workflow.xml: _bmad/core/tasks/workflow.xml - 2. Load workflow config: _bmad/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml - 3. Execute in BATCH mode with story_key={{story_key}} and complexity_level={{story_key}}.complexity.level - 4. Follow all 7 pipeline steps (init, pre-gap, implement, post-validate, code-review, complete, summary) - 5. Commit changes when complete - 6. Report final status (done/failed) with file list - - Story file will be auto-resolved from multiple naming conventions." - - run_in_background: true (non-blocking - critical for semaphore pattern) - - Store in active_workers[worker_id]: - story_key: {{story_key}} - task_id: {{returned_task_id}} - started_at: {{timestamp}} - status: "running" - - - Increment next_story_index - - πŸš€ Worker {{worker_id}} started: {{story_key}} - - After spawning initial workers: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… {{active_workers.size}} workers active -πŸ“‹ {{story_queue.length - next_story_index}} stories queued -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - SEMAPHORE PATTERN: Keep {{max_workers}} agents running continuously - - While active_workers.size > 0 OR next_story_index < story_queue.length: - - Poll for completed workers (check task outputs non-blocking): - - For each worker_id in active_workers: - - Check if worker task completed using TaskOutput(task_id, block=false) - - - Continue to next worker (don't wait) - - - - Get worker details: story_key = active_workers[worker_id].story_key - - βœ… Worker {{worker_id}} completed: {{story_key}} - - ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. - - - 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit - 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed - 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks - 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work - 5. Use Edit: Fill Dev Agent Record with files/date/summary - 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) - 7. Use Edit: Update sprint-status.yaml to "done" or "review" - - - - βœ… COMPLETED: {{story_key}} (reconciled) - Add to completed_stories - - - - ⚠️ WARNING: {{story_key}} completed but reconciliation failed - Add to completed_stories (implementation successful) - Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} - - - Remove worker_id from active_workers (free the slot) - - IMMEDIATELY refill slot if stories remain: - - story_key = story_queue[next_story_index] - - πŸ”„ Worker {{worker_id}} refilled: {{story_key}} - - Spawn new Task agent for this worker_id (same parameters as init) - Update active_workers[worker_id] with new task_id and story_key - Increment next_story_index - - - - - Get worker details: story_key = active_workers[worker_id].story_key - - ❌ Worker {{worker_id}} failed: {{story_key}} - - Add to failed_stories - Remove worker_id from active_workers (free the slot) - - - ⚠️ Stopping all workers due to failure (continue_on_failure=false) - Kill all active workers - Clear story_queue - Break worker pool loop - - - - story_key = story_queue[next_story_index] - - πŸ”„ Worker {{worker_id}} refilled: {{story_key}} (despite previous failure) - - Spawn new Task agent for this worker_id - Update active_workers[worker_id] with new task_id and story_key - Increment next_story_index - - - - Display live progress every 30 seconds: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š Live Progress ({{timestamp}}) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Completed: {{completed_stories.length}} -❌ Failed: {{failed_stories.length}} -πŸ”„ Active workers: {{active_workers.size}} -πŸ“‹ Queued: {{story_queue.length - next_story_index}} - -Active stories: -{{#each active_workers}} - Worker {{@key}}: {{story_key}} (running {{duration}}) -{{/each}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Sleep 5 seconds before next poll (prevents tight loop) - - - - After worker pool drains (all stories processed), jump to Step 5 (Summary) - - - - Calculate end_time and total_duration - Calculate success_rate = (completed / total_count) * 100 - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š BATCH SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total stories:** {{total_count}} -**βœ… Completed:** {{completed}} -**❌ Failed:** {{failed}} -**⚠️ Reconciliation warnings:** {{reconciliation_warnings_count}} -**Success rate:** {{success_rate}}% -**Duration:** {{total_duration}} - -{{#if failed > 0}} -**Failed stories:** -{{#each failed_stories}} - - {{this}} -{{/each}} - -**Retry failed stories:** -```bash -{{#each failed_stories}} -/bmad:bmm:workflows:super-dev-pipeline mode=batch story_key={{this}} -{{/each}} -``` -{{/if}} - -{{#if reconciliation_warnings_count > 0}} -**⚠️ Reconciliation warnings (stories completed but status may be inaccurate):** -{{#each reconciliation_warnings}} - - {{story_key}}: {{warning_message}} -{{/each}} - -**Manual reconciliation needed:** -Review these stories to ensure checkboxes and status are accurate. -Check Dev Agent Record vs Acceptance Criteria/Tasks/DoD sections. -{{/if}} - -{{#if manual_actions_required.length > 0}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -⚠️ MANUAL ACTIONS REQUIRED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -**{{manual_actions_required.length}} stories require manual intervention:** - -{{#each manual_actions_required}} -{{@index}}. **{{story_key}}** - Action: Regenerate story with proper BMAD format - Command: `/create-story-with-gap-analysis` -{{/each}} - -**After completing these actions:** -1. Validate all stories: `./scripts/validate-all-stories.sh` -2. Re-run batch-super-dev for these stories -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -{{/if}} - -**Next steps:** -1. Check sprint-status.yaml - stories should be marked "done" or "review" -2. Run tests: `pnpm test` -3. Check coverage: `pnpm test --coverage` -4. Review commits: `git log -{{completed}}` -5. Spot-check 2-3 stories for quality - -**Run another batch?** -`/bmad:bmm:workflows:batch-super-dev` -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Save batch log to {batch_log} - Log contents: start_time, end_time, total_duration, selected_stories, completed_stories, failed_stories, success_rate - - - diff --git a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/README.md b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/README.md deleted file mode 100644 index 08f41fa6..00000000 --- a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/README.md +++ /dev/null @@ -1,170 +0,0 @@ -# Create Story With Gap Analysis - -**Custom Workflow by Jonah Schulte** -**Created:** December 24, 2025 -**Purpose:** Generate stories with SYSTEMATIC codebase gap analysis (not inference-based) - ---- - -## Problem This Solves - -**Standard `/create-story` workflow:** -- ❌ Reads previous stories and git commits (passive) -- ❌ Infers what probably exists (guessing) -- ❌ Gap analysis quality varies by agent thoroughness -- ❌ Checkboxes may not reflect reality - -**This custom workflow:** -- βœ… Actively scans codebase with Glob/Read tools -- βœ… Verifies file existence (not inference) -- βœ… Reads key files to check implementation depth (mocked vs real) -- βœ… Generates TRUTHFUL gap analysis -- βœ… Checkboxes are FACTS verified by file system - ---- - -## Usage - -```bash -/create-story-with-gap-analysis - -# Or via Skill tool: -Skill: "create-story-with-gap-analysis" -Args: "1.9" (epic.story number) -``` - -**Workflow will:** -1. Load existing story + epic context -2. **SCAN codebase systematically** (Glob for files, Read to verify implementation) -3. Generate gap analysis with verified βœ…/❌/⚠️ status -4. Update story file with truthful checkboxes -5. Save to _bmad-output/implementation-artifacts/ - ---- - -## What It Scans - -**For each story, the workflow:** - -1. **Identifies target directories** (from story title/requirements) - - Example: "admin-user-service" β†’ apps/backend/admin-user-service/ - -2. **Globs for all files** - - `{target}/src/**/*.ts` - Find all TypeScript files - - `{target}/src/**/*.spec.ts` - Find all tests - -3. **Checks specific required files** - - Based on ACs, check if files exist - - Example: `src/auth/controllers/bridgeid-auth.controller.ts` β†’ ❌ MISSING - -4. **Reads key files to verify depth** - - Check if mocked: Search for "MOCK" string - - Check if incomplete: Search for "TODO" - - Verify real implementation exists - -5. **Checks package.json** - - Verify required dependencies are installed - - Identify missing packages - -6. **Counts tests** - - How many test files exist - - Coverage for each component - ---- - -## Output Format - -**Generates story with:** - -1. βœ… Standard BMAD 5 sections (Story, AC, Tasks, Dev Notes, Dev Agent Record) -2. βœ… Enhanced Dev Notes with verified gap analysis subsections: - - Gap Analysis: Current State vs Requirements - - Library/Framework Requirements (from package.json) - - File Structure Requirements (from Glob results) - - Testing Requirements (from test file count) - - Architecture Compliance - - Previous Story Intelligence - -3. βœ… Truthful checkboxes based on verified file existence - ---- - -## Difference from Standard /create-story - -| Feature | /create-story | /create-story-with-gap-analysis | -|---------|---------------|--------------------------------| -| Reads previous story | βœ… | βœ… | -| Reads git commits | βœ… | βœ… | -| Loads epic context | βœ… | βœ… | -| **Scans codebase with Glob** | ❌ | βœ… SYSTEMATIC | -| **Verifies files exist** | ❌ | βœ… VERIFIED | -| **Reads files to check depth** | ❌ | βœ… MOCKED vs REAL | -| **Checks package.json** | ❌ | βœ… DEPENDENCIES | -| **Counts test coverage** | ❌ | βœ… COVERAGE | -| Gap analysis quality | Variable (agent-dependent) | Systematic (tool-verified) | -| Checkbox accuracy | Inference-based | File-existence-based | - ---- - -## When to Use - -**This workflow (planning-time gap analysis):** -- Use when regenerating/auditing stories -- Use when you want verified checkboxes upfront -- Best for stories that will be implemented immediately -- Manual verification at planning time - -**Standard /create-story + /dev-story (dev-time gap analysis):** -- Recommended for most workflows -- Stories start as DRAFT, validated when dev begins -- Prevents staleness in batch planning -- Automatic verification at development time - -**Use standard /create-story when:** -- Greenfield project (nothing exists yet) -- Backlog stories (won't be implemented for months) -- Epic planning phase (just sketching ideas) - -**Tip:** Both approaches are complementary. You can use this workflow to regenerate stories, then use `/dev-story` which will re-validate at dev-time. - ---- - -## Examples - -**Regenerating Story 1.9:** -```bash -/create-story-with-gap-analysis - -Choice: 1.9 - -# Workflow will: -# 1. Load existing 1-9-admin-user-service-bridgeid-rbac.md -# 2. Identify target: apps/backend/admin-user-service/ -# 3. Glob: apps/backend/admin-user-service/src/**/*.ts (finds 47 files) -# 4. Check: src/auth/controllers/bridgeid-auth.controller.ts β†’ ❌ MISSING -# 5. Read: src/bridgeid/services/bridgeid-client.service.ts β†’ ⚠️ MOCKED -# 6. Read: package.json β†’ axios ❌ NOT INSTALLED -# 7. Generate gap analysis with verified status -# 8. Write story with truthful checkboxes -``` - -**Result:** Story with verified gap analysis showing: -- βœ… 7 components IMPLEMENTED (verified file existence) -- ❌ 6 components MISSING (verified file not found) -- ⚠️ 1 component PARTIAL (file exists but contains "MOCK") - ---- - -## Installation - -This workflow is auto-discovered when BMAD is installed. - -**To use:** -```bash -/bmad:bmm:workflows:create-story-with-gap-analysis -``` - ---- - -**Last Updated:** December 27, 2025 -**Status:** Integrated into BMAD-METHOD diff --git a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-01-initialize.md b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-01-initialize.md deleted file mode 100644 index 6212924b..00000000 --- a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-01-initialize.md +++ /dev/null @@ -1,83 +0,0 @@ -# Step 1: Initialize and Extract Story Requirements - -## Goal -Load epic context and identify what needs to be scanned in the codebase. - -## Execution - -### 1. Determine Story to Create - -**Ask user:** -``` -Which story should I regenerate with gap analysis? - -Options: -1. Provide story number (e.g., "1.9" or "1-9") -2. Provide story filename (e.g., "story-1.9.md" or legacy "1-9-admin-user-service-bridgeid-rbac.md") - -Your choice: -``` - -**Parse input:** -- Extract epic_num (e.g., "1") -- Extract story_num (e.g., "9") -- Locate story file: `{story_dir}/story-{epic_num}.{story_num}.md` (fallback: `{story_dir}/{epic_num}-{story_num}-*.md`) - -### 2. Load Existing Story Content - -```bash -Read: {story_dir}/story-{epic_num}.{story_num}.md -# If not found, fallback: -Read: {story_dir}/{epic_num}-{story_num}-*.md -``` - -**Extract from existing story:** -- Story title -- User story text (As a... I want... So that...) -- Acceptance criteria (the requirements, not checkboxes) -- Any existing Dev Notes or technical context - -**Store for later use.** - -### 3. Load Epic Context - -```bash -Read: {planning_artifacts}/epics.md -``` - -**Extract from epic:** -- Epic business objectives -- This story's original requirements -- Technical constraints -- Dependencies on other stories - -### 4. Determine Target Directories - -**From story title and requirements, identify:** -- Which service/app this story targets -- Which directories to scan - -**Examples:** -- "admin-user-service" β†’ `apps/backend/admin-user-service/` -- "Widget Batch 1" β†’ `packages/widgets/` -- "POE Integration" β†’ `apps/frontend/web/` - -**Store target directories for Step 2 codebase scan.** - -### 5. Ready for Codebase Scan - -**Output:** -``` -βœ… Story Context Loaded - -Story: {epic_num}.{story_num} - {title} -Target directories identified: - - {directory_1} - - {directory_2} - -Ready to scan codebase for gap analysis. - -[C] Continue to Codebase Scan -``` - -**WAIT for user to select Continue.** diff --git a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-02-codebase-scan.md b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-02-codebase-scan.md deleted file mode 100644 index 69f4022f..00000000 --- a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-02-codebase-scan.md +++ /dev/null @@ -1,184 +0,0 @@ -# Step 2: Systematic Codebase Gap Analysis - -## Goal -VERIFY what code actually exists vs what's missing using Glob and Read tools. - -## CRITICAL -This step uses ACTUAL file system tools to generate TRUTHFUL gap analysis. -No guessing. No inference. VERIFY with tools. - -## Execution - -### 1. Scan Target Directories - -**For each target directory identified in Step 1:** - -```bash -# List all TypeScript files -Glob: {target_dir}/src/**/*.ts -Glob: {target_dir}/src/**/*.tsx - -# Store file list -``` - -**Output:** -``` -πŸ“ Codebase Scan Results for {target_dir} - -Found {count} TypeScript files: - - {file1} - - {file2} - ... -``` - -### 2. Check for Specific Required Components - -**Based on story Acceptance Criteria, check if required files exist:** - -**Example for Auth Story:** -```bash -# Check for OAuth endpoints -Glob: {target_dir}/src/auth/controllers/*bridgeid*.ts -Result: ❌ MISSING (0 files found) - -# Check for BridgeID client -Glob: {target_dir}/src/bridgeid/**/*.ts -Result: βœ… EXISTS (found: bridgeid-client.service.ts, bridgeid-sync.service.ts) - -# Check for permission guards -Glob: {target_dir}/src/auth/guards/permissions*.ts -Result: ❌ MISSING (0 files found) - -# Check for decorators -Glob: {target_dir}/src/auth/decorators/*permission*.ts -Result: ❌ MISSING (0 files found) -``` - -### 3. Verify Implementation Depth - -**For files that exist, read them to check if MOCKED or REAL:** - -```bash -# Read key implementation file -Read: {target_dir}/src/bridgeid/services/bridgeid-client.service.ts - -# Search for indicators: -- Contains "MOCK" or "mock" β†’ ⚠️ MOCKED (needs real implementation) -- Contains "TODO" β†’ ⚠️ INCOMPLETE -- Contains real HTTP client (axios) β†’ βœ… IMPLEMENTED -``` - -### 4. Check Dependencies - -```bash -# Read package.json -Read: {target_dir}/package.json - -# Verify required dependencies exist: -Required: axios -Found in package.json? β†’ ❌ NO (needs to be added) - -Required: @aws-sdk/client-secrets-manager -Found in package.json? β†’ ❌ NO (needs to be added) -``` - -### 5. Check Test Coverage - -```bash -# Find test files -Glob: {target_dir}/src/**/*.spec.ts -Glob: {target_dir}/test/**/*.test.ts - -# Count tests -Found {test_count} test files - -# Check for specific test coverage -Glob: {target_dir}/src/**/*bridgeid*.spec.ts -Result: βœ… EXISTS (found 3 test files) -``` - -### 6. Generate Truthful Gap Analysis - -**Create structured gap analysis:** - -```markdown -## Gap Analysis: Current State vs Requirements - -**βœ… IMPLEMENTED (Verified by Codebase Scan):** - -1. **BridgeID Client Infrastructure** - MOCKED (needs real HTTP) - - File: src/bridgeid/services/bridgeid-client.service.ts βœ… EXISTS - - Implementation: Mock user data with circuit breaker - - Status: ⚠️ PARTIAL - Ready for real HTTP client - - Tests: 15 tests passing βœ… - -2. **User Synchronization Service** - - File: src/bridgeid/services/bridgeid-sync.service.ts βœ… EXISTS - - Implementation: Bulk sync BridgeID β†’ admin_users - - Status: βœ… COMPLETE - - Tests: 6 tests passing βœ… - -3. **Role Mapping Logic** - - File: src/bridgeid/constants/role-mapping.constants.ts βœ… EXISTS - - Implementation: 7-tier role mapping with priority selection - - Status: βœ… COMPLETE - - Tests: 10 tests passing βœ… - -**❌ MISSING (Required for AC Completion):** - -1. **BridgeID OAuth Endpoints** - - File: src/auth/controllers/bridgeid-auth.controller.ts ❌ NOT FOUND - - Need: POST /api/auth/bridgeid/login endpoint - - Need: GET /api/auth/bridgeid/callback endpoint - - Status: ❌ NOT IMPLEMENTED - -2. **Permission Guards** - - File: src/auth/guards/permissions.guard.ts ❌ NOT FOUND - - File: src/auth/decorators/require-permissions.decorator.ts ❌ NOT FOUND - - Status: ❌ NOT IMPLEMENTED - -3. **Real OAuth HTTP Client** - - Package: axios ❌ NOT in package.json - - Package: @aws-sdk/client-secrets-manager ❌ NOT in package.json - - Status: ❌ DEPENDENCIES NOT ADDED -``` - -### 7. Update Acceptance Criteria Checkboxes - -**Based on verified gap analysis, mark checkboxes:** - -```markdown -### AC1: BridgeID OAuth Integration -- [ ] OAuth login endpoint (VERIFIED MISSING - file not found) -- [ ] OAuth callback endpoint (VERIFIED MISSING - file not found) -- [ ] Client configuration (VERIFIED PARTIAL - exists but mocked) - -### AC3: RBAC Permission System -- [x] Role mapping defined (VERIFIED COMPLETE - file exists, tests pass) -- [ ] Permission guard (VERIFIED MISSING - file not found) -- [ ] Permission decorator (VERIFIED MISSING - file not found) -``` - -**Checkboxes are now FACTS, not guesses.** - -### 8. Present Gap Analysis - -**Output:** -``` -βœ… Codebase Scan Complete - -Scanned: apps/backend/admin-user-service/ -Files found: 47 TypeScript files -Tests found: 31 test files - -Gap Analysis Generated: - βœ… 7 components IMPLEMENTED (verified) - ❌ 6 components MISSING (verified) - ⚠️ 1 component PARTIAL (needs completion) - -Story checkboxes updated based on verified file existence. - -[C] Continue to Story Generation -``` - -**WAIT for user to continue.** diff --git a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-03-generate-story.md b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-03-generate-story.md deleted file mode 100644 index 34281465..00000000 --- a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-03-generate-story.md +++ /dev/null @@ -1,181 +0,0 @@ -# Step 3: Generate Story with Verified Gap Analysis - -## Goal -Generate complete 7-section story file using verified gap analysis from Step 2. - -## Execution - -### 1. Load Template - -```bash -Read: {installed_path}/template.md -``` - -### 2. Fill Template Variables - -**Basic Story Info:** -- `{{epic_num}}` - from Step 1 -- `{{story_num}}` - from Step 1 -- `{{story_title}}` - from existing story or epic -- `{{priority}}` - from epic (P0, P1, P2) -- `{{effort}}` - from epic or estimate - -**Story Section:** -- `{{role}}` - from existing story -- `{{action}}` - from existing story -- `{{benefit}}` - from existing story - -**Business Context:** -- `{{business_value}}` - from epic context -- `{{scale_requirements}}` - from epic/architecture -- `{{compliance_requirements}}` - from epic/architecture -- `{{urgency}}` - from epic priority - -**Acceptance Criteria:** -- `{{acceptance_criteria}}` - from epic + existing story -- Update checkboxes based on Step 2 gap analysis: - - [x] = Component verified EXISTS - - [ ] = Component verified MISSING - - [~] = Component verified PARTIAL (optional notation) - -**Tasks / Subtasks:** -- `{{tasks_subtasks}}` - from epic + existing story -- Add "βœ… DONE", "⚠️ PARTIAL", "❌ TODO" markers based on gap analysis - -**Gap Analysis Section:** -- `{{implemented_components}}` - from Step 2 codebase scan (verified βœ…) -- `{{missing_components}}` - from Step 2 codebase scan (verified ❌) -- `{{partial_components}}` - from Step 2 codebase scan (verified ⚠️) - -**Architecture Compliance:** -- `{{architecture_patterns}}` - from architecture doc + playbooks -- Multi-tenant isolation requirements -- Caching strategies -- Error handling patterns -- Performance requirements - -**Library/Framework Requirements:** -- `{{current_dependencies}}` - from Step 2 package.json scan -- `{{required_dependencies}}` - missing deps identified in Step 2 - -**File Structure:** -- `{{existing_files}}` - from Step 2 Glob results (verified βœ…) -- `{{required_files}}` - from gap analysis (verified ❌) - -**Testing Requirements:** -- `{{test_count}}` - from Step 2 test file count -- `{{required_tests}}` - based on missing components -- `{{coverage_target}}` - from architecture or default 90% - -**Dev Agent Guardrails:** -- `{{guardrails}}` - from playbooks + previous story lessons -- What NOT to do -- Common mistakes to avoid - -**Previous Story Intelligence:** -- `{{previous_story_learnings}}` - from Step 1 previous story Dev Agent Record - -**Project Structure Notes:** -- `{{structure_alignment}}` - from architecture compliance - -**References:** -- `{{references}}` - Links to epic, architecture, playbooks, related stories - -**Definition of Done:** -- Standard DoD checklist with story-specific coverage target - -### 3. Generate Complete Story - -**Write filled template:** -```bash -Write: {story_dir}/story-{{epic_num}}.{{story_num}}.md -[Complete 7-section story with verified gap analysis] -``` - -### 4. Validate Generated Story - -```bash -# Check section count -grep "^## " {story_dir}/story-{{epic_num}}.{{story_num}}.md | wc -l -# Should output: 7 - -# Check for gap analysis -grep -q "Gap Analysis.*Current State" {story_dir}/story-{{epic_num}}.{{story_num}}.md -# Should find it - -# Run custom validation -./scripts/validate-bmad-format.sh {story_dir}/story-{{epic_num}}.{{story_num}}.md -# Update script to expect 7 sections + gap analysis subsection -``` - -### 5. Update Sprint Status - -```bash -Read: {sprint_status} - -# Find story entry -# Update status to "ready-for-dev" if was "backlog" -# Preserve all comments and structure - -Write: {sprint_status} -``` - -### 6. Report Completion - -**Output:** -``` -βœ… Story {{epic_num}}.{{story_num}} Regenerated with Gap Analysis - -File: {story_dir}/story-{{epic_num}}.{{story_num}}.md -Sections: 7/7 βœ… -Gap Analysis: VERIFIED with codebase scan - -Summary: - βœ… {{implemented_count}} components IMPLEMENTED (verified by file scan) - ❌ {{missing_count}} components MISSING (verified file not found) - ⚠️ {{partial_count}} components PARTIAL (file exists but mocked/incomplete) - -Checkboxes in ACs and Tasks reflect VERIFIED status (not guesses). - -Next Steps: -1. Review story file for accuracy -2. Use /dev-story to implement missing components -3. Story provides complete context for flawless implementation - -Story is ready for development. πŸš€ -``` - -### 7. Cleanup - -**Ask user:** -``` -Story regeneration complete! - -Would you like to: -[N] Regenerate next story ({{next_story_num}}) -[Q] Quit workflow -[R] Review generated story first - -Your choice: -``` - -**If N selected:** Loop back to Step 1 with next story number -**If Q selected:** End workflow -**If R selected:** Display story file, then show menu again - ---- - -## Success Criteria - -**Story generation succeeds when:** -1. βœ… 7 top-level ## sections present -2. βœ… Gap Analysis subsection exists with βœ…/❌/⚠️ verified status -3. βœ… Checkboxes match codebase reality (spot-checked) -4. βœ… Dev Notes has all mandatory subsections -5. βœ… Definition of Done checklist included -6. βœ… File saved to correct location -7. βœ… Sprint status updated - ---- - -**WORKFLOW COMPLETE - Ready to execute.** diff --git a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/template.md b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/template.md deleted file mode 100644 index c0b7c87d..00000000 --- a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/template.md +++ /dev/null @@ -1,179 +0,0 @@ -# Story {{epic_num}}.{{story_num}}: {{story_title}} - -**Status:** ready-for-dev -**Epic:** {{epic_num}} -**Priority:** {{priority}} -**Estimated Effort:** {{effort}} - ---- - -## Story - -As a **{{role}}**, -I want to **{{action}}**, -So that **{{benefit}}**. - ---- - -## Business Context - -### Why This Matters - -{{business_value}} - -### Production Reality - -{{scale_requirements}} -{{compliance_requirements}} -{{urgency}} - ---- - -## Acceptance Criteria - -{{acceptance_criteria}} - ---- - -## Tasks / Subtasks - -{{tasks_subtasks}} - ---- - -## Dev Notes - -### Gap Analysis: Current State vs Requirements - -**βœ… IMPLEMENTED (Verified by Codebase Scan):** - -{{implemented_components}} - -**❌ MISSING (Required for AC Completion):** - -{{missing_components}} - -**⚠️ PARTIAL (Needs Enhancement):** - -{{partial_components}} - -### Architecture Compliance - -{{architecture_patterns}} - -### Library/Framework Requirements - -**Current Dependencies:** -```json -{{current_dependencies}} -``` - -**Required Additions:** -```json -{{required_dependencies}} -``` - -### File Structure Requirements - -**Completed Files:** -``` -{{existing_files}} -``` - -**Required New Files:** -``` -{{required_files}} -``` - -### Testing Requirements - -**Current Test Coverage:** {{test_count}} tests passing - -**Required Additional Tests:** -{{required_tests}} - -**Target:** {{coverage_target}} - -### Dev Agent Guardrails - -{{guardrails}} - -### Previous Story Intelligence - -{{previous_story_learnings}} - -### Project Structure Notes - -{{structure_alignment}} - -### References - -{{references}} - ---- - -## Definition of Done - -### Code Quality (BLOCKING) -- [ ] Type check passes: `pnpm type-check` (zero errors) -- [ ] Zero `any` types in new code -- [ ] Lint passes: `pnpm lint` (zero errors in new code) -- [ ] Build succeeds: `pnpm build` - -### Testing (BLOCKING) -- [ ] Unit tests: {{coverage_target}} coverage -- [ ] Integration tests: Key workflows validated -- [ ] All tests pass: New + existing (zero regressions) - -### Security (BLOCKING) -- [ ] Dependency scan: `pnpm audit` (zero high/critical) -- [ ] No hardcoded secrets -- [ ] Input validation on all endpoints -- [ ] Auth checks on protected endpoints -- [ ] Audit logging on mutations - -### Architecture Compliance (BLOCKING) -- [ ] Multi-tenant isolation: dealerId in all queries -- [ ] Cache namespacing: Cache keys include siteId -- [ ] Performance: External APIs cached, no N+1 queries -- [ ] Error handling: No silent failures -- [ ] Follows patterns from playbooks - -### Deployment Validation (BLOCKING) -- [ ] Service starts: `pnpm dev` runs successfully -- [ ] Health check: `/health` returns 200 -- [ ] Smoke test: Primary functionality verified - -### Documentation (BLOCKING) -- [ ] API docs: Swagger decorators on endpoints -- [ ] Inline comments: Complex logic explained -- [ ] Story file: Dev Agent Record complete - ---- - -## Dev Agent Record - -### Agent Model Used - -(To be filled by dev agent) - -### Implementation Summary - -(To be filled by dev agent) - -### File List - -(To be filled by dev agent) - -### Test Results - -(To be filled by dev agent) - -### Completion Notes - -(To be filled by dev agent) - ---- - -**Generated by:** /create-story-with-gap-analysis -**Date:** {{date}} diff --git a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.md b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.md new file mode 100644 index 00000000..b40462b5 --- /dev/null +++ b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.md @@ -0,0 +1,286 @@ +# Create Story with Gap Analysis v3.0 - Verified Story Generation + + +Regenerate story with VERIFIED codebase gap analysis. +Uses Glob/Read tools to determine what actually exists vs what's missing. +Checkboxes reflect reality, not guesses. + + + +**Truth from Codebase, Not Assumptions** + +1. Scan codebase for actual implementations +2. Verify files exist, check for stubs/TODOs +3. Check test coverage +4. Generate story with checkboxes matching reality +5. No guessingβ€”every checkbox has evidence + + + +name: create-story-with-gap-analysis +version: 3.0.0 + +verification_status: + verified: "[x]" # File exists, real implementation, tests exist + partial: "[~]" # File exists but stub/TODO or no tests + missing: "[ ]" # File does not exist + +defaults: + update_sprint_status: true + create_report: false + + + +@patterns/verification.md +@patterns/hospital-grade.md + + + + + +**Identify story and load context** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” STORY REGENERATION WITH GAP ANALYSIS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**Ask user for story:** +``` +Which story should I regenerate with gap analysis? + +Provide: +- Story number (e.g., "1.9" or "1-9") +- OR story filename + +Your choice: +``` + +**Parse input:** +- Extract epic_num, story_num +- Locate story file + +**Load existing story:** +```bash +Read: {{story_dir}}/story-{{epic_num}}.{{story_num}}.md +``` + +Extract: +- Story title +- User story (As a... I want... So that...) +- Acceptance criteria +- Tasks +- Dev Notes + +**Load epic context:** +```bash +Read: {{planning_artifacts}}/epics.md +``` + +Extract: +- Epic business objectives +- Technical constraints +- Dependencies + +**Determine target directories:** +From story title/requirements, identify which directories to scan. + +``` +βœ… Story Context Loaded + +Story: {{epic_num}}.{{story_num}} - {{title}} +Target directories: +{{#each directories}} + - {{this}} +{{/each}} + +[C] Continue to Codebase Scan +``` + + + +**VERIFY what code actually exists** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” CODEBASE SCAN +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**For each target directory:** + +1. **List all source files:** + ```bash + Glob: {{target_dir}}/src/**/*.ts + Glob: {{target_dir}}/src/**/*.tsx + ``` + +2. **Check for specific required components:** + Based on story ACs, check if required files exist: + ```bash + Glob: {{target_dir}}/src/auth/controllers/*oauth*.ts + # Result: βœ… EXISTS or ❌ MISSING + ``` + +3. **Verify implementation depth:** + For files that exist, check quality: + ```bash + Read: {{file}} + + # Check for stubs + Grep: "MOCK|TODO|FIXME|Not implemented" {{file}} + # If found: ⚠️ STUB + ``` + +4. **Check dependencies:** + ```bash + Read: {{target_dir}}/package.json + + # Required: axios - Found? βœ…/❌ + # Required: @aws-sdk/client-secrets-manager - Found? βœ…/❌ + ``` + +5. **Check test coverage:** + ```bash + Glob: {{target_dir}}/src/**/*.spec.ts + Glob: {{target_dir}}/test/**/*.test.ts + ``` + + + +**Create verified gap analysis** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“Š GAP ANALYSIS RESULTS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +βœ… IMPLEMENTED (Verified): +{{#each implemented}} +{{@index}}. **{{name}}** + - File: {{file}} βœ… EXISTS + - Status: {{status}} + - Tests: {{test_count}} tests +{{/each}} + +❌ MISSING (Verified): +{{#each missing}} +{{@index}}. **{{name}}** + - Expected: {{expected_file}} ❌ NOT FOUND + - Needed for: {{requirement}} +{{/each}} + +⚠️ PARTIAL (Stub/Incomplete): +{{#each partial}} +{{@index}}. **{{name}}** + - File: {{file}} βœ… EXISTS + - Issue: {{issue}} +{{/each}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + +**Generate story with verified checkboxes** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“ GENERATING STORY +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Use story template with: +- `[x]` for VERIFIED items (evidence: file exists, not stub, has tests) +- `[~]` for PARTIAL items (evidence: file exists but stub/no tests) +- `[ ]` for MISSING items (evidence: file not found) + +**Write story file:** +```bash +Write: {{story_dir}}/story-{{epic_num}}.{{story_num}}.md +``` + +**Validate generated story:** +```bash +# Check 7 sections exist +grep "^## " {{story_file}} | wc -l +# Should be 7 + +# Check gap analysis section exists +grep "Gap Analysis" {{story_file}} +``` + + + +**Update sprint-status.yaml** + +```bash +Read: {{sprint_status}} + +# Update story status to "ready-for-dev" if was "backlog" +# Preserve comments and structure + +Write: {{sprint_status}} +``` + + + +**Report completion** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… STORY REGENERATED WITH GAP ANALYSIS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{epic_num}}.{{story_num}} - {{title}} +File: {{story_file}} +Sections: 7/7 βœ… + +Gap Analysis Summary: +- βœ… {{implemented_count}} components VERIFIED complete +- ❌ {{missing_count}} components VERIFIED missing +- ⚠️ {{partial_count}} components PARTIAL (stub/no tests) + +Checkboxes reflect VERIFIED codebase state. + +Next Steps: +1. Review story for accuracy +2. Use /dev-story to implement missing components +3. Story provides complete context for implementation + +[N] Regenerate next story +[Q] Quit +[R] Review generated story +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**If [N]:** Loop back to initialize with next story. +**If [R]:** Display story content, then show menu. + + + + + +```bash +# Regenerate specific story +/create-story-with-gap-analysis +> Which story? 1.9 + +# With explicit story file +/create-story-with-gap-analysis story_file=docs/sprint-artifacts/story-1.9.md +``` + + + +**Story not found:** HALT with clear error. +**Target directory not found:** Warn, scan available directories. +**Glob/Read fails:** Log warning, count as MISSING. +**Write fails:** Report error, display generated content. + + + +- [ ] Codebase scanned for all story requirements +- [ ] Gap analysis generated with evidence +- [ ] Story written with verified checkboxes +- [ ] 7 sections present +- [ ] Sprint status updated (if enabled) + diff --git a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml index 19217943..d6297e95 100644 --- a/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml +++ b/src/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml @@ -14,10 +14,9 @@ story_dir: "{implementation_artifacts}" # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/create-story-with-gap-analysis" -template: "{installed_path}/template.md" -instructions: "{installed_path}/step-01-initialize.md" +instructions: "{installed_path}/workflow.md" -# Variables and inputs +# Variables variables: sprint_status: "{implementation_artifacts}/sprint-status.yaml" epics_file: "{planning_artifacts}/epics.md" @@ -28,12 +27,6 @@ project_context: "**/project-context.md" default_output_file: "{story_dir}/{{story_key}}.md" -# Workflow steps (processed in order) -steps: - - step-01-initialize.md - - step-02-codebase-scan.md - - step-03-generate-story.md - standalone: true web_bundle: false diff --git a/src/bmm/workflows/4-implementation/detect-ghost-features/instructions.md b/src/bmm/workflows/4-implementation/detect-ghost-features/instructions.md deleted file mode 100644 index dc113271..00000000 --- a/src/bmm/workflows/4-implementation/detect-ghost-features/instructions.md +++ /dev/null @@ -1,625 +0,0 @@ -# Detect Ghost Features - Reverse Gap Analysis (Who You Gonna Call?) - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml - - - - - Determine scan scope based on parameters: - - - Read {sprint_status} - Filter stories starting with "{{epic_number}}-" - Store as: stories_in_scope - πŸ” Scanning Epic {{epic_number}} stories for documented features... - - - - Read {sprint_status} - Get ALL story keys (exclude epics and retrospectives) - Store as: stories_in_scope - πŸ” Scanning entire sprint for documented features... - - - - Set stories_in_scope = ALL stories found in {sprint_artifacts} - πŸ” Scanning entire codebase for documented features... - - - For each story in stories_in_scope: - Read story file - Extract documented artifacts: - - File List (all paths mentioned) - - Tasks (all file/component/service names mentioned) - - ACs (all features/functionality mentioned) - Store in: documented_artifacts[story_key] = {files, components, services, apis, features} - - -βœ… Loaded {{stories_in_scope.length}} stories -πŸ“‹ Documented artifacts extracted from {{total_sections}} sections - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ‘» SCANNING FOR GHOST FEATURES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Looking for: Components, APIs, Services, DB Tables, Models -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Use Glob to find component files: - - **/*.component.{tsx,jsx,ts,js,vue} (Angular/Vue pattern) - - **/components/**/*.{tsx,jsx} (React pattern) - - **/src/**/*{Component,View,Screen,Page}.{tsx,jsx} (Named pattern) - - For each found component file: - Extract component name from filename or export - Check file size (ignore <50 lines as trivial) - Read file to determine if it's a significant feature - - Store as: codebase_components = [{name, path, size, purpose}] - - πŸ“¦ Found {{codebase_components.length}} components - - - - - - Use Glob to find API files: - - **/api/**/*.{ts,js} (Next.js/Express pattern) - - **/*.controller.{ts,js} (NestJS pattern) - - **/routes/**/*.{ts,js} (Generic routes) - - Use Grep to find endpoint definitions: - - @Get|@Post|@Put|@Delete decorators (NestJS) - - export async function GET|POST|PUT|DELETE (Next.js App Router) - - router.get|post|put|delete (Express) - - app.route (Flask/FastAPI if Python) - - For each endpoint found: - Extract: HTTP method, path, handler name - Read file to understand functionality - - Store as: codebase_apis = [{method, path, handler, file}] - - 🌐 Found {{codebase_apis.length}} API endpoints - - - - - - Use Glob to find schema files: - - **/prisma/schema.prisma (Prisma) - - **/*.entity.{ts,js} (TypeORM) - - **/models/**/*.{ts,js} (Mongoose/Sequelize) - - **/*-table.ts (Custom) - - Use Grep to find table definitions: - - model (Prisma) - - @Entity (TypeORM) - - createTable (Migrations) - - For each table found: - Extract: table name, columns, relationships - - Store as: codebase_tables = [{name, file, columns}] - - πŸ—„οΈ Found {{codebase_tables.length}} database tables - - - - - - Use Glob to find service files: - - **/*.service.{ts,js} - - **/services/**/*.{ts,js} - - **/*Service.{ts,js} - - For each service found: - Extract: service name, key methods, dependencies - Ignore trivial services (<100 lines) - - Store as: codebase_services = [{name, file, methods}] - - βš™οΈ Found {{codebase_services.length}} services - - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” CROSS-REFERENCING CODEBASE ↔ STORIES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Initialize: orphaned_features = [] - - - For each component in codebase_components: - - Search all stories for mentions of: - - Component name in File Lists - - Component name in Task descriptions - - Component file path in File Lists - - Feature described by component in ACs - - - Add to orphaned_features: - - type: "component" - name: {{component.name}} - path: {{component.path}} - size: {{component.size}} lines - purpose: {{inferred_purpose_from_code}} - severity: "HIGH" # Significant orphan - - πŸ‘» ORPHAN: {{component.name}} ({{component.path}}) - - - - βœ… Documented: {{component.name}} β†’ {{story_keys}} - - - - - For each API in codebase_apis: - - Search all stories for mentions of: - - Endpoint path (e.g., "/api/users") - - HTTP method + resource (e.g., "POST users") - - Handler file in File Lists - - API functionality in ACs (e.g., "Users can create account") - - - Add to orphaned_features: - - type: "api" - method: {{api.method}} - path: {{api.path}} - handler: {{api.handler}} - file: {{api.file}} - severity: "CRITICAL" # APIs are critical functionality - - πŸ‘» ORPHAN: {{api.method}} {{api.path}} ({{api.file}}) - - - - - For each table in codebase_tables: - - Search all stories for mentions of: - - Table name - - Migration file in File Lists - - Data model in Tasks - - - Add to orphaned_features: - - type: "database" - name: {{table.name}} - file: {{table.file}} - columns: {{table.columns.length}} - severity: "HIGH" # Database changes are significant - - πŸ‘» ORPHAN: Table {{table.name}} ({{table.file}}) - - - - - For each service in codebase_services: - - Search all stories for mentions of: - - Service name or class name - - Service file in File Lists - - Service functionality in Tasks/ACs - - - Add to orphaned_features: - - type: "service" - name: {{service.name}} - file: {{service.file}} - methods: {{service.methods.length}} - severity: "MEDIUM" # Services are business logic - - πŸ‘» ORPHAN: {{service.name}} ({{service.file}}) - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Cross-Reference Complete -πŸ‘» Orphaned Features: {{orphaned_features.length}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Group orphans by type and severity: - - - critical_orphans (APIs, auth, payment) - - high_orphans (Components, DB tables, services) - - medium_orphans (Utilities, helpers) - - low_orphans (Config files, constants) - - - Estimate complexity for each orphan: - Based on file size, dependencies, test coverage - - Suggest epic assignment based on functionality: - - Auth components β†’ Epic focusing on authentication - - UI components β†’ Epic focusing on frontend - - API endpoints β†’ Epic for that resource type - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ‘» GHOST FEATURES DETECTED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total Orphans:** {{orphaned_features.length}} - -**By Severity:** -- πŸ”΄ CRITICAL: {{critical_orphans.length}} (APIs, security-critical) -- 🟠 HIGH: {{high_orphans.length}} (Components, DB, services) -- 🟑 MEDIUM: {{medium_orphans.length}} (Utilities, helpers) -- 🟒 LOW: {{low_orphans.length}} (Config, constants) - -**By Type:** -- Components: {{component_orphans.length}} -- API Endpoints: {{api_orphans.length}} -- Database Tables: {{db_orphans.length}} -- Services: {{service_orphans.length}} -- Other: {{other_orphans.length}} - ---- - -**CRITICAL Orphans (Immediate Action Required):** -{{#each critical_orphans}} -{{@index + 1}}. **{{type | uppercase}}**: {{name}} - File: {{file}} - Purpose: {{inferred_purpose}} - Risk: {{why_critical}} - Suggested Epic: {{suggested_epic}} -{{/each}} - ---- - -**HIGH Priority Orphans:** -{{#each high_orphans}} -{{@index + 1}}. **{{type | uppercase}}**: {{name}} - File: {{file}} - Size: {{size}} lines / {{complexity}} complexity - Suggested Epic: {{suggested_epic}} -{{/each}} - ---- - -**Detection Confidence:** -- Artifacts scanned: {{total_artifacts_scanned}} -- Stories cross-referenced: {{stories_in_scope.length}} -- Documentation coverage: {{documented_pct}}% -- Orphan rate: {{orphan_rate}}% - -{{#if orphan_rate > 20}} -⚠️ **HIGH ORPHAN RATE** - Over 20% of codebase is undocumented! -Recommend: Comprehensive backfill story creation session -{{/if}} - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - -Backfill story creation disabled. To create stories for orphans, run: -/detect-ghost-features create_backfill_stories=true - - Jump to Step 7 (Generate Report) - - - - βœ… No orphans found - all code is documented in stories! - Jump to Step 7 - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“ PROPOSING BACKFILL STORIES ({{orphaned_features.length}}) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each orphaned feature (prioritized by severity): - - - Analyze orphan to understand functionality: - - Read implementation code - - Identify dependencies and related files - - Determine what it does (infer from code) - - Find tests (if any) to understand use cases - - Generate story draft: - -Story Title: "Document existing {{name}} {{type}}" - -Story Description: -This is a BACKFILL STORY documenting existing functionality found in the codebase -that was not tracked in any story (likely vibe-coded or manually added). - -Business Context: -{{inferred_business_purpose_from_code}} - -Current State: -βœ… **Implementation EXISTS:** {{file}} -- {{description_of_what_it_does}} -- {{key_features_or_methods}} -{{#if has_tests}}βœ… Tests exist: {{test_files}}{{else}}❌ No tests found{{/if}} - -Acceptance Criteria: -{{#each inferred_acs_from_code}} -- [ ] {{this}} -{{/each}} - -Tasks: -- [x] {{name}} implementation (ALREADY EXISTS - {{file}}) -{{#if missing_tests}}- [ ] Add tests for {{name}}{{/if}} -{{#if missing_docs}}- [ ] Add documentation for {{name}}{{/if}} -- [ ] Verify functionality works as expected -- [ ] Add to relevant epic or create new epic for backfills - -Definition of Done: -- [x] Implementation exists and works -{{#if has_tests}}- [x] Tests exist{{else}}- [ ] Tests added{{/if}} -- [ ] Documented in story (this story) -- [ ] Assigned to appropriate epic - -Story Type: BACKFILL (documenting existing code) - - - -πŸ“„ Generated backfill story draft for: {{name}} - -{{story_draft_preview}} - ---- - - - - - - Create backfill story automatically - βœ… Auto-created: {{story_filename}} - - - - -Create backfill story for {{name}}? - -**Type:** {{type}} -**File:** {{file}} -**Suggested Epic:** {{suggested_epic}} -**Complexity:** {{complexity_estimate}} - -[Y] Yes - Create this backfill story -[A] Auto - Create this and all remaining backfill stories -[E] Edit - Let me adjust the story draft first -[S] Skip - Don't create story for this orphan -[H] Halt - Stop backfill story creation - -Your choice: - - - - Create backfill story file: {sprint_artifacts}/backfill-{{type}}-{{name}}.md - Add to backfill_stories_created list - βœ… Created: {{story_filename}} - - - - Set auto_create = true - Create this story and auto-create remaining - - - - Provide your adjusted story content or instructions for modifications: - Apply user's edits to story draft - Create modified backfill story - - - - Add to skipped_backfills list - ⏭️ Skipped - - - - Exit backfill story creation loop - Jump to Step 6 - - - - - - Load {sprint_status} file - - For each created backfill story: - Add entry: {{backfill_story_key}}: backlog # BACKFILL - documents existing {{name}} - - Save sprint-status.yaml - - βœ… Added {{backfill_stories_created.length}} backfill stories to sprint-status.yaml - - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š BACKFILL STORY ORGANIZATION -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Group backfill stories by suggested epic: - - For each suggested_epic: - -**{{suggested_epic}}:** -{{#each backfill_stories_for_epic}} - - {{story_key}}: {{name}} ({{type}}) -{{/each}} - - - ---- - -**Recommendations:** - -1. **Option A: Create "Epic-Backfill" for all orphans** - - Single epic containing all backfill stories - - Easy to track undocumented code - - Clear separation from feature work - -2. **Option B: Distribute to existing epics** - - Add each backfill story to its logical epic - - Better thematic grouping - - May inflate epic story counts - -3. **Option C: Leave in backlog** - - Don't assign to epics yet - - Review and assign during next planning - -**Your choice:** -[A] Create Epic-Backfill (recommended) -[B] Distribute to existing epics -[C] Leave in backlog for manual assignment -[S] Skip epic assignment - - - How should backfill stories be organized? - - - Create epic-backfill.md in epics directory - Update sprint-status.yaml with epic-backfill entry - Assign all backfill stories to epic-backfill - - - - For each backfill story: - Assign to suggested_epic in sprint-status.yaml - Update story_key to match epic (e.g., 2-11-backfill-userprofile) - - - - Leave stories in backlog - - - - - - - Write report to: {sprint_artifacts}/ghost-features-report-{{timestamp}}.md - - Report structure: - -# Ghost Features Report (Reverse Gap Analysis) - -**Generated:** {{timestamp}} -**Scope:** {{scan_scope}} {{#if epic_number}}(Epic {{epic_number}}){{/if}} - -## Executive Summary - -**Codebase Artifacts Scanned:** {{total_artifacts_scanned}} -**Stories Cross-Referenced:** {{stories_in_scope.length}} -**Orphaned Features Found:** {{orphaned_features.length}} -**Documentation Coverage:** {{documented_pct}}% -**Backfill Stories Created:** {{backfill_stories_created.length}} - -## Orphaned Features Detail - -### CRITICAL Orphans ({{critical_orphans.length}}) -[Full list with files, purposes, risks] - -### HIGH Priority Orphans ({{high_orphans.length}}) -[Full list] - -### MEDIUM Priority Orphans ({{medium_orphans.length}}) -[Full list] - -## Backfill Stories Created - -{{#each backfill_stories_created}} -- {{story_key}}: {{story_file}} -{{/each}} - -## Recommendations - -[Epic assignment suggestions, next steps] - -## Appendix: Scan Methodology - -[How detection worked, patterns used, confidence levels] - - - πŸ“„ Full report: {{report_path}} - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… GHOST FEATURE DETECTION COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Scan Scope:** {{scan_scope}} {{#if epic_number}}(Epic {{epic_number}}){{/if}} - -**Results:** -- πŸ‘» Orphaned Features: {{orphaned_features.length}} -- πŸ“ Backfill Stories Created: {{backfill_stories_created.length}} -- ⏭️ Skipped: {{skipped_backfills.length}} -- πŸ“Š Documentation Coverage: {{documented_pct}}% - -{{#if orphaned_features.length == 0}} -βœ… **EXCELLENT!** All code is documented in stories. -Your codebase and story backlog are in perfect sync. -{{/if}} - -{{#if orphaned_features.length > 0 AND backfill_stories_created.length == 0}} -**Action Required:** -Run with create_backfill_stories=true to generate stories for orphans -{{/if}} - -{{#if backfill_stories_created.length > 0}} -**Next Steps:** - -1. **Review backfill stories** - Check generated stories for accuracy -2. **Assign to epics** - Organize backfills (or create Epic-Backfill) -3. **Update sprint-status.yaml** - Already updated with {{backfill_stories_created.length}} new entries -4. **Prioritize** - Decide when to implement tests/docs for orphans -5. **Run revalidation** - Verify orphans work as expected - -**Quick Commands:** -```bash -# Revalidate a backfill story to verify functionality -/revalidate-story story_file={{backfill_stories_created[0].file}} - -# Process backfill stories (add tests/docs) -/batch-super-dev filter_by_epic=backfill -``` -{{/if}} - -{{#if create_report}} -**Detailed Report:** {{report_path}} -{{/if}} - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -πŸ’‘ **Pro Tip:** Run this periodically (e.g., end of each sprint) to catch -vibe-coded features before they become maintenance nightmares. -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - diff --git a/src/bmm/workflows/4-implementation/gap-analysis/instructions.xml b/src/bmm/workflows/4-implementation/gap-analysis/instructions.xml deleted file mode 100644 index 4af6db50..00000000 --- a/src/bmm/workflows/4-implementation/gap-analysis/instructions.xml +++ /dev/null @@ -1,367 +0,0 @@ - - The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml - You MUST have already loaded and processed: {installed_path}/workflow.yaml - Communicate all responses in {communication_language} - - - - Use {{story_file}} directly - Read COMPLETE story file - Extract story_key from filename or metadata - - - - - πŸ” **Gap Analysis - Story Task Validation** - - This workflow validates story tasks against your actual codebase. - - **Use Cases:** - - Audit "done" stories to verify they match reality - - Validate story tasks before starting development - - Check if completed work was actually implemented - - **Provide story to validate:** - - - Enter story file path, story key (e.g., "1-2-auth"), or status to scan (e.g., "done", "review", "in-progress"): - - - Use provided file path as {{story_file}} - Read COMPLETE story file - Extract story_key from filename - - - - - Search {story_dir} for file matching pattern {{story_key}}.md - Set {{story_file}} to found file path - Read COMPLETE story file - - - - - πŸ”Ž Scanning sprint-status.yaml for stories with status: {{user_input}}... - - - Load the FULL file: {{sprint_status}} - Parse development_status section - Find all stories where status equals {{user_input}} - - - πŸ“‹ No stories found with status: {{user_input}} - - Available statuses: backlog, ready-for-dev, in-progress, review, done - - HALT - - - - Found {{count}} stories with status {{user_input}}: - - {{list_of_stories}} - - Which story would you like to validate? [Enter story key or 'all']: - - - Set {{batch_mode}} = true - Store list of all story keys to validate - Set {{story_file}} to first story in list - Read COMPLETE story file - - - - - Set {{story_file}} to selected story path - Read COMPLETE story file - - - - - - Set {{story_file}} to found story path - Read COMPLETE story file - - - - - - ⚠️ No sprint-status.yaml found. Please provide direct story file path. - HALT - - - - - - - - πŸ” CODEBASE REALITY CHECK - Validate tasks against actual code! - - πŸ“Š **Analyzing Story: {{story_key}}** - - Scanning codebase to validate tasks... - - - - Parse story sections: Story, Acceptance Criteria, Tasks/Subtasks, Dev Notes, Status - Extract all tasks and subtasks from story file - Identify technical areas mentioned in tasks (files, classes, functions, services, components) - - - Determine scan targets from task descriptions: - - For "Create X" tasks: Check if X already exists - - For "Implement Y" tasks: Search for Y functionality - - For "Add Z" tasks: Verify Z is missing - - For test tasks: Check for existing test files - - Use Glob to find relevant files matching patterns from tasks (e.g., **/*.ts, **/*.tsx, **/*.test.ts) - Use Grep to search for specific classes, functions, or components mentioned in tasks - Use Read to verify implementation details and functionality in key discovered files - - - Document scan results: - - **CODEBASE REALITY:** - βœ… What Exists: - - List verified files, classes, functions, services found - - Note implementation completeness (partial vs full) - - Identify code that tasks claim to create but already exists - - - ❌ What's Missing: - - List features mentioned in tasks but NOT found in codebase - - Identify claimed implementations that don't exist - - Note tasks marked complete but code missing - - - - For each task in the story, determine: - - ACCURATE: Task matches reality (code exists if task is checked, missing if unchecked) - - FALSE POSITIVE: Task checked [x] but code doesn't exist (BS detection!) - - FALSE NEGATIVE: Task unchecked [ ] but code already exists - - NEEDS UPDATE: Task description doesn't match current implementation - - Generate validation report with: - - Tasks that are accurate - - Tasks that are false positives (marked done but not implemented) ⚠️ - - Tasks that are false negatives (not marked but already exist) - - Recommended task updates - - - - πŸ“‹ SHOW TRUTH - Compare story claims vs codebase reality - - - πŸ“Š **Gap Analysis Results: {{story_key}}** - - **Story Status:** {{story_status}} - - --- - - **Codebase Scan Results:** - - βœ… **What Actually Exists:** - {{list_of_existing_files_features_with_details}} - - ❌ **What's Actually Missing:** - {{list_of_missing_elements_despite_claims}} - - --- - - **Task Validation:** - - {{if_any_accurate_tasks}} - βœ… **Accurate Tasks** ({{count}}): - {{list_tasks_that_match_reality}} - {{endif}} - - {{if_any_false_positives}} - ⚠️ **FALSE POSITIVES** ({{count}}) - Marked done but NOT implemented: - {{list_tasks_marked_complete_but_code_missing}} - **WARNING:** These tasks claim completion but code doesn't exist! - {{endif}} - - {{if_any_false_negatives}} - ℹ️ **FALSE NEGATIVES** ({{count}}) - Not marked but ALREADY exist: - {{list_tasks_unchecked_but_code_exists}} - {{endif}} - - {{if_any_needs_update}} - πŸ”„ **NEEDS UPDATE** ({{count}}) - Task description doesn't match implementation: - {{list_tasks_needing_description_updates}} - {{endif}} - - --- - - πŸ“ **Proposed Story Updates:** - - {{if_false_positives_found}} - **CRITICAL - Uncheck false positives:** - {{list_tasks_to_uncheck_with_reasoning}} - {{endif}} - - {{if_false_negatives_found}} - **Check completed work:** - {{list_tasks_to_check_with_verification}} - {{endif}} - - {{if_task_updates_needed}} - **Update task descriptions:** - {{list_task_description_updates}} - {{endif}} - - {{if_gap_analysis_section_missing}} - **Add Gap Analysis section** documenting findings - {{endif}} - - --- - - **Story Accuracy Score:** {{percentage_of_accurate_tasks}}% ({{accurate_count}}/{{total_count}}) - - - - - - 🚨 **WARNING:** This story is marked {{story_status}} but has FALSE POSITIVES! - - {{count}} task(s) claim completion but code doesn't exist. - This story may have been prematurely marked complete. - - **Recommendation:** Update story status to 'in-progress' and complete missing work. - - - - - - - **What would you like to do?** - - Options: - [U] Update - Apply proposed changes to story file - [A] Audit Report - Save findings to report file without updating story - [N] No Changes - Just show me the findings - [R] Review Details - Show me more details about specific findings - [C] Continue to Next - Move to next story (batch mode only) - [Q] Quit - Exit gap analysis - - - - - Update story file with proposed changes: - - Uncheck false positive tasks - - Check false negative tasks - - Update task descriptions as needed - - Add or update "Gap Analysis" section with findings - - Add Change Log entry: "Gap analysis performed - tasks validated against codebase ({{date}})" - - - Story has false positives. Update status to 'in-progress'? [Y/n]: - - Update story Status to 'in-progress' - - Update sprint-status.yaml status for this story to 'in-progress' - - - - - βœ… Story file updated with gap analysis findings. - - - {{changes_count}} task(s) updated - - Gap Analysis section added/updated - - Accuracy score: {{accuracy_percentage}}% - - **File:** {{story_file}} - - - - Continue to next story? [Y/n]: - - Load next story from batch list - Analyze next story - - - - HALT - Gap analysis complete - - - - - Generate audit report file: {{story_dir}}/gap-analysis-report-{{story_key}}-{{date}}.md - Include full findings, accuracy scores, recommendations - πŸ“„ Audit report saved: {{report_file}} - - This report can be shared with team for review. - Story file was NOT modified. - - - - Continue to next story? [Y/n]: - - Load next story from batch list - Analyze next story - - - - HALT - Gap analysis complete - - - - - ℹ️ Findings displayed only. No files modified. - HALT - Gap analysis complete - - - - - Which findings would you like more details about? (specify task numbers, file names, or areas): - Provide detailed analysis of requested areas using Read tool for deeper code inspection - After review, re-present the decision options - Continue based on user's subsequent choice - - - - - Load next story from batch list - Analyze next story - - - - ⚠️ Not in batch mode. Only one story to validate. - HALT - - - - - πŸ‘‹ Gap analysis session ended. - - {{if batch_mode}}Processed {{processed_count}}/{{total_count}} stories.{{endif}} - - HALT - - - - - βœ… **Gap Analysis Complete, {user_name}!** - - {{if_single_story}} - **Story Analyzed:** {{story_key}} - **Accuracy Score:** {{accuracy_percentage}}% - **Actions Taken:** {{actions_summary}} - {{endif}} - - {{if_batch_mode}} - **Batch Analysis Summary:** - - Stories analyzed: {{processed_count}} - - Average accuracy: {{avg_accuracy}}% - - False positives found: {{total_false_positives}} - - Stories updated: {{updated_count}} - {{endif}} - - **Next Steps:** - - Review updated stories - - Address any false positives found - - Run dev-story for stories needing work - - - - diff --git a/src/bmm/workflows/4-implementation/gap-analysis/workflow.md b/src/bmm/workflows/4-implementation/gap-analysis/workflow.md new file mode 100644 index 00000000..c672b0be --- /dev/null +++ b/src/bmm/workflows/4-implementation/gap-analysis/workflow.md @@ -0,0 +1,246 @@ +# Gap Analysis v3.0 - Verify Story Tasks Against Codebase + + +Validate story checkbox claims against actual codebase reality. +Find false positives (checked but not done) and false negatives (done but unchecked). +Interactive workflow with options to update, audit, or review. + + + +**Evidence-Based Verification** + +Checkboxes lie. Code doesn't. +- Search codebase for implementation evidence +- Check for stubs, TODOs, empty functions +- Verify tests exist for claimed features +- Report accuracy of story completion claims + + + +name: gap-analysis +version: 3.0.0 + +defaults: + auto_update: false + create_audit_report: true + strict_mode: false # If true, stubs count as incomplete + +output: + update_story: "Modify checkbox state to match reality" + audit_report: "Generate detailed gap analysis document" + no_changes: "Display results only" + + + +@patterns/verification.md +@patterns/hospital-grade.md + + + + + +**Load and parse story file** + +```bash +STORY_FILE="{{story_file}}" +[ -f "$STORY_FILE" ] || { echo "❌ story_file required"; exit 1; } +``` + +Use Read tool on story file. Extract: +- All `- [ ]` and `- [x]` items +- File references from Dev Agent Record +- Task descriptions with expected artifacts + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” GAP ANALYSIS: {{story_key}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Tasks: {{total_tasks}} +Currently checked: {{checked_count}} +``` + + + +**Verify each task against codebase** + +For each task item: + +1. **Extract artifacts** - File names, component names, function names +2. **Search codebase:** + ```bash + # Check file exists + Glob: {{expected_file}} + + # Check function/component exists + Grep: "{{function_or_component_name}}" + ``` + +3. **If file exists, check quality:** + ```bash + # Check for stubs + Grep: "TODO|FIXME|Not implemented|throw new Error" {{file}} + + # Check for tests + Glob: {{file_base}}.test.* OR {{file_base}}.spec.* + ``` + +4. **Determine status:** + - **VERIFIED:** File exists, not a stub, tests exist + - **PARTIAL:** File exists but stub/TODO or no tests + - **MISSING:** File does not exist + + + +**Compare claimed vs actual** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“Š GAP ANALYSIS RESULTS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Tasks analyzed: {{total}} + +By Status: +- βœ… Verified Complete: {{verified}} ({{verified_pct}}%) +- ⚠️ Partial: {{partial}} ({{partial_pct}}%) +- ❌ Missing: {{missing}} ({{missing_pct}}%) + +Accuracy Analysis: +- Checked & Verified: {{correct_checked}} +- Checked but MISSING: {{false_positives}} ← FALSE POSITIVES +- Unchecked but DONE: {{false_negatives}} ← FALSE NEGATIVES + +Checkbox Accuracy: {{accuracy}}% +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**If false positives found:** +``` +⚠️ FALSE POSITIVES DETECTED +The following tasks are marked done but code is missing: + +{{#each false_positives}} +- [ ] {{task}} β€” Expected: {{expected_file}} β€” ❌ NOT FOUND +{{/each}} +``` + + + +**Ask user how to proceed** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“‹ OPTIONS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[U] Update - Fix checkboxes to match reality +[A] Audit Report - Generate detailed report file +[N] No Changes - Display only (already done) +[R] Review Details - Show full evidence for each task + +Your choice: +``` + + + +**Update story file checkboxes** + +For false positives: +- Change `[x]` to `[ ]` for tasks with missing code + +For false negatives: +- Change `[ ]` to `[x]` for tasks with verified code + +Use Edit tool to make changes. + +``` +βœ… Story checkboxes updated +- {{fp_count}} false positives unchecked +- {{fn_count}} false negatives checked +- New completion: {{new_pct}}% +``` + + + +**Generate audit report** + +Write to: `{{story_dir}}/gap-analysis-{{story_key}}-{{timestamp}}.md` + +Include: +- Executive summary +- Detailed task-by-task evidence +- False positive/negative lists +- Recommendations + +``` +βœ… Audit report generated: {{report_path}} +``` + + + +**Show detailed evidence** + +For each task: +``` +Task: {{task_text}} +Checkbox: {{checked_state}} +Evidence: + - File: {{file}} - {{exists ? "βœ… EXISTS" : "❌ MISSING"}} + {{#if exists}} + - Stub check: {{is_stub ? "⚠️ STUB DETECTED" : "βœ… Real implementation"}} + - Tests: {{has_tests ? "βœ… Tests exist" : "❌ No tests"}} + {{/if}} +Verdict: {{status}} +``` + +After review, return to options menu. + + + +**Display completion** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… GAP ANALYSIS COMPLETE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{story_key}} +Verified Completion: {{verified_pct}}% +Checkbox Accuracy: {{accuracy}}% + +{{#if updated}} +βœ… Checkboxes updated to match reality +{{/if}} + +{{#if report_generated}} +πŸ“„ Report: {{report_path}} +{{/if}} + +{{#if false_positives > 0}} +⚠️ {{false_positives}} tasks need implementation work +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + + + +```bash +# Quick gap analysis of single story +/gap-analysis story_file=docs/sprint-artifacts/2-5-auth.md + +# With auto-update enabled +/gap-analysis story_file=docs/sprint-artifacts/2-5-auth.md auto_update=true +``` + + + +**Story file not found:** HALT with clear error. +**Search fails:** Log warning, count as MISSING. +**Edit fails:** Report error, suggest manual update. + + + +- [ ] All tasks verified against codebase +- [ ] False positives/negatives identified +- [ ] Accuracy metrics calculated +- [ ] User choice executed (update/audit/review) + diff --git a/src/bmm/workflows/4-implementation/gap-analysis/workflow.yaml b/src/bmm/workflows/4-implementation/gap-analysis/workflow.yaml index 88417f98..07eea0a2 100644 --- a/src/bmm/workflows/4-implementation/gap-analysis/workflow.yaml +++ b/src/bmm/workflows/4-implementation/gap-analysis/workflow.yaml @@ -11,7 +11,7 @@ story_dir: "{implementation_artifacts}" # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/gap-analysis" -instructions: "{installed_path}/instructions.xml" +instructions: "{installed_path}/workflow.md" # Variables story_file: "" # User provides story file path or auto-discover diff --git a/src/bmm/workflows/4-implementation/migrate-to-github/instructions.md b/src/bmm/workflows/4-implementation/migrate-to-github/instructions.md deleted file mode 100644 index d3ccab25..00000000 --- a/src/bmm/workflows/4-implementation/migrate-to-github/instructions.md +++ /dev/null @@ -1,957 +0,0 @@ -# Migrate to GitHub - Production-Grade Story Migration - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml -RELIABILITY FIRST: This workflow prioritizes data integrity over speed - - - - - MUST verify all prerequisites before ANY migration operations - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ›‘οΈ PRE-FLIGHT SAFETY CHECKS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - Test GitHub MCP connection: - Call: mcp__github__get_me() - - - -❌ CRITICAL: GitHub MCP not accessible - -Cannot proceed with migration without GitHub API access. - -Possible causes: -- GitHub MCP server not configured -- Authentication token missing or invalid -- Network connectivity issues - -Fix: -1. Ensure GitHub MCP is configured in Claude settings -2. Verify token has required permissions: - - repo (full control) - - write:discussion (for comments) -3. Test connection: Try any GitHub MCP command - -HALTING - Cannot migrate without GitHub access. - - HALT - - - Extract current user info: - - username: {{user.login}} - - user_id: {{user.id}} - - βœ… GitHub MCP connected (@{{username}}) - - - - Verify github_owner and github_repo parameters provided - - - -❌ ERROR: GitHub repository not specified - -Required parameters: - github_owner: GitHub username or organization - github_repo: Repository name - -Usage: - /migrate-to-github github_owner=jschulte github_repo=myproject - /migrate-to-github github_owner=jschulte github_repo=myproject mode=execute - -HALTING - - HALT - - - Test repository access: - Call: mcp__github__list_issues({ - owner: {{github_owner}}, - repo: {{github_repo}}, - per_page: 1 - }) - - - -❌ CRITICAL: Cannot access repository {{github_owner}}/{{github_repo}} - -Possible causes: -- Repository doesn't exist -- Token lacks access to this repository -- Repository is private and token doesn't have permission - -Verify: -1. Repository exists: -2. Token has write access to issues -3. Repository name is spelled correctly - -HALTING - - HALT - - - βœ… Repository accessible ({{github_owner}}/{{github_repo}}) - - - - Check sprint-status.yaml exists: - test -f {{sprint_status}} - - - -❌ ERROR: sprint-status.yaml not found at {{sprint_status}} - -Cannot migrate without sprint status file. - -Run /sprint-planning to generate it first. - -HALTING - - HALT - - - Read and parse sprint-status.yaml - Count total stories to migrate - - βœ… Found {{total_stories}} stories in sprint-status.yaml - - Verify story files exist: - For each story, try multiple naming patterns to find file - - Report: - -πŸ“Š Story File Status: -- βœ… Files found: {{stories_with_files}} -- ❌ Files missing: {{stories_without_files}} -{{#if stories_without_files > 0}} - Missing: {{missing_story_keys}} -{{/if}} - - - - -⚠️ {{stories_without_files}} stories have no files - -Options: -[C] Continue (only migrate stories with files) -[S] Skip these stories (add to skip list) -[H] Halt (fix missing files first) - -Choice: - - - - HALT - - - - - - Check if state file exists: {{state_file}} - - - Read migration state - Extract: stories_migrated, issues_created, last_completed, timestamp - - -⚠️ Previous migration detected - -Last migration: -- Date: {{migration_timestamp}} -- Stories migrated: {{stories_migrated.length}} -- Issues created: {{issues_created.length}} -- Last completed: {{last_completed}} -- Status: {{migration_status}} - -Options: -[R] Resume (continue from where it left off) -[F] Fresh (start over, may create duplicates if not careful) -[V] View (show what was migrated) -[D] Delete state (clear and start fresh) - -Choice: - - - How to proceed? - - - Set resume_mode = true - Load list of already-migrated stories - Filter them out from migration queue - βœ… Resuming from story: {{last_completed}} - - - - ⚠️ WARNING: Fresh start may create duplicate issues if stories were already migrated. - Confirm fresh start (will check for duplicates)? (yes/no): - - HALT - - - - - Display migration state details - Then re-prompt for choice - - - - Delete state file - Set resume_mode = false - βœ… State cleared - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… PRE-FLIGHT CHECKS PASSED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- GitHub MCP: Connected -- Repository: Accessible -- Sprint status: Loaded ({{total_stories}} stories) -- Story files: {{stories_with_files}} found -- Mode: {{mode}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - Skip to Step 2 (Execute mode) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” DRY-RUN MODE (Preview Only - No Changes) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -This will show what WOULD happen without actually creating issues. -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each story in sprint-status.yaml: - - For each story_key: - - - Search GitHub: mcp__github__search_issues({ - query: "repo:{{github_owner}}/{{github_repo}} label:story:{{story_key}}" - }) - - - would_update = {{update_existing}} - -πŸ“ Story {{story_key}}: - GitHub: Issue #{{existing_issue.number}} EXISTS - Action: {{#if would_update}}Would UPDATE{{else}}Would SKIP{{/if}} - Current labels: {{existing_issue.labels}} - Current assignee: {{existing_issue.assignee || "none"}} - - - - - would_create = true - Read local story file - Parse: title, ACs, tasks, epic, status - - -πŸ“ Story {{story_key}}: - GitHub: NOT FOUND - Action: Would CREATE - - Proposed Issue: - - Title: "Story {{story_key}}: {{parsed_title}}" - - Labels: type:story, story:{{story_key}}, status:{{status}}, epic:{{epic_number}}, complexity:{{complexity}} - - Milestone: Epic {{epic_number}} - - Acceptance Criteria: {{ac_count}} items - - Tasks: {{task_count}} items - - Assignee: {{#if status == 'in-progress'}}@{{infer_from_git_log}}{{else}}none{{/if}} - - - - - Count actions: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š DRY-RUN SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total Stories:** {{total_stories}} - -**Actions:** -- βœ… Would CREATE: {{would_create_count}} new issues -- πŸ”„ Would UPDATE: {{would_update_count}} existing issues -- ⏭️ Would SKIP: {{would_skip_count}} (existing, no update) - -**Epics/Milestones:** -- Would CREATE: {{epic_milestones_to_create.length}} milestones -- Already exist: {{epic_milestones_existing.length}} - -**Estimated API Calls:** -- Issue searches: {{total_stories}} (check existing) -- Issue creates: {{would_create_count}} -- Issue updates: {{would_update_count}} -- Milestone operations: {{milestone_operations}} -- **Total:** ~{{total_api_calls}} API calls - -**Rate Limit Impact:** -- Authenticated limit: 5000/hour -- This migration: ~{{total_api_calls}} calls -- Remaining after: ~{{5000 - total_api_calls}} -- Safe: {{#if total_api_calls < 1000}}YES{{else}}Borderline (consider smaller batches){{/if}} - -**Estimated Duration:** {{estimated_minutes}} minutes - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -⚠️ This was a DRY-RUN. No issues were created. - -To execute the migration: - /migrate-to-github mode=execute github_owner={{github_owner}} github_repo={{github_repo}} - -To migrate only Epic 2: - /migrate-to-github mode=execute filter_by_epic=2 github_owner={{github_owner}} github_repo={{github_repo}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Exit workflow (dry-run complete) - - - - - Skip to Step 3 (Verify mode) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -⚑ EXECUTE MODE (Migrating Stories to GitHub) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**SAFETY GUARANTEES:** -βœ… Idempotent - Can re-run safely (checks for duplicates) -βœ… Atomic - Each story fully succeeds or rolls back -βœ… Verified - Reads back each created issue -βœ… Resumable - Saves state after each story -βœ… Reversible - Creates rollback manifest -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - -⚠️ FINAL CONFIRMATION - -You are about to create ~{{would_create_count}} GitHub Issues. - -This operation: -- WILL create issues in {{github_owner}}/{{github_repo}} -- WILL modify your GitHub repository -- CAN be rolled back (we'll create rollback manifest) -- CANNOT be undone automatically after issues are created - -Have you: -- [ ] Run dry-run mode to preview? -- [ ] Verified repository is correct? -- [ ] Backed up sprint-status.yaml? -- [ ] Confirmed you want to proceed? - -Type "I understand and want to proceed" to continue: - - - - ❌ Migration cancelled - confirmation not received - HALT - - - Initialize migration state: - -migration_state = { - started_at: {{timestamp}}, - mode: "execute", - github_owner: {{github_owner}}, - github_repo: {{github_repo}}, - total_stories: {{total_stories}}, - stories_migrated: [], - issues_created: [], - issues_updated: [], - issues_failed: [], - rollback_manifest: [], - last_completed: null -} - - - Save initial state to {{state_file}} - - Initialize rollback manifest (for safety): - rollback_manifest = { - created_at: {{timestamp}}, - github_owner: {{github_owner}}, - github_repo: {{github_repo}}, - created_issues: [] # Will track issue numbers for rollback - } - - For each story in sprint-status.yaml: - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“¦ Migrating {{current_index}}/{{total_stories}}: {{story_key}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Read local story file - - - ⏭️ SKIP - No file found - Add to migration_state.issues_failed with reason: "File not found" - Continue to next story - - - Parse story file: - - Extract all 12 sections - - Parse Acceptance Criteria (convert to checkboxes) - - Parse Tasks (convert to checkboxes) - - Extract metadata: epic_number, complexity - - Check if issue already exists (idempotent check): - Call: mcp__github__search_issues({ - query: "repo:{{github_owner}}/{{github_repo}} label:story:{{story_key}}" - }) - - - βœ… EXISTS - Issue #{{existing_issue.number}} (skipping, update_existing=false) - Add to migration_state.stories_migrated (already done) - Continue to next story - - - - πŸ”„ EXISTS - Issue #{{existing_issue.number}} (updating) - - ATOMIC UPDATE with retry: - -attempt = 0 -max_attempts = {{max_retries}} + 1 - -WHILE attempt < max_attempts: - TRY: - # Update issue - result = mcp__github__issue_write({ - method: "update", - owner: {{github_owner}}, - repo: {{github_repo}}, - issue_number: {{existing_issue.number}}, - title: "Story {{story_key}}: {{parsed_title}}", - body: {{convertStoryToIssueBody(parsed)}}, - labels: {{generateLabels(story_key, status, parsed)}} - }) - - # Verify update succeeded (read back) - sleep 1 second # GitHub eventual consistency - - verification = mcp__github__issue_read({ - method: "get", - owner: {{github_owner}}, - repo: {{github_repo}}, - issue_number: {{existing_issue.number}} - }) - - # Check verification - IF verification.title != expected_title: - THROW "Write verification failed" - - # Success! - output: " βœ… UPDATED and VERIFIED - Issue #{{existing_issue.number}}" - BREAK - - CATCH error: - attempt++ - IF attempt < max_attempts: - sleep {{retry_backoff_ms[attempt]}} - output: " ⚠️ Retry {{attempt}}/{{max_retries}} after error: {{error}}" - ELSE: - output: " ❌ FAILED after {{max_retries}} retries: {{error}}" - add to migration_state.issues_failed - - IF halt_on_critical_error: - HALT - ELSE: - CONTINUE to next story - - - Add to migration_state.issues_updated - - - - πŸ†• CREATING new issue... - - Generate issue body from story file: - -issue_body = """ -**Story File:** [{{story_key}}.md]({{file_path_in_repo}}) -**Epic:** {{epic_number}} -**Complexity:** {{complexity}} ({{task_count}} tasks) - -## Business Context -{{parsed.businessContext}} - -## Acceptance Criteria -{{#each parsed.acceptanceCriteria}} -- [ ] AC{{@index + 1}}: {{this}} -{{/each}} - -## Tasks -{{#each parsed.tasks}} -- [ ] {{this}} -{{/each}} - -## Technical Requirements -{{parsed.technicalRequirements}} - -## Definition of Done -{{#each parsed.definitionOfDone}} -- [ ] {{this}} -{{/each}} - ---- -_Migrated from BMAD local files_ -_Sync timestamp: {{timestamp}}_ -_Local file: `{{story_file_path}}`_ -""" - - - Generate labels: - -labels = [ - "type:story", - "story:{{story_key}}", - "status:{{current_status}}", - "epic:{{epic_number}}", - "complexity:{{complexity}}" -] - -{{#if has_high_risk_keywords}} -labels.push("risk:high") -{{/if}} - - - ATOMIC CREATE with retry and verification: - -attempt = 0 - -WHILE attempt < max_attempts: - TRY: - # Create issue - created_issue = mcp__github__issue_write({ - method: "create", - owner: {{github_owner}}, - repo: {{github_repo}}, - title: "Story {{story_key}}: {{parsed_title}}", - body: {{issue_body}}, - labels: {{labels}} - }) - - issue_number = created_issue.number - - # CRITICAL: Verify creation succeeded (read back) - sleep 2 seconds # GitHub eventual consistency - - verification = mcp__github__issue_read({ - method: "get", - owner: {{github_owner}}, - repo: {{github_repo}}, - issue_number: {{issue_number}} - }) - - # Verify all fields - IF verification.title != expected_title: - THROW "Title mismatch after create" - - IF NOT verification.labels.includes("story:{{story_key}}"): - THROW "Story label missing after create" - - # Success - record for rollback capability - output: " βœ… CREATED and VERIFIED - Issue #{{issue_number}}" - - rollback_manifest.created_issues.push({ - story_key: {{story_key}}, - issue_number: {{issue_number}}, - created_at: {{timestamp}} - }) - - migration_state.issues_created.push({ - story_key: {{story_key}}, - issue_number: {{issue_number}} - }) - - BREAK - - CATCH error: - attempt++ - - # Check if issue was created despite error (orphaned issue) - check_result = mcp__github__search_issues({ - query: "repo:{{github_owner}}/{{github_repo}} label:story:{{story_key}}" - }) - - IF check_result.length > 0: - # Issue was created, verification failed - treat as success - output: " βœ… CREATED (verification had transient error)" - BREAK - - IF attempt < max_attempts: - sleep {{retry_backoff_ms[attempt]}} - output: " ⚠️ Retry {{attempt}}/{{max_retries}}" - ELSE: - output: " ❌ FAILED after {{max_retries}} retries: {{error}}" - - migration_state.issues_failed.push({ - story_key: {{story_key}}, - error: {{error}}, - attempts: {{attempt}} - }) - - IF halt_on_critical_error: - output: "HALTING - Critical error during migration" - save migration_state - HALT - ELSE: - output: "Continuing despite failure (continue_on_failure=true)" - CONTINUE to next story - - - - Update migration state: - migration_state.stories_migrated.push({{story_key}}) - migration_state.last_completed = {{story_key}} - - - Save migration state to {{state_file}} - Save rollback manifest to {{output_folder}}/migration-rollback-{{timestamp}}.yaml - - - - -πŸ“Š Progress: {{current_index}}/{{total_stories}} migrated - Created: {{issues_created.length}} - Updated: {{issues_updated.length}} - Failed: {{issues_failed.length}} - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… MIGRATION COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total:** {{total_stories}} stories processed -**Created:** {{issues_created.length}} new issues -**Updated:** {{issues_updated.length}} existing issues -**Failed:** {{issues_failed.length}} errors -**Duration:** {{actual_duration}} - -{{#if issues_failed.length > 0}} -**Failed Stories:** -{{#each issues_failed}} - - {{story_key}}: {{error}} -{{/each}} - -Recommendation: Fix errors and re-run migration (will skip already-migrated stories) -{{/if}} - -**Rollback Manifest:** {{rollback_manifest_path}} -(Use this file to delete created issues if needed) - -**State File:** {{state_file}} -(Tracks migration progress for resume capability) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Continue to Step 3 (Verify) - - - - - Skip to Step 4 - - - - -Migration complete. Run verification to double-check accuracy? (yes/no): - - - - Skip to Step 5 (Report) - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” VERIFICATION MODE (Double-Checking Migration) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Load migration state from {{state_file}} - - For each migrated story in migration_state.stories_migrated: - - Fetch issue from GitHub: - Search: label:story:{{story_key}} - - - ❌ VERIFICATION FAILED: {{story_key}} - Issue not found in GitHub - Add to verification_failures - - - - Verify fields match expected: - - Title contains story_key βœ“ - - Label "story:{{story_key}}" exists βœ“ - - Status label matches sprint-status.yaml βœ“ - - AC count matches local file βœ“ - - - βœ… VERIFIED: {{story_key}} β†’ Issue #{{issue_number}} - - - - ⚠️ MISMATCH: {{story_key}} β†’ Issue #{{issue_number}} - Expected: {{expected}} - Actual: {{actual}} - Add to verification_warnings - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š VERIFICATION RESULTS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories Checked:** {{stories_migrated.length}} -**βœ… Verified Correct:** {{verified_count}} -**⚠️ Warnings:** {{verification_warnings.length}} -**❌ Failures:** {{verification_failures.length}} - -{{#if verification_failures.length > 0}} -**Verification Failures:** -{{#each verification_failures}} - - {{this}} -{{/each}} - -❌ Migration has errors - issues may be missing or incorrect -{{else}} -βœ… All migrated stories verified in GitHub -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - Skip to Step 5 (Report) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -⚠️ ROLLBACK MODE (Delete Migrated Issues) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Load rollback manifest from {{output_folder}}/migration-rollback-*.yaml - - - -❌ ERROR: No rollback manifest found - -Cannot rollback without manifest file. -Rollback manifests are in: {{output_folder}}/migration-rollback-*.yaml - -HALTING - - HALT - - - -**Rollback Manifest:** -- Created: {{manifest.created_at}} -- Repository: {{manifest.github_owner}}/{{manifest.github_repo}} -- Issues to delete: {{manifest.created_issues.length}} - -**WARNING:** This will PERMANENTLY DELETE these issues from GitHub: -{{#each manifest.created_issues}} - - Issue #{{issue_number}}: {{story_key}} -{{/each}} - -This operation CANNOT be undone! - - - -Type "DELETE ALL ISSUES" to proceed with rollback: - - - - ❌ Rollback cancelled - HALT - - - For each issue in manifest.created_issues: - - Delete issue (GitHub API doesn't support delete, so close + lock): - -# GitHub doesn't allow issue deletion via API -# Best we can do: close, lock, and add label "migrated:rolled-back" - -mcp__github__issue_write({ - method: "update", - issue_number: {{issue_number}}, - state: "closed", - labels: ["migrated:rolled-back", "do-not-use"], - state_reason: "not_planned" -}) - -# Add comment explaining -mcp__github__add_issue_comment({ - issue_number: {{issue_number}}, - body: "Issue closed - migration was rolled back. Do not use." -}) - - - βœ… Rolled back: Issue #{{issue_number}} - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… ROLLBACK COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Issues Rolled Back:** {{manifest.created_issues.length}} - -Note: GitHub API doesn't support issue deletion. -Issues were closed with label "migrated:rolled-back" instead. - -To fully delete (manual): -1. Go to repository settings -2. Issues β†’ Delete closed issues -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Calculate final statistics: - -final_stats = { - total_stories: {{total_stories}}, - migrated_successfully: {{issues_created.length + issues_updated.length}}, - failed: {{issues_failed.length}}, - success_rate: ({{migrated_successfully}} / {{total_stories}}) * 100, - duration: {{end_time - start_time}}, - avg_time_per_story: {{duration / total_stories}} -} - - - - Write comprehensive report to {{report_path}} - - Report structure: - -# GitHub Migration Report - -**Date:** {{timestamp}} -**Repository:** {{github_owner}}/{{github_repo}} -**Mode:** {{mode}} - -## Executive Summary - -- **Total Stories:** {{total_stories}} -- **βœ… Migrated:** {{migrated_successfully}} ({{success_rate}}%) -- **❌ Failed:** {{failed}} -- **Duration:** {{duration}} -- **Avg per story:** {{avg_time_per_story}} - -## Created Issues - -{{#each issues_created}} -- Story {{story_key}} β†’ Issue #{{issue_number}} - URL: -{{/each}} - -## Updated Issues - -{{#each issues_updated}} -- Story {{story_key}} β†’ Issue #{{issue_number}} (updated) -{{/each}} - -## Failed Migrations - -{{#if issues_failed.length > 0}} -{{#each issues_failed}} -- Story {{story_key}}: {{error}} - Attempts: {{attempts}} -{{/each}} - -**Recovery Steps:** -1. Fix underlying issues (check error messages) -2. Re-run migration (will skip already-migrated stories) -{{else}} -None - all stories migrated successfully! -{{/if}} - -## Rollback Information - -**Rollback Manifest:** {{rollback_manifest_path}} - -To rollback this migration: -```bash -/migrate-to-github mode=rollback -``` - -## Next Steps - -1. **Verify migration:** /migrate-to-github mode=verify -2. **Test story checkout:** /checkout-story story_key=2-5-auth -3. **Enable GitHub sync:** Update workflow.yaml with github_sync_enabled=true -4. **Product Owner setup:** Share GitHub Issues URL with PO team - -## Migration Details - -**API Calls Made:** ~{{total_api_calls}} -**Rate Limit Used:** {{api_calls_used}}/5000 -**Errors Encountered:** {{error_count}} -**Retries Performed:** {{retry_count}} - ---- -_Generated by BMAD migrate-to-github workflow_ - - - πŸ“„ Migration report: {{report_path}} - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… MIGRATION WORKFLOW COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Mode:** {{mode}} -**Success Rate:** {{success_rate}}% - -{{#if mode == 'execute'}} -**βœ… {{migrated_successfully}} stories now in GitHub Issues** - -View in GitHub: - - -**Next Steps:** -1. Verify migration: /migrate-to-github mode=verify -2. Test workflows with GitHub sync enabled -3. Share Issues URL with Product Owner team - -{{#if issues_failed.length > 0}} -⚠️ {{issues_failed.length}} stories failed - re-run to retry -{{/if}} -{{/if}} - -{{#if mode == 'dry-run'}} -**This was a preview. No issues were created.** - -To execute: /migrate-to-github mode=execute -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - diff --git a/src/bmm/workflows/4-implementation/multi-agent-review/instructions.md b/src/bmm/workflows/4-implementation/multi-agent-review/instructions.md deleted file mode 100644 index bb51d72c..00000000 --- a/src/bmm/workflows/4-implementation/multi-agent-review/instructions.md +++ /dev/null @@ -1,188 +0,0 @@ -# Multi-Agent Code Review - -**Purpose:** Perform unbiased code review using multiple specialized AI agents in FRESH CONTEXT, with agent count based on story complexity. - -## Overview - -**Key Principle: FRESH CONTEXT** -- Review happens in NEW session (not the agent that wrote the code) -- Prevents bias from implementation decisions -- Provides truly independent perspective - -**Variable Agent Count by Complexity:** -- **MICRO** (2 agents): Security + Code Quality - Quick sanity check -- **STANDARD** (4 agents): + Architecture + Testing - Balanced review -- **COMPLEX** (6 agents): + Performance + Domain Expert - Comprehensive analysis - -**Available Specialized Agents:** -- **Security Agent**: Identifies vulnerabilities and security risks -- **Code Quality Agent**: Reviews style, maintainability, and best practices -- **Architecture Agent**: Reviews system design, patterns, and structure -- **Testing Agent**: Evaluates test coverage and quality -- **Performance Agent**: Analyzes efficiency and optimization opportunities -- **Domain Expert**: Validates business logic and domain constraints - -## Workflow - -### Step 1: Determine Agent Count - -Based on {complexity_level}: - -``` -If complexity_level == "micro": - agent_count = 2 - agents = ["security", "code_quality"] - Display: πŸ” MICRO Review (2 agents: Security + Code Quality) - -Else if complexity_level == "standard": - agent_count = 4 - agents = ["security", "code_quality", "architecture", "testing"] - Display: πŸ“‹ STANDARD Review (4 agents: Multi-perspective) - -Else if complexity_level == "complex": - agent_count = 6 - agents = ["security", "code_quality", "architecture", "testing", "performance", "domain_expert"] - Display: πŸ”¬ COMPLEX Review (6 agents: Comprehensive analysis) -``` - -### Step 2: Load Story Context - -```bash -# Read story file -story_file="{story_file}" -test -f "$story_file" || (echo "❌ Story file not found: $story_file" && exit 1) -``` - -Read the story file to understand: -- What was supposed to be implemented -- Acceptance criteria -- Tasks and subtasks -- File list - -### Step 3: Invoke Multi-Agent Review Skill (Fresh Context + Smart Agent Selection) - -**CRITICAL:** This review MUST happen in a FRESH CONTEXT (new session, different agent). - -**Smart Agent Selection:** -- Skill analyzes changed files and selects MOST RELEVANT agents -- Touching payments code? β†’ Add financial-security agent -- Touching auth code? β†’ Add auth-security agent -- Touching file uploads? β†’ Add file-security agent -- Touching performance-critical code? β†’ Add performance agent -- Agent count determined by complexity, but agents chosen by code analysis - -```xml - - {story_id} - {base_branch} - {agent_count} - smart - true - -``` - -The skill will: -1. Create fresh context (unbiased review session) -2. Analyze changed files in the story -3. Detect code categories (auth, payments, file handling, etc.) -4. Select {agent_count} MOST RELEVANT specialized agents -5. Run parallel reviews from selected agents -6. Each agent reviews from their expertise perspective -7. Aggregate findings with severity ratings -8. Return comprehensive review report - -### Step 3: Save Review Report - -```bash -# The skill returns a review report -# Save it to: {review_report} -``` - -Display summary: -``` -πŸ€– MULTI-AGENT CODE REVIEW COMPLETE - -Agents Used: {agent_count} -- Architecture Agent -- Security Agent -- Performance Agent -- Testing Agent -- Code Quality Agent - -Findings: -- πŸ”΄ CRITICAL: {critical_count} -- 🟠 HIGH: {high_count} -- 🟑 MEDIUM: {medium_count} -- πŸ”΅ LOW: {low_count} -- ℹ️ INFO: {info_count} - -Report saved to: {review_report} -``` - -### Step 4: Present Findings - -For each finding, display: -``` -[{severity}] {title} -Agent: {agent_name} -Location: {file}:{line} - -{description} - -Recommendation: -{recommendation} - ---- -``` - -### Step 5: Next Steps - -Suggest actions based on findings: -``` -πŸ“‹ RECOMMENDED NEXT STEPS: - -If CRITICAL findings exist: - ⚠️ MUST FIX before proceeding - - Address all critical security/correctness issues - - Re-run review after fixes - -If only HIGH/MEDIUM findings: - βœ… Story may proceed - - Consider addressing high-priority items - - Create follow-up tasks for medium items - - Document LOW items as tech debt - -If only LOW/INFO findings: - βœ… Code quality looks good - - Optional: Address style/optimization suggestions - - Proceed to completion -``` - -## Integration with Super-Dev-Pipeline - -This workflow is designed to be called from super-dev-pipeline step 7 (code review) when the story complexity is COMPLEX or when user explicitly requests multi-agent review. - -**When to Use:** -- Complex stories (β‰₯16 tasks or high-risk keywords) -- Stories involving security-sensitive code -- Stories with significant architectural changes -- When single-agent review has been inconclusive -- User explicitly requests comprehensive review - -**When NOT to Use:** -- Micro stories (≀3 tasks) -- Standard stories with simple changes -- Stories that passed adversarial review cleanly - -## Output Files - -- `{review_report}`: Full review findings in markdown -- Integrated into story completion summary -- Referenced in audit trail - -## Error Handling - -If multi-agent-review skill fails: -- Fall back to adversarial code review -- Log the failure reason -- Continue pipeline with warning diff --git a/src/bmm/workflows/4-implementation/push-all/instructions.xml b/src/bmm/workflows/4-implementation/push-all/instructions.xml deleted file mode 100644 index 9e5b715d..00000000 --- a/src/bmm/workflows/4-implementation/push-all/instructions.xml +++ /dev/null @@ -1,549 +0,0 @@ - - The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml - You MUST have already loaded and processed: {installed_path}/workflow.yaml - Communicate all responses in {communication_language} - πŸ“ PUSH-ALL - Stage, commit, and push changes with comprehensive safety validation - - - ⚑ PARALLEL AGENT MODE: When {{target_files}} is provided: - - ONLY stage and commit the specified files - - Do NOT use `git add .` or `git add -A` - - Use `git add [specific files]` instead - - This prevents committing work from other parallel agents - - πŸ“‹ ALL FILES MODE: When {{target_files}} is empty: - - Stage ALL changes with `git add .` - - Original behavior for single-agent execution - - - - πŸ”„ **Analyzing Repository Changes** - - Scanning for changes to commit and push... - - - - Run git commands in parallel: - - git status - Show modified/added/deleted/untracked files - - git diff --stat - Show change statistics - - git log -1 --oneline - Show recent commit for message style - - git branch --show-current - Confirm current branch - - Parse git status output to identify: - - Modified files - - Added files - - Deleted files - - Untracked files - - Total insertion/deletion counts - - - - ℹ️ **No Changes to Commit** - - Working directory is clean. - Nothing to push. - - HALT - No work to do - - - - - πŸ”’ SAFETY CHECKS - Validate changes before committing - - Scan all changed files for dangerous patterns: - - **Secret Detection:** - Check for files matching secret patterns: - - .env*, *.key, *.pem, credentials.json, secrets.yaml - - id_rsa, *.p12, *.pfx, *.cer - - Any file containing: _API_KEY=, _SECRET=, _TOKEN= with real values (not placeholders) - - - Validate API keys are placeholders only: - βœ… Acceptable placeholders: - - API_KEY=your-api-key-here - - SECRET=placeholder - - TOKEN=xxx - - API_KEY=${{YOUR_KEY}} - - SECRET_KEY=<your-key> - - - ❌ BLOCK real keys: - - OPENAI_API_KEY=sk-proj-xxxxx (real OpenAI key) - - AWS_SECRET_KEY=AKIA... (real AWS key) - - STRIPE_API_KEY=sk_live_... (real Stripe key) - - Any key with recognizable provider prefix + actual value - - - **File Size Check:** - Check for files >10MB without Git LFS configuration - - **Build Artifacts:** - Check for unwanted directories/files that should be gitignored: - - node_modules/, dist/, build/, .next/, __pycache__/, *.pyc, .venv/ - - .DS_Store, Thumbs.db, *.swp, *.tmp, *.log (in root) - - *.class, target/, bin/ (Java) - - vendor/ (unless dependency managed) - - - **Git State:** - Verify: - - .gitignore exists and properly configured - - No unresolved merge conflicts - - Git repository initialized - - - - - 🚨 **DANGER: Secrets Detected!** - - The following sensitive data was found: - {{list_detected_secrets_with_files}} - - ❌ **BLOCKED:** Cannot commit secrets to version control. - - **Actions Required:** - 1. Move secrets to .env file (add to .gitignore) - 2. Use environment variables: process.env.API_KEY - 3. Remove secrets from tracked files: git rm --cached [file] - 4. Update code to load from environment - - **Example:** - ``` - // Before (UNSAFE): - const apiKey = 'sk-proj-xxxxx'; - - // After (SAFE): - const apiKey = process.env.OPENAI_API_KEY; - ``` - - Halting workflow for safety. - - HALT - Cannot proceed with secrets - - - - ⚠️ **Warning: Large Files Detected** - - Files >10MB found: - {{list_large_files_with_sizes}} - - **Recommendation:** Set up Git LFS - ``` - git lfs install - git lfs track "*.{file_extension}" - git add .gitattributes - ``` - - - Proceed with large files anyway? [y/n]: - - - Halting. Please configure Git LFS first. - HALT - - - - - ⚠️ **Warning: Build Artifacts Detected** - - These files should be in .gitignore: - {{list_build_artifacts}} - - **Update .gitignore:** - ``` - node_modules/ - dist/ - build/ - .DS_Store - ``` - - - Commit build artifacts anyway? [y/n]: - - - Halting. Update .gitignore and git rm --cached [files] - HALT - - - - - ⚠️ **Warning: Pushing to {{branch_name}}** - - You're committing directly to {{branch_name}}. - - **Recommendation:** Use feature branch workflow: - 1. git checkout -b feature/my-changes - 2. Make and commit changes - 3. git push -u origin feature/my-changes - 4. Create PR for review - - - Push directly to {{branch_name}}? [y/n]: - - - Halting. Create a feature branch instead. - HALT - - - - βœ… **Safety Checks Passed** - - All validations completed successfully. - - - - - - πŸ“Š **Changes Summary** - - **Files:** - - Modified: {{modified_count}} - - Added: {{added_count}} - - Deleted: {{deleted_count}} - - Untracked: {{untracked_count}} - **Total:** {{total_file_count}} files - - **Changes:** - - Insertions: +{{insertion_count}} lines - - Deletions: -{{deletion_count}} lines - - **Safety:** - {{if_all_safe}} - βœ… No secrets detected - βœ… No large files (or approved) - βœ… No build artifacts (or approved) - βœ… .gitignore configured - {{endif}} - - {{if_warnings_approved}} - ⚠️ Warnings acknowledged and approved - {{endif}} - - **Git:** - - Branch: {{current_branch}} - - Remote: origin/{{current_branch}} - - Last commit: {{last_commit_message}} - - --- - - **I will execute:** - 1. `git add .` - Stage all changes - 2. `git commit -m "[generated message]"` - Create commit - 3. `git push` - Push to remote - - - - **Proceed with commit and push?** - - Options: - [yes] - Proceed with commit and push - [no] - Cancel (leave changes unstaged) - [review] - Show detailed diff first - - - - Execute: git diff --stat - Execute: git diff | head -100 (show first 100 lines of changes) - - {{diff_output}} - - (Use 'git diff' to see full changes) - - After reviewing, proceed with commit and push? [yes/no]: - - - - ❌ **Push-All Cancelled** - - Changes remain unstaged. No git operations performed. - - You can: - - Review changes: git status, git diff - - Commit manually: git add [files] && git commit - - Discard changes: git checkout -- [files] - - HALT - User cancelled - - - - - - - πŸ“Ž **Targeted Commit Mode** (parallel agent safe) - - Staging only files from this story/task: - {{target_files}} - - Execute: git add {{target_files}} - Execute: git status - βœ… **Targeted Files Staged** - - Ready for commit ({{target_file_count}} files): - {{list_staged_files}} - - Note: Other uncommitted changes in repo are NOT included. - - - - - - Execute: git add . - Execute: git status - βœ… **All Changes Staged** - - Ready for commit: - {{list_staged_files}} - - - - - - πŸ“ COMMIT MESSAGE - Generate conventional commit format - - Analyze changes to determine commit type: - - feat: New features (new files with functionality) - - fix: Bug fixes (fixing broken functionality) - - docs: Documentation only (*.md, comments) - - style: Formatting, missing semicolons (no code change) - - refactor: Code restructuring (no feature/fix) - - test: Adding/updating tests - - chore: Tooling, configs, dependencies - - perf: Performance improvements - - Determine scope (optional): - - Component/feature name if changes focused on one area - - Omit if changes span multiple areas - - - Generate message summary (max 72 chars): - - Use imperative mood: "add feature" not "added feature" - - Lowercase except proper nouns - - No period at end - - - Generate message body (if changes >5 files): - - List key changes as bullet points - - Max 3-5 bullets - - Keep concise - - - Reference recent commits for style consistency - - πŸ“ **Generated Commit Message:** - - ``` - {{generated_commit_message}} - ``` - - Based on: - - {{commit_type}} commit type - - {{file_count}} files changed - - {{change_summary}} - - - **Use this commit message?** - - Options: - [yes] - Use generated message - [edit] - Let me write custom message - [cancel] - Cancel push-all (leave staged) - - - - Enter your commit message (use conventional commit format if possible): - Store user input as {{commit_message}} - βœ… Using custom commit message - - - - ❌ Push-all cancelled - - Changes remain staged. - Run: git reset to unstage - - HALT - - - - Use {{generated_commit_message}} as {{commit_message}} - - - - - Execute git commit with heredoc for multi-line message safety: - git commit -m "$(cat <<'EOF' -{{commit_message}} -EOF -)" - - - - ❌ **Commit Failed** - - Error: {{commit_error}} - - **Common Causes:** - - Pre-commit hooks failing (linting, tests) - - Missing git config (user.name, user.email) - - Locked files or permissions - - Empty commit (no actual changes) - - **Fix and try again:** - - Check pre-commit output - - Set git config: git config user.name "Your Name" - - Verify file permissions - - HALT - Fix errors before proceeding - - - Parse commit output for hash - βœ… **Commit Created** - - Commit: {{commit_hash}} - Message: {{commit_subject}} - - - - - πŸš€ **Pushing to Remote** - - Pushing {{current_branch}} to origin... - - - Execute: git push - - - - ⚠️ **Push Rejected - Remote Has New Commits** - - Remote branch has commits you don't have locally. - Attempting to rebase and retry... - - - Execute: git pull --rebase - - - ❌ **Merge Conflicts During Rebase** - - Conflicts found: - {{list_conflicted_files}} - - **Manual resolution required:** - 1. Resolve conflicts in listed files - 2. git add [resolved files] - 3. git rebase --continue - 4. git push - - Halting for manual conflict resolution. - - HALT - Resolve conflicts manually - - - Execute: git push - - - - ℹ️ **No Upstream Branch Set** - - First push to origin for this branch. - Setting upstream... - - - Execute: git push -u origin {{current_branch}} - - - - ❌ **Push to Protected Branch Blocked** - - Branch {{current_branch}} is protected on remote. - - **Use PR workflow instead:** - 1. Ensure you're on a feature branch - 2. Push feature branch: git push -u origin feature-branch - 3. Create PR for review - - Changes are committed locally but not pushed. - - HALT - Use PR workflow for protected branches - - - - ❌ **Authentication Failed** - - Git push requires authentication. - - **Fix authentication:** - - GitHub: Set up SSH key or Personal Access Token - - Check: git remote -v (verify remote URL) - - Docs: https://docs.github.com/authentication - - Changes are committed locally but not pushed. - - HALT - Fix authentication - - - - ❌ **Push Failed** - - Error: {{push_error}} - - Your changes are committed locally but not pushed to remote. - - **Troubleshoot:** - - Check network connection - - Verify remote exists: git remote -v - - Check permissions on remote repository - - Try manual push: git push - - Halting for manual resolution. - - HALT - Manual push required - - - - - βœ… **Successfully Pushed to Remote!** - - **Commit:** {{commit_hash}} - {{commit_subject}} - **Branch:** {{current_branch}} β†’ origin/{{current_branch}} - **Files changed:** {{file_count}} (+{{insertions}}, -{{deletions}}) - - --- - - Your changes are now on the remote repository. - - - Execute: git log -1 --oneline --decorate - - **Latest commit:** {{git_log_output}} - - - - - - πŸŽ‰ **Push-All Complete, {user_name}!** - - **Summary:** - - βœ… {{file_count}} files committed - - βœ… Pushed to origin/{{current_branch}} - - βœ… All safety checks passed - - **Commit Details:** - - Hash: {{commit_hash}} - - Message: {{commit_subject}} - - Changes: +{{insertions}}, -{{deletions}} - - **Next Steps:** - - Verify on remote (GitHub/GitLab/etc) - - Create PR if working on feature branch - - Notify team if appropriate - - **Git State:** - - Working directory: clean - - Branch: {{current_branch}} - - In sync with remote - - - - diff --git a/src/bmm/workflows/4-implementation/push-all/workflow.md b/src/bmm/workflows/4-implementation/push-all/workflow.md new file mode 100644 index 00000000..44637b79 --- /dev/null +++ b/src/bmm/workflows/4-implementation/push-all/workflow.md @@ -0,0 +1,366 @@ +# Push All v3.0 - Safe Git Staging, Commit, and Push + + +Safely stage, commit, and push changes with comprehensive validation. +Detects secrets, large files, build artifacts. Handles push failures gracefully. +Supports targeted mode for specific files (parallel agent coordination). + + + +**Safe by Default, No Surprises** + +- Validate BEFORE committing (secrets, size, artifacts) +- Show exactly what will be committed +- Handle push failures with recovery options +- Never force push without explicit confirmation + + + +name: push-all +version: 3.0.0 + +modes: + full: "Stage all changes (default)" + targeted: "Only stage specified files" + +defaults: + max_file_size_kb: 500 + check_secrets: true + check_build_artifacts: true + auto_push: false + allow_force_push: false + +secret_patterns: + - "AKIA[0-9A-Z]{16}" # AWS Access Key + - "sk-[a-zA-Z0-9]{48}" # OpenAI Key + - "ghp_[a-zA-Z0-9]{36}" # GitHub Personal Token + - "xox[baprs]-[a-zA-Z0-9-]+" # Slack Token + - "-----BEGIN.*PRIVATE KEY" # Private Keys + - "password\\s*=\\s*['\"][^'\"]{8,}" # Hardcoded passwords + +build_artifacts: + - "node_modules/" + - "dist/" + - "build/" + - ".next/" + - "*.min.js" + - "*.bundle.js" + + + +@patterns/hospital-grade.md + + + + + +**Verify git repository state** + +```bash +# Check we're in a git repo +git rev-parse --is-inside-work-tree || { echo "❌ Not a git repository"; exit 1; } + +# Get current branch +git branch --show-current + +# Check for uncommitted changes +git status --porcelain +``` + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“¦ PUSH-ALL: {{mode}} mode +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Branch: {{branch}} +Mode: {{mode}} +{{#if targeted}}Files: {{file_list}}{{/if}} +``` + +**If no changes:** +``` +βœ… Working directory clean - nothing to commit +``` +Exit successfully. + + + +**Identify files to be staged** + +**Full mode:** +```bash +git status --porcelain | awk '{print $2}' +``` + +**Targeted mode:** +Only include files specified in `target_files` parameter. + +**Categorize changes:** +- New files (A) +- Modified files (M) +- Deleted files (D) +- Renamed files (R) + + + +**Scan for secrets in staged content** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” SECRET SCAN +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +For each file to be staged: +```bash +# Check for secret patterns +Grep: "{{pattern}}" {{file}} +``` + +**If secrets found:** +``` +❌ POTENTIAL SECRETS DETECTED + +{{#each secrets}} +File: {{file}} +Line {{line}}: {{preview}} (pattern: {{pattern_name}}) +{{/each}} + +⚠️ BLOCKING COMMIT +Remove secrets before proceeding. + +Options: +[I] Ignore (I know what I'm doing) +[E] Exclude these files +[H] Halt +``` + +**If [I] selected:** Require explicit confirmation text. + + + +**Check for oversized files** + +```bash +# Find files larger than max_file_size_kb +find . -type f -size +{{max_file_size}}k -not -path "./.git/*" +``` + +**If large files found:** +``` +⚠️ LARGE FILES DETECTED + +{{#each large_files}} +- {{file}} ({{size_kb}}KB) +{{/each}} + +Options: +[I] Include anyway +[E] Exclude large files +[H] Halt +``` + + + +**Check for build artifacts** + +```bash +# Check if any staged files match artifact patterns +git status --porcelain | grep -E "{{artifact_pattern}}" +``` + +**If artifacts found:** +``` +⚠️ BUILD ARTIFACTS DETECTED + +{{#each artifacts}} +- {{file}} +{{/each}} + +These should typically be in .gitignore. + +Options: +[E] Exclude artifacts (recommended) +[I] Include anyway +[H] Halt +``` + + + +**Show what will be committed** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“‹ COMMIT PREVIEW +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Files to commit: {{count}} + +Added ({{added_count}}): +{{#each added}} + + {{file}} +{{/each}} + +Modified ({{modified_count}}): +{{#each modified}} + M {{file}} +{{/each}} + +Deleted ({{deleted_count}}): +{{#each deleted}} + - {{file}} +{{/each}} + +{{#if excluded}} +Excluded: {{excluded_count}} files +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + +**Generate or request commit message** + +**If commit_message provided:** Use it. + +**Otherwise, generate from changes:** +``` +Analyzing changes to generate commit message... + +Changes detected: +- {{summary_of_changes}} + +Suggested message: +"{{generated_message}}" + +[Y] Use this message +[E] Edit message +[C] Custom message +``` + +If user selects [C] or [E], prompt for message. + + + +**Stage and commit changes** + +```bash +# Stage files (targeted or full) +{{#if targeted}} +git add {{#each target_files}}{{this}} {{/each}} +{{else}} +git add -A +{{/if}} + +# Commit with message +git commit -m "{{commit_message}}" +``` + +**Verify commit:** +```bash +# Check commit was created +git log -1 --oneline +``` + +``` +βœ… Commit created: {{commit_hash}} +``` + + + +**Push to remote with error handling** + +```bash +git push origin {{branch}} +``` + +**If push fails:** + +**Case: Behind remote** +``` +⚠️ Push rejected - branch is behind remote + +Options: +[P] Pull and retry (git pull --rebase) +[F] Force push (DESTRUCTIVE - overwrites remote) +[H] Halt (commit preserved locally) +``` + +**Case: No upstream** +``` +⚠️ No upstream branch + +Setting upstream and pushing: +git push -u origin {{branch}} +``` + +**Case: Auth failure** +``` +❌ Authentication failed + +Check: +1. SSH key configured? +2. Token valid? +3. Repository access? +``` + +**Case: Protected branch** +``` +❌ Cannot push to protected branch + +Use pull request workflow instead: +gh pr create --title "{{commit_message}}" +``` + + + +**Display completion status** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… PUSH-ALL COMPLETE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Branch: {{branch}} +Commit: {{commit_hash}} +Files: {{file_count}} +{{#if pushed}} +Remote: βœ… Pushed to origin/{{branch}} +{{else}} +Remote: ⏸️ Not pushed (commit preserved locally) +{{/if}} + +{{#if excluded_count > 0}} +Excluded: {{excluded_count}} files (secrets/artifacts/size) +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + + + +```bash +# Stage all, commit, and push +/push-all commit_message="feat: add user authentication" auto_push=true + +# Targeted mode - only specific files +/push-all mode=targeted target_files="src/auth.ts,src/auth.test.ts" commit_message="fix: auth bug" + +# Dry run - see what would be committed +/push-all auto_push=false +``` + + + +**Secrets detected:** BLOCK commit, require explicit override. +**Large files:** Warn, allow exclude or include. +**Build artifacts:** Warn, recommend exclude. +**Push rejected:** Offer pull/rebase, force push (with confirmation), or halt. +**Auth failure:** Report, suggest troubleshooting. + + + +- [ ] Changes validated (secrets, size, artifacts) +- [ ] Files staged correctly +- [ ] Commit created with message +- [ ] Push successful (if requested) +- [ ] No unintended files included + diff --git a/src/bmm/workflows/4-implementation/push-all/workflow.yaml b/src/bmm/workflows/4-implementation/push-all/workflow.yaml index 1eedfe30..5875d911 100644 --- a/src/bmm/workflows/4-implementation/push-all/workflow.yaml +++ b/src/bmm/workflows/4-implementation/push-all/workflow.yaml @@ -9,7 +9,7 @@ communication_language: "{config_source}:communication_language" # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/push-all" -instructions: "{installed_path}/instructions.xml" +instructions: "{installed_path}/workflow.md" # Target files to commit (for parallel agent execution) # When empty/not provided: commits ALL changes (original behavior) diff --git a/src/bmm/workflows/4-implementation/recover-sprint-status/instructions.md b/src/bmm/workflows/4-implementation/recover-sprint-status/instructions.md deleted file mode 100644 index 7ec69cd7..00000000 --- a/src/bmm/workflows/4-implementation/recover-sprint-status/instructions.md +++ /dev/null @@ -1,306 +0,0 @@ -# Sprint Status Recovery - Instructions - -**Workflow:** recover-sprint-status -**Purpose:** Fix sprint-status.yaml when tracking has drifted for days/weeks - ---- - -## What This Workflow Does - -Analyzes multiple sources to rebuild accurate sprint-status.yaml: - -1. **Story File Quality** - Validates size (>=10KB), task lists, checkboxes -2. **Explicit Status: Fields** - Reads story Status: when present -3. **Git Commits** - Searches last 30 days for story references -4. **Autonomous Reports** - Checks .epic-*-completion-report.md files -5. **Task Completion Rate** - Analyzes checkbox completion in story files - -**Infers Status Based On:** -- Explicit Status: field (highest priority) -- Git commits referencing story (strong signal) -- Autonomous completion reports (very high confidence) -- Task checkbox completion rate (90%+ = done) -- File quality (poor quality prevents "done" marking) - ---- - -## Step 1: Run Recovery Analysis - -```bash -Execute: {recovery_script} --dry-run -``` - -**This will:** -- Analyze all story files (quality, tasks, status) -- Search git commits for completion evidence -- Check autonomous completion reports -- Infer status from all evidence -- Report recommendations with confidence levels - -**No changes** made in dry-run mode - just analysis. - ---- - -## Step 2: Review Recommendations - -**Check the output for:** - -### High Confidence Updates (Safe) -- Stories with explicit Status: fields -- Stories in autonomous completion reports -- Stories with 3+ git commits + 90%+ tasks complete - -### Medium Confidence Updates (Verify) -- Stories with 1-2 git commits -- Stories with 50-90% tasks complete -- Stories with file size >=10KB - -### Low Confidence Updates (Question) -- Stories with no Status: field, no commits -- Stories with file size <10KB -- Stories with <5 tasks total - ---- - -## Step 3: Choose Recovery Mode - -### Conservative Mode (Safest) -```bash -Execute: {recovery_script} --conservative -``` - -**Only updates:** -- High/very high confidence stories -- Explicit Status: fields honored -- Git commits with 3+ references -- Won't infer or guess - -**Best for:** Quick fixes, first-time recovery, risk-averse - ---- - -### Aggressive Mode (Thorough) -```bash -Execute: {recovery_script} --aggressive --dry-run # Preview first! -Execute: {recovery_script} --aggressive # Then apply -``` - -**Updates:** -- Medium+ confidence stories -- Infers from git commits (even 1 commit) -- Uses task completion rate -- Pre-fills brownfield checkboxes - -**Best for:** Major drift (30+ days), comprehensive recovery - ---- - -### Interactive Mode (Recommended) -```bash -Execute: {recovery_script} -``` - -**Process:** -1. Shows all recommendations -2. Groups by confidence level -3. Asks for confirmation before each batch -4. Allows selective application - -**Best for:** First-time use, learning the tool - ---- - -## Step 4: Validate Results - -```bash -Execute: ./scripts/sync-sprint-status.sh --validate -``` - -**Should show:** -- "βœ“ sprint-status.yaml is up to date!" (success) -- OR discrepancy count (if issues remain) - ---- - -## Step 5: Commit Changes - -```bash -git add docs/sprint-artifacts/sprint-status.yaml -git add .sprint-status-backups/ # Include backup for audit trail -git commit -m "fix(tracking): Recover sprint-status.yaml - {MODE} recovery" -``` - ---- - -## Recovery Scenarios - -### Scenario 1: Autonomous Epic Completed, Tracking Not Updated - -**Symptoms:** -- Autonomous completion report exists -- Git commits show work done -- sprint-status.yaml shows "in-progress" or "backlog" - -**Solution:** -```bash -{recovery_script} --aggressive -# Will find completion report, mark all stories done -``` - ---- - -### Scenario 2: Manual Work Over Past Week Not Tracked - -**Symptoms:** -- Story Status: fields updated to "done" -- sprint-status.yaml not synced -- Git commits exist - -**Solution:** -```bash -./scripts/sync-sprint-status.sh -# Standard sync (reads Status: fields) -``` - ---- - -### Scenario 3: Story Files Missing Status: Fields - -**Symptoms:** -- 100+ stories with no Status: field -- Some completed, some not -- No autonomous reports - -**Solution:** -```bash -{recovery_script} --aggressive --dry-run # Preview inference -# Review recommendations carefully -{recovery_script} --aggressive # Apply if satisfied -``` - ---- - -### Scenario 4: Complete Chaos (Mix of All Above) - -**Symptoms:** -- Some stories have Status:, some don't -- Autonomous reports for some epics -- Manual work on others -- sprint-status.yaml very outdated - -**Solution:** -```bash -# Step 1: Run recovery in dry-run -{recovery_script} --aggressive --dry-run - -# Step 2: Review /tmp/recovery_results.json - -# Step 3: Apply in conservative mode first (safest updates) -{recovery_script} --conservative - -# Step 4: Manually review remaining stories -# Update Status: fields for known completed work - -# Step 5: Run sync to catch manual updates -./scripts/sync-sprint-status.sh - -# Step 6: Final validation -./scripts/sync-sprint-status.sh --validate -``` - ---- - -## Quality Gates - -**Recovery script will DOWNGRADE status if:** -- Story file < 10KB (not properly detailed) -- Story file has < 5 tasks (incomplete story) -- No git commits found (no evidence of work) -- Explicit Status: contradicts other evidence - -**Recovery script will UPGRADE status if:** -- Autonomous completion report lists story as done -- 3+ git commits + 90%+ tasks checked -- Explicit Status: field says "done" - ---- - -## Post-Recovery Checklist - -After running recovery: - -- [ ] Run validation: `./scripts/sync-sprint-status.sh --validate` -- [ ] Review backup: Check `.sprint-status-backups/` for before state -- [ ] Check epic statuses: Verify epic-level status matches story completion -- [ ] Spot-check 5-10 stories: Confirm inferred status is accurate -- [ ] Commit changes: Add recovery to version control -- [ ] Document issues: Note why drift occurred, prevent recurrence - ---- - -## Preventing Future Drift - -**After recovery:** - -1. **Use workflows properly** - - `/create-story` - Adds to sprint-status.yaml automatically - - `/dev-story` - Updates both Status: and sprint-status.yaml - - Autonomous workflows - Now update tracking - -2. **Run sync regularly** - - Weekly: `pnpm sync:sprint-status:dry-run` (check health) - - After manual Status: updates: `pnpm sync:sprint-status` - -3. **CI/CD validation** (coming soon) - - Blocks PRs with out-of-sync tracking - - Forces sync before merge - ---- - -## Troubleshooting - -### "Recovery script shows 0 updates" - -**Possible causes:** -- sprint-status.yaml already accurate -- Story files all have proper Status: fields -- No git commits found (check date range) - -**Action:** Run `--dry-run` to see analysis, check `/tmp/recovery_results.json` - ---- - -### "Low confidence on stories I know are done" - -**Possible causes:** -- Story file < 10KB (not properly detailed) -- No git commits (work done outside git) -- No explicit Status: field - -**Action:** Manually add Status: field to story, then run standard sync - ---- - -### "Recovery marks incomplete stories as done" - -**Possible causes:** -- Git commits exist but work abandoned -- Autonomous report lists story but implementation failed -- Tasks pre-checked incorrectly (brownfield error) - -**Action:** Use conservative mode, manually verify, fix story files - ---- - -## Output Files - -**Created during recovery:** -- `.sprint-status-backups/sprint-status-recovery-{timestamp}.yaml` - Backup -- `/tmp/recovery_results.json` - Detailed analysis -- Updated `sprint-status.yaml` - Recovered status - ---- - -**Last Updated:** 2026-01-02 -**Status:** Production Ready -**Works On:** ANY BMAD project with sprint-status.yaml tracking diff --git a/src/bmm/workflows/4-implementation/revalidate-epic/instructions.md b/src/bmm/workflows/4-implementation/revalidate-epic/instructions.md deleted file mode 100644 index e229e944..00000000 --- a/src/bmm/workflows/4-implementation/revalidate-epic/instructions.md +++ /dev/null @@ -1,273 +0,0 @@ -# Revalidate Epic - Batch Story Revalidation with Semaphore Pattern - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml - - - - - Verify epic_number parameter provided - - - ❌ ERROR: epic_number parameter required - -Usage: - /revalidate-epic epic_number=2 - /revalidate-epic epic_number=2 fill_gaps=true - /revalidate-epic epic_number=2 fill_gaps=true max_concurrent=5 - - HALT - - - Read {sprint_status} file - Parse development_status map - - Filter stories starting with "{{epic_number}}-" (e.g., "2-1-", "2-2-", etc.) - Exclude epics (keys starting with "epic-") and retrospectives - - Store as: epic_stories (list of story keys) - - - ❌ No stories found for Epic {{epic_number}} - -Check sprint-status.yaml to verify epic number is correct. - - HALT - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” EPIC {{epic_number}} REVALIDATION -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories Found:** {{epic_stories.length}} -**Mode:** {{#if fill_gaps}}Verify & Fill Gaps{{else}}Verify Only{{/if}} -**Max Concurrent:** {{max_concurrent}} agents -**Pattern:** Semaphore (continuous worker pool) - -**Stories to Revalidate:** -{{#each epic_stories}} -{{@index + 1}}. {{this}} -{{/each}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Proceed with revalidation? (yes/no): - - - ❌ Revalidation cancelled - Exit workflow - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸš€ Starting Parallel Revalidation (Semaphore Pattern) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Initialize worker pool state: - - - story_queue = epic_stories - - active_workers = {} - - completed_stories = [] - - failed_stories = [] - - verification_results = {} - - next_story_index = 0 - - max_workers = {{max_concurrent}} - - - Fill initial worker slots: - - While next_story_index < min(max_workers, story_queue.length): - - - story_key = story_queue[next_story_index] - story_file = {sprint_artifacts}/{{story_key}}.md # Try multiple naming patterns if needed - worker_id = next_story_index + 1 - - Spawn Task agent: - - subagent_type: "general-purpose" - - description: "Revalidate story {{story_key}}" - - prompt: "Execute revalidate-story workflow for {{story_key}}. - - CRITICAL INSTRUCTIONS: - 1. Load workflow: _bmad/bmm/workflows/4-implementation/revalidate-story/workflow.yaml - 2. Parameters: story_file={{story_file}}, fill_gaps={{fill_gaps}} - 3. Clear all checkboxes - 4. Verify each AC/Task/DoD against codebase - 5. Re-check verified items - 6. Report gaps - {{#if fill_gaps}}7. Fill gaps and commit{{/if}} - 8. Return verification summary" - - run_in_background: true - - Store in active_workers[worker_id]: - story_key: {{story_key}} - task_id: {{returned_task_id}} - started_at: {{timestamp}} - - - Increment next_story_index - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… {{active_workers.size}} workers active -πŸ“‹ {{story_queue.length - next_story_index}} stories queued -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - SEMAPHORE PATTERN: Keep {{max_workers}} agents running continuously - - While active_workers.size > 0 OR next_story_index < story_queue.length: - - Poll for completed workers (non-blocking): - - For each worker_id in active_workers: - - Check worker status using TaskOutput(task_id, block=false) - - - Get verification results from worker output - Parse: verified_pct, gaps_found, gaps_filled - - Store in verification_results[story_key] - Add to completed_stories - Remove from active_workers - - βœ… Worker {{worker_id}}: {{story_key}} β†’ {{verified_pct}}% verified{{#if gaps_filled > 0}}, {{gaps_filled}} gaps filled{{/if}} - - - Refill slot with next story (same pattern as batch-super-dev) - πŸ”„ Worker {{worker_id}} refilled: {{next_story_key}} - - - - - Add to failed_stories with error - Remove from active_workers - ❌ Worker {{worker_id}}: {{story_key}} failed - - - Refill slot despite failure - - - - Display live progress every 30 seconds: - -πŸ“Š Live Progress: {{completed_stories.length}} completed, {{active_workers.size}} active, {{story_queue.length - next_story_index}} queued - - - Sleep 5 seconds before next poll - - - - Aggregate verification results across all stories: - - epic_total_items = sum of all items across stories - epic_verified = sum of verified items - epic_partial = sum of partial items - epic_missing = sum of missing items - epic_gaps_filled = sum of gaps filled - - epic_verified_pct = (epic_verified / epic_total_items) Γ— 100 - - - Group stories by verification percentage: - - - complete_stories (β‰₯95% verified) - - mostly_complete_stories (80-94% verified) - - partial_stories (50-79% verified) - - incomplete_stories (<50% verified) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š EPIC {{epic_number}} REVALIDATION SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total Stories:** {{epic_stories.length}} -**Completed:** {{completed_stories.length}} -**Failed:** {{failed_stories.length}} - -**Epic-Wide Verification:** -- βœ… Verified: {{epic_verified}}/{{epic_total_items}} ({{epic_verified_pct}}%) -- πŸ”Ά Partial: {{epic_partial}}/{{epic_total_items}} -- ❌ Missing: {{epic_missing}}/{{epic_total_items}} -{{#if fill_gaps}}- πŸ”§ Gaps Filled: {{epic_gaps_filled}}{{/if}} - -**Story Health:** -- βœ… Complete (β‰₯95%): {{complete_stories.length}} stories -- πŸ”Ά Mostly Complete (80-94%): {{mostly_complete_stories.length}} stories -- ⚠️ Partial (50-79%): {{partial_stories.length}} stories -- ❌ Incomplete (<50%): {{incomplete_stories.length}} stories - ---- - -**Complete Stories (β‰₯95% verified):** -{{#each complete_stories}} -- {{story_key}}: {{verified_pct}}% verified -{{/each}} - -{{#if mostly_complete_stories.length > 0}} -**Mostly Complete Stories (80-94%):** -{{#each mostly_complete_stories}} -- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) -{{/each}} -{{/if}} - -{{#if partial_stories.length > 0}} -**⚠️ Partial Stories (50-79%):** -{{#each partial_stories}} -- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) -{{/each}} - -Recommendation: Continue development on these stories -{{/if}} - -{{#if incomplete_stories.length > 0}} -**❌ Incomplete Stories (<50%):** -{{#each incomplete_stories}} -- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) -{{/each}} - -Recommendation: Re-implement these stories from scratch -{{/if}} - -{{#if failed_stories.length > 0}} -**❌ Failed Revalidations:** -{{#each failed_stories}} -- {{story_key}}: {{error}} -{{/each}} -{{/if}} - ---- - -**Epic Health Score:** {{epic_verified_pct}}/100 - -{{#if epic_verified_pct >= 95}} -βœ… Epic is COMPLETE and verified -{{else if epic_verified_pct >= 80}} -πŸ”Ά Epic is MOSTLY COMPLETE ({{epic_missing}} items need attention) -{{else if epic_verified_pct >= 50}} -⚠️ Epic is PARTIALLY COMPLETE (significant gaps remain) -{{else}} -❌ Epic is INCOMPLETE (major rework needed) -{{/if}} - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - Write epic summary to: {sprint_artifacts}/revalidation-epic-{{epic_number}}-{{timestamp}}.md - πŸ“„ Epic report: {{report_path}} - - - - Update sprint-status.yaml with revalidation timestamp and results - Add comment to epic entry: # Revalidated: {{epic_verified_pct}}% verified ({{timestamp}}) - - - - diff --git a/src/bmm/workflows/4-implementation/revalidate-story/instructions.md b/src/bmm/workflows/4-implementation/revalidate-story/instructions.md deleted file mode 100644 index f5135606..00000000 --- a/src/bmm/workflows/4-implementation/revalidate-story/instructions.md +++ /dev/null @@ -1,510 +0,0 @@ -# Revalidate Story - Verify Checkboxes Against Codebase Reality - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml - - - - - Verify story_file parameter provided - - - ❌ ERROR: story_file parameter required - -Usage: - /revalidate-story story_file=path/to/story.md - /revalidate-story story_file=path/to/story.md fill_gaps=true - - HALT - - - Read COMPLETE story file: {{story_file}} - Parse sections: Acceptance Criteria, Tasks/Subtasks, Definition of Done, Dev Agent Record - - Extract story_key from filename (e.g., "2-7-image-file-handling") - - Create backup of current checkbox state: - Count currently checked items: - - ac_checked_before = count of [x] in Acceptance Criteria - - tasks_checked_before = count of [x] in Tasks/Subtasks - - dod_checked_before = count of [x] in Definition of Done - - total_checked_before = sum of above - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” STORY REVALIDATION STARTED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Story:** {{story_key}} -**File:** {{story_file}} -**Mode:** {{#if fill_gaps}}Verify & Fill Gaps{{else}}Verify Only{{/if}} - -**Current State:** -- Acceptance Criteria: {{ac_checked_before}}/{{ac_total}} checked -- Tasks: {{tasks_checked_before}}/{{tasks_total}} checked -- Definition of Done: {{dod_checked_before}}/{{dod_total}} checked -- **Total:** {{total_checked_before}}/{{total_items}} ({{pct_before}}%) - -**Action:** Clearing all checkboxes and re-verifying against codebase... -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - 🧹 Clearing all checkboxes to start fresh verification... - - Use Edit tool to replace all [x] with [ ] in Acceptance Criteria section - Use Edit tool to replace all [x] with [ ] in Tasks/Subtasks section - Use Edit tool to replace all [x] with [ ] in Definition of Done section - - Save story file with all boxes unchecked - - βœ… All checkboxes cleared. Starting verification from clean slate... - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“‹ VERIFYING ACCEPTANCE CRITERIA ({{ac_total}} items) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Extract all AC items from Acceptance Criteria section - - For each AC item: - - - Extract AC description and identify artifacts: - - File mentions (e.g., "UserProfile component") - - Function names (e.g., "updateUser function") - - Features (e.g., "dark mode toggle") - - Test requirements (e.g., "unit tests covering edge cases") - - - Verifying AC{{@index}}: {{ac_description}} - - - - Use Glob to find relevant files: - - If AC mentions specific file: glob for that file - - If AC mentions component: glob for **/*ComponentName* - - If AC mentions feature: glob for files in related directories - - - Use Grep to search for symbols/functions/features - - Read found files to verify: - - NOT a stub (check for "TODO", "Not implemented", "throw new Error") - - Has actual implementation (not just empty function) - - Tests exist (search for *.test.* or *.spec.* files) - - Tests pass (if --fill-gaps mode, run tests) - - - - - verification_status = VERIFIED - Check box [x] in story file for this AC - Record evidence: "βœ… VERIFIED: {{files_found}}, tests: {{test_files}}" - βœ… AC{{@index}}: VERIFIED - - - - verification_status = PARTIAL - Check box [~] in story file for this AC - Record gap: "πŸ”Ά PARTIAL: {{what_exists}}, missing: {{what_is_missing}}" - πŸ”Ά AC{{@index}}: PARTIAL ({{what_is_missing}}) - Add to gaps_list with details - - - - verification_status = MISSING - Leave box unchecked [ ] in story file - Record gap: "❌ MISSING: No implementation found for {{ac_description}}" - ❌ AC{{@index}}: MISSING - Add to gaps_list with details - - - - Save story file after each AC verification - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Acceptance Criteria Verification Complete -βœ… Verified: {{ac_verified}} -πŸ”Ά Partial: {{ac_partial}} -❌ Missing: {{ac_missing}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“‹ VERIFYING TASKS ({{tasks_total}} items) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Extract all Task items from Tasks/Subtasks section - - For each Task item (same verification logic as ACs): - - Parse task description for artifacts - Search codebase with Glob/Grep - Read and verify (check for stubs, tests) - Determine status: VERIFIED | PARTIAL | MISSING - Update checkbox: [x] | [~] | [ ] - Record evidence or gap - Save story file - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Tasks Verification Complete -βœ… Verified: {{tasks_verified}} -πŸ”Ά Partial: {{tasks_partial}} -❌ Missing: {{tasks_missing}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“‹ VERIFYING DEFINITION OF DONE ({{dod_total}} items) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Extract all DoD items from Definition of Done section - - For each DoD item: - - Parse DoD requirement: - - "Type check passes" β†’ Run type checker - - "Unit tests 90%+ coverage" β†’ Run coverage report - - "Linting clean" β†’ Run linter - - "Build succeeds" β†’ Run build - - "All tests pass" β†’ Run test suite - - - Execute verification for this DoD item - - - Check box [x] - Record: "βœ… VERIFIED: {{verification_result}}" - - - - Leave unchecked [ ] or partial [~] - Record gap if applicable - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Definition of Done Verification Complete -βœ… Verified: {{dod_verified}} -πŸ”Ά Partial: {{dod_partial}} -❌ Missing: {{dod_missing}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Calculate overall completion: - - total_verified = ac_verified + tasks_verified + dod_verified - total_partial = ac_partial + tasks_partial + dod_partial - total_missing = ac_missing + tasks_missing + dod_missing - total_items = ac_total + tasks_total + dod_total - - verified_pct = (total_verified / total_items) Γ— 100 - completion_pct = ((total_verified + total_partial) / total_items) Γ— 100 - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š REVALIDATION SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Story:** {{story_key}} -**File:** {{story_file}} - -**Verification Results:** -- βœ… Verified Complete: {{total_verified}}/{{total_items}} ({{verified_pct}}%) -- πŸ”Ά Partially Complete: {{total_partial}}/{{total_items}} -- ❌ Missing/Incomplete: {{total_missing}}/{{total_items}} - -**Breakdown:** -- Acceptance Criteria: {{ac_verified}}βœ… {{ac_partial}}πŸ”Ά {{ac_missing}}❌ / {{ac_total}} total -- Tasks: {{tasks_verified}}βœ… {{tasks_partial}}πŸ”Ά {{tasks_missing}}❌ / {{tasks_total}} total -- Definition of Done: {{dod_verified}}βœ… {{dod_partial}}πŸ”Ά {{dod_missing}}❌ / {{dod_total}} total - -**Status Assessment:** -{{#if verified_pct >= 95}} -βœ… Story is COMPLETE ({{verified_pct}}% verified) -{{else if verified_pct >= 80}} -πŸ”Ά Story is MOSTLY COMPLETE ({{verified_pct}}% verified, {{total_missing}} gaps) -{{else if verified_pct >= 50}} -⚠️ Story is PARTIALLY COMPLETE ({{verified_pct}}% verified, {{total_missing}} gaps) -{{else}} -❌ Story is INCOMPLETE ({{verified_pct}}% verified, significant work missing) -{{/if}} - -**Before Revalidation:** {{total_checked_before}}/{{total_items}} checked ({{pct_before}}%) -**After Revalidation:** {{total_verified}}/{{total_items}} verified ({{verified_pct}}%) -**Accuracy:** {{#if pct_before == verified_pct}}Perfect match{{else if pct_before > verified_pct}}{{pct_before - verified_pct}}% over-reported{{else}}{{verified_pct - pct_before}}% under-reported{{/if}} - -{{#if total_missing > 0}} ---- -**Gaps Found ({{total_missing}}):** -{{#each gaps_list}} -{{@index + 1}}. {{item_type}} - {{item_description}} - Status: {{status}} - Missing: {{what_is_missing}} - {{#if evidence}}Evidence checked: {{evidence}}{{/if}} -{{/each}} ---- -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - Write detailed report to: {sprint_artifacts}/revalidation-{{story_key}}-{{timestamp}}.md - Include: verification results, gaps list, evidence for each item, recommendations - πŸ“„ Detailed report: {{report_path}} - - - - - - -βœ… Verification complete (verify-only mode) - -{{#if total_missing > 0}} -**To fill the {{total_missing}} gaps, run:** -/revalidate-story story_file={{story_file}} fill_gaps=true -{{else}} -No gaps found - story is complete! -{{/if}} - - Exit workflow - - - - βœ… No gaps to fill - story is already complete! - Exit workflow - - - - - -⚠️ TOO MANY GAPS: {{total_missing}} gaps found (max: {{max_gaps_to_fill}}) - -This story has too many missing items for automatic gap filling. -Consider: -1. Re-implementing the story from scratch with /dev-story -2. Manually implementing the gaps -3. Increasing max_gaps_to_fill in workflow.yaml (use cautiously) - -Gap filling HALTED for safety. - - HALT - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ”§ GAP FILLING MODE ({{total_missing}} gaps to fill) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Continue to Step 8 - - - - - For each gap in gaps_list: - - - - -Fill this gap? - -**Item:** {{item_description}} -**Type:** {{item_type}} ({{section}}) -**Missing:** {{what_is_missing}} - -[Y] Yes - Implement this item -[A] Auto-fill - Implement this and all remaining gaps without asking -[S] Skip - Leave this gap unfilled -[H] Halt - Stop gap filling - -Your choice: - - - - Set require_confirmation = false (auto-fill remaining) - - - - Continue to next gap - - - - Exit gap filling loop - Jump to Step 9 (Summary) - - - - - - πŸ”§ Implementing: {{item_description}} - - Load story context (Technical Requirements, Architecture Compliance, Dev Notes) - Implement missing item following story specifications - Write tests if required - Run tests to verify implementation - Verify linting/type checking passes - - - Check box [x] for this item in story file - Update File List with new/modified files - Add to Dev Agent Record: "Gap filled: {{item_description}}" - βœ… Implemented and verified - - - Stage files for this gap - Commit: "fix({{story_key}}): fill gap - {{item_description}}" - βœ… Committed - - - - - ❌ Failed to implement: {{error_message}} - Leave box unchecked - Record failure in gaps_list - Add to failed_gaps - - - - After all gaps processed: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Gap Filling Complete -βœ… Filled: {{gaps_filled}} -❌ Failed: {{gaps_failed}} -⏭️ Skipped: {{gaps_skipped}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - πŸ” Re-verifying filled gaps... - - For each filled gap: - Re-run verification for that item - Ensure still VERIFIED after all changes - - βœ… All filled gaps re-verified - - - Calculate final completion: - - final_verified = count of [x] across all sections - final_partial = count of [~] across all sections - final_missing = count of [ ] across all sections - final_pct = (final_verified / total_items) Γ— 100 - - - - Stage all changed files - Commit: "fix({{story_key}}): fill {{gaps_filled}} gaps from revalidation" - βœ… All gaps committed - - - - Load {sprint_status} file - Update entry with current progress: - Format: {{story_key}}: {{current_status}} # Revalidated: {{final_verified}}/{{total_items}} ({{final_pct}}%) verified - Save sprint-status.yaml - βœ… Sprint status updated with revalidation results - - - - Add to Dev Agent Record in story file: - -## Revalidation Record ({{timestamp}}) - -**Revalidation Mode:** {{#if fill_gaps}}Verify & Fill{{else}}Verify Only{{/if}} - -**Results:** -- Verified: {{final_verified}}/{{total_items}} ({{final_pct}}%) -- Gaps Found: {{total_missing}} -- Gaps Filled: {{gaps_filled}} - -**Evidence:** -{{#each verification_evidence}} -- {{item}}: {{evidence}} -{{/each}} - -{{#if gaps_filled > 0}} -**Gaps Filled:** -{{#each filled_gaps}} -- {{item}}: {{what_was_implemented}} -{{/each}} -{{/if}} - -{{#if failed_gaps.length > 0}} -**Failed to Fill:** -{{#each failed_gaps}} -- {{item}}: {{error}} -{{/each}} -{{/if}} - - Save story file - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… REVALIDATION COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Story:** {{story_key}} - -**Final Status:** -- βœ… Verified Complete: {{final_verified}}/{{total_items}} ({{final_pct}}%) -- πŸ”Ά Partially Complete: {{final_partial}}/{{total_items}} -- ❌ Missing/Incomplete: {{final_missing}}/{{total_items}} - -{{#if fill_gaps}} -**Gap Filling Results:** -- Filled: {{gaps_filled}} -- Failed: {{gaps_failed}} -- Skipped: {{gaps_skipped}} -{{/if}} - -**Accuracy Check:** -- Before revalidation: {{pct_before}}% checked -- After revalidation: {{final_pct}}% verified -- Checkbox accuracy: {{#if pct_before == final_pct}}βœ… Perfect (0% discrepancy){{else if pct_before > final_pct}}⚠️ {{pct_before - final_pct}}% over-reported (checkboxes were optimistic){{else}}πŸ”Ά {{final_pct - pct_before}}% under-reported (work done but not checked){{/if}} - -{{#if final_pct >= 95}} -**Recommendation:** Story is COMPLETE - mark as "done" or "review" -{{else if final_pct >= 80}} -**Recommendation:** Story is mostly complete - finish remaining {{final_missing}} items then mark "review" -{{else if final_pct >= 50}} -**Recommendation:** Story has significant gaps - continue development with /dev-story -{{else}} -**Recommendation:** Story is mostly incomplete - consider re-implementing with /dev-story or /super-dev-pipeline -{{/if}} - -{{#if failed_gaps.length > 0}} -**⚠️ Manual attention needed for {{failed_gaps.length}} items that failed to fill automatically** -{{/if}} - -{{#if create_report}} -**Detailed Report:** {sprint_artifacts}/revalidation-{{story_key}}-{{timestamp}}.md -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - diff --git a/src/bmm/workflows/4-implementation/super-dev-story/README.md b/src/bmm/workflows/4-implementation/super-dev-story/README.md deleted file mode 100644 index 77786969..00000000 --- a/src/bmm/workflows/4-implementation/super-dev-story/README.md +++ /dev/null @@ -1,283 +0,0 @@ -# Super-Dev-Story Workflow - -**Enhanced story development with comprehensive quality validation** - -## What It Does - -Super-dev-story is `/dev-story` on steroids - it includes ALL standard development steps PLUS additional quality gates: - -``` -Standard dev-story: - 1-8. Development cycle β†’ Mark "review" - -Super-dev-story: - 1-8. Development cycle - 9.5. Post-dev gap analysis (verify work complete) - 9.6. Automated code review (catch issues) - β†’ Fix issues if found (loop back to step 5) - 9. Mark "review" (only after all validation passes) -``` - -## When to Use - -### Use `/super-dev-story` for: - -- βœ… Security-critical features (auth, payments, PII handling) -- βœ… Complex business logic with many edge cases -- βœ… Stories you want bulletproof before human review -- βœ… High-stakes features (production releases, customer-facing) -- βœ… When you want to minimize review cycles - -### Use standard `/dev-story` for: - -- Documentation updates -- Simple UI tweaks -- Configuration changes -- Low-risk experimental features -- When speed matters more than extra validation - -## Cost vs Benefit - -| Aspect | dev-story | super-dev-story | -|--------|-----------|-----------------| -| **Tokens** | 50K-100K | 80K-150K (+30-50%) | -| **Time** | Normal | +20-30% | -| **Quality** | Good | Excellent | -| **Review cycles** | 1-3 iterations | 0-1 iterations | -| **False completions** | Possible | Prevented | - -**ROI:** Extra 30K tokens (~$0.09) prevents hours of rework and multiple review cycles - -## What Gets Validated - -### Step 9.5: Post-Dev Gap Analysis - -**Checks:** -- Tasks marked [x] β†’ Code actually exists and works? -- Required files β†’ Actually created? -- Claimed tests β†’ Actually exist and pass? -- Partial implementations β†’ Marked complete prematurely? - -**Catches:** -- ❌ "Created auth service" β†’ File doesn't exist -- ❌ "Added tests with 90% coverage" β†’ Only 60% actual -- ❌ "Implemented login" β†’ Function exists but incomplete - -**Actions if issues found:** -- Unchecks false positive tasks -- Adds tasks for missing work -- Loops back to implementation - -### Step 9.6: Automated Code Review - -**Reviews:** -- βœ… Correctness (logic errors, edge cases) -- βœ… Security (vulnerabilities, input validation) -- βœ… Architecture (pattern compliance, SOLID principles) -- βœ… Performance (inefficiencies, optimization opportunities) -- βœ… Testing (coverage gaps, test quality) -- βœ… Code Quality (readability, maintainability) - -**Actions if issues found:** -- Adds review findings as tasks -- Loops back to implementation -- Continues until issues resolved - -## Usage - -### Basic Usage - -```bash -# Load any BMAD agent -/super-dev-story - -# Follows same flow as dev-story, with extra validation -``` - -### Specify Story - -```bash -/super-dev-story _bmad-output/implementation-artifacts/story-1.2.md -``` - -### Expected Flow - -``` -1. Pre-dev gap analysis - β”œβ”€ "Approve task updates? [Y/A/n/e/s/r]" - └─ Select option - -2. Development (standard TDD cycle) - └─ Implements all tasks - -3. Post-dev gap analysis - β”œβ”€ Scans codebase - β”œβ”€ If gaps: adds tasks, loops back - └─ If clean: proceeds - -4. Code review - β”œβ”€ Analyzes all changes - β”œβ”€ If issues: adds tasks, loops back - └─ If clean: proceeds - -5. Story marked "review" - └─ Truly complete! -``` - -## Fix Iteration Safety - -Super-dev has a **max iteration limit** (default: 3) to prevent infinite loops: - -```yaml -# workflow.yaml -super_dev_settings: - max_fix_iterations: 3 # Stop after 3 fix cycles - fail_on_critical_issues: true # HALT if critical security issues -``` - -If exceeded: -``` -πŸ›‘ Maximum Fix Iterations Reached - -Attempted 3 fix cycles. -Manual intervention required. - -Issues remaining: -- [List of unresolved issues] -``` - -## Examples - -### Example 1: Perfect First Try - -``` -/super-dev-story - -Pre-gap: βœ… Tasks accurate -Development: βœ… 8 tasks completed -Post-gap: βœ… All work verified -Code review: βœ… No issues - -β†’ Story complete! (45 minutes, 85K tokens) -``` - -### Example 2: Post-Dev Catches Incomplete Work - -``` -/super-dev-story - -Pre-gap: βœ… Tasks accurate -Development: βœ… 8 tasks completed -Post-gap: ⚠️ Tests claim 90% coverage, actual 65% - -β†’ Adds task: "Increase test coverage to 90%" -β†’ Implements missing tests -β†’ Post-gap: βœ… Now 92% coverage -β†’ Code review: βœ… No issues - -β†’ Story complete! (52 minutes, 95K tokens) -``` - -### Example 3: Code Review Finds Security Issue - -``` -/super-dev-story - -Pre-gap: βœ… Tasks accurate -Development: βœ… 10 tasks completed -Post-gap: βœ… All work verified -Code review: 🚨 CRITICAL - SQL injection vulnerability - -β†’ Adds task: "Fix SQL injection in user search" -β†’ Implements parameterized queries -β†’ Post-gap: βœ… Verified -β†’ Code review: βœ… Security issue resolved - -β†’ Story complete! (58 minutes, 110K tokens) -``` - -## Comparison to Standard Workflow - -### Standard Flow (dev-story) - -``` -Day 1: Develop story (30 min) -Day 2: Human review finds 3 issues -Day 3: Fix issues (20 min) -Day 4: Human review again -Day 5: Approved - -Total: 5 days, 2 review cycles -``` - -### Super-Dev Flow - -``` -Day 1: Super-dev-story - - Development (30 min) - - Post-gap finds 1 issue (auto-fix 5 min) - - Code review finds 2 issues (auto-fix 15 min) - - Complete (50 min total) - -Day 2: Human review -Day 3: Approved (minimal/no changes needed) - -Total: 3 days, 1 review cycle -``` - -**Savings:** 2 days, 1 fewer review cycle, higher initial quality - -## Troubleshooting - -### "Super-dev keeps looping forever" - -**Cause:** Each validation finds new issues -**Solution:** This indicates quality problems. Review max_fix_iterations setting or manually intervene. - -### "Post-dev gap analysis keeps failing" - -**Cause:** Dev agent marking tasks complete prematurely -**Solution:** This is expected! Super-dev catches this. The loop ensures actual completion. - -### "Code review too strict" - -**Cause:** Reviewing for issues standard dev-story would miss -**Solution:** This is intentional. For less strict review, use standard dev-story. - -### "Too many tokens/too slow" - -**Cause:** Multi-stage validation adds overhead -**Solution:** Use standard dev-story for non-critical stories. Reserve super-dev for important work. - -## Best Practices - -1. **Reserve for important stories** - Don't use for trivial changes -2. **Trust the process** - Fix iterations mean it's working correctly -3. **Review limits** - Adjust max_fix_iterations if stories are complex -4. **Monitor costs** - Track token usage vs review cycle savings -5. **Learn patterns** - Code review findings inform future architecture - -## Configuration Reference - -```yaml -# _bmad/bmm/config.yaml or _bmad/bmgd/config.yaml - -# Per-project settings -super_dev_settings: - post_dev_gap_analysis: true # Enable post-dev validation - auto_code_review: true # Enable automatic code review - fail_on_critical_issues: true # HALT on security vulnerabilities - max_fix_iterations: 3 # Maximum fix cycles before manual intervention - auto_fix_minor_issues: false # Auto-fix LOW severity without asking -``` - -## See Also - -- [dev-story workflow](../dev-story/) - Standard development workflow -- [gap-analysis workflow](../gap-analysis/) - Standalone audit tool -- [Gap Analysis Guide](../../../../docs/gap-analysis.md) - Complete documentation -- [Super-Dev Mode Concept](../../../../docs/super-dev-mode.md) - Vision and roadmap - ---- - -**Super-Dev-Story: Because "done" should mean DONE** βœ… diff --git a/src/bmm/workflows/4-implementation/super-dev-story/instructions.xml b/src/bmm/workflows/4-implementation/super-dev-story/instructions.xml deleted file mode 100644 index b296847a..00000000 --- a/src/bmm/workflows/4-implementation/super-dev-story/instructions.xml +++ /dev/null @@ -1,299 +0,0 @@ - - The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml - You MUST have already loaded and processed: {installed_path}/workflow.yaml - Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level} - Generate all documents in {document_output_language} - πŸš€ SUPER-DEV MODE: Enhanced quality workflow with post-implementation validation and automated code review - This workflow orchestrates existing workflows with additional validation steps - - - - - - - 🎯 RUN DEV-STORY - Complete all standard development steps - This includes: story loading, pre-dev gap analysis, development, testing, and task completion - - πŸš€ **Super-Dev-Story: Enhanced Quality Workflow** - - Running standard dev-story workflow (Steps 1-8)... - - This includes: - βœ… Story loading and validation - βœ… Pre-dev gap analysis - βœ… TDD implementation cycle - βœ… Comprehensive testing - βœ… Task completion validation - - After dev-story completes, super-dev will add: - βœ… Post-dev gap analysis - βœ… Automated code review - βœ… Auto push-all - - - - - - Pass through any user-provided story file path and auto-accept setting - - - - βœ… Dev-story complete - all tasks implemented and tested - - Proceeding to super-dev enhancements... - - - - - ❌ Dev-story did not complete successfully - - Cannot proceed with super-dev enhancements. - Fix issues and retry. - - HALT - dev-story must complete first - - - - - - - - - πŸ” POST-DEV VALIDATION - Verify all work actually completed! - This catches incomplete implementations that were prematurely marked done - - - πŸ”Ž **Post-Development Gap Analysis** - - All tasks marked complete. Verifying against codebase reality... - - - - Re-read story file to get requirements and tasks - Extract all tasks marked [x] complete - For each completed task, identify what should exist in codebase - - - Use Glob to find files that should have been created - Use Grep to search for functions/classes that should exist - Use Read to verify implementation completeness (not just existence) - Run tests to verify claimed test coverage actually exists and passes - - - Compare claimed work vs actual implementation: - - **POST-DEV VERIFICATION:** - βœ… Verified Complete: - - List tasks where code fully exists and works - - Confirm tests exist and pass - - Verify implementation matches requirements - - - ❌ False Positives Detected: - - List tasks marked [x] but code missing or incomplete - - Identify claimed tests that don't exist or fail - - Note partial implementations marked as complete - - - - - - ⚠️ **Post-Dev Gaps Detected!** - - **Tasks marked complete but implementation incomplete:** - {{list_false_positives_with_details}} - - These issues must be addressed before story can be marked complete. - - - Uncheck false positive tasks in story file - Add new tasks for missing work - Update Gap Analysis section with post-dev findings - - πŸ”„ Re-invoking dev-story to complete missing work... - - - - - Resume with added tasks for missing work - - - βœ… Missing work completed. Proceeding to code review... - - - - βœ… **Post-Dev Validation Passed** - - All tasks verified complete against codebase. - Proceeding to code review... - - Update Gap Analysis section with post-dev verification results - - - - - - - - - πŸ‘€ AUTO CODE REVIEW - Independent quality validation - - - πŸ” **Running Automated Code Review** - - Analyzing implementation for issues... - - - - - Run code review on completed story - - - Parse code review results from story file "Code Review" section - Extract issues by severity (Critical, High, Medium, Low) - Count total issues found - - - 🚨 **Code Review Found Issues Requiring Fixes** - - Issues found: {{total_issue_count}} - - Critical: {{critical_count}} - - High: {{high_count}} - - Medium: {{medium_count}} - - Low: {{low_count}} - - Adding review findings to story tasks and re-running dev-story... - - - Add code review findings as tasks in story file - - - - - Fix code review issues - - - βœ… Code review issues resolved. Proceeding to push... - - - - ℹ️ **Code Review Found Minor Issues** - - - Medium: {{medium_count}} - - Low: {{low_count}} - - - Auto-fix these minor issues? [Y/n/skip]: - - - Add review findings as tasks - - - - - - - - Document issues in story file - ℹ️ Minor issues documented. Proceeding to push... - - - - - βœ… **Code Review Passed** - - No issues found. Implementation meets quality standards. - Proceeding to push... - - - - - - - - - - πŸ“ PUSH-ALL - Stage, commit, and push with safety validation - ⚑ TARGETED COMMIT: Only commit files from THIS story's File List (safe for parallel agents) - - - Read story file and extract the "File List" section - Parse all file paths listed (relative to repo root) - Also include the story file itself in the list - Store as {{story_files}} - space-separated list of all files - - πŸ“ **Committing Story Changes** - - Files from this story: - {{story_files}} - - Running push-all with targeted file list (parallel-agent safe)... - - - - - - Only commit files changed by this story - - - - βœ… Changes pushed to remote successfully - - - - ⚠️ Push failed but story is complete locally - - You can push manually when ready. - - - - - - - - - - πŸŽ‰ **SUPER-DEV STORY COMPLETE, {user_name}!** - - **Quality Gates Passed:** - βœ… Pre-dev gap analysis - Tasks validated before work - βœ… Development - All tasks completed with TDD - βœ… Post-dev gap analysis - Implementation verified - βœ… Code review - Quality and security validated - βœ… Pushed to remote - Changes backed up - - **Story File:** {{story_file}} - **Status:** review (ready for human review) - - --- - - **What Super-Dev Validated:** - 1. πŸ” Tasks matched codebase reality before starting - 2. πŸ’» Implementation completed per requirements - 3. βœ… No false positive completions (all work verified) - 4. πŸ‘€ Code quality and security validated - 5. πŸ“ Changes committed and pushed to remote - - **Next Steps:** - - Review the completed story - - Verify business requirements met - - Merge when approved - - **Note:** This story went through enhanced quality validation. - It should require minimal human review. - - - Based on {user_skill_level}, ask if user needs explanations about implementation, decisions, or findings - - - Provide clear, contextual explanations - - - πŸ’‘ **Tip:** This story was developed with super-dev-story for enhanced quality. - - For faster development, use standard `dev-story` workflow. - For maximum quality, continue using `super-dev-story`. - - - - diff --git a/src/bmm/workflows/4-implementation/super-dev-story/workflow.md b/src/bmm/workflows/4-implementation/super-dev-story/workflow.md new file mode 100644 index 00000000..20dcfea4 --- /dev/null +++ b/src/bmm/workflows/4-implementation/super-dev-story/workflow.md @@ -0,0 +1,311 @@ +# Super Dev Story v3.0 - Development with Quality Gates + + +Complete story development pipeline: dev-story β†’ validation β†’ code review β†’ push. +Automatically re-invokes dev-story if gaps or review issues found. +Ensures production-ready code before pushing. + + + +**Quality Over Speed** + +Don't just implementβ€”verify, review, fix. +- Run dev-story for implementation +- Validate with gap analysis +- Code review for quality +- Fix issues before pushing +- Only push when truly ready + + + +name: super-dev-story +version: 3.0.0 + +stages: + - dev-story: "Implement the story" + - validate: "Run gap analysis" + - review: "Code review" + - push: "Safe commit and push" + +defaults: + max_rework_loops: 3 + auto_push: false + review_depth: "standard" # quick | standard | deep + validation_depth: "quick" + +quality_gates: + validation_threshold: 90 # % tasks must be verified + review_threshold: "pass" # pass | pass_with_warnings + + + +@patterns/verification.md +@patterns/hospital-grade.md + + + + + +**Load story and prepare pipeline** + +```bash +STORY_FILE="{{story_file}}" +[ -f "$STORY_FILE" ] || { echo "❌ story_file required"; exit 1; } +``` + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸš€ SUPER DEV STORY PIPELINE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{story_key}} +Stages: dev-story β†’ validate β†’ review β†’ push + +Quality Gates: +- Validation: β‰₯{{validation_threshold}}% verified +- Review: {{review_threshold}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Initialize: +- rework_count = 0 +- stage = "dev-story" + + + +**Stage 1: Implement the story** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“ STAGE 1: DEV-STORY +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Invoke dev-story workflow: +``` +/dev-story story_file={{story_file}} +``` + +Wait for completion. Capture: +- files_created +- files_modified +- tasks_completed + +``` +βœ… Dev-story complete +Files: {{file_count}} created/modified +Tasks: {{tasks_completed}}/{{total_tasks}} +``` + + + +**Stage 2: Validate implementation** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” STAGE 2: VALIDATION +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Invoke validation: +``` +/validate scope=story target={{story_file}} depth={{validation_depth}} +``` + +Capture results: +- verified_pct +- false_positives +- category + +**Check quality gate:** +``` +if verified_pct < validation_threshold: + REWORK_NEEDED = true + reason = "Validation below {{validation_threshold}}%" + +if false_positives > 0: + REWORK_NEEDED = true + reason = "{{false_positives}} tasks marked done but missing" +``` + +``` +{{#if REWORK_NEEDED}} +⚠️ Validation failed: {{reason}} +{{else}} +βœ… Validation passed: {{verified_pct}}% verified +{{/if}} +``` + + + +**Stage 3: Code review** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“‹ STAGE 3: CODE REVIEW +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Invoke code review: +``` +/multi-agent-review files={{files_modified}} depth={{review_depth}} +``` + +Capture results: +- verdict (PASS, PASS_WITH_WARNINGS, NEEDS_REWORK) +- issues + +**Check quality gate:** +``` +if verdict == "NEEDS_REWORK": + REWORK_NEEDED = true + reason = "Code review found blocking issues" + +if review_threshold == "pass" AND verdict == "PASS_WITH_WARNINGS": + REWORK_NEEDED = true + reason = "Warnings not allowed in strict mode" +``` + +``` +{{#if REWORK_NEEDED}} +⚠️ Review failed: {{reason}} +Issues: {{issues}} +{{else}} +βœ… Review passed: {{verdict}} +{{/if}} +``` + + + +**Handle rework loop** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ”„ REWORK REQUIRED (Loop {{rework_count + 1}}/{{max_rework_loops}}) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Reason: {{reason}} + +{{#if validation_issues}} +Validation Issues: +{{#each validation_issues}} +- {{this}} +{{/each}} +{{/if}} + +{{#if review_issues}} +Review Issues: +{{#each review_issues}} +- {{this}} +{{/each}} +{{/if}} +``` + +**Check loop limit:** +``` +rework_count++ +if rework_count > max_rework_loops: + echo "❌ Max rework loops exceeded" + echo "Manual intervention required" + HALT +``` + +**Re-invoke dev-story with issues:** +``` +/dev-story story_file={{story_file}} fix_issues={{issues}} +``` + +After dev-story completes, return to validation stage. + + + +**Stage 4: Push changes** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“¦ STAGE 4: PUSH +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**Generate commit message from story:** +``` +feat({{epic}}): {{story_title}} + +- Implemented {{task_count}} tasks +- Verified: {{verified_pct}}% +- Review: {{verdict}} + +Story: {{story_key}} +``` + +**If auto_push:** +``` +/push-all commit_message="{{message}}" auto_push=true +``` + +**Otherwise, ask:** +``` +Ready to push? + +[Y] Yes, push now +[N] No, keep local (can push later) +[R] Review changes first +``` + + + +**Display pipeline results** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… SUPER DEV STORY COMPLETE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{story_key}} + +Pipeline Results: +- Dev-Story: βœ… Complete +- Validation: βœ… {{verified_pct}}% verified +- Review: βœ… {{verdict}} +- Push: {{pushed ? "βœ… Pushed" : "⏸️ Local only"}} + +Rework Loops: {{rework_count}} +Files Changed: {{file_count}} +Commit: {{commit_hash}} + +{{#if pushed}} +Branch: {{branch}} +Ready for PR: gh pr create +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + + + +```bash +# Standard pipeline +/super-dev-story story_file=docs/sprint-artifacts/2-5-auth.md + +# With auto-push +/super-dev-story story_file=docs/sprint-artifacts/2-5-auth.md auto_push=true + +# Strict review mode +/super-dev-story story_file=docs/sprint-artifacts/2-5-auth.md review_threshold=pass +``` + + + +**Dev-story fails:** Report error, halt pipeline. +**Validation below threshold:** Enter rework loop. +**Review finds blocking issues:** Enter rework loop. +**Max rework loops exceeded:** Halt, require manual intervention. +**Push fails:** Report error, commit preserved locally. + + + +- [ ] Dev-story completed +- [ ] Validation β‰₯ threshold +- [ ] Review passed +- [ ] Changes committed +- [ ] Pushed (if requested) +- [ ] Story status updated + diff --git a/src/bmm/workflows/4-implementation/super-dev-story/workflow.yaml b/src/bmm/workflows/4-implementation/super-dev-story/workflow.yaml index 530f041c..7185b853 100644 --- a/src/bmm/workflows/4-implementation/super-dev-story/workflow.yaml +++ b/src/bmm/workflows/4-implementation/super-dev-story/workflow.yaml @@ -14,7 +14,7 @@ date: system-generated # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/super-dev-story" -instructions: "{installed_path}/instructions.xml" +instructions: "{installed_path}/workflow.md" validation: "{installed_path}/checklist.md" story_file: "" # Explicit story path; auto-discovered if empty diff --git a/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md b/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md deleted file mode 100644 index c7fd4498..00000000 --- a/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md +++ /dev/null @@ -1,1270 +0,0 @@ -# Batch Super-Dev - Interactive Story Selector -## AKA: "Mend the Gap" πŸš‡ - -**Primary Use Case:** Gap analysis and reconciliation workflow - -This workflow helps you "mind the gap" between story requirements and codebase reality, then "mend the gap" by building only what's truly missing. - -### What This Workflow Does - -1. **Scans codebase** to verify what's actually implemented vs what stories claim -2. **Finds the gap** between story requirements and reality -3. **Mends the gap** by building ONLY what's truly missing (no duplicate work) -4. **Updates tracking** to reflect actual completion status (check boxes, sprint-status) - -### Common Use Cases - -**Reconciliation Mode (Most Common):** -- Work was done but not properly tracked -- Stories say "build X" but X is 60-80% already done -- Need second set of eyes to find real gaps -- Update story checkboxes to match reality - -**Greenfield Mode:** -- Story says "build X", nothing exists -- Build 100% from scratch with full quality gates - -**Brownfield Mode:** -- Story says "modify X", X exists -- Refactor carefully, add only new requirements - -### Execution Modes - -**Sequential (Recommended for Gap Analysis):** -- Process stories ONE-BY-ONE in THIS SESSION -- After each story: verify existing code β†’ build only gaps β†’ check boxes β†’ move to next -- Easier to monitor, can intervene if issues found -- Best for reconciliation work - -**Parallel (For Greenfield Batch Implementation):** -- Spawn autonomous Task agents to process stories concurrently -- Faster completion but harder to monitor -- Best when stories are independent and greenfield - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/batch-super-dev/workflow.yaml - -βš•οΈ HOSPITAL-GRADE CODE STANDARDS βš•οΈ -This code may be used in healthcare settings where LIVES ARE AT STAKE. -Every line of code must meet hospital-grade reliability standards. -QUALITY >> SPEED. Take 5 hours to do it right, not 1 hour to do it poorly. - - - - - Read {sprint_status} file - Parse metadata: project, project_key, tracking_system - Parse development_status map - - Filter stories with status = "ready-for-dev" OR "backlog" - Exclude entries that are epics (keys starting with "epic-") or retrospectives (keys ending with "-retrospective") - Group by status: ready_for_dev_stories, backlog_stories - - - Further filter stories to only include those starting with "{filter_by_epic}-" - If filter_by_epic = "3", only include stories like "3-1-...", "3-2-...", etc. - - - Sort filtered stories by epic number, then story number (e.g., 1-1, 1-2, 2-1, 3-1) - Store as: ready_for_dev_stories (list of story keys) - - - βœ… No available stories found (ready-for-dev or backlog). - -All stories are either in-progress, review, or done! - -Run `/bmad_bmm_sprint-status` to see current status. - Exit workflow - - - Combine both lists: available_stories = ready_for_dev_stories + backlog_stories - - - - Read comment field for each story from sprint-status.yaml (text after # on the same line) - - For each story, verify story file exists using COMPREHENSIVE naming pattern detection: - - - Parse story_key (e.g., "20-9-megamenu-navigation" or "20-9") to extract: - - epic_num: first number (e.g., "20") - - story_num: second number (e.g., "9") - - optional_suffix: everything after second number (e.g., "-megamenu-navigation" or empty) - Input: "20-9-megamenu-navigation" β†’ epic=20, story=9, suffix="-megamenu-navigation" - Input: "20-11" β†’ epic=20, story=11, suffix="" - - - - Use Glob tool to search for files matching these patterns (in priority order): - - story-{epic_num}.{story_num}.md - story-20.9.md (DOT notation, no suffix) - - story-{epic_num}.{story_num}*.md - story-20.9-megamenu-navigation.md (DOT notation WITH suffix - use Glob wildcard) - - {epic_num}-{story_num}.md - 20-9.md (HYPHEN notation, no "story-" prefix) - - {epic_num}-{story_num}*.md - 20-9-megamenu-navigation.md (HYPHEN notation WITH suffix) - - story-{story_key}.md - story-20-9-megamenu-navigation.md (literal story_key with "story-" prefix) - - {story_key}.md - 20-9-megamenu-navigation.md (literal story_key) - - Stop at first match and store file_path - If NO match found after all 6 patterns β†’ file_status = ❌ MISSING - If match found β†’ file_status = βœ… EXISTS - - - Mark stories as: βœ… (file exists), ❌ (file missing), πŸ”„ (already implemented but not marked done) - - -## πŸ“¦ Available Stories ({{count}}) - -{{#if filter_by_epic}} -**Filtered by Epic {{filter_by_epic}}** -{{/if}} - -{{#if ready_for_dev_stories.length > 0}} -### Ready for Dev ({{ready_for_dev_stories.length}}) -{{#each ready_for_dev_stories}} -{{@index}}. **{{key}}** {{file_status_icon}} {{sprint_status}} - {{#if comment}}β†’ {{comment}}{{/if}} - {{#if file_path}} File: {{file_path}}{{/if}} -{{/each}} -{{/if}} - -{{#if backlog_stories.length > 0}} -### Backlog ({{backlog_stories.length}}) -{{#each backlog_stories}} -{{@index}}. **{{key}}** {{file_status_icon}} [BACKLOG] - {{#if comment}}β†’ {{comment}}{{/if}} - {{#if file_path}} File: {{file_path}}{{else}} Needs story creation{{/if}} -{{/each}} -{{/if}} - ---- -**Legend:** -- βœ… Story file exists, ready to implement -- πŸ”„ Already implemented, just needs status update -- ❌ Story file missing, needs creation first -- [BACKLOG] Story needs gap analysis before implementation - -**Total:** {{count}} stories available -**Max batch size:** {{max_stories}} stories - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” VALIDATING STORY FILES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each story in available_stories (ready_for_dev + backlog): - - - Check if story file exists (already done in Step 2) - - - - πŸ“ Story {{story_key}}: BACKLOG - will create basic story file - Mark story as needs_story_creation = true - Mark story.creation_workflow = "/create-story" (lightweight, no gap analysis) - Mark story as validated (will create in next step) - - - - ❌ Story {{story_key}}: File MISSING but status is ready-for-dev - Mark story for removal from selection - Add to skipped_stories list with reason: "Story file missing (status ready-for-dev but no file)" - - - - - Read story file: {{file_path}} - Parse sections and validate BMAD format - - Check for all 12 required sections: - 1. Business Context - 2. Current State - 3. Acceptance Criteria - 4. Tasks and Subtasks - 5. Technical Requirements - 6. Architecture Compliance - 7. Testing Requirements - 8. Dev Agent Guardrails - 9. Definition of Done - 10. References - 11. Dev Agent Record - 12. Change Log - - - Count sections present: sections_found - Check Current State content length (word count) - Check Acceptance Criteria item count: ac_count - Count unchecked tasks ([ ]) in Tasks/Subtasks: task_count - Look for gap analysis markers (βœ…/❌) in Current State - - - -❌ Story {{story_key}}: INVALID - Insufficient tasks ({{task_count}}/3 minimum) - -This story has TOO FEW TASKS to be a valid story (found {{task_count}}, need β‰₯3). - -Analysis: -- 0 tasks: Story is a stub or empty -- 1-2 tasks: Too small to represent meaningful feature work -- β‰₯3 tasks: Minimum valid (MICRO threshold) - -Possible causes: -- Story file is incomplete/stub -- Tasks section is empty or malformed -- Story needs proper task breakdown -- Story is too small and should be combined with another - -Required action: -- Run /validate-create-story to regenerate with proper task breakdown -- Or manually add tasks to reach minimum of 3 tasks -- Or combine this story with a related story - -This story will be SKIPPED. - - Mark story for removal from selection - Add to skipped_stories list with reason: "INVALID - Only {{task_count}} tasks (need β‰₯3)" - - - - - -⚠️ Story {{story_key}}: File incomplete or invalid - - Sections: {{sections_found}}/12 - {{#if Current State < 100 words}}- Current State: stub ({{word_count}} words, expected β‰₯100){{/if}} - {{#if no gap analysis}}- Gap analysis: missing{{/if}} - {{#if ac_count < 3}}- Acceptance Criteria: {{ac_count}} items (expected β‰₯3){{/if}} - {{#if task_count < 3}}- Tasks: {{task_count}} items (expected β‰₯3){{/if}} - - - Regenerate story with codebase scan? (yes/no): - - - -⚠️ STORY REGENERATION REQUIRES MANUAL WORKFLOW EXECUTION - -**Story:** {{story_key}} -**Status:** File incomplete or invalid ({{sections_found}}/12 sections) - -**Problem:** -Agents cannot invoke /create-story-with-gap-analysis workflow autonomously. -Story regeneration requires: -- Interactive user prompts -- Context-heavy codebase scanning -- Gap analysis decision-making - -**Required Action:** - -1. **Exit this batch execution:** - - This story will be skipped - - Batch will continue with valid stories only - -2. **Backup existing file (optional):** - ``` - cp {{file_path}} {{file_path}}.backup - ``` - -3. **Regenerate story manually:** - ``` - /create-story-with-gap-analysis - ``` - When prompted, provide: - - Story key: {{story_key}} - -4. **Validate story format:** - ``` - ./scripts/validate-all-stories.sh - ``` - -5. **Re-run batch-super-dev:** - - Story will now be properly formatted - -**Skipping story {{story_key}} from current batch execution.** - - - Mark story for removal from selection - Add to skipped_stories list with reason: "Story regeneration requires manual workflow (agents cannot invoke /create-story)" - Add to manual_actions_required list: "Regenerate {{story_key}} with /create-story-with-gap-analysis" - - - - ⏭️ Skipping story {{story_key}} (file incomplete) - Mark story for removal from selection - Add to skipped_stories list with reason: "User declined regeneration" - - - - - βœ… Story {{story_key}}: Valid (12/12 sections, gap analysis present) - Mark story as validated - - - - - βœ… Story {{story_key}}: Already implemented (will skip or reconcile only) - Mark story as validated (already done) - - - - Remove skipped stories from ready_for_dev_stories - Update count of available stories - - - -⏭️ Skipped Stories ({{skipped_count}}): -{{#each skipped_stories}} - - {{story_key}}: {{reason}} -{{/each}} - - - - - -❌ No valid stories remaining after validation. - -All stories were either: -- Missing files (user declined creation) -- Invalid/incomplete (user declined regeneration) -- Already implemented - -Run `/bmad:bmm:workflows:sprint-status` to see status. - - Exit workflow - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Story Validation Complete -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Validated:** {{validated_count}} stories ready to process -{{#if skipped_count > 0}}**Skipped:** {{skipped_count}} stories{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š SCORING STORY COMPLEXITY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each validated story: - - - Read story file: {{file_path}} - - Count unchecked tasks ([ ]) at top level only in Tasks/Subtasks section β†’ task_count - (See workflow.yaml complexity.task_counting.method = "top_level_only") - - - - -⚠️ Story {{story_key}}: Cannot score complexity - INSUFFICIENT TASKS ({{task_count}}/3 minimum) - -This story was not caught in Step 2.5 validation but has too few tasks. -It should have been rejected during validation. - -Skipping complexity scoring for this story - marking as INVALID. - - Set {{story_key}}.complexity = {level: "INVALID", score: 0, task_count: {{task_count}}, reason: "Insufficient tasks ({{task_count}}/3 minimum)"} - Continue to next story - - - Extract file paths mentioned in tasks β†’ file_count - Scan story title and task descriptions for risk keywords using rules from workflow.yaml: - - Case insensitive matching (require_word_boundaries: true) - - Include keyword variants (e.g., "authentication" matches "auth") - - Scan: story_title, task_descriptions, subtask_descriptions - - - Calculate complexity score: - - Base score = task_count - - Add 5 for each HIGH risk keyword match (auth, security, payment, migration, database, schema, encryption) - - Add 2 for each MEDIUM risk keyword match (api, integration, external, third-party, cache) - - Add 0 for LOW risk keywords (ui, style, config, docs, test) - - Count each keyword only once (no duplicates) - - - Assign complexity level using mutually exclusive decision tree (priority order): - - 1. Check COMPLEX first (highest priority): - IF (task_count β‰₯ 16 OR complexity_score β‰₯ 20 OR has ANY HIGH risk keyword) - THEN level = COMPLEX - - 2. Else check MICRO (lowest complexity): - ELSE IF (task_count ≀ 3 AND complexity_score ≀ 5 AND file_count ≀ 5) - THEN level = MICRO - - 3. Else default to STANDARD: - ELSE level = STANDARD - - This ensures no overlaps: - - Story with HIGH keyword β†’ COMPLEX (never MICRO or STANDARD) - - Story with 4-15 tasks or >5 files β†’ STANDARD (not MICRO or COMPLEX) - - Story with ≀3 tasks, ≀5 files, no HIGH keywords β†’ MICRO - - - Store complexity_level for story: {{story_key}}.complexity = {level, score, task_count, risk_keywords} - - - Group stories by complexity level - - Filter out INVALID stories (those with level="INVALID"): - For each INVALID story, add to skipped_stories with reason from complexity object - Remove INVALID stories from complexity_groups and ready_for_dev_stories - - - -❌ **Invalid Stories Skipped ({{invalid_count}}):** -{{#each invalid_stories}} - - {{story_key}}: {{reason}} -{{/each}} - -These stories need to be regenerated with /create-story or /validate-create-story before processing. - - - - -πŸ“Š **Complexity Analysis Complete** - -{{#each complexity_groups}} -**{{level}} Stories ({{count}}):** -{{#each stories}} - - {{story_key}}: {{task_count}} tasks, score {{score}}{{#if risk_keywords}}, risk: {{risk_keywords}}{{/if}} -{{/each}} -{{/each}} - ---- -**Pipeline Routing:** -- πŸš€ **MICRO** ({{micro_count}}): Lightweight path - skip gap analysis + code review -- βš™οΈ **STANDARD** ({{standard_count}}): Full pipeline with all quality gates -- πŸ”’ **COMPLEX** ({{complex_count}}): Enhanced validation + consider splitting - -{{#if complex_count > 0}} -⚠️ **Warning:** {{complex_count}} complex stories detected. Consider: -- Breaking into smaller stories before processing -- Running these separately with extra attention -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - -❌ No valid stories remaining after complexity analysis. - -All stories were either: -- Missing story files (Step 2.5) -- Invalid/incomplete (Step 2.5) -- Zero tasks (Step 2.6) - -Run /create-story or /validate-create-story to create proper story files, then rerun /batch-super-dev. - - Exit workflow - - - - - -**Select stories to process:** - -Enter story numbers to process (examples): - - Single: `1` - - Multiple: `1,3,5` - - Range: `1-5` (processes 1,2,3,4,5) - - Mixed: `1,3-5,8` (processes 1,3,4,5,8) - - All: `all` (processes all {{count}} stories) - -Or: - - `cancel` - Exit without processing - -**Your selection:** - - - Parse user input - - - ❌ Batch processing cancelled. - Exit workflow - - - - Set selected_stories = all ready_for_dev_stories - - - - Parse selection (handle commas, ranges) - Input "1,3-5,8" β†’ indexes [1,3,4,5,8] β†’ map to story keys - Map selected indexes to story keys from ready_for_dev_stories - Store as: selected_stories - - - - ⚠️ You selected {{count}} stories, but max_stories is {{max_stories}}. - -Only the first {{max_stories}} will be processed. - Truncate selected_stories to first max_stories entries - - - Display confirmation - -## πŸ“‹ Selected Stories ({{count}}) - -{{#each selected_stories}} -{{@index}}. {{key}} {{#if is_backlog}}[BACKLOG - needs story creation]{{/if}} -{{/each}} - -**Estimated time:** {{count}} stories Γ— 30-60 min/story = {{estimated_hours}} hours - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” IMPLEMENTATION READINESS CHECK -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Validating selected stories for quality and completeness... - - - For each selected story: - - - Read story file: {{story_file_path}} - - - - ⚠️ {{story_key}}: No story file (BACKLOG) - will create during execution - Mark story as needs_creation - Continue to next story - - - - ❌ {{story_key}}: Story file MISSING but status is ready-for-dev (inconsistent state) - Add to validation_failures list - Continue to next story - - - - - Validate story completeness: - - Count sections (need 12) - - Check Current State word count (need β‰₯100) - - Check gap analysis markers (βœ…/❌) - - Count Acceptance Criteria (need β‰₯3) - - Count unchecked tasks (need β‰₯3) - - - - ❌ {{story_key}}: INSUFFICIENT TASKS ({{task_count}}/3 minimum) - Add to validation_failures: "{{story_key}}: Only {{task_count}} tasks" - - - - ⚠️ {{story_key}}: Story incomplete ({{sections_found}}/12 sections{{#if !gap_analysis}}, no gap analysis{{/if}}) - Add to validation_warnings: "{{story_key}}: Needs regeneration" - - - - βœ… {{story_key}}: Valid and ready - Add to validated_stories list - - - - - - -❌ **Validation Failures ({{validation_failures.length}}):** - -{{#each validation_failures}} - - {{this}} -{{/each}} - -These stories CANNOT be processed. Options: -1. Remove them from selection -2. Fix them manually -3. Cancel batch execution - - - Remove failed stories and continue? (yes/no): - - - Remove validation_failures from selected_stories - βœ… Removed {{validation_failures.length}} invalid stories. Continuing with {{selected_stories.length}} valid stories. - - - - ❌ Batch processing cancelled. Please fix story validation issues first. - Exit workflow - - - - - -⚠️ **Validation Warnings ({{validation_warnings.length}}):** - -{{#each validation_warnings}} - - {{this}} -{{/each}} - -These stories have quality issues but can still be processed. -Recommend regenerating with /create-story-with-gap-analysis for better quality. - - - Continue with these stories anyway? (yes/no): - - - ❌ Batch processing cancelled. - Exit workflow - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Implementation Readiness: PASS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Validated:** {{validated_stories.length}} stories -**Needs Creation:** {{needs_creation.length}} stories (BACKLOG) -**Quality:** All stories meet minimum standards -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - βœ… All stories have files - skipping story creation - Jump to Step 3 - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“ BATCH STORY CREATION -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -{{needs_creation.length}} stories need creation (BACKLOG status): -{{#each needs_creation}} - - {{story_key}} -{{/each}} - -These will be created using /create-story (lightweight, no gap analysis). -Gap analysis will happen just-in-time during implementation (Step 2 of super-dev-pipeline). - - - Create these {{needs_creation.length}} story files now? (yes/no): - - - ⏭️ Skipping story creation. These stories will be removed from batch. - Remove needs_creation stories from selected_stories - - - ❌ No stories remaining after removing backlog stories. Exiting. - Exit workflow - - - - For each story in needs_creation: - - - πŸ“ Creating story {{@index}}/{{needs_creation.length}}: {{story_key}}... - - Invoke workflow: /bmad_bmm_create-story - Parameters: - - story_key: {{story_key}} - - epic_num: {{epic_num}} - - mode: batch (auto-approve, minimal prompts) - - - - βœ… Story created: {{story_key}} - Mark story.needs_story_creation = false - - - - ❌ Failed to create story: {{story_key}} - Add to failed_creations list - Remove from selected_stories - - - - - -⚠️ {{failed_creations.length}} stories failed creation: -{{#each failed_creations}} - - {{this}} -{{/each}} - -These will be skipped in batch execution. - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Story Creation Complete -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Created:** {{needs_creation.length - failed_creations.length}} stories -**Failed:** {{failed_creations.length}} stories -**Ready for implementation:** {{selected_stories.length}} stories - -Note: Gap analysis will happen just-in-time during implementation. -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -╔═══════════════════════════════════════════════════════════════════╗ -β•‘ BATCH SUPER-DEV: Execution Mode Selection β•‘ -β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• - -βš•οΈ HOSPITAL-GRADE CODE STANDARDS ACTIVE βš•οΈ -Lives are at stake. All code must meet safety-critical reliability standards. - - - -**Choose execution mode:** - -[I] INTERACTIVE CHECKPOINT MODE - - After each story completes, pause for your review - - You approve before proceeding to next story - - Allows course correction if issues detected - - Best for: When you want to monitor progress - -[A] FULLY AUTONOMOUS MODE - - Process all selected stories without pausing - - No human interaction until completion - - Best for: When stories are well-defined and you trust the process - -Which mode? [I/A]: - - - Read user input - - - Set execution_mode = "interactive_checkpoint" - -βœ… Interactive Checkpoint Mode Selected - -After each story implementation: -- Full quality report displayed -- You approve before next story begins -- Allows real-time oversight and intervention - - - - - Set execution_mode = "fully_autonomous" - -βš•οΈ Fully Autonomous Mode Selected - HOSPITAL-GRADE STANDARDS ENFORCED - -Quality enhancements for autonomous mode: -βœ… Double validation at each step -βœ… Comprehensive error checking -βœ… Detailed audit trail generation -βœ… Zero-tolerance for shortcuts -βœ… Hospital-grade code verification - -Processing will continue until ALL selected stories complete. -NO human interaction required until completion. - -QUALITY OVER SPEED: Taking time to ensure correctness. - - Activate hospital_grade_mode = true - Set quality_multiplier = 1.5 - - - -**How should these stories be processed?** - -Options: -- **sequential**: Run stories one-by-one in this session (slower, easier to monitor) -- **parallel**: Spawn Task agents to process stories concurrently (faster, autonomous) - -Enter: sequential or parallel - - - Capture response as: execution_mode - - - Set parallel_count = 1 - Set use_task_agents = false - βœ… Sequential mode selected - stories will be processed one-by-one in this session - - - - Set use_task_agents = true - - -**How many agents should run in parallel?** - -Options: -- **2**: Conservative (low resource usage, easier debugging) -- **4**: Moderate (balanced performance, recommended) -- **8**: Aggressive (higher throughput) -- **10**: Maximum (10 agent limit for safety) -- **all**: Use all stories (max 10 agents) - -Enter number (2-10) or 'all': - - - Capture response as: parallel_count - If parallel_count == 'all': set parallel_count = min(count of selected_stories, 10) - If parallel_count > 10: set parallel_count = 10 (safety limit) - - - ⚠️ Requested {{original_count}} agents, capped at 10 (safety limit) - - - - -## βš™οΈ Execution Plan - -**Mode:** {{execution_mode}} -{{#if use_task_agents}} -**Task Agents:** {{parallel_count}} running concurrently -**Agent Type:** general-purpose (autonomous) -{{else}} -**Sequential processing** in current session -{{/if}} - -**Stories to process:** {{count}} -**Estimated total time:** -{{#if use_task_agents}} -- With {{parallel_count}} agents: {{estimated_hours / parallel_count}} hours -{{else}} -- Sequential: {{estimated_hours}} hours -{{/if}} - - - Confirm execution plan? (yes/no): - - - ❌ Batch processing cancelled. - Exit workflow - - - - - Initialize counters: completed=0, failed=0, failed_stories=[], reconciliation_warnings=[], reconciliation_warnings_count=0 - Set start_time = current timestamp - - - Jump to Step 4-Parallel (Task Agent execution) - - - - Continue to Step 4-Sequential (In-session execution) - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸš€ SEQUENTIAL BATCH PROCESSING STARTED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories:** {{count}} -**Mode:** super-dev-pipeline (batch, sequential) -**Continue on failure:** {{continue_on_failure}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each story in selected_stories: - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“¦ Story {{current_index}}/{{total_count}}: {{story_key}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Invoke workflow: /bmad:bmm:workflows:super-dev-pipeline - Parameters: mode=batch, story_key={{story_key}}, complexity_level={{story_key}}.complexity.level - - - βœ… Implementation complete: {{story_key}} - - ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. - Do NOT delegate this to an agent. YOU do it. - - - 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit - 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed - 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks - 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work - 5. Use Edit: Fill Dev Agent Record with files/date/summary - 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) - 7. Use Edit: Update sprint-status.yaml to "done" or "review" - - - - βœ… COMPLETED: {{story_key}} (reconciled) - Increment completed counter - - - PAUSE FOR USER REVIEW - -╔═══════════════════════════════════════════════════════════════════╗ -β•‘ INTERACTIVE CHECKPOINT: Story {{story_key}} Complete β•‘ -β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• - -βœ… Story {{story_key}} successfully implemented and reconciled - -Quality Summary: -- All tests passing -- Type checks passing -- Linter passing -- Code review completed -- Sprint status updated - -Remaining stories: {{remaining}} - -Options: -[C] Continue to next story -[R] Review implementation details -[P] Pause batch (exit workflow) - -Your choice [C/R/P]: - - - Read user input - - - βœ… Continuing to next story... - - - - πŸ“‹ Implementation Details for {{story_key}} - Display story file, test results, review findings - -Press [C] to continue or [P] to pause: - - Read user input - - βœ… Continuing to next story... - - - ⏸️ Batch paused. Run batch-super-dev again to continue with remaining stories. - Jump to Step 5 (Summary) - - - - - ⏸️ Batch paused. Run batch-super-dev again to continue with remaining stories. - Jump to Step 5 (Summary) - - - - - βœ… {{story_key}} complete. Automatically continuing to next story (autonomous mode)... - - - - - ⚠️ WARNING: {{story_key}} completed but reconciliation failed - Increment completed counter (implementation was successful) - Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} - Increment reconciliation_warnings_count - - - - - ❌ FAILED: {{story_key}} - Increment failed counter - Add story_key to failed_stories list - - - ⚠️ Stopping batch due to failure (continue_on_failure=false) - Jump to Step 5 (Summary) - - - - - -**Progress:** {{completed}} completed, {{failed}} failed, {{remaining}} remaining - - - - - ⏸️ Pausing {{pause_between_stories}} seconds before next story... - Wait {{pause_between_stories}} seconds - - - - After all stories processed, jump to Step 5 (Summary) - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸš€ PARALLEL PROCESSING STARTED (Semaphore Pattern) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories:** {{count}} -**Mode:** Task agents (autonomous, continuous) -**Max concurrent agents:** {{parallel_count}} -**Continue on failure:** {{continue_on_failure}} -**Pattern:** Worker pool with {{parallel_count}} slots -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -πŸ“Š **Semaphore Pattern Benefits:** -- No idle time between batches -- Constant {{parallel_count}} agents running -- As soon as slot frees β†’ next story starts immediately -- Faster completion (no batch synchronization delays) - - - Initialize worker pool state: - - - story_queue = selected_stories (all stories to process) - - active_workers = {} (map of worker_id β†’ {story_key, task_id, started_at}) - - completed_stories = [] - - failed_stories = [] - - next_story_index = 0 - - max_workers = {{parallel_count}} - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ”§ Initializing {{max_workers}} worker slots... -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Spawn first {{max_workers}} agents (or fewer if less stories): - - While next_story_index < min(max_workers, story_queue.length): - - - story_key = story_queue[next_story_index] - worker_id = next_story_index + 1 - - Spawn Task agent: - - subagent_type: "general-purpose" - - description: "Implement story {{story_key}}" - - prompt: "Execute super-dev-pipeline workflow for story {{story_key}}. - - CRITICAL INSTRUCTIONS: - 1. Load workflow.xml: _bmad/core/tasks/workflow.xml - 2. Load workflow config: _bmad/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml - 3. Execute in BATCH mode with story_key={{story_key}} and complexity_level={{story_key}}.complexity.level - 4. Follow all 7 pipeline steps (init, pre-gap, implement, post-validate, code-review, complete, summary) - 5. Commit changes when complete - 6. Report final status (done/failed) with file list - - Story file will be auto-resolved from multiple naming conventions." - - run_in_background: true (non-blocking - critical for semaphore pattern) - - Store in active_workers[worker_id]: - story_key: {{story_key}} - task_id: {{returned_task_id}} - started_at: {{timestamp}} - status: "running" - - - Increment next_story_index - - πŸš€ Worker {{worker_id}} started: {{story_key}} - - After spawning initial workers: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… {{active_workers.size}} workers active -πŸ“‹ {{story_queue.length - next_story_index}} stories queued -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - SEMAPHORE PATTERN: Keep {{max_workers}} agents running continuously - - While active_workers.size > 0 OR next_story_index < story_queue.length: - - Poll for completed workers (check task outputs non-blocking): - - For each worker_id in active_workers: - - Check if worker task completed using TaskOutput(task_id, block=false) - - - Continue to next worker (don't wait) - - - - Get worker details: story_key = active_workers[worker_id].story_key - - βœ… Worker {{worker_id}} completed: {{story_key}} - - ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. - - - 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit - 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed - 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks - 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work - 5. Use Edit: Fill Dev Agent Record with files/date/summary - 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) - 7. Use Edit: Update sprint-status.yaml to "done" or "review" - - - - βœ… COMPLETED: {{story_key}} (reconciled) - Add to completed_stories - - - - ⚠️ WARNING: {{story_key}} completed but reconciliation failed - Add to completed_stories (implementation successful) - Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} - - - Remove worker_id from active_workers (free the slot) - - IMMEDIATELY refill slot if stories remain: - - story_key = story_queue[next_story_index] - - πŸ”„ Worker {{worker_id}} refilled: {{story_key}} - - Spawn new Task agent for this worker_id (same parameters as init) - Update active_workers[worker_id] with new task_id and story_key - Increment next_story_index - - - - - Get worker details: story_key = active_workers[worker_id].story_key - - ❌ Worker {{worker_id}} failed: {{story_key}} - - Add to failed_stories - Remove worker_id from active_workers (free the slot) - - - ⚠️ Stopping all workers due to failure (continue_on_failure=false) - Kill all active workers - Clear story_queue - Break worker pool loop - - - - story_key = story_queue[next_story_index] - - πŸ”„ Worker {{worker_id}} refilled: {{story_key}} (despite previous failure) - - Spawn new Task agent for this worker_id - Update active_workers[worker_id] with new task_id and story_key - Increment next_story_index - - - - Display live progress every 30 seconds: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š Live Progress ({{timestamp}}) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… Completed: {{completed_stories.length}} -❌ Failed: {{failed_stories.length}} -πŸ”„ Active workers: {{active_workers.size}} -πŸ“‹ Queued: {{story_queue.length - next_story_index}} - -Active stories: -{{#each active_workers}} - Worker {{@key}}: {{story_key}} (running {{duration}}) -{{/each}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Sleep 5 seconds before next poll (prevents tight loop) - - - - After worker pool drains (all stories processed), jump to Step 5 (Summary) - - - - Calculate end_time and total_duration - Calculate success_rate = (completed / total_count) * 100 - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š BATCH SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total stories:** {{total_count}} -**βœ… Completed:** {{completed}} -**❌ Failed:** {{failed}} -**⚠️ Reconciliation warnings:** {{reconciliation_warnings_count}} -**Success rate:** {{success_rate}}% -**Duration:** {{total_duration}} - -{{#if failed > 0}} -**Failed stories:** -{{#each failed_stories}} - - {{this}} -{{/each}} - -**Retry failed stories:** -```bash -{{#each failed_stories}} -/bmad:bmm:workflows:super-dev-pipeline mode=batch story_key={{this}} -{{/each}} -``` -{{/if}} - -{{#if reconciliation_warnings_count > 0}} -**⚠️ Reconciliation warnings (stories completed but status may be inaccurate):** -{{#each reconciliation_warnings}} - - {{story_key}}: {{warning_message}} -{{/each}} - -**Manual reconciliation needed:** -Review these stories to ensure checkboxes and status are accurate. -Check Dev Agent Record vs Acceptance Criteria/Tasks/DoD sections. -{{/if}} - -{{#if manual_actions_required.length > 0}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -⚠️ MANUAL ACTIONS REQUIRED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -**{{manual_actions_required.length}} stories require manual intervention:** - -{{#each manual_actions_required}} -{{@index}}. **{{story_key}}** - Action: Regenerate story with proper BMAD format - Command: `/create-story-with-gap-analysis` -{{/each}} - -**After completing these actions:** -1. Validate all stories: `./scripts/validate-all-stories.sh` -2. Re-run batch-super-dev for these stories -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -{{/if}} - -**Next steps:** -1. Check sprint-status.yaml - stories should be marked "done" or "review" -2. Run tests: `pnpm test` -3. Check coverage: `pnpm test --coverage` -4. Review commits: `git log -{{completed}}` -5. Spot-check 2-3 stories for quality - -**Run another batch?** -`/bmad:bmm:workflows:batch-super-dev` -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Save batch log to {batch_log} - Log contents: start_time, end_time, total_duration, selected_stories, completed_stories, failed_stories, success_rate - - - diff --git a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/README.md b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/README.md deleted file mode 100644 index 08f41fa6..00000000 --- a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/README.md +++ /dev/null @@ -1,170 +0,0 @@ -# Create Story With Gap Analysis - -**Custom Workflow by Jonah Schulte** -**Created:** December 24, 2025 -**Purpose:** Generate stories with SYSTEMATIC codebase gap analysis (not inference-based) - ---- - -## Problem This Solves - -**Standard `/create-story` workflow:** -- ❌ Reads previous stories and git commits (passive) -- ❌ Infers what probably exists (guessing) -- ❌ Gap analysis quality varies by agent thoroughness -- ❌ Checkboxes may not reflect reality - -**This custom workflow:** -- βœ… Actively scans codebase with Glob/Read tools -- βœ… Verifies file existence (not inference) -- βœ… Reads key files to check implementation depth (mocked vs real) -- βœ… Generates TRUTHFUL gap analysis -- βœ… Checkboxes are FACTS verified by file system - ---- - -## Usage - -```bash -/create-story-with-gap-analysis - -# Or via Skill tool: -Skill: "create-story-with-gap-analysis" -Args: "1.9" (epic.story number) -``` - -**Workflow will:** -1. Load existing story + epic context -2. **SCAN codebase systematically** (Glob for files, Read to verify implementation) -3. Generate gap analysis with verified βœ…/❌/⚠️ status -4. Update story file with truthful checkboxes -5. Save to _bmad-output/implementation-artifacts/ - ---- - -## What It Scans - -**For each story, the workflow:** - -1. **Identifies target directories** (from story title/requirements) - - Example: "admin-user-service" β†’ apps/backend/admin-user-service/ - -2. **Globs for all files** - - `{target}/src/**/*.ts` - Find all TypeScript files - - `{target}/src/**/*.spec.ts` - Find all tests - -3. **Checks specific required files** - - Based on ACs, check if files exist - - Example: `src/auth/controllers/bridgeid-auth.controller.ts` β†’ ❌ MISSING - -4. **Reads key files to verify depth** - - Check if mocked: Search for "MOCK" string - - Check if incomplete: Search for "TODO" - - Verify real implementation exists - -5. **Checks package.json** - - Verify required dependencies are installed - - Identify missing packages - -6. **Counts tests** - - How many test files exist - - Coverage for each component - ---- - -## Output Format - -**Generates story with:** - -1. βœ… Standard BMAD 5 sections (Story, AC, Tasks, Dev Notes, Dev Agent Record) -2. βœ… Enhanced Dev Notes with verified gap analysis subsections: - - Gap Analysis: Current State vs Requirements - - Library/Framework Requirements (from package.json) - - File Structure Requirements (from Glob results) - - Testing Requirements (from test file count) - - Architecture Compliance - - Previous Story Intelligence - -3. βœ… Truthful checkboxes based on verified file existence - ---- - -## Difference from Standard /create-story - -| Feature | /create-story | /create-story-with-gap-analysis | -|---------|---------------|--------------------------------| -| Reads previous story | βœ… | βœ… | -| Reads git commits | βœ… | βœ… | -| Loads epic context | βœ… | βœ… | -| **Scans codebase with Glob** | ❌ | βœ… SYSTEMATIC | -| **Verifies files exist** | ❌ | βœ… VERIFIED | -| **Reads files to check depth** | ❌ | βœ… MOCKED vs REAL | -| **Checks package.json** | ❌ | βœ… DEPENDENCIES | -| **Counts test coverage** | ❌ | βœ… COVERAGE | -| Gap analysis quality | Variable (agent-dependent) | Systematic (tool-verified) | -| Checkbox accuracy | Inference-based | File-existence-based | - ---- - -## When to Use - -**This workflow (planning-time gap analysis):** -- Use when regenerating/auditing stories -- Use when you want verified checkboxes upfront -- Best for stories that will be implemented immediately -- Manual verification at planning time - -**Standard /create-story + /dev-story (dev-time gap analysis):** -- Recommended for most workflows -- Stories start as DRAFT, validated when dev begins -- Prevents staleness in batch planning -- Automatic verification at development time - -**Use standard /create-story when:** -- Greenfield project (nothing exists yet) -- Backlog stories (won't be implemented for months) -- Epic planning phase (just sketching ideas) - -**Tip:** Both approaches are complementary. You can use this workflow to regenerate stories, then use `/dev-story` which will re-validate at dev-time. - ---- - -## Examples - -**Regenerating Story 1.9:** -```bash -/create-story-with-gap-analysis - -Choice: 1.9 - -# Workflow will: -# 1. Load existing 1-9-admin-user-service-bridgeid-rbac.md -# 2. Identify target: apps/backend/admin-user-service/ -# 3. Glob: apps/backend/admin-user-service/src/**/*.ts (finds 47 files) -# 4. Check: src/auth/controllers/bridgeid-auth.controller.ts β†’ ❌ MISSING -# 5. Read: src/bridgeid/services/bridgeid-client.service.ts β†’ ⚠️ MOCKED -# 6. Read: package.json β†’ axios ❌ NOT INSTALLED -# 7. Generate gap analysis with verified status -# 8. Write story with truthful checkboxes -``` - -**Result:** Story with verified gap analysis showing: -- βœ… 7 components IMPLEMENTED (verified file existence) -- ❌ 6 components MISSING (verified file not found) -- ⚠️ 1 component PARTIAL (file exists but contains "MOCK") - ---- - -## Installation - -This workflow is auto-discovered when BMAD is installed. - -**To use:** -```bash -/bmad:bmm:workflows:create-story-with-gap-analysis -``` - ---- - -**Last Updated:** December 27, 2025 -**Status:** Integrated into BMAD-METHOD diff --git a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-01-initialize.md b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-01-initialize.md deleted file mode 100644 index 6212924b..00000000 --- a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-01-initialize.md +++ /dev/null @@ -1,83 +0,0 @@ -# Step 1: Initialize and Extract Story Requirements - -## Goal -Load epic context and identify what needs to be scanned in the codebase. - -## Execution - -### 1. Determine Story to Create - -**Ask user:** -``` -Which story should I regenerate with gap analysis? - -Options: -1. Provide story number (e.g., "1.9" or "1-9") -2. Provide story filename (e.g., "story-1.9.md" or legacy "1-9-admin-user-service-bridgeid-rbac.md") - -Your choice: -``` - -**Parse input:** -- Extract epic_num (e.g., "1") -- Extract story_num (e.g., "9") -- Locate story file: `{story_dir}/story-{epic_num}.{story_num}.md` (fallback: `{story_dir}/{epic_num}-{story_num}-*.md`) - -### 2. Load Existing Story Content - -```bash -Read: {story_dir}/story-{epic_num}.{story_num}.md -# If not found, fallback: -Read: {story_dir}/{epic_num}-{story_num}-*.md -``` - -**Extract from existing story:** -- Story title -- User story text (As a... I want... So that...) -- Acceptance criteria (the requirements, not checkboxes) -- Any existing Dev Notes or technical context - -**Store for later use.** - -### 3. Load Epic Context - -```bash -Read: {planning_artifacts}/epics.md -``` - -**Extract from epic:** -- Epic business objectives -- This story's original requirements -- Technical constraints -- Dependencies on other stories - -### 4. Determine Target Directories - -**From story title and requirements, identify:** -- Which service/app this story targets -- Which directories to scan - -**Examples:** -- "admin-user-service" β†’ `apps/backend/admin-user-service/` -- "Widget Batch 1" β†’ `packages/widgets/` -- "POE Integration" β†’ `apps/frontend/web/` - -**Store target directories for Step 2 codebase scan.** - -### 5. Ready for Codebase Scan - -**Output:** -``` -βœ… Story Context Loaded - -Story: {epic_num}.{story_num} - {title} -Target directories identified: - - {directory_1} - - {directory_2} - -Ready to scan codebase for gap analysis. - -[C] Continue to Codebase Scan -``` - -**WAIT for user to select Continue.** diff --git a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-02-codebase-scan.md b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-02-codebase-scan.md deleted file mode 100644 index 69f4022f..00000000 --- a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-02-codebase-scan.md +++ /dev/null @@ -1,184 +0,0 @@ -# Step 2: Systematic Codebase Gap Analysis - -## Goal -VERIFY what code actually exists vs what's missing using Glob and Read tools. - -## CRITICAL -This step uses ACTUAL file system tools to generate TRUTHFUL gap analysis. -No guessing. No inference. VERIFY with tools. - -## Execution - -### 1. Scan Target Directories - -**For each target directory identified in Step 1:** - -```bash -# List all TypeScript files -Glob: {target_dir}/src/**/*.ts -Glob: {target_dir}/src/**/*.tsx - -# Store file list -``` - -**Output:** -``` -πŸ“ Codebase Scan Results for {target_dir} - -Found {count} TypeScript files: - - {file1} - - {file2} - ... -``` - -### 2. Check for Specific Required Components - -**Based on story Acceptance Criteria, check if required files exist:** - -**Example for Auth Story:** -```bash -# Check for OAuth endpoints -Glob: {target_dir}/src/auth/controllers/*bridgeid*.ts -Result: ❌ MISSING (0 files found) - -# Check for BridgeID client -Glob: {target_dir}/src/bridgeid/**/*.ts -Result: βœ… EXISTS (found: bridgeid-client.service.ts, bridgeid-sync.service.ts) - -# Check for permission guards -Glob: {target_dir}/src/auth/guards/permissions*.ts -Result: ❌ MISSING (0 files found) - -# Check for decorators -Glob: {target_dir}/src/auth/decorators/*permission*.ts -Result: ❌ MISSING (0 files found) -``` - -### 3. Verify Implementation Depth - -**For files that exist, read them to check if MOCKED or REAL:** - -```bash -# Read key implementation file -Read: {target_dir}/src/bridgeid/services/bridgeid-client.service.ts - -# Search for indicators: -- Contains "MOCK" or "mock" β†’ ⚠️ MOCKED (needs real implementation) -- Contains "TODO" β†’ ⚠️ INCOMPLETE -- Contains real HTTP client (axios) β†’ βœ… IMPLEMENTED -``` - -### 4. Check Dependencies - -```bash -# Read package.json -Read: {target_dir}/package.json - -# Verify required dependencies exist: -Required: axios -Found in package.json? β†’ ❌ NO (needs to be added) - -Required: @aws-sdk/client-secrets-manager -Found in package.json? β†’ ❌ NO (needs to be added) -``` - -### 5. Check Test Coverage - -```bash -# Find test files -Glob: {target_dir}/src/**/*.spec.ts -Glob: {target_dir}/test/**/*.test.ts - -# Count tests -Found {test_count} test files - -# Check for specific test coverage -Glob: {target_dir}/src/**/*bridgeid*.spec.ts -Result: βœ… EXISTS (found 3 test files) -``` - -### 6. Generate Truthful Gap Analysis - -**Create structured gap analysis:** - -```markdown -## Gap Analysis: Current State vs Requirements - -**βœ… IMPLEMENTED (Verified by Codebase Scan):** - -1. **BridgeID Client Infrastructure** - MOCKED (needs real HTTP) - - File: src/bridgeid/services/bridgeid-client.service.ts βœ… EXISTS - - Implementation: Mock user data with circuit breaker - - Status: ⚠️ PARTIAL - Ready for real HTTP client - - Tests: 15 tests passing βœ… - -2. **User Synchronization Service** - - File: src/bridgeid/services/bridgeid-sync.service.ts βœ… EXISTS - - Implementation: Bulk sync BridgeID β†’ admin_users - - Status: βœ… COMPLETE - - Tests: 6 tests passing βœ… - -3. **Role Mapping Logic** - - File: src/bridgeid/constants/role-mapping.constants.ts βœ… EXISTS - - Implementation: 7-tier role mapping with priority selection - - Status: βœ… COMPLETE - - Tests: 10 tests passing βœ… - -**❌ MISSING (Required for AC Completion):** - -1. **BridgeID OAuth Endpoints** - - File: src/auth/controllers/bridgeid-auth.controller.ts ❌ NOT FOUND - - Need: POST /api/auth/bridgeid/login endpoint - - Need: GET /api/auth/bridgeid/callback endpoint - - Status: ❌ NOT IMPLEMENTED - -2. **Permission Guards** - - File: src/auth/guards/permissions.guard.ts ❌ NOT FOUND - - File: src/auth/decorators/require-permissions.decorator.ts ❌ NOT FOUND - - Status: ❌ NOT IMPLEMENTED - -3. **Real OAuth HTTP Client** - - Package: axios ❌ NOT in package.json - - Package: @aws-sdk/client-secrets-manager ❌ NOT in package.json - - Status: ❌ DEPENDENCIES NOT ADDED -``` - -### 7. Update Acceptance Criteria Checkboxes - -**Based on verified gap analysis, mark checkboxes:** - -```markdown -### AC1: BridgeID OAuth Integration -- [ ] OAuth login endpoint (VERIFIED MISSING - file not found) -- [ ] OAuth callback endpoint (VERIFIED MISSING - file not found) -- [ ] Client configuration (VERIFIED PARTIAL - exists but mocked) - -### AC3: RBAC Permission System -- [x] Role mapping defined (VERIFIED COMPLETE - file exists, tests pass) -- [ ] Permission guard (VERIFIED MISSING - file not found) -- [ ] Permission decorator (VERIFIED MISSING - file not found) -``` - -**Checkboxes are now FACTS, not guesses.** - -### 8. Present Gap Analysis - -**Output:** -``` -βœ… Codebase Scan Complete - -Scanned: apps/backend/admin-user-service/ -Files found: 47 TypeScript files -Tests found: 31 test files - -Gap Analysis Generated: - βœ… 7 components IMPLEMENTED (verified) - ❌ 6 components MISSING (verified) - ⚠️ 1 component PARTIAL (needs completion) - -Story checkboxes updated based on verified file existence. - -[C] Continue to Story Generation -``` - -**WAIT for user to continue.** diff --git a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-03-generate-story.md b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-03-generate-story.md deleted file mode 100644 index 34281465..00000000 --- a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/step-03-generate-story.md +++ /dev/null @@ -1,181 +0,0 @@ -# Step 3: Generate Story with Verified Gap Analysis - -## Goal -Generate complete 7-section story file using verified gap analysis from Step 2. - -## Execution - -### 1. Load Template - -```bash -Read: {installed_path}/template.md -``` - -### 2. Fill Template Variables - -**Basic Story Info:** -- `{{epic_num}}` - from Step 1 -- `{{story_num}}` - from Step 1 -- `{{story_title}}` - from existing story or epic -- `{{priority}}` - from epic (P0, P1, P2) -- `{{effort}}` - from epic or estimate - -**Story Section:** -- `{{role}}` - from existing story -- `{{action}}` - from existing story -- `{{benefit}}` - from existing story - -**Business Context:** -- `{{business_value}}` - from epic context -- `{{scale_requirements}}` - from epic/architecture -- `{{compliance_requirements}}` - from epic/architecture -- `{{urgency}}` - from epic priority - -**Acceptance Criteria:** -- `{{acceptance_criteria}}` - from epic + existing story -- Update checkboxes based on Step 2 gap analysis: - - [x] = Component verified EXISTS - - [ ] = Component verified MISSING - - [~] = Component verified PARTIAL (optional notation) - -**Tasks / Subtasks:** -- `{{tasks_subtasks}}` - from epic + existing story -- Add "βœ… DONE", "⚠️ PARTIAL", "❌ TODO" markers based on gap analysis - -**Gap Analysis Section:** -- `{{implemented_components}}` - from Step 2 codebase scan (verified βœ…) -- `{{missing_components}}` - from Step 2 codebase scan (verified ❌) -- `{{partial_components}}` - from Step 2 codebase scan (verified ⚠️) - -**Architecture Compliance:** -- `{{architecture_patterns}}` - from architecture doc + playbooks -- Multi-tenant isolation requirements -- Caching strategies -- Error handling patterns -- Performance requirements - -**Library/Framework Requirements:** -- `{{current_dependencies}}` - from Step 2 package.json scan -- `{{required_dependencies}}` - missing deps identified in Step 2 - -**File Structure:** -- `{{existing_files}}` - from Step 2 Glob results (verified βœ…) -- `{{required_files}}` - from gap analysis (verified ❌) - -**Testing Requirements:** -- `{{test_count}}` - from Step 2 test file count -- `{{required_tests}}` - based on missing components -- `{{coverage_target}}` - from architecture or default 90% - -**Dev Agent Guardrails:** -- `{{guardrails}}` - from playbooks + previous story lessons -- What NOT to do -- Common mistakes to avoid - -**Previous Story Intelligence:** -- `{{previous_story_learnings}}` - from Step 1 previous story Dev Agent Record - -**Project Structure Notes:** -- `{{structure_alignment}}` - from architecture compliance - -**References:** -- `{{references}}` - Links to epic, architecture, playbooks, related stories - -**Definition of Done:** -- Standard DoD checklist with story-specific coverage target - -### 3. Generate Complete Story - -**Write filled template:** -```bash -Write: {story_dir}/story-{{epic_num}}.{{story_num}}.md -[Complete 7-section story with verified gap analysis] -``` - -### 4. Validate Generated Story - -```bash -# Check section count -grep "^## " {story_dir}/story-{{epic_num}}.{{story_num}}.md | wc -l -# Should output: 7 - -# Check for gap analysis -grep -q "Gap Analysis.*Current State" {story_dir}/story-{{epic_num}}.{{story_num}}.md -# Should find it - -# Run custom validation -./scripts/validate-bmad-format.sh {story_dir}/story-{{epic_num}}.{{story_num}}.md -# Update script to expect 7 sections + gap analysis subsection -``` - -### 5. Update Sprint Status - -```bash -Read: {sprint_status} - -# Find story entry -# Update status to "ready-for-dev" if was "backlog" -# Preserve all comments and structure - -Write: {sprint_status} -``` - -### 6. Report Completion - -**Output:** -``` -βœ… Story {{epic_num}}.{{story_num}} Regenerated with Gap Analysis - -File: {story_dir}/story-{{epic_num}}.{{story_num}}.md -Sections: 7/7 βœ… -Gap Analysis: VERIFIED with codebase scan - -Summary: - βœ… {{implemented_count}} components IMPLEMENTED (verified by file scan) - ❌ {{missing_count}} components MISSING (verified file not found) - ⚠️ {{partial_count}} components PARTIAL (file exists but mocked/incomplete) - -Checkboxes in ACs and Tasks reflect VERIFIED status (not guesses). - -Next Steps: -1. Review story file for accuracy -2. Use /dev-story to implement missing components -3. Story provides complete context for flawless implementation - -Story is ready for development. πŸš€ -``` - -### 7. Cleanup - -**Ask user:** -``` -Story regeneration complete! - -Would you like to: -[N] Regenerate next story ({{next_story_num}}) -[Q] Quit workflow -[R] Review generated story first - -Your choice: -``` - -**If N selected:** Loop back to Step 1 with next story number -**If Q selected:** End workflow -**If R selected:** Display story file, then show menu again - ---- - -## Success Criteria - -**Story generation succeeds when:** -1. βœ… 7 top-level ## sections present -2. βœ… Gap Analysis subsection exists with βœ…/❌/⚠️ verified status -3. βœ… Checkboxes match codebase reality (spot-checked) -4. βœ… Dev Notes has all mandatory subsections -5. βœ… Definition of Done checklist included -6. βœ… File saved to correct location -7. βœ… Sprint status updated - ---- - -**WORKFLOW COMPLETE - Ready to execute.** diff --git a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/template.md b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/template.md deleted file mode 100644 index c0b7c87d..00000000 --- a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/template.md +++ /dev/null @@ -1,179 +0,0 @@ -# Story {{epic_num}}.{{story_num}}: {{story_title}} - -**Status:** ready-for-dev -**Epic:** {{epic_num}} -**Priority:** {{priority}} -**Estimated Effort:** {{effort}} - ---- - -## Story - -As a **{{role}}**, -I want to **{{action}}**, -So that **{{benefit}}**. - ---- - -## Business Context - -### Why This Matters - -{{business_value}} - -### Production Reality - -{{scale_requirements}} -{{compliance_requirements}} -{{urgency}} - ---- - -## Acceptance Criteria - -{{acceptance_criteria}} - ---- - -## Tasks / Subtasks - -{{tasks_subtasks}} - ---- - -## Dev Notes - -### Gap Analysis: Current State vs Requirements - -**βœ… IMPLEMENTED (Verified by Codebase Scan):** - -{{implemented_components}} - -**❌ MISSING (Required for AC Completion):** - -{{missing_components}} - -**⚠️ PARTIAL (Needs Enhancement):** - -{{partial_components}} - -### Architecture Compliance - -{{architecture_patterns}} - -### Library/Framework Requirements - -**Current Dependencies:** -```json -{{current_dependencies}} -``` - -**Required Additions:** -```json -{{required_dependencies}} -``` - -### File Structure Requirements - -**Completed Files:** -``` -{{existing_files}} -``` - -**Required New Files:** -``` -{{required_files}} -``` - -### Testing Requirements - -**Current Test Coverage:** {{test_count}} tests passing - -**Required Additional Tests:** -{{required_tests}} - -**Target:** {{coverage_target}} - -### Dev Agent Guardrails - -{{guardrails}} - -### Previous Story Intelligence - -{{previous_story_learnings}} - -### Project Structure Notes - -{{structure_alignment}} - -### References - -{{references}} - ---- - -## Definition of Done - -### Code Quality (BLOCKING) -- [ ] Type check passes: `pnpm type-check` (zero errors) -- [ ] Zero `any` types in new code -- [ ] Lint passes: `pnpm lint` (zero errors in new code) -- [ ] Build succeeds: `pnpm build` - -### Testing (BLOCKING) -- [ ] Unit tests: {{coverage_target}} coverage -- [ ] Integration tests: Key workflows validated -- [ ] All tests pass: New + existing (zero regressions) - -### Security (BLOCKING) -- [ ] Dependency scan: `pnpm audit` (zero high/critical) -- [ ] No hardcoded secrets -- [ ] Input validation on all endpoints -- [ ] Auth checks on protected endpoints -- [ ] Audit logging on mutations - -### Architecture Compliance (BLOCKING) -- [ ] Multi-tenant isolation: dealerId in all queries -- [ ] Cache namespacing: Cache keys include siteId -- [ ] Performance: External APIs cached, no N+1 queries -- [ ] Error handling: No silent failures -- [ ] Follows patterns from playbooks - -### Deployment Validation (BLOCKING) -- [ ] Service starts: `pnpm dev` runs successfully -- [ ] Health check: `/health` returns 200 -- [ ] Smoke test: Primary functionality verified - -### Documentation (BLOCKING) -- [ ] API docs: Swagger decorators on endpoints -- [ ] Inline comments: Complex logic explained -- [ ] Story file: Dev Agent Record complete - ---- - -## Dev Agent Record - -### Agent Model Used - -(To be filled by dev agent) - -### Implementation Summary - -(To be filled by dev agent) - -### File List - -(To be filled by dev agent) - -### Test Results - -(To be filled by dev agent) - -### Completion Notes - -(To be filled by dev agent) - ---- - -**Generated by:** /create-story-with-gap-analysis -**Date:** {{date}} diff --git a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.md b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.md new file mode 100644 index 00000000..b40462b5 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.md @@ -0,0 +1,286 @@ +# Create Story with Gap Analysis v3.0 - Verified Story Generation + + +Regenerate story with VERIFIED codebase gap analysis. +Uses Glob/Read tools to determine what actually exists vs what's missing. +Checkboxes reflect reality, not guesses. + + + +**Truth from Codebase, Not Assumptions** + +1. Scan codebase for actual implementations +2. Verify files exist, check for stubs/TODOs +3. Check test coverage +4. Generate story with checkboxes matching reality +5. No guessingβ€”every checkbox has evidence + + + +name: create-story-with-gap-analysis +version: 3.0.0 + +verification_status: + verified: "[x]" # File exists, real implementation, tests exist + partial: "[~]" # File exists but stub/TODO or no tests + missing: "[ ]" # File does not exist + +defaults: + update_sprint_status: true + create_report: false + + + +@patterns/verification.md +@patterns/hospital-grade.md + + + + + +**Identify story and load context** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” STORY REGENERATION WITH GAP ANALYSIS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**Ask user for story:** +``` +Which story should I regenerate with gap analysis? + +Provide: +- Story number (e.g., "1.9" or "1-9") +- OR story filename + +Your choice: +``` + +**Parse input:** +- Extract epic_num, story_num +- Locate story file + +**Load existing story:** +```bash +Read: {{story_dir}}/story-{{epic_num}}.{{story_num}}.md +``` + +Extract: +- Story title +- User story (As a... I want... So that...) +- Acceptance criteria +- Tasks +- Dev Notes + +**Load epic context:** +```bash +Read: {{planning_artifacts}}/epics.md +``` + +Extract: +- Epic business objectives +- Technical constraints +- Dependencies + +**Determine target directories:** +From story title/requirements, identify which directories to scan. + +``` +βœ… Story Context Loaded + +Story: {{epic_num}}.{{story_num}} - {{title}} +Target directories: +{{#each directories}} + - {{this}} +{{/each}} + +[C] Continue to Codebase Scan +``` + + + +**VERIFY what code actually exists** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” CODEBASE SCAN +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**For each target directory:** + +1. **List all source files:** + ```bash + Glob: {{target_dir}}/src/**/*.ts + Glob: {{target_dir}}/src/**/*.tsx + ``` + +2. **Check for specific required components:** + Based on story ACs, check if required files exist: + ```bash + Glob: {{target_dir}}/src/auth/controllers/*oauth*.ts + # Result: βœ… EXISTS or ❌ MISSING + ``` + +3. **Verify implementation depth:** + For files that exist, check quality: + ```bash + Read: {{file}} + + # Check for stubs + Grep: "MOCK|TODO|FIXME|Not implemented" {{file}} + # If found: ⚠️ STUB + ``` + +4. **Check dependencies:** + ```bash + Read: {{target_dir}}/package.json + + # Required: axios - Found? βœ…/❌ + # Required: @aws-sdk/client-secrets-manager - Found? βœ…/❌ + ``` + +5. **Check test coverage:** + ```bash + Glob: {{target_dir}}/src/**/*.spec.ts + Glob: {{target_dir}}/test/**/*.test.ts + ``` + + + +**Create verified gap analysis** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“Š GAP ANALYSIS RESULTS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +βœ… IMPLEMENTED (Verified): +{{#each implemented}} +{{@index}}. **{{name}}** + - File: {{file}} βœ… EXISTS + - Status: {{status}} + - Tests: {{test_count}} tests +{{/each}} + +❌ MISSING (Verified): +{{#each missing}} +{{@index}}. **{{name}}** + - Expected: {{expected_file}} ❌ NOT FOUND + - Needed for: {{requirement}} +{{/each}} + +⚠️ PARTIAL (Stub/Incomplete): +{{#each partial}} +{{@index}}. **{{name}}** + - File: {{file}} βœ… EXISTS + - Issue: {{issue}} +{{/each}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + +**Generate story with verified checkboxes** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“ GENERATING STORY +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Use story template with: +- `[x]` for VERIFIED items (evidence: file exists, not stub, has tests) +- `[~]` for PARTIAL items (evidence: file exists but stub/no tests) +- `[ ]` for MISSING items (evidence: file not found) + +**Write story file:** +```bash +Write: {{story_dir}}/story-{{epic_num}}.{{story_num}}.md +``` + +**Validate generated story:** +```bash +# Check 7 sections exist +grep "^## " {{story_file}} | wc -l +# Should be 7 + +# Check gap analysis section exists +grep "Gap Analysis" {{story_file}} +``` + + + +**Update sprint-status.yaml** + +```bash +Read: {{sprint_status}} + +# Update story status to "ready-for-dev" if was "backlog" +# Preserve comments and structure + +Write: {{sprint_status}} +``` + + + +**Report completion** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… STORY REGENERATED WITH GAP ANALYSIS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{epic_num}}.{{story_num}} - {{title}} +File: {{story_file}} +Sections: 7/7 βœ… + +Gap Analysis Summary: +- βœ… {{implemented_count}} components VERIFIED complete +- ❌ {{missing_count}} components VERIFIED missing +- ⚠️ {{partial_count}} components PARTIAL (stub/no tests) + +Checkboxes reflect VERIFIED codebase state. + +Next Steps: +1. Review story for accuracy +2. Use /dev-story to implement missing components +3. Story provides complete context for implementation + +[N] Regenerate next story +[Q] Quit +[R] Review generated story +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**If [N]:** Loop back to initialize with next story. +**If [R]:** Display story content, then show menu. + + + + + +```bash +# Regenerate specific story +/create-story-with-gap-analysis +> Which story? 1.9 + +# With explicit story file +/create-story-with-gap-analysis story_file=docs/sprint-artifacts/story-1.9.md +``` + + + +**Story not found:** HALT with clear error. +**Target directory not found:** Warn, scan available directories. +**Glob/Read fails:** Log warning, count as MISSING. +**Write fails:** Report error, display generated content. + + + +- [ ] Codebase scanned for all story requirements +- [ ] Gap analysis generated with evidence +- [ ] Story written with verified checkboxes +- [ ] 7 sections present +- [ ] Sprint status updated (if enabled) + diff --git a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml index 19217943..d6297e95 100644 --- a/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml +++ b/src/modules/bmm/workflows/4-implementation/create-story-with-gap-analysis/workflow.yaml @@ -14,10 +14,9 @@ story_dir: "{implementation_artifacts}" # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/create-story-with-gap-analysis" -template: "{installed_path}/template.md" -instructions: "{installed_path}/step-01-initialize.md" +instructions: "{installed_path}/workflow.md" -# Variables and inputs +# Variables variables: sprint_status: "{implementation_artifacts}/sprint-status.yaml" epics_file: "{planning_artifacts}/epics.md" @@ -28,12 +27,6 @@ project_context: "**/project-context.md" default_output_file: "{story_dir}/{{story_key}}.md" -# Workflow steps (processed in order) -steps: - - step-01-initialize.md - - step-02-codebase-scan.md - - step-03-generate-story.md - standalone: true web_bundle: false diff --git a/src/modules/bmm/workflows/4-implementation/detect-ghost-features/instructions.md b/src/modules/bmm/workflows/4-implementation/detect-ghost-features/instructions.md deleted file mode 100644 index dc113271..00000000 --- a/src/modules/bmm/workflows/4-implementation/detect-ghost-features/instructions.md +++ /dev/null @@ -1,625 +0,0 @@ -# Detect Ghost Features - Reverse Gap Analysis (Who You Gonna Call?) - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml - - - - - Determine scan scope based on parameters: - - - Read {sprint_status} - Filter stories starting with "{{epic_number}}-" - Store as: stories_in_scope - πŸ” Scanning Epic {{epic_number}} stories for documented features... - - - - Read {sprint_status} - Get ALL story keys (exclude epics and retrospectives) - Store as: stories_in_scope - πŸ” Scanning entire sprint for documented features... - - - - Set stories_in_scope = ALL stories found in {sprint_artifacts} - πŸ” Scanning entire codebase for documented features... - - - For each story in stories_in_scope: - Read story file - Extract documented artifacts: - - File List (all paths mentioned) - - Tasks (all file/component/service names mentioned) - - ACs (all features/functionality mentioned) - Store in: documented_artifacts[story_key] = {files, components, services, apis, features} - - -βœ… Loaded {{stories_in_scope.length}} stories -πŸ“‹ Documented artifacts extracted from {{total_sections}} sections - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ‘» SCANNING FOR GHOST FEATURES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Looking for: Components, APIs, Services, DB Tables, Models -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Use Glob to find component files: - - **/*.component.{tsx,jsx,ts,js,vue} (Angular/Vue pattern) - - **/components/**/*.{tsx,jsx} (React pattern) - - **/src/**/*{Component,View,Screen,Page}.{tsx,jsx} (Named pattern) - - For each found component file: - Extract component name from filename or export - Check file size (ignore <50 lines as trivial) - Read file to determine if it's a significant feature - - Store as: codebase_components = [{name, path, size, purpose}] - - πŸ“¦ Found {{codebase_components.length}} components - - - - - - Use Glob to find API files: - - **/api/**/*.{ts,js} (Next.js/Express pattern) - - **/*.controller.{ts,js} (NestJS pattern) - - **/routes/**/*.{ts,js} (Generic routes) - - Use Grep to find endpoint definitions: - - @Get|@Post|@Put|@Delete decorators (NestJS) - - export async function GET|POST|PUT|DELETE (Next.js App Router) - - router.get|post|put|delete (Express) - - app.route (Flask/FastAPI if Python) - - For each endpoint found: - Extract: HTTP method, path, handler name - Read file to understand functionality - - Store as: codebase_apis = [{method, path, handler, file}] - - 🌐 Found {{codebase_apis.length}} API endpoints - - - - - - Use Glob to find schema files: - - **/prisma/schema.prisma (Prisma) - - **/*.entity.{ts,js} (TypeORM) - - **/models/**/*.{ts,js} (Mongoose/Sequelize) - - **/*-table.ts (Custom) - - Use Grep to find table definitions: - - model (Prisma) - - @Entity (TypeORM) - - createTable (Migrations) - - For each table found: - Extract: table name, columns, relationships - - Store as: codebase_tables = [{name, file, columns}] - - πŸ—„οΈ Found {{codebase_tables.length}} database tables - - - - - - Use Glob to find service files: - - **/*.service.{ts,js} - - **/services/**/*.{ts,js} - - **/*Service.{ts,js} - - For each service found: - Extract: service name, key methods, dependencies - Ignore trivial services (<100 lines) - - Store as: codebase_services = [{name, file, methods}] - - βš™οΈ Found {{codebase_services.length}} services - - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” CROSS-REFERENCING CODEBASE ↔ STORIES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Initialize: orphaned_features = [] - - - For each component in codebase_components: - - Search all stories for mentions of: - - Component name in File Lists - - Component name in Task descriptions - - Component file path in File Lists - - Feature described by component in ACs - - - Add to orphaned_features: - - type: "component" - name: {{component.name}} - path: {{component.path}} - size: {{component.size}} lines - purpose: {{inferred_purpose_from_code}} - severity: "HIGH" # Significant orphan - - πŸ‘» ORPHAN: {{component.name}} ({{component.path}}) - - - - βœ… Documented: {{component.name}} β†’ {{story_keys}} - - - - - For each API in codebase_apis: - - Search all stories for mentions of: - - Endpoint path (e.g., "/api/users") - - HTTP method + resource (e.g., "POST users") - - Handler file in File Lists - - API functionality in ACs (e.g., "Users can create account") - - - Add to orphaned_features: - - type: "api" - method: {{api.method}} - path: {{api.path}} - handler: {{api.handler}} - file: {{api.file}} - severity: "CRITICAL" # APIs are critical functionality - - πŸ‘» ORPHAN: {{api.method}} {{api.path}} ({{api.file}}) - - - - - For each table in codebase_tables: - - Search all stories for mentions of: - - Table name - - Migration file in File Lists - - Data model in Tasks - - - Add to orphaned_features: - - type: "database" - name: {{table.name}} - file: {{table.file}} - columns: {{table.columns.length}} - severity: "HIGH" # Database changes are significant - - πŸ‘» ORPHAN: Table {{table.name}} ({{table.file}}) - - - - - For each service in codebase_services: - - Search all stories for mentions of: - - Service name or class name - - Service file in File Lists - - Service functionality in Tasks/ACs - - - Add to orphaned_features: - - type: "service" - name: {{service.name}} - file: {{service.file}} - methods: {{service.methods.length}} - severity: "MEDIUM" # Services are business logic - - πŸ‘» ORPHAN: {{service.name}} ({{service.file}}) - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Cross-Reference Complete -πŸ‘» Orphaned Features: {{orphaned_features.length}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Group orphans by type and severity: - - - critical_orphans (APIs, auth, payment) - - high_orphans (Components, DB tables, services) - - medium_orphans (Utilities, helpers) - - low_orphans (Config files, constants) - - - Estimate complexity for each orphan: - Based on file size, dependencies, test coverage - - Suggest epic assignment based on functionality: - - Auth components β†’ Epic focusing on authentication - - UI components β†’ Epic focusing on frontend - - API endpoints β†’ Epic for that resource type - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ‘» GHOST FEATURES DETECTED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total Orphans:** {{orphaned_features.length}} - -**By Severity:** -- πŸ”΄ CRITICAL: {{critical_orphans.length}} (APIs, security-critical) -- 🟠 HIGH: {{high_orphans.length}} (Components, DB, services) -- 🟑 MEDIUM: {{medium_orphans.length}} (Utilities, helpers) -- 🟒 LOW: {{low_orphans.length}} (Config, constants) - -**By Type:** -- Components: {{component_orphans.length}} -- API Endpoints: {{api_orphans.length}} -- Database Tables: {{db_orphans.length}} -- Services: {{service_orphans.length}} -- Other: {{other_orphans.length}} - ---- - -**CRITICAL Orphans (Immediate Action Required):** -{{#each critical_orphans}} -{{@index + 1}}. **{{type | uppercase}}**: {{name}} - File: {{file}} - Purpose: {{inferred_purpose}} - Risk: {{why_critical}} - Suggested Epic: {{suggested_epic}} -{{/each}} - ---- - -**HIGH Priority Orphans:** -{{#each high_orphans}} -{{@index + 1}}. **{{type | uppercase}}**: {{name}} - File: {{file}} - Size: {{size}} lines / {{complexity}} complexity - Suggested Epic: {{suggested_epic}} -{{/each}} - ---- - -**Detection Confidence:** -- Artifacts scanned: {{total_artifacts_scanned}} -- Stories cross-referenced: {{stories_in_scope.length}} -- Documentation coverage: {{documented_pct}}% -- Orphan rate: {{orphan_rate}}% - -{{#if orphan_rate > 20}} -⚠️ **HIGH ORPHAN RATE** - Over 20% of codebase is undocumented! -Recommend: Comprehensive backfill story creation session -{{/if}} - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - -Backfill story creation disabled. To create stories for orphans, run: -/detect-ghost-features create_backfill_stories=true - - Jump to Step 7 (Generate Report) - - - - βœ… No orphans found - all code is documented in stories! - Jump to Step 7 - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“ PROPOSING BACKFILL STORIES ({{orphaned_features.length}}) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each orphaned feature (prioritized by severity): - - - Analyze orphan to understand functionality: - - Read implementation code - - Identify dependencies and related files - - Determine what it does (infer from code) - - Find tests (if any) to understand use cases - - Generate story draft: - -Story Title: "Document existing {{name}} {{type}}" - -Story Description: -This is a BACKFILL STORY documenting existing functionality found in the codebase -that was not tracked in any story (likely vibe-coded or manually added). - -Business Context: -{{inferred_business_purpose_from_code}} - -Current State: -βœ… **Implementation EXISTS:** {{file}} -- {{description_of_what_it_does}} -- {{key_features_or_methods}} -{{#if has_tests}}βœ… Tests exist: {{test_files}}{{else}}❌ No tests found{{/if}} - -Acceptance Criteria: -{{#each inferred_acs_from_code}} -- [ ] {{this}} -{{/each}} - -Tasks: -- [x] {{name}} implementation (ALREADY EXISTS - {{file}}) -{{#if missing_tests}}- [ ] Add tests for {{name}}{{/if}} -{{#if missing_docs}}- [ ] Add documentation for {{name}}{{/if}} -- [ ] Verify functionality works as expected -- [ ] Add to relevant epic or create new epic for backfills - -Definition of Done: -- [x] Implementation exists and works -{{#if has_tests}}- [x] Tests exist{{else}}- [ ] Tests added{{/if}} -- [ ] Documented in story (this story) -- [ ] Assigned to appropriate epic - -Story Type: BACKFILL (documenting existing code) - - - -πŸ“„ Generated backfill story draft for: {{name}} - -{{story_draft_preview}} - ---- - - - - - - Create backfill story automatically - βœ… Auto-created: {{story_filename}} - - - - -Create backfill story for {{name}}? - -**Type:** {{type}} -**File:** {{file}} -**Suggested Epic:** {{suggested_epic}} -**Complexity:** {{complexity_estimate}} - -[Y] Yes - Create this backfill story -[A] Auto - Create this and all remaining backfill stories -[E] Edit - Let me adjust the story draft first -[S] Skip - Don't create story for this orphan -[H] Halt - Stop backfill story creation - -Your choice: - - - - Create backfill story file: {sprint_artifacts}/backfill-{{type}}-{{name}}.md - Add to backfill_stories_created list - βœ… Created: {{story_filename}} - - - - Set auto_create = true - Create this story and auto-create remaining - - - - Provide your adjusted story content or instructions for modifications: - Apply user's edits to story draft - Create modified backfill story - - - - Add to skipped_backfills list - ⏭️ Skipped - - - - Exit backfill story creation loop - Jump to Step 6 - - - - - - Load {sprint_status} file - - For each created backfill story: - Add entry: {{backfill_story_key}}: backlog # BACKFILL - documents existing {{name}} - - Save sprint-status.yaml - - βœ… Added {{backfill_stories_created.length}} backfill stories to sprint-status.yaml - - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š BACKFILL STORY ORGANIZATION -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Group backfill stories by suggested epic: - - For each suggested_epic: - -**{{suggested_epic}}:** -{{#each backfill_stories_for_epic}} - - {{story_key}}: {{name}} ({{type}}) -{{/each}} - - - ---- - -**Recommendations:** - -1. **Option A: Create "Epic-Backfill" for all orphans** - - Single epic containing all backfill stories - - Easy to track undocumented code - - Clear separation from feature work - -2. **Option B: Distribute to existing epics** - - Add each backfill story to its logical epic - - Better thematic grouping - - May inflate epic story counts - -3. **Option C: Leave in backlog** - - Don't assign to epics yet - - Review and assign during next planning - -**Your choice:** -[A] Create Epic-Backfill (recommended) -[B] Distribute to existing epics -[C] Leave in backlog for manual assignment -[S] Skip epic assignment - - - How should backfill stories be organized? - - - Create epic-backfill.md in epics directory - Update sprint-status.yaml with epic-backfill entry - Assign all backfill stories to epic-backfill - - - - For each backfill story: - Assign to suggested_epic in sprint-status.yaml - Update story_key to match epic (e.g., 2-11-backfill-userprofile) - - - - Leave stories in backlog - - - - - - - Write report to: {sprint_artifacts}/ghost-features-report-{{timestamp}}.md - - Report structure: - -# Ghost Features Report (Reverse Gap Analysis) - -**Generated:** {{timestamp}} -**Scope:** {{scan_scope}} {{#if epic_number}}(Epic {{epic_number}}){{/if}} - -## Executive Summary - -**Codebase Artifacts Scanned:** {{total_artifacts_scanned}} -**Stories Cross-Referenced:** {{stories_in_scope.length}} -**Orphaned Features Found:** {{orphaned_features.length}} -**Documentation Coverage:** {{documented_pct}}% -**Backfill Stories Created:** {{backfill_stories_created.length}} - -## Orphaned Features Detail - -### CRITICAL Orphans ({{critical_orphans.length}}) -[Full list with files, purposes, risks] - -### HIGH Priority Orphans ({{high_orphans.length}}) -[Full list] - -### MEDIUM Priority Orphans ({{medium_orphans.length}}) -[Full list] - -## Backfill Stories Created - -{{#each backfill_stories_created}} -- {{story_key}}: {{story_file}} -{{/each}} - -## Recommendations - -[Epic assignment suggestions, next steps] - -## Appendix: Scan Methodology - -[How detection worked, patterns used, confidence levels] - - - πŸ“„ Full report: {{report_path}} - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… GHOST FEATURE DETECTION COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Scan Scope:** {{scan_scope}} {{#if epic_number}}(Epic {{epic_number}}){{/if}} - -**Results:** -- πŸ‘» Orphaned Features: {{orphaned_features.length}} -- πŸ“ Backfill Stories Created: {{backfill_stories_created.length}} -- ⏭️ Skipped: {{skipped_backfills.length}} -- πŸ“Š Documentation Coverage: {{documented_pct}}% - -{{#if orphaned_features.length == 0}} -βœ… **EXCELLENT!** All code is documented in stories. -Your codebase and story backlog are in perfect sync. -{{/if}} - -{{#if orphaned_features.length > 0 AND backfill_stories_created.length == 0}} -**Action Required:** -Run with create_backfill_stories=true to generate stories for orphans -{{/if}} - -{{#if backfill_stories_created.length > 0}} -**Next Steps:** - -1. **Review backfill stories** - Check generated stories for accuracy -2. **Assign to epics** - Organize backfills (or create Epic-Backfill) -3. **Update sprint-status.yaml** - Already updated with {{backfill_stories_created.length}} new entries -4. **Prioritize** - Decide when to implement tests/docs for orphans -5. **Run revalidation** - Verify orphans work as expected - -**Quick Commands:** -```bash -# Revalidate a backfill story to verify functionality -/revalidate-story story_file={{backfill_stories_created[0].file}} - -# Process backfill stories (add tests/docs) -/batch-super-dev filter_by_epic=backfill -``` -{{/if}} - -{{#if create_report}} -**Detailed Report:** {{report_path}} -{{/if}} - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -πŸ’‘ **Pro Tip:** Run this periodically (e.g., end of each sprint) to catch -vibe-coded features before they become maintenance nightmares. -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - diff --git a/src/modules/bmm/workflows/4-implementation/gap-analysis/instructions.xml b/src/modules/bmm/workflows/4-implementation/gap-analysis/instructions.xml deleted file mode 100644 index 4af6db50..00000000 --- a/src/modules/bmm/workflows/4-implementation/gap-analysis/instructions.xml +++ /dev/null @@ -1,367 +0,0 @@ - - The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml - You MUST have already loaded and processed: {installed_path}/workflow.yaml - Communicate all responses in {communication_language} - - - - Use {{story_file}} directly - Read COMPLETE story file - Extract story_key from filename or metadata - - - - - πŸ” **Gap Analysis - Story Task Validation** - - This workflow validates story tasks against your actual codebase. - - **Use Cases:** - - Audit "done" stories to verify they match reality - - Validate story tasks before starting development - - Check if completed work was actually implemented - - **Provide story to validate:** - - - Enter story file path, story key (e.g., "1-2-auth"), or status to scan (e.g., "done", "review", "in-progress"): - - - Use provided file path as {{story_file}} - Read COMPLETE story file - Extract story_key from filename - - - - - Search {story_dir} for file matching pattern {{story_key}}.md - Set {{story_file}} to found file path - Read COMPLETE story file - - - - - πŸ”Ž Scanning sprint-status.yaml for stories with status: {{user_input}}... - - - Load the FULL file: {{sprint_status}} - Parse development_status section - Find all stories where status equals {{user_input}} - - - πŸ“‹ No stories found with status: {{user_input}} - - Available statuses: backlog, ready-for-dev, in-progress, review, done - - HALT - - - - Found {{count}} stories with status {{user_input}}: - - {{list_of_stories}} - - Which story would you like to validate? [Enter story key or 'all']: - - - Set {{batch_mode}} = true - Store list of all story keys to validate - Set {{story_file}} to first story in list - Read COMPLETE story file - - - - - Set {{story_file}} to selected story path - Read COMPLETE story file - - - - - - Set {{story_file}} to found story path - Read COMPLETE story file - - - - - - ⚠️ No sprint-status.yaml found. Please provide direct story file path. - HALT - - - - - - - - πŸ” CODEBASE REALITY CHECK - Validate tasks against actual code! - - πŸ“Š **Analyzing Story: {{story_key}}** - - Scanning codebase to validate tasks... - - - - Parse story sections: Story, Acceptance Criteria, Tasks/Subtasks, Dev Notes, Status - Extract all tasks and subtasks from story file - Identify technical areas mentioned in tasks (files, classes, functions, services, components) - - - Determine scan targets from task descriptions: - - For "Create X" tasks: Check if X already exists - - For "Implement Y" tasks: Search for Y functionality - - For "Add Z" tasks: Verify Z is missing - - For test tasks: Check for existing test files - - Use Glob to find relevant files matching patterns from tasks (e.g., **/*.ts, **/*.tsx, **/*.test.ts) - Use Grep to search for specific classes, functions, or components mentioned in tasks - Use Read to verify implementation details and functionality in key discovered files - - - Document scan results: - - **CODEBASE REALITY:** - βœ… What Exists: - - List verified files, classes, functions, services found - - Note implementation completeness (partial vs full) - - Identify code that tasks claim to create but already exists - - - ❌ What's Missing: - - List features mentioned in tasks but NOT found in codebase - - Identify claimed implementations that don't exist - - Note tasks marked complete but code missing - - - - For each task in the story, determine: - - ACCURATE: Task matches reality (code exists if task is checked, missing if unchecked) - - FALSE POSITIVE: Task checked [x] but code doesn't exist (BS detection!) - - FALSE NEGATIVE: Task unchecked [ ] but code already exists - - NEEDS UPDATE: Task description doesn't match current implementation - - Generate validation report with: - - Tasks that are accurate - - Tasks that are false positives (marked done but not implemented) ⚠️ - - Tasks that are false negatives (not marked but already exist) - - Recommended task updates - - - - πŸ“‹ SHOW TRUTH - Compare story claims vs codebase reality - - - πŸ“Š **Gap Analysis Results: {{story_key}}** - - **Story Status:** {{story_status}} - - --- - - **Codebase Scan Results:** - - βœ… **What Actually Exists:** - {{list_of_existing_files_features_with_details}} - - ❌ **What's Actually Missing:** - {{list_of_missing_elements_despite_claims}} - - --- - - **Task Validation:** - - {{if_any_accurate_tasks}} - βœ… **Accurate Tasks** ({{count}}): - {{list_tasks_that_match_reality}} - {{endif}} - - {{if_any_false_positives}} - ⚠️ **FALSE POSITIVES** ({{count}}) - Marked done but NOT implemented: - {{list_tasks_marked_complete_but_code_missing}} - **WARNING:** These tasks claim completion but code doesn't exist! - {{endif}} - - {{if_any_false_negatives}} - ℹ️ **FALSE NEGATIVES** ({{count}}) - Not marked but ALREADY exist: - {{list_tasks_unchecked_but_code_exists}} - {{endif}} - - {{if_any_needs_update}} - πŸ”„ **NEEDS UPDATE** ({{count}}) - Task description doesn't match implementation: - {{list_tasks_needing_description_updates}} - {{endif}} - - --- - - πŸ“ **Proposed Story Updates:** - - {{if_false_positives_found}} - **CRITICAL - Uncheck false positives:** - {{list_tasks_to_uncheck_with_reasoning}} - {{endif}} - - {{if_false_negatives_found}} - **Check completed work:** - {{list_tasks_to_check_with_verification}} - {{endif}} - - {{if_task_updates_needed}} - **Update task descriptions:** - {{list_task_description_updates}} - {{endif}} - - {{if_gap_analysis_section_missing}} - **Add Gap Analysis section** documenting findings - {{endif}} - - --- - - **Story Accuracy Score:** {{percentage_of_accurate_tasks}}% ({{accurate_count}}/{{total_count}}) - - - - - - 🚨 **WARNING:** This story is marked {{story_status}} but has FALSE POSITIVES! - - {{count}} task(s) claim completion but code doesn't exist. - This story may have been prematurely marked complete. - - **Recommendation:** Update story status to 'in-progress' and complete missing work. - - - - - - - **What would you like to do?** - - Options: - [U] Update - Apply proposed changes to story file - [A] Audit Report - Save findings to report file without updating story - [N] No Changes - Just show me the findings - [R] Review Details - Show me more details about specific findings - [C] Continue to Next - Move to next story (batch mode only) - [Q] Quit - Exit gap analysis - - - - - Update story file with proposed changes: - - Uncheck false positive tasks - - Check false negative tasks - - Update task descriptions as needed - - Add or update "Gap Analysis" section with findings - - Add Change Log entry: "Gap analysis performed - tasks validated against codebase ({{date}})" - - - Story has false positives. Update status to 'in-progress'? [Y/n]: - - Update story Status to 'in-progress' - - Update sprint-status.yaml status for this story to 'in-progress' - - - - - βœ… Story file updated with gap analysis findings. - - - {{changes_count}} task(s) updated - - Gap Analysis section added/updated - - Accuracy score: {{accuracy_percentage}}% - - **File:** {{story_file}} - - - - Continue to next story? [Y/n]: - - Load next story from batch list - Analyze next story - - - - HALT - Gap analysis complete - - - - - Generate audit report file: {{story_dir}}/gap-analysis-report-{{story_key}}-{{date}}.md - Include full findings, accuracy scores, recommendations - πŸ“„ Audit report saved: {{report_file}} - - This report can be shared with team for review. - Story file was NOT modified. - - - - Continue to next story? [Y/n]: - - Load next story from batch list - Analyze next story - - - - HALT - Gap analysis complete - - - - - ℹ️ Findings displayed only. No files modified. - HALT - Gap analysis complete - - - - - Which findings would you like more details about? (specify task numbers, file names, or areas): - Provide detailed analysis of requested areas using Read tool for deeper code inspection - After review, re-present the decision options - Continue based on user's subsequent choice - - - - - Load next story from batch list - Analyze next story - - - - ⚠️ Not in batch mode. Only one story to validate. - HALT - - - - - πŸ‘‹ Gap analysis session ended. - - {{if batch_mode}}Processed {{processed_count}}/{{total_count}} stories.{{endif}} - - HALT - - - - - βœ… **Gap Analysis Complete, {user_name}!** - - {{if_single_story}} - **Story Analyzed:** {{story_key}} - **Accuracy Score:** {{accuracy_percentage}}% - **Actions Taken:** {{actions_summary}} - {{endif}} - - {{if_batch_mode}} - **Batch Analysis Summary:** - - Stories analyzed: {{processed_count}} - - Average accuracy: {{avg_accuracy}}% - - False positives found: {{total_false_positives}} - - Stories updated: {{updated_count}} - {{endif}} - - **Next Steps:** - - Review updated stories - - Address any false positives found - - Run dev-story for stories needing work - - - - diff --git a/src/modules/bmm/workflows/4-implementation/gap-analysis/workflow.md b/src/modules/bmm/workflows/4-implementation/gap-analysis/workflow.md new file mode 100644 index 00000000..c672b0be --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/gap-analysis/workflow.md @@ -0,0 +1,246 @@ +# Gap Analysis v3.0 - Verify Story Tasks Against Codebase + + +Validate story checkbox claims against actual codebase reality. +Find false positives (checked but not done) and false negatives (done but unchecked). +Interactive workflow with options to update, audit, or review. + + + +**Evidence-Based Verification** + +Checkboxes lie. Code doesn't. +- Search codebase for implementation evidence +- Check for stubs, TODOs, empty functions +- Verify tests exist for claimed features +- Report accuracy of story completion claims + + + +name: gap-analysis +version: 3.0.0 + +defaults: + auto_update: false + create_audit_report: true + strict_mode: false # If true, stubs count as incomplete + +output: + update_story: "Modify checkbox state to match reality" + audit_report: "Generate detailed gap analysis document" + no_changes: "Display results only" + + + +@patterns/verification.md +@patterns/hospital-grade.md + + + + + +**Load and parse story file** + +```bash +STORY_FILE="{{story_file}}" +[ -f "$STORY_FILE" ] || { echo "❌ story_file required"; exit 1; } +``` + +Use Read tool on story file. Extract: +- All `- [ ]` and `- [x]` items +- File references from Dev Agent Record +- Task descriptions with expected artifacts + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” GAP ANALYSIS: {{story_key}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Tasks: {{total_tasks}} +Currently checked: {{checked_count}} +``` + + + +**Verify each task against codebase** + +For each task item: + +1. **Extract artifacts** - File names, component names, function names +2. **Search codebase:** + ```bash + # Check file exists + Glob: {{expected_file}} + + # Check function/component exists + Grep: "{{function_or_component_name}}" + ``` + +3. **If file exists, check quality:** + ```bash + # Check for stubs + Grep: "TODO|FIXME|Not implemented|throw new Error" {{file}} + + # Check for tests + Glob: {{file_base}}.test.* OR {{file_base}}.spec.* + ``` + +4. **Determine status:** + - **VERIFIED:** File exists, not a stub, tests exist + - **PARTIAL:** File exists but stub/TODO or no tests + - **MISSING:** File does not exist + + + +**Compare claimed vs actual** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“Š GAP ANALYSIS RESULTS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Tasks analyzed: {{total}} + +By Status: +- βœ… Verified Complete: {{verified}} ({{verified_pct}}%) +- ⚠️ Partial: {{partial}} ({{partial_pct}}%) +- ❌ Missing: {{missing}} ({{missing_pct}}%) + +Accuracy Analysis: +- Checked & Verified: {{correct_checked}} +- Checked but MISSING: {{false_positives}} ← FALSE POSITIVES +- Unchecked but DONE: {{false_negatives}} ← FALSE NEGATIVES + +Checkbox Accuracy: {{accuracy}}% +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**If false positives found:** +``` +⚠️ FALSE POSITIVES DETECTED +The following tasks are marked done but code is missing: + +{{#each false_positives}} +- [ ] {{task}} β€” Expected: {{expected_file}} β€” ❌ NOT FOUND +{{/each}} +``` + + + +**Ask user how to proceed** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“‹ OPTIONS +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +[U] Update - Fix checkboxes to match reality +[A] Audit Report - Generate detailed report file +[N] No Changes - Display only (already done) +[R] Review Details - Show full evidence for each task + +Your choice: +``` + + + +**Update story file checkboxes** + +For false positives: +- Change `[x]` to `[ ]` for tasks with missing code + +For false negatives: +- Change `[ ]` to `[x]` for tasks with verified code + +Use Edit tool to make changes. + +``` +βœ… Story checkboxes updated +- {{fp_count}} false positives unchecked +- {{fn_count}} false negatives checked +- New completion: {{new_pct}}% +``` + + + +**Generate audit report** + +Write to: `{{story_dir}}/gap-analysis-{{story_key}}-{{timestamp}}.md` + +Include: +- Executive summary +- Detailed task-by-task evidence +- False positive/negative lists +- Recommendations + +``` +βœ… Audit report generated: {{report_path}} +``` + + + +**Show detailed evidence** + +For each task: +``` +Task: {{task_text}} +Checkbox: {{checked_state}} +Evidence: + - File: {{file}} - {{exists ? "βœ… EXISTS" : "❌ MISSING"}} + {{#if exists}} + - Stub check: {{is_stub ? "⚠️ STUB DETECTED" : "βœ… Real implementation"}} + - Tests: {{has_tests ? "βœ… Tests exist" : "❌ No tests"}} + {{/if}} +Verdict: {{status}} +``` + +After review, return to options menu. + + + +**Display completion** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… GAP ANALYSIS COMPLETE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{story_key}} +Verified Completion: {{verified_pct}}% +Checkbox Accuracy: {{accuracy}}% + +{{#if updated}} +βœ… Checkboxes updated to match reality +{{/if}} + +{{#if report_generated}} +πŸ“„ Report: {{report_path}} +{{/if}} + +{{#if false_positives > 0}} +⚠️ {{false_positives}} tasks need implementation work +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + + + +```bash +# Quick gap analysis of single story +/gap-analysis story_file=docs/sprint-artifacts/2-5-auth.md + +# With auto-update enabled +/gap-analysis story_file=docs/sprint-artifacts/2-5-auth.md auto_update=true +``` + + + +**Story file not found:** HALT with clear error. +**Search fails:** Log warning, count as MISSING. +**Edit fails:** Report error, suggest manual update. + + + +- [ ] All tasks verified against codebase +- [ ] False positives/negatives identified +- [ ] Accuracy metrics calculated +- [ ] User choice executed (update/audit/review) + diff --git a/src/modules/bmm/workflows/4-implementation/gap-analysis/workflow.yaml b/src/modules/bmm/workflows/4-implementation/gap-analysis/workflow.yaml index 88417f98..07eea0a2 100644 --- a/src/modules/bmm/workflows/4-implementation/gap-analysis/workflow.yaml +++ b/src/modules/bmm/workflows/4-implementation/gap-analysis/workflow.yaml @@ -11,7 +11,7 @@ story_dir: "{implementation_artifacts}" # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/gap-analysis" -instructions: "{installed_path}/instructions.xml" +instructions: "{installed_path}/workflow.md" # Variables story_file: "" # User provides story file path or auto-discover diff --git a/src/modules/bmm/workflows/4-implementation/migrate-to-github/instructions.md b/src/modules/bmm/workflows/4-implementation/migrate-to-github/instructions.md deleted file mode 100644 index d3ccab25..00000000 --- a/src/modules/bmm/workflows/4-implementation/migrate-to-github/instructions.md +++ /dev/null @@ -1,957 +0,0 @@ -# Migrate to GitHub - Production-Grade Story Migration - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml -RELIABILITY FIRST: This workflow prioritizes data integrity over speed - - - - - MUST verify all prerequisites before ANY migration operations - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ›‘οΈ PRE-FLIGHT SAFETY CHECKS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - Test GitHub MCP connection: - Call: mcp__github__get_me() - - - -❌ CRITICAL: GitHub MCP not accessible - -Cannot proceed with migration without GitHub API access. - -Possible causes: -- GitHub MCP server not configured -- Authentication token missing or invalid -- Network connectivity issues - -Fix: -1. Ensure GitHub MCP is configured in Claude settings -2. Verify token has required permissions: - - repo (full control) - - write:discussion (for comments) -3. Test connection: Try any GitHub MCP command - -HALTING - Cannot migrate without GitHub access. - - HALT - - - Extract current user info: - - username: {{user.login}} - - user_id: {{user.id}} - - βœ… GitHub MCP connected (@{{username}}) - - - - Verify github_owner and github_repo parameters provided - - - -❌ ERROR: GitHub repository not specified - -Required parameters: - github_owner: GitHub username or organization - github_repo: Repository name - -Usage: - /migrate-to-github github_owner=jschulte github_repo=myproject - /migrate-to-github github_owner=jschulte github_repo=myproject mode=execute - -HALTING - - HALT - - - Test repository access: - Call: mcp__github__list_issues({ - owner: {{github_owner}}, - repo: {{github_repo}}, - per_page: 1 - }) - - - -❌ CRITICAL: Cannot access repository {{github_owner}}/{{github_repo}} - -Possible causes: -- Repository doesn't exist -- Token lacks access to this repository -- Repository is private and token doesn't have permission - -Verify: -1. Repository exists: -2. Token has write access to issues -3. Repository name is spelled correctly - -HALTING - - HALT - - - βœ… Repository accessible ({{github_owner}}/{{github_repo}}) - - - - Check sprint-status.yaml exists: - test -f {{sprint_status}} - - - -❌ ERROR: sprint-status.yaml not found at {{sprint_status}} - -Cannot migrate without sprint status file. - -Run /sprint-planning to generate it first. - -HALTING - - HALT - - - Read and parse sprint-status.yaml - Count total stories to migrate - - βœ… Found {{total_stories}} stories in sprint-status.yaml - - Verify story files exist: - For each story, try multiple naming patterns to find file - - Report: - -πŸ“Š Story File Status: -- βœ… Files found: {{stories_with_files}} -- ❌ Files missing: {{stories_without_files}} -{{#if stories_without_files > 0}} - Missing: {{missing_story_keys}} -{{/if}} - - - - -⚠️ {{stories_without_files}} stories have no files - -Options: -[C] Continue (only migrate stories with files) -[S] Skip these stories (add to skip list) -[H] Halt (fix missing files first) - -Choice: - - - - HALT - - - - - - Check if state file exists: {{state_file}} - - - Read migration state - Extract: stories_migrated, issues_created, last_completed, timestamp - - -⚠️ Previous migration detected - -Last migration: -- Date: {{migration_timestamp}} -- Stories migrated: {{stories_migrated.length}} -- Issues created: {{issues_created.length}} -- Last completed: {{last_completed}} -- Status: {{migration_status}} - -Options: -[R] Resume (continue from where it left off) -[F] Fresh (start over, may create duplicates if not careful) -[V] View (show what was migrated) -[D] Delete state (clear and start fresh) - -Choice: - - - How to proceed? - - - Set resume_mode = true - Load list of already-migrated stories - Filter them out from migration queue - βœ… Resuming from story: {{last_completed}} - - - - ⚠️ WARNING: Fresh start may create duplicate issues if stories were already migrated. - Confirm fresh start (will check for duplicates)? (yes/no): - - HALT - - - - - Display migration state details - Then re-prompt for choice - - - - Delete state file - Set resume_mode = false - βœ… State cleared - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… PRE-FLIGHT CHECKS PASSED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- GitHub MCP: Connected -- Repository: Accessible -- Sprint status: Loaded ({{total_stories}} stories) -- Story files: {{stories_with_files}} found -- Mode: {{mode}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - Skip to Step 2 (Execute mode) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” DRY-RUN MODE (Preview Only - No Changes) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -This will show what WOULD happen without actually creating issues. -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each story in sprint-status.yaml: - - For each story_key: - - - Search GitHub: mcp__github__search_issues({ - query: "repo:{{github_owner}}/{{github_repo}} label:story:{{story_key}}" - }) - - - would_update = {{update_existing}} - -πŸ“ Story {{story_key}}: - GitHub: Issue #{{existing_issue.number}} EXISTS - Action: {{#if would_update}}Would UPDATE{{else}}Would SKIP{{/if}} - Current labels: {{existing_issue.labels}} - Current assignee: {{existing_issue.assignee || "none"}} - - - - - would_create = true - Read local story file - Parse: title, ACs, tasks, epic, status - - -πŸ“ Story {{story_key}}: - GitHub: NOT FOUND - Action: Would CREATE - - Proposed Issue: - - Title: "Story {{story_key}}: {{parsed_title}}" - - Labels: type:story, story:{{story_key}}, status:{{status}}, epic:{{epic_number}}, complexity:{{complexity}} - - Milestone: Epic {{epic_number}} - - Acceptance Criteria: {{ac_count}} items - - Tasks: {{task_count}} items - - Assignee: {{#if status == 'in-progress'}}@{{infer_from_git_log}}{{else}}none{{/if}} - - - - - Count actions: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š DRY-RUN SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total Stories:** {{total_stories}} - -**Actions:** -- βœ… Would CREATE: {{would_create_count}} new issues -- πŸ”„ Would UPDATE: {{would_update_count}} existing issues -- ⏭️ Would SKIP: {{would_skip_count}} (existing, no update) - -**Epics/Milestones:** -- Would CREATE: {{epic_milestones_to_create.length}} milestones -- Already exist: {{epic_milestones_existing.length}} - -**Estimated API Calls:** -- Issue searches: {{total_stories}} (check existing) -- Issue creates: {{would_create_count}} -- Issue updates: {{would_update_count}} -- Milestone operations: {{milestone_operations}} -- **Total:** ~{{total_api_calls}} API calls - -**Rate Limit Impact:** -- Authenticated limit: 5000/hour -- This migration: ~{{total_api_calls}} calls -- Remaining after: ~{{5000 - total_api_calls}} -- Safe: {{#if total_api_calls < 1000}}YES{{else}}Borderline (consider smaller batches){{/if}} - -**Estimated Duration:** {{estimated_minutes}} minutes - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -⚠️ This was a DRY-RUN. No issues were created. - -To execute the migration: - /migrate-to-github mode=execute github_owner={{github_owner}} github_repo={{github_repo}} - -To migrate only Epic 2: - /migrate-to-github mode=execute filter_by_epic=2 github_owner={{github_owner}} github_repo={{github_repo}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Exit workflow (dry-run complete) - - - - - Skip to Step 3 (Verify mode) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -⚑ EXECUTE MODE (Migrating Stories to GitHub) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**SAFETY GUARANTEES:** -βœ… Idempotent - Can re-run safely (checks for duplicates) -βœ… Atomic - Each story fully succeeds or rolls back -βœ… Verified - Reads back each created issue -βœ… Resumable - Saves state after each story -βœ… Reversible - Creates rollback manifest -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - -⚠️ FINAL CONFIRMATION - -You are about to create ~{{would_create_count}} GitHub Issues. - -This operation: -- WILL create issues in {{github_owner}}/{{github_repo}} -- WILL modify your GitHub repository -- CAN be rolled back (we'll create rollback manifest) -- CANNOT be undone automatically after issues are created - -Have you: -- [ ] Run dry-run mode to preview? -- [ ] Verified repository is correct? -- [ ] Backed up sprint-status.yaml? -- [ ] Confirmed you want to proceed? - -Type "I understand and want to proceed" to continue: - - - - ❌ Migration cancelled - confirmation not received - HALT - - - Initialize migration state: - -migration_state = { - started_at: {{timestamp}}, - mode: "execute", - github_owner: {{github_owner}}, - github_repo: {{github_repo}}, - total_stories: {{total_stories}}, - stories_migrated: [], - issues_created: [], - issues_updated: [], - issues_failed: [], - rollback_manifest: [], - last_completed: null -} - - - Save initial state to {{state_file}} - - Initialize rollback manifest (for safety): - rollback_manifest = { - created_at: {{timestamp}}, - github_owner: {{github_owner}}, - github_repo: {{github_repo}}, - created_issues: [] # Will track issue numbers for rollback - } - - For each story in sprint-status.yaml: - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“¦ Migrating {{current_index}}/{{total_stories}}: {{story_key}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Read local story file - - - ⏭️ SKIP - No file found - Add to migration_state.issues_failed with reason: "File not found" - Continue to next story - - - Parse story file: - - Extract all 12 sections - - Parse Acceptance Criteria (convert to checkboxes) - - Parse Tasks (convert to checkboxes) - - Extract metadata: epic_number, complexity - - Check if issue already exists (idempotent check): - Call: mcp__github__search_issues({ - query: "repo:{{github_owner}}/{{github_repo}} label:story:{{story_key}}" - }) - - - βœ… EXISTS - Issue #{{existing_issue.number}} (skipping, update_existing=false) - Add to migration_state.stories_migrated (already done) - Continue to next story - - - - πŸ”„ EXISTS - Issue #{{existing_issue.number}} (updating) - - ATOMIC UPDATE with retry: - -attempt = 0 -max_attempts = {{max_retries}} + 1 - -WHILE attempt < max_attempts: - TRY: - # Update issue - result = mcp__github__issue_write({ - method: "update", - owner: {{github_owner}}, - repo: {{github_repo}}, - issue_number: {{existing_issue.number}}, - title: "Story {{story_key}}: {{parsed_title}}", - body: {{convertStoryToIssueBody(parsed)}}, - labels: {{generateLabels(story_key, status, parsed)}} - }) - - # Verify update succeeded (read back) - sleep 1 second # GitHub eventual consistency - - verification = mcp__github__issue_read({ - method: "get", - owner: {{github_owner}}, - repo: {{github_repo}}, - issue_number: {{existing_issue.number}} - }) - - # Check verification - IF verification.title != expected_title: - THROW "Write verification failed" - - # Success! - output: " βœ… UPDATED and VERIFIED - Issue #{{existing_issue.number}}" - BREAK - - CATCH error: - attempt++ - IF attempt < max_attempts: - sleep {{retry_backoff_ms[attempt]}} - output: " ⚠️ Retry {{attempt}}/{{max_retries}} after error: {{error}}" - ELSE: - output: " ❌ FAILED after {{max_retries}} retries: {{error}}" - add to migration_state.issues_failed - - IF halt_on_critical_error: - HALT - ELSE: - CONTINUE to next story - - - Add to migration_state.issues_updated - - - - πŸ†• CREATING new issue... - - Generate issue body from story file: - -issue_body = """ -**Story File:** [{{story_key}}.md]({{file_path_in_repo}}) -**Epic:** {{epic_number}} -**Complexity:** {{complexity}} ({{task_count}} tasks) - -## Business Context -{{parsed.businessContext}} - -## Acceptance Criteria -{{#each parsed.acceptanceCriteria}} -- [ ] AC{{@index + 1}}: {{this}} -{{/each}} - -## Tasks -{{#each parsed.tasks}} -- [ ] {{this}} -{{/each}} - -## Technical Requirements -{{parsed.technicalRequirements}} - -## Definition of Done -{{#each parsed.definitionOfDone}} -- [ ] {{this}} -{{/each}} - ---- -_Migrated from BMAD local files_ -_Sync timestamp: {{timestamp}}_ -_Local file: `{{story_file_path}}`_ -""" - - - Generate labels: - -labels = [ - "type:story", - "story:{{story_key}}", - "status:{{current_status}}", - "epic:{{epic_number}}", - "complexity:{{complexity}}" -] - -{{#if has_high_risk_keywords}} -labels.push("risk:high") -{{/if}} - - - ATOMIC CREATE with retry and verification: - -attempt = 0 - -WHILE attempt < max_attempts: - TRY: - # Create issue - created_issue = mcp__github__issue_write({ - method: "create", - owner: {{github_owner}}, - repo: {{github_repo}}, - title: "Story {{story_key}}: {{parsed_title}}", - body: {{issue_body}}, - labels: {{labels}} - }) - - issue_number = created_issue.number - - # CRITICAL: Verify creation succeeded (read back) - sleep 2 seconds # GitHub eventual consistency - - verification = mcp__github__issue_read({ - method: "get", - owner: {{github_owner}}, - repo: {{github_repo}}, - issue_number: {{issue_number}} - }) - - # Verify all fields - IF verification.title != expected_title: - THROW "Title mismatch after create" - - IF NOT verification.labels.includes("story:{{story_key}}"): - THROW "Story label missing after create" - - # Success - record for rollback capability - output: " βœ… CREATED and VERIFIED - Issue #{{issue_number}}" - - rollback_manifest.created_issues.push({ - story_key: {{story_key}}, - issue_number: {{issue_number}}, - created_at: {{timestamp}} - }) - - migration_state.issues_created.push({ - story_key: {{story_key}}, - issue_number: {{issue_number}} - }) - - BREAK - - CATCH error: - attempt++ - - # Check if issue was created despite error (orphaned issue) - check_result = mcp__github__search_issues({ - query: "repo:{{github_owner}}/{{github_repo}} label:story:{{story_key}}" - }) - - IF check_result.length > 0: - # Issue was created, verification failed - treat as success - output: " βœ… CREATED (verification had transient error)" - BREAK - - IF attempt < max_attempts: - sleep {{retry_backoff_ms[attempt]}} - output: " ⚠️ Retry {{attempt}}/{{max_retries}}" - ELSE: - output: " ❌ FAILED after {{max_retries}} retries: {{error}}" - - migration_state.issues_failed.push({ - story_key: {{story_key}}, - error: {{error}}, - attempts: {{attempt}} - }) - - IF halt_on_critical_error: - output: "HALTING - Critical error during migration" - save migration_state - HALT - ELSE: - output: "Continuing despite failure (continue_on_failure=true)" - CONTINUE to next story - - - - Update migration state: - migration_state.stories_migrated.push({{story_key}}) - migration_state.last_completed = {{story_key}} - - - Save migration state to {{state_file}} - Save rollback manifest to {{output_folder}}/migration-rollback-{{timestamp}}.yaml - - - - -πŸ“Š Progress: {{current_index}}/{{total_stories}} migrated - Created: {{issues_created.length}} - Updated: {{issues_updated.length}} - Failed: {{issues_failed.length}} - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… MIGRATION COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total:** {{total_stories}} stories processed -**Created:** {{issues_created.length}} new issues -**Updated:** {{issues_updated.length}} existing issues -**Failed:** {{issues_failed.length}} errors -**Duration:** {{actual_duration}} - -{{#if issues_failed.length > 0}} -**Failed Stories:** -{{#each issues_failed}} - - {{story_key}}: {{error}} -{{/each}} - -Recommendation: Fix errors and re-run migration (will skip already-migrated stories) -{{/if}} - -**Rollback Manifest:** {{rollback_manifest_path}} -(Use this file to delete created issues if needed) - -**State File:** {{state_file}} -(Tracks migration progress for resume capability) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Continue to Step 3 (Verify) - - - - - Skip to Step 4 - - - - -Migration complete. Run verification to double-check accuracy? (yes/no): - - - - Skip to Step 5 (Report) - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” VERIFICATION MODE (Double-Checking Migration) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Load migration state from {{state_file}} - - For each migrated story in migration_state.stories_migrated: - - Fetch issue from GitHub: - Search: label:story:{{story_key}} - - - ❌ VERIFICATION FAILED: {{story_key}} - Issue not found in GitHub - Add to verification_failures - - - - Verify fields match expected: - - Title contains story_key βœ“ - - Label "story:{{story_key}}" exists βœ“ - - Status label matches sprint-status.yaml βœ“ - - AC count matches local file βœ“ - - - βœ… VERIFIED: {{story_key}} β†’ Issue #{{issue_number}} - - - - ⚠️ MISMATCH: {{story_key}} β†’ Issue #{{issue_number}} - Expected: {{expected}} - Actual: {{actual}} - Add to verification_warnings - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š VERIFICATION RESULTS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories Checked:** {{stories_migrated.length}} -**βœ… Verified Correct:** {{verified_count}} -**⚠️ Warnings:** {{verification_warnings.length}} -**❌ Failures:** {{verification_failures.length}} - -{{#if verification_failures.length > 0}} -**Verification Failures:** -{{#each verification_failures}} - - {{this}} -{{/each}} - -❌ Migration has errors - issues may be missing or incorrect -{{else}} -βœ… All migrated stories verified in GitHub -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - Skip to Step 5 (Report) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -⚠️ ROLLBACK MODE (Delete Migrated Issues) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Load rollback manifest from {{output_folder}}/migration-rollback-*.yaml - - - -❌ ERROR: No rollback manifest found - -Cannot rollback without manifest file. -Rollback manifests are in: {{output_folder}}/migration-rollback-*.yaml - -HALTING - - HALT - - - -**Rollback Manifest:** -- Created: {{manifest.created_at}} -- Repository: {{manifest.github_owner}}/{{manifest.github_repo}} -- Issues to delete: {{manifest.created_issues.length}} - -**WARNING:** This will PERMANENTLY DELETE these issues from GitHub: -{{#each manifest.created_issues}} - - Issue #{{issue_number}}: {{story_key}} -{{/each}} - -This operation CANNOT be undone! - - - -Type "DELETE ALL ISSUES" to proceed with rollback: - - - - ❌ Rollback cancelled - HALT - - - For each issue in manifest.created_issues: - - Delete issue (GitHub API doesn't support delete, so close + lock): - -# GitHub doesn't allow issue deletion via API -# Best we can do: close, lock, and add label "migrated:rolled-back" - -mcp__github__issue_write({ - method: "update", - issue_number: {{issue_number}}, - state: "closed", - labels: ["migrated:rolled-back", "do-not-use"], - state_reason: "not_planned" -}) - -# Add comment explaining -mcp__github__add_issue_comment({ - issue_number: {{issue_number}}, - body: "Issue closed - migration was rolled back. Do not use." -}) - - - βœ… Rolled back: Issue #{{issue_number}} - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… ROLLBACK COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Issues Rolled Back:** {{manifest.created_issues.length}} - -Note: GitHub API doesn't support issue deletion. -Issues were closed with label "migrated:rolled-back" instead. - -To fully delete (manual): -1. Go to repository settings -2. Issues β†’ Delete closed issues -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Calculate final statistics: - -final_stats = { - total_stories: {{total_stories}}, - migrated_successfully: {{issues_created.length + issues_updated.length}}, - failed: {{issues_failed.length}}, - success_rate: ({{migrated_successfully}} / {{total_stories}}) * 100, - duration: {{end_time - start_time}}, - avg_time_per_story: {{duration / total_stories}} -} - - - - Write comprehensive report to {{report_path}} - - Report structure: - -# GitHub Migration Report - -**Date:** {{timestamp}} -**Repository:** {{github_owner}}/{{github_repo}} -**Mode:** {{mode}} - -## Executive Summary - -- **Total Stories:** {{total_stories}} -- **βœ… Migrated:** {{migrated_successfully}} ({{success_rate}}%) -- **❌ Failed:** {{failed}} -- **Duration:** {{duration}} -- **Avg per story:** {{avg_time_per_story}} - -## Created Issues - -{{#each issues_created}} -- Story {{story_key}} β†’ Issue #{{issue_number}} - URL: -{{/each}} - -## Updated Issues - -{{#each issues_updated}} -- Story {{story_key}} β†’ Issue #{{issue_number}} (updated) -{{/each}} - -## Failed Migrations - -{{#if issues_failed.length > 0}} -{{#each issues_failed}} -- Story {{story_key}}: {{error}} - Attempts: {{attempts}} -{{/each}} - -**Recovery Steps:** -1. Fix underlying issues (check error messages) -2. Re-run migration (will skip already-migrated stories) -{{else}} -None - all stories migrated successfully! -{{/if}} - -## Rollback Information - -**Rollback Manifest:** {{rollback_manifest_path}} - -To rollback this migration: -```bash -/migrate-to-github mode=rollback -``` - -## Next Steps - -1. **Verify migration:** /migrate-to-github mode=verify -2. **Test story checkout:** /checkout-story story_key=2-5-auth -3. **Enable GitHub sync:** Update workflow.yaml with github_sync_enabled=true -4. **Product Owner setup:** Share GitHub Issues URL with PO team - -## Migration Details - -**API Calls Made:** ~{{total_api_calls}} -**Rate Limit Used:** {{api_calls_used}}/5000 -**Errors Encountered:** {{error_count}} -**Retries Performed:** {{retry_count}} - ---- -_Generated by BMAD migrate-to-github workflow_ - - - πŸ“„ Migration report: {{report_path}} - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… MIGRATION WORKFLOW COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Mode:** {{mode}} -**Success Rate:** {{success_rate}}% - -{{#if mode == 'execute'}} -**βœ… {{migrated_successfully}} stories now in GitHub Issues** - -View in GitHub: - - -**Next Steps:** -1. Verify migration: /migrate-to-github mode=verify -2. Test workflows with GitHub sync enabled -3. Share Issues URL with Product Owner team - -{{#if issues_failed.length > 0}} -⚠️ {{issues_failed.length}} stories failed - re-run to retry -{{/if}} -{{/if}} - -{{#if mode == 'dry-run'}} -**This was a preview. No issues were created.** - -To execute: /migrate-to-github mode=execute -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - diff --git a/src/modules/bmm/workflows/4-implementation/multi-agent-review/instructions.md b/src/modules/bmm/workflows/4-implementation/multi-agent-review/instructions.md deleted file mode 100644 index bb51d72c..00000000 --- a/src/modules/bmm/workflows/4-implementation/multi-agent-review/instructions.md +++ /dev/null @@ -1,188 +0,0 @@ -# Multi-Agent Code Review - -**Purpose:** Perform unbiased code review using multiple specialized AI agents in FRESH CONTEXT, with agent count based on story complexity. - -## Overview - -**Key Principle: FRESH CONTEXT** -- Review happens in NEW session (not the agent that wrote the code) -- Prevents bias from implementation decisions -- Provides truly independent perspective - -**Variable Agent Count by Complexity:** -- **MICRO** (2 agents): Security + Code Quality - Quick sanity check -- **STANDARD** (4 agents): + Architecture + Testing - Balanced review -- **COMPLEX** (6 agents): + Performance + Domain Expert - Comprehensive analysis - -**Available Specialized Agents:** -- **Security Agent**: Identifies vulnerabilities and security risks -- **Code Quality Agent**: Reviews style, maintainability, and best practices -- **Architecture Agent**: Reviews system design, patterns, and structure -- **Testing Agent**: Evaluates test coverage and quality -- **Performance Agent**: Analyzes efficiency and optimization opportunities -- **Domain Expert**: Validates business logic and domain constraints - -## Workflow - -### Step 1: Determine Agent Count - -Based on {complexity_level}: - -``` -If complexity_level == "micro": - agent_count = 2 - agents = ["security", "code_quality"] - Display: πŸ” MICRO Review (2 agents: Security + Code Quality) - -Else if complexity_level == "standard": - agent_count = 4 - agents = ["security", "code_quality", "architecture", "testing"] - Display: πŸ“‹ STANDARD Review (4 agents: Multi-perspective) - -Else if complexity_level == "complex": - agent_count = 6 - agents = ["security", "code_quality", "architecture", "testing", "performance", "domain_expert"] - Display: πŸ”¬ COMPLEX Review (6 agents: Comprehensive analysis) -``` - -### Step 2: Load Story Context - -```bash -# Read story file -story_file="{story_file}" -test -f "$story_file" || (echo "❌ Story file not found: $story_file" && exit 1) -``` - -Read the story file to understand: -- What was supposed to be implemented -- Acceptance criteria -- Tasks and subtasks -- File list - -### Step 3: Invoke Multi-Agent Review Skill (Fresh Context + Smart Agent Selection) - -**CRITICAL:** This review MUST happen in a FRESH CONTEXT (new session, different agent). - -**Smart Agent Selection:** -- Skill analyzes changed files and selects MOST RELEVANT agents -- Touching payments code? β†’ Add financial-security agent -- Touching auth code? β†’ Add auth-security agent -- Touching file uploads? β†’ Add file-security agent -- Touching performance-critical code? β†’ Add performance agent -- Agent count determined by complexity, but agents chosen by code analysis - -```xml - - {story_id} - {base_branch} - {agent_count} - smart - true - -``` - -The skill will: -1. Create fresh context (unbiased review session) -2. Analyze changed files in the story -3. Detect code categories (auth, payments, file handling, etc.) -4. Select {agent_count} MOST RELEVANT specialized agents -5. Run parallel reviews from selected agents -6. Each agent reviews from their expertise perspective -7. Aggregate findings with severity ratings -8. Return comprehensive review report - -### Step 3: Save Review Report - -```bash -# The skill returns a review report -# Save it to: {review_report} -``` - -Display summary: -``` -πŸ€– MULTI-AGENT CODE REVIEW COMPLETE - -Agents Used: {agent_count} -- Architecture Agent -- Security Agent -- Performance Agent -- Testing Agent -- Code Quality Agent - -Findings: -- πŸ”΄ CRITICAL: {critical_count} -- 🟠 HIGH: {high_count} -- 🟑 MEDIUM: {medium_count} -- πŸ”΅ LOW: {low_count} -- ℹ️ INFO: {info_count} - -Report saved to: {review_report} -``` - -### Step 4: Present Findings - -For each finding, display: -``` -[{severity}] {title} -Agent: {agent_name} -Location: {file}:{line} - -{description} - -Recommendation: -{recommendation} - ---- -``` - -### Step 5: Next Steps - -Suggest actions based on findings: -``` -πŸ“‹ RECOMMENDED NEXT STEPS: - -If CRITICAL findings exist: - ⚠️ MUST FIX before proceeding - - Address all critical security/correctness issues - - Re-run review after fixes - -If only HIGH/MEDIUM findings: - βœ… Story may proceed - - Consider addressing high-priority items - - Create follow-up tasks for medium items - - Document LOW items as tech debt - -If only LOW/INFO findings: - βœ… Code quality looks good - - Optional: Address style/optimization suggestions - - Proceed to completion -``` - -## Integration with Super-Dev-Pipeline - -This workflow is designed to be called from super-dev-pipeline step 7 (code review) when the story complexity is COMPLEX or when user explicitly requests multi-agent review. - -**When to Use:** -- Complex stories (β‰₯16 tasks or high-risk keywords) -- Stories involving security-sensitive code -- Stories with significant architectural changes -- When single-agent review has been inconclusive -- User explicitly requests comprehensive review - -**When NOT to Use:** -- Micro stories (≀3 tasks) -- Standard stories with simple changes -- Stories that passed adversarial review cleanly - -## Output Files - -- `{review_report}`: Full review findings in markdown -- Integrated into story completion summary -- Referenced in audit trail - -## Error Handling - -If multi-agent-review skill fails: -- Fall back to adversarial code review -- Log the failure reason -- Continue pipeline with warning diff --git a/src/modules/bmm/workflows/4-implementation/push-all/instructions.xml b/src/modules/bmm/workflows/4-implementation/push-all/instructions.xml deleted file mode 100644 index 9e5b715d..00000000 --- a/src/modules/bmm/workflows/4-implementation/push-all/instructions.xml +++ /dev/null @@ -1,549 +0,0 @@ - - The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml - You MUST have already loaded and processed: {installed_path}/workflow.yaml - Communicate all responses in {communication_language} - πŸ“ PUSH-ALL - Stage, commit, and push changes with comprehensive safety validation - - - ⚑ PARALLEL AGENT MODE: When {{target_files}} is provided: - - ONLY stage and commit the specified files - - Do NOT use `git add .` or `git add -A` - - Use `git add [specific files]` instead - - This prevents committing work from other parallel agents - - πŸ“‹ ALL FILES MODE: When {{target_files}} is empty: - - Stage ALL changes with `git add .` - - Original behavior for single-agent execution - - - - πŸ”„ **Analyzing Repository Changes** - - Scanning for changes to commit and push... - - - - Run git commands in parallel: - - git status - Show modified/added/deleted/untracked files - - git diff --stat - Show change statistics - - git log -1 --oneline - Show recent commit for message style - - git branch --show-current - Confirm current branch - - Parse git status output to identify: - - Modified files - - Added files - - Deleted files - - Untracked files - - Total insertion/deletion counts - - - - ℹ️ **No Changes to Commit** - - Working directory is clean. - Nothing to push. - - HALT - No work to do - - - - - πŸ”’ SAFETY CHECKS - Validate changes before committing - - Scan all changed files for dangerous patterns: - - **Secret Detection:** - Check for files matching secret patterns: - - .env*, *.key, *.pem, credentials.json, secrets.yaml - - id_rsa, *.p12, *.pfx, *.cer - - Any file containing: _API_KEY=, _SECRET=, _TOKEN= with real values (not placeholders) - - - Validate API keys are placeholders only: - βœ… Acceptable placeholders: - - API_KEY=your-api-key-here - - SECRET=placeholder - - TOKEN=xxx - - API_KEY=${{YOUR_KEY}} - - SECRET_KEY=<your-key> - - - ❌ BLOCK real keys: - - OPENAI_API_KEY=sk-proj-xxxxx (real OpenAI key) - - AWS_SECRET_KEY=AKIA... (real AWS key) - - STRIPE_API_KEY=sk_live_... (real Stripe key) - - Any key with recognizable provider prefix + actual value - - - **File Size Check:** - Check for files >10MB without Git LFS configuration - - **Build Artifacts:** - Check for unwanted directories/files that should be gitignored: - - node_modules/, dist/, build/, .next/, __pycache__/, *.pyc, .venv/ - - .DS_Store, Thumbs.db, *.swp, *.tmp, *.log (in root) - - *.class, target/, bin/ (Java) - - vendor/ (unless dependency managed) - - - **Git State:** - Verify: - - .gitignore exists and properly configured - - No unresolved merge conflicts - - Git repository initialized - - - - - 🚨 **DANGER: Secrets Detected!** - - The following sensitive data was found: - {{list_detected_secrets_with_files}} - - ❌ **BLOCKED:** Cannot commit secrets to version control. - - **Actions Required:** - 1. Move secrets to .env file (add to .gitignore) - 2. Use environment variables: process.env.API_KEY - 3. Remove secrets from tracked files: git rm --cached [file] - 4. Update code to load from environment - - **Example:** - ``` - // Before (UNSAFE): - const apiKey = 'sk-proj-xxxxx'; - - // After (SAFE): - const apiKey = process.env.OPENAI_API_KEY; - ``` - - Halting workflow for safety. - - HALT - Cannot proceed with secrets - - - - ⚠️ **Warning: Large Files Detected** - - Files >10MB found: - {{list_large_files_with_sizes}} - - **Recommendation:** Set up Git LFS - ``` - git lfs install - git lfs track "*.{file_extension}" - git add .gitattributes - ``` - - - Proceed with large files anyway? [y/n]: - - - Halting. Please configure Git LFS first. - HALT - - - - - ⚠️ **Warning: Build Artifacts Detected** - - These files should be in .gitignore: - {{list_build_artifacts}} - - **Update .gitignore:** - ``` - node_modules/ - dist/ - build/ - .DS_Store - ``` - - - Commit build artifacts anyway? [y/n]: - - - Halting. Update .gitignore and git rm --cached [files] - HALT - - - - - ⚠️ **Warning: Pushing to {{branch_name}}** - - You're committing directly to {{branch_name}}. - - **Recommendation:** Use feature branch workflow: - 1. git checkout -b feature/my-changes - 2. Make and commit changes - 3. git push -u origin feature/my-changes - 4. Create PR for review - - - Push directly to {{branch_name}}? [y/n]: - - - Halting. Create a feature branch instead. - HALT - - - - βœ… **Safety Checks Passed** - - All validations completed successfully. - - - - - - πŸ“Š **Changes Summary** - - **Files:** - - Modified: {{modified_count}} - - Added: {{added_count}} - - Deleted: {{deleted_count}} - - Untracked: {{untracked_count}} - **Total:** {{total_file_count}} files - - **Changes:** - - Insertions: +{{insertion_count}} lines - - Deletions: -{{deletion_count}} lines - - **Safety:** - {{if_all_safe}} - βœ… No secrets detected - βœ… No large files (or approved) - βœ… No build artifacts (or approved) - βœ… .gitignore configured - {{endif}} - - {{if_warnings_approved}} - ⚠️ Warnings acknowledged and approved - {{endif}} - - **Git:** - - Branch: {{current_branch}} - - Remote: origin/{{current_branch}} - - Last commit: {{last_commit_message}} - - --- - - **I will execute:** - 1. `git add .` - Stage all changes - 2. `git commit -m "[generated message]"` - Create commit - 3. `git push` - Push to remote - - - - **Proceed with commit and push?** - - Options: - [yes] - Proceed with commit and push - [no] - Cancel (leave changes unstaged) - [review] - Show detailed diff first - - - - Execute: git diff --stat - Execute: git diff | head -100 (show first 100 lines of changes) - - {{diff_output}} - - (Use 'git diff' to see full changes) - - After reviewing, proceed with commit and push? [yes/no]: - - - - ❌ **Push-All Cancelled** - - Changes remain unstaged. No git operations performed. - - You can: - - Review changes: git status, git diff - - Commit manually: git add [files] && git commit - - Discard changes: git checkout -- [files] - - HALT - User cancelled - - - - - - - πŸ“Ž **Targeted Commit Mode** (parallel agent safe) - - Staging only files from this story/task: - {{target_files}} - - Execute: git add {{target_files}} - Execute: git status - βœ… **Targeted Files Staged** - - Ready for commit ({{target_file_count}} files): - {{list_staged_files}} - - Note: Other uncommitted changes in repo are NOT included. - - - - - - Execute: git add . - Execute: git status - βœ… **All Changes Staged** - - Ready for commit: - {{list_staged_files}} - - - - - - πŸ“ COMMIT MESSAGE - Generate conventional commit format - - Analyze changes to determine commit type: - - feat: New features (new files with functionality) - - fix: Bug fixes (fixing broken functionality) - - docs: Documentation only (*.md, comments) - - style: Formatting, missing semicolons (no code change) - - refactor: Code restructuring (no feature/fix) - - test: Adding/updating tests - - chore: Tooling, configs, dependencies - - perf: Performance improvements - - Determine scope (optional): - - Component/feature name if changes focused on one area - - Omit if changes span multiple areas - - - Generate message summary (max 72 chars): - - Use imperative mood: "add feature" not "added feature" - - Lowercase except proper nouns - - No period at end - - - Generate message body (if changes >5 files): - - List key changes as bullet points - - Max 3-5 bullets - - Keep concise - - - Reference recent commits for style consistency - - πŸ“ **Generated Commit Message:** - - ``` - {{generated_commit_message}} - ``` - - Based on: - - {{commit_type}} commit type - - {{file_count}} files changed - - {{change_summary}} - - - **Use this commit message?** - - Options: - [yes] - Use generated message - [edit] - Let me write custom message - [cancel] - Cancel push-all (leave staged) - - - - Enter your commit message (use conventional commit format if possible): - Store user input as {{commit_message}} - βœ… Using custom commit message - - - - ❌ Push-all cancelled - - Changes remain staged. - Run: git reset to unstage - - HALT - - - - Use {{generated_commit_message}} as {{commit_message}} - - - - - Execute git commit with heredoc for multi-line message safety: - git commit -m "$(cat <<'EOF' -{{commit_message}} -EOF -)" - - - - ❌ **Commit Failed** - - Error: {{commit_error}} - - **Common Causes:** - - Pre-commit hooks failing (linting, tests) - - Missing git config (user.name, user.email) - - Locked files or permissions - - Empty commit (no actual changes) - - **Fix and try again:** - - Check pre-commit output - - Set git config: git config user.name "Your Name" - - Verify file permissions - - HALT - Fix errors before proceeding - - - Parse commit output for hash - βœ… **Commit Created** - - Commit: {{commit_hash}} - Message: {{commit_subject}} - - - - - πŸš€ **Pushing to Remote** - - Pushing {{current_branch}} to origin... - - - Execute: git push - - - - ⚠️ **Push Rejected - Remote Has New Commits** - - Remote branch has commits you don't have locally. - Attempting to rebase and retry... - - - Execute: git pull --rebase - - - ❌ **Merge Conflicts During Rebase** - - Conflicts found: - {{list_conflicted_files}} - - **Manual resolution required:** - 1. Resolve conflicts in listed files - 2. git add [resolved files] - 3. git rebase --continue - 4. git push - - Halting for manual conflict resolution. - - HALT - Resolve conflicts manually - - - Execute: git push - - - - ℹ️ **No Upstream Branch Set** - - First push to origin for this branch. - Setting upstream... - - - Execute: git push -u origin {{current_branch}} - - - - ❌ **Push to Protected Branch Blocked** - - Branch {{current_branch}} is protected on remote. - - **Use PR workflow instead:** - 1. Ensure you're on a feature branch - 2. Push feature branch: git push -u origin feature-branch - 3. Create PR for review - - Changes are committed locally but not pushed. - - HALT - Use PR workflow for protected branches - - - - ❌ **Authentication Failed** - - Git push requires authentication. - - **Fix authentication:** - - GitHub: Set up SSH key or Personal Access Token - - Check: git remote -v (verify remote URL) - - Docs: https://docs.github.com/authentication - - Changes are committed locally but not pushed. - - HALT - Fix authentication - - - - ❌ **Push Failed** - - Error: {{push_error}} - - Your changes are committed locally but not pushed to remote. - - **Troubleshoot:** - - Check network connection - - Verify remote exists: git remote -v - - Check permissions on remote repository - - Try manual push: git push - - Halting for manual resolution. - - HALT - Manual push required - - - - - βœ… **Successfully Pushed to Remote!** - - **Commit:** {{commit_hash}} - {{commit_subject}} - **Branch:** {{current_branch}} β†’ origin/{{current_branch}} - **Files changed:** {{file_count}} (+{{insertions}}, -{{deletions}}) - - --- - - Your changes are now on the remote repository. - - - Execute: git log -1 --oneline --decorate - - **Latest commit:** {{git_log_output}} - - - - - - πŸŽ‰ **Push-All Complete, {user_name}!** - - **Summary:** - - βœ… {{file_count}} files committed - - βœ… Pushed to origin/{{current_branch}} - - βœ… All safety checks passed - - **Commit Details:** - - Hash: {{commit_hash}} - - Message: {{commit_subject}} - - Changes: +{{insertions}}, -{{deletions}} - - **Next Steps:** - - Verify on remote (GitHub/GitLab/etc) - - Create PR if working on feature branch - - Notify team if appropriate - - **Git State:** - - Working directory: clean - - Branch: {{current_branch}} - - In sync with remote - - - - diff --git a/src/modules/bmm/workflows/4-implementation/push-all/workflow.md b/src/modules/bmm/workflows/4-implementation/push-all/workflow.md new file mode 100644 index 00000000..44637b79 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/push-all/workflow.md @@ -0,0 +1,366 @@ +# Push All v3.0 - Safe Git Staging, Commit, and Push + + +Safely stage, commit, and push changes with comprehensive validation. +Detects secrets, large files, build artifacts. Handles push failures gracefully. +Supports targeted mode for specific files (parallel agent coordination). + + + +**Safe by Default, No Surprises** + +- Validate BEFORE committing (secrets, size, artifacts) +- Show exactly what will be committed +- Handle push failures with recovery options +- Never force push without explicit confirmation + + + +name: push-all +version: 3.0.0 + +modes: + full: "Stage all changes (default)" + targeted: "Only stage specified files" + +defaults: + max_file_size_kb: 500 + check_secrets: true + check_build_artifacts: true + auto_push: false + allow_force_push: false + +secret_patterns: + - "AKIA[0-9A-Z]{16}" # AWS Access Key + - "sk-[a-zA-Z0-9]{48}" # OpenAI Key + - "ghp_[a-zA-Z0-9]{36}" # GitHub Personal Token + - "xox[baprs]-[a-zA-Z0-9-]+" # Slack Token + - "-----BEGIN.*PRIVATE KEY" # Private Keys + - "password\\s*=\\s*['\"][^'\"]{8,}" # Hardcoded passwords + +build_artifacts: + - "node_modules/" + - "dist/" + - "build/" + - ".next/" + - "*.min.js" + - "*.bundle.js" + + + +@patterns/hospital-grade.md + + + + + +**Verify git repository state** + +```bash +# Check we're in a git repo +git rev-parse --is-inside-work-tree || { echo "❌ Not a git repository"; exit 1; } + +# Get current branch +git branch --show-current + +# Check for uncommitted changes +git status --porcelain +``` + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“¦ PUSH-ALL: {{mode}} mode +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Branch: {{branch}} +Mode: {{mode}} +{{#if targeted}}Files: {{file_list}}{{/if}} +``` + +**If no changes:** +``` +βœ… Working directory clean - nothing to commit +``` +Exit successfully. + + + +**Identify files to be staged** + +**Full mode:** +```bash +git status --porcelain | awk '{print $2}' +``` + +**Targeted mode:** +Only include files specified in `target_files` parameter. + +**Categorize changes:** +- New files (A) +- Modified files (M) +- Deleted files (D) +- Renamed files (R) + + + +**Scan for secrets in staged content** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” SECRET SCAN +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +For each file to be staged: +```bash +# Check for secret patterns +Grep: "{{pattern}}" {{file}} +``` + +**If secrets found:** +``` +❌ POTENTIAL SECRETS DETECTED + +{{#each secrets}} +File: {{file}} +Line {{line}}: {{preview}} (pattern: {{pattern_name}}) +{{/each}} + +⚠️ BLOCKING COMMIT +Remove secrets before proceeding. + +Options: +[I] Ignore (I know what I'm doing) +[E] Exclude these files +[H] Halt +``` + +**If [I] selected:** Require explicit confirmation text. + + + +**Check for oversized files** + +```bash +# Find files larger than max_file_size_kb +find . -type f -size +{{max_file_size}}k -not -path "./.git/*" +``` + +**If large files found:** +``` +⚠️ LARGE FILES DETECTED + +{{#each large_files}} +- {{file}} ({{size_kb}}KB) +{{/each}} + +Options: +[I] Include anyway +[E] Exclude large files +[H] Halt +``` + + + +**Check for build artifacts** + +```bash +# Check if any staged files match artifact patterns +git status --porcelain | grep -E "{{artifact_pattern}}" +``` + +**If artifacts found:** +``` +⚠️ BUILD ARTIFACTS DETECTED + +{{#each artifacts}} +- {{file}} +{{/each}} + +These should typically be in .gitignore. + +Options: +[E] Exclude artifacts (recommended) +[I] Include anyway +[H] Halt +``` + + + +**Show what will be committed** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“‹ COMMIT PREVIEW +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Files to commit: {{count}} + +Added ({{added_count}}): +{{#each added}} + + {{file}} +{{/each}} + +Modified ({{modified_count}}): +{{#each modified}} + M {{file}} +{{/each}} + +Deleted ({{deleted_count}}): +{{#each deleted}} + - {{file}} +{{/each}} + +{{#if excluded}} +Excluded: {{excluded_count}} files +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + +**Generate or request commit message** + +**If commit_message provided:** Use it. + +**Otherwise, generate from changes:** +``` +Analyzing changes to generate commit message... + +Changes detected: +- {{summary_of_changes}} + +Suggested message: +"{{generated_message}}" + +[Y] Use this message +[E] Edit message +[C] Custom message +``` + +If user selects [C] or [E], prompt for message. + + + +**Stage and commit changes** + +```bash +# Stage files (targeted or full) +{{#if targeted}} +git add {{#each target_files}}{{this}} {{/each}} +{{else}} +git add -A +{{/if}} + +# Commit with message +git commit -m "{{commit_message}}" +``` + +**Verify commit:** +```bash +# Check commit was created +git log -1 --oneline +``` + +``` +βœ… Commit created: {{commit_hash}} +``` + + + +**Push to remote with error handling** + +```bash +git push origin {{branch}} +``` + +**If push fails:** + +**Case: Behind remote** +``` +⚠️ Push rejected - branch is behind remote + +Options: +[P] Pull and retry (git pull --rebase) +[F] Force push (DESTRUCTIVE - overwrites remote) +[H] Halt (commit preserved locally) +``` + +**Case: No upstream** +``` +⚠️ No upstream branch + +Setting upstream and pushing: +git push -u origin {{branch}} +``` + +**Case: Auth failure** +``` +❌ Authentication failed + +Check: +1. SSH key configured? +2. Token valid? +3. Repository access? +``` + +**Case: Protected branch** +``` +❌ Cannot push to protected branch + +Use pull request workflow instead: +gh pr create --title "{{commit_message}}" +``` + + + +**Display completion status** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… PUSH-ALL COMPLETE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Branch: {{branch}} +Commit: {{commit_hash}} +Files: {{file_count}} +{{#if pushed}} +Remote: βœ… Pushed to origin/{{branch}} +{{else}} +Remote: ⏸️ Not pushed (commit preserved locally) +{{/if}} + +{{#if excluded_count > 0}} +Excluded: {{excluded_count}} files (secrets/artifacts/size) +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + + + +```bash +# Stage all, commit, and push +/push-all commit_message="feat: add user authentication" auto_push=true + +# Targeted mode - only specific files +/push-all mode=targeted target_files="src/auth.ts,src/auth.test.ts" commit_message="fix: auth bug" + +# Dry run - see what would be committed +/push-all auto_push=false +``` + + + +**Secrets detected:** BLOCK commit, require explicit override. +**Large files:** Warn, allow exclude or include. +**Build artifacts:** Warn, recommend exclude. +**Push rejected:** Offer pull/rebase, force push (with confirmation), or halt. +**Auth failure:** Report, suggest troubleshooting. + + + +- [ ] Changes validated (secrets, size, artifacts) +- [ ] Files staged correctly +- [ ] Commit created with message +- [ ] Push successful (if requested) +- [ ] No unintended files included + diff --git a/src/modules/bmm/workflows/4-implementation/push-all/workflow.yaml b/src/modules/bmm/workflows/4-implementation/push-all/workflow.yaml index 1eedfe30..5875d911 100644 --- a/src/modules/bmm/workflows/4-implementation/push-all/workflow.yaml +++ b/src/modules/bmm/workflows/4-implementation/push-all/workflow.yaml @@ -9,7 +9,7 @@ communication_language: "{config_source}:communication_language" # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/push-all" -instructions: "{installed_path}/instructions.xml" +instructions: "{installed_path}/workflow.md" # Target files to commit (for parallel agent execution) # When empty/not provided: commits ALL changes (original behavior) diff --git a/src/modules/bmm/workflows/4-implementation/recover-sprint-status/instructions.md b/src/modules/bmm/workflows/4-implementation/recover-sprint-status/instructions.md deleted file mode 100644 index 7ec69cd7..00000000 --- a/src/modules/bmm/workflows/4-implementation/recover-sprint-status/instructions.md +++ /dev/null @@ -1,306 +0,0 @@ -# Sprint Status Recovery - Instructions - -**Workflow:** recover-sprint-status -**Purpose:** Fix sprint-status.yaml when tracking has drifted for days/weeks - ---- - -## What This Workflow Does - -Analyzes multiple sources to rebuild accurate sprint-status.yaml: - -1. **Story File Quality** - Validates size (>=10KB), task lists, checkboxes -2. **Explicit Status: Fields** - Reads story Status: when present -3. **Git Commits** - Searches last 30 days for story references -4. **Autonomous Reports** - Checks .epic-*-completion-report.md files -5. **Task Completion Rate** - Analyzes checkbox completion in story files - -**Infers Status Based On:** -- Explicit Status: field (highest priority) -- Git commits referencing story (strong signal) -- Autonomous completion reports (very high confidence) -- Task checkbox completion rate (90%+ = done) -- File quality (poor quality prevents "done" marking) - ---- - -## Step 1: Run Recovery Analysis - -```bash -Execute: {recovery_script} --dry-run -``` - -**This will:** -- Analyze all story files (quality, tasks, status) -- Search git commits for completion evidence -- Check autonomous completion reports -- Infer status from all evidence -- Report recommendations with confidence levels - -**No changes** made in dry-run mode - just analysis. - ---- - -## Step 2: Review Recommendations - -**Check the output for:** - -### High Confidence Updates (Safe) -- Stories with explicit Status: fields -- Stories in autonomous completion reports -- Stories with 3+ git commits + 90%+ tasks complete - -### Medium Confidence Updates (Verify) -- Stories with 1-2 git commits -- Stories with 50-90% tasks complete -- Stories with file size >=10KB - -### Low Confidence Updates (Question) -- Stories with no Status: field, no commits -- Stories with file size <10KB -- Stories with <5 tasks total - ---- - -## Step 3: Choose Recovery Mode - -### Conservative Mode (Safest) -```bash -Execute: {recovery_script} --conservative -``` - -**Only updates:** -- High/very high confidence stories -- Explicit Status: fields honored -- Git commits with 3+ references -- Won't infer or guess - -**Best for:** Quick fixes, first-time recovery, risk-averse - ---- - -### Aggressive Mode (Thorough) -```bash -Execute: {recovery_script} --aggressive --dry-run # Preview first! -Execute: {recovery_script} --aggressive # Then apply -``` - -**Updates:** -- Medium+ confidence stories -- Infers from git commits (even 1 commit) -- Uses task completion rate -- Pre-fills brownfield checkboxes - -**Best for:** Major drift (30+ days), comprehensive recovery - ---- - -### Interactive Mode (Recommended) -```bash -Execute: {recovery_script} -``` - -**Process:** -1. Shows all recommendations -2. Groups by confidence level -3. Asks for confirmation before each batch -4. Allows selective application - -**Best for:** First-time use, learning the tool - ---- - -## Step 4: Validate Results - -```bash -Execute: ./scripts/sync-sprint-status.sh --validate -``` - -**Should show:** -- "βœ“ sprint-status.yaml is up to date!" (success) -- OR discrepancy count (if issues remain) - ---- - -## Step 5: Commit Changes - -```bash -git add docs/sprint-artifacts/sprint-status.yaml -git add .sprint-status-backups/ # Include backup for audit trail -git commit -m "fix(tracking): Recover sprint-status.yaml - {MODE} recovery" -``` - ---- - -## Recovery Scenarios - -### Scenario 1: Autonomous Epic Completed, Tracking Not Updated - -**Symptoms:** -- Autonomous completion report exists -- Git commits show work done -- sprint-status.yaml shows "in-progress" or "backlog" - -**Solution:** -```bash -{recovery_script} --aggressive -# Will find completion report, mark all stories done -``` - ---- - -### Scenario 2: Manual Work Over Past Week Not Tracked - -**Symptoms:** -- Story Status: fields updated to "done" -- sprint-status.yaml not synced -- Git commits exist - -**Solution:** -```bash -./scripts/sync-sprint-status.sh -# Standard sync (reads Status: fields) -``` - ---- - -### Scenario 3: Story Files Missing Status: Fields - -**Symptoms:** -- 100+ stories with no Status: field -- Some completed, some not -- No autonomous reports - -**Solution:** -```bash -{recovery_script} --aggressive --dry-run # Preview inference -# Review recommendations carefully -{recovery_script} --aggressive # Apply if satisfied -``` - ---- - -### Scenario 4: Complete Chaos (Mix of All Above) - -**Symptoms:** -- Some stories have Status:, some don't -- Autonomous reports for some epics -- Manual work on others -- sprint-status.yaml very outdated - -**Solution:** -```bash -# Step 1: Run recovery in dry-run -{recovery_script} --aggressive --dry-run - -# Step 2: Review /tmp/recovery_results.json - -# Step 3: Apply in conservative mode first (safest updates) -{recovery_script} --conservative - -# Step 4: Manually review remaining stories -# Update Status: fields for known completed work - -# Step 5: Run sync to catch manual updates -./scripts/sync-sprint-status.sh - -# Step 6: Final validation -./scripts/sync-sprint-status.sh --validate -``` - ---- - -## Quality Gates - -**Recovery script will DOWNGRADE status if:** -- Story file < 10KB (not properly detailed) -- Story file has < 5 tasks (incomplete story) -- No git commits found (no evidence of work) -- Explicit Status: contradicts other evidence - -**Recovery script will UPGRADE status if:** -- Autonomous completion report lists story as done -- 3+ git commits + 90%+ tasks checked -- Explicit Status: field says "done" - ---- - -## Post-Recovery Checklist - -After running recovery: - -- [ ] Run validation: `./scripts/sync-sprint-status.sh --validate` -- [ ] Review backup: Check `.sprint-status-backups/` for before state -- [ ] Check epic statuses: Verify epic-level status matches story completion -- [ ] Spot-check 5-10 stories: Confirm inferred status is accurate -- [ ] Commit changes: Add recovery to version control -- [ ] Document issues: Note why drift occurred, prevent recurrence - ---- - -## Preventing Future Drift - -**After recovery:** - -1. **Use workflows properly** - - `/create-story` - Adds to sprint-status.yaml automatically - - `/dev-story` - Updates both Status: and sprint-status.yaml - - Autonomous workflows - Now update tracking - -2. **Run sync regularly** - - Weekly: `pnpm sync:sprint-status:dry-run` (check health) - - After manual Status: updates: `pnpm sync:sprint-status` - -3. **CI/CD validation** (coming soon) - - Blocks PRs with out-of-sync tracking - - Forces sync before merge - ---- - -## Troubleshooting - -### "Recovery script shows 0 updates" - -**Possible causes:** -- sprint-status.yaml already accurate -- Story files all have proper Status: fields -- No git commits found (check date range) - -**Action:** Run `--dry-run` to see analysis, check `/tmp/recovery_results.json` - ---- - -### "Low confidence on stories I know are done" - -**Possible causes:** -- Story file < 10KB (not properly detailed) -- No git commits (work done outside git) -- No explicit Status: field - -**Action:** Manually add Status: field to story, then run standard sync - ---- - -### "Recovery marks incomplete stories as done" - -**Possible causes:** -- Git commits exist but work abandoned -- Autonomous report lists story but implementation failed -- Tasks pre-checked incorrectly (brownfield error) - -**Action:** Use conservative mode, manually verify, fix story files - ---- - -## Output Files - -**Created during recovery:** -- `.sprint-status-backups/sprint-status-recovery-{timestamp}.yaml` - Backup -- `/tmp/recovery_results.json` - Detailed analysis -- Updated `sprint-status.yaml` - Recovered status - ---- - -**Last Updated:** 2026-01-02 -**Status:** Production Ready -**Works On:** ANY BMAD project with sprint-status.yaml tracking diff --git a/src/modules/bmm/workflows/4-implementation/revalidate-epic/instructions.md b/src/modules/bmm/workflows/4-implementation/revalidate-epic/instructions.md deleted file mode 100644 index e229e944..00000000 --- a/src/modules/bmm/workflows/4-implementation/revalidate-epic/instructions.md +++ /dev/null @@ -1,273 +0,0 @@ -# Revalidate Epic - Batch Story Revalidation with Semaphore Pattern - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml - - - - - Verify epic_number parameter provided - - - ❌ ERROR: epic_number parameter required - -Usage: - /revalidate-epic epic_number=2 - /revalidate-epic epic_number=2 fill_gaps=true - /revalidate-epic epic_number=2 fill_gaps=true max_concurrent=5 - - HALT - - - Read {sprint_status} file - Parse development_status map - - Filter stories starting with "{{epic_number}}-" (e.g., "2-1-", "2-2-", etc.) - Exclude epics (keys starting with "epic-") and retrospectives - - Store as: epic_stories (list of story keys) - - - ❌ No stories found for Epic {{epic_number}} - -Check sprint-status.yaml to verify epic number is correct. - - HALT - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” EPIC {{epic_number}} REVALIDATION -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories Found:** {{epic_stories.length}} -**Mode:** {{#if fill_gaps}}Verify & Fill Gaps{{else}}Verify Only{{/if}} -**Max Concurrent:** {{max_concurrent}} agents -**Pattern:** Semaphore (continuous worker pool) - -**Stories to Revalidate:** -{{#each epic_stories}} -{{@index + 1}}. {{this}} -{{/each}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Proceed with revalidation? (yes/no): - - - ❌ Revalidation cancelled - Exit workflow - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸš€ Starting Parallel Revalidation (Semaphore Pattern) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Initialize worker pool state: - - - story_queue = epic_stories - - active_workers = {} - - completed_stories = [] - - failed_stories = [] - - verification_results = {} - - next_story_index = 0 - - max_workers = {{max_concurrent}} - - - Fill initial worker slots: - - While next_story_index < min(max_workers, story_queue.length): - - - story_key = story_queue[next_story_index] - story_file = {sprint_artifacts}/{{story_key}}.md # Try multiple naming patterns if needed - worker_id = next_story_index + 1 - - Spawn Task agent: - - subagent_type: "general-purpose" - - description: "Revalidate story {{story_key}}" - - prompt: "Execute revalidate-story workflow for {{story_key}}. - - CRITICAL INSTRUCTIONS: - 1. Load workflow: _bmad/bmm/workflows/4-implementation/revalidate-story/workflow.yaml - 2. Parameters: story_file={{story_file}}, fill_gaps={{fill_gaps}} - 3. Clear all checkboxes - 4. Verify each AC/Task/DoD against codebase - 5. Re-check verified items - 6. Report gaps - {{#if fill_gaps}}7. Fill gaps and commit{{/if}} - 8. Return verification summary" - - run_in_background: true - - Store in active_workers[worker_id]: - story_key: {{story_key}} - task_id: {{returned_task_id}} - started_at: {{timestamp}} - - - Increment next_story_index - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… {{active_workers.size}} workers active -πŸ“‹ {{story_queue.length - next_story_index}} stories queued -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - SEMAPHORE PATTERN: Keep {{max_workers}} agents running continuously - - While active_workers.size > 0 OR next_story_index < story_queue.length: - - Poll for completed workers (non-blocking): - - For each worker_id in active_workers: - - Check worker status using TaskOutput(task_id, block=false) - - - Get verification results from worker output - Parse: verified_pct, gaps_found, gaps_filled - - Store in verification_results[story_key] - Add to completed_stories - Remove from active_workers - - βœ… Worker {{worker_id}}: {{story_key}} β†’ {{verified_pct}}% verified{{#if gaps_filled > 0}}, {{gaps_filled}} gaps filled{{/if}} - - - Refill slot with next story (same pattern as batch-super-dev) - πŸ”„ Worker {{worker_id}} refilled: {{next_story_key}} - - - - - Add to failed_stories with error - Remove from active_workers - ❌ Worker {{worker_id}}: {{story_key}} failed - - - Refill slot despite failure - - - - Display live progress every 30 seconds: - -πŸ“Š Live Progress: {{completed_stories.length}} completed, {{active_workers.size}} active, {{story_queue.length - next_story_index}} queued - - - Sleep 5 seconds before next poll - - - - Aggregate verification results across all stories: - - epic_total_items = sum of all items across stories - epic_verified = sum of verified items - epic_partial = sum of partial items - epic_missing = sum of missing items - epic_gaps_filled = sum of gaps filled - - epic_verified_pct = (epic_verified / epic_total_items) Γ— 100 - - - Group stories by verification percentage: - - - complete_stories (β‰₯95% verified) - - mostly_complete_stories (80-94% verified) - - partial_stories (50-79% verified) - - incomplete_stories (<50% verified) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š EPIC {{epic_number}} REVALIDATION SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Total Stories:** {{epic_stories.length}} -**Completed:** {{completed_stories.length}} -**Failed:** {{failed_stories.length}} - -**Epic-Wide Verification:** -- βœ… Verified: {{epic_verified}}/{{epic_total_items}} ({{epic_verified_pct}}%) -- πŸ”Ά Partial: {{epic_partial}}/{{epic_total_items}} -- ❌ Missing: {{epic_missing}}/{{epic_total_items}} -{{#if fill_gaps}}- πŸ”§ Gaps Filled: {{epic_gaps_filled}}{{/if}} - -**Story Health:** -- βœ… Complete (β‰₯95%): {{complete_stories.length}} stories -- πŸ”Ά Mostly Complete (80-94%): {{mostly_complete_stories.length}} stories -- ⚠️ Partial (50-79%): {{partial_stories.length}} stories -- ❌ Incomplete (<50%): {{incomplete_stories.length}} stories - ---- - -**Complete Stories (β‰₯95% verified):** -{{#each complete_stories}} -- {{story_key}}: {{verified_pct}}% verified -{{/each}} - -{{#if mostly_complete_stories.length > 0}} -**Mostly Complete Stories (80-94%):** -{{#each mostly_complete_stories}} -- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) -{{/each}} -{{/if}} - -{{#if partial_stories.length > 0}} -**⚠️ Partial Stories (50-79%):** -{{#each partial_stories}} -- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) -{{/each}} - -Recommendation: Continue development on these stories -{{/if}} - -{{#if incomplete_stories.length > 0}} -**❌ Incomplete Stories (<50%):** -{{#each incomplete_stories}} -- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) -{{/each}} - -Recommendation: Re-implement these stories from scratch -{{/if}} - -{{#if failed_stories.length > 0}} -**❌ Failed Revalidations:** -{{#each failed_stories}} -- {{story_key}}: {{error}} -{{/each}} -{{/if}} - ---- - -**Epic Health Score:** {{epic_verified_pct}}/100 - -{{#if epic_verified_pct >= 95}} -βœ… Epic is COMPLETE and verified -{{else if epic_verified_pct >= 80}} -πŸ”Ά Epic is MOSTLY COMPLETE ({{epic_missing}} items need attention) -{{else if epic_verified_pct >= 50}} -⚠️ Epic is PARTIALLY COMPLETE (significant gaps remain) -{{else}} -❌ Epic is INCOMPLETE (major rework needed) -{{/if}} - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - Write epic summary to: {sprint_artifacts}/revalidation-epic-{{epic_number}}-{{timestamp}}.md - πŸ“„ Epic report: {{report_path}} - - - - Update sprint-status.yaml with revalidation timestamp and results - Add comment to epic entry: # Revalidated: {{epic_verified_pct}}% verified ({{timestamp}}) - - - - diff --git a/src/modules/bmm/workflows/4-implementation/revalidate-story/instructions.md b/src/modules/bmm/workflows/4-implementation/revalidate-story/instructions.md deleted file mode 100644 index f5135606..00000000 --- a/src/modules/bmm/workflows/4-implementation/revalidate-story/instructions.md +++ /dev/null @@ -1,510 +0,0 @@ -# Revalidate Story - Verify Checkboxes Against Codebase Reality - -The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {installed_path}/workflow.yaml - - - - - Verify story_file parameter provided - - - ❌ ERROR: story_file parameter required - -Usage: - /revalidate-story story_file=path/to/story.md - /revalidate-story story_file=path/to/story.md fill_gaps=true - - HALT - - - Read COMPLETE story file: {{story_file}} - Parse sections: Acceptance Criteria, Tasks/Subtasks, Definition of Done, Dev Agent Record - - Extract story_key from filename (e.g., "2-7-image-file-handling") - - Create backup of current checkbox state: - Count currently checked items: - - ac_checked_before = count of [x] in Acceptance Criteria - - tasks_checked_before = count of [x] in Tasks/Subtasks - - dod_checked_before = count of [x] in Definition of Done - - total_checked_before = sum of above - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ” STORY REVALIDATION STARTED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Story:** {{story_key}} -**File:** {{story_file}} -**Mode:** {{#if fill_gaps}}Verify & Fill Gaps{{else}}Verify Only{{/if}} - -**Current State:** -- Acceptance Criteria: {{ac_checked_before}}/{{ac_total}} checked -- Tasks: {{tasks_checked_before}}/{{tasks_total}} checked -- Definition of Done: {{dod_checked_before}}/{{dod_total}} checked -- **Total:** {{total_checked_before}}/{{total_items}} ({{pct_before}}%) - -**Action:** Clearing all checkboxes and re-verifying against codebase... -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - 🧹 Clearing all checkboxes to start fresh verification... - - Use Edit tool to replace all [x] with [ ] in Acceptance Criteria section - Use Edit tool to replace all [x] with [ ] in Tasks/Subtasks section - Use Edit tool to replace all [x] with [ ] in Definition of Done section - - Save story file with all boxes unchecked - - βœ… All checkboxes cleared. Starting verification from clean slate... - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“‹ VERIFYING ACCEPTANCE CRITERIA ({{ac_total}} items) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Extract all AC items from Acceptance Criteria section - - For each AC item: - - - Extract AC description and identify artifacts: - - File mentions (e.g., "UserProfile component") - - Function names (e.g., "updateUser function") - - Features (e.g., "dark mode toggle") - - Test requirements (e.g., "unit tests covering edge cases") - - - Verifying AC{{@index}}: {{ac_description}} - - - - Use Glob to find relevant files: - - If AC mentions specific file: glob for that file - - If AC mentions component: glob for **/*ComponentName* - - If AC mentions feature: glob for files in related directories - - - Use Grep to search for symbols/functions/features - - Read found files to verify: - - NOT a stub (check for "TODO", "Not implemented", "throw new Error") - - Has actual implementation (not just empty function) - - Tests exist (search for *.test.* or *.spec.* files) - - Tests pass (if --fill-gaps mode, run tests) - - - - - verification_status = VERIFIED - Check box [x] in story file for this AC - Record evidence: "βœ… VERIFIED: {{files_found}}, tests: {{test_files}}" - βœ… AC{{@index}}: VERIFIED - - - - verification_status = PARTIAL - Check box [~] in story file for this AC - Record gap: "πŸ”Ά PARTIAL: {{what_exists}}, missing: {{what_is_missing}}" - πŸ”Ά AC{{@index}}: PARTIAL ({{what_is_missing}}) - Add to gaps_list with details - - - - verification_status = MISSING - Leave box unchecked [ ] in story file - Record gap: "❌ MISSING: No implementation found for {{ac_description}}" - ❌ AC{{@index}}: MISSING - Add to gaps_list with details - - - - Save story file after each AC verification - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Acceptance Criteria Verification Complete -βœ… Verified: {{ac_verified}} -πŸ”Ά Partial: {{ac_partial}} -❌ Missing: {{ac_missing}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“‹ VERIFYING TASKS ({{tasks_total}} items) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Extract all Task items from Tasks/Subtasks section - - For each Task item (same verification logic as ACs): - - Parse task description for artifacts - Search codebase with Glob/Grep - Read and verify (check for stubs, tests) - Determine status: VERIFIED | PARTIAL | MISSING - Update checkbox: [x] | [~] | [ ] - Record evidence or gap - Save story file - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Tasks Verification Complete -βœ… Verified: {{tasks_verified}} -πŸ”Ά Partial: {{tasks_partial}} -❌ Missing: {{tasks_missing}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“‹ VERIFYING DEFINITION OF DONE ({{dod_total}} items) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Extract all DoD items from Definition of Done section - - For each DoD item: - - Parse DoD requirement: - - "Type check passes" β†’ Run type checker - - "Unit tests 90%+ coverage" β†’ Run coverage report - - "Linting clean" β†’ Run linter - - "Build succeeds" β†’ Run build - - "All tests pass" β†’ Run test suite - - - Execute verification for this DoD item - - - Check box [x] - Record: "βœ… VERIFIED: {{verification_result}}" - - - - Leave unchecked [ ] or partial [~] - Record gap if applicable - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Definition of Done Verification Complete -βœ… Verified: {{dod_verified}} -πŸ”Ά Partial: {{dod_partial}} -❌ Missing: {{dod_missing}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - Calculate overall completion: - - total_verified = ac_verified + tasks_verified + dod_verified - total_partial = ac_partial + tasks_partial + dod_partial - total_missing = ac_missing + tasks_missing + dod_missing - total_items = ac_total + tasks_total + dod_total - - verified_pct = (total_verified / total_items) Γ— 100 - completion_pct = ((total_verified + total_partial) / total_items) Γ— 100 - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ“Š REVALIDATION SUMMARY -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Story:** {{story_key}} -**File:** {{story_file}} - -**Verification Results:** -- βœ… Verified Complete: {{total_verified}}/{{total_items}} ({{verified_pct}}%) -- πŸ”Ά Partially Complete: {{total_partial}}/{{total_items}} -- ❌ Missing/Incomplete: {{total_missing}}/{{total_items}} - -**Breakdown:** -- Acceptance Criteria: {{ac_verified}}βœ… {{ac_partial}}πŸ”Ά {{ac_missing}}❌ / {{ac_total}} total -- Tasks: {{tasks_verified}}βœ… {{tasks_partial}}πŸ”Ά {{tasks_missing}}❌ / {{tasks_total}} total -- Definition of Done: {{dod_verified}}βœ… {{dod_partial}}πŸ”Ά {{dod_missing}}❌ / {{dod_total}} total - -**Status Assessment:** -{{#if verified_pct >= 95}} -βœ… Story is COMPLETE ({{verified_pct}}% verified) -{{else if verified_pct >= 80}} -πŸ”Ά Story is MOSTLY COMPLETE ({{verified_pct}}% verified, {{total_missing}} gaps) -{{else if verified_pct >= 50}} -⚠️ Story is PARTIALLY COMPLETE ({{verified_pct}}% verified, {{total_missing}} gaps) -{{else}} -❌ Story is INCOMPLETE ({{verified_pct}}% verified, significant work missing) -{{/if}} - -**Before Revalidation:** {{total_checked_before}}/{{total_items}} checked ({{pct_before}}%) -**After Revalidation:** {{total_verified}}/{{total_items}} verified ({{verified_pct}}%) -**Accuracy:** {{#if pct_before == verified_pct}}Perfect match{{else if pct_before > verified_pct}}{{pct_before - verified_pct}}% over-reported{{else}}{{verified_pct - pct_before}}% under-reported{{/if}} - -{{#if total_missing > 0}} ---- -**Gaps Found ({{total_missing}}):** -{{#each gaps_list}} -{{@index + 1}}. {{item_type}} - {{item_description}} - Status: {{status}} - Missing: {{what_is_missing}} - {{#if evidence}}Evidence checked: {{evidence}}{{/if}} -{{/each}} ---- -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - Write detailed report to: {sprint_artifacts}/revalidation-{{story_key}}-{{timestamp}}.md - Include: verification results, gaps list, evidence for each item, recommendations - πŸ“„ Detailed report: {{report_path}} - - - - - - -βœ… Verification complete (verify-only mode) - -{{#if total_missing > 0}} -**To fill the {{total_missing}} gaps, run:** -/revalidate-story story_file={{story_file}} fill_gaps=true -{{else}} -No gaps found - story is complete! -{{/if}} - - Exit workflow - - - - βœ… No gaps to fill - story is already complete! - Exit workflow - - - - - -⚠️ TOO MANY GAPS: {{total_missing}} gaps found (max: {{max_gaps_to_fill}}) - -This story has too many missing items for automatic gap filling. -Consider: -1. Re-implementing the story from scratch with /dev-story -2. Manually implementing the gaps -3. Increasing max_gaps_to_fill in workflow.yaml (use cautiously) - -Gap filling HALTED for safety. - - HALT - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -πŸ”§ GAP FILLING MODE ({{total_missing}} gaps to fill) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Continue to Step 8 - - - - - For each gap in gaps_list: - - - - -Fill this gap? - -**Item:** {{item_description}} -**Type:** {{item_type}} ({{section}}) -**Missing:** {{what_is_missing}} - -[Y] Yes - Implement this item -[A] Auto-fill - Implement this and all remaining gaps without asking -[S] Skip - Leave this gap unfilled -[H] Halt - Stop gap filling - -Your choice: - - - - Set require_confirmation = false (auto-fill remaining) - - - - Continue to next gap - - - - Exit gap filling loop - Jump to Step 9 (Summary) - - - - - - πŸ”§ Implementing: {{item_description}} - - Load story context (Technical Requirements, Architecture Compliance, Dev Notes) - Implement missing item following story specifications - Write tests if required - Run tests to verify implementation - Verify linting/type checking passes - - - Check box [x] for this item in story file - Update File List with new/modified files - Add to Dev Agent Record: "Gap filled: {{item_description}}" - βœ… Implemented and verified - - - Stage files for this gap - Commit: "fix({{story_key}}): fill gap - {{item_description}}" - βœ… Committed - - - - - ❌ Failed to implement: {{error_message}} - Leave box unchecked - Record failure in gaps_list - Add to failed_gaps - - - - After all gaps processed: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Gap Filling Complete -βœ… Filled: {{gaps_filled}} -❌ Failed: {{gaps_failed}} -⏭️ Skipped: {{gaps_skipped}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - - - πŸ” Re-verifying filled gaps... - - For each filled gap: - Re-run verification for that item - Ensure still VERIFIED after all changes - - βœ… All filled gaps re-verified - - - Calculate final completion: - - final_verified = count of [x] across all sections - final_partial = count of [~] across all sections - final_missing = count of [ ] across all sections - final_pct = (final_verified / total_items) Γ— 100 - - - - Stage all changed files - Commit: "fix({{story_key}}): fill {{gaps_filled}} gaps from revalidation" - βœ… All gaps committed - - - - Load {sprint_status} file - Update entry with current progress: - Format: {{story_key}}: {{current_status}} # Revalidated: {{final_verified}}/{{total_items}} ({{final_pct}}%) verified - Save sprint-status.yaml - βœ… Sprint status updated with revalidation results - - - - Add to Dev Agent Record in story file: - -## Revalidation Record ({{timestamp}}) - -**Revalidation Mode:** {{#if fill_gaps}}Verify & Fill{{else}}Verify Only{{/if}} - -**Results:** -- Verified: {{final_verified}}/{{total_items}} ({{final_pct}}%) -- Gaps Found: {{total_missing}} -- Gaps Filled: {{gaps_filled}} - -**Evidence:** -{{#each verification_evidence}} -- {{item}}: {{evidence}} -{{/each}} - -{{#if gaps_filled > 0}} -**Gaps Filled:** -{{#each filled_gaps}} -- {{item}}: {{what_was_implemented}} -{{/each}} -{{/if}} - -{{#if failed_gaps.length > 0}} -**Failed to Fill:** -{{#each failed_gaps}} -- {{item}}: {{error}} -{{/each}} -{{/if}} - - Save story file - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -βœ… REVALIDATION COMPLETE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Story:** {{story_key}} - -**Final Status:** -- βœ… Verified Complete: {{final_verified}}/{{total_items}} ({{final_pct}}%) -- πŸ”Ά Partially Complete: {{final_partial}}/{{total_items}} -- ❌ Missing/Incomplete: {{final_missing}}/{{total_items}} - -{{#if fill_gaps}} -**Gap Filling Results:** -- Filled: {{gaps_filled}} -- Failed: {{gaps_failed}} -- Skipped: {{gaps_skipped}} -{{/if}} - -**Accuracy Check:** -- Before revalidation: {{pct_before}}% checked -- After revalidation: {{final_pct}}% verified -- Checkbox accuracy: {{#if pct_before == final_pct}}βœ… Perfect (0% discrepancy){{else if pct_before > final_pct}}⚠️ {{pct_before - final_pct}}% over-reported (checkboxes were optimistic){{else}}πŸ”Ά {{final_pct - pct_before}}% under-reported (work done but not checked){{/if}} - -{{#if final_pct >= 95}} -**Recommendation:** Story is COMPLETE - mark as "done" or "review" -{{else if final_pct >= 80}} -**Recommendation:** Story is mostly complete - finish remaining {{final_missing}} items then mark "review" -{{else if final_pct >= 50}} -**Recommendation:** Story has significant gaps - continue development with /dev-story -{{else}} -**Recommendation:** Story is mostly incomplete - consider re-implementing with /dev-story or /super-dev-pipeline -{{/if}} - -{{#if failed_gaps.length > 0}} -**⚠️ Manual attention needed for {{failed_gaps.length}} items that failed to fill automatically** -{{/if}} - -{{#if create_report}} -**Detailed Report:** {sprint_artifacts}/revalidation-{{story_key}}-{{timestamp}}.md -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - - diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-story/README.md b/src/modules/bmm/workflows/4-implementation/super-dev-story/README.md deleted file mode 100644 index 77786969..00000000 --- a/src/modules/bmm/workflows/4-implementation/super-dev-story/README.md +++ /dev/null @@ -1,283 +0,0 @@ -# Super-Dev-Story Workflow - -**Enhanced story development with comprehensive quality validation** - -## What It Does - -Super-dev-story is `/dev-story` on steroids - it includes ALL standard development steps PLUS additional quality gates: - -``` -Standard dev-story: - 1-8. Development cycle β†’ Mark "review" - -Super-dev-story: - 1-8. Development cycle - 9.5. Post-dev gap analysis (verify work complete) - 9.6. Automated code review (catch issues) - β†’ Fix issues if found (loop back to step 5) - 9. Mark "review" (only after all validation passes) -``` - -## When to Use - -### Use `/super-dev-story` for: - -- βœ… Security-critical features (auth, payments, PII handling) -- βœ… Complex business logic with many edge cases -- βœ… Stories you want bulletproof before human review -- βœ… High-stakes features (production releases, customer-facing) -- βœ… When you want to minimize review cycles - -### Use standard `/dev-story` for: - -- Documentation updates -- Simple UI tweaks -- Configuration changes -- Low-risk experimental features -- When speed matters more than extra validation - -## Cost vs Benefit - -| Aspect | dev-story | super-dev-story | -|--------|-----------|-----------------| -| **Tokens** | 50K-100K | 80K-150K (+30-50%) | -| **Time** | Normal | +20-30% | -| **Quality** | Good | Excellent | -| **Review cycles** | 1-3 iterations | 0-1 iterations | -| **False completions** | Possible | Prevented | - -**ROI:** Extra 30K tokens (~$0.09) prevents hours of rework and multiple review cycles - -## What Gets Validated - -### Step 9.5: Post-Dev Gap Analysis - -**Checks:** -- Tasks marked [x] β†’ Code actually exists and works? -- Required files β†’ Actually created? -- Claimed tests β†’ Actually exist and pass? -- Partial implementations β†’ Marked complete prematurely? - -**Catches:** -- ❌ "Created auth service" β†’ File doesn't exist -- ❌ "Added tests with 90% coverage" β†’ Only 60% actual -- ❌ "Implemented login" β†’ Function exists but incomplete - -**Actions if issues found:** -- Unchecks false positive tasks -- Adds tasks for missing work -- Loops back to implementation - -### Step 9.6: Automated Code Review - -**Reviews:** -- βœ… Correctness (logic errors, edge cases) -- βœ… Security (vulnerabilities, input validation) -- βœ… Architecture (pattern compliance, SOLID principles) -- βœ… Performance (inefficiencies, optimization opportunities) -- βœ… Testing (coverage gaps, test quality) -- βœ… Code Quality (readability, maintainability) - -**Actions if issues found:** -- Adds review findings as tasks -- Loops back to implementation -- Continues until issues resolved - -## Usage - -### Basic Usage - -```bash -# Load any BMAD agent -/super-dev-story - -# Follows same flow as dev-story, with extra validation -``` - -### Specify Story - -```bash -/super-dev-story _bmad-output/implementation-artifacts/story-1.2.md -``` - -### Expected Flow - -``` -1. Pre-dev gap analysis - β”œβ”€ "Approve task updates? [Y/A/n/e/s/r]" - └─ Select option - -2. Development (standard TDD cycle) - └─ Implements all tasks - -3. Post-dev gap analysis - β”œβ”€ Scans codebase - β”œβ”€ If gaps: adds tasks, loops back - └─ If clean: proceeds - -4. Code review - β”œβ”€ Analyzes all changes - β”œβ”€ If issues: adds tasks, loops back - └─ If clean: proceeds - -5. Story marked "review" - └─ Truly complete! -``` - -## Fix Iteration Safety - -Super-dev has a **max iteration limit** (default: 3) to prevent infinite loops: - -```yaml -# workflow.yaml -super_dev_settings: - max_fix_iterations: 3 # Stop after 3 fix cycles - fail_on_critical_issues: true # HALT if critical security issues -``` - -If exceeded: -``` -πŸ›‘ Maximum Fix Iterations Reached - -Attempted 3 fix cycles. -Manual intervention required. - -Issues remaining: -- [List of unresolved issues] -``` - -## Examples - -### Example 1: Perfect First Try - -``` -/super-dev-story - -Pre-gap: βœ… Tasks accurate -Development: βœ… 8 tasks completed -Post-gap: βœ… All work verified -Code review: βœ… No issues - -β†’ Story complete! (45 minutes, 85K tokens) -``` - -### Example 2: Post-Dev Catches Incomplete Work - -``` -/super-dev-story - -Pre-gap: βœ… Tasks accurate -Development: βœ… 8 tasks completed -Post-gap: ⚠️ Tests claim 90% coverage, actual 65% - -β†’ Adds task: "Increase test coverage to 90%" -β†’ Implements missing tests -β†’ Post-gap: βœ… Now 92% coverage -β†’ Code review: βœ… No issues - -β†’ Story complete! (52 minutes, 95K tokens) -``` - -### Example 3: Code Review Finds Security Issue - -``` -/super-dev-story - -Pre-gap: βœ… Tasks accurate -Development: βœ… 10 tasks completed -Post-gap: βœ… All work verified -Code review: 🚨 CRITICAL - SQL injection vulnerability - -β†’ Adds task: "Fix SQL injection in user search" -β†’ Implements parameterized queries -β†’ Post-gap: βœ… Verified -β†’ Code review: βœ… Security issue resolved - -β†’ Story complete! (58 minutes, 110K tokens) -``` - -## Comparison to Standard Workflow - -### Standard Flow (dev-story) - -``` -Day 1: Develop story (30 min) -Day 2: Human review finds 3 issues -Day 3: Fix issues (20 min) -Day 4: Human review again -Day 5: Approved - -Total: 5 days, 2 review cycles -``` - -### Super-Dev Flow - -``` -Day 1: Super-dev-story - - Development (30 min) - - Post-gap finds 1 issue (auto-fix 5 min) - - Code review finds 2 issues (auto-fix 15 min) - - Complete (50 min total) - -Day 2: Human review -Day 3: Approved (minimal/no changes needed) - -Total: 3 days, 1 review cycle -``` - -**Savings:** 2 days, 1 fewer review cycle, higher initial quality - -## Troubleshooting - -### "Super-dev keeps looping forever" - -**Cause:** Each validation finds new issues -**Solution:** This indicates quality problems. Review max_fix_iterations setting or manually intervene. - -### "Post-dev gap analysis keeps failing" - -**Cause:** Dev agent marking tasks complete prematurely -**Solution:** This is expected! Super-dev catches this. The loop ensures actual completion. - -### "Code review too strict" - -**Cause:** Reviewing for issues standard dev-story would miss -**Solution:** This is intentional. For less strict review, use standard dev-story. - -### "Too many tokens/too slow" - -**Cause:** Multi-stage validation adds overhead -**Solution:** Use standard dev-story for non-critical stories. Reserve super-dev for important work. - -## Best Practices - -1. **Reserve for important stories** - Don't use for trivial changes -2. **Trust the process** - Fix iterations mean it's working correctly -3. **Review limits** - Adjust max_fix_iterations if stories are complex -4. **Monitor costs** - Track token usage vs review cycle savings -5. **Learn patterns** - Code review findings inform future architecture - -## Configuration Reference - -```yaml -# _bmad/bmm/config.yaml or _bmad/bmgd/config.yaml - -# Per-project settings -super_dev_settings: - post_dev_gap_analysis: true # Enable post-dev validation - auto_code_review: true # Enable automatic code review - fail_on_critical_issues: true # HALT on security vulnerabilities - max_fix_iterations: 3 # Maximum fix cycles before manual intervention - auto_fix_minor_issues: false # Auto-fix LOW severity without asking -``` - -## See Also - -- [dev-story workflow](../dev-story/) - Standard development workflow -- [gap-analysis workflow](../gap-analysis/) - Standalone audit tool -- [Gap Analysis Guide](../../../../docs/gap-analysis.md) - Complete documentation -- [Super-Dev Mode Concept](../../../../docs/super-dev-mode.md) - Vision and roadmap - ---- - -**Super-Dev-Story: Because "done" should mean DONE** βœ… diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-story/instructions.xml b/src/modules/bmm/workflows/4-implementation/super-dev-story/instructions.xml deleted file mode 100644 index b296847a..00000000 --- a/src/modules/bmm/workflows/4-implementation/super-dev-story/instructions.xml +++ /dev/null @@ -1,299 +0,0 @@ - - The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml - You MUST have already loaded and processed: {installed_path}/workflow.yaml - Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level} - Generate all documents in {document_output_language} - πŸš€ SUPER-DEV MODE: Enhanced quality workflow with post-implementation validation and automated code review - This workflow orchestrates existing workflows with additional validation steps - - - - - - - 🎯 RUN DEV-STORY - Complete all standard development steps - This includes: story loading, pre-dev gap analysis, development, testing, and task completion - - πŸš€ **Super-Dev-Story: Enhanced Quality Workflow** - - Running standard dev-story workflow (Steps 1-8)... - - This includes: - βœ… Story loading and validation - βœ… Pre-dev gap analysis - βœ… TDD implementation cycle - βœ… Comprehensive testing - βœ… Task completion validation - - After dev-story completes, super-dev will add: - βœ… Post-dev gap analysis - βœ… Automated code review - βœ… Auto push-all - - - - - - Pass through any user-provided story file path and auto-accept setting - - - - βœ… Dev-story complete - all tasks implemented and tested - - Proceeding to super-dev enhancements... - - - - - ❌ Dev-story did not complete successfully - - Cannot proceed with super-dev enhancements. - Fix issues and retry. - - HALT - dev-story must complete first - - - - - - - - - πŸ” POST-DEV VALIDATION - Verify all work actually completed! - This catches incomplete implementations that were prematurely marked done - - - πŸ”Ž **Post-Development Gap Analysis** - - All tasks marked complete. Verifying against codebase reality... - - - - Re-read story file to get requirements and tasks - Extract all tasks marked [x] complete - For each completed task, identify what should exist in codebase - - - Use Glob to find files that should have been created - Use Grep to search for functions/classes that should exist - Use Read to verify implementation completeness (not just existence) - Run tests to verify claimed test coverage actually exists and passes - - - Compare claimed work vs actual implementation: - - **POST-DEV VERIFICATION:** - βœ… Verified Complete: - - List tasks where code fully exists and works - - Confirm tests exist and pass - - Verify implementation matches requirements - - - ❌ False Positives Detected: - - List tasks marked [x] but code missing or incomplete - - Identify claimed tests that don't exist or fail - - Note partial implementations marked as complete - - - - - - ⚠️ **Post-Dev Gaps Detected!** - - **Tasks marked complete but implementation incomplete:** - {{list_false_positives_with_details}} - - These issues must be addressed before story can be marked complete. - - - Uncheck false positive tasks in story file - Add new tasks for missing work - Update Gap Analysis section with post-dev findings - - πŸ”„ Re-invoking dev-story to complete missing work... - - - - - Resume with added tasks for missing work - - - βœ… Missing work completed. Proceeding to code review... - - - - βœ… **Post-Dev Validation Passed** - - All tasks verified complete against codebase. - Proceeding to code review... - - Update Gap Analysis section with post-dev verification results - - - - - - - - - πŸ‘€ AUTO CODE REVIEW - Independent quality validation - - - πŸ” **Running Automated Code Review** - - Analyzing implementation for issues... - - - - - Run code review on completed story - - - Parse code review results from story file "Code Review" section - Extract issues by severity (Critical, High, Medium, Low) - Count total issues found - - - 🚨 **Code Review Found Issues Requiring Fixes** - - Issues found: {{total_issue_count}} - - Critical: {{critical_count}} - - High: {{high_count}} - - Medium: {{medium_count}} - - Low: {{low_count}} - - Adding review findings to story tasks and re-running dev-story... - - - Add code review findings as tasks in story file - - - - - Fix code review issues - - - βœ… Code review issues resolved. Proceeding to push... - - - - ℹ️ **Code Review Found Minor Issues** - - - Medium: {{medium_count}} - - Low: {{low_count}} - - - Auto-fix these minor issues? [Y/n/skip]: - - - Add review findings as tasks - - - - - - - - Document issues in story file - ℹ️ Minor issues documented. Proceeding to push... - - - - - βœ… **Code Review Passed** - - No issues found. Implementation meets quality standards. - Proceeding to push... - - - - - - - - - - πŸ“ PUSH-ALL - Stage, commit, and push with safety validation - ⚑ TARGETED COMMIT: Only commit files from THIS story's File List (safe for parallel agents) - - - Read story file and extract the "File List" section - Parse all file paths listed (relative to repo root) - Also include the story file itself in the list - Store as {{story_files}} - space-separated list of all files - - πŸ“ **Committing Story Changes** - - Files from this story: - {{story_files}} - - Running push-all with targeted file list (parallel-agent safe)... - - - - - - Only commit files changed by this story - - - - βœ… Changes pushed to remote successfully - - - - ⚠️ Push failed but story is complete locally - - You can push manually when ready. - - - - - - - - - - πŸŽ‰ **SUPER-DEV STORY COMPLETE, {user_name}!** - - **Quality Gates Passed:** - βœ… Pre-dev gap analysis - Tasks validated before work - βœ… Development - All tasks completed with TDD - βœ… Post-dev gap analysis - Implementation verified - βœ… Code review - Quality and security validated - βœ… Pushed to remote - Changes backed up - - **Story File:** {{story_file}} - **Status:** review (ready for human review) - - --- - - **What Super-Dev Validated:** - 1. πŸ” Tasks matched codebase reality before starting - 2. πŸ’» Implementation completed per requirements - 3. βœ… No false positive completions (all work verified) - 4. πŸ‘€ Code quality and security validated - 5. πŸ“ Changes committed and pushed to remote - - **Next Steps:** - - Review the completed story - - Verify business requirements met - - Merge when approved - - **Note:** This story went through enhanced quality validation. - It should require minimal human review. - - - Based on {user_skill_level}, ask if user needs explanations about implementation, decisions, or findings - - - Provide clear, contextual explanations - - - πŸ’‘ **Tip:** This story was developed with super-dev-story for enhanced quality. - - For faster development, use standard `dev-story` workflow. - For maximum quality, continue using `super-dev-story`. - - - - diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-story/workflow.md b/src/modules/bmm/workflows/4-implementation/super-dev-story/workflow.md new file mode 100644 index 00000000..20dcfea4 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/super-dev-story/workflow.md @@ -0,0 +1,311 @@ +# Super Dev Story v3.0 - Development with Quality Gates + + +Complete story development pipeline: dev-story β†’ validation β†’ code review β†’ push. +Automatically re-invokes dev-story if gaps or review issues found. +Ensures production-ready code before pushing. + + + +**Quality Over Speed** + +Don't just implementβ€”verify, review, fix. +- Run dev-story for implementation +- Validate with gap analysis +- Code review for quality +- Fix issues before pushing +- Only push when truly ready + + + +name: super-dev-story +version: 3.0.0 + +stages: + - dev-story: "Implement the story" + - validate: "Run gap analysis" + - review: "Code review" + - push: "Safe commit and push" + +defaults: + max_rework_loops: 3 + auto_push: false + review_depth: "standard" # quick | standard | deep + validation_depth: "quick" + +quality_gates: + validation_threshold: 90 # % tasks must be verified + review_threshold: "pass" # pass | pass_with_warnings + + + +@patterns/verification.md +@patterns/hospital-grade.md + + + + + +**Load story and prepare pipeline** + +```bash +STORY_FILE="{{story_file}}" +[ -f "$STORY_FILE" ] || { echo "❌ story_file required"; exit 1; } +``` + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸš€ SUPER DEV STORY PIPELINE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{story_key}} +Stages: dev-story β†’ validate β†’ review β†’ push + +Quality Gates: +- Validation: β‰₯{{validation_threshold}}% verified +- Review: {{review_threshold}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Initialize: +- rework_count = 0 +- stage = "dev-story" + + + +**Stage 1: Implement the story** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“ STAGE 1: DEV-STORY +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Invoke dev-story workflow: +``` +/dev-story story_file={{story_file}} +``` + +Wait for completion. Capture: +- files_created +- files_modified +- tasks_completed + +``` +βœ… Dev-story complete +Files: {{file_count}} created/modified +Tasks: {{tasks_completed}}/{{total_tasks}} +``` + + + +**Stage 2: Validate implementation** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ” STAGE 2: VALIDATION +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Invoke validation: +``` +/validate scope=story target={{story_file}} depth={{validation_depth}} +``` + +Capture results: +- verified_pct +- false_positives +- category + +**Check quality gate:** +``` +if verified_pct < validation_threshold: + REWORK_NEEDED = true + reason = "Validation below {{validation_threshold}}%" + +if false_positives > 0: + REWORK_NEEDED = true + reason = "{{false_positives}} tasks marked done but missing" +``` + +``` +{{#if REWORK_NEEDED}} +⚠️ Validation failed: {{reason}} +{{else}} +βœ… Validation passed: {{verified_pct}}% verified +{{/if}} +``` + + + +**Stage 3: Code review** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“‹ STAGE 3: CODE REVIEW +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +Invoke code review: +``` +/multi-agent-review files={{files_modified}} depth={{review_depth}} +``` + +Capture results: +- verdict (PASS, PASS_WITH_WARNINGS, NEEDS_REWORK) +- issues + +**Check quality gate:** +``` +if verdict == "NEEDS_REWORK": + REWORK_NEEDED = true + reason = "Code review found blocking issues" + +if review_threshold == "pass" AND verdict == "PASS_WITH_WARNINGS": + REWORK_NEEDED = true + reason = "Warnings not allowed in strict mode" +``` + +``` +{{#if REWORK_NEEDED}} +⚠️ Review failed: {{reason}} +Issues: {{issues}} +{{else}} +βœ… Review passed: {{verdict}} +{{/if}} +``` + + + +**Handle rework loop** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ”„ REWORK REQUIRED (Loop {{rework_count + 1}}/{{max_rework_loops}}) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Reason: {{reason}} + +{{#if validation_issues}} +Validation Issues: +{{#each validation_issues}} +- {{this}} +{{/each}} +{{/if}} + +{{#if review_issues}} +Review Issues: +{{#each review_issues}} +- {{this}} +{{/each}} +{{/if}} +``` + +**Check loop limit:** +``` +rework_count++ +if rework_count > max_rework_loops: + echo "❌ Max rework loops exceeded" + echo "Manual intervention required" + HALT +``` + +**Re-invoke dev-story with issues:** +``` +/dev-story story_file={{story_file}} fix_issues={{issues}} +``` + +After dev-story completes, return to validation stage. + + + +**Stage 4: Push changes** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +πŸ“¦ STAGE 4: PUSH +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**Generate commit message from story:** +``` +feat({{epic}}): {{story_title}} + +- Implemented {{task_count}} tasks +- Verified: {{verified_pct}}% +- Review: {{verdict}} + +Story: {{story_key}} +``` + +**If auto_push:** +``` +/push-all commit_message="{{message}}" auto_push=true +``` + +**Otherwise, ask:** +``` +Ready to push? + +[Y] Yes, push now +[N] No, keep local (can push later) +[R] Review changes first +``` + + + +**Display pipeline results** + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +βœ… SUPER DEV STORY COMPLETE +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story: {{story_key}} + +Pipeline Results: +- Dev-Story: βœ… Complete +- Validation: βœ… {{verified_pct}}% verified +- Review: βœ… {{verdict}} +- Push: {{pushed ? "βœ… Pushed" : "⏸️ Local only"}} + +Rework Loops: {{rework_count}} +Files Changed: {{file_count}} +Commit: {{commit_hash}} + +{{#if pushed}} +Branch: {{branch}} +Ready for PR: gh pr create +{{/if}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + + + + + +```bash +# Standard pipeline +/super-dev-story story_file=docs/sprint-artifacts/2-5-auth.md + +# With auto-push +/super-dev-story story_file=docs/sprint-artifacts/2-5-auth.md auto_push=true + +# Strict review mode +/super-dev-story story_file=docs/sprint-artifacts/2-5-auth.md review_threshold=pass +``` + + + +**Dev-story fails:** Report error, halt pipeline. +**Validation below threshold:** Enter rework loop. +**Review finds blocking issues:** Enter rework loop. +**Max rework loops exceeded:** Halt, require manual intervention. +**Push fails:** Report error, commit preserved locally. + + + +- [ ] Dev-story completed +- [ ] Validation β‰₯ threshold +- [ ] Review passed +- [ ] Changes committed +- [ ] Pushed (if requested) +- [ ] Story status updated + diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-story/workflow.yaml b/src/modules/bmm/workflows/4-implementation/super-dev-story/workflow.yaml index 530f041c..7185b853 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-story/workflow.yaml +++ b/src/modules/bmm/workflows/4-implementation/super-dev-story/workflow.yaml @@ -14,7 +14,7 @@ date: system-generated # Workflow components installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/super-dev-story" -instructions: "{installed_path}/instructions.xml" +instructions: "{installed_path}/workflow.md" validation: "{installed_path}/checklist.md" story_file: "" # Explicit story path; auto-discovered if empty