Add windows split-pane monitoring support, additional support for Windows users#86
Add windows split-pane monitoring support, additional support for Windows users#86danielcrenna wants to merge 13 commits into
Conversation
Introduces Windows Terminal split-pane monitoring for the --monitor flag, adds lib/platform_utils.sh for platform and multiplexer detection, and creates Windows CMD/PowerShell wrappers for installation and test running. Updates documentation for Windows support, improves log_status to output to stderr, and adds 18 new unit tests for platform utilities.
WalkthroughAdds cross-platform Windows support: new lib/platform_utils.sh for OS/multiplexer detection, Windows install/test wrappers (install.cmd, install.ps1, test.ps1), Windows CMD entry wrappers created by install.sh, monitor flow updated to support Windows Terminal or tmux, Claude Code CLI namespace updated, and tests/docs updated. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant InstallWrapper as install.ps1 / install.cmd
participant GitBash as Git Bash
participant InstallSh as install.sh
participant PlatformUtils as lib/platform_utils.sh
participant System
User->>InstallWrapper: run installer
InstallWrapper->>InstallWrapper: locate Git Bash
alt Git Bash found
InstallWrapper->>GitBash: invoke install.sh (args)
GitBash->>InstallSh: execute
InstallSh->>PlatformUtils: source & get_platform()
PlatformUtils-->>InstallSh: platform info
alt Windows
InstallSh->>System: create *.cmd wrappers
InstallSh->>PlatformUtils: has_windows_terminal()
else Unix
InstallSh->>System: check tmux
end
InstallSh-->>GitBash: finish (exit code)
GitBash-->>InstallWrapper: exit code
InstallWrapper-->>User: success/final message
else Git Bash missing
InstallWrapper-->>User: instruct to install Git for Windows
end
sequenceDiagram
participant User
participant RalphLoop as ralph_loop.sh
participant PlatformUtils as lib/platform_utils.sh
participant Multiplexer as Multiplexer (tmux / wt)
participant Session
User->>RalphLoop: request monitor mode
RalphLoop->>PlatformUtils: get_available_multiplexer()
PlatformUtils-->>RalphLoop: returns tmux / windows_terminal / none
alt multiplexer available
RalphLoop->>RalphLoop: setup_monitor_session()
alt windows_terminal
RalphLoop->>Multiplexer: wt.exe split-pane commands
else tmux
RalphLoop->>Multiplexer: tmux new-session / split
end
Multiplexer->>Session: create panes & run commands
Session-->>User: monitoring active
else none
RalphLoop-->>User: error: install tmux or Windows Terminal
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add Windows Terminal split-pane monitor support and create Windows CMD/PowerShell wrappers to run Ralph commands and installation scriptsImplement platform-aware monitor selection in 📍Where to StartStart with the monitor flow in ralph_loop.sh, then review platform detection in lib/platform_utils.sh and installation changes in install.sh. Macroscope summarized 67c5540. |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
README.md (2)
6-6: Update test count and file count throughout README to reflect actual test suite.The README shows 276 tests across 11 test files, but the actual test suite contains 310 tests across 12 test files. Update the following locations:
- Line 6: Badge shows "276 passing" → should be "310 passing"
- Line 21: "276 tests, 100% pass rate" → should be "310 tests, 100% pass rate"
- Line 37: "276 passing tests across 11 test files" → should be "310 passing tests across 12 test files"
- Line 456: "276 tests" and "across 11 test files" → should be "310 tests" and "across 12 test files"
419-491: Enhance Windows Terminal winget installation command with explicit flags for consistency.The Windows Terminal installation commands are verified and correct. However, the winget command should include the
--idand-e(exact match) flags for precision and consistency with package manager best practices. Update the winget command fromwinget install Microsoft.WindowsTerminaltowinget install --id Microsoft.WindowsTerminal -e. The Chocolatey command and Microsoft Store instructions are accurate.
🤖 Fix all issues with AI agents
In @install.sh:
- Around line 159-177: The Windows CMD wrapper creation currently hardcodes
"%ProgramFiles%\Git\bin\bash.exe"; instead source lib/platform_utils.sh in
install.sh and call get_git_bash_path() to obtain the correct Git Bash path,
then use that variable when writing the ralph.cmd, ralph-monitor.cmd,
ralph-setup.cmd, and ralph-import.cmd files (same INSTALL_DIR and filenames) so
the generated batch files embed the detected path; alternatively, implement a
small runtime fallback in the batch wrappers that invokes get_git_bash_path()
logic if detection failed during install (follow the pattern used in
ralph_loop.sh for reference).
In @ralph_loop.sh:
- Around line 189-227: The current code builds ralph_cmd and monitor_cmd as
concatenated strings which is vulnerable to shell-injection (e.g., via
PROMPT_FILE) and also unsafe when passed through cmd.exe; change both to arrays
(e.g., ralph_cmd_arr and monitor_cmd_arr), set the executable as the first
element ("ralph" or "bash", or "$ralph_home/ralph_loop.sh"), and append options
as separate elements (e.g., ralph_cmd_arr+=("--calls" "$MAX_CALLS_PER_HOUR") and
ralph_cmd_arr+=("--prompt" "$PROMPT_FILE") ), do the same for monitor_cmd_arr,
then invoke Windows Terminal using the array expansions (pass each argument
separately via "${ralph_cmd_arr[@]}" and "${monitor_cmd_arr[@]}") instead of
injecting a single string; for the cmd.exe fallback avoid composing a shell
command string—either remove the cmd.exe path entirely or, if unavoidable, build
a single safely quoted command from the arrays using printf '%q' on each element
before passing to cmd.exe; update usages around ralph_cmd, monitor_cmd, and the
cmd.exe invocation to use the new arrays.
In @tests/helpers/test_helper.bash:
- Around line 232-249: The here-doc for the xargs wrapper expands PATH, HOME,
and TERM at load time causing stale values; update the wrapper creation so the
env variables are escaped (use \$PATH, \$HOME, \$TERM and \$@ inside the
here-doc) so they expand at runtime when the wrapper is executed (the wrapper
script created with _REAL_XARGS and written to _XARGS_WRAPPER_DIR/xargs). Also
add cleanup in teardown() to remove the temporary _XARGS_WRAPPER_DIR if set and
exists (check _XARGS_WRAPPER_DIR and that it's a directory, then rm -rf it) to
avoid accumulating wrapper dirs across test runs.
In @tests/unit/test_platform_utils.bats:
- Around line 43-56: The case in the test for os_type is missing the Windows_NT*
pattern which lib/platform_utils.sh handles; update the case statement in
tests/unit/test_platform_utils.bats to include a Windows_NT* branch that sets
expected_platform="windows" (or consolidate Windows_NT* into the existing
MINGW*|MSYS*|CYGWIN* pattern) so that when uname -s returns Windows_NT the test
expects "windows" and does not falsely fail.
🧹 Nitpick comments (5)
CLAUDE.md (1)
329-329: Fix capitalization: "macos" → "macOS".The operating system from Apple should be written as "macOS" (capital OS) per official Apple branding and common technical documentation standards.
📝 Proposed fix
- - `is_windows()`, `is_macos()`, `is_linux()` - Platform detection helpers + - `is_windows()`, `is_macOS()`, `is_linux()` - Platform detection helperstests/unit/test_platform_utils.bats (1)
237-255: Consider using a subshell to isolate directory changes.The
cdoperations on lines 245 and 248 could leave the test in an inconsistent state if either fails (despitereturn 1). Using a subshell would provide better isolation.♻️ Suggested improvement
@test "get_windows_cwd returns Windows path on Windows" { local platform platform=$(get_platform) if [[ "$platform" == "windows" ]]; then - # Change to a directory with a drive letter (not /tmp which lacks it) - local orig_dir - orig_dir=$(pwd) - cd "${BATS_TEST_DIRNAME}" || return 1 - - run get_windows_cwd - cd "$orig_dir" || return 1 + # Use subshell to isolate directory change + run bash -c 'cd "${BATS_TEST_DIRNAME}" && source "$PLATFORM_UTILS" && get_windows_cwd' assert_success # Should start with drive letter (e.g., C:) - check second char is colon [[ "${output:1:1}" == ":" ]] else skip "Not running on Windows" fi }lib/platform_utils.sh (2)
34-54: Consider caching platform detection for repeated calls.Each
is_*function spawns a subprocess viaget_platform→uname -s. For the current usage pattern (initialization-time checks), this is acceptable. If these functions are called frequently in hot paths, consider caching the result.♻️ Optional caching pattern
# Cache platform at source time _CACHED_PLATFORM="" _get_cached_platform() { if [[ -z "$_CACHED_PLATFORM" ]]; then _CACHED_PLATFORM=$(get_platform) fi echo "$_CACHED_PLATFORM" } is_windows() { [[ "$(_get_cached_platform)" == "windows" ]] }
96-100: Redundant stderr redirection.Line 98 uses
&>/dev/null 2>&1which is redundant.&>/dev/nullalready redirects both stdout and stderr. Additionally, whiletimeoutmay not exist on all systems, this code path is only reached on Windows where it should be available.♻️ Suggested fix
# Check via cmd.exe with timeout (may hang in some environments) # Only try this as a last resort - if timeout 2s cmd.exe /c "where wt" &>/dev/null 2>&1; then + if timeout 2s cmd.exe /c "where wt" &>/dev/null; then return 0 firalph_loop.sh (1)
1371-1371: Remove unnecessaryplatform_utils.shsourcing from--reset-circuitand--circuit-statusblocks.The
--reset-circuitblock (line 1371) and--circuit-statusblock (line 1388) sourceplatform_utils.shbut do not use any of its functions. The--reset-circuitblock only callsreset_circuit_breaker()andreset_session(), and the--circuit-statusblock only callsshow_circuit_status()— all from other libraries. Removing these unnecessary source statements will reduce startup overhead.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
CLAUDE.mdREADME.mdcreate_files.shinstall.cmdinstall.ps1install.shlib/platform_utils.shralph_import.shralph_loop.shtest.ps1tests/helpers/test_helper.bashtests/integration/test_prd_import.batstests/unit/test_platform_utils.bats
🧰 Additional context used
📓 Path-based instructions (4)
tests/**/*.bats
📄 CodeRabbit inference engine (CLAUDE.md)
Test files must follow naming convention: test_*.bats in tests/unit/ and tests/integration/ directories, organized by component (cli_parsing, json_parsing, session_continuity, exit_detection, etc.)
Files:
tests/integration/test_prd_import.batstests/unit/test_platform_utils.bats
**/*.sh
📄 CodeRabbit inference engine (CLAUDE.md)
All bash scripts in Ralph must use array-based command building for CLI arguments to maintain shell injection safety
Files:
install.shcreate_files.shralph_import.shlib/platform_utils.shralph_loop.sh
README.md
📄 CodeRabbit inference engine (CLAUDE.md)
README.md must maintain current feature lists, setup instructions, command examples, and version compatibility information - update when commands change or new features add
Files:
README.md
ralph_loop.sh
📄 CodeRabbit inference engine (CLAUDE.md)
Ralph loop context injection via build_loop_context() must include: loop number, remaining tasks from @fix_plan.md, circuit breaker state, and previous work summary
Files:
ralph_loop.sh
🧠 Learnings (18)
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Implementation documentation in CLAUDE.md must remain synchronized with codebase - update when: new commands added to 'Key Commands', exit conditions change, installation instructions change, new Ralph loop behaviors introduced
Applied to files:
tests/integration/test_prd_import.batsinstall.cmdinstall.shcreate_files.shralph_import.shCLAUDE.mdinstall.ps1ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to setup.sh|install.sh|create_files.sh|ralph_import.sh : All Ralph bash scripts must include error handling for missing dependencies (jq, git, node, tmux) with specific error messages and PATH detection warnings
Applied to files:
tests/integration/test_prd_import.batsinstall.cmdinstall.shralph_import.shCLAUDE.mdinstall.ps1README.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to tests/**/*.bats : Test files must follow naming convention: test_*.bats in tests/unit/ and tests/integration/ directories, organized by component (cli_parsing, json_parsing, session_continuity, exit_detection, etc.)
Applied to files:
tests/helpers/test_helper.bashCLAUDE.mdtest.ps1tests/unit/test_platform_utils.bats
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/date_utils.sh : Implement cross-platform date utilities in Ralph scripts - use ISO timestamp generation and epoch time calculations in dedicated date_utils.sh module
Applied to files:
tests/helpers/test_helper.bashinstall.shralph_import.shlib/platform_utils.shCLAUDE.mdralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to ralph_loop.sh|ralph_monitor.sh|setup.sh|ralph_import.sh|install.sh : All Ralph CLI flags must support both long and short forms with comprehensive error handling for invalid inputs and boundary value validation
Applied to files:
install.shralph_import.shCLAUDE.mdralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh|**/ralph_import.sh : Implement JSON field extraction from Claude Code CLI responses supporting both flat format and Claude CLI format with result, sessionId, and metadata fields
Applied to files:
create_files.shralph_import.shCLAUDE.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh : Use JSON output format detection and parsing in Ralph scripts - implement `detect_output_format()` and `parse_json_response()` functions for Claude CLI integration
Applied to files:
ralph_import.shCLAUDE.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: All new features must achieve 100% test pass rate before completion - test types required: unit tests for functions, integration tests for Ralph loop behavior, end-to-end tests for development cycles
Applied to files:
CLAUDE.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh|ralph_loop.sh : Session management functions must auto-reset on: circuit breaker open, manual interrupt (SIGINT), project completion, or manual --reset-circuit flag, with history tracking in .ralph_session_history
Applied to files:
CLAUDE.mdralph_loop.sh
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/*.{test,spec}.{js,ts,jsx,tsx,py} : All tests must pass with 100% pass rate - no exceptions
Applied to files:
CLAUDE.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/*.{test,spec}.{js,ts,jsx,tsx,py} : Complex test scenarios must include comments explaining the test strategy
Applied to files:
CLAUDE.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh : Use session management functions (store_session_id, get_last_session_id, should_resume_session) for maintaining context across Ralph loop iterations with 24-hour expiration
Applied to files:
CLAUDE.mdralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to README.md : README.md must maintain current feature lists, setup instructions, command examples, and version compatibility information - update when commands change or new features add
Applied to files:
README.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/README.md : Keep README updated with feature lists, setup instructions, command examples, and version compatibility information
Applied to files:
README.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Document breaking changes prominently in implementation documentation
Applied to files:
README.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to ralph_loop.sh : Ralph loop context injection via build_loop_context() must include: loop number, remaining tasks from fix_plan.md, circuit breaker state, and previous work summary
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/circuit_breaker.sh : Implement two-stage error filtering in circuit breaker detection - Stage 1 filters JSON field patterns, Stage 2 detects actual error contexts (Error:, Exception, Fatal, etc.)
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/circuit_breaker.sh : Circuit breaker implementation must support three states: CLOSED (normal operation), HALF_OPEN (monitoring mode), OPEN (halted) with configurable thresholds for no-progress and error detection
Applied to files:
ralph_loop.sh
🧬 Code graph analysis (4)
ralph_import.sh (2)
install.sh (1)
log(18-31)ralph_loop.sh (1)
check_claude_version(456-482)
lib/platform_utils.sh (1)
tests/helpers/mocks.bash (2)
tmux(223-223)timeout(227-227)
tests/unit/test_platform_utils.bats (1)
lib/platform_utils.sh (10)
get_platform(12-30)is_windows(34-38)is_macos(42-46)is_linux(50-54)has_tmux(62-64)get_available_multiplexer(150-158)unix_to_windows_path(193-205)has_windows_terminal(68-104)get_windows_terminal_path(108-146)get_windows_cwd(209-215)
ralph_loop.sh (1)
lib/platform_utils.sh (6)
get_available_multiplexer(150-158)is_windows(34-38)get_windows_cwd(209-215)get_git_bash_path(162-184)unix_to_windows_path(193-205)get_windows_terminal_path(108-146)
🪛 LanguageTool
CLAUDE.md
[uncategorized] ~329-~329: The operating system from Apple is written “macOS”.
Context: ...dows", or "unknown" - is_windows(), is_macos(), is_linux() - Platform detection h...
(MAC_OS)
🔇 Additional comments (35)
ralph_import.sh (2)
276-282: LGTM! Test mode optimization is well-implemented.The conditional skip of the slow npx registry check during test mode improves test performance while maintaining dependency validation in normal operation. The guard pattern
${RALPH_TEST_MODE:-}is correct.
294-303: LGTM! Test mode handling prevents external dependencies.The test mode check correctly bypasses the Claude CLI version check and disables modern CLI features during testing. This prevents test flakiness from network dependencies while maintaining full functionality in production use.
install.cmd (3)
8-16: LGTM! Git Bash detection covers standard Windows installation paths.The sequential checks for Git Bash in Program Files, Program Files (x86), and LocalAppData cover the most common installation locations for Git for Windows.
18-25: LGTM! Clear error handling for missing Git Bash dependency.The error message provides actionable guidance with both the download URL and winget command, following the coding guideline for dependency error handling with specific error messages.
27-42: LGTM! Correct execution and exit code propagation.The script correctly:
- Uses
%~dp0to reference the script's directory- Forwards all arguments with
%*- Propagates the exit code from install.sh
- Provides helpful completion message with PATH update guidance
install.ps1 (4)
4-31: LGTM! Proper PowerShell error handling and Git Bash detection.The script uses
$ErrorActionPreference = "Stop"for strict error handling and employs an idiomatic PowerShell array iteration pattern to locate Git Bash. The error message provides actionable guidance matching the CMD version.
35-42: LGTM! Proper PowerShell path handling and validation.The script correctly uses
$MyInvocation.MyCommand.Pathto locate itself,Split-Path -Parentto get the directory, andJoin-Pathfor cross-platform path construction. The validation step prevents cryptic errors.
48-67: LGTM! Correct PowerShell execution and exit code handling.The script properly:
- Uses the
&call operator to execute Git Bash- Captures and checks
$LASTEXITCODE- Provides platform-specific PATH update guidance for PowerShell
- Propagates the exit code on failure
44-46: Windows to Unix path conversion is correct.The path conversion logic properly transforms Windows paths to Git Bash Unix format. Testing confirms all standard absolute paths (e.g.,
C:\Users\test\install.sh→/c/Users/test/install.sh) convert correctly, including paths with spaces and multiple drive letters.test.ps1 (4)
4-27: LGTM! Well-structured parameter handling and help documentation.The parameter block and help message follow PowerShell best practices with clear usage examples. The default test path matches the bash test script behavior.
29-47: LGTM! Consistent Git Bash detection pattern.The Git Bash location logic matches install.ps1, maintaining consistency across Windows wrapper scripts.
49-60: LGTM! Proper test path selection and dependency management.The conditional test path logic correctly handles the Unit and Integration flags, and the bats installation check ensures dependencies are available before running tests.
62-68: LGTM! Correct test execution with proper environment setup.The script correctly:
- Converts Windows paths to Unix format for Git Bash
- Sets
RALPH_TEST_MODE=1to enable test mocking- Propagates the test exit code for CI/CD integration
The use of single quotes in the bash
-ccommand prevents PowerShell variable interpolation, ensuring$TestPathis evaluated in the bash context.README.md (2)
33-34: LGTM! Feature list updated to reflect cross-platform monitoring support.The changes clarify platform-specific monitoring options (tmux for Linux/macOS, Windows Terminal for Windows), maintaining the coding guideline to keep feature lists current.
603-603: LGTM! Monitor flag description updated for cross-platform support.The command reference now accurately describes the
--monitorflag as supporting both tmux and Windows Terminal, maintaining documentation accuracy as required by coding guidelines.install.sh (1)
64-75: LGTM! Platform-specific multiplexer detection is well-structured.The Windows Terminal detection using
WT_SESSIONenvironment variable and command availability checks is appropriate. The fallback to tmux for Linux/macOS maintains backward compatibility.CLAUDE.md (2)
9-9: LGTM! Documentation properly synchronized with Windows Terminal support.The documentation updates accurately reflect the new cross-platform features:
- Version bump and test count increase are consistent
- New
lib/platform_utils.shlibrary is documented with all its functions- Windows Terminal support section provides clear platform-specific guidance
- Integration points updated with correct package namespace
Based on learnings, documentation synchronization is critical for Ralph and these updates meet the requirements.
Also applies to: 55-59, 236-236, 292-292, 307-307, 323-342
247-247: No action needed — the package namespace is correct.The npm package
@anthropic-ai/claude-codeis the official Anthropic package name per the official quickstart and SDK documentation. The documentation update is accurate and will not cause breaking changes for users following current installation guidance.create_files.sh (1)
25-25: LGTM! Package namespace change is consistent.The Claude Code CLI package namespace is updated consistently with the documentation changes in CLAUDE.md and test mocking in test_prd_import.bats.
tests/integration/test_prd_import.bats (2)
85-96: LGTM! Mock npx prevents network dependency in tests.Creating a mock
npxcommand that handles the@anthropic-ai/claude-codepackage prevents slow npm registry calls during test execution and ensures tests are deterministic and isolated from network conditions.
102-104: LGTM! Full path usage improves Windows compatibility.Using the full path to the mock command (
$MOCK_BIN_DIR/claude) and exportingRALPH_TEST_MODE=1properly isolates the test environment and avoids PATH resolution issues on Windows platforms.tests/helpers/test_helper.bash (1)
223-228: LGTM! Windows environment detection is correct.The
is_windows_test_envfunction properly detects Git Bash, MSYS, and Cygwin environments using the standarduname -sapproach with case matching.tests/unit/test_platform_utils.bats (3)
1-24: LGTM: Test file setup follows conventions.The test file correctly follows the naming convention (
test_*.batsintests/unit/) and includes proper setup/teardown with temporary directory management. The sourcing ofplatform_utils.shvia relative path is appropriate. Based on learnings, this aligns with the test organization requirements.
106-132: LGTM: Multiplexer detection tests handle platform variations correctly.The tests appropriately check the actual system state before asserting and use
skipwhen prerequisites aren't met. The preference test for tmux correctly verifies the priority logic inget_available_multiplexer.
138-171: LGTM: Path conversion tests provide good edge case coverage.The tests cover lowercase drives, uppercase drives, non-Windows Unix paths, and relative paths. The expected outputs match the implementation in
unix_to_windows_path.ralph_loop.sh (5)
13-13: LGTM: Platform utils integration.The sourcing of
platform_utils.shis correctly placed alongside other library components.
84-114: LGTM: Platform-aware monitor availability check.The function provides clear, platform-specific error messages with installation instructions. The fallthrough to
exit 1ensures the script doesn't continue without a valid multiplexer.
237-254: LGTM: Clean dispatcher pattern for monitor setup.The function correctly routes to the appropriate setup based on the detected multiplexer. The fallback case on lines 249-252 provides defensive coverage even though
check_monitor_availableexits before returning "none".
299-299: LGTM: Status output to stderr aligns with CLI conventions.Redirecting status messages to stderr keeps stdout available for program output and follows Unix CLI best practices.
1430-1433: LGTM: Monitor setup correctly dispatches to platform-appropriate handler.The change from directly calling
setup_tmux_sessionto usingsetup_monitor_sessionenables cross-platform support while maintaining backward compatibility for tmux users.lib/platform_utils.sh (5)
1-30: LGTM: Platform detection implementation is solid.The
get_platformfunction correctly handles common OS types including multiple Windows environments (MINGW, MSYS, CYGWIN, Windows_NT). Usinguname -sis the standard approach for cross-platform detection.
148-158: LGTM: Multiplexer selection logic is correct.The priority order (tmux → windows_terminal → none) makes sense. tmux is preferred even on Windows since it may be available via WSL or Git Bash installations with tmux.
160-184: LGTM: Git Bash path detection covers common installations.The function checks standard Git for Windows installation paths. While it may miss non-standard installations (e.g., Scoop, Chocolatey with custom paths), it covers the majority of use cases.
193-205: LGTM: Path conversion handles edge cases correctly.The regex correctly matches Unix-style Windows paths (
/c/...) and the${drive^^}uppercase conversion is appropriate for Bash 4.0+ environments (standard on modern systems). The logic correctly passes through paths that don't match the pattern.
217-228: LGTM: Function exports enable subshell availability.Using
export -fmakes these utility functions available in subshells and subprocesses, which is useful for complex script orchestration. This is appropriate given that the functions may be called from spawned processes in the multiplexer setup.
Refactored install.sh and ralph_loop.sh to use platform_utils.sh for better cross-platform compatibility, including dynamic Git Bash path detection and safer command construction. Updated test helper scripts and integration/unit tests to mock platform utilities and reflect new test counts (310 tests across 12 files) in README. Enhanced Windows CMD wrapper creation and improved shell-injection safety in tmux and Windows Terminal session setup.
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In @ralph_loop.sh:
- Line 1377: Remove the redundant "source \"$SCRIPT_DIR/lib/platform_utils.sh\""
calls from the --reset-circuit and --circuit-status flag handler blocks; locate
the handler code that references the flags (e.g., the functions or case branches
handling "--reset-circuit" and "--circuit-status") and delete those two source
lines so the script relies on the single initial sourcing at the top where
SCRIPT_DIR/lib/platform_utils.sh is already sourced.
- Around line 136-153: The code incorrectly uses printf '%q' to escape values
before adding them to ralph_cmd_parts, which double-escapes and breaks paths;
remove printf '%q' and push raw values into ralph_cmd_parts (e.g., use
"$ralph_home/ralph_loop.sh" and "$PROMPT_FILE" directly), and when sending to
tmux use proper array expansion rather than a pre-escaped string (use
"${ralph_cmd_parts[@]}" or pass the array elements to tmux send-keys instead of
the joined ralph_cmd variable) so ralph_cmd_parts, ralph_cmd, and tmux send-keys
handle quoting correctly.
In @README.md:
- Line 6: Update the README's test breakdown to reflect the correct counts:
replace every occurrence of "170 unit" and "140 integration" (including the
references noted at lines 21 and 656-658) with "187 unit" and "123 integration"
so all test split references show 187 unit tests and 123 integration tests;
search the README for any other mentions of the unit/integration split and
update them to the correct numbers.
🧹 Nitpick comments (4)
install.sh (1)
162-192: Consider improving Git Bash path detection fallback.The Windows CMD wrapper creation correctly uses
get_git_bash_path()with fallback, but the hardcoded fallback path at line 172 ("/c/Program Files/Git/bin/bash.exe") might not cover all Git for Windows installations (e.g., user-specific installations, custom install paths, or portable Git).Consider adding a more informative error message if Git Bash is not found, guiding users to install Git for Windows or manually configure the path.
💡 Suggested improvement
if [[ -z "$git_bash_unix_path" ]]; then - log "WARN" "Git Bash not found at standard locations. CMD wrappers will use default path." - git_bash_unix_path="/c/Program Files/Git/bin/bash.exe" + log "ERROR" "Git Bash not found at standard locations." + log "INFO" "Please install Git for Windows from https://git-scm.com/download/win" + log "INFO" "Skipping Windows CMD wrapper creation. Use Git Bash directly or install Git for Windows." + return 0 fiAlternatively, if you want to keep the fallback:
if [[ -z "$git_bash_unix_path" ]]; then - log "WARN" "Git Bash not found at standard locations. CMD wrappers will use default path." + log "WARN" "Git Bash not found. Using default path. If wrappers fail, install Git for Windows from https://git-scm.com/download/win" git_bash_unix_path="/c/Program Files/Git/bin/bash.exe" fitests/helpers/test_helper.bash (1)
237-254: Add error handling for xargs detection.The wrapper setup doesn't verify that
xargswas found before creating the wrapper script. Ifcommand -v xargsfails,_REAL_XARGSwill be empty, resulting in a broken wrapper.♻️ Proposed fix to add error handling
if is_windows_test_env; then # Create wrapper directory in temp _XARGS_WRAPPER_DIR="${BATS_TEST_TMPDIR:-/tmp}/xargs_wrapper_$$" mkdir -p "$_XARGS_WRAPPER_DIR" # Find real xargs _REAL_XARGS=$(command -v xargs) + + # Only create wrapper if xargs was found + if [[ -z "$_REAL_XARGS" ]]; then + echo "Warning: xargs not found, skipping wrapper creation" >&2 + else + # Create wrapper script - escape variables for runtime expansion + cat > "$_XARGS_WRAPPER_DIR/xargs" << WRAPPER_EOF +#!/bin/bash +exec env -i PATH="\$PATH" HOME="\$HOME" TERM="\$TERM" "$_REAL_XARGS" "\$@" +WRAPPER_EOF + chmod +x "$_XARGS_WRAPPER_DIR/xargs" - # Create wrapper script - escape variables for runtime expansion - cat > "$_XARGS_WRAPPER_DIR/xargs" << WRAPPER_EOF -#!/bin/bash -exec env -i PATH="\$PATH" HOME="\$HOME" TERM="\$TERM" "$_REAL_XARGS" "\$@" -WRAPPER_EOF - chmod +x "$_XARGS_WRAPPER_DIR/xargs" - - # Prepend to PATH so our wrapper is found first - export PATH="$_XARGS_WRAPPER_DIR:$PATH" + # Prepend to PATH so our wrapper is found first + export PATH="$_XARGS_WRAPPER_DIR:$PATH" + fi fitests/unit/test_platform_utils.bats (2)
10-17: Consider verifying platform_utils.sh exists before sourcing.If
platform_utils.shis missing or has syntax errors, thesourcecommand will fail and cause all tests to fail with unclear error messages.♻️ Proposed improvement
setup() { # Create temporary test directory TEST_DIR="$(mktemp -d)" cd "$TEST_DIR" + # Verify platform utils exists + if [[ ! -f "$PLATFORM_UTILS" ]]; then + fail "platform_utils.sh not found at $PLATFORM_UTILS" + fi + # Source the platform utils source "$PLATFORM_UTILS" }
212-223: Consider clarifying the assertion logic.Line 219's logic
[[ -z "$output" ]] || assert_failureis technically correct but can be confusing. It accepts either empty output or failure status, which matches the intent but isn't immediately obvious.♻️ Alternative for clarity
if [[ "$platform" != "windows" ]]; then run get_windows_terminal_path - # Should fail or return empty - [[ -z "$output" ]] || assert_failure + # Should return empty on non-Windows systems + assert_success + [[ -z "$output" ]] else skip "Running on Windows - test not applicable" fiOr if you want to accept either empty or failure:
if [[ "$platform" != "windows" ]]; then run get_windows_terminal_path - # Should fail or return empty - [[ -z "$output" ]] || assert_failure + # Should either fail or return empty on non-Windows + if [ "$status" -eq 0 ]; then + [[ -z "$output" ]] + fi else skip "Running on Windows - test not applicable" fi
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.claude/settings.local.jsonREADME.mdinstall.shralph_loop.shtests/helpers/test_helper.bashtests/integration/test_installation.batstests/unit/test_platform_utils.bats
🧰 Additional context used
📓 Path-based instructions (4)
tests/**/*.bats
📄 CodeRabbit inference engine (CLAUDE.md)
Test files must follow naming convention: test_*.bats in tests/unit/ and tests/integration/ directories, organized by component (cli_parsing, json_parsing, session_continuity, exit_detection, etc.)
Files:
tests/integration/test_installation.batstests/unit/test_platform_utils.bats
README.md
📄 CodeRabbit inference engine (CLAUDE.md)
README.md must maintain current feature lists, setup instructions, command examples, and version compatibility information - update when commands change or new features add
Files:
README.md
**/*.sh
📄 CodeRabbit inference engine (CLAUDE.md)
All bash scripts in Ralph must use array-based command building for CLI arguments to maintain shell injection safety
Files:
install.shralph_loop.sh
ralph_loop.sh
📄 CodeRabbit inference engine (CLAUDE.md)
Ralph loop context injection via build_loop_context() must include: loop number, remaining tasks from @fix_plan.md, circuit breaker state, and previous work summary
Files:
ralph_loop.sh
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/date_utils.sh : Implement cross-platform date utilities in Ralph scripts - use ISO timestamp generation and epoch time calculations in dedicated date_utils.sh module
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/date_utils.sh : Implement cross-platform date utilities in Ralph scripts - use ISO timestamp generation and epoch time calculations in dedicated date_utils.sh module
Applied to files:
tests/integration/test_installation.batsinstall.shralph_loop.shtests/helpers/test_helper.bash
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to README.md : README.md must maintain current feature lists, setup instructions, command examples, and version compatibility information - update when commands change or new features add
Applied to files:
README.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/AGENT.md : Update AGENT.md with new build patterns, Key Learnings section, command examples, and testing patterns
Applied to files:
README.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Implementation documentation in CLAUDE.md must remain synchronized with codebase - update when: new commands added to 'Key Commands', exit conditions change, installation instructions change, new Ralph loop behaviors introduced
Applied to files:
README.mdinstall.shralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: All new features must achieve 100% test pass rate before completion - test types required: unit tests for functions, integration tests for Ralph loop behavior, end-to-end tests for development cycles
Applied to files:
README.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to setup.sh|install.sh|create_files.sh|ralph_import.sh : All Ralph bash scripts must include error handling for missing dependencies (jq, git, node, tmux) with specific error messages and PATH detection warnings
Applied to files:
README.mdinstall.shralph_loop.shtests/helpers/test_helper.bash
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to tests/**/*.bats : Test files must follow naming convention: test_*.bats in tests/unit/ and tests/integration/ directories, organized by component (cli_parsing, json_parsing, session_continuity, exit_detection, etc.)
Applied to files:
README.mdtests/unit/test_platform_utils.batstests/helpers/test_helper.bash
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/*.{integration,e2e}.{test,spec}.{js,ts,jsx,tsx,py} : Write integration tests for API endpoints or main functionality
Applied to files:
README.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/*.{test,spec}.{js,ts,jsx,tsx,py} : All tests must pass with 100% pass rate - no exceptions
Applied to files:
README.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/*.{e2e,end-to-end}.{test,spec}.{js,ts,jsx,tsx,py} : Write end-to-end tests for critical user workflows
Applied to files:
README.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/*.{js,ts,jsx,tsx,py,rs} : Write unit tests for all business logic and services
Applied to files:
README.md
📚 Learning: 2025-12-31T19:31:02.350Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: templates/AGENT.md:0-0
Timestamp: 2025-12-31T19:31:02.350Z
Learning: Applies to templates/**/*.{test,spec}.{js,ts,jsx,tsx,py} : Complex test scenarios must include comments explaining the test strategy
Applied to files:
README.md
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh|ralph_loop.sh : Session management functions must auto-reset on: circuit breaker open, manual interrupt (SIGINT), project completion, or manual --reset-circuit flag, with history tracking in .ralph_session_history
Applied to files:
README.mdralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to ralph_loop.sh|ralph_monitor.sh|setup.sh|ralph_import.sh|install.sh : All Ralph CLI flags must support both long and short forms with comprehensive error handling for invalid inputs and boundary value validation
Applied to files:
install.shralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to ralph_loop.sh : Ralph loop context injection via build_loop_context() must include: loop number, remaining tasks from fix_plan.md, circuit breaker state, and previous work summary
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh : Use session management functions (store_session_id, get_last_session_id, should_resume_session) for maintaining context across Ralph loop iterations with 24-hour expiration
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/*.sh : All bash scripts in Ralph must use array-based command building for CLI arguments to maintain shell injection safety
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/circuit_breaker.sh : Implement two-stage error filtering in circuit breaker detection - Stage 1 filters JSON field patterns, Stage 2 detects actual error contexts (Error:, Exception, Fatal, etc.)
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/circuit_breaker.sh : Circuit breaker implementation must support three states: CLOSED (normal operation), HALF_OPEN (monitoring mode), OPEN (halted) with configurable thresholds for no-progress and error detection
Applied to files:
ralph_loop.sh
🧬 Code graph analysis (3)
install.sh (2)
lib/platform_utils.sh (4)
is_windows(34-38)has_windows_terminal(68-104)get_git_bash_path(162-184)unix_to_windows_path(193-205)ralph_import.sh (1)
log(40-53)
ralph_loop.sh (1)
lib/platform_utils.sh (6)
get_available_multiplexer(150-158)is_windows(34-38)get_windows_cwd(209-215)get_git_bash_path(162-184)unix_to_windows_path(193-205)get_windows_terminal_path(108-146)
tests/unit/test_platform_utils.bats (3)
lib/platform_utils.sh (10)
get_platform(12-30)is_windows(34-38)is_macos(42-46)is_linux(50-54)has_tmux(62-64)get_available_multiplexer(150-158)unix_to_windows_path(193-205)has_windows_terminal(68-104)get_windows_terminal_path(108-146)get_windows_cwd(209-215)tests/helpers/test_helper.bash (2)
assert_success(10-16)assert_failure(18-24)tests/helpers/mocks.bash (1)
tmux(223-223)
🔇 Additional comments (16)
.claude/settings.local.json (1)
21-23: LGTM! GitHub CLI permissions added appropriately.The new permissions for
gh pr viewandgh apienable GitHub integration while maintaining security by using the wildcard pattern consistent with other Bash permissions.install.sh (2)
11-12: LGTM! Platform utilities sourced correctly.Sourcing
lib/platform_utils.shearly in the script enables cross-platform support for the installation process.
66-78: Cross-platform multiplexer detection implemented correctly.The conditional logic properly differentiates between Windows (checking for Windows Terminal) and Linux/macOS (checking for tmux), with appropriate warning messages for each platform.
README.md (1)
419-491: LGTM! Windows Terminal documentation added comprehensively.The documentation now properly covers both tmux (Linux/macOS) and Windows Terminal (Windows) for integrated monitoring, with clear installation instructions for each platform.
ralph_loop.sh (3)
84-114: LGTM! Cross-platform monitor detection implemented correctly.The function properly delegates to
get_available_multiplexer()from platform_utils.sh and provides platform-specific error messages and installation guidance for missing multiplexers.
243-260: LGTM! Monitor session dispatcher implemented correctly.The function properly delegates to the appropriate setup function based on the detected multiplexer, with good error handling for unsupported cases.
305-305: LGTM! log_status correctly outputs to stderr.Redirecting log messages to stderr (>&2) is the correct approach, ensuring logs don't interfere with stdout-based data processing or piping.
tests/integration/test_installation.bats (1)
54-67: LGTM! Comprehensive platform_utils.sh mock added.The mock properly implements all platform utility functions needed for installation testing, simulating a Linux environment without Windows Terminal. This ensures tests run consistently regardless of the actual host platform.
tests/helpers/test_helper.bash (3)
5-8: LGTM!The
fail()helper provides a clean, consistent way to report test failures. The implementation is simple and correct.
10-16: Good debugging enhancement.Adding the output display when assertions fail improves the test debugging experience significantly.
228-233: LGTM!The Windows environment detection correctly identifies Git Bash, MSYS, and Cygwin environments using the same pattern as
lib/platform_utils.sh.tests/unit/test_platform_utils.bats (5)
30-100: LGTM!The platform detection tests provide comprehensive coverage. While the test logic in lines 43-56 duplicates the implementation, this is acceptable for validation tests that verify the detection logic works correctly across different platforms.
106-132: LGTM!The multiplexer detection tests correctly handle environment variations using conditional logic and the
skipdirective. The tests verify both availability detection and preference ordering.
138-171: LGTM!Excellent coverage of path conversion edge cases, including different drive letters, uppercase handling, and non-Windows path formats.
177-194: LGTM!The function export tests verify the public API surface is available after sourcing, which is essential for ensuring the module can be used by other scripts.
229-256: LGTM!The integration tests verify cross-platform behavior correctly, with proper directory restoration and platform-specific path format validation. The drive letter check on line 252 correctly identifies Windows path format.
CodeRabbit is suggesting changes that deviate from the project author's style and decisions, so I think if I keep responding it will create a doom loop; Windows side fixes only
Added cleanup for the xargs wrapper directory in test_helper.bash to enhance Windows compatibility. Updated test_platform_utils.bats to use pushd/popd for safer directory changes during Windows-specific tests.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
ralph_loop.sh (1)
1431-1435: Monitor mode dispatch updated to use cross-platform session setup.The main execution block now calls
setup_monitor_sessioninstead of directly callingsetup_tmux_session, enabling automatic selection of the appropriate terminal multiplexer based on platform detection.Note: The variable name
USE_TMUXis now slightly misleading since it enables either tmux or Windows Terminal. Consider renaming toUSE_MONITORfor clarity in a future refactor.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
README.mdralph_loop.shtests/helpers/test_helper.bashtests/unit/test_platform_utils.bats
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
🧰 Additional context used
📓 Path-based instructions (3)
tests/**/*.bats
📄 CodeRabbit inference engine (CLAUDE.md)
Test files must follow naming convention: test_*.bats in tests/unit/ and tests/integration/ directories, organized by component (cli_parsing, json_parsing, session_continuity, exit_detection, etc.)
Files:
tests/unit/test_platform_utils.bats
**/*.sh
📄 CodeRabbit inference engine (CLAUDE.md)
All bash scripts in Ralph must use array-based command building for CLI arguments to maintain shell injection safety
Files:
ralph_loop.sh
ralph_loop.sh
📄 CodeRabbit inference engine (CLAUDE.md)
Ralph loop context injection via build_loop_context() must include: loop number, remaining tasks from @fix_plan.md, circuit breaker state, and previous work summary
Files:
ralph_loop.sh
🧠 Learnings (9)
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to setup.sh|install.sh|create_files.sh|ralph_import.sh : All Ralph bash scripts must include error handling for missing dependencies (jq, git, node, tmux) with specific error messages and PATH detection warnings
Applied to files:
tests/helpers/test_helper.bashralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/date_utils.sh : Implement cross-platform date utilities in Ralph scripts - use ISO timestamp generation and epoch time calculations in dedicated date_utils.sh module
Applied to files:
tests/helpers/test_helper.bashralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to tests/**/*.bats : Test files must follow naming convention: test_*.bats in tests/unit/ and tests/integration/ directories, organized by component (cli_parsing, json_parsing, session_continuity, exit_detection, etc.)
Applied to files:
tests/helpers/test_helper.bashtests/unit/test_platform_utils.bats
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to ralph_loop.sh|ralph_monitor.sh|setup.sh|ralph_import.sh|install.sh : All Ralph CLI flags must support both long and short forms with comprehensive error handling for invalid inputs and boundary value validation
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to ralph_loop.sh : Ralph loop context injection via build_loop_context() must include: loop number, remaining tasks from fix_plan.md, circuit breaker state, and previous work summary
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh|ralph_loop.sh : Session management functions must auto-reset on: circuit breaker open, manual interrupt (SIGINT), project completion, or manual --reset-circuit flag, with history tracking in .ralph_session_history
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Implementation documentation in CLAUDE.md must remain synchronized with codebase - update when: new commands added to 'Key Commands', exit conditions change, installation instructions change, new Ralph loop behaviors introduced
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/response_analyzer.sh : Use session management functions (store_session_id, get_last_session_id, should_resume_session) for maintaining context across Ralph loop iterations with 24-hour expiration
Applied to files:
ralph_loop.sh
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/*.sh : All bash scripts in Ralph must use array-based command building for CLI arguments to maintain shell injection safety
Applied to files:
ralph_loop.sh
🧬 Code graph analysis (2)
tests/unit/test_platform_utils.bats (3)
lib/platform_utils.sh (10)
get_platform(12-30)is_windows(34-38)is_macos(42-46)is_linux(50-54)has_tmux(62-64)get_available_multiplexer(150-158)unix_to_windows_path(193-205)has_windows_terminal(68-104)get_windows_terminal_path(108-146)get_windows_cwd(209-215)tests/helpers/test_helper.bash (2)
assert_success(10-16)assert_failure(18-24)tests/helpers/mocks.bash (1)
tmux(223-223)
ralph_loop.sh (1)
lib/platform_utils.sh (6)
get_available_multiplexer(150-158)is_windows(34-38)get_windows_cwd(209-215)get_git_bash_path(162-184)unix_to_windows_path(193-205)get_windows_terminal_path(108-146)
🔇 Additional comments (16)
tests/helpers/test_helper.bash (3)
5-8: LGTM! Simple and effectivefail()helper.This is a standard BATS-style assertion helper that provides a clean way to fail tests with a message. The implementation is correct.
76-80: LGTM! Proper cleanup of Windows xargs wrapper directory.The teardown correctly checks for the wrapper directory existence before attempting removal, preventing errors on non-Windows systems where the variable won't be set.
227-259: Windows xargs wrapper initialization runs at source-time, not per-test.The xargs wrapper setup at lines 242-258 runs when this file is sourced, which happens once per test file. This is intentional (and efficient), but note:
- The
_XARGS_WRAPPER_DIRuses$$for uniqueness, which is correct for process isolation.- The wrapper script correctly uses escaped
\$for runtime variable expansion.- The
env -iapproach effectively clears the oversized environment that causes xargs failures on Windows.One minor observation: the cleanup in
teardown()will only remove the directory after each test, but the directory is created once at source-time. This works correctly because BATS runs each test in a subshell, so the directory persists across tests in the same file (which is desired).tests/unit/test_platform_utils.bats (7)
1-24: LGTM! Test file structure and setup/teardown are correct.The test file follows the naming convention (
test_*.batsintests/unit/), properly loads the test helper, sources the platform utilities, and has clean setup/teardown with proper directory handling. As per coding guidelines, this follows the required naming convention.
30-61: LGTM! Platform detection tests are well-designed.The tests correctly verify
get_platformreturns valid values and matches the current OS. The case statement mirrors the implementation logic, which ensures consistency.
106-132: LGTM! Multiplexer detection tests handle optional dependencies correctly.The tests properly check for tmux availability before asserting success, and use
skipwhen tmux isn't installed. This prevents false failures in CI environments without tmux.
138-171: LGTM! Path conversion tests cover key scenarios.The tests verify:
- Lowercase drive letter conversion (
/c/→C:\)- Different drive letters (
/d/→D:\)- Uppercase drive letters (
/C/→C:\)- Non-Windows paths remain unchanged
- Relative paths remain unchanged
These cover the main use cases for the
unix_to_windows_pathfunction.
200-223: LGTM! Windows Terminal tests correctly skip on Windows.The tests for
has_windows_terminalandget_windows_terminal_pathappropriately skip when running on Windows (where the behavior would depend on actual Windows Terminal installation) and verify expected failure behavior on non-Windows systems.
237-253: Test uses pushd/popd for directory isolation—good practice.The test at lines 242-245 correctly uses
pushd/popdto isolate directory changes, which aligns with the commit message mentioning "safer pushd/popd usage in Windows-specific tests." The error handling with|| return 1ensures test failure ifpushdfails.
89-100: No typo found inis_linux()implementation.The actual code in
lib/platform_utils.shuses the correct variable name$platform, not the claimed typo$plattform. The implementation is correct:is_linux() { local platform platform=$(get_platform) [[ "$platform" == "linux" ]] }The test at lines 89-100 is also correct and will function as intended.
Likely an incorrect or invalid review comment.
ralph_loop.sh (6)
13-13: LGTM! Platform utilities sourced for cross-platform support.The addition of
source "$SCRIPT_DIR/lib/platform_utils.sh"enables the new Windows Terminal monitoring functionality by providing platform detection and path conversion utilities.
84-114: LGTM! Platform-aware monitor availability check with helpful error messages.The
check_monitor_available()function:
- Uses
get_available_multiplexer()from platform_utils.sh for detection- Provides platform-specific installation instructions (Windows Terminal for Windows, tmux for others)
- Returns the multiplexer type on stdout for the caller to use
The error messages are helpful and actionable.
169-239: Windows Terminal session setup uses array-based command building correctly.The implementation follows the coding guideline requiring array-based command building for CLI arguments (lines 190-214). Key observations:
- Array usage: Commands are built using
local -a ralph_cmd_parts=()andlocal -a monitor_cmd_parts=()✓- Conversion for wt.exe: The array is converted to string at line 205 (
local ralph_cmd="${ralph_cmd_parts[*]}") because Windows Terminal's-cflag requires a single command string. This is a reasonable compromise for cross-platform compatibility.- Fallback handling: Lines 220-231 handle the case where
wt_exepath isn't found by falling back tocmd.exe /c "wt ...".One potential issue: the command string passed to Windows Terminal's
-cflag (line 223, 230) contains nested quotes that may cause issues with certain paths containing spaces. However, this is a known complexity with Windows command-line parsing.
241-258: LGTM! Clean dispatcher pattern for monitor session setup.The
setup_monitor_session()function provides a simple switch betweensetup_tmux_sessionandsetup_windows_terminal_sessionbased on the detected multiplexer. The fallback error case (lines 253-256) is defensive, though it should never be reached sincecheck_monitor_availablewould have already exited on error.
303-303: Redirecting log_status to STDERR is correct for logging.Sending log output to STDERR (
>&2) ensures logs don't interfere with stdout-based data flow (e.g., function return values captured via command substitution). This is a best practice for CLI tools.
1290-1290: Help text updated to reflect cross-platform monitoring.The help text now correctly indicates that
--monitorworks with both tmux and Windows Terminal, aligning with the implementation changes.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In @lib/platform_utils.sh:
- Around line 96-100: The if-statement in lib/platform_utils.sh builds and runs
the timeout+cmd.exe command as a single string which violates the array-based
command-building guideline; change it to construct the command as an array
(separate elements for "timeout", "2s", "cmd.exe", "/c", and "where wt" split
into its program and args), execute it via "${cmd[@]}" with the same redirection
to /dev/null, and keep the existing success path (return 0) unchanged so the
behavior is identical but safe from shell-injection.
- Around line 96-100: The fallback that runs 'timeout 2s cmd.exe /c "where wt"'
can fail on minimal Windows Git Bash because 'timeout' may be absent; update the
code to first test availability with 'command -v timeout >/dev/null' (or
equivalent) before invoking the timed call, and if 'timeout' is missing either
skip the timed cmd.exe branch or use a Windows-native alternative (e.g., a
PowerShell Start-Process/Wait wrapper) so the last-resort detection still works;
adjust both occurrences (the 'timeout 2s cmd.exe /c "where wt"' check and the
similar call at line 137) to use this availability check and a safe fallback
path.
- Around line 135-141: The snippet in lib/platform_utils.sh builds and runs a
shell command as a single string which breaks the guideline to use array-based
command building; change the invocation that sets wt_path to build the command
as an array (e.g., cmd=(timeout 2s cmd.exe /c where wt)), run it with
"${cmd[@]}" and capture its stdout/stderr (2>/dev/null), then pipe to head and
tr as before; update the reference that assigns wt_path to use the array
execution so wt_path=$( ... ) uses the array-based command instead of a quoted
single-string command.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/platform_utils.sh
🧰 Additional context used
📓 Path-based instructions (1)
**/*.sh
📄 CodeRabbit inference engine (CLAUDE.md)
All bash scripts in Ralph must use array-based command building for CLI arguments to maintain shell injection safety
Files:
lib/platform_utils.sh
🧠 Learnings (1)
📚 Learning: 2026-01-10T20:20:22.133Z
Learnt from: CR
Repo: frankbria/ralph-claude-code PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T20:20:22.133Z
Learning: Applies to **/date_utils.sh : Implement cross-platform date utilities in Ralph scripts - use ISO timestamp generation and epoch time calculations in dedicated date_utils.sh module
Applied to files:
lib/platform_utils.sh
🔇 Additional comments (3)
lib/platform_utils.sh (3)
12-54: LGTM! Platform detection is thorough.The platform detection logic correctly handles Linux, macOS, and Windows variants (MINGW, MSYS, CYGWIN, Windows_NT). The boolean helper functions provide clean abstractions for platform checks.
62-64: LGTM! Multiplexer detection follows best practices.The use of
command -vfor feature detection and the priority ordering inget_available_multiplexer()(tmux first, then Windows Terminal) is appropriate.Also applies to: 150-158
196-200: No action needed—bash 4.0+ is an officially documented project requirement.Line 200's
${drive^^}syntax correctly requires bash 4.0+, which is already listed as a prerequisite in CONTRIBUTING.md. The codebase does not need to provide portable alternatives since Ralph explicitly requires bash 4.0+.
Replaces inline command invocation with local array variables for cmd.exe calls in has_windows_terminal and get_windows_terminal_path. This improves readability and consistency in command execution.
|
Thank you @danielcrenna for this comprehensive Windows support implementation! 🙏 We're closing this PR for now because we want to do a more thorough architectural assessment before adding platform-specific code of this scope. The concerns include:
We've created issue #156 to track Windows support as a feature request. Your implementation will be valuable reference material when we're ready to tackle this. We appreciate your contribution and hope you'll engage with us on the architectural discussion in the issue! |

For the Windows crowd, this adds support for split-terminal sessions via Windows Terminal, and adds wrappers for
ralphcommands, so that they can be run in PowerShell or CMD without requiring WSL2. Also adds Windows wrappers forinstall, running unit tests, and fixes issues running tests in Windows due to environment export size.Also fixed a few places that use incorrect Claude package names, which were breaking tests on Windows when
npmis slow to install, but likely have been broken for awhile.I also mocked npx calls in
test_prd_imports.batsince network connectivity issues should not impact mocked services.Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.