diff --git a/src/modules/bmgd/workflows/4-production/dev-story/instructions.xml b/src/modules/bmgd/workflows/4-production/dev-story/instructions.xml index 13b2b004..97aef086 100644 --- a/src/modules/bmgd/workflows/4-production/dev-story/instructions.xml +++ b/src/modules/bmgd/workflows/4-production/dev-story/instructions.xml @@ -138,6 +138,28 @@ 🔍 MANDATORY GAP ANALYSIS - Validate draft tasks against actual codebase reality! This step ensures tasks reflect current codebase state, preventing duplicate implementations and missed dependencies. + + + Extract timestamp from Gap Analysis section + + ⚡ **Gap Analysis Already Complete** ({{gap_analysis_timestamp}}) + + Story was recently validated against codebase. Skipping re-analysis. + - What Exists: {{existing_summary}} + - What's Missing: {{missing_summary}} + + Proceeding to implementation... + + + + + + + + ⚡ **Skipping Gap Analysis** (story pre-validated by batch-super-dev) + + + Extract story requirements, acceptance criteria, and draft tasks from story file Identify technical areas mentioned in tasks (files, classes, functions, services, components) 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 index 2037519d..080f0339 100644 --- a/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md +++ b/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md @@ -215,6 +215,65 @@ Run `/bmad:bmm:workflows:sprint-status` to see status. + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📊 SCORING STORY COMPLEXITY +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + + For each validated story: + + + Read story file: {{file_path}} + + Count unchecked tasks ([ ]) in Tasks/Subtasks section → task_count + Extract file paths mentioned in tasks → file_count + Scan story title and task descriptions for risk keywords + + Calculate complexity score: + - Base score = task_count + - Add 5 for each HIGH risk keyword (auth, security, payment, migration, database, schema) + - Add 2 for each MEDIUM risk keyword (api, integration, external, cache) + - Add 0 for LOW risk keywords (ui, style, config, docs, test) + + + Assign complexity level: + - MICRO: task_count ≤ 3 AND complexity_score ≤ 5 AND no HIGH risk keywords + - COMPLEX: task_count ≥ 16 OR complexity_score ≥ 20 OR has HIGH risk keywords + - STANDARD: everything else + + + Store complexity_level for story: {{story_key}}.complexity = {level, score, task_count, risk_keywords} + + + Group stories by complexity level + + +📊 **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}} +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + + **Select stories to process:** diff --git a/src/modules/bmm/workflows/4-implementation/batch-super-dev/workflow.yaml b/src/modules/bmm/workflows/4-implementation/batch-super-dev/workflow.yaml index 392cce0b..793ae25c 100644 --- a/src/modules/bmm/workflows/4-implementation/batch-super-dev/workflow.yaml +++ b/src/modules/bmm/workflows/4-implementation/batch-super-dev/workflow.yaml @@ -1,7 +1,7 @@ name: batch-super-dev -description: "Interactive batch selector for super-dev-pipeline - select multiple ready-for-dev stories and process them sequentially with full quality gates. Includes smart story validation and automatic creation/regeneration." +description: "Interactive batch selector for super-dev-pipeline with complexity-based routing. Micro stories get lightweight path, standard stories get full pipeline, complex stories get enhanced validation." author: "BMad" -version: "1.2.0" +version: "1.3.0" # Critical variables from config config_source: "{project-root}/_bmad/bmm/config.yaml" @@ -38,6 +38,29 @@ validation: require_gap_analysis: true # Current State must have ✅/❌ markers backup_before_regenerate: true # Create .backup file before regenerating +# Story complexity scoring (NEW in v1.3.0) +# Routes stories to appropriate pipeline based on complexity +complexity: + enabled: true + thresholds: + micro: # Lightweight path: skip gap analysis + code review + max_tasks: 3 + max_files: 5 + risk_keywords: [] # No high-risk keywords allowed + standard: # Normal path: full pipeline + max_tasks: 15 + max_files: 30 + risk_keywords: ["api", "service", "component", "feature"] + complex: # Enhanced path: extra validation, consider splitting + min_tasks: 16 + risk_keywords: ["auth", "security", "migration", "database", "payment", "encryption"] + + # Risk keyword scoring (adds to complexity) + risk_weights: + high: ["auth", "security", "payment", "encryption", "migration", "database", "schema"] + medium: ["api", "integration", "external", "third-party", "cache"] + low: ["ui", "style", "config", "docs", "test"] + # Execution settings execution: continue_on_failure: true # Keep processing remaining stories if one fails diff --git a/src/modules/bmm/workflows/4-implementation/dev-story/instructions.xml b/src/modules/bmm/workflows/4-implementation/dev-story/instructions.xml index 82140472..71a28aa7 100644 --- a/src/modules/bmm/workflows/4-implementation/dev-story/instructions.xml +++ b/src/modules/bmm/workflows/4-implementation/dev-story/instructions.xml @@ -138,6 +138,28 @@ 🔍 MANDATORY GAP ANALYSIS - Validate draft tasks against actual codebase reality! This step ensures tasks reflect current codebase state, preventing duplicate implementations and missed dependencies. + + + Extract timestamp from Gap Analysis section + + ⚡ **Gap Analysis Already Complete** ({{gap_analysis_timestamp}}) + + Story was recently validated against codebase. Skipping re-analysis. + - What Exists: {{existing_summary}} + - What's Missing: {{missing_summary}} + + Proceeding to implementation... + + + + + + + + ⚡ **Skipping Gap Analysis** (story pre-validated by batch-super-dev) + + + Extract story requirements, acceptance criteria, and draft tasks from story file Identify technical areas mentioned in tasks (files, classes, functions, services, components) diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-01-init.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-01-init.md index f5891601..66c7447e 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-01-init.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-01-init.md @@ -91,6 +91,52 @@ Count: - Unchecked tasks: `{unchecked_task_count}` - Checked tasks: `{checked_task_count}` +### 4.5 Pre-Flight Bailout Check (NEW v1.3.0) + +**Check for early bailout conditions before investing more tokens:** + +``` +If total_task_count == 0: + Display: + ⚠️ EARLY BAILOUT: No Tasks Found + + Story file exists but has no tasks in Tasks/Subtasks section. + - Story may be incomplete or malformed + - Run create-story or validate-create-story first + + HALT - Nothing to implement + +If unchecked_task_count == 0: + Display: + ✅ EARLY BAILOUT: Story Already Complete + + All {checked_task_count} tasks are already marked complete. + - No implementation work required + - Story may need status update to "review" or "done" + + {if batch mode: Continue to next story} + {if interactive mode: HALT - Story complete} + +If story file missing required sections (Tasks, Acceptance Criteria): + Display: + ⚠️ EARLY BAILOUT: Invalid Story Format + + Story file is missing required sections: + - Missing: {missing_sections} + + Run validate-create-story to fix the story format. + + HALT - Cannot proceed with invalid story +``` + +**If all bailout checks pass:** +``` +✅ Pre-flight checks passed + - Story valid: {total_task_count} tasks + - Work remaining: {unchecked_task_count} unchecked + - Ready for implementation +``` + ### 5. Load Project Context Read `**/project-context.md`: @@ -101,7 +147,49 @@ Read `**/project-context.md`: Cache in memory for use across steps. -### 6. Detect Development Mode +### 6. Apply Complexity Routing (NEW v1.2.0) + +**Check complexity_level parameter:** +- `micro`: Lightweight path - skip pre-gap analysis (step 2) and code review (step 5) +- `standard`: Full pipeline - all steps +- `complex`: Full pipeline with warnings + +**Determine skip_steps based on complexity:** +``` +If complexity_level == "micro": + skip_steps = [2, 5] + pipeline_mode = "lightweight" + + Display: + 🚀 MICRO COMPLEXITY DETECTED + + Lightweight path enabled: + - ⏭️ Skipping Pre-Gap Analysis (low risk) + - ⏭️ Skipping Code Review (simple changes) + - Estimated token savings: 50-70% + +If complexity_level == "complex": + skip_steps = [] + pipeline_mode = "enhanced" + + Display: + 🔒 COMPLEX STORY DETECTED + + Enhanced validation enabled: + - Full pipeline with all quality gates + - Consider splitting if story fails + + ⚠️ Warning: This story has high-risk elements. + Proceeding with extra attention. + +If complexity_level == "standard": + skip_steps = [] + pipeline_mode = "standard" +``` + +Store `skip_steps` and `pipeline_mode` in state file. + +### 7. Detect Development Mode **Check File List section in story:** @@ -140,7 +228,7 @@ done - `new_count == 0` → **brownfield** (all existing files) - Both > 0 → **hybrid** (mix of new and existing) -### 7. Display Initialization Summary +### 8. Display Initialization Summary ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -150,6 +238,7 @@ done Story: {story_title} File: {story_file} Mode: {mode} (interactive|batch) +Complexity: {complexity_level} → {pipeline_mode} path Development Type: {greenfield|brownfield|hybrid} - Existing files: {existing_count} @@ -164,19 +253,23 @@ Tasks: Pipeline Steps: 1. ✅ Initialize (current) -2. ⏳ Pre-Gap Analysis - Validate tasks +2. {⏭️ SKIP|⏳} Pre-Gap Analysis - Validate tasks {if micro: "(skipped - low risk)"} 3. ⏳ Implement - {TDD|Refactor|Hybrid} 4. ⏳ Post-Validation - Verify completion -5. ⏳ Code Review - Find 3-10 issues +5. {⏭️ SKIP|⏳} Code Review - Find issues {if micro: "(skipped - simple changes)"} 6. ⏳ Complete - Commit + push 7. ⏳ Summary - Audit trail +{if pipeline_mode == "lightweight": + 🚀 LIGHTWEIGHT PATH: Steps 2 and 5 will be skipped (50-70% token savings) +} + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚠️ ANTI-VIBE-CODING ENFORCEMENT ACTIVE This workflow uses step-file architecture to ensure: -- ✅ No skipping steps +- ✅ No skipping steps (except complexity-based routing) - ✅ No optimizing sequences - ✅ No looking ahead - ✅ No vibe coding even at 200K tokens @@ -186,7 +279,7 @@ You will follow each step file PRECISELY. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` -### 8. Initialize State File +### 9. Initialize State File Create state file at `{sprint_artifacts}/super-dev-state-{story_id}.yaml`: @@ -197,9 +290,15 @@ story_file: "{story_file}" mode: "{mode}" development_type: "{greenfield|brownfield|hybrid}" +# Complexity routing (NEW v1.2.0) +complexity: + level: "{complexity_level}" # micro | standard | complex + pipeline_mode: "{pipeline_mode}" # lightweight | standard | enhanced + skip_steps: {skip_steps} # e.g., [2, 5] for micro + stepsCompleted: [1] lastStep: 1 -currentStep: 2 +currentStep: 2 # Or 3 if step 2 is skipped status: "in_progress" started_at: "{timestamp}" @@ -220,24 +319,24 @@ steps: status: completed completed_at: "{timestamp}" step-02-pre-gap-analysis: - status: pending + status: {pending|skipped} # skipped if complexity == micro step-03-implement: status: pending step-04-post-validation: status: pending step-05-code-review: - status: pending + status: {pending|skipped} # skipped if complexity == micro step-06-complete: status: pending step-07-summary: status: pending ``` -### 9. Display Menu (Interactive) or Proceed (Batch) +### 10. Display Menu (Interactive) or Proceed (Batch) **Interactive Mode Menu:** ``` -[C] Continue to Pre-Gap Analysis +[C] Continue to {next step name} [H] Halt pipeline ``` @@ -245,8 +344,18 @@ steps: ## CRITICAL STEP COMPLETION +**Determine next step based on complexity routing:** + +``` +If 2 in skip_steps (micro complexity): + nextStepFile = '{workflow_path}/steps/step-03-implement.md' + Display: "⏭️ Skipping Pre-Gap Analysis (micro complexity) → Proceeding to Implementation" +Else: + nextStepFile = '{workflow_path}/steps/step-02-pre-gap-analysis.md' +``` + **ONLY WHEN** initialization is complete, -load and execute `{nextStepFile}` for pre-gap analysis. +load and execute `{nextStepFile}`. --- diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-03-implement.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-03-implement.md index d89905de..912077f5 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-03-implement.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-03-implement.md @@ -32,11 +32,12 @@ Implement all unchecked tasks using appropriate methodology: ### Implementation Principles -- **ONE TASK AT A TIME** - Never batch multiple tasks -- **RUN TESTS FREQUENTLY** - After each significant change +- **DEFAULT: ONE TASK AT A TIME** - Execute tasks individually unless smart batching applies +- **SMART BATCHING EXCEPTION** - Low-risk patterns (package installs, imports) may batch +- **RUN TESTS FREQUENTLY** - After each task or batch completion - **FOLLOW PROJECT PATTERNS** - Never invent new patterns - **NO VIBE CODING** - Follow the sequence exactly -- **VERIFY EACH TASK** - Check works before moving to next +- **VERIFY BEFORE PROCEEDING** - Confirm success before next task/batch ### Adaptive Methodology diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-04-post-validation.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-04-post-validation.md index ac8e8b24..fd63b543 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-04-post-validation.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-04-post-validation.md @@ -338,12 +338,14 @@ All work verified. Proceeding to Code Review... **Interactive Mode Menu (only if no false positives):** ``` -[C] Continue to Code Review +[C] Continue to {next step based on complexity: Code Review | Complete} [V] Run verification again [T] Run tests again [H] Halt pipeline ``` +{if micro complexity: "⏭️ Code Review will be skipped (lightweight path)"} + **Batch Mode:** - Auto re-run implementation if false positives - Auto-continue if all verified @@ -380,13 +382,24 @@ read("{file_path}") ## CRITICAL STEP COMPLETION -**ONLY WHEN** [all tasks verified AND zero false positives], -load and execute `{nextStepFile}` for code review. - **IF** [false positives detected], load and execute `{prevStepFile}` to complete missing work, then RE-RUN this step. +**ONLY WHEN** [all tasks verified AND zero false positives]: + +**Determine next step based on complexity routing:** + +``` +If 5 in skip_steps (micro complexity): + nextStepFile = '{workflow_path}/steps/step-06-complete.md' + Display: "⏭️ Skipping Code Review (micro complexity) → Proceeding to Complete" +Else: + nextStepFile = '{workflow_path}/steps/step-05-code-review.md' +``` + +Load and execute `{nextStepFile}`. + --- ## SUCCESS/FAILURE METRICS diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-05-code-review.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-05-code-review.md index 4f764389..314c26c8 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-05-code-review.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/steps/step-05-code-review.md @@ -36,6 +36,45 @@ Perform adversarial code review: 5. Fix all issues 6. Verify tests still pass +### Multi-Agent Review Enhancement (NEW v1.3.0) + +**Check complexity level from state file:** + +``` +If complexity_level == "complex": + Display: + 🔒 COMPLEX STORY - Enhanced Review Recommended + + This story involves high-risk changes. Consider using: + /multi-agent-review for multi-perspective code review + + Multi-agent review provides: + - Architecture review by architect-reviewer agent + - Security audit by auditor-security agent + - Performance analysis by optimizer-performance agent + - Dynamic agent selection based on changed files + + [M] Use multi-agent review (recommended for complex) + [S] Use standard adversarial review + [B] Use both (most thorough) + +If complexity_level == "standard" AND mode == "interactive": + Display: + ⚙️ STANDARD STORY - Review Options + + [S] Standard adversarial review (default) + [M] Multi-agent review (optional enhancement) +``` + +**If multi-agent review selected:** +- Invoke `/multi-agent-review` slash command +- Capture review findings +- Merge with standard review categories +- Continue with issue fixing + +**If standard review selected:** +- Continue with adversarial review below + ## MANDATORY EXECUTION RULES ### Adversarial Requirements diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml index 5ecb4e00..37fa2db2 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml @@ -1,7 +1,7 @@ name: super-dev-pipeline -description: "Step-file architecture with smart batching - works for both greenfield and brownfield development with disciplined execution and intelligent task grouping" +description: "Step-file architecture with complexity-based routing and smart batching. Micro stories get lightweight path, standard/complex get full quality gates." author: "BMad" -version: "1.1.0" # Added smart batching feature +version: "1.2.0" # Added complexity-based routing # Critical variables from config config_source: "{project-root}/_bmad/bmm/config.yaml" @@ -20,6 +20,24 @@ checklists_path: "{installed_path}/checklists" state_file: "{sprint_artifacts}/super-dev-state-{{story_id}}.yaml" audit_trail: "{sprint_artifacts}/audit-super-dev-{{story_id}}-{{date}}.yaml" +# Complexity level (passed from batch-super-dev or set manually) +# Controls which pipeline steps to execute +complexity_level: "standard" # micro | standard | complex + +# Complexity-based step skipping (NEW v1.2.0) +complexity_routing: + micro: + skip_steps: [2, 5] # Skip pre-gap analysis and code review + description: "Lightweight path for simple stories (≤3 tasks, low risk)" + standard: + skip_steps: [] # Full pipeline + description: "Normal path with all quality gates" + complex: + skip_steps: [] # Full pipeline + warnings + description: "Enhanced path for high-risk stories" + warn_before_start: true + suggest_split: true + # Workflow modes modes: interactive: