a2aproject / a2aproject/a2a-cli
feat: add task download to save an agent's task artifacts to disk
- 主要語言
- Go
- 星號
- 95
- 分支
- 4
- 平均合併
- 3 天 2 小時
- 30 天內合併 PR
- 24
描述
**Goal:** Let a user save an agent's file artifacts to local disk with one command, instead of only seeing them summarised in the terminal.
**User story:** As a developer whose agent produced files, I want task download to save the artifacts to disk, so that I can use the generated files directly instead of extracting base64 from JSON by hand.
**Priority:** P2 · **Area:** CLI code
## Problem
The `task` command group covers `get`, `list`, `subscribe`, `cancel`, and `push-config`, but there is **no way to save a task's file artifacts to disk**. `task get` and `send` only render/report artifacts (and a file part currently shows as `[binary N bytes]`), so a caller who wants the actual bytes has no supported command.
`task download` does not exist today:
```
$ a2a task download --help
Work with tasks
Usage:
a2a task [command]
```
## Proposed behavior
Add `a2a task download ` that writes the task's artifacts to disk:
```
a2a task download [--output-dir ] [--artifact ]
```
- Writes each file artifact to `--output-dir` (default: current directory), using the artifact's name and media type; falls back to a safe generated name when none is provided.
- `--artifact ` (repeatable) downloads only the named artifact(s); default downloads all.
- Data/text artifacts are written too (e.g. `.json`/`.txt`), so nothing is silently skipped.
- Reports each path written; refuses to overwrite unless `--force` (or writes uniquely-named files).
- Works across transports and honours `-o json` (emit the list of written paths as structured output).
## Who benefits
- Developers pulling generated files (reports, images, data) from an agent without hand-parsing JSON.
- CI jobs that archive an agent's outputs as build artifacts.
- AI coding agents that need the produced files on disk to continue a workflow.
## Acceptance criteria
- [ ] `a2a task download ` writes all artifacts to disk and prints the paths.
- [ ] `--output-dir` and `--artifact` selection work.
- [ ] File artifacts use name + media type; collisions handled safely.
- [ ] `-o json` emits the written paths as structured output; exit code reflects success/failure.
- [ ] Tests cover: all-artifacts download, single `--artifact`, and a missing task.
## Environment
- CLI version: `a2a version v0.0.0-…1e29dfe94f95+dirty`
- OS: Linux x86_64
## Notes
`task list`, `task subscribe`, and `task push-config` already exist — this request is scoped to the one missing member of the group, `task download`. The rendering of file parts by name/media-type/size is tracked separately and complements this command.
貢獻指南
研究方向
Look at the existing `task` command implementations (like `get`, `list`) in the CLI codebase to understand the structure. The new `download` command will need to fetch task artifacts via the API and write them to disk. Start by examining how artifacts are represented in the task response and the existing file handling utilities. The acceptance criteria list the specific behaviors to implement and test.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- cli, go
- 領域
- cli
- Issue 類型
- 功能
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 65/100