Commit graph

160 commits

Author SHA1 Message Date
Test User
0ff60124fd docs(readme): add link to TESTING.md guide 2026-01-10 18:44:23 -07:00
Test User
94cb7493db docs(status): mark CONTRIBUTING.md guide complete 2026-01-10 18:22:37 -07:00
Test User
d0cb80f670 docs: add comprehensive contributor guide
- Create CONTRIBUTING.md with 8 sections covering the full contributor
  journey: Getting Started, Development Workflow, Code Style, Testing,
  PR Process, Code Review, Quality Standards, and Community Guidelines
- Include workflow diagram, quality gates table, and test commands reference
- Update README.md to reference CONTRIBUTING.md, consolidating duplicate
  contributor information into the dedicated guide
2026-01-10 17:03:12 -07:00
Test User
4679b16448 docs: add comprehensive testing guide
Add TESTING.md with complete documentation for the Ralph test suite:
- Quick start commands for running tests
- Test organization and directory structure
- BATS syntax guide with examples from the codebase
- Test helper API documentation (assertions, mocks, fixtures)
- Coverage requirements and kcov limitations
- CI/CD integration with GitHub Actions pipeline
- Troubleshooting guide for common issues
- Appendices with quick reference and patterns

Covers all 276 tests across 11 test files.
2026-01-10 16:58:29 -07:00
Test User
e28d20b856 docs: remove community issues from phase structure
Reverted changes to issues not created by frankbria:
- #44, #54, #64, #65 removed from phase assignments
- Restored original issue titles on GitHub
- Removed phase labels from community issues
- Updated open issue counts (40 → 36)
2026-01-10 15:09:17 -07:00
Test User
bada82e4e2 docs(status): update IMPLEMENTATION_STATUS.md with phased structure
- Update test counts (75 -> 276) and all test file details
- Convert from Week-based to Phase-based structure (Phases 1-6)
- Add all GitHub issues organized by phase and priority
- Update version history with v0.9.0-v0.9.8 changes
- Add summary statistics and open issues by priority
- Collapse closed issues into expandable section
2026-01-10 15:02:08 -07:00
Test User
8123e8f249 docs(plan): restructure IMPLEMENTATION_PLAN.md with phased development
- Reorganize document: Current Phase -> Planned -> Completed (at bottom)
- Integrate all GitHub issues into phased structure (Phases 1-6)
- Add Phase 5 (GitHub Issue Integration) issues #69-73
- Add Phase 6 (Sandbox Environments) issues #49, #74-80
- Minimize completed work in collapsible section
- Add priority legend and implementation order
- Update test coverage summary
- Close #63 (fix IMPLEMENTATION_PLAN)
2026-01-10 14:55:09 -07:00
Test User
d0208c4f6a docs(readme): update for v0.9.3-v0.9.8 changes
- Add version history entries for v0.9.3 through v0.9.8
- Add Session Continuity feature to features list
- Add new Session Continuity configuration section
- Add --reset-session flag to command reference
- Add new test file references (session, import, setup, installation)
2026-01-10 13:30:08 -07:00
Frank Bria
1c72010a93
Merge pull request #67 from frankbria/feature/import-modern-cli
feat(import): modernize ralph_import.sh with JSON output parsing
2026-01-10 13:19:51 -07:00
Test User
852088101d docs(import): add function docblocks and fix path handling bug
- Add detailed docblocks for detect_response_format, parse_conversion_response,
  and check_claude_version functions
- Declare global PARSED_* variables near top of script with documentation
- Fix bug where convert_prd was called with subdirectory path after cd
  (now uses basename since file is copied to project root)

All 276 tests pass.
2026-01-10 12:22:04 -07:00
Test User
1c9059b902 fix(import): address additional code review feedback
- Convert CLAUDE_ALLOWED_TOOLS to bash array for proper quoting
- Use array expansion "${CLAUDE_ALLOWED_TOOLS[@]}" in CLI invocation
- Default empty version components to 0 (handles "2.1" style versions)
- Add stderr_file cleanup in JSON error path
- Add type validation for PARSED_FILES_CREATED before array iteration
- Check for empty file names in JSON array iteration
- Fix stale test counts in README.md (165 → 276, 8 → 11 test files)
2026-01-10 11:38:43 -07:00
macroscopeapp[bot]
bcc3db9474
Append PRD source content to conversion prompt in convert_prd function (#68)
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
2026-01-10 18:35:33 +00:00
Test User
6dde9cbd26 fix(import): address code review feedback
- Fix check_claude_version() to use numeric semantic version comparison
- Fix detect_response_format() to read first non-whitespace character
- Wire PARSED_RESULT into success message output
- Wire PARSED_FILES_CREATED into file verification logic
- Add --allowedTools flag to CLI invocation using CLAUDE_ALLOWED_TOOLS
- Separate stderr to avoid corrupting JSON output file
- Clean up stderr file on completion and error
- Update README.md version badges to v0.9.8 and 276 tests
- Update roadmap section with current test coverage breakdown
2026-01-10 11:24:30 -07:00
Test User
4b1ca9bcc7 feat(import): modernize ralph_import.sh with JSON output parsing
- Add --output-format json flag for structured Claude CLI responses
- Implement detect_response_format() for JSON vs text detection
- Implement parse_conversion_response() for extracting JSON fields
- Add check_claude_version() for modern CLI feature detection
- Enhance error handling with structured JSON error messages
- Improve file verification with JSON-derived status information
- Maintain backward compatibility with automatic text fallback
- Add 11 new TDD tests for modern CLI features (tests 23-33)
- Update README.md with Modern CLI Features section
- Update CLAUDE.md with v0.9.8 release notes

Test count: 276 (up from 265)
2026-01-10 11:12:13 -07:00
Frank Bria
6ace046ef8
Merge pull request #66 from frankbria/feature/session-continuity
feat(session): add session lifecycle management with auto-reset triggers
2026-01-10 10:54:11 -07:00
Test User
cafaacdc0c fix(session): address code review feedback for session management
- Fix SC2155: separate declare from assign in get_session_id(),
  log_session_transition(), init_session_tracking()
- Use jq for safe JSON generation in reset_session() and init_session_tracking()
  instead of heredocs (prevents special character issues)
- Add corruption tolerance to log_session_transition() with JSON validation
  and fallback to empty array on parse failures
- Add generate_session_id() to create unique session IDs (ralph-<epoch>-<random>)
- Add update_session_last_used() helper called on each loop iteration
- init_session_tracking() now generates unique session_id and sets last_used
- Add session files to .gitignore (.ralph_session, .ralph_session_history,
  .claude_session_id)

All 265 tests pass.
2026-01-10 10:48:19 -07:00
Test User
274f496f77 fix(session): address code review feedback
- Add init_session_tracking() call in main() before loop starts
- Use literal escape codes for color in --reset-session output
- Remove conditional in reset_session() to always create file
- Remove unused old_session_id variable
- Remove duplicate SESSION_EXPIRATION_SECONDS (keep in response_analyzer.sh)
- Add clarifying comments for RALPH_SESSION_FILE vs CLAUDE_SESSION_FILE

All 265 tests pass.
2026-01-10 10:37:06 -07:00
Test User
d3310d1f3f feat(session): add session lifecycle management with auto-reset triggers
- Add session management functions: get_session_id(), reset_session(),
  log_session_transition(), init_session_tracking()
- Session auto-reset on: circuit breaker open, manual interrupt,
  project completion, manual circuit reset
- Add --reset-session CLI flag for manual session reset
- Add session history tracking (.ralph_session_history, last 50 entries)
- New config: RALPH_SESSION_FILE, RALPH_SESSION_HISTORY_FILE
- Add 26 comprehensive tests for session continuity (TDD)
- All 265 tests pass (up from 239)
- Update CLAUDE.md with v0.9.7 release notes
2026-01-10 10:27:42 -07:00
Frank Bria
3a474b4317
Merge pull request #62 from frankbria/feature/json-output-parsing
feat(analyzer): add Claude CLI JSON format support and session management
2026-01-09 18:03:03 -07:00
Test User
a2e7e9385c fix(analyzer): address code review feedback
- Fix BSD date parsing to handle milliseconds in ISO timestamps
  (e.g., 2026-01-09T10:30:00.123+00:00)
- Document error_count mapping behavior when only has_errors=true is present
- Remove unused has_session_id_field variable
- Add debug logging for session persistence (controlled by VERBOSE_PROGRESS)
- Standardize session filename to .claude_session_id across all files

All 239 tests passing.
2026-01-09 17:59:08 -07:00
Test User
fdff095c18 feat(analyzer): add Claude CLI JSON format support and session management
- Extend parse_json_response() to support both flat and Claude CLI formats
  - Extract result, sessionId, and metadata fields
  - Support metadata.files_changed, metadata.has_errors, completion_status
  - Parse progress_indicators array for confidence boosting
- Add session management functions for continuity tracking:
  - store_session_id(): Persist session with ISO timestamp
  - get_last_session_id(): Retrieve stored session ID
  - should_resume_session(): Check session validity (24-hour expiration)
- Add get_epoch_seconds() to date_utils.sh for cross-platform epoch time
- Auto-persist sessionId to .session_id file during response analysis
- Add 16 new TDD tests for Claude CLI format and session management
- Update documentation for v0.9.6 (239 tests total)

Test count: 239 (up from 223)
2026-01-09 17:46:02 -07:00
Frank Bria
3d91d92691
Merge pull request #61 from frankbria/feature/prd-import-tests
test(import): add 22 comprehensive tests for ralph_import.sh
2026-01-09 16:34:03 -07:00
Test User
b06d979b0b test(import): add 22 comprehensive tests for ralph_import.sh
Add integration tests for PRD to Ralph format conversion:
- File format support tests (.md, .txt, .json)
- Output file creation tests (PROMPT.md, @fix_plan.md, specs/requirements.md)
- Project naming tests (custom names, auto-detection from filename)
- Error handling tests (missing files, dependencies, conversion failures)
- Help and usage tests
- Full workflow integration tests
- Edge case handling (hyphens, uppercase, subdirectory paths)

Test infrastructure:
- Mock ralph-setup command using PATH manipulation
- Mock Claude Code CLI for isolated conversion testing
- Added create_sample_prd_txt() fixture helper

Test count: 223 (up from 201)
2026-01-09 16:13:23 -07:00
Frank Bria
27df19716e
Merge pull request #60 from frankbria/feature/project-setup-tests
test(setup): add 36 comprehensive tests for setup.sh
2026-01-09 16:04:29 -07:00
Test User
a6587aa189 fix(test): improve test reliability and remove tautologies
- Remove unused 'load mocks' (mocks.bash not needed)
- Use GIT_AUTHOR_*/GIT_COMMITTER_* env vars instead of git config --global
- Prefix git commands with 'command' to bypass shell function overrides
- Fix tautological assertions in edge case tests:
  - Rename test to "succeeds when run in existing directory (idempotent)"
  - Assert success ($status -eq 0) instead of always-true condition
2026-01-09 15:47:41 -07:00
Test User
c68e484f7d test(setup): add 36 comprehensive tests for setup.sh
Add integration tests validating project initialization:
- Directory creation (project dir, subdirectories)
- Template copying (PROMPT.md, @fix_plan.md, @AGENT.md, specs)
- Git initialization (repo, commit, message)
- README creation and content
- Custom/default project names
- Working directory behavior
- Error handling (missing templates)
- Output message validation

Test count: 201 (up from 165)
2026-01-09 15:01:53 -07:00
Frank Bria
4a83b879c2
Merge pull request #59 from frankbria/feature/installation-tests
test(install): add comprehensive installation tests
2026-01-09 14:31:45 -07:00
frankbria
3503b9b27b fix: address code review feedback
README.md:
- Update version badge to v0.9.3
- Update test count to 165 in all locations
- Update test coverage breakdown (111 unit + 54 integration)

test_installation.bats:
- Add missing mock setup.sh in setup() function
- Fix dependency test to mock all three deps (jq, git, node/npx)
- Remove unused source_install_functions helper function
2026-01-09 14:20:58 -07:00
frankbria
31ba3eb2bc docs(readme): add X follow badge for @FrankBria18044
Add social follow badge linking to X profile
2026-01-09 14:09:14 -07:00
frankbria
6688c27681 test(install): add 14 comprehensive installation tests
- Add test_installation.bats with full coverage of install.sh
- Tests cover directory creation, command installation, permissions
- Template and lib file copying verification
- Dependency detection with mocked failures (jq, git, node)
- PATH detection and warning system tests
- Uninstallation cleanup verification
- Idempotency testing (run twice without errors)
- End-to-end installation workflow validation
- All tests use isolated temp directories for safety
- Update CLAUDE.md with new test count (165 total)
- Fix npm test script to run tests recursively
- Version bump to v0.9.3
2026-01-09 14:05:46 -07:00
Frank Bria
4da4d52fde
Merge pull request #58 from frankbria/fix/prompt-file-flag
fix(loop): replace non-existent --prompt-file with -p flag
2026-01-09 13:56:12 -07:00
frankbria
30cdf78331 fix(loop): replace non-existent --prompt-file with -p flag
The build_claude_command() function was incorrectly using --prompt-file
which doesn't exist in Claude Code CLI. This fix:

- Replaces --prompt-file with -p flag plus prompt content
- Reads prompt content via $(cat "$prompt_file") before execution
- Adds error handling for missing prompt files
- Maintains shell injection safety through array-based command building
- Updates comments to reflect the correct approach

Adds 6 TDD tests verifying the fix:
- Uses -p flag instead of --prompt-file
- Reads prompt file content correctly
- Handles missing prompt file
- Includes all modern CLI flags
- Handles multiline prompt content
- Prevents shell injection

Test count: 145 -> 151 (all passing)
2026-01-09 13:44:50 -07:00
frankbria
0fbb92a4ae Add Awesome Code Code mention to README.md 2026-01-09 12:58:13 -07:00
frankbria
6c08757652 docs: update README.md and CLAUDE.md for v0.9.1
README.md:
- Update test count: 98 → 145 tests (accurate count from all 7 test files)
- Change coverage badge to informational (kcov subprocess limitation)
- Add CI/CD integration mention
- Add coverage note with link to bats-core#15
- Add --reset-circuit and --circuit-status to command reference
- Simplify formatting (remove emoji prefixes)

CLAUDE.md:
- Add version/test status line at top
- Add CI/CD Pipeline section documenting all 3 workflows
- Add Test Suite table with all 7 test files
- Add Running Tests section with npm/bats commands
- Document CLI parsing tests (27 new tests)
- Update Feature Completion Checklist with CI/CD requirement
- Add coverage note explaining kcov limitations
2026-01-08 23:34:01 -07:00
Frank Bria
970e683236
Merge pull request #53 from frankbria/fix/ci-coverage-bats-path
fix(ci): disable coverage threshold due to kcov subprocess limitation
2026-01-08 23:25:29 -07:00
frankbria
7db4a63b4f fix(ci): disable coverage threshold due to kcov subprocess limitation
kcov cannot trace subprocess executions due to LD_PRELOAD limitations.
When bats runs tests, it spawns new bash processes that kcov cannot
instrument. This is a known, unsolved issue in bats-core (issue #15).

Changes:
- Set COVERAGE_THRESHOLD to 0 (disabled enforcement)
- Added detailed comment explaining the limitation
- Coverage job remains for informational purposes
- Test pass rate (100%) serves as the quality gate

References:
- https://github.com/bats-core/bats-core/issues/15
2026-01-08 23:23:14 -07:00
frankbria
0c0b0b63b1 fix(ci): use full path to bats for kcov coverage
kcov spawns a subprocess that doesn't inherit the npm PATH, so
the 'bats' command wasn't found. Use the full path to the bats
binary in node_modules/.bin/ to fix coverage measurement.
2026-01-08 23:09:03 -07:00
Frank Bria
f286710ee4
Merge pull request #52 from frankbria/feature/issue-10-cli-parsing-tests
test(cli): add comprehensive CLI argument parsing tests
2026-01-08 23:06:01 -07:00
frankbria
3e76f80e29 fix(ci): properly build kcov from source
Previous approach tried to download pre-built binaries that don't exist.
Now builds kcov from source with all required dependencies:
- cmake, g++ for compilation
- binutils-dev, libcurl4-openssl-dev, libdw-dev, libiberty-dev
- zlib1g-dev, libssl-dev

Also added better debugging output when coverage files not found.

Refs #10
2026-01-08 23:03:30 -07:00
frankbria
5823003ff0 fix(ci): build kcov from source instead of apt-get
kcov is not available in Ubuntu's default repositories. Update the
workflow to:
- Install kcov build dependencies
- Try downloading pre-built binary first
- Fall back to building from source if pre-built not available
- Add graceful handling for coverage measurement failures

Refs #10
2026-01-08 23:00:26 -07:00
frankbria
54963d4ead ci: add kcov coverage measurement for bash scripts
Add coverage job to CI pipeline using kcov:
- Install kcov on Ubuntu runner
- Run BATS tests under kcov to collect coverage for ralph_loop.sh and lib/
- Generate HTML and JSON coverage reports
- Configurable threshold via COVERAGE_THRESHOLD env var (default: 70%)
- Set threshold to 0 to disable enforcement
- Upload coverage artifacts for inspection
- Optional Codecov integration

Coverage is measured separately from test execution to keep the
test job fast and isolate coverage concerns.

Refs #10
2026-01-08 22:56:07 -07:00
frankbria
7407f0f45b test(cli): add --allowed-tools test and code review report
Address code review finding by adding dedicated test for
--allowed-tools flag validation.

Add code review report documenting:
- 0 critical issues
- 0 major issues
- 1 minor issue (addressed in this commit)
- 6 positive findings

Test count: 27 CLI parsing tests (105 total unit tests)

Refs #10
2026-01-08 22:42:50 -07:00
frankbria
fffcc26427 test(cli): add comprehensive CLI argument parsing tests
Add 26 new BATS tests validating all CLI flags in ralph_loop.sh:

- Help flag tests (2): --help, -h short flag
- Flag value tests (6): --calls, --prompt, --monitor, --verbose, --timeout
- Status flag tests (2): --status with/without status.json
- Circuit breaker tests (2): --reset-circuit, --circuit-status
- Invalid input tests (3): unknown flag, invalid timeout, invalid format
- Multiple flags tests (3): combinations, all flags, early exit
- Flag order tests (2): verify order independence
- Short flag tests (6): -c, -p, -s, -m, -v, -t equivalence

Test strategy uses --help as early-exit escape to validate parsing
without triggering main loop execution.

Closes #10
2026-01-08 22:38:23 -07:00
Frank Bria
f4760225dc
Merge pull request #47 from frankbria/feature/phase-1.1-modern-cli-commands
[P1] feat(cli): add modern CLI commands with JSON output support (Phase 1.1)
2026-01-08 21:26:04 -07:00
frankbria
c7c6c9389d fix(security): use jq for JSON construction in analyze_response()
Replace two heredocs that write analysis results with jq construction
to prevent JSON injection via work_summary or other string fields.

Fixed locations:
- Line 205-235: JSON parsing path analysis result
- Line 351-381: Text parsing path analysis result

Both now use jq with --arg for strings and --argjson for numeric/boolean
fields, ensuring proper escaping of special characters.
2026-01-08 21:10:33 -07:00
frankbria
50f6ef7a96 fix(security): address code review security findings
Fixes three security issues identified in Phase 1.1 code review:

1. JSON injection in parse_json_response() (response_analyzer.sh:113-132)
   - Replace heredoc with jq construction using --arg for strings
   - Use --argjson for numeric/boolean fields
   - Ensures proper escaping of quotes, newlines, backslashes

2. Input validation for --allowed-tools flag (ralph_loop.sh:903-905)
   - Add VALID_TOOL_PATTERNS whitelist
   - Add validate_allowed_tools() function
   - Validate against whitelist in argument parsing
   - Allow Bash(...) patterns with any content

3. Shell injection in build_claude_command() (ralph_loop.sh:439-444)
   - Convert from string concatenation to command array
   - Use global CLAUDE_CMD_ARGS array
   - Execute with "${CLAUDE_CMD_ARGS[@]}" instead of bash -c
   - No manual escaping needed - array handles metacharacters

All 98 tests passing.

Closes #48, #50
2026-01-08 21:02:46 -07:00
frankbria
e7e54d8087 docs(review): add Phase 1.1 code review report 2026-01-08 20:49:13 -07:00
frankbria
da5640ef8e feat(cli): add modern CLI commands with JSON output support (Phase 1.1)
Implements Issue #28 - modernize CLI commands for better Claude integration.

Key changes:
- Add JSON output format support with --output-format flag (default: json)
- Add session continuity with --continue flag and .claude_session_id file
- Add tool permissions via --allowed-tools flag
- Add build_loop_context() for loop-aware context injection
- Add detect_output_format() and parse_json_response() for JSON parsing
- Maintain backward compatibility with text output fallback
- Add version checking with check_claude_version()

New CLI options:
- --output-format json|text: Control Claude output format
- --allowed-tools "Write,Read,Bash(git *)": Restrict tool permissions
- --no-continue: Disable session continuity

Test coverage:
- 20 new JSON parsing tests (test_json_parsing.bats)
- 23 new CLI modern tests (test_cli_modern.bats)
- All 98 tests passing (100% pass rate)
2026-01-08 20:39:18 -07:00
Frank Bria
aab6d90502
Add Claude Code GitHub Actions workflow 2026-01-08 20:30:01 -07:00
Frank Bria
0d30de4a80
Add Claude Code Review workflow 2026-01-08 20:28:42 -07:00