File size: 4,669 Bytes
d530f14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
export function getPrompts(config) {
  const prompts = [];

  if (!config.name) {
    prompts.push({
      type: 'input',
      name: 'name',
      message: 'Project name:',
      default: 'my-open-lovable',
      validate: (input) => {
        if (!input || input.trim() === '') {
          return 'Project name is required';
        }
        if (!/^[a-z0-9-_]+$/i.test(input)) {
          return 'Project name can only contain letters, numbers, hyphens, and underscores';
        }
        return true;
      }
    });
  }

  if (!config.sandbox) {
    prompts.push({
      type: 'list',
      name: 'sandbox',
      message: 'Choose your sandbox provider:',
      choices: [
        {
          name: 'E2B - Full-featured development sandboxes',
          value: 'e2b',
          short: 'E2B'
        },
        {
          name: 'Vercel - Lightweight ephemeral VMs',
          value: 'vercel',
          short: 'Vercel'
        }
      ],
      default: 'e2b'
    });
  }

  prompts.push({
    type: 'confirm',
    name: 'configureEnv',
    message: 'Would you like to configure API keys now?',
    default: true
  });

  return prompts;
}

export function getEnvPrompts(provider) {
  const prompts = [];

  // Always include Firecrawl API key
  prompts.push({
    type: 'input',
    name: 'firecrawlApiKey',
    message: 'Firecrawl API key (for web scraping):',
    validate: (input) => {
      if (!input || input.trim() === '') {
        return 'Firecrawl API key is required for web scraping functionality';
      }
      return true;
    }
  });

  if (provider === 'e2b') {
    prompts.push({
      type: 'input',
      name: 'e2bApiKey',
      message: 'E2B API key:',
      validate: (input) => {
        if (!input || input.trim() === '') {
          return 'E2B API key is required';
        }
        return true;
      }
    });
  } else if (provider === 'vercel') {
    prompts.push({
      type: 'list',
      name: 'vercelAuthMethod',
      message: 'Vercel authentication method:',
      choices: [
        {
          name: 'OIDC Token (automatic in Vercel environment)',
          value: 'oidc',
          short: 'OIDC'
        },
        {
          name: 'Personal Access Token',
          value: 'pat',
          short: 'PAT'
        }
      ]
    });

    prompts.push({
      type: 'input',
      name: 'vercelTeamId',
      message: 'Vercel Team ID:',
      when: (answers) => answers.vercelAuthMethod === 'pat',
      validate: (input) => {
        if (!input || input.trim() === '') {
          return 'Team ID is required for PAT authentication';
        }
        return true;
      }
    });

    prompts.push({
      type: 'input',
      name: 'vercelProjectId',
      message: 'Vercel Project ID:',
      when: (answers) => answers.vercelAuthMethod === 'pat',
      validate: (input) => {
        if (!input || input.trim() === '') {
          return 'Project ID is required for PAT authentication';
        }
        return true;
      }
    });

    prompts.push({
      type: 'input',
      name: 'vercelToken',
      message: 'Vercel Access Token:',
      when: (answers) => answers.vercelAuthMethod === 'pat',
      validate: (input) => {
        if (!input || input.trim() === '') {
          return 'Access token is required for PAT authentication';
        }
        return true;
      }
    });
  }

  // Optional AI provider keys
  prompts.push({
    type: 'confirm',
    name: 'addAiKeys',
    message: 'Would you like to add AI provider API keys?',
    default: true
  });

  prompts.push({
    type: 'checkbox',
    name: 'aiProviders',
    message: 'Select AI providers to configure:',
    when: (answers) => answers.addAiKeys,
    choices: [
      { name: 'Anthropic (Claude)', value: 'anthropic' },
      { name: 'OpenAI (GPT)', value: 'openai' },
      { name: 'Google (Gemini)', value: 'gemini' },
      { name: 'Groq', value: 'groq' }
    ]
  });

  prompts.push({
    type: 'input',
    name: 'anthropicApiKey',
    message: 'Anthropic API key:',
    when: (answers) => answers.aiProviders && answers.aiProviders.includes('anthropic')
  });

  prompts.push({
    type: 'input',
    name: 'openaiApiKey',
    message: 'OpenAI API key:',
    when: (answers) => answers.aiProviders && answers.aiProviders.includes('openai')
  });

  prompts.push({
    type: 'input',
    name: 'geminiApiKey',
    message: 'Gemini API key:',
    when: (answers) => answers.aiProviders && answers.aiProviders.includes('gemini')
  });

  prompts.push({
    type: 'input',
    name: 'groqApiKey',
    message: 'Groq API key:',
    when: (answers) => answers.aiProviders && answers.aiProviders.includes('groq')
  });

  return prompts;
}