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.
Files changed (207) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/.claude-plugin/plugin.json +16 -3
  4. package/CHANGELOG.md +430 -0
  5. package/NOTICE +7 -0
  6. package/README.md +230 -25
  7. package/agents/seo-auditor.md +16 -0
  8. package/agents/seo-reviewer.md +16 -0
  9. package/bin/agents.mjs +194 -29
  10. package/bin/extras.mjs +422 -0
  11. package/bin/prompt.mjs +34 -14
  12. package/bin/seo-supervisor.mjs +386 -53
  13. package/commands/seo-audit.md +29 -3
  14. package/commands/seo-brief.md +28 -0
  15. package/commands/seo-connect.md +27 -0
  16. package/commands/seo-fix.md +24 -3
  17. package/commands/seo-grow.md +26 -0
  18. package/commands/seo-launch.md +17 -3
  19. package/commands/seo-review.md +13 -1
  20. package/commands/seo-rewrite.md +25 -0
  21. package/commands/seo-setup.md +17 -1
  22. package/commands/seo-watch.md +28 -0
  23. package/hooks/hooks.json +117 -0
  24. package/package.json +20 -7
  25. package/skills/seo-supervisor/NOTICE +7 -0
  26. package/skills/seo-supervisor/SKILL.md +302 -21
  27. package/skills/seo-supervisor/audience.md +61 -0
  28. package/skills/seo-supervisor/examples/drafts/security.md +41 -0
  29. package/skills/seo-supervisor/examples/hooks/README.md +28 -0
  30. package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
  31. package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
  32. package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
  33. package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
  34. package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
  35. package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
  36. package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
  37. package/skills/seo-supervisor/examples/sample-audit.json +94 -2
  38. package/skills/seo-supervisor/examples/sample-report.html +111 -61
  39. package/skills/seo-supervisor/examples/sample-report.md +147 -44
  40. package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
  41. package/skills/seo-supervisor/examples/snippets.md +648 -1
  42. package/skills/seo-supervisor/grow.md +342 -0
  43. package/skills/seo-supervisor/og-images.md +85 -0
  44. package/skills/seo-supervisor/page-types.md +124 -0
  45. package/skills/seo-supervisor/planning.md +19 -7
  46. package/skills/seo-supervisor/profile-template.md +41 -0
  47. package/skills/seo-supervisor/report-format.md +177 -10
  48. package/skills/seo-supervisor/rewrite.md +59 -0
  49. package/skills/seo-supervisor/rules/ai-search.md +65 -12
  50. package/skills/seo-supervisor/rules/content.md +33 -9
  51. package/skills/seo-supervisor/rules/crawl-index.md +33 -6
  52. package/skills/seo-supervisor/rules/internal-linking.md +49 -6
  53. package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
  54. package/skills/seo-supervisor/rules/media.md +13 -1
  55. package/skills/seo-supervisor/rules/metadata.md +41 -9
  56. package/skills/seo-supervisor/rules/performance.md +50 -5
  57. package/skills/seo-supervisor/rules/rendering.md +39 -2
  58. package/skills/seo-supervisor/rules/search-intent.md +32 -0
  59. package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
  60. package/skills/seo-supervisor/rules/structured-data.md +37 -14
  61. package/skills/seo-supervisor/rules/trust-security.md +25 -2
  62. package/skills/seo-supervisor/rules/urls.md +10 -2
  63. package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
  64. package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
  65. package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
  66. package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
  67. package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
  68. package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
  69. package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
  70. package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
  71. package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
  72. package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
  73. package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
  74. package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
  75. package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
  76. package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
  77. package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
  78. package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
  79. package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
  80. package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
  81. package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
  82. package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
  83. package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
  84. package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
  85. package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
  86. package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
  87. package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
  88. package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
  89. package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
  90. package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
  91. package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
  92. package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
  93. package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
  94. package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
  95. package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
  96. package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
  97. package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
  98. package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
  99. package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
  100. package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
  101. package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
  102. package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
  103. package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
  104. package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
  105. package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
  106. package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
  107. package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
  108. package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
  109. package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
  110. package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
  111. package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
  112. package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
  113. package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
  114. package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
  115. package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
  116. package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
  117. package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
  118. package/skills/seo-supervisor/scripts/google.mjs +1341 -0
  119. package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
  120. package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
  121. package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
  122. package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
  123. package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
  124. package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
  125. package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
  126. package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
  127. package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
  128. package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
  129. package/skills/seo-supervisor/scripts/guard.mjs +74 -0
  130. package/skills/seo-supervisor/scripts/images.mjs +408 -0
  131. package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
  132. package/skills/seo-supervisor/scripts/issues.mjs +217 -0
  133. package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
  134. package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
  135. package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
  136. package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
  137. package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
  138. package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
  139. package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
  140. package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
  141. package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
  142. package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
  143. package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
  144. package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
  145. package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
  146. package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
  147. package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
  148. package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
  149. package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
  150. package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
  151. package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
  152. package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
  153. package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
  154. package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
  155. package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
  156. package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
  157. package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
  158. package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
  159. package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
  160. package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
  161. package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
  162. package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
  163. package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
  164. package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
  165. package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
  166. package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
  167. package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
  168. package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
  169. package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
  170. package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
  171. package/skills/seo-supervisor/scripts/osm.mjs +359 -0
  172. package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
  173. package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
  174. package/skills/seo-supervisor/scripts/report/client.js +37 -0
  175. package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
  176. package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
  177. package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
  178. package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
  179. package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
  180. package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
  181. package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
  182. package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
  183. package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
  184. package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
  185. package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
  186. package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
  187. package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
  188. package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
  189. package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
  190. package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
  191. package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
  192. package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
  193. package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
  194. package/skills/seo-supervisor/scripts/report/styles.css +223 -0
  195. package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
  196. package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
  197. package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
  198. package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
  199. package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
  200. package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
  201. package/skills/seo-supervisor/site-types/content.md +34 -1
  202. package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
  203. package/skills/seo-supervisor/site-types/local-business.md +96 -6
  204. package/skills/seo-supervisor/site-types/services.md +46 -0
  205. package/skills/seo-supervisor/site-types/tools.md +3 -3
  206. package/skills/seo-supervisor/strategy.md +232 -0
  207. package/skills/seo-supervisor/troubleshooting.md +56 -0
@@ -0,0 +1,202 @@
1
+ // @ts-check
2
+ // Duplicate analytics, exposed keys, hidden links, review and event schema, app link files, PDFs and Markdown copies.
3
+ import { HIDDEN_MIN, PDF_PAGES, JS_CAPS, APP_FILES, secretsIn, appFile } from "./hygiene.mjs";
4
+ import { pathKey, upTo, urlOr } from "../crawl/fetch.mjs";
5
+ import { pool } from "../crawl/queue.mjs";
6
+ import { NOSPACE_RUN } from "../lib/html.mjs";
7
+ import { quote } from "../lib/findings.mjs";
8
+ import { mainWords as pickMainWords } from "../keyword-ideas.mjs";
9
+
10
+ // Analytics and secret keys are checked on every page read, since both matter on pages search engines skip too; the
11
+ // rest only on indexable pages. UA is the crawler's user agent, sent for the app link files.
12
+ export async function hygieneChecks(site, UA) {
13
+ const {
14
+ htmlPages,
15
+ home,
16
+ add,
17
+ notes,
18
+ extra,
19
+ startOrigin: START_ORIGIN,
20
+ conc: CONC,
21
+ get,
22
+ indexable,
23
+ selfHosts,
24
+ bareHost,
25
+ } = site;
26
+ const read = htmlPages.filter(p => p.hygieneSignals);
27
+ // The business nodes at the top of the home page's schema are the site's own; a rated business elsewhere is the same
28
+ // one when its @id or name matches.
29
+ const key = s => s.replace(/\s+/g, " ").toLowerCase(),
30
+ own = home?.hygieneSignals?.schema.orgs || [];
31
+ const ownId = new Set(own.map(o => o.id).filter(Boolean)),
32
+ ownName = new Set(own.map(o => key(o.name)).filter(Boolean));
33
+ for (const p of read) {
34
+ const h = p.hygieneSignals,
35
+ u = p.finalUrl;
36
+ if (h.analytics.length) add("analytics-tag-twice", u, h.analytics.join("; "));
37
+ if (h.keys.length) add("secret-key-exposed", u, h.keys.join("; "));
38
+ // Keeps the key's words out of the words file.
39
+ if (h.scrub.length && typeof p.mainWordsText === "string") {
40
+ const drop = new Set(h.scrub);
41
+ p.mainWordsText = p.mainWordsText
42
+ .split(" ")
43
+ .filter(w => !drop.has(w))
44
+ .join(" ");
45
+ }
46
+ if (!indexable(p) || p.clientOnly) continue;
47
+ const away = h.hidden.filter(x => {
48
+ const y = urlOr(x);
49
+ return y && !selfHosts.has(bareHost(y.host));
50
+ });
51
+ if (away.length >= HIDDEN_MIN)
52
+ add("hidden-links", u, `${away.length} hidden link(s) to other sites, e.g. ${away[0]}`);
53
+ if (h.schema.events.length) add("event-online", u, h.schema.events.map(e => `“${e}”`).join(", "));
54
+ if (h.schema.reviews.length) add("review-target-conflict", u, h.schema.reviews.join("; "));
55
+ const self = [
56
+ ...new Map(
57
+ h.schema.rated.filter(x => ownId.has(x.id) || ownName.has(key(x.name))).map(x => [x.id || key(x.name), x]),
58
+ ).values(),
59
+ ];
60
+ if (self.length)
61
+ add(
62
+ "rating-self-serving",
63
+ u,
64
+ self.map(x => `${x.kind} “${x.name || x.id}”${x.type ? ` (${x.type})` : ""}`).join("; "),
65
+ );
66
+ }
67
+ // Builds often bake a server setting into the scripts browsers get. Each on-site script is read once, most-loaded
68
+ // first, without following redirects, so no other host is asked; an HTML answer (an app shell served for every path)
69
+ // is skipped, and source maps aren't read. JS_CAPS are local limits. A script that redirects isn't read; follow
70
+ // on-site hops if that turns up.
71
+ const scripts = new Map(); // crawl URL -> the pages that load it
72
+ for (const p of read)
73
+ for (const s of p.hygieneSignals.js) (scripts.get(s) || scripts.set(s, []).get(s)).push(p.finalUrl);
74
+ const sorted = [...scripts].sort((a, b) => b[1].length - a[1].length || a[0].localeCompare(b[0]));
75
+ // Fetched in parallel, keeping only size and keys; JS_CAPS.all is then applied in order, as if read one by one. A
76
+ // file not started once JS_CAPS.all is spent would have gone unread that way too, so it's skipped.
77
+ let spent = 0;
78
+ const got = await pool(sorted.slice(0, JS_CAPS.files), CONC, async ([src]) => {
79
+ if (spent >= JS_CAPS.all) return null;
80
+ const r = await get(src, { accept: "*/*", text: /^(?!text\/html)/i, max: JS_CAPS.each }),
81
+ bytes = r.over ? JS_CAPS.each : Buffer.byteLength(r.body);
82
+ spent += bytes;
83
+ return {
84
+ status: r.status,
85
+ bytes,
86
+ over: r.over,
87
+ keys: r.over ? [] : [...new Set(secretsIn(r.body).map(k => `${k.label} (${k.shown})`))],
88
+ };
89
+ });
90
+ let jsRead = 0,
91
+ jsBytes = 0,
92
+ jsUnread = 0;
93
+ for (const [i, [src, from]] of sorted.entries()) {
94
+ if (jsRead >= JS_CAPS.files || jsBytes >= JS_CAPS.all) {
95
+ jsUnread++;
96
+ continue;
97
+ }
98
+ jsRead++;
99
+ const cap = Math.min(JS_CAPS.each, JS_CAPS.all - jsBytes),
100
+ r = got[i],
101
+ over = r.over || r.bytes > cap;
102
+ // Still 429 or 503 after the slow-down means busy, not broken, as for images and stylesheets.
103
+ if (r.status === 429 || r.status === 503) {
104
+ notes.push(`The script ${quote(src)} answered ${r.status} (busy), so it wasn't checked.`);
105
+ continue;
106
+ }
107
+ if (r.status >= 400) add("own-file-broken", from.sort()[0], `script ${src} → ${r.status}`);
108
+ jsBytes += over ? cap : r.bytes;
109
+ if (over) {
110
+ jsUnread++;
111
+ continue;
112
+ }
113
+ if (r.keys.length)
114
+ add(
115
+ "secret-key-exposed",
116
+ from.sort()[0],
117
+ `in the script ${pathKey(src)}${from.length > 1 ? ` (loaded by ${from.length} pages)` : ""}: ${r.keys.join("; ")}`,
118
+ );
119
+ }
120
+ if (jsUnread)
121
+ notes.push(
122
+ `${jsUnread} of the site's ${scripts.size} script files weren't read for secret keys, because of our own limits: ${JS_CAPS.files} files, ${JS_CAPS.each / 1048576} MB each and ${JS_CAPS.all / 1048576} MB in all. A key in one of them would be missed.`,
123
+ );
124
+ const apps = [];
125
+ // Only the crawled origin is asked, and redirects aren't followed: neither file may be served through one.
126
+ for (const [k, platform] of [
127
+ ["android", "Android"],
128
+ ["ios", "iOS"],
129
+ ]) {
130
+ const page = read
131
+ .filter(p => p.hygieneSignals.app[k])
132
+ .map(p => p.finalUrl)
133
+ .sort()[0];
134
+ if (!page) continue;
135
+ let res = { status: 0, type: "", body: "" };
136
+ try {
137
+ const r = await fetch(START_ORIGIN + APP_FILES[k], {
138
+ redirect: "manual",
139
+ headers: { "user-agent": UA, accept: "application/json" },
140
+ signal: AbortSignal.timeout(15000),
141
+ });
142
+ res = {
143
+ status: r.status,
144
+ type: r.headers.get("content-type") || "",
145
+ body: r.status === 200 && r.body ? (await upTo(r.body, 1 << 18)).toString("utf8") : "",
146
+ };
147
+ if (r.status !== 200) await r.body?.cancel();
148
+ } catch {}
149
+ const bad = appFile(k, res);
150
+ if (bad) apps.push({ platform, file: APP_FILES[k], page, ...bad });
151
+ }
152
+ if (apps.length) extra.appLinks = apps;
153
+ // PDFs linked from a menu or PDF_PAGES+ indexable pages; Microsoft advises against relying on PDFs for core content.
154
+ // https://about.ads.microsoft.com/en/blog/post/october-2025/optimizing-your-content-for-inclusion-in-ai-search-answers
155
+ const pdfs = new Map(); // crawl URL -> { pages, menu }
156
+ for (const p of read)
157
+ if (indexable(p) && !p.clientOnly)
158
+ for (const x of p.hygieneSignals.pdfs) {
159
+ const e = pdfs.get(x) || pdfs.set(x, { pages: 0, menu: false }).get(x);
160
+ e.pages++;
161
+ e.menu ||= p.hygieneSignals.navPdfs.includes(x);
162
+ }
163
+ const listed = [...pdfs]
164
+ .filter(([, e]) => e.menu || e.pages >= PDF_PAGES)
165
+ .sort(([a, x], [b, y]) => Number(y.menu) - Number(x.menu) || y.pages - x.pages || a.localeCompare(b));
166
+ if (listed.length)
167
+ extra.pdfLinks = { count: listed.length, pdfs: listed.slice(0, 20).map(([url, e]) => ({ url, ...e })) };
168
+ }
169
+
170
+ // Compares the Markdown served for Accept: text/markdown with the page's words, on the render sample, only when the
171
+ // start page served Markdown (mdHome). Cloudflare's conversion drops header, footer and nav and appends the JSON-LD in
172
+ // a ```json block, so a converted copy still matches.
173
+ // https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/
174
+ // The half-the-words lines and the 50-word minimum are local; a few words would swing the share.
175
+ export async function markdownCheck(site, { mdHome, renderSample }) {
176
+ const { byPage, add, start: START, conc: CONC, get } = site;
177
+ if (mdHome == null) return;
178
+ const asked = renderSample.filter(u => byPage.get(u)?.markdownWords);
179
+ const answers = await pool(asked, CONC, async u =>
180
+ u === START.href ? null : get(u, { accept: "text/markdown", text: /^text\/markdown/i }),
181
+ ); // the start page reuses mdHome
182
+ for (const [i, u] of asked.entries()) {
183
+ const p = byPage.get(u),
184
+ res = answers[i];
185
+ const text = res ? (res.status === 200 && /^text\/markdown/i.test(res.ct) ? res.body : null) : mdHome;
186
+ if (text == null) continue;
187
+ const md = text
188
+ .replace(/```json[\s\S]*?```|!\[[^\]]*\]\([^)]*\)|<[^>]*>|https?:\/\/\S+/g, " ")
189
+ .replace(/\]\([^)]*\)/g, "]");
190
+ const words = new Set(pickMainWords(md.replace(NOSPACE_RUN, " "))),
191
+ main = p.markdownWords.main.split(" "),
192
+ pageWords = new Set(p.markdownWords.all.split(" "));
193
+ const kept = main.filter(w => words.has(w)).length / main.length,
194
+ unseen = words.size ? [...words].filter(w => !pageWords.has(w)).length / words.size : 0;
195
+ if (kept < 0.5 || unseen > 0.5)
196
+ add(
197
+ "markdown-differs",
198
+ u,
199
+ `the Markdown has ${Math.round(100 * kept)}% of the page's main words, and ${Math.round(100 * unseen)}% of its own words aren't on the page; our own limit is half`,
200
+ );
201
+ }
202
+ }
@@ -0,0 +1,474 @@
1
+ // @ts-check
2
+ // Per-page checks over every crawled HTML page, plus the site-wide ones that need the same pass.
3
+ import { allowedBy, groupOf } from "./robots.mjs";
4
+ import { checkHreflang } from "./hreflang.mjs";
5
+ import { titleWidth, widthText } from "./content.mjs";
6
+ import { judgeLocal } from "./local.mjs";
7
+ import { isHtmlSitemap } from "./links.mjs";
8
+ import { KEPT, RULES } from "../crawl/catalog.mjs";
9
+ import { clean, urlOr } from "../crawl/fetch.mjs";
10
+ import { NOSPACE, capsOf, norm } from "../lib/html.mjs";
11
+
12
+ // [i, j, dice] for pairs of 5-word chunk sets with Dice similarity over 0.6; an inverted index compares only pages that
13
+ // share a chunk. A chunk on every page (boilerplate) still costs pages² steps; index only each page's rarest chunks
14
+ // (prefix filtering) if that ever shows in a profile.
15
+ export function nearPairs(sets) {
16
+ const index = new Map(),
17
+ shared = new Int32Array(sets.length),
18
+ out = [];
19
+ sets.forEach((s, i) => {
20
+ const met = [];
21
+ for (const x of s) {
22
+ const at = index.get(x);
23
+ if (!at) {
24
+ index.set(x, [i]);
25
+ continue;
26
+ }
27
+ for (const j of at) if (shared[j]++ === 0) met.push(j);
28
+ at.push(i);
29
+ }
30
+ for (const j of met) {
31
+ const dice = (2 * shared[j]) / (sets[j].size + s.size);
32
+ if (dice > 0.6) out.push([j, i, dice]);
33
+ shared[j] = 0;
34
+ }
35
+ });
36
+ return out.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
37
+ }
38
+
39
+ export function checkPages(site) {
40
+ const {
41
+ all,
42
+ pages,
43
+ htmlPages,
44
+ home,
45
+ smSet,
46
+ robots,
47
+ star,
48
+ add,
49
+ evalRules,
50
+ evaluated,
51
+ notes,
52
+ notChecked,
53
+ ignoreNoindex: IGNORE_NOINDEX,
54
+ brand: BRAND,
55
+ startOrigin: START_ORIGIN,
56
+ expectOrigin: EXPECT_ORIGIN,
57
+ toCrawl,
58
+ isHome,
59
+ canonicalFor,
60
+ samePath,
61
+ indexable,
62
+ bareHost,
63
+ } = site;
64
+ for (const p of all) {
65
+ if (p.status >= 500 || p.status === 0) add("server-error", p.url, p.error || `status ${p.status}`);
66
+ if (p.chain && p.chain.length > 2)
67
+ add("redirect-chain", p.url, p.chain.map(c => `${c.status}`).join(" → ") + ` → ${p.finalUrl}`);
68
+ const x = new URL(p.url);
69
+ if (/[A-Z]/.test(x.pathname) || /_/.test(x.pathname) || /%20| /.test(x.pathname) || /\/\//.test(x.pathname))
70
+ add("url-format", p.url);
71
+ }
72
+ const google = robots && groupOf(robots, "googlebot"); // the group Googlebot obeys
73
+ for (const [u, e] of smSet) {
74
+ const p = pages.get(u);
75
+ if (!p) continue;
76
+ if (p.status !== 200 || p.chain.length > 1)
77
+ add("sitemap-bad-status", e.loc, p.chain.length > 1 ? `redirects to ${p.finalUrl}` : `status ${p.status}`);
78
+ else if (p.html && p.noindex && !IGNORE_NOINDEX) add("noindex-in-sitemap", e.loc);
79
+ // Another host, path or query makes the canonical another URL; a #fragment alone doesn't.
80
+ else if (p.html && canonicalFor(p) && clean(toCrawl(canonicalFor(p))) !== clean(p.finalUrl))
81
+ add("sitemap-noncanonical", e.loc, `canonical → ${canonicalFor(p)}`);
82
+ if (google && !allowedBy(google, new URL(u).pathname)) add("sitemap-url-disallowed", e.loc);
83
+ }
84
+ const titleMap = new Map(),
85
+ descMap = new Map(),
86
+ faqMap = new Map();
87
+ let checkedPages = 0,
88
+ drawnByJs = 0;
89
+ const images = new Map(); // same-origin image URL -> first indexable page using it
90
+ const shareImages = new Map(); // og:image on the crawled site (crawl URL) -> { src, page }
91
+ const noindexShare = htmlPages.length ? htmlPages.filter(p => p.noindex).length / htmlPages.length : 0;
92
+ if (IGNORE_NOINDEX)
93
+ notes.push(
94
+ "Ran with --ignore-noindex: noindex pages were checked as if indexable (pre-launch audit). Noindex findings were not raised.",
95
+ );
96
+ else if (noindexShare > 0.5)
97
+ notes.push(
98
+ `${Math.round(noindexShare * 100)}% of pages are noindex. If the site is pre-launch, re-run with --ignore-noindex; per-page checks skipped those pages.`,
99
+ );
100
+ // A basic missing on most pages is a site-wide blocker (the usual no-SEO site), reported once instead of per page.
101
+ const sitewide = (() => {
102
+ const idx = htmlPages.filter(
103
+ p => indexable(p) && !(p.words < 30 && p.h1Count === 0 && (p.emptyRoot || p.scripts > 0)),
104
+ );
105
+ const titles = new Map();
106
+ for (const p of idx) if (p.title) titles.set(p.title, (titles.get(p.title) || 0) + 1);
107
+ const [topTitle, topCount] = [...titles].sort((a, b) => b[1] - a[1])[0] || [];
108
+ const defaultTitle = topCount >= 0.8 * idx.length ? topTitle : undefined;
109
+ const hits = test => {
110
+ const s = new Set(idx.filter(test));
111
+ return s.size >= 3 && s.size >= 0.8 * idx.length ? s : new Set();
112
+ };
113
+ // A framework's starter title marks a site with no SEO work at any size, even a one-page site.
114
+ const STARTER =
115
+ /^(create next app|create react app|react app|vite \+ (react|vue|svelte|preact|lit|solid|ts)( \+ ts)?|vite app|nuxt( app)?|sveltekit( app)?|remix app|astro|welcome to (next\.js|remix|astro|nuxt)!?|gatsby (default )?starter|my gatsby site|angular ?app|document|untitled( document)?)$/i;
116
+ const starter = new Set(idx.filter(p => !p.title || STARTER.test(p.title.trim())));
117
+ const starterSitewide =
118
+ idx.some(p => p.title && STARTER.test(p.title.trim())) && starter.size >= 0.8 * idx.length ? starter : null;
119
+ return {
120
+ title: starterSitewide || hits(p => !p.title || p.title === defaultTitle),
121
+ h1: hits(p => p.h1Count === 0),
122
+ canonical: hits(p => !p.canonicals.length),
123
+ };
124
+ })();
125
+ const ownHosts = new Set(
126
+ EXPECT_ORIGIN.startsWith("https:")
127
+ ? [EXPECT_ORIGIN, START_ORIGIN].filter(o => o.startsWith("https:")).map(o => bareHost(new URL(o).hostname))
128
+ : [],
129
+ );
130
+ // Title words worth looking for: 4+ letters, not a stopword, not a brand word (one in most titles). Words in scripts
131
+ // written without spaces (Chinese, Japanese, Thai) can't be matched word by word, so they're left out.
132
+ const STOP = new Set(
133
+ "about after also been before best does each free from have here home into just like many more most much near official online only over page site some such than that them then there these they this those very website welcome were what when where which while will with your".split(
134
+ " ",
135
+ ),
136
+ );
137
+ const titleWords = t => [
138
+ ...new Set(
139
+ norm(t)
140
+ .split(" ")
141
+ .filter(w => /^\p{L}{4,}$/u.test(w) && !NOSPACE.test(w) && !STOP.has(w)),
142
+ ),
143
+ ];
144
+ const brandWords = (() => {
145
+ // every word, so a short one ("UK" in "Acme UK") is brand too
146
+ const sets = htmlPages.filter(p => p.title && indexable(p)).map(p => new Set(norm(p.title).split(" "))),
147
+ n = new Map();
148
+ for (const s of sets) for (const w of s) n.set(w, (n.get(w) || 0) + 1);
149
+ return new Set([...[...n].filter(([, c]) => c > sets.length / 2).map(([w]) => w), ...norm(BRAND).split(" ")]);
150
+ })();
151
+ // A title's capitalised words ("LPG") and the initials of 3+ words in a row, skipping and/of/the ("Heating,
152
+ // Ventilation and Air Conditioning" is hvac). Two letters ("IP") would match too much by chance.
153
+ const LINKING = new Set("a an and for in of on the to".split(" "));
154
+ const acronyms = t => {
155
+ const w = norm(t)
156
+ .split(" ")
157
+ .filter(x => x && !LINKING.has(x) && !brandWords.has(x)),
158
+ out = new Set([...capsOf(t)].filter(x => !brandWords.has(x)));
159
+ for (let i = 0; i < w.length; i++)
160
+ for (let j = i + 3; j <= w.length; j++)
161
+ out.add(
162
+ w
163
+ .slice(i, j)
164
+ .map(x => x[0])
165
+ .join(""),
166
+ );
167
+ return out;
168
+ };
169
+ // "12 High Street" and "12 High St." both become "12 high st", and "Hauptstraße 5" becomes "hauptstr 5".
170
+ const STREET_WORDS = {
171
+ street: "st",
172
+ road: "rd",
173
+ avenue: "ave",
174
+ suite: "ste",
175
+ apartment: "apt",
176
+ boulevard: "blvd",
177
+ drive: "dr",
178
+ lane: "ln",
179
+ };
180
+ const streetForm = s =>
181
+ norm(s)
182
+ .replace(/stra(?:ß|ss)e\b/g, "str")
183
+ .replace(/\b(?:street|road|avenue|suite|apartment|boulevard|drive|lane)\b/g, w => STREET_WORDS[w]);
184
+ // A phone matches on its last 7 digits in any grouping ("+44 113 496 0000" is shown by "(0113) 496-0000"). An address
185
+ // matches part by part, units included, so "12 High Road Suite 4" is shown by "Ste. 4, 12 High Rd".
186
+ const shows = (p, f) => {
187
+ if (f.kind === "phone")
188
+ return new RegExp(f.value.replace(/\D/g, "").slice(-7).split("").join(" ?") + "(?!\\d)").test(p.normText);
189
+ const text = ` ${streetForm(p.normText)} `;
190
+ return f.value
191
+ .split(",")
192
+ .flatMap(s => streetForm(s).split(/ (?=(?:ste|apt|unit|flat) )/))
193
+ .filter(Boolean)
194
+ .every(part => text.includes(` ${part} `));
195
+ };
196
+ // Judged once, from every page, when the address check or the site-wide block first asks.
197
+ let localJudged;
198
+ const localBusiness = () => (localJudged === undefined ? (localJudged = judgeLocal(htmlPages, shows)) : localJudged);
199
+ for (const p of htmlPages) {
200
+ const u = p.finalUrl;
201
+ if (!IGNORE_NOINDEX) {
202
+ if (isHome(p) && p.noindex) add("home-noindex", u);
203
+ else if (p.noindex && !smSet.has(p.url)) add("noindex-review", u);
204
+ }
205
+ if (p.banned) add("banned-claim", u, `“${p.banned.match}” in: ${p.banned.snippet}`);
206
+ if (p.unconfirmed) add("unconfirmed-claim", u, `“${p.unconfirmed.match}” in: ${p.unconfirmed.snippet}`);
207
+ if (p.words < 30 && p.h1Count === 0 && (p.emptyRoot || p.scripts > 0)) {
208
+ add("client-rendered", u, `${p.words} words in server HTML`);
209
+ p.clientOnly = true;
210
+ drawnByJs++;
211
+ continue;
212
+ }
213
+ const says = rs =>
214
+ rs.includes("noindex") ? "noindex" : rs.some(r => r === "index" || r === "all") ? "index" : null;
215
+ if (says(p.metaRules) && says(p.headerRules) && says(p.metaRules) !== says(p.headerRules))
216
+ add("robots-conflict", u, `meta: “${p.robotsMeta}” · header: “${p.xRobots}”`);
217
+ if (p.noindex && !IGNORE_NOINDEX) {
218
+ // Another page is another host or path; a trailing slash alone doesn't make one.
219
+ const c = canonicalFor(p),
220
+ to = c && urlOr(toCrawl(c)),
221
+ at = new URL(u),
222
+ bare = x => x.pathname.replace(/\/$/, "");
223
+ if (to && (to.origin !== at.origin || bare(to) !== bare(at))) add("noindex-canonical", u, `→ ${c}`);
224
+ continue;
225
+ }
226
+ if (sitewide.canonical.has(p)) add("canonical-missing-sitewide", u);
227
+ else if (!p.canonicals.length) add("canonical-missing", u);
228
+ else {
229
+ if (p.canonicals.length > 1) add("canonical-multiple", u, p.canonicals.join(" | "));
230
+ const c = urlOr(p.canonicals[0], p.base);
231
+ if (!c) add("canonical-bad-target", u, `not a valid URL: ${p.canonicals[0]}`);
232
+ else {
233
+ if (c.search) add("canonical-query", u, c.href);
234
+ if (c.origin !== EXPECT_ORIGIN) add("canonical-origin", u, c.href);
235
+ if (!samePath(toCrawl(c.href), u)) add("canonical-not-self", u, `→ ${c.href}`);
236
+ const t = pages.get(clean(toCrawl(c.href)));
237
+ if (t && (t.status !== 200 || (t.chain && t.chain.length > 1)))
238
+ add("canonical-bad-target", u, `${c.href} → ${t.chain && t.chain.length > 1 ? "redirect" : t.status}`);
239
+ }
240
+ }
241
+ if (!indexable(p)) continue;
242
+ checkedPages++;
243
+ for (const q of p.faqQs) {
244
+ const k = norm(q);
245
+ if (k) (faqMap.get(k) || faqMap.set(k, { q, pages: [] }).get(k)).pages.push(u);
246
+ }
247
+ if (p.titleCount > 1) add("title-multiple", u, `${p.titleCount} <title> tags`);
248
+ if (p.placeholder) add("placeholder-text", u, `“${p.placeholder}”`);
249
+ if (p.hashLinks) add("href-hash", u, `${p.hashLinks} link(s)`);
250
+ if (!p.lang) add("lang-missing", u);
251
+ if (sitewide.title.has(p)) add("title-missing-sitewide", u, p.title ? `“${p.title}”` : undefined);
252
+ else if (!p.title) add("title-missing", u);
253
+ else {
254
+ if (titleWidth(p.title) > 60)
255
+ add("title-long", u, `${widthText(p.title)}: ${p.title}`); // CJK characters count as two
256
+ else if (titleWidth(p.title) < 20) add("title-short", u, p.title);
257
+ (titleMap.get(p.title) || titleMap.set(p.title, []).get(p.title)).push(u);
258
+ if (BRAND && p.title.split(BRAND).length > 2) add("title-brand-twice", u, p.title);
259
+ }
260
+ // Errs towards not flagging: a word counts when its stem is on the page ("pricing" finds "prices"), an acronym when
261
+ // the page shows it in capitals, and the H1 counts as page text.
262
+ const tw = p.title ? titleWords(p.title).filter(w => !brandWords.has(w)) : [];
263
+ if (tw.length >= 2 && p.words >= 50) {
264
+ evalRules("META-09");
265
+ const onPage = " " + p.normText;
266
+ if (
267
+ !tw.some(w => onPage.includes(" " + w.slice(0, Math.max(4, w.length - 3)))) &&
268
+ ![...acronyms(p.title)].some(a => p.caps.has(a))
269
+ )
270
+ add("title-mismatch", u, `“${p.title}”: ${tw.join(", ")} aren't on the page`);
271
+ }
272
+ if (!p.description) add("desc-missing", u);
273
+ else {
274
+ if (p.description.length < 120 || p.description.length > 160)
275
+ add("desc-length", u, `${p.description.length} chars`);
276
+ (descMap.get(p.description) || descMap.set(p.description, []).get(p.description)).push(u);
277
+ }
278
+ // og:description is optional (https://ogp.me), but X falls back only to it and LinkedIn requires it. None says
279
+ // whether the meta description stands in, so it's listed only when that's missing too, and only beside a missing
280
+ // og:title or og:image: alone it's desc-missing's.
281
+ const noOg = [!p.ogTitle && "og:title", !p.ogImage && "og:image"].filter(Boolean);
282
+ if (noOg.length)
283
+ add(
284
+ "og-missing",
285
+ u,
286
+ [...noOg, !p.ogDescription && !p.description && "og:description"].filter(Boolean).join(", "),
287
+ );
288
+ // Without twitter:card, X shows at most the small summary card. A page with no share image gets og-missing instead.
289
+ // From X's cards markup guide, archived 30 May 2025; X has since taken its card docs down.
290
+ const card = p.twitterCard?.trim().toLowerCase();
291
+ if (card && !["summary", "summary_large_image", "app", "player"].includes(card))
292
+ add("twitter-card-invalid", u, `“${p.twitterCard}”`);
293
+ if (p.ogImage) {
294
+ if (!card) add("twitter-card-missing", u);
295
+ if (!p.ogImageSized) add("og-image-no-size", u);
296
+ const src = urlOr(p.ogImage, p.base),
297
+ c = src && clean(toCrawl(src.href));
298
+ if (c && new URL(c).origin === START_ORIGIN && !shareImages.has(c))
299
+ shareImages.set(c, { src: src.href, page: u });
300
+ }
301
+ if (sitewide.h1.has(p)) add("h1-missing-sitewide", u);
302
+ else if (p.h1Count === 0) add("h1-missing", u);
303
+ else if (p.h1Count > 1) add("h1-multiple", u, `${p.h1Count} H1s`);
304
+ const skips = [];
305
+ let prev = null;
306
+ for (const h of p.headings) {
307
+ if (prev !== null && h.level > prev + 1) skips.push(`H${prev} → H${h.level} (“${h.text.slice(0, 40)}”)`);
308
+ prev = h.level;
309
+ }
310
+ if (skips.length) add("heading-skip", u, skips.slice(0, 3).join("; "));
311
+ if (p.words < 150 && !(p.words < 30 && p.h1Count === 0)) add("thin-page", u, `${p.words} words`);
312
+ const noAlt = p.imgs.filter(i => !("alt" in i)).length;
313
+ if (noAlt) add("img-alt", u, `${noAlt} image(s)`);
314
+ const noDim = p.imgs.filter(
315
+ i => !(i.width && i.height) && i["data-nimg"] !== "fill" && !/position:\s*absolute/i.test(i.style || ""),
316
+ ).length;
317
+ if (noDim) add("img-dimensions", u, `${noDim} image(s)`);
318
+ const lcp = p.imgs[p.lcpIndex];
319
+ if (lcp && ((lcp.loading || "").toLowerCase() === "lazy" || p.lcpScriptLazy)) add("lazy-lcp", u, lcp.src || "");
320
+ // Counts stylesheets, not sizes: one or two are normal, six or more usually means plugin CSS loaded everywhere.
321
+ const blocking = [
322
+ p.blockingJs.length && `${p.blockingJs.length} script(s) without async or defer, e.g. ${p.blockingJs[0]}`,
323
+ p.blockingCss >= 6 && `${p.blockingCss} stylesheets`,
324
+ ].filter(Boolean);
325
+ if (blocking.length) add("render-blocking", u, blocking.join("; "));
326
+ if (p.bytes > 2 * 1024 * 1024) add("html-over-2mb", u, `${Math.round(p.bytes / 1024)} KB`);
327
+ else if (p.bytes > 500 * 1024) add("html-size", u, `${Math.round(p.bytes / 1024)} KB`);
328
+ if (p.elements > 1400) add("dom-size", u, `${p.elements.toLocaleString("en")} elements`);
329
+ if (p.nosnippet) add("nosnippet", u);
330
+ if (p.nofollow && !p.noindex)
331
+ add(
332
+ "page-nofollow",
333
+ u,
334
+ [p.robotsMeta && `meta: “${p.robotsMeta}”`, p.xRobots && `header: “${p.xRobots}”`].filter(Boolean).join(" · "),
335
+ );
336
+ const basics = [!p.doctype && "no doctype", !p.charset && "no charset", !p.viewport && "no mobile viewport"].filter(
337
+ Boolean,
338
+ );
339
+ if (basics.length) add("doc-basics", u, basics.join(", "));
340
+ if (p.charsetMismatch) add("charset-mismatch", u, p.charsetMismatch);
341
+ if (p.refreshTo) add("meta-refresh", u, `→ ${p.refreshTo}`);
342
+ evalRules("REND-10"); // only once a page was checked; PERF-10 waits for Chrome's own test
343
+ if (p.obsolete.length) add("obsolete-tags", u, p.obsolete.map(t => `<${t}>`).join(", "));
344
+ if (p.noStore) add("bfcache-no-store", u, `Cache-Control: ${p.headers.get("cache-control")}`);
345
+ if (p.unload) add("bfcache-unload", u, p.unload);
346
+ if (p.ogUrl && p.canonicals.length) {
347
+ const og = urlOr(p.ogUrl, p.base)?.href,
348
+ c = urlOr(p.canonicals[0], p.base)?.href;
349
+ if (c && og !== c)
350
+ add("og-url-mismatch", u, og ? `og:url ${og} · canonical ${c}` : `og:url isn't a valid URL: ${p.ogUrl}`);
351
+ }
352
+ const prod = test => p.products.find(test);
353
+ let pr;
354
+ if ((pr = prod(x => x.singleAggregate))) add("product-aggregate-offer", u, pr.name);
355
+ if ((pr = prod(x => x.noShipping)))
356
+ add("product-no-shipping", u, `${pr.name}: ${pr.noShipping} of ${pr.offers} offer(s)`);
357
+ if ((pr = prod(x => x.noReturns)))
358
+ add("product-no-returns", u, `${pr.name}: ${pr.noReturns} of ${pr.offers} offer(s)`);
359
+ if (
360
+ p.amounts.length &&
361
+ (pr = prod(x => x.prices.length && !x.prices.some(v => p.amounts.some(a => Math.abs(a - v) < 0.005))))
362
+ )
363
+ add(
364
+ "product-price-mismatch",
365
+ u,
366
+ `schema ${pr.prices.join(" / ")} · page shows ${p.amounts.slice(0, 3).join(", ")}`,
367
+ );
368
+ if (!p.largePreview) add("no-large-preview", u);
369
+ for (const i of p.imgs) {
370
+ try {
371
+ const src = new URL(i.src, p.base);
372
+ if (src.origin === new URL(u).origin && !images.has(src.href)) images.set(src.href, u);
373
+ } catch {}
374
+ }
375
+ if (p.jsonldErrors.length) add("jsonld-invalid", u, p.jsonldErrors[0]);
376
+ const allTypes = [...p.types, ...p.schemaOther]; // Google reads Microdata and RDFa too; only JSON-LD is validated here
377
+ if (!allTypes.length) add("jsonld-none", u);
378
+ else if (!p.types.length) add("schema-not-jsonld", u, p.schemaOther.join(", "));
379
+ if (!isHome(p) && !allTypes.includes("BreadcrumbList")) add("breadcrumb-missing", u);
380
+ if (p.deprecated.length) add("deprecated-schema", u, p.deprecated.join(", "));
381
+ if (p.hasRating) add("rating-review", u);
382
+ if (p.nap.length) evalRules("LOCAL-05");
383
+ // A service-area business may hide its street address (LOCAL-06), so it isn't asked to show it.
384
+ const napGone = p.nap.filter(
385
+ f =>
386
+ ![p, home?.html && home].some(r => r && shows(r, f)) &&
387
+ !(f.kind === "street address" && localBusiness()?.kind === "service-area"),
388
+ );
389
+ if (napGone.length)
390
+ add(
391
+ "nap-not-shown",
392
+ u,
393
+ `${napGone.map(f => `${f.kind} “${f.value}”`).join(" and ")} ${napGone.length > 1 ? "aren't" : "isn't"} shown on this page or the home page`,
394
+ );
395
+ const missingQ = p.faqQs.filter(q => !p.normText.includes(norm(q)));
396
+ if (missingQ.length)
397
+ add("faq-not-visible", u, `${missingQ.length} of ${p.faqQs.length}: “${missingQ[0].slice(0, 60)}”`);
398
+ if (p.links.length > 150 && !isHtmlSitemap(p)) add("too-many-links", u, `${p.links.length} links`); // an HTML sitemap is all links
399
+ const generic = p.links.filter(l =>
400
+ /^(click here|here|read more|learn more|more|this|link|details)$/i.test(l.text.trim()),
401
+ ).length;
402
+ if (generic) add("generic-anchor", u, `${generic} link(s)`);
403
+ if (p.emptyLinks.length) add("link-no-text", u, `${p.emptyLinks.length} link(s), e.g. ${p.emptyLinks[0]}`);
404
+ const insecure = p.anchors
405
+ .map(l => l.href)
406
+ .filter(h => /^http:\/\//i.test(h || "") && ownHosts.has(bareHost(urlOr(h)?.hostname || "")));
407
+ if (insecure.length) add("link-http", u, `${insecure.length} link(s), e.g. ${insecure[0]}`);
408
+ if (smSet.size && !smSet.has(p.url) && !smSet.has(u)) add("missing-from-sitemap", u);
409
+ for (const b of p.crumbs.slice(0, -1)) {
410
+ const t = pages.get(clean(toCrawl(b)));
411
+ if (t && t.status !== 200) add("breadcrumb-dead-level", u, `${b} → ${t.status}`);
412
+ }
413
+ }
414
+ // A retired type worth keeping gets one note for the site, not a finding.
415
+ for (const r of KEPT) {
416
+ const at = htmlPages.filter(p => p.kept.includes(r.type));
417
+ if (at.length)
418
+ notes.push(
419
+ `${r.type} on ${at.length} page(s), e.g. ${at[0].finalUrl}: Google retired ${r.feature} in ${r.since.slice(0, 4)}, but keep it: ${r.note}.`,
420
+ );
421
+ }
422
+ const cand = htmlPages.filter(p => p.shingles && !p.clientOnly && indexable(p));
423
+ for (const [i, j, dice] of nearPairs(cand.map(p => p.shingles)))
424
+ add("near-duplicate", cand[i].finalUrl, `${Math.round(dice * 100)}% shared with ${cand[j].finalUrl}`);
425
+ for (const { q, pages: ps } of faqMap.values())
426
+ if (ps.length > 1) add("faq-reused", ps[0], `“${q.slice(0, 70)}” on ${ps.length} pages`);
427
+ const PER_PAGE_RULES = [
428
+ "AI-01",
429
+ "REND-08",
430
+ "URL-04",
431
+ "META-01",
432
+ "META-02",
433
+ "META-04",
434
+ "META-05",
435
+ "CONTENT-01",
436
+ "CONTENT-02",
437
+ "CONTENT-04",
438
+ "CONTENT-05",
439
+ "CONTENT-08",
440
+ "CONTENT-09",
441
+ "REND-04",
442
+ "SCHEMA-01",
443
+ "SCHEMA-03",
444
+ "SCHEMA-04",
445
+ "SCHEMA-05",
446
+ "SCHEMA-07",
447
+ "MAP-03",
448
+ "LINK-05",
449
+ "LINK-06",
450
+ "PERF-03",
451
+ "PERF-04",
452
+ "PERF-06",
453
+ "REND-09",
454
+ "MEDIA-03",
455
+ "PERF-08",
456
+ ];
457
+ const nothingChecked = drawnByJs
458
+ ? `No page could be checked: ${drawnByJs === 1 ? "the page the crawler read is" : `the ${drawnByJs} pages the crawler read are`} drawn by JavaScript, with almost no content in the server HTML (see the client-rendered finding, REND-01).`
459
+ : "No indexable pages were checked (all noindex, non-canonical or failed). For a pre-launch site, re-run with --ignore-noindex.";
460
+ if (checkedPages === 0)
461
+ for (const r of PER_PAGE_RULES)
462
+ if (evaluated.delete(r)) notChecked.push({ rule: r, area: `${r} ${RULES[r][0]}`, reason: nothingChecked });
463
+ for (const [t, us] of titleMap) if (us.length > 1) for (const u of us) add("title-dup", u, t);
464
+ for (const [d, us] of descMap) if (us.length > 1) for (const u of us) add("desc-dup", u, d.slice(0, 80));
465
+ if (htmlPages.some(p => p.products?.length)) evalRules("SHOP-05");
466
+ evalRules("META-08");
467
+ checkHreflang(htmlPages, {
468
+ add,
469
+ canonicalFor,
470
+ statusOf: href => pages.get(clean(toCrawl(href)))?.status,
471
+ origin: EXPECT_ORIGIN,
472
+ });
473
+ return { checkedPages, images, shareImages, titleWords, brandWords, acronyms, localBusiness };
474
+ }