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
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Bing Webmaster Tools: the key's entry, the read (clicks, impressions, links, crawl issues) and URL submission. The
|
|
3
|
+
// crawl-issues finding is connect-keys.mjs's crawlFinding.
|
|
4
|
+
import { Refused, setLine, PASTE, request, POST, chunks, bare, hostOf, day } from "./http.mjs";
|
|
5
|
+
|
|
6
|
+
export const bing = {
|
|
7
|
+
name: "Bing Webmaster Tools",
|
|
8
|
+
env: "BING_WEBMASTER_KEY",
|
|
9
|
+
endpointEnv: "BING_WEBMASTER_ENDPOINT",
|
|
10
|
+
endpoint: "https://ssl.bing.com/webmaster/api.svc/json",
|
|
11
|
+
adds: "Bing clicks and impressions by page and query, the pages other sites link to, and problems Bing hit crawling the site",
|
|
12
|
+
where: "bing.com/webmasters → Settings → API Access",
|
|
13
|
+
guide: [
|
|
14
|
+
"Bing Webmaster Tools (free) adds Bing clicks and impressions by page and query, the pages other sites link to, and the problems Bing hit while crawling your site.",
|
|
15
|
+
"1. Sign in at https://www.bing.com/webmasters with a Microsoft, Google or Facebook account.",
|
|
16
|
+
'2. Add your site and verify it. If the site is already in Google Search Console, choose "Import from Google Search Console": it\'s the quickest way.',
|
|
17
|
+
"3. Open Settings → API Access (Settings is at the top right). Read and accept the terms, then click Generate API Key.",
|
|
18
|
+
`4. Copy the key, then in your own terminal run: ${setLine("bing")}`,
|
|
19
|
+
PASTE,
|
|
20
|
+
"One key covers every site verified in your account. Keep it private: anyone who has it can read and change your Bing Webmaster Tools settings.",
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
const MAX_LINK_PAGES = 10;
|
|
24
|
+
|
|
25
|
+
// ---------- Bing Webmaster Tools ----------
|
|
26
|
+
// CrawlIssues is a flags enum; JSON sends the number, XML the names, so both are read.
|
|
27
|
+
/** @type {[string, number, string][]} */
|
|
28
|
+
const ISSUES = [
|
|
29
|
+
["Code301", 1, "permanent redirect (301)"],
|
|
30
|
+
["Code302", 2, "temporary redirect (302)"],
|
|
31
|
+
["Code4xx", 4, "client error (4xx)"],
|
|
32
|
+
["Code5xx", 8, "server error (5xx)"],
|
|
33
|
+
["BlockedByRobotsTxt", 16, "blocked by robots.txt"],
|
|
34
|
+
["ContainsMalware", 32, "contains malware"],
|
|
35
|
+
["ImportantUrlBlockedByRobotsTxt", 64, "important page blocked by robots.txt"],
|
|
36
|
+
["DnsErrors", 128, "DNS error"],
|
|
37
|
+
["TimeOutErrors", 256, "timed out"],
|
|
38
|
+
];
|
|
39
|
+
const issueBits = v =>
|
|
40
|
+
typeof v === "number"
|
|
41
|
+
? v
|
|
42
|
+
: String(v ?? "")
|
|
43
|
+
.split(/[\s,]+/)
|
|
44
|
+
.reduce((n, s) => n | (ISSUES.find(i => i[0] === s)?.[1] || 0), 0);
|
|
45
|
+
|
|
46
|
+
// Bing takes the key only as ?apikey= (or OAuth). It's never printed, and request()'s errors name the host, not the
|
|
47
|
+
// URL.
|
|
48
|
+
const bingGet =
|
|
49
|
+
(key, base) =>
|
|
50
|
+
(method, params = {}) =>
|
|
51
|
+
request("bing", bing, `${base}/${method}?${new URLSearchParams({ ...params, apikey: key })}`).then(b => b?.d);
|
|
52
|
+
// Bing's own URL for the site (its www and https), which every other Bing call takes as siteUrl.
|
|
53
|
+
async function bingSite(get, site) {
|
|
54
|
+
const want = new URL(site).hostname;
|
|
55
|
+
const sites = (await get("GetUserSites")) || [];
|
|
56
|
+
const match = sites.find(s => hostOf(s.Url) === want) || sites.find(s => bare(hostOf(s.Url)) === bare(want));
|
|
57
|
+
if (!match)
|
|
58
|
+
throw new Refused(
|
|
59
|
+
`Bing Webmaster Tools: ${want} isn't in your Bing Webmaster Tools account. Add and verify it at bing.com/webmasters (it can import your sites from Google Search Console), then run again.`,
|
|
60
|
+
);
|
|
61
|
+
if (match.IsVerified === false)
|
|
62
|
+
throw new Refused(
|
|
63
|
+
`Bing Webmaster Tools: ${want} is in your account but isn't verified yet. Finish verifying it at bing.com/webmasters, then run again.`,
|
|
64
|
+
);
|
|
65
|
+
return match.Url;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const linksOf = d => (d?.Details || []).map(l => ({ url: l.Url, anchorText: l.AnchorText }));
|
|
69
|
+
const MAX_CHOSEN = 20;
|
|
70
|
+
// pages: extra pages to read links for; sister: another site in the same Bing account to compare with.
|
|
71
|
+
export async function fetchBing(key, site, base, notes, { pages: chosen = [], sister = null } = {}) {
|
|
72
|
+
const get = bingGet(key, base),
|
|
73
|
+
want = new URL(site).hostname,
|
|
74
|
+
siteUrl = await bingSite(get, site);
|
|
75
|
+
|
|
76
|
+
const add = (map, k, r) => {
|
|
77
|
+
if (k == null) return;
|
|
78
|
+
const t = map.get(k) || { clicks: 0, impressions: 0 };
|
|
79
|
+
t.clicks += r.Clicks || 0;
|
|
80
|
+
t.impressions += r.Impressions || 0;
|
|
81
|
+
map.set(k, t);
|
|
82
|
+
};
|
|
83
|
+
const queryRows = (await get("GetQueryStats", { siteUrl })) || [],
|
|
84
|
+
q = new Map();
|
|
85
|
+
for (const r of queryRows) add(q, r.Query, r);
|
|
86
|
+
const queries = [...q].map(([query, t]) => ({ query, ...t })).sort((a, b) => b.impressions - a.impressions);
|
|
87
|
+
// GetPageStats has the page's URL in Query. http/https and www/apex variants of one page add up, as in gsc-import.
|
|
88
|
+
const pathOf = u => {
|
|
89
|
+
try {
|
|
90
|
+
const x = new URL(u);
|
|
91
|
+
return bare(x.hostname) === bare(want) ? x.pathname + x.search : null;
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const pageRows = (await get("GetPageStats", { siteUrl })) || [],
|
|
97
|
+
p = new Map();
|
|
98
|
+
for (const r of pageRows) add(p, pathOf(r.Query), r);
|
|
99
|
+
const dates = [...queryRows, ...pageRows]
|
|
100
|
+
.map(r => Number(/\/Date\((-?\d+)/.exec(r.Date || "")?.[1]))
|
|
101
|
+
.filter(Number.isFinite);
|
|
102
|
+
|
|
103
|
+
const pages = [];
|
|
104
|
+
let total = 1;
|
|
105
|
+
for (let page = 0; page < Math.min(total, MAX_LINK_PAGES); page++) {
|
|
106
|
+
const d = await get("GetLinkCounts", { siteUrl, page });
|
|
107
|
+
pages.push(...(d?.Links || []).map(l => ({ url: l.Url, count: l.Count })));
|
|
108
|
+
total = d?.TotalPages || 0;
|
|
109
|
+
}
|
|
110
|
+
if (total > MAX_LINK_PAGES)
|
|
111
|
+
notes.push(`Bing lists inbound links in ${total} pages of results; only the first ${MAX_LINK_PAGES} were read.`);
|
|
112
|
+
const sample = linksOf(await get("GetUrlLinks", { siteUrl, link: new URL("/", siteUrl).href, page: 0 }));
|
|
113
|
+
|
|
114
|
+
// GetUrlLinks takes any page of the site; only the first page of results is read for each chosen one.
|
|
115
|
+
// https://learn.microsoft.com/dotnet/api/microsoft.bing.webmaster.api.interfaces.iwebmasterapi.geturllinks
|
|
116
|
+
let byPage = null;
|
|
117
|
+
if (chosen.length) {
|
|
118
|
+
byPage = {};
|
|
119
|
+
const own = new Set(),
|
|
120
|
+
off = [];
|
|
121
|
+
for (const p of chosen) {
|
|
122
|
+
let u;
|
|
123
|
+
try {
|
|
124
|
+
u = new URL(p, siteUrl);
|
|
125
|
+
} catch {}
|
|
126
|
+
if (u && bare(u.hostname) === bare(want)) own.add(u.pathname + u.search);
|
|
127
|
+
else off.push(p);
|
|
128
|
+
}
|
|
129
|
+
if (off.length)
|
|
130
|
+
notes.push(
|
|
131
|
+
`Bing links: left out ${off.length} chosen page(s) that aren't on ${want}: ${off.slice(0, 5).join(", ")}.`,
|
|
132
|
+
);
|
|
133
|
+
if (own.size > MAX_CHOSEN) notes.push(`Bing links: read the first ${MAX_CHOSEN} of ${own.size} chosen pages.`);
|
|
134
|
+
for (const path of [...own].slice(0, MAX_CHOSEN)) {
|
|
135
|
+
try {
|
|
136
|
+
byPage[path] = linksOf(await get("GetUrlLinks", { siteUrl, link: new URL(path, siteUrl).href, page: 0 }));
|
|
137
|
+
} catch (e) {
|
|
138
|
+
if (!(e instanceof Refused)) throw e;
|
|
139
|
+
notes.push(`Bing didn't give the links to ${path}: ${e.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The sites that link to a sister site but not to this one: the linking pages of each site's 5 most-linked pages
|
|
145
|
+
// (the first page of results each), so it's a sample, not every link.
|
|
146
|
+
let sisterOut = null;
|
|
147
|
+
if (sister) {
|
|
148
|
+
try {
|
|
149
|
+
const sisterUrl = await bingSite(get, sister),
|
|
150
|
+
skip = new Set([bare(want), bare(hostOf(sisterUrl))]);
|
|
151
|
+
const hostsOf = async (url, list) => {
|
|
152
|
+
const hosts = new Set();
|
|
153
|
+
for (const p of list.slice(0, 5))
|
|
154
|
+
for (const l of linksOf(await get("GetUrlLinks", { siteUrl: url, link: p.url, page: 0 }))) {
|
|
155
|
+
const h = bare(hostOf(l.url));
|
|
156
|
+
if (h && !skip.has(h)) hosts.add(h);
|
|
157
|
+
}
|
|
158
|
+
return hosts;
|
|
159
|
+
};
|
|
160
|
+
const theirPages = ((await get("GetLinkCounts", { siteUrl: sisterUrl, page: 0 }))?.Links || [])
|
|
161
|
+
.map(l => ({ url: l.Url, count: l.Count }))
|
|
162
|
+
.sort((a, b) => b.count - a.count);
|
|
163
|
+
const ours = await hostsOf(
|
|
164
|
+
siteUrl,
|
|
165
|
+
[...pages].sort((a, b) => b.count - a.count),
|
|
166
|
+
),
|
|
167
|
+
theirs = [...(await hostsOf(sisterUrl, theirPages))];
|
|
168
|
+
sisterOut = {
|
|
169
|
+
site: sisterUrl,
|
|
170
|
+
onlySister: theirs.filter(h => !ours.has(h)).slice(0, 50),
|
|
171
|
+
shared: theirs.filter(h => ours.has(h)).length,
|
|
172
|
+
};
|
|
173
|
+
} catch (e) {
|
|
174
|
+
if (!(e instanceof Refused)) throw e;
|
|
175
|
+
notes.push(`Bing: the sister site wasn't compared. ${e.message}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let crawlIssues = null;
|
|
180
|
+
try {
|
|
181
|
+
crawlIssues = ((await get("GetCrawlIssues", { siteUrl })) || []).map(r => {
|
|
182
|
+
const bits = issueBits(r.Issues);
|
|
183
|
+
return {
|
|
184
|
+
url: r.Url,
|
|
185
|
+
httpCode: r.HttpCode ?? null,
|
|
186
|
+
issues: ISSUES.filter(i => bits & i[1]).map(i => i[2]),
|
|
187
|
+
inLinks: r.InLinks ?? null,
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
} catch (e) {
|
|
191
|
+
if (!(e instanceof Refused)) throw e;
|
|
192
|
+
notes.push(`Bing didn't give crawl issues, so they weren't checked: ${e.message}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
siteUrl,
|
|
197
|
+
period: dates.length ? { from: day(Math.min(...dates)), to: day(Math.max(...dates)) } : null,
|
|
198
|
+
traffic: Object.fromEntries(p),
|
|
199
|
+
queries,
|
|
200
|
+
backlinks: { pages: pages.sort((a, b) => b.count - a.count), sample, ...(byPage && { byPage }) },
|
|
201
|
+
crawlIssues,
|
|
202
|
+
...(sister && { sister: sisterOut }),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ---------- Bing URL submission: a write to Bing, so the CLI runs it only with --yes ----------
|
|
207
|
+
// SubmitUrlBatch takes at most 500 URLs a batch, within what GetUrlSubmissionQuota reports. The quota differs per site,
|
|
208
|
+
// so it's read each time, never assumed. Returns { siteUrl, quota, sent, notSent, error }.
|
|
209
|
+
// https://learn.microsoft.com/dotnet/api/microsoft.bing.webmaster.api.interfaces.iwebmasterapi.submiturlbatch
|
|
210
|
+
export const BATCH = 500;
|
|
211
|
+
export async function submitBing({ key, site, urls, endpoint }) {
|
|
212
|
+
const get = bingGet(key, endpoint),
|
|
213
|
+
siteUrl = await bingSite(get, site);
|
|
214
|
+
const q = await get("GetUrlSubmissionQuota", { siteUrl }),
|
|
215
|
+
left = v => (v == null || !(Number(v) >= 0) ? null : Math.floor(Number(v)));
|
|
216
|
+
const quota = { daily: left(q?.DailyQuota), monthly: left(q?.MonthlyQuota) };
|
|
217
|
+
if (quota.daily == null)
|
|
218
|
+
throw new Refused(
|
|
219
|
+
"Bing Webmaster Tools didn't say how many URLs it takes today (GetUrlSubmissionQuota), so nothing was sent. Try again later.",
|
|
220
|
+
);
|
|
221
|
+
const fits = urls.slice(0, Math.min(quota.daily, quota.monthly ?? quota.daily));
|
|
222
|
+
let sent = 0,
|
|
223
|
+
error = null;
|
|
224
|
+
for (const urlList of chunks(fits, BATCH)) {
|
|
225
|
+
try {
|
|
226
|
+
await request("bing", bing, `${endpoint}/SubmitUrlBatch?${new URLSearchParams({ apikey: key })}`, {
|
|
227
|
+
...POST,
|
|
228
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
229
|
+
body: JSON.stringify({ siteUrl, urlList }),
|
|
230
|
+
});
|
|
231
|
+
} catch (e) {
|
|
232
|
+
if (!(e instanceof Refused)) throw e;
|
|
233
|
+
error = e.message;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
sent += urlList.length;
|
|
237
|
+
}
|
|
238
|
+
return { siteUrl, quota, sent, notSent: urls.slice(sent), error };
|
|
239
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Microsoft Clarity: the token's entry and what visitors did on each page.
|
|
3
|
+
import { Refused, setLine, PASTE, request, bare, hostOf, day, num } from "./http.mjs";
|
|
4
|
+
|
|
5
|
+
// Offered only when the site uses Clarity, like Matomo and PostHog, so it's never listed under Limits when unset.
|
|
6
|
+
// https://learn.microsoft.com/clarity/setup-and-installation/clarity-data-export-api
|
|
7
|
+
export const clarity = {
|
|
8
|
+
name: "Microsoft Clarity",
|
|
9
|
+
env: "CLARITY_API_TOKEN",
|
|
10
|
+
endpointEnv: "CLARITY_ENDPOINT",
|
|
11
|
+
endpoint: "https://www.clarity.ms/export-data/api/v1/project-live-insights",
|
|
12
|
+
optional: true,
|
|
13
|
+
adds: "what real visitors did on each page in the last 3 days: sessions, scroll depth, quick backs, rage clicks and dead clicks, from your Clarity",
|
|
14
|
+
where: "clarity.microsoft.com → your project → Settings → Data Export",
|
|
15
|
+
guide: [
|
|
16
|
+
"Microsoft Clarity (free) adds what real visitors did on each page in the last 3 days, from your own Clarity: sessions, how far down they scrolled on average, and the share of sessions with quick backs (landing and going straight back), rage clicks (clicking the same spot again and again) and dead clicks (clicks that do nothing).",
|
|
17
|
+
"Clarity's export covers only the last 1 to 3 days, so these are a recent snapshot, not a trend. The heat maps and recordings stay in Clarity's own dashboard.",
|
|
18
|
+
"1. Sign in at https://clarity.microsoft.com and open this site's project. Only a project admin can make a token.",
|
|
19
|
+
"2. Open Settings → Data Export → Generate new API token. Name it SEO-Supervisor (4 to 32 letters, digits, hyphens, underscores or periods, no spaces).",
|
|
20
|
+
"3. Copy the token straight away: Clarity shows it only once. It's long, with two dots in it. It isn't the short project ID in Clarity's tracking code, which can't read data.",
|
|
21
|
+
`4. In your own terminal run: ${setLine("clarity")}`,
|
|
22
|
+
PASTE,
|
|
23
|
+
"Clarity allows 10 requests a day per project, and each fetch uses one. A token reads one project, so for several sites use a client folder each (SEO_SUPERVISOR_CLIENT=<name>). If someone with access leaves the project, Microsoft asks you to replace the token.",
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// ---------- Microsoft Clarity: what visitors did on each page ----------
|
|
28
|
+
// The token names the project, so nothing about the site is sent and its pages are matched here. The answer is a list
|
|
29
|
+
// of { metricName, information: [rows] }, at most 1,000 rows over the last 72 hours. Only Traffic's fields are
|
|
30
|
+
// documented; the other metric names come from Microsoft's Clarity MCP server 1.0.5. Undocumented fields are read only
|
|
31
|
+
// when present, a missing one is named in a note, never guessed, and names match ignoring case and spaces.
|
|
32
|
+
export const CLARITY_DAYS = 3;
|
|
33
|
+
const CLARITY_ROWS = 1000,
|
|
34
|
+
PCT = "sessionsWithMetricPercentage";
|
|
35
|
+
/** @type {Record<string, [string, string, string]>} metricName → [output field, Clarity's field, plain name] */
|
|
36
|
+
const CLARITY_METRICS = {
|
|
37
|
+
scrolldepth: ["scrollDepth", "averageScrollDepth", "average scroll depth"],
|
|
38
|
+
quickbackclick: ["quickBacks", PCT, "quick backs"],
|
|
39
|
+
rageclickcount: ["rageClicks", PCT, "rage clicks"],
|
|
40
|
+
deadclickcount: ["deadClicks", PCT, "dead clicks"],
|
|
41
|
+
excessivescroll: ["excessiveScroll", PCT, "excessive scrolling"],
|
|
42
|
+
};
|
|
43
|
+
const squash = s =>
|
|
44
|
+
String(s ?? "")
|
|
45
|
+
.replace(/\s+/g, "")
|
|
46
|
+
.toLowerCase();
|
|
47
|
+
const fieldOf = (row, name) => Object.keys(row).find(k => k.toLowerCase() === name.toLowerCase());
|
|
48
|
+
export async function fetchClarity(key, base, site, notes) {
|
|
49
|
+
const body = await request(
|
|
50
|
+
"clarity",
|
|
51
|
+
clarity,
|
|
52
|
+
`${base}?${new URLSearchParams({ numOfDays: String(CLARITY_DAYS), dimension1: "URL" })}`,
|
|
53
|
+
{ headers: { authorization: `Bearer ${key}` }, redirect: "manual" },
|
|
54
|
+
); // the token never follows a redirect
|
|
55
|
+
const rowsOf = m => (Array.isArray(m?.information) ? m.information.filter(r => r && typeof r === "object") : []);
|
|
56
|
+
const metric = name => (Array.isArray(body) ? body.find(m => squash(m?.metricName) === name) : null),
|
|
57
|
+
traffic = metric("traffic");
|
|
58
|
+
if (!traffic || !Array.isArray(traffic.information))
|
|
59
|
+
throw new Refused(
|
|
60
|
+
"Microsoft Clarity's answer isn't the list of metrics by page it used to be (it has no Traffic), so nothing was read. Clarity may have changed its export.",
|
|
61
|
+
);
|
|
62
|
+
// A row's page: its URL on this site (www or not, http or https), by path; tracking parameters and the like add up.
|
|
63
|
+
const want = bare(new URL(site).hostname),
|
|
64
|
+
urlOf = r => {
|
|
65
|
+
const k = fieldOf(r, "url");
|
|
66
|
+
return k && typeof r[k] === "string" && r[k] ? r[k] : null;
|
|
67
|
+
};
|
|
68
|
+
const pathOf = u => {
|
|
69
|
+
try {
|
|
70
|
+
const x = new URL(u, site);
|
|
71
|
+
return bare(x.hostname) === want ? x.pathname : null;
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const pages = {},
|
|
77
|
+
weight = new Map(),
|
|
78
|
+
others = new Set();
|
|
79
|
+
for (const r of rowsOf(traffic)) {
|
|
80
|
+
const u = urlOf(r),
|
|
81
|
+
p = u && pathOf(u),
|
|
82
|
+
n = Number(r[fieldOf(r, "totalSessionCount") ?? ""]);
|
|
83
|
+
if (!u || !(n > 0)) continue;
|
|
84
|
+
if (!p) {
|
|
85
|
+
others.add(bare(hostOf(u)) || u);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
weight.set(u, n);
|
|
89
|
+
const t = (pages[p] ||= { sessions: 0, botSessions: 0 });
|
|
90
|
+
t.sessions += n;
|
|
91
|
+
t.botSessions += Number(r[fieldOf(r, "totalBotSessionCount") ?? ""]) || 0;
|
|
92
|
+
}
|
|
93
|
+
// Averages and shares, weighted by each URL's sessions, for the pages Traffic has.
|
|
94
|
+
const unread = []; // "dead clicks without sessionsWithMetricPercentage (it sent …)"
|
|
95
|
+
for (const [name, [field, theirs, plain]] of Object.entries(CLARITY_METRICS)) {
|
|
96
|
+
const rows = rowsOf(metric(name)),
|
|
97
|
+
sums = {};
|
|
98
|
+
if (!rows.length) continue;
|
|
99
|
+
if (!rows.some(r => fieldOf(r, theirs))) {
|
|
100
|
+
unread.push(
|
|
101
|
+
`${plain} without ${theirs} (it sent ${
|
|
102
|
+
[...new Set(rows.flatMap(Object.keys))]
|
|
103
|
+
.filter(k => k.toLowerCase() !== "url")
|
|
104
|
+
.slice(0, 5)
|
|
105
|
+
.join(", ") || "no fields"
|
|
106
|
+
})`,
|
|
107
|
+
);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
for (const r of rows) {
|
|
111
|
+
const u = urlOf(r),
|
|
112
|
+
p = u && pathOf(u),
|
|
113
|
+
v = Number(r[fieldOf(r, theirs) ?? ""]);
|
|
114
|
+
if (!p || !pages[p] || !(v >= 0 && v <= 100)) continue;
|
|
115
|
+
const w = weight.get(u) || 1,
|
|
116
|
+
s = (sums[p] ||= [0, 0]);
|
|
117
|
+
s[0] += v * w;
|
|
118
|
+
s[1] += w;
|
|
119
|
+
}
|
|
120
|
+
for (const [p, [sum, w]] of Object.entries(sums)) pages[p][field] = Math.round((10 * sum) / w) / 10;
|
|
121
|
+
}
|
|
122
|
+
if (unread.length)
|
|
123
|
+
notes.push(
|
|
124
|
+
`Microsoft Clarity sent ${unread.join("; ")}, the field this version reads, so ${unread.length === 1 ? "that's" : "those are"} left out. Clarity may have changed its export.`,
|
|
125
|
+
);
|
|
126
|
+
if (rowsOf(traffic).length >= CLARITY_ROWS)
|
|
127
|
+
notes.push(
|
|
128
|
+
`Microsoft Clarity sends at most ${num(CLARITY_ROWS)} rows and can't page through more, so pages with fewer sessions may be missing.`,
|
|
129
|
+
);
|
|
130
|
+
if (!Object.keys(pages).length)
|
|
131
|
+
notes.push(
|
|
132
|
+
others.size
|
|
133
|
+
? `Microsoft Clarity has sessions only on other sites (${[...others].slice(0, 3).join(", ")}), none on ${want}: check that the token is for this site's Clarity project.`
|
|
134
|
+
: `Microsoft Clarity recorded no sessions in the last ${CLARITY_DAYS} days. Check that Clarity's code is on the site and that the token is for this site's project.`,
|
|
135
|
+
);
|
|
136
|
+
return { days: CLARITY_DAYS, read: day(Date.now()), traffic: pages };
|
|
137
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The DataForSEO API login for keyword-data.mjs, and its status codes as messages.
|
|
3
|
+
import { setLine, fail, DFS_AUTH } from "./http.mjs";
|
|
4
|
+
|
|
5
|
+
// https://docs.dataforseo.com/v3/auth
|
|
6
|
+
// https://dataforseo.com/pricing
|
|
7
|
+
export const dataforseo = {
|
|
8
|
+
name: "DataForSEO",
|
|
9
|
+
env: "DATAFORSEO_PASSWORD",
|
|
10
|
+
endpointEnv: "DATAFORSEO_ENDPOINT",
|
|
11
|
+
endpoint: "https://api.dataforseo.com/v3",
|
|
12
|
+
optional: true,
|
|
13
|
+
script: "keyword-data.mjs",
|
|
14
|
+
secret: "API password",
|
|
15
|
+
adds: "monthly searches, keyword difficulty, cost per click and intent for your keyword ideas, and the keywords a competitor ranks for that you don't (node keyword-data.mjs)",
|
|
16
|
+
where: "app.dataforseo.com/api-access",
|
|
17
|
+
fields: [
|
|
18
|
+
{
|
|
19
|
+
id: "login",
|
|
20
|
+
flag: "login",
|
|
21
|
+
env: "DATAFORSEO_LOGIN",
|
|
22
|
+
ask: "Your DataForSEO API login (the email address on app.dataforseo.com/api-access)",
|
|
23
|
+
check: s =>
|
|
24
|
+
/^\S+$/.test(s)
|
|
25
|
+
? s
|
|
26
|
+
: fail(`the API login is the email address shown on https://app.dataforseo.com/api-access (got "${s}").`),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
about: k => `the API login ${k.login}`,
|
|
30
|
+
guide: [
|
|
31
|
+
"DataForSEO lets keyword-data.mjs read monthly Google searches, keyword difficulty, cost per click and intent for your keyword ideas, and list the keywords a competitor ranks for that you don't. You pay DataForSEO per request, from your own balance: no subscription.",
|
|
32
|
+
"1. Sign up at https://app.dataforseo.com/register. New accounts get $1 of trial credit; after that the smallest top-up is $50, and the balance doesn't expire.",
|
|
33
|
+
"2. Open https://app.dataforseo.com/api-access. It shows your API login (your email address) and your API password. The API password isn't your account password: DataForSEO makes it for you.",
|
|
34
|
+
`3. In your own terminal run: ${setLine("dataforseo")}`,
|
|
35
|
+
" It asks for the API login (shown as you type), then the API password. Paste the password and press Enter. It isn't shown, so it stays out of chats and your command history.",
|
|
36
|
+
"Then node keyword-data.mjs --site <your address> --ideas seo-audit/keyword-ideas.json shows what it would send and the most it can cost. Nothing is sent until you add --yes.",
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Errors usually arrive as HTTP 200 with a status_code; 20000 is OK.
|
|
41
|
+
// https://docs.dataforseo.com/v3/appendix/errors
|
|
42
|
+
export function dataforseoProblem(b) {
|
|
43
|
+
const t = Array.isArray(b?.tasks) ? b.tasks[0] : null;
|
|
44
|
+
const [code, msg] =
|
|
45
|
+
b?.status_code !== 20000
|
|
46
|
+
? [b?.status_code, b?.status_message]
|
|
47
|
+
: t && t.status_code !== 20000
|
|
48
|
+
? [t.status_code, t.status_message]
|
|
49
|
+
: [20000, ""];
|
|
50
|
+
if (code === 20000) return null;
|
|
51
|
+
if (code === 40100) return DFS_AUTH;
|
|
52
|
+
if (code === 40200 || code === 40210)
|
|
53
|
+
return `DataForSEO says the account's balance is too low for this request (${code}). Top up at https://app.dataforseo.com, then run again.`;
|
|
54
|
+
if (code === 40202 || code === 40209)
|
|
55
|
+
return `DataForSEO says too many requests right now (${code}). Wait a minute and run again.`;
|
|
56
|
+
return `DataForSEO said: ${String(msg || "no message").trim()} (${code ?? "no status code"}).`;
|
|
57
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { setLine, PASTE } from "./http.mjs";
|
|
3
|
+
|
|
4
|
+
// script: geo-grid.mjs uses it; fetch doesn't. The project needs billing enabled. The key goes in the X-Goog-Api-Key
|
|
5
|
+
// header, never in an address. Prices are in geo-grid.mjs.
|
|
6
|
+
// https://developers.google.com/maps/documentation/places/web-service/get-api-key
|
|
7
|
+
export const googleplaces = {
|
|
8
|
+
name: "Google Places API",
|
|
9
|
+
env: "GOOGLE_PLACES_API_KEY",
|
|
10
|
+
endpointEnv: "GOOGLE_PLACES_ENDPOINT",
|
|
11
|
+
endpoint: "https://places.googleapis.com/v1",
|
|
12
|
+
optional: true,
|
|
13
|
+
script: "geo-grid.mjs",
|
|
14
|
+
adds: "where your business appears in the list Google's Places API returns near each point of a grid around it (node geo-grid.mjs)",
|
|
15
|
+
where: "console.cloud.google.com → Google Maps Platform → Keys & Credentials",
|
|
16
|
+
guide: [
|
|
17
|
+
"Google's Places API (New) lets geo-grid.mjs check where your business appears in the list Google returns for a keyword near each point of a grid around it. It uses your own Google Maps Platform key. Asking for place IDs only, as geo-grid does, is listed as free without limit on Google's price list (read 22 Nov 2026).",
|
|
18
|
+
"1. Open https://console.cloud.google.com and pick or create a project.",
|
|
19
|
+
"2. Turn on billing for the project: https://console.cloud.google.com/projectselector/billing. Google requires billing for the Places API even when your use stays within the free amounts.",
|
|
20
|
+
"3. Open https://console.cloud.google.com/apis/library/places.googleapis.com and click Enable. Check that it says Places API (New). It can take a few minutes to start working.",
|
|
21
|
+
"4. Open Google Maps Platform → Keys & Credentials (https://console.cloud.google.com/projectselector/google/maps-apis/credentials) and click Create credentials → API key. Under API restrictions, keep only Places API (New) selected, so the key can't be used for anything else.",
|
|
22
|
+
`5. Copy the key, then in your own terminal run: ${setLine("googleplaces")}`,
|
|
23
|
+
PASTE,
|
|
24
|
+
'Then node geo-grid.mjs --place-id <your place ID> --keywords "plumber" shows what it would send and how many requests that is. Nothing is sent until you add --yes. Your place ID is on Google\'s Place ID Finder: https://developers.google.com/maps/documentation/javascript/examples/places-placeid-finder',
|
|
25
|
+
],
|
|
26
|
+
};
|