@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,526 +0,0 @@
1
- // Conversion Elements & Above-the-Fold Analysis
2
- // Reference: "4 Steps to Rank #1 in Google (2026 SEO Plan)" by Nathan Gotch
3
- // "80% of people only read headlines" - above the fold is critical
4
- // "97% of consumers look at reviews, testimonials can increase conversions by 34%"
5
-
6
- import * as cheerio from 'cheerio';
7
- import type { AuditIssue } from '../types.js';
8
-
9
- export interface AboveFoldAnalysis {
10
- hasHeadline: boolean;
11
- headlineText: string | null;
12
- hasCTA: boolean;
13
- ctaCount: number;
14
- ctaTexts: string[];
15
- hasForm: boolean;
16
- formType: 'contact' | 'signup' | 'search' | 'calculator' | 'other' | null;
17
- hasSocialProof: boolean;
18
- socialProofTypes: string[];
19
- hasHeroImage: boolean;
20
- hasVideo: boolean;
21
- estimatedAboveFoldScore: number; // 0-100
22
- }
23
-
24
- export interface SocialProofAnalysis {
25
- hasTestimonials: boolean;
26
- testimonialCount: number;
27
- hasReviews: boolean;
28
- reviewCount: number;
29
- hasRatings: boolean;
30
- averageRating: number | null;
31
- hasClientLogos: boolean;
32
- clientLogoCount: number;
33
- hasCaseStudies: boolean;
34
- hasAwards: boolean;
35
- hasCertifications: boolean;
36
- hasTrustBadges: boolean;
37
- hasStatistics: boolean;
38
- statisticsFound: string[];
39
- socialProofScore: number; // 0-100
40
- }
41
-
42
- export interface EngagementTriggers {
43
- hasCalculator: boolean;
44
- calculatorTypes: string[];
45
- hasQuiz: boolean;
46
- hasInteractiveElement: boolean;
47
- interactiveTypes: string[];
48
- hasEmbeddedVideo: boolean;
49
- videoCount: number;
50
- hasExpandableContent: boolean;
51
- hasTabsOrAccordion: boolean;
52
- hasChatWidget: boolean;
53
- engagementScore: number; // 0-100
54
- }
55
-
56
- export interface ConversionElementsData {
57
- aboveFold: AboveFoldAnalysis;
58
- socialProof: SocialProofAnalysis;
59
- engagementTriggers: EngagementTriggers;
60
- pageType: 'commercial' | 'informational' | 'mixed' | 'unknown';
61
- recommendations: string[];
62
- }
63
-
64
- // CTA patterns
65
- const CTA_PATTERNS = [
66
- /get (started|quote|help|access|now)/i,
67
- /start (now|free|today|here)/i,
68
- /sign up/i,
69
- /subscribe/i,
70
- /contact us/i,
71
- /book (a |now|today|call|demo|meeting)/i,
72
- /schedule/i,
73
- /request (a |quote|demo|call)/i,
74
- /free (trial|quote|consultation|estimate)/i,
75
- /buy now/i,
76
- /add to cart/i,
77
- /shop now/i,
78
- /learn more/i,
79
- /download/i,
80
- /try (it |now|free)/i,
81
- /call (us|now|today)/i,
82
- /chat (with us|now)/i,
83
- ];
84
-
85
- // Social proof selectors and patterns
86
- const TESTIMONIAL_SELECTORS = [
87
- '.testimonial', '.testimonials', '[class*="testimonial"]',
88
- '.review', '.reviews', '[class*="review"]',
89
- '.quote', '[class*="customer-quote"]',
90
- '.client-feedback', '[class*="feedback"]',
91
- 'blockquote[class*="testimonial"]',
92
- ];
93
-
94
- const CLIENT_LOGO_SELECTORS = [
95
- '.client-logos', '.clients', '[class*="client-logo"]',
96
- '.partner-logos', '.partners', '[class*="partner"]',
97
- '.trusted-by', '[class*="trusted"]',
98
- '.as-seen-in', '[class*="featured-in"]',
99
- '.logo-wall', '.logo-carousel',
100
- ];
101
-
102
- /**
103
- * Analyze above-the-fold content
104
- */
105
- export function analyzeAboveFold(html: string): AboveFoldAnalysis {
106
- const $ = cheerio.load(html);
107
-
108
- // Get first significant elements (approximating above fold)
109
- // In a real browser, this would use viewport calculations
110
- const header = $('header').first();
111
- const hero = $('.hero, [class*="hero"], .banner, [class*="banner"], .jumbotron, [class*="landing"]').first();
112
- const firstSection = $('main > section, main > div, body > section').first();
113
-
114
- // Combine above-fold content
115
- const headerHtml = header.html() || '';
116
- const heroOrSectionHtml = hero.length ? (hero.html() || '') : (firstSection.html() || '');
117
- const aboveFoldHtml = headerHtml + heroOrSectionHtml;
118
- const $above = cheerio.load(aboveFoldHtml);
119
-
120
- // Check for headline
121
- const h1 = $('h1').first();
122
- const hasHeadline = h1.length > 0;
123
- const headlineText = h1.text().trim() || null;
124
-
125
- // Check for CTAs
126
- const ctaTexts: string[] = [];
127
- $('a, button').each((_, el) => {
128
- const text = $(el).text().trim();
129
- for (const pattern of CTA_PATTERNS) {
130
- if (pattern.test(text)) {
131
- ctaTexts.push(text);
132
- break;
133
- }
134
- }
135
- });
136
-
137
- // Check for forms
138
- const forms = $('form');
139
- let formType: AboveFoldAnalysis['formType'] = null;
140
- if (forms.length > 0) {
141
- const formHtml = forms.first().html()?.toLowerCase() || '';
142
- if (formHtml.includes('calculator') || formHtml.includes('estimate')) {
143
- formType = 'calculator';
144
- } else if (formHtml.includes('search') || formHtml.includes('query')) {
145
- formType = 'search';
146
- } else if (formHtml.includes('email') && formHtml.includes('subscribe')) {
147
- formType = 'signup';
148
- } else if (formHtml.includes('phone') || formHtml.includes('contact') || formHtml.includes('message')) {
149
- formType = 'contact';
150
- } else {
151
- formType = 'other';
152
- }
153
- }
154
-
155
- // Check for social proof in above fold
156
- const hasSocialProofAbove = $('[class*="testimonial"], [class*="review"], [class*="rating"], [class*="trust"]').length > 0;
157
- const socialProofTypes: string[] = [];
158
- if ($('[class*="rating"], [class*="star"]').length > 0) socialProofTypes.push('ratings');
159
- if ($('[class*="testimonial"]').length > 0) socialProofTypes.push('testimonials');
160
- if ($('[class*="client-logo"], [class*="trusted"]').length > 0) socialProofTypes.push('client-logos');
161
-
162
- // Hero image
163
- const hasHeroImage = hero.find('img').length > 0 || $('header img').length > 0;
164
-
165
- // Video
166
- const hasVideo = $('video, iframe[src*="youtube"], iframe[src*="vimeo"]').length > 0;
167
-
168
- // Calculate score
169
- let score = 0;
170
- if (hasHeadline) score += 25;
171
- if (ctaTexts.length > 0) score += 25;
172
- if (forms.length > 0) score += 20;
173
- if (hasSocialProofAbove) score += 15;
174
- if (hasHeroImage || hasVideo) score += 15;
175
-
176
- return {
177
- hasHeadline,
178
- headlineText,
179
- hasCTA: ctaTexts.length > 0,
180
- ctaCount: ctaTexts.length,
181
- ctaTexts: [...new Set(ctaTexts)].slice(0, 5),
182
- hasForm: forms.length > 0,
183
- formType,
184
- hasSocialProof: hasSocialProofAbove,
185
- socialProofTypes,
186
- hasHeroImage,
187
- hasVideo,
188
- estimatedAboveFoldScore: score,
189
- };
190
- }
191
-
192
- /**
193
- * Analyze social proof elements
194
- */
195
- export function analyzeSocialProof(html: string): SocialProofAnalysis {
196
- const $ = cheerio.load(html);
197
- const text = $('body').text().toLowerCase();
198
-
199
- // Testimonials
200
- let testimonialCount = 0;
201
- for (const selector of TESTIMONIAL_SELECTORS) {
202
- testimonialCount += $(selector).length;
203
- }
204
- const hasTestimonials = testimonialCount > 0;
205
-
206
- // Reviews
207
- const reviewElements = $('[class*="review"], [itemtype*="Review"]');
208
- const hasReviews = reviewElements.length > 0;
209
- const reviewCount = reviewElements.length;
210
-
211
- // Ratings
212
- const ratingElements = $('[class*="rating"], [class*="star"], [itemprop="ratingValue"]');
213
- const hasRatings = ratingElements.length > 0;
214
- let averageRating: number | null = null;
215
- const ratingValue = $('[itemprop="ratingValue"]').first().text();
216
- if (ratingValue) {
217
- const parsed = parseFloat(ratingValue);
218
- if (!isNaN(parsed)) averageRating = parsed;
219
- }
220
-
221
- // Client logos
222
- let clientLogoCount = 0;
223
- for (const selector of CLIENT_LOGO_SELECTORS) {
224
- const container = $(selector);
225
- if (container.length > 0) {
226
- clientLogoCount = container.find('img').length || 1;
227
- break;
228
- }
229
- }
230
- const hasClientLogos = clientLogoCount > 0;
231
-
232
- // Case studies
233
- const hasCaseStudies =
234
- $('a[href*="case-stud"], [class*="case-study"]').length > 0 ||
235
- text.includes('case study') || text.includes('case studies');
236
-
237
- // Awards
238
- const hasAwards =
239
- $('[class*="award"]').length > 0 ||
240
- text.includes('award-winning') || text.includes('winner');
241
-
242
- // Certifications
243
- const hasCertifications =
244
- $('[class*="certif"], [class*="accredit"]').length > 0 ||
245
- /certified|accredited|licensed/i.test(text);
246
-
247
- // Trust badges
248
- const hasTrustBadges =
249
- $('[class*="trust-badge"], [class*="security-badge"], [class*="guarantee"]').length > 0;
250
-
251
- // Statistics (numbers that prove credibility)
252
- const statisticsFound: string[] = [];
253
- const statPatterns = [
254
- /(\d+(?:,\d{3})*\+?)\s*(customers?|clients?|users?|businesses?)/gi,
255
- /(\d+(?:,\d{3})*\+?)\s*(years?)\s*(of experience|in business)/gi,
256
- /(\d+)%\s*(satisfaction|success|increase|growth)/gi,
257
- /\$(\d+(?:,\d{3})*(?:\.\d+)?[MBK]?)\s*(saved|recovered|generated)/gi,
258
- ];
259
- for (const pattern of statPatterns) {
260
- const matches = text.match(pattern);
261
- if (matches) {
262
- statisticsFound.push(...matches.slice(0, 3));
263
- }
264
- }
265
- const hasStatistics = statisticsFound.length > 0;
266
-
267
- // Calculate score
268
- let score = 0;
269
- if (hasTestimonials) score += 20;
270
- if (hasReviews) score += 15;
271
- if (hasRatings) score += 10;
272
- if (hasClientLogos) score += 15;
273
- if (hasCaseStudies) score += 15;
274
- if (hasAwards || hasCertifications) score += 10;
275
- if (hasTrustBadges) score += 5;
276
- if (hasStatistics) score += 10;
277
-
278
- return {
279
- hasTestimonials,
280
- testimonialCount,
281
- hasReviews,
282
- reviewCount,
283
- hasRatings,
284
- averageRating,
285
- hasClientLogos,
286
- clientLogoCount,
287
- hasCaseStudies,
288
- hasAwards,
289
- hasCertifications,
290
- hasTrustBadges,
291
- hasStatistics,
292
- statisticsFound: [...new Set(statisticsFound)].slice(0, 5),
293
- socialProofScore: Math.min(100, score),
294
- };
295
- }
296
-
297
- /**
298
- * Detect engagement triggers (interactive elements)
299
- */
300
- export function detectEngagementTriggers(html: string): EngagementTriggers {
301
- const $ = cheerio.load(html);
302
- const htmlLower = html.toLowerCase();
303
-
304
- // Calculators
305
- const calculatorTypes: string[] = [];
306
- const calcPatterns = [
307
- { pattern: /calculator/i, type: 'calculator' },
308
- { pattern: /estimator/i, type: 'estimator' },
309
- { pattern: /roi.*calculator|calculator.*roi/i, type: 'ROI calculator' },
310
- { pattern: /price.*calculator|cost.*calculator/i, type: 'price calculator' },
311
- { pattern: /mortgage.*calculator/i, type: 'mortgage calculator' },
312
- { pattern: /loan.*calculator/i, type: 'loan calculator' },
313
- { pattern: /bmi.*calculator/i, type: 'BMI calculator' },
314
- { pattern: /quote.*tool|instant.*quote/i, type: 'quote tool' },
315
- ];
316
-
317
- for (const { pattern, type } of calcPatterns) {
318
- if (pattern.test(htmlLower)) {
319
- calculatorTypes.push(type);
320
- }
321
- }
322
- const hasCalculator = calculatorTypes.length > 0;
323
-
324
- // Quiz
325
- const hasQuiz =
326
- $('[class*="quiz"], [id*="quiz"]').length > 0 ||
327
- /quiz|assessment|self-test/i.test(htmlLower);
328
-
329
- // Interactive elements
330
- const interactiveTypes: string[] = [];
331
- if ($('input[type="range"], .slider, [class*="slider"]').length > 0) interactiveTypes.push('slider');
332
- if ($('[class*="configurator"], [class*="customizer"]').length > 0) interactiveTypes.push('configurator');
333
- if ($('canvas, [class*="chart"], [class*="graph"]').length > 0) interactiveTypes.push('charts/graphs');
334
- if ($('[class*="map"], #map, .map').length > 0) interactiveTypes.push('interactive map');
335
- if ($('[class*="filter"], [class*="sort"]').length > 0) interactiveTypes.push('filters');
336
-
337
- const hasInteractiveElement = interactiveTypes.length > 0;
338
-
339
- // Embedded video
340
- const videos = $('video, iframe[src*="youtube"], iframe[src*="vimeo"], iframe[src*="wistia"], [class*="video-embed"]');
341
- const hasEmbeddedVideo = videos.length > 0;
342
- const videoCount = videos.length;
343
-
344
- // Expandable content
345
- const hasExpandableContent =
346
- $('details, [class*="accordion"], [class*="collapsible"], [class*="expandable"]').length > 0;
347
-
348
- // Tabs
349
- const hasTabsOrAccordion =
350
- $('[role="tablist"], [class*="tabs"], [class*="tab-content"]').length > 0;
351
-
352
- // Chat widget
353
- const hasChatWidget =
354
- $('[class*="chat-widget"], [class*="live-chat"], [id*="chat"]').length > 0 ||
355
- /intercom|drift|crisp|zendesk|livechat|tidio/i.test(html);
356
-
357
- // Calculate score
358
- let score = 0;
359
- if (hasCalculator) score += 25;
360
- if (hasQuiz) score += 20;
361
- if (hasInteractiveElement) score += 15;
362
- if (hasEmbeddedVideo) score += 20;
363
- if (hasExpandableContent || hasTabsOrAccordion) score += 10;
364
- if (hasChatWidget) score += 10;
365
-
366
- return {
367
- hasCalculator,
368
- calculatorTypes,
369
- hasQuiz,
370
- hasInteractiveElement,
371
- interactiveTypes,
372
- hasEmbeddedVideo,
373
- videoCount,
374
- hasExpandableContent,
375
- hasTabsOrAccordion,
376
- hasChatWidget,
377
- engagementScore: Math.min(100, score),
378
- };
379
- }
380
-
381
- /**
382
- * Detect page type (commercial vs informational)
383
- */
384
- export function detectPageType(html: string, url: string): 'commercial' | 'informational' | 'mixed' | 'unknown' {
385
- const $ = cheerio.load(html);
386
- const text = $('body').text().toLowerCase();
387
- const urlLower = url.toLowerCase();
388
-
389
- let commercialSignals = 0;
390
- let informationalSignals = 0;
391
-
392
- // URL signals
393
- if (/\/product|\/service|\/pricing|\/buy|\/shop|\/contact/i.test(urlLower)) commercialSignals += 2;
394
- if (/\/blog|\/article|\/guide|\/how-to|\/what-is|\/learn/i.test(urlLower)) informationalSignals += 2;
395
-
396
- // Content signals
397
- if (/buy now|add to cart|get quote|contact us|free consultation/i.test(text)) commercialSignals += 2;
398
- if ($('form').length > 0) commercialSignals += 1;
399
- if (/pricing|price|\$\d+/i.test(text)) commercialSignals += 1;
400
-
401
- if (/table of contents|in this article|what you.ll learn/i.test(text)) informationalSignals += 2;
402
- if ($('article').length > 0) informationalSignals += 1;
403
- if (text.length > 3000) informationalSignals += 1; // Long content is usually informational
404
-
405
- if (commercialSignals > informationalSignals + 1) return 'commercial';
406
- if (informationalSignals > commercialSignals + 1) return 'informational';
407
- if (commercialSignals > 0 && informationalSignals > 0) return 'mixed';
408
- return 'unknown';
409
- }
410
-
411
- /**
412
- * Main function: Analyze conversion elements
413
- */
414
- export function analyzeConversionElements(
415
- html: string,
416
- url: string
417
- ): { issues: AuditIssue[]; data: ConversionElementsData } {
418
- const issues: AuditIssue[] = [];
419
-
420
- const aboveFold = analyzeAboveFold(html);
421
- const socialProof = analyzeSocialProof(html);
422
- const engagementTriggers = detectEngagementTriggers(html);
423
- const pageType = detectPageType(html, url);
424
-
425
- const recommendations: string[] = [];
426
-
427
- // Above-the-fold issues for commercial pages
428
- if (pageType === 'commercial' || pageType === 'mixed') {
429
- if (!aboveFold.hasCTA) {
430
- issues.push({
431
- code: 'COMMERCIAL_NO_CTA',
432
- severity: 'warning',
433
- category: 'content',
434
- title: 'Commercial page without clear CTA',
435
- description: 'This appears to be a commercial page but has no clear call-to-action.',
436
- impact: 'Without a CTA, visitors have no clear next step. 80% of users only see above-the-fold content.',
437
- howToFix: 'Add a prominent CTA button above the fold (e.g., "Get Free Quote", "Contact Us", "Start Free Trial").',
438
- affectedUrls: [url],
439
- details: { pageType },
440
- });
441
- recommendations.push('Add prominent CTA button above the fold');
442
- }
443
-
444
- if (!aboveFold.hasForm && pageType === 'commercial') {
445
- issues.push({
446
- code: 'COMMERCIAL_NO_FORM',
447
- severity: 'notice',
448
- category: 'content',
449
- title: 'Commercial page without lead capture form',
450
- description: 'This commercial page lacks a visible form for lead capture.',
451
- impact: 'Forms above the fold significantly increase conversion rates.',
452
- howToFix: 'Add a contact form, quote request, or signup form visible without scrolling.',
453
- affectedUrls: [url],
454
- });
455
- recommendations.push('Add lead capture form above the fold');
456
- }
457
-
458
- if (!socialProof.hasTestimonials && !socialProof.hasReviews) {
459
- issues.push({
460
- code: 'NO_SOCIAL_PROOF',
461
- severity: 'warning',
462
- category: 'content',
463
- title: 'No testimonials or reviews found',
464
- description: 'Page lacks testimonials, reviews, or other social proof.',
465
- impact: '97% of consumers look at reviews. Testimonials can increase conversions by 34%.',
466
- howToFix: 'Add customer testimonials, reviews, ratings, or case studies to build trust.',
467
- affectedUrls: [url],
468
- details: { socialProofScore: socialProof.socialProofScore },
469
- });
470
- recommendations.push('Add customer testimonials or reviews');
471
- }
472
-
473
- if (!socialProof.hasClientLogos && pageType === 'commercial') {
474
- recommendations.push('Add client/partner logos for credibility ("Trusted by...")');
475
- }
476
- }
477
-
478
- // Engagement triggers for any page type
479
- if (!engagementTriggers.hasEmbeddedVideo && !engagementTriggers.hasInteractiveElement) {
480
- issues.push({
481
- code: 'NO_ENGAGEMENT_TRIGGERS',
482
- severity: 'notice',
483
- category: 'content',
484
- title: 'No engagement triggers found',
485
- description: 'Page lacks interactive elements, videos, or calculators.',
486
- impact: 'Interactive content increases dwell time, a user signal that influences rankings.',
487
- howToFix: 'Add video content, calculators, interactive tools, or expandable sections.',
488
- affectedUrls: [url],
489
- details: { engagementScore: engagementTriggers.engagementScore },
490
- });
491
- recommendations.push('Add video or interactive elements to increase engagement');
492
- }
493
-
494
- // Calculator suggestion for service pages
495
- if (pageType === 'commercial' && !engagementTriggers.hasCalculator) {
496
- const isServicePage = /service|pricing|quote|cost|estimate/i.test(url + html);
497
- if (isServicePage) {
498
- recommendations.push('Consider adding a calculator or instant quote tool');
499
- }
500
- }
501
-
502
- // Headline check
503
- if (!aboveFold.hasHeadline) {
504
- issues.push({
505
- code: 'NO_VISIBLE_HEADLINE',
506
- severity: 'warning',
507
- category: 'on-page',
508
- title: 'No H1 headline visible',
509
- description: 'Page appears to lack a visible H1 headline above the fold.',
510
- impact: '80% of visitors only read headlines. A strong headline is critical for engagement.',
511
- howToFix: 'Add a clear, compelling H1 headline that communicates the page value proposition.',
512
- affectedUrls: [url],
513
- });
514
- }
515
-
516
- return {
517
- issues,
518
- data: {
519
- aboveFold,
520
- socialProof,
521
- engagementTriggers,
522
- pageType,
523
- recommendations,
524
- },
525
- };
526
- }