summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/create.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/cli/create.go b/internal/cli/create.go
index fdad932..addd034 100644
--- a/internal/cli/create.go
+++ b/internal/cli/create.go
@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
- "net/http"
+ "io"
"github.com/spf13/cobra"
)
@@ -52,7 +52,7 @@ func createTask(serverURL, name, instructions, workingDir, model, parentID strin
"priority": priority,
"claude": map[string]interface{}{
"instructions": instructions,
- "working_dir": workingDir,
+ "project_dir": workingDir,
"model": model,
"max_budget_usd": budget,
},
@@ -62,20 +62,26 @@ func createTask(serverURL, name, instructions, workingDir, model, parentID strin
}
data, _ := json.Marshal(body)
- resp, err := http.Post(serverURL+"/api/tasks", "application/json", bytes.NewReader(data)) //nolint:noctx
+ resp, err := httpClient.Post(serverURL+"/api/tasks", "application/json", bytes.NewReader(data)) //nolint:noctx
if err != nil {
return fmt.Errorf("POST /api/tasks: %w", err)
}
defer resp.Body.Close()
+ raw, _ := io.ReadAll(resp.Body)
var result map[string]interface{}
- _ = json.NewDecoder(resp.Body).Decode(&result)
+ if err := json.Unmarshal(raw, &result); err != nil {
+ return fmt.Errorf("server returned invalid JSON (status %d): %s", resp.StatusCode, string(raw))
+ }
if resp.StatusCode >= 300 {
return fmt.Errorf("server returned %d: %v", resp.StatusCode, result["error"])
}
id, _ := result["id"].(string)
+ if id == "" {
+ return fmt.Errorf("server returned task without id field")
+ }
fmt.Printf("Created task %s\n", id)
if autoStart {