-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.js
More file actions
533 lines (463 loc) · 16.5 KB
/
Copy pathsetup.js
File metadata and controls
533 lines (463 loc) · 16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
#!/usr/bin/env node
/**
* 10x-Outreach-Skill Interactive Setup Wizard
*
* This script guides users through setting up their environment
* by collecting API keys and configuration interactively.
*/
import * as readline from 'readline';
import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Color codes for terminal output
const colors = {
reset: '\x1b[0m',
bright: '\x1b[1m',
dim: '\x1b[2m',
red: '\x1b[31m',
green: '\x1b[32m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
magenta: '\x1b[35m',
cyan: '\x1b[36m',
white: '\x1b[37m',
};
// Helper functions for colored output
const log = {
success: (msg) => console.log(`${colors.green}✓${colors.reset} ${msg}`),
error: (msg) => console.log(`${colors.red}✗${colors.reset} ${msg}`),
warning: (msg) => console.log(`${colors.yellow}⚠${colors.reset} ${msg}`),
info: (msg) => console.log(`${colors.cyan}ℹ${colors.reset} ${msg}`),
header: (msg) => console.log(`\n${colors.bright}${colors.magenta}${msg}${colors.reset}`),
section: (msg) => console.log(`\n${colors.bright}${colors.cyan}${msg}${colors.reset}`),
dim: (msg) => console.log(`${colors.dim}${msg}${colors.reset}`),
};
// Configuration structure
const config = {
required: {
EXA_API_KEY: {
prompt: 'Exa AI API Key',
description: 'Required for prospect enrichment and discovery',
getUrl: 'https://exa.ai',
features: [
'Prospect enrichment',
'Company data lookup',
'Social profile discovery',
],
},
GOOGLE_CLIENT_ID: {
prompt: 'Google Client ID',
description: 'Required for Gmail integration',
getUrl: 'https://console.cloud.google.com/',
features: ['Email sending via Gmail'],
},
GOOGLE_CLIENT_SECRET: {
prompt: 'Google Client Secret',
description: 'Required for Gmail integration',
getUrl: 'https://console.cloud.google.com/',
features: ['Email sending via Gmail'],
},
SENDER_EMAIL: {
prompt: 'Sender Email (Gmail address)',
description: 'Your Gmail address for sending emails',
features: ['Email campaigns', 'Outreach automation'],
validate: (value) => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(value) || 'Please enter a valid email address';
},
},
},
optional: {
GEMINI_API_KEY: {
prompt: 'Gemini AI API Key',
description: 'Optional - enables multimodal features',
getUrl: 'https://aistudio.google.com/apikey',
features: [
'Image analysis',
'Video processing',
'PDF extraction',
],
},
CANVA_CLIENT_ID: {
prompt: 'Canva Client ID',
description: 'Optional - enables design automation',
getUrl: 'https://www.canva.com/developers/',
features: ['Automated design generation', 'Template creation'],
},
CANVA_CLIENT_SECRET: {
prompt: 'Canva Client Secret',
description: 'Optional - enables design automation',
getUrl: 'https://www.canva.com/developers/',
features: ['Automated design generation', 'Template creation'],
},
CANVA_ACCESS_TOKEN: {
prompt: 'Canva Access Token',
description: 'Optional - enables design automation',
getUrl: 'https://www.canva.com/developers/',
features: ['Automated design generation', 'Template creation'],
},
ANTHROPIC_API_KEY: {
prompt: 'Anthropic API Key',
description: 'Optional - for advanced AI features (will use Claude Code\'s key if not provided)',
getUrl: 'https://console.anthropic.com/',
features: ['Advanced AI features', 'Enhanced content generation'],
},
},
defaults: {
WORKSPACE_PATH: {
prompt: 'Workspace Path',
description: 'Directory for storing campaign data and outputs',
default: '~/10x-skill-workspace',
},
CANVAS_PORT: {
prompt: 'Canvas Port',
description: 'Port for the visual canvas server',
default: '3000',
},
DEBUG: {
prompt: 'Enable Debug Mode',
description: 'Enable detailed logging (true/false)',
default: 'false',
validate: (value) => {
return ['true', 'false'].includes(value.toLowerCase()) || 'Please enter "true" or "false"';
},
},
},
};
// Create readline interface
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
// Prompt user for input
function question(prompt) {
return new Promise((resolve) => {
rl.question(prompt, resolve);
});
}
// Display banner
function displayBanner() {
console.clear();
console.log(colors.magenta);
console.log('╔══════════════════════════════════════════════════════════════╗');
console.log('║ 10x-Outreach-Skill Interactive Setup Wizard ║');
console.log('║ ║');
console.log('║ This wizard will help you configure your environment ║');
console.log('╚══════════════════════════════════════════════════════════════╝');
console.log(colors.reset);
}
// Display feature warnings
function displayFeatureInfo(key, configItem) {
log.dim(` Get your key: ${configItem.getUrl || 'N/A'}`);
if (configItem.features && configItem.features.length > 0) {
log.dim(` Features enabled: ${configItem.features.join(', ')}`);
}
}
// Collect configuration values
async function collectConfig() {
const values = {};
// Required configuration
log.header('═══ REQUIRED CONFIGURATION ═══');
log.info('These are essential for core functionality\n');
for (const [key, configItem] of Object.entries(config.required)) {
log.section(`${configItem.prompt}:`);
log.dim(` ${configItem.description}`);
displayFeatureInfo(key, configItem);
let value = '';
let isValid = false;
while (!isValid) {
value = await question(`\n${colors.bright}Enter ${configItem.prompt}:${colors.reset} `);
value = value.trim();
if (!value) {
log.error('This field is required. Please provide a value.');
continue;
}
if (configItem.validate) {
const validationResult = configItem.validate(value);
if (validationResult === true) {
isValid = true;
} else {
log.error(validationResult);
}
} else {
isValid = true;
}
}
values[key] = value;
log.success(`${configItem.prompt} configured`);
}
// Optional configuration
log.header('\n═══ OPTIONAL CONFIGURATION ═══');
log.info('These enhance functionality but are not required\n');
const skipOptional = await question(
`${colors.yellow}Would you like to configure optional features? (y/n):${colors.reset} `
);
if (skipOptional.toLowerCase() === 'y') {
for (const [key, configItem] of Object.entries(config.optional)) {
log.section(`\n${configItem.prompt}:`);
log.dim(` ${configItem.description}`);
displayFeatureInfo(key, configItem);
const configure = await question(
`\n${colors.bright}Configure ${configItem.prompt}? (y/n):${colors.reset} `
);
if (configure.toLowerCase() === 'y') {
let value = '';
let isValid = false;
while (!isValid) {
value = await question(`Enter ${configItem.prompt}: `);
value = value.trim();
if (!value) {
log.warning('Skipping this optional field.');
isValid = true;
continue;
}
if (configItem.validate) {
const validationResult = configItem.validate(value);
if (validationResult === true) {
isValid = true;
} else {
log.error(validationResult);
}
} else {
isValid = true;
}
}
if (value) {
values[key] = value;
log.success(`${configItem.prompt} configured`);
}
} else {
log.dim(` Skipped ${configItem.prompt}`);
}
}
} else {
log.info('Skipping optional configuration');
}
// Default configuration
log.header('\n═══ WORKSPACE & SETTINGS ═══');
for (const [key, configItem] of Object.entries(config.defaults)) {
const value = await question(
`${configItem.prompt} [${colors.dim}${configItem.default}${colors.reset}]: `
);
if (value.trim()) {
if (configItem.validate) {
const validationResult = configItem.validate(value.trim());
if (validationResult === true) {
values[key] = value.trim();
} else {
log.error(validationResult);
values[key] = configItem.default;
}
} else {
values[key] = value.trim();
}
} else {
values[key] = configItem.default;
}
}
return values;
}
// Generate .env file content
function generateEnvContent(values) {
const lines = [
'# 10x-Outreach-Skill Environment Configuration',
'# Generated by setup wizard on ' + new Date().toISOString(),
'',
'# ============================================',
'# REQUIRED: Exa AI (for prospect enrichment)',
'# ============================================',
`EXA_API_KEY=${values.EXA_API_KEY || ''}`,
'',
'# ============================================',
'# REQUIRED: Gmail Integration',
'# ============================================',
`GOOGLE_CLIENT_ID=${values.GOOGLE_CLIENT_ID || ''}`,
`GOOGLE_CLIENT_SECRET=${values.GOOGLE_CLIENT_SECRET || ''}`,
`SENDER_EMAIL=${values.SENDER_EMAIL || ''}`,
'',
];
// Add optional configurations if provided
if (values.GEMINI_API_KEY) {
lines.push(
'# ============================================',
'# OPTIONAL: Gemini AI (for multimodal features)',
'# ============================================',
`GEMINI_API_KEY=${values.GEMINI_API_KEY}`,
''
);
}
if (values.CANVA_CLIENT_ID || values.CANVA_CLIENT_SECRET || values.CANVA_ACCESS_TOKEN) {
lines.push(
'# ============================================',
'# OPTIONAL: Canva Integration',
'# ============================================',
`CANVA_CLIENT_ID=${values.CANVA_CLIENT_ID || ''}`,
`CANVA_CLIENT_SECRET=${values.CANVA_CLIENT_SECRET || ''}`,
`CANVA_ACCESS_TOKEN=${values.CANVA_ACCESS_TOKEN || ''}`,
''
);
}
if (values.ANTHROPIC_API_KEY) {
lines.push(
'# ============================================',
'# OPTIONAL: Claude API',
'# ============================================',
`ANTHROPIC_API_KEY=${values.ANTHROPIC_API_KEY}`,
''
);
}
// Add default configurations
lines.push(
'# ============================================',
'# Browser Extension Settings',
'# ============================================',
`CANVAS_PORT=${values.CANVAS_PORT || '3000'}`,
'CANVAS_HOST=localhost',
`WEBSOCKET_URL=ws://localhost:${values.CANVAS_PORT || '3000'}/ws`,
'',
'# ============================================',
'# Workspace Configuration',
'# ============================================',
`WORKSPACE_PATH=${values.WORKSPACE_PATH || '~/10x-skill-workspace'}`,
'',
'# ============================================',
'# Logging & Debug',
'# ============================================',
`DEBUG=${values.DEBUG || 'false'}`,
'LOG_LEVEL=info',
''
);
return lines.join('\n');
}
// Display configuration summary
function displaySummary(values) {
log.header('\n═══ CONFIGURATION SUMMARY ═══\n');
// Required features
log.section('Required Features:');
log.success('Prospect enrichment (Exa AI)');
log.success('Gmail integration');
log.success('Email campaigns');
// Optional features
const optionalFeatures = [];
if (values.GEMINI_API_KEY) optionalFeatures.push('Multimodal features (Gemini AI)');
if (values.CANVA_CLIENT_ID) optionalFeatures.push('Design automation (Canva)');
if (values.ANTHROPIC_API_KEY) optionalFeatures.push('Advanced AI features (Claude API)');
if (optionalFeatures.length > 0) {
log.section('\nOptional Features Enabled:');
optionalFeatures.forEach((feature) => log.success(feature));
}
// Disabled features
const disabledFeatures = [];
if (!values.GEMINI_API_KEY) disabledFeatures.push('Multimodal features (no Gemini API key)');
if (!values.CANVA_CLIENT_ID) disabledFeatures.push('Design automation (no Canva credentials)');
if (disabledFeatures.length > 0) {
log.section('\nDisabled Features:');
disabledFeatures.forEach((feature) => log.warning(feature));
}
// Workspace
log.section('\nWorkspace:');
console.log(` Path: ${values.WORKSPACE_PATH}`);
console.log(` Canvas Port: ${values.CANVAS_PORT}`);
console.log(` Debug Mode: ${values.DEBUG}`);
}
// Create workspace directories
async function createWorkspace(workspacePath) {
try {
const expandedPath = workspacePath.replace('~', process.env.HOME || process.env.USERPROFILE);
const dirs = [
expandedPath,
path.join(expandedPath, 'campaigns'),
path.join(expandedPath, 'templates'),
path.join(expandedPath, 'outputs'),
path.join(expandedPath, 'logs'),
];
for (const dir of dirs) {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
}
log.success(`Workspace created at: ${expandedPath}`);
} catch (error) {
log.error(`Failed to create workspace: ${error.message}`);
}
}
// Display next steps
function displayNextSteps() {
log.header('\n═══ NEXT STEPS ═══\n');
console.log(`${colors.bright}1. Load the Browser Extension:${colors.reset}`);
log.dim(' - Open Chrome/Edge');
log.dim(' - Go to chrome://extensions/');
log.dim(' - Enable "Developer mode"');
log.dim(' - Click "Load unpacked"');
log.dim(' - Select: browser-extension/');
console.log(`\n${colors.bright}2. Start the Canvas Server:${colors.reset}`);
log.dim(' cd tldraw-canvas');
log.dim(' npm run dev -- --port 3000');
console.log(`\n${colors.bright}3. Open the Visual Canvas:${colors.reset}`);
log.dim(' http://localhost:3000');
console.log(`\n${colors.bright}4. Use Claude Code:${colors.reset}`);
log.dim(' Say: "start my app" or "/start"');
console.log(`\n${colors.bright}Available Commands:${colors.reset}`);
log.dim(' /start - Start the visual canvas');
log.dim(' /discover - Find people using Exa AI');
log.dim(' /outreach - Email campaigns');
log.dim(' /linkedin - LinkedIn automation');
log.dim(' /twitter - Twitter automation');
log.dim(' /instagram - Instagram automation');
log.dim(' /workflow - Multi-platform sequences');
console.log('');
}
// Main setup flow
async function main() {
try {
displayBanner();
log.info('This setup wizard will guide you through configuring your environment.');
log.info('Press Ctrl+C at any time to cancel.\n');
await question('Press Enter to continue...');
// Collect configuration
const values = await collectConfig();
// Display summary
displaySummary(values);
// Confirm
console.log('');
const confirm = await question(
`${colors.yellow}Save this configuration to .env? (y/n):${colors.reset} `
);
if (confirm.toLowerCase() !== 'y') {
log.warning('Setup cancelled. No files were modified.');
rl.close();
return;
}
// Generate and save .env file
const envContent = generateEnvContent(values);
const envPath = path.join(__dirname, '.env');
// Backup existing .env if it exists
if (fs.existsSync(envPath)) {
const backupPath = path.join(__dirname, `.env.backup.${Date.now()}`);
fs.copyFileSync(envPath, backupPath);
log.info(`Existing .env backed up to: ${path.basename(backupPath)}`);
}
fs.writeFileSync(envPath, envContent);
log.success('.env file created successfully!');
// Create workspace directories
await createWorkspace(values.WORKSPACE_PATH);
// Display next steps
displayNextSteps();
log.success('\n✨ Setup complete! You\'re ready to start using 10x-Outreach-Skill!');
rl.close();
} catch (error) {
log.error(`Setup failed: ${error.message}`);
rl.close();
process.exit(1);
}
}
// Handle cleanup
rl.on('close', () => {
console.log('');
process.exit(0);
});
// Run setup
main();