hopdeck 1.2.3 → 1.2.5
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 +14 -0
- package/README.en.md +4 -3
- package/README.md +4 -3
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/bin/hopdeck.js +90 -22
- package/lib/i18n.js +2 -0
- package/lib/sixel.js +90 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Cambios
|
|
2
2
|
|
|
3
|
+
## 1.2.5
|
|
4
|
+
|
|
5
|
+
### Cambiado
|
|
6
|
+
- **En Linux y macOS el terminal integrado es ahora el modo por defecto**, también con `tmux` instalado, para que la vista previa al pasar el cursor y las imágenes funcionen igual que en Windows. El modo tmux sigue disponible con `HOPDECK_TMUX=1` y se usa solo si el terminal integrado no está disponible.
|
|
7
|
+
- **La vista previa de imagen es más pequeña** (como mucho 36×9 celdas): es una vista rápida, no un visor. Para verla en grande, clic sobre `[Image #N]`.
|
|
8
|
+
- **En Windows Terminal el Sixel se activa sin esperar la respuesta del terminal**, que no siempre atraviesa ConPTY. `HOPDECK_SIXEL=0` lo apaga.
|
|
9
|
+
- **Logotipo con el texto convertido a trazados** (Inter 800): se ve igual en cualquier equipo y en la página de npm. Se añaden copias PNG en `docs/`.
|
|
10
|
+
|
|
11
|
+
## 1.2.4
|
|
12
|
+
|
|
13
|
+
### Nuevo
|
|
14
|
+
- **Imagen real al pasar el cursor por `[Image #N]`** en terminales con Sixel (Windows Terminal 1.22 o posterior, iTerm2, WezTerm, foot, Konsole…). Hopdeck pregunta al terminal si lo admite y, si es así, dibuja la imagen con todos sus píxeles dentro del cuadro del hover; el texto del chat que queda debajo se repinta al apartar el cursor. Si no lo admite se mantiene la vista de bloques. `HOPDECK_SIXEL=1` lo fuerza y `HOPDECK_SIXEL=0` lo desactiva.
|
|
15
|
+
- **Clic en `[Image #N]` abre la imagen en grande** en el visor de imágenes del sistema, a su tamaño real. La vista rápida del terminal solo puede dibujar dos píxeles por carácter: una captura de pantalla de 1917 px de ancho quedaba en unos 50 y no se podía leer. Arrastrar para copiar texto y hacer clic en otro texto siguen igual. El cuadro del hover avisa («clic: abrir en grande») y es algo más grande.
|
|
16
|
+
|
|
3
17
|
## 1.2.3
|
|
4
18
|
|
|
5
19
|
### Cambiado
|
package/README.en.md
CHANGED
|
@@ -130,7 +130,7 @@ It always starts at `~`. Recently used folders appear on top (`↻ recent`).
|
|
|
130
130
|
|
|
131
131
|
![Floating box with the image when hovering [Image #1]](docs/screenshots/04-hover-imagen.svg)
|
|
132
132
|
|
|
133
|
-
- If a chat shows `[Image #3]` (an image you already sent), **hover it** and a
|
|
133
|
+
- If a chat shows `[Image #3]` (an image you already sent), **hover it** and a quick preview appears without covering the rest of the chat. A terminal can only draw a small version (two pixels per character), so a screenshot with text is not legible: **click the marker** and it opens full size, at its real resolution, in your system's image viewer.
|
|
134
134
|
- `i` / `F7` opens a **gallery** with all the conversation's images (`← →` navigate, `o` opens it in the system viewer, `Esc` closes).
|
|
135
135
|
- An image you just pasted and have not sent yet **cannot** be shown: it is not in the history yet.
|
|
136
136
|
|
|
@@ -169,7 +169,7 @@ Each command has **one single form**. Any other word, or a variant such as `inst
|
|
|
169
169
|
| System | Works with | Notes |
|
|
170
170
|
|---|---|---|
|
|
171
171
|
| **Windows** | PowerShell, CMD, Windows Terminal | All features. This is where it has been tested the most. |
|
|
172
|
-
| **macOS / Linux** | Any terminal with color |
|
|
172
|
+
| **macOS / Linux** | Any terminal with color | It uses the built-in terminal, with every feature (hover preview, chat images). If you prefer `tmux` panes, run `HOPDECK_TMUX=1 hopdeck` (the list responds to the wheel and clicks, but no hover preview or chat images). |
|
|
173
173
|
| **WSL** | Same as Linux | Reads WSL's history, which is separate from Windows' (see [troubleshooting](#troubleshooting)). |
|
|
174
174
|
|
|
175
175
|
## Configuration
|
|
@@ -180,6 +180,7 @@ You almost never need to change anything. The most useful options:
|
|
|
180
180
|
|---|---|
|
|
181
181
|
| `HOPDECK_LANG` | `es` or `en` (default: system language) |
|
|
182
182
|
| `HOPDECK_THEME` | `light` for light backgrounds |
|
|
183
|
+
| `HOPDECK_SIXEL` | `1` forces the real image when hovering `[Image #N]`, `0` always uses blocks (auto-detected by default) |
|
|
183
184
|
| `NO_COLOR` | Disable colors |
|
|
184
185
|
| `CLAUDE_CONFIG_DIR` | Claude Code folder, if it is not `~/.claude` |
|
|
185
186
|
| `HOPDECK_SKIP=1` | Skip Hopdeck once: `HOPDECK_SKIP=1 claude` |
|
|
@@ -199,7 +200,7 @@ Keys in `~/.hopdeck.json` you can edit by hand:
|
|
|
199
200
|
| `maxImages` | Max images per conversation in the gallery | `200` |
|
|
200
201
|
| `previewMsgs` | Messages shown in the preview | `12` |
|
|
201
202
|
|
|
202
|
-
Other variables: `HOPDECK_EMBED=1` forces the built-in terminal, `HOPDECK_NOTMUX=1` avoids tmux and `HOPDECK_NOEMBED=1` disables it; `HOPDECK_CONFIG` and `HOPDECK_CACHE` change the paths of your preferences and the cache.
|
|
203
|
+
Other variables: `HOPDECK_TMUX=1` uses tmux panes on Linux/macOS, `HOPDECK_EMBED=1` forces the built-in terminal, `HOPDECK_NOTMUX=1` avoids tmux and `HOPDECK_NOEMBED=1` disables it; `HOPDECK_CONFIG` and `HOPDECK_CACHE` change the paths of your preferences and the cache.
|
|
203
204
|
|
|
204
205
|
</details>
|
|
205
206
|
|
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ Empieza siempre en `~`. Las carpetas que usaste hace poco aparecen arriba (`↻
|
|
|
130
130
|
|
|
131
131
|
![Cuadro flotante con la imagen al pasar el cursor por [Image #1]](docs/screenshots/04-hover-imagen.svg)
|
|
132
132
|
|
|
133
|
-
- Si en un chat ves `[Image #3]` (una imagen que ya enviaste), **pasa el cursor por encima** y aparece
|
|
133
|
+
- Si en un chat ves `[Image #3]` (una imagen que ya enviaste), **pasa el cursor por encima** y aparece una vista rápida, sin tapar el resto del chat. En un terminal solo se puede dibujar una versión pequeña (dos píxeles por carácter), así que una captura con texto no se lee: **haz clic sobre la marca** y se abre en grande, a su tamaño real, en el visor de imágenes de tu sistema.
|
|
134
134
|
- `i` / `F7` abre una **galería** con todas las imágenes de la conversación (`← →` navegan, `o` la abre en el visor del sistema, `Esc` cierra).
|
|
135
135
|
- Una imagen recién pegada y aún sin enviar **no** se puede mostrar: todavía no está en el historial.
|
|
136
136
|
|
|
@@ -169,7 +169,7 @@ Cada comando tiene **una sola forma**. Cualquier otra palabra, o una variante co
|
|
|
169
169
|
| Sistema | Funciona con | Notas |
|
|
170
170
|
|---|---|---|
|
|
171
171
|
| **Windows** | PowerShell, CMD, Windows Terminal | Todas las funciones. Es donde más se ha probado. |
|
|
172
|
-
| **macOS / Linux** | Cualquier terminal con color |
|
|
172
|
+
| **macOS / Linux** | Cualquier terminal con color | Usa el terminal integrado, con todas las funciones (vista previa al pasar el cursor, imágenes del chat). Si prefieres paneles de `tmux`, lanza `HOPDECK_TMUX=1 hopdeck` (la lista responde a la rueda y al clic, pero sin vista previa al pasar el cursor ni imágenes). |
|
|
173
173
|
| **WSL** | Igual que Linux | Lee el historial de WSL, que es distinto del de Windows (ver [problemas frecuentes](#problemas-frecuentes)). |
|
|
174
174
|
|
|
175
175
|
## Configuración
|
|
@@ -180,6 +180,7 @@ Casi nunca hace falta tocar nada. Lo más útil:
|
|
|
180
180
|
|---|---|
|
|
181
181
|
| `HOPDECK_LANG` | `es` o `en` (por defecto, el idioma del sistema) |
|
|
182
182
|
| `HOPDECK_THEME` | `light` para fondos claros |
|
|
183
|
+
| `HOPDECK_SIXEL` | `1` fuerza la imagen real al pasar el cursor por `[Image #N]`, `0` usa siempre bloques (por defecto se detecta) |
|
|
183
184
|
| `NO_COLOR` | Quita los colores |
|
|
184
185
|
| `CLAUDE_CONFIG_DIR` | Carpeta de Claude Code, si no es `~/.claude` |
|
|
185
186
|
| `HOPDECK_SKIP=1` | Salta Hopdeck una vez: `HOPDECK_SKIP=1 claude` |
|
|
@@ -199,7 +200,7 @@ Claves de `~/.hopdeck.json` que puedes editar a mano:
|
|
|
199
200
|
| `maxImages` | Imágenes máximas por conversación en la galería | `200` |
|
|
200
201
|
| `previewMsgs` | Mensajes mostrados en la vista previa | `12` |
|
|
201
202
|
|
|
202
|
-
Otras variables: `HOPDECK_EMBED=1` fuerza el terminal integrado, `HOPDECK_NOTMUX=1` evita tmux y `HOPDECK_NOEMBED=1` lo desactiva; `HOPDECK_CONFIG` y `HOPDECK_CACHE` cambian las rutas de tus preferencias y de la caché.
|
|
203
|
+
Otras variables: `HOPDECK_TMUX=1` usa paneles de tmux en Linux/macOS, `HOPDECK_EMBED=1` fuerza el terminal integrado, `HOPDECK_NOTMUX=1` evita tmux y `HOPDECK_NOEMBED=1` lo desactiva; `HOPDECK_CONFIG` y `HOPDECK_CACHE` cambian las rutas de tus preferencias y de la caché.
|
|
203
204
|
|
|
204
205
|
</details>
|
|
205
206
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -11,6 +11,10 @@ y cada una conserva su propia licencia.
|
|
|
11
11
|
|
|
12
12
|
Ninguna dependencia ejecuta scripts de instalación (`npm audit`: 0 vulnerabilidades conocidas a la fecha de la versión 1.2.0).
|
|
13
13
|
|
|
14
|
+
## Tipografía del logotipo
|
|
15
|
+
|
|
16
|
+
El texto de `docs/logo-*.svg` y `docs/logo-*.png` está convertido a trazados a partir de la fuente [Inter](https://rsms.me/inter/) (peso 800), con licencia SIL Open Font License 1.1, que permite este uso. No se distribuye la fuente.
|
|
17
|
+
|
|
14
18
|
## Marcas
|
|
15
19
|
|
|
16
20
|
"Claude" y "Claude Code" son marcas de Anthropic, PBC. Este proyecto es independiente: **no está afiliado, respaldado ni patrocinado por Anthropic**.
|
package/bin/hopdeck.js
CHANGED
|
@@ -17,6 +17,7 @@ const { baseName, tidy, home, shortPath, fuzzy, wrapText } = require('../lib/tex
|
|
|
17
17
|
const hist = require('../lib/history');
|
|
18
18
|
const { CONFIG_DIR, CACHE_FILE, textOf, isType, cacheLoad, cacheSave, readSession, decodeDir, projectDirs, buildProject, beginScan, endScan } = hist;
|
|
19
19
|
const images = require('../lib/images');
|
|
20
|
+
const { encodeSixel } = require('../lib/sixel');
|
|
20
21
|
const { collectImages, decodePNG, decodeImage, scaleBox, fitSize, halfBlocks } = images;
|
|
21
22
|
const { parseKeys, KEYMAP, printable, editBuf, normalizeKeys } = require('../lib/keys');
|
|
22
23
|
const { stripJsonc, wtCtrlV, wtSettingsFile } = require('../lib/windows-terminal');
|
|
@@ -126,7 +127,7 @@ function ago(ms) {
|
|
|
126
127
|
const S = { qpos: 0, pc: 0, fb: null, confirmMk: null, confirmClose: null, more: new Set(), qs: null, promptKind: 'folder', renameTarget: null, deep: false, deepHits: null, showHidden: false, prompt: null, help: false, loading: false, projects: [], pi: 0, si: 0, focus: 0, query: '', searching: false, poff: 0, soff: 0, flash: '', c: 0, coff: 0, open: null, live: new Set(), liveKey: '' };
|
|
127
128
|
const SIDEBAR = process.argv.includes('--sidebar');
|
|
128
129
|
let EMBED = false; // vista dividida con terminal embebido (Windows / sin tmux)
|
|
129
|
-
const E = { sessions: new Map(), shown: null, focus: 'left', pend: null, deps: null, mouse: CFG.mouse !== false, hideSide: false, note: null, sel: null, gallery: null, hover: null };
|
|
130
|
+
const E = { sessions: new Map(), shown: null, focus: 'left', pend: null, deps: null, mouse: CFG.mouse !== false, hideSide: false, note: null, sel: null, gallery: null, hover: null, sixelDetected: false, cell: { w: 10, h: 20 }, sixelKey: null, sixelAt: 0, sixelStale: false, sixelRetry: null };
|
|
130
131
|
const SPIN = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
131
132
|
let spinT = null, frameN = 0, reloading = false;
|
|
132
133
|
const needsSpin = () => S.loading || (E.gallery && (E.gallery.loading || E.gallery.pending)) || (E.hover && E.hover.g.pending) || [...E.sessions.values()].some((x) => x.working || (!x.ready && x === E.sessions.get(E.shown)));
|
|
@@ -906,6 +907,7 @@ async function imagesOf(x) {
|
|
|
906
907
|
|
|
907
908
|
/** Abre un archivo o carpeta con el programa por defecto del sistema. */
|
|
908
909
|
function openExternal(target) {
|
|
910
|
+
if (process.env.HOPDECK_OPEN_LOG) { try { fs.appendFileSync(process.env.HOPDECK_OPEN_LOG, target + '\n'); } catch { /* */ } return; } // pruebas: no se abre ningún visor
|
|
909
911
|
const quiet = (cmd, args) => { try { const c = cp.spawn(cmd, args, { stdio: 'ignore', detached: true, windowsHide: true }); c.on('error', () => {}); c.unref(); } catch { /* */ } };
|
|
910
912
|
if (WIN) quiet('cmd', ['/c', 'start', '', target]);
|
|
911
913
|
else if (process.platform === 'darwin') quiet('open', [target]);
|
|
@@ -960,6 +962,27 @@ async function shownSession(x) {
|
|
|
960
962
|
return sess;
|
|
961
963
|
}
|
|
962
964
|
|
|
965
|
+
// ── Imágenes reales (Sixel): se usan si el terminal las admite; si no, la vista rápida con medios bloques ──
|
|
966
|
+
/** HOPDECK_SIXEL=1 las fuerza, =0 las apaga; sin definir, se usan si el terminal dijo que las admite (consulta DA1 al arrancar). */
|
|
967
|
+
// En Windows Terminal (1.22+) la respuesta del terminal no siempre atraviesa ConPTY, así que ahí se activa sin esperarla.
|
|
968
|
+
const sixelOn = () => process.env.HOPDECK_SIXEL === '1' || (process.env.HOPDECK_SIXEL !== '0' && (E.sixelDetected || (WIN && !!process.env.WT_SESSION)));
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Quita de la entrada las respuestas del terminal a nuestras consultas y las guarda en `st`:
|
|
972
|
+
* DA1 (ESC [ ? 61;4;… c): el atributo 4 significa que admite Sixel; y el tamaño en píxeles de una celda (ESC [ 6 ; alto ; ancho t).
|
|
973
|
+
*/
|
|
974
|
+
function parseTermReplies(s, st) {
|
|
975
|
+
return s
|
|
976
|
+
.replace(/\x1b\[\?([0-9;]*)c/g, (m, attrs) => { st.sixelDetected = attrs.split(';').includes('4'); return ''; })
|
|
977
|
+
.replace(/\x1b\[6;(\d+);(\d+)t/g, (m, hh, ww) => { const h = +hh, w = +ww; if (h >= 4 && h <= 200 && w >= 2 && w <= 100) st.cell = { w, h }; return ''; });
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/** Secuencia que coloca el cursor y dibuja la imagen. Con HOPDECK_SIXEL_LOG (pruebas) la ruta y los datos se anotan en un archivo y no se escribe nada. */
|
|
981
|
+
function emitSixel(row, col, data) {
|
|
982
|
+
if (process.env.HOPDECK_SIXEL_LOG) { try { fs.appendFileSync(process.env.HOPDECK_SIXEL_LOG, JSON.stringify({ row, col, data }) + '\n'); } catch { /* */ } return ''; }
|
|
983
|
+
return `\x1b[${row};${col}H` + data;
|
|
984
|
+
}
|
|
985
|
+
|
|
963
986
|
/** Texto de una fila del terminal virtual y la columna de cada carácter (los de ancho 2 ocupan dos celdas). */
|
|
964
987
|
function rowChars(term, y) {
|
|
965
988
|
const b = term.buffer.active, line = b.getLine(b.viewportY + y), cols = []; let text = '';
|
|
@@ -1001,9 +1024,16 @@ function hoverPopup(hv, rw, th) {
|
|
|
1001
1024
|
setImmediate(() => { let d = false; try { d = decodeImage(img) || false; } catch { d = false; } g.dec.set(0, d); g.pending = false; if (active) render(); });
|
|
1002
1025
|
}
|
|
1003
1026
|
const d = g.dec.get(0), lab = ` [Image #${hv.n}] `;
|
|
1004
|
-
let rows, tw;
|
|
1005
|
-
if (d && d.rgba) {
|
|
1006
|
-
const
|
|
1027
|
+
let rows, tw, sx = null;
|
|
1028
|
+
if (d && d.rgba && sixelOn()) { // imagen real: se deja un hueco en blanco del tamaño de la imagen y se dibuja encima con Sixel
|
|
1029
|
+
const cw = E.cell.w, ch = E.cell.h, maxCols = Math.max(8, Math.min(rw - 6, 36)), maxRows = Math.max(2, Math.min(th - 5, 9)); // vista previa pequeña: como mucho 36×9 celdas
|
|
1030
|
+
const k = Math.min((maxCols * cw) / d.w, (maxRows * ch) / d.h, 3);
|
|
1031
|
+
const iw = Math.max(1, Math.min(maxCols, Math.round((d.w * k) / cw))), ih = Math.max(1, Math.min(maxRows, Math.round((d.h * k) / ch))), key = `sx:${iw}x${ih}`;
|
|
1032
|
+
let data = g.cache.get(key);
|
|
1033
|
+
if (!data) { data = encodeSixel(scaleBox(d.rgba, d.w, d.h, iw * cw, ih * ch), iw * cw, ih * ch); g.cache.clear(); g.cache.set(key, data); }
|
|
1034
|
+
sx = { data, iw, ih, key }; tw = iw; rows = Array.from({ length: ih }, () => ' '.repeat(iw));
|
|
1035
|
+
} else if (d && d.rgba) {
|
|
1036
|
+
const sz = fitSize(d.w, d.h, Math.max(8, Math.min(rw - 6, 96)), Math.max(2, Math.min(th - 6, 18)) * 2), key = `${sz.tw}x${sz.th}`;
|
|
1007
1037
|
let hb = g.cache.get(key);
|
|
1008
1038
|
if (!hb) { hb = halfBlocks(scaleBox(d.rgba, d.w, d.h, sz.tw, sz.th), sz.tw, sz.th); g.cache.clear(); g.cache.set(key, hb); }
|
|
1009
1039
|
rows = hb; tw = sz.tw;
|
|
@@ -1014,12 +1044,39 @@ function hoverPopup(hv, rw, th) {
|
|
|
1014
1044
|
}
|
|
1015
1045
|
const label = strW(lab) <= tw - 1 ? lab : '', b = C.accent;
|
|
1016
1046
|
const box = [b + '╭─' + label + '─'.repeat(Math.max(0, tw - 1 - strW(label))) + '╮' + R,
|
|
1017
|
-
...rows.map((r) => b + '│' + R + r + b + '│' + R),
|
|
1047
|
+
...rows.map((r) => b + '│' + R + r + b + '│' + R),
|
|
1048
|
+
(() => { const h = ` ${T.imgClickHint} `; return strW(h) <= tw - 1 ? b + '╰─' + C.dim + h + b + '─'.repeat(tw - 1 - strW(h)) + '╯' + R : b + '╰' + '─'.repeat(tw) + '╯' + R; })()];
|
|
1018
1049
|
const bw = tw + 2, bh = box.length, left = clamp(hv.at.x, 0, Math.max(0, rw - bw));
|
|
1019
1050
|
let top = hv.at.y + 1; // debajo de la marca; si no cabe, encima; si tampoco, pegado al borde
|
|
1020
1051
|
if (top + bh > th) top = hv.at.y - bh;
|
|
1021
1052
|
if (top < 0) top = Math.max(0, th - bh);
|
|
1022
|
-
return { left, top, bw, rows: box };
|
|
1053
|
+
return { left, top, bw, rows: box, sixel: sx ? { ...sx, key: `${hv.k}|${sx.key}|${left},${top}` } : null };
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/** La imagen que corresponde a "[Image #n]" en la conversación de este chat, o null si aún no está en el historial. */
|
|
1057
|
+
async function imageForMarker(sh, n) {
|
|
1058
|
+
try {
|
|
1059
|
+
const sess = await shownSession(sh);
|
|
1060
|
+
if (!sess) return null;
|
|
1061
|
+
const imgs = await imagesOf(sess);
|
|
1062
|
+
let img = imgs.find((im) => im.n === n) || (imgs.some((im) => im.n) ? null : imgs[n - 1]) || null;
|
|
1063
|
+
if (!img && imgs.length >= maxImages()) img = await images.findImageByNumber(sess.file, n); // pasó el límite de la galería: se busca en todo el archivo
|
|
1064
|
+
return img;
|
|
1065
|
+
} catch { return null; }
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Clic en un "[Image #N]": abre esa imagen en el visor del sistema, a su tamaño real. En el terminal solo se puede dibujar una
|
|
1070
|
+
* vista rápida (dos píxeles por carácter): una captura de pantalla con texto de 1917 px de ancho queda en unos 50 y no se lee.
|
|
1071
|
+
*/
|
|
1072
|
+
async function openMarkerImage(sh, n) {
|
|
1073
|
+
const img = await imageForMarker(sh, n);
|
|
1074
|
+
const note = (t) => { E.note = { t, until: Date.now() + 2500 }; scheduleRender(); };
|
|
1075
|
+
if (!img) return note(T.hoverMiss(n));
|
|
1076
|
+
const { files } = exportImages([img]);
|
|
1077
|
+
if (!files[0]) return note(T.imgNoPrev); // no es una imagen reconocible: no se abre
|
|
1078
|
+
openExternal(files[0]);
|
|
1079
|
+
note(T.imgOpened(n));
|
|
1023
1080
|
}
|
|
1024
1081
|
|
|
1025
1082
|
function hoverChat(sh, x, y) {
|
|
@@ -1035,15 +1092,7 @@ function hoverChat(sh, x, y) {
|
|
|
1035
1092
|
const hv = { n, k, at, g: { project: sh.project, title: sh.title, images: [], i: 0, loading: true, pending: false, dec: new Map(), cache: new Map() } };
|
|
1036
1093
|
E.hover = hv; scheduleRender();
|
|
1037
1094
|
(async () => {
|
|
1038
|
-
|
|
1039
|
-
try {
|
|
1040
|
-
const sess = await shownSession(sh);
|
|
1041
|
-
if (sess) {
|
|
1042
|
-
const imgs = await imagesOf(sess);
|
|
1043
|
-
img = imgs.find((im) => im.n === n) || (imgs.some((im) => im.n) ? null : imgs[n - 1]) || null;
|
|
1044
|
-
if (!img && imgs.length >= maxImages()) img = await images.findImageByNumber(sess.file, n); // pasó el límite de la galería: se busca en todo el archivo
|
|
1045
|
-
}
|
|
1046
|
-
} catch { img = null; }
|
|
1095
|
+
const img = await imageForMarker(sh, n);
|
|
1047
1096
|
if (E.hover !== hv) return; // el cursor ya se fue
|
|
1048
1097
|
if (!img) { hv.g.loading = false; E.note = { t: T.hoverMiss(n), until: Date.now() + 2000 }; return scheduleRender(); }
|
|
1049
1098
|
hv.g.images = [img]; hv.g.loading = false; scheduleRender();
|
|
@@ -1179,12 +1228,22 @@ function renderEmbed() {
|
|
|
1179
1228
|
...k('F1', T.bar1), ...k('F2', T.bar2), ...k('F3', E.mouse ? T.bar4 : T.bar5), ...k('F4', E.hideSide ? T.bar7 : T.bar6),
|
|
1180
1229
|
[live ? '● ' + live : '', C.ok]], W));
|
|
1181
1230
|
const changes = diffRows(rowsOut);
|
|
1231
|
+
// 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)
|
|
1232
|
+
let sx = '';
|
|
1233
|
+
if (pop && pop.sixel) {
|
|
1234
|
+
const top = pop.top + 3, touched = lastChanged.some((y) => y >= top && y < top + pop.sixel.ih);
|
|
1235
|
+
if (E.sixelKey !== pop.sixel.key || touched || E.sixelStale) {
|
|
1236
|
+
const now = Date.now();
|
|
1237
|
+
if (E.sixelKey === pop.sixel.key && now - E.sixelAt < 150) { E.sixelStale = true; if (!E.sixelRetry) E.sixelRetry = setTimeout(() => { E.sixelRetry = null; scheduleRender(); }, 160); }
|
|
1238
|
+
else { sx = emitSixel(pop.top + 4, (SW ? SW + 2 : 1) + pop.left + 1, pop.sixel.data); E.sixelKey = pop.sixel.key; E.sixelAt = now; E.sixelStale = false; }
|
|
1239
|
+
}
|
|
1240
|
+
} else if (E.sixelKey) { E.sixelKey = null; E.sixelStale = false; } // al quitar el cuadro, las filas que cubría ya se reescriben solas con el texto del chat
|
|
1182
1241
|
let cur = '';
|
|
1183
1242
|
if (sh && sh.ready && E.focus === 'right' && !sh.cursorHidden && back === 0) {
|
|
1184
1243
|
const b = sh.term.buffer.active;
|
|
1185
1244
|
cur = `\x1b[${Math.min(th, b.cursorY + 1) + 2};${(SW ? SW + 1 : 0) + 1 + Math.min(rw - 1, b.cursorX)}H\x1b[?25h`;
|
|
1186
1245
|
}
|
|
1187
|
-
process.stdout.write((changes ? '\x1b[?2026h\x1b[?25l' + changes : '\x1b[?25l') + cur + (changes ? '\x1b[?2026l' : ''));
|
|
1246
|
+
process.stdout.write((changes || sx ? '\x1b[?2026h\x1b[?25l' + changes + sx : '\x1b[?25l') + cur + (changes || sx ? '\x1b[?2026l' : ''));
|
|
1188
1247
|
}
|
|
1189
1248
|
|
|
1190
1249
|
function scheduleRender() {
|
|
@@ -1340,6 +1399,10 @@ function onMouse(b, x, y, type) {
|
|
|
1340
1399
|
if ((b & 32) && (b & 3) === 0) { if (E.sel && E.sel.down) { E.sel.b = cell(); render(); } return; } // arrastre
|
|
1341
1400
|
if (type === 'm') { // soltar: copiar la selección
|
|
1342
1401
|
const sl = E.sel; E.sel = null;
|
|
1402
|
+
if (sl && sl.down && sl.a.x === sl.b.x && sl.a.y === sl.b.y && sh && sh.ready) { // un clic sin arrastrar: si es sobre un [Image #N], se abre la imagen
|
|
1403
|
+
const hit = imageMarkerAt(sh.term, sl.a.y, sl.a.x);
|
|
1404
|
+
if (hit) openMarkerImage(sh, hit.n);
|
|
1405
|
+
}
|
|
1343
1406
|
if (sl && sl.down && (sl.a.x !== sl.b.x || sl.a.y !== sl.b.y) && sh) {
|
|
1344
1407
|
const t = selText(sh, sl);
|
|
1345
1408
|
if (t) { copyText(t); E.note = { t: T.copied(t.length), until: Date.now() + 3000 }; }
|
|
@@ -1457,10 +1520,11 @@ function embedKillAll() { for (const sess of E.sessions.values()) { try { sess.p
|
|
|
1457
1520
|
// Redibujado diferencial: solo se reescriben las filas que cambiaron desde el último cuadro.
|
|
1458
1521
|
let lastRows = [], forceFull = true;
|
|
1459
1522
|
const invalidate = () => { forceFull = true; };
|
|
1523
|
+
let lastChanged = []; // índices de las filas que reescribió el último diffRows (si pisan una imagen Sixel hay que volver a dibujarla)
|
|
1460
1524
|
function diffRows(rows) {
|
|
1461
|
-
let out = '';
|
|
1525
|
+
let out = ''; lastChanged = [];
|
|
1462
1526
|
for (let i = 0; i < rows.length; i++) {
|
|
1463
|
-
if (forceFull || lastRows[i] !== rows[i]) out += `\x1b[${i + 1};1H` + rows[i];
|
|
1527
|
+
if (forceFull || lastRows[i] !== rows[i]) { out += `\x1b[${i + 1};1H` + rows[i]; lastChanged.push(i); }
|
|
1464
1528
|
}
|
|
1465
1529
|
lastRows = rows.slice(); forceFull = false;
|
|
1466
1530
|
return out;
|
|
@@ -1480,7 +1544,7 @@ function render() {
|
|
|
1480
1544
|
let active = false;
|
|
1481
1545
|
function enter() {
|
|
1482
1546
|
if (active) return; active = true; invalidate();
|
|
1483
|
-
process.stdout.write('\x1b[?1049h\x1b[?25l\x1b[2J' + ((EMBED || SIDEBAR) && E.mouse ? mouseModes(true) : ''));
|
|
1547
|
+
process.stdout.write('\x1b[?1049h\x1b[?25l\x1b[2J' + ((EMBED || SIDEBAR) && E.mouse ? mouseModes(true) : '') + (EMBED && process.env.HOPDECK_SIXEL !== '0' ? '\x1b[c\x1b[16t' : '')); // consulta: ¿admite imágenes (Sixel)? ¿qué tamaño tiene una celda?
|
|
1484
1548
|
process.stdin.setRawMode(true); process.stdin.resume();
|
|
1485
1549
|
}
|
|
1486
1550
|
function leave() {
|
|
@@ -1626,9 +1690,12 @@ async function run() {
|
|
|
1626
1690
|
if (!SIDEBAR && process.env.HOPDECK_INSIDE) { console.log(T.inside); return; }
|
|
1627
1691
|
if (!SIDEBAR) await offerShortcut(); // primera vez: ¿quieres que `claude` abra Hopdeck?
|
|
1628
1692
|
if (!SIDEBAR) {
|
|
1629
|
-
|
|
1630
|
-
|
|
1693
|
+
// Por defecto se usa el terminal integrado (vista previa al pasar el cursor, imágenes). tmux solo con HOPDECK_TMUX=1,
|
|
1694
|
+
// o como alternativa si el terminal integrado no está disponible.
|
|
1695
|
+
const tmuxOk = !WIN && !process.env.HOPDECK_NOTMUX && !process.env.HOPDECK_EMBED && hasTmux();
|
|
1696
|
+
if (tmuxOk && process.env.HOPDECK_TMUX) return bootstrap();
|
|
1631
1697
|
if (!process.env.HOPDECK_NOEMBED) { E.deps = loadDeps(); EMBED = !!E.deps; }
|
|
1698
|
+
if (!EMBED && tmuxOk) return bootstrap();
|
|
1632
1699
|
}
|
|
1633
1700
|
process.on('exit', () => { if (active) { try { process.stdout.write('\x1b[?1000l\x1b[?1003l\x1b[?1006l\x1b[?25h\x1b[?1049l'); } catch { /* */ } } });
|
|
1634
1701
|
process.on('SIGTERM', () => quit(0));
|
|
@@ -1653,6 +1720,7 @@ async function run() {
|
|
|
1653
1720
|
process.stdin.on('data', (buf) => {
|
|
1654
1721
|
if (!active) return;
|
|
1655
1722
|
let s = normalizeKeys(buf.toString('utf8'));
|
|
1723
|
+
if (EMBED) { s = parseTermReplies(s, E); if (!s) return; } // respuestas del terminal a las consultas del arranque
|
|
1656
1724
|
if (EMBED) {
|
|
1657
1725
|
s = s.replace(/\x1b\[<(\d+);(\d+);(\d+)([Mm])/g, (m, b, x, y, t) => { onMouse(+b, +x, +y, t); return ''; });
|
|
1658
1726
|
if (!s) return;
|
|
@@ -1992,7 +2060,7 @@ else {
|
|
|
1992
2060
|
module.exports = {
|
|
1993
2061
|
cw, strW, fit, clean, imageExt, exportImages, safeId, findClaude, install, backupProfile, ago, tidy, fuzzy, wrapText, parseKeys, KEYMAP, isType, T, S, CFG, E,
|
|
1994
2062
|
readSession, buildProject, scan, scanAsync, finishScan, sortProjects, projectDirs,
|
|
1995
|
-
view, flatList, stripBlock, offerShortcut, uninstallAll, commandName, suggestCommand, SNIP, MARK_A, MARK_B, toggleProject, cacheLoad, selNorm,
|
|
2063
|
+
view, flatList, stripBlock, offerShortcut, uninstallAll, commandName, suggestCommand, parseTermReplies, sixelOn, SNIP, MARK_A, MARK_B, toggleProject, cacheLoad, selNorm,
|
|
1996
2064
|
decodePNG, decodeImage, scaleBox, fitSize, halfBlocks, collectImages, extractImages,
|
|
1997
2065
|
editBuf, normalizeKeys, stripJsonc, wtCtrlV, fbNames, fbOpen, fbRows, sidebarMouse, gitBranch, imageMarkerAt, shownSession, linkChats, findImageByNumber: images.findImageByNumber,
|
|
1998
2066
|
};
|
package/lib/i18n.js
CHANGED
|
@@ -20,6 +20,7 @@ const T = {
|
|
|
20
20
|
copied: (n) => `Copiado (${n} caracteres)`, archMsg: 'Archivada (H para verlas)', unarchMsg: 'Desarchivada', qsHint: 'saltar a cualquier conversación',
|
|
21
21
|
prevHint: '⏎ reanudar esta conversación', 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
|
+
imgClickHint: 'clic: abrir en grande', imgOpened: (n) => `[Image #${n}] abierta en el visor de imágenes`,
|
|
23
24
|
unknownCmd: (c) => `Comando desconocido: "${c}"`, didYouMean: (s) => `¿Quisiste decir "${s}"?`, cmdList: 'Comandos: hopdeck shortcut on|off · uninstall · doctor · help (y --list, --version).\nLas opciones de claude (por ejemplo --model opus) se pasan tal cual: hopdeck --model opus',
|
|
24
25
|
shortcutUsage: 'Uso: hopdeck shortcut on (instalar el atajo de claude) · hopdeck shortcut off (quitarlo)',
|
|
25
26
|
unQ: '¿Desinstalar Hopdeck por completo?', unInfo: 'Se quitará el atajo de tu perfil de shell, tus preferencias y la caché de Hopdeck, y el programa (npm uninstall -g hopdeck). Tu historial de Claude Code no se toca.', unKeys: '[s] Sí, desinstalar [Enter] No', unCancel: 'Cancelado: no se ha quitado nada.', unNeedYes: 'Sin terminal no puedo preguntar. Para desinstalar sin preguntar: hopdeck uninstall --yes',
|
|
@@ -59,6 +60,7 @@ const T = {
|
|
|
59
60
|
copied: (n) => `Copied (${n} chars)`, archMsg: 'Archived (H to show)', unarchMsg: 'Unarchived', qsHint: 'jump to any conversation',
|
|
60
61
|
prevHint: '⏎ resume this conversation', noPrev: 'No messages to show',
|
|
61
62
|
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',
|
|
63
|
+
imgClickHint: 'click: open full size', imgOpened: (n) => `[Image #${n}] opened in the image viewer`,
|
|
62
64
|
unknownCmd: (c) => `Unknown command: "${c}"`, didYouMean: (s) => `Did you mean "${s}"?`, cmdList: 'Commands: hopdeck shortcut on|off · uninstall · doctor · help (and --list, --version).\nclaude options (for example --model opus) are passed through as they are: hopdeck --model opus',
|
|
63
65
|
shortcutUsage: 'Usage: hopdeck shortcut on (install the claude shortcut) · hopdeck shortcut off (remove it)',
|
|
64
66
|
unQ: 'Uninstall Hopdeck completely?', unInfo: 'This removes the shortcut from your shell profile, Hopdeck\'s preferences and cache, and the program itself (npm uninstall -g hopdeck). Your Claude Code history is not touched.', unKeys: '[y] Yes, uninstall [Enter] No', unCancel: 'Cancelled: nothing was removed.', unNeedYes: 'Without a terminal I cannot ask. To uninstall without asking: hopdeck uninstall --yes',
|
package/lib/sixel.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Codificador Sixel: convierte una imagen RGB en la secuencia que dibuja una imagen real (con todos sus píxeles) en terminales
|
|
3
|
+
// que la admiten (Windows Terminal 1.22+, iTerm2, WezTerm, foot, mlterm, Konsole…). Sin dependencias.
|
|
4
|
+
//
|
|
5
|
+
// Formato: DCS "P0;0;0q" + atributos del ráster ("1;1;ancho;alto) + paleta (#n;2;r;g;b, en 0-100) + datos por bandas de
|
|
6
|
+
// 6 píxeles de alto (un carácter por columna y color: 63 + máscara de bits), con "!n" para repeticiones, "$" para volver al
|
|
7
|
+
// principio de la banda, "-" para la banda siguiente, y ST (ESC \) para terminar.
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reduce la imagen a como mucho `maxColors` colores. Si ya tiene pocos colores (capturas de pantalla, interfaces) se conservan
|
|
11
|
+
* exactos; si no, se aplica "median cut" sobre un histograma de 5 bits por canal.
|
|
12
|
+
* Devuelve { palette: [[r,g,b]…], index: Uint8Array(w*h) }.
|
|
13
|
+
*/
|
|
14
|
+
function quantize(rgb, w, h, maxColors = 256) {
|
|
15
|
+
const n = w * h, index = new Uint8Array(n);
|
|
16
|
+
// 1) ¿hay pocos colores distintos? entonces la paleta es exacta
|
|
17
|
+
const exact = new Map();
|
|
18
|
+
for (let i = 0; i < n && exact.size <= maxColors; i++) {
|
|
19
|
+
const k = (rgb[i * 3] << 16) | (rgb[i * 3 + 1] << 8) | rgb[i * 3 + 2];
|
|
20
|
+
if (!exact.has(k)) exact.set(k, exact.size);
|
|
21
|
+
}
|
|
22
|
+
if (exact.size <= maxColors) {
|
|
23
|
+
for (let i = 0; i < n; i++) index[i] = exact.get((rgb[i * 3] << 16) | (rgb[i * 3 + 1] << 8) | rgb[i * 3 + 2]);
|
|
24
|
+
const palette = []; for (const [k] of exact) palette.push([(k >> 16) & 255, (k >> 8) & 255, k & 255]);
|
|
25
|
+
return { palette, index };
|
|
26
|
+
}
|
|
27
|
+
// 2) histograma de 5 bits por canal + median cut
|
|
28
|
+
const hist = new Uint32Array(32768);
|
|
29
|
+
for (let i = 0; i < n; i++) hist[((rgb[i * 3] >> 3) << 10) | ((rgb[i * 3 + 1] >> 3) << 5) | (rgb[i * 3 + 2] >> 3)]++;
|
|
30
|
+
const bins = [];
|
|
31
|
+
for (let b = 0; b < 32768; b++) if (hist[b]) bins.push({ r: ((b >> 10) << 3) + 4, g: (((b >> 5) & 31) << 3) + 4, b: ((b & 31) << 3) + 4, c: hist[b], id: b });
|
|
32
|
+
let boxes = [bins];
|
|
33
|
+
while (boxes.length < maxColors) {
|
|
34
|
+
// se parte la caja con más rango (ponderado por su número de píxeles) por su canal más largo, en la mediana
|
|
35
|
+
let bi = -1, best = -1, bch = 'r';
|
|
36
|
+
boxes.forEach((bx, i) => {
|
|
37
|
+
if (bx.length < 2) return;
|
|
38
|
+
let lo = { r: 255, g: 255, b: 255 }, hi = { r: 0, g: 0, b: 0 }, cnt = 0;
|
|
39
|
+
for (const p of bx) { cnt += p.c; for (const ch of ['r', 'g', 'b']) { if (p[ch] < lo[ch]) lo[ch] = p[ch]; if (p[ch] > hi[ch]) hi[ch] = p[ch]; } }
|
|
40
|
+
for (const ch of ['r', 'g', 'b']) { const score = (hi[ch] - lo[ch]) * Math.sqrt(cnt); if (score > best) { best = score; bi = i; bch = ch; } }
|
|
41
|
+
});
|
|
42
|
+
if (bi < 0) break;
|
|
43
|
+
const bx = boxes[bi].slice().sort((p, q) => p[bch] - q[bch]);
|
|
44
|
+
const half = bx.reduce((s, p) => s + p.c, 0) / 2; let acc = 0, cut = 1;
|
|
45
|
+
for (let i = 0; i < bx.length - 1; i++) { acc += bx[i].c; cut = i + 1; if (acc >= half) break; }
|
|
46
|
+
boxes.splice(bi, 1, bx.slice(0, cut), bx.slice(cut));
|
|
47
|
+
}
|
|
48
|
+
const palette = boxes.map((bx) => { let r = 0, g = 0, b = 0, c = 0; for (const p of bx) { r += p.r * p.c; g += p.g * p.c; b += p.b * p.c; c += p.c; } return [Math.round(r / c), Math.round(g / c), Math.round(b / c)]; });
|
|
49
|
+
const map = new Int16Array(32768).fill(-1); // cada color de 5 bits → su caja
|
|
50
|
+
boxes.forEach((bx, i) => { for (const p of bx) map[p.id] = i; });
|
|
51
|
+
for (let i = 0; i < n; i++) index[i] = map[((rgb[i * 3] >> 3) << 10) | ((rgb[i * 3 + 1] >> 3) << 5) | (rgb[i * 3 + 2] >> 3)];
|
|
52
|
+
return { palette, index };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Una fila de máscaras de una banda como cadena sixel, con repeticiones "!n" y sin el relleno vacío del final. */
|
|
56
|
+
function rle(masks) {
|
|
57
|
+
let end = masks.length; while (end > 0 && masks[end - 1] === 0) end--; // los "?" finales no hacen falta
|
|
58
|
+
let out = '';
|
|
59
|
+
for (let x = 0; x < end;) {
|
|
60
|
+
let run = 1; while (x + run < end && masks[x + run] === masks[x]) run++;
|
|
61
|
+
const ch = String.fromCharCode(63 + masks[x]);
|
|
62
|
+
out += run > 3 ? `!${run}${ch}` : ch.repeat(run);
|
|
63
|
+
x += run;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Imagen RGB (3 bytes por píxel) → secuencia Sixel completa lista para escribir en el terminal. */
|
|
69
|
+
function encodeSixel(rgb, w, h, { maxColors = 256 } = {}) {
|
|
70
|
+
const { palette, index } = quantize(rgb, w, h, maxColors);
|
|
71
|
+
let out = `\x1bP0;0;0q"1;1;${w};${h}`;
|
|
72
|
+
palette.forEach(([r, g, b], i) => { out += `#${i};2;${Math.round((r * 100) / 255)};${Math.round((g * 100) / 255)};${Math.round((b * 100) / 255)}`; });
|
|
73
|
+
for (let y0 = 0; y0 < h; y0 += 6) {
|
|
74
|
+
const bandH = Math.min(6, h - y0), cols = new Map();
|
|
75
|
+
for (let dy = 0; dy < bandH; dy++) {
|
|
76
|
+
const row = (y0 + dy) * w;
|
|
77
|
+
for (let x = 0; x < w; x++) {
|
|
78
|
+
const c = index[row + x]; let a = cols.get(c);
|
|
79
|
+
if (!a) { a = new Uint8Array(w); cols.set(c, a); }
|
|
80
|
+
a[x] |= 1 << dy;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let first = true;
|
|
84
|
+
for (const [c, a] of cols) { out += (first ? '' : '$') + '#' + c + rle(a); first = false; }
|
|
85
|
+
if (y0 + 6 < h) out += '-';
|
|
86
|
+
}
|
|
87
|
+
return out + '\x1b\\';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = { encodeSixel, quantize };
|
package/package.json
CHANGED