@ai-lighthouse/cli 1.0.0

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 (103) hide show
  1. package/.ai-lighthouse/audit_example.com_2025-12-15T12-10-43.json +183 -0
  2. package/.ai-lighthouse/audit_fayeed.dev_2026-01-07T19-32-28.html +743 -0
  3. package/.ai-lighthouse/audit_fayeed.dev_2026-01-07T19-33-02.html +757 -0
  4. package/.ai-lighthouse/audit_github.com_2025-12-15T11-53-21.json +168 -0
  5. package/.ai-lighthouse/audit_github.com_2025-12-15T12-04-06.json +168 -0
  6. package/.ai-lighthouse/audit_github.com_2025-12-15T12-05-10.json +168 -0
  7. package/.ai-lighthouse/audit_github.com_2025-12-15T12-09-45.json +168 -0
  8. package/.ai-lighthouse/audit_github.com_2025-12-15T12-11-07.json +168 -0
  9. package/.ai-lighthouse/audit_github.com_2025-12-15T12-13-28.json +168 -0
  10. package/.ai-lighthouse/audit_github.com_2025-12-15T12-14-59.json +205 -0
  11. package/.ai-lighthouse/audit_github.com_2025-12-15T12-18-07.json +205 -0
  12. package/.ai-lighthouse/audit_github.com_2025-12-15T12-18-44.json +205 -0
  13. package/.ai-lighthouse/audit_github.com_2025-12-15T12-21-38.json +205 -0
  14. package/.ai-lighthouse/audit_github.com_2025-12-15T12-22-21.json +205 -0
  15. package/.ai-lighthouse/audit_github.com_2025-12-15T12-22-46.json +205 -0
  16. package/.ai-lighthouse/audit_github.com_2025-12-15T12-23-18.json +205 -0
  17. package/.ai-lighthouse/audit_github.com_2025-12-15T12-24-43.json +205 -0
  18. package/.ai-lighthouse/audit_github.com_2025-12-17T12-15-08.json +168 -0
  19. package/.ai-lighthouse/audit_github.com_2025-12-17T12-15-57.json +168 -0
  20. package/.ai-lighthouse/audit_github.com_2025-12-17T12-17-11.json +168 -0
  21. package/.ai-lighthouse/audit_github.com_2025-12-17T12-22-17.json +168 -0
  22. package/.ai-lighthouse/audit_github.com_2025-12-17T12-22-42.json +168 -0
  23. package/.ai-lighthouse/audit_github.com_2025-12-17T12-23-56.json +168 -0
  24. package/.ai-lighthouse/audit_github.com_2025-12-17T12-25-24.json +168 -0
  25. package/.ai-lighthouse/audit_github.com_2025-12-17T12-25-40.json +168 -0
  26. package/.ai-lighthouse/audit_github.com_2025-12-17T12-27-02.json +168 -0
  27. package/.ai-lighthouse/audit_github.com_2025-12-17T12-27-20.json +168 -0
  28. package/.ai-lighthouse/audit_github.com_2025-12-17T12-29-56.json +168 -0
  29. package/.ai-lighthouse/audit_github.com_2025-12-17T12-32-27.json +168 -0
  30. package/.ai-lighthouse/audit_github.com_2025-12-17T12-33-00.json +168 -0
  31. package/.ai-lighthouse/audit_github.com_2025-12-17T12-34-49.json +168 -0
  32. package/.ai-lighthouse/audit_stripe.com_2025-12-15T12-11-31.json +168 -0
  33. package/.ai-lighthouse/audit_stripe.com_2025-12-15T12-11-45.json +168 -0
  34. package/.ai-lighthouse/audit_tailwindcss.com_2025-12-15T12-12-01.json +169 -0
  35. package/.ai-lighthouse/crawl_example.com_2025-12-15T12-03-08.json +24 -0
  36. package/.ai-lighthouse/crawl_example.com_2025-12-15T12-03-23.json +24 -0
  37. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-41-34.json +21 -0
  38. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-42-09.json +21 -0
  39. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-42-45.json +21 -0
  40. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-43-02.json +21 -0
  41. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-43-26.json +21 -0
  42. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-47-46.json +906 -0
  43. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-50-27.json +906 -0
  44. package/.ai-lighthouse/crawl_github.com_2025-12-15T11-52-59.json +906 -0
  45. package/.ai-lighthouse/crawl_github.com_2025-12-15T12-03-33.json +28 -0
  46. package/CLI_UI_README.md +211 -0
  47. package/EXAMPLES.md +87 -0
  48. package/IMPLEMENTATION.md +215 -0
  49. package/README.md +166 -0
  50. package/USAGE.md +264 -0
  51. package/WIZARD_GUIDE.md +340 -0
  52. package/bin/cli.js +2 -0
  53. package/dist/commands/audit-interactive.d.ts +2 -0
  54. package/dist/commands/audit-interactive.js +106 -0
  55. package/dist/commands/audit-wizard.d.ts +2 -0
  56. package/dist/commands/audit-wizard.js +110 -0
  57. package/dist/commands/audit.d.ts +2 -0
  58. package/dist/commands/audit.js +940 -0
  59. package/dist/commands/crawl.d.ts +2 -0
  60. package/dist/commands/crawl.js +267 -0
  61. package/dist/commands/report.d.ts +2 -0
  62. package/dist/commands/report.js +304 -0
  63. package/dist/index.d.ts +1 -0
  64. package/dist/index.js +16 -0
  65. package/dist/ui/AuditReportUI.d.ts +10 -0
  66. package/dist/ui/AuditReportUI.js +76 -0
  67. package/dist/ui/SetupWizard.d.ts +18 -0
  68. package/dist/ui/SetupWizard.js +179 -0
  69. package/dist/ui/components/AIUnderstandingSection.d.ts +6 -0
  70. package/dist/ui/components/AIUnderstandingSection.js +87 -0
  71. package/dist/ui/components/HallucinationSection.d.ts +6 -0
  72. package/dist/ui/components/HallucinationSection.js +84 -0
  73. package/dist/ui/components/IssuesSection.d.ts +6 -0
  74. package/dist/ui/components/IssuesSection.js +84 -0
  75. package/dist/ui/components/MessageAlignmentSection.d.ts +6 -0
  76. package/dist/ui/components/MessageAlignmentSection.js +108 -0
  77. package/dist/ui/components/OverviewSection.d.ts +6 -0
  78. package/dist/ui/components/OverviewSection.js +107 -0
  79. package/dist/ui/components/ScoreDisplay.d.ts +8 -0
  80. package/dist/ui/components/ScoreDisplay.js +41 -0
  81. package/dist/ui/components/TechnicalSection.d.ts +7 -0
  82. package/dist/ui/components/TechnicalSection.js +110 -0
  83. package/dist/utils/comprehensive-formatter.d.ts +5 -0
  84. package/dist/utils/comprehensive-formatter.js +370 -0
  85. package/package.json +49 -0
  86. package/src/commands/audit-interactive.ts +149 -0
  87. package/src/commands/audit-wizard.ts +137 -0
  88. package/src/commands/audit.ts +1012 -0
  89. package/src/commands/crawl.ts +307 -0
  90. package/src/commands/report.ts +321 -0
  91. package/src/index.ts +22 -0
  92. package/src/ui/AuditReportUI.tsx +151 -0
  93. package/src/ui/SetupWizard.tsx +294 -0
  94. package/src/ui/components/AIUnderstandingSection.tsx +183 -0
  95. package/src/ui/components/HallucinationSection.tsx +172 -0
  96. package/src/ui/components/IssuesSection.tsx +140 -0
  97. package/src/ui/components/MessageAlignmentSection.tsx +203 -0
  98. package/src/ui/components/OverviewSection.tsx +157 -0
  99. package/src/ui/components/ScoreDisplay.tsx +58 -0
  100. package/src/ui/components/TechnicalSection.tsx +200 -0
  101. package/src/utils/comprehensive-formatter.ts +455 -0
  102. package/test.sh +31 -0
  103. package/tsconfig.json +25 -0
@@ -0,0 +1,340 @@
1
+ # AI Lighthouse Interactive Wizard Guide
2
+
3
+ The AI Lighthouse CLI now features an **interactive setup wizard** that simplifies configuration by asking you questions instead of requiring complex command-line flags!
4
+
5
+ ## Quick Start
6
+
7
+ ### Option 1: Wizard with URL
8
+
9
+ ```bash
10
+ ai-lighthouse wizard https://example.com
11
+ ```
12
+
13
+ or use the short alias:
14
+
15
+ ```bash
16
+ ai-lighthouse w https://example.com
17
+ ```
18
+
19
+ ### Option 2: Wizard without URL (asks you for it)
20
+
21
+ ```bash
22
+ ai-lighthouse wizard
23
+ ```
24
+
25
+ ## How It Works
26
+
27
+ The wizard guides you through a simple, step-by-step configuration process:
28
+
29
+ ### Step 1: URL Input (if not provided)
30
+
31
+ ```
32
+ 🚨 AI Lighthouse Setup Wizard
33
+ Configure your audit settings
34
+
35
+ Enter the URL to audit:
36
+ URL: _
37
+ ```
38
+
39
+ Type your URL and press Enter.
40
+
41
+ ### Step 2: Feature Selection
42
+
43
+ ```
44
+ Select features to enable:
45
+ Selected: None (basic audit only)
46
+
47
+ 🧠 AI Understanding (LLM Analysis)
48
+ 📄 Content Chunking Analysis
49
+ 🔄 Extractability Analysis
50
+ ⚠️ Hallucination Detection
51
+ ✅ Continue with selected features
52
+
53
+ Use ↑↓ to navigate, Enter to toggle/continue
54
+ ```
55
+
56
+ - Use **↑** and **↓** arrow keys to navigate
57
+ - Press **Enter** to toggle features on/off (✓ appears when selected)
58
+ - Select **✅ Continue** when ready
59
+
60
+ ### Step 3: LLM Provider Selection (if LLM features enabled)
61
+
62
+ ```
63
+ Select LLM provider:
64
+
65
+ OpenAI (GPT-4, GPT-3.5)
66
+ Anthropic (Claude)
67
+ Ollama (Local)
68
+ Custom/Local Provider
69
+
70
+ Use ↑↓ to navigate, Enter to select
71
+ ```
72
+
73
+ Choose your preferred LLM provider.
74
+
75
+ ### Step 4: Model Name
76
+
77
+ ```
78
+ Enter LLM model name:
79
+ Model: _
80
+
81
+ Leave empty for default, or press Enter to continue
82
+ ```
83
+
84
+ **Defaults:**
85
+ - OpenAI: `gpt-4o-mini`
86
+ - Anthropic: `claude-3-5-sonnet-20241022`
87
+ - Ollama: `qwen2.5:0.5b` (or any installed model)
88
+
89
+ ### Step 5: API Key (for OpenAI/Anthropic)
90
+
91
+ ```
92
+ Enter API key:
93
+ API Key: ****
94
+
95
+ Your API key will not be stored
96
+ ```
97
+
98
+ Type your API key (it will be masked with `*` for security).
99
+
100
+ ### Step 6: Base URL (optional, for Ollama/Custom)
101
+
102
+ ```
103
+ Enter API base URL (optional):
104
+ Base URL: _
105
+
106
+ Press Enter to continue (leave empty for default)
107
+ ```
108
+
109
+ **Defaults:**
110
+ - Ollama: `http://localhost:11434` (auto-filled)
111
+ - Custom: You specify
112
+
113
+ ### Step 7: Running the Audit
114
+
115
+ ```
116
+ ✓ Configuration Complete
117
+ Starting audit...
118
+ ```
119
+
120
+ The wizard automatically transitions to the audit UI!
121
+
122
+ ## Wizard vs. Traditional Commands
123
+
124
+ ### With Wizard (Simplified)
125
+
126
+ ```bash
127
+ # Just run the wizard
128
+ ai-lighthouse wizard https://example.com
129
+
130
+ # Then follow the prompts:
131
+ # 1. Select "AI Understanding (LLM Analysis)" ✓
132
+ # 2. Select "Hallucination Detection" ✓
133
+ # 3. Select "Continue"
134
+ # 4. Choose "Ollama (Local)"
135
+ # 5. Enter model: "qwen2.5:0.5b"
136
+ # 6. Confirm base URL: "http://localhost:11434"
137
+ # Done!
138
+ ```
139
+
140
+ ### Without Wizard (Traditional)
141
+
142
+ ```bash
143
+ ai-lighthouse audit https://example.com \
144
+ --enable-llm \
145
+ --enable-hallucination \
146
+ --llm-provider ollama \
147
+ --llm-model qwen2.5:0.5b \
148
+ --llm-base-url http://localhost:11434
149
+ ```
150
+
151
+ The wizard is **much easier** for beginners and interactive use!
152
+
153
+ ## Feature Matrix
154
+
155
+ When you select features in the wizard:
156
+
157
+ | Feature Selected | What It Enables |
158
+ |-----------------|-----------------|
159
+ | 🧠 AI Understanding | LLM-powered page analysis, entity extraction, FAQ suggestions |
160
+ | 📄 Content Chunking | Shows how your content is divided for AI processing |
161
+ | 🔄 Extractability | Analyzes how well AI can extract your content |
162
+ | ⚠️ Hallucination Detection | Identifies potential hallucination triggers (requires AI Understanding) |
163
+
164
+ ## Tips & Tricks
165
+
166
+ ### Quick Basic Audit
167
+
168
+ ```bash
169
+ # Wizard with URL, select "Continue" without features
170
+ ai-lighthouse w https://example.com
171
+ ```
172
+
173
+ ### Full-Featured Audit
174
+
175
+ ```bash
176
+ # Enable all features in the wizard
177
+ ai-lighthouse wizard https://example.com
178
+ # Then select all 4 features before continuing
179
+ ```
180
+
181
+ ### Skip Wizard for Automation
182
+
183
+ For scripts and CI/CD, use the traditional `audit` command with flags:
184
+
185
+ ```bash
186
+ ai-lighthouse audit https://example.com --output json
187
+ ```
188
+
189
+ ## Common Workflows
190
+
191
+ ### First-Time User
192
+
193
+ 1. Run wizard: `ai-lighthouse wizard`
194
+ 2. Enter your website URL
195
+ 3. Try without features first (press "Continue")
196
+ 4. Review the basic report
197
+ 5. Run again with features to see more insights
198
+
199
+ ### Using Local Ollama
200
+
201
+ 1. Start Ollama: `ollama serve`
202
+ 2. Pull a small model: `ollama pull qwen2.5:0.5b`
203
+ 3. Run wizard: `ai-lighthouse w https://example.com`
204
+ 4. Select "AI Understanding" ✓
205
+ 5. Choose "Ollama (Local)"
206
+ 6. Enter model name: `qwen2.5:0.5b`
207
+ 7. Confirm default URL
208
+
209
+ ### Using OpenAI
210
+
211
+ 1. Get API key from https://platform.openai.com/api-keys
212
+ 2. Run wizard: `ai-lighthouse w https://example.com`
213
+ 3. Select desired features
214
+ 4. Choose "OpenAI (GPT-4, GPT-3.5)"
215
+ 5. Enter model: (leave empty for default or type `gpt-4o-mini`)
216
+ 6. Paste API key when prompted
217
+
218
+ ### Using Anthropic Claude
219
+
220
+ 1. Get API key from https://console.anthropic.com/
221
+ 2. Run wizard: `ai-lighthouse w https://example.com`
222
+ 3. Select features
223
+ 4. Choose "Anthropic (Claude)"
224
+ 5. Enter model: (leave empty for default)
225
+ 6. Paste API key when prompted
226
+
227
+ ## Keyboard Shortcuts in Wizard
228
+
229
+ - **↑** / **↓** - Navigate options
230
+ - **Enter** - Select/toggle option
231
+ - **Type** - Input text in text fields
232
+ - **Ctrl+C** - Cancel and exit
233
+
234
+ ## Benefits of Using the Wizard
235
+
236
+ ✅ **No memorization** - Don't need to remember complex flags
237
+ ✅ **Visual feedback** - See your selections with checkmarks
238
+ ✅ **Smart defaults** - Suggests appropriate defaults for each provider
239
+ ✅ **Guided flow** - Only asks relevant questions
240
+ ✅ **Error prevention** - Validates inputs as you go
241
+ ✅ **Security** - Masks sensitive API keys
242
+ ✅ **Quick setup** - Faster than typing long commands
243
+
244
+ ## When to Use Each Mode
245
+
246
+ ### Use the Wizard When:
247
+ - You're learning the tool
248
+ - You want to try different configurations
249
+ - You don't remember all the flags
250
+ - You're doing interactive analysis
251
+ - You want a guided experience
252
+
253
+ ### Use Direct Commands When:
254
+ - You're automating audits (CI/CD)
255
+ - You're writing scripts
256
+ - You know exactly what you want
257
+ - You're running batch operations
258
+ - You want to pipe output to other tools
259
+
260
+ ## Examples
261
+
262
+ ### Example 1: Quick Test Run
263
+
264
+ ```bash
265
+ $ ai-lighthouse w
266
+
267
+ 🚨 AI Lighthouse Setup Wizard
268
+ Configure your audit settings
269
+
270
+ Enter the URL to audit:
271
+ URL: https://example.com
272
+
273
+ Select features to enable:
274
+ Selected: None (basic audit only)
275
+ > ✅ Continue with selected features
276
+
277
+ ✓ Configuration Complete
278
+ Starting audit...
279
+
280
+ [Beautiful audit UI appears]
281
+ ```
282
+
283
+ ### Example 2: Full Analysis with Ollama
284
+
285
+ ```bash
286
+ $ ai-lighthouse wizard https://mysite.com
287
+
288
+ 🚨 AI Lighthouse Setup Wizard
289
+ Configure your audit settings
290
+
291
+ Select features to enable:
292
+ Selected: 🧠, 📄, 🔄, ⚠️
293
+ > ✅ Continue with selected features
294
+
295
+ Select LLM provider:
296
+ > Ollama (Local)
297
+
298
+ Enter LLM model name:
299
+ Model: llama2
300
+
301
+ Enter API base URL (optional):
302
+ Base URL: http://localhost:11434
303
+
304
+ ✓ Configuration Complete
305
+ Starting audit...
306
+
307
+ [Comprehensive audit with all features]
308
+ ```
309
+
310
+ ## Troubleshooting
311
+
312
+ ### Wizard doesn't start
313
+ - Make sure you're using `wizard` or `w` command
314
+ - Check that you have Node.js 18+ installed
315
+
316
+ ### API key not working
317
+ - Verify your API key is correct
318
+ - Check that you have credits/access
319
+ - Ensure you selected the right provider
320
+
321
+ ### Ollama connection fails
322
+ - Verify Ollama is running: `ollama list`
323
+ - Check the base URL is correct (default: `http://localhost:11434`)
324
+ - Ensure the model is pulled: `ollama pull modelname`
325
+
326
+ ### Features not showing data
327
+ - Make sure you enabled the features in the wizard
328
+ - Check that LLM analysis completed successfully
329
+ - Some features require LLM to be enabled
330
+
331
+ ## Next Steps
332
+
333
+ After using the wizard a few times, you might want to:
334
+
335
+ 1. **Save common configurations** - Use the traditional command with flags in a script
336
+ 2. **Explore all options** - Check `ai-lighthouse audit --help` for advanced flags
337
+ 3. **Automate audits** - Integrate into your CI/CD pipeline
338
+ 4. **Compare results** - Run audits regularly to track improvements
339
+
340
+ Happy auditing! 🚨✨
package/bin/cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import('../src/index.ts');
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function auditInteractiveCommand(program: Command): void;
@@ -0,0 +1,106 @@
1
+ import { analyzeUrlWithRules } from 'scanner';
2
+ import { calculateAIReadiness } from 'scanner';
3
+ import { render } from 'ink';
4
+ import React from 'react';
5
+ import { AuditReportUI } from '../ui/AuditReportUI.js';
6
+ export function auditInteractiveCommand(program) {
7
+ program
8
+ .command('audit-interactive')
9
+ .description('Audit a website for AI readiness with interactive UI')
10
+ .argument('<url>', 'URL to audit')
11
+ .option('-r, --rules <preset>', 'Rule preset: default, strict, minimal', 'default')
12
+ .option('-d, --depth <number>', 'Crawl depth (for multi-page audits)', parseInt, 1)
13
+ .option('-p, --pages <urls>', 'Comma-separated list of specific pages to audit')
14
+ .option('--cache-ttl <seconds>', 'Cache TTL in seconds to avoid re-fetching', parseInt)
15
+ .option('--threshold <score>', 'Minimum score threshold (exit 1 if below)', parseInt)
16
+ .option('--max-chunk-tokens <number>', 'Maximum tokens per content chunk', parseInt, 1200)
17
+ .option('--chunking-strategy <strategy>', 'Chunking strategy: auto, heading-based, paragraph-based', 'auto')
18
+ .option('--enable-chunking', 'Enable detailed content chunking analysis', false)
19
+ .option('--enable-extractability', 'Enable extractability mapping', false)
20
+ .option('--enable-hallucination', 'Enable hallucination detection', false)
21
+ .option('--enable-llm', 'Enable LLM comprehension analysis', false)
22
+ .option('--min-impact <number>', 'Minimum impact score to include', parseInt, 8)
23
+ .option('--min-confidence <number>', 'Minimum confidence to include (0-1)', parseFloat, 0.7)
24
+ .option('--max-issues <number>', 'Maximum issues to return', parseInt, 20)
25
+ .option('--llm-provider <provider>', 'LLM provider: openai, anthropic, ollama, local')
26
+ .option('--llm-model <model>', 'LLM model name')
27
+ .option('--llm-base-url <url>', 'LLM API base URL')
28
+ .option('--llm-api-key <key>', 'LLM API key')
29
+ .action(async (url, options) => {
30
+ // Show loading UI
31
+ const { waitUntilExit, clear, rerender } = render(React.createElement(AuditReportUI, {
32
+ url,
33
+ result: {},
34
+ aiReadiness: {},
35
+ loading: true,
36
+ currentStep: 'Starting audit...',
37
+ }));
38
+ try {
39
+ // Validate URL
40
+ const urlObj = new URL(url);
41
+ // Build scan options
42
+ const scanOptions = {
43
+ maxChunkTokens: options.maxChunkTokens,
44
+ chunkingStrategy: options.chunkingStrategy,
45
+ enableChunking: options.enableChunking,
46
+ enableExtractability: options.enableExtractability,
47
+ enableHallucinationDetection: options.enableHallucination,
48
+ enableLLM: options.enableLlm,
49
+ minImpactScore: options.minImpact,
50
+ minConfidence: options.minConfidence,
51
+ maxIssues: options.maxIssues,
52
+ };
53
+ // Configure LLM if enabled
54
+ if (options.enableLlm && options.llmProvider) {
55
+ scanOptions.llmConfig = {
56
+ provider: options.llmProvider,
57
+ model: options.llmModel,
58
+ baseUrl: options.llmBaseUrl,
59
+ apiKey: options.llmApiKey,
60
+ };
61
+ }
62
+ // Update loading step
63
+ rerender(React.createElement(AuditReportUI, {
64
+ url: urlObj.href,
65
+ result: {},
66
+ aiReadiness: {},
67
+ loading: true,
68
+ currentStep: 'Scanning page...',
69
+ }));
70
+ // Run the audit
71
+ const result = await analyzeUrlWithRules(url, scanOptions);
72
+ // Update loading step
73
+ rerender(React.createElement(AuditReportUI, {
74
+ url: urlObj.href,
75
+ result,
76
+ aiReadiness: {},
77
+ loading: true,
78
+ currentStep: 'Calculating AI readiness scores...',
79
+ }));
80
+ // Calculate AI readiness
81
+ const aiReadiness = calculateAIReadiness(result);
82
+ // Clear loading and show results
83
+ clear();
84
+ const finalRender = render(React.createElement(AuditReportUI, {
85
+ url: urlObj.href,
86
+ result,
87
+ aiReadiness,
88
+ loading: false,
89
+ }));
90
+ // Wait for user to exit
91
+ await finalRender.waitUntilExit();
92
+ // Check threshold
93
+ if (options.threshold !== undefined) {
94
+ const overallScore = aiReadiness.overall;
95
+ if (overallScore !== undefined && overallScore < options.threshold) {
96
+ process.exit(1);
97
+ }
98
+ }
99
+ }
100
+ catch (error) {
101
+ clear();
102
+ console.error('Audit failed:', error instanceof Error ? error.message : error);
103
+ process.exit(1);
104
+ }
105
+ });
106
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function auditWizardCommand(program: Command): void;
@@ -0,0 +1,110 @@
1
+ import { render } from 'ink';
2
+ import React from 'react';
3
+ import { SetupWizard } from '../ui/SetupWizard.js';
4
+ import { AuditReportUI } from '../ui/AuditReportUI.js';
5
+ import { analyzeUrlWithRules, calculateAIReadiness } from 'scanner';
6
+ export function auditWizardCommand(program) {
7
+ program
8
+ .command('wizard')
9
+ .alias('w')
10
+ .description('Interactive wizard to configure and run an audit')
11
+ .argument('[url]', 'Optional URL to audit (will prompt if not provided)')
12
+ .action(async (url) => {
13
+ // Suppress console.error and console.warn for cleaner UI
14
+ const originalConsoleError = console.error;
15
+ const originalConsoleWarn = console.warn;
16
+ console.error = () => { };
17
+ console.warn = () => { };
18
+ let auditConfig = null;
19
+ // Show setup wizard
20
+ const wizardRender = render(React.createElement(SetupWizard, {
21
+ initialUrl: url,
22
+ onComplete: (config) => {
23
+ auditConfig = config;
24
+ },
25
+ }));
26
+ // Wait for wizard to complete
27
+ await wizardRender.waitUntilExit();
28
+ if (!auditConfig) {
29
+ console.error = originalConsoleError;
30
+ console.warn = originalConsoleWarn;
31
+ console.log('\nAudit cancelled.');
32
+ process.exit(0);
33
+ }
34
+ // Start the audit with the configured options
35
+ const { clear, rerender } = render(React.createElement(AuditReportUI, {
36
+ url: auditConfig.url,
37
+ result: {},
38
+ aiReadiness: {},
39
+ loading: true,
40
+ currentStep: 'Starting audit...',
41
+ }));
42
+ try {
43
+ // Build scan options from config
44
+ const scanOptions = {
45
+ maxChunkTokens: 1200,
46
+ chunkingStrategy: 'auto',
47
+ enableChunking: auditConfig.enableChunking,
48
+ enableExtractability: auditConfig.enableExtractability,
49
+ enableHallucinationDetection: auditConfig.enableHallucination,
50
+ enableLLM: auditConfig.enableLlm,
51
+ minImpactScore: 8,
52
+ minConfidence: 0.7,
53
+ maxIssues: 20,
54
+ };
55
+ // Configure LLM if enabled
56
+ if (auditConfig.enableLlm && auditConfig.llmProvider) {
57
+ scanOptions.llmConfig = {
58
+ provider: auditConfig.llmProvider,
59
+ model: auditConfig.llmModel,
60
+ baseUrl: auditConfig.llmBaseUrl,
61
+ apiKey: auditConfig.llmApiKey,
62
+ };
63
+ }
64
+ // Update loading step
65
+ rerender(React.createElement(AuditReportUI, {
66
+ url: auditConfig.url,
67
+ result: {},
68
+ aiReadiness: {},
69
+ loading: true,
70
+ currentStep: 'Scanning page...',
71
+ }));
72
+ // Run the audit
73
+ const result = await analyzeUrlWithRules(auditConfig.url, scanOptions);
74
+ // Update loading step
75
+ rerender(React.createElement(AuditReportUI, {
76
+ url: auditConfig.url,
77
+ result,
78
+ aiReadiness: {},
79
+ loading: true,
80
+ currentStep: 'Calculating AI readiness scores...',
81
+ }));
82
+ // Calculate AI readiness
83
+ const aiReadiness = calculateAIReadiness(result);
84
+ // Clear loading and show results
85
+ clear();
86
+ const finalRender = render(React.createElement(AuditReportUI, {
87
+ url: auditConfig.url,
88
+ result,
89
+ aiReadiness,
90
+ loading: false,
91
+ }));
92
+ // Wait for user to exit
93
+ await finalRender.waitUntilExit();
94
+ // Restore console methods
95
+ console.error = originalConsoleError;
96
+ console.warn = originalConsoleWarn;
97
+ }
98
+ catch (error) {
99
+ // Restore console methods before showing error
100
+ console.error = originalConsoleError;
101
+ console.warn = originalConsoleWarn;
102
+ clear();
103
+ console.log('\n\x1b[1m\x1b[31m❌ Audit Failed\x1b[0m');
104
+ console.log('\x1b[31m' + '─'.repeat(70) + '\x1b[0m');
105
+ console.log('\x1b[31m' + (error instanceof Error ? error.message : String(error)) + '\x1b[0m');
106
+ console.log('\n\x1b[2mPlease check the URL and your configuration.\x1b[0m');
107
+ process.exit(1);
108
+ }
109
+ });
110
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function auditCommand(program: Command): void;