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
@@ -17,11 +17,7 @@ class UpdateChecker {
17
17
  * @param {object} options - Opciones de verificación
18
18
  */
19
19
  async checkForUpdates(options = {}) {
20
- const {
21
- registry = 'https://registry.npmjs.org',
22
- includePrerelease = false,
23
- timeout = 5000
24
- } = options;
20
+ const { registry = 'https://registry.npmjs.org', timeout = 5000 } = options;
25
21
 
26
22
  try {
27
23
  // En producción, esto consultaría el registro de npm
@@ -65,7 +61,7 @@ class UpdateChecker {
65
61
  * Obtiene la última versión disponible
66
62
  * @private
67
63
  */
68
- async fetchLatestVersion(registry, timeout) {
64
+ async fetchLatestVersion(_registry, _timeout) {
69
65
  // Simulación - en producción haría fetch real al registro
70
66
  // const url = `${registry}/${versionManager.packageName}/latest`;
71
67
 
@@ -95,10 +91,10 @@ class UpdateChecker {
95
91
  */
96
92
  getUpdateSeverity(changeType) {
97
93
  const severities = {
98
- 'major': 'critical', // Breaking changes
99
- 'minor': 'important', // New features
100
- 'patch': 'low', // Bug fixes
101
- 'none': 'none'
94
+ major: 'critical', // Breaking changes
95
+ minor: 'important', // New features
96
+ patch: 'low', // Bug fixes
97
+ none: 'none'
102
98
  };
103
99
 
104
100
  return severities[changeType] || 'none';
@@ -109,7 +105,9 @@ class UpdateChecker {
109
105
  * @param {Date} lastCheck - Última vez que se verificó
110
106
  */
111
107
  shouldCheckForUpdates(lastCheck) {
112
- if (!lastCheck) return true;
108
+ if (!lastCheck) {
109
+ return true;
110
+ }
113
111
 
114
112
  const now = new Date();
115
113
  const timeSinceLastCheck = now - new Date(lastCheck);
@@ -132,20 +130,23 @@ class UpdateChecker {
132
130
  }
133
131
 
134
132
  const messages = {
135
- 'critical': `🚨 ACTUALIZACIÓN CRÍTICA DISPONIBLE: v${updateInfo.latestVersion}\n` +
136
- ` Versión actual: v${updateInfo.currentVersion}\n` +
137
- ` Esta actualización incluye cambios importantes (breaking changes).\n` +
138
- ` Actualiza con: npm install -g awc-zns-mtd@latest`,
139
-
140
- 'important': `⚡ Nueva versión disponible: v${updateInfo.latestVersion}\n` +
141
- ` Versión actual: v${updateInfo.currentVersion}\n` +
142
- ` Incluye nuevas funcionalidades.\n` +
143
- ` Actualiza con: npm install -g awc-zns-mtd@latest`,
144
-
145
- 'low': `💡 Actualización disponible: v${updateInfo.latestVersion}\n` +
146
- ` Versión actual: v${updateInfo.currentVersion}\n` +
147
- ` Incluye correcciones de bugs.\n` +
148
- ` Actualiza con: npm install -g awc-zns-mtd@latest`
133
+ critical:
134
+ `🚨 ACTUALIZACIÓN CRÍTICA DISPONIBLE: v${updateInfo.latestVersion}\n` +
135
+ ` Versión actual: v${updateInfo.currentVersion}\n` +
136
+ ' Esta actualización incluye cambios importantes (breaking changes).\n' +
137
+ ' Actualiza con: npm install -g awc-zns-mtd@latest',
138
+
139
+ important:
140
+ `⚡ Nueva versión disponible: v${updateInfo.latestVersion}\n` +
141
+ ` Versión actual: v${updateInfo.currentVersion}\n` +
142
+ ' Incluye nuevas funcionalidades.\n' +
143
+ ' Actualiza con: npm install -g awc-zns-mtd@latest',
144
+
145
+ low:
146
+ `💡 Actualización disponible: v${updateInfo.latestVersion}\n` +
147
+ ` Versión actual: v${updateInfo.currentVersion}\n` +
148
+ ' Incluye correcciones de bugs.\n' +
149
+ ' Actualiza con: npm install -g awc-zns-mtd@latest'
149
150
  };
150
151
 
151
152
  return {
@@ -184,9 +185,7 @@ class UpdateChecker {
184
185
  // Verificar compatibilidad de Node.js
185
186
  const requiredNode = versionManager.getVersionInfo().compatibility?.minimumNodeVersion;
186
187
  if (requiredNode) {
187
- compatibility.recommendations.push(
188
- `Asegúrate de tener Node.js ${requiredNode} o superior`
189
- );
188
+ compatibility.recommendations.push(`Asegúrate de tener Node.js ${requiredNode} o superior`);
190
189
  }
191
190
 
192
191
  return compatibility;
@@ -195,7 +194,7 @@ class UpdateChecker {
195
194
  /**
196
195
  * Obtiene historial de versiones
197
196
  */
198
- async getVersionHistory(limit = 10) {
197
+ async getVersionHistory() {
199
198
  // En producción, esto consultaría el registro real
200
199
  return {
201
200
  current: this.currentVersion,
@@ -217,11 +216,12 @@ class UpdateChecker {
217
216
  async isVersionDeprecated() {
218
217
  const updateInfo = await this.checkForUpdates();
219
218
 
220
- if (!updateInfo.hasUpdate) return false;
219
+ if (!updateInfo.hasUpdate) {
220
+ return false;
221
+ }
221
222
 
222
223
  // Versión deprecada si hay 2+ major versions de diferencia
223
- const majorDiff = semver.major(updateInfo.latestVersion) -
224
- semver.major(this.currentVersion);
224
+ const majorDiff = semver.major(updateInfo.latestVersion) - semver.major(this.currentVersion);
225
225
 
226
226
  return majorDiff >= 2;
227
227
  }
@@ -1,90 +1,89 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Version Bump Script
5
- * Script para incrementar versión del proyecto AWC ZNS-MTD
6
- *
7
- * Uso:
8
- * node version-bump.js <major|minor|patch> [--message "mensaje"]
9
- */
10
-
11
- const fs = require('fs-extra');
12
- const path = require('path');
13
- const versionManager = require('./version-manager');
14
- const changelogManager = require('./changelog-manager');
15
-
16
- async function bumpVersion() {
17
- // Parsear argumentos
18
- const args = process.argv.slice(2);
19
-
20
- if (args.length === 0) {
21
- console.error('❌ Uso: node version-bump.js <major|minor|patch> [--message "mensaje"]');
22
- process.exit(1);
23
- }
24
-
25
- const bumpType = args[0];
26
- const validTypes = ['major', 'minor', 'patch'];
27
-
28
- if (!validTypes.includes(bumpType)) {
29
- console.error(`❌ Tipo inválido: ${bumpType}`);
30
- console.error(` Tipos válidos: ${validTypes.join(', ')}`);
31
- process.exit(1);
32
- }
33
-
34
- // Obtener mensaje personalizado si existe
35
- const messageIndex = args.indexOf('--message');
36
- const customMessage = messageIndex !== -1 ? args[messageIndex + 1] : null;
37
-
38
- try {
39
- console.log('🚀 Incrementando versión...\n');
40
-
41
- // Obtener versión actual
42
- const currentVersion = versionManager.getCurrentVersion();
43
- console.log(` Versión actual: ${currentVersion}`);
44
-
45
- // Calcular nueva versión
46
- const newVersion = versionManager.incrementVersion(bumpType);
47
- console.log(` Nueva versión: ${newVersion}`);
48
- console.log(` Tipo de cambio: ${bumpType}\n`);
49
-
50
- // Actualizar package.json
51
- const packageJsonPath = path.join(__dirname, '../../package.json');
52
- const packageJson = await fs.readJSON(packageJsonPath);
53
- packageJson.version = newVersion;
54
- await fs.writeJSON(packageJsonPath, packageJson, { spaces: 2 });
55
- console.log('✓ package.json actualizado');
56
-
57
- // Generar entrada de changelog
58
- const date = new Date().toISOString().split('T')[0];
59
- const changes = {
60
- added: [],
61
- changed: [`Versión incrementada de ${currentVersion} a ${newVersion}`],
62
- deprecated: [],
63
- removed: [],
64
- fixed: [],
65
- security: []
66
- };
67
-
68
- if (customMessage) {
69
- changes.added.push(customMessage);
70
- }
71
-
72
- await changelogManager.addVersion(newVersion, date, changes);
73
- console.log('✓ CHANGELOG.md actualizado');
74
-
75
- // Resumen
76
- console.log('\n✅ Versión incrementada exitosamente\n');
77
- console.log('📋 Próximos pasos:');
78
- console.log(' 1. Revisa los cambios en CHANGELOG.md');
79
- console.log(' 2. Commit: git add . && git commit -m "chore: bump version to ' + newVersion + '"');
80
- console.log(' 3. Tag: git tag -a v' + newVersion + ' -m "Release v' + newVersion + '"');
81
- console.log(' 4. Push: git push && git push --tags\n');
82
-
83
- } catch (error) {
84
- console.error('❌ Error al incrementar versión:', error.message);
85
- process.exit(1);
86
- }
87
- }
88
-
89
- // Ejecutar
90
- bumpVersion();
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Version Bump Script
5
+ * Script para incrementar versión del proyecto AWC ZNS-MTD
6
+ *
7
+ * Uso:
8
+ * node version-bump.js <major|minor|patch> [--message "mensaje"]
9
+ */
10
+
11
+ const fs = require('fs-extra');
12
+ const path = require('path');
13
+ const versionManager = require('./version-manager');
14
+ const changelogManager = require('./changelog-manager');
15
+
16
+ async function bumpVersion() {
17
+ // Parsear argumentos
18
+ const args = process.argv.slice(2);
19
+
20
+ if (args.length === 0) {
21
+ console.error('❌ Uso: node version-bump.js <major|minor|patch> [--message "mensaje"]');
22
+ process.exit(1);
23
+ }
24
+
25
+ const bumpType = args[0];
26
+ const validTypes = ['major', 'minor', 'patch'];
27
+
28
+ if (!validTypes.includes(bumpType)) {
29
+ console.error(`❌ Tipo inválido: ${bumpType}`);
30
+ console.error(` Tipos válidos: ${validTypes.join(', ')}`);
31
+ process.exit(1);
32
+ }
33
+
34
+ // Obtener mensaje personalizado si existe
35
+ const messageIndex = args.indexOf('--message');
36
+ const customMessage = messageIndex !== -1 ? args[messageIndex + 1] : null;
37
+
38
+ try {
39
+ console.log('🚀 Incrementando versión...\n');
40
+
41
+ // Obtener versión actual
42
+ const currentVersion = versionManager.getCurrentVersion();
43
+ console.log(` Versión actual: ${currentVersion}`);
44
+
45
+ // Calcular nueva versión
46
+ const newVersion = versionManager.incrementVersion(bumpType);
47
+ console.log(` Nueva versión: ${newVersion}`);
48
+ console.log(` Tipo de cambio: ${bumpType}\n`);
49
+
50
+ // Actualizar package.json
51
+ const packageJsonPath = path.join(__dirname, '../../package.json');
52
+ const packageJson = await fs.readJSON(packageJsonPath);
53
+ packageJson.version = newVersion;
54
+ await fs.writeJSON(packageJsonPath, packageJson, { spaces: 2 });
55
+ console.log('✓ package.json actualizado');
56
+
57
+ // Generar entrada de changelog
58
+ const date = new Date().toISOString().split('T')[0];
59
+ const changes = {
60
+ added: [],
61
+ changed: [`Versión incrementada de ${currentVersion} a ${newVersion}`],
62
+ deprecated: [],
63
+ removed: [],
64
+ fixed: [],
65
+ security: []
66
+ };
67
+
68
+ if (customMessage) {
69
+ changes.added.push(customMessage);
70
+ }
71
+
72
+ await changelogManager.addVersion(newVersion, date, changes);
73
+ console.log('✓ CHANGELOG.md actualizado');
74
+
75
+ // Resumen
76
+ console.log('\n✅ Versión incrementada exitosamente\n');
77
+ console.log('📋 Próximos pasos:');
78
+ console.log(' 1. Revisa los cambios en CHANGELOG.md');
79
+ console.log(` 2. Commit: git add . && git commit -m "chore: bump version to ${newVersion}"`);
80
+ console.log(` 3. Tag: git tag -a v${newVersion} -m "Release v${newVersion}"`);
81
+ console.log(' 4. Push: git push && git push --tags\n');
82
+ } catch (error) {
83
+ console.error('❌ Error al incrementar versión:', error.message);
84
+ process.exit(1);
85
+ }
86
+ }
87
+
88
+ // Ejecutar
89
+ bumpVersion();
@@ -48,8 +48,12 @@ class VersionManager {
48
48
  throw new Error('Versiones inválidas');
49
49
  }
50
50
 
51
- if (semver.lt(v1, v2)) return -1;
52
- if (semver.gt(v1, v2)) return 1;
51
+ if (semver.lt(v1, v2)) {
52
+ return -1;
53
+ }
54
+ if (semver.gt(v1, v2)) {
55
+ return 1;
56
+ }
53
57
  return 0;
54
58
  }
55
59
 
@@ -63,7 +67,7 @@ class VersionManager {
63
67
 
64
68
  try {
65
69
  return semver.satisfies(version, requiredVersion);
66
- } catch (error) {
70
+ } catch {
67
71
  return false;
68
72
  }
69
73
  }
@@ -81,9 +85,15 @@ class VersionManager {
81
85
 
82
86
  const diff = semver.diff(oldVersion, newVersion);
83
87
 
84
- if (diff === 'major' || diff === 'premajor') return 'major';
85
- if (diff === 'minor' || diff === 'preminor') return 'minor';
86
- if (diff === 'patch' || diff === 'prepatch') return 'patch';
88
+ if (diff === 'major' || diff === 'premajor') {
89
+ return 'major';
90
+ }
91
+ if (diff === 'minor' || diff === 'preminor') {
92
+ return 'minor';
93
+ }
94
+ if (diff === 'patch' || diff === 'prepatch') {
95
+ return 'patch';
96
+ }
87
97
 
88
98
  return 'none';
89
99
  }
@@ -134,7 +144,7 @@ class VersionManager {
134
144
  const content = await fs.readFile(configPath, 'utf8');
135
145
  const config = yaml.load(content);
136
146
  return config.version || null;
137
- } catch (error) {
147
+ } catch {
138
148
  return null;
139
149
  }
140
150
  }
package/tsconfig.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Language and Environment */
4
+ "target": "ES2021",
5
+ "lib": ["ES2021"],
6
+ "module": "commonjs",
7
+
8
+ /* Modules */
9
+ "moduleResolution": "node",
10
+ "resolveJsonModule": true,
11
+ "allowSyntheticDefaultImports": true,
12
+ "esModuleInterop": true,
13
+
14
+ /* Emit */
15
+ "declaration": true,
16
+ "declarationMap": true,
17
+ "sourceMap": true,
18
+ "outDir": "./dist",
19
+ "removeComments": true,
20
+ "newLine": "lf",
21
+
22
+ /* Interop Constraints */
23
+ "forceConsistentCasingInFileNames": true,
24
+ "allowJs": true,
25
+ "checkJs": false,
26
+
27
+ /* Type Checking */
28
+ "strict": true,
29
+ "noImplicitAny": true,
30
+ "strictNullChecks": true,
31
+ "strictFunctionTypes": true,
32
+ "strictBindCallApply": true,
33
+ "strictPropertyInitialization": true,
34
+ "noImplicitThis": true,
35
+ "alwaysStrict": true,
36
+ "noUnusedLocals": true,
37
+ "noUnusedParameters": true,
38
+ "noImplicitReturns": true,
39
+ "noFallthroughCasesInSwitch": true,
40
+ "noUncheckedIndexedAccess": true,
41
+
42
+ /* Completeness */
43
+ "skipLibCheck": true
44
+ },
45
+ "include": ["tools/**/*.ts", "tools/**/*.js", "src/**/*.ts", "src/**/*.js"],
46
+ "exclude": ["node_modules", "dist", "coverage", "test", "**/*.test.ts", "**/*.test.js"]
47
+ }
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Type Definitions - AWC ZNS-MTD
3
+ * Definiciones de tipos centralizadas para el proyecto
4
+ */
5
+
6
+ /**
7
+ * Metadata de un agente
8
+ */
9
+ export interface AgentMetadata {
10
+ name: string;
11
+ id: string;
12
+ title: string;
13
+ version: string;
14
+ category: AgentCategory;
15
+ stack: string[];
16
+ author?: string;
17
+ description?: string;
18
+ }
19
+
20
+ /**
21
+ * Categorías de agentes
22
+ */
23
+ export type AgentCategory =
24
+ | 'core'
25
+ | 'development'
26
+ | 'qa_testing'
27
+ | 'product_strategy'
28
+ | 'support_maintenance'
29
+ | 'frontend'
30
+ | 'backend'
31
+ | 'infrastructure'
32
+ | 'architecture'
33
+ | 'quality'
34
+ | 'business'
35
+ | 'ai'
36
+ | 'documentation';
37
+
38
+ /**
39
+ * Workflow de un agente
40
+ */
41
+ export interface Workflow {
42
+ name: string;
43
+ description: string;
44
+ steps: WorkflowStep[];
45
+ deliverables?: string[];
46
+ estimatedTime?: string;
47
+ }
48
+
49
+ /**
50
+ * Paso de un workflow
51
+ */
52
+ export interface WorkflowStep {
53
+ id: string;
54
+ name: string;
55
+ action: string;
56
+ inputs?: string[];
57
+ outputs?: string[];
58
+ validations?: string[];
59
+ }
60
+
61
+ /**
62
+ * Definición completa de un agente
63
+ */
64
+ export interface Agent {
65
+ metadata: AgentMetadata;
66
+ role: string;
67
+ expertise: string[];
68
+ workflows: Workflow[];
69
+ deliverables: Deliverable[];
70
+ constraints?: string[];
71
+ bestPractices?: string[];
72
+ }
73
+
74
+ /**
75
+ * Deliverable de un agente
76
+ */
77
+ export interface Deliverable {
78
+ name: string;
79
+ type: DeliverableType;
80
+ format: string;
81
+ description?: string;
82
+ template?: string;
83
+ }
84
+
85
+ /**
86
+ * Tipos de deliverables
87
+ */
88
+ export type DeliverableType =
89
+ | 'document'
90
+ | 'diagram'
91
+ | 'code'
92
+ | 'report'
93
+ | 'specification'
94
+ | 'test'
95
+ | 'artifact';
96
+
97
+ /**
98
+ * Configuración del proyecto
99
+ */
100
+ export interface ProjectConfig {
101
+ projectName: string;
102
+ version: string;
103
+ responsible: string;
104
+ description?: string;
105
+ initialized: boolean;
106
+ projectType?: ProjectType;
107
+ workflow?: WorkflowType;
108
+ technologies?: Technology[];
109
+ createdAt?: string;
110
+ updatedAt?: string;
111
+ }
112
+
113
+ /**
114
+ * Tipos de proyecto
115
+ */
116
+ export type ProjectType =
117
+ | 'code-audit'
118
+ | 'greenfield'
119
+ | 'migration'
120
+ | 'maintenance'
121
+ | 'mobile'
122
+ | 'api'
123
+ | 'enterprise';
124
+
125
+ /**
126
+ * Tipos de workflow
127
+ */
128
+ export type WorkflowType =
129
+ | 'quick'
130
+ | 'standard'
131
+ | 'enterprise'
132
+ | 'comercial-flow'
133
+ | 'inception-flow'
134
+ | 'development-flow'
135
+ | 'qa-flow'
136
+ | 'deployment-flow'
137
+ | 'support-flow';
138
+
139
+ /**
140
+ * Tecnologías soportadas
141
+ */
142
+ export type Technology =
143
+ | 'java'
144
+ | 'dotnet'
145
+ | 'python'
146
+ | 'php'
147
+ | 'nodejs'
148
+ | 'react'
149
+ | 'angular'
150
+ | 'vue'
151
+ | 'react-native'
152
+ | 'sql'
153
+ | 'nosql';
154
+
155
+ /**
156
+ * Opciones de comando CLI
157
+ */
158
+ export interface CommandOptions {
159
+ force?: boolean;
160
+ verbose?: boolean;
161
+ dir?: string;
162
+ type?: string;
163
+ [key: string]: any;
164
+ }
165
+
166
+ /**
167
+ * Resultado de validación
168
+ */
169
+ export interface ValidationResult {
170
+ valid: boolean;
171
+ errors: string[];
172
+ warnings?: string[];
173
+ }
174
+
175
+ /**
176
+ * Información de versión
177
+ */
178
+ export interface VersionInfo {
179
+ current: string;
180
+ latest?: string;
181
+ updateAvailable: boolean;
182
+ releaseNotes?: string;
183
+ }
184
+
185
+ /**
186
+ * Contexto de logging
187
+ */
188
+ export interface LogContext {
189
+ command?: string;
190
+ options?: any;
191
+ timestamp: string;
192
+ duration?: number;
193
+ success?: boolean;
194
+ error?: Error;
195
+ }
196
+
197
+ /**
198
+ * Configuración de entorno
199
+ */
200
+ export interface EnvironmentConfig {
201
+ nodeVersion: string;
202
+ platform: string;
203
+ arch: string;
204
+ cwd: string;
205
+ env: string;
206
+ }