diff --git a/docs/autonomous-epic-processing.md b/docs/autonomous-epic-processing.md index f0a2f569..bbe3b918 100644 --- a/docs/autonomous-epic-processing.md +++ b/docs/autonomous-epic-processing.md @@ -154,16 +154,37 @@ Ready to merge! ## Implementation Status -- 🚧 **Planned** for BMAD v6.1.0 -- Requires: Super-dev mode (v6.0.0-alpha.23) -- Depends on: Robust error handling, progress tracking +- ✅ **IMPLEMENTED** in BMAD v6.0.0-alpha.22+ +- Available as: `/autonomous-epic` workflow +- Requires: Gap analysis and super-dev-story workflows +- Status: Ready for testing and feedback + +## Usage + +```bash +# Load any BMAD agent (PM, Dev, SM) +/autonomous-epic + +# Or specify epic number directly: +/autonomous-epic 2 +``` + +See [autonomous-epic workflow README](../src/modules/bmm/workflows/4-implementation/autonomous-epic/README.md) for complete documentation. + +## Real-World Usage + +**This is production-ready but experimental.** We recommend: +1. Test with small epics first (3-5 stories) +2. Monitor token usage and quality +3. Review completion reports thoroughly +4. Provide feedback to improve the feature ## Contributing -Want to help build autonomous epic processing? +Found issues or have improvements? See [CONTRIBUTING.md](../CONTRIBUTING.md) --- -**The future: Tell BMAD what you want built, come back when it's done** ✨ +**The future is NOW: Tell BMAD "Do Epic 4" and come back when it's done** ✨ diff --git a/src/modules/bmgd/workflows/4-production/autonomous-epic/README.md b/src/modules/bmgd/workflows/4-production/autonomous-epic/README.md new file mode 100644 index 00000000..a7b02bb6 --- /dev/null +++ b/src/modules/bmgd/workflows/4-production/autonomous-epic/README.md @@ -0,0 +1,651 @@ +# Autonomous Epic Processing + +**"Do Epic 4 for me" - Full automation of epic completion** + +## What It Does + +Autonomous epic processing combines just-in-time planning with automated development: + +``` +/autonomous-epic 2 + +→ Creates Story 2.1 → Develops with super-dev-story → Commits → Done ✅ +→ Creates Story 2.2 → Develops with super-dev-story → Commits → Done ✅ +→ Creates Story 2.3 → Develops with super-dev-story → Commits → Done ✅ +... +→ Entire Epic 2 complete! 🎉 +``` + +## How It Works + +``` +┌──────────────────────────────────────────────────┐ +│ Autonomous Epic Processor │ +│ │ +│ For each story in epic (sequential): │ +│ ┌─────────────────────────────────────────────┐ │ +│ │ 1. create-story (just-in-time planning) │ │ +│ │ ↓ │ │ +│ │ 2. super-dev-story (or dev-story) │ │ +│ │ ├─ Pre-dev gap analysis │ │ +│ │ ├─ Development (TDD) │ │ +│ │ ├─ Post-dev gap analysis (super-dev only) │ │ +│ │ ├─ Code review (super-dev only) │ │ +│ │ └─ Fix issues │ │ +│ │ ↓ │ │ +│ │ 3. Git commit │ │ +│ │ ↓ │ │ +│ │ 4. Save progress │ │ +│ └─────────────────────────────────────────────┘ │ +│ │ +│ Epic completion report generated │ +└──────────────────────────────────────────────────┘ +``` + +## Usage + +### Basic Usage + +```bash +# Load any BMAD agent +/autonomous-epic + +# Will prompt for epic number: +Enter epic number: 2 + +# Or provide directly: +/autonomous-epic epic-2 +``` + +### With Defaults + +```bash +/autonomous-epic 3 + +# Uses default settings: +# ✅ super-dev-story (comprehensive quality) +# ✅ Auto-accept gap analysis +# ✅ Create git commits +# ✅ Continue on errors +``` + +### With Custom Settings + +```bash +/autonomous-epic 3 + +# When prompted: +[C] Custom settings + +# Then configure: +# - dev-story or super-dev-story? +# - Auto-accept gap analysis? +# - Create git commits? +# - Halt on error or continue? +``` + +## Configuration + +### Default Settings (workflow.yaml) + +```yaml +autonomous_settings: + use_super_dev: true # Use super-dev-story (vs dev-story) + auto_accept_gap_analysis: true # Auto-approve gap analysis + halt_on_error: false # Continue even if story fails + max_retry_per_story: 2 # Retry failed stories + create_git_commits: true # Commit after each story + git_branch_prefix: "auto-epic-" # Branch: auto-epic-{epic_num} +``` + +### Per-Epic Override + +```yaml +# In sprint-status.yaml or epic frontmatter +epic-3: + autonomous_settings: + use_super_dev: false # Use dev-story (faster) + halt_on_error: true # Stop on first failure +``` + +## Time & Cost Estimates + +### Time per Story + +| Workflow | Avg Time per Story | Token Usage | +|----------|-------------------|-------------| +| **dev-story** | 20-40 minutes | 50K-100K | +| **super-dev-story** | 25-50 minutes | 80K-150K | + +### Epic Estimates + +| Epic Size | Time (dev-story) | Time (super-dev) | Tokens | +|-----------|-----------------|------------------|--------| +| Small (3-5 stories) | 1-3 hours | 2-4 hours | 250K-750K | +| Medium (6-10 stories) | 2-7 hours | 3-8 hours | 500K-1.5M | +| Large (11-20 stories) | 4-13 hours | 5-17 hours | 1M-3M | + +**Recommendation:** Run overnight for large epics + +## Example Session + +``` +🤖 Autonomous Epic Processing + +Enter epic number: 2 + +📊 Epic 2 Status +Total stories: 8 +- Backlog: 5 (will create + develop) +- Ready-for-dev: 2 (will develop) +- In-progress: 1 (will resume) +- Review: 0 +- Done: 0 + +Work Remaining: 8 stories +Estimated Time: 4-6 hours +Estimated Tokens: ~800K-1.2M + +Proceed? [Y/C/n]: Y + +✅ Starting autonomous epic processing... + +📝 Created git branch: auto-epic-2 + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story 1/8: 2-1-user-registration +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Status: backlog + +📝 Creating story 2-1-user-registration... +✅ Story created + +đŸ’ģ Developing story using super-dev-story... + Pre-gap: ✅ 0 changes needed + Development: ✅ 8 tasks completed + Post-gap: ✅ All verified + Code review: ✅ No issues +✅ Story complete (42 minutes, 95K tokens) + +📝 Committed: a1b2c3d + +Progress: 1 ✅ | 0 ❌ | 7 pending + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story 2/8: 2-2-user-login +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📝 Creating story 2-2-user-login... +✅ Story created + +đŸ’ģ Developing story using super-dev-story... + Pre-gap: ✅ Reusing registration code (3 tasks refined) + Development: ✅ 6 tasks completed + Post-gap: ✅ All verified + Code review: âš ī¸ 1 medium issue found + Code review: ✅ Issue fixed +✅ Story complete (38 minutes, 110K tokens) + +📝 Committed: d4e5f6g + +Progress: 2 ✅ | 0 ❌ | 6 pending + +[... continues for all 8 stories ...] + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🎉 EPIC 2 AUTONOMOUS PROCESSING COMPLETE! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Results: +✅ Stories completed: 8/8 +❌ Stories failed: 0 + +Statistics: +- Total time: 5h 23m +- Files created/modified: 47 +- Test coverage: 94% +- Code review issues: 6 (all fixed) + +Git Branch: auto-epic-2 +Commits: 8 + +Next Steps: +1. Review completion report +2. Run human code review +3. Merge auto-epic-2 +``` + +## Progress Tracking + +### Progress File + +Autonomous epic maintains state in `.autonomous-epic-progress.yaml`: + +```yaml +epic_num: 2 +started: 2025-01-18T10:00:00Z +total_stories: 8 +completed_stories: + - 2-1-user-registration + - 2-2-user-login +failed_stories: [] +current_story: 2-3-password-reset +status: running +``` + +### Resume from Interruption + +If interrupted (crash, manual stop, timeout): + +```bash +/autonomous-epic 2 + +# Detects existing progress file +# Shows: "Found in-progress epic processing. Resume? [Y/n]" +# Continues from last completed story +``` + +## Error Handling + +### Story Failures + +**With `halt_on_error: false` (default):** +``` +Story 2.3 fails +→ Logged in failed_stories +→ Continue to Story 2.4 +→ Report failures at end +``` + +**With `halt_on_error: true`:** +``` +Story 2.3 fails +→ Stop processing immediately +→ Report error +→ User fixes manually +→ Resume from Story 2.3 +``` + +### Retry Logic + +Each story gets {{max_retry_per_story}} attempts (default: 2): + +``` +Story 2.5 fails +→ Retry 1/2: Attempt again +→ Retry 2/2: Attempt again +→ Max retries: Mark failed, continue to next story +``` + +## Git Integration + +### Automatic Branching + +```bash +# Autonomous epic creates: +Branch: auto-epic-{epic_num} + +# Example: +/autonomous-epic 3 +→ Creates branch: auto-epic-3 +``` + +### Commits per Story + +Each story gets its own commit: + +``` +feat(epic-2): complete story 2-1-user-registration +feat(epic-2): complete story 2-2-user-login +feat(epic-2): complete story 2-3-password-reset +... +``` + +### Merge When Done + +```bash +# After autonomous epic completes: +git checkout main +git merge auto-epic-2 + +# Or create PR: +gh pr create --base main --head auto-epic-2 --title "Epic 2: User Management" +``` + +## Completion Report + +Generated at: `{{story_dir}}/epic-{{epic_num}}-completion-report.md` + +```markdown +# Epic 2 Completion Report + +**Generated:** 2025-01-18 +**Processing Time:** 5h 23m +**Success Rate:** 100% (8/8 stories) + +## Story Summary + +| Story | Status | Time | Files | Coverage | Issues | +|-------|--------|------|-------|----------|--------| +| 2.1 | ✅ Done | 42m | 6 | 95% | 0 | +| 2.2 | ✅ Done | 38m | 5 | 92% | 1 | +| 2.3 | ✅ Done | 45m | 7 | 96% | 2 | +... + +## Epic Statistics + +- Total files: 47 (35 created, 12 modified) +- Average coverage: 94% +- Code review issues: 6 (all resolved) +- Total commits: 8 + +## Quality Metrics + +- Stories passing first time: 6/8 (75%) +- Average fix iterations: 0.25 +- Zero critical issues escaped + +## Git Branch + +Branch: auto-epic-2 +Ready to merge + +## Recommendations + +- All stories met acceptance criteria +- Test coverage exceeds 90% target +- Code review found minimal issues +- Ready for human review and merge +``` + +## Best Practices + +### 1. Epic Sizing + +**Recommended epic sizes:** +- **Small (3-5 stories):** Can complete in single session +- **Medium (6-10 stories):** Overnight processing ideal +- **Large (11+ stories):** Consider breaking into sub-epics + +### 2. Choosing dev-story vs super-dev-story + +**Use super-dev-story for:** +- Security-critical epics +- Customer-facing features +- Complex business logic +- High-stakes production releases + +**Use dev-story for:** +- Internal tools +- Experimental features +- Non-critical improvements +- When speed matters more than extra validation + +### 3. Monitoring Progress + +```bash +# In another terminal, watch progress: +watch -n 10 'cat docs/sprint-artifacts/.autonomous-epic-progress.yaml' + +# Or tail completion report: +tail -f docs/sprint-artifacts/epic-2-completion-report.md +``` + +### 4. Interruption Handling + +**Safe to interrupt:** +- Ctrl+C between stories (progress saved) +- Terminal disconnect (can resume) +- Timeout (restarts from last completed) + +**Not safe to interrupt:** +- During story development (may leave partial work) +- During git commit (may corrupt repository) + +### 5. Resource Management + +**Token budgets:** +- Set LLM API limits to prevent runaway costs +- Monitor token usage in real-time +- Consider using dev-story for token savings + +**Time management:** +- Run overnight for large epics +- Schedule during low-activity periods +- Use CI/CD for completely automated runs + +## Troubleshooting + +### "Autonomous epic stuck on one story" + +**Cause:** Story has issues preventing completion +**Solution:** +- Check progress file for current_story +- Review that story's dev log +- May need manual intervention + +### "Epic processing stopped mid-story" + +**Cause:** Interruption during development +**Solution:** +- Check progress file status +- Resume with `/autonomous-epic {epic_num}` +- May need to manually clean up partial work + +### "Too many token failures" + +**Cause:** Hitting API rate limits +**Solution:** +- Reduce concurrent processing +- Use dev-story instead of super-dev-story +- Increase API tier/limits + +### "Git merge conflicts after autonomous epic" + +**Cause:** Other changes merged to main during processing +**Solution:** +- Rebase auto-epic branch on latest main +- Resolve conflicts manually +- This is expected for long-running processes + +## Safety Features + +### Max Retry Protection + +Prevents infinite loops: +- Each story: max 2 retries (default) +- After max retries: skip to next story +- Report failures at end + +### Progress Checkpoints + +After each story: +- Progress file updated +- Git commit created (if enabled) +- Can resume from this point + +### Fail-Safe Modes + +```yaml +# Conservative (halt on first problem): +halt_on_error: true +max_retry_per_story: 0 + +# Aggressive (push through everything): +halt_on_error: false +max_retry_per_story: 3 + +# Balanced (default): +halt_on_error: false +max_retry_per_story: 2 +``` + +## Use Cases + +### Use Case 1: Overnight Epic Completion + +```bash +# Before leaving office: +/autonomous-epic 4 + +# Next morning: +# → Epic 100% complete +# → All stories developed +# → All commits created +# → Ready for review +``` + +### Use Case 2: CI/CD Integration + +```bash +# In GitHub Actions: +name: Auto Epic Processing +on: + workflow_dispatch: + inputs: + epic_number: + required: true + +jobs: + process-epic: + steps: + - run: npx bmad-method@alpha autonomous-epic ${{ inputs.epic_number }} +``` + +### Use Case 3: Sprint Automation + +```bash +# Monday: Plan all epics for sprint +/sprint-planning + +# Tuesday: Auto-process Epic 1 +/autonomous-epic 1 + +# Wednesday: Auto-process Epic 2 +/autonomous-epic 2 + +# Thursday-Friday: Human review and merge +``` + +## Comparison to Manual Processing + +### Manual Workflow + +``` +Day 1: Create Story 2.1 → Review → Approve (30m) +Day 2: Develop Story 2.1 → Test → Review → Fix → Done (4h) +Day 3: Create Story 2.2 → Review → Approve (30m) +Day 4: Develop Story 2.2 → Test → Review → Fix → Done (3h) +... + +8 stories = 16 days minimum (with human bottlenecks) +``` + +### Autonomous Workflow + +``` +Day 1 (evening): /autonomous-epic 2 +Day 2 (morning): Epic complete, review ready + +8 stories = 6 hours machine time + 1-2 days human review +``` + +**Savings:** ~14 days, 90% reduction in calendar time + +## Limitations + +### What Autonomous Epic CAN'T Do + +- **Complex requirement clarifications** - Needs human for ambiguous requirements +- **Architectural decisions** - Major tech choices need human input +- **UX design decisions** - Visual/interaction design needs human creativity +- **Business logic validation** - Domain expertise often needs human verification + +### When to Use Manual Processing + +- First epic in new project (learning patterns) +- Experimental features (high uncertainty) +- Stories requiring extensive research +- Complex integrations with unknowns + +## Monitoring Output + +### Real-Time Progress + +```bash +# Terminal output shows: +Story 3/8: 2-3-password-reset + Pre-gap: ✅ 2 tasks refined + Development: âŗ 2/6 tasks complete + ... +``` + +### Progress File + +```bash +# Check progress programmatically: +cat docs/sprint-artifacts/.autonomous-epic-progress.yaml + +# Example: +epic_num: 2 +status: running +completed_stories: [2-1-user-registration, 2-2-user-login] +current_story: 2-3-password-reset +``` + +### Completion Report + +```bash +# Generated when epic completes: +cat docs/sprint-artifacts/epic-2-completion-report.md +``` + +## Advanced: Batch Epic Processing + +Process multiple epics: + +```bash +# Sequential processing: +/autonomous-epic 1 +/autonomous-epic 2 +/autonomous-epic 3 + +# Or create meta-workflow for parallel processing +``` + +## FAQ + +### Q: Can I stop autonomous processing mid-epic? + +**A:** Yes, Ctrl+C between stories. Progress saved. Resume with `/autonomous-epic {num}` + +### Q: What if a story fails? + +**A:** Logged in failed_stories. By default, continues to next story. Fix manually later. + +### Q: Does this work with existing stories? + +**A:** Yes! Picks up any ready-for-dev or in-progress stories and develops them. + +### Q: Can I customize per story? + +**A:** Not currently. All stories in epic use same settings. Manual development for custom needs. + +### Q: What about dependencies between stories? + +**A:** Stories processed sequentially, so Story 2.2 can leverage Story 2.1's code (gap analysis handles this!) + +### Q: Token budget concerns? + +**A:** Use dev-story instead of super-dev-story to reduce token usage by ~30% + +## See Also + +- [super-dev-story](../super-dev-story/) - Enhanced quality workflow +- [dev-story](../dev-story/) - Standard development workflow +- [gap-analysis](../gap-analysis/) - Standalone audit tool +- [Autonomous Epic Concept](../../../../docs/autonomous-epic-processing.md) - Vision document + +--- + +**Autonomous Epic Processing: "Do Epic 4 for me" is now reality** ✨ diff --git a/src/modules/bmgd/workflows/4-production/autonomous-epic/instructions.xml b/src/modules/bmgd/workflows/4-production/autonomous-epic/instructions.xml new file mode 100644 index 00000000..c86d64dd --- /dev/null +++ b/src/modules/bmgd/workflows/4-production/autonomous-epic/instructions.xml @@ -0,0 +1,419 @@ + + 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} + 🤖 AUTONOMOUS EPIC PROCESSING - Full automation of epic completion! + This workflow creates and develops ALL stories in an epic with minimal human intervention + + + 🤖 **Autonomous Epic Processing** + + This workflow will automatically: + 1. Create all stories in the epic (just-in-time planning) + 2. Develop each story with comprehensive validation + 3. Commit changes after each story + 4. Generate epic completion report + + **Time Estimate:** Varies by epic size + - Small epic (3-5 stories): 3-6 hours + - Medium epic (6-10 stories): 6-12 hours + - Large epic (11+ stories): 12-24 hours + + **Token Usage:** ~100K-150K per story + - Uses super-dev-story by default (highest quality) + - Auto-accepts gap analysis (minimal prompts) + + --- + + + + Use provided epic number + + + + Enter epic number to process (e.g., "2", "epic-3"), or [q] to quit: + + + Parse epic number from input (handle "2", "epic-2", "Epic 2" formats) + Set {{epic_num}} to parsed number + + + + + 👋 Autonomous epic processing cancelled. + HALT + + + + + Load {{sprint_status}} file + Find epic-{{epic_num}} entry in development_status + + + ❌ Epic {{epic_num}} not found in sprint-status.yaml + + Available epics: + {{list_available_epics}} + + Run sprint-planning to initialize sprint tracking. + + HALT + + + Get epic status from sprint-status + + + ✅ Epic {{epic_num}} is already complete! + + All stories marked done. Nothing to process. + + HALT + + + Count stories in epic (pattern: {{epic_num}}-*) + Count stories by status: + - backlog: Not yet created + - ready-for-dev: Created but not developed + - in-progress: Partially developed + - review: Developed, pending review + - done: Fully complete + + + + 📊 **Epic {{epic_num}} Status** + + Total stories: {{total_story_count}} + - Backlog: {{backlog_count}} (will create + develop) + - Ready-for-dev: {{ready_count}} (will develop) + - In-progress: {{inprogress_count}} (will resume) + - Review: {{review_count}} (will skip - needs human review) + - Done: {{done_count}} (will skip - already complete) + + **Work Remaining:** {{backlog_count + ready_count + inprogress_count}} stories + **Estimated Time:** {{estimated_hours}} hours + **Estimated Tokens:** ~{{estimated_tokens}}K + + + + + **Proceed with autonomous processing?** + + This will: + - Process {{work_count}} stories automatically + - Use {{dev_workflow}} for development (super-dev-story or dev-story) + - Create git commits after each story + - Take approximately {{estimated_hours}} hours + - Use approximately {{estimated_tokens}}K tokens + + Options: + [Y] Yes - Start autonomous processing with default settings + [C] Custom - Let me configure settings first + [n] No - Cancel autonomous processing + + + + Use default autonomous_settings from workflow.yaml + ✅ Starting autonomous epic processing with defaults... + + + + + Use super-dev-story (comprehensive validation) or dev-story (faster)? [super/dev]: + Store user choice as {{dev_workflow}} + + Auto-accept gap analysis refinements? [Y/n]: + Store user choice as {{auto_accept_gap}} + + Create git commits after each story? [Y/n]: + Store user choice as {{create_commits}} + + Halt on first error or continue? [halt/continue]: + Store user choice as {{error_handling}} + + ✅ Custom settings configured. Starting autonomous processing... + + + + + ❌ Autonomous epic processing cancelled. + HALT + + + + + + + + Check current git branch + Create new branch: {{git_branch_prefix}}{{epic_num}} + 📝 Created git branch: {{git_branch_prefix}}{{epic_num}} + + + + Create progress file: {{progress_file}} + Write initial progress state: + epic_num: {{epic_num}} + started: {{date}} + total_stories: {{total_story_count}} + completed_stories: [] + failed_stories: [] + current_story: null + status: running + + + 🚀 **Autonomous Epic Processing Started** + + Epic: {{epic_num}} + Branch: {{git_branch_name}} + Progress tracking: {{progress_file}} + + Processing {{work_count}} stories... + + + + + 🔄 STORY PROCESSING LOOP - Just-in-time planning + development + + Load {{sprint_status}} file + Find all stories in epic {{epic_num}} (pattern: {{epic_num}}-*) + Sort stories by story number (ascending order) + Filter to stories needing work (backlog, ready-for-dev, in-progress statuses) + + Initialize {{story_counter}} = 0 + Initialize {{success_count}} = 0 + Initialize {{failure_count}} = 0 + + + + Set {{current_story}} = current story from loop + Increment {{story_counter}} + Update progress file with current_story + + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Story {{story_counter}}/{{work_count}}: {{current_story.key}} + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Status: {{current_story.status}} + Started: {{current_time}} + + + + + 📝 Creating story {{current_story.key}}... + + + Run create-story workflow for this story + Wait for story file to be created + ✅ Story created: {{story_file}} + + + + ❌ Failed to create story {{current_story.key}} + + Error: {{error_message}} + + + + Update progress file with failure + 🛑 Halting due to error (halt_on_error=true) + HALT + + + + Add to {{failed_stories}} list + Increment {{failure_count}} + â­ī¸ Skipping to next story... + Next story in loop + + + + + + đŸ’ģ Developing story {{current_story.key}} using {{dev_workflow}}... + + + + Run super-dev-story workflow with auto-accept mode enabled + + + + Run dev-story workflow with auto-accept mode enabled + + + Wait for story to be marked "review" + + ✅ Story {{current_story.key}} completed + + Status: review + Tasks completed: {{task_count}} + Files changed: {{file_count}} + Time: {{elapsed_time}} + + + + + Create git commit for this story: + Message: "feat(epic-{{epic_num}}): complete story {{current_story.key}} - {{story_title}}" + Include: All files changed during story development + + 📝 Committed: {{commit_hash}} + + + Increment {{success_count}} + Add to progress file completed_stories list + Update progress file with success + + + + + ❌ Failed to develop story {{current_story.key}} + + Error: {{error_message}} + Attempt: {{retry_count}}/{{max_retry_per_story}} + + + + 🔄 Retrying story {{current_story.key}}... + Increment {{retry_count}} + Retry this story + + + + âš ī¸ Max retries reached for story {{current_story.key}} + + + Update progress file with failure and halt + 🛑 Halting due to repeated errors (halt_on_error=true) + HALT + + + + Add to {{failed_stories}} list + Increment {{failure_count}} + â­ī¸ Skipping to next story... + Next story in loop + + + + + + + Progress: {{success_count}} ✅ | {{failure_count}} ❌ | {{remaining_count}} pending + + + + + + Update progress file status: complete + + + + 📊 EPIC COMPLETE - Generate completion report + + Load all completed story files from this epic + Aggregate statistics: + - Total files created/modified + - Total test coverage + - Total code review issues found and fixed + - Total development time + - Success rate + + + Generate epic completion report: {{story_dir}}/epic-{{epic_num}}-completion-report.md + + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 🎉 EPIC {{epic_num}} AUTONOMOUS PROCESSING COMPLETE! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + **Results:** + ✅ Stories completed: {{success_count}}/{{total_story_count}} + {{if_failures}} + ❌ Stories failed: {{failure_count}} + {{list_failed_stories_with_reasons}} + {{endif}} + + **Statistics:** + - Total development time: {{total_time}} + - Files created/modified: {{total_files}} + - Test coverage achieved: {{avg_coverage}}% + - Code review issues found: {{total_issues}} + - Code review issues fixed: {{total_fixes}} + + **Git Branch:** {{git_branch_name}} + **Commits:** {{commit_count}} + + **Completion Report:** {{report_file}} + + --- + + **Next Steps:** + 1. Review the completion report + 2. Manually review/fix any failed stories + 3. Run human code review on the branch + 4. Merge {{git_branch_name}} when approved + + {{if_failures}} + **Failed Stories Need Attention:** + {{list_failed_stories}} + {{endif}} + + + + + Load {{sprint_status}} file + Update epic-{{epic_num}} status to "done" + ✅ Epic {{epic_num}} marked complete in sprint-status.yaml + + + + â„šī¸ Epic {{epic_num}} partially complete - some stories failed. + Epic status remains "in-progress" until failed stories resolved. + + + + + + 📝 All changes committed to branch: {{git_branch_name}} + + To merge: + git checkout main + git merge {{git_branch_name}} + + Or create PR: + gh pr create --base main --head {{git_branch_name}} + + + + + + Remove progress file (no longer needed) + + Would you like explanations about: + - How autonomous processing works + - What was implemented in this epic + - Why any stories failed + - How to review and merge the work + - Anything else? + + [Enter topic or 'n' to skip] + + + + Provide clear explanations about requested topics + Reference specific stories, code, or decisions + + + 💡 **Tips for Future Autonomous Processing:** + + - Use super-dev-story for critical epics (higher quality, more tokens) + - Use dev-story for experimental epics (faster, fewer tokens) + - Review completion report for patterns and improvements + - Failed stories often indicate unclear requirements + - Monitor token usage and adjust epic size accordingly + + **Epic {{epic_num}} processing complete, {user_name}!** + + + + diff --git a/src/modules/bmgd/workflows/4-production/autonomous-epic/workflow.yaml b/src/modules/bmgd/workflows/4-production/autonomous-epic/workflow.yaml new file mode 100644 index 00000000..af6744b7 --- /dev/null +++ b/src/modules/bmgd/workflows/4-production/autonomous-epic/workflow.yaml @@ -0,0 +1,33 @@ +name: autonomous-epic +description: "Autonomous epic processing - creates and develops all stories in an epic with minimal human intervention" +author: "BMad" + +# Critical variables from config +config_source: "{project-root}/_bmad/bmgd/config.yaml" +user_name: "{config_source}:user_name" +communication_language: "{config_source}:communication_language" +implementation_artifacts: "{config_source}:implementation_artifacts" +story_dir: "{implementation_artifacts}" + +# Workflow components +installed_path: "{project-root}/_bmad/bmgd/workflows/4-production/autonomous-epic" +instructions: "{installed_path}/instructions.xml" +progress_file: "{story_dir}/.autonomous-epic-progress.yaml" + +# Variables +epic_num: "" # User provides or auto-discover next epic +sprint_status: "{implementation_artifacts}/sprint-status.yaml" +project_context: "**/project-context.md" + +# Autonomous mode settings +autonomous_settings: + use_super_dev: true # Use super-dev-story vs dev-story + auto_accept_gap_analysis: true # Auto-approve gap analysis refinements + halt_on_error: false # Continue even if story fails + max_retry_per_story: 2 # Retry failed stories + create_git_commits: true # Commit after each story + git_branch_prefix: "auto-epic-" # Branch name format: auto-epic-{epic_num} + +standalone: true + +web_bundle: false diff --git a/src/modules/bmm/workflows/4-implementation/autonomous-epic/README.md b/src/modules/bmm/workflows/4-implementation/autonomous-epic/README.md new file mode 100644 index 00000000..a7b02bb6 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/autonomous-epic/README.md @@ -0,0 +1,651 @@ +# Autonomous Epic Processing + +**"Do Epic 4 for me" - Full automation of epic completion** + +## What It Does + +Autonomous epic processing combines just-in-time planning with automated development: + +``` +/autonomous-epic 2 + +→ Creates Story 2.1 → Develops with super-dev-story → Commits → Done ✅ +→ Creates Story 2.2 → Develops with super-dev-story → Commits → Done ✅ +→ Creates Story 2.3 → Develops with super-dev-story → Commits → Done ✅ +... +→ Entire Epic 2 complete! 🎉 +``` + +## How It Works + +``` +┌──────────────────────────────────────────────────┐ +│ Autonomous Epic Processor │ +│ │ +│ For each story in epic (sequential): │ +│ ┌─────────────────────────────────────────────┐ │ +│ │ 1. create-story (just-in-time planning) │ │ +│ │ ↓ │ │ +│ │ 2. super-dev-story (or dev-story) │ │ +│ │ ├─ Pre-dev gap analysis │ │ +│ │ ├─ Development (TDD) │ │ +│ │ ├─ Post-dev gap analysis (super-dev only) │ │ +│ │ ├─ Code review (super-dev only) │ │ +│ │ └─ Fix issues │ │ +│ │ ↓ │ │ +│ │ 3. Git commit │ │ +│ │ ↓ │ │ +│ │ 4. Save progress │ │ +│ └─────────────────────────────────────────────┘ │ +│ │ +│ Epic completion report generated │ +└──────────────────────────────────────────────────┘ +``` + +## Usage + +### Basic Usage + +```bash +# Load any BMAD agent +/autonomous-epic + +# Will prompt for epic number: +Enter epic number: 2 + +# Or provide directly: +/autonomous-epic epic-2 +``` + +### With Defaults + +```bash +/autonomous-epic 3 + +# Uses default settings: +# ✅ super-dev-story (comprehensive quality) +# ✅ Auto-accept gap analysis +# ✅ Create git commits +# ✅ Continue on errors +``` + +### With Custom Settings + +```bash +/autonomous-epic 3 + +# When prompted: +[C] Custom settings + +# Then configure: +# - dev-story or super-dev-story? +# - Auto-accept gap analysis? +# - Create git commits? +# - Halt on error or continue? +``` + +## Configuration + +### Default Settings (workflow.yaml) + +```yaml +autonomous_settings: + use_super_dev: true # Use super-dev-story (vs dev-story) + auto_accept_gap_analysis: true # Auto-approve gap analysis + halt_on_error: false # Continue even if story fails + max_retry_per_story: 2 # Retry failed stories + create_git_commits: true # Commit after each story + git_branch_prefix: "auto-epic-" # Branch: auto-epic-{epic_num} +``` + +### Per-Epic Override + +```yaml +# In sprint-status.yaml or epic frontmatter +epic-3: + autonomous_settings: + use_super_dev: false # Use dev-story (faster) + halt_on_error: true # Stop on first failure +``` + +## Time & Cost Estimates + +### Time per Story + +| Workflow | Avg Time per Story | Token Usage | +|----------|-------------------|-------------| +| **dev-story** | 20-40 minutes | 50K-100K | +| **super-dev-story** | 25-50 minutes | 80K-150K | + +### Epic Estimates + +| Epic Size | Time (dev-story) | Time (super-dev) | Tokens | +|-----------|-----------------|------------------|--------| +| Small (3-5 stories) | 1-3 hours | 2-4 hours | 250K-750K | +| Medium (6-10 stories) | 2-7 hours | 3-8 hours | 500K-1.5M | +| Large (11-20 stories) | 4-13 hours | 5-17 hours | 1M-3M | + +**Recommendation:** Run overnight for large epics + +## Example Session + +``` +🤖 Autonomous Epic Processing + +Enter epic number: 2 + +📊 Epic 2 Status +Total stories: 8 +- Backlog: 5 (will create + develop) +- Ready-for-dev: 2 (will develop) +- In-progress: 1 (will resume) +- Review: 0 +- Done: 0 + +Work Remaining: 8 stories +Estimated Time: 4-6 hours +Estimated Tokens: ~800K-1.2M + +Proceed? [Y/C/n]: Y + +✅ Starting autonomous epic processing... + +📝 Created git branch: auto-epic-2 + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story 1/8: 2-1-user-registration +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Status: backlog + +📝 Creating story 2-1-user-registration... +✅ Story created + +đŸ’ģ Developing story using super-dev-story... + Pre-gap: ✅ 0 changes needed + Development: ✅ 8 tasks completed + Post-gap: ✅ All verified + Code review: ✅ No issues +✅ Story complete (42 minutes, 95K tokens) + +📝 Committed: a1b2c3d + +Progress: 1 ✅ | 0 ❌ | 7 pending + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +Story 2/8: 2-2-user-login +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +📝 Creating story 2-2-user-login... +✅ Story created + +đŸ’ģ Developing story using super-dev-story... + Pre-gap: ✅ Reusing registration code (3 tasks refined) + Development: ✅ 6 tasks completed + Post-gap: ✅ All verified + Code review: âš ī¸ 1 medium issue found + Code review: ✅ Issue fixed +✅ Story complete (38 minutes, 110K tokens) + +📝 Committed: d4e5f6g + +Progress: 2 ✅ | 0 ❌ | 6 pending + +[... continues for all 8 stories ...] + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +🎉 EPIC 2 AUTONOMOUS PROCESSING COMPLETE! +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Results: +✅ Stories completed: 8/8 +❌ Stories failed: 0 + +Statistics: +- Total time: 5h 23m +- Files created/modified: 47 +- Test coverage: 94% +- Code review issues: 6 (all fixed) + +Git Branch: auto-epic-2 +Commits: 8 + +Next Steps: +1. Review completion report +2. Run human code review +3. Merge auto-epic-2 +``` + +## Progress Tracking + +### Progress File + +Autonomous epic maintains state in `.autonomous-epic-progress.yaml`: + +```yaml +epic_num: 2 +started: 2025-01-18T10:00:00Z +total_stories: 8 +completed_stories: + - 2-1-user-registration + - 2-2-user-login +failed_stories: [] +current_story: 2-3-password-reset +status: running +``` + +### Resume from Interruption + +If interrupted (crash, manual stop, timeout): + +```bash +/autonomous-epic 2 + +# Detects existing progress file +# Shows: "Found in-progress epic processing. Resume? [Y/n]" +# Continues from last completed story +``` + +## Error Handling + +### Story Failures + +**With `halt_on_error: false` (default):** +``` +Story 2.3 fails +→ Logged in failed_stories +→ Continue to Story 2.4 +→ Report failures at end +``` + +**With `halt_on_error: true`:** +``` +Story 2.3 fails +→ Stop processing immediately +→ Report error +→ User fixes manually +→ Resume from Story 2.3 +``` + +### Retry Logic + +Each story gets {{max_retry_per_story}} attempts (default: 2): + +``` +Story 2.5 fails +→ Retry 1/2: Attempt again +→ Retry 2/2: Attempt again +→ Max retries: Mark failed, continue to next story +``` + +## Git Integration + +### Automatic Branching + +```bash +# Autonomous epic creates: +Branch: auto-epic-{epic_num} + +# Example: +/autonomous-epic 3 +→ Creates branch: auto-epic-3 +``` + +### Commits per Story + +Each story gets its own commit: + +``` +feat(epic-2): complete story 2-1-user-registration +feat(epic-2): complete story 2-2-user-login +feat(epic-2): complete story 2-3-password-reset +... +``` + +### Merge When Done + +```bash +# After autonomous epic completes: +git checkout main +git merge auto-epic-2 + +# Or create PR: +gh pr create --base main --head auto-epic-2 --title "Epic 2: User Management" +``` + +## Completion Report + +Generated at: `{{story_dir}}/epic-{{epic_num}}-completion-report.md` + +```markdown +# Epic 2 Completion Report + +**Generated:** 2025-01-18 +**Processing Time:** 5h 23m +**Success Rate:** 100% (8/8 stories) + +## Story Summary + +| Story | Status | Time | Files | Coverage | Issues | +|-------|--------|------|-------|----------|--------| +| 2.1 | ✅ Done | 42m | 6 | 95% | 0 | +| 2.2 | ✅ Done | 38m | 5 | 92% | 1 | +| 2.3 | ✅ Done | 45m | 7 | 96% | 2 | +... + +## Epic Statistics + +- Total files: 47 (35 created, 12 modified) +- Average coverage: 94% +- Code review issues: 6 (all resolved) +- Total commits: 8 + +## Quality Metrics + +- Stories passing first time: 6/8 (75%) +- Average fix iterations: 0.25 +- Zero critical issues escaped + +## Git Branch + +Branch: auto-epic-2 +Ready to merge + +## Recommendations + +- All stories met acceptance criteria +- Test coverage exceeds 90% target +- Code review found minimal issues +- Ready for human review and merge +``` + +## Best Practices + +### 1. Epic Sizing + +**Recommended epic sizes:** +- **Small (3-5 stories):** Can complete in single session +- **Medium (6-10 stories):** Overnight processing ideal +- **Large (11+ stories):** Consider breaking into sub-epics + +### 2. Choosing dev-story vs super-dev-story + +**Use super-dev-story for:** +- Security-critical epics +- Customer-facing features +- Complex business logic +- High-stakes production releases + +**Use dev-story for:** +- Internal tools +- Experimental features +- Non-critical improvements +- When speed matters more than extra validation + +### 3. Monitoring Progress + +```bash +# In another terminal, watch progress: +watch -n 10 'cat docs/sprint-artifacts/.autonomous-epic-progress.yaml' + +# Or tail completion report: +tail -f docs/sprint-artifacts/epic-2-completion-report.md +``` + +### 4. Interruption Handling + +**Safe to interrupt:** +- Ctrl+C between stories (progress saved) +- Terminal disconnect (can resume) +- Timeout (restarts from last completed) + +**Not safe to interrupt:** +- During story development (may leave partial work) +- During git commit (may corrupt repository) + +### 5. Resource Management + +**Token budgets:** +- Set LLM API limits to prevent runaway costs +- Monitor token usage in real-time +- Consider using dev-story for token savings + +**Time management:** +- Run overnight for large epics +- Schedule during low-activity periods +- Use CI/CD for completely automated runs + +## Troubleshooting + +### "Autonomous epic stuck on one story" + +**Cause:** Story has issues preventing completion +**Solution:** +- Check progress file for current_story +- Review that story's dev log +- May need manual intervention + +### "Epic processing stopped mid-story" + +**Cause:** Interruption during development +**Solution:** +- Check progress file status +- Resume with `/autonomous-epic {epic_num}` +- May need to manually clean up partial work + +### "Too many token failures" + +**Cause:** Hitting API rate limits +**Solution:** +- Reduce concurrent processing +- Use dev-story instead of super-dev-story +- Increase API tier/limits + +### "Git merge conflicts after autonomous epic" + +**Cause:** Other changes merged to main during processing +**Solution:** +- Rebase auto-epic branch on latest main +- Resolve conflicts manually +- This is expected for long-running processes + +## Safety Features + +### Max Retry Protection + +Prevents infinite loops: +- Each story: max 2 retries (default) +- After max retries: skip to next story +- Report failures at end + +### Progress Checkpoints + +After each story: +- Progress file updated +- Git commit created (if enabled) +- Can resume from this point + +### Fail-Safe Modes + +```yaml +# Conservative (halt on first problem): +halt_on_error: true +max_retry_per_story: 0 + +# Aggressive (push through everything): +halt_on_error: false +max_retry_per_story: 3 + +# Balanced (default): +halt_on_error: false +max_retry_per_story: 2 +``` + +## Use Cases + +### Use Case 1: Overnight Epic Completion + +```bash +# Before leaving office: +/autonomous-epic 4 + +# Next morning: +# → Epic 100% complete +# → All stories developed +# → All commits created +# → Ready for review +``` + +### Use Case 2: CI/CD Integration + +```bash +# In GitHub Actions: +name: Auto Epic Processing +on: + workflow_dispatch: + inputs: + epic_number: + required: true + +jobs: + process-epic: + steps: + - run: npx bmad-method@alpha autonomous-epic ${{ inputs.epic_number }} +``` + +### Use Case 3: Sprint Automation + +```bash +# Monday: Plan all epics for sprint +/sprint-planning + +# Tuesday: Auto-process Epic 1 +/autonomous-epic 1 + +# Wednesday: Auto-process Epic 2 +/autonomous-epic 2 + +# Thursday-Friday: Human review and merge +``` + +## Comparison to Manual Processing + +### Manual Workflow + +``` +Day 1: Create Story 2.1 → Review → Approve (30m) +Day 2: Develop Story 2.1 → Test → Review → Fix → Done (4h) +Day 3: Create Story 2.2 → Review → Approve (30m) +Day 4: Develop Story 2.2 → Test → Review → Fix → Done (3h) +... + +8 stories = 16 days minimum (with human bottlenecks) +``` + +### Autonomous Workflow + +``` +Day 1 (evening): /autonomous-epic 2 +Day 2 (morning): Epic complete, review ready + +8 stories = 6 hours machine time + 1-2 days human review +``` + +**Savings:** ~14 days, 90% reduction in calendar time + +## Limitations + +### What Autonomous Epic CAN'T Do + +- **Complex requirement clarifications** - Needs human for ambiguous requirements +- **Architectural decisions** - Major tech choices need human input +- **UX design decisions** - Visual/interaction design needs human creativity +- **Business logic validation** - Domain expertise often needs human verification + +### When to Use Manual Processing + +- First epic in new project (learning patterns) +- Experimental features (high uncertainty) +- Stories requiring extensive research +- Complex integrations with unknowns + +## Monitoring Output + +### Real-Time Progress + +```bash +# Terminal output shows: +Story 3/8: 2-3-password-reset + Pre-gap: ✅ 2 tasks refined + Development: âŗ 2/6 tasks complete + ... +``` + +### Progress File + +```bash +# Check progress programmatically: +cat docs/sprint-artifacts/.autonomous-epic-progress.yaml + +# Example: +epic_num: 2 +status: running +completed_stories: [2-1-user-registration, 2-2-user-login] +current_story: 2-3-password-reset +``` + +### Completion Report + +```bash +# Generated when epic completes: +cat docs/sprint-artifacts/epic-2-completion-report.md +``` + +## Advanced: Batch Epic Processing + +Process multiple epics: + +```bash +# Sequential processing: +/autonomous-epic 1 +/autonomous-epic 2 +/autonomous-epic 3 + +# Or create meta-workflow for parallel processing +``` + +## FAQ + +### Q: Can I stop autonomous processing mid-epic? + +**A:** Yes, Ctrl+C between stories. Progress saved. Resume with `/autonomous-epic {num}` + +### Q: What if a story fails? + +**A:** Logged in failed_stories. By default, continues to next story. Fix manually later. + +### Q: Does this work with existing stories? + +**A:** Yes! Picks up any ready-for-dev or in-progress stories and develops them. + +### Q: Can I customize per story? + +**A:** Not currently. All stories in epic use same settings. Manual development for custom needs. + +### Q: What about dependencies between stories? + +**A:** Stories processed sequentially, so Story 2.2 can leverage Story 2.1's code (gap analysis handles this!) + +### Q: Token budget concerns? + +**A:** Use dev-story instead of super-dev-story to reduce token usage by ~30% + +## See Also + +- [super-dev-story](../super-dev-story/) - Enhanced quality workflow +- [dev-story](../dev-story/) - Standard development workflow +- [gap-analysis](../gap-analysis/) - Standalone audit tool +- [Autonomous Epic Concept](../../../../docs/autonomous-epic-processing.md) - Vision document + +--- + +**Autonomous Epic Processing: "Do Epic 4 for me" is now reality** ✨ diff --git a/src/modules/bmm/workflows/4-implementation/autonomous-epic/instructions.xml b/src/modules/bmm/workflows/4-implementation/autonomous-epic/instructions.xml new file mode 100644 index 00000000..c86d64dd --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/autonomous-epic/instructions.xml @@ -0,0 +1,419 @@ + + 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} + 🤖 AUTONOMOUS EPIC PROCESSING - Full automation of epic completion! + This workflow creates and develops ALL stories in an epic with minimal human intervention + + + 🤖 **Autonomous Epic Processing** + + This workflow will automatically: + 1. Create all stories in the epic (just-in-time planning) + 2. Develop each story with comprehensive validation + 3. Commit changes after each story + 4. Generate epic completion report + + **Time Estimate:** Varies by epic size + - Small epic (3-5 stories): 3-6 hours + - Medium epic (6-10 stories): 6-12 hours + - Large epic (11+ stories): 12-24 hours + + **Token Usage:** ~100K-150K per story + - Uses super-dev-story by default (highest quality) + - Auto-accepts gap analysis (minimal prompts) + + --- + + + + Use provided epic number + + + + Enter epic number to process (e.g., "2", "epic-3"), or [q] to quit: + + + Parse epic number from input (handle "2", "epic-2", "Epic 2" formats) + Set {{epic_num}} to parsed number + + + + + 👋 Autonomous epic processing cancelled. + HALT + + + + + Load {{sprint_status}} file + Find epic-{{epic_num}} entry in development_status + + + ❌ Epic {{epic_num}} not found in sprint-status.yaml + + Available epics: + {{list_available_epics}} + + Run sprint-planning to initialize sprint tracking. + + HALT + + + Get epic status from sprint-status + + + ✅ Epic {{epic_num}} is already complete! + + All stories marked done. Nothing to process. + + HALT + + + Count stories in epic (pattern: {{epic_num}}-*) + Count stories by status: + - backlog: Not yet created + - ready-for-dev: Created but not developed + - in-progress: Partially developed + - review: Developed, pending review + - done: Fully complete + + + + 📊 **Epic {{epic_num}} Status** + + Total stories: {{total_story_count}} + - Backlog: {{backlog_count}} (will create + develop) + - Ready-for-dev: {{ready_count}} (will develop) + - In-progress: {{inprogress_count}} (will resume) + - Review: {{review_count}} (will skip - needs human review) + - Done: {{done_count}} (will skip - already complete) + + **Work Remaining:** {{backlog_count + ready_count + inprogress_count}} stories + **Estimated Time:** {{estimated_hours}} hours + **Estimated Tokens:** ~{{estimated_tokens}}K + + + + + **Proceed with autonomous processing?** + + This will: + - Process {{work_count}} stories automatically + - Use {{dev_workflow}} for development (super-dev-story or dev-story) + - Create git commits after each story + - Take approximately {{estimated_hours}} hours + - Use approximately {{estimated_tokens}}K tokens + + Options: + [Y] Yes - Start autonomous processing with default settings + [C] Custom - Let me configure settings first + [n] No - Cancel autonomous processing + + + + Use default autonomous_settings from workflow.yaml + ✅ Starting autonomous epic processing with defaults... + + + + + Use super-dev-story (comprehensive validation) or dev-story (faster)? [super/dev]: + Store user choice as {{dev_workflow}} + + Auto-accept gap analysis refinements? [Y/n]: + Store user choice as {{auto_accept_gap}} + + Create git commits after each story? [Y/n]: + Store user choice as {{create_commits}} + + Halt on first error or continue? [halt/continue]: + Store user choice as {{error_handling}} + + ✅ Custom settings configured. Starting autonomous processing... + + + + + ❌ Autonomous epic processing cancelled. + HALT + + + + + + + + Check current git branch + Create new branch: {{git_branch_prefix}}{{epic_num}} + 📝 Created git branch: {{git_branch_prefix}}{{epic_num}} + + + + Create progress file: {{progress_file}} + Write initial progress state: + epic_num: {{epic_num}} + started: {{date}} + total_stories: {{total_story_count}} + completed_stories: [] + failed_stories: [] + current_story: null + status: running + + + 🚀 **Autonomous Epic Processing Started** + + Epic: {{epic_num}} + Branch: {{git_branch_name}} + Progress tracking: {{progress_file}} + + Processing {{work_count}} stories... + + + + + 🔄 STORY PROCESSING LOOP - Just-in-time planning + development + + Load {{sprint_status}} file + Find all stories in epic {{epic_num}} (pattern: {{epic_num}}-*) + Sort stories by story number (ascending order) + Filter to stories needing work (backlog, ready-for-dev, in-progress statuses) + + Initialize {{story_counter}} = 0 + Initialize {{success_count}} = 0 + Initialize {{failure_count}} = 0 + + + + Set {{current_story}} = current story from loop + Increment {{story_counter}} + Update progress file with current_story + + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Story {{story_counter}}/{{work_count}}: {{current_story.key}} + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Status: {{current_story.status}} + Started: {{current_time}} + + + + + 📝 Creating story {{current_story.key}}... + + + Run create-story workflow for this story + Wait for story file to be created + ✅ Story created: {{story_file}} + + + + ❌ Failed to create story {{current_story.key}} + + Error: {{error_message}} + + + + Update progress file with failure + 🛑 Halting due to error (halt_on_error=true) + HALT + + + + Add to {{failed_stories}} list + Increment {{failure_count}} + â­ī¸ Skipping to next story... + Next story in loop + + + + + + đŸ’ģ Developing story {{current_story.key}} using {{dev_workflow}}... + + + + Run super-dev-story workflow with auto-accept mode enabled + + + + Run dev-story workflow with auto-accept mode enabled + + + Wait for story to be marked "review" + + ✅ Story {{current_story.key}} completed + + Status: review + Tasks completed: {{task_count}} + Files changed: {{file_count}} + Time: {{elapsed_time}} + + + + + Create git commit for this story: + Message: "feat(epic-{{epic_num}}): complete story {{current_story.key}} - {{story_title}}" + Include: All files changed during story development + + 📝 Committed: {{commit_hash}} + + + Increment {{success_count}} + Add to progress file completed_stories list + Update progress file with success + + + + + ❌ Failed to develop story {{current_story.key}} + + Error: {{error_message}} + Attempt: {{retry_count}}/{{max_retry_per_story}} + + + + 🔄 Retrying story {{current_story.key}}... + Increment {{retry_count}} + Retry this story + + + + âš ī¸ Max retries reached for story {{current_story.key}} + + + Update progress file with failure and halt + 🛑 Halting due to repeated errors (halt_on_error=true) + HALT + + + + Add to {{failed_stories}} list + Increment {{failure_count}} + â­ī¸ Skipping to next story... + Next story in loop + + + + + + + Progress: {{success_count}} ✅ | {{failure_count}} ❌ | {{remaining_count}} pending + + + + + + Update progress file status: complete + + + + 📊 EPIC COMPLETE - Generate completion report + + Load all completed story files from this epic + Aggregate statistics: + - Total files created/modified + - Total test coverage + - Total code review issues found and fixed + - Total development time + - Success rate + + + Generate epic completion report: {{story_dir}}/epic-{{epic_num}}-completion-report.md + + + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 🎉 EPIC {{epic_num}} AUTONOMOUS PROCESSING COMPLETE! + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + **Results:** + ✅ Stories completed: {{success_count}}/{{total_story_count}} + {{if_failures}} + ❌ Stories failed: {{failure_count}} + {{list_failed_stories_with_reasons}} + {{endif}} + + **Statistics:** + - Total development time: {{total_time}} + - Files created/modified: {{total_files}} + - Test coverage achieved: {{avg_coverage}}% + - Code review issues found: {{total_issues}} + - Code review issues fixed: {{total_fixes}} + + **Git Branch:** {{git_branch_name}} + **Commits:** {{commit_count}} + + **Completion Report:** {{report_file}} + + --- + + **Next Steps:** + 1. Review the completion report + 2. Manually review/fix any failed stories + 3. Run human code review on the branch + 4. Merge {{git_branch_name}} when approved + + {{if_failures}} + **Failed Stories Need Attention:** + {{list_failed_stories}} + {{endif}} + + + + + Load {{sprint_status}} file + Update epic-{{epic_num}} status to "done" + ✅ Epic {{epic_num}} marked complete in sprint-status.yaml + + + + â„šī¸ Epic {{epic_num}} partially complete - some stories failed. + Epic status remains "in-progress" until failed stories resolved. + + + + + + 📝 All changes committed to branch: {{git_branch_name}} + + To merge: + git checkout main + git merge {{git_branch_name}} + + Or create PR: + gh pr create --base main --head {{git_branch_name}} + + + + + + Remove progress file (no longer needed) + + Would you like explanations about: + - How autonomous processing works + - What was implemented in this epic + - Why any stories failed + - How to review and merge the work + - Anything else? + + [Enter topic or 'n' to skip] + + + + Provide clear explanations about requested topics + Reference specific stories, code, or decisions + + + 💡 **Tips for Future Autonomous Processing:** + + - Use super-dev-story for critical epics (higher quality, more tokens) + - Use dev-story for experimental epics (faster, fewer tokens) + - Review completion report for patterns and improvements + - Failed stories often indicate unclear requirements + - Monitor token usage and adjust epic size accordingly + + **Epic {{epic_num}} processing complete, {user_name}!** + + + + diff --git a/src/modules/bmm/workflows/4-implementation/autonomous-epic/workflow.yaml b/src/modules/bmm/workflows/4-implementation/autonomous-epic/workflow.yaml new file mode 100644 index 00000000..43005ddd --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/autonomous-epic/workflow.yaml @@ -0,0 +1,33 @@ +name: autonomous-epic +description: "Autonomous epic processing - creates and develops all stories in an epic with minimal human intervention" +author: "BMad" + +# Critical variables from config +config_source: "{project-root}/_bmad/bmm/config.yaml" +user_name: "{config_source}:user_name" +communication_language: "{config_source}:communication_language" +implementation_artifacts: "{config_source}:implementation_artifacts" +story_dir: "{implementation_artifacts}" + +# Workflow components +installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/autonomous-epic" +instructions: "{installed_path}/instructions.xml" +progress_file: "{story_dir}/.autonomous-epic-progress.yaml" + +# Variables +epic_num: "" # User provides or auto-discover next epic +sprint_status: "{implementation_artifacts}/sprint-status.yaml" +project_context: "**/project-context.md" + +# Autonomous mode settings +autonomous_settings: + use_super_dev: true # Use super-dev-story vs dev-story + auto_accept_gap_analysis: true # Auto-approve gap analysis refinements + halt_on_error: false # Continue even if story fails + max_retry_per_story: 2 # Retry failed stories + create_git_commits: true # Commit after each story + git_branch_prefix: "auto-epic-" # Branch name format: auto-epic-{epic_num} + +standalone: true + +web_bundle: false