CLI for agents: non-TTY safe run/confirmations, compact inspect, wait hints and exit codes
- Without a terminal, run behaves as --json, tui refuses and confirmations fail fast naming --yes instead of prompting. - inspect prints a compact summary by default; --step N, --transcripts and --json give detail. - wait names a failed run's stage and first diagnostic line, prints how to answer a run waiting on a person, and exits 2 when any run failed, was canceled or interrupted (1 stays for client errors). - help describes the current # outcome / # handoff format. - Task starter's Land stage drops edit to match format.md; skill docs document run --json --yes, retry --yes --json and the new behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,12 +3,14 @@ package cli_test
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/cli"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
@@ -49,8 +51,8 @@ func seedRunIn(t *testing.T, store *pipeline.Store, key, workspace string) int64
|
||||
return id
|
||||
}
|
||||
|
||||
// A run that finished unsuccessfully is still a finished run: one line is
|
||||
// printed for it and the command exits 0.
|
||||
// A run that finished unsuccessfully is still reported with one line naming
|
||||
// its failure, and the wait exits with the distinct unsuccessful-run status 2.
|
||||
func TestCLIWaitReportsTerminalRunWithoutFailing(t *testing.T) {
|
||||
run, store, _ := setup(t)
|
||||
ctx := context.Background()
|
||||
@@ -59,13 +61,14 @@ func TestCLIWaitReportsTerminalRunWithoutFailing(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
output, err := run("wait", fmt.Sprint(id), "--timeout", "5s")
|
||||
if err != nil {
|
||||
t.Fatalf("a failed run must not fail the wait: %v", err)
|
||||
var status *cli.StatusError
|
||||
if !errors.As(err, &status) || status.Code != cli.WaitRunsUnsuccessful {
|
||||
t.Fatalf("a failed run must exit %d: %v", cli.WaitRunsUnsuccessful, err)
|
||||
}
|
||||
t.Logf("pipelines wait %d:\n%s", id, strings.TrimSpace(output))
|
||||
line := fmt.Sprintf("run %d · failed (error)", id)
|
||||
if !strings.Contains(output, line) {
|
||||
t.Fatalf("wait output missing %q:\n%s", line, output)
|
||||
if !strings.Contains(output, line) || !strings.Contains(output, "boom") {
|
||||
t.Fatalf("wait output missing %q and its diagnostic:\n%s", line, output)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +108,9 @@ func TestCLIWaitReportsEveryRunInABatch(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
output, err := run("wait", fmt.Sprint(first), fmt.Sprint(second), "--timeout", "5s")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
var status *cli.StatusError
|
||||
if !errors.As(err, &status) || status.Code != cli.WaitRunsUnsuccessful || !strings.Contains(err.Error(), fmt.Sprintf("run %d canceled", second)) {
|
||||
t.Fatalf("a canceled run in the batch must exit %d: %v", cli.WaitRunsUnsuccessful, err)
|
||||
}
|
||||
for _, want := range []string{
|
||||
fmt.Sprintf("run %d · succeeded (success)", first),
|
||||
@@ -177,8 +181,9 @@ func TestCLIWaitJSONPrintsRunEnvelope(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
output, err := run("wait", fmt.Sprint(id), "--json", "--timeout", "5s")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
var status *cli.StatusError
|
||||
if !errors.As(err, &status) || status.Code != cli.WaitRunsUnsuccessful {
|
||||
t.Fatalf("a failed run must exit %d: %v", cli.WaitRunsUnsuccessful, err)
|
||||
}
|
||||
var envelope protocol.Message
|
||||
if err := json.Unmarshal([]byte(output), &envelope); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user