name: book_chapter description: "Write one chapter — continuity check, draft, self-check, then spawn editorial review." debug: true 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 GENRE GUIDE: Your skills section contains exactly the guide for {genre_name}. Apply it fully. CONTINUITY GUARDRAILS: - Use ONLY the outline / character bible and the immediately previous chapter for continuity. - Ignore future chapters, editorial reviews, roundtables, polish drafts, and any non-chapter artifacts. - Never pull facts from a deliverable whose filename indicates a later chapter than {chapter_ref}. ⚠️ CRITICAL: Your task name tells you EXACTLY which chapter to write. Look at the CURRENT MESSAGE — write THAT chapter and ONLY that chapter. Do NOT write Chapter 1 unless the message explicitly says "Chapter 1". STEP 1 — READ THE OUTLINE / CHARACTER BIBLE: Look at PROJECT DELIVERABLES for the outline file (it contains the Character Bible if this is a fiction project, and the Chapter Outline for all projects). 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 (if paranormal or speculative) - This chapter's summary, emotional beat, and closing hook from the outline 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 — FIND THE PREVIOUS CHAPTER: Look at PROJECT DELIVERABLES for the chapter that comes BEFORE this one. If no previous chapter exists (this IS Chapter 1), skip to STEP 4. STEP 3 — 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 4 — 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? - 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 STEP 5 — PREVIOUS CHAPTER CHARACTER STATE (if available): If context contains a block starting with "PREVIOUS CHAPTER CHARACTER STATE:", include it verbatim in the prompt under the heading: "CHARACTER CONTINUITY: The previous chapter ended with these character states: {prev_character_state}" These states override any outline prediction that conflicts with them — the character is ALREADY in this emotional/physical state at the start of this chapter. If no character state was provided, skip this block entirely. Stop here. Output ONLY the draft prompt. Do NOT write chapter prose yet. - type: think model: power 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. 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 hint: | SELF-CHECK — STRUCTURAL VALIDATION ONLY You have just written a chapter draft. Your job here is narrow: check the draft against the structural checklist below, apply ONLY the corrections that fall within scope, 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: Is the draft within 10% of {chapter_target_words}? Flag only if critically short (more than 20% under target) — do not expand for style. 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. 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 NOT ALLOWED — do not make any of these changes: - Improve any sentence for prose quality, rhythm, or lyricism - Deepen emotional beats or add interiority - Expand any description or add sensory detail - Reorder scenes or restructure the chapter - Add new metaphors, aphorisms, or quotable lines - Normalize or upgrade the authorial voice 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: [check pass/fail — include word count] 6. OPENING HOOK: [check pass/fail or N/A] 7. AUTHOR'S INTENT: [honored / partially missed — note / N/A if no intent set] Then output the separator on its own line: ---BEGIN CHAPTER--- Then output the final chapter text (corrected where structurally required, verbatim everywhere else). Start the chapter directly with the chapter title and first line. No preamble or commentary within the chapter text. - type: document filename: "Chapter_{chapter_number}_draft" - type: package hint: | The draft chapter has been written, self-checked, and committed. CRITICAL — include the `chapter_text` field: Copy the COMPLETE chapter text from the self-check output (step 2 — the final chapter draft) into the `chapter_text` field. Reviewers have NO other way to access the chapter content. Do NOT summarize or truncate it — include every word of the chapter. Now spawn the three independent editorial reviewers and the roundtable debate. Use the exact task_names shown — the roundtable depends_on all three. schema: chapter_text: 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: "{chapter_text}" review_focus: developmental genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" chapter_number: "{chapter_number}" review_letter: "a" - task_type: chapter_review task_name: "Review (Lane): {chapter_ref}" agent_name: Lane priority: 6 _if: "not meta.is_locked" context: chapter_text: "{chapter_text}" review_focus: line genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" chapter_number: "{chapter_number}" review_letter: "b" - task_type: chapter_review task_name: "Review (Cora): {chapter_ref}" agent_name: Cora priority: 6 _if: "not meta.is_locked" context: chapter_text: "{chapter_text}" review_focus: continuity genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" chapter_number: "{chapter_number}" review_letter: "c" - task_type: chapter_roundtable task_name: "Roundtable: {chapter_ref}" agents: - Devon - Lane - Cora priority: 7 _if: "not meta.is_locked" context: chapter_text: "{chapter_text}" genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" chapter_target_words: "{chapter_target_words}" 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"