@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,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';