Skip to content

Add plan action list/get commands - #325

Merged
daniel-de-vera merged 2 commits into
mainfrom
plan-action-commands
Apr 29, 2026
Merged

daniel-de-vera merged 2 commits into
mainfrom
plan-action-commands

Conversation

@daniel-de-vera

@daniel-de-vera daniel-de-vera commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Wires the new plan-actions API into the CLI as signadot plan action list and signadot plan action get NAME (alias a), under the existing plan parent.
  • list shows NAME / MANAGED BY / ENABLED / REVISION / DESCRIPTION / UPDATED — MANAGED BY distinguishes system actions from org-owned actions.
  • get shows action header (Enabled, Description, Revision, Image, Requires), parsed Inputs/Outputs/Validations tables, and the action body. Body is rendered through glamour when stdout is a TTY (headings, tables, code blocks, inline code); raw markdown when piped.
  • -o json / -o yaml returns the raw PlanAction payload at both list and get.

Builds on go-sdk feature-plan (PlanActionStatus.Enabled, PlanActionStatus.BodyImage).

Test plan

  • signadot plan action list shows all visible actions with the columns above
  • signadot plan action get check shows header + Inputs/Outputs/Validations tables + rendered body
  • signadot plan action get k6 shows the Image: line populated from Status.BodyImage
  • signadot plan action get k6 | cat (non-TTY) prints raw markdown
  • signadot plan action get check -o json returns the raw PlanAction payload
  • signadot plan action get nonexistent surfaces a 404 from the API

Wires the new plan-actions API (ListPlanActions, GetPlanAction) into the
CLI as `signadot plan action list` and `signadot plan action get NAME`
(alias `a`).

The get view shows the action header (Enabled, Description, Revision,
Image, Requires), parsed Inputs/Outputs/Validations tables, and the raw
markdown body. When stdout is a TTY, the body is rendered through
glamour for headings, tables, code blocks, and inline code; when piped,
raw markdown is preserved so output stays usable for grep/redirect.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@scott-cotton

Copy link
Copy Markdown
Member

From claude:

  1. formatAny mishandles non-scalar JSON values (printers.go:222-227)
    func formatAny(v any) string {
    if v == nil { return "" }
    return fmt.Sprintf("%v", v)
    }
    For a Default of {"a": 1} you get map[a:1] in the table; for [1,2] you get [1 2]. Both are misleading and ugly.
    JSON-encoding (json.Marshal → string) gives faithful round-trip output that a reader can paste back into a plan
    spec. Easy fix.

  2. formatSchema is shallow (printers.go:230)
    Extracts only top-level type; renders any non-trivial schema (array with items, oneOf, enum, object with
    properties) as plain array/object or (custom). Acceptable for a summary column, but enum is common enough it'd
    be worth one extra branch:
    if enums, ok := m["enum"].([]any); ok && len(enums) > 0 {
    return fmt.Sprintf("enum(%d)", len(enums))
    }

  3. formatImage emits input= as a bare string (printers.go:158-167)
    On a "Image:" header line, input=foo reads ambiguously — could be a literal image with = in its tag or a
    Go-flag-style key=value. Suggest (from input "%s") or <input: %s> to disambiguate.

  4. PR description ↔ code mismatch. PR says list shows "Enabled/Revision/Description/Updated columns" but the
    code adds MANAGED BY as well (printers.go:18-26). Either update the description or drop the column — both are
    defensible, but they should agree. MANAGED BY is genuinely useful to differentiate org actions from system ones,
    so I'd keep it and update the PR text.

  5. printBody silently swallows the write result (printers.go:99-106)
    fmt.Fprintln(out, body) and fmt.Fprint(out, rendered) — neither return is checked. The rest of
    printActionDetails propagates errors (tabwriter Flush, sub-printers), so a broken pipe here would silently look
    successful. Minor; checking the second Fprint and returning the error keeps the contract consistent.

- formatAny: render object/array defaults as JSON so {"a": 1} prints
  faithfully instead of map[a:1]; the reader can paste it back into
  a plan spec. Scalars still pass through fmt.Sprintf.
- formatSchema: recognise enum schemas with an enum(N) summary so
  enum-restricted fields don't fall through to the generic (custom)
  bucket.
- formatImage: render the input-bound case as (from input "name")
  rather than input=name, which read ambiguously next to literal
  image refs that may legitimately contain '='.
- printBody: surface write errors from fmt.Fprint(ln) instead of
  silently swallowing them, so a broken pipe doesn't look like
  success.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@daniel-de-vera

Copy link
Copy Markdown
Contributor Author

@scott-cotton, feedback addressed in 2a031d6.

@scott-cotton scott-cotton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daniel-de-vera
daniel-de-vera merged commit af7da69 into main Apr 29, 2026
@daniel-de-vera
daniel-de-vera deleted the plan-action-commands branch April 29, 2026 16:58
daniel-de-vera added a commit that referenced this pull request May 7, 2026
)

* plan: align display across plan-family commands; surface CreatedBy

The plan-family commands had drifted from each other in several
small ways since the previous PR. Audit + fixes:

- plan tag get rendered the embedded plan as a thin metadata blurb
  (ID, Steps count, prompt first line, Created) — the shape we
  replaced in plan get during the previous PR. It now embeds the
  full plan body (Inputs / Steps / Outputs sections) using the
  same arrow form plan get uses. Plan-level metadata is omitted:
  ID and SelectionHint already appear in the tag header above; the
  rest is one signadot plan get away. The tag header also gains a
  Selection Hint: line so plan tag list and plan tag get agree on
  what summarises a tag.

  To make this shareable without a circular import (plan imports
  plantag for tag-application after compile/create), the plan-detail
  printer moved into the planshared package as PrintPlanDetails
  alongside a PrintPlanBody variant that skips the top-level header
  for embedded use. plan/printers.go collapses to a thin wrapper.

- Surface PlanStatus.CreatedBy (added in the latest go-sdk drop)
  as a Created By: row in the plan header — used by plan get,
  compile, create, recompile, run, and the embedded view in plan
  tag get (where it renders as Plan Created By: to disambiguate
  against the tag-level Created/Updated fields). Resolution by
  ActorType: user → email, api_key → "api key" + masked id,
  system → "system".

- plan action get's Outputs table no longer carries REQUIRED /
  DEFAULT columns. Those are input concepts that always rendered
  as false / empty for outputs (review feedback on PR #325 that
  hadn't landed). Separate row type with just NAME / SCHEMA.

- planrunnergroup/printers.go: migrate inline time.Parse +
  timeago.NoMax to utils.TimeAgo, matching the cleanup we'd already
  done in plantag and planexec. Drops the time and timeago imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* planshared: render empty strings as the literal "" in FormatValue

Empty-string values previously collapsed to the same shape as
nil/missing values: name (set in plan) with no detail. That hides
the distinction between "value not provided" and "deliberately
empty," which matters when an action interprets the empty string
specifically — e.g. run-image treats image:"" as "run on the host
runner without a container," a meaningful authoring choice the
reader needs to see.

Now an empty string renders as the literal "" (with quotes):

    image    ← ""   (set in plan)

and an unset/nil value still renders as no-detail:

    image    (set in plan)

Same disambiguation applies wherever FormatValue is used (plan
get's plan-level Inputs, plan x get's resolved inputs, plan get's
declared param defaults, output rows). Scalars still pass through
unchanged; objects and arrays continue to round-trip through
json.Marshal.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants