---
name: ci-artifacts
description: >
  Inspect and download the artifacts a GitLab CI job produced — coverage
  reports, build outputs, generated files, logs, screenshots. Use when the
  user says /ci-artifacts, 'télécharge les artefacts', 'récupère les artefacts',
  'les artefacts du job', 'download artifacts', 'get the artifact', 'le rapport de coverage',
  'récupère le fichier généré par la CI', or wants to pull a file a job left behind.
argument-hint: "[job URL or id]"
allowed-tools:
  - Read
  - Glob
  - Grep
  - Bash
  - Skill
---

Inspect and download a CI job's artifacts via the GitLab API.

## Required tools

- `glab`

Run `pysae-ai-tools tools require <tools>` before starting; if it exits non-zero, abort and report the install command from stderr to the user.

## How it works

All heavy lifting is handled by `pysae-ai-tools ci artifacts` — it resolves the job via `detect_context` (job URL or CI env vars) and calls the GitLab artifacts API. For **JUnit test results specifically, prefer `/ci-reports`** (it reads the parsed test report); use this skill for everything else.

## List what a job exposes

Always list first — it shows the artifact types (`archive`, `metadata`, `junit`, …), filenames, sizes and expiry, so you know what is downloadable and whether it has expired:

```bash
pysae-ai-tools ci artifacts list 987654
pysae-ai-tools ci artifacts list https://gitlab.com/grp/proj/-/jobs/987654
pysae-ai-tools ci artifacts list 987654 --json
```

## Download a single file

```bash
# Print a text file to stdout
pysae-ai-tools ci artifacts download 987654 --path coverage/coverage.xml

# Save it to disk (use for binaries)
pysae-ai-tools ci artifacts download 987654 --path build/app.bin --output /tmp/app.bin
```

## Download the whole archive

```bash
# Downloads the zip and unzips it (defaults to ./artifacts-<job_id>/)
pysae-ai-tools ci artifacts download 987654 --archive --dest /tmp/art
```

`--path` and `--archive` are mutually exclusive — pass exactly one.

## Report to the user

- After `list`, tell the user which files are available and their sizes.
- After a download, give the path where the file/archive landed and a one-line description of what it contains.
- If the job has no artifacts or they expired, say so plainly.

## Rules

- **French** for communication, English for commands
- **Never print artifact contents that may embed secrets** — env dumps, `.env` files, credentials baked into build output. Save to disk and inspect selectively, or mask tokens/passwords/API keys before displaying.
- Prefer downloading a single `--path` over the whole `--archive` when you know the file you need.
- For JUnit test results, delegate to `/ci-reports` instead of downloading the raw XML.

$ARGUMENTS
