InkOS - Autonomous Novel Writing Agent
InkOS is a CLI tool for autonomous fiction writing powered by LLM agents. It orchestrates a multi-agent pipeline (Radar → Planner → Composer → Architect → Writer → Observer → Reflector → Normalizer → Auditor → Reviser) to generate, audit, and revise novel content with zero human intervention per chapter.
The pipeline operates in three phases:
- Phase 1 (Creative Writing, temp 0.7): Planner generates chapter intent with hook agenda, Composer selects relevant context, Writer produces prose with length governance, first-screen hooks, semantic density, hook-ledger payoff, and mobile paragraph rhythm guidance.
- Phase 2 (State Settlement, temp 0.3): Observer over-extracts 9 categories of facts, Reflector outputs a JSON delta (not full markdown), code-layer applies Zod schema validation and immutable state update. Hook operations use upsert/mention/resolve/defer semantics.
- Phase 3 (Quality Loop): Normalizer adjusts chapter length, Auditor runs 33-dimension check including hook health analysis, Reviser auto-fixes critical issues. Self-correction loop runs until all critical issues clear.
Truth files are persisted as schema-validated JSON (story/state/*.json) with markdown projections for human readability. SQLite temporal memory database (story/memory.db) enables relevance-based retrieval on Node 22+.
When to Use InkOS
- English novel writing: Native English support with 10 genre profiles (LitRPG, Progression Fantasy, Isekai, etc.). Set
--lang en
- Chinese web novel writing: 5 built-in Chinese genres (xuanhuan, xianxia, urban, horror, other)
- Fan fiction: Create fanfic from source material with 4 modes (canon, au, ooc, cp)
- Batch chapter generation: Generate multiple chapters with consistent quality
- Import & continue: Import existing chapters from a text file, reverse-engineer truth files, and continue writing
- Style imitation: Analyze and adopt writing styles from reference texts
- Spinoff writing: Write prequels/sequels/spinoffs while maintaining parent canon
- Quality auditing: Detect AI-generated content and perform 33-dimension quality checks
- Genre exploration: Explore trends and create custom genre rules
- Analytics: Track word count, audit pass rate, and issue distribution per book
Initial Setup
First Time Setup
# Initialize a project directory (creates config structure)
inkos init my-writing-project
# Configure your LLM provider (OpenAI, Anthropic, or any OpenAI-compatible API)
# Prefer --api-key-env so the key never appears in shell history:
export OPENAI_API_KEY=sk-xxx
inkos config set-global --provider openai --base-url https://api.openai.com/v1 --api-key-env OPENAI_API_KEY --model gpt-4o
# For compatible/proxy endpoints, use --provider custom and point ONLY to trusted endpoints:
# inkos config set-global --provider custom --base-url https://your-trusted-proxy.com/v1 --api-key-env OPENAI_API_KEY --model gpt-4o
Multi-Model Routing (Optional)
# Assign different models to different agents — balance quality and cost
inkos config set-model writer claude-sonnet-4-20250514 --provider anthropic --base-url https://api.anthropic.com --api-key-env ANTHROPIC_API_KEY
inkos config set-model auditor gpt-4o --provider openai
inkos config show-models
Agents without explicit overrides fall back to the global model.
View System Status
# Check installation and configuration
inkos doctor
# View current config
inkos status
Common Workflows
Workflow 1: Create a New Novel
Initialize and create book:
inkos book create --title "My Novel Title" --genre xuanhuan --chapter-words 3000
# Or with a creative brief (your worldbuilding doc / ideas):
inkos book create --title "My Novel Title" --genre xuanhuan --chapter-words 3000 --brief my-ideas.md
- Genres:
xuanhuan (cultivation), xianxia (immortal), urban (city), horror, other
- Returns a
book-id for all subsequent operations
Generate initial chapters (e.g., 5 chapters):
inkos write next book-id --count 5 --words 3000 --context "young protagonist discovering powers"
- The
write next command runs the full pipeline: draft → audit → revise
--context provides guidance to the Architect and Writer agents
- Returns JSON with chapter details and quality metrics
Review and approve chapters:
inkos review list book-id
inkos review approve-all book-id
Export the book (supports txt, md, epub):
inkos export book-id
inkos export book-id --format epub
Workflow 2: Continue Writing Existing Novel
List your books:
inkos book list
Continue from last chapter:
inkos write next book-id --count 3 --words 2500 --context "protagonist faces critical choice"
- InkOS maintains 7 truth files (world state, character matrix, emotional arcs, etc.) for consistency
- If only one book exists, omit
book-id for auto-detection
Review and approve:
inkos review approve-all
Workflow 2.5: Shared Natural-Language Control (Recommended For OpenClaw)
When InkOS is being driven by OpenClaw or another external agent, prefer the shared interaction executor instead of stitching together many ad-hoc CLI calls:
inkos interact --json --message "continue the current book, but keep the pacing tighter"
inkos interact --json --message "rewrite chapter 3"
inkos interact --json --book my-book --message "switch to auto mode"
This returns a structured payload containing:
- the routed request
- assistant response text
- updated interaction session
- execution state
- pending decision
- recent interaction events
Use this as the primary OpenClaw entry because it shares the same control layer as the project TUI.
Workflow 2.6: Steering Chapter Focus Before Writing
Use this when the user says things like "pull focus back to the mentor conflict", "pause the merchant guild subplot", or "change what the next chapter should prioritize".
Update the book-level control docs when needed:
- Use
update_author_intent to change the long-horizon identity of the book
- Use
update_current_focus to change the next 1-3 chapters' focus
Compile the next chapter intent:
plan_chapter(bookId, guidance?)
- Generates
story/runtime/chapter-XXXX.intent.md
- Use this to verify what the system thinks the next chapter should do
Compose the actual runtime input package:
compose_chapter(bookId, guidance?)
- Generates
story/runtime/chapter-XXXX.context.json
- Generates
story/runtime/chapter-XXXX.rule-stack.yaml
- Generates
story/runtime/chapter-XXXX.trace.json
Only then write:
write_draft if the user wants intermediate review
write_full_pipeline if they want the usual write → audit → revise flow
Recommended orchestration:
- user asks to redirect focus
update_current_focus
plan_chapter
compose_chapter
- inspect the resulting intent/paths
write_draft or write_full_pipeline
Workflow 3: Import Existing Chapters & Continue
Use this when you have an existing novel (or partial novel) and want InkOS to pick up where it left off.
Import from a single text file (auto-splits by chapter headings):
inkos import chapters book-id --from novel.txt
- Automatically splits by
第X章 pattern
- Custom split pattern:
--split "Chapter\\s+\\d+"
Import from a directory of separate chapter files:
inkos import chapters book-id --from ./chapters/
- Reads
.md and .txt files in sorted order
Resume interrupted import:
inkos import chapters book-id --from novel.txt --resume-from 15
Continue writing from the imported chapters:
inkos write next book-id --count 3
- InkOS reverse-engineers all 7 truth files from the imported chapters
- Generates a style guide from the existing text
- New chapters maintain consistency with imported content
Workflow 4: Style Imitation
Analyze reference text:
inkos style analyze reference_text.txt
- Examines vocabulary, sentence structure, tone, pacing
Import style to your book:
inkos style import reference_text.txt book-id --name "Author Name"
- All future chapters adopt this style profile
- Style rules become part of the Reviser's audit criteria
Workflow 5: Spinoff/Prequel Writing
Import parent canon:
inkos import canon spinoff-book-id --from parent-book-id
- Creates links to parent book's world state, characters, and events
- Reviser enforces canon consistency
Continue spinoff:
inkos write next spinoff-book-id --count 3 --context "alternate timeline after Chapter 20"
Workflow 6: Fine-Grained Control (Draft → Audit → Revise)
If you need separate control over each pipeline stage:
Generate draft only:
inkos draft book-id --words 3000 --context "protagonist escapes" --json
Audit the chapter (33-dimension quality check):
inkos audit book-id chapter-1 --json
- Returns metrics across 33 dimensions including pacing, dialogue, world-building, outline adherence, and more
Revise with specific mode:
inkos revise book-id chapter-1 --mode polish --json
- Modes:
polish (minor), spot-fix (targeted), rewrite (major), rework (structure), anti-detect (reduce AI traces)
Workflow 7: Monitor Platform Trends
inkos radar scan
- Analyzes trending genres, tropes, and reader preferences
- Informs Architect recommendations for new books
Workflow 8: Detect AI-Generated Content
# Detect AIGC in a specific chapter
inkos detect book-id
# Deep scan all chapters
inkos detect book-id --all
- Uses 11 deterministic rules (zero LLM cost) + optional LLM validation
- Returns detection confidence and problematic passages
Workflow 9: View Analytics
inkos analytics book-id --json
# Shorthand alias
inkos stats book-id --json
- Total chapters, word count, average words per chapter
- Audit pass rate and top issue categories
- Chapters with most issues, status distribution
- Token usage stats: total prompt/completion tokens, avg tokens per chapter, recent trend
Workflow 10: Write an English Novel
# Create an English LitRPG novel (language auto-detected from genre)
inkos book create --title "The Last Delver" --genre litrpg --chapter-words 3000
# Or set language explicitly
inkos book create --title "My Novel" --genre other --lang en
# Set English as default for all projects
inkos config set-global --lang en
- 10 English genres: litrpg, progression, isekai, cultivation, system-apocalypse, dungeon-core, romantasy, sci-fi, tower-climber, cozy
- Each genre has dedicated pacing rules, fatigue word lists (e.g., "delve", "tapestry", "testament"), and audit dimensions
- Use
inkos genre list to see all available genres
Workflow 11: Fan Fiction
# Create a fanfic from source material
inkos fanfic init --title "My Fanfic" --from source-novel.txt --mode canon
# Modes: canon (faithful), au (alternate universe), ooc (out of character), cp (ship-focused)
inkos fanfic init --title "What If" --from source.txt --mode au --genre other
- Imports and analyzes source material automatically
- Fanfic-specific audit dimensions and information boundary controls
- Ensures new content stays consistent with source canon (or deliberately diverges in au/ooc modes)
Workflow 12: Rename Characters or Entities Across Entire Book
# Via interact
inkos interact --json --message "把林烬改成张三"
inkos interact --json --message "rename Lin Jin to Zhang San"
# Via slash command
inkos interact --json --message "/rename 林烬 => 张三"
- Scans all chapters + all truth files (story_bible, current_state, character_matrix, etc.)
- Replaces every occurrence in one pass
- Returns count of files touched
Workflow 13: Patch Specific Text in a Chapter
inkos interact --json --message "/replace 5 旧文本 => 新文本"
- Precisely replaces text in chapter 5 only
- Marks chapter for review after patching
Workflow 14: Interactive TUI Dashboard
inkos
- Launches a full-screen Ink + React dashboard with conversational creation
- Slash command autocomplete (Tab), input history (arrow keys)
- Themed activity animations per operation (writing, auditing, revising, planning)
- Bilingual i18n (Chinese / English)
- Shares the same interaction kernel as
inkos interact and Studio
InkOS Studio (Web Workbench)
inkos studio launches a local web UI (default port 4567) that provides a visual interface for all InkOS operations:
- Book management — create, delete, export (TXT/MD/EPUB), configure per-book settings
- Chapter review & editing — approve/reject drafts, edit content inline, multi-mode revision (polish/spot-fix/rewrite/anti-detect)
- Real-time writing progress — SSE-based live updates during chapter generation
- Market radar — AI-powered trend analysis with platform/genre recommendations
- Analytics — word count, audit pass rate, chapter ranking, token usage
- AI detection — scan chapters for AI-generated content
- Style analysis — analyze reference texts and import writing styles
- Genre management — create/customize genre profiles with fatigue words, pacing rules, audit dimensions
- Daemon control — start/stop background writing with event log
- Truth file editor — view and edit canonical knowledge base per book
- Config editor — LLM provider, model routing, notifications
inkos studio # Start on default port 4567
inkos studio -p 8080 # Start on custom port
The right-side AI Assistant panel in Studio shares the same interaction kernel as TUI and inkos interact. You can type natural language commands (rename entities, write chapters, audit, export) directly in the assistant panel.
Advanced: Natural Language Agent Mode
For flexible, conversational requests:
inkos agent "写一部都市题材的小说,主角是一个年轻律师,第一章三千字"
- Agent interprets natural language and invokes appropriate commands
- Useful for complex multi-step requests
Input Governance Tools
These tools are the preferred control surface for chapter steering:
plan_chapter(bookId, guidance?)
- Generates chapter intent for the next chapter
- Use before writing when the user wants to change focus
compose_chapter(bookId, guidance?)
- Generates runtime context/rule-stack/trace artifacts
- Use after planning and before writing
update_author_intent(bookId, content)
- Rewrites
story/author_intent.md
- Use for long-horizon changes to the book's identity
update_current_focus(bookId, content)
- Rewrites
story/current_focus.md
- Use for local steering over the next 1-3 chapters
write_truth_file remains available for broad file edits, but prefer the dedicated control tools above for input-governance changes.
Key Concepts
Book ID Auto-Detection
If your project contains only one book, most commands accept book-id as optional. You can omit it for brevity:
# Explicit
inkos write next book-123 --count 1
# Auto-detected (if only one book exists)
inkos write next --count 1
--json Flag
All content-generating commands support --json for structured output. Essential for programmatic use:
inkos draft book-id --words 3000 --context "guidance" --json
Truth Files (Long-Term Memory)
InkOS maintains 7 files per book for coherence:
- World State: Maps, locations, technology levels, magic systems
- Character Matrix: Names, relationships, arcs, motivations
- Resource Ledger: In-world items, money, power levels
- Chapter Summaries: Events, progression, foreshadowing
- Subplot Board: Active and dormant subplots, hooks
- Emotional Arcs: Character emotional progression
- Pending Hooks: Unresolved cliffhangers and promises to reader
All agents reference these to maintain long-term consistency. Since 0.6.0, truth files are backed by schema-validated JSON in story/state/ with automatic bootstrap from markdown for legacy books. During import chapters, these files are reverse-engineered from existing content via the ChapterAnalyzerAgent.
Multi-Phase Writer Architecture
The Writer operates across multiple phases with specialized agents:
- Planner: Generates chapter intent with structured hook agenda (mustAdvance, eligibleResolve, staleDebt) based on memory retrieval.
- Composer: Selects relevant context from truth files by relevance scoring, compiles rule stack and runtime artifacts.
- Phase 1 (Creative, temp 0.7): Generates prose with length governance, English variance brief (anti-repetition), and dialogue-driven guidance.
- Phase 2a (Observer, temp 0.5): Over-extracts 9 categories of facts from the chapter text.
- Phase 2b (Reflector, temp 0.3): Outputs a JSON delta with hookOps (upsert/mention/resolve/defer), currentStatePatch, and chapterSummary. Code-layer validates via Zod schema and applies immutably.
- Normalizer: Single-pass compress/expand to bring chapter length into the target band. Safety net rejects destructive normalization (>75% content loss).
- Auditor: 33-dimension check including hook health analysis (stale debt, burst detection, no-advance warnings).
- Reviser: Auto-fixes critical issues, self-correction loop until clean.
Truth files use structured JSON (story/state/*.json) as the authoritative source, with markdown projections for human readability. Hook admission control prevents duplicate/family hooks from inflating the hook table.
Context Guidance
The --context parameter provides directional hints to the Writer and Architect:
inkos write next book-id --count 2 --context "protagonist discovers betrayal, must decide whether to trust mentor"
- Context is optional but highly recommended for narrative coherence
- Supports both English and Chinese
Genre Management
View Built-In Genres
inkos genre list
inkos genre show xuanhuan
Create Custom Genre
inkos genre create my-genre --name "My Genre"
# Options: --numerical, --power, --era
inkos genre create dark-xuanhuan --name "Dark Xuanhuan" --numerical --power
Copy Built-in Genre for Customization
inkos genre copy xuanhuan
# Copies to project genres/ directory for editing
Command Reference Summary
| Command |
Purpose |
Notes |
inkos init [name] |
Initialize project |
One-time setup |
inkos book create |
Create new book |
Returns book-id. --brief <file>, --lang en/zh, --genre litrpg/progression/... |
inkos book list |
List all books |
Shows IDs, statuses |
inkos write next |
Full pipeline (draft→audit→revise) |
Primary workflow command |
inkos draft |
Generate draft only |
No auditing/revision |
inkos audit |
33-dimension quality check |
Standalone evaluation |
inkos revise |
Revise chapter |
Modes: polish/spot-fix/rewrite/rework/anti-detect |
inkos agent |
Natural language interface |
Flexible requests |
inkos style analyze |
Analyze reference text |
Extracts style profile |
inkos style import |
Apply style to book |
Makes style permanent |
inkos import canon |
Link spinoff to parent |
For prequels/sequels |
inkos import chapters |
Import existing chapters |
Reverse-engineers truth files for continuation |
inkos detect |
AIGC detection |
Flags AI-generated passages |
inkos export |
Export finished book |
Formats: txt, md, epub |
inkos analytics / inkos stats |
View book statistics |
Word count, audit rates, token usage |
inkos radar scan |
Platform trend analysis |
Informs new book ideas |
inkos config set-global |
Configure LLM provider |
OpenAI/Anthropic/custom (any OpenAI-compatible) |
inkos config set-model <agent> <model> |
Set model override for a specific agent |
--provider, --base-url, --api-key-env for multi-provider routing |
inkos config show-models |
Show current model routing |
View per-agent model assignments |
inkos doctor |
Diagnose issues |
Check installation |
inkos update |
Update to latest version |
Self-update |
inkos up/down |
Daemon mode |
Background processing. Logs to inkos.log (JSON Lines). -q for quiet mode |
inkos review list/approve-all |
Manage chapter approvals |
Quality gate |
inkos fanfic init |
Create fanfic from source material |
--from <file>, --mode canon/au/ooc/cp |
inkos genre list |
List all available genres |
Shows English and Chinese genres with default language |
inkos genre create <id> |
Create custom genre profile |
--name, --numerical, --power, --era |
inkos genre copy <id> |
Copy built-in genre to project |
For customization |
inkos write rewrite <book> <ch> |
Rewrite a specific chapter |
Deletes chapter and later, rewrites from that point |
inkos book update [book-id] |
Update book settings |
--chapter-words, --target-chapters, --status, --lang |
inkos book delete <book-id> |
Delete book and all chapters |
--force to skip confirmation |
inkos plan chapter [book-id] |
Generate chapter intent |
Preview what next chapter will do before writing |
inkos compose chapter [book-id] |
Generate runtime artifacts |
Context, rule-stack, trace for next chapter |
inkos consolidate [book-id] |
Consolidate chapter summaries |
Reduces context for long books (volume-level summaries) |
inkos eval [book-id] |
Quality evaluation report |
--json, --chapters <range>. Composite quality score |
inkos studio |
Start web workbench |
-p for port. Local web UI for book management |
inkos fanfic show [book-id] |
Display parsed fanfic canon |
Shows imported source material analysis |
inkos fanfic refresh [book-id] |
Re-import and regenerate fanfic canon |
--from <file> for updated source material |
inkos interact |
Shared interaction endpoint |
--json, --message, --book. Primary entry for OpenClaw |
inkos (no args) |
Launch TUI dashboard |
Full-screen Ink + React interactive dashboard |
Error Handling
Common Issues
"book-id not found"
- Verify the ID with
inkos book list
- Ensure you're in the correct project directory
"Provider not configured"
- Run
inkos config set-global with valid credentials
- Check API key and base URL with
inkos doctor
"Context invalid"
- Ensure
--context is a string (wrap in quotes if multi-word)
- Context can be in English or Chinese
"Audit failed"
- Check chapter for encoding issues
- Ensure chapter-words matches actual word count
- Try
inkos revise with --mode rewrite
"Book already has chapters" (import)
- Use
--resume-from <n> to append to existing chapters
- Or delete existing chapters first
Running Daemon Mode
For long-running operations:
# Start background daemon
inkos up
# Stop daemon
inkos down
# Daemon auto-processes queued chapters
Tips for Best Results
- Provide rich context: The more guidance in
--context, the more coherent the narrative
- Start with style: If imitating an author, run
inkos style import before generation
- Import first: For existing novels, use
inkos import chapters to bootstrap truth files before continuing
- Review regularly: Use
inkos review to catch issues early
- Monitor audits: Check
inkos audit metrics to understand quality bottlenecks
- Use spinoffs strategically: Import canon before writing prequels/sequels
- Batch generation: Generate multiple chapters together (better continuity)
- Check analytics: Use
inkos analytics to track quality trends over time
- Export frequently: Keep backups with
inkos export
Security & Trust
- License: the ClawHub skill descriptor is MIT-0 per platform policy, but the underlying
@actalk/inkos, @actalk/inkos-core, and @actalk/inkos-studio npm packages are AGPL-3.0-only. Running InkOS and distributing modified versions are governed by AGPL. Full source on GitHub for auditability.
- No install hooks: npm package has no
preinstall/postinstall/install scripts. Install is inert.
- Local-only file I/O: all read/write stays inside the project directory (
books/*, inkos.json, inkos.log). No writes outside the working directory.
- No telemetry: InkOS does not phone home, collect usage stats, or ship any data to InkOS-controlled servers. The only outbound traffic is to the LLM provider endpoint you explicitly configure.
- Credential handling: always prefer
--api-key-env <VAR_NAME> over --api-key <literal> so keys never hit shell history. Keys are stored in inkos.json under your project directory — treat it like a secret and add it to .gitignore if you commit the project.
- Custom provider base-URL:
--provider custom forwards your API key to whatever URL you specify. Only point it at endpoints you trust (your own proxy or an audited reverse-proxy). Never paste an untrusted --base-url.
- No elevated privileges: InkOS requires no sudo, no global state mutation, no network listening port (Studio binds
localhost:4567 only).
Support & Resources
- Homepage: https://github.com/Narcooo/inkos
- Configuration: Stored in project root after
inkos init
- Truth files: Located in
books/<id>/story/ per book, with structured JSON in story/state/
- Logs: Check output of
inkos doctor for troubleshooting
1---2name: inkos3description: Autonomous novel writing CLI agent with web workbench (InkOS Studio) - use for creative fiction writing, novel generation, style imitation, chapter continuation/import, EPUB export, AIGC detection, and fan fiction. Native English support with 10 built-in English genre profiles (LitRPG, Progression Fantasy, Isekai, Cultivation, System Apocalypse, Dungeon Core, Romantasy, Sci-Fi, Tower Climber, Cozy Fantasy). Also supports Chinese web novel genres (xuanhuan, xianxia, urban, horror, other). Multi-agent pipeline, two-phase writer (creative + settlement), stronger long-form chapter craft rules, hook-ledger payoff checks, 33-dimension auditing, token usage analytics, creative brief input, structured logging (JSON Lines), multi-model routing, custom OpenAI-compatible provider support, and InkOS Studio web UI for visual book management, chapter review, real-time writing progress, market radar, and analytics.4---56# InkOS - Autonomous Novel Writing Agent78InkOS is a CLI tool for autonomous fiction writing powered by LLM agents. It orchestrates a multi-agent pipeline (Radar → Planner → Composer → Architect → Writer → Observer → Reflector → Normalizer → Auditor → Reviser) to generate, audit, and revise novel content with zero human intervention per chapter.910The pipeline operates in three phases:11- **Phase 1 (Creative Writing, temp 0.7)**: Planner generates chapter intent with hook agenda, Composer selects relevant context, Writer produces prose with length governance, first-screen hooks, semantic density, hook-ledger payoff, and mobile paragraph rhythm guidance.12- **Phase 2 (State Settlement, temp 0.3)**: Observer over-extracts 9 categories of facts, Reflector outputs a JSON delta (not full markdown), code-layer applies Zod schema validation and immutable state update. Hook operations use upsert/mention/resolve/defer semantics.13- **Phase 3 (Quality Loop)**: Normalizer adjusts chapter length, Auditor runs 33-dimension check including hook health analysis, Reviser auto-fixes critical issues. Self-correction loop runs until all critical issues clear.1415Truth files are persisted as schema-validated JSON (`story/state/*.json`) with markdown projections for human readability. SQLite temporal memory database (`story/memory.db`) enables relevance-based retrieval on Node 22+.1617## When to Use InkOS1819- **English novel writing**: Native English support with 10 genre profiles (LitRPG, Progression Fantasy, Isekai, etc.). Set `--lang en`20- **Chinese web novel writing**: 5 built-in Chinese genres (xuanhuan, xianxia, urban, horror, other)21- **Fan fiction**: Create fanfic from source material with 4 modes (canon, au, ooc, cp)22- **Batch chapter generation**: Generate multiple chapters with consistent quality23- **Import & continue**: Import existing chapters from a text file, reverse-engineer truth files, and continue writing24- **Style imitation**: Analyze and adopt writing styles from reference texts25- **Spinoff writing**: Write prequels/sequels/spinoffs while maintaining parent canon26- **Quality auditing**: Detect AI-generated content and perform 33-dimension quality checks27- **Genre exploration**: Explore trends and create custom genre rules28- **Analytics**: Track word count, audit pass rate, and issue distribution per book2930## Initial Setup3132### First Time Setup33```bash34# Initialize a project directory (creates config structure)35inkos init my-writing-project3637# Configure your LLM provider (OpenAI, Anthropic, or any OpenAI-compatible API)38# Prefer --api-key-env so the key never appears in shell history:39export OPENAI_API_KEY=sk-xxx40inkos config set-global --provider openai --base-url https://api.openai.com/v1 --api-key-env OPENAI_API_KEY --model gpt-4o41# For compatible/proxy endpoints, use --provider custom and point ONLY to trusted endpoints:42# inkos config set-global --provider custom --base-url https://your-trusted-proxy.com/v1 --api-key-env OPENAI_API_KEY --model gpt-4o43```4445### Multi-Model Routing (Optional)46```bash47# Assign different models to different agents — balance quality and cost48inkos config set-model writer claude-sonnet-4-20250514 --provider anthropic --base-url https://api.anthropic.com --api-key-env ANTHROPIC_API_KEY49inkos config set-model auditor gpt-4o --provider openai50inkos config show-models51```52Agents without explicit overrides fall back to the global model.5354### View System Status55```bash56# Check installation and configuration57inkos doctor5859# View current config60inkos status61```6263## Common Workflows6465### Workflow 1: Create a New Novel66671. **Initialize and create book**:68 ```bash69 inkos book create --title "My Novel Title" --genre xuanhuan --chapter-words 300070 # Or with a creative brief (your worldbuilding doc / ideas):71 inkos book create --title "My Novel Title" --genre xuanhuan --chapter-words 3000 --brief my-ideas.md72 ```73 - Genres: `xuanhuan` (cultivation), `xianxia` (immortal), `urban` (city), `horror`, `other`74 - Returns a `book-id` for all subsequent operations75762. **Generate initial chapters** (e.g., 5 chapters):77 ```bash78 inkos write next book-id --count 5 --words 3000 --context "young protagonist discovering powers"79 ```80 - The `write next` command runs the full pipeline: draft → audit → revise81 - `--context` provides guidance to the Architect and Writer agents82 - Returns JSON with chapter details and quality metrics83843. **Review and approve chapters**:85 ```bash86 inkos review list book-id87 inkos review approve-all book-id88 ```89904. **Export the book** (supports txt, md, epub):91 ```bash92 inkos export book-id93 inkos export book-id --format epub94 ```9596### Workflow 2: Continue Writing Existing Novel97981. **List your books**:99 ```bash100 inkos book list101 ```1021032. **Continue from last chapter**:104 ```bash105 inkos write next book-id --count 3 --words 2500 --context "protagonist faces critical choice"106 ```107 - InkOS maintains 7 truth files (world state, character matrix, emotional arcs, etc.) for consistency108 - If only one book exists, omit `book-id` for auto-detection1091103. **Review and approve**:111 ```bash112 inkos review approve-all113 ```114115### Workflow 2.5: Shared Natural-Language Control (Recommended For OpenClaw)116117When InkOS is being driven by OpenClaw or another external agent, prefer the shared interaction executor instead of stitching together many ad-hoc CLI calls:118119```bash120inkos interact --json --message "continue the current book, but keep the pacing tighter"121inkos interact --json --message "rewrite chapter 3"122inkos interact --json --book my-book --message "switch to auto mode"123```124125This returns a structured payload containing:126- the routed request127- assistant response text128- updated interaction session129- execution state130- pending decision131- recent interaction events132133Use this as the primary OpenClaw entry because it shares the same control layer as the project TUI.134135### Workflow 2.6: Steering Chapter Focus Before Writing136137Use this when the user says things like "pull focus back to the mentor conflict", "pause the merchant guild subplot", or "change what the next chapter should prioritize".1381391. **Update the book-level control docs when needed**:140 - Use `update_author_intent` to change the long-horizon identity of the book141 - Use `update_current_focus` to change the next 1-3 chapters' focus1421432. **Compile the next chapter intent**:144 ```text145 plan_chapter(bookId, guidance?)146 ```147 - Generates `story/runtime/chapter-XXXX.intent.md`148 - Use this to verify what the system thinks the next chapter should do1491503. **Compose the actual runtime input package**:151 ```text152 compose_chapter(bookId, guidance?)153 ```154 - Generates `story/runtime/chapter-XXXX.context.json`155 - Generates `story/runtime/chapter-XXXX.rule-stack.yaml`156 - Generates `story/runtime/chapter-XXXX.trace.json`1571584. **Only then write**:159 - `write_draft` if the user wants intermediate review160 - `write_full_pipeline` if they want the usual write → audit → revise flow161162Recommended orchestration:163- user asks to redirect focus164- `update_current_focus`165- `plan_chapter`166- `compose_chapter`167- inspect the resulting intent/paths168- `write_draft` or `write_full_pipeline`169170### Workflow 3: Import Existing Chapters & Continue171172Use this when you have an existing novel (or partial novel) and want InkOS to pick up where it left off.1731741. **Import from a single text file** (auto-splits by chapter headings):175 ```bash176 inkos import chapters book-id --from novel.txt177 ```178 - Automatically splits by `第X章` pattern179 - Custom split pattern: `--split "Chapter\\s+\\d+"`1801812. **Import from a directory** of separate chapter files:182 ```bash183 inkos import chapters book-id --from ./chapters/184 ```185 - Reads `.md` and `.txt` files in sorted order1861873. **Resume interrupted import**:188 ```bash189 inkos import chapters book-id --from novel.txt --resume-from 15190 ```1911924. **Continue writing** from the imported chapters:193 ```bash194 inkos write next book-id --count 3195 ```196 - InkOS reverse-engineers all 7 truth files from the imported chapters197 - Generates a style guide from the existing text198 - New chapters maintain consistency with imported content199200### Workflow 4: Style Imitation2012021. **Analyze reference text**:203 ```bash204 inkos style analyze reference_text.txt205 ```206 - Examines vocabulary, sentence structure, tone, pacing2072082. **Import style to your book**:209 ```bash210 inkos style import reference_text.txt book-id --name "Author Name"211 ```212 - All future chapters adopt this style profile213 - Style rules become part of the Reviser's audit criteria214215### Workflow 5: Spinoff/Prequel Writing2162171. **Import parent canon**:218 ```bash219 inkos import canon spinoff-book-id --from parent-book-id220 ```221 - Creates links to parent book's world state, characters, and events222 - Reviser enforces canon consistency2232242. **Continue spinoff**:225 ```bash226 inkos write next spinoff-book-id --count 3 --context "alternate timeline after Chapter 20"227 ```228229### Workflow 6: Fine-Grained Control (Draft → Audit → Revise)230231If you need separate control over each pipeline stage:2322331. **Generate draft only**:234 ```bash235 inkos draft book-id --words 3000 --context "protagonist escapes" --json236 ```2372382. **Audit the chapter** (33-dimension quality check):239 ```bash240 inkos audit book-id chapter-1 --json241 ```242 - Returns metrics across 33 dimensions including pacing, dialogue, world-building, outline adherence, and more2432443. **Revise with specific mode**:245 ```bash246 inkos revise book-id chapter-1 --mode polish --json247 ```248 - Modes: `polish` (minor), `spot-fix` (targeted), `rewrite` (major), `rework` (structure), `anti-detect` (reduce AI traces)249250### Workflow 7: Monitor Platform Trends251252```bash253inkos radar scan254```255- Analyzes trending genres, tropes, and reader preferences256- Informs Architect recommendations for new books257258### Workflow 8: Detect AI-Generated Content259260```bash261# Detect AIGC in a specific chapter262inkos detect book-id263264# Deep scan all chapters265inkos detect book-id --all266```267- Uses 11 deterministic rules (zero LLM cost) + optional LLM validation268- Returns detection confidence and problematic passages269270### Workflow 9: View Analytics271272```bash273inkos analytics book-id --json274# Shorthand alias275inkos stats book-id --json276```277- Total chapters, word count, average words per chapter278- Audit pass rate and top issue categories279- Chapters with most issues, status distribution280- **Token usage stats**: total prompt/completion tokens, avg tokens per chapter, recent trend281282### Workflow 10: Write an English Novel283284```bash285# Create an English LitRPG novel (language auto-detected from genre)286inkos book create --title "The Last Delver" --genre litrpg --chapter-words 3000287288# Or set language explicitly289inkos book create --title "My Novel" --genre other --lang en290291# Set English as default for all projects292inkos config set-global --lang en293```294- 10 English genres: litrpg, progression, isekai, cultivation, system-apocalypse, dungeon-core, romantasy, sci-fi, tower-climber, cozy295- Each genre has dedicated pacing rules, fatigue word lists (e.g., "delve", "tapestry", "testament"), and audit dimensions296- Use `inkos genre list` to see all available genres297298### Workflow 11: Fan Fiction299300```bash301# Create a fanfic from source material302inkos fanfic init --title "My Fanfic" --from source-novel.txt --mode canon303304# Modes: canon (faithful), au (alternate universe), ooc (out of character), cp (ship-focused)305inkos fanfic init --title "What If" --from source.txt --mode au --genre other306```307- Imports and analyzes source material automatically308- Fanfic-specific audit dimensions and information boundary controls309- Ensures new content stays consistent with source canon (or deliberately diverges in au/ooc modes)310311### Workflow 12: Rename Characters or Entities Across Entire Book312313```bash314# Via interact315inkos interact --json --message "把林烬改成张三"316inkos interact --json --message "rename Lin Jin to Zhang San"317318# Via slash command319inkos interact --json --message "/rename 林烬 => 张三"320```321- Scans all chapters + all truth files (story_bible, current_state, character_matrix, etc.)322- Replaces every occurrence in one pass323- Returns count of files touched324325### Workflow 13: Patch Specific Text in a Chapter326327```bash328inkos interact --json --message "/replace 5 旧文本 => 新文本"329```330- Precisely replaces text in chapter 5 only331- Marks chapter for review after patching332333### Workflow 14: Interactive TUI Dashboard334335```bash336inkos337```338- Launches a full-screen Ink + React dashboard with conversational creation339- Slash command autocomplete (Tab), input history (arrow keys)340- Themed activity animations per operation (writing, auditing, revising, planning)341- Bilingual i18n (Chinese / English)342- Shares the same interaction kernel as `inkos interact` and Studio343344## InkOS Studio (Web Workbench)345346`inkos studio` launches a local web UI (default port 4567) that provides a visual interface for all InkOS operations:347348- **Book management** — create, delete, export (TXT/MD/EPUB), configure per-book settings349- **Chapter review & editing** — approve/reject drafts, edit content inline, multi-mode revision (polish/spot-fix/rewrite/anti-detect)350- **Real-time writing progress** — SSE-based live updates during chapter generation351- **Market radar** — AI-powered trend analysis with platform/genre recommendations352- **Analytics** — word count, audit pass rate, chapter ranking, token usage353- **AI detection** — scan chapters for AI-generated content354- **Style analysis** — analyze reference texts and import writing styles355- **Genre management** — create/customize genre profiles with fatigue words, pacing rules, audit dimensions356- **Daemon control** — start/stop background writing with event log357- **Truth file editor** — view and edit canonical knowledge base per book358- **Config editor** — LLM provider, model routing, notifications359360```bash361inkos studio # Start on default port 4567362inkos studio -p 8080 # Start on custom port363```364365The right-side **AI Assistant panel** in Studio shares the same interaction kernel as TUI and `inkos interact`. You can type natural language commands (rename entities, write chapters, audit, export) directly in the assistant panel.366367## Advanced: Natural Language Agent Mode368369For flexible, conversational requests:370371```bash372inkos agent "写一部都市题材的小说,主角是一个年轻律师,第一章三千字"373```374- Agent interprets natural language and invokes appropriate commands375- Useful for complex multi-step requests376377## Input Governance Tools378379These tools are the preferred control surface for chapter steering:380381- `plan_chapter(bookId, guidance?)`382 - Generates chapter intent for the next chapter383 - Use before writing when the user wants to change focus384385- `compose_chapter(bookId, guidance?)`386 - Generates runtime context/rule-stack/trace artifacts387 - Use after planning and before writing388389- `update_author_intent(bookId, content)`390 - Rewrites `story/author_intent.md`391 - Use for long-horizon changes to the book's identity392393- `update_current_focus(bookId, content)`394 - Rewrites `story/current_focus.md`395 - Use for local steering over the next 1-3 chapters396397`write_truth_file` remains available for broad file edits, but prefer the dedicated control tools above for input-governance changes.398399## Key Concepts400401### Book ID Auto-Detection402If your project contains only one book, most commands accept `book-id` as optional. You can omit it for brevity:403```bash404# Explicit405inkos write next book-123 --count 1406407# Auto-detected (if only one book exists)408inkos write next --count 1409```410411### --json Flag412All content-generating commands support `--json` for structured output. Essential for programmatic use:413```bash414inkos draft book-id --words 3000 --context "guidance" --json415```416417### Truth Files (Long-Term Memory)418InkOS maintains 7 files per book for coherence:419- **World State**: Maps, locations, technology levels, magic systems420- **Character Matrix**: Names, relationships, arcs, motivations421- **Resource Ledger**: In-world items, money, power levels422- **Chapter Summaries**: Events, progression, foreshadowing423- **Subplot Board**: Active and dormant subplots, hooks424- **Emotional Arcs**: Character emotional progression425- **Pending Hooks**: Unresolved cliffhangers and promises to reader426427All agents reference these to maintain long-term consistency. Since 0.6.0, truth files are backed by schema-validated JSON in `story/state/` with automatic bootstrap from markdown for legacy books. During `import chapters`, these files are reverse-engineered from existing content via the ChapterAnalyzerAgent.428429### Multi-Phase Writer Architecture430The Writer operates across multiple phases with specialized agents:431- **Planner**: Generates chapter intent with structured hook agenda (mustAdvance, eligibleResolve, staleDebt) based on memory retrieval.432- **Composer**: Selects relevant context from truth files by relevance scoring, compiles rule stack and runtime artifacts.433- **Phase 1 (Creative, temp 0.7)**: Generates prose with length governance, English variance brief (anti-repetition), and dialogue-driven guidance.434- **Phase 2a (Observer, temp 0.5)**: Over-extracts 9 categories of facts from the chapter text.435- **Phase 2b (Reflector, temp 0.3)**: Outputs a JSON delta with hookOps (upsert/mention/resolve/defer), currentStatePatch, and chapterSummary. Code-layer validates via Zod schema and applies immutably.436- **Normalizer**: Single-pass compress/expand to bring chapter length into the target band. Safety net rejects destructive normalization (>75% content loss).437- **Auditor**: 33-dimension check including hook health analysis (stale debt, burst detection, no-advance warnings).438- **Reviser**: Auto-fixes critical issues, self-correction loop until clean.439440Truth files use structured JSON (`story/state/*.json`) as the authoritative source, with markdown projections for human readability. Hook admission control prevents duplicate/family hooks from inflating the hook table.441442### Context Guidance443The `--context` parameter provides directional hints to the Writer and Architect:444```bash445inkos write next book-id --count 2 --context "protagonist discovers betrayal, must decide whether to trust mentor"446```447- Context is optional but highly recommended for narrative coherence448- Supports both English and Chinese449450## Genre Management451452### View Built-In Genres453```bash454inkos genre list455inkos genre show xuanhuan456```457458### Create Custom Genre459```bash460inkos genre create my-genre --name "My Genre"461# Options: --numerical, --power, --era462inkos genre create dark-xuanhuan --name "Dark Xuanhuan" --numerical --power463```464465### Copy Built-in Genre for Customization466```bash467inkos genre copy xuanhuan468# Copies to project genres/ directory for editing469```470471## Command Reference Summary472473| Command | Purpose | Notes |474|---------|---------|-------|475| `inkos init [name]` | Initialize project | One-time setup |476| `inkos book create` | Create new book | Returns book-id. `--brief <file>`, `--lang en/zh`, `--genre litrpg/progression/...` |477| `inkos book list` | List all books | Shows IDs, statuses |478| `inkos write next` | Full pipeline (draft→audit→revise) | Primary workflow command |479| `inkos draft` | Generate draft only | No auditing/revision |480| `inkos audit` | 33-dimension quality check | Standalone evaluation |481| `inkos revise` | Revise chapter | Modes: polish/spot-fix/rewrite/rework/anti-detect |482| `inkos agent` | Natural language interface | Flexible requests |483| `inkos style analyze` | Analyze reference text | Extracts style profile |484| `inkos style import` | Apply style to book | Makes style permanent |485| `inkos import canon` | Link spinoff to parent | For prequels/sequels |486| `inkos import chapters` | Import existing chapters | Reverse-engineers truth files for continuation |487| `inkos detect` | AIGC detection | Flags AI-generated passages |488| `inkos export` | Export finished book | Formats: txt, md, epub |489| `inkos analytics` / `inkos stats` | View book statistics | Word count, audit rates, token usage |490| `inkos radar scan` | Platform trend analysis | Informs new book ideas |491| `inkos config set-global` | Configure LLM provider | OpenAI/Anthropic/custom (any OpenAI-compatible) |492| `inkos config set-model <agent> <model>` | Set model override for a specific agent | `--provider`, `--base-url`, `--api-key-env` for multi-provider routing |493| `inkos config show-models` | Show current model routing | View per-agent model assignments |494| `inkos doctor` | Diagnose issues | Check installation |495| `inkos update` | Update to latest version | Self-update |496| `inkos up/down` | Daemon mode | Background processing. Logs to `inkos.log` (JSON Lines). `-q` for quiet mode |497| `inkos review list/approve-all` | Manage chapter approvals | Quality gate |498| `inkos fanfic init` | Create fanfic from source material | `--from <file>`, `--mode canon/au/ooc/cp` |499| `inkos genre list` | List all available genres | Shows English and Chinese genres with default language |500| `inkos genre create <id>` | Create custom genre profile | `--name`, `--numerical`, `--power`, `--era` |501| `inkos genre copy <id>` | Copy built-in genre to project | For customization |502| `inkos write rewrite <book> <ch>` | Rewrite a specific chapter | Deletes chapter and later, rewrites from that point |503| `inkos book update [book-id]` | Update book settings | `--chapter-words`, `--target-chapters`, `--status`, `--lang` |504| `inkos book delete <book-id>` | Delete book and all chapters | `--force` to skip confirmation |505| `inkos plan chapter [book-id]` | Generate chapter intent | Preview what next chapter will do before writing |506| `inkos compose chapter [book-id]` | Generate runtime artifacts | Context, rule-stack, trace for next chapter |507| `inkos consolidate [book-id]` | Consolidate chapter summaries | Reduces context for long books (volume-level summaries) |508| `inkos eval [book-id]` | Quality evaluation report | `--json`, `--chapters <range>`. Composite quality score |509| `inkos studio` | Start web workbench | `-p` for port. Local web UI for book management |510| `inkos fanfic show [book-id]` | Display parsed fanfic canon | Shows imported source material analysis |511| `inkos fanfic refresh [book-id]` | Re-import and regenerate fanfic canon | `--from <file>` for updated source material |512| `inkos interact` | Shared interaction endpoint | `--json`, `--message`, `--book`. Primary entry for OpenClaw |513| `inkos` (no args) | Launch TUI dashboard | Full-screen Ink + React interactive dashboard |514515## Error Handling516517### Common Issues518519**"book-id not found"**520- Verify the ID with `inkos book list`521- Ensure you're in the correct project directory522523**"Provider not configured"**524- Run `inkos config set-global` with valid credentials525- Check API key and base URL with `inkos doctor`526527**"Context invalid"**528- Ensure `--context` is a string (wrap in quotes if multi-word)529- Context can be in English or Chinese530531**"Audit failed"**532- Check chapter for encoding issues533- Ensure chapter-words matches actual word count534- Try `inkos revise` with `--mode rewrite`535536**"Book already has chapters" (import)**537- Use `--resume-from <n>` to append to existing chapters538- Or delete existing chapters first539540### Running Daemon Mode541542For long-running operations:543```bash544# Start background daemon545inkos up546547# Stop daemon548inkos down549550# Daemon auto-processes queued chapters551```552553## Tips for Best Results5545551. **Provide rich context**: The more guidance in `--context`, the more coherent the narrative5562. **Start with style**: If imitating an author, run `inkos style import` before generation5573. **Import first**: For existing novels, use `inkos import chapters` to bootstrap truth files before continuing5584. **Review regularly**: Use `inkos review` to catch issues early5595. **Monitor audits**: Check `inkos audit` metrics to understand quality bottlenecks5606. **Use spinoffs strategically**: Import canon before writing prequels/sequels5617. **Batch generation**: Generate multiple chapters together (better continuity)5628. **Check analytics**: Use `inkos analytics` to track quality trends over time5639. **Export frequently**: Keep backups with `inkos export`564565## Security & Trust566567- **License**: the ClawHub skill descriptor is MIT-0 per platform policy, but the underlying `@actalk/inkos`, `@actalk/inkos-core`, and `@actalk/inkos-studio` npm packages are **AGPL-3.0-only**. Running InkOS and distributing modified versions are governed by AGPL. Full source on GitHub for auditability.568- **No install hooks**: npm package has no `preinstall`/`postinstall`/`install` scripts. Install is inert.569- **Local-only file I/O**: all read/write stays inside the project directory (`books/*`, `inkos.json`, `inkos.log`). No writes outside the working directory.570- **No telemetry**: InkOS does not phone home, collect usage stats, or ship any data to InkOS-controlled servers. The only outbound traffic is to the LLM provider endpoint you explicitly configure.571- **Credential handling**: always prefer `--api-key-env <VAR_NAME>` over `--api-key <literal>` so keys never hit shell history. Keys are stored in `inkos.json` under your project directory — treat it like a secret and add it to `.gitignore` if you commit the project.572- **Custom provider base-URL**: `--provider custom` forwards your API key to whatever URL you specify. Only point it at endpoints you trust (your own proxy or an audited reverse-proxy). Never paste an untrusted `--base-url`.573- **No elevated privileges**: InkOS requires no sudo, no global state mutation, no network listening port (Studio binds `localhost:4567` only).574575## Support & Resources576577- **Homepage**: https://github.com/Narcooo/inkos578- **Configuration**: Stored in project root after `inkos init`579- **Truth files**: Located in `books/<id>/story/` per book, with structured JSON in `story/state/`580- **Logs**: Check output of `inkos doctor` for troubleshooting