@rankcli/agent-runtime 0.0.1

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 (178) hide show
  1. package/README.md +242 -0
  2. package/dist/analyzer-2CSWIQGD.mjs +6 -0
  3. package/dist/chunk-YNZYHEYM.mjs +774 -0
  4. package/dist/index.d.mts +4012 -0
  5. package/dist/index.d.ts +4012 -0
  6. package/dist/index.js +29672 -0
  7. package/dist/index.mjs +28602 -0
  8. package/package.json +53 -0
  9. package/scripts/build-deno.ts +134 -0
  10. package/src/audit/ai/analyzer.ts +347 -0
  11. package/src/audit/ai/index.ts +29 -0
  12. package/src/audit/ai/prompts/content-analysis.ts +271 -0
  13. package/src/audit/ai/types.ts +179 -0
  14. package/src/audit/checks/additional-checks.ts +439 -0
  15. package/src/audit/checks/ai-citation-worthiness.ts +399 -0
  16. package/src/audit/checks/ai-content-structure.ts +325 -0
  17. package/src/audit/checks/ai-readiness.ts +339 -0
  18. package/src/audit/checks/anchor-text.ts +179 -0
  19. package/src/audit/checks/answer-conciseness.ts +322 -0
  20. package/src/audit/checks/asset-minification.ts +270 -0
  21. package/src/audit/checks/bing-optimization.ts +206 -0
  22. package/src/audit/checks/brand-mention-optimization.ts +349 -0
  23. package/src/audit/checks/caching-headers.ts +305 -0
  24. package/src/audit/checks/canonical-advanced.ts +150 -0
  25. package/src/audit/checks/canonical-domain.ts +196 -0
  26. package/src/audit/checks/citation-quality.ts +358 -0
  27. package/src/audit/checks/client-rendering.ts +542 -0
  28. package/src/audit/checks/color-contrast.ts +342 -0
  29. package/src/audit/checks/content-freshness.ts +170 -0
  30. package/src/audit/checks/content-science.ts +589 -0
  31. package/src/audit/checks/conversion-elements.ts +526 -0
  32. package/src/audit/checks/crawlability.ts +220 -0
  33. package/src/audit/checks/directory-listing.ts +172 -0
  34. package/src/audit/checks/dom-analysis.ts +191 -0
  35. package/src/audit/checks/dom-size.ts +246 -0
  36. package/src/audit/checks/duplicate-content.ts +194 -0
  37. package/src/audit/checks/eeat-signals.ts +990 -0
  38. package/src/audit/checks/entity-seo.ts +396 -0
  39. package/src/audit/checks/featured-snippet.ts +473 -0
  40. package/src/audit/checks/freshness-signals.ts +443 -0
  41. package/src/audit/checks/funnel-intent.ts +463 -0
  42. package/src/audit/checks/hreflang.ts +174 -0
  43. package/src/audit/checks/html-compliance.ts +302 -0
  44. package/src/audit/checks/image-dimensions.ts +167 -0
  45. package/src/audit/checks/images.ts +160 -0
  46. package/src/audit/checks/indexnow.ts +275 -0
  47. package/src/audit/checks/interactive-tools.ts +475 -0
  48. package/src/audit/checks/internal-link-graph.ts +436 -0
  49. package/src/audit/checks/keyword-analysis.ts +239 -0
  50. package/src/audit/checks/keyword-cannibalization.ts +385 -0
  51. package/src/audit/checks/keyword-placement.ts +471 -0
  52. package/src/audit/checks/links.ts +203 -0
  53. package/src/audit/checks/llms-txt.ts +224 -0
  54. package/src/audit/checks/local-seo.ts +296 -0
  55. package/src/audit/checks/mobile.ts +167 -0
  56. package/src/audit/checks/modern-images.ts +226 -0
  57. package/src/audit/checks/navboost-signals.ts +395 -0
  58. package/src/audit/checks/on-page.ts +209 -0
  59. package/src/audit/checks/page-resources.ts +285 -0
  60. package/src/audit/checks/pagination.ts +180 -0
  61. package/src/audit/checks/performance.ts +153 -0
  62. package/src/audit/checks/platform-presence.ts +580 -0
  63. package/src/audit/checks/redirect-analysis.ts +153 -0
  64. package/src/audit/checks/redirect-chain.ts +389 -0
  65. package/src/audit/checks/resource-hints.ts +420 -0
  66. package/src/audit/checks/responsive-css.ts +247 -0
  67. package/src/audit/checks/responsive-images.ts +396 -0
  68. package/src/audit/checks/review-ecosystem.ts +415 -0
  69. package/src/audit/checks/robots-validation.ts +373 -0
  70. package/src/audit/checks/security-headers.ts +172 -0
  71. package/src/audit/checks/security.ts +144 -0
  72. package/src/audit/checks/serp-preview.ts +251 -0
  73. package/src/audit/checks/site-maturity.ts +444 -0
  74. package/src/audit/checks/social-meta.test.ts +275 -0
  75. package/src/audit/checks/social-meta.ts +134 -0
  76. package/src/audit/checks/soft-404.ts +151 -0
  77. package/src/audit/checks/structured-data.ts +238 -0
  78. package/src/audit/checks/tech-detection.ts +496 -0
  79. package/src/audit/checks/topical-clusters.ts +435 -0
  80. package/src/audit/checks/tracker-bloat.ts +462 -0
  81. package/src/audit/checks/tracking-verification.test.ts +371 -0
  82. package/src/audit/checks/tracking-verification.ts +636 -0
  83. package/src/audit/checks/url-safety.ts +682 -0
  84. package/src/audit/deno-entry.ts +66 -0
  85. package/src/audit/discovery/index.ts +15 -0
  86. package/src/audit/discovery/link-crawler.ts +232 -0
  87. package/src/audit/discovery/repo-routes.ts +347 -0
  88. package/src/audit/engine.ts +620 -0
  89. package/src/audit/fixes/index.ts +209 -0
  90. package/src/audit/fixes/social-meta-fixes.test.ts +329 -0
  91. package/src/audit/fixes/social-meta-fixes.ts +463 -0
  92. package/src/audit/index.ts +74 -0
  93. package/src/audit/runner.test.ts +299 -0
  94. package/src/audit/runner.ts +130 -0
  95. package/src/audit/types.ts +1953 -0
  96. package/src/content/featured-snippet.ts +367 -0
  97. package/src/content/generator.test.ts +534 -0
  98. package/src/content/generator.ts +501 -0
  99. package/src/content/headline.ts +317 -0
  100. package/src/content/index.ts +62 -0
  101. package/src/content/intent.ts +258 -0
  102. package/src/content/keyword-density.ts +349 -0
  103. package/src/content/readability.ts +262 -0
  104. package/src/executor.ts +336 -0
  105. package/src/fixer.ts +416 -0
  106. package/src/frameworks/detector.test.ts +248 -0
  107. package/src/frameworks/detector.ts +371 -0
  108. package/src/frameworks/index.ts +68 -0
  109. package/src/frameworks/recipes/angular.yaml +171 -0
  110. package/src/frameworks/recipes/astro.yaml +206 -0
  111. package/src/frameworks/recipes/django.yaml +180 -0
  112. package/src/frameworks/recipes/laravel.yaml +137 -0
  113. package/src/frameworks/recipes/nextjs.yaml +268 -0
  114. package/src/frameworks/recipes/nuxt.yaml +175 -0
  115. package/src/frameworks/recipes/rails.yaml +188 -0
  116. package/src/frameworks/recipes/react.yaml +202 -0
  117. package/src/frameworks/recipes/sveltekit.yaml +154 -0
  118. package/src/frameworks/recipes/vue.yaml +137 -0
  119. package/src/frameworks/recipes/wordpress.yaml +209 -0
  120. package/src/frameworks/suggestion-engine.ts +320 -0
  121. package/src/geo/geo-content.test.ts +305 -0
  122. package/src/geo/geo-content.ts +266 -0
  123. package/src/geo/geo-history.test.ts +473 -0
  124. package/src/geo/geo-history.ts +433 -0
  125. package/src/geo/geo-tracker.test.ts +359 -0
  126. package/src/geo/geo-tracker.ts +411 -0
  127. package/src/geo/index.ts +10 -0
  128. package/src/git/commit-helper.test.ts +261 -0
  129. package/src/git/commit-helper.ts +329 -0
  130. package/src/git/index.ts +12 -0
  131. package/src/git/pr-helper.test.ts +284 -0
  132. package/src/git/pr-helper.ts +307 -0
  133. package/src/index.ts +66 -0
  134. package/src/keywords/ai-keyword-engine.ts +1062 -0
  135. package/src/keywords/ai-summarizer.ts +387 -0
  136. package/src/keywords/ci-mode.ts +555 -0
  137. package/src/keywords/engine.ts +359 -0
  138. package/src/keywords/index.ts +151 -0
  139. package/src/keywords/llm-judge.ts +357 -0
  140. package/src/keywords/nlp-analysis.ts +706 -0
  141. package/src/keywords/prioritizer.ts +295 -0
  142. package/src/keywords/site-crawler.ts +342 -0
  143. package/src/keywords/sources/autocomplete.ts +139 -0
  144. package/src/keywords/sources/competitive-search.ts +450 -0
  145. package/src/keywords/sources/competitor-analysis.ts +374 -0
  146. package/src/keywords/sources/dataforseo.ts +206 -0
  147. package/src/keywords/sources/free-sources.ts +294 -0
  148. package/src/keywords/sources/gsc.ts +123 -0
  149. package/src/keywords/topic-grouping.ts +327 -0
  150. package/src/keywords/types.ts +144 -0
  151. package/src/keywords/wizard.ts +457 -0
  152. package/src/loader.ts +40 -0
  153. package/src/reports/index.ts +7 -0
  154. package/src/reports/report-generator.test.ts +293 -0
  155. package/src/reports/report-generator.ts +713 -0
  156. package/src/scheduler/alerts.test.ts +458 -0
  157. package/src/scheduler/alerts.ts +328 -0
  158. package/src/scheduler/index.ts +8 -0
  159. package/src/scheduler/scheduled-audit.test.ts +377 -0
  160. package/src/scheduler/scheduled-audit.ts +149 -0
  161. package/src/test/integration-test.ts +325 -0
  162. package/src/tools/analyzer.ts +373 -0
  163. package/src/tools/crawl.ts +293 -0
  164. package/src/tools/files.ts +301 -0
  165. package/src/tools/h1-fixer.ts +249 -0
  166. package/src/tools/index.ts +67 -0
  167. package/src/tracking/github-action.ts +326 -0
  168. package/src/tracking/google-analytics.ts +265 -0
  169. package/src/tracking/index.ts +45 -0
  170. package/src/tracking/report-generator.ts +386 -0
  171. package/src/tracking/search-console.ts +335 -0
  172. package/src/types.ts +134 -0
  173. package/src/utils/http.ts +302 -0
  174. package/src/wasm-adapter.ts +297 -0
  175. package/src/wasm-entry.ts +14 -0
  176. package/tsconfig.json +17 -0
  177. package/tsup.wasm.config.ts +26 -0
  178. package/vitest.config.ts +15 -0
@@ -0,0 +1,415 @@
1
+ /**
2
+ * Review Ecosystem Checks
3
+ *
4
+ * AI systems use review signals from multiple platforms to assess brand trust.
5
+ * This check analyzes integration with review platforms and testimonial presence.
6
+ *
7
+ * Key insight: "If you want visibility across AI platforms, you need review
8
+ * diversity. That means building reviews on the platforms that matter in
9
+ * your specific niche."
10
+ */
11
+
12
+ import * as cheerio from 'cheerio';
13
+ import type { AuditIssue } from '../types.js';
14
+
15
+ export interface ReviewEcosystemData {
16
+ reviewPlatforms: {
17
+ linked: string[];
18
+ embedded: string[];
19
+ sameAsLinks: string[];
20
+ };
21
+ testimonials: {
22
+ count: number;
23
+ hasAttribution: boolean;
24
+ hasPhotos: boolean;
25
+ hasCompanyNames: boolean;
26
+ };
27
+ reviewSchema: {
28
+ hasAggregateRating: boolean;
29
+ hasReviewSchema: boolean;
30
+ ratingValue?: number;
31
+ reviewCount?: number;
32
+ };
33
+ trustSignals: {
34
+ hasTrustBadges: boolean;
35
+ hasCertifications: boolean;
36
+ hasAwards: boolean;
37
+ hasMediaMentions: boolean;
38
+ };
39
+ reviewEcosystemScore: number;
40
+ }
41
+
42
+ // Review platforms by category
43
+ const REVIEW_PLATFORMS = {
44
+ general: [
45
+ { name: 'Google Business', domain: 'google.com/maps', aliases: ['goo.gl/maps', 'maps.google'] },
46
+ { name: 'Trustpilot', domain: 'trustpilot.com', aliases: [] },
47
+ { name: 'BBB', domain: 'bbb.org', aliases: [] },
48
+ { name: 'Yelp', domain: 'yelp.com', aliases: [] },
49
+ ],
50
+ saas: [
51
+ { name: 'G2', domain: 'g2.com', aliases: ['g2crowd.com'] },
52
+ { name: 'Capterra', domain: 'capterra.com', aliases: [] },
53
+ { name: 'TrustRadius', domain: 'trustradius.com', aliases: [] },
54
+ { name: 'GetApp', domain: 'getapp.com', aliases: [] },
55
+ { name: 'Software Advice', domain: 'softwareadvice.com', aliases: [] },
56
+ { name: 'Product Hunt', domain: 'producthunt.com', aliases: [] },
57
+ ],
58
+ professional: [
59
+ { name: 'Clutch', domain: 'clutch.co', aliases: [] },
60
+ { name: 'UpCity', domain: 'upcity.com', aliases: [] },
61
+ { name: 'GoodFirms', domain: 'goodfirms.co', aliases: [] },
62
+ { name: 'Expertise', domain: 'expertise.com', aliases: [] },
63
+ ],
64
+ local: [
65
+ { name: 'Angi', domain: 'angi.com', aliases: ['angieslist.com'] },
66
+ { name: 'HomeAdvisor', domain: 'homeadvisor.com', aliases: [] },
67
+ { name: 'Thumbtack', domain: 'thumbtack.com', aliases: [] },
68
+ { name: 'Houzz', domain: 'houzz.com', aliases: [] },
69
+ ],
70
+ healthcare: [
71
+ { name: 'Healthgrades', domain: 'healthgrades.com', aliases: [] },
72
+ { name: 'Zocdoc', domain: 'zocdoc.com', aliases: [] },
73
+ { name: 'Vitals', domain: 'vitals.com', aliases: [] },
74
+ { name: 'WebMD', domain: 'webmd.com', aliases: [] },
75
+ ],
76
+ legal: [
77
+ { name: 'Avvo', domain: 'avvo.com', aliases: [] },
78
+ { name: 'Martindale', domain: 'martindale.com', aliases: [] },
79
+ { name: 'FindLaw', domain: 'findlaw.com', aliases: [] },
80
+ { name: 'Justia', domain: 'justia.com', aliases: [] },
81
+ ],
82
+ hospitality: [
83
+ { name: 'TripAdvisor', domain: 'tripadvisor.com', aliases: [] },
84
+ { name: 'Booking.com', domain: 'booking.com', aliases: [] },
85
+ { name: 'OpenTable', domain: 'opentable.com', aliases: [] },
86
+ { name: 'Zomato', domain: 'zomato.com', aliases: [] },
87
+ ],
88
+ ecommerce: [
89
+ { name: 'Amazon', domain: 'amazon.com', aliases: [] },
90
+ { name: 'Shopify Reviews', domain: 'apps.shopify.com', aliases: [] },
91
+ { name: 'Yotpo', domain: 'yotpo.com', aliases: [] },
92
+ { name: 'Judge.me', domain: 'judge.me', aliases: [] },
93
+ ],
94
+ };
95
+
96
+ // Trust badge patterns
97
+ const TRUST_BADGE_PATTERNS = [
98
+ /ssl|secure|verified|certified|accredited|licensed/i,
99
+ /money.back|guarantee|satisfaction/i,
100
+ /bbb|iso|soc\s*2|hipaa|gdpr|pci/i,
101
+ ];
102
+
103
+ export function analyzeReviewEcosystem(
104
+ html: string,
105
+ url: string
106
+ ): { issues: AuditIssue[]; data: ReviewEcosystemData } {
107
+ const issues: AuditIssue[] = [];
108
+ const $ = cheerio.load(html);
109
+
110
+ const allLinks = $('a[href]').map((_, a) => $(a).attr('href') || '').get();
111
+ const allLinksLower = allLinks.map(l => l.toLowerCase());
112
+
113
+ // Find linked review platforms
114
+ const linkedPlatforms: string[] = [];
115
+ const allPlatforms = Object.values(REVIEW_PLATFORMS).flat();
116
+
117
+ for (const platform of allPlatforms) {
118
+ const isLinked = allLinksLower.some(href =>
119
+ href.includes(platform.domain) ||
120
+ platform.aliases.some(alias => href.includes(alias))
121
+ );
122
+ if (isLinked) {
123
+ linkedPlatforms.push(platform.name);
124
+ }
125
+ }
126
+
127
+ // Find embedded review widgets
128
+ const embeddedPlatforms: string[] = [];
129
+ const embedPatterns = [
130
+ { name: 'Trustpilot', pattern: /trustpilot/i },
131
+ { name: 'G2', pattern: /g2\.com|g2crowd/i },
132
+ { name: 'Yotpo', pattern: /yotpo/i },
133
+ { name: 'Judge.me', pattern: /judgeme|judge\.me/i },
134
+ { name: 'Google Reviews', pattern: /google.*review|elfsight/i },
135
+ ];
136
+
137
+ const htmlLower = html.toLowerCase();
138
+ for (const { name, pattern } of embedPatterns) {
139
+ if (pattern.test(htmlLower) && !linkedPlatforms.includes(name)) {
140
+ embeddedPlatforms.push(name);
141
+ }
142
+ }
143
+
144
+ // Find sameAs links in structured data
145
+ const sameAsLinks: string[] = [];
146
+ const scripts = $('script[type="application/ld+json"]');
147
+ scripts.each((_, script) => {
148
+ try {
149
+ const json = JSON.parse($(script).html() || '{}');
150
+ const sameAs = json.sameAs || (json['@graph'] && json['@graph'][0]?.sameAs);
151
+ if (Array.isArray(sameAs)) {
152
+ for (const link of sameAs) {
153
+ if (typeof link === 'string') {
154
+ for (const platform of allPlatforms) {
155
+ if (link.toLowerCase().includes(platform.domain)) {
156
+ sameAsLinks.push(platform.name);
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ } catch {
163
+ // Invalid JSON
164
+ }
165
+ });
166
+
167
+ // Analyze testimonials
168
+ const testimonialSelectors = [
169
+ '[class*="testimonial"]',
170
+ '[class*="review"]',
171
+ '[class*="quote"]',
172
+ '[id*="testimonial"]',
173
+ 'blockquote',
174
+ ];
175
+
176
+ let testimonialCount = 0;
177
+ let hasAttribution = false;
178
+ let hasPhotos = false;
179
+ let hasCompanyNames = false;
180
+
181
+ for (const selector of testimonialSelectors) {
182
+ const elements = $(selector);
183
+ elements.each((_, el) => {
184
+ const text = $(el).text();
185
+ if (text.length > 50 && text.length < 1000) {
186
+ testimonialCount++;
187
+
188
+ // Check for attribution (name)
189
+ if (/[-–—]\s*[A-Z][a-z]+\s+[A-Z]/.test(text) ||
190
+ $(el).find('[class*="name"], [class*="author"]').length > 0) {
191
+ hasAttribution = true;
192
+ }
193
+
194
+ // Check for photos
195
+ if ($(el).find('img').length > 0 ||
196
+ $(el).siblings('img').length > 0) {
197
+ hasPhotos = true;
198
+ }
199
+
200
+ // Check for company names
201
+ if (/(?:CEO|CTO|founder|director|manager)\s+(?:at|of)\s+[A-Z]/i.test(text) ||
202
+ $(el).find('[class*="company"], [class*="title"]').length > 0) {
203
+ hasCompanyNames = true;
204
+ }
205
+ }
206
+ });
207
+ }
208
+
209
+ // Check for review schema
210
+ let hasAggregateRating = false;
211
+ let hasReviewSchema = false;
212
+ let ratingValue: number | undefined;
213
+ let reviewCount: number | undefined;
214
+
215
+ scripts.each((_, script) => {
216
+ try {
217
+ const json = JSON.parse($(script).html() || '{}');
218
+ const checkSchema = (obj: Record<string, unknown>) => {
219
+ if (obj['@type'] === 'AggregateRating' || obj.aggregateRating) {
220
+ hasAggregateRating = true;
221
+ const rating = obj.aggregateRating || obj;
222
+ if (typeof rating === 'object' && rating !== null) {
223
+ const r = rating as Record<string, unknown>;
224
+ ratingValue = parseFloat(String(r.ratingValue)) || undefined;
225
+ reviewCount = parseInt(String(r.reviewCount || r.ratingCount)) || undefined;
226
+ }
227
+ }
228
+ if (obj['@type'] === 'Review' || Array.isArray(obj.review)) {
229
+ hasReviewSchema = true;
230
+ }
231
+ };
232
+
233
+ checkSchema(json);
234
+ if (json['@graph'] && Array.isArray(json['@graph'])) {
235
+ for (const item of json['@graph']) {
236
+ checkSchema(item);
237
+ }
238
+ }
239
+ } catch {
240
+ // Invalid JSON
241
+ }
242
+ });
243
+
244
+ // Check for trust signals
245
+ const bodyText = $('body').text();
246
+ const imgAlts = $('img').map((_, img) => $(img).attr('alt') || '').get().join(' ');
247
+ const allText = bodyText + ' ' + imgAlts;
248
+
249
+ const hasTrustBadges = TRUST_BADGE_PATTERNS.some(p => p.test(allText)) ||
250
+ $('[class*="trust"], [class*="badge"], [class*="seal"]').length > 0;
251
+
252
+ const hasCertifications =
253
+ /(?:certified|certification|accredited|compliance)/i.test(allText) ||
254
+ $('[class*="certification"], [class*="accredit"]').length > 0;
255
+
256
+ const hasAwards =
257
+ /(?:award|winner|recognized|featured in|as seen)/i.test(allText) ||
258
+ $('[class*="award"], [class*="recognition"], [class*="featured"]').length > 0;
259
+
260
+ const hasMediaMentions =
261
+ /(?:featured in|as seen in|mentioned in|press|media)/i.test(allText) ||
262
+ $('[class*="press"], [class*="media"], [class*="featured"]').length > 0;
263
+
264
+ // Calculate score
265
+ let reviewEcosystemScore = 20; // Base score
266
+
267
+ // Review platform integration (up to 30 points)
268
+ if (linkedPlatforms.length >= 3) reviewEcosystemScore += 15;
269
+ else if (linkedPlatforms.length >= 1) reviewEcosystemScore += 10;
270
+
271
+ if (embeddedPlatforms.length > 0) reviewEcosystemScore += 10;
272
+ if (sameAsLinks.length > 0) reviewEcosystemScore += 5;
273
+
274
+ // Testimonials (up to 25 points)
275
+ if (testimonialCount >= 5) reviewEcosystemScore += 10;
276
+ else if (testimonialCount >= 2) reviewEcosystemScore += 5;
277
+
278
+ if (hasAttribution) reviewEcosystemScore += 5;
279
+ if (hasPhotos) reviewEcosystemScore += 5;
280
+ if (hasCompanyNames) reviewEcosystemScore += 5;
281
+
282
+ // Review schema (up to 15 points)
283
+ if (hasAggregateRating) reviewEcosystemScore += 10;
284
+ if (hasReviewSchema) reviewEcosystemScore += 5;
285
+
286
+ // Trust signals (up to 10 points)
287
+ if (hasTrustBadges) reviewEcosystemScore += 3;
288
+ if (hasCertifications) reviewEcosystemScore += 3;
289
+ if (hasAwards) reviewEcosystemScore += 2;
290
+ if (hasMediaMentions) reviewEcosystemScore += 2;
291
+
292
+ reviewEcosystemScore = Math.min(100, Math.max(0, reviewEcosystemScore));
293
+
294
+ // Generate issues
295
+
296
+ // No review platform links
297
+ if (linkedPlatforms.length === 0 && embeddedPlatforms.length === 0) {
298
+ issues.push({
299
+ code: 'AI_NO_REVIEW_PLATFORMS',
300
+ severity: 'warning',
301
+ category: 'ai-readiness',
302
+ title: 'No review platform integration',
303
+ description: 'No links or embeds from review platforms detected. AI uses review signals from multiple platforms to assess brand trust.',
304
+ impact: 'Missing review diversity signals that AI uses when recommending brands.',
305
+ howToFix: 'Link to your profiles on 2-3 relevant review platforms. Consider embedding review widgets for social proof.',
306
+ affectedUrls: [url],
307
+ details: {
308
+ suggestedPlatforms: {
309
+ 'All businesses': ['Google Business', 'Trustpilot', 'BBB'],
310
+ 'SaaS/Software': ['G2', 'Capterra', 'Product Hunt'],
311
+ 'Professional services': ['Clutch', 'UpCity'],
312
+ 'Local services': ['Angi', 'HomeAdvisor', 'Yelp'],
313
+ },
314
+ },
315
+ });
316
+ }
317
+
318
+ // No testimonials
319
+ if (testimonialCount === 0) {
320
+ issues.push({
321
+ code: 'AI_NO_TESTIMONIALS',
322
+ severity: 'notice',
323
+ category: 'ai-readiness',
324
+ title: 'No testimonials or reviews on page',
325
+ description: 'No customer testimonials found on the page. AI looks for social proof when evaluating brand trustworthiness.',
326
+ impact: 'Missing on-page social proof that strengthens brand authority.',
327
+ howToFix: 'Add customer testimonials with: name attribution, company/title, and optionally photos. Use blockquote elements for semantic markup.',
328
+ affectedUrls: [url],
329
+ });
330
+ }
331
+
332
+ // Testimonials without attribution
333
+ if (testimonialCount > 0 && !hasAttribution) {
334
+ issues.push({
335
+ code: 'AI_UNATTRIBUTED_TESTIMONIALS',
336
+ severity: 'notice',
337
+ category: 'ai-readiness',
338
+ title: 'Testimonials lack proper attribution',
339
+ description: 'Testimonials found but missing name attribution. Anonymous testimonials have less trust weight.',
340
+ impact: 'Unattributed reviews are less credible for AI trust assessment.',
341
+ howToFix: 'Add author names to testimonials: "Great service! - John Smith, CEO at Acme Corp"',
342
+ affectedUrls: [url],
343
+ details: {
344
+ testimonialCount,
345
+ hasAttribution,
346
+ hasPhotos,
347
+ hasCompanyNames,
348
+ },
349
+ });
350
+ }
351
+
352
+ // No review schema
353
+ if (!hasAggregateRating && testimonialCount > 0) {
354
+ issues.push({
355
+ code: 'AI_NO_REVIEW_SCHEMA',
356
+ severity: 'notice',
357
+ category: 'ai-readiness',
358
+ title: 'Missing review/rating schema markup',
359
+ description: 'Page has testimonials but no AggregateRating or Review schema. Structured data helps AI understand review context.',
360
+ impact: 'Missing rich snippet opportunity and AI-readable review data.',
361
+ howToFix: 'Add AggregateRating schema with ratingValue, ratingCount, and bestRating. This enables star ratings in search results.',
362
+ affectedUrls: [url],
363
+ });
364
+ }
365
+
366
+ // Low review ecosystem score
367
+ if (reviewEcosystemScore < 40) {
368
+ issues.push({
369
+ code: 'AI_WEAK_REVIEW_ECOSYSTEM',
370
+ severity: 'warning',
371
+ category: 'ai-readiness',
372
+ title: 'Weak review ecosystem integration',
373
+ description: `Review ecosystem score: ${reviewEcosystemScore}/100. AI uses review diversity across platforms to assess brand trust.`,
374
+ impact: 'Low review presence may result in AI recommending better-reviewed competitors.',
375
+ howToFix: 'Build review diversity: 1) Link to review platforms, 2) Add testimonials with attribution, 3) Implement review schema, 4) Display trust badges.',
376
+ affectedUrls: [url],
377
+ details: {
378
+ reviewEcosystemScore,
379
+ linkedPlatforms,
380
+ testimonialCount,
381
+ hasAggregateRating,
382
+ },
383
+ });
384
+ }
385
+
386
+ return {
387
+ issues,
388
+ data: {
389
+ reviewPlatforms: {
390
+ linked: linkedPlatforms,
391
+ embedded: embeddedPlatforms,
392
+ sameAsLinks: [...new Set(sameAsLinks)],
393
+ },
394
+ testimonials: {
395
+ count: testimonialCount,
396
+ hasAttribution,
397
+ hasPhotos,
398
+ hasCompanyNames,
399
+ },
400
+ reviewSchema: {
401
+ hasAggregateRating,
402
+ hasReviewSchema,
403
+ ratingValue,
404
+ reviewCount,
405
+ },
406
+ trustSignals: {
407
+ hasTrustBadges,
408
+ hasCertifications,
409
+ hasAwards,
410
+ hasMediaMentions,
411
+ },
412
+ reviewEcosystemScore,
413
+ },
414
+ };
415
+ }