@rankcli/agent-runtime 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/index.d.mts +77 -393
  2. package/dist/index.d.ts +77 -393
  3. package/dist/index.js +417 -6443
  4. package/dist/index.mjs +296 -6313
  5. package/package.json +6 -1
  6. package/scripts/build-deno.ts +0 -134
  7. package/src/analyzers/core-web-vitals-analyzer.test.ts +0 -236
  8. package/src/analyzers/core-web-vitals-analyzer.ts +0 -557
  9. package/src/analyzers/geo-analyzer.test.ts +0 -310
  10. package/src/analyzers/geo-analyzer.ts +0 -814
  11. package/src/analyzers/image-optimization-analyzer.test.ts +0 -145
  12. package/src/analyzers/image-optimization-analyzer.ts +0 -348
  13. package/src/analyzers/index.ts +0 -233
  14. package/src/analyzers/internal-linking-analyzer.test.ts +0 -141
  15. package/src/analyzers/internal-linking-analyzer.ts +0 -419
  16. package/src/analyzers/mobile-seo-analyzer.test.ts +0 -140
  17. package/src/analyzers/mobile-seo-analyzer.ts +0 -455
  18. package/src/analyzers/security-headers-analyzer.test.ts +0 -115
  19. package/src/analyzers/security-headers-analyzer.ts +0 -318
  20. package/src/analyzers/structured-data-analyzer.test.ts +0 -210
  21. package/src/analyzers/structured-data-analyzer.ts +0 -590
  22. package/src/audit/ai/analyzer.ts +0 -347
  23. package/src/audit/ai/index.ts +0 -29
  24. package/src/audit/ai/prompts/content-analysis.ts +0 -271
  25. package/src/audit/ai/types.ts +0 -179
  26. package/src/audit/checks/additional-checks.ts +0 -439
  27. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  28. package/src/audit/checks/ai-content-structure.ts +0 -325
  29. package/src/audit/checks/ai-readiness.ts +0 -339
  30. package/src/audit/checks/anchor-text.ts +0 -179
  31. package/src/audit/checks/answer-conciseness.ts +0 -322
  32. package/src/audit/checks/asset-minification.ts +0 -270
  33. package/src/audit/checks/bing-optimization.ts +0 -206
  34. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  35. package/src/audit/checks/caching-headers.ts +0 -305
  36. package/src/audit/checks/canonical-advanced.ts +0 -150
  37. package/src/audit/checks/canonical-domain.ts +0 -196
  38. package/src/audit/checks/citation-quality.ts +0 -358
  39. package/src/audit/checks/client-rendering.ts +0 -542
  40. package/src/audit/checks/color-contrast.ts +0 -342
  41. package/src/audit/checks/content-freshness.ts +0 -170
  42. package/src/audit/checks/content-science.ts +0 -589
  43. package/src/audit/checks/conversion-elements.ts +0 -526
  44. package/src/audit/checks/crawlability.ts +0 -220
  45. package/src/audit/checks/directory-listing.ts +0 -172
  46. package/src/audit/checks/dom-analysis.ts +0 -191
  47. package/src/audit/checks/dom-size.ts +0 -246
  48. package/src/audit/checks/duplicate-content.ts +0 -194
  49. package/src/audit/checks/eeat-signals.ts +0 -990
  50. package/src/audit/checks/entity-seo.ts +0 -396
  51. package/src/audit/checks/featured-snippet.ts +0 -473
  52. package/src/audit/checks/freshness-signals.ts +0 -443
  53. package/src/audit/checks/funnel-intent.ts +0 -463
  54. package/src/audit/checks/hreflang.ts +0 -174
  55. package/src/audit/checks/html-compliance.ts +0 -302
  56. package/src/audit/checks/image-dimensions.ts +0 -167
  57. package/src/audit/checks/images.ts +0 -160
  58. package/src/audit/checks/indexnow.ts +0 -275
  59. package/src/audit/checks/interactive-tools.ts +0 -475
  60. package/src/audit/checks/internal-link-graph.ts +0 -436
  61. package/src/audit/checks/keyword-analysis.ts +0 -239
  62. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  63. package/src/audit/checks/keyword-placement.ts +0 -471
  64. package/src/audit/checks/links.ts +0 -273
  65. package/src/audit/checks/llms-txt.ts +0 -224
  66. package/src/audit/checks/local-seo.ts +0 -296
  67. package/src/audit/checks/mobile.ts +0 -167
  68. package/src/audit/checks/modern-images.ts +0 -226
  69. package/src/audit/checks/navboost-signals.ts +0 -395
  70. package/src/audit/checks/on-page.ts +0 -209
  71. package/src/audit/checks/page-resources.ts +0 -285
  72. package/src/audit/checks/pagination.ts +0 -180
  73. package/src/audit/checks/performance.ts +0 -153
  74. package/src/audit/checks/platform-presence.ts +0 -580
  75. package/src/audit/checks/redirect-analysis.ts +0 -153
  76. package/src/audit/checks/redirect-chain.ts +0 -389
  77. package/src/audit/checks/resource-hints.ts +0 -420
  78. package/src/audit/checks/responsive-css.ts +0 -247
  79. package/src/audit/checks/responsive-images.ts +0 -396
  80. package/src/audit/checks/review-ecosystem.ts +0 -415
  81. package/src/audit/checks/robots-validation.ts +0 -373
  82. package/src/audit/checks/security-headers.ts +0 -188
  83. package/src/audit/checks/security.ts +0 -144
  84. package/src/audit/checks/serp-preview.ts +0 -251
  85. package/src/audit/checks/site-maturity.ts +0 -453
  86. package/src/audit/checks/social-meta.test.ts +0 -275
  87. package/src/audit/checks/social-meta.ts +0 -134
  88. package/src/audit/checks/soft-404.ts +0 -151
  89. package/src/audit/checks/structured-data.ts +0 -238
  90. package/src/audit/checks/tech-detection.ts +0 -496
  91. package/src/audit/checks/topical-clusters.ts +0 -435
  92. package/src/audit/checks/tracker-bloat.ts +0 -462
  93. package/src/audit/checks/tracking-verification.test.ts +0 -371
  94. package/src/audit/checks/tracking-verification.ts +0 -636
  95. package/src/audit/checks/url-safety.ts +0 -682
  96. package/src/audit/deno-entry.ts +0 -66
  97. package/src/audit/discovery/index.ts +0 -15
  98. package/src/audit/discovery/link-crawler.ts +0 -233
  99. package/src/audit/discovery/repo-routes.ts +0 -347
  100. package/src/audit/engine.ts +0 -627
  101. package/src/audit/fixes/index.ts +0 -209
  102. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  103. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  104. package/src/audit/index.ts +0 -74
  105. package/src/audit/runner.test.ts +0 -299
  106. package/src/audit/runner.ts +0 -130
  107. package/src/audit/types.ts +0 -1963
  108. package/src/content/featured-snippet.ts +0 -367
  109. package/src/content/generator.test.ts +0 -534
  110. package/src/content/generator.ts +0 -501
  111. package/src/content/headline.ts +0 -317
  112. package/src/content/index.ts +0 -62
  113. package/src/content/intent.ts +0 -258
  114. package/src/content/keyword-density.ts +0 -349
  115. package/src/content/readability.ts +0 -262
  116. package/src/executor.ts +0 -336
  117. package/src/fixer/framework-fixes.test.ts +0 -489
  118. package/src/fixer/framework-fixes.ts +0 -5287
  119. package/src/fixer/index.ts +0 -6
  120. package/src/fixer/schemas.ts +0 -971
  121. package/src/fixer.ts +0 -642
  122. package/src/frameworks/detector.test.ts +0 -248
  123. package/src/frameworks/detector.ts +0 -899
  124. package/src/frameworks/index.ts +0 -68
  125. package/src/frameworks/recipes/angular.yaml +0 -171
  126. package/src/frameworks/recipes/astro.yaml +0 -206
  127. package/src/frameworks/recipes/django.yaml +0 -180
  128. package/src/frameworks/recipes/laravel.yaml +0 -137
  129. package/src/frameworks/recipes/nextjs.yaml +0 -268
  130. package/src/frameworks/recipes/nuxt.yaml +0 -175
  131. package/src/frameworks/recipes/rails.yaml +0 -188
  132. package/src/frameworks/recipes/react.yaml +0 -202
  133. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  134. package/src/frameworks/recipes/vue.yaml +0 -137
  135. package/src/frameworks/recipes/wordpress.yaml +0 -209
  136. package/src/frameworks/suggestion-engine.ts +0 -357
  137. package/src/geo/geo-content.test.ts +0 -305
  138. package/src/geo/geo-content.ts +0 -266
  139. package/src/geo/geo-history.test.ts +0 -473
  140. package/src/geo/geo-history.ts +0 -433
  141. package/src/geo/geo-tracker.test.ts +0 -359
  142. package/src/geo/geo-tracker.ts +0 -411
  143. package/src/geo/index.ts +0 -11
  144. package/src/geo/llm-citation-checker.ts +0 -188
  145. package/src/git/commit-helper.test.ts +0 -261
  146. package/src/git/commit-helper.ts +0 -329
  147. package/src/git/index.ts +0 -12
  148. package/src/git/pr-helper.test.ts +0 -284
  149. package/src/git/pr-helper.ts +0 -307
  150. package/src/index.ts +0 -76
  151. package/src/keywords/ai-keyword-engine.ts +0 -1062
  152. package/src/keywords/ai-summarizer.ts +0 -387
  153. package/src/keywords/ci-mode.ts +0 -555
  154. package/src/keywords/engine.ts +0 -359
  155. package/src/keywords/index.ts +0 -151
  156. package/src/keywords/llm-judge.ts +0 -357
  157. package/src/keywords/nlp-analysis.ts +0 -706
  158. package/src/keywords/prioritizer.ts +0 -295
  159. package/src/keywords/site-crawler.ts +0 -342
  160. package/src/keywords/sources/autocomplete.ts +0 -139
  161. package/src/keywords/sources/competitive-search.ts +0 -450
  162. package/src/keywords/sources/competitor-analysis.ts +0 -374
  163. package/src/keywords/sources/dataforseo.ts +0 -206
  164. package/src/keywords/sources/free-sources.ts +0 -294
  165. package/src/keywords/sources/gsc.ts +0 -123
  166. package/src/keywords/topic-grouping.ts +0 -327
  167. package/src/keywords/types.ts +0 -144
  168. package/src/keywords/wizard.ts +0 -457
  169. package/src/loader.ts +0 -40
  170. package/src/ranking/index.ts +0 -5
  171. package/src/ranking/serp-client.ts +0 -348
  172. package/src/ranking/tracker.ts +0 -380
  173. package/src/ranking/types.ts +0 -123
  174. package/src/reports/index.ts +0 -7
  175. package/src/reports/report-generator.test.ts +0 -293
  176. package/src/reports/report-generator.ts +0 -713
  177. package/src/scheduler/alerts.test.ts +0 -458
  178. package/src/scheduler/alerts.ts +0 -328
  179. package/src/scheduler/index.ts +0 -8
  180. package/src/scheduler/scheduled-audit.test.ts +0 -377
  181. package/src/scheduler/scheduled-audit.ts +0 -149
  182. package/src/test/integration-test.ts +0 -325
  183. package/src/tools/analyzer.ts +0 -373
  184. package/src/tools/crawl.ts +0 -293
  185. package/src/tools/files.ts +0 -301
  186. package/src/tools/h1-fixer.ts +0 -249
  187. package/src/tools/index.ts +0 -67
  188. package/src/tracking/github-action.ts +0 -326
  189. package/src/tracking/google-analytics.ts +0 -265
  190. package/src/tracking/index.ts +0 -45
  191. package/src/tracking/report-generator.ts +0 -386
  192. package/src/tracking/search-console.ts +0 -335
  193. package/src/types.ts +0 -148
  194. package/src/utils/http.ts +0 -302
  195. package/src/wasm-adapter.ts +0 -297
  196. package/src/wasm-entry.ts +0 -14
  197. package/tsconfig.json +0 -17
  198. package/tsup.wasm.config.ts +0 -26
  199. package/vitest.config.ts +0 -15
@@ -1,273 +0,0 @@
1
- import * as cheerio from 'cheerio';
2
- import { httpHead } from '../../utils/http.js';
3
- import type { AuditIssue } from '../types.js';
4
- import { ISSUE_DEFINITIONS } from '../types.js';
5
-
6
- export interface LinkData {
7
- internal: { href: string; text: string; nofollow: boolean }[];
8
- external: { href: string; text: string; nofollow: boolean }[];
9
- totalLinks: number;
10
- brokenInternal: string[];
11
- brokenExternal: string[];
12
- jsOnlyNavigation: { element: string; text: string; reason: string }[];
13
- ratio: {
14
- internal: number;
15
- external: number;
16
- internalToExternalRatio: number | null; // null if no external links
17
- };
18
- }
19
-
20
- export async function analyzeLinks(
21
- html: string,
22
- baseUrl: string,
23
- checkBroken: boolean = false
24
- ): Promise<{ issues: AuditIssue[]; data: LinkData }> {
25
- const issues: AuditIssue[] = [];
26
- const $ = cheerio.load(html);
27
- const baseHostname = new URL(baseUrl).hostname;
28
-
29
- const internal: LinkData['internal'] = [];
30
- const external: LinkData['external'] = [];
31
- const brokenInternal: string[] = [];
32
- const brokenExternal: string[] = [];
33
- const jsOnlyNavigation: LinkData['jsOnlyNavigation'] = [];
34
-
35
- // Extract all links
36
- $('a[href]').each((_, el) => {
37
- const href = $(el).attr('href') || '';
38
- const text = $(el).text().trim();
39
- const rel = $(el).attr('rel') || '';
40
- const nofollow = rel.includes('nofollow');
41
-
42
- // Skip javascript:, mailto:, tel:, and anchor links
43
- if (href.startsWith('javascript:') || href.startsWith('mailto:') ||
44
- href.startsWith('tel:') || href.startsWith('#')) {
45
- return;
46
- }
47
-
48
- try {
49
- const fullUrl = new URL(href, baseUrl).href;
50
- const linkHostname = new URL(fullUrl).hostname;
51
- const isInternal = linkHostname === baseHostname;
52
-
53
- if (isInternal) {
54
- internal.push({ href: fullUrl, text, nofollow });
55
- if (nofollow) {
56
- issues.push({
57
- ...ISSUE_DEFINITIONS.NOFOLLOW_INTERNAL,
58
- affectedUrls: [baseUrl],
59
- details: { link: fullUrl, anchorText: text },
60
- });
61
- }
62
- } else {
63
- external.push({ href: fullUrl, text, nofollow });
64
- }
65
- } catch {
66
- // Invalid URL, skip
67
- }
68
- });
69
-
70
- const totalLinks = internal.length + external.length;
71
-
72
- // Check for JavaScript-only navigation
73
- // Look for elements with onClick that appear to be navigation
74
- const navPatterns = /navigate|router|history\.push|location\.href|window\.location|goto|redirect/i;
75
- const navTextPatterns = /^(home|about|contact|pricing|blog|docs|features|products?|services?|sign\s*up|log\s*in|register|dashboard|account|settings|help|faq|support|menu|nav)$/i;
76
-
77
- // Check buttons and other elements with onClick
78
- $('button[onclick], div[onclick], span[onclick], li[onclick]').each((_, el) => {
79
- const $el = $(el);
80
- const onclick = $el.attr('onclick') || '';
81
- const text = $el.text().trim().substring(0, 50);
82
-
83
- // Check if onClick contains navigation-like code
84
- if (navPatterns.test(onclick) || navTextPatterns.test(text)) {
85
- jsOnlyNavigation.push({
86
- element: el.tagName.toLowerCase(),
87
- text: text || '(no text)',
88
- reason: 'Element uses onClick for navigation instead of <a href>',
89
- });
90
- }
91
- });
92
-
93
- // Check <a> tags with non-functional href but onClick (common anti-pattern)
94
- $('a[onclick]').each((_, el) => {
95
- const $el = $(el);
96
- const href = $el.attr('href') || '';
97
- const onclick = $el.attr('onclick') || '';
98
- const text = $el.text().trim().substring(0, 50);
99
-
100
- // href="#" or "javascript:" with onClick is a red flag
101
- if ((href === '#' || href === '' || href.startsWith('javascript:')) && onclick) {
102
- jsOnlyNavigation.push({
103
- element: 'a',
104
- text: text || '(no text)',
105
- reason: `Link has href="${href}" with onClick - crawlers cannot follow this`,
106
- });
107
- }
108
- });
109
-
110
- // Check for React/Vue patterns in inline scripts (data-* attributes often used)
111
- $('[data-href], [data-to], [data-link], [data-route]').each((_, el) => {
112
- const $el = $(el);
113
- const tagName = el.tagName.toLowerCase();
114
- const text = $el.text().trim().substring(0, 50);
115
-
116
- // If it's not an <a> tag with a real href, it's JS-only navigation
117
- if (tagName !== 'a' || !$el.attr('href') || $el.attr('href') === '#') {
118
- jsOnlyNavigation.push({
119
- element: tagName,
120
- text: text || '(no text)',
121
- reason: 'Uses data attribute for routing instead of real href',
122
- });
123
- }
124
- });
125
-
126
- // Report JS-only navigation issues (deduplicated, limit to 10)
127
- if (jsOnlyNavigation.length > 0) {
128
- const uniqueNav = jsOnlyNavigation.slice(0, 10);
129
- issues.push({
130
- ...ISSUE_DEFINITIONS.JS_ONLY_NAVIGATION,
131
- affectedUrls: [baseUrl],
132
- details: {
133
- count: jsOnlyNavigation.length,
134
- examples: uniqueNav,
135
- },
136
- });
137
- }
138
-
139
- // Calculate link ratio
140
- const internalCount = internal.length;
141
- const externalCount = external.length;
142
- const internalToExternalRatio = externalCount > 0 ? internalCount / externalCount : null;
143
-
144
- // Check for too many links
145
- if (totalLinks > 100) {
146
- issues.push({
147
- ...ISSUE_DEFINITIONS.TOO_MANY_LINKS,
148
- affectedUrls: [baseUrl],
149
- details: { totalLinks, internal: internalCount, external: externalCount },
150
- });
151
- }
152
-
153
- // Check for no internal links (bad for crawlability and user navigation)
154
- if (internalCount === 0 && totalLinks > 0) {
155
- issues.push({
156
- code: 'LINKS_NO_INTERNAL',
157
- severity: 'warning',
158
- category: 'links',
159
- title: 'No internal links found',
160
- description: 'This page has no internal links to other pages on your site.',
161
- impact: 'Internal links are crucial for SEO. They help search engines discover pages and distribute link equity throughout your site.',
162
- howToFix: 'Add relevant internal links to related content, navigation, or related articles section.',
163
- affectedUrls: [baseUrl],
164
- details: { totalLinks, external: externalCount },
165
- });
166
- }
167
-
168
- // Check for no external links (pages should reference external resources)
169
- if (externalCount === 0 && totalLinks > 5) {
170
- issues.push({
171
- code: 'LINKS_NO_EXTERNAL',
172
- severity: 'notice',
173
- category: 'links',
174
- title: 'No external links found',
175
- description: 'This page has no links to external websites.',
176
- impact: 'Linking to high-quality external sources can improve credibility and help search engines understand your content context.',
177
- howToFix: 'Add links to authoritative external sources that support your content. This builds trust and provides value to readers.',
178
- affectedUrls: [baseUrl],
179
- details: { totalLinks, internal: internalCount },
180
- });
181
- }
182
-
183
- // Check for poor internal-to-external ratio (too many external vs internal)
184
- if (externalCount > internalCount && externalCount > 5 && internalCount < 3) {
185
- issues.push({
186
- code: 'LINKS_RATIO_POOR',
187
- severity: 'warning',
188
- category: 'links',
189
- title: 'Poor internal-to-external link ratio',
190
- description: `Page has ${externalCount} external links but only ${internalCount} internal links.`,
191
- impact: 'A healthy page should have more internal links than external links. Too many external links can dilute page authority and may look spammy.',
192
- howToFix: 'Add more relevant internal links to balance the ratio. Aim for at least 2-3 internal links for every external link.',
193
- affectedUrls: [baseUrl],
194
- details: {
195
- internal: internalCount,
196
- external: externalCount,
197
- ratio: internalToExternalRatio ? `1:${(1/internalToExternalRatio).toFixed(1)}` : 'N/A',
198
- recommendation: 'Aim for a ratio of at least 2:1 (internal:external)',
199
- },
200
- });
201
- }
202
-
203
- // Check for broken links (limited to avoid too many requests)
204
- if (checkBroken) {
205
- // Check internal links (up to 10)
206
- const internalToCheck = internal.slice(0, 10);
207
- for (const link of internalToCheck) {
208
- try {
209
- const response = await httpHead(link.href, {
210
- timeout: 5000,
211
- maxRedirects: 5,
212
- validateStatus: () => true,
213
- });
214
- if (response.status >= 400) {
215
- brokenInternal.push(link.href);
216
- }
217
- } catch {
218
- brokenInternal.push(link.href);
219
- }
220
- }
221
-
222
- // Check external links (up to 5)
223
- const externalToCheck = external.slice(0, 5);
224
- for (const link of externalToCheck) {
225
- try {
226
- const response = await httpHead(link.href, {
227
- timeout: 5000,
228
- maxRedirects: 5,
229
- validateStatus: () => true,
230
- });
231
- if (response.status >= 400) {
232
- brokenExternal.push(link.href);
233
- }
234
- } catch {
235
- // Don't count timeouts as broken for external links
236
- }
237
- }
238
-
239
- // Add issues for broken links
240
- for (const brokenLink of brokenInternal) {
241
- issues.push({
242
- ...ISSUE_DEFINITIONS.BROKEN_INTERNAL_LINK,
243
- affectedUrls: [baseUrl],
244
- details: { brokenLink },
245
- });
246
- }
247
-
248
- for (const brokenLink of brokenExternal) {
249
- issues.push({
250
- ...ISSUE_DEFINITIONS.BROKEN_EXTERNAL_LINK,
251
- affectedUrls: [baseUrl],
252
- details: { brokenLink },
253
- });
254
- }
255
- }
256
-
257
- return {
258
- issues,
259
- data: {
260
- internal,
261
- external,
262
- totalLinks,
263
- brokenInternal,
264
- brokenExternal,
265
- jsOnlyNavigation,
266
- ratio: {
267
- internal: internalCount,
268
- external: externalCount,
269
- internalToExternalRatio,
270
- },
271
- }
272
- };
273
- }
@@ -1,224 +0,0 @@
1
- /**
2
- * llms.txt Check
3
- *
4
- * llms.txt is a proposed standard (https://llmstxt.org/) for providing
5
- * context to Large Language Models about a website.
6
- *
7
- * The file is a Markdown document at /llms.txt that contains:
8
- * - Brief description of the site/organization
9
- * - Links to important pages
10
- * - Optional detailed content at /llms-full.txt
11
- *
12
- * Format:
13
- * # Site Name
14
- * > Brief description
15
- *
16
- * ## Section
17
- * - [Link Text](url): Description
18
- */
19
-
20
- import { httpGet } from '../../utils/http.js';
21
- import type { AuditIssue } from '../types.js';
22
-
23
- export interface LlmsTxtData {
24
- exists: boolean;
25
- fullVersionExists: boolean;
26
- content?: string;
27
- structure: {
28
- hasTitle: boolean;
29
- hasDescription: boolean;
30
- hasSections: boolean;
31
- hasLinks: boolean;
32
- linkCount: number;
33
- };
34
- contentLength: number;
35
- }
36
-
37
- export async function analyzeLlmsTxt(
38
- url: string
39
- ): Promise<{ issues: AuditIssue[]; data: LlmsTxtData }> {
40
- const issues: AuditIssue[] = [];
41
- const parsedUrl = new URL(url);
42
- const baseUrl = parsedUrl.origin;
43
-
44
- // Check for llms.txt
45
- const llmsTxtUrl = new URL('/llms.txt', baseUrl).href;
46
- const llmsFullUrl = new URL('/llms-full.txt', baseUrl).href;
47
-
48
- let exists = false;
49
- let fullVersionExists = false;
50
- let content: string | undefined;
51
- let structure = {
52
- hasTitle: false,
53
- hasDescription: false,
54
- hasSections: false,
55
- hasLinks: false,
56
- linkCount: 0,
57
- };
58
- let contentLength = 0;
59
-
60
- try {
61
- // Check main llms.txt
62
- const response = await httpGet<string>(llmsTxtUrl, {
63
- timeout: 10000,
64
- validateStatus: () => true,
65
- });
66
-
67
- if (response.status === 200) {
68
- exists = true;
69
- content = response.data as string;
70
- contentLength = content.length;
71
- structure = analyzeStructure(content);
72
- }
73
-
74
- // Check for full version
75
- const fullResponse = await httpGet<string>(llmsFullUrl, {
76
- timeout: 10000,
77
- validateStatus: () => true,
78
- });
79
-
80
- if (fullResponse.status === 200) {
81
- fullVersionExists = true;
82
- }
83
- } catch {
84
- // Network error, treat as not existing
85
- }
86
-
87
- // Generate issues
88
- if (!exists) {
89
- issues.push({
90
- code: 'AI_NO_LLMS_TXT',
91
- severity: 'notice',
92
- category: 'ai-readiness',
93
- title: 'No llms.txt file found',
94
- description: 'llms.txt is a proposed standard for providing context to LLMs about your website. Having one helps AI systems better understand and represent your site.',
95
- impact: 'AI systems may have less context about your site, potentially leading to less accurate representations.',
96
- howToFix: 'Create an /llms.txt file with a Markdown description of your site. Include: site name, brief description, and links to key pages. See https://llmstxt.org/ for the specification.',
97
- affectedUrls: [llmsTxtUrl],
98
- details: {
99
- specification: 'https://llmstxt.org/',
100
- exampleFormat: `# Site Name
101
-
102
- > Brief description of your site
103
-
104
- ## About
105
- - [About Us](/about): Learn more about our company
106
-
107
- ## Products
108
- - [Product A](/products/a): Description of product A
109
- - [Product B](/products/b): Description of product B
110
-
111
- ## Documentation
112
- - [Docs](/docs): Full documentation`,
113
- },
114
- });
115
- } else {
116
- // Check structure quality
117
- if (!structure.hasTitle) {
118
- issues.push({
119
- code: 'AI_LLMS_TXT_NO_TITLE',
120
- severity: 'notice',
121
- category: 'ai-readiness',
122
- title: 'llms.txt missing title heading',
123
- description: 'Your llms.txt file should start with a # heading containing your site/organization name.',
124
- impact: 'LLMs may not properly identify your site.',
125
- howToFix: 'Add a title heading at the top: # Your Site Name',
126
- affectedUrls: [llmsTxtUrl],
127
- });
128
- }
129
-
130
- if (!structure.hasDescription) {
131
- issues.push({
132
- code: 'AI_LLMS_TXT_NO_DESCRIPTION',
133
- severity: 'notice',
134
- category: 'ai-readiness',
135
- title: 'llms.txt missing description',
136
- description: 'Your llms.txt should include a brief description (blockquote starting with >) explaining what your site/organization does.',
137
- impact: 'LLMs may not understand your site\'s purpose.',
138
- howToFix: 'Add a description blockquote after the title: > Brief description of your site',
139
- affectedUrls: [llmsTxtUrl],
140
- });
141
- }
142
-
143
- if (!structure.hasLinks || structure.linkCount < 3) {
144
- issues.push({
145
- code: 'AI_LLMS_TXT_FEW_LINKS',
146
- severity: 'notice',
147
- category: 'ai-readiness',
148
- title: 'llms.txt has few navigation links',
149
- description: `Your llms.txt only has ${structure.linkCount} link(s). Include links to your most important pages to help LLMs navigate your content.`,
150
- impact: 'LLMs may miss important content on your site.',
151
- howToFix: 'Add more links in Markdown format: - [Page Title](/path): Brief description',
152
- affectedUrls: [llmsTxtUrl],
153
- });
154
- }
155
-
156
- if (contentLength < 200) {
157
- issues.push({
158
- code: 'AI_LLMS_TXT_TOO_SHORT',
159
- severity: 'notice',
160
- category: 'ai-readiness',
161
- title: 'llms.txt content is very short',
162
- description: `Your llms.txt is only ${contentLength} characters. Consider adding more context about your site.`,
163
- impact: 'LLMs may not have enough context to properly represent your site.',
164
- howToFix: 'Expand your llms.txt with more sections, descriptions, and links to key content.',
165
- affectedUrls: [llmsTxtUrl],
166
- });
167
- }
168
- }
169
-
170
- return {
171
- issues,
172
- data: {
173
- exists,
174
- fullVersionExists,
175
- content: content?.substring(0, 1000), // Truncate for data
176
- structure,
177
- contentLength,
178
- },
179
- };
180
- }
181
-
182
- function analyzeStructure(content: string): LlmsTxtData['structure'] {
183
- const lines = content.split('\n');
184
-
185
- let hasTitle = false;
186
- let hasDescription = false;
187
- let hasSections = false;
188
- let hasLinks = false;
189
- let linkCount = 0;
190
-
191
- for (const line of lines) {
192
- const trimmed = line.trim();
193
-
194
- // Check for title (# heading at start)
195
- if (trimmed.startsWith('# ') && !trimmed.startsWith('## ')) {
196
- hasTitle = true;
197
- }
198
-
199
- // Check for description (blockquote)
200
- if (trimmed.startsWith('>')) {
201
- hasDescription = true;
202
- }
203
-
204
- // Check for sections (## headings)
205
- if (trimmed.startsWith('## ')) {
206
- hasSections = true;
207
- }
208
-
209
- // Check for Markdown links
210
- const linkMatches = trimmed.match(/\[([^\]]+)\]\(([^)]+)\)/g);
211
- if (linkMatches) {
212
- hasLinks = true;
213
- linkCount += linkMatches.length;
214
- }
215
- }
216
-
217
- return {
218
- hasTitle,
219
- hasDescription,
220
- hasSections,
221
- hasLinks,
222
- linkCount,
223
- };
224
- }