diff options
Diffstat (limited to 'internal/task')
| -rw-r--r-- | internal/task/parser_test.go | 25 | ||||
| -rw-r--r-- | internal/task/task.go | 10 | ||||
| -rw-r--r-- | internal/task/validator.go | 14 | ||||
| -rw-r--r-- | internal/task/validator_test.go | 9 |
4 files changed, 34 insertions, 24 deletions
diff --git a/internal/task/parser_test.go b/internal/task/parser_test.go index cb68e86..7c3aadc 100644 --- a/internal/task/parser_test.go +++ b/internal/task/parser_test.go @@ -11,7 +11,8 @@ func TestParse_SingleTask(t *testing.T) { yaml := ` name: "Test Task" description: "A simple test" -claude: +agent: + type: "claude" model: "sonnet" instructions: "Do something" working_dir: "/tmp" @@ -30,8 +31,8 @@ tags: if task.Name != "Test Task" { t.Errorf("expected name 'Test Task', got %q", task.Name) } - if task.Claude.Model != "sonnet" { - t.Errorf("expected model 'sonnet', got %q", task.Claude.Model) + if task.Agent.Model != "sonnet" { + t.Errorf("expected model 'sonnet', got %q", task.Agent.Model) } if task.Timeout.Duration != 10*time.Minute { t.Errorf("expected timeout 10m, got %v", task.Timeout.Duration) @@ -51,12 +52,14 @@ func TestParse_BatchTasks(t *testing.T) { yaml := ` tasks: - name: "Task A" - claude: + agent: + type: "claude" instructions: "Do A" working_dir: "/tmp" tags: ["alpha"] - name: "Task B" - claude: + agent: + type: "claude" instructions: "Do B" working_dir: "/tmp" tags: ["beta"] @@ -79,7 +82,8 @@ tasks: func TestParse_MissingName_ReturnsError(t *testing.T) { yaml := ` description: "no name" -claude: +agent: + type: "claude" instructions: "something" ` _, err := Parse([]byte(yaml)) @@ -91,7 +95,8 @@ claude: func TestParse_DefaultRetryConfig(t *testing.T) { yaml := ` name: "Defaults" -claude: +agent: + type: "claude" instructions: "test" ` tasks, err := Parse([]byte(yaml)) @@ -110,7 +115,8 @@ func TestParse_WithPriority(t *testing.T) { yaml := ` name: "High Priority" priority: "high" -claude: +agent: + type: "claude" instructions: "urgent" ` tasks, err := Parse([]byte(yaml)) @@ -127,7 +133,8 @@ func TestParseFile(t *testing.T) { path := filepath.Join(dir, "task.yaml") content := ` name: "File Task" -claude: +agent: + type: "claude" instructions: "from file" working_dir: "/tmp" ` diff --git a/internal/task/task.go b/internal/task/task.go index 498c364..6b240dd 100644 --- a/internal/task/task.go +++ b/internal/task/task.go @@ -28,7 +28,8 @@ const ( PriorityLow Priority = "low" ) -type ClaudeConfig struct { +type AgentConfig struct { + Type string `yaml:"type" json:"type"` Model string `yaml:"model" json:"model"` ContextFiles []string `yaml:"context_files" json:"context_files"` Instructions string `yaml:"instructions" json:"instructions"` @@ -43,8 +44,8 @@ type ClaudeConfig struct { } // UnmarshalJSON reads project_dir with fallback to legacy working_dir. -func (c *ClaudeConfig) UnmarshalJSON(data []byte) error { - type Alias ClaudeConfig +func (c *AgentConfig) UnmarshalJSON(data []byte) error { + type Alias AgentConfig aux := &struct { ProjectDir string `json:"project_dir"` WorkingDir string `json:"working_dir"` // legacy @@ -71,7 +72,8 @@ type Task struct { ParentTaskID string `yaml:"parent_task_id" json:"parent_task_id"` Name string `yaml:"name" json:"name"` Description string `yaml:"description" json:"description"` - Claude ClaudeConfig `yaml:"claude" json:"claude"` + Agent AgentConfig `yaml:"agent" json:"agent"` + Claude AgentConfig `yaml:"claude" json:"claude"` // alias for backward compatibility Timeout Duration `yaml:"timeout" json:"timeout"` Retry RetryConfig `yaml:"retry" json:"retry"` Priority Priority `yaml:"priority" json:"priority"` diff --git a/internal/task/validator.go b/internal/task/validator.go index ea0b1c2..003fab9 100644 --- a/internal/task/validator.go +++ b/internal/task/validator.go @@ -29,11 +29,11 @@ func Validate(t *Task) error { if t.Name == "" { ve.Add("name is required") } - if t.Claude.Instructions == "" { - ve.Add("claude.instructions is required") + if t.Agent.Instructions == "" { + ve.Add("agent.instructions is required") } - if t.Claude.MaxBudgetUSD < 0 { - ve.Add("claude.max_budget_usd must be non-negative") + if t.Agent.MaxBudgetUSD < 0 { + ve.Add("agent.max_budget_usd must be non-negative") } if t.Timeout.Duration < 0 { ve.Add("timeout must be non-negative") @@ -48,13 +48,13 @@ func Validate(t *Task) error { if t.Priority != "" && !validPriorities[t.Priority] { ve.Add(fmt.Sprintf("invalid priority %q; must be high, normal, or low", t.Priority)) } - if t.Claude.PermissionMode != "" { + if t.Agent.PermissionMode != "" { validModes := map[string]bool{ "default": true, "acceptEdits": true, "bypassPermissions": true, "plan": true, "dontAsk": true, "delegate": true, } - if !validModes[t.Claude.PermissionMode] { - ve.Add(fmt.Sprintf("invalid permission_mode %q", t.Claude.PermissionMode)) + if !validModes[t.Agent.PermissionMode] { + ve.Add(fmt.Sprintf("invalid permission_mode %q", t.Agent.PermissionMode)) } } diff --git a/internal/task/validator_test.go b/internal/task/validator_test.go index 02bde45..657d93f 100644 --- a/internal/task/validator_test.go +++ b/internal/task/validator_test.go @@ -9,7 +9,8 @@ func validTask() *Task { return &Task{ ID: "test-id", Name: "Valid Task", - Claude: ClaudeConfig{ + Agent: AgentConfig{ + Type: "claude", Instructions: "do something", ProjectDir: "/tmp", }, @@ -39,7 +40,7 @@ func TestValidate_MissingName_ReturnsError(t *testing.T) { func TestValidate_MissingInstructions_ReturnsError(t *testing.T) { task := validTask() - task.Claude.Instructions = "" + task.Agent.Instructions = "" err := Validate(task) if err == nil { t.Fatal("expected error") @@ -51,7 +52,7 @@ func TestValidate_MissingInstructions_ReturnsError(t *testing.T) { func TestValidate_NegativeBudget_ReturnsError(t *testing.T) { task := validTask() - task.Claude.MaxBudgetUSD = -1.0 + task.Agent.MaxBudgetUSD = -1.0 err := Validate(task) if err == nil { t.Fatal("expected error") @@ -87,7 +88,7 @@ func TestValidate_InvalidPriority_ReturnsError(t *testing.T) { func TestValidate_InvalidPermissionMode_ReturnsError(t *testing.T) { task := validTask() - task.Claude.PermissionMode = "yolo" + task.Agent.PermissionMode = "yolo" err := Validate(task) if err == nil { t.Fatal("expected error") |
