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

feat(universe-builder): merge style/negative prompts into embrace/avoid chip editor

[._.]/ Adam Eivyfb5d1f68553a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index cab0009a87..a83f317504 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,11 +2,12 @@
## Added
-- **Universe Builder — per-category "Generate N more" variations.** Each category card now has a Generate dropdown (3 / 5 / 10 / custom up to 50) next to the existing Render / + Add buttons. The LLM is given the universe's bible context (logline, premise, style notes, influences, stylePrompt) plus the list of existing labels to skip, and returns N additional variations that get appended to the category. Locked items are unaffected — Generate is purely additive. Auto-saves when the universe is already persisted; otherwise hands you a "review then Save" toast. New endpoint: `POST /api/universe-builder/generate-variations`.
+- **Universe Builder — per-category "Generate N more" variations.** Each category card now has a Generate dropdown (3 / 5 / 10 / custom up to 50) next to the existing Render / + Add buttons. The LLM is given the universe's bible context (logline, premise, style notes, influences) plus the list of existing labels to skip, and returns N additional variations that get appended to the category. Locked items are unaffected — Generate is purely additive. Auto-saves when the universe is already persisted; otherwise hands you a "review then Save" toast. New endpoint: `POST /api/universe-builder/generate-variations`.
## Changed
- **Pipeline series arc — inline theme editing.** Theme pills on the Series Arc card are now directly editable: click a pill to rename, hover for the × to remove, click the dashed "+ Add theme" chip to append (up to 20 themes, 100 chars each — matching `ARC_LIMITS` on the server). Writes are optimistic with a single-flight save gate so a blur-then-click sequence can't double-persist against stale state. The redundant comma-separated themes input was removed from the "Edit arc" form; logline / summary / protagonist arc / shape still live there.
+- **Universe Builder — unify style/negative prompts with the embrace/avoid chip editor.** The prose `stylePrompt` and `negativePrompt` textareas have been removed; the universe's style + negative prompts now live as draggable token lists in `influences.embrace` / `influences.avoid` and are the single editing surface (relabeled in the UI as "Style prompt (embrace)" and "Negative prompt (avoid)"). The renderer joins each list verbatim into the rendered prompt the same way the prose fields used to compose. Existing universes auto-migrate on first read: prose tokens are split on commas, deduped case-insensitively against any pre-existing chips, capped at 30 per list, and persisted (`schemaVersion` bumped to 3). The LLM expand + refine flows now emit `influences` only — no more separate `stylePrompt`/`negativePrompt` keys. Stale-client PATCH payloads still carrying prose fields are absorbed into the chip lists server-side so a stale browser tab doesn't 400.
## Fixed
diff --git a/client/src/components/universeBuilder/InfluenceChipsInput.jsx b/client/src/components/universeBuilder/InfluenceChipsInput.jsx
index 613f9269a4..bde0d024e1 100644
--- a/client/src/components/universeBuilder/InfluenceChipsInput.jsx
+++ b/client/src/components/universeBuilder/InfluenceChipsInput.jsx
@@ -25,14 +25,15 @@ const TONE_CLASS = {
};
/**
- * Chip input for an influence list (embrace or avoid). Used by both the
- * inline Universe Builder editor and the Refine modal — extracting one
- * implementation keeps Enter/comma/paste/Backspace behavior, dedupe rules,
- * per-entry caps, and drag-to-reorder in lockstep across both surfaces.
+ * Chip input for the style-prompt (embrace) or negative-prompt (avoid) token
+ * list. Used by both the inline Universe Builder editor and the Refine modal
+ * — extracting one implementation keeps Enter/comma/paste/Backspace behavior,
+ * dedupe rules, per-entry caps, and drag-to-reorder in lockstep across both
+ * surfaces.
*
- * Order is meaningful: the renderer prepends embrace + avoid to
- * stylePrompt/negativePrompt verbatim, so dragging a chip toward the front
- * gives it priority in the rendered prompt.
+ * Order is meaningful: the renderer joins each list verbatim into the
+ * positive / negative prompt, so dragging a chip toward the front gives it
+ * priority in the rendered prompt.
*
* `readOnly` collapses the editor to a plain chip preview (no input, no X
* buttons, no drag handles) so locked influences render with the same chrome.
diff --git a/client/src/lib/joinInfluenceList.js b/client/src/lib/joinInfluenceList.js
new file mode 100644
index 0000000000..810651f4c0
--- /dev/null
+++ b/client/src/lib/joinInfluenceList.js
@@ -0,0 +1,8 @@
+// Mirror of `joinInfluenceList` in server/services/universeBuilder.js — keep
+// in sync. Joins a universe's chip-token list (embrace OR avoid) into the
+// comma-separated string the renderer's composeStyledPrompt consumes.
+// Tokens are already deduped + capped at write time, so this is a thin join.
+export function joinInfluenceList(structured = []) {
+ if (!Array.isArray(structured)) return '';
+ return structured.filter((t) => typeof t === 'string' && t.trim()).join(', ');
+}
diff --git a/client/src/pages/UniverseBuilder.jsx b/client/src/pages/UniverseBuilder.jsx
index 01a49dd055..9b5c422ccb 100644
--- a/client/src/pages/UniverseBuilder.jsx
+++ b/client/src/pages/UniverseBuilder.jsx
@@ -111,8 +111,6 @@ const compositeKindLabel = (kind) => COMPOSITE_BOARD_KINDS.find((k) => k.value =
const emptyTemplate = () => ({
name: '',
starterPrompt: '',
- stylePrompt: '',
- negativePrompt: '',
logline: '',
premise: '',
styleNotes: '',
@@ -159,42 +157,41 @@ function FieldLabel({ htmlFor, children, field, locked, onToggleLock }) {
);
}
-// Two-column embrace + avoid editor with a single shared lock toggle.
-// Sits in the Story bible section so the writers + creative directors can
-// pin canonical references that the renderer then prepends deterministically
-// to stylePrompt / negativePrompt.
-function InfluencesEditor({ influences, onChange, locked, onToggleLock }) {
+// Style prompt + Negative prompt editor — two parallel chip lists. Embrace
+// tokens become the positive style prompt prepended to every render; avoid
+// tokens become the negative prompt. Each list locks independently.
+function StyleNegativePromptEditor({ influences, onChange, locked, onToggleLock }) {
const safe = ensureInfluences(influences);
return (
<div>
<div className="mb-1">
<label className="text-xs text-gray-400">
- Influences <span className="text-gray-600">— appended to style/negative prompts at render time; embrace + avoid lock independently</span>
+ Style + Negative prompts <span className="text-gray-600">— prepended to every render; drag to reorder, click × to remove</span>
</label>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div>
<div className="flex items-center justify-between gap-2 mb-1">
- <div className="text-[11px] uppercase tracking-wide text-port-success/80">Embrace</div>
- <LockButton field="influencesEmbrace" locked={locked} onToggle={onToggleLock} label="Embrace influences" />
+ <div className="text-[11px] uppercase tracking-wide text-port-success/80">Style prompt (embrace)</div>
+ <LockButton field="influencesEmbrace" locked={locked} onToggle={onToggleLock} label="Style prompt" />
</div>
<InfluenceChipsInput
tokens={safe.embrace}
onChange={(next) => onChange({ ...safe, embrace: next })}
- placeholder="Moebius, cel-shading…"
+ placeholder="moebius linework, cel-shading, dust palette…"
tone="success"
readOnly={!!locked?.influencesEmbrace}
/>
</div>
<div>
<div className="flex items-center justify-between gap-2 mb-1">
- <div className="text-[11px] uppercase tracking-wide text-port-error/80">Avoid</div>
- <LockButton field="influencesAvoid" locked={locked} onToggle={onToggleLock} label="Avoid influences" />
+ <div className="text-[11px] uppercase tracking-wide text-port-error/80">Negative prompt (avoid)</div>
+ <LockButton field="influencesAvoid" locked={locked} onToggle={onToggleLock} label="Negative prompt" />
</div>
<InfluenceChipsInput
tokens={safe.avoid}
onChange={(next) => onChange({ ...safe, avoid: next })}
- placeholder="Ghibli painterly, neon cyberpunk…"
+ placeholder="blurry, lowres, watermark, neon cyberpunk…"
tone="error"
readOnly={!!locked?.influencesAvoid}
/>
@@ -355,8 +352,6 @@ export default function UniverseBuilder() {
const payload = {
name: draft.name.trim(),
starterPrompt: draft.starterPrompt || '',
- stylePrompt: draft.stylePrompt || '',
- negativePrompt: draft.negativePrompt || '',
logline: draft.logline || '',
premise: draft.premise || '',
styleNotes: draft.styleNotes || '',
@@ -431,8 +426,6 @@ export default function UniverseBuilder() {
logline: draft.logline || '',
premise: draft.premise || '',
styleNotes: draft.styleNotes || '',
- stylePrompt: draft.stylePrompt || '',
- negativePrompt: draft.negativePrompt || '',
locked: draft.locked || {},
preservedVariations,
preservedCompositeSheets,
@@ -450,8 +443,8 @@ export default function UniverseBuilder() {
// protects the user's edits.
const locks = draft.locked || {};
// Distinguish "LLM omitted the field" (null/undefined → keep draft) from
- // "LLM returned empty string" (negativePrompt is a legitimate "" — the
- // user's `||` would silently restore a stale value they wanted gone).
+ // "LLM returned empty string" (a legitimate "" — the user's `||` would
+ // silently restore a stale value they wanted gone).
const pick = (key, llmValue) => {
if (locks[key]) return draft[key];
return llmValue == null ? draft[key] : llmValue;
@@ -485,8 +478,6 @@ export default function UniverseBuilder() {
const expandedDraft = {
...draft,
starterPrompt: pick('starterPrompt', result.starterPrompt),
- stylePrompt: pick('stylePrompt', result.stylePrompt),
- negativePrompt: pick('negativePrompt', result.negativePrompt),
logline: pick('logline', result.logline),
premise: pick('premise', result.premise),
styleNotes: pick('styleNotes', result.styleNotes),
@@ -512,8 +503,6 @@ export default function UniverseBuilder() {
const updated = await updateUniverse(selectedId, {
name: expandedDraft.name.trim(),
starterPrompt: expandedDraft.starterPrompt || '',
- stylePrompt: expandedDraft.stylePrompt || '',
- negativePrompt: expandedDraft.negativePrompt || '',
logline: expandedDraft.logline || '',
premise: expandedDraft.premise || '',
styleNotes: expandedDraft.styleNotes || '',
@@ -561,8 +550,6 @@ export default function UniverseBuilder() {
const updated = await updateUniverse(selectedId, {
name: next.name.trim(),
starterPrompt: next.starterPrompt || '',
- stylePrompt: next.stylePrompt || '',
- negativePrompt: next.negativePrompt || '',
logline: next.logline || '',
premise: next.premise || '',
styleNotes: next.styleNotes || '',
@@ -604,8 +591,6 @@ export default function UniverseBuilder() {
setRefineChanges([]);
const result = await refineWorldPrompts({
starterPrompt: draft.starterPrompt || '',
- stylePrompt: draft.stylePrompt || '',
- negativePrompt: draft.negativePrompt || '',
logline: draft.logline || '',
premise: draft.premise || '',
styleNotes: draft.styleNotes || '',
@@ -735,8 +720,6 @@ export default function UniverseBuilder() {
logline: draft.logline || '',
premise: draft.premise || '',
styleNotes: draft.styleNotes || '',
- stylePrompt: draft.stylePrompt || '',
- negativePrompt: draft.negativePrompt || '',
providerId: draft.llm?.provider || undefined,
model: draft.llm?.model || undefined,
}, { silent: true }).catch((e) => { toast.error(`Generate failed: ${e.message}`); return null; });
@@ -1112,7 +1095,7 @@ export default function UniverseBuilder() {
/>
</div>
</div>
- <InfluencesEditor
+ <StyleNegativePromptEditor
influences={draft.influences}
onChange={(next) => updateDraft({ influences: next })}
locked={draft.locked}
@@ -1120,39 +1103,6 @@ export default function UniverseBuilder() {
/>
</section>
- {/* Style template */}
- <section className="bg-port-card border border-port-border rounded p-4 grid grid-cols-1 md:grid-cols-2 gap-3">
- <div>
- <div className="flex items-center justify-between gap-2 mb-1">
- <label className="text-xs text-gray-400 flex items-center gap-1">
- <Sparkles size={12} /> Style prompt (prepended to every variation)
- </label>
- <LockButton field="stylePrompt" locked={draft.locked} onToggle={toggleLock} label="Style prompt" />
- </div>
- <textarea
- value={draft.stylePrompt}
- onChange={(e) => updateDraft({ stylePrompt: e.target.value })}
- placeholder="moebius linework, scavengers reign palette, oil-on-canvas grain, cinematic lighting…"
- className="w-full bg-port-bg border border-port-border rounded px-3 py-2 text-white text-sm focus:outline-none focus:border-port-accent"
- rows={4}
- maxLength={2000}
- />
- </div>
- <div>
- <FieldLabel field="negativePrompt" locked={draft.locked} onToggleLock={toggleLock}>
- Negative prompt
- </FieldLabel>
- <textarea
- value={draft.negativePrompt}
- onChange={(e) => updateDraft({ negativePrompt: e.target.value })}
- placeholder="blurry, lowres, watermark, extra fingers…"
- className="w-full bg-port-bg border border-port-border rounded px-3 py-2 text-white text-sm focus:outline-none focus:border-port-accent"
- rows={4}
- maxLength={2000}
- />
- </div>
- </section>
-
<CompositeSheetsEditor
sheets={draft.compositeSheets || []}
onChange={updateCompositeSheets}
diff --git a/client/src/pages/UniverseCanon.jsx b/client/src/pages/UniverseCanon.jsx
index acd432ae38..e7efe923cf 100644
--- a/client/src/pages/UniverseCanon.jsx
+++ b/client/src/pages/UniverseCanon.jsx
@@ -35,6 +35,14 @@ import {
readPipelineImageSettings,
pipelineImageCfgToRenderOpts,
} from '../lib/pipelineImageDefaults';
+import { joinInfluenceList } from '../lib/joinInfluenceList';
+
+const universeStylePreset = (universe) => {
+ const embrace = joinInfluenceList(universe?.influences?.embrace);
+ const avoid = joinInfluenceList(universe?.influences?.avoid);
+ if (!embrace && !avoid) return null;
+ return { prompt: embrace, negativePrompt: avoid };
+};
const KINDS = [
{
@@ -200,7 +208,7 @@ export default function UniverseCanon() {
const styled = composeStyledPrompt(
`${entry.name}: ${description}`,
baseOpts.negativePrompt || '',
- universe ? { prompt: universe.stylePrompt, negativePrompt: universe.negativePrompt } : null,
+ universe ? universeStylePreset(universe) : null,
);
const queued = await generateImage({
...baseOpts,
@@ -225,7 +233,7 @@ export default function UniverseCanon() {
const styled = composeStyledPrompt(
plate.prompt,
plate.negativePrompt,
- universe ? { prompt: universe.stylePrompt, negativePrompt: universe.negativePrompt } : null,
+ universe ? universeStylePreset(universe) : null,
);
const queued = await generateImage({
...baseOpts,
diff --git a/client/src/services/apiUniverseBuilder.js b/client/src/services/apiUniverseBuilder.js
index b371c99911..a67267cab3 100644
--- a/client/src/services/apiUniverseBuilder.js
+++ b/client/src/services/apiUniverseBuilder.js
@@ -34,7 +34,7 @@ export const deleteUniverse = (id) => request(`/universe-builder/${encodeURIComp
export const expandUniverse = ({
starterPrompt, influences,
preservedVariations, preservedCompositeSheets,
- logline, premise, styleNotes, stylePrompt, negativePrompt,
+ logline, premise, styleNotes,
locked,
providerId, model,
} = {}) => request('/universe-builder/expand', {
@@ -42,7 +42,7 @@ export const expandUniverse = ({
body: JSON.stringify({
starterPrompt, influences,
preservedVariations, preservedCompositeSheets,
- logline, premise, styleNotes, stylePrompt, negativePrompt,
+ logline, premise, styleNotes,
locked,
providerId, model,
}),
@@ -53,21 +53,21 @@ export const expandUniverse = ({
export const generateCategoryVariations = ({
category, count, existingLabels,
influences,
- logline, premise, styleNotes, stylePrompt, negativePrompt,
+ logline, premise, styleNotes,
providerId, model,
} = {}, options = {}) => request('/universe-builder/generate-variations', {
method: 'POST',
body: JSON.stringify({
category, count, existingLabels,
influences,
- logline, premise, styleNotes, stylePrompt, negativePrompt,
+ logline, premise, styleNotes,
providerId, model,
}),
...options,
});
export const refineWorldPrompts = ({
- starterPrompt, stylePrompt, negativePrompt,
+ starterPrompt,
logline, premise, styleNotes,
influences,
// Post-Expand structure — when provided, the server sees the full world and
@@ -79,7 +79,7 @@ export const refineWorldPrompts = ({
} = {}) => request('/universe-builder/refine-prompts', {
method: 'POST',
body: JSON.stringify({
- starterPrompt, stylePrompt, negativePrompt,
+ starterPrompt,
logline, premise, styleNotes,
influences,
...(categories && Object.keys(categories).length ? { categories } : {}),
@@ -93,8 +93,6 @@ export const refineWorldPrompts = ({
// iterates this so a new lockable field only needs adding in two places.
export const WORLD_LOCKABLE_FIELDS = [
'starterPrompt',
- 'stylePrompt',
- 'negativePrompt',
'logline',
'premise',
'styleNotes',
diff --git a/server/routes/universeBuilder.js b/server/routes/universeBuilder.js
index 67ffb1364f..92bd2ff57c 100644
--- a/server/routes/universeBuilder.js
+++ b/server/routes/universeBuilder.js
@@ -6,7 +6,7 @@
* GET /api/universe-builder/:id → Universe
* PATCH /api/universe-builder/:id → Universe
* DELETE /api/universe-builder/:id → { id }
- * POST /api/universe-builder/expand → { stylePrompt, negativePrompt, categories, compositeSheets, llm }
+ * POST /api/universe-builder/expand → { influences, categories, compositeSheets, llm }
* POST /api/universe-builder/:id/render → { runId, collectionId, jobIds, promptCount }
* GET /api/universe-builder/:id/runs → Run[]
*/
@@ -87,11 +87,20 @@ const influencesSchema = z.object({
avoid: z.array(influenceEntrySchema).max(svc.INFLUENCES_PER_LIST_MAX).optional().default([]),
}).strict();
+// Legacy prose prompts: the v2 universe template carried `stylePrompt` /
+// `negativePrompt` as comma-separated prose strings; v3 collapses them into
+// the chip-based `influences` lists. Accepting them here (as optional) lets
+// a stale client (or an importer of a v2 share-bucket payload) hand us the
+// legacy shape — the service-layer sanitizer splits + merges the tokens into
+// influences. New callers should send `influences` directly.
+const legacyStylePromptField = z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional();
+const legacyNegativePromptField = z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional();
+
const createSchema = z.object({
name: z.string().trim().min(1).max(svc.NAME_MAX_LENGTH),
starterPrompt: z.string().trim().max(svc.STARTER_PROMPT_MAX).optional().default(''),
- stylePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional().default(''),
- negativePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional().default(''),
+ stylePrompt: legacyStylePromptField,
+ negativePrompt: legacyNegativePromptField,
logline: z.string().trim().max(svc.LOGLINE_MAX).optional().default(''),
premise: z.string().trim().max(svc.PREMISE_MAX).optional().default(''),
styleNotes: z.string().trim().max(svc.STYLE_NOTES_MAX).optional().default(''),
@@ -117,8 +126,10 @@ const originField = z.record(z.unknown()).nullable().optional();
const patchSchema = z.object({
name: z.string().trim().min(1).max(svc.NAME_MAX_LENGTH).optional(),
starterPrompt: z.string().trim().max(svc.STARTER_PROMPT_MAX).optional(),
- stylePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional(),
- negativePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional(),
+ // Legacy prose prompts — see legacy*Field comment above. Tolerated on PATCH
+ // so a stale client tab can still save while the new chip-based UI lands.
+ stylePrompt: legacyStylePromptField,
+ negativePrompt: legacyNegativePromptField,
logline: z.string().trim().max(svc.LOGLINE_MAX).optional(),
premise: z.string().trim().max(svc.PREMISE_MAX).optional(),
styleNotes: z.string().trim().max(svc.STYLE_NOTES_MAX).optional(),
@@ -157,8 +168,6 @@ const expandSchema = z.object({
logline: z.string().trim().max(svc.LOGLINE_MAX).optional(),
premise: z.string().trim().max(svc.PREMISE_MAX).optional(),
styleNotes: z.string().trim().max(svc.STYLE_NOTES_MAX).optional(),
- stylePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional(),
- negativePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional(),
locked: lockedSchema.optional(),
providerId: z.string().trim().max(80).optional(),
model: z.string().trim().max(200).optional(),
@@ -173,16 +182,12 @@ const generateVariationsSchema = z.object({
logline: z.string().trim().max(svc.LOGLINE_MAX).optional().default(''),
premise: z.string().trim().max(svc.PREMISE_MAX).optional().default(''),
styleNotes: z.string().trim().max(svc.STYLE_NOTES_MAX).optional().default(''),
- stylePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional().default(''),
- negativePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional().default(''),
providerId: z.string().trim().max(80).optional(),
model: z.string().trim().max(200).optional(),
});
const refinePromptsSchema = z.object({
starterPrompt: z.string().trim().min(1).max(svc.STARTER_PROMPT_MAX),
- stylePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional().default(''),
- negativePrompt: z.string().trim().max(svc.PROMPT_FRAGMENT_MAX).optional().default(''),
// Bible context: passed in so the refiner sees the full seed, refines them
// alongside the prompts, and stays consistent with the universe's narrative.
logline: z.string().trim().max(svc.LOGLINE_MAX).optional().default(''),
diff --git a/server/routes/universeBuilder.test.js b/server/routes/universeBuilder.test.js
index 027a4d09bd..18f59ae42f 100644
--- a/server/routes/universeBuilder.test.js
+++ b/server/routes/universeBuilder.test.js
@@ -21,8 +21,10 @@ vi.mock('crypto', async () => {
// Stub the LLM expander so the route test doesn't shell out to a real provider.
vi.mock('../services/universeBuilderExpand.js', () => ({
expandWorldTemplate: vi.fn(async ({ starterPrompt }) => ({
- stylePrompt: 'mocked style for ' + starterPrompt,
- negativePrompt: 'blurry',
+ influences: {
+ embrace: [`mocked style for ${starterPrompt}`],
+ avoid: ['blurry'],
+ },
categories: {
landscapes: { variations: [{ label: 'Mock Land', prompt: 'mocked landscape' }] },
environments: { variations: [] },
@@ -166,10 +168,29 @@ describe('universe-builder routes', () => {
const c = await request(app).post('/api/universe-builder').send({ name: 'A' });
const res = await request(app)
.patch(`/api/universe-builder/${c.body.id}`)
- .send({ name: 'B', stylePrompt: 'oil painting' });
+ .send({ name: 'B', influences: { embrace: ['oil painting'], avoid: [] } });
expect(res.status).toBe(200);
expect(res.body.name).toBe('B');
- expect(res.body.stylePrompt).toBe('oil painting');
+ expect(res.body.influences.embrace).toEqual(['oil painting']);
+ // The v2 prose stylePrompt / negativePrompt fields no longer round-trip.
+ expect(res.body.stylePrompt).toBeUndefined();
+ expect(res.body.negativePrompt).toBeUndefined();
+ });
+
+ it('PATCH /:id absorbs stale prose stylePrompt/negativePrompt into influences', async () => {
+ // Backward compat: a stale v2-shaped client may still PATCH the prose
+ // fields. The sanitizer's v2 → v3 migration splits them into chip tokens
+ // and merges into influences.embrace / influences.avoid.
+ const app = buildApp();
+ const c = await request(app)
+ .post('/api/universe-builder')
+ .send({ name: 'Legacy', influences: { embrace: ['existing'], avoid: ['existing-neg'] } });
+ const res = await request(app)
+ .patch(`/api/universe-builder/${c.body.id}`)
+ .send({ stylePrompt: 'oil painting, gritty', negativePrompt: 'blurry' });
+ expect(res.status).toBe(200);
+ expect(res.body.influences.embrace).toEqual(['existing', 'oil painting', 'gritty']);
+ expect(res.body.influences.avoid).toEqual(['existing-neg', 'blurry']);
});
it('PATCH /:id persists canon array writes (characters/settings/objects)', async () => {
@@ -208,7 +229,7 @@ describe('universe-builder routes', () => {
.post('/api/universe-builder/expand')
.send({ starterPrompt: 'moebius scifi' });
expect(res.status).toBe(200);
- expect(res.body.stylePrompt).toContain('moebius scifi');
+ expect(res.body.influences.embrace[0]).toContain('moebius scifi');
expect(res.body.categories.landscapes.variations).toHaveLength(1);
expect(res.body.compositeSheets).toHaveLength(2);
expect(res.body.llm.provider).toBe('anthropic');
@@ -218,8 +239,7 @@ describe('universe-builder routes', () => {
const app = buildApp();
const created = await request(app).post('/api/universe-builder').send({
name: 'Render Test',
- stylePrompt: 'style',
- negativePrompt: 'neg',
+ influences: { embrace: ['style'], avoid: ['neg'] },
categories: {
landscapes: { variations: [{ label: 'A', prompt: 'a prompt' }, { label: 'B', prompt: 'b prompt' }] },
characters: { variations: [{ label: 'C', prompt: 'c prompt' }] },
@@ -242,7 +262,7 @@ describe('universe-builder routes', () => {
const app = buildApp();
const created = await request(app).post('/api/universe-builder').send({
name: 'Clothing',
- stylePrompt: 'moebius, clean reference sheet',
+ influences: { embrace: ['moebius', 'clean reference sheet'], avoid: [] },
categories: {
clothing_styles: { variations: [{ label: 'Gas-Giant Drifters', prompt: 'buckles, clips, pressure rings' }] },
},
@@ -259,7 +279,7 @@ describe('universe-builder routes', () => {
const app = buildApp();
const created = await request(app).post('/api/universe-builder').send({
name: 'Composite Clothing',
- stylePrompt: 'moebius, clean reference sheet',
+ influences: { embrace: ['moebius', 'clean reference sheet'], avoid: [] },
compositeSheets: [
{ label: 'Gas-Giant Drifters sheet', prompt: 'complete costume reference sheet, five figures, material swatches, pressure rings, palette strip' },
],
diff --git a/server/services/pipeline/migrateSeriesCanon.js b/server/services/pipeline/migrateSeriesCanon.js
index a996c6cba0..08ca074bc2 100644
--- a/server/services/pipeline/migrateSeriesCanon.js
+++ b/server/services/pipeline/migrateSeriesCanon.js
@@ -45,8 +45,6 @@ export async function migrateSeriesCanon({ dryRun = false, log = console.log } =
const newUniverse = await createUniverse({
name: `${s.name} (auto-migrated)`,
starterPrompt: s.logline || s.premise?.slice(0, 500) || '',
- stylePrompt: '',
- negativePrompt: '',
});
await updateSeries(s.id, { universeId: newUniverse.id });
universeId = newUniverse.id;
diff --git a/server/services/pipeline/nounRefine.js b/server/services/pipeline/nounRefine.js
index 58a3b7beaf..de6d114891 100644
--- a/server/services/pipeline/nounRefine.js
+++ b/server/services/pipeline/nounRefine.js
@@ -5,6 +5,7 @@
import { getSeries, updateSeries } from './series.js';
import { ServerError } from '../../lib/errorHandler.js';
import { runPromptRefine } from './refineHelpers.js';
+import { joinInfluenceList } from '../universeBuilder.js';
const peerForPrompt = (entry) => ({
name: entry.name,
@@ -46,8 +47,9 @@ export async function refineCharacterDescription(seriesId, entryId, options = {}
const peers = list.filter((_, i) => i !== idx);
const universe = null; // orphan-series path only — universeId branch returns early above
+ const universeAesthetic = joinInfluenceList(universe?.influences?.embrace);
const styleBits = [
- universe?.stylePrompt ? `Universe aesthetic: ${universe.stylePrompt}` : null,
+ universeAesthetic ? `Universe aesthetic: ${universeAesthetic}` : null,
series.styleNotes ? `Series notes: ${series.styleNotes}` : null,
].filter(Boolean);
const styleClause = styleBits.length
diff --git a/server/services/pipeline/visualStages.js b/server/services/pipeline/visualStages.js
index 556e5811c0..dc3c7be0eb 100644
--- a/server/services/pipeline/visualStages.js
+++ b/server/services/pipeline/visualStages.js
@@ -30,7 +30,7 @@ import { getSeries } from './series.js';
import { getIssue, updateStage, VISUAL_STAGE_IDS } from './issues.js';
import { PATHS } from '../../lib/fileUtils.js';
import { buildComicPagesOwner, buildStoryboardsShotOwner } from './owners.js';
-import { getUniverse } from '../universeBuilder.js';
+import { getUniverse, joinInfluenceList } from '../universeBuilder.js';
import { ServerError } from '../../lib/errorHandler.js';
import {
buildScenePrompt, buildSettingByKey, matchSceneSetting,
@@ -57,7 +57,9 @@ const composeExtraStyle = (series, issue, stageId, callerExtraStyle = '') =>
const applyWorldStyle = (prompt, world) => {
if (!world) return prompt;
- return composeStyledPrompt(prompt, '', { prompt: world.stylePrompt, negativePrompt: '' }).prompt;
+ const stylePrompt = joinInfluenceList(world.influences?.embrace);
+ if (!stylePrompt) return prompt;
+ return composeStyledPrompt(prompt, '', { prompt: stylePrompt, negativePrompt: '' }).prompt;
};
// Resolution order for the image-gen mode on a pipeline visual stage:
@@ -152,7 +154,7 @@ const enqueueImageJob = ({ prompt, world, settings, options, mode, owner, logLin
// effect even when the caller supplies their own additions. Deduplicated
// by token so a user repeating a world negative doesn't double-weight it.
const userNeg = (options.negativePrompt || '').trim();
- const worldNeg = (world?.negativePrompt || '').trim();
+ const worldNeg = joinInfluenceList(world?.influences?.avoid);
const negativeTokens = [userNeg, worldNeg]
.flatMap((s) => s.split(',').map((t) => t.trim()).filter(Boolean));
const negativePrompt = [...new Set(negativeTokens)].join(', ') || undefined;
diff --git a/server/services/pipeline/visualStages.test.js b/server/services/pipeline/visualStages.test.js
index 76364b5c9c..32e1ce6e2c 100644
--- a/server/services/pipeline/visualStages.test.js
+++ b/server/services/pipeline/visualStages.test.js
@@ -46,7 +46,11 @@ vi.mock('../settings.js', () => ({
getSettings: vi.fn(async () => ({ imageGen: { local: { pythonPath: '/usr/bin/python3' }, mode: 'local' }, videoGen: {} })),
}));
-vi.mock('../universeBuilder.js', () => ({ getUniverse: vi.fn(async () => null) }));
+vi.mock('../universeBuilder.js', () => ({
+ getUniverse: vi.fn(async () => null),
+ joinInfluenceList: (arr) =>
+ Array.isArray(arr) ? arr.filter((t) => typeof t === 'string' && t.trim()).join(', ') : '',
+}));
const enqueueJobMock = vi.fn(() => ({ jobId: 'job-fake-1234' }));
vi.mock('../mediaJobQueue/index.js', () => ({ enqueueJob: (...a) => enqueueJobMock(...a) }));
@@ -185,8 +189,16 @@ describe('composeComicPagePrompt', () => {
expect(prompt).toMatch(/Panel 1: continuation of previous beat\./);
});
- it('prepends world.stylePrompt when a world is provided', () => {
- const world = { stylePrompt: 'cinematic ink illustration, dramatic lighting', negativePrompt: '' };
+ it('prepends the world style tokens (influences.embrace) when a world is provided', () => {
+ // The universe's style prompt now lives as a chip-token list on
+ // `influences.embrace`. visualStages joins them verbatim into the
+ // rendered prompt the same way the legacy prose `stylePrompt` did.
+ const world = {
+ influences: {
+ embrace: ['cinematic ink illustration', 'dramatic lighting'],
+ avoid: [],
+ },
+ };
const prompt = composeComicPagePrompt({ series: SERIES, world, page: PAGE, pageNumber: 1 });
expect(prompt).toMatch(/cinematic ink illustration/);
});
@@ -479,8 +491,15 @@ describe('composeComicCoverPrompt', () => {
expect(prompt).toMatch(/issue-number tag reading "#1"/);
});
- it('prepends world.stylePrompt when a world is provided', () => {
- const world = { stylePrompt: 'cinematic ink illustration, dramatic lighting', negativePrompt: '' };
+ it('prepends the world style tokens (influences.embrace) when a world is provided', () => {
+ // Same migration as the page-prompt test above — covers stop reading
+ // a legacy prose stylePrompt; they now live as embrace chips.
+ const world = {
+ influences: {
+ embrace: ['cinematic ink illustration', 'dramatic lighting'],
+ avoid: [],
+ },
+ };
const prompt = composeComicCoverPrompt({
series: SERIES_NAMED,
world,
diff --git a/server/services/universeBuilder.js b/server/services/universeBuilder.js
index e08f3d4801..a0ff50262f 100644
--- a/server/services/universeBuilder.js
+++ b/server/services/universeBuilder.js
@@ -4,7 +4,10 @@
* Stores user-created "universe templates" — sci-fi/fantasy/etc. universe
* descriptions expanded by an LLM into a structured prompt set:
*
- * - stylePrompt + negativePrompt (positive style fragment + negative prompt)
+ * - influences.embrace / influences.avoid (token lists managed as draggable
+ * chips) act as both the style prompt and the negative prompt — they are
+ * joined verbatim at render-compile time and form the single source of
+ * truth for the universe's positive + negative tokens.
* - categories: named prompt buckets, seeded with common universe-art buckets
* like landscapes / characters / vehicles, but open to project-specific
* buckets like colonies, factions, species, clothing_styles, or raider_clans
@@ -35,7 +38,10 @@ import { emitRecordUpdated, emitRecordDeleted } from './sharing/recordEvents.js'
// Bumped when a sanitizer-time backfill changes how on-disk universes are
// shaped, so future migrations can gate on the prior version.
-export const CURRENT_SCHEMA_VERSION = 2;
+// v3 — drop prose stylePrompt/negativePrompt fields; legacy values are
+// split on commas and merged into influences.embrace / influences.avoid
+// so there is a single token-list editing surface.
+export const CURRENT_SCHEMA_VERSION = 3;
const STATE_PATH = join(PATHS.data, 'universe-builder.json');
@@ -71,10 +77,10 @@ export const COMPOSITE_SHEET_KINDS = Object.freeze([
export const WORLD_CATEGORY_KEY_MAX = 64;
export const WORLD_CATEGORY_COUNT_MAX = 30;
-// Influences — structured reference lists that deterministically inform
-// stylePrompt (embrace) and negativePrompt (avoid) at render-compile time.
-// They are the canonical record of the universe's direction so re-expansions
-// inherit it; the LLM still authors the prose stylePrompt around them.
+// Influences — structured token lists that ARE the universe's style + negative
+// prompts. Surfaced in the UI as "Style prompt" (embrace) and "Negative prompt"
+// (avoid) and managed via the draggable-chip editor. Joined verbatim with the
+// per-variation prompt at render-compile time.
export const INFLUENCE_ENTRY_MAX = 120;
export const INFLUENCES_PER_LIST_MAX = 30;
@@ -84,8 +90,6 @@ export const INFLUENCES_PER_LIST_MAX = 30;
// not lockable yet — start with the bible/prompt scalars the user owns.
export const LOCKABLE_FIELDS = Object.freeze([
'starterPrompt',
- 'stylePrompt',
- 'negativePrompt',
'logline',
'premise',
'styleNotes',
@@ -99,13 +103,11 @@ export const LOCKABLE_FIELDS = Object.freeze([
// extending LOCKABLE_FIELDS + this map; the prompts pick it up automatically.
export const LOCKABLE_FIELD_LABELS = Object.freeze({
starterPrompt: 'starter idea',
- stylePrompt: 'style prompt',
- negativePrompt: 'negative prompt',
logline: 'logline',
premise: 'premise',
styleNotes: 'style notes',
- influencesEmbrace: 'embrace influences',
- influencesAvoid: 'avoid influences',
+ influencesEmbrace: 'style prompt tokens',
+ influencesAvoid: 'negative prompt tokens',
});
// Lockable lock-map keys that target one of the two influence sub-lists.
@@ -264,6 +266,32 @@ export const sanitizeInfluences = (raw = {}) => {
};
};
+// v2 → v3 migration helper. Splits a legacy comma/newline-separated prose
+// prompt into individual chip tokens. Returns an array suitable for appending
+// to an influence list before sanitization (sanitizeInfluenceList handles the
+// per-entry cap, list cap, and dedupe).
+const splitProsePrompt = (prose) => {
+ if (typeof prose !== 'string') return [];
+ return prose.split(/[,\n]/).map((s) => s.trim()).filter(Boolean);
+};
+
+// Append legacy prose stylePrompt / negativePrompt tokens onto the structured
+// influences. Existing chip tokens stay at the front so the user's deliberate
+// chip ordering is preserved; prose tokens land at the back and are deduped
+// case-insensitively by the downstream sanitizeInfluenceList. Tolerates raw
+// being missing / non-object.
+export const mergeLegacyPromptsIntoInfluences = (rawInfluences, legacyStylePrompt, legacyNegativePrompt) => {
+ const baseEmbrace = Array.isArray(rawInfluences?.embrace) ? rawInfluences.embrace : [];
+ const baseAvoid = Array.isArray(rawInfluences?.avoid) ? rawInfluences.avoid : [];
+ const extraEmbrace = splitProsePrompt(legacyStylePrompt);
+ const extraAvoid = splitProsePrompt(legacyNegativePrompt);
+ if (!extraEmbrace.length && !extraAvoid.length) return rawInfluences || {};
+ return {
+ embrace: [...baseEmbrace, ...extraEmbrace],
+ avoid: [...baseAvoid, ...extraAvoid],
+ };
+};
+
// Build a refined influences object that honors per-list locks. Locked lists
// take their value from `fallback` (originals); unlocked lists take from
// `fresh` (the LLM output), falling back to `fallback` ONLY when the LLM
@@ -416,14 +444,20 @@ const sanitizeTemplate = (raw) => {
const name = trimTo(raw.name, NAME_MAX_LENGTH);
if (!name) return null;
const starterPrompt = trimTo(raw.starterPrompt, STARTER_PROMPT_MAX);
- const stylePrompt = trimTo(raw.stylePrompt, PROMPT_FRAGMENT_MAX);
- const negativePrompt = trimTo(raw.negativePrompt, PROMPT_FRAGMENT_MAX);
const logline = trimTo(raw.logline, LOGLINE_MAX);
const premise = trimTo(raw.premise, PREMISE_MAX);
const styleNotes = trimTo(raw.styleNotes, STYLE_NOTES_MAX);
const categories = sanitizeCategories(raw.categories || {});
const compositeSheets = sanitizeCompositeSheets(raw.compositeSheets || []);
- const influences = sanitizeInfluences(raw.influences);
+ // Legacy v2 universes carried prose stylePrompt / negativePrompt fields
+ // alongside influences. v3 collapses both into the chip-based influences
+ // editor: split each prose field on commas/newlines and append to the
+ // matching list. sanitizeInfluenceList handles trim, cap, and
+ // case-insensitive dedupe so a token that already exists as a chip is not
+ // re-added by the migration.
+ const influences = sanitizeInfluences(
+ mergeLegacyPromptsIntoInfluences(raw.influences, raw.stylePrompt, raw.negativePrompt),
+ );
const locked = sanitizeLocked(raw.locked);
// Canon registries. Backfill copies legacy `categories[].variations[]` into
// the matching kind on first read so series-side prompts can pull canon by
@@ -446,8 +480,6 @@ const sanitizeTemplate = (raw) => {
id: raw.id,
name,
starterPrompt,
- stylePrompt,
- negativePrompt,
logline,
premise,
styleNotes,
@@ -597,7 +629,7 @@ export async function updateUniverse(id, patch = {}) {
// + `locked` are handled above (they need per-key merging or wholesale
// replacement, not the simple scalar copy).
const PATCHABLE_SCALARS = [
- 'name', 'starterPrompt', 'stylePrompt', 'negativePrompt',
+ 'name', 'starterPrompt',
'logline', 'premise', 'styleNotes', 'compositeSheets',
// Canon entity arrays — patched wholesale (the sanitizer reruns
// sanitizeBibleList so per-entry shape is enforced on every save).
@@ -612,6 +644,10 @@ export async function updateUniverse(id, patch = {}) {
const merged = sanitizeTemplate({
...cur,
...scalarPatch,
+ // sanitizeTemplate runs the v2 → v3 prose-prompt merge — see its
+ // `mergeLegacyPromptsIntoInfluences` call.
+ ...(patch.stylePrompt !== undefined ? { stylePrompt: patch.stylePrompt } : {}),
+ ...(patch.negativePrompt !== undefined ? { negativePrompt: patch.negativePrompt } : {}),
categories: mergedCategories,
influences: mergedInfluences,
locked: mergedLocked,
@@ -654,29 +690,15 @@ export async function listRuns(universeId = null) {
return [...filtered].sort((a, b) => (b.createdAt || '').localeCompare(a.createdAt || ''));
}
-/**
- * Compose a token string by prepending an influence list (embrace or avoid)
- * to a free-form comma-separated prose tokens string, with case-insensitive
- * dedupe so the LLM-authored prompt never repeats an entry the user already
- * pinned. Used by compilePrompts so structured influences ALWAYS land in the
- * rendered prompt regardless of whether the LLM remembered them.
- */
-export function composeInfluenceTokens(structured = [], prose = '') {
- const all = [];
- if (typeof prose === 'string' && prose.trim()) {
- all.push(...prose.split(',').map((s) => s.trim()).filter(Boolean));
- }
- if (Array.isArray(structured)) all.push(...structured);
- const seen = new Set();
- const out = [];
- for (const token of all) {
- if (!token) continue;
- const key = token.toLowerCase();
- if (seen.has(key)) continue;
- seen.add(key);
- out.push(token);
- }
- return out.join(', ');
+// Join an influence list (embrace or avoid) into the comma-separated string
+// shape the renderer's `composeStyledPrompt` consumes. Tokens have already
+// been deduped + capped by `sanitizeInfluenceList` at write time, so this is
+// just a thin join — exported so downstream consumers (universeCanon,
+// pipeline/nounRefine, pipeline/visualStages) read a single helper instead
+// of each open-coding `(arr || []).join(', ')`.
+export function joinInfluenceList(structured = []) {
+ if (!Array.isArray(structured)) return '';
+ return structured.filter((t) => typeof t === 'string' && t.trim()).join(', ');
}
/**
@@ -707,8 +729,8 @@ export function compilePrompts(universe, options = {}) {
const batchPerVariation = Math.max(1, Math.min(20, Number(options.batchPerVariation) || 1));
const stylePreset = {
- prompt: composeInfluenceTokens(universe.influences?.embrace, universe.stylePrompt),
- negativePrompt: composeInfluenceTokens(universe.influences?.avoid, universe.negativePrompt),
+ prompt: joinInfluenceList(universe.influences?.embrace),
+ negativePrompt: joinInfluenceList(universe.influences?.avoid),
};
const compiled = [];
diff --git a/server/services/universeBuilder.test.js b/server/services/universeBuilder.test.js
index ad3caab618..1f87cf2758 100644
--- a/server/services/universeBuilder.test.js
+++ b/server/services/universeBuilder.test.js
@@ -21,12 +21,16 @@ vi.mock("crypto", async () => {
const svc = await import("./universeBuilder.js");
+// Default universe with non-empty influences. Override `influences` for tests
+// that need isolation from the seed tokens.
const seedWorld = async (overrides = {}) =>
svc.createUniverse({
name: "Moebius SciFi",
starterPrompt: "moebius and scavengers reign meets prophet",
- stylePrompt: "moebius linework, scavengers reign palette",
- negativePrompt: "blurry, lowres",
+ influences: {
+ embrace: ["moebius linework", "scavengers reign palette"],
+ avoid: ["blurry", "lowres"],
+ },
categories: {
landscapes: {
variations: [
@@ -179,7 +183,8 @@ describe("universeBuilder service", () => {
expect(patched.styleNotes).toBe("new style notes");
// Untouched (existing) data preserved.
expect(patched.categories.landscapes.variations).toHaveLength(2);
- expect(patched.stylePrompt).toBe(w.stylePrompt);
+ expect(patched.influences.embrace).toEqual(w.influences.embrace);
+ expect(patched.influences.avoid).toEqual(w.influences.avoid);
});
it("createUniverse trims bible fields to their max length", async () => {
@@ -197,10 +202,18 @@ describe("universeBuilder service", () => {
const w = await seedWorld();
const patched = await svc.updateUniverse(w.id, {
name: "Renamed",
+ // Legacy stale-client shape: prose stylePrompt gets split into chips and
+ // appended to influences.embrace by the sanitizer's v2 → v3 migration.
stylePrompt: "new style",
});
expect(patched.name).toBe("Renamed");
- expect(patched.stylePrompt).toBe("new style");
+ // The legacy prose was absorbed as a single token at the tail of embrace.
+ expect(patched.influences.embrace).toEqual([
+ ...w.influences.embrace,
+ "new style",
+ ]);
+ // The legacy field is no longer stored on the record.
+ expect(patched.stylePrompt).toBeUndefined();
// Untouched fields preserved.
expect(patched.starterPrompt).toBe(w.starterPrompt);
expect(patched.categories.landscapes.variations).toHaveLength(2);
@@ -392,6 +405,10 @@ describe("universeBuilder service", () => {
});
describe("influences", () => {
+ // These tests probe the per-list sanitizer in isolation, so they override
+ // seedWorld's default influences with their own to keep the assertions
+ // focused on the input under test (the default influences would otherwise
+ // round-trip alongside and confuse the expected output).
it("round-trips embrace + avoid lists through createUniverse", async () => {
const w = await seedWorld({
influences: {
@@ -418,7 +435,9 @@ describe("universeBuilder service", () => {
});
it("defaults to empty lists when influences is missing or invalid", async () => {
- const w = await seedWorld({ influences: undefined });
+ // seedWorld seeds non-empty influences by default — override with empty
+ // lists so this test isolates the missing/invalid branch.
+ const w = await seedWorld({ influences: { embrace: [], avoid: [] } });
expect(w.influences).toEqual({ embrace: [], avoid: [] });
const w2 = await seedWorld({
name: "second",
@@ -450,10 +469,30 @@ describe("universeBuilder service", () => {
expect(patched.influences.avoid).toEqual([]);
});
- it("compilePrompts deterministically appends embrace to prompt + avoid to negative, deduped", async () => {
+ it("compilePrompts joins embrace verbatim into prompt + avoid into negative", async () => {
+ const w = await seedWorld({
+ influences: {
+ embrace: ["Moebius", "cel-shading", "ink", "dust palette"],
+ avoid: ["ghibli painterly", "lowres"],
+ },
+ });
+ const compiled = svc.compilePrompts(w, {
+ selection: { landscapes: ["Crystal Canyon"] },
+ });
+ expect(compiled).toHaveLength(1);
+ // Embrace tokens land verbatim as the style prefix, joined with the
+ // variation prompt via composeStyledPrompt's `. ` separator.
+ expect(compiled[0].prompt).toBe(
+ "Moebius, cel-shading, ink, dust palette. crystalline canyon, alien sun",
+ );
+ // Avoid tokens become the negative prompt verbatim.
+ expect(compiled[0].negativePrompt).toBe("ghibli painterly, lowres");
+ });
+
+ it("compilePrompts absorbs legacy prose stylePrompt/negativePrompt into the chip lists", async () => {
const w = await seedWorld({
- // stylePrompt already mentions one of the embraces — dedupe should
- // ensure it doesn't appear twice in the rendered prompt.
+ // Stale v2-shaped payload — prose tokens migrate into the chip lists
+ // alongside any pre-existing influences and dedupe case-insensitively.
stylePrompt: "cel-shading, ink, dust palette",
negativePrompt: "lowres",
influences: {
@@ -465,21 +504,14 @@ describe("universeBuilder service", () => {
selection: { landscapes: ["Crystal Canyon"] },
});
expect(compiled).toHaveLength(1);
- // Style prose comes first; embrace tokens are appended; duplicate
- // "cel-shading" only appears once.
- expect(
- compiled[0].prompt.startsWith(
- "cel-shading, ink, dust palette, Moebius",
- ),
- ).toBe(true);
- expect((compiled[0].prompt.match(/cel-shading/g) || []).length).toBe(1);
- // Negative: existing negatives come first; avoid tokens are appended, deduped against "lowres".
- expect(
- compiled[0].negativePrompt.startsWith("lowres, ghibli painterly"),
- ).toBe(true);
- expect((compiled[0].negativePrompt.match(/lowres/g) || []).length).toBe(
- 1,
+ // Chip tokens stay at the front (preserve user ordering); prose tokens
+ // land at the tail. "cel-shading" / "lowres" dedupe at the sanitizer.
+ expect(compiled[0].prompt).toBe(
+ "Moebius, cel-shading, ink, dust palette. crystalline canyon, alien sun",
);
+ expect((compiled[0].prompt.match(/cel-shading/g) || []).length).toBe(1);
+ expect(compiled[0].negativePrompt).toBe("ghibli painterly, lowres");
+ expect((compiled[0].negativePrompt.match(/lowres/g) || []).length).toBe(1);
});
});
@@ -578,7 +610,7 @@ describe("universeBuilder service", () => {
});
describe("categories→canon backfill", () => {
- it("backfills canon arrays from categories on first read + stamps schemaVersion=2", async () => {
+ it("backfills canon arrays from categories on first read + stamps the current schema version", async () => {
fileStore.set("/mock/data/universe-builder.json", {
universes: [
{
@@ -599,7 +631,7 @@ describe("universeBuilder service", () => {
});
const list = await svc.listUniverses();
const w = list[0];
- expect(w.schemaVersion).toBe(2);
+ expect(w.schemaVersion).toBe(svc.CURRENT_SCHEMA_VERSION);
// Characters
const alex = w.characters.find((c) => c.name === "Alex");
expect(alex).toBeTruthy();
@@ -622,7 +654,7 @@ describe("universeBuilder service", () => {
expect(rebels.tags).toEqual(["factions"]); // unknown category key → object catch-all
});
- it("backfill is idempotent — re-reading a v2 universe does not duplicate canon", async () => {
+ it("backfill is idempotent — re-reading an already-migrated universe does not duplicate canon", async () => {
fileStore.set("/mock/data/universe-builder.json", {
universes: [
{
@@ -639,7 +671,7 @@ describe("universeBuilder service", () => {
// First read triggers backfill + persist.
const first = (await svc.listUniverses())[0];
expect(first.characters.length).toBe(1);
- // Second read — schemaVersion=2 already on disk, backfill skipped.
+ // Second read — current schemaVersion already on disk, backfill skipped.
const second = (await svc.listUniverses())[0];
expect(second.characters.length).toBe(1);
// Third read post-rename: a user-renamed entry must not be clobbered by
diff --git a/server/services/universeBuilderExpand.js b/server/services/universeBuilderExpand.js
index c554b2e591..0030c1fb9c 100644
--- a/server/services/universeBuilderExpand.js
+++ b/server/services/universeBuilderExpand.js
@@ -4,7 +4,7 @@
* Takes a starter prompt like:
* "moebius and scavengers reign meets Prophet inspired sci fi universe"
* and asks the chosen LLM to return a structured JSON blob:
- * { stylePrompt, negativePrompt, categories: { ... }, compositeSheets: [{ kind, label, prompt }] }
+ * { influences: { embrace, avoid }, categories: { ... }, compositeSheets: [{ kind, label, prompt }] }
*
* The LLM choice is per-call: caller passes { providerId, model }. If
* either is missing we fall back to the active provider / its default
@@ -50,13 +50,11 @@ function buildExpansionPrompt({
influences,
preservedVariations,
preservedCompositeSheets,
- // Prior bible/prompt state — locked entries echo back unchanged; unlocked
- // entries seed the LLM. Empty/missing fields are skipped.
+ // Prior bible state — locked entries echo back unchanged; unlocked entries
+ // seed the LLM. Empty/missing fields are skipped.
priorLogline = '',
priorPremise = '',
priorStyleNotes = '',
- priorStylePrompt = '',
- priorNegativePrompt = '',
locked = {},
}) {
const embrace = Array.isArray(influences?.embrace)
@@ -69,7 +67,7 @@ function buildExpansionPrompt({
const avoidTag = locked?.influencesAvoid ? ' [LOCKED]' : '';
const influencesSection =
embrace.length || avoid.length
- ? `\n# Influences (canonical reference list — appended to stylePrompt/negativePrompt at render time; keep them distinct from the prose fields)\nEmbrace${embraceTag}: ${embrace.join(", ") || "(none)"}\nAvoid${avoidTag}: ${avoid.join(", ") || "(none)"}\n`
+ ? `\n# Influences (style prompt embrace + negative prompt avoid — joined verbatim at render time as the universe's positive + negative prompts)\nEmbrace${embraceTag}: ${embrace.join(", ") || "(none)"}\nAvoid${avoidTag}: ${avoid.join(", ") || "(none)"}\n`
: "";
// Locked entries are flagged and MUST be echoed verbatim; unlocked entries
@@ -79,8 +77,6 @@ function buildExpansionPrompt({
logline: priorLogline,
premise: priorPremise,
styleNotes: priorStyleNotes,
- stylePrompt: priorStylePrompt,
- negativePrompt: priorNegativePrompt,
};
const stateLines = CURRENT_STATE_FIELDS
.filter(([key]) => typeof priorValues[key] === 'string' && priorValues[key].trim())
@@ -129,9 +125,7 @@ Return a SINGLE JSON object. NO markdown, NO commentary. The object MUST have th
- logline: string. ONE sentence (≤500 chars) capturing the universe's central tension/hook — protagonist-agnostic if no protagonist is implied. Example: "A foundry city goes silent — and the only survivor is a child."
- premise: string. 1-3 short paragraphs (≤4000 chars total) describing the setting, the central conflict or situation, the stakes, and the tone. Write it as the elevator pitch a showrunner would hand to a writers' room. No bullet points; prose only.
- styleNotes: string. A prose paragraph (≤4000 chars) describing the visual + tonal style for the story bible — references (artists, films, comics, games), mood, palette, pacing, narrative voice. This is read by writers + creative directors, not the image model, so use full sentences instead of comma-separated tokens.
-- influences: object { "embrace": [string], "avoid": [string] }. Short canonical reference labels (max 120 chars each, max 30 per list) — artists, comics, films, directors, palettes, materials, eras the universe EMBRACES; styles, tropes, palettes the universe AVOIDS. The renderer appends these to stylePrompt/negativePrompt at render time, so each entry should read as a clean prompt token (e.g. "Moebius", "cel-shading", "Ghibli painterly", "neon cyberpunk"). When influence input is provided above, preserve those entries unless the starter idea explicitly contradicts them.
-- stylePrompt: string. A single comma-separated style fragment (lighting, color palette, render quality, artist references) compiled from the style notes and starter idea. This is PREPENDED to every variation prompt. Keep under 400 characters. No subject nouns — those go in variations. Do NOT echo embrace tokens here — the renderer appends them at render time.
-- negativePrompt: string. Comma-separated tokens to avoid (e.g. "blurry, lowres, watermark, extra fingers") compiled from the style notes and starter idea. Do NOT echo avoid tokens here — the renderer appends them at render time.
+- influences: object { "embrace": [string], "avoid": [string] }. THIS IS THE UNIVERSE'S STYLE + NEGATIVE PROMPT. Each list is a set of short prompt tokens (max 120 chars each, max 30 per list). The "embrace" list is joined verbatim as the positive style prompt prepended to every render (palette, lighting, render quality, artist references — e.g. "moebius linework", "cel-shading", "dust palette"). The "avoid" list is joined verbatim as the negative prompt (e.g. "blurry", "lowres", "watermark", "extra fingers"). Use short token-style labels, NOT full sentences. When influence input is provided above, preserve those entries unless the starter idea explicitly contradicts them.
- categories: object. Atomic reusable buckets. Use snake_case keys. Start from these common buckets when useful:
${WORLD_CATEGORIES.map((c) => ` - ${c}`).join("\n")}
Add, remove, or rename buckets to fit the user's actual universe-building task. Do not force every project into the starter buckets.
@@ -154,30 +148,28 @@ Concrete compositeSheets examples:
- Generate 3-8 compositeSheets when the starter idea involves clothing systems, colonies, factions, cultures, species, vehicles, settlements, props, posters, decks, or other grouped visual-design systems.
- For broad universe/universe/story settings, always include 1-3 "world_pitch_poster" compositeSheets in addition to any "reference_sheet" boards. These are summary concept pitch posters, not atomic character or environment sheets.
- "label" is a short name a human can recognize (e.g. "Crystalline canyon basin", "Scavenger walker mech").
-- "prompt" describes the SUBJECT only — the stylePrompt is automatically prepended at render time, so do NOT repeat style tokens in each variation.
+- "prompt" describes the SUBJECT only — the embrace influences are automatically prepended at render time as the style prompt, so do NOT repeat style tokens in each variation.
- Do not include camera/aspect tokens; the renderer adds those.
-- Ground the universe in the references provided. If the starter mentions specific artists, comics, films, games, or moods, weave them into stylePrompt.
+- Ground the universe in the references provided. If the starter mentions specific artists, comics, films, games, or moods, weave them into the embrace influences.
- If the user asks for style sheets, reference sheets, clothing guides, materials, colonies, factions, tribes, species, pirate/raider groups, universe summary boards, concept pitch posters, or pitch-deck posters, create specific categories for the atomic facts AND create compositeSheets for the complete boards.
- For colony clothing systems, include functional details like fasteners, closures, textile/material logic, silhouettes, class/role markers, weather or pressure adaptations, and culturally specific ornamentation.
- Reference-sheet prompts must include a clear board structure: title/subject, 4-6 figure lineup roles when relevant, materials swatches, fasteners/accessories icons, color palette strip, background hint, and simplicity constraints such as minimal readable layout, fewer tiny objects, clean silhouettes, not baroque, not hyper-detailed.
- Universe pitch poster prompts must include a clear editorial poster structure: universe title/subtitle/logline area, dominant hero panorama, inset environment/culture/creature images, visual-language strip, color palette, materials/textures, light/atmosphere, themes/icons, and concise labeled blocks for universe, feel, aesthetic, environments, cultures, and tone. Mention that body copy should be short, clean, and readable; avoid dense tiny text.
-- If the universe needs pitch posters, do not put "text" in the negativePrompt. Prefer "watermark, logo, unreadable tiny text, text artifacts" so title/section typography remains possible.
+- If the universe needs pitch posters, do not put "text" in the avoid influences. Prefer "watermark", "logo", "unreadable tiny text", "text artifacts" so title/section typography remains possible.
- When "Current universe state" is provided above: treat it as the established universe. Fields marked [LOCKED] MUST be echoed in your output exactly as given — do not reword, expand, or trim them. Unlocked current-state fields are starting points; you may refine them, but stay consistent with locked fields, the starter idea, and influences.
- Output JUST the JSON object. No prose before or after.`;
}
// Prefer a block that *looks like* a universe-expansion response (has any of
-// stylePrompt / negativePrompt / categories / compositeSheets at the top
-// level). The expansion prompt includes literal JSON examples like
+// the top-level keys we expect). The expansion prompt includes literal JSON
+// examples like
// { "label": "Crystalline canyon basin", "prompt": "…" }
// which parse cleanly but aren't the response. Without the shape preference
// we'd return that first valid-but-wrong object and end up with 0 variations.
const isExpansionShape = (o) =>
o &&
typeof o === "object" &&
- (typeof o.stylePrompt === "string" ||
- typeof o.negativePrompt === "string" ||
- typeof o.logline === "string" ||
+ (typeof o.logline === "string" ||
typeof o.premise === "string" ||
typeof o.styleNotes === "string" ||
(o.influences && typeof o.influences === "object") ||
@@ -268,7 +260,7 @@ const normalizeCompositeSheets = (raw) =>
/**
* Expand a starter prompt into a structured universe template draft.
- * Returns { stylePrompt, negativePrompt, categories, compositeSheets, llm: { provider, model } }.
+ * Returns { logline, premise, styleNotes, influences, categories, compositeSheets, llm: { provider, model } }.
*
* @param {object} options
* @param {string} options.starterPrompt
@@ -280,14 +272,12 @@ export async function expandWorldTemplate({
influences,
preservedVariations = {},
preservedCompositeSheets = [],
- // Prior bible/prompt state — locked entries echo back unchanged, unlocked
- // entries seed the LLM. Renamed to `prior*` so the parsed-LLM-output locals
- // below can keep their canonical names.
+ // Prior bible state — locked entries echo back unchanged, unlocked entries
+ // seed the LLM. Renamed to `prior*` so the parsed-LLM-output locals below
+ // can keep their canonical names.
logline: priorLogline = '',
premise: priorPremise = '',
styleNotes: priorStyleNotes = '',
- stylePrompt: priorStylePrompt = '',
- negativePrompt: priorNegativePrompt = '',
locked = {},
providerId,
model,
@@ -320,8 +310,6 @@ export async function expandWorldTemplate({
priorLogline,
priorPremise,
priorStyleNotes,
- priorStylePrompt,
- priorNegativePrompt,
locked,
});
const totalIn = safeInfluences.embrace.length + safeInfluences.avoid.length;
@@ -362,8 +350,6 @@ export async function expandWorldTemplate({
// clobber existing draft state on every response that misses a field.
const trimField = (value, max) =>
typeof value === "string" ? value.trim().slice(0, max) : null;
- const stylePrompt = trimField(parsed.stylePrompt, PROMPT_FRAGMENT_MAX);
- const negativePrompt = trimField(parsed.negativePrompt, PROMPT_FRAGMENT_MAX);
const logline = trimField(parsed.logline, LOGLINE_MAX);
const premise = trimField(parsed.premise, PREMISE_MAX);
const styleNotes = trimField(parsed.styleNotes, STYLE_NOTES_MAX);
@@ -404,8 +390,6 @@ export async function expandWorldTemplate({
logline,
premise,
styleNotes,
- stylePrompt,
- negativePrompt,
influences: influencesOut,
categories,
compositeSheets,
@@ -421,21 +405,17 @@ function buildCategoryGeneratePrompt({
logline,
premise,
styleNotes,
- stylePrompt,
- negativePrompt,
}) {
const embrace = Array.isArray(influences?.embrace) ? influences.embrace.filter(Boolean) : [];
const avoid = Array.isArray(influences?.avoid) ? influences.avoid.filter(Boolean) : [];
const influencesSection = embrace.length || avoid.length
- ? `\n# Influences\nEmbrace: ${embrace.join(", ") || "(none)"}\nAvoid: ${avoid.join(", ") || "(none)"}\n`
+ ? `\n# Influences (embrace = style prompt, avoid = negative prompt)\nEmbrace: ${embrace.join(", ") || "(none)"}\nAvoid: ${avoid.join(", ") || "(none)"}\n`
: "";
const stateLines = [
logline && `LOGLINE: ${logline}`,
premise && `PREMISE: ${premise}`,
styleNotes && `STYLE NOTES: ${styleNotes}`,
- stylePrompt && `STYLE PROMPT: ${stylePrompt}`,
- negativePrompt && `NEGATIVE PROMPT: ${negativePrompt}`,
].filter(Boolean);
const stateSection = stateLines.length
? `\n# Universe context — keep new variations consistent with this established setting\n${stateLines.join('\n\n')}\n`
@@ -455,7 +435,7 @@ Return a SINGLE JSON object with one key: "variations" — an array of EXACTLY $
- Generate ${count} variations — no more, no less.
- Each variation must be visually distinct from the others AND from the existing labels listed above.
- "label" is a short human-recognizable name (e.g. "Crystalline canyon basin", "Scavenger walker mech").
-- "prompt" describes the SUBJECT only — the universe's stylePrompt is automatically prepended at render time, so do NOT repeat style tokens.
+- "prompt" describes the SUBJECT only — the universe's embrace influences are automatically prepended at render time as the style prompt, so do NOT repeat style tokens.
- Do not include camera/aspect tokens; the renderer adds those.
- Stay consistent with the universe context and influences. Lean into the embrace list; avoid the avoid list.
- Output JUST the JSON object. NO markdown, NO commentary.`;
@@ -498,8 +478,6 @@ export async function generateCategoryVariations({
logline = '',
premise = '',
styleNotes = '',
- stylePrompt = '',
- negativePrompt = '',
providerId,
model,
} = {}) {
@@ -523,8 +501,6 @@ export async function generateCategoryVariations({
logline,
premise,
styleNotes,
- stylePrompt,
- negativePrompt,
});
console.log(
diff --git a/server/services/universeBuilderExpand.test.js b/server/services/universeBuilderExpand.test.js
index c5815fd333..fbe5402308 100644
--- a/server/services/universeBuilderExpand.test.js
+++ b/server/services/universeBuilderExpand.test.js
@@ -331,21 +331,21 @@ describe("universeBuilderExpand.EXPANSION_PROMPT", () => {
expect(out).not.toContain("# Current universe state");
});
- it("includes provided bible + prompt fields as Current universe state context", () => {
+ it("includes provided bible fields as Current universe state context", () => {
const out = buildExpansionPrompt({
starterPrompt: "seed",
priorLogline: "A foundry city goes silent.",
priorPremise: "Three families inherit the silence.",
priorStyleNotes: "Tarkovsky pacing, Moebius palette.",
- priorStylePrompt: "moebius linework, dust palette",
- priorNegativePrompt: "blurry, lowres",
});
expect(out).toContain("# Current universe state");
expect(out).toContain("LOGLINE: A foundry city goes silent.");
expect(out).toContain("PREMISE: Three families inherit the silence.");
expect(out).toContain("STYLE NOTES: Tarkovsky pacing, Moebius palette.");
- expect(out).toContain("STYLE PROMPT: moebius linework, dust palette");
- expect(out).toContain("NEGATIVE PROMPT: blurry, lowres");
+ // Style + negative prompts are no longer separate scalars — they live in
+ // the influences section instead.
+ expect(out).not.toContain("STYLE PROMPT:");
+ expect(out).not.toContain("NEGATIVE PROMPT:");
});
it("flags locked fields with [LOCKED] and adds the must-preserve instruction", () => {
diff --git a/server/services/universeBuilderRefine.js b/server/services/universeBuilderRefine.js
index f39ba2264b..a41f37c0d0 100644
--- a/server/services/universeBuilderRefine.js
+++ b/server/services/universeBuilderRefine.js
@@ -1,11 +1,11 @@
/**
- * Universe Builder — refine the 3 top-level prompts (starter idea, style prompt,
- * negative prompt) based on user feedback. Mirrors the media prompt-refine
- * flow (see `mediaPromptRefiner.js`) but operates on a universe template rather
- * than an individual render.
+ * Universe Builder — refine the bible + influences (which collectively act as
+ * the universe's style and negative prompts) based on user feedback. Mirrors
+ * the media prompt-refine flow (see `mediaPromptRefiner.js`) but operates on
+ * a universe template rather than an individual render.
*
* The LLM gets the originals + a free-form feedback string and returns:
- * { starterPrompt, stylePrompt, negativePrompt, rationale, changes? }
+ * { starterPrompt, logline, premise, styleNotes, influences, rationale, changes? }
*
* The caller (route → UI) presents the refined fields for review before they
* overwrite the draft, so the LLM never silently mutates a saved universe.
@@ -161,8 +161,6 @@ const renderCompositesForPrompt = (composites) =>
export function buildWorldRefinePrompt({
starterPrompt,
- stylePrompt,
- negativePrompt,
logline = "",
premise = "",
styleNotes = "",
@@ -225,26 +223,22 @@ ${renderCompositesForPrompt(compositeSheets) || " (none)"}
return `You are a senior universe-building editor for a Stable-Diffusion-style image-generation pipeline AND a story-bible drafter for a comic/TV production pipeline.
-The user has seven top-level fields that define a "universe":
+The user has five top-level fields that define a "universe":
- STARTER IDEA — the high-concept seed the universe expander fans out into categories.
-- STYLE PROMPT — comma-separated visual style tokens prepended to every render (palette, lighting, render quality, artist references).
-- NEGATIVE PROMPT — comma-separated tokens to avoid in renders.
- LOGLINE — one-sentence narrative hook.
- PREMISE — 1-3 paragraph elevator pitch (setting, conflict, stakes, tone).
- STYLE NOTES — narrative-side prose about references, mood, palette, pacing, voice.
-- INFLUENCES — structured { embrace: [string], avoid: [string] } reference list. The renderer appends embrace to the style prompt and avoid to the negative prompt at render time — they are separate from and complementary to the stylePrompt/negativePrompt prose. Each entry is a short prompt-token-style label (e.g. "Moebius", "cel-shading", "Ghibli painterly"). Max 30 entries per list, max 120 chars each.
+- INFLUENCES — structured { embrace: [string], avoid: [string] } token lists. THESE ARE THE UNIVERSE'S STYLE + NEGATIVE PROMPT. The "embrace" list is joined verbatim as the positive style prompt prepended to every render (palette tokens, lighting, render quality, artist references — e.g. "moebius linework", "cel-shading", "dust palette"). The "avoid" list is joined verbatim as the negative prompt (e.g. "blurry", "lowres", "watermark"). Each entry is a short prompt-token-style label, NOT a full sentence. Max 30 entries per list, max 120 chars each.
-The user has given feedback about the story, mood, style, or design they want refined. Rewrite ALL seven fields so they more faithfully express the user's intention and stay internally consistent. Output the COMPLETE rewritten text/values for each — not a placeholder, not a summary, not a diff.
+The user has given feedback about the story, mood, style, or design they want refined. Rewrite ALL fields so they more faithfully express the user's intention and stay internally consistent. Output the COMPLETE rewritten text/values for each — not a placeholder, not a summary, not a diff.
${lockedSection}Return ONLY valid JSON in this schema (replace every <…> with real content; do NOT output the literal angle-bracket text):
{
"starterPrompt": "<full rewritten high-concept starter idea, 1-3 sentences. Stays a clean seed — do NOT append style direction prose here, that belongs in influences + styleNotes>",
- "stylePrompt": "<full rewritten style fragment, comma-separated tokens, no subject nouns — palette, lighting, render quality, artist references; compiled from style notes, NOT echoing embrace tokens (those are appended at render time)>",
- "negativePrompt": "<full rewritten negative prompt, comma-separated tokens to avoid; empty string if none; compiled from style notes, NOT echoing avoid tokens (those are appended at render time)>",
"logline": "<full rewritten one-sentence narrative hook>",
"premise": "<full rewritten 1-3 paragraph elevator pitch>",
"styleNotes": "<full rewritten narrative-style prose about references, mood, palette, pacing, voice>",
- "influences": { "embrace": ["<short reference label>", "..."], "avoid": ["<short reference label>", "..."] }${structureSchema},
+ "influences": { "embrace": ["<short style prompt token>", "..."], "avoid": ["<short negative prompt token>", "..."] }${structureSchema},
"rationale": "<one concise sentence explaining the overall edit>",
"changes": ["<short bullet of what changed and why>"]
}
@@ -252,22 +246,14 @@ ${lockedSection}Return ONLY valid JSON in this schema (replace every <…> with
Rules:
- Preserve story/character/universe DNA from the originals unless the user's feedback explicitly contradicts it.
- The "starterPrompt" stays a clean high-concept seed — no category content (landscapes, factions, etc.) and no style-direction prose. The structured "influences" field carries that direction so re-expansions inherit it deterministically.
-- The "stylePrompt" must be comma-separated visual-style tokens only. No subject nouns. No camera/aspect tokens. Under 400 characters. Compile from style notes — do NOT echo embrace tokens here; the renderer appends them at render time.
-- The "negativePrompt" must be comma-separated tokens compiled from style notes. Do NOT echo avoid tokens here; the renderer appends them at render time. If the universe relies on text/typography (e.g. pitch posters), avoid putting "text" in negatives — prefer "watermark, logo, unreadable tiny text, text artifacts".
-- The "influences" lists are the canonical reference set. Add what the user's feedback embraces, drop what's no longer relevant, and add explicit avoids for things they're moving away from. Keep entries short (a name, a movement, a palette descriptor) — they're prepended verbatim to the renderer prompt.
-- The "logline", "premise", and "styleNotes" must stay narratively coherent with the refined influences and style prompts.
-- Apply the user's feedback decisively. If they ask for a different style/mood/era, move toward it in influences + style prompt + styleNotes, and name the things to avoid in negativePrompt + influences.avoid.
+- The "influences" lists are the canonical positive + negative prompt set. Each token is short (a name, a movement, a palette descriptor, a render-quality token) — they are joined verbatim into the renderer prompt. Add what the user's feedback embraces, drop what's no longer relevant, and add explicit avoids for things they're moving away from. If the universe relies on text/typography (e.g. pitch posters), avoid putting "text" in the avoid list — prefer "watermark", "logo", "unreadable tiny text", "text artifacts" so title typography remains possible.
+- The "logline", "premise", and "styleNotes" must stay narratively coherent with the refined influences.
+- Apply the user's feedback decisively. If they ask for a different style/mood/era, move toward it in influences + styleNotes, and name the things to avoid in influences.avoid.
- No field may equal the schema placeholder text — output real rewritten content for every key.
${lockedRules.length ? "- Any field listed under LOCKED FIELDS above must be returned EXACTLY as the original — do not reword, expand, or trim it. The server will discard any change to a locked field, but echoing the original keeps the JSON consistent.\n" : ""}${structureRules}
ORIGINAL STARTER IDEA:
${starterPrompt || "(empty)"}
-ORIGINAL STYLE PROMPT:
-${stylePrompt || "(empty)"}
-
-ORIGINAL NEGATIVE PROMPT:
-${negativePrompt || "(empty)"}
-
ORIGINAL LOGLINE:
${logline || "(empty)"}
@@ -418,12 +404,10 @@ async function runRefine(provider, model, prompt) {
*
* @param {object} args
* @param {string} args.starterPrompt — original
- * @param {string} [args.stylePrompt] — original (may be empty)
- * @param {string} [args.negativePrompt] — original (may be empty)
* @param {string} [args.logline] — original bible logline (may be empty)
* @param {string} [args.premise] — original bible premise (may be empty)
* @param {string} [args.styleNotes] — original bible style notes (may be empty)
- * @param {object} [args.influences] — { embrace, avoid }
+ * @param {object} [args.influences] — { embrace, avoid } — the universe's style + negative prompt tokens
* @param {object} [args.categories] — full categories map from the draft (with per-item locks)
* @param {Array} [args.compositeSheets] — composite sheets from the draft (with per-item locks)
* @param {object} [args.locked] — { field: true } for fields the user has pinned; locked fields are echoed back unchanged
@@ -433,8 +417,6 @@ async function runRefine(provider, model, prompt) {
*/
export async function refineWorldPrompts({
starterPrompt,
- stylePrompt = "",
- negativePrompt = "",
logline = "",
premise = "",
styleNotes = "",
@@ -508,8 +490,6 @@ export async function refineWorldPrompts({
// verbatim as the lock fallback below.
const originals = {
starterPrompt: trimTo(starterPrompt, STARTER_PROMPT_MAX),
- stylePrompt: trimTo(stylePrompt, PROMPT_FRAGMENT_MAX),
- negativePrompt: trimTo(negativePrompt, PROMPT_FRAGMENT_MAX),
logline: trimTo(logline, LOGLINE_MAX),
premise: trimTo(premise, PREMISE_MAX),
styleNotes: trimTo(styleNotes, STYLE_NOTES_MAX),
@@ -541,8 +521,6 @@ export async function refineWorldPrompts({
const FIELD_CAPS = {
starterPrompt: STARTER_PROMPT_MAX,
- stylePrompt: PROMPT_FRAGMENT_MAX,
- negativePrompt: PROMPT_FRAGMENT_MAX,
logline: LOGLINE_MAX,
premise: PREMISE_MAX,
styleNotes: STYLE_NOTES_MAX,
diff --git a/server/services/universeBuilderRefine.test.js b/server/services/universeBuilderRefine.test.js
index 0446aa67c5..9aa89ea1ba 100644
--- a/server/services/universeBuilderRefine.test.js
+++ b/server/services/universeBuilderRefine.test.js
@@ -73,42 +73,43 @@ describe("universeBuilderRefine.extractRefinementJson", () => {
});
describe("universeBuilderRefine.buildWorldRefinePrompt", () => {
- it("includes all three originals + feedback verbatim", () => {
+ it("includes originals + influences + feedback verbatim", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "moebius scavengers",
- stylePrompt: "comic ink, dust palette",
- negativePrompt: "lowres",
+ influences: {
+ embrace: ["comic ink", "dust palette"],
+ avoid: ["lowres"],
+ },
feedback: "lean grimmer and more spiritual",
});
expect(out).toContain("moebius scavengers");
expect(out).toContain("comic ink, dust palette");
expect(out).toContain("lowres");
expect(out).toContain("lean grimmer and more spiritual");
- // Schema must mention the three output keys so the LLM can comply.
+ // Schema must mention the canonical output keys so the LLM can comply.
expect(out).toContain('"starterPrompt"');
- expect(out).toContain('"stylePrompt"');
- expect(out).toContain('"negativePrompt"');
+ expect(out).toContain('"influences"');
});
it("substitutes (empty) for missing originals so the LLM sees the slot", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "seed",
- stylePrompt: "",
- negativePrompt: "",
feedback: "go dark",
});
- expect(out).toMatch(/ORIGINAL STYLE PROMPT:\n\(empty\)/);
- expect(out).toMatch(/ORIGINAL NEGATIVE PROMPT:\n\(empty\)/);
expect(out).toMatch(/ORIGINAL LOGLINE:\n\(empty\)/);
expect(out).toMatch(/ORIGINAL PREMISE:\n\(empty\)/);
expect(out).toMatch(/ORIGINAL STYLE NOTES:\n\(empty\)/);
+ // Influences carry the style + negative prompt now — verify the section
+ // header is present even with empty lists.
+ expect(out).toMatch(/ORIGINAL INFLUENCES:/);
+ // No standalone STYLE PROMPT / NEGATIVE PROMPT sections anymore.
+ expect(out).not.toContain("ORIGINAL STYLE PROMPT:");
+ expect(out).not.toContain("ORIGINAL NEGATIVE PROMPT:");
});
it("includes bible context (logline / premise / styleNotes) when provided", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "seed",
- stylePrompt: "s",
- negativePrompt: "",
logline: "A foundry city goes silent.",
premise: "Three families inherit the silence.",
styleNotes: "Tarkovsky pacing, Moebius palette.",
@@ -126,8 +127,6 @@ describe("universeBuilderRefine.buildWorldRefinePrompt", () => {
it("emits a LOCKED FIELDS section when fields are pinned", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "seed",
- stylePrompt: "",
- negativePrompt: "",
logline: "L",
premise: "",
styleNotes: "",
@@ -144,8 +143,6 @@ describe("universeBuilderRefine.buildWorldRefinePrompt", () => {
it("omits the LOCKED FIELDS section entirely when nothing is locked", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "seed",
- stylePrompt: "",
- negativePrompt: "",
feedback: "x",
});
expect(out).not.toContain("LOCKED FIELDS");
@@ -154,13 +151,11 @@ describe("universeBuilderRefine.buildWorldRefinePrompt", () => {
it("declares the structured influences schema in the output contract", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "seed",
- stylePrompt: "",
- negativePrompt: "",
feedback: "x",
});
- // Structured influences replaced the legacy "Style direction:" clause —
- // the renderer prepends them deterministically so the LLM has to populate
- // them for re-expansions to inherit direction.
+ // Structured influences ARE the style + negative prompt — the renderer
+ // joins them verbatim so the LLM has to populate them for re-expansions
+ // to inherit direction.
expect(out).toContain('"influences"');
expect(out).toContain('"embrace"');
expect(out).toContain('"avoid"');
@@ -171,8 +166,6 @@ describe("universeBuilderRefine.buildWorldRefinePrompt", () => {
it("embeds prior influences as ORIGINAL INFLUENCES context", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "seed",
- stylePrompt: "",
- negativePrompt: "",
influences: {
embrace: ["Moebius", "cel-shading"],
avoid: ["Ghibli painterly"],
@@ -187,8 +180,6 @@ describe("universeBuilderRefine.buildWorldRefinePrompt", () => {
it("renders ORIGINAL INFLUENCES with (none) when lists are empty", () => {
const out = buildWorldRefinePrompt({
starterPrompt: "seed",
- stylePrompt: "",
- negativePrompt: "",
feedback: "x",
});
expect(out).toMatch(/Embrace: \(none\)/);
diff --git a/server/services/universeCanon.js b/server/services/universeCanon.js
index 28aa811641..006e6ee90d 100644
--- a/server/services/universeCanon.js
+++ b/server/services/universeCanon.js
@@ -4,7 +4,7 @@
// refactor). The series-side helpers stay live until Phase B migrates
// series.cast → references into universe entities.
-import { getUniverse, updateUniverse, listUniverses } from './universeBuilder.js';
+import { getUniverse, updateUniverse, listUniverses, joinInfluenceList } from './universeBuilder.js';
import { extractBible } from '../lib/bibleExtractor.js';
import {
BIBLE_KIND, BIBLE_KINDS, BIBLE_FIELD, BIBLE_KEYS, BIBLE_SOURCE, mergeExtractedBible,
@@ -28,8 +28,9 @@ const targetForPrompt = (entry) => ({
});
const buildStyleClause = (universe) => {
+ const embraceTokens = joinInfluenceList(universe.influences?.embrace);
const bits = [
- universe.stylePrompt ? `Universe aesthetic: ${universe.stylePrompt}` : null,
+ embraceTokens ? `Universe aesthetic: ${embraceTokens}` : null,
universe.styleNotes ? `Universe notes: ${universe.styleNotes}` : null,
].filter(Boolean);
return bits.length ? bits.join('\n') : '(none provided — pick choices that fit the character\'s role and genre)';