#!/usr/bin/env node // Prints the image-edit request. It does not call any API. // Usage: node scripts/build-input.mjs --image https://... --subject "Video topic" [--expression "surprised"] [--accent "electric yellow"] import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' const root = join(dirname(fileURLToPath(import.meta.url)), '..') const options = {} const args = process.argv.slice(2) for (let index = 0; index < args.length; index += 1) { const key = args[index] if (!key.startsWith('--')) continue options[key.slice(2)] = args[index + 1] index += 1 } if (!options.image || !options.subject) { console.error('Usage: node scripts/build-input.mjs --image https://... --subject "Video topic" [--expression "..."] [--accent "..."]') process.exit(1) } if (!/^https:\/\//.test(options.image) && !/^data:image\//.test(options.image)) { console.error('The portrait must be a public https URL or image data URI.') process.exit(1) } const template = readFileSync(join(root, 'assets/prompt-template.md'), 'utf8').trim() const settings = JSON.parse(readFileSync(join(root, 'assets/generation-input.json'), 'utf8')) const prompt = template .replace('{{expression}}', options.expression ?? 'an alert, genuinely surprised expression') .replace('{{subject}}', options.subject) .replace('{{accent}}', options.accent ?? 'warm yellow') .replace(/\s{2,}/g, ' ') console.log(JSON.stringify({ model: settings.model, input: { ...settings.input, image_urls: [options.image], prompt }, }, null, 2))