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([issue-1356]): feed the series ticking clock into the idea beat-sheet prompt

[._.]/ Adam Eivy31fd86a87489
diff --git a/data.reference/prompts/stages/pipeline-idea-expansion.md b/data.reference/prompts/stages/pipeline-idea-expansion.md
index 9cfb76fb3c..914ee2eb46 100644
--- a/data.reference/prompts/stages/pipeline-idea-expansion.md
+++ b/data.reference/prompts/stages/pipeline-idea-expansion.md
@@ -32,6 +32,14 @@ You are a story consultant who turns a rough seed idea into a tight beat sheet f
The beat sheet you write must move the protagonist arc forward and stay within the named themes — do NOT introduce a major new theme the arc never references.
{{/arc}}
+{{#tickingClock}}
+## Ticking clock the reader is anticipating
+
+{{tickingClock}}
+
+Let this countdown shape the issue's pacing: keep it present in the reader's mind, escalate the pressure toward the due position, and don't resolve it early or forget it.
+{{/tickingClock}}
+
{{#volume}}
## This volume / season
@@ -47,7 +55,7 @@ The beat sheet you write must move the protagonist arc forward and stay within t
- **Number:** {{issue.number}}
- **Working title:** {{issue.title}}
-{{#arcRole}}- **Arc role within the volume:** **{{.}}**
+{{#arcRole}}- **Arc role within the volume:** **{{arcRole}}**
{{/arcRole}}{{#positionInVolume}}- **Position in volume:** issue {{ordinal}} of {{total}}.
{{/positionInVolume}}- **Length profile:** {{lengthTargets.profile}} — target {{lengthTargets.pageTarget}}-page comic / {{lengthTargets.minutesTarget}}-minute episode
@@ -73,20 +81,20 @@ This is the *opening* issue of the next volume. Your first beat should pick up d
{{#priorIssue}}
## Prior issue in this volume (immediate predecessor)
-Issue #{{number}} — "{{title}}"{{#arcRole}} (arc role: **{{.}}**){{/arcRole}}
+Issue #{{number}} — "{{title}}"{{#arcRole}} (arc role: **{{arcRole}}**){{/arcRole}}
{{#beats}}
Beat sheet:
```
-{{.}}
+{{beats}}
```
{{/beats}}{{#synopsis}}
Synopsis (no beats yet):
```
-{{.}}
+{{synopsis}}
```
{{/synopsis}}
@@ -96,20 +104,20 @@ Your opening beat must follow naturally from how this issue closed. Don't repeat
{{#nextIssue}}
## Next issue in this volume (immediate successor)
-Issue #{{number}} — "{{title}}"{{#arcRole}} (arc role: **{{.}}**){{/arcRole}}
+Issue #{{number}} — "{{title}}"{{#arcRole}} (arc role: **{{arcRole}}**){{/arcRole}}
{{#beats}}
Beat sheet:
```
-{{.}}
+{{beats}}
```
{{/beats}}{{#synopsis}}
Synopsis (no beats yet):
```
-{{.}}
+{{synopsis}}
```
{{/synopsis}}
diff --git a/scripts/migrations/003-update-pipeline-stage-prompts.js b/scripts/migrations/003-update-pipeline-stage-prompts.js
index ec05712117..746a7a593e 100644
--- a/scripts/migrations/003-update-pipeline-stage-prompts.js
+++ b/scripts/migrations/003-update-pipeline-stage-prompts.js
@@ -25,6 +25,7 @@ export const ACCEPTED_OLD_MD5 = {
'1ee44cf95851ff8debf18729ebcd40b4', // post-004 / pre-025
'1f3c5d077a5ef9a4b610335d5e3edd9c', // post-025 / pre-054
'b5c47c94ffc74637983c95761ab0c66c', // post-054 / pre-054-fence
+ '49a208628290543ba2607a5ed48fdc8c', // post-054-fence / pre-098
],
'pipeline-prose.md': [
'bfea5aeeb471aae9749baee765b473a7', // pre-003 (original)
@@ -48,7 +49,7 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': '49a208628290543ba2607a5ed48fdc8c', // post-054-fence
+ 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
'pipeline-prose.md': '84523d531eeafa60959c65c553b2563f', // post-054-fence
'pipeline-comic-script.md': 'e9ee70bf18888492edada6633cd9928a', // post-063
'pipeline-tv-script.md': '376f779f4687b598f1c92ca4e770fd5a', // retired upstream (no data.reference)
diff --git a/scripts/migrations/004-augment-idea-expansion-context.js b/scripts/migrations/004-augment-idea-expansion-context.js
index 257c70e11a..0d93fc387d 100644
--- a/scripts/migrations/004-augment-idea-expansion-context.js
+++ b/scripts/migrations/004-augment-idea-expansion-context.js
@@ -17,11 +17,12 @@ export const ACCEPTED_OLD_MD5 = {
'41facefbc0c0549d456bef9111f95ab9', // post-003 / pre-004
'1f3c5d077a5ef9a4b610335d5e3edd9c', // post-025 / pre-054
'b5c47c94ffc74637983c95761ab0c66c', // post-054 / pre-054-fence
+ '49a208628290543ba2607a5ed48fdc8c', // post-054-fence / pre-098
],
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': '49a208628290543ba2607a5ed48fdc8c', // post-054-fence
+ 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/025-idea-stage-character-detail.js b/scripts/migrations/025-idea-stage-character-detail.js
index 6fda369c29..cb8d725ae0 100644
--- a/scripts/migrations/025-idea-stage-character-detail.js
+++ b/scripts/migrations/025-idea-stage-character-detail.js
@@ -31,12 +31,13 @@ export const ACCEPTED_OLD_MD5 = {
'aee25112b2c596f643b17c559b772c22', // pre-003, still in setup-data.js OLD list
'1f3c5d077a5ef9a4b610335d5e3edd9c', // post-025 / pre-054
'b5c47c94ffc74637983c95761ab0c66c', // post-054 / pre-054-fence
+ '49a208628290543ba2607a5ed48fdc8c', // post-054-fence / pre-098
],
};
// New shipped hash — what data.reference carries post-migration.
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': '49a208628290543ba2607a5ed48fdc8c', // post-054-fence
+ 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/054-source-agnostic-stage-prompts.js b/scripts/migrations/054-source-agnostic-stage-prompts.js
index 18298d9528..89175b03c2 100644
--- a/scripts/migrations/054-source-agnostic-stage-prompts.js
+++ b/scripts/migrations/054-source-agnostic-stage-prompts.js
@@ -24,7 +24,7 @@ import { makePromptReplaceMigration } from './_lib.js';
// Pre-change shipped hashes (the source-slot templates before this change).
export const ACCEPTED_OLD_MD5 = {
- 'pipeline-idea-expansion.md': ['1f3c5d077a5ef9a4b610335d5e3edd9c', 'b5c47c94ffc74637983c95761ab0c66c'],
+ 'pipeline-idea-expansion.md': ['1f3c5d077a5ef9a4b610335d5e3edd9c', 'b5c47c94ffc74637983c95761ab0c66c', '49a208628290543ba2607a5ed48fdc8c'],
'pipeline-prose.md': ['d1f8e3f1d214725b5aa67f309a81cd7d', 'bef1bc2767b78f585f2bd89f3d615130'],
'pipeline-comic-script.md': ['133d200d069c2e8173b7c129eea58f53', 'e530fc76b89cedaef848ad7ec99c934c', 'dea7d497d1cb38e7574f236f4ff8e644'],
'pipeline-teleplay.md': ['1280ef6b1ad68fa44070ca7478ec2a5f', '2568e14beaa574d43f8018a5def51d04'],
@@ -33,7 +33,7 @@ export const ACCEPTED_OLD_MD5 = {
// Post-change shipped hashes (the source-agnostic + tilde-fence templates this
// migration installs). Mirror these into setup-data.js's drift table.
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': '49a208628290543ba2607a5ed48fdc8c',
+ 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
'pipeline-prose.md': '84523d531eeafa60959c65c553b2563f',
'pipeline-comic-script.md': 'e9ee70bf18888492edada6633cd9928a',
'pipeline-teleplay.md': 'afa4215330bf856429d70d7e2f856605',
diff --git a/scripts/migrations/098-idea-stage-ticking-clock.js b/scripts/migrations/098-idea-stage-ticking-clock.js
new file mode 100644
index 0000000000..e24d0f830c
--- /dev/null
+++ b/scripts/migrations/098-idea-stage-ticking-clock.js
@@ -0,0 +1,67 @@
+/**
+ * Surface the series' ticking clock (countdown the reader anticipates) in the
+ * idea / beat-sheet stage prompt, and fix the idea template's broken `{{.}}`
+ * dot-references inside string-valued Mustache sections.
+ *
+ * Two changes ship in `pipeline-idea-expansion.md`:
+ *
+ * 1. A new `{{#tickingClock}}` section renders the pre-built ticking-clock
+ * guidance (from `renderTickingClock(series.arc.tickingClock)`) so the beat
+ * sheet plants, sustains, and pays off the countdown. The arc-level prompts
+ * already fold the clock into their `{{{shapeGuidance}}}` block (#1289);
+ * the per-issue idea stage needed a NEW template variable, which per
+ * CLAUDE.md requires this migration. Follow-up of #1289 (issue #1356).
+ *
+ * 2. The idea template referenced section values with `{{.}}` inside
+ * string-valued sections (`{{#arcRole}}…{{.}}`, `{{#beats}}…{{.}}`,
+ * `{{#synopsis}}…{{.}}`). PortOS's template engine only binds `{{.}}` to the
+ * current item during *array* iteration — a truthy *string* section renders
+ * its body against the parent context, so `{{.}}` resolved to the whole
+ * context object and emitted the literal `[object Object]`. The neighbor
+ * beat sheets / synopses and the arc-role label were silently corrupted in
+ * every idea prompt. Switched to named references (`{{arcRole}}`,
+ * `{{beats}}`, `{{synopsis}}`), which resolve correctly.
+ *
+ * `scripts/setup-data.js` only copies *missing* prompts, so existing installs
+ * keep their old template until this migration rewrites it. Customization-safe:
+ * only installs whose copy still hashes to the known pre-change shipped version
+ * are auto-updated; customized prompts are left intact and warned about.
+ *
+ * Strategy: hash-driven prompt-replace via `./_lib.js`. Idempotent.
+ */
+
+import { makePromptReplaceMigration } from './_lib.js';
+
+// Pre-change shipped hash: the post-054 (source-agnostic) idea-expansion body.
+export const ACCEPTED_OLD_MD5 = {
+ 'pipeline-idea-expansion.md': ['49a208628290543ba2607a5ed48fdc8c'],
+};
+
+// Post-change shipped hash (ticking-clock section + `{{.}}` → named-ref fixes).
+// Mirror this into every earlier migration that tracks the same file
+// (003/004/025/054) so their drift-catch tests stay green.
+export const NEW_SHIPPED_MD5 = {
+ 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997',
+};
+
+const { applyMigration, up } = makePromptReplaceMigration({
+ accepted: ACCEPTED_OLD_MD5,
+ current: NEW_SHIPPED_MD5,
+ label: 'idea-stage ticking-clock prompt',
+ customizedHint: (filename) =>
+ ` To surface the ticking clock manually, diff:\n` +
+ ` data.reference/prompts/stages/${filename}\n` +
+ ` against your current:\n` +
+ ` data/prompts/stages/${filename}\n` +
+ ` and add the {{#tickingClock}} section (and replace any {{.}} inside\n` +
+ ` {{#arcRole}}/{{#beats}}/{{#synopsis}} with the named reference).`,
+ skipFooter: (count) =>
+ `⚠️ ${count} prompt(s) could not be auto-updated because they were\n` +
+ ` customized. The idea stage still works, but it won't surface the\n` +
+ ` ticking clock (and any {{.}} dot-refs will keep rendering\n` +
+ ` "[object Object]") until you merge the change. See\n` +
+ ` data.reference/prompts/stages/pipeline-idea-expansion.md.`,
+});
+
+export { applyMigration };
+export default { up };
diff --git a/scripts/migrations/098-idea-stage-ticking-clock.test.js b/scripts/migrations/098-idea-stage-ticking-clock.test.js
new file mode 100644
index 0000000000..a3a426eaeb
--- /dev/null
+++ b/scripts/migrations/098-idea-stage-ticking-clock.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 './098-idea-stage-ticking-clock.js';
+
+describe('migration 098 — idea-stage ticking-clock prompt', () => {
+ runPromptMigrationTests({
+ migration,
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ prefix: 'migration-098-',
+ });
+});
diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.js
index 982102b2a0..78d402222b 100644
--- a/scripts/setup-data-drift.test.js
+++ b/scripts/setup-data-drift.test.js
@@ -24,7 +24,7 @@ const migrationsDir = join(dirname(fileURLToPath(import.meta.url)), 'migrations'
// sample-existence filter drops downstream — so its presence here documents
// that the sweep itself is expected to carry it.
const EXPECTED_STAGE_OLD = {
- 'pipeline-idea-expansion.md': ['1ee44cf95851ff8debf18729ebcd40b4', '1f3c5d077a5ef9a4b610335d5e3edd9c', '41facefbc0c0549d456bef9111f95ab9', 'aee25112b2c596f643b17c559b772c22', 'b5c47c94ffc74637983c95761ab0c66c'],
+ 'pipeline-idea-expansion.md': ['1ee44cf95851ff8debf18729ebcd40b4', '1f3c5d077a5ef9a4b610335d5e3edd9c', '41facefbc0c0549d456bef9111f95ab9', '49a208628290543ba2607a5ed48fdc8c', 'aee25112b2c596f643b17c559b772c22', 'b5c47c94ffc74637983c95761ab0c66c'],
'pipeline-prose.md': ['30ac30ec2b9d3e2a9eb869c181732cc6', 'bef1bc2767b78f585f2bd89f3d615130', 'bfea5aeeb471aae9749baee765b473a7', 'd1f8e3f1d214725b5aa67f309a81cd7d'],
'pipeline-comic-script.md': ['133d200d069c2e8173b7c129eea58f53', '1e0af305c27d0c80c4b482d2ebcb4a0d', '40e5fdc1a1e68a7419b7dad936366c1a', 'beab031951859ca13579cdb9c4dbe769', 'dea7d497d1cb38e7574f236f4ff8e644', 'e530fc76b89cedaef848ad7ec99c934c'],
'pipeline-teleplay.md': ['1280ef6b1ad68fa44070ca7478ec2a5f', '2568e14beaa574d43f8018a5def51d04', '376f779f4687b598f1c92ca4e770fd5a', '3f6fecc25573ed054b47db392250034a'],
@@ -44,7 +44,7 @@ const EXPECTED_STAGE_OLD = {
'pipeline-tv-script.md': ['3f6fecc25573ed054b47db392250034a'],
};
const EXPECTED_STAGE_NEW = {
- 'pipeline-idea-expansion.md': '49a208628290543ba2607a5ed48fdc8c',
+ 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997',
'pipeline-prose.md': '84523d531eeafa60959c65c553b2563f',
'pipeline-comic-script.md': 'e9ee70bf18888492edada6633cd9928a',
'pipeline-teleplay.md': 'afa4215330bf856429d70d7e2f856605',
diff --git a/server/services/pipeline/textStages.js b/server/services/pipeline/textStages.js
index f3676b5c9b..ec95bedee1 100644
--- a/server/services/pipeline/textStages.js
+++ b/server/services/pipeline/textStages.js
@@ -24,6 +24,7 @@ import { compareIssuesByPosition, NO_LINKED_UNIVERSE_PLACEHOLDER } from './arcPl
import { computeIssueTargets } from '../../lib/issueLength.js';
import { renderEntitiesSummary } from '../../lib/universePromptRenderers.js';
import { composeStyleNotes } from '../../lib/styleGuide.js';
+import { renderTickingClock } from '../../lib/storyArc.js';
const STAGE_TO_TEMPLATE = Object.freeze({
idea: 'pipeline-idea-expansion',
@@ -93,9 +94,18 @@ async function buildIdeaContextAugment(series, issue) {
}
: null;
+ // Ticking clock — a pre-rendered guidance string (or null when the clock is
+ // absent or toggled off). Surfaced as its own template section, independent
+ // of `arcBlock`: a clock is the author's explicit decision that the story
+ // *has* a countdown, so it must steer the beats even on a clock-only arc with
+ // no logline/summary/themes. `renderTickingClock` already gates on
+ // `tickingClock.enabled === true`.
+ const tickingClock = renderTickingClock(arc?.tickingClock);
+
if (!season) {
return {
arc: arcBlock,
+ tickingClock,
volume: null,
arcRole: issue.arcRole || null,
positionInVolume: null,
@@ -139,6 +149,7 @@ async function buildIdeaContextAugment(series, issue) {
return {
arc: arcBlock,
+ tickingClock,
volume: {
number: season.number,
title: season.title || '',
diff --git a/server/services/pipeline/textStages.test.js b/server/services/pipeline/textStages.test.js
index d871d7b967..6f8ef9d64a 100644
--- a/server/services/pipeline/textStages.test.js
+++ b/server/services/pipeline/textStages.test.js
@@ -249,6 +249,39 @@ describe('pipeline text stage generator', () => {
});
});
+ it('idea context: surfaces the ticking clock as a rendered string when enabled', async () => {
+ const { series, issue } = await seed();
+ await seriesSvc.updateSeries(series.id, {
+ arc: {
+ tickingClock: {
+ enabled: true,
+ label: 'The tide returns',
+ kind: 'deadline',
+ stakes: 'the foundry floods',
+ dueAtArcPosition: 0.9,
+ },
+ },
+ });
+ await textStages.generateStage(issue.id, 'idea');
+ const ctx = ctxFromCall(llmCalls[0]);
+ expect(typeof ctx.tickingClock).toBe('string');
+ expect(ctx.tickingClock).toContain('The tide returns');
+ expect(ctx.tickingClock).toContain('the foundry floods');
+ // A clock-only arc carries no logline/themes — the clock must still surface
+ // even though the arc text block is omitted.
+ expect(ctx.arc).toBe(null);
+ });
+
+ it('idea context: omits the ticking clock when it is toggled off', async () => {
+ const { series, issue } = await seed();
+ await seriesSvc.updateSeries(series.id, {
+ arc: { logline: 'L', tickingClock: { enabled: false, label: 'draft clock' } },
+ });
+ await textStages.generateStage(issue.id, 'idea');
+ const ctx = ctxFromCall(llmCalls[0]);
+ expect(ctx.tickingClock).toBe(null);
+ });
+
it('idea context: volume + position-in-volume + arcRole when issue is grouped', async () => {
const { series } = await seed();
await seriesSvc.updateSeries(series.id, { arc: { logline: 'L' } });