seo-supervisor 0.0.0-stage → 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 (218) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +16 -0
  3. package/.claude-plugin/plugin.json +27 -0
  4. package/CHANGELOG.md +461 -0
  5. package/LICENSE +25 -0
  6. package/NOTICE +7 -0
  7. package/README.md +402 -2
  8. package/agents/seo-auditor.md +16 -0
  9. package/agents/seo-reviewer.md +16 -0
  10. package/bin/agents.mjs +230 -0
  11. package/bin/extras.mjs +422 -0
  12. package/bin/prompt.mjs +96 -0
  13. package/bin/seo-supervisor.mjs +477 -0
  14. package/commands/seo-audit.md +33 -0
  15. package/commands/seo-brief.md +28 -0
  16. package/commands/seo-connect.md +27 -0
  17. package/commands/seo-fix.md +34 -0
  18. package/commands/seo-grow.md +26 -0
  19. package/commands/seo-launch.md +21 -0
  20. package/commands/seo-review.md +19 -0
  21. package/commands/seo-rewrite.md +25 -0
  22. package/commands/seo-setup.md +35 -0
  23. package/commands/seo-watch.md +28 -0
  24. package/hooks/hooks.json +117 -0
  25. package/package.json +58 -4
  26. package/skills/seo-supervisor/NOTICE +7 -0
  27. package/skills/seo-supervisor/SKILL.md +480 -0
  28. package/skills/seo-supervisor/audience.md +61 -0
  29. package/skills/seo-supervisor/examples/drafts/security.md +41 -0
  30. package/skills/seo-supervisor/examples/hooks/README.md +28 -0
  31. package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
  32. package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
  33. package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
  34. package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
  35. package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
  36. package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
  37. package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
  38. package/skills/seo-supervisor/examples/sample-audit.json +532 -0
  39. package/skills/seo-supervisor/examples/sample-report.html +704 -0
  40. package/skills/seo-supervisor/examples/sample-report.md +360 -0
  41. package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
  42. package/skills/seo-supervisor/examples/security-tools-profile.md +73 -0
  43. package/skills/seo-supervisor/examples/snippets.md +781 -0
  44. package/skills/seo-supervisor/frameworks/nextjs.md +98 -0
  45. package/skills/seo-supervisor/frameworks/rails.md +34 -0
  46. package/skills/seo-supervisor/frameworks/spa.md +14 -0
  47. package/skills/seo-supervisor/grow.md +342 -0
  48. package/skills/seo-supervisor/og-images.md +85 -0
  49. package/skills/seo-supervisor/page-types.md +124 -0
  50. package/skills/seo-supervisor/planning.md +157 -0
  51. package/skills/seo-supervisor/profile-template.md +96 -0
  52. package/skills/seo-supervisor/report-format.md +313 -0
  53. package/skills/seo-supervisor/rewrite.md +59 -0
  54. package/skills/seo-supervisor/rules/ai-search.md +93 -0
  55. package/skills/seo-supervisor/rules/content.md +84 -0
  56. package/skills/seo-supervisor/rules/crawl-index.md +92 -0
  57. package/skills/seo-supervisor/rules/internal-linking.md +104 -0
  58. package/skills/seo-supervisor/rules/launch-monitoring.md +57 -0
  59. package/skills/seo-supervisor/rules/media.md +42 -0
  60. package/skills/seo-supervisor/rules/metadata.md +71 -0
  61. package/skills/seo-supervisor/rules/performance.md +78 -0
  62. package/skills/seo-supervisor/rules/rendering.md +79 -0
  63. package/skills/seo-supervisor/rules/search-intent.md +32 -0
  64. package/skills/seo-supervisor/rules/sitemaps-robots.md +49 -0
  65. package/skills/seo-supervisor/rules/structured-data.md +98 -0
  66. package/skills/seo-supervisor/rules/trust-security.md +48 -0
  67. package/skills/seo-supervisor/rules/urls.md +54 -0
  68. package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
  69. package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
  70. package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
  71. package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
  72. package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
  73. package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
  74. package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
  75. package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
  76. package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
  77. package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
  78. package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
  79. package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
  80. package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
  81. package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
  82. package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
  83. package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
  84. package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
  85. package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
  86. package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
  87. package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
  88. package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
  89. package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
  90. package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
  91. package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
  92. package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
  93. package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
  94. package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
  95. package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
  96. package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
  97. package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
  98. package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
  99. package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
  100. package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
  101. package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
  102. package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
  103. package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
  104. package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
  105. package/skills/seo-supervisor/scripts/content-scan.mjs +530 -0
  106. package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
  107. package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
  108. package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
  109. package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
  110. package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
  111. package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
  112. package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
  113. package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
  114. package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
  115. package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
  116. package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
  117. package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
  118. package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
  119. package/skills/seo-supervisor/scripts/fonts/OFL-BricolageGrotesque.txt +93 -0
  120. package/skills/seo-supervisor/scripts/fonts/OFL-Geist.txt +93 -0
  121. package/skills/seo-supervisor/scripts/fonts/OFL-GeistMono.txt +93 -0
  122. package/skills/seo-supervisor/scripts/fonts/bricolage-grotesque.woff2 +0 -0
  123. package/skills/seo-supervisor/scripts/fonts/geist-mono.woff2 +0 -0
  124. package/skills/seo-supervisor/scripts/fonts/geist.woff2 +0 -0
  125. package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
  126. package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
  127. package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
  128. package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
  129. package/skills/seo-supervisor/scripts/google.mjs +1341 -0
  130. package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
  131. package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
  132. package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
  133. package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
  134. package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
  135. package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
  136. package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
  137. package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
  138. package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
  139. package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
  140. package/skills/seo-supervisor/scripts/guard.mjs +74 -0
  141. package/skills/seo-supervisor/scripts/images.mjs +408 -0
  142. package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
  143. package/skills/seo-supervisor/scripts/issues.mjs +217 -0
  144. package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
  145. package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
  146. package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
  147. package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
  148. package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
  149. package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
  150. package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
  151. package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
  152. package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
  153. package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
  154. package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
  155. package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
  156. package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
  157. package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
  158. package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
  159. package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
  160. package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
  161. package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
  162. package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
  163. package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
  164. package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
  165. package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
  166. package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
  167. package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
  168. package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
  169. package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
  170. package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
  171. package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
  172. package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
  173. package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
  174. package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
  175. package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
  176. package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
  177. package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
  178. package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
  179. package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
  180. package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
  181. package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
  182. package/skills/seo-supervisor/scripts/osm.mjs +359 -0
  183. package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
  184. package/skills/seo-supervisor/scripts/render-report.mjs +340 -0
  185. package/skills/seo-supervisor/scripts/report/client.js +37 -0
  186. package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
  187. package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
  188. package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
  189. package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
  190. package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
  191. package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
  192. package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
  193. package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
  194. package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
  195. package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
  196. package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
  197. package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
  198. package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
  199. package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
  200. package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
  201. package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
  202. package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
  203. package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
  204. package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
  205. package/skills/seo-supervisor/scripts/report/styles.css +223 -0
  206. package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
  207. package/skills/seo-supervisor/scripts/report-plan.mjs +241 -0
  208. package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
  209. package/skills/seo-supervisor/scripts/seo-crawl.mjs +1151 -0
  210. package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
  211. package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
  212. package/skills/seo-supervisor/site-types/content.md +55 -0
  213. package/skills/seo-supervisor/site-types/ecommerce.md +64 -0
  214. package/skills/seo-supervisor/site-types/local-business.md +118 -0
  215. package/skills/seo-supervisor/site-types/services.md +68 -0
  216. package/skills/seo-supervisor/site-types/tools.md +127 -0
  217. package/skills/seo-supervisor/strategy.md +232 -0
  218. package/skills/seo-supervisor/troubleshooting.md +56 -0
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ // Registration and expiry dates and the registrar of the site's and competitors' domains, from RDAP, the keyless
4
+ // successor of WHOIS. Domain age is never a finding.
5
+ import { mkdirSync, writeFileSync } from "node:fs";
6
+ import { dirname, resolve } from "node:path";
7
+ import { isMain } from "./lib/is-main.mjs";
8
+ import { parseArgs } from "./lib/args.mjs";
9
+ import { Fail, runMain, warnProxy } from "./lib/cli.mjs";
10
+ import { domainOf } from "./connect-keys.mjs";
11
+
12
+ const BOOTSTRAP = "https://data.iana.org/rdap/dns.json";
13
+ const UA = "seo-supervisor-rdap";
14
+ const get = async url => {
15
+ const r = await fetch(url, {
16
+ headers: { accept: "application/rdap+json, application/json", "user-agent": UA },
17
+ signal: AbortSignal.timeout(30000),
18
+ });
19
+ const body = /** @type {any} */ (await r.json().catch(() => null));
20
+ return { status: r.status, body };
21
+ };
22
+ const reason = e => e.cause?.code || e.message;
23
+
24
+ // The longest match by whole labels from the right, preferring https. Base URLs take "domain/<name>" after a "/".
25
+ // https://www.rfc-editor.org/rfc/rfc9224
26
+ export function serverFor(services, labels) {
27
+ let best = null;
28
+ for (const [entries, urls] of services.filter(Array.isArray))
29
+ for (const e of entries || []) {
30
+ // a malformed entry is skipped
31
+ const parts = String(e).toLowerCase().split(".");
32
+ if (
33
+ parts.length <= labels.length &&
34
+ parts.join(".") === labels.slice(-parts.length).join(".") &&
35
+ (!best || parts.length > best.size)
36
+ )
37
+ best = { size: parts.length, urls: urls || [] };
38
+ }
39
+ const url = best && (best.urls.find(u => /^https:/i.test(u)) || best.urls[0]);
40
+ return url ? { size: best.size, base: url.endsWith("/") ? url : url + "/" } : null;
41
+ }
42
+ // Dates come from the registration and expiration events, the registrar from its entity's vCard fn.
43
+ // https://www.rfc-editor.org/rfc/rfc9083
44
+ const dayOf = (events, action) => {
45
+ const d = (events || []).find(e => e?.eventAction === action)?.eventDate;
46
+ return typeof d === "string" && /^\d{4}-\d\d-\d\d/.test(d) ? d.slice(0, 10) : null;
47
+ };
48
+ const registrarOf = entities => {
49
+ const card = (entities || []).find(e => (e?.roles || []).includes("registrar"))?.vcardArray?.[1];
50
+ const fn = Array.isArray(card) ? card.find(p => Array.isArray(p) && p[0] === "fn")?.[3] : null;
51
+ return typeof fn === "string" && fn.trim() ? fn.trim() : null;
52
+ };
53
+
54
+ // domains are bare names like example.com.
55
+ export async function lookupDomains({ domains, bootstrap = BOOTSTRAP }) {
56
+ const notes = [],
57
+ domainAge = [];
58
+ let services;
59
+ try {
60
+ const { status, body } = await get(bootstrap);
61
+ services = Array.isArray(body?.services) ? body.services : null;
62
+ if (!services)
63
+ return {
64
+ domainAge,
65
+ notes: [
66
+ `IANA's RDAP list (${bootstrap}) didn't answer as expected (HTTP ${status}), so no domain dates were read. Try again later.`,
67
+ ],
68
+ };
69
+ } catch (e) {
70
+ return {
71
+ domainAge,
72
+ notes: [
73
+ `Couldn't reach IANA's RDAP list (${reason(e)}), so no domain dates were read. Check the internet connection and try again.`,
74
+ ],
75
+ };
76
+ }
77
+ for (const domain of domains) {
78
+ const labels = domain.toLowerCase().split("."),
79
+ server = serverFor(services, labels);
80
+ if (!server) {
81
+ notes.push(`${domain}: IANA lists no RDAP server for its ending, so its registration date wasn't read.`);
82
+ continue;
83
+ }
84
+ // A subdomain isn't registered on its own: try the name, then its parent, down to one label more than the
85
+ // registry's ending (shop.example.co.uk, then example.co.uk), never the ending itself.
86
+ let found = null,
87
+ last = null;
88
+ for (let i = 0; labels.length - i > server.size && !found; i++) {
89
+ const name = labels.slice(i).join(".");
90
+ try {
91
+ const { status, body } = await get(`${server.base}domain/${encodeURIComponent(name)}`);
92
+ if (status === 200 && body) found = { name, body };
93
+ else if (status !== 404) {
94
+ last = `the registry answered HTTP ${status}`;
95
+ break;
96
+ } else last = "the registry doesn't know it (404)";
97
+ } catch (e) {
98
+ last = `couldn't reach ${new URL(server.base).host} (${reason(e)})`;
99
+ break;
100
+ }
101
+ }
102
+ if (!found) {
103
+ notes.push(`${domain}: no registration data, ${last}.`);
104
+ continue;
105
+ }
106
+ const { body } = found;
107
+ domainAge.push({
108
+ domain: found.name,
109
+ registered: dayOf(body.events, "registration"),
110
+ expires: dayOf(body.events, "expiration"),
111
+ registrar: registrarOf(body.entities),
112
+ server: new URL(server.base).host,
113
+ });
114
+ }
115
+ return { domainAge, notes };
116
+ }
117
+
118
+ // --rivals is ai-answers.mjs's name for the same list.
119
+ const USAGE =
120
+ "usage: node rdap.mjs --site https://www.example.com [--competitors a.com,b.com] [--out seo-audit/rdap.json] [--yes]";
121
+ async function main(argv) {
122
+ const args = parseArgs(argv, {
123
+ flags: ["site", "competitors", "out"],
124
+ booleans: ["yes"],
125
+ aliases: { rivals: "competitors" },
126
+ positionals: 0,
127
+ usage: USAGE,
128
+ });
129
+ const str = k => (typeof args[k] === "string" ? args[k] : null);
130
+ let site = null;
131
+ try {
132
+ site = /^https?:$/.test(new URL(str("site")).protocol) && domainOf(str("site"));
133
+ } catch {}
134
+ if (!site)
135
+ throw new Fail(
136
+ `rdap: --site must be the site's address, like https://www.example.com (got ${args.site ?? "nothing"}).\n${USAGE}`,
137
+ );
138
+ const listed = (str("competitors") || "")
139
+ .split(",")
140
+ .map(s => s.trim())
141
+ .filter(Boolean);
142
+ const skipped = listed
143
+ .filter(c => !domainOf(c))
144
+ .map(c => `Skipped competitor "${c}": it's not a domain name like rival.com.`);
145
+ const domains = [site, ...listed.map(domainOf)].filter((d, i, all) => d && all.indexOf(d) === i);
146
+ const bootstrap = process.env.RDAP_BOOTSTRAP || BOOTSTRAP; // the tests point it at a local fake
147
+ if (!args.yes) {
148
+ console.log(
149
+ `rdap: dry run, nothing sent. With --yes it would read IANA's list of RDAP servers (${new URL(bootstrap).host}), then send ${domains.length} domain name(s) (${domains.join(", ")}) to each one's registry, to read when it was registered and with which registrar. No key is needed.${skipped.length ? "\n" + skipped.join("\n") : ""}\nThese go to outside services, so re-run with --yes once the owner agrees.`,
150
+ );
151
+ return 0;
152
+ }
153
+ warnProxy();
154
+ const r = await lookupDomains({ domains, bootstrap });
155
+ r.notes.push(...skipped);
156
+ const out = resolve(str("out") || "seo-audit/rdap.json");
157
+ mkdirSync(dirname(out), { recursive: true });
158
+ writeFileSync(out, JSON.stringify({ source: "rdap", when: new Date().toISOString(), ...r }, null, 2));
159
+ for (const n of r.notes) console.log("note: " + n);
160
+ console.log(`rdap: registration dates for ${r.domainAge.length} of ${domains.length} domain(s) · wrote ${out}`);
161
+ return 0;
162
+ }
163
+
164
+ if (isMain(import.meta.url)) await runMain(() => main(process.argv.slice(2)));
@@ -0,0 +1,340 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ // Renders an audit JSON (or raw seo-crawl / content-scan output) as one self-contained HTML page that makes no network
4
+ // requests, plus a Markdown copy with every finding in full. The JSON shape and score model are in ../report-format.md.
5
+
6
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
7
+ import { dirname, resolve, basename } from "node:path";
8
+ import { SEV, bandOf } from "./lib/score.mjs";
9
+ import { isMain } from "./lib/is-main.mjs";
10
+ import { Fail, runMain } from "./lib/cli.mjs";
11
+ import { parseArgs } from "./lib/args.mjs";
12
+ import { SEV_LABEL, esc, link, mdLink, noteMd } from "./report/format.mjs";
13
+ import { buildModel } from "./report/model.mjs";
14
+ import { loadSources } from "./report/sources.mjs";
15
+ import { overviewLines } from "./report/overview-lines.mjs";
16
+ import { searchTraffic } from "./report/traffic.mjs";
17
+ import { diffParts } from "./report/diff.mjs";
18
+ import { findingTabs } from "./report/findings.mjs";
19
+ import { sitePanels } from "./report/panels/site.mjs";
20
+ import { linkPanels } from "./report/panels/links.mjs";
21
+ import { aiPanels } from "./report/panels/ai.mjs";
22
+ import { contentPanels } from "./report/panels/content.mjs";
23
+ import { speedPanels } from "./report/panels/speed-media.mjs";
24
+ import { localPanels } from "./report/panels/local.mjs";
25
+ import { connectionPanels } from "./report/panels/connections.mjs";
26
+ import {
27
+ logsPanel,
28
+ brandTrendPanel,
29
+ topSearchesPanel,
30
+ keywordIdeasPanel,
31
+ keywordDataPanel,
32
+ indexVerdictPanel,
33
+ } from "./report/panels/data-search.mjs";
34
+ import { schemaInventoryPanel } from "./report/panels/data-site.mjs";
35
+ import { overviewHtml } from "./report/overview.mjs";
36
+ import { pageHtml } from "./report/page.mjs";
37
+ import { markdown } from "./report/markdown.mjs";
38
+ import { byTab, deeper } from "./report/panel.mjs";
39
+
40
+ /**
41
+ * Builds the report as text and writes nothing.
42
+ * @param {any} raw the parsed JSON
43
+ * @param {{ dir?: string, mdFile?: string | null }} [opts] dir: the audit's folder, whose settings.json applies;
44
+ * mdFile: the Markdown file's name for the page to mention, or null for no Markdown (md is then null too)
45
+ * @returns {{ html: string, md: string | null, receipt: string[] }} receipt: the lines printed before "Wrote:"
46
+ */
47
+ export function render(raw, { dir = process.cwd(), mdFile = null } = {}) {
48
+ const { raw: full, notShown } = loadSources(raw, dir),
49
+ m = { raw: full, mdFile, notShown, ...buildModel(full, dir) }; // adds the result files beside the audit
50
+ const plan = raw.plan && typeof raw.plan === "object" ? raw.plan : null;
51
+ // Each module builds its parts from the model; what one needs from another is passed in by name.
52
+ const {
53
+ speedText,
54
+ authorityText,
55
+ ahrefsCredit,
56
+ labSpeedText,
57
+ lcpText,
58
+ lighthouseText,
59
+ googleUpdatesText,
60
+ desktopSpeedText,
61
+ } = overviewLines(m);
62
+ const { linked, links, moreLinks, outLinks, linkIdeas, queryGaps, linkedOnce, linkStrength } = linkPanels(m);
63
+ const {
64
+ trafficFor,
65
+ trafficOf,
66
+ trafficHtml,
67
+ clarityOf,
68
+ clarityHtml,
69
+ searchLines,
70
+ positionsText,
71
+ analyticsSplitLines,
72
+ } = searchTraffic(m, { linked });
73
+ const {
74
+ diff,
75
+ diffHtml,
76
+ posts,
77
+ timeline,
78
+ googlePostsText,
79
+ burstMd,
80
+ diffSections,
81
+ diffText,
82
+ unknownLines,
83
+ linksDroppedMd,
84
+ } = diffParts(m, { googleUpdatesText });
85
+ const { findingsHtml, decisionsHtml, changesHtml, passedHtml, limitsHtml, recheckNote, decisionCount } = findingTabs(
86
+ m,
87
+ { trafficHtml, clarityHtml },
88
+ );
89
+ const {
90
+ viewsHtml,
91
+ viewsMd,
92
+ hstsPreload,
93
+ crawlCoverage,
94
+ browser,
95
+ pageScores,
96
+ checkSettings: checkSettingsPanel,
97
+ settingRows,
98
+ settingsSummary,
99
+ } = sitePanels(m);
100
+ const { agents, aiCrawlers, aiAnswers } = aiPanels(m);
101
+ const { writing, productData, descriptions, appsPdfs, audience } = contentPanels(m);
102
+ const { images, lighthouseDetail, speedDetails, a11y } = speedPanels(m);
103
+ const { local, geoGridHtml, geoGridMd } = localPanels(m);
104
+ const { connections, changeCheck, newSearches } = connectionPanels(m);
105
+
106
+ // The one-line summaries, each topic's as one panel of quiet lines at the top of its tab.
107
+ const lines = (title, list) => () => {
108
+ const l = list().filter(Boolean);
109
+ return l.length && { title, blocks: l.map(quiet => ({ quiet })) };
110
+ };
111
+ const searchGlance = lines("Search at a glance", () => [
112
+ ...searchLines(),
113
+ positionsText(),
114
+ ...analyticsSplitLines(),
115
+ googleUpdatesText() && { html: googleUpdatesText(true), md: googleUpdatesText() },
116
+ ]);
117
+ const speedGlance = lines("Speed at a glance", () => [
118
+ speedText(),
119
+ desktopSpeedText(),
120
+ labSpeedText(),
121
+ lcpText(),
122
+ lighthouseText(),
123
+ ]);
124
+ // Ahrefs' licence requires its credit beside a Domain Rating.
125
+ const credit = ahrefsCredit();
126
+ const authority = lines("Authority", () => [
127
+ authorityText() && {
128
+ html: `${esc(authorityText())}${credit ? ` · ${link(credit.url, esc(credit.text))}` : ""}`,
129
+ md: `${noteMd(authorityText())}${credit ? ` · ${mdLink(credit.url, noteMd(credit.text))}` : ""}`,
130
+ },
131
+ ]);
132
+ // Score views are labelled as estimates. Like every topic panel, they and the rank grid sit a heading level down in
133
+ // the Markdown.
134
+ const ESTIMATES = "Estimates, not part of the score";
135
+ /** @type {[() => string, () => string[]]} */
136
+ const views = [
137
+ () =>
138
+ viewsHtml().replace(
139
+ '<span class="sub">The audit read another way</span>',
140
+ `<span class="sub">${ESTIMATES}</span>`,
141
+ ),
142
+ () => {
143
+ const v = viewsMd();
144
+ return v.length ? ["### Score views", "", `${ESTIMATES}.`, "", ...v.slice(2)] : [];
145
+ },
146
+ ];
147
+ /** @type {[() => string, () => string[]]} */
148
+ const grid = [geoGridHtml, () => deeper(geoGridMd(), 1)];
149
+
150
+ // [tab, card, panel] rows. Panels that share a card render as one box. "since", "limits" and "findings" add to
151
+ // those existing tabs.
152
+ const [S, SP, L, SC] = ["search-ai", "speed", "links", "site-content"];
153
+ const SPEED = m.lighthouse.length ? "Speed and Lighthouse" : "Speed"; // the card names Lighthouse only when it ran
154
+ const tabs = byTab([
155
+ [S, "Search traffic", searchGlance],
156
+ [S, "Search traffic", () => topSearchesPanel(m)],
157
+ [S, "Search traffic", () => brandTrendPanel(m)],
158
+ [S, "Search traffic", () => indexVerdictPanel(m)],
159
+ [S, "Search traffic", newSearches],
160
+ [S, "Search traffic", connections],
161
+ [S, "Search traffic", posts],
162
+ [S, "Search ideas", () => keywordIdeasPanel(m)],
163
+ [S, "Search ideas", () => keywordDataPanel(m)],
164
+ [S, "Search ideas", queryGaps],
165
+ [S, "AI crawlers, agents and answers", aiCrawlers],
166
+ [S, "AI crawlers, agents and answers", agents],
167
+ [S, "AI crawlers, agents and answers", () => logsPanel(m)],
168
+ [S, "AI crawlers, agents and answers", aiAnswers],
169
+ [SP, SPEED, speedGlance],
170
+ [SP, SPEED, lighthouseDetail],
171
+ [SP, SPEED, speedDetails],
172
+ [SP, SPEED, images],
173
+ [L, "Internal links", linkStrength],
174
+ [L, "Internal links", linkedOnce],
175
+ [L, "Internal links", linkIdeas],
176
+ [L, "Links from other sites", authority],
177
+ [L, "Links from other sites", links],
178
+ [L, "Links from other sites", moreLinks],
179
+ [L, "Links to other sites", outLinks],
180
+ [SC, null, views],
181
+ [SC, "Structured data", () => schemaInventoryPanel(m)],
182
+ [SC, "Local business", local],
183
+ [SC, "Local business", grid],
184
+ [SC, "Content and writing", writing],
185
+ [SC, "Content and writing", descriptions],
186
+ [SC, "Content and writing", audience],
187
+ [SC, "Content and writing", productData],
188
+ [SC, "Content and writing", pageScores],
189
+ [SC, "Site hygiene", crawlCoverage],
190
+ [SC, "Site hygiene", browser],
191
+ [SC, "Site hygiene", hstsPreload],
192
+ [SC, "Site hygiene", appsPdfs],
193
+ [SC, "Site hygiene", a11y],
194
+ ["since", "Over time", timeline],
195
+ ["since", "Over time", changeCheck],
196
+ ["limits", "Check settings", checkSettingsPanel],
197
+ ["findings", "Checking a fix yourself", recheckNote],
198
+ ]);
199
+ // The topic tabs that have something to show, in this order.
200
+ const topics = /** @type {[string, string][]} */ ([
201
+ [S, "Search & AI"],
202
+ [SP, "Speed"],
203
+ [L, "Links"],
204
+ [SC, "Site & content"],
205
+ ]).filter(([id]) => tabs[id]);
206
+
207
+ const html = pageHtml(m, {
208
+ plan,
209
+ diff,
210
+ diffHtml,
211
+ trafficFor,
212
+ findingsHtml,
213
+ decisionsHtml,
214
+ decisionCount,
215
+ changesHtml,
216
+ passedHtml,
217
+ limitsHtml,
218
+ topics,
219
+ tabs,
220
+ overviewHtml: () => overviewHtml(m),
221
+ });
222
+ const md = mdFile
223
+ ? markdown(m, {
224
+ plan,
225
+ diff,
226
+ topics,
227
+ tabs,
228
+ burstMd,
229
+ googleUpdatesText,
230
+ googlePostsText,
231
+ diffSections,
232
+ diffText,
233
+ unknownLines,
234
+ linksDroppedMd,
235
+ trafficOf,
236
+ clarityOf,
237
+ })
238
+ : null;
239
+ const { overall, verdict, unlock, openBlockers, open, countSev, fixed, checkSettings } = m;
240
+ const receipt = [
241
+ overall ? `SEO health score: ${overall.value}/100 (${bandOf(overall.value)[1]}). ${verdict}.` : verdict,
242
+ unlock &&
243
+ `Fixing the ${openBlockers.length === 1 ? "blocker" : `${openBlockers.length} blockers`} raises it to ${unlock.value}/100 (${bandOf(unlock.value)[1]}).`,
244
+ `Open: ${open.length} (${SEV.map(s => `${countSev(s)} ${SEV_LABEL[s].toLowerCase()}`).join(", ")}) · fixed: ${fixed.length}${overall ? ` · rules passing: ${overall.passing} of ${overall.rules}` : ""}`,
245
+ settingRows().length &&
246
+ `Check settings (settings.json): ${settingsSummary()}. The score leaves turned-off checks out.`,
247
+ ...checkSettings.warnings.map(w => `Settings warning: ${w}`),
248
+ ].filter(Boolean);
249
+ return { html, md, receipt };
250
+ }
251
+
252
+ // Prints the page with its print styles: every tab in turn, findings open, light colours. The browser modules load
253
+ // only for --pdf.
254
+ async function printPdf(htmlPath, pdf) {
255
+ const [{ findBrowser }, { launchChrome }, { installedBrowser }, { pathToFileURL }] = await Promise.all([
256
+ import("./checks/render.mjs"),
257
+ import("./lib/cdp.mjs"),
258
+ import("./lib/settings-dir.mjs"),
259
+ import("node:url"),
260
+ ]);
261
+ const browser = findBrowser() || installedBrowser();
262
+ if (!browser)
263
+ throw new Error(
264
+ "no Chrome or Edge found, so no PDF was made (the HTML report is ready). Install Chrome or Edge, or set CHROME_PATH to it; in a container or CI, the owner can add one with npx seo-supervisor --with-browser (it downloads Chrome).",
265
+ );
266
+ const chrome = await launchChrome(browser, { timeoutMs: 60000 });
267
+ try {
268
+ const page = await chrome.newPage();
269
+ await page.send("Page.enable");
270
+ const loaded = new Promise((ok, no) => {
271
+ page.on("Page.loadEventFired", ok);
272
+ setTimeout(
273
+ no,
274
+ 60000,
275
+ new Error("the report didn't finish loading in Chrome within 60 s, so no PDF was made."),
276
+ ).unref();
277
+ });
278
+ await page.send("Page.navigate", { url: pathToFileURL(htmlPath).href });
279
+ await loaded;
280
+ await page.send("Runtime.evaluate", { expression: "document.fonts.ready.then(() => true)", awaitPromise: true });
281
+ // Every collapsed panel opens, as a browser's own print does (beforeprint), so the PDF holds them all.
282
+ await page.send("Runtime.evaluate", {
283
+ expression: "document.querySelectorAll('details').forEach(d => { d.open = true; })",
284
+ });
285
+ const { data } = await page.send("Page.printToPDF", {
286
+ printBackground: true,
287
+ paperWidth: 8.27,
288
+ paperHeight: 11.69,
289
+ }); // A4, in inches
290
+ writeFileSync(pdf, Buffer.from(data, "base64"));
291
+ } finally {
292
+ await chrome.close();
293
+ }
294
+ }
295
+
296
+ // Exits 0 when written, 1 when only the PDF failed, 2 on a usage error or an input that's missing or isn't JSON.
297
+ const USAGE =
298
+ "Usage: node render-report.mjs <audit.json|seo-crawl.json|content-scan.json> [--out report.html] [--md report.md] [--no-md] [--pdf]";
299
+ async function main(argv) {
300
+ // The input file is the one word that isn't an option, wherever it sits (--out x.html audit.json works too).
301
+ const args = parseArgs(argv, { flags: ["out", "md"], booleans: ["no-md", "pdf"], positionals: 1, usage: USAGE }),
302
+ inPath = args._[0];
303
+ if (!inPath || args.out === true || args.md === true) throw new Fail(USAGE);
304
+ const outPath = resolve(args.out || inPath.replace(/\.json$/i, "") + ".html");
305
+ const mdPath = args["no-md"] ? null : resolve(args.md || outPath.replace(/\.html?$/i, "") + ".md");
306
+ const text = readFileSync(inPath, "utf8");
307
+ let raw;
308
+ try {
309
+ raw = JSON.parse(text);
310
+ } catch (e) {
311
+ throw new Fail(`render-report: ${inPath} isn't valid JSON (${e.message}).`);
312
+ }
313
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
314
+ throw new Fail(`render-report: ${inPath} isn't an audit: it should hold one JSON object (report-format.md).`);
315
+ const { html, md, receipt } = render(raw, {
316
+ dir: dirname(resolve(inPath)),
317
+ mdFile: mdPath ? basename(mdPath) : null,
318
+ });
319
+ mkdirSync(dirname(outPath), { recursive: true });
320
+ writeFileSync(outPath, html);
321
+ if (mdPath) writeFileSync(mdPath, md);
322
+ const pdfPath = args.pdf ? outPath.replace(/\.html?$/i, "") + ".pdf" : null;
323
+ const pdfError = pdfPath
324
+ ? await printPdf(outPath, pdfPath).then(
325
+ () => null,
326
+ e => e.message,
327
+ )
328
+ : null;
329
+ console.log(
330
+ [...receipt, `Wrote: ${[outPath, mdPath, pdfPath && !pdfError && pdfPath].filter(Boolean).join(", ")}`]
331
+ .filter(Boolean)
332
+ .join("\n"),
333
+ );
334
+ if (pdfError) {
335
+ console.error(`render-report: ${pdfError}`);
336
+ return 1;
337
+ }
338
+ }
339
+
340
+ if (isMain(import.meta.url)) await runMain(() => main(process.argv.slice(2)));
@@ -0,0 +1,37 @@
1
+ (function(){
2
+ var DEFAULT_TAB='__DEFAULT_TAB__';
3
+ var d=document;d.documentElement.classList.add('js');
4
+ var root=d.documentElement,tb=d.querySelector('.theme-btn');
5
+ if(tb){var syncTheme=function(){var light=root.dataset.theme==='light';tb.querySelector('.tl').textContent=light?'Dark':'Light';tb.setAttribute('aria-label','Switch to '+(light?'dark':'light')+' theme');};
6
+ tb.hidden=false;syncTheme();
7
+ tb.addEventListener('click',function(){var light=root.dataset.theme!=='light';if(light)root.dataset.theme='light';else delete root.dataset.theme;try{localStorage.setItem('seo-report-theme',light?'light':'dark')}catch(e){}syncTheme();});}
8
+ var tabs=[].slice.call(d.querySelectorAll('.tab')),panels=[].slice.call(d.querySelectorAll('.tp'));
9
+ function show(name,focusTab){var ok=false;tabs.forEach(function(t){var on=t.dataset.tab===name;t.setAttribute('aria-selected',on);t.tabIndex=on?0:-1;if(on){ok=true;if(focusTab)t.focus();}});
10
+ if(!ok)return false;panels.forEach(function(p){p.hidden=p.id!=='p-'+name;});return true;}
11
+ tabs.forEach(function(t,i){t.addEventListener('click',function(){history.replaceState(null,'','#'+t.dataset.tab);show(t.dataset.tab);});
12
+ t.addEventListener('keydown',function(e){var k=e.key,j=i;if(k==='ArrowRight')j=(i+1)%tabs.length;else if(k==='ArrowLeft')j=(i-1+tabs.length)%tabs.length;else if(k==='Home')j=0;else if(k==='End')j=tabs.length-1;else return;
13
+ e.preventDefault();history.replaceState(null,'','#'+tabs[j].dataset.tab);show(tabs[j].dataset.tab,true);});});
14
+ var list=d.getElementById('flist');
15
+ function setOpen(f,open){f.classList.toggle('open',open);f.querySelector('.f-head').setAttribute('aria-expanded',open);
16
+ if(list)list.classList.toggle('focus',!!list.querySelector('.f.open'));}
17
+ [].forEach.call(d.querySelectorAll('.f-head'),function(b){b.addEventListener('click',function(){var f=b.closest('.f');setOpen(f,!f.classList.contains('open'));});});
18
+ var state={sev:'all',status:'all',area:'all',q:''};
19
+ function apply(){if(!list)return;var n=0,all=list.children.length;[].forEach.call(list.children,function(f){
20
+ var ok=(state.sev==='all'||f.dataset.sev===state.sev)&&(state.status==='all'||f.dataset.status===state.status)&&(state.area==='all'||f.dataset.area===state.area)&&(!state.q||f.dataset.text.indexOf(state.q)>-1);
21
+ f.hidden=!ok;if(ok)n++;});
22
+ d.getElementById('showing').textContent=(n===all?all:n+' of '+all)+' findings';d.getElementById('fnone').hidden=n>0;}
23
+ [].forEach.call(d.querySelectorAll('.segb[data-sev]'),function(b){b.addEventListener('click',function(){[].forEach.call(d.querySelectorAll('.segb[data-sev]'),function(x){x.setAttribute('aria-pressed',x===b);});state.sev=b.dataset.sev;apply();});});
24
+ var pb=[].slice.call(d.querySelectorAll('.segb[data-pstatus]'));pb.forEach(function(b){b.addEventListener('click',function(){pb.forEach(function(x){x.setAttribute('aria-pressed',x===b);});var st=b.dataset.pstatus;[].forEach.call(d.querySelectorAll('.prow'),function(r){r.hidden=st!=='all'&&r.dataset.status!==st;});});});
25
+ var q=d.getElementById('q');if(q)q.addEventListener('input',function(){state.q=q.value.trim().toLowerCase();apply();});
26
+ var fs=d.getElementById('fstatus');if(fs)fs.addEventListener('change',function(){state.status=fs.value;apply();});
27
+ var fa=d.getElementById('farea');if(fa)fa.addEventListener('change',function(){state.area=fa.value;apply();});
28
+ var fr=d.getElementById('freset');if(fr)fr.addEventListener('click',function(){state={sev:'all',status:'all',area:'all',q:''};if(q)q.value='';if(fs)fs.value='all';if(fa)fa.value='all';
29
+ [].forEach.call(d.querySelectorAll('.segb[data-sev]'),function(x){x.setAttribute('aria-pressed',x.dataset.sev==='all');});apply();});
30
+ [].forEach.call(d.querySelectorAll('.area[data-sev]'),function(a){a.addEventListener('click',function(e){e.preventDefault();var b=d.querySelector('.segb[data-sev="'+a.dataset.sev+'"]');if(b)b.click();history.replaceState(null,'','#findings');show('findings');window.scrollTo(0,0);});});
31
+ [].forEach.call(d.querySelectorAll('.area[data-area]'),function(a){a.addEventListener('click',function(e){e.preventDefault();if(fa){fa.value=a.dataset.area;state.area=a.dataset.area;apply();}
32
+ history.replaceState(null,'','#findings');show('findings');window.scrollTo(0,0);});});
33
+ function route(e){var h=decodeURIComponent(location.hash.slice(1));if(!h){show(DEFAULT_TAB);return;}
34
+ if(show(h)||(h.slice(0,2)==='p-'&&show(h.slice(2))))return;var f=d.getElementById(h);if(f&&f.classList.contains('f')){show('findings');f.hidden=false;setOpen(f,true);f.scrollIntoView({block:'start'});if(e)f.querySelector('.f-head').focus({preventScroll:true});}else show(DEFAULT_TAB);}
35
+ window.addEventListener('beforeprint',function(){[].forEach.call(d.querySelectorAll('details'),function(r){r.open=true;});});
36
+ window.addEventListener('hashchange',route);route();
37
+ })();