fix(worker): resolve claude CLI shims (.cmd/.bat) not just .exe on PATH

UseShellExecute=false only appends .exe when searching PATH, so an
npm-installed claude.cmd was never found even though it works from a shell.
Adds a shared ExecutableResolver in ClaudeDo.Data (PATH/PATHEXT aware, with
known npm/claude install-dir fallbacks) and wires it into ClaudeCliPreflight
and ClaudeProcess; shims are launched via cmd.exe /c.
This commit is contained in:
mika kuns
2026-08-05 19:08:20 +02:00
parent bdee731376
commit e88f9d01e6
5 changed files with 290 additions and 13 deletions
+18 -1
View File
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Text;
using ClaudeDo.Data.Environment;
using ClaudeDo.Worker.Config;
namespace ClaudeDo.Worker.Runner;
@@ -24,9 +25,11 @@ public sealed class ClaudeProcess : IClaudeProcess
Func<string, Task> onStdoutLine,
CancellationToken ct)
{
var resolved = ExecutableResolver.Resolve(_cfg.ClaudeBin)
?? throw new InvalidOperationException($"'{_cfg.ClaudeBin}' not found on PATH.");
var psi = new ProcessStartInfo
{
FileName = _cfg.ClaudeBin,
WorkingDirectory = workingDirectory,
RedirectStandardInput = true,
RedirectStandardOutput = true,
@@ -36,6 +39,20 @@ public sealed class ClaudeProcess : IClaudeProcess
StandardOutputEncoding = Encoding.UTF8,
StandardErrorEncoding = Encoding.UTF8,
};
// A shim (.cmd/.bat) can't be launched directly with UseShellExecute=false;
// route it through cmd.exe /c so the real interpreter starts the target.
if (resolved.IsShim)
{
psi.FileName = "cmd.exe";
psi.ArgumentList.Add("/c");
psi.ArgumentList.Add(resolved.Path);
}
else
{
psi.FileName = resolved.Path;
}
foreach (var arg in arguments)
psi.ArgumentList.Add(arg);