@waterwx/dsh-novel-forge 1.2.0 → 1.2.1-alpha

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 (125) hide show
  1. package/README.md +237 -349
  2. package/lib/client.js +54447 -10560
  3. package/lib/index.js +12008 -5071
  4. package/lib/types/action-guard.d.ts +61 -0
  5. package/lib/types/ai-scan.d.ts +36 -0
  6. package/lib/types/assets.d.ts +18 -3
  7. package/lib/types/assistant.d.ts +29 -0
  8. package/lib/types/author-assets.d.ts +25 -0
  9. package/lib/types/bookshelf.d.ts +11 -1
  10. package/lib/types/client/api.d.ts +147 -9
  11. package/lib/types/client/docx.d.ts +2 -0
  12. package/lib/types/client/index.d.ts +1 -1
  13. package/lib/types/client/llmLive.d.ts +33 -0
  14. package/lib/types/client/locales.d.ts +28 -11
  15. package/lib/types/client/panel/AdaptModeView.d.ts +5 -0
  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/AuthorAssetsView.d.ts +4 -0
  19. package/lib/types/client/panel/AuthorHome.d.ts +34 -0
  20. package/lib/types/client/panel/BookAnalysisView.d.ts +4 -0
  21. package/lib/types/client/panel/CmdPalette.d.ts +12 -0
  22. package/lib/types/client/panel/CreateBookView.d.ts +5 -1
  23. package/lib/types/client/panel/DirectorView.d.ts +7 -0
  24. package/lib/types/client/panel/GlobalAssetLibraryView.d.ts +4 -0
  25. package/lib/types/client/panel/IdeaInspirationView.d.ts +6 -0
  26. package/lib/types/client/panel/ImportModal.d.ts +7 -0
  27. package/lib/types/client/panel/KnowledgeBaseView.d.ts +4 -0
  28. package/lib/types/client/panel/LiveFeedLog.d.ts +8 -0
  29. package/lib/types/client/panel/MarketRadarView.d.ts +5 -0
  30. package/lib/types/client/panel/ModelManager.d.ts +14 -0
  31. package/lib/types/client/panel/NovelPanel.d.ts +6 -1
  32. package/lib/types/client/panel/PageHeader.d.ts +18 -0
  33. package/lib/types/client/panel/ProgressConsole.d.ts +17 -0
  34. package/lib/types/client/panel/ProgressHomeView.d.ts +5 -0
  35. package/lib/types/client/panel/ReasoningSection.d.ts +10 -0
  36. package/lib/types/client/panel/SettingsView.d.ts +19 -0
  37. package/lib/types/client/panel/ShelfView.d.ts +12 -1
  38. package/lib/types/client/panel/SubPage.d.ts +27 -0
  39. package/lib/types/client/panel/toast.d.ts +2 -0
  40. package/lib/types/client/panel/views.d.ts +25 -7
  41. package/lib/types/client/run-status.d.ts +19 -0
  42. package/lib/types/client/text.d.ts +9 -0
  43. package/lib/types/docx-core.d.ts +16 -0
  44. package/lib/types/docx.d.ts +2 -3
  45. package/lib/types/engine.d.ts +146 -40
  46. package/lib/types/global-assets.d.ts +6 -0
  47. package/lib/types/index.d.ts +18 -2
  48. package/lib/types/llm-live.d.ts +44 -0
  49. package/lib/types/market-radar-scan.d.ts +19 -0
  50. package/lib/types/market-radar-sources.d.ts +31 -0
  51. package/lib/types/migrate-output.d.ts +25 -0
  52. package/lib/types/novel-context.d.ts +80 -0
  53. package/lib/types/prompt-utils.d.ts +35 -0
  54. package/lib/types/prompting.d.ts +10 -0
  55. package/lib/types/protocol.d.ts +1029 -123
  56. package/lib/types/review-policy.d.ts +97 -0
  57. package/lib/types/routes.d.ts +4 -0
  58. package/lib/types/run.d.ts +3 -1
  59. package/lib/types/stage-contract.d.ts +60 -0
  60. package/package.json +51 -27
  61. package/scripts/patch-schemastery.mjs +47 -0
  62. package/src/action-guard.ts +127 -0
  63. package/src/ai-scan.ts +179 -0
  64. package/src/assets.ts +1774 -520
  65. package/src/assistant.ts +1082 -770
  66. package/src/author-assets.ts +149 -0
  67. package/src/bookshelf.ts +187 -151
  68. package/src/client/api.ts +684 -410
  69. package/src/client/docx.ts +37 -69
  70. package/src/client/index.ts +3 -1
  71. package/src/client/llmLive.ts +101 -0
  72. package/src/client/locales.ts +418 -383
  73. package/src/client/mount.tsx +1 -1
  74. package/src/client/panel/AdaptModeView.tsx +535 -0
  75. package/src/client/panel/AiTag.tsx +7 -0
  76. package/src/client/panel/AssetsTab.tsx +448 -458
  77. package/src/client/panel/AssistantTab.tsx +355 -301
  78. package/src/client/panel/AuthorAssetsView.tsx +206 -0
  79. package/src/client/panel/AuthorHome.tsx +309 -0
  80. package/src/client/panel/BookAnalysisView.tsx +63 -0
  81. package/src/client/panel/CmdPalette.tsx +102 -0
  82. package/src/client/panel/CreateBookView.tsx +366 -348
  83. package/src/client/panel/DirectorView.tsx +200 -0
  84. package/src/client/panel/GlobalAssetLibraryView.tsx +168 -0
  85. package/src/client/panel/IdeaInspirationView.tsx +76 -0
  86. package/src/client/panel/ImportModal.tsx +303 -0
  87. package/src/client/panel/KnowledgeBaseView.tsx +125 -0
  88. package/src/client/panel/LiveFeedLog.tsx +67 -0
  89. package/src/client/panel/MarketRadarView.tsx +377 -0
  90. package/src/client/panel/ModelManager.tsx +205 -0
  91. package/src/client/panel/NovelPanel.tsx +5403 -4597
  92. package/src/client/panel/PageHeader.tsx +37 -0
  93. package/src/client/panel/ProgressConsole.tsx +63 -0
  94. package/src/client/panel/ReaderView.tsx +306 -306
  95. package/src/client/panel/ReasoningSection.tsx +31 -0
  96. package/src/client/panel/RunPanel.tsx +223 -204
  97. package/src/client/panel/SettingsView.tsx +305 -0
  98. package/src/client/panel/ShelfView.tsx +266 -236
  99. package/src/client/panel/SubPage.tsx +42 -0
  100. package/src/client/panel/WorldTab.tsx +202 -202
  101. package/src/client/panel/panel.module.css +5764 -2941
  102. package/src/client/panel/toast.ts +51 -0
  103. package/src/client/panel/views.tsx +401 -314
  104. package/src/client/run-status.ts +143 -0
  105. package/src/client/sidebar-entry.ts +1 -1
  106. package/src/client/text.ts +28 -0
  107. package/src/docx-core.ts +53 -0
  108. package/src/docx.ts +44 -83
  109. package/src/engine.ts +4231 -2787
  110. package/src/global-assets.ts +59 -0
  111. package/src/index.ts +311 -252
  112. package/src/llm-live.ts +68 -0
  113. package/src/market-radar-scan.ts +41 -0
  114. package/src/market-radar-sources.ts +173 -0
  115. package/src/migrate-output.ts +76 -0
  116. package/src/novel-context.ts +286 -0
  117. package/src/prompting.ts +26 -0
  118. package/src/protocol.ts +2072 -1182
  119. package/src/review-policy.ts +161 -0
  120. package/src/routes.ts +3405 -2151
  121. package/src/run.ts +342 -330
  122. package/src/stage-contract.ts +189 -0
  123. package/lib/client.js.map +0 -1
  124. package/lib/index.js.map +0 -1
  125. package/src/client/panel/BookshelfBar.tsx +0 -170
@@ -7,12 +7,12 @@
7
7
  */
8
8
  /**
9
9
  * 内容合规红线(平台硬性要求):所有书籍、所有章节无条件生效,
10
- * 优先级高于单书大纲/圣经中的任何设定与作者自定义红线。
10
+ * 优先级高于单书大纲/道藏中的任何设定与作者自定义红线。
11
11
  * 注入点:章节生成系统提示 + 审稿系统提示(命中即 high)。
12
12
  */
13
13
  export declare const COMPLIANCE_REDLINES: ReadonlyArray<string>;
14
14
  import type { Context } from '@deepseek-ai/cordis';
15
- import type { AuditIssue, AuthorReview, BreakdownResponse, ChapterPlan, Foreshadow, NovelConfig, OutlineCandidate, Plotline, PlotlineHealthReport, PlotlinePlan, ProjectState, ReviewReport, RoleRecord, RoleStatusCard, StoryBible, StoryboardPlanResponse, StoryboardResponse, Volume, WorldState } from './protocol.ts';
15
+ import type { AdaptationDimension, AdaptAnalyzeResponse, AdaptationMapping, AdaptationRules, AdaptProposeResponse, AuditIssue, AuthorReview, BreakdownResponse, ChapterPlan, Foreshadow, NovelConfig, OutlineCandidate, Plotline, PlotlineHealthReport, PlotlinePlan, ProjectState, ReviewReport, RoleRecord, RoleStatusCard, StoryBible, AddModelRequest, AddModelResponse, LlmModelsResponse, LlmVendorsResponse, LlmProvidersResponse, RemoveProviderRequest, RemoveProviderResponse, LlmTestResponse, Volume, WorldState, AdaptMaterializeRequest, AdaptMaterializeResponse, AdaptMaterializeSaveRequest, AdaptMaterializeSaveResponse, MarketRadarRequest, MarketRadarResult, MarketRadarSignal, MarketRadarBriefRequest, ProductionFoundation, MarketCreativeBrief, BookAnalysisRequest, BookAnalysisResult, IdeaInspirationRequest, IdeaInspirationResult, DirectorRequest, DirectorAdvice } from './protocol.ts';
16
16
  /** Project state file name inside the output dir. */
17
17
  export declare const PROJECT_FILE = "novel-project.json";
18
18
  /** Chapter output file name, e.g. 第001章_开篇.md */
@@ -45,7 +45,7 @@ export declare function readChapterFile(outputDir: string, chapter: ChapterPlan)
45
45
  /** Create a fresh project from an outline. */
46
46
  export declare function createProject(outline: string, outlinePath?: string): ProjectState;
47
47
  /** Extract the story bible from an outline. */
48
- export declare function extractBible(ctx: Context, config: NovelConfig, outline: string): Promise<StoryBible>;
48
+ export declare function extractBible(ctx: Context, config: NovelConfig, outline: string, project?: ProjectState): Promise<StoryBible>;
49
49
  /** Plan volumes from an outline. */
50
50
  export declare function planVolumes(ctx: Context, config: NovelConfig, outline: string): Promise<Volume[]>;
51
51
  /**
@@ -63,29 +63,40 @@ export declare function reviewChapterText(ctx: Context, config: NovelConfig, pro
63
63
  export declare function authorReviewChapter(ctx: Context, config: NovelConfig, project: ProjectState, chapterNo: number, body: string, prevTail: string): Promise<AuthorReview>;
64
64
  /** 复盘后自动关联:把本章号写入复盘标记推进的剧情线(按名称匹配,去重)。 */
65
65
  export declare function autoLinkPlotlines(project: ProjectState, chapterNo: number, advancedLines: string[]): void;
66
- /** AI 建议剧情线:基于大纲/卷计划/已写章节/编年录,提炼候选线。 */
66
+ /** 建议剧情线:基于大纲/卷计划/已写章节/编年录,提炼候选线。 */
67
67
  export declare function suggestPlotlines(ctx: Context, config: NovelConfig, project: ProjectState): Promise<Plotline[]>;
68
- /** AI 刷新单条剧情线的进度:结合编年录与各章摘要分析该线推进到哪。 */
68
+ /** 刷新单条剧情线的进度:结合编年录与各章摘要分析该线推进到哪。 */
69
69
  export declare function refreshPlotlineProgress(ctx: Context, config: NovelConfig, project: ProjectState, line: Plotline): Promise<string>;
70
- /** ✨ AI 从全书提炼角色库:大纲 + 道藏 + 编年录 + 章节摘要 → 结构化角色清单。 */
70
+ /** AI 从全书提炼角色库:大纲 + 道藏 + 编年录 + 章节摘要 → 结构化角色清单。 */
71
71
  export declare function extractRoles(ctx: Context, config: NovelConfig, project: ProjectState): Promise<RoleRecord[]>;
72
- /** 动漫形象描述词(中文描述 + 英文 booru 标签 + 关键外貌标签)。 */
73
- export interface RoleVisualPrompt {
74
- zh: string;
75
- en: string;
76
- tags: string[];
77
- source: string;
78
- }
79
- /**
80
- * 为单个角色提炼「动漫形象描述词」:扫描该角色出场的已写章节正文,
81
- * 截取含外貌描写的段落,交给 LLM 提炼中文描述 + 英文绘图标签。
82
- */
83
- export declare function extractRoleVisual(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, roleName: string): Promise<RoleVisualPrompt>;
84
- /**
85
- * 开书想法 → AI 大纲:输入一句话想法,生成 2-3 个方向不同、可直接开书的完整大纲方案。
86
- * @param count 本次生成几个(默认 3,最多 3)
87
- * @param exclude 已暂留方案的剧情方向/卖点摘要(换批时避开,防止重复)
88
- */
72
+ /** AI 从全书提炼场景库:正文/编年录 → 高频重要场景的结构化视觉锚点。 */
73
+ export declare function splitBookText(raw: string): Array<{
74
+ no: number;
75
+ title: string;
76
+ body: string;
77
+ }>;
78
+ /** 拆章预览(不落盘):章节编号/标题/字数 + 跳过清单。 */
79
+ export declare function previewBookText(raw: string): {
80
+ chapters: Array<{
81
+ no: number;
82
+ title: string;
83
+ chars: number;
84
+ }>;
85
+ skipped: string[];
86
+ };
87
+ /** 从全本文本导入(浏览器上传 / 服务器文件共用):建项目、写章节文件、保存。 */
88
+ export declare function importBookTextFromText(raw: string, outputDir: string, bookName: string): {
89
+ bookName: string;
90
+ chapters: number;
91
+ skipped: string[];
92
+ };
93
+ /** 从 txt/md 全本文件导入:编码自适应读取后拆章建项目,status=written(待审稿)。 */
94
+ export declare function importBookText(filePath: string, outputDir: string): {
95
+ bookName: string;
96
+ chapters: number;
97
+ skipped: string[];
98
+ };
99
+ /** 保证风格词块已内嵌(LLM 偶发漏嵌时兜底):zh 段首前缀,en 末尾追加。 */
89
100
  export declare function suggestOutlines(ctx: Context, config: NovelConfig, idea: string, count?: number, exclude?: string[]): Promise<OutlineCandidate[]>;
90
101
  /** 拆书分析:对已写章节做结构/人物/文风/卖点四维体检。
91
102
  * 两阶段管道(借鉴 AI-Novel-Writing-Assistant):
@@ -96,20 +107,24 @@ export declare function suggestOutlines(ctx: Context, config: NovelConfig, idea:
96
107
  * @param budgetTokens token 预算上限(超过即截断章节取样)。
97
108
  */
98
109
  export declare function breakdownBook(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, scope?: string, preset?: 'quick' | 'standard', budgetTokens?: number): Promise<BreakdownResponse>;
110
+ /** 对选中的提供商/模型发一次最小真实调用(maxTokens=16),验证 Key / 端点 / 模型可用。 */
111
+ export declare function testLlmModel(ctx: Context, provider: string, model: string): Promise<LlmTestResponse>;
112
+ /** 运行时厂商目录:DSH pi-ai 可配置提供方 + 内置适配器,作为「添加模型」下拉。 */
113
+ export declare function listLlmVendors(ctx: Context): Promise<LlmVendorsResponse>;
114
+ /** 查询某个 provider 当前可用模型(添加成功后可即时刷新下拉)。 */
115
+ export declare function listLlmModels(ctx: Context, provider: string): Promise<LlmModelsResponse>;
116
+ /** 当前已注册的提供方路由列表(提供方管理卡片)。 */
117
+ export declare function listLlmProviders(ctx: Context): Promise<LlmProvidersResponse>;
118
+ /** 移除一个提供方:unset 凭据 ref + 移除 llm-pi-ai providers 路由。 */
119
+ export declare function removeLlmProvider(ctx: Context, req: RemoveProviderRequest): Promise<RemoveProviderResponse>;
99
120
  /**
100
- * 漫剧分镜生成:把一章正文改编为短视频漫剧分镜(吸收 manga-script-master 方法论)。
101
- * 产出:本集标题 + 赛道节奏说明 + 角色视觉锚点卡 + 分镜表(8-12 格)+ 结尾钩子。
102
- * 角色锚点优先复用角色库 imagePrompt(无则从正文提炼)。
103
- */
104
- export declare function generateStoryboard(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, chapterNo: number, genre: string, platform: string, tool: string): Promise<StoryboardResponse>;
105
- /**
106
- * 漫剧分集计划:AI 通读一卷的章节标题+摘要+beats,按故事弧线把章节分组为漫剧集。
107
- * 原则(吸收 manga-script 节奏模型):高潮章单独成集、过渡章合并、断点选在钩子最强处。
121
+ * 添加模型(DSH 同款体验):厂商直填 API Key,或自定义 OpenAI 兼容路由。
122
+ * 写入 DSH 凭据 refs,并(必要时)注册/更新 llm-pi-ai provider 路由。
108
123
  */
109
- export declare function planStoryboardEpisodes(ctx: Context, config: NovelConfig, project: ProjectState, volumeNo: number, platform: string, maxEpisodes: number): Promise<StoryboardPlanResponse>;
110
- /** 🩺 剧情健康检查:基于已写章节数/各线状态/编年录,判断是否需要新线及添加时机。 */
124
+ export declare function registerLlmModel(ctx: Context, req: AddModelRequest): Promise<AddModelResponse>;
125
+ /** 剧情健康检查:基于已写章节数/各线状态/编年录,判断是否需要新线及添加时机。 */
111
126
  export declare function analyzePlotlineHealth(ctx: Context, config: NovelConfig, project: ProjectState): Promise<PlotlineHealthReport>;
112
- /** ✨ AI 剧情方案:基于健康检查结果设计下一阶段方向与建议新线。 */
127
+ /** 剧情方案:基于健康检查结果设计下一阶段方向与建议新线。 */
113
128
  export declare function designPlotlinePlan(ctx: Context, config: NovelConfig, project: ProjectState, health?: PlotlineHealthReport): Promise<PlotlinePlan>;
114
129
  /**
115
130
  * Stream a chapter rewrite. With `target` (a passage of the body), only that
@@ -139,6 +154,8 @@ export declare function polishChapterStream(ctx: Context, config: NovelConfig, p
139
154
  chars: number;
140
155
  draft: string;
141
156
  }, void, unknown>;
157
+ /** 统计中文字符数(汉字),与「每章字数」红线口径一致(不含标点/换行)。 */
158
+ export declare function countHanzi(text: string): number;
142
159
  /** Generate one chapter (streaming). Yields progress frames; persists when done. */
143
160
  export declare function generateChapterStream(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, chapterNo: number): AsyncGenerator<{
144
161
  frame: 'start';
@@ -149,14 +166,75 @@ export declare function generateChapterStream(ctx: Context, config: NovelConfig,
149
166
  frame: 'done';
150
167
  file: string;
151
168
  chars: number;
169
+ warn?: string;
152
170
  }, void, unknown>;
153
171
  /** Generate a chapter summary (narrative memory). */
154
172
  export declare function summarizeChapter(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, chapterNo: number): Promise<string>;
155
173
  /**
156
- * 摘要 + 事实抽取合并为一次 LLM 调用(省一次调用与一次正文输入,
157
- * 批量生成时整体开销约省 25%)。
158
- * @returns 摘要与新增事实条数(失败返回空,调用方 best-effort)。
174
+ * 反向推大纲:从已写章节正文反推出全书总纲(分卷 + 章节要点 + 主线/人物弧线/伏笔清单)。
175
+ * 两阶段:分批提取章节事件摘要 → 汇总生成大纲。不修改章节/设定,只返回大纲文本。
176
+ */
177
+ export declare function reverseOutlineFromChapters(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, onProgress?: (done: number, total: number, phase: string) => void): Promise<string>;
178
+ /**
179
+ * 改编模式 P0:全文分析 → 原文设定卡片 / 可改范围矩阵。
180
+ * 拆章统计 + 取样正文,让 LLM 一次输出结构化 JSON:
181
+ * { bookName, outline, dimensions: [{key,title,mutability,current,evidence,candidates,impact,risk}] }。
159
182
  */
183
+ export declare function analyzeAdaptation(ctx: Context, config: NovelConfig, text: string): Promise<AdaptAnalyzeResponse>;
184
+ /** 改编方案:由用户勾选的维度与新值,生成 LLM 映射表/规则/影响清单。 */
185
+ export declare function proposeAdaptation(ctx: Context, config: NovelConfig, _text: string, selections: Array<{
186
+ key: string;
187
+ title: string;
188
+ current: string;
189
+ target: string;
190
+ mutability: string;
191
+ }>, dimensions?: AdaptationDimension[]): Promise<AdaptProposeResponse>;
192
+ /** 剧本术语替换执行:按映射表做精确替换并统计命中。 */
193
+ export declare function applyAdaptationReplacements(text: string, mappings: AdaptationMapping[]): {
194
+ adaptedText: string;
195
+ hits: Array<{
196
+ source: string;
197
+ target: string;
198
+ count: number;
199
+ }>;
200
+ };
201
+ /** 改编模式 rewrite:逐章 LLM 重写(结构性改写,不只是换词)。
202
+ * @returns 改写后的全文 + 逐章结果 + 保留原章的章号。 */
203
+ export declare function rewriteAdaptationBook(ctx: Context, config: NovelConfig, text: string, mappings: AdaptationMapping[], rules?: AdaptationRules, options?: {
204
+ maxChapters?: number;
205
+ startNo?: number;
206
+ endNo?: number;
207
+ onProgress?: (info: {
208
+ completed: number;
209
+ total: number;
210
+ no: number;
211
+ title: string;
212
+ }) => void;
213
+ }): Promise<{
214
+ adaptedText: string;
215
+ rewritten: Array<{
216
+ no: number;
217
+ title: string;
218
+ chars: number;
219
+ }>;
220
+ skipped: number[];
221
+ hits: Array<{
222
+ source: string;
223
+ target: string;
224
+ count: number;
225
+ }>;
226
+ }>;
227
+ /**
228
+ * 改编模式 P3:从源全文 + 用户编辑后的改编方案,提炼新书资料并保存为「待写新书」。
229
+ * 流程:源文导入临时项目 → 复用 extractBible/extractRoles/extractWorld 提炼 →
230
+ * 按映射表把术语/人名/势力映射到新书命名层 → planVolumes/planChapters 生成待写计划 → 保存。
231
+ * @returns 提炼后的新书资料(不含书架 book,由路由负责登记书架)。
232
+ */
233
+ export declare function materializeAdaptedBook(ctx: Context, config: NovelConfig, args: Omit<AdaptMaterializeRequest, 'outputDir'> & {
234
+ outputDir: string;
235
+ }): Promise<Omit<AdaptMaterializeResponse, 'book'>>;
236
+ /** 把预览/微调后的新书资料写入输出目录并返回摘要(书架登记由路由负责)。 */
237
+ export declare function saveMaterializedBook(outDir: string, bookName: string, data: Omit<AdaptMaterializeSaveRequest, 'bookName' | 'outputDir'>): Omit<AdaptMaterializeSaveResponse, 'book'>;
160
238
  export declare function summarizeAndExtractFacts(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, chapterNo: number): Promise<{
161
239
  summary: string;
162
240
  factCount: number;
@@ -175,7 +253,7 @@ export declare function markForeshadowPlanted(project: ProjectState, outputDir:
175
253
  export declare function extractFacts(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, chapterNo: number): Promise<number>;
176
254
  /** 全书一致性质检:LLM 分批扫描已生成章节 + 设定 + 事实库,聚合矛盾清单。 */
177
255
  export declare function auditBook(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, onProgress?: (completedBatches: number, totalBatches: number) => void): Promise<AuditIssue[]>;
178
- /** 小说简介:AI 生成或按已写开头补全(面向读者的作品门面)。 */
256
+ /** 小说简介:生成或按已写开头补全(面向读者的作品门面)。 */
179
257
  export declare function generateBlurb(ctx: Context, config: NovelConfig, project: ProjectState, partial?: string): Promise<string>;
180
258
  /**
181
259
  * 组装全书上下文包(AI 助手 book_overview 工具)。
@@ -185,7 +263,7 @@ export declare function generateBlurb(ctx: Context, config: NovelConfig, project
185
263
  export declare function bookOverview(project: ProjectState, scope?: 'recent' | 'full' | number): string;
186
264
  /** 一条影响分析结果(改动波及处)。 */
187
265
  export interface ImpactItem {
188
- /** 位置:章节号 / 大纲 / 设定圣经 / 大世界 / 事实库 / 简介。 */
266
+ /** 位置:章节号 / 大纲 / 道藏 / 大世界 / 事实库 / 简介。 */
189
267
  location: string;
190
268
  /** 原文片段(定位用)。 */
191
269
  quote: string;
@@ -201,7 +279,7 @@ export interface ImpactItem {
201
279
  export declare function analyzeImpact(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, change: string): Promise<ImpactItem[]>;
202
280
  /** 把大世界结构化数据渲染成提示词块(境界体系按顺序强约束)。 */
203
281
  export declare function renderWorld(world: WorldState | undefined): string;
204
- /** AI 提炼大世界:从大纲 + 设定圣经生成结构化境界体系/区域/势力。 */
282
+ /** 提炼大世界:从大纲 + 道藏生成结构化境界体系/区域/势力。 */
205
283
  export declare function extractWorld(ctx: Context, config: NovelConfig, project: ProjectState): Promise<WorldState>;
206
284
  /**
207
285
  * 事实库回填:对历史已生成章节批量抽取事实(无事实记录的旧章节)。
@@ -224,7 +302,35 @@ export declare function extractStyleAsset(ctx: Context, config: NovelConfig, sam
224
302
  dialogueRules: string[];
225
303
  descriptionRules: string[];
226
304
  boundaries: string[];
305
+ preset?: 'imitate' | 'balanced' | 'transfer';
306
+ fingerprintRisk?: 'low' | 'medium' | 'high';
307
+ writingGuidance?: string[];
308
+ forbiddenEntities?: string[];
309
+ }>;
310
+ /** 分层提取写作公式(basic/standard/deep)。 */
311
+ export declare function extractStyleFormula(ctx: Context, config: NovelConfig, sampleText: string, depth: 'basic' | 'standard' | 'deep'): Promise<{
312
+ name: string;
313
+ focusAreas: string[];
314
+ formula: string;
315
+ applyGuidance: string;
227
316
  }>;
317
+ /** 题材雷达:输入平台/题材/榜单文本 → 信号 + 生产底座 + 开书创意。 */
318
+ export declare function runMarketRadar(ctx: Context, config: NovelConfig, req: MarketRadarRequest): Promise<MarketRadarResult>;
319
+ /** 开书创意简报:用选中的市场信号 + 影响模式生成可执行 constraint / creative seed。 */
320
+ export declare function runMarketCreativeBrief(ctx: Context, config: NovelConfig, req: MarketRadarBriefRequest): Promise<MarketCreativeBrief>;
321
+ /** 书分析/拆书:输入一本书/章节文本 → 卖点/结构/可借鉴点/风险。 */
322
+ export declare function runBookAnalysis(ctx: Context, config: NovelConfig, req: BookAnalysisRequest): Promise<BookAnalysisResult>;
323
+ /** 创意灵感:一句话/题材 → 多方向开书灵感。 */
324
+ export declare function runIdeaInspiration(ctx: Context, config: NovelConfig, req: IdeaInspirationRequest): Promise<IdeaInspirationResult>;
325
+ /** 雷达→灵感:基于市场信号/生产底座/创意简报,生成贴合市场的开书灵感。 */
326
+ export declare function runMarketIdeaInspiration(ctx: Context, config: NovelConfig, req: {
327
+ signals?: MarketRadarSignal[];
328
+ foundation?: ProductionFoundation;
329
+ brief?: MarketCreativeBrief;
330
+ count?: number;
331
+ }): Promise<IdeaInspirationResult>;
332
+ /** 自动导演编排建议:基于全书上下文,给出下一卷/阶段编排 + 修复再平衡。 */
333
+ export declare function runDirectorAdvice(ctx: Context, config: NovelConfig, project: ProjectState, req: DirectorRequest): Promise<DirectorAdvice>;
228
334
  /** Export the whole book as one txt/md file. */
229
335
  export declare function exportBook(outputDir: string, project: ProjectState, format: 'txt' | 'md'): {
230
336
  file: string;
@@ -0,0 +1,6 @@
1
+ import type { GenreNode, ProgressionMode } from './protocol.ts';
2
+ export declare function globalGenreLibrary(): GenreNode[];
3
+ export declare function globalProgressionLibrary(): ProgressionMode[];
4
+ /** 新增/已有则跳过;返回 true=新增。 */
5
+ export declare function addGlobalGenre(g: GenreNode): boolean;
6
+ export declare function addGlobalMode(m: ProgressionMode): boolean;
@@ -18,7 +18,7 @@ export declare const inject: string[];
18
18
  * settings surface edits. Spelled here rather than imported: the browser half
19
19
  * spells the same value and must not depend on a Host package.
20
20
  */
21
- export declare const NOVEL_SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
21
+ export declare const NOVEL_SETTINGS_NAMESPACE: "dsh-novel-forge";
22
22
  /** Plugin config, validated by the same-named schemastery schema. */
23
23
  export interface Config {
24
24
  /** When true (default), a system-prompt section announces the plugin to every agent. */
@@ -33,8 +33,16 @@ export interface Config {
33
33
  provider?: string;
34
34
  /** LLM model id. */
35
35
  model?: string;
36
+ /** 任务级模型路由:正文生成模型(留空则跟随 model)。 */
37
+ generateModel?: string;
38
+ /** 任务级模型路由:审稿模型(留空则跟随 model)。 */
39
+ reviewModel?: string;
40
+ /** 任务级模型路由:质检模型(留空则跟随 model)。 */
41
+ auditModel?: string;
36
42
  /** LLM reasoning effort (off/low/high/max). */
37
43
  reasoningEffort?: 'off' | 'low' | 'high' | 'max';
44
+ /** 分析类任务(提炼/拆书/反推大纲等)的推理档位;默认 low。 */
45
+ analysisReasoning?: 'off' | 'low' | 'high' | 'max';
38
46
  /** Target characters per chapter. */
39
47
  chapterChars?: number;
40
48
  /** Max output tokens per chapter call. */
@@ -47,10 +55,18 @@ export interface Config {
47
55
  autoAuthorReview?: boolean;
48
56
  /** 修订/润色产出草稿后自动附带一次 AI 审查(默认开,可在设置页关闭省 token)。 */
49
57
  autoReviewAfterRevise?: boolean;
58
+ /** 自定义背景图(URL / dataURL / 服务端路径引用)。 */
59
+ themeBackground?: string;
60
+ /** 自定义背景遮罩/模糊强度 0-80。 */
61
+ themeBackgroundBlur?: number;
62
+ /** 玻璃透明度 0-100(100=当前原样)。 */
63
+ themeOpacity?: number;
64
+ /** 是否启用改编模式(默认关闭)。 */
65
+ enableAdaptMode?: boolean;
50
66
  }
51
67
  export declare const Config: z<Config>;
52
68
  /** Model-facing announcement: plugin presence, capabilities, and limits. */
53
- export declare const NOVEL_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-novel-forge \u63D2\u4EF6\uFF08AI \u7F16\u8BD1\u5C0F\u8BF4\u5DE5\u4F5C\u53F0\uFF09\uFF1A\u4FA7\u8FB9\u680F\u300C\u5C0F\u8BF4\u5DE5\u574A\u300D\u5165\u53E3\u3002\u80FD\u529B\uFF1A\u8BFB\u53D6 docx \u5927\u7EB2\uFF08\u9ED8\u8BA4 D:\\ryan work\\harness\\novels\\\u5F52\u589F\u7389\u4E3B \u5927\u7EB2\uFF09\u6216\u7C98\u8D34\u5927\u7EB2\u6587\u672C\uFF1B\u7528 LLM \u63D0\u70BC\u9053\u85CF\uFF08\u4EBA\u8BBE/\u4E16\u754C\u89C2/\u91D1\u624B\u6307\u89C4\u5219/\u5199\u4F5C\u7EA2\u7EBF\uFF0C\u5373\u8BBE\u5B9A\u5723\u7ECF\uFF09\uFF1B\u751F\u6210\u5377\u8BA1\u5212\u4E0E\u7AE0\u8282\u8BA1\u5212\uFF1B\u9010\u7AE0\u8C03\u7528 LLM \u751F\u6210 3000-4000 \u5B57\u6B63\u6587\u5E76\u4FDD\u5B58\u4E3A Markdown\uFF08\u9ED8\u8BA4\u8F93\u51FA\u5230 D:\\ryan work\\harness\\novels\\\u5F52\u589F\u7389\u4E3B\uFF09\uFF1B\u6BCF\u7AE0\u81EA\u52A8\u751F\u6210\u6458\u8981\uFF08\u53D9\u4E8B\u8BB0\u5FC6\uFF09\u3001\u81EA\u52A8 AI \u5BA1\u7A3F\uFF08\u4EBA\u8BBE/\u8BBE\u5B9A/\u7EA2\u7EBF/\u6587\u7B14/\u723D\u70B9/\u903B\u8F91\uFF09\uFF0C\u652F\u6301\u6309\u5BA1\u7A3F\u610F\u89C1\u91CD\u5199\u3001\u53BB AI \u5473\u6DA6\u8272\u3001\u6697\u7EBF\uFF08\u4F0F\u7B14\uFF09\u7BA1\u7406\u3001\u6279\u91CF\u8FDE\u5199\u4E0E\u5168\u672C\u5BFC\u51FA\uFF08txt/md\uFF09\u3002\u9650\u5236\uFF1A\u751F\u6210\u6D88\u8017 LLM API \u989D\u5EA6\uFF1B\u8F93\u51FA\u76EE\u5F55\u4E0E\u6A21\u578B\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u4FEE\u6539\uFF1B\u7AE0\u8282\u6B63\u6587\u8D28\u91CF\u53D6\u51B3\u4E8E\u5927\u7EB2\u5B8C\u6574\u5EA6\u3002\u7528\u6237\u63D0\u5230\u300C\u5C0F\u8BF4 / \u5927\u7EB2 / \u5199\u5C0F\u8BF4 / \u7AE0\u8282 / \u5BA1\u7A3F / \u6DA6\u8272 / \u5F52\u589F\u7389\u4E3B\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
69
+ export declare const NOVEL_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-novel-forge \u63D2\u4EF6\uFF08AI \u7F16\u8BD1\u5C0F\u8BF4\u5DE5\u4F5C\u53F0\uFF09\uFF1A\u4FA7\u8FB9\u680F\u300C\u5C0F\u8BF4\u5DE5\u574A\u300D\u5165\u53E3\u3002\u80FD\u529B\uFF1A\u8BFB\u53D6 docx \u5927\u7EB2\u6216\u7C98\u8D34\u5927\u7EB2\u6587\u672C\uFF1B\u7528 LLM \u63D0\u70BC\u9053\u85CF\uFF08\u4EBA\u8BBE/\u4E16\u754C\u89C2/\u91D1\u624B\u6307\u89C4\u5219/\u5199\u4F5C\u7EA2\u7EBF\uFF09\uFF1B\u751F\u6210\u5377\u8BA1\u5212\u4E0E\u7AE0\u8282\u8BA1\u5212\uFF1B\u9010\u7AE0\u8C03\u7528 LLM \u751F\u6210 3000-4000 \u5B57\u6B63\u6587\u5E76\u4FDD\u5B58\u4E3A Markdown\uFF08\u9ED8\u8BA4\u8F93\u51FA\u5230\u7528\u6237\u4E3B\u76EE\u5F55 ~/.dsh/novels\uFF09\uFF1B\u6BCF\u7AE0\u81EA\u52A8\u751F\u6210\u6458\u8981\uFF08\u53D9\u4E8B\u8BB0\u5FC6\uFF09\u3001\u81EA\u52A8 AI \u5BA1\u7A3F\uFF08\u4EBA\u8BBE/\u8BBE\u5B9A/\u7EA2\u7EBF/\u6587\u7B14/\u723D\u70B9/\u903B\u8F91\uFF09\uFF0C\u652F\u6301\u6309\u5BA1\u7A3F\u610F\u89C1\u91CD\u5199\u3001\u53BB AI \u5473\u6DA6\u8272\u3001\u6697\u7EBF\uFF08\u4F0F\u7B14\uFF09\u7BA1\u7406\u3001\u6279\u91CF\u8FDE\u5199\u4E0E\u5168\u672C\u5BFC\u51FA\uFF08txt/md\uFF09\u3002\u9650\u5236\uFF1A\u751F\u6210\u6D88\u8017 LLM API \u989D\u5EA6\uFF1B\u8F93\u51FA\u76EE\u5F55\u4E0E\u6A21\u578B\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u4FEE\u6539\uFF1B\u7AE0\u8282\u6B63\u6587\u8D28\u91CF\u53D6\u51B3\u4E8E\u5927\u7EB2\u5B8C\u6574\u5EA6\u3002\u7528\u6237\u63D0\u5230\u300C\u5C0F\u8BF4 / \u5927\u7EB2 / \u5199\u5C0F\u8BF4 / \u7AE0\u8282 / \u5BA1\u7A3F / \u6DA6\u8272\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
54
70
  /** Resolve a config-like value into the full runtime config. */
55
71
  export declare function resolveConfig(value: Partial<Config> | undefined): NovelConfig;
56
72
  /**
@@ -0,0 +1,44 @@
1
+ /**
2
+ * LLM 实况 feed(对齐上游「AI 创作实况 / LIVE LOG」的轻量实现)。
3
+ *
4
+ * 以「每次 LLM 调用」为粒度,把生命周期事件(开始/流式正文/阶段变化/完成)推给订阅者,
5
+ * 并提供环形缓冲供新连上的客户端重放。不持久化(与上游缓存不同,如需成 cache 再扩展)。
6
+ */
7
+ export type LlmLivePhase = 'requesting' | 'streaming' | 'completed' | 'failed';
8
+ export interface LlmLiveFrame {
9
+ type: 'session_started' | 'output_delta' | 'reasoning_delta' | 'phase_changed' | 'session_completed';
10
+ /** 由服务端生成,形如 ll-<n>。 */
11
+ sessionId: string;
12
+ /** 本次调用用途(如 正文生成/审稿/章节规划)。 */
13
+ label?: string;
14
+ /** 使用模型(用于展示)。 */
15
+ model?: string;
16
+ /** 事件时间(ISO)。 */
17
+ at: string;
18
+ /** session_started / 部分帧:交互上下文。 */
19
+ context?: {
20
+ taskId?: string;
21
+ interactionId: string;
22
+ };
23
+ /** output_delta / reasoning_delta:本次增量文本。 */
24
+ content?: string;
25
+ /** session 累计字符数。 */
26
+ totalChars?: number;
27
+ /** reasoning 累计字符数。 */
28
+ totalReasoningChars?: number;
29
+ /** phase_changed:新阶段。 */
30
+ phase?: LlmLivePhase;
31
+ /** phase_changed:阶段描述。 */
32
+ phaseMessage?: string;
33
+ /** session_completed:最终预览(截断)。 */
34
+ preview?: string;
35
+ /** session_completed:失败信息。 */
36
+ error?: string;
37
+ }
38
+ type Listener = (frame: LlmLiveFrame) => void;
39
+ export declare function nextSessionId(): string;
40
+ export declare function subscribeLiveFeed(listener: Listener): () => void;
41
+ export declare function emitLive(frame: LlmLiveFrame): void;
42
+ export declare function liveLatest(): LlmLiveFrame[];
43
+ export declare function clearLiveFeed(): void;
44
+ export {};
@@ -0,0 +1,19 @@
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 getLastMarketScan(): MarketScanResult | null;
19
+ export declare function scanMarketRanking(platforms?: string[]): Promise<MarketScanResult>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 「热门题材雷达」真实榜单抓取源(移植自 AI-Novel-Writing-Assistant marketRadarSources)。
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,80 @@
1
+ /**
2
+ * 统一上下文组装与相关设定检索
3
+ *
4
+ * 取代各阶段各自拼装 prompt,消除「生成看得到、审稿看不到」的断层。
5
+ * 所有阶段通过 buildChapterContext 获取同一来源的事实与设定。
6
+ */
7
+ import type { ProjectState, ChapterPlan, StoryBible, RoleRecord, ChapterFact, Foreshadow, Plotline } from './protocol';
8
+ export interface ChapterContext {
9
+ /** 平台合规红线(永远全量) */
10
+ complianceRedLines: string[];
11
+ /** 本书写作红线(永远全量) */
12
+ bookRedLines: string[];
13
+ /** 当前章相关角色卡(全量信息) */
14
+ relevantRoles: Array<{
15
+ name: string;
16
+ role: string;
17
+ traits: string[];
18
+ goals?: string;
19
+ knowledge?: string[];
20
+ }>;
21
+ /** 当前章相关道藏规则 */
22
+ relevantWorldRules: string[];
23
+ /** 活跃剧情线 */
24
+ activePlotlines: Plotline[];
25
+ /** 未回收伏笔 */
26
+ activeForeshadows: Foreshadow[];
27
+ /** 上一章结尾原文 */
28
+ prevChapterTail: string;
29
+ /** 上一章摘要 */
30
+ prevChapterSummary?: string;
31
+ /** 最近事实(近因记忆,top20) */
32
+ recentFacts: string[];
33
+ /** 相关旧事实(按本章 beats 检索,top15) */
34
+ relatedFacts: string[];
35
+ /** 当前卷大纲 */
36
+ currentVolumeOutline: string;
37
+ /** 本章 beats */
38
+ beats: string;
39
+ /** 本章标题 */
40
+ chapterTitle: string;
41
+ }
42
+ export interface ContextBuildOptions {
43
+ /** 阶段:writing/review/revise/polish/plan */
44
+ stage?: 'writing' | 'review' | 'revise' | 'polish' | 'plan';
45
+ /** 是否注入完整角色卡(false 时只注入角色名+定位) */
46
+ fullRoleCards?: boolean;
47
+ /** 相关事实检索上限 */
48
+ relatedFactsLimit?: number;
49
+ /** 最近事实数量 */
50
+ recentFactsLimit?: number;
51
+ }
52
+ /**
53
+ * 相关事实检索:trigram 重合度 + 角色名命中加权 + 近因加权
54
+ * 从 generateChapterStream 抽取,扩展为通用函数。
55
+ */
56
+ export declare function retrieveRelatedFacts(facts: ChapterFact[], beatsText: string, roleNames: string[], limit?: number): string[];
57
+ /**
58
+ * 相关角色检索:beats 中出现的角色 + 主角/主要反派永远全量
59
+ */
60
+ export declare function retrieveRelevantRoles(bible: StoryBible | undefined, roles: RoleRecord[] | undefined, beatsText: string): ChapterContext['relevantRoles'];
61
+ /**
62
+ * 构建章节统一上下文
63
+ *
64
+ * 各阶段调用此函数获取同一来源的事实与设定,消除上下文断层。
65
+ * 检索结果不足时自动回退全量,保证不丢失关键信息。
66
+ */
67
+ export declare function buildChapterContext(project: ProjectState, chapter: ChapterPlan, outputDir: string, options?: ContextBuildOptions): ChapterContext;
68
+ /**
69
+ * 将上下文渲染为 prompt 文本块
70
+ * 各阶段可按需选择注入哪些块。
71
+ */
72
+ export declare function renderContextBlocks(ctx: ChapterContext): {
73
+ rolesBlock: string;
74
+ worldRulesBlock: string;
75
+ factsBlock: string;
76
+ plotlinesBlock: string;
77
+ foreshadowsBlock: string;
78
+ continuityBlock: string;
79
+ redLinesBlock: string;
80
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 提示词共享常量与工具
3
+ *
4
+ * 所有 JSON 输出规则、通用约束集中在此,避免各阶段重复定义、互相打架。
5
+ */
6
+ /** JSON 输出规则(所有要求模型输出 JSON 的地方共用) */
7
+ export declare const JSON_OUTPUT_RULES: string[];
8
+ /** JSON 输出规则的紧凑版(适合放在提示词末尾) */
9
+ export declare const JSON_OUTPUT_RULES_COMPACT: string;
10
+ /**
11
+ * 估算 prompt 的 token 数(粗略估算,用于上下文预算控制)
12
+ * 中文约 1.7 字/token,英文约 4 字符/token
13
+ */
14
+ export declare function estimateTokens(text: string): number;
15
+ /**
16
+ * 按 token 预算截断文本(保留开头,末尾加省略标记)
17
+ * 用于控制单块上下文不超预算。
18
+ */
19
+ export declare function truncateByTokens(text: string, maxTokens: number, marker?: string): string;
20
+ /** 通用「只改表达不改情节」约束(润色/局部修订共用) */
21
+ export declare const EXPRESSION_ONLY_RULE: string[];
22
+ /** 章节上下文各阶段的 token 预算(粗略,用于控制注入量) */
23
+ export declare const CONTEXT_BUDGET: {
24
+ /** 章节生成:道藏+角色+大纲+事实+伏笔 */
25
+ readonly writing: 12000;
26
+ /** AI 审稿:道藏+角色+事实+正文 */
27
+ readonly review: 10000;
28
+ /** 修订:原意见+相关事实+目标正文 */
29
+ readonly revise: 8000;
30
+ /** 润色:风格资产+原正文 */
31
+ readonly polish: 6000;
32
+ /** 分章规划:大纲+道藏+角色+近期事实 */
33
+ readonly plan: 15000;
34
+ };
35
+ export type ContextStage = keyof typeof CONTEXT_BUDGET;
@@ -0,0 +1,10 @@
1
+ /** 章节写作约束:官方 writer 骨架渲染成可附加到现有系统提示词末尾的必达/禁止/自查块。 */
2
+ export declare function renderOfficialChapterWriterSkeleton(meta: {
3
+ targetChars: number;
4
+ minChars: number;
5
+ maxChars: number;
6
+ pov?: string;
7
+ tonePreference?: string;
8
+ endingHookPreference?: string;
9
+ antiAiRules?: string;
10
+ }): string;