@cobola/dsh-geo 0.4.0 → 0.5.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 - 2026-11-29
4
+
5
+ ### Features
6
+
7
+ - Add the Baidu Search platform profile: Baiduspider and Baiduspider-render
8
+ reachability, robots.txt encoding, XML sitemap presence and root placement,
9
+ crawl stability, server-rendered body content, TDK completeness and mobile
10
+ viewport. Baidu has not published how 文心一言 or 百度 AI 搜索 choose cited
11
+ pages, so the profile states that limitation and never claims to model it.
12
+ - Platform profiles now carry their `limitation` text into the report payload.
13
+
14
+
3
15
  ## 0.4.0 - 2026-11-29
4
16
 
5
17
  ### Changed
package/README.md CHANGED
@@ -164,7 +164,7 @@ CLI 也随 npm 包提供:`npx @cobola/dsh-geo --help`;完整参数见 `dsh-g
164
164
  |---|---|---|
165
165
  | Google | 已实现(作为 Core 的规范边界) | Googlebot、Search 技术要求、Google 明确不需要的 GEO 手段 |
166
166
  | Bing / Copilot | 已实现 | Bingbot / BingPreview 可达性、页面级 bingbot 指令、sitemap、站长验证、`data-nosnippet` |
167
- | 百度 | 规划中 | Baiduspider、资源平台、sitemap 与提交;百度 AI 引用标准未公开 |
167
+ | 百度 | 已实现 | Baiduspider 与 Baiduspider-render 可达性、robots 编码、sitemap 与根目录位置、抓取稳定性、正文直出、TDK、移动端视口;百度 AI 引用标准未公开 |
168
168
  | OpenAI / Perplexity | 规划中 | crawler 与 robots 控制检查 |
169
169
 
170
170
  平台分在报告、CLI 与看板中单独显示,**从不计入 Core 总分**,也不代表任何平台的排名或引用结果。规则与官方来源见 [docs/PROFILES.md](docs/PROFILES.md),Google 边界见 [docs/GOOGLE.md](docs/GOOGLE.md)。
package/docs/PROFILES.md CHANGED
@@ -27,7 +27,7 @@ profile 是证据和检查边界,**不改变 Core 总分**。平台分数在
27
27
  | Core | implemented | — | 通用抓取、索引、结构、实体 |
28
28
  | Google | implemented | [Google AI Search guide](https://developers.google.com/search/docs/fundamentals/ai-optimization-guide) | Googlebot、Search 技术要求、Google 不需要的 GEO hacks 边界 |
29
29
  | Bing | implemented (v0.3.0) | [Bing Webmaster Guidelines](https://www.bing.com/webmasters/help/webmaster-guidelines-30fba23a)、[robots meta](https://www.bing.com/webmasters/help/robots-meta-tags-and-attributes-that-bing-supports-5198d240)、[Sitemaps in AI search](https://blogs.bing.com/webmaster/July-2025/Keep-Content-Discoverable-with-Sitemaps-in-AI-Powered-Search) | Bingbot / BingPreview 可达性、页面级 bingbot 指令、sitemap、站长验证标识、data-nosnippet |
30
- | Baidu | source-mapped | [百度 SEO 指南](https://ziyuan.baidu.com/college/articleinfo?id=193undefinedpage%3D1&page=6)、[抓取友好](https://ziyuan.baidu.com/college/courseinfo?id=1399) | Baiduspider、资源平台、sitemap/提交;百度 AI 引用未公开 |
30
+ | Baidu | implemented (v0.5.0) | [百度搜索引擎优化指南 2.0](https://ziyuan.baidu.com/college/articleinfo?id=193)、[移动搜索建站白皮书](https://ziyuan.baidu.com/college/articleinfo?id=2315)、[资源平台提交说明](https://ziyuan.baidu.com/college/videoinfo?id=3159) | Baiduspider、robots 编码、sitemap 与根目录、抓取稳定性、正文直出、TDK、移动端视口 |
31
31
  | OpenAI | source-mapped | [OpenAI crawlers](https://developers.openai.com/api/docs/bots) | OAI-SearchBot 与 GPTBot 分离控制 |
32
32
  | Perplexity | source-mapped | [Perplexity crawlers](https://docs.perplexity.ai/docs/resources/perplexity-crawlers) | crawler 身份、robots 与抓取可达性 |
33
33
 
@@ -43,9 +43,26 @@ profile 是证据和检查边界,**不改变 Core 总分**。平台分数在
43
43
 
44
44
  源码:[lib/platforms/bing.js](../lib/platforms/bing.js)。
45
45
 
46
+ ## Baidu profile 规则(已实现)
47
+
48
+ 百度未公开文心一言 / 百度 AI 搜索选择引用来源的标准,因此 profile 只覆盖其公开的搜索抓取要求,并在 `limitation` 字段中写明这一点,报告与卡片都会显示。
49
+
50
+ | 规则 | 权重 | 检查内容 |
51
+ |---|---|---|
52
+ | `baidu.baiduspider-access` | 4 | Baiduspider 是否被 robots.txt 允许;Baiduspider-render 是否被禁 |
53
+ | `baidu.robots-ascii` | 1 | robots.txt 规则值是否含中文(注释不计) |
54
+ | `baidu.sitemap` | 2 | 是否有可提交的 XML sitemap |
55
+ | `baidu.sitemap-at-root` | 1 | sitemap 是否位于站点根目录 |
56
+ | `baidu.server-stability` | 2 | 抓取是否稳定返回 4xx 以下状态 |
57
+ | `baidu.server-rendered-content` | 2 | 正文是否直接输出,不依赖脚本 |
58
+ | `baidu.title-description` | 1 | TDK 中的标题与描述是否完整 |
59
+ | `baidu.mobile-friendly` | 1 | 是否声明 meta viewport |
60
+
61
+ 源码:[lib/platforms/baidu.js](../lib/platforms/baidu.js)。
62
+
46
63
  ## 下一步实现顺序
47
64
 
48
- 1. 实现 Baidu Search profile(Baiduspider、robots、sitemap/提交、页面直出),不声称百度 AI 引用规则已知;
49
- 2. OpenAI / Perplexity 只做 crawler 与 robots 控制检查;
50
- 3. 把 `lib/profiles.js` 的成熟度字段同步到看板,让用户看到每个平台覆盖了什么;
65
+ 1. OpenAI / Perplexity 只做 crawler 与 robots 控制检查(`OAI-SearchBot` 与 `GPTBot` 分开);
66
+ 2. 把各平台 profile 的成熟度与 `limitation` 显示到结果卡与报告中;
67
+ 3. 给 CI 加 GitHub Action,支撑“回归门禁”定位;
51
68
  4. 后续接 Search Console / Bing Webmaster / 百度平台数据时,放入独立“效果数据”模块,不混入 HTML 结构评分。
package/docs/index.json CHANGED
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "versions": [
29
29
  {
30
- "version": "0.4.0",
30
+ "version": "0.5.0",
31
31
  "source": {
32
32
  "type": "npm"
33
33
  },
package/index.js CHANGED
@@ -277,6 +277,7 @@ export function scanPresentation(value) {
277
277
  platforms: (value.platforms ?? []).map((platform) => ({
278
278
  title: platform.title,
279
279
  total: platform.total,
280
+ ...(platform.limitation ? { limitation: platform.limitation } : {}),
280
281
  })),
281
282
  actions: (value.topActions ?? []).slice(0, 3).map((action) => ({
282
283
  ruleId: action.ruleId,
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Baidu Search profile.
3
+ *
4
+ * Separate from the Core score: nothing here changes a site's Core total.
5
+ *
6
+ * Scope discipline: only what Baidu documents publicly for its search and
7
+ * webmaster platform is checked. Baidu has not published how 文心一言 / 百度 AI
8
+ * 搜索 choose which pages to cite, so no rule here claims to model that. The
9
+ * profile's `limitation` states this and the UI shows it.
10
+ *
11
+ * Sources (retrieved 2026-11-29):
12
+ * - 百度搜索引擎优化指南 2.0
13
+ * https://ziyuan.baidu.com/college/articleinfo?id=193
14
+ * - 百度移动搜索建站优化白皮书
15
+ * https://ziyuan.baidu.com/college/articleinfo?id=2315
16
+ * - 百度搜索资源平台:普通收录 / sitemap / 主动推送说明
17
+ * https://ziyuan.baidu.com/college/videoinfo?id=3159
18
+ */
19
+ export const BAIDU_PROFILE = {
20
+ id: 'baidu',
21
+ title: '百度搜索',
22
+ limitation: '百度未公开文心一言 / 百度 AI 搜索选择引用来源的标准,本 profile 只检查其公开的搜索抓取与提交要求,不代表百度 AI 的引用结果。',
23
+ sources: [
24
+ 'https://ziyuan.baidu.com/college/articleinfo?id=193',
25
+ 'https://ziyuan.baidu.com/college/articleinfo?id=2315',
26
+ 'https://ziyuan.baidu.com/college/videoinfo?id=3159',
27
+ ],
28
+ rules: [
29
+ {
30
+ id: 'baidu.baiduspider-access',
31
+ weight: 4,
32
+ title: 'Baiduspider 可抓取',
33
+ fix: '在 robots.txt 中允许 Baiduspider 抓取公开页面;百度 PC 与移动端统一使用该 UA,封锁会让站点无法进入索引。',
34
+ evaluate({ scan }) {
35
+ if (!scan.robots.found) return { status: 'pass', evidence: '无 robots.txt,默认允许 Baiduspider' };
36
+ if (scan.robots.unreachable) return { status: 'warn', evidence: 'robots.txt 不可访问,Baiduspider 抓取可能受阻' };
37
+ const access = scan.robots.baiduspider ?? { allowed: true, renderAllowed: true };
38
+ if (access.allowed === false) return { status: 'fail', evidence: 'robots.txt 明确禁止 Baiduspider 抓取' };
39
+ if (access.renderAllowed === false) return { status: 'warn', evidence: 'Baiduspider 可抓取,但 Baiduspider-render 被禁止' };
40
+ return { status: 'pass', evidence: 'robots.txt 允许 Baiduspider' };
41
+ },
42
+ },
43
+ {
44
+ id: 'baidu.robots-ascii',
45
+ weight: 1,
46
+ title: 'robots.txt 不含中文字符',
47
+ fix: '百度蜘蛛不支持 robots.txt 中的中文字符;用 ASCII 路径书写规则,中文路径用 URL 编码形式。',
48
+ evaluate({ scan }) {
49
+ if (!scan.robots.found) return { status: 'skip', evidence: '没有 robots.txt,规则无需编码' };
50
+ // Only rule values matter: Baidu reads paths, not comments, so a Chinese
51
+ // comment after `#` is harmless.
52
+ const effective = (scan.robots.text ?? '')
53
+ .split(/\r?\n/)
54
+ .map((line) => line.replace(/#.*$/, ''))
55
+ .join('\n');
56
+ const cjk = effective.match(/[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff]/g);
57
+ if (cjk && cjk.length > 0) {
58
+ return { status: 'warn', evidence: `robots.txt 规则值含 ${cjk.length} 个中日文字符,百度蜘蛛可能无法解析` };
59
+ }
60
+ return { status: 'pass', evidence: 'robots.txt 规则值全部为 ASCII 字符' };
61
+ },
62
+ },
63
+ {
64
+ id: 'baidu.sitemap',
65
+ weight: 2,
66
+ title: 'XML sitemap 可供百度提交',
67
+ fix: '在网站根目录提供 XML 或 TXT sitemap,并在百度搜索资源平台提交;sitemap 用于缩短发现时间,不保证收录。',
68
+ evaluate({ scan }) {
69
+ if (scan.sitemap.valid) return { status: 'pass', evidence: `${scan.sitemap.urlCount} 个 URL(${scan.sitemap.url})` };
70
+ if (scan.sitemap.found) return { status: 'warn', evidence: 'sitemap 可访问但没有解析出有效 URL' };
71
+ return { status: 'fail', evidence: '未找到可用的 XML sitemap' };
72
+ },
73
+ },
74
+ {
75
+ id: 'baidu.sitemap-at-root',
76
+ weight: 1,
77
+ title: 'sitemap 位于站点根目录',
78
+ fix: '百度要求 sitemap 放在网站根目录(/sitemap.xml 或 /sitemap.txt);放到子目录需要额外提交工具支持。',
79
+ evaluate({ scan }) {
80
+ if (!scan.sitemap.found) return { status: 'skip', evidence: '没有可用 sitemap' };
81
+ let path = null;
82
+ try {
83
+ path = new URL(scan.sitemap.url).pathname;
84
+ } catch {
85
+ path = null;
86
+ }
87
+ if (path === null) return { status: 'skip', evidence: 'sitemap 地址无法解析' };
88
+ const depth = path.split('/').filter(Boolean).length;
89
+ if (depth === 1) return { status: 'pass', evidence: `sitemap 位于根目录:${path}` };
90
+ return { status: 'warn', evidence: `sitemap 不在根目录:${path}` };
91
+ },
92
+ },
93
+ {
94
+ id: 'baidu.server-stability',
95
+ weight: 2,
96
+ title: '抓取返回稳定状态码',
97
+ fix: '保证 Baiduspider 访问公开页面时稳定返回 200;频繁 5xx 或超时会导致抓取频次下降。',
98
+ evaluate({ pages, scan }) {
99
+ if (!Array.isArray(pages) || pages.length === 0) {
100
+ return { status: 'fail', evidence: scan.blockedByRobots ? 'robots.txt 拒绝了扫描,无法验证抓取稳定性' : '未抓取到页面' };
101
+ }
102
+ const serverErrors = pages.filter((page) => page.status >= 500);
103
+ const notFound = pages.filter((page) => page.status === 404);
104
+ if (serverErrors.length > 0) {
105
+ return { status: 'fail', evidence: `${serverErrors.length} 个页面返回 5xx` };
106
+ }
107
+ if (notFound.length > 0) {
108
+ return { status: 'warn', evidence: `${notFound.length} 个页面返回 404` };
109
+ }
110
+ return { status: 'pass', evidence: `${pages.length} 个页面均在 4xx 以下` };
111
+ },
112
+ },
113
+ {
114
+ id: 'baidu.server-rendered-content',
115
+ weight: 2,
116
+ title: '正文直接输出,不依赖脚本',
117
+ fix: '把正文放进服务端输出的 HTML(直出);百度虽能渲染部分 JS 页面,但直出内容抓取更稳定。',
118
+ evaluate({ primary }) {
119
+ if (!primary) return { status: 'fail', evidence: '未抓取到 HTML 入口页' };
120
+ const length = primary.facts.contentLength ?? primary.facts.textLength;
121
+ if (length >= 600) return { status: 'pass', evidence: `原始 HTML 含 ${length} 字正文` };
122
+ if (length >= 250) return { status: 'warn', evidence: `原始 HTML 仅 ${length} 字正文` };
123
+ return { status: 'fail', evidence: `原始 HTML 仅 ${length} 字正文,正文依赖脚本渲染` };
124
+ },
125
+ },
126
+ {
127
+ id: 'baidu.title-description',
128
+ weight: 1,
129
+ title: '标题与描述完整',
130
+ fix: '每个页面输出明确的 <title> 与 meta description;百度在页面分析阶段会提取 TDK 信息。',
131
+ evaluate({ primary }) {
132
+ if (!primary) return { status: 'fail', evidence: '未抓取到 HTML 入口页' };
133
+ const hasTitle = Boolean(primary.facts.title) && primary.facts.titleLength >= 6;
134
+ const hasDescription = [...(primary.facts.description ?? '')].length >= 30;
135
+ if (hasTitle && hasDescription) {
136
+ return { status: 'pass', evidence: `标题 ${primary.facts.titleLength} 字 / 描述 ${[...primary.facts.description].length} 字` };
137
+ }
138
+ if (hasTitle) return { status: 'warn', evidence: '有标题,但描述缺失或过短' };
139
+ return { status: 'fail', evidence: '标题缺失或过短' };
140
+ },
141
+ },
142
+ {
143
+ id: 'baidu.mobile-friendly',
144
+ weight: 1,
145
+ title: '移动端视口声明',
146
+ fix: '在 <head> 中声明 <meta name="viewport">;百度移动搜索建站规范要求页面在移动端可正常浏览。',
147
+ evaluate({ primary }) {
148
+ if (!primary) return { status: 'fail', evidence: '未抓取到 HTML 入口页' };
149
+ if (primary.facts.metaViewport) return { status: 'pass', evidence: primary.facts.metaViewport.slice(0, 80) };
150
+ return { status: 'warn', evidence: '缺少 meta viewport,移动端适配可能不完整' };
151
+ },
152
+ },
153
+ ],
154
+ };
@@ -5,9 +5,10 @@
5
5
  * site's Core total. Every profile declares its official sources, and each
6
6
  * rule returns evidence, a repair hint and an explicit status.
7
7
  */
8
+ import { BAIDU_PROFILE } from './baidu.js';
8
9
  import { BING_PROFILE } from './bing.js';
9
10
 
10
- export const PLATFORM_PROFILES = [BING_PROFILE];
11
+ export const PLATFORM_PROFILES = [BING_PROFILE, BAIDU_PROFILE];
11
12
 
12
13
  const STATUS_FACTOR = { pass: 1, warn: 0.5, fail: 0, skip: 0 };
13
14
 
@@ -48,6 +49,7 @@ function scoreProfile(profile, ctx) {
48
49
  id: profile.id,
49
50
  title: profile.title,
50
51
  sources: [...profile.sources],
52
+ ...(profile.limitation ? { limitation: profile.limitation } : {}),
51
53
  total,
52
54
  scored: applicable > 0,
53
55
  counts: {
package/lib/report.js CHANGED
@@ -309,6 +309,11 @@ export function renderAuditMarkdown(report, context = {}) {
309
309
  }
310
310
  lines.push('');
311
311
  }
312
+ const limitations = report.platforms.filter((platform) => platform.limitation);
313
+ for (const platform of limitations) {
314
+ lines.push(`> ${platform.title}:${escapeInline(platform.limitation)}`);
315
+ }
316
+ if (limitations.length > 0) lines.push('');
312
317
  lines.push('平台检查只反映该平台公开文档中的可验证事项,不代表该平台的排名或引用结果。');
313
318
  lines.push('');
314
319
  }
@@ -381,6 +386,7 @@ export function summarizeReport(report, options = {}) {
381
386
  title: platform.title,
382
387
  total: platform.total,
383
388
  counts: platform.counts,
389
+ ...(platform.limitation ? { limitation: platform.limitation } : {}),
384
390
  actions: platform.actions.slice(0, 3).map((action) => ({
385
391
  ruleId: action.id,
386
392
  title: action.title,
package/lib/robots.js CHANGED
@@ -200,6 +200,21 @@ export function bingbotAccess(robots) {
200
200
  };
201
201
  }
202
202
 
203
+ /**
204
+ * Baidu crawler access at the site root.
205
+ *
206
+ * Baidu documents a single `Baiduspider` user agent for PC and mobile, plus
207
+ * `Baiduspider-render` for its renderer. Both are checked at `/` because the
208
+ * audit's own entry page is what must stay reachable.
209
+ * @param {ReturnType<typeof parseRobots>} robots
210
+ */
211
+ export function baiduspiderAccess(robots) {
212
+ return {
213
+ allowed: isAllowed(robots, '/', 'Baiduspider'),
214
+ renderAllowed: isAllowed(robots, '/', 'Baiduspider-render'),
215
+ };
216
+ }
217
+
203
218
  /**
204
219
  * True when the file forbids the whole site to everyone.
205
220
  * @param {ReturnType<typeof parseRobots>} robots
package/lib/scan.js CHANGED
@@ -13,7 +13,10 @@
13
13
 
14
14
  import { analyzeHtml } from './html.js';
15
15
  import { createTransport, DEFAULT_USER_AGENT, FetchError } from './fetch.js';
16
- import { aiCrawlerPolicy, bingbotAccess, blocksEverything, crawlDelayMs, googlebotAccess, isAllowed, parseRobots } from './robots.js';
16
+ import {
17
+ aiCrawlerPolicy, baiduspiderAccess, bingbotAccess, blocksEverything, crawlDelayMs,
18
+ googlebotAccess, isAllowed, parseRobots,
19
+ } from './robots.js';
17
20
 
18
21
  export const SCAN_VERSION = 'scan@1';
19
22
 
@@ -239,6 +242,7 @@ export async function scanSite(input, options = {}) {
239
242
  aiCrawlers: robotsFound ? aiCrawlerPolicy(robots, new URL(startUrl).pathname) : [],
240
243
  googlebot: robotsFound ? googlebotAccess(robots) : { allowed: true, imageAllowed: true },
241
244
  bingbot: robotsFound ? bingbotAccess(robots) : { allowed: true, previewAllowed: true },
245
+ baiduspider: robotsFound ? baiduspiderAccess(robots) : { allowed: true, renderAllowed: true },
242
246
  crawlDelayMs: robotsFound ? crawlDelayMs(robots, settings.userAgent) : 0,
243
247
  sitemapDeclarations: robots.sitemaps.slice(0, 10),
244
248
  unreachable: robotsUnreachable,
@@ -300,6 +304,7 @@ export async function scanSite(input, options = {}) {
300
304
  aiCrawlers: robotsFound ? aiCrawlerPolicy(robots, new URL(startUrl).pathname) : [],
301
305
  googlebot: robotsFound ? googlebotAccess(robots) : { allowed: true, imageAllowed: true },
302
306
  bingbot: robotsFound ? bingbotAccess(robots) : { allowed: true, previewAllowed: true },
307
+ baiduspider: robotsFound ? baiduspiderAccess(robots) : { allowed: true, renderAllowed: true },
303
308
  crawlDelayMs: robotsFound ? crawlDelayMs(robots, settings.userAgent) : 0,
304
309
  sitemapDeclarations: robots.sitemaps.slice(0, 10),
305
310
  unreachable: settings.respectRobots && (robotsStatus === 0 || robotsStatus >= 500),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobola/dsh-geo",
3
- "version": "0.4.0",
3
+ "version": "0.5.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": {