Add shared live run graphs, debugging, editor choice and draft cleanup

This commit is contained in:
2026-10-09 19:17:43 +01:00
parent 9b8afc874f
commit 0f80ff4e95
33 changed files with 1162 additions and 72 deletions
+34
View File
@@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"sort"
"strings"
)
type Draft struct {
@@ -114,3 +115,36 @@ func List() ([]Draft, error) {
}
return items, nil
}
// Delete only a selected, managed cache draft and its sidecar. Never recurse,
// follow a file symlink, or delete an arbitrary external submission source.
func Delete(path string) error {
dir, err := Directory()
if err != nil {
return err
}
absolute, err := filepath.Abs(path)
if err != nil {
return err
}
name := filepath.Base(absolute)
if filepath.Dir(absolute) != filepath.Clean(dir) || !strings.HasPrefix(name, "pipeline-") || !strings.HasSuffix(name, ".md") {
return fmt.Errorf("only managed drafts inside %s can be deleted", dir)
}
for _, file := range []string{absolute + ".json", absolute} {
info, err := os.Lstat(file)
if os.IsNotExist(err) && file == absolute {
continue
}
if err != nil {
return err
}
if !info.Mode().IsRegular() {
return fmt.Errorf("draft and metadata must be regular files, not symlinks or directories")
}
}
if err := os.Remove(absolute); err != nil && !os.IsNotExist(err) {
return err
}
return os.Remove(absolute + ".json")
}