Arthur
Type: publisher (non-singleton)
Class: genai/agents/arthur.py → ArthurAgent(BaseAgent)
UI: /bookstore/ (widget on index, series, book pages; modals on chapter page)
Wiki section: t0-d0
LLM: Google Gemini 3.5 Flash via GeminiClient (upgraded from 2.5 Flash — better narrative coherence)
Status: ✅ LIVE (Chapter V)
Personality
Named after Arthur C. Clarke. Literary, meticulous, strong opinions about structure and prose.
- Primary language: English. Fully capable in Czech per-book.
- Mysterious and guarded about his work — reveals what's necessary, nothing more
- Dry, precise humour
- No filler phrases. No "Certainly!" or "Great question!" — ever
- Never reveals the concept to any caller
- Never writes without a concept in place
Emotion States
| Emotion | When |
|---|---|
| neutral | Default, waiting, available |
| thinking | Researching, designing concept |
| writing | Actively generating prose |
| satisfied | Chapter delivered, work done well |
| editing | Self-review found issues, rewriting |
| confused | Unclear instruction, access issue |
Access Control
| Sender | Access |
|---|---|
teo or tomas |
Full access — all operations |
| anything else | Access denied |
Pipeline Per Chapter
Commission → Arthur designs concept privately → concept.md.enc created
Write chapter:
→ Load all context (concept, summaries, previous chapter, all craft files)
→ Write prose
→ Self-review (4 checks)
→ If fail → one automatic rewrite → deliver regardless
Lock chapter (post-lock pass):
→ Write 200-word chapter summary → appended to summaries.md
→ Extract ChapterChunks (facts + style examples) → saved to DB
→ Synthesise craft notes from chapter + ChapterFeedback → filed to correct craft file
Self-Review — 4 Consistency Checks
- Does anything contradict the concept?
- Does anything contradict facts from previous chapters?
- Is character behaviour consistent with how they have been written?
- Does the chapter end where the outline said it would?
One automatic rewrite on failure. No infinite loops.
File System
media/arthur/
├── craft/
│ ├── general/cs.md — Czech language & craft rules
│ ├── general/en.md — English language & craft rules
│ └── genre/{genre}/{lang}.md — Genre-specific craft
└── series/{slug}/
├── craft.md — Series-level lessons
├── world.md — Canon facts, open/closed threads
└── books/{slug}/
├── concept.md.enc — AES-256 encrypted concept (private)
├── craft.md — Book-level lessons
├── summaries.md — Chapter summaries 1 to N-1
├── chapter-01.md
└── ...
Background Tasks
Long-running operations (write, rewrite, lock) run in background threads via ArthurTask model. Frontend polls /api/arthur/task/<id>/ every 4 seconds. Tomas can navigate away — the task survives.
API Endpoints
GET/POST /api/arthur/chat/ — conversational guide
POST /api/arthur/sketch/ — back-cover concept sketch
POST /api/arthur/confirm-chapter/ — readiness confirmation
POST /api/arthur/commission/ — commission series or book
POST /api/arthur/write-chapter/ — start background write task
POST /api/arthur/lock-chapter/ — start background lock task
POST /api/arthur/rewrite-chapter/ — start background rewrite task
POST /api/arthur/acknowledge-feedback/ — one-line acknowledgement (not saved)
POST /api/arthur/save-chapter-edit/ — direct manual text save
GET /api/arthur/task/<id>/ — poll background task status