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,102 @@
1
+ // @ts-check
2
+ import { cookieProblems, cspProblems, hstsRead, serverHoles } from "./technical.mjs";
3
+ import { isLocal, urlOr } from "../crawl/fetch.mjs";
4
+
5
+ // Only Set-Cookie headers are seen, not cookies scripts set.
6
+ export function cookiesAndPolicies(site) {
7
+ const { htmlPages, home, add } = site;
8
+ // Load balancer and CDN cookies are skipped, since the site can't change their flags: AWS ALB and ELB stickiness,
9
+ // Azure App Service's ARRAffinity, F5 BIG-IP's BIGipServer<pool>, and Cloudflare's own.
10
+ // https://developers.cloudflare.com/fundamentals/reference/policies-compliances/cloudflare-cookies/
11
+ const INFRA_COOKIE =
12
+ /^(AWSALB(TG)?(CORS)?|AWSALBAPP-\d+|AWSELB|ARRAffinity(SameSite)?|BIGipServer.*|__cf\w+|_cfuvid|cf_clearance|cf_ob_info|cf_use_ob|cf_chl_\w+)$/;
13
+ const cookieSeen = new Set();
14
+ for (const p of htmlPages)
15
+ for (const c of p.headers.getSetCookie()) {
16
+ const name = c.split(";")[0].split("=")[0].trim();
17
+ if (cookieSeen.has(name) || INFRA_COOKIE.test(name)) continue;
18
+ cookieSeen.add(name);
19
+ const problems = cookieProblems(c, { https: p.finalUrl.startsWith("https:") });
20
+ if (problems.length) add("cookie-flags", p.finalUrl, `“${name}”: ${problems.join(", ")}`);
21
+ }
22
+ const POLICIES = new Set([
23
+ "no-referrer",
24
+ "no-referrer-when-downgrade",
25
+ "same-origin",
26
+ "origin",
27
+ "strict-origin",
28
+ "origin-when-cross-origin",
29
+ "strict-origin-when-cross-origin",
30
+ "unsafe-url",
31
+ ]);
32
+ // In the header the last valid value wins. https://www.w3.org/TR/referrer-policy/#parse-referrer-policy-from-header
33
+ const policyOf = v =>
34
+ (v || "")
35
+ .split(",")
36
+ .map(t => t.trim().toLowerCase())
37
+ .filter(t => POLICIES.has(t))
38
+ .at(-1);
39
+ for (const p of htmlPages) {
40
+ const header = p.headers.get("referrer-policy");
41
+ const unsafe = [
42
+ policyOf(header) === "unsafe-url" && `header: ${header}`,
43
+ policyOf(p.referrerMeta) === "unsafe-url" && `meta: ${p.referrerMeta}`,
44
+ ].filter(Boolean);
45
+ if (unsafe.length) add("referrer-unsafe", p.finalUrl, unsafe.join(" · "));
46
+ }
47
+ }
48
+
49
+ // Headers are checked on the home page, mixed content on every page. A Server version with a known hole is
50
+ // needs-decision, as it may be patched. A missing HSTS header is tls.mjs's no-hsts.
51
+ export function securityHeaders(site) {
52
+ const { htmlPages, home, add, extra, startOrigin: START_ORIGIN, expectOrigin: EXPECT_ORIGIN } = site;
53
+ if (home?.headers) {
54
+ const h = home.headers,
55
+ at = home.finalUrl,
56
+ sts = h.get("strict-transport-security");
57
+ if (!h.get("permissions-policy")) add("sec-headers", at, "Permissions-Policy");
58
+ const gaps = cspProblems(h.get("content-security-policy"));
59
+ if (gaps.length) add("csp-weak", at, gaps.join("; "));
60
+ const s = sts && hstsRead(sts);
61
+ // A header browsers ignore is hsts-invalid and nothing else. https://www.rfc-editor.org/rfc/rfc6797#section-8.1
62
+ if (s?.invalid) add("hsts-invalid", at, `${s.invalid}, so browsers ignore the whole header: ${sts}`);
63
+ else if (s) {
64
+ // A year is the preload list's minimum. https://hstspreload.org
65
+ if (s.maxAge < 31536000) {
66
+ const d = Math.round(s.maxAge / 86400);
67
+ add(
68
+ "hsts-short",
69
+ at,
70
+ `max-age=${s.maxAge} (${s.maxAge < 86400 ? "under a day" : `${d} day${d === 1 ? "" : "s"}`})`,
71
+ );
72
+ }
73
+ if (!s.includeSubDomains) add("hsts-no-subdomains", at, sts);
74
+ extra.hstsPreload = { ready: !s.missing.length, missing: s.missing };
75
+ }
76
+ const sv = serverHoles(h.get("server"));
77
+ if (sv)
78
+ add(
79
+ "server-known-holes",
80
+ at,
81
+ `Server: ${h.get("server")}: ${sv.cves.map(c => `${c.id} (${c.what}, fixed in ${c.fixed})`).join("; ")}`,
82
+ );
83
+ }
84
+ // A local copy's own files (the crawl origin or another local address) will be on https once deployed, so only other
85
+ // sites' http:// files count.
86
+ if (EXPECT_ORIGIN.startsWith("https:"))
87
+ for (const p of htmlPages) {
88
+ const bad = (p.insecure || []).filter(r => {
89
+ const o = urlOr(r.url)?.origin;
90
+ return o && o !== START_ORIGIN && !isLocal(o);
91
+ });
92
+ if (bad.length)
93
+ add(
94
+ "mixed-content",
95
+ p.finalUrl,
96
+ `${bad.length} resource${bad.length === 1 ? "" : "s"} over http://: ${bad
97
+ .slice(0, 3)
98
+ .map(r => `${r.kind} ${r.url}`)
99
+ .join(", ")}`,
100
+ );
101
+ }
102
+ }
@@ -0,0 +1,473 @@
1
+ // @ts-check
2
+ // Sitemap reading for the crawler, and the findings on the files and their entries.
3
+ import { attrs, decode, tagsOf } from "../lib/html.mjs";
4
+ import { clean } from "../crawl/fetch.mjs";
5
+ import { quote } from "../lib/findings.mjs";
6
+ import { pool } from "../crawl/queue.mjs";
7
+
8
+ const SITEMAP_URLS = 50000; // the protocol's limit per file: Google reads no further
9
+ export const SITEMAP_KEEP = 200000; // URLs kept from all the sitemap files, far more than a crawl fetches
10
+ // Sitemap files read at once, whatever --concurrency is: each may be 50 MB, and 8 at once can take 1 GB.
11
+ const SITEMAP_CONC = 2;
12
+ const XML_TAG =
13
+ /<([A-Za-z_][\w.:-]*)((?:\s+[A-Za-z_:][\w.:-]*\s*=\s*(?:"[^"<]*"|'[^'<]*'))*)\s*(\/?)>|<\/([A-Za-z_][\w.:-]*)\s*>/y;
14
+ const BAD_ENTITY = /&(?!(?:amp|lt|gt|quot|apos|#\d+|#x[\da-fA-F]+);)/;
15
+ // Where a sitemap stops being well-formed XML ("line 3, column 37: why"), or null. A small scan of the declaration,
16
+ // tags, attributes, entities and single root, not a full parser: DTDs, namespaces and the schema aren't checked.
17
+ function xmlError(s) {
18
+ const at = (i, why) =>
19
+ `line ${(s.slice(0, i).match(/\n/g) || []).length + 1}, column ${i - s.lastIndexOf("\n", i - 1)}: ${why}`;
20
+ const entity = (t, i) => {
21
+ const k = t.search(BAD_ENTITY);
22
+ if (k < 0) return null;
23
+ const name = /^&[^\s&;<]{1,20};/.exec(t.slice(k))?.[0];
24
+ return at(
25
+ i + k,
26
+ name ? `${name} isn't defined in XML (only &amp; &lt; &gt; &quot; &apos; are)` : "a bare & (write it as &amp;)",
27
+ );
28
+ };
29
+ const HTML = "it's an HTML page, not a sitemap";
30
+ const decl = s.search(/<\?xml[\s?]/);
31
+ if (decl > 0) return at(decl, "there's text or a blank line before <?xml …?>, which has to come first");
32
+ const stack = [];
33
+ let i = 0,
34
+ roots = 0;
35
+ while (i < s.length) {
36
+ const lt = s.indexOf("<", i),
37
+ text = s.slice(i, lt < 0 ? s.length : lt);
38
+ if (/\S/.test(text)) {
39
+ if (!stack.length)
40
+ return at(
41
+ i + text.search(/\S/),
42
+ roots ? "there's text after the last closing tag" : "there's text before the first tag",
43
+ );
44
+ const e = entity(text, i);
45
+ if (e) return e;
46
+ }
47
+ if (lt < 0) break;
48
+ const skip = [
49
+ ["<!--", "-->", "a comment isn't closed with -->"],
50
+ ["<![CDATA[", "]]>", "a CDATA section isn't closed with ]]>"],
51
+ ["<?", "?>", "a <?…?> instruction isn't closed"],
52
+ ].find(([open]) => s.startsWith(open, lt));
53
+ if (skip) {
54
+ const e = s.indexOf(skip[1], lt + skip[0].length);
55
+ if (e < 0) return at(lt, skip[2]);
56
+ i = e + skip[1].length;
57
+ continue;
58
+ }
59
+ if (s.startsWith("<!", lt)) {
60
+ if (/^<!doctype\s+html\b/i.test(s.slice(lt, lt + 20))) return at(lt, HTML);
61
+ const e = s.indexOf(">", lt);
62
+ if (e < 0) return at(lt, "a <!DOCTYPE> isn't closed");
63
+ i = e + 1;
64
+ continue;
65
+ }
66
+ XML_TAG.lastIndex = lt;
67
+ const m = XML_TAG.exec(s);
68
+ if (!m) return at(lt, `a broken tag: ${s.slice(lt, lt + 30).split("\n")[0]}…`);
69
+ i = XML_TAG.lastIndex;
70
+ if (m[4]) {
71
+ const open = stack.pop();
72
+ if (open !== m[4])
73
+ return at(lt, open ? `</${m[4]}> where </${open}> was expected` : `</${m[4]}> has no opening tag`);
74
+ continue;
75
+ }
76
+ const e = entity(m[2], lt + 1 + m[1].length);
77
+ if (e) return e;
78
+ if (!stack.length) {
79
+ if (roots++) return at(lt, "a second root element after the first one closed");
80
+ if (/^html$/i.test(m[1])) return at(lt, HTML);
81
+ }
82
+ if (!m[3]) stack.push(m[1]);
83
+ }
84
+ if (stack.length) return at(s.length, `the file ends before </${stack.at(-1)}>`);
85
+ return roots ? null : at(0, "there are no XML tags in it");
86
+ }
87
+ // A tag's text (CDATA unwrapped), or undefined when it's missing or empty.
88
+ const tagText = (h, t) =>
89
+ (h?.match(new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`)) || [])[1]?.replace(/<!\[CDATA\[|\]\]>/g, "").trim() ||
90
+ undefined;
91
+ // listed is false for the guessed /sitemap.xml, where an HTML page means no sitemap. cut means SITEMAP_KEEP URLs were
92
+ // kept and the rest, with any files after them, went unread. toCrawl(url) maps the public origin onto the crawl.
93
+ /** @typedef {{ url: string, status: number, html?: boolean, invalid?: string, tooBig?: boolean, urls?: number, nestedIn?: string }} SitemapFile */
94
+ async function readSitemaps(urls, listed = true, { fetchSitemap, toCrawl, conc }) {
95
+ const entries = [],
96
+ seen = new Set(),
97
+ files = /** @type {SitemapFile[]} */ ([]);
98
+ let cut = false;
99
+ const queue = urls.map(u => [u, listed, null]),
100
+ read = []; // [url, named, the sitemap index that lists it]; [that, answer]
101
+ while ((read.length || queue.length) && files.length < 60 && !cut) {
102
+ // The next conc files are fetched at once, then read in queue order. That holds conc whole files in memory (50 MB
103
+ // each at most); stream them if huge sitemaps turn up.
104
+ if (!read.length) {
105
+ const wave = [];
106
+ while (queue.length && wave.length < conc && files.length + wave.length < 60) {
107
+ const q = queue.shift();
108
+ if (!seen.has(q[0])) {
109
+ seen.add(q[0]);
110
+ wave.push(q);
111
+ }
112
+ }
113
+ read.push(...(await pool(wave, conc, async q => [q, await fetchSitemap(toCrawl(q[0]))])));
114
+ continue;
115
+ }
116
+ const [[u, named, parent], r] = read.shift(),
117
+ body = r.body || "";
118
+ // urls: 0 marks a file that answered but lists nothing (sitemap-empty).
119
+ if (r.status !== 200 || !(body.trim() || r.broken)) {
120
+ files.push(r.status === 200 ? { url: u, status: 200, urls: 0 } : { url: u, status: r.status });
121
+ continue;
122
+ }
123
+ const file = { url: u, status: 200 };
124
+ files.push(file);
125
+ if (!named && /^\s*<(!doctype\s+html|html)\b/i.test(body)) {
126
+ file.html = true;
127
+ continue;
128
+ }
129
+ const bad = r.broken || (body.includes("<") && !r.tooBig && xmlError(body));
130
+ if (bad) file.invalid = bad;
131
+ if (r.tooBig) file.tooBig = true;
132
+ // A text sitemap: one URL per line.
133
+ if (!body.includes("<")) {
134
+ const lines = body.split(/\s*\n\s*/).filter(l => /^https?:\/\/\S+$/.test(l));
135
+ file.urls = lines.length;
136
+ for (const l of lines.slice(0, SITEMAP_URLS)) {
137
+ if (entries.length === SITEMAP_KEEP) {
138
+ cut = true;
139
+ break;
140
+ }
141
+ entries.push({ loc: l, lastmod: null, sitemap: u, hints: false });
142
+ }
143
+ continue;
144
+ }
145
+ // Search Console reports an index listed in another index as an error; its sitemaps are still read here.
146
+ // No \s* around a lazy capture in these patterns: over a run of spaces with no closing tag it backtracks in cubic
147
+ // time (32 KB takes hours); the value is trimmed afterwards instead.
148
+ if (/<sitemapindex\b/i.test(body)) {
149
+ if (parent) file.nestedIn = parent;
150
+ const before = queue.length;
151
+ for (const m of body.matchAll(/<sitemap\b[\s\S]*?<loc>([\s\S]*?)<\/loc>/gi))
152
+ queue.push([decode(m[1].trim()), true, u]);
153
+ if (queue.length === before) file.urls = 0;
154
+ continue;
155
+ }
156
+ // Google accepts an RSS 2.0 or Atom 1.0 feed as a sitemap of recent URLs. An Atom entry's own link has rel
157
+ // alternate or no rel. Feed dates (RFC 822 in RSS) aren't W3C dates, so lastmod is left out.
158
+ // https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap
159
+ if (!/<urlset\b/i.test(body) && /<(rss|feed)\b/i.test(body)) {
160
+ const locs = [
161
+ ...[...body.matchAll(/<item\b[^>]*>([\s\S]*?)<\/item>/gi)].map(
162
+ m => tagText(m[1], "link") && decode(tagText(m[1], "link")),
163
+ ),
164
+ ...[...body.matchAll(/<entry\b[^>]*>([\s\S]*?)<\/entry>/gi)].map(
165
+ m => tagsOf(m[1], "link").find(l => l.href && /^(alternate)?$/i.test((l.rel || "").trim()))?.href,
166
+ ),
167
+ ].filter(Boolean);
168
+ file.urls = locs.length;
169
+ for (const loc of locs.slice(0, SITEMAP_URLS)) {
170
+ if (entries.length === SITEMAP_KEEP) {
171
+ cut = true;
172
+ break;
173
+ }
174
+ entries.push({ loc, lastmod: null, sitemap: u, hints: false });
175
+ }
176
+ continue;
177
+ }
178
+ file.urls = 0;
179
+ const hasNews = body.includes("<news:news");
180
+ // Image and video tags Google retired on 6 Aug 2022 have no effect and can stay, so they get a note, not a finding.
181
+ // https://developers.google.com/search/docs/crawling-indexing/sitemaps/image-sitemaps
182
+ // https://developers.google.com/search/docs/crawling-indexing/sitemaps/video-sitemaps
183
+ const retired = [
184
+ ...new Set(
185
+ [
186
+ ...body.matchAll(
187
+ /<(image:(?:caption|geo_location|title|license)|video:(?:category|gallery_loc|price|tvshow))\b|<video:player_loc\b[^>]*?\s(autoplay|allow_embed)\s*=/g,
188
+ ),
189
+ ].map(m => (m[1] ? `<${m[1]}>` : `${m[2]} on <video:player_loc>`)),
190
+ ),
191
+ ];
192
+ if (retired.length) file.retired = retired;
193
+ for (const m of body.matchAll(/<url\b[^>]*>([\s\S]*?)<\/url>/gi)) {
194
+ // Past a file's 50,000 URLs, or the 200,000 kept in all, the rest is only counted, for sitemap-too-big.
195
+ if (entries.length === SITEMAP_KEEP) cut = true;
196
+ if (cut || file.urls === SITEMAP_URLS) {
197
+ const rest = /<url\b/gi;
198
+ rest.lastIndex = m.index;
199
+ while (rest.exec(body)) file.urls++;
200
+ break;
201
+ }
202
+ file.urls++;
203
+ const loc = (m[1].match(/<loc>([\s\S]*?)<\/loc>/i) || [])[1]?.trim();
204
+ const lastmod = (m[1].match(/<lastmod>([\s\S]*?)<\/lastmod>/i) || [])[1]?.trim();
205
+ if (!loc) continue;
206
+ const e = {
207
+ loc: decode(loc),
208
+ lastmod: lastmod || null,
209
+ sitemap: u,
210
+ hints: /<(priority|changefreq)>/i.test(m[1]),
211
+ };
212
+ // Google News entries: the tags Google requires, and the first-published date.
213
+ const news = hasNews ? tagText(m[1], "news:news") : undefined,
214
+ pub = tagText(news, "news:publication");
215
+ if (news)
216
+ e.news = {
217
+ date: tagText(news, "news:publication_date"),
218
+ missing: ["news:publication", "news:name", "news:language", "news:publication_date", "news:title"].filter(
219
+ t => !tagText(t === "news:name" || t === "news:language" ? pub : news, t),
220
+ ),
221
+ };
222
+ // Each <video:video> needs a thumbnail, title, description (2,048 characters at most) and a content or player
223
+ // URL; each <image:image> needs <image:loc>, and a page may list 1,000 images at most.
224
+ if (m[1].includes("<video:video"))
225
+ e.videos = [...m[1].matchAll(/<video:video\b[^>]*>([\s\S]*?)<\/video:video>/g)].map(([, v]) =>
226
+ [
227
+ ...["video:thumbnail_loc", "video:title", "video:description"]
228
+ .filter(t => !tagText(v, t))
229
+ .map(t => `no <${t}>`),
230
+ tagText(v, "video:description")?.length > 2048 && "a description over 2,048 characters",
231
+ !tagText(v, "video:content_loc") &&
232
+ !tagText(v, "video:player_loc") &&
233
+ "no <video:content_loc> or <video:player_loc>",
234
+ ].filter(Boolean),
235
+ );
236
+ if (m[1].includes("<image:image")) {
237
+ const imgs = [...m[1].matchAll(/<image:image\b[^>]*\/>|<image:image\b[^>]*>([\s\S]*?)<\/image:image>/g)];
238
+ e.images = { count: imgs.length, noLoc: imgs.filter(x => !tagText(x[1], "image:loc")).length };
239
+ }
240
+ // hreflang alternates (<xhtml:link rel="alternate" hreflang href>), which Google reads here as in the HTML.
241
+ if (/<[\w.-]+:link\b/.test(m[1]))
242
+ e.hreflang = [...m[1].matchAll(/<[\w.-]+:link\b[^>]*>/g)]
243
+ .map(t => attrs(t[0]))
244
+ .filter(a => (a.rel || "").toLowerCase().split(/\s+/).includes("alternate") && a.hreflang && a.href)
245
+ .map(a => ({ lang: a.hreflang, href: a.href }));
246
+ // A page listed again in an image, video or news sitemap isn't a duplicate.
247
+ e.media = !!(e.news || e.videos || e.images);
248
+ entries.push(e);
249
+ }
250
+ }
251
+ // Files still queued after the 60-file limit went unread too, so pages in them can't be called missing.
252
+ const filesLeft = !cut && queue.some(([u]) => !seen.has(u));
253
+ return { entries, files, cut: cut || filesLeft, filesLeft };
254
+ }
255
+
256
+ // smUrls are robots.txt's sitemaps (smListed) or the guessed /sitemap.xml; the usual index names follow if they list
257
+ // nothing.
258
+ export async function findSitemaps(
259
+ smUrls,
260
+ smListed,
261
+ { startOrigin: START_ORIGIN, notes, fetchSitemap, toCrawl, conc = 1 },
262
+ ) {
263
+ // At least 1: with 0 (or NaN) no file would ever be asked for, and readSitemaps would loop forever.
264
+ const io = { fetchSitemap, toCrawl, conc: Math.max(1, Math.min(SITEMAP_CONC, conc || 1)) };
265
+ let sm = await readSitemaps(smUrls, smListed, io);
266
+ // The plugins' index names, then WordPress core's (since 5.5), and /sitemap.xml when robots.txt named other files: a
267
+ // stale Sitemap: line left after a move mustn't hide the real sitemap. The named files stay in files, so a broken one
268
+ // is still reported.
269
+ for (const path of [
270
+ ...(smListed ? ["/sitemap.xml"] : []),
271
+ "/sitemap_index.xml",
272
+ "/sitemap-index.xml",
273
+ "/wp-sitemap.xml",
274
+ ]) {
275
+ if (sm.entries.length) break;
276
+ if (smUrls.some(u => toCrawl(u) === START_ORIGIN + path)) continue;
277
+ const alt = await readSitemaps([START_ORIGIN + path], false, io);
278
+ if (alt.entries.length) sm = smListed ? { ...alt, files: [...sm.files, ...alt.files] } : alt;
279
+ }
280
+ if (sm.filesLeft)
281
+ notes.push(
282
+ "The sitemap index lists more than 60 sitemap files. Only the first 60 were read, so the URLs in the rest weren't checked.",
283
+ );
284
+ else if (sm.cut)
285
+ notes.push(
286
+ `The sitemaps list more than ${SITEMAP_KEEP.toLocaleString("en-US")} URLs. Only the first ${SITEMAP_KEEP.toLocaleString("en-US")} were read, so the rest, and any sitemap files after them, weren't checked.`,
287
+ );
288
+ return sm;
289
+ }
290
+
291
+ // Findings on the sitemap files themselves, and a missing sitemap.
292
+ export function checkSitemapFiles(sm, smUrls, { add, findings }) {
293
+ for (const f of sm.files) {
294
+ if (f.invalid) add("sitemap-invalid", f.url, f.invalid);
295
+ if (f.tooBig || f.urls > 50000)
296
+ add("sitemap-too-big", f.url, f.tooBig ? "over 50 MB uncompressed" : `${f.urls.toLocaleString("en-US")} URLs`);
297
+ if (f.nestedIn) add("sitemap-index-nested", f.url, `listed in ${f.nestedIn}`);
298
+ if (f.urls === 0 && !f.invalid && !f.html) add("sitemap-empty", f.url);
299
+ // A file robots.txt or an index names that doesn't load, while URLs came from others (else it's sitemap-missing).
300
+ if (f.status !== 200 && sm.entries.length)
301
+ add("sitemap-unreachable", f.url, f.status ? `status ${f.status}` : "no answer");
302
+ }
303
+ if (!sm.entries.length && !findings.has("sitemap-invalid") && !findings.has("sitemap-empty"))
304
+ add(
305
+ "sitemap-missing",
306
+ smUrls.join(", "),
307
+ sm.files.map(f => `${f.url} → ${f.status}${f.html ? ", an HTML page" : ""}`).join("; ") || undefined,
308
+ );
309
+ }
310
+
311
+ // Runs once the public origin (expectOrigin) is settled. Entries on the crawled site go straight into the crawl queue,
312
+ // as a sitemap lists pages, not links. firstSm, the first sitemap URL, carries the site-wide lastmod finding.
313
+ export function checkSitemapEntries(
314
+ sm,
315
+ firstSm,
316
+ {
317
+ add,
318
+ notes,
319
+ evalRules,
320
+ expectOrigin: EXPECT_ORIGIN,
321
+ startOrigin: START_ORIGIN,
322
+ toCrawl,
323
+ inSection,
324
+ crawler: { seen, queue },
325
+ },
326
+ ) {
327
+ const smSet = new Map(); // crawl URL -> entry
328
+ evalRules("MAP-02", "MAP-04");
329
+ // Google asks to keep session IDs out of URLs: the common names and ASP.NET's (S(…)) path form.
330
+ // https://developers.google.com/search/docs/crawling-indexing/url-structure
331
+ const SESSION_ID =
332
+ /[;?&](?:jsessionid|phpsessid|sessionid|session_id|sessid|aspsessionid[a-z]*|cftoken)=[^&#;]*|\/\(S\([a-z0-9]+\)\)/i;
333
+ for (const e of sm.entries) {
334
+ // A <loc> must be under 2,048 characters, and Google ignores #fragments. https://www.sitemaps.org/protocol.html
335
+ if (e.loc.length >= 2048)
336
+ add(
337
+ "sitemap-url-too-long",
338
+ e.sitemap,
339
+ `${e.loc.slice(0, 80)}… (${e.loc.length.toLocaleString("en-US")} characters)`,
340
+ );
341
+ const sid = SESSION_ID.exec(e.loc)?.[0];
342
+ if (sid || e.loc.includes("#")) add("sitemap-session-ids", e.loc, sid ? `session ID ${sid}` : "a #fragment");
343
+ // Google wants absolute URLs and crawls them exactly as listed, so a relative path or another scheme is flagged,
344
+ // not skipped. https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap
345
+ let o;
346
+ try {
347
+ o = /^https?:\/\//i.test(e.loc) && new URL(e.loc).origin;
348
+ } catch {}
349
+ if (!o) {
350
+ add("sitemap-url-invalid", e.sitemap, e.loc.slice(0, 200));
351
+ continue;
352
+ }
353
+ if (o !== EXPECT_ORIGIN) add("sitemap-origin", e.loc, `expected ${EXPECT_ORIGIN}`);
354
+ const c = clean(toCrawl(e.loc));
355
+ if (!c) continue;
356
+ smSet.set(c, e);
357
+ if (new URL(c).origin === START_ORIGIN && !seen.has(c) && inSection(new URL(c).pathname)) {
358
+ seen.add(c);
359
+ queue.push(c);
360
+ }
361
+ }
362
+ // 90% or more of the dates on one day (a local threshold) reads as a build date, not real edits.
363
+ const lm = sm.entries.map(e => (e.lastmod || "").slice(0, 10)).filter(Boolean),
364
+ byDay = new Map();
365
+ for (const d of lm) byDay.set(d, (byDay.get(d) || 0) + 1);
366
+ const [day, same] = [...byDay].sort((a, b) => b[1] - a[1])[0] || [];
367
+ if (lm.length >= 5 && same >= 0.9 * lm.length)
368
+ add("sitemap-lastmod-same", firstSm, `${same === lm.length ? "all" : `${same} of`} ${lm.length} entries: ${day}`);
369
+ // Per file: lastmod after tomorrow (a day of slack for time zones) or not a W3C date, and tags Google ignores.
370
+ const W3C_DATE =
371
+ /^\d{4}(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01])(T([01]\d|2[0-3]):[0-5]\d(:[0-5]\d(\.\d+)?)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d))?)?)?$/;
372
+ // The regex allows 2026-02-30; a real day survives the round trip through Date.
373
+ const realDay = s => {
374
+ const [y, m, d] = s.slice(0, 10).split("-").map(Number);
375
+ return !d || new Date(Date.UTC(y, m - 1, d)).getUTCDate() === d;
376
+ };
377
+ const validLastmod = s => W3C_DATE.test(s) && realDay(s);
378
+ // File URLs are site text (robots.txt's Sitemap: lines, an index's <loc>), so the notes quote and shorten them.
379
+ for (const f of sm.files)
380
+ if (f.retired)
381
+ notes.push(
382
+ `${quote(f.url)} uses image or video sitemap tags Google has retired: ${f.retired.join(", ")}. Google has ignored them since August 2022, so they do no harm, but they can go when the sitemap code is next touched.`,
383
+ );
384
+ const bySitemap = new Map();
385
+ for (const e of sm.entries) (bySitemap.get(e.sitemap) || bySitemap.set(e.sitemap, []).get(e.sitemap)).push(e);
386
+ // The same URL twice in one file or in two regular sitemaps; a media or news entry for a listed page is fine.
387
+ const plainIn = new Map(),
388
+ inFile = new Set(),
389
+ dupes = new Map(); // URL -> first regular file; "file URL"; file -> [[URL, other file]]
390
+ for (const e of sm.entries) {
391
+ const key = `${e.sitemap} ${e.loc}`,
392
+ other = inFile.has(key) ? e.sitemap : !e.media && plainIn.get(e.loc);
393
+ inFile.add(key);
394
+ if (!e.media && !plainIn.has(e.loc)) plainIn.set(e.loc, e.sitemap);
395
+ if (other) (dupes.get(e.sitemap) || dupes.set(e.sitemap, []).get(e.sitemap)).push([e.loc, other]);
396
+ }
397
+ for (const [file, ds] of dupes)
398
+ add(
399
+ "sitemap-duplicate-urls",
400
+ file,
401
+ `${ds.length.toLocaleString("en-US")} URL(s) listed more than once, e.g. ${ds[0][0]} ${ds[0][1] === file ? "twice in this file" : `(also in ${ds[0][1]})`}`,
402
+ );
403
+ const hintedFiles = []; // [file, hinted, total]
404
+ for (const [file, es] of bySitemap) {
405
+ const videos = es.flatMap(e => (e.videos || []).map(missing => ({ loc: e.loc, missing }))),
406
+ badVideos = videos.filter(v => v.missing.length);
407
+ if (badVideos.length)
408
+ add(
409
+ "video-sitemap-tags",
410
+ file,
411
+ `${badVideos.length} of ${videos.length} videos, e.g. ${badVideos[0].loc}: ${badVideos[0].missing.join(", ")}`,
412
+ );
413
+ const pictured = es.filter(e => e.images),
414
+ badImages = pictured.filter(e => e.images.noLoc || e.images.count > 1000);
415
+ if (badImages.length) {
416
+ const { loc, images: i } = badImages[0];
417
+ add(
418
+ "image-sitemap-tags",
419
+ file,
420
+ `${badImages.length} of ${pictured.length} pages with images, e.g. ${loc}: ${[i.noLoc && `${i.noLoc} <image:image> without <image:loc>`, i.count > 1000 && `${i.count.toLocaleString("en-US")} images (1,000 at most)`].filter(Boolean).join(", ")}`,
421
+ );
422
+ }
423
+ const dated = es.filter(e => e.lastmod),
424
+ eg = list => `${list.length} of ${es.length} entries, e.g. ${list[0].loc}: ${list[0].lastmod}`;
425
+ const invalid = dated.filter(e => !validLastmod(e.lastmod)),
426
+ future = dated.filter(e => validLastmod(e.lastmod) && Date.parse(e.lastmod) > Date.now() + 864e5);
427
+ if (future.length) add("sitemap-lastmod-future", file, eg(future));
428
+ if (invalid.length) add("sitemap-lastmod-invalid", file, eg(invalid));
429
+ const hinted = es.filter(e => e.hints).length;
430
+ if (hinted) hintedFiles.push([file, hinted, es.length]);
431
+ // A news sitemap, per Google's rules: the required tags, a full W3C date, articles from the last two days (a day
432
+ // of slack for time zones and date-only values), and at most 1,000 of them.
433
+ const news = es.filter(e => e.news);
434
+ if (!news.length) continue;
435
+ const say = (list, what) => `${list.length} of ${news.length} articles, e.g. ${list[0].loc}: ${what(list[0].news)}`;
436
+ const newsDate = d => !!d && d.length >= 10 && validLastmod(d);
437
+ const untagged = news.filter(e => e.news.missing.length || !newsDate(e.news.date)),
438
+ old = news.filter(e => newsDate(e.news.date) && Date.parse(e.news.date) < Date.now() - 3 * 864e5);
439
+ if (untagged.length)
440
+ add(
441
+ "news-sitemap-tags",
442
+ file,
443
+ say(untagged, n =>
444
+ n.missing.length
445
+ ? `no ${n.missing.map(t => `<${t}>`).join(", ")}`
446
+ : `publication date “${n.date}” isn't a W3C date such as 2026-11-17 or 2026-11-17T10:30:00+00:00`,
447
+ ),
448
+ );
449
+ if (old.length)
450
+ add(
451
+ "news-sitemap-old",
452
+ file,
453
+ say(old, n => n.date),
454
+ );
455
+ if (news.length > 1000) add("news-sitemap-too-many", file, `${news.length.toLocaleString("en-US")} articles`);
456
+ }
457
+ // Ignored, not harmful, so one note for all the sitemaps rather than a finding.
458
+ if (hintedFiles.length) {
459
+ const n = x => x.toLocaleString("en-US"),
460
+ [hinted, entries] = hintedFiles.reduce(([h, t], [, a, b]) => [h + a, t + b], [0, 0]);
461
+ const where =
462
+ hintedFiles.length === 1
463
+ ? `${quote(hintedFiles[0][0])}: ${n(hinted)} of ${n(entries)} entries use`
464
+ : `${hintedFiles.length} sitemap files (${n(hinted)} of ${n(entries)} entries${hintedFiles.length > 3 ? ", e.g." : ":"} ${hintedFiles
465
+ .slice(0, 3)
466
+ .map(([f]) => quote(f))
467
+ .join(", ")}) use`;
468
+ notes.push(
469
+ `${where} <priority> or <changefreq>. Google and Bing ignore both, so they can go when the sitemap code is next touched; an accurate lastmod is the signal that counts.`,
470
+ );
471
+ }
472
+ return smSet;
473
+ }