@rankcli/agent-runtime 0.0.15 → 0.0.17

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 (203) hide show
  1. package/README.md +5 -4
  2. package/dist/index.d.mts +44 -393
  3. package/dist/index.d.ts +44 -393
  4. package/dist/index.js +22098 -26131
  5. package/dist/index.mjs +11834 -15857
  6. package/package.json +10 -4
  7. package/scripts/build-deno.ts +0 -134
  8. package/src/analyzers/core-web-vitals-analyzer.test.ts +0 -236
  9. package/src/analyzers/core-web-vitals-analyzer.ts +0 -557
  10. package/src/analyzers/geo-analyzer.test.ts +0 -310
  11. package/src/analyzers/geo-analyzer.ts +0 -814
  12. package/src/analyzers/image-optimization-analyzer.test.ts +0 -145
  13. package/src/analyzers/image-optimization-analyzer.ts +0 -348
  14. package/src/analyzers/index.ts +0 -233
  15. package/src/analyzers/internal-linking-analyzer.test.ts +0 -141
  16. package/src/analyzers/internal-linking-analyzer.ts +0 -419
  17. package/src/analyzers/mobile-seo-analyzer.test.ts +0 -140
  18. package/src/analyzers/mobile-seo-analyzer.ts +0 -455
  19. package/src/analyzers/security-headers-analyzer.test.ts +0 -115
  20. package/src/analyzers/security-headers-analyzer.ts +0 -318
  21. package/src/analyzers/structured-data-analyzer.test.ts +0 -210
  22. package/src/analyzers/structured-data-analyzer.ts +0 -590
  23. package/src/audit/ai/analyzer.ts +0 -347
  24. package/src/audit/ai/index.ts +0 -29
  25. package/src/audit/ai/prompts/content-analysis.ts +0 -271
  26. package/src/audit/ai/types.ts +0 -179
  27. package/src/audit/checks/additional-checks.ts +0 -439
  28. package/src/audit/checks/agent-experience.ts +0 -108
  29. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  30. package/src/audit/checks/ai-content-structure.ts +0 -325
  31. package/src/audit/checks/ai-readiness.ts +0 -406
  32. package/src/audit/checks/anchor-text.ts +0 -179
  33. package/src/audit/checks/answer-conciseness.ts +0 -322
  34. package/src/audit/checks/asset-minification.ts +0 -270
  35. package/src/audit/checks/bing-optimization.ts +0 -206
  36. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  37. package/src/audit/checks/caching-headers.ts +0 -305
  38. package/src/audit/checks/canonical-advanced.ts +0 -150
  39. package/src/audit/checks/canonical-domain.ts +0 -196
  40. package/src/audit/checks/citation-quality.ts +0 -358
  41. package/src/audit/checks/client-rendering.ts +0 -542
  42. package/src/audit/checks/color-contrast.ts +0 -342
  43. package/src/audit/checks/content-freshness.ts +0 -170
  44. package/src/audit/checks/content-science.ts +0 -589
  45. package/src/audit/checks/conversion-elements.ts +0 -526
  46. package/src/audit/checks/crawlability.ts +0 -220
  47. package/src/audit/checks/directory-listing.ts +0 -172
  48. package/src/audit/checks/dom-analysis.ts +0 -191
  49. package/src/audit/checks/dom-size.ts +0 -246
  50. package/src/audit/checks/duplicate-content.ts +0 -194
  51. package/src/audit/checks/eeat-signals.ts +0 -990
  52. package/src/audit/checks/entity-seo.ts +0 -396
  53. package/src/audit/checks/featured-snippet.ts +0 -473
  54. package/src/audit/checks/freshness-signals.ts +0 -443
  55. package/src/audit/checks/funnel-intent.ts +0 -463
  56. package/src/audit/checks/hreflang.ts +0 -174
  57. package/src/audit/checks/html-compliance.ts +0 -302
  58. package/src/audit/checks/image-dimensions.ts +0 -167
  59. package/src/audit/checks/images.ts +0 -160
  60. package/src/audit/checks/indexnow.ts +0 -275
  61. package/src/audit/checks/interactive-tools.ts +0 -475
  62. package/src/audit/checks/internal-link-graph.ts +0 -436
  63. package/src/audit/checks/keyword-analysis.ts +0 -239
  64. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  65. package/src/audit/checks/keyword-placement.ts +0 -471
  66. package/src/audit/checks/links.ts +0 -273
  67. package/src/audit/checks/llms-txt.ts +0 -224
  68. package/src/audit/checks/local-seo.ts +0 -296
  69. package/src/audit/checks/mobile.ts +0 -167
  70. package/src/audit/checks/modern-images.ts +0 -226
  71. package/src/audit/checks/navboost-signals.ts +0 -395
  72. package/src/audit/checks/on-page.ts +0 -209
  73. package/src/audit/checks/page-resources.ts +0 -285
  74. package/src/audit/checks/pagination.ts +0 -180
  75. package/src/audit/checks/performance.ts +0 -153
  76. package/src/audit/checks/platform-presence.ts +0 -580
  77. package/src/audit/checks/rag-chunk-readiness.test.ts +0 -159
  78. package/src/audit/checks/rag-chunk-readiness.ts +0 -163
  79. package/src/audit/checks/redirect-analysis.ts +0 -153
  80. package/src/audit/checks/redirect-chain.ts +0 -389
  81. package/src/audit/checks/resource-hints.ts +0 -420
  82. package/src/audit/checks/responsive-css.ts +0 -247
  83. package/src/audit/checks/responsive-images.ts +0 -396
  84. package/src/audit/checks/review-ecosystem.ts +0 -415
  85. package/src/audit/checks/robots-validation.ts +0 -373
  86. package/src/audit/checks/security-headers.ts +0 -188
  87. package/src/audit/checks/security.ts +0 -144
  88. package/src/audit/checks/serp-preview.ts +0 -251
  89. package/src/audit/checks/site-maturity.ts +0 -453
  90. package/src/audit/checks/social-meta.test.ts +0 -275
  91. package/src/audit/checks/social-meta.ts +0 -134
  92. package/src/audit/checks/soft-404.ts +0 -151
  93. package/src/audit/checks/structured-data.ts +0 -238
  94. package/src/audit/checks/tech-detection.ts +0 -496
  95. package/src/audit/checks/topical-clusters.ts +0 -435
  96. package/src/audit/checks/tracker-bloat.ts +0 -462
  97. package/src/audit/checks/tracking-verification.test.ts +0 -371
  98. package/src/audit/checks/tracking-verification.ts +0 -636
  99. package/src/audit/checks/url-safety.ts +0 -682
  100. package/src/audit/deno-entry.ts +0 -66
  101. package/src/audit/discovery/index.ts +0 -15
  102. package/src/audit/discovery/link-crawler.ts +0 -233
  103. package/src/audit/discovery/repo-routes.ts +0 -347
  104. package/src/audit/engine.ts +0 -633
  105. package/src/audit/fixes/index.ts +0 -209
  106. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  107. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  108. package/src/audit/index.ts +0 -74
  109. package/src/audit/runner.test.ts +0 -299
  110. package/src/audit/runner.ts +0 -130
  111. package/src/audit/types.ts +0 -1987
  112. package/src/content/featured-snippet.ts +0 -367
  113. package/src/content/generator.test.ts +0 -534
  114. package/src/content/generator.ts +0 -501
  115. package/src/content/headline.ts +0 -317
  116. package/src/content/index.ts +0 -62
  117. package/src/content/intent.ts +0 -258
  118. package/src/content/keyword-density.ts +0 -349
  119. package/src/content/readability.ts +0 -262
  120. package/src/executor.ts +0 -336
  121. package/src/fixer/framework-fixes.test.ts +0 -489
  122. package/src/fixer/framework-fixes.ts +0 -5287
  123. package/src/fixer/index.ts +0 -6
  124. package/src/fixer/schemas.ts +0 -971
  125. package/src/fixer.ts +0 -642
  126. package/src/frameworks/detector.test.ts +0 -248
  127. package/src/frameworks/detector.ts +0 -899
  128. package/src/frameworks/index.ts +0 -68
  129. package/src/frameworks/recipes/angular.yaml +0 -171
  130. package/src/frameworks/recipes/astro.yaml +0 -206
  131. package/src/frameworks/recipes/django.yaml +0 -180
  132. package/src/frameworks/recipes/laravel.yaml +0 -137
  133. package/src/frameworks/recipes/nextjs.yaml +0 -268
  134. package/src/frameworks/recipes/nuxt.yaml +0 -175
  135. package/src/frameworks/recipes/rails.yaml +0 -188
  136. package/src/frameworks/recipes/react.yaml +0 -202
  137. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  138. package/src/frameworks/recipes/vue.yaml +0 -137
  139. package/src/frameworks/recipes/wordpress.yaml +0 -209
  140. package/src/frameworks/suggestion-engine.ts +0 -357
  141. package/src/geo/geo-content.test.ts +0 -305
  142. package/src/geo/geo-content.ts +0 -266
  143. package/src/geo/geo-history.test.ts +0 -473
  144. package/src/geo/geo-history.ts +0 -433
  145. package/src/geo/geo-tracker.test.ts +0 -359
  146. package/src/geo/geo-tracker.ts +0 -411
  147. package/src/geo/index.ts +0 -11
  148. package/src/geo/llm-citation-checker.ts +0 -188
  149. package/src/git/commit-helper.test.ts +0 -261
  150. package/src/git/commit-helper.ts +0 -329
  151. package/src/git/index.ts +0 -12
  152. package/src/git/pr-helper.test.ts +0 -284
  153. package/src/git/pr-helper.ts +0 -307
  154. package/src/index.ts +0 -76
  155. package/src/keywords/ai-keyword-engine.ts +0 -1062
  156. package/src/keywords/ai-summarizer.ts +0 -387
  157. package/src/keywords/ci-mode.ts +0 -555
  158. package/src/keywords/engine.ts +0 -359
  159. package/src/keywords/index.ts +0 -151
  160. package/src/keywords/llm-judge.ts +0 -357
  161. package/src/keywords/nlp-analysis.ts +0 -706
  162. package/src/keywords/prioritizer.ts +0 -295
  163. package/src/keywords/site-crawler.ts +0 -342
  164. package/src/keywords/sources/autocomplete.ts +0 -139
  165. package/src/keywords/sources/competitive-search.ts +0 -450
  166. package/src/keywords/sources/competitor-analysis.ts +0 -374
  167. package/src/keywords/sources/dataforseo.ts +0 -206
  168. package/src/keywords/sources/free-sources.ts +0 -294
  169. package/src/keywords/sources/gsc.ts +0 -123
  170. package/src/keywords/topic-grouping.ts +0 -327
  171. package/src/keywords/types.ts +0 -144
  172. package/src/keywords/wizard.ts +0 -457
  173. package/src/loader.ts +0 -40
  174. package/src/ranking/index.ts +0 -5
  175. package/src/ranking/serp-client.ts +0 -348
  176. package/src/ranking/tracker.ts +0 -380
  177. package/src/ranking/types.ts +0 -123
  178. package/src/reports/index.ts +0 -7
  179. package/src/reports/report-generator.test.ts +0 -293
  180. package/src/reports/report-generator.ts +0 -713
  181. package/src/scheduler/alerts.test.ts +0 -458
  182. package/src/scheduler/alerts.ts +0 -328
  183. package/src/scheduler/index.ts +0 -8
  184. package/src/scheduler/scheduled-audit.test.ts +0 -377
  185. package/src/scheduler/scheduled-audit.ts +0 -149
  186. package/src/test/integration-test.ts +0 -325
  187. package/src/tools/analyzer.ts +0 -373
  188. package/src/tools/crawl.ts +0 -293
  189. package/src/tools/files.ts +0 -301
  190. package/src/tools/h1-fixer.ts +0 -249
  191. package/src/tools/index.ts +0 -67
  192. package/src/tracking/github-action.ts +0 -326
  193. package/src/tracking/google-analytics.ts +0 -265
  194. package/src/tracking/index.ts +0 -45
  195. package/src/tracking/report-generator.ts +0 -386
  196. package/src/tracking/search-console.ts +0 -335
  197. package/src/types.ts +0 -148
  198. package/src/utils/http.ts +0 -302
  199. package/src/wasm-adapter.ts +0 -297
  200. package/src/wasm-entry.ts +0 -14
  201. package/tsconfig.json +0 -17
  202. package/tsup.wasm.config.ts +0 -26
  203. package/vitest.config.ts +0 -15
@@ -1,457 +0,0 @@
1
- /**
2
- * Keyword Research Wizard
3
- *
4
- * Interactive wizard to reduce uncertainty in keyword research.
5
- * Works with CLI (inquirer-style) and Web (JSON responses).
6
- */
7
-
8
- import OpenAI from 'openai';
9
- import { crawlSite } from './site-crawler.js';
10
- import { summarizeSite, type SiteSummary } from './ai-summarizer.js';
11
-
12
- export interface WizardQuestion {
13
- id: string;
14
- question: string;
15
- description?: string;
16
- type: 'select' | 'multi-select' | 'text' | 'confirm';
17
- options?: Array<{
18
- value: string;
19
- label: string;
20
- description?: string;
21
- }>;
22
- required: boolean;
23
- impactOnConfidence: number;
24
- category: 'product' | 'audience' | 'competition' | 'goals' | 'constraints';
25
- }
26
-
27
- export interface WizardResponse {
28
- questionId: string;
29
- answer: string | string[];
30
- confidence: 'certain' | 'somewhat' | 'unsure';
31
- }
32
-
33
- export interface WizardSession {
34
- sessionId: string;
35
- url: string;
36
- siteSummary: SiteSummary;
37
- questions: WizardQuestion[];
38
- responses: WizardResponse[];
39
- currentQuestionIndex: number;
40
- isComplete: boolean;
41
- finalConfidence: number;
42
- }
43
-
44
- export interface WizardResult {
45
- session: WizardSession;
46
- canProceed: boolean;
47
- message: string;
48
- nextSteps: string[];
49
- }
50
-
51
- /**
52
- * Start a new wizard session
53
- */
54
- export async function startWizardSession(
55
- url: string,
56
- options: {
57
- openaiApiKey?: string;
58
- existingResponses?: WizardResponse[];
59
- } = {}
60
- ): Promise<WizardSession> {
61
- // Crawl site first
62
- console.log('🔍 Analyzing your site...');
63
- const crawlResult = await crawlSite(url, { maxPages: 10 });
64
-
65
- // Get AI summary if API key available
66
- let siteSummary: SiteSummary;
67
- if (options.openaiApiKey) {
68
- siteSummary = await summarizeSite(crawlResult, {
69
- openaiApiKey: options.openaiApiKey,
70
- });
71
- } else {
72
- // Basic summary without AI
73
- siteSummary = {
74
- productName: crawlResult.domain,
75
- productDescription: 'Unable to determine - AI analysis required',
76
- targetAudience: 'Unknown',
77
- keyFeatures: crawlResult.uniqueHeadings.slice(0, 5),
78
- industry: 'Unknown',
79
- businessModel: 'other',
80
- valueProposition: '',
81
- useCases: [],
82
- problemsSolved: [],
83
- suggestedSeedKeywords: [],
84
- confidence: 0.2,
85
- uncertainties: [
86
- 'Product description needs user input',
87
- 'Target audience is unknown',
88
- 'Industry classification needed',
89
- 'Value proposition unclear',
90
- ],
91
- };
92
- }
93
-
94
- // Generate questions based on uncertainty
95
- const questions = generateWizardQuestions(siteSummary);
96
-
97
- // Apply any existing responses
98
- let responses: WizardResponse[] = [];
99
- let currentIndex = 0;
100
-
101
- if (options.existingResponses) {
102
- responses = options.existingResponses;
103
- currentIndex = responses.length;
104
- }
105
-
106
- return {
107
- sessionId: `wizard_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
108
- url,
109
- siteSummary,
110
- questions,
111
- responses,
112
- currentQuestionIndex: currentIndex,
113
- isComplete: currentIndex >= questions.length,
114
- finalConfidence: siteSummary.confidence,
115
- };
116
- }
117
-
118
- /**
119
- * Generate wizard questions based on site summary uncertainty
120
- */
121
- export function generateWizardQuestions(summary: SiteSummary): WizardQuestion[] {
122
- const questions: WizardQuestion[] = [];
123
-
124
- // Question 1: Product Description (if unclear)
125
- if (summary.confidence < 0.8 || summary.productDescription.includes('Unable')) {
126
- questions.push({
127
- id: 'product_description',
128
- question: 'What does your product/service do?',
129
- description: 'Describe your product in 1-2 sentences',
130
- type: 'text',
131
- required: true,
132
- impactOnConfidence: 0.25,
133
- category: 'product',
134
- });
135
- }
136
-
137
- // Question 2: Target Audience
138
- if (summary.targetAudience === 'Unknown' || summary.confidence < 0.7) {
139
- questions.push({
140
- id: 'target_audience',
141
- question: 'Who is your primary target customer?',
142
- description: 'Select the option that best describes your ideal customer',
143
- type: 'select',
144
- options: [
145
- { value: 'small_business', label: 'Small Businesses', description: '1-50 employees' },
146
- { value: 'mid_market', label: 'Mid-Market Companies', description: '50-500 employees' },
147
- { value: 'enterprise', label: 'Enterprise', description: '500+ employees' },
148
- { value: 'developers', label: 'Developers/Technical Users', description: 'Individual devs or dev teams' },
149
- { value: 'marketers', label: 'Marketing Teams', description: 'Marketing professionals' },
150
- { value: 'consumers', label: 'Individual Consumers', description: 'B2C audience' },
151
- { value: 'freelancers', label: 'Freelancers/Agencies', description: 'Independent professionals' },
152
- { value: 'other', label: 'Other', description: 'Will specify below' },
153
- ],
154
- required: true,
155
- impactOnConfidence: 0.2,
156
- category: 'audience',
157
- });
158
- }
159
-
160
- // Question 3: Industry/Category
161
- if (summary.industry === 'Unknown') {
162
- questions.push({
163
- id: 'industry',
164
- question: 'What industry or category is your product in?',
165
- description: 'e.g., "Marketing Automation", "Project Management", "AI Tools"',
166
- type: 'text',
167
- required: true,
168
- impactOnConfidence: 0.15,
169
- category: 'product',
170
- });
171
- }
172
-
173
- // Question 4: Main Problem Solved
174
- if (summary.problemsSolved.length === 0) {
175
- questions.push({
176
- id: 'main_problem',
177
- question: 'What is the main problem your product solves?',
178
- description: 'Be specific about the pain point you address',
179
- type: 'text',
180
- required: true,
181
- impactOnConfidence: 0.2,
182
- category: 'product',
183
- });
184
- }
185
-
186
- // Question 5: Competitors
187
- questions.push({
188
- id: 'competitors',
189
- question: 'Who are your main competitors?',
190
- description: 'List 2-5 competitors (comma-separated)',
191
- type: 'text',
192
- required: false,
193
- impactOnConfidence: 0.1,
194
- category: 'competition',
195
- });
196
-
197
- // Question 6: Differentiator
198
- if (!summary.nicheFocus) {
199
- questions.push({
200
- id: 'differentiator',
201
- question: 'What makes your product different from competitors?',
202
- description: 'Your unique selling point or niche focus',
203
- type: 'text',
204
- required: false,
205
- impactOnConfidence: 0.15,
206
- category: 'competition',
207
- });
208
- }
209
-
210
- // Question 7: Business Goal
211
- questions.push({
212
- id: 'business_goal',
213
- question: 'What is your primary SEO goal?',
214
- type: 'select',
215
- options: [
216
- { value: 'signups', label: 'Get More Signups/Trials', description: 'SaaS, apps, services' },
217
- { value: 'leads', label: 'Generate Leads', description: 'Contact forms, demos' },
218
- { value: 'traffic', label: 'Drive Organic Traffic', description: 'Content, ad revenue' },
219
- { value: 'awareness', label: 'Build Brand Awareness', description: 'Thought leadership' },
220
- { value: 'sales', label: 'Direct Sales', description: 'E-commerce, purchases' },
221
- ],
222
- required: true,
223
- impactOnConfidence: 0.1,
224
- category: 'goals',
225
- });
226
-
227
- // Question 8: Content Capacity
228
- questions.push({
229
- id: 'content_capacity',
230
- question: 'How much content can you produce monthly?',
231
- type: 'select',
232
- options: [
233
- { value: 'low', label: '1-2 pages/month', description: 'Limited time or resources' },
234
- { value: 'medium', label: '3-5 pages/month', description: 'Moderate output' },
235
- { value: 'high', label: '6+ pages/month', description: 'Dedicated content team' },
236
- ],
237
- required: true,
238
- impactOnConfidence: 0.05,
239
- category: 'constraints',
240
- });
241
-
242
- // Question 9: Domain Authority (self-assessment)
243
- questions.push({
244
- id: 'domain_authority',
245
- question: 'How would you describe your website\'s current SEO standing?',
246
- type: 'select',
247
- options: [
248
- { value: 'new', label: 'New Site', description: 'Less than 6 months old, few/no backlinks' },
249
- { value: 'growing', label: 'Growing Site', description: '6-24 months, some backlinks' },
250
- { value: 'established', label: 'Established Site', description: '2+ years, decent backlinks' },
251
- { value: 'authority', label: 'Authority Site', description: 'Strong domain, many backlinks' },
252
- ],
253
- required: true,
254
- impactOnConfidence: 0.05,
255
- category: 'constraints',
256
- });
257
-
258
- // Sort by impact
259
- return questions.sort((a, b) => b.impactOnConfidence - a.impactOnConfidence);
260
- }
261
-
262
- /**
263
- * Process a wizard response and update session
264
- */
265
- export function processWizardResponse(
266
- session: WizardSession,
267
- response: WizardResponse
268
- ): WizardSession {
269
- // Add response
270
- const responses = [...session.responses, response];
271
-
272
- // Calculate new confidence
273
- const question = session.questions.find((q) => q.id === response.questionId);
274
- let confidenceBoost = question?.impactOnConfidence || 0;
275
-
276
- // Reduce boost if user is unsure
277
- if (response.confidence === 'unsure') {
278
- confidenceBoost *= 0.5;
279
- } else if (response.confidence === 'somewhat') {
280
- confidenceBoost *= 0.75;
281
- }
282
-
283
- const newConfidence = Math.min(1, session.finalConfidence + confidenceBoost);
284
-
285
- // Update current index
286
- const currentIndex = session.currentQuestionIndex + 1;
287
- const isComplete = currentIndex >= session.questions.length;
288
-
289
- return {
290
- ...session,
291
- responses,
292
- currentQuestionIndex: currentIndex,
293
- isComplete,
294
- finalConfidence: newConfidence,
295
- };
296
- }
297
-
298
- /**
299
- * Get the next question in the wizard
300
- */
301
- export function getNextQuestion(session: WizardSession): WizardQuestion | null {
302
- if (session.isComplete) return null;
303
- return session.questions[session.currentQuestionIndex] || null;
304
- }
305
-
306
- /**
307
- * Skip to a specific question
308
- */
309
- export function skipToQuestion(session: WizardSession, questionId: string): WizardSession {
310
- const index = session.questions.findIndex((q) => q.id === questionId);
311
- if (index === -1) return session;
312
-
313
- return {
314
- ...session,
315
- currentQuestionIndex: index,
316
- };
317
- }
318
-
319
- /**
320
- * Complete the wizard and get result
321
- */
322
- export function completeWizard(session: WizardSession): WizardResult {
323
- const canProceed = session.finalConfidence >= 0.6;
324
-
325
- let message: string;
326
- let nextSteps: string[] = [];
327
-
328
- if (canProceed) {
329
- message = `✅ Confidence level: ${Math.round(session.finalConfidence * 100)}%. Ready to generate keyword recommendations.`;
330
- nextSteps = [
331
- 'Run keyword research with your responses',
332
- 'Review and prioritize suggested keywords',
333
- 'Start with low-difficulty, high-relevance keywords',
334
- ];
335
- } else {
336
- message = `⚠️ Confidence level: ${Math.round(session.finalConfidence * 100)}%. Consider providing more details for better recommendations.`;
337
- nextSteps = [
338
- 'Answer any skipped questions',
339
- 'Provide more specific details in text answers',
340
- 'Run with lower confidence (results may be less accurate)',
341
- ];
342
- }
343
-
344
- return {
345
- session,
346
- canProceed,
347
- message,
348
- nextSteps,
349
- };
350
- }
351
-
352
- /**
353
- * Convert wizard responses to keyword research context
354
- */
355
- export function wizardResponsesToContext(
356
- session: WizardSession
357
- ): {
358
- productDescription?: string;
359
- targetAudience?: string;
360
- competitors?: string[];
361
- mainProblem?: string;
362
- differentiator?: string;
363
- businessGoal?: string;
364
- contentCapacity?: string;
365
- domainAuthority?: string;
366
- } {
367
- const context: Record<string, any> = {};
368
-
369
- for (const response of session.responses) {
370
- const answer = Array.isArray(response.answer) ? response.answer.join(', ') : response.answer;
371
-
372
- switch (response.questionId) {
373
- case 'product_description':
374
- context.productDescription = answer;
375
- break;
376
- case 'target_audience':
377
- context.targetAudience = answer;
378
- break;
379
- case 'competitors':
380
- context.competitors = answer.split(',').map((c: string) => c.trim()).filter(Boolean);
381
- break;
382
- case 'main_problem':
383
- context.mainProblem = answer;
384
- break;
385
- case 'differentiator':
386
- context.differentiator = answer;
387
- break;
388
- case 'business_goal':
389
- context.businessGoal = answer;
390
- break;
391
- case 'content_capacity':
392
- context.contentCapacity = answer;
393
- break;
394
- case 'domain_authority':
395
- context.domainAuthority = answer;
396
- break;
397
- case 'industry':
398
- context.industry = answer;
399
- break;
400
- }
401
- }
402
-
403
- return context;
404
- }
405
-
406
- /**
407
- * Format wizard session for CLI output
408
- */
409
- export function formatWizardProgress(session: WizardSession): string {
410
- const lines: string[] = [];
411
-
412
- lines.push('');
413
- lines.push('═'.repeat(60));
414
- lines.push(' KEYWORD RESEARCH WIZARD');
415
- lines.push('═'.repeat(60));
416
- lines.push('');
417
- lines.push(` Site: ${session.url}`);
418
- lines.push(` Progress: ${session.currentQuestionIndex}/${session.questions.length} questions`);
419
- lines.push(` Confidence: ${Math.round(session.finalConfidence * 100)}%`);
420
- lines.push('');
421
-
422
- // Progress bar
423
- const progress = session.currentQuestionIndex / session.questions.length;
424
- const filled = Math.round(progress * 40);
425
- const empty = 40 - filled;
426
- lines.push(` [${'█'.repeat(filled)}${'░'.repeat(empty)}]`);
427
- lines.push('');
428
-
429
- // Current question
430
- const current = getNextQuestion(session);
431
- if (current) {
432
- lines.push('─'.repeat(60));
433
- lines.push(` Question ${session.currentQuestionIndex + 1}:`);
434
- lines.push(` ${current.question}`);
435
- if (current.description) {
436
- lines.push(` (${current.description})`);
437
- }
438
- lines.push('');
439
-
440
- if (current.options) {
441
- lines.push(' Options:');
442
- current.options.forEach((opt, i) => {
443
- lines.push(` ${i + 1}. ${opt.label}`);
444
- if (opt.description) {
445
- lines.push(` ${opt.description}`);
446
- }
447
- });
448
- }
449
- } else {
450
- lines.push(' ✅ All questions answered!');
451
- }
452
-
453
- lines.push('');
454
- lines.push('═'.repeat(60));
455
-
456
- return lines.join('\n');
457
- }
package/src/loader.ts DELETED
@@ -1,40 +0,0 @@
1
- import { readFileSync, existsSync } from 'fs';
2
- import { parse as parseYaml } from 'yaml';
3
- import { join } from 'path';
4
- import type { AgentDefinition } from './types.js';
5
-
6
- export function loadAgent(agentPath: string): AgentDefinition {
7
- if (!existsSync(agentPath)) {
8
- throw new Error(`Agent file not found: ${agentPath}`);
9
- }
10
-
11
- const content = readFileSync(agentPath, 'utf-8');
12
- const agent = parseYaml(content) as AgentDefinition;
13
-
14
- // Validate required fields
15
- if (!agent.name) throw new Error('Agent missing required field: name');
16
- if (!agent.model) throw new Error('Agent missing required field: model');
17
- if (!agent.system) throw new Error('Agent missing required field: system');
18
- if (!agent.prompt) throw new Error('Agent missing required field: prompt');
19
-
20
- // Set defaults
21
- agent.temperature = agent.temperature ?? 0.1;
22
- agent.max_tokens = agent.max_tokens ?? 4096;
23
- agent.tools = agent.tools ?? [];
24
-
25
- return agent;
26
- }
27
-
28
- export function loadAgentByName(name: string, agentsDir?: string): AgentDefinition {
29
- const baseDir = agentsDir || join(process.cwd(), 'agents');
30
- const agentPath = join(baseDir, `${name}.yaml`);
31
- return loadAgent(agentPath);
32
- }
33
-
34
- export function interpolatePrompt(template: string, variables: Record<string, string>): string {
35
- let result = template;
36
- for (const [key, value] of Object.entries(variables)) {
37
- result = result.replace(new RegExp(`\\{\\{\\s*${key}\\s*\\}\\}`, 'g'), value);
38
- }
39
- return result;
40
- }
@@ -1,5 +0,0 @@
1
- // Ranking Module - Keyword position tracking and SERP analysis
2
-
3
- export * from './types.js';
4
- export * from './serp-client.js';
5
- export * from './tracker.js';