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

Merge remote-tracking branch 'origin/main' into next/issue-1315

Adam Eivy0e04f81f3185
diff --cc .changelog/NEXT.md
index dd0b667d4a,0679bdd789..1c8b07772a
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -2,8 -2,10 +2,11 @@@
## Added
+- **[issue-1315] Storyboard shots now record camera framing + screen direction, and a new editorial check catches film-grammar continuity errors before render.** Each storyboard shot gains two film-grammar fields — **shot type** (extreme-wide / wide / medium / close / extreme-close / over-the-shoulder / two-shot / POV) and **screen direction** (the side the subject faces or moves: left / right / neutral) — captured by the scene extractor (the teleplay→scenes prompt now asks the model to tag them) and carried on the shot record. A new deterministic **Storyboard shot continuity** check (Create → Editorial Checks) reads those fields and flags two classic film-grammar mistakes *before* you spend render time on a clip: a **180-degree-rule axis reversal** — a shot that continues from an earlier one but flips the subject to the opposite side of the screen, so they appear to jump sides across the cut — and **shot-type monotony**, a scene whose shots all share one framing and read as flat, slideshow coverage with no establishing wide or punch-in. Findings render as `Continuity` notes anchored to the offending issue + scene, and (being deterministic) need no LLM. Both fields are backward-compatible and default to "not captured," so older storyboards simply aren't flagged until re-extracted; the extraction-prompt change migrates for existing installs (114). Eyeline-match and appearance/prop continuity (which need a vision/LLM pass) and a hard pre-render render-gate are tracked as follow-ups. (`server/lib/shotGrammar.js`, `server/lib/sceneExtractor.js`, `server/lib/editorial/shotContinuity.js`, `server/lib/editorial/checkRegistry.js`, `server/services/pipeline/editorial/checkRunner.js`, `scripts/migrations/114-extract-scenes-shot-grammar.js`, #1315)
+ - **Digital Twin federation now syncs your *whole* identity — taste profile, documents, and autobiography — not just the four core files.** The `digitalTwin` sync category only ever transferred `identity` / `chronotype` / `longevity` / `feedback`, so a peer could read **"Digital Twin: synced"** while your taste questionnaire, soul documents, and autobiography stories never crossed between machines (they were never wired into the snapshot at all). The snapshot now covers everything under `data/digital-twin/`: the **taste profile** (responses union per section by `questionId`, LWW — answers given on either machine survive), **meta.json** (documents/test-histories/personas union by id, enrichment deep-unioned, settings fill-missing), the **`.md` documents** themselves (shipped by filename, written **add-only** so a local doc is never overwritten — with a path-traversal guard on peer-supplied names), and the **autobiography** (stories union by id with LWW, prompt schedule stays machine-local). The merge is additive and key-presence-guarded, so an older peer that still sends only the four legacy keys can't blank out the new data, and no schemaVersions gate is needed (digitalTwin stays unversioned). The "Digital Twin" sync-category description in the Instances UI now reflects the full coverage. (`server/services/digital-twin-sync.js`, `server/services/dataSync.js`, `client/src/pages/Instances.jsx`)
+
- **[issue-1310] Editorial check flags plot-structure & momentum problems — passive protagonist, deus ex machina, idiot plot, flat stakes, sagging middle, dropped subplots.** A new **Plot structure & momentum** check (Create → Editorial Checks) reads your drafted manuscript and surfaces the macro pathologies a developmental editor flags at the arc level: a **passive protagonist** (events happen *to* them instead of being driven by their choices), a **deus ex machina / convenient coincidence** that resolves a problem by luck rather than setup, an **idiot plot** that only holds together because someone won't say the obvious, **flat or unclear stakes** that never escalate, a **sagging middle** with no try-fail rhythm, and **dropped subplots** — threads that open and then fizzle. It reconciles dropped threads against your reverse-outline plotline tags and your authored reader-map hooks/payoffs, and defers whole-arc judgments (a sagging middle, a never-resolved thread) until it has seen the whole manuscript so a long book reviewed in chunks isn't false-flagged. Findings render as `Plot structure` notes in the manuscript editor, anchored to the issue and (where one exists) a verbatim quote. Ships a new stage prompt (`pipeline-editorial-plot-structure`) that migrates for existing installs (111). (#1310)
+ - **[issue-1313] Editorial check flags over-stuffed comic panels (lettering density / balloon load).** A new **Comic lettering density / balloon load** check (Create → Editorial Checks) reads each issue's comic script and counts the lettering load the art has to make room for — the #1 reader gripe in comics being a wall of text crammed into one panel. It flags **over-stuffed balloons** (a single balloon past ~25 words), **over-stuffed panels** (more than ~50 words of dialogue + caption + SFX, or more than ~3 balloons fighting for room), and **text-heavy pages** whose total lettering would overwhelm the illustration — all thresholds configurable, with severity scaled by how far over the limit a panel runs and a fix suggestion (split the balloon, move to a caption, or break into another panel). Findings render as `Lettering` notes in the manuscript editor anchored to the issue/page/panel; the same accounting also surfaces **inline in the comic-script stage**, so over-stuffed pages warn you as you edit without waiting for an editorial-checks run. The check is deterministic — no model needed. (`server/lib/editorial/letteringDensity.js`, `server/lib/editorial/checkRegistry.js`, `client/src/lib/letteringDensity.js`, `client/src/components/pipeline/stages/ComicScriptStage.jsx`, #1313)
- **[issue-1311] Editorial check flags head-hopping / POV-discipline breaks within a scene.** A new **Head-hopping / POV discipline** LLM check (Create → Editorial Checks) polices viewpoint discipline in limited-POV prose — distinct from the existing **POV justification** check (#1295, which asks whether each viewpoint *character* earns an arc). For each limited-POV scene it flags narration that enters another character's head (reports interior thoughts/feelings the POV character can't know), reports knowledge or perception the POV character couldn't have (offstage events, things behind them), or switches POV mid-scene with no break — and suggests re-anchoring to the POV character's perception or inserting a proper scene break. It reads your reverse-outline scene segmentation as context (each scene's anchored POV character + the other characters on-stage, the candidate heads a hop slips into) and **degrades gracefully** to a whole-issue manuscript scan when no outline exists yet. It **no-ops when the series style guide sets third-person omniscient** — there the roaming viewpoint is intentional — and surfaces the configured POV person (first / third-limited / second) to the model so it judges against the discipline actually in force. Each finding anchors a verbatim quote + issue number and names whose head was entered. Ships a new stage prompt (`pipeline-editorial-head-hopping`) that migrates for existing installs (112). (`server/lib/editorial/checkRegistry.js`, `scripts/migrations/112-editorial-head-hopping-stage.js`, #1311)
- **[issue-1306] Line-edit / copy-edit pass — eight prose-tic editorial checks.** A bundle of deterministic copy-edit checks (Create → Editorial Checks) that catch the most common reader pet peeves and editorial red ink, each independently toggleable + configurable: **Filter words** (distancing verbs — saw/felt/noticed/began-to), **Crutch / filler words** (just/really/very/suddenly/"in order to"; bare "that" behind a toggle so grammatical "that" doesn't swamp the count), **Adverb overuse** (`-ly` adverbs, with adverb-laden dialogue tags — "said angrily" — flagged at higher severity), **Passive voice** (be-verb + past-participle heuristic, advisory), **Repeated gestures / body-part autonomy** (a gesture tally across the manuscript — nodded/smiled/shrugged — plus detached body parts that act on their own, "her eyes followed him across the room"), **Word repetition / echoes** (a distinctive word repeated within a window, plus repeated sentence openers — "He… He… He…"), and **Sentence rhythm & variety** (monotonous, uniform-length sentences). All are density-scaled — one "just" is fine, forty is a tic — with house-style allow/extra word lists and per-check thresholds, and ship sensible defaults so they don't drown the author. A ninth, LLM-judged sibling — **Telling-not-showing emotion** ("she was sad" → dramatize) — handles the false-positive-prone case a keyword scan can't, via a new stage prompt (`pipeline-editorial-telling-emotion`) that migrates for existing installs (110). The pure scanners live in `server/lib/editorial/proseTics.js` + `repetition.js` (no new deps). Reading-grade level is already covered by the existing `style.reading-level` check. (`server/lib/editorial/{proseTics,repetition,checkRegistry}.js`, `scripts/migrations/110-editorial-telling-emotion-stage.js`, #1306)
diff --cc server/lib/editorial/README.md
index 641d8317cc,f5774473a9..0089148f02
--- a/server/lib/editorial/README.md
+++ b/server/lib/editorial/README.md
@@@ -58,7 -58,7 +58,7 @@@ Declare every input the check's `run(ct
non-empty subset of `EDITORIAL_SOURCES`: `manuscript`, `canon`,
`series.styleGuide`, `series.arc.tickingClock`, `series.arc.readerMap`,
`reverseOutline`, `reverseOutline.plotlines`, `editorialArcs`,
- `series.characterArcs`, `storyboard.shots`). The staleness
-`series.characterArcs`, `comicScript`). The staleness
++`series.characterArcs`, `storyboard.shots`, `comicScript`). The staleness
runner fingerprints exactly those sources, so a finding goes stale only when
content the check actually analyzed drifts — declare too few and a finding stays
falsely fresh; a `manuscript` source must pair with `needsManuscript: true`, and
@@@ -76,11 -76,13 +76,17 @@@ because not-yet-analyzed" under a parti
(#1293) reads the AUTHORED per-character arcs off the already-loaded series
record (`series.characterArcs[]` — want/need, start → end state, transition
beats), which the `arc.transitions` check reconciles detected change moments
-against. `comicScript` (#1313) fingerprints every issue's AUTHORITATIVE comic content,
+against. `storyboard.shots` (#1315) is built off the already-loaded issues (no
+extra I/O) and injects `ctx.storyboardScenes` (a flat `{ issueNumber, scene }`
+list for every issue with storyboard scenes), which the deterministic
+`visual.shot-continuity` check reads for 180°-rule axis reversals + shot-type
- monotony. When a new check reads a
++monotony. `comicScript` (#1313) fingerprints every issue's AUTHORITATIVE comic content,
+ keyed by issue number — the edited comic-pages split (`stages.comicPages.pages[]`)
+ when present, else the generated `stages.comicScript.output` (derived from the
+ already-loaded `ctx.issues`, no extra fetch). The `comic.lettering-density` check
+ reads the same content (via the shared `comicLetteringIssues`) to count
+ balloon/panel/page word load, so a finding stales exactly when the comic text the
+ check read changes — not when an unrelated image renders. When a new check reads a
`ctx.series` field (or another artifact) that isn't yet a token, add the token to
`EDITORIAL_SOURCES` and a matching resolver in the runner's `SOURCE_RESOLVERS`.
@@@ -107,6 -109,6 +113,7 @@@ runner-injected `ctx.callInlineLLM` (a
| `italicThoughts.js` | Pure, dependency-free italic-thought primitive for `prose.italic-thoughts` (#1300): `findItalicThoughts` (multi-word markdown `*…*` / `_…_` italic runs, dedup + word-count threshold so single-word emphasis, bold, and `snake_case` are skipped). The LLM siblings (`opening.wrong-start`, `prose.mirror-description`, `dialogue.pleasantries`, `prose.kill-your-darlings`) handle the judgment cases in the #1300 anti-pattern bundle. |
| `proseTics.js` | Pure, dependency-free copy-edit prose-tic primitives for the #1306 line-edit group: `tokenizeWords` / `splitSentences` (shared tokenization), `findFilterWords` (`prose.filter-words`), `findCrutchWords` (`prose.crutch-words`), `findAdverbs` (`prose.adverbs` — `-ly` adverbs + dialogue-tag adverbs), `findPassiveVoice` (`prose.passive-voice` — be-verb + past-participle heuristic), `findGestures` (`prose.repeated-gestures` — gesture tally + body-part autonomy), plus the seed `FILTER_WORDS` / `CRUTCH_WORDS` / `GESTURE_WORDS` lists. The LLM sibling `prose.telling-emotion` handles the named-emotion judgment case. |
| `repetition.js` | Pure, dependency-free word-echo & rhythm primitives for #1306: `findWordEchoes` (`prose.word-echoes` — distinctive word repeated within a window), `findRepeatedOpeners` (runs of sentences sharing an opener, "He… He… He…"), and `measureSentenceRhythm` (`prose.sentence-rhythm` — sentence-length variation). Reuses `tokenizeWords` / `splitSentences` from `proseTics.js`. |
+| `shotContinuity.js` | Pure, dependency-free storyboard shot-continuity primitives for the deterministic `visual.shot-continuity` check (#1315): `findAxisReversals` (180°-rule axis flips across a continuity-linked shot pair using `screenDirection`) and `findShotTypeMonotony` (a scene whose classified shots all share one `shotType`). Reads the shot-grammar fields from `server/lib/shotGrammar.js`. The judgment cases (eyeline match, appearance/prop continuity) are LLM-sibling follow-ups. |
| `dialogue.js` | Pure, dependency-free dialogue-tag primitives for the #1307 dialogue-craft group: `findSaidBookisms` (`dialogue.said-bookisms` — ornate speech tags like *expostulated*/*opined* and non-speech tags like "she smiled", matched only when adjacent to a double-quote span) and `findUnattributedDialogueRuns` (`dialogue.attribution-clarity` — runs of consecutive untagged/unbeated dialogue lines where the speaker can't be tracked), plus the seed `SAID_BOOKISMS` / `NON_SPEECH_TAGS` lists. The LLM siblings `dialogue.on-the-nose` (subtext-free / "as you know, Bob" dialogue) and `dialogue.voice-distinctiveness` (per-character voice against canon `speechPattern`/`speechAccent`) handle the judgment cases. |
+ | `letteringDensity.js` | Pure, dependency-free comic lettering-density primitives for `comic.lettering-density` (#1313): `countWords`, `panelLetteringMetrics` (per-panel balloon/caption/SFX word + balloon tally over the `comicScriptParser` output), `analyzeComicLettering` (flags balloons/panels/pages over the configurable thresholds in `DEFAULT_LETTERING_THRESHOLDS`), `overflowSeverity` (severity scaled by how far over the limit), and `sanitizeLetteringThresholds`. Mirrored to `client/src/lib/letteringDensity.js` for the comic-script stage's inline warnings — keep the two in sync. |
| `index.js` | Barrel re-export of the above. |
diff --cc server/lib/editorial/checkRegistry.js
index 551a6bf094,0bf4e12183..be851a37b5
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@@ -87,15 -91,14 +92,23 @@@ const SEVERITIES = CHECK_SEVERITIES
// want, need, startState, endState, transitions[] }`). The
// arc.transitions check reconciles detected change moments
// against these authored transitions + flat-arc warnings.
+// - 'storyboard.shots' — the per-issue storyboard shot lists
+// (`stages.storyboards.scenes[].shots[]`) the
+// visual-continuity check (#1315) reasons over:
+// each shot carries `shotType` / `screenDirection`
+// / `continuityFromShotId` (server/lib/shotGrammar.js).
+// Served off the already-loaded `ctx.issues` (no
+// extra I/O); the runner injects `ctx.storyboardScenes`
+// (a flat list of `{ issueNumber, scene }` for every
+// issue that has storyboard scenes).
+ // - 'comicScript' — every issue's AUTHORITATIVE comic content, keyed by
+ // issue number: the edited comic-pages split
+ // (`stages.comicPages.pages[]`) when present, else the
+ // generated `stages.comicScript.output`. The
+ // lettering-density check (#1313) counts per-panel/per-page
+ // word + balloon load over it. The runner fingerprints the
+ // lettering-relevant fields so a finding goes stale when the
+ // comic text (not the prose manuscript) is edited.
export const EDITORIAL_SOURCES = Object.freeze([
'manuscript',
'canon',
@@@ -106,7 -109,7 +119,8 @@@
'reverseOutline.plotlines',
'editorialArcs',
'series.characterArcs',
+ 'storyboard.shots',
+ 'comicScript',
]);
// Default per-run finding cap for user-defined checks (#1346) — mirrors the
diff --cc server/services/pipeline/editorial/checkRunner.js
index e6a1967cc0,5635176a9b..696f55dc80
--- a/server/services/pipeline/editorial/checkRunner.js
+++ b/server/services/pipeline/editorial/checkRunner.js
@@@ -81,30 -81,38 +81,60 @@@ const SOURCE_RESOLVERS =
// against (#1293). Lives on the already-loaded series record, so no extra I/O
// — fingerprint the whole array so any arc/transition edit stales the findings.
'series.characterArcs': ({ series }) => canonicalStringify(series?.characterArcs ?? null),
+ // The per-issue storyboard shot lists the visual.shot-continuity check reads
+ // (#1315). Built off the already-loaded issues (no extra I/O); fingerprint the
+ // flattened `{ issueNumber, scene }` list so any shot edit (framing, direction,
+ // continuity link) stales the finding. Over-eager-but-safe, like reverseOutline.
+ 'storyboard.shots': ({ storyboardScenes }) => canonicalStringify(storyboardScenes ?? null),
+ // Every issue's AUTHORITATIVE comic lettering content, keyed by issue number
+ // (#1313). The lettering-density check reads the edited comic-pages split (or the
+ // generated script when unsplit) — NOT the prose manuscript — so it gets its own
+ // source token: editing a comic script/page stales lettering findings without
+ // staling prose findings, and vice-versa. `projectComicLetteringContent` builds
+ // the stable [{ number, panels: [{ caption, dialogue, sfx }] }] off the SAME
+ // `comicLetteringIssues` the check analyzes, so a finding stales exactly when the
+ // text it read changes (and an unrelated image render — `panel.imageJobId` — does
+ // NOT stale it, since only the lettering fields are projected).
+ comicScript: ({ comicScripts }) => canonicalStringify(comicScripts ?? null),
};
+// Flatten the storyboard scenes across every issue into the `{ issueNumber, scene }`
+// list the visual.shot-continuity check reads (#1315). Built off the already-loaded
+// issues — no extra I/O. Only issues that actually have storyboard scenes contribute,
+// so a series with no visual stage yields an empty list (the check's gate then skips).
+function collectStoryboardScenes(issues) {
+ const out = [];
+ for (const issue of (Array.isArray(issues) ? issues : [])) {
+ const scenes = issue?.stages?.storyboards?.scenes;
+ if (!Array.isArray(scenes) || !scenes.length) continue;
+ const issueNumber = Number.isInteger(issue.number) ? issue.number : null;
+ for (const scene of scenes) {
+ if (scene && typeof scene === 'object') out.push({ issueNumber, scene });
+ }
+ }
+ return out;
+}
+
+ // Project the loaded issues down to the lettering-relevant comic content the check
+ // analyzes, via the registry's shared `comicLetteringIssues` (so the fingerprint
+ // can't drift from what `run` reads). Keeps ONLY caption/dialogue/SFX — the fields
+ // `panelLetteringMetrics` consumes — so the hash is stable across image renders and
+ // description edits that don't change lettering. PAGE GROUPING is preserved (not
+ // flattened): the check reports per-page totals and page/panel locations, so moving
+ // panels between pages must change the hash even when the lettering text is identical.
+ function projectComicLetteringContent(issues) {
+ return comicLetteringIssues(issues).map(({ number, pages }) => ({
+ number,
+ pages: pages.map((p) => ({
+ panels: (Array.isArray(p?.panels) ? p.panels : []).map((panel) => ({
+ caption: typeof panel?.caption === 'string' ? panel.caption : '',
+ dialogue: Array.isArray(panel?.dialogue) ? panel.dialogue : [],
+ sfx: typeof panel?.sfx === 'string' ? panel.sfx : '',
+ })),
+ })),
+ }));
+ }
+
// Stable projection of the series editorial aggregate down to the arc fields a
// POV/arc check reads — drops the volatile `generatedAt` (and the rest) so the
// staleness fingerprint only moves when a character's detected arc actually does.
@@@ -247,7 -256,7 +281,7 @@@ export async function runEditorialCheck
// Resolve every source token once — each finding's fingerprint reads from this
// so the editor flags it `stale` when the content that check actually read (its
// declared `sources`) drifts (#1345, #1387).
- const resolvedSources = resolveSources({ manuscript, canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes });
- const resolvedSources = resolveSources({ manuscript, canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, comicScripts });
++ const resolvedSources = resolveSources({ manuscript, canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts });
const baseCtx = {
seriesId,
series,
@@@ -406,23 -414,24 +440,28 @@@ export async function getReviewWithStal
return sources.includes('reverseOutline') || sources.includes('reverseOutline.plotlines');
});
const needsEditorialArcs = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('editorialArcs'));
- // Storyboard shots staleness (#1315) — fetch issues only when an evaluable check
- // declares the source, mirroring the other gated fetches.
- // Issues are only fetched here when a comic-script-sourced finding (#1313) needs
- // re-fingerprinting — mirrors the other per-source I/O gates.
++ // Issues are fetched here only when a storyboard-shots (#1315) OR comic-script
++ // (#1313) finding needs re-fingerprinting — both derive from the issue records,
++ // so a single gated fetch serves both. Mirrors the other per-source I/O gates.
+ const needsStoryboards = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('storyboard.shots'));
+ const needsComicScript = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('comicScript'));
++ const needsIssues = needsStoryboards || needsComicScript;
const series = await getSeries(seriesId);
const [sections, canon, outline, editorial, issues] = await Promise.all([
needsManuscript ? collectManuscriptSections(seriesId) : Promise.resolve([]),
getSeriesCanon(series),
needsReverseOutline ? getReverseOutline(seriesId).catch(() => null) : Promise.resolve(null),
+ // Reuse the already-loaded series.
needsEditorialArcs ? getSeriesEditorial(seriesId, { series }).catch(() => null) : Promise.resolve(null),
- needsStoryboards ? listIssues({ seriesId }).catch(() => []) : Promise.resolve([]),
- needsComicScript ? listIssues({ seriesId }).catch(() => []) : Promise.resolve([]),
++ needsIssues ? listIssues({ seriesId }).catch(() => []) : Promise.resolve([]),
]);
const reverseOutline = Array.isArray(outline?.scenes) ? outline.scenes : [];
const reverseOutlinePlotlines = Array.isArray(outline?.plotlines) ? outline.plotlines : [];
const editorialArcs = projectEditorialArcs(editorial);
const editorialArcsComplete = editorialCoverageComplete(editorial);
+ const storyboardScenes = collectStoryboardScenes(issues);
- const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes });
+ const comicScripts = projectComicLetteringContent(issues);
- const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, comicScripts });
++ const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts });
return {
...review,
comments: review.comments.map((c) => {