@waterwx/dsh-novel-forge 2.4.0 → 2.5.1
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.
- package/README.md +8 -6
- package/lib/client.js +2543 -1834
- package/lib/index.js +732 -134
- package/lib/types/assets.d.ts +5 -5
- package/lib/types/client/api.d.ts +18 -0
- package/lib/types/client/locales.d.ts +0 -1
- package/lib/types/client/panel/ChapterWorkbench.d.ts +69 -0
- package/lib/types/client/panel/NameForgeView.d.ts +11 -0
- package/lib/types/client/panel/NovelPanel.d.ts +0 -1
- package/lib/types/client/panel/StyleView.d.ts +4 -0
- package/lib/types/client/panel/WorkspaceView.d.ts +51 -0
- package/lib/types/client/panel/home-model.d.ts +53 -0
- package/lib/types/engine.d.ts +42 -2
- package/lib/types/index.d.ts +5 -1
- package/lib/types/name-forge.d.ts +110 -0
- package/lib/types/prompts/nameforge.d.ts +16 -0
- package/lib/types/protocol.d.ts +113 -1
- package/lib/types/style-fingerprint.d.ts +3 -2
- package/lib/types/style-profile.d.ts +62 -0
- package/package.json +2 -2
package/lib/types/protocol.d.ts
CHANGED
|
@@ -34,8 +34,12 @@ export declare const NOVEL_API: {
|
|
|
34
34
|
/** 张力曲线(GET 数据 / POST 设置)。 */
|
|
35
35
|
readonly tension: "/api/dsh-novel-forge/tension";
|
|
36
36
|
readonly styleHistory: "/api/dsh-novel-forge/style-history";
|
|
37
|
+
/** 风格目标卡:GET 当前卡;POST {action:'distill-archived'|'distill-sample'|'clear'}。 */
|
|
38
|
+
readonly styleProfile: "/api/dsh-novel-forge/style-profile";
|
|
37
39
|
/** 提示词槽位(GET 列表 / POST 写入)。 */
|
|
38
40
|
readonly promptSlots: "/api/dsh-novel-forge/prompt-slots";
|
|
41
|
+
/** 取名器:POST {action:'generate'} 生成候选;GET 名字库;POST {action:'adopt'|'discard'|'clear'} 维护。 */
|
|
42
|
+
readonly nameForge: "/api/dsh-novel-forge/name-forge";
|
|
39
43
|
/** 故事时间线(GET 列表 / POST 操作)。 */
|
|
40
44
|
readonly timeline: "/api/dsh-novel-forge/timeline";
|
|
41
45
|
readonly marketRadar: "/api/dsh-novel-forge/market-radar";
|
|
@@ -261,7 +265,7 @@ export interface BookImportTextPreviewResponse {
|
|
|
261
265
|
skipped: string[];
|
|
262
266
|
}
|
|
263
267
|
/** Chapter lifecycle states (the writing pipeline's state machine). */
|
|
264
|
-
export type ChapterStatus = 'pending' | 'generating' | 'written' | '
|
|
268
|
+
export type ChapterStatus = 'pending' | 'generating' | 'written' | 'approved' | 'rejected' | 'error';
|
|
265
269
|
/** One chapter in the plan. */
|
|
266
270
|
export interface ChapterPlan {
|
|
267
271
|
/** 1-based chapter number (stable identity; files are named from it). */
|
|
@@ -699,6 +703,57 @@ export interface PromptSlotsRequest {
|
|
|
699
703
|
/** 空串 = 清空该槽位(恢复默认)。 */
|
|
700
704
|
value: string;
|
|
701
705
|
}
|
|
706
|
+
/** 取名类别。 */
|
|
707
|
+
export type NameCategory = 'person' | 'place' | 'technique' | 'faction' | 'artifact';
|
|
708
|
+
/** 名字库里的一条(采纳后才注入写作提示词)。 */
|
|
709
|
+
export interface NameForgeEntry {
|
|
710
|
+
/** 稳定 id(`类别:名字`)。 */
|
|
711
|
+
id: string;
|
|
712
|
+
category: NameCategory;
|
|
713
|
+
name: string;
|
|
714
|
+
/** 命名理由/意象(20 字内为宜)。 */
|
|
715
|
+
note: string;
|
|
716
|
+
/** 是否生效(false = 已弃用,不注入)。 */
|
|
717
|
+
adopted: boolean;
|
|
718
|
+
createdAt: string;
|
|
719
|
+
}
|
|
720
|
+
/** 一次取名生成的候选(未落盘,作者采纳后才入库)。 */
|
|
721
|
+
export interface NameForgeCandidate {
|
|
722
|
+
name: string;
|
|
723
|
+
note: string;
|
|
724
|
+
}
|
|
725
|
+
/** POST /name-forge {action:'generate'} 请求。 */
|
|
726
|
+
export interface NameForgeGenerateRequest {
|
|
727
|
+
action: 'generate';
|
|
728
|
+
category: NameCategory;
|
|
729
|
+
/** 生成条数(1-20,默认 10)。 */
|
|
730
|
+
count?: number;
|
|
731
|
+
/** 作者补充要求(可空)。 */
|
|
732
|
+
hint?: string;
|
|
733
|
+
bookId?: string;
|
|
734
|
+
}
|
|
735
|
+
/** POST /name-forge 库维护请求。 */
|
|
736
|
+
export interface NameForgeMutateRequest {
|
|
737
|
+
action: 'adopt' | 'discard' | 'clear';
|
|
738
|
+
category?: NameCategory;
|
|
739
|
+
/** adopt 时的候选列表。 */
|
|
740
|
+
candidates?: NameForgeCandidate[];
|
|
741
|
+
/** discard 时的条目 id。 */
|
|
742
|
+
id?: string;
|
|
743
|
+
bookId?: string;
|
|
744
|
+
}
|
|
745
|
+
/** POST /name-forge {action:'generate'} 响应。 */
|
|
746
|
+
export interface NameForgeGenerateResponse {
|
|
747
|
+
candidates: NameForgeCandidate[];
|
|
748
|
+
}
|
|
749
|
+
/** GET /name-forge 响应:本书名字库(按类别分组由面板做)。 */
|
|
750
|
+
export interface NameForgeBankResponse {
|
|
751
|
+
entries: NameForgeEntry[];
|
|
752
|
+
}
|
|
753
|
+
/** POST /name-forge 库维护响应。 */
|
|
754
|
+
export interface NameForgeMutateResponse {
|
|
755
|
+
entries: NameForgeEntry[];
|
|
756
|
+
}
|
|
702
757
|
/**
|
|
703
758
|
* 故事时间线事件:从章节正文抽取的「故事内时间点 + 地点 + 参与角色 + 事件」。
|
|
704
759
|
* 用途:后续章节的时间连续性与地点衔接(比编年录更强调"顺序")。
|
|
@@ -1190,6 +1245,10 @@ export interface ProjectState {
|
|
|
1190
1245
|
tensionCurve?: TensionCurveConfig;
|
|
1191
1246
|
/** 作者自定义的提示词槽位(白名单见 prompt-slots.ts)。 */
|
|
1192
1247
|
promptSlots?: Partial<Record<PromptSlotId, string>>;
|
|
1248
|
+
/** 取名器名字库(按类别收录的已采纳专有名字,注入写作提示词)。 */
|
|
1249
|
+
nameBank?: NameForgeEntry[];
|
|
1250
|
+
/** 风格目标卡(显式蒸馏的生成端锚点;审稿尺子不读它,实时算)。 */
|
|
1251
|
+
styleProfile?: StyleProfile;
|
|
1193
1252
|
/** 本书参数(写作/审稿/推理/模型快切;未设字段回退全局 config)。 */
|
|
1194
1253
|
bookSettings?: BookSettings;
|
|
1195
1254
|
/** ISO timestamps. */
|
|
@@ -1809,6 +1868,8 @@ export interface ExportResponse {
|
|
|
1809
1868
|
file: string;
|
|
1810
1869
|
chars: number;
|
|
1811
1870
|
chapters: number;
|
|
1871
|
+
/** 全本导出时因文件缺失/为空被跳过的章号;无跳过项时缺省。 */
|
|
1872
|
+
skipped?: number[];
|
|
1812
1873
|
scope: ExportScope;
|
|
1813
1874
|
format: 'txt' | 'md' | 'json';
|
|
1814
1875
|
}
|
|
@@ -1823,6 +1884,8 @@ export interface ConfigPatch {
|
|
|
1823
1884
|
auditModel?: string;
|
|
1824
1885
|
/** 备用模型(主模型失败时自动切换重试一次;空串 = 关闭)。 */
|
|
1825
1886
|
fallbackModel?: string;
|
|
1887
|
+
/** 备用模型的输出 token 上限(0/空 = 沿用主模型预算)。 */
|
|
1888
|
+
fallbackMaxTokens?: number;
|
|
1826
1889
|
/** 出章后自动抽取故事时间线(默认开)。 */
|
|
1827
1890
|
autoTimeline?: boolean;
|
|
1828
1891
|
reasoningEffort?: 'off' | 'low' | 'high' | 'max';
|
|
@@ -2092,6 +2155,55 @@ export interface StyleHistoryPoint {
|
|
|
2092
2155
|
significant: string[];
|
|
2093
2156
|
}
|
|
2094
2157
|
/** 风格漂移曲线:逐章指标 + 参照基线。 */
|
|
2158
|
+
/**
|
|
2159
|
+
* 风格指纹数据(字段与 style-fingerprint.ts 的 StyleFingerprint 结构一致,
|
|
2160
|
+
* 这里复述一份是为了让协议文件不依赖宿主模块——shared vocabulary 自包含)。
|
|
2161
|
+
*/
|
|
2162
|
+
export interface StyleFingerprintData {
|
|
2163
|
+
chars: number;
|
|
2164
|
+
sentences: number;
|
|
2165
|
+
avgSentenceLength: number;
|
|
2166
|
+
sentenceLengthCv: number;
|
|
2167
|
+
shortSentenceRatio: number;
|
|
2168
|
+
dialogueRatio: number;
|
|
2169
|
+
avgParagraphLength: number;
|
|
2170
|
+
imageryPer1000: number;
|
|
2171
|
+
}
|
|
2172
|
+
/** 风格目标卡的蒸馏来源。 */
|
|
2173
|
+
export type StyleProfileSource = 'archived' | 'sample';
|
|
2174
|
+
/**
|
|
2175
|
+
* 风格目标卡:作者**显式蒸馏**的产物(不是派生视图,所以落盘)。
|
|
2176
|
+
*
|
|
2177
|
+
* 与审稿端尺子的分工:审稿用「本书已过审章节中位数」实时算(自适应尺子);
|
|
2178
|
+
* 生成端的目标由本卡提供(外部锚点)——两把尺子刻意分开,否则生成目标会跟着
|
|
2179
|
+
* 本书漂移一起走,越写越偏而且互相认证(棘轮效应)。本卡只在作者点「蒸馏」时变。
|
|
2180
|
+
*/
|
|
2181
|
+
export interface StyleProfile {
|
|
2182
|
+
/** 蒸馏来源。 */
|
|
2183
|
+
source: StyleProfileSource;
|
|
2184
|
+
/** 人类可读来源说明,如「本书已过审 12 章的中位数」。 */
|
|
2185
|
+
label: string;
|
|
2186
|
+
fingerprint: StyleFingerprintData;
|
|
2187
|
+
/** archived 来源的采样章数。 */
|
|
2188
|
+
sampleChapters?: number;
|
|
2189
|
+
updatedAt: string;
|
|
2190
|
+
}
|
|
2191
|
+
/** GET /style-profile 响应。 */
|
|
2192
|
+
export interface StyleProfileResponse {
|
|
2193
|
+
/** 当前生效的目标卡;从未蒸馏过为 null(回落资产样本文本)。 */
|
|
2194
|
+
profile: StyleProfile | null;
|
|
2195
|
+
/** 可供蒸馏的已过审章数(<3 时不可用 archived 蒸馏)。 */
|
|
2196
|
+
approvedChapters: number;
|
|
2197
|
+
/** 当前实际生效的目标说明(卡优先,否则回落样本文本或「无」)。 */
|
|
2198
|
+
effectiveLabel: string;
|
|
2199
|
+
}
|
|
2200
|
+
/** POST /style-profile 请求。 */
|
|
2201
|
+
export interface StyleProfileRequest {
|
|
2202
|
+
action: 'distill-archived' | 'distill-sample' | 'clear';
|
|
2203
|
+
/** distill-sample 时的样本文本(≥200 字)。 */
|
|
2204
|
+
text?: string;
|
|
2205
|
+
bookId?: string;
|
|
2206
|
+
}
|
|
2095
2207
|
export interface StyleHistoryResponse {
|
|
2096
2208
|
/** 基线说明,如「本书已过审 12 章的中位数」 */
|
|
2097
2209
|
baselineLabel: string;
|
|
@@ -61,10 +61,11 @@ export declare function compareStyleFingerprint(reference: StyleFingerprint, act
|
|
|
61
61
|
export declare function mergeFingerprints(items: readonly StyleFingerprint[]): StyleFingerprint;
|
|
62
62
|
/**
|
|
63
63
|
* 渲染**生成端**的风格目标(区间形式)。
|
|
64
|
-
* @param reference -
|
|
64
|
+
* @param reference - 参照指纹(写法样本或蒸馏卡)。
|
|
65
|
+
* @param sourceLabel - 参照物的人类可读说明(缺省「绑定的写法样本」)。
|
|
65
66
|
* @returns 可注入写作 prompt 的文本;样本过短时返回空串。
|
|
66
67
|
*/
|
|
67
|
-
export declare function renderFingerprintTargets(reference: StyleFingerprint): string;
|
|
68
|
+
export declare function renderFingerprintTargets(reference: StyleFingerprint, sourceLabel?: string): string;
|
|
68
69
|
/**
|
|
69
70
|
* 渲染**审稿端**的风格比对(事实锚点)。
|
|
70
71
|
*
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 风格目标卡:把「这本书的写法」蒸馏成一份**作者显式确认**的确定性指标卡,
|
|
3
|
+
* 作为生成端的风格锚点。
|
|
4
|
+
*
|
|
5
|
+
* ## 为什么生成端要一张卡,而审稿端实时算
|
|
6
|
+
*
|
|
7
|
+
* 审稿端的尺子是「本书已过审章节的中位数」(styleBaseline,engine.ts)——自适应:
|
|
8
|
+
* 书写到哪,尺子量到哪。生成端如果也用同一把尺子,会出现**棘轮效应**:某一章
|
|
9
|
+
* 对话占比偏高 → 进了中位数 → 下一章的目标跟着抬高 → 越写越偏且「生成符合目标、
|
|
10
|
+
* 审稿也符合尺子」互相认证,没有任何一方报警。
|
|
11
|
+
*
|
|
12
|
+
* 所以两边刻意分开:
|
|
13
|
+
* * 审稿 = 自适应尺子(实时算,不落盘);
|
|
14
|
+
* * 生成 = 外部锚点(本卡;只在作者点「蒸馏」时更新,是**决定**不是派生)。
|
|
15
|
+
*
|
|
16
|
+
* ## 卡的来源
|
|
17
|
+
*
|
|
18
|
+
* 1. `archived` —— 本书已过审章节等距抽样(≤12 章)的中位数:把「我现在实际
|
|
19
|
+
* 写出来的样子」固化成目标,适合写了一定时量后收紧;
|
|
20
|
+
* 2. `sample` —— 作者粘贴的参考样文本:开书阶段就想定调;
|
|
21
|
+
* 3. 无卡 —— 回落绑定写法资产的样本文本(旧行为,保持兼容)。
|
|
22
|
+
*/
|
|
23
|
+
import type { StyleProfile, StyleProfileSource, StyleFingerprintData } from './protocol.ts';
|
|
24
|
+
/** 生成端实际生效的风格目标(判别联合:卡直给指纹,样本由调用方现算)。 */
|
|
25
|
+
export type EffectiveStyleTarget = {
|
|
26
|
+
kind: 'profile';
|
|
27
|
+
fingerprint: StyleFingerprintData;
|
|
28
|
+
label: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'sample';
|
|
31
|
+
sampleText: string;
|
|
32
|
+
label: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'none';
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 解析生成端生效的风格目标。
|
|
38
|
+
*
|
|
39
|
+
* 优先级:显式卡 > 绑定资产的样本文本 > 无。样本文本取「第一个有 sourceText
|
|
40
|
+
* 的资产」,指纹由调用方现算——本模块不依赖 style-fingerprint,保持纯数据。
|
|
41
|
+
*
|
|
42
|
+
* @param project 项目状态(只需 styleProfile 与 assets.styleAssets[].sourceText)。
|
|
43
|
+
* @returns 生效目标。
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveStyleTarget(project: {
|
|
46
|
+
styleProfile?: StyleProfile;
|
|
47
|
+
assets?: {
|
|
48
|
+
styleAssets?: Array<{
|
|
49
|
+
sourceText?: string;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
}): EffectiveStyleTarget;
|
|
53
|
+
/** 用指纹数据构造一张目标卡。 */
|
|
54
|
+
export declare function makeStyleProfile(source: StyleProfileSource, label: string, fingerprint: StyleFingerprintData, sampleChapters?: number): StyleProfile;
|
|
55
|
+
/** 目标卡的中文来源名(面板用)。 */
|
|
56
|
+
export declare function styleProfileSourceLabel(source: StyleProfileSource): string;
|
|
57
|
+
/**
|
|
58
|
+
* 校验一次 distilled-sample 请求的样本文本。
|
|
59
|
+
* @returns 归一化后的文本。
|
|
60
|
+
* @throws 文本过短时抛错(路由转 400)。
|
|
61
|
+
*/
|
|
62
|
+
export declare function normalizeSampleText(text: string | undefined): string;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waterwx/dsh-novel-forge",
|
|
3
3
|
"description": "AI 编译纯文本小说工作台 for the dsh web GUI: import a novel outline (docx/text), plan volumes & chapters with LLM, generate chapter by chapter (3000-4000 chars each), auto AI review & book audit, and export the full book as Markdown/TXT into your chosen output folder.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "waterwx",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/watersxya/dsh-novel-forge.git"
|
|
9
|
+
"url": "git+https://github.com/watersxya/dsh-novel-forge.git"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://github.com/watersxya/dsh-novel-forge",
|
|
12
12
|
"bugs": {
|