Commit Graph

16 Commits

Author SHA1 Message Date
Caleb 8a41477ae0 feat(epic-execute): bound design-phase context and persist plans
Design phase improvements #1 and #2:

#1 Bounded context:
- Pass architecture.md by path instead of embedding full contents
  (the main unbounded size risk in this prompt)
- Cap decision-log context at last 20KB (matches dev phase)
- Add log_prompt_size guard, consistent with other phases
- Replace hardcoded JS/TS exploration hints with language-agnostic guidance

#2 File persistence:
- Add DESIGN_DIR config and persist each plan to <DESIGN_DIR>/<story>-design.md
- build_design_context_for_dev falls back to the persisted file when the
  in-memory plan is empty, so resumed runs keep their design context

Story file remains inlined (small, bounded, needed in full by the planner).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 05:57:58 -05:00
Caleb cf03b6f50d merge: sync with upstream v6.8.0
Brings 558 upstream commits (v6.0.0-Beta.8 → v6.8.0) into our fork while
preserving our automation surface.

Key upstream changes absorbed:
- src/bmm/ workflow layout retired in favor of src/bmm-skills/ (skill-based
  architecture with SKILL.md + customize.toml per skill)
- src/core/ replaced by src/core-skills/
- New src/scripts/resolve_customization.py for TOML override merging
- Installer expansion (42 platforms, channel-based versioning, remote registry)
- New bmm-skills: bmad-investigate, bmad-spec, bmad-prd (rewritten),
  bmad-prfaq, bmad-checkpoint-preview, bmad-customize, bmad-ux
- 15 new releases of doc translations, web bundles, validators

Our automation preserved:
- scripts/{epic-execute,epic-chain,uat-validate}.sh + epic-execute-lib/
  (untouched by upstream — no path collision)
- src/bmm/workflows/4-implementation/{epic-execute,epic-chain}/
- src/bmm/workflows/5-validation/uat-validate/

Script path rewiring:
- epic-execute.sh: DEV_WORKFLOW_DIR/REVIEW_WORKFLOW_DIR now point at
  src/bmm-skills/4-implementation/bmad-{dev-story,code-review}/, with
  *_WORKFLOW_SKILL pointing at SKILL.md (replaces old workflow.yaml +
  instructions.xml pair). Removed CORE_TASKS_DIR/WORKFLOW_EXECUTOR refs
  (src/core/tasks/workflow.xml no longer exists upstream).
- epic-execute-lib/INIT.md: updated directory tree doc and inspection
  commands to reference new skill paths.

Conflict resolutions:
- README.md, docs/reference/workflow-map.md, docs/tutorials/getting-started.md,
  src/bmm-skills/4-implementation/bmad-create-story/checklist.md → took
  upstream verbatim (stay aligned with their docs direction).
- package.json → took upstream (dropped test:schemas/validate:schemas since
  agent YAML schema retired with src/bmm/agents/; added test:urls,
  test:channels, validate:skills; rebundle path moved cli/ → installer/).
- src/bmm/agents/sm.agent.yaml, src/bmm/workflows/3-solutioning/create-architecture/workflow.md,
  src/bmm/workflows/document-project/instructions.md → accepted upstream's
  deletion (modify/delete conflict; these files are part of the retired
  src/bmm/ layout).

Validated:
- All 4 shell scripts pass `bash -n` syntax check.
- No stale path references remain in scripts/ (grep clean).

Not yet validated:
- `npm install` + `npm test` (run as follow-up).
- Functional smoke test of epic-execute.sh against a real story (manual,
  follow-up).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 06:00:02 -05:00
Caleb cdc92d0d90 feat(scripts): port memory-safe execution and reliability improvements from revive-dev
Sync functional improvements developed in revive-dev into BMAD-METHOD
fork while preserving repo-specific paths:

- Add memory-safe Claude helpers (run_claude_to_file, read_phase_tail)
  that pipe output to temp files instead of bash variables, preventing
  GB-scale RAM usage during long epic executions
- Add kill_orphaned_test_processes() to clean up zombie jest/vitest/
  playwright/pytest processes between stories and on exit
- Replace per-call `env -u CLAUDECODE` with global `unset CLAUDECODE`
  at script start for cleaner nested session support
- Port metrics resume/accumulation logic that restores counters from
  existing YAML on resumed runs and accumulates duration
- Add log truncation between stories (64KB cap) to prevent unbounded
  log growth across multi-story runs
- Add log persistence and cleanup trap to epic-chain.sh
- Revert regression-gate.sh test commands to direct execution (matching
  revive-dev pattern)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 11:52:39 -05:00
Caleb a58fb564d1 feat(scripts): add env isolation, incremental logging, and test timeouts
- Wrap all Claude CLI subprocess calls with `env -u CLAUDECODE` to prevent
  parent env var interference with child processes (17 sites across 7 files)
- Add `flush_log_to_repo()` to epic-execute.sh for incremental log persistence
  after each story completes or fails (prevents log loss on interruption)
- Add portable `run_with_timeout` utility to utils.sh and wrap all test
  invocations in epic-execute.sh and regression-gate.sh with configurable
  timeout (default 120s via REGRESSION_TEST_TIMEOUT)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 05:19:53 -06:00
Caleb 03e0cc63d5 merge: sync with upstream/main (v6.0.0-Beta.8)
Merge 217 upstream commits covering:
- Module restructuring: src/modules/ flattened to src/
- BMB, BMGD, CIS modules moved to separate repos
- Installer migrated from inquirer to @clack/prompts
- Workflow simplification and new naming conventions
- Docusaurus to Astro/Starlight docs migration
- CodeRabbit AI review integration
- Cross-file reference validator
- Non-interactive install support
- Kiro IDE support

Conflict resolutions:
- sm.agent.yaml: kept fork's EE/EC/UV/CR menu items, took upstream's CC description
- uat-validator.agent.yaml: moved to src/bmm/agents/, removed unsupported webskip field

Path updates for new structure:
- scripts/*.sh: src/modules/bmm/ → src/bmm/
- CLAUDE.md: updated module paths and removed references to extracted modules
- docs: fixed broken links, added Astro frontmatter to fork docs files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 14:09:21 -06:00
Caleb 87223692d3 feat(epic-execute): add test failure filtering and sync improvements from revive-dev
Port improvements developed in revive-dev: new test-failure-filter module for
baseline-aware failure detection and prompt size management, broken pipe fixes
in regression-gate, and log persistence in epic-execute. Paths adapted to
BMAD-METHOD repo structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 13:49:55 -06:00
Caleb 51e31ada91 feat(epic-execute): implement low-priority UX improvements (L1-L5)
- L1: Add checkpoint/resume capability with --resume flag
  - load_checkpoint(), save_checkpoint(), clear_checkpoint() in utils.sh
  - Auto-saves progress after each story, 7-day expiration
- L2: Add comprehensive --help option with grouped options and examples
  - show_help() function with environment variables and file locations
- L3: Add verbose Claude output streaming
  - execute_claude_verbose() for real-time output when --verbose set
- L4: Add metrics file archival to prevent unbounded growth
  - Archives to metrics/archive/, keeps last 10 per epic
- L5: Add workflow file content validation
  - validate_yaml_content(), validate_xml_content() with fallbacks
  - Integrated into validate_workflows()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:18:20 -06:00
Caleb 06ce7e7fca feat(epic-execute): implement medium-priority reliability fixes (M1-M5)
Add new utils.sh module with cross-platform support and reliability improvements:
- M1: execute_with_retry() with exponential backoff for transient failures
- M2: validate_yq() to detect Go vs Python yq versions with fallback
- M3: check_phase_completion_fuzzy() for case-insensitive signal detection
- M4: sed_inplace() for cross-platform sed (macOS/Linux compatibility)
- M5: check_branch_protection() to prevent commits to main/master

Update json-output.sh with enhanced JSON extraction using awk for multi-block
handling, normalized status comparison, and fuzzy matching fallback.

Update epic-execute.sh to source utils.sh and use cross-platform sed functions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:11:41 -06:00
Caleb ce2f9fb3d7 fix(epic-execute): implement high-priority reliability fixes (H1-H5)
H1: Git Add -A Safety
- Add check_sensitive_files() to detect untracked secrets
- Replace git add -A with git add -u (tracked files only)
- Update prompts to use explicit file staging

H2: Cleanup on Exit
- Add cleanup() function with trap handler for EXIT/INT/TERM
- Save checkpoint file for resume capability
- Finalize metrics and report uncommitted changes on exit
- Track CURRENT_STORY_INDEX throughout main loop

H3: Test Count Parsing (Multi-Framework)
- Add extract_test_count() supporting Jest, Mocha, Vitest, AVA, TAP, pytest, Go, Rust
- Try JSON output first, fall back to regex patterns
- Replace inline patterns in init_regression_baseline() and execute_regression_gate()

H4: Story Discovery (Word Boundaries)
- Fix grep pattern with word boundary: ${EPIC_ID}([^0-9]|$)
- Prevents "Epic: 1" from matching "Epic: 10" or "Epic: 100"
- Add associative array deduplication (bash 4+) with fallback

H5: Prompt Size Limits
- Add MAX_PROMPT_SIZE config (default 150KB)
- Add get_byte_size(), truncate_content(), build_sized_prompt()
- Truncate large workflow YAML and decision logs
- Add verbose logging of prompt sizes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:03:48 -06:00
Caleb 5c63f31c0e feat(epic-execute): add JSON output parsing and TDD workflow phases
Implements the final two improvements from bmad_improvements_v2.md:

## Structured JSON Output (Improvement #6)
- New module: scripts/epic-execute-lib/json-output.sh
- Functions for extracting and parsing JSON from Claude output
- Unified check_phase_completion() with JSON + text fallback
- Updated prompts to request JSON result blocks
- Added --legacy-output flag to disable JSON parsing

## Test-First Flow (Improvement #7)
- New module: scripts/epic-execute-lib/tdd-flow.sh
- execute_test_spec_phase() - Generates BDD specs from acceptance criteria
- execute_test_impl_phase() - Creates failing tests from specs
- execute_test_verification_phase() - Verifies tests fail correctly
- Integration with dev phase for TDD context
- Added --skip-tdd, --skip-test-spec, --skip-test-impl flags

All 7 improvements from the analysis are now complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:33:25 -06:00
Caleb fd744c96f3 feat(epic-execute): add phase 2+3 improvements with modular architecture
- Add decision log module for context preservation across phases
- Add regression gate module for test baseline tracking
- Add design phase module for pre-implementation planning
- Enhance fix phase to include real tooling output
- Pass design and decision context to dev phase
- Add --skip-design and --skip-regression CLI flags
- Modularize into epic-execute-lib/ for maintainability

Implements improvements from bmad_improvements_v2.md:
- Phase 2.1: Real test output in fix loops
- Phase 2.2: Cumulative decision log
- Phase 2.3: Regression test gate
- Phase 3.1: Pre-implementation design phase

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:23:16 -06:00
Caleb 3bad076884 fix(epic-execute): make --skip-done case-insensitive for status matching
The script marks stories with lowercase "done" but was checking for
capitalized "Done", causing --skip-done to never match completed stories.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:51:30 -06:00
Caleb 865b904041 feat(epic-execute): add comprehensive quality gates with self-healing
- Add architecture compliance check (per-story) with fix loop
- Add test quality review (per-story) with TEA patterns
- Add requirements traceability (per-epic) with self-healing test generation
- Add --skip-arch, --skip-test-quality, --skip-traceability flags
- Update workflow.md to v2.0 with new flow diagram
- Add step templates for each quality gate phase
- Include improvements doc and execution report

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:45:13 -06:00
Caleb 059c1f6e4a feat(epic-execute): integrate BMAD workflows with self-healing fix loop
- Replace inline prompts with actual BMAD workflow files:
  - dev-story workflow (workflow.yaml, instructions.xml, checklist.md)
  - code-review workflow (workflow.yaml, instructions.xml, checklist.md)
  - UAT generation templates (step-04-generate-uat.md, uat-template.md)

- Add workflow validation at startup to ensure all required files exist

- Implement self-healing fix loop for review failures:
  - When review fails, capture HIGH/MEDIUM severity findings
  - Spawn new fix phase using dev-story workflow in targeted fix mode
  - Re-run review after fixes to verify resolution
  - Retry up to 3 times before marking story as failed

- Enhanced metrics tracking:
  - fix_loop.total_fix_attempts: count of all fix phases
  - fix_loop.stories_requiring_fixes: stories needing at least one fix
  - fix_loop.max_retries_hit: stories that failed after 3 attempts
  - story_details: per-story fix attempt outcomes with timestamps

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 06:01:22 -06:00
Caleb 15b7bb1ae6 feat: implement UAT validation with self-healing fix loop
Add complete UAT validation workflow implementation:

- scripts/uat-validate.sh: Core UAT validation script with scenario
  classification, automated execution, and self-healing fix loop
- scripts/epic-execute.sh: Add metrics instrumentation for story
  execution tracking (init, update, finalize metrics)
- scripts/epic-chain.sh: Integrate UAT gate after each epic with
  configurable blocking mode, and add report generation phase

New workflow step documentation:
- step-01-load-uat.md: UAT document loading and parsing
- step-02-classify-scenarios.md: Scenario classification logic
- step-03-execute-scenarios.md: Automated scenario execution
- step-04-evaluate-gate.md: Gate evaluation and fix loop
- step-05-report-results.md: Metrics and signal output

Key features:
- Gate modes: quick (automatable only), full (+ semi-auto), skip
- Self-healing: spawns fresh Claude context for targeted fixes
- Metrics: YAML files track execution stats and UAT results
- Signals: parseable output for orchestration (UAT_GATE_RESULT, etc.)
- Handoffs: include UAT status and fix context references

Also fixes lint/format issues in pre-existing files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 19:24:18 -06:00
Caleb 66186e1438 feat: add epic-execute and epic-chain workflows
Add two new implementation workflows for the Scrum Master agent:
- epic-execute: Sequential story execution with isolated dev/review phases
- epic-chain: Multi-epic execution with dependency detection

Includes orchestration scripts and SM agent menu items.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 11:24:21 -06:00