From 3962597950421e422b6e1ce57764550f5600ded6 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 3 Mar 2026 21:22:30 +0000 Subject: Fix working_dir failures: validate path early, remove hardcoded /root executor/claude.go: stat working_dir before cmd.Start() so a missing or inaccessible directory surfaces as a clear error ("working_dir \"/bad/path\": no such file or directory") rather than an opaque chdir failure wrapped in "starting claude". api/elaborate.go: replace the hardcoded /root/workspace/claudomator path with buildElaboratePrompt(workDir) which injects the server's actual working directory (from os.Getwd() at startup). Empty workDir tells the model to leave working_dir blank. Co-Authored-By: Claude Sonnet 4.6 --- internal/api/elaborate_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'internal/api/elaborate_test.go') diff --git a/internal/api/elaborate_test.go b/internal/api/elaborate_test.go index ff158a8..52f7fdf 100644 --- a/internal/api/elaborate_test.go +++ b/internal/api/elaborate_test.go @@ -8,6 +8,7 @@ import ( "net/http/httptest" "os" "path/filepath" + "strings" "testing" ) @@ -28,6 +29,23 @@ func createFakeClaude(t *testing.T, output string, exitCode int) string { return script } +func TestElaboratePrompt_ContainsWorkDir(t *testing.T) { + prompt := buildElaboratePrompt("/some/custom/path") + if !strings.Contains(prompt, "/some/custom/path") { + t.Error("prompt should contain the provided workDir") + } + if strings.Contains(prompt, "/root/workspace/claudomator") { + t.Error("prompt should not hardcode /root/workspace/claudomator") + } +} + +func TestElaboratePrompt_EmptyWorkDir(t *testing.T) { + prompt := buildElaboratePrompt("") + if strings.Contains(prompt, "/root") { + t.Error("prompt should not reference /root when workDir is empty") + } +} + func TestElaborateTask_Success(t *testing.T) { srv, _ := testServer(t) -- cgit v1.2.3