feat: Implement ai_blueprint.md Steps 1 & 2 — bible-tracking merge and character voice profiles
Step 1 (Bible-Tracking Merge):
- Added merge_tracking_to_bible() to story/bible_tracker.py — merges character
tracking state and lore back into bible dict after each chapter, making
blueprint_initial.json the single persistent source of truth.
- Integrated in cli/engine.py after each chapter's update_tracking + update_lore_index
calls so the persisted bible is always up-to-date.
Step 2 (Character-Specific Voice Profiles):
- story/writer.py: write_chapter now checks bp['characters'] for a voice_profile on
the POV character before falling back to the prebuilt_persona cache.
- story/style_persona.py: refine_persona() accepts pov_character=None; when a POV
character with a voice_profile is supplied it refines that profile's bio instead of
the global author_details bio.
- cli/engine.py: refine_persona call now passes ch.get('pov_character') so per-chapter
persona refinement targets the correct voice.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -219,7 +219,8 @@ def process_book(bp, folder, context="", resume=False, interactive=False):
|
||||
|
||||
# Refine Persona to match the actual output (every 5 chapters)
|
||||
if (i == 0 or i % 5 == 0) and txt:
|
||||
bp['book_metadata']['author_details'] = style_persona.refine_persona(bp, txt, folder)
|
||||
pov_char = ch.get('pov_character')
|
||||
bp['book_metadata']['author_details'] = style_persona.refine_persona(bp, txt, folder, pov_character=pov_char)
|
||||
with open(bp_path, "w") as f: json.dump(bp, f, indent=2)
|
||||
cached_persona = build_persona_info(bp) # Rebuild cache with updated bio
|
||||
|
||||
@@ -275,6 +276,10 @@ def process_book(bp, folder, context="", resume=False, interactive=False):
|
||||
tracking['lore'] = bible_tracker.update_lore_index(folder, txt, tracking.get('lore', {}))
|
||||
with open(lore_track_path, "w") as f: json.dump(tracking['lore'], f, indent=2)
|
||||
|
||||
# Persist dynamic tracking changes back to the bible (Step 1: Bible-Tracking Merge)
|
||||
bp = bible_tracker.merge_tracking_to_bible(bp, tracking)
|
||||
with open(bp_path, "w") as f: json.dump(bp, f, indent=2)
|
||||
|
||||
# Update Structured Story State (Item 9: Thread Tracking)
|
||||
current_story_state = story_state.update_story_state(txt, ch['chapter_number'], current_story_state, folder)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user