Parcourir la source

docs: sync READMEs with v0.5 features

- Roadmap: mark logging, stream fallback, local model compat, --brief as done
- Remove "empty chapter / truncation fix" from TODO (done)
- Command reference: book create --brief, write/draft/up -q, doctor hints
- Daemon section: mention inkos.log and -q quiet mode
- Note about --brief in usage paragraph
Ma il y a 7 mois
Parent
commit
4e27ab5266
2 fichiers modifiés avec 104 ajouts et 584 suppressions
  1. 53 293
      README.en.md
  2. 51 291
      README.md

+ 53 - 293
README.en.md

@@ -3,7 +3,7 @@
   <img src="assets/inkos-text.svg" width="240" height="65" alt="InkOS">
 </p>
 
-<h1 align="center">Multi-Agent Novel Production System</h1>
+<h1 align="center">Autonomous Novel Writing CLI Agent</h1>
 
 <p align="center">
   <a href="https://www.npmjs.com/package/@actalk/inkos"><img src="https://img.shields.io/npm/v/@actalk/inkos.svg?color=cb3837&logo=npm" alt="npm version"></a>
@@ -18,250 +18,67 @@
 
 ---
 
-Open-source multi-agent system that autonomously writes, audits, and revises novels — with human review gates that keep you in control.
+Open-source CLI agent that autonomously writes, audits, and revises novels — with human review gates that keep you in control.
 
-## v0.4 Update
-
-Continuation writing + spinoff writing + style cloning + multi-provider routing + post-write validator + audit-revise hardening.
-
-### Continuation Writing (Import Existing Work)
-
-Import an existing novel (single file or chapter directory) into InkOS. The system auto-splits chapters, reverse-engineers all truth files (world state, hooks, character matrix, etc.), then seamlessly continues writing.
-
-```bash
-inkos import chapters my-book --from chapters/          # Import from directory
-inkos import chapters my-book --from novel.txt           # Import from single file (auto-splits on "第X章")
-inkos import chapters my-book --from novel.txt --split "Chapter\\s+\\d+"  # Custom split regex
-inkos write next my-book                                 # Continue writing seamlessly
-```
-
-Single-file mode splits on `第X章` by default. Use `--split <regex>` for custom patterns. Interrupted imports can resume with `--resume-from <n>`.
-
-### Spinoff Writing
-
-Create prequels, sequels, side-stories, or what-if branches from existing books. Spinoffs share the parent's world and characters but have independent plot lines.
-
-```bash
-inkos import canon my-prequel --from main-novel   # Import parent canon
-inkos write next my-prequel                        # Writer auto-reads canon constraints
-```
-
-Generates `story/parent_canon.md` containing the parent's world rules, character snapshots (with information boundaries), key event timeline, and foreshadowing state. The auditor auto-activates 4 spinoff-specific dimensions:
-
-| Dimension | Checks |
-|-----------|--------|
-| Canon Event Conflict | Whether spinoff events contradict the parent's canon constraints |
-| Future Info Leak | Whether characters reference information revealed after the divergence point |
-| Cross-Book World Consistency | Whether the spinoff violates parent world rules (power systems, geography, factions) |
-| Spinoff Foreshadowing Isolation | Whether the spinoff oversteps by resolving parent foreshadowing |
-
-Auto-activates when `parent_canon.md` is detected. No extra configuration needed.
-
-### Style Cloning
+## Quick Start
 
-Feed in a real novel excerpt. The system extracts a statistical fingerprint + generates a qualitative style guide, then injects both into every chapter's Writer prompt.
+### Install
 
 ```bash
-inkos style analyze reference.txt                      # Analyze: sentence length, TTR, rhetorical features
-inkos style import reference.txt my-book --name "Author"  # Import style into book
+npm i -g @actalk/inkos
 ```
 
-Produces two files:
-- `style_profile.json` — statistical fingerprint (sentence/paragraph length distribution, vocabulary diversity, rhetorical density)
-- `style_guide.md` — LLM-generated qualitative guide (rhythm, tone, word preferences, taboos)
-
-The Writer reads the style guide every chapter; the Auditor cross-checks against it in the style dimension.
-
-### Post-Write Validator
-
-11 deterministic rules, zero LLM cost, fires immediately after each chapter:
-
-| Rule | Description |
-|------|-------------|
-| Banned Patterns | "not X… but Y…" sentence structure |
-| Dash Prohibition | em-dash "——" |
-| Transition Word Density | "as if" / "suddenly" / "unexpectedly" — max 1 per 3,000 words |
-| High-Fatigue Words | Genre fatigue words: max 1 per word per chapter |
-| Meta-Narration | Screenwriter-style commentary |
-| Report Terminology | Analytical framework terms banned from prose |
-| Author Sermonizing | "obviously" / "needless to say" etc. |
-| Collective Shock | "the whole crowd was stunned" cliches |
-| Consecutive "le" (了) | ≥ 6 consecutive sentences containing "了" |
-| Paragraph Length | ≥ 2 paragraphs over 300 characters |
-| Book Prohibitions | Custom bans from book_rules.md |
-
-When the validator finds error-level violations, it auto-triggers `spot-fix` mode for targeted repair before the LLM audit even runs.
-
-### Audit-Revise Loop Hardening
-
-Real testing showed `rewrite` mode introduces 6x more AI markers than the original text. Now:
-
-- Auto-revise mode changed from `rewrite` to `spot-fix` (only fixes flagged sentences, leaves everything else untouched)
-- Post-revise AI marker guard: if revision increases AI tell count, the revision is discarded
-- Re-audit temperature locked to 0 (deterministic pass/fail gating)
-- `polish` mode boundaries strengthened (no adding paragraphs, renaming entities, or changing causality)
-
-### Multi-Provider Agent Routing
+### Configure
 
-Different agents can use completely different API providers — not just different model names, but different API endpoints and keys. For example, use a cheap model for drafting and a strong model for auditing:
+**Option 1: Global config (recommended, one-time setup)**
 
 ```bash
-inkos config set-model writer gpt-4o-mini                                    # Simple model override
-inkos config set-model auditor gemini-2.5-flash \
-  --base-url https://generativelanguage.googleapis.com/v1beta/openai \
+inkos config set-global \
   --provider openai \
-  --api-key-env GEMINI_API_KEY                                                # Route to Gemini API
-inkos config set-model reviser claude-sonnet-4-20250514 \
-  --base-url https://api.anthropic.com \
-  --provider anthropic \
-  --api-key-env ANTHROPIC_API_KEY                                             # Route to Anthropic API
-inkos config show-models                                                      # View full routing
-```
-
-Each agent independently configurable with `--base-url`, `--provider`, `--api-key-env`, `--no-stream`. Unconfigured agents use the project default.
-
-### Analytics
-
-```bash
-inkos analytics my-book          # Audit pass rate, top issue categories, chapters with most issues
-inkos analytics my-book --json   # Structured output
+  --base-url https://api.openai.com/v1 \
+  --api-key sk-xxx \
+  --model gpt-4o
 ```
 
-### Other v0.4 Changes
-
-- Audit dimensions expanded from 26 to 33 (+4 spinoff dims + dim 27 sensitive words + dim 32 reader expectation management + dim 33 outline adherence detection)
-- All 5 genres now activate dims 24-26 (subplot stagnation / flat emotional arc / monotonous pacing)
-- Auditor web search: era-research genres can verify real events/people/geography online (native search)
-- Scheduler rewrite: AI-paced (15min cycles), parallel book processing, immediate retry, daily cap
-- New `spot-fix` revise mode (targeted repair)
-- `additionalAuditDimensions` in `book_rules.md` now supports name-string matching
-- `inkos export` supports `--format md`, `--output <path>`, `--approved-only`
-- Post-write validator consecutive "了" threshold raised from 4 to 6 (reduces false positives in Chinese prose)
-- Safety hardening: `init`/`book create`/`import chapters` overwrite guards, `config set` type coercion + key validation, `update` downgrade prevention, `doctor` works outside projects, consistent status display, `genre show` rejects invalid IDs
-
----
-
-## v0.3 Update
-
-Three-layer rule separation + cross-chapter memory + AIGC detection + Webhook.
-
-### Cross-Chapter Memory & Writing Quality
-
-The Writer auto-generates chapter summaries, updates subplot/emotion/character matrices — all appended to truth files. Subsequent chapters load full context, so long-term foreshadowing never gets lost.
-
-| Truth File | Purpose |
-|------------|---------|
-| `chapter_summaries.md` | Per-chapter summaries: characters, key events, state changes, hook dynamics |
-| `subplot_board.md` | Subplot progress board: A/B/C line status tracking |
-| `emotional_arcs.md` | Emotional arcs: per-character emotion, triggers, arc direction |
-| `character_matrix.md` | Character interaction matrix: encounter records, information boundaries |
-
-### AIGC Detection
+Saved to `~/.inkos/.env`, shared by all projects. New projects just work without extra config.
 
-| Feature | Description |
-|---------|-------------|
-| AI-Tell Audit | Pure rule-based detection (no LLM): paragraph uniformity, hedge word density, formulaic transitions, list-like structure — auto-merged into audit results |
-| AIGC Detection API | External API integration (GPTZero / Originality / custom endpoints), `inkos detect` command |
-| Style Fingerprint | Extract StyleProfile from reference text (sentence length, TTR, rhetorical features), inject into Writer prompt |
-| Anti-Detect Rewrite | ReviserAgent `anti-detect` mode, detect → rewrite → re-detect loop |
-| Detection Feedback Loop | `detection_history.json` records each detection/rewrite result, `inkos detect --stats` for statistics |
+**Option 2: Per-project `.env`**
 
 ```bash
-inkos style analyze reference.txt           # Analyze reference text style
-inkos style import reference.txt my-book    # Import style into book
-inkos detect my-book --all                  # Detect all chapters
-inkos detect --stats                        # Detection statistics
+inkos init my-novel     # Initialize project
+# Edit my-novel/.env
 ```
 
-### Webhook + Smart Scheduler
-
-Pipeline events POST JSON to configured URLs (HMAC-SHA256 signed), with event filtering (`chapter-complete`, `audit-failed`, `pipeline-error`, etc.). Daemon mode adds quality gates: auto-retry on audit failure (with temperature ramp), pause book after consecutive failures.
-
-### Genre Customization
-
-5 built-in genres, each with a complete set of writing rules: chapter types, prohibition lists, fatigue words, language rules, and audit dimensions.
-
-| Genre | Built-in Rules |
-|-------|---------------|
-| Xuanhuan (Fantasy) | Numerical system, power scaling, same-type absorption decay formula, face-slap/upgrade/payoff pacing |
-| Xianxia (Cultivation) | Cultivation/enlightenment pacing, artifact system, heavenly dao rules |
-| Urban | Era research, business/social-driven plot, era-matched legal terminology, no numerical system |
-| Horror | Atmosphere progression, fear levels, restrained narration, no power scaling audit |
-| General | Minimal fallback |
-
-Specify a genre when creating a book and matching rules activate automatically:
-
 ```bash
-inkos book create --title "Devouring Emperor" --genre xuanhuan
-```
-
-View, copy, or create genre rules:
+# Required
+INKOS_LLM_PROVIDER=openai                        # openai / anthropic
+INKOS_LLM_BASE_URL=https://api.openai.com/v1     # API endpoint (proxy-friendly)
+INKOS_LLM_API_KEY=sk-xxx                          # API Key
+INKOS_LLM_MODEL=gpt-4o                            # Model name
 
-```bash
-inkos genre list                      # List all genres
-inkos genre show xuanhuan             # View full xuanhuan rules
-inkos genre copy xuanhuan             # Copy to project for customization
-inkos genre create wuxia --name Wuxia # Create a new genre from scratch
+# Optional
+# INKOS_LLM_TEMPERATURE=0.7                       # Temperature
+# INKOS_LLM_MAX_TOKENS=8192                        # Max output tokens
+# INKOS_LLM_THINKING_BUDGET=0                      # Anthropic extended thinking budget
 ```
 
-After copying to your project, add/remove prohibitions, adjust fatigue words, modify pacing rules, customize language rules — changes take effect on the next chapter.
-
-Each genre has dedicated language rules (with bad → good examples), enforced by both writer and auditor:
-
-- **Xuanhuan**: ✗ "Fire essence increased from 12 to 24 wisps" → ✓ "His arm felt stronger than before, knuckles tightening into a fist"
-- **Urban**: ✗ "Quickly analyzed the current debt situation" → ✓ "Flipped through the stack of wrinkled IOUs three times"
-- **Horror**: ✗ "Felt a wave of fear" → ✓ "The hairs on the back of his neck stood up one by one"
-
-### Per-Book Rules
+Project `.env` overrides global config. Skip it if no override needed.
 
-Each book has its own `book_rules.md`, auto-generated by the Architect agent when creating a book — also editable anytime. Rules here are injected into every chapter's prompt:
+### Write Your First Book
 
-```yaml
-protagonist:
-  name: Lin Jin
-  personalityLock: ["ruthlessly calm", "patient but lethal", "smart, not reckless"]
-  behavioralConstraints: ["no mercy, no hesitation", "warm to allies but never sentimental"]
-numericalSystemOverrides:
-  hardCap: 840000000
-  resourceTypes: ["particles", "bloodline density", "spirit stones"]
-prohibitions:
-  - protagonist goes soft at critical moments
-  - pointless harem romance dragging the plot
-  - side characters stealing the spotlight
-fatigueWordsOverride: ["pupils constricted", "disbelief"]   # Override genre defaults
+```bash
+inkos book create --title "Devouring Emperor" --genre xuanhuan  # Create a book
+inkos write next my-book          # Write next chapter (full pipeline: draft → audit → revise)
+inkos status                      # Check status
+inkos review list my-book         # Review drafts
+inkos review approve-all my-book  # Batch approve
+inkos export my-book              # Export full book
+inkos export my-book --format epub  # Export EPUB (read on phone/Kindle)
 ```
 
-Protagonist personality lock, numerical caps, custom prohibitions, fatigue word overrides — each book's rules are independent, without affecting the genre template.
-
-### 33-Dimension Audit
-
-Auditing is broken down into 33 dimensions, with genre-appropriate subsets auto-enabled:
-
-OOC check, timeline, setting conflicts, power scaling collapse, numerical verification, foreshadowing, pacing, writing style, information leaking, vocabulary fatigue, broken interest chains, era research, side character intelligence drops, side character tool-ification, hollow payoffs, dialogue authenticity, padding detection, knowledge base contamination, POV consistency, paragraph uniformity, hedge word density, formulaic transitions, list-like structure, subplot stagnation, flat emotional arc, monotonous pacing, sensitive word check, canon event conflict, future info leak, cross-book world consistency, spinoff foreshadowing isolation, reader expectation management, outline adherence detection
-
-Dims 20-23 (AI-tell detection) + dim 27 (sensitive words) use a pure rule engine — no LLM calls. Dims 28-31 (spinoff) auto-activate when `parent_canon.md` is detected. Dim 32 (reader expectation management) and dim 33 (outline adherence detection) are always on.
-
-### De-AI-ification
-
-5 universal rules + genre-specific language rules to control AI marker word density and narration habits:
-
-- AI marker word frequency limit: "as if" / "suddenly" / "unexpectedly" / "couldn't help but" — max 1 per 3,000 words
-- Narrator never draws conclusions for the reader, only writes actions
-- No analytical report language ("core motivation", "information gap" never appear in prose)
-- Same imagery rendered no more than twice
-- Methodology jargon stays out of prose
-
-Vocabulary fatigue audit + AI-tell audit (dims 20-23) provide dual detection. Style fingerprint injection further reduces AI text characteristics.
-
-### Other
-
-- Supports OpenAI + Anthropic native + all OpenAI-compatible endpoints
-- Reviser supports polish / rewrite / rework / anti-detect / spot-fix modes
-- Genres without numerical systems skip resource ledger generation
-- All commands support `--json` structured output for OpenClaw / external agent integration
-- Auto-detect book-id when project has only one book
-- `inkos update` for self-updating, `inkos init` supports current directory
-- API errors include diagnostic hints, `inkos doctor` includes connectivity test
+<p align="center">
+  <img src="assets/screenshot-terminal.png" width="700" alt="Terminal screenshot">
+</p>
 
 ---
 
@@ -319,7 +136,7 @@ The Writer agent has ~25 universal writing rules (character craft, narrative tec
 
 On top of that, each genre has dedicated rules (prohibitions, language rules, pacing, audit dimensions), and each book has its own `book_rules.md` (protagonist personality, numerical caps, custom prohibitions) and `story_bible.md` (worldbuilding), auto-generated by the Architect agent.
 
-See [v0.3 Update](#v03-update-2026-03-13) for details.
+See [CHANGELOG](CHANGELOG.md) for details.
 
 ## Three Usage Modes
 
@@ -352,84 +169,25 @@ inkos agent "Scan market trends first, then create a new book based on results"
 
 13 built-in tools (write_draft, audit_chapter, revise_chapter, scan_market, create_book, get_book_status, read_truth_files, list_books, write_full_pipeline, web_fetch, import_style, import_canon, import_chapters), with the LLM deciding call order via tool-use.
 
-## Quick Start
-
-### Install
-
-```bash
-npm i -g @actalk/inkos
-```
-
-### Configure
-
-**Option 1: Global config (recommended, one-time setup)**
-
-```bash
-inkos config set-global \
-  --provider openai \
-  --base-url https://api.openai.com/v1 \
-  --api-key sk-xxx \
-  --model gpt-4o
-```
-
-Saved to `~/.inkos/.env`, shared by all projects. New projects just work without extra config.
-
-**Option 2: Per-project `.env`**
-
-```bash
-inkos init my-novel     # Initialize project
-# Edit my-novel/.env
-```
-
-```bash
-# Required
-INKOS_LLM_PROVIDER=openai                        # openai / anthropic
-INKOS_LLM_BASE_URL=https://api.openai.com/v1     # API endpoint (proxy-friendly)
-INKOS_LLM_API_KEY=sk-xxx                          # API Key
-INKOS_LLM_MODEL=gpt-4o                            # Model name
-
-# Optional
-# INKOS_LLM_TEMPERATURE=0.7                       # Temperature
-# INKOS_LLM_MAX_TOKENS=8192                        # Max output tokens
-# INKOS_LLM_THINKING_BUDGET=0                      # Anthropic extended thinking budget
-```
-
-Project `.env` overrides global config. Skip it if no override needed.
-
-### Usage
-
-```bash
-inkos book create --title "Devouring Emperor" --genre xuanhuan  # Create a book
-inkos write next my-book          # Write next chapter (full pipeline)
-inkos status                      # Check status
-inkos review list my-book         # Review drafts
-inkos export my-book              # Export full book
-inkos up                          # Daemon mode
-```
-
-<p align="center">
-  <img src="assets/screenshot-terminal.png" width="700" alt="Terminal screenshot">
-</p>
-
 ## CLI Reference
 
 | Command | Description |
 |---------|-------------|
 | `inkos init [name]` | Initialize project (omit name to init current directory) |
-| `inkos book create` | Create a new book (`--genre`, `--platform`, `--chapter-words`, `--target-chapters`, `--context`) |
+| `inkos book create` | Create a new book (`--genre`, `--platform`, `--chapter-words`, `--target-chapters`, `--brief <file>` for creative brief) |
 | `inkos book update [id]` | Update book settings (`--chapter-words`, `--target-chapters`, `--status`) |
 | `inkos book list` | List all books |
 | `inkos genre list/show/copy/create` | View, copy, or create genres |
-| `inkos write next [id]` | Full pipeline: write next chapter (`--words` to override, `--count` for batch) |
+| `inkos write next [id]` | Full pipeline: write next chapter (`--words` to override, `--count` for batch, `-q` quiet mode) |
 | `inkos write rewrite [id] <n>` | Rewrite chapter N (restores state snapshot, `--force` to skip confirmation, `--words` to override) |
-| `inkos draft [id]` | Write draft only (`--words` to override word count) |
+| `inkos draft [id]` | Write draft only (`--words` to override word count, `-q` quiet mode) |
 | `inkos audit [id] [n]` | Audit a specific chapter |
 | `inkos revise [id] [n]` | Revise a specific chapter |
 | `inkos agent <instruction>` | Natural language agent mode |
 | `inkos review list [id]` | Review drafts |
 | `inkos review approve-all [id]` | Batch approve |
 | `inkos status [id]` | Project status |
-| `inkos export [id]` | Export book (`--format md`, `--output <path>`, `--approved-only`) |
+| `inkos export [id]` | Export book (`--format txt/md/epub`, `--output <path>`, `--approved-only`) |
 | `inkos radar scan` | Scan platform trends |
 | `inkos config set-global` | Set global LLM config (~/.inkos/.env) |
 | `inkos config show-global` | Show global config |
@@ -437,17 +195,17 @@ inkos up                          # Daemon mode
 | `inkos config set-model <agent> <model>` | Set model override for a specific agent (`--base-url`, `--provider`, `--api-key-env` for multi-provider routing) |
 | `inkos config remove-model <agent>` | Remove agent model override (fall back to default) |
 | `inkos config show-models` | Show current model routing |
-| `inkos doctor` | Diagnose setup issues (includes API connectivity test) |
+| `inkos doctor` | Diagnose setup issues (API connectivity test + provider compatibility hints) |
 | `inkos detect [id] [n]` | AIGC detection (`--all` for all chapters, `--stats` for statistics) |
 | `inkos style analyze <file>` | Analyze reference text to extract style fingerprint |
 | `inkos style import <file> [id]` | Import style fingerprint into a book |
 | `inkos import canon [id] --from <parent>` | Import parent canon for spinoff writing |
 | `inkos import chapters [id] --from <path>` | Import existing chapters for continuation (`--split`, `--resume-from`) |
-| `inkos analytics [id]` | Book analytics (audit pass rate, top issues, chapter ranking) |
+| `inkos analytics [id]` / `inkos stats [id]` | Book analytics (audit pass rate, top issues, chapter ranking, token usage) |
 | `inkos update` | Update to latest version |
-| `inkos up / down` | Start/stop daemon |
+| `inkos up / down` | Start/stop daemon (`-q` quiet mode, auto-writes `inkos.log`) |
 
-`[id]` is auto-detected when the project has only one book. All commands support `--json` for structured output. `draft`/`write next`/`book create` support `--context` for writing guidance and `--words` to override per-chapter word count (OpenClaw can dynamically control this per chapter).
+`[id]` is auto-detected when the project has only one book. All commands support `--json` for structured output. `draft`/`write next` support `--context` for writing guidance and `--words` to override per-chapter word count. `book create` supports `--brief <file>` to pass a creative brief (your brainstorming/worldbuilding doc) — the Architect builds from your ideas instead of generating from scratch.
 
 ## Key Features
 
@@ -469,7 +227,7 @@ Radar data sources are pluggable via the `RadarSource` interface. Built-in sourc
 
 ### Daemon Mode
 
-`inkos up` starts an autonomous background loop that writes chapters on a schedule. The pipeline runs fully unattended for non-critical issues, but pauses for human review when the auditor flags problems it cannot auto-fix.
+`inkos up` starts an autonomous background loop that writes chapters on a schedule. The pipeline runs fully unattended for non-critical issues, but pauses for human review when the auditor flags problems it cannot auto-fix. All logs are written to `inkos.log` (JSON Lines format) in the project root. Use `-q` to suppress stderr and keep only file logging.
 
 ### Notifications
 
@@ -524,12 +282,14 @@ TypeScript monorepo managed with pnpm workspaces.
 - [x] Cross-chapter coherence (chapter summaries + subplot/emotion/character matrices)
 - [x] Continuation writing (import chapters + auto reverse-engineer truth files + resumable import)
 - [x] Multi-provider agent routing (different agents use different API endpoints and keys, `inkos config set-model --base-url --provider`)
-- [x] Analytics (`inkos analytics`: audit pass rate, top issues, chapter ranking)
+- [x] Analytics (`inkos analytics`: audit pass rate, top issues, chapter ranking, token usage stats)
+- [x] EPUB export (`inkos export --format epub`, read on phone/Kindle)
+- [x] Structured logging (ANSI colors, JSON Lines file logging, quiet mode, LLM streaming heartbeat)
+- [x] Stream auto-fallback (auto sync retry when SSE fails — compatible with Zhipu, Gemini proxies, etc.)
+- [x] Local model compatibility (fallback parsing + partial response recovery on stream interruption)
+- [x] Creative brief (`book create --brief` — pass your brainstorming doc, Architect builds from it)
 - [ ] `packages/studio` Web UI for review and editing (Vite + React + Hono)
-- [ ] Cost tracking + runtime dashboard (per-chapter token usage, API cost, audit rounds, `inkos stats`)
-- [ ] EPUB export (`inkos export --format epub`, read on phone/Kindle)
 - [ ] Partial chapter intervention (rewrite half a chapter + cascade truth file updates)
-- [ ] Empty chapter / truncation fix (local model parsing tolerance + timeout reconnection)
 - [ ] Full English novel support (English genre profiles, prompts, audit rules, post-write validator)
 - [ ] Custom agent plugin system
 - [ ] Platform-specific export (Qidian, Tomato, etc.)

+ 51 - 291
README.md

@@ -20,248 +20,65 @@
 
 Agent 写小说。写、审、改,全程接管。
 
-## v0.4 更新
-
-续写 + 番外写作 + 文风仿写 + 多 Provider 路由 + 写后验证器 + 审计闭环加固。
-
-### 续写已有作品
-
-把已有的小说(单文件或章节目录)导入 InkOS,系统自动拆章、逆向工程生成全套真相文件(世界状态、伏笔、角色矩阵等),之后直接 `write next` 续写。
-
-```bash
-inkos import chapters 我的小说 --from 已有章节/        # 从目录导入
-inkos import chapters 我的小说 --from 全书.txt          # 从单文件导入(自动按"第X章"拆分)
-inkos import chapters 我的小说 --from 全书.txt --split "Chapter\\s+\\d+"  # 自定义分章正则
-inkos write next 我的小说                               # 无缝续写
-```
-
-单文件模式自动按 `第X章` 分章,也支持 `--split <regex>` 自定义。导入中断可用 `--resume-from <n>` 断点续导。
-
-### 番外写作(Spinoff)
-
-基于已有书创建前传、后传、外传或 if 线。番外和正传共享世界观和角色,但有独立剧情线。
-
-```bash
-inkos import canon 烈焰前传 --from 吞天魔帝   # 导入正传正典到番外
-inkos write next 烈焰前传                     # 写手自动读取正典约束
-```
-
-导入后生成 `story/parent_canon.md`,包含正传的世界规则、角色快照(含信息边界)、关键事件时间线、伏笔状态。写手在动笔前参照正典,审计员自动激活 4 个番外专属维度:
-
-| 维度 | 审查内容 |
-|------|----------|
-| 正传事件冲突 | 番外事件是否与正典约束表矛盾 |
-| 未来信息泄露 | 角色是否引用了分歧点之后才揭示的信息 |
-| 世界规则跨书一致性 | 番外是否违反正传世界规则(力量体系、地理、阵营) |
-| 番外伏笔隔离 | 番外是否越权回收正传伏笔 |
-
-检测到 `parent_canon.md` 自动激活,无需额外配置。
-
-### 文风仿写
+## 快速开始
 
-喂入真人小说片段,系统提取统计指纹 + 生成风格指南,后续每章自动注入写手 prompt。
+### 安装
 
 ```bash
-inkos style analyze 参考小说.txt                     # 分析:句长、TTR、修辞特征
-inkos style import 参考小说.txt 吞天魔帝 --name 某作者  # 导入文风到书
+npm i -g @actalk/inkos
 ```
 
-产出两个文件:
-- `style_profile.json` — 统计指纹(句长分布、段落长度、词汇多样性、修辞密度)
-- `style_guide.md` — LLM 生成的定性风格指南(节奏、语气、用词偏好、禁忌)
-
-写手每章读取风格指南,审计员在文风维度对照检查。
-
-### 写后验证器
-
-11 条确定性规则,零 LLM 成本,每章写完立刻触发:
-
-| 规则 | 说明 |
-|------|------|
-| 禁止句式 | 「不是……而是……」 |
-| 禁止破折号 | 「——」 |
-| 转折词密度 | 仿佛/忽然/竟然等,每 3000 字 ≤ 1 次 |
-| 高疲劳词 | 题材疲劳词单章每词 ≤ 1 次 |
-| 元叙事 | 编剧旁白式表述 |
-| 报告术语 | 分析框架术语不入正文 |
-| 作者说教 | 显然/不言而喻等 |
-| 集体反应 | 「全场震惊」类套话 |
-| 连续了字 | ≥ 6 句连续含「了」 |
-| 段落过长 | ≥ 2 个段落超 300 字 |
-| 本书禁忌 | book_rules.md 中的禁令 |
-
-验证器发现 error 级违规时,自动触发 `spot-fix` 模式定点修复,不等 LLM 审计。
-
-### 审计-修订闭环加固
-
-实测发现 `rewrite` 模式引入 6 倍 AI 标记词,现在:
-
-- 自动修订模式从 `rewrite` 改为 `spot-fix`(只改问题句,不碰其余正文)
-- 修订后对比 AI 标记数,如果修订反而增多 AI 痕迹,丢弃修订保留原文
-- 再审温度锁 0(消除审计随机性,同一章不再出现 0-6 个 critical 的波动)
-- `polish` 模式加固边界(禁止增删段落、改人名、加新情节)
-
-### 多 Provider 路由
+### 配置
 
-不同 agent 可以走不同 API 提供商——不只是换模型名,是完全不同的 API 地址和 Key。例如写手用便宜模型高速出稿,审计员用强模型精审:
+**方式一:全局配置(推荐,只需一次)**
 
 ```bash
-inkos config set-model writer gpt-4o-mini                                    # 简单模型覆盖
-inkos config set-model auditor gemini-2.5-flash \
-  --base-url https://generativelanguage.googleapis.com/v1beta/openai \
+inkos config set-global \
   --provider openai \
-  --api-key-env GEMINI_API_KEY                                                # 走 Gemini API
-inkos config set-model reviser claude-sonnet-4-20250514 \
-  --base-url https://api.anthropic.com \
-  --provider anthropic \
-  --api-key-env ANTHROPIC_API_KEY                                             # 走 Anthropic API
-inkos config show-models                                                      # 查看路由全景
-```
-
-每个 agent 独立配置 `--base-url`、`--provider`、`--api-key-env`、`--no-stream`。未覆盖的 agent 使用项目默认模型。
-
-### 数据分析
-
-```bash
-inkos analytics 吞天魔帝          # 审计通过率、高频问题类别、问题最多的章节
-inkos analytics 吞天魔帝 --json   # 结构化输出
+  --base-url https://api.openai.com/v1 \
+  --api-key sk-xxx \
+  --model gpt-4o
 ```
 
-### 其他 v0.4 变更
-
-- 审计维度从 26 扩展到 33(+4 番外维度 + dim 27 敏感词 + dim 32 读者期待管理 + dim 33 大纲偏离检测)
-- 审计员联网搜索:年代考据题材可联网核实真实事件/人物/地理(原生搜索能力)
-- 调度器重写:AI 节奏(默认 15 分钟一轮)、并行书处理、立即重试、每日上限
-- 修订者新增 `spot-fix` 模式(定点修复)
-- `book_rules.md` 的 `additionalAuditDimensions` 支持中文名称匹配
-- 全部 5 个题材激活 dim 24-26(支线停滞/弧线平坦/节奏单调)
-- `inkos export` 支持 `--format md`、`--output <path>`、`--approved-only`
-- 写后验证器「连续了字」阈值从 4 句上调至 6 句(减少中文叙事误报)
-- 安全加固:`init`/`book create`/`import chapters` 防覆盖检查、`config set` 类型推断 + key 校验、`update` 防降级、`doctor` 项目外可测 API、状态显示一致性、`genre show` 拒绝无效 ID
-
----
-
-## v0.3 更新
-
-创作规则三层分离 + 跨章记忆 + AIGC 检测 + Webhook。
-
-### 跨章记忆与写作质量
-
-Writer 每章自动生成摘要、更新支线/情感/角色矩阵,全部追加到真相文件。后续章节加载全量上下文,长线伏笔不再丢失。
-
-| 真相文件 | 用途 |
-|----------|------|
-| `chapter_summaries.md` | 各章摘要:出场人物、关键事件、状态变化、伏笔动态 |
-| `subplot_board.md` | 支线进度板:A/B/C 线状态追踪 |
-| `emotional_arcs.md` | 情感弧线:按角色追踪情绪、触发事件、弧线方向 |
-| `character_matrix.md` | 角色交互矩阵:相遇记录、信息边界 |
-
-### AIGC 检测
+配置保存在 `~/.inkos/.env`,所有项目共享。之后新建项目不用再配。
 
-| 功能 | 说明 |
-|------|------|
-| AI 痕迹审计 | 纯规则检测(不走 LLM):段落等长、套话密度、公式化转折、列表式结构,自动合并到审计结果 |
-| AIGC 检测 API | 外部 API 集成(GPTZero / Originality / 自定义端点),`inkos detect` 命令 |
-| 文风指纹学习 | 从参考文本提取 StyleProfile(句长、TTR、修辞特征),注入 Writer prompt |
-| 反检测改写 | ReviserAgent `anti-detect` 模式,检测→改写→重检测循环 |
-| 检测反馈闭环 | `detection_history.json` 记录每次检测/改写结果,`inkos detect --stats` 查看统计 |
+**方式二:项目级 `.env`**
 
 ```bash
-inkos style analyze reference.txt         # 分析参考文本文风
-inkos style import reference.txt 吞天魔帝  # 导入文风到书
-inkos detect 吞天魔帝 --all               # 全书 AIGC 检测
-inkos detect --stats                      # 检测统计
+inkos init my-novel     # 初始化项目
+# 编辑 my-novel/.env
 ```
 
-### Webhook + 智能调度
-
-管线事件 POST JSON 到配置 URL(HMAC-SHA256 签名),支持事件过滤(`chapter-complete`、`audit-failed`、`pipeline-error` 等)。守护进程增加质量门控:审计失败自动重试(调高 temperature)、连续失败暂停书籍。
-
-### 题材自定义
-
-内置 5 个题材,每个题材带一套完整的创作规则:章节类型、禁忌清单、疲劳词、语言铁律、审计维度。
-
-| 题材 | 自带规则 |
-|------|----------|
-| 玄幻 | 数值系统、战力体系、同质吞噬衰减公式、打脸/升级/收益兑现节奏 |
-| 仙侠 | 修炼/悟道节奏、法宝体系、天道规则 |
-| 都市 | 年代考据、商战/社交驱动、法律术语年代匹配、无数值系统 |
-| 恐怖 | 氛围递进、恐惧层级、克制叙事、无战力审计 |
-| 通用 | 最小化兜底 |
-
-创建书时指定题材,对应规则自动生效:
-
 ```bash
-inkos book create --title "吞天魔帝" --genre xuanhuan
-```
-
-题材规则可以查看、复制到项目中修改、或从零创建:
+# 必填
+INKOS_LLM_PROVIDER=openai                        # openai / anthropic
+INKOS_LLM_BASE_URL=https://api.openai.com/v1     # API 地址(支持中转站)
+INKOS_LLM_API_KEY=sk-xxx                          # API Key
+INKOS_LLM_MODEL=gpt-4o                            # 模型名
 
-```bash
-inkos genre list                      # 查看所有题材
-inkos genre show xuanhuan             # 查看玄幻的完整规则
-inkos genre copy xuanhuan             # 复制到项目中,随意改
-inkos genre create wuxia --name 武侠   # 从零创建新题材
+# 可选
+# INKOS_LLM_TEMPERATURE=0.7                       # 温度
+# INKOS_LLM_MAX_TOKENS=8192                        # 最大输出 token
+# INKOS_LLM_THINKING_BUDGET=0                      # Anthropic 扩展思考预算
 ```
 
-复制到项目后,增删禁忌、调整疲劳词、修改节奏规则、自定义语言铁律——改完下次写章自动生效。
-
-每个题材有专属语言铁律(带 ✗→✓ 示例),写手和审计员同时执行:
-
-- **玄幻**:✗ "火元从12缕增加到24缕" → ✓ "手臂比先前有力了,握拳时指骨发紧"
-- **都市**:✗ "迅速分析了当前的债务状况" → ✓ "把那叠皱巴巴的白条翻了三遍"
-- **恐怖**:✗ "感到一阵恐惧" → ✓ "后颈的汗毛一根根立起来"
-
-### 单本书规则
+项目 `.env` 会覆盖全局配置。不需要覆盖时可以不写。
 
-每本书有独立的 `book_rules.md`,建筑师 agent 创建书时自动生成,也可以随时手改。写在这里的规则注入每一章的 prompt:
+### 写第一本书
 
-```yaml
-protagonist:
-  name: 林烬
-  personalityLock: ["强势冷静", "能忍能杀", "有脑子不是疯狗"]
-  behavioralConstraints: ["不圣母不留手", "对盟友有温度但不煽情"]
-numericalSystemOverrides:
-  hardCap: 840000000
-  resourceTypes: ["微粒", "血脉浓度", "灵石"]
-prohibitions:
-  - 主角关键时刻心软
-  - 无意义后宫暧昧拖剧情
-  - 配角戏份喧宾夺主
-fatigueWordsOverride: ["瞳孔骤缩", "不可置信"]   # 覆盖题材默认
+```bash
+inkos book create --title "吞天魔帝" --genre xuanhuan  # 创建新书
+inkos write next 吞天魔帝      # 写下一章(完整管线:草稿 → 审计 → 修订)
+inkos status                   # 查看状态
+inkos review list 吞天魔帝     # 审阅草稿
+inkos review approve-all 吞天魔帝  # 批量通过
+inkos export 吞天魔帝          # 导出全书
+inkos export 吞天魔帝 --format epub  # 导出 EPUB(手机/Kindle 阅读)
 ```
 
-主角人设锁定、数值上限、自定义禁令、疲劳词覆盖——每本书的规则独立调整,不影响题材模板。
-
-### 33 维度审计
-
-审计细化为 33 个维度,按题材自动启用对应的子集:
-
-OOC检查、时间线、设定冲突、战力崩坏、数值检查、伏笔、节奏、文风、信息越界、词汇疲劳、利益链断裂、年代考据、配角降智、配角工具人化、爽点虚化、台词失真、流水账、知识库污染、视角一致性、段落等长、套话密度、公式化转折、列表式结构、支线停滞、弧线平坦、节奏单调、敏感词检查、正传事件冲突、未来信息泄露、世界规则跨书一致性、番外伏笔隔离、读者期待管理、大纲偏离检测
-
-dim 20-23(AI 痕迹)+ dim 27(敏感词)由纯规则引擎检测,不消耗 LLM 调用。dim 28-31(番外维度)检测到 `parent_canon.md` 自动激活。dim 32(读者期待管理)、dim 33(大纲偏离检测)始终开启。
-
-### 去 AI 味
-
-5 条通用规则 + 每个题材的专属语言规则,控制 AI 标记词密度和叙述习惯:
-
-- AI 标记词限频:仿佛/忽然/竟然/不禁/宛如/猛地,每 3000 字 ≤ 1 次
-- 叙述者不替读者下结论,只写动作
-- 禁止分析报告式语言("核心动机""信息落差"不入正文)
-- 同一意象渲染不超过两轮
-- 方法论术语不入正文
-
-词汇疲劳审计 + AI 痕迹审计(dim 20-23)双重检测。文风指纹注入进一步降低 AI 文本特征。
-
-### 其他
-
-- 支持 OpenAI + Anthropic 原生 + 所有 OpenAI 兼容接口
-- 修订者支持 polish / rewrite / rework / anti-detect / spot-fix 五种模式
-- 无数值系统的题材不生成资源账本
-- 所有命令支持 `--json` 结构化输出,OpenClaw / 外部 Agent 可直接解析
-- book-id 自动检测:项目只有一本书时省略 book-id
-- `inkos update` 一键更新、`inkos init` 支持当前目录初始化
-- API 错误附带中文诊断提示,`inkos doctor` 含 API 连通性测试
+<p align="center">
+  <img src="assets/screenshot-terminal.png" width="700" alt="终端截图">
+</p>
 
 ---
 
@@ -319,7 +136,7 @@ dim 20-23(AI 痕迹)+ dim 27(敏感词)由纯规则引擎检测,不消
 
 在此基础上,每个题材有专属规则(禁忌、语言铁律、节奏、审计维度),每本书有独立的 `book_rules.md`(主角人设、数值上限、自定义禁令)和 `story_bible.md`(世界观设定),由建筑师 agent 创建书籍时自动生成。
 
-详见 [v0.3 更新](#v03-更新-2026-03-13)。
+详见 [CHANGELOG](CHANGELOG.md)。
 
 ## 三种使用模式
 
@@ -352,84 +169,25 @@ inkos agent "先扫描市场趋势,然后根据结果创建一本新书"
 
 内置 13 个工具(write_draft、audit_chapter、revise_chapter、scan_market、create_book、get_book_status、read_truth_files、list_books、write_full_pipeline、web_fetch、import_style、import_canon、import_chapters),LLM 通过 tool-use 决定调用顺序。
 
-## 快速开始
-
-### 安装
-
-```bash
-npm i -g @actalk/inkos
-```
-
-### 配置
-
-**方式一:全局配置(推荐,只需一次)**
-
-```bash
-inkos config set-global \
-  --provider openai \
-  --base-url https://api.openai.com/v1 \
-  --api-key sk-xxx \
-  --model gpt-4o
-```
-
-配置保存在 `~/.inkos/.env`,所有项目共享。之后新建项目不用再配。
-
-**方式二:项目级 `.env`**
-
-```bash
-inkos init my-novel     # 初始化项目
-# 编辑 my-novel/.env
-```
-
-```bash
-# 必填
-INKOS_LLM_PROVIDER=openai                        # openai / anthropic
-INKOS_LLM_BASE_URL=https://api.openai.com/v1     # API 地址(支持中转站)
-INKOS_LLM_API_KEY=sk-xxx                          # API Key
-INKOS_LLM_MODEL=gpt-4o                            # 模型名
-
-# 可选
-# INKOS_LLM_TEMPERATURE=0.7                       # 温度
-# INKOS_LLM_MAX_TOKENS=8192                        # 最大输出 token
-# INKOS_LLM_THINKING_BUDGET=0                      # Anthropic 扩展思考预算
-```
-
-项目 `.env` 会覆盖全局配置。不需要覆盖时可以不写。
-
-### 使用
-
-```bash
-inkos book create --title "吞天魔帝" --genre xuanhuan  # 创建新书
-inkos write next 吞天魔帝      # 写下一章(完整管线)
-inkos status                   # 查看状态
-inkos review list 吞天魔帝     # 审阅草稿
-inkos export 吞天魔帝          # 导出全书
-inkos up                       # 守护进程模式
-```
-
-<p align="center">
-  <img src="assets/screenshot-terminal.png" width="700" alt="终端截图">
-</p>
-
 ## 命令参考
 
 | 命令 | 说明 |
 |------|------|
 | `inkos init [name]` | 初始化项目(省略 name 在当前目录初始化) |
-| `inkos book create` | 创建新书(`--genre`、`--platform`、`--chapter-words`、`--target-chapters`、`--context`) |
+| `inkos book create` | 创建新书(`--genre`、`--platform`、`--chapter-words`、`--target-chapters`、`--brief <file>` 传入创作简报) |
 | `inkos book update [id]` | 修改书设置(`--chapter-words`、`--target-chapters`、`--status`) |
 | `inkos book list` | 列出所有书籍 |
 | `inkos genre list/show/copy/create` | 查看、复制、创建题材 |
-| `inkos write next [id]` | 完整管线写下一章(`--words` 覆盖字数,`--count` 连写) |
+| `inkos write next [id]` | 完整管线写下一章(`--words` 覆盖字数,`--count` 连写,`-q` 静默模式) |
 | `inkos write rewrite [id] <n>` | 重写第 N 章(恢复状态快照,`--force` 跳过确认,`--words` 覆盖字数) |
-| `inkos draft [id]` | 只写草稿(`--words` 覆盖字数) |
+| `inkos draft [id]` | 只写草稿(`--words` 覆盖字数,`-q` 静默模式) |
 | `inkos audit [id] [n]` | 审计指定章节 |
 | `inkos revise [id] [n]` | 修订指定章节 |
 | `inkos agent <instruction>` | 自然语言 Agent 模式 |
 | `inkos review list [id]` | 审阅草稿 |
 | `inkos review approve-all [id]` | 批量通过 |
 | `inkos status [id]` | 项目状态 |
-| `inkos export [id]` | 导出书籍(`--format md`、`--output <path>`、`--approved-only`) |
+| `inkos export [id]` | 导出书籍(`--format txt/md/epub`、`--output <path>`、`--approved-only`) |
 | `inkos radar scan` | 扫描平台趋势 |
 | `inkos config set-global` | 设置全局 LLM 配置(~/.inkos/.env) |
 | `inkos config show-global` | 查看全局配置 |
@@ -437,17 +195,17 @@ inkos up                       # 守护进程模式
 | `inkos config set-model <agent> <model>` | 为指定 agent 设置模型覆盖(`--base-url`、`--provider`、`--api-key-env` 支持多 Provider 路由) |
 | `inkos config remove-model <agent>` | 移除 agent 模型覆盖(回退到默认) |
 | `inkos config show-models` | 查看当前模型路由 |
-| `inkos doctor` | 诊断配置问题(含 API 连通性测试) |
+| `inkos doctor` | 诊断配置问题(含 API 连通性测试 + 提供商兼容性提示) |
 | `inkos detect [id] [n]` | AIGC 检测(`--all` 全部章节,`--stats` 统计) |
 | `inkos style analyze <file>` | 分析参考文本提取文风指纹 |
 | `inkos style import <file> [id]` | 导入文风指纹到指定书 |
 | `inkos import canon [id] --from <parent>` | 导入正传正典到番外书 |
 | `inkos import chapters [id] --from <path>` | 导入已有章节续写(`--split`、`--resume-from`) |
-| `inkos analytics [id]` | 书籍数据分析(审计通过率、高频问题、章节排名) |
+| `inkos analytics [id]` / `inkos stats [id]` | 书籍数据分析(审计通过率、高频问题、章节排名、token 用量) |
 | `inkos update` | 更新到最新版本 |
-| `inkos up / down` | 启动/停止守护进程 |
+| `inkos up / down` | 启动/停止守护进程(`-q` 静默模式,自动写入 `inkos.log`) |
 
-`[id]` 参数在项目只有一本书时可省略,自动检测。所有命令支持 `--json` 输出结构化数据。`draft`/`write next`/`book create` 支持 `--context` 传入创作指导,`--words` 覆盖每章字数(OpenClaw 可逐章动态控制)。
+`[id]` 参数在项目只有一本书时可省略,自动检测。所有命令支持 `--json` 输出结构化数据。`draft`/`write next` 支持 `--context` 传入创作指导,`--words` 覆盖每章字数。`book create` 支持 `--brief <file>` 传入创作简报(你的脑洞/设定文档),Architect 会基于此生成设定而非凭空创作。
 
 ## 实测数据
 
@@ -487,7 +245,7 @@ inkos up                       # 守护进程模式
 
 ### 守护进程模式
 
-`inkos up` 启动后台循环,按计划写章。管线对非关键问题全自动运行,当审计员标记无法自动修复的问题时暂停等待人工审核。
+`inkos up` 启动后台循环,按计划写章。管线对非关键问题全自动运行,当审计员标记无法自动修复的问题时暂停等待人工审核。所有日志自动写入项目根目录 `inkos.log`(JSON Lines 格式),`-q` 静默模式关闭 stderr 只保留文件日志。
 
 ### 通知推送
 
@@ -542,12 +300,14 @@ TypeScript 单仓库,pnpm workspaces 管理。
 - [x] 审计-修订闭环加固(AI 标记守卫 + 温度锁)
 - [x] 续写已有作品(import chapters + 自动逆向真相文件 + 断点续导)
 - [x] 多 Provider 路由(不同 agent 走不同 API 地址和 Key,`inkos config set-model --base-url --provider`)
-- [x] 数据分析(`inkos analytics`:审计通过率、高频问题、章节排名)
+- [x] 数据分析(`inkos analytics`:审计通过率、高频问题、章节排名、token 用量统计)
+- [x] EPUB 导出(`inkos export --format epub`,手机/Kindle 阅读)
+- [x] 结构化日志系统(ANSI 颜色、JSON Lines 文件日志、静默模式、LLM 流式心跳)
+- [x] Stream 自动降级(中转站不支持 SSE 时自动回退 sync,兼容智谱/Gemini 等)
+- [x] 本地小模型兼容(fallback 解析 + 流中断部分内容恢复)
+- [x] 创作简报(`book create --brief` 传入你的脑洞,基于此生成设定)
 - [ ] `packages/studio` Web UI 审阅编辑界面(Vite + React + Hono)
-- [ ] 成本追踪 + 运行看板(每章 token 消耗、API 花费、审计轮次,`inkos stats`)
-- [ ] EPUB 导出(`inkos export --format epub`,手机/Kindle 阅读)
 - [ ] 局部干预(重写半章 + 级联更新后续 truth 文件)
-- [ ] 空章节/断章修复(本地小模型解析容错 + 超时重连)
 - [ ] 英文小说全面适配(English genre profiles, prompts, audit rules, post-write validator)
 - [ ] 自定义 agent 插件系统
 - [ ] 平台格式导出(起点、番茄等)