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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: catch malformed comic script craft gaps
[._.]/ Adam Eivy30947bfd16c6
diff --git a/data.reference/prompts/stages/pipeline-script-verify.md b/data.reference/prompts/stages/pipeline-script-verify.mdindex a32c93f014..41898e1450 100644--- a/data.reference/prompts/stages/pipeline-script-verify.md+++ b/data.reference/prompts/stages/pipeline-script-verify.md@@ -22,9 +22,11 @@ Read the script page by page, panel by panel. Flag only concrete, fixable proble2. **Missing or malformed structure.** A page with no panels, a panel with no description, dialogue attributed to no one, an empty quoted dialogue line (`NAME: ""`) that would create a blank balloon, or a page that's actually prose paragraphs rather than panel breakdowns.3. **Panel-to-panel flow breaks.** A jump where the reader loses the thread between panels (an action with no establishing panel, a reaction with no cause shown, a location change with no re-establish).4. **Dialogue/art imbalance.** A panel buried under more dialogue/caption than a single image can carry (wall-of-text balloons), or a key beat with no dialogue *and* no clear visual.-5. **Continuity within the issue.** A character/prop/setting that appears, changes, or vanishes between panels without explanation (a gun drawn in panel 2 gone in panel 3 with no beat).+5. **Continuity within the issue.** A character/prop/setting that appears, changes, or vanishes between panels without explanation (a gun drawn in panel 2 gone in panel 3 with no beat), or a run of pages that repeats the same story beats so the reader cannot tell whether time is advancing.6. **Page-turn / beat placement.** A cliffhanger or reveal placed mid-page where a page turn would land it harder, or a page so overloaded it can't be drawn at the implied panel count.+Treat repeated confrontation beats as high severity when the same action cycle recurs across several pages without escalation or a new decision point — for example: a character refuses the same framing, a crowd reaction resets, the character approaches/crosses the same mark, an overlay/prop sharpens again, allies silently react again, and the same refusal speech restarts. The fix should collapse the loop into one clear progression and keep only the beats that advance the scene.+## Output contractReturn ONLY valid JSON matching this shape — no prose, no markdown fence, no commentary. Each `issues[]` entry must be **actionable** — name the page/panel, name the problem, and propose the smallest concrete fix:diff --git a/scripts/migrations/122-script-verify-continuity-loop-prompt.js b/scripts/migrations/122-script-verify-continuity-loop-prompt.jsnew file mode 100644index 0000000000..ba327f93aa--- /dev/null+++ b/scripts/migrations/122-script-verify-continuity-loop-prompt.js@@ -0,0 +1,42 @@+/**+ * Teach the comic-script verifier to flag repeated confrontation loops.+ *+ * The script-craft pass already checks malformed structure, but repeated+ * beats across a long scene can still leave an issue looking like time is not+ * advancing. This migration updates the verifier prompt with an explicit+ * continuity-loop rule while preserving customized installed prompts.+ */++import { makePromptReplaceMigration } from './_lib.js';++export const ACCEPTED_OLD_MD5 = {+ 'pipeline-script-verify.md': [+ 'ed6c8101644cfe56a100eb6bfe3587f3', // pre-122+ ],+};++export const NEW_SHIPPED_MD5 = {+ 'pipeline-script-verify.md': '722c62462d05462603cf67ca0ed1dee8', // post-122+};++const { applyMigration, up } = makePromptReplaceMigration({+ accepted: ACCEPTED_OLD_MD5,+ current: NEW_SHIPPED_MD5,+ label: 'script-verify continuity-loop prompt',+ customizedHint: (filename) =>+ ` To add the continuity-loop rule manually, diff:\n` ++ ` data.reference/prompts/stages/${filename}\n` ++ ` against your current:\n` ++ ` data/prompts/stages/${filename}\n` ++ ` and add the rule telling the verifier to flag repeated confrontation\n` ++ ` beat cycles where time does not appear to advance.`,+ skipFooter: (count) =>+ `⚠️ ${count} script-verify prompt(s) could not be auto-updated because\n` ++ ` they were customized. Comic script verification still runs, but long\n` ++ ` repeated beat loops may remain under-detected until you merge the\n` ++ ` prompt change manually.\n` ++ ` See data.reference/prompts/stages/pipeline-script-verify.md.`,+});++export { applyMigration };+export default { up };diff --git a/scripts/migrations/122-script-verify-continuity-loop-prompt.test.js b/scripts/migrations/122-script-verify-continuity-loop-prompt.test.jsnew file mode 100644index 0000000000..2f29d85c21--- /dev/null+++ b/scripts/migrations/122-script-verify-continuity-loop-prompt.test.js@@ -0,0 +1,14 @@+import { describe } from 'vitest';++import { runPromptMigrationTests } from './_testHelpers.js';+import migration, { applyMigration, ACCEPTED_OLD_MD5, NEW_SHIPPED_MD5 } from './122-script-verify-continuity-loop-prompt.js';++describe('migration 122 - script-verify continuity-loop prompt', () => {+ runPromptMigrationTests({+ migration,+ applyMigration,+ ACCEPTED_OLD_MD5,+ NEW_SHIPPED_MD5,+ prefix: 'migration-122-',+ });+});diff --git a/server/services/pipeline/scriptVerify.js b/server/services/pipeline/scriptVerify.jsindex ccf8bda37a..ed46c6fba8 100644--- a/server/services/pipeline/scriptVerify.js+++ b/server/services/pipeline/scriptVerify.js@@ -27,6 +27,12 @@ const VERIFY_PAGE_RE = /^##\s+Page\s+([\dIVX]+)\b/i;const VERIFY_PANEL_RE = /^(?:###\s+)?Panel\s+([\dIVX]+)\s*(?:\([^)]+\))?\s*:?\s*$/i;const VERIFY_FIELD_RE = /^(?:\*\*)?(Description|Caption(?:\s+\d+)?|Dialogue|SFX)\s*:(?:\*\*)?\s*(.*)$/i;const EMPTY_DIALOGUE_RE = /^[-*]?\s*([A-Z][A-Z0-9 '"&./()\-]*?):\s*(?:"\s*"|'\s*'|“\s*”|‘\s*’)\s*$/;+const EXCERPT_MAX = 140;++function excerpt(text, max = EXCERPT_MAX) {+ const t = String(text || '').replace(/\s+/g, ' ').trim();+ return t.length > max ? `${t.slice(0, max - 3)}...` : t;+}function emptyDialogueIssue(speaker, pageNumber, panelNumber) {const who = speaker.trim();@@ -38,6 +44,20 @@ function emptyDialogueIssue(speaker, pageNumber, panelNumber) {};}+function missingDescriptionIssue(pageNumber, panelNumber, firstUnlabeledLine) {+ const firstLine = excerpt(firstUnlabeledLine);+ return {+ severity: 'high',+ location: `page ${pageNumber || '?'} / panel ${panelNumber || '?'}`,+ problem: firstLine+ ? `The panel is missing the required "Description:" label before "${firstLine}". This can make the panel disappear from parsing or break production handoff.`+ : 'The panel is missing the required "Description:" field, so the artist/image pipeline has no labeled frame description to render.',+ suggestion: firstLine+ ? 'Add `Description:` before the panel description and keep Caption, Dialogue, and SFX as separate labeled fields.'+ : 'Add a concrete `Description:` field for the panel before Caption, Dialogue, or SFX.',+ };+}+function findEmptyDialogueIssues(script) {if (typeof script !== 'string' || !script.trim()) return [];const issues = [];@@ -82,6 +102,76 @@ function findEmptyDialogueIssues(script) {return shapeVerifyIssues(issues);}+function findMissingDescriptionIssues(script) {+ if (typeof script !== 'string' || !script.trim()) return [];+ const issues = [];+ let pageNumber = '';+ let panelNumber = '';+ let inPanel = false;+ let hasDescription = false;+ let firstUnlabeledLine = '';+ let activeField = null;++ const flushPanel = () => {+ if (!inPanel) return;+ if (!hasDescription) {+ issues.push(missingDescriptionIssue(pageNumber, panelNumber, firstUnlabeledLine));+ }+ };++ for (const raw of script.split(/\r?\n/)) {+ const line = raw || '';+ const pageMatch = line.match(VERIFY_PAGE_RE);+ if (pageMatch) {+ flushPanel();+ pageNumber = pageMatch[1];+ panelNumber = '';+ inPanel = false;+ hasDescription = false;+ firstUnlabeledLine = '';+ activeField = null;+ continue;+ }++ const panelMatch = line.match(VERIFY_PANEL_RE);+ if (panelMatch) {+ flushPanel();+ panelNumber = panelMatch[1];+ inPanel = true;+ hasDescription = false;+ firstUnlabeledLine = '';+ activeField = null;+ continue;+ }++ if (!inPanel) continue;++ const fieldMatch = line.match(VERIFY_FIELD_RE);+ if (fieldMatch) {+ const label = fieldMatch[1].toLowerCase().replace(/\s+\d+$/, '').trim();+ activeField = label;+ if (label === 'description') hasDescription = true;+ continue;+ }++ const t = line.trim();+ if (!t) continue;+ if (!hasDescription && !activeField && !firstUnlabeledLine) {+ firstUnlabeledLine = t;+ }+ }++ flushPanel();+ return shapeVerifyIssues(issues);+}++function findDeterministicIssues(script) {+ return mergeVerifyIssues(+ findMissingDescriptionIssues(script),+ findEmptyDialogueIssues(script),+ );+}+function issueKey(issue) {return `${issue.severity}|${issue.location}|${issue.problem}`;}@@ -107,7 +197,7 @@ export async function verifyComicScript(issueId, { providerId, model } = {}) {const issue = await getIssue(issueId);const script = (issue.stages?.comicScript?.output || '').trim();if (!script) return { issues: [], skipped: 'no-comic-script' };- const deterministicIssues = findEmptyDialogueIssues(script);+ const deterministicIssues = findDeterministicIssues(script);const series = await getSeries(issue.seriesId).catch(() => null);@@ -149,6 +239,8 @@ export async function verifyComicScript(issueId, { providerId, model } = {}) {}export const __testing = {+ findDeterministicIssues,findEmptyDialogueIssues,+ findMissingDescriptionIssues,mergeVerifyIssues,};diff --git a/server/services/pipeline/scriptVerify.test.js b/server/services/pipeline/scriptVerify.test.jsindex 38f0546af8..8fb4af90da 100644--- a/server/services/pipeline/scriptVerify.test.js+++ b/server/services/pipeline/scriptVerify.test.js@@ -1,7 +1,12 @@import { describe, expect, it } from 'vitest';import { __testing } from './scriptVerify.js';-const { findEmptyDialogueIssues, mergeVerifyIssues } = __testing;+const {+ findDeterministicIssues,+ findEmptyDialogueIssues,+ findMissingDescriptionIssues,+ mergeVerifyIssues,+} = __testing;describe('scriptVerify deterministic checks', () => {it('flags an empty quoted dialogue line with page and panel location', () => {@@ -58,4 +63,59 @@ describe('scriptVerify deterministic checks', () => {expect(findEmptyDialogueIssues(script)).toEqual([]);expect(mergeVerifyIssues(existing, existing)).toEqual(existing);});++ it('flags panel prose that is missing the Description label', () => {+ const script = [+ '## Page 7',+ '',+ 'Panel 4',+ 'Medium. Cassian taps the table twice, eyes fixed on the locked door.',+ 'Caption: (none)',+ 'Dialogue:',+ '- CASSIAN: "Now."',+ 'SFX: TAP TAP',+ ].join('\n');++ expect(findMissingDescriptionIssues(script)).toEqual([+ expect.objectContaining({+ severity: 'high',+ location: 'page 7 / panel 4',+ problem: expect.stringContaining('missing the required "Description:" label before "Medium. Cassian taps the table twice'),+ suggestion: expect.stringContaining('Add `Description:`'),+ }),+ ]);+ });++ it('flags a panel that has fields but no Description field', () => {+ const script = [+ '## Page 16',+ 'Panel 3',+ 'Caption: (none)',+ 'Dialogue:',+ '- JUNO: "No."',+ 'SFX: (none)',+ ].join('\n');++ expect(findMissingDescriptionIssues(script)).toEqual([+ expect.objectContaining({+ location: 'page 16 / panel 3',+ problem: expect.stringContaining('missing the required "Description:" field'),+ }),+ ]);+ });++ it('merges all deterministic script checks', () => {+ const script = [+ '## Page 1',+ 'Panel 1',+ 'Close. JUNO\'s eyes track the overlay.',+ 'Dialogue:',+ '- JUNO: ""',+ ].join('\n');++ const issues = findDeterministicIssues(script);+ expect(issues).toHaveLength(2);+ expect(issues.map((i) => i.problem).join('\n')).toContain('missing the required "Description:" label');+ expect(issues.map((i) => i.problem).join('\n')).toContain('empty quoted line');+ });});