#!/usr/bin/env bash

TOKEN="578edf8a8328fb37d6c32f56eb1450622db3492a"
BASE="https://git.sunamura-llc.com"
OWNER="openRepo"
REPO="AI-ART"
BRANCH="main"

OUT="manifest.json"

images_json=$(curl -s \
  -H "Authorization: token ${TOKEN}" \
  "${BASE}/api/v1/repos/${OWNER}/${REPO}/contents/images")

echo "{
  \"repo\": \"${OWNER}/${REPO}\",
  \"branch\": \"${BRANCH}\",
  \"readme\": \"${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/README.md\",
  \"task_template\": \"${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/prompts/task_template.md\",
  \"rules\": \"${BASE}/${OWNER}/${REPO}/raw/branch/${BRANCH}/.cursorrules\",
  \"images\": $(echo "$images_json" | jq '[.[] | {name: .name, url: .download_url}]')
}" > "${OUT}"

echo "✔ manifest.json generated"
