CLI/MCP: first-class image & file attachments on issues + comments
## Problem The CLI ships `pgai issues files upload <path>` and `pgai issues files download <url>` (storage primitives), but the four issue/comment commands — `create`, `update`, `post-comment`, `update-comment` — accept text only. Adding a screenshot to a comment is currently a 2-step manual dance: upload, copy markdown, paste into a follow-up command. Worse, the **MCP server** has no file tools at all. AI agents using the postgresai MCP can post text comments but cannot attach screenshots, EXPLAIN diagrams, flame graphs, or any other file. The MCP server has `list_report_files` / `get_report_data` but those are for *checkup reports*, not for arbitrary issue attachments. This blocks AI workflows that produce visual output (screenshots, plots, diagrams) and want to land them in the right issue thread. ## Resolution Implemented in !N (this MR will be linked): **CLI** — new repeatable `--attach <path>` flag on: - `pgai issues create` - `pgai issues post-comment` - `pgai issues update` (when --description is omitted, fetches existing description and appends — one-step "add a screenshot to issue X") - `pgai issues update-comment` Each path is uploaded via the existing storage service; the resulting markdown link is appended to the body. Image extensions (.png/.jpg/.jpeg/.gif/.webp/.svg/.bmp/.ico) render inline (`![]()`); other types render as plain links (`[]()`). **MCP server** — new tools and parameters: - `upload_file({path})` — uploads, returns URL + ready-to-paste markdown link. - `download_file({url, output_path?})` — symmetric download. - New `attachments: string[]` parameter (local file paths) on `post_issue_comment`, `create_issue`, `update_issue`, `update_issue_comment` — server-side does upload-then-append. For `update_issue` with `attachments` and no `description`, fetches existing description and appends. Both surfaces share helpers in `lib/storage.ts` (`uploadAttachments`, `appendAttachmentsToContent`) so output is identical regardless of which path the user / agent takes. ## Acceptance criteria - [ ] `--attach` flag accepted (and repeatable) on all four issue/comment CLI commands - [ ] Comment / description content shows the markdown link with the right rendering form (image vs file) - [ ] `update --attach` without `--description` preserves the existing description and appends - [ ] MCP `upload_file` and `download_file` tools surface in `tools/list` - [ ] MCP issue/comment tools accept `attachments` and produce content identical to the CLI flag - [ ] Unit tests with mocked fetch + real tmp files cover the helpers, the CLI flag, and the MCP integration - [ ] Live smoke test against production team org confirms end-to-end flow (issue + comment lifecycle, image + log attachments, download round-trip)
issue