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
feat: add a "Zoom into the moment" construction section to the craft-anti-patterns partial (#3594)
[._.]/ Adam Eivyd19064011182
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 4846dc47ab..3e4ed5eacf 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -198,3 +198,4 @@- **[issue-3586] The Writers Room synced review now shows which card you actually clicked.** All three panes drew their cards through a helper that had four states — selected, linked, dimmed, plain — but every caller passed "not selected" as a constant, so the strongest of the four was unreachable code. Because the mapping deliberately includes the selected item in its own pane's highlight set, the card you clicked came out styled exactly like the cards it links to: with a prose segment selected, the segment itself and the scene it maps to were the same faint accent border, and nothing on screen said which end of the cross-link you were standing on. The real selection is now threaded into each pane, so the anchor card takes the full accent ring and its linked counterparts keep the lighter treatment, in the prose, script and media panes alike.- **[issue-3569] The Writers Room library's header buttons are now big enough to hit on a phone.** "New folder", "New work" and "Hide library" each wrapped a 14px icon in nothing but `p-1`, giving them roughly 22x22px of tappable area sitting side by side in a 260px sidebar — close enough together that a thumb aiming for "New work" landed on "New folder" instead, which is the one control the whole pane exists to reach. All three now clear the 44px floor the rest of the app uses, as do the create-folder and create-work forms they open: the name/title inputs, the kind dropdown, and the Add/Create/Cancel buttons were all ~24px tall, so getting past the header only landed you on a second row of targets just as easy to miss. Unlike the bible and snapshot rows in #3565, the header row has no padding of its own for the extra height to bleed back into, so it grows to 44px rather than clawing it back with a negative margin that would collide with the pane's top edge. "Hide library" stays desktop-only and is centred with `inline-flex` rather than `flex`, since the two are the same Tailwind layer and a bare `flex` would race the `md:` variant that hides it.- **[issue-3590] Lengthening a perpetual task's recheck cadence no longer delays a recheck that was already due.** When the recheck cadence changes, the schedule re-derives the park timestamp of every currently-parked execution record from the new cadence, so the edit takes effect on the next slot instead of waiting out the old timestamp. The guard was "does this record carry a park at all" — but an elapsed park is never cleared when it expires (the task simply reports itself as due for a recheck, and the dispatch gate clears the park when it actually runs), so a record that was ready to run right now was matched by that guard too and stamped with a fresh future timestamp. Shortening the cadence was harmless, since the new timestamp was sooner; lengthening it pushed the pending recheck back out by the new interval, and the drain the user was waiting on silently went quiet again. Only parks still in the future are re-derived now — a record whose park has already elapsed is left exactly as it is, so it rechecks on the very next tick.+- **[issue-3594] The drafting prompt now teaches how to write a scene, not just how much scene to write.** The craft doctrine injected into both drafting stages — the prose pipeline and Writers Room live continuation — was entirely negative: eleven "avoid X" rules plus the Stability Trap countermeasures. One of those rules carries a measurable target with no technique attached ("at least 70% in-scene, not summary"), and a model told to dramatize more with no construction recipe reaches for longer description, which is exactly the white-room, zero-interiority draft the editorial checks then have to catch. A new "Zoom into the moment" section — the first positive-instruction block in the partial, placed right after the rule it operationalizes — gives it the recipe in five elements: name the location with one concrete noun rather than an inventory, say what the character is doing in present-moment verbs, render thoughts raw in the character's own diction instead of essay register, show emotion on the body rather than naming the feeling, and quote dialogue that is worth quoting instead of narrating that someone spoke. Each element ships with the failure mode that makes it a rule rather than a suggestion. Because the partial is a file on disk that existing installs already have, and both `setup-data.js` and the original seed migration only ever copy it when it is *missing*, the section arrives through a hash-gated migration: an install still running the shipped version is upgraded in place, and a hand-edited partial is left exactly as it is and told what to merge.diff --git a/data.reference/prompts/_partials/craft-anti-patterns.md b/data.reference/prompts/_partials/craft-anti-patterns.mdindex 0f70a33f27..e1e9a05518 100644--- a/data.reference/prompts/_partials/craft-anti-patterns.md+++ b/data.reference/prompts/_partials/craft-anti-patterns.md@@ -10,10 +10,20 @@ These are hard-won lessons about prose that reads as machine-generated. Follow t- **Section breaks ≤ two per chapter.** Hard section breaks (blank-line / horizontal-rule scene cuts within a chapter) fragment momentum. Use at most two per chapter.- **Vary paragraph length.** Never write three or more consecutive paragraphs of similar length. Break the pattern deliberately — a one-line paragraph after two dense ones, or vice versa.- **End each chapter differently from previous chapters.** Do not fall into a repeated closing rhythm (every chapter ending on a line of dialogue, or a lone-image beat, or an em-dash). Vary how endings land across the work.-- **At least 70% in-scene, not summary.** The majority of the prose should be dramatized moment-to-moment scene, not narrated summary ("Over the next week, they…"). Summary is for compression between scenes, not the default mode.+- **At least 70% in-scene, not summary.** The majority of the prose should be dramatized moment-to-moment scene, not narrated summary ("Over the next week, they…"). Summary is for compression between scenes, not the default mode. See **Zoom into the moment** below for how to build one.- **Dialogue sounds like speech, not polished prose.** People interrupt, trail off, use contractions and fragments, dodge the question. Do not write dialogue that reads like edited essay prose.- **Include at least one genuinely surprising moment.** Every chapter should contain at least one beat the reader could not have predicted a paragraph earlier — a reveal, a reversal, an unexpected reaction. Predictable-throughout is a failure state.+## Zoom into the moment — how to build a scene++Everything above is a thing to avoid. These five are things to *do*. They are the construction recipe for the 70%-in-scene rule: when you drop into a dramatized beat, build it out of these elements. A passage missing them is the summary that rule is warning you about, and "add more description" is not the fix.++- **Location first.** Open the beat by saying where the character physically is — one concrete noun ("the conference room", "the kitchen table"), not an inventory. A named place is enough for the reader to build the room themselves; piling on furniture and floor materials buys nothing and crowds out interiority.+- **Actions, in verbs.** Say what the character is *doing* in this specific moment — walking, waiting, opening, reading. Present-moment verbs create forward momentum and signal that the story has already started; context can be back-filled later, or not at all.+- **Thoughts, raw.** Render the thought itself, in the character's own diction — fragmentary, self-interrupting, unflattering. Never write a thought in essay register ("this represents a considerable opportunity"); nobody thinks that.+- **Emotions, shown on the body.** Do not name the feeling. Give the physical tell — the lean back and the exhale, the pen tapping, the glance at the clock. A named emotion is invisible; a body is not.+- **Dialogue, quoted and specific.** When a character says something that matters, quote the actual words, and make them worth quoting — concrete and characterful, never corporate paraphrase ("I'm dissatisfied with the inadequate execution"). Narrated speech ("she told him she was leaving") is the most common place a draft leaves value on the table.+## Stability Trap countermeasuresAI-drafted stories drift toward *stability*: characters resist real change, conflicts resolve too cleanly, nothing is truly lost, everything is revealed at once, and the emotional register sits at "room temperature." Actively push against this:diff --git a/scripts/migrations/228-craft-partial-zoom-into-the-moment.js b/scripts/migrations/228-craft-partial-zoom-into-the-moment.jsnew file mode 100644index 0000000000..432eb090a1--- /dev/null+++ b/scripts/migrations/228-craft-partial-zoom-into-the-moment.js@@ -0,0 +1,66 @@+/**+ * Ship the "Zoom into the moment" construction section into the+ * `craft-anti-patterns` prompt PARTIAL (#3594).+ *+ * The partial is injected into BOTH drafting stages (`pipeline-prose.md` and+ * `writers-room-continue.md`) and until now was entirely negative — 11 "avoid X"+ * rules plus the Stability Trap countermeasures. One of those rules carries a+ * measurable target with no technique attached ("at least 70% in-scene, not+ * summary"), so a drafter told to dramatize more defaults to longer description.+ * The new section gives it the recipe: location, actions, thoughts, emotions,+ * dialogue.+ *+ * Why a migration: `scripts/setup-data.js` copies only *missing* prompt files,+ * and migration `183-seed-craft-anti-patterns-partial.js` copies the partial only+ * when absent (never clobbering a hand-edited one). So every existing install+ * already has the pre-change partial on disk and would never receive this edit.+ *+ * Customization-safe: only installs whose copy still hashes to the shipped+ * pre-change body are auto-updated; a hand-edited partial is left intact and+ * warned about (and surfaces in setup-data.js's drift warning via the+ * `ACCEPTED_OLD_MD5` / `NEW_SHIPPED_MD5` / `DRIFT_SUBDIRS` sweep). Idempotent.+ *+ * `DRIFT_SUBDIRS` is what routes this file to `prompts/_partials/` rather than+ * the default `prompts/stages/` — for the drift sweep AND for the replace pass+ * itself, which takes the same table via `subdirs`.+ */++import { makePromptReplaceMigration } from './_lib.js';++// Pre-change shipped hash (the partial as seeded by migration 183 / #2172).+export const ACCEPTED_OLD_MD5 = {+ 'craft-anti-patterns.md': ['bd0149bf1a5c721e65e053dad8e536d3'],+};++// Post-change shipped hash ("Zoom into the moment" section added).+export const NEW_SHIPPED_MD5 = {+ 'craft-anti-patterns.md': 'f34e75f19ac4e41aa0533a0abcb38a2a',+};++// This file is a prompt fragment, not a stage prompt.+export const DRIFT_SUBDIRS = {+ 'craft-anti-patterns.md': '_partials',+};++const { applyMigration, up } = makePromptReplaceMigration({+ accepted: ACCEPTED_OLD_MD5,+ current: NEW_SHIPPED_MD5,+ subdirs: DRIFT_SUBDIRS,+ label: 'craft "Zoom into the moment" section',+ customizedHint: (filename) =>+ ` To upgrade it manually, diff:\n` ++ ` data.reference/prompts/_partials/${filename}\n` ++ ` against your current:\n` ++ ` data/prompts/_partials/${filename}\n` ++ ` and add the "Zoom into the moment" section (the five construction\n` ++ ` elements: location, actions, thoughts, emotions, dialogue).`,+ skipFooter: (count) =>+ `⚠️ ${count} craft-anti-patterns partial(s) could not be auto-updated because\n` ++ ` they were customized. Drafting still works, but the prose and\n` ++ ` Writers-Room-continue stages will keep asking for 70% in-scene prose\n` ++ ` without teaching how to build a scene, until you merge the "Zoom into\n` ++ ` the moment" section from data.reference/prompts/_partials/craft-anti-patterns.md.`,+});++export { applyMigration };+export default { up };diff --git a/scripts/migrations/228-craft-partial-zoom-into-the-moment.test.js b/scripts/migrations/228-craft-partial-zoom-into-the-moment.test.jsnew file mode 100644index 0000000000..2baafcf2f1--- /dev/null+++ b/scripts/migrations/228-craft-partial-zoom-into-the-moment.test.js@@ -0,0 +1,84 @@+import { describe, it, expect } from 'vitest';+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';++import { runPromptMigrationTests, sampleBody, repoRoot, md5 } from './_testHelpers.js';+import migration, {+ applyMigration,+ ACCEPTED_OLD_MD5,+ NEW_SHIPPED_MD5,+ DRIFT_SUBDIRS,+} from './228-craft-partial-zoom-into-the-moment.js';++const FILENAME = 'craft-anti-patterns.md';++describe('migration 228 — craft "Zoom into the moment" section', () => {+ runPromptMigrationTests({+ migration,+ applyMigration,+ ACCEPTED_OLD_MD5,+ NEW_SHIPPED_MD5,+ prefix: 'migration-228-',+ subdir: '_partials',+ });++ it('routes the partial to prompts/_partials, never prompts/stages', async () => {+ // The single easiest thing to get wrong: the prompt-replace family defaults+ // to `prompts/stages/`, so a missing DRIFT_SUBDIRS entry would leave every+ // install's real partial untouched while silently "succeeding".+ expect(DRIFT_SUBDIRS[FILENAME]).toBe('_partials');++ const rootDir = mkdtempSync(join(tmpdir(), 'migration-228-routing-'));+ const partialsDir = join(rootDir, 'data', 'prompts', '_partials');+ const stagesDir = join(rootDir, 'data', 'prompts', 'stages');+ const sampleDir = join(rootDir, 'data.reference', 'prompts', '_partials');+ mkdirSync(partialsDir, { recursive: true });+ mkdirSync(stagesDir, { recursive: true });+ mkdirSync(sampleDir, { recursive: true });+ writeFileSync(join(sampleDir, FILENAME), sampleBody(FILENAME, '_partials'));++ const staleBody = '# synthetic pre-228 partial\n';+ writeFileSync(join(partialsDir, FILENAME), staleBody);+ // A stage-dir decoy with the SAME name must be left alone.+ writeFileSync(join(stagesDir, FILENAME), staleBody);++ const result = await applyMigration({+ rootDir,+ accepted: { [FILENAME]: [md5(staleBody)] },+ current: { [FILENAME]: md5(sampleBody(FILENAME, '_partials')) },+ });++ expect(result).toMatchObject({ updated: 1, skipped: 0 });+ expect(readFileSync(join(partialsDir, FILENAME), 'utf-8')).toBe(sampleBody(FILENAME, '_partials'));+ expect(readFileSync(join(stagesDir, FILENAME), 'utf-8')).toBe(staleBody);+ expect(existsSync(join(rootDir, 'data', 'prompts', 'stages', FILENAME))).toBe(true);++ rmSync(rootDir, { recursive: true, force: true });+ });++ it('ships all five construction elements, after the in-scene rule and before the Stability Trap', () => {+ const body = readFileSync(join(repoRoot, 'data.reference', 'prompts', '_partials', FILENAME), 'utf-8');++ const inScene = body.indexOf('At least 70% in-scene, not summary');+ const zoom = body.indexOf('## Zoom into the moment');+ const stability = body.indexOf('## Stability Trap countermeasures');+ expect(inScene).toBeGreaterThan(-1);+ expect(zoom).toBeGreaterThan(inScene);+ expect(stability).toBeGreaterThan(zoom);++ for (const element of [+ 'Location first',+ 'Actions, in verbs',+ 'Thoughts, raw',+ 'Emotions, shown on the body',+ 'Dialogue, quoted and specific',+ ]) {+ expect(body.slice(zoom, stability)).toContain(element);+ }+ });++ it('the pre-change shipped hash is a real ancestor, distinct from the new one', () => {+ expect(ACCEPTED_OLD_MD5[FILENAME]).not.toContain(NEW_SHIPPED_MD5[FILENAME]);+ });+});diff --git a/scripts/migrations/_lib.js b/scripts/migrations/_lib.jsindex 8523887206..97ed81473b 100644--- a/scripts/migrations/_lib.js+++ b/scripts/migrations/_lib.js@@ -323,6 +323,12 @@ export const md5 = (str) => {* flag, a missing sample raises an ENOENT at read time. Used by migration* 003 to handle the `pipeline-tv-script.md` → `pipeline-teleplay.md`* rename.+ *+ * `subdirs` mirrors a migration's `DRIFT_SUBDIRS` export: a per-filename+ * override of the `prompts/<subdir>/` directory both sides resolve under.+ * Stage prompts (the default, `'stages'`) need no entry; prompt fragments in+ * `prompts/_partials/` do. Passing the migration's own `DRIFT_SUBDIRS` object+ * keeps the replace pass and the setup-data.js drift sweep reading one table.*/export async function applyPromptReplaceMigration({rootDir,@@ -332,9 +338,11 @@ export async function applyPromptReplaceMigration({customizedHint,createIfMissing = false,retireOnSampleMissing = false,+ subdirs = {},}) {- const stagesDir = join(rootDir, 'data', 'prompts', 'stages');- const sampleDir = join(rootDir, 'data.reference', 'prompts', 'stages');+ const subdirFor = (filename) => subdirs[filename] || 'stages';+ const dataPathFor = (filename) => join(rootDir, 'data', 'prompts', subdirFor(filename), filename);+ const samplePathFor = (filename) => join(rootDir, 'data.reference', 'prompts', subdirFor(filename), filename);const filenames = Object.keys(accepted);// Two phases so parallelism never changes the migration's failure semantics:@@ -351,8 +359,8 @@ export async function applyPromptReplaceMigration({// order so log output and the on-disk result are deterministic, exactly// as the serial loop produced them.const plans = await Promise.all(filenames.map(async (filename) => {- const dataPath = join(stagesDir, filename);- const samplePath = join(sampleDir, filename);+ const dataPath = dataPathFor(filename);+ const samplePath = samplePathFor(filename);const existing = await readFile(dataPath, 'utf-8').catch((err) => {if (err.code !== 'ENOENT') throw err;@@ -391,7 +399,7 @@ export async function applyPromptReplaceMigration({return {counter: 'skipped',warn: `⚠️ ${label} ${filename} was renamed/retired upstream but your local copy has been customized.\n` +- ` Check data.reference/prompts/stages/ for the replacement file and merge any custom edits manually.`,+ ` Check data.reference/prompts/${subdirFor(filename)}/ for the replacement file and merge any custom edits manually.`,};}}@@ -439,6 +447,7 @@ export function makePromptReplaceMigration({skipFooter,createIfMissing = false,retireOnSampleMissing = false,+ subdirs = {},}) {const applyMigration = (opts = {}) =>applyPromptReplaceMigration({@@ -448,6 +457,7 @@ export function makePromptReplaceMigration({customizedHint,createIfMissing,retireOnSampleMissing,+ subdirs,...opts,});diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.jsindex b486fd5b94..d131778bbb 100644--- a/scripts/setup-data-drift.test.js+++ b/scripts/setup-data-drift.test.js@@ -81,9 +81,11 @@ const EXPECTED_STAGE_NEW = {};const EXPECTED_PARTIAL_OLD = {'bible-deference.md': ['218f0e85643609ed85a12b1ccc7b5a8d'],+ 'craft-anti-patterns.md': ['bd0149bf1a5c721e65e053dad8e536d3'],};const EXPECTED_PARTIAL_NEW = {'bible-deference.md': 'a4681348c27776e414acf6e0be566a99',+ 'craft-anti-patterns.md': 'f34e75f19ac4e41aa0533a0abcb38a2a',};// Compare a swept oldMap to a baseline with each hash list order-normalized.@@ -105,6 +107,7 @@ describe('buildPromptDriftTables', () => {expect(_partials.newMap).toEqual(EXPECTED_PARTIAL_NEW);expect(sortValues(_partials.oldMap)).toEqual(sortValues(EXPECTED_PARTIAL_OLD));expect(stages.newMap['bible-deference.md']).toBeUndefined();+ expect(stages.newMap['craft-anti-patterns.md']).toBeUndefined();});it('never lists the current hash among its own accepted-old set', async () => {diff --git a/server/lib/craftAntiPatternsPartial.test.js b/server/lib/craftAntiPatternsPartial.test.jsindex e48d7f4697..ded92ba350 100644--- a/server/lib/craftAntiPatternsPartial.test.js+++ b/server/lib/craftAntiPatternsPartial.test.js@@ -25,6 +25,7 @@ describe('craft-anti-patterns partial (#2172)', () => {// The include marker is gone and the partial body landed inline.expect(expanded).not.toContain('{{> craft-anti-patterns }}');expect(expanded).toContain('No triadic sensory lists');+ expect(expanded).toContain('Zoom into the moment');expect(expanded).toContain('Stability Trap countermeasures');expect(expanded).toContain('Characters must end TRULY different');expect(expanded).toContain('A choice with no real cost is not a real choice');@@ -37,6 +38,30 @@ describe('craft-anti-patterns partial (#2172)', () => {const rendered = applyTemplate(expanded, {});expect(rendered).not.toContain('{{>');expect(rendered).toContain('Include at least one genuinely surprising moment');+ // The construction recipe (#3594) must reach BOTH drafting stages — it is+ // the only positive-instruction block in the partial, and the thing that+ // makes the 70%-in-scene rule actionable rather than aspirational.+ expect(rendered).toContain('Zoom into the moment');+ expect(rendered).toContain('Emotions, shown on the body');+ }+ });++ it('carries the five "Zoom into the moment" construction elements (#3594)', () => {+ const body = readFileSync(join(partialsDir, 'craft-anti-patterns.md'), 'utf-8');+ const zoom = body.indexOf('## Zoom into the moment');+ const stability = body.indexOf('## Stability Trap countermeasures');+ // Positioned after the rule it operationalizes, before the Stability Trap block.+ expect(body.indexOf('At least 70% in-scene, not summary')).toBeLessThan(zoom);+ expect(zoom).toBeLessThan(stability);+ const section = body.slice(zoom, stability);+ for (const element of [+ 'Location first',+ 'Actions, in verbs',+ 'Thoughts, raw',+ 'Emotions, shown on the body',+ 'Dialogue, quoted and specific',+ ]) {+ expect(section).toContain(element);}});