@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,473 +0,0 @@
1
- // Featured Snippet Optimization Checks
2
- // Based on advanced SEO research: optimizing content for featured snippets
3
- // Includes: definition format, list format, table format, Q&A structure
4
-
5
- import * as cheerio from 'cheerio';
6
- import type { AuditIssue } from '../types.js';
7
-
8
- export interface SnippetOpportunity {
9
- type: 'definition' | 'list' | 'table' | 'paragraph' | 'qa';
10
- heading: string;
11
- score: number; // 0-100 optimization score
12
- issues: string[];
13
- suggestions: string[];
14
- }
15
-
16
- export interface FeaturedSnippetData {
17
- hasDefinitionFormat: boolean;
18
- hasListFormat: boolean;
19
- hasTableFormat: boolean;
20
- hasQAFormat: boolean;
21
- hasInvertedPyramid: boolean;
22
- opportunities: SnippetOpportunity[];
23
- faqSchemaPresent: boolean;
24
- howToSchemaPresent: boolean;
25
- questionHeadingsCount: number;
26
- }
27
-
28
- /**
29
- * Detect definition-style content (optimal for "what is" snippets)
30
- * Pattern: "X is a/an [noun] that..."
31
- */
32
- export function detectDefinitionFormat(html: string): {
33
- found: boolean;
34
- definitions: Array<{ term: string; definition: string }>;
35
- } {
36
- const $ = cheerio.load(html);
37
- const definitions: Array<{ term: string; definition: string }> = [];
38
-
39
- // Check for <dfn> tags
40
- $('dfn').each((_, el) => {
41
- const term = $(el).text().trim();
42
- const parent = $(el).parent().text().trim();
43
- if (term && parent) {
44
- definitions.push({ term, definition: parent });
45
- }
46
- });
47
-
48
- // Check for "X is a/an" patterns in paragraphs following H2/H3
49
- $('h2, h3').each((_, el) => {
50
- const heading = $(el).text().trim();
51
- const nextP = $(el).next('p').text().trim();
52
-
53
- // Pattern: starts with a noun phrase and "is a/an"
54
- const definitionPattern = /^([\w\s]+)\s+is\s+(?:a|an|the)\s+[\w\s]+(?:that|which|who)/i;
55
- const match = nextP.match(definitionPattern);
56
-
57
- if (match) {
58
- definitions.push({ term: match[1].trim(), definition: nextP.substring(0, 200) });
59
- }
60
- });
61
-
62
- return { found: definitions.length > 0, definitions };
63
- }
64
-
65
- /**
66
- * Detect list-format content (optimal for "how to" and "best X" snippets)
67
- */
68
- export function detectListFormat(html: string): {
69
- found: boolean;
70
- lists: Array<{ type: 'ol' | 'ul'; itemCount: number; context: string }>;
71
- } {
72
- const $ = cheerio.load(html);
73
- const lists: Array<{ type: 'ol' | 'ul'; itemCount: number; context: string }> = [];
74
-
75
- // Find ordered lists after headings
76
- $('h2, h3').each((_, el) => {
77
- const heading = $(el).text().trim();
78
- const nextEl = $(el).next();
79
-
80
- if (nextEl.is('ol')) {
81
- const items = nextEl.find('li').length;
82
- if (items >= 3 && items <= 10) {
83
- lists.push({ type: 'ol', itemCount: items, context: heading });
84
- }
85
- } else if (nextEl.is('ul')) {
86
- const items = nextEl.find('li').length;
87
- if (items >= 3 && items <= 10) {
88
- lists.push({ type: 'ul', itemCount: items, context: heading });
89
- }
90
- }
91
- });
92
-
93
- return { found: lists.length > 0, lists };
94
- }
95
-
96
- /**
97
- * Detect table-format content (optimal for comparison snippets)
98
- */
99
- export function detectTableFormat(html: string): {
100
- found: boolean;
101
- tables: Array<{ hasHeaders: boolean; rows: number; cols: number }>;
102
- } {
103
- const $ = cheerio.load(html);
104
- const tables: Array<{ hasHeaders: boolean; rows: number; cols: number }> = [];
105
-
106
- $('table').each((_, el) => {
107
- const $table = $(el);
108
- const hasHeaders = $table.find('th').length > 0 || $table.find('thead').length > 0;
109
- const rows = $table.find('tr').length;
110
- const cols = $table.find('tr').first().find('td, th').length;
111
-
112
- // Good snippet tables have 3-5 columns and 4-10 rows
113
- if (cols >= 2 && cols <= 6 && rows >= 3 && rows <= 15) {
114
- tables.push({ hasHeaders, rows, cols });
115
- }
116
- });
117
-
118
- return { found: tables.length > 0, tables };
119
- }
120
-
121
- /**
122
- * Detect Q&A format content (optimal for PAA boxes and FAQ snippets)
123
- */
124
- export function detectQAFormat(html: string): {
125
- found: boolean;
126
- qaCount: number;
127
- questions: string[];
128
- } {
129
- const $ = cheerio.load(html);
130
- const questions: string[] = [];
131
-
132
- // Question patterns in headings
133
- const questionPatterns = [
134
- /^what\s+/i,
135
- /^how\s+/i,
136
- /^why\s+/i,
137
- /^when\s+/i,
138
- /^where\s+/i,
139
- /^who\s+/i,
140
- /^which\s+/i,
141
- /^can\s+/i,
142
- /^does\s+/i,
143
- /^is\s+/i,
144
- /^are\s+/i,
145
- /^should\s+/i,
146
- /\?$/,
147
- ];
148
-
149
- // Check H2-H4 headings for questions
150
- $('h2, h3, h4').each((_, el) => {
151
- const text = $(el).text().trim();
152
- for (const pattern of questionPatterns) {
153
- if (pattern.test(text)) {
154
- questions.push(text);
155
- break;
156
- }
157
- }
158
- });
159
-
160
- // Check for FAQ sections
161
- const hasFaqSection =
162
- $('section.faq, div.faq, #faq, .faqs, [data-faq]').length > 0 ||
163
- $('h2, h3').text().toLowerCase().includes('faq') ||
164
- $('h2, h3').text().toLowerCase().includes('frequently asked');
165
-
166
- // Check for details/summary elements (accordion FAQs)
167
- $('details summary').each((_, el) => {
168
- const text = $(el).text().trim();
169
- if (text.endsWith('?') || questionPatterns.some((p) => p.test(text))) {
170
- questions.push(text);
171
- }
172
- });
173
-
174
- return { found: questions.length > 0 || hasFaqSection, qaCount: questions.length, questions };
175
- }
176
-
177
- /**
178
- * Check for inverted pyramid structure (key info first)
179
- */
180
- export function detectInvertedPyramid(html: string): { found: boolean; score: number } {
181
- const $ = cheerio.load(html);
182
-
183
- // Remove non-content elements
184
- $('script, style, nav, header, footer, aside').remove();
185
-
186
- // Get first paragraph after H1
187
- const h1 = $('h1').first();
188
- const firstContent = h1.nextAll('p').first().text().trim();
189
-
190
- if (!firstContent) {
191
- return { found: false, score: 0 };
192
- }
193
-
194
- // Check for answer patterns in first paragraph
195
- const answerPatterns = [
196
- /^the\s+answer\s+is/i,
197
- /^yes[,\s]/i,
198
- /^no[,\s]/i,
199
- /^in\s+short/i,
200
- /^to\s+summarize/i,
201
- /^([\w\s]+)\s+is\s+/i, // Definition pattern
202
- /^\d+/i, // Starts with number
203
- /^the\s+best\s+/i,
204
- /^you\s+(can|should|need)/i,
205
- ];
206
-
207
- let score = 0;
208
-
209
- // Check if first paragraph contains direct answer
210
- for (const pattern of answerPatterns) {
211
- if (pattern.test(firstContent)) {
212
- score += 30;
213
- break;
214
- }
215
- }
216
-
217
- // Check word count of first paragraph (should be concise: 40-80 words)
218
- const wordCount = firstContent.split(/\s+/).length;
219
- if (wordCount >= 40 && wordCount <= 100) {
220
- score += 30;
221
- } else if (wordCount > 0 && wordCount < 40) {
222
- score += 15;
223
- }
224
-
225
- // Check if key terms from title appear in first paragraph
226
- const title = $('title').text().toLowerCase();
227
- const titleWords = title
228
- .replace(/[^a-z0-9\s]/g, '')
229
- .split(/\s+/)
230
- .filter((w) => w.length > 3);
231
-
232
- const firstParaLower = firstContent.toLowerCase();
233
- const matchingWords = titleWords.filter((w) => firstParaLower.includes(w));
234
- const titleMatchRatio = titleWords.length > 0 ? matchingWords.length / titleWords.length : 0;
235
-
236
- if (titleMatchRatio > 0.5) {
237
- score += 40;
238
- } else if (titleMatchRatio > 0.25) {
239
- score += 20;
240
- }
241
-
242
- return { found: score >= 50, score: Math.min(score, 100) };
243
- }
244
-
245
- /**
246
- * Check for structured data that supports snippets
247
- */
248
- export function detectSnippetSchema(html: string): {
249
- hasFaqSchema: boolean;
250
- hasHowToSchema: boolean;
251
- hasQASchema: boolean;
252
- } {
253
- const $ = cheerio.load(html);
254
-
255
- let hasFaqSchema = false;
256
- let hasHowToSchema = false;
257
- let hasQASchema = false;
258
-
259
- // Check JSON-LD scripts
260
- $('script[type="application/ld+json"]').each((_, el) => {
261
- try {
262
- const data = JSON.parse($(el).html() || '');
263
- const types = Array.isArray(data) ? data.map((d) => d['@type']) : [data['@type']];
264
-
265
- if (types.includes('FAQPage') || types.some((t) => t?.includes?.('FAQPage'))) {
266
- hasFaqSchema = true;
267
- }
268
- if (types.includes('HowTo') || types.some((t) => t?.includes?.('HowTo'))) {
269
- hasHowToSchema = true;
270
- }
271
- if (types.includes('QAPage') || types.some((t) => t?.includes?.('QAPage'))) {
272
- hasQASchema = true;
273
- }
274
- } catch {
275
- // Invalid JSON
276
- }
277
- });
278
-
279
- return { hasFaqSchema, hasHowToSchema, hasQASchema };
280
- }
281
-
282
- /**
283
- * Analyze snippet bait headers (trigger words for featured snippets)
284
- */
285
- export function analyzeSnippetBaitHeaders(html: string): string[] {
286
- const $ = cheerio.load(html);
287
- const snippetBaitHeaders: string[] = [];
288
-
289
- // High-value snippet trigger patterns
290
- const triggerPatterns = [
291
- /^what\s+is\s+/i,
292
- /^how\s+to\s+/i,
293
- /^how\s+do\s+/i,
294
- /^how\s+does\s+/i,
295
- /^why\s+is\s+/i,
296
- /^why\s+do\s+/i,
297
- /^why\s+does\s+/i,
298
- /^when\s+to\s+/i,
299
- /^where\s+to\s+/i,
300
- /^\d+\s+(ways|tips|steps|reasons|benefits|examples)/i,
301
- /^(best|top)\s+\d+/i,
302
- /^(guide|tutorial):/i,
303
- /\s+vs\s+/i,
304
- /^definition\s+of/i,
305
- ];
306
-
307
- $('h2, h3').each((_, el) => {
308
- const text = $(el).text().trim();
309
- for (const pattern of triggerPatterns) {
310
- if (pattern.test(text)) {
311
- snippetBaitHeaders.push(text);
312
- break;
313
- }
314
- }
315
- });
316
-
317
- return snippetBaitHeaders;
318
- }
319
-
320
- /**
321
- * Main function: Analyze page for featured snippet optimization
322
- */
323
- export function analyzeFeaturedSnippet(
324
- html: string,
325
- url: string
326
- ): { issues: AuditIssue[]; data: FeaturedSnippetData } {
327
- const issues: AuditIssue[] = [];
328
-
329
- const definitions = detectDefinitionFormat(html);
330
- const lists = detectListFormat(html);
331
- const tables = detectTableFormat(html);
332
- const qa = detectQAFormat(html);
333
- const invertedPyramid = detectInvertedPyramid(html);
334
- const schema = detectSnippetSchema(html);
335
- const snippetBaitHeaders = analyzeSnippetBaitHeaders(html);
336
-
337
- const opportunities: SnippetOpportunity[] = [];
338
-
339
- // Analyze definition opportunities
340
- if (!definitions.found) {
341
- opportunities.push({
342
- type: 'definition',
343
- heading: 'Missing definition format',
344
- score: 0,
345
- issues: ['No clear definition patterns found'],
346
- suggestions: [
347
- 'Add a paragraph starting with "[Topic] is a [noun] that..." after your main heading',
348
- 'Use <dfn> tags for key term definitions',
349
- 'Keep definitions concise (40-60 words)',
350
- ],
351
- });
352
- }
353
-
354
- // Analyze list opportunities
355
- if (lists.found) {
356
- for (const list of lists.lists) {
357
- if (!list.context.toLowerCase().match(/^\d+|^(how|steps|tips|ways)/)) {
358
- opportunities.push({
359
- type: 'list',
360
- heading: list.context,
361
- score: 70,
362
- issues: ['List heading could be more snippet-friendly'],
363
- suggestions: [
364
- 'Consider rephrasing to "X Steps to..." or "Top X Tips for..."',
365
- 'Ensure list items are parallel in structure',
366
- ],
367
- });
368
- }
369
- }
370
- } else {
371
- opportunities.push({
372
- type: 'list',
373
- heading: 'Missing list content',
374
- score: 0,
375
- issues: ['No optimized lists found for snippet targeting'],
376
- suggestions: [
377
- 'Add numbered or bulleted lists with 4-8 items',
378
- 'Use headers like "Steps to...", "Ways to...", or "Top X..."',
379
- 'Keep list items concise and parallel in structure',
380
- ],
381
- });
382
- }
383
-
384
- // Analyze table opportunities
385
- if (!tables.found) {
386
- opportunities.push({
387
- type: 'table',
388
- heading: 'No comparison tables',
389
- score: 0,
390
- issues: ['No tables optimized for comparison snippets'],
391
- suggestions: [
392
- 'Add comparison tables with clear headers',
393
- 'Use 3-5 columns and 4-10 rows for optimal snippet display',
394
- 'Include thead with th elements for proper table structure',
395
- ],
396
- });
397
- }
398
-
399
- // Analyze Q&A opportunities
400
- if (qa.found && qa.qaCount > 0) {
401
- if (!schema.hasFaqSchema && qa.qaCount >= 3) {
402
- issues.push({
403
- code: 'FAQ_SCHEMA_MISSING',
404
- severity: 'warning',
405
- category: 'structured-data',
406
- title: 'FAQ content without FAQPage schema',
407
- description: `Found ${qa.qaCount} question-format headings but no FAQPage schema markup.`,
408
- impact: 'Missing out on FAQ rich results and PAA box opportunities.',
409
- howToFix: 'Add FAQPage structured data for your Q&A content.',
410
- affectedUrls: [url],
411
- details: { questions: qa.questions.slice(0, 5) },
412
- });
413
- }
414
- } else {
415
- opportunities.push({
416
- type: 'qa',
417
- heading: 'Missing Q&A content',
418
- score: 0,
419
- issues: ['No question-format headers found'],
420
- suggestions: [
421
- 'Add H2/H3 headings in question format (What is..., How to..., Why does...)',
422
- 'Follow each question heading with a direct answer paragraph',
423
- 'Consider adding a FAQ section with 3-5 common questions',
424
- ],
425
- });
426
- }
427
-
428
- // Analyze inverted pyramid
429
- if (!invertedPyramid.found) {
430
- issues.push({
431
- code: 'INVERTED_PYRAMID_MISSING',
432
- severity: 'notice',
433
- category: 'content',
434
- title: 'Content not structured for featured snippets',
435
- description: 'First paragraph does not contain a direct answer or summary.',
436
- impact: 'Featured snippets pull from early content; burying answers reduces snippet capture rate.',
437
- howToFix: 'Start with a concise answer (40-80 words) that directly addresses the page topic.',
438
- affectedUrls: [url],
439
- details: { invertedPyramidScore: invertedPyramid.score },
440
- });
441
- }
442
-
443
- // Check for snippet bait headers
444
- if (snippetBaitHeaders.length === 0) {
445
- issues.push({
446
- code: 'NO_SNIPPET_BAIT_HEADERS',
447
- severity: 'notice',
448
- category: 'on-page',
449
- title: 'No snippet-targeting headers found',
450
- description: 'Headings do not use patterns that commonly trigger featured snippets.',
451
- impact: 'Missing opportunities for high-visibility snippet placements.',
452
- howToFix:
453
- 'Use headers like "What is [topic]?", "How to [action]", or "X Ways to [achieve goal]".',
454
- affectedUrls: [url],
455
- details: { suggestedPatterns: ['What is X?', 'How to X', 'X Steps to Y', 'Best X for Y'] },
456
- });
457
- }
458
-
459
- return {
460
- issues,
461
- data: {
462
- hasDefinitionFormat: definitions.found,
463
- hasListFormat: lists.found,
464
- hasTableFormat: tables.found,
465
- hasQAFormat: qa.found,
466
- hasInvertedPyramid: invertedPyramid.found,
467
- opportunities,
468
- faqSchemaPresent: schema.hasFaqSchema,
469
- howToSchemaPresent: schema.hasHowToSchema,
470
- questionHeadingsCount: qa.qaCount,
471
- },
472
- };
473
- }