diff --git a/pkg/agentic/commands_plan.go b/pkg/agentic/commands_plan.go index 9047d0e..1564699 100644 --- a/pkg/agentic/commands_plan.go +++ b/pkg/agentic/commands_plan.go @@ -39,11 +39,40 @@ func (s *PrepSubsystem) registerPlanCommands() { } func (s *PrepSubsystem) cmdPlan(options core.Options) core.Result { - if action := optionStringValue(options, "action", "_arg"); action == "templates" { + switch action := optionStringValue(options, "action", "_arg"); action { + case "", "list": + return s.cmdPlanList(options) + case "templates": return s.cmdPlanTemplates(options) + case "create": + return s.cmdPlanCreate(options) + case "from-issue", "from_issue", "fromissue": + return s.cmdPlanFromIssue(options) + case "get", "read", "show": + return s.cmdPlanShow(options) + case "update": + return s.cmdPlanUpdate(options) + case "status": + return s.cmdPlanStatus(options) + case "check": + return s.cmdPlanCheck(options) + case "archive": + return s.cmdPlanArchive(options) + case "delete": + return s.cmdPlanDelete(options) + default: + core.Print(nil, "usage: core-agent plan list [--status=ready] [--repo=go-io] [--limit=20]") + core.Print(nil, " core-agent plan templates [--category=development]") + core.Print(nil, " core-agent plan create --title=\"My Plan\" [--objective=\"...\"] [--description=\"...\"] [--import=bug-fix] [--activate]") + core.Print(nil, " core-agent plan from-issue [--id=N]") + core.Print(nil, " core-agent plan show ") + core.Print(nil, " core-agent plan update [--status=ready] [--title=\"...\"] [--objective=\"...\"] [--description=\"...\"] [--notes=\"...\"] [--agent=codex] [--context='{\"repo\":\"go-io\"}'] [--phases='[...]']") + core.Print(nil, " core-agent plan status [--set=ready]") + core.Print(nil, " core-agent plan check [--phase=1]") + core.Print(nil, " core-agent plan archive [--reason=\"...\"]") + core.Print(nil, " core-agent plan delete [--reason=\"...\"]") + return core.Result{Value: core.E("agentic.cmdPlan", core.Concat("unknown plan command: ", action), nil), OK: false} } - - return s.cmdPlanList(options) } func (s *PrepSubsystem) cmdPlanTemplates(options core.Options) core.Result { diff --git a/pkg/agentic/commands_plan_test.go b/pkg/agentic/commands_plan_test.go index 38a11fb..4e5b5aa 100644 --- a/pkg/agentic/commands_plan_test.go +++ b/pkg/agentic/commands_plan_test.go @@ -92,6 +92,65 @@ func TestCommandsPlan_CmdPlanCheck_Ugly_IncompletePhase(t *testing.T) { assert.Equal(t, []string{"Patch code"}, output.Pending) } +func TestCommandsPlan_CmdPlan_Good_RoutesCreate(t *testing.T) { + dir := t.TempDir() + t.Setenv("CORE_WORKSPACE", dir) + + s := newTestPrep(t) + + r := s.cmdPlan(core.NewOptions( + core.Option{Key: "action", Value: "create"}, + core.Option{Key: "slug", Value: "root-route-plan"}, + core.Option{Key: "title", Value: "Root Route Plan"}, + core.Option{Key: "objective", Value: "Exercise the root plan router"}, + )) + + require.True(t, r.OK) + output, ok := r.Value.(PlanCreateOutput) + require.True(t, ok) + assert.True(t, output.Success) + assert.NotEmpty(t, output.ID) + assert.NotEmpty(t, output.Path) +} + +func TestCommandsPlan_CmdPlan_Good_RoutesStatus(t *testing.T) { + dir := t.TempDir() + t.Setenv("CORE_WORKSPACE", dir) + + s := newTestPrep(t) + _, created, err := s.planCreate(context.Background(), nil, PlanCreateInput{ + Title: "Status Route Plan", + Description: "Exercise the root plan router status action", + }) + require.NoError(t, err) + + plan, err := readPlan(PlansRoot(), created.ID) + require.NoError(t, err) + + r := s.cmdPlan(core.NewOptions( + core.Option{Key: "action", Value: "status"}, + core.Option{Key: "slug", Value: plan.Slug}, + )) + + require.True(t, r.OK) + output, ok := r.Value.(PlanCompatibilityGetOutput) + require.True(t, ok) + assert.True(t, output.Success) + assert.Equal(t, plan.Slug, output.Plan.Slug) +} + +func TestCommandsPlan_CmdPlan_Bad_UnknownAction(t *testing.T) { + s := newTestPrep(t) + + r := s.cmdPlan(core.NewOptions( + core.Option{Key: "action", Value: "does-not-exist"}, + )) + + require.False(t, r.OK) + require.Error(t, r.Value.(error)) + assert.Contains(t, r.Value.(error).Error(), "unknown plan command") +} + func TestCommandsPlan_CmdPlanUpdate_Good_StatusAndAgent(t *testing.T) { dir := t.TempDir() t.Setenv("CORE_WORKSPACE", dir)