@wabot-dev/create 0.0.2 → 0.0.4
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.
- package/README.md +189 -0
- package/bin/create-wabot.mjs +7 -100
- package/lib/cli.mjs +50 -0
- package/lib/create-project.mjs +386 -0
- package/lib/i18n.mjs +167 -0
- package/lib/skills/install.mjs +238 -0
- package/lib/skills/registry.mjs +64 -0
- package/package.json +4 -5
- package/skills/wabot-async/SKILL.md +139 -0
- package/skills/wabot-auth/SKILL.md +149 -0
- package/skills/wabot-chat/SKILL.md +136 -0
- package/skills/wabot-di-config/SKILL.md +117 -0
- package/skills/wabot-framework/SKILL.md +79 -0
- package/skills/wabot-framework/references/quickstart.md +85 -0
- package/skills/wabot-mindset/SKILL.md +155 -0
- package/skills/wabot-ops/SKILL.md +151 -0
- package/skills/wabot-persistence/SKILL.md +155 -0
- package/skills/wabot-rest-socket/SKILL.md +163 -0
- package/skills/wabot-validation/SKILL.md +104 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import degit from 'degit'
|
|
3
|
+
import prompts from 'prompts'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import fs from 'fs/promises'
|
|
6
|
+
import { spawn } from 'child_process'
|
|
7
|
+
|
|
8
|
+
import { installSkillsInProject, listSupportedAgents } from './skills/install.mjs'
|
|
9
|
+
import { listSkills } from './skills/registry.mjs'
|
|
10
|
+
import { createTranslator } from './i18n.mjs'
|
|
11
|
+
|
|
12
|
+
const REQUIRED_NODE_MAJOR = 22
|
|
13
|
+
|
|
14
|
+
const AI_PROVIDERS = [
|
|
15
|
+
{
|
|
16
|
+
value: 'openrouter',
|
|
17
|
+
title: 'OpenRouter',
|
|
18
|
+
descriptionKey: 'providers.openrouter',
|
|
19
|
+
envKey: 'OPENROUTER_API_KEY',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: 'openai',
|
|
23
|
+
title: 'OpenAI',
|
|
24
|
+
descriptionKey: 'providers.openai',
|
|
25
|
+
envKey: 'OPENAI_API_KEY',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: 'anthropic',
|
|
29
|
+
title: 'Anthropic',
|
|
30
|
+
descriptionKey: 'providers.anthropic',
|
|
31
|
+
envKey: 'ANTHROPIC_API_KEY',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 'google',
|
|
35
|
+
title: 'Google',
|
|
36
|
+
descriptionKey: 'providers.google',
|
|
37
|
+
envKey: 'GOOGLE_API_KEY',
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
function agentLabel(t, agent) {
|
|
42
|
+
const key = `agent.label.${agent}`
|
|
43
|
+
const value = t(key)
|
|
44
|
+
return value === key ? agent : value
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function runCreateProjectCommand(projectDirectory, options) {
|
|
48
|
+
const t = createTranslator(options?.lang)
|
|
49
|
+
|
|
50
|
+
printIntro(t)
|
|
51
|
+
ensureNodeVersion(t)
|
|
52
|
+
|
|
53
|
+
const projectName = await resolveProjectName(projectDirectory, t)
|
|
54
|
+
const setup = await collectSetup(options, t)
|
|
55
|
+
|
|
56
|
+
await createProject(projectName, setup, t)
|
|
57
|
+
await installDependencies(projectName, t)
|
|
58
|
+
|
|
59
|
+
if (setup.skills.install) {
|
|
60
|
+
await installAgentSkills(projectName, setup.skills, t)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
printNextSteps(projectName, setup, t)
|
|
64
|
+
process.exit(0)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function printIntro(t) {
|
|
68
|
+
const line = chalk.gray('─'.repeat(60))
|
|
69
|
+
console.log()
|
|
70
|
+
console.log(line)
|
|
71
|
+
console.log(chalk.bold.cyan(` ${t('intro.title')}`))
|
|
72
|
+
console.log()
|
|
73
|
+
console.log(` ${t('intro.line1')}`)
|
|
74
|
+
console.log(
|
|
75
|
+
` ${t('intro.line2', chalk.cyan('@wabot-dev/template'), chalk.cyan('.env'))}`,
|
|
76
|
+
)
|
|
77
|
+
console.log()
|
|
78
|
+
console.log(` ${t('intro.askAbout')}`)
|
|
79
|
+
console.log(` • ${t('intro.bullet.storage')}`)
|
|
80
|
+
console.log(` • ${t('intro.bullet.providers')}`)
|
|
81
|
+
console.log(line)
|
|
82
|
+
console.log()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function ensureNodeVersion(t) {
|
|
86
|
+
const major = Number(process.versions.node.split('.')[0])
|
|
87
|
+
if (major === REQUIRED_NODE_MAJOR) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log(chalk.red(t('node.required', REQUIRED_NODE_MAJOR, process.versions.node)))
|
|
92
|
+
console.log()
|
|
93
|
+
console.log(t('node.templatePin', REQUIRED_NODE_MAJOR, chalk.cyan('.nvmrc')))
|
|
94
|
+
console.log(t('node.installHint', chalk.cyan('nvm')))
|
|
95
|
+
console.log()
|
|
96
|
+
console.log(chalk.cyan(` nvm install ${REQUIRED_NODE_MAJOR}`))
|
|
97
|
+
console.log(chalk.cyan(` nvm use ${REQUIRED_NODE_MAJOR}`))
|
|
98
|
+
console.log()
|
|
99
|
+
console.log(
|
|
100
|
+
t('node.noNvm', chalk.underline('https://github.com/nvm-sh/nvm#installing-and-updating')),
|
|
101
|
+
)
|
|
102
|
+
console.log()
|
|
103
|
+
process.exit(1)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function resolveProjectName(projectDirectory, t) {
|
|
107
|
+
if (projectDirectory) {
|
|
108
|
+
return projectDirectory
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const response = await prompts({
|
|
112
|
+
type: 'text',
|
|
113
|
+
name: 'projectName',
|
|
114
|
+
message: t('project.namePrompt'),
|
|
115
|
+
initial: 'my-wabot-app',
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
if (!response.projectName) {
|
|
119
|
+
throw new Error(t('project.nameRequired'))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return response.projectName
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function collectSetup(options, t) {
|
|
126
|
+
const onCancel = () => {
|
|
127
|
+
throw new Error(t('project.cancelled'))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const { storage } = await prompts(
|
|
131
|
+
{
|
|
132
|
+
type: 'select',
|
|
133
|
+
name: 'storage',
|
|
134
|
+
message: t('storage.prompt'),
|
|
135
|
+
choices: [
|
|
136
|
+
{ title: t('storage.memory'), value: 'memory' },
|
|
137
|
+
{ title: t('storage.postgres'), value: 'postgres' },
|
|
138
|
+
],
|
|
139
|
+
initial: 0,
|
|
140
|
+
},
|
|
141
|
+
{ onCancel },
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
let databaseUrl = ''
|
|
145
|
+
if (storage === 'postgres') {
|
|
146
|
+
const dbResponse = await prompts(
|
|
147
|
+
{
|
|
148
|
+
type: 'text',
|
|
149
|
+
name: 'databaseUrl',
|
|
150
|
+
message: t('storage.dbUrlPrompt'),
|
|
151
|
+
initial: options.dbUrl ?? '',
|
|
152
|
+
},
|
|
153
|
+
{ onCancel },
|
|
154
|
+
)
|
|
155
|
+
databaseUrl = dbResponse.databaseUrl ?? ''
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const { providers } = await prompts(
|
|
159
|
+
{
|
|
160
|
+
type: 'multiselect',
|
|
161
|
+
name: 'providers',
|
|
162
|
+
message: t('providers.prompt'),
|
|
163
|
+
choices: AI_PROVIDERS.map((p) => ({
|
|
164
|
+
title: p.title,
|
|
165
|
+
value: p.value,
|
|
166
|
+
description: t(p.descriptionKey),
|
|
167
|
+
selected: p.value === 'openrouter',
|
|
168
|
+
})),
|
|
169
|
+
hint: t('providers.hint'),
|
|
170
|
+
instructions: false,
|
|
171
|
+
min: 1,
|
|
172
|
+
},
|
|
173
|
+
{ onCancel },
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
const providerKeys = {}
|
|
177
|
+
for (const value of providers) {
|
|
178
|
+
const provider = AI_PROVIDERS.find((p) => p.value === value)
|
|
179
|
+
const { apiKey } = await prompts(
|
|
180
|
+
{
|
|
181
|
+
type: 'password',
|
|
182
|
+
name: 'apiKey',
|
|
183
|
+
message: t('providers.apiKeyPrompt', provider.envKey),
|
|
184
|
+
},
|
|
185
|
+
{ onCancel },
|
|
186
|
+
)
|
|
187
|
+
providerKeys[provider.envKey] = apiKey ?? ''
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const skills = await collectSkillsSetup({ onCancel }, t)
|
|
191
|
+
|
|
192
|
+
return { storage, databaseUrl, providers, providerKeys, skills }
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function collectSkillsSetup({ onCancel }, t) {
|
|
196
|
+
const supportedAgents = listSupportedAgents()
|
|
197
|
+
const availableSkills = listSkills()
|
|
198
|
+
|
|
199
|
+
const { install } = await prompts(
|
|
200
|
+
{
|
|
201
|
+
type: 'confirm',
|
|
202
|
+
name: 'install',
|
|
203
|
+
message: t('skills.installPrompt', availableSkills.length),
|
|
204
|
+
initial: true,
|
|
205
|
+
},
|
|
206
|
+
{ onCancel },
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
if (!install) {
|
|
210
|
+
return { install: false, agents: [], skills: [] }
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const { agents } = await prompts(
|
|
214
|
+
{
|
|
215
|
+
type: 'multiselect',
|
|
216
|
+
name: 'agents',
|
|
217
|
+
message: t('skills.agentsPrompt'),
|
|
218
|
+
choices: supportedAgents.map((agent) => ({
|
|
219
|
+
title: agentLabel(t, agent),
|
|
220
|
+
value: agent,
|
|
221
|
+
selected: true,
|
|
222
|
+
})),
|
|
223
|
+
hint: t('skills.agentsHint'),
|
|
224
|
+
instructions: false,
|
|
225
|
+
min: 1,
|
|
226
|
+
},
|
|
227
|
+
{ onCancel },
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
install: true,
|
|
232
|
+
agents,
|
|
233
|
+
skills: availableSkills.map((skill) => skill.name),
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async function createProject(projectName, setup, t) {
|
|
238
|
+
const targetDir = path.resolve(process.cwd(), projectName)
|
|
239
|
+
|
|
240
|
+
await ensureDirectoryDoesNotExist(targetDir, projectName, t)
|
|
241
|
+
|
|
242
|
+
console.log(chalk.blue(t('project.creating', chalk.green(targetDir))))
|
|
243
|
+
|
|
244
|
+
const emitter = degit('wabot-dev/wabot-template', {
|
|
245
|
+
cache: false,
|
|
246
|
+
force: true,
|
|
247
|
+
verbose: true,
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
await emitter.clone(targetDir)
|
|
251
|
+
|
|
252
|
+
const packageJsonPath = path.join(targetDir, 'package.json')
|
|
253
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'))
|
|
254
|
+
packageJson.name = projectName
|
|
255
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n')
|
|
256
|
+
|
|
257
|
+
await writeEnvFile(targetDir, setup, t)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function ensureDirectoryDoesNotExist(targetDir, projectName, t) {
|
|
261
|
+
try {
|
|
262
|
+
await fs.access(targetDir)
|
|
263
|
+
throw new Error(t('project.exists', projectName))
|
|
264
|
+
} catch (error) {
|
|
265
|
+
if (error?.code === 'ENOENT') {
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
throw error
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async function writeEnvFile(targetDir, setup, t) {
|
|
274
|
+
const lines = []
|
|
275
|
+
lines.push(t('env.debugComment'))
|
|
276
|
+
lines.push('DEBUG=wabot:*:error,wabot:*:warn,wabot:*:info')
|
|
277
|
+
lines.push('')
|
|
278
|
+
|
|
279
|
+
if (setup.storage === 'postgres') {
|
|
280
|
+
lines.push(t('env.postgresComment'))
|
|
281
|
+
lines.push(`DATABASE_URL=${setup.databaseUrl}`)
|
|
282
|
+
} else {
|
|
283
|
+
lines.push(t('env.inMemoryComment'))
|
|
284
|
+
lines.push('# DATABASE_URL=')
|
|
285
|
+
}
|
|
286
|
+
lines.push('')
|
|
287
|
+
|
|
288
|
+
lines.push(t('env.providersComment'))
|
|
289
|
+
for (const provider of AI_PROVIDERS) {
|
|
290
|
+
const selected = setup.providers.includes(provider.value)
|
|
291
|
+
if (selected) {
|
|
292
|
+
lines.push(`${provider.envKey}=${setup.providerKeys[provider.envKey] ?? ''}`)
|
|
293
|
+
} else {
|
|
294
|
+
lines.push(`# ${provider.envKey}=`)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
lines.push('')
|
|
298
|
+
|
|
299
|
+
await fs.writeFile(path.join(targetDir, '.env'), lines.join('\n'))
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async function installDependencies(projectName, t) {
|
|
303
|
+
const targetDir = path.resolve(process.cwd(), projectName)
|
|
304
|
+
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
|
305
|
+
|
|
306
|
+
console.log(chalk.blue(t('deps.installing')))
|
|
307
|
+
|
|
308
|
+
await new Promise((resolve, reject) => {
|
|
309
|
+
const child = spawn(npmCmd, ['install'], {
|
|
310
|
+
cwd: targetDir,
|
|
311
|
+
stdio: 'inherit',
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
child.on('error', reject)
|
|
315
|
+
child.on('close', (code) => {
|
|
316
|
+
if (code === 0) {
|
|
317
|
+
resolve()
|
|
318
|
+
} else {
|
|
319
|
+
reject(new Error(t('deps.exitCode', code)))
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async function installAgentSkills(projectName, skillsSetup, t) {
|
|
326
|
+
const targetDir = path.resolve(process.cwd(), projectName)
|
|
327
|
+
|
|
328
|
+
console.log(chalk.blue(t('skills.installing')))
|
|
329
|
+
|
|
330
|
+
try {
|
|
331
|
+
const result = await installSkillsInProject(targetDir, skillsSetup.agents, skillsSetup.skills)
|
|
332
|
+
|
|
333
|
+
const installed = result.installations.filter((i) => i.status === 'installed')
|
|
334
|
+
const skipped = result.installations.filter((i) => i.status === 'skipped')
|
|
335
|
+
|
|
336
|
+
if (installed.length > 0) {
|
|
337
|
+
const byAgent = new Map()
|
|
338
|
+
for (const item of installed) {
|
|
339
|
+
const list = byAgent.get(item.agent) ?? []
|
|
340
|
+
list.push(item.skill)
|
|
341
|
+
byAgent.set(item.agent, list)
|
|
342
|
+
}
|
|
343
|
+
for (const [agent, names] of byAgent) {
|
|
344
|
+
const dir = path.join(projectName, ...resolveAgentDir(agent))
|
|
345
|
+
console.log(chalk.green(t('skills.installed', agent, names.length, dir)))
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (skipped.length > 0) {
|
|
349
|
+
console.log(chalk.yellow(t('skills.skipped', skipped.length)))
|
|
350
|
+
}
|
|
351
|
+
} catch (error) {
|
|
352
|
+
console.log(chalk.red(t('skills.failed', error.message)))
|
|
353
|
+
console.log(chalk.yellow(t('skills.installLater')))
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function resolveAgentDir(agent) {
|
|
358
|
+
switch (agent) {
|
|
359
|
+
case 'claude': return ['.claude', 'skills']
|
|
360
|
+
case 'codex': return ['.codex', 'skills']
|
|
361
|
+
case 'agents': return ['.agents', 'skills']
|
|
362
|
+
default: return [`.${agent}`, 'skills']
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function printNextSteps(projectName, setup, t) {
|
|
367
|
+
console.log(chalk.green(t('next.ready', chalk.bold(projectName))))
|
|
368
|
+
|
|
369
|
+
const missingKeys = AI_PROVIDERS.filter(
|
|
370
|
+
(p) => setup.providers.includes(p.value) && !setup.providerKeys[p.envKey],
|
|
371
|
+
).map((p) => p.envKey)
|
|
372
|
+
|
|
373
|
+
if (setup.storage === 'postgres' && !setup.databaseUrl) {
|
|
374
|
+
console.log(chalk.yellow(t('next.dbUrlEmpty')))
|
|
375
|
+
}
|
|
376
|
+
if (missingKeys.length > 0) {
|
|
377
|
+
console.log(chalk.yellow(t('next.missingKeys', missingKeys.join(', '))))
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
console.log(t('next.heading'))
|
|
381
|
+
console.log(chalk.cyan(`\n cd ${projectName}`))
|
|
382
|
+
console.log(chalk.cyan(' npm run dev:watch'))
|
|
383
|
+
console.log(t('next.cmdChannelHint'))
|
|
384
|
+
console.log(chalk.cyan('\n npm run cmd:channel'))
|
|
385
|
+
console.log(t('next.happy'))
|
|
386
|
+
}
|
package/lib/i18n.mjs
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
const STRINGS = {
|
|
2
|
+
en: {
|
|
3
|
+
'intro.title': '🤖 Wabot project creator',
|
|
4
|
+
'intro.line1': 'This wizard will scaffold a new chat-bot project from the',
|
|
5
|
+
'intro.line2': (template, env) => `${template} starter and configure your ${env}.`,
|
|
6
|
+
'intro.askAbout': 'You will be asked about:',
|
|
7
|
+
'intro.bullet.storage': 'where to store data (in-memory or PostgreSQL)',
|
|
8
|
+
'intro.bullet.providers': 'which AI providers you want to use',
|
|
9
|
+
|
|
10
|
+
'node.required': (required, current) =>
|
|
11
|
+
`✖ Node.js ${required} is required (you are running ${current}).`,
|
|
12
|
+
'node.templatePin': (required, nvmrc) =>
|
|
13
|
+
`The Wabot template pins Node ${required} in its ${nvmrc}.`,
|
|
14
|
+
'node.installHint': (nvm) => `We recommend installing it with ${nvm}:`,
|
|
15
|
+
'node.noNvm': (url) => `Don't have nvm? See ${url}`,
|
|
16
|
+
|
|
17
|
+
'project.namePrompt': 'What is your project named?',
|
|
18
|
+
'project.nameRequired': 'Project name is required',
|
|
19
|
+
'project.cancelled': 'Setup cancelled',
|
|
20
|
+
'project.exists': (name) => `Directory ${name} already exists`,
|
|
21
|
+
'project.creating': (dir) => `\nCreating a new Wabot project in ${dir}\n`,
|
|
22
|
+
|
|
23
|
+
'storage.prompt': 'How do you want to store data?',
|
|
24
|
+
'storage.memory': 'In-memory (quickest start, data resets on restart)',
|
|
25
|
+
'storage.postgres': 'PostgreSQL (persistent, recommended for real bots)',
|
|
26
|
+
'storage.dbUrlPrompt': 'DATABASE_URL (leave blank to fill in later):',
|
|
27
|
+
|
|
28
|
+
'providers.prompt': 'Which AI providers will you use? (space to toggle, enter to confirm)',
|
|
29
|
+
'providers.hint': 'At least one is required to run the included Pixel example',
|
|
30
|
+
'providers.apiKeyPrompt': (envKey) => `${envKey} (leave blank to fill in later):`,
|
|
31
|
+
'providers.openrouter': 'Used by the included Pixel example',
|
|
32
|
+
'providers.openai': 'GPT models via the official OpenAI API',
|
|
33
|
+
'providers.anthropic': 'Claude models',
|
|
34
|
+
'providers.google': 'Gemini models',
|
|
35
|
+
|
|
36
|
+
'skills.installPrompt': (count) =>
|
|
37
|
+
`Install Wabot agent skills (${count}) into the new project?`,
|
|
38
|
+
'skills.agentsPrompt': 'Install for which agents? (space to toggle, enter to confirm)',
|
|
39
|
+
'skills.agentsHint': 'Each adds a folder of <agent>/skills under the project root',
|
|
40
|
+
'skills.installing': '\nInstalling Wabot agent skills...\n',
|
|
41
|
+
'skills.installed': (agent, count, dir) =>
|
|
42
|
+
` ✔ ${agent}: installed ${count} skill(s) into ${dir}`,
|
|
43
|
+
'skills.skipped': (count) =>
|
|
44
|
+
` ⚠ ${count} skill folder(s) already existed and were left untouched.`,
|
|
45
|
+
'skills.failed': (msg) => ` ✖ Failed to install agent skills: ${msg}`,
|
|
46
|
+
'skills.installLater':
|
|
47
|
+
' You can install them later with `create-wabot skill add <skill>`.',
|
|
48
|
+
|
|
49
|
+
'deps.installing': '\nInstalling dependencies with npm...\n',
|
|
50
|
+
'deps.exitCode': (code) => `npm install exited with code ${code}`,
|
|
51
|
+
|
|
52
|
+
'env.debugComment': '# debug important things',
|
|
53
|
+
'env.postgresComment': '# postgres connection string',
|
|
54
|
+
'env.inMemoryComment':
|
|
55
|
+
'# using in-memory storage (set DATABASE_URL to switch to postgres)',
|
|
56
|
+
'env.providersComment': '# AI provider keys',
|
|
57
|
+
|
|
58
|
+
'next.ready': (name) => `\n✔ Project ${name} is ready.\n`,
|
|
59
|
+
'next.dbUrlEmpty': ' ⚠ DATABASE_URL is empty — set it in .env before running.',
|
|
60
|
+
'next.missingKeys': (keys) => ` ⚠ Missing API keys in .env: ${keys}`,
|
|
61
|
+
'next.heading': '\nNext steps:',
|
|
62
|
+
'next.cmdChannelHint':
|
|
63
|
+
'\nIn another terminal, open a CLI to chat with your bot:',
|
|
64
|
+
'next.happy': '\nHappy hacking! 🚀\n',
|
|
65
|
+
|
|
66
|
+
'agent.label.claude': 'Claude Code (.claude/skills)',
|
|
67
|
+
'agent.label.codex': 'Codex (.codex/skills)',
|
|
68
|
+
'agent.label.agents': 'Generic agents (.agents/skills)',
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
es: {
|
|
72
|
+
'intro.title': '🤖 Creador de proyectos Wabot',
|
|
73
|
+
'intro.line1': 'Este asistente generará un nuevo proyecto de chat-bot a partir de',
|
|
74
|
+
'intro.line2': (template, env) =>
|
|
75
|
+
`la plantilla ${template} y configurará tu archivo ${env}.`,
|
|
76
|
+
'intro.askAbout': 'Te preguntaremos sobre:',
|
|
77
|
+
'intro.bullet.storage': 'dónde almacenar los datos (en memoria o PostgreSQL)',
|
|
78
|
+
'intro.bullet.providers': 'qué proveedores de IA deseas usar',
|
|
79
|
+
|
|
80
|
+
'node.required': (required, current) =>
|
|
81
|
+
`✖ Se requiere Node.js ${required} (estás usando ${current}).`,
|
|
82
|
+
'node.templatePin': (required, nvmrc) =>
|
|
83
|
+
`La plantilla de Wabot fija Node ${required} en su ${nvmrc}.`,
|
|
84
|
+
'node.installHint': (nvm) => `Recomendamos instalarlo con ${nvm}:`,
|
|
85
|
+
'node.noNvm': (url) => `¿No tienes nvm? Consulta ${url}`,
|
|
86
|
+
|
|
87
|
+
'project.namePrompt': '¿Cómo se llama tu proyecto?',
|
|
88
|
+
'project.nameRequired': 'El nombre del proyecto es obligatorio',
|
|
89
|
+
'project.cancelled': 'Configuración cancelada',
|
|
90
|
+
'project.exists': (name) => `El directorio ${name} ya existe`,
|
|
91
|
+
'project.creating': (dir) => `\nCreando un nuevo proyecto Wabot en ${dir}\n`,
|
|
92
|
+
|
|
93
|
+
'storage.prompt': '¿Cómo deseas almacenar los datos?',
|
|
94
|
+
'storage.memory': 'En memoria (inicio más rápido, los datos se pierden al reiniciar)',
|
|
95
|
+
'storage.postgres': 'PostgreSQL (persistente, recomendado para bots reales)',
|
|
96
|
+
'storage.dbUrlPrompt': 'DATABASE_URL (déjalo en blanco para completarlo después):',
|
|
97
|
+
|
|
98
|
+
'providers.prompt':
|
|
99
|
+
'¿Qué proveedores de IA usarás? (espacio para alternar, enter para confirmar)',
|
|
100
|
+
'providers.hint':
|
|
101
|
+
'Se requiere al menos uno para ejecutar el ejemplo Pixel incluido',
|
|
102
|
+
'providers.apiKeyPrompt': (envKey) =>
|
|
103
|
+
`${envKey} (déjalo en blanco para completarlo después):`,
|
|
104
|
+
'providers.openrouter': 'Usado por el ejemplo Pixel incluido',
|
|
105
|
+
'providers.openai': 'Modelos GPT mediante la API oficial de OpenAI',
|
|
106
|
+
'providers.anthropic': 'Modelos Claude',
|
|
107
|
+
'providers.google': 'Modelos Gemini',
|
|
108
|
+
|
|
109
|
+
'skills.installPrompt': (count) =>
|
|
110
|
+
`¿Instalar las skills de agente de Wabot (${count}) en el nuevo proyecto?`,
|
|
111
|
+
'skills.agentsPrompt':
|
|
112
|
+
'¿Para qué agentes instalarlas? (espacio para alternar, enter para confirmar)',
|
|
113
|
+
'skills.agentsHint':
|
|
114
|
+
'Cada uno añade una carpeta <agente>/skills en la raíz del proyecto',
|
|
115
|
+
'skills.installing': '\nInstalando skills de agente Wabot...\n',
|
|
116
|
+
'skills.installed': (agent, count, dir) =>
|
|
117
|
+
` ✔ ${agent}: se instalaron ${count} skill(s) en ${dir}`,
|
|
118
|
+
'skills.skipped': (count) =>
|
|
119
|
+
` ⚠ ${count} carpeta(s) de skill ya existían y no se modificaron.`,
|
|
120
|
+
'skills.failed': (msg) => ` ✖ Fallo al instalar las skills de agente: ${msg}`,
|
|
121
|
+
'skills.installLater':
|
|
122
|
+
' Puedes instalarlas más tarde con `create-wabot skill add <skill>`.',
|
|
123
|
+
|
|
124
|
+
'deps.installing': '\nInstalando dependencias con npm...\n',
|
|
125
|
+
'deps.exitCode': (code) => `npm install terminó con código ${code}`,
|
|
126
|
+
|
|
127
|
+
'env.debugComment': '# depurar lo importante',
|
|
128
|
+
'env.postgresComment': '# cadena de conexión de postgres',
|
|
129
|
+
'env.inMemoryComment':
|
|
130
|
+
'# usando almacenamiento en memoria (define DATABASE_URL para cambiar a postgres)',
|
|
131
|
+
'env.providersComment': '# claves de proveedores de IA',
|
|
132
|
+
|
|
133
|
+
'next.ready': (name) => `\n✔ El proyecto ${name} está listo.\n`,
|
|
134
|
+
'next.dbUrlEmpty':
|
|
135
|
+
' ⚠ DATABASE_URL está vacío — defínelo en .env antes de ejecutar.',
|
|
136
|
+
'next.missingKeys': (keys) => ` ⚠ Faltan claves de API en .env: ${keys}`,
|
|
137
|
+
'next.heading': '\nPróximos pasos:',
|
|
138
|
+
'next.cmdChannelHint':
|
|
139
|
+
'\nEn otra terminal, abre una CLI para chatear con tu bot:',
|
|
140
|
+
'next.happy': '\n¡Feliz desarrollo! 🚀\n',
|
|
141
|
+
|
|
142
|
+
'agent.label.claude': 'Claude Code (.claude/skills)',
|
|
143
|
+
'agent.label.codex': 'Codex (.codex/skills)',
|
|
144
|
+
'agent.label.agents': 'Agentes genéricos (.agents/skills)',
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const SUPPORTED_LANGS = Object.keys(STRINGS)
|
|
149
|
+
export const DEFAULT_LANG = 'en'
|
|
150
|
+
|
|
151
|
+
export function resolveLang(lang) {
|
|
152
|
+
if (!lang) return DEFAULT_LANG
|
|
153
|
+
const normalized = String(lang).toLowerCase()
|
|
154
|
+
return SUPPORTED_LANGS.includes(normalized) ? normalized : DEFAULT_LANG
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function createTranslator(lang) {
|
|
158
|
+
const resolved = resolveLang(lang)
|
|
159
|
+
const dict = STRINGS[resolved]
|
|
160
|
+
const fallback = STRINGS[DEFAULT_LANG]
|
|
161
|
+
|
|
162
|
+
return function t(key, ...args) {
|
|
163
|
+
const value = dict[key] ?? fallback[key]
|
|
164
|
+
if (value === undefined) return key
|
|
165
|
+
return typeof value === 'function' ? value(...args) : value
|
|
166
|
+
}
|
|
167
|
+
}
|