#!/usr/bin/env node // Writes the plan (stunt.json) for one giant-product street stunt: two 5 s shots (a wide establishing // shot, then a low-angle hero moment) of the user's product, giant, in a staged city street. // The shot prompts and sounds come filled from the stunt menu (assets/stunts.json); only the product // lock is left as FILL for the agent to write from the photo. // stunt.json is the single source of truth for build-requests.mjs and assemble-stunt.mjs. // // Usage: // node scripts/build-plan.mjs --out stunt.json --product "our running shoe" --photo shoe.jpg // --stunt billboard-burst|hill-roll|rooftop-park|tram-wrap|harbour-rise // [--street downtown|old-town|hill-street|tram-street|harbour-front|"free text"] // [--light golden-hour|overcast-day|bright-morning|blue-hour] [--colour "sage green"] // [--keep-logo yes|no] [--model kling|seedance] [--tag "AI-made"|off] // // A street from the menu is filled in for you; any other text is used as written (a type of street, never // a named place). Node 18 or newer. No npm packages. Calls no API. import { existsSync, readFileSync, writeFileSync } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' const FLAGS = new Set(['out', 'product', 'photo', 'stunt', 'street', 'light', 'colour', 'keep-logo', 'model', 'tag']) const root = join(dirname(fileURLToPath(import.meta.url)), '..') const menu = JSON.parse(readFileSync(join(root, 'assets', 'stunts.json'), 'utf8')) function fail(message) { console.error(message) process.exit(1) } const opts = {} const argv = process.argv.slice(2) for (let i = 0; i < argv.length; i++) { const a = argv[i] if (!a.startsWith('--')) fail(`Unexpected argument "${a}". Flags look like --name value.`) const key = a.slice(2) if (!FLAGS.has(key)) fail(`Unknown flag --${key}. Allowed: ${[...FLAGS].map((f) => `--${f}`).join(', ')}`) const value = argv[i + 1] if (value === undefined || value.startsWith('--')) fail(`--${key} needs a value.`) opts[key] = value i++ } const usage = 'Usage: node scripts/build-plan.mjs --out stunt.json --product "our running shoe" --photo shoe.jpg --stunt billboard-burst|hill-roll|rooftop-park|tram-wrap|harbour-rise [--street ...] [--light ...] [--colour ...] [--keep-logo yes|no] [--model kling|seedance] [--tag "AI-made"|off]' if (!opts.out || !opts.product || !opts.photo || !opts.stunt) fail(usage) if (!/\.json$/i.test(opts.out)) fail('--out must end in .json.') const stunt = menu.stunts[opts.stunt] if (!stunt) fail(`--stunt must be one of ${Object.keys(menu.stunts).join(', ')}, not "${opts.stunt}".`) if (!existsSync(opts.photo)) fail(`Product photo not found: ${opts.photo}. This Skill needs one photo of the product.`) if (!/\.(jpe?g|png|webp)$/i.test(opts.photo)) fail('--photo must be a .jpg, .png or .webp image.') // First filters, not the judge: look at the photo and the words yourself (references/safety-and-honesty.md). const PEOPLE = /\b(person|people|man|men|woman|women|girl|boy|child|children|kid|baby|model|celebrity|actor|actress|singer|athlete|player|politician)\b/i const LANDMARKS = /\b(times square|piccadilly|eiffel|big ben|statue of liberty|golden gate|tower bridge|brooklyn bridge|colosseum|sagrada|burj|shibuya|trafalgar|champs[- ]elys|las vegas strip|white house|red square|opera house|london eye|empire state|space needle|christ the redeemer|taj mahal|acropolis|brandenburg)\b/i const CITIES = /\b(new york|nyc|london|paris|tokyo|los angeles|san francisco|dubai|rome|berlin|sydney|hong kong|singapore)\b/i if (PEOPLE.test(opts.product)) fail(`"${opts.product}" reads as a person. This Skill is for a product with no people in the photo: crop them out, or describe only the product.`) const street = opts.street ?? stunt.default_street if (LANDMARKS.test(street) || CITIES.test(street)) fail(`"${street}" names a real landmark or city. Describe a type of street ("a narrow cobbled lane", "a wide avenue") so the clip cannot be read as a real event at a real place. See references/safety-and-honesty.md.`) const streetText = menu.streets[street] ?? street.replace(/[.]$/, '') const lightKey = opts.light ?? 'golden-hour' const light = menu.lights[lightKey] ?? (opts.light ? (/[.!?]$/.test(opts.light) ? opts.light : `${opts.light}.`) : null) if (!light) fail(`--light must be one of ${Object.keys(menu.lights).join(', ')} or a sentence of your own.`) const colour = (opts.colour ?? stunt.default_colour).replace(/[.]$/, '') const keepLogo = (opts['keep-logo'] ?? 'no').toLowerCase() if (!['yes', 'no'].includes(keepLogo)) fail('--keep-logo must be yes or no.') const model = opts.model ?? 'kling' if (!['kling', 'seedance'].includes(model)) fail(`--model must be kling or seedance, not "${model}".`) const tag = opts.tag ?? 'AI-made' if (tag.toLowerCase() !== 'off' && !/^[A-Za-z0-9 .,'&+-]{2,24}$/.test(tag)) fail('--tag takes 2 to 24 letters, numbers or simple punctuation (or "off"). The tag is drawn locally, never by the video model.') const plan = { brief: { product: opts.product, stunt: opts.stunt, street, light: lightKey, keep_logo: keepLogo === 'yes', final_model: model, final_resolution: '720p', tag: tag.toLowerCase() === 'off' ? 'off' : tag, }, locks: { product: 'FILL: the product\'s shape, proportions, parts and colours, written from the photo, with no logo, text or brand name (for example "a low-top running shoe with a rounded toe, a thick cushioned sole, lace eyelets and laces, in white with soft green side panels and a green sole edge")', scale: stunt.scale, street: streetText, light, colour, setpiece: stunt.setpiece.replaceAll('{{COLOUR}}', colour), look: menu.look, }, references: { photo: opts.photo }, shots: [ { n: 1, id: '01-wide', beat: 'wide', duration: 5, use_first_frame_ref: false }, { n: 2, id: '02-hero', beat: 'low-angle hero', duration: 5, use_first_frame_ref: true }, ].map((s, i) => ({ ...s, keyframe_prompt: stunt.shots[i].keyframe, motion_prompt: stunt.shots[i].motion, sound: stunt.shots[i].sound, keyframe: null, clip: null, in: 0.1, out: 5, })), } writeFileSync(opts.out, `${JSON.stringify(plan, null, 2)}\n`) console.log(`Wrote ${opts.out}: ${stunt.name} on ${street}, ${lightKey}, 2 shots of 5 s, final model ${model}, tag ${plan.brief.tag}.`) console.log('Next: write locks.product (the only FILL), check the prompts read well for this product, then run scripts/build-requests.mjs --plan', opts.out, '--stage estimate.') console.log(`Fit: ${stunt.name} suits ${stunt.best_for}. If the product is not like that, offer another stunt (references/stunt-menu.md).`) if (plan.brief.tag === 'off') console.log('Note: the AI-made tag is off. Only do this if the user asked, and tell them to post with the platform\'s AI label and a caption that says it is CGI.')