name: book_editorial
description: "Editorial boardroom -- agents review the full manuscript, debate quality, and produce written editorial notes."
debug: true
rag_exclude: [business_plan, charter]
system: agent_prompt

agent_prompt:
  - "= identity.md"
  - "agent.rag.json"

participant_prompt:
  - "= identity.md"

sections:
  - agent
  - project
  - history
  - rag
  - deliverables
  - participants
  - participants_prompt
  - message
  - rejection_feedback
  - instructions

steps:
  - type: think
    rotate_participants: true
    loop:
      max_iterations: 3
    hint: |
      You are {agent.name}. This is the editorial review boardroom for the manuscript.

      TASK: Review all completed chapters (look in PROJECT DELIVERABLES -- files named
      "final-chapter-*.md"). Read them carefully as a professional editor would.

      For each round, discuss:
        1. CONTINUITY -- Does each chapter open by continuing the previous chapter's cliffhanger?
           Quote specific chapter-to-chapter handoffs that work well or need repair.
        2. CHARACTER VOICE -- Are POV voices distinct across chapters?
           Call out any chapters where the voice felt off.
        3. WATTPAD HOOKS -- Do chapters open with a strong hook that stops a teen scrolling?
           Which openings are weakest and need a rewrite?
        4. PACING -- Any chapters that drag or that rush past important emotional beats?
        5. CLIFFHANGERS -- Which chapter endings are strong? Which are weak or generic?
        6. SERIES HOOK -- Does the final chapter end in a way that makes readers desperate for the next book?

      Speak in your own professional voice. Debate. Challenge each other.
      When the editorial team has reached consensus on the manuscript's strengths and
      key revision priorities, include exactly: "consensus_reached: true"

  - type: think
    hint: |
      You are the lead editor synthesizing the boardroom transcript into formal editorial notes.

      Write a professional EDITORIAL REPORT for the manuscript covering:

      ## Editorial Report: {project.name}
      ### {project.company} | Lead Author: {project.lead_author}

      **OVERALL ASSESSMENT**
      (1-2 paragraphs on the manuscript's readiness for publication)

      **STRENGTHS** (specific, with chapter references)
      **REVISION PRIORITIES** (ranked 1-5, most critical first)
        - For each: what the issue is, which chapters are affected, suggested fix
      **CONTINUITY CHECK** (chapter-by-chapter handoff assessment)
      **CHARACTER VOICE CONSISTENCY** (POV analysis across chapters)
      **PUBLICATION READINESS SCORE** (out of 10, with reasoning)
      **RECOMMENDED NEXT STEPS** (in order of priority)

  - type: document
    filename: "{{task_name_slug}}"

  - type: package
    packet_type: IntakeResponse
    hint: |
      You are the Project Manager. The editorial report above lists REVISION PRIORITIES ranked 1-5.
      Convert each revision priority into a sequential create_task action for Iris.
      After all revision tasks, add ONE final task to compile the project index.

      Rules for revision tasks:
      - One action per revision priority (up to 5)
      - task_name format: "Revise: [short issue name]" (e.g., "Revise: POV Handoff Bridges")
      - agent_name: "Iris"
      - task_type: "book_chapter"
      - description: Include the specific issue, affected chapters, and suggested fix from the editorial report.
        Start with: "EDITORIAL REVISION -- [Priority N]: [issue]. Affected chapters: [chapters]. Fix: [fix]."
      - depends_on: the exact task_name of the PREVIOUS revision task (empty string for the first revision)

      Final task (always add this LAST):
      - task_name: "Compile Project Index"
      - agent_name: "Nova"
      - task_type: "project_index"
      - description: "Compile the final MANUSCRIPT-README.md index of all project deliverables, revisions, and publication status."
      - depends_on: the exact task_name of the LAST revision task

    schema:
      actions:
        - type: create_task
          task_name: "string"
          agent_name: "string"
          task_type: "string"
          description: "string"
          depends_on: "string"

  - type: close
    rag_update: true

adjudication:
  enabled: true
  pass_threshold: 65
  deliverable_type: coordination
  criteria:
    specificity:
      weight: 40
      description: "Feedback references specific issues, not vague"
    actionability:
      weight: 35
      description: "Suggestions are concrete and implementable"
    coverage:
      weight: 25
      description: "All major aspects of the work are addressed"
