@waterwx/dsh-novel-forge 2.0.0-alpha.1 → 2.0.0

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 (206) hide show
  1. package/README.md +286 -285
  2. package/lib/client.js +19561 -19439
  3. package/lib/index.js +8159 -4456
  4. package/lib/types/action-guard.d.ts +61 -0
  5. package/lib/types/ai-scan.d.ts +0 -6
  6. package/lib/types/assets.d.ts +20 -9
  7. package/lib/types/assistant.d.ts +29 -0
  8. package/lib/types/author-assets.d.ts +1 -3
  9. package/lib/types/bookshelf.d.ts +13 -3
  10. package/lib/types/client/api.d.ts +136 -27
  11. package/lib/types/client/chip-prefs.d.ts +36 -0
  12. package/lib/types/client/docx.d.ts +2 -2
  13. package/lib/types/client/llmLive.d.ts +31 -0
  14. package/lib/types/client/locales.d.ts +15 -70
  15. package/lib/types/client/mount.d.ts +0 -2
  16. package/lib/types/client/panel/AiTag.d.ts +1 -0
  17. package/lib/types/client/panel/AssistantTab.d.ts +4 -1
  18. package/lib/types/client/panel/AuthorHome.d.ts +13 -11
  19. package/lib/types/client/panel/BookAnalysisView.d.ts +4 -0
  20. package/lib/types/client/panel/CmdPalette.d.ts +12 -0
  21. package/lib/types/client/panel/CreateBookView.d.ts +5 -1
  22. package/lib/types/client/panel/DirectorView.d.ts +7 -0
  23. package/lib/types/client/panel/IdeaInspirationView.d.ts +6 -0
  24. package/lib/types/client/panel/KnowledgeBaseView.d.ts +4 -0
  25. package/lib/types/client/panel/LiveFeedLog.d.ts +13 -0
  26. package/lib/types/client/panel/MarketRadarView.d.ts +5 -0
  27. package/lib/types/client/panel/ModelManager.d.ts +2 -2
  28. package/lib/types/client/panel/NovelPanel.d.ts +6 -1
  29. package/lib/types/client/panel/PageHeader.d.ts +18 -0
  30. package/lib/types/client/panel/PromptSlotsView.d.ts +11 -0
  31. package/lib/types/client/panel/SettingsView.d.ts +12 -9
  32. package/lib/types/client/panel/ShelfView.d.ts +10 -1
  33. package/lib/types/client/panel/SubPage.d.ts +27 -0
  34. package/lib/types/client/panel/TensionView.d.ts +18 -0
  35. package/lib/types/client/panel/TimelineView.d.ts +18 -0
  36. package/lib/types/client/panel/helpers.d.ts +5 -3
  37. package/lib/types/client/panel/market-radar-state.d.ts +56 -0
  38. package/lib/types/client/panel/toast.d.ts +2 -0
  39. package/lib/types/client/panel/views.d.ts +21 -35
  40. package/lib/types/client/run-status.d.ts +21 -0
  41. package/lib/types/client/sidebar-entry.d.ts +0 -2
  42. package/lib/types/docx-core.d.ts +16 -0
  43. package/lib/types/docx.d.ts +2 -3
  44. package/lib/types/engine.d.ts +78 -103
  45. package/lib/types/global-assets.d.ts +6 -0
  46. package/lib/types/home.d.ts +11 -0
  47. package/lib/types/index.d.ts +26 -12
  48. package/lib/types/llm-live.d.ts +70 -0
  49. package/lib/types/llm-retry.d.ts +38 -0
  50. package/lib/types/market-radar-scan.d.ts +18 -0
  51. package/lib/types/market-radar-sources.d.ts +31 -0
  52. package/lib/types/migrate-output.d.ts +25 -0
  53. package/lib/types/model-capability.d.ts +93 -0
  54. package/lib/types/output-budget.d.ts +86 -0
  55. package/lib/types/prompt-slots.d.ts +57 -0
  56. package/lib/types/prompting.d.ts +10 -0
  57. package/lib/types/protocol.d.ts +816 -601
  58. package/lib/types/revision.d.ts +76 -0
  59. package/lib/types/routes.d.ts +9 -3
  60. package/lib/types/run.d.ts +23 -1
  61. package/lib/types/settings-persist.d.ts +59 -0
  62. package/lib/types/snapshots.d.ts +46 -0
  63. package/lib/types/stage-contract.d.ts +58 -0
  64. package/lib/types/tension.d.ts +53 -0
  65. package/lib/types/timeline.d.ts +37 -0
  66. package/package.json +50 -25
  67. package/src/action-guard.ts +127 -0
  68. package/src/ai-scan.ts +0 -24
  69. package/src/assets.ts +1801 -879
  70. package/src/assistant.ts +1098 -770
  71. package/src/author-assets.ts +131 -147
  72. package/src/bookshelf.ts +193 -167
  73. package/src/client/api.ts +767 -617
  74. package/src/client/chip-prefs.ts +121 -0
  75. package/src/client/docx.ts +32 -69
  76. package/src/client/index.ts +2 -0
  77. package/src/client/llmLive.ts +111 -0
  78. package/src/client/locales.ts +15 -274
  79. package/src/client/mount.tsx +3 -2
  80. package/src/client/panel/AdaptModeView.tsx +535 -520
  81. package/src/client/panel/AiTag.tsx +7 -0
  82. package/src/client/panel/AssetsTab.tsx +448 -458
  83. package/src/client/panel/AssistantTab.tsx +355 -301
  84. package/src/client/panel/AuthorAssetsView.tsx +205 -207
  85. package/src/client/panel/AuthorHome.tsx +309 -204
  86. package/src/client/panel/BookAnalysisView.tsx +63 -0
  87. package/src/client/panel/CmdPalette.tsx +102 -0
  88. package/src/client/panel/CreateBookView.tsx +366 -352
  89. package/src/client/panel/DirectorView.tsx +200 -0
  90. package/src/client/panel/GlobalAssetLibraryView.tsx +168 -172
  91. package/src/client/panel/IdeaInspirationView.tsx +76 -0
  92. package/src/client/panel/ImportModal.tsx +302 -302
  93. package/src/client/panel/KnowledgeBaseView.tsx +125 -0
  94. package/src/client/panel/LiveFeedLog.tsx +204 -0
  95. package/src/client/panel/MarketRadarView.tsx +415 -0
  96. package/src/client/panel/ModelManager.tsx +205 -205
  97. package/src/client/panel/NovelPanel.tsx +3144 -2205
  98. package/src/client/panel/PageHeader.tsx +37 -0
  99. package/src/client/panel/ProgressConsole.tsx +63 -64
  100. package/src/client/panel/PromptSlotsView.tsx +97 -0
  101. package/src/client/panel/ReaderView.tsx +306 -306
  102. package/src/client/panel/RunPanel.tsx +56 -24
  103. package/src/client/panel/SettingsView.tsx +175 -106
  104. package/src/client/panel/ShelfView.tsx +63 -39
  105. package/src/client/panel/SubPage.tsx +42 -0
  106. package/src/client/panel/TensionView.tsx +212 -0
  107. package/src/client/panel/TimelineView.tsx +208 -0
  108. package/src/client/panel/WorldTab.tsx +202 -202
  109. package/src/client/panel/helpers.ts +7 -5
  110. package/src/client/panel/market-radar-state.ts +79 -0
  111. package/src/client/panel/panel.module.css +5767 -4360
  112. package/src/client/panel/toast.ts +51 -0
  113. package/src/client/panel/views.tsx +316 -314
  114. package/src/client/run-status.ts +171 -0
  115. package/src/client/sidebar-entry.ts +3 -3
  116. package/src/docx-core.ts +53 -0
  117. package/src/docx.ts +44 -83
  118. package/src/engine.ts +1197 -1638
  119. package/src/global-assets.ts +58 -0
  120. package/src/home.ts +33 -0
  121. package/src/index.ts +181 -101
  122. package/src/llm-live.ts +245 -0
  123. package/src/llm-retry.ts +77 -0
  124. package/src/market-radar-scan.ts +35 -0
  125. package/src/market-radar-sources.ts +173 -0
  126. package/src/migrate-output.ts +76 -0
  127. package/src/model-capability.ts +215 -0
  128. package/src/novel-context.ts +286 -287
  129. package/src/output-budget.ts +147 -0
  130. package/src/prompt-slots.ts +125 -0
  131. package/src/prompting.ts +26 -0
  132. package/src/protocol.ts +835 -614
  133. package/src/revision.ts +283 -0
  134. package/src/routes.ts +1286 -910
  135. package/src/run.ts +113 -17
  136. package/src/settings-persist.ts +114 -0
  137. package/src/snapshots.ts +174 -0
  138. package/src/stage-contract.ts +186 -0
  139. package/src/tension.ts +251 -0
  140. package/src/timeline.ts +159 -0
  141. package/assets/styles/arcane-thick-3d.webp +0 -0
  142. package/assets/styles/chinese-ink.webp +0 -0
  143. package/assets/styles/clay-stopmotion-3d.webp +0 -0
  144. package/assets/styles/dark-ghibli.webp +0 -0
  145. package/assets/styles/dark-gothic-3d.webp +0 -0
  146. package/assets/styles/film-photo.webp +0 -0
  147. package/assets/styles/guofeng-heavy.webp +0 -0
  148. package/assets/styles/guoman-2d-gufeng.webp +0 -0
  149. package/assets/styles/guoman-3d-tianyuan.webp +0 -0
  150. package/assets/styles/guoman-3d-xuanhuan.webp +0 -0
  151. package/assets/styles/horror-game-3d.webp +0 -0
  152. package/assets/styles/hyperreal-3d.webp +0 -0
  153. package/assets/styles/japan-cel-dark.webp +0 -0
  154. package/assets/styles/korean-webtoon.webp +0 -0
  155. package/assets/styles/low-cyberpunk-3d.webp +0 -0
  156. package/assets/styles/nextgen-cg.webp +0 -0
  157. package/assets/styles/noir-film.webp +0 -0
  158. package/assets/styles/openworld-survival.webp +0 -0
  159. package/assets/styles/paper-cut-3d.webp +0 -0
  160. package/assets/styles/pixar-adult-3d.webp +0 -0
  161. package/assets/styles/pop-marvel-2d.webp +0 -0
  162. package/assets/styles/sandiao-qban.webp +0 -0
  163. package/assets/styles/shinkai-anime.webp +0 -0
  164. package/assets/styles/tactical-stealth.webp +0 -0
  165. package/assets/styles/urban-lightreal-3d.webp +0 -0
  166. package/assets/styles/vaporwave-3d.webp +0 -0
  167. package/assets/styles/vhs90.webp +0 -0
  168. package/lib/types/client/panel/BookshelfBar.d.ts +0 -11
  169. package/lib/types/client/panel/FlowGuide.d.ts +0 -22
  170. package/lib/types/client/panel/MangaRoleLibrary.d.ts +0 -20
  171. package/lib/types/client/panel/MangaWorkspace.d.ts +0 -12
  172. package/lib/types/client/panel/ModelPicker.d.ts +0 -11
  173. package/lib/types/client/panel/ProgressHomeView.d.ts +0 -5
  174. package/lib/types/client/panel/PropLibrary.d.ts +0 -8
  175. package/lib/types/client/panel/SceneLibrary.d.ts +0 -16
  176. package/lib/types/client/panel/StoryboardTab.d.ts +0 -19
  177. package/lib/types/client/panel/StyleCard.d.ts +0 -8
  178. package/lib/types/client/panel/StyleGallery.d.ts +0 -1
  179. package/lib/types/comic-presets.d.ts +0 -12
  180. package/lib/types/manga-genre-rules.d.ts +0 -22
  181. package/lib/types/prompt-utils.d.ts +0 -35
  182. package/lib/types/review-policy.d.ts +0 -97
  183. package/lib/types/shot-language.d.ts +0 -46
  184. package/lib/types/story-beat-language.d.ts +0 -35
  185. package/lib/types/style-library.d.ts +0 -33
  186. package/skills/chapter-batch/SKILL.md +0 -81
  187. package/src/client/mount.tsx._new +0 -97
  188. package/src/client/mount.tsx._nf +0 -97
  189. package/src/client/mount.tsx._tmp +0 -97
  190. package/src/client/panel/BookshelfBar.tsx +0 -170
  191. package/src/client/panel/FlowGuide.tsx +0 -84
  192. package/src/client/panel/MangaRoleLibrary.tsx +0 -1002
  193. package/src/client/panel/MangaWorkspace.tsx +0 -715
  194. package/src/client/panel/ProgressHomeView.tsx +0 -87
  195. package/src/client/panel/PropLibrary.tsx +0 -175
  196. package/src/client/panel/SceneLibrary.tsx +0 -453
  197. package/src/client/panel/StoryboardTab.tsx +0 -472
  198. package/src/client/panel/StyleCard.tsx +0 -90
  199. package/src/client/panel/StyleGallery.tsx +0 -58
  200. package/src/comic-presets.ts +0 -67
  201. package/src/manga-genre-rules.ts +0 -87
  202. package/src/prompt-utils.ts +0 -73
  203. package/src/review-policy.ts +0 -161
  204. package/src/shot-language.ts +0 -181
  205. package/src/story-beat-language.ts +0 -130
  206. package/src/style-library.ts +0 -84
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 热门题材雷达:真实榜单扫榜(聚合各平台榜单源,容错)。
3
+ */
4
+ import { type CollectedRankingItem, type MarketRadarPlatform } from './market-radar-sources.ts';
5
+ export interface MarketRadarGroup {
6
+ platform: MarketRadarPlatform;
7
+ platformLabel: string;
8
+ listKey: string;
9
+ listLabel: string;
10
+ status: 'ok' | 'error';
11
+ error?: string;
12
+ items: CollectedRankingItem[];
13
+ }
14
+ export interface MarketScanResult {
15
+ scannedAt: string;
16
+ groups: MarketRadarGroup[];
17
+ }
18
+ export declare function scanMarketRanking(platforms?: string[]): Promise<MarketScanResult>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 「热门题材雷达」真实榜单抓取源(公开榜单页面的地址与选择器,属事实性配置)。
3
+ * 用全局 fetch 抓取公开榜单移动版页面,正则抽取元数据;无第三方依赖。
4
+ */
5
+ export type MarketRadarPlatform = 'fanqie' | 'qidian' | 'jinjiang';
6
+ export interface MarketRadarListSource {
7
+ platform: MarketRadarPlatform;
8
+ platformLabel: string;
9
+ listKey: string;
10
+ listLabel: string;
11
+ channel: string;
12
+ sourceUrl: string;
13
+ }
14
+ export interface CollectedRankingItem {
15
+ rank: number;
16
+ title: string;
17
+ author?: string;
18
+ category?: string;
19
+ tags: string[];
20
+ synopsis?: string;
21
+ heatLabel?: string;
22
+ serialStatus?: string;
23
+ sourceUrl: string;
24
+ }
25
+ export declare const MARKET_RADAR_SOURCES: MarketRadarListSource[];
26
+ export declare function hasPrivateUseCharacters(value: string | null | undefined): boolean;
27
+ export declare function parseFanqieRanking(html: string, source: MarketRadarListSource): CollectedRankingItem[];
28
+ export declare function parseFanqieDetail(html: string, item: CollectedRankingItem): CollectedRankingItem;
29
+ export declare function parseQidianRanking(html: string, source: MarketRadarListSource): CollectedRankingItem[];
30
+ export declare function parseJinjiangRanking(html: string, source: MarketRadarListSource): CollectedRankingItem[];
31
+ export declare function collectMarketSource(source: MarketRadarListSource): Promise<CollectedRankingItem[]>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 输出目录迁移(Migrate Output Dir)— 把一本书/默认输出目录的内容搬到新位置。
3
+ *
4
+ * 安全纪律(数据零丢失排序):
5
+ * 1. copy 全部内容到新目录(源目录始终原样保留);
6
+ * 2. 调用方完成配置写入 / 书架重指向后,最后一步才删源目录;
7
+ * 3. 中途任何失败,最坏情况只是新目录多一份副本,源数据零丢失。
8
+ */
9
+ /** 目录内容清单(相对路径 + 总字节)。 */
10
+ export interface DirContents {
11
+ files: string[];
12
+ bytes: number;
13
+ }
14
+ /** 规范化路径用于比较(统一分隔符,Windows 忽略大小写)。 */
15
+ export declare function normalizeDir(dir: string): string;
16
+ /** 列出目录全部内容(递归;子目录以 `name/` 形式占位列出)。 */
17
+ export declare function listDirContents(dir: string): DirContents;
18
+ /**
19
+ * 把 from 全部内容复制到 to(源目录保留,删除由调用方在收尾执行)。
20
+ * 目标必须不存在或为空目录(防覆盖无关数据);禁止互相嵌套的目录对。
21
+ * @returns 复制的顶层条目数。
22
+ */
23
+ export declare function copyDirContents(from: string, to: string): number;
24
+ /** 删除源目录(仅复制 + 配置/书架重指向全部成功后调用)。 */
25
+ export declare function removeDir(dir: string): void;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * 模型参数能力兼容层。
3
+ *
4
+ * 设计原则:**界面上保存的温度/思考档位是用户偏好,不是最终请求值。** 构造请求前
5
+ * 必须经过本层收敛到厂商允许的范围 —— 否则换模型、走自定义中转、或厂商改了约束,
6
+ * 就会出现「换个 provider 就报参数错误」这类故障。
7
+ *
8
+ * 两条硬要求:
9
+ * 1. **按模型身份判断,不按 provider 判断**。同一个模型经由自定义中转调用时,
10
+ * provider 名可能完全自定义,但参数约束属于模型本身;把判断写成
11
+ * `provider === '某个厂商' && ...` 会让走中转的调用绕过约束。
12
+ * 2. **约束要有出处**。每条规则的来源写在规则上,不靠猜。下列规则来自厂商官方
13
+ * 《模型参数参考》(https://platform.kimi.com/docs/api/models-overview.md):
14
+ * · kimi-k3 : temperature 固定 1.0;支持顶层 reasoning_effort
15
+ * · kimi-k2.7-code : temperature 固定 1.0;不支持 reasoning_effort(用 thinking,且不可禁用)
16
+ * · kimi-k2.6 : thinking 固定 1.0 / 非 thinking 固定 0.6;不支持 reasoning_effort
17
+ * 官方同时建议:这类模型**不要显式传入 temperature**。本层因此优先「不传」,
18
+ * 仅在调用方无法省略该参数时才钳到允许值。
19
+ */
20
+ /** 一次请求的参数约束。 */
21
+ export interface ModelCapability {
22
+ /** 该模型只接受这一个温度值(如 Kimi 全系),缺省表示不约束。 */
23
+ fixedTemperature?: number;
24
+ /** 温度允许的下界(默认 0)。 */
25
+ minTemperature?: number;
26
+ /** 温度允许的上界(默认 2,主流 OpenAI 兼容区间)。 */
27
+ maxTemperature?: number;
28
+ /**
29
+ * 是否支持 OpenAI 兼容的 `reasoning_effort`。
30
+ * false 表示**不得下发**该参数(如 Kimi K2.x 用的是 `thinking`),下发会被厂商拒绝。
31
+ */
32
+ supportsReasoning?: boolean;
33
+ /**
34
+ * 推理控制方式:`reasoning_effort`(OpenAI 兼容顶层参数)或 `thinking`(Kimi K2.x 专属)。
35
+ * 运行时若适配层支持,应按此选择参数名;仅为诊断与后续适配保留。
36
+ */
37
+ reasoningControl?: 'reasoning-effort' | 'thinking' | 'none';
38
+ /** 严格结构化输出必须关闭思考(覆盖用户偏好)。 */
39
+ reasoningForcedOff?: boolean;
40
+ /** 命中的规则名,用于日志与测试断言。 */
41
+ rule: string;
42
+ /** 约束出处(文档 URL 或说明),便于复核与更新。 */
43
+ source: string;
44
+ }
45
+ /**
46
+ * 把模型 id 归一化为「模型身份」。
47
+ *
48
+ * 处理:去空白与首尾斜杠、小写、剥掉供应商前缀(`kimi/kimi-k3` → `kimi-k3`)。
49
+ * @param model - 原始模型 id。
50
+ * @returns 归一化后的身份(小写、无前缀)。
51
+ */
52
+ export declare function canonicalModelId(model: string | undefined): string;
53
+ /**
54
+ * 解析一条模型的能力约束。
55
+ * @param model - 模型 id(可能带供应商前缀)。
56
+ * @returns 命中的能力;无约束时返回 undefined。
57
+ */
58
+ export declare function resolveModelCapability(model: string | undefined): ModelCapability | undefined;
59
+ /** 一次待收敛的请求参数。 */
60
+ export interface RequestParams {
61
+ temperature: number;
62
+ /** 请求方(含用户偏好)希望使用的思考档位;undefined 表示不涉及。 */
63
+ reasoningEffort?: 'off' | 'low' | 'high' | 'max';
64
+ }
65
+ /** 收敛结果:最终请求值 + 发生了哪些调整(便于日志与诊断)。 */
66
+ export interface ConvergedParams {
67
+ /**
68
+ * 最终要下发的温度;`undefined` 表示**应当省略该参数**。
69
+ * 厂商建议这类模型不要显式传 temperature 时,本层返回 undefined。
70
+ */
71
+ temperature: number | undefined;
72
+ reasoningEffort?: 'off' | 'low' | 'high' | 'max';
73
+ /** 被本层改掉的项,形如 `temperature: 0.3 -> 省略`。 */
74
+ adjustments: string[];
75
+ /** 命中的规则名。 */
76
+ rule?: string;
77
+ /** 约束出处。 */
78
+ source?: string;
79
+ }
80
+ /**
81
+ * 把请求参数收敛到模型允许的范围。
82
+ *
83
+ * @param params - 调用方希望使用的参数。
84
+ * @param model - 实际要调用的模型 id(应传**实际模型**;换备用模型后需重算)。
85
+ * @param options - `structured: true` 表示这是严格结构化输出任务;
86
+ * `omitFixedTemperature: true` 表示调用方可以不传温度(推荐,厂商建议如此),
87
+ * 此时固定温度会收敛为 undefined 而不是钳到固定值。
88
+ * @returns 最终请求值与被调整项。
89
+ */
90
+ export declare function convergeRequestParams(params: RequestParams, model: string | undefined, options?: {
91
+ structured?: boolean;
92
+ omitFixedTemperature?: boolean;
93
+ }): ConvergedParams;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * 结构化输出预算与字段长度合同。
3
+ *
4
+ * 背景:本插件此前给每个 LLM 调用写死一个 `Math.max(config.maxTokens, N)`。短任务
5
+ * 与长任务拿到同一个额度,长任务(分卷、拆章、逐章规划)**额度不随规模增长**,
6
+ * 截断后只能抛「请增大 maxTokens」。这里把额度改成按规模推算,并给结构化字段
7
+ * 定长度上限,让预算花在结构上而不是被自由发挥吃光。
8
+ *
9
+ * 设计取舍:结构化输出的额度应当**随本次要产出的条目数增长**,并由硬上限兜住,
10
+ * 否则要么短任务浪费额度,要么长任务写到一半被截断。字段长度上限同时写进提示词
11
+ * 与解析端,两处共用一张表,避免漂移。
12
+ *
13
+ * 一条硬纪律:**不要用 JSON repair 去补被截断的结构**。repair 只能修已有结构,
14
+ * 补不出尚未输出的条目;在服务层手工补齐缺失项,等于把不完整的规划伪装成可用
15
+ * 资产。预算给够 + 输出够紧凑,才是正解。
16
+ */
17
+ /** 一次调用的输出规模描述:给出能决定输出体量的那个量。 */
18
+ export interface OutputScope {
19
+ /** 预期卷数(分卷/卷战略类)。 */
20
+ volumes?: number;
21
+ /** 预期章节数(章节列表/批量拆章类)。 */
22
+ chapters?: number;
23
+ /** 预期角色数(角色阵容/资产提炼类)。 */
24
+ characters?: number;
25
+ /** 预期条目数(伏笔、题材、资产等清单类)。 */
26
+ items?: number;
27
+ /** 需要覆盖的正文规模(字),用于拆书/反推这类按输入体量走的任务。 */
28
+ sourceChars?: number;
29
+ }
30
+ /** 一类结构化任务的预算规格。 */
31
+ export interface OutputBudgetSpec {
32
+ /** 无视规模也要给到的下限。 */
33
+ floor: number;
34
+ /** 规模为 0 时的起步额度。 */
35
+ base: number;
36
+ /** 每单位规模追加的额度。 */
37
+ perUnit: number;
38
+ /** 硬上限:超过它只会让模型啰嗦,不会让结构更完整。 */
39
+ ceiling: number;
40
+ }
41
+ /** 结构化任务分组——按"输出里每个单位要写多少字段"分档,而不是按业务名。 */
42
+ export type OutputBudgetKind = 'volume-strategy' | 'chapter-list' | 'character-cast' | 'item-list' | 'analysis';
43
+ /**
44
+ * 取出与任务类型相关的那一个规模量。
45
+ * @param kind - 任务类型。
46
+ * @param scope - 规模描述。
47
+ * @returns 单位数;分析类返回千字单位(向上取整)。
48
+ */
49
+ export declare function scopeUnits(kind: OutputBudgetKind, scope: OutputScope): number;
50
+ /**
51
+ * 按规模推算输出额度。
52
+ * @param kind - 结构化任务类型。
53
+ * @param scope - 本次任务的规模(缺省时按最小规模处理)。
54
+ * @returns 建议的 `maxTokens`,落在该类型的 [floor, ceiling] 内。
55
+ */
56
+ export declare function resolveOutputBudget(kind: OutputBudgetKind, scope?: OutputScope): number;
57
+ /** 读取某类任务的规格(供诊断与测试断言)。 */
58
+ export declare function outputBudgetSpec(kind: OutputBudgetKind): OutputBudgetSpec;
59
+ /**
60
+ * 结构化字段长度合同 —— 与 prompt 里的长度声明必须逐项一致。
61
+ *
62
+ * 两边同步的理由:只写进 schema,模型不知道就会超长被拒;只写进 prompt,模型
63
+ * 偶尔超长没人拦。本表是单一数据源。
64
+ */
65
+ export declare const STRUCTURED_FIELD_LIMITS: {
66
+ /** 分卷战略:书级阶梯类字段。 */
67
+ readonly volumeLadder: 160;
68
+ /** 分卷战略:每卷定位标签。 */
69
+ readonly volumeRoleLabel: 32;
70
+ /** 分卷战略:每卷核心回报 / 升级焦点。 */
71
+ readonly volumeReward: 64;
72
+ /** 分卷战略:不确定项原因。 */
73
+ readonly volumeUncertaintyReason: 64;
74
+ /** 章节计划:单章标题。 */
75
+ readonly chapterTitle: 40;
76
+ /** 章节计划:单章摘要。 */
77
+ readonly chapterSummary: 300;
78
+ /** 章节计划:本章目标。 */
79
+ readonly chapterGoal: 200;
80
+ };
81
+ /**
82
+ * 把长度合同渲染成可直接塞进 system prompt 的一句话,避免 prompt 与表漂移。
83
+ * @param entries - 要声明的字段(描述 + 上限),按声明顺序渲染。
84
+ * @returns 形如「为保证输出完整:A 不超过 160 字;B 不超过 64 字。」的中文说明。
85
+ */
86
+ export declare function renderLengthContract(entries: ReadonlyArray<readonly [string, number]>): string;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * 提示词槽位:给作者留几个**安全可改**的位置,用来微调本书的写作偏好。
3
+ *
4
+ * 设计边界(很重要):
5
+ * * 槽位只追加"作者偏好",**不允许覆盖**规则工程与合规红线——道藏、写作红线、
6
+ * 九条内容合规红线、反 AI 规则、阶段契约都由宿主锁定,槽位碰不到;
7
+ * * 槽位内容随项目保存(`novel-project.json`),换书即换槽位;
8
+ * * 每个槽位有长度上限,超长直接截断并标记(沿用「截断显式化」的规则)。
9
+ */
10
+ import type { ProjectState, PromptSlotId } from './protocol.ts';
11
+ /** 单个槽位的元信息。 */
12
+ export interface PromptSlotSpec {
13
+ id: PromptSlotId;
14
+ /** 面板显示名。 */
15
+ label: string;
16
+ /** 一句话说明它影响什么。 */
17
+ hint: string;
18
+ /** 示例(面板占位符)。 */
19
+ placeholder: string;
20
+ /** 字符上限。 */
21
+ maxChars: number;
22
+ }
23
+ /** 允许作者编辑的槽位(白名单;不在此列表的提示词一律不可改)。 */
24
+ export declare const PROMPT_SLOTS: readonly PromptSlotSpec[];
25
+ /** 单个槽位的渲染结果。 */
26
+ export interface RenderedSlot {
27
+ id: PromptSlotId;
28
+ label: string;
29
+ text: string;
30
+ /** 是否因超长被截断。 */
31
+ truncated: boolean;
32
+ /** 原文长度(截断前)。 */
33
+ chars: number;
34
+ }
35
+ /**
36
+ * 读取并规整项目里的槽位内容(去空白、按上限截断)。
37
+ *
38
+ * @param project 项目状态。
39
+ * @returns 非空槽位列表(保持 PROMPT_SLOTS 的声明顺序)。
40
+ */
41
+ export declare function readPromptSlots(project: ProjectState): RenderedSlot[];
42
+ /**
43
+ * 把槽位渲染成注入提示词的段落。
44
+ *
45
+ * @param project 项目状态。
46
+ * @returns 提示词片段;无槽位时返回空串。
47
+ */
48
+ export declare function renderPromptSlots(project: ProjectState): string;
49
+ /**
50
+ * 校验并规整一次槽位写入。
51
+ *
52
+ * @param id 槽位 id。
53
+ * @param value 内容(空串表示清空该槽位)。
54
+ * @returns 归一化后的内容。
55
+ * @throws 槽位 id 不在白名单时抛错。
56
+ */
57
+ export declare function normalizeSlotValue(id: string, value: string): string;
@@ -0,0 +1,10 @@
1
+ /** 章节写作约束:把写作骨架渲染成可附加到系统提示词末尾的必达/禁止/自查块。 */
2
+ export declare function renderChapterWriterSkeleton(meta: {
3
+ targetChars: number;
4
+ minChars: number;
5
+ maxChars: number;
6
+ pov?: string;
7
+ tonePreference?: string;
8
+ endingHookPreference?: string;
9
+ antiAiRules?: string;
10
+ }): string;