multica/server/internal/cli
devv-eve 8eb1caa72b
fix(agent): instruct agents to use download_url for attachments (#356)
* fix(agent): instruct agents to use download_url for attachments

Agents were not aware of the signed vs unsigned URL distinction in
attachments, causing failures when trying to read images. Added an
Attachments section to the generated CLAUDE.md/AGENTS.md template that
tells agents to always use `download_url`. Also increased signed URL
expiry from 5 to 30 minutes to better accommodate agent processing time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(cli): add `multica attachment download` command

Adds a dedicated CLI command for downloading attachments by ID. The
command fetches attachment metadata from the API (which returns a fresh
signed URL), downloads the file, and saves it locally. This eliminates
the need for agents to understand signed vs unsigned URLs.

Changes:
- New `multica attachment download <id>` CLI command
- New `GET /api/attachments/{id}` backend endpoint
- `DownloadFile` helper on APIClient
- Updated CLAUDE.md template to document the command

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(cli): sanitize filename and add download size limit

- Use filepath.Base on attachment filename to prevent path traversal
- Add 100MB size limit to DownloadFile (matches upload limit)
- Include response body in download error messages for debugging

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Devv <devv@Devvs-Mac-mini.local>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:45:42 -07:00
..
client.go fix(agent): instruct agents to use download_url for attachments (#356) 2026-04-02 07:45:42 -07:00
client_test.go test(cli): add unit tests for PostJSON API client method 2026-03-26 15:04:50 +08:00
config.go feat(daemon): add --profile flag for multi-environment isolation 2026-03-30 20:21:23 +08:00
flags.go refactor(cli): unify daemon into multica-cli binary with cobra subcommands 2026-03-24 15:44:49 +08:00
output.go refactor(cli): unify daemon into multica-cli binary with cobra subcommands 2026-03-24 15:44:49 +08:00
update.go feat(daemon): support direct download update for non-Homebrew installs (#334) 2026-04-02 15:38:06 +08:00