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,192 @@
1
+ // @ts-check
2
+ // Plain-language writing notes for English pages, and a reading-ease check for CI when run on its own.
3
+ import { readFileSync, readdirSync, statSync, existsSync } from "node:fs";
4
+ import { join, relative, sep } from "node:path";
5
+ import { isMain } from "../lib/is-main.mjs";
6
+
7
+ // Filler and stock phrases: a short local list.
8
+ const STOCK = [
9
+ "in today's fast-paced world",
10
+ "in today's digital age",
11
+ "ever-evolving landscape",
12
+ "it's important to note",
13
+ "it's worth noting",
14
+ "delve into",
15
+ "a testament to",
16
+ "unlock the power of",
17
+ "unlock the full potential",
18
+ "harness the power of",
19
+ "to the next level",
20
+ "look no further",
21
+ "game-changer",
22
+ "cutting-edge",
23
+ "state-of-the-art",
24
+ "rest assured",
25
+ "without further ado",
26
+ "embark on a journey",
27
+ "navigate the complexities",
28
+ "seamlessly integrate",
29
+ "plays a crucial role",
30
+ "plays a vital role",
31
+ ];
32
+ // Phrases hold letters, spaces, apostrophes and hyphens only. A curly apostrophe matches too, and a hyphen may be a
33
+ // space or nothing.
34
+ const STOCK_RE = STOCK.map(
35
+ p =>
36
+ /** @type {[string, RegExp]} */ ([
37
+ p,
38
+ new RegExp(`\\b${p.replace(/'/g, "['’]").replace(/-/g, "[- ]?").replace(/ /g, "\\s+")}\\b`, "i"),
39
+ ]),
40
+ );
41
+
42
+ const ENT = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
43
+ const decode = s =>
44
+ s.replace(/&(#x[0-9a-f]{1,6}|#\d{1,7}|\w+);/gi, (m, e) => {
45
+ if (e[0] !== "#") return ENT[e.toLowerCase()] ?? m;
46
+ const n = e[1].toLowerCase() === "x" ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
47
+ return n <= 0x10ffff ? String.fromCodePoint(n) : m;
48
+ });
49
+ // What's left out: code, tables, maths, forms' option lists and anything that isn't read as text.
50
+ const SKIP =
51
+ /<(pre|code|kbd|samp|var|table|math|select|textarea|script|style|noscript|template|svg)\b[\s\S]*?<\/\1>|<!--[\s\S]*?-->/gi;
52
+ // A <p> ends at </p>, the next <p> or a block element, as browsers close it. Only <p> text is read; text in bare
53
+ // <div>s and list items isn't, so a page built without <p> gets no notes rather than wrong ones.
54
+ const PARA =
55
+ /<p\b[^>]*>([\s\S]*?)(?=<\/p>|<p\b|<\/?(?:div|section|article|main|aside|header|footer|nav|ul|ol|li|dl|h[1-6]|blockquote|figure|form|table|body)\b|$)/gi;
56
+
57
+ // The page's main HTML as plain text: one paragraph per <p>, separated by a blank line, and a <br> as a line break.
58
+ export function writingText(html) {
59
+ return [...html.replace(SKIP, " ").matchAll(PARA)]
60
+ .map(m =>
61
+ decode(
62
+ m[1]
63
+ .replace(/\s+/g, " ")
64
+ .replace(/<br\b[^>]*>/gi, "\n")
65
+ .replace(/<[^>]+>/g, " "),
66
+ )
67
+ .replace(/[^\S\n]+/g, " ")
68
+ .replace(/ ?\n ?/g, "\n")
69
+ .trim(),
70
+ )
71
+ .filter(Boolean)
72
+ .join("\n\n");
73
+ }
74
+
75
+ const SENTENCES = new Intl.Segmenter("en", { granularity: "sentence" });
76
+ const wordsOf = s => s.split(/\s+/).filter(w => /[\p{L}\p{N}]/u.test(w));
77
+ const syllables = w => {
78
+ w = w.toLowerCase().replace(/[^a-z]/g, "");
79
+ let n = (w.match(/[aeiouy]+/g) || []).length;
80
+ if (n > 1 && /[^aeiouy]e$/.test(w) && !/[^aeiouy]le$/.test(w)) n--; // a silent final e ("make"), but not "table"
81
+ return Math.max(1, n);
82
+ };
83
+ const quote = s => (s.length > 300 ? s.slice(0, 299) + "…" : s);
84
+ // A stock phrase with up to 4 words either side, inside its own paragraph, so rewrite mode can find it in the source.
85
+ // The 100 characters before it keep the backward search short.
86
+ const inContext = (para, re) => {
87
+ const m = re.exec(para);
88
+ const before = para.slice(Math.max(0, m.index - 100), m.index).match(/(?:\S+\s+){0,4}\S*$/)[0];
89
+ const after = para.slice(m.index + m[0].length).match(/^\S*(?:\s+\S+){0,4}/)[0];
90
+ return quote((before + m[0] + after).replace(/\s+/g, " "));
91
+ };
92
+
93
+ export function writingFeatures(text, lang) {
94
+ const none = {
95
+ longSentences: 0,
96
+ longestSentence: null,
97
+ longParagraphs: 0,
98
+ stockPhrases: [],
99
+ readingEase: null,
100
+ examples: [],
101
+ };
102
+ // English only: the thresholds, the phrases and the formula are all English ones.
103
+ if (!/^en(?![a-z])/i.test(lang || "")) return none;
104
+ const paras = String(text || "")
105
+ .split(/\n{2,}/)
106
+ .map(p => p.trim())
107
+ .filter(Boolean);
108
+ const sentences = paras
109
+ .flatMap(p => [...SENTENCES.segment(p)].map(s => s.segment.replace(/\s+/g, " ").trim()))
110
+ .map(s => [s, wordsOf(s)])
111
+ .filter(([, w]) => w.length);
112
+ // Over 35 words a sentence or 150 a paragraph is long: rough local guides, not Google's.
113
+ const long = sentences.filter(([, w]) => w.length > 35);
114
+ const longest = long.reduce((a, b) => (b[1].length > a[1].length ? b : a), long[0]);
115
+ const words = sentences.flatMap(([, w]) => w);
116
+ // Flesch, "A new readability yardstick", Journal of Applied Psychology 32(3), 1948. Syllables are counted by vowel
117
+ // groups, so it's a rough guide.
118
+ const ease =
119
+ 206.835 -
120
+ 1.015 * (words.length / sentences.length) -
121
+ 84.6 * (words.reduce((n, w) => n + syllables(w), 0) / words.length);
122
+ const stock = STOCK_RE.flatMap(([p, re]) => {
123
+ const para = paras.find(x => re.test(x));
124
+ return para ? [[p, inContext(para, re)]] : [];
125
+ });
126
+ return {
127
+ longSentences: long.length,
128
+ longestSentence: longest ? quote(longest[0]) : null,
129
+ longParagraphs: paras.filter(p => wordsOf(p).length > 150).length,
130
+ stockPhrases: stock.map(([p]) => p),
131
+ readingEase: words.length >= 100 ? Math.max(0, Math.min(100, Math.round(ease))) : null, // too few words make it noise
132
+ // The first 12 words of up to 3 long sentences, then each stock phrase in context.
133
+ examples: [
134
+ ...long.slice(0, 3).map(([s]) => quote(s.split(" ").slice(0, 12).join(" ") + "…")),
135
+ ...stock.map(([, c]) => c),
136
+ ],
137
+ };
138
+ }
139
+
140
+ // The opt-in CI check (examples/hooks/reading-ease.yml). The default pass mark, 60, is where Flesch's table moves from
141
+ // "standard" to "fairly difficult". It never touches the audit or its score.
142
+ if (isMain(import.meta.url)) {
143
+ const args = process.argv.slice(2),
144
+ at = args.indexOf("--min"),
145
+ min = at >= 0 ? Number(args[at + 1]) : 60;
146
+ const inputs = args.filter((a, i) => !a.startsWith("--") && !(at >= 0 && i === at + 1));
147
+ if (!inputs.length || !(min >= 0 && min <= 100) || inputs.some(p => !existsSync(p))) {
148
+ console.error(
149
+ "usage: node writing.mjs <file|folder ...> [--min 60] (the pass mark is a reading ease from 0 to 100; every path must exist)",
150
+ );
151
+ process.exit(2);
152
+ }
153
+ const walk = d =>
154
+ readdirSync(d, { withFileTypes: true }).flatMap(e =>
155
+ e.isDirectory()
156
+ ? e.name.startsWith(".") || e.name === "node_modules"
157
+ ? []
158
+ : walk(join(d, e.name))
159
+ : /\.html?$/i.test(e.name)
160
+ ? [join(d, e.name)]
161
+ : [],
162
+ );
163
+ const pages = inputs.flatMap(p =>
164
+ statSync(p).isDirectory() ? walk(p).map(f => [f, relative(p, f).split(sep).join("/")]) : [[p, p]],
165
+ );
166
+ const scored = [];
167
+ for (const [file, name] of pages) {
168
+ const html = readFileSync(file, "utf8"),
169
+ lang = html.match(/<html\b[^>]*\blang\s*=\s*["']?([\w-]+)/i)?.[1];
170
+ const body = html.replace(/^[\s\S]*?<body\b[^>]*>/i, "");
171
+ const main =
172
+ body.match(/<main\b[^>]*>([\s\S]*?)<\/main>/i)?.[1] ??
173
+ body.replace(/<(header|nav|footer|aside)\b[\s\S]*?<\/\1>/gi, " ");
174
+ const ease = writingFeatures(writingText(main), lang).readingEase;
175
+ if (ease != null) scored.push([ease, name]);
176
+ }
177
+ const low = scored.filter(([e]) => e < min);
178
+ console.log(
179
+ `Reading ease (Flesch 1948: 0 to 100, higher is easier). SEO Supervisor's own check, not Google's; it never changes the audit score.\nPass mark: ${min}.`,
180
+ );
181
+ for (const [e, name] of scored) console.log(`${String(e).padStart(5)} ${name}${e < min ? ` below ${min}` : ""}`);
182
+ if (pages.length > scored.length)
183
+ console.log(`Skipped ${pages.length - scored.length} page(s): not English, or under 100 words.`);
184
+ console.log(
185
+ !scored.length
186
+ ? "No English page had 100 words or more to score."
187
+ : low.length
188
+ ? `${low.length} of ${scored.length} pages scored below ${min}.`
189
+ : `All ${scored.length} pages scored ${min} or more.`,
190
+ );
191
+ process.exitCode = low.length ? 1 : 0;
192
+ }
@@ -0,0 +1,452 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ // Common Crawl's view of a site: its pages in the newest crawl, its domain rank, and whether the saved copies of known
4
+ // linking pages link to it. The linking sites themselves are never visited.
5
+ import { writeFileSync, mkdirSync, readFileSync } from "node:fs";
6
+ import { dirname, resolve } from "node:path";
7
+ import { Readable } from "node:stream";
8
+ import { createGunzip, gunzipSync } from "node:zlib";
9
+ import { setTimeout as sleep } from "node:timers/promises";
10
+ import { isMain } from "./lib/is-main.mjs";
11
+ import { parseArgs } from "./lib/args.mjs";
12
+ import { Fail, runMain, warnProxy } from "./lib/cli.mjs";
13
+ import { bodyUpTo } from "./lib/http.mjs";
14
+ import { linkingPages, linksTo, pageNofollow } from "./backlinks.mjs";
15
+
16
+ const USAGE =
17
+ 'usage: node commoncrawl.mjs --site https://www.example.com [--keys seo-audit/keys.json] [--csv "Latest links.csv"] [--urls links.txt] [--rank [--rank-max-mb 500]] [--out seo-audit/commoncrawl.json] [--yes]';
18
+ // SEO_CC_* point the script at the tests' local servers.
19
+ const UA = "seo-supervisor-commoncrawl",
20
+ COLLINFO = process.env.SEO_CC_COLLINFO || "https://index.commoncrawl.org/collinfo.json",
21
+ DATA = "https://data.commoncrawl.org/";
22
+ const GRAPHINFO = process.env.SEO_CC_GRAPHINFO || "https://index.commoncrawl.org/graphinfo.json",
23
+ GRAPH = process.env.SEO_CC_GRAPH || "https://data.commoncrawl.org/projects/hyperlinkgraph/";
24
+ const MAX = 20,
25
+ KB = 1024,
26
+ MB = 1024 * KB,
27
+ BUSY = new Set([429, 503, 504]);
28
+ // Byte caps: the crawl list, the site's index lines (1,000 at most), one page's index lines, one saved record.
29
+ const CAP = { list: MB, site: MB, page: 64 * KB, record: MB };
30
+ const bare = h => h.toLowerCase().replace(/^www\./, "");
31
+
32
+ // body is null when the answer exceeds cap. Redirects are errors so only Common Crawl's own hosts are ever asked.
33
+ async function get(url, cap, headers = {}) {
34
+ const r = await fetch(url, {
35
+ headers: { "user-agent": UA, ...headers },
36
+ redirect: "error",
37
+ signal: AbortSignal.timeout(30000),
38
+ });
39
+ return { status: r.status, body: await bodyUpTo(r, cap) };
40
+ }
41
+ const jsonLines = buf =>
42
+ buf
43
+ .toString("utf8")
44
+ .split("\n")
45
+ .flatMap(l => {
46
+ try {
47
+ const x = JSON.parse(l);
48
+ return x && typeof x === "object" ? [x] : [];
49
+ } catch {
50
+ return [];
51
+ }
52
+ });
53
+ const why = e => (e.name === "TimeoutError" ? "no answer within 30 seconds" : e.cause?.code || e.message);
54
+
55
+ // Splits a WARC response record into the crawled page's X-Robots-Tag values and its body.
56
+ function warc(buf) {
57
+ const s = buf.toString("utf8"),
58
+ a = s.indexOf("\r\n\r\n"),
59
+ b = s.indexOf("\r\n\r\n", a + 4);
60
+ if (a < 0 || b < 0) return null;
61
+ const headers = s
62
+ .slice(a + 4, b)
63
+ .split("\r\n")
64
+ .slice(1)
65
+ .map(l => l.split(/:(.*)/s))
66
+ .filter(([k, v]) => v != null && k.trim().toLowerCase() === "x-robots-tag")
67
+ .map(([, v]) => v.trim());
68
+ return { headers, body: s.slice(b + 4) };
69
+ }
70
+
71
+ // The domain ranks file is gzipped TSV, most-linked first, with reversed domains: harmonicc_pos, harmonicc_val,
72
+ // pr_pos, pr_val, host_rev, n_hosts. With no per-domain lookup it's streamed (about 2.5 GB in all) and never stored,
73
+ // stopping at the domain or the cap; 500 MB covers about the top 27 million domains. The edges file is never read, so
74
+ // linking sites come only from linking pages already known.
75
+ // https://data.commoncrawl.org/projects/hyperlinkgraph/
76
+ const RANK_CAP_MB = 500;
77
+ // The registered domain, reversed as the graph writes it (shop.acme.co.uk gives uk.co.acme). A two-letter TLD after a
78
+ // label of 3 letters or fewer counts as the suffix; use the Public Suffix List if a domain comes out wrong.
79
+ export function rankDomain(hostname) {
80
+ const l = bare(hostname).split(".");
81
+ return l
82
+ .slice(l.length >= 3 && l.at(-1).length === 2 && l.at(-2).length <= 3 ? -3 : -2)
83
+ .reverse()
84
+ .join(".");
85
+ }
86
+ export async function domainRank(site, { graphinfo = GRAPHINFO, graph = GRAPH, capBytes = RANK_CAP_MB * MB } = {}) {
87
+ const rev = rankDomain(new URL(site).hostname),
88
+ domain = rev.split(".").reverse().join("."),
89
+ checked = new Date().toISOString().slice(0, 10);
90
+ let g;
91
+ try {
92
+ const r = await get(graphinfo, CAP.list),
93
+ list = r.status === 200 && r.body ? JSON.parse(/** @type {any} */ (r.body)) : null;
94
+ // The id goes into a URL path, so only letters, digits, . _ and -, never "..".
95
+ // A host-only graph has no domain ranks.
96
+ g =
97
+ Array.isArray(list) &&
98
+ list.find(
99
+ x =>
100
+ typeof x?.id === "string" &&
101
+ /^[A-Za-z0-9._-]+$/.test(x.id) &&
102
+ !x.id.includes("..") &&
103
+ x.stats?.domain?.nodes > 0,
104
+ );
105
+ } catch (e) {
106
+ return {
107
+ domain,
108
+ checked,
109
+ found: null,
110
+ note: `Couldn't read Common Crawl's list of web graphs (${why(e)}), so the rank wasn't looked up.`,
111
+ };
112
+ }
113
+ if (!g)
114
+ return {
115
+ domain,
116
+ checked,
117
+ found: null,
118
+ note: "Common Crawl's list of web graphs had no domain graph, so the rank wasn't looked up.",
119
+ };
120
+ const domains = g.stats.domain.nodes,
121
+ ac = new AbortController();
122
+ let res;
123
+ try {
124
+ res = await fetch(`${graph}${g.id}/domain/${g.id}-domain-ranks.txt.gz`, {
125
+ headers: { "user-agent": UA },
126
+ redirect: "error",
127
+ signal: ac.signal,
128
+ });
129
+ } catch (e) {
130
+ return {
131
+ release: g.id,
132
+ domain,
133
+ checked,
134
+ found: null,
135
+ note: `Couldn't reach Common Crawl's rank file (${why(e)}).`,
136
+ };
137
+ }
138
+ if (res.status !== 200 || !res.body) {
139
+ ac.abort();
140
+ return {
141
+ release: g.id,
142
+ domain,
143
+ checked,
144
+ found: null,
145
+ note: `Common Crawl's rank file answered ${res.status}, so the rank wasn't read.`,
146
+ };
147
+ }
148
+ const src = Readable.fromWeb(res.body),
149
+ gz = createGunzip();
150
+ let bytes = 0,
151
+ capped = false,
152
+ scanned = 0,
153
+ hit = null,
154
+ rest = "";
155
+ src.on("error", () => {});
156
+ src.pipe(gz);
157
+ // Added after pipe(), so the chunk that crosses the cap still reaches gunzip.
158
+ src.on("data", c => {
159
+ bytes += c.length;
160
+ if (bytes > capBytes && !capped) {
161
+ capped = true;
162
+ src.unpipe(gz);
163
+ gz.end();
164
+ }
165
+ });
166
+ try {
167
+ read: for await (const chunk of gz) {
168
+ const lines = (rest + chunk).split("\n");
169
+ rest = lines.pop();
170
+ for (const line of lines) {
171
+ if (!line || line[0] === "#") continue;
172
+ const f = line.split("\t");
173
+ scanned = Number(f[0]) || scanned;
174
+ if (f[4] === rev) {
175
+ hit = f;
176
+ break read;
177
+ }
178
+ }
179
+ }
180
+ } catch {
181
+ /* A stream cut at the cap ends in a gzip error; lines already read still count. */
182
+ }
183
+ if (!hit && !capped && rest) {
184
+ const f = rest.split("\t");
185
+ if (f[4] === rev) hit = f;
186
+ } // a last line with no newline
187
+ ac.abort();
188
+ src.destroy();
189
+ gz.destroy();
190
+ if (hit)
191
+ return {
192
+ release: g.id,
193
+ domain,
194
+ checked,
195
+ found: true,
196
+ harmonicPos: Number(hit[0]),
197
+ harmonic: Number(hit[1]),
198
+ pageRankPos: Number(hit[2]),
199
+ pageRank: Number(hit[3]),
200
+ hosts: Number(hit[5]),
201
+ domains,
202
+ };
203
+ return { release: g.id, domain, checked, found: false, capped, scanned, domains, readMB: Math.round(bytes / MB) };
204
+ }
205
+
206
+ // pages are known linking pages. collinfo, data and pause are for tests.
207
+ export async function commonCrawl(site, pages, { collinfo = COLLINFO, data = DATA, pause = 1000 } = {}) {
208
+ const notes = [],
209
+ host = bare(new URL(site).hostname);
210
+ // Only the newest crawl is asked; add older ones from collinfo.json if too few linking pages turn up.
211
+ let crawl;
212
+ try {
213
+ const r = await get(collinfo, CAP.list),
214
+ newest = r.status === 200 && r.body ? JSON.parse(/** @type {any} */ (r.body))?.[0] : null;
215
+ if (typeof newest?.id !== "string" || typeof newest["cdx-api"] !== "string")
216
+ throw new Error(`its list of crawls answered ${r.status}`);
217
+ crawl = {
218
+ id: newest.id,
219
+ name: typeof newest.name === "string" ? newest.name : newest.id,
220
+ api: new URL(newest["cdx-api"]),
221
+ };
222
+ } catch (e) {
223
+ notes.push(`Couldn't read Common Crawl's list of crawls (${why(e)}), so nothing was looked up.`);
224
+ return { commonCrawl: null, notes };
225
+ }
226
+ // The list could point the index anywhere; only collinfo.json's own host is trusted.
227
+ if (crawl.api.origin !== new URL(collinfo).origin) {
228
+ notes.push(
229
+ `Common Crawl's list of crawls points its index at ${crawl.api.host}, not ${new URL(collinfo).host}, so it wasn't used.`,
230
+ );
231
+ return { commonCrawl: null, notes };
232
+ }
233
+
234
+ // One request at a time, 1 s apart: Common Crawl calls the index's rate limits strict but publishes no number. A busy
235
+ // answer stops all further lookups.
236
+ let asked = 0,
237
+ busy = null;
238
+ const index = async (params, cap) => {
239
+ if (asked++) await sleep(pause);
240
+ const r = await get(`${crawl.api.href}?${new URLSearchParams({ ...params, output: "json" })}`, cap);
241
+ if (BUSY.has(r.status)) busy = r.status;
242
+ return r;
243
+ };
244
+
245
+ // Up to 1,000 of the site's captures, subdomains included.
246
+ let siteInfo = null;
247
+ try {
248
+ const r = await index({ url: host, matchType: "domain", fl: "url", limit: "1000" }, CAP.site);
249
+ const caps = r.status === 404 ? [] : r.status === 200 && r.body ? jsonLines(r.body) : null;
250
+ const isHome = u => {
251
+ try {
252
+ const x = new URL(u);
253
+ return bare(x.hostname) === host && x.pathname === "/" && !x.search;
254
+ } catch {
255
+ return false;
256
+ }
257
+ };
258
+ if (caps)
259
+ siteInfo = {
260
+ captures: caps.length,
261
+ capped: caps.length >= 1000,
262
+ pages: new Set(caps.map(c => c.url)).size,
263
+ home: caps.some(c => isHome(c.url)),
264
+ };
265
+ else
266
+ notes.push(
267
+ `Common Crawl's index answered ${r.status} about ${host}, so whether the site is in it wasn't found out.`,
268
+ );
269
+ if (caps && !caps.length)
270
+ notes.push(
271
+ `Common Crawl's newest crawl (${crawl.name}) has none of ${host}'s pages. If robots.txt blocks CCBot, Common Crawl's crawler, that's why (commoncrawl.org/ccbot).`,
272
+ );
273
+ } catch (e) {
274
+ notes.push(`Couldn't ask Common Crawl's index about ${host} (${why(e)}).`);
275
+ }
276
+
277
+ // A linking page's saved copy in the crawl, and the links to the site in it.
278
+ /** @returns {Promise<{ state: string, reason?: string, captured?: string, links?: any[], pageNofollow?: any }>} */
279
+ async function look(url) {
280
+ if (busy) return { state: "not-checked" };
281
+ try {
282
+ const r = await index({ url, limit: "5" }, CAP.page);
283
+ if (busy) return { state: "not-checked" };
284
+ if (r.status === 404) return { state: "not-in-crawl" };
285
+ if (r.status !== 200 || !r.body)
286
+ return { state: "not-checked", reason: `Common Crawl's index answered ${r.status}` };
287
+ const caps = jsonLines(r.body),
288
+ c = caps.find(x => x.status === "200") || caps[0];
289
+ if (!c) return { state: "not-in-crawl" };
290
+ const captured = /^\d{8}/.test(c.timestamp)
291
+ ? `${c.timestamp.slice(0, 4)}-${c.timestamp.slice(4, 6)}-${c.timestamp.slice(6, 8)}`
292
+ : null,
293
+ at = captured ? { captured } : {};
294
+ if (c.status !== "200")
295
+ return { state: "not-read", ...at, reason: `Common Crawl's crawler got status ${c.status} for it` };
296
+ if (!/html/i.test(c.mime || "")) return { state: "not-read", ...at, reason: "it isn't a web page" };
297
+ const offset = Number(c.offset),
298
+ length = Number(c.length);
299
+ if (
300
+ !/^crawl-data\/[\w./-]+$/.test(c.filename || "") ||
301
+ c.filename.includes("..") ||
302
+ !Number.isSafeInteger(offset) ||
303
+ offset < 0 ||
304
+ !Number.isSafeInteger(length) ||
305
+ length <= 0
306
+ )
307
+ return { state: "not-read", ...at, reason: "Common Crawl's index didn't say where the saved copy is" };
308
+ if (length > CAP.record)
309
+ return { state: "not-read", ...at, reason: "its saved copy is larger than 1 MB, so it wasn't downloaded" };
310
+ // A byte-range request reads just this record, a few KB.
311
+ // https://commoncrawl.org/blog/you-can-now-build-directly-on-common-crawl-from-the-browser
312
+ const d = await get(new URL(c.filename, data).href, CAP.record, {
313
+ range: `bytes=${offset}-${offset + length - 1}`,
314
+ });
315
+ if (d.status !== 206 || !d.body)
316
+ return { state: "not-read", ...at, reason: `Common Crawl's data server answered ${d.status}` };
317
+ let rec = null;
318
+ try {
319
+ rec = warc(gunzipSync(d.body));
320
+ } catch {}
321
+ // A page that isn't HTML text (still compressed, or cut off) isn't judged.
322
+ if (!rec || !/<[a-z!]/i.test(rec.body.slice(0, 4096)))
323
+ return { state: "not-read", ...at, reason: "its saved copy couldn't be read" };
324
+ const links = linksTo(rec.body, url, host),
325
+ page = pageNofollow(rec.body, rec.headers);
326
+ return {
327
+ state: links.length ? "links" : "no-link",
328
+ ...at,
329
+ ...(links.length && { links }),
330
+ ...(page && { pageNofollow: page }),
331
+ };
332
+ } catch (e) {
333
+ return { state: "not-checked", reason: `couldn't reach Common Crawl (${why(e)})` };
334
+ }
335
+ }
336
+ const all = [...new Set(pages)],
337
+ list = all.slice(0, MAX),
338
+ linking = [];
339
+ for (const url of list) linking.push({ url, ...(await look(url)) });
340
+ const skipped = linking.filter(p => p.state === "not-checked" && !p.reason).length;
341
+ if (busy && skipped)
342
+ notes.push(
343
+ `Common Crawl's index server is busy (it answered ${busy}), so ${skipped} linking page${skipped === 1 ? " wasn't" : "s weren't"} looked up. Try again later.`,
344
+ );
345
+ if (all.length > MAX)
346
+ notes.push(`${all.length - MAX} more linking pages weren't looked up: at most ${MAX} are looked up per run.`);
347
+ const sites = [...new Set(linking.filter(p => p.state === "links").map(p => bare(new URL(p.url).hostname)))];
348
+ return {
349
+ commonCrawl: {
350
+ when: new Date().toISOString(),
351
+ crawl: { id: crawl.id, name: crawl.name },
352
+ site: siteInfo,
353
+ linkingPages: linking,
354
+ linkingSites: sites,
355
+ },
356
+ notes,
357
+ };
358
+ }
359
+
360
+ async function main(argv) {
361
+ const args = parseArgs(argv, {
362
+ flags: ["site", "keys", "csv", "urls", "rank-max-mb", "out"],
363
+ booleans: ["rank", "yes"],
364
+ positionals: 0,
365
+ usage: USAGE,
366
+ });
367
+ const str = k => (typeof args[k] === "string" ? args[k] : null);
368
+ if (!str("site")) throw new Fail(USAGE);
369
+ let site;
370
+ try {
371
+ site = new URL(args.site);
372
+ } catch {}
373
+ if (!site || !/^https?:$/.test(site.protocol))
374
+ throw new Fail(`commoncrawl: --site must be the site's address, like https://www.example.com (got ${args.site})`);
375
+ const pages = [
376
+ ...new Set(
377
+ linkingPages({ keys: str("keys"), csv: str("csv"), urls: str("urls") }).filter(u => /^https?:\/\//i.test(u)),
378
+ ),
379
+ ];
380
+ const n = Math.min(pages.length, MAX),
381
+ host = bare(site.hostname),
382
+ out = resolve(str("out") || "seo-audit/commoncrawl.json");
383
+ const capMb = str("rank-max-mb") ? Number(args["rank-max-mb"]) : RANK_CAP_MB;
384
+ if (args.rank && !(Number.isFinite(capMb) && capMb >= 10 && capMb <= 3000))
385
+ throw new Fail(
386
+ "commoncrawl: --rank-max-mb must be a number of MB from 10 to 3000 (the whole rank file is about 2,500).",
387
+ );
388
+ // A rank under 90 days old is reused: the graph changes monthly and the read is large.
389
+ let saved = null;
390
+ try {
391
+ const r = JSON.parse(readFileSync(out, "utf8"))?.commonCrawl?.rank;
392
+ if (
393
+ r?.domain === rankDomain(site.hostname).split(".").reverse().join(".") &&
394
+ r.found !== null &&
395
+ Date.now() - Date.parse(r.checked) < 90 * 864e5
396
+ )
397
+ saved = r;
398
+ } catch {}
399
+
400
+ if (!args.yes) {
401
+ const most = CAP.list + CAP.site + n * (CAP.page + CAP.record);
402
+ console.log(
403
+ [
404
+ `commoncrawl: dry run, nothing downloaded. With --yes it would ask Common Crawl's index (index.commoncrawl.org) whether ${host} is in its newest crawl${n ? `, and look up ${n} known linking page${n === 1 ? "" : "s"}, reading each saved copy from data.commoncrawl.org` : ""}.`,
405
+ `That's at most ${2 + 2 * n} requests, one at a time, and at most ${(most / MB).toFixed(1)} MB, usually much less. The linking sites themselves aren't visited.`,
406
+ ...(pages.length > MAX
407
+ ? [`${pages.length - MAX} more linking pages would be left out: at most ${MAX} are looked up per run.`]
408
+ : []),
409
+ args.rank
410
+ ? saved
411
+ ? `The site's rank in Common Crawl's web graph was looked up on ${saved.checked} and would be reused, with no download.`
412
+ : `With --rank it would also read the site's rank from Common Crawl's web graph (data.commoncrawl.org): the ranks file is about 2.5 GB in all, read as it downloads and never stored, stopping once ${rankDomain(site.hostname).split(".").reverse().join(".")} is found or after ${capMb} MB. Well-linked sites are found early.`
413
+ : "The site's rank in Common Crawl's web graph isn't read without --rank: that streams a large file.",
414
+ "Re-run with --yes once the owner agrees.",
415
+ ].join("\n"),
416
+ );
417
+ return 0;
418
+ }
419
+ warnProxy();
420
+ const result = /** @type {{ commonCrawl: any, notes: string[] }} */ (await commonCrawl(site.href, pages));
421
+ if (args.rank) {
422
+ const rank = saved || (await domainRank(site.href, { capBytes: capMb * MB }));
423
+ if (rank.note) result.notes.push(rank.note);
424
+ result.commonCrawl = { ...(result.commonCrawl || {}), rank };
425
+ }
426
+ mkdirSync(dirname(out), { recursive: true });
427
+ writeFileSync(out, JSON.stringify(result, null, 2));
428
+ for (const note of result.notes) console.log("commoncrawl: " + note);
429
+ const cc = result.commonCrawl,
430
+ s = cc?.site,
431
+ rk = cc?.rank,
432
+ num = x => x.toLocaleString("en-US");
433
+ const rankLine =
434
+ !rk || rk.found === null
435
+ ? ""
436
+ : rk.found
437
+ ? ` · rank #${num(rk.harmonicPos)} of ${num(rk.domains)} domains (${rk.release})`
438
+ : ` · not in the top ${num(rk.scanned)} of ${num(rk.domains)} domains${rk.capped ? ` (read ${rk.readMB} MB)` : ""}`;
439
+ console.log(
440
+ `commoncrawl: ${cc?.crawl ? `${cc.crawl.name}: ${s ? `${s.capped ? "1,000 or more" : s.captures} saved page(s) of ${host}` : "the site wasn't looked up"}${n ? ` · ${cc.linkingSites.length} linking site(s) found linking to you in its copies` : ""}` : "the index wasn't looked up"}${rankLine} · wrote ${out}`,
441
+ );
442
+ return 0;
443
+ }
444
+
445
+ // The input files are read by backlinks.mjs; its errors are renamed to this script.
446
+ if (isMain(import.meta.url))
447
+ await runMain(() =>
448
+ main(process.argv.slice(2)).catch(e => {
449
+ if (e instanceof Fail) e.message = e.message.replace(/^backlinks: /, "commoncrawl: ");
450
+ throw e;
451
+ }),
452
+ );