@rankcli/agent-runtime 0.0.15 → 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 (202) hide show
  1. package/dist/index.d.mts +43 -393
  2. package/dist/index.d.ts +43 -393
  3. package/dist/index.js +306 -6526
  4. package/dist/index.mjs +202 -6412
  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/agent-experience.ts +0 -108
  28. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  29. package/src/audit/checks/ai-content-structure.ts +0 -325
  30. package/src/audit/checks/ai-readiness.ts +0 -406
  31. package/src/audit/checks/anchor-text.ts +0 -179
  32. package/src/audit/checks/answer-conciseness.ts +0 -322
  33. package/src/audit/checks/asset-minification.ts +0 -270
  34. package/src/audit/checks/bing-optimization.ts +0 -206
  35. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  36. package/src/audit/checks/caching-headers.ts +0 -305
  37. package/src/audit/checks/canonical-advanced.ts +0 -150
  38. package/src/audit/checks/canonical-domain.ts +0 -196
  39. package/src/audit/checks/citation-quality.ts +0 -358
  40. package/src/audit/checks/client-rendering.ts +0 -542
  41. package/src/audit/checks/color-contrast.ts +0 -342
  42. package/src/audit/checks/content-freshness.ts +0 -170
  43. package/src/audit/checks/content-science.ts +0 -589
  44. package/src/audit/checks/conversion-elements.ts +0 -526
  45. package/src/audit/checks/crawlability.ts +0 -220
  46. package/src/audit/checks/directory-listing.ts +0 -172
  47. package/src/audit/checks/dom-analysis.ts +0 -191
  48. package/src/audit/checks/dom-size.ts +0 -246
  49. package/src/audit/checks/duplicate-content.ts +0 -194
  50. package/src/audit/checks/eeat-signals.ts +0 -990
  51. package/src/audit/checks/entity-seo.ts +0 -396
  52. package/src/audit/checks/featured-snippet.ts +0 -473
  53. package/src/audit/checks/freshness-signals.ts +0 -443
  54. package/src/audit/checks/funnel-intent.ts +0 -463
  55. package/src/audit/checks/hreflang.ts +0 -174
  56. package/src/audit/checks/html-compliance.ts +0 -302
  57. package/src/audit/checks/image-dimensions.ts +0 -167
  58. package/src/audit/checks/images.ts +0 -160
  59. package/src/audit/checks/indexnow.ts +0 -275
  60. package/src/audit/checks/interactive-tools.ts +0 -475
  61. package/src/audit/checks/internal-link-graph.ts +0 -436
  62. package/src/audit/checks/keyword-analysis.ts +0 -239
  63. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  64. package/src/audit/checks/keyword-placement.ts +0 -471
  65. package/src/audit/checks/links.ts +0 -273
  66. package/src/audit/checks/llms-txt.ts +0 -224
  67. package/src/audit/checks/local-seo.ts +0 -296
  68. package/src/audit/checks/mobile.ts +0 -167
  69. package/src/audit/checks/modern-images.ts +0 -226
  70. package/src/audit/checks/navboost-signals.ts +0 -395
  71. package/src/audit/checks/on-page.ts +0 -209
  72. package/src/audit/checks/page-resources.ts +0 -285
  73. package/src/audit/checks/pagination.ts +0 -180
  74. package/src/audit/checks/performance.ts +0 -153
  75. package/src/audit/checks/platform-presence.ts +0 -580
  76. package/src/audit/checks/rag-chunk-readiness.test.ts +0 -159
  77. package/src/audit/checks/rag-chunk-readiness.ts +0 -163
  78. package/src/audit/checks/redirect-analysis.ts +0 -153
  79. package/src/audit/checks/redirect-chain.ts +0 -389
  80. package/src/audit/checks/resource-hints.ts +0 -420
  81. package/src/audit/checks/responsive-css.ts +0 -247
  82. package/src/audit/checks/responsive-images.ts +0 -396
  83. package/src/audit/checks/review-ecosystem.ts +0 -415
  84. package/src/audit/checks/robots-validation.ts +0 -373
  85. package/src/audit/checks/security-headers.ts +0 -188
  86. package/src/audit/checks/security.ts +0 -144
  87. package/src/audit/checks/serp-preview.ts +0 -251
  88. package/src/audit/checks/site-maturity.ts +0 -453
  89. package/src/audit/checks/social-meta.test.ts +0 -275
  90. package/src/audit/checks/social-meta.ts +0 -134
  91. package/src/audit/checks/soft-404.ts +0 -151
  92. package/src/audit/checks/structured-data.ts +0 -238
  93. package/src/audit/checks/tech-detection.ts +0 -496
  94. package/src/audit/checks/topical-clusters.ts +0 -435
  95. package/src/audit/checks/tracker-bloat.ts +0 -462
  96. package/src/audit/checks/tracking-verification.test.ts +0 -371
  97. package/src/audit/checks/tracking-verification.ts +0 -636
  98. package/src/audit/checks/url-safety.ts +0 -682
  99. package/src/audit/deno-entry.ts +0 -66
  100. package/src/audit/discovery/index.ts +0 -15
  101. package/src/audit/discovery/link-crawler.ts +0 -233
  102. package/src/audit/discovery/repo-routes.ts +0 -347
  103. package/src/audit/engine.ts +0 -633
  104. package/src/audit/fixes/index.ts +0 -209
  105. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  106. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  107. package/src/audit/index.ts +0 -74
  108. package/src/audit/runner.test.ts +0 -299
  109. package/src/audit/runner.ts +0 -130
  110. package/src/audit/types.ts +0 -1987
  111. package/src/content/featured-snippet.ts +0 -367
  112. package/src/content/generator.test.ts +0 -534
  113. package/src/content/generator.ts +0 -501
  114. package/src/content/headline.ts +0 -317
  115. package/src/content/index.ts +0 -62
  116. package/src/content/intent.ts +0 -258
  117. package/src/content/keyword-density.ts +0 -349
  118. package/src/content/readability.ts +0 -262
  119. package/src/executor.ts +0 -336
  120. package/src/fixer/framework-fixes.test.ts +0 -489
  121. package/src/fixer/framework-fixes.ts +0 -5287
  122. package/src/fixer/index.ts +0 -6
  123. package/src/fixer/schemas.ts +0 -971
  124. package/src/fixer.ts +0 -642
  125. package/src/frameworks/detector.test.ts +0 -248
  126. package/src/frameworks/detector.ts +0 -899
  127. package/src/frameworks/index.ts +0 -68
  128. package/src/frameworks/recipes/angular.yaml +0 -171
  129. package/src/frameworks/recipes/astro.yaml +0 -206
  130. package/src/frameworks/recipes/django.yaml +0 -180
  131. package/src/frameworks/recipes/laravel.yaml +0 -137
  132. package/src/frameworks/recipes/nextjs.yaml +0 -268
  133. package/src/frameworks/recipes/nuxt.yaml +0 -175
  134. package/src/frameworks/recipes/rails.yaml +0 -188
  135. package/src/frameworks/recipes/react.yaml +0 -202
  136. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  137. package/src/frameworks/recipes/vue.yaml +0 -137
  138. package/src/frameworks/recipes/wordpress.yaml +0 -209
  139. package/src/frameworks/suggestion-engine.ts +0 -357
  140. package/src/geo/geo-content.test.ts +0 -305
  141. package/src/geo/geo-content.ts +0 -266
  142. package/src/geo/geo-history.test.ts +0 -473
  143. package/src/geo/geo-history.ts +0 -433
  144. package/src/geo/geo-tracker.test.ts +0 -359
  145. package/src/geo/geo-tracker.ts +0 -411
  146. package/src/geo/index.ts +0 -11
  147. package/src/geo/llm-citation-checker.ts +0 -188
  148. package/src/git/commit-helper.test.ts +0 -261
  149. package/src/git/commit-helper.ts +0 -329
  150. package/src/git/index.ts +0 -12
  151. package/src/git/pr-helper.test.ts +0 -284
  152. package/src/git/pr-helper.ts +0 -307
  153. package/src/index.ts +0 -76
  154. package/src/keywords/ai-keyword-engine.ts +0 -1062
  155. package/src/keywords/ai-summarizer.ts +0 -387
  156. package/src/keywords/ci-mode.ts +0 -555
  157. package/src/keywords/engine.ts +0 -359
  158. package/src/keywords/index.ts +0 -151
  159. package/src/keywords/llm-judge.ts +0 -357
  160. package/src/keywords/nlp-analysis.ts +0 -706
  161. package/src/keywords/prioritizer.ts +0 -295
  162. package/src/keywords/site-crawler.ts +0 -342
  163. package/src/keywords/sources/autocomplete.ts +0 -139
  164. package/src/keywords/sources/competitive-search.ts +0 -450
  165. package/src/keywords/sources/competitor-analysis.ts +0 -374
  166. package/src/keywords/sources/dataforseo.ts +0 -206
  167. package/src/keywords/sources/free-sources.ts +0 -294
  168. package/src/keywords/sources/gsc.ts +0 -123
  169. package/src/keywords/topic-grouping.ts +0 -327
  170. package/src/keywords/types.ts +0 -144
  171. package/src/keywords/wizard.ts +0 -457
  172. package/src/loader.ts +0 -40
  173. package/src/ranking/index.ts +0 -5
  174. package/src/ranking/serp-client.ts +0 -348
  175. package/src/ranking/tracker.ts +0 -380
  176. package/src/ranking/types.ts +0 -123
  177. package/src/reports/index.ts +0 -7
  178. package/src/reports/report-generator.test.ts +0 -293
  179. package/src/reports/report-generator.ts +0 -713
  180. package/src/scheduler/alerts.test.ts +0 -458
  181. package/src/scheduler/alerts.ts +0 -328
  182. package/src/scheduler/index.ts +0 -8
  183. package/src/scheduler/scheduled-audit.test.ts +0 -377
  184. package/src/scheduler/scheduled-audit.ts +0 -149
  185. package/src/test/integration-test.ts +0 -325
  186. package/src/tools/analyzer.ts +0 -373
  187. package/src/tools/crawl.ts +0 -293
  188. package/src/tools/files.ts +0 -301
  189. package/src/tools/h1-fixer.ts +0 -249
  190. package/src/tools/index.ts +0 -67
  191. package/src/tracking/github-action.ts +0 -326
  192. package/src/tracking/google-analytics.ts +0 -265
  193. package/src/tracking/index.ts +0 -45
  194. package/src/tracking/report-generator.ts +0 -386
  195. package/src/tracking/search-console.ts +0 -335
  196. package/src/types.ts +0 -148
  197. package/src/utils/http.ts +0 -302
  198. package/src/wasm-adapter.ts +0 -297
  199. package/src/wasm-entry.ts +0 -14
  200. package/tsconfig.json +0 -17
  201. package/tsup.wasm.config.ts +0 -26
  202. package/vitest.config.ts +0 -15
@@ -1,206 +0,0 @@
1
- /**
2
- * Bing Optimization Checks
3
- *
4
- * ChatGPT Search uses Bing's index, making Bing optimization crucial for AI search visibility.
5
- * These checks verify Bing-specific optimizations that improve AI search presence.
6
- */
7
-
8
- import * as cheerio from 'cheerio';
9
- import { httpGet } from '../../utils/http.js';
10
- import type { AuditIssue } from '../types.js';
11
-
12
- export interface BingOptimizationData {
13
- hasBingSiteAuth: boolean;
14
- hasBingMetaTag: boolean;
15
- hasBingIndexNowKey: boolean;
16
- bingPlacesDetected: boolean;
17
- bingSitemapAccessible: boolean;
18
- issues: string[];
19
- }
20
-
21
- export async function analyzeBingOptimization(
22
- html: string,
23
- url: string
24
- ): Promise<{ issues: AuditIssue[]; data: BingOptimizationData }> {
25
- const issues: AuditIssue[] = [];
26
- const $ = cheerio.load(html);
27
- const parsedUrl = new URL(url);
28
- const baseUrl = `${parsedUrl.protocol}//${parsedUrl.hostname}`;
29
- const detectedIssues: string[] = [];
30
-
31
- // Check for Bing site verification meta tag
32
- const bingMetaTag = $('meta[name="msvalidate.01"]').attr('content');
33
- const hasBingMetaTag = !!bingMetaTag && bingMetaTag.length > 0;
34
-
35
- // Check for BingSiteAuth.xml
36
- let hasBingSiteAuth = false;
37
- try {
38
- const authResponse = await httpGet(`${baseUrl}/BingSiteAuth.xml`, { timeout: 5000 });
39
- hasBingSiteAuth = authResponse.status === 200 &&
40
- authResponse.data.includes('<?xml') &&
41
- authResponse.data.toLowerCase().includes('users');
42
- } catch {
43
- // File doesn't exist or not accessible
44
- }
45
-
46
- // Check for IndexNow key file (used by Bing)
47
- let hasBingIndexNowKey = false;
48
- try {
49
- // Common IndexNow key file patterns
50
- const keyPatterns = [
51
- `${baseUrl}/indexnow.txt`,
52
- `${baseUrl}/.well-known/indexnow`,
53
- ];
54
-
55
- for (const keyUrl of keyPatterns) {
56
- try {
57
- const keyResponse = await httpGet(keyUrl, { timeout: 5000 });
58
- if (keyResponse.status === 200 && keyResponse.data.length >= 8) {
59
- hasBingIndexNowKey = true;
60
- break;
61
- }
62
- } catch {
63
- // Continue checking other patterns
64
- }
65
- }
66
- } catch {
67
- // IndexNow key not found
68
- }
69
-
70
- // Check for Bing Places indicators in structured data
71
- const scripts = $('script[type="application/ld+json"]');
72
- let bingPlacesDetected = false;
73
-
74
- scripts.each((_, el) => {
75
- try {
76
- const jsonText = $(el).html();
77
- if (jsonText) {
78
- const data = JSON.parse(jsonText);
79
- const schemas = Array.isArray(data) ? data : [data];
80
-
81
- for (const schema of schemas) {
82
- // Check for LocalBusiness or Organization with address
83
- if (schema['@type'] === 'LocalBusiness' ||
84
- (schema['@type'] === 'Organization' && schema.address)) {
85
- bingPlacesDetected = true;
86
- }
87
-
88
- // Check sameAs for Bing Places URL
89
- if (schema.sameAs) {
90
- const sameAsUrls = Array.isArray(schema.sameAs) ? schema.sameAs : [schema.sameAs];
91
- if (sameAsUrls.some((u: string) => u.includes('bing.com/maps'))) {
92
- bingPlacesDetected = true;
93
- }
94
- }
95
- }
96
- }
97
- } catch {
98
- // Invalid JSON
99
- }
100
- });
101
-
102
- // Check if sitemap is accessible (important for Bing indexing)
103
- let bingSitemapAccessible = false;
104
- try {
105
- const sitemapResponse = await httpGet(`${baseUrl}/sitemap.xml`, { timeout: 5000 });
106
- bingSitemapAccessible = sitemapResponse.status === 200 &&
107
- sitemapResponse.data.includes('<?xml');
108
- } catch {
109
- // Sitemap not accessible
110
- }
111
-
112
- // Generate issues
113
-
114
- // No Bing verification
115
- if (!hasBingMetaTag && !hasBingSiteAuth) {
116
- detectedIssues.push('No Bing site verification');
117
- issues.push({
118
- code: 'BING_NOT_VERIFIED',
119
- severity: 'warning',
120
- category: 'ai-readiness',
121
- title: 'Site not verified with Bing Webmaster Tools',
122
- description: 'ChatGPT Search uses Bing\'s index. Verifying your site with Bing Webmaster Tools ensures proper indexing and access to Bing-specific SEO tools.',
123
- impact: 'May reduce visibility in ChatGPT Search results and miss Bing-specific optimization opportunities.',
124
- howToFix: 'Add Bing verification: 1) Go to Bing Webmaster Tools, 2) Add your site, 3) Choose verification method (meta tag or XML file), 4) Add the verification code to your site.',
125
- affectedUrls: [url],
126
- details: {
127
- hasBingMetaTag,
128
- hasBingSiteAuth,
129
- verificationMethods: [
130
- 'Add <meta name="msvalidate.01" content="YOUR_CODE"> to <head>',
131
- 'Upload BingSiteAuth.xml to root directory',
132
- ],
133
- },
134
- });
135
- }
136
-
137
- // No IndexNow for Bing
138
- if (!hasBingIndexNowKey) {
139
- detectedIssues.push('No IndexNow key for Bing');
140
- issues.push({
141
- code: 'BING_NO_INDEXNOW',
142
- severity: 'notice',
143
- category: 'ai-readiness',
144
- title: 'IndexNow not configured for Bing instant indexing',
145
- description: 'IndexNow enables instant content indexing by Bing (and subsequently ChatGPT Search). Without it, new content may take longer to appear in AI search results.',
146
- impact: 'Content updates may be delayed in Bing\'s index and ChatGPT Search results.',
147
- howToFix: 'Implement IndexNow: 1) Generate an API key, 2) Host the key file at /indexnow.txt or /.well-known/indexnow, 3) Notify Bing of URL changes via the IndexNow API.',
148
- affectedUrls: [url],
149
- details: {
150
- indexNowEndpoint: 'https://www.bing.com/indexnow',
151
- documentation: 'https://www.indexnow.org/documentation',
152
- },
153
- });
154
- }
155
-
156
- // No sitemap for Bing
157
- if (!bingSitemapAccessible) {
158
- detectedIssues.push('Sitemap not accessible');
159
- issues.push({
160
- code: 'BING_SITEMAP_MISSING',
161
- severity: 'warning',
162
- category: 'ai-readiness',
163
- title: 'XML sitemap not accessible for Bing crawling',
164
- description: 'A sitemap helps Bing discover and index all your pages. Without it, some content may not be indexed and thus not appear in ChatGPT Search.',
165
- impact: 'Bing may miss important pages, reducing your AI search coverage.',
166
- howToFix: 'Create and submit an XML sitemap: 1) Generate sitemap.xml with all important URLs, 2) Submit it in Bing Webmaster Tools, 3) Reference it in robots.txt.',
167
- affectedUrls: [url],
168
- });
169
- }
170
-
171
- // Local business without Bing Places
172
- const hasLocalBusinessSchema = bingPlacesDetected;
173
- const hasAddressOnPage = $('address').length > 0 ||
174
- html.toLowerCase().includes('street') ||
175
- /\d{5}(-\d{4})?/.test(html); // ZIP code pattern
176
-
177
- if (hasAddressOnPage && !hasLocalBusinessSchema) {
178
- detectedIssues.push('Local business may not be on Bing Places');
179
- issues.push({
180
- code: 'BING_PLACES_MISSING',
181
- severity: 'notice',
182
- category: 'ai-readiness',
183
- title: 'Local business not optimized for Bing Places',
184
- description: 'Your site appears to have a physical location but may not be listed on Bing Places. Bing Places listings appear in Bing Maps and can be referenced by AI assistants.',
185
- impact: 'Missing local search visibility in Bing and potential AI assistant recommendations for local queries.',
186
- howToFix: 'Claim your Bing Places listing: 1) Go to bingplaces.com, 2) Claim or add your business, 3) Verify ownership, 4) Add complete business information.',
187
- affectedUrls: [url],
188
- details: {
189
- bingPlacesUrl: 'https://www.bingplaces.com/',
190
- recommendation: 'Also add sameAs link to your Bing Places listing in Organization schema',
191
- },
192
- });
193
- }
194
-
195
- return {
196
- issues,
197
- data: {
198
- hasBingSiteAuth,
199
- hasBingMetaTag,
200
- hasBingIndexNowKey,
201
- bingPlacesDetected,
202
- bingSitemapAccessible,
203
- issues: detectedIssues,
204
- },
205
- };
206
- }
@@ -1,349 +0,0 @@
1
- /**
2
- * Brand Mention Optimization Checks
3
- *
4
- * AI systems extract and quote brand information when answering queries.
5
- * This check analyzes whether your brand is clearly defined in a way
6
- * that AI can extract, quote, and recommend.
7
- *
8
- * Key insight: "AI doesn't decide who you are. It mostly just repeats
9
- * what it finds on the internet." - Control your brand narrative.
10
- */
11
-
12
- import * as cheerio from 'cheerio';
13
- import type { AuditIssue } from '../types.js';
14
-
15
- export interface BrandMentionData {
16
- brandSignals: {
17
- hasBrandDefinition: boolean;
18
- hasUSP: boolean;
19
- hasValueProposition: boolean;
20
- hasBrandStatement: boolean;
21
- brandMentionCount: number;
22
- };
23
- brandCoverage: {
24
- hasPricingInfo: boolean;
25
- hasAboutSection: boolean;
26
- hasFAQSection: boolean;
27
- hasTestimonials: boolean;
28
- hasProofPoints: boolean;
29
- };
30
- brandConsistency: {
31
- hasConsistentNaming: boolean;
32
- hasContactInfo: boolean;
33
- hasSocialLinks: boolean;
34
- hasReviewLinks: boolean;
35
- };
36
- quotableBrandStatements: string[];
37
- brandScore: number;
38
- }
39
-
40
- // Patterns for brand-defining statements
41
- const BRAND_DEFINITION_PATTERNS = [
42
- /(?:we are|we're|is a|is the|is an)\s+(?:leading|premier|top|best|trusted|innovative|professional)/i,
43
- /(?:our mission|our vision|we help|we provide|we offer|we specialize)/i,
44
- /(?:founded in|established in|since \d{4}|for over \d+)/i,
45
- ];
46
-
47
- // USP (Unique Selling Proposition) patterns
48
- const USP_PATTERNS = [
49
- /(?:only|unique|exclusive|proprietary|patented|first|original)/i,
50
- /(?:unlike|different from|better than|compared to)/i,
51
- /(?:guarantee|warranty|promise|commitment)/i,
52
- /(?:free|no cost|complimentary|included)/i,
53
- /(?:\d+%|\d+x|\d+ times|faster|cheaper|easier)/i,
54
- ];
55
-
56
- // Value proposition patterns
57
- const VALUE_PROP_PATTERNS = [
58
- /(?:save|reduce|increase|improve|boost|grow|maximize|minimize)/i,
59
- /(?:get|achieve|reach|attain|unlock|discover)/i,
60
- /(?:without|no need|don't have to|eliminates|removes)/i,
61
- ];
62
-
63
- // Review platform domains
64
- const REVIEW_PLATFORMS = [
65
- 'trustpilot.com', 'g2.com', 'capterra.com', 'yelp.com',
66
- 'bbb.org', 'glassdoor.com', 'indeed.com', 'tripadvisor.com',
67
- 'angi.com', 'homeadvisor.com', 'avvo.com', 'healthgrades.com',
68
- 'zocdoc.com', 'clutch.co', 'producthunt.com', 'getapp.com',
69
- ];
70
-
71
- export function analyzeBrandMentionOptimization(
72
- html: string,
73
- url: string
74
- ): { issues: AuditIssue[]; data: BrandMentionData } {
75
- const issues: AuditIssue[] = [];
76
- const $ = cheerio.load(html);
77
- const parsedUrl = new URL(url);
78
-
79
- // Remove non-content elements
80
- const $content = $('body').clone();
81
- $content.find('nav, footer, script, style, noscript').remove();
82
- const bodyText = $content.text();
83
- const bodyHtml = $content.html() || '';
84
-
85
- // Extract potential brand name from domain or title
86
- const domainParts = parsedUrl.hostname.replace('www.', '').split('.');
87
- const potentialBrandName = domainParts[0];
88
- const title = $('title').text();
89
- const ogSiteName = $('meta[property="og:site_name"]').attr('content') || '';
90
-
91
- // Count brand mentions
92
- const brandNameRegex = new RegExp(potentialBrandName, 'gi');
93
- const brandMentionCount = (bodyText.match(brandNameRegex) || []).length;
94
-
95
- // Check for brand definition patterns
96
- let hasBrandDefinition = false;
97
- let hasUSP = false;
98
- let hasValueProposition = false;
99
- let hasBrandStatement = false;
100
- const quotableBrandStatements: string[] = [];
101
-
102
- // Analyze paragraphs for brand statements
103
- $content.find('p, li, h1, h2, h3').each((_, el) => {
104
- const text = $(el).text().trim();
105
- if (text.length < 20 || text.length > 300) return;
106
-
107
- // Check for brand definitions
108
- for (const pattern of BRAND_DEFINITION_PATTERNS) {
109
- if (pattern.test(text)) {
110
- hasBrandDefinition = true;
111
- if (text.length <= 200 && quotableBrandStatements.length < 5) {
112
- quotableBrandStatements.push(text);
113
- }
114
- break;
115
- }
116
- }
117
-
118
- // Check for USPs
119
- for (const pattern of USP_PATTERNS) {
120
- if (pattern.test(text)) {
121
- hasUSP = true;
122
- break;
123
- }
124
- }
125
-
126
- // Check for value propositions
127
- for (const pattern of VALUE_PROP_PATTERNS) {
128
- if (pattern.test(text)) {
129
- hasValueProposition = true;
130
- break;
131
- }
132
- }
133
- });
134
-
135
- // Check for explicit brand statement (often in hero or about section)
136
- hasBrandStatement =
137
- $('[class*="hero"] p, [class*="about"] p, [id*="hero"] p, [id*="about"] p').length > 0 ||
138
- $('main > section:first-child p').length > 0;
139
-
140
- // Check brand topic coverage
141
- const headingText = $('h1, h2, h3, h4').map((_, h) => $(h).text().toLowerCase()).get().join(' ');
142
- const linkText = $('a').map((_, a) => $(a).text().toLowerCase()).get().join(' ');
143
- const allLinks = $('a[href]').map((_, a) => $(a).attr('href') || '').get();
144
-
145
- const hasPricingInfo =
146
- headingText.includes('pricing') ||
147
- headingText.includes('plans') ||
148
- headingText.includes('cost') ||
149
- linkText.includes('pricing') ||
150
- allLinks.some(href => href.includes('pricing') || href.includes('plans'));
151
-
152
- const hasAboutSection =
153
- headingText.includes('about') ||
154
- headingText.includes('who we are') ||
155
- headingText.includes('our story') ||
156
- allLinks.some(href => href.includes('about'));
157
-
158
- const hasFAQSection =
159
- headingText.includes('faq') ||
160
- headingText.includes('frequently asked') ||
161
- headingText.includes('questions') ||
162
- $('[itemtype*="FAQPage"]').length > 0 ||
163
- $('details summary').length >= 2;
164
-
165
- const hasTestimonials =
166
- headingText.includes('testimonial') ||
167
- headingText.includes('review') ||
168
- headingText.includes('what our') ||
169
- headingText.includes('customer') ||
170
- $('[class*="testimonial"], [class*="review"], [id*="testimonial"]').length > 0 ||
171
- $('blockquote').length >= 2;
172
-
173
- const hasProofPoints =
174
- headingText.includes('case stud') ||
175
- headingText.includes('success') ||
176
- headingText.includes('results') ||
177
- /\d+\+?\s*(customers|clients|users|companies|businesses)/i.test(bodyText) ||
178
- /\d+%\s*(increase|decrease|improvement|growth)/i.test(bodyText);
179
-
180
- // Check brand consistency signals
181
- const hasConsistentNaming = brandMentionCount >= 3 && ogSiteName.length > 0;
182
-
183
- const hasContactInfo =
184
- $('a[href^="tel:"], a[href^="mailto:"]').length > 0 ||
185
- /\d{3}[-.\s]?\d{3}[-.\s]?\d{4}/.test(bodyText) ||
186
- bodyText.toLowerCase().includes('contact');
187
-
188
- const socialLinks = $('a[href*="facebook.com"], a[href*="twitter.com"], a[href*="linkedin.com"], a[href*="instagram.com"]');
189
- const hasSocialLinks = socialLinks.length >= 2;
190
-
191
- // Check for review platform links
192
- const hasReviewLinks = allLinks.some(href => {
193
- const lowerHref = href.toLowerCase();
194
- return REVIEW_PLATFORMS.some(platform => lowerHref.includes(platform));
195
- });
196
-
197
- // Calculate brand score
198
- let brandScore = 30; // Base score
199
-
200
- // Brand signals
201
- if (hasBrandDefinition) brandScore += 15;
202
- if (hasUSP) brandScore += 10;
203
- if (hasValueProposition) brandScore += 10;
204
- if (brandMentionCount >= 5) brandScore += 5;
205
-
206
- // Brand coverage
207
- if (hasPricingInfo) brandScore += 5;
208
- if (hasAboutSection) brandScore += 5;
209
- if (hasFAQSection) brandScore += 5;
210
- if (hasTestimonials) brandScore += 10;
211
- if (hasProofPoints) brandScore += 10;
212
-
213
- // Brand consistency
214
- if (hasConsistentNaming) brandScore += 5;
215
- if (hasContactInfo) brandScore += 3;
216
- if (hasSocialLinks) brandScore += 3;
217
- if (hasReviewLinks) brandScore += 5;
218
-
219
- brandScore = Math.min(100, Math.max(0, brandScore));
220
-
221
- // Generate issues
222
-
223
- // No clear brand definition
224
- if (!hasBrandDefinition) {
225
- issues.push({
226
- code: 'AI_NO_BRAND_DEFINITION',
227
- severity: 'warning',
228
- category: 'ai-readiness',
229
- title: 'No clear brand definition for AI to extract',
230
- description: 'AI systems look for clear "Brand X is..." statements to quote when recommending brands. Your page lacks quotable brand definitions.',
231
- impact: 'AI cannot accurately describe your brand, reducing recommendation likelihood.',
232
- howToFix: 'Add a clear brand definition early in your content: "[Brand] is a [category] that [key benefit]." Make it quotable (under 200 characters).',
233
- affectedUrls: [url],
234
- details: {
235
- suggestion: `Example: "${potentialBrandName.charAt(0).toUpperCase() + potentialBrandName.slice(1)} is a [category] that helps [audience] [achieve benefit]."`,
236
- },
237
- });
238
- }
239
-
240
- // No USP
241
- if (!hasUSP) {
242
- issues.push({
243
- code: 'AI_NO_USP',
244
- severity: 'notice',
245
- category: 'ai-readiness',
246
- title: 'No unique selling proposition (USP) detected',
247
- description: 'AI needs clear differentiators to recommend your brand over competitors. No USP patterns found.',
248
- impact: 'AI may not distinguish your brand from competitors when making recommendations.',
249
- howToFix: 'Add clear differentiators: "The only...", "Unlike competitors...", "Guaranteed...", specific numbers (e.g., "50% faster").',
250
- affectedUrls: [url],
251
- });
252
- }
253
-
254
- // Missing brand topic coverage
255
- const missingTopics: string[] = [];
256
- if (!hasPricingInfo) missingTopics.push('pricing');
257
- if (!hasFAQSection) missingTopics.push('FAQ');
258
- if (!hasTestimonials) missingTopics.push('testimonials/reviews');
259
- if (!hasProofPoints) missingTopics.push('proof points/case studies');
260
-
261
- if (missingTopics.length >= 2) {
262
- issues.push({
263
- code: 'AI_INCOMPLETE_BRAND_COVERAGE',
264
- severity: 'notice',
265
- category: 'ai-readiness',
266
- title: 'Incomplete brand topic coverage',
267
- description: `Missing key brand topics that AI uses to answer queries: ${missingTopics.join(', ')}. AI may rely on third-party sources instead.`,
268
- impact: 'Third-party sites may define your brand narrative instead of you.',
269
- howToFix: 'Cover key brand topics on your site: pricing, positioning, proof (testimonials, case studies), and FAQs.',
270
- affectedUrls: [url],
271
- details: {
272
- missingTopics,
273
- recommendation: 'Control your brand narrative by having authoritative content on these topics on your own site.',
274
- },
275
- });
276
- }
277
-
278
- // No review platform integration
279
- if (!hasReviewLinks && !hasTestimonials) {
280
- issues.push({
281
- code: 'AI_NO_REVIEW_INTEGRATION',
282
- severity: 'notice',
283
- category: 'ai-readiness',
284
- title: 'No review platform integration',
285
- description: 'No links to review platforms or testimonial sections found. AI uses review signals from multiple platforms for trust.',
286
- impact: 'Missing review diversity signals that AI uses for brand trust assessment.',
287
- howToFix: 'Link to your profiles on relevant review platforms (G2, Capterra, Trustpilot, etc.) and display testimonials with attribution.',
288
- affectedUrls: [url],
289
- details: {
290
- relevantPlatforms: [
291
- 'B2B SaaS: G2, Capterra, TrustRadius',
292
- 'Local: Google Business, Yelp, BBB',
293
- 'Professional: Clutch, UpCity',
294
- ],
295
- },
296
- });
297
- }
298
-
299
- // Low brand score
300
- if (brandScore < 50) {
301
- issues.push({
302
- code: 'AI_LOW_BRAND_SCORE',
303
- severity: 'warning',
304
- category: 'ai-readiness',
305
- title: 'Brand is not well-optimized for AI extraction',
306
- description: `Brand optimization score: ${brandScore}/100. AI may struggle to accurately describe and recommend your brand.`,
307
- impact: 'Low likelihood of being recommended in AI answers for brand-related queries.',
308
- howToFix: 'Improve brand clarity: add quotable definitions, USPs, testimonials, proof points, and link to review platforms.',
309
- affectedUrls: [url],
310
- details: {
311
- brandScore,
312
- hasBrandDefinition,
313
- hasUSP,
314
- hasTestimonials,
315
- hasProofPoints,
316
- hasReviewLinks,
317
- quotableBrandStatements: quotableBrandStatements.slice(0, 3),
318
- },
319
- });
320
- }
321
-
322
- return {
323
- issues,
324
- data: {
325
- brandSignals: {
326
- hasBrandDefinition,
327
- hasUSP,
328
- hasValueProposition,
329
- hasBrandStatement,
330
- brandMentionCount,
331
- },
332
- brandCoverage: {
333
- hasPricingInfo,
334
- hasAboutSection,
335
- hasFAQSection,
336
- hasTestimonials,
337
- hasProofPoints,
338
- },
339
- brandConsistency: {
340
- hasConsistentNaming,
341
- hasContactInfo,
342
- hasSocialLinks,
343
- hasReviewLinks,
344
- },
345
- quotableBrandStatements,
346
- brandScore,
347
- },
348
- };
349
- }