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,190 @@
1
+ // @ts-check
2
+ // The crawl queue. seo-crawl.mjs runs it twice: the start page first, then the sitemap's URLs and every link found.
3
+ import { FILE_EXT, tagsOf } from "../lib/html.mjs";
4
+ import { quote } from "../lib/findings.mjs";
5
+ import { PAGE_MAX, clean, urlOr } from "./fetch.mjs";
6
+ import { agentRule, analyze, productImages } from "./page.mjs";
7
+ import { challengeHeaders } from "../checks/bots.mjs";
8
+
9
+ /** Runs fn over items, at most conc at once, so the checks' own requests keep to --concurrency. Results come back in
10
+ * item order, so findings don't depend on which answer came first.
11
+ * @template T, R
12
+ * @param {T[]} items
13
+ * @param {number} conc
14
+ * @param {(item: T) => Promise<R>} fn
15
+ * @returns {Promise<R[]>} */
16
+ export async function pool(items, conc, fn) {
17
+ const out = new Array(items.length);
18
+ let next = 0;
19
+ // A missing or zero conc means one worker, never none, which would leave every answer empty.
20
+ await Promise.all(
21
+ Array.from({ length: Math.min(Math.max(1, conc || 1), items.length) }, async () => {
22
+ while (next < items.length) {
23
+ const i = next++;
24
+ out[i] = await fn(items[i]);
25
+ }
26
+ }),
27
+ );
28
+ return out;
29
+ }
30
+
31
+ /**
32
+ * @param {{ start: URL, startOrigin: string, max: number, conc: number, includeQuery: boolean, inSection: (path: string) => boolean,
33
+ * fetcher: { follow: Function, xRobotsLines: Function }, page: any, toCrawl: (u: string) => string, notes: string[] }} o
34
+ */
35
+ export function createCrawler({
36
+ start: START,
37
+ startOrigin: START_ORIGIN,
38
+ max: MAX,
39
+ conc: CONC,
40
+ includeQuery: INCLUDE_QUERY,
41
+ inSection,
42
+ fetcher: { follow, xRobotsLines },
43
+ page,
44
+ toCrawl,
45
+ notes,
46
+ }) {
47
+ const pages = new Map(); // requested crawl URL -> record
48
+ const queue = [];
49
+ const seen = new Set(),
50
+ challenges = []; // challenges: the URLs a bot challenge answered
51
+ let fetched = 0,
52
+ capped = false;
53
+ function enqueue(u, from) {
54
+ const c = clean(u, from);
55
+ if (!c) return;
56
+ const x = new URL(c);
57
+ if (x.origin !== START_ORIGIN) return;
58
+ if (FILE_EXT.test(x.pathname)) return;
59
+ // Cloudflare serves its own endpoints under /cdn-cgi/ on every site it fronts; they aren't the site's pages.
60
+ // https://developers.cloudflare.com/fundamentals/reference/cdn-cgi-endpoint/
61
+ if (x.pathname.startsWith("/cdn-cgi/")) return;
62
+ if (x.search && !INCLUDE_QUERY) return;
63
+ if (!inSection(x.pathname) && c !== clean(START.href)) return; // the start page is always the way in
64
+ if (seen.has(c)) return;
65
+ seen.add(c);
66
+ queue.push(c);
67
+ }
68
+ // Own-origin stylesheets, for checks/assets.mjs.
69
+ const ownStylesheets = (html, base) => [
70
+ ...new Set(
71
+ tagsOf(html.replace(/<!--[\s\S]*?-->/g, " "), "link")
72
+ .filter(
73
+ l => l.href && /(^|\s)stylesheet(\s|$)/i.test(l.rel || "") && !/(^|\s)alternate(\s|$)/i.test(l.rel || ""),
74
+ )
75
+ .map(l => {
76
+ const x = urlOr(l.href.trim(), base);
77
+ return x && /^https?:$/.test(x.protocol) ? clean(toCrawl(x.href)) : null;
78
+ })
79
+ .filter(c => c && new URL(c).origin === START_ORIGIN),
80
+ ),
81
+ ];
82
+ async function crawlOne(u) {
83
+ const r = await follow(u);
84
+ // A bot challenge isn't the page, so it stays out of the records and is never reported as broken; seo-crawl.mjs
85
+ // notes it as not checked.
86
+ if (challengeHeaders(r)) {
87
+ challenges.push(r.finalUrl);
88
+ return;
89
+ }
90
+ const rec = {
91
+ url: u,
92
+ status: r.status,
93
+ finalUrl: r.finalUrl,
94
+ chain: r.chain,
95
+ error: r.error || null,
96
+ headers: r.headers,
97
+ ms: r.ms,
98
+ };
99
+ pages.set(u, rec);
100
+ if (r.status === 200 && /html/.test(r.ct) && r.body) {
101
+ // Only a crawler prefix makes the joined header ambiguous, so the lines are read apart only then.
102
+ const xrt = r.headers.get("x-robots-tag");
103
+ // A check that throws skips this page's checks with a note. The page answered 200, so it's never reported as a
104
+ // server error or a broken link.
105
+ let a;
106
+ try {
107
+ a = analyze(
108
+ r.finalUrl,
109
+ r.body,
110
+ r.headers,
111
+ xrt && xrt.toLowerCase().split(",").some(agentRule) ? await xRobotsLines(r.finalUrl) : null,
112
+ page,
113
+ );
114
+ } catch (e) {
115
+ notes.push(
116
+ `A check couldn't read ${quote(r.finalUrl)} (${quote(String(e.message).split("\n")[0])}), so that page's checks were skipped.`,
117
+ );
118
+ return;
119
+ }
120
+ Object.assign(rec, a, {
121
+ html: true,
122
+ productImages: productImages(r.body),
123
+ stylesheets: ownStylesheets(r.body, a.base),
124
+ });
125
+ rec.links = [];
126
+ // On a local crawl with --site-origin, an absolute link to the public origin means the crawled page.
127
+ rec.mainLinks = new Set(
128
+ a.mainHrefs
129
+ .map(h => clean(h, a.base))
130
+ .filter(Boolean)
131
+ .map(toCrawl),
132
+ );
133
+ for (const l of a.anchors) {
134
+ if (!l.href || /^(mailto|tel|javascript|sms):/i.test(l.href)) continue;
135
+ const raw = clean(l.href, a.base),
136
+ c = raw && toCrawl(raw);
137
+ if (!c) continue;
138
+ if (new URL(c).origin !== START_ORIGIN) continue;
139
+ rec.links.push({ url: c, text: l.text });
140
+ enqueue(c, r.finalUrl);
141
+ }
142
+ for (const b of a.crumbs) enqueue(toCrawl(b), r.finalUrl);
143
+ for (const c of a.canonicals.slice(0, 1)) {
144
+ const x = c && urlOr(c, a.base);
145
+ if (x) enqueue(toCrawl(x.href), r.finalUrl);
146
+ }
147
+ } else if (r.over) {
148
+ // seo-crawl.mjs still flags it as over Googlebot's 2 MB
149
+ rec.over = true;
150
+ notes.push(
151
+ `${quote(r.finalUrl)} is over ${PAGE_MAX / 1048576} MB (once unpacked), our own limit for one page, so it wasn't read or checked.`,
152
+ );
153
+ }
154
+ }
155
+ async function runQueue() {
156
+ await new Promise(done => {
157
+ let active = 0;
158
+ const pump = () => {
159
+ while (active < CONC && queue.length && fetched < MAX) {
160
+ const u = queue.shift();
161
+ active++;
162
+ fetched++;
163
+ crawlOne(u)
164
+ .catch(e => pages.set(u, { url: u, status: 0, error: String(e) }))
165
+ .finally(() => {
166
+ active--;
167
+ pump();
168
+ });
169
+ }
170
+ if (fetched >= MAX && queue.length) capped = true;
171
+ if (active === 0 && (!queue.length || fetched >= MAX)) done();
172
+ };
173
+ pump();
174
+ });
175
+ }
176
+ return {
177
+ pages,
178
+ queue,
179
+ seen,
180
+ challenges,
181
+ enqueue,
182
+ run: runQueue,
183
+ get fetched() {
184
+ return fetched;
185
+ },
186
+ get capped() {
187
+ return capped;
188
+ },
189
+ };
190
+ }
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ // Several sites at a glance from local audits. Scores come from lib/score.mjs, so they match each seo-audit.html.
4
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { basename, dirname, join, relative, resolve } from "node:path";
6
+ import { bandOf, scoreSummary, OWN_SCORE } from "./lib/score.mjs";
7
+ import { isMain } from "./lib/is-main.mjs";
8
+ import { parseArgs } from "./lib/args.mjs";
9
+ import { Fail, runMain } from "./lib/cli.mjs";
10
+ import { esc, fmtDate, plural } from "./report/format.mjs";
11
+
12
+ // fmtDate keeps a YYYY-MM-DD date on that day in every time zone; a missing or bad date shows nothing.
13
+ const dayOf = d => (d && !isNaN(new Date(d).getTime()) ? fmtDate(d) : "");
14
+
15
+ export function summaryOf(dir) {
16
+ const file = [join(dir, "seo-audit.json"), join(dir, "seo-audit", "seo-audit.json")].find(f => existsSync(f));
17
+ if (!file) return { dir, problem: "no seo-audit.json" };
18
+ let raw;
19
+ try {
20
+ raw = JSON.parse(readFileSync(file, "utf8"));
21
+ } catch {
22
+ return { dir, problem: `${file} can't be read as JSON` };
23
+ }
24
+ const { open, overall, unlock, countSev } = scoreSummary(raw, dirname(file));
25
+ return {
26
+ dir,
27
+ report: file.replace(/\.json$/i, ".html"),
28
+ name: String(raw.site?.name || basename(dirname(resolve(file)))),
29
+ url: typeof raw.site?.url === "string" ? raw.site.url : "",
30
+ date: dayOf(raw.run?.date),
31
+ score: overall,
32
+ open: open.length,
33
+ blockers: countSev("blocker"),
34
+ high: countSev("high"),
35
+ unlock,
36
+ regressions: Array.isArray(raw.diff?.regressions) ? raw.diff.regressions.length : null,
37
+ };
38
+ }
39
+
40
+ const scoreText = x => (x.score ? `${x.score.value}/100 (${bandOf(x.score.value)[1]})` : "not scored");
41
+ const issuesText = x =>
42
+ [x.blockers && plural(x.blockers, "blocker"), x.high && `${x.high} high`, `${x.open} open`]
43
+ .filter(Boolean)
44
+ .join(", ");
45
+ export const lineOf = x =>
46
+ x.problem
47
+ ? `${x.dir}: ${x.problem}`
48
+ : [
49
+ x.name,
50
+ scoreText(x),
51
+ issuesText(x),
52
+ x.unlock && `${x.unlock.value} once the blockers are fixed`,
53
+ x.regressions && plural(x.regressions, "regression") + " since the last audit",
54
+ x.date && `audited ${x.date}`,
55
+ ]
56
+ .filter(Boolean)
57
+ .join(" · ");
58
+ // Lowest score first, unscored after, folders with no audit last.
59
+ export const order = list =>
60
+ [...list].sort(
61
+ (a, b) =>
62
+ +!!a.problem - +!!b.problem ||
63
+ (a.score?.value ?? 101) - (b.score?.value ?? 101) ||
64
+ String(a.name).localeCompare(String(b.name)),
65
+ );
66
+
67
+ export function dashboardHtml(list, out) {
68
+ const link = x => {
69
+ const r = relative(dirname(out), x.report).split(/[\\/]/).map(encodeURIComponent).join("/");
70
+ return existsSync(x.report) ? `<a href="${esc(r)}">Open report</a>` : `<span class="mute">Not rendered yet</span>`;
71
+ };
72
+ const rows = list
73
+ .map(x =>
74
+ x.problem
75
+ ? `<tr><td colspan="5"><code>${esc(x.dir)}</code></td><td class="mute">${esc(x.problem)}</td></tr>`
76
+ : `<tr><td><b>${esc(x.name)}</b>${x.url ? `<br><span class="mute">${esc(x.url.replace(/^https?:\/\//, ""))}</span>` : ""}</td><td>${x.score ? `<span class="n ${bandOf(x.score.value)[2]}">${x.score.value}</span> ${esc(bandOf(x.score.value)[1])}${x.unlock ? `<br><span class="mute">${x.unlock.value} once the blockers are fixed</span>` : ""}` : "Not scored"}</td><td>${esc(issuesText(x))}</td><td>${x.regressions == null ? `<span class="mute">First audit</span>` : x.regressions ? esc(plural(x.regressions, "regression")) : "None"}</td><td>${esc(x.date)}</td><td>${link(x)}</td></tr>`,
77
+ )
78
+ .join("\n");
79
+ return `<!doctype html>
80
+ <html lang="en">
81
+ <head>
82
+ <meta charset="utf-8">
83
+ <meta name="viewport" content="width=device-width, initial-scale=1">
84
+ <meta name="robots" content="noindex, nofollow">
85
+ <meta name="color-scheme" content="light dark">
86
+ <title>SEO dashboard</title>
87
+ <style>
88
+ :root{--bg:#f4f6f9;--panel:#fff;--ink:#1c2a39;--mute:#5d6878;--line:#e2e6ec;--b1:#c03030;--b2:#b5541a;--b3:#8a6400;--b4:#3f7f2e;--b5:#1d7444}
89
+ @media (prefers-color-scheme:dark){:root{--bg:#0e131a;--panel:#151c26;--ink:#e6ebf2;--mute:#98a3b3;--line:#232c39;--b1:#ef6464;--b2:#f38b4a;--b3:#efb93b;--b4:#86c873;--b5:#45b97a}}
90
+ body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;font-variant-numeric:tabular-nums}
91
+ main{max-width:1100px;margin:0 auto;padding:28px 16px 48px}
92
+ h1{font-size:26px;margin:0 0 4px}
93
+ .mute{color:var(--mute);font-size:13.5px}
94
+ .wrap{overflow-x:auto;margin-top:20px;background:var(--panel);border:1px solid var(--line);border-radius:10px}
95
+ table{border-collapse:collapse;width:100%;min-width:640px}
96
+ th,td{text-align:left;vertical-align:top;padding:10px 14px;border-top:1px solid var(--line)}
97
+ thead th{border-top:0;font-size:12.5px;color:var(--mute);font-weight:600}
98
+ .n{font:700 22px/1 ui-monospace,Menlo,Consolas,monospace}.b1{color:var(--b1)}.b2{color:var(--b2)}.b3{color:var(--b3)}.b4{color:var(--b4)}.b5{color:var(--b5)}
99
+ a{color:inherit}
100
+ code{font:13px ui-monospace,Menlo,Consolas,monospace;overflow-wrap:anywhere}
101
+ </style>
102
+ </head>
103
+ <body>
104
+ <main>
105
+ <h1>SEO dashboard</h1>
106
+ <p class="mute">${esc(plural(list.filter(x => !x.problem).length, "site"))}, lowest score first · made ${esc(fmtDate(Date.now()))} from the audits on this computer. The health score is ${OWN_SCORE}.</p>
107
+ <div class="wrap"><table>
108
+ <thead><tr><th scope="col">Site</th><th scope="col">SEO health score</th><th scope="col">Open issues</th><th scope="col">Since last audit</th><th scope="col">Audited</th><th scope="col">Report</th></tr></thead>
109
+ <tbody>
110
+ ${rows}
111
+ </tbody>
112
+ </table></div>
113
+ </main>
114
+ </body>
115
+ </html>
116
+ `;
117
+ }
118
+
119
+ const USAGE = `Usage: node dashboard.mjs [folder ...] [--out dashboard.html]
120
+ npx seo-supervisor dashboard [folder ...] [--out dashboard.html]
121
+
122
+ The state of several sites at a glance, from the audits already on this computer. Sends nothing.
123
+ folder ... a seo-audit/ folder, or a project folder with one inside (default: ./seo-audit)
124
+ --out <file> also write one offline HTML page that links to each site's report
125
+ --help, -h show this help`;
126
+
127
+ if (isMain(import.meta.url))
128
+ await runMain(() => {
129
+ const args = parseArgs(process.argv.slice(2), { flags: ["out"], usage: USAGE }),
130
+ dirs = args._;
131
+ if (args.out === true) throw new Fail(USAGE); // --out with no file after it
132
+ const list = order((dirs.length ? dirs : ["seo-audit"]).map(summaryOf));
133
+ for (const x of list) console.log(lineOf(x));
134
+ if (args.out) {
135
+ const out = resolve(args.out);
136
+ mkdirSync(dirname(out), { recursive: true });
137
+ writeFileSync(out, dashboardHtml(list, out));
138
+ console.log(`Wrote ${out}`);
139
+ }
140
+ });
@@ -0,0 +1,38 @@
1
+ [
2
+ { "name": "OAI-SearchBot", "vendor": "OpenAI", "kind": "search", "group": "ai-search", "purpose": "Crawls so sites can be shown and linked in ChatGPT search", "ips": ["https://openai.com/searchbot.json"], "probeUa": "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; OAI-SearchBot/1.4; +https://openai.com/searchbot" },
3
+ { "name": "Claude-SearchBot", "vendor": "Anthropic", "kind": "search", "group": "ai-search", "purpose": "Crawls to improve the search results Claude cites", "ips": ["https://claude.com/crawling/bots.json"], "probeUa": "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Claude-SearchBot/1.0)" },
4
+ { "name": "PerplexityBot", "vendor": "Perplexity", "kind": "search", "group": "ai-search", "purpose": "Crawls so sites can be shown and linked in Perplexity answers", "ips": ["https://www.perplexity.ai/perplexitybot.json"], "probeUa": "Mozilla/5.0 (compatible; PerplexityBot/1.0; +https://perplexity.ai/perplexitybot)" },
5
+ { "name": "MistralAI-Index", "vendor": "Mistral AI", "kind": "search", "group": "ai-search", "purpose": "Crawls to index pages for Mistral's search, which answers questions in Vibe; not used for training", "ips": ["https://mistral.ai/mistralai-index-ips.json"] },
6
+ { "name": "DuckAssistBot", "vendor": "DuckDuckGo", "kind": "search", "group": "ai-search", "purpose": "Fetches pages in real time for DuckDuckGo's AI-assisted answers; not used to train AI models", "ips": ["https://duckduckgo.com/duckassistbot.json"] },
7
+ { "name": "Amzn-SearchBot", "vendor": "Amazon", "kind": "search", "group": "ai-search", "purpose": "Crawls for search in Amazon's products, including Alexa; not used to train AI models", "ipsAt": "developer.amazon.com/amazonbot, as web pages" },
8
+ { "name": "Meta-WebIndexer", "vendor": "Meta", "kind": "search", "group": "ai-search", "purpose": "Crawls to improve Meta AI's search results; letting it in helps Meta AI cite and link the site" },
9
+ { "name": "YandexAdditionalBot", "vendor": "Yandex", "kind": "search", "alias": "YandexAdditional", "ownGroupOnly": true },
10
+ { "name": "Applebot", "vendor": "Apple", "kind": "search", "fallback": "Googlebot", "group": "search", "purpose": "Crawls for Apple's search features (Siri, Spotlight, Safari) and AI answers; may also be used to train Apple's models", "ips": ["https://search.developer.apple.com/applebot.json"] },
11
+ { "name": "GPTBot", "vendor": "OpenAI", "kind": "training", "group": "ai-training", "purpose": "Collects content to train OpenAI's models", "ips": ["https://openai.com/gptbot.json"] },
12
+ { "name": "ClaudeBot", "vendor": "Anthropic", "kind": "training", "group": "ai-training", "purpose": "Collects content to train Anthropic's models", "ips": ["https://claude.com/crawling/bots.json"] },
13
+ { "name": "Google-Extended", "vendor": "Google", "kind": "training" },
14
+ { "name": "Applebot-Extended", "vendor": "Apple", "kind": "training" },
15
+ { "name": "CCBot", "vendor": "Common Crawl", "kind": "training", "group": "ai-training", "purpose": "Builds the open Common Crawl dataset, widely used to train AI models", "ips": ["https://index.commoncrawl.org/ccbot.json"] },
16
+ { "name": "Bytespider", "vendor": "ByteDance", "kind": "training", "group": "ai-training", "purpose": "Collects content to train ByteDance's models" },
17
+ { "name": "meta-externalagent", "vendor": "Meta", "kind": "training", "group": "ai-training", "purpose": "Collects content to train Meta's AI models and index it for Meta's products" },
18
+ { "name": "MistralAI-Training", "vendor": "Mistral AI", "kind": "training", "group": "ai-training", "purpose": "Collects content to train Mistral's models; not used for search or live answers" },
19
+ { "name": "Amazonbot", "vendor": "Amazon", "kind": "training", "group": "ai-training", "purpose": "Crawls to improve Amazon's products and services; may be used to train Amazon's AI models", "ipsAt": "developer.amazon.com/amazonbot, as web pages" },
20
+ { "name": "ChatGPT-User", "vendor": "OpenAI", "kind": "user", "mayIgnore": true, "group": "ai-search", "purpose": "Fetches a page when a ChatGPT user's request needs it", "ips": ["https://openai.com/chatgpt-user.json"] },
21
+ { "name": "Claude-User", "vendor": "Anthropic", "kind": "user", "group": "ai-search", "purpose": "Fetches a page when a Claude user's request needs it", "ips": ["https://claude.com/crawling/bots.json"] },
22
+ { "name": "Perplexity-User", "vendor": "Perplexity", "kind": "user", "mayIgnore": true, "group": "ai-search", "purpose": "Fetches a page when a Perplexity user's request needs it", "ips": ["https://www.perplexity.ai/perplexity-user.json"] },
23
+ { "name": "Google-Agent", "vendor": "Google", "kind": "user", "mayIgnore": true, "group": "ai-search", "purpose": "Browses pages and acts on them for a user, from agents on Google's servers; robots.txt may not apply", "ips": ["https://developers.google.com/static/crawling/ipranges/user-triggered-agents.json"] },
24
+ { "name": "Google-GeminiNotebook", "vendor": "Google", "kind": "user", "mayIgnore": true, "group": "ai-search", "purpose": "Fetches a page a Gemini Notebook user added as a source", "ips": ["https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers-google.json", "https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers.json"] },
25
+ { "name": "MistralAI-User", "vendor": "Mistral AI", "kind": "user", "group": "ai-search", "purpose": "Fetches a page when a Vibe user's question needs it, and links the source in the answer", "ips": ["https://mistral.ai/mistralai-user-ips.json"] },
26
+ { "name": "Amzn-User", "vendor": "Amazon", "kind": "user", "mayIgnore": true, "group": "ai-search", "purpose": "Fetches a page for a live user request, such as an Alexa question; may not follow all robots.txt rules", "ipsAt": "developer.amazon.com/amazonbot, as web pages" },
27
+ { "name": "Meta-ExternalFetcher", "vendor": "Meta", "kind": "user", "mayIgnore": true, "group": "ai-search", "purpose": "Fetches a link at a user's request for Meta's AI features, including AI agents browsing sites; may bypass robots.txt" },
28
+ { "name": "OAI-AdsBot", "vendor": "OpenAI", "kind": "other", "group": "other", "purpose": "Checks landing pages submitted as ChatGPT ads; not used for training", "ips": ["https://openai.com/adsbot.json"] },
29
+ { "name": "Google-CloudVertexBot", "vendor": "Google", "kind": "other", "group": "other", "purpose": "Crawls a site only when its owner sets up a Vertex AI agent on it; no effect on Google Search", "ips": ["https://developers.google.com/static/crawling/ipranges/common-crawlers.json"] },
30
+ { "name": "Meta-ExternalAds", "vendor": "Meta", "kind": "other", "group": "other", "purpose": "Crawls for Meta's advertising and other business products and services" },
31
+ { "name": "GoogleMessages", "vendor": "Google", "group": "other", "purpose": "Builds link previews for URLs sent in Google Messages chats", "ips": ["https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers-google.json", "https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers.json"] },
32
+ { "name": "Google-NotebookLM", "vendor": "Google", "group": "ai-search", "purpose": "Fetches a page a NotebookLM user added as a source (the former name of Google-GeminiNotebook)", "ips": ["https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers-google.json", "https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers.json"] },
33
+ { "name": "Claude-Agent", "vendor": "Anthropic", "group": "ai-search", "purpose": "An Anthropic-hosted browser acting for a user; it keeps the browser's own user agent and adds this token", "ipsAt": "claude.com/.well-known/sail, in a draft format" },
34
+ { "name": "Googlebot", "vendor": "Google", "group": "search", "purpose": "Crawls for Google Search, including AI Overviews and AI Mode", "ips": ["https://developers.google.com/static/crawling/ipranges/common-crawlers.json"] },
35
+ { "name": "Bingbot", "vendor": "Microsoft", "group": "search", "purpose": "Crawls for Bing; Copilot answers are grounded in Bing's index", "ips": ["https://www.bing.com/toolbox/bingbot.json"] },
36
+ { "name": "DuckDuckBot", "vendor": "DuckDuckGo", "group": "search", "purpose": "Crawls for DuckDuckGo search" },
37
+ { "name": "YandexBot", "vendor": "Yandex", "group": "search", "purpose": "Crawls for Yandex search" }
38
+ ]
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ // Rebuilds schema-vocab.json for schema-check.mjs from one schema.org release. Run by hand for each new release.
3
+ // https://schema.org/docs/releases.html
4
+ // Output: types (name -> parents) and props (name -> [domain types, range types]); the checker resolves inheritance.
5
+ import { readFileSync, writeFileSync } from "node:fs";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const [version, flag, from] = process.argv.slice(2);
9
+ if (!/^\d+\.\d+$/.test(version || "") || (flag && (flag !== "--from" || !from))) {
10
+ console.error("usage: node build-schema-vocab.mjs <schema.org version, e.g. 30.1> [--from file.jsonld]");
11
+ process.exit(2);
12
+ }
13
+ const SOURCE = `https://schema.org/version/${version}/schemaorg-current-https.jsonld`;
14
+ let text;
15
+ if (from) text = readFileSync(from, "utf8");
16
+ else {
17
+ const res = await fetch(SOURCE);
18
+ if (!res.ok) {
19
+ console.error(`build-schema-vocab: ${SOURCE} returned ${res.status}`);
20
+ process.exit(1);
21
+ }
22
+ text = await res.text();
23
+ }
24
+
25
+ const name = id => String(id).replace(/^schema:/, "");
26
+ const ids = v =>
27
+ []
28
+ .concat(v ?? [])
29
+ .map(x => x["@id"])
30
+ .filter(id => id?.startsWith("schema:"))
31
+ .map(name)
32
+ .sort();
33
+ const types = {},
34
+ props = {};
35
+ for (const n of JSON.parse(text)["@graph"]) {
36
+ if (!n["@id"]?.startsWith("schema:")) continue;
37
+ const kinds = [].concat(n["@type"]);
38
+ if (kinds.includes("rdfs:Class")) types[name(n["@id"])] = ids(n["rdfs:subClassOf"]);
39
+ else if (kinds.includes("rdf:Property"))
40
+ props[name(n["@id"])] = [ids(n["schema:domainIncludes"]), ids(n["schema:rangeIncludes"])];
41
+ }
42
+ const sorted = o => Object.fromEntries(Object.entries(o).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
43
+ const out = fileURLToPath(new URL("./schema-vocab.json", import.meta.url));
44
+ writeFileSync(
45
+ out,
46
+ JSON.stringify({
47
+ version,
48
+ source: SOURCE,
49
+ license:
50
+ "Schema.org vocabulary (https://schema.org), licensed under the Creative Commons Attribution-ShareAlike 3.0 licence (CC BY-SA 3.0, https://creativecommons.org/licenses/by-sa/3.0/). Reduced to type, parent, domain and range names by build-schema-vocab.mjs.",
51
+ types: sorted(types),
52
+ props: sorted(props),
53
+ }) + "\n",
54
+ );
55
+ console.log(
56
+ `build-schema-vocab: schema.org ${version}, ${Object.keys(types).length} types, ${Object.keys(props).length} properties · wrote ${out}`,
57
+ );