Add a human decision stage that pauses a run for an operator's choice
A new registered stage type `human` (internal/stage/human.go) has no model,
agent, tools or configs: its required `prompt` block carries the operator
instructions and its non-error edges are the selectable options. It parses,
validates, renders, exports and imports like every other type (no parser
special-case, no config keys).
At runtime the runner parks the run instead of executing: the step and the run
persist `waiting` with self-contained {prompt, options} evidence, and the run
returns without starting later stages, capturing file diffs, scanning artifacts,
holding a goroutine/timer or applying a stage timeout. The wait is durable: a
restart leaves the waiting rows untouched (RecoverRuns excludes them) and a
rebuilt runtime over the same database still accepts the decision.
`pipelines decide <run-id> [stage] --option KEY [--feedback TEXT] [--json]` and
the TUI `c` picker resolve the decision from the pinned graph in one store
transaction, record the choice and feedback as the step's evidence and resume
along edges[KEY]. An unknown option is refused with the valid list, a stage that
is not waiting is refused, and a repeated decision for an already-decided visit
does not double-apply. Cancel and retry keep working while waiting and after a
decision; a human stage is never killed by a stage timeout or max_visits, and a
`notify` policy can fire an `on=waiting` event.
Docs: the authoring skill references (format.md, operations.md), docs/cli.md and
README describe the stage, the command and the TUI picker. Tests cover stage
validation, the parsing round-trip, the store transitions, a websocket wait/decide
integration, cancel/retry, waiting notifications and a persistence-layer rebuild
(second Open + newRunner over one database, no process restart).
This commit is contained in:
@@ -35,6 +35,7 @@ type App struct {
|
||||
type options struct {
|
||||
harness string
|
||||
url, name, prompt, title, template, workspace, paths, key, opencode, model string
|
||||
option, feedback string
|
||||
output string
|
||||
conflict string
|
||||
all bool
|
||||
@@ -107,6 +108,9 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
f.DurationVar(&o.waitTimeout, "wait-timeout", 0, "Client limit for --wait (0 waits until the run ends); independent of --timeout")
|
||||
case "cancel", "draft-delete":
|
||||
f.BoolVar(&o.yes, "yes", false, "Confirm this action without an interactive prompt")
|
||||
case "decide":
|
||||
f.StringVar(&o.option, "option", "", "Option key to choose among the waiting stage's edges (required)")
|
||||
f.StringVar(&o.feedback, "feedback", "", "Optional free-text feedback recorded with the decision")
|
||||
case "debug":
|
||||
f.StringVar(&o.harness, "harness", "", "Debugging harness: configured opencode/pi, or nvim")
|
||||
f.BoolVar(&o.yes, "yes", false, "Approve opening a debugging session without prompting")
|
||||
@@ -778,6 +782,38 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
return a.finishRun(ctx, r, o, call)
|
||||
}
|
||||
return a.output(r.RunDetail)
|
||||
case "decide":
|
||||
if len(pos) < 1 || len(pos) > 2 {
|
||||
return fmt.Errorf("decide requires a run ID and an optional stage key")
|
||||
}
|
||||
id, err := strconv.ParseInt(pos[0], 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
return fmt.Errorf("run ID must be positive")
|
||||
}
|
||||
option := strings.TrimSpace(o.option)
|
||||
if option == "" {
|
||||
return fmt.Errorf("decide requires --option KEY")
|
||||
}
|
||||
stageKey := ""
|
||||
if len(pos) == 2 {
|
||||
stageKey = pos[1]
|
||||
}
|
||||
r, err := call(protocol.Message{Type: protocol.DecideRun, RunID: id, Stage: stageKey, Option: option, Feedback: o.feedback})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if r.RunDetail == nil {
|
||||
return fmt.Errorf("server did not return run detail")
|
||||
}
|
||||
if o.json {
|
||||
return a.output(r.RunDetail)
|
||||
}
|
||||
line := fmt.Sprintf("Decided run #%d: %s · %s", r.RunDetail.ID, option, r.RunDetail.Status)
|
||||
if feedback := strings.TrimSpace(o.feedback); feedback != "" {
|
||||
line += " · feedback: " + feedback
|
||||
}
|
||||
_, err = fmt.Fprintln(a.Out, line)
|
||||
return err
|
||||
case "title":
|
||||
if len(pos) != 2 {
|
||||
return fmt.Errorf("title requires a run ID and a title")
|
||||
|
||||
Reference in New Issue
Block a user