fix(agentic): route root plan command
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
428cd25ebc
commit
92703d5af5
2 changed files with 91 additions and 3 deletions
|
|
@ -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 <slug> --title=\"My Plan\" [--objective=\"...\"] [--description=\"...\"] [--import=bug-fix] [--activate]")
|
||||
core.Print(nil, " core-agent plan from-issue <slug> [--id=N]")
|
||||
core.Print(nil, " core-agent plan show <slug>")
|
||||
core.Print(nil, " core-agent plan update <id-or-slug> [--status=ready] [--title=\"...\"] [--objective=\"...\"] [--description=\"...\"] [--notes=\"...\"] [--agent=codex] [--context='{\"repo\":\"go-io\"}'] [--phases='[...]']")
|
||||
core.Print(nil, " core-agent plan status <slug> [--set=ready]")
|
||||
core.Print(nil, " core-agent plan check <slug> [--phase=1]")
|
||||
core.Print(nil, " core-agent plan archive <slug> [--reason=\"...\"]")
|
||||
core.Print(nil, " core-agent plan delete <id> [--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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue