@saulwade/swl-ses 2.4.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.
- package/CLAUDE.md +2 -1
- package/README.md +1 -1
- package/habilidades/harness-claude-code/SKILL.md +2 -1
- package/habilidades/tdd-workflow/SKILL.md +3 -1
- package/manifiestos/canonical-hashes.json +328 -0
- package/manifiestos/skills-lock.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/reglas/arreglar-al-detectar.md +16 -0
- package/reglas/pruebas.md +7 -3
- package/scripts/actualizar.js +253 -254
- package/scripts/doctor.js +25 -17
- package/scripts/lib/detectar-runtime.js +58 -0
- package/scripts/lib/hooks-settings.js +40 -3
- package/scripts/tui/pantallas/inspect.js +175 -173
- package/scripts/tui/pantallas/uninstall-wizard.js +210 -208
- package/scripts/tui/pantallas/update-wizard.js +234 -232
- package/scripts/tui/pantallas/welcome.js +189 -187
|
@@ -1,208 +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 } = 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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// ---------------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
render.rellenarDer(
|
|
85
|
-
render.rellenarDer(i.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
teclado.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// ---------------------------------------------------------------------------
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
+
};
|