Skip to content

fix(agents): resolve explicit command paths during detection#302

Merged
subsy merged 1 commit intomainfrom
fix/issue-301-findcommandpath
Feb 14, 2026
Merged

fix(agents): resolve explicit command paths during detection#302
subsy merged 1 commit intomainfrom
fix/issue-301-findcommandpath

Conversation

@subsy
Copy link
Copy Markdown
Owner

@subsy subsy commented Feb 14, 2026

Fixes issue #301 (Windows path resolution in agent detection).\n\nWhen detect uses a configured full path (e.g. C:\Users...\claude.exe), we now resolve it directly via filesystem check instead of shelling out to where/which.\n\nIncludes regression coverage in base agent tests for path-like commands.

Summary by CodeRabbit

Release Notes

  • Tests

    • Added comprehensive test coverage for command path resolution, validating absolute paths and non-existent path scenarios.
  • Bug Fixes

    • Enhanced command path resolution to pre-validate explicit executable paths before subprocess execution, improving reliability and performance for direct path references.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 14, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ralph-tui Ignored Ignored Feb 14, 2026 8:07am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 14, 2026

Walkthrough

Added tests for the findCommandPath function to validate resolving absolute paths and handling non-existent paths. Enhanced findCommandPath to pre-check for path-like commands by trimming, unquoting, and verifying accessibility via accessSync before falling back to which/where lookup. Exported the function for public use.

Changes

Cohort / File(s) Summary
Test Coverage
src/plugins/agents/base.test.ts
Added test cases for findCommandPath covering explicit absolute path resolution and non-existent path handling, including filesystem utilities for temporary file operations.
Core Logic Enhancement
src/plugins/agents/base.ts
Enhanced findCommandPath function with path-like command detection by trimming/unquoting input, identifying absolute or path-separator-containing commands, and checking file accessibility via accessSync before invoking which/where fallback logic. Updated imports to include accessSync and isAbsolute.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ 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 specifically summarizes the main change: enhancing command path detection to resolve explicit paths directly before invoking which/where, addressing the Windows path resolution issue in agent detection.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-301-findcommandpath

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
Copy Markdown

codecov bot commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.51%. Comparing base (281b140) to head (f9da0a2).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/plugins/agents/base.ts 83.33% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #302      +/-   ##
==========================================
+ Coverage   44.48%   44.51%   +0.02%     
==========================================
  Files          96       96              
  Lines       30153    30175      +22     
==========================================
+ Hits        13414    13432      +18     
- Misses      16739    16743       +4     
Files with missing lines Coverage Δ
src/plugins/agents/base.ts 39.33% <83.33%> (+1.19%) ⬆️
🚀 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/plugins/agents/base.ts (1)

56-62: ⚠️ Potential issue | 🟡 Minor

which/where fallback still receives the raw, un-normalised command

When the command is not path-like, the fallback on line 58 passes the original command (potentially still padded with whitespace or wrapped in quotes) to spawn(whichCmd, [command]). For example, '"node"' is not path-like, so it falls through — but where "node" / which "node" will fail.

Use normalizedCommand (or at least trimmedCommand) here too:

Suggested fix
-    const proc = spawn(whichCmd, [command], {
+    const proc = spawn(whichCmd, [normalizedCommand], {
🧹 Nitpick comments (2)
src/plugins/agents/base.ts (1)

44-54: accessSync checks existence, not executability

accessSync(normalizedCommand) defaults to fs.constants.F_OK (file visible), so a path-like command that exists but lacks the execute bit will be reported as found: true even though it cannot actually run. Consider passing fs.constants.X_OK on non-Windows platforms to catch this early.

Suggested fix
+import { constants as fsConstants } from 'node:fs';
 ...
     if (isPathLikeCommand) {
       try {
-        accessSync(normalizedCommand);
+        accessSync(normalizedCommand, isWindows ? undefined : fsConstants.X_OK);
         return resolve({
src/plugins/agents/base.test.ts (1)

155-176: Consider adding a test for quoted command paths

The implementation strips surrounding double quotes (lines 35-37 of base.ts), which is a key part of the Windows path-resolution fix, but there is no test exercising that branch. A test like findCommandPath('"' + commandPath + '"') would confirm the unquoting logic works correctly and guard against regressions.

@subsy subsy merged commit df7bd04 into main Feb 14, 2026
9 checks passed
@subsy subsy deleted the fix/issue-301-findcommandpath branch February 14, 2026 08:28
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.

1 participant