Files
pad/internal/cli
xarmian 5e27989ab8 feat(attachment): add pad attachment view|show|list CLI surfaces (IDEA-898) (#321)
* feat(attachment): add `pad attachment view|show|list` CLI surfaces (IDEA-898)

Agents and CLI users had no first-class way to fetch attachment bytes
through the API: the only path to read an `![alt](pad-attachment:<uuid>)`
reference was to read the raw blob out of `~/.pad/attachments/<storage_key>`,
which bypasses workspace ACLs, doesn't work on Pad Cloud / remote /
Postgres deployments, skips the variant pipeline (TASK-872 / TASK-879 /
TASK-880), and breaks when storage moves to S3.

Three new subcommands wrap the existing REST endpoints:

- `pad attachment view <id> [-o path]` — agent-friendly: with no `-o`,
  fetches to a fresh OS temp directory using the stored filename and
  prints just the absolute path on stdout (so `$(pad attachment view <id>)`
  composes cleanly into shell pipelines). Reuses `download`'s atomic
  temp-then-rename pattern via a shared helper.

- `pad attachment show <id>` — HEAD-based metadata only; surfaces MIME,
  size, filename, ETag, Last-Modified.

- `pad attachment list [--item REF] [--category X] [--attached|--unattached]
  [--collection ID] [--sort ...] [--limit N] [--offset N]` — workspace
  list. The `--item REF` flag resolves a TASK-5-style ref to a UUID
  client-side and passes it to a new `item_id` query param on the list
  endpoint (server side: AttachmentListFilters.ItemID, ~6 lines in the
  store + 1 in the handler).

Skill update: `skills/pad/SKILL.md` gains a "Working with attachments"
subsection plus a CLI Reference entry, both ending in the hard rule that
agents must NEVER read directly from `~/.pad/attachments/`.

* style(cli): gofmt AttachmentListParams field alignment

CI's golangci-lint v2 flagged this with the gofmt formatter (configured
with simplify: true in .golangci.yml). The contiguous Sort/Limit/Offset
block at the end of the struct needs uniform column alignment — gofmt
considers the doc comment above Sort attached to that field rather than
a block separator, so the three int/string fields get aligned together.

Verified locally with `golangci-lint run --timeout=5m ./...` (v2.11.4 to
match CI) — 0 issues. Local make lint only runs `go vet ./...` and
`golangci-lint` wasn't installed, which is why this slipped through;
filing a separate follow-up to mirror the CI checks in the local
workflow.
2026-04-30 16:06:08 -04:00
..
2026-03-26 01:52:36 +00:00
2026-03-26 01:52:36 +00:00
2026-03-26 01:52:36 +00:00