---
name: item-images
description: Use when finding and updating product images for items on the Chá do Martin wishlist. Triggers on "find image", "add image", "update image", or when an item is missing its imageUrl.
---

# Item Images — Chá do Martin

Finds a product image for a wishlist item via web search and patches it to the API.

## Config

- **Base URL**: `https://chadomartin.omeu.website`
- **Admin token**: read from `/home/adriano/chadebebe/.env` (key `ADMIN_TOKEN`)
- **Auth**: cookie `adm_token=<token>` sent with every request

## Instructions

1. Load the admin token:
   ```bash
   ADMIN_TOKEN=$(grep ADMIN_TOKEN /home/adriano/chadebebe/.env | cut -d= -f2)
   ```

2. Search the web for a clean product image. Good queries:
   - `"<item name> bebê" site:amazon.com.br`
   - `"<item name> newborn product photo"`
   - Try mitiendanube stores, newbiestore.com, or brand sites (burtsbeesbaby.com, halosleep.com, honestbabyclothing.com)

3. Find a direct image URL ending in `.jpg`, `.png`, or `.webp`.

4. Verify the URL returns an actual image:
   ```bash
   curl -sI "<IMAGE_URL>" | grep -i "content-type\|http/"
   # Must be HTTP 200 and content-type: image/*
   ```

5. PATCH the item:
   ```bash
   curl -s -X PATCH \
     "https://chadomartin.omeu.website/api/items/<ITEM_ID>" \
     -H "Content-Type: application/json" \
     -H "Cookie: adm_token=${ADMIN_TOKEN}" \
     -d '{"imageUrl": "<IMAGE_URL>"}'
   ```

6. Check response for `"success": true`.

## Listing items without images

```bash
ADMIN_TOKEN=$(grep ADMIN_TOKEN /home/adriano/chadebebe/.env | cut -d= -f2)
curl -s "https://chadomartin.omeu.website/api/wishlists/r7ug0ez62x7ljx8c870ofwcv/items" \
  -H "Cookie: adm_token=${ADMIN_TOKEN}" | python3 -c "
import json, sys
data = json.load(sys.stdin)
for it in sorted(data['items'], key=lambda x: x['sortOrder']):
    if not it['imageUrl']:
        print(it['id'], it['name'])
"
```

## Committing the DB snapshot after updates

Images are stored in the live SQLite DB (`/home/adriano/chadebebe/data/db/wishlist.db`).
After a batch of image updates, commit a snapshot:

```bash
sqlite3 /home/adriano/chadebebe/data/db/wishlist.db "PRAGMA wal_checkpoint(FULL);"
cp /home/adriano/chadebebe/data/db/wishlist.db /home/adriano/chadebebe/src/data/db/wishlist.db
cd /home/adriano/chadebebe/src
git add data/db/wishlist.db
git commit -m "chore: db snapshot with updated item images"
```

## Notes

- Do NOT use placeholder or stock photo URLs — find actual product images
- Prefer `.webp` or `.jpg` from CDNs (faster loading)
- Good CDN sources: `mitiendanube.com`, `newbiestore.com`, `burtsbeesbaby.com`, `halosleep.com`, `honestbabyclothing.com`
- Always verify HTTP 200 before patching — dead URLs show broken images to guests
- Run multiple items in parallel (background subagents, model: haiku) for speed
