@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
|
@@ -21,7 +21,7 @@ docs/material-library/
|
|
|
21
21
|
plugins/fancy-material/
|
|
22
22
|
├── index.js
|
|
23
23
|
├── templates.js
|
|
24
|
-
├── kinds.js #
|
|
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` 时必须是
|
|
53
|
+
| `kind` | 是 | `source=builtin` 时必须是 58 个原子类型之一;`source=other` 时不受限制 |
|
|
54
54
|
| `name` | 是 | 素材本体:名字、短语、一句话机制/代价/规则/钩子 |
|
|
55
|
-
| `tags` | 是 | 3–8
|
|
56
|
-
| `genres` | 是 | 1–
|
|
55
|
+
| `tags` | 是 | 3–8 个短标签,可同时覆盖多个题材/标签 |
|
|
56
|
+
| `genres` | 是 | 1–5 个适用题材;一个素材可以同时适配多个题材,跨题材写 `["通用"]` |
|
|
57
|
+
| `group_id` | 否 | 可选,组件组共用 ID,格式 `group_<类型>_<序号>_v4` |
|
|
57
58
|
| `note` | 否 | 只有 `name` 不够清楚时补一句 |
|
|
58
|
-
| `source` | 是 | `builtin` 或 `other
|
|
59
|
+
| `source` | 是 | `builtin` 或 `other`;内置题材生成 `builtin`,`/fancy-material <题材> <素材类型>` 生成 `other` |
|
|
59
60
|
|
|
60
|
-
`source` 用来区分内置素材和外部素材:`builtin` 的 `kind` 受
|
|
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
|
|
|
@@ -77,7 +78,28 @@ plugins/fancy-material/
|
|
|
77
78
|
- 需要搭配时用 `tags` 表达,例如 `["剑","雷系","高速"]`;不要写从属关系。
|
|
78
79
|
- 一条素材删掉后正文没有任何损失,就不收。
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
### 2.3 标签与题材是数组
|
|
82
|
+
|
|
83
|
+
`tags` 和 `genres` 都是字符串数组,不是单值:
|
|
84
|
+
|
|
85
|
+
- `tags` 3–8 个,从题材、类型、功能、元素、情绪、场景、代价、关系、强度等维度打标签。
|
|
86
|
+
- `genres` 1–5 个,必须原样包含本次主题材名;一个素材同时适配多个题材时全部写进去。
|
|
87
|
+
- 例:都市高武相关素材可以写 `tags: ["都市","高武","都市高武","地标"]`、`genres: ["都市高武","都市","高武"]`。
|
|
88
|
+
|
|
89
|
+
### 2.4 自定义题材 + 自定义素材类型
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
/fancy-material 都市高武 城市地标
|
|
93
|
+
/fancy-material 克苏鲁 神话生物
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
第一个参数是题材,第二个参数是素材类型;两者都可以随便写,不要求命中内置题材/58 个 kind。插件会把它们交给 LLM:
|
|
97
|
+
|
|
98
|
+
- 素材类型命中内置 kind 时直接使用该 kind;否则由 LLM 自拟一个安全的小写 snake_case kind。
|
|
99
|
+
- 生成结果的 `source` 固定为 `other`,不占用内置目录,也不会被 `init` 当作旧内置 kind 清理。
|
|
100
|
+
- 同一批只能使用一个 kind;插件在第一轮识别后记住它,后续批次沿用。
|
|
101
|
+
|
|
102
|
+
## 3. 58 个 kind
|
|
81
103
|
|
|
82
104
|
### 命名
|
|
83
105
|
|
|
@@ -96,7 +118,7 @@ person_voice, person_background
|
|
|
96
118
|
### 关系与情绪
|
|
97
119
|
|
|
98
120
|
```text
|
|
99
|
-
reaction
|
|
121
|
+
reaction, emotion_beat, relationship_dynamic
|
|
100
122
|
```
|
|
101
123
|
|
|
102
124
|
### 能力
|
|
@@ -115,7 +137,8 @@ item_form, item_material, item_function, item_visual
|
|
|
115
137
|
### 场景与感官
|
|
116
138
|
|
|
117
139
|
```text
|
|
118
|
-
location_feature, weather,
|
|
140
|
+
location_feature, weather, sensory_visual, sensory_sound,
|
|
141
|
+
sensory_smell, sensory_taste
|
|
119
142
|
```
|
|
120
143
|
|
|
121
144
|
### 描写词库
|
|
@@ -305,7 +328,7 @@ DEFINE ANALYZER material_zh
|
|
|
305
328
|
|
|
306
329
|
不再从 `topic_decision` 里猜题材。
|
|
307
330
|
|
|
308
|
-
不带参数时,插件会覆盖全部
|
|
331
|
+
不带参数时,插件会覆盖全部 58 个 kind:
|
|
309
332
|
|
|
310
333
|
```text
|
|
311
334
|
每次运行,每个 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
|
-
* 一条素材有
|
|
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 {
|
|
@@ -65,7 +65,15 @@ function validateRecord(raw, line, seenIds) {
|
|
|
65
65
|
ensureString(raw.kind, 'kind', line);
|
|
66
66
|
ensureString(raw.name, 'name', line);
|
|
67
67
|
ensureStringArray(raw.tags, 'tags', line, 3, 8);
|
|
68
|
-
ensureStringArray(raw.genres, 'genres', line, 1,
|
|
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
|
};
|