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,250 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Everything from the audit file is escaped: mdSafe where the page uses inl, noteMd for plain values, noteCode for
|
|
3
|
+
// paths, URLs and file names, cellMd in tables.
|
|
4
|
+
import { SEV, bandOf } from "../lib/score.mjs";
|
|
5
|
+
import { recheckOf } from "../lib/recheck.mjs";
|
|
6
|
+
import { planMarkdown } from "../report-plan.mjs";
|
|
7
|
+
import { SEV_LABEL, STATUS_LABEL, cellMd, fmtDate, mdSafe, noteCode, noteMd, num, plural } from "./format.mjs";
|
|
8
|
+
import { needsYou } from "./model.mjs";
|
|
9
|
+
import { effortOf, nextStep } from "./findings.mjs";
|
|
10
|
+
import { SCORE_HOW, actions, keyNumbers, scopeText } from "./overview.mjs";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Follows the page's order (page.mjs), every finding with all its evidence, and ends with "How the score works",
|
|
14
|
+
* which the page folds into its score panel.
|
|
15
|
+
*/
|
|
16
|
+
export function markdown(
|
|
17
|
+
m,
|
|
18
|
+
{
|
|
19
|
+
plan,
|
|
20
|
+
diff,
|
|
21
|
+
topics,
|
|
22
|
+
tabs,
|
|
23
|
+
burstMd,
|
|
24
|
+
googleUpdatesText,
|
|
25
|
+
googlePostsText,
|
|
26
|
+
diffSections,
|
|
27
|
+
diffText,
|
|
28
|
+
unknownLines,
|
|
29
|
+
linksDroppedMd,
|
|
30
|
+
trafficOf,
|
|
31
|
+
clarityOf,
|
|
32
|
+
},
|
|
33
|
+
) {
|
|
34
|
+
const {
|
|
35
|
+
raw,
|
|
36
|
+
site,
|
|
37
|
+
run,
|
|
38
|
+
overall,
|
|
39
|
+
verdict,
|
|
40
|
+
deltaOf,
|
|
41
|
+
openBlockers,
|
|
42
|
+
unlock,
|
|
43
|
+
open,
|
|
44
|
+
fixed,
|
|
45
|
+
countSev,
|
|
46
|
+
areas,
|
|
47
|
+
decisions,
|
|
48
|
+
findings,
|
|
49
|
+
passed,
|
|
50
|
+
notChecked,
|
|
51
|
+
notes,
|
|
52
|
+
notShown = [],
|
|
53
|
+
} = m;
|
|
54
|
+
const panels = id => (tabs[id] || []).flatMap(x => x.md);
|
|
55
|
+
const L = [];
|
|
56
|
+
const files = list => list.map(x => noteCode(x)).join(", ");
|
|
57
|
+
L.push(`# SEO report: ${noteMd(site.name)}`, "");
|
|
58
|
+
L.push(
|
|
59
|
+
mdSafe(
|
|
60
|
+
[
|
|
61
|
+
site.url,
|
|
62
|
+
run.pagesCrawled != null && `${run.pagesCrawled} pages crawled`,
|
|
63
|
+
site.framework,
|
|
64
|
+
(site.siteTypes || []).join(", "),
|
|
65
|
+
fmtDate(run.date),
|
|
66
|
+
run.mode,
|
|
67
|
+
]
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.join(" · "),
|
|
70
|
+
),
|
|
71
|
+
"",
|
|
72
|
+
);
|
|
73
|
+
if (raw.summary) L.push(mdSafe(raw.summary), "");
|
|
74
|
+
const proposed = plan?.status === "proposed";
|
|
75
|
+
if (plan && proposed) L.push(...planMarkdown(plan));
|
|
76
|
+
if (overall) {
|
|
77
|
+
L.push(`**SEO health score: ${overall.value}/100 (${bandOf(overall.value)[1]}).** ${verdict}.`, "");
|
|
78
|
+
const delta = deltaOf(),
|
|
79
|
+
md = h => h.replace(/<\/?b>/g, "**").replace(/<[^>]+>/g, "");
|
|
80
|
+
if (overall.cap) {
|
|
81
|
+
L.push(
|
|
82
|
+
`${plural(overall.blockers, "open blocker")} hold${overall.blockers === 1 ? "s" : ""} the score at ${overall.cap} until fixed.`,
|
|
83
|
+
"",
|
|
84
|
+
);
|
|
85
|
+
const owner = openBlockers.filter(needsYou).map(f => noteMd(f.id));
|
|
86
|
+
L.push(
|
|
87
|
+
`**Fix ${openBlockers.length === 1 ? "the blocker" : `the ${openBlockers.length} blockers`} and the score rises to ${unlock.value}/100 (${bandOf(unlock.value)[1]}).**${delta?.inUnlock ? ` ${md(delta.html)}.` : ""}${owner.length ? ` ${owner.join(", ")} need${owner.length === 1 ? "s" : ""} you: the agent won't change ${owner.length === 1 ? "it" : "them"} without your go-ahead.` : ""}`,
|
|
88
|
+
"",
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (delta && !delta.inUnlock) L.push(`${md(delta.html)}.`, "");
|
|
92
|
+
}
|
|
93
|
+
const { fixFirst, needsYou: yours, yours: allYours, tasks } = actions(m);
|
|
94
|
+
const { clicks, period, cwv, strategy } = keyNumbers(m);
|
|
95
|
+
const item = x => `- ${x.id ? `**${noteMd(x.id)}** · ` : ""}${SEV_LABEL[x.sev]} · ${mdSafe(x.title)}`;
|
|
96
|
+
if (fixFirst.length)
|
|
97
|
+
L.push(
|
|
98
|
+
"## Fix first",
|
|
99
|
+
"",
|
|
100
|
+
"What the agent can fix in code. Each line fixes one.",
|
|
101
|
+
"",
|
|
102
|
+
...fixFirst.map(x => `${item(x)}${x.id ? ` · ${noteCode(`/seo-fix ${x.id}`)}` : ""}`),
|
|
103
|
+
"",
|
|
104
|
+
);
|
|
105
|
+
if (yours.length)
|
|
106
|
+
L.push(
|
|
107
|
+
"## Needs you",
|
|
108
|
+
"",
|
|
109
|
+
"Your call, your accounts or your go-ahead: the agent won't change these without you.",
|
|
110
|
+
"",
|
|
111
|
+
...yours.map(item),
|
|
112
|
+
"",
|
|
113
|
+
`All ${allYours.length} are under Decisions needed, below.`,
|
|
114
|
+
"",
|
|
115
|
+
);
|
|
116
|
+
if (areas.length) {
|
|
117
|
+
L.push("## Area scores", "", "| Area | Score | Open findings | Top issue |", "| --- | ---: | ---: | --- |");
|
|
118
|
+
for (const a of areas)
|
|
119
|
+
L.push(
|
|
120
|
+
`| ${cellMd(noteMd(a.name))} | ${a.value} | ${a.top.length} | ${cellMd(a.top[0] ? mdSafe(a.top[0].title) : "All checks pass")} |`,
|
|
121
|
+
);
|
|
122
|
+
L.push("");
|
|
123
|
+
}
|
|
124
|
+
if (overall) L.push(`${scopeText(m)} Limits of this audit, below.`, "");
|
|
125
|
+
L.push(
|
|
126
|
+
`Open: ${open.length} (${SEV.map(s => `${countSev(s)} ${SEV_LABEL[s].toLowerCase()}`).join(", ")}) · Fixed: ${fixed.length} · Rules passing: ${overall ? `${overall.passing} of ${overall.rules}` : "n/a"}`,
|
|
127
|
+
"",
|
|
128
|
+
);
|
|
129
|
+
if (clicks != null || cwv)
|
|
130
|
+
L.push(
|
|
131
|
+
[
|
|
132
|
+
clicks != null && `Clicks from Google: ${num(clicks)}${period ? ` (${noteMd(period)})` : ""}`,
|
|
133
|
+
cwv && `Core Web Vitals (real visitors, ${noteMd(strategy)}): ${cwv.toLowerCase()}`,
|
|
134
|
+
]
|
|
135
|
+
.filter(Boolean)
|
|
136
|
+
.join(" · "),
|
|
137
|
+
"",
|
|
138
|
+
);
|
|
139
|
+
if (plan && !proposed) L.push(...planMarkdown(plan));
|
|
140
|
+
const options = d => [...(d.options || []).map(o => `- ${mdSafe(o)}`), ...((d.options || []).length ? [""] : [])];
|
|
141
|
+
L.push("## Findings", "");
|
|
142
|
+
for (const f of findings) {
|
|
143
|
+
// Titles and what's wrong can quote crawled pages and Google's messages, so they're escaped like evidence.
|
|
144
|
+
L.push(
|
|
145
|
+
`### ${noteMd(f.id)} · ${SEV_LABEL[f.severity]}${needsYou(f) ? " · Needs you" : ""} · ${mdSafe(f.title)}`,
|
|
146
|
+
"",
|
|
147
|
+
);
|
|
148
|
+
L.push(
|
|
149
|
+
`Status: ${noteMd(STATUS_LABEL[f.status] || f.status)} · Area: ${noteMd(f.category)}${f.rule ? ` · Rule: ${noteMd(f.rule)}` : ""}${f.count ? ` · Cases: ${noteMd(f.count)}` : ""}${effortOf(f) ? ` · ${effortOf(f)}` : ""}`,
|
|
150
|
+
"",
|
|
151
|
+
);
|
|
152
|
+
if (f.what) L.push(`**What's wrong.** ${mdSafe(f.what)}`, "");
|
|
153
|
+
if (f.why) L.push(`**Why it matters.** ${mdSafe(f.why)}`, "");
|
|
154
|
+
if (f.fix) L.push(`**How to fix.** ${mdSafe(f.fix)}`, "");
|
|
155
|
+
if (f.decision) {
|
|
156
|
+
L.push(`**Decision needed.** ${mdSafe(f.decision.question || "")}`, "", ...options(f.decision));
|
|
157
|
+
if (f.decision.recommendation) L.push(`Recommended: ${mdSafe(f.decision.recommendation)}`, "");
|
|
158
|
+
}
|
|
159
|
+
if (f.fixed)
|
|
160
|
+
L.push(
|
|
161
|
+
`**What was done.** ${mdSafe(f.fixed.summary || "")}${(f.fixed.files || []).length ? ` Files: ${files(f.fixed.files)}.` : ""}${f.fixed.verified ? ` Verified: ${mdSafe(f.fixed.verified)}.` : ""}`,
|
|
162
|
+
"",
|
|
163
|
+
);
|
|
164
|
+
const t = trafficOf(f);
|
|
165
|
+
if (t) L.push(`${noteMd(t.text)} on ${noteCode(t.path)}`, "");
|
|
166
|
+
const c = clarityOf(f);
|
|
167
|
+
if (c) L.push(`${noteMd(c.text)} on ${noteCode(c.path)}`, "");
|
|
168
|
+
if ((f.evidence || []).length) {
|
|
169
|
+
L.push("| Where | Detail |", "| --- | --- |");
|
|
170
|
+
for (const e of f.evidence)
|
|
171
|
+
L.push(
|
|
172
|
+
`| ${cellMd([e.url && noteCode(e.url), e.file && noteCode(`${e.file}${e.line ? ":" + e.line : ""}`)].filter(Boolean).join(" "))} | ${cellMd(mdSafe(e.detail))} |`,
|
|
173
|
+
);
|
|
174
|
+
if (f.count > f.evidence.length) L.push("", `${f.count - f.evidence.length} more cases not listed.`);
|
|
175
|
+
L.push("");
|
|
176
|
+
}
|
|
177
|
+
if (nextStep(f, decisions)) L.push(`**Next step.** ${mdSafe(nextStep(f, decisions))}`, "");
|
|
178
|
+
const rc = recheckOf(f);
|
|
179
|
+
if (rc) L.push(`**Check the fix yourself.** ${noteCode(rc.command)} ${rc.hint}`, "");
|
|
180
|
+
}
|
|
181
|
+
L.push(...panels("findings"));
|
|
182
|
+
if (decisions.length || tasks.length) {
|
|
183
|
+
L.push("## Decisions needed", "");
|
|
184
|
+
for (const d of decisions) {
|
|
185
|
+
L.push(`### ${d.id ? `${noteMd(d.id)}: ` : ""}${mdSafe(d.question)}`, "");
|
|
186
|
+
if (d.context) L.push(mdSafe(d.context), "");
|
|
187
|
+
L.push(...options(d));
|
|
188
|
+
if (d.recommendation) L.push(`**Recommended:** ${mdSafe(d.recommendation)}`, "");
|
|
189
|
+
}
|
|
190
|
+
if (tasks.length)
|
|
191
|
+
L.push(
|
|
192
|
+
"### Your tasks",
|
|
193
|
+
"",
|
|
194
|
+
"Findings only you can resolve: a setting on your host or an account, your content or your facts. The agent won't change them without your go-ahead.",
|
|
195
|
+
"",
|
|
196
|
+
...tasks.map(f => `- **${noteMd(f.id)}** ${mdSafe(f.title)} · ${SEV_LABEL[f.severity]}`),
|
|
197
|
+
"",
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
for (const [id, label] of topics)
|
|
201
|
+
L.push(`## ${label}`, "", "Information only: nothing here changes the score.", "", ...panels(id));
|
|
202
|
+
if (diff || tabs.since) L.push("## Since last audit", "");
|
|
203
|
+
if (diff) {
|
|
204
|
+
L.push(...burstMd(), `Compared with the crawl of ${noteMd(fmtDate(diff.since))}.`, "");
|
|
205
|
+
if (googleUpdatesText()) L.push(googleUpdatesText(), "");
|
|
206
|
+
if (googlePostsText()) L.push(googlePostsText(), "");
|
|
207
|
+
for (const [h, list] of diffSections(diff))
|
|
208
|
+
L.push(`### ${h}`, "", ...list.map(c => `- ${noteCode(c.path)} ${noteMd(diffText(c))}`), ""); // crawled titles and robots.txt rules, escaped
|
|
209
|
+
for (const t of unknownLines(diff)) L.push(t, "");
|
|
210
|
+
for (const [h, l] of [
|
|
211
|
+
["Pages added", diff.added],
|
|
212
|
+
["Pages gone", diff.removed],
|
|
213
|
+
])
|
|
214
|
+
if ((l || []).length) L.push(`### ${h}`, "", ...l.map(p => `- ${noteCode(p)}`), "");
|
|
215
|
+
L.push(...linksDroppedMd());
|
|
216
|
+
}
|
|
217
|
+
L.push(...panels("since"));
|
|
218
|
+
if (fixed.length) {
|
|
219
|
+
L.push("## What was changed", "");
|
|
220
|
+
for (const f of fixed)
|
|
221
|
+
L.push(
|
|
222
|
+
`- **${noteMd(f.id)}** ${mdSafe(f.title)}${f.fixed?.summary ? `: ${mdSafe(f.fixed.summary)}` : ""}${(f.fixed?.files || []).length ? ` (${files(f.fixed.files)})` : ""}${f.fixed?.verified ? `. Verified: ${mdSafe(f.fixed.verified)}` : ""}`,
|
|
223
|
+
);
|
|
224
|
+
L.push("");
|
|
225
|
+
}
|
|
226
|
+
if (passed.length) {
|
|
227
|
+
L.push("## Passed checks", "");
|
|
228
|
+
for (const p of passed)
|
|
229
|
+
L.push(`- **${noteMd(p.rule)}** ${mdSafe(p.title)}${p.detail ? ` (${mdSafe(p.detail)})` : ""}`);
|
|
230
|
+
L.push("");
|
|
231
|
+
}
|
|
232
|
+
if (notChecked.length || notes.length || notShown.length || tabs.limits) {
|
|
233
|
+
L.push("## Limits of this audit", "");
|
|
234
|
+
for (const n of notChecked) L.push(`- **${noteMd(n.area || n.rule)}:** ${mdSafe(n.reason || "")}`);
|
|
235
|
+
for (const n of notes) L.push(`- ${mdSafe(n)}`);
|
|
236
|
+
L.push("");
|
|
237
|
+
if (notShown.length)
|
|
238
|
+
L.push(
|
|
239
|
+
"### Not shown",
|
|
240
|
+
"",
|
|
241
|
+
"Results that were produced but can't be shown in this report, and why. Information only: they never change the score.",
|
|
242
|
+
"",
|
|
243
|
+
...notShown.map(n => `- **${noteMd(n.what)}:** ${noteMd(n.why)}`),
|
|
244
|
+
"",
|
|
245
|
+
);
|
|
246
|
+
L.push(...panels("limits"));
|
|
247
|
+
}
|
|
248
|
+
L.push("## How the score works", "", SCORE_HOW, "");
|
|
249
|
+
return L.join("\n");
|
|
250
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The report's model: the audit read once, with check settings applied and the score worked out.
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
import { EARN, isOpen, buildRules as rulesOf, score, scoreSummary } from "../lib/score.mjs";
|
|
5
|
+
import { plural, obj, isText } from "./format.mjs";
|
|
6
|
+
|
|
7
|
+
export const needsYou = f => f.fixBy === "owner" && isOpen(f);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {any} raw the audit JSON (or raw seo-crawl / content-scan output)
|
|
11
|
+
* @param {string} dir the audit file's folder: its settings.json applies
|
|
12
|
+
*/
|
|
13
|
+
export function buildModel(raw, dir) {
|
|
14
|
+
const isCrawl = raw.tool === "seo-supervisor-crawler";
|
|
15
|
+
const isScan = raw.tool === "seo-supervisor-content-scan";
|
|
16
|
+
const host = () => {
|
|
17
|
+
try {
|
|
18
|
+
return new URL(raw.siteOrigin).host;
|
|
19
|
+
} catch {
|
|
20
|
+
return String(raw.siteOrigin || "Website");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const site = raw.site || {
|
|
24
|
+
name: isCrawl ? host() : isScan ? `Content: ${basename(String(raw.source))}` : "Website",
|
|
25
|
+
url: raw.siteOrigin || "",
|
|
26
|
+
};
|
|
27
|
+
const run = { ...(raw.run || {}) };
|
|
28
|
+
if (isCrawl)
|
|
29
|
+
Object.assign(run, {
|
|
30
|
+
mode: "crawl",
|
|
31
|
+
date: raw.crawledAt,
|
|
32
|
+
pagesCrawled: raw.stats?.htmlPages,
|
|
33
|
+
auditor: "seo-crawl.mjs " + raw.version,
|
|
34
|
+
});
|
|
35
|
+
if (isScan) Object.assign(run, { mode: "content scan", date: raw.scannedAt, auditor: "content-scan.mjs" });
|
|
36
|
+
// scoreSummary applies settings.json before scoring, the same way the dashboard does.
|
|
37
|
+
const { findings, checkSettings, passed, open, rules, overall, unlock, countSev } = scoreSummary(raw, dir);
|
|
38
|
+
const notChecked = raw.notChecked || [];
|
|
39
|
+
const notes = raw.notes || [];
|
|
40
|
+
// Lighthouse runs, validated once for every panel; each failed audit keeps up to 10 of the items it names.
|
|
41
|
+
const lighthouse = (Array.isArray(raw.lighthouse) ? raw.lighthouse : [])
|
|
42
|
+
.filter(x => obj(x) && isText(x.url))
|
|
43
|
+
.map(x => ({
|
|
44
|
+
...x,
|
|
45
|
+
detail: (Array.isArray(x.detail) ? x.detail : [])
|
|
46
|
+
.filter(a => obj(a) && typeof a.title === "string")
|
|
47
|
+
.map(a => ({
|
|
48
|
+
...a,
|
|
49
|
+
items: (Array.isArray(a.items) ? a.items : []).filter(s => typeof s === "string" && s).slice(0, 10),
|
|
50
|
+
})),
|
|
51
|
+
}));
|
|
52
|
+
// The audit's own decisions first, then open ones on findings, deduped by id so the Decisions tab never counts one
|
|
53
|
+
// twice.
|
|
54
|
+
const decisions = [
|
|
55
|
+
...(raw.decisions || []).map(d => ({ ...d })),
|
|
56
|
+
...findings
|
|
57
|
+
.filter(f => f.status === "needs-decision" && isOpen(f))
|
|
58
|
+
.map(f => ({
|
|
59
|
+
id: f.id,
|
|
60
|
+
question: f.decision?.question || f.title,
|
|
61
|
+
context: f.what || f.why,
|
|
62
|
+
options: f.decision?.options,
|
|
63
|
+
recommendation: f.decision?.recommendation || f.fix,
|
|
64
|
+
})),
|
|
65
|
+
].filter((d, i, all) => !d.id || all.findIndex(x => x.id === d.id) === i);
|
|
66
|
+
const fixed = findings.filter(f => !isOpen(f));
|
|
67
|
+
|
|
68
|
+
// The score model is documented in report-format.md.
|
|
69
|
+
const buildRules = opts => rulesOf(findings, passed, opts);
|
|
70
|
+
const areaNames = [...new Set(rules.map(r => r.area))];
|
|
71
|
+
const areas = areaNames
|
|
72
|
+
.map(name => {
|
|
73
|
+
const s = score(rules.filter(r => r.area === name));
|
|
74
|
+
const top = open.filter(f => f.category === name);
|
|
75
|
+
const fixedHere = fixed.filter(f => f.category === name).length;
|
|
76
|
+
return { name, ...s, worst: top[0]?.severity || null, top, fixedHere };
|
|
77
|
+
})
|
|
78
|
+
.sort((a, b) => a.value - b.value || a.name.localeCompare(b.name));
|
|
79
|
+
|
|
80
|
+
const before = fixed.length ? score(buildRules({ fixedCountsAsOpen: true })) : null;
|
|
81
|
+
// While blockers cap the score, the report shows what fixing them unlocks.
|
|
82
|
+
const isBlocker = f => f.severity === "blocker";
|
|
83
|
+
const openBlockers = findings.filter(f => isBlocker(f) && isOpen(f));
|
|
84
|
+
const beforeUnlock = unlock && before ? score(buildRules({ fixedCountsAsOpen: true, assume: isBlocker })) : null;
|
|
85
|
+
// What this run's fixes changed. While the blocker cap holds the total, the gain shows in the unlocked score instead.
|
|
86
|
+
function deltaOf() {
|
|
87
|
+
if (!before || !overall) return null;
|
|
88
|
+
const fx = plural(fixed.length, "fix", "fixes");
|
|
89
|
+
if (before.value !== overall.value) {
|
|
90
|
+
const up = overall.value > before.value;
|
|
91
|
+
return {
|
|
92
|
+
dir: up ? "up" : "down",
|
|
93
|
+
html: `${up ? "Up" : "Down"} <b>${Math.abs(overall.value - before.value)}</b> from ${before.value} before this run's ${fx}`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (unlock && beforeUnlock && beforeUnlock.value !== unlock.value) {
|
|
97
|
+
const up = unlock.value > beforeUnlock.value;
|
|
98
|
+
const n = Math.abs(unlock.value - beforeUnlock.value);
|
|
99
|
+
return {
|
|
100
|
+
dir: up ? "up" : "down",
|
|
101
|
+
inUnlock: true,
|
|
102
|
+
html: up
|
|
103
|
+
? `The ${fx} from this run earned <b>${n}</b> ${n === 1 ? "point" : "points"}. You'll see ${n === 1 ? "it" : "them"} once the ${openBlockers.length === 1 ? "blocker is" : "blockers are"} fixed`
|
|
104
|
+
: `This run's changes cost <b>${n}</b> ${n === 1 ? "point" : "points"}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const impact = (() => {
|
|
110
|
+
if (!overall) return { rows: [], cap: 0 };
|
|
111
|
+
const possible = overall.rules * 10;
|
|
112
|
+
const lost = areas.map(
|
|
113
|
+
a =>
|
|
114
|
+
/** @type {{ a: typeof a, exact: number, pts?: number }} */ ({
|
|
115
|
+
a,
|
|
116
|
+
exact:
|
|
117
|
+
(100 * rules.filter(r => r.area === a.name).reduce((s, r) => s + (r.worst ? 10 - EARN[r.worst] : 0), 0)) /
|
|
118
|
+
possible,
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
// Area points add up to what's lost before the blocker cap, lib/score.mjs's stop at 99 included.
|
|
122
|
+
const target = 100 - (overall.cap ? overall.raw : overall.value);
|
|
123
|
+
lost.forEach(x => {
|
|
124
|
+
x.pts = Math.floor(x.exact);
|
|
125
|
+
});
|
|
126
|
+
let rest = target - lost.reduce((s, x) => s + x.pts, 0);
|
|
127
|
+
[...lost]
|
|
128
|
+
.sort((x, y) => y.exact - y.pts - (x.exact - x.pts))
|
|
129
|
+
.forEach(x => {
|
|
130
|
+
if (rest > 0 && x.exact > x.pts) {
|
|
131
|
+
x.pts++;
|
|
132
|
+
rest--;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
rows: lost.filter(x => x.exact > 0).sort((x, y) => y.exact - x.exact || x.a.value - y.a.value),
|
|
137
|
+
cap: overall.cap ? overall.raw - overall.value : 0,
|
|
138
|
+
};
|
|
139
|
+
})();
|
|
140
|
+
|
|
141
|
+
let verdict;
|
|
142
|
+
if (!overall) verdict = "Not scored: no checked rules in this file.";
|
|
143
|
+
else if (countSev("blocker"))
|
|
144
|
+
verdict = `Not ready: ${countSev("blocker")} blocker${countSev("blocker") > 1 ? "s" : ""} to fix first`;
|
|
145
|
+
else if (countSev("high"))
|
|
146
|
+
verdict = `Needs work: ${countSev("high")} high-severity issue${countSev("high") > 1 ? "s" : ""}`;
|
|
147
|
+
else if (open.length) verdict = "In good shape: only minor issues left";
|
|
148
|
+
else verdict = "Every checked rule passes";
|
|
149
|
+
return {
|
|
150
|
+
site,
|
|
151
|
+
run,
|
|
152
|
+
findings,
|
|
153
|
+
checkSettings,
|
|
154
|
+
passed,
|
|
155
|
+
notChecked,
|
|
156
|
+
notes,
|
|
157
|
+
lighthouse,
|
|
158
|
+
decisions,
|
|
159
|
+
open,
|
|
160
|
+
fixed,
|
|
161
|
+
countSev,
|
|
162
|
+
buildRules,
|
|
163
|
+
overall,
|
|
164
|
+
areas,
|
|
165
|
+
openBlockers,
|
|
166
|
+
unlock,
|
|
167
|
+
deltaOf,
|
|
168
|
+
impact,
|
|
169
|
+
verdict,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// One-line summaries of the outside checks for the topic tabs' "at a glance" panels; each is "" without its data.
|
|
3
|
+
import { fmtCwv, passes, band } from "../checks/speed.mjs";
|
|
4
|
+
import { esc, fmtDate, link, noteMd, notePath, obj } from "./format.mjs";
|
|
5
|
+
|
|
6
|
+
// LCP's four parts (speed.lcpBreakdown, in ms), each with its fix.
|
|
7
|
+
export const LCP_PART = {
|
|
8
|
+
ttfb: ["the server's response", "Cache pages, serve them from a CDN or use a faster server."],
|
|
9
|
+
loadDelay: [
|
|
10
|
+
"the wait before the main image starts loading",
|
|
11
|
+
'Preload the hero image, give it fetchpriority="high" and don\'t lazy-load it.',
|
|
12
|
+
],
|
|
13
|
+
loadDuration: ["downloading the main image", "Make it smaller and serve it in a modern format (WebP or AVIF)."],
|
|
14
|
+
renderDelay: [
|
|
15
|
+
"drawing it on screen",
|
|
16
|
+
"Cut render-blocking CSS and JavaScript, and build the page on the server rather than in the browser.",
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
// LCP, INP and CLS, each with Google's good / needs improvement / poor band.
|
|
20
|
+
function bandedCwv(v) {
|
|
21
|
+
return [
|
|
22
|
+
`LCP ${(v.lcp / 1000).toFixed(1)} s (${band("lcp", v.lcp)})`,
|
|
23
|
+
v.inp != null && `INP ${Math.round(v.inp)} ms (${band("inp", v.inp)})`,
|
|
24
|
+
v.cls != null && `CLS ${Math.round(v.cls * 100) / 100} (${band("cls", v.cls)})`,
|
|
25
|
+
]
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.join(" · ");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function overviewLines({ raw, lighthouse }) {
|
|
31
|
+
// Origin field data, else the first page's.
|
|
32
|
+
function speedText() {
|
|
33
|
+
const s = raw.speed;
|
|
34
|
+
if (!s || (!(s.samples || []).length && !s.trend)) return "";
|
|
35
|
+
const v = (s.samples || []).find(x => x.origin)?.origin || (s.samples || []).find(x => x.field)?.field;
|
|
36
|
+
const now = (s.samples || []).length
|
|
37
|
+
? v
|
|
38
|
+
? `${bandedCwv(v)}, ${passes(v) ? "passes" : "fails"} Core Web Vitals`
|
|
39
|
+
: "not enough visits for field data yet"
|
|
40
|
+
: "";
|
|
41
|
+
const l = s.trend?.lcp,
|
|
42
|
+
trend = l
|
|
43
|
+
? `over ${s.trend.weeks} weeks: LCP ${(l[0] / 1000).toFixed(1)} → ${(l[1] / 1000).toFixed(1)} s (${l[1] < l[0] * 0.95 ? "better" : l[1] > l[0] * 1.05 ? "worse" : "steady"})`
|
|
44
|
+
: "";
|
|
45
|
+
return `Real-user speed (${s.strategy || "mobile"}): ${[now, trend].filter(Boolean).join(" · ")}`;
|
|
46
|
+
}
|
|
47
|
+
// Ahrefs' licence requires its credit beside the numbers.
|
|
48
|
+
function authorityText() {
|
|
49
|
+
const a = Array.isArray(raw.authority) ? raw.authority : [];
|
|
50
|
+
const scores = x =>
|
|
51
|
+
[
|
|
52
|
+
x.openPageRank != null && `Open PageRank ${Number(x.openPageRank).toFixed(1)}`,
|
|
53
|
+
x.ahrefsDR != null && `Domain Rating ${Number(x.ahrefsDR).toFixed(0)}`,
|
|
54
|
+
]
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join(" · ");
|
|
57
|
+
const [site, ...rivals] = a,
|
|
58
|
+
parts = a.length
|
|
59
|
+
? [scores(site), ...rivals.filter(r => scores(r)).map(r => `${r.domain}: ${scores(r)}`)].filter(Boolean)
|
|
60
|
+
: [];
|
|
61
|
+
return parts.length ? `Authority: ${parts.join("; ")}` : "";
|
|
62
|
+
}
|
|
63
|
+
// The credit goes wherever a Domain Rating shows, whether or not the file carries the attribution.
|
|
64
|
+
const ahrefsCredit = () =>
|
|
65
|
+
(raw.authority || []).some(x => x.ahrefsDR != null)
|
|
66
|
+
? raw.attribution || { text: "Domain Rating by Ahrefs", url: "https://ahrefs.com/" }
|
|
67
|
+
: null;
|
|
68
|
+
// notePath never throws: a URL it can't read shows as written, so one bad URL can't stop the report.
|
|
69
|
+
const pageName = (u, home = "home page") => (notePath(u) === "/" ? home : notePath(u));
|
|
70
|
+
// The crawler's throttled phone load: the home page, else the first page.
|
|
71
|
+
function labSpeedText() {
|
|
72
|
+
const l = (Array.isArray(raw.labSpeed) ? raw.labSpeed : []).filter(x => obj(x) && x.lcp != null),
|
|
73
|
+
x = l.find(x => notePath(x.url) === "/") || l[0];
|
|
74
|
+
return x
|
|
75
|
+
? `Lab speed, slow mobile (indicative): ${fmtCwv(x)} · TBT ${Math.round(x.tbt || 0)} ms on ${pageName(x.url, "the home page")}`
|
|
76
|
+
: "";
|
|
77
|
+
}
|
|
78
|
+
function lcpText() {
|
|
79
|
+
const b = obj(raw.speed?.lcpBreakdown);
|
|
80
|
+
if (!b) return "";
|
|
81
|
+
const [k] = Object.keys(LCP_PART).sort((x, y) => (b[y] || 0) - (b[x] || 0)),
|
|
82
|
+
path = notePath(b.url);
|
|
83
|
+
return `LCP breakdown (${b.source === "lab" ? `lab test${path ? `, ${pageName(b.url)}` : ""}` : "real visitors"}): most of the time goes on ${LCP_PART[k][0]} (${(b[k] / 1000).toFixed(1)} s). ${LCP_PART[k][1]}`;
|
|
84
|
+
}
|
|
85
|
+
// More than the default 5 pages (--lighthouse all) adds the three lowest performance scores.
|
|
86
|
+
function lighthouseText() {
|
|
87
|
+
const l = lighthouse,
|
|
88
|
+
x = l.find(x => notePath(x.url) === "/") || l[0],
|
|
89
|
+
s = x?.scores || {};
|
|
90
|
+
const parts = [
|
|
91
|
+
["Performance", s.performance],
|
|
92
|
+
["SEO", s.seo],
|
|
93
|
+
["Accessibility", s.accessibility],
|
|
94
|
+
["Best practices", s.bestPractices],
|
|
95
|
+
].filter(([, v]) => v != null);
|
|
96
|
+
const scored =
|
|
97
|
+
l.length > 5
|
|
98
|
+
? l.filter(y => y.scores?.performance != null).sort((a, b) => a.scores.performance - b.scores.performance)
|
|
99
|
+
: [];
|
|
100
|
+
const slowest = scored.length
|
|
101
|
+
? `. Lowest performance of ${scored.length} pages: ${scored
|
|
102
|
+
.slice(0, 3)
|
|
103
|
+
.map(y => `${notePath(y.url)} ${y.scores.performance}`)
|
|
104
|
+
.join(" · ")}`
|
|
105
|
+
: "";
|
|
106
|
+
return parts.length
|
|
107
|
+
? `Lighthouse (mobile, ${pageName(x.url)}): ${parts.map(([k, v]) => `${k} ${v}`).join(" · ")}${slowest}`
|
|
108
|
+
: "";
|
|
109
|
+
}
|
|
110
|
+
// Names and dates only: the line never says an update caused anything.
|
|
111
|
+
function googleUpdatesText(html = false) {
|
|
112
|
+
const g = obj(raw.googleUpdates),
|
|
113
|
+
isDay = s => /^\d{4}-\d{2}-\d{2}$/.test(s);
|
|
114
|
+
if (!g || !Array.isArray(g.updates)) return "";
|
|
115
|
+
const day = (d, year = false) => fmtDate(d, year);
|
|
116
|
+
const span = (a, b) =>
|
|
117
|
+
!isDay(b)
|
|
118
|
+
? `${day(a)}, still rolling out`
|
|
119
|
+
: a === b
|
|
120
|
+
? day(a)
|
|
121
|
+
: a.slice(0, 7) === b.slice(0, 7)
|
|
122
|
+
? `${+a.slice(8)}–${day(b)}`
|
|
123
|
+
: `${day(a)} – ${day(b)}`;
|
|
124
|
+
const text = html ? esc : noteMd; // feed text: escaped for HTML or Markdown
|
|
125
|
+
const name = u => (html ? link(u.url, esc(u.name)) : text(u.name));
|
|
126
|
+
const list = g.updates
|
|
127
|
+
.filter(u => obj(u) && u.name && isDay(u.start))
|
|
128
|
+
.map(u => `${name(u)} (${span(u.start, u.end)})`);
|
|
129
|
+
const none =
|
|
130
|
+
isDay(g.from) && isDay(g.to)
|
|
131
|
+
? `none were announced between ${day(g.from, g.from.slice(0, 4) !== g.to.slice(0, 4))} and ${day(g.to, true)}`
|
|
132
|
+
: "none were announced";
|
|
133
|
+
return `Google ranking updates in this period: ${list.length ? list.join(" · ") : none}${g.note ? `. ${text(g.note)}` : ""}`;
|
|
134
|
+
}
|
|
135
|
+
// --desktop: origin field data, else the first page's, plus the desktop trend.
|
|
136
|
+
function desktopSpeedText() {
|
|
137
|
+
const s = raw.speed?.desktop,
|
|
138
|
+
samples = s?.samples || [];
|
|
139
|
+
if (!s || (!samples.length && !s.trend)) return "";
|
|
140
|
+
const v = samples.find(x => x.origin)?.origin || samples.find(x => x.field)?.field;
|
|
141
|
+
const now = !samples.length ? "" : !v ? "not enough visits for field data yet" : bandedCwv(v);
|
|
142
|
+
const l = s.trend?.lcp,
|
|
143
|
+
trend = l
|
|
144
|
+
? `over ${s.trend.weeks} weeks: LCP ${(l[0] / 1000).toFixed(1)} → ${(l[1] / 1000).toFixed(1)} s (${l[1] < l[0] * 0.95 ? "better" : l[1] > l[0] * 1.05 ? "worse" : "steady"})`
|
|
145
|
+
: "";
|
|
146
|
+
return `Real-user speed (desktop): ${[now, trend].filter(Boolean).join(" · ")}`;
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
speedText,
|
|
150
|
+
authorityText,
|
|
151
|
+
ahrefsCredit,
|
|
152
|
+
labSpeedText,
|
|
153
|
+
lcpText,
|
|
154
|
+
lighthouseText,
|
|
155
|
+
googleUpdatesText,
|
|
156
|
+
desktopSpeedText,
|
|
157
|
+
};
|
|
158
|
+
}
|