@cloud411716/fancy-webnovel 4.30.37 → 4.30.38
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.
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* --database material_library --user root --pass root sample.jsonl
|
|
10
10
|
*
|
|
11
11
|
* 一条素材有基础字段 + 多层 facet:
|
|
12
|
-
* id, kind, name, subject, tags, genres, tropes, narrative, traits, roles, relations, moods, settings, world_id, group_id, subkind, rank_order, note, source
|
|
12
|
+
* id, kind, name, subject, derivation, tags, genres, tropes, narrative, traits, roles, relations, moods, settings, world_id, group_id, subkind, rank_order, note, source
|
|
13
13
|
*
|
|
14
14
|
* 默认只追加:已存在的 id 或同 kind+name 会跳过;--update 才覆盖。
|
|
15
15
|
*/
|
|
@@ -22,11 +22,12 @@ import { MATERIAL_FACET_FIELDS, MATERIAL_FACET_LIMITS, MATERIAL_TAG_LIMITS, MATE
|
|
|
22
22
|
|
|
23
23
|
const HERE = fileURLToPath(new URL('.', import.meta.url));
|
|
24
24
|
const ALLOWED_FIELDS = new Set([
|
|
25
|
-
'id', 'kind', 'name', 'subject', 'tags', 'group_id', 'subkind', 'world_id', 'rank_order', 'note', 'source',
|
|
25
|
+
'id', 'kind', 'name', 'subject', 'derivation', 'tags', 'group_id', 'subkind', 'world_id', 'rank_order', 'note', 'source',
|
|
26
26
|
...MATERIAL_FACET_FIELDS,
|
|
27
27
|
]);
|
|
28
28
|
const QUALITY_TAGS = new Set(['精品', '高价值', '文笔好', '强力', '神秘']);
|
|
29
29
|
const NOTE_MAX = 300;
|
|
30
|
+
const DERIVATION_MAX = 400;
|
|
30
31
|
const SUBKIND_MAX = 40;
|
|
31
32
|
const ID_RE = /^[a-z][a-z0-9_]*$/;
|
|
32
33
|
|
|
@@ -64,7 +65,7 @@ function validateRecord(raw, line, seenIds) {
|
|
|
64
65
|
|
|
65
66
|
for (const key of Object.keys(raw)) {
|
|
66
67
|
if (!ALLOWED_FIELDS.has(key)) {
|
|
67
|
-
throw new ImportError(`不允许的字段:${key}。原子素材只允许 id/kind/name/subject/tags/各 facet/group_id/subkind/note/source`, line);
|
|
68
|
+
throw new ImportError(`不允许的字段:${key}。原子素材只允许 id/kind/name/subject/derivation/tags/各 facet/group_id/subkind/note/source`, line);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -90,6 +91,11 @@ function validateRecord(raw, line, seenIds) {
|
|
|
90
91
|
throw new ImportError('subject 必须是不超过 ' + MATERIAL_SUBJECT_MAX + ' 字的字符串', line);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
94
|
+
if (raw.derivation !== undefined) {
|
|
95
|
+
if (typeof raw.derivation !== 'string' || raw.derivation.trim().length > DERIVATION_MAX) {
|
|
96
|
+
throw new ImportError('derivation 必须是不超过 ' + DERIVATION_MAX + ' 字的字符串', line);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
93
99
|
if (raw.group_id !== undefined) {
|
|
94
100
|
if (typeof raw.group_id !== 'string' || !raw.group_id.trim()) {
|
|
95
101
|
throw new ImportError('group_id 必须是非空字符串', line);
|
|
@@ -151,6 +157,7 @@ function validateRecord(raw, line, seenIds) {
|
|
|
151
157
|
name: raw.name.trim(),
|
|
152
158
|
tags: raw.tags.map((item) => item.trim()),
|
|
153
159
|
...(raw.subject ? { subject: raw.subject.trim() } : {}),
|
|
160
|
+
...(raw.derivation ? { derivation: raw.derivation.trim() } : {}),
|
|
154
161
|
...Object.fromEntries(MATERIAL_FACET_FIELDS.map((facet) => [
|
|
155
162
|
facet,
|
|
156
163
|
(raw[facet] || []).map((item) => item.trim()),
|
|
@@ -390,7 +397,7 @@ function usage() {
|
|
|
390
397
|
node import.js [连接参数] <file.jsonl>
|
|
391
398
|
|
|
392
399
|
一条素材字段:
|
|
393
|
-
id, kind, name, subject, tags, genres, tropes, narrative, traits, roles, relations, moods, settings, world_id, group_id, subkind, rank_order, note, source
|
|
400
|
+
id, kind, name, subject, derivation, tags, genres, tropes, narrative, traits, roles, relations, moods, settings, world_id, group_id, subkind, rank_order, note, source
|
|
394
401
|
|
|
395
402
|
source:
|
|
396
403
|
builtin 内置素材,kind 必须是允许列表之一
|
package/package.json
CHANGED
|
@@ -1638,15 +1638,6 @@ export async function runGenerationWithPlan(ctx, invocation, session, taskList,
|
|
|
1638
1638
|
});
|
|
1639
1639
|
if (metadataProblem) return { ok: false, detail: metadataProblem };
|
|
1640
1640
|
const records = readJsonlRecords(file);
|
|
1641
|
-
const nameFormProblem = chargingBarNameFormProblem(records, primaryStyleKey);
|
|
1642
|
-
if (nameFormProblem) return { ok: false, detail: nameFormProblem };
|
|
1643
|
-
const nameHighConceptProblem = chargingBarNameHighConceptProblem(records, primaryStyleKey);
|
|
1644
|
-
const nameGroundingProblem = chargingBarNameGroundingProblem(records, primaryStyleKey);
|
|
1645
|
-
const nameDiversityProblem = chargingBarNameDiversityProblem(records, primaryStyleKey, {
|
|
1646
|
-
historical: rememberedNames(item),
|
|
1647
|
-
});
|
|
1648
|
-
const nameProblems = [nameHighConceptProblem, nameGroundingProblem, nameDiversityProblem].filter(Boolean);
|
|
1649
|
-
if (nameProblems.length) return { ok: false, detail: nameProblems.join('\n\n') };
|
|
1650
1641
|
return { ok: true, records };
|
|
1651
1642
|
};
|
|
1652
1643
|
|
|
@@ -1669,11 +1660,6 @@ export async function runGenerationWithPlan(ctx, invocation, session, taskList,
|
|
|
1669
1660
|
const expectedGroup = item.group_id || groupId;
|
|
1670
1661
|
if (expectedGroup && record.group_id !== expectedGroup) reasons.push('group_id');
|
|
1671
1662
|
if (typeof record.name !== 'string' || !record.name.trim()) reasons.push('name');
|
|
1672
|
-
if (primaryStyleKey) {
|
|
1673
|
-
if (chargingBarNameFormProblem([record], primaryStyleKey)) reasons.push('name-form');
|
|
1674
|
-
if (chargingBarNameHighConceptProblem([record], primaryStyleKey)) reasons.push('name-concept');
|
|
1675
|
-
if (chargingBarNameGroundingProblem([record], primaryStyleKey)) reasons.push('name-grounding');
|
|
1676
|
-
}
|
|
1677
1663
|
if (reasons.length) dropped.push((record.name || '未命名') + '(' + reasons.join('、') + ')');
|
|
1678
1664
|
else kept.push(record);
|
|
1679
1665
|
}
|