hopdeck 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/bin/hopdeck.js +75 -13
- package/lib/i18n.js +4 -2
- package/lib/stats.js +79 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# Cambios
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.4.3
|
|
4
|
+
|
|
5
|
+
### Arreglado
|
|
6
|
+
- **Teclas repetidas al pie de la lista.** La fila de la lista repetía `n nueva`, `/ buscar` y `? ayuda`, que ya dice la barra de abajo (`[/] buscar [n] nueva …`). Ahora esa fila solo dice lo propio de la fila marcada: sobre un proyecto, `⏎ desplegar p fijar x ocultar`; sobre una conversación, `⏎ reanudar R renombrar a archivar`. También se quitaron los espacios que sobraban tras la última tecla y que hacían que se cortara con «…» aunque cupiera.
|
|
7
|
+
|
|
8
|
+
## 1.4.2
|
|
4
9
|
|
|
5
10
|
### Nuevo
|
|
11
|
+
- **Estadísticas de cada conversación en la fila del título**, a la derecha: `MSGS 2324 │ TOK 206.9M │ TOOLS 1249 │ opus`. Mensajes, tokens (entrada, salida y caché de cada mensaje de Claude), herramientas usadas y modelo; la rama de git sigue a la izquierda, junto al título. Salen en la vista previa al pasar el cursor y con el chat abierto. Si el panel es estrecho se quitan primero los campos menos importantes (TOOLS, luego el modelo). Se calculan en segundo plano (una conversación de 79 MB tarda unos 250 ms) y después solo se lee lo que Claude añade, como mucho cada 3 s.
|
|
12
|
+
- **Barra inferior con las teclas entre corchetes**, como `[/] buscar [n] nueva [Ctrl+P] saltar`. Cambia con el foco: con la lista activa muestra las teclas de letra, y con un chat abierto solo las F (`[F1] lista [F3] copiar texto [F4] ocultar lista [F5] saltar [F8] git [F9] tema`), porque las letras son de Claude. A la derecha, los chats abiertos y cuántos proyectos y chats hay; ese resumen se omite si no caben las teclas enteras.
|
|
6
13
|
- **La mascota de Hopdeck, un sapo naranja con auriculares.** Sale en la pantalla de inicio (el panel derecho cuando no hay ningún chat abierto), encima del texto y del mayor tamaño que quepa; si el terminal es pequeño o usas `NO_COLOR`, se queda el texto de siempre. También en la pantalla de carga y en el panel de tmux. Y con el comando `hopdeck mascot` (`--size small|normal|large`, `--plain` para dibujarla sin colores). Va dentro del programa, sin archivos de imagen ni Python; en el README hay una imagen (`docs/mascot.png`).
|
|
7
14
|
|
|
8
15
|
## 1.4.1
|
package/README.en.md
CHANGED
|
@@ -112,6 +112,8 @@ Every text box supports a cursor: `←` `→`, `Home`/`End`, `Delete`, and `Ctrl
|
|
|
112
112
|
|
|
113
113
|
With no chat open, the right pane shows the last messages of the selected conversation. With the mouse you only need to **hover** the list, no click needed.
|
|
114
114
|
|
|
115
|
+
On the title row, at the right, you get the conversation statistics: `MSGS` (messages), `TOK` (tokens: input, output and cache), `TOOLS` (tools used) and the model. They show in the preview and with the chat open, and on a narrow pane the least important ones are dropped first. They are computed in the background the first time, and afterwards only what Claude appends is read.
|
|
116
|
+
|
|
115
117
|
### Pick a folder
|
|
116
118
|
|
|
117
119
|
<picture>
|
package/README.md
CHANGED
|
@@ -112,6 +112,8 @@ En todas las cajas de texto puedes mover el cursor con `←` `→`, ir al princi
|
|
|
112
112
|
|
|
113
113
|
Sin ningún chat abierto, el panel derecho muestra los últimos mensajes de la conversación seleccionada. Con el ratón basta **pasar el cursor** por la lista, sin hacer clic.
|
|
114
114
|
|
|
115
|
+
En la fila del título, a la derecha, salen las estadísticas de la conversación: `MSGS` (mensajes), `TOK` (tokens: entrada, salida y caché), `TOOLS` (herramientas usadas) y el modelo. Aparecen tanto en la vista previa como con el chat abierto, y si el panel es estrecho se quitan primero los menos importantes. Se calculan en segundo plano la primera vez, y después solo se lee lo que Claude va añadiendo.
|
|
116
|
+
|
|
115
117
|
### Elegir una carpeta
|
|
116
118
|
|
|
117
119
|
<picture>
|
package/bin/hopdeck.js
CHANGED
|
@@ -14,6 +14,7 @@ const readline = require('readline');
|
|
|
14
14
|
const { LANG, T } = require('../lib/i18n');
|
|
15
15
|
const { TRUE, NOCOL, LIGHT, setTheme, isLight, fg, bg, R, C, cw, strW, fit, clean } = require('../lib/style');
|
|
16
16
|
const mascot = require('../lib/mascot');
|
|
17
|
+
const stats = require('../lib/stats');
|
|
17
18
|
const { baseName, tidy, home, shortPath, fold, queryWords, matchWords, fuzzy, wrapText } = require('../lib/text');
|
|
18
19
|
const hist = require('../lib/history');
|
|
19
20
|
const { CONFIG_DIR, CACHE_FILE, textOf, isType, cacheLoad, cacheSave, readSession, decodeDir, projectDirs, buildProject, beginScan, endScan } = hist;
|
|
@@ -479,12 +480,13 @@ function frameTree(W, H) {
|
|
|
479
480
|
lines.push(fit([[' ⏎', C.accent], [' ' + T.k.open + ' ', C.dim], S.searching ? ['Tab', C.accent] : ['/', C.accent], S.searching ? [' ' + (deepOn ? '◉ ' : '○ ') + T.deep + ' ', deepOn ? C.ok : C.dim] : [' ' + T.kEdit + ' ', C.dim],
|
|
480
481
|
['esc', C.accent], [' ' + (S.searching ? T.kEsc : T.kClear), C.dim]], W));
|
|
481
482
|
} else {
|
|
483
|
+
// solo lo que la barra de abajo no dice: qué hace ⏎ en la fila marcada y sus teclas propias (n, /, ?, q… ya están abajo)
|
|
482
484
|
const k = T.k, segs = [[' ', '']];
|
|
483
|
-
const keys = !cur ? [['⏎', k.open]
|
|
484
|
-
: cur.t === 'p' ? [['⏎', T.kUnfold], ['
|
|
485
|
-
: cur.t === 's' ? [['⏎', k.resume], ['R', T.kRename], ['
|
|
486
|
-
: [['⏎', k.open]
|
|
487
|
-
|
|
485
|
+
const keys = !cur ? [['⏎', k.open]]
|
|
486
|
+
: cur.t === 'p' ? [['⏎', T.kUnfold], ['p', T.kPin], ['x', T.kHide]]
|
|
487
|
+
: cur.t === 's' ? [['⏎', k.resume], ['R', T.kRename], ['a', T.kArchive]]
|
|
488
|
+
: [['⏎', k.open]];
|
|
489
|
+
keys.forEach(([key, desc], i) => segs.push([key, C.accent], [' ' + desc + (i < keys.length - 1 ? ' ' : ''), C.dim])); // sin espacios tras la última: contarían para el ancho y forzarían el «…»
|
|
488
490
|
lines.push(fit(segs, W));
|
|
489
491
|
}
|
|
490
492
|
return lines;
|
|
@@ -1380,9 +1382,62 @@ function previewRows(msgs, width, height, info = '') {
|
|
|
1380
1382
|
}
|
|
1381
1383
|
|
|
1382
1384
|
/** Título del panel del chat: proyecto › conversación ⎇ rama */
|
|
1383
|
-
|
|
1385
|
+
// ── Estadísticas de la conversación (mensajes, tokens, herramientas, modelo), en la fila del título del chat ──
|
|
1386
|
+
const STATS = new Map(); // archivo → { st, sum, at, busy, m, z }; solo se guardan las últimas conversaciones vistas
|
|
1387
|
+
let sidIdx = { src: null, map: new Map() };
|
|
1388
|
+
/** Archivo de una conversación por su id (la lista se recorre una vez por escaneo). */
|
|
1389
|
+
function fileOfSid(sid) {
|
|
1390
|
+
if (sidIdx.src !== S.projects) sidIdx = { src: S.projects, map: new Map(S.projects.flatMap((p) => p.sessions.map((q) => [q.id, q.file]))) };
|
|
1391
|
+
return sidIdx.map.get(sid) || null;
|
|
1392
|
+
}
|
|
1393
|
+
const chatFile = (x) => x.file || (x.sid ? fileOfSid(x.sid) : null);
|
|
1394
|
+
/**
|
|
1395
|
+
* Resumen de la conversación de ese archivo, o null mientras se lee la primera vez (undefined si no hay archivo). Se calcula en segundo
|
|
1396
|
+
* plano y, si el archivo crece (el chat abierto), se actualiza leyendo solo lo nuevo, como mucho cada 3 s.
|
|
1397
|
+
*/
|
|
1398
|
+
function chatStats(file) {
|
|
1399
|
+
if (!file) return undefined;
|
|
1400
|
+
let e = STATS.get(file);
|
|
1401
|
+
if (e) { STATS.delete(file); STATS.set(file, e); } // los más recientes al final
|
|
1402
|
+
else { e = { st: stats.newState(), sum: null, at: 0, busy: false, m: -1, z: -1 }; STATS.set(file, e); if (STATS.size > 12) STATS.delete(STATS.keys().next().value); }
|
|
1403
|
+
const now = Date.now();
|
|
1404
|
+
if (!e.busy && now - e.at > (e.sum ? 3000 : 0)) {
|
|
1405
|
+
e.at = now;
|
|
1406
|
+
let s; try { s = fs.statSync(file); } catch { return e.sum; }
|
|
1407
|
+
if (!e.sum || s.size !== e.z || s.mtimeMs !== e.m) {
|
|
1408
|
+
e.busy = true; e.z = s.size; e.m = s.mtimeMs;
|
|
1409
|
+
stats.update(e.st, file).then(() => { e.sum = stats.summary(e.st); }, () => { e.sum = e.sum || stats.summary(e.st); }).finally(() => { e.busy = false; if (active) scheduleRender(); });
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
return e.sum;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
/** Campos de las estadísticas, de más a menos importante: se muestran los que quepan, siempre en este orden: MSGS │ TOK │ TOOLS │ modelo. */
|
|
1416
|
+
function statFields(sum) {
|
|
1417
|
+
if (sum === undefined) return [];
|
|
1418
|
+
if (sum === null) return [{ t: '…', c: C.dim, o: 0 }];
|
|
1419
|
+
return [
|
|
1420
|
+
{ t: 'MSGS ' + sum.msgs, c: C.accent, o: 0 },
|
|
1421
|
+
sum.tok ? { t: 'TOK ' + stats.fmtNum(sum.tok), c: C.ok, o: 1 } : null,
|
|
1422
|
+
sum.model ? { t: stats.modelShort(sum.model), c: C.brand + C.bold, o: 3 } : null,
|
|
1423
|
+
sum.tools ? { t: 'TOOLS ' + sum.tools, c: C.warn, o: 2 } : null,
|
|
1424
|
+
].filter(Boolean);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
/** Título del panel del chat: proyecto › conversación ⎇ rama, y a la derecha MSGS │ TOK │ TOOLS │ modelo (los que quepan). */
|
|
1428
|
+
function headerRow(sh, width, sum) {
|
|
1384
1429
|
if (!sh) return ' '.repeat(width);
|
|
1385
|
-
|
|
1430
|
+
const left = [[' ' + sh.project, C.accent + C.bold], [' › ' + sh.title, C.text], [sh.branch ? ' ⎇ ' + sh.branch : '', C.dim]];
|
|
1431
|
+
const leftW = left.reduce((a, [t]) => a + strW(t), 0), budget = width - Math.min(leftW, Math.floor(width * 0.5)) - 1; // el título puede acortarse, pero no desaparecer
|
|
1432
|
+
const chosen = []; let used = 0;
|
|
1433
|
+
for (const f of statFields(sum)) { const w = strW(f.t) + (chosen.length ? 3 : 0); if (used + w > budget) break; chosen.push(f); used += w; } // en orden de importancia
|
|
1434
|
+
if (!chosen.length) return fit(left, width);
|
|
1435
|
+
chosen.sort((a, b) => a.o - b.o);
|
|
1436
|
+
const right = [];
|
|
1437
|
+
chosen.forEach((f, i) => { if (i) right.push([' │ ', C.faint]); right.push([f.t, f.c]); });
|
|
1438
|
+
right.push([' ', '']);
|
|
1439
|
+
const rw = right.reduce((a, [t]) => a + strW(t), 0);
|
|
1440
|
+
return fit(left, width - rw) + fit(right, rw);
|
|
1386
1441
|
}
|
|
1387
1442
|
|
|
1388
1443
|
function renderEmbed() {
|
|
@@ -1395,7 +1450,7 @@ function renderEmbed() {
|
|
|
1395
1450
|
const selEnt = !sh && !S.help && !S.qs ? flatList()[S.c] : null;
|
|
1396
1451
|
const pvMsgs = selEnt && selEnt.t === 's' ? previewFor(selEnt.s) : null;
|
|
1397
1452
|
const pvRows = pvMsgs && pvMsgs.length ? previewRows(pvMsgs, rw, th, T.prevInfo(ago(selEnt.s.mtime), pvMsgs.length)) : null;
|
|
1398
|
-
const hdr = sh || (selEnt && selEnt.t === 's' ? { project: selEnt.p.name, title: selEnt.s.title, branch: gitBranch(selEnt.p.cwd) } : null);
|
|
1453
|
+
const hdr = sh || (selEnt && selEnt.t === 's' ? { project: selEnt.p.name, title: selEnt.s.title, branch: gitBranch(selEnt.p.cwd), file: selEnt.s.file } : null);
|
|
1399
1454
|
const gRows = E.gallery ? galleryRows(rw, th) : null;
|
|
1400
1455
|
const hv = !E.gallery && sh && sh.ready && E.hover && !E.hover.g.loading && E.hover.g.images.length ? E.hover : null;
|
|
1401
1456
|
const pop = hv ? hoverPopup(hv, rw, th) : null;
|
|
@@ -1411,17 +1466,24 @@ function renderEmbed() {
|
|
|
1411
1466
|
const right = gRows ? (y === 0 ? fit([[' ' + E.gallery.project, C.accent + C.bold], [' › ' + E.gallery.title, C.text],
|
|
1412
1467
|
[E.gallery.images.length ? ` ▣ ${E.gallery.i + 1}/${E.gallery.images.length}` + (gd ? ` · ${gd.w}×${gd.h}` : '') : '', C.dim]], rw)
|
|
1413
1468
|
: y === 1 ? C.faint + '─'.repeat(rw) + R : gRows[ty])
|
|
1414
|
-
: y === 0 ? headerRow(hdr, rw) : y === 1 ? C.faint + '─'.repeat(rw) + R
|
|
1469
|
+
: y === 0 ? headerRow(hdr, rw, hdr ? chatStats(chatFile(hdr)) : undefined) : y === 1 ? C.faint + '─'.repeat(rw) + R
|
|
1415
1470
|
: sh && sh.ready ? (popRow(ty) || termRow(sh.term, ty, rw, selRange(ty, rw))) : sh ? loaderRow(ty, rw, th, sh.title) : pvRows ? pvRows[ty] : idleRow(ty, rw, th);
|
|
1416
1471
|
rowsOut.push((left ? (left[y] || ' '.repeat(SW)) + div : '') + right + (gitR ? gdiv + gitR[y] : ''));
|
|
1417
1472
|
}
|
|
1418
1473
|
const live = E.sessions.size;
|
|
1419
|
-
const k = (key, d) => [[key, C.accent], [' ' + d + '
|
|
1474
|
+
const k = (key, d) => [['[' + key + ']', C.accent + C.bold], [' ' + d + ' ', C.text]]; // [tecla] descripción
|
|
1420
1475
|
const sb = sh && sh.ready ? sh.term.buffer.active : null;
|
|
1421
1476
|
const back = sb ? sb.baseY - sb.viewportY : 0;
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
[
|
|
1477
|
+
// las teclas cambian con el foco: en el chat, las letras son de Claude y solo valen las F; en la lista valen las letras
|
|
1478
|
+
const keys = E.focus === 'right' && sh
|
|
1479
|
+
? [...k('F1', T.barList), ...k('F3', E.mouse ? T.bar4 : T.bar5), ...k('F4', E.hideSide ? T.bar7 : T.bar6), ...k('F5', T.barJump), ...k('F8', T.bar8), ...k('F9', T.barTheme)]
|
|
1480
|
+
: [...k('/', T.k.find), ...k('n', T.k.neu), ...k('Ctrl+P', T.barJump), ...k('b', T.bar8), ...k('t', T.barTheme), ...k('?', T.kHelp), ...k('q', T.k.quit)];
|
|
1481
|
+
// a la derecha: los chats abiertos y cuántos proyectos y chats hay (se omiten si no caben)
|
|
1482
|
+
const stat = [[live ? '● ' + live + ' ' : '', C.ok], [T.barCount(S.projects.length, S.projects.reduce((a, p) => a + p.sessions.length, 0)), C.dim], [' ', '']];
|
|
1483
|
+
const statW = stat.reduce((a, [t]) => a + strW(t), 0), keysW = keys.reduce((a, [t]) => a + strW(t), 0) + strW(E.note ? E.note.t : '') + 8;
|
|
1484
|
+
const full = W - statW >= keysW; // el resumen solo sale si las teclas caben enteras
|
|
1485
|
+
const barL = fit([[' ', ''], [E.note ? E.note.t + ' ' : '', C.ok], [back > 0 ? T.up(back, sb && sb.baseY ? Math.round((100 * sb.viewportY) / sb.baseY) : -1) + ' ' : '', C.warn], ...keys], full ? W - statW : W);
|
|
1486
|
+
rowsOut.push(full ? barL + fit(stat, statW) : barL);
|
|
1425
1487
|
const changes = diffRows(rowsOut);
|
|
1426
1488
|
// imagen real (Sixel) sobre el hueco del cuadro: se dibuja al aparecer y se repite si algo reescribe esas filas (con un mínimo de 150 ms entre dibujos)
|
|
1427
1489
|
let sx = '';
|
package/lib/i18n.js
CHANGED
|
@@ -18,7 +18,7 @@ const T = {
|
|
|
18
18
|
imgNoPrev: 'No se puede previsualizar este formato', imgHint: '← → navegar o abrir en el visor esc cerrar', imgFolder: 'Imágenes abiertas en el visor',
|
|
19
19
|
more: (n) => `mostrar ${n} más…`, busyRename: 'Cierra la conversación antes de renombrarla', renameLbl: 'nombre',
|
|
20
20
|
copied: (n) => `Copiado (${n} caracteres)`, archMsg: 'Archivada (H para verlas)', unarchMsg: 'Desarchivada', qsHint: 'saltar a cualquier conversación',
|
|
21
|
-
prevHint: '⏎ reanudar esta conversación', bar8: 'git', gitNone: 'Elige un proyecto', gitNoRepo: 'Esta carpeta no es un repositorio git', gitMissing: 'git no está instalado', gitErr: 'No se pudo leer el repositorio', gitClean: 'sin cambios', gitDirty: (n) => (n === 1 ? '1 cambio sin guardar' : `${n} cambios sin guardar`), gitMore: (n) => `… y ${n} más`, gitBranches: 'Ramas recientes', gitActivity: 'Actividad de ramas', gitNoActivity: 'Sin cambios de rama', gitFrom: 'desde', gitNarrow: (n) => `Terminal estrecha: el panel de git necesita ${n} columnas`, gitOnlyEmbed: 'El panel de git solo está en el terminal integrado', prevInfo: (a, n) => `${a === 'ahora' ? 'ahora mismo' : 'hace ' + a} · últimos ${n} mensajes`, kUnfold: 'desplegar', kRename: 'renombrar', kPin: 'fijar', kHelp: 'ayuda', noPrev: 'Sin mensajes para mostrar',
|
|
21
|
+
prevHint: '⏎ reanudar esta conversación', bar8: 'git', gitNone: 'Elige un proyecto', gitNoRepo: 'Esta carpeta no es un repositorio git', gitMissing: 'git no está instalado', gitErr: 'No se pudo leer el repositorio', gitClean: 'sin cambios', gitDirty: (n) => (n === 1 ? '1 cambio sin guardar' : `${n} cambios sin guardar`), gitMore: (n) => `… y ${n} más`, gitBranches: 'Ramas recientes', gitActivity: 'Actividad de ramas', gitNoActivity: 'Sin cambios de rama', gitFrom: 'desde', gitNarrow: (n) => `Terminal estrecha: el panel de git necesita ${n} columnas`, gitOnlyEmbed: 'El panel de git solo está en el terminal integrado', prevInfo: (a, n) => `${a === 'ahora' ? 'ahora mismo' : 'hace ' + a} · últimos ${n} mensajes`, kUnfold: 'desplegar', kRename: 'renombrar', kPin: 'fijar', kHelp: 'ayuda', kArchive: 'archivar', kHide: 'ocultar', noPrev: 'Sin mensajes para mostrar',
|
|
22
22
|
bar6: 'ocultar lista', bar7: 'mostrar lista', deep: 'contenido', pathPrompt: 'nombre de la nueva carpeta', mkIn: 'se crea en', fbTitle: 'Elegir carpeta', fbHere: 'Abrir chat aquí', fbNew: 'Nueva carpeta aquí…', fbUp: 'Subir un nivel', fbProj: 'proyecto', fbHint: '⏎ entrar · ␣ abrir · / buscar · . ocultas', fbDrives: 'Este equipo', fbRecent: 'reciente', hoverMiss: (n) => `[Image #${n}]: aún no está en el historial`, fbEmpty: 'Sin subcarpetas', badId: 'Identificador de sesión no válido',
|
|
23
23
|
imgClickHint: 'clic: abrir en grande', imgOpened: (n) => `[Image #${n}] abierta en el visor de imágenes`,
|
|
24
24
|
unknownCmd: (c) => `Comando desconocido: "${c}"`, didYouMean: (s) => `¿Quisiste decir "${s}"?`, cmdList: 'Comandos: hopdeck shortcut on|off · theme light|dark|auto · mascot · uninstall · doctor · help (y --list, --version).\nLas opciones de claude (por ejemplo --model opus) se pasan tal cual: hopdeck --model opus',
|
|
@@ -44,6 +44,7 @@ const T = {
|
|
|
44
44
|
'c F6 cerrar el chat abierto', 'i F7 ver imágenes del chat', 'R a renombrar / archivar', 'Ctrl+P F5 saltar a cualquier chat', '[ ] ancho de la lista', 'r recargar',
|
|
45
45
|
'F1 F2 foco lista / chat', 'F3 copiar texto (ratón)', 'F4 ocultar la lista', 'b F8 panel de git', 't F9 tema claro / oscuro', '⠋ ✔ ● trabajando · terminó · abierta', 'q salir'],
|
|
46
46
|
bar4: 'copiar texto', bar5: 'ratón', up: (n, pct) => `↑ ${n} líneas${pct >= 0 ? ` (${pct}%)` : ''} · PgDn/End`, loading: 'Cargando proyectos', opening: 'Abriendo conversación', close: 'cerrar', idle1: 'Elige una conversación', idle2: 'Usa ↑↓ y ⏎ en el panel izquierdo',
|
|
47
|
+
barList: 'lista', barJump: 'saltar', barTheme: 'tema', barCount: (p, c) => `${p} ${p === 1 ? 'proyecto' : 'proyectos'} · ${c} ${c === 1 ? 'chat' : 'chats'}`,
|
|
47
48
|
idle3: 'F1 proyectos · F2 chat', bar1: 'proyectos', bar2: 'chat', bar3: 'minimizar',
|
|
48
49
|
selHint: 'Ctrl+C o clic derecho: copiar · Esc: quitar la selección',
|
|
49
50
|
searchPh: 'buscar conversación o proyecto…', found: (n) => `${n} ${n === 1 ? 'resultado' : 'resultados'}`, noRes: (q) => `Sin resultados para «${q}»`,
|
|
@@ -65,7 +66,7 @@ const T = {
|
|
|
65
66
|
imgNoPrev: 'This format cannot be previewed', imgHint: '← → browse o open in viewer esc close', imgFolder: 'Images opened in the viewer',
|
|
66
67
|
more: (n) => `show ${n} more…`, busyRename: 'Close the conversation before renaming it', renameLbl: 'name',
|
|
67
68
|
copied: (n) => `Copied (${n} chars)`, archMsg: 'Archived (H to show)', unarchMsg: 'Unarchived', qsHint: 'jump to any conversation',
|
|
68
|
-
prevHint: '⏎ resume this conversation', bar8: 'git', gitNone: 'Pick a project', gitNoRepo: 'This folder is not a git repository', gitMissing: 'git is not installed', gitErr: 'Could not read the repository', gitClean: 'clean', gitDirty: (n) => (n === 1 ? '1 uncommitted change' : `${n} uncommitted changes`), gitMore: (n) => `… and ${n} more`, gitBranches: 'Recent branches', gitActivity: 'Branch activity', gitNoActivity: 'No branch changes', gitFrom: 'from', gitNarrow: (n) => `Terminal too narrow: the git panel needs ${n} columns`, gitOnlyEmbed: 'The git panel is only in the built-in terminal', prevInfo: (a, n) => `${a === 'now' ? 'just now' : a + ' ago'} · last ${n} messages`, kUnfold: 'unfold', kRename: 'rename', kPin: 'pin', kHelp: 'help', noPrev: 'No messages to show',
|
|
69
|
+
prevHint: '⏎ resume this conversation', bar8: 'git', gitNone: 'Pick a project', gitNoRepo: 'This folder is not a git repository', gitMissing: 'git is not installed', gitErr: 'Could not read the repository', gitClean: 'clean', gitDirty: (n) => (n === 1 ? '1 uncommitted change' : `${n} uncommitted changes`), gitMore: (n) => `… and ${n} more`, gitBranches: 'Recent branches', gitActivity: 'Branch activity', gitNoActivity: 'No branch changes', gitFrom: 'from', gitNarrow: (n) => `Terminal too narrow: the git panel needs ${n} columns`, gitOnlyEmbed: 'The git panel is only in the built-in terminal', prevInfo: (a, n) => `${a === 'now' ? 'just now' : a + ' ago'} · last ${n} messages`, kUnfold: 'unfold', kRename: 'rename', kPin: 'pin', kHelp: 'help', kArchive: 'archive', kHide: 'hide', noPrev: 'No messages to show',
|
|
69
70
|
bar6: 'hide list', bar7: 'show list', deep: 'content', pathPrompt: 'new folder name', mkIn: 'created in', fbTitle: 'Pick a folder', fbHere: 'Open chat here', fbNew: 'New folder here…', fbUp: 'Go up', fbProj: 'project', fbHint: '⏎ enter · ␣ open · / find · . hidden', fbDrives: 'This PC', fbRecent: 'recent', hoverMiss: (n) => `[Image #${n}]: not in the history yet`, fbEmpty: 'No subfolders', badId: 'Invalid session id',
|
|
70
71
|
imgClickHint: 'click: open full size', imgOpened: (n) => `[Image #${n}] opened in the image viewer`,
|
|
71
72
|
unknownCmd: (c) => `Unknown command: "${c}"`, didYouMean: (s) => `Did you mean "${s}"?`, cmdList: 'Commands: hopdeck shortcut on|off · theme light|dark|auto · mascot · uninstall · doctor · help (and --list, --version).\nclaude options (for example --model opus) are passed through as they are: hopdeck --model opus',
|
|
@@ -91,6 +92,7 @@ const T = {
|
|
|
91
92
|
'c F6 close the open chat', 'i F7 view the chat images', 'R a rename / archive', 'Ctrl+P F5 jump to any chat', '[ ] list width', 'r reload',
|
|
92
93
|
'F1 F2 focus list / chat', 'F3 copy text (mouse)', 'F4 hide the list', 'b F8 git panel', 't F9 light / dark theme', '⠋ ✔ ● working · done · open', 'q quit'],
|
|
93
94
|
bar4: 'copy text', bar5: 'mouse', up: (n, pct) => `↑ ${n} lines${pct >= 0 ? ` (${pct}%)` : ''} · PgDn/End`, loading: 'Loading projects', opening: 'Opening conversation', close: 'close', idle1: 'Pick a conversation', idle2: 'Use ↑↓ and ⏎ in the left pane',
|
|
95
|
+
barList: 'list', barJump: 'jump', barTheme: 'theme', barCount: (p, c) => `${p} ${p === 1 ? 'project' : 'projects'} · ${c} ${c === 1 ? 'chat' : 'chats'}`,
|
|
94
96
|
idle3: 'F1 projects · F2 chat', bar1: 'projects', bar2: 'chat', bar3: 'minimize',
|
|
95
97
|
selHint: 'Ctrl+C or right click: copy · Esc: clear the selection',
|
|
96
98
|
searchPh: 'search conversation or project…', found: (n) => `${n} ${n === 1 ? 'result' : 'results'}`, noRes: (q) => `No results for “${q}”`,
|
package/lib/stats.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Estadísticas de una conversación (mensajes, tokens, herramientas, modelo) sacadas de su archivo .jsonl. Claude Code solo añade
|
|
3
|
+
// líneas al final, así que se lee todo una vez y, cuando el archivo crece, únicamente lo que se añadió. Los archivos llegan a pesar
|
|
4
|
+
// decenas de MB: se lee por bloques y se cede el control entre ellos para no congelar la interfaz.
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
const newState = () => ({ pos: 0, carry: Buffer.alloc(0), users: 0, asst: new Map(), anon: 0, anonTok: 0, tools: new Set(), anonTools: 0, model: '' });
|
|
8
|
+
|
|
9
|
+
const num = (v) => (Number.isFinite(v) && v > 0 ? v : 0);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Suma una línea del archivo. Las de la conversación empiezan por {"parentUuid" y llevan el rol dentro de "message", al principio:
|
|
13
|
+
* con eso basta para saber si es de usuario o de Claude (el "type" de la línea va al final en las de Claude). Solo se lee entera
|
|
14
|
+
* la línea de Claude; las de usuario con imágenes miden cientos de KB y no hace falta leerlas.
|
|
15
|
+
*/
|
|
16
|
+
function feed(st, head, full) {
|
|
17
|
+
if (!head.startsWith('{"parentUuid"')) return; // otras líneas: títulos, adjuntos, copias de peticiones…
|
|
18
|
+
const m = /"message":\{[^{}]{0,240}?"role":"(user|assistant)"/.exec(head);
|
|
19
|
+
if (!m) return;
|
|
20
|
+
if (m[1] === 'user') { if (!head.includes('"isMeta":true') && !head.includes('"isSidechain":true')) st.users++; return; }
|
|
21
|
+
let j; try { j = JSON.parse(full()); } catch { return; }
|
|
22
|
+
const msg = j && j.message; if (!msg) return;
|
|
23
|
+
if (typeof msg.model === 'string' && msg.model && !msg.model.startsWith('<')) st.model = msg.model; // «<synthetic>» no es un modelo
|
|
24
|
+
const u = msg.usage || {};
|
|
25
|
+
const cur = { i: num(u.input_tokens), o: num(u.output_tokens), cc: num(u.cache_creation_input_tokens), cr: num(u.cache_read_input_tokens) };
|
|
26
|
+
// Claude Code escribe un mensaje en varias líneas (una por bloque) repitiendo el uso: cada mensaje cuenta una vez, con el mayor valor visto
|
|
27
|
+
if (msg.id) {
|
|
28
|
+
const prev = st.asst.get(msg.id);
|
|
29
|
+
st.asst.set(msg.id, prev ? { i: Math.max(prev.i, cur.i), o: Math.max(prev.o, cur.o), cc: Math.max(prev.cc, cur.cc), cr: Math.max(prev.cr, cur.cr) } : cur);
|
|
30
|
+
} else { st.anon++; st.anonTok += cur.i + cur.o + cur.cc + cur.cr; }
|
|
31
|
+
if (Array.isArray(msg.content)) for (const b of msg.content) if (b && b.type === 'tool_use') { if (b.id) st.tools.add(b.id); else st.anonTools++; }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Lee lo que se haya añadido al archivo desde la última vez. */
|
|
35
|
+
async function update(st, file) {
|
|
36
|
+
const fh = await fs.promises.open(file, 'r');
|
|
37
|
+
try {
|
|
38
|
+
const { size } = await fh.stat();
|
|
39
|
+
if (size < st.pos) Object.assign(st, newState()); // el archivo se reescribió más corto: se empieza de nuevo
|
|
40
|
+
const CHUNK = 2 * 1024 * 1024;
|
|
41
|
+
while (st.pos < size) {
|
|
42
|
+
const buf = Buffer.alloc(Math.min(CHUNK, size - st.pos));
|
|
43
|
+
const { bytesRead } = await fh.read(buf, 0, buf.length, st.pos);
|
|
44
|
+
if (!bytesRead) break;
|
|
45
|
+
st.pos += bytesRead;
|
|
46
|
+
const data = st.carry.length ? Buffer.concat([st.carry, buf.subarray(0, bytesRead)]) : buf.subarray(0, bytesRead);
|
|
47
|
+
let start = 0, nl;
|
|
48
|
+
while ((nl = data.indexOf(10, start)) >= 0) {
|
|
49
|
+
const s = start, e = nl;
|
|
50
|
+
feed(st, data.toString('utf8', s, Math.min(e, s + 700)), () => data.toString('utf8', s, e));
|
|
51
|
+
start = nl + 1;
|
|
52
|
+
}
|
|
53
|
+
st.carry = data.subarray(start); // la última línea, si aún no está completa
|
|
54
|
+
await new Promise((r) => setImmediate(r));
|
|
55
|
+
}
|
|
56
|
+
} finally { await fh.close(); }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Resumen: { msgs, tok, tools, model }. tok suma entrada, salida y caché de cada mensaje de Claude. */
|
|
60
|
+
function summary(st) {
|
|
61
|
+
let tok = st.anonTok;
|
|
62
|
+
for (const u of st.asst.values()) tok += u.i + u.o + u.cc + u.cr;
|
|
63
|
+
return { msgs: st.users + st.asst.size + st.anon, tok, tools: st.tools.size + st.anonTools, model: st.model };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 1234 → «1.2K», 206900000 → «206.9M». */
|
|
67
|
+
function fmtNum(n) {
|
|
68
|
+
if (n < 1000) return String(n);
|
|
69
|
+
for (const [div, s] of [[1e9, 'B'], [1e6, 'M'], [1e3, 'K']]) if (n >= div) return (n / div).toFixed(1).replace(/\.0$/, '') + s;
|
|
70
|
+
return String(n);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** «claude-opus-4-5-20251101» → «opus». */
|
|
74
|
+
function modelShort(model) {
|
|
75
|
+
const m = /(opus|sonnet|haiku|fable)/i.exec(model || '');
|
|
76
|
+
return m ? m[1].toLowerCase() : String(model || '').replace(/^claude-/, '').replace(/-\d{8}$/, '').slice(0, 14);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = { newState, update, summary, feed, fmtNum, modelShort };
|
package/package.json
CHANGED