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.
- package/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +16 -3
- package/CHANGELOG.md +430 -0
- package/NOTICE +7 -0
- package/README.md +230 -25
- package/agents/seo-auditor.md +16 -0
- package/agents/seo-reviewer.md +16 -0
- package/bin/agents.mjs +194 -29
- package/bin/extras.mjs +422 -0
- package/bin/prompt.mjs +34 -14
- package/bin/seo-supervisor.mjs +386 -53
- package/commands/seo-audit.md +29 -3
- package/commands/seo-brief.md +28 -0
- package/commands/seo-connect.md +27 -0
- package/commands/seo-fix.md +24 -3
- package/commands/seo-grow.md +26 -0
- package/commands/seo-launch.md +17 -3
- package/commands/seo-review.md +13 -1
- package/commands/seo-rewrite.md +25 -0
- package/commands/seo-setup.md +17 -1
- package/commands/seo-watch.md +28 -0
- package/hooks/hooks.json +117 -0
- package/package.json +20 -7
- package/skills/seo-supervisor/NOTICE +7 -0
- package/skills/seo-supervisor/SKILL.md +302 -21
- package/skills/seo-supervisor/audience.md +61 -0
- package/skills/seo-supervisor/examples/drafts/security.md +41 -0
- package/skills/seo-supervisor/examples/hooks/README.md +28 -0
- package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
- package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
- package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
- package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
- package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
- package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
- package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
- package/skills/seo-supervisor/examples/sample-audit.json +94 -2
- package/skills/seo-supervisor/examples/sample-report.html +111 -61
- package/skills/seo-supervisor/examples/sample-report.md +147 -44
- package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
- package/skills/seo-supervisor/examples/snippets.md +648 -1
- package/skills/seo-supervisor/grow.md +342 -0
- package/skills/seo-supervisor/og-images.md +85 -0
- package/skills/seo-supervisor/page-types.md +124 -0
- package/skills/seo-supervisor/planning.md +19 -7
- package/skills/seo-supervisor/profile-template.md +41 -0
- package/skills/seo-supervisor/report-format.md +177 -10
- package/skills/seo-supervisor/rewrite.md +59 -0
- package/skills/seo-supervisor/rules/ai-search.md +65 -12
- package/skills/seo-supervisor/rules/content.md +33 -9
- package/skills/seo-supervisor/rules/crawl-index.md +33 -6
- package/skills/seo-supervisor/rules/internal-linking.md +49 -6
- package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
- package/skills/seo-supervisor/rules/media.md +13 -1
- package/skills/seo-supervisor/rules/metadata.md +41 -9
- package/skills/seo-supervisor/rules/performance.md +50 -5
- package/skills/seo-supervisor/rules/rendering.md +39 -2
- package/skills/seo-supervisor/rules/search-intent.md +32 -0
- package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
- package/skills/seo-supervisor/rules/structured-data.md +37 -14
- package/skills/seo-supervisor/rules/trust-security.md +25 -2
- package/skills/seo-supervisor/rules/urls.md +10 -2
- package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
- package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
- package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
- package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
- package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
- package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
- package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
- package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
- package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
- package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
- package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
- package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
- package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
- package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
- package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
- package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
- package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
- package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
- package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
- package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
- package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
- package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
- package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
- package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
- package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
- package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
- package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
- package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
- package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
- package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
- package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
- package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
- package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
- package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
- package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
- package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
- package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
- package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
- package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
- package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
- package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
- package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
- package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
- package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
- package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
- package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
- package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
- package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
- package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
- package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
- package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
- package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
- package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
- package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
- package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
- package/skills/seo-supervisor/scripts/google.mjs +1341 -0
- package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
- package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
- package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
- package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
- package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
- package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
- package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
- package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
- package/skills/seo-supervisor/scripts/guard.mjs +74 -0
- package/skills/seo-supervisor/scripts/images.mjs +408 -0
- package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
- package/skills/seo-supervisor/scripts/issues.mjs +217 -0
- package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
- package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
- package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
- package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
- package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
- package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
- package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
- package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
- package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
- package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
- package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
- package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
- package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
- package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
- package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
- package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
- package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
- package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
- package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
- package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
- package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
- package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
- package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
- package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
- package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
- package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
- package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
- package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
- package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
- package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
- package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
- package/skills/seo-supervisor/scripts/osm.mjs +359 -0
- package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
- package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
- package/skills/seo-supervisor/scripts/report/client.js +37 -0
- package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
- package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
- package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
- package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
- package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
- package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
- package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
- package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
- package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
- package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
- package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
- package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
- package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
- package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
- package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
- package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
- package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
- package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
- package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
- package/skills/seo-supervisor/scripts/report/styles.css +223 -0
- package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
- package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
- package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
- package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
- package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
- package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
- package/skills/seo-supervisor/site-types/content.md +34 -1
- package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
- package/skills/seo-supervisor/site-types/local-business.md +96 -6
- package/skills/seo-supervisor/site-types/services.md +46 -0
- package/skills/seo-supervisor/site-types/tools.md +3 -3
- package/skills/seo-supervisor/strategy.md +232 -0
- package/skills/seo-supervisor/troubleshooting.md +56 -0
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
# Trust and security (TRUST)
|
|
2
2
|
|
|
3
3
|
### TRUST-01 · HTTPS with security headers · low (high for security, finance and health sites)
|
|
4
|
-
- **Check:** crawler `sec-headers
|
|
4
|
+
- **Check:** crawler `sec-headers` (now including `Permissions-Policy`), `mixed-content`. Check production too: CDNs often add or strip headers. A `Content-Security-Policy-Report-Only` header alone counts as no CSP: the W3C CSP spec says it monitors a policy "but not enforcing" it (read 22 Nov 2026), so it blocks nothing. It's the right way to try a policy before sending it for real.
|
|
5
|
+
- **Mixed content (`mixed-content`, medium):** an https page (or, on a local crawl, a page whose public origin is https) that loads another site's files over `http://`: stylesheets, preloads and scripts in the head, and images (`srcset` too), video, audio, `<source>`, `<track>`, embeds, objects and frames. Browsers block the first kind outright (W3C Mixed Content) and upgrade or block the rest. A page or header CSP with `upgrade-insecure-requests` passes, and a local build's own files don't count.
|
|
5
6
|
- **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.
|
|
7
|
+
- **Live check:** `--check-live` reads HSTS from the production origin itself (`no-hsts`), since a CDN often adds or strips it.
|
|
8
|
+
- **Old TLS:** `--check-live` also tries a TLS 1.0 and a TLS 1.1 handshake with the production origin (`tls-old-versions`, low). RFC 8996 (2021) says neither may be used; turn both off at the server or CDN and keep TLS 1.2 and 1.3. A handshake that fails or times out counts as refused.
|
|
9
|
+
- **Secret keys (`secret-key-exposed`, high):** a page's HTML (inline scripts, attributes, comments), or a script file on the site's own origin that a page loads (`<script src>`, each file read once; never other hosts, and never source maps), holds a key whose provider documents it as secret: Stripe live secret or restricted keys (`sk_live_`, `rk_live_`), GitHub tokens (`ghp_`, `github_pat_`, `gho_`, `ghu_`, `ghs_`, `ghr_`), Slack tokens (`xoxb-`, `xoxp-`, `xapp-`, `xwfp-`) or a private-key block. Browser keys (Google `AIza…`, Firebase web config, Stripe `pk_live_`) and Stripe test keys aren't flagged. Script files are read up to our own limits (50 files, 5 MB each, 50 MB in all); a note says how many weren't read. The evidence shows only the key's type and first characters. Fix: revoke the key with its provider first, then keep the new one on the server.
|
|
10
|
+
- **Crawler, each low:**
|
|
11
|
+
- `cookie-flags`: a cookie in a `Set-Cookie` header on an HTML page without `HttpOnly` or `SameSite`, or without `Secure` on an HTTPS crawl (local dev servers leave it off). Cookies that scripts set (analytics, consent banners) aren't seen, a CSRF-token cookie may skip `HttpOnly` because a script must read it, and cookies being deleted are skipped.
|
|
12
|
+
- `hsts-short`: the home page's HSTS `max-age` is under 31536000 (a year: this skill's own line, the preload list's minimum). hstspreload.org advises raising `max-age` in stages (5 minutes, a week, a month), checking for broken pages at each one.
|
|
13
|
+
- `referrer-unsafe`: `Referrer-Policy: unsafe-url` in the header (the last valid value counts) or in `<meta name="referrer">`. The W3C spec calls it unsafe: it leaks full addresses from HTTPS pages to insecure sites.
|
|
14
|
+
- `csp-weak`: the home page's `Content-Security-Policy` lets scripts run inline (`'unsafe-inline'` with no nonce or hash) or through `'unsafe-eval'`, lets them load from any site (`*`, `http:`, `https:`, `data:` without `'strict-dynamic'`), has no `script-src`/`default-src` or `object-src`/`default-src`, or has a nonce policy with no `base-uri`. These are the gaps Google's CSP Evaluator reports; the strict form web.dev recommends is `script-src 'nonce-…' 'strict-dynamic'; object-src 'none'; base-uri 'none'`. Several policies all apply, so a gap counts only when every policy has it.
|
|
15
|
+
- `hsts-invalid`: the first HSTS header (the only one browsers read) repeats a directive, has no `max-age` or a `max-age` that isn't whole seconds, or breaks the syntax. RFC 6797 says browsers then ignore the whole header, so the site has no HSTS.
|
|
16
|
+
- `hsts-no-subdomains`: a valid HSTS header without `includeSubDomains`. Check that every subdomain works over HTTPS before adding it.
|
|
17
|
+
- **HSTS preload (information):** the report says whether the home page's header meets the preload list's header rules (hstspreload.org: `max-age` of at least 31536000, `includeSubDomains`, `preload`) and what it lacks. The list also needs the header on the bare domain, http:// sent to https:// on the same host first, and every subdomain on HTTPS. Joining is optional and slow to undo, and hstspreload.org itself says "While HSTS is recommended, HSTS preloading is not recommended" and that preloading should be opt-in (read 22 Nov 2026). So it never changes the score, and the skill never tells the owner to add `preload` or join the list; only an owner who asks gets the list's rules.
|
|
18
|
+
- **Server version (`server-known-holes`, needs-decision):** a `Server` header naming an Apache httpd or nginx version that the maker's own advisory lists with a hole at its top rating (Apache "critical": 2.4.49 and 2.4.50, CVE-2021-41773 and CVE-2021-42013; 2.4.55 to 2.4.70, CVE-2026-119618 in mod_http2. nginx "major": 1.9.5 to 1.31.8, CVE-2026-123007 in HTTP/2; fixed in mainline 1.31.9 and stable 1.30.7, so 1.30.7 to 1.30.x is safe while 1.31.0 to 1.31.8 is not). A distribution's build (`Apache/2.4.62 (Ubuntu)`) is skipped, as distributions patch without changing the version, and so is a header without a version. Ask the owner whether it's patched. The list was checked on 2026-11-21 and is due for a re-check by 2027-05-21 (`checks/technical.mjs`).
|
|
19
|
+
- **The audit's own safety:** headless Chrome (renders, phone and desktop loads) and Lighthouse can't reach private or cloud-metadata addresses (169.254.169.254, `metadata.google.internal`, 10.x, 192.168.x, other loopback addresses): a name counts by every address it resolves to, and only the site's own addresses stay open. Renders and Lighthouse go through a local guard proxy; phone and desktop loads check each request and run without service workers. With the owner's own proxy set (`HTTPS_PROXY`), Chrome goes through that instead and a note says the guard is off. Home folders, email addresses and tokens are masked in error messages, and secret query values (`token`, `key`, `password`, `signature`, `credential`…) in reported URLs.
|
|
6
20
|
|
|
7
21
|
### TRUST-02 · /.well-known/security.txt is published · low (high for security companies)
|
|
8
22
|
- **Check:** crawler `security-txt`.
|
|
@@ -15,11 +29,20 @@
|
|
|
15
29
|
### TRUST-04 · Who's behind the site is clear · medium
|
|
16
30
|
- **Check:** content: About, Contact, author pages, methodology or "how we test" pages, editorial policy.
|
|
17
31
|
- **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).
|
|
32
|
+
- **Trust view:** the crawler's About, contact, Organization schema and policy signals show in the Overview's "Trust signals (E-E-A-T)" view with what to add; they're suggestions that never change the score, and this rule is still judged from the content.
|
|
18
33
|
|
|
19
34
|
### TRUST-05 · No fake trust signals · blocker
|
|
20
35
|
- **Check:** content and schema: ratings, review counts, testimonials, "as seen in" logos, certifications, years in business, team photos.
|
|
21
36
|
- **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.
|
|
37
|
+
- **US law:** the FTC's Consumer Reviews and Testimonials Rule (16 CFR Part 465), in force since 21 October 2024, bans fake and AI-written reviews, bought reviews, reviews by the business's own people that don't say so, and hiding bad reviews. The FTC can seek civil penalties of up to $53,088 per violation (ftc.gov).
|
|
22
38
|
- **Fix:** remove anything unsourced. Ask the owner (`needs-decision`) rather than keep it.
|
|
23
39
|
|
|
24
40
|
### 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
|
|
41
|
+
- **Check:** whatever the site sells or tests, it does well itself. A security company scores well on security headers (HSTS with a long `max-age` and `includeSubDomains`; the preload list is optional, and hstspreload.org doesn't recommend it) 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.
|
|
42
|
+
|
|
43
|
+
### TRUST-07 · The HTTPS certificate is trusted, covers every host and renews in time · blocker
|
|
44
|
+
- **Check:** `--check-live` on the production origin: trust, both the apex and www host (when the other host answers), and time left.
|
|
45
|
+
- **Pass:** trusted; covers every host that answers; and not yet near expiry: more time left than a third of its lifetime or 30 days, whichever is sooner. A healthy 6-day certificate with 4 days left passes.
|
|
46
|
+
- **Severity:** blocker when untrusted, missing a host, expired or under 2 days left; high when less time is left than a third of its lifetime or 30 days, whichever is sooner (30 days when the lifetime can't be read). The threshold scales because certificates are getting shorter: CA/Browser Forum limits fall to 200 days from March 2026 and 47 days by 2029, and some CAs issue 6-day certificates. A healthy short certificate isn't flagged.
|
|
47
|
+
- **Fix:** automatic renewal at the host or CDN, issued for both hosts.
|
|
48
|
+
- **Connection:** with `--check-live`, an HTTPS connection that fails is high. `https-unreachable`: the server refused the connection, dropped it or timed out. `https-missing`: no HTTPS at all, because port 443 doesn't speak TLS for the host name, or plain `http://` serves the site while `https://` doesn't connect. A production host that doesn't resolve in DNS is a note, and TRUST-07 and URL-03 stay under Limits.
|
|
@@ -4,21 +4,27 @@
|
|
|
4
4
|
- **Check:** crawler `url-format`. Code: route folders, slug generation.
|
|
5
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
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.
|
|
7
8
|
|
|
8
9
|
### 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
|
+
- **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.
|
|
10
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`).
|
|
11
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.
|
|
12
14
|
|
|
13
15
|
### URL-03 · One host, HTTPS only · high
|
|
14
16
|
- **Check:** code: server/CDN config. Probe `http://` and the other `www` variant against production when you're allowed to.
|
|
15
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.
|
|
16
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.
|
|
17
20
|
|
|
18
21
|
### 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.
|
|
22
|
+
- **Check:** crawler `canonical-missing`, `canonical-multiple`, `canonical-not-self`, `canonical-query`, `canonical-origin`, `canonical-bad-target`, `canonical-relative`. Code: the metadata helper.
|
|
20
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".
|
|
21
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.
|
|
22
28
|
|
|
23
29
|
### URL-05 · Breadcrumbs are visible, match their schema, and every level is a real page · high
|
|
24
30
|
- **Check:** crawler `breadcrumb-dead-level`, `breadcrumb-missing`. Code: breadcrumb component and BreadcrumbList builder.
|
|
@@ -34,6 +40,8 @@
|
|
|
34
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.
|
|
35
41
|
- **Pass:** redirects are generated from data, go to the final URL in one hop, and every target resolves.
|
|
36
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.
|
|
37
45
|
|
|
38
46
|
### URL-08 · Pagination is crawlable and self-canonical · medium
|
|
39
47
|
- **Check:** crawler pages with `?page=` or `/page/N/`. Code: list components.
|
|
@@ -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
|
+
}
|