@rankcli/agent-runtime 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/index.d.mts +43 -393
  2. package/dist/index.d.ts +43 -393
  3. package/dist/index.js +306 -6526
  4. package/dist/index.mjs +202 -6412
  5. package/package.json +6 -1
  6. package/scripts/build-deno.ts +0 -134
  7. package/src/analyzers/core-web-vitals-analyzer.test.ts +0 -236
  8. package/src/analyzers/core-web-vitals-analyzer.ts +0 -557
  9. package/src/analyzers/geo-analyzer.test.ts +0 -310
  10. package/src/analyzers/geo-analyzer.ts +0 -814
  11. package/src/analyzers/image-optimization-analyzer.test.ts +0 -145
  12. package/src/analyzers/image-optimization-analyzer.ts +0 -348
  13. package/src/analyzers/index.ts +0 -233
  14. package/src/analyzers/internal-linking-analyzer.test.ts +0 -141
  15. package/src/analyzers/internal-linking-analyzer.ts +0 -419
  16. package/src/analyzers/mobile-seo-analyzer.test.ts +0 -140
  17. package/src/analyzers/mobile-seo-analyzer.ts +0 -455
  18. package/src/analyzers/security-headers-analyzer.test.ts +0 -115
  19. package/src/analyzers/security-headers-analyzer.ts +0 -318
  20. package/src/analyzers/structured-data-analyzer.test.ts +0 -210
  21. package/src/analyzers/structured-data-analyzer.ts +0 -590
  22. package/src/audit/ai/analyzer.ts +0 -347
  23. package/src/audit/ai/index.ts +0 -29
  24. package/src/audit/ai/prompts/content-analysis.ts +0 -271
  25. package/src/audit/ai/types.ts +0 -179
  26. package/src/audit/checks/additional-checks.ts +0 -439
  27. package/src/audit/checks/agent-experience.ts +0 -108
  28. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  29. package/src/audit/checks/ai-content-structure.ts +0 -325
  30. package/src/audit/checks/ai-readiness.ts +0 -406
  31. package/src/audit/checks/anchor-text.ts +0 -179
  32. package/src/audit/checks/answer-conciseness.ts +0 -322
  33. package/src/audit/checks/asset-minification.ts +0 -270
  34. package/src/audit/checks/bing-optimization.ts +0 -206
  35. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  36. package/src/audit/checks/caching-headers.ts +0 -305
  37. package/src/audit/checks/canonical-advanced.ts +0 -150
  38. package/src/audit/checks/canonical-domain.ts +0 -196
  39. package/src/audit/checks/citation-quality.ts +0 -358
  40. package/src/audit/checks/client-rendering.ts +0 -542
  41. package/src/audit/checks/color-contrast.ts +0 -342
  42. package/src/audit/checks/content-freshness.ts +0 -170
  43. package/src/audit/checks/content-science.ts +0 -589
  44. package/src/audit/checks/conversion-elements.ts +0 -526
  45. package/src/audit/checks/crawlability.ts +0 -220
  46. package/src/audit/checks/directory-listing.ts +0 -172
  47. package/src/audit/checks/dom-analysis.ts +0 -191
  48. package/src/audit/checks/dom-size.ts +0 -246
  49. package/src/audit/checks/duplicate-content.ts +0 -194
  50. package/src/audit/checks/eeat-signals.ts +0 -990
  51. package/src/audit/checks/entity-seo.ts +0 -396
  52. package/src/audit/checks/featured-snippet.ts +0 -473
  53. package/src/audit/checks/freshness-signals.ts +0 -443
  54. package/src/audit/checks/funnel-intent.ts +0 -463
  55. package/src/audit/checks/hreflang.ts +0 -174
  56. package/src/audit/checks/html-compliance.ts +0 -302
  57. package/src/audit/checks/image-dimensions.ts +0 -167
  58. package/src/audit/checks/images.ts +0 -160
  59. package/src/audit/checks/indexnow.ts +0 -275
  60. package/src/audit/checks/interactive-tools.ts +0 -475
  61. package/src/audit/checks/internal-link-graph.ts +0 -436
  62. package/src/audit/checks/keyword-analysis.ts +0 -239
  63. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  64. package/src/audit/checks/keyword-placement.ts +0 -471
  65. package/src/audit/checks/links.ts +0 -273
  66. package/src/audit/checks/llms-txt.ts +0 -224
  67. package/src/audit/checks/local-seo.ts +0 -296
  68. package/src/audit/checks/mobile.ts +0 -167
  69. package/src/audit/checks/modern-images.ts +0 -226
  70. package/src/audit/checks/navboost-signals.ts +0 -395
  71. package/src/audit/checks/on-page.ts +0 -209
  72. package/src/audit/checks/page-resources.ts +0 -285
  73. package/src/audit/checks/pagination.ts +0 -180
  74. package/src/audit/checks/performance.ts +0 -153
  75. package/src/audit/checks/platform-presence.ts +0 -580
  76. package/src/audit/checks/rag-chunk-readiness.test.ts +0 -159
  77. package/src/audit/checks/rag-chunk-readiness.ts +0 -163
  78. package/src/audit/checks/redirect-analysis.ts +0 -153
  79. package/src/audit/checks/redirect-chain.ts +0 -389
  80. package/src/audit/checks/resource-hints.ts +0 -420
  81. package/src/audit/checks/responsive-css.ts +0 -247
  82. package/src/audit/checks/responsive-images.ts +0 -396
  83. package/src/audit/checks/review-ecosystem.ts +0 -415
  84. package/src/audit/checks/robots-validation.ts +0 -373
  85. package/src/audit/checks/security-headers.ts +0 -188
  86. package/src/audit/checks/security.ts +0 -144
  87. package/src/audit/checks/serp-preview.ts +0 -251
  88. package/src/audit/checks/site-maturity.ts +0 -453
  89. package/src/audit/checks/social-meta.test.ts +0 -275
  90. package/src/audit/checks/social-meta.ts +0 -134
  91. package/src/audit/checks/soft-404.ts +0 -151
  92. package/src/audit/checks/structured-data.ts +0 -238
  93. package/src/audit/checks/tech-detection.ts +0 -496
  94. package/src/audit/checks/topical-clusters.ts +0 -435
  95. package/src/audit/checks/tracker-bloat.ts +0 -462
  96. package/src/audit/checks/tracking-verification.test.ts +0 -371
  97. package/src/audit/checks/tracking-verification.ts +0 -636
  98. package/src/audit/checks/url-safety.ts +0 -682
  99. package/src/audit/deno-entry.ts +0 -66
  100. package/src/audit/discovery/index.ts +0 -15
  101. package/src/audit/discovery/link-crawler.ts +0 -233
  102. package/src/audit/discovery/repo-routes.ts +0 -347
  103. package/src/audit/engine.ts +0 -633
  104. package/src/audit/fixes/index.ts +0 -209
  105. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  106. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  107. package/src/audit/index.ts +0 -74
  108. package/src/audit/runner.test.ts +0 -299
  109. package/src/audit/runner.ts +0 -130
  110. package/src/audit/types.ts +0 -1987
  111. package/src/content/featured-snippet.ts +0 -367
  112. package/src/content/generator.test.ts +0 -534
  113. package/src/content/generator.ts +0 -501
  114. package/src/content/headline.ts +0 -317
  115. package/src/content/index.ts +0 -62
  116. package/src/content/intent.ts +0 -258
  117. package/src/content/keyword-density.ts +0 -349
  118. package/src/content/readability.ts +0 -262
  119. package/src/executor.ts +0 -336
  120. package/src/fixer/framework-fixes.test.ts +0 -489
  121. package/src/fixer/framework-fixes.ts +0 -5287
  122. package/src/fixer/index.ts +0 -6
  123. package/src/fixer/schemas.ts +0 -971
  124. package/src/fixer.ts +0 -642
  125. package/src/frameworks/detector.test.ts +0 -248
  126. package/src/frameworks/detector.ts +0 -899
  127. package/src/frameworks/index.ts +0 -68
  128. package/src/frameworks/recipes/angular.yaml +0 -171
  129. package/src/frameworks/recipes/astro.yaml +0 -206
  130. package/src/frameworks/recipes/django.yaml +0 -180
  131. package/src/frameworks/recipes/laravel.yaml +0 -137
  132. package/src/frameworks/recipes/nextjs.yaml +0 -268
  133. package/src/frameworks/recipes/nuxt.yaml +0 -175
  134. package/src/frameworks/recipes/rails.yaml +0 -188
  135. package/src/frameworks/recipes/react.yaml +0 -202
  136. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  137. package/src/frameworks/recipes/vue.yaml +0 -137
  138. package/src/frameworks/recipes/wordpress.yaml +0 -209
  139. package/src/frameworks/suggestion-engine.ts +0 -357
  140. package/src/geo/geo-content.test.ts +0 -305
  141. package/src/geo/geo-content.ts +0 -266
  142. package/src/geo/geo-history.test.ts +0 -473
  143. package/src/geo/geo-history.ts +0 -433
  144. package/src/geo/geo-tracker.test.ts +0 -359
  145. package/src/geo/geo-tracker.ts +0 -411
  146. package/src/geo/index.ts +0 -11
  147. package/src/geo/llm-citation-checker.ts +0 -188
  148. package/src/git/commit-helper.test.ts +0 -261
  149. package/src/git/commit-helper.ts +0 -329
  150. package/src/git/index.ts +0 -12
  151. package/src/git/pr-helper.test.ts +0 -284
  152. package/src/git/pr-helper.ts +0 -307
  153. package/src/index.ts +0 -76
  154. package/src/keywords/ai-keyword-engine.ts +0 -1062
  155. package/src/keywords/ai-summarizer.ts +0 -387
  156. package/src/keywords/ci-mode.ts +0 -555
  157. package/src/keywords/engine.ts +0 -359
  158. package/src/keywords/index.ts +0 -151
  159. package/src/keywords/llm-judge.ts +0 -357
  160. package/src/keywords/nlp-analysis.ts +0 -706
  161. package/src/keywords/prioritizer.ts +0 -295
  162. package/src/keywords/site-crawler.ts +0 -342
  163. package/src/keywords/sources/autocomplete.ts +0 -139
  164. package/src/keywords/sources/competitive-search.ts +0 -450
  165. package/src/keywords/sources/competitor-analysis.ts +0 -374
  166. package/src/keywords/sources/dataforseo.ts +0 -206
  167. package/src/keywords/sources/free-sources.ts +0 -294
  168. package/src/keywords/sources/gsc.ts +0 -123
  169. package/src/keywords/topic-grouping.ts +0 -327
  170. package/src/keywords/types.ts +0 -144
  171. package/src/keywords/wizard.ts +0 -457
  172. package/src/loader.ts +0 -40
  173. package/src/ranking/index.ts +0 -5
  174. package/src/ranking/serp-client.ts +0 -348
  175. package/src/ranking/tracker.ts +0 -380
  176. package/src/ranking/types.ts +0 -123
  177. package/src/reports/index.ts +0 -7
  178. package/src/reports/report-generator.test.ts +0 -293
  179. package/src/reports/report-generator.ts +0 -713
  180. package/src/scheduler/alerts.test.ts +0 -458
  181. package/src/scheduler/alerts.ts +0 -328
  182. package/src/scheduler/index.ts +0 -8
  183. package/src/scheduler/scheduled-audit.test.ts +0 -377
  184. package/src/scheduler/scheduled-audit.ts +0 -149
  185. package/src/test/integration-test.ts +0 -325
  186. package/src/tools/analyzer.ts +0 -373
  187. package/src/tools/crawl.ts +0 -293
  188. package/src/tools/files.ts +0 -301
  189. package/src/tools/h1-fixer.ts +0 -249
  190. package/src/tools/index.ts +0 -67
  191. package/src/tracking/github-action.ts +0 -326
  192. package/src/tracking/google-analytics.ts +0 -265
  193. package/src/tracking/index.ts +0 -45
  194. package/src/tracking/report-generator.ts +0 -386
  195. package/src/tracking/search-console.ts +0 -335
  196. package/src/types.ts +0 -148
  197. package/src/utils/http.ts +0 -302
  198. package/src/wasm-adapter.ts +0 -297
  199. package/src/wasm-entry.ts +0 -14
  200. package/tsconfig.json +0 -17
  201. package/tsup.wasm.config.ts +0 -26
  202. package/vitest.config.ts +0 -15
@@ -1,555 +0,0 @@
1
- /**
2
- * CI Mode for Keyword Research
3
- *
4
- * Handles automated keyword research in CI/CD pipelines.
5
- * - If confidence is high enough, adds keywords to PR
6
- * - If uncertainty is high, skips and warns user
7
- * - Provides clear instructions for what to do next
8
- */
9
-
10
- import {
11
- runAIKeywordResearch,
12
- type PaidKeywordResult,
13
- type FreeKeywordResult,
14
- type KeywordRecommendation,
15
- type PlanTier,
16
- } from './ai-keyword-engine.js';
17
- import type { SiteSummary } from './ai-summarizer.js';
18
-
19
- export interface CIKeywordOptions {
20
- url: string;
21
- tier: PlanTier;
22
- openaiApiKey?: string;
23
- /** Minimum confidence to proceed (default: 0.7) */
24
- minConfidence?: number;
25
- /** Maximum keywords to include in PR */
26
- maxKeywords?: number;
27
- /** Branch name for context */
28
- branchName?: string;
29
- /** PR number if applicable */
30
- prNumber?: number;
31
- /** Site ID for dashboard link */
32
- siteId?: string;
33
- }
34
-
35
- export interface CIKeywordResult {
36
- /** Whether keywords can be added to the PR */
37
- canAddToPR: boolean;
38
- /** Keywords to add (if canAddToPR is true) */
39
- keywords: KeywordRecommendation[];
40
- /** Warning messages to display */
41
- warnings: string[];
42
- /** Error messages (if any) */
43
- errors: string[];
44
- /** Info messages */
45
- info: string[];
46
- /** Actions user needs to take */
47
- requiredActions: CIAction[];
48
- /** PR comment body */
49
- prCommentBody: string;
50
- /** Exit code (0 = success, 1 = needs action, 2 = error) */
51
- exitCode: 0 | 1 | 2;
52
- /** Detailed explanation */
53
- explanation: string;
54
- /** Raw result for debugging */
55
- rawResult?: PaidKeywordResult | FreeKeywordResult;
56
- }
57
-
58
- export interface CIAction {
59
- title: string;
60
- description: string;
61
- command?: string;
62
- webUrl?: string;
63
- priority: 'high' | 'medium' | 'low';
64
- }
65
-
66
- const CI_CONFIDENCE_THRESHOLD = 0.7;
67
- const MAX_KEYWORDS_IN_PR = 10;
68
-
69
- /**
70
- * Run keyword research in CI mode
71
- */
72
- export async function runCIKeywordResearch(
73
- options: CIKeywordOptions
74
- ): Promise<CIKeywordResult> {
75
- const {
76
- url,
77
- tier,
78
- openaiApiKey,
79
- minConfidence = CI_CONFIDENCE_THRESHOLD,
80
- maxKeywords = MAX_KEYWORDS_IN_PR,
81
- siteId,
82
- } = options;
83
-
84
- const warnings: string[] = [];
85
- const errors: string[] = [];
86
- const info: string[] = [];
87
- const actions: CIAction[] = [];
88
-
89
- console.log('đŸ”Ŧ Running keyword research in CI mode...');
90
-
91
- // Free tier gets limited results and upgrade prompt
92
- if (tier === 'free') {
93
- return handleFreeTierCI(url, siteId);
94
- }
95
-
96
- // Paid tier - require API key
97
- if (!openaiApiKey) {
98
- errors.push('OpenAI API key required for keyword research in CI mode');
99
- return {
100
- canAddToPR: false,
101
- keywords: [],
102
- warnings,
103
- errors,
104
- info,
105
- requiredActions: [
106
- {
107
- title: 'Add OpenAI API Key',
108
- description: 'Set OPENAI_API_KEY in your GitHub secrets',
109
- command: 'gh secret set OPENAI_API_KEY',
110
- priority: 'high',
111
- },
112
- ],
113
- prCommentBody: generateErrorPRComment(errors),
114
- exitCode: 2,
115
- explanation: 'Missing required OpenAI API key for AI-powered keyword research.',
116
- };
117
- }
118
-
119
- try {
120
- // Run the keyword research
121
- const result = await runAIKeywordResearch({
122
- url,
123
- tier,
124
- openaiApiKey,
125
- ciMode: true,
126
- });
127
-
128
- // Handle paid tier result
129
- if ('uncertainty' in result) {
130
- return handlePaidTierCI(result, {
131
- minConfidence,
132
- maxKeywords,
133
- siteId,
134
- warnings,
135
- info,
136
- });
137
- }
138
-
139
- // Shouldn't happen, but handle just in case
140
- return handleFreeTierCI(url, siteId);
141
- } catch (error) {
142
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
143
- errors.push(`Keyword research failed: ${errorMessage}`);
144
-
145
- return {
146
- canAddToPR: false,
147
- keywords: [],
148
- warnings,
149
- errors,
150
- info,
151
- requiredActions: [
152
- {
153
- title: 'Check Configuration',
154
- description: 'Verify your API keys and site URL are correct',
155
- priority: 'high',
156
- },
157
- ],
158
- prCommentBody: generateErrorPRComment(errors),
159
- exitCode: 2,
160
- explanation: `Keyword research encountered an error: ${errorMessage}`,
161
- };
162
- }
163
- }
164
-
165
- /**
166
- * Handle free tier CI results
167
- */
168
- function handleFreeTierCI(url: string, siteId?: string): CIKeywordResult {
169
- const dashboardUrl = siteId
170
- ? `https://rankcli.dev/dashboard/projects/${siteId}/keywords`
171
- : 'https://rankcli.dev/pricing';
172
-
173
- return {
174
- canAddToPR: false,
175
- keywords: [],
176
- warnings: [
177
- 'Keyword research requires a paid plan for CI automation',
178
- ],
179
- errors: [],
180
- info: [
181
- `Found potential keyword opportunities for ${url}`,
182
- 'Upgrade to Solo plan or higher for automated keyword research in CI',
183
- ],
184
- requiredActions: [
185
- {
186
- title: 'Upgrade to Solo Plan',
187
- description: 'Get AI-powered keyword research with CI/CD automation',
188
- webUrl: 'https://rankcli.dev/pricing',
189
- priority: 'medium',
190
- },
191
- {
192
- title: 'Run Manual Keyword Research',
193
- description: 'Use the CLI wizard to get keyword recommendations',
194
- command: 'rankcli keywords --wizard',
195
- priority: 'low',
196
- },
197
- ],
198
- prCommentBody: generateFreeTierPRComment(url, dashboardUrl),
199
- exitCode: 1,
200
- explanation: 'Free tier does not support automated keyword research in CI. Upgrade for this feature.',
201
- };
202
- }
203
-
204
- /**
205
- * Handle paid tier CI results
206
- */
207
- function handlePaidTierCI(
208
- result: PaidKeywordResult,
209
- options: {
210
- minConfidence: number;
211
- maxKeywords: number;
212
- siteId?: string;
213
- warnings: string[];
214
- info: string[];
215
- }
216
- ): CIKeywordResult {
217
- const { minConfidence, maxKeywords, siteId, warnings, info } = options;
218
- const { uncertainty, recommendations, siteSummary, freeToolIdeas } = result;
219
-
220
- const dashboardUrl = siteId
221
- ? `https://rankcli.dev/dashboard/projects/${siteId}/keywords`
222
- : 'https://rankcli.dev/dashboard';
223
-
224
- const wizardUrl = siteId
225
- ? `https://rankcli.dev/dashboard/projects/${siteId}/keywords/wizard`
226
- : 'https://rankcli.dev/dashboard';
227
-
228
- // Check confidence level
229
- if (uncertainty.overallConfidence < minConfidence) {
230
- // High uncertainty - cannot automate
231
- const questionsNeeded = uncertainty.questionsToAsk.slice(0, 5);
232
-
233
- return {
234
- canAddToPR: false,
235
- keywords: [],
236
- warnings: [
237
- `Confidence level (${Math.round(uncertainty.overallConfidence * 100)}%) is below threshold (${Math.round(minConfidence * 100)}%)`,
238
- 'Keyword recommendations skipped due to uncertainty',
239
- ],
240
- errors: [],
241
- info: [
242
- `Site analyzed: ${siteSummary.productName}`,
243
- `Industry detected: ${siteSummary.industry}`,
244
- `Found ${recommendations.length} potential keyword opportunities`,
245
- ],
246
- requiredActions: [
247
- {
248
- title: 'Run Keyword Wizard',
249
- description: `Answer ${questionsNeeded.length} questions to improve accuracy`,
250
- command: 'rankcli keywords --wizard',
251
- webUrl: wizardUrl,
252
- priority: 'high',
253
- },
254
- {
255
- title: 'Provide Product Context',
256
- description: 'Add product description to reduce uncertainty',
257
- command: 'rankcli keywords --context "Your product description"',
258
- priority: 'medium',
259
- },
260
- ],
261
- prCommentBody: generateUncertaintyPRComment(
262
- siteSummary,
263
- uncertainty,
264
- questionsNeeded,
265
- wizardUrl
266
- ),
267
- exitCode: 1,
268
- explanation: uncertainty.explanation,
269
- rawResult: result,
270
- };
271
- }
272
-
273
- // High enough confidence - include keywords
274
- const keywordsToAdd = recommendations
275
- .filter((r) => r.action !== 'needs-input' && r.action !== 'skip')
276
- .slice(0, maxKeywords);
277
-
278
- if (keywordsToAdd.length === 0) {
279
- warnings.push('No actionable keywords found meeting criteria');
280
- return {
281
- canAddToPR: false,
282
- keywords: [],
283
- warnings,
284
- errors: [],
285
- info: [
286
- `Site: ${siteSummary.productName}`,
287
- `Industry: ${siteSummary.industry}`,
288
- 'Consider expanding search criteria or running wizard',
289
- ],
290
- requiredActions: [
291
- {
292
- title: 'Run Keyword Wizard',
293
- description: 'Get personalized keyword recommendations',
294
- command: 'rankcli keywords --wizard',
295
- webUrl: wizardUrl,
296
- priority: 'medium',
297
- },
298
- ],
299
- prCommentBody: generateNoKeywordsPRComment(siteSummary, dashboardUrl),
300
- exitCode: 0,
301
- explanation: 'Analysis complete but no keywords met the criteria for automation.',
302
- rawResult: result,
303
- };
304
- }
305
-
306
- // Success - keywords can be added
307
- info.push(`Confidence: ${Math.round(uncertainty.overallConfidence * 100)}%`);
308
- info.push(`Adding ${keywordsToAdd.length} keyword recommendations`);
309
-
310
- return {
311
- canAddToPR: true,
312
- keywords: keywordsToAdd,
313
- warnings,
314
- errors: [],
315
- info,
316
- requiredActions: [],
317
- prCommentBody: generateSuccessPRComment(
318
- siteSummary,
319
- keywordsToAdd,
320
- freeToolIdeas.slice(0, 5),
321
- uncertainty.overallConfidence,
322
- dashboardUrl
323
- ),
324
- exitCode: 0,
325
- explanation: `Successfully analyzed ${siteSummary.productName}. ${keywordsToAdd.length} keyword recommendations ready.`,
326
- rawResult: result,
327
- };
328
- }
329
-
330
- // PR Comment Generators
331
-
332
- function generateErrorPRComment(errors: string[]): string {
333
- return `## 🔑 Keyword Research - Error
334
-
335
- ❌ **Keyword research could not complete**
336
-
337
- ${errors.map((e) => `- ${e}`).join('\n')}
338
-
339
- ### Next Steps
340
- 1. Check your configuration and API keys
341
- 2. Run \`rankcli keywords --debug\` locally to diagnose
342
- 3. See [documentation](https://rankcli.dev/docs/keywords) for help
343
-
344
- ---
345
- *Generated by [RankCLI](https://rankcli.dev)*`;
346
- }
347
-
348
- function generateFreeTierPRComment(url: string, upgradeUrl: string): string {
349
- return `## 🔑 Keyword Research
350
-
351
- 📊 **Keyword opportunities detected for ${url}**
352
-
353
- Automated keyword research in CI requires a paid plan.
354
-
355
- ### What You Get with Solo Plan ($9/mo):
356
- - ✅ AI-powered keyword discovery
357
- - ✅ Automated CI/CD integration
358
- - ✅ Keyword clustering & prioritization
359
- - ✅ Free tool ideas with CTAs
360
- - ✅ Competitive analysis
361
-
362
- ### Run Manually
363
- \`\`\`bash
364
- rankcli keywords --wizard
365
- \`\`\`
366
-
367
- [Upgrade to unlock →](${upgradeUrl})
368
-
369
- ---
370
- *Generated by [RankCLI](https://rankcli.dev)*`;
371
- }
372
-
373
- function generateUncertaintyPRComment(
374
- summary: SiteSummary,
375
- uncertainty: any,
376
- questions: any[],
377
- wizardUrl: string
378
- ): string {
379
- const questionsList = questions
380
- .map((q, i) => `${i + 1}. ${q.question}`)
381
- .join('\n');
382
-
383
- return `## 🔑 Keyword Research - Needs Input
384
-
385
- âš ī¸ **Confidence: ${Math.round(uncertainty.overallConfidence * 100)}%** - Too low for automation
386
-
387
- ### What We Detected
388
- - **Product:** ${summary.productName}
389
- - **Industry:** ${summary.industry}
390
- - **Audience:** ${summary.targetAudience}
391
-
392
- ### Questions to Answer
393
- To improve accuracy, please answer these questions:
394
-
395
- ${questionsList}
396
-
397
- ### How to Proceed
398
-
399
- **Option 1: Run the wizard (recommended)**
400
- \`\`\`bash
401
- rankcli keywords --wizard
402
- \`\`\`
403
-
404
- **Option 2: Use the web wizard**
405
- [Open Keyword Wizard →](${wizardUrl})
406
-
407
- **Option 3: Provide context directly**
408
- \`\`\`bash
409
- rankcli keywords --context "Your product description here"
410
- \`\`\`
411
-
412
- ### Why This Matters
413
- Low confidence means our recommendations might not be relevant to your business. Taking 2 minutes to answer questions will significantly improve results.
414
-
415
- ---
416
- *Generated by [RankCLI](https://rankcli.dev)*`;
417
- }
418
-
419
- function generateNoKeywordsPRComment(summary: SiteSummary, dashboardUrl: string): string {
420
- return `## 🔑 Keyword Research - Complete
421
-
422
- ✅ **Analysis complete for ${summary.productName}**
423
-
424
- No keywords currently meet the automation criteria (low difficulty + high volume + high relevance).
425
-
426
- ### What This Means
427
- - Your niche may be competitive
428
- - Consider longer-tail keywords
429
- - Try the wizard for personalized recommendations
430
-
431
- ### Next Steps
432
- 1. Run \`rankcli keywords --wizard\` for guided research
433
- 2. View full analysis in [dashboard](${dashboardUrl})
434
-
435
- ---
436
- *Generated by [RankCLI](https://rankcli.dev)*`;
437
- }
438
-
439
- function generateSuccessPRComment(
440
- summary: SiteSummary,
441
- keywords: KeywordRecommendation[],
442
- toolIdeas: any[],
443
- confidence: number,
444
- dashboardUrl: string
445
- ): string {
446
- const keywordTable = keywords
447
- .map((k, i) => `| ${i + 1} | ${k.keyword} | ${k.action} | ${k.impact} | ${k.effort} |`)
448
- .join('\n');
449
-
450
- const toolList = toolIdeas
451
- .map((t) => `- **${t.toolName}** (${t.volume} searches/mo, KD: ${t.difficulty})`)
452
- .join('\n');
453
-
454
- return `## 🔑 Keyword Research - Success
455
-
456
- ✅ **Confidence: ${Math.round(confidence * 100)}%**
457
-
458
- ### Site Analysis
459
- - **Product:** ${summary.productName}
460
- - **Industry:** ${summary.industry}
461
- - **Target:** ${summary.targetAudience}
462
-
463
- ### Top Keyword Recommendations
464
-
465
- | # | Keyword | Action | Impact | Effort |
466
- |---|---------|--------|--------|--------|
467
- ${keywordTable}
468
-
469
- ### Free Tool Ideas (Engineering as Marketing)
470
- ${toolList || 'No tool ideas generated'}
471
-
472
- ### Next Steps
473
- 1. Review recommendations in [dashboard](${dashboardUrl})
474
- 2. Start with high-impact, low-effort keywords
475
- 3. Build free tools to capture search traffic
476
-
477
- ---
478
- *Generated by [RankCLI](https://rankcli.dev) â€ĸ [View Full Report](${dashboardUrl})*`;
479
- }
480
-
481
- /**
482
- * Format CI result for console output
483
- */
484
- export function formatCIResult(result: CIKeywordResult): string {
485
- const lines: string[] = [];
486
-
487
- lines.push('');
488
- lines.push('═'.repeat(70));
489
- lines.push(' KEYWORD RESEARCH - CI MODE');
490
- lines.push('═'.repeat(70));
491
- lines.push('');
492
-
493
- // Status
494
- if (result.canAddToPR) {
495
- lines.push('✅ STATUS: Keywords ready to add to PR');
496
- } else if (result.exitCode === 2) {
497
- lines.push('❌ STATUS: Error occurred');
498
- } else {
499
- lines.push('âš ī¸ STATUS: Needs user input');
500
- }
501
- lines.push('');
502
-
503
- // Errors
504
- if (result.errors.length > 0) {
505
- lines.push('ERRORS:');
506
- result.errors.forEach((e) => lines.push(` ❌ ${e}`));
507
- lines.push('');
508
- }
509
-
510
- // Warnings
511
- if (result.warnings.length > 0) {
512
- lines.push('WARNINGS:');
513
- result.warnings.forEach((w) => lines.push(` âš ī¸ ${w}`));
514
- lines.push('');
515
- }
516
-
517
- // Info
518
- if (result.info.length > 0) {
519
- lines.push('INFO:');
520
- result.info.forEach((i) => lines.push(` â„šī¸ ${i}`));
521
- lines.push('');
522
- }
523
-
524
- // Keywords
525
- if (result.keywords.length > 0) {
526
- lines.push('KEYWORDS:');
527
- result.keywords.forEach((k, i) => {
528
- lines.push(` ${i + 1}. "${k.keyword}" - ${k.action} (${k.impact} impact, ${k.effort} effort)`);
529
- });
530
- lines.push('');
531
- }
532
-
533
- // Required Actions
534
- if (result.requiredActions.length > 0) {
535
- lines.push('REQUIRED ACTIONS:');
536
- result.requiredActions.forEach((a) => {
537
- lines.push(` 📌 ${a.title}`);
538
- lines.push(` ${a.description}`);
539
- if (a.command) {
540
- lines.push(` Command: ${a.command}`);
541
- }
542
- if (a.webUrl) {
543
- lines.push(` URL: ${a.webUrl}`);
544
- }
545
- lines.push('');
546
- });
547
- }
548
-
549
- // Explanation
550
- lines.push('─'.repeat(70));
551
- lines.push(` ${result.explanation}`);
552
- lines.push('═'.repeat(70));
553
-
554
- return lines.join('\n');
555
- }