135 lines
4.8 KiB
YAML
135 lines
4.8 KiB
YAML
name: chapter_production
|
|
description: "CLP self-driving chapter dispatch -- checks project pipeline status and spawns the next unwritten chapter."
|
|
debug: true
|
|
model: power
|
|
system: agent_prompt
|
|
agent_prompt:
|
|
- "= identity.md"
|
|
sections:
|
|
- agent
|
|
- project
|
|
- deliverables
|
|
- rag
|
|
- message
|
|
- instructions
|
|
steps:
|
|
- type: tool
|
|
action: git_read_file
|
|
optional: true
|
|
output_key: book_outline_text
|
|
params:
|
|
path: "outline.md"
|
|
|
|
- type: think
|
|
max_tokens: 2000
|
|
output_key: next_chapter_decision
|
|
hint: |
|
|
You are {agent.name}, production manager for {project.name}.
|
|
|
|
Review the DELIVERABLES section above.
|
|
|
|
STEP 1 -- Count fully polished chapters (sequential):
|
|
Look for files matching: staging/polished/chapter-ch-XX.md
|
|
Walk the sequence from ch-01 upward. Count how many consecutive chapters
|
|
have a polished file. STOP counting at the first gap -- a missing polished
|
|
file breaks the sequence even if later chapters are polished.
|
|
Example: ch-01, ch-02, ch-03 exist but ch-04 missing -> sequential polished = 3
|
|
even if ch-05 polished file also exists.
|
|
|
|
STEP 2 -- Identify the next chapter needed:
|
|
NEXT_CHAPTER = the first chapter in the sequence that does NOT have a polished file.
|
|
This is always sequential_polished_count + 1.
|
|
Example: ch-01 through ch-05 polished, ch-06 missing -> NEXT_CHAPTER = ch-06
|
|
Even if ch-07 is already polished, ch-06 must be completed first.
|
|
|
|
STEP 3 -- Check if NEXT_CHAPTER is already in the pipeline:
|
|
Look in DELIVERABLES for any staging evidence for NEXT_CHAPTER:
|
|
- A draft file (e.g. Chapter_6_draft.md or Chapter_06_draft.md)
|
|
- Any review files (e.g. Chapter_6_review_a.md)
|
|
If staging evidence exists for NEXT_CHAPTER: it is ALREADY_IN_PIPELINE.
|
|
If no staging evidence at all: it is NEEDS_DRAFT.
|
|
|
|
STEP 4 -- Determine STATUS:
|
|
Check the BOOK OUTLINE for total chapter count (TOTAL_CHAPTERS).
|
|
If sequential_polished_count >= TOTAL_CHAPTERS: STATUS = COMPLETE
|
|
Otherwise: STATUS = NEEDS_CHAPTER
|
|
|
|
Output:
|
|
STATUS: NEEDS_CHAPTER or COMPLETE
|
|
NEXT_CHAPTER: ch-06 (or whichever, or N/A if COMPLETE)
|
|
CHAPTER_TITLE: <from outline if available>
|
|
SEQUENTIAL_POLISHED: <count of consecutive polished chapters from ch-01>
|
|
ALREADY_IN_PIPELINE: yes or no
|
|
PIPELINE_STAGE: draft-only / has-reviews / has-polish / none
|
|
|
|
- type: think
|
|
max_tokens: 100
|
|
output_key: production_status
|
|
hint: |
|
|
Read the STATUS line from the chapter production decision above.
|
|
Output EXACTLY one of these values, nothing else:
|
|
- NEEDS_CHAPTER
|
|
- COMPLETE
|
|
|
|
- type: think
|
|
max_tokens: 400
|
|
output_key: chapter_dispatch_message
|
|
hint: |
|
|
Read the next chapter decision above.
|
|
|
|
If STATUS is COMPLETE: output exactly: none
|
|
|
|
If STATUS is NEEDS_CHAPTER:
|
|
- If ALREADY_IN_PIPELINE is "yes": the chapter has a draft but is not polished.
|
|
Write a dispatch message instructing the author to pick up from the existing draft,
|
|
run the roundtable and polish sequence, and NOT re-draft from scratch.
|
|
Include: "Note: a draft already exists for this chapter in staging -- proceed directly
|
|
to chapter_roundtable using the existing draft. Do not re-write the draft."
|
|
- If ALREADY_IN_PIPELINE is "no": write a normal chapter dispatch message.
|
|
|
|
Always include:
|
|
- Book: {project.name} ({genre_name})
|
|
- Chapter to write: the NEXT_CHAPTER value from the decision
|
|
- Chapter title: the CHAPTER_TITLE value
|
|
- Characters: {character_profiles}
|
|
- Word count target: {chapter_target_words} words
|
|
- Instruction: check the most recent polished chapter for continuity,
|
|
then write this chapter following the outline
|
|
|
|
Output ONLY the dispatch message. No preamble.
|
|
|
|
# Dispatch the next chapter if NEEDS_CHAPTER
|
|
- type: tool
|
|
action: enqueue_strategy
|
|
optional: true
|
|
params:
|
|
company_slug: "crimson_leaf_publishing"
|
|
project_slug: "{project.slug}"
|
|
task_type: "book_chapter"
|
|
content: "{chapter_dispatch_message}"
|
|
|
|
# If COMPLETE, dispatch project_index to compile the manuscript and signal book done
|
|
- type: think
|
|
max_tokens: 50
|
|
output_key: index_dispatch_message
|
|
hint: |
|
|
Read production_status above.
|
|
If production_status is COMPLETE, output exactly:
|
|
Compile the manuscript index for {project.name}. All chapters are polished and complete.
|
|
If production_status is NEEDS_CHAPTER, output exactly: none
|
|
|
|
- type: tool
|
|
action: enqueue_strategy
|
|
optional: true
|
|
params:
|
|
company_slug: "crimson_leaf_publishing"
|
|
project_slug: "{project.slug}"
|
|
task_type: "project_index"
|
|
content: "{index_dispatch_message}"
|
|
|
|
- type: reply
|
|
target: channel
|
|
channel_name: "crimson_leaf_publishing:live-feed"
|
|
|
|
adjudication:
|
|
enabled: false |