Build a local novel-drafting app whose defining feature is a codex that injects itself into the drafting prompt. Data model, in SQLite: a project holds chapters, chapters hold scenes, and a scene holds Markdown text. Alongside that, a codex of entries, each with a type (character, place, object, faction, concept), a canonical name, a list of aliases, a body of notes, and a set of relationships to other entries. The matching pass is the core. When the user asks for a draft or a continuation of a scene, scan the scene's existing text and its one-line summary for codex names and aliases. Build the prompt from: the project's style notes, the summaries of the two preceding scenes, the full text of the current scene, and the notes of every matched codex entry plus its first-degree relations. Show the assembled context to the user before sending, as a collapsible list of what was included and why, and let them add or remove an entry for this call only. Never send the whole codex; the point is selection. Drafting actions: continue the scene, rewrite the selection with an instruction, and expand a one-line beat into prose. Insert every result as a suggestion the user accepts, rejects or edits — never write directly into the manuscript. Manuscript views: a chapter tree with drag-to-reorder, a per-scene status (outline, draft, revised, done), a running word count with a daily target, and a scene board showing point-of-view character and summary as cards. Export: a single Markdown file, a compiled DOCX with chapter breaks, and a full JSON backup of manuscript plus codex. Use Anthropic or OpenAI, whichever key is configured. With no key, everything except the three drafting actions must still work — the codex, the manuscript and the export are the parts you cannot afford to lose. Out of scope: cloud sync, collaboration, any hosted service, and shipping bundled prompt presets. The user writes their own.