awc-zns-mtd 2.9.0 → 2.10.3

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 (38) hide show
  1. package/.github/workflows/ci.yml +148 -0
  2. package/.husky/pre-commit +2 -0
  3. package/.prettierignore +31 -0
  4. package/.prettierrc +13 -0
  5. package/IMPLEMENTATION_SUMMARY.md +410 -0
  6. package/PHASE_2_SUMMARY.md +289 -0
  7. package/README.md +114 -47
  8. package/SECURITY.md +58 -0
  9. package/eslint.config.js +70 -0
  10. package/jest.config.js +49 -0
  11. package/package.json +40 -14
  12. package/src/modules/custom-agents/cli/awc-agent.js +505 -372
  13. package/test/integration/cli/cli-commands.integration.test.js +105 -0
  14. package/test/setup.js +22 -0
  15. package/test/unit/commands/version.test.js +39 -0
  16. package/test/unit/config/config-manager.test.js +147 -0
  17. package/test/unit/utils/file-utils.test.js +177 -0
  18. package/test/unit/utils/validators.test.js +57 -0
  19. package/tools/cli/commands/init.js +556 -513
  20. package/tools/cli/commands/new-project.js +680 -659
  21. package/tools/cli/commands/validate.js +13 -13
  22. package/tools/cli/commands/version.js +5 -3
  23. package/tools/cli/utils/console-logger.js +39 -15
  24. package/tools/cli/utils/logger.js +176 -0
  25. package/tools/cli/utils/project-analyzer.js +33 -16
  26. package/tools/cli/utils/validators.js +144 -0
  27. package/tools/cli/utils/version.js +6 -2
  28. package/tools/config/config-manager.js +243 -0
  29. package/tools/version/changelog-manager.js +301 -288
  30. package/tools/version/update-checker.js +32 -32
  31. package/tools/version/version-bump.js +89 -90
  32. package/tools/version/version-manager.js +17 -7
  33. package/tsconfig.json +47 -0
  34. package/types/index.d.ts +206 -0
  35. package/tools/cli/commands/init-old.js +0 -147
  36. package/tools/cli/commands/new-project-broken.js +0 -1302
  37. package/tools/cli/commands/new-project-old.js +0 -1302
  38. package/tools/cli/commands/new-project.js.backup +0 -1302
@@ -1,513 +1,556 @@
1
- /**
2
- * Comando: init
3
- * Inicializa el tipo de proyecto y crea estructura específica según necesidades
4
- */
5
-
6
- const fs = require('fs-extra');
7
- const path = require('path');
8
- const chalk = require('chalk');
9
- const ora = require('ora');
10
- const inquirer = require('inquirer');
11
- const { displayLogo } = require('../utils/console-logger');
12
- const { loadConfig, updateConfig } = require('../utils/file-utils');
13
-
14
- async function initCommand(options = {}) {
15
- const cwd = process.cwd();
16
- const awcDir = path.join(cwd, '.awc');
17
-
18
- displayLogo();
19
-
20
- console.log(chalk.cyan('\n🎯 Inicialización de Proyecto ZΞNAPSΞS\n'));
21
-
22
- // Verificar que existe .awc
23
- if (!(await fs.pathExists(awcDir))) {
24
- console.log(chalk.red('❌ Este directorio no es un proyecto ZNS.'));
25
- console.log(chalk.yellow(`\n💡 Ejecuta primero ${chalk.green('zns new <proyecto>')}\n`));
26
- return;
27
- }
28
-
29
- // Cargar configuración
30
- const config = await loadConfig(awcDir);
31
-
32
- if (config.initialized) {
33
- console.log(chalk.yellow('⚠️ Este proyecto ya fue inicializado.'));
34
- const { reinit } = await inquirer.prompt([
35
- {
36
- type: 'confirm',
37
- name: 'reinit',
38
- message: '¿Deseas reinicializar? (Se mantendrán archivos existentes)',
39
- default: false
40
- }
41
- ]);
42
- if (!reinit) return;
43
- }
44
-
45
- // Preguntas de inicialización
46
- const answers = await inquirer.prompt([
47
- {
48
- type: 'list',
49
- name: 'projectType',
50
- message: '📋 ¿Qué tipo de proyecto es?',
51
- choices: [
52
- { name: '🔍 Auditoría de Código Existente', value: 'code-audit' },
53
- { name: '🆕 Desarrollo Desde Cero', value: 'greenfield' },
54
- { name: '🔄 Migración/Modernización', value: 'migration' },
55
- { name: '🛠️ Mantenimiento/Soporte', value: 'maintenance' },
56
- { name: '📱 Aplicación Móvil', value: 'mobile' },
57
- { name: '🌐 API/Microservicios', value: 'api' },
58
- { name: '🏢 Sistema Empresarial', value: 'enterprise' }
59
- ]
60
- },
61
- {
62
- type: 'list',
63
- name: 'workflow',
64
- message: '⚡ ¿Qué workflow deseas usar?',
65
- choices: [
66
- { name: '⚡ Quick (1-2 semanas)', value: 'quick' },
67
- { name: '📊 Standard (1-3 meses)', value: 'standard' },
68
- { name: '🏢 Enterprise (3+ meses)', value: 'enterprise' }
69
- ]
70
- },
71
- {
72
- type: 'checkbox',
73
- name: 'technologies',
74
- message: '🛠️ Selecciona las tecnologías del proyecto (usa espacio para seleccionar):',
75
- choices: [
76
- { name: 'Java', value: 'java' },
77
- { name: '.NET Core', value: 'dotnet' },
78
- { name: 'Python', value: 'python' },
79
- { name: 'PHP', value: 'php' },
80
- { name: 'Node.js', value: 'nodejs' },
81
- { name: 'React', value: 'react' },
82
- { name: 'Angular', value: 'angular' },
83
- { name: 'Vue', value: 'vue' },
84
- { name: 'React Native', value: 'react-native' },
85
- { name: 'SQL Database', value: 'sql' },
86
- { name: 'NoSQL Database', value: 'nosql' }
87
- ]
88
- }
89
- ]);
90
-
91
- const spinner = ora('Creando estructura del proyecto...').start();
92
-
93
- try {
94
- // Crear estructura según tipo de proyecto
95
- const structure = getProjectStructure(answers.projectType);
96
-
97
- for (const dir of structure.directories) {
98
- await fs.ensureDir(path.join(cwd, dir));
99
- }
100
- spinner.text = 'Estructura de directorios creada';
101
-
102
- // Crear guías START_HERE.md para fases activas
103
- await createPhaseGuides(cwd, structure.phases);
104
- spinner.text = 'Guías de fase creadas';
105
-
106
- // Crear README de client-docs para fases activas
107
- await createClientDocsReadmes(cwd, structure.phases);
108
- spinner.text = 'README de client-docs creados';
109
-
110
- // Actualizar configuración
111
- config.initialized = true;
112
- config.projectType = answers.projectType;
113
- config.workflow = answers.workflow;
114
- config.technologies = answers.technologies;
115
- config.structure = structure;
116
- config.workflows.current_phase = structure.startPhase;
117
-
118
- await updateConfig(awcDir, config);
119
- spinner.text = 'Configuración actualizada';
120
-
121
- spinner.succeed(chalk.green('✅ Proyecto inicializado exitosamente'));
122
-
123
- // Mostrar resumen
124
- console.log(chalk.cyan('\n' + '═'.repeat(60)));
125
- console.log(chalk.cyan('📊 Resumen de Inicialización'));
126
- console.log(chalk.cyan('═'.repeat(60) + '\n'));
127
-
128
- console.log(`${chalk.gray('Tipo de Proyecto:')} ${chalk.green(getProjectTypeName(answers.projectType))}`);
129
- console.log(`${chalk.gray('Workflow:')} ${chalk.yellow(answers.workflow.toUpperCase())}`);
130
- console.log(`${chalk.gray('Tecnologías:')} ${chalk.blue(answers.technologies.join(', ') || 'Ninguna')}`);
131
- console.log(`${chalk.gray('Fases creadas:')} ${chalk.yellow(structure.phases.length)}\n`);
132
-
133
- // Mostrar fases creadas
134
- console.log(chalk.cyan('📂 Estructura Creada:\n'));
135
- structure.phases.forEach((phase, index) => {
136
- const icon = phase === structure.startPhase ? '👉' : ' ';
137
- console.log(` ${icon} ${chalk.green(phase)} ${phase === structure.startPhase ? chalk.yellow(' INICIAR AQUÍ') : ''}`);
138
- });
139
-
140
- // Próximos pasos
141
- console.log(chalk.cyan('\n📚 Próximos Pasos:\n'));
142
- console.log(` ${chalk.green('1.')} Ir a ${chalk.yellow(structure.startPhase + '/')}`);
143
- console.log(` ${chalk.green('2.')} Leer ${chalk.yellow('START_HERE.md')}`);
144
- console.log(` ${chalk.green('3.')} Colocar documentación del cliente en ${chalk.yellow('docs/client-docs/')}`);
145
- console.log(` ${chalk.green('4.')} Comenzar a trabajar con los agentes especializados\n`);
146
-
147
- // Mostrar agentes recomendados
148
- const recommendedAgents = getRecommendedAgents(answers.projectType, answers.technologies);
149
- console.log(chalk.cyan('🤖 Agentes Recomendados para este Proyecto:\n'));
150
- recommendedAgents.forEach(agent => {
151
- console.log(` ${chalk.green('')} ${agent}`);
152
- });
153
- console.log();
154
-
155
- } catch (error) {
156
- spinner.fail(chalk.red('❌ Error inicializando proyecto'));
157
- throw error;
158
- }
159
- }
160
-
161
- /**
162
- * Obtiene la estructura de directorios según tipo de proyecto
163
- */
164
- function getProjectStructure(projectType) {
165
- const structures = {
166
- 'code-audit': {
167
- phases: ['01-comercial', '03-analysis', '04-planning', '08-support'],
168
- startPhase: '01-comercial',
169
- directories: [
170
- // Comercial
171
- '01-comercial/01-prospection',
172
- '01-comercial/02-technical-proposal',
173
- '01-comercial/03-quotation',
174
- '01-comercial/04-contract',
175
- '01-comercial/docs/client-docs/requerimientos',
176
- '01-comercial/docs/client-docs/presentaciones',
177
- '01-comercial/docs/client-docs/contratos',
178
-
179
- // Analysis (PRINCIPAL para auditoría)
180
- '03-analysis/01-code-audit',
181
- '03-analysis/02-architecture-review',
182
- '03-analysis/03-technical-debt',
183
- '03-analysis/04-recommendations',
184
- '03-analysis/docs/client-docs/arquitectura',
185
- '03-analysis/docs/client-docs/databases',
186
- '03-analysis/docs/client-docs/codigo-fuente',
187
- '03-analysis/reports',
188
-
189
- // Planning (plan de mejoras)
190
- '04-planning/01-improvement-plan',
191
- '04-planning/02-priorities',
192
- '04-planning/docs/client-docs/estimaciones',
193
-
194
- // Support (recomendaciones)
195
- '08-support/recommendations',
196
- '08-support/docs/client-docs/seguimiento'
197
- ]
198
- },
199
-
200
- 'greenfield': {
201
- phases: ['01-comercial', '02-inception', '04-planning', '05-development', '06-qa', '07-deployment', '08-support'],
202
- startPhase: '01-comercial',
203
- directories: [
204
- // Comercial
205
- '01-comercial/01-prospection',
206
- '01-comercial/02-technical-proposal',
207
- '01-comercial/03-quotation',
208
- '01-comercial/04-contract',
209
- '01-comercial/docs/client-docs/requerimientos',
210
- '01-comercial/docs/client-docs/presentaciones',
211
-
212
- // Inception (PRINCIPAL)
213
- '02-inception/01-kickoff',
214
- '02-inception/02-prd',
215
- '02-inception/03-backlog',
216
- '02-inception/04-release-planning',
217
- '02-inception/docs/client-docs/procesos',
218
- '02-inception/docs/client-docs/manuales',
219
- '02-inception/docs/client-docs/imagenes',
220
-
221
- // Planning
222
- '04-planning/01-sprint-planning',
223
- '04-planning/02-backlog-refinement',
224
- '04-planning/docs/client-docs/historias',
225
-
226
- // Development (PRINCIPAL)
227
- '05-development/src',
228
- '05-development/tests',
229
- '05-development/docs',
230
- '05-development/docs/client-docs/recursos',
231
-
232
- // QA
233
- '06-qa/test-plans',
234
- '06-qa/test-cases',
235
- '06-qa/test-results',
236
- '06-qa/docs/client-docs/criterios-aceptacion',
237
-
238
- // Deployment
239
- '07-deployment/environments',
240
- '07-deployment/scripts',
241
- '07-deployment/docs/client-docs/infraestructura',
242
-
243
- // Support
244
- '08-support/incidents',
245
- '08-support/maintenance',
246
- '08-support/docs/client-docs/incidentes'
247
- ]
248
- },
249
-
250
- 'migration': {
251
- phases: ['01-comercial', '03-analysis', '04-planning', '05-development', '07-deployment'],
252
- startPhase: '01-comercial',
253
- directories: [
254
- // Comercial
255
- '01-comercial/01-prospection',
256
- '01-comercial/02-technical-proposal',
257
- '01-comercial/03-quotation',
258
- '01-comercial/docs/client-docs/requerimientos',
259
-
260
- // Analysis (PRINCIPAL - analizar sistema legacy)
261
- '03-analysis/01-legacy-assessment',
262
- '03-analysis/02-migration-plan',
263
- '03-analysis/03-risk-assessment',
264
- '03-analysis/docs/client-docs/arquitectura',
265
- '03-analysis/docs/client-docs/databases',
266
- '03-analysis/docs/client-docs/codigo-existente',
267
-
268
- // Planning (plan de migración)
269
- '04-planning/01-migration-phases',
270
- '04-planning/02-data-migration',
271
- '04-planning/03-rollback-plan',
272
- '04-planning/docs/client-docs/cronograma',
273
-
274
- // Development (nuevo sistema)
275
- '05-development/src',
276
- '05-development/migration-scripts',
277
- '05-development/tests',
278
- '05-development/docs/client-docs/apis',
279
-
280
- // Deployment (ejecución de migración)
281
- '07-deployment/pre-migration',
282
- '07-deployment/migration',
283
- '07-deployment/post-migration',
284
- '07-deployment/docs/client-docs/infraestructura',
285
- '07-deployment/docs/client-docs/accesos'
286
- ]
287
- },
288
-
289
- 'maintenance': {
290
- phases: ['01-comercial', '03-analysis', '08-support'],
291
- startPhase: '08-support',
292
- directories: [
293
- // Comercial (contrato de mantenimiento)
294
- '01-comercial/01-contract',
295
- '01-comercial/02-sla',
296
- '01-comercial/docs/client-docs/contratos',
297
-
298
- // Analysis (entender sistema)
299
- '03-analysis/01-system-documentation',
300
- '03-analysis/docs/client-docs/arquitectura',
301
- '03-analysis/docs/client-docs/codigo',
302
-
303
- // Support (PRINCIPAL)
304
- '08-support/incidents',
305
- '08-support/bug-fixes',
306
- '08-support/maintenance',
307
- '08-support/change-requests',
308
- '08-support/docs/client-docs/incidentes',
309
- '08-support/docs/client-docs/cambios'
310
- ]
311
- },
312
-
313
- 'mobile': {
314
- phases: ['01-comercial', '02-inception', '04-planning', '05-development', '06-qa', '07-deployment'],
315
- startPhase: '02-inception',
316
- directories: [
317
- // Comercial
318
- '01-comercial/01-prospection',
319
- '01-comercial/docs/client-docs/requerimientos',
320
-
321
- // Inception (PRINCIPAL - diseño UX/UI)
322
- '02-inception/01-ux-design',
323
- '02-inception/02-ui-design',
324
- '02-inception/03-prototypes',
325
- '02-inception/04-backlog',
326
- '02-inception/docs/client-docs/mockups',
327
- '02-inception/docs/client-docs/branding',
328
-
329
- // Planning
330
- '04-planning/01-sprint-planning',
331
-
332
- // Development
333
- '05-development/src/ios',
334
- '05-development/src/android',
335
- '05-development/src/shared',
336
- '05-development/tests',
337
- '05-development/docs/client-docs/assets',
338
-
339
- // QA
340
- '06-qa/device-testing',
341
- '06-qa/automation',
342
-
343
- // Deployment
344
- '07-deployment/app-store',
345
- '07-deployment/play-store'
346
- ]
347
- },
348
-
349
- 'api': {
350
- phases: ['01-comercial', '02-inception', '05-development', '06-qa', '07-deployment'],
351
- startPhase: '02-inception',
352
- directories: [
353
- // Comercial
354
- '01-comercial/01-prospection',
355
-
356
- // Inception (diseño API)
357
- '02-inception/01-api-design',
358
- '02-inception/02-swagger',
359
- '02-inception/docs/client-docs/integraciones',
360
-
361
- // Development (PRINCIPAL)
362
- '05-development/src/controllers',
363
- '05-development/src/services',
364
- '05-development/src/models',
365
- '05-development/tests/integration',
366
- '05-development/tests/unit',
367
- '05-development/docs/api',
368
-
369
- // QA
370
- '06-qa/api-testing',
371
- '06-qa/performance',
372
-
373
- // Deployment
374
- '07-deployment/kubernetes',
375
- '07-deployment/docker'
376
- ]
377
- },
378
-
379
- 'enterprise': {
380
- phases: ['01-comercial', '02-inception', '03-analysis', '04-planning', '05-development', '06-qa', '07-deployment', '08-support'],
381
- startPhase: '01-comercial',
382
- directories: [
383
- // Todas las fases con estructura completa
384
- '01-comercial/01-prospection',
385
- '01-comercial/02-technical-proposal',
386
- '01-comercial/03-quotation',
387
- '01-comercial/04-contract',
388
- '01-comercial/docs/client-docs/requerimientos',
389
- '01-comercial/docs/client-docs/presentaciones',
390
- '01-comercial/docs/client-docs/contratos',
391
-
392
- '02-inception/01-kickoff',
393
- '02-inception/02-prd',
394
- '02-inception/03-backlog',
395
- '02-inception/04-release-planning',
396
- '02-inception/docs/client-docs/procesos',
397
- '02-inception/docs/client-docs/manuales',
398
-
399
- '03-analysis/01-code-audit',
400
- '03-analysis/02-architecture-review',
401
- '03-analysis/docs/client-docs/arquitectura',
402
- '03-analysis/docs/client-docs/databases',
403
-
404
- '04-planning/01-sprint-planning',
405
- '04-planning/02-backlog-refinement',
406
- '04-planning/03-release-planning',
407
- '04-planning/docs/client-docs/historias',
408
-
409
- '05-development/src',
410
- '05-development/tests',
411
- '05-development/docs',
412
- '05-development/docs/client-docs/apis',
413
- '05-development/docs/client-docs/integraciones',
414
-
415
- '06-qa/test-plans',
416
- '06-qa/test-cases',
417
- '06-qa/automation',
418
- '06-qa/docs/client-docs/criterios-aceptacion',
419
-
420
- '07-deployment/environments',
421
- '07-deployment/scripts',
422
- '07-deployment/docs/client-docs/infraestructura',
423
- '07-deployment/docs/client-docs/accesos',
424
-
425
- '08-support/incidents',
426
- '08-support/maintenance',
427
- '08-support/docs/client-docs/incidentes'
428
- ]
429
- }
430
- };
431
-
432
- return structures[projectType] || structures.greenfield;
433
- }
434
-
435
- /**
436
- * Crea guías START_HERE.md para las fases activas
437
- */
438
- async function createPhaseGuides(projectPath, phases) {
439
- // TODO: Crear START_HERE.md específicos para cada fase
440
- // según el tipo de proyecto
441
- console.log('Creando guías para:', phases);
442
- }
443
-
444
- /**
445
- * Crea README en client-docs para las fases activas
446
- */
447
- async function createClientDocsReadmes(projectPath, phases) {
448
- // TODO: Crear README.md en client-docs/ de cada fase
449
- console.log('Creando client-docs README para:', phases);
450
- }
451
-
452
- /**
453
- * Obtiene nombre del tipo de proyecto
454
- */
455
- function getProjectTypeName(projectType) {
456
- const names = {
457
- 'code-audit': 'Auditoría de Código Existente',
458
- 'greenfield': 'Desarrollo Desde Cero',
459
- 'migration': 'Migración/Modernización',
460
- 'maintenance': 'Mantenimiento/Soporte',
461
- 'mobile': 'Aplicación Móvil',
462
- 'api': 'API/Microservicios',
463
- 'enterprise': 'Sistema Empresarial'
464
- };
465
- return names[projectType] || projectType;
466
- }
467
-
468
- /**
469
- * Obtiene agentes recomendados según tipo de proyecto y tecnologías
470
- */
471
- function getRecommendedAgents(projectType, technologies) {
472
- const baseAgents = [];
473
-
474
- // Agentes según tipo de proyecto
475
- if (projectType === 'code-audit') {
476
- baseAgents.push('backend-audit-master', 'frontend-audit-master', 'obsolescence-analyst-senior');
477
- } else if (projectType === 'greenfield') {
478
- baseAgents.push('product-owner-business-analyst', 'solution-architect-senior', 'technical-stories-architect');
479
- } else if (projectType === 'migration') {
480
- baseAgents.push('backend-audit-master', 'solution-architect-senior', 'database-engineer-senior');
481
- } else if (projectType === 'mobile') {
482
- baseAgents.push('react-native-senior', 'frontend-react-senior');
483
- } else if (projectType === 'api') {
484
- baseAgents.push('solution-architect-senior', 'database-engineer-senior');
485
- }
486
-
487
- // Agentes según tecnología
488
- if (technologies.includes('java')) {
489
- baseAgents.push('backend-java-senior');
490
- }
491
- if (technologies.includes('dotnet')) {
492
- baseAgents.push('dotnet-core-senior', 'aspnet-core-architect-senior');
493
- }
494
- if (technologies.includes('python')) {
495
- baseAgents.push('python-senior');
496
- }
497
- if (technologies.includes('react')) {
498
- baseAgents.push('frontend-react-senior');
499
- }
500
- if (technologies.includes('sql') || technologies.includes('nosql')) {
501
- baseAgents.push('database-engineer-senior');
502
- }
503
-
504
- // Agregar agentes base si aún no hay
505
- if (baseAgents.length === 0) {
506
- baseAgents.push('zen-master', 'architect-senior', 'developer-pro');
507
- }
508
-
509
- // Remover duplicados
510
- return [...new Set(baseAgents)];
511
- }
512
-
513
- module.exports = { initCommand };
1
+ /**
2
+ * Comando: init
3
+ * Inicializa el tipo de proyecto y crea estructura específica según necesidades
4
+ */
5
+
6
+ const fs = require('fs-extra');
7
+ const path = require('path');
8
+ const chalk = require('chalk');
9
+ const ora = require('ora');
10
+ const inquirer = require('inquirer');
11
+ const { displayLogo } = require('../utils/console-logger');
12
+ const { loadConfig, updateConfig } = require('../utils/file-utils');
13
+
14
+ async function initCommand() {
15
+ const cwd = process.cwd();
16
+ const awcDir = path.join(cwd, '.awc');
17
+
18
+ displayLogo();
19
+
20
+ console.log(chalk.cyan('\n🎯 Inicialización de Proyecto ZΞNAPSΞS\n'));
21
+
22
+ // Verificar que existe .awc
23
+ if (!(await fs.pathExists(awcDir))) {
24
+ console.log(chalk.red('❌ Este directorio no es un proyecto ZNS.'));
25
+ console.log(chalk.yellow(`\n💡 Ejecuta primero ${chalk.green('zns new <proyecto>')}\n`));
26
+ return;
27
+ }
28
+
29
+ // Cargar configuración
30
+ const config = await loadConfig(awcDir);
31
+
32
+ if (config.initialized) {
33
+ console.log(chalk.yellow('⚠️ Este proyecto ya fue inicializado.'));
34
+ const { reinit } = await inquirer.prompt([
35
+ {
36
+ type: 'confirm',
37
+ name: 'reinit',
38
+ message: '¿Deseas reinicializar? (Se mantendrán archivos existentes)',
39
+ default: false
40
+ }
41
+ ]);
42
+ if (!reinit) {
43
+ return;
44
+ }
45
+ }
46
+
47
+ // Preguntas de inicialización
48
+ const answers = await inquirer.prompt([
49
+ {
50
+ type: 'list',
51
+ name: 'projectType',
52
+ message: '📋 ¿Qué tipo de proyecto es?',
53
+ choices: [
54
+ { name: '🔍 Auditoría de Código Existente', value: 'code-audit' },
55
+ { name: '🆕 Desarrollo Desde Cero', value: 'greenfield' },
56
+ { name: '🔄 Migración/Modernización', value: 'migration' },
57
+ { name: '🛠️ Mantenimiento/Soporte', value: 'maintenance' },
58
+ { name: '📱 Aplicación Móvil', value: 'mobile' },
59
+ { name: '🌐 API/Microservicios', value: 'api' },
60
+ { name: '🏢 Sistema Empresarial', value: 'enterprise' }
61
+ ]
62
+ },
63
+ {
64
+ type: 'list',
65
+ name: 'workflow',
66
+ message: '⚡ ¿Qué workflow deseas usar?',
67
+ choices: [
68
+ { name: ' Quick (1-2 semanas)', value: 'quick' },
69
+ { name: '📊 Standard (1-3 meses)', value: 'standard' },
70
+ { name: '🏢 Enterprise (3+ meses)', value: 'enterprise' }
71
+ ]
72
+ },
73
+ {
74
+ type: 'checkbox',
75
+ name: 'technologies',
76
+ message: '🛠️ Selecciona las tecnologías del proyecto (usa espacio para seleccionar):',
77
+ choices: [
78
+ { name: 'Java', value: 'java' },
79
+ { name: '.NET Core', value: 'dotnet' },
80
+ { name: 'Python', value: 'python' },
81
+ { name: 'PHP', value: 'php' },
82
+ { name: 'Node.js', value: 'nodejs' },
83
+ { name: 'React', value: 'react' },
84
+ { name: 'Angular', value: 'angular' },
85
+ { name: 'Vue', value: 'vue' },
86
+ { name: 'React Native', value: 'react-native' },
87
+ { name: 'SQL Database', value: 'sql' },
88
+ { name: 'NoSQL Database', value: 'nosql' }
89
+ ]
90
+ }
91
+ ]);
92
+
93
+ const spinner = ora('Creando estructura del proyecto...').start();
94
+
95
+ try {
96
+ // Crear estructura según tipo de proyecto
97
+ const structure = getProjectStructure(answers.projectType);
98
+
99
+ for (const dir of structure.directories) {
100
+ await fs.ensureDir(path.join(cwd, dir));
101
+ }
102
+ spinner.text = 'Estructura de directorios creada';
103
+
104
+ // Crear guías START_HERE.md para fases activas
105
+ await createPhaseGuides(cwd, structure.phases);
106
+ spinner.text = 'Guías de fase creadas';
107
+
108
+ // Crear README de client-docs para fases activas
109
+ await createClientDocsReadmes(cwd, structure.phases);
110
+ spinner.text = 'README de client-docs creados';
111
+
112
+ // Actualizar configuración
113
+ config.initialized = true;
114
+ config.projectType = answers.projectType;
115
+ config.workflow = answers.workflow;
116
+ config.technologies = answers.technologies;
117
+ config.structure = structure;
118
+ config.workflows.current_phase = structure.startPhase;
119
+
120
+ await updateConfig(awcDir, config);
121
+ spinner.text = 'Configuración actualizada';
122
+
123
+ spinner.succeed(chalk.green('✅ Proyecto inicializado exitosamente'));
124
+
125
+ // Mostrar resumen
126
+ console.log(chalk.cyan(`\n${'═'.repeat(60)}`));
127
+ console.log(chalk.cyan('📊 Resumen de Inicialización'));
128
+ console.log(chalk.cyan(`${''.repeat(60)}\n`));
129
+
130
+ console.log(
131
+ `${chalk.gray('Tipo de Proyecto:')} ${chalk.green(getProjectTypeName(answers.projectType))}`
132
+ );
133
+ console.log(
134
+ `${chalk.gray('Workflow:')} ${chalk.yellow(answers.workflow.toUpperCase())}`
135
+ );
136
+ console.log(
137
+ `${chalk.gray('Tecnologías:')} ${chalk.blue(answers.technologies.join(', ') || 'Ninguna')}`
138
+ );
139
+ console.log(`${chalk.gray('Fases creadas:')} ${chalk.yellow(structure.phases.length)}\n`);
140
+
141
+ // Mostrar fases creadas
142
+ console.log(chalk.cyan('📂 Estructura Creada:\n'));
143
+ structure.phases.forEach((phase, _index) => {
144
+ const icon = phase === structure.startPhase ? '👉' : ' ';
145
+ console.log(
146
+ ` ${icon} ${chalk.green(phase)} ${phase === structure.startPhase ? chalk.yellow('← INICIAR AQUÍ') : ''}`
147
+ );
148
+ });
149
+
150
+ // Próximos pasos
151
+ console.log(chalk.cyan('\n📚 Próximos Pasos:\n'));
152
+ console.log(` ${chalk.green('1.')} Ir a ${chalk.yellow(`${structure.startPhase}/`)}`);
153
+ console.log(` ${chalk.green('2.')} Leer ${chalk.yellow('START_HERE.md')}`);
154
+ console.log(
155
+ ` ${chalk.green('3.')} Colocar documentación del cliente en ${chalk.yellow('docs/client-docs/')}`
156
+ );
157
+ console.log(` ${chalk.green('4.')} Comenzar a trabajar con los agentes especializados\n`);
158
+
159
+ // Mostrar agentes recomendados
160
+ const recommendedAgents = getRecommendedAgents(answers.projectType, answers.technologies);
161
+ console.log(chalk.cyan('🤖 Agentes Recomendados para este Proyecto:\n'));
162
+ recommendedAgents.forEach((agent) => {
163
+ console.log(` ${chalk.green('→')} ${agent}`);
164
+ });
165
+ console.log();
166
+ } catch (error) {
167
+ spinner.fail(chalk.red(' Error inicializando proyecto'));
168
+ throw error;
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Obtiene la estructura de directorios según tipo de proyecto
174
+ */
175
+ function getProjectStructure(projectType) {
176
+ const structures = {
177
+ 'code-audit': {
178
+ phases: ['01-comercial', '03-analysis', '04-planning', '08-support'],
179
+ startPhase: '01-comercial',
180
+ directories: [
181
+ // Comercial
182
+ '01-comercial/01-prospection',
183
+ '01-comercial/02-technical-proposal',
184
+ '01-comercial/03-quotation',
185
+ '01-comercial/04-contract',
186
+ '01-comercial/docs/client-docs/requerimientos',
187
+ '01-comercial/docs/client-docs/presentaciones',
188
+ '01-comercial/docs/client-docs/contratos',
189
+
190
+ // Analysis (PRINCIPAL para auditoría)
191
+ '03-analysis/01-code-audit',
192
+ '03-analysis/02-architecture-review',
193
+ '03-analysis/03-technical-debt',
194
+ '03-analysis/04-recommendations',
195
+ '03-analysis/docs/client-docs/arquitectura',
196
+ '03-analysis/docs/client-docs/databases',
197
+ '03-analysis/docs/client-docs/codigo-fuente',
198
+ '03-analysis/reports',
199
+
200
+ // Planning (plan de mejoras)
201
+ '04-planning/01-improvement-plan',
202
+ '04-planning/02-priorities',
203
+ '04-planning/docs/client-docs/estimaciones',
204
+
205
+ // Support (recomendaciones)
206
+ '08-support/recommendations',
207
+ '08-support/docs/client-docs/seguimiento'
208
+ ]
209
+ },
210
+
211
+ greenfield: {
212
+ phases: [
213
+ '01-comercial',
214
+ '02-inception',
215
+ '04-planning',
216
+ '05-development',
217
+ '06-qa',
218
+ '07-deployment',
219
+ '08-support'
220
+ ],
221
+ startPhase: '01-comercial',
222
+ directories: [
223
+ // Comercial
224
+ '01-comercial/01-prospection',
225
+ '01-comercial/02-technical-proposal',
226
+ '01-comercial/03-quotation',
227
+ '01-comercial/04-contract',
228
+ '01-comercial/docs/client-docs/requerimientos',
229
+ '01-comercial/docs/client-docs/presentaciones',
230
+
231
+ // Inception (PRINCIPAL)
232
+ '02-inception/01-kickoff',
233
+ '02-inception/02-prd',
234
+ '02-inception/03-backlog',
235
+ '02-inception/04-release-planning',
236
+ '02-inception/docs/client-docs/procesos',
237
+ '02-inception/docs/client-docs/manuales',
238
+ '02-inception/docs/client-docs/imagenes',
239
+
240
+ // Planning
241
+ '04-planning/01-sprint-planning',
242
+ '04-planning/02-backlog-refinement',
243
+ '04-planning/docs/client-docs/historias',
244
+
245
+ // Development (PRINCIPAL)
246
+ '05-development/src',
247
+ '05-development/tests',
248
+ '05-development/docs',
249
+ '05-development/docs/client-docs/recursos',
250
+
251
+ // QA
252
+ '06-qa/test-plans',
253
+ '06-qa/test-cases',
254
+ '06-qa/test-results',
255
+ '06-qa/docs/client-docs/criterios-aceptacion',
256
+
257
+ // Deployment
258
+ '07-deployment/environments',
259
+ '07-deployment/scripts',
260
+ '07-deployment/docs/client-docs/infraestructura',
261
+
262
+ // Support
263
+ '08-support/incidents',
264
+ '08-support/maintenance',
265
+ '08-support/docs/client-docs/incidentes'
266
+ ]
267
+ },
268
+
269
+ migration: {
270
+ phases: ['01-comercial', '03-analysis', '04-planning', '05-development', '07-deployment'],
271
+ startPhase: '01-comercial',
272
+ directories: [
273
+ // Comercial
274
+ '01-comercial/01-prospection',
275
+ '01-comercial/02-technical-proposal',
276
+ '01-comercial/03-quotation',
277
+ '01-comercial/docs/client-docs/requerimientos',
278
+
279
+ // Analysis (PRINCIPAL - analizar sistema legacy)
280
+ '03-analysis/01-legacy-assessment',
281
+ '03-analysis/02-migration-plan',
282
+ '03-analysis/03-risk-assessment',
283
+ '03-analysis/docs/client-docs/arquitectura',
284
+ '03-analysis/docs/client-docs/databases',
285
+ '03-analysis/docs/client-docs/codigo-existente',
286
+
287
+ // Planning (plan de migración)
288
+ '04-planning/01-migration-phases',
289
+ '04-planning/02-data-migration',
290
+ '04-planning/03-rollback-plan',
291
+ '04-planning/docs/client-docs/cronograma',
292
+
293
+ // Development (nuevo sistema)
294
+ '05-development/src',
295
+ '05-development/migration-scripts',
296
+ '05-development/tests',
297
+ '05-development/docs/client-docs/apis',
298
+
299
+ // Deployment (ejecución de migración)
300
+ '07-deployment/pre-migration',
301
+ '07-deployment/migration',
302
+ '07-deployment/post-migration',
303
+ '07-deployment/docs/client-docs/infraestructura',
304
+ '07-deployment/docs/client-docs/accesos'
305
+ ]
306
+ },
307
+
308
+ maintenance: {
309
+ phases: ['01-comercial', '03-analysis', '08-support'],
310
+ startPhase: '08-support',
311
+ directories: [
312
+ // Comercial (contrato de mantenimiento)
313
+ '01-comercial/01-contract',
314
+ '01-comercial/02-sla',
315
+ '01-comercial/docs/client-docs/contratos',
316
+
317
+ // Analysis (entender sistema)
318
+ '03-analysis/01-system-documentation',
319
+ '03-analysis/docs/client-docs/arquitectura',
320
+ '03-analysis/docs/client-docs/codigo',
321
+
322
+ // Support (PRINCIPAL)
323
+ '08-support/incidents',
324
+ '08-support/bug-fixes',
325
+ '08-support/maintenance',
326
+ '08-support/change-requests',
327
+ '08-support/docs/client-docs/incidentes',
328
+ '08-support/docs/client-docs/cambios'
329
+ ]
330
+ },
331
+
332
+ mobile: {
333
+ phases: [
334
+ '01-comercial',
335
+ '02-inception',
336
+ '04-planning',
337
+ '05-development',
338
+ '06-qa',
339
+ '07-deployment'
340
+ ],
341
+ startPhase: '02-inception',
342
+ directories: [
343
+ // Comercial
344
+ '01-comercial/01-prospection',
345
+ '01-comercial/docs/client-docs/requerimientos',
346
+
347
+ // Inception (PRINCIPAL - diseño UX/UI)
348
+ '02-inception/01-ux-design',
349
+ '02-inception/02-ui-design',
350
+ '02-inception/03-prototypes',
351
+ '02-inception/04-backlog',
352
+ '02-inception/docs/client-docs/mockups',
353
+ '02-inception/docs/client-docs/branding',
354
+
355
+ // Planning
356
+ '04-planning/01-sprint-planning',
357
+
358
+ // Development
359
+ '05-development/src/ios',
360
+ '05-development/src/android',
361
+ '05-development/src/shared',
362
+ '05-development/tests',
363
+ '05-development/docs/client-docs/assets',
364
+
365
+ // QA
366
+ '06-qa/device-testing',
367
+ '06-qa/automation',
368
+
369
+ // Deployment
370
+ '07-deployment/app-store',
371
+ '07-deployment/play-store'
372
+ ]
373
+ },
374
+
375
+ api: {
376
+ phases: ['01-comercial', '02-inception', '05-development', '06-qa', '07-deployment'],
377
+ startPhase: '02-inception',
378
+ directories: [
379
+ // Comercial
380
+ '01-comercial/01-prospection',
381
+
382
+ // Inception (diseño API)
383
+ '02-inception/01-api-design',
384
+ '02-inception/02-swagger',
385
+ '02-inception/docs/client-docs/integraciones',
386
+
387
+ // Development (PRINCIPAL)
388
+ '05-development/src/controllers',
389
+ '05-development/src/services',
390
+ '05-development/src/models',
391
+ '05-development/tests/integration',
392
+ '05-development/tests/unit',
393
+ '05-development/docs/api',
394
+
395
+ // QA
396
+ '06-qa/api-testing',
397
+ '06-qa/performance',
398
+
399
+ // Deployment
400
+ '07-deployment/kubernetes',
401
+ '07-deployment/docker'
402
+ ]
403
+ },
404
+
405
+ enterprise: {
406
+ phases: [
407
+ '01-comercial',
408
+ '02-inception',
409
+ '03-analysis',
410
+ '04-planning',
411
+ '05-development',
412
+ '06-qa',
413
+ '07-deployment',
414
+ '08-support'
415
+ ],
416
+ startPhase: '01-comercial',
417
+ directories: [
418
+ // Todas las fases con estructura completa
419
+ '01-comercial/01-prospection',
420
+ '01-comercial/02-technical-proposal',
421
+ '01-comercial/03-quotation',
422
+ '01-comercial/04-contract',
423
+ '01-comercial/docs/client-docs/requerimientos',
424
+ '01-comercial/docs/client-docs/presentaciones',
425
+ '01-comercial/docs/client-docs/contratos',
426
+
427
+ '02-inception/01-kickoff',
428
+ '02-inception/02-prd',
429
+ '02-inception/03-backlog',
430
+ '02-inception/04-release-planning',
431
+ '02-inception/docs/client-docs/procesos',
432
+ '02-inception/docs/client-docs/manuales',
433
+
434
+ '03-analysis/01-code-audit',
435
+ '03-analysis/02-architecture-review',
436
+ '03-analysis/docs/client-docs/arquitectura',
437
+ '03-analysis/docs/client-docs/databases',
438
+
439
+ '04-planning/01-sprint-planning',
440
+ '04-planning/02-backlog-refinement',
441
+ '04-planning/03-release-planning',
442
+ '04-planning/docs/client-docs/historias',
443
+
444
+ '05-development/src',
445
+ '05-development/tests',
446
+ '05-development/docs',
447
+ '05-development/docs/client-docs/apis',
448
+ '05-development/docs/client-docs/integraciones',
449
+
450
+ '06-qa/test-plans',
451
+ '06-qa/test-cases',
452
+ '06-qa/automation',
453
+ '06-qa/docs/client-docs/criterios-aceptacion',
454
+
455
+ '07-deployment/environments',
456
+ '07-deployment/scripts',
457
+ '07-deployment/docs/client-docs/infraestructura',
458
+ '07-deployment/docs/client-docs/accesos',
459
+
460
+ '08-support/incidents',
461
+ '08-support/maintenance',
462
+ '08-support/docs/client-docs/incidentes'
463
+ ]
464
+ }
465
+ };
466
+
467
+ return structures[projectType] || structures.greenfield;
468
+ }
469
+
470
+ /**
471
+ * Crea guías START_HERE.md para las fases activas
472
+ */
473
+ async function createPhaseGuides(projectPath, phases) {
474
+ // TODO: Crear START_HERE.md específicos para cada fase
475
+ // según el tipo de proyecto
476
+ console.log('Creando guías para:', phases);
477
+ }
478
+
479
+ /**
480
+ * Crea README en client-docs para las fases activas
481
+ */
482
+ async function createClientDocsReadmes(projectPath, phases) {
483
+ // TODO: Crear README.md en client-docs/ de cada fase
484
+ console.log('Creando client-docs README para:', phases);
485
+ }
486
+
487
+ /**
488
+ * Obtiene nombre del tipo de proyecto
489
+ */
490
+ function getProjectTypeName(projectType) {
491
+ const names = {
492
+ 'code-audit': 'Auditoría de Código Existente',
493
+ greenfield: 'Desarrollo Desde Cero',
494
+ migration: 'Migración/Modernización',
495
+ maintenance: 'Mantenimiento/Soporte',
496
+ mobile: 'Aplicación Móvil',
497
+ api: 'API/Microservicios',
498
+ enterprise: 'Sistema Empresarial'
499
+ };
500
+ return names[projectType] || projectType;
501
+ }
502
+
503
+ /**
504
+ * Obtiene agentes recomendados según tipo de proyecto y tecnologías
505
+ */
506
+ function getRecommendedAgents(projectType, technologies) {
507
+ const baseAgents = [];
508
+
509
+ // Agentes según tipo de proyecto
510
+ if (projectType === 'code-audit') {
511
+ baseAgents.push('backend-audit-master', 'frontend-audit-master', 'obsolescence-analyst-senior');
512
+ } else if (projectType === 'greenfield') {
513
+ baseAgents.push(
514
+ 'product-owner-business-analyst',
515
+ 'solution-architect-senior',
516
+ 'technical-stories-architect'
517
+ );
518
+ } else if (projectType === 'migration') {
519
+ baseAgents.push(
520
+ 'backend-audit-master',
521
+ 'solution-architect-senior',
522
+ 'database-engineer-senior'
523
+ );
524
+ } else if (projectType === 'mobile') {
525
+ baseAgents.push('react-native-senior', 'frontend-react-senior');
526
+ } else if (projectType === 'api') {
527
+ baseAgents.push('solution-architect-senior', 'database-engineer-senior');
528
+ }
529
+
530
+ // Agentes según tecnología
531
+ if (technologies.includes('java')) {
532
+ baseAgents.push('backend-java-senior');
533
+ }
534
+ if (technologies.includes('dotnet')) {
535
+ baseAgents.push('dotnet-core-senior', 'aspnet-core-architect-senior');
536
+ }
537
+ if (technologies.includes('python')) {
538
+ baseAgents.push('python-senior');
539
+ }
540
+ if (technologies.includes('react')) {
541
+ baseAgents.push('frontend-react-senior');
542
+ }
543
+ if (technologies.includes('sql') || technologies.includes('nosql')) {
544
+ baseAgents.push('database-engineer-senior');
545
+ }
546
+
547
+ // Agregar agentes base si aún no hay
548
+ if (baseAgents.length === 0) {
549
+ baseAgents.push('zen-master', 'architect-senior', 'developer-pro');
550
+ }
551
+
552
+ // Remover duplicados
553
+ return [...new Set(baseAgents)];
554
+ }
555
+
556
+ module.exports = { initCommand };