@cobola/dsh-geo 0.10.0 → 0.12.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 CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.0 - 2026-11-29
4
+
5
+ ### Removed
6
+
7
+ - Delete `lib/profiles.js` and its test. It was the original platform evidence
8
+ registry, superseded by `lib/platforms/*`; no production code imported it.
9
+ - Stop writing `.dsh-geo/dashboard.json`. It duplicated state already held in
10
+ `history/`, and nothing read it after the dashboard page left Settings.
11
+ - Drop the unused `sessions` and `remote.workspaceFiles` injections from the
12
+ client half: it no longer lists sessions or reads workspace files.
13
+
14
+ ### Features
15
+
16
+ - Add `dsh-geo trend`, which derives the score trend from `history/` instead of
17
+ a separately maintained file. Exits 4 when there is no history.
18
+
19
+
20
+ ## 0.11.0 - 2026-11-29
21
+
22
+ ### Features
23
+
24
+ - Add schema.org completeness checking: every typed entity is compared against
25
+ the properties its type actually needs (`Article` needs headline/author/
26
+ datePublished, `Product` needs name/offers, …), and the gap is named.
27
+ - Add page-type/schema matching. The inference uses observable signals only
28
+ (URL path, cart copy, FAQ entities) and is reported as a warning, never a hard
29
+ failure, because inference can be wrong.
30
+ - Add an optional WebMCP check (W3C Web Machine Learning CG draft): forms
31
+ declaring `toolname`/`tooldescription` are recognised. Plain search forms
32
+ report `skip`, not a defect.
33
+ - Rubric is now 56 checks: SEO 28, AEO 16, GEO 12.
34
+
35
+ ### Notes
36
+
37
+ - Google rich-result membership is encoded separately from schema.org
38
+ requirements, so the audit never implies a rich result it cannot verify.
39
+
40
+
3
41
  ## 0.10.0 - 2026-11-29
4
42
 
5
43
  ### Features
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
  | 会话内结果卡 | 模型调用 `geo_scan` / `geo_fix_plan` 后,对话中直接显示分数、五维、平台参考分与优先修复,不用另开页面 |
24
24
  | `geo_fix_plan`(DSH 工具) | 把最近一次(或指定的)报告变成按影响力排序的修复清单 |
25
25
  | **设置 → GEO 体检**(面板) | 修改抓取页数、robots 策略、限速、超时、体积上限、报告目录、私有目标开关 |
26
- | CLI(`dsh-geo`) | `scan` / `ci` / `mcp` / `generate-llms` / `generate-faq` / `fix-plan` / `history` / `diff` |
26
+ | CLI(`dsh-geo`) | `scan` / `ci` / `mcp` / `generate-llms` / `generate-faq` / `fix-plan` / `history` / `trend` / `diff` |
27
27
  | MCP server | `npx -y @cobola/dsh-geo mcp`,给 Cursor / Claude Code 等客户端直接调用 |
28
28
 
29
29
  报告固定在会话工作区的 `.dsh-geo/` 下;报告可能包含页面正文摘录,上传 CI artifact 前请先审阅内容:
@@ -31,7 +31,7 @@
31
31
  ```
32
32
  .dsh-geo/
33
33
  latest.json 最近一次完整产物(scan + score + diff)
34
- history/<scannedAt>.json 每次扫描一份,保留最近 50 份
34
+ history/<scannedAt>.json 每次扫描一份,保留最近 50 份(趋势也从这里读)
35
35
  report.md 给人看的体检摘要
36
36
  fix-plan.md / fix-plan.json 最新修复清单(机器可读 + Markdown)
37
37
  ```
@@ -136,6 +136,7 @@ dsh-geo fix-plan
136
136
 
137
137
  # 历史与对比
138
138
  dsh-geo history
139
+ dsh-geo trend # 最近几次扫描的分数走势
139
140
  dsh-geo diff .dsh-geo/history/<before>.json .dsh-geo/latest.json
140
141
 
141
142
  # CI:低于阈值时退出码 3
@@ -167,7 +168,7 @@ dsh-geo ci https://journal123.com \
167
168
 
168
169
  ```yaml
169
170
  - uses: actions/checkout@v4
170
- - uses: cobola/dsh-geo@v0.10.0
171
+ - uses: cobola/dsh-geo@v0.12.0
171
172
  with:
172
173
  url: https://journal123.com
173
174
  baseline: geo-baseline.json
@@ -199,7 +200,7 @@ CLI 也随 npm 包提供:`npx @cobola/dsh-geo --help`;完整参数见 `dsh-g
199
200
  | 实体与信任 | 15 | 站点身份是否可核实(HTTPS、组织实体、联系方式、安全头) |
200
201
  | 机器说明书 | 15 | llms.txt、结构化数据、OpenGraph、feed、Link 提示 |
201
202
 
202
- 45 条可审计检查,维度内按权重归一化;`pass` 计 1、`warn` 计 0.5、`fail` 计 0、`skip` 移出分母。总分是五维加权平均。完整规则、阈值与修复建议见 **[docs/RULES.md](docs/RULES.md)**(由 `lib/rules.js` 生成)。
203
+ 56 条可审计检查,维度内按权重归一化;`pass` 计 1、`warn` 计 0.5、`fail` 计 0、`skip` 移出分母。总分是五维加权平均。完整规则、阈值与修复建议见 **[docs/RULES.md](docs/RULES.md)**(由 `lib/rules.js` 生成)。
203
204
 
204
205
  ### 内容生成器(可选)
205
206
 
@@ -252,7 +253,7 @@ fixture 基线(参考时间 `2026-06-15T00:00:00Z`,由测试锁定):
252
253
  - **只读原始 HTML**:不执行 JavaScript,这是与检索管线对齐的设计;它不测渲染后的 DOM、Core Web Vitals、搜索排名、流量或真实 AI 引用。
253
254
  - **不自动改代码**:`geo_fix_plan` 只产出清单;修改由 agent 或人完成,再用 `geo_scan` 验证。
254
255
  - **评规则不是真理**:分数用于同站点纵向对比,不适合跨站点绝对排名。规则可审计、可改,带版本号 `geo-rubric@1`。
255
- - **面板只编辑默认值**:扫描结果出现在对话卡片中;趋势与历史通过 `.dsh-geo/`、CLI 或 `dsh-geo history` 查看,尚未做图标趋势图。
256
+ - **面板只编辑默认值**:扫描结果出现在对话卡片中;趋势用 `dsh-geo trend` 查看(纯文本,不含图表)。
256
257
  - **npm 上仅发布命令行与库**:作为 DSH 插件仍建议本地目录链接安装,确保读到当前 checkout。
257
258
 
258
259
  ## 开发与发布
@@ -275,6 +276,8 @@ lib/html.js 无依赖 HTML 解析与事实抽取
275
276
  lib/scan.js 抓取流程
276
277
  lib/rules.js 45 条 Core 规则(唯一事实源)
277
278
  lib/platforms/ 平台 profile(Bing、百度、OpenAI、Perplexity 已实现)
279
+ lib/schema.js schema.org 字段完整性、页面类型匹配
280
+ lib/generate.js llms.txt 与 FAQ JSON-LD 生成器
278
281
  lib/ci.js CI 审计、基线与质量门禁
279
282
  lib/mcp.js stdio MCP server(零依赖手写 JSON-RPC)
280
283
  bin/dsh-geo-mcp.js MCP 二进制入口
package/bin/dsh-geo.js CHANGED
@@ -16,7 +16,7 @@ import path from 'node:path';
16
16
  import { auditSite, persistAudit, planFromReport } from '../lib/audit.js';
17
17
  import { runCi } from '../lib/ci.js';
18
18
  import { diffReports } from '../lib/report.js';
19
- import { listAudits, resolveStoreDir } from '../lib/store.js';
19
+ import { listAudits, readTrend, resolveStoreDir } from '../lib/store.js';
20
20
 
21
21
  const require = createRequire(import.meta.url);
22
22
  const { version } = require('../package.json');
@@ -31,6 +31,7 @@ Usage:
31
31
  dsh-geo generate-faq <url> [--out <path>]
32
32
  dsh-geo fix-plan [options]
33
33
  dsh-geo history [options]
34
+ dsh-geo trend [options] Recent score trend from saved audits.
34
35
  dsh-geo diff <before.json> <after.json> [--json]
35
36
  dsh-geo --help | --version
36
37
 
@@ -78,6 +79,11 @@ fix-plan options:
78
79
  --report <path> Use a specific report instead of .dsh-geo/latest.json.
79
80
  --json Print the plan payload as JSON.
80
81
 
82
+ trend options:
83
+ --dir <path> Report directory (default .dsh-geo).
84
+ --limit <n> Entries to include (default 12).
85
+ --json Print trend entries as JSON.
86
+
81
87
  history options:
82
88
  --dir <path> Report directory (default .dsh-geo).
83
89
  --limit <n> Entries to show (default 10).
@@ -474,6 +480,35 @@ async function commandGenerate(positionals, options) {
474
480
  return 0;
475
481
  }
476
482
 
483
+ async function commandTrend(positionals, options) {
484
+ if (positionals.length > 0) throw new Error(`Unexpected argument: ${positionals[0]}`);
485
+ const cwd = process.cwd();
486
+ const storeDir = resolveStoreDir(cwd, options.dir);
487
+ const entries = await readTrend(storeDir, options.limit);
488
+ if (options.json) {
489
+ process.stdout.write(`${JSON.stringify(entries, null, 2)}\n`);
490
+ return entries.length === 0 ? 4 : 0;
491
+ }
492
+ if (entries.length === 0) {
493
+ process.stdout.write(`No saved audits in ${path.relative(cwd, storeDir)}/history\n`);
494
+ return 4;
495
+ }
496
+ const lines = [`最近 ${entries.length} 次扫描:`, ''];
497
+ for (const entry of entries) {
498
+ const when = (entry.scannedAt ?? '').slice(0, 10);
499
+ lines.push(`${when} ${String(entry.total).padStart(5)} ${entry.grade} ${bar(entry.total)}`);
500
+ }
501
+ const first = entries[0];
502
+ const last = entries[entries.length - 1];
503
+ if (entries.length > 1) {
504
+ const delta = Math.round((last.total - first.total) * 10) / 10;
505
+ lines.push('');
506
+ lines.push(`合计变化:${first.total} → ${last.total}(${delta > 0 ? '+' : ''}${delta})`);
507
+ }
508
+ process.stdout.write(`${lines.join('\n')}\n`);
509
+ return 0;
510
+ }
511
+
477
512
  const COMMANDS = {
478
513
  scan: commandScan,
479
514
  ci: commandCi,
@@ -482,6 +517,7 @@ const COMMANDS = {
482
517
  'generate-faq': (pos, opts) => commandGenerate(pos, { ...opts, generateKind: 'faq' }),
483
518
  'fix-plan': commandFixPlan,
484
519
  history: commandHistory,
520
+ trend: commandTrend,
485
521
  diff: commandDiff,
486
522
  };
487
523
 
package/client.js CHANGED
@@ -526,7 +526,7 @@ window.__ModuleLoader__.load({
526
526
  }
527
527
 
528
528
  return {
529
- inject: ['slots', 'locale', 'remote', 'remote.settings', 'sessions', 'remote.workspaceFiles'],
529
+ inject: ['slots', 'locale', 'remote', 'remote.settings'],
530
530
  apply(ctx) {
531
531
  ctx.effect(() => ctx.locale.register(NS, DICT), 'dsh-geo: settings dictionaries');
532
532
  const t = ctx.locale.bind(NS);
package/docs/CI.md CHANGED
@@ -123,7 +123,7 @@ on:
123
123
 
124
124
  ```yaml
125
125
  - uses: actions/checkout@v4
126
- - uses: cobola/dsh-geo@v0.10.0
126
+ - uses: cobola/dsh-geo@v0.12.0
127
127
  with:
128
128
  url: https://journal123.com
129
129
  baseline: geo-baseline.json
package/docs/GOOGLE.md CHANGED
@@ -38,7 +38,7 @@ Google 指南的关键是:**Google Search 能抓取并索引公开内容**。
38
38
 
39
39
  ## 当前仍不是 Google Search Console 数据
40
40
 
41
- 截图类效果面板(总分趋势、五维变化、修复/回归)读取本地 `.dsh-geo/dashboard.json`,它展示的是**站点结构体检历史**,不是:
41
+ `dsh-geo trend` 与 `dsh-geo diff` 读取本地 `.dsh-geo/history/`,展示的是**站点结构体检历史**,不是:
42
42
 
43
43
  - GSC clicks/impressions;
44
44
  - AI Overviews / AI Mode 的真实曝光;
package/docs/RULES.md CHANGED
@@ -1,4 +1,4 @@
1
- # GEO 评分规则(geo-rubric@2)
1
+ # GEO 评分规则(geo-rubric@3)
2
2
 
3
3
  本文件由 `scripts/gen-docs.mjs` 从 `lib/rules.js` 生成,请勿手工编辑。改规则后运行 `npm run docs`。
4
4
 
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## 2. 规则表
16
16
 
17
- 共 53 条规则,分归三个支柱:SEO 26 条、AEO 16 条、GEO 11 条。支柱是同一批规则的第二个视图,不改变 Core 总分。每条规则的通过条件、证据格式与失败阈值都在 `lib/rules.js` 的 `evaluate()` 中,运行时会把证据写进报告(`findings[].evidence`),因此报告本身就能说明为什么得分。
17
+ 共 56 条规则,分归三个支柱:SEO 28 条、AEO 16 条、GEO 12 条。支柱是同一批规则的第二个视图,不改变 Core 总分。每条规则的通过条件、证据格式与失败阈值都在 `lib/rules.js` 的 `evaluate()` 中,运行时会把证据写进报告(`findings[].evidence`),因此报告本身就能说明为什么得分。
18
18
 
19
19
  ### 可发现性(25 分)
20
20
 
@@ -52,6 +52,8 @@
52
52
  | `seo.viewport` | SEO | 2 | 移动端视口声明 | 在 <head> 输出 <meta name="viewport" content="width=device-width, initial-scale=1">;缺少它会让移动端按桌面宽度渲染。 |
53
53
  | `seo.image-dimensions` | SEO | 2 | 图片声明宽高 | 为 <img> 写上 width/height 或使用 aspect-ratio,避免加载时布局跳动(CLS)。 |
54
54
  | `seo.image-lazy` | SEO | 1 | 首屏外图片懒加载 | 给首屏以下的图片加 loading="lazy",首屏图不要加,避免延迟最大内容渲染。 |
55
+ | `seo.schema-fields` | SEO | 3 | 结构化数据字段完整 | 按 schema.org 定义补齐必备属性:Article 要 headline/author/datePublished,Product 要 name 与 offers,Organization 要 name 与 url。 |
56
+ | `seo.schema-matches-page-type` | SEO | 2 | 页面类型与结构化数据匹配 | 内容页输出 Article/BlogPosting,商品页输出 Product,问答页输出 FAQPage;类型与内容不符会被忽略。 |
55
57
 
56
58
  ### 可引用性(25 分)
57
59
 
@@ -86,6 +88,7 @@
86
88
 
87
89
  | 规则 ID | 支柱 | 权重 | 检查项 | 修复建议 |
88
90
  |---|---|---|---|---|
91
+ | `geo.agent-tools` | GEO | 2 | 可选:WebMCP agent 工具声明 | 可选能力:若希望 agent 直接调用站内功能,给 <form> 加 toolname/tooldescription(W3C WebMCP 草案);普通内容站不需要。 |
89
92
  | `manifest.llms-txt` | GEO | 2 | llms.txt(可选,非 Google 必需) | 可选:若需要服务非 Google 的 agent/工具,可发布 llms.txt(# 标题 + ## 分节 + Markdown 链接)。Google Search 明确不使用 llms.txt,不要把它当作 Google 排名手段。 |
90
93
  | `manifest.llms-structure` | GEO | 1 | llms.txt 结构完整(可选) | 若提供 llms.txt,至少包含 2 个 ## 分节和 3 个指向正文的 Markdown 链接。注意:Google Search 不使用该文件。 |
91
94
  | `manifest.structured-breadth` | GEO | 2 | schema.org 类型覆盖面(富结果) | 按页面类型输出 schema(Organization/WebSite、Article、FAQPage、BreadcrumbList),用于富结果与实体消歧。Google 明确表示生成式 AI 不需要特殊 schema。 |
package/docs/index.json CHANGED
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "versions": [
29
29
  {
30
- "version": "0.10.0",
30
+ "version": "0.12.0",
31
31
  "source": {
32
32
  "type": "npm"
33
33
  },
@@ -23,7 +23,7 @@ jobs:
23
23
  - uses: actions/checkout@v4
24
24
 
25
25
  - name: Audit and compare against the committed baseline
26
- uses: cobola/dsh-geo@v0.10.0
26
+ uses: cobola/dsh-geo@v0.12.0
27
27
  with:
28
28
  url: https://journal123.com
29
29
  baseline: geo-baseline.json
@@ -15,7 +15,7 @@ jobs:
15
15
  - uses: actions/checkout@v4
16
16
 
17
17
  - name: Audit and write a baseline
18
- uses: cobola/dsh-geo@v0.10.0
18
+ uses: cobola/dsh-geo@v0.12.0
19
19
  with:
20
20
  url: https://journal123.com
21
21
  now: 2026-11-29T00:00:00Z
package/lib/html.js CHANGED
@@ -540,6 +540,13 @@ export function analyzeHtml(html, pageUrl) {
540
540
  .filter((link) => link.rel.includes('alternate') && Boolean(link.hreflang))
541
541
  .map((link) => link.hreflang);
542
542
 
543
+ const webmcpForms = nodes
544
+ .filter((node) => node.tag === 'form')
545
+ .map((node) => ({
546
+ toolname: attribute(node, 'toolname'),
547
+ tooldescription: attribute(node, 'tooldescription'),
548
+ }));
549
+
543
550
  const times = [];
544
551
  for (const node of nodes) {
545
552
  if (node.tag !== 'time') continue;
@@ -661,6 +668,8 @@ export function analyzeHtml(html, pageUrl) {
661
668
  jsonLdTypes: [...new Set(jsonLd.flatMap((block) => block.types))].sort(),
662
669
  jsonLdValid: jsonLd.length > 0 && jsonLd.every((block) => block.ok),
663
670
  orgEntities,
671
+ jsonLdEntities,
672
+ webmcpForms,
664
673
  articleEntities,
665
674
  faqEntities,
666
675
  sameAs: [...new Set(sameAs)],
package/lib/rules.js CHANGED
@@ -12,7 +12,9 @@
12
12
  * - skip: excluded from the denominator (not applicable)
13
13
  */
14
14
 
15
- export const RUBRIC_VERSION = 'geo-rubric@2';
15
+ import { checkPageTypeSchema, checkSchemaCompleteness } from './schema.js';
16
+
17
+ export const RUBRIC_VERSION = 'geo-rubric@3';
16
18
 
17
19
  /**
18
20
  * The three optimisation pillars industry tools report separately.
@@ -1053,6 +1055,61 @@ export const RULES = [
1053
1055
  },
1054
1056
  },
1055
1057
 
1058
+ {
1059
+ id: 'seo.schema-fields',
1060
+ pillar: 'seo',
1061
+ dimension: 'parsability',
1062
+ weight: 3,
1063
+ title: '结构化数据字段完整',
1064
+ fix: '按 schema.org 定义补齐必备属性:Article 要 headline/author/datePublished,Product 要 name 与 offers,Organization 要 name 与 url。',
1065
+ evaluate({ factsPages }) {
1066
+ const result = checkSchemaCompleteness(factsPages);
1067
+ if (result.summary.total === 0) return skip('页面没有带 @type 的结构化数据');
1068
+ const broken = result.entities.filter((entity) => entity.missingRequired.length > 0);
1069
+ if (broken.length === 0) {
1070
+ return pass(`${result.summary.total} 个实体必备字段齐全`);
1071
+ }
1072
+ const examples = broken.slice(0, 3).map((entity) => `${entity.type} 缺 ${entity.missingRequired.join('/')}`);
1073
+ const evidence = `${broken.length}/${result.summary.total} 个实体缺必备字段:${examples.join(';')}`;
1074
+ return broken.length === result.summary.total ? fail(evidence) : warn(evidence);
1075
+ },
1076
+ },
1077
+ {
1078
+ id: 'seo.schema-matches-page-type',
1079
+ pillar: 'seo',
1080
+ dimension: 'parsability',
1081
+ weight: 2,
1082
+ title: '页面类型与结构化数据匹配',
1083
+ fix: '内容页输出 Article/BlogPosting,商品页输出 Product,问答页输出 FAQPage;类型与内容不符会被忽略。',
1084
+ evaluate({ scan, factsPages }) {
1085
+ const signals = checkPageTypeSchema(scan, factsPages);
1086
+ if (signals.length === 0) return skip('未能从 URL 或内容推断页面类型');
1087
+ const missing = signals.filter((signal) => !signal.present);
1088
+ if (missing.length === 0) {
1089
+ return pass(signals.map((signal) => `${signal.pageType}✓`).join(' '));
1090
+ }
1091
+ // Inference, not proof: report as partial rather than a hard failure.
1092
+ return warn(`疑似 ${missing.map((signal) => signal.pageType).join('/')} 页缺少对应类型(${missing.map((signal) => signal.expected.join(' 或 ')).join(';')})`);
1093
+ },
1094
+ },
1095
+ {
1096
+ id: 'geo.agent-tools',
1097
+ pillar: 'geo',
1098
+ dimension: 'manifest',
1099
+ weight: 2,
1100
+ title: '可选:WebMCP agent 工具声明',
1101
+ fix: '可选能力:若希望 agent 直接调用站内功能,给 <form> 加 toolname/tooldescription(W3C WebMCP 草案);普通内容站不需要。',
1102
+ evaluate({ factsPages }) {
1103
+ const forms = factsPages.flatMap((page) => page.facts.webmcpForms ?? []);
1104
+ if (forms.length === 0) return skip('页面没有表单,也没有 WebMCP 声明;这是可选能力');
1105
+ const named = forms.filter((form) => form.toolname && form.tooldescription);
1106
+ if (named.length > 0 && named.length === forms.length) return pass(`${named.length} 个表单已声明 WebMCP 工具`);
1107
+ if (named.length > 0) return warn(`${forms.length} 个表单中 ${forms.length - named.length} 个缺少 toolname 或 tooldescription`);
1108
+ // Plain search/filter forms are not agent tools; absence is not a defect.
1109
+ return skip(`${forms.length} 个普通表单未声明 WebMCP;这是可选能力,内容站不需要`);
1110
+ },
1111
+ },
1112
+
1056
1113
  // ---------------------------------------------------------------- 机器说明书
1057
1114
  {
1058
1115
  id: 'manifest.llms-txt',
package/lib/schema.js ADDED
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Schema.org completeness: does a declared type carry the properties a
3
+ * consumer actually needs?
4
+ *
5
+ * Two different standards apply, and conflating them is a common mistake:
6
+ *
7
+ * - **Required for Google rich results.** Google's structured-data
8
+ * documentation lists required and recommended properties per feature, and
9
+ * only those produce rich results. A type Google does not consume at all
10
+ * (or no longer consumes) earns nothing regardless of completeness.
11
+ * - **Required for the type to be meaningful.** schema.org itself defines few
12
+ * hard requirements, but a `Product` without an offer, or an `Article`
13
+ * without a headline, does not describe what it claims to describe.
14
+ *
15
+ * This module only encodes the second kind plus the fields Google publishes as
16
+ * required, and it labels which is which. It never claims a rich-result outcome.
17
+ *
18
+ * Source: https://schema.org/docs/full.html and the per-feature pages under
19
+ * https://developers.google.com/search/docs/appearance/structured-data
20
+ */
21
+ export const SCHEMA_REQUIREMENTS = {
22
+ Article: { required: ['headline', 'author', 'datePublished'], recommended: ['dateModified', 'image', 'publisher'] },
23
+ NewsArticle: { required: ['headline', 'author', 'datePublished'], recommended: ['dateModified', 'image', 'publisher'] },
24
+ BlogPosting: { required: ['headline', 'author', 'datePublished'], recommended: ['dateModified', 'image'] },
25
+ TechArticle: { required: ['headline', 'author', 'datePublished'], recommended: ['dateModified', 'image'] },
26
+ Product: { required: ['name'], recommended: ['offers', 'image', 'brand', 'sku', 'aggregateRating'] },
27
+ Offer: { required: ['price', 'priceCurrency'], recommended: ['availability', 'url', 'priceValidUntil'] },
28
+ Organization: { required: ['name'], recommended: ['url', 'logo', 'sameAs', 'contactPoint'] },
29
+ Person: { required: ['name'], recommended: ['url', 'sameAs', 'jobTitle'] },
30
+ WebSite: { required: ['name', 'url'], recommended: ['potentialAction', 'description'] },
31
+ WebPage: { required: ['name'], recommended: ['url', 'description', 'dateModified'] },
32
+ BreadcrumbList: { required: ['itemListElement'], recommended: [] },
33
+ FAQPage: { required: ['mainEntity'], recommended: [] },
34
+ Question: { required: ['name', 'acceptedAnswer'], recommended: [] },
35
+ HowTo: { required: ['name', 'step'], recommended: ['image', 'totalTime'] },
36
+ Event: { required: ['name', 'startDate', 'location'], recommended: ['endDate', 'image', 'offers'] },
37
+ Recipe: { required: ['name', 'recipeIngredient', 'recipeInstructions'], recommended: ['image', 'author'] },
38
+ VideoObject: { required: ['name', 'thumbnailUrl', 'uploadDate'], recommended: ['description', 'duration', 'contentUrl'] },
39
+ LocalBusiness: { required: ['name', 'address'], recommended: ['telephone', 'openingHours', 'priceRange'] },
40
+ ItemList: { required: ['itemListElement'], recommended: ['name'] },
41
+ Course: { required: ['name', 'description'], recommended: ['provider'] },
42
+ JobPosting: { required: ['title', 'description', 'datePosted', 'hiringOrganization'], recommended: ['jobLocation', 'baseSalary'] },
43
+ };
44
+
45
+ /** Types Google states it consumes for rich results, with the caveat that most
46
+ * require per-feature checks this audit does not perform. */
47
+ export const GOOGLE_RICH_RESULT_TYPES = new Set([
48
+ 'Article', 'NewsArticle', 'BlogPosting', 'Product', 'Offer', 'BreadcrumbList',
49
+ 'Event', 'Recipe', 'VideoObject', 'LocalBusiness', 'JobPosting', 'Course',
50
+ 'FAQPage', 'HowTo', 'Question', 'ItemList', 'Person', 'Organization', 'WebSite',
51
+ ]);
52
+
53
+ function hasProperty(entity, property) {
54
+ const value = entity[property];
55
+ if (value === undefined || value === null) return false;
56
+ if (typeof value === 'string') return value.trim().length > 0;
57
+ if (Array.isArray(value)) return value.length > 0;
58
+ if (typeof value === 'object') return Object.keys(value).length > 0;
59
+ return true;
60
+ }
61
+
62
+ function typesOf(entity) {
63
+ const type = entity?.['@type'];
64
+ if (typeof type === 'string') return [type];
65
+ if (Array.isArray(type)) return type.filter((entry) => typeof entry === 'string');
66
+ return [];
67
+ }
68
+
69
+ /**
70
+ * Check every typed entity on the crawled pages against its requirements.
71
+ *
72
+ * @param {object[]} factsPages - Pages carrying facts.
73
+ * @returns {{entities: Array<object>, summary: object, unknownTypes: string[]}}
74
+ */
75
+ export function checkSchemaCompleteness(factsPages) {
76
+ const entities = [];
77
+ const unknownTypes = new Set();
78
+
79
+ for (const page of factsPages) {
80
+ for (const entity of page.facts.jsonLdEntities ?? []) {
81
+ for (const type of typesOf(entity)) {
82
+ const rule = SCHEMA_REQUIREMENTS[type];
83
+ if (!rule) {
84
+ unknownTypes.add(type);
85
+ continue;
86
+ }
87
+ const missingRequired = rule.required.filter((property) => !hasProperty(entity, property));
88
+ const missingRecommended = rule.recommended.filter((property) => !hasProperty(entity, property));
89
+ entities.push({
90
+ page: page.path,
91
+ type,
92
+ missingRequired,
93
+ missingRecommended,
94
+ googleRichResultType: GOOGLE_RICH_RESULT_TYPES.has(type),
95
+ });
96
+ }
97
+ }
98
+ }
99
+
100
+ const complete = entities.filter((entity) => entity.missingRequired.length === 0);
101
+ return {
102
+ entities,
103
+ summary: {
104
+ total: entities.length,
105
+ complete: complete.length,
106
+ incomplete: entities.length - complete.length,
107
+ },
108
+ unknownTypes: [...unknownTypes].sort(),
109
+ };
110
+ }
111
+
112
+ /**
113
+ * Whether the site is a page type that expects a matching schema type.
114
+ *
115
+ * This is inference from observable signals, and the caller must present it as
116
+ * such: a site can be a product page without looking like one.
117
+ *
118
+ * @param {object} scan
119
+ * @param {object[]} factsPages
120
+ */
121
+ export function checkPageTypeSchema(scan, factsPages) {
122
+ const present = new Set(factsPages.flatMap((page) => page.facts.jsonLdTypes ?? []));
123
+ const path = scan.startUrl ? new URL(scan.startUrl).pathname : '/';
124
+ const primary = factsPages.find((page) => page.depth === 0) ?? factsPages[0];
125
+ const text = primary?.facts?.text ?? '';
126
+ const signals = [];
127
+
128
+ if (/(?:^|\/)(?:product|products|item|shop|p)\//i.test(path) || /\b(?:add to cart|buy now|price)\b/i.test(text)) {
129
+ signals.push({ pageType: 'product', expected: ['Product'], present: present.has('Product') });
130
+ }
131
+ if (/(?:^|\/)(?:blog|article|news|post|posts)\//i.test(path) || (primary?.facts?.articleEntities?.length ?? 0) > 0) {
132
+ signals.push({ pageType: 'article', expected: ['Article', 'NewsArticle', 'BlogPosting'], present: ['Article', 'NewsArticle', 'BlogPosting'].some((type) => present.has(type)) });
133
+ }
134
+ if ((primary?.facts?.faqEntities?.length ?? 0) > 0 || (primary?.facts?.questionHeadings?.length ?? 0) >= 3) {
135
+ signals.push({ pageType: 'faq', expected: ['FAQPage'], present: present.has('FAQPage') });
136
+ }
137
+ if (/\b(?:opening hours|visit us|our address|directions)\b/i.test(text)) {
138
+ signals.push({ pageType: 'local-business', expected: ['LocalBusiness'], present: present.has('LocalBusiness') });
139
+ }
140
+ return signals;
141
+ }
package/lib/store.js CHANGED
@@ -17,7 +17,6 @@ import { REPORT_FORMAT_VERSION, renderAuditMarkdown } from './report.js';
17
17
  export const STORE_DIRNAME = '.dsh-geo';
18
18
  export const FORMAT_VERSION = REPORT_FORMAT_VERSION;
19
19
  export const HISTORY_LIMIT = 50;
20
- export const DASHBOARD_TREND_LIMIT = 24;
21
20
 
22
21
  /**
23
22
  * Resolve the configured report directory, refusing anything outside `.dsh-geo/`.
@@ -110,97 +109,13 @@ export async function writeAudit(storeDir, { scan, report, diff = null, previous
110
109
  const latestPath = path.join(storeDir, 'latest.json');
111
110
  const historyPath = path.join(historyDir, historyName(scan.scannedAt));
112
111
  const reportPath = path.join(storeDir, 'report.md');
113
- const dashboardPath = path.join(storeDir, 'dashboard.json');
114
112
 
115
113
  await writeJsonAtomic(latestPath, payload);
116
114
  await writeJsonAtomic(historyPath, payload);
117
115
  await writeFileAtomic(reportPath, renderAuditMarkdown(report, { scan, diff }));
118
116
  await pruneHistory(historyDir);
119
117
 
120
- const previousDashboard = await readDashboard(storeDir);
121
- const dashboard = buildDashboard(scan, report, diff, previousDashboard);
122
- await writeJsonAtomic(dashboardPath, dashboard);
123
-
124
- return { latestPath, historyPath, reportPath, dashboardPath };
125
- }
126
-
127
- function dimensionSummary(dimensions) {
128
- return dimensions.map((dimension) => ({
129
- id: dimension.id,
130
- title: dimension.title,
131
- weight: dimension.weight,
132
- score: dimension.score,
133
- scored: dimension.scored !== false,
134
- }));
135
- }
136
-
137
- function buildDashboard(scan, report, diff, previousDashboard) {
138
- const priorTrend = Array.isArray(previousDashboard?.trend) ? previousDashboard.trend : [];
139
- const trend = [...priorTrend, {
140
- scannedAt: scan.scannedAt,
141
- total: report.total,
142
- grade: report.grade,
143
- url: scan.startUrl,
144
- }]
145
- .filter((entry) => entry && typeof entry.total === 'number' && entry.scannedAt)
146
- .slice(-DASHBOARD_TREND_LIMIT);
147
-
148
- return {
149
- formatVersion: FORMAT_VERSION,
150
- generatedAt: scan.scannedAt,
151
- url: scan.startUrl,
152
- origin: scan.origin,
153
- current: {
154
- total: report.total,
155
- grade: report.grade,
156
- gradeLabel: report.gradeLabel,
157
- counts: report.counts,
158
- dimensions: dimensionSummary(report.dimensions),
159
- platforms: (report.platforms ?? []).map((platform) => ({
160
- id: platform.id,
161
- title: platform.title,
162
- total: platform.total,
163
- counts: platform.counts,
164
- })),
165
- },
166
- previous: diff
167
- ? {
168
- scannedAt: diff.previous.scannedAt,
169
- total: diff.previous.total,
170
- grade: diff.previous.grade,
171
- dimensions: diff.dimensions.map((dimension) => ({
172
- id: dimension.id,
173
- before: dimension.before,
174
- after: dimension.after,
175
- delta: dimension.delta,
176
- })),
177
- }
178
- : null,
179
- delta: diff
180
- ? {
181
- total: diff.total.delta,
182
- fixed: diff.fixed.map((entry) => entry.ruleId),
183
- regressed: diff.regressed.map((entry) => entry.ruleId),
184
- stillFailing: diff.counts.stillFailing,
185
- dimensions: diff.dimensions,
186
- }
187
- : null,
188
- trend,
189
- actions: report.actions.slice(0, 5).map((action) => ({
190
- ruleId: action.ruleId,
191
- dimensionTitle: action.dimensionTitle,
192
- title: action.title,
193
- status: action.status,
194
- weight: action.weight,
195
- evidence: action.evidence,
196
- fix: action.fix,
197
- })),
198
- };
199
- }
200
-
201
- /** Read the latest dashboard payload, or null. */
202
- export async function readDashboard(storeDir) {
203
- return readJson(path.join(storeDir, 'dashboard.json'));
118
+ return { latestPath, historyPath, reportPath };
204
119
  }
205
120
 
206
121
  async function pruneHistory(historyDir) {
@@ -242,6 +157,29 @@ export async function listAudits(storeDir, limit = 20) {
242
157
  return entries;
243
158
  }
244
159
 
160
+ /**
161
+ * Score trend across saved audits, oldest first.
162
+ *
163
+ * History files already hold every score, so a separate trend file would be a
164
+ * second copy of the same state that can drift or go stale.
165
+ *
166
+ * @param {string} storeDir
167
+ * @param {number} [limit] - Most recent entries to include.
168
+ * @returns {Promise<Array<{scannedAt: string|null, total: number, grade: string, url: string|null}>>}
169
+ */
170
+ export async function readTrend(storeDir, limit = 24) {
171
+ const entries = await listAudits(storeDir, limit);
172
+ return entries
173
+ .slice()
174
+ .reverse()
175
+ .map((entry) => ({
176
+ scannedAt: entry.savedAt,
177
+ total: entry.total,
178
+ grade: entry.grade,
179
+ url: entry.url,
180
+ }));
181
+ }
182
+
245
183
  /**
246
184
  * Read one audit payload file.
247
185
  * @param {string} file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobola/dsh-geo",
3
- "version": "0.10.0",
3
+ "version": "0.12.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": {
package/lib/profiles.js DELETED
@@ -1,62 +0,0 @@
1
- /**
2
- * Platform evidence registry. Profiles are metadata and source boundaries, not
3
- * extra score weight. A profile may later add platform-specific checks without
4
- * contaminating the Core score.
5
- */
6
- export const PLATFORM_PROFILES = Object.freeze({
7
- core: Object.freeze({
8
- id: 'core', title: '跨平台基础', maturity: 'implemented',
9
- sources: [],
10
- scope: 'crawlability, indexability, page structure, duplicate URLs, entity clarity',
11
- }),
12
- google: Object.freeze({
13
- id: 'google', title: 'Google Search / AI features', maturity: 'implemented',
14
- sources: ['https://developers.google.com/search/docs/fundamentals/ai-optimization-guide'],
15
- scope: 'Googlebot access, Search technical requirements, people-first content, Google-specific controls',
16
- }),
17
- bing: Object.freeze({
18
- id: 'bing', title: 'Bing / Copilot', maturity: 'source-mapped',
19
- sources: [
20
- 'https://www.bing.com/webmasters/help/webmaster-guidelines-30fba23a',
21
- 'https://www.bing.com/webmasters/help/robots-meta-tags-and-attributes-that-bing-supports-5198d240',
22
- 'https://www.bing.com/indexnow',
23
- ],
24
- scope: 'Bingbot, Copilot grounding, data-nosnippet, AI controls, IndexNow',
25
- }),
26
- baidu: Object.freeze({
27
- id: 'baidu', title: '百度搜索', maturity: 'source-mapped',
28
- sources: [
29
- 'https://ziyuan.baidu.com/college/articleinfo?id=193undefinedpage%3D1&page=6',
30
- 'https://ziyuan.baidu.com/college/courseinfo?id=1399',
31
- ],
32
- scope: 'Baiduspider, 百度搜索资源平台, sitemap/submission, Chinese search crawlability',
33
- limitation: '百度 AI 引用选择标准没有完整公开;不把推测当作规则。',
34
- }),
35
- openai: Object.freeze({
36
- id: 'openai', title: 'OpenAI Search', maturity: 'source-mapped',
37
- sources: ['https://developers.openai.com/api/docs/bots'],
38
- scope: 'OAI-SearchBot vs GPTBot access controls',
39
- limitation: '不推导未公开的 ChatGPT 引用排序公式。',
40
- }),
41
- perplexity: Object.freeze({
42
- id: 'perplexity', title: 'Perplexity', maturity: 'source-mapped',
43
- sources: ['https://docs.perplexity.ai/docs/resources/perplexity-crawlers'],
44
- scope: 'Perplexity crawler identity, robots and fetchability',
45
- limitation: '不推导未公开的引用排序公式。',
46
- }),
47
- });
48
-
49
- export function listProfiles() {
50
- return Object.values(PLATFORM_PROFILES).map((profile) => ({
51
- id: profile.id,
52
- title: profile.title,
53
- maturity: profile.maturity,
54
- scope: profile.scope,
55
- sources: [...profile.sources],
56
- ...(profile.limitation ? { limitation: profile.limitation } : {}),
57
- }));
58
- }
59
-
60
- export function profileById(id) {
61
- return PLATFORM_PROFILES[id] ?? null;
62
- }