@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.
@@ -21,7 +21,7 @@ docs/material-library/
21
21
  plugins/fancy-material/
22
22
  ├── index.js
23
23
  ├── templates.js
24
- ├── kinds.js # 54 个 kind 的单一事实来源
24
+ ├── kinds.js # 58 个 kind 的单一事实来源
25
25
  ├── genres.js # topic_decision / 番茄题材提取
26
26
  ├── inventory.js # 已有素材索引、按 kind 计数
27
27
  ├── queue.js # 按 kind 排队、计算每批还差多少
@@ -33,7 +33,7 @@ plugins/fancy-material/
33
33
 
34
34
  ## 2. 原子素材模型
35
35
 
36
- 每条素材有七个字段:
36
+ 每条素材有八个字段(`group_id` 可选):
37
37
 
38
38
  ```json
39
39
  {
@@ -50,14 +50,15 @@ plugins/fancy-material/
50
50
  | 字段 | 必填 | 说明 |
51
51
  | --- | --- | --- |
52
52
  | `id` | 是 | `<kind>_<ascii_slug>_v4`,全局唯一 |
53
- | `kind` | 是 | `source=builtin` 时必须是 54 个原子类型之一;`source=other` 时不受限制 |
53
+ | `kind` | 是 | `source=builtin` 时必须是 58 个原子类型之一;`source=other` 时不受限制 |
54
54
  | `name` | 是 | 素材本体:名字、短语、一句话机制/代价/规则/钩子 |
55
55
  | `tags` | 是 | 3–8 个短标签,可同时覆盖多个题材/标签 |
56
56
  | `genres` | 是 | 1–5 个适用题材;一个素材可以同时适配多个题材,跨题材写 `["通用"]` |
57
+ | `group_id` | 否 | 可选,组件组共用 ID,格式 `group_<类型>_<序号>_v4` |
57
58
  | `note` | 否 | 只有 `name` 不够清楚时补一句 |
58
59
  | `source` | 是 | `builtin` 或 `other`;内置题材生成 `builtin`,`/fancy-material <题材> <素材类型>` 生成 `other` |
59
60
 
60
- `source` 用来区分内置素材和外部素材:`builtin` 的 `kind` 受 54 个类型限制;`other` 可以写任意自定义 `kind`。不再有 `payload`、`summary`、`description`、`core_hook`、`market_diff`、`search_text` 这些复合字段。
61
+ `source` 用来区分内置素材和外部素材:`builtin` 的 `kind` 受 58 个类型限制;`other` 可以写任意自定义 `kind`。不再有 `payload`、`summary`、`description`、`core_hook`、`market_diff`、`search_text` 这些复合字段。
61
62
 
62
63
  ### 2.1 `name` 是内容,不是标题
63
64
 
@@ -90,15 +91,17 @@ plugins/fancy-material/
90
91
  ```text
91
92
  /fancy-material 都市高武 城市地标
92
93
  /fancy-material 克苏鲁 神话生物
94
+ /fancy-material 都市高武 all # 该题材下全部 58 个 kind
93
95
  ```
94
96
 
95
- 第一个参数是题材,第二个参数是素材类型;两者都可以随便写,不要求命中内置题材/54 个 kind。插件会把它们交给 LLM:
97
+ 第一个参数是题材,第二个参数是素材类型;两者都可以随便写,不要求命中内置题材/58 个 kind。插件会把它们交给 LLM:
96
98
 
97
99
  - 素材类型命中内置 kind 时直接使用该 kind;否则由 LLM 自拟一个安全的小写 snake_case kind。
98
100
  - 生成结果的 `source` 固定为 `other`,不占用内置目录,也不会被 `init` 当作旧内置 kind 清理。
101
+ - 第二个参数写 `all` 时,插件会把该题材下的全部 58 个 kind 排成队列,逐个生成;source 仍然是 `other`。
99
102
  - 同一批只能使用一个 kind;插件在第一轮识别后记住它,后续批次沿用。
100
103
 
101
- ## 3. 54 个 kind
104
+ ## 3. 58 个 kind
102
105
 
103
106
  ### 命名
104
107
 
@@ -117,7 +120,7 @@ person_voice, person_background
117
120
  ### 关系与情绪
118
121
 
119
122
  ```text
120
- reaction
123
+ reaction, emotion_beat, relationship_dynamic
121
124
  ```
122
125
 
123
126
  ### 能力
@@ -136,7 +139,8 @@ item_form, item_material, item_function, item_visual
136
139
  ### 场景与感官
137
140
 
138
141
  ```text
139
- location_feature, weather, sensory_taste, sensory_visual
142
+ location_feature, weather, sensory_visual, sensory_sound,
143
+ sensory_smell, sensory_taste
140
144
  ```
141
145
 
142
146
  ### 描写词库
@@ -326,7 +330,7 @@ DEFINE ANALYZER material_zh
326
330
 
327
331
  不再从 `topic_decision` 里猜题材。
328
332
 
329
- 不带参数时,插件会覆盖全部 54 个 kind:
333
+ 不带参数时,插件会覆盖全部 58 个 kind:
330
334
 
331
335
  ```text
332
336
  每次运行,每个 kind 新增 50 条。
@@ -8,8 +8,8 @@
8
8
  * node import.js --endpoint http://127.0.0.1:8000 --namespace fancy \
9
9
  * --database material_library --user root --pass root sample.jsonl
10
10
  *
11
- * 一条素材有 7 个字段:
12
- * id, kind, name, tags, genres, note, source
11
+ * 一条素材有 8 个字段:
12
+ * id, kind, name, tags, genres, group_id, note, source
13
13
  *
14
14
  * 默认只追加:已存在的 id 或同 kind+name 会跳过;--update 才覆盖。
15
15
  */
@@ -20,7 +20,7 @@ import { fileURLToPath } from 'node:url';
20
20
  import { MATERIAL_KINDS } from '../../plugins/fancy-material/kinds.js';
21
21
 
22
22
  const HERE = fileURLToPath(new URL('.', import.meta.url));
23
- const ALLOWED_FIELDS = new Set(['id', 'kind', 'name', 'tags', 'genres', 'note', 'source']);
23
+ const ALLOWED_FIELDS = new Set(['id', 'kind', 'name', 'tags', 'genres', 'group_id', 'note', 'source']);
24
24
  const ID_RE = /^[a-z][a-z0-9_]*$/;
25
25
 
26
26
  class ImportError extends Error {
@@ -66,6 +66,14 @@ function validateRecord(raw, line, seenIds) {
66
66
  ensureString(raw.name, 'name', line);
67
67
  ensureStringArray(raw.tags, 'tags', line, 3, 8);
68
68
  ensureStringArray(raw.genres, 'genres', line, 1, 5);
69
+ if (raw.group_id !== undefined) {
70
+ if (typeof raw.group_id !== 'string' || !raw.group_id.trim()) {
71
+ throw new ImportError('group_id 必须是非空字符串', line);
72
+ }
73
+ if (!/^group_[a-z0-9_]+_v4$/.test(raw.group_id.trim()) || raw.group_id.trim().length > 120) {
74
+ throw new ImportError(`group_id 格式必须是 group_<类型>_<序号>_v4:${raw.group_id}`, line);
75
+ }
76
+ }
69
77
  if (raw.note !== undefined) {
70
78
  if (typeof raw.note !== 'string') throw new ImportError('note 必须是字符串', line);
71
79
  }
@@ -99,6 +107,7 @@ function validateRecord(raw, line, seenIds) {
99
107
  name: raw.name.trim(),
100
108
  tags: raw.tags.map((item) => item.trim()),
101
109
  genres: raw.genres.map((item) => item.trim()),
110
+ ...(raw.group_id ? { group_id: raw.group_id.trim() } : {}),
102
111
  note: typeof raw.note === 'string' ? raw.note : '',
103
112
  },
104
113
  };