@saulwade/swl-ses 2.4.3 → 2.5.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 (200) hide show
  1. package/CLAUDE.md +194 -241
  2. package/README.md +600 -597
  3. package/agentes/_intent-spec.md +73 -73
  4. package/agentes/_propose-step.md +90 -90
  5. package/agentes/abogado-diablo-swl.md +145 -0
  6. package/agentes/accesibilidad-wcag-swl.md +690 -690
  7. package/agentes/arquitecto-swl.md +267 -267
  8. package/agentes/auto-evolucion-swl.md +908 -908
  9. package/agentes/backend-api-swl.md +1 -1
  10. package/agentes/backend-csharp-swl.md +420 -420
  11. package/agentes/backend-go-swl.md +390 -390
  12. package/agentes/backend-java-swl.md +281 -281
  13. package/agentes/backend-node-swl.md +1 -1
  14. package/agentes/backend-python-swl.md +1 -1
  15. package/agentes/backend-rust-swl.md +364 -364
  16. package/agentes/backend-workers-swl.md +482 -482
  17. package/agentes/cloud-infra-swl.md +509 -509
  18. package/agentes/consolidador-swl.md +541 -541
  19. package/agentes/datos-swl.md +1 -1
  20. package/agentes/depurador-swl.md +352 -352
  21. package/agentes/devops-ci-swl.md +400 -400
  22. package/agentes/disenador-ui-swl.md +569 -569
  23. package/agentes/documentador-swl.md +345 -345
  24. package/agentes/frontend-angular-swl.md +621 -621
  25. package/agentes/frontend-css-swl.md +716 -716
  26. package/agentes/frontend-react-swl.md +692 -692
  27. package/agentes/frontend-swl.md +496 -496
  28. package/agentes/frontend-tailwind-swl.md +826 -826
  29. package/agentes/gh-fix-ci-swl.md +6 -1
  30. package/agentes/implementador-swl.md +1 -1
  31. package/agentes/investigador-swl.md +432 -432
  32. package/agentes/investigador-ux-swl.md +505 -505
  33. package/agentes/llm-apps-swl.md +1 -1
  34. package/agentes/migrador-swl.md +442 -442
  35. package/agentes/mobile-android-swl.md +511 -511
  36. package/agentes/mobile-cross-swl.md +541 -541
  37. package/agentes/mobile-ios-swl.md +502 -502
  38. package/agentes/mobile-testing-swl.md +302 -302
  39. package/agentes/nemesis-auditor-swl.md +285 -285
  40. package/agentes/notificador-swl.md +1 -1
  41. package/agentes/observabilidad-swl.md +438 -438
  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 +10 -1
  50. package/agentes/revisor-angular-swl.md +278 -278
  51. package/agentes/revisor-codigo-swl.md +1 -1
  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 +1 -1
  64. package/agentes/tdd-qa-swl.md +393 -393
  65. package/bin/lib/bot-comandos.js +1 -1
  66. package/bin/swl-ses.js +6 -0
  67. package/comandos/swl/adoptar-proyecto.md +14 -2
  68. package/comandos/swl/configurar-ci.md +8 -1
  69. package/comandos/swl/deuda-codigo.md +97 -97
  70. package/comandos/swl/discutir-fase.md +22 -118
  71. package/comandos/swl/fix.md +118 -0
  72. package/comandos/swl/nuevo-proyecto.md +54 -3
  73. package/comandos/swl/predecir.md +32 -2
  74. package/comandos/swl/seguridad.md +189 -0
  75. package/comandos/swl/status.md +5 -3
  76. package/habilidades/aprendizaje-continuo/SKILL.md +3 -1
  77. package/habilidades/discutir-fase/SKILL.md +84 -81
  78. package/habilidades/discutir-fase/recursos/plantilla-contexto.md +136 -0
  79. package/habilidades/doc-sync/SKILL.md +3 -1
  80. package/habilidades/doubt-driven-review/SKILL.md +15 -1
  81. package/habilidades/ejecutar-task-iterativo/SKILL.md +278 -278
  82. package/habilidades/estructura-proyecto-claude/SKILL.md +11 -2
  83. package/habilidades/harness-claude-code/SKILL.md +3 -1
  84. package/habilidades/instalar-sistema/SKILL.md +3 -1
  85. package/habilidades/meta-reglas-extendido/SKILL.md +92 -0
  86. package/habilidades/meta-reglas-extendido/recursos/analisis-previo-tareas-grandes.md +186 -0
  87. package/habilidades/meta-reglas-extendido/recursos/analizar-directorios-antes-de-escribir.md +235 -0
  88. package/habilidades/meta-reglas-extendido/recursos/api-diseno.md +413 -0
  89. package/habilidades/meta-reglas-extendido/recursos/arquitectura.md +491 -0
  90. package/habilidades/meta-reglas-extendido/recursos/arreglar-al-detectar.md +264 -0
  91. package/habilidades/meta-reglas-extendido/recursos/debatir-antes-de-aceptar.md +152 -0
  92. package/habilidades/meta-reglas-extendido/recursos/git-workflow.md +259 -0
  93. package/habilidades/meta-reglas-extendido/recursos/gobernanza.md +291 -0
  94. package/habilidades/meta-reglas-extendido/recursos/memoria-consolidada.md +263 -0
  95. package/habilidades/meta-reglas-extendido/recursos/seguridad-agentes.md +443 -0
  96. package/habilidades/meta-reglas-extendido/recursos/sesiones-paralelas.md +190 -0
  97. package/habilidades/meta-reglas-extendido/recursos/sin-duplicacion-reglas-globales.md +179 -0
  98. package/habilidades/meta-reglas-extendido/recursos/skills-estandar.md +394 -0
  99. package/habilidades/meta-reglas-extendido/recursos/usar-code-review-graph.md +156 -0
  100. package/habilidades/meta-reglas-extendido/recursos/usar-context7.md +236 -0
  101. package/habilidades/meta-reglas-extendido/recursos/usar-sistema-swl.md +253 -0
  102. package/habilidades/meta-reglas-extendido/recursos/verificar-citas-normativas.md +527 -0
  103. package/habilidades/meta-skills-estandar/SKILL.md +3 -1
  104. package/habilidades/nuevo-proyecto/SKILL.md +20 -3
  105. package/habilidades/php-experto/SKILL.md +10 -3
  106. package/habilidades/{filament-admin/SKILL.md → php-experto/recursos/filament-admin.md} +23 -39
  107. package/habilidades/prevencion-sobreingenieria/recursos/soluciones-nativas.md +166 -166
  108. package/habilidades/prevencion-sobreingenieria/recursos/variables-residuales-post-refactor.md +85 -85
  109. package/habilidades/proceso-debate-adversarial/recursos/personas.md +5 -4
  110. package/habilidades/proceso-ingenieria-requerimientos/SKILL.md +147 -0
  111. package/hooks/check-update.js +19 -10
  112. package/hooks/contexto-subagente.js +68 -68
  113. package/hooks/degradacion-instintos.js +1 -1
  114. package/hooks/extraccion-aprendizajes.js +2 -2
  115. package/hooks/lib/briefing.js +3 -3
  116. package/hooks/lib/nudge-tracker.js +1 -1
  117. package/hooks/lib/otlp-exporter.js +1 -1
  118. package/hooks/lib/webhook-dedup.js +1 -1
  119. package/hooks/session-briefing.js +1 -1
  120. package/llms.txt +6 -6
  121. package/manifiestos/canonical-hashes.json +1043 -52
  122. package/manifiestos/hooks-config.json +469 -469
  123. package/manifiestos/invariantes-criticos.json +30 -30
  124. package/manifiestos/modulos.json +168 -135
  125. package/manifiestos/perfiles.json +0 -2
  126. package/manifiestos/skills-lock.json +49 -56
  127. package/package.json +7 -5
  128. package/plantillas/github-workflows/README.md +15 -1
  129. package/plantillas/github-workflows/swl-devsecops.yml +70 -0
  130. package/plugin.json +5 -5
  131. package/reglas/analisis-previo-tareas-grandes.md +30 -156
  132. package/reglas/analizar-directorios-antes-de-escribir.md +30 -211
  133. package/reglas/api-diseno.md +28 -398
  134. package/reglas/arquitectura.md +35 -456
  135. package/reglas/arreglar-al-detectar.md +30 -230
  136. package/reglas/debatir-antes-de-aceptar.md +30 -143
  137. package/reglas/docs.md +7 -0
  138. package/reglas/estilo-codigo.md +9 -0
  139. package/reglas/fragmentos-compartidos.md +6 -0
  140. package/reglas/git-workflow.md +44 -240
  141. package/reglas/gobernanza.md +23 -262
  142. package/reglas/memoria-consolidada.md +34 -228
  143. package/reglas/performance.md +8 -0
  144. package/reglas/pruebas.md +12 -0
  145. package/reglas/seguridad-agentes.md +37 -418
  146. package/reglas/seguridad.md +12 -0
  147. package/reglas/sesiones-paralelas.md +29 -162
  148. package/reglas/sin-duplicacion-reglas-globales.md +25 -166
  149. package/reglas/skills-estandar.md +23 -373
  150. package/reglas/usar-code-review-graph.md +31 -140
  151. package/reglas/usar-context7.md +30 -208
  152. package/reglas/usar-sistema-swl.md +47 -242
  153. package/reglas/verificar-citas-normativas.md +47 -537
  154. package/scripts/actualizar.js +253 -253
  155. package/scripts/audit-tools/auditar-relleno-inventario.js +145 -0
  156. package/scripts/auditar-clases-conocidas.js +106 -0
  157. package/scripts/bootstrap-instintos.js +2 -2
  158. package/scripts/canario-hooks.js +166 -0
  159. package/scripts/cli/configurar-ci.js +2 -1
  160. package/scripts/evidencia-valor.js +101 -0
  161. package/scripts/field-report.js +18 -2
  162. package/scripts/generar-comandos.js +143 -0
  163. package/scripts/generar-inventario.js +236 -23
  164. package/scripts/generar-matriz-lenguajes.js +1 -1
  165. package/scripts/instalador.js +15 -1
  166. package/scripts/instalar-git-hook.js +8 -1
  167. package/scripts/lib/configurar-ci.js +10 -3
  168. package/scripts/lib/diary-entry.js +3 -1
  169. package/scripts/lib/drift-detector.js +1 -1
  170. package/scripts/lib/evidencia-valor.js +228 -0
  171. package/scripts/lib/expandir-targets.js +71 -71
  172. package/scripts/lib/frontmatter-md.js +63 -0
  173. package/scripts/lib/parsear-opciones.js +2 -0
  174. package/scripts/lib/prune-componentes.js +180 -0
  175. package/scripts/lib/reglas-globales-conocidas.json +16 -2
  176. package/scripts/lib/scoring-instintos.js +2 -2
  177. package/scripts/lib/toml-merge.js +204 -204
  178. package/scripts/lib/transformadores/claude.js +1 -1
  179. package/scripts/lib/transformadores/codex.js +1 -1
  180. package/scripts/lib/transformadores/copilot.js +1 -1
  181. package/scripts/lib/transformadores/cursor.js +1 -1
  182. package/scripts/lib/transformadores/gemini.js +22 -2
  183. package/scripts/lib/transformadores/opencode.js +1 -1
  184. package/scripts/mcp-server/auth.js +105 -105
  185. package/scripts/mcp-server/cache.js +106 -106
  186. package/scripts/prune.js +102 -0
  187. package/scripts/publicar.js +18 -2
  188. package/scripts/tui/index.js +10 -1
  189. package/scripts/tui/pantallas/inspect.js +175 -175
  190. package/scripts/tui/pantallas/install-wizard.js +21 -8
  191. package/scripts/tui/pantallas/uninstall-wizard.js +210 -210
  192. package/scripts/tui/pantallas/update-wizard.js +234 -234
  193. package/scripts/tui/pantallas/welcome.js +188 -189
  194. package/habilidades/paid-media-tracking/SKILL.md +0 -269
  195. package/habilidades/paid-media-tracking/recursos/auditoria-tracking.md +0 -220
  196. package/habilidades/paid-media-tracking/recursos/google-ads-api.md +0 -215
  197. package/habilidades/tracking-measurement/SKILL.md +0 -239
  198. package/habilidades/tracking-measurement/recursos/consent-mode.md +0 -231
  199. package/habilidades/tracking-measurement/recursos/gtm-datalayer.md +0 -216
  200. package/habilidades/tracking-measurement/recursos/meta-capi.md +0 -262
@@ -1,210 +1,210 @@
1
- 'use strict';
2
-
3
- /**
4
- * Wizard de desinstalación TUI.
5
- * Operación destructiva — requiere doble confirmación:
6
- * 1. Multi-select de instalaciones a desinstalar (default: ninguna preseleccionada)
7
- * 2. Vista previa de qué se eliminará (rutas, conteo de archivos)
8
- * 3. Confirmación con escritura explícita del nombre del runtime (anti-clicaccidental)
9
- * 4. Confirmación final
10
- *
11
- * NUNCA toca _userland/ ni APRENDIZAJES.md por diseño del desinstalador.
12
- */
13
-
14
- const fs = require('fs');
15
- const path = require('path');
16
-
17
- const { selectorUnico } = require('../componentes/selector-unico');
18
- const { selectorMulti } = require('../componentes/selector-multi');
19
- const render = require('../lib/render');
20
- const teclas = require('../lib/teclas');
21
- const { colores, semantico, iconos } = require('../lib/colores');
22
-
23
- function _cargarInstalaciones() {
24
- let detectarRuntimes, cargarEstado;
25
- try {
26
- ({ detectarRuntimes, scopesReales } = require('../../lib/detectar-runtime'));
27
- ({ cargarEstado } = require('../../lib/estado'));
28
- } catch (_) {
29
- return [];
30
- }
31
-
32
- const runtimes = detectarRuntimes();
33
- const filas = [];
34
- for (const runtime of runtimes) {
35
- // Dedup + guard anti-fantasma: desde HOME, el local relativo resuelve al
36
- // global propio (duplicado) o al de OTRO runtime (p.ej. .claude de
37
- // OpenClaude = global de Claude Code) — ver scopesReales().
38
- const candidatos = scopesReales(runtime).map(({ dir, esGlobal }) => (
39
- { ruta: dir, scope: esGlobal ? 'global' : 'proyecto', esGlobal }
40
- ));
41
- for (const { ruta, scope, esGlobal } of candidatos) {
42
- if (!fs.existsSync(ruta)) continue;
43
- const estado = cargarEstado(ruta);
44
- if (!estado) continue;
45
- filas.push({
46
- id: `${runtime.id}:${scope}`,
47
- runtimeId: runtime.id,
48
- runtimeNombre: runtime.nombre,
49
- scope,
50
- esGlobal,
51
- ruta,
52
- version: estado.versionSistema || 'desconocida',
53
- perfil: estado.perfil || '-',
54
- archivos: estado.archivosInstalados?.length || 0,
55
- });
56
- }
57
- }
58
- return filas;
59
- }
60
-
61
- // ---------------------------------------------------------------------------
62
- // Pantalla de vista previa de eliminación
63
- // ---------------------------------------------------------------------------
64
-
65
- function _pantallaPreview(seleccionadas) {
66
- return new Promise((resolve) => {
67
- if (!render.ES_TTY || !process.stdin.isTTY) {
68
- resolve(true);
69
- return;
70
- }
71
-
72
- function _renderizar() {
73
- render.limpiarPantalla();
74
- const { cols, rows } = render.obtenerDimensiones();
75
-
76
- render.escribirEn(2, 3, semantico.titulo('Vista previa de desinstalación'));
77
- render.escribirEn(3, 3, semantico.warn(
78
- `${iconos.warn} Esta operación es destructiva. Se eliminarán archivos del sistema.`));
79
-
80
- render.escribirEn(5, 3, semantico.enfasis('Instalaciones a eliminar:'));
81
- seleccionadas.forEach((i, idx) => {
82
- const linea =
83
- `${semantico.error(iconos.cross)} ` +
84
- render.rellenarDer(colores.negrita(i.runtimeNombre), 18) +
85
- render.rellenarDer(`(${i.scope})`, 12) +
86
- render.rellenarDer(`v${i.version}`, 12) +
87
- render.rellenarDer(i.perfil, 16) +
88
- colores.dim(`${i.archivos} archivos`);
89
- render.escribirEn(6 + idx, 5, linea);
90
- });
91
-
92
- const filaRutas = 7 + seleccionadas.length;
93
- render.escribirEn(filaRutas, 3, semantico.enfasis('Rutas afectadas:'));
94
- seleccionadas.forEach((i, idx) => {
95
- if (filaRutas + 1 + idx >= rows - 8) return;
96
- render.escribirEn(filaRutas + 1 + idx, 5,
97
- render.recortar(`${iconos.arrow} ${colores.dim(i.ruta)}`, cols - 7));
98
- });
99
-
100
- // Garantías preservadas
101
- const filaPres = filaRutas + seleccionadas.length + 2;
102
- if (filaPres < rows - 4) {
103
- render.escribirEn(filaPres, 3, semantico.exito('Lo que NO se toca:'));
104
- const preservados = [
105
- '_userland/ — tu código y configuración personal',
106
- '.planning/APRENDIZAJES.md — aprendizajes del proyecto',
107
- '.planning/ — sesiones y contexto del proyecto',
108
- 'Hooks externos no-SWL en settings.json',
109
- ];
110
- preservados.forEach((p, idx) => {
111
- if (filaPres + 1 + idx >= rows - 3) return;
112
- render.escribirEn(filaPres + 1 + idx, 5,
113
- `${semantico.exito(iconos.check)} ${colores.dim(p)}`);
114
- });
115
- }
116
-
117
- render.dibujarPiePagina([
118
- ['Enter', 'continuar a confirmación'],
119
- ['Esc', 'cancelar'],
120
- ]);
121
- }
122
-
123
- render.iniciarModoTui();
124
- _renderizar();
125
- const onResize = () => _renderizar();
126
- process.stdout.on('resize', onResize);
127
-
128
- const teclado = teclas.crearTeclado();
129
- function _finalizar(v) {
130
- teclado.desactivar();
131
- process.stdout.removeListener('resize', onResize);
132
- render.salirModoTui();
133
- resolve(v);
134
- }
135
- teclado.on('return', () => _finalizar(true));
136
- teclado.on('escape', () => _finalizar(false));
137
- teclado.activar();
138
- });
139
- }
140
-
141
- // ---------------------------------------------------------------------------
142
- // Wizard principal
143
- // ---------------------------------------------------------------------------
144
-
145
- async function ejecutarWizardUninstall() {
146
- const instalaciones = _cargarInstalaciones();
147
-
148
- if (instalaciones.length === 0) {
149
- return {
150
- exito: false,
151
- error: 'No se detectaron instalaciones SWL para desinstalar.',
152
- sugerencia: 'Ejecuta swl-ses doctor para diagnosticar.',
153
- };
154
- }
155
-
156
- // 1. Multi-select (NADA preseleccionado por seguridad)
157
- const itemsRuntimes = instalaciones.map(i => ({
158
- valor: i.id,
159
- etiqueta: `${i.runtimeNombre} (${i.scope}) — v${i.version} · perfil ${i.perfil}`,
160
- descripcion: `${i.archivos} archivos en ${i.ruta}`,
161
- preseleccionado: false,
162
- }));
163
-
164
- const idsElegidos = await selectorMulti({
165
- titulo: 'Paso 1/3 — ¿Qué instalaciones desinstalar? (espacio para marcar)',
166
- items: itemsRuntimes,
167
- });
168
- if (idsElegidos === null) return { exito: false, cancelado: true };
169
- if (idsElegidos.length === 0) {
170
- return { exito: false, vacio: true, error: 'No seleccionaste nada.' };
171
- }
172
-
173
- const seleccionadas = instalaciones.filter(i => idsElegidos.includes(i.id));
174
-
175
- // 2. Vista previa
176
- const proceder = await _pantallaPreview(seleccionadas);
177
- if (!proceder) return { exito: false, cancelado: true };
178
-
179
- // 3. Doble confirmación
180
- const confirmacion = await selectorUnico({
181
- titulo: `Paso 3/3 — ¿Confirmar desinstalación de ${seleccionadas.length} instalación(es)?`,
182
- items: [
183
- {
184
- valor: 'no',
185
- etiqueta: 'No, cancelar y volver al menú',
186
- descripcion: 'Vuelve sin tocar nada.',
187
- },
188
- {
189
- valor: 'si',
190
- etiqueta: `Sí, eliminar ${seleccionadas.length} instalación(es) ahora`,
191
- descripcion:
192
- 'Acción irreversible. Si tienes dudas, escoge "No" y haz backup primero. ' +
193
- 'Recuerda que _userland/ y APRENDIZAJES.md se preservan.',
194
- badge: 'destructivo',
195
- },
196
- ],
197
- indiceDefault: 0, // default seguro: cancelar
198
- });
199
- if (confirmacion !== 'si') return { exito: false, cancelado: true };
200
-
201
- return {
202
- exito: true,
203
- plan: { seleccionadas },
204
- };
205
- }
206
-
207
- module.exports = {
208
- ejecutarWizardUninstall,
209
- _cargarInstalaciones,
210
- };
1
+ 'use strict';
2
+
3
+ /**
4
+ * Wizard de desinstalación TUI.
5
+ * Operación destructiva — requiere doble confirmación:
6
+ * 1. Multi-select de instalaciones a desinstalar (default: ninguna preseleccionada)
7
+ * 2. Vista previa de qué se eliminará (rutas, conteo de archivos)
8
+ * 3. Confirmación con escritura explícita del nombre del runtime (anti-clicaccidental)
9
+ * 4. Confirmación final
10
+ *
11
+ * NUNCA toca _userland/ ni APRENDIZAJES.md por diseño del desinstalador.
12
+ */
13
+
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+
17
+ const { selectorUnico } = require('../componentes/selector-unico');
18
+ const { selectorMulti } = require('../componentes/selector-multi');
19
+ const render = require('../lib/render');
20
+ const teclas = require('../lib/teclas');
21
+ const { colores, semantico, iconos } = require('../lib/colores');
22
+
23
+ function _cargarInstalaciones() {
24
+ let detectarRuntimes, scopesReales, cargarEstado;
25
+ try {
26
+ ({ detectarRuntimes, scopesReales } = require('../../lib/detectar-runtime'));
27
+ ({ cargarEstado } = require('../../lib/estado'));
28
+ } catch (_) {
29
+ return [];
30
+ }
31
+
32
+ const runtimes = detectarRuntimes();
33
+ const filas = [];
34
+ for (const runtime of runtimes) {
35
+ // Dedup + guard anti-fantasma: desde HOME, el local relativo resuelve al
36
+ // global propio (duplicado) o al de OTRO runtime (p.ej. .claude de
37
+ // OpenClaude = global de Claude Code) — ver scopesReales().
38
+ const candidatos = scopesReales(runtime).map(({ dir, esGlobal }) => (
39
+ { ruta: dir, scope: esGlobal ? 'global' : 'proyecto', esGlobal }
40
+ ));
41
+ for (const { ruta, scope, esGlobal } of candidatos) {
42
+ if (!fs.existsSync(ruta)) continue;
43
+ const estado = cargarEstado(ruta);
44
+ if (!estado) continue;
45
+ filas.push({
46
+ id: `${runtime.id}:${scope}`,
47
+ runtimeId: runtime.id,
48
+ runtimeNombre: runtime.nombre,
49
+ scope,
50
+ esGlobal,
51
+ ruta,
52
+ version: estado.versionSistema || 'desconocida',
53
+ perfil: estado.perfil || '-',
54
+ archivos: estado.archivosInstalados?.length || 0,
55
+ });
56
+ }
57
+ }
58
+ return filas;
59
+ }
60
+
61
+ // ---------------------------------------------------------------------------
62
+ // Pantalla de vista previa de eliminación
63
+ // ---------------------------------------------------------------------------
64
+
65
+ function _pantallaPreview(seleccionadas) {
66
+ return new Promise((resolve) => {
67
+ if (!render.ES_TTY || !process.stdin.isTTY) {
68
+ resolve(true);
69
+ return;
70
+ }
71
+
72
+ function _renderizar() {
73
+ render.limpiarPantalla();
74
+ const { cols, rows } = render.obtenerDimensiones();
75
+
76
+ render.escribirEn(2, 3, semantico.titulo('Vista previa de desinstalación'));
77
+ render.escribirEn(3, 3, semantico.warn(
78
+ `${iconos.warn} Esta operación es destructiva. Se eliminarán archivos del sistema.`));
79
+
80
+ render.escribirEn(5, 3, semantico.enfasis('Instalaciones a eliminar:'));
81
+ seleccionadas.forEach((i, idx) => {
82
+ const linea =
83
+ `${semantico.error(iconos.cross)} ` +
84
+ render.rellenarDer(colores.negrita(i.runtimeNombre), 18) +
85
+ render.rellenarDer(`(${i.scope})`, 12) +
86
+ render.rellenarDer(`v${i.version}`, 12) +
87
+ render.rellenarDer(i.perfil, 16) +
88
+ colores.dim(`${i.archivos} archivos`);
89
+ render.escribirEn(6 + idx, 5, linea);
90
+ });
91
+
92
+ const filaRutas = 7 + seleccionadas.length;
93
+ render.escribirEn(filaRutas, 3, semantico.enfasis('Rutas afectadas:'));
94
+ seleccionadas.forEach((i, idx) => {
95
+ if (filaRutas + 1 + idx >= rows - 8) return;
96
+ render.escribirEn(filaRutas + 1 + idx, 5,
97
+ render.recortar(`${iconos.arrow} ${colores.dim(i.ruta)}`, cols - 7));
98
+ });
99
+
100
+ // Garantías preservadas
101
+ const filaPres = filaRutas + seleccionadas.length + 2;
102
+ if (filaPres < rows - 4) {
103
+ render.escribirEn(filaPres, 3, semantico.exito('Lo que NO se toca:'));
104
+ const preservados = [
105
+ '_userland/ — tu código y configuración personal',
106
+ '.planning/APRENDIZAJES.md — aprendizajes del proyecto',
107
+ '.planning/ — sesiones y contexto del proyecto',
108
+ 'Hooks externos no-SWL en settings.json',
109
+ ];
110
+ preservados.forEach((p, idx) => {
111
+ if (filaPres + 1 + idx >= rows - 3) return;
112
+ render.escribirEn(filaPres + 1 + idx, 5,
113
+ `${semantico.exito(iconos.check)} ${colores.dim(p)}`);
114
+ });
115
+ }
116
+
117
+ render.dibujarPiePagina([
118
+ ['Enter', 'continuar a confirmación'],
119
+ ['Esc', 'cancelar'],
120
+ ]);
121
+ }
122
+
123
+ render.iniciarModoTui();
124
+ _renderizar();
125
+ const onResize = () => _renderizar();
126
+ process.stdout.on('resize', onResize);
127
+
128
+ const teclado = teclas.crearTeclado();
129
+ function _finalizar(v) {
130
+ teclado.desactivar();
131
+ process.stdout.removeListener('resize', onResize);
132
+ render.salirModoTui();
133
+ resolve(v);
134
+ }
135
+ teclado.on('return', () => _finalizar(true));
136
+ teclado.on('escape', () => _finalizar(false));
137
+ teclado.activar();
138
+ });
139
+ }
140
+
141
+ // ---------------------------------------------------------------------------
142
+ // Wizard principal
143
+ // ---------------------------------------------------------------------------
144
+
145
+ async function ejecutarWizardUninstall() {
146
+ const instalaciones = _cargarInstalaciones();
147
+
148
+ if (instalaciones.length === 0) {
149
+ return {
150
+ exito: false,
151
+ error: 'No se detectaron instalaciones SWL para desinstalar.',
152
+ sugerencia: 'Ejecuta swl-ses doctor para diagnosticar.',
153
+ };
154
+ }
155
+
156
+ // 1. Multi-select (NADA preseleccionado por seguridad)
157
+ const itemsRuntimes = instalaciones.map(i => ({
158
+ valor: i.id,
159
+ etiqueta: `${i.runtimeNombre} (${i.scope}) — v${i.version} · perfil ${i.perfil}`,
160
+ descripcion: `${i.archivos} archivos en ${i.ruta}`,
161
+ preseleccionado: false,
162
+ }));
163
+
164
+ const idsElegidos = await selectorMulti({
165
+ titulo: 'Paso 1/3 — ¿Qué instalaciones desinstalar? (espacio para marcar)',
166
+ items: itemsRuntimes,
167
+ });
168
+ if (idsElegidos === null) return { exito: false, cancelado: true };
169
+ if (idsElegidos.length === 0) {
170
+ return { exito: false, vacio: true, error: 'No seleccionaste nada.' };
171
+ }
172
+
173
+ const seleccionadas = instalaciones.filter(i => idsElegidos.includes(i.id));
174
+
175
+ // 2. Vista previa
176
+ const proceder = await _pantallaPreview(seleccionadas);
177
+ if (!proceder) return { exito: false, cancelado: true };
178
+
179
+ // 3. Doble confirmación
180
+ const confirmacion = await selectorUnico({
181
+ titulo: `Paso 3/3 — ¿Confirmar desinstalación de ${seleccionadas.length} instalación(es)?`,
182
+ items: [
183
+ {
184
+ valor: 'no',
185
+ etiqueta: 'No, cancelar y volver al menú',
186
+ descripcion: 'Vuelve sin tocar nada.',
187
+ },
188
+ {
189
+ valor: 'si',
190
+ etiqueta: `Sí, eliminar ${seleccionadas.length} instalación(es) ahora`,
191
+ descripcion:
192
+ 'Acción irreversible. Si tienes dudas, escoge "No" y haz backup primero. ' +
193
+ 'Recuerda que _userland/ y APRENDIZAJES.md se preservan.',
194
+ badge: 'destructivo',
195
+ },
196
+ ],
197
+ indiceDefault: 0, // default seguro: cancelar
198
+ });
199
+ if (confirmacion !== 'si') return { exito: false, cancelado: true };
200
+
201
+ return {
202
+ exito: true,
203
+ plan: { seleccionadas },
204
+ };
205
+ }
206
+
207
+ module.exports = {
208
+ ejecutarWizardUninstall,
209
+ _cargarInstalaciones,
210
+ };