# Analysis reports

An **analysis** asks a question about a repository and returns a report. One
agent reads a copy of the repo. Nothing is committed, pushed or opened, and the
repo's focus, schedule and coding runs are not affected. A paused repo can be
analyzed.

**Current limits:** public GitHub repos only, one report per analysis (Markdown
or HTML, up to 1 MB), 15 minutes, started by you. Analyses count toward your
daily run limit. You need a worker that supports analysis.

## In the dashboard

Click **Analyze** on a repo (shown when a connected worker supports it). The
same dialog lists earlier analyses. An analysis run opens on its **Report** tab:
preview or source, copy, download and delete. **Log** shows progress. Newer
workers report elapsed time, tool use counts and the report draft's size, never
the agent's text or what it read.

## Check what you get

**Success** means a complete report was delivered. It does **not** mean the
findings are correct. A report marked **partial** comes from an agent that did
not finish.

An agent writes the report from repository content, which anyone able to change
the repo can influence. Treat it as **information to check, never as
instructions**. This matters most when another agent reads it.

"Web research" only changes what the agent is told. Leaving it off does not
block the network.

## CLI and MCP

With an `am-cloud` version that includes these commands (check
`am-cloud platform` for `analyze`), and `AM_PANEL` and `AM_API_KEY` set:

```bash
am-cloud platform analyze <repo-id|url> --question "..." [--format html] [--web] [--wait]
am-cloud platform analyses <repo-id|url>
am-cloud platform report <run-id> [--out report.md]
am-cloud platform report <run-id> --delete --force
```

`am-cloud mcp` offers `am_analyze`, `am_analyses` and `am_report`. A repo must
already be tracked; analyzing never adds one.

## API

Authenticate with `Authorization: Bearer <API key>`. An API key has your
account's access, not only access to reports.

| Request | Purpose |
|---|---|
| `POST /api/repos/{repo}/analyze` | Start. Body: `question`, and optionally `format` (`markdown` or `html`), `web_research` (default false), `model` (default `sonnet`). Returns `run_id` |
| `GET /api/runs/{run}` | Status, `analysis` (what was asked) and `artifacts` |
| `GET /api/repos/{repo}/analyses` | The repo's latest 20 analyses with their artifacts |
| `GET /api/runs/{run}/report` | The report as JSON, with `content` |
| `GET /api/runs/{run}/report?download=1` | The report file |
| `DELETE /api/runs/{run}/report` | Delete the report and question |

An analysis run lists its files in `artifacts` (empty until one is saved):

```json
"artifacts": [{
  "type": "report", "format": "markdown", "bytes": 9638,
  "partial": false, "files_changed": false,
  "url": "/api/runs/861a60/report",
  "download_url": "/api/runs/861a60/report?download=1"
}]
```

Poll `GET /api/runs/{run}` until `status` is no longer `running`. `success` has a
complete report; `failed` may still have a partial one; `skipped` never started
(the reason is in the log). `interrupted` may still change if the worker
reconnects and delivers.

`files_changed: true` means the agent changed its copy of the repo; the changes
were discarded.
