diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-06-04 00:53:03 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-06-04 00:53:03 +0000 |
| commit | a6ad24d9d4524ebef6ed40edf90c6597be876fbd (patch) | |
| tree | 390028656c505ee1b92d7297a937749562666a41 | |
| parent | 0d537df08fea539022cbcffe3ea778a3c84e7fb7 (diff) | |
cli: add --repository-url flag and improve error reporting
| -rw-r--r-- | internal/cli/create.go | 13 | ||||
| -rw-r--r-- | internal/cli/status.go | 3 | ||||
| -rw-r--r-- | internal/executor/helpers.go | 23 |
3 files changed, 24 insertions, 15 deletions
diff --git a/internal/cli/create.go b/internal/cli/create.go index 396cd77..88f94ba 100644 --- a/internal/cli/create.go +++ b/internal/cli/create.go @@ -14,6 +14,7 @@ func newCreateCmd() *cobra.Command { serverURL string instructions string workingDir string + repoURL string model string agentType string parentID string @@ -28,13 +29,14 @@ func newCreateCmd() *cobra.Command { Short: "Create a task via the running server", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - return createTask(serverURL, args[0], instructions, workingDir, model, agentType, parentID, budget, timeout, priority, autoStart) + return createTask(serverURL, args[0], instructions, workingDir, repoURL, model, agentType, parentID, budget, timeout, priority, autoStart) }, } cmd.Flags().StringVar(&serverURL, "server", defaultServerURL, "claudomator server URL") cmd.Flags().StringVarP(&instructions, "instructions", "i", "", "task instructions (required)") cmd.Flags().StringVarP(&workingDir, "working-dir", "d", "", "working directory for the task") + cmd.Flags().StringVar(&repoURL, "repository-url", "", "repository URL for cloning") cmd.Flags().StringVarP(&model, "model", "m", "", "model to use") cmd.Flags().StringVar(&agentType, "agent-type", "claude", "agent type: claude, gemini") cmd.Flags().StringVar(&parentID, "parent-id", "", "parent task ID (makes this a subtask)") @@ -47,11 +49,12 @@ func newCreateCmd() *cobra.Command { return cmd } -func createTask(serverURL, name, instructions, workingDir, model, agentType, parentID string, budget float64, timeout, priority string, autoStart bool) error { +func createTask(serverURL, name, instructions, workingDir, repoURL, model, agentType, parentID string, budget float64, timeout, priority string, autoStart bool) error { body := map[string]interface{}{ - "name": name, - "timeout": timeout, - "priority": priority, + "name": name, + "timeout": timeout, + "priority": priority, + "repository_url": repoURL, "agent": map[string]interface{}{ "type": agentType, "instructions": instructions, diff --git a/internal/cli/status.go b/internal/cli/status.go index 77a30d5..ee787dd 100644 --- a/internal/cli/status.go +++ b/internal/cli/status.go @@ -59,6 +59,9 @@ func showStatus(id string) error { dur := e.EndTime.Sub(e.StartTime) fmt.Fprintf(w, " %.8s\t%s\t%d\t$%.4f\t%v\t%s\n", e.ID, e.Status, e.ExitCode, e.CostUSD, dur.Round(1e9), e.StartTime.Format("15:04:05")) + if e.ErrorMsg != "" { + fmt.Fprintf(w, " Error: %s\n", e.ErrorMsg) + } } w.Flush() } diff --git a/internal/executor/helpers.go b/internal/executor/helpers.go index 9517492..f2111a4 100644 --- a/internal/executor/helpers.go +++ b/internal/executor/helpers.go @@ -33,7 +33,6 @@ func parseStream(r io.Reader, w io.Writer, logger *slog.Logger) (float64, string var sessionID string var streamErr error -Loop: for scanner.Scan() { line := scanner.Bytes() var msg map[string]interface{} @@ -53,22 +52,26 @@ Loop: if info, ok := msg["rate_limit_info"].(map[string]interface{}); ok { status, _ := info["status"].(string) if status == "rejected" { - streamErr = fmt.Errorf("claude rate limit reached (rejected): %v", msg) - // Immediately break since we can't continue anyway - break Loop + if streamErr == nil { + streamErr = fmt.Errorf("claude rate limit reached (rejected): %v", msg) + } } } case "assistant": if errStr, ok := msg["error"].(string); ok && errStr == "rate_limit" { - streamErr = fmt.Errorf("claude rate limit reached: %v", msg) + if streamErr == nil { + streamErr = fmt.Errorf("claude rate limit reached: %v", msg) + } } case "result": if isErr, _ := msg["is_error"].(bool); isErr { - result, _ := msg["result"].(string) - if result != "" { - streamErr = fmt.Errorf("claude task failed: %s", result) - } else { - streamErr = fmt.Errorf("claude task failed (is_error=true in result)") + if streamErr == nil { + result, _ := msg["result"].(string) + if result != "" { + streamErr = fmt.Errorf("claude task failed: %s", result) + } else { + streamErr = fmt.Errorf("claude task failed (is_error=true in result)") + } } } // Prefer total_cost_usd from result message; fall through to legacy check below. |
