fix(agents): resolve explicit command paths during detection#302
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
WalkthroughAdded tests for the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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/wherefallback still receives the raw, un-normalised commandWhen the command is not path-like, the fallback on line 58 passes the original
command(potentially still padded with whitespace or wrapped in quotes) tospawn(whichCmd, [command]). For example,'"node"'is not path-like, so it falls through — butwhere "node"/which "node"will fail.Use
normalizedCommand(or at leasttrimmedCommand) 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:accessSyncchecks existence, not executability
accessSync(normalizedCommand)defaults tofs.constants.F_OK(file visible), so a path-like command that exists but lacks the execute bit will be reported asfound: trueeven though it cannot actually run. Consider passingfs.constants.X_OKon 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 pathsThe 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 likefindCommandPath('"' + commandPath + '"')would confirm the unquoting logic works correctly and guard against regressions.
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
Bug Fixes