seo 0.2.1 → 0.2.2

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/dist/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
2
- import { n as load, t as version } from "./package-BTOI9tde.js";
2
+ import { n as load, t as version } from "./package-uOaBUbds.js";
3
3
  import { Headers, fetch as fetch$1 } from "undici";
4
4
  import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
@@ -1732,7 +1732,7 @@ function effectiveSnippetControl(input) {
1732
1732
  }
1733
1733
  //#endregion
1734
1734
  //#region packages/core/dist/extract/canonical.js
1735
- function headerValue$3(headers, name) {
1735
+ function headerValue$4(headers, name) {
1736
1736
  const lower = name.toLowerCase();
1737
1737
  return Object.entries(headers).find(([key]) => key.toLowerCase() === lower)?.[1];
1738
1738
  }
@@ -1816,7 +1816,7 @@ function parameter(value, name) {
1816
1816
  return match?.[1] ?? match?.[2] ?? match?.[3];
1817
1817
  }
1818
1818
  function headerCandidates(headers, baseUrl) {
1819
- const link = headerValue$3(headers, "link");
1819
+ const link = headerValue$4(headers, "link");
1820
1820
  if (!link) return [];
1821
1821
  const candidates = [];
1822
1822
  for (const item of splitLinkHeader(link)) {
@@ -2485,7 +2485,7 @@ function safeText$1(value) {
2485
2485
  const trimmed = value?.replace(/\s+/g, " ").trim();
2486
2486
  return trimmed ? trimmed : void 0;
2487
2487
  }
2488
- function headerValue$2(headers, name) {
2488
+ function headerValue$3(headers, name) {
2489
2489
  const target = name.toLowerCase();
2490
2490
  return Object.entries(headers).find(([key]) => key.toLowerCase() === target)?.[1];
2491
2491
  }
@@ -2584,6 +2584,7 @@ async function extractPage(fetchResult, extractor = "defuddle", dependencies = {
2584
2584
  });
2585
2585
  else invalidHreflangCount += 1;
2586
2586
  }
2587
+ const markdownAlternates = [...new Set($("head link[rel~=\"alternate\"][type][href]").toArray().filter((element) => $(element).attr("type")?.trim().toLowerCase() === "text/markdown").map((element) => httpUrl($(element).attr("href"), fetchResult.finalUrl)).filter((value) => Boolean(value)))].sort();
2587
2588
  const openGraph = Object.fromEntries($("meta[property^=\"og:\"]").toArray().map((element) => [$(element).attr("property") ?? "", $(element).attr("content") ?? ""]).filter(([key, value]) => key && value));
2588
2589
  const twitter = Object.fromEntries($("meta[name^=\"twitter:\"]").toArray().map((element) => [$(element).attr("name") ?? "", $(element).attr("content") ?? ""]).filter(([key, value]) => key && value));
2589
2590
  const structuredData = extractStructuredData($, fetchResult.finalUrl);
@@ -2631,13 +2632,14 @@ async function extractPage(fetchResult, extractor = "defuddle", dependencies = {
2631
2632
  title: safeText$1($("title").first().text()),
2632
2633
  metaDescription: safeText$1($("meta[name=\"description\"]").attr("content")),
2633
2634
  metaRobots,
2634
- xRobotsTag: safeText$1(headerValue$2(fetchResult.headers, "x-robots-tag")),
2635
+ xRobotsTag: safeText$1(headerValue$3(fetchResult.headers, "x-robots-tag")),
2635
2636
  canonical: canonicalEvidence.selectedRaw,
2636
2637
  canonicalEvidence,
2637
2638
  lang: safeText$1($("html").attr("lang")),
2638
2639
  hasViewport: Boolean($("meta[name=\"viewport\"]").attr("content")),
2639
2640
  headings,
2640
2641
  links,
2642
+ markdownAlternates,
2641
2643
  hreflang,
2642
2644
  jsonLd: structuredData.jsonLd,
2643
2645
  invalidJsonLdCount: structuredData.invalidJsonLdSamples.length,
@@ -3442,7 +3444,7 @@ function safeText(value) {
3442
3444
  const normalized = value?.replace(/\s+/g, " ").trim();
3443
3445
  return normalized ? normalized.slice(0, MAX_TEXT_VALUE_LENGTH) : void 0;
3444
3446
  }
3445
- function headerValue$1(headers, name) {
3447
+ function headerValue$2(headers, name) {
3446
3448
  const expected = name.toLowerCase();
3447
3449
  return Object.entries(headers).find(([key]) => key.toLowerCase() === expected)?.[1];
3448
3450
  }
@@ -3495,7 +3497,7 @@ function renderingDocumentSnapshot(result) {
3495
3497
  const structuredData = extractStructuredData($, result.finalUrl);
3496
3498
  const metaRobots = normalizedDirectiveValue([metaValue($, "robots")]);
3497
3499
  const googlebotRobots = normalizedDirectiveValue([metaValue($, "googlebot")]);
3498
- const httpRobots = normalizedDirectiveValue([headerValue$1(result.headers, "x-robots-tag")]);
3500
+ const httpRobots = normalizedDirectiveValue([headerValue$2(result.headers, "x-robots-tag")]);
3499
3501
  const headings = $("h1, h2, h3, h4, h5, h6").toArray().map((element) => ({
3500
3502
  level: Number.parseInt(element.tagName.slice(1), 10),
3501
3503
  text: safeText($(element).text())
@@ -6030,8 +6032,1062 @@ function matchesFilters(issue, filters) {
6030
6032
  return true;
6031
6033
  }
6032
6034
  //#endregion
6033
- //#region packages/core/dist/analyze/crawler/ai-readiness.js
6035
+ //#region packages/core/dist/analyze/crawler/agent-discovery.js
6036
+ const MAX_BODY_BYTES = 2e6;
6037
+ const MAX_LLMS_LINKS = 100;
6038
+ const MAX_CURATED_LLMS_BYTES = 1e5;
6039
+ const MAX_SKILLS = 25;
6040
+ function sha256(value) {
6041
+ return createHash("sha256").update(value).digest("hex");
6042
+ }
6043
+ function headerValue$1(headers, name) {
6044
+ if (!headers) return void 0;
6045
+ const target = name.toLowerCase();
6046
+ return Object.entries(headers).find(([key]) => key.toLowerCase() === target)?.[1];
6047
+ }
6048
+ function linkEntries(value, base) {
6049
+ if (!value) return [];
6050
+ return value.split(/,(?=\s*<)/u).map((entry) => {
6051
+ const match = entry.match(/^\s*<([^>]+)>\s*(.*)$/u);
6052
+ if (!match?.[1]) return void 0;
6053
+ try {
6054
+ const url = new URL(match[1], base).toString();
6055
+ const parameters = match[2] ?? "";
6056
+ const rel = parameters.match(/(?:^|;)\s*rel=(?:"([^"]+)"|([^;\s]+))/iu);
6057
+ const type = parameters.match(/(?:^|;)\s*type=(?:"([^"]+)"|([^;\s]+))/iu);
6058
+ return {
6059
+ url,
6060
+ rel: (rel?.[1] ?? rel?.[2] ?? "").toLowerCase().split(/\s+/u),
6061
+ type: (type?.[1] ?? type?.[2] ?? "").toLowerCase()
6062
+ };
6063
+ } catch {
6064
+ return;
6065
+ }
6066
+ }).filter((entry) => Boolean(entry));
6067
+ }
6068
+ function normalizedDocumentUrl(value) {
6069
+ const url = new URL(value);
6070
+ url.hash = "";
6071
+ if (url.pathname !== "/") url.pathname = url.pathname.replace(/\/$/u, "");
6072
+ return url.toString();
6073
+ }
6074
+ function sameDocument(left, right) {
6075
+ if (!left || !right) return null;
6076
+ try {
6077
+ return normalizedDocumentUrl(left) === normalizedDocumentUrl(right);
6078
+ } catch {
6079
+ return false;
6080
+ }
6081
+ }
6082
+ function bodyWordCount(value) {
6083
+ return value.replace(/^---[\s\S]*?---\s*/u, "").replace(/```[\s\S]*?```/gu, " ").replace(/[#>*_`[\]()|:-]/gu, " ").split(/\s+/u).filter(Boolean).length;
6084
+ }
6085
+ function responseIsNoindex(response, body) {
6086
+ if ((response.headers.get("x-robots-tag") ?? "").toLowerCase().includes("noindex")) return true;
6087
+ return [...body.matchAll(/<meta\s+[^>]*>/giu)].some((match) => {
6088
+ const tag = match[0];
6089
+ const name = tag.match(/\bname\s*=\s*["']([^"']+)["']/iu)?.[1];
6090
+ const content = tag.match(/\bcontent\s*=\s*["']([^"']+)["']/iu)?.[1];
6091
+ return name?.toLowerCase() === "robots" && /\bnoindex\b/iu.test(content ?? "");
6092
+ });
6093
+ }
6094
+ function markdownQuality(markdown, page) {
6095
+ const introProbe = (page.contentSample?.replace(/\s+/gu, " ").trim())?.split(" ").slice(0, 10).join(" ");
6096
+ const normalizedMarkdown = markdown.replace(/\s+/gu, " ");
6097
+ const codeFences = markdown.match(/^```/gmu)?.length ?? 0;
6098
+ const repeatedLines = [...markdown.matchAll(/^(.{12,})$/gmu)].map((match) => match[1]?.trim()).filter((line) => Boolean(line)).filter((line, index, lines) => lines.indexOf(line) !== index).length;
6099
+ const wordCount = bodyWordCount(markdown);
6100
+ const sourceWordCount = page.wordCount ?? 0;
6101
+ return {
6102
+ frontmatterTitle: /^---[\s\S]*?^title:\s*.+$/mu.test(markdown),
6103
+ h1Count: markdown.match(/^#\s+\S.+$/gmu)?.length ?? 0,
6104
+ codeFenceBalanced: codeFences % 2 === 0,
6105
+ tableRows: markdown.match(/^\s*\|.*\|\s*$/gmu)?.length ?? 0,
6106
+ links: markdown.match(/\[[^\]]+\]\([^)]+\)/gu)?.length ?? 0,
6107
+ wordCount,
6108
+ rawHtmlTags: markdown.match(/<(?:div|span|section|article|nav|button)\b/giu)?.length ?? 0,
6109
+ rawSvgTags: markdown.match(/<svg\b/giu)?.length ?? 0,
6110
+ rawScriptTags: markdown.match(/<script\b/giu)?.length ?? 0,
6111
+ rawStyleTags: markdown.match(/<style\b/giu)?.length ?? 0,
6112
+ suspiciousConcatenations: markdown.match(/\b[a-z]{4,}[A-Z][A-Za-z]{3,}\b/gu)?.length ?? 0,
6113
+ repeatedLines,
6114
+ sourceWordCount,
6115
+ wordRetentionRatio: sourceWordCount > 0 ? Math.round(wordCount / sourceWordCount * 1e3) / 1e3 : null,
6116
+ introductoryCopyRetained: introProbe ? normalizedMarkdown.includes(introProbe) : null,
6117
+ navigationOnly: bodyWordCount(markdown) < 25
6118
+ };
6119
+ }
6120
+ function combinedSignal(timeoutMs, signal) {
6121
+ const controller = new AbortController();
6122
+ const abort = () => controller.abort();
6123
+ const timer = setTimeout(abort, timeoutMs);
6124
+ if (signal?.aborted) controller.abort();
6125
+ else signal?.addEventListener("abort", abort, { once: true });
6126
+ return {
6127
+ signal: controller.signal,
6128
+ cleanup: () => {
6129
+ clearTimeout(timer);
6130
+ signal?.removeEventListener("abort", abort);
6131
+ }
6132
+ };
6133
+ }
6134
+ async function readBoundedText(response) {
6135
+ if (!response.body) return "";
6136
+ const reader = response.body.getReader();
6137
+ const chunks = [];
6138
+ let size = 0;
6139
+ try {
6140
+ while (true) {
6141
+ const result = await reader.read();
6142
+ if (result.done) break;
6143
+ size += result.value.byteLength;
6144
+ if (size > MAX_BODY_BYTES) throw new Error(`Response exceeds ${MAX_BODY_BYTES} bytes.`);
6145
+ chunks.push(result.value);
6146
+ }
6147
+ } finally {
6148
+ await reader.cancel().catch(() => void 0);
6149
+ }
6150
+ return Buffer.concat(chunks).toString("utf8");
6151
+ }
6152
+ async function fetchRepresentation(input) {
6153
+ const controller = combinedSignal(input.timeoutMs, input.signal);
6154
+ try {
6155
+ const response = await input.fetch(input.url, {
6156
+ profile: "bot",
6157
+ redirect: "follow",
6158
+ headers: { accept: input.accept },
6159
+ signal: controller.signal
6160
+ });
6161
+ const body = await readBoundedText(response);
6162
+ const link = linkEntries(response.headers.get("link") ?? void 0, input.url);
6163
+ const tokens = Number(response.headers.get("x-markdown-tokens"));
6164
+ return {
6165
+ observation: {
6166
+ requestedUrl: input.url,
6167
+ finalUrl: response.url || input.url,
6168
+ status: response.status,
6169
+ contentType: response.headers.get("content-type") ?? void 0,
6170
+ bytes: Buffer.byteLength(body),
6171
+ sha256: sha256(body),
6172
+ canonicalUrl: link.find((entry) => entry.rel.includes("canonical"))?.url,
6173
+ alternateUrl: link.find((entry) => entry.rel.includes("alternate") && entry.type === "text/markdown")?.url,
6174
+ varyAccept: (response.headers.get("vary") ?? "").split(",").some((value) => value.trim().toLowerCase() === "accept"),
6175
+ ...Number.isInteger(tokens) && tokens >= 0 ? { markdownTokens: tokens } : {},
6176
+ contentSignal: response.headers.get("content-signal") ?? void 0
6177
+ },
6178
+ body
6179
+ };
6180
+ } catch (error) {
6181
+ return { observation: {
6182
+ requestedUrl: input.url,
6183
+ varyAccept: false,
6184
+ error: error instanceof Error ? error.message : String(error)
6185
+ } };
6186
+ } finally {
6187
+ controller.cleanup();
6188
+ }
6189
+ }
6190
+ async function inspectMarkdownPage(input) {
6191
+ const advertisedUrls = [...new Set(input.page.markdownAlternates ?? [])].sort();
6192
+ const httpAlternateUrls = linkEntries(headerValue$1(input.page.responseHeaders, "link"), input.page.finalUrl).filter((entry) => entry.rel.includes("alternate") && entry.type === "text/markdown").map((entry) => entry.url).sort();
6193
+ const observation = {
6194
+ htmlUrl: input.page.finalUrl,
6195
+ advertisedUrls,
6196
+ htmlAlternateUnique: advertisedUrls.length === 1,
6197
+ httpAlternateUrls,
6198
+ explicitMatchesNegotiated: null,
6199
+ repeatedHashStable: null,
6200
+ markdownCanonicalMatchesHtml: null
6201
+ };
6202
+ if (advertisedUrls.length !== 1) return observation;
6203
+ const explicitUrl = advertisedUrls[0];
6204
+ const [explicit, negotiated, repeated] = await Promise.all([
6205
+ fetchRepresentation({
6206
+ url: explicitUrl,
6207
+ accept: "text/markdown",
6208
+ timeoutMs: input.timeoutMs,
6209
+ fetch: input.fetch,
6210
+ signal: input.signal
6211
+ }),
6212
+ fetchRepresentation({
6213
+ url: input.page.finalUrl,
6214
+ accept: "text/markdown",
6215
+ timeoutMs: input.timeoutMs,
6216
+ fetch: input.fetch,
6217
+ signal: input.signal
6218
+ }),
6219
+ fetchRepresentation({
6220
+ url: explicitUrl,
6221
+ accept: "text/markdown",
6222
+ timeoutMs: input.timeoutMs,
6223
+ fetch: input.fetch,
6224
+ signal: input.signal
6225
+ })
6226
+ ]);
6227
+ observation.explicit = explicit.observation;
6228
+ observation.negotiated = negotiated.observation;
6229
+ observation.repeated = repeated.observation;
6230
+ observation.explicitMatchesNegotiated = explicit.observation.sha256 && negotiated.observation.sha256 ? explicit.observation.sha256 === negotiated.observation.sha256 : null;
6231
+ observation.repeatedHashStable = explicit.observation.sha256 && repeated.observation.sha256 ? explicit.observation.sha256 === repeated.observation.sha256 : null;
6232
+ observation.markdownCanonicalMatchesHtml = sameDocument(explicit.observation.canonicalUrl, input.page.finalUrl);
6233
+ if (explicit.body) observation.quality = markdownQuality(explicit.body, input.page);
6234
+ return observation;
6235
+ }
6236
+ async function fetchText(input) {
6237
+ const controller = combinedSignal(input.timeoutMs, input.signal);
6238
+ try {
6239
+ const response = await input.fetch(input.url, {
6240
+ profile: "bot",
6241
+ redirect: input.redirect ?? "follow",
6242
+ headers: input.accept ? { accept: input.accept } : void 0,
6243
+ signal: controller.signal
6244
+ });
6245
+ return {
6246
+ response,
6247
+ body: await readBoundedText(response)
6248
+ };
6249
+ } finally {
6250
+ controller.cleanup();
6251
+ }
6252
+ }
6253
+ function safeError(error) {
6254
+ return error instanceof Error ? error.message : String(error);
6255
+ }
6256
+ async function inspectAgentSkills(input) {
6257
+ const indexUrl = new URL("/.well-known/agent-skills/index.json", input.origin).toString();
6258
+ try {
6259
+ const { response, body } = await fetchText({
6260
+ url: indexUrl,
6261
+ timeoutMs: input.timeoutMs,
6262
+ fetch: input.fetch,
6263
+ signal: input.signal,
6264
+ accept: "application/json"
6265
+ });
6266
+ const contentType = response.headers.get("content-type") ?? void 0;
6267
+ const cors = response.headers.get("access-control-allow-origin") ?? void 0;
6268
+ if (response.status < 200 || response.status >= 300) return {
6269
+ indexUrl,
6270
+ status: response.status,
6271
+ contentType,
6272
+ validIndex: false,
6273
+ skills: []
6274
+ };
6275
+ const parsed = JSON.parse(body);
6276
+ const entries = Array.isArray(parsed.skills) ? parsed.skills.slice(0, MAX_SKILLS) : [];
6277
+ const skills = await Promise.all(entries.map(async (entry) => {
6278
+ const name = typeof entry.name === "string" ? entry.name : void 0;
6279
+ const declaredDigest = typeof entry.digest === "string" ? entry.digest : void 0;
6280
+ const relativeUrl = typeof entry.url === "string" ? entry.url : void 0;
6281
+ if (!relativeUrl) return {
6282
+ name,
6283
+ declaredDigest,
6284
+ digestMatches: null,
6285
+ frontmatterValid: null,
6286
+ sameOrigin: false,
6287
+ error: "Skill URL is missing."
6288
+ };
6289
+ const url = new URL(relativeUrl, indexUrl).toString();
6290
+ const sameOrigin = new URL(url).origin === new URL(input.origin).origin;
6291
+ if (!sameOrigin) return {
6292
+ name,
6293
+ url,
6294
+ declaredDigest,
6295
+ digestMatches: null,
6296
+ frontmatterValid: null,
6297
+ sameOrigin,
6298
+ error: "Skill URL is off origin."
6299
+ };
6300
+ try {
6301
+ const skill = await fetchText({
6302
+ url,
6303
+ timeoutMs: input.timeoutMs,
6304
+ fetch: input.fetch,
6305
+ signal: input.signal,
6306
+ accept: "text/markdown,text/plain;q=0.9"
6307
+ });
6308
+ const observedDigest = `sha256:${sha256(skill.body)}`;
6309
+ const frontmatterValid = /^---\s*\n[\s\S]*?^name:\s*\S.+$[\s\S]*?^description:\s*\S.+$[\s\S]*?^---\s*$/mu.test(skill.body);
6310
+ return {
6311
+ name,
6312
+ url,
6313
+ status: skill.response.status,
6314
+ contentType: skill.response.headers.get("content-type") ?? void 0,
6315
+ cors: skill.response.headers.get("access-control-allow-origin") ?? void 0,
6316
+ declaredDigest,
6317
+ observedDigest,
6318
+ digestMatches: declaredDigest ? declaredDigest === observedDigest : null,
6319
+ frontmatterValid,
6320
+ sameOrigin
6321
+ };
6322
+ } catch (error) {
6323
+ return {
6324
+ name,
6325
+ url,
6326
+ declaredDigest,
6327
+ digestMatches: null,
6328
+ frontmatterValid: null,
6329
+ sameOrigin,
6330
+ error: safeError(error)
6331
+ };
6332
+ }
6333
+ }));
6334
+ return {
6335
+ indexUrl,
6336
+ status: response.status,
6337
+ contentType,
6338
+ cors,
6339
+ validIndex: typeof parsed.$schema === "string" && Array.isArray(parsed.skills),
6340
+ skills
6341
+ };
6342
+ } catch (error) {
6343
+ return {
6344
+ indexUrl,
6345
+ validIndex: false,
6346
+ skills: [],
6347
+ error: safeError(error)
6348
+ };
6349
+ }
6350
+ }
6351
+ function markdownLinks(value, base) {
6352
+ const links = [];
6353
+ const invalidLinks = [];
6354
+ for (const match of value.matchAll(/\[([^\u005d]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/gu)) {
6355
+ if (!match[1] || !match[2]) continue;
6356
+ try {
6357
+ links.push({
6358
+ label: match[1],
6359
+ url: new URL(match[2], base).toString()
6360
+ });
6361
+ } catch {
6362
+ invalidLinks.push(match[2]);
6363
+ }
6364
+ }
6365
+ return {
6366
+ links,
6367
+ invalidLinks
6368
+ };
6369
+ }
6370
+ async function inspectLlmsTxt(input) {
6371
+ const url = new URL("/llms.txt", input.origin).toString();
6372
+ try {
6373
+ const [first, second] = await Promise.all([fetchText({
6374
+ url,
6375
+ timeoutMs: input.timeoutMs,
6376
+ fetch: input.fetch,
6377
+ signal: input.signal,
6378
+ accept: "text/plain,text/markdown;q=0.9"
6379
+ }), fetchText({
6380
+ url,
6381
+ timeoutMs: input.timeoutMs,
6382
+ fetch: input.fetch,
6383
+ signal: input.signal,
6384
+ accept: "text/plain,text/markdown;q=0.9"
6385
+ })]);
6386
+ const exists = first.response.status >= 200 && first.response.status < 300;
6387
+ const parsed = markdownLinks(first.body, url);
6388
+ const links = parsed.links.slice(0, MAX_LLMS_LINKS);
6389
+ const linkLimitReached = parsed.links.length > links.length;
6390
+ const counts = /* @__PURE__ */ new Map();
6391
+ for (const link of links) counts.set(link.url, (counts.get(link.url) ?? 0) + 1);
6392
+ const duplicateLinks = [...counts].filter(([, count]) => count > 1).map(([link]) => link).sort();
6393
+ const crawlRoutes = new Set(input.pages.map((page) => normalizedDocumentUrl(page.finalUrl)));
6394
+ const linkObservations = await Promise.all(links.map(async (link) => {
6395
+ const sameOrigin = new URL(link.url).origin === new URL(input.origin).origin;
6396
+ try {
6397
+ const target = await fetchText({
6398
+ url: link.url,
6399
+ timeoutMs: input.timeoutMs,
6400
+ fetch: input.fetch,
6401
+ signal: input.signal
6402
+ });
6403
+ const indexableTarget = sameOrigin && target.response.status >= 200 && target.response.status < 300 ? !responseIsNoindex(target.response, target.body) : void 0;
6404
+ const finalUrl = target.response.url || void 0;
6405
+ return {
6406
+ ...link,
6407
+ sameOrigin,
6408
+ status: target.response.status,
6409
+ finalUrl,
6410
+ redirected: target.response.redirected,
6411
+ ...indexableTarget === void 0 ? {} : { indexableTarget }
6412
+ };
6413
+ } catch (error) {
6414
+ return {
6415
+ ...link,
6416
+ sameOrigin,
6417
+ redirected: false,
6418
+ error: safeError(error)
6419
+ };
6420
+ }
6421
+ }));
6422
+ const linkedCrawlRoutes = new Set(linkObservations.filter((link) => link.sameOrigin && !new URL(link.url).pathname.startsWith("/.well-known/") && !new URL(link.url).pathname.endsWith(".md")).map((link) => normalizedDocumentUrl(link.url)));
6423
+ return {
6424
+ url,
6425
+ exists,
6426
+ status: first.response.status,
6427
+ contentType: first.response.headers.get("content-type") ?? void 0,
6428
+ bytes: Buffer.byteLength(first.body),
6429
+ sha256: sha256(first.body),
6430
+ repeatedHashStable: sha256(first.body) === sha256(second.body),
6431
+ headingCount: first.body.match(/^#{1,2}\s+\S/gmu)?.length ?? 0,
6432
+ totalParsedLinks: parsed.links.length,
6433
+ linkLimitReached,
6434
+ links: linkObservations,
6435
+ invalidLinks: parsed.invalidLinks.sort(),
6436
+ duplicateLinks,
6437
+ offSiteLinks: linkObservations.filter((link) => !link.sameOrigin).map((link) => link.url).sort(),
6438
+ redirectedLinks: linkObservations.filter((link) => link.redirected).map((link) => link.url).sort(),
6439
+ nonIndexableLinks: linkObservations.filter((link) => link.indexableTarget === false).map((link) => link.url).sort(),
6440
+ missingCrawlRoutes: [...linkedCrawlRoutes].filter((route) => !crawlRoutes.has(route)).sort(),
6441
+ oversized: Buffer.byteLength(first.body) > MAX_CURATED_LLMS_BYTES
6442
+ };
6443
+ } catch (error) {
6444
+ return {
6445
+ url,
6446
+ exists: false,
6447
+ repeatedHashStable: null,
6448
+ headingCount: 0,
6449
+ totalParsedLinks: 0,
6450
+ linkLimitReached: false,
6451
+ links: [],
6452
+ invalidLinks: [],
6453
+ duplicateLinks: [],
6454
+ offSiteLinks: [],
6455
+ redirectedLinks: [],
6456
+ nonIndexableLinks: [],
6457
+ missingCrawlRoutes: [],
6458
+ oversized: false,
6459
+ error: safeError(error)
6460
+ };
6461
+ }
6462
+ }
6463
+ async function inspectRouteManifest(input) {
6464
+ const url = new URL("/agent-routes.json", input.origin).toString();
6465
+ try {
6466
+ const result = await fetchText({
6467
+ url,
6468
+ timeoutMs: input.timeoutMs,
6469
+ fetch: input.fetch,
6470
+ signal: input.signal,
6471
+ accept: "application/json"
6472
+ });
6473
+ const parsed = JSON.parse(result.body);
6474
+ const declared = Array.isArray(parsed.pages) ? parsed.pages : [];
6475
+ const declaredHtmlRoutes = declared.map((page) => page.htmlPath).filter((path) => typeof path === "string").sort();
6476
+ const declaredMarkdownRoutes = declared.map((page) => page.markdownPath).filter((path) => typeof path === "string").sort();
6477
+ const crawledHtmlRoutes = new Set(input.pages.map((page) => new URL(page.finalUrl).pathname.replace(/\/$/u, "") || "/"));
6478
+ const observedMarkdownRoutes = new Set(input.observations.flatMap((page) => page.advertisedUrls.map((value) => new URL(value).pathname)));
6479
+ return {
6480
+ url,
6481
+ status: result.response.status,
6482
+ valid: Array.isArray(parsed.pages),
6483
+ declaredHtmlRoutes,
6484
+ declaredMarkdownRoutes,
6485
+ missingHtmlRoutes: declaredHtmlRoutes.filter((path) => !crawledHtmlRoutes.has(path.replace(/\/$/u, "") || "/")).sort(),
6486
+ missingMarkdownRoutes: declaredMarkdownRoutes.filter((path) => !observedMarkdownRoutes.has(path)).sort(),
6487
+ orphanMarkdownRoutes: [...observedMarkdownRoutes].filter((path) => !declaredMarkdownRoutes.includes(path)).sort()
6488
+ };
6489
+ } catch (error) {
6490
+ return {
6491
+ url,
6492
+ valid: false,
6493
+ declaredHtmlRoutes: [],
6494
+ declaredMarkdownRoutes: [],
6495
+ missingHtmlRoutes: [],
6496
+ missingMarkdownRoutes: [],
6497
+ orphanMarkdownRoutes: [],
6498
+ error: safeError(error)
6499
+ };
6500
+ }
6501
+ }
6502
+ async function inspectProtocolVariant(input) {
6503
+ try {
6504
+ const result = await fetchText({
6505
+ url: input.url,
6506
+ timeoutMs: input.timeoutMs,
6507
+ fetch: input.fetch,
6508
+ signal: input.signal,
6509
+ redirect: "manual"
6510
+ });
6511
+ return {
6512
+ status: result.response.status,
6513
+ location: result.response.headers.get("location") ?? void 0
6514
+ };
6515
+ } catch (error) {
6516
+ return { error: safeError(error) };
6517
+ }
6518
+ }
6519
+ async function collectAgentDiscovery(input) {
6520
+ const origin = new URL(input.startUrl).origin;
6521
+ const pages = input.pages.filter((page) => page.status >= 200 && page.status < 300 && /^\s*(?:text\/html|application\/xhtml\+xml)\b/iu.test(page.contentType ?? "")).sort((left, right) => left.finalUrl.localeCompare(right.finalUrl));
6522
+ const queue = new PQueue({ concurrency: input.concurrency ?? 4 });
6523
+ const observations = await Promise.all(pages.map((page) => queue.add(() => inspectMarkdownPage({
6524
+ page,
6525
+ timeoutMs: input.timeoutMs,
6526
+ fetch: input.fetch,
6527
+ signal: input.signal
6528
+ }))));
6529
+ const [agentSkills, llmsTxt, routeManifest] = await Promise.all([
6530
+ inspectAgentSkills({
6531
+ ...input,
6532
+ origin
6533
+ }),
6534
+ inspectLlmsTxt({
6535
+ ...input,
6536
+ origin,
6537
+ pages
6538
+ }),
6539
+ inspectRouteManifest({
6540
+ ...input,
6541
+ origin,
6542
+ pages,
6543
+ observations
6544
+ })
6545
+ ]);
6546
+ const qZero = await fetchRepresentation({
6547
+ url: input.startUrl,
6548
+ accept: "text/markdown;q=0,text/html;q=1",
6549
+ timeoutMs: input.timeoutMs,
6550
+ fetch: input.fetch,
6551
+ signal: input.signal
6552
+ });
6553
+ const start = new URL(input.startUrl);
6554
+ const httpUrl = new URL(start);
6555
+ httpUrl.protocol = "http:";
6556
+ const wwwUrl = new URL(start);
6557
+ wwwUrl.hostname = start.hostname.startsWith("www.") ? start.hostname.slice(4) : `www.${start.hostname}`;
6558
+ const [http, www] = await Promise.all([inspectProtocolVariant({
6559
+ ...input,
6560
+ url: httpUrl.toString()
6561
+ }), inspectProtocolVariant({
6562
+ ...input,
6563
+ url: wwwUrl.toString()
6564
+ })]);
6565
+ const httpLocation = http.location ? new URL(http.location, httpUrl).toString() : void 0;
6566
+ const wwwLocation = www.location ? new URL(www.location, wwwUrl).toString() : void 0;
6567
+ const qZeroContentType = qZero.observation.contentType;
6568
+ const advertisedPages = observations.filter((observation) => observation.htmlAlternateUnique).length;
6569
+ const evaluatedPages = observations.filter((observation) => observation.explicit?.status !== void 0).length;
6570
+ const warnings = [...pages.length !== input.pages.length ? [`Agent representations were evaluated for ${pages.length} successful HTML pages from ${input.pages.length} retained documents.`] : [], ...routeManifest.valid ? [] : ["No valid public agent route manifest was available for orphan checks."]].sort();
6571
+ const htmlContentSignals = pages.map((page) => headerValue$1(page.responseHeaders, "content-signal")).filter((value) => Boolean(value));
6572
+ const markdownContentSignals = observations.map((observation) => observation.explicit?.contentSignal).filter((value) => Boolean(value));
6573
+ const contentSignalValues = [.../* @__PURE__ */ new Set([...htmlContentSignals, ...markdownContentSignals])].sort();
6574
+ return {
6575
+ profile: "content",
6576
+ profileApplicability: {
6577
+ content: {
6578
+ status: "evaluated",
6579
+ reason: "This site publishes documents, so access, representations, discovery, identity, and extraction quality were evaluated."
6580
+ },
6581
+ api: {
6582
+ status: "notApplicable",
6583
+ reason: "No public API surface was selected for this content-site run."
6584
+ },
6585
+ application: {
6586
+ status: "notApplicable",
6587
+ reason: "A local MCP product does not make this website a public remote agent endpoint."
6588
+ },
6589
+ commerce: {
6590
+ status: "notApplicable",
6591
+ reason: "No product checkout or transactional surface was selected."
6592
+ }
6593
+ },
6594
+ dataStatus: pages.length === 0 ? "unavailable" : evaluatedPages === pages.length ? "complete" : "partial",
6595
+ markdownAlternates: {
6596
+ eligibleHtmlPages: pages.length,
6597
+ advertisedPages,
6598
+ evaluatedPages,
6599
+ exactByteMatches: observations.filter((observation) => observation.explicitMatchesNegotiated).length,
6600
+ stableResponses: observations.filter((observation) => observation.repeatedHashStable).length,
6601
+ pages: observations
6602
+ },
6603
+ contentNegotiation: {
6604
+ qZeroHonoured: qZeroContentType !== void 0 ? !/^\s*text\/markdown\b/iu.test(qZeroContentType) : null,
6605
+ qZeroStatus: qZero.observation.status,
6606
+ qZeroContentType,
6607
+ error: qZero.observation.error
6608
+ },
6609
+ routeManifest,
6610
+ agentSkills,
6611
+ llmsTxt,
6612
+ contentSignals: {
6613
+ htmlValues: [...new Set(htmlContentSignals)].sort(),
6614
+ markdownValues: [...new Set(markdownContentSignals)].sort(),
6615
+ missingHtmlPages: pages.length - htmlContentSignals.length,
6616
+ missingMarkdownPages: observations.length - markdownContentSignals.length,
6617
+ consistent: pages.length > 0 && observations.length > 0 ? contentSignalValues.length === 1 && htmlContentSignals.length === pages.length && markdownContentSignals.length === observations.length : null
6618
+ },
6619
+ protocolVariants: {
6620
+ http: {
6621
+ url: httpUrl.toString(),
6622
+ status: http.status,
6623
+ location: httpLocation,
6624
+ permanentRedirectToHttps: http.status !== void 0 ? [301, 308].includes(http.status) && Boolean(httpLocation?.startsWith("https://")) : null,
6625
+ error: http.error
6626
+ },
6627
+ www: {
6628
+ url: wwwUrl.toString(),
6629
+ status: www.status,
6630
+ location: wwwLocation,
6631
+ redirectsToPreferredHost: www.status !== void 0 ? [301, 308].includes(www.status) && Boolean(wwwLocation && new URL(wwwLocation).hostname === start.hostname && new URL(wwwLocation).protocol === "https:") : null,
6632
+ error: www.error
6633
+ },
6634
+ hstsOnStartPage: pages.find((page) => normalizedDocumentUrl(page.finalUrl) === normalizedDocumentUrl(input.startUrl))?.hasHsts ?? null
6635
+ },
6636
+ warnings
6637
+ };
6638
+ }
6639
+ //#endregion
6640
+ //#region packages/core/dist/analyze/crawler/agent-readiness.js
6641
+ function check$1(section, input) {
6642
+ return {
6643
+ section,
6644
+ ...input
6645
+ };
6646
+ }
6647
+ function section$1(id, title, checks) {
6648
+ return {
6649
+ id,
6650
+ title,
6651
+ checks
6652
+ };
6653
+ }
6654
+ function failedMarkdownUrls(discovery) {
6655
+ return discovery.markdownAlternates.pages.filter((page) => !page.htmlAlternateUnique || page.httpAlternateUrls.length !== 1 || page.explicit?.status !== 200 || !/^\s*text\/markdown\b/iu.test(page.explicit.contentType ?? "") || page.explicitMatchesNegotiated !== true || page.repeatedHashStable !== true || page.markdownCanonicalMatchesHtml !== true || page.explicit?.varyAccept !== true || page.negotiated?.varyAccept !== true).map((page) => page.htmlUrl);
6656
+ }
6657
+ function qualityFailureUrls(discovery) {
6658
+ return discovery.markdownAlternates.pages.filter((page) => {
6659
+ const quality = page.quality;
6660
+ if (!quality) return true;
6661
+ return !quality.frontmatterTitle || quality.h1Count !== 1 || !quality.codeFenceBalanced || quality.rawHtmlTags > 0 || quality.rawSvgTags > 0 || quality.rawScriptTags > 0 || quality.rawStyleTags > 0 || quality.navigationOnly || quality.repeatedLines > 0 || quality.wordRetentionRatio !== null && quality.wordRetentionRatio < .4 || quality.introductoryCopyRetained === false;
6662
+ }).map((page) => page.htmlUrl);
6663
+ }
6664
+ function profileChecks(discovery) {
6665
+ return [
6666
+ "api",
6667
+ "application",
6668
+ "commerce"
6669
+ ].map((profile) => check$1("profile", {
6670
+ id: `profile-${profile}`,
6671
+ status: "notApplicable",
6672
+ title: `${profile[0]?.toUpperCase()}${profile.slice(1)} checks are not applicable`,
6673
+ plainEnglish: discovery.profileApplicability[profile].reason,
6674
+ action: "Choose this profile only when the site exposes that capability publicly.",
6675
+ evidence: {
6676
+ profile,
6677
+ selectedProfile: discovery.profile
6678
+ }
6679
+ }));
6680
+ }
6681
+ function summariseChecks(checks) {
6682
+ const count = (status) => checks.filter((item) => item.status === status).length;
6683
+ return {
6684
+ checks: checks.length,
6685
+ passed: count("pass"),
6686
+ warnings: count("warning"),
6687
+ failed: count("fail"),
6688
+ unknown: count("unknown"),
6689
+ information: count("info"),
6690
+ notApplicable: count("notApplicable")
6691
+ };
6692
+ }
6693
+ function markdownChecks(discovery) {
6694
+ const markdown = discovery.markdownAlternates;
6695
+ const failedUrls = failedMarkdownUrls(discovery);
6696
+ const qualityUrls = qualityFailureUrls(discovery);
6697
+ const coverageComplete = markdown.eligibleHtmlPages > 0 && markdown.advertisedPages === markdown.eligibleHtmlPages && markdown.evaluatedPages === markdown.eligibleHtmlPages;
6698
+ const bytesMatch = markdown.eligibleHtmlPages > 0 && markdown.exactByteMatches === markdown.eligibleHtmlPages;
6699
+ const stable = markdown.eligibleHtmlPages > 0 && markdown.stableResponses === markdown.eligibleHtmlPages;
6700
+ const tokenHeaders = markdown.pages.filter((page) => page.explicit?.bytes !== void 0 && page.explicit?.markdownTokens !== void 0 && page.explicit.markdownTokens === Math.ceil(page.explicit.bytes / 4) && page.explicit.markdownTokens === page.negotiated?.markdownTokens).length;
6701
+ return [
6702
+ check$1("representations", {
6703
+ id: "markdown-coverage",
6704
+ status: markdown.eligibleHtmlPages === 0 ? "unknown" : coverageComplete ? "pass" : "fail",
6705
+ title: coverageComplete ? "Every successful HTML page advertises one Markdown alternative" : "Markdown alternative coverage is incomplete",
6706
+ plainEnglish: `${markdown.advertisedPages} of ${markdown.eligibleHtmlPages} successful HTML pages advertised one Markdown alternative, and ${markdown.evaluatedPages} were fetched.`,
6707
+ action: coverageComplete ? "Keep route generation tied to the same deterministic page manifest." : "Add one text/markdown alternate for each public HTML page and make every advertised URL return successfully.",
6708
+ evidence: {
6709
+ eligibleHtmlPages: markdown.eligibleHtmlPages,
6710
+ advertisedPages: markdown.advertisedPages,
6711
+ evaluatedPages: markdown.evaluatedPages
6712
+ },
6713
+ urls: failedUrls.slice(0, 25)
6714
+ }),
6715
+ check$1("representations", {
6716
+ id: "markdown-token-estimates",
6717
+ status: markdown.evaluatedPages === 0 ? "unknown" : tokenHeaders === markdown.evaluatedPages ? "pass" : "warning",
6718
+ title: tokenHeaders === markdown.evaluatedPages ? "Every Markdown response includes the same token estimate" : "Some Markdown responses are missing a stable token estimate",
6719
+ plainEnglish: `${tokenHeaders} of ${markdown.evaluatedPages} evaluated pages returned matching X-Markdown-Tokens values on the explicit and negotiated responses. The value is a quick size estimate, not an exact model-specific token count.`,
6720
+ action: "Generate the estimate from the stored Markdown bytes and return the same value for explicit and negotiated responses.",
6721
+ urls: markdown.pages.filter((page) => page.explicit?.markdownTokens === void 0 || page.explicit.markdownTokens !== page.negotiated?.markdownTokens).map((page) => page.htmlUrl).slice(0, 25)
6722
+ }),
6723
+ check$1("representations", {
6724
+ id: "markdown-negotiation",
6725
+ status: markdown.eligibleHtmlPages === 0 ? "unknown" : bytesMatch && discovery.contentNegotiation.qZeroHonoured ? "pass" : "fail",
6726
+ title: bytesMatch && discovery.contentNegotiation.qZeroHonoured ? "Explicit and negotiated Markdown use the same bytes" : "Content negotiation does not match the explicit Markdown contract",
6727
+ plainEnglish: `${markdown.exactByteMatches} of ${markdown.eligibleHtmlPages} pages returned identical explicit and negotiated Markdown. A request that refuses Markdown ${discovery.contentNegotiation.qZeroHonoured ? "received HTML" : "did not produce confirmed HTML evidence"}.`,
6728
+ action: "Use one stored Markdown artifact for both routes, honour Accept q-values, and send Vary: Accept on negotiated responses.",
6729
+ evidence: {
6730
+ exactByteMatches: markdown.exactByteMatches,
6731
+ qZero: discovery.contentNegotiation
6732
+ },
6733
+ urls: failedUrls.slice(0, 25)
6734
+ }),
6735
+ check$1("representations", {
6736
+ id: "markdown-determinism",
6737
+ status: markdown.eligibleHtmlPages === 0 ? "unknown" : stable ? "pass" : "fail",
6738
+ title: stable ? "Repeated Markdown responses are stable" : "Repeated Markdown responses changed during the audit",
6739
+ plainEnglish: `${markdown.stableResponses} of ${markdown.eligibleHtmlPages} repeated explicit responses kept the same SHA-256 digest.`,
6740
+ action: "Generate Markdown during the build and remove runtime rewriting, timestamps, or random output.",
6741
+ evidence: { stableResponses: markdown.stableResponses },
6742
+ urls: failedUrls.slice(0, 25)
6743
+ }),
6744
+ check$1("representations", {
6745
+ id: "markdown-quality",
6746
+ status: markdown.evaluatedPages === 0 ? "unknown" : qualityUrls.length === 0 ? "pass" : "warning",
6747
+ title: qualityUrls.length === 0 ? "Markdown keeps the useful document structure cleanly" : "Some Markdown alternatives need an extraction review",
6748
+ plainEnglish: qualityUrls.length === 0 ? "The evaluated alternatives retained one H1, frontmatter titles, balanced code fences, useful copy, and no leaked SVG, script, style, or layout tags." : `${qualityUrls.length} Markdown alternative${qualityUrls.length === 1 ? "" : "s"} lost important structure, looked navigation-only, or leaked presentation markup.`,
6749
+ action: "Open the affected Markdown directly and fix the shared converter or component exclusion rules rather than patching generated files.",
6750
+ urls: qualityUrls.slice(0, 25)
6751
+ })
6752
+ ];
6753
+ }
6754
+ function discoveryChecks(discovery) {
6755
+ const skills = discovery.agentSkills;
6756
+ const skillsValid = skills.validIndex && skills.skills.length > 0 && skills.skills.every((skill) => skill.sameOrigin && skill.status === 200 && /^\s*text\/markdown\b/iu.test(skill.contentType ?? "") && Boolean(skill.cors) && skill.digestMatches === true && skill.frontmatterValid === true) && Boolean(skills.cors);
6757
+ const llms = discovery.llmsTxt;
6758
+ const llmsBroken = llms.links.filter((link) => !link.status || link.status < 200 || link.status >= 400);
6759
+ const llmsValid = llms.exists && /^\s*(?:text\/plain|text\/markdown)\b/iu.test(llms.contentType ?? "") && llms.headingCount > 0 && llms.links.length > 0 && !llms.linkLimitReached && !llms.oversized && llms.invalidLinks.length === 0 && llms.duplicateLinks.length === 0 && llms.redirectedLinks.length === 0 && llms.nonIndexableLinks.length === 0 && llms.missingCrawlRoutes.length === 0 && llmsBroken.length === 0 && llms.repeatedHashStable === true;
6760
+ return [
6761
+ check$1("discovery", {
6762
+ id: "agent-skills",
6763
+ status: skillsValid ? "pass" : skills.status === 404 ? "info" : "warning",
6764
+ title: skillsValid ? "Agent Skills discovery is valid and digest verified" : "Agent Skills discovery is absent or needs attention",
6765
+ plainEnglish: skillsValid ? `${skills.skills.length} published skill${skills.skills.length === 1 ? "" : "s"} matched the declared SHA-256 digest, valid SKILL.md frontmatter, Markdown content type, and cross-origin access policy.` : "Agent Skills is optional for a content site, but a published index should resolve same-origin Markdown skill files, allow intended cross-origin clients, and verify their declared bytes.",
6766
+ action: "If you publish Agent Skills, keep the discovery index and SHA-256 digests generated from the exact deployed skill bytes.",
6767
+ evidence: skills
6768
+ }),
6769
+ check$1("discovery", {
6770
+ id: "llms-txt",
6771
+ status: llms.exists ? llmsValid ? "pass" : "warning" : "info",
6772
+ title: llms.exists ? llmsValid ? "llms.txt is short, stable, and its links resolve" : "llms.txt exists but needs a content or link review" : "llms.txt is not published",
6773
+ plainEnglish: llms.exists ? `${llms.links.length} declared links were checked. ${llms.invalidLinks.length} were malformed, ${llms.duplicateLinks.length} were duplicated, ${llms.redirectedLinks.length} redirected, ${llms.nonIndexableLinks.length} reached non-indexable pages, ${llmsBroken.length} did not resolve, and ${llms.missingCrawlRoutes.length} were missing from the crawl inventory. ${llms.offSiteLinks.length} linked to other sites.` : "llms.txt is optional and its absence is not a search ranking problem.",
6774
+ action: llms.exists ? "Keep the file curated, deterministic, and limited to useful entry points whose links still resolve." : "Add it only when an intended consumer uses it. Do not treat it as a Google ranking requirement.",
6775
+ evidence: {
6776
+ status: llms.status,
6777
+ contentType: llms.contentType,
6778
+ bytes: llms.bytes,
6779
+ oversized: llms.oversized,
6780
+ totalParsedLinks: llms.totalParsedLinks,
6781
+ linkLimitReached: llms.linkLimitReached,
6782
+ links: llms.links.length,
6783
+ invalidLinks: llms.invalidLinks,
6784
+ duplicateLinks: llms.duplicateLinks,
6785
+ offSiteLinks: llms.offSiteLinks,
6786
+ redirectedLinks: llms.redirectedLinks,
6787
+ nonIndexableLinks: llms.nonIndexableLinks,
6788
+ missingCrawlRoutes: llms.missingCrawlRoutes,
6789
+ repeatedHashStable: llms.repeatedHashStable
6790
+ },
6791
+ urls: [
6792
+ ...llmsBroken.map((link) => link.url),
6793
+ ...llms.redirectedLinks,
6794
+ ...llms.nonIndexableLinks,
6795
+ ...llms.missingCrawlRoutes
6796
+ ].slice(0, 25)
6797
+ }),
6798
+ check$1("discovery", {
6799
+ id: "content-signals",
6800
+ status: discovery.contentSignals.consistent === null ? "unknown" : discovery.contentSignals.consistent ? "pass" : "warning",
6801
+ title: discovery.contentSignals.consistent ? "HTML and Markdown publish one explicit Content Signals policy" : "Content Signals are missing or inconsistent across representations",
6802
+ plainEnglish: discovery.contentSignals.consistent ? `The same ${discovery.contentSignals.htmlValues[0]} policy was observed on every evaluated HTML and Markdown response.` : `${discovery.contentSignals.missingHtmlPages} HTML responses and ${discovery.contentSignals.missingMarkdownPages} Markdown responses were missing the header, or the observed values differed.`,
6803
+ action: "Choose the site policy deliberately and return the same Content-Signal value on HTML and Markdown responses.",
6804
+ evidence: discovery.contentSignals
6805
+ }),
6806
+ check$1("discovery", {
6807
+ id: "route-manifest",
6808
+ status: !discovery.routeManifest.valid ? "info" : discovery.routeManifest.missingHtmlRoutes.length === 0 && discovery.routeManifest.missingMarkdownRoutes.length === 0 && discovery.routeManifest.orphanMarkdownRoutes.length === 0 ? "pass" : "warning",
6809
+ title: discovery.routeManifest.valid ? "The public route manifest agrees with the crawl" : "No public route manifest was available",
6810
+ plainEnglish: discovery.routeManifest.valid ? `The manifest declared ${discovery.routeManifest.declaredHtmlRoutes.length} HTML routes and ${discovery.routeManifest.declaredMarkdownRoutes.length} Markdown routes. Missing or orphan routes are listed in the evidence.` : "A public route manifest is optional. Without one, this crawl cannot prove that no orphan Markdown files were deployed.",
6811
+ action: "Generate one deterministic route inventory from the build when exact HTML and Markdown parity matters.",
6812
+ evidence: discovery.routeManifest
6813
+ })
6814
+ ];
6815
+ }
6816
+ function accessChecks(report, discovery) {
6817
+ const bots = report.ai?.robotsTxt?.botAccess ?? [];
6818
+ const blocked = bots.filter((bot) => bot.allowed === false);
6819
+ const robotsKnown = report.ai?.robotsTxt?.availability === "available" || report.ai?.robotsTxt?.availability === "absent";
6820
+ const protocol = discovery.protocolVariants;
6821
+ return [check$1("access", {
6822
+ id: "crawler-access",
6823
+ status: !robotsKnown ? "unknown" : blocked.length > 0 ? "warning" : "pass",
6824
+ title: blocked.length ? "robots.txt blocks selected crawler tokens" : "No selected crawler token is blocked at the start URL",
6825
+ plainEnglish: robotsKnown ? `${blocked.length} of ${bots.length} selected crawler tokens were blocked by the start URL robots.txt policy.` : "The robots.txt response was not stable enough to make a crawler-access claim.",
6826
+ action: "Keep blocks intentional. A crawler token being allowed here does not prove that the service will crawl, index, or cite the site.",
6827
+ evidence: {
6828
+ availability: report.ai?.robotsTxt?.availability,
6829
+ blocked,
6830
+ botAccess: bots
6831
+ }
6832
+ }), check$1("access", {
6833
+ id: "protocol-canonicalization",
6834
+ status: protocol.http.permanentRedirectToHttps === true && protocol.hstsOnStartPage === true ? "pass" : protocol.http.permanentRedirectToHttps === null ? "unknown" : "warning",
6835
+ title: protocol.http.permanentRedirectToHttps === true && protocol.hstsOnStartPage === true ? "HTTP redirects permanently to HTTPS and HTTPS sends HSTS" : "Protocol canonicalization needs attention or could not be proven",
6836
+ plainEnglish: `The HTTP variant ${protocol.http.permanentRedirectToHttps === true ? "redirected permanently to HTTPS" : "did not produce a confirmed permanent HTTPS redirect"}. The HTTPS start page ${protocol.hstsOnStartPage ? "sent HSTS" : "did not provide confirmed HSTS evidence"}.`,
6837
+ action: "Use one permanent HTTP-to-HTTPS redirect and send HSTS only after HTTPS is stable across the site.",
6838
+ evidence: protocol
6839
+ })];
6840
+ }
6841
+ function identityChecks(report) {
6842
+ const types = new Set(report.pages.flatMap((page) => page.schemaTypes ?? []));
6843
+ const hasSoftware = types.has("SoftwareApplication");
6844
+ const hasWebsite = types.has("WebSite");
6845
+ const hasCreator = types.has("Person") || types.has("Organization");
6846
+ const pageTypes = [
6847
+ "WebPage",
6848
+ "TechArticle",
6849
+ "CollectionPage"
6850
+ ].filter((type) => types.has(type));
6851
+ const officialProfiles = [...new Set(report.pages.flatMap((page) => [...page.schemaSameAs ?? [], ...page.socialProfileLinks ?? []]))];
6852
+ return [check$1("identity", {
6853
+ id: "identity-graph",
6854
+ status: hasSoftware && hasWebsite && hasCreator && pageTypes.length > 0 ? "pass" : "warning",
6855
+ title: hasSoftware && hasWebsite && hasCreator && pageTypes.length > 0 ? "Structured identity covers the software, website, creator, and pages" : "The structured identity graph is missing a useful entity layer",
6856
+ plainEnglish: `Software identity: ${hasSoftware ? "present" : "missing"}. Website identity: ${hasWebsite ? "present" : "missing"}. Creator or publisher identity: ${hasCreator ? "present" : "missing"}. Page-level types: ${pageTypes.length ? pageTypes.join(", ") : "missing"}.`,
6857
+ action: "Connect truthful SoftwareApplication, WebSite, creator or publisher, and page nodes. Use sameAs only for official profiles that identify the same entity.",
6858
+ evidence: {
6859
+ schemaTypes: [...types].sort(),
6860
+ officialProfiles: officialProfiles.sort()
6861
+ }
6862
+ })];
6863
+ }
6864
+ function agentReadiness(report) {
6865
+ const discovery = report.agentDiscovery;
6866
+ if (!discovery) {
6867
+ const profiles = {
6868
+ content: {
6869
+ status: "evaluated",
6870
+ reason: "The content profile was selected but discovery evidence was not collected."
6871
+ },
6872
+ api: {
6873
+ status: "notApplicable",
6874
+ reason: "Not selected."
6875
+ },
6876
+ application: {
6877
+ status: "notApplicable",
6878
+ reason: "Not selected."
6879
+ },
6880
+ commerce: {
6881
+ status: "notApplicable",
6882
+ reason: "Not selected."
6883
+ }
6884
+ };
6885
+ const missing = check$1("collection", {
6886
+ id: "agent-discovery-evidence",
6887
+ status: "unknown",
6888
+ title: "Agent discovery evidence was not collected",
6889
+ plainEnglish: "This saved crawl predates the focused content-profile checks or was run without them.",
6890
+ action: "Run the agent-readiness report with a URL or start a fresh crawl with agent discovery enabled."
6891
+ });
6892
+ const scopeChecks = profileChecks({
6893
+ profile: "content",
6894
+ profileApplicability: profiles
6895
+ });
6896
+ const checks = [missing, ...scopeChecks];
6897
+ return {
6898
+ reportId: report.id,
6899
+ url: report.config.url,
6900
+ generatedAt: report.generatedAt,
6901
+ profile: "content",
6902
+ dataStatus: "unavailable",
6903
+ assessment: "evidence-only",
6904
+ headline: "No agent-discovery evidence is stored in this crawl. Run a fresh focused check.",
6905
+ profileApplicability: profiles,
6906
+ summary: summariseChecks(checks),
6907
+ sections: [section$1("collection", "Evidence collection", [missing]), section$1("profile", "Profile scope", scopeChecks)],
6908
+ checks,
6909
+ topActions: [missing],
6910
+ caveats: ["Not evaluated does not mean absent or broken.", "This report does not measure rankings, AI mentions, citations, or selection."]
6911
+ };
6912
+ }
6913
+ const sections = [
6914
+ section$1("profile", "Profile scope", profileChecks(discovery)),
6915
+ section$1("access", "Crawler and protocol access", accessChecks(report, discovery)),
6916
+ section$1("representations", "HTML and Markdown representations", markdownChecks(discovery)),
6917
+ section$1("discovery", "Agent discovery files", discoveryChecks(discovery)),
6918
+ section$1("identity", "Identity evidence", identityChecks(report))
6919
+ ];
6920
+ const checks = sections.flatMap((item) => item.checks);
6921
+ const actionable = checks.filter((item) => [
6922
+ "fail",
6923
+ "warning",
6924
+ "unknown"
6925
+ ].includes(item.status));
6926
+ const rank = {
6927
+ fail: 0,
6928
+ warning: 1,
6929
+ unknown: 2,
6930
+ pass: 3,
6931
+ info: 4,
6932
+ notApplicable: 5
6933
+ };
6934
+ const topActions = [...actionable].sort((left, right) => rank[left.status] - rank[right.status]).slice(0, 10);
6935
+ const summary = summariseChecks(checks);
6936
+ return {
6937
+ reportId: report.id,
6938
+ url: report.config.url,
6939
+ generatedAt: report.generatedAt,
6940
+ profile: discovery.profile,
6941
+ dataStatus: discovery.dataStatus,
6942
+ assessment: "evidence-only",
6943
+ headline: `${summary.passed} checks passed, ${summary.warnings} need review, and ${summary.failed} failed for the content profile.`,
6944
+ profileApplicability: discovery.profileApplicability,
6945
+ summary,
6946
+ sections,
6947
+ checks,
6948
+ topActions,
6949
+ caveats: [
6950
+ ...report.caveats,
6951
+ ...discovery.warnings,
6952
+ "A clean content profile does not prove indexing, rankings, AI mentions, citations, or selection.",
6953
+ "A crawler token being allowed does not prove that a service fetched or used the page.",
6954
+ "API, application, and commerce checks were not applicable to this content-site run."
6955
+ ]
6956
+ };
6957
+ }
6958
+ //#endregion
6959
+ //#region packages/core/dist/analyze/crawler/entity-readiness.js
6960
+ const ENTITY_EVIDENCE_SCHEMA_TYPES = /* @__PURE__ */ new Set([
6961
+ "organization",
6962
+ "localbusiness",
6963
+ "person",
6964
+ "product",
6965
+ "softwareapplication",
6966
+ "website"
6967
+ ]);
6968
+ const SITE_IDENTITY_SCHEMA_TYPES = /* @__PURE__ */ new Set(["organization", "localbusiness"]);
6969
+ const PROFILE_IDENTITY_SCHEMA_TYPES = /* @__PURE__ */ new Set([...SITE_IDENTITY_SCHEMA_TYPES, "person"]);
6970
+ function isEntityEvidenceSchemaType(type) {
6971
+ return ENTITY_EVIDENCE_SCHEMA_TYPES.has(type.toLowerCase());
6972
+ }
6973
+ function isSiteIdentitySchemaType(type) {
6974
+ return SITE_IDENTITY_SCHEMA_TYPES.has(type.toLowerCase());
6975
+ }
6976
+ function isProfileIdentitySchemaType(type) {
6977
+ return PROFILE_IDENTITY_SCHEMA_TYPES.has(type.toLowerCase());
6978
+ }
6979
+ function unique$3(values) {
6980
+ return [...new Set(values.filter((value) => Boolean(value)))];
6981
+ }
6034
6982
  function pct$3(part, total) {
6983
+ return total ? Math.round(part / total * 100) : 0;
6984
+ }
6985
+ function entityReadiness(report) {
6986
+ const pages = report.pages.filter((page) => page.indexable && page.status < 400);
6987
+ const total = pages.length || 1;
6988
+ const schemaTypes = {};
6989
+ for (const page of pages) for (const type of page.schemaTypes ?? []) schemaTypes[type] = (schemaTypes[type] ?? 0) + 1;
6990
+ const entitySchemaPages = pages.filter((page) => page.schemaTypes?.some(isEntityEvidenceSchemaType));
6991
+ const sameAsEvidence = pages.flatMap((page) => page.schemaSameAsEvidence ?? []).filter((evidence) => evidence.subjectTypes.some(isProfileIdentitySchemaType));
6992
+ const siteSameAsEvidence = sameAsEvidence.filter((evidence) => evidence.subjectTypes.some(isSiteIdentitySchemaType));
6993
+ const sameAs = unique$3(sameAsEvidence.map((evidence) => evidence.url));
6994
+ const sameAsByType = {};
6995
+ for (const evidence of sameAsEvidence) for (const type of evidence.subjectTypes) {
6996
+ if (!isProfileIdentitySchemaType(type)) continue;
6997
+ sameAsByType[type] = unique$3([...sameAsByType[type] ?? [], evidence.url]);
6998
+ }
6999
+ const socialProfiles = unique$3(pages.flatMap((page) => page.socialProfileLinks ?? []));
7000
+ const authors = unique$3(pages.map((page) => page.author));
7001
+ const authorPages = pages.filter((page) => page.author || page.geo?.hasAuthor);
7002
+ const datePages = pages.filter((page) => page.hasDate || page.geo?.hasDate);
7003
+ const titlePages = pages.filter((page) => page.title && page.h1);
7004
+ const checks = [
7005
+ {
7006
+ coverage: pct$3(entitySchemaPages.length, total),
7007
+ check: {
7008
+ id: "entity-schema",
7009
+ title: "Entity schema is present",
7010
+ plainEnglish: `${pct$3(entitySchemaPages.length, total)}% of evaluated indexable pages include Organization, LocalBusiness, Person, Product, SoftwareApplication, or WebSite schema.`,
7011
+ action: "Add accurate schema only where it describes the software, website, organization, person, product, or local business shown on the page.",
7012
+ evidence: { schemaTypes },
7013
+ urls: pages.filter((page) => !entitySchemaPages.includes(page)).slice(0, 10).map((page) => page.finalUrl)
7014
+ }
7015
+ },
7016
+ {
7017
+ coverage: siteSameAsEvidence.length ? 100 : 0,
7018
+ check: {
7019
+ id: "same-as",
7020
+ title: "Site entity profiles are connected",
7021
+ plainEnglish: siteSameAsEvidence.length ? "The crawl found sameAs links attached to Organization or LocalBusiness structured data." : sameAs.length ? "The crawl found Person sameAs links, but no Organization or LocalBusiness profile evidence for the site entity." : socialProfiles.length ? "The crawl found social-domain links, but they are not enough to prove official profile ownership." : "The crawl did not find entity-scoped sameAs evidence.",
7022
+ action: "Connect official profiles with sameAs on Organization, Person, or LocalBusiness schema. Use only profiles you control.",
7023
+ evidence: {
7024
+ sameAs,
7025
+ siteSameAs: unique$3(siteSameAsEvidence.map((evidence) => evidence.url)),
7026
+ sameAsEvidence,
7027
+ unclassifiedSocialLinks: socialProfiles
7028
+ }
7029
+ }
7030
+ },
7031
+ {
7032
+ coverage: Math.round((pct$3(authorPages.length, total) + pct$3(datePages.length, total)) / 2),
7033
+ check: {
7034
+ id: "authority-freshness",
7035
+ title: "Author and date signals observed",
7036
+ plainEnglish: `${pct$3(authorPages.length, total)}% of evaluated indexable pages expose an author signal and ${pct$3(datePages.length, total)}% expose a date signal.`,
7037
+ action: "For editorial content, identify authors and show accurate published or modified dates when that information is useful to readers.",
7038
+ evidence: {
7039
+ authorCoverage: pct$3(authorPages.length, total),
7040
+ dateCoverage: pct$3(datePages.length, total),
7041
+ authors
7042
+ }
7043
+ }
7044
+ },
7045
+ {
7046
+ coverage: pct$3(titlePages.length, total),
7047
+ check: {
7048
+ id: "entity-naming",
7049
+ title: "Title and H1 coverage observed",
7050
+ plainEnglish: `${pct$3(titlePages.length, total)}% of evaluated indexable pages have both a title and H1.`,
7051
+ action: "Review pages missing either signal. Keep brand, product, and person names accurate wherever they appear."
7052
+ }
7053
+ }
7054
+ ].map(({ coverage, check }) => ({
7055
+ ...check,
7056
+ status: "info",
7057
+ evidence: {
7058
+ ...check.evidence,
7059
+ observedCoveragePercent: coverage
7060
+ }
7061
+ }));
7062
+ const dataStatus = report.status === "completed" && pages.length > 0 ? "complete" : "partial";
7063
+ return {
7064
+ reportId: report.id,
7065
+ url: report.config.url,
7066
+ generatedAt: report.generatedAt,
7067
+ dataStatus,
7068
+ evaluatedPages: pages.length,
7069
+ crawlPages: report.pages.length,
7070
+ assessment: "evidence-only",
7071
+ headline: dataStatus === "partial" ? "Entity evidence is incomplete; treat these findings as scoped to the evaluated pages, not the whole site." : "Entity signals are reported as observations, not a ranking, visibility, or machine-understanding score.",
7072
+ caveats: [
7073
+ ...report.caveats,
7074
+ "This report deliberately has no aggregate entity score. Add schema, authors, dates, and sameAs only where they accurately fit the page and a documented use case.",
7075
+ ...dataStatus === "partial" ? [`Entity coverage is based on ${pages.length} evaluated indexable page${pages.length === 1 ? "" : "s"} from a ${report.status} crawl.`] : [],
7076
+ ...socialProfiles.length && !sameAs.length ? ["Social-domain links are unclassified navigation evidence, not proof that the linked profiles are official."] : []
7077
+ ],
7078
+ checks,
7079
+ entities: {
7080
+ schemaTypes,
7081
+ sameAs,
7082
+ sameAsByType,
7083
+ socialProfiles,
7084
+ authors
7085
+ }
7086
+ };
7087
+ }
7088
+ //#endregion
7089
+ //#region packages/core/dist/analyze/crawler/ai-readiness.js
7090
+ function pct$2(part, total) {
6035
7091
  if (total <= 0) return 0;
6036
7092
  return Math.round(part / total * 100);
6037
7093
  }
@@ -6068,6 +7124,7 @@ function sampleUrls$1(pages, predicate) {
6068
7124
  return pages.filter(predicate).slice(0, 10).map((page) => page.finalUrl);
6069
7125
  }
6070
7126
  function aiReadiness(report) {
7127
+ const agentDiscovery = report.agentDiscovery;
6071
7128
  const pages = indexablePages$1(report);
6072
7129
  const pageCount = pages.length;
6073
7130
  const hasIndexablePages = pageCount > 0;
@@ -6091,7 +7148,7 @@ function aiReadiness(report) {
6091
7148
  const titlePages = pages.filter((page) => page.title && page.h1);
6092
7149
  const metaPages = pages.filter((page) => page.metaDescription);
6093
7150
  const langPages = pages.filter((page) => page.lang);
6094
- const entityPages = pages.filter((page) => page.schemaTypes?.some((type) => /^(Organization|LocalBusiness|Person|Product|WebSite)$/i.test(type)) || (page.schemaSameAs?.length ?? 0) > 0 || (page.socialProfileLinks?.length ?? 0) > 0);
7151
+ const entityPages = pages.filter((page) => page.schemaTypes?.some(isEntityEvidenceSchemaType) || (page.schemaSameAs?.length ?? 0) > 0 || (page.socialProfileLinks?.length ?? 0) > 0);
6095
7152
  const restrictedSnippets = pages.map((page) => ({
6096
7153
  url: page.finalUrl,
6097
7154
  control: effectiveSnippetControl({
@@ -6108,7 +7165,7 @@ function aiReadiness(report) {
6108
7165
  section: "agent-access",
6109
7166
  maxScore: 20,
6110
7167
  evaluated: botAccessEvaluated,
6111
- score: robotsUnavailable ? 0 : botAccess.length ? blockedBots.length ? scoreFromPercent(pct$3(botAccess.length - blockedBots.length, botAccess.length), 20) : 20 : 8,
7168
+ score: robotsUnavailable ? 0 : botAccess.length ? blockedBots.length ? scoreFromPercent(pct$2(botAccess.length - blockedBots.length, botAccess.length), 20) : 20 : 8,
6112
7169
  title: robotsUnavailable ? "robots.txt crawler-policy evidence is unavailable" : !hasBotAccessEvidence ? "robots.txt crawler-policy evidence was not collected" : blockedBots.length ? "robots.txt blocks selected crawler tokens at the start URL" : "robots.txt allows selected crawler tokens at the start URL",
6113
7170
  plainEnglish: robotsUnavailable ? "The robots.txt request failed, so this report cannot say whether selected crawler tokens are allowed at the start URL." : !hasBotAccessEvidence ? "This crawl does not include per-bot robots.txt policy data for the start URL." : blockedBots.length ? `robots.txt policy blocks ${blockedBots.length} selected crawler ${blockedBots.length === 1 ? "token" : "tokens"} at the start URL.` : "robots.txt policy does not block the selected crawler tokens at the start URL. This does not verify actual or site-wide fetchability.",
6114
7171
  action: robotsUnavailable ? "Restore a stable robots.txt response, then rerun this report before making crawler-policy claims." : !hasBotAccessEvidence ? "Rerun the crawl with top-level per-bot robots.txt evidence before making crawler-policy claims." : blockedBots.length ? "Only block AI crawlers intentionally. If discovery matters, remove accidental Disallow rules for the blocked user agents." : "Keep robots.txt explicit and intentional so humans and agents can see what is allowed.",
@@ -6151,10 +7208,11 @@ function aiReadiness(report) {
6151
7208
  maxScore: 0,
6152
7209
  score: 0,
6153
7210
  title: "llms.txt is optional",
6154
- plainEnglish: report.ai?.llmsTxt?.exists ? "An optional llms.txt file was found. Google says it has no positive or negative Search impact." : "No llms.txt file was found. Google says the file is not needed for Search and does not affect visibility.",
7211
+ plainEnglish: report.ai?.llmsTxt?.exists ? agentDiscovery?.llmsTxt ? `An optional llms.txt file was found and its body was checked. It declared ${agentDiscovery.llmsTxt.links.length} links, ${agentDiscovery.llmsTxt.duplicateLinks.length} duplicates, and ${agentDiscovery.llmsTxt.missingCrawlRoutes.length} links outside the crawled route inventory. Google says llms.txt has no positive or negative Search impact.` : "An optional llms.txt file was found. Its body was not validated in this crawl. Google says it has no positive or negative Search impact." : "No llms.txt file was found. Google says the file is not needed for Search and does not affect visibility.",
6155
7212
  action: "No SEO action is required. Generate one only for a specific agent or service that consumes it.",
6156
7213
  evidence: {
6157
7214
  llmsTxt: report.ai?.llmsTxt,
7215
+ validation: agentDiscovery?.llmsTxt,
6158
7216
  googleSearchImpact: "none",
6159
7217
  guidanceUrl: "https://developers.google.com/search/updates#clarifying-guidance-on-llms-txt-files"
6160
7218
  }
@@ -6177,7 +7235,7 @@ function aiReadiness(report) {
6177
7235
  evaluated: hasIndexablePages,
6178
7236
  score: 0,
6179
7237
  title: "Short opening paragraphs are an unscored observation",
6180
- plainEnglish: hasIndexablePages ? `${pct$3(answerablePages.length, pageCount)}% of indexable pages have at least one 25-word paragraph near the start. This does not establish content quality, citation likelihood, or Google AI eligibility.` : "No indexable 2xx pages were available, so opening-paragraph coverage was not evaluated.",
7238
+ plainEnglish: hasIndexablePages ? `${pct$2(answerablePages.length, pageCount)}% of indexable pages have at least one 25-word paragraph near the start. This does not establish content quality, citation likelihood, or Google AI eligibility.` : "No indexable 2xx pages were available, so opening-paragraph coverage was not evaluated.",
6181
7239
  action: "Write for the reader and the page intent. Do not create artificial answer blocks or chunk content solely for AI Search.",
6182
7240
  urls: sampleUrls$1(pages, (page) => !page.geo?.answerable),
6183
7241
  evidence: {
@@ -6195,7 +7253,7 @@ function aiReadiness(report) {
6195
7253
  evaluated: hasIndexablePages,
6196
7254
  score: 0,
6197
7255
  title: "Semantic HTML coverage observed",
6198
- plainEnglish: hasIndexablePages ? `${pct$3(semanticPages.length, pageCount)}% of indexable pages use semantic structure.` : "No indexable 2xx pages were available, so semantic HTML coverage was not evaluated.",
7256
+ plainEnglish: hasIndexablePages ? `${pct$2(semanticPages.length, pageCount)}% of indexable pages use semantic structure.` : "No indexable 2xx pages were available, so semantic HTML coverage was not evaluated.",
6199
7257
  action: "Use real headings, lists, tables, nav, main, article, and section elements instead of layout-only divs."
6200
7258
  }),
6201
7259
  check({
@@ -6205,7 +7263,7 @@ function aiReadiness(report) {
6205
7263
  evaluated: hasIndexablePages,
6206
7264
  score: 0,
6207
7265
  title: "Title, H1, and description coverage observed",
6208
- plainEnglish: hasIndexablePages ? `${pct$3(titlePages.length, pageCount)}% of indexable pages have title/H1 coverage and ${pct$3(metaPages.length, pageCount)}% have meta descriptions.` : "No indexable 2xx pages were available, so title, H1, and description coverage was not evaluated.",
7266
+ plainEnglish: hasIndexablePages ? `${pct$2(titlePages.length, pageCount)}% of indexable pages have title/H1 coverage and ${pct$2(metaPages.length, pageCount)}% have meta descriptions.` : "No indexable 2xx pages were available, so title, H1, and description coverage was not evaluated.",
6209
7267
  action: "Write a unique title and descriptive H1. Add a useful meta description when a summary would help searchers understand the page."
6210
7268
  }),
6211
7269
  check({
@@ -6215,7 +7273,7 @@ function aiReadiness(report) {
6215
7273
  evaluated: hasIndexablePages,
6216
7274
  score: 0,
6217
7275
  title: "HTML language declaration coverage observed",
6218
- plainEnglish: hasIndexablePages ? `${pct$3(langPages.length, pageCount)}% of indexable pages declare a language.` : "No indexable 2xx pages were available, so language declaration coverage was not evaluated.",
7276
+ plainEnglish: hasIndexablePages ? `${pct$2(langPages.length, pageCount)}% of indexable pages declare a language.` : "No indexable 2xx pages were available, so language declaration coverage was not evaluated.",
6219
7277
  action: "Set the html lang attribute so crawlers and assistive tech understand the page language."
6220
7278
  })
6221
7279
  ]),
@@ -6226,7 +7284,7 @@ function aiReadiness(report) {
6226
7284
  evaluated: hasIndexablePages,
6227
7285
  score: 0,
6228
7286
  title: "Entity-signal coverage observed",
6229
- plainEnglish: hasIndexablePages ? `${pct$3(entityPages.length, pageCount)}% of indexable pages include entity signals such as Organization, Person, Product, sameAs, or social profile links.` : "No indexable 2xx pages were available, so entity-signal coverage was not evaluated.",
7287
+ plainEnglish: hasIndexablePages ? `${pct$2(entityPages.length, pageCount)}% of indexable pages include entity signals such as Organization, Person, Product, sameAs, or social profile links.` : "No indexable 2xx pages were available, so entity-signal coverage was not evaluated.",
6230
7288
  action: "Make the homepage and key pages explicit about the brand, product, people, and official profiles using accurate schema and links.",
6231
7289
  urls: sampleUrls$1(pages, (page) => !entityPages.includes(page))
6232
7290
  }), check({
@@ -6270,12 +7328,52 @@ function aiReadiness(report) {
6270
7328
  section: "technical-ux",
6271
7329
  maxScore: 12,
6272
7330
  evaluated: report.pages.length > 0,
6273
- score: scoreFromPercent(pct$3(pages.length, report.pages.length || 1), 12),
7331
+ score: scoreFromPercent(pct$2(pages.length, report.pages.length || 1), 12),
6274
7332
  title: report.pages.length ? "Crawled-page indexability observed" : "Crawled-page indexability was not evaluated",
6275
- plainEnglish: report.pages.length ? `${pct$3(pages.length, report.pages.length)}% of crawled pages are indexable 2xx pages.` : "No crawled pages were available, so status and indexability were not evaluated.",
7333
+ plainEnglish: report.pages.length ? `${pct$2(pages.length, report.pages.length)}% of crawled pages are indexable 2xx pages.` : "No crawled pages were available, so status and indexability were not evaluated.",
6276
7334
  action: "Fix 4xx/5xx pages, accidental noindex, and blocked internal URLs before expanding AI discovery work."
6277
7335
  })
6278
7336
  ]),
7337
+ section("agent-content", "Agent content observations", [
7338
+ check({
7339
+ id: "markdown-alternates",
7340
+ section: "agent-content",
7341
+ maxScore: 0,
7342
+ score: 0,
7343
+ evaluated: Boolean(agentDiscovery),
7344
+ title: agentDiscovery ? "Markdown alternatives were checked" : "Markdown alternatives were not evaluated",
7345
+ plainEnglish: agentDiscovery ? `${agentDiscovery.markdownAlternates.advertisedPages} of ${agentDiscovery.markdownAlternates.eligibleHtmlPages} successful HTML pages advertised one Markdown alternative. ${agentDiscovery.markdownAlternates.exactByteMatches} explicit responses matched content negotiation byte for byte.` : "This crawl does not include the focused representation checks, so it cannot say whether HTML pages publish stable Markdown alternatives.",
7346
+ action: "Use the focused agent-readiness report when you need route coverage, content negotiation, byte stability, or extraction-quality evidence.",
7347
+ evidence: agentDiscovery ? {
7348
+ eligibleHtmlPages: agentDiscovery.markdownAlternates.eligibleHtmlPages,
7349
+ advertisedPages: agentDiscovery.markdownAlternates.advertisedPages,
7350
+ exactByteMatches: agentDiscovery.markdownAlternates.exactByteMatches,
7351
+ stableResponses: agentDiscovery.markdownAlternates.stableResponses
7352
+ } : void 0
7353
+ }),
7354
+ check({
7355
+ id: "agent-skills-discovery",
7356
+ section: "agent-content",
7357
+ maxScore: 0,
7358
+ score: 0,
7359
+ evaluated: Boolean(agentDiscovery),
7360
+ title: agentDiscovery ? "Agent Skills discovery was checked" : "Agent Skills discovery was not evaluated",
7361
+ plainEnglish: agentDiscovery ? `${agentDiscovery.agentSkills.skills.length} published skill${agentDiscovery.agentSkills.skills.length === 1 ? "" : "s"} were found. ${agentDiscovery.agentSkills.skills.filter((skill) => skill.digestMatches).length} matched their declared SHA-256 digest.` : "This crawl checked common legacy descriptor paths but did not validate the Agent Skills discovery index or its file digests.",
7362
+ action: "Publish Agent Skills only for real reusable capabilities. Generate the index digest from the exact deployed SKILL.md bytes.",
7363
+ evidence: agentDiscovery?.agentSkills
7364
+ }),
7365
+ check({
7366
+ id: "agent-content-profile",
7367
+ section: "agent-content",
7368
+ maxScore: 0,
7369
+ score: 0,
7370
+ evaluated: Boolean(agentDiscovery),
7371
+ title: agentDiscovery ? "The content profile was selected explicitly" : "No focused agent-readiness profile was selected",
7372
+ plainEnglish: agentDiscovery ? "Document access, representations, discovery, identity, and extraction quality were evaluated. API, application, and commerce checks were marked not applicable rather than failed." : "A normal crawl does not assume that a content site also exposes a public API, remote agent endpoint, or checkout.",
7373
+ action: "Run a different profile only when that public capability really exists.",
7374
+ evidence: agentDiscovery?.profileApplicability
7375
+ })
7376
+ ]),
6279
7377
  section("crawl-completeness", "Crawl completeness", [check({
6280
7378
  id: "crawl-depth",
6281
7379
  section: "crawl-completeness",
@@ -6326,117 +7424,6 @@ function aiReadiness(report) {
6326
7424
  };
6327
7425
  }
6328
7426
  //#endregion
6329
- //#region packages/core/dist/analyze/crawler/entity-readiness.js
6330
- function unique$3(values) {
6331
- return [...new Set(values.filter((value) => Boolean(value)))];
6332
- }
6333
- function pct$2(part, total) {
6334
- return total ? Math.round(part / total * 100) : 0;
6335
- }
6336
- function entityReadiness(report) {
6337
- const pages = report.pages.filter((page) => page.indexable && page.status < 400);
6338
- const total = pages.length || 1;
6339
- const schemaTypes = {};
6340
- for (const page of pages) for (const type of page.schemaTypes ?? []) schemaTypes[type] = (schemaTypes[type] ?? 0) + 1;
6341
- const entitySchemaPages = pages.filter((page) => page.schemaTypes?.some((type) => /^(Organization|LocalBusiness|Person|Product|WebSite)$/i.test(type)));
6342
- const sameAsEvidence = pages.flatMap((page) => page.schemaSameAsEvidence ?? []).filter((evidence) => evidence.subjectTypes.some((type) => /^(Organization|LocalBusiness|Person)$/i.test(type)));
6343
- const siteSameAsEvidence = sameAsEvidence.filter((evidence) => evidence.subjectTypes.some((type) => /^(Organization|LocalBusiness)$/i.test(type)));
6344
- const sameAs = unique$3(sameAsEvidence.map((evidence) => evidence.url));
6345
- const sameAsByType = {};
6346
- for (const evidence of sameAsEvidence) for (const type of evidence.subjectTypes) {
6347
- if (!/^(Organization|LocalBusiness|Person)$/i.test(type)) continue;
6348
- sameAsByType[type] = unique$3([...sameAsByType[type] ?? [], evidence.url]);
6349
- }
6350
- const socialProfiles = unique$3(pages.flatMap((page) => page.socialProfileLinks ?? []));
6351
- const authors = unique$3(pages.map((page) => page.author));
6352
- const authorPages = pages.filter((page) => page.author || page.geo?.hasAuthor);
6353
- const datePages = pages.filter((page) => page.hasDate || page.geo?.hasDate);
6354
- const titlePages = pages.filter((page) => page.title && page.h1);
6355
- const checks = [
6356
- {
6357
- coverage: pct$2(entitySchemaPages.length, total),
6358
- check: {
6359
- id: "entity-schema",
6360
- title: "Entity schema is present",
6361
- plainEnglish: `${pct$2(entitySchemaPages.length, total)}% of evaluated indexable pages include Organization, LocalBusiness, Person, Product, or WebSite schema.`,
6362
- action: "Add accurate entity schema to the homepage and key product, author, organization, and local pages.",
6363
- evidence: { schemaTypes },
6364
- urls: pages.filter((page) => !entitySchemaPages.includes(page)).slice(0, 10).map((page) => page.finalUrl)
6365
- }
6366
- },
6367
- {
6368
- coverage: siteSameAsEvidence.length ? 100 : 0,
6369
- check: {
6370
- id: "same-as",
6371
- title: "Site entity profiles are connected",
6372
- plainEnglish: siteSameAsEvidence.length ? "The crawl found sameAs links attached to Organization or LocalBusiness structured data." : sameAs.length ? "The crawl found Person sameAs links, but no Organization or LocalBusiness profile evidence for the site entity." : socialProfiles.length ? "The crawl found social-domain links, but they are not enough to prove official profile ownership." : "The crawl did not find entity-scoped sameAs evidence.",
6373
- action: "Connect official profiles with sameAs on Organization, Person, or LocalBusiness schema. Use only profiles you control.",
6374
- evidence: {
6375
- sameAs,
6376
- siteSameAs: unique$3(siteSameAsEvidence.map((evidence) => evidence.url)),
6377
- sameAsEvidence,
6378
- unclassifiedSocialLinks: socialProfiles
6379
- }
6380
- }
6381
- },
6382
- {
6383
- coverage: Math.round((pct$2(authorPages.length, total) + pct$2(datePages.length, total)) / 2),
6384
- check: {
6385
- id: "authority-freshness",
6386
- title: "Author and date signals observed",
6387
- plainEnglish: `${pct$2(authorPages.length, total)}% of evaluated indexable pages expose an author signal and ${pct$2(datePages.length, total)}% expose a date signal.`,
6388
- action: "For editorial content, identify authors and show accurate published or modified dates when that information is useful to readers.",
6389
- evidence: {
6390
- authorCoverage: pct$2(authorPages.length, total),
6391
- dateCoverage: pct$2(datePages.length, total),
6392
- authors
6393
- }
6394
- }
6395
- },
6396
- {
6397
- coverage: pct$2(titlePages.length, total),
6398
- check: {
6399
- id: "entity-naming",
6400
- title: "Title and H1 coverage observed",
6401
- plainEnglish: `${pct$2(titlePages.length, total)}% of evaluated indexable pages have both a title and H1.`,
6402
- action: "Review pages missing either signal. Keep brand, product, and person names accurate wherever they appear."
6403
- }
6404
- }
6405
- ].map(({ coverage, check }) => ({
6406
- ...check,
6407
- status: "info",
6408
- evidence: {
6409
- ...check.evidence,
6410
- observedCoveragePercent: coverage
6411
- }
6412
- }));
6413
- const dataStatus = report.status === "completed" && pages.length > 0 ? "complete" : "partial";
6414
- return {
6415
- reportId: report.id,
6416
- url: report.config.url,
6417
- generatedAt: report.generatedAt,
6418
- dataStatus,
6419
- evaluatedPages: pages.length,
6420
- crawlPages: report.pages.length,
6421
- assessment: "evidence-only",
6422
- headline: dataStatus === "partial" ? "Entity evidence is incomplete; treat these findings as scoped to the evaluated pages, not the whole site." : "Entity signals are reported as observations, not a ranking, visibility, or machine-understanding score.",
6423
- caveats: [
6424
- ...report.caveats,
6425
- "This report deliberately has no aggregate entity score. Add schema, authors, dates, and sameAs only where they accurately fit the page and a documented use case.",
6426
- ...dataStatus === "partial" ? [`Entity coverage is based on ${pages.length} evaluated indexable page${pages.length === 1 ? "" : "s"} from a ${report.status} crawl.`] : [],
6427
- ...socialProfiles.length && !sameAs.length ? ["Social-domain links are unclassified navigation evidence, not proof that the linked profiles are official."] : []
6428
- ],
6429
- checks,
6430
- entities: {
6431
- schemaTypes,
6432
- sameAs,
6433
- sameAsByType,
6434
- socialProfiles,
6435
- authors
6436
- }
6437
- };
6438
- }
6439
- //#endregion
6440
7427
  //#region packages/core/dist/analyze/crawler/geo-gaps.js
6441
7428
  const ELIGIBILITY_RULES = /* @__PURE__ */ new Set([
6442
7429
  "connection_error",
@@ -6504,7 +7491,7 @@ function partialReasons(report) {
6504
7491
  if (report.requestEvidenceStatus === "partial") reasons.push("request-evidence-partial");
6505
7492
  if (report.requestEvidenceStatus === "unavailable") reasons.push("request-evidence-unavailable");
6506
7493
  if (report.summary.pageLimitReached) reasons.push("page-limit-reached");
6507
- if (report.summary.skippedUrls > 0) reasons.push("skipped-urls");
7494
+ if (report.summary.skippedUrlsByImpact.coverageAffecting > 0) reasons.push("coverage-affecting-skips");
6508
7495
  if (report.summary.failedRequests > 0) reasons.push("failed-requests");
6509
7496
  if (report.summary.extractionFailures > 0) reasons.push("extraction-failures");
6510
7497
  return reasons;
@@ -6532,6 +7519,8 @@ function geoGapsReport(report, filters = {}) {
6532
7519
  queuedUrls: report.summary.queuedUrls,
6533
7520
  crawledUrls: report.summary.crawledUrls,
6534
7521
  skippedUrls: report.summary.skippedUrls,
7522
+ coverageAffectingSkippedUrls: report.summary.skippedUrlsByImpact.coverageAffecting,
7523
+ nonImpactingSkippedUrls: report.summary.skippedUrlsByImpact.nonImpacting,
6535
7524
  failedRequests: report.summary.failedRequests,
6536
7525
  extractionFailures: report.summary.extractionFailures,
6537
7526
  partialReasons: reasons
@@ -6594,8 +7583,56 @@ function candidatePages(report, options = {}) {
6594
7583
  }
6595
7584
  function auditLlmsTxt(report) {
6596
7585
  const llmsTxt = report.ai?.llmsTxt;
7586
+ const validation = report.agentDiscovery?.llmsTxt;
6597
7587
  const pages = candidatePages(report);
6598
7588
  const issues = [];
7589
+ if (validation?.exists && !/^\s*(?:text\/plain|text\/markdown)\b/iu.test(validation.contentType ?? "")) issues.push({
7590
+ id: "llms-content-type",
7591
+ severity: "medium",
7592
+ title: "llms.txt uses an unexpected content type",
7593
+ plainEnglish: `The file returned ${validation.contentType ?? "no content type"} instead of plain text or Markdown.`,
7594
+ action: "Serve the deterministic text file as text/plain or text/markdown so consumers do not mistake it for HTML.",
7595
+ evidence: { contentType: validation.contentType }
7596
+ });
7597
+ if (validation?.exists && validation.headingCount === 0) issues.push({
7598
+ id: "llms-structure",
7599
+ severity: "medium",
7600
+ title: "llms.txt has no useful heading structure",
7601
+ plainEnglish: "The fetched file did not contain a level-one or level-two Markdown heading.",
7602
+ action: "Start with one clear title, then group a short list of useful entry points under descriptive headings."
7603
+ });
7604
+ if (validation?.duplicateLinks.length) issues.push({
7605
+ id: "llms-duplicate-links",
7606
+ severity: "low",
7607
+ title: "llms.txt repeats the same link",
7608
+ plainEnglish: `${validation.duplicateLinks.length} URL${validation.duplicateLinks.length === 1 ? " appears" : "s appear"} more than once.`,
7609
+ action: "Remove duplicate entries so the file remains short and deliberate.",
7610
+ evidence: { urls: validation.duplicateLinks }
7611
+ });
7612
+ const brokenLinks = validation?.links.filter((link) => !link.status || link.status < 200 || link.status >= 400 || link.error) ?? [];
7613
+ if (brokenLinks.length) issues.push({
7614
+ id: "llms-broken-links",
7615
+ severity: "medium",
7616
+ title: "llms.txt links did not resolve",
7617
+ plainEnglish: `${brokenLinks.length} declared link${brokenLinks.length === 1 ? "" : "s"} did not return a usable response during this audit.`,
7618
+ action: "Update or remove stale entries, then rerun the focused agent-readiness report.",
7619
+ evidence: { links: brokenLinks }
7620
+ });
7621
+ if (validation?.missingCrawlRoutes.length) issues.push({
7622
+ id: "llms-outside-crawl",
7623
+ severity: "low",
7624
+ title: "llms.txt links fall outside the crawl inventory",
7625
+ plainEnglish: `${validation.missingCrawlRoutes.length} same-origin route${validation.missingCrawlRoutes.length === 1 ? " was" : "s were"} not present in the retained crawl.`,
7626
+ action: "Confirm those routes are intentional and indexable, or remove stale declarations.",
7627
+ evidence: { urls: validation.missingCrawlRoutes }
7628
+ });
7629
+ if (validation?.repeatedHashStable === false) issues.push({
7630
+ id: "llms-unstable-body",
7631
+ severity: "medium",
7632
+ title: "llms.txt changed between repeated requests",
7633
+ plainEnglish: "Two requests in the same audit returned different SHA-256 digests.",
7634
+ action: "Generate the file during the build and remove timestamps, random ordering, or runtime rewriting."
7635
+ });
6599
7636
  if (pages.length < 3) issues.push({
6600
7637
  id: "thin-llms-inventory",
6601
7638
  severity: "low",
@@ -6613,7 +7650,7 @@ function auditLlmsTxt(report) {
6613
7650
  optional: true,
6614
7651
  googleSearchImpact: "none",
6615
7652
  guidanceUrl: "https://developers.google.com/search/updates#clarifying-guidance-on-llms-txt-files",
6616
- headline: llmsTxt?.exists ? "An optional llms.txt file is present. It has no Google Search visibility impact." : "No llms.txt file was found. This is not an SEO issue and requires no action.",
7653
+ headline: llmsTxt?.exists ? validation ? issues.length ? `The optional llms.txt file was validated and ${issues.length} content or link issue${issues.length === 1 ? " needs" : "s need"} review. It has no Google Search visibility impact.` : `The optional llms.txt file was validated with ${validation.links.length} resolving link${validation.links.length === 1 ? "" : "s"} and a stable body. It has no Google Search visibility impact.` : "An optional llms.txt file is present, but its body was not validated in this crawl. It has no Google Search visibility impact." : "No llms.txt file was found. This is not an SEO issue and requires no action.",
6617
7654
  issues,
6618
7655
  recommendedPages: pages.slice(0, 25).map((page) => ({
6619
7656
  url: page.finalUrl,
@@ -6712,8 +7749,6 @@ const SCORECARD_CHECK_ORDER = [
6712
7749
  "entity-identity",
6713
7750
  "answerable-content"
6714
7751
  ];
6715
- const ENTITY_SCHEMA_PATTERN = /^(Organization|LocalBusiness|Person|Product|WebSite)$/i;
6716
- const SITE_ENTITY_TYPE_PATTERN = /^(Organization|LocalBusiness)$/i;
6717
7752
  function indexablePages(report) {
6718
7753
  return report.pages.filter((page) => page.indexable && page.status < 400);
6719
7754
  }
@@ -6921,8 +7956,8 @@ function entityIdentityCheck(report) {
6921
7956
  finding: "Entity identity could not be evaluated because no indexable 2xx pages were available.",
6922
7957
  verification
6923
7958
  };
6924
- const hasEntitySchema = Object.keys(entity.entities.schemaTypes).some((type) => ENTITY_SCHEMA_PATTERN.test(type));
6925
- const siteSameAs = Object.entries(entity.entities.sameAsByType).filter(([type]) => SITE_ENTITY_TYPE_PATTERN.test(type)).flatMap(([, urls]) => urls);
7959
+ const hasEntitySchema = Object.keys(entity.entities.schemaTypes).some(isEntityEvidenceSchemaType);
7960
+ const siteSameAs = Object.entries(entity.entities.sameAsByType).filter(([type]) => isSiteIdentitySchemaType(type)).flatMap(([, urls]) => urls);
6926
7961
  const uniqueSiteSameAs = [...new Set(siteSameAs)].sort();
6927
7962
  const status = uniqueSiteSameAs.length ? "pass" : hasEntitySchema ? "warn" : "fail";
6928
7963
  return {
@@ -6935,7 +7970,7 @@ function entityIdentityCheck(report) {
6935
7970
  sameAs: entity.entities.sameAs,
6936
7971
  socialProfiles: entity.entities.socialProfiles
6937
7972
  },
6938
- finding: status === "pass" ? "The crawl found sameAs links attached to Organization or LocalBusiness structured data for the site entity." : status === "warn" ? "Entity schema is present, but no Organization or LocalBusiness sameAs evidence connects the site entity to official profiles." : "No Organization, LocalBusiness, Person, Product, or WebSite schema was found on the evaluated pages.",
7973
+ finding: status === "pass" ? "The crawl found sameAs links attached to Organization or LocalBusiness structured data for the site entity." : status === "warn" ? "Entity schema is present, but no Organization or LocalBusiness sameAs evidence connects the site entity to official profiles." : "No Organization, LocalBusiness, Person, Product, SoftwareApplication, or WebSite schema was found on the evaluated pages.",
6939
7974
  verification
6940
7975
  };
6941
7976
  }
@@ -7428,7 +8463,7 @@ const RULE_DEFINITIONS = [
7428
8463
  whyItMatters: "External links are part of the page experience and source trail. Broken references make content feel stale and less trustworthy.",
7429
8464
  howToFix: "Replace the link with a working source, update the URL, or remove the reference if it no longer supports the page.",
7430
8465
  impactIfIgnored: "Readers and agents following citations hit dead ends, which weakens trust in the content.",
7431
- howToVerify: "Re-run the crawl with external checks enabled and confirm the external link no longer appears in externalLinkChecks as broken."
8466
+ howToVerify: "Re-run the crawl with external checks enabled and confirm the URL no longer has a confirmed-broken externalLinkChecks result."
7432
8467
  },
7433
8468
  {
7434
8469
  id: "orphan_page",
@@ -8086,11 +9121,13 @@ function auditCrawlPages(pages, opts = {}) {
8086
9121
  if (page.hasHsts === false) issues.push(issue("hsts_missing", page, void 0, { header: "strict-transport-security" }));
8087
9122
  }
8088
9123
  for (const link of page.externalLinkChecks ?? []) {
8089
- if (!isBrokenLinkStatus(link.status)) continue;
9124
+ if (link.state !== "confirmed-broken") continue;
8090
9125
  issues.push(issue("broken_external_link", page, link.url, {
8091
9126
  url: link.url,
8092
9127
  status: link.status,
8093
- error: link.error
9128
+ error: link.error,
9129
+ state: link.state,
9130
+ attempts: link.attempts
8094
9131
  }));
8095
9132
  }
8096
9133
  if (page.indexable && (page.internalInlinkCount ?? 0) === 0 && !sameUrl(page.url, opts.startUrl)) issues.push(issue("orphan_page", page, "No internal inlinks", { internalInlinkCount: page.internalInlinkCount ?? 0 }));
@@ -8225,6 +9262,80 @@ function auditCrawlPages(pages, opts = {}) {
8225
9262
  return issues;
8226
9263
  }
8227
9264
  //#endregion
9265
+ //#region packages/core/dist/analyze/crawler/crawl-skip-reasons.js
9266
+ const CRAWL_SKIP_REASONS = [
9267
+ "asset-url",
9268
+ "configured-exclusion",
9269
+ "duplicate-normalization",
9270
+ "invalid-url",
9271
+ "off-origin",
9272
+ "origin-backpressure",
9273
+ "queue-safety-limit",
9274
+ "robots-disallowed",
9275
+ "robots-uncertain",
9276
+ "legacy-unclassified"
9277
+ ];
9278
+ const SKIP_IMPACT = {
9279
+ "asset-url": "non-impacting",
9280
+ "configured-exclusion": "non-impacting",
9281
+ "duplicate-normalization": "non-impacting",
9282
+ "invalid-url": "non-impacting",
9283
+ "off-origin": "non-impacting",
9284
+ "origin-backpressure": "coverage-affecting",
9285
+ "queue-safety-limit": "coverage-affecting",
9286
+ "robots-disallowed": "coverage-affecting",
9287
+ "robots-uncertain": "coverage-affecting",
9288
+ "legacy-unclassified": "coverage-affecting"
9289
+ };
9290
+ const REASON_ORDER = new Map(CRAWL_SKIP_REASONS.map((reason, index) => [reason, index]));
9291
+ function isCrawlSkipReason(value) {
9292
+ return typeof value === "string" && CRAWL_SKIP_REASONS.includes(value);
9293
+ }
9294
+ function validCount$1(value) {
9295
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
9296
+ }
9297
+ function crawlSkipImpact(reason) {
9298
+ return SKIP_IMPACT[reason];
9299
+ }
9300
+ function normalizeCrawlSkipReasonCounts(input) {
9301
+ const counts = /* @__PURE__ */ new Map();
9302
+ if (Array.isArray(input.skipReasons)) for (const item of input.skipReasons) {
9303
+ if (!item || typeof item !== "object") continue;
9304
+ const { reason, count } = item;
9305
+ if (!isCrawlSkipReason(reason)) continue;
9306
+ const normalizedCount = validCount$1(count);
9307
+ if (!normalizedCount) continue;
9308
+ counts.set(reason, (counts.get(reason) ?? 0) + normalizedCount);
9309
+ }
9310
+ const declaredTotal = validCount$1(input.skippedUrls);
9311
+ const classifiedTotal = [...counts.values()].reduce((total, count) => total + count, 0);
9312
+ if (declaredTotal > classifiedTotal) counts.set("legacy-unclassified", (counts.get("legacy-unclassified") ?? 0) + declaredTotal - classifiedTotal);
9313
+ const skipReasons = [...counts.entries()].map(([reason, count]) => ({
9314
+ reason,
9315
+ impact: crawlSkipImpact(reason),
9316
+ count
9317
+ })).sort((left, right) => (REASON_ORDER.get(left.reason) ?? Number.MAX_SAFE_INTEGER) - (REASON_ORDER.get(right.reason) ?? Number.MAX_SAFE_INTEGER));
9318
+ const skippedUrlsByImpact = skipReasons.reduce((totals, item) => {
9319
+ if (item.impact === "coverage-affecting") totals.coverageAffecting += item.count;
9320
+ else totals.nonImpacting += item.count;
9321
+ return totals;
9322
+ }, {
9323
+ coverageAffecting: 0,
9324
+ nonImpacting: 0
9325
+ });
9326
+ return {
9327
+ skippedUrls: skippedUrlsByImpact.coverageAffecting + skippedUrlsByImpact.nonImpacting,
9328
+ skipReasons,
9329
+ skippedUrlsByImpact
9330
+ };
9331
+ }
9332
+ function crawlSkipReasonCountsFromRecord(input = {}) {
9333
+ return normalizeCrawlSkipReasonCounts({ skipReasons: Object.entries(input).map(([reason, count]) => ({
9334
+ reason,
9335
+ count
9336
+ })) }).skipReasons;
9337
+ }
9338
+ //#endregion
8228
9339
  //#region packages/core/dist/analyze/crawler/report.js
8229
9340
  const SENSITIVE_FIELD_NAMES = /* @__PURE__ */ new Set([
8230
9341
  "authorization",
@@ -8263,6 +9374,7 @@ function normalizeCrawlConfig(input) {
8263
9374
  respectRobots: input.respectRobots ?? true,
8264
9375
  useSitemap: input.useSitemap ?? true,
8265
9376
  checkExternal: input.checkExternal ?? true,
9377
+ checkAgentDiscovery: input.checkAgentDiscovery ?? false,
8266
9378
  js: normalizeJavaScriptRenderingMode(input.js),
8267
9379
  refresh: input.refresh ?? false,
8268
9380
  fetchRate: normalizeFetchRate(input)
@@ -8382,12 +9494,13 @@ function summarizeCrawlReport(input) {
8382
9494
  }
8383
9495
  }
8384
9496
  for (const issue of input.issues) byCategory[issue.category] = (byCategory[issue.category] ?? 0) + 1;
9497
+ const runStats = crawlRunStats(input.pages, input.stats);
8385
9498
  return {
8386
9499
  totalPages: input.pages.length,
8387
9500
  indexablePages: input.pages.filter((page) => page.indexable).length,
8388
9501
  nonIndexablePages: input.pages.filter((page) => !page.indexable).length,
8389
9502
  statusErrors: input.pages.filter((page) => page.status === 0 || page.status >= 400).length,
8390
- ...crawlRunStats(input.pages, input.stats),
9503
+ ...runStats,
8391
9504
  attemptedRequests: input.requestEvidenceStatus === "unavailable" ? 0 : requests.length,
8392
9505
  responseRequests: requests.filter((request) => request.outcome === "response").length,
8393
9506
  failedRequests: failedRequests.length,
@@ -8412,11 +9525,17 @@ function crawlRunStats(pages, stats = {}) {
8412
9525
  for (const url of page.sampleExternalLinks ?? []) discovered.add(url);
8413
9526
  observedInternalLinks += page.outgoingInternalCount;
8414
9527
  }
9528
+ const skips = normalizeCrawlSkipReasonCounts({
9529
+ skippedUrls: stats.skippedUrls,
9530
+ skipReasons: stats.skipReasons ?? crawlSkipReasonCountsFromRecord(stats.skipReasonCounts)
9531
+ });
8415
9532
  return {
8416
9533
  discoveredUrls: stats.discoveredUrls ?? discovered.size,
8417
9534
  queuedUrls: stats.queuedUrls ?? pages.length,
8418
9535
  crawledUrls: stats.crawledUrls ?? pages.length,
8419
- skippedUrls: stats.skippedUrls ?? 0,
9536
+ skippedUrls: skips.skippedUrls,
9537
+ skipReasons: skips.skipReasons,
9538
+ skippedUrlsByImpact: skips.skippedUrlsByImpact,
8420
9539
  failedUrls: stats.failedUrls ?? pages.filter((page) => page.status === 0 || page.status >= 400).length,
8421
9540
  observedInternalLinks: stats.observedInternalLinks ?? observedInternalLinks,
8422
9541
  pageLimitReached: stats.pageLimitReached ?? false
@@ -8506,6 +9625,7 @@ function createCrawlReport(input) {
8506
9625
  ...input.ai ? { ai: sanitizeTenantValue(input.ai) } : {},
8507
9626
  ...input.sitemapDiscovery ? { sitemapDiscovery: sanitizeTenantValue(input.sitemapDiscovery) } : {},
8508
9627
  ...input.externalLinkVerification ? { externalLinkVerification: sanitizeTenantValue(input.externalLinkVerification) } : {},
9628
+ ...input.agentDiscovery ? { agentDiscovery: sanitizeTenantValue(input.agentDiscovery) } : {},
8509
9629
  warnings: sanitizeMessages(input.warnings).sort(compareText$13),
8510
9630
  caveats: sanitizeMessages(input.caveats).sort(compareText$13)
8511
9631
  };
@@ -8557,7 +9677,7 @@ function storageEnvelope(report) {
8557
9677
  if (report.site) tenant.site = report.site;
8558
9678
  return {
8559
9679
  kind: "seo.crawl_report",
8560
- version: 5,
9680
+ version: 6,
8561
9681
  savedAt: (/* @__PURE__ */ new Date()).toISOString(),
8562
9682
  ...tenant.projectId || tenant.site ? { tenant } : {},
8563
9683
  report
@@ -8593,7 +9713,7 @@ function saveCrawlReportToSqlite(report) {
8593
9713
  totalPages: report.summary.totalPages,
8594
9714
  issueCount: report.issues.length,
8595
9715
  createdAt: report.generatedAt,
8596
- storageVersion: 5
9716
+ storageVersion: 6
8597
9717
  };
8598
9718
  }
8599
9719
  function listCrawlReportsFromSqlite(input = {}) {
@@ -8676,6 +9796,15 @@ function cancellationRace(signal) {
8676
9796
  //#endregion
8677
9797
  //#region packages/core/dist/analyze/crawler/external-link-checks.js
8678
9798
  const EXTERNAL_LINK_SELECTION_LIMIT = 200;
9799
+ const EXTERNAL_LINK_STATES = [
9800
+ "available",
9801
+ "confirmed-broken",
9802
+ "transient",
9803
+ "provider-blocked",
9804
+ "rate-limited",
9805
+ "method-rejected",
9806
+ "unavailable"
9807
+ ];
8679
9808
  function stableHash(value) {
8680
9809
  let hash = 2166136261;
8681
9810
  for (const character of value) hash = Math.imul(hash ^ (character.codePointAt(0) ?? 0), 16777619);
@@ -8745,32 +9874,73 @@ function selectCandidateUrls(candidates, limit) {
8745
9874
  }
8746
9875
  return [...selected];
8747
9876
  }
8748
- async function checkExternalLink(url, timeoutMs, fetch, signal) {
9877
+ function isAvailableStatus(status) {
9878
+ return status !== void 0 && status >= 200 && status < 400;
9879
+ }
9880
+ function isBrokenStatus(status) {
9881
+ return status === 404 || status === 410;
9882
+ }
9883
+ function isMethodRejectedStatus(status) {
9884
+ return status === 405 || status === 501;
9885
+ }
9886
+ function isProviderBlockedStatus(status) {
9887
+ return status === 401 || status === 403 || status === 451;
9888
+ }
9889
+ function isTransientStatus(status) {
9890
+ return status === 408 || status === 425 || status !== void 0 && status >= 500;
9891
+ }
9892
+ function stateForAttempts(attempts) {
9893
+ const last = attempts.at(-1);
9894
+ const statuses = attempts.map((attempt) => attempt.status).filter((status) => status !== void 0);
9895
+ if (isAvailableStatus(last?.status)) return isMethodRejectedStatus(attempts[0]?.status) ? "method-rejected" : attempts.length > 1 ? "transient" : "available";
9896
+ if (attempts.length >= 2 && isBrokenStatus(last?.status) && attempts.at(-2)?.status === last?.status) return "confirmed-broken";
9897
+ if (last?.status === 429) return "rate-limited";
9898
+ if (isProviderBlockedStatus(last?.status)) return "provider-blocked";
9899
+ if (isMethodRejectedStatus(last?.status)) return "method-rejected";
9900
+ if (isTransientStatus(last?.status) || statuses.some(isBrokenStatus) || statuses.length > 0 && attempts.some((attempt) => attempt.error)) return "transient";
9901
+ return "unavailable";
9902
+ }
9903
+ async function requestExternalLink(url, method, timeoutMs, fetch, signal) {
8749
9904
  const controller = abortController({
8750
9905
  timeoutMs,
8751
9906
  signal
8752
9907
  });
8753
9908
  try {
8754
9909
  const response = await fetch(url, {
8755
- method: "HEAD",
9910
+ method,
8756
9911
  redirect: "follow",
8757
9912
  signal: controller.signal
8758
9913
  });
8759
9914
  await response.body?.cancel().catch(() => void 0);
8760
9915
  return {
8761
- url,
9916
+ method,
8762
9917
  status: response.status
8763
9918
  };
8764
9919
  } catch (error) {
8765
9920
  return {
8766
- url,
8767
- status: 0,
9921
+ method,
8768
9922
  error: error instanceof Error ? error.message : String(error)
8769
9923
  };
8770
9924
  } finally {
8771
9925
  controller.cleanup();
8772
9926
  }
8773
9927
  }
9928
+ async function checkExternalLink(url, timeoutMs, fetch, signal) {
9929
+ const attempts = [];
9930
+ attempts.push(await requestExternalLink(url, "HEAD", timeoutMs, fetch, signal));
9931
+ const head = attempts[0];
9932
+ if (!signal?.aborted && !isAvailableStatus(head?.status) && head?.status !== 429 && !isProviderBlockedStatus(head?.status)) attempts.push(await requestExternalLink(url, "GET", timeoutMs, fetch, signal));
9933
+ const last = attempts.at(-1);
9934
+ if (!signal?.aborted && isBrokenStatus(last?.status) && attempts.at(-2)?.status !== last?.status) attempts.push(await requestExternalLink(url, "GET", timeoutMs, fetch, signal));
9935
+ const finalAttempt = attempts.at(-1);
9936
+ return {
9937
+ url,
9938
+ ...finalAttempt?.status !== void 0 ? { status: finalAttempt.status } : {},
9939
+ ...finalAttempt?.error ? { error: finalAttempt.error } : {},
9940
+ state: stateForAttempts(attempts),
9941
+ attempts
9942
+ };
9943
+ }
8774
9944
  async function verifyExternalLinks(input) {
8775
9945
  const { candidates, discoveredLinkOccurrences, retainedLinkOccurrences } = collectCandidates(input.pages);
8776
9946
  const urls = input.signal?.aborted ? [] : selectCandidateUrls(candidates, EXTERNAL_LINK_SELECTION_LIMIT);
@@ -8785,16 +9955,22 @@ async function verifyExternalLinks(input) {
8785
9955
  const pageChecks = (page.sampleExternalLinks ?? []).map((url) => checks.get(url)).filter((value) => Boolean(value));
8786
9956
  if (pageChecks.length) page.externalLinkChecks = pageChecks;
8787
9957
  }
8788
- const fetchedUrls = [...checks.values()].filter((check) => typeof check.status === "number" && check.status > 0).length;
8789
- const failedUrls = checks.size - fetchedUrls;
9958
+ const fetchedUrls = [...checks.values()].filter((check) => check.attempts?.some((attempt) => attempt.status !== void 0)).length;
9959
+ const failedUrls = [...checks.values()].filter((check) => check.state === "unavailable").length;
9960
+ const unresolvedMethodRejectedUrls = [...checks.values()].filter((check) => check.state === "method-rejected" && !isAvailableStatus(check.status)).length;
8790
9961
  const deferredUrls = candidates.length - checks.size;
9962
+ const outcomes = Object.fromEntries(EXTERNAL_LINK_STATES.map((state) => [state, [...checks.values()].filter((check) => check.state === state).length]));
8791
9963
  const warnings = [];
8792
9964
  if (discoveredLinkOccurrences > retainedLinkOccurrences) warnings.push(`Retained ${retainedLinkOccurrences} sampled external link occurrence${retainedLinkOccurrences === 1 ? "" : "s"} from ${discoveredLinkOccurrences} observed occurrence${discoveredLinkOccurrences === 1 ? "" : "s"}.`);
8793
9965
  if (candidates.length > urls.length) warnings.push(`Selected ${urls.length} of ${candidates.length} retained external URLs using the ${EXTERNAL_LINK_SELECTION_LIMIT}-URL verification limit.`);
8794
9966
  if (checks.size < urls.length) warnings.push(`Stopped before checking ${urls.length - checks.size} selected external URL${urls.length - checks.size === 1 ? "" : "s"}.`);
8795
- if (failedUrls) warnings.push(`${failedUrls} external URL request${failedUrls === 1 ? "" : "s"} failed before a response was received.`);
9967
+ if (failedUrls) warnings.push(`${failedUrls} external URL${failedUrls === 1 ? "" : "s"} could not be reached after bounded verification.`);
9968
+ if (outcomes.transient) warnings.push(`${outcomes.transient} external URL${outcomes.transient === 1 ? "" : "s"} returned inconsistent or temporary responses. Recheck ${outcomes.transient === 1 ? "it" : "them"} before changing the source page.`);
9969
+ if (outcomes["provider-blocked"]) warnings.push(`${outcomes["provider-blocked"]} external URL${outcomes["provider-blocked"] === 1 ? "" : "s"} blocked automated verification. Open ${outcomes["provider-blocked"] === 1 ? "it" : "them"} manually before changing the source page.`);
9970
+ if (outcomes["rate-limited"]) warnings.push(`${outcomes["rate-limited"]} external URL${outcomes["rate-limited"] === 1 ? "" : "s"} rate-limited verification. Recheck ${outcomes["rate-limited"] === 1 ? "it" : "them"} later.`);
9971
+ if (unresolvedMethodRejectedUrls) warnings.push(`${unresolvedMethodRejectedUrls} external URL${unresolvedMethodRejectedUrls === 1 ? "" : "s"} rejected both verification methods. Open ${unresolvedMethodRejectedUrls === 1 ? "it" : "them"} manually before changing the source page.`);
8796
9972
  return {
8797
- dataStatus: discoveredLinkOccurrences > retainedLinkOccurrences || deferredUrls > 0 || failedUrls > 0 ? "partial" : "complete",
9973
+ dataStatus: discoveredLinkOccurrences > retainedLinkOccurrences || deferredUrls > 0 || failedUrls > 0 || outcomes.transient > 0 || outcomes["provider-blocked"] > 0 || outcomes["rate-limited"] > 0 || unresolvedMethodRejectedUrls > 0 ? "partial" : "complete",
8798
9974
  discoveredLinkOccurrences,
8799
9975
  retainedUrls: candidates.length,
8800
9976
  selectedUrls: urls.length,
@@ -8802,6 +9978,7 @@ async function verifyExternalLinks(input) {
8802
9978
  failedUrls,
8803
9979
  deferredUrls,
8804
9980
  limit: EXTERNAL_LINK_SELECTION_LIMIT,
9981
+ outcomes,
8805
9982
  warnings
8806
9983
  };
8807
9984
  }
@@ -9402,6 +10579,7 @@ async function crawlOne(url, opts = {}) {
9402
10579
  sampleExternalLinks: uniqueExternalLinks.slice(0, 25),
9403
10580
  internalAnchorSamples: anchorSamples(extracted.links, true),
9404
10581
  externalAnchorSamples: anchorSamples(extracted.links, false),
10582
+ markdownAlternates: extracted.markdownAlternates,
9405
10583
  schemaTypes: extracted.schemaTypes,
9406
10584
  structuredDataFormats: extracted.structuredDataFormats ?? [],
9407
10585
  googleRichResults: richResults.assessments,
@@ -9997,6 +11175,7 @@ function resolveCrawlSiteDependencies(dependencies = {}) {
9997
11175
  queryPagesTopQueriesBatch: injectedMode === "batch" ? dependencies.queryPagesTopQueriesBatch : injectedMode ? void 0 : queryPagesTopQueriesBatch,
9998
11176
  fetchLandingPageValues: dependencies.fetchLandingPageValues ?? fetchLandingPageValues,
9999
11177
  landingValueForUrl: dependencies.landingValueForUrl ?? landingValueForUrl,
11178
+ collectAgentDiscovery: dependencies.collectAgentDiscovery ?? collectAgentDiscovery,
10000
11179
  now: dependencies.now ?? (() => /* @__PURE__ */ new Date())
10001
11180
  };
10002
11181
  }
@@ -10322,6 +11501,11 @@ async function crawlSite(input, dependencies) {
10322
11501
  const followLinks = config.mode === "site";
10323
11502
  let queuedUrls = 0;
10324
11503
  let skippedUrls = 0;
11504
+ const skipReasonCounts = {};
11505
+ const recordSkip = (reason) => {
11506
+ skippedUrls += 1;
11507
+ skipReasonCounts[reason] = (skipReasonCounts[reason] ?? 0) + 1;
11508
+ };
10325
11509
  let robotsDeferredUrls = 0;
10326
11510
  let originBackpressureSkippedUrls = 0;
10327
11511
  let queueSafetySkippedUrls = 0;
@@ -10388,7 +11572,7 @@ async function crawlSite(input, dependencies) {
10388
11572
  const enqueue = (value, depth) => {
10389
11573
  const normalized = normalizeUrl$1(value, config.url);
10390
11574
  if (!normalized) {
10391
- skippedUrls += 1;
11575
+ recordSkip("invalid-url");
10392
11576
  emitStatus("url_skipped", {
10393
11577
  url: value,
10394
11578
  depth,
@@ -10405,7 +11589,7 @@ async function crawlSite(input, dependencies) {
10405
11589
  return;
10406
11590
  }
10407
11591
  if (!sameOrigin(normalized, origin)) {
10408
- skippedUrls += 1;
11592
+ recordSkip("off-origin");
10409
11593
  emitStatus("url_skipped", {
10410
11594
  url: normalized,
10411
11595
  depth,
@@ -10414,7 +11598,7 @@ async function crawlSite(input, dependencies) {
10414
11598
  return;
10415
11599
  }
10416
11600
  if (isLikelyAsset(normalized)) {
10417
- skippedUrls += 1;
11601
+ recordSkip("asset-url");
10418
11602
  emitStatus("url_skipped", {
10419
11603
  url: normalized,
10420
11604
  depth,
@@ -10423,7 +11607,7 @@ async function crawlSite(input, dependencies) {
10423
11607
  return;
10424
11608
  }
10425
11609
  if (!passesFilters(normalized, config.include, config.exclude)) {
10426
- skippedUrls += 1;
11610
+ recordSkip("configured-exclusion");
10427
11611
  emitStatus("url_skipped", {
10428
11612
  url: normalized,
10429
11613
  depth,
@@ -10432,7 +11616,7 @@ async function crawlSite(input, dependencies) {
10432
11616
  return;
10433
11617
  }
10434
11618
  if (queue.length + visited.size + inFlight.size >= config.maxPages * 5) {
10435
- skippedUrls += 1;
11619
+ recordSkip("queue-safety-limit");
10436
11620
  queueSafetySkippedUrls += 1;
10437
11621
  emitStatus("url_skipped", {
10438
11622
  url: normalized,
@@ -10541,7 +11725,7 @@ async function crawlSite(input, dependencies) {
10541
11725
  });
10542
11726
  requests.push(request);
10543
11727
  if (request.outcome === "skipped") {
10544
- skippedUrls += 1;
11728
+ recordSkip(request.reason === "robots-disallowed" ? "robots-disallowed" : request.reason === "robots-deferred" ? "robots-uncertain" : "origin-backpressure");
10545
11729
  if (request.reason === "robots-deferred") {
10546
11730
  robotsDeferredUrls += 1;
10547
11731
  warnings.push(`${task.url}: crawl deferred because robots.txt availability is unknown.`);
@@ -10646,7 +11830,7 @@ async function crawlSite(input, dependencies) {
10646
11830
  page.declaredIndexability = "robots-blocked";
10647
11831
  storeDocument([]);
10648
11832
  warnings.push(`${page.url}: skipped because robots.txt disallows it`);
10649
- skippedUrls += 1;
11833
+ recordSkip("robots-disallowed");
10650
11834
  emitStatus("page_skipped", {
10651
11835
  url: page.url,
10652
11836
  depth: task.depth,
@@ -10733,6 +11917,14 @@ async function crawlSite(input, dependencies) {
10733
11917
  message: "Finished external link checks."
10734
11918
  });
10735
11919
  }
11920
+ const agentDiscovery = !cancelled && config.checkAgentDiscovery ? await deps.collectAgentDiscovery({
11921
+ startUrl: config.url,
11922
+ pages,
11923
+ timeoutMs: config.timeoutMs,
11924
+ fetch: deps.fetch,
11925
+ signal,
11926
+ concurrency: Math.min(config.concurrency, 4)
11927
+ }) : void 0;
10736
11928
  for (const page of pages) {
10737
11929
  if (!page.geo) continue;
10738
11930
  page.geo = {
@@ -10759,6 +11951,7 @@ async function crawlSite(input, dependencies) {
10759
11951
  },
10760
11952
  ...sitemapDiscovery ? { sitemapDiscovery } : {},
10761
11953
  ...externalLinkVerification ? { externalLinkVerification } : {},
11954
+ ...agentDiscovery ? { agentDiscovery } : {},
10762
11955
  status: reportStatus,
10763
11956
  warnings,
10764
11957
  caveats: crawlCaveats({
@@ -10773,6 +11966,7 @@ async function crawlSite(input, dependencies) {
10773
11966
  queuedUrls,
10774
11967
  crawledUrls: pages.length,
10775
11968
  skippedUrls,
11969
+ skipReasonCounts,
10776
11970
  failedUrls,
10777
11971
  observedInternalLinks,
10778
11972
  pageLimitReached
@@ -10967,7 +12161,7 @@ function completenessReasons(report) {
10967
12161
  if (report.status !== "completed") reasons.push(`report-status-${report.status}`);
10968
12162
  if (report.summary.pageLimitReached) reasons.push("crawl-page-limit-reached");
10969
12163
  if (report.requestEvidenceStatus !== "available") reasons.push(`request-evidence-${report.requestEvidenceStatus}`);
10970
- if (report.summary.skippedUrls > 0) reasons.push("urls-skipped");
12164
+ if (report.summary.skippedUrlsByImpact.coverageAffecting > 0) reasons.push("coverage-affecting-urls-skipped");
10971
12165
  if (report.summary.failedRequests > 0) reasons.push("requests-failed");
10972
12166
  if (report.summary.abortedRequests > 0) reasons.push("requests-aborted");
10973
12167
  if (report.summary.extractionFailures > 0) reasons.push("document-extraction-failed");
@@ -10987,6 +12181,8 @@ function snapshotCompleteness(report) {
10987
12181
  requestEvidenceStatus: report.requestEvidenceStatus,
10988
12182
  pageLimitReached: report.summary.pageLimitReached,
10989
12183
  skippedUrls: report.summary.skippedUrls,
12184
+ skipReasons: report.summary.skipReasons,
12185
+ skippedUrlsByImpact: report.summary.skippedUrlsByImpact,
10990
12186
  failedRequests: report.summary.failedRequests,
10991
12187
  abortedRequests: report.summary.abortedRequests,
10992
12188
  extractionFailures: report.summary.extractionFailures,
@@ -11619,6 +12815,169 @@ function explainOkfValidation(validation) {
11619
12815
  };
11620
12816
  }
11621
12817
  //#endregion
12818
+ //#region packages/core/dist/analyze/crawler/agent-discovery-schema.js
12819
+ const agentRepresentationResponseSchema = z.object({
12820
+ requestedUrl: z.string().url(),
12821
+ finalUrl: z.string().url().optional(),
12822
+ status: z.number().int().optional(),
12823
+ contentType: z.string().optional(),
12824
+ bytes: z.number().int().nonnegative().optional(),
12825
+ sha256: z.string().optional(),
12826
+ canonicalUrl: z.string().url().optional(),
12827
+ alternateUrl: z.string().url().optional(),
12828
+ varyAccept: z.boolean(),
12829
+ markdownTokens: z.number().int().nonnegative().optional(),
12830
+ contentSignal: z.string().optional(),
12831
+ error: z.string().optional()
12832
+ });
12833
+ const agentDiscoverySchema = z.object({
12834
+ profile: z.literal("content"),
12835
+ profileApplicability: z.record(z.enum([
12836
+ "content",
12837
+ "api",
12838
+ "application",
12839
+ "commerce"
12840
+ ]), z.object({
12841
+ status: z.enum(["evaluated", "notApplicable"]),
12842
+ reason: z.string()
12843
+ })),
12844
+ dataStatus: z.enum([
12845
+ "complete",
12846
+ "partial",
12847
+ "unavailable"
12848
+ ]),
12849
+ markdownAlternates: z.object({
12850
+ eligibleHtmlPages: z.number().int().nonnegative(),
12851
+ advertisedPages: z.number().int().nonnegative(),
12852
+ evaluatedPages: z.number().int().nonnegative(),
12853
+ exactByteMatches: z.number().int().nonnegative(),
12854
+ stableResponses: z.number().int().nonnegative(),
12855
+ pages: z.array(z.object({
12856
+ htmlUrl: z.string().url(),
12857
+ advertisedUrls: z.array(z.string().url()),
12858
+ htmlAlternateUnique: z.boolean(),
12859
+ httpAlternateUrls: z.array(z.string().url()),
12860
+ explicit: agentRepresentationResponseSchema.optional(),
12861
+ negotiated: agentRepresentationResponseSchema.optional(),
12862
+ repeated: agentRepresentationResponseSchema.optional(),
12863
+ explicitMatchesNegotiated: z.boolean().nullable(),
12864
+ repeatedHashStable: z.boolean().nullable(),
12865
+ markdownCanonicalMatchesHtml: z.boolean().nullable(),
12866
+ quality: z.object({
12867
+ frontmatterTitle: z.boolean(),
12868
+ h1Count: z.number().int().nonnegative(),
12869
+ codeFenceBalanced: z.boolean(),
12870
+ tableRows: z.number().int().nonnegative(),
12871
+ links: z.number().int().nonnegative(),
12872
+ wordCount: z.number().int().nonnegative(),
12873
+ rawHtmlTags: z.number().int().nonnegative(),
12874
+ rawSvgTags: z.number().int().nonnegative(),
12875
+ rawScriptTags: z.number().int().nonnegative(),
12876
+ rawStyleTags: z.number().int().nonnegative(),
12877
+ suspiciousConcatenations: z.number().int().nonnegative(),
12878
+ repeatedLines: z.number().int().nonnegative(),
12879
+ sourceWordCount: z.number().int().nonnegative(),
12880
+ wordRetentionRatio: z.number().nonnegative().nullable(),
12881
+ introductoryCopyRetained: z.boolean().nullable(),
12882
+ navigationOnly: z.boolean()
12883
+ }).optional()
12884
+ }))
12885
+ }),
12886
+ contentNegotiation: z.object({
12887
+ qZeroHonoured: z.boolean().nullable(),
12888
+ qZeroStatus: z.number().int().optional(),
12889
+ qZeroContentType: z.string().optional(),
12890
+ error: z.string().optional()
12891
+ }),
12892
+ routeManifest: z.object({
12893
+ url: z.string().url(),
12894
+ status: z.number().int().optional(),
12895
+ valid: z.boolean(),
12896
+ declaredHtmlRoutes: z.array(z.string()),
12897
+ declaredMarkdownRoutes: z.array(z.string()),
12898
+ missingHtmlRoutes: z.array(z.string()),
12899
+ missingMarkdownRoutes: z.array(z.string()),
12900
+ orphanMarkdownRoutes: z.array(z.string()),
12901
+ error: z.string().optional()
12902
+ }),
12903
+ agentSkills: z.object({
12904
+ indexUrl: z.string().url(),
12905
+ status: z.number().int().optional(),
12906
+ contentType: z.string().optional(),
12907
+ cors: z.string().optional(),
12908
+ validIndex: z.boolean(),
12909
+ skills: z.array(z.object({
12910
+ name: z.string().optional(),
12911
+ url: z.string().url().optional(),
12912
+ status: z.number().int().optional(),
12913
+ contentType: z.string().optional(),
12914
+ declaredDigest: z.string().optional(),
12915
+ observedDigest: z.string().optional(),
12916
+ digestMatches: z.boolean().nullable(),
12917
+ frontmatterValid: z.boolean().nullable(),
12918
+ sameOrigin: z.boolean(),
12919
+ cors: z.string().optional(),
12920
+ error: z.string().optional()
12921
+ })),
12922
+ error: z.string().optional()
12923
+ }),
12924
+ llmsTxt: z.object({
12925
+ url: z.string().url(),
12926
+ exists: z.boolean(),
12927
+ status: z.number().int().optional(),
12928
+ contentType: z.string().optional(),
12929
+ bytes: z.number().int().nonnegative().optional(),
12930
+ sha256: z.string().optional(),
12931
+ repeatedHashStable: z.boolean().nullable(),
12932
+ headingCount: z.number().int().nonnegative(),
12933
+ totalParsedLinks: z.number().int().nonnegative(),
12934
+ linkLimitReached: z.boolean(),
12935
+ links: z.array(z.object({
12936
+ label: z.string(),
12937
+ url: z.string().url(),
12938
+ sameOrigin: z.boolean(),
12939
+ status: z.number().int().optional(),
12940
+ finalUrl: z.string().url().optional(),
12941
+ redirected: z.boolean(),
12942
+ indexableTarget: z.boolean().optional(),
12943
+ error: z.string().optional()
12944
+ })),
12945
+ invalidLinks: z.array(z.string()),
12946
+ duplicateLinks: z.array(z.string().url()),
12947
+ offSiteLinks: z.array(z.string().url()),
12948
+ redirectedLinks: z.array(z.string().url()),
12949
+ nonIndexableLinks: z.array(z.string().url()),
12950
+ missingCrawlRoutes: z.array(z.string().url()),
12951
+ oversized: z.boolean(),
12952
+ error: z.string().optional()
12953
+ }),
12954
+ contentSignals: z.object({
12955
+ htmlValues: z.array(z.string()),
12956
+ markdownValues: z.array(z.string()),
12957
+ missingHtmlPages: z.number().int().nonnegative(),
12958
+ missingMarkdownPages: z.number().int().nonnegative(),
12959
+ consistent: z.boolean().nullable()
12960
+ }),
12961
+ protocolVariants: z.object({
12962
+ http: z.object({
12963
+ url: z.string().url(),
12964
+ status: z.number().int().optional(),
12965
+ location: z.string().url().optional(),
12966
+ permanentRedirectToHttps: z.boolean().nullable(),
12967
+ error: z.string().optional()
12968
+ }),
12969
+ www: z.object({
12970
+ url: z.string().url(),
12971
+ status: z.number().int().optional(),
12972
+ location: z.string().url().optional(),
12973
+ redirectsToPreferredHost: z.boolean().nullable(),
12974
+ error: z.string().optional()
12975
+ }),
12976
+ hstsOnStartPage: z.boolean().nullable()
12977
+ }),
12978
+ warnings: z.array(z.string())
12979
+ });
12980
+ //#endregion
11622
12981
  //#region packages/core/dist/analyze/crawler/schemas.js
11623
12982
  const crawlerRuleSeveritySchema = z.enum([
11624
12983
  "low",
@@ -12043,10 +13402,25 @@ const crawlPageSnapshotSchema = z.object({
12043
13402
  href: z.string().url(),
12044
13403
  text: z.string()
12045
13404
  })).optional(),
13405
+ markdownAlternates: z.array(z.string().url()).optional(),
12046
13406
  externalLinkChecks: z.array(z.object({
12047
13407
  url: z.string().url(),
12048
13408
  status: z.number().int().optional(),
12049
- error: z.string().optional()
13409
+ error: z.string().optional(),
13410
+ state: z.enum([
13411
+ "available",
13412
+ "confirmed-broken",
13413
+ "transient",
13414
+ "provider-blocked",
13415
+ "rate-limited",
13416
+ "method-rejected",
13417
+ "unavailable"
13418
+ ]).optional(),
13419
+ attempts: z.array(z.object({
13420
+ method: z.enum(["HEAD", "GET"]),
13421
+ status: z.number().int().optional(),
13422
+ error: z.string().optional()
13423
+ })).optional()
12050
13424
  })).optional(),
12051
13425
  schemaTypes: z.array(z.string()).optional(),
12052
13426
  structuredDataFormats: z.array(z.enum([
@@ -12327,6 +13701,15 @@ const crawlExternalLinkVerificationSchema = z.object({
12327
13701
  failedUrls: z.number().int().nonnegative(),
12328
13702
  deferredUrls: z.number().int().nonnegative(),
12329
13703
  limit: z.number().int().positive(),
13704
+ outcomes: z.record(z.enum([
13705
+ "available",
13706
+ "confirmed-broken",
13707
+ "transient",
13708
+ "provider-blocked",
13709
+ "rate-limited",
13710
+ "method-rejected",
13711
+ "unavailable"
13712
+ ]), z.number().int().nonnegative()).optional(),
12330
13713
  warnings: z.array(z.string())
12331
13714
  });
12332
13715
  const crawlConfigSchema = z.object({
@@ -12347,6 +13730,7 @@ const crawlConfigSchema = z.object({
12347
13730
  respectRobots: z.boolean(),
12348
13731
  useSitemap: z.boolean(),
12349
13732
  checkExternal: z.boolean(),
13733
+ checkAgentDiscovery: z.boolean(),
12350
13734
  js: z.union([z.enum([
12351
13735
  "auto",
12352
13736
  "on",
@@ -12377,6 +13761,15 @@ const crawlReportSummarySchema = z.object({
12377
13761
  queuedUrls: z.number().int(),
12378
13762
  crawledUrls: z.number().int(),
12379
13763
  skippedUrls: z.number().int(),
13764
+ skipReasons: z.array(z.object({
13765
+ reason: z.enum(CRAWL_SKIP_REASONS),
13766
+ impact: z.enum(["coverage-affecting", "non-impacting"]),
13767
+ count: z.number().int().positive()
13768
+ })),
13769
+ skippedUrlsByImpact: z.object({
13770
+ coverageAffecting: z.number().int().nonnegative(),
13771
+ nonImpacting: z.number().int().nonnegative()
13772
+ }),
12380
13773
  failedUrls: z.number().int(),
12381
13774
  observedInternalLinks: z.number().int(),
12382
13775
  pageLimitReached: z.boolean().default(false),
@@ -12459,6 +13852,7 @@ const crawlReportBaseSchema = z.object({
12459
13852
  ai: crawlAiSignalsSchema.optional(),
12460
13853
  sitemapDiscovery: crawlSitemapDiscoverySchema.optional(),
12461
13854
  externalLinkVerification: crawlExternalLinkVerificationSchema.optional(),
13855
+ agentDiscovery: agentDiscoverySchema.optional(),
12462
13856
  warnings: z.array(z.string()),
12463
13857
  caveats: z.array(z.string())
12464
13858
  });
@@ -18184,7 +19578,7 @@ function crawlInput(input) {
18184
19578
  return {
18185
19579
  pages,
18186
19580
  evidence: sourceEvidence({
18187
- completeness: report ? report.summary.pageLimitReached ? "truncated" : report.status === "completed" ? "complete" : report.status === "partial" ? "partial" : "unknown" : "completeness" in input ? input.completeness : "unknown",
19581
+ completeness: report ? report.summary.pageLimitReached ? "truncated" : report.status === "partial" || report.summary.skippedUrlsByImpact.coverageAffecting > 0 ? "partial" : report.status === "completed" ? "complete" : "unknown" : "completeness" in input ? input.completeness : "unknown",
18188
19582
  rowsReceived: pages.length,
18189
19583
  validUrls: urls.length,
18190
19584
  uniqueUrls: uniqueUrls.size,
@@ -23236,14 +24630,14 @@ function workflowReport(input) {
23236
24630
  async function diagnosePropertyWorkflow(input) {
23237
24631
  const narrative = await reportNarrative(input);
23238
24632
  const skippedCount = narrative.diagnosis.skippedSections?.length ?? 0;
23239
- const stepSummary = narrative.dataStatus === "complete" ? "Generated diagnosis, movement, change, and monitoring narrative." : skippedCount ? `Generated ${narrative.dataStatus === "unavailable" ? "an" : "a"} ${narrative.dataStatus} diagnosis; ${skippedCount} sections were unavailable.` : "Generated a partial diagnosis because one or more source datasets were incomplete.";
24633
+ const stepSummary = input.skipSearchData ? "Skipped provider-backed search diagnosis because no Search Console property was selected." : narrative.dataStatus === "complete" ? "Generated diagnosis, movement, change, and monitoring narrative." : skippedCount ? `Generated ${narrative.dataStatus === "unavailable" ? "an" : "a"} ${narrative.dataStatus} diagnosis; ${skippedCount} sections were unavailable.` : "Generated a partial diagnosis because one or more source datasets were incomplete.";
23240
24634
  return workflowReport({
23241
24635
  workflow: "diagnose-property",
23242
24636
  site: input.site,
23243
24637
  summary: narrative.headline,
23244
24638
  steps: [{
23245
24639
  tool: "seo_report_narrative",
23246
- status: "completed",
24640
+ status: input.skipSearchData ? "skipped" : "completed",
23247
24641
  summary: stepSummary
23248
24642
  }],
23249
24643
  actions: narrative.priorities.map((priority) => ({
@@ -24780,6 +26174,9 @@ function resolveSavedReportAlias(input) {
24780
26174
  }
24781
26175
  return loadCrawlReport(input.value);
24782
26176
  }
26177
+ function assertExclusiveReportInput(url, reportId) {
26178
+ if (url && reportId) throw new SeoError("INVALID_INPUT", "Use either url or reportId, not both.");
26179
+ }
24783
26180
  function registerCrawlerTools(server) {
24784
26181
  server.registerTool("seo_crawl_site", {
24785
26182
  description: "Crawl a site and run technical SEO checks. The compact result separates prioritised fixes from review observations. Set includePages/includeIssues for raw data.",
@@ -24896,6 +26293,7 @@ function registerCrawlerTools(server) {
24896
26293
  }
24897
26294
  }, async ({ url, reportId, site, maxPages, maxDepth, fetchIntervalCap, fetchIntervalMs, refresh, category, limit }) => {
24898
26295
  try {
26296
+ assertExclusiveReportInput(url, reportId);
24899
26297
  const report = url ? await crawlSite({
24900
26298
  url,
24901
26299
  site,
@@ -25022,6 +26420,40 @@ function registerCrawlerTools(server) {
25022
26420
  return toolError(error);
25023
26421
  }
25024
26422
  });
26423
+ server.registerTool("seo_agent_readiness", {
26424
+ description: "Check a content site for stable Markdown alternatives, agent discovery, crawler access, and identity evidence without an aggregate score.",
26425
+ inputSchema: {
26426
+ url: z$1.string().url().optional(),
26427
+ reportId: z$1.string().optional(),
26428
+ site: z$1.string().optional(),
26429
+ maxPages: z$1.number().int().positive().optional(),
26430
+ fetchIntervalCap: z$1.number().int().positive().optional(),
26431
+ fetchIntervalMs: z$1.number().int().positive().optional(),
26432
+ refresh: z$1.boolean().optional()
26433
+ }
26434
+ }, async ({ url, reportId, site, maxPages, fetchIntervalCap, fetchIntervalMs, refresh }) => {
26435
+ try {
26436
+ assertExclusiveReportInput(url, reportId);
26437
+ const report = url ? await crawlSite({
26438
+ url,
26439
+ site,
26440
+ maxPages,
26441
+ refresh,
26442
+ checkAgentDiscovery: true,
26443
+ useSitemap: true,
26444
+ checkExternal: false,
26445
+ fetchRate: fetchRateInput({
26446
+ fetchIntervalCap,
26447
+ fetchIntervalMs
26448
+ })
26449
+ }) : reportId ? loadCrawlReport(reportId) : latestCrawlReport(site);
26450
+ if (!report) return toolError("No crawl report found. Pass url, reportId, or run seo_crawl_site with saveReport first.");
26451
+ const readiness = agentReadiness(report);
26452
+ return toolSuccess(readiness.headline, readiness);
26453
+ } catch (error) {
26454
+ return toolError(error);
26455
+ }
26456
+ });
25025
26457
  server.registerTool("seo_ai_readiness", {
25026
26458
  description: "Return AI-search technical evidence and optional observations without an aggregate score or citation prediction.",
25027
26459
  inputSchema: {
@@ -26206,6 +27638,39 @@ const REPORT_DEPTH = {
26206
27638
  }
26207
27639
  ]
26208
27640
  },
27641
+ "agent-readiness": {
27642
+ readOrder: [
27643
+ "profile, profileApplicability, dataStatus, and crawl caveats",
27644
+ "summary and topActions",
27645
+ "HTML and Markdown representation checks with affected URLs",
27646
+ "Agent Skills, llms.txt, route manifest, crawler access, and identity evidence"
27647
+ ],
27648
+ doNotClaim: [
27649
+ "A clean content profile is not proof of indexing, rankings, AI mentions, citations, or selection.",
27650
+ "API, application, and commerce checks marked notApplicable were outside this content-site run. They did not fail.",
27651
+ "An allowed crawler token does not prove that a service fetched or used the page.",
27652
+ "Optional discovery files are not Google ranking requirements."
27653
+ ],
27654
+ verify: "Run the same content profile against the same public route scope after deployment and confirm each failed or warning check changed.",
27655
+ related: [
27656
+ {
27657
+ id: "ai-readiness",
27658
+ reason: "Checks AI search technical eligibility."
27659
+ },
27660
+ {
27661
+ id: "llms-txt-audit",
27662
+ reason: "Inspects llms.txt in more detail."
27663
+ },
27664
+ {
27665
+ id: "entity-readiness",
27666
+ reason: "Reviews identity evidence."
27667
+ },
27668
+ {
27669
+ id: "site-crawl",
27670
+ reason: "Creates a reusable crawl baseline."
27671
+ }
27672
+ ]
27673
+ },
26209
27674
  "ai-readiness": {
26210
27675
  readOrder: [
26211
27676
  "dataStatus and crawl caveats",
@@ -27575,6 +29040,13 @@ const REPORT_GUIDANCE = {
27575
29040
  avoidWhen: ["You have not run or selected a crawl yet.", "You need an overview of the most important crawl findings first."],
27576
29041
  outcome: "A focused list of affected URLs with the evidence for each match."
27577
29042
  },
29043
+ "agent-readiness": {
29044
+ name: "AI agent readiness",
29045
+ description: "Check whether a content site gives agents clean, stable, machine-readable pages and discovery files.",
29046
+ useWhen: ["You want to test Markdown alternatives, content negotiation, Agent Skills, llms.txt, identity, and crawler access together.", "You need evidence that the agent-facing version of a content site matches its public HTML routes."],
29047
+ avoidWhen: ["You need an AI visibility, mention, citation, or ranking report.", "You are auditing a public API, interactive application, or commerce flow rather than a content site."],
29048
+ outcome: "An unscored content-site assessment with failed routes, evidence, and clear next actions."
29049
+ },
27578
29050
  "ai-readiness": {
27579
29051
  name: "AI search technical readiness",
27580
29052
  description: "Check whether crawl, index, or snippet controls could block pages from Google AI search features.",
@@ -28348,6 +29820,7 @@ const reportGroups = [
28348
29820
  register: registerCrawlerTools,
28349
29821
  names: [
28350
29822
  "seo_affected_urls",
29823
+ "seo_agent_readiness",
28351
29824
  "seo_ai_readiness",
28352
29825
  "seo_audit_urls",
28353
29826
  "seo_compare_crawl_reports",