@rankcli/agent-runtime 0.0.14 → 0.0.16

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.
Files changed (199) hide show
  1. package/dist/index.d.mts +77 -393
  2. package/dist/index.d.ts +77 -393
  3. package/dist/index.js +417 -6443
  4. package/dist/index.mjs +296 -6313
  5. package/package.json +6 -1
  6. package/scripts/build-deno.ts +0 -134
  7. package/src/analyzers/core-web-vitals-analyzer.test.ts +0 -236
  8. package/src/analyzers/core-web-vitals-analyzer.ts +0 -557
  9. package/src/analyzers/geo-analyzer.test.ts +0 -310
  10. package/src/analyzers/geo-analyzer.ts +0 -814
  11. package/src/analyzers/image-optimization-analyzer.test.ts +0 -145
  12. package/src/analyzers/image-optimization-analyzer.ts +0 -348
  13. package/src/analyzers/index.ts +0 -233
  14. package/src/analyzers/internal-linking-analyzer.test.ts +0 -141
  15. package/src/analyzers/internal-linking-analyzer.ts +0 -419
  16. package/src/analyzers/mobile-seo-analyzer.test.ts +0 -140
  17. package/src/analyzers/mobile-seo-analyzer.ts +0 -455
  18. package/src/analyzers/security-headers-analyzer.test.ts +0 -115
  19. package/src/analyzers/security-headers-analyzer.ts +0 -318
  20. package/src/analyzers/structured-data-analyzer.test.ts +0 -210
  21. package/src/analyzers/structured-data-analyzer.ts +0 -590
  22. package/src/audit/ai/analyzer.ts +0 -347
  23. package/src/audit/ai/index.ts +0 -29
  24. package/src/audit/ai/prompts/content-analysis.ts +0 -271
  25. package/src/audit/ai/types.ts +0 -179
  26. package/src/audit/checks/additional-checks.ts +0 -439
  27. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  28. package/src/audit/checks/ai-content-structure.ts +0 -325
  29. package/src/audit/checks/ai-readiness.ts +0 -339
  30. package/src/audit/checks/anchor-text.ts +0 -179
  31. package/src/audit/checks/answer-conciseness.ts +0 -322
  32. package/src/audit/checks/asset-minification.ts +0 -270
  33. package/src/audit/checks/bing-optimization.ts +0 -206
  34. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  35. package/src/audit/checks/caching-headers.ts +0 -305
  36. package/src/audit/checks/canonical-advanced.ts +0 -150
  37. package/src/audit/checks/canonical-domain.ts +0 -196
  38. package/src/audit/checks/citation-quality.ts +0 -358
  39. package/src/audit/checks/client-rendering.ts +0 -542
  40. package/src/audit/checks/color-contrast.ts +0 -342
  41. package/src/audit/checks/content-freshness.ts +0 -170
  42. package/src/audit/checks/content-science.ts +0 -589
  43. package/src/audit/checks/conversion-elements.ts +0 -526
  44. package/src/audit/checks/crawlability.ts +0 -220
  45. package/src/audit/checks/directory-listing.ts +0 -172
  46. package/src/audit/checks/dom-analysis.ts +0 -191
  47. package/src/audit/checks/dom-size.ts +0 -246
  48. package/src/audit/checks/duplicate-content.ts +0 -194
  49. package/src/audit/checks/eeat-signals.ts +0 -990
  50. package/src/audit/checks/entity-seo.ts +0 -396
  51. package/src/audit/checks/featured-snippet.ts +0 -473
  52. package/src/audit/checks/freshness-signals.ts +0 -443
  53. package/src/audit/checks/funnel-intent.ts +0 -463
  54. package/src/audit/checks/hreflang.ts +0 -174
  55. package/src/audit/checks/html-compliance.ts +0 -302
  56. package/src/audit/checks/image-dimensions.ts +0 -167
  57. package/src/audit/checks/images.ts +0 -160
  58. package/src/audit/checks/indexnow.ts +0 -275
  59. package/src/audit/checks/interactive-tools.ts +0 -475
  60. package/src/audit/checks/internal-link-graph.ts +0 -436
  61. package/src/audit/checks/keyword-analysis.ts +0 -239
  62. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  63. package/src/audit/checks/keyword-placement.ts +0 -471
  64. package/src/audit/checks/links.ts +0 -273
  65. package/src/audit/checks/llms-txt.ts +0 -224
  66. package/src/audit/checks/local-seo.ts +0 -296
  67. package/src/audit/checks/mobile.ts +0 -167
  68. package/src/audit/checks/modern-images.ts +0 -226
  69. package/src/audit/checks/navboost-signals.ts +0 -395
  70. package/src/audit/checks/on-page.ts +0 -209
  71. package/src/audit/checks/page-resources.ts +0 -285
  72. package/src/audit/checks/pagination.ts +0 -180
  73. package/src/audit/checks/performance.ts +0 -153
  74. package/src/audit/checks/platform-presence.ts +0 -580
  75. package/src/audit/checks/redirect-analysis.ts +0 -153
  76. package/src/audit/checks/redirect-chain.ts +0 -389
  77. package/src/audit/checks/resource-hints.ts +0 -420
  78. package/src/audit/checks/responsive-css.ts +0 -247
  79. package/src/audit/checks/responsive-images.ts +0 -396
  80. package/src/audit/checks/review-ecosystem.ts +0 -415
  81. package/src/audit/checks/robots-validation.ts +0 -373
  82. package/src/audit/checks/security-headers.ts +0 -188
  83. package/src/audit/checks/security.ts +0 -144
  84. package/src/audit/checks/serp-preview.ts +0 -251
  85. package/src/audit/checks/site-maturity.ts +0 -453
  86. package/src/audit/checks/social-meta.test.ts +0 -275
  87. package/src/audit/checks/social-meta.ts +0 -134
  88. package/src/audit/checks/soft-404.ts +0 -151
  89. package/src/audit/checks/structured-data.ts +0 -238
  90. package/src/audit/checks/tech-detection.ts +0 -496
  91. package/src/audit/checks/topical-clusters.ts +0 -435
  92. package/src/audit/checks/tracker-bloat.ts +0 -462
  93. package/src/audit/checks/tracking-verification.test.ts +0 -371
  94. package/src/audit/checks/tracking-verification.ts +0 -636
  95. package/src/audit/checks/url-safety.ts +0 -682
  96. package/src/audit/deno-entry.ts +0 -66
  97. package/src/audit/discovery/index.ts +0 -15
  98. package/src/audit/discovery/link-crawler.ts +0 -233
  99. package/src/audit/discovery/repo-routes.ts +0 -347
  100. package/src/audit/engine.ts +0 -627
  101. package/src/audit/fixes/index.ts +0 -209
  102. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  103. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  104. package/src/audit/index.ts +0 -74
  105. package/src/audit/runner.test.ts +0 -299
  106. package/src/audit/runner.ts +0 -130
  107. package/src/audit/types.ts +0 -1963
  108. package/src/content/featured-snippet.ts +0 -367
  109. package/src/content/generator.test.ts +0 -534
  110. package/src/content/generator.ts +0 -501
  111. package/src/content/headline.ts +0 -317
  112. package/src/content/index.ts +0 -62
  113. package/src/content/intent.ts +0 -258
  114. package/src/content/keyword-density.ts +0 -349
  115. package/src/content/readability.ts +0 -262
  116. package/src/executor.ts +0 -336
  117. package/src/fixer/framework-fixes.test.ts +0 -489
  118. package/src/fixer/framework-fixes.ts +0 -5287
  119. package/src/fixer/index.ts +0 -6
  120. package/src/fixer/schemas.ts +0 -971
  121. package/src/fixer.ts +0 -642
  122. package/src/frameworks/detector.test.ts +0 -248
  123. package/src/frameworks/detector.ts +0 -899
  124. package/src/frameworks/index.ts +0 -68
  125. package/src/frameworks/recipes/angular.yaml +0 -171
  126. package/src/frameworks/recipes/astro.yaml +0 -206
  127. package/src/frameworks/recipes/django.yaml +0 -180
  128. package/src/frameworks/recipes/laravel.yaml +0 -137
  129. package/src/frameworks/recipes/nextjs.yaml +0 -268
  130. package/src/frameworks/recipes/nuxt.yaml +0 -175
  131. package/src/frameworks/recipes/rails.yaml +0 -188
  132. package/src/frameworks/recipes/react.yaml +0 -202
  133. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  134. package/src/frameworks/recipes/vue.yaml +0 -137
  135. package/src/frameworks/recipes/wordpress.yaml +0 -209
  136. package/src/frameworks/suggestion-engine.ts +0 -357
  137. package/src/geo/geo-content.test.ts +0 -305
  138. package/src/geo/geo-content.ts +0 -266
  139. package/src/geo/geo-history.test.ts +0 -473
  140. package/src/geo/geo-history.ts +0 -433
  141. package/src/geo/geo-tracker.test.ts +0 -359
  142. package/src/geo/geo-tracker.ts +0 -411
  143. package/src/geo/index.ts +0 -11
  144. package/src/geo/llm-citation-checker.ts +0 -188
  145. package/src/git/commit-helper.test.ts +0 -261
  146. package/src/git/commit-helper.ts +0 -329
  147. package/src/git/index.ts +0 -12
  148. package/src/git/pr-helper.test.ts +0 -284
  149. package/src/git/pr-helper.ts +0 -307
  150. package/src/index.ts +0 -76
  151. package/src/keywords/ai-keyword-engine.ts +0 -1062
  152. package/src/keywords/ai-summarizer.ts +0 -387
  153. package/src/keywords/ci-mode.ts +0 -555
  154. package/src/keywords/engine.ts +0 -359
  155. package/src/keywords/index.ts +0 -151
  156. package/src/keywords/llm-judge.ts +0 -357
  157. package/src/keywords/nlp-analysis.ts +0 -706
  158. package/src/keywords/prioritizer.ts +0 -295
  159. package/src/keywords/site-crawler.ts +0 -342
  160. package/src/keywords/sources/autocomplete.ts +0 -139
  161. package/src/keywords/sources/competitive-search.ts +0 -450
  162. package/src/keywords/sources/competitor-analysis.ts +0 -374
  163. package/src/keywords/sources/dataforseo.ts +0 -206
  164. package/src/keywords/sources/free-sources.ts +0 -294
  165. package/src/keywords/sources/gsc.ts +0 -123
  166. package/src/keywords/topic-grouping.ts +0 -327
  167. package/src/keywords/types.ts +0 -144
  168. package/src/keywords/wizard.ts +0 -457
  169. package/src/loader.ts +0 -40
  170. package/src/ranking/index.ts +0 -5
  171. package/src/ranking/serp-client.ts +0 -348
  172. package/src/ranking/tracker.ts +0 -380
  173. package/src/ranking/types.ts +0 -123
  174. package/src/reports/index.ts +0 -7
  175. package/src/reports/report-generator.test.ts +0 -293
  176. package/src/reports/report-generator.ts +0 -713
  177. package/src/scheduler/alerts.test.ts +0 -458
  178. package/src/scheduler/alerts.ts +0 -328
  179. package/src/scheduler/index.ts +0 -8
  180. package/src/scheduler/scheduled-audit.test.ts +0 -377
  181. package/src/scheduler/scheduled-audit.ts +0 -149
  182. package/src/test/integration-test.ts +0 -325
  183. package/src/tools/analyzer.ts +0 -373
  184. package/src/tools/crawl.ts +0 -293
  185. package/src/tools/files.ts +0 -301
  186. package/src/tools/h1-fixer.ts +0 -249
  187. package/src/tools/index.ts +0 -67
  188. package/src/tracking/github-action.ts +0 -326
  189. package/src/tracking/google-analytics.ts +0 -265
  190. package/src/tracking/index.ts +0 -45
  191. package/src/tracking/report-generator.ts +0 -386
  192. package/src/tracking/search-console.ts +0 -335
  193. package/src/types.ts +0 -148
  194. package/src/utils/http.ts +0 -302
  195. package/src/wasm-adapter.ts +0 -297
  196. package/src/wasm-entry.ts +0 -14
  197. package/tsconfig.json +0 -17
  198. package/tsup.wasm.config.ts +0 -26
  199. package/vitest.config.ts +0 -15
@@ -1,463 +0,0 @@
1
- // Search Funnel Intent Analysis
2
- // Reference: "6 Advanced SEO Tips for 2026"
3
- // "Stop relying on top of funnel search terms"
4
- // "TOFU, MOFU, BOFU - focus on middle and bottom of funnel"
5
- // "AI overviews answer informational queries - focus on money keywords"
6
-
7
- import * as cheerio from 'cheerio';
8
- import type { AuditIssue } from '../types.js';
9
-
10
- export type FunnelStage = 'tofu' | 'mofu' | 'bofu' | 'mixed';
11
-
12
- export interface FunnelIntentData {
13
- detectedStage: FunnelStage;
14
- confidence: number; // 0-100
15
- signals: {
16
- tofu: string[];
17
- mofu: string[];
18
- bofu: string[];
19
- };
20
- metrics: {
21
- informationalScore: number;
22
- considerationScore: number;
23
- conversionScore: number;
24
- };
25
- pageType: string;
26
- aiOverviewRisk: 'high' | 'medium' | 'low';
27
- recommendations: string[];
28
- }
29
-
30
- // TOFU (Top of Funnel) - Informational intent patterns
31
- const TOFU_PATTERNS = {
32
- url: [
33
- /\/blog\//i,
34
- /\/article/i,
35
- /\/guide/i,
36
- /\/tutorial/i,
37
- /\/how-to/i,
38
- /\/what-is/i,
39
- /\/learn/i,
40
- /\/tips/i,
41
- /\/explained/i,
42
- /\/introduction/i,
43
- /\/beginners?/i,
44
- ],
45
- title: [
46
- /^how to/i,
47
- /^what is/i,
48
- /^what are/i,
49
- /^why /i,
50
- /^when /i,
51
- /^guide to/i,
52
- /complete guide/i,
53
- /beginner'?s? guide/i,
54
- /ultimate guide/i,
55
- /\d+ tips/i,
56
- /\d+ ways/i,
57
- /\d+ things/i,
58
- /explained/i,
59
- /introduction to/i,
60
- /learn /i,
61
- /understanding/i,
62
- ],
63
- content: [
64
- /in this article/i,
65
- /in this guide/i,
66
- /we'll explain/i,
67
- /we'll cover/i,
68
- /you'll learn/i,
69
- /let's explore/i,
70
- /let's dive/i,
71
- /did you know/i,
72
- /according to/i,
73
- /research shows/i,
74
- /studies show/i,
75
- ],
76
- };
77
-
78
- // MOFU (Middle of Funnel) - Consideration/comparison intent patterns
79
- const MOFU_PATTERNS = {
80
- url: [
81
- /\/compare/i,
82
- /\/comparison/i,
83
- /\/vs/i,
84
- /\/versus/i,
85
- /\/alternative/i,
86
- /\/review/i,
87
- /\/pros-cons/i,
88
- /\/features/i,
89
- /\/solutions/i,
90
- /\/case-stud/i,
91
- ],
92
- title: [
93
- /vs\.?$/i,
94
- /versus/i,
95
- /comparison/i,
96
- /compared/i,
97
- /alternative/i,
98
- /review/i,
99
- /pros and cons/i,
100
- /which is better/i,
101
- /best .* for/i,
102
- /top \d+/i,
103
- /\d+ best/i,
104
- /how .* compares/i,
105
- /should you/i,
106
- ],
107
- content: [
108
- /let'?s compare/i,
109
- /in comparison/i,
110
- /alternative to/i,
111
- /pros:/i,
112
- /cons:/i,
113
- /advantages:/i,
114
- /disadvantages:/i,
115
- /key features/i,
116
- /feature comparison/i,
117
- /case study/i,
118
- /our client/i,
119
- /we helped/i,
120
- ],
121
- };
122
-
123
- // BOFU (Bottom of Funnel) - Conversion/purchase intent patterns
124
- const BOFU_PATTERNS = {
125
- url: [
126
- /\/pricing/i,
127
- /\/buy/i,
128
- /\/purchase/i,
129
- /\/order/i,
130
- /\/sign-?up/i,
131
- /\/register/i,
132
- /\/demo/i,
133
- /\/trial/i,
134
- /\/quote/i,
135
- /\/contact/i,
136
- /\/get-started/i,
137
- /\/checkout/i,
138
- /\/hire/i,
139
- /\/services?$/i,
140
- ],
141
- title: [
142
- /pricing/i,
143
- /buy /i,
144
- /purchase/i,
145
- /order /i,
146
- /sign up/i,
147
- /get started/i,
148
- /free trial/i,
149
- /request .* demo/i,
150
- /book .* call/i,
151
- /schedule/i,
152
- /get .* quote/i,
153
- /contact us/i,
154
- /hire /i,
155
- /\$\d+/,
156
- /per month/i,
157
- /\/mo\b/i,
158
- ],
159
- content: [
160
- /add to cart/i,
161
- /buy now/i,
162
- /purchase now/i,
163
- /sign up now/i,
164
- /get started/i,
165
- /start.*trial/i,
166
- /request.*demo/i,
167
- /book.*call/i,
168
- /schedule.*meeting/i,
169
- /contact.*today/i,
170
- /limited.*offer/i,
171
- /special.*price/i,
172
- /money.*back.*guarantee/i,
173
- /free.*shipping/i,
174
- /plans.*pricing/i,
175
- /per user/i,
176
- /per month/i,
177
- /billed annually/i,
178
- /\$\d+/,
179
- ],
180
- elements: [
181
- 'form[action*="checkout"]',
182
- 'form[action*="purchase"]',
183
- 'form[action*="subscribe"]',
184
- 'button[data-action="buy"]',
185
- '[class*="pricing-table"]',
186
- '[class*="price-card"]',
187
- '[class*="checkout"]',
188
- '[class*="add-to-cart"]',
189
- ],
190
- };
191
-
192
- /**
193
- * Calculate score for a funnel stage based on pattern matches
194
- */
195
- function calculateStageScore(
196
- url: string,
197
- title: string,
198
- content: string,
199
- $: cheerio.CheerioAPI,
200
- patterns: {
201
- url: RegExp[];
202
- title: RegExp[];
203
- content: RegExp[];
204
- elements?: string[];
205
- }
206
- ): { score: number; signals: string[] } {
207
- let score = 0;
208
- const signals: string[] = [];
209
-
210
- // URL patterns (weighted highest)
211
- for (const pattern of patterns.url) {
212
- if (pattern.test(url)) {
213
- score += 15;
214
- signals.push(`URL: ${pattern.source}`);
215
- }
216
- }
217
-
218
- // Title patterns (high weight)
219
- for (const pattern of patterns.title) {
220
- if (pattern.test(title)) {
221
- score += 12;
222
- signals.push(`Title: ${pattern.source}`);
223
- }
224
- }
225
-
226
- // Content patterns (medium weight)
227
- for (const pattern of patterns.content) {
228
- if (pattern.test(content)) {
229
- score += 5;
230
- signals.push(`Content: ${pattern.source}`);
231
- }
232
- }
233
-
234
- // Element patterns (BOFU only)
235
- if (patterns.elements) {
236
- for (const selector of patterns.elements) {
237
- if ($(selector).length > 0) {
238
- score += 10;
239
- signals.push(`Element: ${selector}`);
240
- }
241
- }
242
- }
243
-
244
- return { score, signals: signals.slice(0, 5) }; // Limit signals for readability
245
- }
246
-
247
- /**
248
- * Determine page type based on content
249
- */
250
- function determinePageType($: cheerio.CheerioAPI, url: string): string {
251
- // Check URL first
252
- if (/\/blog\//i.test(url)) return 'blog-post';
253
- if (/\/product/i.test(url)) return 'product-page';
254
- if (/\/services?/i.test(url)) return 'service-page';
255
- if (/\/pricing/i.test(url)) return 'pricing-page';
256
- if (/\/about/i.test(url)) return 'about-page';
257
- if (/\/contact/i.test(url)) return 'contact-page';
258
- if (/\/case-stud/i.test(url)) return 'case-study';
259
-
260
- // Check content
261
- if ($('[class*="pricing"]').length > 0) return 'pricing-page';
262
- if ($('[class*="product"]').length > 0) return 'product-page';
263
- if ($('article').length > 0) return 'article';
264
- if ($('[class*="blog"]').length > 0) return 'blog-post';
265
-
266
- // Check for e-commerce
267
- if ($('[class*="cart"]').length > 0 || $('[class*="checkout"]').length > 0) return 'e-commerce';
268
-
269
- return 'general';
270
- }
271
-
272
- /**
273
- * Calculate AI overview risk (likelihood of being replaced by AI-generated answer)
274
- */
275
- function calculateAIOverviewRisk(stage: FunnelStage, pageType: string): FunnelIntentData['aiOverviewRisk'] {
276
- // TOFU informational content is most at risk
277
- if (stage === 'tofu') {
278
- return 'high';
279
- }
280
-
281
- // Blog posts and articles are at risk
282
- if (pageType === 'blog-post' || pageType === 'article') {
283
- return 'high';
284
- }
285
-
286
- // MOFU comparison content is medium risk
287
- if (stage === 'mofu') {
288
- return 'medium';
289
- }
290
-
291
- // BOFU transactional content is least at risk
292
- return 'low';
293
- }
294
-
295
- /**
296
- * Main function: Analyze search funnel intent
297
- */
298
- export function analyzeFunnelIntent(
299
- html: string,
300
- url: string
301
- ): { issues: AuditIssue[]; data: FunnelIntentData } {
302
- const $ = cheerio.load(html);
303
- const issues: AuditIssue[] = [];
304
-
305
- // Extract text content
306
- const title = $('title').text().trim() + ' ' + $('h1').first().text().trim();
307
- const bodyText = $('body').text().toLowerCase();
308
-
309
- // Calculate scores for each funnel stage
310
- const tofuResult = calculateStageScore(url, title, bodyText, $, TOFU_PATTERNS);
311
- const mofuResult = calculateStageScore(url, title, bodyText, $, MOFU_PATTERNS);
312
- const bofuResult = calculateStageScore(url, title, bodyText, $, BOFU_PATTERNS);
313
-
314
- // Normalize scores
315
- const totalScore = tofuResult.score + mofuResult.score + bofuResult.score || 1;
316
- const informationalScore = Math.round((tofuResult.score / totalScore) * 100);
317
- const considerationScore = Math.round((mofuResult.score / totalScore) * 100);
318
- const conversionScore = Math.round((bofuResult.score / totalScore) * 100);
319
-
320
- // Determine primary funnel stage
321
- let detectedStage: FunnelStage;
322
- let confidence: number;
323
-
324
- if (bofuResult.score > tofuResult.score && bofuResult.score > mofuResult.score) {
325
- detectedStage = 'bofu';
326
- confidence = conversionScore;
327
- } else if (mofuResult.score > tofuResult.score) {
328
- detectedStage = 'mofu';
329
- confidence = considerationScore;
330
- } else if (tofuResult.score > 0) {
331
- detectedStage = 'tofu';
332
- confidence = informationalScore;
333
- } else {
334
- detectedStage = 'mixed';
335
- confidence = 50;
336
- }
337
-
338
- // Determine page type
339
- const pageType = determinePageType($, url);
340
-
341
- // Calculate AI overview risk
342
- const aiOverviewRisk = calculateAIOverviewRisk(detectedStage, pageType);
343
-
344
- // Generate recommendations
345
- const recommendations: string[] = [];
346
-
347
- if (detectedStage === 'tofu') {
348
- recommendations.push('Consider adding conversion elements (CTAs, forms) to capture leads');
349
- recommendations.push('Link to MOFU/BOFU pages (comparisons, pricing) to guide users down the funnel');
350
- if (aiOverviewRisk === 'high') {
351
- recommendations.push('Add unique data, case studies, or expert opinions that AI cannot replicate');
352
- }
353
- }
354
-
355
- if (detectedStage === 'mofu') {
356
- recommendations.push('Add clear CTAs to BOFU pages (pricing, demos, trials)');
357
- recommendations.push('Include social proof (testimonials, case studies) to build trust');
358
- }
359
-
360
- if (detectedStage === 'mixed') {
361
- recommendations.push('Clarify the page\'s primary intent - is this informational, comparison, or conversion focused?');
362
- recommendations.push('Consider splitting into multiple focused pages for better SEO');
363
- }
364
-
365
- // Generate issues
366
-
367
- // High AI overview risk on TOFU content
368
- if (aiOverviewRisk === 'high' && detectedStage === 'tofu') {
369
- issues.push({
370
- code: 'TOFU_AI_OVERVIEW_RISK',
371
- severity: 'notice',
372
- category: 'content',
373
- title: 'Content at risk of AI overview displacement',
374
- description: 'This informational content may be answered directly by AI overviews, reducing click-through.',
375
- impact: 'Google AI overviews are increasingly answering informational queries directly in SERPs.',
376
- howToFix: 'Add unique value: original data, expert opinions, case studies, or interactive tools that AI cannot replicate.',
377
- affectedUrls: [url],
378
- details: {
379
- funnelStage: 'tofu',
380
- aiOverviewRisk,
381
- recommendation: 'Focus on MOFU/BOFU content or add unique differentiating content',
382
- },
383
- });
384
- }
385
-
386
- // TOFU without BOFU links
387
- if (detectedStage === 'tofu') {
388
- const hasConversionLinks = $('a[href*="pricing"], a[href*="demo"], a[href*="trial"], a[href*="contact"], a[href*="buy"]').length > 0;
389
- if (!hasConversionLinks) {
390
- issues.push({
391
- code: 'TOFU_NO_FUNNEL_LINKS',
392
- severity: 'notice',
393
- category: 'content',
394
- title: 'Informational page lacks conversion path',
395
- description: 'This TOFU content has no links to pricing, demo, trial, or contact pages.',
396
- impact: 'Users may leave without entering the sales funnel. Missing revenue opportunity.',
397
- howToFix: 'Add contextual CTAs linking to MOFU/BOFU pages (comparisons, pricing, demos).',
398
- affectedUrls: [url],
399
- });
400
- }
401
- }
402
-
403
- // BOFU page without social proof
404
- if (detectedStage === 'bofu') {
405
- const hasSocialProof = $('[class*="testimonial"], [class*="review"], [class*="case-study"], [class*="trust"]').length > 0 ||
406
- bodyText.includes('testimonial') || bodyText.includes('customer said');
407
-
408
- if (!hasSocialProof) {
409
- issues.push({
410
- code: 'BOFU_NO_SOCIAL_PROOF',
411
- severity: 'warning',
412
- category: 'content',
413
- title: 'Conversion page lacks social proof',
414
- description: 'This pricing/sales page has no visible testimonials, reviews, or case studies.',
415
- impact: '97% of consumers look at reviews before buying. Social proof can increase conversions by 34%.',
416
- howToFix: 'Add customer testimonials, case study results, trust badges, or review ratings.',
417
- affectedUrls: [url],
418
- details: {
419
- funnelStage: 'bofu',
420
- pageType,
421
- },
422
- });
423
- }
424
- }
425
-
426
- // Mixed intent page
427
- if (detectedStage === 'mixed' && confidence < 40) {
428
- issues.push({
429
- code: 'MIXED_FUNNEL_INTENT',
430
- severity: 'notice',
431
- category: 'content',
432
- title: 'Unclear page intent',
433
- description: 'This page has mixed signals - unclear if informational, comparison, or conversion focused.',
434
- impact: 'Mixed intent pages may rank poorly because search engines cannot determine primary purpose.',
435
- howToFix: 'Focus on one primary intent per page. Create separate pages for different funnel stages.',
436
- affectedUrls: [url],
437
- details: {
438
- scores: { tofu: informationalScore, mofu: considerationScore, bofu: conversionScore },
439
- },
440
- });
441
- }
442
-
443
- return {
444
- issues,
445
- data: {
446
- detectedStage,
447
- confidence,
448
- signals: {
449
- tofu: tofuResult.signals,
450
- mofu: mofuResult.signals,
451
- bofu: bofuResult.signals,
452
- },
453
- metrics: {
454
- informationalScore,
455
- considerationScore,
456
- conversionScore,
457
- },
458
- pageType,
459
- aiOverviewRisk,
460
- recommendations,
461
- },
462
- };
463
- }
@@ -1,174 +0,0 @@
1
- import * as cheerio from 'cheerio';
2
- import { httpHead, httpGet } from '../../utils/http.js';
3
- import type { AuditIssue } from '../types.js';
4
- import { ISSUE_DEFINITIONS } from '../types.js';
5
-
6
- export interface HreflangData {
7
- hasHreflang: boolean;
8
- entries: HreflangEntry[];
9
- hasSelfReference: boolean;
10
- hasXDefault: boolean;
11
- }
12
-
13
- export interface HreflangEntry {
14
- lang: string;
15
- href: string;
16
- isValid: boolean;
17
- isSelfReference: boolean;
18
- statusCode?: number;
19
- }
20
-
21
- // Valid ISO 639-1 language codes (subset of most common)
22
- const VALID_LANG_CODES = new Set([
23
- 'en', 'es', 'fr', 'de', 'it', 'pt', 'ru', 'ja', 'zh', 'ko', 'ar', 'hi', 'nl', 'sv',
24
- 'pl', 'tr', 'da', 'fi', 'no', 'cs', 'el', 'he', 'hu', 'id', 'ms', 'th', 'vi', 'uk',
25
- 'ro', 'bg', 'hr', 'sk', 'sl', 'et', 'lv', 'lt', 'sr', 'ca', 'eu', 'gl', 'af', 'sw',
26
- 'x-default'
27
- ]);
28
-
29
- function isValidHreflang(lang: string): boolean {
30
- const parts = lang.toLowerCase().split('-');
31
- if (parts[0] === 'x' && parts[1] === 'default') return true;
32
- if (!VALID_LANG_CODES.has(parts[0])) return false;
33
- // Region codes are optional, just check length if present
34
- if (parts[1] && parts[1].length !== 2) return false;
35
- return true;
36
- }
37
-
38
- export async function analyzeHreflang(
39
- html: string,
40
- url: string,
41
- options: { validateUrls?: boolean } = {}
42
- ): Promise<{ issues: AuditIssue[]; data: HreflangData }> {
43
- const issues: AuditIssue[] = [];
44
- const $ = cheerio.load(html);
45
- const entries: HreflangEntry[] = [];
46
-
47
- // Extract hreflang from link tags
48
- $('link[rel="alternate"][hreflang]').each((_, el) => {
49
- const lang = $(el).attr('hreflang') || '';
50
- const href = $(el).attr('href') || '';
51
- const isValid = isValidHreflang(lang);
52
- const isSelfReference = normalizeUrl(href) === normalizeUrl(url);
53
-
54
- entries.push({ lang, href, isValid, isSelfReference });
55
- });
56
-
57
- // Also check for hreflang in HTTP headers (would need to be passed in)
58
-
59
- const hasHreflang = entries.length > 0;
60
- const hasSelfReference = entries.some(e => e.isSelfReference);
61
- const hasXDefault = entries.some(e => e.lang.toLowerCase() === 'x-default');
62
-
63
- const data: HreflangData = {
64
- hasHreflang,
65
- entries,
66
- hasSelfReference,
67
- hasXDefault,
68
- };
69
-
70
- if (!hasHreflang) {
71
- // No hreflang is not necessarily an issue for single-language sites
72
- return { issues, data };
73
- }
74
-
75
- // Check for invalid hreflang values
76
- const invalidEntries = entries.filter(e => !e.isValid);
77
- if (invalidEntries.length > 0) {
78
- issues.push({
79
- ...ISSUE_DEFINITIONS.HREFLANG_INVALID,
80
- affectedUrls: [url],
81
- details: { invalidLanguages: invalidEntries.map(e => e.lang) },
82
- });
83
- }
84
-
85
- // Check for missing self-reference
86
- if (!hasSelfReference) {
87
- issues.push({
88
- ...ISSUE_DEFINITIONS.HREFLANG_SELF_MISSING,
89
- affectedUrls: [url],
90
- });
91
- }
92
-
93
- // Check for missing x-default
94
- if (!hasXDefault && entries.length > 1) {
95
- issues.push({
96
- ...ISSUE_DEFINITIONS.HREFLANG_X_DEFAULT_MISSING,
97
- affectedUrls: [url],
98
- });
99
- }
100
-
101
- // Validate hreflang URLs if enabled
102
- if (options.validateUrls) {
103
- for (const entry of entries) {
104
- if (!entry.isSelfReference && entry.href) {
105
- try {
106
- const response = await httpHead(entry.href, {
107
- timeout: 5000,
108
- maxRedirects: 0,
109
- validateStatus: () => true,
110
- });
111
- entry.statusCode = response.status;
112
-
113
- if (response.status >= 300) {
114
- issues.push({
115
- ...ISSUE_DEFINITIONS.HREFLANG_TO_NON_200,
116
- affectedUrls: [url],
117
- details: {
118
- targetUrl: entry.href,
119
- lang: entry.lang,
120
- statusCode: response.status
121
- },
122
- });
123
- }
124
- } catch {
125
- entry.statusCode = 0;
126
- issues.push({
127
- ...ISSUE_DEFINITIONS.HREFLANG_TO_NON_200,
128
- affectedUrls: [url],
129
- details: {
130
- targetUrl: entry.href,
131
- lang: entry.lang,
132
- statusCode: 'unreachable'
133
- },
134
- });
135
- }
136
- }
137
- }
138
-
139
- // Check for reciprocal links
140
- for (const entry of entries) {
141
- if (!entry.isSelfReference && entry.href && entry.statusCode === 200) {
142
- try {
143
- const response = await httpGet<string>(entry.href, { timeout: 5000 });
144
- const $target = cheerio.load(response.data);
145
- const hasReturnLink = $target(`link[rel="alternate"][hreflang][href*="${new URL(url).hostname}"]`).length > 0;
146
-
147
- if (!hasReturnLink) {
148
- issues.push({
149
- ...ISSUE_DEFINITIONS.HREFLANG_NO_RETURN,
150
- affectedUrls: [url],
151
- details: {
152
- targetUrl: entry.href,
153
- lang: entry.lang
154
- },
155
- });
156
- }
157
- } catch {
158
- // Skip if can't fetch
159
- }
160
- }
161
- }
162
- }
163
-
164
- return { issues, data };
165
- }
166
-
167
- function normalizeUrl(urlStr: string): string {
168
- try {
169
- const parsed = new URL(urlStr);
170
- return `${parsed.protocol}//${parsed.host}${parsed.pathname}`.replace(/\/$/, '');
171
- } catch {
172
- return urlStr;
173
- }
174
- }