@cobola/dsh-geo 0.0.0-stage → 0.2.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/lib/rules.js ADDED
@@ -0,0 +1,939 @@
1
+ /**
2
+ * The GEO rubric: a fixed, deterministic catalog of checks.
3
+ *
4
+ * Nothing here calls a model or a clock of its own: every check reads only the
5
+ * scan artifact (plus the caller's `now` for freshness). Rules are the single
6
+ * source of truth for weights, findings, and the fix catalogue.
7
+ *
8
+ * Status semantics:
9
+ * - pass: full weight
10
+ * - warn: half weight (partial evidence)
11
+ * - fail: zero weight
12
+ * - skip: excluded from the denominator (not applicable)
13
+ */
14
+
15
+ export const RUBRIC_VERSION = 'geo-rubric@1';
16
+
17
+ export const DIMENSIONS = [
18
+ {
19
+ id: 'discoverability',
20
+ title: '可发现性',
21
+ weight: 25,
22
+ summary: '爬虫能否找到、抓取并索引页面:robots、sitemap、canonical、内链。',
23
+ },
24
+ {
25
+ id: 'parsability',
26
+ title: '可解析性',
27
+ weight: 20,
28
+ summary: '不执行 JavaScript 时,页面结构与正文是否仍能被稳定解析。',
29
+ },
30
+ {
31
+ id: 'citability',
32
+ title: '可引用性',
33
+ weight: 25,
34
+ summary: '内容是否具备被 LLM 直接摘录的条件:问答结构、事实密度、来源、时效与作者。',
35
+ },
36
+ {
37
+ id: 'trust',
38
+ title: '实体与信任',
39
+ weight: 15,
40
+ summary: '站点身份是否可核实:HTTPS、组织 schema、联系方式、安全头与外部背书。',
41
+ },
42
+ {
43
+ id: 'manifest',
44
+ title: '机器说明书',
45
+ weight: 15,
46
+ summary: '面向机器读者的显式入口:llms.txt、结构化数据、OpenGraph、feed 与 Link 提示。',
47
+ },
48
+ ];
49
+
50
+ const MONTH_MS = 30.4375 * 24 * 60 * 60 * 1000;
51
+ const GENERIC_LINK_TEXT = new Set([
52
+ 'click here', 'click', 'here', 'read more', 'more', 'learn more', 'details',
53
+ 'link', 'this', '查看', '详情', '详情请见', '更多', '点击这里', '点击', '了解更多', '这里',
54
+ ]);
55
+
56
+ function pass(evidence) {
57
+ return { status: 'pass', evidence };
58
+ }
59
+
60
+ function warn(evidence) {
61
+ return { status: 'warn', evidence };
62
+ }
63
+
64
+ function fail(evidence) {
65
+ return { status: 'fail', evidence };
66
+ }
67
+
68
+ function skip(evidence) {
69
+ return { status: 'skip', evidence };
70
+ }
71
+
72
+ function pageUrlOf(page) {
73
+ try {
74
+ return new URL(page.url);
75
+ } catch {
76
+ return null;
77
+ }
78
+ }
79
+
80
+ function pathnameOf(url) {
81
+ try {
82
+ return new URL(url).pathname;
83
+ } catch {
84
+ return '';
85
+ }
86
+ }
87
+
88
+ function trimSlash(value) {
89
+ const url = new URL(value);
90
+ url.hash = '';
91
+ let path = url.pathname;
92
+ if (path.length > 1 && path.endsWith('/')) path = path.slice(0, -1);
93
+ return `${url.origin}${path}${url.search}`;
94
+ }
95
+
96
+ function uniqueBy(list, keyFn) {
97
+ const seen = new Set();
98
+ const out = [];
99
+ for (const entry of list) {
100
+ const key = keyFn(entry);
101
+ if (seen.has(key)) continue;
102
+ seen.add(key);
103
+ out.push(entry);
104
+ }
105
+ return out;
106
+ }
107
+
108
+ function linkMatching(pages, pattern) {
109
+ for (const page of pages) {
110
+ if (!page.facts) continue;
111
+ for (const link of page.facts.internalLinks) {
112
+ const path = pathnameOf(link.href);
113
+ if (pattern.test(path)) return { page, link };
114
+ }
115
+ }
116
+ return null;
117
+ }
118
+
119
+ /**
120
+ * Parse a date without depending on the machine timezone. Offset-less
121
+ * date-times are pinned to UTC so two hosts with different TZ settings score
122
+ * the same artifact identically.
123
+ */
124
+ export function parseDateValue(value) {
125
+ if (typeof value !== 'string') return Number.NaN;
126
+ const trimmed = value.trim();
127
+ if (/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) return Date.parse(`${trimmed}T00:00:00Z`);
128
+ const match = /^(\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?)(Z|[+-]\d{2}:?\d{2})?$/.exec(trimmed);
129
+ if (!match) return Number.NaN;
130
+ const zone = match[3] ?? 'Z';
131
+ return Date.parse(`${match[1]}T${match[2]}${zone}`);
132
+ }
133
+
134
+ function parsedDates(facts) {
135
+ const dates = [];
136
+ for (const entry of facts.dateValues ?? []) {
137
+ const value = typeof entry === 'string' ? entry : entry.value;
138
+ if (typeof value !== 'string') continue;
139
+ const time = parseDateValue(value);
140
+ if (Number.isFinite(time)) dates.push({ time, value });
141
+ }
142
+ return dates.sort((a, b) => b.time - a.time);
143
+ }
144
+
145
+ function monthsAgo(from, now) {
146
+ return Math.round(((now - from) / MONTH_MS) * 10) / 10;
147
+ }
148
+
149
+ function imageStats(factsPages) {
150
+ let total = 0;
151
+ let withAlt = 0;
152
+ for (const page of factsPages) {
153
+ for (const image of page.facts.images) {
154
+ total += 1;
155
+ if (image.hasAlt) withAlt += 1;
156
+ }
157
+ }
158
+ return { total, withAlt };
159
+ }
160
+
161
+ function jsonLdBlocks(factsPages) {
162
+ return factsPages.flatMap((page) => page.facts.jsonLd.map((block) => ({ page, block })));
163
+ }
164
+
165
+ function orgEntities(factsPages) {
166
+ return factsPages.flatMap((page) => page.facts.orgEntities.map((entity) => ({ page, entity })));
167
+ }
168
+
169
+ /**
170
+ * Evaluate every rule once.
171
+ * @param {{scan: object, primary: object|null, pages: object[], factsPages: object[], now: Date|string|number}} ctx
172
+ */
173
+ export function evaluateRules(ctx) {
174
+ return RULES.map((rule) => {
175
+ let outcome;
176
+ try {
177
+ outcome = rule.evaluate(ctx);
178
+ } catch (error) {
179
+ outcome = fail(`规则执行异常:${error?.message ?? String(error)}`);
180
+ }
181
+ if (!outcome || !['pass', 'warn', 'fail', 'skip'].includes(outcome.status)) {
182
+ outcome = fail('规则未返回有效结论');
183
+ }
184
+ return {
185
+ id: rule.id,
186
+ dimension: rule.dimension,
187
+ weight: rule.weight,
188
+ title: rule.title,
189
+ status: outcome.status,
190
+ evidence: outcome.evidence ?? '',
191
+ fix: rule.fix,
192
+ action: rule.action ?? rule.fix,
193
+ };
194
+ });
195
+ }
196
+
197
+ /**
198
+ * @typedef {object} Rule
199
+ * @property {string} id
200
+ * @property {string} dimension
201
+ * @property {number} weight
202
+ * @property {string} title
203
+ * @property {string} fix
204
+ * @property {(ctx: object) => {status: string, evidence: string}} evaluate
205
+ */
206
+
207
+ /** @type {Rule[]} */
208
+ export const RULES = [
209
+ // ---------------------------------------------------------------- 可发现性
210
+ {
211
+ id: 'disc.robots-present',
212
+ dimension: 'discoverability',
213
+ weight: 3,
214
+ title: 'robots.txt 可访问',
215
+ fix: '在站点根目录发布 robots.txt,声明 Sitemap 与 AI 爬虫策略;返回 200 且为纯文本。',
216
+ evaluate({ scan }) {
217
+ if (scan.robots.found) return pass(`HTTP ${scan.robots.status},${scan.robots.text.length} 字节`);
218
+ if (scan.robots.status === 0) return fail('抓取失败,没有可读的 robots.txt');
219
+ return fail(`HTTP ${scan.robots.status},没有可用的 robots.txt`);
220
+ },
221
+ },
222
+ {
223
+ id: 'disc.robots-not-blocking-site',
224
+ dimension: 'discoverability',
225
+ weight: 4,
226
+ title: 'robots.txt 未封禁站点',
227
+ fix: '删掉对 Disallow: / 的全局封禁;只对确实需要保密的路径单独设置规则。',
228
+ evaluate({ scan }) {
229
+ if (scan.blockedByRobots) {
230
+ if (scan.blockedReason === 'robots-unreachable') {
231
+ return fail('robots.txt 无法访问(网络错误或 5xx),按 RFC 9309 视为禁止抓取');
232
+ }
233
+ return fail(`robots.txt 拒绝扫描 UA 抓取 ${scan.robotsBlockedAt ?? scan.startUrl}`);
234
+ }
235
+ if (scan.robots.blocksEverything) return fail('robots.txt 对 User-agent: * 执行 Disallow: /');
236
+ return pass(scan.robots.found ? '扫描 UA 可抓取入口页' : '无 robots.txt,默认允许抓取');
237
+ },
238
+ },
239
+ {
240
+ id: 'disc.ai-crawler-policy',
241
+ dimension: 'discoverability',
242
+ weight: 3,
243
+ title: 'AI 爬虫策略明确',
244
+ fix: '若希望被 AI 检索,在 robots.txt 显式 Allow GPTBot、ClaudeBot、PerplexityBot、Google-Extended 等;若刻意封闭,保留 Disallow 但需接受 AI 搜索不可见。',
245
+ evaluate({ scan }) {
246
+ if (!scan.robots.found) return skip('没有 robots.txt,默认允许所有爬虫;是否声明 AI 策略是可选选择');
247
+ const named = scan.robots.aiCrawlers.filter((entry) => entry.status !== 'unmentioned');
248
+ if (named.length === 0) return warn('robots.txt 未点名 AI 爬虫,默认按 * 规则放行;可显式化以便审计');
249
+ const denied = named.filter((entry) => entry.status === 'deny');
250
+ const allowed = named.filter((entry) => entry.status === 'allow');
251
+ const summary = named.map((entry) => `${entry.agent}=${entry.status}`).join(', ');
252
+ if (denied.length === 0 && allowed.length >= 3) return pass(`明确允许 ${allowed.length} 个 AI 爬虫(${summary})`);
253
+ if (allowed.length > 0) return warn(`部分 AI 爬虫被拒绝(${summary})`);
254
+ return warn(`明确拒绝 AI 爬虫(${summary});若是有意封闭可保留,Google Search 不要求允许这些爬虫`);
255
+ },
256
+ },
257
+ {
258
+ id: 'disc.googlebot-accessible',
259
+ dimension: 'discoverability',
260
+ weight: 3,
261
+ title: 'Googlebot 可抓取',
262
+ fix: '在 robots.txt 中允许 Googlebot 与 Googlebot-Image 抓取公开页面;这是 Google Search(包括生成式 AI 功能)的前提。',
263
+ evaluate({ scan }) {
264
+ if (!scan.robots.found) return pass('无 robots.txt,默认允许 Googlebot');
265
+ if (scan.robots.unreachable) return warn('robots.txt 无法访问,Googlebot 抓取可能暂停');
266
+ const access = scan.robots.googlebot ?? { allowed: true, imageAllowed: true };
267
+ if (access.allowed === false) return fail('robots.txt 明确禁止 Googlebot 抓取');
268
+ if (access.imageAllowed === false) return warn('Googlebot 可抓取,但 Googlebot-Image 被禁止');
269
+ return pass('robots.txt 允许 Googlebot 与 Googlebot-Image');
270
+ },
271
+ },
272
+ {
273
+ id: 'disc.sitemap-present',
274
+ dimension: 'discoverability',
275
+ weight: 3,
276
+ title: 'XML sitemap 可用',
277
+ fix: '发布 /sitemap.xml(或 sitemap index),每个 <url> 使用最终的可索引 URL,并在 robots.txt 里声明。',
278
+ evaluate({ scan }) {
279
+ if (scan.sitemap.found && scan.sitemap.valid) {
280
+ return pass(`${scan.sitemap.urlCount} 个 URL(${scan.sitemap.url})`);
281
+ }
282
+ if (scan.sitemap.found) return warn(`sitemap 可访问,但没有解析出有效 URL(${scan.sitemap.url ?? '未知地址'})`);
283
+ return fail('未找到可用的 XML sitemap(/sitemap.xml)');
284
+ },
285
+ },
286
+ {
287
+ id: 'disc.sitemap-declared',
288
+ dimension: 'discoverability',
289
+ weight: 2,
290
+ title: 'sitemap 已声明',
291
+ fix: '在 robots.txt 增加 Sitemap: <绝对 URL>,或在首页 <link rel="sitemap"> / Link 响应头中声明。',
292
+ evaluate({ scan, primary }) {
293
+ if (scan.robots.sitemapDeclarations.length > 0) {
294
+ return pass(`robots.txt 声明了 ${scan.robots.sitemapDeclarations.length} 个 sitemap`);
295
+ }
296
+ const viaHtml = primary?.facts?.alternateLinks.some((link) => link.rel.includes('sitemap'));
297
+ const viaHeader = /rel\s*=\s*"?sitemap/i.test(primary?.headers?.link ?? '');
298
+ if (viaHtml || viaHeader) return warn('sitemap 仅通过 HTML/Link 头声明,robots.txt 未声明');
299
+ return fail('sitemap 未在 robots.txt 或页面中声明');
300
+ },
301
+ },
302
+ {
303
+ id: 'disc.sitemap-covers-pages',
304
+ dimension: 'discoverability',
305
+ weight: 2,
306
+ title: 'sitemap 覆盖已抓取页面',
307
+ fix: '把被内链或导航暴露的可索引页面全部写进 sitemap,移除已 404/重定向的旧 URL。',
308
+ evaluate({ scan, factsPages }) {
309
+ if (!scan.sitemap.valid) return skip('没有可用 sitemap,覆盖率无从计算');
310
+ if (scan.sitemap.urlsTruncated) return skip('sitemap 过大,已抽样 2000 条,覆盖率不可靠');
311
+ if (factsPages.length === 0) return fail('未抓到 HTML 页面,无法计算覆盖');
312
+ const listed = new Set(scan.sitemap.urls.map((url) => trimSlash(url)));
313
+ const covered = factsPages.filter((page) => listed.has(trimSlash(page.url))).length;
314
+ const ratio = covered / factsPages.length;
315
+ const evidence = `${covered}/${factsPages.length} 个已抓取页面在 sitemap 中`;
316
+ if (ratio >= 0.8) return pass(evidence);
317
+ if (ratio >= 0.5) return warn(evidence);
318
+ return fail(evidence);
319
+ },
320
+ },
321
+ {
322
+ id: 'disc.indexable',
323
+ dimension: 'discoverability',
324
+ weight: 3,
325
+ title: '入口页可索引',
326
+ fix: '入口页返回 200;移除 meta robots 与 X-Robots-Tag 中的 noindex/nofollow。',
327
+ evaluate({ primary, scan }) {
328
+ if (!primary) {
329
+ if (scan.blockedByRobots) return fail('入口页因 robots.txt 被跳过,无法索引');
330
+ return fail('未抓取到 HTML 入口页');
331
+ }
332
+ if (primary.status !== 200) return fail(`入口页 HTTP ${primary.status}`);
333
+ const metaRobots = primary.facts.robotsMeta;
334
+ const headerRobots = (primary.headers['x-robots-tag'] ?? '').toLowerCase();
335
+ if (metaRobots.includes('noindex')) return fail('入口页存在 <meta name="robots" content="noindex">');
336
+ if (headerRobots.includes('noindex')) return fail('入口页 X-Robots-Tag 含 noindex');
337
+ return pass('入口页 200,无 noindex 指令');
338
+ },
339
+ },
340
+ {
341
+ id: 'disc.canonical',
342
+ dimension: 'discoverability',
343
+ weight: 2,
344
+ title: 'canonical 自指且为绝对地址',
345
+ fix: '每个页面输出 <link rel="canonical" href="https://正式域名/该页路径">,与当前 URL 完全一致(含尾斜杠策略)。',
346
+ evaluate({ primary }) {
347
+ if (!primary) return fail('未抓取到 HTML 入口页');
348
+ if (!primary.facts.canonical) return warn('入口页缺少 rel="canonical";canonical 是合并重复 URL 的提示,不是硬性排名要求');
349
+ if (trimSlash(primary.facts.canonical) === trimSlash(primary.url)) {
350
+ return pass(`canonical 自指:${primary.facts.canonical}`);
351
+ }
352
+ return warn(`canonical 指向其它 URL:${primary.facts.canonical}`);
353
+ },
354
+ },
355
+ {
356
+ id: 'disc.internal-links',
357
+ dimension: 'discoverability',
358
+ weight: 3,
359
+ title: '入口页内链充分',
360
+ fix: '在入口页用真实 <a href> 链接导航到核心页面(≥5 个),避免只在 JavaScript 里跳转。',
361
+ evaluate({ primary, pages }) {
362
+ if (!primary) return fail('未抓取到 HTML 入口页');
363
+ const targets = uniqueBy(primary.facts.internalLinks, (link) => trimSlash(link.href));
364
+ const crawled = pages.filter((page) => page.depth > 0 && page.facts).length;
365
+ if (targets.length >= 5 && crawled >= 1) return pass(`入口页 ${targets.length} 个内链,已抓到 ${crawled} 个下级页面`);
366
+ if (targets.length >= 3) return warn(`入口页仅 ${targets.length} 个内链,抓到 ${crawled} 个下级页面`);
367
+ return fail(`入口页仅 ${targets.length} 个可用内链`);
368
+ },
369
+ },
370
+
371
+ // ---------------------------------------------------------------- 可解析性
372
+ {
373
+ id: 'parse.title',
374
+ dimension: 'parsability',
375
+ weight: 3,
376
+ title: '<title> 长度合适',
377
+ fix: '为每个页面写唯一的 <title>,10–65 个字符,包含主题词与品牌名。',
378
+ evaluate({ primary }) {
379
+ if (!primary) return fail('未抓取到 HTML 入口页');
380
+ const { title, titleLength } = primary.facts;
381
+ if (titleLength === 0) return fail('入口页缺少 <title>');
382
+ if (titleLength >= 10 && titleLength <= 65) return pass(`“${title}”(${titleLength} 字)`);
383
+ return warn(`“${title}”(${titleLength} 字,建议 10–65)`);
384
+ },
385
+ },
386
+ {
387
+ id: 'parse.meta-description',
388
+ dimension: 'parsability',
389
+ weight: 2,
390
+ title: 'meta description 存在且合适',
391
+ fix: '为每个页面输出 50–170 字的 <meta name="description">,概括该页回答的问题。',
392
+ evaluate({ primary }) {
393
+ if (!primary) return fail('未抓取到 HTML 入口页');
394
+ const description = primary.facts.description;
395
+ const length = [...description].length;
396
+ if (length === 0) return fail('入口页缺少 meta description');
397
+ if (length >= 50 && length <= 170) return pass(`${length} 字`);
398
+ return warn(`${length} 字,建议 50–170`);
399
+ },
400
+ },
401
+ {
402
+ id: 'parse.lang',
403
+ dimension: 'parsability',
404
+ weight: 1,
405
+ title: '<html lang> 已声明',
406
+ fix: '在 <html> 上声明 lang(如 lang="zh-CN"),便于检索与语言匹配。',
407
+ evaluate({ primary }) {
408
+ if (!primary) return fail('未抓取到 HTML 入口页');
409
+ if (primary.facts.lang) return pass(`lang="${primary.facts.lang}"`);
410
+ return fail('缺少 <html lang>');
411
+ },
412
+ },
413
+ {
414
+ id: 'parse.h1',
415
+ dimension: 'parsability',
416
+ weight: 2,
417
+ title: '唯一且非空的主标题',
418
+ fix: '每页保留一个 <h1> 作为主标题,用 <h2>/<h3> 组织小节。',
419
+ evaluate({ primary }) {
420
+ if (!primary) return fail('未抓取到 HTML 入口页');
421
+ const headings = primary.facts.headings.filter((heading) => heading.level === 1 && heading.text.length >= 2);
422
+ if (headings.length === 1) return pass(`“${headings[0].text}”`);
423
+ if (headings.length === 0) return fail('入口页没有非空 <h1>');
424
+ return warn(`入口页有 ${headings.length} 个 <h1>,建议只保留一个`);
425
+ },
426
+ },
427
+ {
428
+ id: 'parse.heading-order',
429
+ dimension: 'parsability',
430
+ weight: 2,
431
+ title: '标题层级连续',
432
+ fix: '按 h1 → h2 → h3 顺序组织标题,不要从 h1 直接跳到 h4;每个小节都要有 h2。',
433
+ evaluate({ primary }) {
434
+ if (!primary) return fail('未抓取到 HTML 入口页');
435
+ const headings = primary.facts.headings;
436
+ if (headings.length < 2) return fail(`入口页仅 ${headings.length} 个标题`);
437
+ const levels = headings.map((heading) => heading.level);
438
+ let skipped = null;
439
+ for (let i = 1; i < levels.length; i += 1) {
440
+ if (levels[i] - levels[i - 1] > 1) {
441
+ skipped = `h${levels[i - 1]} → h${levels[i]}`;
442
+ break;
443
+ }
444
+ }
445
+ if (skipped) return warn(`标题层级跳级:${skipped}`);
446
+ if (!headings.some((heading) => heading.level === 2)) return warn('缺少 <h2> 二级标题');
447
+ return pass(`${headings.length} 个标题,层级连续`);
448
+ },
449
+ },
450
+ {
451
+ id: 'parse.semantics',
452
+ dimension: 'parsability',
453
+ weight: 2,
454
+ title: '语义化正文容器',
455
+ fix: '用 <main> 包裹正文、<article> 包裹独立内容,替代无语义的 <div> 堆叠。',
456
+ evaluate({ primary }) {
457
+ if (!primary) return fail('未抓取到 HTML 入口页');
458
+ if (primary.facts.hasMain && primary.facts.hasArticle) return pass('<main> 与 <article> 均存在');
459
+ if (primary.facts.hasMain || primary.facts.hasArticle) return pass(primary.facts.hasMain ? '<main> 存在' : '<article> 存在');
460
+ return warn('缺少 <main>/<article>;语义化 HTML 有助于可读性与无障碍,但 Google 明确表示不要求完美语义');
461
+ },
462
+ },
463
+ {
464
+ id: 'parse.raw-content',
465
+ dimension: 'parsability',
466
+ weight: 3,
467
+ title: '无 JS 也能读到正文',
468
+ fix: '服务端渲染或预渲染正文,保证不执行 JavaScript 的检索/引用管线也能读到 ≥600 字;Googlebot 能渲染 JS,但许多 AI 抓取器不能。',
469
+ evaluate({ primary }) {
470
+ if (!primary) return fail('未抓取到 HTML 入口页');
471
+ const length = primary.facts.contentLength ?? primary.facts.textLength;
472
+ if (length >= 600) return pass(`原始 HTML 含 ${length} 字正文`);
473
+ if (length >= 250) return warn(`原始 HTML 仅 ${length} 字正文`);
474
+ return fail(`原始 HTML 仅 ${length} 字正文,内容依赖 JavaScript 渲染`);
475
+ },
476
+ },
477
+ {
478
+ id: 'parse.pages-with-content',
479
+ dimension: 'parsability',
480
+ weight: 2,
481
+ title: '被抓取页面普遍含正文',
482
+ fix: '确保列表页、详情页都在原始 HTML 中输出正文,而不是只输出加载骨架。',
483
+ evaluate({ factsPages }) {
484
+ if (factsPages.length === 0) return fail('未抓取到 HTML 页面');
485
+ const substantial = factsPages.filter((page) => (page.facts.contentLength ?? page.facts.textLength) >= 600).length;
486
+ const ratio = substantial / factsPages.length;
487
+ const evidence = `${substantial}/${factsPages.length} 个页面原始 HTML ≥600 字`;
488
+ if (ratio >= 0.6) return pass(evidence);
489
+ if (ratio >= 0.3) return warn(evidence);
490
+ return fail(evidence);
491
+ },
492
+ },
493
+ {
494
+ id: 'parse.duplicate-metadata',
495
+ dimension: 'parsability',
496
+ weight: 2,
497
+ title: '页面标题/描述不重复',
498
+ fix: '为每个页面写唯一的 <title> 与 meta description;重复元数据会让检索系统难以区分页面,也浪费抓取预算。',
499
+ evaluate({ factsPages }) {
500
+ if (factsPages.length < 2) return skip('只有一个页面,无法判断重复');
501
+ const normalize = (value) => String(value ?? '').trim().toLowerCase().replace(/\s+/g, ' ');
502
+ const duplicates = { titles: [], descriptions: [] };
503
+ for (const key of ['title', 'description']) {
504
+ const seen = new Map();
505
+ for (const page of factsPages) {
506
+ const value = normalize(page.facts[key]);
507
+ if (!value) continue;
508
+ if (seen.has(value)) duplicates[key === 'title' ? 'titles' : 'descriptions'].push(value);
509
+ else seen.set(value, page.url);
510
+ }
511
+ }
512
+ const count = duplicates.titles.length + duplicates.descriptions.length;
513
+ const evidence = `${duplicates.titles.length} 个重复标题 / ${duplicates.descriptions.length} 个重复描述`;
514
+ if (count === 0) return pass('已抓取页面的 title 与 description 均唯一');
515
+ if (count === 1) return warn(evidence);
516
+ return fail(evidence);
517
+ },
518
+ },
519
+ {
520
+ id: 'parse.image-alt',
521
+ dimension: 'parsability',
522
+ weight: 2,
523
+ title: '图片 alt 覆盖',
524
+ fix: '为所有内容图片补写描述性 alt;纯装饰图片使用 alt="" 并标记 role="presentation"。',
525
+ evaluate({ factsPages }) {
526
+ const stats = imageStats(factsPages);
527
+ if (stats.total === 0) return skip('未使用图片');
528
+ const ratio = stats.withAlt / stats.total;
529
+ const evidence = `${stats.withAlt}/${stats.total} 张图片有 alt`;
530
+ if (ratio >= 0.9) return pass(evidence);
531
+ if (ratio >= 0.6) return warn(evidence);
532
+ return fail(evidence);
533
+ },
534
+ },
535
+ {
536
+ id: 'parse.jsonld-syntax',
537
+ dimension: 'parsability',
538
+ weight: 2,
539
+ title: 'JSON-LD 语法有效',
540
+ fix: '用 schema.org 词汇输出 application/ld+json,并在发布前用校验器检查括号与逗号。',
541
+ evaluate({ factsPages }) {
542
+ const blocks = jsonLdBlocks(factsPages);
543
+ if (blocks.length === 0) return warn('页面未使用 JSON-LD;Google 的生成式 AI 功能不要求结构化数据,但它有助于富结果与实体消歧');
544
+ const broken = blocks.filter((entry) => !entry.block.ok);
545
+ if (broken.length === 0) return pass(`${blocks.length} 个 JSON-LD 块全部可解析`);
546
+ if (broken.length === blocks.length) return fail(`${blocks.length} 个 JSON-LD 块全部解析失败`);
547
+ return warn(`${broken.length}/${blocks.length} 个 JSON-LD 块解析失败`);
548
+ },
549
+ },
550
+ {
551
+ id: 'parse.link-text',
552
+ dimension: 'parsability',
553
+ weight: 1,
554
+ title: '内链锚文本有描述性',
555
+ fix: '把“点击这里/了解更多”改成能说明目标内容的锚文本,例如“GEO 评分方法”。',
556
+ evaluate({ primary }) {
557
+ if (!primary) return fail('未抓取到 HTML 入口页');
558
+ const links = uniqueBy(primary.facts.internalLinks, (link) => trimSlash(link.href));
559
+ if (links.length === 0) return skip('入口页没有内链');
560
+ const descriptive = links.filter((link) => {
561
+ const text = link.text.trim().toLowerCase();
562
+ return text.length >= 2 && !GENERIC_LINK_TEXT.has(text) && !/^https?:\/\//.test(text);
563
+ }).length;
564
+ const ratio = descriptive / links.length;
565
+ const evidence = `${descriptive}/${links.length} 个内链锚文本有描述性`;
566
+ if (ratio >= 0.7) return pass(evidence);
567
+ if (ratio >= 0.4) return warn(evidence);
568
+ return fail(evidence);
569
+ },
570
+ },
571
+
572
+ // ---------------------------------------------------------------- 可引用性
573
+ {
574
+ id: 'cite.qa-structure',
575
+ dimension: 'citability',
576
+ weight: 3,
577
+ title: '问答结构',
578
+ fix: '把用户真实提问写成 h2/h3,并用 FAQPage/HowTo 结构化数据标注问答对。',
579
+ evaluate({ primary, factsPages }) {
580
+ if (!primary) return fail('未抓取到 HTML 入口页');
581
+ const faq = factsPages.some((page) => page.facts.faqEntities.length > 0);
582
+ const questions = primary.facts.questionHeadings.length;
583
+ if (faq && questions >= 2) return pass(`FAQ/HowTo schema + ${questions} 个问句标题`);
584
+ if (faq || questions >= 2) return warn(faq ? '有 FAQ schema,但问句标题不足 2 个' : `有 ${questions} 个问句标题,但缺少 FAQ schema(schema 可选)`);
585
+ if (questions === 1) return warn('仅 1 个问句标题');
586
+ return warn('没有问答结构;这是可读性建议,Google 不要求为 AI 拆分问答');
587
+ },
588
+ },
589
+ {
590
+ id: 'cite.summary',
591
+ dimension: 'citability',
592
+ weight: 2,
593
+ title: '摘要 / TL;DR 区块',
594
+ fix: '在正文开头加一段 2–4 句的摘要(class="summary" 或 TL;DR),让引用者能直接取用。',
595
+ evaluate({ primary }) {
596
+ if (!primary) return fail('未抓取到 HTML 入口页');
597
+ if (primary.facts.hasTldr || primary.facts.hasSummaryBlock) return pass('存在摘要区块');
598
+ return warn('没有摘要或 TL;DR 区块;这是可读性建议,不是 Google 的排名要求');
599
+ },
600
+ },
601
+ {
602
+ id: 'cite.numeric-evidence',
603
+ dimension: 'citability',
604
+ weight: 3,
605
+ title: '可验证的数字证据',
606
+ fix: '补充带单位的具体数字(百分比、耗时、样本量、版本号、日期),避免只有形容词。',
607
+ evaluate({ primary }) {
608
+ if (!primary) return fail('未抓取到 HTML 入口页');
609
+ const count = primary.facts.numericFacts;
610
+ if (count >= 5) return pass(`${count} 处带单位数字`);
611
+ if (count >= 2) return warn(`仅 ${count} 处带单位数字`);
612
+ return fail(`仅 ${count} 处带单位数字`);
613
+ },
614
+ },
615
+ {
616
+ id: 'cite.authority-sources',
617
+ dimension: 'citability',
618
+ weight: 2,
619
+ title: '引用权威来源',
620
+ fix: '在关键论断处链接一手来源(标准文档、官方文档、论文、政府/教育站点),并保持链接可访问。',
621
+ evaluate({ primary }) {
622
+ if (!primary) return fail('未抓取到 HTML 入口页');
623
+ const sources = uniqueBy(primary.facts.outboundAuthoritative, (link) => new URL(link.href).hostname);
624
+ if (sources.length >= 2) return pass(`${sources.length} 个权威外链(${sources.map((link) => new URL(link.href).hostname).join(', ')})`);
625
+ if (sources.length === 1) return warn('仅 1 个权威外链');
626
+ return fail('没有指向权威来源的外链');
627
+ },
628
+ },
629
+ {
630
+ id: 'cite.freshness',
631
+ dimension: 'citability',
632
+ weight: 3,
633
+ title: '内容时效可判定',
634
+ fix: '输出 datePublished/dateModified(JSON-LD 或 <time datetime>),并在正文中显示“最后更新日期”。',
635
+ evaluate({ primary, nowMs }) {
636
+ if (!primary) return fail('未抓取到 HTML 入口页');
637
+ const dates = parsedDates(primary.facts);
638
+ if (dates.length === 0) return fail('未声明任何发布日期或更新日期');
639
+ const newest = dates[0];
640
+ const age = monthsAgo(newest.time, nowMs);
641
+ const evidence = `最新日期 ${newest.value}(约 ${age} 个月前)`;
642
+ if (age <= 18) return pass(evidence);
643
+ if (age <= 36) return warn(evidence);
644
+ return fail(evidence);
645
+ },
646
+ },
647
+ {
648
+ id: 'cite.author',
649
+ dimension: 'citability',
650
+ weight: 2,
651
+ title: '作者署名可识别',
652
+ fix: '在页面与 Article schema 中给出作者姓名、简介与主页;匿名内容很难被引用。',
653
+ evaluate({ primary }) {
654
+ if (!primary) return fail('未抓取到 HTML 入口页');
655
+ const names = [
656
+ ...(primary.facts.authorNames ?? []),
657
+ ...(primary.facts.metasAuthor ? [primary.facts.metasAuthor] : []),
658
+ ...(primary.facts.bylines ?? []),
659
+ ].filter(Boolean);
660
+ if (names.length > 0) return pass(`作者线索:${names.slice(0, 3).join(' / ')}`);
661
+ return fail('没有作者或署名信息');
662
+ },
663
+ },
664
+ {
665
+ id: 'cite.anchors',
666
+ dimension: 'citability',
667
+ weight: 2,
668
+ title: '章节可锚点引用',
669
+ fix: '给每个 h2/h3 加语义化 id(如 id="geo-score"),方便引用到具体小节。',
670
+ evaluate({ primary }) {
671
+ if (!primary) return fail('未抓取到 HTML 入口页');
672
+ const headings = primary.facts.headings.filter((heading) => heading.level >= 2);
673
+ if (headings.length < 3) return fail(`仅 ${headings.length} 个二级及以下标题`);
674
+ const withId = headings.filter((heading) => heading.id).length;
675
+ const ratio = withId / headings.length;
676
+ const evidence = `${withId}/${headings.length} 个章节标题有 id`;
677
+ if (ratio >= 0.5) return pass(evidence);
678
+ if (ratio >= 0.25) return warn(evidence);
679
+ return fail(evidence);
680
+ },
681
+ },
682
+ {
683
+ id: 'cite.structure',
684
+ dimension: 'citability',
685
+ weight: 3,
686
+ title: '结构化排版与短段落',
687
+ fix: '用表格、有序列表承载对比与步骤,段落控制在 120 词以内,便于模型截取。',
688
+ evaluate({ primary }) {
689
+ if (!primary) return fail('未抓取到 HTML 入口页');
690
+ const { tables, lists } = primary.facts.counts;
691
+ const paragraphs = primary.facts.paragraphs;
692
+ const avgWords = paragraphs.length > 0
693
+ ? Math.round(paragraphs.reduce((sum, paragraph) => sum + paragraph.words, 0) / paragraphs.length)
694
+ : 0;
695
+ const structured = tables >= 1 || lists >= 2;
696
+ const shortParagraphs = paragraphs.length > 0 && avgWords <= 120;
697
+ const evidence = `${tables} 个表格 / ${lists} 个列表,平均段落 ${avgWords} 词`;
698
+ if (structured && shortParagraphs) return pass(evidence);
699
+ if (structured || shortParagraphs) return warn(evidence);
700
+ return fail(evidence);
701
+ },
702
+ },
703
+ {
704
+ id: 'cite.snippet-ready',
705
+ dimension: 'citability',
706
+ weight: 3,
707
+ title: '小节答案可直接摘录',
708
+ fix: '每个 h2 下紧跟 30–140 词的直接回答,再展开细节;避免先铺垫后给结论。',
709
+ evaluate({ primary }) {
710
+ if (!primary) return fail('未抓取到 HTML 入口页');
711
+ const count = primary.facts.snippetBlockCount;
712
+ if (count >= 2) return pass(`${count} 个小节满足“标题 + 30–140 词答案”`);
713
+ if (count === 1) return warn('仅 1 个小节满足自包含写法');
714
+ return skip('没有“标题 + 直接答案”的小节;Google 明确表示不需要为 AI 切分内容,此项仅作可摘录性参考');
715
+ },
716
+ },
717
+
718
+ // ---------------------------------------------------------------- 实体与信任
719
+ {
720
+ id: 'trust.https',
721
+ dimension: 'trust',
722
+ weight: 3,
723
+ title: '全站 HTTPS',
724
+ fix: '启用 HTTPS,把 HTTP 301 到 HTTPS,并提交 HSTS。',
725
+ evaluate({ scan }) {
726
+ let protocol;
727
+ try {
728
+ protocol = new URL(scan.origin).protocol;
729
+ } catch {
730
+ protocol = '';
731
+ }
732
+ if (protocol === 'https:') return pass(scan.origin);
733
+ return fail(`入口页为 ${protocol || '未知协议'},未启用 HTTPS`);
734
+ },
735
+ },
736
+ {
737
+ id: 'trust.org-schema',
738
+ dimension: 'trust',
739
+ weight: 3,
740
+ title: '组织实体 schema',
741
+ fix: '用 Organization/LocalBusiness JSON-LD 声明 name、url、logo、sameAs,帮助实体消歧与富结果;Google 表示生成式 AI 不要求特殊 schema。',
742
+ evaluate({ factsPages }) {
743
+ const entities = orgEntities(factsPages);
744
+ if (entities.length === 0) return warn('没有 Organization/Person 结构化数据;这对富结果与实体消歧有用,但不是 AI 功能的前提');
745
+ const complete = entities.find(({ entity }) => entity.name && (entity.url || entity.logo));
746
+ if (complete) return pass(`实体:${complete.entity.name}`);
747
+ return warn(`${entities.length} 个实体声明缺少 name/url/logo`);
748
+ },
749
+ },
750
+ {
751
+ id: 'trust.contact',
752
+ dimension: 'trust',
753
+ weight: 2,
754
+ title: '联系方式可找到',
755
+ fix: '提供 /contact 页面、mailto: 或 schema contactPoint,并保持信息与实体注册一致。',
756
+ evaluate({ pages, factsPages }) {
757
+ const contactPage = linkMatching(pages.filter((page) => page.facts), /^\/(?:contact|contact-us|about\/contact|联系|联系我们)/i);
758
+ const contactPoint = factsPages.some((page) => page.facts.orgEntities.some((entity) => entity.contactPoint));
759
+ const direct = factsPages.some((page) => page.facts.contactLinks.length > 0);
760
+ if (contactPage || contactPoint || direct) {
761
+ const via = contactPage ? `contact 页面:${contactPage.link.href}` : contactPoint ? 'schema contactPoint' : 'mailto/tel 链接';
762
+ return pass(via);
763
+ }
764
+ return fail('未找到 contact 页面、contactPoint 或 mailto/tel 链接');
765
+ },
766
+ },
767
+ {
768
+ id: 'trust.about',
769
+ dimension: 'trust',
770
+ weight: 2,
771
+ title: 'About 页面可核实身份',
772
+ fix: '提供 /about 页面,写明团队、公司主体、所在地与联系方式。',
773
+ evaluate({ pages }) {
774
+ const match = linkMatching(pages.filter((page) => page.facts), /^\/(?:about|about-us|company|关于|关于我们)/i);
775
+ if (!match) return fail('入口页没有 about 链接');
776
+ const crawled = pages.find((page) => page.facts && trimSlash(page.url) === trimSlash(match.link.href))
777
+ ?? pages.find((page) => page.facts && /^\/(?:about|about-us|company|关于|关于我们)/i.test(page.path));
778
+ if (!crawled) return warn(`about 链接存在但未抓取:${match.link.href}`);
779
+ const aboutLength = crawled.facts.contentLength ?? crawled.facts.textLength;
780
+ if (aboutLength >= 300) return pass(`about 页 ${aboutLength} 字`);
781
+ return warn(`about 页正文仅 ${aboutLength} 字`);
782
+ },
783
+ },
784
+ {
785
+ id: 'trust.security-headers',
786
+ dimension: 'trust',
787
+ weight: 2,
788
+ title: '基础安全响应头',
789
+ fix: '至少配置 HSTS(HTTPS)、Content-Security-Policy、X-Content-Type-Options: nosniff、Referrer-Policy。',
790
+ evaluate({ primary, scan }) {
791
+ if (!primary) return fail('未抓取到 HTML 入口页');
792
+ const headers = primary.headers;
793
+ const https = (() => {
794
+ try {
795
+ return new URL(scan.origin).protocol === 'https:';
796
+ } catch {
797
+ return false;
798
+ }
799
+ })();
800
+ const present = [];
801
+ if (https && headers['strict-transport-security']) present.push('HSTS');
802
+ if (headers['content-security-policy']) present.push('CSP');
803
+ if (/nosniff/i.test(headers['x-content-type-options'] ?? '')) present.push('X-Content-Type-Options');
804
+ if (headers['referrer-policy']) present.push('Referrer-Policy');
805
+ const evidence = present.length > 0 ? `已配置:${present.join(', ')}` : '四个基础安全头均缺失';
806
+ if (present.length >= 2) return pass(evidence);
807
+ if (present.length === 1) return warn(evidence);
808
+ return fail(evidence);
809
+ },
810
+ },
811
+ {
812
+ id: 'trust.privacy',
813
+ dimension: 'trust',
814
+ weight: 1,
815
+ title: '隐私政策可达',
816
+ fix: '添加隐私政策页面并从页脚链接,说明数据用途与联系方式。',
817
+ evaluate({ pages }) {
818
+ const match = linkMatching(pages.filter((page) => page.facts), /\/(?:privacy|privacy-policy|legal\/privacy|隐私)/i);
819
+ if (match) return pass(match.link.href);
820
+ return fail('没有隐私政策链接');
821
+ },
822
+ },
823
+ {
824
+ id: 'trust.sameas',
825
+ dimension: 'trust',
826
+ weight: 2,
827
+ title: '外部身份背书',
828
+ fix: '在 Organization sameAs 或 <link rel="me"> 中列出官方 GitHub、LinkedIn、X、维基数据等主页。',
829
+ evaluate({ factsPages }) {
830
+ const sameAs = [...new Set(factsPages.flatMap((page) => page.facts.sameAs))];
831
+ const relMe = [...new Set(factsPages.flatMap((page) => page.facts.relMe))];
832
+ const total = sameAs.length + relMe.length;
833
+ if (total >= 2) return pass(`${sameAs.length} 个 sameAs + ${relMe.length} 个 rel=me`);
834
+ if (total === 1) return warn('仅 1 个外部身份链接');
835
+ return fail('没有 sameAs 或 rel=me 外部身份链接');
836
+ },
837
+ },
838
+
839
+ // ---------------------------------------------------------------- 机器说明书
840
+ {
841
+ id: 'manifest.llms-txt',
842
+ dimension: 'manifest',
843
+ weight: 2,
844
+ title: 'llms.txt(可选,非 Google 必需)',
845
+ fix: '可选:若需要服务非 Google 的 agent/工具,可发布 llms.txt(# 标题 + ## 分节 + Markdown 链接)。Google Search 明确不使用 llms.txt,不要把它当作 Google 排名手段。',
846
+ evaluate({ scan }) {
847
+ if (scan.llms.found && scan.llms.valid) return pass(`HTTP 200,${scan.llms.sectionCount} 个分节 / ${scan.llms.linkCount} 个链接`);
848
+ if (scan.llms.found) return warn('llms.txt 存在但结构无效(缺少 # 标题或 Markdown 链接)');
849
+ if (scan.llms.blockedByRobots) return skip('robots.txt 禁止 llms.txt;Google 不使用它,非 Google agent 是否可读取决于对方的策略');
850
+ return skip('未提供 llms.txt;Google Search 不使用它,此检查仅在提供时评估');
851
+ },
852
+ },
853
+ {
854
+ id: 'manifest.llms-structure',
855
+ dimension: 'manifest',
856
+ weight: 1,
857
+ title: 'llms.txt 结构完整(可选)',
858
+ fix: '若提供 llms.txt,至少包含 2 个 ## 分节和 3 个指向正文的 Markdown 链接。注意:Google Search 不使用该文件。',
859
+ evaluate({ scan }) {
860
+ if (!scan.llms.found) return skip('没有 llms.txt,结构无从评估');
861
+ const { sectionCount, linkCount } = scan.llms;
862
+ if (sectionCount >= 2 && linkCount >= 3) return pass(`${sectionCount} 个分节 / ${linkCount} 个链接`);
863
+ if (sectionCount >= 1 || linkCount >= 1) return warn(`${sectionCount} 个分节 / ${linkCount} 个链接`);
864
+ return warn('llms.txt 只有标题,没有分节与链接');
865
+ },
866
+ },
867
+ {
868
+ id: 'manifest.structured-breadth',
869
+ dimension: 'manifest',
870
+ weight: 2,
871
+ title: 'schema.org 类型覆盖面(富结果)',
872
+ fix: '按页面类型输出 schema(Organization/WebSite、Article、FAQPage、BreadcrumbList),用于富结果与实体消歧。Google 明确表示生成式 AI 不需要特殊 schema。',
873
+ evaluate({ factsPages }) {
874
+ const types = new Set(factsPages.flatMap((page) => page.facts.jsonLdTypes));
875
+ if (types.size >= 3) return pass(`${types.size} 种类型:${[...types].slice(0, 6).join(', ')}`);
876
+ if (types.size === 2) return warn(`仅 2 种类型:${[...types].join(', ')}`);
877
+ if (types.size === 1) return warn(`仅 1 种类型:${[...types][0]}`);
878
+ return skip('没有 schema.org 类型;结构化数据可选,不是 AI 功能的前提');
879
+ },
880
+ },
881
+ {
882
+ id: 'manifest.og-cards',
883
+ dimension: 'manifest',
884
+ weight: 1,
885
+ title: 'OpenGraph / 分享卡片',
886
+ fix: '为每个页面输出 og:title、og:description、og:image(1200×630)与 og:url。',
887
+ evaluate({ primary }) {
888
+ if (!primary) return fail('未抓取到 HTML 入口页');
889
+ const meta = primary.facts.meta;
890
+ const present = ['og:title', 'og:description', 'og:image'].filter((key) => meta[key]);
891
+ if (present.length === 3) return pass('og:title / og:description / og:image 均存在');
892
+ if (present.length > 0) return warn(`缺少 ${['og:title', 'og:description', 'og:image'].filter((key) => !meta[key]).join(', ')}`);
893
+ return skip('没有 OpenGraph 标签;它影响社交分享预览,不影响 Google AI 可见性');
894
+ },
895
+ },
896
+ {
897
+ id: 'manifest.feed',
898
+ dimension: 'manifest',
899
+ weight: 1,
900
+ title: '内容 feed(可选)',
901
+ fix: '发布 RSS/Atom feed,并用 <link rel="alternate" type="application/rss+xml"> 暴露;它服务于订阅与分发,不是 Google AI 的要求。',
902
+ evaluate({ primary }) {
903
+ if (!primary) return fail('未抓取到 HTML 入口页');
904
+ const feed = primary.facts.alternateLinks.find((link) => ['application/rss+xml', 'application/atom+xml', 'application/feed+json'].includes(link.type)
905
+ || /(?:^|\/)(?:feed|rss|atom)(?:\.xml)?$/i.test(link.href));
906
+ if (feed) return pass(feed.href);
907
+ return skip('没有可发现的 feed;这是分发渠道建议,不是 AI 可见性要求');
908
+ },
909
+ },
910
+ {
911
+ id: 'manifest.link-hints',
912
+ dimension: 'manifest',
913
+ weight: 1,
914
+ title: 'HTTP Link / Markdown 入口提示(可选)',
915
+ fix: '可选:在响应头加 Link: </llms.txt>; rel="llms",或提供 text/markdown alternate。Google Search 不使用这些提示。',
916
+ evaluate({ primary }) {
917
+ if (!primary) return fail('未抓取到 HTML 入口页');
918
+ const header = primary.headers.link ?? '';
919
+ const markdown = primary.facts.alternateLinks.some((link) => link.type === 'text/markdown' || /\.md$/i.test(link.href));
920
+ const llmsHeader = /rel\s*=\s*"?llms/i.test(header);
921
+ if (llmsHeader || markdown) return pass(llmsHeader ? 'Link: rel="llms"' : 'Markdown alternate 链接');
922
+ return skip('没有 rel="llms" 或 text/markdown 提示;Google Search 不使用它们');
923
+ },
924
+ },
925
+ {
926
+ id: 'manifest.entity-id',
927
+ dimension: 'manifest',
928
+ weight: 1,
929
+ title: '实体 @id 稳定',
930
+ fix: '给 Organization/WebSite 分配稳定的 @id(如 https://example.com/#organization),所有页面复用同一 @id。',
931
+ evaluate({ factsPages }) {
932
+ const entities = orgEntities(factsPages);
933
+ if (entities.length === 0) return skip('没有实体声明;稳定 @id 仅在已有实体时评估');
934
+ const withId = entities.find(({ entity }) => typeof entity['@id'] === 'string' && /^https?:\/\//i.test(entity['@id']));
935
+ if (withId) return pass(withId.entity['@id']);
936
+ return warn('实体缺少绝对 @id');
937
+ },
938
+ },
939
+ ];