@cloud411716/fancy-webnovel 4.3.0 → 4.4.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.
|
@@ -91,12 +91,14 @@ plugins/fancy-material/
|
|
|
91
91
|
```text
|
|
92
92
|
/fancy-material 都市高武 城市地标
|
|
93
93
|
/fancy-material 克苏鲁 神话生物
|
|
94
|
+
/fancy-material 都市高武 all # 该题材下全部 58 个 kind
|
|
94
95
|
```
|
|
95
96
|
|
|
96
97
|
第一个参数是题材,第二个参数是素材类型;两者都可以随便写,不要求命中内置题材/58 个 kind。插件会把它们交给 LLM:
|
|
97
98
|
|
|
98
99
|
- 素材类型命中内置 kind 时直接使用该 kind;否则由 LLM 自拟一个安全的小写 snake_case kind。
|
|
99
100
|
- 生成结果的 `source` 固定为 `other`,不占用内置目录,也不会被 `init` 当作旧内置 kind 清理。
|
|
101
|
+
- 第二个参数写 `all` 时,插件会把该题材下的全部 58 个 kind 排成队列,逐个生成;source 仍然是 `other`。
|
|
100
102
|
- 同一批只能使用一个 kind;插件在第一轮识别后记住它,后续批次沿用。
|
|
101
103
|
|
|
102
104
|
## 3. 58 个 kind
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
# 小说原子素材库生成提示词 v4.2
|
|
2
|
-
|
|
3
|
-
> 兼容原有 SurrealDB 数据库结构与插件生成队列;v4 版本字段全部保留,新增 `group_id` 与单 kind 质量要求。
|
|
4
|
-
> 核心升级:全题材创意拉升机制 + 组件组生成逻辑 + 分题材俗套黑名单 + 命名高级感范式 + 单 kind 质量标准 + 标准化标签体系。
|
|
5
|
-
> 目标:保留原子积木的颗粒度与灵活性,平衡「亮眼不俗套」与「好读不生僻」,从根源解决素材平庸、命名晦涩、换皮重复的问题。
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
1
|
## 一、角色定位与核心创作原则
|
|
10
2
|
|
|
11
3
|
你是一位跨媒介故事素材设计师。你不写完整小说,而是生产**可以独立取用、自由组合、有记忆点、不落入俗套**的小块原子素材。
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ import { makeWaitForTurn } from '../fancy-story-builder/writing-driver.js';
|
|
|
28
28
|
import { exportMaterials } from './exporter.js';
|
|
29
29
|
import { allKnownGenres } from './genres.js';
|
|
30
30
|
import { buildExistingIndex, countByKind, countKind } from './inventory.js';
|
|
31
|
-
import { KIND_LABELS, MATERIAL_KINDS, customFocusBlock, focusBlock, renderKindTable, resolveFocus } from './kinds.js';
|
|
31
|
+
import { KIND_LABELS, MATERIAL_KINDS, customFocusBlock, focusBlock, renderKindTable, resolveCustomKinds, resolveFocus } from './kinds.js';
|
|
32
32
|
import { nextBatchRequest, planMaterialQueue } from './queue.js';
|
|
33
33
|
import { deployMaterialTools } from './tool-deploy.js';
|
|
34
34
|
import {
|
|
@@ -452,8 +452,11 @@ async function runGenerate(ctx, invocation, session, focusRaw = '', taskList, op
|
|
|
452
452
|
// 判断对应哪个 kind(不在 58 个内置 kind 里时自拟 kind)。
|
|
453
453
|
const custom = opts.custom || null;
|
|
454
454
|
const isCustom = Boolean(custom && custom.genre && custom.materialType);
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
const customAllKinds = Boolean(custom && custom.allKinds);
|
|
456
|
+
if (isCustom && !customAllKinds) focusRaw = custom.materialType;
|
|
457
|
+
const focus = customAllKinds
|
|
458
|
+
? { query: '全部素材类型(all)', kinds: [] }
|
|
459
|
+
: resolveFocus(focusRaw);
|
|
457
460
|
if (!isCustom && focusRaw && !focus.kinds.length) {
|
|
458
461
|
return notify(session, 'error', '❌ 未识别素材类型:' + focusRaw
|
|
459
462
|
+ '\n可用示例:地名、人名、姓氏、门派、技能、超能力、武器、颜色、特效、脑洞、人物性格、关系、场景。'
|
|
@@ -503,7 +506,9 @@ async function runGenerate(ctx, invocation, session, focusRaw = '', taskList, op
|
|
|
503
506
|
const database = materialDatabaseName(readWorkspace(root));
|
|
504
507
|
const counts = await countByKind(root, plan.genres);
|
|
505
508
|
// 自定义素材第一轮 kind 由 LLM 决定,这里先用一个占位项跑一条队列。
|
|
506
|
-
const kinds =
|
|
509
|
+
const kinds = isCustom
|
|
510
|
+
? resolveCustomKinds({ materialType: custom.materialType, kinds: focus.kinds })
|
|
511
|
+
: [...new Set(focus.kinds.length ? focus.kinds : MATERIAL_KINDS)];
|
|
507
512
|
const planned = planMaterialQueue({ kinds, target: config.targetPerKind });
|
|
508
513
|
|
|
509
514
|
const startedAt = Date.now();
|
|
@@ -519,6 +524,7 @@ async function runGenerate(ctx, invocation, session, focusRaw = '', taskList, op
|
|
|
519
524
|
genre: plan.customGenre,
|
|
520
525
|
materialType: plan.customMaterialType,
|
|
521
526
|
kinds: focus.kinds,
|
|
527
|
+
allKinds: customAllKinds,
|
|
522
528
|
})
|
|
523
529
|
: '';
|
|
524
530
|
const base = renderBasePrompt({
|
|
@@ -540,7 +546,7 @@ async function runGenerate(ctx, invocation, session, focusRaw = '', taskList, op
|
|
|
540
546
|
|
|
541
547
|
const queue = planned.all.map((item) => ({
|
|
542
548
|
kind: item.kind === '__custom__' ? '' : item.kind,
|
|
543
|
-
label: isCustom
|
|
549
|
+
label: isCustom && !customAllKinds
|
|
544
550
|
? plan.customMaterialType
|
|
545
551
|
: (KIND_LABELS[item.kind] || item.kind),
|
|
546
552
|
db_existing: Number(counts[item.kind]) || 0,
|
|
@@ -570,6 +576,7 @@ async function runGenerate(ctx, invocation, session, focusRaw = '', taskList, op
|
|
|
570
576
|
...(isCustom ? {
|
|
571
577
|
custom_genre: plan.customGenre,
|
|
572
578
|
custom_material_type: plan.customMaterialType,
|
|
579
|
+
custom_all_kinds: customAllKinds,
|
|
573
580
|
} : {}),
|
|
574
581
|
kinds: queue,
|
|
575
582
|
};
|
|
@@ -666,7 +673,9 @@ async function runGenerate(ctx, invocation, session, focusRaw = '', taskList, op
|
|
|
666
673
|
queryScript: tools.queryScript,
|
|
667
674
|
existingIndex: existing.file,
|
|
668
675
|
existingTotal: existing.count,
|
|
669
|
-
custom: isCustom
|
|
676
|
+
custom: isCustom
|
|
677
|
+
? { genre: plan.customGenre, materialType: plan.customMaterialType, allKinds: customAllKinds }
|
|
678
|
+
: null,
|
|
670
679
|
customKindPending: isCustom && !item.kind,
|
|
671
680
|
sourceFixed: plan.mode === 'other' ? 'other' : 'builtin',
|
|
672
681
|
});
|
|
@@ -969,12 +978,17 @@ export async function apply(ctx) {
|
|
|
969
978
|
// 题材和素材类型都可以随便写;source 记 other,不占用内置目录。
|
|
970
979
|
if (!SPECIAL.has(command) && tokens.length >= 2) {
|
|
971
980
|
const genre = stripQuotes(tokens[0]);
|
|
972
|
-
const
|
|
973
|
-
if (!genre || !
|
|
974
|
-
return notify(session, 'error', '用法:/fancy-material <题材>
|
|
981
|
+
const materialTypeRaw = stripQuotes(tokens.slice(1).join(' '));
|
|
982
|
+
if (!genre || !materialTypeRaw) {
|
|
983
|
+
return notify(session, 'error', '用法:/fancy-material <题材> <素材类型|all>(两个参数都不能为空)');
|
|
975
984
|
}
|
|
985
|
+
const allKinds = materialTypeRaw.toLowerCase() === 'all';
|
|
976
986
|
return await runGenerate(ctx, invocation, session, '', taskList, {
|
|
977
|
-
custom: {
|
|
987
|
+
custom: {
|
|
988
|
+
genre,
|
|
989
|
+
materialType: allKinds ? 'all' : materialTypeRaw,
|
|
990
|
+
allKinds,
|
|
991
|
+
},
|
|
978
992
|
});
|
|
979
993
|
}
|
|
980
994
|
// 其它单参数视为素材类型重点,例如 /fancy-material 地名
|
|
@@ -395,6 +395,20 @@ export function focusBlock(focus) {
|
|
|
395
395
|
return `本批用户指定的重点是「${focus.query}」,对应 ${list}。插件会按顺序逐个 kind 排队,每个批次只写一个 kind;不要生成其它 kind。其他质量、题材、追加和查询规则继续适用。`;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Resolve the queue for the two-parameter custom command.
|
|
400
|
+
*
|
|
401
|
+
* `materialType === 'all'` expands to every builtin kind, but keeps the
|
|
402
|
+
* custom mode (`source=other`). A known focus keeps its matched kinds; an
|
|
403
|
+
* unknown focus gets one placeholder item whose kind is chosen by the LLM.
|
|
404
|
+
*/
|
|
405
|
+
export function resolveCustomKinds({ materialType, kinds = [] }) {
|
|
406
|
+
if (String(materialType == null ? '' : materialType).trim().toLowerCase() === 'all') {
|
|
407
|
+
return [...MATERIAL_KINDS];
|
|
408
|
+
}
|
|
409
|
+
return Array.isArray(kinds) && kinds.length ? [...kinds] : ['__custom__'];
|
|
410
|
+
}
|
|
411
|
+
|
|
398
412
|
/**
|
|
399
413
|
* 自定义题材 + 自定义素材类型的本批规则。
|
|
400
414
|
*
|
|
@@ -403,7 +417,17 @@ export function focusBlock(focus) {
|
|
|
403
417
|
* - 素材类型可以不在 58 个 kind 里,模型可以自拟 kind;
|
|
404
418
|
* - 同一批只能用一个 kind,插件会在第一轮之后记住它。
|
|
405
419
|
*/
|
|
406
|
-
export function customFocusBlock({ genre, materialType, kinds = [] }) {
|
|
420
|
+
export function customFocusBlock({ genre, materialType, kinds = [], allKinds = false }) {
|
|
421
|
+
if (allKinds) {
|
|
422
|
+
return `本批是**用户自定义素材**:题材「${genre}」,素材类型「all」,覆盖全部 ${MATERIAL_KINDS.length} 个 kind。
|
|
423
|
+
|
|
424
|
+
- 插件会把 ${MATERIAL_KINDS.length} 个 kind 排成队列,逐个 kind 派活。本批只写「本次运行」里指定的**一个** kind;不要混写,也不要自己切换到下一个 kind。
|
|
425
|
+
- 每个 kind 都要严格遵守「素材类型总表」里对应的质量要求。
|
|
426
|
+
- source 固定写 \`other\`,不要写 \`builtin\`。
|
|
427
|
+
- tags 和 genres 都是数组:先想清楚这个素材能适配哪些题材/标签,再全部写进去。例如「都市高武」相关素材可以写 tags: ["都市","高武","都市高武", ...],genres: ["都市高武","都市","高武"]。
|
|
428
|
+
- genres 必须原样包含用户题材「${genre}」;可以再附加其它适用题材(1–5 个)。
|
|
429
|
+
- 其他质量、查询、追加规则继续适用。`;
|
|
430
|
+
}
|
|
407
431
|
const known = Array.isArray(kinds) && kinds.length
|
|
408
432
|
? '用户素材类型匹配到内置 kind:' + kinds.map((kind) => `\`${kind}\`(${KIND_LABELS[kind] || kind})`).join('、') + '。'
|
|
409
433
|
: '用户素材类型不在内置表内;请自拟一个稳定的小写 snake_case kind(例如 `custom_xxx`)。';
|
|
@@ -24,6 +24,7 @@ export function helpText() {
|
|
|
24
24
|
/fancy-material 生成全部素材类型:${MATERIAL_KINDS.length} 个 kind,每个新增 50 条
|
|
25
25
|
/fancy-material <素材类型> 只生成指定类型,例如:/fancy-material 地名
|
|
26
26
|
/fancy-material <题材> <素材类型> 自定义题材+素材类型,source=other,例如:/fancy-material 都市高武 地名
|
|
27
|
+
/fancy-material <题材> all 生成该题材下全部 58 个 kind,source=other,例如:/fancy-material 都市高武 all
|
|
27
28
|
/fancy-material import <文件> 导入 JSONL;导入前先校验格式
|
|
28
29
|
/fancy-material init 创建/补齐素材库 schema、索引和查询/校验脚本
|
|
29
30
|
/fancy-material remove 删除整个素材库(会二次确认)
|
|
@@ -38,7 +39,7 @@ export function helpText() {
|
|
|
38
39
|
- 未指定类型:${MATERIAL_KINDS.length} 个 kind 全部排队。
|
|
39
40
|
- 题材来源:优先 _novel_topic.json,其次 _novel_topic_suggestion.json;都没有时弹框确认后使用内置全题材。
|
|
40
41
|
- 指定类型:只生成指定 kind,题材来源不变,source=builtin。
|
|
41
|
-
- 自定义题材+素材类型:题材和素材类型都可以随便写,插件把它们交给 LLM
|
|
42
|
+
- 自定义题材+素材类型:题材和素材类型都可以随便写,插件把它们交给 LLM;第二个参数写 all 表示全部 58 个 kind。生成结果 source=other,不占用内置 kind 目录。
|
|
42
43
|
- 不设库内上限:运行两次就是每个 kind 累计 100 条;已有素材只用于去重。
|
|
43
44
|
- 中断后重跑会开始新一轮 50 条配额,已经导入的素材不会撤销。
|
|
44
45
|
- 只追加,不覆盖;同 kind 同 name 的素材会被跳过。
|
|
@@ -147,7 +148,7 @@ export function generationPrompt({
|
|
|
147
148
|
lines.push('- 题材模式:' + modeLabel);
|
|
148
149
|
if (Array.isArray(genres) && genres.length) lines.push('- 本次题材:' + genres.join('、'));
|
|
149
150
|
if (custom) {
|
|
150
|
-
lines.push('- 用户素材类型:' + custom.materialType);
|
|
151
|
+
lines.push('- 用户素材类型:' + (custom.allKinds ? 'all(全部 ' + MATERIAL_KINDS.length + ' 个素材类型)' : custom.materialType));
|
|
151
152
|
lines.push('- 素材来源:**other**(用户自定义素材,不是内置目录)');
|
|
152
153
|
lines.push('- 标签要求:一个素材可以适配多个题材/标签;tags 和 genres 都要写全,不要只写一个主题材。');
|
|
153
154
|
}
|