@cloud411716/fancy-webnovel 4.30.0 → 4.30.2
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/material-library/backlog.md +139 -0
- package/docs/material-library/prompt-v2.md +729 -0
- package/docs/material-library/prompt-v3.md +202 -0
- package/docs/material-library/prompt.md +140 -467
- package/package.json +1 -1
- package/plugins/fancy-material/builtin-styles.js +30 -14
- package/plugins/fancy-material/facet-copy.js +200 -0
- package/plugins/fancy-material/genre-playbooks.js +98 -0
- package/plugins/fancy-material/index.js +30 -2
- package/plugins/fancy-material/kinds.js +16 -0
- package/plugins/fancy-material/styles.js +31 -7
- package/plugins/fancy-material/world.js +3 -3
|
@@ -41,6 +41,11 @@ function normalizeStyle(raw, origin = 'database') {
|
|
|
41
41
|
const style = raw && typeof raw === 'object' ? raw : {};
|
|
42
42
|
const profile = asObject(style.profile_json);
|
|
43
43
|
const merged = { ...profile, ...style };
|
|
44
|
+
const crossKindExamples = asObject(merged.cross_kind_examples);
|
|
45
|
+
if (crossKindExamples.rank_name && !crossKindExamples.power_rank) {
|
|
46
|
+
crossKindExamples.power_rank = crossKindExamples.rank_name;
|
|
47
|
+
}
|
|
48
|
+
delete crossKindExamples.rank_name;
|
|
44
49
|
return {
|
|
45
50
|
style_key: String(merged.style_key || '').trim(),
|
|
46
51
|
style_name: String(merged.style_name || merged.name || merged.style_key || '').trim(),
|
|
@@ -57,9 +62,15 @@ function normalizeStyle(raw, origin = 'database') {
|
|
|
57
62
|
].map((v) => String(v || '').trim()).filter(Boolean)),
|
|
58
63
|
genre_tags: unique(asArray(merged.genre_tags).map((v) => String(v || '').trim())),
|
|
59
64
|
dna: String(merged.dna || '').trim(),
|
|
65
|
+
naming_mode: ['image', 'hybrid', 'identifier'].includes(String(merged.naming_mode || '').trim())
|
|
66
|
+
? String(merged.naming_mode).trim()
|
|
67
|
+
: '',
|
|
68
|
+
generation_chain: unique(asArray(merged.generation_chain).map((v) => String(v || '').trim())),
|
|
69
|
+
image_pool: unique(asArray(merged.image_pool).map((v) => String(v || '').trim())),
|
|
70
|
+
hook_rule: String(merged.hook_rule || '').trim(),
|
|
60
71
|
naming_rules: asObject(merged.naming_rules),
|
|
61
72
|
lexicon: asObject(merged.lexicon),
|
|
62
|
-
cross_kind_examples:
|
|
73
|
+
cross_kind_examples: crossKindExamples,
|
|
63
74
|
anti_examples: unique(asArray(merged.anti_examples).map((v) => String(v || '').trim())),
|
|
64
75
|
compatibility: asObject(merged.compatibility),
|
|
65
76
|
confidence: Math.max(0, Math.min(1, Number(merged.confidence) || 0)),
|
|
@@ -84,6 +95,10 @@ function mergeStyle(base, patch) {
|
|
|
84
95
|
account_urls: unique([...a.account_urls, ...b.account_urls]),
|
|
85
96
|
genre_tags: unique([...a.genre_tags, ...b.genre_tags]),
|
|
86
97
|
dna: b.dna || a.dna,
|
|
98
|
+
naming_mode: b.naming_mode || a.naming_mode,
|
|
99
|
+
generation_chain: unique([...a.generation_chain, ...b.generation_chain]),
|
|
100
|
+
image_pool: unique([...a.image_pool, ...b.image_pool]),
|
|
101
|
+
hook_rule: b.hook_rule || a.hook_rule,
|
|
87
102
|
naming_rules: mergeObject(a.naming_rules, b.naming_rules),
|
|
88
103
|
lexicon: mergeObject(a.lexicon, b.lexicon),
|
|
89
104
|
cross_kind_examples: mergeObject(a.cross_kind_examples, b.cross_kind_examples),
|
|
@@ -287,7 +302,6 @@ export function styleIndexLines(styles, { limit = 20 } = {}) {
|
|
|
287
302
|
* 只展开本次选中的风格;其余只给索引,避免上下文爆炸。
|
|
288
303
|
*/
|
|
289
304
|
export function stylePromptBlock(styles, selected, { genres = [] } = {}) {
|
|
290
|
-
const all = Array.isArray(styles) ? styles : [];
|
|
291
305
|
const picked = Array.isArray(selected) ? selected : [];
|
|
292
306
|
const lines = [
|
|
293
307
|
'## 风格锁定(最高优先级)',
|
|
@@ -295,12 +309,9 @@ export function stylePromptBlock(styles, selected, { genres = [] } = {}) {
|
|
|
295
309
|
'风格是跨 kind 的不变量:kind 决定“写什么信息点”,风格决定“用什么方式写”。',
|
|
296
310
|
'如果下面的风格规则与题材命名体例冲突,以风格规则为准;题材只负责换词汇和禁用项。',
|
|
297
311
|
'',
|
|
298
|
-
'### 可用风格索引',
|
|
299
|
-
...styleIndexLines(all),
|
|
300
|
-
'',
|
|
301
312
|
];
|
|
302
313
|
if (!picked.length) {
|
|
303
|
-
lines.push('
|
|
314
|
+
lines.push('本次未选择账号风格,按通用规则生成;命名模式默认 image。');
|
|
304
315
|
return lines.join('\n');
|
|
305
316
|
}
|
|
306
317
|
lines.push('### 本次选中的风格');
|
|
@@ -308,8 +319,17 @@ export function stylePromptBlock(styles, selected, { genres = [] } = {}) {
|
|
|
308
319
|
lines.push('');
|
|
309
320
|
lines.push(`#### \`${style.style_key}\`(${style.style_name})`);
|
|
310
321
|
lines.push('- 风格类型:' + style.style_type);
|
|
322
|
+
lines.push('- 命名模式:`' + (style.naming_mode || 'image') + '`');
|
|
311
323
|
lines.push('- 适用题材:' + (style.genre_tags || []).join('、'));
|
|
312
324
|
lines.push('- DNA:' + style.dna);
|
|
325
|
+
if (style.generation_chain && style.generation_chain.length) {
|
|
326
|
+
lines.push('- 生成链路:');
|
|
327
|
+
for (const step of style.generation_chain) lines.push(' - ' + step);
|
|
328
|
+
}
|
|
329
|
+
if (style.image_pool && style.image_pool.length) {
|
|
330
|
+
lines.push('- 母题意象池:' + style.image_pool.join('、'));
|
|
331
|
+
}
|
|
332
|
+
if (style.hook_rule) lines.push('- 钩子要求:' + style.hook_rule);
|
|
313
333
|
const rules = style.naming_rules || {};
|
|
314
334
|
if (rules.length) lines.push('- 长度:' + (Array.isArray(rules.length) ? rules.length.join('–') + ' 字' : rules.length));
|
|
315
335
|
if (rules.syntax) lines.push('- 句式:' + asArray(rules.syntax).join(';'));
|
|
@@ -331,7 +351,7 @@ export function stylePromptBlock(styles, selected, { genres = [] } = {}) {
|
|
|
331
351
|
}
|
|
332
352
|
lines.push('');
|
|
333
353
|
lines.push('本批题材:' + (genres.join('、') || '通用'));
|
|
334
|
-
lines.push('
|
|
354
|
+
lines.push('严格按选中风格的 `naming_mode` 和生成链路执行;不要自行切换风格或命名模式。');
|
|
335
355
|
return lines.join('\n');
|
|
336
356
|
}
|
|
337
357
|
|
|
@@ -425,6 +445,10 @@ export async function upsertStyleProfiles(db, profiles, { account = null } = {})
|
|
|
425
445
|
profile_json: {
|
|
426
446
|
account_names: merged.account_names,
|
|
427
447
|
account_urls: merged.account_urls,
|
|
448
|
+
naming_mode: merged.naming_mode,
|
|
449
|
+
generation_chain: merged.generation_chain,
|
|
450
|
+
image_pool: merged.image_pool,
|
|
451
|
+
hook_rule: merged.hook_rule,
|
|
428
452
|
naming_rules: merged.naming_rules,
|
|
429
453
|
lexicon: merged.lexicon,
|
|
430
454
|
cross_kind_examples: merged.cross_kind_examples,
|
|
@@ -22,6 +22,7 @@ import { BUILTIN_GENRES } from '#material-topic';
|
|
|
22
22
|
import { MATERIAL_FACET_CANDIDATES } from './facets.js';
|
|
23
23
|
import { KIND_GROUPS, KIND_LABELS, MATERIAL_KINDS } from './kinds.js';
|
|
24
24
|
import { normalizeCategories } from './plan.js';
|
|
25
|
+
import { facetOptionDescription } from './facet-copy.js';
|
|
25
26
|
|
|
26
27
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
27
28
|
const WORLD_PROMPT_FILE = path.join(__dirname, 'prompts', 'world-mother.md');
|
|
@@ -173,9 +174,8 @@ export function facetQuestion(step, { suggestion = null, selected = [] } = {}) {
|
|
|
173
174
|
const isRecommended = recommended.includes(value);
|
|
174
175
|
options.push({
|
|
175
176
|
label: value,
|
|
176
|
-
description: isRecommended
|
|
177
|
-
|
|
178
|
-
: (step.id === 'genres' ? '题材条件;多选时每一项都要同时满足' : '选中后必须同时满足'),
|
|
177
|
+
description: (isRecommended ? '推荐:来自 _novel_topic_suggestion.json(可改);' : '')
|
|
178
|
+
+ facetOptionDescription(step.id, value),
|
|
179
179
|
});
|
|
180
180
|
if (Number.isFinite(limit) && options.length >= limit + 1) break;
|
|
181
181
|
}
|