seo-supervisor 1.2.0 → 2.0.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/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +16 -3
- package/CHANGELOG.md +430 -0
- package/NOTICE +7 -0
- package/README.md +230 -25
- package/agents/seo-auditor.md +16 -0
- package/agents/seo-reviewer.md +16 -0
- package/bin/agents.mjs +194 -29
- package/bin/extras.mjs +422 -0
- package/bin/prompt.mjs +34 -14
- package/bin/seo-supervisor.mjs +386 -53
- package/commands/seo-audit.md +29 -3
- package/commands/seo-brief.md +28 -0
- package/commands/seo-connect.md +27 -0
- package/commands/seo-fix.md +24 -3
- package/commands/seo-grow.md +26 -0
- package/commands/seo-launch.md +17 -3
- package/commands/seo-review.md +13 -1
- package/commands/seo-rewrite.md +25 -0
- package/commands/seo-setup.md +17 -1
- package/commands/seo-watch.md +28 -0
- package/hooks/hooks.json +117 -0
- package/package.json +20 -7
- package/skills/seo-supervisor/NOTICE +7 -0
- package/skills/seo-supervisor/SKILL.md +302 -21
- package/skills/seo-supervisor/audience.md +61 -0
- package/skills/seo-supervisor/examples/drafts/security.md +41 -0
- package/skills/seo-supervisor/examples/hooks/README.md +28 -0
- package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
- package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
- package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
- package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
- package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
- package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
- package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
- package/skills/seo-supervisor/examples/sample-audit.json +94 -2
- package/skills/seo-supervisor/examples/sample-report.html +111 -61
- package/skills/seo-supervisor/examples/sample-report.md +147 -44
- package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
- package/skills/seo-supervisor/examples/snippets.md +648 -1
- package/skills/seo-supervisor/grow.md +342 -0
- package/skills/seo-supervisor/og-images.md +85 -0
- package/skills/seo-supervisor/page-types.md +124 -0
- package/skills/seo-supervisor/planning.md +19 -7
- package/skills/seo-supervisor/profile-template.md +41 -0
- package/skills/seo-supervisor/report-format.md +177 -10
- package/skills/seo-supervisor/rewrite.md +59 -0
- package/skills/seo-supervisor/rules/ai-search.md +65 -12
- package/skills/seo-supervisor/rules/content.md +33 -9
- package/skills/seo-supervisor/rules/crawl-index.md +33 -6
- package/skills/seo-supervisor/rules/internal-linking.md +49 -6
- package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
- package/skills/seo-supervisor/rules/media.md +13 -1
- package/skills/seo-supervisor/rules/metadata.md +41 -9
- package/skills/seo-supervisor/rules/performance.md +50 -5
- package/skills/seo-supervisor/rules/rendering.md +39 -2
- package/skills/seo-supervisor/rules/search-intent.md +32 -0
- package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
- package/skills/seo-supervisor/rules/structured-data.md +37 -14
- package/skills/seo-supervisor/rules/trust-security.md +25 -2
- package/skills/seo-supervisor/rules/urls.md +10 -2
- package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
- package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
- package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
- package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
- package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
- package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
- package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
- package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
- package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
- package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
- package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
- package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
- package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
- package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
- package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
- package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
- package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
- package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
- package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
- package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
- package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
- package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
- package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
- package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
- package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
- package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
- package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
- package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
- package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
- package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
- package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
- package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
- package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
- package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
- package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
- package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
- package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
- package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
- package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
- package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
- package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
- package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
- package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
- package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
- package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
- package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
- package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
- package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
- package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
- package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
- package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
- package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
- package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
- package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
- package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
- package/skills/seo-supervisor/scripts/google.mjs +1341 -0
- package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
- package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
- package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
- package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
- package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
- package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
- package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
- package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
- package/skills/seo-supervisor/scripts/guard.mjs +74 -0
- package/skills/seo-supervisor/scripts/images.mjs +408 -0
- package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
- package/skills/seo-supervisor/scripts/issues.mjs +217 -0
- package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
- package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
- package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
- package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
- package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
- package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
- package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
- package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
- package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
- package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
- package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
- package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
- package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
- package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
- package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
- package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
- package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
- package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
- package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
- package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
- package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
- package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
- package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
- package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
- package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
- package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
- package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
- package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
- package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
- package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
- package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
- package/skills/seo-supervisor/scripts/osm.mjs +359 -0
- package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
- package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
- package/skills/seo-supervisor/scripts/report/client.js +37 -0
- package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
- package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
- package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
- package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
- package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
- package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
- package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
- package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
- package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
- package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
- package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
- package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
- package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
- package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
- package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
- package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
- package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
- package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
- package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
- package/skills/seo-supervisor/scripts/report/styles.css +223 -0
- package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
- package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
- package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
- package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
- package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
- package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
- package/skills/seo-supervisor/site-types/content.md +34 -1
- package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
- package/skills/seo-supervisor/site-types/local-business.md +96 -6
- package/skills/seo-supervisor/site-types/services.md +46 -0
- package/skills/seo-supervisor/site-types/tools.md +3 -3
- package/skills/seo-supervisor/strategy.md +232 -0
- package/skills/seo-supervisor/troubleshooting.md +56 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// robots.txt checks, and the AI crawler access the report shows. Parsing and matching live in lib/robots.mjs.
|
|
3
|
+
import { AI_BOTS, signalPlacement, aiRobots } from "./agents.mjs";
|
|
4
|
+
import { quote } from "../lib/findings.mjs";
|
|
5
|
+
import { allowedBy, groupFor, groupOf, parseRobots } from "../lib/robots.mjs";
|
|
6
|
+
export { allowedBy, groupFor, groupOf, parseRobots, ruleRe } from "../lib/robots.mjs";
|
|
7
|
+
|
|
8
|
+
// Returns the parsed rules (null when unreadable), whether the server failed, and the `User-agent: *` group.
|
|
9
|
+
export function checkRobots(robotsRes, { add, evalRules, startOrigin: START_ORIGIN }) {
|
|
10
|
+
const robots =
|
|
11
|
+
robotsRes.status === 200 && robotsRes.body && !/<html/i.test(robotsRes.body) ? parseRobots(robotsRes.body) : null;
|
|
12
|
+
// Google treats a 4xx other than 429 as no rules, and a 5xx, 429 or no answer as a server error that halts crawling.
|
|
13
|
+
// After five redirects it treats the file as missing.
|
|
14
|
+
// https://developers.google.com/search/docs/crawling-indexing/robots/robots_txt
|
|
15
|
+
const robotsHops = robotsRes.error === "too many redirects" ? robotsRes.chain.map(c => c.url) : null;
|
|
16
|
+
const robotsDown = !robotsHops && (robotsRes.status >= 500 || robotsRes.status === 429 || robotsRes.status === 0);
|
|
17
|
+
evalRules("CRAWL-01", ...(robotsDown ? [] : ["MAP-01", "MAP-05", "MAP-06"]));
|
|
18
|
+
const star = robots ? groupFor(robots, "*") : null;
|
|
19
|
+
if (robotsDown)
|
|
20
|
+
add(
|
|
21
|
+
"robots-server-error",
|
|
22
|
+
START_ORIGIN + "/robots.txt",
|
|
23
|
+
robotsRes.status ? `status ${robotsRes.status}` : `no answer: ${robotsRes.error}`,
|
|
24
|
+
);
|
|
25
|
+
else if (robotsHops) {
|
|
26
|
+
const again = robotsHops.findIndex((u, i) => robotsHops.indexOf(u) < i);
|
|
27
|
+
add(
|
|
28
|
+
"robots-missing",
|
|
29
|
+
START_ORIGIN + "/robots.txt",
|
|
30
|
+
`${again > 0 ? `a redirect loop: ${[...robotsHops.slice(0, again), robotsHops[again]].join(" → ")}` : `more than 5 redirects: ${robotsHops[0]} → … → ${robotsHops.at(-1)}`}. Google stops after 5 and reads that as no robots.txt`,
|
|
31
|
+
);
|
|
32
|
+
} else if (!robots)
|
|
33
|
+
add(
|
|
34
|
+
"robots-missing",
|
|
35
|
+
START_ORIGIN + "/robots.txt",
|
|
36
|
+
robotsRes.status !== 200
|
|
37
|
+
? `status ${robotsRes.status}`
|
|
38
|
+
: robotsRes.body
|
|
39
|
+
? "returns an HTML page instead (soft 404)"
|
|
40
|
+
: "an empty file",
|
|
41
|
+
);
|
|
42
|
+
else {
|
|
43
|
+
// Judged as Googlebot reads it: its own group if it has one, else `User-agent: *`.
|
|
44
|
+
const google = groupOf(robots, "googlebot"),
|
|
45
|
+
which = groupFor(robots, "googlebot")
|
|
46
|
+
? "Googlebot's own group (User-agent: Googlebot)"
|
|
47
|
+
: "User-agent: *, which Googlebot follows as it has no group of its own,";
|
|
48
|
+
if (google && !allowedBy(google, "/"))
|
|
49
|
+
add("robots-blocks-all", START_ORIGIN + "/robots.txt", `${which} is not allowed to crawl /`);
|
|
50
|
+
for (const p of ["/_next/static/x.js", "/assets/x.js", "/static/x.css", "/x.css", "/x.js"])
|
|
51
|
+
if (google && !allowedBy(google, p) && allowedBy(google, "/"))
|
|
52
|
+
add("robots-blocks-assets", START_ORIGIN + "/robots.txt", `blocks ${p.replace(/x\.(js|css)$/, "")}`);
|
|
53
|
+
// Only a bot's own group counts here; a block by `User-agent: *` shows in the AI bot table instead.
|
|
54
|
+
for (const [bot, , , , { alias } = {}] of AI_BOTS) {
|
|
55
|
+
const g = ownGroup(robots, bot, alias);
|
|
56
|
+
if (g && !allowedBy(g, "/")) add("ai-bots-blocked", START_ORIGIN + "/robots.txt", bot);
|
|
57
|
+
}
|
|
58
|
+
if (!robots.sitemaps.length) add("sitemap-not-in-robots", START_ORIGIN + "/robots.txt");
|
|
59
|
+
// A line may start with the path it applies to: `Content-Signal: /blog/ search=yes`. https://contentsignals.org
|
|
60
|
+
for (const m of robotsRes.body.matchAll(/^\s*content-signal\s*:\s*(?:\/\S*\s+)?(.*)$/gim))
|
|
61
|
+
for (const pair of m[1]
|
|
62
|
+
.split(",")
|
|
63
|
+
.map(x => x.trim())
|
|
64
|
+
.filter(Boolean)) {
|
|
65
|
+
// The policy's three keys, plus the use= field Cloudflare is testing in its managed robots.txt.
|
|
66
|
+
const [k, v] = pair.split("=").map(x => (x || "").trim().toLowerCase());
|
|
67
|
+
if (!/^(?:(?:search|ai-input|ai-train)=(?:yes|no)|use=(?:immediate|reference|full))$/.test(`${k}=${v}`))
|
|
68
|
+
add("content-signal-invalid", START_ORIGIN + "/robots.txt", pair);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { robots, robotsDown, star };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// A versioned user-agent still matches by its bare name, so this is a note, not a finding.
|
|
75
|
+
export function versionedNote(robots, notes) {
|
|
76
|
+
if (robots?.versioned.length) {
|
|
77
|
+
const v = robots.versioned[0],
|
|
78
|
+
bare = /^[A-Za-z_-]+/.exec(v)[0];
|
|
79
|
+
const more = robots.versioned.length - 3;
|
|
80
|
+
notes.push(
|
|
81
|
+
`robots.txt names ${robots.versioned
|
|
82
|
+
.slice(0, 3)
|
|
83
|
+
.map(x => `User-agent: ${quote(x)}`)
|
|
84
|
+
.join(
|
|
85
|
+
", ",
|
|
86
|
+
)}${more > 0 ? ` and ${more} more` : ""} with more than the crawler's name. Google reads only the name, up to the first character that isn't a letter, "_" or "-", so ${quote(v)} counts as ${bare}. RFC 9309 allows only those characters, so other crawlers may not match it: write the bare name, such as \`User-agent: ${bare}\`.`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The group naming the bot, or the second name its vendor accepts.
|
|
92
|
+
const ownGroup = (robots, bot, alias) => groupFor(robots, bot) || (alias ? groupFor(robots, alias) : null);
|
|
93
|
+
|
|
94
|
+
// Each AI bot's access: its own group, else `User-agent: *`. Also flags Content-Signal lines crawlers won't read.
|
|
95
|
+
// https://www.rfc-editor.org/rfc/rfc9309#section-2.2.1
|
|
96
|
+
export function aiBotAccess({ robots, robotsRes, star }, { add, extra, startOrigin: START_ORIGIN }) {
|
|
97
|
+
if (robots) {
|
|
98
|
+
// Applebot falls back to Googlebot's group when it isn't named (https://support.apple.com/en-us/119829), and
|
|
99
|
+
// YandexAdditional reads only its own group, never `*`.
|
|
100
|
+
extra.aiBots = AI_BOTS.map(([bot, vendor, kind, mayIgnore, { alias, fallback, ownGroupOnly } = {}]) => {
|
|
101
|
+
const own = ownGroup(robots, bot, alias),
|
|
102
|
+
via = !own && fallback ? groupFor(robots, fallback) : null,
|
|
103
|
+
g = own || via || (ownGroupOnly ? null : star);
|
|
104
|
+
return {
|
|
105
|
+
bot,
|
|
106
|
+
vendor,
|
|
107
|
+
kind,
|
|
108
|
+
robots:
|
|
109
|
+
!g || allowedBy(g, "/")
|
|
110
|
+
? "allowed"
|
|
111
|
+
: own
|
|
112
|
+
? "blocked"
|
|
113
|
+
: via
|
|
114
|
+
? `blocked-by-${fallback.toLowerCase()}`
|
|
115
|
+
: "blocked-by-star",
|
|
116
|
+
...(mayIgnore ? { mayIgnore } : {}),
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
// The shared AI-training opt-out (IETF draft-kelley-aipref-training-preference-signal) matches only its own group.
|
|
120
|
+
const shared = groupFor(robots, "__usage_ai-training");
|
|
121
|
+
extra.trainingOptOut = !shared
|
|
122
|
+
? "not-set"
|
|
123
|
+
: !allowedBy(shared, "/")
|
|
124
|
+
? "blocked"
|
|
125
|
+
: shared.rules.some(x => !x.allow && x.path)
|
|
126
|
+
? "partly"
|
|
127
|
+
: "allowed";
|
|
128
|
+
for (const d of signalPlacement(robotsRes.body, g => !allowedBy(g, "/")))
|
|
129
|
+
add("content-signal-placement", START_ORIGIN + "/robots.txt", d);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// AI crawler rules that contradict each other, aipref Content-Usage lines, and Cloudflare's managed block. Both of
|
|
134
|
+
// Cloudflare's markers set botPreferenceSync, the field older reports use.
|
|
135
|
+
// https://developers.cloudflare.com/bots/additional-configurations/managed-robots-txt/
|
|
136
|
+
export function aiRobotRules({ robots, robotsRes }, { add, extra, startOrigin: START_ORIGIN }) {
|
|
137
|
+
if (robots) {
|
|
138
|
+
const ai = aiRobots(robotsRes.body, allowedBy);
|
|
139
|
+
for (const c of ai.conflicts) add("ai-robots-conflict", START_ORIGIN + "/robots.txt", c);
|
|
140
|
+
if (ai.usage.length) extra.contentUsage = ai.usage;
|
|
141
|
+
if (/^\s*#\s*BEGIN Cloudflare (?:Bot Preference Sync|Managed content)\b/im.test(robotsRes.body))
|
|
142
|
+
extra.botPreferenceSync = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Structured data checks shared by the crawler and schema-check.mjs, which re-exports them.
|
|
3
|
+
import { isA, isBusinessType, schemaTypes } from "../lib/business.mjs";
|
|
4
|
+
|
|
5
|
+
const term = s => s.replace(/^(?:https?:\/\/schema\.org\/|schema:)/, "");
|
|
6
|
+
const list = x => [].concat(x ?? []);
|
|
7
|
+
const clip = s => (s.length > 60 ? s.slice(0, 57) + "…" : s);
|
|
8
|
+
|
|
9
|
+
// A merchant listing is a Product sold with an Offer, not an AggregateOffer. It needs an image, a price above zero, an
|
|
10
|
+
// ISO 4217 priceCurrency and one availability value, as the URL or its short name. The crawler reads these too.
|
|
11
|
+
export const MERCHANT_DOC = "https://developers.google.com/search/docs/appearance/structured-data/merchant-listing";
|
|
12
|
+
// Every current alphabetic code in ISO 4217 List One, as its maintenance agency SIX published it on 17 Sep 2026.
|
|
13
|
+
export const ISO_4217 = new Set(
|
|
14
|
+
(
|
|
15
|
+
"AED AFN ALL AMD AOA ARS AUD AWG AZN BAM BBD BDT BHD BIF BMD BND BOB BOV BRL BSD BTN BWP BYN BZD CAD CDF CHE " +
|
|
16
|
+
"CHF CHW CLF CLP CNY COP COU CRC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HTG HUF IDR " +
|
|
17
|
+
"ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRU MUR MVR MWK " +
|
|
18
|
+
"MXN MXV MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLE SOS SRD SSP " +
|
|
19
|
+
"STN SVC SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD USN UYI UYU UYW UZS VED VES VND VUV WST XAD XAF XAG XAU XBA XBB XBC XBD " +
|
|
20
|
+
"XCD XCG XDR XOF XPD XPF XPT XSU XTS XUA XXX YER ZAR ZMW ZWG"
|
|
21
|
+
).split(" "),
|
|
22
|
+
);
|
|
23
|
+
// ItemAvailability's members in schema.org V30.1. Google lists ten and accepts short names; MadeToOrder and Reserved
|
|
24
|
+
// are schema.org's too, so they aren't flagged.
|
|
25
|
+
// https://schema.org/ItemAvailability
|
|
26
|
+
const AVAILABILITY = new Set(
|
|
27
|
+
"BackOrder Discontinued InStock InStoreOnly LimitedAvailability MadeToOrder OnlineOnly OutOfStock PreOrder PreSale Reserved SoldOut".split(
|
|
28
|
+
" ",
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
// Stand-ins for a brand. Merchant Center's help says to leave brand out rather than guess, and to use the shop's name
|
|
32
|
+
// for its own products.
|
|
33
|
+
const NO_BRAND =
|
|
34
|
+
/^(?:n\/?a|none|no brand|unbranded|generic|unknown|not applicable|does not exist|null|undefined|-+)?$/i;
|
|
35
|
+
const typeIs = (o, t) => list(o?.["@type"]).some(x => typeof x === "string" && term(x) === t);
|
|
36
|
+
/** A Product sold with an Offer rather than an AggregateOffer: one Google's merchant listings are for. */
|
|
37
|
+
export const sellsWithOffer = p =>
|
|
38
|
+
list(p?.offers).some(o => o && typeof o === "object" && !typeIs(o, "AggregateOffer"));
|
|
39
|
+
/** The values in a Product's offers and brand that Google's merchant listings reject or ignore. */
|
|
40
|
+
export function merchantProblems(p) {
|
|
41
|
+
const out = [],
|
|
42
|
+
say = (check, severity, key, value, message) => out.push({ check, severity, key, value: String(value), message });
|
|
43
|
+
for (const o of list(p?.offers).filter(o => o && typeof o === "object")) {
|
|
44
|
+
const specs = list(o.priceSpecification).filter(s => s && typeof s === "object");
|
|
45
|
+
const price = o.price ?? specs.find(s => !/StrikethroughPrice$/.test(String(s.priceType ?? "")))?.price;
|
|
46
|
+
if (!typeIs(o, "AggregateOffer") && String(price ?? "").trim() !== "" && Number(price) === 0)
|
|
47
|
+
say(
|
|
48
|
+
"price-zero",
|
|
49
|
+
"warning",
|
|
50
|
+
"price",
|
|
51
|
+
price,
|
|
52
|
+
`"price" is ${price}; Google's merchant listings need a price above zero (product snippets accept 0)`,
|
|
53
|
+
);
|
|
54
|
+
for (const c of [o.priceCurrency, ...specs.map(s => s.priceCurrency)])
|
|
55
|
+
if (typeof c === "string" && !ISO_4217.has(c.trim().toUpperCase()))
|
|
56
|
+
say(
|
|
57
|
+
"currency-invalid",
|
|
58
|
+
"error",
|
|
59
|
+
"priceCurrency",
|
|
60
|
+
c,
|
|
61
|
+
`"priceCurrency" is "${clip(c)}"; Google wants a three-letter ISO 4217 code, such as "USD", "EUR" or "GBP"`,
|
|
62
|
+
);
|
|
63
|
+
const av = list(o.availability).map(x => (typeof x === "string" ? x : x?.["@id"]));
|
|
64
|
+
if (av.length > 1)
|
|
65
|
+
say(
|
|
66
|
+
"availability-invalid",
|
|
67
|
+
"warning",
|
|
68
|
+
"availability",
|
|
69
|
+
av.join(", "),
|
|
70
|
+
`"availability" has ${av.length} values; Google wants one, such as "https://schema.org/InStock"`,
|
|
71
|
+
);
|
|
72
|
+
else if (av.length && !(typeof av[0] === "string" && AVAILABILITY.has(term(av[0].trim()))))
|
|
73
|
+
say(
|
|
74
|
+
"availability-invalid",
|
|
75
|
+
"warning",
|
|
76
|
+
"availability",
|
|
77
|
+
av[0],
|
|
78
|
+
`"availability" is "${clip(String(av[0]))}"; use one of schema.org's ItemAvailability values, such as "https://schema.org/InStock" or "https://schema.org/OutOfStock"`,
|
|
79
|
+
);
|
|
80
|
+
if (typeof o.priceValidUntil === "string" && Date.parse(o.priceValidUntil) < Date.now() - 864e5)
|
|
81
|
+
say(
|
|
82
|
+
"price-expired",
|
|
83
|
+
"warning",
|
|
84
|
+
"priceValidUntil",
|
|
85
|
+
o.priceValidUntil,
|
|
86
|
+
`"priceValidUntil" is ${clip(o.priceValidUntil)}, in the past; Google says the listing may not show`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
for (const b of list(p?.brand)) {
|
|
90
|
+
const name = typeof b === "string" ? b : b && typeof b === "object" && "name" in b ? b.name : null;
|
|
91
|
+
if (typeof name === "string" && NO_BRAND.test(name.trim()))
|
|
92
|
+
say(
|
|
93
|
+
"brand-placeholder",
|
|
94
|
+
"warning",
|
|
95
|
+
"brand",
|
|
96
|
+
name,
|
|
97
|
+
`the brand is "${clip(name)}", which isn't a brand; leave "brand" out when there's none, or use the shop's name for products it makes itself`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Types schema.org deprecates, and the type it names instead. The crawler reads this list too.
|
|
104
|
+
// https://schema.org/Attorney
|
|
105
|
+
export const SUPERSEDED = { Attorney: "LegalService" };
|
|
106
|
+
// Template placeholders: a bracketed field name ([Business Name], [Phone], [CITY]) or a REPLACE_ token. Only field
|
|
107
|
+
// names count, so "[Updated]" in a headline isn't one.
|
|
108
|
+
const BRACKET =
|
|
109
|
+
/\[(?:(?:your|the|insert|enter|add) )?(?:business|company|brand|site|store|shop|city|town|street|state|county|region|country|zip|postcode|postal|phone|telephone|email|e-mail|address|name|url|website|domain|logo|price|hours)(?: (?:name|number|address|url|code|here))?\]/i;
|
|
110
|
+
const REPLACE = /\bREPLACE_[A-Z0-9_]*|\bREPLACE[_ ]?ME\b/;
|
|
111
|
+
export const placeholderIn = s => (BRACKET.exec(s) || REPLACE.exec(s))?.[0] ?? null;
|
|
112
|
+
|
|
113
|
+
// A nested review or rating should leave out itemReviewed, as the parent is the item reviewed, and since 12 Nov 2025
|
|
114
|
+
// Google asks sites not to name it more than one way. Only a different item is flagged, told apart by @id when both
|
|
115
|
+
// have one, else by name.
|
|
116
|
+
// https://developers.google.com/search/updates
|
|
117
|
+
export const REVIEW_DOC = "https://developers.google.com/search/docs/appearance/structured-data/review-snippet";
|
|
118
|
+
const nameKey = s => (typeof s === "string" ? s.replace(/\s+/g, " ").trim().toLowerCase() : "");
|
|
119
|
+
/** The other item a review or rating nested in `parent` names in itemReviewed (its name or @id), or null. */
|
|
120
|
+
export function otherReviewed(parent, child) {
|
|
121
|
+
if (!parent || typeof parent !== "object" || !child || typeof child !== "object") return null;
|
|
122
|
+
const own = [parent["@id"], parent.url, parent.name].map(nameKey).filter(Boolean);
|
|
123
|
+
for (const it of list(child.itemReviewed)) {
|
|
124
|
+
if (typeof it === "string") {
|
|
125
|
+
if (it.trim() && own.length && !own.includes(nameKey(it))) return it.trim();
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (!it || typeof it !== "object") continue;
|
|
129
|
+
if (typeof it["@id"] === "string" && typeof parent["@id"] === "string") {
|
|
130
|
+
if (it["@id"].trim() !== parent["@id"].trim()) return nameKey(it.name) ? it.name.trim() : it["@id"].trim();
|
|
131
|
+
} else if (nameKey(it.name) && nameKey(parent.name) && nameKey(it.name) !== nameKey(parent.name))
|
|
132
|
+
return it.name.trim();
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
// Google's event results need a physical location; the online event properties went on 5 Jun 2025. Online mode with no
|
|
137
|
+
// other place, or only VirtualLocations, is online only; Mixed or Offline mode, a Place or a text address isn't.
|
|
138
|
+
export const EVENT_DOC = "https://developers.google.com/search/docs/appearance/structured-data/event";
|
|
139
|
+
/** True when an Event has no real-world place. */
|
|
140
|
+
export function onlineOnly(e) {
|
|
141
|
+
const mode = list(e?.eventAttendanceMode).map(x =>
|
|
142
|
+
term(String((x && typeof x === "object" ? x["@id"] : x) ?? "").trim()),
|
|
143
|
+
);
|
|
144
|
+
if (mode.some(m => /^(Offline|Mixed)EventAttendanceMode$/.test(m))) return false;
|
|
145
|
+
const locs = list(e?.location).filter(l => l != null && l !== ""),
|
|
146
|
+
virtual = l => typeIs(l, "VirtualLocation");
|
|
147
|
+
return mode.includes("OnlineEventAttendanceMode") ? locs.every(virtual) : locs.length > 0 && locs.every(virtual);
|
|
148
|
+
}
|
|
149
|
+
// Self-serving ratings: a business that controls its own reviews gets no review stars on its business pages
|
|
150
|
+
// (REVIEW_DOC). A business is rated by a rating or review on its node, or by a Review or AggregateRating naming it
|
|
151
|
+
// (or a bare @id) in itemReviewed. Which business is the site's own is site-hygiene.mjs's call.
|
|
152
|
+
const typesIn = o =>
|
|
153
|
+
list(o?.["@type"])
|
|
154
|
+
.filter(t => typeof t === "string")
|
|
155
|
+
.map(term)
|
|
156
|
+
.filter(t => schemaTypes()[t]);
|
|
157
|
+
const who = (o, types, kind) => ({
|
|
158
|
+
id: typeof o["@id"] === "string" ? o["@id"].trim() : "",
|
|
159
|
+
name: nameKey(o.name) ? o.name.trim() : "",
|
|
160
|
+
type: types.find(isBusinessType) || "",
|
|
161
|
+
...(kind && { kind }),
|
|
162
|
+
});
|
|
163
|
+
/** For the crawler: the names of online-only events and each nested review or rating naming another item, at any depth;
|
|
164
|
+
* the business nodes at the top (orgs) and the businesses rated here (rated), as { id, name, type, kind }. */
|
|
165
|
+
export function reviewEventProblems(nodes) {
|
|
166
|
+
const events = [],
|
|
167
|
+
reviews = [],
|
|
168
|
+
orgs = [],
|
|
169
|
+
rated = [],
|
|
170
|
+
seen = new Set();
|
|
171
|
+
const walk = (o, d) => {
|
|
172
|
+
if (!o || typeof o !== "object" || d > 12 || seen.has(o)) return;
|
|
173
|
+
seen.add(o);
|
|
174
|
+
if (Array.isArray(o)) return o.forEach(x => walk(x, d + 1));
|
|
175
|
+
const types = typesIn(o);
|
|
176
|
+
if (types.some(t => isA(t, "Event")) && onlineOnly(o))
|
|
177
|
+
events.push(typeof o.name === "string" && o.name.trim() ? o.name.trim() : "an event");
|
|
178
|
+
if (types.some(isBusinessType)) {
|
|
179
|
+
if (d === 0) orgs.push(who(o, types));
|
|
180
|
+
if (list(o.aggregateRating).length || list(o.review).length)
|
|
181
|
+
rated.push(who(o, types, list(o.aggregateRating).length ? "a rating on" : "a review on"));
|
|
182
|
+
}
|
|
183
|
+
const of = types.some(t => isA(t, "Review"))
|
|
184
|
+
? "a review of"
|
|
185
|
+
: types.some(t => isA(t, "AggregateRating"))
|
|
186
|
+
? "a rating of"
|
|
187
|
+
: null;
|
|
188
|
+
if (of)
|
|
189
|
+
for (const it of list(o.itemReviewed)) {
|
|
190
|
+
const t = typesIn(it);
|
|
191
|
+
if (it && typeof it === "object" && (t.some(isBusinessType) || (!it["@type"] && typeof it["@id"] === "string")))
|
|
192
|
+
rated.push(who(it, t, of));
|
|
193
|
+
}
|
|
194
|
+
for (const k of ["review", "aggregateRating"])
|
|
195
|
+
for (const c of list(o[k])) {
|
|
196
|
+
const other = otherReviewed(o, c);
|
|
197
|
+
if (other)
|
|
198
|
+
reviews.push(
|
|
199
|
+
`${k === "review" ? "a review" : "a rating"} in “${nameKey(o.name) ? o.name.trim() : types[0] || "an item"}” names “${other}”`,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
Object.values(o).forEach(x => walk(x, d + 1));
|
|
203
|
+
};
|
|
204
|
+
nodes.forEach(n => walk(n, 0));
|
|
205
|
+
return { events, reviews, orgs, rated };
|
|
206
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Site-wide AI agent checks over the crawled pages. site is the crawl's context (seo-crawl.mjs).
|
|
3
|
+
import { agentFiles, BING_PREFS } from "./agents.mjs";
|
|
4
|
+
|
|
5
|
+
// Unnamed controls (AI-05 counts as checked once a page has a control), plus WebMCP tools, agent files and writing
|
|
6
|
+
// notes for the report. UA is the crawler's user agent, for the agent file requests.
|
|
7
|
+
export async function agentData(site, UA) {
|
|
8
|
+
const { htmlPages, add, evalRules, notes, extra, startOrigin: START_ORIGIN, indexable } = site;
|
|
9
|
+
const tools = [],
|
|
10
|
+
writingNotes = [];
|
|
11
|
+
for (const p of htmlPages) {
|
|
12
|
+
if (!p.agent || !indexable(p) || p.clientOnly) continue;
|
|
13
|
+
const { unnamedFields: f, unnamedButtons: b, webmcpTools, controls } = p.agent;
|
|
14
|
+
if (controls) evalRules("AI-05");
|
|
15
|
+
if (f.length || b.length)
|
|
16
|
+
add(
|
|
17
|
+
"controls-no-name",
|
|
18
|
+
p.finalUrl,
|
|
19
|
+
`${[f.length && `${f.length} field(s)`, b.length && `${b.length} button(s)`].filter(Boolean).join(" and ")}, e.g. \`${f[0] || b[0]}\``,
|
|
20
|
+
);
|
|
21
|
+
if (webmcpTools.length) tools.push({ url: p.finalUrl, tools: webmcpTools });
|
|
22
|
+
const w = p.writing,
|
|
23
|
+
count = w.longSentences + w.longParagraphs + w.stockPhrases.length;
|
|
24
|
+
if (count) writingNotes.push({ url: p.finalUrl, ...w, count });
|
|
25
|
+
}
|
|
26
|
+
writingNotes.sort((a, b) => b.count - a.count || (a.url < b.url ? -1 : 1));
|
|
27
|
+
if (writingNotes.length > 50)
|
|
28
|
+
notes.push(`Writing notes list the 50 pages with the most notes, of ${writingNotes.length}.`);
|
|
29
|
+
const files = await agentFiles(
|
|
30
|
+
u =>
|
|
31
|
+
fetch(u, {
|
|
32
|
+
redirect: "manual",
|
|
33
|
+
headers: { "user-agent": UA, accept: "application/json,*/*;q=0.8" },
|
|
34
|
+
signal: AbortSignal.timeout(15000),
|
|
35
|
+
}),
|
|
36
|
+
START_ORIGIN,
|
|
37
|
+
);
|
|
38
|
+
extra.agents = { pages: tools.slice(0, 50), ...files };
|
|
39
|
+
extra.writingNotes = writingNotes.slice(0, 50).map(({ count, ...n }) => n);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// A page still on noarchive or nocache without the new directive needs a decision before 1 Mar 2027. Pages Bing can't
|
|
43
|
+
// index don't matter, noindex pages that --ignore-noindex treats as indexable included (page-nofollow skips them too).
|
|
44
|
+
export function bingAiPrefs(site) {
|
|
45
|
+
const { htmlPages, add, evalRules, indexable } = site;
|
|
46
|
+
evalRules("AI-03");
|
|
47
|
+
for (const p of htmlPages) {
|
|
48
|
+
if (!p.bingAi || !indexable(p) || p.noindex) continue;
|
|
49
|
+
const { legacy, prefs } = p.bingAi,
|
|
50
|
+
at = w => [...new Set(legacy.filter(l => l.where === w).map(l => l.rule))].join(" and ");
|
|
51
|
+
if (legacy.length && !prefs.length)
|
|
52
|
+
add(
|
|
53
|
+
"ai-legacy-noarchive",
|
|
54
|
+
p.finalUrl,
|
|
55
|
+
[at("meta") && `${at("meta")} in a meta tag`, at("header") && `${at("header")} in the X-Robots-Tag header`]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join("; "),
|
|
58
|
+
);
|
|
59
|
+
const bad = prefs.filter(x => !BING_PREFS[x.name].includes(x.value));
|
|
60
|
+
if (bad.length) add("ai-preference-invalid", p.finalUrl, bad.map(x => `${x.name}:${x.value}`).join(", "));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Click-only elements and missing landmarks on indexable, server-rendered pages; the first 20 lacking a landmark are
|
|
65
|
+
// listed.
|
|
66
|
+
export function landmarks(site) {
|
|
67
|
+
const { htmlPages, add, extra, indexable } = site;
|
|
68
|
+
const bare = [];
|
|
69
|
+
let checked = 0;
|
|
70
|
+
for (const p of htmlPages) {
|
|
71
|
+
if (!p.agent || !indexable(p) || p.clientOnly) continue;
|
|
72
|
+
checked++;
|
|
73
|
+
const { clickOnly, landmarksMissing } = p.agent;
|
|
74
|
+
if (clickOnly.length)
|
|
75
|
+
add("click-only-elements", p.finalUrl, `${clickOnly.length} element(s), e.g. \`${clickOnly[0]}\``);
|
|
76
|
+
if (landmarksMissing.length) bare.push({ url: p.finalUrl, missing: landmarksMissing });
|
|
77
|
+
}
|
|
78
|
+
if (bare.length) extra.landmarks = { checked, count: bare.length, pages: bare.slice(0, 20) };
|
|
79
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { SHOP_FIELDS } from "../crawl/catalog.mjs";
|
|
3
|
+
import { norm } from "../lib/html.mjs";
|
|
4
|
+
import { identityDrift } from "./page.mjs";
|
|
5
|
+
import { brandTail, sectionOf, templatedDescs, templatedShare } from "./content.mjs";
|
|
6
|
+
import { quote } from "../lib/findings.mjs";
|
|
7
|
+
|
|
8
|
+
export function pageMarkup(site) {
|
|
9
|
+
const { htmlPages, add, indexable } = site;
|
|
10
|
+
for (const p of htmlPages) {
|
|
11
|
+
if (p.clientOnly || !indexable(p)) continue;
|
|
12
|
+
const u = p.finalUrl;
|
|
13
|
+
if (p.unencoded.length)
|
|
14
|
+
add("url-unencoded", u, `${p.unencoded.length} link(s), e.g. ${p.unencoded.slice(0, 3).join(", ")}`);
|
|
15
|
+
if (p.wideImgs.length)
|
|
16
|
+
add("img-no-srcset", u, `${p.wideImgs.length} image(s) over 1,000 px wide, e.g. ${p.wideImgs[0]}`);
|
|
17
|
+
if (p.eagerLate.length)
|
|
18
|
+
add("img-not-lazy", u, `${p.eagerLate.length} image(s) from the 11th on, e.g. ${p.eagerLate[0]}`);
|
|
19
|
+
if (p.dupHead.length) add("duplicate-head-tags", u, p.dupHead.join(", "));
|
|
20
|
+
if (p.numberHeadings.length) add("heading-only-number", u, p.numberHeadings.slice(0, 3).join("; "));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Titles under 20 characters ("Contact us") are skipped: a short title often starts a natural sentence.
|
|
25
|
+
export function descStartsWithTitle(site) {
|
|
26
|
+
const { htmlPages, add, indexable } = site;
|
|
27
|
+
for (const p of htmlPages) {
|
|
28
|
+
if (!indexable(p) || !p.title || !p.description) continue;
|
|
29
|
+
const flat = s => s.toLowerCase().replace(/\s+/g, " ").trim(),
|
|
30
|
+
t = flat(p.title);
|
|
31
|
+
if (t.length >= 20 && flat(p.description).startsWith(t.slice(0, Math.ceil(t.length * 0.8))))
|
|
32
|
+
add("desc-starts-with-title", p.finalUrl, `“${p.description.slice(0, 80)}”`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Findings from page.mjs's per-page checks. CONTENT-11 stays under NOT_CRAWLABLE.
|
|
37
|
+
export function pageSignals(site) {
|
|
38
|
+
const { htmlPages, add, indexable, selfHosts, bareHost } = site;
|
|
39
|
+
const read = htmlPages.filter(p => p.pageChecks && indexable(p) && !p.clientOnly);
|
|
40
|
+
for (const { finalUrl: u, pageChecks: r } of read) {
|
|
41
|
+
const away = r.ugc.filter(h => !selfHosts.has(bareHost(new URL(h).host)));
|
|
42
|
+
if (away.length) add("ugc-link-followed", u, `${away.length} link(s), e.g. ${away[0]}`);
|
|
43
|
+
if (r.backTrap) add("back-button-trap", u, r.backTrap);
|
|
44
|
+
if (r.paywall) add("paywall-text-sent", u, `about ${r.paywall.words} words inside ${r.paywall.selector}`);
|
|
45
|
+
if (r.late.length) add("head-tags-late", u, `in the body: ${r.late.join(", ")}`);
|
|
46
|
+
if (r.relCanon) add("canonical-relative", u, r.relCanon);
|
|
47
|
+
}
|
|
48
|
+
for (const [u, d] of identityDrift(read.map(p => ({ url: p.finalUrl, ...p.pageChecks.identity }))))
|
|
49
|
+
add("site-identity-differs", u, d);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// One finding per check per page. An H1 shared by 3+ product pages counts as reused unless it names one of their
|
|
53
|
+
// products (a variant's "Wool coat" names "Wool coat, small").
|
|
54
|
+
export function shopChecks(site) {
|
|
55
|
+
const { htmlPages, add, extra, indexable } = site;
|
|
56
|
+
const shop = htmlPages.filter(p => p.shop && indexable(p)),
|
|
57
|
+
byH1 = new Map();
|
|
58
|
+
for (const p of shop) {
|
|
59
|
+
const reported = new Set();
|
|
60
|
+
for (const pr of p.shop)
|
|
61
|
+
for (const x of pr.problems)
|
|
62
|
+
if (!reported.has(x.check)) {
|
|
63
|
+
reported.add(x.check);
|
|
64
|
+
add(`product-${x.check}`, p.finalUrl, x.key ? `${pr.name}: ${x.key} “${x.value}”` : pr.name);
|
|
65
|
+
}
|
|
66
|
+
const h = p.headings.find(x => x.level === 1)?.text,
|
|
67
|
+
k = h && norm(h);
|
|
68
|
+
if (k) (byH1.get(k) || byH1.set(k, { h, pages: [] }).get(k)).pages.push(p);
|
|
69
|
+
}
|
|
70
|
+
for (const [k, { h, pages: ps }] of byH1)
|
|
71
|
+
if (ps.length >= 3 && !ps.some(p => p.shop.some(pr => norm(pr.name).includes(k))))
|
|
72
|
+
for (const p of ps) add("product-h1-reused", p.finalUrl, `“${h}” on ${ps.length} product pages`);
|
|
73
|
+
const products = shop.flatMap(p => p.shop);
|
|
74
|
+
if (products.length)
|
|
75
|
+
extra.productFields = {
|
|
76
|
+
products: products.length,
|
|
77
|
+
...Object.fromEntries(
|
|
78
|
+
Object.keys(SHOP_FIELDS).map(f => [f, products.filter(pr => pr.fields.includes(f)).length]),
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// A description's main words are read as META-09 reads a title's, matched by stem or acronym. The 4-word minimum, a
|
|
84
|
+
// quarter on the page and the one-year guide age are local lines. titleWords, brandWords and acronyms come from
|
|
85
|
+
// checkPages.
|
|
86
|
+
export function contentChecks(site, { titleWords, brandWords, acronyms }) {
|
|
87
|
+
const { htmlPages, add, extra, indexable } = site;
|
|
88
|
+
const read = htmlPages.filter(p => indexable(p) && !p.clientOnly);
|
|
89
|
+
for (const p of read) {
|
|
90
|
+
const u = p.finalUrl;
|
|
91
|
+
if (p.description) {
|
|
92
|
+
const dw = titleWords(p.description).filter(w => !brandWords.has(w)),
|
|
93
|
+
onPage = " " + p.normText;
|
|
94
|
+
if (dw.length >= 4 && p.words >= 50) {
|
|
95
|
+
const on = dw.filter(w => onPage.includes(" " + w.slice(0, Math.max(4, w.length - 3)))).length;
|
|
96
|
+
if (on < dw.length / 4 && ![...acronyms(p.description)].some(a => p.caps.has(a)))
|
|
97
|
+
add("desc-mismatch", u, `“${p.description.slice(0, 80)}”: ${on} of ${dw.length} main words are on the page`);
|
|
98
|
+
}
|
|
99
|
+
const tail = p.title && brandTail(p.title, p.description);
|
|
100
|
+
if (tail) add("desc-brand-tail", u, `ends with “${tail}”, as the title does`);
|
|
101
|
+
}
|
|
102
|
+
if (p.guideDate && Date.now() - p.guideDate.time > 365 * 864e5)
|
|
103
|
+
add("stale-guide", u, `newest date ${p.guideDate.date}, from ${p.guideDate.from}`);
|
|
104
|
+
}
|
|
105
|
+
const descs = read
|
|
106
|
+
.filter(p => p.description)
|
|
107
|
+
.map(p => ({ url: p.finalUrl, section: sectionOf(p.finalUrl), desc: p.description }));
|
|
108
|
+
const hits = templatedDescs(descs);
|
|
109
|
+
for (const [u, why] of hits) add("templated-desc", u, why);
|
|
110
|
+
if (hits.length)
|
|
111
|
+
extra.templatedDescriptions = templatedShare(
|
|
112
|
+
descs,
|
|
113
|
+
hits.map(h => h[0]),
|
|
114
|
+
);
|
|
115
|
+
const kw = read.filter(p => p.keywordUse).map(p => ({ url: p.finalUrl, ...p.keywordUse }));
|
|
116
|
+
if (kw.length)
|
|
117
|
+
extra.keywordUse = {
|
|
118
|
+
counts: Object.fromEntries(
|
|
119
|
+
["natural", "missing", "repetitive", "forced"].map(v => [v, kw.filter(k => k.verdict === v).length]),
|
|
120
|
+
),
|
|
121
|
+
pages: kw.filter(k => k.verdict !== "natural").slice(0, 50),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// A service-area business whose schema gives a street address no page shows gets a note instead of the address
|
|
126
|
+
// finding. localBusiness comes from checkPages and judges on its first call.
|
|
127
|
+
export function localData(site, localBusiness) {
|
|
128
|
+
const { notes, extra } = site;
|
|
129
|
+
const lb = localBusiness();
|
|
130
|
+
if (lb) extra.localBusiness = lb;
|
|
131
|
+
if (lb?.streetHidden)
|
|
132
|
+
notes.push(
|
|
133
|
+
`The business schema gives the street address ${quote(lb.address?.streetAddress || lb.address?.text)}, but no page shows it, and the site says the business goes to its customers, so the address check skipped it. If customers don't come to that address, take it out of the schema too and keep the town, region and postcode (LOCAL-06). If they do, show it on the site (LOCAL-05).`,
|
|
134
|
+
);
|
|
135
|
+
}
|