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,54 @@
1
+ # URLs, canonicals and breadcrumbs (URL)
2
+
3
+ ### URL-01 · One clean URL pattern per content type · high
4
+ - **Check:** crawler `url-format`. Code: route folders, slug generation.
5
+ - **Pass:** lowercase words joined by hyphens, using the words people actually search (`dmarc-checker`, `ssl-certificate-checker`, not `tool-17` or `dmarc-v2`). No IDs, dates, file extensions or version numbers in slugs. Each content type has a fixed prefix from the profile's URL map. Slugs are permanent; tools, guides and posts get linked from forums and docs for years.
6
+ - **Fix:** follow the profile's URL map. When a slug must change, 301 the old one (URL-07).
7
+ - **Unencoded links:** crawler `url-unencoded` (low) flags links whose path or query holds a space or a non-ASCII letter (`/my page/`, `/café/`). Google's URL structure guide asks for non-ASCII characters to be percent-encoded (`/caf%C3%A9/`). A non-ASCII host name is fine, and so are spaces around the address.
8
+
9
+ ### URL-02 · One trailing-slash style, with the other variant redirecting · high
10
+ - **Check:** crawler `trailing-slash-mixed`, `slash-variant-no-redirect`, `slash-redirect-temporary`, `link-to-redirect`. Code: framework config (`trailingSlash` in Next.js), link helpers, canonical and sitemap builders.
11
+ - **Pass:** the profile names the style. Every page uses it, the other variant 301/308-redirects, and every internal link, canonical, sitemap `<loc>` and JSON-LD URL matches. Files keep no slash (`/sitemap.xml`, `/robots.txt`, `/llms.txt`).
12
+ - **Fix:** set it once in the framework, then fix the URL builders. Don't hand-edit links.
13
+ - **Temporary redirect:** `slash-redirect-temporary` (medium) flags the other variant redirecting with a 302, 303 or 307 on a staging or live server. Against a local dev server it's a note instead: dev servers often add the slash with a 302 (http-server does) where production doesn't.
14
+
15
+ ### URL-03 · One host, HTTPS only · high
16
+ - **Check:** code: server/CDN config. Probe `http://` and the other `www` variant against production when you're allowed to.
17
+ - **Pass:** `http` and the non-preferred host 301 to `https://` plus the preferred host in one hop. Retired staging hosts redirect or sit behind auth.
18
+ - **Fix:** add the redirects at the edge (nginx, CDN or host settings).
19
+ - **Live check:** `--check-live` follows `http://` on the production host and flags no redirect (high) or more than one hop to HTTPS (medium). It also asks the other host (with or without `www`) for its `http://` and `https://` home page and one deeper page: `host-not-redirected` (high) when it shows the site itself, so every page exists twice; `host-redirect-hops` (medium) for more than one hop (an `http://` to `https://` step on the same host first is allowed, as HSTS preloading requires); `host-redirect-drops-path` (medium) when the deeper page lands on the home page. `redirect-temporary` (medium) flags a 302, 303 or 307 on any of these redirects, the http→https one included. An other host that doesn't resolve or answer is fine: the site has one host. Before launch it's listed under Limits, and so it is while the production host doesn't resolve.
20
+
21
+ ### URL-04 · Every indexable page has a self-referencing, absolute canonical · high
22
+ - **Check:** crawler `canonical-missing`, `canonical-multiple`, `canonical-not-self`, `canonical-query`, `canonical-origin`, `canonical-bad-target`, `canonical-relative`. Code: the metadata helper.
23
+ - **Pass:** exactly one canonical, absolute, on the production origin, with the right slash style and no query string, pointing at a 200 page. Variants (parameters, prefill links, product variants) canonicalize to the master page.
24
+ - **Where it's read:** the canonical can come from the `<head>` or an HTTP `Link: <url>; rel="canonical"` header; one in the `<body>` doesn't count. Use one method: a header and a link element that disagree are two canonicals (`canonical-multiple`). Write it as an absolute URL (`canonical-relative`, low). Source: Google, "How to specify a canonical URL".
25
+ - **Fix:** build canonicals from the clean path plus one base-URL setting. Never build them from the request URL, which leaks `?utm_` tags.
26
+ - **After a fix:** Google may keep pages in a duplicate cluster for up to two weeks after the fix ("Fix canonicalization issues", Google Search Central), so URL Inspection can still show the old canonical for a while. Don't change the canonical again in the meantime.
27
+ - **Site-wide:** when the canonical is missing on at least 80% of indexable pages (and at least 3), the crawler reports one `*-sitewide` finding as a **blocker**, not one high per page. Keep it a blocker: it's the usual sign of a site with no SEO work.
28
+
29
+ ### URL-05 · Breadcrumbs are visible, match their schema, and every level is a real page · high
30
+ - **Check:** crawler `breadcrumb-dead-level`, `breadcrumb-missing`. Code: breadcrumb component and BreadcrumbList builder.
31
+ - **Pass:** one array renders both the visible trail and BreadcrumbList. Every level except the last is a live hub page. Levels that exist only in the breadcrumb (e.g. "Resources" with no URL prefix) still have a real page at their URL.
32
+ - **Fix:** create the missing hub pages, and share one breadcrumb source.
33
+
34
+ ### URL-06 · Item slugs can't clash with browse pages · medium
35
+ - **Check:** code: where items and categories share a namespace (e.g. `/blog/{post}/` and `/blog/{category}/`).
36
+ - **Pass:** a unique check covers both item and category slugs in each shared namespace, enforced in the database or a build check. Words the site will need later (`page`, `feed`, `tag`, `search`, `category`) are reserved.
37
+ - **Fix:** add the constraint and rename any clash with a redirect.
38
+
39
+ ### URL-07 · Renames redirect automatically · medium
40
+ - **Check:** code: redirect source. Look for a `redirectFrom` (or similar) field on content and a build check that fails when a slug changes without a redirect.
41
+ - **Pass:** redirects are generated from data, go to the final URL in one hop, and every target resolves.
42
+ - **Fix:** add the field and the build check. Never change the URL of a page that already gets search impressions unless the owner agrees.
43
+ - **Crawler:** with `--urls` (old site URLs) or `--next-manifest`, each old URL is tested with and without its trailing slash: `redirect-broken` (high) when it ends in an error, `redirect-chain` (CRAWL-08) for more than one hop, and `old-url-temporary` (medium) for a 302, 303 or 307. A hop that only adds or drops the trailing slash is left to URL-02. `old-urls-same-target` (medium) when 3 or more old URLs redirect to the home page, or 10 or more to any one other page (our own lines): Google says not to redirect many old URLs to one irrelevant page such as the home page, which "might be treated as a soft 404 error" (site moves with URL changes, updated 20 Aug 2026). Old pages merged into one new page may redirect there.
44
+ - **Linked pages that broke:** `scripts/links-import.mjs --crawl seo-audit/seo-crawl.json` matches the pages other sites link to (Search Console's Top linked pages, Bing's linked pages) with the crawl by path. One that returns 404 or 410, redirects in a loop, or redirects to the home page (Google: "might be treated as a soft 404 error") is `linked-page-broken` (medium); the home page's own other addresses (`/index.html`, `/home`, a bare language prefix like `/en/`) are left out. Fix: a 301 to the closest live page. Linked pages the crawl didn't reach aren't judged: pass them to the crawler with `--urls`, which records the ones that fail or redirect in the crawl's errors and redirects, and run links-import again.
45
+
46
+ ### URL-08 · Pagination is crawlable and self-canonical · medium
47
+ - **Check:** crawler pages with `?page=` or `/page/N/`. Code: list components.
48
+ - **Pass:** page 2 and beyond are reachable through real `<a href>` links. Each page is indexable with a canonical to itself, not to page 1. Sort-order variants canonicalize to the unsorted page.
49
+ - **Fix:** render real pagination links and per-page canonicals.
50
+
51
+ ### URL-09 · Every content item has one primary parent · medium
52
+ - **Check:** code: content model.
53
+ - **Pass:** where URLs are flat but breadcrumbs show a category or topic, every item has exactly one required primary category or topic. Changing it changes the breadcrumb, never the URL.
54
+ - **Fix:** add a required `primaryCategory` (or similar) field.
@@ -0,0 +1,314 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ // How often AI answer engines cite a site, or its rivals, when asked a list of questions.
4
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
5
+ import { dirname, resolve } from "node:path";
6
+ import { isMain } from "./lib/is-main.mjs";
7
+ import { parseArgs } from "./lib/args.mjs";
8
+ import { Fail, runMain, warnProxy } from "./lib/cli.mjs";
9
+ import { SERVICES, activeKeys, keyFile, call, Refused, domainOf } from "./connect-keys.mjs";
10
+
11
+ // Answers vary from run to run, so each question is asked several times.
12
+ const MAX_QUESTIONS = 20,
13
+ MAX_REPEAT = 10,
14
+ REPEAT = 3; // local caps, not provider limits
15
+ const ENGINES = {
16
+ // Sonar is only reachable through the Agent API since Chat Completions support ended on 27 Sep 2026. Perplexity
17
+ // names the search_results items the source of truth for citations. https://docs.perplexity.ai/docs/agent-api
18
+ perplexity: {
19
+ model: "perplexity/sonar",
20
+ body: q => ({ model: "perplexity/sonar", input: q, tools: [{ type: "web_search" }] }),
21
+ cited: b =>
22
+ b.output
23
+ .filter(o => o?.type === "search_results")
24
+ .flatMap(o => (Array.isArray(o.results) ? o.results : []))
25
+ .map(r => r?.url),
26
+ },
27
+ // chat-latest is ChatGPT's model. tool_choice "required" forces a search on every answer; store: false stops OpenAI
28
+ // keeping the answer for 30 days. https://developers.openai.com/api/docs/guides/tools-web-search
29
+ openai: {
30
+ model: "chat-latest",
31
+ body: q => ({
32
+ model: "chat-latest",
33
+ input: q,
34
+ tools: [{ type: "web_search" }],
35
+ tool_choice: "required",
36
+ store: false,
37
+ }),
38
+ cited: b =>
39
+ b.output
40
+ .filter(o => o?.type === "message")
41
+ .flatMap(o => (Array.isArray(o.content) ? o.content : []))
42
+ .flatMap(c => (Array.isArray(c?.annotations) ? c.annotations : []))
43
+ .filter(a => a?.type === "url_citation")
44
+ .map(a => a.url),
45
+ },
46
+ };
47
+ const IDS = Object.keys(ENGINES);
48
+ const CAVEAT =
49
+ "These answers come from the providers' APIs. They can differ from what people see in the ChatGPT or Perplexity apps, which add personal settings and location. Answers also change from day to day. So this is a sample to compare over time, not a ranking.";
50
+ const USAGE =
51
+ "usage: node ai-answers.mjs --site https://www.example.com --questions questions.txt [--rivals a.com,b.com] [--repeat 3] [--engines perplexity,openai] [--out seo-audit/ai-answers.json] [--yes]";
52
+ const fail = msg => {
53
+ throw new Fail("ai-answers: " + msg);
54
+ };
55
+ const bare = h => h.toLowerCase().replace(/^www\./, "");
56
+ const hostOf = u => {
57
+ try {
58
+ const x = new URL(u);
59
+ return /^https?:$/.test(x.protocol) ? bare(x.hostname) : null;
60
+ } catch {
61
+ return null;
62
+ }
63
+ };
64
+ const times = n => (n === 1 ? "once" : `${n} times`);
65
+ const plural = (n, w) => `${n} ${n === 1 ? w : w + "s"}`;
66
+ const sampleLine = (e, nQuestions, repeat, date) =>
67
+ `cited in ${e.cited} of ${plural(e.answers, "answer")} (a sample: ${plural(nQuestions, "question")}, asked ${times(repeat)} each, on ${date})`;
68
+
69
+ // Engines run in parallel, each one request at a time. A refusal (bad key, no credit, rate limit) stops only that
70
+ // engine and keeps its answers so far. Only the question is sent; citations are matched to the site locally.
71
+ async function askAll({ questions, repeat, engines, keys, endpoints, log }) {
72
+ const answers = [],
73
+ errors = {},
74
+ unread = {};
75
+ await Promise.all(
76
+ engines.map(async id => {
77
+ const e = ENGINES[id],
78
+ url = endpoints[id];
79
+ try {
80
+ for (const [i, question] of questions.entries()) {
81
+ for (let run = 1; run <= repeat; run++) {
82
+ const b = await call(id, url, {
83
+ method: "POST",
84
+ redirect: "manual",
85
+ headers: { authorization: `Bearer ${keys[id].key}`, "content-type": "application/json" },
86
+ body: JSON.stringify(e.body(question)),
87
+ });
88
+ if (!Array.isArray(b?.output) || b.status === "failed") {
89
+ unread[id] = (unread[id] || 0) + 1;
90
+ continue;
91
+ }
92
+ answers.push({
93
+ engine: id,
94
+ question,
95
+ run,
96
+ model: typeof b.model === "string" ? b.model : e.model,
97
+ cited: [...new Set(e.cited(b).filter(u => typeof u === "string" && hostOf(u)))],
98
+ });
99
+ }
100
+ log(`${SERVICES[id].name}: question ${i + 1} of ${questions.length} asked`);
101
+ }
102
+ } catch (err) {
103
+ if (!(err instanceof Refused)) throw err;
104
+ errors[id] = err.message;
105
+ }
106
+ }),
107
+ );
108
+ const order = a => [IDS.indexOf(a.engine), questions.indexOf(a.question), a.run];
109
+ answers.sort((a, b) => {
110
+ const x = order(a),
111
+ y = order(b);
112
+ return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
113
+ });
114
+ return { answers, errors, unread };
115
+ }
116
+
117
+ // An answer counts once per host or page, however many of its links point there.
118
+ function summarize({ answers, questions, repeat, host, rivals, engines, errors = {}, unread = {} }) {
119
+ return Object.fromEntries(
120
+ engines.map(id => {
121
+ const mine = answers.filter(a => a.engine === id),
122
+ cites = (a, h) => a.cited.some(u => hostOf(u) === h);
123
+ const pages = {};
124
+ for (const a of mine)
125
+ for (const p of new Set(a.cited.filter(u => hostOf(u) === host).map(u => new URL(u).pathname)))
126
+ pages[p] = (pages[p] || 0) + 1;
127
+ const asked = q => mine.filter(a => a.question === q);
128
+ return [
129
+ id,
130
+ {
131
+ name: SERVICES[id].name,
132
+ model: ENGINES[id].model,
133
+ asked: questions.length * repeat,
134
+ answers: mine.length,
135
+ cited: mine.filter(a => cites(a, host)).length,
136
+ rivals: Object.fromEntries(rivals.map(r => [r, mine.filter(a => cites(a, r)).length])),
137
+ pages: Object.fromEntries(Object.entries(pages).sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))),
138
+ neverCited: questions.filter(q => asked(q).length && !asked(q).some(a => cites(a, host))),
139
+ ...(unread[id] && { unread: unread[id] }),
140
+ ...(errors[id] && { error: errors[id] }),
141
+ },
142
+ ];
143
+ }),
144
+ );
145
+ }
146
+
147
+ // --competitors is the name rdap.mjs and connect-keys.mjs use for --rivals.
148
+ function main(argv) {
149
+ const args = parseArgs(argv, {
150
+ flags: ["site", "questions", "rivals", "repeat", "engines", "out"],
151
+ booleans: ["yes"],
152
+ aliases: { competitors: "rivals" },
153
+ positionals: 0,
154
+ usage: USAGE,
155
+ });
156
+ const str = k => (typeof args[k] === "string" ? args[k] : null);
157
+ if (!str("site") || !str("questions")) throw new Fail(USAGE);
158
+ let site;
159
+ try {
160
+ site = new URL(str("site"));
161
+ } catch {}
162
+ if (!site || !/^https?:$/.test(site.protocol))
163
+ fail(`--site must be the site's address, like https://www.example.com (got ${args.site})`);
164
+ const siteUrl = new URL("/", site).href,
165
+ host = bare(site.hostname);
166
+
167
+ let text;
168
+ try {
169
+ text = readFileSync(str("questions"), "utf8");
170
+ } catch (e) {
171
+ fail(`can't read ${args.questions} (${e.code || e.message}).`);
172
+ }
173
+ const questions = text
174
+ .split(/\r?\n/)
175
+ .map(s => s.trim())
176
+ .filter(s => s && !s.startsWith("#"));
177
+ if (!questions.length)
178
+ fail(`${args.questions} has no questions. Write one question per line, the way your customers would ask it.`);
179
+ if (questions.length > MAX_QUESTIONS)
180
+ fail(
181
+ `${args.questions} has ${questions.length} questions; the most is ${MAX_QUESTIONS} (our own cap, to keep the cost small). Keep the ones that matter most and run again.`,
182
+ );
183
+ const repeat = args.repeat === undefined ? REPEAT : Number(str("repeat"));
184
+ if (!(Number.isInteger(repeat) && repeat >= 1 && repeat <= MAX_REPEAT))
185
+ fail(`--repeat must be a whole number from 1 to ${MAX_REPEAT} (our own cap; got ${args.repeat}).`);
186
+ const chosen = str("engines")
187
+ ? [
188
+ ...new Set(
189
+ str("engines")
190
+ .split(",")
191
+ .map(s => s.trim().toLowerCase())
192
+ .filter(Boolean),
193
+ ),
194
+ ]
195
+ : IDS;
196
+ for (const id of chosen)
197
+ if (!IDS.includes(id))
198
+ fail(`there's no "${id}" engine. Use perplexity or openai, or both: --engines perplexity,openai`);
199
+
200
+ const listed = (str("rivals") || "")
201
+ .split(",")
202
+ .map(s => s.trim())
203
+ .filter(Boolean);
204
+ const notes = listed
205
+ .filter(r => !domainOf(r))
206
+ .map(r => `Skipped rival "${r}": it's not a domain name like rival.com.`);
207
+ const rivals = [...new Set(listed.map(domainOf).filter(d => d && d !== host))];
208
+ const keys = activeKeys(),
209
+ endpoints = Object.fromEntries(IDS.map(id => [id, process.env[SERVICES[id].endpointEnv] || SERVICES[id].endpoint]));
210
+ const engines = chosen.filter(id => keys[id]);
211
+
212
+ if (!args.yes) {
213
+ const lines = chosen.map(id => {
214
+ const s = SERVICES[id],
215
+ k = keys[id],
216
+ url = new URL(endpoints[id]);
217
+ return k
218
+ ? ` ${s.name}: ${questions.length * repeat} requests to ${url.host} (POST ${url.href}, the model ${ENGINES[id].model} with web search), with your key ${k.from === s.env ? `from ${s.env}` : `saved in ${keyFile()}`}`
219
+ : ` ${s.name}: no key set, so it's skipped. To add it: node connect-keys.mjs guide ${id}`;
220
+ });
221
+ console.log(
222
+ [
223
+ `ai-answers: dry run, nothing sent. With --yes it would ask ${plural(questions.length, "question")}, ${times(repeat)} each, with your own keys:`,
224
+ ...lines,
225
+ ` ${questions.length * repeat * engines.length} requests in all. Each one sends one question and your key, with the model and web search settings above. Nothing about your site goes: not its address, its pages or the rivals' names. The answers are matched to them on this computer.`,
226
+ "The questions, exactly as they would be sent:",
227
+ ...questions.map((q, i) => ` ${i + 1}. ${q}`),
228
+ ...notes,
229
+ // Prices as of 22 Nov 2026: https://docs.perplexity.ai/docs/getting-started/pricing and
230
+ // https://developers.openai.com/api/docs/pricing
231
+ "Each provider bills its own account for every answer: the text it reads and writes, at the model's rates, plus a fee for each web search (one answer can search more than once). On 22 Nov 2026 their pricing pages listed $2.50 per 1,000 searches for Perplexity and $10 per 1,000 for OpenAI. See docs.perplexity.ai/docs/getting-started/pricing and developers.openai.com/api/docs/pricing.",
232
+ "Your questions may name your brand, and they go to these providers at your cost, so re-run with --yes once the owner agrees.",
233
+ ].join("\n"),
234
+ );
235
+ return 0;
236
+ }
237
+ if (!engines.length)
238
+ fail(
239
+ `no key is set for ${chosen.map(id => SERVICES[id].name).join(" or ")}. To add one: ${chosen.map(id => `node connect-keys.mjs guide ${id}`).join(", or ")}`,
240
+ );
241
+ return run({
242
+ siteUrl,
243
+ host,
244
+ questions,
245
+ repeat,
246
+ rivals,
247
+ engines,
248
+ keys,
249
+ endpoints,
250
+ notes,
251
+ skipped: chosen.filter(id => !keys[id]),
252
+ out: resolve(str("out") || "seo-audit/ai-answers.json"),
253
+ });
254
+ }
255
+
256
+ async function run({ siteUrl, host, questions, repeat, rivals, engines, keys, endpoints, notes, skipped, out }) {
257
+ const date = new Date().toISOString().slice(0, 10);
258
+ const { answers, errors, unread } = await askAll({
259
+ questions,
260
+ repeat,
261
+ engines,
262
+ keys,
263
+ endpoints,
264
+ log: s => console.error("ai-answers: " + s),
265
+ });
266
+ for (const id of skipped)
267
+ notes.push(`${SERVICES[id].name} wasn't asked: no key is set. To add it: node connect-keys.mjs guide ${id}`);
268
+ for (const [id, n] of Object.entries(unread))
269
+ notes.push(
270
+ `${SERVICES[id].name}: ${plural(n, "answer")} failed or couldn't be read, so ${n === 1 ? "it's" : "they're"} left out.`,
271
+ );
272
+ const result = {
273
+ source: "ai-answers",
274
+ date,
275
+ site: siteUrl,
276
+ host,
277
+ rivals,
278
+ questions,
279
+ repeat,
280
+ engines: summarize({ answers, questions, repeat, host, rivals, engines, errors, unread }),
281
+ answers,
282
+ notes,
283
+ };
284
+ mkdirSync(dirname(out), { recursive: true });
285
+ writeFileSync(out, JSON.stringify(result, null, 2));
286
+ for (const [id, e] of Object.entries(result.engines)) {
287
+ if (e.error)
288
+ console.log(
289
+ `ai-answers: ${e.error}${e.answers ? ` The ${plural(e.answers, "answer")} ${SERVICES[id].name} gave before that ${e.answers === 1 ? "is" : "are"} kept.` : ""}`,
290
+ );
291
+ if (!e.answers) continue;
292
+ console.log(`ai-answers: ${e.name}: your site was ${sampleLine(e, questions.length, repeat, date)}.`);
293
+ for (const [r, n] of Object.entries(e.rivals))
294
+ console.log(` ${r}: cited in ${n} of ${plural(e.answers, "answer")}`);
295
+ const pages = Object.entries(e.pages);
296
+ if (pages.length)
297
+ console.log(
298
+ ` Your pages cited: ${pages
299
+ .slice(0, 10)
300
+ .map(([p, n]) => `${p} in ${plural(n, "answer")}`)
301
+ .join(", ")}`,
302
+ );
303
+ if (e.neverCited.length)
304
+ console.log(` Questions whose answers never cited your site: ${e.neverCited.map(q => `"${q}"`).join(", ")}`);
305
+ }
306
+ for (const n of notes) console.log("ai-answers: " + n);
307
+ console.log(`ai-answers: ${CAVEAT}\nai-answers: wrote ${out}`);
308
+ return Object.keys(errors).length ? 1 : 0;
309
+ }
310
+
311
+ if (isMain(import.meta.url)) {
312
+ warnProxy();
313
+ await runMain(() => main(process.argv.slice(2)));
314
+ }