103 lines
4.2 KiB
Go
103 lines
4.2 KiB
Go
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
package agentic
|
|
|
|
import (
|
|
core "dappco.re/go/core"
|
|
)
|
|
|
|
func (s *PrepSubsystem) registerTaskCommands() {
|
|
c := s.Core()
|
|
c.Command("task", core.Command{Description: "Manage plan tasks", Action: s.cmdTask})
|
|
c.Command("task/update", core.Command{Description: "Update a plan task status or notes", Action: s.cmdTaskUpdate})
|
|
c.Command("task/toggle", core.Command{Description: "Toggle a plan task between pending and completed", Action: s.cmdTaskToggle})
|
|
}
|
|
|
|
func (s *PrepSubsystem) cmdTask(options core.Options) core.Result {
|
|
action := optionStringValue(options, "action")
|
|
switch action {
|
|
case "toggle":
|
|
return s.cmdTaskToggle(options)
|
|
case "update":
|
|
return s.cmdTaskUpdate(options)
|
|
case "":
|
|
core.Print(nil, "usage: core-agent task update <plan> --phase=1 --task=1 [--status=completed] [--notes=\"Done\"]")
|
|
core.Print(nil, " core-agent task toggle <plan> --phase=1 --task=1")
|
|
return core.Result{OK: true}
|
|
default:
|
|
core.Print(nil, "usage: core-agent task update <plan> --phase=1 --task=1 [--status=completed] [--notes=\"Done\"]")
|
|
core.Print(nil, " core-agent task toggle <plan> --phase=1 --task=1")
|
|
return core.Result{Value: core.E("agentic.cmdTask", core.Concat("unknown task command: ", action), nil), OK: false}
|
|
}
|
|
}
|
|
|
|
func (s *PrepSubsystem) cmdTaskUpdate(options core.Options) core.Result {
|
|
planSlug := optionStringValue(options, "plan_slug", "plan", "slug", "_arg")
|
|
phaseOrder := optionIntValue(options, "phase_order", "phase")
|
|
taskIdentifier := optionAnyValue(options, "task_identifier", "task")
|
|
|
|
if planSlug == "" || phaseOrder == 0 || taskIdentifierValue(taskIdentifier) == "" {
|
|
core.Print(nil, "usage: core-agent task update <plan> --phase=1 --task=1 [--status=completed] [--notes=\"Done\"]")
|
|
return core.Result{Value: core.E("agentic.cmdTaskUpdate", "plan_slug, phase_order, and task_identifier are required", nil), OK: false}
|
|
}
|
|
|
|
result := s.handleTaskUpdate(s.commandContext(), core.NewOptions(
|
|
core.Option{Key: "plan_slug", Value: planSlug},
|
|
core.Option{Key: "phase_order", Value: phaseOrder},
|
|
core.Option{Key: "task_identifier", Value: taskIdentifier},
|
|
core.Option{Key: "status", Value: optionStringValue(options, "status")},
|
|
core.Option{Key: "notes", Value: optionStringValue(options, "notes")},
|
|
))
|
|
if !result.OK {
|
|
err := commandResultError("agentic.cmdTaskUpdate", result)
|
|
core.Print(nil, "error: %v", err)
|
|
return core.Result{Value: err, OK: false}
|
|
}
|
|
|
|
output, ok := result.Value.(TaskOutput)
|
|
if !ok {
|
|
err := core.E("agentic.cmdTaskUpdate", "invalid task update output", nil)
|
|
core.Print(nil, "error: %v", err)
|
|
return core.Result{Value: err, OK: false}
|
|
}
|
|
|
|
core.Print(nil, "task: %s", output.Task.Title)
|
|
core.Print(nil, "status: %s", output.Task.Status)
|
|
if output.Task.Notes != "" {
|
|
core.Print(nil, "notes: %s", output.Task.Notes)
|
|
}
|
|
return core.Result{Value: output, OK: true}
|
|
}
|
|
|
|
func (s *PrepSubsystem) cmdTaskToggle(options core.Options) core.Result {
|
|
planSlug := optionStringValue(options, "plan_slug", "plan", "slug", "_arg")
|
|
phaseOrder := optionIntValue(options, "phase_order", "phase")
|
|
taskIdentifier := optionAnyValue(options, "task_identifier", "task")
|
|
|
|
if planSlug == "" || phaseOrder == 0 || taskIdentifierValue(taskIdentifier) == "" {
|
|
core.Print(nil, "usage: core-agent task toggle <plan> --phase=1 --task=1")
|
|
return core.Result{Value: core.E("agentic.cmdTaskToggle", "plan_slug, phase_order, and task_identifier are required", nil), OK: false}
|
|
}
|
|
|
|
result := s.handleTaskToggle(s.commandContext(), core.NewOptions(
|
|
core.Option{Key: "plan_slug", Value: planSlug},
|
|
core.Option{Key: "phase_order", Value: phaseOrder},
|
|
core.Option{Key: "task_identifier", Value: taskIdentifier},
|
|
))
|
|
if !result.OK {
|
|
err := commandResultError("agentic.cmdTaskToggle", result)
|
|
core.Print(nil, "error: %v", err)
|
|
return core.Result{Value: err, OK: false}
|
|
}
|
|
|
|
output, ok := result.Value.(TaskOutput)
|
|
if !ok {
|
|
err := core.E("agentic.cmdTaskToggle", "invalid task toggle output", nil)
|
|
core.Print(nil, "error: %v", err)
|
|
return core.Result{Value: err, OK: false}
|
|
}
|
|
|
|
core.Print(nil, "task: %s", output.Task.Title)
|
|
core.Print(nil, "status: %s", output.Task.Status)
|
|
return core.Result{Value: output, OK: true}
|
|
}
|