Fix chapter_production: use correct polished file pattern (staging/polished/chapter-ch-XX.md)

This commit is contained in:
2026-04-18 00:31:44 +00:00
parent ec6ef0acf4
commit 3a0f1253c7

View File

@@ -1,90 +1,98 @@
name: chapter_production name: chapter_production
description: "CLP self-driving chapter dispatch -- checks project pipeline status and spawns the next unwritten chapter." description: "CLP self-driving chapter dispatch -- checks project pipeline status and spawns the next unwritten chapter."
debug: true debug: true
model: power model: power
system: agent_prompt system: agent_prompt
agent_prompt:
agent_prompt: - "= identity.md"
- "= identity.md" sections:
- agent
sections: - project
- agent - deliverables
- project - rag
- deliverables - message
- rag - instructions
- message steps:
- instructions - type: tool
action: git_read_file
steps: optional: true
- type: tool output_key: book_outline_text
action: git_read_file params:
optional: true path: "outline.md"
output_key: book_outline_text
params: - type: think
path: "outline.md" max_tokens: 2000
output_key: next_chapter_decision
- type: think hint: |
max_tokens: 2000 You are {agent.name}, production manager for {project.name}.
output_key: next_chapter_decision
hint: | Review the DELIVERABLES section above.
You are {agent.name}, production manager for {project.name}.
STEP 1 -- Count completed (polished) chapters:
Review the DELIVERABLES section above. Count the final-chapter-*.md files. Look for files matching the pattern: staging/polished/chapter-ch-XX.md
These are the chapters that have been fully completed (written + polished + approved). Count how many such files exist (ch-01, ch-02, etc.)
These are the chapters that have been fully written AND polished.
Also check the BOOK OUTLINE if available above.
STEP 2 -- Count in-progress (drafted) chapters:
Determine which chapter needs to be written NEXT: Look for any staging files that suggest a chapter has been drafted but not polished.
- If no chapters exist: ch-01 Examples: review files, roundtable files, or draft files for a given chapter ref.
- If ch-01 exists but ch-02 does not: ch-02
- Continue this pattern up to the chapter_target_words limit STEP 3 -- Determine next chapter:
- If all chapters are complete: the book is DONE The next chapter to write is the first chapter that has NO draft files at all.
- If polished: ch-01 through ch-04 and draft evidence for ch-05: next is ch-06
Output: - If polished: ch-01 and draft evidence for ch-02: next is ch-03
STATUS: NEEDS_CHAPTER or COMPLETE - If nothing exists for any chapter: next is ch-01
NEXT_CHAPTER: ch-01 (or ch-02, etc., or N/A if COMPLETE)
CHAPTER_TITLE: <from outline if available, otherwise "Chapter N"> Also check the BOOK OUTLINE if available above for chapter titles and total count.
If all chapters exist in some form up to the outline limit: the book is DONE.
- type: think
max_tokens: 100 Output:
output_key: production_status STATUS: NEEDS_CHAPTER or COMPLETE
hint: | NEXT_CHAPTER: ch-01 (or ch-02, etc., or N/A if COMPLETE)
Read the STATUS line from the chapter production decision above. CHAPTER_TITLE: <from outline if available, otherwise "Chapter N">
Output EXACTLY one of these values, nothing else: POLISHED_COUNT: <number of staging/polished/chapter-ch-*.md files found>
- NEEDS_CHAPTER DRAFTED_COUNT: <number of chapters with any staging evidence>
- COMPLETE
- type: think
- type: think max_tokens: 100
max_tokens: 400 output_key: production_status
output_key: chapter_dispatch_message hint: |
hint: | Read the STATUS line from the chapter production decision above.
Read the next chapter decision above. Output EXACTLY one of these values, nothing else:
- NEEDS_CHAPTER
If STATUS is COMPLETE: output exactly: none - COMPLETE
If STATUS is NEEDS_CHAPTER, write a chapter dispatch message for Iris (lead author). - type: think
Include: max_tokens: 400
- Book: {project.name} ({genre_name}) output_key: chapter_dispatch_message
- Chapter to write: the NEXT_CHAPTER value from the decision hint: |
- Chapter title: the CHAPTER_TITLE value Read the next chapter decision above.
- Characters: {character_profiles}
- Word count target: {chapter_target_words} words If STATUS is COMPLETE: output exactly: none
- Instruction: check the most recent polished chapter for continuity,
then write this chapter following the outline If STATUS is NEEDS_CHAPTER, write a chapter dispatch message for Iris (lead author).
Include:
Output ONLY the dispatch message. No preamble. - Book: {project.name} ({genre_name})
- Chapter to write: the NEXT_CHAPTER value from the decision
- type: tool - Chapter title: the CHAPTER_TITLE value
action: enqueue_strategy - Characters: {character_profiles}
optional: true - Word count target: {chapter_target_words} words
params: - Instruction: check the most recent polished chapter for continuity,
company_slug: "crimson_leaf_publishing" then write this chapter following the outline
project_slug: "{project.slug}"
task_type: "book_chapter" Output ONLY the dispatch message. No preamble.
content: "{chapter_dispatch_message}"
- type: tool
- type: reply action: enqueue_strategy
target: discussion optional: true
params:
adjudication: company_slug: "crimson_leaf_publishing"
enabled: false project_slug: "{project.slug}"
task_type: "book_chapter"
content: "{chapter_dispatch_message}"
- type: reply
target: discussion
adjudication:
enabled: false