Archive pipelines: hide unused ones while keeping their history

archived_at on pipelines (migrated in place). archive_pipeline and
unarchive_pipeline by id or name with an expected-version guard;
list_pipelines hides archived unless include_archived. Archived
pipelines refuse runs, retries, new versions and name reuse, and
cannot be archived while an enabled schedule points at them.
CLI archive/unarchive and list --archived/--all, docs and skill note.
This commit is contained in:
2026-11-04 23:25:55 +00:00
parent fa6c0864db
commit 06bf580154
16 changed files with 630 additions and 14 deletions
+24 -4
View File
@@ -51,6 +51,7 @@ type options struct {
keepSet bool
all bool
json, source, noOpen, yes, allow, createOnly, force, wait bool
archived bool
version, expected, limit, retryVisit int
timeout, waitTimeout time.Duration
stageModels stageModelFlags
@@ -137,6 +138,11 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
f.BoolVar(&o.yes, "yes", false, "Confirm publication (schedules may activate)")
case "template":
f.BoolVar(&o.source, "source", false, "Print original Markdown instead of metadata")
case "list":
f.BoolVar(&o.archived, "archived", false, "List only archived pipelines")
f.BoolVar(&o.all, "all", false, "List active and archived pipelines (archived ones are marked)")
case "archive":
f.BoolVar(&o.yes, "yes", false, "Confirm archiving without an interactive prompt")
case "submit":
f.BoolVar(&o.yes, "yes", false, "Confirm publication without an interactive prompt")
f.StringVar(&o.name, "name", "", "Name for an external Markdown file (managed drafts already know their name)")
@@ -511,8 +517,10 @@ func (a App) Run(ctx context.Context, args []string) error {
defer cancel()
return c.Call(requestCtx, request)
}
// Resolution includes archived pipelines so history, show and unarchive
// still address them; the server refuses runs and publications for them.
resolve := func(value string) (protocol.PipelineSummary, error) {
r, err := call(protocol.Message{Type: protocol.List})
r, err := call(protocol.Message{Type: protocol.List, IncludeArchived: true})
if err != nil {
return protocol.PipelineSummary{}, err
}
@@ -755,6 +763,8 @@ func (a App) Run(ctx context.Context, args []string) error {
}
}
return nil
case "archive", "unarchive":
return a.archive(command, pos, o, call, resolve)
case "list", "templates", "runs", "ping", "connection":
if command == "runs" && len(pos) > 0 && pos[0] == "rm" {
return a.removeRuns(o, pos[1:], call)
@@ -763,10 +773,13 @@ func (a App) Run(ctx context.Context, args []string) error {
return fmt.Errorf("%s takes no positional arguments", command)
}
typeName := map[string]string{"list": protocol.List, "templates": protocol.ListTemplates, "runs": protocol.ListRuns, "ping": protocol.Ping, "connection": protocol.List}[command]
r, err := call(protocol.Message{Type: typeName})
r, err := call(protocol.Message{Type: typeName, IncludeArchived: command == "list" && (o.all || o.archived)})
if err != nil {
return err
}
if command == "list" && o.archived && !o.all {
r.Pipelines = archivedOnly(r.Pipelines)
}
if command == "runs" && o.name != "" {
p, err := resolve(o.name)
if err != nil {
@@ -786,7 +799,11 @@ func (a App) Run(ctx context.Context, args []string) error {
switch command {
case "list":
for _, p := range r.Pipelines {
fmt.Fprintf(a.Out, "%d\t%s\tv%d\t%d stages\n", p.ID, p.Name, p.Version, p.Stages)
note := ""
if p.ArchivedAt != "" {
note = "\tarchived " + p.ArchivedAt
}
fmt.Fprintf(a.Out, "%d\t%s\tv%d\t%d stages%s\n", p.ID, p.Name, p.Version, p.Stages, note)
}
case "templates":
for _, t := range r.Templates {
@@ -1195,11 +1212,14 @@ func (a App) author(ctx context.Context, command string, pos []string, o *option
if (o.name != "" && strings.TrimSpace(o.name) == "") || len(o.name) > 200 || strings.ContainsAny(o.name, "\r\n\x00") {
return fmt.Errorf("name must be 1–200 bytes without line breaks or NUL")
}
r, err := call(protocol.Message{Type: protocol.List})
r, err := call(protocol.Message{Type: protocol.List, IncludeArchived: true})
if err != nil {
return err
}
for _, p := range r.Pipelines {
if p.Name == o.name && p.ArchivedAt != "" {
return &pipeline.ArchivedError{Name: p.Name}
}
if p.Name == o.name {
return fmt.Errorf("pipeline already exists; use edit or choose another name")
}