@cloud411716/fancy-webnovel 4.29.0 → 4.30.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.
- package/docs/douyin-plugin.md +1 -1
- package/docs/material-library/README.md +25 -19
- package/docs/material-library/backlog.md +171 -0
- package/docs/material-library/import.js +16 -3
- package/docs/material-library/prompt.md +12 -9
- package/docs/material-library/queries.surql +2 -2
- package/docs/material-library/sample.jsonl +8 -7
- package/docs/material-library/schema.surql +17 -10
- package/docs/workspace-mcp.md +1 -1
- package/lib/material-db.js +4 -4
- package/lib/material-topic.js +3 -0
- package/package.json +1 -1
- package/plugins/fancy-bootstrap/index.js +1 -1
- package/plugins/fancy-db/index.js +1 -1
- package/plugins/fancy-material/exporter.js +5 -1
- package/plugins/fancy-material/index.js +316 -118
- package/plugins/fancy-material/inventory.js +7 -5
- package/plugins/fancy-material/kinds.js +47 -20
- package/plugins/fancy-material/plan.js +190 -0
- package/plugins/fancy-material/prompts/world-mother.md +11 -1
- package/plugins/fancy-material/styles.js +1 -1
- package/plugins/fancy-material/templates.js +171 -8
- package/plugins/fancy-material/validate.js +14 -2
- package/plugins/fancy-material/world.js +49 -20
- package/plugins/fancy-topic/index.js +2 -2
- package/plugins/fancy-topic/prompts/02-setup-prompt.md +3 -2
- package/plugins/fancy-topic/templates.js +2 -1
|
@@ -18,8 +18,10 @@ import path from 'node:path';
|
|
|
18
18
|
import { fileURLToPath } from 'node:url';
|
|
19
19
|
|
|
20
20
|
import { atomicWriteJson } from '#workspace';
|
|
21
|
+
import { BUILTIN_GENRES } from '#material-topic';
|
|
21
22
|
import { MATERIAL_FACET_CANDIDATES } from './facets.js';
|
|
22
23
|
import { KIND_GROUPS, KIND_LABELS, MATERIAL_KINDS } from './kinds.js';
|
|
24
|
+
import { normalizeCategories } from './plan.js';
|
|
23
25
|
|
|
24
26
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
25
27
|
const WORLD_PROMPT_FILE = path.join(__dirname, 'prompts', 'world-mother.md');
|
|
@@ -27,15 +29,15 @@ const WORLD_PROMPT_FILE = path.join(__dirname, 'prompts', 'world-mother.md');
|
|
|
27
29
|
export const FLOW_VERSION = 1;
|
|
28
30
|
export const FLOW_RELATIVE_PATH = path.join('.fancy', 'material', 'flow.json');
|
|
29
31
|
export const EMPTY_FACET_LABEL = '无(不限)';
|
|
30
|
-
export const DEFAULT_TARGET_PER_KIND =
|
|
31
|
-
export const DEFAULT_SCOPE_TITLES = ['命名', '世界与势力', '能力', '剧情与脑洞'];
|
|
32
|
+
export const DEFAULT_TARGET_PER_KIND = 50;
|
|
33
|
+
export const DEFAULT_SCOPE_TITLES = ['命名', '世界与势力', '能力', '等级', '剧情与脑洞'];
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* 弹框顺序。只选 6 层,避免把用户拖进十几个框。
|
|
35
37
|
* 每一层都是多选,第一项统一是“无(不限)”。
|
|
36
38
|
*/
|
|
37
39
|
export const FACET_STEPS = [
|
|
38
|
-
{ id: 'genres', label: '题材 / 世界类型', header: '题材', limit:
|
|
40
|
+
{ id: 'genres', label: '题材 / 世界类型', header: '题材', limit: Infinity },
|
|
39
41
|
{ id: 'settings', label: '时代 / 场景 / 背景', header: '场景', limit: 15 },
|
|
40
42
|
{ id: 'moods', label: '情绪 / 调性', header: '情绪', limit: 14 },
|
|
41
43
|
{ id: 'tropes', label: '情节 / 流派 / 梗', header: '情节', limit: 16 },
|
|
@@ -137,6 +139,16 @@ function recommendationLabels(field, suggestion) {
|
|
|
137
139
|
return unique([raw, ...expandGenre(raw)]);
|
|
138
140
|
}
|
|
139
141
|
|
|
142
|
+
function allGenreLabels() {
|
|
143
|
+
// 第一层题材必须完整:平台题材 + 常用基础/细分题材都列出来。
|
|
144
|
+
// 这里不做截断;用户想选冷门题材时不用自己手打。
|
|
145
|
+
return unique([
|
|
146
|
+
...BUILTIN_GENRES,
|
|
147
|
+
...Object.keys(GENRE_ALIASES),
|
|
148
|
+
...asArray(MATERIAL_FACET_CANDIDATES.genres),
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
|
|
140
152
|
/**
|
|
141
153
|
* 为一层 facet 生成 DSH 合法的问题对象。
|
|
142
154
|
* 选项第一项固定是“无(不限)”。
|
|
@@ -146,13 +158,13 @@ export function facetQuestion(step, { suggestion = null, selected = [] } = {}) {
|
|
|
146
158
|
const recommended = recommendationLabels(step.id, suggestion);
|
|
147
159
|
const candidates = unique([
|
|
148
160
|
...recommended,
|
|
149
|
-
...asArray(MATERIAL_FACET_CANDIDATES[step.id]),
|
|
161
|
+
...(step.id === 'genres' ? allGenreLabels() : asArray(MATERIAL_FACET_CANDIDATES[step.id])),
|
|
150
162
|
...asArray(selected),
|
|
151
163
|
]);
|
|
152
|
-
const limit = Math.max(1, Number(step.limit)
|
|
164
|
+
const limit = Number.isFinite(Number(step.limit)) ? Math.max(1, Number(step.limit)) : Infinity;
|
|
153
165
|
const options = [{
|
|
154
166
|
label: EMPTY_FACET_LABEL,
|
|
155
|
-
description: '
|
|
167
|
+
description: '这一组不限制;选中会清空同组的其它选项',
|
|
156
168
|
}];
|
|
157
169
|
const used = new Set([EMPTY_FACET_LABEL]);
|
|
158
170
|
for (const value of candidates) {
|
|
@@ -163,13 +175,13 @@ export function facetQuestion(step, { suggestion = null, selected = [] } = {}) {
|
|
|
163
175
|
label: value,
|
|
164
176
|
description: isRecommended
|
|
165
177
|
? '推荐:来自 _novel_topic_suggestion.json(可改)'
|
|
166
|
-
: (step.id === 'genres' ? '
|
|
178
|
+
: (step.id === 'genres' ? '题材条件;多选时每一项都要同时满足' : '选中后必须同时满足'),
|
|
167
179
|
});
|
|
168
|
-
if (options.length >= limit + 1) break;
|
|
180
|
+
if (Number.isFinite(limit) && options.length >= limit + 1) break;
|
|
169
181
|
}
|
|
170
182
|
const hint = step.id === 'genres'
|
|
171
|
-
? '
|
|
172
|
-
: '
|
|
183
|
+
? '多选规则(交集):例如同时选 都市 + 异能 + 脑洞,生成素材必须同时满足这三种,不是任选其一。选「都市异能」时,会同时按「都市」和「异能」两个条件处理。'
|
|
184
|
+
: '多选规则:同一个问题里选中的每一项都必须同时成立,不是任选其一。';
|
|
173
185
|
return {
|
|
174
186
|
id: 'material-facet-' + step.id,
|
|
175
187
|
header: '素材 · ' + step.header,
|
|
@@ -198,7 +210,7 @@ export function styleQuestion(styles = []) {
|
|
|
198
210
|
id: 'material-style',
|
|
199
211
|
header: '素材 · 风格',
|
|
200
212
|
question: '请选择对标风格(可多选;第一项「无」表示自动)',
|
|
201
|
-
detail: '
|
|
213
|
+
detail: '同一个问题里多选=同时使用这些风格核心;无=按题材自动选;不使用账号风格=关闭风格锁定。',
|
|
202
214
|
options,
|
|
203
215
|
multiSelect: true,
|
|
204
216
|
};
|
|
@@ -234,7 +246,7 @@ export function scopeQuestion({ currentKinds = [] } = {}) {
|
|
|
234
246
|
});
|
|
235
247
|
}
|
|
236
248
|
options.push({
|
|
237
|
-
label: '推荐:命名 + 世界 + 能力 + 剧情',
|
|
249
|
+
label: '推荐:命名 + 世界 + 能力 + 等级 + 剧情',
|
|
238
250
|
description: `世界母体最相关的 ${recommendedScopeKinds().length} 个 kind`,
|
|
239
251
|
});
|
|
240
252
|
options.push({
|
|
@@ -257,12 +269,12 @@ export function countQuestion() {
|
|
|
257
269
|
id: 'material-count',
|
|
258
270
|
header: '素材 · 数量',
|
|
259
271
|
question: '每个 kind 本次追加多少条?',
|
|
260
|
-
detail: '只追加,不覆盖已有素材。默认
|
|
272
|
+
detail: '只追加,不覆盖已有素材。默认 50 条;系统组按套生成,不受这个数字影响。',
|
|
261
273
|
options: [
|
|
262
|
-
{ label: '
|
|
263
|
-
{ label: '
|
|
264
|
-
{ label: '30 条', description: '
|
|
265
|
-
{ label: '
|
|
274
|
+
{ label: '50 条(推荐)', description: '长篇默认池子大小' },
|
|
275
|
+
{ label: '20 条', description: '先小批试跑' },
|
|
276
|
+
{ label: '30 条', description: '中等批量' },
|
|
277
|
+
{ label: '100 条', description: '需要更多备选,耗时较长' },
|
|
266
278
|
],
|
|
267
279
|
};
|
|
268
280
|
}
|
|
@@ -305,6 +317,8 @@ export function worldCandidateQuestion(candidates, { allowReroll = true } = {})
|
|
|
305
317
|
const bits = [];
|
|
306
318
|
if (candidate.core_conflict) bits.push('核心矛盾:' + candidate.core_conflict);
|
|
307
319
|
if (candidate.suggestion_fit) bits.push('与选题关系:' + candidate.suggestion_fit);
|
|
320
|
+
if (candidate.ability_categories?.length) bits.push('能力:' + candidate.ability_categories.map((item) => item.name || item).join('、'));
|
|
321
|
+
if (candidate.faction_types?.length) bits.push('势力:' + candidate.faction_types.map((item) => item.name || item).join('、'));
|
|
308
322
|
if (candidate.difference) bits.push('差异:' + candidate.difference);
|
|
309
323
|
options.push({
|
|
310
324
|
label,
|
|
@@ -359,7 +373,10 @@ function normalizeWorldCandidate(raw, index, { constraintGenres = [] } = {}) {
|
|
|
359
373
|
taboos: normalizeStringArray(source.taboos || source.forbidden),
|
|
360
374
|
visual_motifs: normalizeStringArray(source.visual_motifs || source.motifs),
|
|
361
375
|
naming_logic: clean(source.naming_logic || source.naming),
|
|
362
|
-
core_genres:
|
|
376
|
+
core_genres: constraintGenres.length ? [...constraintGenres] : coreGenres,
|
|
377
|
+
ability_categories: normalizeCategories(source.ability_categories || source.power_categories, []),
|
|
378
|
+
faction_types: normalizeCategories(source.faction_types || source.factions, []),
|
|
379
|
+
power_systems: normalizeCategories(source.power_systems || source.power_system, []),
|
|
363
380
|
supported_kinds: normalizeStringArray(source.supported_kinds)
|
|
364
381
|
.filter((kind) => MATERIAL_KINDS.includes(kind)),
|
|
365
382
|
suggestion_fit: clean(source.suggestion_fit),
|
|
@@ -475,7 +492,7 @@ function renderSuggestionBlock(suggestion) {
|
|
|
475
492
|
'- 方向是候选世界母体的锚点,不是最终世界名。',
|
|
476
493
|
'- 定位是读者承诺和核心矛盾,不是命名词表。',
|
|
477
494
|
'- 必须先把定位翻译成 3–5 条世界公理/代价/禁忌,再让名字从公理里长出来。',
|
|
478
|
-
'- 禁止把定位里的职业、机构、流程名词直接当
|
|
495
|
+
'- 禁止把定位里的职业、机构、流程名词直接当 power_rank / faction_rank / skill_name / faction_name。',
|
|
479
496
|
'- 反例:试岗、替班、带班、值守、包月令、静音条。',
|
|
480
497
|
].join('\n');
|
|
481
498
|
}
|
|
@@ -555,9 +572,18 @@ export function renderWorldBlock({
|
|
|
555
572
|
'- 素材的 genres 必须原样包含全部核心题材;缺任何一个都算废稿。',
|
|
556
573
|
'- 对应 facet 数组(tropes / moods / settings / roles / relations)必须包含本次选中的全部值;不能只写其中一个。',
|
|
557
574
|
'- 名字必须从世界母体的公理、代价、禁忌里长出来,不能是现实职业词或字面功能词。',
|
|
558
|
-
'- 禁止把 positioning 里的职业/机构/流程名词直接当
|
|
575
|
+
'- 禁止把 positioning 里的职业/机构/流程名词直接当 power_rank / faction_rank / skill_name / faction_name。',
|
|
559
576
|
'- 反例:试岗、替班、带班、值守、包月令、静音条。',
|
|
560
577
|
].filter(Boolean);
|
|
578
|
+
if (world.ability_categories?.length) {
|
|
579
|
+
lines.push('', '### 能力类别', ...world.ability_categories.map((item) => '- ' + (item.name || item)));
|
|
580
|
+
}
|
|
581
|
+
if (world.faction_types?.length) {
|
|
582
|
+
lines.push('', '### 势力类型', ...world.faction_types.map((item) => '- ' + (item.name || item)));
|
|
583
|
+
}
|
|
584
|
+
if (world.power_systems?.length) {
|
|
585
|
+
lines.push('', '### 力量体系', ...world.power_systems.map((item) => '- ' + (item.name || item)));
|
|
586
|
+
}
|
|
561
587
|
if (world.institutions?.length) lines.push('', '### 机构/场所', ...world.institutions.map((item) => '- ' + item));
|
|
562
588
|
if (world.taboos?.length) lines.push('', '### 禁忌', ...world.taboos.map((item) => '- ' + item));
|
|
563
589
|
if (world.visual_motifs?.length) lines.push('', '### 视觉母题', ...world.visual_motifs.map((item) => '- ' + item));
|
|
@@ -587,6 +613,9 @@ export function renderWorldBatchSummary({
|
|
|
587
613
|
world.cost ? '- 核心代价:' + world.cost : '',
|
|
588
614
|
world.naming_logic ? '- 命名逻辑:' + world.naming_logic : '',
|
|
589
615
|
'- 题材交集(必须全部满足):' + (constraintGenres.join('、') || '无(不限)'),
|
|
616
|
+
world.ability_categories?.length ? '- 能力类别:' + world.ability_categories.map((item) => item.name || item).join('、') : '',
|
|
617
|
+
world.faction_types?.length ? '- 势力类型:' + world.faction_types.map((item) => item.name || item).join('、') : '',
|
|
618
|
+
world.power_systems?.length ? '- 力量体系:' + world.power_systems.map((item) => item.name || item).join('、') : '',
|
|
590
619
|
selected ? '- facet 交集:' + selected : '',
|
|
591
620
|
'- 同一层多选是 AND;禁止只取其中一个约束。',
|
|
592
621
|
].filter(Boolean).join('\n');
|
|
@@ -16,7 +16,7 @@ import { readDeployedState, deployedStateProblemText, DEPLOYED_STATUS } from '#d
|
|
|
16
16
|
import { repairTopicDecision, selectNonRedundantBlocks, inspectBlockBodies } from '#topic-decision';
|
|
17
17
|
import { isSensitiveProjectPath, isValidProjectPath } from '#path-guard';
|
|
18
18
|
import { parseDecisionCandidates } from '#topic-candidates';
|
|
19
|
-
import { NOVEL_SUGGESTION_FILE, validateSuggestion, validateMinimalTopic, readSuggestion, ABILITY_KINDS, PLOT_KINDS } from '#material-topic';
|
|
19
|
+
import { NOVEL_SUGGESTION_FILE, validateSuggestion, validateMinimalTopic, readSuggestion, ABILITY_KINDS, PLOT_KINDS, PLOT_MATERIAL_KINDS } from '#material-topic';
|
|
20
20
|
import { atomicWriteJSON } from '#atomic-write';
|
|
21
21
|
import { resolveWorkspace } from '#workspace';
|
|
22
22
|
import { topic } from './templates.js';
|
|
@@ -507,7 +507,7 @@ async function pathSetup(ctx, session, invocation, signal, projectRoot, tasks) {
|
|
|
507
507
|
const coverage = {
|
|
508
508
|
genres,
|
|
509
509
|
ability: ABILITY_KINDS.map((kind) => ({ kind, count: Number(counts[kind]) || 0 })),
|
|
510
|
-
plot:
|
|
510
|
+
plot: PLOT_MATERIAL_KINDS.map((kind) => ({ kind, count: Number(counts[kind]) || 0 })),
|
|
511
511
|
};
|
|
512
512
|
const missing = [...coverage.ability, ...coverage.plot]
|
|
513
513
|
.filter((item) => !item.count)
|
|
@@ -42,7 +42,7 @@ node '${QUERY_SCRIPT}' --workspace '${WORKSPACE}' --genre '${QUERY_GENRE}' --kin
|
|
|
42
42
|
需要查询的 kind:
|
|
43
43
|
|
|
44
44
|
- 能力组:${ABILITY_KINDS}
|
|
45
|
-
-
|
|
45
|
+
- 剧情种子组:${PLOT_SEED_KINDS}
|
|
46
46
|
|
|
47
47
|
规则:
|
|
48
48
|
|
|
@@ -51,7 +51,8 @@ node '${QUERY_SCRIPT}' --workspace '${WORKSPACE}' --genre '${QUERY_GENRE}' --kin
|
|
|
51
51
|
3. 题材是交集:本次选择是 `${GENRE_FILTERS}`。可以用其中任意一个题材查询,但选中的素材必须同时满足 `flow.json` 里的全部题材、场景、情绪、情节、身份、关系约束。
|
|
52
52
|
4. 如果某个 kind 查不到结果,可以去掉 `--genre` 再查一次,但只能用真实素材;仍然没有就停下来告诉用户,不要编。
|
|
53
53
|
5. 同一层 facet 多选是 AND,不是 OR。不要把只满足一个条件的素材硬拼成方案。
|
|
54
|
-
6.
|
|
54
|
+
6. `conflict_seed`、`conflict_escalation`、`plot_twist`、`mystery_seed`、`payoff_scene`、`trope` 不需要从素材库查询;它们要在定稿方案里结合世界母体、角色和 `${PLOT_SEED_KINDS}` 种子现场生成。
|
|
55
|
+
7. 不要修改、删除 `.fancy-tools/fancy-material/` 下的脚本。
|
|
55
56
|
|
|
56
57
|
## 三、生成 1 个推荐定稿 + 2 个备选
|
|
57
58
|
|
|
@@ -17,7 +17,7 @@ import { dirname, join } from 'path';
|
|
|
17
17
|
import { createHash } from 'crypto';
|
|
18
18
|
import { fileURLToPath } from 'url';
|
|
19
19
|
import { shellSingleQuote } from '#path-guard';
|
|
20
|
-
import { ABILITY_KINDS, PLOT_KINDS } from '#material-topic';
|
|
20
|
+
import { ABILITY_KINDS, PLOT_KINDS, PLOT_MATERIAL_KINDS } from '#material-topic';
|
|
21
21
|
import {
|
|
22
22
|
TOPIC_FIELDS,
|
|
23
23
|
TOPIC_FIELD_CN,
|
|
@@ -405,6 +405,7 @@ export const topic = {
|
|
|
405
405
|
COVERAGE_JSON: JSON.stringify(coverage || {}, null, 2),
|
|
406
406
|
ABILITY_KINDS: ABILITY_KINDS.map(k => `\`${k}\``).join('、'),
|
|
407
407
|
PLOT_KINDS: PLOT_KINDS.map(k => `\`${k}\``).join('、'),
|
|
408
|
+
PLOT_SEED_KINDS: PLOT_MATERIAL_KINDS.map(k => `\`${k}\``).join('、'),
|
|
408
409
|
QUERY_SCRIPT: queryScript || '',
|
|
409
410
|
WORKSPACE: workspace || '',
|
|
410
411
|
});
|