InkOS - Story Creation AI Agent
InkOS is a story creation and multilingual translation AI agent for long-form novels, short fiction, scripts, storyboards, interactive-film projects, fan works, continuations, covers, open-world / branching interactive play, and long-document localization. Prefer the Studio Chat / action-surface workflow for natural-language requests: the model proposes or invokes typed actions, InkOS executes them, and completion is derived from real tool results and files, not from prose claims.
Long-form writing still uses the chapter pipeline internally:
- Input governance: Architect / Planner / Composer preserve author intent, current focus, outline sections, and relevant truth files instead of injecting everything blindly.
- Writing: Writer produces prose with length governance, craft rules, and context selected for the current task.
- Settlement and review: Observer / Reflector update runtime state; Auditor checks continuity and quality; Reviser handles critical issues. The default write cycle keeps automatic repair conservative and leaves unresolved issues visible for human or agent follow-up.
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+.
Persisted story memory is isolated to its project and book, excludes credentials and unrelated files, and is never reused across projects unless the user explicitly imports material. Users can inspect or delete the owning book/project through Studio or CLI.
v1.8.0 Mental Model
Treat InkOS as a pi-agent-centered production harness, not a bag of prompt shortcuts or parallel pipelines. The model interprets requests and emits typed actions; the host owns confirmation, deterministic tools, state, atomic persistence, and artifact truth. Standard AgentSkills / OpenClaw SKILL.md packages provide medium-specific craft and static references, but they never grant execution permissions.
- Natural-language requests should go through Studio Chat / TUI /
inkos interact whenever possible.
- Production workers for long fiction, short fiction, scripts, storyboards, interactive film, Play, and translation use the same harness contract while binding different built-in Skills. Share the architecture, not long-form-specific prompts.
- Pipelines and atomic CLI commands are deterministic host capabilities. Do not create a second natural-language router around them.
- Do not infer success from assistant prose. A book, short, cover, or play step is complete only when the corresponding tool result and files exist.
- Use
short_fiction_run only for a standalone short-fiction package.
- Use
generate_cover only for cover generation/regeneration.
- Use
play_start / play_step for Open World or Branching Interactive sessions.
- Use script / storyboard / interactive-film tools only for production artifacts that should be saved and exported, not for casual discussion.
- Use the translation project workflow for EPUB, text-based PDF, TXT, or Markdown localization. Keep source and target languages, glossary, review report, and export format explicit; do not replace it with an ad hoc one-turn translation when the user wants a complete deliverable.
- Use
research_web only when the user explicitly asks for external facts, market references, era/profession details, or worldbuilding research. Research reports are reference material and do not automatically mutate canon or prose.
- Use long-form chapter tools only for existing long-form books.
- Use narrative forecasts when the author wants to compare possible long-form directions before writing. A forecast is non-canonical planning material: selecting a branch may write
selected-branch-plan.md, but it must not be described as changing prose, outlines, or canonical state.
- A running production task does not prevent ordinary discussion, but do not start another conflicting book mutation until that task reaches a terminal state.
- Agent Skills provide professional guidance and static references. They do not grant new file, network, image, or writing permissions by themselves.
- Story memory, archived material, and Skill references share the local FTS5 / BM25 retrieval kernel. Source files remain authoritative; retrieved excerpts should retain source pointers.
- Bind reusable imported material to a book with explicit intended uses instead of repeatedly injecting every source file in full.
- Chapter prose, state, hooks, and run snapshots should commit through the safe chapter workspace / atomic file-set boundary. Never report completion from a partially persisted run.
- Context is governed: protected facts and current intent should not be silently compressed away; compressible history may be summarized when the context budget is tight.
- Studio Chat can receive user-uploaded text / Markdown / image attachments. Text attachments are injected into the LLM context; image attachments require a vision-capable model.
- External materials can be archived and retrieved later with evidence traces instead of relying on ad hoc pasted context.
- Prompt packs are user-tunable in Studio Project Settings. Project overrides are saved under
prompt/<pack>/<prompt>.md; do not edit generated artifacts just to change system behavior.
- Long-form chapter revision from Chat passes the current user instruction into the reviser as a one-off brief. If the revision is not applied, inspect the returned gate metrics and remaining audit issues before claiming it was fixed.
v1.7 added multilingual translation/localization, narrative forecasting, background production, import, configurable review gates, recoverable locks, material archives, and standard Agent Skills. v1.8 unifies production around the pi-agent harness, adds medium-specific built-in Skills, shared FTS5 / BM25 retrieval, book-bound references, safe chapter workspaces, cross-format run snapshots, and TUI confirmation/model controls. Still surface unresolved review or execution issues plainly instead of claiming they were fixed.
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
- Standalone short fiction: Generate a complete short-fiction package with outline, draft, review artifacts, synopsis, selling points, and optional cover image
- Cover generation: Generate or regenerate only a cover prompt and cover image from a title, synopsis, or visual direction without rerunning story writing
- Interactive worlds: Start Open World or Branching Interactive sessions with world contracts, character agents, inventory/evidence/relationship state, guided choices, free actions, and optional image generation
- Interactive-film projects: Create playable branch graphs, variables/flags, relationship state, endings, node images, and exportable interactive project packages
- Scripts and storyboards: Convert ideas, outlines, or prose into script/storyboard deliverables while preserving user format choices
- Long-document translation: Translate EPUB, text-based PDF, TXT, or Markdown by chapter and semantic segment, maintain terminology, review source and target side by side, and export TXT/Markdown/EPUB
- Agent Skills: Load standard AgentSkills/OpenClaw or project-local
SKILL.md packages; let the Chat Agent invoke them from user intent, or force one with @skill-id
- Traceable web research: Create sourced Markdown reports for facts, era/profession details, markets, and worldbuilding references
- 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
InkOS requires Node.js 22 or later.
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.
Provider setup tip
When the user needs an aggregator provider, point them to Studio's service settings. InkOS includes kkaiapi and OpenRouter as optional aggregator choices. For kkaiapi, use:
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 structured runtime state, readable Markdown projections, control docs, and temporal memory 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 --message "start an open-world detective game about a locked archive room"
The current JSON payload contains:
- assistant response text
- interaction session id / session kind / active book id when bound
Real completion still comes from tool results and files. Do not treat assistant prose alone as proof that a book, chapter, short, cover, or play step was created.
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 2.7: Compare Long-Form Directions Before Writing
Use a narrative forecast when the author wants to inspect several plausible futures without committing any of them to canon.
- Create isolated candidates from the current book state:
inkos forecast create book-id --divergence "Does the protagonist reveal the evidence now?" --branches 3 --horizon 5
- Compare the branch cards in Studio Chat, or inspect the saved comparison with
inkos forecast show [book-id] <forecast-id>.
- Re-check the forecast before relying on it. Canon changes mark the forecast stale.
- Select one candidate with the Studio card or:
inkos forecast select book-id forecast-id branch-2
Selection writes only story/runtime/narrative-forecasts/<forecast-id>/selected-branch-plan.md. It does not apply the plan to chapter prose, outlines, author intent, or canonical state. Any later application remains a separate explicit authoring action.
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 rebuilds structured state, chapter summaries, hooks, character relationships, readable projections, and a style guide 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 documented for agent use:
polish (minor), spot-fix (targeted), rewrite (major), and rework (structure)
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: Edit Persistent Text Through Chat
Use Studio Chat or inkos interact for small, explicit edits to generated text artifacts. Treat the chat layer like an external editor: it may edit persisted files, then the writing pipeline can continue from the updated state.
inkos interact --book my-book --json --message "把第 3 章里那句过长的解释删短一点,但不要改剧情事实"
inkos interact --json --message "把 covers/demo/cover-prompt.md 里的人物拉近一点,标题字更大"
- Use for clear text edits, cover prompt edits, and control-document edits.
- Do not infer success from the assistant's prose; check the tool result or changed file.
- For broad story direction changes, prefer updating
author_intent.md / current_focus.md, then run plan / compose before writing.
Workflow 13: Explicit Rename / Replacement Requests
When the user asks for a rename or targeted replacement, keep the request explicit and scoped. Prefer Studio Chat / inkos interact over hidden slash shortcuts; the agent should route the edit through the shared action surface and report which file changed.
Examples:
- "把当前书里角色 林烬 改成 张三,先说明会影响哪些文件。"
- "只改第 5 章,把这句旧文本换成新文本,改完标记需要复核。"
Workflow 14: Interactive TUI Dashboard
inkos tui
- Launches a full-screen Ink + React dashboard with conversational creation
- Slash command autocomplete (Tab), input history (arrow keys)
- Uses explicit
/new, /short, /play, /cover, and /write surfaces; /confirm and /cancel resolve structured proposals without rerunning intent detection
/model <name> changes the model for the current TUI session; ordinary text that merely discusses models remains a normal Agent turn
- Adapts text colors to light or dark terminal backgrounds (
INKOS_TUI_THEME can override detection)
- Themed activity animations per operation (writing, auditing, revising, planning)
- Bilingual i18n (Chinese / English)
- Shares the same interaction kernel as
inkos interact and Studio
Workflow 15: Standalone Short Fiction Package
Use this when the user wants a complete short story or short-fiction deliverable that is separate from the active long-form book.
inkos short run \
--direction "modern short fiction marriage reversal evidence-driven heroine" \
--chapters 12 \
--chars 1000
Outputs are written under shorts/<story-name>/final/:
full.md — complete short-fiction manuscript
sales-package.md — synopsis and selling points
cover-prompt.md — cover prompt
cover.png — cover image when a cover provider is configured
For OpenClaw/Studio/agent orchestration, call the short_fiction_run tool when the user asks for a new complete short-fiction package. Do not use it for the next chapter of an existing long-form book.
Workflow 16: Standalone Cover Tool
Use this when the user only wants a cover for an existing title, synopsis, or visual direction. Do not rerun the short-fiction pipeline.
In Studio or agent mode, ask naturally:
Generate a short-fiction cover for "The Divorce Papers He Regretted", modern city, high-drama reversal.
For tool-using agents, call generate_cover with:
title — required
intro or sellingPoints — optional story context
coverPrompt — optional visual direction
outputDir — optional; defaults to covers/<title>/
The standalone cover tool writes:
covers/<title>/cover-prompt.md
covers/<title>/cover.png
If cover image generation fails, report the provider/configuration error plainly. Do not rewrite the story, do not rerun short_fiction_run, and do not suggest unrelated external tools unless the user asks.
Workflow 17: Open World / Branching Interactive Play
Use this when the user wants to play inside an interactive world instead of generating a finished manuscript.
In Studio or agent mode, ask naturally:
Create a Warcraft-like border watchtower open world. Time can advance differently by action: patrols take an hour, training can take days. Equipment should show rarity through material and atmosphere, not stat blocks.
For tool-using agents:
- Call
play_start when there is no active world/run yet, or when the user explicitly asks to start a new world.
- Call
play_step when the user performs an action inside an existing world.
- Keep Open World free-form: do not force clickable choices unless the current session is Branching Interactive.
- If the user changes world rules, persona, visual contract, or character behavior, treat it as a world-state edit or a new instruction for the next step, not as long-form chapter writing.
- If image generation is configured, let Play generate scene / character / item / evidence images through the Play image path. Do not call the short-fiction cover tool for Play scene images.
Workflow 18: Agent Skills
Use this when the user wants reusable professional rules, a domain-specific writing mode, or a forced capability for the current Chat turn.
Project-local skills live at:
.agents/skills/<skill-id>/SKILL.md
InkOS also discovers standard AgentSkills / OpenClaw locations (skills/, .agents/skills/, ~/.agents/skills/, and ~/.openclaw/skills/). Studio can import a complete skill folder with its static reference files.
External skill directories can be loaded with:
export INKOS_SKILL_DIRS=/abs/path/to/skills
Guidelines for agent orchestration:
- Let the Chat Agent inspect the available skill catalog and call
use_skill when the current user intent needs that expertise. Do not emulate this with session-kind routing, keyword lists, or substring matching.
- Force a skill by including
@skill-id in the user message when the user explicitly chooses one.
- Treat skills as standard expertise packets containing instructions and static references. Prompt packs and governed context recipes are separate InkOS systems.
- Skill folders may contain static references. Read them only when needed, and never auto-execute bundled scripts.
- Do not treat skills as permissions. File edits, book creation, chapter writing, image generation, and exports still require the normal InkOS tools and confirmation gates.
Workflow 18.5: Book-Bound Reference Material
Use this when imported material should influence one book over multiple future turns without becoming canon or being injected in full every time.
- Archive the source with
ingest_material; keep the returned material id.
- On the active book, call
manage_book_reference with action=bind, that material id, concrete uses, and an optional limiting note.
- Let Planner / Composer / Writer retrieve relevant passages through the shared local search index. Source files remain authoritative and retrieval keeps source pointers.
- Use
manage_book_reference with action=list to inspect bindings or action=unbind to detach one without deleting the project asset.
Binding a reference does not make it canon and does not authorize copying its expression. Canon changes still require the normal explicit edit path.
Workflow 19: Traceable Web Research
Use this when the user asks for real-world references, external facts, era/profession details, market references, or worldbuilding research.
For tool-using agents, call research_web with:
topic — the research question
purpose — worldbuilding, era, profession, market, fact-check, or general
depth — optional: quick, standard, or deep
The tool writes a Markdown report under:
.inkos/research/
The report includes sources, claims, unknowns, conflicts, query logs, and confidence. It is reference material only. If research should change canon, wait for explicit user confirmation and then use the normal truth-file editing path.
Search credentials are user/project supplied. Studio can configure a Tavily-compatible search API, or the server can use TAVILY_API_KEY from the environment.
Workflow 20: Script, Storyboard, and Interactive-Film Creation
Use this when the user wants a production artifact rather than a casual answer:
- Script: dramatic scenes, dialogue, acts, episode structure, or format-specific script drafts.
- Storyboard: visual beats, shot descriptions, image prompts, and scene-by-scene production notes.
- Interactive film: branch graph, choices, variables/flags, relationship state, endings, node images, and exportable project package.
In Studio Chat, these actions should be proposed with a confirmation card first. After confirmation, InkOS writes the artifact and reports the saved files. Do not hand-write a fake "created" result in prose.
Workflow 21: Multilingual Translation / Localization
Use a translation project when the user wants a complete, reviewable deliverable rather than a one-off translated paragraph. Inputs can be EPUB, text-based PDF, TXT, or Markdown; source and target languages can be written as normal language names in Studio.
inkos translate init --from ./source.epub --source Chinese --target English
inkos translate run <project-id>
inkos translate export <project-id> --format epub
- Preserve the project glossary and chapter boundaries across translation batches.
- Review source and translation side by side; treat the generated review report as the quality record.
- Export TXT, Markdown, or EPUB only after the requested segments are complete.
- For scanned PDFs without a text layer, run OCR before importing; InkOS currently reads text-based PDFs.
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
- Short fiction & cover tools — generate independent short-fiction packages, synopsis/selling points, cover prompts, and standalone covers
- Open World / Branching Interactive — start and continue interactive worlds with world contracts, free actions, clickable choices, HUD state, and image generation
- Interactive-film workbench — create and inspect branch nodes, variables/flags, endings, node images, and export packages
- Script / storyboard tools — generate production-oriented script and storyboard files from ideas, prose, or reference notes
- Translation workbench — import EPUB, text-based PDF, TXT, or Markdown; choose source and target languages; translate, compare, review, and export complete projects
- Agent Skills management — list standard skills, import AgentSkills/OpenClaw folders with static references into
.agents/skills/, let Chat invoke skills from intent, and force skills from Chat
- Research search provider — configure external web search API credentials for
research_web
- Chapter review & editing — approve/reject drafts, edit content inline, and revise with polish/spot-fix/rewrite/rework modes
- 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, cover/image services, notifications
inkos studio # Start on default port 4567
inkos studio -p 8080 # Start on custom port
The Studio Chat surface shares the same action kernel as TUI and CLI. It can answer questions, propose/confirm creation and translation actions, run Short, generate covers, start Play, import existing novels, edit persistent text artifacts, and invoke long-form writing operations.
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
Creative, Research, and Play Agent Tools
These are the preferred tools when InkOS is driven by OpenClaw, Studio chat, or inkos agent:
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
Long-Term Memory
InkOS maintains each book's memory in three layers:
- Structured state:
story/state/*.json is the authoritative runtime state, validated by Zod schemas.
- Readable projections:
current_state.md, pending_hooks.md, chapter_summaries.md, character_matrix.md, and related Markdown files are for humans and debugging.
- Temporal memory:
story/memory.db on Node 22+ supports relevance-based retrieval of facts, hooks, and chapter summaries.
Agents use the governed composer to select the relevant parts for the current task instead of blindly injecting every file. During import chapters, InkOS rebuilds structured state and projections 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 structured state, control docs, readable projections, and retrieval results, then 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: Attempts one configured repair pass for critical issues, then keeps unresolved findings visible for human or agent follow-up.
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 documented for agent use: polish/spot-fix/rewrite/rework |
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 short run |
Generate standalone short fiction |
Outputs manuscript, sales package, cover prompt, optional cover |
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, `-- |
…(truncated)
1---2name: inkos3description: Story Creation and Translation AI Agent with Studio Chat, CLI, and TUI - use for long-form novels, short fiction, scripts, storyboards, interactive-film projects, open-world / branching play, fan fiction, spinoffs, style imitation, continuations, covers, and multilingual EPUB/PDF/TXT/Markdown translation. Includes Agent Skills, traceable research, governed context, persistent story state, multi-model routing, image services, and InkOS Studio.4---5
6# InkOS - Story Creation AI Agent
7
8InkOS is a story creation and multilingual translation AI agent for long-form novels, short fiction, scripts, storyboards, interactive-film projects, fan works, continuations, covers, open-world / branching interactive play, and long-document localization. Prefer the Studio Chat / action-surface workflow for natural-language requests: the model proposes or invokes typed actions, InkOS executes them, and completion is derived from real tool results and files, not from prose claims.
9
10Long-form writing still uses the chapter pipeline internally:
11- **Input governance**: Architect / Planner / Composer preserve author intent, current focus, outline sections, and relevant truth files instead of injecting everything blindly.
12- **Writing**: Writer produces prose with length governance, craft rules, and context selected for the current task.
13- **Settlement and review**: Observer / Reflector update runtime state; Auditor checks continuity and quality; Reviser handles critical issues. The default write cycle keeps automatic repair conservative and leaves unresolved issues visible for human or agent follow-up.
14
15Truth 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+.
16Persisted story memory is isolated to its project and book, excludes credentials and unrelated files, and is never reused across projects unless the user explicitly imports material. Users can inspect or delete the owning book/project through Studio or CLI.
17
18## v1.8.0 Mental Model
19
20Treat InkOS as a pi-agent-centered production harness, not a bag of prompt shortcuts or parallel pipelines. The model interprets requests and emits typed actions; the host owns confirmation, deterministic tools, state, atomic persistence, and artifact truth. Standard AgentSkills / OpenClaw `SKILL.md` packages provide medium-specific craft and static references, but they never grant execution permissions.
21
22- Natural-language requests should go through Studio Chat / TUI / `inkos interact` whenever possible.
23- Production workers for long fiction, short fiction, scripts, storyboards, interactive film, Play, and translation use the same harness contract while binding different built-in Skills. Share the architecture, not long-form-specific prompts.
24- Pipelines and atomic CLI commands are deterministic host capabilities. Do not create a second natural-language router around them.
25- Do not infer success from assistant prose. A book, short, cover, or play step is complete only when the corresponding tool result and files exist.
26- Use `short_fiction_run` only for a standalone short-fiction package.
27- Use `generate_cover` only for cover generation/regeneration.
28- Use `play_start` / `play_step` for Open World or Branching Interactive sessions.
29- Use script / storyboard / interactive-film tools only for production artifacts that should be saved and exported, not for casual discussion.
30- Use the translation project workflow for EPUB, text-based PDF, TXT, or Markdown localization. Keep source and target languages, glossary, review report, and export format explicit; do not replace it with an ad hoc one-turn translation when the user wants a complete deliverable.
31- Use `research_web` only when the user explicitly asks for external facts, market references, era/profession details, or worldbuilding research. Research reports are reference material and do not automatically mutate canon or prose.
32- Use long-form chapter tools only for existing long-form books.
33- Use narrative forecasts when the author wants to compare possible long-form directions before writing. A forecast is non-canonical planning material: selecting a branch may write `selected-branch-plan.md`, but it must not be described as changing prose, outlines, or canonical state.
34- A running production task does not prevent ordinary discussion, but do not start another conflicting book mutation until that task reaches a terminal state.
35- Agent Skills provide professional guidance and static references. They do not grant new file, network, image, or writing permissions by themselves.
36- Story memory, archived material, and Skill references share the local FTS5 / BM25 retrieval kernel. Source files remain authoritative; retrieved excerpts should retain source pointers.
37- Bind reusable imported material to a book with explicit intended uses instead of repeatedly injecting every source file in full.
38- Chapter prose, state, hooks, and run snapshots should commit through the safe chapter workspace / atomic file-set boundary. Never report completion from a partially persisted run.
39- Context is governed: protected facts and current intent should not be silently compressed away; compressible history may be summarized when the context budget is tight.
40- Studio Chat can receive user-uploaded text / Markdown / image attachments. Text attachments are injected into the LLM context; image attachments require a vision-capable model.
41- External materials can be archived and retrieved later with evidence traces instead of relying on ad hoc pasted context.
42- Prompt packs are user-tunable in Studio Project Settings. Project overrides are saved under `prompt/<pack>/<prompt>.md`; do not edit generated artifacts just to change system behavior.
43- Long-form chapter revision from Chat passes the current user instruction into the reviser as a one-off brief. If the revision is not applied, inspect the returned gate metrics and remaining audit issues before claiming it was fixed.
44
45v1.7 added multilingual translation/localization, narrative forecasting, background production, import, configurable review gates, recoverable locks, material archives, and standard Agent Skills. v1.8 unifies production around the pi-agent harness, adds medium-specific built-in Skills, shared FTS5 / BM25 retrieval, book-bound references, safe chapter workspaces, cross-format run snapshots, and TUI confirmation/model controls. Still surface unresolved review or execution issues plainly instead of claiming they were fixed.
46
47## When to Use InkOS
48
49- **English novel writing**: Native English support with 10 genre profiles (LitRPG, Progression Fantasy, Isekai, etc.). Set `--lang en`
50- **Chinese web novel writing**: 5 built-in Chinese genres (xuanhuan, xianxia, urban, horror, other)
51- **Fan fiction**: Create fanfic from source material with 4 modes (canon, au, ooc, cp)
52- **Batch chapter generation**: Generate multiple chapters with consistent quality
53- **Import & continue**: Import existing chapters from a text file, reverse-engineer truth files, and continue writing
54- **Style imitation**: Analyze and adopt writing styles from reference texts
55- **Spinoff writing**: Write prequels/sequels/spinoffs while maintaining parent canon
56- **Standalone short fiction**: Generate a complete short-fiction package with outline, draft, review artifacts, synopsis, selling points, and optional cover image
57- **Cover generation**: Generate or regenerate only a cover prompt and cover image from a title, synopsis, or visual direction without rerunning story writing
58- **Interactive worlds**: Start Open World or Branching Interactive sessions with world contracts, character agents, inventory/evidence/relationship state, guided choices, free actions, and optional image generation
59- **Interactive-film projects**: Create playable branch graphs, variables/flags, relationship state, endings, node images, and exportable interactive project packages
60- **Scripts and storyboards**: Convert ideas, outlines, or prose into script/storyboard deliverables while preserving user format choices
61- **Long-document translation**: Translate EPUB, text-based PDF, TXT, or Markdown by chapter and semantic segment, maintain terminology, review source and target side by side, and export TXT/Markdown/EPUB
62- **Agent Skills**: Load standard AgentSkills/OpenClaw or project-local `SKILL.md` packages; let the Chat Agent invoke them from user intent, or force one with `@skill-id`
63- **Traceable web research**: Create sourced Markdown reports for facts, era/profession details, markets, and worldbuilding references
64- **Quality auditing**: Detect AI-generated content and perform 33-dimension quality checks
65- **Genre exploration**: Explore trends and create custom genre rules
66- **Analytics**: Track word count, audit pass rate, and issue distribution per book
67
68## Initial Setup
69
70InkOS requires Node.js 22 or later.
71
72### First Time Setup
73```bash
74# Initialize a project directory (creates config structure)
75inkos init my-writing-project
76
77# Configure your LLM provider (OpenAI, Anthropic, or any OpenAI-compatible API)
78# Prefer --api-key-env so the key never appears in shell history:
79export OPENAI_API_KEY=sk-xxx
80inkos config set-global --provider openai --base-url https://api.openai.com/v1 --api-key-env OPENAI_API_KEY --model gpt-4o
81# For compatible/proxy endpoints, use --provider custom and point ONLY to trusted endpoints:
82# inkos config set-global --provider custom --base-url https://your-trusted-proxy.com/v1 --api-key-env OPENAI_API_KEY --model gpt-4o
83```
84
85### Multi-Model Routing (Optional)
86```bash
87# Assign different models to different agents — balance quality and cost
88inkos config set-model writer claude-sonnet-4-20250514 --provider anthropic --base-url https://api.anthropic.com --api-key-env ANTHROPIC_API_KEY
89inkos config set-model auditor gpt-4o --provider openai
90inkos config show-models
91```
92Agents without explicit overrides fall back to the global model.
93
94### Provider setup tip
95
96When the user needs an aggregator provider, point them to Studio's service settings. InkOS includes kkaiapi and OpenRouter as optional aggregator choices. For kkaiapi, use:
97- Chinese website: https://kkaiapi.com/
98- English website: https://en.kkaiapi.com/
99- Chinese API docs: https://kkaiapi.com/docs
100- English API docs: https://en.kkaiapi.com/docs
101- Chinese models/pricing: https://kkaiapi.com/models
102- English models/pricing: https://en.kkaiapi.com/models
103
104### View System Status
105```bash
106# Check installation and configuration
107inkos doctor
108
109# View current config
110inkos status
111```
112
113## Common Workflows
114
115### Workflow 1: Create a New Novel
116
1171. **Initialize and create book**:
118 ```bash
119 inkos book create --title "My Novel Title" --genre xuanhuan --chapter-words 3000
120 # Or with a creative brief (your worldbuilding doc / ideas):
121 inkos book create --title "My Novel Title" --genre xuanhuan --chapter-words 3000 --brief my-ideas.md
122 ```
123 - Genres: `xuanhuan` (cultivation), `xianxia` (immortal), `urban` (city), `horror`, `other`
124 - Returns a `book-id` for all subsequent operations
125
1262. **Generate initial chapters** (e.g., 5 chapters):
127 ```bash
128 inkos write next book-id --count 5 --words 3000 --context "young protagonist discovering powers"
129 ```
130 - The `write next` command runs the full pipeline: draft → audit → revise
131 - `--context` provides guidance to the Architect and Writer agents
132 - Returns JSON with chapter details and quality metrics
133
1343. **Review and approve chapters**:
135 ```bash
136 inkos review list book-id
137 inkos review approve-all book-id
138 ```
139
1404. **Export the book** (supports txt, md, epub):
141 ```bash
142 inkos export book-id
143 inkos export book-id --format epub
144 ```
145
146### Workflow 2: Continue Writing Existing Novel
147
1481. **List your books**:
149 ```bash
150 inkos book list
151 ```
152
1532. **Continue from last chapter**:
154 ```bash
155 inkos write next book-id --count 3 --words 2500 --context "protagonist faces critical choice"
156 ```
157 - InkOS maintains structured runtime state, readable Markdown projections, control docs, and temporal memory for consistency
158 - If only one book exists, omit `book-id` for auto-detection
159
1603. **Review and approve**:
161 ```bash
162 inkos review approve-all
163 ```
164
165### Workflow 2.5: Shared Natural-Language Control (Recommended For OpenClaw)
166
167When InkOS is being driven by OpenClaw or another external agent, prefer the shared interaction executor instead of stitching together many ad-hoc CLI calls:
168
169```bash
170inkos interact --json --message "continue the current book, but keep the pacing tighter"
171inkos interact --json --message "rewrite chapter 3"
172inkos interact --json --message "start an open-world detective game about a locked archive room"
173```
174
175The current JSON payload contains:
176- assistant response text
177- interaction session id / session kind / active book id when bound
178
179Real completion still comes from tool results and files. Do not treat assistant prose alone as proof that a book, chapter, short, cover, or play step was created.
180
181Use this as the primary OpenClaw entry because it shares the same control layer as the project TUI.
182
183### Workflow 2.6: Steering Chapter Focus Before Writing
184
185Use 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".
186
1871. **Update the book-level control docs when needed**:
188 - Use `update_author_intent` to change the long-horizon identity of the book
189 - Use `update_current_focus` to change the next 1-3 chapters' focus
190
1912. **Compile the next chapter intent**:
192 ```text
193 plan_chapter(bookId, guidance?)
194 ```
195 - Generates `story/runtime/chapter-XXXX.intent.md`
196 - Use this to verify what the system thinks the next chapter should do
197
1983. **Compose the actual runtime input package**:
199 ```text
200 compose_chapter(bookId, guidance?)
201 ```
202 - Generates `story/runtime/chapter-XXXX.context.json`
203 - Generates `story/runtime/chapter-XXXX.rule-stack.yaml`
204 - Generates `story/runtime/chapter-XXXX.trace.json`
205
2064. **Only then write**:
207 - `write_draft` if the user wants intermediate review
208 - `write_full_pipeline` if they want the usual write → audit → revise flow
209
210Recommended orchestration:
211- user asks to redirect focus
212- `update_current_focus`
213- `plan_chapter`
214- `compose_chapter`
215- inspect the resulting intent/paths
216- `write_draft` or `write_full_pipeline`
217
218### Workflow 2.7: Compare Long-Form Directions Before Writing
219
220Use a narrative forecast when the author wants to inspect several plausible futures without committing any of them to canon.
221
2221. Create isolated candidates from the current book state:
223 ```bash
224 inkos forecast create book-id --divergence "Does the protagonist reveal the evidence now?" --branches 3 --horizon 5
225 ```
2262. Compare the branch cards in Studio Chat, or inspect the saved comparison with `inkos forecast show [book-id] <forecast-id>`.
2273. Re-check the forecast before relying on it. Canon changes mark the forecast stale.
2284. Select one candidate with the Studio card or:
229 ```bash
230 inkos forecast select book-id forecast-id branch-2
231 ```
232
233Selection writes only `story/runtime/narrative-forecasts/<forecast-id>/selected-branch-plan.md`. It does not apply the plan to chapter prose, outlines, author intent, or canonical state. Any later application remains a separate explicit authoring action.
234
235### Workflow 3: Import Existing Chapters & Continue
236
237Use this when you have an existing novel (or partial novel) and want InkOS to pick up where it left off.
238
2391. **Import from a single text file** (auto-splits by chapter headings):
240 ```bash
241 inkos import chapters book-id --from novel.txt
242 ```
243 - Automatically splits by `第X章` pattern
244 - Custom split pattern: `--split "Chapter\\s+\\d+"`
245
2462. **Import from a directory** of separate chapter files:
247 ```bash
248 inkos import chapters book-id --from ./chapters/
249 ```
250 - Reads `.md` and `.txt` files in sorted order
251
2523. **Resume interrupted import**:
253 ```bash
254 inkos import chapters book-id --from novel.txt --resume-from 15
255 ```
256
2574. **Continue writing** from the imported chapters:
258 ```bash
259 inkos write next book-id --count 3
260 ```
261 - InkOS rebuilds structured state, chapter summaries, hooks, character relationships, readable projections, and a style guide from the imported chapters
262 - Generates a style guide from the existing text
263 - New chapters maintain consistency with imported content
264
265### Workflow 4: Style Imitation
266
2671. **Analyze reference text**:
268 ```bash
269 inkos style analyze reference_text.txt
270 ```
271 - Examines vocabulary, sentence structure, tone, pacing
272
2732. **Import style to your book**:
274 ```bash
275 inkos style import reference_text.txt book-id --name "Author Name"
276 ```
277 - All future chapters adopt this style profile
278 - Style rules become part of the Reviser's audit criteria
279
280### Workflow 5: Spinoff/Prequel Writing
281
2821. **Import parent canon**:
283 ```bash
284 inkos import canon spinoff-book-id --from parent-book-id
285 ```
286 - Creates links to parent book's world state, characters, and events
287 - Reviser enforces canon consistency
288
2892. **Continue spinoff**:
290 ```bash
291 inkos write next spinoff-book-id --count 3 --context "alternate timeline after Chapter 20"
292 ```
293
294### Workflow 6: Fine-Grained Control (Draft → Audit → Revise)
295
296If you need separate control over each pipeline stage:
297
2981. **Generate draft only**:
299 ```bash
300 inkos draft book-id --words 3000 --context "protagonist escapes" --json
301 ```
302
3032. **Audit the chapter** (33-dimension quality check):
304 ```bash
305 inkos audit book-id chapter-1 --json
306 ```
307 - Returns metrics across 33 dimensions including pacing, dialogue, world-building, outline adherence, and more
308
3093. **Revise with specific mode**:
310 ```bash
311 inkos revise book-id chapter-1 --mode polish --json
312 ```
313 - Modes documented for agent use: `polish` (minor), `spot-fix` (targeted), `rewrite` (major), and `rework` (structure)
314
315### Workflow 7: Monitor Platform Trends
316
317```bash
318inkos radar scan
319```
320- Analyzes trending genres, tropes, and reader preferences
321- Informs Architect recommendations for new books
322
323### Workflow 8: Detect AI-Generated Content
324
325```bash
326# Detect AIGC in a specific chapter
327inkos detect book-id
328
329# Deep scan all chapters
330inkos detect book-id --all
331```
332- Uses 11 deterministic rules (zero LLM cost) + optional LLM validation
333- Returns detection confidence and problematic passages
334
335### Workflow 9: View Analytics
336
337```bash
338inkos analytics book-id --json
339# Shorthand alias
340inkos stats book-id --json
341```
342- Total chapters, word count, average words per chapter
343- Audit pass rate and top issue categories
344- Chapters with most issues, status distribution
345- **Token usage stats**: total prompt/completion tokens, avg tokens per chapter, recent trend
346
347### Workflow 10: Write an English Novel
348
349```bash
350# Create an English LitRPG novel (language auto-detected from genre)
351inkos book create --title "The Last Delver" --genre litrpg --chapter-words 3000
352
353# Or set language explicitly
354inkos book create --title "My Novel" --genre other --lang en
355
356# Set English as default for all projects
357inkos config set-global --lang en
358```
359- 10 English genres: litrpg, progression, isekai, cultivation, system-apocalypse, dungeon-core, romantasy, sci-fi, tower-climber, cozy
360- Each genre has dedicated pacing rules, fatigue word lists (e.g., "delve", "tapestry", "testament"), and audit dimensions
361- Use `inkos genre list` to see all available genres
362
363### Workflow 11: Fan Fiction
364
365```bash
366# Create a fanfic from source material
367inkos fanfic init --title "My Fanfic" --from source-novel.txt --mode canon
368
369# Modes: canon (faithful), au (alternate universe), ooc (out of character), cp (ship-focused)
370inkos fanfic init --title "What If" --from source.txt --mode au --genre other
371```
372- Imports and analyzes source material automatically
373- Fanfic-specific audit dimensions and information boundary controls
374- Ensures new content stays consistent with source canon (or deliberately diverges in au/ooc modes)
375
376### Workflow 12: Edit Persistent Text Through Chat
377
378Use Studio Chat or `inkos interact` for small, explicit edits to generated text artifacts. Treat the chat layer like an external editor: it may edit persisted files, then the writing pipeline can continue from the updated state.
379
380```bash
381inkos interact --book my-book --json --message "把第 3 章里那句过长的解释删短一点,但不要改剧情事实"
382inkos interact --json --message "把 covers/demo/cover-prompt.md 里的人物拉近一点,标题字更大"
383```
384- Use for clear text edits, cover prompt edits, and control-document edits.
385- Do not infer success from the assistant's prose; check the tool result or changed file.
386- For broad story direction changes, prefer updating `author_intent.md` / `current_focus.md`, then run `plan` / `compose` before writing.
387
388### Workflow 13: Explicit Rename / Replacement Requests
389
390When the user asks for a rename or targeted replacement, keep the request explicit and scoped. Prefer Studio Chat / `inkos interact` over hidden slash shortcuts; the agent should route the edit through the shared action surface and report which file changed.
391
392Examples:
393- "把当前书里角色 林烬 改成 张三,先说明会影响哪些文件。"
394- "只改第 5 章,把这句旧文本换成新文本,改完标记需要复核。"
395
396### Workflow 14: Interactive TUI Dashboard
397
398```bash
399inkos tui
400```
401- Launches a full-screen Ink + React dashboard with conversational creation
402- Slash command autocomplete (Tab), input history (arrow keys)
403- Uses explicit `/new`, `/short`, `/play`, `/cover`, and `/write` surfaces; `/confirm` and `/cancel` resolve structured proposals without rerunning intent detection
404- `/model <name>` changes the model for the current TUI session; ordinary text that merely discusses models remains a normal Agent turn
405- Adapts text colors to light or dark terminal backgrounds (`INKOS_TUI_THEME` can override detection)
406- Themed activity animations per operation (writing, auditing, revising, planning)
407- Bilingual i18n (Chinese / English)
408- Shares the same interaction kernel as `inkos interact` and Studio
409
410### Workflow 15: Standalone Short Fiction Package
411
412Use this when the user wants a complete short story or short-fiction deliverable that is separate from the active long-form book.
413
414```bash
415inkos short run \
416 --direction "modern short fiction marriage reversal evidence-driven heroine" \
417 --chapters 12 \
418 --chars 1000
419```
420
421Outputs are written under `shorts/<story-name>/final/`:
422- `full.md` — complete short-fiction manuscript
423- `sales-package.md` — synopsis and selling points
424- `cover-prompt.md` — cover prompt
425- `cover.png` — cover image when a cover provider is configured
426
427For OpenClaw/Studio/agent orchestration, call the `short_fiction_run` tool when the user asks for a new complete short-fiction package. Do not use it for the next chapter of an existing long-form book.
428
429### Workflow 16: Standalone Cover Tool
430
431Use this when the user only wants a cover for an existing title, synopsis, or visual direction. Do not rerun the short-fiction pipeline.
432
433In Studio or agent mode, ask naturally:
434
435```text
436Generate a short-fiction cover for "The Divorce Papers He Regretted", modern city, high-drama reversal.
437```
438
439For tool-using agents, call `generate_cover` with:
440- `title` — required
441- `intro` or `sellingPoints` — optional story context
442- `coverPrompt` — optional visual direction
443- `outputDir` — optional; defaults to `covers/<title>/`
444
445The standalone cover tool writes:
446- `covers/<title>/cover-prompt.md`
447- `covers/<title>/cover.png`
448
449If cover image generation fails, report the provider/configuration error plainly. Do not rewrite the story, do not rerun `short_fiction_run`, and do not suggest unrelated external tools unless the user asks.
450
451### Workflow 17: Open World / Branching Interactive Play
452
453Use this when the user wants to play inside an interactive world instead of generating a finished manuscript.
454
455In Studio or agent mode, ask naturally:
456
457```text
458Create a Warcraft-like border watchtower open world. Time can advance differently by action: patrols take an hour, training can take days. Equipment should show rarity through material and atmosphere, not stat blocks.
459```
460
461For tool-using agents:
462- Call `play_start` when there is no active world/run yet, or when the user explicitly asks to start a new world.
463- Call `play_step` when the user performs an action inside an existing world.
464- Keep Open World free-form: do not force clickable choices unless the current session is Branching Interactive.
465- If the user changes world rules, persona, visual contract, or character behavior, treat it as a world-state edit or a new instruction for the next step, not as long-form chapter writing.
466- If image generation is configured, let Play generate scene / character / item / evidence images through the Play image path. Do not call the short-fiction cover tool for Play scene images.
467
468### Workflow 18: Agent Skills
469
470Use this when the user wants reusable professional rules, a domain-specific writing mode, or a forced capability for the current Chat turn.
471
472Project-local skills live at:
473
474```text
475.agents/skills/<skill-id>/SKILL.md
476```
477
478InkOS also discovers standard AgentSkills / OpenClaw locations (`skills/`, `.agents/skills/`, `~/.agents/skills/`, and `~/.openclaw/skills/`). Studio can import a complete skill folder with its static reference files.
479
480External skill directories can be loaded with:
481
482```bash
483export INKOS_SKILL_DIRS=/abs/path/to/skills
484```
485
486Guidelines for agent orchestration:
487- Let the Chat Agent inspect the available skill catalog and call `use_skill` when the current user intent needs that expertise. Do not emulate this with session-kind routing, keyword lists, or substring matching.
488- Force a skill by including `@skill-id` in the user message when the user explicitly chooses one.
489- Treat skills as standard expertise packets containing instructions and static references. Prompt packs and governed context recipes are separate InkOS systems.
490- Skill folders may contain static references. Read them only when needed, and never auto-execute bundled scripts.
491- Do not treat skills as permissions. File edits, book creation, chapter writing, image generation, and exports still require the normal InkOS tools and confirmation gates.
492
493### Workflow 18.5: Book-Bound Reference Material
494
495Use this when imported material should influence one book over multiple future turns without becoming canon or being injected in full every time.
496
4971. Archive the source with `ingest_material`; keep the returned material id.
4982. On the active book, call `manage_book_reference` with `action=bind`, that material id, concrete `uses`, and an optional limiting note.
4993. Let Planner / Composer / Writer retrieve relevant passages through the shared local search index. Source files remain authoritative and retrieval keeps source pointers.
5004. Use `manage_book_reference` with `action=list` to inspect bindings or `action=unbind` to detach one without deleting the project asset.
501
502Binding a reference does not make it canon and does not authorize copying its expression. Canon changes still require the normal explicit edit path.
503
504### Workflow 19: Traceable Web Research
505
506Use this when the user asks for real-world references, external facts, era/profession details, market references, or worldbuilding research.
507
508For tool-using agents, call `research_web` with:
509- `topic` — the research question
510- `purpose` — `worldbuilding`, `era`, `profession`, `market`, `fact-check`, or `general`
511- `depth` — optional: `quick`, `standard`, or `deep`
512
513The tool writes a Markdown report under:
514
515```text
516.inkos/research/
517```
518
519The report includes sources, claims, unknowns, conflicts, query logs, and confidence. It is reference material only. If research should change canon, wait for explicit user confirmation and then use the normal truth-file editing path.
520
521Search credentials are user/project supplied. Studio can configure a Tavily-compatible search API, or the server can use `TAVILY_API_KEY` from the environment.
522
523### Workflow 20: Script, Storyboard, and Interactive-Film Creation
524
525Use this when the user wants a production artifact rather than a casual answer:
526- Script: dramatic scenes, dialogue, acts, episode structure, or format-specific script drafts.
527- Storyboard: visual beats, shot descriptions, image prompts, and scene-by-scene production notes.
528- Interactive film: branch graph, choices, variables/flags, relationship state, endings, node images, and exportable project package.
529
530In Studio Chat, these actions should be proposed with a confirmation card first. After confirmation, InkOS writes the artifact and reports the saved files. Do not hand-write a fake "created" result in prose.
531
532### Workflow 21: Multilingual Translation / Localization
533
534Use a translation project when the user wants a complete, reviewable deliverable rather than a one-off translated paragraph. Inputs can be EPUB, text-based PDF, TXT, or Markdown; source and target languages can be written as normal language names in Studio.
535
536```bash
537inkos translate init --from ./source.epub --source Chinese --target English
538inkos translate run <project-id>
539inkos translate export <project-id> --format epub
540```
541
542- Preserve the project glossary and chapter boundaries across translation batches.
543- Review source and translation side by side; treat the generated review report as the quality record.
544- Export TXT, Markdown, or EPUB only after the requested segments are complete.
545- For scanned PDFs without a text layer, run OCR before importing; InkOS currently reads text-based PDFs.
546
547## InkOS Studio (Web Workbench)
548
549`inkos studio` launches a local web UI (default port 4567) that provides a visual interface for all InkOS operations:
550
551- **Book management** — create, delete, export (TXT/MD/EPUB), configure per-book settings
552- **Short fiction & cover tools** — generate independent short-fiction packages, synopsis/selling points, cover prompts, and standalone covers
553- **Open World / Branching Interactive** — start and continue interactive worlds with world contracts, free actions, clickable choices, HUD state, and image generation
554- **Interactive-film workbench** — create and inspect branch nodes, variables/flags, endings, node images, and export packages
555- **Script / storyboard tools** — generate production-oriented script and storyboard files from ideas, prose, or reference notes
556- **Translation workbench** — import EPUB, text-based PDF, TXT, or Markdown; choose source and target languages; translate, compare, review, and export complete projects
557- **Agent Skills management** — list standard skills, import AgentSkills/OpenClaw folders with static references into `.agents/skills/`, let Chat invoke skills from intent, and force skills from Chat
558- **Research search provider** — configure external web search API credentials for `research_web`
559- **Chapter review & editing** — approve/reject drafts, edit content inline, and revise with polish/spot-fix/rewrite/rework modes
560- **Real-time writing progress** — SSE-based live updates during chapter generation
561- **Market radar** — AI-powered trend analysis with platform/genre recommendations
562- **Analytics** — word count, audit pass rate, chapter ranking, token usage
563- **AI detection** — scan chapters for AI-generated content
564- **Style analysis** — analyze reference texts and import writing styles
565- **Genre management** — create/customize genre profiles with fatigue words, pacing rules, audit dimensions
566- **Daemon control** — start/stop background writing with event log
567- **Truth file editor** — view and edit canonical knowledge base per book
568- **Config editor** — LLM provider, model routing, cover/image services, notifications
569
570```bash
571inkos studio # Start on default port 4567
572inkos studio -p 8080 # Start on custom port
573```
574
575The **Studio Chat** surface shares the same action kernel as TUI and CLI. It can answer questions, propose/confirm creation and translation actions, run Short, generate covers, start Play, import existing novels, edit persistent text artifacts, and invoke long-form writing operations.
576
577## Advanced: Natural Language Agent Mode
578
579For flexible, conversational requests:
580
581```bash
582inkos agent "写一部都市题材的小说,主角是一个年轻律师,第一章三千字"
583```
584- Agent interprets natural language and invokes appropriate commands
585- Useful for complex multi-step requests
586
587## Input Governance Tools
588
589These tools are the preferred control surface for chapter steering:
590
591- `plan_chapter(bookId, guidance?)`
592 - Generates chapter intent for the next chapter
593 - Use before writing when the user wants to change focus
594
595- `compose_chapter(bookId, guidance?)`
596 - Generates runtime context/rule-stack/trace artifacts
597 - Use after planning and before writing
598
599- `update_author_intent(bookId, content)`
600 - Rewrites `story/author_intent.md`
601 - Use for long-horizon changes to the book's identity
602
603- `update_current_focus(bookId, content)`
604 - Rewrites `story/current_focus.md`
605 - Use for local steering over the next 1-3 chapters
606
607## Creative, Research, and Play Agent Tools
608
609These are the preferred tools when InkOS is driven by OpenClaw, Studio chat, or `inkos agent`:
610
611- `short_fiction_run`
612 - Creates an independent short-fiction package from a direction
613 - Runs outline → outline review/revision → full draft → draft review/revision → synopsis/selling points/cover prompt → optional cover image
614 - Writes to `shorts/<story-name>/`
615 - Use only when the user asks for a separate complete short story / short-fiction deliverable
616
617- `generate_cover`
618 - Generates only a cover prompt and cover image
619 - Writes to `covers/<title>/` by default
620 - Use when the user asks to create or regenerate a cover for an existing title, synopsis, or completed short
621 - Also use when the user changes the cover prompt through chat; pass the revised visual direction as `coverPrompt` and reuse the existing `outputDir` when available
622 - Do not rerun story generation unless the user explicitly asks for a new story
623
624- `play_start`
625 - Starts a new Open World or Branching Interactive run
626 - Use when the user asks to play in a world, simulate an interactive story, create a game-like scene, or start a free-action/choice-based session
627 - The user's world contract should carry time rules, character agency, item/evidence rules, tone, genre, and visual style when provided
628
629- `play_step`
630 - Advances an existing Play run by one user action
631 - Use for free-form actions such as "inspect the letter", "talk to the guard", "train for three days", or "choose option 2"
632 - Do not use it to write the next chapter of a long-form book
633
634- `research_web`
635 - Collects external sources and writes a traceable Markdown research report
636 - Use only for explicit research/fact-check/worldbuilding/market requests
637 - Never mutate canon or prose directly from research output without explicit user confirmation
638
639- Script / storyboard / interactive-film creation tools
640 - Use when the user wants saved production artifacts
641 - Preserve the user's requested format, market, target audience, and export needs
642 - Do not use these tools for casual analysis unless the user asks to create deliverables
643
644`write_truth_file` remains available for broad file edits, but prefer the dedicated control tools above for input-governance changes.
645
646## Key Concepts
647
648### Book ID Auto-Detection
649If your project contains only one book, most commands accept `book-id` as optional. You can omit it for brevity:
650```bash
651# Explicit
652inkos write next book-123 --count 1
653
654# Auto-detected (if only one book exists)
655inkos write next --count 1
656```
657
658### --json Flag
659All content-generating commands support `--json` for structured output. Essential for programmatic use:
660```bash
661inkos draft book-id --words 3000 --context "guidance" --json
662```
663
664### Long-Term Memory
665InkOS maintains each book's memory in three layers:
666- **Structured state**: `story/state/*.json` is the authoritative runtime state, validated by Zod schemas.
667- **Readable projections**: `current_state.md`, `pending_hooks.md`, `chapter_summaries.md`, `character_matrix.md`, and related Markdown files are for humans and debugging.
668- **Temporal memory**: `story/memory.db` on Node 22+ supports relevance-based retrieval of facts, hooks, and chapter summaries.
669
670Agents use the governed composer to select the relevant parts for the current task instead of blindly injecting every file. During `import chapters`, InkOS rebuilds structured state and projections from existing content via the ChapterAnalyzerAgent.
671
672### Multi-Phase Writer Architecture
673The Writer operates across multiple phases with specialized agents:
674- **Planner**: Generates chapter intent with structured hook agenda (mustAdvance, eligibleResolve, staleDebt) based on memory retrieval.
675- **Composer**: Selects relevant context from structured state, control docs, readable projections, and retrieval results, then compiles rule stack and runtime artifacts.
676- **Phase 1 (Creative, temp 0.7)**: Generates prose with length governance, English variance brief (anti-repetition), and dialogue-driven guidance.
677- **Phase 2a (Observer, temp 0.5)**: Over-extracts 9 categories of facts from the chapter text.
678- **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.
679- **Normalizer**: Single-pass compress/expand to bring chapter length into the target band. Safety net rejects destructive normalization (>75% content loss).
680- **Auditor**: 33-dimension check including hook health analysis (stale debt, burst detection, no-advance warnings).
681- **Reviser**: Attempts one configured repair pass for critical issues, then keeps unresolved findings visible for human or agent follow-up.
682
683Truth 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.
684
685### Context Guidance
686The `--context` parameter provides directional hints to the Writer and Architect:
687```bash
688inkos write next book-id --count 2 --context "protagonist discovers betrayal, must decide whether to trust mentor"
689```
690- Context is optional but highly recommended for narrative coherence
691- Supports both English and Chinese
692
693## Genre Management
694
695### View Built-In Genres
696```bash
697inkos genre list
698inkos genre show xuanhuan
699```
700
701### Create Custom Genre
702```bash
703inkos genre create my-genre --name "My Genre"
704# Options: --numerical, --power, --era
705inkos genre create dark-xuanhuan --name "Dark Xuanhuan" --numerical --power
706```
707
708### Copy Built-in Genre for Customization
709```bash
710inkos genre copy xuanhuan
711# Copies to project genres/ directory for editing
712```
713
714## Command Reference Summary
715
716| Command | Purpose | Notes |
717|---------|---------|-------|
718| `inkos init [name]` | Initialize project | One-time setup |
719| `inkos book create` | Create new book | Returns book-id. `--brief <file>`, `--lang en/zh`, `--genre litrpg/progression/...` |
720| `inkos book list` | List all books | Shows IDs, statuses |
721| `inkos write next` | Full pipeline (draft→audit→revise) | Primary workflow command |
722| `inkos draft` | Generate draft only | No auditing/revision |
723| `inkos audit` | 33-dimension quality check | Standalone evaluation |
724| `inkos revise` | Revise chapter | Modes documented for agent use: polish/spot-fix/rewrite/rework |
725| `inkos agent` | Natural language interface | Flexible requests |
726| `inkos style analyze` | Analyze reference text | Extracts style profile |
727| `inkos style import` | Apply style to book | Makes style permanent |
728| `inkos import canon` | Link spinoff to parent | For prequels/sequels |
729| `inkos import chapters` | Import existing chapters | Reverse-engineers truth files for continuation |
730| `inkos detect` | AIGC detection | Flags AI-generated passages |
731| `inkos export` | Export finished book | Formats: txt, md, epub |
732| `inkos analytics` / `inkos stats` | View book statistics | Word count, audit rates, token usage |
733| `inkos radar scan` | Platform trend analysis | Informs new book ideas |
734| `inkos short run` | Generate standalone short fiction | Outputs manuscript, sales package, cover prompt, optional cover |
735| `inkos config set-global` | Configure LLM provider | OpenAI/Anthropic/custom (any OpenAI-compatible) |
736| `inkos config set-model <agent> <model>` | Set model override for a specific agent | `--provider`, `--base-url`, `--
737
738…(truncated)