Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

render the brief writer's cast through the shared canon renderer so reveal gates apply

[._.]/ Adam Eivy5d9b0b78c644
diff --git a/client/src/pages/CodeAnimation.jsx b/client/src/pages/CodeAnimation.jsx
index 6e05f8a15c..6a0f17e553 100644
--- a/client/src/pages/CodeAnimation.jsx
+++ b/client/src/pages/CodeAnimation.jsx
@@ -92,7 +92,9 @@ function toBriefIdeaInput(draft) {
onScreenText: draft.onScreenText,
styleNotes: draft.styleNotes,
},
- format: draft.format,
+ // The writer's prompt reads only these two — the rest of the format
+ // conditions the picture, not the story.
+ format: { durationSeconds: draft.format.durationSeconds, aspectRatio: draft.format.aspectRatio },
};
}
@@ -368,7 +370,7 @@ export default function CodeAnimation() {
<label htmlFor="ca-seed" className={labelClass}>
Starting idea <span className="text-gray-600">(optional; what the brief writer starts from)</span>
</label>
- <textarea id="ca-seed" rows={2} value={draft.seedIdea} maxLength={options?.briefLimits?.seedIdeaMax} onChange={(event) => update({ seedIdea: event.target.value })} placeholder="A chase through the lower market that ends in silence" className={`${inputClass} resize-y`} />
+ <textarea id="ca-seed" rows={2} value={draft.seedIdea} maxLength={limits?.seedIdeaMax} onChange={(event) => update({ seedIdea: event.target.value })} placeholder="A chase through the lower market that ends in silence" className={`${inputClass} resize-y`} />
<p className="mt-1 text-xs text-gray-500">
{draft.universeId
? 'Write brief casts the film from this universe\u2019s characters, places, and tone.'
diff --git a/client/src/pages/CodeAnimation.test.jsx b/client/src/pages/CodeAnimation.test.jsx
index 8a698f6790..844bdcc135 100644
--- a/client/src/pages/CodeAnimation.test.jsx
+++ b/client/src/pages/CodeAnimation.test.jsx
@@ -41,8 +41,7 @@ const OPTIONS = {
aspectRatios: ['16:9', '9:16'],
resolutions: ['720p', '1080p'],
renderers: ['auto', 'canvas2d'],
- limits: { durationMin: 3, durationMax: 180, fpsOptions: [24, 30, 60], referenceImagesMax: 8 },
- briefLimits: { seedIdeaMax: 2000 },
+ limits: { durationMin: 3, durationMax: 180, fpsOptions: [24, 30, 60], referenceImagesMax: 8, seedIdeaMax: 2000 },
messages: { ready: 'r', record: 'rec', recorded: 'done', progress: 'p', error: 'e' },
audioGlobal: 'ANIMATION_AUDIO_URL',
audioExtensions: ['mp3', 'wav'],
diff --git a/server/routes/codeAnimation.js b/server/routes/codeAnimation.js
index 5621261456..da1e88ec96 100644
--- a/server/routes/codeAnimation.js
+++ b/server/routes/codeAnimation.js
@@ -28,7 +28,6 @@ import {
CODE_ANIMATION_RENDERERS,
CODE_ANIMATION_RESOLUTIONS,
} from '../services/codeAnimation/prompt.js';
-import { CODE_ANIMATION_BRIEF_LIMITS } from '../services/codeAnimation/brief.js';
const router = Router();
const L = CODE_ANIMATION_LIMITS;
@@ -46,7 +45,7 @@ const formatSchema = z.object({
});
const briefSchema = z.object({
- title: z.string().trim().max(200).default(''),
+ title: z.string().trim().max(L.titleMax).default(''),
concept: z.string().trim().min(1, 'Describe what happens in the animation').max(L.conceptMax),
onScreenText: z.string().trim().max(L.textMax).default(''),
// Refinements on top of the universe style — the universe is the art direction.
@@ -84,14 +83,16 @@ const generateSchema = briefSchema.extend({
const briefIdeaSchema = z.object({
universeId: optionalId,
moodBoardId: optionalId,
- seedIdea: z.string().trim().max(CODE_ANIMATION_BRIEF_LIMITS.seedIdeaMax).default(''),
- current: z.object({
- title: z.string().trim().max(200).default(''),
- concept: z.string().trim().max(L.conceptMax).default(''),
- onScreenText: z.string().trim().max(L.textMax).default(''),
- styleNotes: z.string().trim().max(L.styleNotesMax).default(''),
- }).prefault({}),
- format: formatSchema.prefault({}),
+ seedIdea: z.string().trim().max(L.seedIdeaMax).default(''),
+ // The same brief, partially filled — derived from briefSchema so the field
+ // caps are stated once, with `concept` relaxed because there may be none yet.
+ current: briefSchema
+ .pick({ title: true, onScreenText: true, styleNotes: true })
+ .extend({ concept: z.string().trim().max(L.conceptMax).default('') })
+ .prefault({}),
+ // Only the two the writer's prompt reads — the renderer, fps, and resolution
+ // condition the picture, not the story.
+ format: formatSchema.pick({ durationSeconds: true, aspectRatio: true }).prefault({}),
providerId: z.string().trim().max(128).optional(),
model: z.string().trim().max(256).optional(),
effort: z.preprocess(emptyToNull, z.enum(EFFORT_LEVELS).nullable().optional()),
@@ -102,13 +103,7 @@ router.get('/options', (_req, res) => {
});
router.post('/brief', asyncHandler(async (req, res) => {
- const input = validateRequest(briefIdeaSchema, req.body ?? {});
- // With no world and no words the model has nothing to be faithful to, and a
- // blank-slate brief is not what this button is for.
- if (!input.universeId && !input.seedIdea && !input.current.concept && !input.current.title) {
- throw new ServerError('Pick a universe or describe a starting idea to write a brief from', { status: 400, code: 'BRIEF_INPUT_REQUIRED' });
- }
- res.json(await generateCodeAnimationBrief(input));
+ res.json(await generateCodeAnimationBrief(validateRequest(briefIdeaSchema, req.body ?? {})));
}));
router.post('/prompt', asyncHandler(async (req, res) => {
diff --git a/server/routes/codeAnimation.test.js b/server/routes/codeAnimation.test.js
index 3f84c0fadf..e85c215578 100644
--- a/server/routes/codeAnimation.test.js
+++ b/server/routes/codeAnimation.test.js
@@ -97,13 +97,11 @@ describe('POST /api/code-animation/brief', () => {
onScreenText: '0:02 "One light remains"',
styleNotes: 'colder blues at the climax',
});
- expect(res.body.moodBoardId).toBe('board-1');
- expect(res.body.llm).toEqual({ provider: 'api-1', model: 'example-model', runId: 'run-b' });
const call = runPromptThroughProvider.mock.calls[0][0];
expect(call.source).toBe('code-animation-brief');
expect(call.cwd).toBe(PATHS.data);
expect(call.prompt).toContain('a chase that ends in silence');
- expect(call.prompt).toContain('- Mira — role: lamplighter');
+ expect(call.prompt).toContain(' - Mira [lamplighter]: tall, oil-stained coat');
expect(call.prompt).toContain('Mood board: "Dusk"');
// The brief is text — no reference images are attached or named.
expect(call.screenshots).toBeUndefined();
diff --git a/server/services/codeAnimation/brief.js b/server/services/codeAnimation/brief.js
index 78e0bfc617..6f93b92072 100644
--- a/server/services/codeAnimation/brief.js
+++ b/server/services/codeAnimation/brief.js
@@ -18,92 +18,32 @@
import { isNonBlankStr, trimTo } from '../../lib/textUtils.js';
import { extractJson } from '../../lib/jsonExtract.js';
+import { renderCanonForPrompt } from '../../lib/universePromptRenderers.js';
import { ServerError } from '../../lib/errorHandler.js';
-import { CODE_ANIMATION_LIMITS, moodBoardSection } from './prompt.js';
-
-export const CODE_ANIMATION_BRIEF_LIMITS = Object.freeze({
- seedIdeaMax: 2_000,
- charactersMax: 10,
- placesMax: 6,
- objectsMax: 6,
- fieldMax: 600,
-});
-
-const B = CODE_ANIMATION_BRIEF_LIMITS;
-
-// The canon fields a 20-second animated film can actually act on: who someone
-// is, what they look like, what they want. Deliberately narrower than the
-// bible's full prompt-field set (`lib/storyBible.js#PROMPT_FIELDS`) — psychology
-// sliders, wardrobes, and relationship graphs would swamp the prompt without
-// changing a single frame.
-const CANON_FIELDS = Object.freeze({
- characters: ['role', 'physicalDescription', 'visualNotes', 'personality', 'motivations', 'coreTheme'],
- places: ['description', 'palette', 'timeOfDay', 'recurringDetails'],
- objects: ['description', 'significance'],
-});
-
-const stringField = (value) => {
- if (Array.isArray(value)) return trimTo(value.filter(isNonBlankStr).join(', '), B.fieldMax);
- return isNonBlankStr(value) ? trimTo(value, B.fieldMax) : '';
-};
-
-/**
- * Project one canon kind down to the named-entity lines the brief writer reads.
- * Entries with nothing but a name still make the list — the writer needs to
- * know the world HAS them.
- */
-export function projectCanonForBrief(entries, kind, cap) {
- const fields = CANON_FIELDS[kind] || [];
- return (Array.isArray(entries) ? entries : [])
- .filter((entry) => isNonBlankStr(entry?.name))
- .slice(0, cap)
- .map((entry) => {
- const projected = { name: trimTo(entry.name, 120) };
- for (const field of fields) {
- const value = stringField(entry[field]);
- if (value) projected[field] = value;
- }
- return projected;
- });
-}
-
-const canonBlock = (heading, rows) => {
- if (!rows.length) return '';
- const lines = rows.map((row) => {
- const { name, ...rest } = row;
- const detail = Object.entries(rest).map(([key, value]) => `${key}: ${value}`).join('; ');
- return detail ? `- ${name} — ${detail}` : `- ${name}`;
- });
- return `${heading}\n${lines.join('\n')}`;
-};
+import { CODE_ANIMATION_LIMITS, moodBoardSection, universeStyleLines } from './prompt.js';
function universeSection(universe) {
- if (!universe) return '';
const lines = [`The film is set in the universe "${universe.name}". Everything you write must be canon to it.`];
if (isNonBlankStr(universe.logline)) lines.push(`Logline: ${universe.logline}`);
if (isNonBlankStr(universe.premise)) lines.push(`Premise: ${universe.premise}`);
- if (universe.embrace?.length) lines.push(`Visual style to embrace: ${universe.embrace.join(', ')}`);
- if (universe.avoid?.length) lines.push(`Visual style to avoid: ${universe.avoid.join(', ')}`);
+ lines.push(...universeStyleLines(universe));
if (isNonBlankStr(universe.styleNotes)) lines.push(`Tone, staging, and pacing notes: ${universe.styleNotes}`);
- if (universe.styleReferences?.length) {
- lines.push('Style references curated for this universe:');
- lines.push(universe.styleReferences.map((ref) => `- ${ref.title ? `${ref.title}: ` : ''}${ref.prompt}`).join('\n'));
- }
return lines.join('\n');
}
+// The cast the film is drawn from. `renderCanonForPrompt` is the project-wide
+// canon→prompt block: it carries the per-kind formatting, the entry caps with
+// their "+N more" footer, and — the reason a local projection would be wrong —
+// the reveal gate, so a spoiler-flagged character's concealed history never
+// reaches a generation prompt.
function castSection(universe) {
- const blocks = [
- canonBlock('CHARACTERS (cast the film from these — use their names):', universe?.characters || []),
- canonBlock('PLACES (stage the film in these):', universe?.places || []),
- canonBlock('OBJECTS that matter in this world:', universe?.objects || []),
- ].filter(Boolean);
- if (!blocks.length) {
+ const canon = renderCanonForPrompt(universe, { respectRevealGates: true });
+ if (!canon) {
return universe
? 'This universe has no canon characters, places, or objects recorded yet — invent ones that fit its logline and tone, and keep the cast small.'
: '';
}
- return `${blocks.join('\n\n')}\n\nPrefer the canon above over inventing new entities. A character you use must behave, speak, and look as their entry describes.`;
+ return `CANON — cast the film from these and use their names:\n${canon}\n\nPrefer the canon above over inventing new entities. A character you use must behave, speak, and look as their entry describes.`;
}
function currentSection(current) {
@@ -121,7 +61,7 @@ function currentSection(current) {
* Build the prompt that asks a model to write an animation brief.
*
* @param {object} input
- * @param {object|null} [input.universe] - `{ name, logline, premise, embrace, avoid, styleNotes, styleReferences, characters, places, objects }`
+ * @param {object|null} [input.universe] - the resolved universe: style tokens plus `{ logline, premise, characters, places, objects }`
* @param {object|null} [input.moodBoard] - `collectBoardStyleContext` output
* @param {string} [input.seedIdea] - the artist's starting spark, if any
* @param {{ durationSeconds: number, aspectRatio: string }} input.format
@@ -140,12 +80,12 @@ export function buildCodeAnimationBriefPrompt({
`You are a short-film director and writer. Write the brief for a ${durationSeconds}-second ${aspectRatio} animated film that will be drawn entirely in code — procedural shapes, strokes, particles, and typography, with no photographic or hand-drawn assets. Write something a creative coder can actually stage: silhouettes, light, motion, and a handful of clear beats rather than dialogue, facial acting, or crowds.`,
];
if (isNonBlankStr(seedIdea)) {
- sections.push(`THE ARTIST'S SPARK — this is the film they want; honor it:\n${trimTo(seedIdea, B.seedIdeaMax)}`);
+ sections.push(`THE ARTIST'S SPARK — this is the film they want; honor it:\n${trimTo(seedIdea, CODE_ANIMATION_LIMITS.seedIdeaMax)}`);
+ }
+ if (universe) {
+ sections.push(`UNIVERSE:\n${universeSection(universe)}`);
+ sections.push(castSection(universe));
}
- const universeText = universeSection(universe);
- if (universeText) sections.push(`UNIVERSE:\n${universeText}`);
- const castText = castSection(universe);
- if (castText) sections.push(castText);
const boardText = moodBoardSection(moodBoard);
if (boardText) sections.push(boardText);
const currentText = currentSection(current);
@@ -184,7 +124,7 @@ export function extractBriefIdea(raw) {
});
}
return {
- title: briefField(value.title, 200),
+ title: briefField(value.title, CODE_ANIMATION_LIMITS.titleMax),
concept,
onScreenText: briefField(value.onScreenText, CODE_ANIMATION_LIMITS.textMax),
styleNotes: briefField(value.styleNotes, CODE_ANIMATION_LIMITS.styleNotesMax),
diff --git a/server/services/codeAnimation/brief.test.js b/server/services/codeAnimation/brief.test.js
index 4418848071..0b07468a45 100644
--- a/server/services/codeAnimation/brief.test.js
+++ b/server/services/codeAnimation/brief.test.js
@@ -1,9 +1,5 @@
import { describe, expect, it } from 'vitest';
-import {
- buildCodeAnimationBriefPrompt,
- extractBriefIdea,
- projectCanonForBrief,
-} from './brief.js';
+import { buildCodeAnimationBriefPrompt, extractBriefIdea } from './brief.js';
import { CODE_ANIMATION_LIMITS } from './prompt.js';
const FORMAT = { durationSeconds: 20, aspectRatio: '16:9' };
@@ -21,25 +17,6 @@ const UNIVERSE = {
objects: [{ name: 'The Brass Wick', significance: 'the last lamp that never gutters' }],
};
-describe('projectCanonForBrief', () => {
- it('keeps the named entities and the fields a film can stage, and caps the list', () => {
- const rows = projectCanonForBrief([
- { name: 'Mira', role: 'lamplighter', motivations: ['keep the lamps lit', 'find her brother'], sliders: { warmth: 3 }, id: 'chr-1' },
- { name: ' ', role: 'nobody' },
- { name: 'Corin' },
- { name: 'Vale' },
- ], 'characters', 2);
- expect(rows).toEqual([
- { name: 'Mira', role: 'lamplighter', motivations: 'keep the lamps lit, find her brother' },
- { name: 'Corin' },
- ]);
- });
-
- it('is empty for a universe with no canon of that kind', () => {
- expect(projectCanonForBrief(undefined, 'places', 6)).toEqual([]);
- });
-});
-
describe('buildCodeAnimationBriefPrompt', () => {
it('grounds the brief in the universe bible, its cast, and the artist\'s spark', () => {
const prompt = buildCodeAnimationBriefPrompt({
@@ -53,9 +30,9 @@ describe('buildCodeAnimationBriefPrompt', () => {
expect(prompt).toContain('a chase that ends in silence');
expect(prompt).toContain('The film is set in the universe "Example Universe"');
expect(prompt).toContain('Logline: A drowned city keeps its lamps lit');
- expect(prompt).toContain('- Mira — role: lamplighter; physicalDescription: tall, oil-stained coat');
- expect(prompt).toContain('- The Lower Market — description: flooded arcade of stalls');
- expect(prompt).toContain('- The Brass Wick — significance: the last lamp that never gutters');
+ expect(prompt).toContain(' - Mira [lamplighter]: tall, oil-stained coat');
+ expect(prompt).toContain(' - The Lower Market: flooded arcade of stalls');
+ expect(prompt).toContain(' - The Brass Wick (the last lamp that never gutters)');
expect(prompt).toContain('Mood board: "Dusk"');
expect(prompt).toContain('Title: The Brass Wick');
expect(prompt).toContain('"title": "..."');
@@ -67,13 +44,34 @@ describe('buildCodeAnimationBriefPrompt', () => {
format: FORMAT,
});
expect(prompt).toContain('no canon characters, places, or objects recorded yet');
- expect(prompt).not.toContain('CHARACTERS (');
+ expect(prompt).not.toContain('CANON —');
});
it('falls back to a blank-slate instruction with nothing to go on', () => {
const prompt = buildCodeAnimationBriefPrompt({ format: FORMAT });
expect(prompt).toContain('invent a striking, self-contained concept');
});
+
+ it('withholds a reveal-gated character\'s concealed canon', () => {
+ const prompt = buildCodeAnimationBriefPrompt({
+ universe: {
+ ...UNIVERSE,
+ characters: [{
+ name: 'Corin',
+ role: 'archivist',
+ spoiler: true,
+ surfaceDescriptor: 'a quiet clerk',
+ background: 'signed the order that drowned the city',
+ personality: 'remorseless',
+ }],
+ },
+ format: FORMAT,
+ });
+ expect(prompt).toContain('a quiet clerk');
+ expect(prompt).toContain('reveal-gated');
+ expect(prompt).not.toContain('signed the order that drowned the city');
+ expect(prompt).not.toContain('remorseless');
+ });
});
describe('extractBriefIdea', () => {
@@ -100,7 +98,7 @@ describe('extractBriefIdea', () => {
onScreenText: 'O'.repeat(CODE_ANIMATION_LIMITS.textMax + 100),
styleNotes: 'S'.repeat(CODE_ANIMATION_LIMITS.styleNotesMax + 100),
}));
- expect(parsed.title.length).toBe(200);
+ expect(parsed.title.length).toBe(CODE_ANIMATION_LIMITS.titleMax);
expect(parsed.concept.length).toBe(CODE_ANIMATION_LIMITS.conceptMax);
expect(parsed.onScreenText.length).toBe(CODE_ANIMATION_LIMITS.textMax);
expect(parsed.styleNotes.length).toBe(CODE_ANIMATION_LIMITS.styleNotesMax);
diff --git a/server/services/codeAnimation/index.js b/server/services/codeAnimation/index.js
index 2ee36627c0..261920ba3d 100644
--- a/server/services/codeAnimation/index.js
+++ b/server/services/codeAnimation/index.js
@@ -31,12 +31,6 @@ import {
CODE_ANIMATION_RENDERERS,
CODE_ANIMATION_RESOLUTIONS,
} from './prompt.js';
-import {
- buildCodeAnimationBriefPrompt,
- extractBriefIdea,
- projectCanonForBrief,
- CODE_ANIMATION_BRIEF_LIMITS,
-} from './brief.js';
const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif'];
const resolveUploadImage = makePathResolver(() => PATHS.uploads, { extensions: IMAGE_EXTENSIONS });
@@ -52,7 +46,6 @@ export function getCodeAnimationOptions() {
resolutions: Object.keys(CODE_ANIMATION_RESOLUTIONS),
renderers: CODE_ANIMATION_RENDERERS,
limits: CODE_ANIMATION_LIMITS,
- briefLimits: CODE_ANIMATION_BRIEF_LIMITS,
messages: CODE_ANIMATION_MESSAGES,
audioGlobal: CODE_ANIMATION_AUDIO_GLOBAL,
audioExtensions: UPLOAD_AUDIO_EXTENSIONS,
@@ -84,16 +77,18 @@ function fillReferences(candidates, slots) {
return images;
}
-// The narrative half of a universe — its bible text and canon cast. Only the
-// brief writer reads it: the coding prompt is art direction, and a logline or a
-// character's motivations would just crowd out the runtime contract.
+// The narrative half of a universe — its bible text and canon arrays, passed
+// through for `renderCanonForPrompt` to project. Only the brief writer reads
+// it: the coding prompt is art direction, and a logline or a character's
+// motivations would just crowd out the runtime contract.
function universeNarrative(universe) {
+ const { characters, places, objects } = universe;
return {
logline: trimTo(universe.logline, 2_000),
premise: trimTo(universe.premise, 4_000),
- characters: projectCanonForBrief(universe.characters, 'characters', CODE_ANIMATION_BRIEF_LIMITS.charactersMax),
- places: projectCanonForBrief(universe.places, 'places', CODE_ANIMATION_BRIEF_LIMITS.placesMax),
- objects: projectCanonForBrief(universe.objects, 'objects', CODE_ANIMATION_BRIEF_LIMITS.objectsMax),
+ characters,
+ places,
+ objects,
};
}
@@ -236,16 +231,27 @@ export async function buildCodeAnimationRequest(input, { delivery = 'copy' } = {
* way a series or story is generated from a universe. Synchronous — a few
* hundred words comes back inside one request, unlike the HTML generation.
*
- * Returns `{ brief, moodBoardId, llm }`; the client drops `brief` straight into
- * the form so the user can edit it before building the animation prompt.
+ * Returns `{ brief }`, which the client drops straight into the form so the
+ * user can edit it before building the animation prompt.
*/
export async function generateCodeAnimationBrief(input) {
+ // With no world and no words the model has nothing to be faithful to, and a
+ // blank-slate brief is not what this writer is for. The rule lives here, not
+ // in the route, so a non-HTTP caller gets it too.
+ const { title, concept } = input.current || {};
+ if (!input.universeId && !input.seedIdea && !concept && !title) {
+ throw new ServerError('Pick a universe or describe a starting idea to write a brief from', { status: 400, code: 'BRIEF_INPUT_REQUIRED' });
+ }
const { assertProvider, resolveProviderAndModel, runPromptThroughProvider } = await import('../promptRunner.js');
- const { provider, selectedModel } = await resolveProviderAndModel({ providerId: input.providerId, model: input.model });
+ const { buildCodeAnimationBriefPrompt, extractBriefIdea } = await import('./brief.js');
+ // Resolving the provider and loading the universe are independent — only the
+ // board depends on which universe came back. No image slots: the brief is
+ // text, and the style images are already the coding prompt's job.
+ const [{ provider, selectedModel }, universe] = await Promise.all([
+ resolveProviderAndModel({ providerId: input.providerId, model: input.model }),
+ resolveUniverse(input.universeId, { imageSlots: 0, narrative: true }),
+ ]);
assertProvider(provider, { message: 'No AI provider available to write the brief', code: 'PROVIDER_UNAVAILABLE', status: 400 });
- // No image slots: the brief is text, and the style images are already the
- // coding prompt's job.
- const universe = await resolveUniverse(input.universeId, { imageSlots: 0, narrative: true });
const moodBoardId = input.moodBoardId === undefined ? universe?.moodBoardId : input.moodBoardId;
const { board } = await resolveMoodBoard(moodBoardId, { imageSlots: 0 });
const prompt = buildCodeAnimationBriefPrompt({
@@ -268,7 +274,7 @@ export async function generateCodeAnimationBrief(input) {
});
const brief = extractBriefIdea(text);
console.log(`✅ Code animation brief written — runId=${runId || 'n/a'} concept=${brief.concept.length} chars`);
- return { brief, moodBoardId: moodBoardId || null, llm: { provider: provider.id, model: selectedModel || null, runId: runId || null } };
+ return { brief };
}
// Drop settled jobs past their TTL, then the oldest settled ones past the cap.
diff --git a/server/services/codeAnimation/prompt.js b/server/services/codeAnimation/prompt.js
index bc935b43e0..0ab7a2abae 100644
--- a/server/services/codeAnimation/prompt.js
+++ b/server/services/codeAnimation/prompt.js
@@ -57,6 +57,8 @@ export const CODE_ANIMATION_LIMITS = Object.freeze({
durationMin: 3,
durationMax: 180,
fpsOptions: [24, 30, 60],
+ titleMax: 200,
+ seedIdeaMax: 2_000,
conceptMax: 6_000,
textMax: 4_000,
styleNotesMax: 2_000,
@@ -85,6 +87,22 @@ export function resolveFrameSize(aspectRatio, resolution) {
const bulletList = (values) => values.map((value) => `- ${value}`).join('\n');
+/**
+ * The universe's curated style, as prompt lines. Shared with the brief writer
+ * so the two prompts describing one universe can't drift in what they show the
+ * model. Excludes the free-text `styleNotes`, which each caller frames itself.
+ */
+export function universeStyleLines(universe) {
+ const lines = [];
+ if (universe.embrace?.length) lines.push(`Visual style to embrace: ${universe.embrace.join(', ')}`);
+ if (universe.avoid?.length) lines.push(`Visual style to avoid: ${universe.avoid.join(', ')}`);
+ if (universe.styleReferences?.length) {
+ lines.push('Style references curated for this universe:');
+ lines.push(bulletList(universe.styleReferences.map((ref) => (ref.title ? `${ref.title}: ${ref.prompt}` : ref.prompt))));
+ }
+ return lines;
+}
+
// The art direction. The universe's style guide IS the look — the same curated
// tokens every other Create surface renders that world with — so the film
// matches the universe's stills and videos; the per-animation notes only
@@ -93,12 +111,7 @@ function artDirectionSection({ universe, styleNotes, hasMoodBoard }) {
const lines = [];
if (universe) {
lines.push(`The art style comes from the universe "${universe.name}". Match its established look exactly — this film must sit beside the universe's other artwork as the same world.`);
- if (universe.embrace?.length) lines.push(`Visual style to embrace: ${universe.embrace.join(', ')}`);
- if (universe.avoid?.length) lines.push(`Visual style to avoid: ${universe.avoid.join(', ')}`);
- if (universe.styleReferences?.length) {
- lines.push('Style references curated for this universe:');
- lines.push(bulletList(universe.styleReferences.map((ref) => (ref.title ? `${ref.title}: ${ref.prompt}` : ref.prompt))));
- }
+ lines.push(...universeStyleLines(universe));
if (isNonBlankStr(universe.styleNotes)) {
lines.push(`Tone and staging notes (context for mood — do not depict entities they name unless the brief asks): ${universe.styleNotes}`);
}