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

add series voice exemplar/anti-exemplar passages injected into prose prompts

[._.]/ Adam Eivy93f647a12731
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 59bca853f0..d35a6fbe27 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -25,6 +25,7 @@
- **[issue-2168] A new "adversarial cuts" editorial check and mechanical applier tightens prose by identifying what a ruthless editor would cut.** The `prose.adversarial-cuts` check asks an LLM editor persona to cut 8–12% of the text as 10–20 passages, classifying each cut by type: FAT (purple prose), REDUNDANT (repeated information), OVER-EXPLAIN (spelling out what's clear), GENERIC (stock phrases), TELL (emotion-telling after showing), or STRUCTURAL (scenes that don't advance the story). Each cut lands as a manuscriptReview finding with the exact verbatim quote. The Manuscript Editor gains an "Apply safe cuts" action that batch-removes OVER-EXPLAIN and REDUNDANT cuts mechanically — exact string match with whitespace-normalized fallback, refusing ambiguous or too-short quotes — through the same snapshotted stage-write path fixes use (full undo via version history). The check also reports `fat_percentage`, `tightest_passage` (protected), and `loosest_passage` for a quick health read.
- **[issue-2170] A simulated four-persona reader panel now reads your whole series and shows you where the readers disagree.** Convene the panel from a new **Reader Panel** tab on the Reader Map page (deep-linkable via `?tab=panel`) and four distinct readers — The Editor (prose texture, subtext, over-explaining), The Genre Reader (pacing and page-turn pull, "gets bored by beautiful prose that doesn't GO anywhere"), The Writer (structure, beats, foreshadowing payoff, whose worst insult is "I can see the outline"), and The First Reader (pure emotional response, no craft vocabulary) — each read a condensed, content-hash-pinned arc digest of the series (per-issue summary, opening/closing excerpts, and notable dialogue) and answer the same ten qualitative questions (where momentum is lost, is the ending earned, what to cut, a missing scene, the thinnest character, best/worst scene, would-recommend, what haunts you, would-read-the-next-book), citing specific issue numbers. The editorial signal is where they *disagree*: an issue flagged by 3+ personas is routed straight into your editorial-findings triage flow as a consensus concern; softer some-flagged-some-didn't calls and "polarizing" issues (one persona's best scene is another's worst) are surfaced for your judgment. One LLM call per persona, run only from the explicit Convene button — nothing fires on its own.
- **[issue-2175] Worldbuilding craft doctrine now shapes universe generation up-front, and two new editorial checks verify it.** The universe-expansion prompt now injects Sanderson's-Laws craft doctrine before the writer model drafts — limitations over powers, costs that drive plot decisions, solutions foreshadowed before they resolve, iceberg depth, interconnected systems, 2–3 societal implications per major system, and a sensory signature per location — so autonomous and interactive runs alike start from a lived-in world instead of decorative set dressing (Series Autopilot calls the same stages, so autonomous mode is upgraded automatically). Two new series-scope editorial checks close the loop on the review side: `world.unforeshadowed-solution` (a plot problem solved by a rule/power the reader was never shown — the worldbuilding sibling of the deus ex machina) and `world.cost-free-power` (an ability used at a decisive moment with no cost or limitation on the page). Both reconcile the prose against the established world canon and the continuity-bible world-rule facts, so a rule that WAS planted earlier is not flagged. (First slice of #2175 — the character-framework and structure-rule pillars ship separately.)
+- **[issue-2179] A series style guide can now carry concrete voice exemplar and anti-exemplar passages — "the tuning fork" — that get injected into every draft and revision prompt.** Adjective lists ("witty, atmospheric") anchor prose voice far more weakly than an actual passage does, so the series style guide gains two new fields: `voiceExemplars` (1–3 short passages that nail the target voice, each with an optional one-line note on what it demonstrates) and `voiceAntiExemplars` (passages in the wrong register kept as negative examples, noted with what's wrong — "too ornate", "wrong emotional temperature"). Add and edit them inline on the series style-guide editor. On generation they render into the house-style block as a "MATCH this voice — echo their rhythm, diction, and register" block and a "NEVER drift toward this" block — conditional, so a guide with no passages injects nothing. They ride the existing `{{series.styleNotes}}` template variable (via `composeStyleNotes`), so prose drafting, revision, arc planning, and episode-seed passes all honor them with no new prompt-template variable and no migration. The sanitizer drops empty passages, trims each to ~2000 chars, and caps the list at 3 so the fixed per-call prompt overhead stays tight. (First slice of #2179 — the AI-assisted voice-discovery flow, Writers Room parity, and the voice-fingerprint baseline hook ship separately.)
## Human Activity Tracking
diff --git a/client/src/pages/PipelineSeries.jsx b/client/src/pages/PipelineSeries.jsx
index 60ce2e009e..5b7d6b9f3a 100644
--- a/client/src/pages/PipelineSeries.jsx
+++ b/client/src/pages/PipelineSeries.jsx
@@ -81,6 +81,11 @@ const STYLE_GUIDE_FIELDS = [
{ key: 'contentRating', label: 'Content rating', options: [['G', 'G'], ['PG', 'PG'], ['PG-13', 'PG-13'], ['R', 'R'], ['custom', 'Custom']] },
{ key: 'profanity', label: 'Profanity', options: [['none', 'None'], ['mild', 'Mild'], ['moderate', 'Moderate'], ['strong', 'Strong']] },
];
+// Voice exemplar caps — mirror STYLE_GUIDE_LIMITS in server/lib/styleGuide.js
+// so the editor bounds match the server sanitizer (#2179).
+const STYLE_GUIDE_EXEMPLARS_MAX = 3;
+const STYLE_GUIDE_EXEMPLAR_PASSAGE_MAX = 2000;
+const STYLE_GUIDE_EXEMPLAR_NOTE_MAX = 200;
// Tri-state boolean conventions rendered as —/Yes/No selects so "unset" stays
// distinct from "No" (matches the server's tri-state sanitizer).
const STYLE_GUIDE_TRISTATE = [
@@ -588,6 +593,84 @@ function StyleGuideSection({ series, patchSeries }) {
/>
))}
</div>
+
+ <VoiceExemplarEditor
+ idPrefix="sg-voice-exemplar"
+ title="Voice exemplars (the tuning fork)"
+ hint="1–3 short passages (~150–300 words) that nail the series' voice. Injected into every draft/revision prompt as “MATCH this voice”. A concrete anchor beats any adjective list."
+ notePlaceholder="what this demonstrates (e.g. spare, close-psychic)"
+ entries={Array.isArray(sg.voiceExemplars) ? sg.voiceExemplars : []}
+ onChange={(next) => setSG({ voiceExemplars: next.length ? next : null })}
+ />
+
+ <VoiceExemplarEditor
+ idPrefix="sg-voice-anti"
+ title="Anti-exemplars (never drift toward this)"
+ hint="Passages in the wrong register, kept as negative examples. Injected as “NEVER drift toward this”."
+ notePlaceholder="what's wrong (e.g. too ornate, wrong temperature)"
+ entries={Array.isArray(sg.voiceAntiExemplars) ? sg.voiceAntiExemplars : []}
+ onChange={(next) => setSG({ voiceAntiExemplars: next.length ? next : null })}
+ />
+ </div>
+ );
+}
+
+// Editor for the voice exemplar / anti-exemplar passage lists (#2179). Each row
+// is `{ passage, note }`; the passage textarea is required (an empty passage
+// prunes the row), the note is an optional one-liner. Capped at
+// STYLE_GUIDE_EXEMPLARS_MAX rows. All labels are htmlFor/id paired.
+function VoiceExemplarEditor({ idPrefix, title, hint, notePlaceholder, entries, onChange }) {
+ const setEntry = (i, patch) => onChange(entries.map((e, idx) => (idx === i ? { ...e, ...patch } : e)));
+ const removeEntry = (i) => onChange(entries.filter((_, idx) => idx !== i));
+ const addEntry = () => onChange([...entries, { passage: '', note: '' }]);
+
+ return (
+ <div className="mt-3">
+ <h4 className="text-[11px] uppercase tracking-wider text-gray-500 mb-1">{title}</h4>
+ <p className="text-[11px] text-gray-500 mb-2 -mt-0.5">{hint}</p>
+ <div className="space-y-2">
+ {entries.map((entry, i) => (
+ <div key={i} className="border border-port-border rounded p-2 bg-port-bg/50">
+ <label htmlFor={`${idPrefix}-passage-${i}`} className="block text-[11px] text-gray-500 mb-1">Passage {i + 1}</label>
+ <textarea
+ id={`${idPrefix}-passage-${i}`}
+ value={entry.passage || ''}
+ onChange={(e) => setEntry(i, { passage: e.target.value })}
+ rows={4}
+ maxLength={STYLE_GUIDE_EXEMPLAR_PASSAGE_MAX}
+ placeholder="Paste a short prose passage that captures the voice."
+ className="w-full px-2 py-1.5 bg-port-bg border border-port-border rounded text-white text-sm font-mono"
+ />
+ <div className="flex items-center gap-2 mt-1">
+ <label htmlFor={`${idPrefix}-note-${i}`} className="sr-only">Note for passage {i + 1}</label>
+ <input
+ id={`${idPrefix}-note-${i}`}
+ value={entry.note || ''}
+ onChange={(e) => setEntry(i, { note: e.target.value })}
+ maxLength={STYLE_GUIDE_EXEMPLAR_NOTE_MAX}
+ placeholder={notePlaceholder}
+ className="flex-1 px-2 py-1 bg-port-bg border border-port-border rounded text-white text-xs"
+ />
+ <button
+ type="button"
+ onClick={() => removeEntry(i)}
+ className="px-2 py-1 text-xs text-port-error hover:bg-port-error/10 rounded"
+ >
+ Remove
+ </button>
+ </div>
+ </div>
+ ))}
+ </div>
+ {entries.length < STYLE_GUIDE_EXEMPLARS_MAX && (
+ <button
+ type="button"
+ onClick={addEntry}
+ className="mt-2 px-2 py-1 text-xs text-port-accent hover:bg-port-accent/10 rounded border border-port-border"
+ >
+ + Add passage
+ </button>
+ )}
</div>
);
}
diff --git a/server/lib/styleGuide.js b/server/lib/styleGuide.js
index 797659309b..93afb09865 100644
--- a/server/lib/styleGuide.js
+++ b/server/lib/styleGuide.js
@@ -27,6 +27,15 @@ export const STYLE_GUIDE_LIMITS = Object.freeze({
TONES_MAX: 20,
READING_LEVEL_MIN: 1,
READING_LEVEL_MAX: 18,
+ // Voice exemplars (#2179, CWQE Phase 14) — concrete prose anchors ("the
+ // tuning fork") beat adjective lists. Passages run ~150–300 words; the cap is
+ // ~2000 chars each and 3 apiece so the fixed per-call prompt overhead stays
+ // tight (exemplars are injected into every draft/revision prompt). Each entry
+ // is `{ passage, note }` — the note says what the passage demonstrates
+ // (exemplar) or what's wrong with it (anti-exemplar: "too ornate").
+ EXEMPLARS_MAX: 3,
+ EXEMPLAR_PASSAGE_MAX: 2000,
+ EXEMPLAR_NOTE_MAX: 200,
});
export const STYLE_GUIDE_TENSES = Object.freeze(['past', 'present']);
@@ -79,6 +88,25 @@ function cleanTone(raw) {
return out;
}
+// Sanitize a list of voice exemplar / anti-exemplar passages (#2179). Each
+// entry is `{ passage, note }`: `passage` is the concrete prose anchor (the
+// tuning fork), `note` a one-line gloss of what it demonstrates (exemplar) or
+// what's wrong with it (anti-exemplar). Drops entries with no passage, trims to
+// the char caps, and caps the list length. Returns `[]` when nothing usable.
+function cleanExemplars(raw) {
+ if (!Array.isArray(raw)) return [];
+ const out = [];
+ for (const item of raw) {
+ if (item == null || typeof item !== 'object') continue;
+ const passage = trimTo(item.passage, STYLE_GUIDE_LIMITS.EXEMPLAR_PASSAGE_MAX);
+ if (!passage) continue;
+ const note = trimTo(item.note, STYLE_GUIDE_LIMITS.EXEMPLAR_NOTE_MAX);
+ out.push(note ? { passage, note } : { passage });
+ if (out.length >= STYLE_GUIDE_LIMITS.EXEMPLARS_MAX) break;
+ }
+ return out;
+}
+
// Sanitize the copy-edit conventions sub-object. Returns null when nothing is
// set so a guide that declares only tense/POV doesn't carry an empty husk.
function sanitizeConventions(raw) {
@@ -107,13 +135,39 @@ export function sanitizeStyleGuide(raw) {
const readingLevel = optReadingLevel(raw.readingLevel);
const tone = cleanTone(raw.tone);
const conventions = sanitizeConventions(raw.conventions);
+ const voiceExemplars = cleanExemplars(raw.voiceExemplars);
+ const voiceAntiExemplars = cleanExemplars(raw.voiceAntiExemplars);
if (
tense == null && povPerson == null && targetAudience == null && contentRating == null
&& profanity == null && readingLevel == null && tone.length === 0 && conventions == null
+ && voiceExemplars.length === 0 && voiceAntiExemplars.length === 0
) {
return null;
}
- return { tense, povPerson, targetAudience, contentRating, profanity, readingLevel, tone, conventions };
+ return {
+ tense, povPerson, targetAudience, contentRating, profanity, readingLevel, tone, conventions,
+ voiceExemplars, voiceAntiExemplars,
+ };
+}
+
+// Render the voice exemplar / anti-exemplar blocks (#2179). Concrete prose
+// anchors do more to fix voice than any adjective list — so a "MATCH this
+// voice" block of exemplars and a "NEVER drift toward this" block of
+// anti-exemplars are appended to the house-style directives. Both are
+// conditional: absent exemplars render nothing (so a guide with no passages
+// carries no empty husk in the prompt). Returns `''` when neither is present.
+function renderVoiceExemplars(styleGuide) {
+ const blocks = [];
+ const exemplars = Array.isArray(styleGuide.voiceExemplars) ? styleGuide.voiceExemplars : [];
+ const antiExemplars = Array.isArray(styleGuide.voiceAntiExemplars) ? styleGuide.voiceAntiExemplars : [];
+ const renderPassage = (e) => (e.note ? `> ${e.passage}\n> — ${e.note}` : `> ${e.passage}`);
+ if (exemplars.length) {
+ blocks.push(`MATCH this voice — these passages are the tuning fork for the series' prose. Echo their rhythm, diction, and register; do not copy their content:\n${exemplars.map(renderPassage).join('\n\n')}`);
+ }
+ if (antiExemplars.length) {
+ blocks.push(`NEVER drift toward this — these passages are in the wrong register for the series. Avoid what each note flags:\n${antiExemplars.map(renderPassage).join('\n\n')}`);
+ }
+ return blocks.join('\n\n');
}
/**
@@ -155,8 +209,12 @@ export function renderStyleGuide(styleGuide) {
if (conv.italicizeThoughts === true) directives.push('Render internal thoughts in italics.');
else if (conv.italicizeThoughts === false) directives.push('Do not italicize internal thoughts.');
}
- if (directives.length === 0) return null;
- return `Series style guide (house style — follow exactly):\n${directives.map((d) => `- ${d}`).join('\n')}`;
+ const voiceBlock = renderVoiceExemplars(styleGuide);
+ if (directives.length === 0 && !voiceBlock) return null;
+ const header = directives.length
+ ? `Series style guide (house style — follow exactly):\n${directives.map((d) => `- ${d}`).join('\n')}`
+ : '';
+ return [header, voiceBlock].filter(Boolean).join('\n\n');
}
/**
diff --git a/server/lib/styleGuide.test.js b/server/lib/styleGuide.test.js
index 27b44e180b..486b802e89 100644
--- a/server/lib/styleGuide.test.js
+++ b/server/lib/styleGuide.test.js
@@ -63,6 +63,37 @@ describe('sanitizeStyleGuide', () => {
it('survives when only one field is set', () => {
expect(sanitizeStyleGuide({ tense: 'past' })).toMatchObject({ tense: 'past', povPerson: null });
});
+
+ it('cleans voice exemplars: drops empty passages, trims, caps at 3', () => {
+ const sg = sanitizeStyleGuide({
+ voiceExemplars: [
+ { passage: ' Spare, clipped prose. ', note: ' wry ' },
+ { passage: '', note: 'no passage' }, // dropped — empty passage
+ { passage: 'x'.repeat(3000) }, // trimmed to cap, no note key
+ { passage: 'four' },
+ { passage: 'five' }, // over the cap of 3 → dropped
+ 'not an object', // ignored
+ ],
+ });
+ expect(sg.voiceExemplars).toHaveLength(3);
+ expect(sg.voiceExemplars[0]).toEqual({ passage: 'Spare, clipped prose.', note: 'wry' });
+ expect(sg.voiceExemplars[1].passage).toHaveLength(STYLE_GUIDE_LIMITS.EXEMPLAR_PASSAGE_MAX);
+ expect(sg.voiceExemplars[1]).not.toHaveProperty('note'); // no note → key omitted
+ expect(sg.voiceExemplars[2]).toEqual({ passage: 'four' });
+ });
+
+ it('a guide with only exemplars is not collapsed to null', () => {
+ const sg = sanitizeStyleGuide({ voiceExemplars: [{ passage: 'anchor prose' }] });
+ expect(sg).not.toBeNull();
+ expect(sg.tense).toBeNull();
+ expect(sg.voiceExemplars).toHaveLength(1);
+ expect(sg.voiceAntiExemplars).toEqual([]);
+ });
+
+ it('all-empty exemplar entries do not save an empty husk', () => {
+ // Every field absent + exemplars that all drop → still null.
+ expect(sanitizeStyleGuide({ voiceExemplars: [{ passage: '' }, 'junk'] })).toBeNull();
+ });
});
describe('renderStyleGuide', () => {
@@ -99,4 +130,36 @@ describe('renderStyleGuide', () => {
expect(block).not.toContain('rating');
expect(block).toContain('past tense');
});
+
+ it('renders MATCH / NEVER voice blocks with passages + notes', () => {
+ const block = renderStyleGuide(sanitizeStyleGuide({
+ tense: 'past',
+ voiceExemplars: [{ passage: 'The rain came sideways.', note: 'terse' }],
+ voiceAntiExemplars: [{ passage: 'Verily the tempest did descend.', note: 'too ornate' }],
+ }));
+ expect(block).toContain('past tense');
+ expect(block).toContain('MATCH this voice');
+ expect(block).toContain('The rain came sideways.');
+ expect(block).toContain('— terse');
+ expect(block).toContain('NEVER drift toward this');
+ expect(block).toContain('Verily the tempest did descend.');
+ expect(block).toContain('— too ornate');
+ });
+
+ it('renders voice blocks even when no mechanical directives are set', () => {
+ const block = renderStyleGuide(sanitizeStyleGuide({
+ voiceExemplars: [{ passage: 'Clean, quiet sentences.' }],
+ }));
+ expect(block).not.toBeNull();
+ expect(block).not.toContain('house style — follow exactly'); // no directive header
+ expect(block).toContain('MATCH this voice');
+ expect(block).toContain('Clean, quiet sentences.');
+ });
+
+ it('conditionally omits absent voice blocks (renders nothing)', () => {
+ const block = renderStyleGuide(sanitizeStyleGuide({ tense: 'present' }));
+ expect(block).toContain('present tense');
+ expect(block).not.toContain('MATCH this voice');
+ expect(block).not.toContain('NEVER drift toward this');
+ });
});
diff --git a/server/routes/pipeline/series.js b/server/routes/pipeline/series.js
index 1d372fb137..69e71347cb 100644
--- a/server/routes/pipeline/series.js
+++ b/server/routes/pipeline/series.js
@@ -124,6 +124,19 @@ const styleGuideSchema = z.object({
spelling: z.enum(STYLE_GUIDE_SPELLING).nullable().optional(),
italicizeThoughts: z.boolean().nullable().optional(),
}).nullable().optional(),
+ // Voice exemplars / anti-exemplars (#2179, CWQE Phase 14). Concrete prose
+ // anchors ("the tuning fork") injected into every draft/revision prompt.
+ // `note` is optional (a passage can stand on its own); the service-side
+ // `cleanExemplars` drops empty passages, trims to the char caps, and caps the
+ // list length, so the schema only bounds the outer shape.
+ voiceExemplars: z.array(z.object({
+ passage: z.string().trim().min(1).max(STYLE_GUIDE_LIMITS.EXEMPLAR_PASSAGE_MAX),
+ note: z.string().trim().max(STYLE_GUIDE_LIMITS.EXEMPLAR_NOTE_MAX).optional(),
+ })).max(STYLE_GUIDE_LIMITS.EXEMPLARS_MAX).optional(),
+ voiceAntiExemplars: z.array(z.object({
+ passage: z.string().trim().min(1).max(STYLE_GUIDE_LIMITS.EXEMPLAR_PASSAGE_MAX),
+ note: z.string().trim().max(STYLE_GUIDE_LIMITS.EXEMPLAR_NOTE_MAX).optional(),
+ })).max(STYLE_GUIDE_LIMITS.EXEMPLARS_MAX).optional(),
});
// Volume-cover / back-cover sub-schema — accepts the script text plus the