Local AI novel generator for Gemini and Ollama. Write coherent novels chapter by chapter with causal planning, persistent story memory, scene handoffs, and continuity checks.
144
stars
189
commits
TypeScript
primary language
Sep 14, 2026
updated
NovelGenerator is a source-available AI novel writer that turns a one-paragraph premise into a full manuscript, chapter by chapter. Run it with Gemini or use Ollama as a local AI writer with your own model.
It is built for long-form story generation rather than isolated prompts: causal planning, persistent story memory, explicit scene handoffs and continuity checks keep characters, facts and open plot threads available as the novel grows.
AI novel generator · Local LLM and Ollama · Long-form fiction · Persistent story memory · Continuity checking
git clone https://github.com/KazKozDev/NovelGenerator.git
cd NovelGenerator
npm install
npm run dev
VITE v6.3.6 ready in 118 ms
➜ Local: http://localhost:3000/
➜ Network: http://192.168.1.177:3000/
Open that address, pick a provider, set a model, write a premise and a chapter count, then
start. Gemini needs GEMINI_API_KEY in the environment; Ollama needs to be running. The
engine designs the book, reviews its own construction, then writes chapter by chapter and
scene by scene without asking you to approve anything mid-run. Export the finished book as
EPUB, PDF, TXT or Markdown, and the audit as JSON.
Select Ollama in the app to write with a model served from your machine. This is the local/private path: manuscript generation does not require sending the premise or chapters to Gemini. You can use one model for prose and a separate Ollama model for planning, continuity review and the final audit.
The premise is the whole input. From it the engine builds one compact construction — cast, world rules, a causal map, an ending and a chapter map — and refuses to write against a construction its own review found incoherent. A premise name nobody in the cast answers to fails that review in code, not by opinion.
A measured run: 7 chapters, 15,390 words, 122 model calls, about 40 minutes on Ollama cloud models.
Every scene is folded into story memory before the next one is written. One call extracts what changed — events, locations, who knows what, which promises opened and closed — and each record must cite the paragraph that proves it; a citation pointing nowhere is rejected and asked again.
The accepted scene produces an explicit handoff: what the reader already knows, what actually changed, which question remains open and what the next scene must accomplish differently. The next scene's causal plan is rebased on that handoff before prose is written, so chapter 7 follows what the book established, not merely what chapter 1 intended. A scene that contradicts confirmed state is rewritten once, with the contradiction named.
npx vite-node scripts/run-book.ts --writer deepseek-v4.1-flash:cloud \
--editor mistral-large-3:675b-cloud --chapters 3 --premise "..." --out runs/demo
STAGE design calls=0
STAGE chapter ch1 calls=2
STAGE chapter ch2 calls=15
STAGE chapter ch3 calls=29
STAGE audit calls=46
DONE status=COMPLETE_WITH_WARNINGS calls=47 tokens~362683
Every call is logged with its route, model, prompt size and duration. --out holds
manuscript.md, snapshot.json and run.log. --provider gemini runs the same pipeline
against the Gemini transport instead, with --writer/--editor as model names.
Two models, two roles. The writer produces prose. The editor plans, reviews,
extracts memory and audits the finished book; without a separate editor the writer judges
its own prose, which is the weakest configuration this engine allows. Eight prompts live as
files under prompts/, one per stage, and code never hand-builds them — it names a prompt
and supplies its variables. Before any prose exists, structural doubts about a scene (no
viewpoint, an outcome that changes nothing, a location the memory contradicts) go to a
readiness review that turns a blocking verdict into an instruction for the writer instead
of stopping the book. Every stage is committed to IndexedDB, so a closed tab or a failed
scene costs at most the call in flight: reopening offers to continue, and finished chapters
keep their manuscript and memory.
premise → design → plan review → chapter plan → scene → handoff → rebase → next scene → audit → export
Set in the app before generation starts.
| Option | Default | What it does |
|---|---|---|
| Chapters | 3 | Book length, 3–100 |
| Target words per chapter | 4000 | 300–10000 |
| Language | English | Language of the manuscript |
| Genre | fantasy | Genre contract carried into every prompt |
| Narrative voice | third-limited | Point of view |
| Tense | past | past or present |
| Tone | serious | Tonal contract |
| Target audience | adult | Audience contract |
| Writing style | descriptive | Style contract |
| Ending | closed | closed, open or series |
| Writer provider | Gemini | gemini or ollama; Gemini defaults to gemini-3.6-flash |
| Separate editor model | off | A second model for planning, review and the audit — strongly recommended |
| Reasoning (think) | off | Lets a reasoning model think before answering; capped calls get cut off with it on |
| Semantic pre-write check | light | Local models read each chapter plan against finished prose: light (~90MB), full (~700MB), off |
| Variable | Required | What it does |
|---|---|---|
GEMINI_API_KEY | For Gemini | Gemini API key; API_KEY is accepted as an alias |
OLLAMA_HOST | No | Ollama address the dev server proxies to, default http://127.0.0.1:11434 |
deepseek-v4.1-flash:cloud and mistral-large-3:675b-cloudnpm test
Test Files 13 passed (13)
Tests 141 passed (141)
npm run build && npm run preview
189 commits
TypeScript
97.2%
HTML
1.8%
Shell
1.1%
Local AI novel generator for Gemini and Ollama. Write coherent novels chapter by chapter with causal planning, persistent story memory, scene handoffs, and continuity checks.
144
stars
189
commits
TypeScript
primary language
Sep 14, 2026
updated
NovelGenerator is a source-available AI novel writer that turns a one-paragraph premise into a full manuscript, chapter by chapter. Run it with Gemini or use Ollama as a local AI writer with your own model.
It is built for long-form story generation rather than isolated prompts: causal planning, persistent story memory, explicit scene handoffs and continuity checks keep characters, facts and open plot threads available as the novel grows.
AI novel generator · Local LLM and Ollama · Long-form fiction · Persistent story memory · Continuity checking
git clone https://github.com/KazKozDev/NovelGenerator.git
cd NovelGenerator
npm install
npm run dev
VITE v6.3.6 ready in 118 ms
➜ Local: http://localhost:3000/
➜ Network: http://192.168.1.177:3000/
Open that address, pick a provider, set a model, write a premise and a chapter count, then
start. Gemini needs GEMINI_API_KEY in the environment; Ollama needs to be running. The
engine designs the book, reviews its own construction, then writes chapter by chapter and
scene by scene without asking you to approve anything mid-run. Export the finished book as
EPUB, PDF, TXT or Markdown, and the audit as JSON.
Select Ollama in the app to write with a model served from your machine. This is the local/private path: manuscript generation does not require sending the premise or chapters to Gemini. You can use one model for prose and a separate Ollama model for planning, continuity review and the final audit.
The premise is the whole input. From it the engine builds one compact construction — cast, world rules, a causal map, an ending and a chapter map — and refuses to write against a construction its own review found incoherent. A premise name nobody in the cast answers to fails that review in code, not by opinion.
A measured run: 7 chapters, 15,390 words, 122 model calls, about 40 minutes on Ollama cloud models.
Every scene is folded into story memory before the next one is written. One call extracts what changed — events, locations, who knows what, which promises opened and closed — and each record must cite the paragraph that proves it; a citation pointing nowhere is rejected and asked again.
The accepted scene produces an explicit handoff: what the reader already knows, what actually changed, which question remains open and what the next scene must accomplish differently. The next scene's causal plan is rebased on that handoff before prose is written, so chapter 7 follows what the book established, not merely what chapter 1 intended. A scene that contradicts confirmed state is rewritten once, with the contradiction named.
npx vite-node scripts/run-book.ts --writer deepseek-v4.1-flash:cloud \
--editor mistral-large-3:675b-cloud --chapters 3 --premise "..." --out runs/demo
STAGE design calls=0
STAGE chapter ch1 calls=2
STAGE chapter ch2 calls=15
STAGE chapter ch3 calls=29
STAGE audit calls=46
DONE status=COMPLETE_WITH_WARNINGS calls=47 tokens~362683
Every call is logged with its route, model, prompt size and duration. --out holds
manuscript.md, snapshot.json and run.log. --provider gemini runs the same pipeline
against the Gemini transport instead, with --writer/--editor as model names.
Two models, two roles. The writer produces prose. The editor plans, reviews,
extracts memory and audits the finished book; without a separate editor the writer judges
its own prose, which is the weakest configuration this engine allows. Eight prompts live as
files under prompts/, one per stage, and code never hand-builds them — it names a prompt
and supplies its variables. Before any prose exists, structural doubts about a scene (no
viewpoint, an outcome that changes nothing, a location the memory contradicts) go to a
readiness review that turns a blocking verdict into an instruction for the writer instead
of stopping the book. Every stage is committed to IndexedDB, so a closed tab or a failed
scene costs at most the call in flight: reopening offers to continue, and finished chapters
keep their manuscript and memory.
premise → design → plan review → chapter plan → scene → handoff → rebase → next scene → audit → export
Set in the app before generation starts.
| Option | Default | What it does |
|---|---|---|
| Chapters | 3 | Book length, 3–100 |
| Target words per chapter | 4000 | 300–10000 |
| Language | English | Language of the manuscript |
| Genre | fantasy | Genre contract carried into every prompt |
| Narrative voice | third-limited | Point of view |
| Tense | past | past or present |
| Tone | serious | Tonal contract |
| Target audience | adult | Audience contract |
| Writing style | descriptive | Style contract |
| Ending | closed | closed, open or series |
| Writer provider | Gemini | gemini or ollama; Gemini defaults to gemini-3.6-flash |
| Separate editor model | off | A second model for planning, review and the audit — strongly recommended |
| Reasoning (think) | off | Lets a reasoning model think before answering; capped calls get cut off with it on |
| Semantic pre-write check | light | Local models read each chapter plan against finished prose: light (~90MB), full (~700MB), off |
| Variable | Required | What it does |
|---|---|---|
GEMINI_API_KEY | For Gemini | Gemini API key; API_KEY is accepted as an alias |
OLLAMA_HOST | No | Ollama address the dev server proxies to, default http://127.0.0.1:11434 |
deepseek-v4.1-flash:cloud and mistral-large-3:675b-cloudnpm test
Test Files 13 passed (13)
Tests 141 passed (141)
npm run build && npm run preview
189 commits
TypeScript
97.2%
HTML
1.8%
Shell
1.1%