@cloud411716/fancy-webnovel 4.7.1 → 4.8.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.
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * Scan one Douyin account homepage and return its /note/ image-text works.
4
+ * Scan one Douyin account homepage and return its /note/ image-text works
5
+ * and /video/ video works.
5
6
  *
6
7
  * stdout is one JSON object. Progress goes to stderr. The script never closes
7
8
  * Chrome; it closes only its own page, so login state stays in the profile.
@@ -11,7 +12,7 @@ const fs = require('fs');
11
12
  const path = require('path');
12
13
  const {
13
14
  log, parseArgs, connect, installExternalProtocolGuard, restoreCookies, saveCookies,
14
- gateResult, printJson, fail, ensureDir,
15
+ safeGateResult, printJson, fail, ensureDir,
15
16
  } = require('./lib.cjs');
16
17
 
17
18
  function normalize(url) {
@@ -92,7 +93,7 @@ async function main() {
92
93
  await page.goto(account, { waitUntil: 'domcontentloaded', timeout: 60000 });
93
94
  await page.waitForTimeout(3500);
94
95
 
95
- const firstGate = await gateResult(page, outDir);
96
+ const firstGate = await safeGateResult(page, outDir);
96
97
  if (firstGate) {
97
98
  keepPage = true;
98
99
  await saveCookies(context, loginState, page.url());
@@ -100,8 +101,32 @@ async function main() {
100
101
  return;
101
102
  }
102
103
 
103
- const cards = await collectCards(page);
104
- const afterGate = await gateResult(page, outDir);
104
+ let cards = [];
105
+ try {
106
+ cards = await collectCards(page);
107
+ } catch (err) {
108
+ // 页面在滚动/解析过程中跳转(登录页、验证页、风控页)时,
109
+ // page.evaluate 会报 Execution context was destroyed。
110
+ // 先等新页面稳定并检测登录门禁;检测不到也按需要登录处理,
111
+ // 让上层弹登录提示,而不是只报一句采集失败。
112
+ log('[scan] collectCards failed: ' + (err && err.message ? err.message : String(err)));
113
+ const gate = await safeGateResult(page, outDir, { reason: 'page_navigation' });
114
+ keepPage = true;
115
+ await saveCookies(context, loginState, page.url());
116
+ if (gate) {
117
+ printJson(gate);
118
+ } else {
119
+ printJson({
120
+ ok: true,
121
+ login_required: true,
122
+ reason: 'page_navigation',
123
+ error: err && err.message ? err.message : String(err),
124
+ url: page.url(),
125
+ });
126
+ }
127
+ return;
128
+ }
129
+ const afterGate = await safeGateResult(page, outDir);
105
130
  if (afterGate) {
106
131
  keepPage = true;
107
132
  await saveCookies(context, loginState, page.url());
@@ -139,7 +164,7 @@ async function main() {
139
164
  account,
140
165
  title: await page.title(),
141
166
  notes,
142
- videos: videos.length,
167
+ videos,
143
168
  cards_file: cardsFile,
144
169
  });
145
170
  } finally {
@@ -5,9 +5,10 @@
5
5
  * live under <workspace>/.fancy/douyin. The deployed crawler scripts live under
6
6
  * <workspace>/.fancy-tools/fancy-douyin.
7
7
  *
8
- * The crawl history is keyed by the note id parsed from /note/<id>. A note is
9
- * written only after its screenshot analysis has been imported into the
10
- * material library, so failed notes are retried on the next run.
8
+ * The crawl history is keyed by the note/video id parsed from /note/<id> or
9
+ * /video/<id>. A work is written only after its analysis has been imported into
10
+ * the material library, or after it was confirmed irrelevant/long and skipped,
11
+ * so failed works are retried on the next run.
11
12
  */
12
13
 
13
14
  import fs from 'fs';
@@ -8,22 +8,29 @@ import { fileURLToPath } from 'url';
8
8
 
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
10
  const PROMPT_FILE = path.join(__dirname, 'prompts', '01-analysis-prompt.md');
11
+ const VIDEO_PROMPT_FILE = path.join(__dirname, 'prompts', '02-video-analysis-prompt.md');
12
+ const CAPABILITY_PROMPT_FILE = path.join(__dirname, 'prompts', '00-capability-prompt.md');
11
13
 
12
14
  export function helpText() {
13
- return `🎬 抖音图文采集 用法
15
+ return `🎬 抖音素材采集 用法
14
16
 
15
17
  /fancy-douyin add <主页地址> 记录一个抖音账号主页
16
18
  /fancy-douyin list 查看已记录的账号
17
19
  /fancy-douyin remove <序号|地址> 删除已记录的账号
18
- /fancy-douyin 依次采集所有账号下未处理的图文作品
20
+ /fancy-douyin 依次采集所有账号下未处理的图文和视频作品
19
21
  /fancy-douyin help 显示本帮助
20
22
 
21
23
  说明:
22
- - 只采集 /note/ 图文作品,跳过视频。
23
- - 每篇作品会下载轮播原图并转成 JPG(不是滚动中的页面截图),然后交给 LLM 提取素材。
24
- - 如果图文内容与网文创作无关,LLM 会写入 skip 标记,该作品记为已处理并跳过。
25
- - 素材按 material JSONL 格式写入数据库,source 固定为 other。
26
- - 已成功入库的作品记录在 <工作区>/.fancy/douyin/crawled.json,后续跳过。
24
+ - 先让 LLM 自检图片识别和视频识别能力:
25
+ - 有图片识别能力:分析 /note/ 图文作品。
26
+ - 有视频识别能力:分析 /video/ 视频作品。
27
+ - 两种能力都没有:直接退出并通知,不启动采集。
28
+ - 图文作品会下载轮播原图并转成 JPG,然后交给 LLM 提取素材。
29
+ - 视频作品先判断时长:超过 1 分钟直接跳过;不超过 1 分钟的先看前 5 秒,
30
+ 与网文创作无关就跳过,有关才继续分析关键帧。
31
+ - 如果内容与网文创作无关,LLM 会写入 skip 标记,该作品记为已处理并跳过。
32
+ - 素材按 material JSONL 格式写入数据库,source 固定为 other,kind 用中文作品主题。
33
+ - 已成功入库或确认无关的作品记录在 <工作区>/.fancy/douyin/crawled.json,后续跳过。
27
34
  - 登录态保存在 <工作区>/.fancy/douyin/chrome-profile/,并镜像到 login-state.json。
28
35
  - 首次需要登录时用有头 Chrome;登录态有效后后续运行自动使用无头 Chrome。
29
36
  - 每次运行结束会自动关闭 Chrome,释放资源。
@@ -86,13 +93,110 @@ export function analysisPrompt({
86
93
  return text.trim() + '\n';
87
94
  }
88
95
 
96
+ function renderTemplate(file, vars) {
97
+ const template = fs.readFileSync(file, 'utf8');
98
+ let text = template;
99
+ for (const [key, value] of Object.entries(vars)) {
100
+ text = text.split('{{' + key + '}}').join(value);
101
+ }
102
+ return text.trim() + '\n';
103
+ }
104
+
105
+ function frameListText(frames) {
106
+ return (frames || [])
107
+ .map((frame, index) => {
108
+ const time = frame && Number.isFinite(Number(frame.time)) ? Number(frame.time) : index;
109
+ return `${index + 1}. \`${frame.file}\`(第 ${time} 秒)`;
110
+ })
111
+ .join('\n');
112
+ }
113
+
114
+ export function capabilityPrompt({ capabilityFile }) {
115
+ return renderTemplate(CAPABILITY_PROMPT_FILE, {
116
+ CAPABILITY_FILE: capabilityFile,
117
+ });
118
+ }
119
+
120
+ export function videoRelevancePrompt({
121
+ accountUrl,
122
+ video,
123
+ firstFrames,
124
+ targetFile,
125
+ }) {
126
+ const lines = [
127
+ '你正在筛选一个抖音视频。只根据前 5 秒的关键帧判断:内容是否与网文小说创作素材、灵感、设定、写作技巧有关。',
128
+ '',
129
+ '- 账号主页:' + read(accountUrl),
130
+ '- 作品地址:' + read(video.url),
131
+ '- 作品标题:' + read(video.title, '(无标题)'),
132
+ '',
133
+ '## 前 5 秒关键帧',
134
+ '',
135
+ frameListText(firstFrames) || '(没有关键帧)',
136
+ '',
137
+ '## 判断规则',
138
+ '',
139
+ '- 只看前 5 秒,不要根据标题或后续内容猜测。',
140
+ '- 如果前 5 秒是纯娱乐、纯广告、纯生活记录、纯口播带货、纯音乐卡点等与网文创作无关的内容,写 skip。',
141
+ '- 如果前 5 秒已经在讲人物设定、世界观、剧情钩子、冲突、场景、素材清单或写作技巧,写 relevant。',
142
+ '',
143
+ '把结果写入下面的绝对路径(覆盖写):',
144
+ '',
145
+ '```text',
146
+ targetFile,
147
+ '```',
148
+ '',
149
+ '无关:',
150
+ '',
151
+ '```json',
152
+ '{"skip": true, "reason": "前 5 秒与网文创作无关:<一句话原因>"}',
153
+ '```',
154
+ '',
155
+ '有关:',
156
+ '',
157
+ '```json',
158
+ '{"relevant": true, "reason": "<一句话说明>"}',
159
+ '```',
160
+ '',
161
+ '只写一个 JSON 对象,不要 Markdown 代码围栏、解释或前后缀。',
162
+ '写完后只回复:`已写入 ' + targetFile + '`。',
163
+ ];
164
+ return lines.join('\n') + '\n';
165
+ }
166
+
167
+ export function videoAnalysisPrompt({
168
+ accountUrl,
169
+ video,
170
+ frames,
171
+ targetFile,
172
+ workspace,
173
+ queryScript,
174
+ validateScript,
175
+ }) {
176
+ return renderTemplate(VIDEO_PROMPT_FILE, {
177
+ ACCOUNT_URL: read(accountUrl),
178
+ VIDEO_URL: read(video.url),
179
+ VIDEO_TITLE: read(video.title, '(无标题)'),
180
+ VIDEO_DURATION: Number.isFinite(Number(video.duration)) ? String(Number(video.duration)) : '未知',
181
+ FRAME_LIST: frameListText(frames) || '(没有关键帧)',
182
+ TARGET_FILE: targetFile,
183
+ QUERY_SCRIPT: queryScript,
184
+ VALIDATE_SCRIPT: validateScript,
185
+ WORKSPACE: workspace,
186
+ });
187
+ }
188
+
89
189
  export function summaryText({
90
190
  accounts,
91
191
  scannedAccounts,
92
192
  foundNotes,
193
+ foundVideos = 0,
194
+ skippedNotesByCapability = 0,
195
+ skippedVideosByCapability = 0,
93
196
  skippedNotes,
94
197
  processedNotes,
95
198
  skippedIrrelevant = 0,
199
+ skippedLongVideos = 0,
96
200
  inserted,
97
201
  skippedMaterials,
98
202
  failures,
@@ -106,9 +210,12 @@ export function summaryText({
106
210
  '账号:' + accounts + ' 个(本次扫描 ' + scannedAccounts + ' 个)',
107
211
  '浏览器:' + (mode === 'headless' ? '无头' : '有头'),
108
212
  '发现图文:' + foundNotes + ' 篇',
213
+ '发现视频:' + foundVideos + ' 个',
109
214
  '已处理过并跳过:' + skippedNotes + ' 篇',
215
+ '能力不支持跳过:图文 ' + skippedNotesByCapability + ' 篇 / 视频 ' + skippedVideosByCapability + ' 个',
110
216
  '本次处理:' + processedNotes + ' 篇',
111
217
  '无关跳过:' + skippedIrrelevant + ' 篇',
218
+ '长视频跳过:' + skippedLongVideos + ' 个',
112
219
  '新增素材:' + inserted + ' 条(重复跳过 ' + skippedMaterials + ' 条)',
113
220
  ];
114
221
  if (failures.length) {
@@ -98,6 +98,7 @@ export function renderMaterialMarkdown(records, meta = {}) {
98
98
  lines.push('- **tags**:' + valueText(record.tags));
99
99
  lines.push('- **genres**:' + valueText(record.genres));
100
100
  if (record.group_id) lines.push('- **group_id**:' + text(record.group_id));
101
+ if (record.subkind) lines.push('- **subkind**:' + text(record.subkind));
101
102
  if (record.source) lines.push('- **source**:' + text(record.source));
102
103
  if (record.note) lines.push('- **note**:' + text(record.note));
103
104
  lines.push('');
@@ -119,6 +120,7 @@ export function renderMaterialMarkdown(records, meta = {}) {
119
120
  lines.push('- **tags**:' + valueText(record.tags));
120
121
  lines.push('- **genres**:' + valueText(record.genres));
121
122
  if (record.group_id) lines.push('- **group_id**:' + text(record.group_id));
123
+ if (record.subkind) lines.push('- **subkind**:' + text(record.subkind));
122
124
  if (record.source) lines.push('- **source**:' + text(record.source));
123
125
  if (record.note) lines.push('- **note**:' + text(record.note));
124
126
  lines.push('');
@@ -138,7 +140,7 @@ export function renderMaterialMarkdown(records, meta = {}) {
138
140
  export async function exportMaterials(root) {
139
141
  const { db, database } = await connectMaterial(root);
140
142
  try {
141
- const rows = await db.query('SELECT kind, name, tags, genres, group_id, note, source FROM material ORDER BY kind, name;');
143
+ const rows = await db.query('SELECT kind, subkind, name, tags, genres, group_id, note, source FROM material ORDER BY kind, subkind, name;');
142
144
  const records = Array.isArray(rows) && Array.isArray(rows[0]) ? rows[0] : [];
143
145
  const file = path.join(path.resolve(root), '素材库.md');
144
146
  const markdown = renderMaterialMarkdown(records, {
@@ -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, group_id?, source }.
23
+ * One JSON object per line: { kind, subkind?, 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, group_id, source FROM material ORDER BY kind, name;');
35
+ const rows = await db.query('SELECT kind, subkind, name, tags, genres, group_id, source FROM material ORDER BY kind, subkind, 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
@@ -46,6 +46,7 @@ export async function buildExistingIndex(root, genres, stamp) {
46
46
  fs.mkdirSync(path.dirname(file), { recursive: true });
47
47
  const lines = filtered.map((record) => JSON.stringify({
48
48
  kind: clean(record.kind),
49
+ ...(record.subkind ? { subkind: clean(record.subkind) } : {}),
49
50
  name: clean(record.name),
50
51
  tags: Array.isArray(record.tags) ? record.tags.map(clean) : [],
51
52
  genres: Array.isArray(record.genres) ? record.genres.map(clean) : [],
@@ -22,11 +22,12 @@ function usage() {
22
22
  return `素材库查询
23
23
 
24
24
  用法:
25
- node query.js [--workspace <工作区>] [--kind <kind>] [--genre <题材>] [--name <精确名字>] [--search <关键词>] [--limit N] [--json]
25
+ node query.js [--workspace <工作区>] [--kind <kind>] [--subkind <二级分类>] [--genre <题材>] [--name <精确名字>] [--search <关键词>] [--limit N] [--json]
26
26
 
27
27
  参数:
28
28
  --workspace <目录> 工作区目录;省略时从 cwd/FANCY_HOME 向上查找
29
29
  --kind <kind> 只查某个 kind,例如 place_name / color_word / ability_cost
30
+ --subkind <分类> 只查某个 subkind,例如 病理变异 / 红气场系
30
31
  --genre <题材> 只查某个题材;必须与素材 genres 中的值完全一致
31
32
  --name <名字> 精确查某个名字,用于生成前检查重名
32
33
  --search <关键词> 全文检索 name,支持空格分隔多个词
@@ -45,6 +46,7 @@ function parseArgs(argv) {
45
46
  const opts = {
46
47
  workspace: process.env.FANCY_HOME || '',
47
48
  kind: '',
49
+ subkind: '',
48
50
  genre: '',
49
51
  name: '',
50
52
  search: '',
@@ -66,6 +68,8 @@ function parseArgs(argv) {
66
68
  else if (arg.startsWith('--workspace=')) opts.workspace = arg.slice('--workspace='.length);
67
69
  else if (arg === '--kind') opts.kind = take();
68
70
  else if (arg.startsWith('--kind=')) opts.kind = arg.slice('--kind='.length);
71
+ else if (arg === '--subkind') opts.subkind = take();
72
+ else if (arg.startsWith('--subkind=')) opts.subkind = arg.slice('--subkind='.length);
69
73
  else if (arg === '--genre') opts.genre = take();
70
74
  else if (arg.startsWith('--genre=')) opts.genre = arg.slice('--genre='.length);
71
75
  else if (arg === '--name') opts.name = take();
@@ -133,7 +137,8 @@ function rowText(row) {
133
137
  const genres = Array.isArray(row.genres) ? row.genres.join('、') : '';
134
138
  const source = row.source === 'other' ? ' | other' : '';
135
139
  const group = row.group_id ? ' | ' + row.group_id : '';
136
- return `[${row.kind}] ${row.name}${tags ? ' | ' + tags : ''}${genres ? ' | ' + genres : ''}${group}${source}`;
140
+ const sub = row.subkind ? ' | ' + row.subkind : '';
141
+ return `[${row.kind}] ${row.name}${tags ? ' | ' + tags : ''}${genres ? ' | ' + genres : ''}${sub}${group}${source}`;
137
142
  }
138
143
 
139
144
  async function main() {
@@ -169,15 +174,16 @@ async function main() {
169
174
 
170
175
  const where = [];
171
176
  if (opts.kind) where.push('kind = ' + q(opts.kind));
177
+ if (opts.subkind) where.push('subkind = ' + q(opts.subkind));
172
178
  if (opts.genre) where.push('genres CONTAINS ' + q(opts.genre));
173
179
  if (opts.name) where.push('name = ' + q(opts.name));
174
180
  if (opts.search) where.push('name @1@ ' + q(opts.search));
175
181
 
176
- let sql = 'SELECT id, kind, name, tags, genres, group_id, source';
182
+ let sql = 'SELECT id, kind, subkind, name, tags, genres, group_id, source';
177
183
  if (opts.search) sql += ', search::score(1) AS score';
178
184
  sql += ' FROM material';
179
185
  if (where.length) sql += ' WHERE ' + where.join(' AND ');
180
- sql += opts.search ? ' ORDER BY score DESC' : ' ORDER BY kind, name';
186
+ sql += opts.search ? ' ORDER BY score DESC' : ' ORDER BY kind, subkind, name';
181
187
  sql += ' LIMIT ' + opts.limit + ';';
182
188
 
183
189
  const namespace = workspace.surreal?.namespace || 'fancy';
@@ -236,6 +242,7 @@ async function main() {
236
242
  process.stdout.write(JSON.stringify({
237
243
  id: String(row.id || ''),
238
244
  kind: row.kind,
245
+ ...(row.subkind ? { subkind: row.subkind } : {}),
239
246
  name: row.name,
240
247
  tags: row.tags || [],
241
248
  genres: row.genres || [],
@@ -33,7 +33,8 @@ export function helpText() {
33
33
  /fancy-material help 显示本帮助
34
34
 
35
35
  说明:
36
- - 素材是原子积木,每条有 id / kind / name / tags / genres / group_id / note / source;group_id 可选。
36
+ - 素材是原子积木,每条有 id / kind / name / tags / genres / group_id / subkind / note / source;group_id 和 subkind 可选。
37
+ - subkind 是 kind 下的二级分类(例如 kind=特殊体质,subkind=病理变异);用于同一 kind 内再分组。
37
38
  - note 可选,最多 300 字;都市类地名/势力/能力名优先写内层身份,表层伪装名写 note。
38
39
  - 命名/措辞按题材文化体系适配:东方仙侠用诀/式/法/印,都市高武用令/条/章/程,西幻用契/印/律/颂,科幻用协议/阈值/序列,历史用司/署/营/旗,悬疑用规则/现象/编号,言情以意象词为主。
39
40
  - 禁止用质量评价词做 tags:精品、高价值、文笔好、强力、神秘。
@@ -82,7 +83,7 @@ function compactRules(genres, queryScript, workspace, sourceFixed = 'builtin') {
82
83
  '- 只写本批指定的一个 kind;不要把其它 kind 混进同一个文件。',
83
84
  '- 每条必须独立、具体、可复用;拒绝“火红、耀眼、神秘、强大”这类空泛词。',
84
85
  '- 命名类必须有具体锚点;拒绝“复原眼、章眼、旧仓单、神秘剑、黑色长刀”这类废名。',
85
- '- 字段只能是 id / kind / name / tags / genres / group_id / note / source;'
86
+ '- 字段只能是 id / kind / name / tags / genres / group_id / subkind / note / source;'
86
87
  + 'source 写 ' + sourceFixed + ';tags 3–8 个,genres 1–5 个。',
87
88
  '- tags 和 genres 都是数组:一个素材能适配多个题材/标签时,把它们都写进去;'
88
89
  + '例如「都市高武」可以写 tags: ["都市","高武","都市高武", ...]。',
@@ -191,7 +192,7 @@ export function generationPrompt({
191
192
 
192
193
  lines.push('');
193
194
  lines.push('写入要求:');
194
- lines.push('1. 只把 JSONL 写进目标文件,一行一个对象;字段只能是 id / kind / name / tags / genres / group_id / note / source,source 固定写 ' + sourceFixed + '。tags 和 genres 都是数组:一个素材能适配多个题材/标签时,把它们都写进去(例如 都市高武 → 都市、高武、都市高武)。');
195
+ lines.push('1. 只把 JSONL 写进目标文件,一行一个对象;字段只能是 id / kind / name / tags / genres / group_id / subkind / note / source,source 固定写 ' + sourceFixed + '。tags 和 genres 都是数组:一个素材能适配多个题材/标签时,把它们都写进去(例如 都市高武 → 都市、高武、都市高武)。');
195
196
  lines.push('2. 命名/措辞/体例必须匹配题材文化体系,禁止跨题材串用后缀;都市类地名/势力/能力名优先写内层身份,表层日常伪装名写 note(最多 300 字)。');
196
197
  lines.push('3. tags 不能用质量评价词:精品、高价值、文笔好、强力、神秘。');
197
198
  lines.push('4. 不要在文件里写 Markdown 代码围栏、标题、解释、前后缀。');
@@ -11,9 +11,10 @@
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', 'group_id', 'note', 'source']);
14
+ const ALLOWED = new Set(['id', 'kind', 'name', 'tags', 'genres', 'group_id', 'subkind', 'note', 'source']);
15
15
  const QUALITY_TAGS = new Set(['精品', '高价值', '文笔好', '强力', '神秘']);
16
16
  const NOTE_MAX = 300;
17
+ const SUBKIND_MAX = 40;
17
18
  const ID_RE = /^[a-z][a-z0-9_]*$/;
18
19
 
19
20
  function usage() {
@@ -24,11 +25,12 @@ function usage() {
24
25
 
25
26
  检查:
26
27
  - 一行一个合法 JSON 对象
27
- - 字段只能是 id / kind / name / tags / genres / group_id / note / source
28
+ - 字段只能是 id / kind / name / tags / genres / group_id / subkind / note / source
28
29
  - source 只能是 builtin / other
29
30
  - builtin 的 kind 必须在允许列表内,id 以 kind 开头
30
31
  - other 的 kind 不受限制
31
32
  - tags 3–8 个,genres 1–5 个(都是数组);tags 不能写质量评价词
33
+ - subkind 可选,最多 40 字(kind 下的二级分类)
32
34
  - note 可选,最多 300 字
33
35
  - 同文件内 kind + name 不重复
34
36
 
@@ -74,6 +76,13 @@ function validate(raw, line) {
74
76
  errors.push('第 ' + line + ' 行:group_id 格式必须是 group_<类型>_<序号>_v4:' + raw.group_id);
75
77
  }
76
78
  }
79
+ if (raw.subkind !== undefined) {
80
+ if (typeof raw.subkind !== 'string' || !raw.subkind.trim()) {
81
+ errors.push('第 ' + line + ' 行:subkind 必须是非空字符串');
82
+ } else if (raw.subkind.trim().length > SUBKIND_MAX) {
83
+ errors.push('第 ' + line + ' 行:subkind 不能超过 ' + SUBKIND_MAX + ' 字');
84
+ }
85
+ }
77
86
  if (raw.note !== undefined) {
78
87
  if (typeof raw.note !== 'string') errors.push('第 ' + line + ' 行:note 必须是字符串');
79
88
  else if (raw.note.length > NOTE_MAX) errors.push('第 ' + line + ' 行:note 不能超过 ' + NOTE_MAX + ' 字');