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-canon): per-series filter, stylePromptOverride, sorted Appears-in

[._.]/ Adam Eivyfe6d3ce06e8b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 7b2ccc898a..4acc077ae0 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -3,7 +3,8 @@
## Added
- **Create Suite — Importer page (v1).** New on-ramp to the Create pipeline at `/importer` (also reachable via `⌘K → Importer`). Paste a finished short story / novel / screenplay / comic script + Universe Name + Series Name + content-type radio; the server runs three `heavy`-tier LLM passes (canon + arc in parallel, issue-proposal chained behind the arc summary), returns a preview, and the Review phase lets the user toggle per-entry canon checkboxes + edit the arc + issue titles / synopses / arc roles / per-issue season pickers before committing. On commit, `mergeExtractedBible` LWW-merges characters / places / objects into the universe (case-insensitive name match — preserves locked entries, never duplicates), `series.arc` + `series.seasons[]` are written, and one issue is created per proposal with `stages.prose.output` seeded with the verbatim source excerpt and `stages.idea.input` seeded with the LLM's logline + synopsis. Find-or-create on both universe + series names — re-running with the same names extends the existing world instead of forking a fresh one; series-name match is scoped to its universe so a typo can't cross-link. The series-arc lock is honored end-to-end (analyze fails fast with `ERR_LOCKED` so heavy-tier tokens aren't burned on a doomed run; commit double-checks under the read window). 200K-char hard cap on v1 source size — chunked-extraction follow-up captured in PLAN.md. Three new stage prompts (`importer-canon-extract.md`, `importer-arc-extract.md`, `importer-issue-proposal.md`) ship with per-content-type Liquid `{% if %}` branching; migration `015-importer-stage-prompts.js` seeds them into existing installs (idempotent — never overwrites a customized prompt). Wire-shape `places` maps to storage-shape `settings` at the orchestrator boundary so the UI + prompts already speak the forward-looking Phase 0b vocabulary while the on-disk schema stays unchanged. 11 unit tests cover find-or-create scoping, oversize rejection (no LLM call), locked-arc gating (no LLM call), canon merge correctness, prose+idea seeding, and second-pass dedup. Registered in `navManifest.js` (`nav.create.importer`), `Layout.jsx` sidebar (between Media Gen and Series Pipeline alphabetically), `App.jsx` lazy route, and `apiImporter.js` client wrapper.
-
+- **Universe Canon — per-series filter dropdown.** The Universe Canon page header now shows a Filter dropdown when the universe has more than one series with canon usage. Selecting a series narrows the page to canon entries that appear in that series' issues (derived from the existing `canonUsage` cross-reference, no new API call). Adds a `?series=<id>` URL param so filtered views are linkable; stale ids in the URL drop themselves silently. Per-kind section counts switch to "filtered / total" while a filter is active, and the empty-state for a kind now distinguishes "no canon of this kind in selected series" from "no canon at all". Bonus: the per-entry "Appears in" list is now sorted by `issueCount` descending (most-used series leads) with an alphabetical tiebreaker so the cross-reference reads consistently when two series tie.
+- **Pipeline series — per-series Universe style override.** Series linked to a universe can now set a `stylePromptOverride` that prepends ahead of the universe's `influences.embrace` for every image-gen call from that series. Lets a single series in a shared universe deviate visually (e.g. a noir spin-off) without forking the universe — the universe aesthetic still trails so it stays visible to the diffusion model. Server-side composition lives in `applyWorldStyle` in `visualStages.js`; client previews (NounsStage ref renders, clean plates) mirror the same composition. New textarea on the Series page is visible only when a universe is linked; max 1000 chars; empty falls through to universe-only style.
- **Settings → Image Gen → HuggingFace Token panel.** Adds a first-class place to paste, view, and clear the HuggingFace token used by gated local image models (FLUX.1-dev, FLUX.2-klein). The panel shows live status with source attribution (stored in `settings.json` vs `HF_TOKEN` env var vs `~/.cache/huggingface/token` from `hf auth login`) so it's clear which slot a token lives in; the Clear button only appears for stored tokens (env/CLI come from outside settings). The runner-side `GatedRepoError` message already pointed at "Image Gen settings" — that destination now exists. Backed by `GET /api/image-gen/setup/hf-token-status` (now returns `source`), the existing `POST` for save, and a new `DELETE /api/image-gen/setup/hf-token` for clear. Also: migration `012-mark-flux1-dev-gated.js` retrofits `requiresHfToken: true` + `licenseUrl` onto the FLUX.1-dev entry in existing installs' `data/media-models.json` (fresh installs were already covered via `data.sample`), so the inline banner on the Image Gen page surfaces for that model too — same flow that previously only worked for FLUX.2-klein.
- **Pipeline — issue back covers + volume (trade-paperback) covers + volume PDF.** Every comic issue now generates both a front and a back cover concept as part of the LLM comic-script pass (new `## Back cover concept` section, parsed alongside the existing `## Cover concept`). Both renders use the proof/final workflow and ship in the issue PDF as `cover → pages → back → colophon`. Each volume (season) gets its own front + back cover concepts via a new per-season LLM step (`POST /series/:id/seasons/:seasonId/cover-concepts/generate`) that seeds `season.cover.script` / `season.backCover.script` when blank (never clobbers user edits). The new `GET /series/:id/seasons/:seasonId/volume.pdf` compiles a full trade paperback: `[vol front] → [issue1 front → issue1 pages → issue1 back] → [issue2 …] → [vol back] → colophon`, sorted by `arcPosition ?? number`. Existing seasons get a "Generate cover concepts (LLM)" + "Compile volume PDF" button on each Arc canvas row to backfill. Migration `011-comic-script-back-cover.js` adds the back-cover section to the installed comic-script prompt for unmodified installs.
- **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`.
diff --git a/client/src/components/pipeline/stages/NounsStage.jsx b/client/src/components/pipeline/stages/NounsStage.jsx
index 631bc3ee77..58cc066a3c 100644
--- a/client/src/components/pipeline/stages/NounsStage.jsx
+++ b/client/src/components/pipeline/stages/NounsStage.jsx
@@ -71,6 +71,18 @@ const KINDS = [
},
];
+// Stitch the series' optional `stylePromptOverride` ahead of the linked
+// universe's stylePrompt — mirrors server-side `applyWorldStyle` in
+// visualStages.js so client preview renders match comic-page renders.
+const universeStylePreset = (universe, series) => {
+ if (!universe) return null;
+ const stylePrompt = [series?.stylePromptOverride, universe.stylePrompt]
+ .map((s) => (s || '').trim())
+ .filter(Boolean)
+ .join('. ');
+ return { prompt: stylePrompt, negativePrompt: universe.negativePrompt };
+};
+
export default function NounsStage({ issue, series }) {
const mountedRef = useMounted();
const prose = (issue.stages?.prose?.output || '').trim();
@@ -227,11 +239,14 @@ export default function NounsStage({ issue, series }) {
// Inject the universe's stylePrompt as a prefix and merge negativePrompts so
// ref images and comic pages share the same aesthetic (Codex doesn't
// accept reference images, so style consistency comes from text alone).
+ // `series.stylePromptOverride` prepends ahead of the universe style so
+ // a single series can deviate without forking the universe — mirrors
+ // server-side `applyWorldStyle` in visualStages.js.
const userPrompt = `${entry.name}: ${description}`;
const styled = composeStyledPrompt(
userPrompt,
baseOpts.negativePrompt || '',
- universe ? { prompt: universe.stylePrompt, negativePrompt: universe.negativePrompt } : null,
+ universeStylePreset(universe, series),
);
const payload = {
...baseOpts,
@@ -255,7 +270,7 @@ export default function NounsStage({ issue, series }) {
const styled = composeStyledPrompt(
plate.prompt,
plate.negativePrompt,
- universe ? { prompt: universe.stylePrompt, negativePrompt: universe.negativePrompt } : null,
+ universeStylePreset(universe, series),
);
const queued = await generateImage({
...baseOpts,
diff --git a/client/src/pages/PipelineSeries.jsx b/client/src/pages/PipelineSeries.jsx
index ea059fbbba..5bc896517f 100644
--- a/client/src/pages/PipelineSeries.jsx
+++ b/client/src/pages/PipelineSeries.jsx
@@ -93,7 +93,7 @@ export default function PipelineSeries() {
const flushPending = async () => {
if (!series) return false;
const saved = lastSavedRef.current || series;
- const fields = ['name', 'logline', 'premise', 'styleNotes', 'issueCountTarget', 'universeId'];
+ const fields = ['name', 'logline', 'premise', 'styleNotes', 'stylePromptOverride', 'issueCountTarget', 'universeId'];
const dirty = fields.some((k) => (series[k] ?? '') !== (saved[k] ?? ''))
|| JSON.stringify(series.characters || []) !== JSON.stringify(saved.characters || [])
|| JSON.stringify(series.llm || {}) !== JSON.stringify(saved.llm || {});
@@ -104,6 +104,7 @@ export default function PipelineSeries() {
premise: series.premise,
universeId: series.universeId || null,
styleNotes: series.styleNotes,
+ stylePromptOverride: series.stylePromptOverride || '',
issueCountTarget: series.issueCountTarget,
characters: series.characters,
llm: series.llm || { provider: null, model: null },
@@ -339,6 +340,22 @@ function BibleSidebar({ series, universes, patchSeries, onAddCharacter, onUpdate
</div>
</Field>
+ {series.universeId ? (
+ <Field label="Universe style override (this series only)">
+ <textarea
+ value={series.stylePromptOverride || ''}
+ onChange={(e) => patchSeries({ stylePromptOverride: e.target.value })}
+ rows={2}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"
+ maxLength={1000}
+ placeholder="moody noir lighting, high contrast monochrome. Prepended ahead of the universe's style so this series can deviate without forking the universe."
+ />
+ <p className="text-[11px] text-gray-500 mt-1">
+ Prepended ahead of the linked universe's <em>stylePrompt</em> for every image-gen call from this series. Leave blank to use the universe style verbatim.
+ </p>
+ </Field>
+ ) : null}
+
<div>
<div className="flex items-center justify-between mb-2">
<h3 className="text-xs uppercase tracking-wider text-gray-500">Characters</h3>
diff --git a/client/src/pages/UniverseCanon.jsx b/client/src/pages/UniverseCanon.jsx
index e7efe923cf..74c3c506c9 100644
--- a/client/src/pages/UniverseCanon.jsx
+++ b/client/src/pages/UniverseCanon.jsx
@@ -9,9 +9,9 @@
*/
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import { Link, useParams } from 'react-router-dom';
+import { Link, useParams, useSearchParams } from 'react-router-dom';
import {
- Library, Loader2, Users, MapPin, Package, Globe2, Wand2, ArrowLeft,
+ Library, Loader2, Users, MapPin, Package, Globe2, Wand2, ArrowLeft, Filter,
} from 'lucide-react';
import toast from '../components/ui/Toast';
import {
@@ -65,6 +65,8 @@ const KINDS = [
export default function UniverseCanon() {
const { universeId } = useParams();
+ const [searchParams, setSearchParams] = useSearchParams();
+ const seriesFilter = searchParams.get('series') || '';
const mountedRef = useMounted();
const [universe, setUniverse] = useState(null);
const [loadErr, setLoadErr] = useState(null);
@@ -109,6 +111,64 @@ export default function UniverseCanon() {
}, [universeId, mountedRef]);
useEffect(() => { refreshUsage(); }, [refreshUsage]);
+ // Series-with-usage options for the filter dropdown. Derived from the
+ // usage map rather than a fresh API call so the dropdown only lists
+ // series that actually reference this universe's canon — a series linked
+ // to the universe with zero issues has nothing to filter to.
+ const seriesOptions = useMemo(() => {
+ if (!usage) return [];
+ const seen = new Map();
+ for (const kind of KINDS) {
+ const perEntry = usage[kind.key] || {};
+ for (const list of Object.values(perEntry)) {
+ for (const row of (list || [])) {
+ if (row?.seriesId && !seen.has(row.seriesId)) {
+ seen.set(row.seriesId, row.seriesName || row.seriesId);
+ }
+ }
+ }
+ }
+ return [...seen.entries()]
+ .map(([id, name]) => ({ id, name }))
+ .sort((a, b) => a.name.localeCompare(b.name));
+ }, [usage]);
+
+ // If the URL names a series that isn't in this universe's usage map
+ // (stale bookmark, deleted series), drop the param silently so the page
+ // doesn't show an empty "filtered" view forever.
+ useEffect(() => {
+ if (!usage || !seriesFilter) return;
+ if (!seriesOptions.some((s) => s.id === seriesFilter)) {
+ const next = new URLSearchParams(searchParams);
+ next.delete('series');
+ setSearchParams(next, { replace: true });
+ }
+ }, [usage, seriesFilter, seriesOptions, searchParams, setSearchParams]);
+
+ const handleSeriesFilterChange = useCallback((value) => {
+ const next = new URLSearchParams(searchParams);
+ if (value) next.set('series', value);
+ else next.delete('series');
+ setSearchParams(next, { replace: true });
+ }, [searchParams, setSearchParams]);
+
+ // Build a per-kind filtered entry list. When no filter is active the
+ // raw universe arrays pass through unchanged.
+ const filteredByKind = useMemo(() => {
+ if (!universe) return {};
+ const out = {};
+ for (const kind of KINDS) {
+ const all = Array.isArray(universe[kind.key]) ? universe[kind.key] : [];
+ if (!seriesFilter || !usage) { out[kind.key] = all; continue; }
+ const perEntry = usage[kind.key] || {};
+ out[kind.key] = all.filter((entry) => {
+ const rows = perEntry[entry.id] || [];
+ return rows.some((r) => r.seriesId === seriesFilter);
+ });
+ }
+ return out;
+ }, [universe, usage, seriesFilter]);
+
const previewItems = useMemo(() => {
if (!universe) return [];
const out = [];
@@ -312,6 +372,23 @@ export default function UniverseCanon() {
</p>
</div>
<div className="flex items-center gap-2 flex-wrap">
+ {seriesOptions.length > 1 ? (
+ <label className="inline-flex items-center gap-1.5 px-2 py-1.5 rounded-lg bg-port-card border border-port-border text-gray-300 text-sm">
+ <Filter size={12} className="text-gray-500" />
+ <span className="sr-only">Filter by series</span>
+ <select
+ value={seriesFilter}
+ onChange={(e) => handleSeriesFilterChange(e.target.value)}
+ className="bg-transparent text-xs focus:outline-none"
+ aria-label="Filter canon by series"
+ >
+ <option value="">All series</option>
+ {seriesOptions.map((s) => (
+ <option key={s.id} value={s.id}>{s.name}</option>
+ ))}
+ </select>
+ </label>
+ ) : null}
<button
type="button"
onClick={() => setExtractOpen((v) => !v)}
@@ -363,11 +440,24 @@ export default function UniverseCanon() {
</section>
) : null}
+ {seriesFilter && seriesOptions.length > 1 ? (
+ <p className="text-xs text-gray-500 italic">
+ Showing canon used in <span className="text-gray-300">{seriesOptions.find((s) => s.id === seriesFilter)?.name || 'selected series'}</span>.{' '}
+ <button
+ type="button"
+ onClick={() => handleSeriesFilterChange('')}
+ className="text-port-accent hover:underline"
+ >Clear filter</button>
+ </p>
+ ) : null}
+
{KINDS.map((kind) => (
<KindSection
key={kind.key}
kind={kind}
- all={universe[kind.key] || []}
+ all={filteredByKind[kind.key] || []}
+ totalCount={(universe[kind.key] || []).length}
+ filtered={!!seriesFilter}
usage={usage?.[kind.key] || null}
renderingJobs={renderingJobs}
onRender={(entry) => handleRenderRef(kind, entry)}
@@ -388,18 +478,22 @@ export default function UniverseCanon() {
);
}
-function KindSection({ kind, all, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onToggleLock, togglingLockId, onPatchEntry, onRenderCleanPlate }) {
+function KindSection({ kind, all, totalCount, filtered, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onToggleLock, togglingLockId, onPatchEntry, onRenderCleanPlate }) {
const Icon = kind.icon;
return (
<section className="rounded-lg border border-port-border bg-port-card/40">
<div className="flex items-center gap-2 px-3 py-2 border-b border-port-border">
<Icon size={14} className="text-gray-400" />
<h3 className="text-sm font-semibold text-white">{kind.label}</h3>
- <span className="text-[10px] text-gray-500">{all.length}</span>
+ <span className="text-[10px] text-gray-500">
+ {filtered && totalCount !== all.length ? `${all.length} / ${totalCount}` : all.length}
+ </span>
</div>
<div className="p-3">
{all.length === 0 ? (
- <p className="text-xs text-gray-500 italic">No {kind.label.toLowerCase()} yet. Use <em>Extract from prose</em> above to populate this list from an issue.</p>
+ filtered && totalCount > 0
+ ? <p className="text-xs text-gray-500 italic">No {kind.label.toLowerCase()} in the selected series. {totalCount} total in this universe — clear the filter to see them all.</p>
+ : <p className="text-xs text-gray-500 italic">No {kind.label.toLowerCase()} yet. Use <em>Extract from prose</em> above to populate this list from an issue.</p>
) : (
<ul className="space-y-2">
{all.map((entry) => (
diff --git a/server/routes/pipeline.js b/server/routes/pipeline.js
index dbd7e41179..200d237879 100644
--- a/server/routes/pipeline.js
+++ b/server/routes/pipeline.js
@@ -208,6 +208,7 @@ const seriesCreateSchema = z.object({
seasons: z.array(seasonSchema).max(ARC_LIMITS.SEASONS_PER_SERIES_MAX).optional(),
locked: seriesLockedSchema.optional(),
styleNotes: z.string().trim().max(seriesSvc.STYLE_NOTES_MAX).optional().default(''),
+ stylePromptOverride: z.string().trim().max(seriesSvc.STYLE_PROMPT_OVERRIDE_MAX).optional().default(''),
visualStyleDefault: visualStyleRefSchema.optional(),
targetFormat: z.enum(seriesSvc.TARGET_FORMATS).optional(),
issueCountTarget: z.number().int().min(0).max(seriesSvc.ISSUE_COUNT_TARGET_MAX).optional(),
@@ -227,6 +228,7 @@ const seriesPatchSchema = z.object({
seasons: z.array(seasonSchema).max(ARC_LIMITS.SEASONS_PER_SERIES_MAX).optional(),
locked: seriesLockedSchema.optional(),
styleNotes: z.string().trim().max(seriesSvc.STYLE_NOTES_MAX).optional(),
+ stylePromptOverride: z.string().trim().max(seriesSvc.STYLE_PROMPT_OVERRIDE_MAX).optional(),
visualStyleDefault: visualStyleRefSchema.optional(),
targetFormat: z.enum(seriesSvc.TARGET_FORMATS).optional(),
issueCountTarget: z.number().int().min(0).max(seriesSvc.ISSUE_COUNT_TARGET_MAX).optional(),
diff --git a/server/services/canonUsage.js b/server/services/canonUsage.js
index cca7569a57..fb63fb2ea2 100644
--- a/server/services/canonUsage.js
+++ b/server/services/canonUsage.js
@@ -91,12 +91,14 @@ export async function getUniverseCanonUsage(universeId) {
const shape = (perKind) => {
const out = {};
for (const [entryId, perSeries] of perKind.entries()) {
- out[entryId] = [...perSeries.entries()].map(([seriesId, { seriesName, issueIds }]) => ({
- seriesId,
- seriesName,
- issueIds: [...issueIds],
- issueCount: issueIds.size,
- }));
+ out[entryId] = [...perSeries.entries()]
+ .map(([seriesId, { seriesName, issueIds }]) => ({
+ seriesId,
+ seriesName,
+ issueIds: [...issueIds],
+ issueCount: issueIds.size,
+ }))
+ .sort((a, b) => b.issueCount - a.issueCount || a.seriesName.localeCompare(b.seriesName));
}
return out;
};
diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.js
index ac972e5412..ad13c455b5 100644
--- a/server/services/pipeline/series.js
+++ b/server/services/pipeline/series.js
@@ -59,6 +59,7 @@ export const NAME_MAX = 200;
export const LOGLINE_MAX = 500;
export const PREMISE_MAX = 8000;
export const STYLE_NOTES_MAX = 4000;
+export const STYLE_PROMPT_OVERRIDE_MAX = 1000;
export const CHARACTER_NAME_MAX = BIBLE_LIMITS.NAME_MAX;
export const CHARACTER_DESCRIPTION_MAX = BIBLE_LIMITS.PHYSICAL_DESCRIPTION_MAX;
export const CHARACTERS_PER_SERIES_MAX = BIBLE_LIMITS.ENTRIES_PER_BIBLE_MAX;
@@ -119,6 +120,12 @@ const sanitizeSeries = (raw) => {
seasons: sanitizeSeasonList(raw.seasons),
locked: sanitizeSeriesLocked(raw.locked),
styleNotes: trimTo(raw.styleNotes, STYLE_NOTES_MAX),
+ // Per-series override that prepends ahead of the linked universe's
+ // stylePrompt during image-gen composition. Lets a single series in a
+ // shared universe deviate slightly (e.g. a noir spin-off) without
+ // forking the universe. Empty string = no override; fall through to
+ // universe-only style.
+ stylePromptOverride: trimTo(raw.stylePromptOverride, STYLE_PROMPT_OVERRIDE_MAX),
// Series-level default visual style (catalog id + optional custom prompt).
// `null` when the user hasn't picked one — stage-level fallbacks in
// resolveVisualStyle() handle that case so legacy series keep rendering
@@ -177,6 +184,7 @@ export async function createSeries(input = {}) {
seasons: input.seasons || [],
locked: input.locked || {},
styleNotes: input.styleNotes || '',
+ stylePromptOverride: input.stylePromptOverride || '',
targetFormat: input.targetFormat || 'comic+tv',
issueCountTarget: input.issueCountTarget || 0,
llm: input.llm || null,
@@ -240,6 +248,7 @@ export async function updateSeries(id, patch = {}) {
// Wholesale replace — `locked: {}` clears every lock; omission preserves.
...('locked' in patch ? { locked: patch.locked } : {}),
...('styleNotes' in patch ? { styleNotes: patch.styleNotes } : {}),
+ ...('stylePromptOverride' in patch ? { stylePromptOverride: patch.stylePromptOverride } : {}),
...('visualStyleDefault' in patch ? { visualStyleDefault: patch.visualStyleDefault } : {}),
...('targetFormat' in patch ? { targetFormat: patch.targetFormat } : {}),
...('issueCountTarget' in patch ? { issueCountTarget: patch.issueCountTarget } : {}),
diff --git a/server/services/pipeline/visualStages.js b/server/services/pipeline/visualStages.js
index 2b9812d45e..a12674397a 100644
--- a/server/services/pipeline/visualStages.js
+++ b/server/services/pipeline/visualStages.js
@@ -55,9 +55,20 @@ const stackStyle = (series, extraStyle) => joinStyleParts(series?.styleNotes, ex
const composeExtraStyle = (series, issue, stageId, callerExtraStyle = '') =>
joinStyleParts(resolveVisualStyle(series, issue, stageId)?.promptFragment, callerExtraStyle);
-const applyWorldStyle = (prompt, world) => {
- if (!world) return prompt;
- const stylePrompt = joinInfluenceList(world.influences?.embrace);
+// Build the style-prompt prefix for a series + universe pair. The per-series
+// override prepends ahead of the universe's embrace influences so a single
+// series can deviate (e.g. a noir spin-off) without forking the universe;
+// the universe's broader aesthetic still trails so it stays visible to the
+// diffusion model. Returns '' when neither side has content — caller skips
+// the composeStyledPrompt wrap in that case.
+const buildStyleClause = (world, series) => {
+ const override = (series?.stylePromptOverride || '').trim();
+ const universeStyle = joinInfluenceList(world?.influences?.embrace);
+ return [override, universeStyle].filter(Boolean).join('. ');
+};
+
+const applyWorldStyle = (prompt, world, series = null) => {
+ const stylePrompt = buildStyleClause(world, series);
if (!stylePrompt) return prompt;
return composeStyledPrompt(prompt, '', { prompt: stylePrompt, negativePrompt: '' }).prompt;
};
@@ -185,7 +196,7 @@ export function composeVisualPrompt({ series, description, slugline = '', extraS
stackStyle(series, extraStyle),
matchSceneSetting(slugline, map),
);
- return applyWorldStyle(scenePrompt, world);
+ return applyWorldStyle(scenePrompt, world, series);
}
// Marvel/DC scripts attach parentheticals to speakers — `ETTA (EARPIECE):`,
@@ -272,7 +283,7 @@ export function composeComicCoverPrompt({
const layout = `A single full printable comic-book front cover for a serialized issue. ${titleBlock} ${numberBlock}${titleLine} The rest of the cover is one bold hero image (no panel borders, no multi-panel layout — this is the cover, not an interior page).${styleClause}`;
const body = `Cover concept: ${sceneDescription}`;
- return applyWorldStyle(`${layout}\n\n${body}`, world);
+ return applyWorldStyle(`${layout}\n\n${body}`, world, series);
}
/**
@@ -302,7 +313,7 @@ export function composeComicBackCoverPrompt({
const layout = `A single full printable comic-book BACK cover for a serialized issue. NO text of any kind — no masthead, no logo, no title, no issue-number tag, no UPC, no credits, no typography, no captions, no panel borders, no multi-panel layout. The entire cover is one bold illustrated hero image, edge-to-edge.${styleClause}`;
const body = `Back-cover concept: ${sceneDescription}`;
- return applyWorldStyle(`${layout}\n\n${body}`, world);
+ return applyWorldStyle(`${layout}\n\n${body}`, world, series);
}
/**
@@ -426,7 +437,7 @@ export function composeVolumeCoverPrompt({
const layout = `A single full printable comic-book trade-paperback FRONT cover collecting an entire volume of issues. ${titleBlock} ${numberBlock}${titleLine} The rest of the cover is one bold hero image — bigger and more iconic than any single-issue cover (no panel borders, no multi-panel layout — this is a collected-edition cover).${styleClause}`;
const body = `Volume cover concept: ${sceneDescription}`;
- return applyWorldStyle(`${layout}\n\n${body}`, world);
+ return applyWorldStyle(`${layout}\n\n${body}`, world, series);
}
export function composeVolumeBackCoverPrompt({
@@ -445,7 +456,7 @@ export function composeVolumeBackCoverPrompt({
const layout = `A single full printable comic-book trade-paperback BACK cover. NO text of any kind — no masthead, no logo, no title, no volume tag, no UPC, no credits, no typography, no captions, no panel borders, no multi-panel layout. The entire cover is one bold illustrated hero image, edge-to-edge.${styleClause}`;
const body = `Volume back-cover concept: ${sceneDescription}`;
- return applyWorldStyle(`${layout}\n\n${body}`, world);
+ return applyWorldStyle(`${layout}\n\n${body}`, world, series);
}
/**
@@ -593,7 +604,7 @@ export function composeComicPagePrompt({
const settingClause = settingsClause ? `\n\nSetting — ${settingsClause}` : '';
const notableClause = notable ? `\n\nNotable — ${notable}` : '';
- return applyWorldStyle(`${layout}${featuringClause}${settingClause}${notableClause}\n\n${panelLines.join('\n\n')}`, world);
+ return applyWorldStyle(`${layout}${featuringClause}${settingClause}${notableClause}\n\n${panelLines.join('\n\n')}`, world, series);
}
/**
diff --git a/server/services/pipeline/visualStages.test.js b/server/services/pipeline/visualStages.test.js
index 32e1ce6e2c..053f23d006 100644
--- a/server/services/pipeline/visualStages.test.js
+++ b/server/services/pipeline/visualStages.test.js
@@ -203,6 +203,45 @@ describe('composeComicPagePrompt', () => {
expect(prompt).toMatch(/cinematic ink illustration/);
});
+ it('prepends series.stylePromptOverride ahead of the universe embrace tokens', () => {
+ // A per-series override lets one series in a shared universe deviate
+ // visually (e.g. a noir spin-off) without forking the universe. The
+ // override prepends so its tokens land in the heaviest position, with
+ // the universe style trailing — both must appear, override first.
+ const world = {
+ influences: {
+ embrace: ['cinematic ink illustration', 'dramatic lighting'],
+ avoid: [],
+ },
+ };
+ const seriesWithOverride = { ...SERIES, stylePromptOverride: 'moody noir lighting, high contrast monochrome' };
+ const prompt = composeComicPagePrompt({ series: seriesWithOverride, world, page: PAGE, pageNumber: 1 });
+ const overrideAt = prompt.indexOf('moody noir lighting');
+ const universeAt = prompt.indexOf('cinematic ink illustration');
+ expect(overrideAt).toBeGreaterThanOrEqual(0);
+ expect(universeAt).toBeGreaterThanOrEqual(0);
+ expect(overrideAt).toBeLessThan(universeAt);
+ });
+
+ it('falls through to universe-only style when stylePromptOverride is empty', () => {
+ const world = {
+ influences: { embrace: ['cinematic ink illustration'], avoid: [] },
+ };
+ const seriesNoOverride = { ...SERIES, stylePromptOverride: '' };
+ const prompt = composeComicPagePrompt({ series: seriesNoOverride, world, page: PAGE, pageNumber: 1 });
+ expect(prompt).toMatch(/cinematic ink illustration/);
+ expect(prompt).not.toMatch(/moody noir/);
+ });
+
+ it('applies stylePromptOverride even without a universe (no embrace tokens)', () => {
+ // The override is independent of the universe — if the series has an
+ // override but isn't linked to a universe (or the universe has no
+ // embrace tokens), the override still prepends to the prompt.
+ const seriesWithOverride = { ...SERIES, stylePromptOverride: 'experimental rotoscope' };
+ const prompt = composeComicPagePrompt({ series: seriesWithOverride, page: PAGE, pageNumber: 1 });
+ expect(prompt).toMatch(/experimental rotoscope/);
+ });
+
it('appends extraStyle into the Art style clause', () => {
const prompt = composeComicPagePrompt({
series: SERIES,