Просмотр исходного кода

chore: untrack docs/ — already in .gitignore

Ma 7 месяцев назад
Родитель
Сommit
6a60f2fc5b

+ 0 - 171
docs/plans/2026-03-28-v0.6.3-hardening-plan.md

@@ -1,171 +0,0 @@
-# v0.6.3 Hardening Implementation Plan
-
-> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
-
-**Goal:** Close the remaining 0.6.3 safety gaps around agent tool misuse, final-content paragraph checks, duplicate chapter titles, migration hints, and rewrite regression coverage.
-
-**Architecture:** Keep the current v2 pipeline, but tighten the remaining soft spots at the edges. Add deterministic guards in the agent dispatch layer, run final-content validation at the last safe point before persist, surface migration status in user-facing CLI flows, and add targeted regressions for the exact user-visible failures.
-
-**Tech Stack:** TypeScript, Vitest, Commander CLI
-
----
-
-### Task 1: Guard the remaining agent path
-
-**Files:**
-- Modify: `packages/core/src/__tests__/pipeline-agent.test.ts`
-- Modify: `packages/core/src/pipeline/agent.ts`
-
-**Step 1: Write the failing tests**
-
-Add tests that prove:
-- `write_full_pipeline` is rejected when the chapter sequence is inconsistent
-- `write_truth_file` cannot use `current_state.md` to mutate progress
-
-**Step 2: Run test to verify it fails**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/pipeline-agent.test.ts
-```
-
-**Step 3: Write minimal implementation**
-
-Reuse the same guard logic currently applied to `write_draft` and block `write_full_pipeline` before it calls `writeNextChapter()`.
-
-**Step 4: Run test to verify it passes**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/pipeline-agent.test.ts
-```
-
-**Step 5: Commit**
-
-```bash
-git add packages/core/src/pipeline/agent.ts packages/core/src/__tests__/pipeline-agent.test.ts
-git commit -m "fix: guard write_full_pipeline in agent dispatch"
-```
-
-### Task 2: Validate final persisted chapter shape
-
-**Files:**
-- Modify: `packages/core/src/__tests__/post-write-validator.test.ts`
-- Modify: `packages/core/src/__tests__/pipeline-runner.test.ts`
-- Modify: `packages/core/src/agents/post-write-validator.ts`
-- Modify: `packages/core/src/pipeline/runner.ts`
-
-**Step 1: Write the failing tests**
-
-Add tests that prove:
-- final persisted content can trigger `段落过碎` / `连续短段`
-- duplicate titles are handled as a real final-stage action, not a passive warning
-
-**Step 2: Run tests to verify they fail**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/post-write-validator.test.ts src/__tests__/pipeline-runner.test.ts
-```
-
-**Step 3: Write minimal implementation**
-
-Export a reusable final paragraph-shape detector and run it on `finalContent` before persist. Upgrade duplicate-title handling from a passive warning to an explicit final-stage resolution path.
-
-**Step 4: Run tests to verify they pass**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/post-write-validator.test.ts src/__tests__/pipeline-runner.test.ts
-```
-
-**Step 5: Commit**
-
-```bash
-git add packages/core/src/agents/post-write-validator.ts packages/core/src/pipeline/runner.ts packages/core/src/__tests__/post-write-validator.test.ts packages/core/src/__tests__/pipeline-runner.test.ts
-git commit -m "fix: harden final content validation and title handling"
-```
-
-### Task 3: Surface migration status in user-facing CLI flows
-
-**Files:**
-- Modify: `packages/cli/src/__tests__/cli-integration.test.ts`
-- Modify: `packages/cli/src/commands/status.ts`
-- Modify: `packages/cli/src/commands/write.ts`
-- Modify: `packages/cli/src/utils.ts`
-
-**Step 1: Write the failing tests**
-
-Add tests that prove:
-- `inkos status` shows a migration hint for legacy books
-- `inkos write next` warns before auto-migrating a legacy book
-
-**Step 2: Run tests to verify they fail**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/cli-integration.test.ts
-```
-
-**Step 3: Write minimal implementation**
-
-Add a shared CLI helper that detects legacy pre-v0.6 books and emits a clear hint in `status` and `write next`.
-
-**Step 4: Run tests to verify they pass**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/cli-integration.test.ts
-```
-
-**Step 5: Commit**
-
-```bash
-git add packages/cli/src/utils.ts packages/cli/src/commands/status.ts packages/cli/src/commands/write.ts packages/cli/src/__tests__/cli-integration.test.ts
-git commit -m "feat: show migration hints in status and write flows"
-```
-
-### Task 4: Verify rewrite from user path
-
-**Files:**
-- Modify: `packages/cli/src/__tests__/cli-integration.test.ts`
-
-**Step 1: Write the failing test**
-
-Add a CLI-level regression covering:
-- create 3 chapters
-- rewrite chapter 2
-- assert next chapter number is 2 again
-
-**Step 2: Run test to verify it fails**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/cli-integration.test.ts
-```
-
-**Step 3: Write minimal implementation**
-
-Prefer no production change unless the new CLI regression exposes a real gap.
-
-**Step 4: Run tests to verify it passes**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/cli-integration.test.ts
-```
-
-**Step 5: Commit**
-
-```bash
-git add packages/cli/src/__tests__/cli-integration.test.ts
-git commit -m "test: cover rewrite flow from CLI path"
-```

+ 0 - 76
docs/plans/2026-03-29-book-create-atomic-init-design.md

@@ -1,76 +0,0 @@
-# Book Create Atomic Init Design
-
-**Goal:** Eliminate half-initialized books by making `inkos book create` fail-closed: foundation generation must either produce a complete book or leave no book directory behind.
-
-## Problem
-
-Current `book create` is not atomic:
-
-- `PipelineRunner.initBook()` writes `book.json` before foundation generation.
-- `ArchitectAgent.parseSections()` silently substitutes placeholder text when a required section is missing.
-- CLI treats an existing but incomplete directory as resumable state.
-
-This creates dirty `books/<bookId>/` directories with partial files. Re-running create on the same title can then behave unpredictably.
-
-## Design
-
-### 1. Stage to a temporary book directory
-
-`initBook()` should build the full book in a temporary directory under `books/`:
-
-- write `book.json`
-- generate foundation
-- write foundation files
-- initialize control docs
-- create chapter index
-- snapshot chapter 0
-
-Only after all of that succeeds should the temp directory be renamed to the final `books/<bookId>/`.
-
-If any step fails, the temp directory is deleted.
-
-### 2. Treat missing Architect sections as hard failure
-
-`ArchitectAgent.parseSections()` should no longer emit placeholder text like:
-
-- `[book_rules 生成失败,需要重新生成]`
-
-Missing required sections should throw an error immediately. This prevents malformed foundations from being persisted as if they were valid content.
-
-### 3. Remove resumable incomplete-init semantics
-
-CLI should no longer “resume incomplete book creation”.
-
-If `books/<bookId>/` exists:
-
-- if it looks complete, `book create` should fail with “already exists”
-- if it looks incomplete, it should be treated as stale partial state and removed before a fresh atomic create starts
-
-This keeps the behavior simple:
-
-- success => complete book exists
-- failure => no book directory remains
-
-## Scope
-
-In scope:
-
-- `book create`
-- `PipelineRunner.initBook()`
-- Architect foundation parsing
-- stale incomplete directory cleanup
-- regression tests
-
-Out of scope:
-
-- `initFanficBook()` atomic staging
-- state-validator robustness
-- interactive-fiction work
-
-## Validation
-
-Add regressions for:
-
-1. `ArchitectAgent` throws when a required section is missing.
-2. `PipelineRunner.initBook()` leaves no final book directory when foundation generation fails.
-3. CLI `book create` removes stale incomplete directories and does not keep a dirty directory when create fails downstream.

+ 0 - 116
docs/plans/2026-03-29-book-create-atomic-init-implementation-plan.md

@@ -1,116 +0,0 @@
-# Book Create Atomic Init Implementation Plan
-
-> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
-
-**Goal:** Make `book create` atomic so malformed Architect output or failed initialization never leaves a half-built book directory behind.
-
-**Architecture:** Stage new books in a temporary directory, require Architect to return all mandatory sections, and delete stale incomplete directories instead of resuming them. Promote the staged directory into place only after all initialization steps succeed.
-
-**Tech Stack:** TypeScript, Vitest, Commander CLI, Node `fs/promises`
-
----
-
-### Task 1: Lock down Architect missing-section failure
-
-**Files:**
-- Modify: `packages/core/src/__tests__/architect.test.ts`
-- Modify: `packages/core/src/agents/architect.ts`
-
-**Step 1: Write the failing test**
-
-Add a test showing `generateFoundation()` rejects when `book_rules` is missing from the LLM response.
-
-**Step 2: Run test to verify it fails**
-
-Run: `pnpm vitest run src/__tests__/architect.test.ts -t "throws when a required foundation section is missing"`
-
-**Step 3: Write minimal implementation**
-
-Change `parseSections()` to throw on missing required sections instead of returning placeholder content.
-
-**Step 4: Run test to verify it passes**
-
-Run the same Vitest command and confirm it passes.
-
-### Task 2: Lock down atomic init rollback
-
-**Files:**
-- Modify: `packages/core/src/__tests__/pipeline-runner.test.ts`
-- Modify: `packages/core/src/state/manager.ts`
-- Modify: `packages/core/src/pipeline/runner.ts`
-
-**Step 1: Write the failing test**
-
-Add a regression showing `initBook()` leaves no final `books/<bookId>/` when foundation generation fails.
-
-**Step 2: Run test to verify it fails**
-
-Run: `pnpm vitest run src/__tests__/pipeline-runner.test.ts -t "cleans staged files when initBook fails before foundation is complete"`
-
-**Step 3: Write minimal implementation**
-
-Implement staged initialization in a temporary directory, then rename into place only after success. Add helper methods in `StateManager` as needed for path-based control-doc/index/snapshot writes.
-
-**Step 4: Run test to verify it passes**
-
-Run the same Vitest command and confirm it passes.
-
-### Task 3: Lock down stale incomplete-directory cleanup at CLI level
-
-**Files:**
-- Modify: `packages/cli/src/__tests__/cli-integration.test.ts`
-- Modify: `packages/cli/src/commands/book.ts`
-
-**Step 1: Write the failing test**
-
-Add a CLI regression where a stale incomplete `books/<bookId>/` exists before `book create`, and verify the command does not preserve that stale directory when create later fails.
-
-**Step 2: Run test to verify it fails**
-
-Run: `pnpm vitest run src/__tests__/cli-integration.test.ts -t "removes stale incomplete book directories before retrying create"`
-
-**Step 3: Write minimal implementation**
-
-Replace “resume incomplete book creation” behavior with stale-directory cleanup plus fresh atomic create.
-
-**Step 4: Run test to verify it passes**
-
-Run the same Vitest command and confirm it passes.
-
-### Task 4: Run focused verification
-
-**Files:**
-- No production changes expected
-
-**Step 1: Run targeted suite**
-
-Run:
-
-```bash
-pnpm vitest run src/__tests__/architect.test.ts src/__tests__/pipeline-runner.test.ts
-```
-
-in `packages/core`, and:
-
-```bash
-pnpm vitest run src/__tests__/cli-integration.test.ts
-```
-
-in `packages/cli`.
-
-**Step 2: Run typecheck**
-
-Run:
-
-```bash
-pnpm typecheck
-```
-
-in `packages/core` and `packages/cli`.
-
-**Step 3: Commit**
-
-```bash
-git add docs/plans/2026-03-29-book-create-atomic-init-design.md docs/plans/2026-03-29-book-create-atomic-init-implementation-plan.md packages/core/src/agents/architect.ts packages/core/src/pipeline/runner.ts packages/core/src/state/manager.ts packages/core/src/__tests__/architect.test.ts packages/core/src/__tests__/pipeline-runner.test.ts packages/cli/src/commands/book.ts packages/cli/src/__tests__/cli-integration.test.ts
-git commit -m "fix: make book creation fail closed"
-```

+ 0 - 248
docs/superpowers/specs/2026-03-18-studio-redesign-design.md

@@ -1,248 +0,0 @@
-# InkOS Studio Redesign — From CLI Viewer to Independent Workbench
-
-## Purpose
-
-Transform InkOS Studio from a read-mostly web viewer into a fully independent creative workbench that replaces the CLI entirely. Authors open their browser and never need a terminal again.
-
-## Users
-
-- Chinese web fiction authors writing for 番茄小说 / 起点中文网
-- English web fiction authors writing for Royal Road / Kindle Unlimited / Scribble Hub
-- These are two distinct user populations with different workflows, genres, platforms, and aesthetic expectations
-
-## Success Criteria
-
-1. Every CLI operation is achievable through Studio (via UI or Chat)
-2. A new user can go from zero to first chapter without touching a terminal
-3. Chinese and English authors each feel the product was built for them specifically
-
----
-
-## Architecture
-
-### Layout
-
-```
-┌──────────┬──────────────────────────────────┐
-│ Sidebar  │          Main Area               │
-│          │                                  │
-│ 书籍列表  │   Pages: Dashboard, BookDetail,  │
-│ 题材管理  │   ChapterReader, BookCreate,     │
-│ 配置     │   Config, GenreManager, Daemon,   │
-│ Daemon   │   TruthFiles, Analytics, Logs     │
-│ 日志     │                                  │
-│          ├──────────────────────────────────┤
-│          │ 💬 Tell InkOS what to do...  [↑] │
-└──────────┴──────────────────────────────────┘
-```
-
-- **Sidebar** (180-200px): Fixed left navigation. Book list at top, system tools at bottom. Shows active language mode (ZH/EN).
-- **Main Area**: Page content fills remaining width. All 10+ pages render here.
-- **Chat Bar** (bottom, default collapsed to 1 line): Always visible input. Expands upward on input to show conversation. Connects to `inkos agent` (13 built-in tools). Closes back to 1 line when idle.
-
-### Chat Bar Behavior
-
-- Default: single-line input with placeholder text ("告诉 InkOS 你想做什么..." / "Tell InkOS what to do...")
-- On focus/input: expands to ~200px showing recent messages
-- Displays real-time progress during write operations (Phase 1/2, streaming stats)
-- Results update the main area (e.g., chat says "write next" → chapter appears in book detail)
-- Closeable via ✕, reopens via keyboard shortcut or sidebar icon
-
-### Chat ↔ UI Integration
-
-Chat is not isolated — it drives the same API as button clicks:
-- User types "写下一章" → POST /api/books/:id/write-next (same as clicking "Write Next")
-- User types "审计第5章" → POST /api/books/:id/audit/5
-- User types "帮我创建一本都市修仙" → multi-step: create book → init → navigate to book detail
-- Progress and results reflect in both chat and main UI simultaneously via SSE
-
----
-
-## Chinese / English Isolation
-
-### Implementation: Language Mode
-
-First-time setup: language selector screen before anything else. Choice persists in project config (`language` field). Switchable in settings but not casually toggled.
-
-### What Changes Per Mode
-
-| Aspect | Chinese Mode | English Mode |
-|--------|-------------|--------------|
-| UI language | All labels, buttons, breadcrumbs in Chinese | All in English |
-| Genre list | 玄幻, 仙侠, 都市, 恐怖, 通用 | LitRPG, Progression, System Apocalypse, etc. |
-| Default word count | 3000 字/章 | 2000 words/chapter |
-| Platform options | 番茄, 起点, 飞卢 | Royal Road, KU, Scribble Hub, Other |
-| AI-tell detection | Chinese fatigue words | English AI-tell word list |
-| Audit dimension labels | Chinese names | English names |
-| Chat placeholder | "告诉 InkOS 你想做什么..." | "Tell InkOS what to do..." |
-| Typography | System sans (optimized for CJK) + Instrument Serif for headings | DM Sans + Instrument Serif |
-| Example content | Chinese novel excerpts | English web fiction excerpts |
-| Empty state copy | Chinese onboarding text | English onboarding text |
-
-### What Does NOT Change
-
-- Layout structure (same sidebar + main + chat bar)
-- Color palette (Midnight Manuscript warm amber)
-- API endpoints
-- Core engine logic (all in @actalk/inkos-core)
-
----
-
-## Pages — Full Scope
-
-### 1. Language Selector (first-time only)
-
-- Full-screen choice: "中文创作" / "English Writing"
-- Sets project `language` field
-- Never shown again (changeable in Config)
-
-### 2. Dashboard (home)
-
-- Recent activity feed (chapters written, audits completed)
-- Book cards with status, chapter count, word count
-- Daemon status indicator (running/stopped with toggle)
-- Quick actions: "New Book" button
-- Active writing progress (from SSE) if daemon is running
-
-### 3. Book Detail
-
-- Chapter list table with status badges
-- Actions per chapter: read, approve, reject, audit, revise
-- Book-level actions: Write Next, Draft Only, Approve All, Export
-- Truth Files quick access link
-- Analytics link
-- Book metadata display (genre, platform, word count, language, fanfic mode)
-
-### 4. Chapter Reader
-
-- Full prose reading with literary typography
-- Approve / Reject actions
-- Navigation: previous / next chapter
-- Word count display
-
-### 5. Book Create
-
-- Multi-step or single form:
-  - Title, Genre (filtered by language mode), Platform (filtered by language mode)
-  - Words per chapter, Target chapters
-  - Brief file upload (optional)
-  - Fanfic mode toggle (with source file upload if fanfic)
-  - Spinoff parent selection (if spinoff)
-- Creates book + generates foundation (async, progress in chat bar)
-
-### 6. Config
-
-- All settings editable inline (no CLI needed):
-  - LLM: provider, baseUrl, model, temperature, maxTokens, stream, API format
-  - Language: switch mode
-  - Daemon: cron schedules, max concurrent, chapters per cycle, daily cap
-  - Notifications: add/remove channels (telegram, feishu, wechat, webhook)
-  - Multi-model routing: set model per agent (writer, auditor, reviser, architect, radar)
-- Save button writes to inkos.json
-
-### 7. Genre Manager
-
-- List all genres (builtin + project custom)
-- View genre details (rules, fatigue words, chapter types, audit dimensions)
-- Copy builtin to project for customization
-- Create new custom genre
-- Edit project genres
-
-### 8. Daemon Control
-
-- Start / Stop toggle
-- Status: running, stopped, paused (with reason)
-- Schedule display (write cron, radar cron)
-- Paused books list with resume action
-- Real-time event log (from SSE)
-
-### 9. Truth Files Browser
-
-- Split pane: file list | content viewer
-- All truth files: story_bible, volume_outline, current_state, ledger, hooks, summaries, subplots, emotional_arcs, character_matrix, style_guide, parent_canon, fanfic_canon, book_rules
-- Read-only for now (editing is a future enhancement)
-
-### 10. Analytics
-
-- Stat cards: total chapters, total words, avg words/chapter, audit pass rate
-- Status distribution chart
-- Token usage (if available): total, per-chapter trend
-- Top issue categories
-- Chapters with most issues
-
-### 11. Log Viewer
-
-- Last 100 entries from inkos.log
-- Color-coded by level (error=red, warn=amber, info=primary, debug=muted)
-- Auto-refresh or manual refresh button
-- Timestamp + level + tag + message columns
-
----
-
-## API Additions Needed
-
-Current API covers ~60% of requirements. Missing:
-
-| Endpoint | Purpose |
-|----------|---------|
-| POST /api/books/:id/audit/:chapter | Trigger audit |
-| POST /api/books/:id/revise/:chapter | Trigger revision |
-| POST /api/books/:id/export | Export book (returns file) |
-| GET/POST /api/genres | List / create genres |
-| GET/PUT /api/genres/:id | View / edit genre |
-| POST /api/genres/:id/copy | Copy builtin to project |
-| POST /api/books/:id/import-chapters | Import chapters from uploaded file |
-| POST /api/books/:id/import-canon | Import canon from parent book |
-| POST /api/books/:id/style-analyze | Upload + analyze style |
-| POST /api/books/:id/style-import | Import style fingerprint |
-| POST /api/books/:id/detect/:chapter | AIGC detection |
-| POST /api/agent | Chat endpoint — sends to inkos agent, streams response |
-| PUT /api/books/:id/truth/:file | Edit truth file |
-| POST /api/init | Initialize new project |
-| PUT /api/project/notify | Add/remove notification channels |
-| PUT /api/project/model-overrides | Set multi-model routing |
-
----
-
-## Implementation Phases
-
-### Phase 1: Layout + Chat Bar + Language Selector
-- New sidebar layout replacing top nav
-- Bottom chat bar component (collapse/expand)
-- Chat ↔ agent API integration
-- Language selector first-time flow
-- Language mode throughout existing pages
-
-### Phase 2: Config Full Edit + Genre Manager
-- Config page: all settings editable
-- Multi-model routing UI
-- Notification channel management
-- Genre manager page (list/view/copy/create)
-- Corresponding API endpoints
-
-### Phase 3: Missing Operations
-- Audit / Revise triggers in Book Detail
-- Export (download) action
-- Import chapters (file upload)
-- Import canon (parent book selection)
-- Style analyze + import (file upload)
-- AIGC detection trigger + results display
-
-### Phase 4: Polish
-- Responsive (tablet-friendly at minimum)
-- Keyboard shortcuts
-- First-time onboarding flow improvements
-- coss ui component adoption for dialogs, selects, dropdowns
-- Performance (lazy loading pages, code splitting)
-
----
-
-## Not In Scope (this design)
-
-- Real-time collaborative editing (multi-user)
-- Mobile-first responsive design (tablet OK, phone not targeted)
-- Truth file inline editing (read-only browser for now)
-- Drag-and-drop chapter reordering
-- Rich text chapter editor (authors write via AI, not by hand)
-- Version control / diff view for truth files
-- Plugin/extension system in Studio