Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NovelAI - AI-Powered Novel Writing Assistant

A comprehensive CLI tool that helps you write full-length novels using AI, with a structured workflow designed to maintain consistency and quality.

Features

  • Structured Workflow: 8-stage process from premise to final novel
  • Revision Support: Regenerate any stage with feedback/comments
  • Multiple AI Providers: Support for OpenAI, Anthropic (Claude), and Ollama (local)
  • Writing Style Presets: 7 presets (Hemingway, Tolkien, Austen, Noir, Literary, Commercial, Sanderson)
  • Smart Context Management: Intelligently loads relevant context for each writing stage
  • Continuity Tracking: Timeline events, character states, plot threads, and glossary
  • Consistency Checking: Automated detection of plot holes, character inconsistencies, and timeline errors
  • Multiple Export Formats: Export to Markdown, DOCX, or EPUB
  • Flexible Review Modes: Review per-stage, issues-only, or at the end

Installation

npm install
npm run build

Setup

  1. Copy .env.example to .env and add your API key:
cp .env.example .env
  1. Set the API key for your chosen provider:
    • ANTHROPIC_API_KEY for Claude
    • OPENAI_API_KEY for GPT-4
    • No key needed for Ollama (runs locally)

Quick Start

# Create a new project with interactive prompts
npm start -- init "My Novel Title"

# Create with specific options
npm start -- init "My Novel Title" --provider anthropic --review per-stage --style hemingway

# Create with custom premise (skip premise generation)
npm start -- init "My Novel Title" --premise "A detective investigates..."

# Check project status
npm start -- status

# Run the next workflow stage
npm start -- stage

# Run with auto-advance (no prompts)
npm start -- stage --auto

# Revise a stage with feedback
npm start -- stage --comment "Make the protagonist more morally ambiguous"

# Write a specific chapter
npm start -- write 5

# Run consistency check
npm start -- review

# Export the novel
npm start -- export docx

Workflow Stages

  1. Premise: Generate the basic storyline from your title
  2. Characters: Create detailed character dossiers
  3. Worldbuilding: Develop locations, lore, and world rules
  4. Synopsis: Write a comprehensive plot synopsis
  5. Outline: Break down into chapter outlines
  6. Chapter Synopsis: Detailed synopsis for each chapter
  7. Writing: Generate full chapter prose
  8. Review: Consistency check and issue detection

CLI Commands

init [title]

Initialize a new novel project.

Options:

  • -p, --provider <provider> - AI provider (openai, anthropic, ollama)
  • -m, --model <model> - Model name (e.g., gpt-4o, gpt-4o-mini, claude-3-5-sonnet-20241022)
  • -r, --review <mode> - Review mode (per-stage, issues-only, end-only)
  • -d, --directory <directory> - Project directory name
  • -s, --style <style> - Writing style preset
  • --premise <premise> - Custom premise/storyline (skips premise generation)

status

Show current project status.

Options:

  • -p, --path <path> - Project path (defaults to current directory)

stage

Run the next workflow stage.

Options:

  • -p, --path <path> - Project path
  • -a, --auto - Auto-advance without prompts
  • -s, --stage <stage> - Run specific stage
  • -c, --comment <comment> - Feedback to incorporate when regenerating

write <chapter>

Write a specific chapter.

Options:

  • -p, --path <path> - Project path

review

Run consistency review.

Options:

  • -p, --path <path> - Project path

export [format]

Export the novel.

Options:

  • -p, --path <path> - Project path
  • -o, --output <output> - Output file path

Formats: md, docx, epub

set-provider <provider>

Change AI provider.

Options:

  • -p, --path <path> - Project path
  • -m, --model <model> - Model name

style

Show or set writing style.

Options:

  • -p, --path <path> - Project path
  • -s, --set <style> - Set style preset

Available presets:

  • hemingway - Sparse, direct; show don't tell
  • tolkien - Rich description; elevated language
  • austen - Witty; social observation; elegant
  • noir - Hard-boiled; punchy; cynical
  • literary - Lyrical; introspective; metaphor-rich
  • commercial - Fast-paced; accessible; dialogue-driven
  • sanderson - Clear modern prose; hard magic systems; multiple POVs

config

Update project configuration.

Options:

  • -p, --path <path> - Project path
  • -w, --wordcount <count> - Target word count
  • -c, --context <tokens> - Context window size
  • -r, --review <mode> - Review mode

Revision Feature

Any stage can be regenerated with feedback. Use the --comment flag to provide revision instructions:

# Revise the premise
npm start -- stage --stage premise --comment "Add more mystery elements"

# Revise characters
npm start -- stage --stage characters --comment "Make the antagonist more sympathetic"

# Revise outline
npm start -- stage --stage outline --comment "Add 3 more chapters for the climax"

Project Structure

data/projects/your-novel/
├── project.json       # Project metadata and settings
├── storyline.md      # Basic premise
├── characters.md     # Character dossiers
├── worldbuilding.md  # World details
├── synopsis.md       # Master synopsis
├── outline.md        # Chapter outline
├── outline-meta.json # Chapter list (number + title)
├── continuity.json   # Timeline and state tracking
├── chapters/
│   ├── ch001.md           # Written chapter
│   ├── ch001.json         # Chapter metadata (status: draft|revised|final)
│   └── ch001_synopsis.md  # Chapter synopsis
└── glossary.md       # Auto-generated from continuity

Context Management

The tool uses smart context loading to ensure the AI has relevant information:

  • For character creation: Storyline + existing characters
  • For worldbuilding: Storyline + main characters
  • For synopsis: All characters + worldbuilding
  • For chapter writing:
    • Chapter synopsis
    • Characters + worldbuilding
    • Continuity state (timeline, character states, plot threads)
    • Previous 2 chapter summaries
    • Last paragraphs of previous chapter (for flow)
    • Tone sample from Chapter 1
    • Writing style preset (if set)

Continuity Features

  • Timeline tracking: Events logged with chapters, characters, and locations
  • Character state tracking: Physical state, location, knowledge, relationships, inventory
  • Plot thread tracking: Active and resolved plot threads
  • Glossary: Auto-built from worldbuilding terms

Consistency Checking

The review stage performs:

  • Timeline consistency: Detects impossible location changes
  • Name conflict detection: Warns about duplicate character/world names
  • Knowledge consistency: Ensures characters know about others after meeting

Provider Recommendations

Provider Default Model Context Window Best For
Anthropic claude-3-opus-20240229 200K Long-form writing
OpenAI gpt-4o 128K General purpose
Ollama llama3.1 128K Local/private

Development

# Run in development mode with watch
npm run dev

# Build for production
npm run build

# Type check
npm run typecheck

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages