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:
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+.
--lang enbash
# 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
bash
# 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.
bash
# Check installation and configuration
inkos doctor
# View current config
inkos status
Initialize and create book: bash
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
xuanhuan (cultivation), xianxia (immortal), urban (city), horror, otherbook-id for all subsequent operationsGenerate initial chapters (e.g., 5 chapters): bash
inkos write next book-id --count 5 --words 3000 --context "young protagonist discovering powers"
write next command runs the full pipeline: draft → audit → revise--context provides guidance to the Architect and Writer agentsReview and approve chapters: bash
inkos review list book-id
inkos review approve-all book-id
Export the book (supports txt, md, epub): bash
inkos export book-id
inkos export book-id --format epub
List your books: bash
inkos book list
Continue from last chapter: bash
inkos write next book-id --count 3 --words 2500 --context "protagonist faces critical choice"
book-id for auto-detectionReview and approve: bash
inkos review approve-all
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:
bash
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:
Use this as the primary OpenClaw entry because it shares the same control layer as the project TUI.
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:
update_author_intent to change the long-horizon identity of the bookupdate_current_focus to change the next 1-3 chapters' focusCompile the next chapter intent: text
plan_chapter(bookId, guidance?)
story/runtime/chapter-XXXX.intent.mdCompose the actual runtime input package: text
compose_chapter(bookId, guidance?)
story/runtime/chapter-XXXX.context.jsonstory/runtime/chapter-XXXX.rule-stack.yamlstory/runtime/chapter-XXXX.trace.jsonOnly then write:
write_draft if the user wants intermediate reviewwrite_full_pipeline if they want the usual write → audit → revise flowRecommended orchestration:
update_current_focusplan_chaptercompose_chapterwrite_draft or write_full_pipelineUse 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): bash
inkos import chapters book-id --from novel.txt
第X章 pattern--split "Chapter\\s+\\d+"Import from a directory of separate chapter files: bash
inkos import chapters book-id --from ./chapters/
.md and .txt files in sorted orderResume interrupted import: bash
inkos import chapters book-id --from novel.txt --resume-from 15
Continue writing from the imported chapters: bash
inkos write next book-id --count 3
Analyze reference text: bash
inkos style analyze reference_text.txt
Import style to your book: bash
inkos style import reference_text.txt book-id --name "Author Name"
Import parent canon: bash
inkos import canon spinoff-book-id --from parent-book-id
Continue spinoff: bash
inkos write next spinoff-book-id --count 3 --context "alternate timeline after Chapter 20"
If you need separate control over each pipeline stage:
Generate draft only: bash
inkos draft book-id --words 3000 --context "protagonist escapes" --json
Audit the chapter (33-dimension quality check): bash
inkos audit book-id chapter-1 --json
Revise with specific mode: bash
inkos revise book-id chapter-1 --mode polish --json
polish (minor), spot-fix (targeted), rewrite (major), rework (structure), anti-detect (reduce AI traces)bash
inkos radar scan
bash
# Detect AIGC in a specific chapter
inkos detect book-id
# Deep scan all chapters
inkos detect book-id --all
bash
inkos analytics book-id --json
# Shorthand alias
inkos stats book-id --json
bash
# 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
inkos genre list to see all available genresbash
# 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
bash
# Via interact
inkos interact --json --message "把林烬改成张三"
inkos interact --json --message "rename Lin Jin to Zhang San"
# Via slash command
inkos interact --json --message "/rename 林烬 => 张三"
bash
inkos interact --json --message "/replace 5 旧文本 => 新文本"
bash
inkos
inkos interact and Studioinkos studio launches a local web UI (default port 4567) that provides a visual interface for all InkOS operations:
bash
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.
For flexible, conversational requests:
bash
inkos agent "写一部都市题材的小说,主角是一个年轻律师,第一章三千字"
These tools are the preferred control surface for chapter steering:
plan_chapter(bookId, guidance?)
compose_chapter(bookId, guidance?)
update_author_intent(bookId, content)
story/author_intent.mdupdate_current_focus(bookId, content)
story/current_focus.mdwrite_truth_file remains available for broad file edits, but prefer the dedicated control tools above for input-governance changes.
If your project contains only one book, most commands accept book-id as optional. You can omit it for brevity:
bash
# Explicit
inkos write next book-123 --count 1
# Auto-detected (if only one book exists)
inkos write next --count 1
All content-generating commands support --json for structured output. Essential for programmatic use:
bash
inkos draft book-id --words 3000 --context "guidance" --json
InkOS maintains 7 files per book for coherence:
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.
The Writer operates across multiple phases with specialized agents:
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.
The --context parameter provides directional hints to the Writer and Architect:
bash
inkos write next book-id --count 2 --context "protagonist discovers betrayal, must decide whether to trust mentor"
bash
inkos genre list
inkos genre show xuanhuan
bash
inkos genre create my-genre --name "My Genre"
# Options: --numerical, --power, --era
inkos genre create dark-xuanhuan --name "Dark Xuanhuan" --numerical --power
bash
inkos genre copy xuanhuan
# Copies to project genres/ directory for editing
CommandPurposeNotesinkos init [name]Initialize projectOne-time setupinkos book createCreate new bookReturns book-id. --brief <file>, --lang en/zh, --genre litrpg/progression/...``inkos book listList all booksShows IDs, statusesinkos write nextFull pipeline (draft→audit→revise)Primary workflow commandinkos draftGenerate draft onlyNo auditing/revisioninkos audit33-dimension quality checkStandalone evaluationinkos reviseRevise chapterModes: polish/spot-fix/rewrite/rework/anti-detectinkos agentNatural language interfaceFlexible requestsinkos style analyzeAnalyze reference textExtracts style profileinkos style importApply style to bookMakes style permanentinkos import canonLink spinoff to parentFor prequels/sequelsinkos import chaptersImport existing chaptersReverse-engineers truth files for continuationinkos detectAIGC detectionFlags AI-generated passagesinkos exportExport finished bookFormats: txt, md, epubinkos analytics / inkos statsView book statisticsWord count, audit rates, token usageinkos radar scanPlatform trend analysisInforms new book ideasinkos config set-globalConfigure LLM providerOpenAI/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 routinginkos config show-modelsShow current model routingView per-agent model assignmentsinkos doctorDiagnose issuesCheck installationinkos updateUpdate to latest versionSelf-updateinkos up/downDaemon modeBackground processing. Logs to inkos.log (JSON Lines). -q for quiet modeinkos review list/approve-allManage chapter approvalsQuality gateinkos fanfic initCreate fanfic from source material--from <file>, --mode canon/au/ooc/cp``inkos genre listList all available genresShows English and Chinese genres with default languageinkos genre create <id>Create custom genre profile--name, --numerical, --power, --era``inkos genre copy <id>Copy built-in genre to projectFor customizationinkos write rewrite <book> <ch>Rewrite a specific chapterDeletes chapter and later, rewrites from that pointinkos 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 confirmationinkos plan chapter [book-id]Generate chapter intentPreview what next chapter will do before writinginkos compose chapter [book-id]Generate runtime artifactsContext, rule-stack, trace for next chapterinkos consolidate [book-id]Consolidate chapter summariesReduces context for long books (volume-level summaries)inkos eval [book-id]Quality evaluation report--json, --chapters <range>. Composite quality scoreinkos studioStart web workbench-p for port. Local web UI for book managementinkos fanfic show [book-id]Display parsed fanfic canonShows imported source material analysisinkos fanfic refresh [book-id]Re-import and regenerate fanfic canon--from <file> for updated source materialinkos interactShared interaction endpoint--json, --message, --book. Primary entry for OpenClawinkos (no args)Launch TUI dashboardFull-screen Ink + React interactive dashboard
"book-id not found"
inkos book list"Provider not configured"
inkos config set-global with valid credentialsinkos doctor"Context invalid"
--context is a string (wrap in quotes if multi-word)"Audit failed"
inkos revise with --mode rewrite"Book already has chapters" (import)
--resume-from <n> to append to existing chaptersFor long-running operations:
bash
# Start background daemon
inkos up
# Stop daemon
inkos down
# Daemon auto-processes queued chapters
--context, the more coherent the narrativeinkos style import before generationinkos import chapters to bootstrap truth files before continuinginkos review to catch issues earlyinkos audit metrics to understand quality bottlenecksinkos analytics to track quality trends over timeinkos export@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.preinstall/ postinstall/ install scripts. Install is inert.books/*, inkos.json, inkos.log). No writes outside the working directory.--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.--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.localhost:4567 only).inkos initbooks/<id>/story/ per book, with structured JSON in story/state/inkos doctor for troubleshooting