Commit Graph

10 Commits

Author SHA1 Message Date
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 efc0bdd56f docs(epic-execute): add dependency and setup documentation
Add INIT.md documenting:
- Required dependencies (bash, git, claude CLI)
- Recommended dependencies (yq, jq, xmllint)
- Project-specific test runners
- Quick setup script for dependency checking
- Environment variables reference
- Directory structure and path configuration
- Path resolution explanation for target projects

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:26:53 -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