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,184 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Crawl coverage: parameter copies, soft 404s, malformed URLs, sections, site size and Search Console's indexed count.
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { CHECKS, RULES } from "../crawl/catalog.mjs";
|
|
5
|
+
import { urlOr } from "../crawl/fetch.mjs";
|
|
6
|
+
import { parseCsv } from "../lib/csv.mjs";
|
|
7
|
+
|
|
8
|
+
// include and exclude are --include and --exclude; sm is the sitemaps read; gscIndexing is --gsc-indexing's file.
|
|
9
|
+
export function checkCoverage(
|
|
10
|
+
site,
|
|
11
|
+
{ section: SECTION, include: INCLUDE, exclude: EXCLUDE, crawler, sm, gscIndexing },
|
|
12
|
+
) {
|
|
13
|
+
const {
|
|
14
|
+
htmlPages,
|
|
15
|
+
smSet,
|
|
16
|
+
add,
|
|
17
|
+
evalRules,
|
|
18
|
+
evaluated,
|
|
19
|
+
findings,
|
|
20
|
+
notes,
|
|
21
|
+
notChecked,
|
|
22
|
+
extra,
|
|
23
|
+
startOrigin: START_ORIGIN,
|
|
24
|
+
indexable,
|
|
25
|
+
canonicalFor,
|
|
26
|
+
} = site;
|
|
27
|
+
const { seen, fetched, capped } = crawler;
|
|
28
|
+
// A parameter page whose clean URL was also crawled, with no canonical dropping the parameters, is an indexable copy.
|
|
29
|
+
// Tracking and paging parameters are skipped: Google wants paginated pages to stay indexable.
|
|
30
|
+
// https://developers.google.com/search/docs/specialty/ecommerce/pagination-and-incremental-page-loading
|
|
31
|
+
{
|
|
32
|
+
const TRACKING = /^(utm_\w+|gclid|gbraid|wbraid|dclid|fbclid|msclkid|yclid|igshid|mc_cid|mc_eid|_gl|_ga)$/i,
|
|
33
|
+
PAGING = /^(page|p|pg|paged|offset|start)$/i;
|
|
34
|
+
// A copy is the same page: same title as the page without the parameters. A different title is a different page
|
|
35
|
+
// (WordPress's /?page_id=2), and a page that lists itself in its own hreflang is a language version (WPML's ?lang=fr).
|
|
36
|
+
const titleKey = t =>
|
|
37
|
+
String(t || "")
|
|
38
|
+
.trim()
|
|
39
|
+
.toLowerCase();
|
|
40
|
+
const cleanTitles = new Map(
|
|
41
|
+
htmlPages.filter(p => !new URL(p.finalUrl).search).map(p => [new URL(p.finalUrl).pathname, titleKey(p.title)]),
|
|
42
|
+
);
|
|
43
|
+
const listsItself = p =>
|
|
44
|
+
(p.hreflang || []).some(h => {
|
|
45
|
+
try {
|
|
46
|
+
return new URL(h.href, p.finalUrl).href === p.finalUrl;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
for (const p of htmlPages) {
|
|
52
|
+
const x = new URL(p.finalUrl),
|
|
53
|
+
keys = [...new Set(x.searchParams.keys())].filter(k => !TRACKING.test(k) && !PAGING.test(k));
|
|
54
|
+
if (!keys.length || p.clientOnly || !indexable(p) || !cleanTitles.has(x.pathname)) continue;
|
|
55
|
+
if (cleanTitles.get(x.pathname) !== titleKey(p.title) || listsItself(p)) continue;
|
|
56
|
+
evalRules("CRAWL-10");
|
|
57
|
+
const c = canonicalFor(p);
|
|
58
|
+
if (!c || urlOr(c)?.search)
|
|
59
|
+
add(
|
|
60
|
+
"parameter-page-indexable",
|
|
61
|
+
p.finalUrl,
|
|
62
|
+
`parameters ${keys.join(", ")}; ${c ? `canonical ${c}` : "no canonical"}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// A small, well-linked site (about 500 pages, all reached from the home page) without video or news may not need a
|
|
67
|
+
// sitemap. A crawl that read no indexable page (a site that's down) can't call the site small.
|
|
68
|
+
// https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview
|
|
69
|
+
if (
|
|
70
|
+
findings.has("sitemap-missing") &&
|
|
71
|
+
!capped &&
|
|
72
|
+
!SECTION &&
|
|
73
|
+
site.start.pathname === "/" &&
|
|
74
|
+
!findings.has("deep-page") &&
|
|
75
|
+
htmlPages.some(p => indexable(p)) &&
|
|
76
|
+
htmlPages.filter(p => indexable(p)).length <= 500 &&
|
|
77
|
+
!htmlPages.some(p => (p.types || []).some(t => t === "VideoObject" || t === "NewsArticle"))
|
|
78
|
+
) {
|
|
79
|
+
const f = findings.get("sitemap-missing");
|
|
80
|
+
findings.delete("sitemap-missing");
|
|
81
|
+
for (const e of f.evidence) add("sitemap-missing-small", e.url, e.detail);
|
|
82
|
+
}
|
|
83
|
+
// A 200 page that shows an error message is a soft 404 to Google.
|
|
84
|
+
// https://developers.google.com/search/docs/crawling-indexing/http-network-errors
|
|
85
|
+
// English only, matched at the start so "How to fix a 404 error" isn't one; other languages need their own.
|
|
86
|
+
const ERROR_PAGE =
|
|
87
|
+
/^(?:error\s*)?(?:404|410)\b|^(?:oops\W*)?(?:page |post |product |article )?not found\b|^(?:sorry\W*)?(?:this |that |the )?page (?:does not|doesn't|cannot be|can't be|could not be|couldn't be|was not|wasn't) (?:exist|found)|^no (?:results|products|posts|items|articles) (?:were )?found\b|^nothing (?:was )?found\b/i;
|
|
88
|
+
for (const p of htmlPages) {
|
|
89
|
+
if (p.status !== 200 || !indexable(p)) continue;
|
|
90
|
+
const said = [
|
|
91
|
+
["title", p.title],
|
|
92
|
+
["H1", p.headings?.find(h => h.level === 1)?.text],
|
|
93
|
+
].find(([, t]) => t && ERROR_PAGE.test(t.trim()));
|
|
94
|
+
if (said) add("soft-404-page", p.finalUrl, `${said[0]} “${said[1].slice(0, 80)}”`);
|
|
95
|
+
}
|
|
96
|
+
for (const p of htmlPages)
|
|
97
|
+
if (!p.clientOnly && p.badUrls?.length)
|
|
98
|
+
add("url-malformed", p.finalUrl, `${p.badUrls.length} address(es): ${p.badUrls.slice(0, 5).join(", ")}`);
|
|
99
|
+
// One section: links from the pages left out aren't known, so depth and orphans can't be judged.
|
|
100
|
+
if (SECTION) {
|
|
101
|
+
extra.section = { include: INCLUDE, exclude: EXCLUDE };
|
|
102
|
+
notes.push(
|
|
103
|
+
`Crawled one part of the site: ${[INCLUDE.length && `paths starting with ${INCLUDE.join(" or ")}`, EXCLUDE.length && `leaving out ${EXCLUDE.join(" and ")}`].filter(Boolean).join(", ")}, plus the start page. robots.txt and the sitemap files were still read whole.`,
|
|
104
|
+
);
|
|
105
|
+
for (const rule of ["LINK-01", "LINK-02"]) {
|
|
106
|
+
for (const k of [...findings.keys()]) if (CHECKS[k][0] === rule) findings.delete(k);
|
|
107
|
+
evaluated.delete(rule);
|
|
108
|
+
notChecked.push({
|
|
109
|
+
rule,
|
|
110
|
+
area: `${rule} ${RULES[rule][0]}`,
|
|
111
|
+
reason:
|
|
112
|
+
"Only part of the site was crawled (--include or --exclude), so links from the pages left out aren't known. Crawl the whole site to check this.",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// A folder with pages below it (/blog/ for /blog/a/) is a section; every other page counts under "/".
|
|
117
|
+
{
|
|
118
|
+
const parts = p => new URL(p.finalUrl).pathname.split("/").filter(Boolean);
|
|
119
|
+
const folders = new Set(
|
|
120
|
+
htmlPages
|
|
121
|
+
.map(parts)
|
|
122
|
+
.filter(s => s.length > 1)
|
|
123
|
+
.map(s => s[0]),
|
|
124
|
+
),
|
|
125
|
+
count = new Map();
|
|
126
|
+
for (const p of htmlPages) {
|
|
127
|
+
const s = parts(p)[0],
|
|
128
|
+
key = folders.has(s) ? `/${s}/` : "/";
|
|
129
|
+
count.set(key, (count.get(key) || 0) + 1);
|
|
130
|
+
}
|
|
131
|
+
extra.sections = [...count]
|
|
132
|
+
.sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))
|
|
133
|
+
.slice(0, 50)
|
|
134
|
+
.map(([path, pages]) => ({ path, pages, share: Math.round((1000 * pages) / htmlPages.length) / 1000 }));
|
|
135
|
+
}
|
|
136
|
+
// Every URL the crawl knew of, from links and sitemaps, is a floor for the site's size.
|
|
137
|
+
if (capped) {
|
|
138
|
+
const listed = [...smSet.keys()].filter(u => new URL(u).origin === START_ORIGIN).length,
|
|
139
|
+
n = x => x.toLocaleString("en-US");
|
|
140
|
+
extra.siteSize = { crawled: fetched, known: seen.size, sitemapUrls: listed };
|
|
141
|
+
notes.push(
|
|
142
|
+
`The crawl stopped at ${n(fetched)} pages (--max). It knew of ${n(seen.size)} URLs on the site from links and sitemaps (the sitemaps list ${n(listed)}${sm.cut ? ", and more past the part read" : ""}), so the site has at least ${n(Math.max(seen.size, listed))} URLs. The pages past the limit weren't checked; raise --max to check them.`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
// The Page indexing export's Chart.csv is undocumented, so columns are found by the English export's names (Date
|
|
146
|
+
// first, Indexed, Not indexed). A file without them gets a note, not a guess.
|
|
147
|
+
if (typeof gscIndexing === "string") {
|
|
148
|
+
const file = gscIndexing;
|
|
149
|
+
let rows = [];
|
|
150
|
+
try {
|
|
151
|
+
rows = parseCsv(readFileSync(file, "utf8"));
|
|
152
|
+
} catch (e) {
|
|
153
|
+
notes.push(`--gsc-indexing: couldn't read ${file} (${e.message}).`);
|
|
154
|
+
}
|
|
155
|
+
const keys = Object.keys(rows[0] || {}),
|
|
156
|
+
on = keys.find(k => /^indexed$/i.test(k)),
|
|
157
|
+
off = keys.find(k => /^not indexed$/i.test(k)),
|
|
158
|
+
count = s => Number(String(s ?? "").replace(/\D/g, ""));
|
|
159
|
+
const last =
|
|
160
|
+
on && off
|
|
161
|
+
? rows
|
|
162
|
+
.filter(r => /^\d{4}-\d{2}-\d{2}$/.test(r[keys[0]]))
|
|
163
|
+
.sort((a, b) => (a[keys[0]] < b[keys[0]] ? -1 : 1))
|
|
164
|
+
.at(-1)
|
|
165
|
+
: null;
|
|
166
|
+
if (last) {
|
|
167
|
+
extra.indexing = {
|
|
168
|
+
date: last[keys[0]],
|
|
169
|
+
indexed: count(last[on]),
|
|
170
|
+
notIndexed: count(last[off]),
|
|
171
|
+
crawlIndexable: htmlPages.filter(p => indexable(p)).length,
|
|
172
|
+
capped,
|
|
173
|
+
};
|
|
174
|
+
const i = extra.indexing,
|
|
175
|
+
n = x => x.toLocaleString("en-US");
|
|
176
|
+
notes.push(
|
|
177
|
+
`Search Console counted ${n(i.indexed)} indexed pages (and ${n(i.notIndexed)} not indexed) on ${i.date}; this crawl found ${n(i.crawlIndexable)} pages meant to be indexed${capped ? " before it stopped at --max" : ""}. Google counts every URL it knows, old and parameter URLs too, so the two rarely match exactly; a big gap either way is worth a look in the Page indexing report.`,
|
|
178
|
+
);
|
|
179
|
+
} else if (keys.length)
|
|
180
|
+
notes.push(
|
|
181
|
+
`--gsc-indexing: ${file} has no dated rows with Indexed and Not indexed columns. It takes the chart table (Chart.csv) of Search Console's Page indexing export, in English, so Google's indexed count wasn't compared.`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Links to a #name the target page lacks, and the crawler's back-off when a site asks it to slow down.
|
|
3
|
+
|
|
4
|
+
export const CHECKS = {
|
|
5
|
+
"link-fragment-missing": [
|
|
6
|
+
"CRAWL-07",
|
|
7
|
+
"low",
|
|
8
|
+
n => `${n} link(s) jump to a part of a page that isn't there`,
|
|
9
|
+
"A link that ends in `#name` should open its page at the element with `id=\"name\"`. When the page has no such element, the browser opens it at the top, and the visitor has to look for the part the link promised. This check reads the HTML the server sends: an id that the page's own JavaScript adds later isn't seen, so open one of these links in a browser before changing anything. Pages built only in the browser aren't checked, since their ids come from JavaScript.",
|
|
10
|
+
'Give the section the id the link uses (`<h2 id="prices">`), or change the link to the id the section has. Ids must match exactly, capital letters included.',
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Tab, menu and dialog toggles: a script reads their #name, so they're skipped, as in visual.mjs.
|
|
15
|
+
const widget = a =>
|
|
16
|
+
/^(button|tab)$/i.test((a.role || "").trim()) || ["aria-controls", "data-toggle", "data-bs-toggle"].some(k => k in a);
|
|
17
|
+
/** Links to a #name, as unique [page URL without the hash, name] pairs. Skips a bare # and #top (browsers read both
|
|
18
|
+
* as the page top), router hashes (#/… and #!…) and non-http schemes. Of a text fragment, only the part before :~:
|
|
19
|
+
* is a name.
|
|
20
|
+
* @param {{ href?: string, role?: string }[]} anchors
|
|
21
|
+
* @param {string} base
|
|
22
|
+
* @returns {[string, string][]} */
|
|
23
|
+
export function fragmentLinks(anchors, base) {
|
|
24
|
+
const out = new Map();
|
|
25
|
+
for (const a of anchors) {
|
|
26
|
+
if (!a.href?.includes("#") || widget(a)) continue;
|
|
27
|
+
let u;
|
|
28
|
+
try {
|
|
29
|
+
u = new URL(a.href.trim(), base);
|
|
30
|
+
} catch {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const name = u.hash.slice(1).split(":~:")[0];
|
|
34
|
+
if (!/^https?:$/.test(u.protocol) || !name || /^top$/i.test(name) || /^[!/]/.test(name)) continue;
|
|
35
|
+
u.hash = "";
|
|
36
|
+
out.set(`${u.href}#${name}`, [u.href, name]);
|
|
37
|
+
}
|
|
38
|
+
return [...out.values()];
|
|
39
|
+
}
|
|
40
|
+
/** Matches the #name as written or percent-decoded, as browsers try both. Ids are case-sensitive.
|
|
41
|
+
* @param {Set<string>} ids
|
|
42
|
+
* @param {string} name */
|
|
43
|
+
export const hasName = (ids, name) => {
|
|
44
|
+
if (ids.has(name)) return true;
|
|
45
|
+
try {
|
|
46
|
+
return ids.has(decodeURIComponent(name));
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Every fixed wait in the crawler, speed.mjs's PageSpeed retry included. SEO_SUPERVISOR_NO_PAUSES makes them 0 ms:
|
|
53
|
+
* the tests' offline guard sets it, and it isn't a user setting.
|
|
54
|
+
* @param {number} ms */
|
|
55
|
+
export const sleep = ms => new Promise(ok => setTimeout(ok, process.env.SEO_SUPERVISOR_NO_PAUSES ? 0 : ms));
|
|
56
|
+
|
|
57
|
+
// Back-off after a 429, 503 or no answer: `until` is when requests may resume, `ms` the total paused, `busy` and
|
|
58
|
+
// `silent` the causes. Pauses stop at PAUSE_CAP in total so a struggling site can't stall the crawl; `full` marks that.
|
|
59
|
+
export const PAUSE_CAP = 120000;
|
|
60
|
+
export function brake(cap = PAUSE_CAP) {
|
|
61
|
+
const s = {
|
|
62
|
+
until: 0,
|
|
63
|
+
ms: 0,
|
|
64
|
+
busy: 0,
|
|
65
|
+
silent: 0,
|
|
66
|
+
full: false,
|
|
67
|
+
/** Pause every request until `ms` from `now`, within what's left of the cap. */
|
|
68
|
+
pause(ms, now = Date.now()) {
|
|
69
|
+
const from = Math.max(s.until, now),
|
|
70
|
+
want = now + ms - from,
|
|
71
|
+
more = Math.min(want, cap - s.ms);
|
|
72
|
+
if (want > more) s.full = true;
|
|
73
|
+
if (more > 0) {
|
|
74
|
+
s.ms += more;
|
|
75
|
+
s.until = from + more;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
return s;
|
|
80
|
+
}
|
|
81
|
+
// The crawl note, or null when nothing slowed the crawl. Google advises a 429 or 503 only for a few hours, two days at
|
|
82
|
+
// most (Search Central blog, "Moving to a CDN without overwhelming your origin", 11 Nov 2026).
|
|
83
|
+
/** @param {{ busy: number, silent: number, ms: number, full: boolean }} s */
|
|
84
|
+
export function slowNote({ busy, silent, ms, full }) {
|
|
85
|
+
if (!busy && !silent) return null;
|
|
86
|
+
const n = (k, one) => `${k} ${one}${k === 1 ? "" : "s"}`;
|
|
87
|
+
const why = [
|
|
88
|
+
busy && `the site sent ${n(busy, "answer")} of 429 (too many requests) or 503 (server busy)`,
|
|
89
|
+
silent && `${n(silent, "request")} got no answer (the connection dropped or timed out)`,
|
|
90
|
+
]
|
|
91
|
+
.filter(Boolean)
|
|
92
|
+
.join(", and ");
|
|
93
|
+
const time = ms >= 1000 ? `${Math.round(ms / 1000)} s` : "under a second";
|
|
94
|
+
return `The crawler slowed down: ${why}. It paused every request to the site for ${time} in all, then asked each of those pages once more${full ? `. The pauses stopped at ${PAUSE_CAP / 60000} minutes in all, our own limit, so later ones were asked again at once` : ""}. A page that still failed is reported as a server error.${busy ? " Google says to answer 429 or 503 only for a short time (a few hours, 1 to 2 days at most), so if this happens on the live site, check the server's or CDN's rate limits." : ""}`;
|
|
95
|
+
}
|