aeorank 1.5.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  extractAllUrlsFromSitemap,
4
4
  extractInternalLinks,
5
5
  inferCategory
6
- } from "./chunk-3IJISYWT.js";
6
+ } from "./chunk-PKJIKMLV.js";
7
7
 
8
8
  // src/parked-domain.ts
9
9
  var PARKING_PATHS = ["/lander", "/parking", "/park", "/sedoparking"];
@@ -195,7 +195,7 @@ async function prefetchSiteData(domain) {
195
195
  sitemapForBlog = subSitemap.text;
196
196
  }
197
197
  }
198
- const blogUrls = extractBlogUrlsFromSitemap(sitemapForBlog, domain, 10);
198
+ const blogUrls = extractBlogUrlsFromSitemap(sitemapForBlog, domain, 50);
199
199
  if (blogUrls.length > 0) {
200
200
  const fetched = await Promise.all(blogUrls.map((url) => fetchText(url)));
201
201
  blogSample = fetched.filter(
@@ -552,15 +552,17 @@ function checkOriginalData(data) {
552
552
  findings.push({ severity: "critical", detail: "Could not fetch homepage" });
553
553
  return { criterion: "original_data", criterion_label: "Original Data & Expert Content", score: 0, status: "not_found", findings, fix_priority: "P2" };
554
554
  }
555
+ const allPages = [data.homepage, ...data.blogSample || []].filter(Boolean);
555
556
  const html = data.homepage.text;
556
- const text = html.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ");
557
+ const allText = allPages.map((p) => p.text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ")).join(" ");
558
+ const text = data.homepage.text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ");
557
559
  let score = 0;
558
560
  const statPatterns = /\d+%|\d+\s*(patients|clients|customers|cases|years|professionals|specialists|companies|users|businesses|domains|audits)/i;
559
- if (statPatterns.test(text)) {
561
+ if (statPatterns.test(allText)) {
560
562
  const researchContext = /\b(our\s+(?:study|analysis|research|data|survey|findings|report)|we\s+(?:surveyed|analyzed|studied|measured|tracked)|proprietary|methodology|original\s+research)\b/i;
561
- if (researchContext.test(text)) {
563
+ if (researchContext.test(allText)) {
562
564
  score += 3;
563
- findings.push({ severity: "info", detail: "Proprietary statistics with research context found on homepage" });
565
+ findings.push({ severity: "info", detail: "Proprietary statistics with research context found" });
564
566
  } else {
565
567
  score += 1;
566
568
  findings.push({ severity: "low", detail: 'Statistics found but without research context (e.g., "500+ clients")', fix: 'Add context about your methodology: "Our analysis of X found..." or "We surveyed Y..."' });
@@ -1075,20 +1077,24 @@ function checkFactDensity(data) {
1075
1077
  findings.push({ severity: "critical", detail: "Could not fetch homepage" });
1076
1078
  return { criterion: "fact_density", criterion_label: "Fact & Data Density", score: 0, status: "not_found", findings, fix_priority: "P2" };
1077
1079
  }
1078
- const text = data.homepage.text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ");
1080
+ const allPages = [data.homepage, ...data.blogSample || []].filter(Boolean);
1081
+ const allText = allPages.map((p) => p.text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ")).join(" ");
1082
+ const text = allText;
1083
+ const pageCount = allPages.length;
1079
1084
  let score = 0;
1080
1085
  const dataPoints = text.match(/\d+(?:\.\d+)?(?:\s*%|\s*\$|\s*USD|\s*EUR)/g) || [];
1081
1086
  const countPhrases = text.match(/\d+(?:,\d{3})*\+?\s+(?:users?|clients?|customers?|companies|businesses|patients?|members?|employees?|projects?|downloads?)/gi) || [];
1082
1087
  const totalDataPoints = dataPoints.length + countPhrases.length;
1083
- if (totalDataPoints >= 6) {
1088
+ const avgPerPage = pageCount > 0 ? totalDataPoints / pageCount : 0;
1089
+ if (avgPerPage >= 4) {
1084
1090
  score += 5;
1085
- findings.push({ severity: "info", detail: `${totalDataPoints} quantitative data points found on homepage` });
1086
- } else if (totalDataPoints >= 3) {
1091
+ findings.push({ severity: "info", detail: `${totalDataPoints} quantitative data points found across ${pageCount} pages (avg ${avgPerPage.toFixed(1)}/page)` });
1092
+ } else if (avgPerPage >= 2) {
1087
1093
  score += 3;
1088
- findings.push({ severity: "info", detail: `${totalDataPoints} quantitative data points found` });
1094
+ findings.push({ severity: "info", detail: `${totalDataPoints} quantitative data points found across ${pageCount} pages` });
1089
1095
  } else if (totalDataPoints >= 1) {
1090
1096
  score += 1;
1091
- findings.push({ severity: "low", detail: `Only ${totalDataPoints} quantitative data point(s) found`, fix: "Add more specific numbers, percentages, and metrics to strengthen credibility" });
1097
+ findings.push({ severity: "low", detail: `Only ${totalDataPoints} quantitative data point(s) found across ${pageCount} pages`, fix: "Add more specific numbers, percentages, and metrics to strengthen credibility" });
1092
1098
  } else {
1093
1099
  findings.push({ severity: "high", detail: "No quantitative data points found", fix: "Add specific statistics (percentages, counts, comparisons) that AI engines can cite" });
1094
1100
  }
@@ -1194,9 +1200,9 @@ function countRecentSitemapDates(sitemapText) {
1194
1200
  distinctRecentDays: recentDays.size
1195
1201
  };
1196
1202
  }
1197
- var BLOG_PATH_PATTERNS = /\/(?:blog|articles?|insights?|guides?|resources?|news|posts?|learn|help|how-?to|tutorials?|case-stud|whitepapers?)\b/i;
1203
+ var BLOG_PATH_PATTERNS = /\/(?:[^/]*-?)?(?:blog|articles?|insights?|guides?|resources?|news|posts?|learn|help|how-?to|tutorials?|case-stud|whitepapers?)\b/i;
1198
1204
  var EXCLUDE_PATH_PATTERNS = /\/(?:tag|category|author|page|feed|wp-content|wp-admin|wp-json|cart|checkout|login|search|api|static|assets|_next)\b/i;
1199
- function extractBlogUrlsFromSitemap(sitemapText, domain, limit = 5) {
1205
+ function extractBlogUrlsFromSitemap(sitemapText, domain, limit = 50) {
1200
1206
  const urlBlocks = sitemapText.match(/<url>([\s\S]*?)<\/url>/gi) || [];
1201
1207
  const candidates = [];
1202
1208
  const cleanDomain = domain.replace(/^www\./, "").toLowerCase();
@@ -1492,7 +1498,7 @@ function jaccardSimilarity(a, b) {
1492
1498
  const union = a.size + b.size - intersection;
1493
1499
  return union === 0 ? 0 : intersection / union;
1494
1500
  }
1495
- function checkContentCannibalization(data) {
1501
+ function checkContentCannibalization(data, topicCoherenceScore) {
1496
1502
  const findings = [];
1497
1503
  if (!data.homepage) {
1498
1504
  findings.push({ severity: "critical", detail: "No homepage available for cannibalization analysis" });
@@ -1502,7 +1508,7 @@ function checkContentCannibalization(data) {
1502
1508
  { html: data.homepage.text, url: data.homepage.finalUrl || `https://${data.domain}/` }
1503
1509
  ];
1504
1510
  if (data.blogSample) {
1505
- for (const page of data.blogSample.slice(0, 5)) {
1511
+ for (const page of data.blogSample) {
1506
1512
  pages.push({ html: page.text, url: page.finalUrl || "" });
1507
1513
  }
1508
1514
  }
@@ -1512,10 +1518,29 @@ function checkContentCannibalization(data) {
1512
1518
  }
1513
1519
  const pageTitles = pages.map((p) => ({ title: extractPageTitle(p.html), url: p.url }));
1514
1520
  const wordSets = pageTitles.map((p) => titleToWordSet(p.title));
1521
+ const termPageCount = /* @__PURE__ */ new Map();
1522
+ for (const ws of wordSets) {
1523
+ for (const w of ws) {
1524
+ termPageCount.set(w, (termPageCount.get(w) || 0) + 1);
1525
+ }
1526
+ }
1527
+ const commonTermThreshold = Math.max(3, pages.length * 0.4);
1528
+ const siteThemeTerms = /* @__PURE__ */ new Set();
1529
+ for (const [term, count] of termPageCount) {
1530
+ if (count >= commonTermThreshold) siteThemeTerms.add(term);
1531
+ }
1532
+ const filteredSets = wordSets.map((ws) => {
1533
+ const filtered = /* @__PURE__ */ new Set();
1534
+ for (const w of ws) {
1535
+ if (!siteThemeTerms.has(w)) filtered.add(w);
1536
+ }
1537
+ return filtered;
1538
+ });
1515
1539
  const cannibalPairs = [];
1516
1540
  for (let i = 0; i < pages.length; i++) {
1517
1541
  for (let j = i + 1; j < pages.length; j++) {
1518
- const sim = jaccardSimilarity(wordSets[i], wordSets[j]);
1542
+ if (filteredSets[i].size === 0 && filteredSets[j].size === 0) continue;
1543
+ const sim = jaccardSimilarity(filteredSets[i], filteredSets[j]);
1519
1544
  if (sim > 0.6) {
1520
1545
  cannibalPairs.push({
1521
1546
  urlA: pageTitles[i].url.slice(0, 60),
@@ -1525,23 +1550,39 @@ function checkContentCannibalization(data) {
1525
1550
  }
1526
1551
  }
1527
1552
  }
1553
+ const cannibalUrls = /* @__PURE__ */ new Set();
1554
+ for (const pair of cannibalPairs) {
1555
+ cannibalUrls.add(pair.urlA);
1556
+ cannibalUrls.add(pair.urlB);
1557
+ }
1558
+ const cannibalRatio = pages.length > 0 ? cannibalUrls.size / pages.length : 0;
1528
1559
  let score;
1529
1560
  if (cannibalPairs.length === 0) {
1530
1561
  score = 10;
1531
1562
  findings.push({ severity: "info", detail: `${pages.length} pages analyzed - no content cannibalization detected` });
1532
- } else if (cannibalPairs.length === 1) {
1533
- score = 8;
1534
- findings.push({ severity: "low", detail: `1 pair of pages with overlapping topics (${cannibalPairs[0].similarity}% similarity)`, fix: "Differentiate titles and H1 headings to reduce topic overlap" });
1535
- } else if (cannibalPairs.length === 2) {
1563
+ } else if (cannibalRatio <= 0.05) {
1564
+ score = 9;
1565
+ findings.push({ severity: "info", detail: `${cannibalPairs.length} pair(s) of pages with minor topic overlap (${cannibalUrls.size}/${pages.length} pages affected)` });
1566
+ } else if (cannibalRatio <= 0.1) {
1567
+ score = 7;
1568
+ findings.push({ severity: "low", detail: `${cannibalUrls.size} pages (${Math.round(cannibalRatio * 100)}%) have overlapping topics`, fix: "Differentiate titles and H1 headings to reduce topic overlap" });
1569
+ } else if (cannibalRatio <= 0.2) {
1536
1570
  score = 5;
1537
- findings.push({ severity: "medium", detail: `${cannibalPairs.length} pairs of pages with overlapping topics`, fix: "Consolidate overlapping pages or differentiate their titles and content focus" });
1571
+ findings.push({ severity: "medium", detail: `${cannibalUrls.size} pages (${Math.round(cannibalRatio * 100)}%) competing for overlapping topics`, fix: "Consolidate overlapping pages or differentiate their titles and content focus" });
1572
+ } else if (cannibalRatio <= 0.4) {
1573
+ score = 3;
1574
+ findings.push({ severity: "medium", detail: `${cannibalUrls.size} pages (${Math.round(cannibalRatio * 100)}%) have significant content overlap`, fix: "Many pages compete for the same topics - consolidate or clearly differentiate them" });
1538
1575
  } else {
1539
1576
  score = 0;
1540
- findings.push({ severity: "high", detail: `${cannibalPairs.length} pairs of pages competing for the same topics`, fix: "Significant content overlap detected - consolidate or clearly differentiate competing pages" });
1577
+ findings.push({ severity: "high", detail: `${cannibalUrls.size} pages (${Math.round(cannibalRatio * 100)}%) competing for the same topics`, fix: "Severe content cannibalization - consolidate overlapping pages or create clear topic differentiation" });
1541
1578
  }
1542
1579
  for (const pair of cannibalPairs.slice(0, 3)) {
1543
1580
  findings.push({ severity: "low", detail: `Overlap (${pair.similarity}%): ${pair.urlA} vs ${pair.urlB}` });
1544
1581
  }
1582
+ if (topicCoherenceScore !== void 0 && topicCoherenceScore <= 4 && score >= 8) {
1583
+ score = 6;
1584
+ findings.push({ severity: "low", detail: "Low topic overlap but content lacks coherent focus - not a strong signal for AI authority", fix: "Focus content on fewer core topics to build topical authority that AI engines can identify" });
1585
+ }
1545
1586
  return { criterion: "content_cannibalization", criterion_label: "Content Cannibalization", score, status: score >= 7 ? "pass" : score >= 4 ? "partial" : "fail", findings, fix_priority: score >= 7 ? "P3" : "P1" };
1546
1587
  }
1547
1588
  function checkVisibleDateSignal(data) {
@@ -1767,7 +1808,233 @@ function extractRawDataSummary(data) {
1767
1808
  crawl_skipped: data.crawlStats?.skipped ?? 0
1768
1809
  };
1769
1810
  }
1811
+ function getPageTopicText(html) {
1812
+ const titleMatch = html.match(/<title[^>]*>([^<]+)<\/title>/i);
1813
+ const h1Match = html.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i);
1814
+ return [
1815
+ titleMatch?.[1] || "",
1816
+ h1Match?.[1]?.replace(/<[^>]*>/g, "") || ""
1817
+ ].join(" ").toLowerCase().trim();
1818
+ }
1819
+ function extractBigrams(text) {
1820
+ const words = text.split(/[\s,.!?;:()\[\]{}"'\/&]+/).filter((w) => w.length > 2 && !STOP_WORDS.has(w) && !/^\d+$/.test(w));
1821
+ const bigrams = [];
1822
+ for (let i = 0; i < words.length - 1; i++) {
1823
+ bigrams.push(words[i] + " " + words[i + 1]);
1824
+ }
1825
+ return bigrams;
1826
+ }
1827
+ function checkTopicCoherence(data) {
1828
+ const findings = [];
1829
+ if (!data.homepage) {
1830
+ findings.push({ severity: "critical", detail: "Could not fetch homepage" });
1831
+ return { criterion: "topic_coherence", criterion_label: "Topic Coherence", score: 0, status: "not_found", findings, fix_priority: "P0" };
1832
+ }
1833
+ if (!data.blogSample || data.blogSample.length < 3) {
1834
+ findings.push({ severity: "info", detail: `Only ${data.blogSample?.length || 0} blog pages found - insufficient for topic coherence analysis` });
1835
+ return { criterion: "topic_coherence", criterion_label: "Topic Coherence", score: 5, status: "partial", findings, fix_priority: "P2" };
1836
+ }
1837
+ const blogPages = data.blogSample;
1838
+ const domainBase = data.domain.replace(/^www\./, "").replace(/\.(com|org|net|io|co|ai)$/i, "").toLowerCase();
1839
+ const brandWords = /* @__PURE__ */ new Set();
1840
+ brandWords.add(domainBase);
1841
+ for (const part of domainBase.split(/[-_]/)) {
1842
+ if (part.length > 2) brandWords.add(part);
1843
+ }
1844
+ const rawTermFreq = /* @__PURE__ */ new Map();
1845
+ const pageTitleTexts = [];
1846
+ for (const page of blogPages) {
1847
+ const topicText = getPageTopicText(page.text);
1848
+ pageTitleTexts.push(topicText);
1849
+ const words = topicText.split(/[\s,.!?;:()\[\]{}"'\/&]+/).filter((w) => w.length > 2 && !STOP_WORDS.has(w) && !/^\d+$/.test(w));
1850
+ const uniqueWords = new Set(words);
1851
+ for (const w of uniqueWords) {
1852
+ rawTermFreq.set(w, (rawTermFreq.get(w) || 0) + 1);
1853
+ }
1854
+ }
1855
+ for (const [term, count] of rawTermFreq) {
1856
+ if (count / blogPages.length >= 0.8 && domainBase.includes(term)) {
1857
+ brandWords.add(term);
1858
+ }
1859
+ }
1860
+ const termFreq = /* @__PURE__ */ new Map();
1861
+ for (const page of blogPages) {
1862
+ const topicText = getPageTopicText(page.text);
1863
+ const words = topicText.split(/[\s,.!?;:()\[\]{}"'\/&]+/).filter((w) => w.length > 2 && !STOP_WORDS.has(w) && !/^\d+$/.test(w) && !brandWords.has(w));
1864
+ const uniqueWords = new Set(words);
1865
+ for (const w of uniqueWords) {
1866
+ termFreq.set(w, (termFreq.get(w) || 0) + 1);
1867
+ }
1868
+ }
1869
+ const sortedTerms = [...termFreq.entries()].sort((a, b) => b[1] - a[1]);
1870
+ const topTerm = sortedTerms[0];
1871
+ const bigramFreq = /* @__PURE__ */ new Map();
1872
+ const pageBigrams = [];
1873
+ for (const topicText of pageTitleTexts) {
1874
+ const bigrams = extractBigrams(topicText).filter((bg) => !bg.split(" ").some((w) => brandWords.has(w)));
1875
+ pageBigrams.push(bigrams);
1876
+ const uniqueBigrams = new Set(bigrams);
1877
+ for (const bg of uniqueBigrams) {
1878
+ bigramFreq.set(bg, (bigramFreq.get(bg) || 0) + 1);
1879
+ }
1880
+ }
1881
+ const sortedBigrams = [...bigramFreq.entries()].sort((a, b) => b[1] - a[1]);
1882
+ const topBigram = sortedBigrams[0];
1883
+ const significantBigrams = sortedBigrams.filter(([, count]) => count >= 2);
1884
+ const clusterRoots = [];
1885
+ const assigned = /* @__PURE__ */ new Set();
1886
+ for (const [bg] of significantBigrams) {
1887
+ if (assigned.has(bg)) continue;
1888
+ clusterRoots.push(bg);
1889
+ assigned.add(bg);
1890
+ const [w1, w2] = bg.split(" ");
1891
+ for (const [otherBg] of significantBigrams) {
1892
+ if (assigned.has(otherBg)) continue;
1893
+ if (otherBg.includes(w1) || otherBg.includes(w2)) {
1894
+ assigned.add(otherBg);
1895
+ }
1896
+ }
1897
+ }
1898
+ const topicClusterCount = clusterRoots.length;
1899
+ const dominantTerm = topTerm?.[0] || "";
1900
+ const dominantTermCount = topTerm?.[1] || 0;
1901
+ const focusRatio = blogPages.length > 0 ? dominantTermCount / blogPages.length : 0;
1902
+ const dominantBigram = topBigram?.[0] || "";
1903
+ const dominantBigramCount = topBigram?.[1] || 0;
1904
+ const bigramFocusRatio = blogPages.length > 0 ? dominantBigramCount / blogPages.length : 0;
1905
+ let score = 0;
1906
+ const bestFocusRatio = Math.max(focusRatio, bigramFocusRatio);
1907
+ if (bestFocusRatio >= 0.8) {
1908
+ score += 7;
1909
+ } else if (bestFocusRatio >= 0.6) {
1910
+ score += 6;
1911
+ } else if (bestFocusRatio >= 0.45) {
1912
+ score += 5;
1913
+ } else if (bestFocusRatio >= 0.3) {
1914
+ score += 3;
1915
+ } else if (bestFocusRatio >= 0.15) {
1916
+ score += 2;
1917
+ } else {
1918
+ score += 1;
1919
+ }
1920
+ const clusterPenaltyReduced = focusRatio >= 0.7;
1921
+ if (topicClusterCount <= 3) {
1922
+ score += 3;
1923
+ findings.push({ severity: "info", detail: `${topicClusterCount} topic cluster(s) - tightly focused content` });
1924
+ } else if (topicClusterCount <= 6) {
1925
+ score += clusterPenaltyReduced ? 2 : 1;
1926
+ findings.push({ severity: "info", detail: `${topicClusterCount} topic clusters${clusterPenaltyReduced ? " within a focused niche" : " - moderately focused"}` });
1927
+ } else if (topicClusterCount <= 10) {
1928
+ score += clusterPenaltyReduced ? 1 : 0;
1929
+ if (!clusterPenaltyReduced) {
1930
+ findings.push({ severity: "low", detail: `${topicClusterCount} topic clusters - scattered content`, fix: "Reduce the number of distinct topics. Focus blog content on 2-3 core expertise areas." });
1931
+ } else {
1932
+ findings.push({ severity: "info", detail: `${topicClusterCount} topic clusters but strong core topic focus (${Math.round(focusRatio * 100)}%)` });
1933
+ }
1934
+ } else {
1935
+ score += clusterPenaltyReduced ? 0 : -2;
1936
+ if (!clusterPenaltyReduced) {
1937
+ findings.push({ severity: "medium", detail: `${topicClusterCount} topic clusters - highly scattered content`, fix: "Content covers too many unrelated topics. AI engines cannot identify your expertise. Focus on your core niche." });
1938
+ } else {
1939
+ findings.push({ severity: "low", detail: `${topicClusterCount} topic clusters despite strong core topic focus`, fix: "Consider narrowing subtopics within your niche for even stronger AI visibility." });
1940
+ }
1941
+ }
1942
+ score = Math.max(0, Math.min(10, score));
1943
+ if (dominantTerm) {
1944
+ const focusPct = Math.round(focusRatio * 100);
1945
+ findings.push({ severity: "info", detail: `Dominant topic term: "${dominantTerm}" (${focusPct}% of ${blogPages.length} pages)` });
1946
+ }
1947
+ if (dominantBigram && dominantBigramCount >= 2) {
1948
+ findings.push({ severity: "info", detail: `Dominant topic phrase: "${dominantBigram}" (${dominantBigramCount}/${blogPages.length} pages)` });
1949
+ }
1950
+ const offTopicExamples = [];
1951
+ for (let i = 0; i < pageTitleTexts.length && offTopicExamples.length < 3; i++) {
1952
+ if (dominantTerm && !pageTitleTexts[i].includes(dominantTerm)) {
1953
+ const title = blogPages[i].text.match(/<title[^>]*>([^<]+)<\/title>/i)?.[1]?.trim();
1954
+ if (title && title.length > 3) offTopicExamples.push(title.slice(0, 60));
1955
+ }
1956
+ }
1957
+ if (offTopicExamples.length > 0 && score < 8) {
1958
+ findings.push({ severity: "low", detail: `Off-topic examples: ${offTopicExamples.join("; ")}` });
1959
+ }
1960
+ return { criterion: "topic_coherence", criterion_label: "Topic Coherence", score, status: score >= 7 ? "pass" : score >= 4 ? "partial" : "fail", findings, fix_priority: score >= 7 ? "P3" : "P0" };
1961
+ }
1962
+ function countWords(html) {
1963
+ const text = html.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
1964
+ return text.split(/\s+/).filter((w) => w.length > 0).length;
1965
+ }
1966
+ function countHeadings(html) {
1967
+ const headings = html.match(/<h[2-6][^>]*>/gi) || [];
1968
+ return headings.length;
1969
+ }
1970
+ function checkContentDepth(data, topicCoherenceScore) {
1971
+ const findings = [];
1972
+ if (!data.blogSample || data.blogSample.length < 2) {
1973
+ findings.push({ severity: "info", detail: `Only ${data.blogSample?.length || 0} blog pages found - insufficient for depth analysis` });
1974
+ return { criterion: "content_depth", criterion_label: "Content Depth", score: 3, status: "partial", findings, fix_priority: "P2" };
1975
+ }
1976
+ const blogPages = data.blogSample;
1977
+ const wordCounts = blogPages.map((p) => countWords(p.text));
1978
+ const headingCounts = blogPages.map((p) => countHeadings(p.text));
1979
+ const avgWords = wordCounts.reduce((a, b) => a + b, 0) / wordCounts.length;
1980
+ const avgHeadings = headingCounts.reduce((a, b) => a + b, 0) / headingCounts.length;
1981
+ const deepPages = wordCounts.filter((w) => w >= 1e3).length;
1982
+ const thinPages = wordCounts.filter((w) => w < 300).length;
1983
+ const deepRatio = deepPages / blogPages.length;
1984
+ const thinRatio = thinPages / blogPages.length;
1985
+ let score = 0;
1986
+ if (avgWords >= 2e3) {
1987
+ score += 5;
1988
+ findings.push({ severity: "info", detail: `Average ${Math.round(avgWords)} words per page across ${blogPages.length} pages - excellent depth` });
1989
+ } else if (avgWords >= 1200) {
1990
+ score += 4;
1991
+ findings.push({ severity: "info", detail: `Average ${Math.round(avgWords)} words per page across ${blogPages.length} pages - good depth` });
1992
+ } else if (avgWords >= 800) {
1993
+ score += 3;
1994
+ findings.push({ severity: "info", detail: `Average ${Math.round(avgWords)} words per page - moderate depth` });
1995
+ } else if (avgWords >= 400) {
1996
+ score += 2;
1997
+ findings.push({ severity: "low", detail: `Average ${Math.round(avgWords)} words per page - shallow content`, fix: "Expand articles with more detail, examples, and expert analysis to build AI citation authority" });
1998
+ } else {
1999
+ score += 1;
2000
+ findings.push({ severity: "medium", detail: `Average ${Math.round(avgWords)} words per page - very thin content`, fix: "Content is too thin for AI engines to cite. Aim for 1000+ words per article with structured sections." });
2001
+ }
2002
+ if (avgHeadings >= 8) {
2003
+ score += 3;
2004
+ findings.push({ severity: "info", detail: `Average ${avgHeadings.toFixed(1)} subheadings per page - well-structured` });
2005
+ } else if (avgHeadings >= 5) {
2006
+ score += 2;
2007
+ findings.push({ severity: "info", detail: `Average ${avgHeadings.toFixed(1)} subheadings per page - decent structure` });
2008
+ } else if (avgHeadings >= 2) {
2009
+ score += 1;
2010
+ findings.push({ severity: "low", detail: `Average ${avgHeadings.toFixed(1)} subheadings per page`, fix: "Add more H2/H3 headings to break content into extractable sections" });
2011
+ } else {
2012
+ findings.push({ severity: "medium", detail: `Average ${avgHeadings.toFixed(1)} subheadings per page - minimal structure`, fix: "Add question-format H2/H3 headings so AI engines can extract specific answers" });
2013
+ }
2014
+ if (deepRatio >= 0.5) {
2015
+ score += 2;
2016
+ findings.push({ severity: "info", detail: `${deepPages}/${blogPages.length} pages (${Math.round(deepRatio * 100)}%) have 1000+ words` });
2017
+ } else if (deepRatio >= 0.25) {
2018
+ score += 1;
2019
+ findings.push({ severity: "info", detail: `${deepPages}/${blogPages.length} pages have 1000+ words` });
2020
+ }
2021
+ if (thinRatio >= 0.5) {
2022
+ score = Math.max(0, score - 2);
2023
+ findings.push({ severity: "medium", detail: `${thinPages}/${blogPages.length} pages (${Math.round(thinRatio * 100)}%) have under 300 words - high thin content ratio`, fix: "Remove or expand thin pages. Thin content dilutes site quality for AI engines." });
2024
+ } else if (thinRatio >= 0.25) {
2025
+ score = Math.max(0, score - 1);
2026
+ findings.push({ severity: "low", detail: `${thinPages}/${blogPages.length} pages have under 300 words` });
2027
+ }
2028
+ let finalScore = Math.min(10, score);
2029
+ if (topicCoherenceScore !== void 0 && topicCoherenceScore <= 4 && finalScore >= 8) {
2030
+ finalScore = 7;
2031
+ findings.push({ severity: "low", detail: "Deep content but low topic coherence - depth on scattered topics has reduced AI citation value", fix: "Focus content depth on your core expertise area for maximum AI visibility" });
2032
+ }
2033
+ return { criterion: "content_depth", criterion_label: "Content Depth", score: finalScore, status: finalScore >= 7 ? "pass" : finalScore >= 4 ? "partial" : "fail", findings, fix_priority: finalScore >= 7 ? "P3" : "P1" };
2034
+ }
1770
2035
  function auditSiteFromData(data) {
2036
+ const topicCoherence = checkTopicCoherence(data);
2037
+ const cannibalization = checkContentCannibalization(data, topicCoherence.score);
1771
2038
  return [
1772
2039
  checkLlmsTxt(data),
1773
2040
  checkSchemaMarkup(data),
@@ -1793,47 +2060,55 @@ function auditSiteFromData(data) {
1793
2060
  checkSchemaCoverage(data),
1794
2061
  checkSpeakableSchema(data),
1795
2062
  checkQueryAnswerAlignment(data),
1796
- checkContentCannibalization(data),
1797
- checkVisibleDateSignal(data)
2063
+ cannibalization,
2064
+ checkVisibleDateSignal(data),
2065
+ topicCoherence,
2066
+ checkContentDepth(data, topicCoherence.score)
1798
2067
  ];
1799
2068
  }
1800
2069
 
1801
2070
  // src/scoring.ts
1802
2071
  var WEIGHTS = {
1803
- // Original 10
1804
- llms_txt: 0.1,
1805
- schema_markup: 0.15,
1806
- qa_content_format: 0.15,
1807
- clean_html: 0.1,
1808
- entity_consistency: 0.1,
1809
- robots_txt: 0.05,
1810
- faq_section: 0.1,
1811
- original_data: 0.1,
1812
- internal_linking: 0.1,
1813
- semantic_html: 0.05,
1814
- // New 12
1815
- content_freshness: 0.07,
1816
- sitemap_completeness: 0.05,
1817
- rss_feed: 0.03,
1818
- table_list_extractability: 0.07,
1819
- definition_patterns: 0.04,
2072
+ // ─── Core Content (high weight - these determine real AI citation quality) ──
2073
+ qa_content_format: 0.12,
2074
+ original_data: 0.12,
2075
+ topic_coherence: 0.14,
2076
+ // NEW v2.0: biggest predictor of AI citation quality
2077
+ fact_density: 0.08,
1820
2078
  direct_answer_density: 0.07,
1821
- content_licensing: 0.04,
2079
+ content_depth: 0.06,
2080
+ // NEW v2.0: substantive content vs thin pages
2081
+ // ─── Structure & Discovery (medium weight - technical readiness) ────────────
2082
+ schema_markup: 0.08,
2083
+ llms_txt: 0.08,
2084
+ clean_html: 0.08,
2085
+ entity_consistency: 0.08,
2086
+ faq_section: 0.08,
2087
+ internal_linking: 0.08,
2088
+ // ─── Content Signals (moderate weight) ──────────────────────────────────────
2089
+ content_freshness: 0.06,
2090
+ table_list_extractability: 0.05,
2091
+ query_answer_alignment: 0.06,
2092
+ definition_patterns: 0.04,
1822
2093
  author_schema_depth: 0.04,
1823
- fact_density: 0.05,
1824
- canonical_url: 0.04,
1825
- content_velocity: 0.03,
1826
- schema_coverage: 0.03,
1827
- speakable_schema: 0.03,
1828
- query_answer_alignment: 0.08,
1829
2094
  content_cannibalization: 0.05,
1830
- visible_date_signal: 0.04
2095
+ visible_date_signal: 0.04,
2096
+ semantic_html: 0.04,
2097
+ // ─── Plumbing (low weight - nice to have but not what drives citations) ─────
2098
+ robots_txt: 0.03,
2099
+ sitemap_completeness: 0.03,
2100
+ content_velocity: 0.03,
2101
+ rss_feed: 0.02,
2102
+ content_licensing: 0.03,
2103
+ canonical_url: 0.02,
2104
+ schema_coverage: 0.02,
2105
+ speakable_schema: 0.02
1831
2106
  };
1832
2107
  function calculateOverallScore(criteria) {
1833
2108
  let totalWeight = 0;
1834
2109
  let weightedSum = 0;
1835
2110
  for (const c of criteria) {
1836
- const weight = WEIGHTS[c.criterion] ?? 0.1;
2111
+ const weight = WEIGHTS[c.criterion] ?? 0.05;
1837
2112
  weightedSum += c.score / 10 * weight * 100;
1838
2113
  totalWeight += weight;
1839
2114
  }
@@ -1969,7 +2244,9 @@ var CRITERION_LABELS = {
1969
2244
  "Speakable Schema": "Speakable Schema",
1970
2245
  "Query-Answer Alignment": "Query-Answer Alignment",
1971
2246
  "Content Cannibalization": "Content Cannibalization",
1972
- "Visible Date Signal": "Visible Date Signal"
2247
+ "Visible Date Signal": "Visible Date Signal",
2248
+ "Topic Coherence": "Topic Coherence",
2249
+ "Content Depth": "Content Depth"
1973
2250
  };
1974
2251
  function scoreToStatus(score) {
1975
2252
  if (score === 0) return "MISSING";
@@ -2878,7 +3155,7 @@ function extractTitle(html) {
2878
3155
  function getTextContent2(html) {
2879
3156
  return html.replace(/<script[\s\S]*?<\/script>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "").replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
2880
3157
  }
2881
- function countWords(text) {
3158
+ function countWords2(text) {
2882
3159
  if (!text) return 0;
2883
3160
  return text.split(/\s+/).filter((w) => w.length > 0).length;
2884
3161
  }
@@ -3029,7 +3306,7 @@ function checkHasQuestionHeadings(html) {
3029
3306
  function analyzePage(html, url, category) {
3030
3307
  const title = extractTitle(html);
3031
3308
  const textContent = getTextContent2(html);
3032
- const wordCount = countWords(textContent);
3309
+ const wordCount = countWords2(textContent);
3033
3310
  const issues = [];
3034
3311
  const strengths = [];
3035
3312
  const issueChecks = [
@@ -3109,7 +3386,7 @@ async function audit(domain, options) {
3109
3386
  }
3110
3387
  }
3111
3388
  if (options?.fullCrawl) {
3112
- const { crawlFullSite: crawlFullSite2 } = await import("./full-site-crawler-VFARFR2C.js");
3389
+ const { crawlFullSite: crawlFullSite2 } = await import("./full-site-crawler-UIOMKOZA.js");
3113
3390
  const crawlResult = await crawlFullSite2(siteData, {
3114
3391
  maxPages: options.maxPages ?? 200,
3115
3392
  concurrency: options.concurrency ?? 5
@@ -3154,6 +3431,1314 @@ async function audit(domain, options) {
3154
3431
  };
3155
3432
  }
3156
3433
 
3434
+ // src/link-graph.ts
3435
+ function serializeLinkGraph(graph) {
3436
+ return {
3437
+ nodes: Array.from(graph.nodes.values()),
3438
+ stats: graph.stats,
3439
+ clusters: graph.clusters
3440
+ };
3441
+ }
3442
+ function normalizeUrl(url) {
3443
+ try {
3444
+ const parsed = new URL(url);
3445
+ return (parsed.origin + parsed.pathname.replace(/\/+$/, "") + parsed.search).toLowerCase();
3446
+ } catch {
3447
+ return url.toLowerCase();
3448
+ }
3449
+ }
3450
+ var RESOURCE_EXTENSIONS = /\.(js|css|png|jpg|jpeg|gif|svg|ico|pdf|xml|txt|woff|woff2|ttf|eot|mp4|mp3|webp|avif|zip|gz|tar|json)$/i;
3451
+ var SKIP_PATH_PATTERNS = /^\/(api|wp-admin|wp-json|static|assets|_next|auth|login|signup|cart|checkout|admin|feed|xmlrpc)\b/i;
3452
+ function extractTitle2(html) {
3453
+ const match = html.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
3454
+ return match ? match[1].replace(/\s+/g, " ").trim() : "";
3455
+ }
3456
+ function getTextContent3(html) {
3457
+ return html.replace(/<script[\s\S]*?<\/script>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "").replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
3458
+ }
3459
+ function countWords3(text) {
3460
+ if (!text) return 0;
3461
+ return text.split(/\s+/).filter((w) => w.length > 0).length;
3462
+ }
3463
+ function extractLinksWithAnchors(html, sourceUrl, domain) {
3464
+ const cleanDomain = domain.replace(/^www\./, "").toLowerCase();
3465
+ const edges = [];
3466
+ const seen = /* @__PURE__ */ new Set();
3467
+ const anchorRegex = /<a\s[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi;
3468
+ let match;
3469
+ while ((match = anchorRegex.exec(html)) !== null) {
3470
+ const href = match[1];
3471
+ const rawAnchor = match[2];
3472
+ if (!href || !href.trim()) continue;
3473
+ let fullUrl;
3474
+ if (href.startsWith("//")) {
3475
+ fullUrl = `https:${href}`;
3476
+ } else if (href.startsWith("/")) {
3477
+ if (href === "/" || href.startsWith("/#")) continue;
3478
+ fullUrl = `https://${domain}${href}`;
3479
+ } else if (href.startsWith("http")) {
3480
+ fullUrl = href;
3481
+ } else if (href.startsWith("#") || href.startsWith("?") || href.startsWith("mailto:") || href.startsWith("tel:") || href.startsWith("javascript:")) {
3482
+ continue;
3483
+ } else {
3484
+ fullUrl = `https://${domain}/${href}`;
3485
+ }
3486
+ try {
3487
+ const parsed = new URL(fullUrl);
3488
+ const linkDomain = parsed.hostname.replace(/^www\./, "").toLowerCase();
3489
+ if (linkDomain !== cleanDomain) continue;
3490
+ parsed.hash = "";
3491
+ const path = parsed.pathname;
3492
+ if (path === "/" || path === "") continue;
3493
+ if (RESOURCE_EXTENSIONS.test(path)) continue;
3494
+ if (SKIP_PATH_PATTERNS.test(path)) continue;
3495
+ const normalized = normalizeUrl(fullUrl);
3496
+ const sourceNorm = normalizeUrl(sourceUrl);
3497
+ if (normalized === sourceNorm) continue;
3498
+ const edgeKey = `${sourceNorm}->${normalized}`;
3499
+ if (seen.has(edgeKey)) continue;
3500
+ seen.add(edgeKey);
3501
+ const anchorText = rawAnchor.replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim();
3502
+ edges.push({
3503
+ source: sourceNorm,
3504
+ target: normalized,
3505
+ anchorText
3506
+ });
3507
+ } catch {
3508
+ continue;
3509
+ }
3510
+ }
3511
+ return edges;
3512
+ }
3513
+ function calculateDepths(nodes, adjacency, homepageUrl) {
3514
+ const homeNorm = normalizeUrl(homepageUrl);
3515
+ for (const node of nodes.values()) {
3516
+ node.depth = Infinity;
3517
+ }
3518
+ const homeNode = nodes.get(homeNorm);
3519
+ if (homeNode) {
3520
+ homeNode.depth = 0;
3521
+ }
3522
+ const queue = [homeNorm];
3523
+ const visited = /* @__PURE__ */ new Set([homeNorm]);
3524
+ while (queue.length > 0) {
3525
+ const current = queue.shift();
3526
+ const currentNode = nodes.get(current);
3527
+ if (!currentNode) continue;
3528
+ const nextDepth = currentNode.depth + 1;
3529
+ const neighbors = adjacency.get(current);
3530
+ if (!neighbors) continue;
3531
+ for (const neighbor of neighbors) {
3532
+ if (visited.has(neighbor)) continue;
3533
+ visited.add(neighbor);
3534
+ const neighborNode = nodes.get(neighbor);
3535
+ if (neighborNode) {
3536
+ neighborNode.depth = nextDepth;
3537
+ queue.push(neighbor);
3538
+ }
3539
+ }
3540
+ }
3541
+ }
3542
+ var PILLAR_CATEGORIES = /* @__PURE__ */ new Set(["blog", "content", "resources", "docs"]);
3543
+ function detectPillars(nodes) {
3544
+ for (const node of nodes.values()) {
3545
+ node.isPillar = node.wordCount >= 1500 && node.inDegree >= 3 && node.outDegree >= 3 && PILLAR_CATEGORIES.has(node.category) && node.depth > 0;
3546
+ }
3547
+ }
3548
+ var HUB_CATEGORIES = /* @__PURE__ */ new Set(["homepage", "resources", "docs"]);
3549
+ function detectHubs(nodes) {
3550
+ for (const node of nodes.values()) {
3551
+ node.isHub = node.outDegree >= 10 && HUB_CATEGORIES.has(node.category) || node.outDegree >= 15;
3552
+ }
3553
+ }
3554
+ function detectClusters(nodes, edges) {
3555
+ const clusters = [];
3556
+ const edgeSet = /* @__PURE__ */ new Set();
3557
+ for (const edge of edges) {
3558
+ edgeSet.add(`${edge.source}->${edge.target}`);
3559
+ }
3560
+ for (const node of nodes.values()) {
3561
+ if (!node.isPillar) continue;
3562
+ const pillarNorm = normalizeUrl(node.url);
3563
+ const spokeSet = /* @__PURE__ */ new Set();
3564
+ for (const edge of edges) {
3565
+ if (edge.source === pillarNorm && nodes.has(edge.target)) {
3566
+ spokeSet.add(edge.target);
3567
+ }
3568
+ if (edge.target === pillarNorm && nodes.has(edge.source)) {
3569
+ spokeSet.add(edge.source);
3570
+ }
3571
+ }
3572
+ spokeSet.delete(pillarNorm);
3573
+ if (spokeSet.size < 2) continue;
3574
+ const spokes = Array.from(spokeSet);
3575
+ const members = [pillarNorm, ...spokes];
3576
+ let actualEdges = 0;
3577
+ const possibleEdges = members.length * (members.length - 1);
3578
+ for (const from of members) {
3579
+ for (const to of members) {
3580
+ if (from === to) continue;
3581
+ if (edgeSet.has(`${from}->${to}`)) {
3582
+ actualEdges++;
3583
+ }
3584
+ }
3585
+ }
3586
+ const cohesion = possibleEdges > 0 ? Math.round(actualEdges / possibleEdges * 100) : 0;
3587
+ clusters.push({
3588
+ pillarUrl: node.url,
3589
+ pillarTitle: node.title,
3590
+ spokes,
3591
+ cohesion
3592
+ });
3593
+ }
3594
+ return clusters;
3595
+ }
3596
+ function buildLinkGraph(pages, domain, homepageUrl) {
3597
+ const nodes = /* @__PURE__ */ new Map();
3598
+ const allEdges = [];
3599
+ const adjacency = /* @__PURE__ */ new Map();
3600
+ const inDegreeMap = /* @__PURE__ */ new Map();
3601
+ for (const page of pages) {
3602
+ const url = page.finalUrl || `https://${domain}`;
3603
+ const norm = normalizeUrl(url);
3604
+ if (nodes.has(norm)) continue;
3605
+ const title = extractTitle2(page.text);
3606
+ const text = getTextContent3(page.text);
3607
+ const wordCount = countWords3(text);
3608
+ nodes.set(norm, {
3609
+ url: norm,
3610
+ title,
3611
+ wordCount,
3612
+ category: page.category || "content",
3613
+ inDegree: 0,
3614
+ outDegree: 0,
3615
+ depth: Infinity,
3616
+ isPillar: false,
3617
+ isHub: false,
3618
+ isOrphan: false
3619
+ });
3620
+ }
3621
+ for (const page of pages) {
3622
+ const url = page.finalUrl || `https://${domain}`;
3623
+ const sourceNorm = normalizeUrl(url);
3624
+ const edges = extractLinksWithAnchors(page.text, url, domain);
3625
+ for (const edge of edges) {
3626
+ const targetNorm = normalizeUrl(edge.target);
3627
+ if (!nodes.has(targetNorm)) continue;
3628
+ allEdges.push({
3629
+ source: sourceNorm,
3630
+ target: targetNorm,
3631
+ anchorText: edge.anchorText
3632
+ });
3633
+ if (!adjacency.has(sourceNorm)) {
3634
+ adjacency.set(sourceNorm, /* @__PURE__ */ new Set());
3635
+ }
3636
+ adjacency.get(sourceNorm).add(targetNorm);
3637
+ inDegreeMap.set(targetNorm, (inDegreeMap.get(targetNorm) || 0) + 1);
3638
+ }
3639
+ }
3640
+ for (const [url, node] of nodes) {
3641
+ node.inDegree = inDegreeMap.get(url) || 0;
3642
+ node.outDegree = adjacency.get(url)?.size || 0;
3643
+ }
3644
+ calculateDepths(nodes, adjacency, homepageUrl);
3645
+ detectPillars(nodes);
3646
+ detectHubs(nodes);
3647
+ const homeNorm = normalizeUrl(homepageUrl);
3648
+ for (const [url, node] of nodes) {
3649
+ node.isOrphan = node.inDegree === 0 && url !== homeNorm;
3650
+ }
3651
+ const clusters = detectClusters(nodes, allEdges);
3652
+ const depthValues = Array.from(nodes.values()).map((n) => n.depth).filter((d) => d !== Infinity);
3653
+ const avgDepth = depthValues.length > 0 ? Math.round(depthValues.reduce((s, d) => s + d, 0) / depthValues.length * 10) / 10 : 0;
3654
+ const maxDepth = depthValues.length > 0 ? Math.max(...depthValues) : 0;
3655
+ const stats = {
3656
+ totalPages: nodes.size,
3657
+ totalEdges: allEdges.length,
3658
+ orphanPages: Array.from(nodes.values()).filter((n) => n.isOrphan).length,
3659
+ pillarPages: Array.from(nodes.values()).filter((n) => n.isPillar).length,
3660
+ hubPages: Array.from(nodes.values()).filter((n) => n.isHub).length,
3661
+ avgDepth,
3662
+ maxDepth,
3663
+ clusters: clusters.length
3664
+ };
3665
+ return { nodes, edges: allEdges, stats, clusters };
3666
+ }
3667
+
3668
+ // src/fix-engine.ts
3669
+ var CRITERION_WEIGHTS2 = {
3670
+ llms_txt: 0.1,
3671
+ schema_markup: 0.15,
3672
+ qa_content_format: 0.15,
3673
+ clean_html: 0.1,
3674
+ entity_consistency: 0.1,
3675
+ robots_txt: 0.05,
3676
+ faq_section: 0.1,
3677
+ original_data: 0.1,
3678
+ internal_linking: 0.1,
3679
+ semantic_html: 0.05,
3680
+ content_freshness: 0.07,
3681
+ sitemap_completeness: 0.05,
3682
+ rss_feed: 0.03,
3683
+ table_list_extractability: 0.07,
3684
+ definition_patterns: 0.04,
3685
+ direct_answer_density: 0.07,
3686
+ content_licensing: 0.04,
3687
+ author_schema_depth: 0.04,
3688
+ fact_density: 0.05,
3689
+ canonical_url: 0.04,
3690
+ content_velocity: 0.03,
3691
+ schema_coverage: 0.03,
3692
+ speakable_schema: 0.03,
3693
+ query_answer_alignment: 0.08,
3694
+ content_cannibalization: 0.05,
3695
+ visible_date_signal: 0.04
3696
+ };
3697
+ var PHASE_CONFIG = [
3698
+ {
3699
+ phase: 1,
3700
+ title: "Foundation",
3701
+ description: "Discovery and structural fixes that enable AI crawlers to access and parse your content.",
3702
+ criteria: ["robots_txt", "llms_txt", "canonical_url", "clean_html", "sitemap_completeness"]
3703
+ },
3704
+ {
3705
+ phase: 2,
3706
+ title: "Content",
3707
+ description: "Content quality and format improvements that make your pages citable by AI engines.",
3708
+ criteria: [
3709
+ "qa_content_format",
3710
+ "faq_section",
3711
+ "original_data",
3712
+ "definition_patterns",
3713
+ "direct_answer_density",
3714
+ "fact_density",
3715
+ "content_freshness",
3716
+ "table_list_extractability",
3717
+ "query_answer_alignment",
3718
+ "visible_date_signal"
3719
+ ]
3720
+ },
3721
+ {
3722
+ phase: 3,
3723
+ title: "Authority",
3724
+ description: "Trust signals, schema depth, and semantic structure that establish credibility with AI engines.",
3725
+ criteria: [
3726
+ "schema_markup",
3727
+ "schema_coverage",
3728
+ "speakable_schema",
3729
+ "author_schema_depth",
3730
+ "content_licensing",
3731
+ "entity_consistency",
3732
+ "semantic_html"
3733
+ ]
3734
+ },
3735
+ {
3736
+ phase: 4,
3737
+ title: "Architecture",
3738
+ description: "Site architecture, linking patterns, and publishing cadence that support long-term AI visibility.",
3739
+ criteria: ["internal_linking", "content_velocity", "content_cannibalization", "rss_feed"]
3740
+ }
3741
+ ];
3742
+ function impactFromScore(score) {
3743
+ if (score <= 3) return "critical";
3744
+ if (score <= 5) return "high";
3745
+ if (score <= 7) return "medium";
3746
+ return "low";
3747
+ }
3748
+ function effortForCriterion(criterion, score) {
3749
+ const trivialCriteria = ["llms_txt", "robots_txt", "canonical_url", "content_licensing", "visible_date_signal"];
3750
+ const lowCriteria = ["rss_feed", "sitemap_completeness", "speakable_schema", "author_schema_depth", "semantic_html", "definition_patterns", "content_freshness"];
3751
+ const highCriteria = ["original_data", "content_velocity", "content_cannibalization"];
3752
+ if (trivialCriteria.includes(criterion)) return score <= 3 ? "low" : "trivial";
3753
+ if (lowCriteria.includes(criterion)) return score <= 3 ? "medium" : "low";
3754
+ if (highCriteria.includes(criterion)) return score <= 5 ? "high" : "medium";
3755
+ return score <= 3 ? "medium" : "low";
3756
+ }
3757
+ function getAffectedPages(criterion, pages, threshold = 7) {
3758
+ if (!pages || pages.length === 0) return void 0;
3759
+ const affected = pages.filter((p) => {
3760
+ const cs = p.criterionScores?.find((c) => c.criterion === criterion);
3761
+ return cs && cs.score < threshold;
3762
+ });
3763
+ if (affected.length === 0) return void 0;
3764
+ return affected.map((p) => p.url);
3765
+ }
3766
+ function effortToHours(effort) {
3767
+ switch (effort) {
3768
+ case "trivial":
3769
+ return 0.5;
3770
+ case "low":
3771
+ return 1;
3772
+ case "medium":
3773
+ return 3;
3774
+ case "high":
3775
+ return 8;
3776
+ }
3777
+ }
3778
+ var FIX_GENERATORS = {
3779
+ llms_txt: (c) => {
3780
+ if (c.score >= 10) return [];
3781
+ const impact = impactFromScore(c.score);
3782
+ const effort = effortForCriterion("llms_txt", c.score);
3783
+ const fixes = [];
3784
+ if (c.score <= 6) {
3785
+ fixes.push({
3786
+ id: "fix-llms-txt-create",
3787
+ criterion: c.criterion_label,
3788
+ criterionId: c.criterion,
3789
+ title: "Create /llms.txt file",
3790
+ description: "Add a machine-readable llms.txt file at your domain root that describes your site, services, and key pages for AI engines.",
3791
+ impact,
3792
+ effort,
3793
+ impactScore: 0,
3794
+ // calculated later
3795
+ category: "discovery",
3796
+ steps: [
3797
+ "Create a file named llms.txt in your site root",
3798
+ "Add site name, description, and core URLs in markdown format",
3799
+ "Include key service/product pages and their descriptions",
3800
+ "Deploy and verify access at yourdomain.com/llms.txt"
3801
+ ],
3802
+ codeExample: `# Site Name
3803
+ > One-line site description
3804
+
3805
+ ## Core Pages
3806
+ - [About](/about): Company overview
3807
+ - [Services](/services): Service offerings
3808
+ - [Blog](/blog): Latest articles
3809
+
3810
+ ## Key Topics
3811
+ - Topic 1
3812
+ - Topic 2`,
3813
+ successCriteria: "/llms.txt returns 200 with valid markdown content"
3814
+ });
3815
+ }
3816
+ if (c.score <= 3) {
3817
+ fixes.push({
3818
+ id: "fix-llms-txt-full",
3819
+ criterion: c.criterion_label,
3820
+ criterionId: c.criterion,
3821
+ title: "Add llms-full.txt with extended content",
3822
+ description: "Create a comprehensive llms-full.txt with detailed page descriptions, content summaries, and topic taxonomy.",
3823
+ impact: "medium",
3824
+ effort: "low",
3825
+ impactScore: 0,
3826
+ category: "discovery",
3827
+ steps: [
3828
+ "Create llms-full.txt alongside llms.txt",
3829
+ "Include full page descriptions with word counts",
3830
+ "Add topic categories and content clusters",
3831
+ "Link from llms.txt to llms-full.txt"
3832
+ ],
3833
+ successCriteria: "/llms-full.txt returns 200 with comprehensive site map"
3834
+ });
3835
+ }
3836
+ return fixes;
3837
+ },
3838
+ schema_markup: (c, pages) => {
3839
+ if (c.score >= 10) return [];
3840
+ const impact = impactFromScore(c.score);
3841
+ const effort = effortForCriterion("schema_markup", c.score);
3842
+ const affected = getAffectedPages("schema_markup", pages);
3843
+ const fixes = [{
3844
+ id: "fix-schema-markup",
3845
+ criterion: c.criterion_label,
3846
+ criterionId: c.criterion,
3847
+ title: "Add JSON-LD structured data",
3848
+ description: "Implement Organization, WebSite, and page-specific schema.org JSON-LD to help AI engines extract your content.",
3849
+ impact,
3850
+ effort,
3851
+ impactScore: 0,
3852
+ category: "trust",
3853
+ steps: [
3854
+ "Add Organization JSON-LD to your homepage with name, url, logo, sameAs",
3855
+ "Add WebSite schema with SearchAction",
3856
+ "Add page-specific schema (Article, Service, Product, FAQPage) to relevant pages",
3857
+ "Validate with Google Rich Results Test"
3858
+ ],
3859
+ codeExample: `<script type="application/ld+json">
3860
+ {
3861
+ "@context": "https://schema.org",
3862
+ "@type": "Organization",
3863
+ "name": "Your Company",
3864
+ "url": "https://example.com",
3865
+ "logo": "https://example.com/logo.png",
3866
+ "sameAs": [
3867
+ "https://twitter.com/company",
3868
+ "https://linkedin.com/company/company"
3869
+ ]
3870
+ }
3871
+ </script>`,
3872
+ successCriteria: "Homepage and key pages have valid JSON-LD schema",
3873
+ dependsOn: ["fix-clean-html-structure"],
3874
+ affectedPages: affected,
3875
+ pageCount: affected?.length
3876
+ }];
3877
+ return fixes;
3878
+ },
3879
+ qa_content_format: (c, pages) => {
3880
+ if (c.score >= 10) return [];
3881
+ const impact = impactFromScore(c.score);
3882
+ const effort = effortForCriterion("qa_content_format", c.score);
3883
+ const affected = getAffectedPages("qa_content_format", pages);
3884
+ return [{
3885
+ id: "fix-qa-format",
3886
+ criterion: c.criterion_label,
3887
+ criterionId: c.criterion,
3888
+ title: "Add question-based headings",
3889
+ description: "Restructure content with H2/H3 question headings that match how users query AI assistants.",
3890
+ impact,
3891
+ effort,
3892
+ impactScore: 0,
3893
+ category: "content",
3894
+ steps: [
3895
+ "Identify top user questions for each page topic",
3896
+ "Convert section headings to question format (What, How, Why, When)",
3897
+ "Follow each question heading with a direct 2-3 sentence answer",
3898
+ "Add a summary answer box at the top of long-form content"
3899
+ ],
3900
+ successCriteria: "At least 50% of H2/H3 headings use question format",
3901
+ affectedPages: affected,
3902
+ pageCount: affected?.length
3903
+ }];
3904
+ },
3905
+ clean_html: (c, pages) => {
3906
+ if (c.score >= 10) return [];
3907
+ const impact = impactFromScore(c.score);
3908
+ const effort = effortForCriterion("clean_html", c.score);
3909
+ const affected = getAffectedPages("clean_html", pages);
3910
+ const fixes = [{
3911
+ id: "fix-clean-html-structure",
3912
+ criterion: c.criterion_label,
3913
+ criterionId: c.criterion,
3914
+ title: "Fix HTML structure and meta tags",
3915
+ description: "Ensure clean, well-structured HTML with proper meta tags, HTTPS, and parseable content for AI crawlers.",
3916
+ impact,
3917
+ effort,
3918
+ impactScore: 0,
3919
+ category: "structure",
3920
+ steps: [
3921
+ "Enable HTTPS and redirect HTTP to HTTPS",
3922
+ "Add proper <title>, meta description, and viewport meta tags",
3923
+ "Fix HTML validation errors (unclosed tags, invalid nesting)",
3924
+ "Ensure content is server-rendered (not client-side only)"
3925
+ ],
3926
+ successCriteria: "Pages pass HTML validation with proper meta tags and HTTPS",
3927
+ affectedPages: affected,
3928
+ pageCount: affected?.length
3929
+ }];
3930
+ return fixes;
3931
+ },
3932
+ entity_consistency: (c) => {
3933
+ if (c.score >= 10) return [];
3934
+ const impact = impactFromScore(c.score);
3935
+ const effort = effortForCriterion("entity_consistency", c.score);
3936
+ return [{
3937
+ id: "fix-entity-consistency",
3938
+ criterion: c.criterion_label,
3939
+ criterionId: c.criterion,
3940
+ title: "Strengthen entity authority (NAP)",
3941
+ description: "Add consistent name, address, phone (NAP) and sameAs links across all pages to strengthen entity recognition.",
3942
+ impact,
3943
+ effort,
3944
+ impactScore: 0,
3945
+ category: "trust",
3946
+ steps: [
3947
+ "Ensure company name is consistent across all pages",
3948
+ "Add Organization schema with full NAP details",
3949
+ "Include sameAs links to social profiles and directories",
3950
+ "Add logo and brand marks consistently"
3951
+ ],
3952
+ successCriteria: "Organization schema present with consistent NAP on all pages"
3953
+ }];
3954
+ },
3955
+ robots_txt: (c) => {
3956
+ if (c.score >= 10) return [];
3957
+ const impact = impactFromScore(c.score);
3958
+ const effort = effortForCriterion("robots_txt", c.score);
3959
+ return [{
3960
+ id: "fix-robots-txt",
3961
+ criterion: c.criterion_label,
3962
+ criterionId: c.criterion,
3963
+ title: "Configure robots.txt for AI crawlers",
3964
+ description: "Update robots.txt to explicitly allow AI crawlers and include sitemap directive.",
3965
+ impact,
3966
+ effort,
3967
+ impactScore: 0,
3968
+ category: "discovery",
3969
+ steps: [
3970
+ "Create or update robots.txt at domain root",
3971
+ "Add User-agent rules for GPTBot, ClaudeBot, PerplexityBot",
3972
+ "Include Sitemap directive pointing to sitemap.xml",
3973
+ "Verify no accidental Disallow rules blocking content pages"
3974
+ ],
3975
+ codeExample: `User-agent: *
3976
+ Allow: /
3977
+
3978
+ User-agent: GPTBot
3979
+ Allow: /
3980
+
3981
+ User-agent: ClaudeBot
3982
+ Allow: /
3983
+
3984
+ User-agent: PerplexityBot
3985
+ Allow: /
3986
+
3987
+ Sitemap: https://example.com/sitemap.xml`,
3988
+ successCriteria: "robots.txt returns 200 with AI crawler directives and Sitemap"
3989
+ }];
3990
+ },
3991
+ faq_section: (c, pages) => {
3992
+ if (c.score >= 10) return [];
3993
+ const impact = impactFromScore(c.score);
3994
+ const effort = effortForCriterion("faq_section", c.score);
3995
+ const affected = getAffectedPages("faq_section", pages);
3996
+ return [{
3997
+ id: "fix-faq-section",
3998
+ criterion: c.criterion_label,
3999
+ criterionId: c.criterion,
4000
+ title: "Build FAQ sections with schema",
4001
+ description: "Create FAQ content with FAQPage schema markup on key pages to become a direct answer source for AI engines.",
4002
+ impact,
4003
+ effort,
4004
+ impactScore: 0,
4005
+ category: "content",
4006
+ steps: [
4007
+ "Identify 8-10 most common customer questions per service area",
4008
+ "Create dedicated FAQ page with categorized Q&A pairs",
4009
+ "Add inline FAQ sections to key service/product pages",
4010
+ "Implement FAQPage JSON-LD schema on all FAQ content"
4011
+ ],
4012
+ successCriteria: "FAQ page exists with FAQPage schema, key pages have inline FAQ sections",
4013
+ affectedPages: affected,
4014
+ pageCount: affected?.length
4015
+ }];
4016
+ },
4017
+ original_data: (c, pages) => {
4018
+ if (c.score >= 10) return [];
4019
+ const impact = impactFromScore(c.score);
4020
+ const effort = effortForCriterion("original_data", c.score);
4021
+ const affected = getAffectedPages("original_data", pages);
4022
+ return [{
4023
+ id: "fix-original-data",
4024
+ criterion: c.criterion_label,
4025
+ criterionId: c.criterion,
4026
+ title: "Add original data and case studies",
4027
+ description: "Publish proprietary data, statistics, case studies, or research that AI engines cannot find elsewhere.",
4028
+ impact,
4029
+ effort,
4030
+ impactScore: 0,
4031
+ category: "content",
4032
+ steps: [
4033
+ "Identify internal data assets (customer metrics, case study results, survey data)",
4034
+ "Create data-driven content with specific numbers and percentages",
4035
+ "Publish case studies with measurable outcomes",
4036
+ "Add comparison tables with proprietary benchmarks"
4037
+ ],
4038
+ successCriteria: "At least 3 pages contain original data points not found elsewhere online",
4039
+ affectedPages: affected,
4040
+ pageCount: affected?.length
4041
+ }];
4042
+ },
4043
+ internal_linking: (c, pages, linkGraph) => {
4044
+ if (c.score >= 10) return [];
4045
+ const impact = impactFromScore(c.score);
4046
+ const effort = effortForCriterion("internal_linking", c.score);
4047
+ const fixes = [];
4048
+ if (linkGraph) {
4049
+ const orphans = [];
4050
+ linkGraph.nodes.forEach((node) => {
4051
+ if (node.isOrphan) orphans.push(node.url);
4052
+ });
4053
+ if (orphans.length > 0) {
4054
+ fixes.push({
4055
+ id: "fix-internal-linking-orphans",
4056
+ criterion: c.criterion_label,
4057
+ criterionId: c.criterion,
4058
+ title: "Link orphan pages into site navigation",
4059
+ description: `${orphans.length} pages have no incoming internal links. These are invisible to AI crawlers that follow links.`,
4060
+ impact: orphans.length > 5 ? "critical" : "high",
4061
+ effort: orphans.length > 10 ? "medium" : "low",
4062
+ impactScore: 0,
4063
+ category: "structure",
4064
+ steps: [
4065
+ `Identify the ${orphans.length} orphan pages with zero incoming links`,
4066
+ "Add contextual links from related content pages",
4067
+ "Include orphan pages in navigation menus or footer links",
4068
+ 'Add "Related Content" sections on relevant pages'
4069
+ ],
4070
+ successCriteria: "All content pages have at least 1 incoming internal link",
4071
+ affectedPages: orphans.slice(0, 20),
4072
+ pageCount: orphans.length
4073
+ });
4074
+ }
4075
+ if (linkGraph.stats.maxDepth > 3) {
4076
+ fixes.push({
4077
+ id: "fix-internal-linking-depth",
4078
+ criterion: c.criterion_label,
4079
+ criterionId: c.criterion,
4080
+ title: "Reduce page depth for deep content",
4081
+ description: `Max depth is ${linkGraph.stats.maxDepth} clicks from homepage. AI crawlers rarely follow links beyond 3 levels.`,
4082
+ impact: "medium",
4083
+ effort: "medium",
4084
+ impactScore: 0,
4085
+ category: "structure",
4086
+ steps: [
4087
+ "Identify pages more than 3 clicks from the homepage",
4088
+ "Add direct links from high-level pages to deep content",
4089
+ "Consider flattening URL structure for key pages",
4090
+ "Add hub pages that aggregate related deep content"
4091
+ ],
4092
+ successCriteria: "All important content pages reachable within 3 clicks from homepage"
4093
+ });
4094
+ }
4095
+ if (linkGraph.clusters.length === 0) {
4096
+ fixes.push({
4097
+ id: "fix-internal-linking-clusters",
4098
+ criterion: c.criterion_label,
4099
+ criterionId: c.criterion,
4100
+ title: "Create topic clusters with pillar pages",
4101
+ description: "No topic clusters detected. Organizing content into pillar-spoke clusters strengthens topical authority for AI engines.",
4102
+ impact: "high",
4103
+ effort: "high",
4104
+ impactScore: 0,
4105
+ category: "structure",
4106
+ steps: [
4107
+ "Identify 3-5 core topic areas for your business",
4108
+ "Create comprehensive pillar pages (3000+ words) for each topic",
4109
+ "Write 5-7 supporting articles per pillar linking back to pillar",
4110
+ "Interlink supporting articles within each cluster"
4111
+ ],
4112
+ successCriteria: "At least 2 topic clusters with pillar page and 5+ spoke pages"
4113
+ });
4114
+ }
4115
+ } else {
4116
+ fixes.push({
4117
+ id: "fix-internal-linking-generic",
4118
+ criterion: c.criterion_label,
4119
+ criterionId: c.criterion,
4120
+ title: "Improve internal linking architecture",
4121
+ description: "Strengthen internal linking with descriptive anchor text between related pages.",
4122
+ impact,
4123
+ effort,
4124
+ impactScore: 0,
4125
+ category: "structure",
4126
+ steps: [
4127
+ "Audit current internal link structure",
4128
+ "Add contextual links between related content pages",
4129
+ "Ensure every key page is reachable within 3 clicks from homepage",
4130
+ 'Use descriptive anchor text instead of "click here" or "read more"'
4131
+ ],
4132
+ successCriteria: "Key pages have 3+ incoming internal links with descriptive anchors"
4133
+ });
4134
+ }
4135
+ return fixes;
4136
+ },
4137
+ semantic_html: (c, pages) => {
4138
+ if (c.score >= 10) return [];
4139
+ const impact = impactFromScore(c.score);
4140
+ const effort = effortForCriterion("semantic_html", c.score);
4141
+ const affected = getAffectedPages("semantic_html", pages);
4142
+ return [{
4143
+ id: "fix-semantic-html",
4144
+ criterion: c.criterion_label,
4145
+ criterionId: c.criterion,
4146
+ title: "Implement semantic HTML5 elements",
4147
+ description: "Use semantic HTML5 elements (main, article, nav, header, footer, section) to give AI parsers clear content structure.",
4148
+ impact,
4149
+ effort,
4150
+ impactScore: 0,
4151
+ category: "structure",
4152
+ steps: [
4153
+ "Wrap main content in <main> element",
4154
+ "Use <article> for self-contained content blocks",
4155
+ "Add <nav> for navigation and <aside> for sidebars",
4156
+ "Add lang attribute to <html> and ARIA labels for accessibility"
4157
+ ],
4158
+ successCriteria: "Pages use semantic HTML5 elements with lang attribute",
4159
+ affectedPages: affected,
4160
+ pageCount: affected?.length
4161
+ }];
4162
+ },
4163
+ content_freshness: (c, pages) => {
4164
+ if (c.score >= 10) return [];
4165
+ const impact = impactFromScore(c.score);
4166
+ const effort = effortForCriterion("content_freshness", c.score);
4167
+ const affected = getAffectedPages("content_freshness", pages);
4168
+ return [{
4169
+ id: "fix-content-freshness",
4170
+ criterion: c.criterion_label,
4171
+ criterionId: c.criterion,
4172
+ title: "Add content freshness signals",
4173
+ description: "Include dateModified schema, visible dates, and recent content updates to signal freshness to AI engines.",
4174
+ impact,
4175
+ effort,
4176
+ impactScore: 0,
4177
+ category: "content",
4178
+ steps: [
4179
+ "Add datePublished and dateModified to Article schema",
4180
+ 'Display visible "Last updated" dates on content pages',
4181
+ "Update stale content with current information",
4182
+ "Add <time> elements with datetime attributes for all dates"
4183
+ ],
4184
+ successCriteria: "Content pages show visible dates and have dateModified in schema",
4185
+ affectedPages: affected,
4186
+ pageCount: affected?.length
4187
+ }];
4188
+ },
4189
+ sitemap_completeness: (c) => {
4190
+ if (c.score >= 10) return [];
4191
+ const impact = impactFromScore(c.score);
4192
+ const effort = effortForCriterion("sitemap_completeness", c.score);
4193
+ return [{
4194
+ id: "fix-sitemap",
4195
+ criterion: c.criterion_label,
4196
+ criterionId: c.criterion,
4197
+ title: "Create complete sitemap.xml",
4198
+ description: "Generate a comprehensive sitemap with lastmod dates for all important pages.",
4199
+ impact,
4200
+ effort,
4201
+ impactScore: 0,
4202
+ category: "discovery",
4203
+ steps: [
4204
+ "Generate sitemap.xml listing all content pages",
4205
+ "Include <lastmod> dates for each URL",
4206
+ "Set <changefreq> and <priority> appropriately",
4207
+ "Reference sitemap in robots.txt"
4208
+ ],
4209
+ successCriteria: "sitemap.xml returns 200 with all content pages and lastmod dates"
4210
+ }];
4211
+ },
4212
+ rss_feed: (c) => {
4213
+ if (c.score >= 10) return [];
4214
+ const impact = impactFromScore(c.score);
4215
+ const effort = effortForCriterion("rss_feed", c.score);
4216
+ return [{
4217
+ id: "fix-rss-feed",
4218
+ criterion: c.criterion_label,
4219
+ criterionId: c.criterion,
4220
+ title: "Deploy RSS/Atom feed",
4221
+ description: "Add an RSS or Atom feed for your blog/news content to signal active publishing to AI engines.",
4222
+ impact,
4223
+ effort,
4224
+ impactScore: 0,
4225
+ category: "discovery",
4226
+ steps: [
4227
+ "Create RSS 2.0 or Atom feed for blog/news content",
4228
+ "Include title, description, pubDate, and full content for each item",
4229
+ 'Add <link rel="alternate" type="application/rss+xml"> to page head',
4230
+ "Auto-generate feed on each new publish"
4231
+ ],
4232
+ codeExample: `<?xml version="1.0" encoding="UTF-8"?>
4233
+ <rss version="2.0">
4234
+ <channel>
4235
+ <title>Your Site Blog</title>
4236
+ <link>https://example.com/blog</link>
4237
+ <description>Latest articles</description>
4238
+ <item>
4239
+ <title>Article Title</title>
4240
+ <link>https://example.com/blog/article</link>
4241
+ <pubDate>Mon, 01 Jan 2024 00:00:00 GMT</pubDate>
4242
+ <description>Article summary</description>
4243
+ </item>
4244
+ </channel>
4245
+ </rss>`,
4246
+ successCriteria: "RSS feed returns valid XML with recent content items"
4247
+ }];
4248
+ },
4249
+ table_list_extractability: (c, pages) => {
4250
+ if (c.score >= 10) return [];
4251
+ const impact = impactFromScore(c.score);
4252
+ const effort = effortForCriterion("table_list_extractability", c.score);
4253
+ const affected = getAffectedPages("table_list_extractability", pages);
4254
+ return [{
4255
+ id: "fix-tables-lists",
4256
+ criterion: c.criterion_label,
4257
+ criterionId: c.criterion,
4258
+ title: "Add structured tables and lists",
4259
+ description: "Use HTML tables for comparison data and lists for features, steps, and specifications.",
4260
+ impact,
4261
+ effort,
4262
+ impactScore: 0,
4263
+ category: "content",
4264
+ steps: [
4265
+ "Identify data suitable for table format (comparisons, pricing, specs)",
4266
+ "Convert bullet points to proper <ul>/<ol> lists",
4267
+ "Add comparison tables with <th> headers",
4268
+ "Ensure tables have descriptive captions"
4269
+ ],
4270
+ successCriteria: "Key pages contain at least one HTML table or structured list",
4271
+ affectedPages: affected,
4272
+ pageCount: affected?.length
4273
+ }];
4274
+ },
4275
+ definition_patterns: (c, pages) => {
4276
+ if (c.score >= 10) return [];
4277
+ const impact = impactFromScore(c.score);
4278
+ const effort = effortForCriterion("definition_patterns", c.score);
4279
+ const affected = getAffectedPages("definition_patterns", pages);
4280
+ return [{
4281
+ id: "fix-definitions",
4282
+ criterion: c.criterion_label,
4283
+ criterionId: c.criterion,
4284
+ title: "Add definition-style content",
4285
+ description: 'Include clear definition patterns for key terms and concepts that AI engines can cite for "what is" queries.',
4286
+ impact,
4287
+ effort,
4288
+ impactScore: 0,
4289
+ category: "content",
4290
+ steps: [
4291
+ "Identify key industry terms your audience searches for",
4292
+ 'Write clear definitions using "X is..." or "X refers to..." patterns',
4293
+ "Place definitions near the top of relevant pages",
4294
+ "Consider a glossary page for comprehensive term coverage"
4295
+ ],
4296
+ successCriteria: "Key pages contain definition patterns for relevant terms",
4297
+ affectedPages: affected,
4298
+ pageCount: affected?.length
4299
+ }];
4300
+ },
4301
+ direct_answer_density: (c, pages) => {
4302
+ if (c.score >= 10) return [];
4303
+ const impact = impactFromScore(c.score);
4304
+ const effort = effortForCriterion("direct_answer_density", c.score);
4305
+ const affected = getAffectedPages("direct_answer_density", pages);
4306
+ return [{
4307
+ id: "fix-direct-answers",
4308
+ criterion: c.criterion_label,
4309
+ criterionId: c.criterion,
4310
+ title: "Add direct answer paragraphs",
4311
+ description: "Write concise, standalone answer paragraphs after question headings for AI engine citations.",
4312
+ impact,
4313
+ effort,
4314
+ impactScore: 0,
4315
+ category: "content",
4316
+ steps: [
4317
+ "Identify question-format headings on each page",
4318
+ "Write a 2-3 sentence direct answer immediately after each heading",
4319
+ "Ensure answers are self-contained (don't require context from other sections)",
4320
+ "Use bold for key facts within answer paragraphs"
4321
+ ],
4322
+ successCriteria: "Question headings are followed by direct, concise answer paragraphs",
4323
+ affectedPages: affected,
4324
+ pageCount: affected?.length
4325
+ }];
4326
+ },
4327
+ content_licensing: (c) => {
4328
+ if (c.score >= 10) return [];
4329
+ const impact = impactFromScore(c.score);
4330
+ const effort = effortForCriterion("content_licensing", c.score);
4331
+ return [{
4332
+ id: "fix-content-licensing",
4333
+ criterion: c.criterion_label,
4334
+ criterionId: c.criterion,
4335
+ title: "Add ai.txt and content licensing",
4336
+ description: "Create an /ai.txt file specifying AI usage permissions and add license schema to structured data.",
4337
+ impact,
4338
+ effort,
4339
+ impactScore: 0,
4340
+ category: "trust",
4341
+ steps: [
4342
+ "Create ai.txt at domain root with usage permissions",
4343
+ "Specify allowed AI uses (training, citation, summarization)",
4344
+ "Add license information to schema markup",
4345
+ "Consider a content licensing page linked from footer"
4346
+ ],
4347
+ codeExample: `# ai.txt - AI Usage Policy for example.com
4348
+
4349
+ User-Agent: *
4350
+ Allow: /blog/
4351
+ Allow: /docs/
4352
+
4353
+ # Permissions
4354
+ Training: yes
4355
+ Citation: yes with attribution
4356
+ Summarization: yes`,
4357
+ successCriteria: "/ai.txt returns 200 with clear AI usage permissions"
4358
+ }];
4359
+ },
4360
+ author_schema_depth: (c) => {
4361
+ if (c.score >= 10) return [];
4362
+ const impact = impactFromScore(c.score);
4363
+ const effort = effortForCriterion("author_schema_depth", c.score);
4364
+ return [{
4365
+ id: "fix-author-schema",
4366
+ criterion: c.criterion_label,
4367
+ criterionId: c.criterion,
4368
+ title: "Enhance author and expert schema",
4369
+ description: "Add Person schema for content authors with credentials and sameAs links for E-E-A-T signals.",
4370
+ impact,
4371
+ effort,
4372
+ impactScore: 0,
4373
+ category: "trust",
4374
+ steps: [
4375
+ "Create author profile pages for content creators",
4376
+ "Add Person schema with name, jobTitle, credentials, sameAs",
4377
+ "Link articles to author profiles via schema author property",
4378
+ "Include author bio and expertise on article pages"
4379
+ ],
4380
+ successCriteria: "Articles have Person schema for authors with credentials"
4381
+ }];
4382
+ },
4383
+ fact_density: (c, pages) => {
4384
+ if (c.score >= 10) return [];
4385
+ const impact = impactFromScore(c.score);
4386
+ const effort = effortForCriterion("fact_density", c.score);
4387
+ const affected = getAffectedPages("fact_density", pages);
4388
+ return [{
4389
+ id: "fix-fact-density",
4390
+ criterion: c.criterion_label,
4391
+ criterionId: c.criterion,
4392
+ title: "Increase fact and data density",
4393
+ description: "Add specific numbers, percentages, statistics, and data points that AI engines can cite.",
4394
+ impact,
4395
+ effort,
4396
+ impactScore: 0,
4397
+ category: "content",
4398
+ steps: [
4399
+ "Review content for vague claims and replace with specific data",
4400
+ "Add statistics, percentages, and measurable outcomes",
4401
+ "Include source citations for data points",
4402
+ "Add data tables or comparison charts where appropriate"
4403
+ ],
4404
+ successCriteria: "Key pages contain at least 3 specific data points per 500 words",
4405
+ affectedPages: affected,
4406
+ pageCount: affected?.length
4407
+ }];
4408
+ },
4409
+ canonical_url: (c, pages) => {
4410
+ if (c.score >= 10) return [];
4411
+ const impact = impactFromScore(c.score);
4412
+ const effort = effortForCriterion("canonical_url", c.score);
4413
+ const affected = getAffectedPages("canonical_url", pages);
4414
+ return [{
4415
+ id: "fix-canonical-url",
4416
+ criterion: c.criterion_label,
4417
+ criterionId: c.criterion,
4418
+ title: "Fix canonical URL strategy",
4419
+ description: 'Add rel="canonical" tags to all pages to prevent duplicate content confusion.',
4420
+ impact,
4421
+ effort,
4422
+ impactScore: 0,
4423
+ category: "structure",
4424
+ steps: [
4425
+ 'Add <link rel="canonical"> to every page pointing to preferred URL',
4426
+ "Ensure canonical URLs use consistent scheme (https) and format",
4427
+ "Handle www vs non-www with proper redirects",
4428
+ "Set canonical for paginated content to the main page"
4429
+ ],
4430
+ codeExample: `<link rel="canonical" href="https://example.com/page" />`,
4431
+ successCriteria: 'All pages have rel="canonical" pointing to the correct URL',
4432
+ affectedPages: affected,
4433
+ pageCount: affected?.length
4434
+ }];
4435
+ },
4436
+ content_velocity: (c) => {
4437
+ if (c.score >= 10) return [];
4438
+ const impact = impactFromScore(c.score);
4439
+ const effort = effortForCriterion("content_velocity", c.score);
4440
+ return [{
4441
+ id: "fix-content-velocity",
4442
+ criterion: c.criterion_label,
4443
+ criterionId: c.criterion,
4444
+ title: "Increase publishing frequency",
4445
+ description: "Establish a regular content publishing cadence to signal active, current information to AI engines.",
4446
+ impact,
4447
+ effort,
4448
+ impactScore: 0,
4449
+ category: "content",
4450
+ steps: [
4451
+ "Set a publishing schedule (weekly or bi-weekly minimum)",
4452
+ "Create a content calendar covering key topics",
4453
+ "Update sitemap and RSS feed with each new publish",
4454
+ "Refresh existing evergreen content with current data"
4455
+ ],
4456
+ successCriteria: "At least 2 new or updated content pages per month with dated entries"
4457
+ }];
4458
+ },
4459
+ schema_coverage: (c) => {
4460
+ if (c.score >= 10) return [];
4461
+ const impact = impactFromScore(c.score);
4462
+ const effort = effortForCriterion("schema_coverage", c.score);
4463
+ return [{
4464
+ id: "fix-schema-coverage",
4465
+ criterion: c.criterion_label,
4466
+ criterionId: c.criterion,
4467
+ title: "Extend schema to inner pages",
4468
+ description: "Add page-specific structured data beyond the homepage to articles, services, and product pages.",
4469
+ impact,
4470
+ effort,
4471
+ impactScore: 0,
4472
+ category: "trust",
4473
+ steps: [
4474
+ "Add Article schema to blog/news pages",
4475
+ "Add Service/Product schema to service/product pages",
4476
+ "Add BreadcrumbList schema to all inner pages",
4477
+ "Validate each page type with Rich Results Test"
4478
+ ],
4479
+ successCriteria: "At least 50% of content pages have page-specific schema",
4480
+ dependsOn: ["fix-schema-markup"]
4481
+ }];
4482
+ },
4483
+ speakable_schema: (c) => {
4484
+ if (c.score >= 10) return [];
4485
+ const impact = impactFromScore(c.score);
4486
+ const effort = effortForCriterion("speakable_schema", c.score);
4487
+ return [{
4488
+ id: "fix-speakable-schema",
4489
+ criterion: c.criterion_label,
4490
+ criterionId: c.criterion,
4491
+ title: "Add SpeakableSpecification schema",
4492
+ description: "Add Speakable schema to tell voice assistants which content sections are best for spoken answers.",
4493
+ impact,
4494
+ effort,
4495
+ impactScore: 0,
4496
+ category: "trust",
4497
+ steps: [
4498
+ "Identify key paragraphs suitable for voice readout",
4499
+ "Add SpeakableSpecification with CSS selectors to Article schema",
4500
+ "Point speakable selectors to headline and summary paragraphs",
4501
+ "Test with Google structured data testing tool"
4502
+ ],
4503
+ codeExample: `"speakable": {
4504
+ "@type": "SpeakableSpecification",
4505
+ "cssSelector": [
4506
+ ".article-headline",
4507
+ ".article-summary"
4508
+ ]
4509
+ }`,
4510
+ successCriteria: "Article pages include SpeakableSpecification in schema",
4511
+ dependsOn: ["fix-schema-markup"]
4512
+ }];
4513
+ },
4514
+ query_answer_alignment: (c, pages) => {
4515
+ if (c.score >= 10) return [];
4516
+ const impact = impactFromScore(c.score);
4517
+ const effort = effortForCriterion("query_answer_alignment", c.score);
4518
+ const affected = getAffectedPages("query_answer_alignment", pages);
4519
+ return [{
4520
+ id: "fix-query-answer-alignment",
4521
+ criterion: c.criterion_label,
4522
+ criterionId: c.criterion,
4523
+ title: "Improve query-answer alignment",
4524
+ description: "Ensure question headings are followed by direct, concise answers in the first paragraph.",
4525
+ impact,
4526
+ effort,
4527
+ impactScore: 0,
4528
+ category: "content",
4529
+ steps: [
4530
+ "Audit question-format headings and their following paragraphs",
4531
+ "Add direct answers in the first 1-2 sentences after each question heading",
4532
+ "Remove filler text between question and answer",
4533
+ "Ensure answers are self-contained and citable"
4534
+ ],
4535
+ successCriteria: "Question headings have direct answer paragraphs within 50 words",
4536
+ affectedPages: affected,
4537
+ pageCount: affected?.length
4538
+ }];
4539
+ },
4540
+ content_cannibalization: (c, pages, linkGraph) => {
4541
+ if (c.score >= 10) return [];
4542
+ const impact = impactFromScore(c.score);
4543
+ const effort = effortForCriterion("content_cannibalization", c.score);
4544
+ const fixes = [];
4545
+ if (linkGraph && linkGraph.clusters.length > 0) {
4546
+ const lowCohesion = linkGraph.clusters.filter((cl) => cl.cohesion < 50);
4547
+ if (lowCohesion.length > 0) {
4548
+ const affected = lowCohesion.flatMap((cl) => [cl.pillarUrl, ...cl.spokes]);
4549
+ fixes.push({
4550
+ id: "fix-content-cannibalization-overlap",
4551
+ criterion: c.criterion_label,
4552
+ criterionId: c.criterion,
4553
+ title: "Consolidate overlapping content",
4554
+ description: `${lowCohesion.length} content clusters have low cohesion, suggesting pages compete for the same topics.`,
4555
+ impact,
4556
+ effort,
4557
+ impactScore: 0,
4558
+ category: "content",
4559
+ steps: [
4560
+ "Identify pages targeting the same keywords or topics",
4561
+ "Merge overlapping pages into single authoritative pages",
4562
+ "Set up 301 redirects from merged pages to consolidated page",
4563
+ "Differentiate remaining similar pages with distinct angles"
4564
+ ],
4565
+ successCriteria: "No two pages target the same primary keyword or topic",
4566
+ affectedPages: affected.slice(0, 20),
4567
+ pageCount: affected.length
4568
+ });
4569
+ }
4570
+ }
4571
+ if (fixes.length === 0) {
4572
+ const affected = getAffectedPages("content_cannibalization", pages);
4573
+ fixes.push({
4574
+ id: "fix-content-cannibalization",
4575
+ criterion: c.criterion_label,
4576
+ criterionId: c.criterion,
4577
+ title: "Resolve content cannibalization",
4578
+ description: "Multiple pages may be targeting the same topics, diluting AI engine citations.",
4579
+ impact,
4580
+ effort,
4581
+ impactScore: 0,
4582
+ category: "content",
4583
+ steps: [
4584
+ "Audit pages for overlapping topic coverage",
4585
+ "Consolidate similar pages into comprehensive single pages",
4586
+ "Differentiate remaining pages with distinct angles and keywords",
4587
+ "Add canonical tags to prevent duplicate content issues"
4588
+ ],
4589
+ successCriteria: "Each topic is covered by a single authoritative page",
4590
+ affectedPages: affected,
4591
+ pageCount: affected?.length
4592
+ });
4593
+ }
4594
+ return fixes;
4595
+ },
4596
+ visible_date_signal: (c, pages) => {
4597
+ if (c.score >= 10) return [];
4598
+ const impact = impactFromScore(c.score);
4599
+ const effort = effortForCriterion("visible_date_signal", c.score);
4600
+ const affected = getAffectedPages("visible_date_signal", pages);
4601
+ return [{
4602
+ id: "fix-visible-dates",
4603
+ criterion: c.criterion_label,
4604
+ criterionId: c.criterion,
4605
+ title: "Add visible date signals",
4606
+ description: "Add visible publication and modification dates using <time> elements for AI engine freshness assessment.",
4607
+ impact,
4608
+ effort,
4609
+ impactScore: 0,
4610
+ category: "content",
4611
+ steps: [
4612
+ 'Add visible "Published" and "Last updated" dates to content pages',
4613
+ "Use <time> elements with datetime attributes",
4614
+ "Ensure dates match dateModified in schema markup",
4615
+ "Update dates when content is refreshed"
4616
+ ],
4617
+ codeExample: `<time datetime="2024-01-15">January 15, 2024</time>`,
4618
+ successCriteria: "Content pages show visible dates with <time> elements",
4619
+ affectedPages: affected,
4620
+ pageCount: affected?.length
4621
+ }];
4622
+ }
4623
+ };
4624
+ function generateFixPlan(domain, overallScore, criteria, pagesReviewed, linkGraph) {
4625
+ const allFixes = [];
4626
+ for (const criterion of criteria) {
4627
+ const generator = FIX_GENERATORS[criterion.criterion];
4628
+ if (!generator) continue;
4629
+ const fixes = generator(criterion, pagesReviewed, linkGraph);
4630
+ for (const fix of fixes) {
4631
+ const weight = CRITERION_WEIGHTS2[criterion.criterion] ?? 0.05;
4632
+ fix.impactScore = Math.round((10 - criterion.score) * weight * 100);
4633
+ allFixes.push(fix);
4634
+ }
4635
+ }
4636
+ const phases = PHASE_CONFIG.map((config) => {
4637
+ const phaseFixes = allFixes.filter((fix) => config.criteria.includes(fix.criterionId)).sort((a, b) => b.impactScore - a.impactScore);
4638
+ return {
4639
+ phase: config.phase,
4640
+ title: config.title,
4641
+ description: config.description,
4642
+ fixes: phaseFixes,
4643
+ estimatedImpact: 0
4644
+ // calculated after projected score
4645
+ };
4646
+ });
4647
+ for (const phase of phases) {
4648
+ for (const fix of phase.fixes) {
4649
+ if (!fix.dependsOn) continue;
4650
+ for (const depId of fix.dependsOn) {
4651
+ const depPhase = phases.find((p) => p.fixes.some((f) => f.id === depId));
4652
+ if (depPhase && depPhase.phase > phase.phase) {
4653
+ phase.fixes = phase.fixes.filter((f) => f.id !== fix.id);
4654
+ depPhase.fixes.push(fix);
4655
+ depPhase.fixes.sort((a, b) => b.impactScore - a.impactScore);
4656
+ break;
4657
+ }
4658
+ }
4659
+ }
4660
+ }
4661
+ const totalWeight = Object.values(CRITERION_WEIGHTS2).reduce((s, w) => s + w, 0);
4662
+ const bestDeltaPerCriterion = /* @__PURE__ */ new Map();
4663
+ for (const fix of allFixes) {
4664
+ const criterion = criteria.find((c) => c.criterion === fix.criterionId);
4665
+ if (!criterion) continue;
4666
+ const weight = CRITERION_WEIGHTS2[fix.criterionId] ?? 0.05;
4667
+ let targetScore;
4668
+ switch (fix.effort) {
4669
+ case "trivial":
4670
+ case "low":
4671
+ targetScore = 8;
4672
+ break;
4673
+ case "medium":
4674
+ targetScore = 7;
4675
+ break;
4676
+ case "high":
4677
+ targetScore = 6;
4678
+ break;
4679
+ }
4680
+ const improvement = Math.max(0, targetScore - criterion.score);
4681
+ const delta = improvement * weight / totalWeight * 100;
4682
+ const existing = bestDeltaPerCriterion.get(fix.criterionId) ?? 0;
4683
+ if (delta > existing) bestDeltaPerCriterion.set(fix.criterionId, delta);
4684
+ }
4685
+ const scoreDelta = Array.from(bestDeltaPerCriterion.values()).reduce((s, d) => s + d, 0);
4686
+ const projectedScore = Math.min(100, Math.round(overallScore + scoreDelta));
4687
+ for (const phase of phases) {
4688
+ let phaseImpact = 0;
4689
+ const seenCriteria = /* @__PURE__ */ new Set();
4690
+ for (const fix of phase.fixes) {
4691
+ if (seenCriteria.has(fix.criterionId)) continue;
4692
+ seenCriteria.add(fix.criterionId);
4693
+ const criterion = criteria.find((c) => c.criterion === fix.criterionId);
4694
+ if (!criterion) continue;
4695
+ const weight = CRITERION_WEIGHTS2[fix.criterionId] ?? 0.05;
4696
+ let targetScore;
4697
+ switch (fix.effort) {
4698
+ case "trivial":
4699
+ case "low":
4700
+ targetScore = 8;
4701
+ break;
4702
+ case "medium":
4703
+ targetScore = 7;
4704
+ break;
4705
+ case "high":
4706
+ targetScore = 6;
4707
+ break;
4708
+ }
4709
+ const improvement = Math.max(0, targetScore - criterion.score);
4710
+ phaseImpact += improvement * weight / totalWeight * 100;
4711
+ }
4712
+ phase.estimatedImpact = Math.round(phaseImpact);
4713
+ }
4714
+ const quickWins = allFixes.filter(
4715
+ (f) => (f.effort === "trivial" || f.effort === "low") && (f.impact === "critical" || f.impact === "high")
4716
+ );
4717
+ const summary = {
4718
+ criticalCount: allFixes.filter((f) => f.impact === "critical").length,
4719
+ highCount: allFixes.filter((f) => f.impact === "high").length,
4720
+ mediumCount: allFixes.filter((f) => f.impact === "medium").length,
4721
+ lowCount: allFixes.filter((f) => f.impact === "low").length,
4722
+ quickWinCount: quickWins.length,
4723
+ topOpportunity: allFixes.length > 0 ? allFixes.sort((a, b) => b.impactScore - a.impactScore)[0].title : "None",
4724
+ estimatedTotalEffort: formatEffort(allFixes.reduce((s, f) => s + effortToHours(f.effort), 0))
4725
+ };
4726
+ return {
4727
+ domain,
4728
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
4729
+ overallScore,
4730
+ projectedScore,
4731
+ totalFixes: allFixes.length,
4732
+ phases,
4733
+ quickWins,
4734
+ summary
4735
+ };
4736
+ }
4737
+ function formatEffort(hours) {
4738
+ if (hours < 1) return "<1h";
4739
+ return `~${Math.round(hours)}h`;
4740
+ }
4741
+
3157
4742
  // src/html-report.ts
3158
4743
  function scoreColor(score) {
3159
4744
  if (score <= 40) return "#F44336";
@@ -3489,21 +5074,28 @@ export {
3489
5074
  audit,
3490
5075
  auditSiteFromData,
3491
5076
  buildDetailedFindings,
5077
+ buildLinkGraph,
3492
5078
  buildScorecard,
5079
+ calculateDepths,
3493
5080
  calculateOverallScore,
3494
5081
  classifyRendering,
3495
5082
  compare,
3496
5083
  crawlFullSite,
5084
+ detectClusters,
5085
+ detectHubs,
3497
5086
  detectParkedDomain,
5087
+ detectPillars,
3498
5088
  extractAllUrlsFromSitemap,
3499
5089
  extractContentPagesFromSitemap,
3500
5090
  extractInternalLinks,
5091
+ extractLinksWithAnchors,
3501
5092
  extractNavLinks,
3502
5093
  extractRawDataSummary,
3503
5094
  fetchMultiPageData,
3504
5095
  fetchWithHeadless,
3505
5096
  generateBottomLine,
3506
5097
  generateComparisonHtmlReport,
5098
+ generateFixPlan,
3507
5099
  generateHtmlReport,
3508
5100
  generateOpportunities,
3509
5101
  generatePitchNumbers,
@@ -3513,6 +5105,7 @@ export {
3513
5105
  prefetchSiteData,
3514
5106
  scoreAllPages,
3515
5107
  scorePage,
3516
- scoreToStatus
5108
+ scoreToStatus,
5109
+ serializeLinkGraph
3517
5110
  };
3518
5111
  //# sourceMappingURL=index.js.map