@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,317 +0,0 @@
1
- // Headline Analysis & Optimization
2
- // Scores headlines for SEO and engagement effectiveness
3
-
4
- export interface HeadlineAnalysis {
5
- headline: string;
6
- score: number; // 0-100
7
- wordCount: number;
8
- charCount: number;
9
- // Score breakdown
10
- breakdown: {
11
- length: number;
12
- powerWords: number;
13
- emotionalWords: number;
14
- numbers: number;
15
- readability: number;
16
- uniqueness: number;
17
- };
18
- // Issues and suggestions
19
- issues: string[];
20
- suggestions: string[];
21
- // Classification
22
- type: 'how-to' | 'list' | 'question' | 'statement' | 'guide' | 'other';
23
- sentiment: 'positive' | 'negative' | 'neutral';
24
- }
25
-
26
- // Power words that drive engagement
27
- const POWER_WORDS = new Set([
28
- 'ultimate', 'essential', 'proven', 'powerful', 'incredible', 'amazing',
29
- 'exclusive', 'secret', 'free', 'new', 'best', 'top', 'complete', 'simple',
30
- 'easy', 'quick', 'fast', 'instant', 'guaranteed', 'effective', 'brilliant',
31
- 'stunning', 'remarkable', 'exceptional', 'revolutionary', 'breakthrough',
32
- 'transform', 'discover', 'unlock', 'master', 'boost', 'skyrocket', 'crush',
33
- ]);
34
-
35
- // Emotional trigger words
36
- const EMOTIONAL_WORDS = new Set([
37
- 'love', 'hate', 'fear', 'anxiety', 'stress', 'happy', 'sad', 'angry',
38
- 'frustrated', 'excited', 'thrilled', 'terrified', 'worried', 'confident',
39
- 'surprising', 'shocking', 'devastating', 'inspiring', 'heartwarming',
40
- 'painful', 'embarrassing', 'awkward', 'dangerous', 'risky', 'safe',
41
- ]);
42
-
43
- // Common/weak words to avoid
44
- const WEAK_WORDS = new Set([
45
- 'things', 'stuff', 'very', 'really', 'just', 'actually', 'basically',
46
- 'literally', 'nice', 'good', 'great', 'awesome', 'cool', 'interesting',
47
- ]);
48
-
49
- /**
50
- * Analyze headline effectiveness
51
- */
52
- export function analyzeHeadline(headline: string): HeadlineAnalysis {
53
- const words = headline.toLowerCase().split(/\s+/).filter(w => w.length > 0);
54
- const wordCount = words.length;
55
- const charCount = headline.length;
56
-
57
- const issues: string[] = [];
58
- const suggestions: string[] = [];
59
-
60
- // Score components
61
- const breakdown = {
62
- length: 0,
63
- powerWords: 0,
64
- emotionalWords: 0,
65
- numbers: 0,
66
- readability: 0,
67
- uniqueness: 0,
68
- };
69
-
70
- // 1. Length score (ideal: 6-12 words, 50-60 chars for SEO)
71
- if (wordCount >= 6 && wordCount <= 12) {
72
- breakdown.length = 25;
73
- } else if (wordCount >= 4 && wordCount <= 15) {
74
- breakdown.length = 15;
75
- } else if (wordCount < 4) {
76
- breakdown.length = 5;
77
- issues.push('Too short - aim for 6-12 words');
78
- suggestions.push('Add more descriptive words to convey value');
79
- } else {
80
- breakdown.length = 10;
81
- issues.push('Too long - may get truncated in SERPs');
82
- suggestions.push('Trim to under 60 characters for display');
83
- }
84
-
85
- if (charCount <= 60) {
86
- breakdown.length += 5;
87
- } else if (charCount <= 70) {
88
- breakdown.length += 2;
89
- } else {
90
- issues.push(`Title is ${charCount} chars (${charCount - 60} over limit)`);
91
- }
92
-
93
- // 2. Power words
94
- const powerWordCount = words.filter(w => POWER_WORDS.has(w.replace(/[^a-z]/g, ''))).length;
95
- if (powerWordCount >= 2) {
96
- breakdown.powerWords = 20;
97
- } else if (powerWordCount === 1) {
98
- breakdown.powerWords = 15;
99
- suggestions.push('Add another power word for more impact');
100
- } else {
101
- breakdown.powerWords = 0;
102
- suggestions.push('Include power words like: ultimate, proven, essential, free');
103
- }
104
-
105
- // 3. Emotional words
106
- const emotionalCount = words.filter(w => EMOTIONAL_WORDS.has(w.replace(/[^a-z]/g, ''))).length;
107
- if (emotionalCount >= 1) {
108
- breakdown.emotionalWords = 15;
109
- } else {
110
- breakdown.emotionalWords = 5;
111
- suggestions.push('Consider adding emotional trigger words for engagement');
112
- }
113
-
114
- // 4. Numbers (lists perform well)
115
- const hasNumber = /\d+/.test(headline);
116
- if (hasNumber) {
117
- breakdown.numbers = 15;
118
- // Odd numbers perform better
119
- const numbers = headline.match(/\d+/g) || [];
120
- const hasOddNumber = numbers.some(n => parseInt(n) % 2 !== 0);
121
- if (hasOddNumber) {
122
- breakdown.numbers += 5;
123
- }
124
- } else {
125
- breakdown.numbers = 0;
126
- suggestions.push('Consider adding a number (e.g., "7 Ways to...", "5 Tips for...")');
127
- }
128
-
129
- // 5. Readability
130
- const weakWordCount = words.filter(w => WEAK_WORDS.has(w)).length;
131
- if (weakWordCount === 0) {
132
- breakdown.readability = 15;
133
- } else {
134
- breakdown.readability = Math.max(0, 15 - weakWordCount * 5);
135
- issues.push(`Contains weak/vague words: ${words.filter(w => WEAK_WORDS.has(w)).join(', ')}`);
136
- }
137
-
138
- // Check for sentence case (Title Case vs sentence case)
139
- const titleCaseWords = words.filter((w, i) => i > 0 && /^[A-Z]/.test(headline.split(/\s+/)[i]));
140
- if (titleCaseWords.length > words.length * 0.7) {
141
- suggestions.push('Consider sentence case instead of Title Case for better readability');
142
- }
143
-
144
- // 6. Uniqueness (check for clichés)
145
- const cliches = [
146
- 'you need to know',
147
- 'you won\'t believe',
148
- 'the truth about',
149
- 'everything you need',
150
- 'game changer',
151
- 'must read',
152
- ];
153
- const hasCliche = cliches.some(c => headline.toLowerCase().includes(c));
154
- if (hasCliche) {
155
- breakdown.uniqueness = 5;
156
- issues.push('Contains overused phrases/clichés');
157
- suggestions.push('Try a more original angle or phrasing');
158
- } else {
159
- breakdown.uniqueness = 10;
160
- }
161
-
162
- // Classify headline type
163
- const type = classifyHeadlineType(headline);
164
-
165
- // Determine sentiment
166
- const sentiment = analyzeSentiment(words);
167
-
168
- // Calculate total score
169
- const score = Math.min(100,
170
- breakdown.length +
171
- breakdown.powerWords +
172
- breakdown.emotionalWords +
173
- breakdown.numbers +
174
- breakdown.readability +
175
- breakdown.uniqueness
176
- );
177
-
178
- // Add type-specific suggestions
179
- if (type === 'question' && !headline.endsWith('?')) {
180
- suggestions.push('Question headlines should end with a question mark');
181
- }
182
-
183
- if (type === 'how-to' && !headline.toLowerCase().startsWith('how to')) {
184
- suggestions.push('Ensure "How to" appears at the beginning for clarity');
185
- }
186
-
187
- return {
188
- headline,
189
- score,
190
- wordCount,
191
- charCount,
192
- breakdown,
193
- issues,
194
- suggestions,
195
- type,
196
- sentiment,
197
- };
198
- }
199
-
200
- function classifyHeadlineType(headline: string): HeadlineAnalysis['type'] {
201
- const h = headline.toLowerCase();
202
-
203
- if (h.startsWith('how to') || h.includes('how to')) return 'how-to';
204
- if (/^\d+\s/.test(h) || /\btop\s+\d+\b/.test(h)) return 'list';
205
- if (h.endsWith('?') || h.startsWith('what') || h.startsWith('why') || h.startsWith('when')) return 'question';
206
- if (h.includes('guide') || h.includes('tutorial')) return 'guide';
207
- if (/^(the|a|an)\s/i.test(h)) return 'statement';
208
-
209
- return 'other';
210
- }
211
-
212
- function analyzeSentiment(words: string[]): HeadlineAnalysis['sentiment'] {
213
- const positiveWords = new Set(['best', 'top', 'amazing', 'great', 'success', 'win', 'boost', 'improve', 'easy', 'free', 'new']);
214
- const negativeWords = new Set(['worst', 'bad', 'fail', 'mistake', 'avoid', 'stop', 'never', 'wrong', 'problem', 'risk', 'danger']);
215
-
216
- let positiveCount = 0;
217
- let negativeCount = 0;
218
-
219
- for (const word of words) {
220
- const w = word.replace(/[^a-z]/g, '');
221
- if (positiveWords.has(w)) positiveCount++;
222
- if (negativeWords.has(w)) negativeCount++;
223
- }
224
-
225
- if (positiveCount > negativeCount) return 'positive';
226
- if (negativeCount > positiveCount) return 'negative';
227
- return 'neutral';
228
- }
229
-
230
- /**
231
- * Generate headline variations
232
- */
233
- export function generateHeadlineVariations(topic: string, keywords: string[]): string[] {
234
- const variations: string[] = [];
235
- const mainKeyword = keywords[0] || topic;
236
-
237
- // How-to format
238
- variations.push(`How to ${topic} in ${Math.floor(Math.random() * 5) + 3} Simple Steps`);
239
- variations.push(`How to ${topic}: A Complete Guide`);
240
-
241
- // List format (odd numbers perform better)
242
- const oddNumbers = [3, 5, 7, 9, 11, 13];
243
- const num = oddNumbers[Math.floor(Math.random() * oddNumbers.length)];
244
- variations.push(`${num} Proven Ways to ${topic}`);
245
- variations.push(`${num} ${mainKeyword} Tips That Actually Work`);
246
-
247
- // Question format
248
- variations.push(`What Is ${topic}? Everything You Need to Know`);
249
- variations.push(`Why ${topic} Matters More Than Ever in ${new Date().getFullYear()}`);
250
-
251
- // Statement with power words
252
- variations.push(`The Ultimate Guide to ${topic}`);
253
- variations.push(`${topic}: The Complete ${new Date().getFullYear()} Guide`);
254
-
255
- // Problem/solution
256
- variations.push(`${topic} Made Simple: A Beginner's Guide`);
257
- variations.push(`Master ${topic} Without the Confusion`);
258
-
259
- return variations;
260
- }
261
-
262
- /**
263
- * Format headline analysis report
264
- */
265
- export function formatHeadlineReport(analysis: HeadlineAnalysis): string {
266
- const lines: string[] = [];
267
-
268
- lines.push('');
269
- lines.push('═'.repeat(60));
270
- lines.push(' HEADLINE ANALYSIS');
271
- lines.push('═'.repeat(60));
272
- lines.push('');
273
-
274
- // Headline and score
275
- lines.push(`"${analysis.headline}"`);
276
- lines.push('');
277
-
278
- const scoreIcon = analysis.score >= 70 ? '🟢' : analysis.score >= 50 ? '🟡' : '🔴';
279
- lines.push(`${scoreIcon} Score: ${analysis.score}/100`);
280
- lines.push(` Type: ${analysis.type} | Sentiment: ${analysis.sentiment}`);
281
- lines.push(` Length: ${analysis.wordCount} words, ${analysis.charCount} chars`);
282
- lines.push('');
283
-
284
- // Score breakdown
285
- lines.push('📊 SCORE BREAKDOWN');
286
- lines.push('─'.repeat(60));
287
- lines.push(` Length: ${analysis.breakdown.length}/30`);
288
- lines.push(` Power Words: ${analysis.breakdown.powerWords}/20`);
289
- lines.push(` Emotion: ${analysis.breakdown.emotionalWords}/15`);
290
- lines.push(` Numbers: ${analysis.breakdown.numbers}/20`);
291
- lines.push(` Readability: ${analysis.breakdown.readability}/15`);
292
- lines.push('');
293
-
294
- // Issues
295
- if (analysis.issues.length > 0) {
296
- lines.push('⚠️ ISSUES');
297
- lines.push('─'.repeat(60));
298
- for (const issue of analysis.issues) {
299
- lines.push(` • ${issue}`);
300
- }
301
- lines.push('');
302
- }
303
-
304
- // Suggestions
305
- if (analysis.suggestions.length > 0) {
306
- lines.push('💡 SUGGESTIONS');
307
- lines.push('─'.repeat(60));
308
- for (const suggestion of analysis.suggestions) {
309
- lines.push(` • ${suggestion}`);
310
- }
311
- lines.push('');
312
- }
313
-
314
- lines.push('═'.repeat(60));
315
-
316
- return lines.join('\n');
317
- }
@@ -1,62 +0,0 @@
1
- // Content Analysis & Optimization Module
2
- // Tools for analyzing and optimizing content for SEO
3
-
4
- // Readability Analysis
5
- export {
6
- analyzeReadability,
7
- formatReadabilityReport,
8
- type ReadabilityResult,
9
- } from './readability.js';
10
-
11
- // Search Intent Classification
12
- export {
13
- classifyIntent,
14
- classifyIntents,
15
- formatIntentReport,
16
- type SearchIntent,
17
- type IntentAnalysis,
18
- } from './intent.js';
19
-
20
- // Headline Analysis
21
- export {
22
- analyzeHeadline,
23
- generateHeadlineVariations,
24
- formatHeadlineReport,
25
- type HeadlineAnalysis,
26
- } from './headline.js';
27
-
28
- // Featured Snippet Optimization
29
- export {
30
- analyzeFeaturedSnippetPotential,
31
- formatFeaturedSnippetReport,
32
- type SnippetType,
33
- type FeaturedSnippetAnalysis,
34
- type SnippetRecommendation,
35
- } from './featured-snippet.js';
36
-
37
- // Keyword Density & LSI
38
- export {
39
- analyzeKeywordDensity,
40
- findLSIKeywords,
41
- calculateTFIDF,
42
- formatKeywordDensityReport,
43
- type KeywordDensityAnalysis,
44
- type LSIKeyword,
45
- type ContentElements,
46
- } from './keyword-density.js';
47
-
48
- // Content Generation
49
- export {
50
- generateBlogPost,
51
- generateChangelog,
52
- optimizeReadme,
53
- scoreContentSEO,
54
- type BlogPostConfig,
55
- type ChangelogConfig,
56
- type ReadmeConfig,
57
- type GeneratedContent,
58
- type ChangelogResult,
59
- type ReadmeResult,
60
- type SEOScore,
61
- type ContentGeneratorOptions,
62
- } from './generator.js';
@@ -1,258 +0,0 @@
1
- // Search Intent Classification
2
- // Categorizes queries as informational, navigational, transactional, or commercial
3
-
4
- export type SearchIntent = 'informational' | 'navigational' | 'transactional' | 'commercial';
5
-
6
- export interface IntentAnalysis {
7
- intent: SearchIntent;
8
- confidence: number; // 0-100
9
- signals: string[];
10
- recommendedContentFormat: string;
11
- contentSuggestions: string[];
12
- }
13
-
14
- /**
15
- * Classify search intent for a keyword/query
16
- */
17
- export function classifyIntent(query: string): IntentAnalysis {
18
- const q = query.toLowerCase().trim();
19
- const signals: string[] = [];
20
- const scores: Record<SearchIntent, number> = {
21
- informational: 0,
22
- navigational: 0,
23
- transactional: 0,
24
- commercial: 0,
25
- };
26
-
27
- // Informational signals (user wants to learn)
28
- const informationalPatterns = [
29
- { pattern: /^(what|who|why|when|where|which)\b/, weight: 30, signal: 'Question word (what/who/why)' },
30
- { pattern: /^how (to|do|does|can|should)\b/, weight: 35, signal: 'How-to question' },
31
- { pattern: /\b(guide|tutorial|learn|understand|explain)\b/, weight: 25, signal: 'Learning intent' },
32
- { pattern: /\b(definition|meaning|example|history)\b/, weight: 25, signal: 'Definition/meaning query' },
33
- { pattern: /\b(tips|ideas|ways to|steps)\b/, weight: 20, signal: 'Tips/ideas request' },
34
- { pattern: /^(is|are|can|does|do)\b/, weight: 15, signal: 'Yes/no question' },
35
- { pattern: /\b(vs|versus|difference between|compared to)\b/, weight: 20, signal: 'Comparison query' },
36
- ];
37
-
38
- // Navigational signals (user wants to go somewhere specific)
39
- const navigationalPatterns = [
40
- { pattern: /\b(login|sign in|log in|signin)\b/, weight: 40, signal: 'Login intent' },
41
- { pattern: /\b(\.com|\.org|\.net|\.io)\b/, weight: 35, signal: 'Domain in query' },
42
- { pattern: /\b(official|website|homepage|site)\b/, weight: 30, signal: 'Website reference' },
43
- { pattern: /\b(facebook|twitter|instagram|youtube|linkedin|github)\b/, weight: 40, signal: 'Social platform' },
44
- { pattern: /\b(amazon|google|apple|microsoft)\b/, weight: 25, signal: 'Brand name' },
45
- { pattern: /\b(app|download|install)\b/, weight: 20, signal: 'App/download intent' },
46
- ];
47
-
48
- // Transactional signals (user wants to take action/buy)
49
- const transactionalPatterns = [
50
- { pattern: /\b(buy|purchase|order|shop)\b/, weight: 40, signal: 'Purchase intent' },
51
- { pattern: /\b(price|pricing|cost|cheap|discount|deal|sale|coupon)\b/, weight: 35, signal: 'Price interest' },
52
- { pattern: /\b(free trial|free download|download free)\b/, weight: 30, signal: 'Free trial/download' },
53
- { pattern: /\b(subscribe|sign up|signup|register)\b/, weight: 30, signal: 'Signup intent' },
54
- { pattern: /\b(book|reserve|schedule|appointment)\b/, weight: 30, signal: 'Booking intent' },
55
- { pattern: /\b(hire|service|quote)\b/, weight: 25, signal: 'Service request' },
56
- { pattern: /\b(near me|nearby|local)\b/, weight: 25, signal: 'Local intent' },
57
- ];
58
-
59
- // Commercial investigation signals (user researching before purchase)
60
- const commercialPatterns = [
61
- { pattern: /\b(best|top|review|reviews)\b/, weight: 35, signal: 'Review/best-of query' },
62
- { pattern: /\b(comparison|compare|vs|versus|or)\b/, weight: 30, signal: 'Comparison shopping' },
63
- { pattern: /\b(alternative|alternatives to)\b/, weight: 30, signal: 'Alternative search' },
64
- { pattern: /\b(pros and cons|advantages|disadvantages)\b/, weight: 25, signal: 'Evaluation query' },
65
- { pattern: /\b(worth it|should i|is it good)\b/, weight: 25, signal: 'Purchase consideration' },
66
- { pattern: /\b(for (small business|enterprise|startups|developers))\b/, weight: 20, signal: 'Segment-specific' },
67
- { pattern: /\b20\d{2}\b/, weight: 15, signal: 'Year reference (recency)' },
68
- ];
69
-
70
- // Calculate scores
71
- for (const p of informationalPatterns) {
72
- if (p.pattern.test(q)) {
73
- scores.informational += p.weight;
74
- signals.push(`[INFO] ${p.signal}`);
75
- }
76
- }
77
-
78
- for (const p of navigationalPatterns) {
79
- if (p.pattern.test(q)) {
80
- scores.navigational += p.weight;
81
- signals.push(`[NAV] ${p.signal}`);
82
- }
83
- }
84
-
85
- for (const p of transactionalPatterns) {
86
- if (p.pattern.test(q)) {
87
- scores.transactional += p.weight;
88
- signals.push(`[TRANS] ${p.signal}`);
89
- }
90
- }
91
-
92
- for (const p of commercialPatterns) {
93
- if (p.pattern.test(q)) {
94
- scores.commercial += p.weight;
95
- signals.push(`[COMM] ${p.signal}`);
96
- }
97
- }
98
-
99
- // Determine winner
100
- const maxScore = Math.max(...Object.values(scores));
101
- let intent: SearchIntent = 'informational'; // Default
102
-
103
- if (maxScore === 0) {
104
- // No clear signals, use heuristics
105
- const wordCount = q.split(/\s+/).length;
106
- if (wordCount <= 2) {
107
- intent = 'navigational';
108
- signals.push('[DEFAULT] Short query - likely navigational');
109
- } else {
110
- intent = 'informational';
111
- signals.push('[DEFAULT] No clear signals - defaulting to informational');
112
- }
113
- } else {
114
- intent = (Object.entries(scores) as [SearchIntent, number][])
115
- .sort((a, b) => b[1] - a[1])[0][0];
116
- }
117
-
118
- // Calculate confidence
119
- const totalScore = Object.values(scores).reduce((a, b) => a + b, 0);
120
- const confidence = totalScore > 0
121
- ? Math.min(100, Math.round((scores[intent] / totalScore) * 100))
122
- : 50;
123
-
124
- // Get recommendations
125
- const { recommendedContentFormat, contentSuggestions } = getContentRecommendations(intent);
126
-
127
- return {
128
- intent,
129
- confidence,
130
- signals,
131
- recommendedContentFormat,
132
- contentSuggestions,
133
- };
134
- }
135
-
136
- function getContentRecommendations(intent: SearchIntent): {
137
- recommendedContentFormat: string;
138
- contentSuggestions: string[];
139
- } {
140
- switch (intent) {
141
- case 'informational':
142
- return {
143
- recommendedContentFormat: 'Long-form blog post, guide, or tutorial',
144
- contentSuggestions: [
145
- 'Create comprehensive how-to content',
146
- 'Include step-by-step instructions',
147
- 'Add FAQ section for related questions',
148
- 'Use clear headings (H2, H3) for scanability',
149
- 'Include images/diagrams to illustrate concepts',
150
- 'Target featured snippet with direct answers',
151
- ],
152
- };
153
-
154
- case 'navigational':
155
- return {
156
- recommendedContentFormat: 'Brand landing page or homepage',
157
- contentSuggestions: [
158
- 'Ensure brand name is in title and H1',
159
- 'Include clear navigation to key sections',
160
- 'Add structured data for organization/website',
161
- 'Optimize for brand + product variations',
162
- 'Include social proof and trust signals',
163
- ],
164
- };
165
-
166
- case 'transactional':
167
- return {
168
- recommendedContentFormat: 'Product page or service landing page',
169
- contentSuggestions: [
170
- 'Include clear CTA (Buy, Sign Up, Download)',
171
- 'Show pricing information prominently',
172
- 'Add product schema markup',
173
- 'Include trust signals (reviews, testimonials)',
174
- 'Optimize for "buy", "price", "discount" variations',
175
- 'Add urgency elements (limited time, stock)',
176
- ],
177
- };
178
-
179
- case 'commercial':
180
- return {
181
- recommendedContentFormat: 'Comparison page, review, or buying guide',
182
- contentSuggestions: [
183
- 'Create detailed comparison tables',
184
- 'Include pros and cons lists',
185
- 'Add expert opinions or user reviews',
186
- 'Compare features, pricing, use cases',
187
- 'Include clear recommendation/winner',
188
- 'Add affiliate-friendly product links',
189
- ],
190
- };
191
- }
192
- }
193
-
194
- /**
195
- * Batch classify multiple keywords
196
- */
197
- export function classifyIntents(keywords: string[]): Map<string, IntentAnalysis> {
198
- const results = new Map<string, IntentAnalysis>();
199
- for (const kw of keywords) {
200
- results.set(kw, classifyIntent(kw));
201
- }
202
- return results;
203
- }
204
-
205
- /**
206
- * Format intent analysis report
207
- */
208
- export function formatIntentReport(query: string, analysis: IntentAnalysis): string {
209
- const lines: string[] = [];
210
-
211
- const intentIcons: Record<SearchIntent, string> = {
212
- informational: '📚',
213
- navigational: '🧭',
214
- transactional: '💰',
215
- commercial: '🔍',
216
- };
217
-
218
- lines.push('');
219
- lines.push('═'.repeat(60));
220
- lines.push(' SEARCH INTENT ANALYSIS');
221
- lines.push('═'.repeat(60));
222
- lines.push('');
223
-
224
- lines.push(`Query: "${query}"`);
225
- lines.push('');
226
-
227
- lines.push(`${intentIcons[analysis.intent]} Intent: ${analysis.intent.toUpperCase()}`);
228
- lines.push(` Confidence: ${analysis.confidence}%`);
229
- lines.push('');
230
-
231
- // Signals
232
- if (analysis.signals.length > 0) {
233
- lines.push('📊 SIGNALS DETECTED');
234
- lines.push('─'.repeat(60));
235
- for (const signal of analysis.signals) {
236
- lines.push(` • ${signal}`);
237
- }
238
- lines.push('');
239
- }
240
-
241
- // Content format
242
- lines.push('📝 RECOMMENDED CONTENT');
243
- lines.push('─'.repeat(60));
244
- lines.push(` Format: ${analysis.recommendedContentFormat}`);
245
- lines.push('');
246
-
247
- // Suggestions
248
- lines.push('💡 CONTENT SUGGESTIONS');
249
- lines.push('─'.repeat(60));
250
- for (const suggestion of analysis.contentSuggestions) {
251
- lines.push(` • ${suggestion}`);
252
- }
253
- lines.push('');
254
-
255
- lines.push('═'.repeat(60));
256
-
257
- return lines.join('\n');
258
- }