diff options
Diffstat (limited to 'internal/api/validate.go')
| -rw-r--r-- | internal/api/validate.go | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/internal/api/validate.go b/internal/api/validate.go index 0fcdb47..07d293c 100644 --- a/internal/api/validate.go +++ b/internal/api/validate.go @@ -12,7 +12,7 @@ import ( const validateTimeout = 20 * time.Second -const validateSystemPrompt = `You are a task instruction reviewer for Claudomator, an AI task runner that executes tasks by running Claude as a subprocess. +const validateSystemPrompt = `You are a task instruction reviewer for Claudomator, an AI task runner that executes tasks by running Claude or Gemini as a subprocess. Analyze the given task name and instructions for clarity and completeness. @@ -48,7 +48,7 @@ func (s *Server) validateBinaryPath() string { if s.validateCmdPath != "" { return s.validateCmdPath } - return s.claudeBinaryPath() + return s.claudeBinPath } func (s *Server) handleValidateTask(w http.ResponseWriter, r *http.Request) { @@ -59,11 +59,13 @@ func (s *Server) handleValidateTask(w http.ResponseWriter, r *http.Request) { var input struct { Name string `json:"name"` - Claude struct { + Agent struct { + Type string `json:"type"` Instructions string `json:"instructions"` ProjectDir string `json:"project_dir"` + WorkingDir string `json:"working_dir"` // legacy AllowedTools []string `json:"allowed_tools"` - } `json:"claude"` + } `json:"agent"` } if err := json.NewDecoder(r.Body).Decode(&input); err != nil { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid JSON: " + err.Error()}) @@ -73,17 +75,27 @@ func (s *Server) handleValidateTask(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "name is required"}) return } - if input.Claude.Instructions == "" { + if input.Agent.Instructions == "" { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "instructions are required"}) return } - userMsg := fmt.Sprintf("Task name: %s\n\nInstructions:\n%s", input.Name, input.Claude.Instructions) - if input.Claude.ProjectDir != "" { - userMsg += fmt.Sprintf("\n\nWorking directory: %s", input.Claude.ProjectDir) + agentType := input.Agent.Type + if agentType == "" { + agentType = "claude" } - if len(input.Claude.AllowedTools) > 0 { - userMsg += fmt.Sprintf("\n\nAllowed tools: %v", input.Claude.AllowedTools) + + projectDir := input.Agent.ProjectDir + if projectDir == "" { + projectDir = input.Agent.WorkingDir + } + + userMsg := fmt.Sprintf("Task name: %s\nAgent: %s\n\nInstructions:\n%s", input.Name, agentType, input.Agent.Instructions) + if projectDir != "" { + userMsg += fmt.Sprintf("\n\nWorking directory: %s", projectDir) + } + if len(input.Agent.AllowedTools) > 0 { + userMsg += fmt.Sprintf("\n\nAllowed tools: %v", input.Agent.AllowedTools) } ctx, cancel := context.WithTimeout(r.Context(), validateTimeout) |
