Show it a video you love. Get a new video in the same style. An AI crew (Claude Code or Codex) plans, builds and reviews it with you.
JavaScript 2d-animationai-agentsai-videoanimationclaude-codecodexmulti-agentstyle-transfervideo-generation
post-video: require a passed final review, fix the idempotency key, rename the script
許元豪02a5cfb950d2
diff --git a/README.md b/README.mdindex 4df381f..8c6296b 100644--- a/README.md+++ b/README.md@@ -131,7 +131,7 @@ committed. See [`secrets.example.json`](secrets.example.json) for the format.| `CODEX_SANDBOX` | Codex sandbox mode (default `danger-full-access`, like Claude Code with Bash allowed; `workspace-write` blocks the Chrome renderer) || `BUILDERS`, `MAX_AGENTS` | How many agents work on one video at once (default 6), and the limit across all projects (default 12) || `PORT` | Web port (default 4318) |-| `UPLOAD_POST_KEY`, `UPLOAD_POST_USER` | Optional. Post a finished video to TikTok, Instagram, YouTube and others with `npm run publish` (see below) |+| `UPLOAD_POST_KEY`, `UPLOAD_POST_USER` | Optional. Post a finished video to TikTok, Instagram, YouTube and others with `npm run post-video` (see below); `UPLOAD_POST_API` overrides the API address |### Posting the finished video (optional)@@ -139,11 +139,12 @@ ReelMimic never posts anything by itself. Once a project's final review is donesend it to your social accounts through [Upload-Post](https://upload-post.com) from the `app/` folder:```bash-npm run publish -- <project id> --platforms tiktok,instagram,youtube # dry run: shows what it would post-npm run publish -- <project id> --platforms tiktok --at 2026-10-05T18:00 --tz Europe/Madrid --send+npm run post-video -- <project id> --platforms tiktok,instagram,youtube # dry run: shows what it would post+npm run post-video -- <project id> --platforms tiktok --at 2026-10-05T18:00 --tz Europe/Madrid --send```-Without `--send` nothing leaves your computer. It only takes projects whose stage is `done`, uses the plan's title+Without `--send` nothing leaves your computer. It only takes projects whose final review passed (`--force` to post one+that stopped with must-fix items left), uses the plan's titleunless you pass `--title`, and a rerun of the same video won't post it twice.## Docsdiff --git a/app/package.json b/app/package.jsonindex 2f6a340..beed6cd 100644--- a/app/package.json+++ b/app/package.json@@ -12,7 +12,7 @@"test": "node --test --experimental-test-module-mocks \"server/**/*.test.ts\"","check": "npm run typecheck && npm run lint && npm test","doctor": "node scripts/doctor.mjs",- "publish": "node scripts/publish.mjs",+ "post-video": "node scripts/post-video.mjs","setup": "npm install && node scripts/doctor.mjs"},"dependencies": {diff --git a/app/scripts/publish.mjs b/app/scripts/post-video.mjssimilarity index 71%rename from app/scripts/publish.mjsrename to app/scripts/post-video.mjsindex e2318c1..723e2c8 100644--- a/app/scripts/publish.mjs+++ b/app/scripts/post-video.mjs@@ -1,9 +1,10 @@-// Optional: post a finished video to social platforms through Upload-Post (https://upload-post.com). npm run publish -- <project>-// Never runs on its own: nothing in the pipeline calls it, and it only takes a project whose final review is done.+// Optional: post a finished video to social platforms through Upload-Post (https://upload-post.com). npm run post-video -- <project>+// Never runs on its own: nothing in the pipeline calls it, and it only takes a project whose final review passed.// Without --send it is a dry run: it prints what it would post and sends nothing.-// npm run publish -- 20261003-ab12c --platforms tiktok,instagram,youtube-// npm run publish -- 20261003-ab12c --platforms tiktok --title "Bath Time" --at 2026-10-05T18:00 --tz Europe/Madrid --send+// npm run post-video -- 20261003-ab12c --platforms tiktok,instagram,youtube+// npm run post-video -- 20261003-ab12c --platforms tiktok --title "Bath Time" --at 2026-10-05T18:00 --tz Europe/Madrid --send// Needs UPLOAD_POST_KEY (an API key) and UPLOAD_POST_USER (the profile the accounts are connected to) in ~/.reelmimic/secrets.json.+// UPLOAD_POST_API overrides the API address (the key is sent there), e.g. for a staging server.// @ts-checkimport { createHash } from 'node:crypto';import { existsSync, openAsBlob, readFileSync, statSync } from 'node:fs';@@ -21,23 +22,30 @@ const readJSON = (p) => { try { return JSON.parse(readFileSync(p, 'utf8')); } caconst { values: o, positionals } = parseArgs({ allowPositionals: true, options: {platforms: { type: 'string' }, title: { type: 'string' }, description: { type: 'string' },- at: { type: 'string' }, tz: { type: 'string' }, send: { type: 'boolean', default: false },+ at: { type: 'string' }, tz: { type: 'string' }, send: { type: 'boolean', default: false }, force: { type: 'boolean', default: false },} });const id = positionals[0];-if (!id || !o.platforms) fail('usage: npm run publish -- <project id> --platforms tiktok,instagram [--title …] [--description …] [--at 2026-10-05T18:00 --tz Europe/Madrid] [--send]');+if (!id || !o.platforms) fail('usage: npm run post-video -- <project id> --platforms tiktok,instagram [--title …] [--description …] [--at 2026-10-05T18:00 --tz Europe/Madrid] [--send] [--force]');if (!/^[\w-]+$/.test(id)) fail(`not a project id: ${id}`);const dir = join(PROJECTS, id), job = readJSON(join(dir, 'job.json')), video = join(dir, 'out', 'video.mp4');if (!job) fail(`no such project: ${dir}`);// Only after the final review: a video still being produced or revised is not the one you approved.if (job.stage !== 'done') fail(`project is "${job.stage}", not "done". Publish only once the final review is finished`);+// "done" also means the final review stopped at its round limit with must-fix items left: require a pass, or --force.+if (!job.lastCritique?.pass) {+ const why = job.lastCritique ? `the final review did not pass (${job.lastCritique.must} must-fix item(s) left)` : 'no final review result on record';+ if (!o.force) fail(`${why}. Fix them first, or pass --force to post it anyway`);+ console.log(` [33m![0m ${why}; posting anyway (--force)`);+}if (!existsSync(video)) fail(`no final video at ${video}`);const platforms = String(o.platforms).split(',').map((p) => p.trim().toLowerCase()).filter(Boolean);const title = (o.title || readJSON(join(dir, 'plan.json'))?.title || job.title || '').trim();if (!title && platforms.includes('youtube')) fail('YouTube needs a title: pass --title');if (o.tz && !o.at) fail('--tz only applies with --at');-// Same project + same video file → same key, so a retried run never posts the video twice.-const st = statSync(video), idem = createHash('sha256').update(`${id}:${st.size}:${st.mtimeMs}:${platforms.join(',')}:${o.at || ''}`).digest('hex').slice(0, 32);+// Same project + video file + target (profile, platforms, time and time zone) → same key, so a retried run never posts the+// video twice, while correcting --tz (or --at) is a new request instead of silently returning the earlier schedule.+const st = statSync(video), idem = createHash('sha256').update(`${id}:${st.size}:${st.mtimeMs}:${process.env.UPLOAD_POST_USER || ''}:${platforms.join(',')}:${o.at || ''}:${o.tz || ''}`).digest('hex').slice(0, 32);const form = new FormData();form.append('user', process.env.UPLOAD_POST_USER || '');for (const p of platforms) form.append('platform[]', p);diff --git a/secrets.example.json b/secrets.example.jsonindex ddc24f2..1b96c65 100644--- a/secrets.example.json+++ b/secrets.example.json@@ -7,6 +7,6 @@"CODEX_BIN": "path to a specific codex CLI if an old one shadows it on PATH","BUILDERS": "parallel shot builders per video (default 5)","MAX_AGENTS": "agents running at once across all projects (default 10)",- "UPLOAD_POST_KEY": "optional: post finished videos with npm run publish (upload-post.com API key)",+ "UPLOAD_POST_KEY": "optional: post finished videos with npm run post-video (upload-post.com API key)","UPLOAD_POST_USER": "optional: the Upload-Post profile your social accounts are connected to"}