@saulwade/swl-ses 2.3.1 → 2.4.2

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 (123) hide show
  1. package/CLAUDE.md +242 -240
  2. package/README.md +597 -597
  3. package/agentes/_intent-spec.md +73 -73
  4. package/agentes/_propose-step.md +90 -90
  5. package/agentes/accesibilidad-wcag-swl.md +690 -690
  6. package/agentes/arquitecto-swl.md +267 -267
  7. package/agentes/auto-evolucion-swl.md +908 -908
  8. package/agentes/backend-api-swl.md +472 -472
  9. package/agentes/backend-csharp-swl.md +420 -420
  10. package/agentes/backend-go-swl.md +390 -390
  11. package/agentes/backend-java-swl.md +281 -281
  12. package/agentes/backend-node-swl.md +479 -479
  13. package/agentes/backend-python-swl.md +605 -605
  14. package/agentes/backend-rust-swl.md +364 -364
  15. package/agentes/backend-workers-swl.md +482 -482
  16. package/agentes/cloud-infra-swl.md +509 -509
  17. package/agentes/consolidador-swl.md +541 -541
  18. package/agentes/datos-swl.md +605 -605
  19. package/agentes/depurador-swl.md +352 -352
  20. package/agentes/devops-ci-swl.md +400 -400
  21. package/agentes/disenador-ui-swl.md +569 -569
  22. package/agentes/documentador-swl.md +345 -345
  23. package/agentes/frontend-angular-swl.md +621 -621
  24. package/agentes/frontend-css-swl.md +716 -716
  25. package/agentes/frontend-react-swl.md +692 -692
  26. package/agentes/frontend-swl.md +496 -496
  27. package/agentes/frontend-tailwind-swl.md +826 -826
  28. package/agentes/gh-fix-ci-swl.md +275 -275
  29. package/agentes/implementador-swl.md +328 -328
  30. package/agentes/investigador-swl.md +432 -432
  31. package/agentes/investigador-ux-swl.md +505 -505
  32. package/agentes/llm-apps-swl.md +278 -278
  33. package/agentes/migrador-swl.md +442 -442
  34. package/agentes/mobile-android-swl.md +511 -511
  35. package/agentes/mobile-cross-swl.md +541 -541
  36. package/agentes/mobile-ios-swl.md +502 -502
  37. package/agentes/mobile-testing-swl.md +302 -302
  38. package/agentes/nemesis-auditor-swl.md +285 -285
  39. package/agentes/notificador-swl.md +918 -918
  40. package/agentes/observabilidad-swl.md +438 -438
  41. package/agentes/orquestador-swl.md +1053 -1026
  42. package/agentes/pagos-swl.md +310 -310
  43. package/agentes/perfilador-usuario-swl.md +321 -321
  44. package/agentes/planificador-swl.md +399 -399
  45. package/agentes/producto-prd-swl.md +589 -589
  46. package/agentes/red-team-swl.md +218 -218
  47. package/agentes/release-manager-swl.md +590 -590
  48. package/agentes/rendimiento-swl.md +713 -713
  49. package/agentes/resolutor-build-swl.md +245 -245
  50. package/agentes/revisor-angular-swl.md +278 -278
  51. package/agentes/revisor-codigo-swl.md +538 -505
  52. package/agentes/revisor-csharp-swl.md +264 -264
  53. package/agentes/revisor-go-swl.md +259 -259
  54. package/agentes/revisor-java-swl.md +257 -257
  55. package/agentes/revisor-kotlin-swl.md +273 -273
  56. package/agentes/revisor-nextjs-swl.md +281 -281
  57. package/agentes/revisor-php-swl.md +271 -271
  58. package/agentes/revisor-react-swl.md +278 -278
  59. package/agentes/revisor-rust-swl.md +346 -346
  60. package/agentes/revisor-seguridad-swl.md +399 -399
  61. package/agentes/revisor-swift-swl.md +268 -268
  62. package/agentes/revisor-typescript-swl.md +346 -346
  63. package/agentes/sre-swl.md +291 -291
  64. package/agentes/tdd-qa-swl.md +393 -393
  65. package/comandos/swl/contexto.md +0 -2
  66. package/comandos/swl/deuda-codigo.md +97 -0
  67. package/habilidades/angular-moderno/SKILL.md +5 -1
  68. package/habilidades/contenedores-docker/SKILL.md +3 -1
  69. package/habilidades/ejecutar-task-iterativo/SKILL.md +278 -278
  70. package/habilidades/harness-claude-code/SKILL.md +5 -4
  71. package/habilidades/harness-claude-code/recursos/disciplina-harness-regla.md +6 -5
  72. package/habilidades/legacy-code-rescue/SKILL.md +2 -1
  73. package/habilidades/meta-skills-estandar/SKILL.md +1 -1
  74. package/habilidades/meta-skills-estandar/recursos/skills-as-agents.md +2 -2
  75. package/habilidades/postgresql-experto/SKILL.md +3 -1
  76. package/habilidades/prevencion-sobreingenieria/SKILL.md +70 -92
  77. package/habilidades/prevencion-sobreingenieria/recursos/soluciones-nativas.md +166 -0
  78. package/habilidades/prevencion-sobreingenieria/recursos/variables-residuales-post-refactor.md +85 -0
  79. package/habilidades/tdd-workflow/SKILL.md +3 -1
  80. package/hooks/audit-trail.js +4 -4
  81. package/hooks/calidad-pre-commit.js +15 -11
  82. package/hooks/captura-acciones-post.js +3 -2
  83. package/hooks/captura-acciones-session.js +3 -2
  84. package/hooks/contexto-iteracion.js +2 -1
  85. package/hooks/contexto-subagente.js +68 -0
  86. package/hooks/guardrail-modelo.js +13 -3
  87. package/hooks/inyeccion-contexto.js +12 -12
  88. package/hooks/registro-turnos.js +5 -4
  89. package/hooks/spec-gate.js +2 -1
  90. package/hooks/sugerir-contribuir.js +2 -1
  91. package/hooks/sugerir-regenerar-inventario.js +3 -2
  92. package/hooks/tdd-gate.js +2 -1
  93. package/llms.txt +3 -3
  94. package/manifiestos/canonical-hashes.json +995 -10
  95. package/manifiestos/hook-profiles.json +0 -2
  96. package/manifiestos/hooks-config.json +469 -477
  97. package/manifiestos/invariantes-criticos.json +30 -0
  98. package/manifiestos/modulos.json +1390 -1390
  99. package/manifiestos/skills-lock.json +24 -24
  100. package/package.json +93 -93
  101. package/plugin.json +369 -371
  102. package/reglas/arreglar-al-detectar.md +16 -0
  103. package/reglas/pruebas.md +7 -3
  104. package/schemas/agent-frontmatter.schema.json +3 -1
  105. package/scripts/actualizar.js +253 -254
  106. package/scripts/doctor.js +25 -17
  107. package/scripts/instalador.js +4 -1
  108. package/scripts/lib/detectar-runtime.js +58 -0
  109. package/scripts/lib/expandir-targets.js +71 -71
  110. package/scripts/lib/hooks-settings.js +40 -3
  111. package/scripts/lib/preservar-usuario.js +39 -5
  112. package/scripts/lib/toml-merge.js +204 -204
  113. package/scripts/mcp-server/auth.js +105 -105
  114. package/scripts/mcp-server/cache.js +106 -106
  115. package/scripts/tui/pantallas/inspect.js +175 -173
  116. package/scripts/tui/pantallas/uninstall-wizard.js +210 -208
  117. package/scripts/tui/pantallas/update-wizard.js +234 -232
  118. package/scripts/tui/pantallas/welcome.js +189 -187
  119. package/scripts/validar.js +1 -1
  120. package/scripts/verificar-release.js +51 -0
  121. package/hooks/lib/context-compressor.js +0 -657
  122. package/hooks/linea-estado.js +0 -328
  123. package/hooks/monitor-contexto.js +0 -373
@@ -1,232 +1,234 @@
1
- 'use strict';
2
-
3
- /**
4
- * Wizard de actualización TUI.
5
- * Reemplaza el flujo simple de scripts/actualizar.js que pregunta una vez
6
- * por runtime con un wizard visual:
7
- *
8
- * 1. Detectar runtimes instalados (con su versión, perfil, scope)
9
- * 2. Multi-select de runtimes a actualizar (default: todos los desactualizados)
10
- * 3. Multi-select de categorías de componentes a refrescar
11
- * (skills, hooks, agentes, reglas, comandos, schemas, plantillas)
12
- * 4. Diff preview: ¿qué cambia entre versión instalada y nueva?
13
- * 5. Confirmación final
14
- *
15
- * Devuelve el plan completo o { cancelado: true }.
16
- */
17
-
18
- const fs = require('fs');
19
- const path = require('path');
20
-
21
- const { selectorUnico } = require('../componentes/selector-unico');
22
- const { selectorMulti } = require('../componentes/selector-multi');
23
- const render = require('../lib/render');
24
- const teclas = require('../lib/teclas');
25
- const { colores, semantico, iconos } = require('../lib/colores');
26
-
27
- const CATEGORIAS = [
28
- { valor: 'agentes', etiqueta: 'Agentes', descripcion: '60 agentes especializados (orquestador, revisor, depurador, etc.)' },
29
- { valor: 'habilidades', etiqueta: 'Skills', descripcion: '162 skills cargables bajo demanda' },
30
- { valor: 'comandos', etiqueta: 'Comandos', descripcion: '44 comandos /swl:* del runtime' },
31
- { valor: 'reglas', etiqueta: 'Reglas', descripcion: '66 reglas obligatorias' },
32
- { valor: 'hooks', etiqueta: 'Hooks', descripcion: '41 hooks de pre/post-tool' },
33
- { valor: 'schemas', etiqueta: 'Schemas', descripcion: 'JSON schemas de validación' },
34
- { valor: 'plantillas', etiqueta: 'Plantillas', descripcion: 'Plantillas para .planning/' },
35
- { valor: 'manifiestos', etiqueta: 'Manifiestos', descripcion: 'Catálogos de módulos, perfiles y hooks' },
36
- ];
37
-
38
- // ---------------------------------------------------------------------------
39
- // Detección
40
- // ---------------------------------------------------------------------------
41
-
42
- function _detectarInstalaciones() {
43
- let detectarRuntimes, cargarEstado;
44
- try {
45
- ({ detectarRuntimes } = require('../../lib/detectar-runtime'));
46
- ({ cargarEstado } = require('../../lib/estado'));
47
- } catch (_) {
48
- return [];
49
- }
50
-
51
- const versionPaquete = require('../../../package.json').version;
52
- const runtimes = detectarRuntimes();
53
- const filas = [];
54
-
55
- for (const runtime of runtimes) {
56
- const dirs = [
57
- { ruta: runtime.global, scope: 'global' },
58
- { ruta: path.resolve(runtime.local), scope: 'proyecto' },
59
- ];
60
- for (const { ruta, scope } of dirs) {
61
- try {
62
- if (!fs.existsSync(ruta)) continue;
63
- const estado = cargarEstado(ruta);
64
- if (!estado) continue;
65
- const version = estado.versionSistema || 'desconocida';
66
- filas.push({
67
- id: `${runtime.id}:${scope}`,
68
- runtimeId: runtime.id,
69
- runtimeNombre: runtime.nombre,
70
- scope,
71
- version,
72
- perfil: estado.perfil || '-',
73
- esGlobal: scope === 'global',
74
- desactualizada: version !== versionPaquete,
75
- componentes: estado.componentesInstalados?.length || 0,
76
- });
77
- } catch (_) {
78
- // ignorar
79
- }
80
- }
81
- }
82
- return filas;
83
- }
84
-
85
- // ---------------------------------------------------------------------------
86
- // Pantalla de diff preview
87
- // ---------------------------------------------------------------------------
88
-
89
- function _pantallaDiff(plan, versionPaquete) {
90
- return new Promise((resolve) => {
91
- if (!render.ES_TTY || !process.stdin.isTTY) {
92
- resolve(true);
93
- return;
94
- }
95
-
96
- function _renderizar() {
97
- render.limpiarPantalla();
98
- const { cols } = render.obtenerDimensiones();
99
-
100
- render.escribirEn(2, 3, semantico.titulo('Resumen de la actualización'));
101
- render.escribirEn(3, 3, colores.dim(`Versión disponible: v${versionPaquete}`));
102
-
103
- render.escribirEn(5, 3, semantico.enfasis('Runtimes a actualizar:'));
104
- plan.runtimes.forEach((r, i) => {
105
- const versionEstado = r.version === versionPaquete
106
- ? semantico.exito(`v${r.version}`)
107
- : semantico.warn(`v${r.version} v${versionPaquete}`);
108
- const linea =
109
- `${iconos.arrow} ${render.rellenarDer(colores.negrita(r.runtimeNombre), 18)}` +
110
- render.rellenarDer(`(${r.scope})`, 12) +
111
- render.rellenarDer(r.perfil, 18) +
112
- versionEstado;
113
- render.escribirEn(6 + i, 5, linea);
114
- });
115
-
116
- const filaCat = 7 + plan.runtimes.length;
117
- render.escribirEn(filaCat, 3, semantico.enfasis('Componentes a refrescar:'));
118
- plan.categorias.forEach((c, i) => {
119
- const cat = CATEGORIAS.find(x => x.valor === c);
120
- const lab = cat ? cat.etiqueta : c;
121
- render.escribirEn(filaCat + 1 + i, 5,
122
- `${colores.verde(iconos.check)} ${lab}`);
123
- });
124
-
125
- render.dibujarPiePagina([
126
- ['Enter', 'continuar a confirmación'],
127
- ['Esc', 'cancelar'],
128
- ]);
129
- }
130
-
131
- render.iniciarModoTui();
132
- _renderizar();
133
-
134
- const onResize = () => _renderizar();
135
- process.stdout.on('resize', onResize);
136
-
137
- const teclado = teclas.crearTeclado();
138
- function _finalizar(v) {
139
- teclado.desactivar();
140
- process.stdout.removeListener('resize', onResize);
141
- render.salirModoTui();
142
- resolve(v);
143
- }
144
- teclado.on('return', () => _finalizar(true));
145
- teclado.on('escape', () => _finalizar(false));
146
- teclado.activar();
147
- });
148
- }
149
-
150
- // ---------------------------------------------------------------------------
151
- // Wizard principal
152
- // ---------------------------------------------------------------------------
153
-
154
- async function ejecutarWizardUpdate() {
155
- const versionPaquete = require('../../../package.json').version;
156
- const instalaciones = _detectarInstalaciones();
157
-
158
- if (instalaciones.length === 0) {
159
- return {
160
- exito: false,
161
- error: 'No se detectaron instalaciones SWL para actualizar.',
162
- sugerencia: 'Ejecuta primero swl-ses install para crear una instalación.',
163
- };
164
- }
165
-
166
- // 1. Multi-select de runtimes a actualizar
167
- const itemsRuntimes = instalaciones.map(i => ({
168
- valor: i.id,
169
- etiqueta: `${i.runtimeNombre} (${i.scope}) v${i.version} · perfil ${i.perfil}`,
170
- descripcion: i.desactualizada
171
- ? `Desactualizado. Subirá de v${i.version} a v${versionPaquete}. ${i.componentes} componentes.`
172
- : `Ya está en v${versionPaquete}. Re-instalación refrescará archivos sin cambio de versión.`,
173
- preseleccionado: i.desactualizada, // por default, solo los desactualizados
174
- }));
175
-
176
- const idsElegidos = await selectorMulti({
177
- titulo: 'Paso 1/4 — ¿Qué runtimes actualizas?',
178
- items: itemsRuntimes,
179
- });
180
- if (idsElegidos === null) return { exito: false, cancelado: true };
181
- if (idsElegidos.length === 0) {
182
- return { exito: false, vacio: true, error: 'No seleccionaste ningún runtime para actualizar.' };
183
- }
184
-
185
- const runtimesPlan = instalaciones.filter(i => idsElegidos.includes(i.id));
186
-
187
- // 2. Multi-select de categorías
188
- const categoriasElegidas = await selectorMulti({
189
- titulo: 'Paso 2/4 ¿Qué categorías de componentes refrescas?',
190
- items: CATEGORIAS.map(c => ({ ...c, preseleccionado: true })),
191
- });
192
- if (categoriasElegidas === null) return { exito: false, cancelado: true };
193
- if (categoriasElegidas.length === 0) {
194
- return { exito: false, vacio: true, error: 'No seleccionaste ninguna categoría.' };
195
- }
196
-
197
- const plan = {
198
- runtimes: runtimesPlan,
199
- categorias: categoriasElegidas,
200
- };
201
-
202
- // 3. Diff preview
203
- const proceder = await _pantallaDiff(plan, versionPaquete);
204
- if (!proceder) return { exito: false, cancelado: true };
205
-
206
- // 4. Confirmación final
207
- const confirmacion = await selectorUnico({
208
- titulo: 'Paso 4/4 Confirmar e iniciar actualización',
209
- items: [
210
- {
211
- valor: 'si',
212
- etiqueta: 'Sí, actualizar ahora',
213
- descripcion: `Actualiza ${plan.runtimes.length} runtime(s) en ${plan.categorias.length} categorías. La operación es idempotente; archivos sin cambio quedan iguales.`,
214
- },
215
- {
216
- valor: 'no',
217
- etiqueta: 'No, cancelar',
218
- descripcion: 'Volver al menú sin tocar nada.',
219
- },
220
- ],
221
- });
222
- if (confirmacion !== 'si') return { exito: false, cancelado: true };
223
-
224
- return { exito: true, plan, versionPaquete };
225
- }
226
-
227
- module.exports = {
228
- ejecutarWizardUpdate,
229
- // exports para tests
230
- CATEGORIAS,
231
- _detectarInstalaciones,
232
- };
1
+ 'use strict';
2
+
3
+ /**
4
+ * Wizard de actualización TUI.
5
+ * Reemplaza el flujo simple de scripts/actualizar.js que pregunta una vez
6
+ * por runtime con un wizard visual:
7
+ *
8
+ * 1. Detectar runtimes instalados (con su versión, perfil, scope)
9
+ * 2. Multi-select de runtimes a actualizar (default: todos los desactualizados)
10
+ * 3. Multi-select de categorías de componentes a refrescar
11
+ * (skills, hooks, agentes, reglas, comandos, schemas, plantillas)
12
+ * 4. Diff preview: ¿qué cambia entre versión instalada y nueva?
13
+ * 5. Confirmación final
14
+ *
15
+ * Devuelve el plan completo o { cancelado: true }.
16
+ */
17
+
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+
21
+ const { selectorUnico } = require('../componentes/selector-unico');
22
+ const { selectorMulti } = require('../componentes/selector-multi');
23
+ const render = require('../lib/render');
24
+ const teclas = require('../lib/teclas');
25
+ const { colores, semantico, iconos } = require('../lib/colores');
26
+
27
+ const CATEGORIAS = [
28
+ { valor: 'agentes', etiqueta: 'Agentes', descripcion: '60 agentes especializados (orquestador, revisor, depurador, etc.)' },
29
+ { valor: 'habilidades', etiqueta: 'Skills', descripcion: '162 skills cargables bajo demanda' },
30
+ { valor: 'comandos', etiqueta: 'Comandos', descripcion: '44 comandos /swl:* del runtime' },
31
+ { valor: 'reglas', etiqueta: 'Reglas', descripcion: '66 reglas obligatorias' },
32
+ { valor: 'hooks', etiqueta: 'Hooks', descripcion: '41 hooks de pre/post-tool' },
33
+ { valor: 'schemas', etiqueta: 'Schemas', descripcion: 'JSON schemas de validación' },
34
+ { valor: 'plantillas', etiqueta: 'Plantillas', descripcion: 'Plantillas para .planning/' },
35
+ { valor: 'manifiestos', etiqueta: 'Manifiestos', descripcion: 'Catálogos de módulos, perfiles y hooks' },
36
+ ];
37
+
38
+ // ---------------------------------------------------------------------------
39
+ // Detección
40
+ // ---------------------------------------------------------------------------
41
+
42
+ function _detectarInstalaciones() {
43
+ let detectarRuntimes, cargarEstado;
44
+ try {
45
+ ({ detectarRuntimes, scopesReales } = require('../../lib/detectar-runtime'));
46
+ ({ cargarEstado } = require('../../lib/estado'));
47
+ } catch (_) {
48
+ return [];
49
+ }
50
+
51
+ const versionPaquete = require('../../../package.json').version;
52
+ const runtimes = detectarRuntimes();
53
+ const filas = [];
54
+
55
+ for (const runtime of runtimes) {
56
+ // Dedup + guard anti-fantasma: desde HOME, el local relativo resuelve al
57
+ // global propio (duplicado) o al de OTRO runtime (p.ej. .claude de
58
+ // OpenClaude = global de Claude Code) ver scopesReales().
59
+ const dirs = scopesReales(runtime).map(({ dir, esGlobal }) => (
60
+ { ruta: dir, scope: esGlobal ? 'global' : 'proyecto' }
61
+ ));
62
+ for (const { ruta, scope } of dirs) {
63
+ try {
64
+ if (!fs.existsSync(ruta)) continue;
65
+ const estado = cargarEstado(ruta);
66
+ if (!estado) continue;
67
+ const version = estado.versionSistema || 'desconocida';
68
+ filas.push({
69
+ id: `${runtime.id}:${scope}`,
70
+ runtimeId: runtime.id,
71
+ runtimeNombre: runtime.nombre,
72
+ scope,
73
+ version,
74
+ perfil: estado.perfil || '-',
75
+ esGlobal: scope === 'global',
76
+ desactualizada: version !== versionPaquete,
77
+ componentes: estado.componentesInstalados?.length || 0,
78
+ });
79
+ } catch (_) {
80
+ // ignorar
81
+ }
82
+ }
83
+ }
84
+ return filas;
85
+ }
86
+
87
+ // ---------------------------------------------------------------------------
88
+ // Pantalla de diff preview
89
+ // ---------------------------------------------------------------------------
90
+
91
+ function _pantallaDiff(plan, versionPaquete) {
92
+ return new Promise((resolve) => {
93
+ if (!render.ES_TTY || !process.stdin.isTTY) {
94
+ resolve(true);
95
+ return;
96
+ }
97
+
98
+ function _renderizar() {
99
+ render.limpiarPantalla();
100
+ const { cols } = render.obtenerDimensiones();
101
+
102
+ render.escribirEn(2, 3, semantico.titulo('Resumen de la actualización'));
103
+ render.escribirEn(3, 3, colores.dim(`Versión disponible: v${versionPaquete}`));
104
+
105
+ render.escribirEn(5, 3, semantico.enfasis('Runtimes a actualizar:'));
106
+ plan.runtimes.forEach((r, i) => {
107
+ const versionEstado = r.version === versionPaquete
108
+ ? semantico.exito(`v${r.version}`)
109
+ : semantico.warn(`v${r.version} → v${versionPaquete}`);
110
+ const linea =
111
+ `${iconos.arrow} ${render.rellenarDer(colores.negrita(r.runtimeNombre), 18)}` +
112
+ render.rellenarDer(`(${r.scope})`, 12) +
113
+ render.rellenarDer(r.perfil, 18) +
114
+ versionEstado;
115
+ render.escribirEn(6 + i, 5, linea);
116
+ });
117
+
118
+ const filaCat = 7 + plan.runtimes.length;
119
+ render.escribirEn(filaCat, 3, semantico.enfasis('Componentes a refrescar:'));
120
+ plan.categorias.forEach((c, i) => {
121
+ const cat = CATEGORIAS.find(x => x.valor === c);
122
+ const lab = cat ? cat.etiqueta : c;
123
+ render.escribirEn(filaCat + 1 + i, 5,
124
+ `${colores.verde(iconos.check)} ${lab}`);
125
+ });
126
+
127
+ render.dibujarPiePagina([
128
+ ['Enter', 'continuar a confirmación'],
129
+ ['Esc', 'cancelar'],
130
+ ]);
131
+ }
132
+
133
+ render.iniciarModoTui();
134
+ _renderizar();
135
+
136
+ const onResize = () => _renderizar();
137
+ process.stdout.on('resize', onResize);
138
+
139
+ const teclado = teclas.crearTeclado();
140
+ function _finalizar(v) {
141
+ teclado.desactivar();
142
+ process.stdout.removeListener('resize', onResize);
143
+ render.salirModoTui();
144
+ resolve(v);
145
+ }
146
+ teclado.on('return', () => _finalizar(true));
147
+ teclado.on('escape', () => _finalizar(false));
148
+ teclado.activar();
149
+ });
150
+ }
151
+
152
+ // ---------------------------------------------------------------------------
153
+ // Wizard principal
154
+ // ---------------------------------------------------------------------------
155
+
156
+ async function ejecutarWizardUpdate() {
157
+ const versionPaquete = require('../../../package.json').version;
158
+ const instalaciones = _detectarInstalaciones();
159
+
160
+ if (instalaciones.length === 0) {
161
+ return {
162
+ exito: false,
163
+ error: 'No se detectaron instalaciones SWL para actualizar.',
164
+ sugerencia: 'Ejecuta primero swl-ses install para crear una instalación.',
165
+ };
166
+ }
167
+
168
+ // 1. Multi-select de runtimes a actualizar
169
+ const itemsRuntimes = instalaciones.map(i => ({
170
+ valor: i.id,
171
+ etiqueta: `${i.runtimeNombre} (${i.scope}) v${i.version} · perfil ${i.perfil}`,
172
+ descripcion: i.desactualizada
173
+ ? `Desactualizado. Subirá de v${i.version} a v${versionPaquete}. ${i.componentes} componentes.`
174
+ : `Ya está en v${versionPaquete}. Re-instalación refrescará archivos sin cambio de versión.`,
175
+ preseleccionado: i.desactualizada, // por default, solo los desactualizados
176
+ }));
177
+
178
+ const idsElegidos = await selectorMulti({
179
+ titulo: 'Paso 1/4 — ¿Qué runtimes actualizas?',
180
+ items: itemsRuntimes,
181
+ });
182
+ if (idsElegidos === null) return { exito: false, cancelado: true };
183
+ if (idsElegidos.length === 0) {
184
+ return { exito: false, vacio: true, error: 'No seleccionaste ningún runtime para actualizar.' };
185
+ }
186
+
187
+ const runtimesPlan = instalaciones.filter(i => idsElegidos.includes(i.id));
188
+
189
+ // 2. Multi-select de categorías
190
+ const categoriasElegidas = await selectorMulti({
191
+ titulo: 'Paso 2/4 — ¿Qué categorías de componentes refrescas?',
192
+ items: CATEGORIAS.map(c => ({ ...c, preseleccionado: true })),
193
+ });
194
+ if (categoriasElegidas === null) return { exito: false, cancelado: true };
195
+ if (categoriasElegidas.length === 0) {
196
+ return { exito: false, vacio: true, error: 'No seleccionaste ninguna categoría.' };
197
+ }
198
+
199
+ const plan = {
200
+ runtimes: runtimesPlan,
201
+ categorias: categoriasElegidas,
202
+ };
203
+
204
+ // 3. Diff preview
205
+ const proceder = await _pantallaDiff(plan, versionPaquete);
206
+ if (!proceder) return { exito: false, cancelado: true };
207
+
208
+ // 4. Confirmación final
209
+ const confirmacion = await selectorUnico({
210
+ titulo: 'Paso 4/4 — Confirmar e iniciar actualización',
211
+ items: [
212
+ {
213
+ valor: 'si',
214
+ etiqueta: 'Sí, actualizar ahora',
215
+ descripcion: `Actualiza ${plan.runtimes.length} runtime(s) en ${plan.categorias.length} categorías. La operación es idempotente; archivos sin cambio quedan iguales.`,
216
+ },
217
+ {
218
+ valor: 'no',
219
+ etiqueta: 'No, cancelar',
220
+ descripcion: 'Volver al menú sin tocar nada.',
221
+ },
222
+ ],
223
+ });
224
+ if (confirmacion !== 'si') return { exito: false, cancelado: true };
225
+
226
+ return { exito: true, plan, versionPaquete };
227
+ }
228
+
229
+ module.exports = {
230
+ ejecutarWizardUpdate,
231
+ // exports para tests
232
+ CATEGORIAS,
233
+ _detectarInstalaciones,
234
+ };