@cloud411716/fancy-webnovel 4.1.0 → 4.3.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/material-library/README.md +34 -11
- package/docs/material-library/import.js +13 -4
- package/docs/material-library/prompt.md +249 -198
- package/docs/material-library/sample.jsonl +2 -2
- package/docs/material-library/schema.surql +5 -2
- package/lib/material-db.js +4 -4
- package/package.json +1 -1
- package/plugins/fancy-bootstrap/index.js +1 -1
- package/plugins/fancy-db/index.js +1 -1
- package/plugins/fancy-douyin/prompts/01-analysis-prompt.md +1 -1
- package/plugins/fancy-material/exporter.js +3 -1
- package/plugins/fancy-material/index.js +179 -37
- package/plugins/fancy-material/inventory.js +3 -2
- package/plugins/fancy-material/kinds.js +111 -5
- package/plugins/fancy-material/scripts/query.js +4 -2
- package/plugins/fancy-material/templates.js +65 -19
- package/plugins/fancy-material/validate.js +12 -5
|
@@ -23,7 +23,7 @@ export const KIND_GROUPS = [
|
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
title: '关系与情绪',
|
|
26
|
-
kinds: ['reaction'],
|
|
26
|
+
kinds: ['reaction', 'emotion_beat', 'relationship_dynamic'],
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
title: '能力',
|
|
@@ -42,7 +42,8 @@ export const KIND_GROUPS = [
|
|
|
42
42
|
{
|
|
43
43
|
title: '场景与感官',
|
|
44
44
|
kinds: [
|
|
45
|
-
'location_feature', 'weather', '
|
|
45
|
+
'location_feature', 'weather', 'sensory_visual', 'sensory_sound',
|
|
46
|
+
'sensory_smell', 'sensory_taste',
|
|
46
47
|
],
|
|
47
48
|
},
|
|
48
49
|
{
|
|
@@ -89,6 +90,8 @@ export const KIND_LABELS = {
|
|
|
89
90
|
person_voice: '说话风格',
|
|
90
91
|
person_background: '身份/职业/出身',
|
|
91
92
|
reaction: '反应/微表情',
|
|
93
|
+
emotion_beat: '情绪节拍',
|
|
94
|
+
relationship_dynamic: '关系动态',
|
|
92
95
|
ability_mechanism: '能力机制',
|
|
93
96
|
ability_activation: '发动条件',
|
|
94
97
|
ability_cost: '能力代价',
|
|
@@ -103,6 +106,8 @@ export const KIND_LABELS = {
|
|
|
103
106
|
weather: '天气',
|
|
104
107
|
sensory_taste: '味觉',
|
|
105
108
|
sensory_visual: '视觉画面',
|
|
109
|
+
sensory_sound: '听觉画面',
|
|
110
|
+
sensory_smell: '嗅觉画面',
|
|
106
111
|
color_word: '颜色描述',
|
|
107
112
|
light_word: '光影描述',
|
|
108
113
|
sound_word: '声音描述',
|
|
@@ -127,6 +132,74 @@ export const KIND_LABELS = {
|
|
|
127
132
|
trope: '套路/反套路',
|
|
128
133
|
};
|
|
129
134
|
|
|
135
|
+
/**
|
|
136
|
+
* 每个 kind 的「亮眼 + 好读」质量要求。
|
|
137
|
+
*
|
|
138
|
+
* 这是提示词里「素材类型总表」的第四列;与 KIND_LABELS/DEFAULT_HINTS 一起
|
|
139
|
+
* 构成 58 个 kind 的单一事实来源。help 只打印 kind + 中文名,提示词才展开
|
|
140
|
+
* 这一列,避免帮助信息过长。
|
|
141
|
+
*/
|
|
142
|
+
export const KIND_QUALITY = {
|
|
143
|
+
surname: '有典籍出处或历史渊源;避免极生僻字、多音易误读字;辨识度高于普通大姓,但读者能顺畅认读。',
|
|
144
|
+
given_name: '有画面感与意象底色;不用生僻字堆砌文雅感;读音顺口、字形协调,符合题材时代语感。',
|
|
145
|
+
nickname: '贴合身份/能力/特征,有记忆点,不低俗;有江湖/市井/组织语感,不是直白能力标签;顺口好记。',
|
|
146
|
+
place_name: '有空间画面与氛围底色,符合时代与地域;不用生僻字堆砌古风;自带故事感,不是“XX山/XX城”通用组合。',
|
|
147
|
+
faction_name: '有辨识度与阵营气质,贴合核心主张/行事风格;不空洞喊口号,不带“神秘/绝世/至尊”空泛词;长短适中。',
|
|
148
|
+
skill_name: '走意象章法路线,核心规则藏在名字里,不直白喊功能;搭配题材体例后缀(诀/式/令/法);不用生僻典故,能猜出效果方向。',
|
|
149
|
+
ability_name: '走规则凝练路线,不直接把物品载体当名字;简洁有记忆点,暗合能力核心逻辑;不晦涩、不堆术语。',
|
|
150
|
+
item_name: '走痕迹感路线,名字带数字/缺损/年代/主人痕迹至少一项;不是“形容词+通用名词”;有专属感,换名字功能不成立。',
|
|
151
|
+
monster_name: '有生态感,能脑补外形与习性;不猎奇、不堆恐怖词;贴合生存环境与世界观。',
|
|
152
|
+
mythic_being: '有氛围感与分量感,自带传说底色;不照搬现有神话本名,做原创化改编;不用极端生僻字。',
|
|
153
|
+
rank_name: '有层级递进感,相邻等级能看出高低;不直白用“一级/初级”;符合体系文化底色,能快速理解高低。',
|
|
154
|
+
person_appearance: '只写一个有辨识度的局部细节,不从头到脚列清单;细节暗示性格/身份/经历;避免“剑眉星目/肤若凝脂”。',
|
|
155
|
+
person_temperament: '通过动作/姿态/气场体现气质,不直接写“沉稳/清冷/威严”;有具体参照物;一个细节立住一种气质。',
|
|
156
|
+
person_personality: '用具体行为模式体现性格,不贴标签;性格能制造冲突或选择困境;有反差空间。',
|
|
157
|
+
person_habit: '有剧情价值,能成为伏笔/识别点/弱点;贴合身份经历,不为特别而特别;日常场景能体现。',
|
|
158
|
+
person_voice: '有专属辨识度,能和其他角色区分;贴合身份/年龄/性格;不用方言梗/网络热梗。',
|
|
159
|
+
person_background: '自带冲突点与故事空间,不是扁平“XX掌门/XX总裁”;有明面身份与隐藏底色反差;能引出剧情矛盾。',
|
|
160
|
+
reaction: '写细微肢体/神态动作,不直接写“生气/开心/惊讶”;符合人物性格,有专属反应模式;能藏潜台词。',
|
|
161
|
+
emotion_beat: '有明确情绪转向,不平铺直叙;通过具体物件/动作触发转折,不直白心理独白;有余韵。',
|
|
162
|
+
relationship_dynamic: '有天然立场冲突或情感拉扯,不是扁平“朋友/敌人”;相处模式有专属细节,换两个人不成立;有变化空间。',
|
|
163
|
+
ability_mechanism: '采用「日常规则×超能力」嫁接逻辑,不是把日常物品当武器;规则清晰自洽;跳出“攻击/防御/治疗”通用框架。',
|
|
164
|
+
ability_activation: '和能力机制深度绑定,不是通用“意念发动/消耗内力”;有专属触发动作/场景/时机;有操作门槛。',
|
|
165
|
+
ability_cost: '和能力核心规则联动,不是通用“耗体力/耗精神/有冷却”;代价有具体日常场景落点;代价与收益对等。',
|
|
166
|
+
ability_limit: '明确边界与例外,不是简单“每天3次/持续10秒”;限制来自能力规则漏洞;能被对手利用,形成博弈。',
|
|
167
|
+
ability_counter: '利用能力规则漏洞破解,不是直白“毁掉媒介/打断施法”;有智斗感,反常识但符合规则;反制也有代价。',
|
|
168
|
+
power_source: '和能力机制深度绑定,不是随便找物品当引子;来源属性决定能力特性与弱点;不是“天地灵气”通用答案。',
|
|
169
|
+
item_form: '有具体尺寸/纹路/磨损痕迹,不是“古朴/精美/神秘”空泛形容;外形暗示功能与来历;有使用痕迹。',
|
|
170
|
+
item_material: '有专属质感,不是“精钢/玉石/木头”通用材质;材质决定特性与弱点;贴合世界观,有合理来源。',
|
|
171
|
+
item_function: '有明确规则边界,不是万能神器;功能与外形/材质逻辑自洽;有副作用与使用门槛。',
|
|
172
|
+
item_visual: '有记忆点,激活/使用时有专属感官表现;不是“金光闪闪/嗡嗡作响”通用特效;暗示等级与状态。',
|
|
173
|
+
location_feature: '有明确空间结构与动线,不是“繁华/荒凉/阴森”笼统形容;能影响剧情,能设计战斗/埋伏/谈判;有专属标识。',
|
|
174
|
+
weather: '带情绪属性,不是单纯“下雨/刮风/晴天”;能影响能力/推动剧情/烘托氛围;有具体感官细节。',
|
|
175
|
+
sensory_visual: '有具体参照物与光影状态,不是“好看/恐怖/壮观”空泛评价;有情绪底色;细节精准,能立刻脑补。',
|
|
176
|
+
sensory_sound: '有具体声源与质感,不是“响亮/刺耳/诡异”笼统描述;能暗示信息/烘托情绪/制造悬念;有辨识度。',
|
|
177
|
+
sensory_smell: '有具体气味源与浓度变化,不是“清香/恶臭/诡异”直白形容;能暗示环境/伏笔/调动情绪;贴合场景逻辑。',
|
|
178
|
+
sensory_taste: '有具体味道层次与参照物,不是“好吃/苦涩/甘甜”简单描述;对应人物状态/剧情转折;有生活质感。',
|
|
179
|
+
color_word: '必须绑定具体事物/场景,不是纯色名词;带情绪与质感,不是“火红/天蓝”词典搭配;不用生僻色名。',
|
|
180
|
+
light_word: '明确光源与光影形态,不是“明亮/昏暗/耀眼”笼统形容;带氛围属性;有具体形态。',
|
|
181
|
+
sound_word: '绑定具体声源与质感,不是“响亮/清脆/沉闷”形容词;用拟物/拟声表达;不用生僻拟声词。',
|
|
182
|
+
smell_word: '绑定具体气味源,不是“香味/臭味”笼统概括;带情绪与场景属性;有层次变化。',
|
|
183
|
+
touch_word: '绑定具体材质与温度,不是“光滑/粗糙/冰冷”通用形容;有体感细节;贴合日常经验。',
|
|
184
|
+
effect_word: '有具体形态与运动方式,不是“炫酷/炸裂/神秘”空泛评价;和规则绑定;有画面记忆点。',
|
|
185
|
+
speed_word: '用具体参照物体现快慢强弱,不是“极快/巨力”形容词;有体感对比;不用夸张虚词。',
|
|
186
|
+
atmosphere_word: '绑定具体场景,不是“紧张/温馨/诡异”情绪标签;用细节烘托;有代入感。',
|
|
187
|
+
appearance_word: '写局部特征,不是“美丽/帅气/魁梧”笼统评价;有辨识度,能对应性格;避免模板化容貌。',
|
|
188
|
+
expression_word: '用细节动作体现情绪,不是“愤怒/悲伤/温柔”直白标签;有微表情细节,能传递潜台词;不脸谱化。',
|
|
189
|
+
action_verb: '有力度与节奏质感,不是“打/走/看”通用动词;动作带人物性格与状态;精准凝练。',
|
|
190
|
+
world_rule: '有明确适用范围/执行方式/违规代价,不是“弱肉强食/强者为尊”空话;能塑造冲突/限制能力/推动剧情;有例外与漏洞。',
|
|
191
|
+
faction_culture: '有具体行为规矩/奖惩方式,不是“团结/残暴/神秘”空泛标签;能解释势力行事逻辑;有内部矛盾空间。',
|
|
192
|
+
faction_symbol: '有专属造型与含义,对应势力核心主张;有使用场景与禁忌,不是单纯 logo;能成为剧情线索。',
|
|
193
|
+
ritual: '有完整流程/禁忌/目的与代价,不是形式主义;能引出剧情/塑造氛围/埋伏笔;符合世界观逻辑。',
|
|
194
|
+
brainstorm: '采用远域嫁接逻辑,两个不相关领域规则融合,不是换皮老套路;一句话讲清核心;有扩展成长线空间。',
|
|
195
|
+
conflict_seed: '双方都有明确目标与底线,不是“好人遇坏人”脸谱对立;冲突有日常落点;有升级空间。',
|
|
196
|
+
conflict_escalation: '升级伴随代价加码,不是单纯“叫更多人来”;戳中双方核心痛点;符合人物立场,不强行降智。',
|
|
197
|
+
plot_twist: '有伏笔空间,不是空降反转;颠覆认知但回头看符合逻辑;反转带来新冲突。',
|
|
198
|
+
mystery_seed: '有可追寻线索,不是“神秘古老秘密”空话;有明确 stakes;真相比诡异更有冲击力。',
|
|
199
|
+
payoff_scene: '有对应憋屈铺垫,不是空降爽点;落点符合题材调性;爽完有余味与新问题。',
|
|
200
|
+
trope: '反套路不是硬反过来写,而是让反套路产生新麻烦与代价;点出读者固有预期再打破;有落地场景。',
|
|
201
|
+
};
|
|
202
|
+
|
|
130
203
|
const DEFAULT_HINTS = {
|
|
131
204
|
surname: '一个姓氏',
|
|
132
205
|
given_name: '一个名',
|
|
@@ -146,6 +219,8 @@ const DEFAULT_HINTS = {
|
|
|
146
219
|
person_voice: '一句说话风格',
|
|
147
220
|
person_background: '一句身份/职业/出身',
|
|
148
221
|
reaction: '一个反应或微表情',
|
|
222
|
+
emotion_beat: '一个情绪转折的具体瞬间',
|
|
223
|
+
relationship_dynamic: '一种人物关系的相处模式或张力点',
|
|
149
224
|
ability_mechanism: '一句能力机制',
|
|
150
225
|
ability_activation: '一句发动条件',
|
|
151
226
|
ability_cost: '一句能力代价',
|
|
@@ -160,6 +235,8 @@ const DEFAULT_HINTS = {
|
|
|
160
235
|
weather: '一句天气',
|
|
161
236
|
sensory_taste: '一句味觉',
|
|
162
237
|
sensory_visual: '一句视觉画面',
|
|
238
|
+
sensory_sound: '一句带声源与质感的声音场景',
|
|
239
|
+
sensory_smell: '一句带气味源与浓度变化的气味场景',
|
|
163
240
|
color_word: '一个颜色描述词',
|
|
164
241
|
light_word: '一个光影描述词',
|
|
165
242
|
sound_word: '一个声音描述词',
|
|
@@ -247,6 +324,12 @@ const EXTRA_ALIASES = {
|
|
|
247
324
|
冲突: ['conflict_seed'],
|
|
248
325
|
反转: ['plot_twist'],
|
|
249
326
|
场景: ['location_feature'],
|
|
327
|
+
情绪节拍: ['emotion_beat'],
|
|
328
|
+
关系动态: ['relationship_dynamic'],
|
|
329
|
+
听觉: ['sensory_sound', 'sound_word'],
|
|
330
|
+
声音场景: ['sensory_sound'],
|
|
331
|
+
嗅觉: ['sensory_smell', 'smell_word'],
|
|
332
|
+
气味场景: ['sensory_smell'],
|
|
250
333
|
};
|
|
251
334
|
|
|
252
335
|
function normalize(text) {
|
|
@@ -291,10 +374,10 @@ export function renderKindTable() {
|
|
|
291
374
|
for (const group of KIND_GROUPS) {
|
|
292
375
|
lines.push(`**${group.title}**`);
|
|
293
376
|
lines.push('');
|
|
294
|
-
lines.push('| kind | 中文名 | name 写什么 |');
|
|
295
|
-
lines.push('| --- | --- | --- |');
|
|
377
|
+
lines.push('| kind | 中文名 | name 写什么 | 质量要求(亮眼 + 好读) |');
|
|
378
|
+
lines.push('| --- | --- | --- | --- |');
|
|
296
379
|
for (const kind of group.kinds) {
|
|
297
|
-
lines.push(`| \`${kind}\` | ${KIND_LABELS[kind] || kind} | ${DEFAULT_HINTS[kind] || ''} |`);
|
|
380
|
+
lines.push(`| \`${kind}\` | ${KIND_LABELS[kind] || kind} | ${DEFAULT_HINTS[kind] || ''} | ${KIND_QUALITY[kind] || ''} |`);
|
|
298
381
|
}
|
|
299
382
|
lines.push('');
|
|
300
383
|
}
|
|
@@ -311,3 +394,26 @@ export function focusBlock(focus) {
|
|
|
311
394
|
const list = focus.kinds.map((kind) => `\`${kind}\`(${KIND_LABELS[kind] || kind})`).join('、');
|
|
312
395
|
return `本批用户指定的重点是「${focus.query}」,对应 ${list}。插件会按顺序逐个 kind 排队,每个批次只写一个 kind;不要生成其它 kind。其他质量、题材、追加和查询规则继续适用。`;
|
|
313
396
|
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* 自定义题材 + 自定义素材类型的本批规则。
|
|
400
|
+
*
|
|
401
|
+
* 与内置目录最大的区别:
|
|
402
|
+
* - source 必须是 other;
|
|
403
|
+
* - 素材类型可以不在 58 个 kind 里,模型可以自拟 kind;
|
|
404
|
+
* - 同一批只能用一个 kind,插件会在第一轮之后记住它。
|
|
405
|
+
*/
|
|
406
|
+
export function customFocusBlock({ genre, materialType, kinds = [] }) {
|
|
407
|
+
const known = Array.isArray(kinds) && kinds.length
|
|
408
|
+
? '用户素材类型匹配到内置 kind:' + kinds.map((kind) => `\`${kind}\`(${KIND_LABELS[kind] || kind})`).join('、') + '。'
|
|
409
|
+
: '用户素材类型不在内置表内;请自拟一个稳定的小写 snake_case kind(例如 `custom_xxx`)。';
|
|
410
|
+
return `本批是**用户自定义素材**:题材「${genre}」,素材类型「${materialType}」。
|
|
411
|
+
|
|
412
|
+
- ${known}
|
|
413
|
+
- 如果素材类型明显对应总表里的某个 kind,优先使用内置 kind;否则自拟 kind。
|
|
414
|
+
- 同一批文件里的所有记录必须使用**同一个** kind;下一批插件会沿用你这次确定的 kind。
|
|
415
|
+
- source 固定写 \`other\`,不要写 \`builtin\`。
|
|
416
|
+
- tags 和 genres 都是数组:先想清楚这个素材能适配哪些题材/标签,再全部写进去。例如「都市高武」相关素材可以写 tags: ["都市","高武","都市高武", ...],genres: ["都市高武","都市","高武"]。
|
|
417
|
+
- genres 必须原样包含用户题材「${genre}」;可以再附加其它适用题材(1–5 个)。
|
|
418
|
+
- 其他质量、查询、追加规则继续适用。`;
|
|
419
|
+
}
|
|
@@ -132,7 +132,8 @@ function rowText(row) {
|
|
|
132
132
|
const tags = Array.isArray(row.tags) ? row.tags.join('、') : '';
|
|
133
133
|
const genres = Array.isArray(row.genres) ? row.genres.join('、') : '';
|
|
134
134
|
const source = row.source === 'other' ? ' | other' : '';
|
|
135
|
-
|
|
135
|
+
const group = row.group_id ? ' | ' + row.group_id : '';
|
|
136
|
+
return `[${row.kind}] ${row.name}${tags ? ' | ' + tags : ''}${genres ? ' | ' + genres : ''}${group}${source}`;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
async function main() {
|
|
@@ -172,7 +173,7 @@ async function main() {
|
|
|
172
173
|
if (opts.name) where.push('name = ' + q(opts.name));
|
|
173
174
|
if (opts.search) where.push('name @1@ ' + q(opts.search));
|
|
174
175
|
|
|
175
|
-
let sql = 'SELECT id, kind, name, tags, genres, source';
|
|
176
|
+
let sql = 'SELECT id, kind, name, tags, genres, group_id, source';
|
|
176
177
|
if (opts.search) sql += ', search::score(1) AS score';
|
|
177
178
|
sql += ' FROM material';
|
|
178
179
|
if (where.length) sql += ' WHERE ' + where.join(' AND ');
|
|
@@ -238,6 +239,7 @@ async function main() {
|
|
|
238
239
|
name: row.name,
|
|
239
240
|
tags: row.tags || [],
|
|
240
241
|
genres: row.genres || [],
|
|
242
|
+
...(row.group_id ? { group_id: row.group_id } : {}),
|
|
241
243
|
...(row.score !== undefined ? { score: row.score } : {}),
|
|
242
244
|
}) + '\n');
|
|
243
245
|
}
|
|
@@ -2,30 +2,55 @@
|
|
|
2
2
|
* fancy-material command text for atomic material blocks.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { BUILTIN_GENRES } from '#material-topic';
|
|
6
|
+
import { KIND_GROUPS, KIND_LABELS, MATERIAL_KINDS } from './kinds.js';
|
|
7
|
+
|
|
8
|
+
function wrapList(items, perLine = 8) {
|
|
9
|
+
const lines = [];
|
|
10
|
+
for (let i = 0; i < items.length; i += perLine) {
|
|
11
|
+
lines.push(' ' + items.slice(i, i + perLine).join('、'));
|
|
12
|
+
}
|
|
13
|
+
return lines.join('\n');
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
export function helpText() {
|
|
17
|
+
const genreBlock = wrapList(BUILTIN_GENRES, 8);
|
|
18
|
+
const kindBlock = KIND_GROUPS.map((group) => {
|
|
19
|
+
const items = group.kinds.map((kind) => `${kind}(${KIND_LABELS[kind] || kind})`);
|
|
20
|
+
return `- ${group.title}(${group.kinds.length}):` + items.join('、');
|
|
21
|
+
}).join('\n');
|
|
6
22
|
return `🧩 素材库 用法
|
|
7
23
|
|
|
8
|
-
/fancy-material
|
|
9
|
-
/fancy-material <素材类型>
|
|
10
|
-
/fancy-material
|
|
11
|
-
/fancy-material
|
|
12
|
-
/fancy-material
|
|
13
|
-
/fancy-material
|
|
14
|
-
/fancy-material
|
|
15
|
-
/fancy-material
|
|
24
|
+
/fancy-material 生成全部素材类型:${MATERIAL_KINDS.length} 个 kind,每个新增 50 条
|
|
25
|
+
/fancy-material <素材类型> 只生成指定类型,例如:/fancy-material 地名
|
|
26
|
+
/fancy-material <题材> <素材类型> 自定义题材+素材类型,source=other,例如:/fancy-material 都市高武 地名
|
|
27
|
+
/fancy-material import <文件> 导入 JSONL;导入前先校验格式
|
|
28
|
+
/fancy-material init 创建/补齐素材库 schema、索引和查询/校验脚本
|
|
29
|
+
/fancy-material remove 删除整个素材库(会二次确认)
|
|
30
|
+
/fancy-material prompt 展示全类型提示词,不发送给 LLM
|
|
31
|
+
/fancy-material export 把素材库导出为 <工作区>/素材库.md
|
|
32
|
+
/fancy-material help 显示本帮助
|
|
16
33
|
|
|
17
34
|
说明:
|
|
18
|
-
-
|
|
35
|
+
- 素材是原子积木,每条有 id / kind / name / tags / genres / group_id / note / source;group_id 可选。
|
|
36
|
+
- tags 和 genres 都是数组:tags 3–8 个,genres 1–5 个;一个素材可以同时适配多个题材/标签。
|
|
19
37
|
- 每次运行:每个 kind 新增 50 条;每批最多 10 条,插件自动分批直到完成。
|
|
20
|
-
-
|
|
38
|
+
- 未指定类型:${MATERIAL_KINDS.length} 个 kind 全部排队。
|
|
21
39
|
- 题材来源:优先 _novel_topic.json,其次 _novel_topic_suggestion.json;都没有时弹框确认后使用内置全题材。
|
|
22
|
-
- 指定类型:只生成指定 kind
|
|
40
|
+
- 指定类型:只生成指定 kind,题材来源不变,source=builtin。
|
|
41
|
+
- 自定义题材+素材类型:题材和素材类型都可以随便写,插件把它们交给 LLM;生成结果 source=other,不占用内置 kind 目录。
|
|
23
42
|
- 不设库内上限:运行两次就是每个 kind 累计 100 条;已有素材只用于去重。
|
|
24
43
|
- 中断后重跑会开始新一轮 50 条配额,已经导入的素材不会撤销。
|
|
25
44
|
- 只追加,不覆盖;同 kind 同 name 的素材会被跳过。
|
|
26
45
|
- 全文索引:name(中文 ngram);tags / genres 精确过滤。
|
|
27
46
|
- 查询脚本:<工作区>/.fancy-tools/fancy-material/query.js
|
|
28
|
-
- 校验脚本:<工作区>/.fancy-tools/fancy-material/validate.js
|
|
47
|
+
- 校验脚本:<工作区>/.fancy-tools/fancy-material/validate.js
|
|
48
|
+
|
|
49
|
+
内置题材(${BUILTIN_GENRES.length}):
|
|
50
|
+
${genreBlock}
|
|
51
|
+
|
|
52
|
+
素材类型(${MATERIAL_KINDS.length}):
|
|
53
|
+
${kindBlock}`;
|
|
29
54
|
}
|
|
30
55
|
|
|
31
56
|
export const DEFAULT_TARGET_PER_KIND = 50;
|
|
@@ -46,14 +71,17 @@ export function promptDisplayText(prompt) {
|
|
|
46
71
|
return `📚 fancy-material 提示词(未发送给 LLM)\n\n${String(prompt || '').trim()}`;
|
|
47
72
|
}
|
|
48
73
|
|
|
49
|
-
function compactRules(genres, queryScript, workspace) {
|
|
74
|
+
function compactRules(genres, queryScript, workspace, sourceFixed = 'builtin') {
|
|
50
75
|
const lines = [
|
|
51
76
|
'## 本批规则(与最初提示词一致)',
|
|
52
77
|
'',
|
|
53
78
|
'- 只写本批指定的一个 kind;不要把其它 kind 混进同一个文件。',
|
|
54
79
|
'- 每条必须独立、具体、可复用;拒绝“火红、耀眼、神秘、强大”这类空泛词。',
|
|
55
80
|
'- 命名类必须有具体锚点;拒绝“复原眼、章眼、旧仓单、神秘剑、黑色长刀”这类废名。',
|
|
56
|
-
'- 字段只能是 id / kind / name / tags / genres / note / source;
|
|
81
|
+
'- 字段只能是 id / kind / name / tags / genres / group_id / note / source;'
|
|
82
|
+
+ 'source 写 ' + sourceFixed + ';tags 3–8 个,genres 1–5 个。',
|
|
83
|
+
'- tags 和 genres 都是数组:一个素材能适配多个题材/标签时,把它们都写进去;'
|
|
84
|
+
+ '例如「都市高武」可以写 tags: ["都市","高武","都市高武", ...]。',
|
|
57
85
|
];
|
|
58
86
|
if (Array.isArray(genres) && genres.length) {
|
|
59
87
|
lines.push('- genres 必须原样包含本次题材之一:' + genres.join('、'));
|
|
@@ -90,6 +118,9 @@ export function generationPrompt({
|
|
|
90
118
|
queryScript,
|
|
91
119
|
existingIndex,
|
|
92
120
|
existingTotal,
|
|
121
|
+
custom = null,
|
|
122
|
+
customKindPending = false,
|
|
123
|
+
sourceFixed = 'builtin',
|
|
93
124
|
}) {
|
|
94
125
|
const lines = [];
|
|
95
126
|
if (includeBase && base) {
|
|
@@ -97,7 +128,7 @@ export function generationPrompt({
|
|
|
97
128
|
} else {
|
|
98
129
|
lines.push('## 继续生成(同一素材库)', '');
|
|
99
130
|
lines.push('继续遵守最初提示词中的角色、写作原则、质量红线、命名标准、描写标准、查询与追加规则。不要重新解释规则,直接写本批素材。', '');
|
|
100
|
-
lines.push(...compactRules(genres, queryScript, workspace), '');
|
|
131
|
+
lines.push(...compactRules(genres, queryScript, workspace, sourceFixed), '');
|
|
101
132
|
}
|
|
102
133
|
|
|
103
134
|
lines.push('## 本次运行', '');
|
|
@@ -110,9 +141,16 @@ export function generationPrompt({
|
|
|
110
141
|
? 'suggestion(_novel_topic_suggestion.json)'
|
|
111
142
|
: mode === 'builtin'
|
|
112
143
|
? 'builtin(内置全题材)'
|
|
113
|
-
:
|
|
144
|
+
: mode === 'other'
|
|
145
|
+
? 'other(用户自定义题材 + 素材类型)'
|
|
146
|
+
: String(mode || '未指定');
|
|
114
147
|
lines.push('- 题材模式:' + modeLabel);
|
|
115
148
|
if (Array.isArray(genres) && genres.length) lines.push('- 本次题材:' + genres.join('、'));
|
|
149
|
+
if (custom) {
|
|
150
|
+
lines.push('- 用户素材类型:' + custom.materialType);
|
|
151
|
+
lines.push('- 素材来源:**other**(用户自定义素材,不是内置目录)');
|
|
152
|
+
lines.push('- 标签要求:一个素材可以适配多个题材/标签;tags 和 genres 都要写全,不要只写一个主题材。');
|
|
153
|
+
}
|
|
116
154
|
if (focus && focus.query) {
|
|
117
155
|
const kinds = (focus.kinds || []).map((item) => `\`${item}\``).join('、');
|
|
118
156
|
lines.push('- 本次重点:' + focus.query + (kinds ? '(' + kinds + ')' : ''));
|
|
@@ -129,6 +167,13 @@ export function generationPrompt({
|
|
|
129
167
|
lines.push('- 本批要写:' + requestCount + ' 条(只写 `' + kind + '`)');
|
|
130
168
|
lines.push('- 写不满时可以少写;不要用重复、换皮、空泛命名凑数,插件会继续补下一批');
|
|
131
169
|
lines.push('- 写完本批后立即结束本轮;插件会自动发下一批,不要在同一个文件里继续写其它 kind');
|
|
170
|
+
} else if (customKindPending) {
|
|
171
|
+
lines.push('- 本次目标:用户自定义素材 1 个 kind,本次配额 ' + targetPerKind + ' 条');
|
|
172
|
+
lines.push('- 本批 kind:**由你选择**。如果用户素材类型对应素材类型总表里的某个 kind,直接用该 kind;否则自拟一个稳定的小写 snake_case kind(例如 `custom_xxx`)。');
|
|
173
|
+
lines.push('- 同一批文件里的所有记录必须使用同一个 kind;下一批会沿用你这次确定的 kind。');
|
|
174
|
+
lines.push('- 本批要写:' + requestCount + ' 条');
|
|
175
|
+
lines.push('- 写不满时可以少写;不要用重复、换皮、空泛命名凑数,插件会继续补下一批');
|
|
176
|
+
lines.push('- 写完本批后立即结束本轮;插件会自动发下一批,不要在同一个文件里继续写其它 kind');
|
|
132
177
|
} else {
|
|
133
178
|
lines.push('- 本次目标:每个 kind ' + targetPerKind + ' 条');
|
|
134
179
|
lines.push('- 每批最多:' + batchSize + ' 条');
|
|
@@ -139,14 +184,15 @@ export function generationPrompt({
|
|
|
139
184
|
|
|
140
185
|
lines.push('');
|
|
141
186
|
lines.push('写入要求:');
|
|
142
|
-
lines.push('1. 只把 JSONL 写进目标文件,一行一个对象;字段只能是 id / kind / name / tags / genres / note / source,source 固定写
|
|
187
|
+
lines.push('1. 只把 JSONL 写进目标文件,一行一个对象;字段只能是 id / kind / name / tags / genres / group_id / note / source,source 固定写 ' + sourceFixed + '。');
|
|
188
|
+
lines.push(' tags 和 genres 都是数组:一个素材能适配多个题材/标签时,把它们都写进去(例如 都市高武 → 都市、高武、都市高武)。');
|
|
143
189
|
lines.push('2. 不要在文件里写 Markdown 代码围栏、标题、解释、前后缀。');
|
|
144
190
|
lines.push('3. 可以直接写 JSONL,也可以使用 Python/Node 生成器;生成器放 <工作区>/.tmp/,输出必须是目标 JSONL。');
|
|
145
191
|
lines.push('4. 本批文件只放本批素材;数据库导入只追加,不会覆盖已有素材。');
|
|
146
192
|
lines.push('5. 生成前先用查询脚本/索引检查候选名字;同 kind 同 name 已存在就换一个。');
|
|
147
193
|
lines.push('6. 写完后运行 validate.js;失败就按错误修正,直到通过。');
|
|
148
194
|
lines.push('7. 不要自己运行导入命令;插件会负责最终校验、按 kind+name 去重并追加导入。');
|
|
149
|
-
if (kind) {
|
|
195
|
+
if (kind || customKindPending) {
|
|
150
196
|
lines.push('8. 本批写完后(尽量写满 ' + requestCount + ' 条)通过校验,只回复:已写入 <目标文件路径>;然后结束本轮,等插件发下一批。');
|
|
151
197
|
} else {
|
|
152
198
|
lines.push('8. 写完后只回复:已写入 <目标文件路径>。');
|
|
@@ -210,7 +256,7 @@ export function generationRunText({
|
|
|
210
256
|
if (incomplete.length) {
|
|
211
257
|
lines.push('未完成:' + incomplete.length + ' 个 kind');
|
|
212
258
|
for (const item of incomplete.slice(0, 20)) {
|
|
213
|
-
lines.push(' - ' + item.kind + ':' + item.generated + '/' + targetPerKind
|
|
259
|
+
lines.push(' - ' + (item.label || item.kind || '自定义素材') + ':' + item.generated + '/' + targetPerKind
|
|
214
260
|
+ (item.reason ? '(' + item.reason + ')' : ''));
|
|
215
261
|
}
|
|
216
262
|
if (incomplete.length > 20) lines.push(' - 其余 ' + (incomplete.length - 20) + ' 个省略');
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import fs from 'node:fs';
|
|
12
12
|
import { MATERIAL_KINDS } from './kinds.js';
|
|
13
13
|
|
|
14
|
-
const ALLOWED = new Set(['id', 'kind', 'name', 'tags', 'genres', 'note', 'source']);
|
|
14
|
+
const ALLOWED = new Set(['id', 'kind', 'name', 'tags', 'genres', 'group_id', 'note', 'source']);
|
|
15
15
|
const ID_RE = /^[a-z][a-z0-9_]*$/;
|
|
16
16
|
|
|
17
17
|
function usage() {
|
|
@@ -22,11 +22,11 @@ function usage() {
|
|
|
22
22
|
|
|
23
23
|
检查:
|
|
24
24
|
- 一行一个合法 JSON 对象
|
|
25
|
-
- 字段只能是 id / kind / name / tags / genres / note / source
|
|
25
|
+
- 字段只能是 id / kind / name / tags / genres / group_id / note / source
|
|
26
26
|
- source 只能是 builtin / other
|
|
27
27
|
- builtin 的 kind 必须在允许列表内,id 以 kind 开头
|
|
28
28
|
- other 的 kind 不受限制
|
|
29
|
-
- tags 3–8 个,genres 1–
|
|
29
|
+
- tags 3–8 个,genres 1–5 个(都是数组)
|
|
30
30
|
- 同文件内 kind + name 不重复
|
|
31
31
|
|
|
32
32
|
退出码:0=通过,1=有错误,2=用法错误`;
|
|
@@ -53,13 +53,20 @@ function validate(raw, line) {
|
|
|
53
53
|
if (typeof tag !== 'string' || !tag.trim()) errors.push('第 ' + line + ' 行:tags 元素必须是非空字符串');
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
if (!Array.isArray(raw.genres) || raw.genres.length < 1 || raw.genres.length >
|
|
57
|
-
errors.push('第 ' + line + ' 行:genres 需要 1–
|
|
56
|
+
if (!Array.isArray(raw.genres) || raw.genres.length < 1 || raw.genres.length > 5) {
|
|
57
|
+
errors.push('第 ' + line + ' 行:genres 需要 1–5 项');
|
|
58
58
|
} else {
|
|
59
59
|
for (const genre of raw.genres) {
|
|
60
60
|
if (typeof genre !== 'string' || !genre.trim()) errors.push('第 ' + line + ' 行:genres 元素必须是非空字符串');
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
if (raw.group_id !== undefined) {
|
|
64
|
+
if (typeof raw.group_id !== 'string' || !raw.group_id.trim()) {
|
|
65
|
+
errors.push('第 ' + line + ' 行:group_id 必须是非空字符串');
|
|
66
|
+
} else if (!/^group_[a-z0-9_]+_v4$/.test(raw.group_id.trim()) || raw.group_id.trim().length > 120) {
|
|
67
|
+
errors.push('第 ' + line + ' 行:group_id 格式必须是 group_<类型>_<序号>_v4:' + raw.group_id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
63
70
|
if (raw.note !== undefined && typeof raw.note !== 'string') {
|
|
64
71
|
errors.push('第 ' + line + ' 行:note 必须是字符串');
|
|
65
72
|
}
|