@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,270 @@
1
+ /**
2
+ * Asset Minification Check
3
+ *
4
+ * Checks if CSS and JavaScript files are properly minified.
5
+ * Unminified files contain unnecessary whitespace, comments, and long variable names
6
+ * that increase file size and slow down page load times.
7
+ *
8
+ * Detection methods:
9
+ * - Whitespace ratio (minified files have very low whitespace)
10
+ * - Average line length (minified files have very long lines)
11
+ * - Comment presence (minified files have no comments)
12
+ */
13
+
14
+ import { httpGet } from '../../utils/http.js';
15
+ import * as cheerio from 'cheerio';
16
+ import type { AuditIssue } from '../types.js';
17
+
18
+ export interface MinificationData {
19
+ cssFiles: AssetMinificationInfo[];
20
+ jsFiles: AssetMinificationInfo[];
21
+ totalCssFiles: number;
22
+ totalJsFiles: number;
23
+ unminifiedCss: number;
24
+ unminifiedJs: number;
25
+ potentialSavings: {
26
+ css: number; // estimated bytes
27
+ js: number;
28
+ };
29
+ }
30
+
31
+ interface AssetMinificationInfo {
32
+ url: string;
33
+ size: number;
34
+ isMinified: boolean;
35
+ indicators: {
36
+ avgLineLength: number;
37
+ whitespaceRatio: number;
38
+ hasComments: boolean;
39
+ };
40
+ }
41
+
42
+ /**
43
+ * Detect if content is minified
44
+ */
45
+ function isMinified(content: string, type: 'css' | 'js'): { isMinified: boolean; indicators: AssetMinificationInfo['indicators'] } {
46
+ const lines = content.split('\n');
47
+ const totalLines = lines.length;
48
+ const avgLineLength = totalLines > 0 ? content.length / totalLines : 0;
49
+
50
+ // Count whitespace characters (spaces, tabs, newlines)
51
+ const whitespaceCount = (content.match(/\s/g) || []).length;
52
+ const whitespaceRatio = content.length > 0 ? whitespaceCount / content.length : 0;
53
+
54
+ // Check for comments
55
+ let hasComments = false;
56
+ if (type === 'css') {
57
+ // CSS comments: /* ... */
58
+ hasComments = /\/\*[\s\S]*?\*\//.test(content);
59
+ } else {
60
+ // JS comments: // ... or /* ... */
61
+ hasComments = /\/\/[^\n]*|\/\*[\s\S]*?\*\//.test(content);
62
+ }
63
+
64
+ // Minification indicators:
65
+ // - Average line length > 500 chars (minified = long lines)
66
+ // - Whitespace ratio < 10% (minified = little whitespace)
67
+ // - No comments
68
+ const isMinifiedByLineLength = avgLineLength > 500;
69
+ const isMinifiedByWhitespace = whitespaceRatio < 0.1;
70
+ const isMinifiedByComments = !hasComments;
71
+
72
+ // Consider minified if at least 2 of 3 indicators pass
73
+ // OR if single-line file with reasonable length (common for small minified files)
74
+ const score = (isMinifiedByLineLength ? 1 : 0) + (isMinifiedByWhitespace ? 1 : 0) + (isMinifiedByComments ? 1 : 0);
75
+ const isSingleLineMinified = totalLines <= 2 && avgLineLength > 100;
76
+
77
+ return {
78
+ isMinified: score >= 2 || isSingleLineMinified,
79
+ indicators: {
80
+ avgLineLength: Math.round(avgLineLength),
81
+ whitespaceRatio: Math.round(whitespaceRatio * 100) / 100,
82
+ hasComments,
83
+ },
84
+ };
85
+ }
86
+
87
+ /**
88
+ * Extract asset URLs from HTML
89
+ */
90
+ function extractAssetUrls(html: string, baseUrl: string): { css: string[]; js: string[] } {
91
+ const $ = cheerio.load(html);
92
+ const base = new URL(baseUrl);
93
+ const css: string[] = [];
94
+ const js: string[] = [];
95
+
96
+ // Extract CSS files
97
+ $('link[rel="stylesheet"][href]').each((_, el) => {
98
+ const href = $(el).attr('href');
99
+ if (href && !href.startsWith('data:')) {
100
+ try {
101
+ const fullUrl = new URL(href, base).href;
102
+ // Only check first-party CSS
103
+ if (new URL(fullUrl).hostname === base.hostname) {
104
+ css.push(fullUrl);
105
+ }
106
+ } catch {
107
+ // Invalid URL
108
+ }
109
+ }
110
+ });
111
+
112
+ // Extract JS files
113
+ $('script[src]').each((_, el) => {
114
+ const src = $(el).attr('src');
115
+ if (src && !src.startsWith('data:')) {
116
+ try {
117
+ const fullUrl = new URL(src, base).href;
118
+ // Only check first-party JS
119
+ if (new URL(fullUrl).hostname === base.hostname) {
120
+ js.push(fullUrl);
121
+ }
122
+ } catch {
123
+ // Invalid URL
124
+ }
125
+ }
126
+ });
127
+
128
+ return { css, js };
129
+ }
130
+
131
+ /**
132
+ * Analyze asset minification
133
+ */
134
+ export async function analyzeAssetMinification(
135
+ html: string,
136
+ url: string
137
+ ): Promise<{ issues: AuditIssue[]; data: MinificationData }> {
138
+ const issues: AuditIssue[] = [];
139
+ const assetUrls = extractAssetUrls(html, url);
140
+
141
+ const cssFiles: AssetMinificationInfo[] = [];
142
+ const jsFiles: AssetMinificationInfo[] = [];
143
+
144
+ // Check CSS files (limit to 3, parallel with short timeout)
145
+ const cssToCheck = assetUrls.css.slice(0, 3);
146
+ const cssPromises = cssToCheck.map(async (cssUrl) => {
147
+ try {
148
+ const response = await httpGet<string>(cssUrl, {
149
+ timeout: 3000, // Reduced timeout
150
+ validateStatus: () => true,
151
+ });
152
+
153
+ if (response.status === 200 && typeof response.data === 'string') {
154
+ const content = response.data;
155
+ const { isMinified: minified, indicators } = isMinified(content, 'css');
156
+
157
+ cssFiles.push({
158
+ url: cssUrl,
159
+ size: content.length,
160
+ isMinified: minified,
161
+ indicators,
162
+ });
163
+ }
164
+ } catch {
165
+ // Skip failed requests
166
+ }
167
+ });
168
+
169
+ // Check JS files (limit to 3, parallel with short timeout)
170
+ const jsToCheck = assetUrls.js.slice(0, 3);
171
+ const jsPromises = jsToCheck.map(async (jsUrl) => {
172
+ try {
173
+ const response = await httpGet<string>(jsUrl, {
174
+ timeout: 3000, // Reduced timeout
175
+ validateStatus: () => true,
176
+ });
177
+
178
+ if (response.status === 200 && typeof response.data === 'string') {
179
+ const content = response.data;
180
+ const { isMinified: minified, indicators } = isMinified(content, 'js');
181
+
182
+ jsFiles.push({
183
+ url: jsUrl,
184
+ size: content.length,
185
+ isMinified: minified,
186
+ indicators,
187
+ });
188
+ }
189
+ } catch {
190
+ // Skip failed requests
191
+ }
192
+ });
193
+
194
+ // Run all checks in parallel with overall timeout
195
+ await Promise.race([
196
+ Promise.all([...cssPromises, ...jsPromises]),
197
+ new Promise<void>((resolve) => setTimeout(resolve, 8000)), // 8s overall timeout
198
+ ]);
199
+
200
+ // Count unminified files
201
+ const unminifiedCss = cssFiles.filter((f) => !f.isMinified);
202
+ const unminifiedJs = jsFiles.filter((f) => !f.isMinified);
203
+
204
+ // Estimate potential savings (minification typically saves 30-50%)
205
+ const cssSavings = unminifiedCss.reduce((sum, f) => sum + Math.round(f.size * 0.4), 0);
206
+ const jsSavings = unminifiedJs.reduce((sum, f) => sum + Math.round(f.size * 0.4), 0);
207
+
208
+ // Generate issues
209
+ if (unminifiedCss.length > 0) {
210
+ issues.push({
211
+ code: 'CSS_NOT_MINIFIED',
212
+ severity: 'warning',
213
+ category: 'performance',
214
+ title: 'CSS files not minified',
215
+ description: `${unminifiedCss.length} CSS file(s) appear to not be minified. Minification removes whitespace and comments to reduce file size.`,
216
+ impact: `Unminified CSS increases page load time. Potential savings: ~${Math.round(cssSavings / 1024)}KB.`,
217
+ howToFix:
218
+ 'Use a CSS minifier like cssnano, clean-css, or build tools (Vite, Webpack) to minify CSS files. Most bundlers do this automatically in production builds.',
219
+ affectedUrls: unminifiedCss.map((f) => f.url),
220
+ details: {
221
+ files: unminifiedCss.map((f) => ({
222
+ url: f.url,
223
+ size: `${Math.round(f.size / 1024)}KB`,
224
+ avgLineLength: f.indicators.avgLineLength,
225
+ whitespaceRatio: `${Math.round(f.indicators.whitespaceRatio * 100)}%`,
226
+ hasComments: f.indicators.hasComments,
227
+ })),
228
+ },
229
+ });
230
+ }
231
+
232
+ if (unminifiedJs.length > 0) {
233
+ issues.push({
234
+ code: 'JS_NOT_MINIFIED',
235
+ severity: 'warning',
236
+ category: 'performance',
237
+ title: 'JavaScript files not minified',
238
+ description: `${unminifiedJs.length} JavaScript file(s) appear to not be minified. Minification removes whitespace, comments, and shortens variable names.`,
239
+ impact: `Unminified JavaScript increases page load time and parsing time. Potential savings: ~${Math.round(jsSavings / 1024)}KB.`,
240
+ howToFix:
241
+ 'Use a JS minifier like Terser, UglifyJS, or build tools (Vite, Webpack, esbuild) to minify JavaScript. Most bundlers do this automatically in production builds.',
242
+ affectedUrls: unminifiedJs.map((f) => f.url),
243
+ details: {
244
+ files: unminifiedJs.map((f) => ({
245
+ url: f.url,
246
+ size: `${Math.round(f.size / 1024)}KB`,
247
+ avgLineLength: f.indicators.avgLineLength,
248
+ whitespaceRatio: `${Math.round(f.indicators.whitespaceRatio * 100)}%`,
249
+ hasComments: f.indicators.hasComments,
250
+ })),
251
+ },
252
+ });
253
+ }
254
+
255
+ return {
256
+ issues,
257
+ data: {
258
+ cssFiles,
259
+ jsFiles,
260
+ totalCssFiles: assetUrls.css.length,
261
+ totalJsFiles: assetUrls.js.length,
262
+ unminifiedCss: unminifiedCss.length,
263
+ unminifiedJs: unminifiedJs.length,
264
+ potentialSavings: {
265
+ css: cssSavings,
266
+ js: jsSavings,
267
+ },
268
+ },
269
+ };
270
+ }
@@ -0,0 +1,206 @@
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
+ }