Commit Graph

427 Commits

Author SHA1 Message Date
Ma 90a26ea5d8 chore: bump version to 1.1.0, update CHANGELOG and README
Writing pipeline overhaul driven by Meta-Harness autoresearch:
- Foundation Reviewer with 5-dimension scoring and reject/retry loop
- New-spacetime requirements for fanfic mode
- Hook seed excerpt system (replacing lifecycle pressure)
- Review reject state rollback
- State validation recovery with settler retry
- Chapter number anchoring to contiguous durable artifacts
- Audit drift isolation
- Title collapse auto-repair
- Hook budget hints and chapter ending trail
- Mood/title/scene fatigue detection

Benchmark: from-scratch novels improved from 75 to 92/100.
2026-04-03 13:45:21 +08:00
Ma e771dee73a fix(pipeline): wire foundation review retries and hook budget 2026-04-03 10:13:48 +08:00
Ma 160f3a2704 feat(architect): add foundation reviewer and new-spacetime requirements
Three changes:

1. Architect fanfic prompt now requires a "new spacetime":
   - Explicit divergence point from source material
   - Original core conflict (not retelling original plot)
   - 5-chapter ignition constraint
   - 50% fresh scene locations

2. New FoundationReviewerAgent reviews architect output before
   writing begins. Scores 5 dimensions (source DNA, new space,
   core conflict, opening momentum, pacing feasibility).
   Threshold: 80 total, 60 floor per dimension.
   Rejects with specific feedback, architect regenerates.
   Max 2 retries before accepting best effort.

3. Review loop integrated into initBook (original mode) and
   initFanficBook (fanfic mode). Both now go through
   generate → review → (reject → regenerate) cycle.

This addresses the #2 problem (斗破同人 75.5): fanfic architect
was retelling original plot because nothing required it to create
new narrative space.
2026-04-03 09:55:33 +08:00
Ma b4f8e2df82 feat(pipeline): add hook budget hint and chapter ending trail
Hook budget: planner intent now shows "N/12 active hooks" in the
Hook Agenda section. When N >= 10, adds explicit guidance to
prioritize resolving old debt over opening new threads.
Soft hint only — no hard cap.

Ending trail: composer now extracts the last meaningful sentence
from the 3 most recent chapter files and injects it as context,
so the writer can see "ch3: buried under rubble | ch4: buried
under rubble" and know to vary the chapter ending structure.
2026-04-03 09:45:55 +08:00
Ma 54d090c351 fix(state): close remaining chapter-number pollution paths
Post-merge regression: bootstrapStructuredStateFromMarkdown still
included currentState.chapter in lastAppliedChapter, allowing a
hallucinated chapter number in current_state.md to override the
contiguous durable progress.

Changes:
- state-bootstrap.ts: derivedProgress and lastAppliedChapter now
  come exclusively from durableStoryProgress (contiguous artifact
  chain), currentState.chapter is no longer trusted
- manager.ts: getNextChapterNumber returns durableChapter + 1
  without consulting manifest
- story-markdown.ts: hook startChapter/lastAdvancedChapter parsed
  with parseStrictChapterInteger (rejects "第141号文明" style prose)
- Tests updated to provide durable chapter artifacts matching the
  chapter numbers they expect
2026-04-02 23:08:50 +08:00
Ma 47512e741c merge: integrate writing-pipeline-systemic-repair into master
Combines 43 commits of autoresearch pipeline improvements with
master's chapter-number anchoring fixes.

Key features merged:
- Hook seed excerpt system (replacing lifecycle pressure)
- Audit drift isolation (audit_drift.md)
- Cadence analysis (mood/scene/title fatigue detection)
- State validation retry + degraded recovery
- Review reject rollback
- Title collapse auto-repair
- Chapter number anchoring (contiguous prefix)
- Sequence-level fatigue excluded from revision blockers
2026-04-02 22:50:58 +08:00
Ma 2e64055927 fix(state): anchor chapter progress to contiguous durable chapters 2026-04-02 21:33:57 +08:00
Ma 66bb890e5c feat(hooks): replace lifecycle pressure system with seed excerpt approach
Removes the hook lifecycle/pressure scoring system (5-level timing,
pressure formulas, pressure map tables) and replaces it with:

1. Simple stalest-first sorting for mustAdvance (same as iter-001)
2. Hook seed excerpts in composer — for each hookAgenda target, finds
   the original chapter where it was planted and the latest advancement
   chapter, extracts the hookActivity text, and injects it as an
   evidence block the writer can directly build on.

The writer now sees concrete narrative material ("original seed (ch2):
萧炎右手碰到戒面时,有一丝温热渗出") instead of abstract metadata
("pressure: high, movement: partial-payoff, reason: stale-promise").

This addresses the hook execution problem: writer knew WHICH hooks to
advance but not HOW. Seed excerpts provide the "how" material.
2026-04-02 17:20:13 +08:00
Ma b4f5cc6d96 fix(pipeline): scope revision blockers and normalize delta chapters 2026-04-02 16:54:17 +08:00
Ma f4ee25b1fe fix(writer): override LLM-hallucinated chapter numbers in state delta
The settler may extract a chapter number from story content rather than
using the pipeline's authoritative value (e.g. parsing year "1988" from
a contemporary fiction novel as "第1988章").  This corrupts the manifest's
lastAppliedChapter, causing all subsequent chapters to use absurd numbers.

buildRuntimeStateArtifactsIfPresent now accepts an authoritative chapter
number and replaces the delta's chapter field when it disagrees.

Root cause of 旧城暗号v4's ch4→ch1988 numbering jump.
2026-04-02 16:15:13 +08:00
Ma fb8e1aa523 fix(pipeline): exclude sequence-level fatigue from revision blockingCount
Long-span-fatigue warnings (mood monotony, title clustering, pacing
repetition, opening/ending pattern similarity) are sequence-level
properties that cannot be fixed by revising the current chapter's text.

Previously these warnings inflated blockingCount in evaluateMergedAudit,
causing the revision gate to trigger or reject revisions for issues that
no single-chapter edit can resolve.

Now blockingCount only counts chapter-level issues (LLM audit, AI tells,
sensitive words). Sequence-level warnings still appear in the audit
report but no longer drive revision decisions.
2026-04-02 16:00:48 +08:00
Ma 86ea01a2a3 revert: undo prompt softening and compaction (iter-002 regression fix)
Reverts 822708e, 4248e1d, eb288b3 which:
- Softened all directive language from "must/do not" to "try/prefer"
- Compressed writer context into compact Story Briefs
- Removed selectedEvidenceBlock from governed mode
- Extended compact briefs to auditor/reviser

Control experiment showed these 3 commits are the primary regression
suspects: iter-001 build + gpt-5.4 scored 75.5/66.5, while iter-002
(with these commits) scored 71.5/37.5 on the same model.

Restores imperative directive language and full context sections.
2026-04-02 12:48:02 +08:00
Ma 16cbf271f7 refactor(pipeline): extract chapter truth validation 2026-04-01 19:52:06 +08:00
Ma f989204e6c refactor(pipeline): extract chapter persistence tail 2026-04-01 19:48:07 +08:00
Ma e2bf6cba81 refactor(pipeline): extract chapter review cycle 2026-04-01 19:38:16 +08:00
Ma 6759867285 fix(test): update hook table assertions for payoff_timing column
Three tests expected the old 7-column hook table format but the schema
now includes a payoff_timing column between expected_payoff and notes.
2026-04-01 18:14:26 +08:00
Ma 2a5ab2cbc0 refactor(pipeline): extract persisted governed plan loader 2026-04-01 17:27:20 +08:00
Ma 06070ca4be refactor(state): share story markdown parsers 2026-04-01 17:22:11 +08:00
Ma eb288b31f8 refactor(prompt): share compact governed process briefs 2026-04-01 17:12:15 +08:00
Ma 4248e1db56 refactor(prompt): compact governed writer control surface 2026-04-01 16:40:15 +08:00
Ma 616f807d6f refactor(pipeline): extract chapter state recovery 2026-04-01 16:21:45 +08:00
Ma ef7d4ebb6a refactor(pipeline): extract hook agenda from memory retrieval 2026-04-01 16:14:32 +08:00
Ma f3044007d4 feat(pipeline): auto-repair collapsed chapter titles 2026-04-01 16:05:41 +08:00
Ma b80056eac5 refactor(prompt): naturalize hook debt briefs 2026-04-01 15:44:26 +08:00
Ma 71a860e7d5 refactor(pipeline): centralize cadence pressure policy 2026-04-01 15:39:06 +08:00
Ma 822708e3ca refactor(prompt): soften governed creative guidance 2026-04-01 15:33:33 +08:00
Ma 82c28425a3 refactor(pipeline): align hook activity thresholds 2026-04-01 13:41:21 +08:00
Ma 2b911816c6 refactor(pipeline): centralize hook policy constants 2026-04-01 13:38:40 +08:00
Ma ba7f7c5f08 refactor(pipeline): unify legacy context windows 2026-04-01 13:24:55 +08:00
Ma 3f8528798f feat(pipeline): make hook retrieval lifecycle-aware 2026-04-01 13:15:38 +08:00
Ma 198cc94859 feat(pipeline): make hook agenda pressure-aware 2026-04-01 13:08:42 +08:00
Ma f0110e8d7b feat(pipeline): align hook audit with lifecycle semantics 2026-04-01 12:56:44 +08:00
Ma 2638f22927 fix(pipeline): isolate audit drift guidance from state 2026-04-01 12:43:38 +08:00
Ma c608cd3237 feat(pipeline): unify chapter cadence pressure analysis 2026-04-01 12:38:01 +08:00
Ma 6b12293dd5 feat(pipeline): add structured hook pressure map 2026-04-01 12:15:34 +08:00
Ma d6855e4e60 feat(pipeline): add semantic hook lifecycle guidance 2026-04-01 11:52:26 +08:00
Ma aeb64b658c feat(llm): support custom HTTP headers via INKOS_LLM_HEADERS env var
Some API providers (e.g. openclaudecode.cn) require a specific
User-Agent header for external clients.  Without it requests get 403.

Adds INKOS_LLM_HEADERS (JSON object) which is injected as
defaultHeaders into the OpenAI SDK client.  No effect when unset.
Also adds an optional `headers` field to LLMConfigSchema.
2026-04-01 10:11:18 +08:00
Ma e689a8391f feat(cli): expose degraded-state recovery flow 2026-04-01 09:52:01 +08:00
Ma 2e2264f255 fix(pipeline): recover from state validation failures 2026-04-01 09:50:59 +08:00
Ma bbb059bcdb fix(architect): tolerate section label format drift 2026-04-01 01:35:14 +08:00
Ma b688531b81 fix(studio): reload latest llm config per request 2026-04-01 01:35:02 +08:00
Ma b98bc78277 fix(studio): persist manual theme selection 2026-04-01 01:34:41 +08:00
Ma f9faefc27b fix(style): degrade gracefully when fingerprint extraction fails 2026-03-31 21:28:51 +08:00
Ma 48ea3e353d fix(review): preserve committed snapshots on approval 2026-03-31 21:28:09 +08:00
Ma 5f187f957c feat(review): reject rolls back state and discards downstream chapters
Adds StateManager.rollbackToChapter(bookId, targetChapter) which:
- Restores the snapshot at targetChapter
- Deletes chapter files, snapshots, and runtime artifacts beyond it
- Updates the chapter index to remove discarded entries

review reject now calls rollbackToChapter(chapterNum - 1) by default,
undoing the rejected chapter's state mutations and any subsequent chapters
that depended on them.  --keep-subsequent preserves legacy behavior.

review approve now re-snapshots the approved chapter to ensure a clean
rollback target exists.

This prevents bad drafts from permanently polluting truth files — the
core "audit-then-commit" invariant that was missing.
2026-03-31 20:36:50 +08:00
Ma 7316ed7027 feat(style): extract writing style in fanfic/continuation/import flows
Three changes:

1. FanficCanonImporter now extracts a writing_style section from source
   material — narration voice, sentence rhythm, dialogue markers, imagery
   preferences, emotional expression patterns, with source-text citations.

2. initFanficBook calls generateStyleGuide after canon import so fanfic
   books start with both style_profile.json and style_guide.md.

3. importCanon reads up to 5 parent chapters and generates a style guide
   for the target book.  importChapters does the same on first run.

These ensure continuation and fanfic books have style reference data
available to the writer from the first chapter onward.
2026-03-31 19:58:58 +08:00
Ma 1fa53d3131 feat(planner): emit mood directive when consecutive chapters are high-tension
Implements buildMoodDirective — detects when 3+ recent chapters share
high-tension mood keywords (紧张/冷硬/压抑/tense/grim/etc.) and emits
a structured directive forcing the writer to downshift to a quieter scene.

Completes the moodDirective slot that was declared but left as undefined
in the previous structured-directives commit.
2026-03-31 19:58:43 +08:00
Ma bf975e31b1 chore: bump version to 1.0.2 v1.0.2 2026-03-31 17:14:53 +08:00
Ma 1a6b50b807 fix(studio): wait for async book creation before failing 2026-03-31 16:39:22 +08:00
Ma c5af09f897 fix(titles): regenerate duplicates before suffix fallback 2026-03-31 16:00:18 +08:00