seo-supervisor 0.0.0-stage → 1.2.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 (54) hide show
  1. package/.claude-plugin/marketplace.json +16 -0
  2. package/.claude-plugin/plugin.json +14 -0
  3. package/CHANGELOG.md +31 -0
  4. package/LICENSE +25 -0
  5. package/README.md +197 -2
  6. package/bin/agents.mjs +65 -0
  7. package/bin/prompt.mjs +76 -0
  8. package/bin/seo-supervisor.mjs +144 -0
  9. package/commands/seo-audit.md +7 -0
  10. package/commands/seo-fix.md +13 -0
  11. package/commands/seo-launch.md +7 -0
  12. package/commands/seo-review.md +7 -0
  13. package/commands/seo-setup.md +19 -0
  14. package/package.json +45 -4
  15. package/skills/seo-supervisor/SKILL.md +199 -0
  16. package/skills/seo-supervisor/examples/sample-audit.json +440 -0
  17. package/skills/seo-supervisor/examples/sample-report.html +654 -0
  18. package/skills/seo-supervisor/examples/sample-report.md +257 -0
  19. package/skills/seo-supervisor/examples/security-tools-profile.md +73 -0
  20. package/skills/seo-supervisor/examples/snippets.md +134 -0
  21. package/skills/seo-supervisor/frameworks/nextjs.md +98 -0
  22. package/skills/seo-supervisor/frameworks/rails.md +34 -0
  23. package/skills/seo-supervisor/frameworks/spa.md +14 -0
  24. package/skills/seo-supervisor/planning.md +145 -0
  25. package/skills/seo-supervisor/profile-template.md +55 -0
  26. package/skills/seo-supervisor/report-format.md +146 -0
  27. package/skills/seo-supervisor/rules/ai-search.md +40 -0
  28. package/skills/seo-supervisor/rules/content.md +60 -0
  29. package/skills/seo-supervisor/rules/crawl-index.md +65 -0
  30. package/skills/seo-supervisor/rules/internal-linking.md +61 -0
  31. package/skills/seo-supervisor/rules/launch-monitoring.md +48 -0
  32. package/skills/seo-supervisor/rules/media.md +30 -0
  33. package/skills/seo-supervisor/rules/metadata.md +39 -0
  34. package/skills/seo-supervisor/rules/performance.md +33 -0
  35. package/skills/seo-supervisor/rules/rendering.md +42 -0
  36. package/skills/seo-supervisor/rules/sitemaps-robots.md +37 -0
  37. package/skills/seo-supervisor/rules/structured-data.md +75 -0
  38. package/skills/seo-supervisor/rules/trust-security.md +25 -0
  39. package/skills/seo-supervisor/rules/urls.md +46 -0
  40. package/skills/seo-supervisor/scripts/content-scan.mjs +173 -0
  41. package/skills/seo-supervisor/scripts/fonts/OFL-BricolageGrotesque.txt +93 -0
  42. package/skills/seo-supervisor/scripts/fonts/OFL-Geist.txt +93 -0
  43. package/skills/seo-supervisor/scripts/fonts/OFL-GeistMono.txt +93 -0
  44. package/skills/seo-supervisor/scripts/fonts/bricolage-grotesque.woff2 +0 -0
  45. package/skills/seo-supervisor/scripts/fonts/geist-mono.woff2 +0 -0
  46. package/skills/seo-supervisor/scripts/fonts/geist.woff2 +0 -0
  47. package/skills/seo-supervisor/scripts/render-report.mjs +706 -0
  48. package/skills/seo-supervisor/scripts/report-plan.mjs +162 -0
  49. package/skills/seo-supervisor/scripts/seo-crawl.mjs +703 -0
  50. package/skills/seo-supervisor/site-types/content.md +22 -0
  51. package/skills/seo-supervisor/site-types/ecommerce.md +27 -0
  52. package/skills/seo-supervisor/site-types/local-business.md +28 -0
  53. package/skills/seo-supervisor/site-types/services.md +22 -0
  54. package/skills/seo-supervisor/site-types/tools.md +127 -0
@@ -0,0 +1,48 @@
1
+ # Launch and monitoring (LAUNCH)
2
+
3
+ ### LAUNCH-01 · Crawl staging before launch · high
4
+ - Run the crawler against staging (with auth, or a production build on localhost). Zero blockers and zero high findings in CRAWL, URL, REND and MAP before go-live.
5
+ - Check the redirect map for the old site: every old URL that has traffic or backlinks 301s to its closest new page in one hop, and nothing that used to get traffic returns 404 (old blog posts, printed short links like `/go/review`).
6
+
7
+ ### LAUNCH-02 · Launch day · high
8
+ 1. Switch the indexing variable on and run the production noindex check (CRAWL-03).
9
+ 2. Confirm `http` → `https` and the host redirects (URL-03).
10
+ 3. Submit the sitemap in Search Console and Bing, and ping IndexNow.
11
+ 4. Run URL Inspection on the home page, the main hubs and the 10 most important pages, and request indexing.
12
+ 5. Re-run the crawler against production with `--concurrency 2`.
13
+
14
+ ### LAUNCH-03 · The build fails on SEO regressions · high
15
+ - **Check:** CI config.
16
+ - **Pass:** a content or route validator runs in prebuild or CI and fails on:
17
+ - duplicate or wrongly sized titles and descriptions
18
+ - not exactly one H1, or skipped heading levels
19
+ - FAQ schema without a visible FAQ
20
+ - links to unknown or unpublished slugs
21
+ - orphan pages
22
+ - near-duplicate intros
23
+ - reused FAQ questions
24
+ - placeholder and banned strings
25
+ - a slug changed without a redirect
26
+ - When a rule fires, rewrite the content; never weaken the rule. The crawler can also run in CI against a preview deployment: fail the job when `seo-crawl.json` has blocker or high findings.
27
+
28
+ ### LAUNCH-04 · Measure what visitors do · medium
29
+ - Analytics events on the actions that matter (form submit, tool run, call click, add to cart, next-step link clicks). Never send what a visitor typed, secrets or scanned domains. Tool sites: use the event list in TOOL-12.
30
+
31
+ ### LAUNCH-05 · Watch Search Console every week · medium
32
+ - **Pages report:** "Crawled, currently not indexed" on templated pages usually means thin or duplicate content (CONTENT-04/05).
33
+ - 404s that have backlinks get redirects.
34
+ - Core Web Vitals and enhancement reports.
35
+ - Manual actions and security issues.
36
+
37
+ ### LAUNCH-08 · Traffic drops are checked against Google updates first · medium
38
+ - Before diagnosing a drop as technical, compare its dates with the Google Search Status Dashboard (status.search.google.com). Recent windows:
39
+ - **Core updates:** Mar, Jun and Dec 2025; Mar, May and Nov 2026.
40
+ - **Spam updates:** Aug 2025; Mar, Jun, Aug and Sep 2026.
41
+ - Wait at least a week after an update finishes, compare by search type, and expect recovery to take months, through better content rather than technical tweaks.
42
+ - **Search Console reports worth using:** Insights, query groups, the branded-queries filter, annotations, and Generative AI performance.
43
+
44
+ ### LAUNCH-06 · The 404 page helps · low
45
+ - A real 404 status, noindex, a short message, and links to the main hubs and popular pages.
46
+
47
+ ### LAUNCH-07 · Roll out large sets of programmatic pages in batches · medium
48
+ - Publish the highest-value pages first and the rest over weeks, using release flags (CRAWL-11). Watch indexing after each batch before releasing the next.
@@ -0,0 +1,30 @@
1
+ # Images and video (MEDIA)
2
+
3
+ > Checked **17 Nov 2026** against Google's image, Discover and video documentation.
4
+
5
+ ### MEDIA-01 · Content images are real `<img>` elements · high
6
+ - **Check:** code: hero and content images set as CSS `background-image`; `<picture>` or `srcset` without a fallback `src`.
7
+ - **Pass:** every image that should be found uses `<img src>` (Google doesn't index CSS background images), with a fallback `src` on `srcset`/`<picture>`. Inline SVG uses `<title>`.
8
+
9
+ ### MEDIA-02 · Images are described and named · medium
10
+ - **Check:** crawler `img-alt`; filenames in the image folder or CMS.
11
+ - **Pass:** alt text describes the image in context (CONTENT-08); filenames are descriptive (`ssl-certificate-chain-diagram.webp`, not `IMG_4032.jpg`) and translated per locale; the same image uses the same URL everywhere; formats are BMP, GIF, JPEG, PNG, WebP, SVG or AVIF, with an extension that matches.
12
+
13
+ ### MEDIA-03 · Each page signals its preferred thumbnail · medium
14
+ - **Check:** `primaryImageOfPage`, `image` on the page's `mainEntity`, or `og:image`.
15
+ - **Pass:** a relevant image, not a logo, text-heavy graphic or extreme aspect ratio. Publishers wanting Google Discover: images at least 1200 px wide (over 300,000 pixels, ideally 16:9) plus `max-image-preview:large`.
16
+
17
+ ### MEDIA-04 · Image sitemaps only where they help · low
18
+ - Optional. Useful when images live on a CDN or are loaded in ways crawlers miss. Only `<image:loc>` is used; verify the CDN host in Search Console.
19
+
20
+ ### MEDIA-05 · Videos get indexed on watch pages · medium
21
+ - **Check:** pages with video; robots rules for video files and thumbnails.
22
+ - **Pass:** a video gets video results only on a page where it's the main content (a watch page). Embeds inside articles, products or categories generally don't. Video files and thumbnails aren't blocked by robots.txt, noindex or login, and use stable URLs (expiring CDN URLs break indexing). Thumbnails are at least 60×30.
23
+
24
+ ### MEDIA-06 · VideoObject is complete · high (on watch pages)
25
+ - **Required:** `name`, `thumbnailUrl`, `uploadDate` (ISO 8601 with a timezone).
26
+ - **Recommended:** `contentUrl` (the most effective), `embedUrl`, `duration`, `description`, `creator`.
27
+ - Use `regionsAllowed` or `ineligibleRegion`, not both.
28
+ - **Key moments:** `Clip` (name, `startOffset`, a `?t=` URL, unique starts) or `SeekToAction` (a target with `{seek_to_second_number}`). The video must be at least 30 seconds long, and `nosnippet` turns key moments off.
29
+ - **Live streams:** `BroadcastEvent`.
30
+ - After launch, watch Search Console's Video indexing report.
@@ -0,0 +1,39 @@
1
+ # Metadata (META)
2
+
3
+ ### META-01 · Every indexable page has a unique title of a sensible length · high
4
+ - **Check:** crawler `title-missing`, `title-long`, `title-short`, `title-dup`, `title-multiple`.
5
+ - **Pass:** unique, about 30–60 characters (some projects allow 65), main keyword first, brand once at the end.
6
+ - **Fix:** a title pattern per page type in the profile, e.g. tool pages: "DMARC Checker - Free DMARC Record Lookup | Brand". Where pages compete for one phrase, give that phrase to one page and retitle the others (CONTENT-04).
7
+
8
+ ### META-02 · Every indexable page has a unique meta description of 120–160 characters · medium
9
+ - **Check:** crawler `desc-missing`, `desc-length`, `desc-dup`.
10
+ - **Pass:** says what the visitor gets and why this page; no template text with a name swapped.
11
+ - **Fix:** add a description field to the content model, or generate one per page type from specific data, never from boilerplate.
12
+
13
+ ### META-03 · All metadata comes from one helper · medium
14
+ - **Check:** crawler `title-brand-twice` (with `--brand`). Code: how pages set titles, canonicals, Open Graph and robots.
15
+ - **Pass:** one helper sets the title, description, canonical, Open Graph, Twitter card and robots. The title template doesn't double the brand.
16
+ - **Fix:** centralize it. When a page title already contains the brand, use an absolute title.
17
+
18
+ ### META-04 · Open Graph and Twitter tags on every page; key pages get their own image · low
19
+ - **Check:** crawler `og-missing`. Code: does a per-page `openGraph` object replace the inherited image? (A common Next.js trap.)
20
+ - **Fix:** set a default image in the helper and generate images for key page types.
21
+
22
+ ### META-05 · The page language is declared · low
23
+ - **Check:** crawler `lang-missing`.
24
+ - **Fix:** set `<html lang>` in the root layout.
25
+
26
+ ### META-06 · Robots meta depends on page type, using the object form · medium
27
+ - **Check:** code: robots values in the metadata helper.
28
+ - **Pass:** indexable pages are `index, follow` with `max-image-preview:large` and `max-snippet:-1`. Search, filter and result pages are `noindex, follow`. Account, admin, sign-in and 404 pages are `noindex, nofollow`.
29
+ - **Fix:** derive it from the page type. A plain string robots value can silently override the layout's richer object.
30
+
31
+ ### META-07 · Google Search Console and Bing Webmaster Tools are verified · medium
32
+ - **Check:** code: verification meta or DNS TXT (ask the owner if you can't tell).
33
+ - **Fix:** verify a Domain property by DNS; Bing can import it from Search Console. Never ship placeholder verification codes.
34
+
35
+ ### META-08 · hreflang only when there are real language or region versions · low
36
+ - **Check:** code: `alternates.languages` or `<link rel="alternate" hreflang>`.
37
+ - **Pass:** each version lists all the others and itself, plus `x-default` (for language selectors and auto-redirecting home pages), with fully qualified URLs. Codes are ISO 639-1 language codes with an optional ISO 3166-1 region (`en-GB`); `UK`, `EU` and `es-419` are silently ignored. Each version canonicalizes to itself in the same language. Use one method only (HTML, header or sitemap).
38
+ - **Never:** auto-redirect by IP or `Accept-Language` (Googlebot usually crawls from the US with no `Accept-Language`). Use a banner suggesting the other version instead.
39
+ - **Fix:** remove one-sided or self-only hreflang that serves no purpose, unless the site deliberately targets one region.
@@ -0,0 +1,33 @@
1
+ # Performance and Core Web Vitals (PERF)
2
+
3
+ > Thresholds checked **16 Nov 2026**, unchanged since INP replaced FID (March 2024): LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1, measured at the 75th percentile of real mobile visits.
4
+
5
+ > Google says only Core Web Vitals are used by its ranking systems; other page-experience factors (HTTPS, popups) "don't directly help your website rank". Rate those by their effect on visitors and crawling, not as ranking levers.
6
+
7
+ ### PERF-07 · Popups don't block content or crawlers · high
8
+ - **Check:** code: modals, consent walls, age gates, app banners.
9
+ - **Pass:** no popup covers the whole page on arrival. Users aren't redirected to a separate consent or input page (Googlebot would see only that page). Required gates (age, legal) overlay the content instead of replacing it.
10
+
11
+ ### PERF-01 · Core Web Vitals pass on mobile · high
12
+ - **Check:** field data (Search Console CWV report, PageSpeed Insights or CrUX) when the site is live; lab data (Lighthouse) before launch. The crawler can't measure CWV, so list it under `notChecked` unless you ran one of these.
13
+ - **Fix:** send real-user metrics to analytics with the `web-vitals` library, and fix the worst template first.
14
+
15
+ ### PERF-02 · Each page loads only its own code · medium
16
+ - **Check:** code: shared bundles importing every widget or heavy library; client components wrapping whole pages.
17
+ - **Fix:** dynamic import per widget, with server rendering kept on for anything with text.
18
+
19
+ ### PERF-03 · The LCP element loads first · medium
20
+ - **Check:** crawler `lazy-lcp`. Code: hero components.
21
+ - **Pass:** the LCP is a real `<img>` (never a CSS background) or text. It's never lazy-loaded on any template, and gets `fetchpriority="high"` / framework `priority`. Exactly one preload per page. Fonts use `font-display: swap` and are self-hosted or preloaded.
22
+
23
+ ### PERF-04 · Layout doesn't jump · medium
24
+ - **Check:** crawler `img-dimensions`. Code: banners injected after load, results areas that grow, embeds.
25
+ - **Pass:** images and embeds have width and height or an aspect-ratio box. Dynamic areas reserve space. Nothing is inserted above content after load.
26
+
27
+ ### PERF-05 · Interactions stay fast · low
28
+ - **Check:** code: heavy work on input (parsing, hashing, large lists).
29
+ - **Fix:** debounce, move CPU work to a Web Worker, and show progress.
30
+
31
+ ### PERF-06 · Documents and third parties stay light · low
32
+ - **Check:** crawler `html-size` (over 500 KB). Code: third-party scripts and iframes (maps, chat, video).
33
+ - **Pass:** third-party domains kept to a minimum. Iframes load on interaction or below the fold and carry a descriptive `title`. Images are no more than about 2× their display size and use modern formats.
@@ -0,0 +1,42 @@
1
+ # Rendering: what crawlers actually see (REND)
2
+
3
+ Google renders JavaScript, but later and not always. Most AI crawlers (GPTBot, ClaudeBot, PerplexityBot) don't render it at all. Judge pages by the HTML the server sends.
4
+
5
+ ### REND-01 · Content is in the server HTML, not only in JavaScript · blocker
6
+ - **Check:** crawler `client-rendered`, plus words per page in `seo-crawl.json`. Spot-check the H1, H2s, JSON-LD and an FAQ answer with the curl commands in `examples/snippets.md`.
7
+ - **Pass:** the H1, intro, main copy, FAQ, links and JSON-LD are all in the HTML response. Only interactive widgets need client JavaScript.
8
+ - **Fix:** use server rendering or static generation (see the framework file). Never disable SSR for components that contain text.
9
+
10
+ ### REND-02 · Collapsed content stays in the HTML · high
11
+ - **Check:** code: accordions, tabs, "show more", FAQ components that render with `{open && …}` or mount on click. Crawler `faq-not-visible` catches FAQ schema whose text is missing.
12
+ - **Pass:** collapsed content is rendered and hidden with CSS or a native `<details>` element.
13
+ - **Fix:** always render the content; toggle visibility with CSS, `hidden` or `inert`.
14
+
15
+ ### REND-03 · Pages don't depend on a slow or failing API to render · high
16
+ - **Check:** code: page data fetching. Does a page call an external or scan API during render?
17
+ - **Pass:** page data comes from cached content (build time, ISR, or a cache). Live APIs are called only on user action. If they're down, the page still returns 200 with its content.
18
+ - **Fix:** move live calls behind the user action, and give the widget its own error state.
19
+
20
+ ### REND-04 · Navigation uses real `<a href>` links · low
21
+ - **Check:** crawler `href-hash`. Code: `onClick` navigation, `href="#"`, `javascript:` links, links rendered only after JavaScript.
22
+ - **Fix:** use real links for navigation and `<button>` for actions.
23
+
24
+ ### REND-06 · JavaScript doesn't fight the HTML · blocker
25
+ - **Check:** code: client code that edits robots meta, canonicals or status.
26
+ - **Pass:**
27
+ - **Noindex:** a noindex in the server HTML can stop rendering, so removing it with JavaScript may never take effect.
28
+ - **Canonical:** set it in the server HTML; JavaScript must not change it.
29
+ - **Status:** only 200 pages are reliably rendered. SPA "not found" views redirect to a URL the server answers with 404, or inject noindex.
30
+ - **Routing:** use the History API, not `#` routes.
31
+
32
+ ### REND-07 · Mobile shows the same content as desktop · blocker
33
+ - **Check:** compare a mobile and a desktop render of key templates (Google indexes mobile-first, fully since 2024).
34
+ - **Pass:** same main content, headings, structured data, titles, descriptions, alt text and robots meta on mobile. Primary content isn't hidden behind interaction-only lazy loading.
35
+
36
+ ### REND-08 · HTML stays under Googlebot's 2 MB limit · high
37
+ - **Check:** crawler `html-size` (flags anything over 500 KB; over 2 MB is high).
38
+ - **Pass:** Googlebot reads only the first 2 MB of each HTML response; content past that isn't indexed. Keep the title, meta, canonical and JSON-LD early in `<head>`, and move huge inline JSON (hydration data, big lists) out of the document.
39
+
40
+ ### REND-05 · One title, canonical, robots tag and schema graph per page · high
41
+ - **Check:** crawler `title-multiple`, `canonical-multiple`. Code: layouts that hard-code a title, or two SEO plugins or helpers both writing tags.
42
+ - **Fix:** emit head tags from one place.
@@ -0,0 +1,37 @@
1
+ # Sitemaps, robots.txt and llms.txt (MAP)
2
+
3
+ ### MAP-01 · An XML sitemap exists and robots.txt references it · high
4
+ - **Check:** crawler `sitemap-missing`, `sitemap-not-in-robots`.
5
+ - **Pass:** `/sitemap.xml` (or a sitemap index) is valid XML with absolute `<loc>` URLs, linked from robots.txt with `Sitemap: https://…/sitemap.xml`. Not an RSS feed; no dead sitemaps listed.
6
+ - **Fix:** split into a sitemap index with one file per section past a few thousand URLs, or when you want Search Console to report indexing per section.
7
+
8
+ ### MAP-02 · The sitemap lists only canonical, indexable URLs on the production host · high
9
+ - **Check:** crawler `sitemap-origin`, `sitemap-noncanonical`, `noindex-in-sitemap`, `sitemap-bad-status`.
10
+ - **Pass:** generated from the same live data as the pages. No redirects, noindex pages, variants, parameter URLs, thin browse pages, drafts, or localhost/staging hosts.
11
+
12
+ ### MAP-03 · Every indexable page is in the sitemap · medium
13
+ - **Check:** crawler `missing-from-sitemap`.
14
+ - **Fix:** generate the sitemap from the content source instead of a hand-kept list. A test comparing sitemap URLs with indexable routes keeps them in sync.
15
+
16
+ ### MAP-04 · lastmod dates are real · low
17
+ - **Check:** crawler `sitemap-lastmod-same`. Code: is `lastModified` set to `new Date()` or the build time?
18
+ - **Pass:** each URL's lastmod is the record's real `updatedAt`, and a hub's is the newest among its items. Google uses lastmod only on sites where it proves accurate. Leave `priority` and `changefreq` out; Google and Bing ignore them.
19
+ - **Fix:** use content dates, or drop lastmod rather than fake it.
20
+
21
+ ### MAP-05 · robots.txt blocks only junk, and never CSS or JS · medium
22
+ - **Check:** crawler `robots-missing`, `robots-blocks-assets`.
23
+ - **Pass:** allows `/`. Disallows only API routes, framework internals that aren't render assets (e.g. Next.js `_rsc` requests), internal search and admin. Never blocks pages that carry noindex.
24
+
25
+ ### MAP-06 · The AI crawler policy is a deliberate, written decision · low
26
+ - **Check:** crawler `ai-bots-blocked` (needs-decision).
27
+ - **Default:** allow them; being cited in AI answers is distribution.
28
+ - **Middle ground:** block the training crawlers (`GPTBot`, `ClaudeBot`, `Google-Extended`, `CCBot`, `Applebot-Extended`) and allow the search and user crawlers (`OAI-SearchBot`, `ChatGPT-User`, `Claude-SearchBot`, `Claude-User`, `PerplexityBot`). Record the choice in the profile. Details, Bing's new AI directives and the vendor IP lists are in `rules/ai-search.md` (AI-02, AI-03).
29
+
30
+ ### MAP-07 · /llms.txt, optional · low
31
+ - **Check:** crawler `llms-txt`.
32
+ - **Fact:** Google Search ignores llms.txt and it doesn't affect ranking (clarified June 2026). No major AI crawler documents using it either. It's harmless; never present it as a ranking or AI-visibility fix.
33
+ - **Pass (if kept):** Markdown with one line on what the site is, then each section with its key pages (name, URL, one sentence), generated so it can't drift from the real pages.
34
+
35
+ ### MAP-08 · Sitemaps are submitted, and changes are pinged · low
36
+ - **Check:** ask the owner, or look for automation.
37
+ - **Pass:** sitemaps are submitted in Search Console and Bing Webmaster Tools. IndexNow is pinged on publish, with the key file at the site root. IndexNow reaches Bing (and through it Copilot), Yandex, Seznam, Naver, Yep, Internet Archive and Amazonbot, but not Google. Bing wants the true content-change time as lastmod and ignores `changefreq` and `priority`.
@@ -0,0 +1,75 @@
1
+ # Structured data: JSON-LD (SCHEMA)
2
+
3
+ > Facts checked **16 Nov 2026** against Google Search Central. Verify again if this is more than about six months old.
4
+ > **Still earn Google rich results:** Breadcrumb, Software app (needs a real rating or review), Article, Organization, Profile page, Product / merchant listing, Review snippet, Local business, Event, Recipe, Video, Dataset, Q&A and discussion forum.
5
+ > **Gone:**
6
+ > - FAQ rich results (removed for every site on 7 May 2026)
7
+ > - HowTo (Sept 2023)
8
+ > - sitelinks search box / SearchAction (Nov 2024)
9
+ > - Book Actions, Course Info, ClaimReview, Estimated Salary, Learning Video, Special Announcement and Vehicle Listing (phased out from June 2025)
10
+ > - Practice Problem (Jan 2026)
11
+ >
12
+ > Leftover markup of these types is harmless dead weight. FAQPage is still valid schema that Bing and AI engines read, so keep it only where the FAQ is visible. Dataset markup now serves Dataset Search only.
13
+ >
14
+ > **Added recently:**
15
+ > - Offer `priceType` and `validForMemberTier`
16
+ > - loyalty programs
17
+ > - return and shipping policies at Organization level
18
+ > - Product `category`
19
+ > - VideoObject `creator`
20
+ > - new Discussion forum and Q&A properties
21
+ >
22
+ > **Reviews:** no fake or undisclosed incentivised reviews, on the page or in markup. Self-serving reviews in LocalBusiness or Organization markup never earn stars.
23
+ >
24
+ > **Not needed for AI search:** Google says no schema is required for AI Overviews or AI Mode.
25
+
26
+ ### SCHEMA-01 · JSON-LD parses and comes from data · high
27
+ - **Check:** crawler `jsonld-invalid`. Code: the JSON-LD component.
28
+ - **Pass:** built with `JSON.stringify` from typed data, with `<` escaped (`<`) so no string can close the script tag. Never string templates. No relative URLs, staging hosts or `new Date()` dates.
29
+
30
+ ### SCHEMA-02 · Organization (or the right business subtype) and WebSite, once, with stable `@id`s · medium
31
+ - **Check:** crawler `org-missing`, `website-missing`. Code: root layout.
32
+ - **Pass:** one node each, in the root layout: `https://site/#organization` and `https://site/#website`. Other nodes reference them by `@id` (`publisher`, `provider`, `isPartOf`) instead of repeating them. `sameAs` lists real profiles.
33
+
34
+ ### SCHEMA-03 · Each page type carries the schema the profile assigns · medium
35
+ - **Check:** crawler `jsonld-none` and the `schema` list per page in `seo-crawl.json`, compared with the profile's schema column.
36
+
37
+ | Page type | Schema |
38
+ | --- | --- |
39
+ | Every page | Organization, WebSite (root layout) |
40
+ | Hubs, categories, browse pages | CollectionPage, ItemList (items in the order shown on the page), BreadcrumbList |
41
+ | Interactive tool | WebPage, WebApplication (`applicationCategory` from Google's list, e.g. `SecurityApplication`, `UtilitiesApplication`; `operatingSystem: "Any"`; Offer `price: "0"`), BreadcrumbList, FAQPage if visible |
42
+ | Article, guide, post | Article or BlogPosting with `author` (Person with author page), `datePublished`, `dateModified`, BreadcrumbList |
43
+ | Author page | ProfilePage, Person (`jobTitle`, `sameAs`, `knowsAbout`) |
44
+ | Service page | Service (`serviceType`, `provider` → `#organization`, `areaServed`), BreadcrumbList |
45
+ | Local business | The most specific LocalBusiness subtype with real NAP, `geo`, `openingHoursSpecification`, `sameAs` (Google profile) |
46
+ | Product | Product with Offer (merchant listing) or AggregateOffer (product snippet only), plus shipping, return policy and warranty when they apply |
47
+ | Glossary | DefinedTermSet on the glossary hub; DefinedTerm on each term page, pointing back with `inDefinedTermSet` |
48
+ | Comparison | Article, ItemList of the products compared (no ratings for anyone, yours included) |
49
+ | Path / guided sequence | WebPage, ItemList of the steps in order, each pointing to its guide, tool or template |
50
+ | Download (template, checklist) | CreativeWork or DigitalDocument with `name`, `description`, `encodingFormat`, `dateModified` |
51
+ | Sample report | WebPage, plus DigitalDocument when it's a download (client details redacted) |
52
+ | Pricing | Service or SoftwareApplication with one Offer per plan |
53
+ | Search, result and account pages | None |
54
+
55
+ CollectionPage, ItemList, DefinedTerm, CreativeWork and Service earn no Google rich result. Add them anyway: they tell Bing and AI engines what each page is. Full examples are in `examples/snippets.md`.
56
+
57
+ ### SCHEMA-04 · Schema matches what the page visibly shows · blocker
58
+ - **Check:** crawler `faq-not-visible`, `rating-review`. Code: where FAQ, breadcrumb and rating schema come from.
59
+ - **Pass:** FAQPage is built from the same array that renders the visible FAQ, and BreadcrumbList from the same array as the visible trail. Ratings and reviews appear in schema only when real reviews are shown on that page. No self-serving Organization or LocalBusiness rating. No Organization rating attached to a WebApplication. Nothing imported, scraped or AI-rewritten is presented as a verified review.
60
+ - **Fix:** remove any rating that isn't sourced; that's a decision for the owner (`needs-decision`). Never invent one. Leaving the rating out keeps the markup valid; it just shows no stars. To earn stars honestly, collect ratings on the page (e.g. "Was this useful?"), show the average and count there, and build `aggregateRating` from that data. A fake rating can cost the whole site its rich results through a manual action.
61
+
62
+ ### SCHEMA-05 · No schema kept for rich results that no longer exist · low
63
+ - **Check:** crawler `deprecated-schema`.
64
+ - **Fix:** remove HowTo and SearchAction, or keep them knowingly. Never promise these rich results.
65
+
66
+ ### SCHEMA-06 · No visitor input in schema · high
67
+ - **Check:** code: tool results, search terms or form values flowing into JSON-LD.
68
+ - **Fix:** schema describes the page, never data a visitor typed in or a scanned domain.
69
+
70
+ ### SCHEMA-07 · BreadcrumbList on every page below the home page · medium
71
+ - **Check:** crawler `breadcrumb-missing`, and URL-05.
72
+
73
+ ### SCHEMA-08 · Every template is validated · medium
74
+ - **Check:** one URL per template through Google's Rich Results Test and validator.schema.org. After launch, watch the enhancement reports in Search Console.
75
+ - Facts that must match the visible page: phone, email, address, prices, hours.
@@ -0,0 +1,25 @@
1
+ # Trust and security (TRUST)
2
+
3
+ ### TRUST-01 · HTTPS with security headers · low (high for security, finance and health sites)
4
+ - **Check:** crawler `sec-headers`, `mixed-content`. Check production too: CDNs often add or strip headers.
5
+ - **Pass:** HTTPS only. `Strict-Transport-Security`, `Content-Security-Policy` (with `frame-ancestors`), `X-Content-Type-Options: nosniff`, `Referrer-Policy`, `Permissions-Policy`. No HTTP resources on HTTPS pages.
6
+
7
+ ### TRUST-02 · /.well-known/security.txt is published · low (high for security companies)
8
+ - **Check:** crawler `security-txt`.
9
+ - **Pass:** RFC 9116 with `Contact` and `Expires` (renewed before it lapses), plus `Policy` and `Canonical`.
10
+
11
+ ### TRUST-03 · Privacy is stated wherever visitors enter data · medium
12
+ - **Check:** content: forms, tools, calculators.
13
+ - **Pass:** one line by the form says what's stored and for how long, linking to the privacy policy. Secrets (passwords, tokens, keys) are processed in the browser and never logged, put in URLs or sent to analytics.
14
+
15
+ ### TRUST-04 · Who's behind the site is clear · medium
16
+ - **Check:** content: About, Contact, author pages, methodology or "how we test" pages, editorial policy.
17
+ - **Pass:** a real organization with a contact route, named experts with credentials (CONTENT-07), and how claims and results are produced. Tool sites need a methodology page per tool family that names its standards, data sources and limits (TOOL-11).
18
+
19
+ ### TRUST-05 · No fake trust signals · blocker
20
+ - **Check:** content and schema: ratings, review counts, testimonials, "as seen in" logos, certifications, years in business, team photos.
21
+ - **Pass:** every one is real and verifiable. Imported or AI-rewritten reviews are never presented as verified (in some places, such as the UK under the DMCC Act 2024, this is illegal). Review requests go to every customer, with no gating.
22
+ - **Fix:** remove anything unsourced. Ask the owner (`needs-decision`) rather than keep it.
23
+
24
+ ### TRUST-06 · The site passes its own claims · medium
25
+ - **Check:** whatever the site sells or tests, it does well itself. A security company scores well on security headers (with HSTS on the preload list once stable) and DNS: SPF, DKIM, DMARC at `p=reject`, CAA, and DNSSEC where the DNS host supports it. A speed agency passes CWV. An accessibility firm passes WCAG basics.
@@ -0,0 +1,46 @@
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
+
8
+ ### URL-02 · One trailing-slash style, with the other variant redirecting · high
9
+ - **Check:** crawler `trailing-slash-mixed`, `slash-variant-no-redirect`, `link-to-redirect`. Code: framework config (`trailingSlash` in Next.js), link helpers, canonical and sitemap builders.
10
+ - **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`).
11
+ - **Fix:** set it once in the framework, then fix the URL builders. Don't hand-edit links.
12
+
13
+ ### URL-03 · One host, HTTPS only · high
14
+ - **Check:** code: server/CDN config. Probe `http://` and the other `www` variant against production when you're allowed to.
15
+ - **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.
16
+ - **Fix:** add the redirects at the edge (nginx, CDN or host settings).
17
+
18
+ ### URL-04 · Every indexable page has a self-referencing, absolute canonical · high
19
+ - **Check:** crawler `canonical-missing`, `canonical-multiple`, `canonical-not-self`, `canonical-query`, `canonical-origin`, `canonical-bad-target`. Code: the metadata helper.
20
+ - **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.
21
+ - **Fix:** build canonicals from the clean path plus one base-URL setting. Never build them from the request URL, which leaks `?utm_` tags.
22
+
23
+ ### URL-05 · Breadcrumbs are visible, match their schema, and every level is a real page · high
24
+ - **Check:** crawler `breadcrumb-dead-level`, `breadcrumb-missing`. Code: breadcrumb component and BreadcrumbList builder.
25
+ - **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.
26
+ - **Fix:** create the missing hub pages, and share one breadcrumb source.
27
+
28
+ ### URL-06 · Item slugs can't clash with browse pages · medium
29
+ - **Check:** code: where items and categories share a namespace (e.g. `/blog/{post}/` and `/blog/{category}/`).
30
+ - **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.
31
+ - **Fix:** add the constraint and rename any clash with a redirect.
32
+
33
+ ### URL-07 · Renames redirect automatically · medium
34
+ - **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.
35
+ - **Pass:** redirects are generated from data, go to the final URL in one hop, and every target resolves.
36
+ - **Fix:** add the field and the build check. Never change the URL of a page that already gets search impressions unless the owner agrees.
37
+
38
+ ### URL-08 · Pagination is crawlable and self-canonical · medium
39
+ - **Check:** crawler pages with `?page=` or `/page/N/`. Code: list components.
40
+ - **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.
41
+ - **Fix:** render real pagination links and per-page canonicals.
42
+
43
+ ### URL-09 · Every content item has one primary parent · medium
44
+ - **Check:** code: content model.
45
+ - **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.
46
+ - **Fix:** add a required `primaryCategory` (or similar) field.
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+ // content-scan.mjs: audits content data (JSON, CSV or a Markdown folder) before it becomes pages.
3
+ // Finds templated copy, reused FAQs, missing required fields, unpublished items, bad title/description
4
+ // lengths, placeholders and banned/unconfirmed claims. Read-only, no dependencies, Node 20+.
5
+ //
6
+ // node content-scan.mjs --in content.json [--items pages] JSON array, {type: [...]}, or {id: {...}}
7
+ // node content-scan.mjs --csv sheet.csv first row = headers
8
+ // node content-scan.mjs --md content/blog .md/.mdx files with front matter
9
+ //
10
+ // Field options (dot paths allowed, comma lists where noted):
11
+ // --id slug --url "/blog/{slug}/" --title title --desc description
12
+ // --text intro,body fields compared for near-duplicate copy (default: longest text field)
13
+ // --faq faqs array of strings or {q|question|name, a|answer}
14
+ // --publish published truthy = live (yes/true/1/live/published)
15
+ // --group service compare duplicates only within the same group
16
+ // --strip "Antioch|Concord" words removed before comparing (e.g. city names); the record's own id/title words are removed too
17
+ // --required title,localProof fields that must be non-empty
18
+ // --banned regex --verify regex --threshold 0.5 --out seo-audit/content-scan.json
19
+ //
20
+ // For content in TypeScript modules or a CMS, dump it to JSON first, e.g. the way the project runs its own scripts:
21
+ // npx tsx -e "import('./src/lib/content.ts').then(m => console.log(JSON.stringify(m.getAllPages())))" > seo-audit/content.json
22
+
23
+ import { readFileSync, readdirSync, statSync, mkdirSync, writeFileSync } from "node:fs";
24
+ import { join, dirname, resolve, extname, basename } from "node:path";
25
+
26
+ const args = {};
27
+ for (let i = 2; i < process.argv.length; i++) {
28
+ const a = process.argv[i]; if (!a.startsWith("--")) continue;
29
+ args[a.slice(2)] = process.argv[i + 1] && !process.argv[i + 1].startsWith("--") ? process.argv[++i] : true;
30
+ }
31
+ if (!args.in && !args.csv && !args.md) { console.error("Usage: node content-scan.mjs --in content.json | --csv file.csv | --md dir [--id] [--url] [--title] [--desc] [--text] [--faq] [--publish] [--group] [--strip] [--required] [--banned] [--verify] [--threshold 0.5] [--out file]"); process.exit(2); }
32
+ const list = v => typeof v === "string" ? v.split(",").map(s => s.trim()).filter(Boolean) : [];
33
+ const get = (o, path) => path.split(".").reduce((x, k) => (x == null ? undefined : x[k]), o);
34
+ const OUT = resolve(typeof args.out === "string" ? args.out : "seo-audit/content-scan.json");
35
+ const THRESH = Number(args.threshold || 0.5);
36
+ const STRIP = typeof args.strip === "string" ? new RegExp(`\\b(${args.strip})\\b`, "gi") : null;
37
+ const BANNED = typeof args.banned === "string" ? new RegExp(args.banned, "i") : null;
38
+ const VERIFY = typeof args.verify === "string" ? new RegExp(args.verify, "i") : null;
39
+ const PH = /\b[Ll]orem [Ii]psum\b|\bTODO\b|\bTBD\b|\{\{\s*[\w.]+\s*\}\}|\[(?:[A-Z][A-Z _]{2,29})\]|�|\b(?:We|You|They|It|Don|Can|Isn|Won|Doesn|Didn|That|There)\?(?:ve|re|s|t|ll|d)\b/;
40
+
41
+ // ---------- load ----------
42
+ function parseCsv(txt) {
43
+ const rows = []; let row = [], cell = "", q = false;
44
+ for (let i = 0; i < txt.length; i++) {
45
+ const c = txt[i];
46
+ if (q) { if (c === '"' && txt[i + 1] === '"') { cell += '"'; i++; } else if (c === '"') q = false; else cell += c; continue; }
47
+ if (c === '"') q = true; else if (c === ",") { row.push(cell); cell = ""; }
48
+ else if (c === "\n" || c === "\r") { if (c === "\r" && txt[i + 1] === "\n") i++; row.push(cell); rows.push(row); row = []; cell = ""; }
49
+ else cell += c;
50
+ }
51
+ if (cell || row.length) { row.push(cell); rows.push(row); }
52
+ const [head, ...body] = rows.filter(r => r.some(x => x.trim()));
53
+ return body.map(r => Object.fromEntries(head.map((h, i) => [h.trim(), (r[i] ?? "").trim()])));
54
+ }
55
+ function walk(d) { return readdirSync(d).flatMap(f => { const p = join(d, f); return statSync(p).isDirectory() ? walk(p) : [p]; }); }
56
+ function parseMd(file) {
57
+ const raw = readFileSync(file, "utf8"); const rec = { _file: file, slug: basename(file, extname(file)) };
58
+ const m = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
59
+ const fm = m ? m[1] : "", body = m ? m[2] : raw;
60
+ for (const line of fm.split(/\r?\n/)) { const k = line.match(/^([\w-]+):\s*(.*)$/); if (k) rec[k[1]] = k[2].replace(/^["']|["']$/g, ""); }
61
+ rec.body = body; return rec;
62
+ }
63
+ let records = [], source = "";
64
+ if (args.in) {
65
+ source = args.in; let data = JSON.parse(readFileSync(args.in, "utf8"));
66
+ if (typeof args.items === "string") data = get(data, args.items);
67
+ if (Array.isArray(data)) records = data;
68
+ else if (data && typeof data === "object") {
69
+ const vals = Object.entries(data);
70
+ records = vals.every(([, v]) => Array.isArray(v)) ? vals.flatMap(([k, v]) => v.map(r => ({ _type: k, ...r }))) : vals.map(([k, v]) => ({ _key: k, ...v }));
71
+ }
72
+ } else if (args.csv) { source = args.csv; records = parseCsv(readFileSync(args.csv, "utf8")); }
73
+ else { source = args.md; records = walk(args.md).filter(f => /\.mdx?$/.test(f)).map(parseMd); }
74
+ records = records.filter(r => r && typeof r === "object");
75
+
76
+ // ---------- helpers ----------
77
+ const ID = typeof args.id === "string" ? args.id : null;
78
+ const idOf = (r, i) => String((ID && get(r, ID)) ?? r.slug ?? r.id ?? r._key ?? r.title ?? `#${i + 1}`);
79
+ const urlOf = (r, i) => typeof args.url === "string" ? args.url.replace(/\{([\w.]+)\}/g, (_, k) => get(r, k) ?? "") : idOf(r, i);
80
+ const str = v => v == null ? "" : Array.isArray(v) ? v.map(str).join(" ") : typeof v === "object" ? Object.values(v).map(str).join(" ") : String(v);
81
+ const norm = s => s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
82
+ let textFields = list(args.text);
83
+ if (!textFields.length && records.length) {
84
+ const lens = {}; for (const r of records.slice(0, 50)) for (const [k, v] of Object.entries(r)) if (typeof v === "string") lens[k] = (lens[k] || 0) + v.length;
85
+ const best = Object.entries(lens).sort((a, b) => b[1] - a[1])[0]; if (best) textFields = [best[0]];
86
+ }
87
+ const own = r => [ID && get(r, ID), r.slug, r.title, r.name, r.city, r.location].filter(Boolean).map(x => norm(String(x).replace(/-/g, " "))).filter(x => x.length > 2);
88
+ function cleanText(r) {
89
+ let t = norm(textFields.map(f => str(get(r, f))).join(" "));
90
+ if (STRIP) t = t.replace(new RegExp(STRIP.source, "gi"), " ");
91
+ for (const o of own(r)) t = t.split(o).join(" ");
92
+ return t.replace(/\s+/g, " ").trim();
93
+ }
94
+ const shingles = t => { const w = t.split(" ").filter(Boolean); const s = new Set(); for (let i = 0; i + 5 <= w.length; i++) s.add(w.slice(i, i + 5).join(" ")); return s; };
95
+ const isLive = v => /^(1|true|yes|y|live|published|publish)$/i.test(String(v ?? "").trim());
96
+ function ctx(text, re) { const m = re.exec(text); if (!m) return null; const s = Math.max(0, m.index - 50), e = Math.min(text.length, m.index + m[0].length + 50); return `“${m[0]}” in: ${s ? "…" : ""}${text.slice(s, e)}${e < text.length ? "…" : ""}`; }
97
+
98
+ // ---------- checks ----------
99
+ const CHECKS = {
100
+ "templated-text": ["CONTENT-04", "high", n => `${n} pair(s) of items share most of their copy`, "Items whose text differs only by a swapped name (city, product, tool) become doorway or scaled-content pages.", "Write specific copy per item, or merge and hold the items that can't be made unique."],
101
+ "few-distinct-texts": ["CONTENT-04", "high", n => `Only ${n} distinct text(s) once names are removed`, "When hundreds of items collapse to a handful of texts after removing the swapped name, the pages are templates.", "Treat each template as one page's worth of content; add real per-item substance before publishing more."],
102
+ "faq-reused": ["CONTENT-04", "medium", n => `${n} FAQ question(s) are reused across items`, "Identical FAQs on many pages add nothing unique.", "Write questions specific to each item; keep shared questions on one FAQ page."],
103
+ "missing-field": ["CONTENT-05", "high", n => `${n} item(s) are missing required fields`, "Required fields (local proof, unique intro, author) are what make a page worth indexing.", "Fill the fields, or keep the item unpublished until they're filled."],
104
+ "unpublished": ["CRAWL-11", "needs-decision", n => `${n} item(s) are marked unpublished`, "Unpublished items must not be routable, linked or in the sitemap. Check the code actually honours this flag.", "Filter every route, static-params list, sitemap and link block by the publish flag."],
105
+ "title-length": ["META-01", "medium", n => `${n} title(s) outside 20–60 characters`, "Long titles get cut off in results; very short ones waste the spot.", "Keep titles about 30–60 characters, main keyword first."],
106
+ "title-dup": ["META-01", "high", n => `${n} title(s) shared by more than one item`, "Duplicate titles make pages compete with each other.", "Make each title specific to its item."],
107
+ "desc-length": ["META-02", "low", n => `${n} description(s) outside 120–160 characters`, "Short descriptions undersell the page; long ones get cut off.", "Aim for 120–160 characters."],
108
+ "desc-dup": ["META-02", "medium", n => `${n} description(s) shared by more than one item`, "Duplicate descriptions signal templated pages.", "Write a specific description per item."],
109
+ "placeholder": ["CONTENT-09", "high", n => `${n} item(s) contain placeholder or broken text`, "Placeholders and mangled characters look unfinished.", "Replace them with real content; keep the patterns in a build check."],
110
+ "banned": ["CONTENT-10", "high", n => `${n} item(s) contain banned text`, "Banned claims are a legal and trust risk. Matches are leads: an honest denial is fine.", "Remove or reword the claim at its source."],
111
+ "unconfirmed": ["CONTENT-10", "needs-decision", n => `${n} item(s) contain claims the owner hasn't confirmed`, "Unconfirmed claims become false advertising if they turn out wrong.", "Get each claim confirmed, or hold it."],
112
+ };
113
+ const found = new Map();
114
+ const add = (k, url, detail) => { let f = found.get(k); if (!f) found.set(k, f = { count: 0, evidence: [] }); f.count++; if (f.evidence.length < 100) f.evidence.push(detail ? { url, detail } : { url }); };
115
+ const setCount = (k, n) => { const f = found.get(k); if (f) f.count = n; };
116
+
117
+ const live = typeof args.publish === "string" ? records.filter(r => isLive(get(r, args.publish))) : records;
118
+ const stats = { records: records.length, published: typeof args.publish === "string" ? live.length : null, textFields };
119
+ if (typeof args.publish === "string") records.forEach((r, i) => { if (!isLive(get(r, args.publish))) add("unpublished", urlOf(r, i), `${args.publish} = ${JSON.stringify(get(r, args.publish) ?? null)}`); });
120
+
121
+ // near-duplicates (within group)
122
+ const items = records.map((r, i) => ({ r, i, url: urlOf(r, i), group: typeof args.group === "string" ? String(get(r, args.group) ?? "") : "", text: cleanText(r) })).filter(x => x.text.split(" ").length >= 20);
123
+ const distinct = new Set(items.map(x => x.text));
124
+ stats.compared = items.length; stats.distinctTexts = distinct.size;
125
+ if (items.length >= 10 && distinct.size <= items.length * 0.25) { add("few-distinct-texts", source, `${items.length} items → ${distinct.size} distinct text(s) in ${textFields.join(", ")}`); setCount("few-distinct-texts", distinct.size); }
126
+ const sh = items.map(x => shingles(x.text));
127
+ let pairs = 0;
128
+ for (let a = 0; a < items.length && a < 1500; a++) for (let b = a + 1; b < items.length && b < 1500; b++) {
129
+ if (items[a].group !== items[b].group) continue;
130
+ const A = sh[a], B = sh[b]; if (!A.size || !B.size) continue;
131
+ const [s1, s2] = A.size < B.size ? [A, B] : [B, A]; if (s1.size / s2.size < 0.3) continue;
132
+ let inter = 0; for (const x of s1) if (s2.has(x)) inter++;
133
+ const d = 2 * inter / (A.size + B.size);
134
+ if (d > THRESH) { pairs++; add("templated-text", items[a].url, `${Math.round(d * 100)}% shared with ${items[b].url}`); }
135
+ }
136
+ setCount("templated-text", pairs);
137
+
138
+ // FAQs
139
+ if (typeof args.faq === "string") {
140
+ const qmap = new Map();
141
+ records.forEach((r, i) => { for (const f of [].concat(get(r, args.faq) || [])) { const q = typeof f === "string" ? f : f && (f.q || f.question || f.name); if (!q) continue; let k = norm(q); if (STRIP) k = k.replace(new RegExp(STRIP.source, "gi"), " ").replace(/\s+/g, " ").trim(); (qmap.get(k) || qmap.set(k, { q, urls: [] }).get(k)).urls.push(urlOf(r, i)); } });
142
+ let reused = 0; for (const { q, urls } of qmap.values()) if (urls.length > 1) { reused++; add("faq-reused", urls[0], `“${q.slice(0, 70)}” on ${urls.length} items`); }
143
+ setCount("faq-reused", reused);
144
+ }
145
+ // required fields
146
+ const req = list(args.required);
147
+ if (req.length) records.forEach((r, i) => { const miss = req.filter(f => !str(get(r, f)).trim()); if (miss.length) add("missing-field", urlOf(r, i), `missing: ${miss.join(", ")}`); });
148
+ // titles / descriptions
149
+ for (const [field, lenKey, dupKey, lo, hi] of [[args.title, "title-length", "title-dup", 20, 60], [args.desc, "desc-length", "desc-dup", 120, 160]]) {
150
+ if (typeof field !== "string") continue;
151
+ const m = new Map();
152
+ live.forEach(r => { const i = records.indexOf(r); const v = str(get(r, field)).trim(); if (!v) return; if (v.length < lo || v.length > hi) add(lenKey, urlOf(r, i), `${v.length} chars: ${v.slice(0, 80)}`); (m.get(v) || m.set(v, []).get(v)).push(urlOf(r, i)); });
153
+ for (const [v, us] of m) if (us.length > 1) for (const u of us) add(dupKey, u, v.slice(0, 80));
154
+ }
155
+ // text patterns over every string field
156
+ records.forEach((r, i) => {
157
+ const all = str(r);
158
+ const ph = all.match(PH); if (ph) add("placeholder", urlOf(r, i), `“${ph[0]}”`);
159
+ if (BANNED) { const c = ctx(all, BANNED); if (c) add("banned", urlOf(r, i), c); }
160
+ if (VERIFY) { const c = ctx(all, VERIFY); if (c) add("unconfirmed", urlOf(r, i), c); }
161
+ });
162
+
163
+ // ---------- output ----------
164
+ const SEV = { blocker: 0, high: 1, "needs-decision": 2, medium: 3, low: 4 };
165
+ const findings = [...found].map(([k, f]) => {
166
+ const [rule, severity, title, why, fix] = CHECKS[k]; const ex = f.evidence[0] || {};
167
+ return { check: k, rule, severity, category: "Content data", title: title(f.count), what: `${f.count === 1 ? "Found in" : "For example"} ${ex.url}${ex.detail ? ` (${ex.detail})` : ""}.`, why, fix, count: f.count, evidence: f.evidence, source: "content-scan", status: severity === "needs-decision" ? "needs-decision" : "open" };
168
+ }).sort((a, b) => SEV[a.severity] - SEV[b.severity] || b.count - a.count);
169
+ findings.forEach((f, i) => { f.id = "D-" + String(i + 1).padStart(3, "0"); });
170
+ const report = { tool: "seo-supervisor-content-scan", scannedAt: new Date().toISOString(), source, options: { text: textFields, group: args.group || null, strip: args.strip || null, threshold: THRESH }, stats, findings, passed: [], notChecked: [], notes: [`Scanned ${records.length} records from ${source}; compared ${items.length} texts (${distinct.size} distinct after removing names).`] };
171
+ mkdirSync(dirname(OUT), { recursive: true });
172
+ writeFileSync(OUT, JSON.stringify(report, null, 2));
173
+ console.log(`content-scan: ${records.length} records, ${findings.length} findings ${JSON.stringify(findings.reduce((m, f) => (m[f.severity] = (m[f.severity] || 0) + 1, m), {}))} → ${OUT}`);