@cobola/dsh-geo 0.5.0 → 0.7.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 +41 -0
- package/README.md +48 -3
- package/action.yml +138 -0
- package/bin/dsh-geo.js +63 -2
- package/docs/CI.md +35 -1
- package/docs/PROFILES.md +26 -7
- package/docs/index.json +1 -1
- package/examples/geo-audit.yml +42 -0
- package/examples/geo-baseline.yml +29 -0
- package/lib/ci.js +202 -0
- package/lib/platforms/index.js +3 -1
- package/lib/platforms/openai.js +94 -0
- package/lib/platforms/perplexity.js +88 -0
- package/lib/robots.js +18 -0
- package/lib/scan.js +14 -2
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0 - 2026-11-29
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Add the OpenAI profile: `OAI-SearchBot` (search) and `GPTBot` (training) are
|
|
8
|
+
checked separately, including a warning when a training-block also removes the
|
|
9
|
+
site from search.
|
|
10
|
+
- Add the Perplexity profile: `PerplexityBot` (index) and `Perplexity-User`
|
|
11
|
+
(live fetch) are checked separately, with an explicit result for the
|
|
12
|
+
index-only trade-off.
|
|
13
|
+
- Record per-crawler robots facts (`crawlers`) in the scan artifact.
|
|
14
|
+
|
|
15
|
+
### Fixtures
|
|
16
|
+
|
|
17
|
+
- The good fixture now declares `OAI-SearchBot` and `Perplexity-User` so it
|
|
18
|
+
demonstrates the separate search/training and index/fetch declarations.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## 0.6.0 - 2026-11-29
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
- Add `dsh-geo ci` and a bundled GitHub composite action: audit a site, compare
|
|
26
|
+
it with a baseline committed in the repository, and fail the job when the
|
|
27
|
+
score drops or a previously passing rule regresses.
|
|
28
|
+
- Emit a Markdown summary for `$GITHUB_STEP_SUMMARY`, a machine-readable JSON
|
|
29
|
+
report, and optional human-readable report.
|
|
30
|
+
- Add example workflows for the audit job and for creating the baseline.
|
|
31
|
+
|
|
32
|
+
### Fixes
|
|
33
|
+
|
|
34
|
+
- A baseline file describing another site is reported as `different-site` and is
|
|
35
|
+
never overwritten by the current run; a new baseline is written only when no
|
|
36
|
+
baseline was supplied.
|
|
37
|
+
|
|
38
|
+
### Documentation
|
|
39
|
+
|
|
40
|
+
- State the readiness-versus-results boundary at the top of the README: the score
|
|
41
|
+
describes crawlable structure, not rankings, traffic or AI citations.
|
|
42
|
+
|
|
43
|
+
|
|
3
44
|
## 0.5.0 - 2026-11-29
|
|
4
45
|
|
|
5
46
|
### Features
|
package/README.md
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
`dsh-geo` 是一个只读、可复现的网站 GEO/SEO 结构体检工具:它读取网站实际返回的 HTML、robots.txt、sitemap 和结构化数据,找出影响可见性的具体问题,生成可以直接执行的修复清单,并在修改后用同一套规则复查结果。
|
|
12
12
|
|
|
13
|
+
> **它衡量的是 readiness,不是 results。**
|
|
14
|
+
> 分数回答“站点的可抓取、可解析、可引用结构准备好了没有”,不回答“搜索引擎排第几”或“AI 有没有引用你”。真实曝光、点击和引用必须去 Google Search Console、Bing Webmaster、百度搜索资源平台等平台查看。任何把结构分说成排名或引用保证的说法,都不是这个工具的立场。
|
|
15
|
+
|
|
13
16
|
它适合维护官网、内容站、文档站和数据产品的产品负责人、内容负责人、SEO/GEO 顾问与开发者。工具不承诺排名,也不猜测任何平台的黑盒算法;它只报告能够从网站和公开平台文档中验证的事实。
|
|
14
17
|
|
|
15
18
|
## 现在能做什么
|
|
@@ -140,6 +143,45 @@ dsh-geo scan https://journal123.com --save --fail-under 80
|
|
|
140
143
|
|
|
141
144
|
`scan --json` 输出 `{ scan, score }`(加了 `--save` 还会有 `saved` 与 `diff`),同一站点与 `--now` 下两次输出逐字节一致。
|
|
142
145
|
|
|
146
|
+
### CI:把结构质量做成回归门禁
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
# 首次:生成可提交的基线
|
|
150
|
+
dsh-geo ci https://journal123.com --now 2026-11-29T00:00:00Z --write-baseline geo-baseline.json
|
|
151
|
+
|
|
152
|
+
# 之后:与基线对比,回归或低于阈值就让 job 失败
|
|
153
|
+
dsh-geo ci https://journal123.com \
|
|
154
|
+
--baseline geo-baseline.json \
|
|
155
|
+
--fail-on-regression \
|
|
156
|
+
--fail-under 60 \
|
|
157
|
+
--now 2026-11-29T00:00:00Z \
|
|
158
|
+
--json-file geo-report/audit.json
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`ci` 会写出 Markdown 摘要(可直接进 `$GITHUB_STEP_SUMMARY`)和机器可读 JSON,并在不达标时以退出码 `3` 结束。
|
|
162
|
+
|
|
163
|
+
### GitHub Action
|
|
164
|
+
|
|
165
|
+
仓库根目录提供 composite action,可直接在站点仓库里引用:
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
- uses: actions/checkout@v4
|
|
169
|
+
- uses: cobola/dsh-geo@v0.7.0
|
|
170
|
+
with:
|
|
171
|
+
url: https://journal123.com
|
|
172
|
+
baseline: geo-baseline.json
|
|
173
|
+
fail-on-regression: true
|
|
174
|
+
fail-under: 60
|
|
175
|
+
now: 2026-11-29T00:00:00Z
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
输入项、输出与完整示例见 [action.yml](action.yml) 与 [examples/](examples/)。
|
|
179
|
+
|
|
180
|
+
需要注意的两条边界:
|
|
181
|
+
|
|
182
|
+
- 基线一旦提交就是“被审阅过的文件”,工具只在没有基线时才写新文件,不会覆盖它;
|
|
183
|
+
- 阈值和回归门禁衡量的是结构指标,不衡量排名或流量。
|
|
184
|
+
|
|
143
185
|
CLI 也随 npm 包提供:`npx @cobola/dsh-geo --help`;完整参数见 `dsh-geo --help`。CI 示例见 [docs/CI.md](docs/CI.md)。
|
|
144
186
|
|
|
145
187
|
退出码:`0` 完成,`1` 运行错误,`2` 用法错误,`3` 低于 `--fail-under`。
|
|
@@ -165,7 +207,8 @@ CLI 也随 npm 包提供:`npx @cobola/dsh-geo --help`;完整参数见 `dsh-g
|
|
|
165
207
|
| Google | 已实现(作为 Core 的规范边界) | Googlebot、Search 技术要求、Google 明确不需要的 GEO 手段 |
|
|
166
208
|
| Bing / Copilot | 已实现 | Bingbot / BingPreview 可达性、页面级 bingbot 指令、sitemap、站长验证、`data-nosnippet` |
|
|
167
209
|
| 百度 | 已实现 | Baiduspider 与 Baiduspider-render 可达性、robots 编码、sitemap 与根目录位置、抓取稳定性、正文直出、TDK、移动端视口;百度 AI 引用标准未公开 |
|
|
168
|
-
| OpenAI /
|
|
210
|
+
| OpenAI / ChatGPT | 已实现 | `OAI-SearchBot` 与 `GPTBot` 分开检查,含训练策略误伤搜索的告警 |
|
|
211
|
+
| Perplexity | 已实现 | `PerplexityBot`(索引)与 `Perplexity-User`(实时抓取)分开检查 |
|
|
169
212
|
|
|
170
213
|
平台分在报告、CLI 与看板中单独显示,**从不计入 Core 总分**,也不代表任何平台的排名或引用结果。规则与官方来源见 [docs/PROFILES.md](docs/PROFILES.md),Google 边界见 [docs/GOOGLE.md](docs/GOOGLE.md)。
|
|
171
214
|
|
|
@@ -198,7 +241,7 @@ fixture 基线(参考时间 `2026-06-15T00:00:00Z`,由测试锁定):
|
|
|
198
241
|
## 开发与发布
|
|
199
242
|
|
|
200
243
|
```sh
|
|
201
|
-
npm test #
|
|
244
|
+
npm test # 运行完整测试套件,验证规则、平台、CI、工具、存储、面板、CLI 与安全边界
|
|
202
245
|
npm run docs # 规则改动后重新生成 docs/RULES.md
|
|
203
246
|
```
|
|
204
247
|
|
|
@@ -214,7 +257,9 @@ lib/robots.js robots.txt 解析
|
|
|
214
257
|
lib/html.js 无依赖 HTML 解析与事实抽取
|
|
215
258
|
lib/scan.js 抓取流程
|
|
216
259
|
lib/rules.js 45 条 Core 规则(唯一事实源)
|
|
217
|
-
lib/platforms/ 平台 profile(Bing 已实现)
|
|
260
|
+
lib/platforms/ 平台 profile(Bing、百度、OpenAI、Perplexity 已实现)
|
|
261
|
+
lib/ci.js CI 审计、基线与质量门禁
|
|
262
|
+
action.yml GitHub composite action
|
|
218
263
|
lib/score.js 评分聚合(纯函数)
|
|
219
264
|
lib/report.js 报告/修复清单/diff 生成
|
|
220
265
|
lib/audit.js 工具与 CLI 共用的高层动作
|
package/action.yml
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
name: dsh-geo audit
|
|
2
|
+
description: Audit a site's crawlable structure, compare it with a committed baseline, and fail the job when the quality gate is not met.
|
|
3
|
+
|
|
4
|
+
branding:
|
|
5
|
+
icon: search
|
|
6
|
+
color: blue
|
|
7
|
+
|
|
8
|
+
inputs:
|
|
9
|
+
url:
|
|
10
|
+
description: Absolute http(s) URL of the site entry page to audit.
|
|
11
|
+
required: true
|
|
12
|
+
baseline:
|
|
13
|
+
description: Path to a committed baseline report. Leave empty to run a snapshot without comparison.
|
|
14
|
+
required: false
|
|
15
|
+
default: ''
|
|
16
|
+
fail-under:
|
|
17
|
+
description: Fail the job when the total score is below this value (0-100). Leave empty to skip.
|
|
18
|
+
required: false
|
|
19
|
+
default: ''
|
|
20
|
+
fail-on-regression:
|
|
21
|
+
description: Fail the job when any rule that previously passed no longer does.
|
|
22
|
+
required: false
|
|
23
|
+
default: 'false'
|
|
24
|
+
max-regression:
|
|
25
|
+
description: Tolerated drop in the total score when fail-on-regression is enabled.
|
|
26
|
+
required: false
|
|
27
|
+
default: '0'
|
|
28
|
+
max-pages:
|
|
29
|
+
description: Pages to crawl (1-50).
|
|
30
|
+
required: false
|
|
31
|
+
default: '6'
|
|
32
|
+
now:
|
|
33
|
+
description: ISO-8601 reference time for freshness checks. Reuse one value so runs stay comparable.
|
|
34
|
+
required: false
|
|
35
|
+
default: ''
|
|
36
|
+
report-dir:
|
|
37
|
+
description: Directory for generated reports.
|
|
38
|
+
required: false
|
|
39
|
+
default: geo-report
|
|
40
|
+
summary-file:
|
|
41
|
+
description: Markdown summary path, meant for the job summary.
|
|
42
|
+
required: false
|
|
43
|
+
default: geo-summary.md
|
|
44
|
+
json-file:
|
|
45
|
+
description: Machine-readable audit output path.
|
|
46
|
+
required: false
|
|
47
|
+
default: geo-report/audit.json
|
|
48
|
+
write-baseline:
|
|
49
|
+
description: When true and no baseline exists, write one to this path for the caller to commit.
|
|
50
|
+
required: false
|
|
51
|
+
default: ''
|
|
52
|
+
version:
|
|
53
|
+
description: npm version or dist-tag of @cobola/dsh-geo to run.
|
|
54
|
+
required: false
|
|
55
|
+
default: latest
|
|
56
|
+
|
|
57
|
+
outputs:
|
|
58
|
+
total:
|
|
59
|
+
description: Total score (0-100).
|
|
60
|
+
value: ${{ steps.publish.outputs.total }}
|
|
61
|
+
grade:
|
|
62
|
+
description: Letter grade.
|
|
63
|
+
value: ${{ steps.publish.outputs.grade }}
|
|
64
|
+
summary-path:
|
|
65
|
+
description: Path of the generated Markdown summary.
|
|
66
|
+
value: ${{ inputs.summary-file }}
|
|
67
|
+
json-path:
|
|
68
|
+
description: Path of the generated JSON report.
|
|
69
|
+
value: ${{ inputs.json-file }}
|
|
70
|
+
|
|
71
|
+
runs:
|
|
72
|
+
using: composite
|
|
73
|
+
steps:
|
|
74
|
+
- name: Set up Node.js
|
|
75
|
+
uses: actions/setup-node@v4
|
|
76
|
+
with:
|
|
77
|
+
node-version: 22
|
|
78
|
+
|
|
79
|
+
- name: Run dsh-geo audit
|
|
80
|
+
id: audit
|
|
81
|
+
shell: bash
|
|
82
|
+
env:
|
|
83
|
+
GEO_URL: ${{ inputs.url }}
|
|
84
|
+
GEO_BASELINE: ${{ inputs.baseline }}
|
|
85
|
+
GEO_FAIL_UNDER: ${{ inputs.fail-under }}
|
|
86
|
+
GEO_FAIL_ON_REGRESSION: ${{ inputs.fail-on-regression }}
|
|
87
|
+
GEO_MAX_REGRESSION: ${{ inputs.max-regression }}
|
|
88
|
+
GEO_MAX_PAGES: ${{ inputs.max-pages }}
|
|
89
|
+
GEO_NOW: ${{ inputs.now }}
|
|
90
|
+
GEO_SUMMARY_FILE: ${{ inputs.summary-file }}
|
|
91
|
+
GEO_JSON_FILE: ${{ inputs.json-file }}
|
|
92
|
+
GEO_BASELINE_OUT: ${{ inputs.write-baseline }}
|
|
93
|
+
GEO_VERSION: ${{ inputs.version }}
|
|
94
|
+
run: |
|
|
95
|
+
set -euo pipefail
|
|
96
|
+
mkdir -p "$(dirname "$GEO_JSON_FILE")"
|
|
97
|
+
ARGS=(ci "$GEO_URL")
|
|
98
|
+
[ -n "${GEO_BASELINE:-}" ] && ARGS+=(--baseline "$GEO_BASELINE")
|
|
99
|
+
[ -n "${GEO_FAIL_UNDER:-}" ] && ARGS+=(--fail-under "$GEO_FAIL_UNDER")
|
|
100
|
+
[ "${GEO_FAIL_ON_REGRESSION:-false}" = "true" ] && ARGS+=(--fail-on-regression)
|
|
101
|
+
[ -n "${GEO_MAX_REGRESSION:-}" ] && ARGS+=(--max-regression "$GEO_MAX_REGRESSION")
|
|
102
|
+
[ -n "${GEO_MAX_PAGES:-}" ] && ARGS+=(--max-pages "$GEO_MAX_PAGES")
|
|
103
|
+
[ -n "${GEO_NOW:-}" ] && ARGS+=(--now "$GEO_NOW")
|
|
104
|
+
[ -n "${GEO_BASELINE_OUT:-}" ] && ARGS+=(--write-baseline "$GEO_BASELINE_OUT")
|
|
105
|
+
ARGS+=(--summary-file "$GEO_SUMMARY_FILE" --json-file "$GEO_JSON_FILE")
|
|
106
|
+
npx --yes "@cobola/dsh-geo@${GEO_VERSION}" "${ARGS[@]}"
|
|
107
|
+
|
|
108
|
+
- name: Publish outputs
|
|
109
|
+
id: publish
|
|
110
|
+
if: always()
|
|
111
|
+
shell: bash
|
|
112
|
+
env:
|
|
113
|
+
GEO_JSON_FILE: ${{ inputs.json-file }}
|
|
114
|
+
run: |
|
|
115
|
+
if [ -f "$GEO_JSON_FILE" ]; then
|
|
116
|
+
TOTAL=$(node -p "require('$GEO_JSON_FILE').score.total" 2>/dev/null || echo '')
|
|
117
|
+
GRADE=$(node -p "require('$GEO_JSON_FILE').score.grade" 2>/dev/null || echo '')
|
|
118
|
+
echo "total=$TOTAL" >> "$GITHUB_OUTPUT"
|
|
119
|
+
echo "grade=$GRADE" >> "$GITHUB_OUTPUT"
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
- name: Append job summary
|
|
123
|
+
if: always()
|
|
124
|
+
shell: bash
|
|
125
|
+
run: |
|
|
126
|
+
if [ -f "${{ inputs.summary-file }}" ]; then
|
|
127
|
+
cat "${{ inputs.summary-file }}" >> "$GITHUB_STEP_SUMMARY"
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
- name: Upload audit reports
|
|
131
|
+
if: always()
|
|
132
|
+
uses: actions/upload-artifact@v4
|
|
133
|
+
with:
|
|
134
|
+
name: dsh-geo-report
|
|
135
|
+
path: |
|
|
136
|
+
${{ inputs.summary-file }}
|
|
137
|
+
${{ inputs.json-file }}
|
|
138
|
+
if-no-files-found: warn
|
package/bin/dsh-geo.js
CHANGED
|
@@ -14,6 +14,7 @@ import fs from 'node:fs/promises';
|
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
|
|
16
16
|
import { auditSite, persistAudit, planFromReport } from '../lib/audit.js';
|
|
17
|
+
import { runCi } from '../lib/ci.js';
|
|
17
18
|
import { diffReports } from '../lib/report.js';
|
|
18
19
|
import { listAudits, resolveStoreDir } from '../lib/store.js';
|
|
19
20
|
|
|
@@ -24,11 +25,23 @@ const HELP = `dsh-geo ${version} — deterministic GEO/SEO audit
|
|
|
24
25
|
|
|
25
26
|
Usage:
|
|
26
27
|
dsh-geo scan <url> [options]
|
|
28
|
+
dsh-geo ci <url> [options]
|
|
27
29
|
dsh-geo fix-plan [options]
|
|
28
30
|
dsh-geo history [options]
|
|
29
31
|
dsh-geo diff <before.json> <after.json> [--json]
|
|
30
32
|
dsh-geo --help | --version
|
|
31
33
|
|
|
34
|
+
ci options (for CI jobs):
|
|
35
|
+
--baseline <path> Compare against a committed baseline report.
|
|
36
|
+
--fail-under <score> Exit 3 when the total is below this score.
|
|
37
|
+
--fail-on-regression Exit 3 when a previously passing rule now fails.
|
|
38
|
+
--max-regression <n> Tolerated total drop with --fail-on-regression (default 0).
|
|
39
|
+
--summary-file <path> Markdown summary path (default geo-summary.md).
|
|
40
|
+
--json-file <path> Machine-readable output path.
|
|
41
|
+
--report-file <path> Human-readable report path.
|
|
42
|
+
--write-baseline <p> Write a baseline when none exists yet.
|
|
43
|
+
Scan options (--max-pages, --now, --timeout, --rate-limit, ...) also apply.
|
|
44
|
+
|
|
32
45
|
scan options:
|
|
33
46
|
--json Print { scan, score } as JSON.
|
|
34
47
|
--save Write .dsh-geo/latest.json, history/, report.md and diff.
|
|
@@ -74,12 +87,20 @@ function defaults() {
|
|
|
74
87
|
userAgent: undefined,
|
|
75
88
|
report: null,
|
|
76
89
|
limit: 10,
|
|
90
|
+
baseline: null,
|
|
91
|
+
failOnRegression: false,
|
|
92
|
+
maxRegression: 0,
|
|
93
|
+
summaryFile: 'geo-summary.md',
|
|
94
|
+
jsonFile: null,
|
|
95
|
+
reportFile: null,
|
|
96
|
+
baselineOut: null,
|
|
77
97
|
};
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
const VALUE_OPTIONS = new Set([
|
|
81
101
|
'dir', 'fail-under', 'max-pages', 'now', 'timeout', 'rate-limit',
|
|
82
102
|
'user-agent', 'report', 'limit',
|
|
103
|
+
'baseline', 'max-regression', 'summary-file', 'json-file', 'report-file', 'write-baseline',
|
|
83
104
|
]);
|
|
84
105
|
|
|
85
106
|
function parseArgs(argv) {
|
|
@@ -99,7 +120,7 @@ function parseArgs(argv) {
|
|
|
99
120
|
if (key === 'help') { options.help = true; continue; }
|
|
100
121
|
if (key === 'version') { options.version = true; continue; }
|
|
101
122
|
if (!VALUE_OPTIONS.has(key)) {
|
|
102
|
-
if (!['json', 'save', 'no-robots', 'allow-private', 'insecure-tls'].includes(key)) {
|
|
123
|
+
if (!['json', 'save', 'no-robots', 'allow-private', 'insecure-tls', 'fail-on-regression'].includes(key)) {
|
|
103
124
|
throw new Error(`Unknown option: --${key}`);
|
|
104
125
|
}
|
|
105
126
|
}
|
|
@@ -108,6 +129,7 @@ function parseArgs(argv) {
|
|
|
108
129
|
switch (key) {
|
|
109
130
|
case 'json': options.json = true; break;
|
|
110
131
|
case 'save': options.save = true; break;
|
|
132
|
+
case 'fail-on-regression': options.failOnRegression = true; break;
|
|
111
133
|
case 'no-robots': options.respectRobots = false; break;
|
|
112
134
|
case 'allow-private': options.allowPrivate = true; break;
|
|
113
135
|
case 'insecure-tls': options.insecureTls = true; break;
|
|
@@ -120,6 +142,12 @@ function parseArgs(argv) {
|
|
|
120
142
|
case 'timeout': options.timeoutMs = Number(value); break;
|
|
121
143
|
case 'rate-limit': options.rateLimitMs = Number(value); break;
|
|
122
144
|
case 'limit': options.limit = Number(value); break;
|
|
145
|
+
case 'baseline': options.baseline = value; break;
|
|
146
|
+
case 'max-regression': options.maxRegression = Number(value); break;
|
|
147
|
+
case 'summary-file': options.summaryFile = value; break;
|
|
148
|
+
case 'json-file': options.jsonFile = value; break;
|
|
149
|
+
case 'report-file': options.reportFile = value; break;
|
|
150
|
+
case 'write-baseline': options.baselineOut = value; break;
|
|
123
151
|
default: throw new Error(`Unknown option: --${key}`);
|
|
124
152
|
}
|
|
125
153
|
}
|
|
@@ -135,7 +163,7 @@ function validate(options, commandName) {
|
|
|
135
163
|
}
|
|
136
164
|
if (options.now !== null && !Number.isFinite(Date.parse(options.now))) throw new Error(`--now is not a valid ISO time: ${options.now}`);
|
|
137
165
|
if (!Number.isInteger(options.limit) || options.limit < 1) throw new Error('--limit must be a positive integer');
|
|
138
|
-
if (
|
|
166
|
+
if (!['scan', 'ci'].includes(commandName) && (options.maxPages !== 6 || options.now !== null || !options.respectRobots
|
|
139
167
|
|| options.allowPrivate || options.insecureTls || options.timeoutMs !== 10_000 || options.rateLimitMs !== 250)) {
|
|
140
168
|
throw new Error(`Scan-only options are not accepted by "${commandName}"`);
|
|
141
169
|
}
|
|
@@ -330,8 +358,41 @@ async function commandDiff(positionals, options) {
|
|
|
330
358
|
return 0;
|
|
331
359
|
}
|
|
332
360
|
|
|
361
|
+
async function commandCi(positionals, options) {
|
|
362
|
+
if (positionals.length > 1) throw new Error(`Unexpected argument: ${positionals[1]}`);
|
|
363
|
+
const url = positionals[0];
|
|
364
|
+
if (!url) throw new Error('Missing <url>');
|
|
365
|
+
const cwd = process.cwd();
|
|
366
|
+
const result = await runCi({
|
|
367
|
+
url,
|
|
368
|
+
cwd,
|
|
369
|
+
baseline: options.baseline,
|
|
370
|
+
failUnder: options.failUnder,
|
|
371
|
+
failOnRegression: options.failOnRegression,
|
|
372
|
+
maxRegression: options.maxRegression,
|
|
373
|
+
summaryFile: options.summaryFile,
|
|
374
|
+
jsonFile: options.jsonFile,
|
|
375
|
+
reportFile: options.reportFile,
|
|
376
|
+
baselineOut: options.baselineOut,
|
|
377
|
+
scanOptions: {
|
|
378
|
+
maxPages: options.maxPages,
|
|
379
|
+
now: options.now ?? undefined,
|
|
380
|
+
respectRobots: options.respectRobots,
|
|
381
|
+
allowPrivate: options.allowPrivate,
|
|
382
|
+
insecureTls: options.insecureTls,
|
|
383
|
+
timeoutMs: options.timeoutMs,
|
|
384
|
+
rateLimitMs: options.rateLimitMs,
|
|
385
|
+
userAgent: options.userAgent,
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
process.stdout.write(`${result.summary}\n`);
|
|
389
|
+
for (const reason of result.reasons) process.stderr.write(`dsh-geo ci: ${reason}\n`);
|
|
390
|
+
return result.exitCode;
|
|
391
|
+
}
|
|
392
|
+
|
|
333
393
|
const COMMANDS = {
|
|
334
394
|
scan: commandScan,
|
|
395
|
+
ci: commandCi,
|
|
335
396
|
'fix-plan': commandFixPlan,
|
|
336
397
|
history: commandHistory,
|
|
337
398
|
diff: commandDiff,
|
package/docs/CI.md
CHANGED
|
@@ -115,4 +115,38 @@ on:
|
|
|
115
115
|
schedule:
|
|
116
116
|
- cron: '17 2 * * 1'
|
|
117
117
|
workflow_dispatch:
|
|
118
|
-
```
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 内置的 composite action
|
|
121
|
+
|
|
122
|
+
本仓库自带一个 action([action.yml](../action.yml)),不需要在站点仓库里写安装脚本:
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- uses: cobola/dsh-geo@v0.7.0
|
|
127
|
+
with:
|
|
128
|
+
url: https://journal123.com
|
|
129
|
+
baseline: geo-baseline.json
|
|
130
|
+
fail-on-regression: true
|
|
131
|
+
fail-under: 60
|
|
132
|
+
now: 2026-11-29T00:00:00Z
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
它输出 `total`、`grade`,并把 Markdown 摘要写入 job summary、上传报告 artifact。
|
|
136
|
+
|
|
137
|
+
## 基线的正确用法
|
|
138
|
+
|
|
139
|
+
1. 先用手动触发的 baseline workflow([examples/geo-baseline.yml](../examples/geo-baseline.yml))生成 `geo-baseline.json`;
|
|
140
|
+
2. 下载 artifact,把它提交进仓库;
|
|
141
|
+
3. PR workflow 引用这个文件做对比。
|
|
142
|
+
|
|
143
|
+
工具只在**没有提供基线**时才写新基线;已有文件不会被本次运行覆盖,避免悄悄改掉被审阅过的门禁。
|
|
144
|
+
|
|
145
|
+
## 阈值的含义
|
|
146
|
+
|
|
147
|
+
`--fail-under` 与 `--fail-on-regression` 衡量的是结构指标:
|
|
148
|
+
|
|
149
|
+
- 分数下降、规则回归 → 说明结构退化了;
|
|
150
|
+
- 它们**不**衡量排名、流量或 AI 引用。
|
|
151
|
+
|
|
152
|
+
如果团队只想要回归门禁、不想卡绝对分数,把 `fail-under` 留空,只开 `fail-on-regression`。
|
package/docs/PROFILES.md
CHANGED
|
@@ -28,8 +28,8 @@ profile 是证据和检查边界,**不改变 Core 总分**。平台分数在
|
|
|
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
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
|
-
| OpenAI |
|
|
32
|
-
| Perplexity |
|
|
31
|
+
| OpenAI | implemented (v0.7.0) | [OpenAI crawlers](https://developers.openai.com/api/docs/bots) | OAI-SearchBot 与 GPTBot 分离控制、训练策略误伤搜索告警 |
|
|
32
|
+
| Perplexity | implemented (v0.7.0) | [Perplexity crawlers](https://docs.perplexity.ai/docs/resources/perplexity-crawlers)、[robots 遵循说明](https://www.perplexity.ai/help-center/en/articles/10354969-how-does-perplexity-follow-robots-txt) | PerplexityBot(索引)与 Perplexity-User(实时抓取)分开检查 |
|
|
33
33
|
|
|
34
34
|
## Bing profile 规则(已实现)
|
|
35
35
|
|
|
@@ -60,9 +60,28 @@ profile 是证据和检查边界,**不改变 Core 总分**。平台分数在
|
|
|
60
60
|
|
|
61
61
|
源码:[lib/platforms/baidu.js](../lib/platforms/baidu.js)。
|
|
62
62
|
|
|
63
|
-
##
|
|
63
|
+
## OpenAI profile 规则(已实现)
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
| 规则 | 权重 | 检查内容 |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `openai.searchbot-access` | 4 | `OAI-SearchBot` 是否可抓取,以及是否被显式点名 |
|
|
68
|
+
| `openai.searchbot-vs-training` | 2 | `OAI-SearchBot` 与 `GPTBot` 是否分开声明 |
|
|
69
|
+
| `openai.no-accidental-block` | 3 | 是否因封训练爬虫误伤搜索抓取 |
|
|
70
|
+
| `openai.content-reachable` | 2 | 原始 HTML 是否有可读正文 |
|
|
71
|
+
|
|
72
|
+
## Perplexity profile 规则(已实现)
|
|
73
|
+
|
|
74
|
+
| 规则 | 权重 | 检查内容 |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `perplexity.bot-access` | 4 | `PerplexityBot`(索引)是否可抓取 |
|
|
77
|
+
| `perplexity.user-crawler` | 2 | `Perplexity-User`(实时抓取)是否被误封 |
|
|
78
|
+
| `perplexity.index-vs-fetch` | 2 | 索引与实时抓取的策略是否一致 |
|
|
79
|
+
| `perplexity.content-reachable` | 2 | 原始 HTML 是否有可读正文 |
|
|
80
|
+
|
|
81
|
+
源码:[lib/platforms/openai.js](../lib/platforms/openai.js)、[lib/platforms/perplexity.js](../lib/platforms/perplexity.js)。
|
|
82
|
+
|
|
83
|
+
## 下一步
|
|
84
|
+
|
|
85
|
+
1. 把各平台覆盖范围显示到结果卡(当前只能看到分数);
|
|
86
|
+
2. 后续接 Search Console / Bing Webmaster / 百度平台数据时,放入独立“效果数据”模块,不混入 HTML 结构评分;
|
|
87
|
+
3. MCP server 作为生态扩展,视需求推进。
|
package/docs/index.json
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Copy this file to .github/workflows/geo-audit.yml in the site's repository.
|
|
2
|
+
#
|
|
3
|
+
# What it does on every pull request:
|
|
4
|
+
# 1. audits the site's crawlable structure,
|
|
5
|
+
# 2. compares the result with the baseline committed in the repository,
|
|
6
|
+
# 3. fails the job when the score drops or a rule regresses.
|
|
7
|
+
#
|
|
8
|
+
# One-time setup: run the workflow once with `write_baseline` enabled, commit
|
|
9
|
+
# the produced baseline file, then leave it in place to serve as the gate.
|
|
10
|
+
name: Website visibility audit
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
pull_request:
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
audit:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Audit and compare against the committed baseline
|
|
26
|
+
uses: cobola/dsh-geo@v0.7.0
|
|
27
|
+
with:
|
|
28
|
+
url: https://journal123.com
|
|
29
|
+
baseline: geo-baseline.json
|
|
30
|
+
fail-on-regression: true
|
|
31
|
+
fail-under: 60
|
|
32
|
+
# A fixed reference time keeps two runs comparable: freshness checks
|
|
33
|
+
# then measure the site, not the passing days.
|
|
34
|
+
now: 2026-11-29T00:00:00Z
|
|
35
|
+
json-file: geo-report/audit.json
|
|
36
|
+
|
|
37
|
+
- name: Keep the reports
|
|
38
|
+
if: always()
|
|
39
|
+
uses: actions/upload-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: geo-audit
|
|
42
|
+
path: geo-report/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# One-time workflow that creates the baseline the audit job compares against.
|
|
2
|
+
# Run it from the Actions tab, download the artifact, and commit the file.
|
|
3
|
+
name: Create website visibility baseline
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
baseline:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Audit and write a baseline
|
|
18
|
+
uses: cobola/dsh-geo@v0.7.0
|
|
19
|
+
with:
|
|
20
|
+
url: https://journal123.com
|
|
21
|
+
now: 2026-11-29T00:00:00Z
|
|
22
|
+
write-baseline: geo-baseline.json
|
|
23
|
+
json-file: geo-report/audit.json
|
|
24
|
+
|
|
25
|
+
- name: Upload the baseline to commit
|
|
26
|
+
uses: actions/upload-artifact@v4
|
|
27
|
+
with:
|
|
28
|
+
name: geo-baseline
|
|
29
|
+
path: geo-baseline.json
|
package/lib/ci.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Continuous-integration entry point.
|
|
3
|
+
*
|
|
4
|
+
* One call does what a CI job needs: audit a site, compare it with a baseline
|
|
5
|
+
* file kept in the repository, decide whether the run should fail, and emit a
|
|
6
|
+
* bounded summary plus the machine-readable reports.
|
|
7
|
+
*
|
|
8
|
+
* The baseline is an ordinary audit payload (`latest.json` from any earlier
|
|
9
|
+
* run). Keeping it in the repository is what turns a snapshot into a regression
|
|
10
|
+
* gate: the comparison is against a reviewed commit, not against whatever the
|
|
11
|
+
* last CI run happened to write.
|
|
12
|
+
*/
|
|
13
|
+
import fs from 'node:fs/promises';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
|
|
16
|
+
import { auditSite } from './audit.js';
|
|
17
|
+
import { buildFixPlan, comparableSites, diffReports, renderAuditMarkdown } from './report.js';
|
|
18
|
+
import { resolveWorkspaceFile } from './store.js';
|
|
19
|
+
|
|
20
|
+
export const CI_DEFAULTS = {
|
|
21
|
+
failUnder: null,
|
|
22
|
+
failOnRegression: false,
|
|
23
|
+
maxRegression: 0,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
async function readJsonFile(file) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(await fs.readFile(file, 'utf8'));
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error?.code === 'ENOENT') return null;
|
|
31
|
+
throw new Error(`Cannot read ${file}: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function writeText(file, text) {
|
|
36
|
+
await fs.mkdir(path.dirname(path.resolve(file)), { recursive: true });
|
|
37
|
+
await fs.writeFile(file, text, 'utf8');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function signed(value) {
|
|
41
|
+
return value > 0 ? `+${value}` : String(value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Render the CI summary. GitHub Actions appends this to the step summary.
|
|
46
|
+
* @param {object} result - value returned by {@link runCi}.
|
|
47
|
+
*/
|
|
48
|
+
export function renderCiSummary(result) {
|
|
49
|
+
const lines = [];
|
|
50
|
+
lines.push(`## dsh-geo audit — ${result.url}`);
|
|
51
|
+
lines.push('');
|
|
52
|
+
lines.push(`**${result.total} / 100** (${result.grade}) · ${result.pages} pages · ${result.counts.pass} pass / ${result.counts.warn} partial / ${result.counts.fail} fail`);
|
|
53
|
+
lines.push('');
|
|
54
|
+
lines.push('| Dimension | Score | Weight |');
|
|
55
|
+
lines.push('|---|---|---|');
|
|
56
|
+
for (const dimension of result.dimensions) {
|
|
57
|
+
lines.push(`| ${dimension.title} | ${dimension.score} | ${dimension.weight} |`);
|
|
58
|
+
}
|
|
59
|
+
lines.push('');
|
|
60
|
+
|
|
61
|
+
if (result.platforms.length > 0) {
|
|
62
|
+
lines.push('| Platform profile | Score (not in Core) |');
|
|
63
|
+
lines.push('|---|---|');
|
|
64
|
+
for (const platform of result.platforms) {
|
|
65
|
+
lines.push(`| ${platform.title} | ${platform.total} |`);
|
|
66
|
+
}
|
|
67
|
+
lines.push('');
|
|
68
|
+
for (const platform of result.platforms) {
|
|
69
|
+
if (platform.limitation) lines.push(`> ${platform.title}: ${platform.limitation}`);
|
|
70
|
+
}
|
|
71
|
+
if (result.platforms.some((platform) => platform.limitation)) lines.push('');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (result.diff) {
|
|
75
|
+
lines.push(`### Compared with baseline (${result.diff.previous.scannedAt})`);
|
|
76
|
+
lines.push('');
|
|
77
|
+
lines.push(`${result.diff.total.before} → ${result.diff.total.after} (${signed(result.diff.total.delta)})`);
|
|
78
|
+
lines.push('');
|
|
79
|
+
lines.push(`- Fixed: ${result.diff.counts.fixed}${result.diff.fixed.length > 0 ? ` (${result.diff.fixed.map((entry) => entry.ruleId).join(', ')})` : ''}`);
|
|
80
|
+
lines.push(`- Regressed: ${result.diff.counts.regressed}${result.diff.regressed.length > 0 ? ` (${result.diff.regressed.map((entry) => entry.ruleId).join(', ')})` : ''}`);
|
|
81
|
+
lines.push(`- Still failing: ${result.diff.counts.stillFailing}`);
|
|
82
|
+
lines.push('');
|
|
83
|
+
} else if (result.baselineStatus === 'missing') {
|
|
84
|
+
lines.push('> No baseline file supplied. This run is a snapshot; commit the report as a baseline to enable regression checks.');
|
|
85
|
+
lines.push('');
|
|
86
|
+
} else if (result.baselineStatus === 'different-site') {
|
|
87
|
+
lines.push('> The baseline describes a different site, so no comparison was made.');
|
|
88
|
+
lines.push('');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (result.actions.length > 0) {
|
|
92
|
+
lines.push('### Top fixes');
|
|
93
|
+
lines.push('');
|
|
94
|
+
result.actions.forEach((action, index) => {
|
|
95
|
+
lines.push(`${index + 1}. **${action.dimensionTitle} · ${action.title}** — ${action.evidence}`);
|
|
96
|
+
lines.push(` ${action.fix}`);
|
|
97
|
+
});
|
|
98
|
+
lines.push('');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
lines.push('---');
|
|
102
|
+
lines.push('');
|
|
103
|
+
lines.push('Readiness signal only: this audit inspects crawlable HTML structure. It does not measure rankings, traffic, or whether any AI product cites the page.');
|
|
104
|
+
lines.push('');
|
|
105
|
+
return lines.join('\n');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Run one CI audit.
|
|
110
|
+
*
|
|
111
|
+
* @param {object} options
|
|
112
|
+
* @param {string} options.url Site entry URL.
|
|
113
|
+
* @param {string} [options.baseline] Baseline audit payload path.
|
|
114
|
+
* @param {number} [options.failUnder] Fail when the total is below this score.
|
|
115
|
+
* @param {boolean} [options.failOnRegression] Fail when any rule regresses.
|
|
116
|
+
* @param {number} [options.maxRegression] Tolerated total-score drop (default 0).
|
|
117
|
+
* @param {object} [options.scanOptions] Extra scanSite options (now, maxPages…).
|
|
118
|
+
* @returns {Promise<object>} result with `exitCode`, reports and rendered summary.
|
|
119
|
+
*/
|
|
120
|
+
export async function runCi(options = {}) {
|
|
121
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
122
|
+
if (!options.url) throw new Error('runCi needs a url');
|
|
123
|
+
|
|
124
|
+
const scanOptions = { ...(options.scanOptions ?? {}) };
|
|
125
|
+
const { scan, report } = await auditSite(options.url, scanOptions);
|
|
126
|
+
|
|
127
|
+
let baseline = null;
|
|
128
|
+
let baselineStatus = 'missing';
|
|
129
|
+
if (options.baseline) {
|
|
130
|
+
const file = resolveWorkspaceFile(cwd, options.baseline);
|
|
131
|
+
baseline = await readJsonFile(file);
|
|
132
|
+
if (!baseline) baselineStatus = 'missing';
|
|
133
|
+
else if (!baseline.score) baselineStatus = 'unreadable';
|
|
134
|
+
else if (!comparableSites(baseline.url, scan.startUrl)) baselineStatus = 'different-site';
|
|
135
|
+
else baselineStatus = 'used';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const diff = baselineStatus === 'used' ? diffReports(baseline.score, report) : null;
|
|
139
|
+
const plan = buildFixPlan(report, { scan, diff });
|
|
140
|
+
const summary = renderCiSummary({
|
|
141
|
+
url: scan.startUrl,
|
|
142
|
+
total: report.total,
|
|
143
|
+
grade: report.grade,
|
|
144
|
+
pages: scan.stats.pages,
|
|
145
|
+
counts: report.counts,
|
|
146
|
+
dimensions: report.dimensions,
|
|
147
|
+
platforms: report.platforms ?? [],
|
|
148
|
+
diff,
|
|
149
|
+
baselineStatus,
|
|
150
|
+
actions: plan.actions.slice(0, 5),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const reasons = [];
|
|
154
|
+
if (typeof options.failUnder === 'number' && report.total < options.failUnder) {
|
|
155
|
+
reasons.push(`score ${report.total} is below --fail-under ${options.failUnder}`);
|
|
156
|
+
}
|
|
157
|
+
if (options.failOnRegression && diff) {
|
|
158
|
+
const maxDrop = typeof options.maxRegression === 'number' ? options.maxRegression : 0;
|
|
159
|
+
if (diff.counts.regressed > 0) {
|
|
160
|
+
reasons.push(`${diff.counts.regressed} rule(s) regressed: ${diff.regressed.map((entry) => entry.ruleId).join(', ')}`);
|
|
161
|
+
}
|
|
162
|
+
if (diff.total.delta < -maxDrop) {
|
|
163
|
+
reasons.push(`total dropped ${Math.abs(diff.total.delta)} (tolerance ${maxDrop})`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const exitCode = reasons.length > 0 ? 3 : 0;
|
|
168
|
+
|
|
169
|
+
if (options.summaryFile) await writeText(path.resolve(cwd, options.summaryFile), summary);
|
|
170
|
+
if (options.jsonFile) {
|
|
171
|
+
await writeText(
|
|
172
|
+
path.resolve(cwd, options.jsonFile),
|
|
173
|
+
`${JSON.stringify({ scan, score: report, diff, plan: plan.json }, null, 2)}\n`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (options.baselineOut && baselineStatus === 'missing' && !options.baseline) {
|
|
177
|
+
// A baseline is written only when none was supplied: an existing reviewed
|
|
178
|
+
// file is the caller's to update deliberately, and a file describing a
|
|
179
|
+
// different site must never be replaced by this run.
|
|
180
|
+
await writeText(
|
|
181
|
+
path.resolve(cwd, options.baselineOut),
|
|
182
|
+
`${JSON.stringify({ url: scan.startUrl, savedAt: scan.scannedAt, score: report }, null, 2)}\n`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
if (options.reportFile) {
|
|
186
|
+
await writeText(path.resolve(cwd, options.reportFile), renderAuditMarkdown(report, { scan, diff }));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
url: scan.startUrl,
|
|
191
|
+
total: report.total,
|
|
192
|
+
grade: report.grade,
|
|
193
|
+
counts: report.counts,
|
|
194
|
+
dimensions: report.dimensions,
|
|
195
|
+
platforms: report.platforms ?? [],
|
|
196
|
+
diff,
|
|
197
|
+
baselineStatus,
|
|
198
|
+
exitCode,
|
|
199
|
+
reasons,
|
|
200
|
+
summary,
|
|
201
|
+
};
|
|
202
|
+
}
|
package/lib/platforms/index.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { BAIDU_PROFILE } from './baidu.js';
|
|
9
9
|
import { BING_PROFILE } from './bing.js';
|
|
10
|
+
import { OPENAI_PROFILE } from './openai.js';
|
|
11
|
+
import { PERPLEXITY_PROFILE } from './perplexity.js';
|
|
10
12
|
|
|
11
|
-
export const PLATFORM_PROFILES = [BING_PROFILE, BAIDU_PROFILE];
|
|
13
|
+
export const PLATFORM_PROFILES = [BING_PROFILE, BAIDU_PROFILE, OPENAI_PROFILE, PERPLEXITY_PROFILE];
|
|
12
14
|
|
|
13
15
|
const STATUS_FACTOR = { pass: 1, warn: 0.5, fail: 0, skip: 0 };
|
|
14
16
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Search profile.
|
|
3
|
+
*
|
|
4
|
+
* OpenAI documents two independently controlled crawlers, and the distinction
|
|
5
|
+
* is the whole point of this profile: a site may allow `OAI-SearchBot` (used to
|
|
6
|
+
* surface pages in search results) while disallowing `GPTBot` (used for model
|
|
7
|
+
* training). Treating them as one "AI crawler" hides that choice.
|
|
8
|
+
*
|
|
9
|
+
* Sources (retrieved 2026-11-29):
|
|
10
|
+
* - Overview of OpenAI crawlers
|
|
11
|
+
* https://developers.openai.com/api/docs/bots
|
|
12
|
+
*
|
|
13
|
+
* Scope discipline: OpenAI publishes which crawlers exist and how to control
|
|
14
|
+
* them with robots.txt. It does not publish how ChatGPT chooses which pages to
|
|
15
|
+
* cite, so no rule here claims to model citation ranking.
|
|
16
|
+
*/
|
|
17
|
+
export const OPENAI_PROFILE = {
|
|
18
|
+
id: 'openai',
|
|
19
|
+
title: 'OpenAI / ChatGPT',
|
|
20
|
+
limitation: 'OpenAI 只公开了爬虫身份与 robots 控制方式,未公开 ChatGPT 如何选择引用页面;本 profile 只检查可抓取性与控制声明。',
|
|
21
|
+
sources: ['https://developers.openai.com/api/docs/bots'],
|
|
22
|
+
rules: [
|
|
23
|
+
{
|
|
24
|
+
id: 'openai.searchbot-access',
|
|
25
|
+
weight: 4,
|
|
26
|
+
title: 'OAI-SearchBot 可抓取',
|
|
27
|
+
fix: '若希望出现在 ChatGPT 搜索结果中,在 robots.txt 允许 OAI-SearchBot;它是搜索用途的独立爬虫,与训练用的 GPTBot 无关。',
|
|
28
|
+
evaluate({ scan }) {
|
|
29
|
+
if (!scan.robots.found) return { status: 'pass', evidence: '无 robots.txt,默认允许 OAI-SearchBot' };
|
|
30
|
+
if (scan.robots.unreachable) return { status: 'warn', evidence: 'robots.txt 不可访问,抓取状态不确定' };
|
|
31
|
+
const access = scan.robots.crawlers?.['OAI-SearchBot'];
|
|
32
|
+
if (!access) return { status: 'skip', evidence: '本次扫描未记录 OAI-SearchBot 状态' };
|
|
33
|
+
if (!access.allowed) return { status: 'fail', evidence: 'robots.txt 禁止 OAI-SearchBot,ChatGPT 搜索无法抓取' };
|
|
34
|
+
if (!access.named) return { status: 'warn', evidence: 'OAI-SearchBot 未被点名,按 * 规则放行' };
|
|
35
|
+
return { status: 'pass', evidence: 'robots.txt 显式允许 OAI-SearchBot' };
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'openai.searchbot-vs-training',
|
|
40
|
+
weight: 2,
|
|
41
|
+
title: '搜索与训练爬虫分开声明',
|
|
42
|
+
fix: '把 OAI-SearchBot 与 GPTBot 分开写进 robots.txt:前者决定能否被搜索到,后者决定内容是否用于训练,混为一谈会误伤其一。',
|
|
43
|
+
evaluate({ scan }) {
|
|
44
|
+
if (!scan.robots.found) return { status: 'warn', evidence: '无 robots.txt,两个爬虫都依赖默认放行' };
|
|
45
|
+
const search = scan.robots.crawlers?.['OAI-SearchBot'];
|
|
46
|
+
const training = scan.robots.crawlers?.GPTBot;
|
|
47
|
+
if (!search || !training) return { status: 'skip', evidence: '本次扫描未记录完整爬虫状态' };
|
|
48
|
+
if (search.named && training.named) {
|
|
49
|
+
return { status: 'pass', evidence: `OAI-SearchBot=${search.allowed ? 'allow' : 'deny'} / GPTBot=${training.allowed ? 'allow' : 'deny'},两者均已点名` };
|
|
50
|
+
}
|
|
51
|
+
if (search.named || training.named) {
|
|
52
|
+
const missing = search.named ? 'GPTBot' : 'OAI-SearchBot';
|
|
53
|
+
return { status: 'warn', evidence: `只声明了其中一个,${missing} 依赖 * 规则` };
|
|
54
|
+
}
|
|
55
|
+
return { status: 'warn', evidence: '两个爬虫都未点名,搜索与训练策略无法区分' };
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'openai.no-accidental-block',
|
|
60
|
+
weight: 3,
|
|
61
|
+
title: '未因训练策略误伤搜索抓取',
|
|
62
|
+
fix: '只封 GPTBot 不影响搜索;但若用 User-agent: * 或同时封禁两者来阻止训练,站点也会从 ChatGPT 搜索中消失。按需分开设置。',
|
|
63
|
+
evaluate({ scan }) {
|
|
64
|
+
if (!scan.robots.found) return { status: 'pass', evidence: '无 robots.txt,没有针对性封禁' };
|
|
65
|
+
const search = scan.robots.crawlers?.['OAI-SearchBot'];
|
|
66
|
+
const training = scan.robots.crawlers?.GPTBot;
|
|
67
|
+
if (!search || !training) return { status: 'skip', evidence: '本次扫描未记录完整爬虫状态' };
|
|
68
|
+
if (search.allowed && !training.allowed) {
|
|
69
|
+
return { status: 'pass', evidence: '仅禁止 GPTBot,OAI-SearchBot 仍可抓取(常见且合理的配置)' };
|
|
70
|
+
}
|
|
71
|
+
if (!search.allowed && !training.allowed) {
|
|
72
|
+
return { status: 'fail', evidence: '两个爬虫都被禁止,站点不会出现在 ChatGPT 搜索中' };
|
|
73
|
+
}
|
|
74
|
+
if (!search.allowed && training.allowed) {
|
|
75
|
+
return { status: 'warn', evidence: 'OAI-SearchBot 被禁但 GPTBot 允许:不接受搜索可见,却允许训练使用内容' };
|
|
76
|
+
}
|
|
77
|
+
return { status: 'pass', evidence: '两个爬虫均可抓取' };
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'openai.content-reachable',
|
|
82
|
+
weight: 2,
|
|
83
|
+
title: '原始 HTML 有可读正文',
|
|
84
|
+
fix: '保证正文出现在服务端输出的 HTML 中;只依赖客户端渲染的页面,对不执行脚本的抓取器不可读。',
|
|
85
|
+
evaluate({ primary }) {
|
|
86
|
+
if (!primary) return { status: 'fail', evidence: '未抓取到 HTML 入口页' };
|
|
87
|
+
const length = primary.facts.contentLength ?? primary.facts.textLength;
|
|
88
|
+
if (length >= 600) return { status: 'pass', evidence: `原始 HTML 含 ${length} 字正文` };
|
|
89
|
+
if (length >= 250) return { status: 'warn', evidence: `原始 HTML 仅 ${length} 字正文` };
|
|
90
|
+
return { status: 'fail', evidence: `原始 HTML 仅 ${length} 字正文,正文依赖脚本渲染` };
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perplexity profile.
|
|
3
|
+
*
|
|
4
|
+
* Perplexity documents separate crawlers for indexing and for user-triggered
|
|
5
|
+
* fetches. `PerplexityBot` builds the search index; `Perplexity-User` visits a
|
|
6
|
+
* page because a person asked about it. Blocking only the second changes what
|
|
7
|
+
* happens during a live answer without removing the site from the index.
|
|
8
|
+
*
|
|
9
|
+
* Sources (retrieved 2026-11-29):
|
|
10
|
+
* - Perplexity crawlers
|
|
11
|
+
* https://docs.perplexity.ai/docs/resources/perplexity-crawlers
|
|
12
|
+
*
|
|
13
|
+
* Scope discipline: Perplexity publishes crawler identity and robots handling.
|
|
14
|
+
* It does not publish a citation ranking formula, so no rule here models one.
|
|
15
|
+
*/
|
|
16
|
+
export const PERPLEXITY_PROFILE = {
|
|
17
|
+
id: 'perplexity',
|
|
18
|
+
title: 'Perplexity',
|
|
19
|
+
limitation: 'Perplexity 公开了爬虫身份与 robots 遵循规则,未公开引用排序公式;本 profile 只检查抓取可达性与控制声明。',
|
|
20
|
+
sources: [
|
|
21
|
+
'https://docs.perplexity.ai/docs/resources/perplexity-crawlers',
|
|
22
|
+
'https://www.perplexity.ai/help-center/en/articles/10354969-how-does-perplexity-follow-robots-txt',
|
|
23
|
+
],
|
|
24
|
+
rules: [
|
|
25
|
+
{
|
|
26
|
+
id: 'perplexity.bot-access',
|
|
27
|
+
weight: 4,
|
|
28
|
+
title: 'PerplexityBot 可抓取',
|
|
29
|
+
fix: '若希望被 Perplexity 检索,在 robots.txt 允许 PerplexityBot;它负责建立搜索索引。',
|
|
30
|
+
evaluate({ scan }) {
|
|
31
|
+
if (!scan.robots.found) return { status: 'pass', evidence: '无 robots.txt,默认允许 PerplexityBot' };
|
|
32
|
+
if (scan.robots.unreachable) return { status: 'warn', evidence: 'robots.txt 不可访问,抓取状态不确定' };
|
|
33
|
+
const access = scan.robots.crawlers?.PerplexityBot;
|
|
34
|
+
if (!access) return { status: 'skip', evidence: '本次扫描未记录 PerplexityBot 状态' };
|
|
35
|
+
if (!access.allowed) return { status: 'fail', evidence: 'robots.txt 禁止 PerplexityBot,站点无法进入其索引' };
|
|
36
|
+
if (!access.named) return { status: 'warn', evidence: 'PerplexityBot 未被点名,按 * 规则放行' };
|
|
37
|
+
return { status: 'pass', evidence: 'robots.txt 显式允许 PerplexityBot' };
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'perplexity.user-crawler',
|
|
42
|
+
weight: 2,
|
|
43
|
+
title: 'Perplexity-User 未被误封',
|
|
44
|
+
fix: 'Perplexity-User 只用于用户提问时的实时抓取。单独禁止它不会移除已收录内容,但会让实时引用拿不到最新页面。',
|
|
45
|
+
evaluate({ scan }) {
|
|
46
|
+
if (!scan.robots.found) return { status: 'pass', evidence: '无 robots.txt,默认允许 Perplexity-User' };
|
|
47
|
+
const access = scan.robots.crawlers?.['Perplexity-User'];
|
|
48
|
+
if (!access) return { status: 'skip', evidence: '本次扫描未记录 Perplexity-User 状态' };
|
|
49
|
+
if (!access.allowed) return { status: 'warn', evidence: 'Perplexity-User 被禁止,用户提问时的实时抓取会失败' };
|
|
50
|
+
if (!access.named) return { status: 'pass', evidence: '未点名,按 * 规则放行' };
|
|
51
|
+
return { status: 'pass', evidence: 'robots.txt 显式允许 Perplexity-User' };
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'perplexity.index-vs-fetch',
|
|
56
|
+
weight: 2,
|
|
57
|
+
title: '索引与实时抓取策略一致',
|
|
58
|
+
fix: '检查两个 Perplexity 爬虫的配置是否符合意图:只封 Perplexity-User 保留索引,同时封两个则完全退出 Perplexity。',
|
|
59
|
+
evaluate({ scan }) {
|
|
60
|
+
if (!scan.robots.found) return { status: 'skip', evidence: '无 robots.txt,两者都依赖默认规则' };
|
|
61
|
+
const index = scan.robots.crawlers?.PerplexityBot;
|
|
62
|
+
const user = scan.robots.crawlers?.['Perplexity-User'];
|
|
63
|
+
if (!index || !user) return { status: 'skip', evidence: '本次扫描未记录完整爬虫状态' };
|
|
64
|
+
if (index.allowed && user.allowed) return { status: 'pass', evidence: '索引与实时抓取均允许' };
|
|
65
|
+
if (index.allowed && !user.allowed) {
|
|
66
|
+
return { status: 'pass', evidence: '保留索引、限制实时抓取(明确的取舍)' };
|
|
67
|
+
}
|
|
68
|
+
if (!index.allowed && user.allowed) {
|
|
69
|
+
return { status: 'warn', evidence: '索引被禁但实时抓取允许:引用只能来自实时访问,稳定性依赖页面可访问' };
|
|
70
|
+
}
|
|
71
|
+
return { status: 'fail', evidence: '两个爬虫都被禁止,站点不会出现在 Perplexity 结果中' };
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'perplexity.content-reachable',
|
|
76
|
+
weight: 2,
|
|
77
|
+
title: '原始 HTML 有可读正文',
|
|
78
|
+
fix: '保证正文出现在服务端输出的 HTML 中;实时抓取同样不保证执行完整脚本。',
|
|
79
|
+
evaluate({ primary }) {
|
|
80
|
+
if (!primary) return { status: 'fail', evidence: '未抓取到 HTML 入口页' };
|
|
81
|
+
const length = primary.facts.contentLength ?? primary.facts.textLength;
|
|
82
|
+
if (length >= 600) return { status: 'pass', evidence: `原始 HTML 含 ${length} 字正文` };
|
|
83
|
+
if (length >= 250) return { status: 'warn', evidence: `原始 HTML 仅 ${length} 字正文` };
|
|
84
|
+
return { status: 'fail', evidence: `原始 HTML 仅 ${length} 字正文,正文依赖脚本渲染` };
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
package/lib/robots.js
CHANGED
|
@@ -215,6 +215,24 @@ export function baiduspiderAccess(robots) {
|
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Access for a named crawler, distinguishing "named in robots.txt" from
|
|
220
|
+
* "falls back to the * group". The distinction matters for AI crawlers: a site
|
|
221
|
+
* that blocks one model's crawler is making a deliberate choice, while a site
|
|
222
|
+
* that never mentions it is relying on the default.
|
|
223
|
+
* @param {ReturnType<typeof parseRobots>} robots
|
|
224
|
+
* @param {string} userAgent - Crawler product token, e.g. `OAI-SearchBot`.
|
|
225
|
+
* @param {string} [path] - Path to test; defaults to the site root.
|
|
226
|
+
*/
|
|
227
|
+
export function crawlerAccess(robots, userAgent, path = '/') {
|
|
228
|
+
const agent = String(userAgent).toLowerCase();
|
|
229
|
+
const named = robots.groups.some((group) => group.agents.includes(agent));
|
|
230
|
+
return {
|
|
231
|
+
named,
|
|
232
|
+
allowed: isAllowed(robots, path, userAgent),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
218
236
|
/**
|
|
219
237
|
* True when the file forbids the whole site to everyone.
|
|
220
238
|
* @param {ReturnType<typeof parseRobots>} robots
|
package/lib/scan.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
import { analyzeHtml } from './html.js';
|
|
15
15
|
import { createTransport, DEFAULT_USER_AGENT, FetchError } from './fetch.js';
|
|
16
16
|
import {
|
|
17
|
-
aiCrawlerPolicy, baiduspiderAccess, bingbotAccess, blocksEverything,
|
|
18
|
-
googlebotAccess, isAllowed, parseRobots,
|
|
17
|
+
aiCrawlerPolicy, baiduspiderAccess, bingbotAccess, blocksEverything, crawlerAccess,
|
|
18
|
+
crawlDelayMs, googlebotAccess, isAllowed, parseRobots,
|
|
19
19
|
} from './robots.js';
|
|
20
20
|
|
|
21
21
|
export const SCAN_VERSION = 'scan@1';
|
|
@@ -243,6 +243,12 @@ export async function scanSite(input, options = {}) {
|
|
|
243
243
|
googlebot: robotsFound ? googlebotAccess(robots) : { allowed: true, imageAllowed: true },
|
|
244
244
|
bingbot: robotsFound ? bingbotAccess(robots) : { allowed: true, previewAllowed: true },
|
|
245
245
|
baiduspider: robotsFound ? baiduspiderAccess(robots) : { allowed: true, renderAllowed: true },
|
|
246
|
+
crawlers: {
|
|
247
|
+
'OAI-SearchBot': robotsFound ? crawlerAccess(robots, 'OAI-SearchBot') : { named: false, allowed: true },
|
|
248
|
+
GPTBot: robotsFound ? crawlerAccess(robots, 'GPTBot') : { named: false, allowed: true },
|
|
249
|
+
PerplexityBot: robotsFound ? crawlerAccess(robots, 'PerplexityBot') : { named: false, allowed: true },
|
|
250
|
+
'Perplexity-User': robotsFound ? crawlerAccess(robots, 'Perplexity-User') : { named: false, allowed: true },
|
|
251
|
+
},
|
|
246
252
|
crawlDelayMs: robotsFound ? crawlDelayMs(robots, settings.userAgent) : 0,
|
|
247
253
|
sitemapDeclarations: robots.sitemaps.slice(0, 10),
|
|
248
254
|
unreachable: robotsUnreachable,
|
|
@@ -305,6 +311,12 @@ export async function scanSite(input, options = {}) {
|
|
|
305
311
|
googlebot: robotsFound ? googlebotAccess(robots) : { allowed: true, imageAllowed: true },
|
|
306
312
|
bingbot: robotsFound ? bingbotAccess(robots) : { allowed: true, previewAllowed: true },
|
|
307
313
|
baiduspider: robotsFound ? baiduspiderAccess(robots) : { allowed: true, renderAllowed: true },
|
|
314
|
+
crawlers: {
|
|
315
|
+
'OAI-SearchBot': robotsFound ? crawlerAccess(robots, 'OAI-SearchBot') : { named: false, allowed: true },
|
|
316
|
+
GPTBot: robotsFound ? crawlerAccess(robots, 'GPTBot') : { named: false, allowed: true },
|
|
317
|
+
PerplexityBot: robotsFound ? crawlerAccess(robots, 'PerplexityBot') : { named: false, allowed: true },
|
|
318
|
+
'Perplexity-User': robotsFound ? crawlerAccess(robots, 'Perplexity-User') : { named: false, allowed: true },
|
|
319
|
+
},
|
|
308
320
|
crawlDelayMs: robotsFound ? crawlDelayMs(robots, settings.userAgent) : 0,
|
|
309
321
|
sitemapDeclarations: robots.sitemaps.slice(0, 10),
|
|
310
322
|
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.
|
|
3
|
+
"version": "0.7.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": {
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
"CONTRIBUTING.md",
|
|
41
41
|
"CHANGELOG.md",
|
|
42
42
|
".github/workflows/publish.yml",
|
|
43
|
-
"docs/NPM-TRUSTED-PUBLISHING.md"
|
|
43
|
+
"docs/NPM-TRUSTED-PUBLISHING.md",
|
|
44
|
+
"action.yml",
|
|
45
|
+
"examples"
|
|
44
46
|
],
|
|
45
47
|
"engines": {
|
|
46
48
|
"dsh": ">=0.2.2-rc.5 <0.3.0"
|