Skip to content

feat(attachments): download work item attachments - #27

Draft
nogara wants to merge 6 commits into
cpatrickalves:mainfrom
nogara:feat/attachment-download
Draft

nogara wants to merge 6 commits into
cpatrickalves:mainfrom
nogara:feat/attachment-download

Conversation

@nogara

@nogara nogara commented Oct 20, 2026

Copy link
Copy Markdown

Depends on #12. This branch contains #12's commits unchanged. Only the last two commits are new, so the diff here gets small once #12 merges. Opened as a draft until then.

Summary

Adds planecli attachment get (aliases download, dl) to download work item attachments:

planecli attachment get ISSUE [SELECTOR] [--all] [--dir/-d DIR | --output/-o FILE] [--force] [--json]
  • SELECTOR is an attachment id or exact file name. It can be left out when the item has one attachment, or when --all is given.
  • A name shared by several attachments (pasted screenshots are all image.png) fails and lists the ids, unless --all is given. --all saves every match with repeated names suffixed (image-2.png).
  • Existing files are not overwritten without --force. -o saves exactly one attachment. --json prints [{id, name, type, size, path}] with absolute paths.

The v1 detail endpoint answers with a redirect to a presigned storage URL. The CLI follows that redirect itself, so the API key is only sent to the API host. The body streams to a .part file that is renamed on success.

New commits on top of #12

Test plan

  • uv run ruff check src/
  • uv run pytest tests/: 221 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_013dQcgZHVdyPjyJMov9Ljba

Liewzheng and others added 6 commits September 3, 2026 22:20
Add an `attachment` sub-app with `attach`/`ls` commands, backed by a
three-step upload flow (register for a presigned S3 URL, PUT the binary,
PATCH is_uploaded and verify the write — see ADRs 0003 and 0007).
Duplicate asset names are rejected unless the user confirms.

`wi create`/`wi update` gain repeatable `-i/--image` flags that upload an
image and append it to the description. The img src stores only the
asset UUID — the web editor resolves it via getAssetSrc, so storing a
full path breaks image rendering ("Error loading image").

The v2 app upload endpoint (ISSUE_DESCRIPTION) is preferred and
automatically falls back to v1 when the server rejects API-token auth;
asset UUIDs stay interchangeable across both paths.
comment create/update wrapped the whole body in a single p tag; the
editor collapses whitespace inside a paragraph, so multi-line comments
(numbered items, link lists) rendered as one long line. Blank lines now
split into separate paragraphs, single newlines become br tags.
The API stores comment HTML verbatim and does not auto-link URLs — only
the web editor does — so links posted via the CLI rendered as plain text.
Bare http(s) URLs now become anchors; trailing sentence punctuation stays
outside the link, and URLs already inside an anchor are left alone.
The editor stores HTML and does not parse markdown, so `branch` and
fenced blocks posted via the CLI showed literal backticks. Inline code
becomes an escaped code tag (never linkified); fenced blocks become
pre-wrapped code and keep their own paragraph.
- attach: check the local file before resolving the work item, so a bad
  path fails before the config or the network is touched.
- _guess_mime: know .md/.markdown/.log where the platform MIME database
  lacks them (the uv-managed Python on macOS has no .md entry).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013dQcgZHVdyPjyJMov9Ljba
Add `planecli attachment get` (aliases `download`, `dl`). SELECTOR picks
an attachment by id or exact file name; a name shared by several
attachments needs an id, or --all to save every match with repeated
names suffixed (image-2.png). --dir/-o choose the target, --force
overwrites existing files, --json prints the saved paths.

The v1 detail endpoint answers with a redirect to a presigned storage
URL; the redirect is followed by hand so the API key stays on the API
host, and the body streams to a .part file renamed on success.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HcDT5cKbMgPEE4tTPZqhKs
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