Skip to content

Preflight Scripts

backfillAssetAnalysis.ts

Runs VLM analysis on character, environment, and prop images and stores the results on the image record (ImageMedia.imageAnalysis). Covers both variant images and top-level asset images — the same images the automatic triggers in WorkbenchService analyze on upload/generation. Use this to backfill projects whose images predate those triggers.

# Analyze all characters, environments, and props in a project
npx ts-node scripts/preflight/backfillAssetAnalysis.ts --projectId <id>

# Limit to one asset type
npx ts-node scripts/preflight/backfillAssetAnalysis.ts --projectId <id> --assetType character

# Target a specific asset/variant
npx ts-node scripts/preflight/backfillAssetAnalysis.ts --projectId <id> --assetId <id> --variantId <id>

# Options
--assetType  character|environment|prop (default: all three)
--batchSize  How many images to analyze concurrently, 1-20 (default: 1 = sequential)
--force      Re-analyze even if analysis already exists
--dryRun     Print what would be analyzed without calling the VLM

Notes: - Analyzes each variant's selected image (falling back to its latest image with a URL) and the asset's top-level selected/latest image. - Environment analysis gets the project's props as known objects and the combined project scripts as context, mirroring the runtime trigger. - 1s pause between batches of VLM calls as a basic rate limit. With the default --batchSize 1 this means fully sequential; higher values run that many images concurrently per batch (useful for large projects).