#!/bin/sh
# One-time bootstrap for the seedance-direct free-Higgsfield engine.
# Creates the local venv + installs deps + the Playwright browser. The runtime
# (.venv/ and .cloak-profile/) is git-ignored and never committed (see ADR 0006).
set -e
DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$DIR"

echo "[1/3] python venv"
[ -d .venv ] || python3 -m venv .venv
./.venv/bin/pip install -q --upgrade pip

echo "[2/3] deps (cloakbrowser, playwright, browser_cookie3)"
./.venv/bin/pip install -q -r requirements.txt

echo "[3/3] chromium for playwright/cloakbrowser"
./.venv/bin/python -m playwright install chromium

cat <<'NEXT'

Dependencies installed. This script does NOT turn free rendering on: it cannot
sign you in, so it deliberately writes no readiness file. Final step — import the
Higgsfield browser session. This reads your Chrome higgsfield.ai cookies and
opens a (headless) browser:

  ./.venv/bin/python bootstrap/find_cookies.py      # find the right Chrome profile
  ./.venv/bin/python bootstrap/import_cookies.py    # imports the session + writes its readiness file

Verify (offline, no browser/spend):
  HIGGS_VCLAW_TEST_STUB=1 ./.venv/bin/python test_adapter.py    # -> ALL TESTS PASS

videoclaw renders Seedance 2.0 free through your Higgsfield account only once
import_cookies.py has written <session>/.vclaw-engine-ready.json with
"loggedIn": true. Until then that route uses the paid API.
Confirm with: vclaw video providers   (activeTransport: in-tree-engine, no setupHint)
Ask for the paid API explicitly with VCLAW_SEEDANCE_DIRECT_NATIVE=1.
NEXT
