diff --git a/templates/book_chapter.yml b/templates/book_chapter.yml index e40b342..592320f 100644 --- a/templates/book_chapter.yml +++ b/templates/book_chapter.yml @@ -1,542 +1,542 @@ -name: book_chapter -description: "Write one chapter — continuity check, draft, self-check, then spawn editorial review." -debug: true +name: book_chapter +description: "Write one chapter -- continuity check, draft, self-check, then spawn editorial review." +debug: true rag_exclude: [business_plan, charter] -system: agent_prompt - -requires: - - genre_name - - genre_audience - - prose_style - - chapter_target_words - - chapter_ref - -conditional_skills: - - path: guides/YAFictionGuide.md - genre_contains: - - "YA" - - "Young Adult" - - path: guides/RomanceFictionGuide.md - genre_contains: - - "Romance" - - "Contemporary Romance" - - path: guides/SciFiFictionGuide.md - genre_contains: - - "Science Fiction" - - "Sci-Fi" - - "SciFi" - - "Science-Fiction" - -# Genre-aware guide use: Only the guide whose genre_contains keywords match {genre_name} -# is injected. The pipeline skips non-matching guides entirely, so there are no -# conflicting craft signals from other genres. - -agent_prompt: - - "= identity.md" - - "agent.rag.json" - -sections: - - agent - - project - - rag - - skills - - deliverables - - message - - rejection_feedback - - instructions - -steps: - - type: think - hint: | - PASS 0 — BIBLE, CONTINUITY, AND DRAFT PROMPT - - GENRE: {genre_name} | AUDIENCE: {genre_audience} - PROSE STYLE GUIDE: {prose_style} - TARGET CHAPTER LENGTH: ~{chapter_target_words} words - THIS CHAPTER: {chapter_number} ({chapter_ref}) - - GENRE GUIDE: Your skills section contains exactly the guide for {genre_name}. Apply it fully. - - ╔══════════════════════════════════════════════════════════════════╗ - ║ THE READER KNOWS RULE — CRITICAL, NON-NEGOTIABLE ║ - ║ You are the Scribe entering chapter {chapter_number}. ║ - ║ You may only use information the READER already knows — ║ - ║ what was established in chapters 1 through {chapter_number}. ║ - ║ Characters enter this chapter as they left chapter ║ - ║ {chapter_number_prev}, not as they end up at book's end. ║ - ║ ║ - ║ FORBIDDEN sources: ║ - ║ - Outline entries for chapters after {chapter_number} ║ - ║ - Character sheet state written after this chapter ║ - ║ - Any deliverable whose filename contains a chapter ref ║ - ║ later than {chapter_ref} (e.g. chapter-ch-08 when ║ - ║ writing ch-03) ║ - ║ - Editorial reviews, polish drafts, roundtable summaries ║ - ║ (they reflect post-writing analysis) ║ - ╚══════════════════════════════════════════════════════════════════╝ - - STEP 1 — READ THE OUTLINE (chapters 1 through {chapter_number} ONLY): - Look at PROJECT DELIVERABLES for the outline file. - ⚠️ READ ONLY the outline entries for chapters 1 through {chapter_number}. - STOP READING when you reach "Chapter {chapter_number_next}:" or any heading - indicating a chapter number greater than {chapter_number}. - Do NOT read, record, or reason from any future chapter entry. - - From the permitted portion, extract and record: - - Protagonist: exact name, voice description, age (if fiction) - - Love interest and supporting characters: exact names and roles (if fiction) - - World rules / constraints established so far (if paranormal or speculative) - - THIS chapter's summary, emotional beat, and closing hook ONLY - If no outline/bible is available, use the character names and project details - from the task description above — be CONSISTENT throughout the book. - - STEP 2 — CHARACTER STATE (enter chapter {chapter_number} as they LEFT chapter {chapter_number_prev}): - Character sheets show the FINAL state of each character (end of book). - Do NOT use that final state for early chapters. - - Use sources in this priority order: - 1. RAG asset [character-state] — the most accurate record of right now. - Record as "LIVE CHARACTER STATE:" and use it to override outline predictions. - 2. "PREVIOUS CHAPTER CHARACTER STATE:" block if present in this prompt. - 3. The character's established traits from outline up to chapter {chapter_number_prev}. - Ignore arc resolution or growth that happens in later chapters. - - LOCATION CONTINUITY CHECK (if [character-state] is present): - Does this chapter's outline place any character at a location inconsistent - with their Location field in [character-state]? - If conflict found — FLAG before drafting: - "LOCATION CONFLICT: [char] is at [state-location] per last chapter but outline - places them at [outline-location]. Resolve: (a) open chapter in transit, - (b) adjust scene to actual location, or (c) write a time-skip bridge paragraph. - Do NOT silently teleport the character." - - Also note Active obligations, Open loops, or Known secrets from [character-state] - that should be honored or advanced in this chapter. - - Also check RAG for [world-state] — current NPC attitudes and faction memory. - If present, record as "LIVE WORLD STATE:". NPCs listed there should behave - according to their recorded attitude. - - STEP 3 — FIND THE PREVIOUS CHAPTER: - Look at PROJECT DELIVERABLES for the chapter before this one - (filename: chapter-{chapter_ref_prev} or similar). - If no previous chapter exists (this IS Chapter 1), skip to STEP 5. - - STEP 4 — QUOTE THE ENDING: - Copy the LAST 2–3 sentences of the previous chapter here, word for word. - Label them: "PREVIOUS CHAPTER ENDED WITH: ..." - Your new chapter MUST pick up from this exact moment. - - STEP 5 — BUILD THE DRAFT PROMPT: - Write the exact drafting prompt for the next pass. That prompt must include: - - CHAPTER: Exact chapter number and title (from the task message) - - POV CHARACTER: Whose perspective are we in? - - FIRST LINE: The exact opening sentence, continuing from the previous ending - - EMOTIONAL ARC: What does the protagonist feel at start vs end OF THIS CHAPTER? - - CHAPTER GOAL: What plot event MUST happen here? - - KEY BEATS: 3–5 numbered scene beats that will form the chapter - - CLOSING HOOK: Exact last image or line that makes readers continue - - Reminders about continuity, prose style, and target length - - CHARACTER VOICE PROFILES (pre-extracted): - {character_profiles} - If this block is empty, fall back to searching PROJECT DELIVERABLES for a file - containing "## Voice Signatures" and copy it here. Use ONLY the voice/speech - patterns — do NOT copy arc outcomes or end-state descriptions. - PASS 1 must write every character to their profile. - - EDITORIAL OVERRIDES — apply these BEFORE writing any KEY BEATS: - {author_intent} - ^ If this line is not blank, it is a BINDING creative directive from the editor. - Include it verbatim in the draft prompt as: "AUTHOR'S INTENT: [text]" - PASS 1 must satisfy this intent completely. - {closing_hook} - ^ If this line is not blank, use it as the CLOSING HOOK instead of any outline hook. - Include it verbatim in the draft prompt as: "LOCKED CLOSING HOOK: [text]" - - Stop here. Output ONLY the draft prompt. Do NOT write chapter prose yet. - - - type: think - model: power - max_tokens: 32000 - hint: | - PASS 1 — WRITE THE DRAFT - - Use the draft prompt below as your exact writing brief: - - {steps[0].text} - - Requirements: - - Start with the FIRST LINE you planned — make it continue naturally from the previous chapter - - If the draft prompt contains a line starting with "LOCKED PREVIOUS CHAPTER HOOK:", - your FIRST LINE MUST directly resolve that hook — the reader expects the answer immediately - - If the draft prompt contains a line starting with "AUTHOR'S INTENT:", treat it as a - binding creative directive — your draft must satisfy that intent in full - - Follow the KEY BEATS in order, but write with full scene depth — don't skip - - All character names must be consistent with the bible/outline - - Every dialogue exchange must be tight and voice-distinct - - Show, don't tell — externalize emotion through action, detail, and dialogue - - Every scene beat moves the story forward OR reveals character (no filler) - - End with the CLOSING HOOK you planned - - Match the prose style guide: {prose_style} - - Target length: {chapter_target_words} words — write the FULL chapter, not a summary - - ⚠️ DO NOT stop early. If you have not reached {chapter_target_words} words, continue - writing — add interiority, sensory detail, extended dialogue beats, and scene transitions - until you hit the target. Short chapters will be REJECTED in adjudication. - - DRAFTING DISCIPLINE — apply these on every page: - - {prose_style} is a hard constraint, not decoration - - Not every paragraph needs a memorable or quotable line — use functional connective prose - - Let observation precede interpretation: show the moment before naming what it means - - Avoid clustering aphorisms or thesis-style sentences back to back - - Prefer scene motion over thesis delivery — action and dialogue carry meaning - - Write ONE complete draft now. Do NOT self-polish. Reviewers will give feedback downstream. - - VOICE ANTI-PATTERNS — THESE ARE FORBIDDEN ON EVERY PAGE: - - Do NOT open any chapter with the "didn't just X; it Y" sentence construction. - Every chapter must have a structurally distinct opener. Vary: in medias res, - quiet beat, dialogue cold open, environmental sweep, interiority. - No two consecutive chapters may use the same opener structure. - - The book's thematic contrast (whatever it is — body/mind, memory/possibility, etc.) - may appear ONCE per scene as a metaphor. Not in every paragraph. Trust the reader. - If you have used the contrast in the last two paragraphs, you may not use it again - for at least three more paragraphs. - - Do NOT label an emotion that you have already shown through action or dialogue. - If the character's hands are shaking, do not also write "she was afraid." - If the dialogue already conveys anger, do not add "his voice was furious." - - Do NOT count or reference chapter numbers in the prose. - "Five chapters of..." is an AI fingerprint. Never. - - Each character must have at least ONE verbal imperfection per scene they appear in: - a sentence they don't finish, a word they use wrong, a line that doesn't land, - a moment of fumbling before the right words come. Perfect dialogue is dead dialogue. - - Check the CHARACTER VOICE PROFILE in the outline/bible (if present) — if each - speaking character's dialogue cannot be identified as THEIRS without a speaker tag, - rewrite until it can. Verbal tics, pet phrases, and characteristic patterns are - non-negotiable signatures. - - Output ONLY the draft chapter text. - Start directly with the chapter title (e.g., "Chapter N: [Title]") and opening line. - No commentary, no plan headers, no "Pass 1" label. - - - type: think - model: power - max_tokens: 32000 - hint: | - SELF-CHECK — STRUCTURAL VALIDATION AND WORD-COUNT EXPANSION - - You have just written a chapter draft. Your job: check the draft against the structural - checklist below, apply all corrections within scope (including word-count expansion if - the draft is short), and output the final chapter. - - DRAFT TO CHECK: - {steps[1].text} - - CHECKLIST — check each item, note any issue found: - 1. BEAT & HOOK: Does the chapter reach its intended emotional beat and closing hook - from the PASS 0 draft prompt? Flag if the chapter ends without the planned hook. - 2. NAMES & POV: Are all character names and the POV consistent with the bible/outline? - Flag any name that doesn't match the project canon. - 3. CONTINUITY TERMS: Do world rules, place names, and timeline references match - project state? Flag any factual break. - 4. FORMATTING: Are there obvious section-break artifacts, duplicate headers, - or missing chapter title? Flag and fix. - 5. WORD FLOOR: Estimate draft word count: count paragraphs × ~60 words/paragraph. - Target is {chapter_target_words} words. - BEFORE writing the VALIDATION LOG line, you MUST have your full word estimate. - - If the draft is MORE THAN 10% under target: EXPAND NOW (write SCENE A, B, C BEFORE validation log). - - If within 10% of target: PASS, output verbatim. - Do NOT write 'EXPANDED' in the log if you did not write actual new scenes. - 6. OPENING HOOK: Check the PASS 0 draft prompt ({steps[0].text}) for a line labeled - "LOCKED PREVIOUS CHAPTER HOOK:". If present, verify the chapter's opening paragraph - directly resolves it. If not, add a brief resolution sentence at the opening — - do not leave a locked hook unanswered. - 7. AUTHOR'S INTENT: Check the PASS 0 draft prompt ({steps[0].text}) for a line - starting with "AUTHOR'S INTENT:". If present, confirm the completed chapter - satisfies that intent — note whether it was honored or partially missed. - 8. CLOSING HOOK LOCK: Check the PASS 0 draft prompt ({steps[0].text}) for a line - starting with "LOCKED CLOSING HOOK:". If present, verify the last paragraph of - the chapter uses that exact hook wording. If it's missing or paraphrased, add a - final paragraph that delivers the locked hook precisely. - - ALLOWED CORRECTIONS: - - Fix a wrong character name to match the canon name - - Fix a POV slip (e.g., the chapter is 1st-person but one paragraph shifted to 3rd) - - Fix a missing or duplicated chapter title/header - - If the chapter is missing its closing hook entirely, add it as a final paragraph - that matches the hook specified in the draft prompt — no new invention beyond the - planned hook - - WORD COUNT EXPANSION (when draft is more than 10% below {chapter_target_words}): - IMPORTANT: Do NOT claim expansion in the VALIDATION LOG unless you have actually written it. - The WORD FLOOR line must show a word count you can verify by counting paragraphs. - Each paragraph ≈ 50–80 words. Count your paragraphs × 60 to estimate total words. - Write NEW SCENES sequentially AFTER the chapter ends: - SCENE A: 400+ words — interiority beat deepening the aftermath - SCENE B: 400+ words — dialogue exchange with voice-distinct characters - SCENE C: 300+ words — grounded transition showing the next 24 hours - Total added prose must reach the word target. Obey voice anti-patterns from PASS 1. - Do NOT add new plot beats not in PASS 0. Each new scene is an EXPANSION, not a new chapter. - - NOT ALLOWED — do not make any of these changes: - - Improve existing sentences for prose quality, rhythm, or lyricism - - Reorder scenes or restructure the chapter - - Add new metaphors or aphorisms to existing prose - - Normalize or upgrade the authorial voice in existing sentences - - OUTPUT FORMAT: - Start your response with a VALIDATION LOG section: - VALIDATION LOG: - 1. BEAT & HOOK: [check pass/fail with brief note] - 2. NAMES & POV: [check pass/fail with brief note] - 3. CONTINUITY TERMS: [check pass/fail with brief note] - 4. FORMATTING: [check pass/fail — note any fixes applied] - 5. WORD FLOOR: [PASS/EXPANDED — include word count before and after] - 6. OPENING HOOK: [check pass/fail or N/A] - 7. AUTHOR'S INTENT: [honored / partially missed — note / N/A if no intent set] - 8. CLOSING HOOK LOCK: [locked hook delivered / missing / N/A if not locked] - - Then output the separator on its own line: - ---BEGIN CHAPTER--- - - Then output the COMPLETE final chapter text (all original prose + any expansion). - Start the chapter directly with the chapter title and first line. - No preamble or commentary within the chapter text. - - # Commit chapter draft now — last_text() = self-check output (step 2). Must come before - # PASS 3 think so the character-state extraction does not overwrite last_text(). - - type: document - filename: "Chapter_{chapter_number}_draft" - primary_deliverable: true - strip_before_marker: "---BEGIN CHAPTER---" - - - type: think - system: | - EXTRACTION MODE — DO NOT CREATE FICTION. - Your ONLY task is to extract factual state from the chapter you just wrote. - You are NOT writing the story. You are NOT continuing the narrative. - Characters who are DEAD are DEAD. You may NOT invent a living version of them. - A character is DECEASED only if they are explicitly killed in the PASS 1 prose of THIS chapter. - DO NOT preemptively mark characters DECEASED based on project outline future events. - If the outline says a character dies in Chapter 9 but you are writing Chapter 4 and they survive in your prose, they are ALIVE in this chapter's state. - hint: | - PASS 3 -- CHARACTER + WORLD STATE EXTRACTION - - ══ STEP 0: FIND THE CORRECT CHAPTER TEXT (DO THIS FIRST) ══ - This conversation has multiple text sources. You must extract from the RIGHT one. - - YOUR CONVERSATION HISTORY (in order): - Turn 1 → You received PASS 0 context (deliverables, outline, bible). - Deliverables include files like [Chapter_1_draft.md], [Chapter_3_draft.md], - [Chapter_10_draft.md], etc. THESE ARE HISTORICAL. NOT the current chapter. - Turn 2 → You wrote Chapter {chapter_number} in PASS 1 (~4000-word narrative prose). - THIS IS THE CHAPTER YOU ARE ANALYZING. - Turn 3 → You performed SELF-CHECK (editorial notes, not chapter prose). - Turn 4 → THIS MESSAGE (PASS 3 extract). - - THE CHAPTER = YOUR PASS 1 RESPONSE (Turn 2). It starts immediately after the line - "PASS 1 — WRITE THE DRAFT" and ends before the SELF-CHECK. - - ⚠ ANCHOR TEST — before writing any Location field, ask yourself: - "Did I write this location in my PASS 1 narrative, or is it from a deliverable file?" - If it is from any [Chapter_N_draft.md] or from the PRE-PASS-1 context — REJECT IT. - Use ONLY what your PASS 1 narrative says. - - ══ MANDATORY CHECK — DECEASED CHARACTERS ══ - Before writing ANY character entry, classify every named character into ONE bucket: - - BUCKET A — DIES IN THIS CHAPTER: Character appears alive in PASS 1, then dies within - THIS chapter's narrative (death scene described in PASS 1 prose). - → Use DECEASED FORMAT. Death chapter = {chapter_ref} (NOT any prior chapter). - → Write a NEW ESTABLISHED sentence from how they died in PASS 1. - → NEVER copy the chapter number or cause from a prior deliverable. - - BUCKET B — ALIVE THROUGHOUT: Character appears in PASS 1 and is still alive at the end. - → Use LIVING FORMAT. - → Prior deliverables showing them DECEASED are OVERRIDDEN by the prose. - → The prose you wrote is THE authoritative source. No exceptions. - - BUCKET C — ABSENT (not in PASS 1 prose at all): Character does not appear. - → Check PASS 0 for last known state. - → If DECEASED in prior state: copy their entry forward UNCHANGED (same chapter). - → If ALIVE in prior state: omit them (no update needed for off-screen characters). - - RULE: NEVER use a prior deliverable's death-chapter for BUCKET A characters. - NEVER mark a BUCKET B character as DECEASED. - NEVER give a BUCKET C / deceased character a living Location or Emotional field. - ══ DECEASED FORMAT(two lines only) ══ - ## [Name] — DECEASED (Ch[N]) - Established: [one sentence: how they died] - Legacy: [one sentence: how their death affected this chapter] - - ══ LIVING CHARACTER FORMAT ══ - - # Character State: {chapter_ref} - - ## [Character Name] - Location: [specific location -- building, floor, city, planet] - Physical: [injuries, fatigue, notable physical state, or "no injuries"] - Emotional: [dominant emotion at chapter end] - Active obligations: [format: "owes [person] [what] (Ch[N]) -- UNPAID/PAID"] - Open loops: [format: "[parties] [issue] (Ch[N]) -- UNRESOLVED/RESOLVED"] - Known secrets: [format: "knows [what] -- [who does NOT know]"] - Arc: [XX%] -- [one sentence: what permanently changed this chapter] - Permanent: [YES/NO] - - (Repeat for EVERY named character who appeared. Deceased = short form only.) - - # World State: {chapter_ref} - - ## NPC Memory - - [NPC Name] ([faction/location]): [ATTITUDE] -- [what happened] -- [consequence] - - ## Faction Attitudes - - [Faction name]: [attitude] -- [reason] - - ## Active World Events - - [Event]: [status and timeline] - - ══ SECRET CARRY-FORWARD RULE ══ - Before submitting, check the PASS 0 context for any "Known secrets:" fields or - "CARRIED SECRET" markers from the PREVIOUS character-state file. - ⚠ FUTURE-CHAPTER CONTAMINATION GUARD: ONLY carry secrets from character-state files - whose filename indicates a chapter EARLIER than {chapter_ref}. - Example: if writing ch-07, only use secrets from ch-06, ch-05, ch-04, etc. - NEVER copy a secret from character-state-ch-08 or later — those are FUTURE events. - If a secret in PASS 0 context comes from a deliverable filename like - "character-state-ch-08" or "character-state-ch-09", IGNORE it entirely. - For each secret that was NOT resolved or revealed in THIS chapter's PASS 1 prose: - → Copy it forward unchanged into the character's "Known secrets:" field. - → Prefix it: "CARRIED (Ch[N]—unresolved): [secret]" - This ensures multi-chapter secrets are NOT silently dropped between chapters. - - ══ DEATH-FORWARD RULE ══ - Scan the PASS 1 prose for character death events (these are BUCKET A characters). - For each character who DIES in THIS chapter's prose: - → Status: DECEASED ({chapter_ref}) — always the CURRENT chapter, never a prior one - → Established: [one sentence from PASS 1 describing HOW they died] - → Legacy: [one sentence: how their death affects surviving characters this chapter] - → Remove all Living Format fields (Location, Physical, Emotional, obligations, etc.) - For characters ALREADY deceased in prior state (BUCKET C, absent from prose): - → Copy their entry forward UNCHANGED. Do NOT change the chapter number or cause. - EXCEPTION — RETCON: If a character was DECEASED in prior state but appears ALIVE in - THIS chapter's PASS 1 prose (BUCKET B), use LIVING FORMAT. Prose overrides all. - - CRITICAL: Keep total output under 3500 characters. NO prose — structured data only. - - - type: rag_write - asset_id: "character-state" - source_step: 4 # PASS 3 character-state extraction; explicit to avoid last_text() falling back to chapter text - max_chars: 4000 - - - type: document - filename: "character-state-{chapter_ref}" - - - type: package - source_step: 4 # PASS 3 — character-state extraction (compact, describes permanent changes) - max_tokens: 4000 - hint: | - The draft chapter has been written, self-checked, and committed. - The character-state from PASS 3 is provided above. - - Summarize the character state changes for {chapter_ref} in the `chapter_state` field - (2-3 sentences max). This is used for bookkeeping — the chapter text itself is passed - to reviewers directly. - - NEW CHARACTER DETECTION: - For each NEW character introduced this chapter (not previously known), emit one - create_task action using task_type: character_sheet. - - PERMANENT CHANGE DETECTION (butterfly effect): - For any character with "Permanent: YES" in the state, emit a create_task action - using task_type: character_update to record the change in the character sheet. - - Now confirm the chapter is ready for review. - schema: - chapter_state: string - spawn: - - task_type: chapter_review - task_name: "Review (Devon): {chapter_ref}" - agent_name: Devon - priority: 6 - _if: "not meta.is_locked" - context: - chapter_text: "{steps[1].text}" - review_focus: developmental - genre_name: "{genre_name}" - genre_audience: "{genre_audience}" - chapter_ref: "{chapter_ref}" - chapter_number: "{chapter_number}" - review_letter: "a" - character_profiles: "{character_profiles|}" - - - task_type: chapter_review - task_name: "Review (Lane): {chapter_ref}" - agent_name: Lane - priority: 6 - _if: "not meta.is_locked" - context: - chapter_text: "{steps[1].text}" - review_focus: line - genre_name: "{genre_name}" - genre_audience: "{genre_audience}" - chapter_ref: "{chapter_ref}" - chapter_number: "{chapter_number}" - review_letter: "b" - character_profiles: "{character_profiles|}" - - - task_type: chapter_review - task_name: "Review (Cora): {chapter_ref}" - agent_name: Cora - priority: 6 - _if: "not meta.is_locked" - context: - chapter_text: "{steps[1].text}" - review_focus: continuity - genre_name: "{genre_name}" - genre_audience: "{genre_audience}" - chapter_ref: "{chapter_ref}" - chapter_number: "{chapter_number}" - review_letter: "c" - character_profiles: "{character_profiles|}" - - - task_type: chapter_roundtable - task_name: "Roundtable: {chapter_ref}" - agents: - - Devon - - Lane - - Cora - priority: 7 - _if: "not meta.is_locked" - context: - chapter_text: "{steps[1].text}" - genre_name: "{genre_name}" - genre_audience: "{genre_audience}" - chapter_ref: "{chapter_ref}" - chapter_target_words: "{chapter_target_words}" - character_profiles: "{character_profiles|}" - depends_on: - - "Review (Devon): {chapter_ref}" - - "Review (Lane): {chapter_ref}" - - "Review (Cora): {chapter_ref}" - - - type: close - rag_update: true - -adjudication: - enabled: true - pass_threshold: 80 - deliverable_type: consumer - criteria: - word_count: - weight: 30 - description: "Chapter meets the {chapter_target_words}-word minimum; under-length chapters fail" - narrative_flow: - weight: 25 - description: "Story progresses naturally with good pacing" - character_voice: - weight: 20 - description: "Characters are distinct and consistent" - prose_quality: - weight: 15 - description: "Writing is clear and readable; voice is consistent with {prose_style}" - continuity: - weight: 10 - description: "Consistent with prior chapters and canon" +system: agent_prompt + +requires: + - genre_name + - genre_audience + - prose_style + - chapter_target_words + - chapter_ref + +conditional_skills: + - path: guides/YAFictionGuide.md + genre_contains: + - "YA" + - "Young Adult" + - path: guides/RomanceFictionGuide.md + genre_contains: + - "Romance" + - "Contemporary Romance" + - path: guides/SciFiFictionGuide.md + genre_contains: + - "Science Fiction" + - "Sci-Fi" + - "SciFi" + - "Science-Fiction" + +# Genre-aware guide use: Only the guide whose genre_contains keywords match {genre_name} +# is injected. The pipeline skips non-matching guides entirely, so there are no +# conflicting craft signals from other genres. + +agent_prompt: + - "= identity.md" + - "agent.rag.json" + +sections: + - agent + - project + - rag + - skills + - deliverables + - message + - rejection_feedback + - instructions + +steps: + - type: think + hint: | + PASS 0 -- BIBLE, CONTINUITY, AND DRAFT PROMPT + + GENRE: {genre_name} | AUDIENCE: {genre_audience} + PROSE STYLE GUIDE: {prose_style} + TARGET CHAPTER LENGTH: ~{chapter_target_words} words + THIS CHAPTER: {chapter_number} ({chapter_ref}) + + GENRE GUIDE: Your skills section contains exactly the guide for {genre_name}. Apply it fully. + + ???????????????????????????????????????????????????????????????????? + ? THE READER KNOWS RULE -- CRITICAL, NON-NEGOTIABLE ? + ? You are the Scribe entering chapter {chapter_number}. ? + ? You may only use information the READER already knows -- ? + ? what was established in chapters 1 through {chapter_number}. ? + ? Characters enter this chapter as they left chapter ? + ? {chapter_number_prev}, not as they end up at book's end. ? + ? ? + ? FORBIDDEN sources: ? + ? - Outline entries for chapters after {chapter_number} ? + ? - Character sheet state written after this chapter ? + ? - Any deliverable whose filename contains a chapter ref ? + ? later than {chapter_ref} (e.g. chapter-ch-08 when ? + ? writing ch-03) ? + ? - Editorial reviews, polish drafts, roundtable summaries ? + ? (they reflect post-writing analysis) ? + ???????????????????????????????????????????????????????????????????? + + STEP 1 -- READ THE OUTLINE (chapters 1 through {chapter_number} ONLY): + Look at PROJECT DELIVERABLES for the outline file. + ?? READ ONLY the outline entries for chapters 1 through {chapter_number}. + STOP READING when you reach "Chapter {chapter_number_next}:" or any heading + indicating a chapter number greater than {chapter_number}. + Do NOT read, record, or reason from any future chapter entry. + + From the permitted portion, extract and record: + - Protagonist: exact name, voice description, age (if fiction) + - Love interest and supporting characters: exact names and roles (if fiction) + - World rules / constraints established so far (if paranormal or speculative) + - THIS chapter's summary, emotional beat, and closing hook ONLY + If no outline/bible is available, use the character names and project details + from the task description above -- be CONSISTENT throughout the book. + + STEP 2 -- CHARACTER STATE (enter chapter {chapter_number} as they LEFT chapter {chapter_number_prev}): + Character sheets show the FINAL state of each character (end of book). + Do NOT use that final state for early chapters. + + Use sources in this priority order: + 1. RAG asset [character-state] -- the most accurate record of right now. + Record as "LIVE CHARACTER STATE:" and use it to override outline predictions. + 2. "PREVIOUS CHAPTER CHARACTER STATE:" block if present in this prompt. + 3. The character's established traits from outline up to chapter {chapter_number_prev}. + Ignore arc resolution or growth that happens in later chapters. + + LOCATION CONTINUITY CHECK (if [character-state] is present): + Does this chapter's outline place any character at a location inconsistent + with their Location field in [character-state]? + If conflict found -- FLAG before drafting: + "LOCATION CONFLICT: [char] is at [state-location] per last chapter but outline + places them at [outline-location]. Resolve: (a) open chapter in transit, + (b) adjust scene to actual location, or (c) write a time-skip bridge paragraph. + Do NOT silently teleport the character." + + Also note Active obligations, Open loops, or Known secrets from [character-state] + that should be honored or advanced in this chapter. + + Also check RAG for [world-state] -- current NPC attitudes and faction memory. + If present, record as "LIVE WORLD STATE:". NPCs listed there should behave + according to their recorded attitude. + + STEP 3 -- FIND THE PREVIOUS CHAPTER: + Look at PROJECT DELIVERABLES for the chapter before this one + (filename: chapter-{chapter_ref_prev} or similar). + If no previous chapter exists (this IS Chapter 1), skip to STEP 5. + + STEP 4 -- QUOTE THE ENDING: + Copy the LAST 2-3 sentences of the previous chapter here, word for word. + Label them: "PREVIOUS CHAPTER ENDED WITH: ..." + Your new chapter MUST pick up from this exact moment. + + STEP 5 -- BUILD THE DRAFT PROMPT: + Write the exact drafting prompt for the next pass. That prompt must include: + - CHAPTER: Exact chapter number and title (from the task message) + - POV CHARACTER: Whose perspective are we in? + - FIRST LINE: The exact opening sentence, continuing from the previous ending + - EMOTIONAL ARC: What does the protagonist feel at start vs end OF THIS CHAPTER? + - CHAPTER GOAL: What plot event MUST happen here? + - KEY BEATS: 3-5 numbered scene beats that will form the chapter + - CLOSING HOOK: Exact last image or line that makes readers continue + - Reminders about continuity, prose style, and target length + - CHARACTER VOICE PROFILES (pre-extracted): + {character_profiles} + If this block is empty, fall back to searching PROJECT DELIVERABLES for a file + containing "## Voice Signatures" and copy it here. Use ONLY the voice/speech + patterns -- do NOT copy arc outcomes or end-state descriptions. + PASS 1 must write every character to their profile. + + EDITORIAL OVERRIDES -- apply these BEFORE writing any KEY BEATS: + {author_intent} + ^ If this line is not blank, it is a BINDING creative directive from the editor. + Include it verbatim in the draft prompt as: "AUTHOR'S INTENT: [text]" + PASS 1 must satisfy this intent completely. + {closing_hook} + ^ If this line is not blank, use it as the CLOSING HOOK instead of any outline hook. + Include it verbatim in the draft prompt as: "LOCKED CLOSING HOOK: [text]" + + Stop here. Output ONLY the draft prompt. Do NOT write chapter prose yet. + + - type: think + model: power + max_tokens: 32000 + hint: | + PASS 1 -- WRITE THE DRAFT + + Use the draft prompt below as your exact writing brief: + + {steps[0].text} + + Requirements: + - Start with the FIRST LINE you planned -- make it continue naturally from the previous chapter + - If the draft prompt contains a line starting with "LOCKED PREVIOUS CHAPTER HOOK:", + your FIRST LINE MUST directly resolve that hook -- the reader expects the answer immediately + - If the draft prompt contains a line starting with "AUTHOR'S INTENT:", treat it as a + binding creative directive -- your draft must satisfy that intent in full + - Follow the KEY BEATS in order, but write with full scene depth -- don't skip + - All character names must be consistent with the bible/outline + - Every dialogue exchange must be tight and voice-distinct + - Show, don't tell -- externalize emotion through action, detail, and dialogue + - Every scene beat moves the story forward OR reveals character (no filler) + - End with the CLOSING HOOK you planned + - Match the prose style guide: {prose_style} + - Target length: {chapter_target_words} words -- write the FULL chapter, not a summary + - ?? DO NOT stop early. If you have not reached {chapter_target_words} words, continue + writing -- add interiority, sensory detail, extended dialogue beats, and scene transitions + until you hit the target. Short chapters will be REJECTED in adjudication. + + DRAFTING DISCIPLINE -- apply these on every page: + - {prose_style} is a hard constraint, not decoration + - Not every paragraph needs a memorable or quotable line -- use functional connective prose + - Let observation precede interpretation: show the moment before naming what it means + - Avoid clustering aphorisms or thesis-style sentences back to back + - Prefer scene motion over thesis delivery -- action and dialogue carry meaning + - Write ONE complete draft now. Do NOT self-polish. Reviewers will give feedback downstream. + + VOICE ANTI-PATTERNS -- THESE ARE FORBIDDEN ON EVERY PAGE: + - Do NOT open any chapter with the "didn't just X; it Y" sentence construction. + Every chapter must have a structurally distinct opener. Vary: in medias res, + quiet beat, dialogue cold open, environmental sweep, interiority. + No two consecutive chapters may use the same opener structure. + - The book's thematic contrast (whatever it is -- body/mind, memory/possibility, etc.) + may appear ONCE per scene as a metaphor. Not in every paragraph. Trust the reader. + If you have used the contrast in the last two paragraphs, you may not use it again + for at least three more paragraphs. + - Do NOT label an emotion that you have already shown through action or dialogue. + If the character's hands are shaking, do not also write "she was afraid." + If the dialogue already conveys anger, do not add "his voice was furious." + - Do NOT count or reference chapter numbers in the prose. + "Five chapters of..." is an AI fingerprint. Never. + - Each character must have at least ONE verbal imperfection per scene they appear in: + a sentence they don't finish, a word they use wrong, a line that doesn't land, + a moment of fumbling before the right words come. Perfect dialogue is dead dialogue. + - Check the CHARACTER VOICE PROFILE in the outline/bible (if present) -- if each + speaking character's dialogue cannot be identified as THEIRS without a speaker tag, + rewrite until it can. Verbal tics, pet phrases, and characteristic patterns are + non-negotiable signatures. + + Output ONLY the draft chapter text. + Start directly with the chapter title (e.g., "Chapter N: [Title]") and opening line. + No commentary, no plan headers, no "Pass 1" label. + + - type: think + model: power + max_tokens: 32000 + hint: | + SELF-CHECK -- STRUCTURAL VALIDATION AND WORD-COUNT EXPANSION + + You have just written a chapter draft. Your job: check the draft against the structural + checklist below, apply all corrections within scope (including word-count expansion if + the draft is short), and output the final chapter. + + DRAFT TO CHECK: + {steps[1].text} + + CHECKLIST -- check each item, note any issue found: + 1. BEAT & HOOK: Does the chapter reach its intended emotional beat and closing hook + from the PASS 0 draft prompt? Flag if the chapter ends without the planned hook. + 2. NAMES & POV: Are all character names and the POV consistent with the bible/outline? + Flag any name that doesn't match the project canon. + 3. CONTINUITY TERMS: Do world rules, place names, and timeline references match + project state? Flag any factual break. + 4. FORMATTING: Are there obvious section-break artifacts, duplicate headers, + or missing chapter title? Flag and fix. + 5. WORD FLOOR: Estimate draft word count: count paragraphs ? ~60 words/paragraph. + Target is {chapter_target_words} words. + BEFORE writing the VALIDATION LOG line, you MUST have your full word estimate. + - If the draft is MORE THAN 10% under target: EXPAND NOW (write SCENE A, B, C BEFORE validation log). + - If within 10% of target: PASS, output verbatim. + Do NOT write 'EXPANDED' in the log if you did not write actual new scenes. + 6. OPENING HOOK: Check the PASS 0 draft prompt ({steps[0].text}) for a line labeled + "LOCKED PREVIOUS CHAPTER HOOK:". If present, verify the chapter's opening paragraph + directly resolves it. If not, add a brief resolution sentence at the opening -- + do not leave a locked hook unanswered. + 7. AUTHOR'S INTENT: Check the PASS 0 draft prompt ({steps[0].text}) for a line + starting with "AUTHOR'S INTENT:". If present, confirm the completed chapter + satisfies that intent -- note whether it was honored or partially missed. + 8. CLOSING HOOK LOCK: Check the PASS 0 draft prompt ({steps[0].text}) for a line + starting with "LOCKED CLOSING HOOK:". If present, verify the last paragraph of + the chapter uses that exact hook wording. If it's missing or paraphrased, add a + final paragraph that delivers the locked hook precisely. + + ALLOWED CORRECTIONS: + - Fix a wrong character name to match the canon name + - Fix a POV slip (e.g., the chapter is 1st-person but one paragraph shifted to 3rd) + - Fix a missing or duplicated chapter title/header + - If the chapter is missing its closing hook entirely, add it as a final paragraph + that matches the hook specified in the draft prompt -- no new invention beyond the + planned hook + - WORD COUNT EXPANSION (when draft is more than 10% below {chapter_target_words}): + IMPORTANT: Do NOT claim expansion in the VALIDATION LOG unless you have actually written it. + The WORD FLOOR line must show a word count you can verify by counting paragraphs. + Each paragraph ? 50-80 words. Count your paragraphs ? 60 to estimate total words. + Write NEW SCENES sequentially AFTER the chapter ends: + SCENE A: 400+ words -- interiority beat deepening the aftermath + SCENE B: 400+ words -- dialogue exchange with voice-distinct characters + SCENE C: 300+ words -- grounded transition showing the next 24 hours + Total added prose must reach the word target. Obey voice anti-patterns from PASS 1. + Do NOT add new plot beats not in PASS 0. Each new scene is an EXPANSION, not a new chapter. + + NOT ALLOWED -- do not make any of these changes: + - Improve existing sentences for prose quality, rhythm, or lyricism + - Reorder scenes or restructure the chapter + - Add new metaphors or aphorisms to existing prose + - Normalize or upgrade the authorial voice in existing sentences + + OUTPUT FORMAT: + Start your response with a VALIDATION LOG section: + VALIDATION LOG: + 1. BEAT & HOOK: [check pass/fail with brief note] + 2. NAMES & POV: [check pass/fail with brief note] + 3. CONTINUITY TERMS: [check pass/fail with brief note] + 4. FORMATTING: [check pass/fail -- note any fixes applied] + 5. WORD FLOOR: [PASS/EXPANDED -- include word count before and after] + 6. OPENING HOOK: [check pass/fail or N/A] + 7. AUTHOR'S INTENT: [honored / partially missed -- note / N/A if no intent set] + 8. CLOSING HOOK LOCK: [locked hook delivered / missing / N/A if not locked] + + Then output the separator on its own line: + ---BEGIN CHAPTER--- + + Then output the COMPLETE final chapter text (all original prose + any expansion). + Start the chapter directly with the chapter title and first line. + No preamble or commentary within the chapter text. + + # Commit chapter draft now -- last_text() = self-check output (step 2). Must come before + # PASS 3 think so the character-state extraction does not overwrite last_text(). + - type: document + filename: "Chapter_{chapter_number}_draft" + primary_deliverable: true + strip_before_marker: "---BEGIN CHAPTER---" + + - type: think + system: | + EXTRACTION MODE -- DO NOT CREATE FICTION. + Your ONLY task is to extract factual state from the chapter you just wrote. + You are NOT writing the story. You are NOT continuing the narrative. + Characters who are DEAD are DEAD. You may NOT invent a living version of them. + A character is DECEASED only if they are explicitly killed in the PASS 1 prose of THIS chapter. + DO NOT preemptively mark characters DECEASED based on project outline future events. + If the outline says a character dies in Chapter 9 but you are writing Chapter 4 and they survive in your prose, they are ALIVE in this chapter's state. + hint: | + PASS 3 -- CHARACTER + WORLD STATE EXTRACTION + + ?? STEP 0: FIND THE CORRECT CHAPTER TEXT (DO THIS FIRST) ?? + This conversation has multiple text sources. You must extract from the RIGHT one. + + YOUR CONVERSATION HISTORY (in order): + Turn 1 -> You received PASS 0 context (deliverables, outline, bible). + Deliverables include files like [Chapter_1_draft.md], [Chapter_3_draft.md], + [Chapter_10_draft.md], etc. THESE ARE HISTORICAL. NOT the current chapter. + Turn 2 -> You wrote Chapter {chapter_number} in PASS 1 (~4000-word narrative prose). + THIS IS THE CHAPTER YOU ARE ANALYZING. + Turn 3 -> You performed SELF-CHECK (editorial notes, not chapter prose). + Turn 4 -> THIS MESSAGE (PASS 3 extract). + + THE CHAPTER = YOUR PASS 1 RESPONSE (Turn 2). It starts immediately after the line + "PASS 1 -- WRITE THE DRAFT" and ends before the SELF-CHECK. + + ? ANCHOR TEST -- before writing any Location field, ask yourself: + "Did I write this location in my PASS 1 narrative, or is it from a deliverable file?" + If it is from any [Chapter_N_draft.md] or from the PRE-PASS-1 context -- REJECT IT. + Use ONLY what your PASS 1 narrative says. + + ?? MANDATORY CHECK -- DECEASED CHARACTERS ?? + Before writing ANY character entry, classify every named character into ONE bucket: + + BUCKET A -- DIES IN THIS CHAPTER: Character appears alive in PASS 1, then dies within + THIS chapter's narrative (death scene described in PASS 1 prose). + -> Use DECEASED FORMAT. Death chapter = {chapter_ref} (NOT any prior chapter). + -> Write a NEW ESTABLISHED sentence from how they died in PASS 1. + -> NEVER copy the chapter number or cause from a prior deliverable. + + BUCKET B -- ALIVE THROUGHOUT: Character appears in PASS 1 and is still alive at the end. + -> Use LIVING FORMAT. + -> Prior deliverables showing them DECEASED are OVERRIDDEN by the prose. + -> The prose you wrote is THE authoritative source. No exceptions. + + BUCKET C -- ABSENT (not in PASS 1 prose at all): Character does not appear. + -> Check PASS 0 for last known state. + -> If DECEASED in prior state: copy their entry forward UNCHANGED (same chapter). + -> If ALIVE in prior state: omit them (no update needed for off-screen characters). + + RULE: NEVER use a prior deliverable's death-chapter for BUCKET A characters. + NEVER mark a BUCKET B character as DECEASED. + NEVER give a BUCKET C / deceased character a living Location or Emotional field. + ?? DECEASED FORMAT(two lines only) ?? + ## [Name] -- DECEASED (Ch[N]) + Established: [one sentence: how they died] + Legacy: [one sentence: how their death affected this chapter] + + ?? LIVING CHARACTER FORMAT ?? + + # Character State: {chapter_ref} + + ## [Character Name] + Location: [specific location -- building, floor, city, planet] + Physical: [injuries, fatigue, notable physical state, or "no injuries"] + Emotional: [dominant emotion at chapter end] + Active obligations: [format: "owes [person] [what] (Ch[N]) -- UNPAID/PAID"] + Open loops: [format: "[parties] [issue] (Ch[N]) -- UNRESOLVED/RESOLVED"] + Known secrets: [format: "knows [what] -- [who does NOT know]"] + Arc: [XX%] -- [one sentence: what permanently changed this chapter] + Permanent: [YES/NO] + + (Repeat for EVERY named character who appeared. Deceased = short form only.) + + # World State: {chapter_ref} + + ## NPC Memory + - [NPC Name] ([faction/location]): [ATTITUDE] -- [what happened] -- [consequence] + + ## Faction Attitudes + - [Faction name]: [attitude] -- [reason] + + ## Active World Events + - [Event]: [status and timeline] + + ?? SECRET CARRY-FORWARD RULE ?? + Before submitting, check the PASS 0 context for any "Known secrets:" fields or + "CARRIED SECRET" markers from the PREVIOUS character-state file. + ? FUTURE-CHAPTER CONTAMINATION GUARD: ONLY carry secrets from character-state files + whose filename indicates a chapter EARLIER than {chapter_ref}. + Example: if writing ch-07, only use secrets from ch-06, ch-05, ch-04, etc. + NEVER copy a secret from character-state-ch-08 or later -- those are FUTURE events. + If a secret in PASS 0 context comes from a deliverable filename like + "character-state-ch-08" or "character-state-ch-09", IGNORE it entirely. + For each secret that was NOT resolved or revealed in THIS chapter's PASS 1 prose: + -> Copy it forward unchanged into the character's "Known secrets:" field. + -> Prefix it: "CARRIED (Ch[N]--unresolved): [secret]" + This ensures multi-chapter secrets are NOT silently dropped between chapters. + + ?? DEATH-FORWARD RULE ?? + Scan the PASS 1 prose for character death events (these are BUCKET A characters). + For each character who DIES in THIS chapter's prose: + -> Status: DECEASED ({chapter_ref}) -- always the CURRENT chapter, never a prior one + -> Established: [one sentence from PASS 1 describing HOW they died] + -> Legacy: [one sentence: how their death affects surviving characters this chapter] + -> Remove all Living Format fields (Location, Physical, Emotional, obligations, etc.) + For characters ALREADY deceased in prior state (BUCKET C, absent from prose): + -> Copy their entry forward UNCHANGED. Do NOT change the chapter number or cause. + EXCEPTION -- RETCON: If a character was DECEASED in prior state but appears ALIVE in + THIS chapter's PASS 1 prose (BUCKET B), use LIVING FORMAT. Prose overrides all. + + CRITICAL: Keep total output under 3500 characters. NO prose -- structured data only. + + - type: rag_write + asset_id: "character-state" + source_step: 4 # PASS 3 character-state extraction; explicit to avoid last_text() falling back to chapter text + max_chars: 4000 + + - type: document + filename: "character-state-{chapter_ref}" + + - type: package + source_step: 4 # PASS 3 -- character-state extraction (compact, describes permanent changes) + max_tokens: 4000 + hint: | + The draft chapter has been written, self-checked, and committed. + The character-state from PASS 3 is provided above. + + Summarize the character state changes for {chapter_ref} in the `chapter_state` field + (2-3 sentences max). This is used for bookkeeping -- the chapter text itself is passed + to reviewers directly. + + NEW CHARACTER DETECTION: + For each NEW character introduced this chapter (not previously known), emit one + create_task action using task_type: character_sheet. + + PERMANENT CHANGE DETECTION (butterfly effect): + For any character with "Permanent: YES" in the state, emit a create_task action + using task_type: character_update to record the change in the character sheet. + + Now confirm the chapter is ready for review. + schema: + chapter_state: string + spawn: + - task_type: chapter_review + task_name: "Review (Devon): {chapter_ref}" + agent_name: Devon + priority: 6 + _if: "not meta.is_locked" + context: + chapter_text: "{steps[1].text}" + review_focus: developmental + genre_name: "{genre_name}" + genre_audience: "{genre_audience}" + chapter_ref: "{chapter_ref}" + chapter_number: "{chapter_number}" + review_letter: "a" + character_profiles: "{character_profiles|}" + + - task_type: chapter_review + task_name: "Review (Lane): {chapter_ref}" + agent_name: Lane + priority: 6 + _if: "not meta.is_locked" + context: + chapter_text: "{steps[1].text}" + review_focus: line + genre_name: "{genre_name}" + genre_audience: "{genre_audience}" + chapter_ref: "{chapter_ref}" + chapter_number: "{chapter_number}" + review_letter: "b" + character_profiles: "{character_profiles|}" + + - task_type: chapter_review + task_name: "Review (Cora): {chapter_ref}" + agent_name: Cora + priority: 6 + _if: "not meta.is_locked" + context: + chapter_text: "{steps[1].text}" + review_focus: continuity + genre_name: "{genre_name}" + genre_audience: "{genre_audience}" + chapter_ref: "{chapter_ref}" + chapter_number: "{chapter_number}" + review_letter: "c" + character_profiles: "{character_profiles|}" + + - task_type: chapter_roundtable + task_name: "Roundtable: {chapter_ref}" + agents: + - Devon + - Lane + - Cora + priority: 7 + _if: "not meta.is_locked" + context: + chapter_text: "{steps[1].text}" + genre_name: "{genre_name}" + genre_audience: "{genre_audience}" + chapter_ref: "{chapter_ref}" + chapter_target_words: "{chapter_target_words}" + character_profiles: "{character_profiles|}" + depends_on: + - "Review (Devon): {chapter_ref}" + - "Review (Lane): {chapter_ref}" + - "Review (Cora): {chapter_ref}" + + - type: close + rag_update: true + +adjudication: + enabled: true + pass_threshold: 80 + deliverable_type: consumer + criteria: + word_count: + weight: 30 + description: "Chapter meets the {chapter_target_words}-word minimum; under-length chapters fail" + narrative_flow: + weight: 25 + description: "Story progresses naturally with good pacing" + character_voice: + weight: 20 + description: "Characters are distinct and consistent" + prose_quality: + weight: 15 + description: "Writing is clear and readable; voice is consistent with {prose_style}" + continuity: + weight: 10 + description: "Consistent with prior chapters and canon"