@cobola/dsh-geo 0.8.0 → 0.10.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/CHANGELOG.md +49 -0
- package/README.md +20 -2
- package/bin/dsh-geo.js +70 -2
- package/client.js +13 -0
- package/docs/CI.md +1 -1
- package/docs/GENERATORS.md +75 -0
- package/docs/RULES.md +67 -59
- package/docs/index.json +1 -1
- package/examples/geo-audit.yml +1 -1
- package/examples/geo-baseline.yml +1 -1
- package/index.js +10 -1
- package/lib/generate.js +178 -0
- package/lib/html.js +47 -5
- package/lib/mcp.js +58 -0
- package/lib/report.js +18 -0
- package/lib/rules.js +225 -1
- package/lib/score.js +27 -1
- package/package.json +1 -1
package/lib/rules.js
CHANGED
|
@@ -12,7 +12,33 @@
|
|
|
12
12
|
* - skip: excluded from the denominator (not applicable)
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
export const RUBRIC_VERSION = 'geo-rubric@
|
|
15
|
+
export const RUBRIC_VERSION = 'geo-rubric@2';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The three optimisation pillars industry tools report separately.
|
|
19
|
+
*
|
|
20
|
+
* They are a second view over the same rules, never a second score: a rule
|
|
21
|
+
* contributes to exactly one pillar, and the pillars explain which part of the
|
|
22
|
+
* problem a finding belongs to. Adding a pillar does not change the Core total,
|
|
23
|
+
* which stays the five-dimension weighted score.
|
|
24
|
+
*/
|
|
25
|
+
export const PILLARS = [
|
|
26
|
+
{
|
|
27
|
+
id: 'seo',
|
|
28
|
+
title: 'SEO',
|
|
29
|
+
summary: '传统搜索引擎:抓取、索引、元数据、规范 URL 与可发现性。',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'aeo',
|
|
33
|
+
title: 'AEO',
|
|
34
|
+
summary: '答案引擎:语音助手与摘要场景需要的可回答结构、问答与实体。',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'geo',
|
|
38
|
+
title: 'GEO',
|
|
39
|
+
summary: '生成式引擎:AI 爬虫策略、机器说明书、可引用性与时效。',
|
|
40
|
+
},
|
|
41
|
+
];
|
|
16
42
|
|
|
17
43
|
export const DIMENSIONS = [
|
|
18
44
|
{
|
|
@@ -209,6 +235,7 @@ export const RULES = [
|
|
|
209
235
|
// ---------------------------------------------------------------- 可发现性
|
|
210
236
|
{
|
|
211
237
|
id: 'disc.robots-present',
|
|
238
|
+
pillar: 'seo',
|
|
212
239
|
dimension: 'discoverability',
|
|
213
240
|
weight: 3,
|
|
214
241
|
title: 'robots.txt 可访问',
|
|
@@ -221,6 +248,7 @@ export const RULES = [
|
|
|
221
248
|
},
|
|
222
249
|
{
|
|
223
250
|
id: 'disc.robots-not-blocking-site',
|
|
251
|
+
pillar: 'seo',
|
|
224
252
|
dimension: 'discoverability',
|
|
225
253
|
weight: 4,
|
|
226
254
|
title: 'robots.txt 未封禁站点',
|
|
@@ -238,6 +266,7 @@ export const RULES = [
|
|
|
238
266
|
},
|
|
239
267
|
{
|
|
240
268
|
id: 'disc.ai-crawler-policy',
|
|
269
|
+
pillar: 'geo',
|
|
241
270
|
dimension: 'discoverability',
|
|
242
271
|
weight: 3,
|
|
243
272
|
title: 'AI 爬虫策略明确',
|
|
@@ -256,6 +285,7 @@ export const RULES = [
|
|
|
256
285
|
},
|
|
257
286
|
{
|
|
258
287
|
id: 'disc.googlebot-accessible',
|
|
288
|
+
pillar: 'seo',
|
|
259
289
|
dimension: 'discoverability',
|
|
260
290
|
weight: 3,
|
|
261
291
|
title: 'Googlebot 可抓取',
|
|
@@ -271,6 +301,7 @@ export const RULES = [
|
|
|
271
301
|
},
|
|
272
302
|
{
|
|
273
303
|
id: 'disc.sitemap-present',
|
|
304
|
+
pillar: 'seo',
|
|
274
305
|
dimension: 'discoverability',
|
|
275
306
|
weight: 3,
|
|
276
307
|
title: 'XML sitemap 可用',
|
|
@@ -285,6 +316,7 @@ export const RULES = [
|
|
|
285
316
|
},
|
|
286
317
|
{
|
|
287
318
|
id: 'disc.sitemap-declared',
|
|
319
|
+
pillar: 'seo',
|
|
288
320
|
dimension: 'discoverability',
|
|
289
321
|
weight: 2,
|
|
290
322
|
title: 'sitemap 已声明',
|
|
@@ -301,6 +333,7 @@ export const RULES = [
|
|
|
301
333
|
},
|
|
302
334
|
{
|
|
303
335
|
id: 'disc.sitemap-covers-pages',
|
|
336
|
+
pillar: 'seo',
|
|
304
337
|
dimension: 'discoverability',
|
|
305
338
|
weight: 2,
|
|
306
339
|
title: 'sitemap 覆盖已抓取页面',
|
|
@@ -320,6 +353,7 @@ export const RULES = [
|
|
|
320
353
|
},
|
|
321
354
|
{
|
|
322
355
|
id: 'disc.indexable',
|
|
356
|
+
pillar: 'seo',
|
|
323
357
|
dimension: 'discoverability',
|
|
324
358
|
weight: 3,
|
|
325
359
|
title: '入口页可索引',
|
|
@@ -339,6 +373,7 @@ export const RULES = [
|
|
|
339
373
|
},
|
|
340
374
|
{
|
|
341
375
|
id: 'disc.canonical',
|
|
376
|
+
pillar: 'seo',
|
|
342
377
|
dimension: 'discoverability',
|
|
343
378
|
weight: 2,
|
|
344
379
|
title: 'canonical 自指且为绝对地址',
|
|
@@ -354,6 +389,7 @@ export const RULES = [
|
|
|
354
389
|
},
|
|
355
390
|
{
|
|
356
391
|
id: 'disc.internal-links',
|
|
392
|
+
pillar: 'seo',
|
|
357
393
|
dimension: 'discoverability',
|
|
358
394
|
weight: 3,
|
|
359
395
|
title: '入口页内链充分',
|
|
@@ -371,6 +407,7 @@ export const RULES = [
|
|
|
371
407
|
// ---------------------------------------------------------------- 可解析性
|
|
372
408
|
{
|
|
373
409
|
id: 'parse.title',
|
|
410
|
+
pillar: 'seo',
|
|
374
411
|
dimension: 'parsability',
|
|
375
412
|
weight: 3,
|
|
376
413
|
title: '<title> 长度合适',
|
|
@@ -385,6 +422,7 @@ export const RULES = [
|
|
|
385
422
|
},
|
|
386
423
|
{
|
|
387
424
|
id: 'parse.meta-description',
|
|
425
|
+
pillar: 'seo',
|
|
388
426
|
dimension: 'parsability',
|
|
389
427
|
weight: 2,
|
|
390
428
|
title: 'meta description 存在且合适',
|
|
@@ -400,6 +438,7 @@ export const RULES = [
|
|
|
400
438
|
},
|
|
401
439
|
{
|
|
402
440
|
id: 'parse.lang',
|
|
441
|
+
pillar: 'seo',
|
|
403
442
|
dimension: 'parsability',
|
|
404
443
|
weight: 1,
|
|
405
444
|
title: '<html lang> 已声明',
|
|
@@ -412,6 +451,7 @@ export const RULES = [
|
|
|
412
451
|
},
|
|
413
452
|
{
|
|
414
453
|
id: 'parse.h1',
|
|
454
|
+
pillar: 'seo',
|
|
415
455
|
dimension: 'parsability',
|
|
416
456
|
weight: 2,
|
|
417
457
|
title: '唯一且非空的主标题',
|
|
@@ -426,6 +466,7 @@ export const RULES = [
|
|
|
426
466
|
},
|
|
427
467
|
{
|
|
428
468
|
id: 'parse.heading-order',
|
|
469
|
+
pillar: 'seo',
|
|
429
470
|
dimension: 'parsability',
|
|
430
471
|
weight: 2,
|
|
431
472
|
title: '标题层级连续',
|
|
@@ -449,6 +490,7 @@ export const RULES = [
|
|
|
449
490
|
},
|
|
450
491
|
{
|
|
451
492
|
id: 'parse.semantics',
|
|
493
|
+
pillar: 'aeo',
|
|
452
494
|
dimension: 'parsability',
|
|
453
495
|
weight: 2,
|
|
454
496
|
title: '语义化正文容器',
|
|
@@ -462,6 +504,7 @@ export const RULES = [
|
|
|
462
504
|
},
|
|
463
505
|
{
|
|
464
506
|
id: 'parse.raw-content',
|
|
507
|
+
pillar: 'aeo',
|
|
465
508
|
dimension: 'parsability',
|
|
466
509
|
weight: 3,
|
|
467
510
|
title: '无 JS 也能读到正文',
|
|
@@ -476,6 +519,7 @@ export const RULES = [
|
|
|
476
519
|
},
|
|
477
520
|
{
|
|
478
521
|
id: 'parse.pages-with-content',
|
|
522
|
+
pillar: 'aeo',
|
|
479
523
|
dimension: 'parsability',
|
|
480
524
|
weight: 2,
|
|
481
525
|
title: '被抓取页面普遍含正文',
|
|
@@ -492,6 +536,7 @@ export const RULES = [
|
|
|
492
536
|
},
|
|
493
537
|
{
|
|
494
538
|
id: 'parse.duplicate-metadata',
|
|
539
|
+
pillar: 'seo',
|
|
495
540
|
dimension: 'parsability',
|
|
496
541
|
weight: 2,
|
|
497
542
|
title: '页面标题/描述不重复',
|
|
@@ -518,6 +563,7 @@ export const RULES = [
|
|
|
518
563
|
},
|
|
519
564
|
{
|
|
520
565
|
id: 'parse.image-alt',
|
|
566
|
+
pillar: 'seo',
|
|
521
567
|
dimension: 'parsability',
|
|
522
568
|
weight: 2,
|
|
523
569
|
title: '图片 alt 覆盖',
|
|
@@ -534,6 +580,7 @@ export const RULES = [
|
|
|
534
580
|
},
|
|
535
581
|
{
|
|
536
582
|
id: 'parse.jsonld-syntax',
|
|
583
|
+
pillar: 'aeo',
|
|
537
584
|
dimension: 'parsability',
|
|
538
585
|
weight: 2,
|
|
539
586
|
title: 'JSON-LD 语法有效',
|
|
@@ -549,6 +596,7 @@ export const RULES = [
|
|
|
549
596
|
},
|
|
550
597
|
{
|
|
551
598
|
id: 'parse.link-text',
|
|
599
|
+
pillar: 'seo',
|
|
552
600
|
dimension: 'parsability',
|
|
553
601
|
weight: 1,
|
|
554
602
|
title: '内链锚文本有描述性',
|
|
@@ -572,6 +620,7 @@ export const RULES = [
|
|
|
572
620
|
// ---------------------------------------------------------------- 可引用性
|
|
573
621
|
{
|
|
574
622
|
id: 'cite.qa-structure',
|
|
623
|
+
pillar: 'aeo',
|
|
575
624
|
dimension: 'citability',
|
|
576
625
|
weight: 3,
|
|
577
626
|
title: '问答结构',
|
|
@@ -588,6 +637,7 @@ export const RULES = [
|
|
|
588
637
|
},
|
|
589
638
|
{
|
|
590
639
|
id: 'cite.summary',
|
|
640
|
+
pillar: 'aeo',
|
|
591
641
|
dimension: 'citability',
|
|
592
642
|
weight: 2,
|
|
593
643
|
title: '摘要 / TL;DR 区块',
|
|
@@ -600,6 +650,7 @@ export const RULES = [
|
|
|
600
650
|
},
|
|
601
651
|
{
|
|
602
652
|
id: 'cite.numeric-evidence',
|
|
653
|
+
pillar: 'geo',
|
|
603
654
|
dimension: 'citability',
|
|
604
655
|
weight: 3,
|
|
605
656
|
title: '可验证的数字证据',
|
|
@@ -614,6 +665,7 @@ export const RULES = [
|
|
|
614
665
|
},
|
|
615
666
|
{
|
|
616
667
|
id: 'cite.authority-sources',
|
|
668
|
+
pillar: 'geo',
|
|
617
669
|
dimension: 'citability',
|
|
618
670
|
weight: 2,
|
|
619
671
|
title: '引用权威来源',
|
|
@@ -628,6 +680,7 @@ export const RULES = [
|
|
|
628
680
|
},
|
|
629
681
|
{
|
|
630
682
|
id: 'cite.freshness',
|
|
683
|
+
pillar: 'geo',
|
|
631
684
|
dimension: 'citability',
|
|
632
685
|
weight: 3,
|
|
633
686
|
title: '内容时效可判定',
|
|
@@ -646,6 +699,7 @@ export const RULES = [
|
|
|
646
699
|
},
|
|
647
700
|
{
|
|
648
701
|
id: 'cite.author',
|
|
702
|
+
pillar: 'geo',
|
|
649
703
|
dimension: 'citability',
|
|
650
704
|
weight: 2,
|
|
651
705
|
title: '作者署名可识别',
|
|
@@ -663,6 +717,7 @@ export const RULES = [
|
|
|
663
717
|
},
|
|
664
718
|
{
|
|
665
719
|
id: 'cite.anchors',
|
|
720
|
+
pillar: 'aeo',
|
|
666
721
|
dimension: 'citability',
|
|
667
722
|
weight: 2,
|
|
668
723
|
title: '章节可锚点引用',
|
|
@@ -681,6 +736,7 @@ export const RULES = [
|
|
|
681
736
|
},
|
|
682
737
|
{
|
|
683
738
|
id: 'cite.structure',
|
|
739
|
+
pillar: 'aeo',
|
|
684
740
|
dimension: 'citability',
|
|
685
741
|
weight: 3,
|
|
686
742
|
title: '结构化排版与短段落',
|
|
@@ -702,6 +758,7 @@ export const RULES = [
|
|
|
702
758
|
},
|
|
703
759
|
{
|
|
704
760
|
id: 'cite.snippet-ready',
|
|
761
|
+
pillar: 'aeo',
|
|
705
762
|
dimension: 'citability',
|
|
706
763
|
weight: 3,
|
|
707
764
|
title: '小节答案可直接摘录',
|
|
@@ -718,6 +775,7 @@ export const RULES = [
|
|
|
718
775
|
// ---------------------------------------------------------------- 实体与信任
|
|
719
776
|
{
|
|
720
777
|
id: 'trust.https',
|
|
778
|
+
pillar: 'seo',
|
|
721
779
|
dimension: 'trust',
|
|
722
780
|
weight: 3,
|
|
723
781
|
title: '全站 HTTPS',
|
|
@@ -735,6 +793,7 @@ export const RULES = [
|
|
|
735
793
|
},
|
|
736
794
|
{
|
|
737
795
|
id: 'trust.org-schema',
|
|
796
|
+
pillar: 'aeo',
|
|
738
797
|
dimension: 'trust',
|
|
739
798
|
weight: 3,
|
|
740
799
|
title: '组织实体 schema',
|
|
@@ -749,6 +808,7 @@ export const RULES = [
|
|
|
749
808
|
},
|
|
750
809
|
{
|
|
751
810
|
id: 'trust.contact',
|
|
811
|
+
pillar: 'aeo',
|
|
752
812
|
dimension: 'trust',
|
|
753
813
|
weight: 2,
|
|
754
814
|
title: '联系方式可找到',
|
|
@@ -766,6 +826,7 @@ export const RULES = [
|
|
|
766
826
|
},
|
|
767
827
|
{
|
|
768
828
|
id: 'trust.about',
|
|
829
|
+
pillar: 'aeo',
|
|
769
830
|
dimension: 'trust',
|
|
770
831
|
weight: 2,
|
|
771
832
|
title: 'About 页面可核实身份',
|
|
@@ -783,6 +844,7 @@ export const RULES = [
|
|
|
783
844
|
},
|
|
784
845
|
{
|
|
785
846
|
id: 'trust.security-headers',
|
|
847
|
+
pillar: 'seo',
|
|
786
848
|
dimension: 'trust',
|
|
787
849
|
weight: 2,
|
|
788
850
|
title: '基础安全响应头',
|
|
@@ -810,6 +872,7 @@ export const RULES = [
|
|
|
810
872
|
},
|
|
811
873
|
{
|
|
812
874
|
id: 'trust.privacy',
|
|
875
|
+
pillar: 'aeo',
|
|
813
876
|
dimension: 'trust',
|
|
814
877
|
weight: 1,
|
|
815
878
|
title: '隐私政策可达',
|
|
@@ -822,6 +885,7 @@ export const RULES = [
|
|
|
822
885
|
},
|
|
823
886
|
{
|
|
824
887
|
id: 'trust.sameas',
|
|
888
|
+
pillar: 'geo',
|
|
825
889
|
dimension: 'trust',
|
|
826
890
|
weight: 2,
|
|
827
891
|
title: '外部身份背书',
|
|
@@ -836,9 +900,163 @@ export const RULES = [
|
|
|
836
900
|
},
|
|
837
901
|
},
|
|
838
902
|
|
|
903
|
+
{
|
|
904
|
+
id: 'seo.viewport',
|
|
905
|
+
pillar: 'seo',
|
|
906
|
+
dimension: 'parsability',
|
|
907
|
+
weight: 2,
|
|
908
|
+
title: '移动端视口声明',
|
|
909
|
+
fix: '在 <head> 输出 <meta name="viewport" content="width=device-width, initial-scale=1">;缺少它会让移动端按桌面宽度渲染。',
|
|
910
|
+
evaluate({ primary }) {
|
|
911
|
+
if (!primary) return fail('未抓取到 HTML 入口页');
|
|
912
|
+
const viewport = primary.facts.metaViewport ?? '';
|
|
913
|
+
if (!viewport) return fail('缺少 meta viewport');
|
|
914
|
+
if (/width\s*=\s*device-width/i.test(viewport)) return pass(viewport.slice(0, 80));
|
|
915
|
+
return warn(`viewport 未使用 device-width:${viewport.slice(0, 80)}`);
|
|
916
|
+
},
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
id: 'seo.image-dimensions',
|
|
920
|
+
pillar: 'seo',
|
|
921
|
+
dimension: 'parsability',
|
|
922
|
+
weight: 2,
|
|
923
|
+
title: '图片声明宽高',
|
|
924
|
+
fix: '为 <img> 写上 width/height 或使用 aspect-ratio,避免加载时布局跳动(CLS)。',
|
|
925
|
+
evaluate({ factsPages }) {
|
|
926
|
+
const stats = imageStats(factsPages);
|
|
927
|
+
if (stats.total === 0) return skip('未使用图片');
|
|
928
|
+
let withDimensions = 0;
|
|
929
|
+
for (const page of factsPages) {
|
|
930
|
+
for (const image of page.facts.images) if (image.hasDimensions) withDimensions += 1;
|
|
931
|
+
}
|
|
932
|
+
const ratio = withDimensions / stats.total;
|
|
933
|
+
const evidence = `${withDimensions}/${stats.total} 张图片声明了宽高`;
|
|
934
|
+
if (ratio >= 0.8) return pass(evidence);
|
|
935
|
+
if (ratio >= 0.4) return warn(evidence);
|
|
936
|
+
return fail(evidence);
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
id: 'seo.image-lazy',
|
|
941
|
+
pillar: 'seo',
|
|
942
|
+
dimension: 'parsability',
|
|
943
|
+
weight: 1,
|
|
944
|
+
title: '首屏外图片懒加载',
|
|
945
|
+
fix: '给首屏以下的图片加 loading="lazy",首屏图不要加,避免延迟最大内容渲染。',
|
|
946
|
+
evaluate({ primary }) {
|
|
947
|
+
if (!primary) return fail('未抓取到 HTML 入口页');
|
|
948
|
+
const images = primary.facts.images ?? [];
|
|
949
|
+
if (images.length === 0) return skip('入口页没有图片');
|
|
950
|
+
const lazy = images.filter((image) => image.lazy).length;
|
|
951
|
+
if (lazy > 0) return pass(`${lazy}/${images.length} 张图片使用 loading="lazy"`);
|
|
952
|
+
if (images.length <= 2) return skip(`入口页只有 ${images.length} 张图片,懒加载意义有限`);
|
|
953
|
+
return warn(`${images.length} 张图片都没有 loading="lazy"`);
|
|
954
|
+
},
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
id: 'seo.url-structure',
|
|
958
|
+
pillar: 'seo',
|
|
959
|
+
dimension: 'discoverability',
|
|
960
|
+
weight: 2,
|
|
961
|
+
title: 'URL 结构可读',
|
|
962
|
+
fix: '用短、含语义词的路径;避免大写、下划线、过长 query 串与深层嵌套(超过 4 层)。',
|
|
963
|
+
evaluate({ pages }) {
|
|
964
|
+
const html = pages.filter((page) => page.facts);
|
|
965
|
+
if (html.length === 0) return fail('未抓取到 HTML 页面');
|
|
966
|
+
const problems = [];
|
|
967
|
+
for (const page of html) {
|
|
968
|
+
const path = page.path ?? '/';
|
|
969
|
+
const depth = path.split('/').filter(Boolean).length;
|
|
970
|
+
if (depth > 4) problems.push(`${path}(${depth} 层)`);
|
|
971
|
+
else if (/[A-Z]/.test(path)) problems.push(`${path}(含大写)`);
|
|
972
|
+
else if (/_/.test(path)) problems.push(`${path}(含下划线)`);
|
|
973
|
+
else if ((page.facts.url ?? '').length > 120) problems.push(`${path}(过长)`);
|
|
974
|
+
}
|
|
975
|
+
if (problems.length === 0) return pass(`${html.length} 个页面路径结构清晰`);
|
|
976
|
+
if (problems.length <= Math.ceil(html.length / 2)) return warn(`${problems.length} 个页面路径可优化:${problems.slice(0, 3).join('、')}`);
|
|
977
|
+
return fail(`${problems.length}/${html.length} 个页面路径可优化`);
|
|
978
|
+
},
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
id: 'seo.hreflang',
|
|
982
|
+
pillar: 'seo',
|
|
983
|
+
dimension: 'discoverability',
|
|
984
|
+
weight: 1,
|
|
985
|
+
title: '多语言 hreflang',
|
|
986
|
+
fix: '若站点有多个语言版本,用 <link rel="alternate" hreflang="..."> 标注互指;单语言站点可忽略。',
|
|
987
|
+
evaluate({ primary }) {
|
|
988
|
+
if (!primary) return fail('未抓取到 HTML 入口页');
|
|
989
|
+
if (primary.facts.hreflangs.length > 0) {
|
|
990
|
+
return pass(`${primary.facts.hreflangs.length} 个 hreflang:${primary.facts.hreflangs.slice(0, 5).join(', ')}`);
|
|
991
|
+
}
|
|
992
|
+
return skip('未声明 hreflang;单语言站点不需要');
|
|
993
|
+
},
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
id: 'aeo.answer-first',
|
|
997
|
+
pillar: 'aeo',
|
|
998
|
+
dimension: 'citability',
|
|
999
|
+
weight: 3,
|
|
1000
|
+
title: '正文开头给出直接答案',
|
|
1001
|
+
fix: '在第一个 h1 之后紧跟一段 2–4 句的直接回答,再展开解释;语音助手与摘要更依赖开头的自足段落。',
|
|
1002
|
+
evaluate({ primary }) {
|
|
1003
|
+
if (!primary) return fail('未抓取到 HTML 入口页');
|
|
1004
|
+
const sections = primary.facts.sections ?? [];
|
|
1005
|
+
// Bylines and kickers are short paragraphs before the real answer; skip
|
|
1006
|
+
// them and judge the first substantial paragraph near the top instead.
|
|
1007
|
+
const candidates = sections
|
|
1008
|
+
.slice(0, 3)
|
|
1009
|
+
.flatMap((section) => section.paragraphs)
|
|
1010
|
+
.filter((text) => text.length > 0);
|
|
1011
|
+
const first = candidates.find((text) => text.length >= 25);
|
|
1012
|
+
if (!first) {
|
|
1013
|
+
const longest = candidates.sort((a, b) => b.length - a.length)[0] ?? '';
|
|
1014
|
+
return fail(`开头没有可作答案的段落(最长 ${longest.length} 字)`);
|
|
1015
|
+
}
|
|
1016
|
+
if (first.length >= 60) return pass(`开头段落 ${first.length} 字:${first.slice(0, 60)}…`);
|
|
1017
|
+
return warn(`开头段落仅 ${first.length} 字,建议扩成 2–4 句直接回答`);
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
id: 'aeo.question-density',
|
|
1022
|
+
pillar: 'aeo',
|
|
1023
|
+
dimension: 'citability',
|
|
1024
|
+
weight: 2,
|
|
1025
|
+
title: '问句式标题覆盖',
|
|
1026
|
+
fix: '用用户真实的提问作为 h2/h3(“怎么…”“为什么…”“是否…”),一段回答一个问题。',
|
|
1027
|
+
evaluate({ primary }) {
|
|
1028
|
+
if (!primary) return fail('未抓取到 HTML 入口页');
|
|
1029
|
+
const headings = primary.facts.headings.filter((heading) => heading.level >= 2);
|
|
1030
|
+
if (headings.length === 0) return fail('入口页没有二级标题');
|
|
1031
|
+
const questions = primary.facts.questionHeadings.length;
|
|
1032
|
+
const ratio = questions / headings.length;
|
|
1033
|
+
const evidence = `${questions}/${headings.length} 个二级标题是问句`;
|
|
1034
|
+
if (questions >= 3 && ratio >= 0.25) return pass(evidence);
|
|
1035
|
+
if (questions >= 1) return warn(evidence);
|
|
1036
|
+
return fail(evidence);
|
|
1037
|
+
},
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
id: 'aeo.definition-list',
|
|
1041
|
+
pillar: 'aeo',
|
|
1042
|
+
dimension: 'citability',
|
|
1043
|
+
weight: 1,
|
|
1044
|
+
title: '术语与要点可抽取',
|
|
1045
|
+
fix: '用 <dl>/<table>/<ul> 承载定义、对比与步骤;纯段落堆叠不易被答案引擎抽成条目。',
|
|
1046
|
+
evaluate({ primary }) {
|
|
1047
|
+
if (!primary) return fail('未抓取到 HTML 入口页');
|
|
1048
|
+
const { tables, lists, definitionLists } = primary.facts.counts;
|
|
1049
|
+
const total = tables + lists + definitionLists;
|
|
1050
|
+
if (total >= 3) return pass(`${tables} 表格 / ${lists} 列表 / ${definitionLists} 定义列表`);
|
|
1051
|
+
if (total >= 1) return warn(`仅 ${total} 处结构化列表或表格`);
|
|
1052
|
+
return fail('没有列表、表格或定义列表');
|
|
1053
|
+
},
|
|
1054
|
+
},
|
|
1055
|
+
|
|
839
1056
|
// ---------------------------------------------------------------- 机器说明书
|
|
840
1057
|
{
|
|
841
1058
|
id: 'manifest.llms-txt',
|
|
1059
|
+
pillar: 'geo',
|
|
842
1060
|
dimension: 'manifest',
|
|
843
1061
|
weight: 2,
|
|
844
1062
|
title: 'llms.txt(可选,非 Google 必需)',
|
|
@@ -852,6 +1070,7 @@ export const RULES = [
|
|
|
852
1070
|
},
|
|
853
1071
|
{
|
|
854
1072
|
id: 'manifest.llms-structure',
|
|
1073
|
+
pillar: 'geo',
|
|
855
1074
|
dimension: 'manifest',
|
|
856
1075
|
weight: 1,
|
|
857
1076
|
title: 'llms.txt 结构完整(可选)',
|
|
@@ -866,6 +1085,7 @@ export const RULES = [
|
|
|
866
1085
|
},
|
|
867
1086
|
{
|
|
868
1087
|
id: 'manifest.structured-breadth',
|
|
1088
|
+
pillar: 'geo',
|
|
869
1089
|
dimension: 'manifest',
|
|
870
1090
|
weight: 2,
|
|
871
1091
|
title: 'schema.org 类型覆盖面(富结果)',
|
|
@@ -880,6 +1100,7 @@ export const RULES = [
|
|
|
880
1100
|
},
|
|
881
1101
|
{
|
|
882
1102
|
id: 'manifest.og-cards',
|
|
1103
|
+
pillar: 'seo',
|
|
883
1104
|
dimension: 'manifest',
|
|
884
1105
|
weight: 1,
|
|
885
1106
|
title: 'OpenGraph / 分享卡片',
|
|
@@ -895,6 +1116,7 @@ export const RULES = [
|
|
|
895
1116
|
},
|
|
896
1117
|
{
|
|
897
1118
|
id: 'manifest.feed',
|
|
1119
|
+
pillar: 'seo',
|
|
898
1120
|
dimension: 'manifest',
|
|
899
1121
|
weight: 1,
|
|
900
1122
|
title: '内容 feed(可选)',
|
|
@@ -909,6 +1131,7 @@ export const RULES = [
|
|
|
909
1131
|
},
|
|
910
1132
|
{
|
|
911
1133
|
id: 'manifest.link-hints',
|
|
1134
|
+
pillar: 'geo',
|
|
912
1135
|
dimension: 'manifest',
|
|
913
1136
|
weight: 1,
|
|
914
1137
|
title: 'HTTP Link / Markdown 入口提示(可选)',
|
|
@@ -924,6 +1147,7 @@ export const RULES = [
|
|
|
924
1147
|
},
|
|
925
1148
|
{
|
|
926
1149
|
id: 'manifest.entity-id',
|
|
1150
|
+
pillar: 'geo',
|
|
927
1151
|
dimension: 'manifest',
|
|
928
1152
|
weight: 1,
|
|
929
1153
|
title: '实体 @id 稳定',
|
package/lib/score.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { evaluatePlatforms } from './platforms/index.js';
|
|
12
|
-
import { DIMENSIONS, RULES, RUBRIC_VERSION, evaluateRules } from './rules.js';
|
|
12
|
+
import { DIMENSIONS, PILLARS, RULES, RUBRIC_VERSION, evaluateRules } from './rules.js';
|
|
13
13
|
|
|
14
14
|
export const SCORE_VERSION = 'score@1';
|
|
15
15
|
|
|
@@ -108,6 +108,31 @@ export function scoreScan(scan, options = {}) {
|
|
|
108
108
|
skip: findings.filter((finding) => finding.status === 'skip').length,
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
// Pillars are a second view over the same findings: each rule belongs to
|
|
112
|
+
// exactly one pillar, and the pillar score is that subset's weighted ratio.
|
|
113
|
+
const pillars = PILLARS.map((pillar) => {
|
|
114
|
+
const own = findings.filter((finding) => {
|
|
115
|
+
const rule = RULES.find((entry) => entry.id === finding.id);
|
|
116
|
+
return rule?.pillar === pillar.id;
|
|
117
|
+
});
|
|
118
|
+
const applicable = own.reduce((sum, finding) => sum + (finding.status === 'skip' ? 0 : finding.weight), 0);
|
|
119
|
+
const earned = own.reduce((sum, finding) => sum + finding.weight * (STATUS_FACTOR[finding.status] ?? 0), 0);
|
|
120
|
+
return {
|
|
121
|
+
id: pillar.id,
|
|
122
|
+
title: pillar.title,
|
|
123
|
+
summary: pillar.summary,
|
|
124
|
+
score: applicable > 0 ? round1((earned / applicable) * 100) : 0,
|
|
125
|
+
scored: applicable > 0,
|
|
126
|
+
ruleCount: own.length,
|
|
127
|
+
counts: {
|
|
128
|
+
pass: own.filter((finding) => finding.status === 'pass').length,
|
|
129
|
+
warn: own.filter((finding) => finding.status === 'warn').length,
|
|
130
|
+
fail: own.filter((finding) => finding.status === 'fail').length,
|
|
131
|
+
skip: own.filter((finding) => finding.status === 'skip').length,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
|
|
111
136
|
const dimensionWeight = new Map(DIMENSIONS.map((dimension) => [dimension.id, dimension.weight]));
|
|
112
137
|
const actions = findings
|
|
113
138
|
.filter((finding) => finding.status === 'fail' || finding.status === 'warn')
|
|
@@ -135,6 +160,7 @@ export function scoreScan(scan, options = {}) {
|
|
|
135
160
|
grade: grade.grade,
|
|
136
161
|
gradeLabel: grade.label,
|
|
137
162
|
dimensions,
|
|
163
|
+
pillars,
|
|
138
164
|
counts,
|
|
139
165
|
findings,
|
|
140
166
|
actions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobola/dsh-geo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Read-only, reproducible GEO/SEO website audits for DeepSeek Harness: inspect crawlability and citation-ready structure, return evidence and prioritized fixes, and never edit the site or promise rankings.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|