Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Added
- `planecli attachment` command group: `attach` uploads a file to a work item and confirms the upload by reading it back; `ls` lists a work item's attachments. If a file with the same name is already attached, `attach` asks on stderr when run in a terminal and refuses with exit 5 otherwise; `--force` uploads anyway. Thanks to Liewzheng (#11)
- Repeatable `-i/--image` on `wi create` and `wi update` uploads images and appends them to the description. Uploads use the app's description-asset endpoint and fall back to a v1 attachment when the server rejects API tokens there. All paths are checked before anything is written, and `wi update` uploads only after its other options resolved (#11)

### Fixed
- `wi create --module` resolves the module before creating the work item, so a mistyped module name no longer leaves an item behind that a retry would duplicate

## [0.6.0] - 2026-11-06

### Added
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The main differentiator is **intelligent fuzzy search**: reference any resource
- **Documents**: Create, read, update, and delete project documents
- **Intake**: Manage a project's intake queue — list, create, triage (accept/decline), and delete items
- **Comments**: Add, update, and delete comments on work items
- **Attachments**: Upload files to work items, list them, and embed images in descriptions
- **Users**: List workspace members and identify the authenticated user
- **Fuzzy Search**: Intelligent resource resolution — `--project "Front"` finds "Frontend"
- **Dual Output**: Rich tables (default) or JSON with `--json` for scripting
Expand Down Expand Up @@ -101,6 +102,10 @@ planecli wi create "Review PR #345" --parent ABC-234 --assign "Luiz" --state "In
# Update a work item
planecli wi update ABC-123 --state "Done" --priority none

# Embed images in the description (repeatable -i/--image; uploaded, then appended as <img>)
planecli wi create "Login screen glitch" -p "Frontend" -d "See screenshot" -i ./shot.png
planecli wi update ABC-123 -i ./before.png -i ./after.png

# Quick-assign a work item (defaults to yourself)
planecli wi assign ABC-123
planecli wi assign ABC-123 --assign "Patrick"
Expand Down Expand Up @@ -246,6 +251,21 @@ planecli intake delete <issue-uuid> -p Frontend
planecli intake enabled Frontend --json
```

### Attachments

```bash
# Upload a file to a work item
planecli attachment attach ABC-123 -f ./server.log

# List a work item's attachments
planecli attachment ls ABC-123
```

If a file with the same name is already attached, `attach` asks before uploading when it runs in a
terminal (the question goes to stderr). Without a terminal it refuses with exit code 5; pass
`--force` to upload anyway. `wi update -i --force` does the same, but only when the server falls
back to v1 attachments for the image (see the command reference).

### Comments

```bash
Expand Down
13 changes: 12 additions & 1 deletion docs/adr/0003-sdk-escape-hatches.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ The three escape hatches:
2. **Documents (Pages) — direct HTTP.** For `list`, `update`, and `delete`, `commands/documents.py` calls the Plane HTTP API directly with `requests` and an `X-Api-Key` header through `asyncio.to_thread`. These calls run in a thread but deliberately skip `run_sdk`, so they get no concurrency semaphore and no retries from [ADR-0001](0001-async-wrapper-over-sync-sdk.md). `show` and `create` use the SDK through `run_sdk`.
3. **Estimate points — derive from work items.** `cached_list_estimate_points` fetches work items with `expand=estimate_point` (again via raw `_get()`, since expansion turns `estimate_point` from a string into a dict and breaks SDK validation) and collects the unique `{id, value}` pairs. `resolve_estimate_point_async` then maps a requested value to its UUID.

### Amendment (2026-11-06): attachments and description assets

A fourth escape hatch arrived with `commands/attachments.py`:

4. **Attachments and description assets — raw resource methods and direct HTTP.**
- Listing, registering, marking and reading back v1 attachments uses `client.work_items.attachments._get`/`_post`/`_patch`. The typed `attachments.list` returns `[]` when the API answers with a paginated `{"results": [...]}` dict, which would hide attachments, and the typed create drops `upload_data`, the presigned form the upload needs.
- Description images go through the app endpoint `/api/assets/v2/workspaces/<ws>/projects/<project>/` (entity type `ISSUE_DESCRIPTION`) and are read back through `/api/v1/workspaces/<ws>/assets/<id>/`, with `requests` and an `X-Api-Key` header. The SDK covers neither. Servers whose app endpoints accept only a browser session answer 401/403/404 to an API token; the command then falls back to a v1 attachment upload, and the asset UUID works the same in the description.
- The file bytes are POSTed to the presigned storage URL directly, with the signature in the form fields, no API key, and a 300-second timeout.

All of these run through `run_sdk`, so they get the concurrency limit and retries of [ADR-0001](0001-async-wrapper-over-sync-sdk.md). Each call site carries a `NOTE:`.

## Consequences

**Positive:**
Expand All @@ -47,4 +58,4 @@ The three escape hatches:

## Confirmation

Work item bypasses are marked with a `NOTE:` comment at their call sites. To list every bypass, grep for `_get(` in `utils/resolve.py` and `cache.py`, and for the `X-Api-Key` header in `commands/documents.py`. If a future `plane-sdk` release fixes `WorkItemDetail` validation or adds Pages/estimate-point endpoints, those call sites are the checklist for removing the workarounds.
Work item bypasses are marked with a `NOTE:` comment at their call sites. To list every bypass, grep for `_get(` in `utils/resolve.py` and `cache.py`, for the `X-Api-Key` header in `commands/documents.py`, and for `NOTE:` in `commands/attachments.py`. If a future `plane-sdk` release fixes `WorkItemDetail` validation or adds Pages/estimate-point endpoints, those call sites are the checklist for removing the workarounds.
19 changes: 19 additions & 0 deletions docs/adr/0008-destructive-deletes-are-documented-not-prompted.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,22 @@ command with a cascade is expected to follow the same pattern in code review.
**Neutral:**
- Revisit if the CLI ever adopts a uniform confirmation model; this ADR would then be
superseded rather than amended per command.

## Amendment (2026-11-06): duplicate-name confirmation on uploads

`attachment attach` and `wi update -i` (when the image upload falls back to v1 attachments) ask
before uploading a file whose name is already attached to the work item. Same-named attachments
are easy to create by accident and hard to tell apart in the web UI, and deleting the wrong one
breaks an image embedded in the description. This is the one exception to "no `planecli` command
blocks on stdin", and it is bounded so that it keeps the reason behind the rule (never hang an
automated caller):

- A command may confirm only when `sys.stdin.isatty()` is true.
- The prompt goes to stderr, never stdout, so `--json` output stays clean ([ADR-0005](0005-dual-output-contract.md)).
- Without a TTY the command does not wait: it refuses with exit 5 and a message that names
`--force`. An answer other than `y`/`yes`, or EOF, also refuses.
- `--force` skips the check. It is documented in `--help`, the README and the skill's command
reference.

The prompt guards against a duplicate, not against data loss, so it does not change the decision
above for deletes: they stay unprompted and documented.
1 change: 1 addition & 0 deletions docs/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Comments are cached **per work item** (keyed by `item_id`, not just the project)
|----------|--------|
| Documents / Pages | Change frequently |
| Individual resource lookups (by UUID/identifier) | Single-resource fetches should always be fresh |
| Attachments (`attachment ls`, uploads) | Read and written straight through the API; an upload is verified by reading the list back, which a cache would defeat |
| Intake queue (`intake ls`) | Goes straight to the API (there is no `cached_list_intake`), so the queue always reflects the current state |

**Important distinction**: What's cached is the *list of state definitions* — the lookup table that maps state UUIDs to display names and colors — not the association between a work item and its state. A work item's own fields are only ever as stale as its 2-minute TTL.
Expand Down
10 changes: 8 additions & 2 deletions skills/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: planecli
description: "Manage Plane.so through the planecli CLI — work items, projects, cycles/sprints, modules, labels, states, documents, intake queue, comments. Use when the user mentions Plane, planecli, or a work-item identifier like ABC-123, or asks about tasks, sprints, or backlogs in a project where Plane is the tracker."
description: "Manage Plane.so through the planecli CLI — work items, projects, cycles/sprints, modules, labels, states, documents, intake queue, comments, attachments. Use when the user mentions Plane, planecli, or a work-item identifier like ABC-123, or asks about tasks, sprints, or backlogs in a project where Plane is the tracker."
allowed-tools: Bash(planecli *)
metadata:
author: Patrick Alves
version: "1.8.0"
version: "1.9.2"
---

# PlaneCLI
Expand Down Expand Up @@ -126,6 +126,12 @@ planecli doc create --title "Spec" --content "$(cat spec.txt)" -p "Project" --js
# Comments
planecli comment ls ABC-123 --json
planecli comment create ABC-123 --body "Fixed in PR #456" --json

# Attachments (a duplicate name refuses with exit 5 without a TTY; --force uploads anyway)
planecli attachment attach ABC-123 -f ./server.log --json
planecli attachment ls ABC-123 --json
# Embed images in a description (repeatable; paths are checked before anything is written)
planecli wi update ABC-123 -i ./shot.png --json
```

## Gotchas
Expand Down
36 changes: 36 additions & 0 deletions skills/references/command-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [States](#states)
- [Documents](#documents)
- [Comments](#comments)
- [Attachments](#attachments)
- [Intake](#intake)
- [Users](#users)
- [Cache](#cache)
Expand All @@ -34,6 +35,7 @@ Environment variable `PLANECLI_NO_CACHE=1` disables cache globally.
| `project` | `projects` |
| `document` | `doc`, `docs`, `documents` |
| `comment` | `comments` |
| `attachment` | `attachments` |
| `module` | `modules` |
| `label` | `labels` |
| `state` | `states` |
Expand All @@ -42,6 +44,7 @@ Environment variable `PLANECLI_NO_CACHE=1` disables cache globally.
| `list` | `ls` |
| `show` | `read` |
| `create` | `new` |
| `attachment attach` | `upload`, `new` |

## Work Items

Expand Down Expand Up @@ -102,6 +105,7 @@ planecli wi create TITLE [OPTIONS]
| `--parent` | Parent work item identifier (ABC-123) for sub-issues |
| `--estimate` / `-e` | Story point estimate |
| `--description` / `-d` | Description. Stored as raw HTML, not markdown — see the Gotchas in SKILL.md |
| `--image` / `-i` | Image file to embed in the description (repeatable). Every path is checked before the item is created; the images are uploaded after the create and appended to the `-d` text as `<p><img src="ASSET_UUID" /></p>` |
| `--json` | JSON output |

### wi update
Expand All @@ -121,6 +125,8 @@ planecli wi update ISSUE [OPTIONS]
| `--clear-labels` | Remove all labels |
| `--name` | New title |
| `--description` / `-d` | New description. Stored as raw HTML, not markdown |
| `--image` / `-i` | Image file to embed (repeatable). Appended to the new `-d` text, or to the existing description. Uploaded only after every other option resolved, so a typo in `--state` uploads nothing |
| `--force` | Upload an image even if an attachment with the same name exists. Applies only when the server falls back to v1 attachments |
| `--json` | JSON output |

### wi delete
Expand Down Expand Up @@ -296,6 +302,36 @@ oldest → newest — not the first N chronologically. A limit of `0` or a negat
value returns no comments (consistent with the `[:limit]` semantics used elsewhere,
where `0` means "none").

## Attachments

Command group: `planecli attachment` (alias: `attachments`)

```
planecli attachment attach ISSUE -f FILE [--project/-p PROJECT] [--force] [--json]
planecli attachment ls ISSUE [--project/-p PROJECT] [--json]
```

- `attach` checks that `FILE` exists before any API call (exit 5 if not), uploads it in three
steps (register, push to the presigned storage URL, mark uploaded), and reads it back: exit 4
if the server does not confirm the upload, or if storage times out (300 s) or refuses the
connection.
- **Duplicate names.** If a file with the same name is already attached, `attach` asks
`Upload anyway? [y/N]` on stderr when stdin is a terminal. Without a terminal it refuses with
exit 5 and names `--force`, so a script never blocks on stdin
([ADR-0008](../../docs/adr/0008-destructive-deletes-are-documented-not-prompted.md)).
`--force` uploads without asking.
- `ls` shows `ID`, `Name`, `Type`, `Size`, `Uploaded`, `Created`. In `--json`, `name`, `type` and
`size` are copied to the top level from the API's `attributes`.
- **Images in descriptions** (`wi create/update -i`) first try the app endpoint
`/api/assets/v2/` (entity type `ISSUE_DESCRIPTION`, not listed by `attachment ls`). Servers that
answer 401/403/404 to an API token there fall back to a v1 attachment, which `attachment ls`
shows and which the duplicate-name check covers. The `img` tag stores only the asset UUID; the
web editor resolves it.
- MIME types come from the file extension. `.md`, `.markdown` and `.log` always upload as
`text/plain`, because some Plane servers reject `text/markdown` with `400 Invalid file type.`
Unknown types upload as `application/octet-stream`. Other types a server's allow list
rejects fail with exit 4.

## Intake

Command group: `planecli intake` (no alias)
Expand Down
2 changes: 2 additions & 0 deletions src/planecli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
)

# Import and register sub-apps
from planecli.commands.attachments import attachment_app # noqa: E402
from planecli.commands.cache_cmd import cache_app # noqa: E402
from planecli.commands.comments import comment_app # noqa: E402
from planecli.commands.cycles import cycle_app # noqa: E402
Expand All @@ -32,6 +33,7 @@

app.command(project_app)
app.command(wi_app)
app.command(attachment_app)
app.command(comment_app)
app.command(doc_app)
app.command(intake_app)
Expand Down
Loading
Loading