name: book_chapter description: "Write one chapter — continuity check, draft, deepen, then spawn editorial review." debug: true system: agent_prompt requires: - genre_name - genre_audience - prose_style - chapter_target_words - chapter_ref agent_prompt: - "= identity.md" - "agent.rag.json" sections: - agent - project - history - rag - deliverables - message - rejection_feedback - instructions steps: - type: think hint: | PASS 0 — BIBLE & CONTINUITY CHECK (do this FIRST, before drafting) GENRE: {genre_name} | AUDIENCE: {genre_audience} PROSE STYLE GUIDE: {prose_style} TARGET CHAPTER LENGTH: ~{chapter_target_words} words ⚠️ 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 — PLAN YOUR CHAPTER: State your plan: - CHAPTER: Exact chapter number and title (from the task message) - POV CHARACTER: Whose perspective are we in? - FIRST LINE: How does this chapter begin, continuing from the previous ending? - EMOTIONAL ARC: What does the protagonist feel at start vs end? - CHAPTER GOAL: What plot event MUST happen here? - CLOSING HOOK: Exact last image or line that makes readers continue? Now write the full draft chapter following the prose style guide above. Be consistent with ALL character names and world rules from the bible. - type: think model: power hint: | PASS 2 — DEEPEN & SHARPEN Read your draft critically through an editor's eyes: - Does the first line continue naturally from the previous chapter's ending? - Does the opening hook land in the first two lines? - Are ALL character names consistent with the bible/outline? - Is every dialogue exchange tight and voice-distinct between characters? - Are there any "telling" moments that should be "showing"? - Does every scene beat move the story forward OR reveal character? - Is the closing hook specific and compelling, not generic? - Does the prose match the genre style guide above? - Is the chapter at the target length? ({chapter_target_words} words — write the full chapter) Rewrite the COMPLETE final chapter incorporating all improvements. Output ONLY the polished chapter text — no commentary, no "Pass 2" headings. Start directly with the chapter title and opening line. - type: document filename: "chapter-{chapter_ref}" - type: package hint: | The chapter has been written and committed. 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 context: chapter_text: "{chapter_text}" review_focus: developmental genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" - task_type: chapter_review task_name: "Review (Lane): {chapter_ref}" agent_name: Lane priority: 6 context: chapter_text: "{chapter_text}" review_focus: line genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" - task_type: chapter_review task_name: "Review (Cora): {chapter_ref}" agent_name: Cora priority: 6 context: chapter_text: "{chapter_text}" review_focus: continuity genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" - task_type: chapter_roundtable task_name: "Roundtable: {chapter_ref}" agents: - Devon - Lane - Cora priority: 7 context: chapter_text: "{chapter_text}" genre_name: "{genre_name}" genre_audience: "{genre_audience}" chapter_ref: "{chapter_ref}" 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: narrative_flow: weight: 30 description: "Story progresses naturally with good pacing" character_voice: weight: 25 description: "Characters are distinct and consistent" prose_quality: weight: 25 description: "Writing is polished and engaging" continuity: weight: 20 description: "Consistent with prior chapters and canon"