diff --git a/Services/ClaudeCliService.cs b/Services/ClaudeCliService.cs index 5368086..d6f4bdc 100644 --- a/Services/ClaudeCliService.cs +++ b/Services/ClaudeCliService.cs @@ -56,7 +56,7 @@ public class ClaudeCliService return dir; } - private ProcessStartInfo CreateCliStartInfo(List args, bool redirectInput = false, string effort = null) + private ProcessStartInfo CreateCliStartInfo(List args, bool redirectInput = false, string effort = null, string workingDirectory = null) { var psi = new ProcessStartInfo { @@ -70,6 +70,14 @@ public class ClaudeCliService StandardErrorEncoding = Encoding.UTF8 }; + // Arbeitsverzeichnis explizit auf den Workspace setzen. + // Ohne das erbt der CLI-Child das CWD des gott-Servers (unter Windows das + // Dienst-/Installationsverzeichnis), wodurch RELATIVE Tool-Pfade wie + // Glob "Sources/**" ins Leere laufen ("No files found"), während absolute + // Pfade funktionieren. --add-dir erteilt nur Zugriff, setzt aber NICHT das CWD. + if (!string.IsNullOrEmpty(workingDirectory) && Directory.Exists(workingDirectory)) + psi.WorkingDirectory = workingDirectory; + // 1h-Prompt-Cache-TTL für Claude CLI aktivieren (seit CLI 2.1.108). // Anthropic hat Anfang März 2026 den Default von 1h auf 5min gesenkt, // dieser Flag holt die 1h-TTL zurück (gilt für API-Key, Bedrock, Vertex, Foundry). @@ -229,7 +237,7 @@ public class ClaudeCliService args.Add(mcpConfigPath); } - return await RunCliStreamingAsync(args, prompt, onEvent, cancellationToken, effort); + return await RunCliStreamingAsync(args, prompt, onEvent, cancellationToken, effort, workspace); } private async Task RunCliStreamingAsync( @@ -237,7 +245,8 @@ public class ClaudeCliService string stdinPrompt, Func onEvent, CancellationToken cancellationToken, - string effort = null) + string effort = null, + string workspace = null) { var result = new CliChatResult(); var fullOutput = new StringBuilder(); @@ -257,7 +266,7 @@ public class ClaudeCliService try { - var startInfo = CreateCliStartInfo(args, redirectInput: true, effort: effort); + var startInfo = CreateCliStartInfo(args, redirectInput: true, effort: effort, workingDirectory: workspace); using var process = new Process { StartInfo = startInfo };