@waterwx/dsh-novel-forge 0.1.0 → 1.0.0-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 (180) hide show
  1. package/README.md +162 -111
  2. package/cordis.patch.yml +1 -1
  3. package/lib/client.js +54165 -2666
  4. package/lib/index.js +11895 -2211
  5. package/lib/types/ai-scan.d.ts +36 -0
  6. package/lib/types/assets.d.ts +19 -4
  7. package/lib/types/assistant.d.ts +6 -0
  8. package/lib/types/author-assets.d.ts +25 -0
  9. package/lib/types/bookshelf.d.ts +8 -1
  10. package/lib/types/client/api.d.ts +235 -3
  11. package/lib/types/client/index.d.ts +1 -1
  12. package/lib/types/client/llmLive.d.ts +33 -0
  13. package/lib/types/client/locales.d.ts +101 -28
  14. package/lib/types/client/panel/AdaptModeView.d.ts +5 -0
  15. package/lib/types/client/panel/AssetsTab.d.ts +6 -1
  16. package/lib/types/client/panel/AuthorAssetsView.d.ts +4 -0
  17. package/lib/types/client/panel/AuthorHome.d.ts +34 -0
  18. package/lib/types/client/panel/BookAnalysisView.d.ts +4 -0
  19. package/lib/types/client/panel/CreateBookView.d.ts +13 -0
  20. package/lib/types/client/panel/DirectorView.d.ts +7 -0
  21. package/lib/types/client/panel/FlowGuide.d.ts +22 -0
  22. package/lib/types/client/panel/GlobalAssetLibraryView.d.ts +4 -0
  23. package/lib/types/client/panel/IdeaInspirationView.d.ts +6 -0
  24. package/lib/types/client/panel/ImportModal.d.ts +7 -0
  25. package/lib/types/client/panel/KnowledgeBaseView.d.ts +4 -0
  26. package/lib/types/client/panel/LiveFeedLog.d.ts +5 -0
  27. package/lib/types/client/panel/MangaRoleLibrary.d.ts +20 -0
  28. package/lib/types/client/panel/MangaWorkspace.d.ts +12 -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/ModelPicker.d.ts +11 -0
  32. package/lib/types/client/panel/NovelPanel.d.ts +1 -1
  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/PropLibrary.d.ts +8 -0
  36. package/lib/types/client/panel/ReaderView.d.ts +8 -0
  37. package/lib/types/client/panel/ReasoningSection.d.ts +10 -0
  38. package/lib/types/client/panel/RunPanel.d.ts +5 -0
  39. package/lib/types/client/panel/SceneLibrary.d.ts +16 -0
  40. package/lib/types/client/panel/SettingsView.d.ts +16 -0
  41. package/lib/types/client/panel/ShelfView.d.ts +15 -0
  42. package/lib/types/client/panel/StoryboardTab.d.ts +19 -0
  43. package/lib/types/client/panel/StyleCard.d.ts +8 -0
  44. package/lib/types/client/panel/StyleGallery.d.ts +1 -0
  45. package/lib/types/client/panel/WorldTab.d.ts +10 -0
  46. package/lib/types/client/panel/helpers.d.ts +10 -0
  47. package/lib/types/client/panel/views.d.ts +77 -0
  48. package/lib/types/client/run-status.d.ts +19 -0
  49. package/lib/types/client/text.d.ts +9 -0
  50. package/lib/types/comic-presets.d.ts +12 -0
  51. package/lib/types/engine.d.ts +250 -8
  52. package/lib/types/global-assets.d.ts +6 -0
  53. package/lib/types/index.d.ts +24 -2
  54. package/lib/types/llm-live.d.ts +44 -0
  55. package/lib/types/manga-genre-rules.d.ts +22 -0
  56. package/lib/types/market-radar-scan.d.ts +19 -0
  57. package/lib/types/market-radar-sources.d.ts +31 -0
  58. package/lib/types/novel-context.d.ts +80 -0
  59. package/lib/types/prompt-utils.d.ts +35 -0
  60. package/lib/types/prompting.d.ts +35 -0
  61. package/lib/types/protocol.d.ts +1453 -5
  62. package/lib/types/review-policy.d.ts +97 -0
  63. package/lib/types/run.d.ts +32 -0
  64. package/lib/types/shot-language.d.ts +46 -0
  65. package/lib/types/src/ai-scan.d.ts +36 -0
  66. package/lib/types/src/assets.d.ts +37 -0
  67. package/lib/types/src/assistant.d.ts +45 -0
  68. package/lib/types/src/author-assets.d.ts +25 -0
  69. package/lib/types/src/bookshelf.d.ts +42 -0
  70. package/lib/types/src/client/api.d.ts +234 -0
  71. package/lib/types/src/client/docx.d.ts +15 -0
  72. package/lib/types/src/client/index.d.ts +14 -0
  73. package/lib/types/src/client/locales.d.ts +212 -0
  74. package/lib/types/src/client/mount.d.ts +9 -0
  75. package/lib/types/src/client/panel/AdaptModeView.d.ts +5 -0
  76. package/lib/types/src/client/panel/AssetsTab.d.ts +12 -0
  77. package/lib/types/src/client/panel/AssistantTab.d.ts +7 -0
  78. package/lib/types/src/client/panel/AuthorAssetsView.d.ts +4 -0
  79. package/lib/types/src/client/panel/AuthorHome.d.ts +32 -0
  80. package/lib/types/src/client/panel/BookshelfBar.d.ts +11 -0
  81. package/lib/types/src/client/panel/CreateBookView.d.ts +9 -0
  82. package/lib/types/src/client/panel/FlowGuide.d.ts +22 -0
  83. package/lib/types/src/client/panel/GlobalAssetLibraryView.d.ts +4 -0
  84. package/lib/types/src/client/panel/ImportModal.d.ts +7 -0
  85. package/lib/types/src/client/panel/MangaRoleLibrary.d.ts +20 -0
  86. package/lib/types/src/client/panel/MangaWorkspace.d.ts +12 -0
  87. package/lib/types/src/client/panel/ModelManager.d.ts +14 -0
  88. package/lib/types/src/client/panel/NovelPanel.d.ts +13 -0
  89. package/lib/types/src/client/panel/ProgressConsole.d.ts +17 -0
  90. package/lib/types/src/client/panel/ProgressHomeView.d.ts +5 -0
  91. package/lib/types/src/client/panel/PropLibrary.d.ts +8 -0
  92. package/lib/types/src/client/panel/ReaderView.d.ts +8 -0
  93. package/lib/types/src/client/panel/ReasoningSection.d.ts +10 -0
  94. package/lib/types/src/client/panel/RunPanel.d.ts +5 -0
  95. package/lib/types/src/client/panel/SceneLibrary.d.ts +16 -0
  96. package/lib/types/src/client/panel/SettingsView.d.ts +16 -0
  97. package/lib/types/src/client/panel/ShelfView.d.ts +15 -0
  98. package/lib/types/src/client/panel/StoryboardTab.d.ts +19 -0
  99. package/lib/types/src/client/panel/StyleCard.d.ts +8 -0
  100. package/lib/types/src/client/panel/StyleGallery.d.ts +1 -0
  101. package/lib/types/src/client/panel/WorldTab.d.ts +10 -0
  102. package/lib/types/src/client/panel/controller.d.ts +19 -0
  103. package/lib/types/src/client/panel/helpers.d.ts +18 -0
  104. package/lib/types/src/client/panel/views.d.ts +77 -0
  105. package/lib/types/src/client/sidebar-entry.d.ts +13 -0
  106. package/lib/types/src/client/text.d.ts +9 -0
  107. package/lib/types/src/comic-presets.d.ts +12 -0
  108. package/lib/types/src/docx.d.ts +19 -0
  109. package/lib/types/src/engine.d.ts +402 -0
  110. package/lib/types/src/index.d.ts +79 -0
  111. package/lib/types/src/manga-genre-rules.d.ts +22 -0
  112. package/lib/types/src/novel-context.d.ts +80 -0
  113. package/lib/types/src/prompt-utils.d.ts +35 -0
  114. package/lib/types/src/protocol.d.ts +2176 -0
  115. package/lib/types/src/review-policy.d.ts +97 -0
  116. package/lib/types/src/routes.d.ts +29 -0
  117. package/lib/types/src/run.d.ts +32 -0
  118. package/lib/types/src/shot-language.d.ts +46 -0
  119. package/lib/types/src/story-beat-language.d.ts +35 -0
  120. package/lib/types/src/style-library.d.ts +33 -0
  121. package/lib/types/story-beat-language.d.ts +35 -0
  122. package/lib/types/style-library.d.ts +33 -0
  123. package/package.json +57 -42
  124. package/scripts/patch-schemastery.mjs +47 -0
  125. package/src/ai-scan.ts +179 -0
  126. package/src/assets.ts +1774 -518
  127. package/src/assistant.ts +915 -547
  128. package/src/author-assets.ts +147 -0
  129. package/src/bookshelf.ts +32 -2
  130. package/src/client/api.ts +666 -254
  131. package/src/client/index.ts +3 -1
  132. package/src/client/llmLive.ts +101 -0
  133. package/src/client/locales.ts +178 -31
  134. package/src/client/mount.tsx +1 -1
  135. package/src/client/panel/AdaptModeView.tsx +535 -0
  136. package/src/client/panel/AssetsTab.tsx +168 -51
  137. package/src/client/panel/AssistantTab.tsx +339 -188
  138. package/src/client/panel/AuthorAssetsView.tsx +208 -0
  139. package/src/client/panel/AuthorHome.tsx +234 -0
  140. package/src/client/panel/BookAnalysisView.tsx +60 -0
  141. package/src/client/panel/BookshelfBar.tsx +63 -9
  142. package/src/client/panel/CreateBookView.tsx +371 -0
  143. package/src/client/panel/DirectorView.tsx +200 -0
  144. package/src/client/panel/GlobalAssetLibraryView.tsx +172 -0
  145. package/src/client/panel/IdeaInspirationView.tsx +71 -0
  146. package/src/client/panel/ImportModal.tsx +303 -0
  147. package/src/client/panel/KnowledgeBaseView.tsx +73 -0
  148. package/src/client/panel/LiveFeedLog.tsx +67 -0
  149. package/src/client/panel/MarketRadarView.tsx +374 -0
  150. package/src/client/panel/ModelManager.tsx +205 -0
  151. package/src/client/panel/NovelPanel.tsx +4713 -990
  152. package/src/client/panel/ProgressConsole.tsx +63 -0
  153. package/src/client/panel/ProgressHomeView.tsx +87 -0
  154. package/src/client/panel/ReaderView.tsx +306 -0
  155. package/src/client/panel/ReasoningSection.tsx +31 -0
  156. package/src/client/panel/RunPanel.tsx +204 -0
  157. package/src/client/panel/SettingsView.tsx +265 -0
  158. package/src/client/panel/ShelfView.tsx +242 -0
  159. package/src/client/panel/WorldTab.tsx +202 -0
  160. package/src/client/panel/helpers.ts +50 -0
  161. package/src/client/panel/panel.module.css +4325 -526
  162. package/src/client/panel/views.tsx +346 -0
  163. package/src/client/run-status.ts +100 -0
  164. package/src/client/sidebar-entry.ts +1 -1
  165. package/src/client/text.ts +28 -0
  166. package/src/engine.ts +4230 -1019
  167. package/src/global-assets.ts +59 -0
  168. package/src/index.ts +123 -9
  169. package/src/llm-live.ts +68 -0
  170. package/src/market-radar-scan.ts +41 -0
  171. package/src/market-radar-sources.ts +173 -0
  172. package/src/novel-context.ts +287 -0
  173. package/src/prompt-utils.ts +73 -0
  174. package/src/prompting.ts +159 -0
  175. package/src/protocol.ts +1998 -539
  176. package/src/review-policy.ts +161 -0
  177. package/src/routes.ts +3277 -955
  178. package/src/run.ts +338 -0
  179. package/lib/client.js.map +0 -1
  180. package/lib/index.js.map +0 -1
@@ -0,0 +1,97 @@
1
+ /**
2
+ * 审稿规则注册表
3
+ *
4
+ * 生成用 compact 模式(核心规则),审稿用 full 模式(全部规则),
5
+ * 消除 reviewSystemPrompt 内嵌规则与 renderAllAssets() 两套打架的问题。
6
+ */
7
+ /** 通用写作资产规则(兼容 ProjectAssets 中的各类规则) */
8
+ export interface WritingRule {
9
+ name: string;
10
+ description: string;
11
+ type?: string;
12
+ enabled?: boolean;
13
+ }
14
+ export interface ReviewRule {
15
+ id: string;
16
+ /** 规则维度 */
17
+ dimension: 'character' | 'setting' | 'redline' | 'writing' | 'pacing' | 'logic' | 'anti-ai' | 'presentation' | 'compliance';
18
+ /** 严重度 */
19
+ severity: 'high' | 'medium' | 'low';
20
+ /** 规则类型:forbidden=禁止类(命中即问题),encourage=鼓励类(不命中不算错) */
21
+ type: 'forbidden' | 'encourage';
22
+ /** 规则描述 */
23
+ description: string;
24
+ /** 是否启用 */
25
+ enabled: boolean;
26
+ /** 作用域 */
27
+ scope: Array<'writing' | 'review' | 'polish' | 'all'>;
28
+ }
29
+ /** 内置审稿维度(结构化评分用) */
30
+ export declare const REVIEW_DIMENSIONS: readonly [{
31
+ readonly id: "character";
32
+ readonly name: "人设一致性";
33
+ readonly weight: 0.2;
34
+ }, {
35
+ readonly id: "setting";
36
+ readonly name: "设定一致性";
37
+ readonly weight: 0.15;
38
+ }, {
39
+ readonly id: "redline";
40
+ readonly name: "红线检查";
41
+ readonly weight: 0.15;
42
+ }, {
43
+ readonly id: "writing";
44
+ readonly name: "文笔质量";
45
+ readonly weight: 0.15;
46
+ }, {
47
+ readonly id: "pacing";
48
+ readonly name: "节奏与爽点";
49
+ readonly weight: 0.1;
50
+ }, {
51
+ readonly id: "logic";
52
+ readonly name: "逻辑漏洞";
53
+ readonly weight: 0.1;
54
+ }, {
55
+ readonly id: "anti-ai";
56
+ readonly name: "反 AI 规则";
57
+ readonly weight: 0.05;
58
+ }, {
59
+ readonly id: "presentation";
60
+ readonly name: "呈现方式";
61
+ readonly weight: 0.05;
62
+ }, {
63
+ readonly id: "compliance";
64
+ readonly name: "内容合规";
65
+ readonly weight: 0.05;
66
+ }];
67
+ export type ReviewDimensionId = typeof REVIEW_DIMENSIONS[number]['id'];
68
+ /** 维度结构化评分 */
69
+ export interface DimensionScore {
70
+ dimension: ReviewDimensionId;
71
+ score: number;
72
+ note: string;
73
+ }
74
+ /**
75
+ * 渲染审稿规则(compact 或 full 模式)
76
+ *
77
+ * compact: 只渲染禁止类 + high 严重度(用于生成时的约束)
78
+ * full: 渲染全部启用规则(用于审稿时的检查清单)
79
+ */
80
+ export declare function renderReviewRules(assets: WritingRule[] | undefined, mode?: 'compact' | 'full'): string;
81
+ /**
82
+ * 从审稿 issues 中按维度统计
83
+ * 用于结构化评分和 UI 展示。
84
+ */
85
+ export declare function groupIssuesByDimension(issues: Array<{
86
+ severity: string;
87
+ item: string;
88
+ dimension?: string;
89
+ }>): Record<string, Array<{
90
+ severity: string;
91
+ item: string;
92
+ }>>;
93
+ /**
94
+ * 计算维度加权总分
95
+ * 用于审稿报告的结构化评分。
96
+ */
97
+ export declare function calculateWeightedScore(dimensions: DimensionScore[]): number;
@@ -0,0 +1,32 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { NovelConfig, RunState } from './protocol.ts';
3
+ export declare class ProductionRunner {
4
+ private deps;
5
+ private state;
6
+ private working;
7
+ private pauseRequested;
8
+ private stopRequested;
9
+ /** 生产单绑定目录(start 时快照;所有读写固定用它,防止运行中切书导致写错目录)。 */
10
+ private bookDir;
11
+ constructor(deps: {
12
+ ctx: Context;
13
+ getConfig: () => NovelConfig;
14
+ });
15
+ /** 当前生产单状态(内存优先;web 重启后从磁盘恢复)。 */
16
+ status(): RunState | null;
17
+ private persist;
18
+ private log;
19
+ /** 启动/续跑生产单:startNo..endNo 区间,endNo 超出计划时先自动补计划。 */
20
+ start(startNo: number, endNo: number, runDir?: string): Promise<RunState>;
21
+ pause(): void;
22
+ resume(): void;
23
+ stop(): void;
24
+ /** 主循环:从 currentNo 扫描到 endNo,逐章处理;支持暂停/停止。 */
25
+ private loop;
26
+ private processChapter;
27
+ /** 完整质量门:生成 → 摘要+事实 → 伏笔标记 → 审稿 → 作者复盘。 */
28
+ private produce;
29
+ /** 被拒分级处理:无 high 豁免;有 high 按意见修订(最多 2 轮)+ 验证模式;仍不过 → 待人工。 */
30
+ private handleRejected;
31
+ private applyDraft;
32
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * 镜头语言词库(分镜规范化基准)。
3
+ * 分镜表的 shot/camera/composition/light 字段统一从这里取值(英文 id),
4
+ * 生成提示词时用 zh 中文词块;适配英文平台时用 en。
5
+ * 目的:让"景别/运镜/构图/光效"有标准词表,避免 LLM 自由发挥导致漂移。
6
+ */
7
+ /** 景别。 */
8
+ export type ShotSizeId = 'extreme_wide' | 'wide' | 'full' | 'medium' | 'medium_close' | 'close' | 'extreme_close' | 'big_extreme_close';
9
+ /** 运镜/机位。 */
10
+ export type CameraMoveId = 'static' | 'dolly_in' | 'dolly_out' | 'pan_left' | 'pan_right' | 'track_left' | 'track_right' | 'follow' | 'pedestal_up' | 'pedestal_down' | 'orbit' | 'handheld' | 'low_angle' | 'high_angle' | 'over_shoulder';
11
+ /** 构图。 */
12
+ export type CompositionId = 'rule_of_thirds' | 'center' | 'leading_line' | 'foreground' | 'low' | 'overhead' | 'symmetry';
13
+ /** 光效。 */
14
+ export type LightingId = 'front' | 'side' | 'back' | 'top' | 'rembrandt' | 'neon' | 'hard' | 'soft' | 'mood' | 'contrast';
15
+ export interface ShotLangEntry<T extends string> {
16
+ id: T;
17
+ /** 中文(提示词/展示用)。 */
18
+ zh: string;
19
+ /** 英文(英文平台适配用)。 */
20
+ en: string;
21
+ /** 一句话说明(下拉/卡片)。 */
22
+ hint: string;
23
+ }
24
+ export declare const SHOT_SIZES: readonly ShotLangEntry<ShotSizeId>[];
25
+ export declare const CAMERA_MOVES: readonly ShotLangEntry<CameraMoveId>[];
26
+ export declare const COMPOSITIONS: readonly ShotLangEntry<CompositionId>[];
27
+ export declare const LIGHTINGS: readonly ShotLangEntry<LightingId>[];
28
+ export interface ShotLanguage {
29
+ shot?: ShotSizeId;
30
+ camera: CameraMoveId[];
31
+ composition?: CompositionId;
32
+ light: LightingId[];
33
+ }
34
+ /** 从中文文本归一化到景别(处理旧数据/LLM 口语)。未知回退 medium。 */
35
+ export declare function normalizeShotSize(text: string | undefined): ShotSizeId;
36
+ /** 从中文文本归一化到运镜列表。 */
37
+ export declare function normalizeCameras(text: string | undefined): CameraMoveId[];
38
+ /** 从中文文本归一化到构图(可选)。 */
39
+ export declare function normalizeComposition(text: string | undefined): CompositionId | undefined;
40
+ /** 从中文文本归一化到光效列表。 */
41
+ export declare function normalizeLightings(text: string | undefined): LightingId[];
42
+ /** 取词条中文(ZHs 合并句子)。 */
43
+ export declare function sizeZh(id: ShotSizeId | undefined): string;
44
+ export declare function cameraZh(ids: CameraMoveId[] | undefined): string;
45
+ export declare function compoZh(id: CompositionId | undefined): string;
46
+ export declare function lightZh(ids: LightingId[] | undefined): string;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 本地 AI 味扫描器(不调 LLM,确定性检测)
3
+ *
4
+ * 用途:生成/润色后自动扫描,结果作为「事实锚点」注入审稿提示词,
5
+ * 让 LLM 做判断而非机械统计。也可用于 UI 展示 AI 味指标。
6
+ */
7
+ export interface AiScanResult {
8
+ /** 总评分 0-100,越高越像 AI 写的 */
9
+ aiScore: number;
10
+ /** 命中的套话及次数 */
11
+ clicheHits: Array<{
12
+ word: string;
13
+ count: number;
14
+ }>;
15
+ /** 段落长度方差(过高=段落过于整齐) */
16
+ paragraphLengthVariance: number;
17
+ /** 连续解释性叙事段数(≥3 视为问题) */
18
+ consecutiveExpositoryParagraphs: number;
19
+ /** 句式重复率(相同开头句式占比) */
20
+ sentenceRepetitionRate: number;
21
+ /** 过长段落数(>300字) */
22
+ longParagraphCount: number;
23
+ /** 过短段落数(<20字) */
24
+ shortParagraphCount: number;
25
+ /** 对话占比(0-1) */
26
+ dialogueRatio: number;
27
+ /** 问题摘要,可直接注入审稿提示词 */
28
+ summary: string;
29
+ }
30
+ export declare function scanAiFlavor(text: string): AiScanResult;
31
+ /** 扫描前后对比(润色时用) */
32
+ export declare function compareAiScan(before: AiScanResult, after: AiScanResult): {
33
+ improved: boolean;
34
+ deltaScore: number;
35
+ details: string[];
36
+ };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Writing assets — 题材基底库 / 推进模式库 / 反 AI 规则 / 写法引擎.
3
+ *
4
+ * Ported from AI-Novel-Writing-Assistant (Apache-2.0) built-in seed data:
5
+ * - 8 preset style templates (DEFAULT_STYLE_TEMPLATES)
6
+ * - 12 anti-AI rules with concrete detect patterns (DEFAULT_ANTI_AI_RULES)
7
+ * - genre tree + progression mode seeds
8
+ * Assets persist with the project (novel-project.json) and are injected into
9
+ * generation / planning / review prompts, and available to the AI assistant.
10
+ */
11
+ import type { AntiAiRule, GenreNode, PlotBeatTemplate, ProgressionMode, ProjectAssets, StyleAsset, StyleTemplate } from './protocol.ts';
12
+ /** 预置写法模板(来自 AI-Novel-Writing-Assistant 内置 DEFAULT_STYLE_TEMPLATES)。 */
13
+ export declare const BUILTIN_STYLE_TEMPLATES: StyleTemplate[];
14
+ /** 内置全局反 AI 规则(来自 AI-Novel-Writing-Assistant 内置 DEFAULT_ANTI_AI_RULES)。 */
15
+ export declare const BUILTIN_ANTI_AI_RULES: AntiAiRule[];
16
+ /** 内置题材基底库(常用网文题材树,跨书复用)。 */
17
+ export declare const BUILTIN_GENRE_LIBRARY: GenreNode[];
18
+ /** 内置常用推进模式。 */
19
+ export declare const BUILTIN_PROGRESSION_MODES: ProgressionMode[];
20
+ /** 剧情桥段库:可复用情节套路(作者阅读经验沉淀,非某本书的剧情线)。 */
21
+ export declare const BUILTIN_PLOT_BEATS: PlotBeatTemplate[];
22
+ /** 默认(空)项目写作资产。 */
23
+ export declare function emptyProjectAssets(): ProjectAssets;
24
+ /** 合并项目资产与内置库:返回「生效的反 AI 规则」(内置全局 + 项目自定义)。 */
25
+ export declare function effectiveAntiAiRules(assets: ProjectAssets | undefined): AntiAiRule[];
26
+ /** 把生效规则渲染成提示词块(禁止/鼓励分列,压缩省 token)。 */
27
+ export declare function renderAntiAiRules(assets: ProjectAssets | undefined): string;
28
+ /** 渲染题材与推进模式提示词块。 */
29
+ export declare function renderGenreAndProgression(assets: ProjectAssets | undefined): string;
30
+ /** 渲染写法资产提示词块(规则去重,省 token)。 */
31
+ export declare function renderStyleAssets(assets: ProjectAssets | undefined): string;
32
+ /** 渲染全部写作资产提示词(供生成/规划/审稿注入)。 */
33
+ export declare function renderAllAssets(assets: ProjectAssets | undefined): string;
34
+ /** 预置写法模板 → 可直接绑定的 StyleAsset。 */
35
+ export declare function styleTemplateToAsset(template: StyleTemplate): StyleAsset;
36
+ /** 写法引擎:从样本文本提取风格资产的系统提示词。 */
37
+ export declare function styleEngineSystemPrompt(): string;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * AI assistant engine — a conversational editor over the novel project.
3
+ *
4
+ * The user talks to the assistant about plot, characters, settings; the
5
+ * assistant can reply in prose AND emit action directives that the host
6
+ * executes (rewrite a paragraph, edit the bible, regenerate a chapter,
7
+ * export the book, ...). Conversation history persists next to the project
8
+ * as NDJSON, so a reload keeps the thread.
9
+ *
10
+ * Action protocol: the model emits a line of the form
11
+ * <dsh-action name="toolName">{jsonArgs}</dsh-action>
12
+ * anywhere in its reply. The host strips it, executes the tool, appends the
13
+ * result as a tool-role message, and continues the loop (bounded rounds).
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis';
16
+ import type { AssistantMessage, NovelConfig, ProjectState } from './protocol.ts';
17
+ import { chapterFileName } from './engine.ts';
18
+ /** History file name inside the output dir. */
19
+ export declare const ASSISTANT_HISTORY_FILE = "novel-assistant.jsonl";
20
+ /** Load the persisted conversation (empty when none). */
21
+ export declare function loadAssistantHistory(outputDir: string): AssistantMessage[];
22
+ /** 清空助手对话记录(删除历史文件)。 */
23
+ export declare function clearAssistantHistory(outputDir: string): void;
24
+ /** Execute one action directive. Returns a text result (or throws). */
25
+ /**
26
+ * Execute one action directive as an async generator: yields live progress
27
+ * text (chapter text being generated/rewritten), then yields the final result
28
+ * string. Throws on failure.
29
+ */
30
+ export declare function executeAction(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, name: string, args: Record<string, unknown>): AsyncGenerator<string, string, unknown>;
31
+ /** Run one user turn. Yields stream frames; persists history. */
32
+ export declare function runAssistantTurn(ctx: Context, config: NovelConfig, project: ProjectState, outputDir: string, userMessage: string): AsyncGenerator<{
33
+ frame: 'delta';
34
+ text: string;
35
+ } | {
36
+ frame: 'tool';
37
+ name: string;
38
+ status: 'start' | 'done' | 'error';
39
+ detail?: string;
40
+ } | {
41
+ frame: 'toolDelta';
42
+ name: string;
43
+ text: string;
44
+ }, void, unknown>;
45
+ export { chapterFileName };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 作者资产库/总数据(跨书)— 按作者维度聚合的可复用资产。
3
+ * 与书架同惯例持久化到 ~/.dsh/dsh-novel-forge-author-assets.json。
4
+ * 提供读取/持久化/新增或更新/删除,以及「导入默认」:把书架书的写作资产/角色 +
5
+ * 内置全局库(题材/反AI规则/风格模板/推进模式)批量沉淀成资产条目(默认库)。
6
+ */
7
+ import type { AuthorAssetLibrary, AuthorStyleAsset } from './protocol.ts';
8
+ /** 作者资产库配置文件路径。 */
9
+ export declare function authorAssetsFile(): string;
10
+ /** 读取作者资产库(不存在/损坏则返回空库,不抛错)。 */
11
+ export declare function loadAuthorAssets(): AuthorAssetLibrary;
12
+ /** 持久化作者资产库。 */
13
+ export declare function saveAuthorAssets(library: AuthorAssetLibrary): void;
14
+ /** 新建一条资产(自动生成 id 与时间戳)。 */
15
+ export declare function createAuthorAsset(input: Omit<AuthorStyleAsset, 'id' | 'createdAt' | 'updatedAt'>): AuthorStyleAsset;
16
+ /** 按 id 更新一条资产;不存在则追加。 */
17
+ export declare function upsertAuthorAsset(input: AuthorStyleAsset): AuthorAssetLibrary;
18
+ /** 删除一条资产;返回更新后的资产库。 */
19
+ export declare function removeAuthorAsset(id: string): AuthorAssetLibrary;
20
+ /**
21
+ * 导入默认:把书架所有书的写作资产/角色 + 内置全局库批量沉淀到作者资产库。
22
+ * 按 `kind:name` 去重(已存在则跳过),不覆盖用户已有条目。
23
+ * @returns 更新后的资产库。
24
+ */
25
+ export declare function importDefaultAuthorAssets(): AuthorAssetLibrary;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * 书架(Bookshelf)— 多书管理:一本书记录一个独立输出目录。
3
+ * 状态持久化到 ~/.dsh/dsh-novel-forge-bookshelf.json(跟随 dsh 配置惯例)。
4
+ */
5
+ import type { BookEntry, BookshelfSnapshot } from './protocol.ts';
6
+ /** 书架配置文件路径。 */
7
+ export declare function bookshelfFile(): string;
8
+ interface BookshelfStore {
9
+ books: BookEntry[];
10
+ activeBookId: string | null;
11
+ }
12
+ /** 读取书架(无则返回空)。 */
13
+ export declare function loadBookshelf(): BookshelfStore;
14
+ /** 当前激活的书。 */
15
+ export declare function activeBook(store: BookshelfStore): BookEntry | undefined;
16
+ /** 书架快照(含每本书的进度摘要)。 */
17
+ export declare function bookshelfSnapshot(store: BookshelfStore): BookshelfSnapshot;
18
+ /** 新建一本书(自动成为当前书)。 */
19
+ export declare function createBook(bookName: string, outputDir: string): BookEntry;
20
+ /** 更新某本书的书名(开书向导导入大纲后书名以大纲首行为准)。 */
21
+ export declare function renameBook(id: string, bookName: string): boolean;
22
+ /**
23
+ * 播种:书架为空时,把指定输出目录下已有的项目自动登记为第一本书。
24
+ * 兼容升级场景 —— 旧版插件直接在输出目录写项目,从未登记书架。
25
+ * @param outputDir - 候选输出目录(通常为 settings 的默认输出目录)。
26
+ * @returns 是否发生了播种。
27
+ */
28
+ export declare function seedBookshelfFromOutputDir(outputDir: string): boolean;
29
+ /** 导入已有项目目录到书架:校验 novel-project.json,已存在则直接激活。 */
30
+ export declare function importDir(outputDir: string): {
31
+ book: BookEntry;
32
+ existed: boolean;
33
+ };
34
+ /** 激活一本书。 */
35
+ export declare function activateBook(id: string): BookEntry | undefined;
36
+ /** 移除一本书。 */
37
+ export declare function removeBook(id: string): boolean;
38
+ /** 当前书输出目录(无书架则 undefined,回退 settings)。 */
39
+ export declare function activeBookOutputDir(): string | undefined;
40
+ /** 默认输出目录推断:~/.dsh/novels/书名。 */
41
+ export declare function defaultOutputDirFor(bookName: string): string;
42
+ export {};
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Browser-side API client for the /api/dsh-novel-forge route family. Plain
3
+ * fetch, same origin; generation/rewrite/polish ride NDJSON streams read
4
+ * incrementally.
5
+ */
6
+ import { type AssetsPatch, type AssetsResponse, type AddModelRequest, type AddModelResponse, type LlmModelsResponse, type LlmProvidersResponse, type LlmVendorsResponse, type RemoveProviderRequest, type RemoveProviderResponse, type BibleResponse, type ChapterResponse, type ConfigPatch, type ExportResponse, type ForeshadowRequest, type ForeshadowResponse, type JobFrame, type LoadOutlineResponse, type AdaptExecuteRequest, type AdaptRewriteFrame, type AdaptMaterializeSaveRequest, type AdaptMaterializeSaveResponse, type PluginUpdateResponse, type LlmTestResponse, type NovelConfig, type PlanResponse, type ReviewReport, type StatusResponse, type StyleEngineRequest, type StyleAsset, type VolumesResponse } from '../protocol.ts';
7
+ /** Error carrying the route's JSON error message. */
8
+ export declare class NovelApiError extends Error {
9
+ constructor(message: string);
10
+ }
11
+ /** The browser half's only data entry point. */
12
+ export declare class NovelApi {
13
+ status(): Promise<StatusResponse>;
14
+ loadOutline(path?: string, text?: string): Promise<LoadOutlineResponse>;
15
+ saveOutline(text: string): Promise<{
16
+ ok: boolean;
17
+ bookName: string;
18
+ }>;
19
+ /** 反推大纲:从已写章节正文反向生成全书总纲(NDJSON 流)。 */
20
+ outlineReverse(onFrame: (frame: JobFrame) => void): Promise<void>;
21
+ /** 分镜·导演级:骨架 → 分镜表(镜头级)。 */
22
+ storyboardTable(chapterNo: number, skeleton: import('../protocol.ts').StoryboardSkeleton, styleId?: string, filterId?: string): Promise<import('../protocol.ts').StoryboardTableResponse>;
23
+ /** 漫剧方案管理:create / remove / activate。 */
24
+ manhuaPlans(req: import('../protocol.ts').MangaPlansRequest): Promise<import('../protocol.ts').MangaPlansResponse>;
25
+ /** 分镜·提示词级:分镜表 → 即梦可粘贴视频提示词。 */
26
+ storyboardPrompts(chapterNo: number, table: import('../protocol.ts').StoryboardTable, styleId?: string, filterId?: string): Promise<import('../protocol.ts').StoryboardPromptsResponse>;
27
+ /** 分镜·编剧级:单章 → 剧情骨架(节拍链)。 */
28
+ storyboardSkeleton(chapterNo: number): Promise<import('../protocol.ts').StoryboardSkeletonResponse>;
29
+ /** 开书想法 → AI 大纲:生成 count 个方案(换批时传 exclude 避开已暂留方向)。 */
30
+ outlineSuggest(idea: string, count?: number, exclude?: string[]): Promise<import('../protocol.ts').OutlineSuggestResponse>;
31
+ /** 拆书分析:对已写章节做结构/人物/文风/卖点体检。 */
32
+ breakdown(scope?: string, preset?: 'quick' | 'standard', budgetTokens?: number): Promise<import('../protocol.ts').BreakdownResponse>;
33
+ plan(outline?: string, chapterCount?: number, volume?: number): Promise<PlanResponse>;
34
+ volumes(outline?: string): Promise<VolumesResponse>;
35
+ bible(outline?: string): Promise<BibleResponse>;
36
+ review(chapterNo: number): Promise<{
37
+ report: ReviewReport;
38
+ }>;
39
+ summarize(chapterNo: number): Promise<{
40
+ summary: string;
41
+ }>;
42
+ foreshadow(req: ForeshadowRequest): Promise<ForeshadowResponse>;
43
+ exportBook(format: 'txt' | 'md'): Promise<ExportResponse>;
44
+ chapter(no: number): Promise<ChapterResponse>;
45
+ /** 审查手动编辑的正文(不落盘)。previousReport 传入时走「验证模式」(核对原意见解决 + 只挑新增 high)。 */
46
+ chapterCheck(no: number, text: string, previousReport?: ReviewReport): Promise<{
47
+ report: ReviewReport;
48
+ }>;
49
+ /** 保存手动编辑的正文(自动备份 .bak;带报告则沿用落盘,否则保存后自动审稿)。 */
50
+ chapterSave(no: number, text: string, report?: ReviewReport): Promise<import('../protocol.ts').ChapterSaveResponse>;
51
+ patchConfig(patch: ConfigPatch): Promise<{
52
+ config: NovelConfig;
53
+ }>;
54
+ openFolder(): Promise<void>;
55
+ /** 插件自更新:在 DSH profile 目录拉取最新 npm 版(需重启 DSH 生效)。 */
56
+ pluginUpdate(): Promise<PluginUpdateResponse>;
57
+ /** 书架快照。 */
58
+ bookshelf(): Promise<import('../protocol.ts').BookshelfSnapshot>;
59
+ /** 新建书并激活(开书向导:可携带大纲文本,创建即建项目)。 */
60
+ bookCreate(bookName: string, outputDir?: string, outline?: string): Promise<import('../protocol.ts').BookshelfSnapshot>;
61
+ /** 重置项目(清空进度;可携带新大纲)。 */
62
+ reset(outline?: string): Promise<{
63
+ ok: boolean;
64
+ bookName: string;
65
+ }>;
66
+ /** 全书一致性质检。 */
67
+ audit(): Promise<import('../protocol.ts').AuditResponse>;
68
+ /** 角色卡刷新(基于事实库聚合)。 */
69
+ charactersRefresh(): Promise<{
70
+ cards: import('../protocol.ts').RoleStatusCard[];
71
+ }>;
72
+ /** 事实库回填:对历史已生成章节批量抽取事实。 */
73
+ factsBackfill(): Promise<{
74
+ ok: boolean;
75
+ filled: number;
76
+ }>;
77
+ /** 道藏局部修补。 */
78
+ biblePatch(patch: import('../protocol.ts').BiblePatchRequest): Promise<{
79
+ bible: import('../protocol.ts').StoryBible;
80
+ }>;
81
+ /** 剧情线管理:增删改 + 关联章节。 */
82
+ plotlines(req: import('../protocol.ts').PlotlinesRequest): Promise<import('../protocol.ts').PlotlinesResponse>;
83
+ /** 敏感词检查:指定章节 / 任意文本 / 全书。 */
84
+ sensitiveCheck(req: import('../protocol.ts').SensitiveCheckRequest): Promise<import('../protocol.ts').SensitiveCheckResponse>;
85
+ /** 作者复盘补跑:单章(JSON)。 */
86
+ reviewBackfillChapter(no: number): Promise<{
87
+ no: number;
88
+ review: import('../protocol.ts').AuthorReview;
89
+ }>;
90
+ /** 作者复盘补跑:全书缺失章节(NDJSON 流)。 */
91
+ reviewBackfillAll(onFrame: (frame: JobFrame) => void): Promise<void>;
92
+ /** 章节复位:generating 卡死 → pending。 */
93
+ chapterReset(no: number): Promise<{
94
+ ok: boolean;
95
+ no: number;
96
+ }>;
97
+ /** 章节直接通过(作者行使最终决定权)。 */
98
+ chapterApprove(no: number): Promise<{
99
+ ok: boolean;
100
+ no: number;
101
+ }>;
102
+ /** 角色库:AI 提炼 / 采纳 / 更新 / 删除。 */
103
+ imageTest(req: import('../protocol.ts').ImageTestRequest): Promise<import('../protocol.ts').ImageTestResponse>;
104
+ /** 对选中的提供商/模型发一次最小真实调用,验证连通性。 */
105
+ llmTest(provider: string, model: string): Promise<LlmTestResponse>;
106
+ /** 添加模型:厂商直填 key,或自定义 OpenAI 兼容路由(写 DSH 凭据 + 注册路由)。 */
107
+ addModel(req: AddModelRequest): Promise<AddModelResponse>;
108
+ /** 运行时厂商目录(DSH pi-ai 可配置提供方 + 内置适配器)。 */
109
+ llmVendors(): Promise<LlmVendorsResponse>;
110
+ /** 查询某个 provider 当前可用的模型(添加成功后可即时刷新)。 */
111
+ llmModels(provider: string): Promise<LlmModelsResponse>;
112
+ /** 已注册的提供方路由列表(提供方管理卡片)。 */
113
+ llmProviders(): Promise<LlmProvidersResponse>;
114
+ /** 移除一个提供方(unset key + 移除 llm-pi-ai 路由)。 */
115
+ removeProvider(req: RemoveProviderRequest): Promise<RemoveProviderResponse>;
116
+ roles(req: import('../protocol.ts').RolesRequest): Promise<import('../protocol.ts').RolesResponse>;
117
+ /** 漫剧角色库:从分镜提名 / 建卡 / 更新 / 删除 / 形象锚点 / 精修提示词。 */
118
+ mangaRoles(req: import('../protocol.ts').MangaRolesRequest): Promise<import('../protocol.ts').MangaRolesResponse>;
119
+ /** 导出「即梦素材包」落盘到资产库 manga-assets/素材包/。 */
120
+ exportPackage(chapterNo: number, title: string, markdown: string): Promise<{
121
+ ok: boolean;
122
+ file: string;
123
+ }>;
124
+ /** 场景库:AI 提炼 / 采纳 / 更新 / 删除 / 图集。 */
125
+ scenes(req: import('../protocol.ts').ScenesRequest): Promise<import('../protocol.ts').ScenesResponse>;
126
+ /** 视觉世界观规则:提炼 / 保存。 */
127
+ visualRules(req: import('../protocol.ts').VisualRulesRequest): Promise<import('../protocol.ts').VisualRulesResponse>;
128
+ /** 道具库:从已写章节提炼常驻道具 / 保存清单。 */
129
+ mangaProps(req: import('../protocol.ts').MangaPropsRequest): Promise<import('../protocol.ts').MangaPropsResponse>;
130
+ /** 小说简介:AI 生成/补全(partial 留空 = 全量),或手动保存。 */
131
+ blurb(action: 'generate' | 'save', text?: string, partial?: string): Promise<{
132
+ blurb: string;
133
+ }>;
134
+ /** 封面:读取(dataUrl;dir 指定某本书的输出目录,省略为当前书)。 */
135
+ coverGet(dir?: string): Promise<import('../protocol.ts').CoverResponse>;
136
+ /** 封面:上传(base64 data URL)或移除。 */
137
+ coverPost(action: 'upload' | 'remove', dataUrl?: string): Promise<{
138
+ ok: boolean;
139
+ coverPath?: string | null;
140
+ }>;
141
+ /** 重命名当前书(同步项目与书架条目)。 */
142
+ rename(bookName: string): Promise<{
143
+ bookName: string;
144
+ }>;
145
+ /** 大世界:AI 提炼(generate)或手动保存(save)。 */
146
+ world(action: 'generate' | 'save', world?: import('../protocol.ts').WorldState): Promise<{
147
+ world: import('../protocol.ts').WorldState;
148
+ }>;
149
+ /** 切换当前书。 */
150
+ bookActivate(id: string): Promise<import('../protocol.ts').BookshelfSnapshot>;
151
+ /** 移除书架条目。 */
152
+ bookRemove(id: string): Promise<import('../protocol.ts').BookshelfSnapshot>;
153
+ /** 导入已有项目目录(Mode A):校验 novel-project.json,登记/激活书架。 */
154
+ bookImportDir(outputDir: string): Promise<import('../protocol.ts').BookImportDirResponse>;
155
+ /** 导入 txt/md 全本(Mode B):服务器本地文件路径模式。 */
156
+ bookImportText(filePath: string, outputDir?: string): Promise<import('../protocol.ts').BookImportTextResponse>;
157
+ /** 拆章预览(浏览器上传全文,不落盘):返回识别到的章节与跳过清单。 */
158
+ bookImportTextPreview(text: string, fileName?: string): Promise<import('../protocol.ts').BookImportTextPreviewResponse>;
159
+ /** 导入 txt/md 全本(Mode B):浏览器上传全文内容模式。 */
160
+ bookImportTextContent(text: string, fileName: string, outputDir?: string): Promise<import('../protocol.ts').BookImportTextResponse>;
161
+ /** 生产单:启动批量生产(区间或新增 N 章;计划不足自动补)。 */
162
+ runStart(req: import('../protocol.ts').RunStartRequest): Promise<import('../protocol.ts').RunState>;
163
+ /** 生产单控制:pause / resume / stop。 */
164
+ runControl(action: 'pause' | 'resume' | 'stop'): Promise<import('../protocol.ts').RunState | null>;
165
+ /** 生产单状态(无生产单返回 null)。 */
166
+ runStatus(): Promise<import('../protocol.ts').RunState | null>;
167
+ /** Get project writing assets + built-in libraries. */
168
+ assets(): Promise<AssetsResponse>;
169
+ /** Patch project writing assets. */
170
+ patchAssets(patch: AssetsPatch): Promise<AssetsResponse>;
171
+ /** Extract a style asset from sample text. */
172
+ styleEngine(req: StyleEngineRequest): Promise<{
173
+ styleAsset: StyleAsset;
174
+ }>;
175
+ /**
176
+ * Consume an NDJSON job stream (generate / rewrite / polish).
177
+ * @param path - the route to POST to.
178
+ * @param payload - the JSON body.
179
+ * @param onFrame - receives every frame as it lands.
180
+ */
181
+ private streamJob;
182
+ /** Generate one chapter. */
183
+ generate(chapterNo: number, skipReview: boolean, onFrame: (frame: JobFrame) => void): Promise<void>;
184
+ /** Rewrite one chapter (whole-chapter, or local when `target` is given). */
185
+ rewrite(chapterNo: number, instructions: string, target: string, onFrame: (frame: JobFrame) => void): Promise<void>;
186
+ /** Polish (de-AI-ify) one chapter. */
187
+ polish(chapterNo: number, onFrame: (frame: JobFrame) => void): Promise<void>;
188
+ /** 采纳待确认草稿(润色/重写产物),覆盖正文文件。返回采纳后的新正文(markdown)。
189
+ * 可携带审查报告(沿用结论定状态:通过 → approved)。 */
190
+ draftApply(chapterNo: number, report?: import('../protocol.ts').ReviewReport): Promise<{
191
+ ok: boolean;
192
+ chars: number;
193
+ file: string;
194
+ markdown: string;
195
+ }>;
196
+ /** 放弃待确认草稿,保留原稿。 */
197
+ draftDiscard(chapterNo: number): Promise<{
198
+ ok: boolean;
199
+ }>;
200
+ /** Run one assistant turn (NDJSON stream). */
201
+ assistant(message: string, onFrame: (frame: import('../protocol.ts').AssistantFrame) => void): Promise<void>;
202
+ /** Load the persisted assistant conversation. */
203
+ assistantHistory(): Promise<import('../protocol.ts').AssistantMessage[]>;
204
+ /** 清空助手对话记录。 */
205
+ assistantClear(): Promise<{
206
+ ok: boolean;
207
+ }>;
208
+ /** 作者资产库/总数据:读取跨书可复用资产。 */
209
+ authorAssets(): Promise<import('../protocol.ts').AuthorAssetsResponse>;
210
+ /** 作者资产库:新增/更新一条资产(upsert by id)。 */
211
+ authorAssetsUpsert(asset: import('../protocol.ts').AuthorStyleAsset): Promise<import('../protocol.ts').AuthorAssetsResponse>;
212
+ /** 作者资产库:删除一条资产。 */
213
+ authorAssetsRemove(id: string): Promise<import('../protocol.ts').AuthorAssetsResponse>;
214
+ /** 作者资产库:导入默认(书架书的写作资产/角色 + 内置全局库)批量沉淀。 */
215
+ authorAssetsImportDefault(): Promise<import('../protocol.ts').AuthorAssetsResponse>;
216
+ /** 改编模式 P0:上传全文 → 原文设定卡片 / 可改范围矩阵。 */
217
+ adaptAnalyze(text: string, filePath?: string): Promise<import('../protocol.ts').AdaptAnalyzeResponse>;
218
+ /** 改编模式 P1:确认要改的维度 → 生成映射表/改编规则/联动影响清单。 */
219
+ adaptPropose(req: import('../protocol.ts').AdaptProposeRequest): Promise<import('../protocol.ts').AdaptProposeResponse>;
220
+ /** 改编模式 P2:执行术语替换(全局替换 + 命中统计 + 改编文本预览)。 */
221
+ adaptExecute(req: import('../protocol.ts').AdaptExecuteRequest): Promise<import('../protocol.ts').AdaptExecuteResponse>;
222
+ /** 改编模式 P3:保存改编全文为新书(原书保留,登记书架)。 */
223
+ adaptSave(req: import('../protocol.ts').AdaptSaveRequest): Promise<import('../protocol.ts').AdaptSaveResponse>;
224
+ /** 改编模式 P4:从源全文 + 编辑后方案提炼新书资料并保存为「待写新书」。 */
225
+ adaptMaterialize(req: import('../protocol.ts').AdaptMaterializeRequest): Promise<import('../protocol.ts').AdaptMaterializeResponse>;
226
+ /** 改编模式:保存预览/微调后的新书资料为新书(原书保留,登记书架)。 */
227
+ adaptMaterializeSave(req: AdaptMaterializeSaveRequest): Promise<AdaptMaterializeSaveResponse>;
228
+ /** 改编模式:rewrite 逐章重写(NDJSON 流式进度,支持分段 startNo/endNo)。 */
229
+ adaptRewriteStream(req: AdaptExecuteRequest, onFrame: (frame: AdaptRewriteFrame) => void): Promise<void>;
230
+ /** 主题自定义背景:上传图片,服务端存盘并返回可访问 URL。 */
231
+ themeBackgroundUpload(dataUrl: string): Promise<{
232
+ url: string;
233
+ }>;
234
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Browser-side docx outline extraction: a .docx is a zip whose
3
+ * word/document.xml holds the body text in <w:t> runs inside <w:p> paragraphs.
4
+ * Uses fflate (inlined into the client bundle) so the user can pick or drag a
5
+ * docx without any server upload.
6
+ *
7
+ * Import from 'fflate/browser' (not 'fflate'): the default entry resolves to
8
+ * the Node build (esm/index.mjs), which calls module.createRequire() for the
9
+ * optional worker_threads path — inlining that into the browser bundle leaves
10
+ * a bare require("module") the client-modules table cannot answer.
11
+ */
12
+ /** Extract plain text from a docx buffer: one line per <w:p> paragraph. */
13
+ export declare function extractDocxTextFromBuffer(buffer: ArrayBuffer | Uint8Array): string;
14
+ /** Read a File as ArrayBuffer. */
15
+ export declare function readFileAsArrayBuffer(file: File): Promise<ArrayBuffer>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Browser-half entry for the dsh-novel-forge plugin — runs inside the dsh web
3
+ * GUI. Registers the sidebar entry row and the workbench panel. DOM mounting
4
+ * problems are logged, never thrown — the web shell fails the whole boot when
5
+ * a plugin apply throws.
6
+ */
7
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
8
+ /** Required services (fiber inject waiting). */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Mount the novel-forge workbench.
12
+ * @param ctx - client root context.
13
+ */
14
+ export declare function apply(ctx: ClientContext): void;