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":
|
||||
|
||||
+23
-20
@@ -2,26 +2,28 @@ package cli
|
||||
|
||||
// Help is also the public command inventory for agents and parity checks.
|
||||
var usage = map[string]string{
|
||||
"new": "new [name] [prompt] [--template KEY] [--no-open | --json]",
|
||||
"edit": "edit [name|id] [prompt] [--version N] [--no-open | --json]",
|
||||
"drafts": "drafts [--json]",
|
||||
"validate": "validate <draft.md> [--json]",
|
||||
"submit": "submit <draft.md> [--name NAME] [--create-only] [--json]",
|
||||
"list": "list [--json]",
|
||||
"show": "show <name|id> [--version N] [--json]",
|
||||
"versions": "versions <name|id> [--json]",
|
||||
"export": "export <name|id> [--version N]",
|
||||
"templates": "templates [--json]",
|
||||
"template": "template <key> [--source | --json]",
|
||||
"run": "run [name|id] [prompt] [--json [--wait]]",
|
||||
"runs": "runs [--pipeline NAME] [--json]",
|
||||
"inspect": "inspect <run-id> [--json]",
|
||||
"cancel": "cancel <run-id> [--json]",
|
||||
"retry": "retry <run-id> [--json] [--wait]",
|
||||
"connection": "connection [--json]",
|
||||
"ping": "ping [--json]",
|
||||
"rpc": "rpc <request.json|->",
|
||||
"tui": "tui",
|
||||
"new": "new [name] [prompt] [--template KEY] [--no-open | --json]",
|
||||
"edit": "edit [name|id] [prompt] [--version N] [--no-open | --json]",
|
||||
"drafts": "drafts [--json]",
|
||||
"draft-delete": "draft-delete <draft.md> [--json]",
|
||||
"validate": "validate <draft.md> [--json]",
|
||||
"submit": "submit <draft.md> [--name NAME] [--create-only] [--json]",
|
||||
"list": "list [--json]",
|
||||
"show": "show <name|id> [--version N] [--json]",
|
||||
"versions": "versions <name|id> [--json]",
|
||||
"export": "export <name|id> [--version N]",
|
||||
"templates": "templates [--json]",
|
||||
"template": "template <key> [--source | --json]",
|
||||
"run": "run [name|id] [prompt] [--json [--wait]]",
|
||||
"runs": "runs [--pipeline NAME] [--json]",
|
||||
"inspect": "inspect <run-id> [--json]",
|
||||
"cancel": "cancel <run-id> [--json]",
|
||||
"retry": "retry <run-id> [--json] [--wait]",
|
||||
"debug": "debug <run-id> [--json | --no-open]",
|
||||
"connection": "connection [--json]",
|
||||
"ping": "ping [--json]",
|
||||
"rpc": "rpc <request.json|->",
|
||||
"tui": "tui",
|
||||
}
|
||||
|
||||
var notes = map[string]string{
|
||||
@@ -31,6 +33,7 @@ var notes = map[string]string{
|
||||
"submit": "This command is explicit approval to publish; schedules activate on acceptance. Managed drafts provide the name and base-version guard. --force never bypasses validation.",
|
||||
"run": "Runs in your current directory. Supplied name/prompt start immediately; otherwise select a pipeline and send a multiline task with Ctrl+S. Stage tools are enabled automatically; no file list or RUN confirmation. Cancellation does not undo edits.",
|
||||
"retry": "Start a new attempt of a failed run with the same initial input, directory, pipeline version, and edit scope. Original history is retained. Already-completed side effects are not undone.",
|
||||
"debug": "Open a fresh OpenCode conversation to investigate a run using inspect/show/runs CLI queries. Does not resume the implementing session or retry the run. --json returns the investigation prompt without opening OpenCode.",
|
||||
"rpc": "Accepts a JSON protocol envelope; '-' reads stdin. Every TUI server operation is available here too. Mutating commands are not dry runs.",
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/draft"
|
||||
)
|
||||
|
||||
func TestDraftDeleteWorksWithoutServerConnection(t *testing.T) {
|
||||
t.Setenv("PIPELINES_DRAFT_DIR", t.TempDir())
|
||||
d, err := draft.Create("discard", "source", "server", true, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out bytes.Buffer
|
||||
a := App{Out: &out, Err: &out, In: strings.NewReader("")}
|
||||
if err := a.Run(context.Background(), []string{"draft-delete", d.Path, "--json", "--url", "not-a-server"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(out.String(), "deleted") {
|
||||
t.Fatal("deletion not reported", out.String())
|
||||
}
|
||||
if _, err := os.Stat(d.Path); !os.IsNotExist(err) {
|
||||
t.Fatal("selected draft not removed", err)
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ EXECUTE
|
||||
inspect <run-id> Inspect stages, outputs, errors and status
|
||||
cancel <run-id> Cancel a run; changes are NOT rolled back
|
||||
retry <run-id> Restart a failed run with its original input and directory
|
||||
debug <run-id> Ask OpenCode questions about a recorded or active run
|
||||
draft-delete <draft.md> Delete a selected retained draft and its metadata
|
||||
connection Server and public phone connection (no secrets)
|
||||
ping Check the server connection
|
||||
rpc <request.json|-> Send any protocol command (automation escape hatch)
|
||||
|
||||
Reference in New Issue
Block a user