Auto-commit: v2.7 Series Continuity & Book Number Awareness

- story/planner.py: enrich() and plan_structure() now extract series_metadata
  and inject a SERIES_CONTEXT block (Book X of Y in series Z, with position-aware
  guidance) into prompts when is_series is true.
- story/writer.py: write_chapter() builds and injects the same SERIES_CONTEXT
  into the chapter draft prompt; passes series_context to evaluate_chapter_quality().
- story/editor.py: evaluate_chapter_quality() accepts optional series_context
  parameter and injects it into METADATA so arc pacing is evaluated relative to
  the book's position in the series.
- ai_blueprint.md: Section 11 marked complete (v2.7), summary updated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 01:51:35 -05:00
parent 83a6a4315b
commit d75186cb29
4 changed files with 56 additions and 7 deletions

View File

@@ -12,13 +12,26 @@ def enrich(bp, folder, context=""):
if 'characters' not in bp: bp['characters'] = []
if 'plot_beats' not in bp: bp['plot_beats'] = []
series_meta = bp.get('series_metadata', {})
series_block = ""
if series_meta.get('is_series'):
series_title = series_meta.get('series_title', 'this series')
book_num = series_meta.get('book_number', '?')
total_books = series_meta.get('total_books', '?')
series_block = (
f"\n - SERIES_CONTEXT: This is Book {book_num} of {total_books} in the '{series_title}' series. "
f"Pace character arcs and plot resolution accordingly. "
f"Book {book_num} of {total_books} should reflect its position: "
f"{'establish the world and core characters' if str(book_num) == '1' else 'escalate stakes and deepen arcs' if str(book_num) != str(total_books) else 'resolve all major threads with a satisfying conclusion'}."
)
prompt = f"""
ROLE: Creative Director
TASK: Create a comprehensive Book Bible from the user description.
INPUT DATA:
- USER_DESCRIPTION: "{bp.get('manual_instruction', 'A generic story')}"
- CONTEXT (Sequel): {context}
- CONTEXT (Sequel): {context}{series_block}
STEPS:
1. Generate a catchy Title.
@@ -96,6 +109,18 @@ def plan_structure(bp, folder):
target_words = bp.get('length_settings', {}).get('words', 'flexible')
chars_summary = [{"name": c.get("name"), "role": c.get("role")} for c in bp.get('characters', [])]
series_meta = bp.get('series_metadata', {})
series_block = ""
if series_meta.get('is_series'):
series_title = series_meta.get('series_title', 'this series')
book_num = series_meta.get('book_number', '?')
total_books = series_meta.get('total_books', '?')
series_block = (
f"\n - SERIES_CONTEXT: This is Book {book_num} of {total_books} in the '{series_title}' series. "
f"Structure the arc to fit its position in the series: "
f"{'introduce all major characters and the central conflict; leave threads open for future books' if str(book_num) == '1' else 'deepen existing character arcs and escalate the overarching conflict; do not resolve the series-level stakes' if str(book_num) != str(total_books) else 'resolve all series-level threads; provide a satisfying conclusion for every major character arc'}."
)
prompt = f"""
ROLE: Story Architect
TASK: Create a detailed structural event outline for a {target_chapters}-chapter book.
@@ -105,7 +130,7 @@ def plan_structure(bp, folder):
- GENRE: {bp.get('book_metadata', {}).get('genre', 'Fiction')}
- TARGET_CHAPTERS: {target_chapters}
- TARGET_WORDS: {target_words}
- STRUCTURE: {structure_type}
- STRUCTURE: {structure_type}{series_block}
CHARACTERS: {json.dumps(chars_summary)}