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
Address review: match whole shot ids when routing final items; sweep job.json temp files at startup
許元豪8eda5d5fe75a
diff --git a/app/server/final.ts b/app/server/final.tsindex ad06817..0516fb0 100644--- a/app/server/final.ts+++ b/app/server/final.ts@@ -25,6 +25,13 @@ function splitBySegment(id: string, must: MustFix): { local: Map<Chunk, Item[]>;return { local, global };}+// The items as a builder's per-shot issue list. Shot ids are matched whole: a substring test handed S10's item to S1 too.+export function shotIssues(items: Item[]): ShotEntry[] {+ const named = items.map((m) => ({ m, shots: new Set(String(m.shot || '').match(/S\d+/g) || []) }));+ return [...new Set(named.flatMap((x) => [...x.shots]))]+ .map((sid) => ({ id: sid, issues: named.filter((x) => x.shots.has(sid)).map(({ m }) => ({ issue: `${m.time != null ? `[${m.time}s] ` : ''}${m.issue}`, fix: m.fix })) }));+}+// Segment items go back to the builders who made them, all at once (their conversations still hold how each shot was// made). Real runs: the director fixing 9–12 items alone was the longest step after approval (14–17 min), and its edits// to shots it had not built brought back the very defect being fixed in another shot. Returns the fixes files for the@@ -34,9 +41,7 @@ async function fixSegments(id: string, local: Map<Chunk, Item[]>, round: number)const ids = [...local.keys()].map((c) => c.id);chat(id, 'system', L(id, `${ids.join('、')} 的必修交回各段的製作 agent 同時修,全片性的交給導演`, `Segment items go back to their builders (${ids.join(', ')}) in parallel; film-wide ones to the director`));const results = await Promise.all([...local.entries()].map(async ([c, items]) => {- const bad: ShotEntry[] = [...new Set(items.flatMap((m) => String(m.shot).match(/S\d+/g) || []))]- .map((sid) => ({ id: sid, issues: items.filter((m) => String(m.shot).includes(sid)).map((m) => ({ issue: `${m.time != null ? `[${m.time}s] ` : ''}${m.issue}`, fix: m.fix })) }));- const r = await turn(id, 'fix_chunk', { chunk: c, bad, round: `final-${round}`, final: true }, [`out/check/shots/${c.id}.fixes.json`], { session: `builder-${c.id}`, who: `builder-${c.id}` });+ const r = await turn(id, 'fix_chunk', { chunk: c, bad: shotIssues(items), round: `final-${round}`, final: true }, [`out/check/shots/${c.id}.fixes.json`], { session: `builder-${c.id}`, who: `builder-${c.id}` });return { c, r };}));const failed = results.find((x) => !x.r.ok);diff --git a/app/server/jobs.ts b/app/server/jobs.tsindex fdb81ef..742b803 100644--- a/app/server/jobs.ts+++ b/app/server/jobs.ts@@ -10,7 +10,7 @@// This file is the server's API over all of that: the user's actions, each one run as the project's single flow// (runner.ts), plus the project list and snapshot. Every review/fix gate shares one loop (review.ts); one agent turn is// turn.ts; job.json and helpers are store.ts.-import { appendFileSync, existsSync, mkdirSync, writeFileSync, readdirSync, cpSync } from 'node:fs';+import { appendFileSync, existsSync, mkdirSync, writeFileSync, readdirSync, cpSync, rmSync } from 'node:fs';import { extname, join, relative } from 'node:path';import { finalPanel } from './final.ts';import { openInputs, alignIfReadyWithNotice, requiredInputs } from './inputs.ts';@@ -111,8 +111,17 @@ export function setQuality(id: string, q: unknown): { upgrade: boolean } {return { upgrade };}+// A crash between writing job.json's temp file and renaming it leaves job.json.<pid>.tmp behind: swept at startup.+function sweepTempJobs() {+ for (const d of existsSync(PROJECTS) ? readdirSync(PROJECTS) : []) {+ const dir = dirOf(d);+ try { for (const f of readdirSync(dir)) if (/^job\.json\.\d+\.tmp$/.test(f)) rmSync(join(dir, f), { force: true }); } catch {}+ }+}+// On startup nothing is running, so a job still marked as working was cut off by a restart: say so instead of pretending.export function recoverOrphans(): string[] {+ sweepTempJobs();const cut: string[] = [];const WORK = ['analyzing', 'styling', 'planning', 'replanning', 'producing', 'revising', 'critiquing'];for (const d of readableJobs()) {diff --git a/app/server/pipeline.test.ts b/app/server/pipeline.test.tsindex 3a3f63d..32799cd 100644--- a/app/server/pipeline.test.ts+++ b/app/server/pipeline.test.ts@@ -380,6 +380,20 @@ describe('pauses', () => {});});+describe('final review routing', () => {+ test('items reach the shots they name, matched whole: S10 is not S1', async () => {+ const { shotIssues } = await import('./final.ts');+ const by = Object.fromEntries(shotIssues([{ shot: 'S1', issue: 'a' }, { shot: 'S10', issue: 'b' }, { shot: 'S11/S1', issue: 'c' }]).map((e) => [e.id, (e.issues || []).map((x) => x.issue)]));+ assert.deepEqual(by, { S1: ['a', 'c'], S10: ['b'], S11: ['c'] });+ });+ test('a job.json temp file left by a crash is swept at startup', () => {+ const id = newProject('plan_review'), tmp = join(J.dirOf(id), 'job.json.12345.tmp');+ writeFileSync(tmp, '{');+ J.recoverOrphans();+ assert.ok(!existsSync(tmp));+ });+});+describe('quality modes', () => {test('fast: a segment and a character at their limit carry on, and the film is delivered without pausing', async () => {S = base({ castPass: () => false, shotPass: (s) => s !== 'S2', critique: () => ({ must: 3 }) });