@cloud411716/fancy-webnovel 4.2.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.
@@ -17,7 +17,7 @@ import { readSecrets, readWorkspace } from './workspace.js';
17
17
  import { rpcUrl, startServer } from './surreal-server.js';
18
18
 
19
19
  export const MATERIAL_DATABASE = 'material_library';
20
- export const MATERIAL_SCHEMA_VERSION = 6;
20
+ export const MATERIAL_SCHEMA_VERSION = 7;
21
21
 
22
22
  const SCHEMA_FILE = fileURLToPath(new URL('../docs/material-library/schema.surql', import.meta.url));
23
23
 
@@ -57,7 +57,7 @@ export async function connectMaterial(root) {
57
57
  /**
58
58
  * Ensure the material database and its schema exist. Idempotent.
59
59
  *
60
- * Schema v6 adds `source` (builtin/other) and narrows builtin kinds to the current 54-kind catalog. Before applying the
60
+ * Schema v7 adds `group_id` and the 58-kind catalog. It keeps the v6 `source` field. Before applying the
61
61
  * new ASSERT, rows belonging to retired kinds are removed; otherwise SurrealDB
62
62
  * refuses to overwrite the field because existing records no longer conform.
63
63
  *
@@ -97,8 +97,8 @@ export async function ensureMaterialDatabase(root) {
97
97
  await db.query(materialSchemaText());
98
98
  const tableInfo = await db.query('INFO FOR TABLE material;');
99
99
  const table = Array.isArray(tableInfo) && tableInfo[0] ? tableInfo[0] : {};
100
- if (!table.fields || !table.fields.source || !table.fields.kind || !table.fields.name || !table.fields.tags) {
101
- throw new Error('素材库 schema 初始化后仍未找到 material.kind/name/tags 字段。');
100
+ if (!table.fields || !table.fields.source || !table.fields.kind || !table.fields.name || !table.fields.tags || !table.fields.group_id) {
101
+ throw new Error('素材库 schema 初始化后仍未找到 material.kind/name/tags/group_id 字段。');
102
102
  }
103
103
  return {
104
104
  ok: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -304,7 +304,7 @@ export async function apply(ctx) {
304
304
  formatWorkspace(result.workspace),
305
305
  '',
306
306
  '数据库:schema ' + result.schema_version + ' · validation ' + result.validation_version,
307
- '素材库:' + (result.material?.database || 'material_library') + '(schema ' + (result.material?.schema_version || 6) + ')',
307
+ '素材库:' + (result.material?.database || 'material_library') + '(schema ' + (result.material?.schema_version || 7) + ')',
308
308
  '服务:' + (result.server.running ? '运行中' : '未运行'),
309
309
  ...(result.started && result.started.endpoint_changed
310
310
  ? ['⚠️ 原端口被另一个 SurrealDB 占用,已改用:' + result.started.endpoint]
@@ -151,7 +151,7 @@ export async function apply(ctx) {
151
151
  '✅ 工作区数据库初始化完成',
152
152
  '服务:' + (result.server.running ? '运行中' : '未运行'),
153
153
  'schema:' + result.schema_version + ' validation:' + result.validation_version,
154
- '素材库:' + (result.material?.database || 'material_library') + '(schema ' + (result.material?.schema_version || 6) + ')',
154
+ '素材库:' + (result.material?.database || 'material_library') + '(schema ' + (result.material?.schema_version || 7) + ')',
155
155
  '项目库:' + result.projects.length + ' 个' + (failed.length ? ',失败 ' + failed.length + ' 个' : ''),
156
156
  ...failed.map((f) => '❌ ' + f.project.name + ':' + f.error),
157
157
  ].join('\n'));
@@ -97,6 +97,7 @@ export function renderMaterialMarkdown(records, meta = {}) {
97
97
  lines.push('');
98
98
  lines.push('- **tags**:' + valueText(record.tags));
99
99
  lines.push('- **genres**:' + valueText(record.genres));
100
+ if (record.group_id) lines.push('- **group_id**:' + text(record.group_id));
100
101
  if (record.source) lines.push('- **source**:' + text(record.source));
101
102
  if (record.note) lines.push('- **note**:' + text(record.note));
102
103
  lines.push('');
@@ -117,6 +118,7 @@ export function renderMaterialMarkdown(records, meta = {}) {
117
118
  lines.push('');
118
119
  lines.push('- **tags**:' + valueText(record.tags));
119
120
  lines.push('- **genres**:' + valueText(record.genres));
121
+ if (record.group_id) lines.push('- **group_id**:' + text(record.group_id));
120
122
  if (record.source) lines.push('- **source**:' + text(record.source));
121
123
  if (record.note) lines.push('- **note**:' + text(record.note));
122
124
  lines.push('');
@@ -136,7 +138,7 @@ export function renderMaterialMarkdown(records, meta = {}) {
136
138
  export async function exportMaterials(root) {
137
139
  const { db, database } = await connectMaterial(root);
138
140
  try {
139
- const rows = await db.query('SELECT kind, name, tags, genres, note, source FROM material ORDER BY kind, name;');
141
+ const rows = await db.query('SELECT kind, name, tags, genres, group_id, note, source FROM material ORDER BY kind, name;');
140
142
  const records = Array.isArray(rows) && Array.isArray(rows[0]) ? rows[0] : [];
141
143
  const file = path.join(path.resolve(root), '素材库.md');
142
144
  const markdown = renderMaterialMarkdown(records, {
@@ -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 {
@@ -449,11 +449,14 @@ async function runGenerate(ctx, invocation, session, focusRaw = '', taskList, op
449
449
  const root = workspaceOf(session);
450
450
  // 两参数形式:/fancy-material <题材> <素材类型>。
451
451
  // 题材和素材类型都允许用户随便写:题材直接进提示词,素材类型由 LLM
452
- // 判断对应哪个 kind(不在 54 个内置 kind 里时自拟 kind)。
452
+ // 判断对应哪个 kind(不在 58 个内置 kind 里时自拟 kind)。
453
453
  const custom = opts.custom || null;
454
454
  const isCustom = Boolean(custom && custom.genre && custom.materialType);
455
- if (isCustom) focusRaw = custom.materialType;
456
- const focus = resolveFocus(focusRaw);
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 = [...new Set(focus.kinds.length ? focus.kinds : (isCustom ? ['__custom__'] : MATERIAL_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 ? { genre: plan.customGenre, materialType: plan.customMaterialType } : null,
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 materialType = stripQuotes(tokens.slice(1).join(' '));
973
- if (!genre || !materialType) {
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: { genre, materialType },
987
+ custom: {
988
+ genre,
989
+ materialType: allKinds ? 'all' : materialTypeRaw,
990
+ allKinds,
991
+ },
978
992
  });
979
993
  }
980
994
  // 其它单参数视为素材类型重点,例如 /fancy-material 地名
@@ -20,7 +20,7 @@ function clean(value) {
20
20
  /**
21
21
  * Write an existing-material index to <workspace>/.tmp.
22
22
  *
23
- * One JSON object per line: { kind, name, tags, genres }.
23
+ * One JSON object per line: { kind, name, tags, genres, group_id?, source }.
24
24
  * It is intentionally a file, not prompt text: the model can grep/search it
25
25
  * without loading a six-figure line list into the context window.
26
26
  *
@@ -32,7 +32,7 @@ function clean(value) {
32
32
  export async function buildExistingIndex(root, genres, stamp) {
33
33
  const { db } = await connectMaterial(root);
34
34
  try {
35
- const rows = await db.query('SELECT kind, name, tags, genres, source FROM material ORDER BY kind, name;');
35
+ const rows = await db.query('SELECT kind, name, tags, genres, group_id, source FROM material ORDER BY kind, name;');
36
36
  const records = Array.isArray(rows) && Array.isArray(rows[0]) ? rows[0] : [];
37
37
  const selected = new Set((genres || []).filter(Boolean));
38
38
  const filtered = selected.size
@@ -49,6 +49,7 @@ export async function buildExistingIndex(root, genres, stamp) {
49
49
  name: clean(record.name),
50
50
  tags: Array.isArray(record.tags) ? record.tags.map(clean) : [],
51
51
  genres: Array.isArray(record.genres) ? record.genres.map(clean) : [],
52
+ ...(record.group_id ? { group_id: clean(record.group_id) } : {}),
52
53
  source: clean(record.source) || 'builtin',
53
54
  }));
54
55
  fs.writeFileSync(file, lines.length ? lines.join('\n') + '\n' : '', 'utf8');
@@ -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', 'sensory_taste', 'sensory_visual',
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
  }
@@ -312,15 +395,39 @@ export function focusBlock(focus) {
312
395
  return `本批用户指定的重点是「${focus.query}」,对应 ${list}。插件会按顺序逐个 kind 排队,每个批次只写一个 kind;不要生成其它 kind。其他质量、题材、追加和查询规则继续适用。`;
313
396
  }
314
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
+
315
412
  /**
316
413
  * 自定义题材 + 自定义素材类型的本批规则。
317
414
  *
318
415
  * 与内置目录最大的区别:
319
416
  * - source 必须是 other;
320
- * - 素材类型可以不在 54 个 kind 里,模型可以自拟 kind;
417
+ * - 素材类型可以不在 58 个 kind 里,模型可以自拟 kind;
321
418
  * - 同一批只能用一个 kind,插件会在第一轮之后记住它。
322
419
  */
323
- 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
+ }
324
431
  const known = Array.isArray(kinds) && kinds.length
325
432
  ? '用户素材类型匹配到内置 kind:' + kinds.map((kind) => `\`${kind}\`(${KIND_LABELS[kind] || kind})`).join('、') + '。'
326
433
  : '用户素材类型不在内置表内;请自拟一个稳定的小写 snake_case kind(例如 `custom_xxx`)。';
@@ -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
- return `[${row.kind}] ${row.name}${tags ? ' | ' + tags : ''}${genres ? ' | ' + genres : ''}${source}`;
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
  }
@@ -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 删除整个素材库(会二次确认)
@@ -32,13 +33,13 @@ export function helpText() {
32
33
  /fancy-material help 显示本帮助
33
34
 
34
35
  说明:
35
- - 素材是原子积木,每条只有 id / kind / name / tags / genres / note / source。
36
+ - 素材是原子积木,每条有 id / kind / name / tags / genres / group_id / note / source;group_id 可选。
36
37
  - tags 和 genres 都是数组:tags 3–8 个,genres 1–5 个;一个素材可以同时适配多个题材/标签。
37
38
  - 每次运行:每个 kind 新增 50 条;每批最多 10 条,插件自动分批直到完成。
38
39
  - 未指定类型:${MATERIAL_KINDS.length} 个 kind 全部排队。
39
40
  - 题材来源:优先 _novel_topic.json,其次 _novel_topic_suggestion.json;都没有时弹框确认后使用内置全题材。
40
41
  - 指定类型:只生成指定 kind,题材来源不变,source=builtin。
41
- - 自定义题材+素材类型:题材和素材类型都可以随便写,插件把它们交给 LLM;生成结果 source=other,不占用内置 kind 目录。
42
+ - 自定义题材+素材类型:题材和素材类型都可以随便写,插件把它们交给 LLM;第二个参数写 all 表示全部 58 个 kind。生成结果 source=other,不占用内置 kind 目录。
42
43
  - 不设库内上限:运行两次就是每个 kind 累计 100 条;已有素材只用于去重。
43
44
  - 中断后重跑会开始新一轮 50 条配额,已经导入的素材不会撤销。
44
45
  - 只追加,不覆盖;同 kind 同 name 的素材会被跳过。
@@ -78,7 +79,7 @@ function compactRules(genres, queryScript, workspace, sourceFixed = 'builtin') {
78
79
  '- 只写本批指定的一个 kind;不要把其它 kind 混进同一个文件。',
79
80
  '- 每条必须独立、具体、可复用;拒绝“火红、耀眼、神秘、强大”这类空泛词。',
80
81
  '- 命名类必须有具体锚点;拒绝“复原眼、章眼、旧仓单、神秘剑、黑色长刀”这类废名。',
81
- '- 字段只能是 id / kind / name / tags / genres / note / source;'
82
+ '- 字段只能是 id / kind / name / tags / genres / group_id / note / source;'
82
83
  + 'source 写 ' + sourceFixed + ';tags 3–8 个,genres 1–5 个。',
83
84
  '- tags 和 genres 都是数组:一个素材能适配多个题材/标签时,把它们都写进去;'
84
85
  + '例如「都市高武」可以写 tags: ["都市","高武","都市高武", ...]。',
@@ -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
  }
@@ -184,7 +185,7 @@ export function generationPrompt({
184
185
 
185
186
  lines.push('');
186
187
  lines.push('写入要求:');
187
- lines.push('1. 只把 JSONL 写进目标文件,一行一个对象;字段只能是 id / kind / name / tags / genres / note / source,source 固定写 ' + sourceFixed + '。');
188
+ lines.push('1. 只把 JSONL 写进目标文件,一行一个对象;字段只能是 id / kind / name / tags / genres / group_id / note / source,source 固定写 ' + sourceFixed + '。');
188
189
  lines.push(' tags 和 genres 都是数组:一个素材能适配多个题材/标签时,把它们都写进去(例如 都市高武 → 都市、高武、都市高武)。');
189
190
  lines.push('2. 不要在文件里写 Markdown 代码围栏、标题、解释、前后缀。');
190
191
  lines.push('3. 可以直接写 JSONL,也可以使用 Python/Node 生成器;生成器放 <工作区>/.tmp/,输出必须是目标 JSONL。');
@@ -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,7 +22,7 @@ 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 不受限制
@@ -60,6 +60,13 @@ function validate(raw, line) {
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
  }