@zwbigi/ink-xy 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (598) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +2 -2
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/server/app/_global-error.html +1 -1
  5. package/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/server/app/_not-found.html +1 -1
  13. package/.next/server/app/_not-found.rsc +1 -1
  14. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  15. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  20. package/.next/server/app/api/inkos/route.js.nft.json +1 -1
  21. package/.next/server/app/api/skills/install/route.js.nft.json +1 -1
  22. package/.next/server/app/api/skills/search/route.js.nft.json +1 -1
  23. package/.next/server/app/index.html +1 -1
  24. package/.next/server/app/index.rsc +1 -1
  25. package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  26. package/.next/server/app/index.segments/_full.segment.rsc +1 -1
  27. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  28. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  29. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  30. package/.next/server/app-paths-manifest.json +2 -2
  31. package/.next/server/chunks/162.js +1 -1
  32. package/.next/server/middleware-build-manifest.js +1 -1
  33. package/.next/server/pages/404.html +1 -1
  34. package/.next/server/pages/500.html +1 -1
  35. package/.next/trace +4 -4
  36. package/.next/trace-build +1 -1
  37. package/bin/pi-web.js +4 -1
  38. package/inkos/.env.example +20 -0
  39. package/inkos/.node-version +1 -0
  40. package/inkos/.nvmrc +1 -0
  41. package/inkos/CHANGELOG.md +787 -0
  42. package/inkos/CONTRIBUTING.md +89 -0
  43. package/inkos/LICENSE +661 -0
  44. package/inkos/README.en.md +483 -0
  45. package/inkos/README.ja.md +461 -0
  46. package/inkos/README.md +272 -0
  47. package/inkos/assets/15qun.jpg +0 -0
  48. package/inkos/assets/41777702961_.pic.jpg +0 -0
  49. package/inkos/assets/inkos-short-demo-cover.png +0 -0
  50. package/inkos/assets/inkos-text.svg +40 -0
  51. package/inkos/assets/logo.svg +47 -0
  52. package/inkos/assets/screenshot-chapters.png +0 -0
  53. package/inkos/assets/screenshot-pipeline.png +0 -0
  54. package/inkos/assets/screenshot-state.png +0 -0
  55. package/inkos/assets/screenshot-terminal.png +0 -0
  56. package/inkos/assets/wechat-group-v8.jpg +0 -0
  57. package/inkos/package.json +42 -0
  58. package/inkos/packages/cli/package.json +74 -0
  59. package/inkos/packages/cli/src/__tests__/analytics.test.ts +154 -0
  60. package/inkos/packages/cli/src/__tests__/cli-integration.test.ts +1031 -0
  61. package/inkos/packages/cli/src/__tests__/daemon.test.ts +93 -0
  62. package/inkos/packages/cli/src/__tests__/doctor.test.ts +36 -0
  63. package/inkos/packages/cli/src/__tests__/interact-command.test.ts +142 -0
  64. package/inkos/packages/cli/src/__tests__/interaction-tools.test.ts +107 -0
  65. package/inkos/packages/cli/src/__tests__/llm-overrides.test.ts +25 -0
  66. package/inkos/packages/cli/src/__tests__/localization.test.ts +121 -0
  67. package/inkos/packages/cli/src/__tests__/progress-text.test.ts +92 -0
  68. package/inkos/packages/cli/src/__tests__/project-bootstrap.test.ts +71 -0
  69. package/inkos/packages/cli/src/__tests__/publish-package.test.ts +272 -0
  70. package/inkos/packages/cli/src/__tests__/revision-command.test.ts +82 -0
  71. package/inkos/packages/cli/src/__tests__/runtime-requirements.test.ts +89 -0
  72. package/inkos/packages/cli/src/__tests__/short-fiction-command.test.ts +48 -0
  73. package/inkos/packages/cli/src/__tests__/studio-runtime.test.ts +142 -0
  74. package/inkos/packages/cli/src/__tests__/studio.test.ts +87 -0
  75. package/inkos/packages/cli/src/__tests__/tui-activity-state.test.ts +20 -0
  76. package/inkos/packages/cli/src/__tests__/tui-agent-session.test.ts +213 -0
  77. package/inkos/packages/cli/src/__tests__/tui-chat-depth.test.ts +27 -0
  78. package/inkos/packages/cli/src/__tests__/tui-chat-draft.test.ts +44 -0
  79. package/inkos/packages/cli/src/__tests__/tui-command.test.ts +86 -0
  80. package/inkos/packages/cli/src/__tests__/tui-composer-caret.test.ts +46 -0
  81. package/inkos/packages/cli/src/__tests__/tui-composer-display.test.ts +40 -0
  82. package/inkos/packages/cli/src/__tests__/tui-dashboard.test.tsx +219 -0
  83. package/inkos/packages/cli/src/__tests__/tui-effects-i18n.test.ts +29 -0
  84. package/inkos/packages/cli/src/__tests__/tui-i18n.test.ts +22 -0
  85. package/inkos/packages/cli/src/__tests__/tui-input-chrome.test.ts +10 -0
  86. package/inkos/packages/cli/src/__tests__/tui-input-history.test.ts +40 -0
  87. package/inkos/packages/cli/src/__tests__/tui-layout.test.ts +55 -0
  88. package/inkos/packages/cli/src/__tests__/tui-local-commands.test.ts +47 -0
  89. package/inkos/packages/cli/src/__tests__/tui-session-store.test.ts +81 -0
  90. package/inkos/packages/cli/src/__tests__/tui-setup-i18n.test.ts +31 -0
  91. package/inkos/packages/cli/src/__tests__/tui-slash-autocomplete.test.ts +33 -0
  92. package/inkos/packages/cli/src/commands/agent.ts +65 -0
  93. package/inkos/packages/cli/src/commands/analytics.ts +77 -0
  94. package/inkos/packages/cli/src/commands/audit.ts +52 -0
  95. package/inkos/packages/cli/src/commands/book.ts +260 -0
  96. package/inkos/packages/cli/src/commands/compose.ts +50 -0
  97. package/inkos/packages/cli/src/commands/config.ts +328 -0
  98. package/inkos/packages/cli/src/commands/consolidate.ts +50 -0
  99. package/inkos/packages/cli/src/commands/daemon.ts +121 -0
  100. package/inkos/packages/cli/src/commands/detect.ts +125 -0
  101. package/inkos/packages/cli/src/commands/doctor.ts +391 -0
  102. package/inkos/packages/cli/src/commands/draft.ts +43 -0
  103. package/inkos/packages/cli/src/commands/eval.ts +217 -0
  104. package/inkos/packages/cli/src/commands/export.ts +45 -0
  105. package/inkos/packages/cli/src/commands/fanfic.ts +183 -0
  106. package/inkos/packages/cli/src/commands/genre.ts +160 -0
  107. package/inkos/packages/cli/src/commands/import.ts +158 -0
  108. package/inkos/packages/cli/src/commands/init.ts +47 -0
  109. package/inkos/packages/cli/src/commands/interact.ts +109 -0
  110. package/inkos/packages/cli/src/commands/plan.ts +54 -0
  111. package/inkos/packages/cli/src/commands/radar.ts +60 -0
  112. package/inkos/packages/cli/src/commands/review.ts +253 -0
  113. package/inkos/packages/cli/src/commands/revise.ts +58 -0
  114. package/inkos/packages/cli/src/commands/short-fiction.ts +294 -0
  115. package/inkos/packages/cli/src/commands/status.ts +138 -0
  116. package/inkos/packages/cli/src/commands/studio.ts +194 -0
  117. package/inkos/packages/cli/src/commands/style.ts +99 -0
  118. package/inkos/packages/cli/src/commands/tui.ts +18 -0
  119. package/inkos/packages/cli/src/commands/update.ts +45 -0
  120. package/inkos/packages/cli/src/commands/write.ts +324 -0
  121. package/inkos/packages/cli/src/index.ts +5 -0
  122. package/inkos/packages/cli/src/interaction/tools.ts +49 -0
  123. package/inkos/packages/cli/src/localization.ts +215 -0
  124. package/inkos/packages/cli/src/program.ts +106 -0
  125. package/inkos/packages/cli/src/progress-text.ts +85 -0
  126. package/inkos/packages/cli/src/project-bootstrap.ts +175 -0
  127. package/inkos/packages/cli/src/runtime-requirements.ts +135 -0
  128. package/inkos/packages/cli/src/tui/__tests__/markdown.test.ts +64 -0
  129. package/inkos/packages/cli/src/tui/activity-state.ts +41 -0
  130. package/inkos/packages/cli/src/tui/agent-input.ts +264 -0
  131. package/inkos/packages/cli/src/tui/ansi.ts +72 -0
  132. package/inkos/packages/cli/src/tui/app.ts +130 -0
  133. package/inkos/packages/cli/src/tui/chat-depth.ts +22 -0
  134. package/inkos/packages/cli/src/tui/chat-draft.ts +42 -0
  135. package/inkos/packages/cli/src/tui/composer-caret.ts +22 -0
  136. package/inkos/packages/cli/src/tui/composer-display.ts +26 -0
  137. package/inkos/packages/cli/src/tui/dashboard-model.ts +164 -0
  138. package/inkos/packages/cli/src/tui/dashboard.tsx +544 -0
  139. package/inkos/packages/cli/src/tui/effects.ts +542 -0
  140. package/inkos/packages/cli/src/tui/i18n.ts +278 -0
  141. package/inkos/packages/cli/src/tui/input-history.ts +69 -0
  142. package/inkos/packages/cli/src/tui/local-commands.ts +55 -0
  143. package/inkos/packages/cli/src/tui/markdown.ts +64 -0
  144. package/inkos/packages/cli/src/tui/session-store.ts +6 -0
  145. package/inkos/packages/cli/src/tui/setup.ts +397 -0
  146. package/inkos/packages/cli/src/tui/slash-autocomplete.ts +62 -0
  147. package/inkos/packages/cli/src/tui/theme.ts +17 -0
  148. package/inkos/packages/cli/src/utils.ts +222 -0
  149. package/inkos/packages/cli/tsconfig.json +9 -0
  150. package/inkos/packages/core/genres/cozy.md +43 -0
  151. package/inkos/packages/core/genres/cultivation.md +42 -0
  152. package/inkos/packages/core/genres/dungeon-core.md +40 -0
  153. package/inkos/packages/core/genres/horror.md +51 -0
  154. package/inkos/packages/core/genres/isekai.md +43 -0
  155. package/inkos/packages/core/genres/litrpg.md +43 -0
  156. package/inkos/packages/core/genres/other.md +24 -0
  157. package/inkos/packages/core/genres/progression.md +41 -0
  158. package/inkos/packages/core/genres/romantasy.md +45 -0
  159. package/inkos/packages/core/genres/sci-fi.md +42 -0
  160. package/inkos/packages/core/genres/system-apocalypse.md +40 -0
  161. package/inkos/packages/core/genres/tower-climber.md +41 -0
  162. package/inkos/packages/core/genres/urban.md +53 -0
  163. package/inkos/packages/core/genres/xianxia.md +46 -0
  164. package/inkos/packages/core/genres/xuanhuan.md +64 -0
  165. package/inkos/packages/core/package.json +61 -0
  166. package/inkos/packages/core/src/__tests__/agent-max-tokens-policy.test.ts +29 -0
  167. package/inkos/packages/core/src/__tests__/agent-session.test.ts +866 -0
  168. package/inkos/packages/core/src/__tests__/agent-system-prompt.test.ts +167 -0
  169. package/inkos/packages/core/src/__tests__/agent-tools-params.test.ts +197 -0
  170. package/inkos/packages/core/src/__tests__/agent-tools.test.ts +421 -0
  171. package/inkos/packages/core/src/__tests__/ai-tells.test.ts +90 -0
  172. package/inkos/packages/core/src/__tests__/architect-phase5-consolidated.test.ts +445 -0
  173. package/inkos/packages/core/src/__tests__/architect-phase5.test.ts +455 -0
  174. package/inkos/packages/core/src/__tests__/architect-phase7.test.ts +210 -0
  175. package/inkos/packages/core/src/__tests__/architect.test.ts +859 -0
  176. package/inkos/packages/core/src/__tests__/audit-parse.test.ts +78 -0
  177. package/inkos/packages/core/src/__tests__/book-id.test.ts +26 -0
  178. package/inkos/packages/core/src/__tests__/book-session-store.test.ts +447 -0
  179. package/inkos/packages/core/src/__tests__/book-session.test.ts +113 -0
  180. package/inkos/packages/core/src/__tests__/chapter-analyzer.test.ts +574 -0
  181. package/inkos/packages/core/src/__tests__/chapter-memo-parser.test.ts +247 -0
  182. package/inkos/packages/core/src/__tests__/chapter-persistence.test.ts +198 -0
  183. package/inkos/packages/core/src/__tests__/chapter-review-cycle.test.ts +294 -0
  184. package/inkos/packages/core/src/__tests__/chapter-splitter.test.ts +156 -0
  185. package/inkos/packages/core/src/__tests__/chapter-state-recovery.test.ts +235 -0
  186. package/inkos/packages/core/src/__tests__/chapter-truth-validation.test.ts +253 -0
  187. package/inkos/packages/core/src/__tests__/composer.test.ts +627 -0
  188. package/inkos/packages/core/src/__tests__/config-loader.test.ts +325 -0
  189. package/inkos/packages/core/src/__tests__/config-migration.test.ts +102 -0
  190. package/inkos/packages/core/src/__tests__/consolidator.test.ts +32 -0
  191. package/inkos/packages/core/src/__tests__/context-filter.test.ts +60 -0
  192. package/inkos/packages/core/src/__tests__/context-transform.test.ts +108 -0
  193. package/inkos/packages/core/src/__tests__/continuity.test.ts +391 -0
  194. package/inkos/packages/core/src/__tests__/detection-insights.test.ts +59 -0
  195. package/inkos/packages/core/src/__tests__/detector.test.ts +86 -0
  196. package/inkos/packages/core/src/__tests__/draft-directive-parser.test.ts +386 -0
  197. package/inkos/packages/core/src/__tests__/edit-controller.test.ts +190 -0
  198. package/inkos/packages/core/src/__tests__/effective-llm-config.test.ts +486 -0
  199. package/inkos/packages/core/src/__tests__/fanfic-dimensions.test.ts +58 -0
  200. package/inkos/packages/core/src/__tests__/fanfic-models.test.ts +69 -0
  201. package/inkos/packages/core/src/__tests__/governed-working-set.test.ts +155 -0
  202. package/inkos/packages/core/src/__tests__/hook-arbiter.test.ts +124 -0
  203. package/inkos/packages/core/src/__tests__/hook-governance.test.ts +228 -0
  204. package/inkos/packages/core/src/__tests__/hook-health.test.ts +166 -0
  205. package/inkos/packages/core/src/__tests__/hook-ledger-validator.test.ts +236 -0
  206. package/inkos/packages/core/src/__tests__/hook-promotion.test.ts +192 -0
  207. package/inkos/packages/core/src/__tests__/hook-stale-detection.test.ts +136 -0
  208. package/inkos/packages/core/src/__tests__/index-notify-lazy.test.ts +20 -0
  209. package/inkos/packages/core/src/__tests__/interaction-chat-tokens.test.ts +170 -0
  210. package/inkos/packages/core/src/__tests__/interaction-models.test.ts +155 -0
  211. package/inkos/packages/core/src/__tests__/interaction-nl-router.test.ts +223 -0
  212. package/inkos/packages/core/src/__tests__/interaction-runtime.test.ts +633 -0
  213. package/inkos/packages/core/src/__tests__/interaction-tools.test.ts +343 -0
  214. package/inkos/packages/core/src/__tests__/length-metrics.test.ts +82 -0
  215. package/inkos/packages/core/src/__tests__/length-normalizer.test.ts +331 -0
  216. package/inkos/packages/core/src/__tests__/list-models.test.ts +109 -0
  217. package/inkos/packages/core/src/__tests__/llm-env.test.ts +31 -0
  218. package/inkos/packages/core/src/__tests__/logger.test.ts +175 -0
  219. package/inkos/packages/core/src/__tests__/long-span-fatigue.test.ts +160 -0
  220. package/inkos/packages/core/src/__tests__/memory-retrieval.test.ts +1303 -0
  221. package/inkos/packages/core/src/__tests__/models.test.ts +918 -0
  222. package/inkos/packages/core/src/__tests__/outline-paths.test.ts +97 -0
  223. package/inkos/packages/core/src/__tests__/path-safety.test.ts +22 -0
  224. package/inkos/packages/core/src/__tests__/persisted-governed-plan.test.ts +134 -0
  225. package/inkos/packages/core/src/__tests__/phase5-cleanup.test.ts +393 -0
  226. package/inkos/packages/core/src/__tests__/phase5-hotfix.test.ts +288 -0
  227. package/inkos/packages/core/src/__tests__/phase7-hotfix.test.ts +614 -0
  228. package/inkos/packages/core/src/__tests__/pipeline-agent.test.ts +354 -0
  229. package/inkos/packages/core/src/__tests__/pipeline-runner-memory-sync.test.ts +317 -0
  230. package/inkos/packages/core/src/__tests__/pipeline-runner.test.ts +5200 -0
  231. package/inkos/packages/core/src/__tests__/planner-context.test.ts +137 -0
  232. package/inkos/packages/core/src/__tests__/planner-prompts-ratio.test.ts +11 -0
  233. package/inkos/packages/core/src/__tests__/planner-prompts.test.ts +171 -0
  234. package/inkos/packages/core/src/__tests__/planner.test.ts +362 -0
  235. package/inkos/packages/core/src/__tests__/planning-materials.test.ts +90 -0
  236. package/inkos/packages/core/src/__tests__/polisher.test.ts +189 -0
  237. package/inkos/packages/core/src/__tests__/post-write-validator.test.ts +291 -0
  238. package/inkos/packages/core/src/__tests__/probe.test.ts +77 -0
  239. package/inkos/packages/core/src/__tests__/project-interaction.test.ts +241 -0
  240. package/inkos/packages/core/src/__tests__/provider.test.ts +953 -0
  241. package/inkos/packages/core/src/__tests__/providers-group.test.ts +34 -0
  242. package/inkos/packages/core/src/__tests__/providers-lookup.test.ts +81 -0
  243. package/inkos/packages/core/src/__tests__/providers-schema.test.ts +158 -0
  244. package/inkos/packages/core/src/__tests__/proxy-fetch.test.ts +75 -0
  245. package/inkos/packages/core/src/__tests__/revise-foundation.test.ts +514 -0
  246. package/inkos/packages/core/src/__tests__/reviser.test.ts +859 -0
  247. package/inkos/packages/core/src/__tests__/runtime-state-store.test.ts +388 -0
  248. package/inkos/packages/core/src/__tests__/scheduler.test.ts +123 -0
  249. package/inkos/packages/core/src/__tests__/secrets-migration.test.ts +71 -0
  250. package/inkos/packages/core/src/__tests__/secrets.test.ts +95 -0
  251. package/inkos/packages/core/src/__tests__/sensitive-words.test.ts +88 -0
  252. package/inkos/packages/core/src/__tests__/service-presets-regression.test.ts +73 -0
  253. package/inkos/packages/core/src/__tests__/service-resolver-regression.test.ts +75 -0
  254. package/inkos/packages/core/src/__tests__/service-resolver.test.ts +228 -0
  255. package/inkos/packages/core/src/__tests__/session-transcript-restore.test.ts +1311 -0
  256. package/inkos/packages/core/src/__tests__/session-transcript.test.ts +195 -0
  257. package/inkos/packages/core/src/__tests__/settler-delta-parser.test.ts +133 -0
  258. package/inkos/packages/core/src/__tests__/short-fiction-public.test.ts +241 -0
  259. package/inkos/packages/core/src/__tests__/spot-fix-patches.test.ts +104 -0
  260. package/inkos/packages/core/src/__tests__/state-manager.test.ts +1298 -0
  261. package/inkos/packages/core/src/__tests__/state-projections.test.ts +130 -0
  262. package/inkos/packages/core/src/__tests__/state-reducer.test.ts +372 -0
  263. package/inkos/packages/core/src/__tests__/state-validator-agent.test.ts +165 -0
  264. package/inkos/packages/core/src/__tests__/state-validator.test.ts +122 -0
  265. package/inkos/packages/core/src/__tests__/style-analyzer.test.ts +61 -0
  266. package/inkos/packages/core/src/__tests__/temperature-constraints.test.ts +57 -0
  267. package/inkos/packages/core/src/__tests__/v13-hotfix-round4.test.ts +343 -0
  268. package/inkos/packages/core/src/__tests__/verify-service.test.ts +77 -0
  269. package/inkos/packages/core/src/__tests__/webhook.test.ts +91 -0
  270. package/inkos/packages/core/src/__tests__/writer-parser.test.ts +348 -0
  271. package/inkos/packages/core/src/__tests__/writer-prompts.test.ts +269 -0
  272. package/inkos/packages/core/src/__tests__/writer.test.ts +1360 -0
  273. package/inkos/packages/core/src/agent/agent-session.ts +737 -0
  274. package/inkos/packages/core/src/agent/agent-system-prompt.ts +199 -0
  275. package/inkos/packages/core/src/agent/agent-tools.ts +835 -0
  276. package/inkos/packages/core/src/agent/context-transform.ts +85 -0
  277. package/inkos/packages/core/src/agent/index.ts +14 -0
  278. package/inkos/packages/core/src/agents/ai-tells.ts +161 -0
  279. package/inkos/packages/core/src/agents/architect.ts +1291 -0
  280. package/inkos/packages/core/src/agents/base.ts +100 -0
  281. package/inkos/packages/core/src/agents/chapter-analyzer.ts +634 -0
  282. package/inkos/packages/core/src/agents/composer.ts +469 -0
  283. package/inkos/packages/core/src/agents/consolidator.ts +218 -0
  284. package/inkos/packages/core/src/agents/continuity.ts +824 -0
  285. package/inkos/packages/core/src/agents/detection-insights.ts +72 -0
  286. package/inkos/packages/core/src/agents/detector.ts +224 -0
  287. package/inkos/packages/core/src/agents/en-prompt-sections.ts +129 -0
  288. package/inkos/packages/core/src/agents/fanfic-canon-importer.ts +146 -0
  289. package/inkos/packages/core/src/agents/fanfic-dimensions.ts +87 -0
  290. package/inkos/packages/core/src/agents/fanfic-prompt-sections.ts +109 -0
  291. package/inkos/packages/core/src/agents/foundation-reviewer.ts +204 -0
  292. package/inkos/packages/core/src/agents/length-normalizer.ts +218 -0
  293. package/inkos/packages/core/src/agents/observer-prompts.ts +127 -0
  294. package/inkos/packages/core/src/agents/planner-context.ts +297 -0
  295. package/inkos/packages/core/src/agents/planner-prompts.ts +404 -0
  296. package/inkos/packages/core/src/agents/planner.ts +783 -0
  297. package/inkos/packages/core/src/agents/polisher.ts +153 -0
  298. package/inkos/packages/core/src/agents/post-write-validator.ts +873 -0
  299. package/inkos/packages/core/src/agents/radar-source.ts +123 -0
  300. package/inkos/packages/core/src/agents/radar.ts +120 -0
  301. package/inkos/packages/core/src/agents/reviser.ts +701 -0
  302. package/inkos/packages/core/src/agents/rules-reader.ts +155 -0
  303. package/inkos/packages/core/src/agents/sensitive-words.ts +142 -0
  304. package/inkos/packages/core/src/agents/settler-delta-parser.ts +53 -0
  305. package/inkos/packages/core/src/agents/settler-parser.ts +38 -0
  306. package/inkos/packages/core/src/agents/settler-prompts.ts +230 -0
  307. package/inkos/packages/core/src/agents/short-fiction.ts +429 -0
  308. package/inkos/packages/core/src/agents/state-validator.ts +322 -0
  309. package/inkos/packages/core/src/agents/style-analyzer.ts +93 -0
  310. package/inkos/packages/core/src/agents/writer-parser.ts +178 -0
  311. package/inkos/packages/core/src/agents/writer-prompts.ts +899 -0
  312. package/inkos/packages/core/src/agents/writer.ts +1450 -0
  313. package/inkos/packages/core/src/index.ts +392 -0
  314. package/inkos/packages/core/src/interaction/book-session-store.ts +226 -0
  315. package/inkos/packages/core/src/interaction/draft-directive-parser.ts +266 -0
  316. package/inkos/packages/core/src/interaction/edit-controller.ts +270 -0
  317. package/inkos/packages/core/src/interaction/events.ts +41 -0
  318. package/inkos/packages/core/src/interaction/export-artifact.ts +151 -0
  319. package/inkos/packages/core/src/interaction/intents.ts +63 -0
  320. package/inkos/packages/core/src/interaction/modes.ts +13 -0
  321. package/inkos/packages/core/src/interaction/nl-router.ts +258 -0
  322. package/inkos/packages/core/src/interaction/project-control.ts +150 -0
  323. package/inkos/packages/core/src/interaction/project-session-store.ts +81 -0
  324. package/inkos/packages/core/src/interaction/project-tools.ts +704 -0
  325. package/inkos/packages/core/src/interaction/request-router.ts +5 -0
  326. package/inkos/packages/core/src/interaction/runtime.ts +1167 -0
  327. package/inkos/packages/core/src/interaction/session-transcript-legacy.ts +113 -0
  328. package/inkos/packages/core/src/interaction/session-transcript-restore.ts +607 -0
  329. package/inkos/packages/core/src/interaction/session-transcript-schema.ts +76 -0
  330. package/inkos/packages/core/src/interaction/session-transcript.ts +189 -0
  331. package/inkos/packages/core/src/interaction/session.ts +226 -0
  332. package/inkos/packages/core/src/interaction/truth-authority.ts +45 -0
  333. package/inkos/packages/core/src/llm/config-migration.ts +58 -0
  334. package/inkos/packages/core/src/llm/cover-providers.ts +45 -0
  335. package/inkos/packages/core/src/llm/provider.ts +1331 -0
  336. package/inkos/packages/core/src/llm/providers/endpoints/ai360.ts +42 -0
  337. package/inkos/packages/core/src/llm/providers/endpoints/anthropic.ts +82 -0
  338. package/inkos/packages/core/src/llm/providers/endpoints/astronCodingPlan.ts +30 -0
  339. package/inkos/packages/core/src/llm/providers/endpoints/baichuan.ts +28 -0
  340. package/inkos/packages/core/src/llm/providers/endpoints/bailian.ts +65 -0
  341. package/inkos/packages/core/src/llm/providers/endpoints/bailianCodingPlan.ts +30 -0
  342. package/inkos/packages/core/src/llm/providers/endpoints/custom.ts +22 -0
  343. package/inkos/packages/core/src/llm/providers/endpoints/deepseek.ts +35 -0
  344. package/inkos/packages/core/src/llm/providers/endpoints/giteeai.ts +41 -0
  345. package/inkos/packages/core/src/llm/providers/endpoints/githubCopilot.ts +43 -0
  346. package/inkos/packages/core/src/llm/providers/endpoints/glmCodingPlan.ts +28 -0
  347. package/inkos/packages/core/src/llm/providers/endpoints/google.ts +51 -0
  348. package/inkos/packages/core/src/llm/providers/endpoints/hunyuan.ts +42 -0
  349. package/inkos/packages/core/src/llm/providers/endpoints/infiniai.ts +72 -0
  350. package/inkos/packages/core/src/llm/providers/endpoints/internlm.ts +28 -0
  351. package/inkos/packages/core/src/llm/providers/endpoints/kimiCode.ts +23 -0
  352. package/inkos/packages/core/src/llm/providers/endpoints/kimiCodingPlan.ts +24 -0
  353. package/inkos/packages/core/src/llm/providers/endpoints/kkaiapi.ts +56 -0
  354. package/inkos/packages/core/src/llm/providers/endpoints/longcat.ts +25 -0
  355. package/inkos/packages/core/src/llm/providers/endpoints/minimax.ts +39 -0
  356. package/inkos/packages/core/src/llm/providers/endpoints/minimaxCodingPlan.ts +28 -0
  357. package/inkos/packages/core/src/llm/providers/endpoints/mistral.ts +40 -0
  358. package/inkos/packages/core/src/llm/providers/endpoints/modelscope.ts +30 -0
  359. package/inkos/packages/core/src/llm/providers/endpoints/moonshot.ts +39 -0
  360. package/inkos/packages/core/src/llm/providers/endpoints/newapi.ts +21 -0
  361. package/inkos/packages/core/src/llm/providers/endpoints/ollama.ts +73 -0
  362. package/inkos/packages/core/src/llm/providers/endpoints/openai.ts +77 -0
  363. package/inkos/packages/core/src/llm/providers/endpoints/opencodeCodingPlan.ts +30 -0
  364. package/inkos/packages/core/src/llm/providers/endpoints/openrouter.ts +87 -0
  365. package/inkos/packages/core/src/llm/providers/endpoints/ppio.ts +86 -0
  366. package/inkos/packages/core/src/llm/providers/endpoints/qiniu.ts +32 -0
  367. package/inkos/packages/core/src/llm/providers/endpoints/sensenova.ts +45 -0
  368. package/inkos/packages/core/src/llm/providers/endpoints/siliconcloud.ts +126 -0
  369. package/inkos/packages/core/src/llm/providers/endpoints/spark.ts +33 -0
  370. package/inkos/packages/core/src/llm/providers/endpoints/stepfun.ts +35 -0
  371. package/inkos/packages/core/src/llm/providers/endpoints/tencentcloud.ts +25 -0
  372. package/inkos/packages/core/src/llm/providers/endpoints/volcengine.ts +52 -0
  373. package/inkos/packages/core/src/llm/providers/endpoints/volcengineCodingPlan.ts +42 -0
  374. package/inkos/packages/core/src/llm/providers/endpoints/wenxin.ts +106 -0
  375. package/inkos/packages/core/src/llm/providers/endpoints/xai.ts +34 -0
  376. package/inkos/packages/core/src/llm/providers/endpoints/xiaomimimo.ts +26 -0
  377. package/inkos/packages/core/src/llm/providers/endpoints/zeroone.ts +34 -0
  378. package/inkos/packages/core/src/llm/providers/endpoints/zhipu.ts +61 -0
  379. package/inkos/packages/core/src/llm/providers/index.ts +71 -0
  380. package/inkos/packages/core/src/llm/providers/lookup.ts +70 -0
  381. package/inkos/packages/core/src/llm/providers/probe.ts +35 -0
  382. package/inkos/packages/core/src/llm/providers/types.ts +89 -0
  383. package/inkos/packages/core/src/llm/providers/verify.ts +104 -0
  384. package/inkos/packages/core/src/llm/secrets.ts +77 -0
  385. package/inkos/packages/core/src/llm/service-presets.ts +215 -0
  386. package/inkos/packages/core/src/llm/service-resolver.ts +91 -0
  387. package/inkos/packages/core/src/models/book-rules.ts +126 -0
  388. package/inkos/packages/core/src/models/book.ts +70 -0
  389. package/inkos/packages/core/src/models/chapter.ts +42 -0
  390. package/inkos/packages/core/src/models/detection.ts +25 -0
  391. package/inkos/packages/core/src/models/genre-profile.ts +36 -0
  392. package/inkos/packages/core/src/models/input-governance.ts +99 -0
  393. package/inkos/packages/core/src/models/length-governance.ts +46 -0
  394. package/inkos/packages/core/src/models/project.ts +161 -0
  395. package/inkos/packages/core/src/models/runtime-state.ts +144 -0
  396. package/inkos/packages/core/src/models/state.ts +52 -0
  397. package/inkos/packages/core/src/models/style-profile.ts +15 -0
  398. package/inkos/packages/core/src/notify/dispatcher.ts +96 -0
  399. package/inkos/packages/core/src/notify/feishu.ts +34 -0
  400. package/inkos/packages/core/src/notify/telegram.ts +25 -0
  401. package/inkos/packages/core/src/notify/webhook.ts +58 -0
  402. package/inkos/packages/core/src/notify/wechat-work.ts +22 -0
  403. package/inkos/packages/core/src/pipeline/agent.ts +691 -0
  404. package/inkos/packages/core/src/pipeline/chapter-persistence.ts +79 -0
  405. package/inkos/packages/core/src/pipeline/chapter-review-cycle.ts +324 -0
  406. package/inkos/packages/core/src/pipeline/chapter-state-recovery.ts +236 -0
  407. package/inkos/packages/core/src/pipeline/chapter-truth-validation.ts +145 -0
  408. package/inkos/packages/core/src/pipeline/detection-runner.ts +164 -0
  409. package/inkos/packages/core/src/pipeline/persisted-governed-plan.ts +216 -0
  410. package/inkos/packages/core/src/pipeline/runner.ts +3438 -0
  411. package/inkos/packages/core/src/pipeline/scheduler.ts +411 -0
  412. package/inkos/packages/core/src/pipeline/short-fiction-runner.ts +801 -0
  413. package/inkos/packages/core/src/prompts/index.ts +1 -0
  414. package/inkos/packages/core/src/prompts/short-fiction.ts +273 -0
  415. package/inkos/packages/core/src/state/manager.ts +560 -0
  416. package/inkos/packages/core/src/state/memory-db.ts +359 -0
  417. package/inkos/packages/core/src/state/runtime-state-store.ts +164 -0
  418. package/inkos/packages/core/src/state/state-bootstrap.ts +657 -0
  419. package/inkos/packages/core/src/state/state-projections.ts +255 -0
  420. package/inkos/packages/core/src/state/state-reducer.ts +260 -0
  421. package/inkos/packages/core/src/state/state-validator.ts +117 -0
  422. package/inkos/packages/core/src/utils/analytics.ts +92 -0
  423. package/inkos/packages/core/src/utils/book-id.ts +31 -0
  424. package/inkos/packages/core/src/utils/cadence-policy.ts +46 -0
  425. package/inkos/packages/core/src/utils/chapter-cadence.ts +211 -0
  426. package/inkos/packages/core/src/utils/chapter-memo-parser.ts +157 -0
  427. package/inkos/packages/core/src/utils/chapter-splitter.ts +80 -0
  428. package/inkos/packages/core/src/utils/config-loader.ts +29 -0
  429. package/inkos/packages/core/src/utils/context-assembly.ts +98 -0
  430. package/inkos/packages/core/src/utils/context-filter.ts +190 -0
  431. package/inkos/packages/core/src/utils/effective-llm-config.ts +529 -0
  432. package/inkos/packages/core/src/utils/governed-context.ts +101 -0
  433. package/inkos/packages/core/src/utils/governed-working-set.ts +395 -0
  434. package/inkos/packages/core/src/utils/hook-arbiter.ts +332 -0
  435. package/inkos/packages/core/src/utils/hook-governance.ts +199 -0
  436. package/inkos/packages/core/src/utils/hook-health.ts +189 -0
  437. package/inkos/packages/core/src/utils/hook-ledger-validator.ts +277 -0
  438. package/inkos/packages/core/src/utils/hook-lifecycle.ts +224 -0
  439. package/inkos/packages/core/src/utils/hook-policy.ts +115 -0
  440. package/inkos/packages/core/src/utils/hook-promotion.ts +313 -0
  441. package/inkos/packages/core/src/utils/hook-stale-detection.ts +168 -0
  442. package/inkos/packages/core/src/utils/length-metrics.ts +123 -0
  443. package/inkos/packages/core/src/utils/llm-endpoint-auth.ts +40 -0
  444. package/inkos/packages/core/src/utils/llm-env.ts +74 -0
  445. package/inkos/packages/core/src/utils/logger.ts +123 -0
  446. package/inkos/packages/core/src/utils/long-span-fatigue.ts +545 -0
  447. package/inkos/packages/core/src/utils/memory-retrieval.ts +527 -0
  448. package/inkos/packages/core/src/utils/narrative-control.ts +177 -0
  449. package/inkos/packages/core/src/utils/outline-paths.ts +275 -0
  450. package/inkos/packages/core/src/utils/path-safety.ts +11 -0
  451. package/inkos/packages/core/src/utils/planning-materials.ts +185 -0
  452. package/inkos/packages/core/src/utils/pov-filter.ts +149 -0
  453. package/inkos/packages/core/src/utils/proxy-fetch.ts +44 -0
  454. package/inkos/packages/core/src/utils/runtime-writer.ts +41 -0
  455. package/inkos/packages/core/src/utils/spot-fix-patches.ts +189 -0
  456. package/inkos/packages/core/src/utils/story-markdown.ts +346 -0
  457. package/inkos/packages/core/src/utils/web-search.ts +82 -0
  458. package/inkos/packages/core/src/utils/writing-methodology.ts +164 -0
  459. package/inkos/packages/core/tsconfig.json +8 -0
  460. package/inkos/packages/core/vitest.config.ts +7 -0
  461. package/inkos/packages/studio/components.json +25 -0
  462. package/inkos/packages/studio/index.html +13 -0
  463. package/inkos/packages/studio/package.json +72 -0
  464. package/inkos/packages/studio/postcss.config.js +3 -0
  465. package/inkos/packages/studio/src/App.test.ts +25 -0
  466. package/inkos/packages/studio/src/App.tsx +280 -0
  467. package/inkos/packages/studio/src/api/__tests__/normalize-base-url.test.ts +40 -0
  468. package/inkos/packages/studio/src/api/book-create.test.ts +104 -0
  469. package/inkos/packages/studio/src/api/book-create.ts +94 -0
  470. package/inkos/packages/studio/src/api/errors.ts +17 -0
  471. package/inkos/packages/studio/src/api/index.ts +30 -0
  472. package/inkos/packages/studio/src/api/lib/run-store.ts +177 -0
  473. package/inkos/packages/studio/src/api/lib/sse.ts +50 -0
  474. package/inkos/packages/studio/src/api/phase5-hotfix.test.ts +335 -0
  475. package/inkos/packages/studio/src/api/safety.ts +6 -0
  476. package/inkos/packages/studio/src/api/server.test.ts +3162 -0
  477. package/inkos/packages/studio/src/api/server.ts +3666 -0
  478. package/inkos/packages/studio/src/api/v13-hotfix-round4.test.ts +226 -0
  479. package/inkos/packages/studio/src/app-state.test.ts +8 -0
  480. package/inkos/packages/studio/src/app-state.ts +1 -0
  481. package/inkos/packages/studio/src/components/ConfirmDialog.tsx +95 -0
  482. package/inkos/packages/studio/src/components/ServiceConfigSourceCard.tsx +139 -0
  483. package/inkos/packages/studio/src/components/ServiceQuickLinks.tsx +65 -0
  484. package/inkos/packages/studio/src/components/Sidebar.tsx +652 -0
  485. package/inkos/packages/studio/src/components/ai-elements/code-block.tsx +562 -0
  486. package/inkos/packages/studio/src/components/ai-elements/confirmation.tsx +174 -0
  487. package/inkos/packages/studio/src/components/ai-elements/message.tsx +360 -0
  488. package/inkos/packages/studio/src/components/ai-elements/prompt-input.tsx +1457 -0
  489. package/inkos/packages/studio/src/components/ai-elements/reasoning.tsx +226 -0
  490. package/inkos/packages/studio/src/components/ai-elements/shimmer.tsx +77 -0
  491. package/inkos/packages/studio/src/components/ai-elements/tool.tsx +173 -0
  492. package/inkos/packages/studio/src/components/chat/BookSidebar.tsx +291 -0
  493. package/inkos/packages/studio/src/components/chat/ChatMessage.tsx +39 -0
  494. package/inkos/packages/studio/src/components/chat/QuickActions.tsx +73 -0
  495. package/inkos/packages/studio/src/components/chat/ToolExecutionSteps.tsx +320 -0
  496. package/inkos/packages/studio/src/components/chat/__tests__/ToolExecutionSteps.test.ts +114 -0
  497. package/inkos/packages/studio/src/components/chat-utils.ts +56 -0
  498. package/inkos/packages/studio/src/components/chatbar-state.test.ts +69 -0
  499. package/inkos/packages/studio/src/components/sidebar/ChaptersSection.tsx +66 -0
  500. package/inkos/packages/studio/src/components/sidebar/CharacterSection.tsx +129 -0
  501. package/inkos/packages/studio/src/components/sidebar/FoundationSection.tsx +61 -0
  502. package/inkos/packages/studio/src/components/sidebar/ProgressSection.tsx +124 -0
  503. package/inkos/packages/studio/src/components/sidebar/SidebarCard.tsx +30 -0
  504. package/inkos/packages/studio/src/components/sidebar/SummarySection.tsx +89 -0
  505. package/inkos/packages/studio/src/components/ui/alert.tsx +76 -0
  506. package/inkos/packages/studio/src/components/ui/badge.tsx +52 -0
  507. package/inkos/packages/studio/src/components/ui/button-group.tsx +87 -0
  508. package/inkos/packages/studio/src/components/ui/button.tsx +58 -0
  509. package/inkos/packages/studio/src/components/ui/collapsible.tsx +19 -0
  510. package/inkos/packages/studio/src/components/ui/command.tsx +194 -0
  511. package/inkos/packages/studio/src/components/ui/dialog.tsx +158 -0
  512. package/inkos/packages/studio/src/components/ui/dropdown-menu.tsx +266 -0
  513. package/inkos/packages/studio/src/components/ui/hover-card.tsx +51 -0
  514. package/inkos/packages/studio/src/components/ui/input-group.tsx +158 -0
  515. package/inkos/packages/studio/src/components/ui/input.tsx +20 -0
  516. package/inkos/packages/studio/src/components/ui/select.tsx +199 -0
  517. package/inkos/packages/studio/src/components/ui/separator.tsx +23 -0
  518. package/inkos/packages/studio/src/components/ui/spinner.tsx +10 -0
  519. package/inkos/packages/studio/src/components/ui/textarea.tsx +18 -0
  520. package/inkos/packages/studio/src/components/ui/tooltip.tsx +66 -0
  521. package/inkos/packages/studio/src/constants/service-groups.ts +29 -0
  522. package/inkos/packages/studio/src/hooks/use-api.test.ts +93 -0
  523. package/inkos/packages/studio/src/hooks/use-api.ts +189 -0
  524. package/inkos/packages/studio/src/hooks/use-book-activity.test.ts +129 -0
  525. package/inkos/packages/studio/src/hooks/use-book-activity.ts +180 -0
  526. package/inkos/packages/studio/src/hooks/use-colors.ts +27 -0
  527. package/inkos/packages/studio/src/hooks/use-hash-route.test.ts +101 -0
  528. package/inkos/packages/studio/src/hooks/use-hash-route.ts +89 -0
  529. package/inkos/packages/studio/src/hooks/use-i18n.ts +289 -0
  530. package/inkos/packages/studio/src/hooks/use-session-events.ts +64 -0
  531. package/inkos/packages/studio/src/hooks/use-sse.test.ts +52 -0
  532. package/inkos/packages/studio/src/hooks/use-sse.ts +92 -0
  533. package/inkos/packages/studio/src/hooks/use-theme.test.ts +31 -0
  534. package/inkos/packages/studio/src/hooks/use-theme.ts +75 -0
  535. package/inkos/packages/studio/src/index.css +323 -0
  536. package/inkos/packages/studio/src/lib/error-copy.test.ts +34 -0
  537. package/inkos/packages/studio/src/lib/error-copy.ts +37 -0
  538. package/inkos/packages/studio/src/lib/utils.ts +6 -0
  539. package/inkos/packages/studio/src/main.tsx +10 -0
  540. package/inkos/packages/studio/src/pages/Analytics.tsx +80 -0
  541. package/inkos/packages/studio/src/pages/BookCreate.tsx +895 -0
  542. package/inkos/packages/studio/src/pages/BookDetail.tsx +652 -0
  543. package/inkos/packages/studio/src/pages/ChapterReader.tsx +266 -0
  544. package/inkos/packages/studio/src/pages/ChatPage.tsx +521 -0
  545. package/inkos/packages/studio/src/pages/DaemonControl.tsx +116 -0
  546. package/inkos/packages/studio/src/pages/Dashboard.tsx +379 -0
  547. package/inkos/packages/studio/src/pages/DoctorView.tsx +82 -0
  548. package/inkos/packages/studio/src/pages/GenreManager.tsx +464 -0
  549. package/inkos/packages/studio/src/pages/ImportManager.tsx +216 -0
  550. package/inkos/packages/studio/src/pages/LanguageSelector.tsx +74 -0
  551. package/inkos/packages/studio/src/pages/LogViewer.tsx +82 -0
  552. package/inkos/packages/studio/src/pages/RadarView.tsx +157 -0
  553. package/inkos/packages/studio/src/pages/ServiceDetailPage.tsx +393 -0
  554. package/inkos/packages/studio/src/pages/ServiceListPage.tsx +463 -0
  555. package/inkos/packages/studio/src/pages/StyleManager.tsx +225 -0
  556. package/inkos/packages/studio/src/pages/TruthFiles.tsx +194 -0
  557. package/inkos/packages/studio/src/pages/chat-page-state.test.ts +206 -0
  558. package/inkos/packages/studio/src/pages/chat-page-state.ts +112 -0
  559. package/inkos/packages/studio/src/pages/page-state.test.ts +258 -0
  560. package/inkos/packages/studio/src/pages/service-detail-state.test.ts +294 -0
  561. package/inkos/packages/studio/src/pages/service-detail-state.ts +234 -0
  562. package/inkos/packages/studio/src/pages/style-manager-state.test.ts +22 -0
  563. package/inkos/packages/studio/src/pages/truth-files-state.test.ts +61 -0
  564. package/inkos/packages/studio/src/shared/contracts.ts +143 -0
  565. package/inkos/packages/studio/src/store/chat/__tests__/message-parts.test.ts +172 -0
  566. package/inkos/packages/studio/src/store/chat/index.ts +3 -0
  567. package/inkos/packages/studio/src/store/chat/initialState.ts +8 -0
  568. package/inkos/packages/studio/src/store/chat/message-policy.test.ts +16 -0
  569. package/inkos/packages/studio/src/store/chat/message-policy.ts +5 -0
  570. package/inkos/packages/studio/src/store/chat/parts-builder.ts +187 -0
  571. package/inkos/packages/studio/src/store/chat/selectors.ts +13 -0
  572. package/inkos/packages/studio/src/store/chat/slices/create/action.ts +10 -0
  573. package/inkos/packages/studio/src/store/chat/slices/create/initialState.ts +9 -0
  574. package/inkos/packages/studio/src/store/chat/slices/message/action.ts +417 -0
  575. package/inkos/packages/studio/src/store/chat/slices/message/initialState.ts +10 -0
  576. package/inkos/packages/studio/src/store/chat/slices/message/runtime.test.ts +21 -0
  577. package/inkos/packages/studio/src/store/chat/slices/message/runtime.ts +233 -0
  578. package/inkos/packages/studio/src/store/chat/slices/message/stream-events.ts +272 -0
  579. package/inkos/packages/studio/src/store/chat/store.ts +11 -0
  580. package/inkos/packages/studio/src/store/chat/types.ts +169 -0
  581. package/inkos/packages/studio/src/store/service/index.ts +2 -0
  582. package/inkos/packages/studio/src/store/service/store.ts +123 -0
  583. package/inkos/packages/studio/src/store/service/types.ts +50 -0
  584. package/inkos/packages/studio/tsconfig.json +24 -0
  585. package/inkos/packages/studio/tsconfig.server.json +11 -0
  586. package/inkos/packages/studio/vite.config.ts +34 -0
  587. package/inkos/packages/studio/vitest.config.ts +14 -0
  588. package/inkos/pnpm-lock.yaml +9569 -0
  589. package/inkos/pnpm-workspace.yaml +2 -0
  590. package/inkos/scripts/prepare-package-for-publish.mjs +135 -0
  591. package/inkos/scripts/restore-package-json.mjs +31 -0
  592. package/inkos/scripts/set-package-versions.mjs +74 -0
  593. package/inkos/scripts/verify-no-workspace-protocol.mjs +140 -0
  594. package/inkos/skills/SKILL.md +654 -0
  595. package/inkos/tsconfig.json +19 -0
  596. package/package.json +4 -3
  597. /package/.next/static/{F2hMZMf1IyCVAWpkbtRz7 → -3vIrBZXdQ0rp7Wa3Kz40}/_buildManifest.js +0 -0
  598. /package/.next/static/{F2hMZMf1IyCVAWpkbtRz7 → -3vIrBZXdQ0rp7Wa3Kz40}/_ssgManifest.js +0 -0
@@ -0,0 +1,899 @@
1
+ import type { BookConfig, FanficMode } from "../models/book.js";
2
+ import type { GenreProfile } from "../models/genre-profile.js";
3
+ import type { BookRules } from "../models/book-rules.js";
4
+ import type { LengthSpec } from "../models/length-governance.js";
5
+ import { buildFanficCanonSection, buildCharacterVoiceProfiles, buildFanficModeInstructions } from "./fanfic-prompt-sections.js";
6
+ import { buildEnglishCoreRules, buildEnglishAntiAIRules, buildEnglishCharacterMethod, buildEnglishPreWriteChecklist, buildEnglishGenreIntro } from "./en-prompt-sections.js";
7
+ import { buildLengthSpec } from "../utils/length-metrics.js";
8
+
9
+ export interface FanficContext {
10
+ readonly fanficCanon: string;
11
+ readonly fanficMode: FanficMode;
12
+ readonly allowedDeviations: ReadonlyArray<string>;
13
+ }
14
+
15
+ // ---------------------------------------------------------------------------
16
+ // Public API
17
+ // ---------------------------------------------------------------------------
18
+
19
+ export function buildWriterSystemPrompt(
20
+ book: BookConfig,
21
+ genreProfile: GenreProfile,
22
+ bookRules: BookRules | null,
23
+ bookRulesBody: string,
24
+ genreBody: string,
25
+ styleGuide: string,
26
+ styleFingerprint?: string,
27
+ chapterNumber?: number,
28
+ mode: "full" | "creative" = "full",
29
+ fanficContext?: FanficContext,
30
+ languageOverride?: "zh" | "en",
31
+ inputProfile: "legacy" | "governed" = "legacy",
32
+ lengthSpec?: LengthSpec,
33
+ ): string {
34
+ const isEnglish = (languageOverride ?? genreProfile.language) === "en";
35
+ const governed = inputProfile === "governed";
36
+ const resolvedLengthSpec = lengthSpec ?? buildLengthSpec(book.chapterWordCount, isEnglish ? "en" : "zh");
37
+
38
+ const outputSection = mode === "creative"
39
+ ? buildCreativeOutputFormat(book, genreProfile, resolvedLengthSpec)
40
+ : buildOutputFormat(book, genreProfile, resolvedLengthSpec);
41
+
42
+ const sections = isEnglish
43
+ ? [
44
+ buildEnglishGenreIntro(book, genreProfile),
45
+ buildEnglishCoreRules(book),
46
+ buildGovernedInputContract("en", governed),
47
+ buildChapterMemoContract("en", governed),
48
+ buildLengthGuidance(resolvedLengthSpec, "en"),
49
+ buildWritingCraftCard("en"),
50
+ buildCreativeConstitution("en"),
51
+ buildImmersionPillars("en"),
52
+ buildGoldenOpeningDiscipline(chapterNumber, "en"),
53
+ buildGenreRules(genreProfile, genreBody),
54
+ buildProtagonistRules(bookRules),
55
+ buildBookRulesBody(bookRulesBody),
56
+ buildStyleGuide(styleGuide),
57
+ buildStyleFingerprint(styleFingerprint),
58
+ fanficContext ? buildFanficCanonSection(fanficContext.fanficCanon, fanficContext.fanficMode) : "",
59
+ fanficContext ? buildCharacterVoiceProfiles(fanficContext.fanficCanon) : "",
60
+ fanficContext ? buildFanficModeInstructions(fanficContext.fanficMode, fanficContext.allowedDeviations) : "",
61
+ // Pre-write checklist moved to style_guide.md (v10)
62
+ outputSection,
63
+ ]
64
+ : [
65
+ buildGenreIntro(book, genreProfile),
66
+ buildCoreRules(resolvedLengthSpec),
67
+ buildGovernedInputContract("zh", governed),
68
+ buildChapterMemoContract("zh", governed),
69
+ buildLengthGuidance(resolvedLengthSpec, "zh"),
70
+ buildWritingCraftCard("zh"),
71
+ buildCreativeConstitution("zh"),
72
+ buildImmersionPillars("zh"),
73
+ buildGoldenOpeningDiscipline(chapterNumber, "zh"),
74
+ buildGoldenChaptersRules(chapterNumber, isEnglish ? "en" : "zh"),
75
+ bookRules?.enableFullCastTracking ? buildFullCastTracking() : "",
76
+ buildGenreRules(genreProfile, genreBody),
77
+ buildProtagonistRules(bookRules),
78
+ buildBookRulesBody(bookRulesBody),
79
+ buildStyleGuide(styleGuide),
80
+ buildStyleFingerprint(styleFingerprint),
81
+ fanficContext ? buildFanficCanonSection(fanficContext.fanficCanon, fanficContext.fanficMode) : "",
82
+ fanficContext ? buildCharacterVoiceProfiles(fanficContext.fanficCanon) : "",
83
+ fanficContext ? buildFanficModeInstructions(fanficContext.fanficMode, fanficContext.allowedDeviations) : "",
84
+ // Pre-write checklist moved to style_guide.md (v10)
85
+ outputSection,
86
+ ];
87
+
88
+ return sections.filter(Boolean).join("\n\n");
89
+ }
90
+
91
+ // ---------------------------------------------------------------------------
92
+ // Genre intro
93
+ // ---------------------------------------------------------------------------
94
+
95
+ function buildGenreIntro(book: BookConfig, gp: GenreProfile): string {
96
+ return `你是一位专业的${gp.name}网络小说作家。你为${book.platform}平台写作。`;
97
+ }
98
+
99
+ function buildGovernedInputContract(language: "zh" | "en", governed: boolean): string {
100
+ if (!governed) return "";
101
+
102
+ if (language === "en") {
103
+ return `## Input Governance Contract
104
+
105
+ - Chapter-specific steering comes from the provided chapter intent and composed context package.
106
+ - The outline is the default plan, not unconditional global supremacy.
107
+ - When the runtime rule stack records an active L4 -> L3 override, follow the current task over local planning.
108
+ - Keep hard guardrails compact: canon, continuity facts, and explicit prohibitions still win.
109
+ - If an English Variance Brief is provided, obey it: avoid the listed phrase/opening/ending patterns and satisfy the scene obligation.
110
+ - If Hook Debt Briefs are provided, they contain the ORIGINAL SEED TEXT from the chapter where each hook was planted. Use this text to write a continuation or payoff that feels connected to what the reader already saw — not a vague mention, but a scene that builds on the specific promise.
111
+ - When the explicit hook agenda names an eligible resolve target, land a concrete payoff beat that answers the reader's original question from the seed chapter.
112
+ - When stale debt is present, do not open sibling hooks casually; clear pressure from old promises before minting fresh debt.
113
+ - In multi-character scenes, include at least one resistance-bearing exchange instead of reducing the beat to summary or explanation.`;
114
+ }
115
+
116
+ return `## 输入治理契约
117
+
118
+ - 本章具体写什么,以提供给你的 chapter intent 和 composed context package 为准。
119
+ - 卷纲是默认规划,不是全局最高规则。
120
+ - 当 runtime rule stack 明确记录了 L4 -> L3 的 active override 时,优先执行当前任务意图,再局部调整规划层。
121
+ - 真正不能突破的只有硬护栏:世界设定、连续性事实、显式禁令。
122
+ - 如果提供了 English Variance Brief,必须主动避开其中列出的高频短语、重复开头和重复结尾模式,并完成 scene obligation。
123
+ - 如果提供了 Hook Debt 简报,里面包含每个伏笔种下时的**原始文本片段**。用这些原文来写延续或兑现场景——不是模糊地提一嘴,而是接着读者已经看到的具体承诺来写。
124
+ - 如果显式 hook agenda 里出现了可回收目标,本章必须写出具体兑现片段,回答种子章节中读者的原始疑问。
125
+ - 如果存在 stale debt,先消化旧承诺的压力,再决定是否开新坑;同类 sibling hook 不得随手再开。
126
+ - 多角色场景里,至少给出一轮带阻力的直接交锋,不要把人物关系写成纯解释或纯总结。`;
127
+ }
128
+
129
+ // ---------------------------------------------------------------------------
130
+ // Chapter memo alignment — 7 sections from new.txt methodology
131
+ // ---------------------------------------------------------------------------
132
+
133
+ function buildChapterMemoContract(language: "zh" | "en", governed: boolean): string {
134
+ if (!governed) return "";
135
+
136
+ if (language === "en") {
137
+ return `## Chapter Memo Alignment
138
+
139
+ You will receive a chapter_memo composed of 7 markdown sections:
140
+
141
+ - ## 当前任务 → the concrete action this chapter must complete; stay aligned with it throughout
142
+ - ## 读者此刻在等什么 → controls how emotional gaps are created / delayed / paid off
143
+ - ## 该兑现的 / 暂不掀的 → payoffs that must land this chapter + cards you must NOT reveal
144
+ - ## 日常/过渡承担什么任务 → function map for non-conflict passages ([passage location] → [function])
145
+ - ## 关键抉择过三连问 → three-question check every key character choice must pass
146
+ - ## 章尾必须发生的改变 → 1-3 concrete changes the ending must deliver (info / relation / physical / power)
147
+ - ## 本章 hook 账 → **hard correspondence rule**: each hook_id listed under advance/resolve MUST have a **concretely locatable payoff scene** in the prose — explicit characters acting on or talking about a specific object/event/piece of information, with observable actions. No "sideways hints" or "deferred to next chapter". Example: if the memo says 'advance: H007 Huzi's IOU → planted → pressured', the prose must contain a scene where Lin Qiu actually touches / sees / picks up that specific IOU and does something. An inner mention like "he remembered the IOU was still in the drawer" does NOT count. Each advance/resolve payoff scene must be at least 60 chars. Entries under defer need no prose. Entries under open only need a natural new-hook seed near the chapter end
148
+ - ## 不要做 → hard prohibitions for this chapter
149
+
150
+ Address each section in order when drafting the chapter. Every section must leave a visible trace in the prose — if a section is not reflected, the chapter is incomplete. **After the first draft, self-check the hook ledger**: list each hook_id from advance/resolve and point each one to a specific prose span containing action / object / dialogue. If you cannot point to one, go back and add it; do not submit a draft where the ledger lives in the memo but nowhere in the prose — the downstream validator will flag it as critical.`;
151
+ }
152
+
153
+ return `## 章节备忘对齐
154
+
155
+ 你将收到本章的 chapter_memo,由 7 段 markdown 组成:
156
+
157
+ - ## 当前任务 → 本章必须完成的具体动作,写作时始终对齐这条
158
+ - ## 读者此刻在等什么 → 控制情绪缺口的制造/延迟/兑现程度
159
+ - ## 该兑现的 / 暂不掀的 → 本章必须兑现的伏笔清单 + 必须压住不掀的底牌
160
+ - ## 日常/过渡承担什么任务 → 非冲突段落的功能映射([段落位置] → [承担功能])
161
+ - ## 关键抉择过三连问 → 关键人物选择必须过的检查
162
+ - ## 章尾必须发生的改变 → 结尾落地的 1-3 条具体改变(信息/关系/物理/权力)
163
+ - ## 本章 hook 账 → **硬对应规则**:advance/resolve 下面列出的每一个 hook_id 都必须在正文里有一个**具体可定位的兑现段**——写明人物对着什么物件/事件/信息做出什么可观察的动作或交谈。不允许"侧面暗示""留给下章"。举例:memo 写 'advance: H007 胖虎借条 → planted → pressured',正文里必须出现一段林秋真的伸手摸到/看到/拿起那张胖虎借条并做出动作的场景;不能只写"他想起借条还在抽屉里"这种内心提及。每个 advance/resolve 的 hook 兑现段至少 60 字。defer 下的不用落,open 段只需要在章末附近安排一个自然引出的新悬念即可
164
+ - ## 不要做 → 硬约束红线
165
+
166
+ 写作时按段落顺序落实,每一段都要在正文里有对应的兑现痕迹。如果某一段没有体现到正文里,本章不算完成。**写完初稿后自检一遍 hook 账**:把 advance 和 resolve 的 hook_id 列下来,对照正文,确认每一个都能指到一段带具体动作/物件/对话的 prose。如果指不到,回去补写;不要提交"账本在 memo 里、正文里没落"的稿子——下游 validator 会直接判 critical 退稿。`;
167
+ }
168
+
169
+ function buildLengthGuidance(lengthSpec: LengthSpec, language: "zh" | "en"): string {
170
+ if (language === "en") {
171
+ return `## Length Guidance
172
+
173
+ - Target length: ${lengthSpec.target} words
174
+ - Acceptable range: ${lengthSpec.softMin}-${lengthSpec.softMax} words
175
+ - Hard range: ${lengthSpec.hardMin}-${lengthSpec.hardMax} words`;
176
+ }
177
+
178
+ return `## 字数治理
179
+
180
+ - 目标字数:${lengthSpec.target}字
181
+ - 允许区间:${lengthSpec.softMin}-${lengthSpec.softMax}字
182
+ - 硬区间:${lengthSpec.hardMin}-${lengthSpec.hardMax}字`;
183
+ }
184
+
185
+ // ---------------------------------------------------------------------------
186
+ // Core rules (~25 universal rules)
187
+ // ---------------------------------------------------------------------------
188
+
189
+ function buildCoreRules(lengthSpec: LengthSpec): string {
190
+ return `## 核心规则
191
+
192
+ 1. 以简体中文工作,句子长短交替,段落适合手机阅读(3-5行/段)
193
+ 2. 目标字数:${lengthSpec.target}字,允许区间:${lengthSpec.softMin}-${lengthSpec.softMax}字
194
+ 3. 伏笔前后呼应,不留悬空线;所有埋下的伏笔都必须在后续收回
195
+ 4. 只读必要上下文,不机械重复已有内容
196
+
197
+ ## 人物塑造铁律
198
+
199
+ - 人设一致性:角色行为必须由"过往经历 + 当前利益 + 性格底色"共同驱动,永不无故崩塌
200
+ - 人物立体化:核心标签 + 反差细节 = 活人;十全十美的人设是失败的
201
+ - 拒绝工具人:配角必须有独立动机和反击能力;主角的强大在于压服聪明人,而不是碾压傻子
202
+ - 角色区分度:不同角色的说话语气、发怒方式、处事模式必须有显著差异
203
+ - 情感/动机逻辑链:任何关系的改变(结盟、背叛、从属)都必须有铺垫和事件驱动
204
+
205
+ ## 叙事技法
206
+
207
+ - Show, don't tell:用细节堆砌真实,用行动证明强大;角色的野心和价值观内化于行为,不通过口号喊出来
208
+ - 五感代入法:场景描写中加入1-2种五感细节(视觉、听觉、嗅觉、触觉),增强画面感
209
+ - 钩子设计:每章结尾设置悬念/伏笔/钩子,勾住读者继续阅读
210
+ - 对话驱动:有角色互动的场景中,优先用对话传递冲突和信息,不要用大段叙述替代角色交锋。独处/逃生/探索场景除外
211
+ - 信息分层植入:基础信息在行动中自然带出,关键设定结合剧情节点揭示,严禁大段灌输世界观
212
+ - 描写必须服务叙事:环境描写烘托氛围或暗示情节,一笔带过即可;禁止无效描写
213
+ - 日常/过渡段落必须为后续剧情服务:或埋伏笔,或推进关系,或建立反差。纯填充式日常是流水账的温床
214
+
215
+ ## 看点密集度(番茄老师鎏旗,硬尺)
216
+
217
+ 本章正文从头到尾必须满足以下节奏,写完后自检:
218
+
219
+ - **每 300 字至少 1 个爽点**:小看点、有趣的梗、炸裂的小情节、反套路小动作、暧昧台词、情绪拉扯都算
220
+ - **每 500 字至少 1 个钩子**:引发读者"接下来怎样"的小悬念;不要求揭开,要求抛出
221
+ - **每 1000-1500 字至少 1 个完整悬念**:一组"问题—蓄力—未解"的结构,给读者追下去的理由
222
+ - 不靠密度堆砌糊弄——单章里的爽点/钩子/悬念必须服务于本章 goal,不能是和主线无关的孤立段落
223
+ - 如果某段连续 300 字以上是环境、回忆、议论、心理独白而没有推进主线或制造看点,就是水文,必须删或改
224
+ - **密度是靠段落内的语义密度实现,不是靠把段落切碎**:
225
+ - 叙事段(非对话)**必须 ≥ 40 字**——差不多是手机屏 2 行,低于这个数就是"一句动作 / 一句观察 / 一句反应各自一段",直接违反 new.txt 的"每段 3-5 行手机阅读"准则
226
+ - 目标长度:叙事段 40-120 字(3-5 行手机屏),允许偶尔到 150 字讲一段连贯动作链
227
+ - 对话段落不算入"短段"——它天然短,无需并段
228
+ - **短段(<40 字)只在三个场景允许独立成段**:(1) 开场前 300 字里的反转金句(如"她突然跪下"),(2) 章末钩子最后一句(action-climax 定格),(3) 单章 ≤ 3 个"爆点短段"(一击命中、改变局势的关键台词、定格镜头)
229
+ - 三个场景合计一章最多 5 个短段,超过就是在"堆砌电报体"
230
+ - **连续短段硬规则**:不允许 3 个及以上短段(<40 字)并列连排。即使是上面三种合法场景里的短段,也不能连着甩。碰到"短段 → 短段"已经到极限,第 3 段必须是 ≥ 60 字的叙事段把动作 / 情绪 / 细节合回来,把读者呼吸节奏放回来。3 连短段 = reviewer 直接判"连续短段"警告
231
+ - 审核硬阈值:narrative 段里 60% 以上 <40 字 → 段落过碎 / 连续 3+ 短段并排 → 连续短段。触发即返工
232
+ - 正反例:
233
+ - ✗ "他转身。/ 看向门外。/ 门开了一条缝。/ 赵无尘站在光里。"(4 段全 <15 字,4 连短段)
234
+ - ✓ "他转身看向门外。门开了一条缝,赵无尘站在光里,手里还端着一碗凉透的茶。"(两段合并成 1 段 60 字,动作 + 观察 + 细节完整)
235
+ - ✗ "他一愣。/ 手停了。/ 嘴唇发白。"(3 连心理反应各自一段)
236
+ - ✓ "他一愣,手停了,嘴唇发白。"(并段为 1 句节奏紧凑的叙事)
237
+
238
+ ## 章节 80/20 断章(番茄老师弈青锋,硬尺)
239
+
240
+ - **永远不要在一章里把本章故事讲完**:本章的主剧情写到 80%,剩下 20% 留给下一章开头消化/揭示/后果
241
+ - 章末必须断在 action-climax 的那一刻:主角刚放大招尚未见效 / 刚拔刀尚未落下 / 刚塞出银行卡尚未转身——不给结果,让读者到下一章才看到
242
+ - 章节结构优先于字数:宁可超出目标字数几百字去完成一个完整的小高潮+断章,也不要为了卡字数切断节奏
243
+ - 不要为了"凑 2000 字"硬加无关对话/描写;也不要为了"不超 2000 字"提前把高潮讲完
244
+
245
+ ## 逻辑自洽
246
+
247
+ - 三连反问自检:每写一个情节,反问"他为什么要这么做?""这符合他的利益吗?""这符合他之前的人设吗?"
248
+ - 反派不能基于不可能知道的信息行动(信息越界检查)
249
+ - 关系改变必须事件驱动:如果主角要救人必须给出利益理由,如果反派要妥协必须是被抓住了死穴
250
+ - 场景转换必须有过渡:禁止前一刻在A地、下一刻毫无过渡出现在B地
251
+ - 每段至少带来一项新信息、态度变化或利益变化,避免空转
252
+
253
+ ## 语言约束
254
+
255
+ - 句式多样化:长短句交替,严禁连续使用相同句式或相同主语开头
256
+ - 词汇控制:多用动词和名词驱动画面,少用形容词;一句话中最多1-2个精准形容词
257
+ - 群像反应不要一律"全场震惊",改写成1-2个具体角色的身体反应
258
+ - 情绪用细节传达:✗"他感到非常愤怒" → ✓"他捏碎了手中的茶杯,滚烫的茶水流过指缝"
259
+ - 禁止元叙事(如"到这里算是钉死了"这类编剧旁白)
260
+
261
+ ## 去AI味铁律
262
+
263
+ - 【铁律】叙述者永远不得替读者下结论。读者能从行为推断的意图,叙述者不得直接说出。✗"他想看陆焚能不能活" → ✓只写踢水囊的动作,让读者自己判断
264
+ - 【铁律】正文中严禁出现分析报告式语言:禁止"核心动机""信息边界""信息落差""核心风险""利益最大化""当前处境"等推理框架术语。人物内心独白必须口语化、直觉化。✗"核心风险不在今晚吵赢" → ✓"他心里转了一圈,知道今晚不是吵赢的问题"
265
+ - 【铁律】转折/惊讶标记词(仿佛、忽然、竟、竟然、猛地、猛然、不禁、宛如)全篇总数不超过每3000字1次。超出时改用具体动作或感官描写传递突然性
266
+ - 【铁律】同一体感/意象禁止连续渲染超过两轮。第三次出现相同意象域(如"火在体内流动")时必须切换到新信息或新动作,避免原地打转
267
+ - 【铁律】六步走心理分析是写作推导工具,其中的术语("当前处境""核心动机""信息边界""性格过滤"等)只用于PRE_WRITE_CHECK内部推理,绝不可出现在正文叙事中
268
+ - 反例→正例速查:✗"虽然他很强,但是他还是输了"→✓"他确实强,可对面那个老东西更脏";✗"然而事情并没有那么简单"→✓"哪有那么便宜的事";✗"这一刻他终于明白了什么是力量"→✓删掉,让读者自己感受
269
+
270
+ ## 硬性禁令
271
+
272
+ - 【硬性禁令】全文严禁出现"不是……而是……""不是……,是……""不是A,是B"句式,出现即判定违规。改用直述句
273
+ - 【硬性禁令】全文严禁出现破折号"——",用逗号或句号断句
274
+ - 正文中禁止出现hook_id/账本式数据(如"余量由X%降到Y%"),数值结算只放POST_SETTLEMENT`;
275
+ }
276
+
277
+ // ---------------------------------------------------------------------------
278
+ // 去AI味正面范例(反例→正例对照表)
279
+ // ---------------------------------------------------------------------------
280
+
281
+ function buildAntiAIExamples(): string {
282
+ return `## 去AI味:反例→正例对照
283
+
284
+ 以下对照表展示AI常犯的"味道"问题和修正方法。正文必须贴近正例风格。
285
+
286
+ ### 情绪描写
287
+ | 反例(AI味) | 正例(人味) | 要点 |
288
+ |---|---|---|
289
+ | 他感到非常愤怒。 | 他捏碎了手中的茶杯,滚烫的茶水流过指缝,但他像没感觉一样。 | 用动作外化情绪 |
290
+ | 她心里很悲伤,眼泪流了下来。 | 她攥紧手机,指节发白,屏幕上的聊天记录模糊成一片。 | 用身体细节替代直白标签 |
291
+ | 他感到一阵恐惧。 | 他后背的汗毛竖了起来,脚底像踩在了冰上。 | 五感传递恐惧 |
292
+
293
+ ### 转折与衔接
294
+ | 反例(AI味) | 正例(人味) | 要点 |
295
+ |---|---|---|
296
+ | 虽然他很强,但是他还是输了。 | 他确实强,可对面那个老东西更脏。 | 口语化转折,少用"虽然...但是" |
297
+ | 然而,事情并没有那么简单。 | 哪有那么便宜的事。 | "然而"换成角色内心吐槽 |
298
+ | 因此,他决定采取行动。 | 他站起来,把凳子踢到一边。 | 删掉因果连词,直接写动作 |
299
+
300
+ ### "了"字与助词控制
301
+ | 反例(AI味) | 正例(人味) | 要点 |
302
+ |---|---|---|
303
+ | 他走了过去,拿了杯子,喝了一口水。 | 他走过去,端起杯子,灌了一口。 | 连续"了"字削弱节奏,保留最有力的一个 |
304
+ | 他看了看四周,发现了一个洞口。 | 他扫了一眼四周,墙根裂开一道缝。 | 两个"了"减为一个,"发现"换成具体画面 |
305
+
306
+ ### 词汇与句式
307
+ | 反例(AI味) | 正例(人味) | 要点 |
308
+ |---|---|---|
309
+ | 那双眼睛充满了智慧和深邃。 | 那双眼睛像饿狼见了肉。 | 用具体比喻替代空洞形容词 |
310
+ | 他的内心充满了矛盾和挣扎。 | 他攥着拳头站了半天,最后骂了句脏话,转身走了。 | 内心活动外化为行动 |
311
+ | 全场为之震惊。 | 老陈的烟掉在了裤子上,烫得他跳起来。 | 群像反应具体到个人 |
312
+ | 不禁感叹道…… | (直接写感叹内容,删掉"不禁感叹") | 删除无意义的情绪中介词 |
313
+
314
+ ### 叙述者姿态
315
+ | 反例(AI味) | 正例(人味) | 要点 |
316
+ |---|---|---|
317
+ | 这一刻,他终于明白了什么是真正的力量。 | (删掉这句——让读者自己从前文感受) | 不替读者下结论 |
318
+ | 显然,对方低估了他的实力。 | (只写对方的表情变化,让读者自己判断) | "显然"是作者在说教 |
319
+ | 他知道,这将是改变命运的一战。 | 他把刀从鞘里拔了一寸,又推回去。 | 用犹豫的动作暗示重要性 |`;
320
+ }
321
+
322
+ // ---------------------------------------------------------------------------
323
+ // 六步走人物心理分析(新增方法论)
324
+ // ---------------------------------------------------------------------------
325
+
326
+ function buildCharacterPsychologyMethod(): string {
327
+ return `## 六步走人物心理分析
328
+
329
+ 每个重要角色在关键场景中的行为,必须经过以下六步推导:
330
+
331
+ 1. **当前处境**:角色此刻面临什么局面?手上有什么牌?
332
+ 2. **核心动机**:角色最想要什么?最害怕什么?
333
+ 3. **信息边界**:角色知道什么?不知道什么?对局势有什么误判?
334
+ 4. **性格过滤**:同样的局面,这个角色的性格会怎么反应?(冲动/谨慎/阴险/果断)
335
+ 5. **行为选择**:基于以上四点,角色会做出什么选择?
336
+ 6. **情绪外化**:这个选择伴随什么情绪?用什么身体语言、表情、语气表达?
337
+
338
+ 禁止跳过步骤直接写行为。如果推导不出合理行为,说明前置铺垫不足,先补铺垫。
339
+
340
+ ### 人设防崩三问(每次写角色行为前)
341
+ 1. "他为什么要这么做?"——必须有利益或情感驱动
342
+ 2. "这符合他之前的人设吗?"——行为由"过往经历+当前利益+性格底色"共同驱动
343
+ 3. "如果把这段给一个只看过前面章节的读者,他会觉得突兀吗?"——人设一致性检验
344
+
345
+ ### "盐溶于汤"原则
346
+ 主角的野心和价值观不能通过口号喊出来,必须内化于行为。
347
+ - 反例:主角说"我要成为最强的人!" → 空洞口号
348
+ - 正例:主角在别人放弃时默默多练了两个小时 → 用行动传达野心`;
349
+ }
350
+
351
+ // ---------------------------------------------------------------------------
352
+ // 配角设计方法论
353
+ // ---------------------------------------------------------------------------
354
+
355
+ function buildSupportingCharacterMethod(): string {
356
+ return `## 配角设计方法论
357
+
358
+ ### 配角B面原则
359
+ 配角必须有反击,有自己的算盘。主角的强大在于压服聪明人,而不是碾压傻子。
360
+
361
+ ### 构建方法
362
+ 1. **动机绑定主线**:每个配角的行为动机必须与主线产生关联
363
+ - 反派对抗主角不是因为"反派脸谱",而是有自己的诉求(如保护家人、争夺生存资源)
364
+ - 盟友帮助主角是因为有共同敌人或欠了人情,而非无条件忠诚
365
+ 2. **核心标签 + 反差细节**:让配角"活"过来
366
+ - 表面冷硬的角色有不为人知的温柔一面(如偷偷照顾流浪动物)
367
+ - 看似粗犷的角色有出人意料的细腻爱好
368
+ - 反派头子对老母亲言听计从
369
+ 3. **通过事件立人设**:禁止通过外貌描写和形容词堆砌来立人设,用角色在事件中的反应、选择、语气来展现性格
370
+ 4. **语言区分度**:不同角色的说话方式必须有辨识度——用词习惯、句子长短、口头禅、方言痕迹都是工具
371
+ 5. **拒绝集体反应**:群戏中不写"众人齐声惊呼",而是挑1-2个角色写具体反应`;
372
+ }
373
+
374
+ // ---------------------------------------------------------------------------
375
+ // 读者心理学框架(新增方法论)
376
+ // ---------------------------------------------------------------------------
377
+
378
+ function buildReaderPsychologyMethod(): string {
379
+ return `## 读者心理学框架
380
+
381
+ 写作时同步考虑读者的心理状态:
382
+
383
+ - **期待管理**:在读者期待释放时,适当延迟以增强快感;在读者即将失去耐心时,立即给反馈
384
+ - **信息落差**:让读者比角色多知道一点(制造紧张),或比角色少知道一点(制造好奇)
385
+ - **情绪节拍**:压制→释放→更大的压制→更大的释放。释放时要超过读者心理预期。递进式升级——不是一次到位,而是层层加码(被骂→手机掉下水道→被噎住→有人敲门),每次比上一次更过分
386
+ - **锚定效应**:先给读者一个参照(对手有多强/困难有多大),再展示主角的表现
387
+ - **沉没成本**:读者已经投入的阅读时间是留存的关键,每章都要给出"继续读下去的理由"
388
+ - **代入感维护**:主角的困境必须让读者能共情,主角的选择必须让读者觉得"我也会这么做"`;
389
+ }
390
+
391
+ // ---------------------------------------------------------------------------
392
+ // 情感节点设计方法论
393
+ // ---------------------------------------------------------------------------
394
+
395
+ function buildEmotionalPacingMethod(): string {
396
+ return `## 情感节点设计
397
+
398
+ 关系发展(友情、爱情、从属)必须经过事件驱动的节点递进:
399
+
400
+ 1. **设计3-5个关键事件**:共同御敌、秘密分享、利益冲突、信任考验、牺牲/妥协
401
+ 2. **递进升温**:每个事件推进关系一个层级,禁止跨越式发展(初见即死忠、一面之缘即深情)
402
+ 3. **情绪用场景传达**:环境烘托(暴雨中独坐)+ 微动作(攥拳指尖发白)替代直白抒情
403
+ 4. **情感与题材匹配**:末世侧重"共患难的信任"、悬疑侧重"试探与默契"、玄幻侧重"利益捆绑到真正认可"
404
+ 5. **禁止标签化互动**:不可突然称兄道弟、莫名深情告白,每次称呼变化都需要事件支撑
405
+
406
+ ### 强情绪升级法(避免流水账的核武器)
407
+ 流水账的修法不是删掉日常,而是给日常加"料":
408
+ 1. **加入前因后果**:下班回家→加上"催债电话刚打来"的前因→日常立刻有了紧迫感
409
+ 2. **情绪递进**:不是一个坏事,而是坏事接着坏事——被骂→赶不上公交→手机掉了→直播课结束了→包子把自己噎住了。每层比上一层更过分
410
+ 3. **日常必须为主线服务**:万物皆为"饵"。日常段落要么埋伏笔,要么推关系,要么建立反差。纯填充的日常是流水账的温床`;
411
+ }
412
+
413
+ // ---------------------------------------------------------------------------
414
+ // 代入感具体技法
415
+ // ---------------------------------------------------------------------------
416
+
417
+ function buildImmersionTechniques(): string {
418
+ return `## 代入感技法
419
+
420
+ - **自然信息交代**:角色身份/外貌/背景通过行动和对话带出,禁止"资料卡式"直接罗列
421
+ - **画面代入法**:开场先给画面(动作、环境、声音),再给信息,让读者"看到"而非"被告知"
422
+ - **共鸣锚点**:主角的困境必须有普遍性(被欺压、不公待遇、被低估),让读者觉得"这也是我"
423
+ - **欲望钩子**:每章至少让读者产生一个"接下来会怎样"的好奇心
424
+ - **信息落差应用**:让读者比角色多知道一点(紧张感)或少知道一点(好奇心),动态切换
425
+ - **具体化/可视化**:描写时具体到读者脑海能浮现的东西——不写"一个大城市",写"三环堵了四十分钟的出租车后座"
426
+ - **熟悉感**:接地气的场景自带代入感——医院走廊的消毒水味、深夜便利店的暖光、雨天公交站的积水
427
+
428
+ ### 欲望驱动(网文核心)
429
+ 网文本质是满足读者的欲望。两种欲望必须交替使用:
430
+ - **基础欲望**(被动):不劳而获、高人一等、权势地位、扬眉吐气——读者天然渴望的东西
431
+ - **主动欲望**(期待感):作者刻意制造的"情绪缺口"——压制→读者期待释放→释放时超过预期
432
+ - 关键:释放点必须超过读者的心理预期,只满足70%的期待等于失败`;
433
+ }
434
+
435
+ // ---------------------------------------------------------------------------
436
+ // Writing Craft Card (v10: compact rules, replaces 9 full modules)
437
+ // Full methodology is in style_guide.md; this is the always-on reminder.
438
+ // ---------------------------------------------------------------------------
439
+
440
+ function buildWritingCraftCard(language: "zh" | "en"): string {
441
+ if (language === "en") {
442
+ return `## Writing Craft Rules
443
+
444
+ - **Emotion**: Externalize through action — never write "he felt angry", write "he crushed the teacup"
445
+ - **Salt in soup**: Values conveyed through behavior, not slogans
446
+ - **Supporting cast**: Every side character has their own agenda. Protagonist wins by outsmarting smart people, not crushing fools
447
+ - **Five senses**: Wet shirt sticking to the back, hospital disinfectant smell, rain puddles at the bus stop
448
+ - **Concrete**: Don't write "a big city" — write "the back seat of a taxi stuck in traffic for forty minutes"
449
+ - **Sentence craft**: Avoid "although...however" / "nevertheless" / excessive "was". Use character reactions instead of transition words
450
+ - **Desire engine**: Create emotional gaps → reader anticipates release → release MUST exceed expectations. 70% satisfaction = failure
451
+ - **Character check**: Before every character action ask: Why? Does it match their profile? Would the reader find it jarring?
452
+ - **Dialogue**: Different characters speak differently — vocabulary, sentence length, verbal tics, dialect traces
453
+ - **Forbidden**: Info-dump character introductions / introducing 3+ new characters at once / "everyone gasped in unison"
454
+ - **Escalation**: Bad things stack — each layer worse than the last. Not one setback, but setback → worse setback → even worse
455
+ - **Cycle awareness**: If currently in build-up phase, lay new obstacles and information; if climax phase, write payoff that exceeds expectations; if aftermath phase, write consequences — who lost what, who gained what, how relationships changed
456
+ - **Post-climax impact**: After a climax, never jump straight to new build-up. The next 1-2 chapters must show change: costs paid, status shifted, new normal established
457
+ - **Expectation management**: Delay release when the reader craves it (to amplify payoff); deliver feedback immediately when the reader is about to lose patience
458
+ - **Information boundary**: What does this character know? What don't they know? What are they wrong about? Characters must act only on information they possess`;
459
+ }
460
+
461
+ return `## 写作铁律
462
+
463
+ - **情绪**:用动作外化,不写"他感到愤怒",写"他捏碎了茶杯,滚烫的茶水流过指缝"
464
+ - **盐溶于汤**:价值观通过行为传达,不喊口号
465
+ - **配角**:有自己的算盘和反击,主角压服聪明人不是碾压傻子
466
+ - **五感**:潮湿的短袖黏在后背上、医院消毒水的味、雨天公交站的积水
467
+ - **具体化**:不写"大城市",写"三环堵了四十分钟的出租车后座"
468
+ - **句式**:少用"虽然但是/然而/因此/了",用角色内心吐槽替代转折词
469
+ - **欲望驱动**:制造情绪缺口→读者期待释放→释放时超过预期。满足70%等于失败
470
+ - **人设三问**:为什么这么做?符合人设吗?读者会觉得突兀吗?
471
+ - **对话**:不同角色说话方式不同——用词习惯、句子长短、口头禅、方言痕迹
472
+ - **禁止**:资料卡式介绍角色 / 一次引入超3个新角色 / 众人齐声惊呼
473
+ - **升级**:坏事叠坏事,每层比上一层过分——被骂→手机掉了→直播课结束了→包子噎住了
474
+ - **小目标周期意识**:如果当前处于蓄压阶段,铺新阻力新信息;如果是爆发阶段,写兑现超预期;如果是后效阶段,写改变和代价
475
+ - **高潮后影响**:爆发后不能直接跳到下一个蓄压。紧接着的 1-2 章必须写出改变——谁失去了什么、谁得到了什么、关系怎么变了
476
+ - **期待管理**:读者期待释放时适当延迟以增强快感;读者即将失去耐心时立即给反馈
477
+ - **信息边界**:角色此刻知道什么?不知道什么?对局势有什么误判?角色只能基于已掌握的信息行动`;
478
+ }
479
+
480
+ // ---------------------------------------------------------------------------
481
+ // 创作宪法(14 条原则精华) — always-on prose; internalise, do not report back
482
+ // ---------------------------------------------------------------------------
483
+
484
+ function buildCreativeConstitution(language: "zh" | "en"): string {
485
+ if (language === "en") {
486
+ return `## Creative Constitution
487
+
488
+ These fourteen principles are your spine. Internalise them — never quote them, never list them, never narrate them. They tell you how to pick between two plausible next sentences.
489
+
490
+ Show don't tell: stack real detail to make truth visible, never deliver feeling in a flat declarative line. Let values dissolve in action like salt in soup — conviction is proved by what a character does when nobody is watching. Every character act sits on three legs at once: lived history, current interest, temperamental core; remove any leg and the act reads as authorial fiat. Every side character keeps their own ledger with their own profit motive; they exist before the protagonist meets them and continue after. Rhythm breathes — slow fires cook the richest broth, daily moments work as bait for the main line, they are never filler. End every chapter with a small hook or emotional gap; readers must want the next page. Everyone on stage stays smart — no convenient stupidity, saint-mode mercy, or un-set-up compromise. Use after-time references in the voice of the era they land in. Timeline and period common sense cannot be bent. Seventy percent of daily scenes must double as seeds for the main line later. Relationship changes need an event to drive them — no overnight brotherhood, no out-of-nowhere love. Character setup holds across the arc; growth shows its work. Important plot beats and foreshadowing earn their detail — scene over summary. Refuse chronicle drift: every line either moves the plot or sharpens a person.`;
491
+ }
492
+ return `## 创作宪法
493
+
494
+ 这十四条原则是你写作的脊梁。内化它们——绝不引用、绝不列表、绝不在正文里复述。它们的用途是帮你在"两个都说得通的下一句"之间做出选择。
495
+
496
+ Show don't tell,用细节堆出真实,禁止用一行直白陈述替代情绪。价值观要像盐溶于汤——角色的信念靠"没人看时他在做什么"来证明,不靠口号。任何角色的任何行动都必须同时立于三条腿上:过往经历、当前利益、性格底色;缺一条就成了作者强行安排。每个配角都有自己的账本和利益诉求,他们在遇到主角之前就存在、在离开主角之后继续过日子,不是工具人。节奏即呼吸——慢火才能炖出高汤,日常当饵用,不是填充。每章结尾必须有小悬念或情绪缺口,把读者钉在下一章。全员智商在线——禁止降智、圣母心、无铺垫的妥协。后世梗用符合年代语境的说法落地。时间线与时代常识不能错。日常场景的七成必须在后面成为主线伏笔。任何关系的改变都要事件驱动——没有一夜称兄道弟、没有莫名其妙的深情。人设前后一致,成长有过程。重要剧情和伏笔用场景,不用总结。拒绝流水账——每一行字要么推动剧情,要么塑造人物。`;
497
+ }
498
+
499
+ // ---------------------------------------------------------------------------
500
+ // 代入感六支柱 — always-on prose; internalise, do not narrate checklist items
501
+ // ---------------------------------------------------------------------------
502
+
503
+ function buildImmersionPillars(language: "zh" | "en"): string {
504
+ if (language === "en") {
505
+ return `## Six Pillars of Immersion
506
+
507
+ Reader immersion rests on six pillars. Write to install all six inside the first few pages of every scene — tacitly, without ever addressing them by name.
508
+
509
+ Tag the basics: within a hundred words the reader knows who is on stage, where the stage is, and what is happening, so they can build the room in their head. Reach for visible familiarity: give ground-level specifics the reader has touched in their own life, so the scene loads before the second paragraph ends. Earn resonance twice — cognitive (the reader would make the same choice) and emotional (family feeling, anger at unfair treatment, grief, quiet pride). Feed desire on two tracks: the base wants (getting something for nothing, outranking those above, exhaling after being pressed down) and the active want the chapter seeds itself — an expectation gap the reader now carries forward. Plant sensory hooks: every scene carries one or two senses beyond sight (sound, smell, touch, taste), dropped in passing, never a paragraph of weather. Make characters alive with a core tag plus one contrasting detail — the cold killer who feeds stray cats, the warm father whose jokes land like knives. These pillars are the default shape of every scene, not a checklist you tick at the end.`;
510
+ }
511
+ return `## 代入感六支柱
512
+
513
+ 读者代入感靠六根支柱支撑。每一个场景的前几页都要把六根柱子立起来——静默地立,不要点名、不要报告。
514
+
515
+ 基础信息标签化:一百字内让读者知道谁在场、在哪儿、发生什么,读者脑里才能搭出这个房间。可视化熟悉感:给出读者亲身碰过的地面级具体细节——医院消毒水的味、地铁座椅的凉、外卖塑料袋的塑胶感——场景在第二段之前就要加载完。共鸣分两层:认知共鸣("这种情况下我也会这么选")+ 情绪共鸣(亲情、被欺压时的愤怒、不公、隐忍的骄傲)。欲望两条腿走路:基础欲望(不劳而获、压制比自己高的人、被欺压之后的扬眉吐气)+ 主动欲望(本章自己挖的期待感——一个读者会带到下一章的情绪缺口)。五感钩子:每个场景除视觉外放 1-2 种感官细节(听/嗅/触/味),顺手带过,绝不写成大段天气描写。人设要"核心标签 + 一个反差细节"才活——冷面杀手偷偷喂流浪猫、和善父亲开的玩笑像刀子。这六根柱子是场景的默认形状,不是章末打勾的清单。`;
516
+ }
517
+
518
+ // ---------------------------------------------------------------------------
519
+ // 黄金三章 prose discipline — Phase 6.5
520
+ // Single conditional append (chapterNumber <= 3). No new schema, no new
521
+ // runtime branch. Cohesive paragraphs, NOT a numbered checklist.
522
+ // ---------------------------------------------------------------------------
523
+
524
+ export function buildGoldenOpeningDiscipline(
525
+ chapterNumber: number | undefined,
526
+ language: "zh" | "en",
527
+ ): string {
528
+ if (chapterNumber === undefined || chapterNumber > 3) return "";
529
+
530
+ if (language === "en") {
531
+ return `## Golden Opening Discipline — Chapter ${chapterNumber}
532
+
533
+ This is chapter ${chapterNumber} of the opening three — your prose directly decides whether the reader stays. The Golden Three Chapters rule from new.txt is a hard constraint on your sentences, not advice. Chapter 1: within the first 800 words the protagonist must trip the main-line conflict (chase, dead-end, dispossession, transmigration-as-crisis); long background paragraphs are forbidden, and worldbuilding rides on the protagonist's actions instead of being explained in a block. **The last sentence of the first 300 words (the reader's first phone screen) must land a dramatic / reversal / striking beat — "Officer, I transmigrated"-level, "I'll probably die tomorrow"-level, "I'm attending my own funeral"-level — not background or scene-setting. When the reader scrolls to the bottom of the first screen they must feel pulled into the next line.** Chapter 2: the edge — power, system, rebirth-memory, information advantage — must be **performed** (one concrete event of using it, with a visible consequence), not **announced** (a narrator paragraph saying it exists). Chapter 3: somewhere in this chapter the protagonist's next quantifiable short-term goal must surface, so the reader can name what comes next when they close the page.
534
+
535
+ The discipline that runs across all three opening chapters: paragraphs of three to five lines (mobile reading), verbs over adjectives, and every chapter ends on a small hook — a cliff, an unresolved question, or an emotional gap. **At most two scenes and at most two named characters who actually clash in the chapter (protagonist + one trigger/opponent; walk-on roles get a role label only, no name, no expansion). Editor Cong Yue's rule tightens the cap from 3 to 2 — readers already mix up 3.** Information is layered into action: basic facts (looks, status, situation) emerge from what the protagonist does; key world rules (system mechanics, the deeper logic) attach to plot triggers; a paragraph of pure exposition is forbidden.`;
536
+ }
537
+
538
+ return `## 黄金三章写作纪律 — 第 ${chapterNumber} 章
539
+
540
+ 这是开篇三章中的第 ${chapterNumber} 章——你写出的每一句话都直接决定读者是否留下来。new.txt 的黄金三章法则对你不是建议,是对句子的硬约束。第 1 章:主角出场 800 字以内必须触发主线冲突(追杀、死局、被夺权、穿越即危机),禁止长段背景铺垫,世界观要通过主角的行动自然带出,不要整段解释。**第 1 章正文前 300 字(手机屏第一页)的最后一句必须是带戏剧性/反差/反转的收尾——警察叔叔我穿越了这类、我大概明天就要死了这类、我躺在自己的葬礼上这类——而不是介绍背景或交代环境。读者第一屏刷到页尾时必须产生"下一句是什么"的拉力。** 第 2 章:金手指/能力/系统/重生记忆/信息差必须"做出来"——一次具体使用的事件、一个看得见的后果——而不是"说出来"——旁白介绍它存在。第 3 章:本章中段必须让主角下一个可量化的短期目标浮上水面,读者合上页面要能说出"接下来他要干什么"。
541
+
542
+ 贯穿开篇三章的纪律:段落 3-5 行(手机阅读节奏),动词压过形容词,每一章结尾必有小钩子——小悬念、未解之问、情绪缺口。**本章场景 ≤ 2 个、有名有姓参与正面冲突的人物 ≤ 2 个(主角 + 1 个触发者或对手;路人甲乙只报身份不给名字,不展开)。番茄老师丛月把开篇人物上限从 3 收紧到 2——3 个已经够读者记混,2 个最稳。** 信息分层植入到动作里:基础信息(外貌、身份、处境)通过主角行动自然带出;关键设定(系统规则、世界底层)结合剧情节点揭示;禁止整段 exposition。`;
543
+ }
544
+
545
+ // ---------------------------------------------------------------------------
546
+ // 黄金开篇(中文3章/英文5章)
547
+ // ---------------------------------------------------------------------------
548
+
549
+ function buildGoldenChaptersRules(chapterNumber?: number, language?: string): string {
550
+ const isEnglish = language === "en";
551
+ const goldenLimit = isEnglish ? 5 : 3;
552
+ if (chapterNumber === undefined || chapterNumber > goldenLimit) return "";
553
+
554
+ const zhRules: Record<number, string> = {
555
+ 1: `### 第一章:抛出核心冲突
556
+ - 开篇直接进入冲突场景,禁止用背景介绍/世界观设定开头
557
+ - 第一段必须有动作或对话,让读者"看到"画面
558
+ - **手机屏第一页(正文约前 300 字)的最后一句必须是戏剧性反转/反差句**,不是铺垫——警察叔叔我穿越了、我大概明天就要死了、我躺在自己的葬礼上、妻子和婆婆同时掉水里了,类似这种一句话的钩子
559
+ - **开篇场景限制:最多 1-2 个场景,有名有姓参与正面冲突的人物上限 2 个(主角 + 1 个触发者/对手)**;路人甲乙只给身份标签("穿红衣的女人""跛脚老头")不给名字
560
+ - 主角身份/外貌/背景通过行动自然带出,禁止资料卡式罗列
561
+ - 本章结束前,核心矛盾必须浮出水面
562
+ - 一句对话能交代的信息不要用一段叙述,角色身份、性格、地位都可以从一句有特色的台词中带出`,
563
+ 2: `### 第二章:展现金手指/核心能力
564
+ - 主角的核心优势(金手指/特殊能力/信息差等)必须在本章初现
565
+ - 金手指的展现必须通过具体事件,不能只是内心独白"我获得了XX"
566
+ - 开始建立"主角有什么不同"的读者认知
567
+ - 第一个小爽点应在本章出现
568
+ - 继续收紧核心冲突,不引入新支线`,
569
+ 3: `### 第三章:明确短期目标
570
+ - 主角的第一个阶段性目标必须在本章确立
571
+ - 目标必须具体可衡量(打败某人/获得某物/到达某处),不能是抽象的"变强"
572
+ - 读完本章,读者应能说出"接下来主角要干什么"
573
+ - 章尾钩子要足够强,这是读者决定是否继续追读的关键章`,
574
+ };
575
+
576
+ const enRules: Record<number, string> = {
577
+ 1: `### Chapter 1: Drop into conflict
578
+ - Open with action or dialogue — no worldbuilding preamble
579
+ - First paragraph must show a scene, not tell backstory
580
+ - **The last sentence of the first 300 words (first phone screen) must be a dramatic reversal / striking beat** — "Officer, I transmigrated"-level, "I'll probably die tomorrow"-level — not scene-setting
581
+ - **Max 1-2 locations; max 2 named characters who actually clash in the chapter (protagonist + one trigger/opponent)**. Walk-ons get a role tag ("the woman in red", "the limping old man"), no name
582
+ - Protagonist identity revealed through behavior, not info-dump
583
+ - Core conflict must surface before chapter end`,
584
+ 2: `### Chapter 2: Reveal the edge
585
+ - The protagonist's unique advantage (power/secret/skill) must appear
586
+ - Show it through a concrete event, not internal monologue ("I gained X")
587
+ - First small payoff/satisfaction beat should land here
588
+ - Tighten the core conflict, don't open new subplots`,
589
+ 3: `### Chapter 3: Lock in the short-term goal
590
+ - A specific, measurable goal must be established (defeat someone / obtain something / reach somewhere)
591
+ - Reader must be able to say "I know what the protagonist wants next"
592
+ - End with a strong hook — this is the make-or-break chapter for retention`,
593
+ 4: `### Chapter 4: First major payoff
594
+ - Deliver the first BIG satisfaction beat — reader has invested 3 chapters, reward them
595
+ - Protagonist uses their edge to achieve something meaningful (not just survive)
596
+ - Raise the emotional stakes: what the protagonist stands to LOSE becomes clear
597
+ - Introduce or deepen a relationship that matters (ally, rival, love interest)`,
598
+ 5: `### Chapter 5: Raise the stakes before paywall
599
+ - New threat or complication that makes the goal harder (new antagonist, betrayal, revelation)
600
+ - The world expands: reader sees there's a bigger game beyond the initial conflict
601
+ - End on the strongest cliffhanger yet — reader hits paywall after this chapter
602
+ - They must feel "I CANNOT stop here" — this is the conversion chapter`,
603
+ };
604
+
605
+ const rules = isEnglish ? enRules : zhRules;
606
+ const header = isEnglish
607
+ ? `## Golden ${goldenLimit} Chapters — Chapter ${chapterNumber}
608
+
609
+ The opening ${goldenLimit} chapters determine whether readers stay or leave. Before the paywall (ch6-8), every chapter must hook harder than the last.
610
+
611
+ - Start from an explosion, not the first brick
612
+ - No info-dumps: worldbuilding reveals through action
613
+ - Each chapter: 1 storyline; **ch1-ch2 keep named characters in conflict ≤ 2** (protagonist + one), ch3+ relax to ≤ 3
614
+ - Lead with strong emotion: injustice, danger, mystery, desire`
615
+ : `## 黄金${goldenLimit}章特殊指令(当前第${chapterNumber}章)
616
+
617
+ 开篇${goldenLimit}章决定读者是否追读。遵循以下强制规则:
618
+
619
+ - 开篇不要从第一块砖头开始砌楼——从炸了一栋楼开始写
620
+ - 禁止信息轰炸:世界观、力量体系等设定随剧情自然揭示
621
+ - 每章聚焦 1 条故事线;**第 1-2 章有名有姓参与正面冲突的人物 ≤ 2 个(主角 + 1 个触发者/对手),第 3 章起可放宽到 ≤ 3 个**
622
+ - 强情绪优先:利用读者共情(亲情纽带、不公待遇、被低估)快速建立代入感`;
623
+
624
+ return `${header}
625
+
626
+ ${rules[chapterNumber] ?? ""}`;
627
+ }
628
+
629
+ // ---------------------------------------------------------------------------
630
+ // Full cast tracking (conditional)
631
+ // ---------------------------------------------------------------------------
632
+
633
+ function buildFullCastTracking(): string {
634
+ return `## 全员追踪
635
+
636
+ 本书启用全员追踪模式。每章结束时,POST_SETTLEMENT 必须额外包含:
637
+ - 本章出场角色清单(名字 + 一句话状态变化)
638
+ - 角色间关系变动(如有)
639
+ - 未出场但被提及的角色(名字 + 提及原因)`;
640
+ }
641
+
642
+ // ---------------------------------------------------------------------------
643
+ // Genre-specific rules
644
+ // ---------------------------------------------------------------------------
645
+
646
+ function buildGenreRules(gp: GenreProfile, genreBody: string): string {
647
+ const fatigueLine = gp.fatigueWords.length > 0
648
+ ? `- 高疲劳词(${gp.fatigueWords.join("、")})单章最多出现1次`
649
+ : "";
650
+
651
+ const chapterTypesLine = gp.chapterTypes.length > 0
652
+ ? `动笔前先判断本章类型:\n${gp.chapterTypes.map(t => `- ${t}`).join("\n")}`
653
+ : "";
654
+
655
+ const pacingLine = gp.pacingRule
656
+ ? `- 节奏规则:${gp.pacingRule}`
657
+ : "";
658
+
659
+ return [
660
+ `## 题材规范(${gp.name})`,
661
+ fatigueLine,
662
+ pacingLine,
663
+ chapterTypesLine,
664
+ genreBody,
665
+ ].filter(Boolean).join("\n\n");
666
+ }
667
+
668
+ // ---------------------------------------------------------------------------
669
+ // Protagonist rules from book_rules
670
+ // ---------------------------------------------------------------------------
671
+
672
+ function buildProtagonistRules(bookRules: BookRules | null): string {
673
+ if (!bookRules?.protagonist) return "";
674
+
675
+ const p = bookRules.protagonist;
676
+ const lines = [`## 主角铁律(${p.name})`];
677
+
678
+ if (p.personalityLock.length > 0) {
679
+ lines.push(`\n性格锁定:${p.personalityLock.join("、")}`);
680
+ }
681
+ if (p.behavioralConstraints.length > 0) {
682
+ lines.push("\n行为约束:");
683
+ for (const c of p.behavioralConstraints) {
684
+ lines.push(`- ${c}`);
685
+ }
686
+ }
687
+
688
+ if (bookRules.prohibitions.length > 0) {
689
+ lines.push("\n本书禁忌:");
690
+ for (const p of bookRules.prohibitions) {
691
+ lines.push(`- ${p}`);
692
+ }
693
+ }
694
+
695
+ if (bookRules.genreLock?.forbidden && bookRules.genreLock.forbidden.length > 0) {
696
+ lines.push(`\n风格禁区:禁止出现${bookRules.genreLock.forbidden.join("、")}`);
697
+ }
698
+
699
+ return lines.join("\n");
700
+ }
701
+
702
+ // ---------------------------------------------------------------------------
703
+ // Book rules body (user-written markdown)
704
+ // ---------------------------------------------------------------------------
705
+
706
+ function buildBookRulesBody(body: string): string {
707
+ if (!body) return "";
708
+ return `## 本书专属规则\n\n${body}`;
709
+ }
710
+
711
+ // ---------------------------------------------------------------------------
712
+ // Style guide
713
+ // ---------------------------------------------------------------------------
714
+
715
+ function buildStyleGuide(styleGuide: string): string {
716
+ if (!styleGuide || styleGuide === "(文件尚未创建)") return "";
717
+ return `## 文风指南\n\n${styleGuide}`;
718
+ }
719
+
720
+ // ---------------------------------------------------------------------------
721
+ // Style fingerprint (Phase 9: C3)
722
+ // ---------------------------------------------------------------------------
723
+
724
+ function buildStyleFingerprint(fingerprint?: string): string {
725
+ if (!fingerprint) return "";
726
+ return `## 文风指纹(模仿目标)
727
+
728
+ 以下是从参考文本中提取的写作风格特征。你的输出必须尽量贴合这些特征:
729
+
730
+ ${fingerprint}`;
731
+ }
732
+
733
+ // ---------------------------------------------------------------------------
734
+ // Pre-write checklist
735
+ // ---------------------------------------------------------------------------
736
+
737
+ function buildPreWriteChecklist(book: BookConfig, gp: GenreProfile): string {
738
+ let idx = 1;
739
+ const lines = [
740
+ "## 动笔前必须自问",
741
+ "",
742
+ `${idx++}. 【大纲锚定】本章对应卷纲中的哪个节点/阶段?本章必须推进该节点的剧情,不得跳过或提前消耗后续节点。如果卷纲指定了章节范围,严格遵守节奏。`,
743
+ `${idx++}. 主角此刻利益最大化的选择是什么?`,
744
+ `${idx++}. 这场冲突是谁先动手,为什么非做不可?`,
745
+ `${idx++}. 配角/反派是否有明确诉求、恐惧和反制?行为是否由"过往经历+当前利益+性格底色"驱动?`,
746
+ `${idx++}. 反派当前掌握了哪些已知信息?哪些信息只有读者知道?有无信息越界?`,
747
+ `${idx++}. 章尾是否留了钩子(悬念/伏笔/冲突升级)?`,
748
+ ];
749
+
750
+ if (gp.numericalSystem) {
751
+ lines.push(`${idx++}. 本章收益能否落到具体资源、数值增量、地位变化或已回收伏笔?`);
752
+ }
753
+
754
+ // 17雷点精华预防
755
+ lines.push(
756
+ `${idx++}. 【流水账检查】本章是否有无冲突的日常流水叙述?如有,加入前因后果或强情绪改造`,
757
+ `${idx++}. 【主线偏离检查】本章是否推进了主线目标?支线是否在2-3章内与核心目标关联?`,
758
+ `${idx++}. 【爽点节奏检查】最近3-5章内是否有小爽点落地?读者的"情绪缺口"是否在积累或释放?`,
759
+ `${idx++}. 【人设崩塌检查】角色行为是否与已建立的性格标签一致?有无无铺垫的突然转变?`,
760
+ `${idx++}. 【视角检查】本章视角是否清晰?同场景内说话人物是否控制在3人以内?`,
761
+ `${idx++}. 如果任何问题答不上来,先补逻辑链,再写正文`,
762
+ );
763
+
764
+ return lines.join("\n");
765
+ }
766
+
767
+ // ---------------------------------------------------------------------------
768
+ // Creative-only output format (no settlement blocks)
769
+ // ---------------------------------------------------------------------------
770
+
771
+ function buildCreativeOutputFormat(book: BookConfig, gp: GenreProfile, lengthSpec: LengthSpec): string {
772
+ const resourceRow = gp.numericalSystem
773
+ ? "| 当前资源总量 | X | 与账本一致 |\n| 本章预计增量 | +X(来源) | 无增量写+0 |"
774
+ : "";
775
+
776
+ const preWriteTable = `=== PRE_WRITE_CHECK ===
777
+ (必须输出Markdown表格,全部检查项对齐 chapter_memo 七段,而不是卷纲)
778
+ | 检查项 | 本章记录 | 备注 |
779
+ |--------|----------|------|
780
+ | 当前任务 | 复述 chapter_memo 的「当前任务」并写出本章执行动作 | 必须具体,不能抽象 |
781
+ | 读者在等什么 | 本章如何处理「读者此刻在等什么」—制造/延迟/兑现 | 与 memo 一致 |
782
+ | 该兑现的 / 暂不掀的 | 本章确认要兑现的伏笔 + 必须压住不掀的底牌 | 引用 memo 原文 |
783
+ | 日常/过渡承担任务 | 若有日常/过渡段落,说明各自承担的功能 | 对齐 memo 映射表 |
784
+ | 章尾必须发生的改变 | 列出 memo「章尾必须发生的改变」中 1-3 条具体改变 | 必须落地 |
785
+ | 不要做 | 复述 memo「不要做」清单 | 正文不得触碰 |
786
+ | 上下文范围 | 第X章至第Y章 / 状态卡 / 设定文件 | |
787
+ | 当前锚点 | 地点 / 对手 / 收益目标 | 锚点必须具体 |
788
+ ${resourceRow}| 待回收伏笔 | 用真实 hook_id 填写(无则写 none) | 与伏笔池一致 |
789
+ | 本章冲突 | 一句话概括 | |
790
+ | 章节类型 | ${gp.chapterTypes.join("/")} | |
791
+ | 风险扫描 | OOC/信息越界/设定冲突${gp.powerScaling ? "/战力崩坏" : ""}/节奏/词汇疲劳 | |`;
792
+
793
+ return `## 输出格式(严格遵守)
794
+
795
+ ${preWriteTable}
796
+
797
+ === CHAPTER_TITLE ===
798
+ (章节标题,不含"第X章"。标题必须与已有章节标题不同,不要重复使用相同或相似的标题;若提供了 recent title history 或高频标题词,必须主动避开重复词根和高频意象)
799
+
800
+ === CHAPTER_CONTENT ===
801
+ (正文内容,目标${lengthSpec.target}字,允许区间${lengthSpec.softMin}-${lengthSpec.softMax}字)
802
+
803
+ 【重要】本次只需输出以上三个区块(PRE_WRITE_CHECK、CHAPTER_TITLE、CHAPTER_CONTENT)。
804
+ 状态卡、伏笔池、摘要等追踪文件将由后续结算阶段处理,请勿输出。`;
805
+ }
806
+
807
+ // ---------------------------------------------------------------------------
808
+ // Output format
809
+ // ---------------------------------------------------------------------------
810
+
811
+ function buildOutputFormat(book: BookConfig, gp: GenreProfile, lengthSpec: LengthSpec): string {
812
+ const resourceRow = gp.numericalSystem
813
+ ? "| 当前资源总量 | X | 与账本一致 |\n| 本章预计增量 | +X(来源) | 无增量写+0 |"
814
+ : "";
815
+
816
+ const preWriteTable = `=== PRE_WRITE_CHECK ===
817
+ (必须输出Markdown表格,全部检查项对齐 chapter_memo 七段,而不是卷纲)
818
+ | 检查项 | 本章记录 | 备注 |
819
+ |--------|----------|------|
820
+ | 当前任务 | 复述 chapter_memo 的「当前任务」并写出本章执行动作 | 必须具体,不能抽象 |
821
+ | 读者在等什么 | 本章如何处理「读者此刻在等什么」—制造/延迟/兑现 | 与 memo 一致 |
822
+ | 该兑现的 / 暂不掀的 | 本章确认要兑现的伏笔 + 必须压住不掀的底牌 | 引用 memo 原文 |
823
+ | 日常/过渡承担任务 | 若有日常/过渡段落,说明各自承担的功能 | 对齐 memo 映射表 |
824
+ | 章尾必须发生的改变 | 列出 memo「章尾必须发生的改变」中 1-3 条具体改变 | 必须落地 |
825
+ | 不要做 | 复述 memo「不要做」清单 | 正文不得触碰 |
826
+ | 上下文范围 | 第X章至第Y章 / 状态卡 / 设定文件 | |
827
+ | 当前锚点 | 地点 / 对手 / 收益目标 | 锚点必须具体 |
828
+ ${resourceRow}| 待回收伏笔 | 用真实 hook_id 填写(无则写 none) | 与伏笔池一致 |
829
+ | 本章冲突 | 一句话概括 | |
830
+ | 章节类型 | ${gp.chapterTypes.join("/")} | |
831
+ | 风险扫描 | OOC/信息越界/设定冲突${gp.powerScaling ? "/战力崩坏" : ""}/节奏/词汇疲劳 | |`;
832
+
833
+ const postSettlement = gp.numericalSystem
834
+ ? `=== POST_SETTLEMENT ===
835
+ (如有数值变动,必须输出Markdown表格)
836
+ | 结算项 | 本章记录 | 备注 |
837
+ |--------|----------|------|
838
+ | 资源账本 | 期初X / 增量+Y / 期末Z | 无增量写+0 |
839
+ | 重要资源 | 资源名 -> 贡献+Y(依据) | 无写"无" |
840
+ | 伏笔变动 | 新增/回收/延后 Hook | 同步更新伏笔池 |`
841
+ : `=== POST_SETTLEMENT ===
842
+ (如有伏笔变动,必须输出)
843
+ | 结算项 | 本章记录 | 备注 |
844
+ |--------|----------|------|
845
+ | 伏笔变动 | 新增/回收/延后 Hook | 同步更新伏笔池 |`;
846
+
847
+ const updatedLedger = gp.numericalSystem
848
+ ? `\n=== UPDATED_LEDGER ===\n(更新后的完整资源账本,Markdown表格格式)`
849
+ : "";
850
+
851
+ return `## 输出格式(严格遵守)
852
+
853
+ ${preWriteTable}
854
+
855
+ === CHAPTER_TITLE ===
856
+ (章节标题,不含"第X章"。标题必须与已有章节标题不同,不要重复使用相同或相似的标题;若提供了 recent title history 或高频标题词,必须主动避开重复词根和高频意象)
857
+
858
+ === CHAPTER_CONTENT ===
859
+ (正文内容,目标${lengthSpec.target}字,允许区间${lengthSpec.softMin}-${lengthSpec.softMax}字)
860
+
861
+ ${postSettlement}
862
+
863
+ === UPDATED_STATE ===
864
+ (更新后的完整状态卡,Markdown表格格式)
865
+ ${updatedLedger}
866
+ === UPDATED_HOOKS ===
867
+ (更新后的完整伏笔池,Markdown表格格式)
868
+
869
+ === CHAPTER_SUMMARY ===
870
+ (本章摘要,Markdown表格格式,必须包含以下列)
871
+ | 章节 | 标题 | 出场人物 | 关键事件 | 状态变化 | 伏笔动态 | 情绪基调 | 章节类型 |
872
+ |------|------|----------|----------|----------|----------|----------|----------|
873
+ | N | 本章标题 | 角色1,角色2 | 一句话概括 | 关键变化 | H01埋设/H02推进 | 情绪走向 | ${gp.chapterTypes.length > 0 ? gp.chapterTypes.join("/") : "过渡/冲突/高潮/收束"} |
874
+
875
+ === UPDATED_SUBPLOTS ===
876
+ (更新后的完整支线进度板,Markdown表格格式)
877
+ | 支线ID | 支线名 | 相关角色 | 起始章 | 最近活跃章 | 距今章数 | 状态 | 进度概述 | 回收ETA |
878
+ |--------|--------|----------|--------|------------|----------|------|----------|---------|
879
+
880
+ === UPDATED_EMOTIONAL_ARCS ===
881
+ (更新后的完整情感弧线,Markdown表格格式)
882
+ | 角色 | 章节 | 情绪状态 | 触发事件 | 强度(1-10) | 弧线方向 |
883
+ |------|------|----------|----------|------------|----------|
884
+
885
+ === UPDATED_CHARACTER_MATRIX ===
886
+ (更新后的角色矩阵,每个角色一个 ## 块)
887
+
888
+ ## 角色名
889
+ - **定位**: 主角 / 反派 / 盟友 / 配角 / 提及
890
+ - **标签**: 核心身份标签
891
+ - **反差**: 打破刻板印象的独特细节
892
+ - **说话**: 说话风格概述
893
+ - **性格**: 性格底色
894
+ - **动机**: 根本驱动力
895
+ - **当前**: 本章即时目标
896
+ - **关系**: 某角色(关系性质/Ch#) | ...
897
+ - **已知**: 该角色已知的信息(仅限亲历或被告知)
898
+ - **未知**: 该角色不知道的信息`;
899
+ }