SPB Git

Repository Public

README.md 6.4 KB

# CLIP — Autonomous AI Cinema

https://clip.spboucher.ai — a small autonomous studio that conceives, writes, storyboards, shoots, narrates, edits, reviews and (after a human approval) publishes original short vertical films, with a public cinema to watch them and a private studio to run the production.

  • Public cinema: vertical feed, editorial home, film pages with provenance and sources, series, explore, search, English and French.
  • Private studio (/studio): Concept Lab, script and research, storyboard, prompt workbench, timeline, preview, automated QA, approval and release, programming, budgets, kill switch, audit log.
  • Production engine: an eight-stage pipeline on a durable queue, real xAI integrations (Grok LLM, Grok Imagine image and video, text to speech), FFmpeg assembly, idempotent and budgeted provider calls.

What is live and what is not is stated plainly in PROGRESS.md.

# Architecture in one picture

text
visitor ─▶ Caddy (TLS) ─▶ clip-web  (Next.js 16: cinema, studio, API, media with range)
                              │  enqueue                 ▲ read
                              ▼                          │
                         Redis (BullMQ) ──▶ clip-worker ─┼─▶ PostgreSQL 17
                                              │ FFmpeg   │
                                              ▼          │
                                   content-addressed asset store (disk)
                                              │
                                              ▼ HTTPS, server side only
                                   xAI: grok-4.7 · Grok Imagine · TTS      (+ Claude Code as director)
text
Idea → Pitches → Research → Script → Storyboard → Keyframes → Voice → Video → Assembly → QA → Approval → Release

Details: docs/architecture.md. Provider facts verified against the live API: docs/provider-capabilities.md. Money: docs/cost-model.md. Threat model: docs/security.md. Operations: docs/deployment.md.

# Repository map

Path What it holds
src/app/(public)/[locale]/ Public cinema (English at /, French at /fr)
src/app/studio/ Studio pages and server actions
src/app/api/ Public API, studio API, OpenAPI document (/api/openapi.json)
src/app/media/[file]/ Media delivery with HTTP range; public only for published films
src/providers/ Provider interfaces, xAI adapters, capability matrix, price table, HTTP layer (retries, breaker)
src/pipeline/ Stages, prompts (agent roles), provider-job wrapper (idempotency, budget, resume), FFmpeg, captions, QA, publication, orchestrator
src/worker/ Queue worker, programming scheduler, housekeeping, nightly backup
src/lib/ Contracts (Zod), auth, budget, storage, queue, search, i18n, taxonomy
db/migrations/ SQL schema
scripts/ Migrate, seed, owner bootstrap, operator CLIs, backup/restore, CI gate, secrets scan
tests/, e2e/ Unit tests (Vitest) and end-to-end tests (Playwright)

# Local setup

Requirements: Node 24+, pnpm, PostgreSQL 17, Redis, FFmpeg.

bash
pnpm install
createdb clip_dev
cp .env.example .env            # fill DATABASE_URL, ASSET_ROOT, APP_SECRET (openssl rand -hex 32), XAI_API_KEY, OWNER_EMAIL
pnpm migrate && pnpm seed
pnpm bootstrap:owner            # prints a one-time password, to be replaced at first sign-in
pnpm build && pnpm start        # web on http://localhost:8640
pnpm worker                     # in a second terminal

Sign in at /studio, replace the one-time password, turn on two-factor authentication in Account, then open the Concept Lab.

# Operator commands

bash
pnpm tsx scripts/provider-probe.ts          # live models and prices vs the compiled matrix (no paid call)
pnpm tsx scripts/produce.ts --theme "…" --series one-minute-ideas --lang fr --shots 4 --quality draft --until qa
pnpm tsx scripts/produce.ts --project <id> --publish --approver you@example.com
pnpm tsx scripts/kill-switch.ts on|off|status
scripts/backup.sh                           # database dump + asset copy (+ off-node rsync)
scripts/restore.sh ~/backups/clip-spboucher-ai   # restore drill into a scratch database
scripts/ci.sh                               # typecheck, lint, unit tests, build, secrets scan (+ e2e with PW_BASE_URL)

produce.ts runs the same stages inline, under the same budgets and idempotency rules as the worker. Publishing from the CLI still requires naming a studio user as approver: release is a human decision.

# Claude Code director

Studio → Director: type one idea and Claude Code directs the whole film. The worker runs claude -p on the node with three tools: ./clip (plan, keyframe, preview, render, voice, factcheck, assemble, qa, note), Read and Write. It looks at every image it produces, tests motion with cheap previews before the 1080p renders, and stops at QA: release stays a human decision. Requirements on the node: /opt/homebrew/bin/claude and an Anthropic API key in ~/.config/clip/anthropic-api-key (mode 600). CLI equivalent: pnpm tsx scripts/director-start.ts --idea "…" --lang fr --shots 5 --budget 15.

# How spending is controlled

  1. Every paid call goes through runProviderJob(): budget gate → atomic claim → provider → ledger.
  2. The gate enforces the kill switch and four ceilings (shot, film, day, month) on money spent plus money committed to running jobs. An unknown price blocks autonomous execution.
  3. The same input is paid for once: the idempotency key is a hash of (kind, model, input). Re-running a stage, double-clicking, or a worker restart reuses the stored result; a crashed video job resumes from its provider request_id.
  4. Regenerating a shot is explicit, counted, and capped; past the cap an owner must approve.
  5. Nothing loops: the scheduler has a daily quota, retries are bounded, and a failed QA never retries itself.

# Tests

bash
pnpm test                                   # unit: contracts, budget gate, pricing, captions, idempotency, SSRF allow-list…
PW_BASE_URL=https://clip.spboucher.ai pnpm test:e2e   # public cinema, API contract, studio access control

# Licence and content

Code: private. Films: AI-generated, © CLIP / Simon-Pierre Boucher. Voices are provider presets (no cloning); there is no third-party music; no real person is depicted.

Files main
Menu

Theme