How nousresearch/autonovel works
1. What this repo is
- autonovel is a document-generation pipeline, not a traditional app server. It turns a seed concept into a full novel package: chapter markdown, revision history, typeset PDF/ePub, cover art, audiobook assets, and a landing page.
- The core architecture is a staged production line driven by Python scripts and a small set of shared markdown/YAML/JSON state files.
2. Primary control plane
- run_pipeline.py is the top-level orchestrator. It coordinates the phases described in README.md: foundation, drafting, automated revision, Opus review, and export.
- state.json is the main runtime tracker for pipeline progress and propagation debt across layers. It lets the system know which artifacts are stale and what needs regeneration.
3. Core knowledge layers
- The novel is modeled as co-evolving layers: voice.md, world.md, characters.md, outline.md, chapters/, with canon.md as the cross-cutting source of truth.
- These files are the main boundary between “story design” and “written prose.” Changes in one layer are expected to ripple downstream into chapters and sometimes back upstream into lore.
4. Foundation subsystem
- seed.py, gen_world.py, gen_characters.py, gen_outline.py, gen_outline_part2.py, gen_canon.py, and voice_fingerprint.py form the prewriting stack.
- Their job is to transform a seed into a consistent world bible, cast list, chapter outline, foreshadowing ledger, hard facts database, and discovered voice constraints.
- This phase loops until the foundation score is good enough, so the output is not a single artifact but a stabilized set of interdependent references.
5. Drafting subsystem
- draft_chapter.py writes one chapter at a time, and run_drafts.py batches the sequential generation flow.
- Drafting consumes the foundation files and emits chapter markdown files under chapters/, typically one file per chapter.
- program.md, CRAFT.md, ANTI-SLOP.md, and ANTI-PATTERNS.md act as operating constraints for the writing agents: craft guidance plus style/structure guardrails.
6. Evaluation subsystem
- evaluate.py combines mechanical checks and LLM-based judging. The repo explicitly treats this as two “immune systems”: one non-LLM, one model-based.
- compare_chapters.py runs comparative scoring between chapters, while reader_panel.py simulates multiple reader personas for manuscript-level feedback.
- These tools decide whether content is acceptable, needs revision, or should be discarded/retried.
7. Revision loop
- adversarial_edit.py generates “cut 500 words” style critique and classifies deletions; apply_cuts.py applies those changes in batch.
- gen_brief.py converts feedback into actionable revision briefs, and gen_revision.py rewrites a chapter from a brief.
- review.py implements the higher-level Opus review loop described in the README, including stop conditions for when the major issues have been exhausted.
8. Feedback propagation and rebuilding
- build_outline.py and build_arc_summary.py regenerate higher-level summaries from the chapter set, which is important after merges, cuts, or major revisions.
- This repo is not purely top-down; completed chapters can force outline/canon updates. That bidirectional propagation is part of the architecture.
9. Art and cover generation
- gen_art.py, gen_art_directions.py, gen_cover_composite.py, and gen_cover_print.py form the visual production pipeline.
- gen_art.py appears to handle style generation, curation, ornament creation, and vectorization; gen_cover_print.py targets print-ready wraparound specs.
- External image generation is driven through fal.ai per the README, making visual generation an optional but distinct subsystem.
10. Audiobook subsystem
- gen_audiobook_script.py parses chapter prose into speaker-attributed segments, and gen_audiobook.py renders multi-voice audio.
- audiobook_voices.json is the mapping layer between characters and specific voice choices, and voice.md influences the speech style boundary.
- This is a separate export path from print/ePub, with its own intermediate script representation.
11. Typesetting and publishing outputs
- The typeset/ directory is a self-contained publication layer: typeset/build_tex.py turns chapter content into LaTeX using typeset/novel.tex and supporting metadata/front matter.
- The repo also includes ePub assets (epub_metadata.yaml, epub_style.css, epub_front_matter.md, etc.), so the final output is multi-format publishing rather than a single manuscript file.
- This layer is where the novel transitions from editable markdown into distribution-ready artifacts.
12. Landing page and presentation
- landing/index.html is a static promotional surface for the finished novel.
- It sits beside the export pipeline, not the writing pipeline, and is likely populated from final art/book metadata rather than live application state.
13. Repository boundaries and runtime
- The whole system is Python-based (pyproject.toml, uv.lock, .python-version) and is orchestrated via uv run python ....
- .env.example shows the main external service boundaries: Anthropic for writing/evaluation/review, fal.ai for art, and ElevenLabs for narration.
- The scripts are file-oriented and batch-oriented, with markdown and JSON as the main interchange formats.
14. How to draw the architecture
- A good diagram would show a left-to-right flow: seed/foundation inputs → chapter drafting → evaluation/revision loops → manuscript rebuilds → export branches.
- From the export branch, split into print/ePub typesetting, art/cover generation, audiobook generation, and landing page publishing.
- The central shared state should be shown as the markdown knowledge base plus state.json, with canon.md as the consistency anchor across all phases.
Main entry points: chapters Chapters · run_pipeline.py Pipeline · build_tex.py Typeset · outline.md Outline
Components 20
Control Plane
Top-level orchestration and pipeline state.
Story Knowledge
Shared markdown and JSON sources of truth for the novel.
- Seed · Starting concept that feeds foundation generation.
seed.py - Voice · Narrative voice constraints and style boundary.
voice.md - World · Setting, rules, and world facts.
world.md - Cast · Character profiles and relationships.
characters.md - Outline · Narrative structure and chapter-level plan.
outline.md - Canon · Cross-cutting facts database used to keep story layers consistent.
canon.md
Foundation
Prewriting and canonicalization steps.
- Foundation · Seed-to-bible generation and stabilization loop.
Drafting
Chapter generation and batch drafting.
- Chapters · Generated chapter markdown files.
chapters - Drafting · Sequential chapter writing from the foundation layers.
Evaluation
Scoring, critique, and revision loops.
- Evaluate · Mechanical and model-based manuscript assessment.
evaluate.py - Review · Higher-level Opus review and stop-condition logic.
review.py - Briefs · Actionable feedback packets used to drive rewrites.
gen_brief.py - Revisions · Chapter-level rewrite and cut application tools.
gen_revision.py - Rebuild · Regenerates outline and arc summaries after manuscript changes.
Publishing
Typesetting, audio, art, and landing-page outputs.
- Typeset · Builds LaTeX and ePub publication artifacts.
typeset/build_tex.py - Art · Generates cover art, directions, and print composites.
gen_art.py - Audiobook · Creates narration scripts and multi-voice audio outputs.
gen_audiobook.py - Landing · Promotional page for the finished novel.
landing/index.html
Connections 32
- Pipeline → Foundation: orchestrates · Runs the staged production pipeline from end to end.
- Pipeline → Drafting: drives · Starts and sequences drafting after foundation is ready.
- Pipeline → Evaluate: checks · Invokes quality gates and scoring.
- Pipeline → Review: reviews · Triggers the higher-level revision loop.
- Pipeline → Typeset: exports · Pushes finalized manuscript into publication builds.
- State → Pipeline: tracks · Stores pipeline progress and regeneration needs.
- Seed → Foundation: inputs · Starting concept for world, characters, and outline generation.
- Foundation → Voice: refines · Discovers and constrains narrative voice.
- Foundation → World: builds · Creates the world bible.
- Foundation → Cast: builds · Creates the cast and relationships.
- Foundation → Outline: builds · Creates chapter structure and foreshadowing plan.
- Foundation → Canon: anchors · Consolidates hard facts and cross-layer consistency.
- Voice → Drafting: guides · Shapes prose style during chapter generation.
- World → Drafting: guides · Provides setting and lore constraints.
- Cast → Drafting: guides · Provides character continuity for scenes and dialogue.
- Outline → Drafting: orders · Defines chapter sequence and beats.
- Canon → Drafting: constrains · Keeps prose aligned to established facts.
- Drafting → Chapters: writes · Emits chapter markdown files.
- Chapters → Evaluate: scores · Manuscript content is checked and judged.
- Evaluate → Briefs: distills · Turns feedback into actionable revision briefs.
- Briefs → Revisions: drives · Used to rewrite or cut chapter content.
- Revisions → Chapters: updates · Applies revised chapter text back into the manuscript.
- Chapters → Review: inspects · Feeds the higher-level Opus review loop.
- Review → Revisions: requests · Issues major revision work when needed.
- Chapters → Rebuild: rebuilds · Chapter changes force summary regeneration.
- Rebuild → Outline: refreshes · Rebuilds the outline from the manuscript state.
- Rebuild → Canon: refreshes · Propagates chapter-level facts back into canon.
- Chapters → Typeset: publishes · Source manuscript for print and ePub output.
- Chapters → Audiobook: voices · Chapter prose is converted into narration scripts.
- Chapters → Art: inspires · Story and metadata inform visual generation.
- Art → Typeset: packages · Cover and art assets feed publication outputs.
- Typeset → Landing: supports · Publication metadata and visuals populate the landing page.