diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-03 21:22:30 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-03 21:22:30 +0000 |
| commit | 3962597950421e422b6e1ce57764550f5600ded6 (patch) | |
| tree | ef376c4c192293869fe408cb27abe6bba9e1fa32 /internal/api/elaborate_test.go | |
| parent | e8d1b80bd504088a7535e6045ab77f1ddd3b3d43 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/api/elaborate_test.go')
| -rw-r--r-- | internal/api/elaborate_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
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) |
