Skip to content

mrigankad/Novel-OS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Novel OS Mascot

A Production-Grade Multi-Agent Fiction Writing Framework

Write novels like a professional author β€” with an entire editorial team at your command.


Python License Status Agents Providers


╔══════════════════════════════════════════════════════════════════╗
β•‘                                                                  β•‘
β•‘   "The difference between an amateur and a professional          β•‘
β•‘    writer is a systematic process."                              β•‘
β•‘                                                                  β•‘
β•‘                              β€” Novel OS Philosophy               β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

🌟 What is Novel OS?

Novel OS is a complete editorial infrastructure for producing professional-quality novels using multiple specialized AI agents working in concert β€” with any LLM you choose (Claude, GPT, Gemini, Llama, Kimi, local models, anything OpenAI-compatible).

Traditional AI writing generates one response and forgets everything. Novel OS is different:

  • 🧠 Persistent memory β€” agent outputs are parsed and merged into a central state file. Characters, locations, plot threads, foreshadowing, and quality scores accumulate chapter by chapter.
  • 🀝 Agents collaborate β€” Architect β†’ Scribe β†’ Editor β†’ Guardian β†’ Curator, each handing off to the next with full context.
  • πŸ›‘οΈ Deterministic + LLM validation β€” a free local continuity engine catches dormant threads, unresolved foreshadowing, and timeline drift before the LLM Guardian runs.
  • πŸ”Œ Provider-agnostic β€” Anthropic, OpenAI, Azure, Gemini, NVIDIA NIM, Kimi, Groq, Together, OpenRouter, DeepSeek, Mistral, Fireworks, Ollama, LM Studio, or any OpenAI-compatible endpoint.

Think of it as hiring a full-time editorial team β€” story architect, prose craftsman, line editor, fact-checker, voice coach β€” all working on your novel around the clock, on infrastructure that actually remembers what happened in chapter 3.

Novel OS architecture β€” five agents around the StoryState brain


πŸ›οΈ Architecture

graph TB
    subgraph Agents["The Five Agents"]
        A["πŸ—οΈ Architect<br/>Planner"]
        B["✍️ Scribe<br/>Drafter"]
        E["πŸ” Editor<br/>Refiner"]
        G["πŸ›‘οΈ Guardian<br/>Validator"]
        S["🎨 Curator<br/>Voice"]
    end

    subgraph Memory["Persistent State"]
        SM["🧠 StoryState<br/>(JSON)"]
        SP["πŸ“₯ State Parser"]
        CE["πŸ”¬ Continuity Engine<br/>(deterministic)"]
    end

    subgraph LLM["Provider Layer"]
        LC["πŸ”Œ LLMClient<br/>(13+ providers)"]
    end

    A & B & E & G & S --> LC
    LC -.outputs.-> SP
    SP --> SM
    CE --> SM
    CE -.findings.-> G

    style A fill:#1e3a5f,stroke:#4a9eff,color:#fff
    style B fill:#1a4731,stroke:#4ade80,color:#fff
    style E fill:#3b1f5e,stroke:#a78bfa,color:#fff
    style G fill:#5e1f1f,stroke:#f87171,color:#fff
    style S fill:#4a1f4a,stroke:#e879f9,color:#fff
    style SM fill:#1f3a4f,stroke:#fbbf24,color:#fff
    style SP fill:#1f3a4f,stroke:#fbbf24,color:#fff
    style CE fill:#1f3a4f,stroke:#fbbf24,color:#fff
    style LC fill:#2a3441,stroke:#06b6d4,color:#fff
Loading

🎭 The Five Agents

# Agent Role Outputs
1 πŸ—οΈ Architect Story planner β€” designs 3-act structure, character arcs, beats outline.json, expanded chapter_NNN_outline.md
2 ✍️ Scribe Prose drafter β€” writes the chapter in deep POV chapter_NNN_draft.md + [SCRIBE_STATE_UPDATE] block
3 πŸ” Editor Line surgeon β€” 5 modes: line / developmental / pacing / dialogue / tension chapter_NNN_revised.md + [EDITOR_STATE_UPDATE] with before/after scores
4 πŸ›‘οΈ Guardian Forensic fact-checker β€” character, timeline, world, plot continuity chapter_NNN_continuity_report.md with Status: PASS/WARNING/FAIL
5 🎨 Curator Voice stylist β€” locks tone, prose rhythm, genre conventions [STYLE_STATE_UPDATE] with consistency / genre / voice scores

Every agent prompt now includes a strict OUTPUT CONTRACT that forces the LLM to emit machine-parseable update blocks β€” verified working with frontier models (Claude, GPT) and open-weight models (Llama 3.3 70B).


πŸ”„ The Chapter Workflow

flowchart LR
    P["πŸ—οΈ PLAN<br/>Architect"] --> D["✍️ DRAFT<br/>Scribe"]
    D --> Px1["πŸ“₯ Parse +<br/>persist"]
    Px1 --> Ed["πŸ” EDIT<br/>Editor"]
    Ed --> Px2["πŸ“₯ Parse +<br/>persist"]
    Px2 --> CE["πŸ”¬ PRE-CHECK<br/>Continuity Engine"]
    CE --> V["πŸ›‘οΈ VALIDATE<br/>Guardian"]
    V --> Px3["πŸ“₯ Parse +<br/>persist"]
    Px3 --> Ap["βœ… APPROVE<br/>(gates FAIL)"]
    Ap -->|"Next β†Ί"| P

    style P fill:#1e3a5f,stroke:#4a9eff,color:#fff
    style D fill:#1a4731,stroke:#4ade80,color:#fff
    style Ed fill:#3b1f5e,stroke:#a78bfa,color:#fff
    style CE fill:#1f3a4f,stroke:#fbbf24,color:#fff
    style V fill:#5e1f1f,stroke:#f87171,color:#fff
    style Ap fill:#1a4731,stroke:#22c55e,color:#fff
    style Px1 fill:#2a3441,stroke:#06b6d4,color:#fff
    style Px2 fill:#2a3441,stroke:#06b6d4,color:#fff
    style Px3 fill:#2a3441,stroke:#06b6d4,color:#fff
Loading

Quality gates β€” a chapter cannot be approved while Status: FAIL is on file. Resolve the issue and re-validate.

Chapter pipeline β€” six stations feeding StoryState


🧠 Persistent Memory β€” How State Actually Lives

The defining feature: every agent's structured output is parsed and merged into a central JSON state, so subsequent agents see what came before.

sequenceDiagram
    participant U as You
    participant O as Orchestrator
    participant L as LLMClient
    participant P as State Parser
    participant S as StoryState (JSON)

    U->>O: write --chapter 1
    O->>L: Scribe prompt + context from S
    L-->>O: chapter prose + [SCRIBE_STATE_UPDATE]
    O->>P: parse(output)
    P->>S: update characters.location<br/>update characters.emotional_state<br/>append plot_advances<br/>append foreshadowing_planted
    S-->>O: persisted
    O-->>U: βœ… + change log
Loading

Captured per chapter: character locations, emotional states, last-appearance index, key events, foreshadowing planted/resolved, new information revealed, editor quality scores (before/after), continuity status & issues, style scores.


πŸ”¬ The Continuity Engine

Deterministic, free, instant β€” runs before the LLM Guardian on every validate, and on demand via check.

Check Severity Catches
dormant_thread warning Active plot threads idle >3 chapters
overdue_thread critical Threads past their target_resolution_chapter still active
unresolved_foreshadowing warning Planted seeds with no matching resolved entry
absent_character warning Main characters silent >5 chapters
never_appeared warning Protagonists/antagonists who never showed up
dead_character_state warning Flagged-dead characters with active state
missing_chapter_file critical Chapter marked complete but no manuscript file
status_drift info Draft exists but status still planned
thin_character info Main characters with no internal_desire set
python core/orchestrator.py check                 # check whole project
python core/orchestrator.py check --chapter 12    # check as-of a specific chapter

Findings are also injected into the LLM Guardian's prompt as context β€” the Guardian gets a head start instead of rediscovering obvious issues, and you don't spend tokens on them.


πŸ”Œ Provider-Agnostic LLM Layer

Pick any of these β€” auto-detected from whichever API key is present:

Provider NOVEL_OS_LLM_PROVIDER Key env var
Anthropic Claude anthropic ANTHROPIC_API_KEY
OpenAI openai OPENAI_API_KEY
Azure OpenAI azure AZURE_OPENAI_API_KEY + AZURE_OPENAI_ENDPOINT
Google Gemini gemini GEMINI_API_KEY
NVIDIA NIM nvidia NVIDIA_API_KEY
Kimi / Moonshot kimi KIMI_API_KEY
Groq groq GROQ_API_KEY
Together AI together TOGETHER_API_KEY
OpenRouter openrouter OPENROUTER_API_KEY
DeepSeek deepseek DEEPSEEK_API_KEY
Mistral mistral MISTRAL_API_KEY
Fireworks fireworks FIREWORKS_API_KEY
Ollama (local) ollama β€”
LM Studio (local) lmstudio β€”
Any OpenAI-compatible endpoint openai_compatible NOVEL_OS_API_KEY + NOVEL_OS_BASE_URL
graph LR
    A[Architect] & B[Scribe] & E[Editor] & G[Guardian] & S[Curator] --> LC{πŸ”Œ LLMClient}
    LC --> P1[Anthropic]
    LC --> P2[OpenAI]
    LC --> P3[Azure]
    LC --> P4[Gemini]
    LC --> P5[NVIDIA NIM]
    LC --> P6[Kimi]
    LC --> P7[Groq Β· Together Β·<br/>OpenRouter Β· DeepSeek Β·<br/>Mistral Β· Fireworks]
    LC --> P8[Ollama Β· LM Studio<br/>local servers]
    LC --> P9[Any OpenAI-compatible<br/>endpoint]

    style LC fill:#06b6d4,stroke:#0e7490,color:#000
Loading

πŸš€ Quick Start

git clone https://github.com/mrigankad/Novel-OS.git
cd Novel-OS
pip install -r requirements.txt   # install only the SDKs you need
cp .env.example .env              # add your API key(s)

1 β€” Initialize

python core/orchestrator.py init --title "The Last Signal" --genre "Sci-Fi Thriller"

2 β€” Cast

python core/orchestrator.py character add --name "Lena Vasquez" --role protagonist
python core/orchestrator.py character add --name "Director Malk" --role antagonist

3 β€” Plan

python core/orchestrator.py plan outline --chapters 32
python core/orchestrator.py plan chapter --number 1 --pov "Lena Vasquez"

4 β€” Write, edit, validate

python core/orchestrator.py write --chapter 1                     # Scribe drafts
python core/orchestrator.py edit  --chapter 1 --mode line         # Editor polishes
python core/orchestrator.py check --chapter 1                     # free pre-check
python core/orchestrator.py validate --chapter 1                  # Guardian validates
python core/orchestrator.py approve  --chapter 1                  # gates on FAIL

Every phase command also accepts --dry-run to emit the prompt without calling the LLM β€” useful for hand-running in a chat UI.

5 β€” Track & export

python core/orchestrator.py status
python core/orchestrator.py export --format markdown

πŸ—‚οΈ CLI Reference

Command Purpose
init --title --genre [--author] Bootstrap a new project
character add --name --role Add a character (protagonist/antagonist/supporting/minor)
character list List all characters with arc state
plot add --name --description [--type --priority] Register a plot thread
plot list List threads by priority and status
plan outline --chapters --words Generate act structure
plan chapter --number [--pov --summary] [--dry-run] Architect expands the chapter
write --chapter [--draft-file --dry-run] Scribe drafts (or accept a file)
edit --chapter --mode [--dry-run] Editor revises in one of 5 modes
validate --chapter [--dry-run] Pre-check + LLM Guardian validates
check [--chapter N] Deterministic engine only (no LLM)
approve --chapter Mark complete (blocked while Status: FAIL)
status Project dashboard
export --format markdown Compile approved chapters

πŸ“ Project Structure

novel-os/
β”œβ”€β”€ πŸ“„ README.md                       ← you are here
β”œβ”€β”€ πŸ“„ AGENTS.md                       ← full agent specs
β”œβ”€β”€ πŸ“„ SYSTEM_OVERVIEW.md              ← architecture deep-dive
β”œβ”€β”€ πŸ“„ requirements.txt
β”œβ”€β”€ πŸ“„ .env.example                    ← provider configuration
β”‚
β”œβ”€β”€ 🐍 core/
β”‚   β”œβ”€β”€ orchestrator.py                ← CLI + workflow
β”‚   β”œβ”€β”€ state_manager.py               ← persistent JSON state
β”‚   β”œβ”€β”€ llm_client.py                  ← 13+ provider abstraction
β”‚   β”œβ”€β”€ state_parser.py                ← agent output β†’ state mutations
β”‚   └── continuity_engine.py           ← deterministic checks
β”‚
β”œβ”€β”€ πŸ€– agents/                         ← each has prompt.md with OUTPUT CONTRACT
β”‚   β”œβ”€β”€ architect/
β”‚   β”œβ”€β”€ scribe/
β”‚   β”œβ”€β”€ editor/
β”‚   β”œβ”€β”€ continuity_guardian/
β”‚   └── style_curator/
β”‚
β”œβ”€β”€ πŸ“‹ templates/                      ← story bible / character / outline starters
β”œβ”€β”€ πŸ“š docs/                           ← WORKFLOWS.md, API.md
β”œβ”€β”€ 🎬 examples/                       ← demo project + recent smoke run
β”œβ”€β”€ 🎨 assets/                         ← mascot + optional generated imagery
β”‚
└── πŸ“€ outputs/                        ← (per project, gitignored)
    β”œβ”€β”€ state/story_state.json
    β”œβ”€β”€ manuscript/
    └── feedback/

πŸ’‘ Why Novel OS Works

Great novels are not written β€” they are engineered. Professional authors use editors, fact-checkers, and style guides. They maintain character bibles, plot trackers, and timelines. Novel OS gives every writer that infrastructure, automated and systematic, with state that actually accumulates rather than dissolving between sessions.

❌ Without Novel OS βœ… With Novel OS
Characters forget their backstory Persistent character database with location, emotion, knowledge
Plot holes emerge 200 pages in Continuity engine catches dormant threads & overdue resolutions
Style drifts between chapters Curator scores and flags voice drift per chapter
Foreshadowing dropped silently Planted/resolved tracked; orphans surfaced
Tension collapses in act two Architect beats + Editor tension mode enforce escalation
Vendor lock-in to one LLM 13+ providers, swap with one env var

πŸ“– Documentation

Document What's inside
AGENTS.md Full system prompts and OUTPUT CONTRACT for each of 5 agents
SYSTEM_OVERVIEW.md Architecture deep-dive and design rationale
docs/WORKFLOWS.md Step-by-step writing workflows
docs/API.md Programmatic API for custom integrations

Novel OS β€” Write novels like a professional author, with an entire editorial team at your command.

v1.1 | Production-Ready Fiction Framework | MIT License

Packages

 
 
 

Contributors

Languages