Skip to content

fix: use conditional shell in runVersion for claude and opencode agents#187

Merged
subsy merged 4 commits intomainfrom
claude/issue-183-266wZ
Jan 22, 2026
Merged

fix: use conditional shell in runVersion for claude and opencode agents#187
subsy merged 4 commits intomainfrom
claude/issue-183-266wZ

Conversation

@subsy
Copy link
Owner

@subsy subsy commented Jan 22, 2026

Summary

  • Use conditional shell spawning (shell: process.platform === 'win32') in runVersion method for both claude.ts and opencode.ts agent plugins
  • Matches pattern already established by newer plugins (codex, gemini, kiro)
  • Eliminates unnecessary shell invocation overhead on Linux/macOS

Closes #183

Test plan

  • bun run typecheck passes
  • bun run build succeeds
  • Verify agent detection works on Linux/macOS (no shell spawned)
  • Verify agent detection works on Windows (shell spawned for wrapper scripts)

Summary by CodeRabbit

  • Bug Fixes

    • Command execution is now platform-specific: Windows runs via shell, other systems use non-shell execution for consistent cross-platform behaviour.
  • Tests

    • Added comprehensive cross-platform tests validating shell usage, command detection and version checks for the affected agent plugins.
    • Added sandbox requirement tests for one agent (auth, binary and runtime path expectations, network requirement).

✏️ Tip: You can customize this high-level summary in your review settings.

Only use shell when spawning version check on Windows. On Unix-like systems,
the command path is already resolved so shell invocation is unnecessary.

This matches the pattern already used by newer agent plugins (codex, gemini, kiro)
and reduces shell spawning overhead on Linux/macOS.
@vercel
Copy link

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Preview Jan 22, 2026 11:56am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Walkthrough

Conditional shell usage was added to Claude and OpenCode agent version checks: spawn now sets shell only on Windows (process.platform === 'win32') instead of unconditionally. Tests were added to verify platform-specific shell behaviour and Claude plugin sandbox requirement checks.

Changes

Cohort / File(s) Summary
Agent plugins — conditional shell
src/plugins/agents/builtin/claude.ts, src/plugins/agents/builtin/opencode.ts
Replace unconditional shell: true with const useShell = process.platform === 'win32' and pass shell: useShell to spawn for --version checks.
Tests — runVersion shell behaviour
tests/plugins/agents/runversion-shell.test.ts
New comprehensive tests mocking child_process.spawn to validate shell usage across platforms (Linux/macOS vs Windows), command lookup, and detection outcomes.
Tests — Claude sandbox requirements
tests/plugins/claude-agent.test.ts
New tests asserting getSandboxRequirements values for ClaudeAgentPlugin (authPaths, binaryPaths, requiresNetwork, runtimePaths).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through code on tiptoe feet,
Windows gets a shell, others keep it neat,
Tests now check each platform's rule,
Tiny tweak — the build stays cool. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: implementing conditional shell usage in runVersion for Claude and OpenCode agents, directly matching the PR objectives.
Linked Issues check ✅ Passed The pull request fully addresses all coding requirements from issue #183: conditional shell spawning is implemented in both claude.ts and opencode.ts files, aligning with the pattern used by newer plugins.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objectives. The test additions comprehensively validate the conditional shell behaviour across platforms, supporting the core implementation changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.83%. Comparing base (aa8b5d5) to head (53c3043).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
+ Coverage   44.50%   44.83%   +0.32%     
==========================================
  Files          76       76              
  Lines       22027    22029       +2     
==========================================
+ Hits         9804     9877      +73     
+ Misses      12223    12152      -71     
Files with missing lines Coverage Δ
src/plugins/agents/builtin/claude.ts 52.18% <100.00%> (+6.75%) ⬆️
src/plugins/agents/builtin/opencode.ts 73.05% <100.00%> (+7.20%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

subsy pushed a commit that referenced this pull request Jan 22, 2026
Add comprehensive tests for the runVersion method's platform-specific
shell option in claude and opencode agent plugins.

Changes:
- Apply PR #187 fix: use shell: process.platform === 'win32' instead of
  shell: true in runVersion for both claude.ts and opencode.ts
- Add new test file (runversion-shell.test.ts) that mocks spawn and
  verifies the shell option is correctly set based on platform
- Add tests for Linux, macOS (shell: false) and Windows (shell: true)
- Add tests for detect() success/failure scenarios
- Add getSandboxRequirements tests to claude-agent.test.ts

The tests achieve 100% coverage on the changed lines and >50% overall
coverage on both affected files.
Add comprehensive tests for the runVersion method's platform-specific
shell option in claude and opencode agent plugins.

Changes:
- Apply PR #187 fix: use shell: process.platform === 'win32' instead of
  shell: true in runVersion for both claude.ts and opencode.ts
- Add new test file (runversion-shell.test.ts) that mocks spawn and
  verifies the shell option is correctly set based on platform
- Add tests for Linux, macOS (shell: false) and Windows (shell: true)
- Add tests for detect() success/failure scenarios
- Add getSandboxRequirements tests to claude-agent.test.ts

The tests achieve 100% coverage on the changed lines and >50% overall
coverage on both affected files.
@subsy subsy merged commit 6c15061 into main Jan 22, 2026
9 checks passed
@subsy subsy deleted the claude/issue-183-266wZ branch January 22, 2026 12:16
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
Add comprehensive tests for the runVersion method's platform-specific
shell option in claude and opencode agent plugins.

Changes:
- Apply PR subsy#187 fix: use shell: process.platform === 'win32' instead of
  shell: true in runVersion for both claude.ts and opencode.ts
- Add new test file (runversion-shell.test.ts) that mocks spawn and
  verifies the shell option is correctly set based on platform
- Add tests for Linux, macOS (shell: false) and Windows (shell: true)
- Add tests for detect() success/failure scenarios
- Add getSandboxRequirements tests to claude-agent.test.ts

The tests achieve 100% coverage on the changed lines and >50% overall
coverage on both affected files.
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
fix: use conditional shell in runVersion for claude and opencode agents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: use conditional shell in runVersion for claude and opencode agents

2 participants

Comments