@rankcli/agent-runtime 0.0.15 → 0.0.17

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 (203) hide show
  1. package/README.md +5 -4
  2. package/dist/index.d.mts +44 -393
  3. package/dist/index.d.ts +44 -393
  4. package/dist/index.js +22098 -26131
  5. package/dist/index.mjs +11834 -15857
  6. package/package.json +10 -4
  7. package/scripts/build-deno.ts +0 -134
  8. package/src/analyzers/core-web-vitals-analyzer.test.ts +0 -236
  9. package/src/analyzers/core-web-vitals-analyzer.ts +0 -557
  10. package/src/analyzers/geo-analyzer.test.ts +0 -310
  11. package/src/analyzers/geo-analyzer.ts +0 -814
  12. package/src/analyzers/image-optimization-analyzer.test.ts +0 -145
  13. package/src/analyzers/image-optimization-analyzer.ts +0 -348
  14. package/src/analyzers/index.ts +0 -233
  15. package/src/analyzers/internal-linking-analyzer.test.ts +0 -141
  16. package/src/analyzers/internal-linking-analyzer.ts +0 -419
  17. package/src/analyzers/mobile-seo-analyzer.test.ts +0 -140
  18. package/src/analyzers/mobile-seo-analyzer.ts +0 -455
  19. package/src/analyzers/security-headers-analyzer.test.ts +0 -115
  20. package/src/analyzers/security-headers-analyzer.ts +0 -318
  21. package/src/analyzers/structured-data-analyzer.test.ts +0 -210
  22. package/src/analyzers/structured-data-analyzer.ts +0 -590
  23. package/src/audit/ai/analyzer.ts +0 -347
  24. package/src/audit/ai/index.ts +0 -29
  25. package/src/audit/ai/prompts/content-analysis.ts +0 -271
  26. package/src/audit/ai/types.ts +0 -179
  27. package/src/audit/checks/additional-checks.ts +0 -439
  28. package/src/audit/checks/agent-experience.ts +0 -108
  29. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  30. package/src/audit/checks/ai-content-structure.ts +0 -325
  31. package/src/audit/checks/ai-readiness.ts +0 -406
  32. package/src/audit/checks/anchor-text.ts +0 -179
  33. package/src/audit/checks/answer-conciseness.ts +0 -322
  34. package/src/audit/checks/asset-minification.ts +0 -270
  35. package/src/audit/checks/bing-optimization.ts +0 -206
  36. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  37. package/src/audit/checks/caching-headers.ts +0 -305
  38. package/src/audit/checks/canonical-advanced.ts +0 -150
  39. package/src/audit/checks/canonical-domain.ts +0 -196
  40. package/src/audit/checks/citation-quality.ts +0 -358
  41. package/src/audit/checks/client-rendering.ts +0 -542
  42. package/src/audit/checks/color-contrast.ts +0 -342
  43. package/src/audit/checks/content-freshness.ts +0 -170
  44. package/src/audit/checks/content-science.ts +0 -589
  45. package/src/audit/checks/conversion-elements.ts +0 -526
  46. package/src/audit/checks/crawlability.ts +0 -220
  47. package/src/audit/checks/directory-listing.ts +0 -172
  48. package/src/audit/checks/dom-analysis.ts +0 -191
  49. package/src/audit/checks/dom-size.ts +0 -246
  50. package/src/audit/checks/duplicate-content.ts +0 -194
  51. package/src/audit/checks/eeat-signals.ts +0 -990
  52. package/src/audit/checks/entity-seo.ts +0 -396
  53. package/src/audit/checks/featured-snippet.ts +0 -473
  54. package/src/audit/checks/freshness-signals.ts +0 -443
  55. package/src/audit/checks/funnel-intent.ts +0 -463
  56. package/src/audit/checks/hreflang.ts +0 -174
  57. package/src/audit/checks/html-compliance.ts +0 -302
  58. package/src/audit/checks/image-dimensions.ts +0 -167
  59. package/src/audit/checks/images.ts +0 -160
  60. package/src/audit/checks/indexnow.ts +0 -275
  61. package/src/audit/checks/interactive-tools.ts +0 -475
  62. package/src/audit/checks/internal-link-graph.ts +0 -436
  63. package/src/audit/checks/keyword-analysis.ts +0 -239
  64. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  65. package/src/audit/checks/keyword-placement.ts +0 -471
  66. package/src/audit/checks/links.ts +0 -273
  67. package/src/audit/checks/llms-txt.ts +0 -224
  68. package/src/audit/checks/local-seo.ts +0 -296
  69. package/src/audit/checks/mobile.ts +0 -167
  70. package/src/audit/checks/modern-images.ts +0 -226
  71. package/src/audit/checks/navboost-signals.ts +0 -395
  72. package/src/audit/checks/on-page.ts +0 -209
  73. package/src/audit/checks/page-resources.ts +0 -285
  74. package/src/audit/checks/pagination.ts +0 -180
  75. package/src/audit/checks/performance.ts +0 -153
  76. package/src/audit/checks/platform-presence.ts +0 -580
  77. package/src/audit/checks/rag-chunk-readiness.test.ts +0 -159
  78. package/src/audit/checks/rag-chunk-readiness.ts +0 -163
  79. package/src/audit/checks/redirect-analysis.ts +0 -153
  80. package/src/audit/checks/redirect-chain.ts +0 -389
  81. package/src/audit/checks/resource-hints.ts +0 -420
  82. package/src/audit/checks/responsive-css.ts +0 -247
  83. package/src/audit/checks/responsive-images.ts +0 -396
  84. package/src/audit/checks/review-ecosystem.ts +0 -415
  85. package/src/audit/checks/robots-validation.ts +0 -373
  86. package/src/audit/checks/security-headers.ts +0 -188
  87. package/src/audit/checks/security.ts +0 -144
  88. package/src/audit/checks/serp-preview.ts +0 -251
  89. package/src/audit/checks/site-maturity.ts +0 -453
  90. package/src/audit/checks/social-meta.test.ts +0 -275
  91. package/src/audit/checks/social-meta.ts +0 -134
  92. package/src/audit/checks/soft-404.ts +0 -151
  93. package/src/audit/checks/structured-data.ts +0 -238
  94. package/src/audit/checks/tech-detection.ts +0 -496
  95. package/src/audit/checks/topical-clusters.ts +0 -435
  96. package/src/audit/checks/tracker-bloat.ts +0 -462
  97. package/src/audit/checks/tracking-verification.test.ts +0 -371
  98. package/src/audit/checks/tracking-verification.ts +0 -636
  99. package/src/audit/checks/url-safety.ts +0 -682
  100. package/src/audit/deno-entry.ts +0 -66
  101. package/src/audit/discovery/index.ts +0 -15
  102. package/src/audit/discovery/link-crawler.ts +0 -233
  103. package/src/audit/discovery/repo-routes.ts +0 -347
  104. package/src/audit/engine.ts +0 -633
  105. package/src/audit/fixes/index.ts +0 -209
  106. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  107. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  108. package/src/audit/index.ts +0 -74
  109. package/src/audit/runner.test.ts +0 -299
  110. package/src/audit/runner.ts +0 -130
  111. package/src/audit/types.ts +0 -1987
  112. package/src/content/featured-snippet.ts +0 -367
  113. package/src/content/generator.test.ts +0 -534
  114. package/src/content/generator.ts +0 -501
  115. package/src/content/headline.ts +0 -317
  116. package/src/content/index.ts +0 -62
  117. package/src/content/intent.ts +0 -258
  118. package/src/content/keyword-density.ts +0 -349
  119. package/src/content/readability.ts +0 -262
  120. package/src/executor.ts +0 -336
  121. package/src/fixer/framework-fixes.test.ts +0 -489
  122. package/src/fixer/framework-fixes.ts +0 -5287
  123. package/src/fixer/index.ts +0 -6
  124. package/src/fixer/schemas.ts +0 -971
  125. package/src/fixer.ts +0 -642
  126. package/src/frameworks/detector.test.ts +0 -248
  127. package/src/frameworks/detector.ts +0 -899
  128. package/src/frameworks/index.ts +0 -68
  129. package/src/frameworks/recipes/angular.yaml +0 -171
  130. package/src/frameworks/recipes/astro.yaml +0 -206
  131. package/src/frameworks/recipes/django.yaml +0 -180
  132. package/src/frameworks/recipes/laravel.yaml +0 -137
  133. package/src/frameworks/recipes/nextjs.yaml +0 -268
  134. package/src/frameworks/recipes/nuxt.yaml +0 -175
  135. package/src/frameworks/recipes/rails.yaml +0 -188
  136. package/src/frameworks/recipes/react.yaml +0 -202
  137. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  138. package/src/frameworks/recipes/vue.yaml +0 -137
  139. package/src/frameworks/recipes/wordpress.yaml +0 -209
  140. package/src/frameworks/suggestion-engine.ts +0 -357
  141. package/src/geo/geo-content.test.ts +0 -305
  142. package/src/geo/geo-content.ts +0 -266
  143. package/src/geo/geo-history.test.ts +0 -473
  144. package/src/geo/geo-history.ts +0 -433
  145. package/src/geo/geo-tracker.test.ts +0 -359
  146. package/src/geo/geo-tracker.ts +0 -411
  147. package/src/geo/index.ts +0 -11
  148. package/src/geo/llm-citation-checker.ts +0 -188
  149. package/src/git/commit-helper.test.ts +0 -261
  150. package/src/git/commit-helper.ts +0 -329
  151. package/src/git/index.ts +0 -12
  152. package/src/git/pr-helper.test.ts +0 -284
  153. package/src/git/pr-helper.ts +0 -307
  154. package/src/index.ts +0 -76
  155. package/src/keywords/ai-keyword-engine.ts +0 -1062
  156. package/src/keywords/ai-summarizer.ts +0 -387
  157. package/src/keywords/ci-mode.ts +0 -555
  158. package/src/keywords/engine.ts +0 -359
  159. package/src/keywords/index.ts +0 -151
  160. package/src/keywords/llm-judge.ts +0 -357
  161. package/src/keywords/nlp-analysis.ts +0 -706
  162. package/src/keywords/prioritizer.ts +0 -295
  163. package/src/keywords/site-crawler.ts +0 -342
  164. package/src/keywords/sources/autocomplete.ts +0 -139
  165. package/src/keywords/sources/competitive-search.ts +0 -450
  166. package/src/keywords/sources/competitor-analysis.ts +0 -374
  167. package/src/keywords/sources/dataforseo.ts +0 -206
  168. package/src/keywords/sources/free-sources.ts +0 -294
  169. package/src/keywords/sources/gsc.ts +0 -123
  170. package/src/keywords/topic-grouping.ts +0 -327
  171. package/src/keywords/types.ts +0 -144
  172. package/src/keywords/wizard.ts +0 -457
  173. package/src/loader.ts +0 -40
  174. package/src/ranking/index.ts +0 -5
  175. package/src/ranking/serp-client.ts +0 -348
  176. package/src/ranking/tracker.ts +0 -380
  177. package/src/ranking/types.ts +0 -123
  178. package/src/reports/index.ts +0 -7
  179. package/src/reports/report-generator.test.ts +0 -293
  180. package/src/reports/report-generator.ts +0 -713
  181. package/src/scheduler/alerts.test.ts +0 -458
  182. package/src/scheduler/alerts.ts +0 -328
  183. package/src/scheduler/index.ts +0 -8
  184. package/src/scheduler/scheduled-audit.test.ts +0 -377
  185. package/src/scheduler/scheduled-audit.ts +0 -149
  186. package/src/test/integration-test.ts +0 -325
  187. package/src/tools/analyzer.ts +0 -373
  188. package/src/tools/crawl.ts +0 -293
  189. package/src/tools/files.ts +0 -301
  190. package/src/tools/h1-fixer.ts +0 -249
  191. package/src/tools/index.ts +0 -67
  192. package/src/tracking/github-action.ts +0 -326
  193. package/src/tracking/google-analytics.ts +0 -265
  194. package/src/tracking/index.ts +0 -45
  195. package/src/tracking/report-generator.ts +0 -386
  196. package/src/tracking/search-console.ts +0 -335
  197. package/src/types.ts +0 -148
  198. package/src/utils/http.ts +0 -302
  199. package/src/wasm-adapter.ts +0 -297
  200. package/src/wasm-entry.ts +0 -14
  201. package/tsconfig.json +0 -17
  202. package/tsup.wasm.config.ts +0 -26
  203. 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
- }