Publish or update an Artfly artifact via the API.

## Usage

- `/artfly` — publish new artifact from a file or pasted HTML
- `/artfly update <public_id>` — create a new version of an existing artifact

## How to run this skill

1. **Get the API key.** Check for `ARTFLY_API_KEY` in the environment:
   ```bash
   echo $ARTFLY_API_KEY
   ```
   If it's empty, tell the user: "Set `ARTFLY_API_KEY` in your environment or in `.env.local` at the Artfly project root, then run this again. You can create a key at https://artfly.com/settings"

2. **Get the HTML content.** If the user passed a file path in `$ARGUMENTS`, read that file. Otherwise, ask the user to paste the HTML or point to a file.

3. **Determine the base URL.** Default to `https://artfly.com`. Override with `ARTFLY_API_URL` env var if set (useful for local dev: `http://localhost:3000`).

4. **Call the API:**

   **Create new artifact** (no `update <public_id>` in `$ARGUMENTS`):
   ```bash
   curl -s -X POST "$ARTFLY_API_URL/api/v1/artifacts" \
     -H "Authorization: Bearer $ARTFLY_API_KEY" \
     -H "Content-Type: application/json" \
     -d "$(jq -n --arg html "$(cat PATH_TO_HTML)" --arg title "TITLE" \
       '{html: $html, title: $title}')"
   ```

   **Update existing artifact** (user ran `/artfly update abc123xyz`):
   ```bash
   curl -s -X PUT "$ARTFLY_API_URL/api/v1/artifacts/PUBLIC_ID" \
     -H "Authorization: Bearer $ARTFLY_API_KEY" \
     -H "Content-Type: application/json" \
     -d "$(jq -n --arg html "$(cat PATH_TO_HTML)" --arg title "TITLE" \
       '{html: $html, title: $title}')"
   ```

5. **Parse the response** and show the user:
   - The artifact URL (field `url` in the JSON response)
   - The `public_id` (save it — the user will need it for future `/artfly update <public_id>` calls)
   - If updating: the new `version_number`

6. **On error**, show the `error.message` from the response and suggest fixes:
   - `UNAUTHENTICATED` → API key is wrong or missing
   - `PAYLOAD_TOO_LARGE` → HTML exceeds 10 MB
   - `ARTIFACT_NOT_FOUND` → wrong public_id; list their artifacts with `GET /api/v1/artifacts`

## Tips

- Use `jq` to safely encode HTML into JSON — never use string interpolation, as HTML contains quotes and special characters.
- If `jq` is not installed, write the HTML to a temp file and use Python: `python3 -c "import json,sys; print(json.dumps({'html': open(sys.argv[1]).read(), 'title': sys.argv[2]}))" file.html "Title"`.
- To list existing artifacts: `curl -s "$ARTFLY_API_URL/api/v1/artifacts" -H "Authorization: Bearer $ARTFLY_API_KEY" | jq '.artifacts[] | {public_id, title, url}'`
