@tacuchi/updater 3.0.0 → 3.1.0

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -62
  3. package/dist/cli.js +1379 -1197
  4. package/package.json +11 -2
package/dist/cli.js CHANGED
@@ -1,11 +1,662 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // src/cli.tsx
4
+ import { Writable } from "stream";
5
+
6
+ // src/lib/config.ts
7
+ import fs from "fs";
8
+ import path from "path";
9
+ import os from "os";
10
+ var DEFAULTS = {
11
+ enabledManagers: {},
12
+ verbosity: "info",
13
+ language: "es",
14
+ concurrency: 4,
15
+ timeoutsMs: {},
16
+ logTailBytes: 16384,
17
+ managers: {},
18
+ logRetentionRuns: 30,
19
+ selfCheck: true
20
+ };
21
+ var MIN_CONCURRENCY = 1;
22
+ var MAX_CONCURRENCY = 8;
23
+ function clampConcurrency(value) {
24
+ const n = typeof value === "number" && Number.isFinite(value) ? value : DEFAULTS.concurrency;
25
+ return Math.max(MIN_CONCURRENCY, Math.min(MAX_CONCURRENCY, Math.round(n)));
26
+ }
27
+ function normalizeConfig(parsed) {
28
+ return {
29
+ ...DEFAULTS,
30
+ ...parsed,
31
+ enabledManagers: { ...DEFAULTS.enabledManagers, ...parsed.enabledManagers },
32
+ timeoutsMs: { ...DEFAULTS.timeoutsMs, ...parsed.timeoutsMs },
33
+ managers: { ...DEFAULTS.managers, ...parsed.managers },
34
+ concurrency: clampConcurrency(parsed.concurrency),
35
+ logTailBytes: typeof parsed.logTailBytes === "number" && Number.isFinite(parsed.logTailBytes) && parsed.logTailBytes > 0 ? Math.max(1, Math.round(parsed.logTailBytes)) : DEFAULTS.logTailBytes,
36
+ logRetentionRuns: typeof parsed.logRetentionRuns === "number" && parsed.logRetentionRuns >= 1 ? Math.round(parsed.logRetentionRuns) : DEFAULTS.logRetentionRuns,
37
+ selfCheck: typeof parsed.selfCheck === "boolean" ? parsed.selfCheck : DEFAULTS.selfCheck
38
+ };
39
+ }
40
+ var APP = "tacuchi-updater";
41
+ function windowsPaths() {
42
+ const home = os.homedir();
43
+ const roaming = process.env["APPDATA"] || path.join(home, "AppData", "Roaming");
44
+ const local = process.env["LOCALAPPDATA"] || path.join(home, "AppData", "Local");
45
+ return { config: path.join(roaming, APP, "Config"), log: path.join(local, APP, "Log") };
46
+ }
47
+ function getConfigDir(platform = process.platform) {
48
+ const override = process.env["TACUCHI_UPDATER_CONFIG_DIR"];
49
+ if (override) return override;
50
+ if (platform === "win32") return windowsPaths().config;
51
+ return path.join(os.homedir(), ".tacuchi-updater");
52
+ }
53
+ function getLogDir(platform = process.platform) {
54
+ const override = process.env["TACUCHI_UPDATER_LOG_DIR"];
55
+ if (override) return override;
56
+ if (platform === "win32") return windowsPaths().log;
57
+ return path.join(getConfigDir(platform), "logs");
58
+ }
59
+ function getConfigPath() {
60
+ return path.join(getConfigDir(), "config.json");
61
+ }
62
+ function migrateLegacyConfig() {
63
+ if (process.platform !== "win32") return;
64
+ try {
65
+ const target = getConfigPath();
66
+ if (fs.existsSync(target)) return;
67
+ const legacy = path.join(os.homedir(), ".tacuchi-updater", "config.json");
68
+ if (!fs.existsSync(legacy)) return;
69
+ const dir = getConfigDir();
70
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
71
+ fs.copyFileSync(legacy, target);
72
+ } catch {
73
+ }
74
+ }
75
+ function loadConfig() {
76
+ migrateLegacyConfig();
77
+ const configPath = getConfigPath();
78
+ try {
79
+ if (!fs.existsSync(configPath)) {
80
+ const defaults = { ...DEFAULTS };
81
+ try {
82
+ saveConfig(defaults);
83
+ } catch {
84
+ }
85
+ return defaults;
86
+ }
87
+ const raw = fs.readFileSync(configPath, "utf-8");
88
+ const parsed = JSON.parse(raw);
89
+ return normalizeConfig(parsed);
90
+ } catch {
91
+ return { ...DEFAULTS };
92
+ }
93
+ }
94
+ function saveConfig(config) {
95
+ const dir = getConfigDir();
96
+ if (!fs.existsSync(dir)) {
97
+ fs.mkdirSync(dir, { recursive: true });
98
+ }
99
+ const target = getConfigPath();
100
+ const tmp = target + ".tmp";
101
+ const data = JSON.stringify(config, null, 2);
102
+ try {
103
+ fs.writeFileSync(tmp, data, "utf-8");
104
+ fs.renameSync(tmp, target);
105
+ } catch (err) {
106
+ const code = err.code;
107
+ if (code === "EPERM" || code === "EBUSY" || code === "EEXIST") {
108
+ fs.writeFileSync(target, data, "utf-8");
109
+ try {
110
+ fs.unlinkSync(tmp);
111
+ } catch {
112
+ }
113
+ } else {
114
+ throw err;
115
+ }
116
+ }
117
+ }
118
+ function isManagerEnabled(config, managerId) {
119
+ if (Object.prototype.hasOwnProperty.call(config.enabledManagers, managerId)) {
120
+ return config.enabledManagers[managerId] ?? true;
121
+ }
122
+ return true;
123
+ }
124
+
125
+ // src/i18n/es.ts
126
+ var es = {
127
+ hints: {
128
+ ctrlC: "Ctrl+C cancelar",
129
+ confirmCancel: "S s\xED, cancelar",
130
+ continueRun: "N/Esc seguir",
131
+ quit: "Q salir",
132
+ retry: "R volver a buscar",
133
+ down: "Abajo/J bajar",
134
+ up: "Arriba/K subir",
135
+ mark: "Espacio marcar",
136
+ all: "A todos",
137
+ none: "N ninguno",
138
+ next: "Enter continuar",
139
+ settings: "S ajustes",
140
+ back: "Esc volver",
141
+ detail: "D detalle",
142
+ language: "L idioma",
143
+ elevate: "E abrir como administrador",
144
+ start: "Enter/Y actualizar",
145
+ cancel: "Esc cancelar"
146
+ },
147
+ cli: {
148
+ help: "@tacuchi/updater - Actualiza los gestores de paquetes\n\nUso: updater [opciones]\n\n-s, --sudo Permite gestores que requieren administrador\n-y, --yes, --all Actualiza todo sin teclado\n-h, --help Muestra esta ayuda\n-v, --version Muestra la versi\xF3n\n\nSin stdin TTY, la ejecuci\xF3n es autom\xE1tica.\n\xDAltima versi\xF3n: npx @tacuchi/updater@latest",
149
+ sudoPrompt: "Modo SUDO: ingresa tu contrase\xF1a para continuar...",
150
+ sudoFailure: "No se pudo autenticar sudo. Continuando sin permisos elevados.",
151
+ windowsAdmin: "En Windows --sudo no eleva. Abre la terminal como Administrador."
152
+ },
153
+ managers: {
154
+ brew: "Homebrew",
155
+ pip: "pip / Python",
156
+ npm: "Node NPM",
157
+ conda: "Conda",
158
+ gem: "RubyGems",
159
+ softwareupdate: "macOS Updates",
160
+ winget: "Winget",
161
+ apt: "APT / Debian",
162
+ dnf: "DNF / Fedora",
163
+ pacman: "Pacman / Arch",
164
+ flatpak: "Flatpak",
165
+ snap: "Snap",
166
+ flutter: "Flutter SDK",
167
+ angular: "Angular CLI",
168
+ cargo: "Cargo binarios",
169
+ "go-lang": "Go SDK",
170
+ composer: "Composer / PHP",
171
+ choco: "Chocolatey",
172
+ pnpm: "pnpm",
173
+ yarn: "Yarn",
174
+ bun: "Bun",
175
+ mise: "mise",
176
+ asdf: "asdf",
177
+ rustup: "Rust / rustup",
178
+ mas: "Mac App Store",
179
+ scoop: "Scoop",
180
+ pipx: "pipx"
181
+ },
182
+ banner: {
183
+ macos: "macOS",
184
+ linux: "Linux",
185
+ windows: "Windows",
186
+ searching: "buscando gestores",
187
+ managerOne: "gestor detectado",
188
+ managerMany: "gestores detectados"
189
+ },
190
+ flow: {
191
+ step: "Paso",
192
+ detecting: "Detectando gestores",
193
+ scanning: "Buscando actualizaciones",
194
+ select: "Seleccionar",
195
+ confirm: "Confirmar",
196
+ updating: "Actualizando",
197
+ summary: "Resumen",
198
+ detail: "Detalle por paquete",
199
+ settings: "Ajustes"
200
+ },
201
+ // Etiquetas de estado por-gestor (ManagerStatus)
202
+ status: {
203
+ cancelling: "CANCELANDO",
204
+ partial: "PARCIAL",
205
+ pending: "PENDIENTE",
206
+ scanning: "ESCANEANDO",
207
+ outdated: "DISPONIBLE",
208
+ uptodate: "AL D\xCDA",
209
+ queued: "EN COLA",
210
+ running: "ACTUALIZANDO",
211
+ done: "OK",
212
+ failed: "ERROR",
213
+ skipped: "MANUAL",
214
+ unknown: "INDETERMINADO"
215
+ },
216
+ // Cadenas de la interfaz del flujo
217
+ ui: {
218
+ rebootRequired: "necesario",
219
+ rebootInitiated: "iniciado",
220
+ rebootDeferred: "pospuesto",
221
+ of: "de",
222
+ upgradedOne: "actualizado",
223
+ failedOne: "fallido",
224
+ manualShort: "manual",
225
+ manualMany: "manuales",
226
+ cancelQuestion: "\xBFCancelar? Se detendr\xEDan:",
227
+ rebootPending: "Reinicio pendiente",
228
+ language: "Idioma",
229
+ on: "[s\xED]",
230
+ off: "[no]",
231
+ packageOne: "paquete",
232
+ packageMany: "paquetes",
233
+ adminManual: "requiere admin; manual",
234
+ sudoManual: "requiere --sudo; manual",
235
+ timeoutNote: "Un TIMEOUT suele pedir interacci\xF3n. Actual\xEDzalo a mano en una terminal.",
236
+ detectionFailed: "No se pudieron detectar los gestores de paquetes.",
237
+ chooseFirst: "Marca al menos un paquete para continuar.",
238
+ detecting: "Detectando gestores de paquetes...",
239
+ scanning: "Buscando actualizaciones...",
240
+ noUpdates: "Todo est\xE1 al d\xEDa. No hay actualizaciones.",
241
+ selectedOne: "marcado",
242
+ selected: "marcados",
243
+ willRun: "Se ejecutar\xE1:",
244
+ upgraded: "actualizados",
245
+ failed: "fallidos",
246
+ allDone: "COMPLETADO",
247
+ withErrors: "COMPLETADO CON ERRORES",
248
+ logAt: "Registro:",
249
+ manualNeeded: "Requiere ejecuci\xF3n manual:",
250
+ passwordNote: 'Si pide "Password:", escr\xEDbela y pulsa Enter.',
251
+ undetermined: "no se pudo determinar",
252
+ undeterminedShort: "sin determinar",
253
+ noChanges: "Ninguna corrida cambi\xF3 paquetes."
254
+ }
255
+ };
256
+
257
+ // src/i18n/en.ts
258
+ var en = {
259
+ hints: {
260
+ ctrlC: "Ctrl+C cancel",
261
+ confirmCancel: "Y yes, cancel",
262
+ continueRun: "N/Esc continue",
263
+ quit: "Q quit",
264
+ retry: "R scan again",
265
+ down: "Down/J move down",
266
+ up: "Up/K move up",
267
+ mark: "Space select",
268
+ all: "A all",
269
+ none: "N none",
270
+ next: "Enter continue",
271
+ settings: "S settings",
272
+ back: "Esc back",
273
+ detail: "D details",
274
+ language: "L language",
275
+ elevate: "E open as administrator",
276
+ start: "Enter/Y update",
277
+ cancel: "Esc cancel"
278
+ },
279
+ cli: {
280
+ help: "@tacuchi/updater - Updates package managers\n\nUsage: updater [options]\n\n-s, --sudo Allows managers requiring administrator access\n-y, --yes, --all Updates everything without keyboard input\n-h, --help Shows this help\n-v, --version Shows the version\n\nWithout stdin TTY, execution is automatic.\nLatest version: npx @tacuchi/updater@latest",
281
+ sudoPrompt: "SUDO mode: enter your password to continue...",
282
+ sudoFailure: "Could not authenticate sudo. Continuing without elevated permissions.",
283
+ windowsAdmin: "On Windows --sudo does not elevate. Open the terminal as Administrator."
284
+ },
285
+ managers: {
286
+ brew: "Homebrew",
287
+ pip: "pip / Python",
288
+ npm: "Node NPM",
289
+ conda: "Conda",
290
+ gem: "RubyGems",
291
+ softwareupdate: "macOS Updates",
292
+ winget: "Winget",
293
+ apt: "APT / Debian",
294
+ dnf: "DNF / Fedora",
295
+ pacman: "Pacman / Arch",
296
+ flatpak: "Flatpak",
297
+ snap: "Snap",
298
+ flutter: "Flutter SDK",
299
+ angular: "Angular CLI",
300
+ cargo: "Cargo binaries",
301
+ "go-lang": "Go SDK",
302
+ composer: "Composer / PHP",
303
+ choco: "Chocolatey",
304
+ pnpm: "pnpm",
305
+ yarn: "Yarn",
306
+ bun: "Bun",
307
+ mise: "mise",
308
+ asdf: "asdf",
309
+ rustup: "Rust / rustup",
310
+ mas: "Mac App Store",
311
+ scoop: "Scoop",
312
+ pipx: "pipx"
313
+ },
314
+ banner: {
315
+ macos: "macOS",
316
+ linux: "Linux",
317
+ windows: "Windows",
318
+ searching: "looking for managers",
319
+ managerOne: "manager detected",
320
+ managerMany: "managers detected"
321
+ },
322
+ flow: {
323
+ step: "Step",
324
+ detecting: "Detecting managers",
325
+ scanning: "Checking for updates",
326
+ select: "Select",
327
+ confirm: "Confirm",
328
+ updating: "Updating",
329
+ summary: "Summary",
330
+ detail: "Per-package detail",
331
+ settings: "Settings"
332
+ },
333
+ status: {
334
+ cancelling: "CANCELLING",
335
+ partial: "PARTIAL",
336
+ pending: "PENDING",
337
+ scanning: "SCANNING",
338
+ outdated: "AVAILABLE",
339
+ uptodate: "UP TO DATE",
340
+ queued: "QUEUED",
341
+ running: "UPDATING",
342
+ done: "OK",
343
+ failed: "ERROR",
344
+ skipped: "MANUAL",
345
+ unknown: "UNDETERMINED"
346
+ },
347
+ ui: {
348
+ rebootRequired: "required",
349
+ rebootInitiated: "initiated",
350
+ rebootDeferred: "deferred",
351
+ of: "of",
352
+ upgradedOne: "upgraded",
353
+ failedOne: "failed",
354
+ manualShort: "manual update",
355
+ manualMany: "manual updates",
356
+ cancelQuestion: "Cancel? These managers would stop:",
357
+ rebootPending: "Reboot pending",
358
+ language: "Language",
359
+ on: "[on]",
360
+ off: "[off]",
361
+ packageOne: "package",
362
+ packageMany: "packages",
363
+ adminManual: "requires admin; manual",
364
+ sudoManual: "requires --sudo; manual",
365
+ timeoutNote: "A TIMEOUT often needs interaction. Update it manually in a terminal.",
366
+ detectionFailed: "Could not detect package managers.",
367
+ chooseFirst: "Select at least one package to continue.",
368
+ detecting: "Detecting package managers...",
369
+ scanning: "Checking for updates...",
370
+ noUpdates: "Everything is up to date. No updates.",
371
+ selectedOne: "marked",
372
+ selected: "marked",
373
+ willRun: "Will run:",
374
+ upgraded: "upgraded",
375
+ failed: "failed",
376
+ allDone: "DONE",
377
+ withErrors: "DONE WITH ERRORS",
378
+ logAt: "Log:",
379
+ manualNeeded: "Manual command needed:",
380
+ passwordNote: 'If asked for "Password:", type it and press Enter.',
381
+ undetermined: "could not be determined",
382
+ undeterminedShort: "undetermined",
383
+ noChanges: "No run changed any package."
384
+ }
385
+ };
386
+
387
+ // src/i18n/index.ts
388
+ var currentLang = detectLanguage();
389
+ function detectLanguage() {
390
+ const lang = (process.env["LANG"] ?? process.env["LANGUAGE"] ?? "").toLowerCase();
391
+ if (lang.startsWith("en")) return "en";
392
+ return "es";
393
+ }
394
+ function setLanguage(lang) {
395
+ currentLang = lang;
396
+ }
397
+ function getLanguage() {
398
+ return currentLang;
399
+ }
400
+ var translations = { es, en };
401
+ function t(section, key) {
402
+ const dict = translations[currentLang] ?? es;
403
+ const sec = dict[section];
404
+ if (key === void 0) return sec;
405
+ return sec[key];
406
+ }
407
+ function managerName(id) {
408
+ const dict = translations[currentLang] ?? es;
409
+ const names = dict.managers;
410
+ return names[id] ?? id;
411
+ }
412
+
413
+ // src/theme.ts
414
+ var tokens = {
415
+ dark: { text: "#e6e6e2", muted: "#a3a39b", accent: "#bff278" },
416
+ light: { text: "#111111", muted: "#5c5c56", accent: "#bce489" },
417
+ logo: "#b6f23c",
418
+ error: "#ffb4ab",
419
+ warning: "#ffade0",
420
+ unknown: "#f0b429"
421
+ };
422
+ function themeFor(mode) {
423
+ const palette = tokens[mode];
424
+ return {
425
+ text: palette.text,
426
+ muted: palette.muted,
427
+ action: mode === "light" ? palette.text : palette.accent,
428
+ success: mode === "light" ? palette.text : palette.accent,
429
+ error: tokens.error,
430
+ warning: tokens.warning,
431
+ unknown: tokens.unknown,
432
+ accentFill: palette.accent,
433
+ logoFill: tokens.logo
434
+ };
435
+ }
436
+ var semantic = themeFor("dark");
437
+ var terminalTheme = "dark";
438
+ var colors = { outline: semantic.muted };
439
+ function setTerminalTheme(mode) {
440
+ terminalTheme = mode;
441
+ Object.assign(semantic, themeFor(mode));
442
+ colors.outline = semantic.muted;
443
+ }
444
+
445
+ // src/lib/brand-images.ts
446
+ var darkIsotype = "iVBORw0KGgoAAAANSUhEUgAAAXAAAAE4CAYAAABCEqg+AAAABmJLR0QA/wD/AP+gvaeTAAAOsElEQVR4nO3dT6il913H8c/vzJ8mtSk1Menck7kT22RAjXFh3dg/OlVBLIaCqOjCaEXanX9xKTWKuHAlCmIXRUEXWpBW1FIobaTFbrpoFylSWtNkpplkUgx1Es105p6fi4l1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bs04D8Acn2cifw1j7K8SZQEMCCE+klIel1J2SykP27Z9GD5edvN/AGTZ5V8riM4AAAAASUVORK5CYII=";
449
+
450
+ // src/lib/terminal-image.ts
451
+ var ESC = "\x1B";
452
+ var ST = `${ESC}\\`;
453
+ var KITTY_QUERY_ID = 31;
454
+ var KITTY_QUERY = `${ESC}_Gi=${KITTY_QUERY_ID},s=1,v=1,a=q,t=d,f=24;AAAA${ST}`;
455
+ var BANNER_MIN_COLUMNS = 60;
456
+ var BANNER_MIN_ROWS = 17 + 2;
457
+ var BANNER_EXTRA_ROWS = 2;
458
+ var CHUNK = 4096;
459
+ var PLACEHOLDER = "\u{10EEEE}";
460
+ var DIACRITICS = [773, 781, 782, 784, 786, 829, 830, 831].map((code) => String.fromCodePoint(code));
461
+ function answersImages(response) {
462
+ const answer = response.indexOf(`${ESC}_Gi=${KITTY_QUERY_ID};OK${ST}`);
463
+ const attributes = response.search(/\x1b\[[?\d;]*c/);
464
+ return answer !== -1 && attributes !== -1 && answer < attributes;
465
+ }
466
+ function pickPiece(theme, themeKnown) {
467
+ if (!themeKnown) return { name: "icono-terminal", png: icon, columns: 6, rows: 3 };
468
+ return theme === "light" ? { name: "isotipo-terminal-claro", png: lightIsotype, columns: 8, rows: 3 } : { name: "isotipo-terminal-oscuro", png: darkIsotype, columns: 8, rows: 3 };
469
+ }
470
+ function bannerBlocker({ env, stdoutTTY, ascii, columns, rows }) {
471
+ if (!stdoutTTY) return "not-tty";
472
+ if (env["NO_COLOR"] !== void 0) return "no-color";
473
+ if (ascii) return "ascii";
474
+ if (env["TMUX"] || env["STY"] || /^(?:screen|tmux)/.test(env["TERM"] ?? "")) return "multiplexer";
475
+ if (columns < BANNER_MIN_COLUMNS) return "narrow";
476
+ if (rows < BANNER_MIN_ROWS) return "short";
477
+ return null;
478
+ }
479
+ function pickImageId(random = Math.random) {
480
+ return 16 + Math.floor(random() * 240);
481
+ }
482
+ function transmitImage(id, piece) {
483
+ const chunks = [];
484
+ for (let start = 0; start < piece.png.length; start += CHUNK) chunks.push(piece.png.slice(start, start + CHUNK));
485
+ return chunks.map((chunk, index) => {
486
+ const more = index < chunks.length - 1 ? 1 : 0;
487
+ const keys = index === 0 ? `a=T,U=1,f=100,t=d,i=${id},c=${piece.columns},r=${piece.rows},C=1,q=2,m=${more}` : `m=${more}`;
488
+ return `${ESC}_G${keys};${chunk}${ST}`;
489
+ }).join("");
490
+ }
491
+ function deleteImage(id) {
492
+ return `${ESC}_Ga=d,d=I,i=${id},q=2${ST}`;
493
+ }
494
+ function placeholderRows(id, columns, rows) {
495
+ return Array.from({ length: rows }, (_, row) => `${ESC}[38;5;${id}m${Array.from({ length: columns }, (_2, column) => PLACEHOLDER + DIACRITICS[row] + DIACRITICS[column]).join("")}${ESC}[39m`);
496
+ }
497
+
498
+ // src/lib/terminal-theme.ts
499
+ var THEME_TIMEOUT_MS = 150;
500
+ function parseTerminalTheme(colorfgbg, response = "") {
501
+ const palette = colorfgbg?.split(";").at(-1);
502
+ if (palette !== void 0 && /^\d+$/.test(palette)) return [7, 10, 11, 14, 15].includes(Number(palette)) ? "light" : "dark";
503
+ const match = response.match(/\x1b\]11;rgb:([a-f\d]+)\/([a-f\d]+)\/([a-f\d]+)(?:\x07|\x1b\\)/i);
504
+ if (!match) return "dark";
505
+ const channels = match.slice(1).map((value) => {
506
+ const c = parseInt(value, 16) / (16 ** value.length - 1);
507
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
508
+ });
509
+ return channels[0] * 0.2126 + channels[1] * 0.7152 + channels[2] * 0.0722 > 0.5 ? "light" : "dark";
510
+ }
511
+ function themeReported(colorfgbg, response = "") {
512
+ const palette = colorfgbg?.split(";").at(-1);
513
+ if (palette !== void 0 && /^\d+$/.test(palette)) return true;
514
+ return /\x1b\]11;rgb:[a-f\d]+\/[a-f\d]+\/[a-f\d]+(?:\x07|\x1b\\)/i.test(response);
515
+ }
516
+ async function probeTerminal({ input = process.stdin, output = process.stdout, interactive, env = process.env, images = false }) {
517
+ const colorfgbg = env["COLORFGBG"];
518
+ if (!interactive || !input.isTTY || !output.isTTY || !input.setRawMode) return { theme: "dark", themeKnown: false, images: false };
519
+ if (colorfgbg && !images) return { theme: parseTerminalTheme(colorfgbg), themeKnown: themeReported(colorfgbg), images: false };
520
+ const wasRaw = input.isRaw === true;
521
+ const wasPaused = input.isPaused();
522
+ input.setRawMode(true);
523
+ let response = "";
524
+ try {
525
+ await new Promise((resolve) => {
526
+ const finish = () => {
527
+ clearTimeout(timer);
528
+ input.off("data", data);
529
+ resolve();
530
+ };
531
+ const data = (chunk) => {
532
+ response += chunk.toString();
533
+ if (/\x1b\[[?\d;]*c/.test(response)) finish();
534
+ };
535
+ const timer = setTimeout(finish, THEME_TIMEOUT_MS);
536
+ input.on("data", data);
537
+ output.write((colorfgbg ? "" : "\x1B]11;?\x07") + (images ? KITTY_QUERY : "") + "\x1B[c");
538
+ });
539
+ } finally {
540
+ input.setRawMode(wasRaw);
541
+ if (wasPaused) input.pause();
542
+ }
543
+ return {
544
+ theme: parseTerminalTheme(colorfgbg, response),
545
+ themeKnown: themeReported(colorfgbg, response),
546
+ images: images && answersImages(response)
547
+ };
548
+ }
549
+
550
+ // src/lib/glyphs.ts
551
+ function shouldUseAscii(env, platform) {
552
+ if (env["TACUCHI_ASCII"] === "1") return true;
553
+ if (env["TACUCHI_ASCII"] === "0") return false;
554
+ if (env["TERM"] === "dumb") return true;
555
+ if (platform === "win32" && !env["WT_SESSION"]) return true;
556
+ return false;
557
+ }
558
+ var UNICODE = {
559
+ separator: "\xB7",
560
+ logo: "\u2582",
561
+ partial: "!",
562
+ pending: "\xB7",
563
+ scanning: "\u25CC",
564
+ outdated: "\u203A",
565
+ uptodate: "\u2713",
566
+ running: "\u25B8",
567
+ done: "\u2713",
568
+ failed: "\u2717",
569
+ skipped: "\u2298",
570
+ unknown: "?",
571
+ cursor: "\u276F",
572
+ checkOn: "[\u2713]",
573
+ checkOff: "[ ]",
574
+ arrow: "\u2192",
575
+ scrollUp: "\u25B2",
576
+ scrollDown: "\u25BC",
577
+ stepOn: "\u2586",
578
+ stepOff: "\u2581",
579
+ info: "\u24D8",
580
+ ellipsis: "\u2026",
581
+ bullet: "\u25B8",
582
+ reboot: "\u27F3"
583
+ };
584
+ var ASCII_GLYPHS = {
585
+ separator: "|",
586
+ logo: "_",
587
+ partial: "!",
588
+ pending: ".",
589
+ scanning: "o",
590
+ outdated: ">",
591
+ uptodate: "+",
592
+ running: ">",
593
+ done: "+",
594
+ failed: "x",
595
+ skipped: "-",
596
+ unknown: "?",
597
+ cursor: ">",
598
+ checkOn: "[x]",
599
+ checkOff: "[ ]",
600
+ arrow: "->",
601
+ scrollUp: "^",
602
+ scrollDown: "v",
603
+ stepOn: "#",
604
+ stepOff: "_",
605
+ info: "i",
606
+ ellipsis: "...",
607
+ bullet: ">",
608
+ reboot: "*"
609
+ };
610
+ var ASCII = shouldUseAscii(process.env, process.platform);
611
+ var g = ASCII ? ASCII_GLYPHS : UNICODE;
612
+ var NO_ANIM = ASCII || !process.stdout.isTTY;
613
+ var SPINNER_UNICODE = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
614
+ var SPINNER_ASCII = ["|", "/", "-", "\\"];
615
+ var spinnerFrames = ASCII ? SPINNER_ASCII : SPINNER_UNICODE;
616
+
617
+ // src/lib/banner.ts
618
+ var image = null;
619
+ var retired = false;
620
+ var listeners = /* @__PURE__ */ new Set();
621
+ var emit = () => {
622
+ for (const listener of listeners) listener();
623
+ };
624
+ function configureBanner(next) {
625
+ image = next;
626
+ retired = false;
627
+ emit();
628
+ }
629
+ function retireBanner() {
630
+ if (!image || retired) return false;
631
+ retired = true;
632
+ emit();
633
+ return true;
634
+ }
635
+ function subscribeBanner(listener) {
636
+ listeners.add(listener);
637
+ return () => {
638
+ listeners.delete(listener);
639
+ };
640
+ }
641
+ function bannerSnapshot() {
642
+ return retired ? null : image;
643
+ }
644
+ function shownBanner(snapshot2 = bannerSnapshot(), stdout = process.stdout, env = process.env, ascii = ASCII) {
645
+ if (!snapshot2) return null;
646
+ const blocker = bannerBlocker({ env, stdoutTTY: true, ascii, columns: Math.min(stdout.columns ?? 100, 100), rows: stdout.rows ?? 24 });
647
+ return blocker ? null : snapshot2;
648
+ }
649
+ function headerExtraRows() {
650
+ return shownBanner() ? BANNER_EXTRA_ROWS : 0;
651
+ }
652
+
3
653
  // src/cli.tsx
4
654
  import { render } from "ink";
5
655
  import { execaSync } from "execa";
6
656
 
7
657
  // src/app.tsx
8
- import { Box as Box9, Text as Text10 } from "ink";
658
+ import { useEffect as useEffect5, useState as useState7 } from "react";
659
+ import { Box as Box9 } from "ink";
9
660
 
10
661
  // src/hooks/use-app-machine.tsx
11
662
  import { createContext, useContext, useReducer, useEffect, useRef, useState, useCallback } from "react";
@@ -62,7 +713,7 @@ function allOutdatedKeys(state) {
62
713
  function appReducer(state, action) {
63
714
  switch (action.type) {
64
715
  case "BOOT_DONE":
65
- return { ...state, phase: "detecting" };
716
+ return { ...state, phase: "detecting", error: void 0 };
66
717
  case "DETECT_DONE": {
67
718
  const managers = {};
68
719
  for (const info of action.managers) managers[info.id] = newEntry(info);
@@ -132,7 +783,7 @@ function appReducer(state, action) {
132
783
  ...state,
133
784
  phase: "updating",
134
785
  managers,
135
- run: { queue: action.queue, doneCount: 0, failedCount: 0, skippedCount: 0, unknownCount: 0 }
786
+ run: { startedAt: action.at, queue: action.queue, doneCount: 0, failedCount: 0, skippedCount: 0, unknownCount: 0 }
136
787
  };
137
788
  }
138
789
  case "MGR_QUEUED":
@@ -154,8 +805,8 @@ function appReducer(state, action) {
154
805
  }));
155
806
  case "MGR_DONE":
156
807
  return {
157
- ...patch(state, action.id, (e) => ({ ...e, status: "done", percent: 100, result: action.result })),
158
- run: { ...state.run, doneCount: state.run.doneCount + 1 }
808
+ ...patch(state, action.id, (e) => ({ ...e, status: action.result.failed > 0 ? "partial" : "done", percent: 100, result: action.result })),
809
+ run: { ...state.run, doneCount: state.run.doneCount + (action.result.failed > 0 ? 0 : 1), failedCount: state.run.failedCount + (action.result.failed > 0 ? 1 : 0) }
159
810
  };
160
811
  case "MGR_FAILED":
161
812
  return {
@@ -174,8 +825,10 @@ function appReducer(state, action) {
174
825
  ...patch(state, action.id, (e) => ({ ...e, status: "unknown", percent: 100, result: action.result })),
175
826
  run: { ...state.run, unknownCount: state.run.unknownCount + 1 }
176
827
  };
828
+ case "RUN_CANCEL":
829
+ return { ...state, managers: Object.fromEntries(Object.entries(state.managers).map(([id, entry]) => [id, entry.status === "running" ? { ...entry, status: "cancelling" } : entry])) };
177
830
  case "RUN_DONE":
178
- return { ...state, phase: "summary" };
831
+ return { ...state, phase: "summary", run: { ...state.run, finishedAt: action.at } };
179
832
  case "SET_LANGUAGE":
180
833
  return { ...state, config: { ...state.config, language: action.lang } };
181
834
  case "TOGGLE_ENABLED": {
@@ -289,12 +942,17 @@ function withSudo(cmd, args2, sudo) {
289
942
  return [cmd, args2];
290
943
  }
291
944
  function tail(s, bytes) {
292
- if (!s) return "";
293
- return s.length > bytes ? s.slice(-bytes) : s;
945
+ if (Buffer.byteLength(s, "utf8") <= bytes) return s;
946
+ const encoded = Buffer.from(s, "utf8");
947
+ let start = encoded.length - bytes;
948
+ while (start < encoded.length && (encoded[start] & 192) === 128) start += 1;
949
+ return encoded.subarray(start).toString("utf8");
294
950
  }
295
951
  function execaOptions(opts, all) {
952
+ if (!Number.isFinite(opts.timeoutMs) || opts.timeoutMs < 0) {
953
+ throw new TypeError("timeoutMs must be a finite, non-negative number");
954
+ }
296
955
  return {
297
- timeout: opts.timeoutMs,
298
956
  reject: false,
299
957
  cwd: opts.cwd,
300
958
  env: opts.env,
@@ -303,11 +961,23 @@ function execaOptions(opts, all) {
303
961
  encoding: "buffer"
304
962
  };
305
963
  }
306
- function attachTreeKill(signal, child) {
307
- if (!signal) return;
964
+ function attachTreeKill(opts, child) {
965
+ const { signal } = opts;
966
+ const lifetime = {
967
+ timedOut: false,
968
+ dispose() {
969
+ clearTimeout(timer);
970
+ signal?.removeEventListener("abort", onAbort);
971
+ }
972
+ };
308
973
  const onAbort = () => killTree(child.pid);
309
- if (signal.aborted) onAbort();
310
- else signal.addEventListener("abort", onAbort, { once: true });
974
+ const timer = opts.timeoutMs === 0 ? void 0 : setTimeout(() => {
975
+ lifetime.timedOut = true;
976
+ killTree(child.pid, "SIGKILL");
977
+ }, opts.timeoutMs);
978
+ if (signal?.aborted) onAbort();
979
+ else signal?.addEventListener("abort", onAbort, { once: true });
980
+ return lifetime;
311
981
  }
312
982
  var WARN_RE = /error|fail|denied|errno|cannot|unable/i;
313
983
  async function* runStream(cmd, args2, opts, percentParser) {
@@ -315,41 +985,45 @@ async function* runStream(cmd, args2, opts, percentParser) {
315
985
  const tailBytes = opts.tailBytes ?? DEFAULT_TAIL_BYTES;
316
986
  const started = Date.now();
317
987
  const child = execa(finalCmd, finalArgs, { ...execaOptions(opts, true), stdout: "pipe", stderr: "pipe" });
318
- attachTreeKill(opts.signal, child);
319
- if (child.all) {
320
- const decoder = new StreamDecoder();
321
- let lineBuf = "";
322
- const emit = function* (raw) {
323
- const line = raw.replace(/\r$/, "");
324
- if (!line) return;
325
- const percent = percentParser?.(line);
326
- if (percent !== void 0) {
327
- yield { type: "progress", message: line, percent };
328
- } else {
329
- yield { type: "log", message: line, severity: WARN_RE.test(line) ? "warn" : "info" };
330
- }
331
- };
332
- for await (const chunk of child.all) {
333
- lineBuf += decoder.write(chunk);
334
- let nl;
335
- while ((nl = lineBuf.indexOf("\n")) >= 0) {
336
- const raw = lineBuf.slice(0, nl);
337
- lineBuf = lineBuf.slice(nl + 1);
338
- yield* emit(raw);
988
+ const lifetime = attachTreeKill(opts, child);
989
+ try {
990
+ if (child.all) {
991
+ const decoder = new StreamDecoder();
992
+ let lineBuf = "";
993
+ const emit2 = function* (raw) {
994
+ const line = raw.replace(/\r$/, "");
995
+ if (!line) return;
996
+ const percent = percentParser?.(line);
997
+ if (percent !== void 0) {
998
+ yield { type: "progress", message: line, percent };
999
+ } else {
1000
+ yield { type: "log", message: line, severity: WARN_RE.test(line) ? "warn" : "info" };
1001
+ }
1002
+ };
1003
+ for await (const chunk of child.all) {
1004
+ lineBuf += decoder.write(chunk);
1005
+ let nl;
1006
+ while ((nl = lineBuf.indexOf("\n")) >= 0) {
1007
+ const raw = lineBuf.slice(0, nl);
1008
+ lineBuf = lineBuf.slice(nl + 1);
1009
+ yield* emit2(raw);
1010
+ }
339
1011
  }
1012
+ lineBuf += decoder.end();
1013
+ if (lineBuf) yield* emit2(lineBuf);
340
1014
  }
341
- lineBuf += decoder.end();
342
- if (lineBuf) yield* emit(lineBuf);
1015
+ const result = await child;
1016
+ return {
1017
+ cmd: [finalCmd, ...finalArgs].join(" "),
1018
+ exitCode: result.exitCode ?? null,
1019
+ durationMs: Date.now() - started,
1020
+ timedOut: lifetime.timedOut,
1021
+ stdoutTail: tail(decodeSmart(result.stdout), tailBytes),
1022
+ stderrTail: tail(decodeSmart(result.stderr), tailBytes)
1023
+ };
1024
+ } finally {
1025
+ lifetime.dispose();
343
1026
  }
344
- const result = await child;
345
- return {
346
- cmd: [finalCmd, ...finalArgs].join(" "),
347
- exitCode: result.exitCode ?? null,
348
- durationMs: Date.now() - started,
349
- timedOut: result.timedOut ?? false,
350
- stdoutTail: tail(decodeSmart(result.stdout), tailBytes),
351
- stderrTail: tail(decodeSmart(result.stderr), tailBytes)
352
- };
353
1027
  }
354
1028
 
355
1029
  // src/lib/executor.ts
@@ -436,185 +1110,66 @@ function reconcile(requested, before, after, commands, successExitCodes) {
436
1110
  return {
437
1111
  name,
438
1112
  outcome: "unknown",
439
- fromVersion: b?.currentVersion,
440
- toVersion: b?.newVersion
441
- };
442
- }),
443
- commands
444
- };
445
- }
446
- const stillOutdated = new Set(after.stillOutdated.map((p) => p.name));
447
- const packages = targets.map((name) => {
448
- const b = beforeByName.get(name);
449
- if (stillOutdated.has(name)) {
450
- return {
451
- name,
452
- outcome: "failed",
453
- fromVersion: b?.currentVersion,
454
- toVersion: b?.newVersion,
455
- failureKind: cmdKind ?? "COMMAND_FAILED"
456
- };
457
- }
458
- return {
459
- name,
460
- outcome: "upgraded",
461
- fromVersion: b?.currentVersion,
462
- toVersion: b?.newVersion
463
- };
464
- });
465
- const upgraded = packages.filter((p) => p.outcome === "upgraded").length;
466
- const failed = packages.filter((p) => p.outcome === "failed").length;
467
- let status;
468
- let reason;
469
- if (targets.length === 0) {
470
- status = "noop";
471
- } else if (failed === 0) {
472
- status = "success";
473
- } else if (upgraded === 0) {
474
- status = "failed";
475
- reason = cmdKind ?? "UNKNOWN";
476
- } else {
477
- status = "partial";
478
- reason = "PARTIAL";
479
- }
480
- const errors = packages.filter((p) => p.outcome === "failed").map((p) => `${p.name}: no se pudo actualizar (${p.failureKind})`);
481
- return {
482
- success: status === "success" || status === "noop",
483
- upgraded,
484
- failed,
485
- errors,
486
- status,
487
- skipped: 0,
488
- reason,
489
- reboot: rebootFrom(commands),
490
- packages,
491
- commands
492
- };
493
- }
494
-
495
- // src/lib/logger.ts
496
- import fs3 from "fs";
497
- import path3 from "path";
498
-
499
- // src/lib/config.ts
500
- import fs from "fs";
501
- import path from "path";
502
- import os from "os";
503
- var DEFAULTS = {
504
- enabledManagers: {},
505
- verbosity: "info",
506
- language: "es",
507
- concurrency: 4,
508
- timeoutsMs: {},
509
- logTailBytes: 16384,
510
- managers: {},
511
- logRetentionRuns: 30,
512
- selfCheck: true
513
- };
514
- var MIN_CONCURRENCY = 1;
515
- var MAX_CONCURRENCY = 8;
516
- function clampConcurrency(value) {
517
- const n = typeof value === "number" && Number.isFinite(value) ? value : DEFAULTS.concurrency;
518
- return Math.max(MIN_CONCURRENCY, Math.min(MAX_CONCURRENCY, Math.round(n)));
519
- }
520
- function normalizeConfig(parsed) {
521
- return {
522
- ...DEFAULTS,
523
- ...parsed,
524
- enabledManagers: { ...DEFAULTS.enabledManagers, ...parsed.enabledManagers },
525
- timeoutsMs: { ...DEFAULTS.timeoutsMs, ...parsed.timeoutsMs },
526
- managers: { ...DEFAULTS.managers, ...parsed.managers },
527
- concurrency: clampConcurrency(parsed.concurrency),
528
- logTailBytes: typeof parsed.logTailBytes === "number" && parsed.logTailBytes > 0 ? Math.round(parsed.logTailBytes) : DEFAULTS.logTailBytes,
529
- logRetentionRuns: typeof parsed.logRetentionRuns === "number" && parsed.logRetentionRuns >= 1 ? Math.round(parsed.logRetentionRuns) : DEFAULTS.logRetentionRuns,
530
- selfCheck: typeof parsed.selfCheck === "boolean" ? parsed.selfCheck : DEFAULTS.selfCheck
531
- };
532
- }
533
- var APP = "tacuchi-updater";
534
- function windowsPaths() {
535
- const home = os.homedir();
536
- const roaming = process.env["APPDATA"] || path.join(home, "AppData", "Roaming");
537
- const local = process.env["LOCALAPPDATA"] || path.join(home, "AppData", "Local");
538
- return { config: path.join(roaming, APP, "Config"), log: path.join(local, APP, "Log") };
539
- }
540
- function getConfigDir(platform = process.platform) {
541
- const override = process.env["TACUCHI_UPDATER_CONFIG_DIR"];
542
- if (override) return override;
543
- if (platform === "win32") return windowsPaths().config;
544
- return path.join(os.homedir(), ".tacuchi-updater");
545
- }
546
- function getLogDir(platform = process.platform) {
547
- const override = process.env["TACUCHI_UPDATER_LOG_DIR"];
548
- if (override) return override;
549
- if (platform === "win32") return windowsPaths().log;
550
- return path.join(getConfigDir(platform), "logs");
551
- }
552
- function getConfigPath() {
553
- return path.join(getConfigDir(), "config.json");
554
- }
555
- function migrateLegacyConfig() {
556
- if (process.platform !== "win32") return;
557
- try {
558
- const target = getConfigPath();
559
- if (fs.existsSync(target)) return;
560
- const legacy = path.join(os.homedir(), ".tacuchi-updater", "config.json");
561
- if (!fs.existsSync(legacy)) return;
562
- const dir = getConfigDir();
563
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
564
- fs.copyFileSync(legacy, target);
565
- } catch {
566
- }
567
- }
568
- function loadConfig() {
569
- migrateLegacyConfig();
570
- const configPath = getConfigPath();
571
- try {
572
- if (!fs.existsSync(configPath)) {
573
- const defaults = { ...DEFAULTS };
574
- try {
575
- saveConfig(defaults);
576
- } catch {
577
- }
578
- return defaults;
579
- }
580
- const raw = fs.readFileSync(configPath, "utf-8");
581
- const parsed = JSON.parse(raw);
582
- return normalizeConfig(parsed);
583
- } catch {
584
- return { ...DEFAULTS };
585
- }
586
- }
587
- function saveConfig(config) {
588
- const dir = getConfigDir();
589
- if (!fs.existsSync(dir)) {
590
- fs.mkdirSync(dir, { recursive: true });
591
- }
592
- const target = getConfigPath();
593
- const tmp = target + ".tmp";
594
- const data = JSON.stringify(config, null, 2);
595
- try {
596
- fs.writeFileSync(tmp, data, "utf-8");
597
- fs.renameSync(tmp, target);
598
- } catch (err) {
599
- const code = err.code;
600
- if (code === "EPERM" || code === "EBUSY" || code === "EEXIST") {
601
- fs.writeFileSync(target, data, "utf-8");
602
- try {
603
- fs.unlinkSync(tmp);
604
- } catch {
605
- }
606
- } else {
607
- throw err;
608
- }
1113
+ fromVersion: b?.currentVersion,
1114
+ toVersion: b?.newVersion
1115
+ };
1116
+ }),
1117
+ commands
1118
+ };
609
1119
  }
610
- }
611
- function isManagerEnabled(config, managerId) {
612
- if (Object.prototype.hasOwnProperty.call(config.enabledManagers, managerId)) {
613
- return config.enabledManagers[managerId] ?? true;
1120
+ const stillOutdated = new Set(after.stillOutdated.map((p) => p.name));
1121
+ const packages = targets.map((name) => {
1122
+ const b = beforeByName.get(name);
1123
+ if (stillOutdated.has(name)) {
1124
+ return {
1125
+ name,
1126
+ outcome: "failed",
1127
+ fromVersion: b?.currentVersion,
1128
+ toVersion: b?.newVersion,
1129
+ failureKind: cmdKind ?? "COMMAND_FAILED"
1130
+ };
1131
+ }
1132
+ return {
1133
+ name,
1134
+ outcome: "upgraded",
1135
+ fromVersion: b?.currentVersion,
1136
+ toVersion: b?.newVersion
1137
+ };
1138
+ });
1139
+ const upgraded = packages.filter((p) => p.outcome === "upgraded").length;
1140
+ const failed = packages.filter((p) => p.outcome === "failed").length;
1141
+ let status;
1142
+ let reason;
1143
+ if (targets.length === 0) {
1144
+ status = "noop";
1145
+ } else if (failed === 0) {
1146
+ status = "success";
1147
+ } else if (upgraded === 0) {
1148
+ status = "failed";
1149
+ reason = cmdKind ?? "UNKNOWN";
1150
+ } else {
1151
+ status = "partial";
1152
+ reason = "PARTIAL";
614
1153
  }
615
- return true;
1154
+ const errors = packages.filter((p) => p.outcome === "failed").map((p) => `${p.name}: no se pudo actualizar (${p.failureKind})`);
1155
+ return {
1156
+ success: status === "success" || status === "noop",
1157
+ upgraded,
1158
+ failed,
1159
+ errors,
1160
+ status,
1161
+ skipped: 0,
1162
+ reason,
1163
+ reboot: rebootFrom(commands),
1164
+ packages,
1165
+ commands
1166
+ };
616
1167
  }
617
1168
 
1169
+ // src/lib/logger.ts
1170
+ import fs3 from "fs";
1171
+ import path3 from "path";
1172
+
618
1173
  // src/lib/log-retention.ts
619
1174
  import fs2 from "fs";
620
1175
  import path2 from "path";
@@ -912,7 +1467,8 @@ function fromDescriptor(d, cfg, deps = defaultDeps) {
912
1467
  platform: process.platform,
913
1468
  sudoMode: sudoMode2,
914
1469
  meta: {},
915
- signal
1470
+ signal,
1471
+ logTailBytes: cfg.logTailBytes
916
1472
  });
917
1473
  const upgradeTimeout = cfg.timeoutsMs[d.id] ?? d.defaultTimeoutMs ?? UPGRADE_TIMEOUT;
918
1474
  function sudoFor(spec, c) {
@@ -1036,12 +1592,19 @@ function fromDescriptor(d, cfg, deps = defaultDeps) {
1036
1592
  const pp = d.percentParser ? (line) => d.percentParser(line, c) : void 0;
1037
1593
  const runOne = async function* (spec) {
1038
1594
  yield { type: "log", message: `${spec.cmd} ${spec.args.join(" ")}` };
1039
- const rec = yield* deps.runStream(
1595
+ const stream = deps.runStream(
1040
1596
  spec.cmd,
1041
1597
  spec.args,
1042
- { timeoutMs: spec.timeout ?? upgradeTimeout, sudo: sudoFor(spec, c), signal: c.signal },
1598
+ { timeoutMs: spec.timeout ?? upgradeTimeout, sudo: sudoFor(spec, c), signal: c.signal, tailBytes: cfg.logTailBytes },
1043
1599
  pp
1044
1600
  );
1601
+ let item = await stream.next();
1602
+ while (!item.done) {
1603
+ const currentPackage = d.packageParser?.(item.value.message, c);
1604
+ yield currentPackage ? { ...item.value, type: "progress", package: currentPackage } : item.value;
1605
+ item = await stream.next();
1606
+ }
1607
+ const rec = item.value;
1045
1608
  commands.push(rec);
1046
1609
  logCommand(rec);
1047
1610
  };
@@ -1113,6 +1676,9 @@ function makeFractionParser(re) {
1113
1676
 
1114
1677
  // src/managers/descriptors/brew.ts
1115
1678
  var brewUpgradePercent = makeFractionParser(/Upgrading (\d+)\/(\d+)/);
1679
+ function parseBrewPackage(line) {
1680
+ return line.match(/^==> (?:Upgrading|Installing) ([a-zA-Z][\w@./+-]*)(?:\s|$)/)?.[1];
1681
+ }
1116
1682
  function parseBrewOutdated(stdout) {
1117
1683
  try {
1118
1684
  const data = JSON.parse(stdout);
@@ -1141,7 +1707,8 @@ var brew = {
1141
1707
  preUpgradeCmds: () => [{ cmd: "brew", args: ["update"] }],
1142
1708
  upgradeCmd: (pkgs) => ({ cmd: "brew", args: pkgs && pkgs.length ? ["upgrade", ...pkgs] : ["upgrade"] }),
1143
1709
  postUpgradeCmds: () => [{ cmd: "brew", args: ["cleanup"] }],
1144
- percentParser: (line) => brewUpgradePercent(line)
1710
+ percentParser: (line) => brewUpgradePercent(line),
1711
+ packageParser: parseBrewPackage
1145
1712
  };
1146
1713
 
1147
1714
  // src/lib/exec/capabilities.ts
@@ -1165,8 +1732,8 @@ async function pythonModuleCmd() {
1165
1732
  return once("pip:python", async () => {
1166
1733
  const candidates = process.platform === "win32" ? ["python", "py", "python3"] : ["python3", "python"];
1167
1734
  for (const c of candidates) {
1168
- const probe = await execCommand(c, ["-m", "pip", "--version"], 5e3);
1169
- if (probe.exitCode === 0) return c;
1735
+ const probe2 = await execCommand(c, ["-m", "pip", "--version"], 5e3);
1736
+ if (probe2.exitCode === 0) return c;
1170
1737
  }
1171
1738
  return null;
1172
1739
  });
@@ -1185,8 +1752,8 @@ function parsePipOutdated(stdout) {
1185
1752
  async function pep668Flags() {
1186
1753
  return once("pip:pep668", async () => {
1187
1754
  const { cmd, baseArgs } = await resolvedInvocation();
1188
- const probe = await execCommand(cmd, [...baseArgs, "install", "--user", "--dry-run", "pip"], 5e3);
1189
- const managed = (probe.stdout + probe.stderr).includes("externally-managed");
1755
+ const probe2 = await execCommand(cmd, [...baseArgs, "install", "--user", "--dry-run", "pip"], 5e3);
1756
+ const managed = (probe2.stdout + probe2.stderr).includes("externally-managed");
1190
1757
  return managed ? ["--break-system-packages"] : [];
1191
1758
  });
1192
1759
  }
@@ -1221,7 +1788,7 @@ var pip = {
1221
1788
  if (target.length) {
1222
1789
  const args2 = [...baseArgs, "install", "--user", "--upgrade", ...flags, ...target];
1223
1790
  yield { type: "log", message: `${cmd} ${args2.join(" ")}` };
1224
- const rec = yield* runStream(cmd, args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
1791
+ const rec = yield* runStream(cmd, args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
1225
1792
  commands.push(rec);
1226
1793
  logCommand(rec);
1227
1794
  }
@@ -1361,7 +1928,7 @@ var gem = {
1361
1928
  if (target.length) {
1362
1929
  const args2 = updateArgs(target, useSudo);
1363
1930
  yield { type: "log", message: `${useSudo ? "sudo " : ""}gem ${args2.join(" ")}` };
1364
- const rec = yield* runStream("gem", args2, { timeoutMs: 3e5, sudo: useSudo, signal: ctx.signal });
1931
+ const rec = yield* runStream("gem", args2, { timeoutMs: 3e5, sudo: useSudo, signal: ctx.signal, tailBytes: ctx.logTailBytes });
1365
1932
  commands.push(rec);
1366
1933
  logCommand(rec);
1367
1934
  }
@@ -1462,7 +2029,7 @@ var winget = {
1462
2029
  const commands = [];
1463
2030
  const run = async function* (args2) {
1464
2031
  yield { type: "log", message: `winget ${args2.join(" ")}` };
1465
- const rec = yield* runStream("winget", args2, { timeoutMs: 6e5, sudo: false, signal: ctx.signal });
2032
+ const rec = yield* runStream("winget", args2, { timeoutMs: 6e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
1466
2033
  commands.push(rec);
1467
2034
  logCommand(rec);
1468
2035
  };
@@ -1664,7 +2231,7 @@ async function currentVersion() {
1664
2231
  async function latestStable(platform) {
1665
2232
  return once(`flutter:latest:${platformKey(platform)}`, async () => {
1666
2233
  try {
1667
- const resp = await fetch(releasesUrl(platform));
2234
+ const resp = await fetch(releasesUrl(platform), { signal: AbortSignal.timeout(1e4) });
1668
2235
  if (!resp.ok) return void 0;
1669
2236
  return findLatestStable(await resp.text());
1670
2237
  } catch {
@@ -1708,7 +2275,7 @@ var flutter = {
1708
2275
  if (before.length) {
1709
2276
  const args2 = ["upgrade", "--force"];
1710
2277
  yield { type: "log", message: `flutter ${args2.join(" ")}` };
1711
- const rec = yield* runStream("flutter", args2, { timeoutMs: 6e5, sudo: false, signal: ctx.signal });
2278
+ const rec = yield* runStream("flutter", args2, { timeoutMs: 6e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
1712
2279
  commands.push(rec);
1713
2280
  logCommand(rec);
1714
2281
  }
@@ -1772,7 +2339,7 @@ var angular = {
1772
2339
  if (target.length) {
1773
2340
  const args2 = ["install", "-g", `${PACKAGE}@latest`];
1774
2341
  yield { type: "log", message: `npm ${args2.join(" ")}` };
1775
- const rec = yield* runStream("npm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
2342
+ const rec = yield* runStream("npm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
1776
2343
  commands.push(rec);
1777
2344
  logCommand(rec);
1778
2345
  }
@@ -1901,7 +2468,7 @@ var goLang = {
1901
2468
  const commands = [];
1902
2469
  const args2 = ["upgrade", "go"];
1903
2470
  yield { type: "log", message: `brew ${args2.join(" ")}` };
1904
- const rec = yield* runStream("brew", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
2471
+ const rec = yield* runStream("brew", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
1905
2472
  commands.push(rec);
1906
2473
  logCommand(rec);
1907
2474
  yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
@@ -2057,7 +2624,7 @@ var pnpm = {
2057
2624
  if (target.length) {
2058
2625
  const args2 = packages && packages.length ? ["update", "-g", ...packages] : ["update", "-g"];
2059
2626
  yield { type: "log", message: `pnpm ${args2.join(" ")}` };
2060
- const rec = yield* runStream("pnpm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
2627
+ const rec = yield* runStream("pnpm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
2061
2628
  commands.push(rec);
2062
2629
  logCommand(rec);
2063
2630
  }
@@ -2160,7 +2727,7 @@ var yarn = {
2160
2727
  if (target.length) {
2161
2728
  const args2 = packages && packages.length ? ["global", "upgrade", ...packages] : ["global", "upgrade"];
2162
2729
  yield { type: "log", message: `yarn ${args2.join(" ")}` };
2163
- const rec = yield* runStream("yarn", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
2730
+ const rec = yield* runStream("yarn", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
2164
2731
  commands.push(rec);
2165
2732
  logCommand(rec);
2166
2733
  }
@@ -2217,7 +2784,7 @@ var bun = {
2217
2784
  const commands = [];
2218
2785
  const args2 = packages && packages.length ? ["update", "-g", ...packages] : ["update", "-g"];
2219
2786
  yield { type: "log", message: `bun ${args2.join(" ")}` };
2220
- const rec = yield* runStream("bun", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
2787
+ const rec = yield* runStream("bun", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
2221
2788
  commands.push(rec);
2222
2789
  logCommand(rec);
2223
2790
  yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
@@ -2253,8 +2820,8 @@ function parseMiseOutdated(stdout) {
2253
2820
  bodyStart = headerIdx + 1;
2254
2821
  }
2255
2822
  const norm = (v) => {
2256
- const t3 = v?.trim();
2257
- return t3 && t3 !== "-" ? t3 : "?";
2823
+ const t2 = v?.trim();
2824
+ return t2 && t2 !== "-" ? t2 : "?";
2258
2825
  };
2259
2826
  return lines.slice(bodyStart).map((line) => {
2260
2827
  const cols = line.trim().split(/\s+/);
@@ -2533,7 +3100,7 @@ var pipx = {
2533
3100
  if (before.length) {
2534
3101
  const args2 = ["upgrade-all"];
2535
3102
  yield { type: "log", message: `pipx ${args2.join(" ")}` };
2536
- const rec = yield* runStream("pipx", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
3103
+ const rec = yield* runStream("pipx", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal, tailBytes: ctx.logTailBytes });
2537
3104
  commands.push(rec);
2538
3105
  logCommand(rec);
2539
3106
  }
@@ -2653,472 +3220,23 @@ async function pool(items, limit, worker) {
2653
3220
  await worker(item);
2654
3221
  }
2655
3222
  };
2656
- const lanes = Math.max(1, Math.min(limit, items.length));
2657
- await Promise.all(Array.from({ length: lanes }, () => run()));
2658
- }
2659
- async function runEngine(tasks, opts) {
2660
- const results = new Array(tasks.length);
2661
- const indexed = tasks.map((task, index) => ({ task, index }));
2662
- const adminLane = indexed.filter((t3) => t3.task.manager.requiresAdmin);
2663
- const fastLane = indexed.filter((t3) => !t3.task.manager.requiresAdmin);
2664
- await Promise.all([
2665
- pool(fastLane, opts.concurrency, async ({ task, index }) => {
2666
- results[index] = await runTask(task, opts);
2667
- }),
2668
- pool(adminLane, 1, async ({ task, index }) => {
2669
- results[index] = await runTask(task, opts);
2670
- })
2671
- ]);
2672
- return results;
2673
- }
2674
-
2675
- // src/i18n/es.ts
2676
- var es = {
2677
- // Navegación
2678
- nav: {
2679
- title: "KINETIC_PKG_MGR",
2680
- dashboard: "PANEL",
2681
- packages: "PAQUETES",
2682
- registry: "REGISTRO",
2683
- settings: "AJUSTES",
2684
- version: "v1.0.0"
2685
- },
2686
- // Teclas de acción (barra inferior)
2687
- keys: {
2688
- quit: "[Q] SALIR",
2689
- help: "[?] AYUDA",
2690
- next: "[TAB] SIGUIENTE",
2691
- exec: "[ENTER] EJECUTAR",
2692
- back: "[ESC] VOLVER",
2693
- select: "[ESPACIO] SELECCIONAR",
2694
- update: "[U] ACTUALIZAR",
2695
- sync: "[S] SINCRONIZAR",
2696
- logView: "[F1] VER LOG"
2697
- },
2698
- // Panel principal (Dashboard)
2699
- dashboard: {
2700
- title: "PANEL_",
2701
- status: "ESTADO: ENTORNO ACTIVO",
2702
- totalUpdates: "TOTAL ACTUALIZACIONES",
2703
- systemLoad: "CARGA DEL SISTEMA",
2704
- systemInfo: "INFO_SISTEMA",
2705
- os: "SO",
2706
- kernel: "KERNEL",
2707
- uptime: "ACTIVO",
2708
- lastScan: "\xDALTIMO ESCANEO",
2709
- terminalLog: "TERMINAL_LOG",
2710
- noManagers: "No se detectaron gestores de paquetes",
2711
- scanning: "Escaneando...",
2712
- active: "ACTIVO",
2713
- degraded: "DEGRADADO",
2714
- available: "DISPONIBLE"
2715
- },
2716
- // Actualizaciones activas
2717
- activeUpdates: {
2718
- title: "ACTUALIZACIONES_ACTIVAS",
2719
- syncing: "\u25CF SINCRONIZANDO...",
2720
- stdout: "STDOUT \u2014 SESI\xD3N",
2721
- active: "ACTIVO",
2722
- success: "EXITOSO",
2723
- errors: "ERRORES",
2724
- pending: "[PENDIENTE]",
2725
- ok: "[OK]",
2726
- err: "[ERR]",
2727
- noActive: "No hay actualizaciones en curso",
2728
- goToPackages: "Ve a PAQUETES para iniciar una actualizaci\xF3n",
2729
- verifying: "VERIFICANDO_SUMA...",
2730
- retrying: "REINTENTANDO_EN_5S",
2731
- upgraded: "actualizado(s)",
2732
- failed: "fallido(s)",
2733
- noChanges: "Sin cambios",
2734
- allDone: "\u25CF COMPLETADO",
2735
- rescanHint: "Re-escanear actualizaciones disponibles"
2736
- },
2737
- // Sincronización de paquetes
2738
- packageSync: {
2739
- title: "SYNC_PAQUETES.",
2740
- diskUsage: "USO DE DISCO",
2741
- queueSize: "COLA",
2742
- pending: "OPERACIONES_PENDIENTES",
2743
- colSel: "SEL",
2744
- colManager: "GESTOR",
2745
- colPackage: "PAQUETE",
2746
- colVersion: "VERSION",
2747
- colNew: "NUEVA",
2748
- colSize: "TAMA\xD1O",
2749
- hint: "\u203A Presiona [ESPACIO] para seleccionar, [U] para Actualizar Seleccionados",
2750
- eligible: "paquetes elegibles para actualizar",
2751
- systemState: "ESTADO DEL SISTEMA",
2752
- noUpdates: "El sistema est\xE1 actualizado",
2753
- requiresAdmin: "REQUIERE ADMIN",
2754
- manualCmd: "Comando manual:"
2755
- },
2756
- // Ajustes
2757
- settings: {
2758
- title: "CONFIGURACI\xD3N_DEL_SISTEMA",
2759
- subtitle: "KINETIC::PKG::AJUSTES",
2760
- nav: {
2761
- general: "General",
2762
- sources: "Fuentes",
2763
- automation: "Automatizaci\xF3n",
2764
- networking: "Red",
2765
- advanced: "Avanzado"
2766
- },
2767
- activeManagers: "[01] GESTORES DE PAQUETES ACTIVOS",
2768
- automation: "[02] AUTOMATIZACI\xD3N Y LOGS",
2769
- autoScanInterval: "INTERVALO_AUTO_ESCANEO",
2770
- autoScanDesc: "Tiempo entre escaneos autom\xE1ticos.",
2771
- verbosity: "NIVEL_VERBOSIDAD",
2772
- verbosityDesc: "Controla la cantidad de datos guardados en logs.",
2773
- notifications: "NOTIFICACIONES",
2774
- desktopAlerts: "ALERTAS DE ESCRITORIO",
2775
- terminalBell: "CAMPANILLA",
2776
- telemetry: "TELEMETR\xCDA",
2777
- anonymousData: "DATOS AN\xD3NIMOS",
2778
- anonymousDesc: "Comparte datos de uso para mejorar la herramienta.",
2779
- language: "IDIOMA",
2780
- statusSynced: "Configuraci\xF3n sincronizada con archivo local.",
2781
- stable: "ESTABLE",
2782
- detected: "DETECTADO",
2783
- notFound: "NO ENCONTRADO",
2784
- on: "[ ON ]",
2785
- off: "[OFF]",
2786
- seconds: "SEGUNDOS"
2787
- },
2788
- // Estados comunes
2789
- states: {
2790
- loading: "Cargando...",
2791
- error: "Error",
2792
- success: "Exitoso",
2793
- warning: "Advertencia",
2794
- notFound: "No encontrado",
2795
- available: "Disponible",
2796
- unavailable: "No disponible",
2797
- requiresAdmin: "Requiere admin",
2798
- minutesAgo: "hace %d min",
2799
- justNow: "ahora mismo",
2800
- never: "nunca"
2801
- },
2802
- // Managers
2803
- managers: {
2804
- brew: "Homebrew",
2805
- pip: "pip / Python",
2806
- npm: "Node NPM",
2807
- conda: "Conda",
2808
- gem: "RubyGems",
2809
- softwareupdate: "macOS Updates",
2810
- winget: "Winget",
2811
- apt: "APT / Debian",
2812
- dnf: "DNF / Fedora",
2813
- pacman: "Pacman / Arch",
2814
- flatpak: "Flatpak",
2815
- snap: "Snap",
2816
- flutter: "Flutter SDK",
2817
- angular: "Angular CLI",
2818
- cargo: "Cargo binarios",
2819
- "go-lang": "Go SDK",
2820
- composer: "Composer / PHP",
2821
- choco: "Chocolatey",
2822
- pnpm: "pnpm",
2823
- yarn: "Yarn",
2824
- bun: "Bun",
2825
- mise: "mise",
2826
- asdf: "asdf",
2827
- rustup: "Rust / rustup",
2828
- mas: "Mac App Store",
2829
- scoop: "Scoop",
2830
- pipx: "pipx"
2831
- },
2832
- // Verbosidad
2833
- verbosity: {
2834
- silent: "SILENCIO",
2835
- info: "NORMAL",
2836
- debug: "DEBUG",
2837
- trace: "DETALLADO"
2838
- },
2839
- // Flujo lineal — etiquetas de fase/paso
2840
- flow: {
2841
- step: "Paso",
2842
- detecting: "Detectando gestores",
2843
- scanning: "Buscando actualizaciones",
2844
- select: "Seleccionar",
2845
- confirm: "Confirmar",
2846
- updating: "Actualizando",
2847
- summary: "Resumen",
2848
- detail: "Detalle por paquete",
2849
- settings: "Ajustes"
2850
- },
2851
- // Etiquetas de estado por-gestor (ManagerStatus)
2852
- status: {
2853
- pending: "PENDIENTE",
2854
- scanning: "ESCANEANDO",
2855
- outdated: "DISPONIBLE",
2856
- uptodate: "AL D\xCDA",
2857
- queued: "EN COLA",
2858
- running: "ACTUALIZANDO",
2859
- done: "OK",
2860
- failed: "ERROR",
2861
- skipped: "MANUAL",
2862
- unknown: "INDETERMINADO"
2863
- },
2864
- // Cadenas de la interfaz del flujo
2865
- ui: {
2866
- detecting: "Detectando gestores de paquetes...",
2867
- scanning: "Buscando actualizaciones...",
2868
- noUpdates: "Todo est\xE1 al d\xEDa. No hay actualizaciones.",
2869
- selected: "seleccionados",
2870
- willRun: "Se ejecutar\xE1:",
2871
- upgraded: "actualizados",
2872
- failed: "fallidos",
2873
- skipped: "omitidos (manual)",
2874
- allDone: "COMPLETADO",
2875
- withErrors: "COMPLETADO CON ERRORES",
2876
- logAt: "Registro completo en:",
2877
- manualNeeded: "Requiere ejecuci\xF3n manual:",
2878
- selectHint: "Espacio marcar \xB7 A todos \xB7 N ninguno \xB7 Enter continuar \xB7 S ajustes \xB7 Q salir",
2879
- confirmHint: "Enter actualizar \xB7 Esc volver \xB7 Q salir",
2880
- updatingHint: "Esc cancelar",
2881
- passwordNote: 'Si aparece "Password:" abajo, es un gestor (p.ej. un cask de brew): escr\xEDbela y Enter.',
2882
- summaryHint: "R re-escanear \xB7 Q salir",
2883
- elapsed: "transcurrido",
2884
- cancel: "Cancelando...",
2885
- undetermined: "no se pudo determinar",
2886
- undeterminedCount: "no se pudieron determinar",
2887
- undeterminedTotal: "indeterminados",
2888
- detailHint: "D detalle \xB7 R re-escanear \xB7 Q salir",
2889
- detailBack: "\u2191\u2193 recorrer \xB7 D volver al resumen \xB7 Q salir",
2890
- noChanges: "Ninguna corrida cambi\xF3 paquetes."
2891
- }
2892
- };
2893
-
2894
- // src/i18n/en.ts
2895
- var en = {
2896
- nav: {
2897
- title: "KINETIC_PKG_MGR",
2898
- dashboard: "DASHBOARD",
2899
- packages: "PACKAGES",
2900
- registry: "REGISTRY",
2901
- settings: "SETTINGS",
2902
- version: "v1.0.0"
2903
- },
2904
- keys: {
2905
- quit: "[Q] QUIT",
2906
- help: "[?] HELP",
2907
- next: "[TAB] NEXT",
2908
- exec: "[ENTER] EXEC",
2909
- back: "[ESC] BACK",
2910
- select: "[SPACE] SELECT",
2911
- update: "[U] UPDATE",
2912
- sync: "[S] SYNC",
2913
- logView: "[F1] LOG VIEW"
2914
- },
2915
- dashboard: {
2916
- title: "DASHBOARD_",
2917
- status: "STATUS: ACTIVE ENVIRONMENT",
2918
- totalUpdates: "TOTAL UPDATES",
2919
- systemLoad: "SYSTEM LOAD",
2920
- systemInfo: "SYSTEM_INFO",
2921
- os: "OS",
2922
- kernel: "KERNEL",
2923
- uptime: "UPTIME",
2924
- lastScan: "LAST SCAN",
2925
- terminalLog: "TERMINAL_LOG",
2926
- noManagers: "No package managers detected",
2927
- scanning: "Scanning...",
2928
- active: "ACTIVE",
2929
- degraded: "DEGRADED",
2930
- available: "AVAILABLE"
2931
- },
2932
- activeUpdates: {
2933
- title: "ACTIVE_UPDATES",
2934
- syncing: "\u25CF SYNCING_REPOS...",
2935
- stdout: "STDOUT \u2014 SESSION",
2936
- active: "ACTIVE",
2937
- success: "SUCCESS",
2938
- errors: "ERRORS",
2939
- pending: "[PENDING]",
2940
- ok: "[OK]",
2941
- err: "[ERR]",
2942
- noActive: "No active updates",
2943
- goToPackages: "Go to PACKAGES to start an update",
2944
- verifying: "VERIFYING_CHECKSUM...",
2945
- retrying: "RETRYING_IN_5S",
2946
- upgraded: "upgraded",
2947
- failed: "failed",
2948
- noChanges: "No changes",
2949
- allDone: "\u25CF COMPLETED",
2950
- rescanHint: "Re-scan for available updates"
2951
- },
2952
- packageSync: {
2953
- title: "PACKAGE_SYNC.",
2954
- diskUsage: "DISK USAGE",
2955
- queueSize: "QUEUE SIZE",
2956
- pending: "PENDING_OPERATIONS",
2957
- colSel: "SEL",
2958
- colManager: "MANAGER",
2959
- colPackage: "PACKAGE",
2960
- colVersion: "VERSION",
2961
- colNew: "NEW",
2962
- colSize: "SIZE",
2963
- hint: "\u203A Press [SPACE] to select, [U] to Update Selected",
2964
- eligible: "packages eligible for update",
2965
- systemState: "SYSTEM STATE",
2966
- noUpdates: "System is up to date",
2967
- requiresAdmin: "REQUIRES ADMIN",
2968
- manualCmd: "Manual command:"
2969
- },
2970
- settings: {
2971
- title: "SYSTEM_CONFIGURATION",
2972
- subtitle: "KINETIC::PKG::SETTINGS",
2973
- nav: {
2974
- general: "General",
2975
- sources: "Sources",
2976
- automation: "Automation",
2977
- networking: "Networking",
2978
- advanced: "Advanced"
2979
- },
2980
- activeManagers: "[01] ACTIVE PACKAGE MANAGERS",
2981
- automation: "[02] AUTOMATION & LOGGING",
2982
- autoScanInterval: "AUTO_SCAN_INTERVAL",
2983
- autoScanDesc: "Time between automatic global package scans.",
2984
- verbosity: "VERBOSITY_LEVEL",
2985
- verbosityDesc: "Controls the amount of data saved to logs.",
2986
- notifications: "NOTIFICATIONS",
2987
- desktopAlerts: "DESKTOP ALERTS",
2988
- terminalBell: "TERMINAL BELL",
2989
- telemetry: "TELEMETRY",
2990
- anonymousData: "ANONYMOUS DATA",
2991
- anonymousDesc: "Share usage data to improve kinetic tools.",
2992
- language: "LANGUAGE",
2993
- statusSynced: "Configuration is currently synced with local yaml file.",
2994
- stable: "STABLE",
2995
- detected: "DETECTED",
2996
- notFound: "NOT FOUND",
2997
- on: "[ ON ]",
2998
- off: "[OFF]",
2999
- seconds: "SECONDS"
3000
- },
3001
- states: {
3002
- loading: "Loading...",
3003
- error: "Error",
3004
- success: "Success",
3005
- warning: "Warning",
3006
- notFound: "Not found",
3007
- available: "Available",
3008
- unavailable: "Unavailable",
3009
- requiresAdmin: "Requires admin",
3010
- minutesAgo: "%d mins ago",
3011
- justNow: "just now",
3012
- never: "never"
3013
- },
3014
- managers: {
3015
- brew: "Homebrew",
3016
- pip: "pip / Python",
3017
- npm: "Node NPM",
3018
- conda: "Conda",
3019
- gem: "RubyGems",
3020
- softwareupdate: "macOS Updates",
3021
- winget: "Winget",
3022
- apt: "APT / Debian",
3023
- dnf: "DNF / Fedora",
3024
- pacman: "Pacman / Arch",
3025
- flatpak: "Flatpak",
3026
- snap: "Snap",
3027
- flutter: "Flutter SDK",
3028
- angular: "Angular CLI",
3029
- cargo: "Cargo binaries",
3030
- "go-lang": "Go SDK",
3031
- composer: "Composer / PHP",
3032
- choco: "Chocolatey",
3033
- pnpm: "pnpm",
3034
- yarn: "Yarn",
3035
- bun: "Bun",
3036
- mise: "mise",
3037
- asdf: "asdf",
3038
- rustup: "Rust / rustup",
3039
- mas: "Mac App Store",
3040
- scoop: "Scoop",
3041
- pipx: "pipx"
3042
- },
3043
- verbosity: {
3044
- silent: "SILENT",
3045
- info: "NORMAL",
3046
- debug: "DEBUG",
3047
- trace: "TRACE"
3048
- },
3049
- flow: {
3050
- step: "Step",
3051
- detecting: "Detecting managers",
3052
- scanning: "Checking for updates",
3053
- select: "Select",
3054
- confirm: "Confirm",
3055
- updating: "Updating",
3056
- summary: "Summary",
3057
- detail: "Per-package detail",
3058
- settings: "Settings"
3059
- },
3060
- status: {
3061
- pending: "PENDING",
3062
- scanning: "SCANNING",
3063
- outdated: "AVAILABLE",
3064
- uptodate: "UP TO DATE",
3065
- queued: "QUEUED",
3066
- running: "UPDATING",
3067
- done: "OK",
3068
- failed: "ERROR",
3069
- skipped: "MANUAL",
3070
- unknown: "UNDETERMINED"
3071
- },
3072
- ui: {
3073
- detecting: "Detecting package managers...",
3074
- scanning: "Checking for updates...",
3075
- noUpdates: "Everything is up to date. No updates.",
3076
- selected: "selected",
3077
- willRun: "Will run:",
3078
- upgraded: "upgraded",
3079
- failed: "failed",
3080
- skipped: "skipped (manual)",
3081
- allDone: "DONE",
3082
- withErrors: "DONE WITH ERRORS",
3083
- logAt: "Full log at:",
3084
- manualNeeded: "Manual command needed:",
3085
- selectHint: "Space toggle \xB7 A all \xB7 N none \xB7 Enter continue \xB7 S settings \xB7 Q quit",
3086
- confirmHint: "Enter update \xB7 Esc back \xB7 Q quit",
3087
- updatingHint: "Esc cancel",
3088
- passwordNote: 'If a "Password:" prompt appears below, it is a manager (e.g. a brew cask): type it and Enter.',
3089
- summaryHint: "R rescan \xB7 Q quit",
3090
- elapsed: "elapsed",
3091
- cancel: "Cancelling...",
3092
- undetermined: "could not be determined",
3093
- undeterminedCount: "could not be determined",
3094
- undeterminedTotal: "undetermined",
3095
- detailHint: "D detail \xB7 R rescan \xB7 Q quit",
3096
- detailBack: "\u2191\u2193 scroll \xB7 D back to summary \xB7 Q quit",
3097
- noChanges: "No run changed any package."
3098
- }
3099
- };
3100
-
3101
- // src/i18n/index.ts
3102
- var currentLang = detectLanguage();
3103
- function detectLanguage() {
3104
- const lang = (process.env["LANG"] ?? process.env["LANGUAGE"] ?? "").toLowerCase();
3105
- if (lang.startsWith("en")) return "en";
3106
- return "es";
3107
- }
3108
- function setLanguage(lang) {
3109
- currentLang = lang;
3110
- }
3111
- var translations = { es, en };
3112
- function t(section, key) {
3113
- const dict = translations[currentLang] ?? es;
3114
- const sec = dict[section];
3115
- if (key === void 0) return sec;
3116
- return sec[key];
3223
+ const lanes = Math.max(1, Math.min(limit, items.length));
3224
+ await Promise.all(Array.from({ length: lanes }, () => run()));
3117
3225
  }
3118
- function managerName(id) {
3119
- const dict = translations[currentLang] ?? es;
3120
- const names = dict.managers;
3121
- return names[id] ?? id;
3226
+ async function runEngine(tasks, opts) {
3227
+ const results = new Array(tasks.length);
3228
+ const indexed = tasks.map((task, index) => ({ task, index }));
3229
+ const adminLane = indexed.filter((t2) => t2.task.manager.requiresAdmin);
3230
+ const fastLane = indexed.filter((t2) => !t2.task.manager.requiresAdmin);
3231
+ await Promise.all([
3232
+ pool(fastLane, opts.concurrency, async ({ task, index }) => {
3233
+ results[index] = await runTask(task, opts);
3234
+ }),
3235
+ pool(adminLane, 1, async ({ task, index }) => {
3236
+ results[index] = await runTask(task, opts);
3237
+ })
3238
+ ]);
3239
+ return results;
3122
3240
  }
3123
3241
 
3124
3242
  // src/hooks/use-app-machine.tsx
@@ -3364,11 +3482,10 @@ function useMachine() {
3364
3482
  }
3365
3483
  function useAppMachine(sudoMode2, nonInteractive2 = false) {
3366
3484
  const configRef = useRef(loadConfig());
3367
- const [state, dispatch] = useReducer(
3368
- appReducer,
3369
- void 0,
3370
- () => initialState(configRef.current, sudoMode2)
3371
- );
3485
+ const [state, dispatch] = useReducer(appReducer, void 0, () => {
3486
+ setLanguage(configRef.current.language);
3487
+ return initialState(configRef.current, sudoMode2);
3488
+ });
3372
3489
  const detectedRef = useRef([]);
3373
3490
  const abortRef = useRef(null);
3374
3491
  const runLogRef = useRef(null);
@@ -3443,7 +3560,7 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3443
3560
  }
3444
3561
  const tasks = detectedRef.current.filter((dm) => packagesByManager.has(dm.manager.id)).map((dm) => ({ manager: dm.manager, op: "upgrade", packages: packagesByManager.get(dm.manager.id) }));
3445
3562
  if (tasks.length === 0) return;
3446
- const queue = tasks.map((t3) => t3.manager.id);
3563
+ const queue = tasks.map((t2) => t2.manager.id);
3447
3564
  logSelection({
3448
3565
  offered: state.order.reduce((n, id) => n + (state.managers[id]?.outdated.length ?? 0), 0),
3449
3566
  chosen: state.selection.size,
@@ -3453,7 +3570,7 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3453
3570
  chosen: packagesByManager.get(id)?.length ?? 0
3454
3571
  }))
3455
3572
  });
3456
- dispatch({ type: "RUN_START", queue });
3573
+ dispatch({ type: "RUN_START", queue, at: Date.now() });
3457
3574
  const ac = new AbortController();
3458
3575
  abortRef.current = ac;
3459
3576
  const logRef = getLogFilePath() ?? void 0;
@@ -3510,8 +3627,8 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3510
3627
  if (e.phase === "queued") {
3511
3628
  enqueue({ type: "MGR_QUEUED", id });
3512
3629
  } else if (e.phase === "upgrading") {
3513
- if (e.event?.percent !== void 0) {
3514
- enqueue({ type: "MGR_PROGRESS", id, percent: e.event.percent });
3630
+ if (e.event?.percent !== void 0 || e.event?.package !== void 0) {
3631
+ enqueue({ type: "MGR_PROGRESS", id, percent: e.event.percent, currentPackage: e.event.package });
3515
3632
  } else if (!e.event) {
3516
3633
  enqueue({ type: "MGR_RUNNING", id, at: Date.now() });
3517
3634
  }
@@ -3543,7 +3660,7 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3543
3660
  error(`El motor termin\xF3 con error: ${String(err)}`);
3544
3661
  }).finally(() => {
3545
3662
  flush();
3546
- dispatch({ type: "RUN_DONE" });
3663
+ dispatch({ type: "RUN_DONE", at: Date.now() });
3547
3664
  abortRef.current = null;
3548
3665
  if (ac.signal.aborted) settleRun("cancelada", "corrida abortada en vuelo");
3549
3666
  else if (engineError !== null) settleRun("fallida", `motor: ${String(engineError)}`);
@@ -3551,6 +3668,7 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3551
3668
  });
3552
3669
  }, [state.selection, sudoMode2]);
3553
3670
  const cancelRun = useCallback(() => {
3671
+ dispatch({ type: "RUN_CANCEL" });
3554
3672
  abortRef.current?.abort();
3555
3673
  }, []);
3556
3674
  const rescan = useCallback(() => {
@@ -3558,7 +3676,11 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3558
3676
  dispatch({ type: "RESCAN" });
3559
3677
  void boot();
3560
3678
  }, [boot]);
3561
- const { exit } = useApp();
3679
+ const { exit: inkExit } = useApp();
3680
+ const exit = useCallback(() => {
3681
+ if (retireBanner()) setImmediate(inkExit);
3682
+ else inkExit();
3683
+ }, [inkExit]);
3562
3684
  const exitedRef = useRef(false);
3563
3685
  const finishNonInteractive = useCallback(
3564
3686
  (code) => {
@@ -3568,14 +3690,18 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3568
3690
  settleRun("completa");
3569
3691
  exit();
3570
3692
  if (!process.env["VITEST"]) {
3571
- const t3 = setTimeout(() => process.exit(code), 100);
3572
- t3.unref?.();
3693
+ const t2 = setTimeout(() => process.exit(code), 100);
3694
+ t2.unref?.();
3573
3695
  }
3574
3696
  },
3575
3697
  [exit]
3576
3698
  );
3577
3699
  useEffect(() => {
3578
3700
  if (!nonInteractive2) return;
3701
+ if (state.error) {
3702
+ finishNonInteractive(1);
3703
+ return;
3704
+ }
3579
3705
  if (state.phase === "select") {
3580
3706
  const hasOutdated = state.order.some((id) => (state.managers[id]?.outdated.length ?? 0) > 0);
3581
3707
  if (!hasOutdated) finishNonInteractive(0);
@@ -3589,6 +3715,7 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3589
3715
  }, [
3590
3716
  nonInteractive2,
3591
3717
  state.phase,
3718
+ state.error,
3592
3719
  state.selection.size,
3593
3720
  state.run.failedCount,
3594
3721
  state.order,
@@ -3613,8 +3740,8 @@ function useAppMachine(sudoMode2, nonInteractive2 = false) {
3613
3740
  settleRun("cedida", "consola elevada");
3614
3741
  exit();
3615
3742
  if (!process.env["VITEST"]) {
3616
- const t3 = setTimeout(() => process.exit(0), 100);
3617
- t3.unref?.();
3743
+ const t2 = setTimeout(() => process.exit(0), 100);
3744
+ t2.unref?.();
3618
3745
  }
3619
3746
  }
3620
3747
  })();
@@ -3672,238 +3799,163 @@ function MachineProvider({ value, children }) {
3672
3799
  return /* @__PURE__ */ jsx(MachineContext.Provider, { value, children });
3673
3800
  }
3674
3801
 
3802
+ // src/screens/keys.tsx
3803
+ import { Text } from "ink";
3804
+
3675
3805
  // src/hooks/use-safe-input.ts
3676
3806
  import { useInput, useStdin } from "ink";
3807
+ import { useCallback as useCallback2, useLayoutEffect, useRef as useRef2 } from "react";
3677
3808
  function useSafeInput(handler, options) {
3809
+ const latestHandler = useRef2(handler);
3810
+ useLayoutEffect(() => {
3811
+ latestHandler.current = handler;
3812
+ }, [handler]);
3813
+ const stableHandler = useCallback2((input, key) => latestHandler.current(input, key), []);
3678
3814
  const { isRawModeSupported } = useStdin();
3679
3815
  const active = (options?.isActive ?? true) && isRawModeSupported === true;
3680
- useInput(handler, { ...options, isActive: active });
3816
+ useInput(stableHandler, { ...options, isActive: active });
3681
3817
  }
3682
3818
 
3683
- // src/screens/detect.tsx
3684
- import { Box as Box2, Text as Text3 } from "ink";
3685
-
3686
- // src/components/step-header.tsx
3687
- import { Box, Text } from "ink";
3688
-
3689
- // src/theme.ts
3690
- var colors = {
3691
- // Superficies (fondo)
3692
- surface: "#131313",
3693
- surfaceContainer: "#201f1f",
3694
- surfaceContainerLow: "#1c1b1b",
3695
- surfaceContainerHigh: "#2a2a2a",
3696
- surfaceContainerHighest: "#353534",
3697
- surfaceContainerLowest: "#0e0e0e",
3698
- // Primario (púrpura)
3699
- primary: "#c9bfff",
3700
- primaryContainer: "#6a49f8",
3701
- onPrimary: "#131313",
3702
- onPrimaryContainer: "#f0e9ff",
3703
- // Secundario (rosa)
3704
- secondary: "#ffade0",
3705
- secondaryContainer: "#7a3060",
3706
- onSecondary: "#131313",
3707
- onSecondaryContainer: "#ffd8ef",
3708
- // Terciario (verde - señal de éxito/activo)
3709
- tertiary: "#31e368",
3710
- tertiaryContainer: "#005229",
3711
- onTertiary: "#131313",
3712
- onTertiaryContainer: "#adffd0",
3713
- // Error
3714
- error: "#ffb4ab",
3715
- errorContainer: "#93000a",
3716
- onError: "#690005",
3717
- onErrorContainer: "#ffdad6",
3718
- // Texto
3719
- onSurface: "#e5e2e1",
3720
- onSurfaceVariant: "#a09d9c",
3721
- // Ámbar — reservado al estado «no se pudo determinar»
3722
- unknown: "#f0b429",
3723
- // Bordes
3724
- outlineVariant: "#484556",
3725
- outline: "#6f6d70"
3726
- };
3727
- var semantic = {
3728
- action: colors.primary,
3729
- // foco / acción primaria (púrpura)
3730
- success: colors.tertiary,
3731
- // verde
3732
- error: colors.error,
3733
- // rojo
3734
- warning: colors.secondary,
3735
- // rosa (admin / skipped / atención)
3736
- // Ámbar — «no se pudo determinar». NO puede reusar `muted`, que hoy significa
3737
- // «al día»: eso es exactamente confundir «no lo sé» con «está bien»
3738
- // (DES-001@r1). Se distingue a la vez del rosa de advertencia y del gris.
3739
- unknown: colors.unknown,
3740
- text: colors.onSurface,
3741
- muted: colors.onSurfaceVariant
3819
+ // src/screens/keys.tsx
3820
+ import { jsx as jsx2 } from "react/jsx-runtime";
3821
+ var bindings = {
3822
+ quit: ["q"],
3823
+ retry: ["r"],
3824
+ down: ["downArrow", "j"],
3825
+ up: ["upArrow", "k"],
3826
+ mark: [" "],
3827
+ all: ["a"],
3828
+ none: ["n"],
3829
+ next: ["return"],
3830
+ settings: ["s"],
3831
+ back: ["escape"],
3832
+ detail: ["d"],
3833
+ language: ["l"],
3834
+ elevate: ["e"],
3835
+ start: ["return", "y"],
3836
+ cancel: ["escape"],
3837
+ ctrlC: ["ctrl+c"],
3838
+ confirmCancel: ["s"],
3839
+ continueRun: ["n", "escape"]
3742
3840
  };
3743
-
3744
- // src/lib/glyphs.ts
3745
- function shouldUseAscii(env, platform) {
3746
- if (env["TACUCHI_ASCII"] === "1") return true;
3747
- if (env["TACUCHI_ASCII"] === "0") return false;
3748
- if (env["TERM"] === "dumb") return true;
3749
- if (platform === "win32" && !env["WT_SESSION"]) return true;
3750
- return false;
3841
+ function commandsFor(handlers2) {
3842
+ return Object.entries(handlers2).map(([action, run]) => ({ keys: action === "confirmCancel" && getLanguage() === "en" ? ["y"] : bindings[action], label: t("hints", action), run }));
3843
+ }
3844
+ function dispatchKey(commands, key) {
3845
+ commands.find((command) => command.keys.includes(key))?.run();
3846
+ }
3847
+ function hintLines(commands, width) {
3848
+ const lines = [];
3849
+ for (const command of commands) {
3850
+ const last = lines.at(-1);
3851
+ if (last && last.length + command.label.length + 3 <= width) lines[lines.length - 1] = `${last} ${g.separator} ${command.label}`;
3852
+ else lines.push(command.label);
3853
+ }
3854
+ return lines;
3855
+ }
3856
+ function useScreenKeys(handlers2) {
3857
+ const { quitApp } = useMachine();
3858
+ const commands = commandsFor({ ...handlers2, ctrlC: handlers2.ctrlC ?? quitApp });
3859
+ useSafeInput((input, key) => {
3860
+ const special = ["return", "escape", "downArrow", "upArrow"].find((name) => key[name]);
3861
+ if (key.ctrl) {
3862
+ if (input === "c") dispatchKey(commands, "ctrl+c");
3863
+ return;
3864
+ }
3865
+ if (key.meta && !key.escape) return;
3866
+ dispatchKey(commands, special ?? input.toLowerCase());
3867
+ });
3868
+ return commands;
3869
+ }
3870
+ function KeyHints({ commands }) {
3871
+ const width = Math.min(process.stdout.columns ?? 100, 100) - 4;
3872
+ return /* @__PURE__ */ jsx2(Text, { color: semantic.muted, children: hintLines(commands, width).join("\n") });
3751
3873
  }
3752
- var UNICODE = {
3753
- pending: "\xB7",
3754
- scanning: "\u25CC",
3755
- outdated: "\u203A",
3756
- uptodate: "\u2713",
3757
- running: "\u25B8",
3758
- done: "\u2713",
3759
- failed: "\u2717",
3760
- skipped: "\u2298",
3761
- unknown: "?",
3762
- cursor: "\u276F",
3763
- checkOn: "[\u2713]",
3764
- checkOff: "[ ]",
3765
- arrow: "\u2192",
3766
- scrollUp: "\u25B2",
3767
- scrollDown: "\u25BC",
3768
- stepOn: "\u2586",
3769
- stepOff: "\u2581",
3770
- info: "\u24D8",
3771
- ellipsis: "\u2026",
3772
- bullet: "\u25B8",
3773
- reboot: "\u27F3"
3774
- };
3775
- var ASCII_GLYPHS = {
3776
- pending: ".",
3777
- scanning: "o",
3778
- outdated: ">",
3779
- uptodate: "+",
3780
- running: ">",
3781
- done: "+",
3782
- failed: "x",
3783
- skipped: "-",
3784
- unknown: "?",
3785
- cursor: ">",
3786
- checkOn: "[x]",
3787
- checkOff: "[ ]",
3788
- arrow: "->",
3789
- scrollUp: "^",
3790
- scrollDown: "v",
3791
- stepOn: "#",
3792
- stepOff: "_",
3793
- info: "i",
3794
- ellipsis: "...",
3795
- bullet: ">",
3796
- reboot: "*"
3797
- };
3798
- var ASCII = shouldUseAscii(process.env, process.platform);
3799
- var g = ASCII ? ASCII_GLYPHS : UNICODE;
3800
- var NO_ANIM = ASCII || !process.stdout.isTTY;
3801
- var SPINNER_UNICODE = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
3802
- var SPINNER_ASCII = ["|", "/", "-", "\\"];
3803
- var spinnerFrames = ASCII ? SPINNER_ASCII : SPINNER_UNICODE;
3804
3874
 
3805
- // src/components/step-header.tsx
3806
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
3807
- var STEP = {
3808
- detecting: { n: 1, key: "detecting" },
3809
- scanning: { n: 1, key: "scanning" },
3810
- select: { n: 2, key: "select" },
3811
- confirm: { n: 3, key: "confirm" },
3812
- updating: { n: 4, key: "updating" }
3813
- };
3814
- function StepHeader({ phase }) {
3815
- if (phase === "summary") {
3816
- return /* @__PURE__ */ jsx2(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: semantic.success, bold: true, children: [
3817
- g.stepOn,
3818
- " ",
3819
- t("flow", "summary")
3820
- ] }) });
3821
- }
3822
- if (phase === "detail") {
3823
- return /* @__PURE__ */ jsx2(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: semantic.action, bold: true, children: [
3824
- g.stepOn,
3825
- " ",
3826
- t("flow", "detail")
3827
- ] }) });
3828
- }
3829
- if (phase === "settings") {
3830
- return /* @__PURE__ */ jsx2(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: semantic.action, bold: true, children: [
3831
- g.stepOn,
3832
- " ",
3833
- t("flow", "settings")
3834
- ] }) });
3835
- }
3836
- const step = STEP[phase];
3837
- if (!step) return null;
3838
- return /* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
3839
- [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxs(Text, { color: i === step.n ? semantic.action : semantic.muted, bold: i === step.n, children: [
3840
- i === step.n ? g.stepOn : g.stepOff,
3841
- " "
3842
- ] }, i)),
3843
- /* @__PURE__ */ jsxs(Text, { color: semantic.muted, children: [
3844
- " ",
3845
- t("flow", "step"),
3846
- " ",
3847
- step.n,
3848
- "/4 \xB7",
3849
- " "
3850
- ] }),
3851
- /* @__PURE__ */ jsx2(Text, { color: semantic.action, bold: true, children: t("flow", step.key) })
3852
- ] });
3875
+ // src/lib/display-path.ts
3876
+ import { homedir } from "os";
3877
+ function compactPath(path7, width) {
3878
+ const home = homedir();
3879
+ const display = path7 === home || path7.startsWith(home + "/") || path7.startsWith(home + "\\") ? "~" + path7.slice(home.length) : path7;
3880
+ if (display.length <= width) return display;
3881
+ const available = Math.max(0, width - g.ellipsis.length);
3882
+ const left = Math.ceil(available / 2);
3883
+ return display.slice(0, left) + g.ellipsis + display.slice(display.length - (available - left));
3853
3884
  }
3854
3885
 
3886
+ // src/screens/detect.tsx
3887
+ import { Box, Text as Text3 } from "ink";
3888
+
3855
3889
  // src/components/status-glyph.tsx
3856
3890
  import { useEffect as useEffect2, useState as useState2 } from "react";
3857
3891
  import { Text as Text2 } from "ink";
3858
3892
  import { jsx as jsx3 } from "react/jsx-runtime";
3859
- var SPECS = {
3860
- pending: { glyph: g.pending, color: semantic.muted },
3861
- scanning: { glyph: g.scanning, color: semantic.action },
3862
- outdated: { glyph: g.outdated, color: semantic.warning },
3863
- uptodate: { glyph: g.uptodate, color: semantic.muted },
3864
- queued: { glyph: g.pending, color: semantic.muted },
3865
- running: { glyph: g.running, color: semantic.action },
3866
- done: { glyph: g.done, color: semantic.success },
3867
- failed: { glyph: g.failed, color: semantic.error },
3868
- skipped: { glyph: g.skipped, color: semantic.warning },
3869
- // Amber and a one-cell `?`: it cannot reuse `muted`, which is the colour of
3870
- // "up to date" — the confusion this state exists to remove (DES-001@r1). The
3871
- // spec lands here with the domain state because this table is exhaustive over
3872
- // ManagerStatus, so the state cannot exist without it.
3873
- unknown: { glyph: g.unknown, color: semantic.unknown }
3874
- };
3893
+ function specs() {
3894
+ return {
3895
+ cancelling: { glyph: g.running, color: semantic.warning },
3896
+ partial: { glyph: g.partial, color: semantic.error },
3897
+ pending: { glyph: g.pending, color: semantic.muted },
3898
+ scanning: { glyph: g.scanning, color: semantic.action },
3899
+ outdated: { glyph: g.outdated, color: semantic.warning },
3900
+ uptodate: { glyph: g.uptodate, color: semantic.muted },
3901
+ queued: { glyph: g.pending, color: semantic.muted },
3902
+ running: { glyph: g.running, color: semantic.action },
3903
+ done: { glyph: g.done, color: semantic.success },
3904
+ failed: { glyph: g.failed, color: semantic.error },
3905
+ skipped: { glyph: g.skipped, color: semantic.warning },
3906
+ // Amber and a one-cell `?`: it cannot reuse `muted`, which is the colour of
3907
+ // "up to date" — the confusion this state exists to remove (DES-001@r1). The
3908
+ // spec lands here with the domain state because this table is exhaustive over
3909
+ // ManagerStatus, so the state cannot exist without it.
3910
+ unknown: { glyph: g.unknown, color: semantic.unknown }
3911
+ };
3912
+ }
3875
3913
  function statusColor(status) {
3876
- return SPECS[status].color;
3914
+ return specs()[status].color;
3877
3915
  }
3878
3916
  function StatusGlyph({ status }) {
3879
- const spec = SPECS[status];
3917
+ const spec = specs()[status];
3880
3918
  return /* @__PURE__ */ jsx3(Text2, { color: spec.color, children: spec.glyph });
3881
3919
  }
3882
3920
  function RunningGlyph() {
3883
3921
  const [i, setI] = useState2(0);
3884
3922
  useEffect2(() => {
3885
3923
  if (NO_ANIM) return;
3886
- const t3 = setInterval(() => setI((n) => (n + 1) % spinnerFrames.length), 90);
3887
- return () => clearInterval(t3);
3924
+ const t2 = setInterval(() => setI((n) => (n + 1) % spinnerFrames.length), 90);
3925
+ return () => clearInterval(t2);
3888
3926
  }, []);
3889
3927
  const frame = NO_ANIM ? g.running : spinnerFrames[i] ?? g.running;
3890
- return /* @__PURE__ */ jsx3(Text2, { color: SPECS.running.color, children: frame });
3928
+ return /* @__PURE__ */ jsx3(Text2, { color: specs().running.color, children: frame });
3891
3929
  }
3892
3930
 
3893
3931
  // src/screens/detect.tsx
3894
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
3932
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
3895
3933
  function DetectScreen() {
3896
- const { state } = useMachine();
3934
+ const { state, rescan, quitApp } = useMachine();
3935
+ const commands = useScreenKeys({ ...state.error ? { retry: rescan } : {}, quit: quitApp });
3897
3936
  const scanning = state.phase === "scanning";
3898
3937
  const done = state.order.filter((id) => {
3899
3938
  const s = state.managers[id]?.status;
3900
3939
  return s === "outdated" || s === "uptodate" || s === "unknown";
3901
3940
  }).length;
3902
- return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
3903
- /* @__PURE__ */ jsx4(StepHeader, { phase: state.phase }),
3904
- /* @__PURE__ */ jsxs2(Box2, { marginBottom: 1, children: [
3941
+ if (state.error) return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
3942
+ /* @__PURE__ */ jsxs(Text3, { color: semantic.error, children: [
3943
+ g.failed,
3944
+ " ",
3945
+ t("ui", "detectionFailed")
3946
+ ] }),
3947
+ /* @__PURE__ */ jsx4(Text3, { color: semantic.text, children: state.error }),
3948
+ /* @__PURE__ */ jsxs(Text3, { color: semantic.muted, children: [
3949
+ t("ui", "logAt"),
3950
+ " ",
3951
+ compactPath(getLogFilePath() ?? "", Math.min(process.stdout.columns ?? 100, 100) - 4 - t("ui", "logAt").length)
3952
+ ] }),
3953
+ /* @__PURE__ */ jsx4(KeyHints, { commands })
3954
+ ] });
3955
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
3956
+ /* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
3905
3957
  /* @__PURE__ */ jsx4(Text3, { color: semantic.text, children: scanning ? t("ui", "scanning") : t("ui", "detecting") }),
3906
- scanning && /* @__PURE__ */ jsxs2(Text3, { color: semantic.muted, children: [
3958
+ scanning && /* @__PURE__ */ jsxs(Text3, { color: semantic.muted, children: [
3907
3959
  " ",
3908
3960
  "(",
3909
3961
  done,
@@ -3915,28 +3967,53 @@ function DetectScreen() {
3915
3967
  scanning && state.order.map((id) => {
3916
3968
  const e = state.managers[id];
3917
3969
  if (!e) return null;
3918
- return /* @__PURE__ */ jsxs2(Box2, { children: [
3919
- /* @__PURE__ */ jsx4(Box2, { width: 2, children: /* @__PURE__ */ jsx4(StatusGlyph, { status: e.status }) }),
3920
- /* @__PURE__ */ jsx4(Box2, { width: 18, children: /* @__PURE__ */ jsx4(Text3, { color: e.status === "outdated" ? semantic.text : semantic.muted, children: managerName(id) }) }),
3921
- e.status === "outdated" ? /* @__PURE__ */ jsxs2(Text3, { color: semantic.warning, children: [
3970
+ return /* @__PURE__ */ jsxs(Box, { children: [
3971
+ /* @__PURE__ */ jsx4(Box, { width: 2, children: /* @__PURE__ */ jsx4(StatusGlyph, { status: e.status }) }),
3972
+ /* @__PURE__ */ jsx4(Box, { width: 18, children: /* @__PURE__ */ jsx4(Text3, { color: e.status === "outdated" ? semantic.text : semantic.muted, children: managerName(id) }) }),
3973
+ e.status === "outdated" ? /* @__PURE__ */ jsxs(Text3, { color: semantic.warning, children: [
3922
3974
  e.outdated.length,
3923
3975
  " ",
3924
3976
  g.outdated
3925
3977
  ] }) : e.status === "uptodate" ? /* @__PURE__ */ jsx4(Text3, { color: colors.outline, children: "-" }) : e.status === "unknown" ? /* @__PURE__ */ jsx4(Text3, { color: semantic.unknown, children: t("ui", "undetermined") }) : /* @__PURE__ */ jsx4(Text3, { color: semantic.muted, children: g.ellipsis })
3926
3978
  ] }, id);
3927
- })
3979
+ }),
3980
+ /* @__PURE__ */ jsx4(KeyHints, { commands })
3928
3981
  ] });
3929
3982
  }
3930
3983
 
3931
3984
  // src/screens/select.tsx
3932
3985
  import { useState as useState3 } from "react";
3933
- import { Box as Box3, Text as Text4 } from "ink";
3934
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
3986
+ import { Box as Box2, Text as Text4 } from "ink";
3987
+
3988
+ // src/lib/display-counts.ts
3989
+ var labels = {
3990
+ upgraded: ["upgradedOne", "upgraded"],
3991
+ failed: ["failedOne", "failed"],
3992
+ manual: ["manualShort", "manualMany"],
3993
+ unknown: ["undeterminedShort", "undeterminedShort"]
3994
+ };
3995
+ function countText(count, kind) {
3996
+ return `${count} ${t("ui", labels[kind][count === 1 ? 0 : 1])}`;
3997
+ }
3998
+ function selectionText(marked, total) {
3999
+ return `${marked} ${t("ui", "of")} ${total} ${t("ui", marked === 1 ? "selectedOne" : "selected")}`;
4000
+ }
4001
+ function summaryText(counts) {
4002
+ const parts = [countText(counts.upgraded, "upgraded")];
4003
+ if (counts.failed > 0) parts.push(countText(counts.failed, "failed"));
4004
+ if (counts.skipped > 0) parts.push(countText(counts.skipped, "manual"));
4005
+ if (counts.unknown > 0) parts.push(countText(counts.unknown, "unknown"));
4006
+ return parts.join(` ${g.separator} `);
4007
+ }
4008
+
4009
+ // src/screens/select.tsx
4010
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
3935
4011
  function clip(s, n) {
3936
4012
  return s.length > n ? s.slice(0, Math.max(0, n - g.ellipsis.length)) + g.ellipsis : s;
3937
4013
  }
3938
4014
  function SelectScreen() {
3939
- const { state, toggleItem, selectAll, selectNone, goConfirm, openSettings } = useMachine();
4015
+ const { state, toggleItem, selectAll, selectNone, goConfirm, openSettings, rescan, quitApp } = useMachine();
4016
+ const [notice, setNotice] = useState3(false);
3940
4017
  const [cursor, setCursor] = useState3(0);
3941
4018
  const rows = [];
3942
4019
  for (const id of state.order) {
@@ -3945,71 +4022,61 @@ function SelectScreen() {
3945
4022
  }
3946
4023
  const clamped = Math.min(cursor, Math.max(0, rows.length - 1));
3947
4024
  const undetermined = state.order.filter((id) => state.managers[id]?.status === "unknown");
3948
- useSafeInput((input, key) => {
3949
- if (key.downArrow || input === "j") setCursor((c) => Math.min(rows.length - 1, c + 1));
3950
- else if (key.upArrow || input === "k") setCursor((c) => Math.max(0, c - 1));
3951
- else if (input === " ") {
3952
- const r = rows[clamped];
3953
- if (r) toggleItem(selectionKey(r.managerId, r.pkg.name));
3954
- } else if (input === "a" || input === "A") selectAll();
3955
- else if (input === "n" || input === "N") selectNone();
3956
- else if (key.return) goConfirm();
3957
- else if (input === "s" || input === "S") openSettings();
4025
+ const commands = useScreenKeys({
4026
+ ...rows.length > 0 ? {
4027
+ down: () => setCursor((c) => Math.min(rows.length - 1, c + 1)),
4028
+ up: () => setCursor((c) => Math.max(0, c - 1)),
4029
+ mark: () => {
4030
+ const row = rows[clamped];
4031
+ if (row) toggleItem(selectionKey(row.managerId, row.pkg.name));
4032
+ },
4033
+ all: selectAll,
4034
+ none: selectNone,
4035
+ next: () => {
4036
+ if (state.selection.size === 0) setNotice(true);
4037
+ else goConfirm();
4038
+ }
4039
+ } : { retry: rescan },
4040
+ settings: openSettings,
4041
+ quit: quitApp
3958
4042
  });
3959
4043
  if (rows.length === 0) {
3960
- return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
3961
- /* @__PURE__ */ jsx5(StepHeader, { phase: state.phase }),
3962
- /* @__PURE__ */ jsxs3(Text4, { color: semantic.success, children: [
3963
- "\u2713 ",
4044
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
4045
+ /* @__PURE__ */ jsxs2(Text4, { color: semantic.success, children: [
4046
+ g.done,
4047
+ " ",
3964
4048
  t("ui", "noUpdates")
3965
4049
  ] }),
3966
- undetermined.length > 0 && /* @__PURE__ */ jsxs3(Text4, { color: semantic.unknown, children: [
4050
+ undetermined.length > 0 && /* @__PURE__ */ jsxs2(Text4, { color: semantic.unknown, children: [
3967
4051
  g.unknown,
3968
4052
  " ",
3969
- undetermined.length,
3970
- " ",
3971
- t("ui", "undeterminedCount"),
4053
+ countText(undetermined.length, "unknown"),
3972
4054
  ":",
3973
4055
  " ",
3974
4056
  undetermined.map((id) => managerName(id)).join(", ")
3975
4057
  ] }),
3976
- /* @__PURE__ */ jsx5(Box3, { marginTop: 1, children: /* @__PURE__ */ jsxs3(Text4, { color: semantic.muted, children: [
3977
- "R ",
3978
- t("flow", "detecting"),
3979
- " \xB7 Q"
3980
- ] }) })
4058
+ /* @__PURE__ */ jsx5(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx5(KeyHints, { commands }) })
3981
4059
  ] });
3982
4060
  }
3983
4061
  const width = Math.min((process.stdout.columns ?? 90) - 4, 92);
3984
- const view = Math.max(6, (process.stdout.rows ?? 24) - 11);
4062
+ const view = Math.max(6, (process.stdout.rows ?? 24) - 11 - headerExtraRows());
3985
4063
  let start = clamped - Math.floor(view / 2);
3986
4064
  start = Math.max(0, Math.min(start, Math.max(0, rows.length - view)));
3987
4065
  const end = Math.min(rows.length, start + view);
3988
4066
  const visible = rows.slice(start, end);
3989
4067
  let prevManager = "";
3990
- return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
3991
- /* @__PURE__ */ jsx5(StepHeader, { phase: state.phase }),
3992
- /* @__PURE__ */ jsxs3(Box3, { marginBottom: 1, children: [
3993
- /* @__PURE__ */ jsx5(Text4, { color: semantic.action, bold: true, children: state.selection.size }),
3994
- /* @__PURE__ */ jsxs3(Text4, { color: semantic.muted, children: [
3995
- " ",
3996
- "/ ",
3997
- rows.length,
3998
- " ",
3999
- t("ui", "selected")
4000
- ] })
4001
- ] }),
4002
- undetermined.length > 0 && /* @__PURE__ */ jsx5(Box3, { marginBottom: 1, children: /* @__PURE__ */ jsxs3(Text4, { color: semantic.unknown, children: [
4068
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
4069
+ notice && /* @__PURE__ */ jsx5(Text4, { color: semantic.warning, children: t("ui", "chooseFirst") }),
4070
+ /* @__PURE__ */ jsx5(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsx5(Text4, { color: semantic.action, bold: true, children: selectionText(state.selection.size, rows.length) }) }),
4071
+ undetermined.length > 0 && /* @__PURE__ */ jsx5(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsxs2(Text4, { color: semantic.unknown, children: [
4003
4072
  g.unknown,
4004
4073
  " ",
4005
- undetermined.length,
4006
- " ",
4007
- t("ui", "undeterminedCount"),
4074
+ countText(undetermined.length, "unknown"),
4008
4075
  ":",
4009
4076
  " ",
4010
4077
  undetermined.map((id) => managerName(id)).join(", ")
4011
4078
  ] }) }),
4012
- start > 0 && /* @__PURE__ */ jsxs3(Text4, { color: colors.outline, children: [
4079
+ start > 0 && /* @__PURE__ */ jsxs2(Text4, { color: colors.outline, children: [
4013
4080
  g.scrollUp,
4014
4081
  " ",
4015
4082
  start
@@ -4019,13 +4086,13 @@ function SelectScreen() {
4019
4086
  prevManager = r.managerId;
4020
4087
  const selected = state.selection.has(selectionKey(r.managerId, r.pkg.name));
4021
4088
  const isCursor = rows[clamped] === r;
4022
- return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
4089
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
4023
4090
  header && /* @__PURE__ */ jsx5(Text4, { color: semantic.muted, bold: true, children: header }),
4024
- /* @__PURE__ */ jsxs3(Box3, { children: [
4091
+ /* @__PURE__ */ jsxs2(Box2, { children: [
4025
4092
  /* @__PURE__ */ jsx5(Text4, { color: isCursor ? semantic.action : colors.outline, children: isCursor ? `${g.cursor} ` : " " }),
4026
4093
  /* @__PURE__ */ jsx5(Text4, { color: selected ? semantic.success : colors.outline, children: selected ? `${g.checkOn} ` : `${g.checkOff} ` }),
4027
- /* @__PURE__ */ jsx5(Box3, { width: 22, children: /* @__PURE__ */ jsx5(Text4, { color: semantic.text, bold: isCursor, children: clip(r.pkg.name, 21) }) }),
4028
- /* @__PURE__ */ jsxs3(Text4, { color: semantic.muted, wrap: "truncate-end", children: [
4094
+ /* @__PURE__ */ jsx5(Box2, { width: 22, children: /* @__PURE__ */ jsx5(Text4, { color: semantic.text, bold: isCursor, children: clip(r.pkg.name, 21) }) }),
4095
+ /* @__PURE__ */ jsxs2(Text4, { color: semantic.muted, wrap: "truncate-end", children: [
4029
4096
  clip(r.pkg.currentVersion, 14),
4030
4097
  " ",
4031
4098
  /* @__PURE__ */ jsx5(Text4, { color: semantic.action, children: g.arrow }),
@@ -4035,59 +4102,74 @@ function SelectScreen() {
4035
4102
  ] })
4036
4103
  ] }, `${r.managerId}:${r.pkg.name}`);
4037
4104
  }),
4038
- end < rows.length && /* @__PURE__ */ jsxs3(Text4, { color: colors.outline, children: [
4105
+ end < rows.length && /* @__PURE__ */ jsxs2(Text4, { color: colors.outline, children: [
4039
4106
  g.scrollDown,
4040
4107
  " ",
4041
4108
  rows.length - end
4042
4109
  ] }),
4043
- /* @__PURE__ */ jsx5(Box3, { marginTop: 1, children: /* @__PURE__ */ jsx5(Text4, { color: semantic.muted, children: clip(t("ui", "selectHint"), width) }) })
4110
+ /* @__PURE__ */ jsx5(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx5(KeyHints, { commands }) })
4044
4111
  ] });
4045
4112
  }
4046
4113
 
4047
4114
  // src/screens/confirm.tsx
4048
- import { Box as Box4, Text as Text5 } from "ink";
4049
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
4115
+ import { Box as Box3, Text as Text5 } from "ink";
4116
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
4050
4117
  function ConfirmScreen() {
4051
- const { state, startRun, goSelect, sudoMode: sudoMode2, relaunch } = useMachine();
4118
+ const { state, startRun, goSelect, sudoMode: sudoMode2, relaunch, quitApp } = useMachine();
4052
4119
  const byManager = /* @__PURE__ */ new Map();
4053
4120
  for (const key of state.selection) {
4054
4121
  const [id] = parseSelectionKey(key);
4055
4122
  byManager.set(id, (byManager.get(id) ?? 0) + 1);
4056
4123
  }
4057
4124
  const needsElevation = process.platform === "win32" && !sudoMode2 && [...byManager.keys()].some((id) => state.managers[id]?.requiresAdmin);
4058
- useSafeInput((input, key) => {
4059
- if ((input === "e" || input === "E") && needsElevation) relaunch();
4060
- else if (key.return || input === "y" || input === "Y") startRun();
4061
- else if (key.escape) goSelect();
4062
- });
4063
- return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
4064
- /* @__PURE__ */ jsx6(StepHeader, { phase: state.phase }),
4065
- /* @__PURE__ */ jsx6(Text5, { color: semantic.text, children: t("ui", "willRun") }),
4066
- /* @__PURE__ */ jsx6(Box4, { flexDirection: "column", marginTop: 1, marginBottom: 1, children: [...byManager.entries()].map(([id, count]) => {
4067
- const m = state.managers[id];
4068
- const willSkip = m?.requiresAdmin && !sudoMode2;
4069
- return /* @__PURE__ */ jsxs4(Box4, { children: [
4070
- /* @__PURE__ */ jsxs4(Text5, { color: semantic.action, children: [
4125
+ const commands = useScreenKeys({ start: startRun, back: goSelect, ...needsElevation ? { elevate: relaunch } : {}, quit: quitApp });
4126
+ const active = [...byManager.entries()].filter(([id]) => !state.managers[id]?.requiresAdmin || sudoMode2);
4127
+ const skipped = [...byManager.entries()].filter(([id]) => state.managers[id]?.requiresAdmin && !sudoMode2);
4128
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
4129
+ /* @__PURE__ */ jsxs3(Text5, { color: semantic.text, children: [
4130
+ t("ui", "willRun"),
4131
+ " ",
4132
+ active.reduce((sum, [, count]) => sum + count, 0),
4133
+ " ",
4134
+ t("ui", active.reduce((sum, [, count]) => sum + count, 0) === 1 ? "packageOne" : "packageMany")
4135
+ ] }),
4136
+ /* @__PURE__ */ jsx6(Box3, { flexDirection: "column", marginTop: 1, marginBottom: 1, children: active.map(([id, count]) => {
4137
+ return /* @__PURE__ */ jsxs3(Box3, { children: [
4138
+ /* @__PURE__ */ jsxs3(Text5, { color: semantic.action, children: [
4071
4139
  g.bullet,
4072
4140
  " "
4073
4141
  ] }),
4074
- /* @__PURE__ */ jsx6(Box4, { width: 20, children: /* @__PURE__ */ jsx6(Text5, { color: semantic.text, bold: true, children: managerName(id) }) }),
4075
- /* @__PURE__ */ jsxs4(Text5, { color: semantic.muted, children: [
4142
+ /* @__PURE__ */ jsx6(Box3, { width: 20, children: /* @__PURE__ */ jsx6(Text5, { color: semantic.text, bold: true, children: managerName(id) }) }),
4143
+ /* @__PURE__ */ jsxs3(Text5, { color: semantic.muted, children: [
4076
4144
  count,
4077
- " paquete(s)"
4078
- ] }),
4079
- willSkip && /* @__PURE__ */ jsx6(Text5, { color: semantic.warning, children: process.platform === "win32" ? " \xB7 requiere admin \u2192 manual" : " \xB7 requiere sudo \u2192 manual" })
4145
+ " ",
4146
+ t("ui", count === 1 ? "packageOne" : "packageMany")
4147
+ ] })
4080
4148
  ] }, id);
4081
4149
  }) }),
4082
- /* @__PURE__ */ jsx6(Text5, { color: semantic.muted, children: t("ui", "confirmHint") }),
4083
- needsElevation && /* @__PURE__ */ jsx6(Text5, { color: semantic.warning, children: "E \xB7 relanzar como Administrador (1 UAC) para los gestores que lo requieren" })
4150
+ skipped.length > 0 && /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", marginBottom: 1, children: [
4151
+ /* @__PURE__ */ jsxs3(Text5, { color: semantic.warning, children: [
4152
+ t("ui", process.platform === "win32" ? "adminManual" : "sudoManual"),
4153
+ ":"
4154
+ ] }),
4155
+ skipped.map(([id, count]) => /* @__PURE__ */ jsxs3(Text5, { color: semantic.warning, children: [
4156
+ g.skipped,
4157
+ " ",
4158
+ managerName(id),
4159
+ " ",
4160
+ count,
4161
+ " ",
4162
+ t("ui", count === 1 ? "packageOne" : "packageMany")
4163
+ ] }, id))
4164
+ ] }),
4165
+ /* @__PURE__ */ jsx6(KeyHints, { commands })
4084
4166
  ] });
4085
4167
  }
4086
4168
 
4087
4169
  // src/screens/update.tsx
4088
4170
  import { useEffect as useEffect3, useState as useState4 } from "react";
4089
- import { Box as Box5, Text as Text6 } from "ink";
4090
- import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
4171
+ import { Box as Box4, Text as Text6 } from "ink";
4172
+ import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
4091
4173
  function clip2(s, n) {
4092
4174
  return s.length > n ? s.slice(0, Math.max(0, n - g.ellipsis.length)) + g.ellipsis : s;
4093
4175
  }
@@ -4114,62 +4196,89 @@ function Row({ e, width }) {
4114
4196
  else if (e.status === "skipped") detail = e.manualCommand ?? "manual";
4115
4197
  else if (e.status === "failed") detail = e.result?.failures[0]?.message ?? "";
4116
4198
  else if (e.status === "unknown") detail = e.result?.failures[0]?.message ?? t("ui", "undetermined");
4117
- return /* @__PURE__ */ jsxs5(Box5, { children: [
4118
- /* @__PURE__ */ jsx7(Box5, { width: 2, children: e.status === "running" ? /* @__PURE__ */ jsx7(RunningGlyph, {}) : /* @__PURE__ */ jsx7(StatusGlyph, { status: e.status }) }),
4119
- /* @__PURE__ */ jsx7(Box5, { width: 16, children: /* @__PURE__ */ jsx7(Text6, { color: semantic.text, bold: e.status === "running", children: clip2(managerName(e.id), 15) }) }),
4120
- /* @__PURE__ */ jsx7(Box5, { width: 13, children: /* @__PURE__ */ jsx7(Text6, { color: statusColor(e.status), children: t("status", e.status) }) }),
4121
- /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: e.status === "running" ? e.percent > 0 ? `${e.percent}%` : e.startedAt !== void 0 && e.startedAt > 0 ? /* @__PURE__ */ jsx7(Elapsed, { startedAt: e.startedAt }) : "" : clip2(detail, Math.max(0, width - 33)) })
4199
+ return /* @__PURE__ */ jsxs4(Box4, { children: [
4200
+ /* @__PURE__ */ jsx7(Box4, { width: 2, children: e.status === "running" ? /* @__PURE__ */ jsx7(RunningGlyph, {}) : /* @__PURE__ */ jsx7(StatusGlyph, { status: e.status }) }),
4201
+ /* @__PURE__ */ jsx7(Box4, { width: 16, children: /* @__PURE__ */ jsx7(Text6, { color: semantic.text, bold: e.status === "running", children: clip2(managerName(e.id), 15) }) }),
4202
+ /* @__PURE__ */ jsx7(Box4, { width: 13, children: /* @__PURE__ */ jsx7(Text6, { color: statusColor(e.status), children: t("status", e.status) }) }),
4203
+ /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: e.status === "running" ? e.percent > 0 ? `${e.percent}%` : e.startedAt !== void 0 && e.startedAt > 0 ? /* @__PURE__ */ jsx7(Elapsed, { startedAt: e.startedAt }) : "" : clip2(detail, Math.max(0, width - 33)) }),
4204
+ e.status === "running" && /* @__PURE__ */ jsxs4(Text6, { color: semantic.muted, children: [
4205
+ " ",
4206
+ e.percent > 0 && e.startedAt ? /* @__PURE__ */ jsx7(Elapsed, { startedAt: e.startedAt }) : "",
4207
+ " ",
4208
+ clip2(e.currentPackage ?? "", Math.max(0, width - 45))
4209
+ ] })
4122
4210
  ] });
4123
4211
  }
4124
4212
  function UpdateScreen() {
4125
- const { state, cancelRun } = useMachine();
4126
- useSafeInput((_input, key) => {
4127
- if (key.escape) cancelRun();
4128
- });
4213
+ const [now, setNow] = useState4(Date.now);
4214
+ useEffect3(() => {
4215
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
4216
+ return () => clearInterval(timer);
4217
+ }, []);
4218
+ const { state, cancelRun, quitApp } = useMachine();
4219
+ const [asking, setAsking] = useState4(false);
4220
+ const commands = useScreenKeys(asking ? {
4221
+ confirmCancel: () => {
4222
+ setAsking(false);
4223
+ cancelRun();
4224
+ },
4225
+ continueRun: () => setAsking(false),
4226
+ ctrlC: quitApp
4227
+ } : { cancel: () => setAsking(true), quit: () => setAsking(true), ctrlC: quitApp });
4228
+ const activeNames = state.run.queue.filter((id) => ["running", "queued"].includes(state.managers[id]?.status ?? "")).map(managerName);
4129
4229
  const total = state.run.queue.length;
4230
+ const packagesDone = state.run.queue.reduce((sum, id) => {
4231
+ const result = state.managers[id]?.result;
4232
+ return sum + (result?.upgraded ?? 0) + (result?.failed ?? 0) + (result?.skipped ?? 0);
4233
+ }, 0);
4234
+ const canPrompt = state.run.queue.some((id) => {
4235
+ const entry = state.managers[id];
4236
+ if (entry?.requiresAdmin && !state.sudoMode) return false;
4237
+ return entry?.requiresAdmin || process.platform !== "win32" && ["brew", "gem", "pip", "pipx"].includes(id);
4238
+ });
4130
4239
  const finished = state.run.doneCount + state.run.failedCount + state.run.skippedCount + state.run.unknownCount;
4131
4240
  const width = Math.min((process.stdout.columns ?? 90) - 4, 92);
4132
- return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
4133
- /* @__PURE__ */ jsx7(StepHeader, { phase: state.phase }),
4134
- /* @__PURE__ */ jsxs5(Box5, { marginBottom: 1, children: [
4135
- /* @__PURE__ */ jsxs5(Text6, { color: semantic.text, bold: true, children: [
4136
- finished,
4137
- "/",
4138
- total,
4139
- " "
4140
- ] }),
4141
- /* @__PURE__ */ jsxs5(Text6, { color: semantic.success, children: [
4142
- g.done,
4143
- " ",
4144
- state.run.doneCount,
4145
- " "
4146
- ] }),
4147
- /* @__PURE__ */ jsxs5(Text6, { color: semantic.error, children: [
4148
- g.failed,
4149
- " ",
4150
- state.run.failedCount,
4151
- " "
4152
- ] }),
4153
- /* @__PURE__ */ jsxs5(Text6, { color: semantic.warning, children: [
4154
- g.skipped,
4155
- " ",
4156
- state.run.skippedCount
4157
- ] })
4158
- ] }),
4241
+ return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
4242
+ /* @__PURE__ */ jsx7(Box4, { marginBottom: 1, children: /* @__PURE__ */ jsxs4(Text6, { color: semantic.text, children: [
4243
+ finished,
4244
+ "/",
4245
+ total,
4246
+ " ",
4247
+ g.separator,
4248
+ " ",
4249
+ packagesDone,
4250
+ " ",
4251
+ t("ui", "of"),
4252
+ " ",
4253
+ state.selection.size,
4254
+ " ",
4255
+ t("ui", state.selection.size === 1 ? "packageOne" : "packageMany"),
4256
+ " ",
4257
+ g.separator,
4258
+ " ",
4259
+ formatElapsed(now - (state.run.startedAt ?? now))
4260
+ ] }) }),
4159
4261
  state.run.queue.map((id) => {
4160
4262
  const e = state.managers[id];
4161
4263
  return e ? /* @__PURE__ */ jsx7(Row, { e, width }, id) : null;
4162
4264
  }),
4163
- /* @__PURE__ */ jsxs5(Box5, { marginTop: 1, flexDirection: "column", children: [
4164
- /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: t("ui", "updatingHint") }),
4165
- /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: t("ui", "passwordNote") })
4265
+ /* @__PURE__ */ jsxs4(Box4, { marginTop: 1, flexDirection: "column", children: [
4266
+ /* @__PURE__ */ jsxs4(Box4, { height: 3, flexDirection: "column", children: [
4267
+ asking && /* @__PURE__ */ jsx7(Box4, { height: 2, children: /* @__PURE__ */ jsxs4(Text6, { color: semantic.warning, wrap: "truncate-end", children: [
4268
+ t("ui", "cancelQuestion"),
4269
+ " ",
4270
+ activeNames.join(", ")
4271
+ ] }) }),
4272
+ /* @__PURE__ */ jsx7(KeyHints, { commands })
4273
+ ] }),
4274
+ canPrompt && /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: t("ui", "passwordNote") })
4166
4275
  ] })
4167
4276
  ] });
4168
4277
  }
4169
4278
 
4170
4279
  // src/screens/summary.tsx
4171
- import { Box as Box6, Text as Text7 } from "ink";
4172
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
4280
+ import { Box as Box5, Text as Text7 } from "ink";
4281
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
4173
4282
  function versionDelta(m) {
4174
4283
  const ups = (m.packages ?? []).filter((p) => p.outcome === "upgraded" && p.toVersion);
4175
4284
  if (ups.length === 0) return "";
@@ -4177,40 +4286,37 @@ function versionDelta(m) {
4177
4286
  const p = ups[0];
4178
4287
  return p.fromVersion ? `${p.name} ${p.fromVersion} ${g.arrow} ${p.toVersion}` : `${p.name} ${g.arrow} ${p.toVersion}`;
4179
4288
  }
4180
- return `${ups.length} ${t("ui", "upgraded")}`;
4289
+ return countText(ups.length, "upgraded");
4181
4290
  }
4182
4291
  function ManagerRow({ m }) {
4183
4292
  const dur = m.durationMs !== void 0 ? `${(m.durationMs / 1e3).toFixed(1)}s` : "";
4184
- return /* @__PURE__ */ jsxs6(Box6, { children: [
4185
- /* @__PURE__ */ jsx8(Box6, { width: 2, children: /* @__PURE__ */ jsx8(StatusGlyph, { status: m.status }) }),
4186
- /* @__PURE__ */ jsx8(Box6, { width: 14, children: /* @__PURE__ */ jsx8(Text7, { color: semantic.text, wrap: "truncate-end", children: managerName(m.id) }) }),
4187
- /* @__PURE__ */ jsxs6(Box6, { width: 9, children: [
4188
- m.upgraded > 0 ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.success, children: [
4293
+ return /* @__PURE__ */ jsxs5(Box5, { children: [
4294
+ /* @__PURE__ */ jsx8(Box5, { width: 2, children: /* @__PURE__ */ jsx8(StatusGlyph, { status: m.status }) }),
4295
+ /* @__PURE__ */ jsx8(Box5, { width: 14, children: /* @__PURE__ */ jsx8(Text7, { color: semantic.text, wrap: "truncate-end", children: managerName(m.id) }) }),
4296
+ /* @__PURE__ */ jsxs5(Box5, { width: 9, children: [
4297
+ m.upgraded > 0 ? /* @__PURE__ */ jsxs5(Text7, { color: semantic.success, children: [
4189
4298
  g.done,
4190
4299
  " ",
4191
4300
  m.upgraded
4192
4301
  ] }) : null,
4193
- m.failed > 0 ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.error, children: [
4302
+ m.failed > 0 ? /* @__PURE__ */ jsxs5(Text7, { color: semantic.error, children: [
4194
4303
  " ",
4195
4304
  g.failed,
4196
4305
  " ",
4197
4306
  m.failed
4198
4307
  ] }) : null
4199
4308
  ] }),
4200
- /* @__PURE__ */ jsx8(Box6, { flexGrow: 1, children: /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, wrap: "truncate-end", children: versionDelta(m) }) }),
4201
- /* @__PURE__ */ jsx8(Box6, { width: 7, justifyContent: "flex-end", children: /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, children: dur }) })
4309
+ /* @__PURE__ */ jsx8(Box5, { flexGrow: 1, children: /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, wrap: "truncate-end", children: versionDelta(m) }) }),
4310
+ /* @__PURE__ */ jsx8(Box5, { width: 7, justifyContent: "flex-end", children: /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, children: dur }) })
4202
4311
  ] });
4203
4312
  }
4204
4313
  function SummaryScreen() {
4205
- const { state, rescan, openDetail } = useMachine();
4206
- useSafeInput((input) => {
4207
- if (input === "r" || input === "R") rescan();
4208
- else if (input === "d" || input === "D") openDetail();
4209
- });
4314
+ const { state, rescan, openDetail, quitApp, selfUpdate } = useMachine();
4210
4315
  const summary = summarizeRun(state);
4211
- const { upgraded, failed, skipped, unknown } = summary;
4212
- const hasErrors = failed > 0;
4316
+ const { failed } = summary;
4317
+ const hasErrors = failed > 0 || state.run.failedCount > 0;
4213
4318
  const hasPackages = summary.managers.some((m) => (m.packages ?? []).length > 0);
4319
+ const commands = useScreenKeys({ ...hasPackages ? { detail: openDetail } : {}, retry: rescan, quit: quitApp });
4214
4320
  const failures = [];
4215
4321
  const manuals = [];
4216
4322
  const reboots = [];
@@ -4232,134 +4338,115 @@ function SummaryScreen() {
4232
4338
  if (r.reboot) reboots.push({ manager: id, state: r.reboot });
4233
4339
  }
4234
4340
  }
4235
- return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
4236
- /* @__PURE__ */ jsx8(StepHeader, { phase: state.phase }),
4237
- /* @__PURE__ */ jsx8(Box6, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text7, { color: hasErrors ? semantic.error : semantic.success, bold: true, children: hasErrors ? `${g.failed} ${t("ui", "withErrors")}` : `${g.done} ${t("ui", "allDone")}` }) }),
4238
- undetermined.length > 0 && /* @__PURE__ */ jsx8(Box6, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs6(Text7, { color: semantic.unknown, children: [
4341
+ return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
4342
+ /* @__PURE__ */ jsx8(Box5, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text7, { color: hasErrors ? semantic.error : semantic.success, bold: true, children: hasErrors ? `${g.failed} ${t("ui", "withErrors")}` : `${g.done} ${t("ui", "allDone")}` }) }),
4343
+ undetermined.length > 0 && /* @__PURE__ */ jsx8(Box5, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs5(Text7, { color: semantic.unknown, children: [
4239
4344
  g.unknown,
4240
4345
  " ",
4241
- undetermined.length,
4242
- " ",
4243
- t("ui", "undeterminedCount"),
4346
+ countText(undetermined.length, "unknown"),
4244
4347
  ":",
4245
4348
  " ",
4246
4349
  undetermined.map((id) => managerName(id)).join(", ")
4247
4350
  ] }) }),
4248
- manuals.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
4351
+ manuals.length > 0 && /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginBottom: 1, children: [
4249
4352
  /* @__PURE__ */ jsx8(Text7, { color: semantic.warning, children: t("ui", "manualNeeded") }),
4250
- manuals.map((m, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
4353
+ manuals.map((m, i) => /* @__PURE__ */ jsxs5(Text7, { color: semantic.muted, children: [
4251
4354
  " ",
4252
4355
  managerName(m.manager),
4253
4356
  ": ",
4254
4357
  /* @__PURE__ */ jsx8(Text7, { color: semantic.text, children: m.command })
4255
4358
  ] }, i))
4256
4359
  ] }),
4257
- /* @__PURE__ */ jsxs6(Box6, { marginBottom: 1, children: [
4258
- /* @__PURE__ */ jsxs6(Text7, { color: semantic.success, children: [
4259
- upgraded,
4260
- " ",
4261
- t("ui", "upgraded")
4262
- ] }),
4263
- /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, children: " \xB7 " }),
4264
- /* @__PURE__ */ jsxs6(Text7, { color: hasErrors ? semantic.error : semantic.muted, children: [
4265
- failed,
4266
- " ",
4267
- t("ui", "failed")
4268
- ] }),
4269
- /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, children: " \xB7 " }),
4270
- /* @__PURE__ */ jsxs6(Text7, { color: semantic.warning, children: [
4271
- skipped,
4272
- " ",
4273
- t("ui", "skipped")
4274
- ] }),
4275
- /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, children: " \xB7 " }),
4276
- /* @__PURE__ */ jsxs6(Text7, { color: unknown > 0 ? semantic.unknown : semantic.muted, children: [
4277
- unknown,
4278
- " ",
4279
- t("ui", "undeterminedTotal")
4280
- ] })
4281
- ] }),
4282
- summary.managers.length > 0 && /* @__PURE__ */ jsx8(Box6, { flexDirection: "column", marginBottom: 1, children: summary.managers.map((m) => /* @__PURE__ */ jsx8(ManagerRow, { m }, m.id)) }),
4283
- failures.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
4284
- failures.slice(0, 8).map((f, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.error, wrap: "truncate-end", children: [
4360
+ /* @__PURE__ */ jsx8(Box5, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text7, { color: semantic.text, children: summaryText(summary) }) }),
4361
+ summary.managers.length > 0 && /* @__PURE__ */ jsx8(Box5, { flexDirection: "column", marginBottom: 1, children: summary.managers.map((m) => /* @__PURE__ */ jsx8(ManagerRow, { m }, m.id)) }),
4362
+ failures.length > 0 && /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginBottom: 1, children: [
4363
+ failures.slice(0, 8).map((f, i) => /* @__PURE__ */ jsxs5(Text7, { color: semantic.error, wrap: "truncate-end", children: [
4285
4364
  g.failed,
4286
4365
  " ",
4287
4366
  managerName(f.manager),
4288
- f.package ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.text, children: [
4367
+ f.package ? /* @__PURE__ */ jsxs5(Text7, { color: semantic.text, children: [
4289
4368
  " ",
4290
4369
  f.package
4291
4370
  ] }) : null,
4292
- f.kind ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
4293
- " \xB7 ",
4371
+ f.kind ? /* @__PURE__ */ jsxs5(Text7, { color: semantic.muted, children: [
4372
+ " ",
4373
+ g.separator,
4374
+ " ",
4294
4375
  f.kind
4295
4376
  ] }) : null
4296
4377
  ] }, i)),
4297
- failures.some((f) => f.kind === "TIMEOUT") && /* @__PURE__ */ jsxs6(Text7, { color: semantic.warning, children: [
4378
+ failures.some((f) => f.kind === "TIMEOUT") && /* @__PURE__ */ jsxs5(Text7, { color: semantic.warning, children: [
4298
4379
  g.info,
4299
- " Un TIMEOUT suele indicar un paquete que pide interacci\xF3n (ej. un cask que requiere cerrar la app o sudo). Actual\xEDzalo manualmente en una terminal."
4380
+ " ",
4381
+ t("ui", "timeoutNote")
4300
4382
  ] })
4301
4383
  ] }),
4302
- reboots.length > 0 && /* @__PURE__ */ jsx8(Box6, { marginBottom: 1, children: /* @__PURE__ */ jsxs6(Text7, { color: semantic.warning, children: [
4384
+ reboots.length > 0 && /* @__PURE__ */ jsx8(Box5, { marginBottom: 1, children: /* @__PURE__ */ jsxs5(Text7, { color: semantic.warning, children: [
4303
4385
  g.reboot,
4304
- " Reinicio pendiente: ",
4305
- reboots.map((r) => `${managerName(r.manager)} (${r.state})`).join(", ")
4386
+ " ",
4387
+ t("ui", "rebootPending"),
4388
+ ": ",
4389
+ reboots.map((r) => `${managerName(r.manager)} (${t("ui", r.state === "required" ? "rebootRequired" : r.state === "initiated" ? "rebootInitiated" : "rebootDeferred")})`).join(", ")
4306
4390
  ] }) }),
4307
- /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
4391
+ selfUpdate && /* @__PURE__ */ jsx8(Text7, { color: semantic.warning, children: selfUpdate.howTo }),
4392
+ /* @__PURE__ */ jsxs5(Text7, { color: semantic.muted, children: [
4308
4393
  t("ui", "logAt"),
4309
4394
  " ",
4310
- getLogFilePath() ?? "~/.tacuchi-updater/logs/"
4395
+ compactPath(getLogFilePath() ?? "~/.tacuchi-updater/logs/", Math.min(process.stdout.columns ?? 100, 100) - 4 - t("ui", "logAt").length)
4311
4396
  ] }),
4312
- /* @__PURE__ */ jsx8(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx8(Text7, { color: semantic.muted, children: hasPackages ? t("ui", "detailHint") : t("ui", "summaryHint") }) })
4397
+ /* @__PURE__ */ jsx8(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx8(KeyHints, { commands }) })
4313
4398
  ] });
4314
4399
  }
4315
4400
 
4316
4401
  // src/screens/settings-screen.tsx
4317
4402
  import { useState as useState5 } from "react";
4318
- import { Box as Box7, Text as Text8 } from "ink";
4319
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
4403
+ import { Box as Box6, Text as Text8 } from "ink";
4404
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
4320
4405
  function SettingsScreen() {
4321
- const { state, toggleEnabled, setLang, closeSettings } = useMachine();
4406
+ const { state, toggleEnabled, setLang, closeSettings, quitApp } = useMachine();
4322
4407
  const ids = state.order;
4323
4408
  const [cursor, setCursor] = useState5(0);
4324
4409
  const clamped = Math.min(cursor, Math.max(0, ids.length - 1));
4325
- useSafeInput((input, key) => {
4326
- if (key.escape) closeSettings();
4327
- else if (key.downArrow || input === "j") setCursor((c) => Math.min(ids.length - 1, c + 1));
4328
- else if (key.upArrow || input === "k") setCursor((c) => Math.max(0, c - 1));
4329
- else if (input === " ") {
4410
+ const commands = useScreenKeys({
4411
+ back: closeSettings,
4412
+ down: () => setCursor((c) => Math.min(ids.length - 1, c + 1)),
4413
+ up: () => setCursor((c) => Math.max(0, c - 1)),
4414
+ mark: () => {
4330
4415
  const id = ids[clamped];
4331
4416
  if (id) toggleEnabled(id);
4332
- } else if (input === "l" || input === "L") {
4333
- setLang(state.config.language === "es" ? "en" : "es");
4334
- }
4417
+ },
4418
+ language: () => setLang(state.config.language === "es" ? "en" : "es"),
4419
+ quit: quitApp
4335
4420
  });
4336
- return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
4337
- /* @__PURE__ */ jsx9(StepHeader, { phase: "settings" }),
4338
- /* @__PURE__ */ jsxs7(Box7, { marginBottom: 1, children: [
4339
- /* @__PURE__ */ jsx9(Text8, { color: semantic.text, children: "Idioma / Language: " }),
4421
+ return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
4422
+ /* @__PURE__ */ jsxs6(Box6, { marginBottom: 1, children: [
4423
+ /* @__PURE__ */ jsxs6(Text8, { color: semantic.text, children: [
4424
+ t("ui", "language"),
4425
+ ": "
4426
+ ] }),
4340
4427
  /* @__PURE__ */ jsx9(Text8, { color: semantic.action, bold: true, children: state.config.language.toUpperCase() }),
4341
4428
  /* @__PURE__ */ jsx9(Text8, { color: semantic.muted, children: " (L)" })
4342
4429
  ] }),
4343
4430
  ids.map((id, i) => {
4344
4431
  const enabled = isManagerEnabled(state.config, id);
4345
4432
  const isCursor = i === clamped;
4346
- return /* @__PURE__ */ jsxs7(Box7, { children: [
4433
+ return /* @__PURE__ */ jsxs6(Box6, { children: [
4347
4434
  /* @__PURE__ */ jsx9(Text8, { color: isCursor ? semantic.action : colors.outline, children: isCursor ? `${g.cursor} ` : " " }),
4348
- /* @__PURE__ */ jsxs7(Text8, { color: enabled ? semantic.success : colors.outline, children: [
4349
- enabled ? "[on ]" : "[off]",
4435
+ /* @__PURE__ */ jsxs6(Text8, { color: enabled ? semantic.success : colors.outline, children: [
4436
+ t("ui", enabled ? "on" : "off"),
4350
4437
  " "
4351
4438
  ] }),
4352
4439
  /* @__PURE__ */ jsx9(Text8, { color: enabled ? semantic.text : semantic.muted, children: managerName(id) })
4353
4440
  ] }, id);
4354
4441
  }),
4355
- /* @__PURE__ */ jsx9(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text8, { color: semantic.muted, children: "Espacio activar/desactivar \xB7 L idioma \xB7 Esc volver" }) })
4442
+ /* @__PURE__ */ jsx9(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx9(KeyHints, { commands }) })
4356
4443
  ] });
4357
4444
  }
4358
4445
 
4359
4446
  // src/screens/detail.tsx
4360
4447
  import { useState as useState6 } from "react";
4361
- import { Box as Box8, Text as Text9 } from "ink";
4362
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
4448
+ import { Box as Box7, Text as Text9 } from "ink";
4449
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
4363
4450
  function glyphStatus(outcome) {
4364
4451
  switch (outcome) {
4365
4452
  case "upgraded":
@@ -4381,7 +4468,7 @@ function delta(from, to) {
4381
4468
  return `${from} ${g.arrow} ${to}`;
4382
4469
  }
4383
4470
  function DetailScreen() {
4384
- const { state, closeDetail } = useMachine();
4471
+ const { state, closeDetail, quitApp } = useMachine();
4385
4472
  const [offset, setOffset] = useState6(0);
4386
4473
  const summary = summarizeRun(state);
4387
4474
  const rows = [];
@@ -4400,96 +4487,177 @@ function DetailScreen() {
4400
4487
  }
4401
4488
  }
4402
4489
  const width = Math.min((process.stdout.columns ?? 90) - 4, 92);
4403
- const view = Math.max(6, (process.stdout.rows ?? 24) - 11);
4490
+ const view = Math.max(6, (process.stdout.rows ?? 24) - 11 - headerExtraRows());
4404
4491
  const maxOffset = Math.max(0, rows.length - view);
4405
4492
  const start = Math.min(offset, maxOffset);
4406
4493
  const visible = rows.slice(start, start + view);
4407
4494
  const nameWidth = Math.max(12, Math.min(32, width - 26));
4408
- useSafeInput((input, key) => {
4409
- if (input === "d" || input === "D") closeDetail();
4410
- else if (key.downArrow || input === "j") setOffset((o) => Math.min(maxOffset, o + 1));
4411
- else if (key.upArrow || input === "k") setOffset((o) => Math.max(0, o - 1));
4495
+ const commands = useScreenKeys({
4496
+ detail: closeDetail,
4497
+ back: closeDetail,
4498
+ down: () => setOffset((o) => Math.min(maxOffset, o + 1)),
4499
+ up: () => setOffset((o) => Math.max(0, o - 1)),
4500
+ quit: quitApp
4412
4501
  });
4413
- return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", children: [
4414
- /* @__PURE__ */ jsx10(StepHeader, { phase: state.phase }),
4502
+ return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
4415
4503
  /* @__PURE__ */ jsx10(Text9, { color: colors.outline, children: start > 0 ? `${g.scrollUp} ${start}` : " " }),
4416
4504
  rows.length === 0 ? /* @__PURE__ */ jsx10(Text9, { color: semantic.muted, children: t("ui", "noChanges") }) : visible.map(
4417
- (r, i) => r.kind === "manager" ? /* @__PURE__ */ jsx10(Text9, { color: semantic.muted, bold: true, children: managerName(r.managerId) }, `m:${r.managerId}:${i}`) : /* @__PURE__ */ jsxs8(Box8, { children: [
4418
- /* @__PURE__ */ jsx10(Box8, { width: 2, children: /* @__PURE__ */ jsx10(StatusGlyph, { status: glyphStatus(r.outcome ?? "unchanged") }) }),
4419
- /* @__PURE__ */ jsx10(Box8, { width: nameWidth, children: /* @__PURE__ */ jsx10(Text9, { color: semantic.text, wrap: "truncate-end", children: r.name }) }),
4420
- /* @__PURE__ */ jsx10(Box8, { flexGrow: 1, justifyContent: "flex-end", children: /* @__PURE__ */ jsx10(Text9, { color: semantic.muted, wrap: "truncate-end", children: r.right }) })
4505
+ (r, i) => r.kind === "manager" ? /* @__PURE__ */ jsx10(Text9, { color: semantic.muted, bold: true, children: managerName(r.managerId) }, `m:${r.managerId}:${i}`) : /* @__PURE__ */ jsxs7(Box7, { children: [
4506
+ /* @__PURE__ */ jsx10(Box7, { width: 2, children: /* @__PURE__ */ jsx10(StatusGlyph, { status: glyphStatus(r.outcome ?? "unchanged") }) }),
4507
+ /* @__PURE__ */ jsx10(Box7, { width: nameWidth, children: /* @__PURE__ */ jsx10(Text9, { color: semantic.text, wrap: "truncate-end", children: r.name }) }),
4508
+ /* @__PURE__ */ jsx10(Box7, { flexGrow: 1, justifyContent: "flex-end", children: /* @__PURE__ */ jsx10(Text9, { color: semantic.muted, wrap: "truncate-end", children: r.right }) })
4421
4509
  ] }, `p:${r.managerId}:${r.name}:${i}`)
4422
4510
  ),
4423
4511
  /* @__PURE__ */ jsx10(Text9, { color: colors.outline, children: start + visible.length < rows.length ? `${g.scrollDown} ${rows.length - start - visible.length}` : " " }),
4424
- /* @__PURE__ */ jsx10(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text9, { color: semantic.muted, children: t("ui", "detailBack") }) })
4512
+ /* @__PURE__ */ jsx10(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx10(KeyHints, { commands }) })
4425
4513
  ] });
4426
4514
  }
4427
4515
 
4428
- // src/app.tsx
4429
- import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
4430
- function Header({ sudoMode: sudoMode2 }) {
4431
- const { selfUpdate } = useMachine();
4432
- return /* @__PURE__ */ jsxs9(Box9, { justifyContent: "space-between", marginBottom: 1, children: [
4433
- /* @__PURE__ */ jsxs9(Box9, { children: [
4434
- /* @__PURE__ */ jsx11(Text10, { color: semantic.action, bold: true, children: "@tacuchi/updater" }),
4435
- /* @__PURE__ */ jsxs9(Text10, { color: colors.outline, children: [
4436
- " v",
4437
- getVersion()
4516
+ // src/components/step-header.tsx
4517
+ import { useSyncExternalStore } from "react";
4518
+ import { Box as Box8, Text as Text10 } from "ink";
4519
+
4520
+ // src/lib/platform.ts
4521
+ function getPlatform() {
4522
+ switch (process.platform) {
4523
+ case "darwin":
4524
+ return "macos";
4525
+ case "win32":
4526
+ return "windows";
4527
+ default:
4528
+ return "linux";
4529
+ }
4530
+ }
4531
+
4532
+ // src/components/step-header.tsx
4533
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
4534
+ var steps = { boot: 1, detecting: 1, scanning: 1, select: 2, confirm: 3, updating: 4 };
4535
+ function StepHeader() {
4536
+ const banner = shownBanner(useSyncExternalStore(subscribeBanner, bannerSnapshot));
4537
+ return banner ? /* @__PURE__ */ jsx11(BrandBanner, { image: banner }) : /* @__PURE__ */ jsx11(LineHeader, {});
4538
+ }
4539
+ var clip3 = (text, width) => text.length > width ? text.slice(0, Math.max(0, width - g.ellipsis.length)) + g.ellipsis : text;
4540
+ function BrandBanner({ image: image2 }) {
4541
+ const { state, selfUpdate } = useMachine();
4542
+ const textWidth = Math.min(process.stdout.columns ?? 100, 100) - 2 - 1 - image2.columns - 2;
4543
+ const step = steps[state.phase];
4544
+ const label = t("flow", state.phase === "boot" ? "detecting" : state.phase);
4545
+ const version = ` ${getVersion()}${selfUpdate ? ` ${g.arrow} ${selfUpdate.version}` : ""}`;
4546
+ const count = state.order.length;
4547
+ const detecting = count === 0 && (state.phase === "boot" || state.phase === "detecting");
4548
+ const managers = !detecting ? `${count} ${t("banner", count === 1 ? "managerOne" : "managerMany")}` : state.error ? "" : t("banner", "searching");
4549
+ const platform = t("banner", getPlatform()) + (managers ? ` ${g.separator} ${managers}` : "");
4550
+ const name = "tacuchi updater";
4551
+ return /* @__PURE__ */ jsxs8(Box8, { marginBottom: 1, children: [
4552
+ /* @__PURE__ */ jsx11(Box8, { flexDirection: "column", marginLeft: 1, width: image2.columns, flexShrink: 0, children: placeholderRows(image2.id, image2.columns, image2.rows).map((row, index) => /* @__PURE__ */ jsx11(Text10, { children: row }, index)) }),
4553
+ /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginLeft: 2, children: [
4554
+ /* @__PURE__ */ jsxs8(Text10, { children: [
4555
+ /* @__PURE__ */ jsx11(Text10, { bold: true, color: semantic.text, children: name }),
4556
+ /* @__PURE__ */ jsx11(Text10, { color: semantic.muted, children: clip3(version, Math.max(0, textWidth - name.length)) })
4438
4557
  ] }),
4439
- selfUpdate ? (
4440
- // `warning`, NOT `unknown`: el ámbar está reservado a «no se pudo
4441
- // determinar» (DES-001@r1) y reusarlo acá lo vuelve a significar dos cosas.
4442
- /* @__PURE__ */ jsxs9(Text10, { color: semantic.warning, children: [
4443
- " ",
4444
- "\u2192 v",
4445
- selfUpdate.version,
4446
- " \xB7 ",
4447
- selfUpdate.howTo
4448
- ] })
4449
- ) : null
4450
- ] }),
4451
- /* @__PURE__ */ jsx11(Text10, { color: sudoMode2 ? semantic.warning : colors.outline, children: sudoMode2 ? "SUDO" : `${process.platform}` })
4558
+ /* @__PURE__ */ jsx11(Text10, { color: semantic.muted, children: clip3(platform, textWidth) }),
4559
+ /* @__PURE__ */ jsx11(Text10, { color: semantic.muted, children: clip3(step ? `${t("flow", "step")} ${step}/4 ${g.separator} ${label}` : label, textWidth) })
4560
+ ] })
4561
+ ] });
4562
+ }
4563
+ function LineHeader() {
4564
+ const { state, selfUpdate } = useMachine();
4565
+ const width = Math.min(process.stdout.columns ?? 100, 100) - 2;
4566
+ const key = state.phase === "boot" ? "detecting" : state.phase;
4567
+ const label = t("flow", key);
4568
+ const step = steps[state.phase];
4569
+ let product = ` updater ${getVersion()}${selfUpdate ? ` ${g.arrow} ${selfUpdate.version}` : ""}`;
4570
+ let right = step ? `${t("flow", "step")} ${step}/4 ${g.separator} ${label}` : label;
4571
+ if (8 + product.length + right.length + 1 > width) product = product.replace(" updater", "");
4572
+ if (8 + product.length + right.length + 1 > width && step) right = `${step}/4 ${g.separator} ${label}`;
4573
+ const available = width - 8 - product.length - 1;
4574
+ if (right.length > available) right = right.slice(0, Math.max(0, available - g.ellipsis.length)) + g.ellipsis;
4575
+ const gap = " ".repeat(Math.max(1, width - 8 - product.length - right.length));
4576
+ const plainLogo = ASCII || process.env["NO_COLOR"] !== void 0;
4577
+ return /* @__PURE__ */ jsxs8(Box8, { marginBottom: 1, children: [
4578
+ /* @__PURE__ */ jsx11(Text10, { bold: true, color: semantic.text, children: "tacuchi" }),
4579
+ plainLogo ? /* @__PURE__ */ jsx11(Text10, { children: "_" }) : /* @__PURE__ */ jsx11(Text10, { color: terminalTheme === "light" ? semantic.text : semantic.logoFill, backgroundColor: terminalTheme === "light" ? semantic.logoFill : void 0, children: g.logo }),
4580
+ /* @__PURE__ */ jsxs8(Text10, { color: semantic.muted, children: [
4581
+ product,
4582
+ gap,
4583
+ right
4584
+ ] })
4452
4585
  ] });
4453
4586
  }
4587
+
4588
+ // src/components/line-output.tsx
4589
+ import { useEffect as useEffect4, useRef as useRef3 } from "react";
4590
+ function LineOutput({ write }) {
4591
+ const { state, selfUpdate } = useMachine();
4592
+ const emitted = useRef3(/* @__PURE__ */ new Set());
4593
+ useEffect4(() => {
4594
+ const once2 = (key, text) => {
4595
+ if (emitted.current.has(key)) return;
4596
+ emitted.current.add(key);
4597
+ write(text + "\n");
4598
+ };
4599
+ if (state.error) once2("error", `${t("ui", "detectionFailed")} ${state.error}`);
4600
+ for (const id of state.run.queue) {
4601
+ const entry = state.managers[id];
4602
+ if (!entry) continue;
4603
+ const result = entry.result;
4604
+ once2(`${id}:${entry.status}`, `${managerName(id)}: ${t("status", entry.status)}${result ? ` ${countText(result.upgraded, "upgraded")}, ${countText(result.failed, "failed")}` : ""}${entry.manualCommand ? ` ${entry.manualCommand}` : ""}`);
4605
+ }
4606
+ if (state.phase === "summary" || state.phase === "select" && state.order.every((id) => state.managers[id]?.outdated.length === 0)) {
4607
+ const result = summarizeRun(state);
4608
+ once2("summary", `${t("flow", "summary")}: ${summaryText(result)}`);
4609
+ if (selfUpdate) once2("self-update", selfUpdate.howTo);
4610
+ }
4611
+ }, [state, selfUpdate, write]);
4612
+ return null;
4613
+ }
4614
+
4615
+ // src/app.tsx
4616
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
4454
4617
  function PhaseRouter() {
4455
4618
  const { state } = useMachine();
4456
4619
  switch (state.phase) {
4457
4620
  case "boot":
4458
4621
  case "detecting":
4459
4622
  case "scanning":
4460
- return /* @__PURE__ */ jsx11(DetectScreen, {});
4623
+ return /* @__PURE__ */ jsx12(DetectScreen, {});
4461
4624
  case "select":
4462
- return /* @__PURE__ */ jsx11(SelectScreen, {});
4625
+ return /* @__PURE__ */ jsx12(SelectScreen, {});
4463
4626
  case "confirm":
4464
- return /* @__PURE__ */ jsx11(ConfirmScreen, {});
4627
+ return /* @__PURE__ */ jsx12(ConfirmScreen, {});
4465
4628
  case "updating":
4466
- return /* @__PURE__ */ jsx11(UpdateScreen, {});
4629
+ return /* @__PURE__ */ jsx12(UpdateScreen, {});
4467
4630
  case "summary":
4468
- return /* @__PURE__ */ jsx11(SummaryScreen, {});
4631
+ return /* @__PURE__ */ jsx12(SummaryScreen, {});
4469
4632
  case "detail":
4470
- return /* @__PURE__ */ jsx11(DetailScreen, {});
4633
+ return /* @__PURE__ */ jsx12(DetailScreen, {});
4471
4634
  case "settings":
4472
- return /* @__PURE__ */ jsx11(SettingsScreen, {});
4635
+ return /* @__PURE__ */ jsx12(SettingsScreen, {});
4473
4636
  default:
4474
4637
  return null;
4475
4638
  }
4476
4639
  }
4477
- function Shell({ sudoMode: sudoMode2 }) {
4478
- const { quitApp } = useMachine();
4479
- useSafeInput((input) => {
4480
- if (input === "q" || input === "Q") quitApp();
4481
- });
4640
+ function Shell() {
4641
+ const [, setSize] = useState7(0);
4642
+ useEffect5(() => {
4643
+ const resized = () => setSize((size) => size + 1);
4644
+ process.stdout.on("resize", resized);
4645
+ return () => {
4646
+ process.stdout.off("resize", resized);
4647
+ };
4648
+ }, []);
4482
4649
  return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 1, width: Math.min(process.stdout.columns ?? 100, 100), children: [
4483
- /* @__PURE__ */ jsx11(Header, { sudoMode: sudoMode2 }),
4484
- /* @__PURE__ */ jsx11(PhaseRouter, {})
4650
+ /* @__PURE__ */ jsx12(StepHeader, {}),
4651
+ /* @__PURE__ */ jsx12(PhaseRouter, {})
4485
4652
  ] });
4486
4653
  }
4487
4654
  function App({
4488
4655
  sudoMode: sudoMode2 = false,
4489
- nonInteractive: nonInteractive2 = false
4656
+ nonInteractive: nonInteractive2 = false,
4657
+ lineOutput: lineOutput2
4490
4658
  }) {
4491
4659
  const machine = useAppMachine(sudoMode2, nonInteractive2);
4492
- return /* @__PURE__ */ jsx11(MachineProvider, { value: machine, children: /* @__PURE__ */ jsx11(Shell, { sudoMode: sudoMode2 }) });
4660
+ return /* @__PURE__ */ jsx12(MachineProvider, { value: machine, children: lineOutput2 ? /* @__PURE__ */ jsx12(LineOutput, { write: lineOutput2 }) : /* @__PURE__ */ jsx12(Shell, {}) });
4493
4661
  }
4494
4662
 
4495
4663
  // src/lib/signals.ts
@@ -4519,29 +4687,13 @@ function answerSignal(route, effects) {
4519
4687
  }
4520
4688
 
4521
4689
  // src/cli.tsx
4522
- import { jsx as jsx12 } from "react/jsx-runtime";
4690
+ import { jsx as jsx13 } from "react/jsx-runtime";
4691
+ setLanguage(loadConfig().language);
4523
4692
  var args = process.argv.slice(2);
4524
4693
  var sudoRequested = args.includes("--sudo") || args.includes("-s");
4525
4694
  var isRoot = process.getuid?.() === 0;
4526
4695
  if (args.includes("--help") || args.includes("-h")) {
4527
- console.log(`
4528
- @tacuchi/updater \u2014 CLI para actualizar gestores de paquetes
4529
-
4530
- Uso:
4531
- updater Modo normal (sin permisos de admin)
4532
- updater --sudo Ejecutar con permisos de administrador
4533
- updater --help Mostrar esta ayuda
4534
-
4535
- Flags:
4536
- -s, --sudo Permite actualizar gestores que requieren admin
4537
- (softwareupdate, apt, dnf, pacman, snap)
4538
- -y, --yes, --all Modo no-interactivo: actualiza todo sin teclado
4539
- (autom\xE1tico cuando stdin no es un TTY / CI / pipe)
4540
- -h, --help Mostrar ayuda
4541
- -v, --version Mostrar versi\xF3n
4542
-
4543
- Tip: ejecuta siempre la \xFAltima versi\xF3n con npx @tacuchi/updater@latest
4544
- `);
4696
+ console.log(t("cli", "help"));
4545
4697
  process.exit(0);
4546
4698
  }
4547
4699
  if (args.includes("--version") || args.includes("-v")) {
@@ -4549,7 +4701,7 @@ if (args.includes("--version") || args.includes("-v")) {
4549
4701
  process.exit(0);
4550
4702
  }
4551
4703
  if (sudoRequested && !isRoot && process.platform !== "win32") {
4552
- console.log("\x1B[35m\xBB Modo SUDO: ingresa tu contrase\xF1a para continuar...\x1B[0m");
4704
+ console.log(t("cli", "sudoPrompt"));
4553
4705
  try {
4554
4706
  const scriptPath = process.argv[1] ?? "";
4555
4707
  const isDevMode = scriptPath.endsWith(".tsx") || scriptPath.endsWith(".ts");
@@ -4561,18 +4713,48 @@ if (sudoRequested && !isRoot && process.platform !== "win32") {
4561
4713
  });
4562
4714
  process.exit(result.exitCode ?? 0);
4563
4715
  } catch {
4564
- console.error("\x1B[31m\u2717 No se pudo autenticar sudo. Continuando sin permisos elevados.\x1B[0m");
4716
+ console.error(t("cli", "sudoFailure"));
4565
4717
  }
4566
4718
  }
4567
4719
  var elevated = await isElevated();
4568
4720
  if (process.platform === "win32" && sudoRequested && !elevated) {
4569
4721
  console.log(
4570
- "\x1B[33m\xBB En Windows --sudo no eleva. Abr\xED la terminal como Administrador (se detecta autom\xE1ticamente).\x1B[0m"
4722
+ t("cli", "windowsAdmin")
4571
4723
  );
4572
4724
  }
4573
4725
  var sudoMode = process.platform === "win32" ? elevated : isRoot || sudoRequested;
4574
4726
  var nonInteractive = !process.stdin.isTTY || args.includes("--yes") || args.includes("-y") || args.includes("--all");
4575
- var { unmount } = render(/* @__PURE__ */ jsx12(App, { sudoMode, nonInteractive }));
4727
+ var bannerWanted = !nonInteractive && bannerBlocker({
4728
+ env: process.env,
4729
+ stdoutTTY: process.stdout.isTTY === true,
4730
+ ascii: ASCII,
4731
+ columns: Math.min(process.stdout.columns ?? 0, 100),
4732
+ rows: process.stdout.rows ?? 0
4733
+ }) === null;
4734
+ var probe = await probeTerminal({ interactive: !nonInteractive, images: bannerWanted });
4735
+ setTerminalTheme(probe.theme);
4736
+ if (probe.images) {
4737
+ const piece = pickPiece(probe.theme, probe.themeKnown);
4738
+ const id = pickImageId();
4739
+ process.stdout.write(transmitImage(id, piece));
4740
+ configureBanner({ id, columns: piece.columns, rows: piece.rows });
4741
+ process.on("exit", () => {
4742
+ process.stdout.write(deleteImage(id));
4743
+ });
4744
+ }
4745
+ var redirected = !process.stdout.isTTY;
4746
+ var lineOutput = redirected ? (line) => {
4747
+ process.stdout.write(line);
4748
+ } : void 0;
4749
+ var sink = redirected ? new Writable({ write(_chunk, _encoding, done) {
4750
+ done();
4751
+ } }) : process.stdout;
4752
+ var app = /* @__PURE__ */ jsx13(App, { sudoMode, nonInteractive, lineOutput });
4753
+ var { unmount: inkUnmount, rerender } = render(app, { exitOnCtrlC: false, stdout: sink });
4754
+ var unmount = () => {
4755
+ if (retireBanner()) rerender(app);
4756
+ inkUnmount();
4757
+ };
4576
4758
  for (const route of signalRoutes(process.platform)) {
4577
4759
  process.on(
4578
4760
  route.signal,