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

address review (codex): normalize dialogue speakers, only generate target scripts

[._.]/ Adam Eivy4575d7d141a4
diff --git a/server/services/pipeline/autoRunner.js b/server/services/pipeline/autoRunner.js
index 6627f2d13c..c6438ef83d 100644
--- a/server/services/pipeline/autoRunner.js
+++ b/server/services/pipeline/autoRunner.js
@@ -66,9 +66,18 @@ export async function startAutoRunTextStages(issueId, options = {}) {
// permitted boundary use of try/catch in this module — without it an LLM
// rejection would surface as an unhandledRejection on Node ≥15 and kill the
// process. See ~/.claude skill `nodejs-async-event-listener-unhandled-rejection`.
+ // Which script stages to adapt from prose. Defaults to both (manual auto-run
+ // from the UI); callers targeting a single format (e.g. Series Autopilot on a
+ // comic-only series) pass `scripts: ['comicScript']` to skip the off-target
+ // stage and its LLM call. Unknown entries are filtered out.
+ const VALID_SCRIPTS = ['comicScript', 'teleplay'];
+ const scripts = Array.isArray(options.scripts) && options.scripts.length
+ ? VALID_SCRIPTS.filter((s) => options.scripts.includes(s))
+ : VALID_SCRIPTS;
+
(async () => {
await updateIssue(issueId, { status: 'running' }).catch(() => null);
- broadcast(issueId, { type: 'start', runId, stages: ['idea', 'prose', 'comicScript', 'teleplay'] });
+ broadcast(issueId, { type: 'start', runId, stages: ['idea', 'prose', ...scripts] });
try {
// Stage 1: idea — skip if already ready/edited and not force-rerun
@@ -103,7 +112,7 @@ export async function startAutoRunTextStages(issueId, options = {}) {
// the authored script runs through runStageIfNeeded and is skipped as
// already-ready. `force` still regenerates everything.
if (!record.cancelRequested) {
- await Promise.all(['comicScript', 'teleplay'].map(async (stageId) => {
+ await Promise.all(scripts.map(async (stageId) => {
if (scriptFirstSkip && !options.force) {
const iss = await getIssue(issueId);
if (!isStageReady(iss.stages?.[stageId])) {
diff --git a/server/services/pipeline/autoRunner.test.js b/server/services/pipeline/autoRunner.test.js
index c0513a0a53..2946f79488 100644
--- a/server/services/pipeline/autoRunner.test.js
+++ b/server/services/pipeline/autoRunner.test.js
@@ -101,6 +101,19 @@ describe('pipeline auto-runner', () => {
expect(final.status).toBe('needs-review');
});
+ it('only generates the requested script stages via the scripts option', async () => {
+ const { issue } = await seed();
+ await autoRunner.startAutoRunTextStages(issue.id, { scripts: ['comicScript'] });
+ await waitFor(() => {
+ const run = autoRunner.__testing.runs.get(issue.id);
+ return run?.lastPayload?.type === 'complete';
+ });
+ expect(generated).toContain('idea');
+ expect(generated).toContain('prose');
+ expect(generated).toContain('comicScript');
+ expect(generated).not.toContain('teleplay');
+ });
+
it('skips a stage that is already ready (no force)', async () => {
const { issue } = await seed();
await issuesSvc.updateStage(issue.id, 'idea', { status: 'ready', output: 'PREFILLED-IDEA' });
diff --git a/server/services/pipeline/canonReadiness.js b/server/services/pipeline/canonReadiness.js
index 443d4c607d..6e2b4629db 100644
--- a/server/services/pipeline/canonReadiness.js
+++ b/server/services/pipeline/canonReadiness.js
@@ -134,7 +134,11 @@ export function gradeComicReferencedNouns(comicScript, canon, thinChars = CANON_
for (const pa of Array.isArray(pg.panels) ? pg.panels : []) {
consume(pa.description);
for (const d of Array.isArray(pa.dialogue) ? pa.dialogue : []) {
- if (d.character) speakers.push(d.character);
+ // Strip a trailing dialogue modifier — `KAI (WHISPERED)` → `KAI` — so
+ // the speaker matches its canon name (the description-line path already
+ // strips it via PANEL_LABEL_LINE; structured dialogue needs it too).
+ const name = d.character && d.character.replace(/\s*\([^)]*\)\s*$/, '').trim();
+ if (name) speakers.push(name);
}
}
}
diff --git a/server/services/pipeline/canonReadiness.test.js b/server/services/pipeline/canonReadiness.test.js
index 007fac8a0e..066c4141a1 100644
--- a/server/services/pipeline/canonReadiness.test.js
+++ b/server/services/pipeline/canonReadiness.test.js
@@ -123,6 +123,13 @@ describe('checkIssueCanonReadiness (matches the visual source)', () => {
expect(report.none.map((n) => n.name)).toContain('Kai');
});
+ it('matches a speaker even with a dialogue modifier (KAI (WHISPERED): …)', async () => {
+ canon = { characters: [{ id: 'c1', name: 'Kai', physicalDescription: '' }], places: [], objects: [] };
+ const issueId = await seedIssue({ comicScript: 'PAGE 1\nPANEL 1\nTwo figures in shadow.\nKAI (WHISPERED): I built it.' });
+ const report = await checkIssueCanonReadiness(issueId);
+ expect(report.none.map((n) => n.name)).toContain('Kai');
+ });
+
it('does NOT flag an off-page character (in prose only, not in panels)', async () => {
// Aria appears only in prose narration, never in the comic-script panels.
canon = { characters: [{ id: 'c1', name: 'Aria', physicalDescription: '' }], places: [], objects: [] };
diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.js
index e582c3b698..5dd7b9b4d9 100644
--- a/server/services/pipeline/seriesAutopilot.js
+++ b/server/services/pipeline/seriesAutopilot.js
@@ -455,9 +455,14 @@ const runBeats = (seriesId, seasonId, record) => runChildToCompletion(record, {
async function runText(issueId, record) {
record.runState.textAttempted.add(issueId);
+ // Only adapt the target format's script(s) — a single-format series shouldn't
+ // spend LLM calls populating the off-target script across every issue.
+ const preIssue = await getIssue(issueId);
+ const preSeries = await getSeries(preIssue.seriesId).catch(() => null);
+ const scripts = requiredScriptStages(preSeries);
// Forward the run's provider/model override so prose + scripts honor it like
// every other step (autoRunner threads these into generateStage).
- await autoRunner.startAutoRunTextStages(issueId, { force: false, ...providerIdOpts(record) });
+ await autoRunner.startAutoRunTextStages(issueId, { force: false, scripts, ...providerIdOpts(record) });
record.activeChild = { kind: 'text', id: issueId };
await waitForChild(() => autoRunner.isAutoRunActive(issueId), record);
record.activeChild = null;