Add shared live run graphs, debugging, editor choice and draft cleanup
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"git.a-wan.net/alan/pipelines/internal/draft"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/runinspect"
|
||||
"git.a-wan.net/alan/pipelines/internal/tui"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
@@ -76,6 +77,9 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
case "retry":
|
||||
f.StringVar(&o.key, "request-key", "", "Idempotency key (default: generated unique key)")
|
||||
f.BoolVar(&o.wait, "wait", false, "Wait for the new run to finish")
|
||||
case "debug":
|
||||
f.StringVar(&o.opencode, "opencode", envOr("PIPELINES_OPENCODE", "opencode"), "Host OpenCode executable")
|
||||
f.BoolVar(&o.noOpen, "no-open", false, "Print the investigation prompt without launching OpenCode")
|
||||
}
|
||||
f.Usage = func() {
|
||||
fmt.Fprintf(a.Out, "Usage: pipelines %s\n", usage[command])
|
||||
@@ -193,6 +197,19 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
return fmt.Errorf("timeout must be positive and versions nonnegative")
|
||||
}
|
||||
pos := f.Args()
|
||||
if command == "draft-delete" {
|
||||
if len(pos) != 1 {
|
||||
return fmt.Errorf("draft-delete requires one retained draft path")
|
||||
}
|
||||
if err := draft.Delete(pos[0]); err != nil {
|
||||
return err
|
||||
}
|
||||
if o.json {
|
||||
return a.output(map[string]any{"deleted": pos[0]})
|
||||
}
|
||||
_, err := fmt.Fprintln(a.Out, "Deleted draft:", pos[0])
|
||||
return err
|
||||
}
|
||||
if command == "tui" {
|
||||
if len(pos) > 0 {
|
||||
return fmt.Errorf("tui takes no arguments")
|
||||
@@ -255,6 +272,39 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
return pos[0], nil
|
||||
}
|
||||
switch command {
|
||||
case "debug":
|
||||
value, err := one()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id, err := strconv.ParseInt(value, 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
return fmt.Errorf("run ID must be positive")
|
||||
}
|
||||
response, err := call(protocol.Message{Type: protocol.GetRun, RunID: id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if response.RunDetail == nil {
|
||||
return fmt.Errorf("server did not return run detail")
|
||||
}
|
||||
executable, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
debug := runinspect.New(response.RunDetail, executable, o.url)
|
||||
if o.json {
|
||||
return a.output(debug)
|
||||
}
|
||||
if o.noOpen {
|
||||
_, err := fmt.Fprintln(a.Out, debug.Prompt)
|
||||
return err
|
||||
}
|
||||
cmd := debug.Command(ctx, o.opencode)
|
||||
cmd.Stdin = a.In
|
||||
cmd.Stdout = a.Out
|
||||
cmd.Stderr = a.Err
|
||||
return cmd.Run()
|
||||
case "new", "edit":
|
||||
return a.author(ctx, command, pos, o, call, resolve)
|
||||
case "validate", "submit":
|
||||
|
||||
Reference in New Issue
Block a user