hopdeck 1.3.0 → 1.4.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.
- package/CHANGELOG.md +24 -0
- package/README.en.md +6 -2
- package/README.md +6 -2
- package/bin/hopdeck.js +149 -68
- package/lib/deepsearch.js +95 -0
- package/lib/history.js +42 -9
- package/lib/i18n.js +14 -4
- package/lib/images.js +40 -9
- package/lib/keys.js +1 -1
- package/lib/style.js +17 -5
- package/lib/text.js +20 -3
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
# Cambios
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Nuevo
|
|
6
|
+
- **Ancho de los paneles con el ratón.** Agarra con el cursor la línea `│` que separa la lista del chat, o el chat del panel de git, y arrástrala a izquierda o derecha. Cada panel puede medir entre el 15 % y el 50 % del ancho del terminal (nunca menos de 20 columnas), el chat siempre conserva su ancho mínimo y el ancho se recuerda para la próxima vez. Solo en el terminal integrado (en tmux, arrastra el borde del panel como siempre).
|
|
7
|
+
|
|
8
|
+
### Mejorado
|
|
9
|
+
- **La búsqueda es más fácil de encontrar y falla menos.**
|
|
10
|
+
- **Se ve de dónde parte:** arriba a la derecha de la lista hay siempre un `⌕ / buscar`; pulsando `/` (o haciendo clic en esa fila) el cuadro de búsqueda ocupa el lugar del título, arriba, y no en la última fila. El pie dice cuántos resultados hay, dónde se busca y qué teclas valen.
|
|
11
|
+
- **`⏎` abre la conversación marcada en el momento:** al escribir se marca el primer resultado y `⏎` lo abre, sin tener que pulsar `⏎` dos veces como antes (el salto rápido `Ctrl+P` ya funcionaba así).
|
|
12
|
+
- **Encuentra más:** las palabras valen en cualquier orden y sin importar mayúsculas ni acentos («vision roles» encuentra «Roles y visión»), y se comparan con el proyecto, el título y el primer mensaje. El salto rápido tampoco distingue acentos.
|
|
13
|
+
- **Si no coincide ningún título, se busca sola dentro del contenido** de las conversaciones (ya no hace falta saber que `Tab` lo activa). Con `Tab` se fuerza también cuando sí hay coincidencias.
|
|
14
|
+
- **Sin resultados lo dice:** «Sin resultados para …» y qué hacer, en lugar de una lista vacía.
|
|
15
|
+
|
|
16
|
+
### Arreglado
|
|
17
|
+
- **Una misma conversación aparecía varias veces** (con el mismo título y un `#xxxx` distinto). Cada vez que reanudas una conversación, o Claude Code la continúa tras agotar el contexto, crea un archivo nuevo que copia todo el historial anterior. Hopdeck ahora reconoce que comparten el primer mensaje, los junta en una sola fila y abre la que tiene el último mensaje, que ya contiene todo lo anterior. La fila lleva `↻N` (continuada N veces). El `#xxxx` queda solo para conversaciones realmente distintas con el mismo título. La fecha del archivo no sirve para elegir: también cambia al abrir una conversación vieja.
|
|
18
|
+
- **macOS: el cuadro del hover salía sin la imagen** cuando el formato no lo entendía el decodificador propio (WebP, GIF, HEIC, TIFF, PNG entrelazado o imágenes enormes). Ahora esas imágenes se convierten con `sips`, que viene con macOS. Y si aun así no se puede leer, el cuadro indica el formato («No se puede previsualizar este formato (image/webp)») para saber por qué.
|
|
19
|
+
|
|
20
|
+
## 1.3.1
|
|
21
|
+
|
|
22
|
+
### Nuevo
|
|
23
|
+
- **Cambiar de tema en caliente: `t` o `F9`.** Alterna entre el tema claro y el oscuro sin reiniciar: se repinta todo al instante (lista, chat, panel de git, cuadros) y se recuerda para la próxima vez. Cambia los colores de Hopdeck, no el fondo de tu terminal: úsalo cuando cambies el tema de tu terminal.
|
|
24
|
+
- **`hopdeck theme light|dark|auto`:** lo mismo desde la línea de comandos (`hopdeck theme` solo muestra el actual). La variable `HOPDECK_THEME` sigue mandando sobre lo guardado.
|
|
25
|
+
|
|
3
26
|
## 1.3.0
|
|
4
27
|
|
|
5
28
|
### Nuevo
|
|
6
29
|
- **Panel de git (F8 o `b`):** un tercer panel de solo lectura a la derecha del chat con la rama actual (y lo que lleva por delante o por detrás del remoto), los cambios sin guardar, las ramas recientes y la **actividad de ramas** (cambios de rama, ramas creadas y merges, desde el reflog de git; los de los últimos 10 minutos se destacan). Se refresca solo, no modifica el repositorio y solo aparece si caben unas 140 columnas. Solo en el terminal integrado. En macOS no se llama a `git` si solo existe el atajo que abre el instalador de Apple.
|
|
7
30
|
|
|
8
31
|
### Mejorado
|
|
32
|
+
- **La búsqueda dentro del contenido (`/` y Tab) es unas 10 veces más rápida:** con 2,2 GB de historial pasó de unos 35 s a unos 3,5 s en el peor caso. Se hace en hilos de trabajo en paralelo, sin decodificar el texto, y las conversaciones aparecen en la lista según se encuentran. Además ya no se saltan los archivos de más de 40 MB (ahora el límite es 256 MB), que suelen ser las conversaciones más largas.
|
|
9
33
|
- **La codificación de imágenes Sixel es unas 10 veces más rápida** (el recorte de colores recalculaba todas las cajas en cada paso).
|
|
10
34
|
- **La búsqueda resalta las coincidencias** en los nombres de proyecto y en los títulos; si una conversación aparece porque la coincidencia está dentro de su texto, lleva un `⌕`.
|
|
11
35
|
- **Resumen de chats abiertos en la cabecera de la lista:** `⠋` trabajando, `✔` terminados sin ver, `●` abiertos. La ayuda (`?`) explica los símbolos.
|
package/README.en.md
CHANGED
|
@@ -22,6 +22,8 @@ The project list stays on the left and the conversation on the right.
|
|
|
22
22
|
<img alt="Split view: project list on the left, chat on the right" src="docs/screenshots/02-vista-dividida.svg">
|
|
23
23
|
</picture>
|
|
24
24
|
|
|
25
|
+
<p align="center"><img alt="Hopdeck in action: preview, chat, image on hover and git panel" src="docs/demo.gif" width="900"></p>
|
|
26
|
+
|
|
25
27
|
> **Independent community project.** Not affiliated with, endorsed or sponsored by Anthropic.
|
|
26
28
|
> "Claude" and "Claude Code" are trademarks of Anthropic, PBC. Hopdeck only reads the local history that Claude Code already keeps on your machine and launches the `claude` command you have installed.
|
|
27
29
|
|
|
@@ -97,6 +99,7 @@ You can say no and always use `hopdeck`. If you change your mind: `hopdeck short
|
|
|
97
99
|
| `F3` | Turn the mouse off/on (to select text with the terminal) |
|
|
98
100
|
| `F4` | Hide/show the list to give the chat the full width |
|
|
99
101
|
| `F8` · `b` | Show/hide the git panel (third panel). `b` works with the focus on the list; on macOS `F8` usually needs `Fn` |
|
|
102
|
+
| `t` · `F9` | Switch between light and dark theme instantly (remembered). Also: `hopdeck theme light\|dark\|auto` |
|
|
100
103
|
| `r` · `?` · `q` | Reload · help · quit |
|
|
101
104
|
|
|
102
105
|
Every text box supports a cursor: `←` `→`, `Home`/`End`, `Delete`, and `Ctrl+U` to clear up to the start.
|
|
@@ -188,6 +191,7 @@ It refreshes itself every few seconds and never modifies the repository. It need
|
|
|
188
191
|
|---|---|
|
|
189
192
|
| `hopdeck` | Opens Hopdeck |
|
|
190
193
|
| `hopdeck shortcut on` / `hopdeck shortcut off` | Installs or removes the shortcut so that `claude` opens Hopdeck |
|
|
194
|
+
| `hopdeck theme light` / `dark` / `auto` | Changes the color theme and remembers it (`hopdeck theme` shows the current one) |
|
|
191
195
|
| `hopdeck uninstall` | **Uninstalls Hopdeck completely**: the shortcut, your preferences and cache, and the program. Asks first (without a terminal, use `--yes`). Does not touch your Claude Code history |
|
|
192
196
|
| `hopdeck doctor` | Checks your setup and tells you how to fix whatever is missing |
|
|
193
197
|
| `hopdeck --list` | Lists the projects as plain text |
|
|
@@ -211,7 +215,7 @@ You almost never need to change anything. The most useful options:
|
|
|
211
215
|
| Environment variable | Effect |
|
|
212
216
|
|---|---|
|
|
213
217
|
| `HOPDECK_LANG` | `es` or `en` (default: system language) |
|
|
214
|
-
| `HOPDECK_THEME` | `light`
|
|
218
|
+
| `HOPDECK_THEME` | `light` or `dark`: takes priority over what `hopdeck theme` saved |
|
|
215
219
|
| `HOPDECK_SIXEL` | `1` forces the real image when hovering `[Image #N]`, `0` always uses blocks (auto-detected by default) |
|
|
216
220
|
| `NO_COLOR` | Disable colors |
|
|
217
221
|
| `CLAUDE_CONFIG_DIR` | Claude Code folder, if it is not `~/.claude` |
|
|
@@ -262,7 +266,7 @@ Always start with `hopdeck doctor`.
|
|
|
262
266
|
|
|
263
267
|
**I want `claude` back to normal.** `hopdeck shortcut off`, or `HOPDECK_SKIP=1 claude` to skip it once.
|
|
264
268
|
|
|
265
|
-
**It looks wrong in my terminal.** Try `
|
|
269
|
+
**It looks wrong in my terminal.** Try `hopdeck theme light` (light background) or `NO_COLOR=1`.
|
|
266
270
|
|
|
267
271
|
## Contributing and license
|
|
268
272
|
|
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ La lista de proyectos queda a la izquierda y la conversación a la derecha.
|
|
|
22
22
|
<img alt="Vista dividida: lista de proyectos a la izquierda y el chat a la derecha" src="docs/screenshots/02-vista-dividida.svg">
|
|
23
23
|
</picture>
|
|
24
24
|
|
|
25
|
+
<p align="center"><img alt="Hopdeck en acción: vista previa, chat, imagen al pasar el cursor y panel de git" src="docs/demo.gif" width="900"></p>
|
|
26
|
+
|
|
25
27
|
> **Proyecto independiente de la comunidad.** No está afiliado, respaldado ni patrocinado por Anthropic.
|
|
26
28
|
> "Claude" y "Claude Code" son marcas de Anthropic, PBC. Hopdeck solo lee el historial local que Claude Code ya guarda en tu equipo y lanza el comando `claude` que tú tengas instalado.
|
|
27
29
|
|
|
@@ -97,6 +99,7 @@ Puedes decir que no y usar siempre `hopdeck`. Si cambias de idea: `hopdeck short
|
|
|
97
99
|
| `F3` | Apagar/encender el ratón (para seleccionar texto con el terminal) |
|
|
98
100
|
| `F4` | Ocultar/mostrar la lista para dar todo el ancho al chat |
|
|
99
101
|
| `F8` · `b` | Mostrar/ocultar el panel de git (tercer panel). `b` funciona con el foco en la lista; en macOS `F8` suele necesitar `Fn` |
|
|
102
|
+
| `t` · `F9` | Cambiar entre tema claro y oscuro al instante (se recuerda). También: `hopdeck theme light\|dark\|auto` |
|
|
100
103
|
| `r` · `?` · `q` | Recargar · ayuda · salir |
|
|
101
104
|
|
|
102
105
|
En todas las cajas de texto puedes mover el cursor con `←` `→`, ir al principio/final con `Inicio`/`Fin`, borrar con `Supr` y vaciar hasta el inicio con `Ctrl+U`.
|
|
@@ -188,6 +191,7 @@ Se refresca solo cada pocos segundos y no modifica nada en el repositorio. Neces
|
|
|
188
191
|
|---|---|
|
|
189
192
|
| `hopdeck` | Abre Hopdeck |
|
|
190
193
|
| `hopdeck shortcut on` / `hopdeck shortcut off` | Instala o quita el atajo para que `claude` abra Hopdeck |
|
|
194
|
+
| `hopdeck theme light` / `dark` / `auto` | Cambia el tema de colores y lo guarda (`hopdeck theme` muestra el actual) |
|
|
191
195
|
| `hopdeck uninstall` | **Desinstala Hopdeck por completo**: el atajo, tus preferencias y la caché, y el programa. Pregunta antes (sin terminal, usa `--yes`). No toca tu historial de Claude Code |
|
|
192
196
|
| `hopdeck doctor` | Revisa tu instalación y dice cómo arreglar lo que falte |
|
|
193
197
|
| `hopdeck --list` | Lista los proyectos en texto plano |
|
|
@@ -211,7 +215,7 @@ Casi nunca hace falta tocar nada. Lo más útil:
|
|
|
211
215
|
| Variable de entorno | Efecto |
|
|
212
216
|
|---|---|
|
|
213
217
|
| `HOPDECK_LANG` | `es` o `en` (por defecto, el idioma del sistema) |
|
|
214
|
-
| `HOPDECK_THEME` | `light`
|
|
218
|
+
| `HOPDECK_THEME` | `light` o `dark`: manda sobre lo guardado con `hopdeck theme` |
|
|
215
219
|
| `HOPDECK_SIXEL` | `1` fuerza la imagen real al pasar el cursor por `[Image #N]`, `0` usa siempre bloques (por defecto se detecta) |
|
|
216
220
|
| `NO_COLOR` | Quita los colores |
|
|
217
221
|
| `CLAUDE_CONFIG_DIR` | Carpeta de Claude Code, si no es `~/.claude` |
|
|
@@ -262,7 +266,7 @@ Empieza siempre por `hopdeck doctor`.
|
|
|
262
266
|
|
|
263
267
|
**Quiero que `claude` vuelva a ser el de siempre.** `hopdeck shortcut off`, o `HOPDECK_SKIP=1 claude` para saltarlo una vez.
|
|
264
268
|
|
|
265
|
-
**Se ve mal en mi terminal.** Prueba `
|
|
269
|
+
**Se ve mal en mi terminal.** Prueba `hopdeck theme light` (fondo claro) o `NO_COLOR=1`.
|
|
266
270
|
|
|
267
271
|
## Colaborar y licencia
|
|
268
272
|
|
package/bin/hopdeck.js
CHANGED
|
@@ -12,13 +12,14 @@ const cp = require('child_process');
|
|
|
12
12
|
const readline = require('readline');
|
|
13
13
|
|
|
14
14
|
const { LANG, T } = require('../lib/i18n');
|
|
15
|
-
const { TRUE, NOCOL, LIGHT, fg, bg, R, C, cw, strW, fit, clean } = require('../lib/style');
|
|
16
|
-
const { baseName, tidy, home, shortPath, fuzzy, wrapText } = require('../lib/text');
|
|
15
|
+
const { TRUE, NOCOL, LIGHT, setTheme, isLight, fg, bg, R, C, cw, strW, fit, clean } = require('../lib/style');
|
|
16
|
+
const { baseName, tidy, home, shortPath, fold, queryWords, matchWords, fuzzy, wrapText } = require('../lib/text');
|
|
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
20
|
const { encodeSixel } = require('../lib/sixel');
|
|
21
21
|
const gitlib = require('../lib/git');
|
|
22
|
+
const deepsearch = require('../lib/deepsearch');
|
|
22
23
|
const { collectImages, decodePNG, decodeImage, scaleBox, fitSize, halfBlocks } = images;
|
|
23
24
|
const { parseKeys, KEYMAP, printable, editBuf, normalizeKeys } = require('../lib/keys');
|
|
24
25
|
const { stripJsonc, wtCtrlV, wtSettingsFile } = require('../lib/windows-terminal');
|
|
@@ -125,7 +126,7 @@ function ago(ms) {
|
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
// ───────────────────────── estado ─────────────────────────
|
|
128
|
-
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: '' };
|
|
129
|
+
const S = { auto: false, 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: '' };
|
|
129
130
|
const SIDEBAR = process.argv.includes('--sidebar');
|
|
130
131
|
let EMBED = false; // vista dividida con terminal embebido (Windows / sin tmux)
|
|
131
132
|
const E = { sessions: new Map(), shown: null, focus: 'left', pend: null, deps: null, mouse: CFG.mouse !== false, hideSide: false, git: !!CFG.git, note: null, sel: null, gallery: null, hover: null, sixelDetected: false, cell: { w: 10, h: 20 }, sixelKey: null, sixelAt: 0, sixelStale: false, sixelRetry: null };
|
|
@@ -153,55 +154,47 @@ async function reloadAsync(after, silent) {
|
|
|
153
154
|
|
|
154
155
|
const clamp = (n, a, b) => Math.max(a, Math.min(b, n));
|
|
155
156
|
|
|
157
|
+
/** Marca junto a una conversación: ↻N = es la misma conversación continuada N veces (se muestra solo la última); #xxxx = otra distinta con el mismo título. */
|
|
158
|
+
const sessTag = (s) => (s.parts ? '↻' + s.parts : s.dup ? '#' + s.id.slice(0, 4) : '');
|
|
159
|
+
|
|
156
160
|
function view() {
|
|
157
|
-
|
|
161
|
+
// La búsqueda son palabras sueltas, sin importar el orden, mayúsculas ni acentos: «vistas roles» encuentra «Roles y vistas».
|
|
162
|
+
// Cada conversación se compara con proyecto + título + primer mensaje; el proyecto entero sale si lo que se busca está en su nombre o ruta.
|
|
163
|
+
const ws = queryWords(S.query);
|
|
158
164
|
const base = S.projects.filter((p) => S.showHidden || !p.hidden);
|
|
159
165
|
const vis = (x) => S.showHidden || !CFG.archived.includes(x.id);
|
|
160
|
-
if (!
|
|
161
|
-
const hitS = (x) => (x.title + ' ' + x.first)
|
|
166
|
+
if (!ws.length) return base.map((p) => ({ p, ss: p.sessions.filter(vis) }));
|
|
167
|
+
const hitS = (p, x) => matchWords(ws, x._f || (x._f = fold(p.name + ' ' + x.title + ' ' + x.first))) || !!(S.deepHits && S.deepHits.has(x.id));
|
|
162
168
|
const out = [];
|
|
163
169
|
for (const p of base) {
|
|
164
|
-
const hit = (p.name + ' ' + p.cwd)
|
|
165
|
-
const ss = (hit ? p.sessions : p.sessions.filter(hitS)).filter(vis);
|
|
170
|
+
const hit = matchWords(ws, p._f || (p._f = fold(p.name + ' ' + p.cwd)));
|
|
171
|
+
const ss = (hit ? p.sessions : p.sessions.filter((x) => hitS(p, x))).filter(vis);
|
|
166
172
|
if (hit || ss.length) out.push({ p, ss });
|
|
167
173
|
}
|
|
168
174
|
return out;
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
// búsqueda dentro del texto de las conversaciones (Tab en el modo búsqueda)
|
|
172
|
-
let deepT = null, deepTok = 0, deepPrev = null;
|
|
173
|
-
async function fileHas(file, q) {
|
|
174
|
-
let fh; try { fh = await fs.promises.open(file, 'r'); } catch { return false; }
|
|
175
|
-
try {
|
|
176
|
-
const st = await fh.stat(); if (st.size > 40 * 1024 * 1024) return false;
|
|
177
|
-
const buf = Buffer.alloc(256 * 1024); let pos = 0, carry = '';
|
|
178
|
-
while (pos < st.size) {
|
|
179
|
-
const { bytesRead } = await fh.read(buf, 0, buf.length, pos); if (!bytesRead) break;
|
|
180
|
-
const text = carry + buf.toString('utf8', 0, bytesRead).toLowerCase();
|
|
181
|
-
if (text.includes(q)) return true;
|
|
182
|
-
carry = text.slice(-q.length); pos += bytesRead;
|
|
183
|
-
}
|
|
184
|
-
return false;
|
|
185
|
-
} finally { await fh.close(); }
|
|
186
|
-
}
|
|
177
|
+
// búsqueda dentro del texto de las conversaciones (Tab en el modo búsqueda): en hilos de trabajo y con los aciertos en directo
|
|
178
|
+
let deepT = null, deepTok = 0, deepPrev = null, deepJob = null;
|
|
187
179
|
function queryChanged() {
|
|
188
180
|
clearTimeout(deepT); deepTok++; S.deepHits = null;
|
|
189
|
-
if (
|
|
190
|
-
|
|
181
|
+
if (deepJob) { deepJob.cancel(); deepJob = null; }
|
|
182
|
+
// Si ningún título ni proyecto coincide, se busca solo dentro del contenido sin que haya que pedirlo con Tab
|
|
183
|
+
S.auto = !S.deep && S.query.trim().length >= 3 && !view().length;
|
|
184
|
+
const deepOn = S.deep || S.auto;
|
|
185
|
+
if (!deepOn || !S.query.trim()) deepPrev = null;
|
|
186
|
+
if (!deepOn || S.query.trim().length < 3) { if (!reloading) S.loading = false; return; }
|
|
191
187
|
const tok = deepTok; S.loading = true; ensureSpin();
|
|
192
|
-
deepT = setTimeout(
|
|
188
|
+
deepT = setTimeout(() => {
|
|
193
189
|
const q = S.query.trim().toLowerCase(), hits = new Set();
|
|
194
190
|
const all = S.projects.flatMap((p) => p.sessions);
|
|
195
191
|
// si la búsqueda anterior era un prefijo de esta, solo hay que mirar sus aciertos
|
|
196
|
-
const list = deepPrev && q.startsWith(deepPrev.q) ? all.filter((x) => deepPrev.hits.has(x.id)) : all;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
}));
|
|
204
|
-
if (tok === deepTok) { S.deepHits = hits; deepPrev = { q, hits }; S.loading = false; if (active) render(); }
|
|
192
|
+
const list = (deepPrev && q.startsWith(deepPrev.q) ? all.filter((x) => deepPrev.hits.has(x.id)) : all).filter((x) => x.file);
|
|
193
|
+
const idOf = new Map(list.map((x) => [x.file, x.id]));
|
|
194
|
+
S.deepHits = hits; // se va llenando: los aciertos aparecen en la lista según se encuentran
|
|
195
|
+
const job = deepsearch.deepSearch(list.map((x) => x.file), q, (file) => { if (tok !== deepTok) return; hits.add(idOf.get(file)); if (active) scheduleRender(); });
|
|
196
|
+
deepJob = job;
|
|
197
|
+
job.done.then(() => { if (tok === deepTok) { deepPrev = { q, hits }; S.loading = false; deepJob = null; if (active) render(); } });
|
|
205
198
|
}, 250);
|
|
206
199
|
}
|
|
207
200
|
|
|
@@ -275,7 +268,7 @@ function frame(cols, rows) {
|
|
|
275
268
|
const tw = rw - 2 - when.length - 2;
|
|
276
269
|
right = fit([[mark, C.accent], [e.title, sel ? C.text + C.bold : C.text],
|
|
277
270
|
[e.first && e.first !== e.title ? ' ' + e.first : '', C.dim],
|
|
278
|
-
[e
|
|
271
|
+
[sessTag(e) ? ' ' + sessTag(e) : '', C.accent]], tw + 2, base) +
|
|
279
272
|
fit([[' ' + when, C.dim]], rw - tw - 2, base);
|
|
280
273
|
}
|
|
281
274
|
} else right = ' '.repeat(rw);
|
|
@@ -348,18 +341,20 @@ function chatMark(id) {
|
|
|
348
341
|
|
|
349
342
|
/** Trocea `text` en segmentos [[texto, estilo]] resaltando las coincidencias (sin distinguir mayúsculas) con la búsqueda `q` (en minúsculas). */
|
|
350
343
|
function hl(text, q, style) {
|
|
351
|
-
const t = String(text);
|
|
352
|
-
if (!
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
const
|
|
356
|
-
for (let at =
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
344
|
+
const t = String(text), ws = queryWords(q);
|
|
345
|
+
if (!ws.length) return [[t, style]];
|
|
346
|
+
const f = fold(t);
|
|
347
|
+
if (f.length !== t.length) return [[t, style]]; // algunas letras cambian de largo al plegarlas: no se resalta
|
|
348
|
+
const on = new Array(t.length).fill(false); // cada palabra de la búsqueda, en cualquier parte y sin importar acentos ni mayúsculas
|
|
349
|
+
for (const w of ws) for (let at = f.indexOf(w); at >= 0; at = f.indexOf(w, at + w.length)) for (let i = at; i < at + w.length; i++) on[i] = true;
|
|
350
|
+
if (!on.includes(true)) return [[t, style]];
|
|
351
|
+
const out = [];
|
|
352
|
+
for (let i = 0; i < t.length;) {
|
|
353
|
+
let j = i; while (j < t.length && on[j] === on[i]) j++;
|
|
354
|
+
out.push([t.slice(i, j), on[i] ? C.brand + C.bold : style]);
|
|
355
|
+
i = j;
|
|
360
356
|
}
|
|
361
|
-
|
|
362
|
-
return out.length ? out : [[t, style]];
|
|
357
|
+
return out;
|
|
363
358
|
}
|
|
364
359
|
|
|
365
360
|
/** Resumen de los chats abiertos para la cabecera de la lista: trabajando ⠋, terminados sin ver ✔, abiertos ●. */
|
|
@@ -383,9 +378,19 @@ function frameTree(W, H) {
|
|
|
383
378
|
const bodyH = H - 5;
|
|
384
379
|
S.coff = scroll(S.coff, S.c, bodyH);
|
|
385
380
|
const lines = [];
|
|
386
|
-
|
|
381
|
+
const searchOn = !S.fb && !S.qs && S.prompt === null && !S.help && (S.searching || !!S.query.trim()); // hay una búsqueda en marcha
|
|
382
|
+
const head = [[' » ', C.brand], ['Hop', C.brand + C.bold], ['deck', C.text + C.bold], [' ' + S.projects.length, C.dim], [S.loading && !searchOn ? ' ' + spin() : '', C.accent], ...liveSummary()];
|
|
383
|
+
// «⌕ / buscar» siempre a la vista, arriba a la derecha (sin la palabra si el título y los chats abiertos ya ocupan el sitio)
|
|
384
|
+
const headW = head.reduce((a, [t]) => a + strW(t), 0), longHint = ' ⌕ / ' + T.k.find + ' ', hint = headW + strW(longHint) <= W ? longHint : headW + 5 <= W ? ' ⌕ / ' : '';
|
|
385
|
+
lines.push(searchOn
|
|
386
|
+
// el cuadro de búsqueda ocupa el lugar del título, arriba, donde se mira primero
|
|
387
|
+
? fit([[' ⌕ ', C.accent], ...withCursor(S.query, S.searching ? S.qpos : [...S.query].length, S.searching), [S.query ? '' : ' ' + T.searchPh, C.dim]], W)
|
|
388
|
+
: hint && !S.fb && !S.qs && S.prompt === null && !S.help ? fit(head, W - strW(hint)) + fit([[' ⌕ ', C.accent], ['/ ', C.accent + C.bold], [hint.slice(5), C.dim]], strW(hint))
|
|
389
|
+
: fit(head, W));
|
|
387
390
|
lines.push(C.faint + '─'.repeat(W) + R);
|
|
388
391
|
const sq0 = S.query.trim().toLowerCase(); // búsqueda activa: se resaltan las coincidencias
|
|
392
|
+
const qWords = searchOn ? queryWords(S.query) : [];
|
|
393
|
+
const nHits = searchOn ? L.filter((x) => x.t === 's' || (x.t === 'p' && !x.open)).length : 0; // conversaciones que coinciden (o el proyecto, si coincidió su nombre)
|
|
389
394
|
const qsList = S.qs ? qsItems() : null;
|
|
390
395
|
const fbList = S.fb && !S.qs ? fbRows() : null;
|
|
391
396
|
if (fbList) { S.fb.i = clamp(S.fb.i, 0, Math.max(0, fbList.length - 1)); S.fb.off = scroll(S.fb.off, S.fb.i, bodyH); lines[0] = fit([[' » ' + T.fbTitle, C.accent + C.bold]], W); }
|
|
@@ -418,6 +423,11 @@ function frameTree(W, H) {
|
|
|
418
423
|
}
|
|
419
424
|
if (S.help) { const t = T.help[r]; lines.push(fit([[t ? ' ' + t : '', r === 0 ? C.accent + C.bold : C.dim]], W)); continue; }
|
|
420
425
|
const e = L[S.coff + r];
|
|
426
|
+
if (!e && searchOn && !L.length && r <= 2) { // búsqueda sin resultados: se dice, y se explica qué hacer
|
|
427
|
+
const msg = r === 0 ? [[' ' + T.noRes(S.query.trim()), C.warn]]
|
|
428
|
+
: r === 2 ? [[' ' + ((S.deep || S.auto) ? (S.loading ? spin() + ' ' + T.searchingContent : '') : T.tryContent), C.dim]] : [];
|
|
429
|
+
lines.push(fit(msg, W)); continue;
|
|
430
|
+
}
|
|
421
431
|
if (!e) { lines.push(' '.repeat(W)); continue; }
|
|
422
432
|
const sel = S.coff + r === S.c;
|
|
423
433
|
const base = sel ? (EMBED && E.focus === 'right' ? C.selOff : C.selOn) : '';
|
|
@@ -441,8 +451,8 @@ function frameTree(W, H) {
|
|
|
441
451
|
lines.push(fit([mark, [' + ', C.accent], [T.newChat, sel ? C.accent + C.bold : C.accent]], W, base));
|
|
442
452
|
} else {
|
|
443
453
|
const [mk, mc] = chatMark(e.s.id);
|
|
444
|
-
const arch = CFG.archived.includes(e.s.id), tag = e.s
|
|
445
|
-
const ts = sel ? C.text + C.bold : arch ? C.dim : C.text, inTxt =
|
|
454
|
+
const arch = CFG.archived.includes(e.s.id), tag = sessTag(e.s);
|
|
455
|
+
const ts = sel ? C.text + C.bold : arch ? C.dim : C.text, inTxt = qWords.length && !matchWords(qWords, fold(e.s.title)); // ⌕: coincide por el proyecto, el primer mensaje o el contenido
|
|
446
456
|
lines.push(fit([mark, [' ', ''], [mk, mc], ...hl(e.s.title, sq0, ts), ...(inTxt ? [[' ⌕', C.dim]] : [])], W - 13, base) +
|
|
447
457
|
fit([[tag.padEnd(6), C.accent], [ago(e.s.mtime).padStart(6), C.dim], [' ', '']], 13, base));
|
|
448
458
|
}
|
|
@@ -451,7 +461,10 @@ function frameTree(W, H) {
|
|
|
451
461
|
lines.push(C.faint + '─'.repeat(W) + R);
|
|
452
462
|
const br = cur && !S.flash ? gitBranch(cur.p.cwd) : '';
|
|
453
463
|
const note = EMBED && E.note;
|
|
454
|
-
|
|
464
|
+
const deepOn = S.deep || S.auto;
|
|
465
|
+
lines.push(fit(S.flash ? [[' ' + S.flash, C.warn]] : searchOn // durante una búsqueda, esta fila dice cuántos resultados hay y dónde se busca
|
|
466
|
+
? [[' ', ''], nHits ? [T.found(nHits), C.accent + C.bold] : [T.noMatch, C.warn], deepOn ? [S.loading ? ' ' + spin() + ' ' + T.searchingContent : ' · ' + T.inContent, C.dim] : ['', '']]
|
|
467
|
+
: S.fb ? [[S.prompt !== null ? ' ' + T.mkIn + ' ' : ' ⌂ ', C.dim], [tailFit(S.fb.dir === '' ? T.fbDrives : shortPath(S.fb.dir) + (S.prompt !== null ? path.sep : ''), W - 14), C.accent]] : note ? [[' ' + note.t, C.ok]]
|
|
455
468
|
: [[br ? ' ⎇ ' + br + ' ' : '', C.accent], [cur ? (br ? '' : ' ⌂ ') + shortPath(cur.p.cwd) : '', C.dim]], W));
|
|
456
469
|
if (S.qs) {
|
|
457
470
|
lines.push(fit([[' ⌕ ', C.accent], ...withCursor(S.qs.q, S.qs.pc), [S.qs.q ? '' : ' ' + T.qsHint, C.dim]], W));
|
|
@@ -460,9 +473,10 @@ function frameTree(W, H) {
|
|
|
460
473
|
lines.push(fit([[rn ? ' ✎ ' : ' ⌂ ', C.accent], ...withCursor(S.prompt, S.pc), [S.prompt ? '' : ' ' + (rn ? T.renameLbl : T.pathPrompt) + '…', C.dim]], W));
|
|
461
474
|
} else if (S.fb) {
|
|
462
475
|
lines.push(fit(S.fb.filt || S.fb.q ? [[' / ', C.accent], ...withCursor(S.fb.q, S.fb.qp, S.fb.filt)] : [[' ' + T.fbHint, C.dim]], W));
|
|
463
|
-
} else if (
|
|
464
|
-
|
|
465
|
-
|
|
476
|
+
} else if (searchOn) {
|
|
477
|
+
// teclas de la búsqueda: mientras se escribe, ⏎ abre la conversación marcada; con la búsqueda ya aceptada, / permite editarla
|
|
478
|
+
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],
|
|
479
|
+
['esc', C.accent], [' ' + (S.searching ? T.kEsc : T.kClear), C.dim]], W));
|
|
466
480
|
} else {
|
|
467
481
|
const k = T.k, segs = [[' ', '']];
|
|
468
482
|
const keys = !cur ? [['⏎', k.open], ['n', k.neu], ['/', k.find], ['?', T.kHelp]]
|
|
@@ -556,7 +570,8 @@ function doRename(x, name) {
|
|
|
556
570
|
|
|
557
571
|
function adjustSidebar(d) {
|
|
558
572
|
const cur = EMBED ? embedLayout().SW || 36 : process.stdout.columns || 40;
|
|
559
|
-
|
|
573
|
+
const lim = EMBED ? panelLimits(process.stdout.columns || 100) : { min: 24, max: 80 };
|
|
574
|
+
CFG.sidebar = clamp(cur + d, lim.min, lim.max); saveCfg();
|
|
560
575
|
if (EMBED) return embedResize();
|
|
561
576
|
if (SIDEBAR) { try { tmux('resize-pane', '-t', process.env.TMUX_PANE, '-x', String(CFG.sidebar)); } catch { /* */ } render(); }
|
|
562
577
|
}
|
|
@@ -739,11 +754,21 @@ function onKeyTree(raw) {
|
|
|
739
754
|
if (S.fb) return fbKey(k, raw);
|
|
740
755
|
if (S.searching) {
|
|
741
756
|
if (k === 'esc') { S.query = ''; S.searching = false; S.c = 0; queryChanged(); }
|
|
742
|
-
else if (k === 'enter')
|
|
757
|
+
else if (k === 'enter') {
|
|
758
|
+
S.searching = false;
|
|
759
|
+
const en = L[S.c]; // con una conversación marcada, ⏎ la abre ya (como el salto rápido); sobre un proyecto solo termina de escribir
|
|
760
|
+
if (en && en.t === 's') { render(); return launch(en.p, en.s); }
|
|
761
|
+
}
|
|
743
762
|
else if (k === '\t') { S.deep = !S.deep; queryChanged(); }
|
|
744
763
|
else if (k === 'up') S.c = Math.max(0, S.c - 1);
|
|
745
764
|
else if (k === 'down') S.c = Math.min(L.length - 1, S.c + 1);
|
|
746
|
-
else {
|
|
765
|
+
else {
|
|
766
|
+
const r = editBuf(S.query, S.qpos, k, raw);
|
|
767
|
+
if (r) {
|
|
768
|
+
const ch = r.s !== S.query; S.query = r.s; S.qpos = r.pos;
|
|
769
|
+
if (ch) { queryChanged(); const i = flatList().findIndex((x) => x.t === 's'); S.c = S.query.trim() && i >= 0 ? i : 0; } // se marca el primer resultado
|
|
770
|
+
}
|
|
771
|
+
}
|
|
747
772
|
return render();
|
|
748
773
|
}
|
|
749
774
|
S.flash = '';
|
|
@@ -783,6 +808,7 @@ function onKeyTree(raw) {
|
|
|
783
808
|
const key = e && e.t === 's' && S.live.has(e.s.id) ? (chatKeyOf(e.s.id) || e.s.id) : e && e.t === 'l' ? e.key : EMBED ? E.shown : null;
|
|
784
809
|
return key ? closeChat(key) : flash(T.notOpen);
|
|
785
810
|
}
|
|
811
|
+
case 't': case 'f9': return toggleTheme(); // tema claro/oscuro en caliente
|
|
786
812
|
case 'b': return toggleGit(); // panel de git (F8 en macOS pide Fn: por defecto son las teclas multimedia)
|
|
787
813
|
case 'i': case 'f7':
|
|
788
814
|
if (e && e.t === 's') {
|
|
@@ -866,14 +892,42 @@ function loadDeps() {
|
|
|
866
892
|
try { return { pty: require('@lydell/node-pty'), Terminal: require('@xterm/headless').Terminal }; } catch { return null; }
|
|
867
893
|
}
|
|
868
894
|
|
|
895
|
+
/** Límites de un panel lateral al arrastrar su borde con el ratón: del 15 % al 50 % del ancho (y nunca menos de 20 columnas). */
|
|
896
|
+
const panelLimits = (W) => ({ min: Math.min(Math.max(20, Math.round(W * 0.15)), Math.floor(W * 0.5)), max: Math.max(20, Math.floor(W * 0.5)) });
|
|
897
|
+
/** Ancho de la lista (panel izquierdo): el guardado por el usuario, o 30 % del terminal por defecto. */
|
|
898
|
+
const sideWidth = (W) => (E.hideSide ? 0 : CFG.sidebar ? clamp(CFG.sidebar, panelLimits(W).min, panelLimits(W).max) : clamp(Math.floor(W * 0.3), 36, 46));
|
|
899
|
+
/** Ancho del panel de git (derecho): el guardado por el usuario, o GIT_W por defecto. */
|
|
900
|
+
const gitWidth = (W) => (CFG.gitw ? clamp(CFG.gitw, panelLimits(W).min, panelLimits(W).max) : GIT_W);
|
|
901
|
+
|
|
869
902
|
function embedLayout() {
|
|
870
903
|
const W = process.stdout.columns || 100, H = process.stdout.rows || 30;
|
|
871
|
-
const SW =
|
|
904
|
+
const SW = sideWidth(W);
|
|
872
905
|
const room = Math.max(10, W - SW - (SW ? 1 : 0));
|
|
873
|
-
const
|
|
906
|
+
const gw = gitWidth(W);
|
|
907
|
+
const GW = E.git && room - gw - 1 >= GIT_MIN_CHAT ? gw : 0; // tercer panel (git): solo si el chat conserva un ancho cómodo
|
|
874
908
|
return { W, H, SW, GW, rw: GW ? room - GW - 1 : room, rh: Math.max(3, H - 1), th: Math.max(3, H - 3) };
|
|
875
909
|
}
|
|
876
910
|
|
|
911
|
+
/**
|
|
912
|
+
* Arrastre de una línea divisoria: `x` es la columna (desde 1) donde está el ratón. La lista ocupa las columnas anteriores
|
|
913
|
+
* a la línea y el panel de git las posteriores. El chat conserva siempre su ancho mínimo, así el panel de git no desaparece.
|
|
914
|
+
*/
|
|
915
|
+
function dragPanel(which, x) {
|
|
916
|
+
const { W, SW, GW } = embedLayout(), l = panelLimits(W);
|
|
917
|
+
if (which === 'side') {
|
|
918
|
+
const hi = Math.max(l.min, Math.min(l.max, W - 1 - (GW ? GW + 1 + GIT_MIN_CHAT : 40)));
|
|
919
|
+
const n = clamp(x - 1, l.min, hi);
|
|
920
|
+
if (n === SW) return;
|
|
921
|
+
CFG.sidebar = n;
|
|
922
|
+
} else {
|
|
923
|
+
const hi = Math.max(l.min, Math.min(l.max, W - (SW ? SW + 1 : 0) - 1 - GIT_MIN_CHAT));
|
|
924
|
+
const n = clamp(W - x, l.min, hi);
|
|
925
|
+
if (n === GW) return;
|
|
926
|
+
CFG.gitw = n;
|
|
927
|
+
}
|
|
928
|
+
embedResize();
|
|
929
|
+
}
|
|
930
|
+
|
|
877
931
|
// ───────────────────────── panel de git (tercer panel, F8) ─────────────────────────
|
|
878
932
|
const GIT_W = 38, GIT_MIN_CHAT = 60;
|
|
879
933
|
const GITC = new Map(); // carpeta → { t, loading, data }
|
|
@@ -894,8 +948,8 @@ const gitCwd = () => {
|
|
|
894
948
|
function toggleGit() {
|
|
895
949
|
if (!EMBED) return flash(T.gitOnlyEmbed);
|
|
896
950
|
if (!E.git) {
|
|
897
|
-
const
|
|
898
|
-
const need = SW + (SW ? 1 : 0) + GIT_MIN_CHAT +
|
|
951
|
+
const W = process.stdout.columns || 100, SW = sideWidth(W);
|
|
952
|
+
const need = SW + (SW ? 1 : 0) + GIT_MIN_CHAT + gitWidth(W) + 1;
|
|
899
953
|
if ((process.stdout.columns || 100) < need) return flash(T.gitNarrow(need));
|
|
900
954
|
}
|
|
901
955
|
E.git = !E.git; CFG.git = E.git; saveCfg();
|
|
@@ -1151,7 +1205,7 @@ function hoverPopup(hv, rw, th) {
|
|
|
1151
1205
|
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); }
|
|
1152
1206
|
rows = hb; tw = sz.tw;
|
|
1153
1207
|
} else {
|
|
1154
|
-
const txt = d === undefined ? spin() + ' …' : T.imgNoPrev
|
|
1208
|
+
const txt = d === undefined ? spin() + ' …' : `${T.imgNoPrev} (${img.media || '?'})`; // el formato ayuda a saber por qué no se pudo leer
|
|
1155
1209
|
tw = Math.max(strW(lab) + 1, Math.min(strW(txt) + 2, Math.max(8, rw - 4)));
|
|
1156
1210
|
rows = [fit([[' ' + txt, d === false ? C.warn : C.accent]], tw)];
|
|
1157
1211
|
}
|
|
@@ -1326,7 +1380,8 @@ function renderEmbed() {
|
|
|
1326
1380
|
const popRow = (ty) => (pop && ty >= pop.top && ty < pop.top + pop.rows.length
|
|
1327
1381
|
? termRow(sh.term, ty, pop.left, selRange(ty, rw)) + pop.rows[ty - pop.top] + termRow(sh.term, ty, rw - pop.left - pop.bw, selRange(ty, rw), pop.left + pop.bw)
|
|
1328
1382
|
: null);
|
|
1329
|
-
const div = (E.focus === 'right' ? C.accent : C.faint) + '│' + R;
|
|
1383
|
+
const div = (E.drag === 'side' || E.focus === 'right' ? C.accent : C.faint) + '│' + R;
|
|
1384
|
+
const gdiv = (E.drag === 'git' ? C.accent : C.faint) + '│' + R; // la línea que se está arrastrando se resalta
|
|
1330
1385
|
const gitR = GW ? gitRows(GW, rh) : null;
|
|
1331
1386
|
for (let y = 0; y < rh; y++) {
|
|
1332
1387
|
const ty = y - 2; // las 2 primeras filas del panel derecho son el título y su línea
|
|
@@ -1336,7 +1391,7 @@ function renderEmbed() {
|
|
|
1336
1391
|
: y === 1 ? C.faint + '─'.repeat(rw) + R : gRows[ty])
|
|
1337
1392
|
: y === 0 ? headerRow(hdr, rw) : y === 1 ? C.faint + '─'.repeat(rw) + R
|
|
1338
1393
|
: 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);
|
|
1339
|
-
rowsOut.push((left ? (left[y] || ' '.repeat(SW)) + div : '') + right + (gitR ?
|
|
1394
|
+
rowsOut.push((left ? (left[y] || ' '.repeat(SW)) + div : '') + right + (gitR ? gdiv + gitR[y] : ''));
|
|
1340
1395
|
}
|
|
1341
1396
|
const live = E.sessions.size;
|
|
1342
1397
|
const k = (key, d) => [[key, C.accent], [' ' + d + ' ', C.dim]];
|
|
@@ -1484,6 +1539,7 @@ function sidebarMouse(b, x, y, type, rows = process.stdout.rows || 30) {
|
|
|
1484
1539
|
return render();
|
|
1485
1540
|
}
|
|
1486
1541
|
if (type !== 'M' || (b & 3) !== 0 || (b & 32)) return; // solo clic izquierdo (no soltar, ni arrastrar, ni otros botones)
|
|
1542
|
+
if (y === 1 && !S.help && !S.fb && !S.qs && S.prompt === null) { S.searching = true; S.qpos = [...S.query].length; return render(); } // clic en la fila de arriba: buscar
|
|
1487
1543
|
if (S.help || S.prompt !== null || y < 3 || y > rows - 3) return; // las filas de la lista van de la 3 a rows-3
|
|
1488
1544
|
if (S.qs) { const i = S.qs.off + (y - 3); if (qsItems()[i]) { S.qs.i = i; return onKeyTree('\r'); } return; }
|
|
1489
1545
|
if (S.fb) { const i = S.fb.off + (y - 3); if (fbRows()[i]) { S.fb.i = i; fbActivate(); } return; }
|
|
@@ -1495,6 +1551,15 @@ function onMouse(b, x, y, type) {
|
|
|
1495
1551
|
if (E.gallery) return;
|
|
1496
1552
|
const { SW, GW, rw, rh } = embedLayout();
|
|
1497
1553
|
const sh = E.sessions.get(E.shown);
|
|
1554
|
+
// líneas divisorias arrastrables (columna de cada '│'): lista|chat y chat|git
|
|
1555
|
+
const sx = SW ? SW + 1 : 0, gx = GW ? sx + rw + 1 : 0;
|
|
1556
|
+
if (E.drag) {
|
|
1557
|
+
if (type === 'm') { E.drag = null; saveCfg(); return render(); }
|
|
1558
|
+
if ((b & 32) && (b & 3) === 0) return dragPanel(E.drag, x);
|
|
1559
|
+
} else if (type === 'M' && !(b & 96) && (b & 3) === 0 && y <= rh && ((SW && x === sx) || (GW && x === gx))) {
|
|
1560
|
+
E.drag = x === sx ? 'side' : 'git'; E.sel = null; E.hover = null;
|
|
1561
|
+
return render();
|
|
1562
|
+
}
|
|
1498
1563
|
if (GW && x > (SW ? SW + 1 : 0) + rw) { if (E.hover) { E.hover = null; scheduleRender(); } return; } // el panel de git es de solo lectura
|
|
1499
1564
|
if (b & 64) { // rueda
|
|
1500
1565
|
E.hover = null;
|
|
@@ -1529,6 +1594,7 @@ function onMouse(b, x, y, type) {
|
|
|
1529
1594
|
return render();
|
|
1530
1595
|
}
|
|
1531
1596
|
if (type !== 'M' || (b & 3) !== 0) return; // solo clic izquierdo
|
|
1597
|
+
if (x <= SW && y === 1 && !S.fb && !S.qs && S.prompt === null && !S.help) { E.focus = 'left'; E.sel = null; S.searching = true; S.qpos = [...S.query].length; return render(); } // clic en la fila de arriba de la lista: buscar
|
|
1532
1598
|
if (inPane) { E.focus = 'right'; const c = cell(); E.sel = { a: c, b: c, down: true }; return render(); }
|
|
1533
1599
|
E.sel = null;
|
|
1534
1600
|
if (S.fb && x <= SW) {
|
|
@@ -1741,6 +1807,13 @@ function back(key) {
|
|
|
1741
1807
|
}
|
|
1742
1808
|
|
|
1743
1809
|
let flashT;
|
|
1810
|
+
/** Cambia entre el tema claro y el oscuro sin reiniciar, y lo recuerda para la próxima vez. */
|
|
1811
|
+
function toggleTheme() {
|
|
1812
|
+
const next = isLight() ? 'dark' : 'light';
|
|
1813
|
+
setTheme(next); CFG.theme = next; saveCfg();
|
|
1814
|
+
invalidate(); // todas las filas se repintan con los colores nuevos
|
|
1815
|
+
flash(T.themeNow(next));
|
|
1816
|
+
}
|
|
1744
1817
|
function flash(msg) { S.flash = msg; render(); clearTimeout(flashT); flashT = setTimeout(() => { S.flash = ''; render(); }, 2500); }
|
|
1745
1818
|
|
|
1746
1819
|
|
|
@@ -1849,6 +1922,7 @@ async function run() {
|
|
|
1849
1922
|
if (s === '\x1b[17~' && E.focus === 'right') return closeChat(E.shown);
|
|
1850
1923
|
if (s === '\x1b[18~') return openGalleryShown();
|
|
1851
1924
|
if (s === '\x1b[19~') return toggleGit();
|
|
1925
|
+
if (s === '\x1b[20~') return toggleTheme();
|
|
1852
1926
|
if (s === '\x1b[15~') { E.focus = 'left'; if (E.hideSide) E.hideSide = false; S.qs = { q: '', pc: 0, i: 0, off: 0 }; return embedResize(); }
|
|
1853
1927
|
if (s === '\x1bOS' || s === '\x1b[14~') {
|
|
1854
1928
|
E.hideSide = !E.hideSide && E.sessions.has(E.shown);
|
|
@@ -2124,9 +2198,9 @@ function tutorial(afterInstall) {
|
|
|
2124
2198
|
|
|
2125
2199
|
// ───────────────────────── entrada ─────────────────────────
|
|
2126
2200
|
// ── Comandos: UNA sola forma para cada uno (shortcut on|off, uninstall, doctor, help). Lo demás no hace nada: da un error con una sugerencia ──
|
|
2127
|
-
const COMMANDS = ['shortcut', 'uninstall', 'doctor', 'help'];
|
|
2201
|
+
const COMMANDS = ['shortcut', 'theme', 'uninstall', 'doctor', 'help'];
|
|
2128
2202
|
// Palabras que alguien escribiría para lo mismo: no son comandos y no se ejecutan, solo sirven para sugerir el correcto
|
|
2129
|
-
const SYNONYMS = { install: 'shortcut on', instalar: 'shortcut on', atajo: 'shortcut on', desinstalar: 'uninstall', remove: 'uninstall', delete: 'uninstall', ayuda: 'help', diagnostico: 'doctor', version: '--version', list: '--list' };
|
|
2203
|
+
const SYNONYMS = { install: 'shortcut on', instalar: 'shortcut on', atajo: 'shortcut on', desinstalar: 'uninstall', remove: 'uninstall', delete: 'uninstall', ayuda: 'help', diagnostico: 'doctor', version: '--version', list: '--list', tema: 'theme', modo: 'theme', mode: 'theme', dark: 'theme dark', light: 'theme light', oscuro: 'theme dark', claro: 'theme light' };
|
|
2130
2204
|
/** Nombre de comando si `arg` es exactamente uno (sin guiones ni variantes); null si no. */
|
|
2131
2205
|
const commandName = (arg) => (COMMANDS.includes(String(arg || '').toLowerCase()) ? String(arg).toLowerCase() : null);
|
|
2132
2206
|
const editDistance = (a, b) => { const d = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]); for (let j = 1; j <= b.length; j++) d[0][j] = j; for (let i = 1; i <= a.length; i++) for (let j = 1; j <= b.length; j++) d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)); return d[a.length][b.length]; };
|
|
@@ -2154,6 +2228,13 @@ function main() {
|
|
|
2154
2228
|
if (rest.length !== 1 || !['on', 'off'].includes(rest[0])) { console.error(`${C.warn}${T.shortcutUsage}${R}`); process.exit(2); }
|
|
2155
2229
|
install(rest[0] === 'off'); markAsked();
|
|
2156
2230
|
}
|
|
2231
|
+
else if (commandName(cmd) === 'theme') { // hopdeck theme [light|dark|auto]: guarda el tema (la variable HOPDECK_THEME manda sobre esto)
|
|
2232
|
+
if (rest.length > 1 || (rest[0] && !['light', 'dark', 'auto'].includes(rest[0]))) { console.error(`${C.warn}${T.themeUsage}${R}`); process.exit(2); }
|
|
2233
|
+
if (rest[0]) { if (rest[0] === 'auto') delete CFG.theme; else CFG.theme = rest[0]; saveCfg(); }
|
|
2234
|
+
const env = !!process.env.HOPDECK_THEME; // lo que se usará la próxima vez que abras Hopdeck
|
|
2235
|
+
const eff = env ? (LIGHT ? 'light' : 'dark') : CFG.theme || (/;(7|15)$/.test(process.env.COLORFGBG || '') ? 'light' : 'dark');
|
|
2236
|
+
console.log(T.themeShow(CFG.theme || 'auto', eff, CFG.theme ? 'config' : 'auto', env));
|
|
2237
|
+
}
|
|
2157
2238
|
else if (commandName(cmd) === 'uninstall') { // desinstalación completa: atajo, preferencias, caché y programa
|
|
2158
2239
|
if (rest.some((a) => a !== '--yes' && a !== '-y')) { console.error(`${C.warn}${T.unknownCmd(rest.find((a) => a !== '--yes' && a !== '-y'))}${R}\n${C.dim}${T.cmdList}${R}`); process.exit(2); }
|
|
2159
2240
|
uninstallAll({ yes: rest.length > 0 }).then((code) => process.exit(code), (e) => { console.error(e); process.exit(1); });
|
|
@@ -2183,6 +2264,6 @@ else {
|
|
|
2183
2264
|
readSession, buildProject, scan, scanAsync, finishScan, sortProjects, projectDirs,
|
|
2184
2265
|
view, flatList, stripBlock, offerShortcut, uninstallAll, commandName, suggestCommand, parseTermReplies, sixelOn, SNIP, MARK_A, MARK_B, toggleProject, cacheLoad, selNorm,
|
|
2185
2266
|
decodePNG, decodeImage, scaleBox, fitSize, halfBlocks, collectImages, extractImages,
|
|
2186
|
-
editBuf, normalizeKeys, stripJsonc, wtCtrlV, fbNames, fbOpen, fbRows, sidebarMouse, gitBranch, imageMarkerAt, shownSession, linkChats, findImageByNumber: images.findImageByNumber,
|
|
2267
|
+
onMouse, dragPanel, panelLimits, embedLayout, sessTag, editBuf, normalizeKeys, stripJsonc, wtCtrlV, fbNames, fbOpen, fbRows, sidebarMouse, toggleTheme, gitBranch, imageMarkerAt, shownSession, linkChats, findImageByNumber: images.findImageByNumber,
|
|
2187
2268
|
};
|
|
2188
2269
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Búsqueda dentro del contenido de las conversaciones (Tab en el modo búsqueda). Los archivos de historial pueden sumar
|
|
3
|
+
// gigas (imágenes en base64, resultados de herramientas), así que la búsqueda se hace en hilos de trabajo, en paralelo,
|
|
4
|
+
// y cada acierto se avisa en cuanto se encuentra. Sin dependencias.
|
|
5
|
+
//
|
|
6
|
+
// No se decodifica el texto: se busca con una expresión regular sobre los bytes del archivo (leídos como latin1).
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
|
|
10
|
+
|
|
11
|
+
const CHUNK = 1024 * 1024;
|
|
12
|
+
const MAX_SIZE = 256 * 1024 * 1024; // más grande que esto no se busca (antes 40 MB: se perdían las conversaciones más largas)
|
|
13
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
14
|
+
// eslint-disable-next-line no-control-regex
|
|
15
|
+
const isAscii = (s) => /^[\u0000-\u007f]*$/.test(s);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Expresión que busca `q` sin distinguir mayúsculas directamente sobre los bytes del archivo (leídos como latin1):
|
|
19
|
+
* cada letra se sustituye por las variantes (minúscula/mayúscula) codificadas en UTF-8. Así tampoco hace falta decodificar
|
|
20
|
+
* el texto cuando la búsqueda lleva acentos o eñes. `keep` = bytes que hay que arrastrar entre bloques de lectura.
|
|
21
|
+
*/
|
|
22
|
+
function buildMatcher(q) {
|
|
23
|
+
if (isAscii(q)) return { re: new RegExp(escapeRe(q), 'i'), keep: Math.max(0, q.length - 1) };
|
|
24
|
+
const parts = []; let bytes = 0;
|
|
25
|
+
for (const ch of q) {
|
|
26
|
+
const vs = [...new Set([ch, ch.toLowerCase(), ch.toUpperCase()])].filter((v) => [...v].length === 1).map((v) => Buffer.from(v, 'utf8').toString('latin1'));
|
|
27
|
+
bytes += Math.max(...vs.map((v) => v.length));
|
|
28
|
+
parts.push(vs.length > 1 ? '(?:' + vs.map(escapeRe).join('|') + ')' : escapeRe(vs[0]));
|
|
29
|
+
}
|
|
30
|
+
return { re: new RegExp(parts.join('')), keep: Math.max(0, bytes - 1) };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** ¿El archivo contiene `q` (sin distinguir mayúsculas)? Síncrono: pensado para correr en un hilo de trabajo. */
|
|
34
|
+
function fileHasSync(file, q) {
|
|
35
|
+
let fd;
|
|
36
|
+
try { fd = fs.openSync(file, 'r'); } catch { return false; }
|
|
37
|
+
try {
|
|
38
|
+
const size = fs.fstatSync(fd).size;
|
|
39
|
+
if (size > MAX_SIZE || !q) return false;
|
|
40
|
+
const { re, keep } = buildMatcher(q);
|
|
41
|
+
const buf = Buffer.alloc(CHUNK);
|
|
42
|
+
let pos = 0, carry = '';
|
|
43
|
+
while (pos < size) {
|
|
44
|
+
const n = fs.readSync(fd, buf, 0, CHUNK, pos);
|
|
45
|
+
if (!n) break;
|
|
46
|
+
pos += n;
|
|
47
|
+
const text = carry + buf.latin1Slice(0, n);
|
|
48
|
+
if (re.test(text)) return true;
|
|
49
|
+
carry = keep > 0 ? text.slice(-keep) : '';
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
} catch { return false; } finally { try { fs.closeSync(fd); } catch { /* */ } }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!isMainThread && workerData && workerData.deepSearch) {
|
|
56
|
+
// hilo de trabajo: recorre su parte de los archivos y avisa de cada acierto
|
|
57
|
+
const { files, q } = workerData;
|
|
58
|
+
for (const f of files) if (fileHasSync(f, q)) parentPort.postMessage({ hit: f });
|
|
59
|
+
parentPort.postMessage({ done: true });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Busca `q` en `files`. `onHit(file)` se llama en cuanto se encuentra un acierto. Devuelve { done: Promise, cancel() }.
|
|
64
|
+
* Reparte los archivos (los grandes primero) entre varios hilos; si no se pueden crear hilos, busca en el hilo principal por tandas.
|
|
65
|
+
*/
|
|
66
|
+
function deepSearch(files, q, onHit, { threads } = {}) {
|
|
67
|
+
let cancelled = false; const workers = [];
|
|
68
|
+
const cancel = () => { cancelled = true; for (const w of workers) { try { w.terminate(); } catch { /* */ } } };
|
|
69
|
+
const sized = files.map((f) => { let s = 0; try { s = fs.statSync(f).size; } catch { /* */ } return [f, s]; }).filter(([, s]) => s <= MAX_SIZE).sort((a, b) => b[1] - a[1]);
|
|
70
|
+
const n = Math.max(1, Math.min(threads || 4, os.cpus().length - 1 || 1, sized.length));
|
|
71
|
+
const parts = Array.from({ length: n }, () => []);
|
|
72
|
+
sized.forEach(([f], i) => parts[i % n].push(f));
|
|
73
|
+
const done = new Promise((resolve) => {
|
|
74
|
+
if (!sized.length) return resolve();
|
|
75
|
+
let left = parts.filter((p) => p.length).length;
|
|
76
|
+
const finish = () => { if (--left <= 0) resolve(); };
|
|
77
|
+
const fallback = (list) => { // sin hilos: en el hilo principal, cediendo el control entre archivos
|
|
78
|
+
let i = 0;
|
|
79
|
+
const step = () => { if (cancelled) return finish(); const t = Date.now(); while (i < list.length && Date.now() - t < 20) { const f = list[i++]; if (fileHasSync(f, q)) onHit(f); } if (i < list.length) setImmediate(step); else finish(); };
|
|
80
|
+
step();
|
|
81
|
+
};
|
|
82
|
+
for (const part of parts) {
|
|
83
|
+
if (!part.length) continue;
|
|
84
|
+
let w;
|
|
85
|
+
try { w = new Worker(__filename, { workerData: { deepSearch: true, files: part, q } }); } catch { fallback(part); continue; }
|
|
86
|
+
workers.push(w);
|
|
87
|
+
let ended = false; const end = () => { if (!ended) { ended = true; finish(); } };
|
|
88
|
+
w.on('message', (m) => { if (cancelled) return; if (m.hit) onHit(m.hit); else if (m.done) end(); });
|
|
89
|
+
w.on('error', end); w.on('exit', end);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return { done, cancel };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = { deepSearch, fileHasSync, MAX_SIZE };
|
package/lib/history.js
CHANGED
|
@@ -19,7 +19,7 @@ function textOf(content) {
|
|
|
19
19
|
// Caché del índice: solo se vuelven a leer las sesiones cuya fecha/tamaño cambió.
|
|
20
20
|
const CACHE_FILE = process.env.HOPDECK_CACHE || path.join(os.homedir(), '.hopdeck-cache.json');
|
|
21
21
|
// Sube la versión cuando cambie cómo se lee una sesión: así las cachés ya guardadas se reconstruyen en vez de repetir resultados antiguos.
|
|
22
|
-
const CACHE_VERSION =
|
|
22
|
+
const CACHE_VERSION = 3;
|
|
23
23
|
let CACHE = null, cacheDirty = false, cacheSeen = null;
|
|
24
24
|
/** Empieza un escaneo: las entradas de la caché que no se vean se descartan al terminar. */
|
|
25
25
|
const beginScan = () => { cacheSeen = new Set(); };
|
|
@@ -48,7 +48,7 @@ function readSession(file) {
|
|
|
48
48
|
const hit = cache.files[file];
|
|
49
49
|
if (hit && hit.m === st.mtimeMs && hit.z === st.size) return hit.d ? { ...hit.d, file, mtime: st.mtimeMs } : null;
|
|
50
50
|
const d = parseSession(file, st);
|
|
51
|
-
cache.files[file] = { m: st.mtimeMs, z: st.size, d: d ? { id: d.id, title: d.title, first: d.first, cwd: d.cwd } : null };
|
|
51
|
+
cache.files[file] = { m: st.mtimeMs, z: st.size, d: d ? { id: d.id, title: d.title, first: d.first, cwd: d.cwd, root: d.root, last: d.last } : null };
|
|
52
52
|
cacheDirty = true;
|
|
53
53
|
return d;
|
|
54
54
|
}
|
|
@@ -82,15 +82,19 @@ function parseSession(file, st) {
|
|
|
82
82
|
try { fd = fs.openSync(file, 'r'); } catch { return null; }
|
|
83
83
|
try {
|
|
84
84
|
const TAIL = 160 * 1024;
|
|
85
|
-
let cwd = '', first = '', custom = '', ai = '';
|
|
85
|
+
let cwd = '', first = '', custom = '', ai = '', root = '';
|
|
86
86
|
scanHead(fd, st.size, (line) => {
|
|
87
87
|
if (!line) return false;
|
|
88
88
|
const wantCwd = !cwd && line.includes('"cwd"');
|
|
89
89
|
const wantUser = !first && isType(line, 'user');
|
|
90
90
|
const wantTitle = line.includes('-title"');
|
|
91
|
-
|
|
91
|
+
const wantRoot = !root && !first && line.includes('"uuid"'); // el primer mensaje del archivo; el primer "user" ya lo trae si antes no hubo otro
|
|
92
|
+
if (wantCwd || wantUser || wantTitle || wantRoot) {
|
|
92
93
|
let j; try { j = JSON.parse(line); } catch { j = null; }
|
|
93
94
|
if (j) {
|
|
95
|
+
// Al reanudar o continuar una conversación, Claude Code crea un archivo nuevo que copia el historial desde el principio:
|
|
96
|
+
// todos comparten el uuid del primer mensaje, y eso permite saber que son la misma conversación.
|
|
97
|
+
if (!root && typeof j.uuid === 'string') root = j.uuid;
|
|
94
98
|
if (wantCwd && j.cwd) cwd = j.cwd;
|
|
95
99
|
if (j.type === 'custom-title' && j.customTitle) custom = j.customTitle;
|
|
96
100
|
if (j.type === 'ai-title' && j.aiTitle) ai = j.aiTitle;
|
|
@@ -118,7 +122,13 @@ function parseSession(file, st) {
|
|
|
118
122
|
}
|
|
119
123
|
const title = tidy(tCustom || custom || tAi || ai || first || '');
|
|
120
124
|
if (!title) return null; // sesión vacía
|
|
121
|
-
|
|
125
|
+
// fecha del último mensaje real: la fecha del archivo cambia también al abrir la conversación o al renombrarla
|
|
126
|
+
let last = 0;
|
|
127
|
+
for (let i = tail.length - 1; i >= 0 && !last; i--) {
|
|
128
|
+
if (!isType(tail[i], 'user') && !isType(tail[i], 'assistant')) continue;
|
|
129
|
+
try { const j = JSON.parse(tail[i]); if (j.type === 'user' || j.type === 'assistant') last = Date.parse(j.timestamp) || 0; } catch { /* línea cortada */ }
|
|
130
|
+
}
|
|
131
|
+
return { id: path.basename(file, '.jsonl'), file, title, first, cwd, root, last, mtime: st.mtimeMs };
|
|
122
132
|
} catch { return null; } finally { try { fs.closeSync(fd); } catch { /* */ } }
|
|
123
133
|
}
|
|
124
134
|
|
|
@@ -132,12 +142,35 @@ function projectDirs() {
|
|
|
132
142
|
try { return fs.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => path.join(root, d.name)); } catch { return []; }
|
|
133
143
|
}
|
|
134
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Las sesiones que comparten el primer mensaje (`root`) son la misma conversación: cada vez que se reanuda o se continúa tras
|
|
147
|
+
* agotar el contexto, Claude Code crea un archivo nuevo que contiene todo el anterior. Se deja solo la del mensaje más reciente
|
|
148
|
+
* (la que tiene el historial completo; no vale la fecha del archivo, que también cambia al abrir una conversación vieja) y se anota
|
|
149
|
+
* en `parts` cuántas continuaciones anteriores se plegaron. Las sesiones sin `root` nunca se juntan. Devuelve la lista por fecha.
|
|
150
|
+
*/
|
|
151
|
+
function foldContinuations(sessions) {
|
|
152
|
+
const groups = new Map(), out = [];
|
|
153
|
+
for (const x of sessions) {
|
|
154
|
+
if (!x.root) { out.push(x); continue; }
|
|
155
|
+
const g = groups.get(x.root);
|
|
156
|
+
if (g) g.push(x); else groups.set(x.root, [x]);
|
|
157
|
+
}
|
|
158
|
+
const at = (x) => x.last || x.mtime;
|
|
159
|
+
for (const g of groups.values()) {
|
|
160
|
+
const rep = g.reduce((a, b) => (at(b) > at(a) || (at(b) === at(a) && b.mtime > a.mtime) ? b : a));
|
|
161
|
+
if (g.length > 1) { rep.parts = g.length - 1; rep.prior = g.filter((x) => x !== rep).map((x) => x.id); }
|
|
162
|
+
out.push(rep);
|
|
163
|
+
}
|
|
164
|
+
return out.sort((a, b) => b.mtime - a.mtime);
|
|
165
|
+
}
|
|
166
|
+
|
|
135
167
|
function buildProject(dir) {
|
|
136
168
|
let files = [];
|
|
137
169
|
try { files = fs.readdirSync(dir).filter((f) => f.endsWith('.jsonl')); } catch { return null; }
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
140
|
-
|
|
170
|
+
const all = files.map((f) => readSession(path.join(dir, f))).filter(Boolean);
|
|
171
|
+
if (!all.length) return null;
|
|
172
|
+
all.sort((a, b) => b.mtime - a.mtime);
|
|
173
|
+
const sessions = foldContinuations(all);
|
|
141
174
|
const seen = {};
|
|
142
175
|
for (const x of sessions) { const k = x.title + '|' + x.first; seen[k] = (seen[k] || 0) + 1; }
|
|
143
176
|
for (const x of sessions) x.dup = seen[x.title + '|' + x.first] > 1;
|
|
@@ -146,4 +179,4 @@ function buildProject(dir) {
|
|
|
146
179
|
return { key, cwd, name: baseName(cwd), sessions, mtime: sessions[0].mtime };
|
|
147
180
|
}
|
|
148
181
|
|
|
149
|
-
module.exports = { CONFIG_DIR, CACHE_FILE, textOf, isType, cacheLoad, cacheSave, beginScan, endScan, readSession, parseSession, decodeDir, projectDirs, buildProject };
|
|
182
|
+
module.exports = { CONFIG_DIR, CACHE_FILE, textOf, isType, cacheLoad, cacheSave, beginScan, endScan, readSession, parseSession, foldContinuations, decodeDir, projectDirs, buildProject };
|
package/lib/i18n.js
CHANGED
|
@@ -21,7 +21,10 @@ const T = {
|
|
|
21
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',
|
|
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
|
-
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
|
+
unknownCmd: (c) => `Comando desconocido: "${c}"`, didYouMean: (s) => `¿Quisiste decir "${s}"?`, cmdList: 'Comandos: hopdeck shortcut on|off · theme light|dark|auto · uninstall · doctor · help (y --list, --version).\nLas opciones de claude (por ejemplo --model opus) se pasan tal cual: hopdeck --model opus',
|
|
25
|
+
themeNow: (n) => `Tema ${n === 'light' ? 'claro' : 'oscuro'} (guardado)`,
|
|
26
|
+
themeUsage: 'Uso: hopdeck theme light (claro) · hopdeck theme dark (oscuro) · hopdeck theme auto (según el terminal) · hopdeck theme (ver el actual)',
|
|
27
|
+
themeShow: (saved, eff, from, env) => `Tema guardado: ${saved === 'auto' ? 'automático' : saved === 'light' ? 'claro' : 'oscuro'}.\nSe está usando: ${eff === 'light' ? 'claro' : 'oscuro'}` + (env ? ' (la variable HOPDECK_THEME tiene prioridad sobre lo guardado).' : from === 'auto' ? ' (automático: oscuro salvo que el terminal diga que tiene fondo claro).' : '.'),
|
|
25
28
|
shortcutUsage: 'Uso: hopdeck shortcut on (instalar el atajo de claude) · hopdeck shortcut off (quitarlo)',
|
|
26
29
|
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',
|
|
27
30
|
unShortcutOff: 'Atajo quitado de tu perfil de shell', unNoShortcut: 'No había atajo instalado', unData: 'Preferencias y caché borradas', unProgram: 'Programa desinstalado (npm uninstall -g hopdeck)', unProgramFail: (p) => `El programa sigue en ${p}. Si no lo instalaste con npm, quítalo con tu gestor (pnpm, yarn…); si es una copia de código fuente, borra esa carpeta. Con npm: npm uninstall -g hopdeck`, unDone: 'Hopdeck se ha desinstalado. Si también lo instalaste en otro sitio (por ejemplo en WSL y en Windows), repite allí: hopdeck uninstall', unSkipNpm: 'Sin ejecutar npm (HOPDECK_NO_NPM). El comando sería: npm uninstall -g hopdeck',
|
|
@@ -38,9 +41,11 @@ const T = {
|
|
|
38
41
|
help: ['Teclas', '↑↓ j k mover', '⏎ → l abrir / desplegar', '← h volver / plegar', 'n nueva conversación',
|
|
39
42
|
'/ buscar (Tab: contenido)', 'p fijar proyecto ★', 'x H ocultar / ver ocultos', 'o abrir una carpeta',
|
|
40
43
|
'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',
|
|
41
|
-
'F1 F2 foco lista / chat', 'F3 copiar texto (ratón)', 'F4 ocultar la lista', 'b F8 panel de git', '⠋ ✔ ● trabajando · terminó · abierta', 'q salir'],
|
|
44
|
+
'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'],
|
|
42
45
|
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',
|
|
43
46
|
idle3: 'F1 proyectos · F2 chat', bar1: 'proyectos', bar2: 'chat', bar3: 'minimizar',
|
|
47
|
+
searchPh: 'buscar conversación o proyecto…', found: (n) => `${n} ${n === 1 ? 'resultado' : 'resultados'}`, noRes: (q) => `Sin resultados para «${q}»`,
|
|
48
|
+
searchingContent: 'Buscando dentro de las conversaciones…', tryContent: 'Pulsa Tab para buscar también dentro del contenido', inContent: 'en el contenido', kClear: 'limpiar', kEdit: 'editar', kEsc: 'salir',
|
|
44
49
|
inside: 'Ya estás dentro de Hopdeck (F1 para ir a la lista de proyectos).',
|
|
45
50
|
},
|
|
46
51
|
en: {
|
|
@@ -61,7 +66,10 @@ const T = {
|
|
|
61
66
|
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',
|
|
62
67
|
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
68
|
imgClickHint: 'click: open full size', imgOpened: (n) => `[Image #${n}] opened in the image viewer`,
|
|
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',
|
|
69
|
+
unknownCmd: (c) => `Unknown command: "${c}"`, didYouMean: (s) => `Did you mean "${s}"?`, cmdList: 'Commands: hopdeck shortcut on|off · theme light|dark|auto · uninstall · doctor · help (and --list, --version).\nclaude options (for example --model opus) are passed through as they are: hopdeck --model opus',
|
|
70
|
+
themeNow: (n) => `${n === 'light' ? 'Light' : 'Dark'} theme (saved)`,
|
|
71
|
+
themeUsage: 'Usage: hopdeck theme light · hopdeck theme dark · hopdeck theme auto (follow the terminal) · hopdeck theme (show the current one)',
|
|
72
|
+
themeShow: (saved, eff, from, env) => `Saved theme: ${saved}.\nIn use: ${eff}` + (env ? ' (the HOPDECK_THEME variable takes priority over the saved one).' : from === 'auto' ? ' (auto: dark unless the terminal says it has a light background).' : '.'),
|
|
65
73
|
shortcutUsage: 'Usage: hopdeck shortcut on (install the claude shortcut) · hopdeck shortcut off (remove it)',
|
|
66
74
|
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',
|
|
67
75
|
unShortcutOff: 'Shortcut removed from your shell profile', unNoShortcut: 'There was no shortcut installed', unData: 'Preferences and cache deleted', unProgram: 'Program uninstalled (npm uninstall -g hopdeck)', unProgramFail: (p) => `The program is still at ${p}. If you did not install it with npm, remove it with your package manager (pnpm, yarn…); if it is a source copy, delete that folder. With npm: npm uninstall -g hopdeck`, unDone: 'Hopdeck has been uninstalled. If you also installed it elsewhere (for example in WSL and in Windows), repeat there: hopdeck uninstall', unSkipNpm: 'Not running npm (HOPDECK_NO_NPM). The command would be: npm uninstall -g hopdeck',
|
|
@@ -78,9 +86,11 @@ const T = {
|
|
|
78
86
|
help: ['Keys', '↑↓ j k move', '⏎ → l open / expand', '← h back / collapse', 'n new conversation',
|
|
79
87
|
'/ search (Tab: content)', 'p pin project ★', 'x H hide / show hidden', 'o open a folder',
|
|
80
88
|
'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',
|
|
81
|
-
'F1 F2 focus list / chat', 'F3 copy text (mouse)', 'F4 hide the list', 'b F8 git panel', '⠋ ✔ ● working · done · open', 'q quit'],
|
|
89
|
+
'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'],
|
|
82
90
|
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',
|
|
83
91
|
idle3: 'F1 projects · F2 chat', bar1: 'projects', bar2: 'chat', bar3: 'minimize',
|
|
92
|
+
searchPh: 'search conversation or project…', found: (n) => `${n} ${n === 1 ? 'result' : 'results'}`, noRes: (q) => `No results for “${q}”`,
|
|
93
|
+
searchingContent: 'Searching inside the conversations…', tryContent: 'Press Tab to also search inside the content', inContent: 'in content', kClear: 'clear', kEdit: 'edit', kEsc: 'exit',
|
|
84
94
|
inside: 'You are already inside Hopdeck (F1 jumps to the project list).',
|
|
85
95
|
},
|
|
86
96
|
}[LANG];
|
package/lib/images.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// Imágenes del historial: extracción de bloques base64, decodificación PNG/JPEG y dibujo con medios bloques (▀).
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const cp = require('child_process');
|
|
4
7
|
const readline = require('readline');
|
|
5
8
|
const { TRUE, R } = require('./style');
|
|
6
9
|
|
|
@@ -111,18 +114,46 @@ function decodePNG(buf) {
|
|
|
111
114
|
return { w, h, rgba };
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
/**
|
|
117
|
+
/** Extensión según los primeros bytes (sips la usa para saber qué formato lee). */
|
|
118
|
+
function sniffExt(b) {
|
|
119
|
+
if (b.length > 12) {
|
|
120
|
+
if (b.readUInt32BE(0) === 0x89504e47) return 'png';
|
|
121
|
+
if (b[0] === 0xff && b[1] === 0xd8) return 'jpg';
|
|
122
|
+
if (b.toString('latin1', 0, 4) === 'GIF8') return 'gif';
|
|
123
|
+
if (b.toString('latin1', 0, 4) === 'RIFF' && b.toString('latin1', 8, 12) === 'WEBP') return 'webp';
|
|
124
|
+
if (b.toString('latin1', 4, 8) === 'ftyp') return 'heic';
|
|
125
|
+
if (b.readUInt32BE(0) === 0x49492a00 || b.readUInt32BE(0) === 0x4d4d002a) return 'tiff';
|
|
126
|
+
}
|
|
127
|
+
return 'img';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* macOS: `sips` (viene con el sistema) convierte a PNG, y reduce, lo que el decodificador propio no entiende: WebP, GIF, HEIC, TIFF,
|
|
132
|
+
* PNG entrelazado o imágenes enormes. `run` se puede sustituir (pruebas). Devuelve { w, h, rgba } o null.
|
|
133
|
+
*/
|
|
134
|
+
function decodeViaSips(buf, run = cp.spawnSync) {
|
|
135
|
+
let dir;
|
|
136
|
+
try {
|
|
137
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'hopdeck-sips-'));
|
|
138
|
+
const src = path.join(dir, 'in.' + sniffExt(buf)), dst = path.join(dir, 'out.png');
|
|
139
|
+
fs.writeFileSync(src, buf);
|
|
140
|
+
const r = run('sips', ['-s', 'format', 'png', '-Z', '1600', src, '--out', dst], { stdio: 'ignore', timeout: 8000 });
|
|
141
|
+
return r && r.status === 0 ? decodePNG(fs.readFileSync(dst)) : null;
|
|
142
|
+
} catch { return null; } finally { if (dir) { try { fs.rmSync(dir, { recursive: true, force: true }); } catch { /* */ } } }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** PNG (propio) o JPEG (si está jpeg-js); en macOS, lo demás con sips. Devuelve { w, h, rgba } o null. */
|
|
115
146
|
function decodeImage(img) {
|
|
116
147
|
const buf = Buffer.from(img.data, 'base64');
|
|
148
|
+
let d = null;
|
|
117
149
|
try {
|
|
118
|
-
if (buf.length > 8 && buf.readUInt32BE(0) === 0x89504e47)
|
|
119
|
-
if (buf[0] === 0xff && buf[1] === 0xd8) {
|
|
120
|
-
let jpeg; try { jpeg = require('jpeg-js'); } catch {
|
|
121
|
-
const
|
|
122
|
-
return { w: d.width, h: d.height, rgba: d.data };
|
|
150
|
+
if (buf.length > 8 && buf.readUInt32BE(0) === 0x89504e47) d = decodePNG(buf);
|
|
151
|
+
else if (buf[0] === 0xff && buf[1] === 0xd8) {
|
|
152
|
+
let jpeg; try { jpeg = require('jpeg-js'); } catch { jpeg = null; }
|
|
153
|
+
if (jpeg) { const j = jpeg.decode(buf, { useTArray: true, formatAsRGBA: true, maxMemoryUsageInMB: 512 }); d = { w: j.width, h: j.height, rgba: j.data }; }
|
|
123
154
|
}
|
|
124
|
-
} catch { /* formato corrupto */ }
|
|
125
|
-
return null;
|
|
155
|
+
} catch { /* formato corrupto o demasiado grande */ }
|
|
156
|
+
return d || (process.platform === 'darwin' ? decodeViaSips(buf) : null);
|
|
126
157
|
}
|
|
127
158
|
|
|
128
159
|
/** Reduce con filtro de caja y compone sobre un fondo oscuro. Devuelve RGB (3 bytes por píxel). */
|
|
@@ -165,4 +196,4 @@ function halfBlocks(rgb, tw, th2) {
|
|
|
165
196
|
return rows;
|
|
166
197
|
}
|
|
167
198
|
|
|
168
|
-
module.exports = { collectImages, extractImages, findImageByNumber, decodePNG, decodeImage, scaleBox, fitSize, halfBlocks };
|
|
199
|
+
module.exports = { collectImages, extractImages, findImageByNumber, decodePNG, decodeImage, decodeViaSips, sniffExt, scaleBox, fitSize, halfBlocks };
|
package/lib/keys.js
CHANGED
|
@@ -18,7 +18,7 @@ function parseKeys(s) {
|
|
|
18
18
|
const KEYMAP = {
|
|
19
19
|
'\x1b[A': 'up', '\x1bOA': 'up', '\x1b[B': 'down', '\x1bOB': 'down', '\x1b[C': 'right', '\x1bOC': 'right',
|
|
20
20
|
'\x1b[D': 'left', '\x1bOD': 'left', '\x1b[5~': 'pgup', '\x1b[6~': 'pgdn', '\x1b[H': 'home', '\x1b[1~': 'home',
|
|
21
|
-
'\x1b[17~': 'f6', '\x1b[18~': 'f7', '\x10': 'ctrlp', '\x1b[15~': 'f5', '\x1b[I': 'focus', '\x1bOP': 'f1', '\x1b[11~': 'f1', '\x1bOQ': 'f2', '\x1b[12~': 'f2', '\x1b[F': 'end', '\x1b[4~': 'end', '\r': 'enter', '\n': 'enter', '\x1b': 'esc', '\x7f': 'bs', '\b': 'bs', '\x03': 'ctrlc',
|
|
21
|
+
'\x1b[17~': 'f6', '\x1b[18~': 'f7', '\x1b[20~': 'f9', '\x10': 'ctrlp', '\x1b[15~': 'f5', '\x1b[I': 'focus', '\x1bOP': 'f1', '\x1b[11~': 'f1', '\x1bOQ': 'f2', '\x1b[12~': 'f2', '\x1b[F': 'end', '\x1b[4~': 'end', '\r': 'enter', '\n': 'enter', '\x1b': 'esc', '\x7f': 'bs', '\b': 'bs', '\x03': 'ctrlc',
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
|
package/lib/style.js
CHANGED
|
@@ -2,20 +2,32 @@
|
|
|
2
2
|
// Colores ANSI, tema claro/oscuro y utilidades de ancho visual (emoji / CJK = 2 columnas).
|
|
3
3
|
const TRUE = /truecolor|24bit/i.test(process.env.COLORTERM || '') || !!process.env.WT_SESSION;
|
|
4
4
|
const NOCOL = !!process.env.NO_COLOR; // https://no-color.org
|
|
5
|
-
// tema: HOPDECK_THEME=light|dark
|
|
6
|
-
|
|
5
|
+
// tema, por orden de prioridad: HOPDECK_THEME=light|dark → la elección guardada con "hopdeck theme" → COLORFGBG (fondo claro
|
|
6
|
+
// termina en ;7 o ;15) → oscuro
|
|
7
|
+
const savedTheme = () => { try { const t = JSON.parse(require('fs').readFileSync(process.env.HOPDECK_CONFIG || require('path').join(require('os').homedir(), '.hopdeck.json'), 'utf8')).theme; return t === 'light' || t === 'dark' ? t : ''; } catch { return ''; } };
|
|
8
|
+
const THEME_FROM = process.env.HOPDECK_THEME ? 'env' : savedTheme() ? 'config' : 'auto';
|
|
9
|
+
const LIGHT = THEME_FROM === 'env' ? process.env.HOPDECK_THEME === 'light' : THEME_FROM === 'config' ? savedTheme() === 'light' : /;(7|15)$/.test(process.env.COLORFGBG || '');
|
|
7
10
|
const fg = (r, g, b, n) => (NOCOL ? '' : TRUE ? `\x1b[38;2;${r};${g};${b}m` : `\x1b[38;5;${n}m`);
|
|
8
11
|
const bg = (r, g, b, n) => (NOCOL ? '' : TRUE ? `\x1b[48;2;${r};${g};${b}m` : `\x1b[48;5;${n}m`);
|
|
9
12
|
const R = '\x1b[0m';
|
|
10
|
-
const
|
|
13
|
+
const PALETTES = {
|
|
14
|
+
light: {
|
|
11
15
|
brand: fg(190, 85, 50, 166), accent: fg(79, 70, 229, 62), text: fg(38, 38, 44, 235), dim: fg(105, 105, 114, 242),
|
|
12
16
|
faint: fg(190, 190, 196, 250), ok: fg(28, 128, 68, 29), warn: fg(168, 104, 16, 130),
|
|
13
17
|
selOn: bg(232, 234, 252, 189), selOff: bg(234, 234, 238, 255), bold: NOCOL ? '' : '\x1b[1m', ital: NOCOL ? '' : '\x1b[3m',
|
|
14
|
-
}
|
|
18
|
+
},
|
|
19
|
+
dark: {
|
|
15
20
|
brand: fg(217, 119, 87, 173), accent: fg(129, 140, 248, 105), text: fg(232, 230, 227, 253), dim: fg(128, 128, 134, 244),
|
|
16
21
|
faint: fg(78, 78, 84, 239), ok: fg(126, 196, 143, 114), warn: fg(224, 175, 104, 179),
|
|
17
22
|
selOn: bg(38, 40, 64, 236), selOff: bg(34, 34, 36, 235), bold: NOCOL ? '' : '\x1b[1m', ital: NOCOL ? '' : '\x1b[3m',
|
|
23
|
+
},
|
|
18
24
|
};
|
|
25
|
+
// La paleta se puede cambiar en caliente (tecla t / F9): `C` es un solo objeto que se actualiza en su sitio, y todo el programa lo lee
|
|
26
|
+
// al pintar, nunca lo copia.
|
|
27
|
+
let light = LIGHT;
|
|
28
|
+
const C = { ...PALETTES[light ? 'light' : 'dark'] };
|
|
29
|
+
const setTheme = (name) => { light = name === 'light'; Object.assign(C, PALETTES[light ? 'light' : 'dark']); };
|
|
30
|
+
const isLight = () => light;
|
|
19
31
|
|
|
20
32
|
// ancho visual (emoji / CJK = 2 columnas)
|
|
21
33
|
function cw(c) {
|
|
@@ -59,4 +71,4 @@ function fit(segs, width, base = '') {
|
|
|
59
71
|
return out;
|
|
60
72
|
}
|
|
61
73
|
|
|
62
|
-
module.exports = { TRUE, NOCOL, LIGHT, fg, bg, R, C, cw, strW, fit, clean };
|
|
74
|
+
module.exports = { TRUE, NOCOL, LIGHT, THEME_FROM, setTheme, isLight, fg, bg, R, C, cw, strW, fit, clean };
|
package/lib/text.js
CHANGED
|
@@ -8,10 +8,27 @@ const tidy = (s) => s.replace(/\s+/g, ' ').trim();
|
|
|
8
8
|
const home = os.homedir();
|
|
9
9
|
const shortPath = (p) => (p.startsWith(home) ? '~' + p.slice(home.length) : p);
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Minúsculas y sin acentos («Visión» → «vision», «ñ» → «n»). Cada letra se pliega por separado, así el resultado mide lo mismo
|
|
13
|
+
* que el original y una posición encontrada en uno vale para el otro (hace falta para resaltar las coincidencias).
|
|
14
|
+
*/
|
|
15
|
+
function fold(s) {
|
|
16
|
+
let o = '';
|
|
17
|
+
for (const ch of String(s)) {
|
|
18
|
+
const b = Array.from(ch.normalize('NFD'))[0] || ch, l = b.toLowerCase();
|
|
19
|
+
o += l.length === b.length ? l : b;
|
|
20
|
+
}
|
|
21
|
+
return o;
|
|
22
|
+
}
|
|
23
|
+
/** Palabras de una búsqueda, ya plegadas. */
|
|
24
|
+
const queryWords = (q) => fold(q).split(/\s+/).filter(Boolean);
|
|
25
|
+
/** ¿Aparecen todas las palabras (en cualquier orden) en el texto ya plegado? */
|
|
26
|
+
const matchWords = (ws, folded) => ws.every((w) => folded.includes(w));
|
|
27
|
+
|
|
11
28
|
/** Coincidencia difusa: cada palabra de la consulta debe aparecer como subsecuencia. -1 si no coincide. */
|
|
12
29
|
function fuzzy(q, text) {
|
|
13
|
-
const t = text
|
|
14
|
-
for (const term of q
|
|
30
|
+
const t = fold(text); let total = 0;
|
|
31
|
+
for (const term of queryWords(q)) {
|
|
15
32
|
let pos = -1, run = 0, score = 0;
|
|
16
33
|
const sub = t.indexOf(term);
|
|
17
34
|
if (sub >= 0) { total += 10 + term.length * 3 - Math.min(sub, 30) / 3; continue; }
|
|
@@ -40,4 +57,4 @@ function wrapText(text, width) {
|
|
|
40
57
|
return out;
|
|
41
58
|
}
|
|
42
59
|
|
|
43
|
-
module.exports = { baseName, tidy, home, shortPath, fuzzy, wrapText };
|
|
60
|
+
module.exports = { baseName, tidy, home, shortPath, fold, queryWords, matchWords, fuzzy, wrapText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hopdeck",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Selector visual de proyectos y conversaciones para Claude Code, en la terminal: salta entre proyectos sin hacer cd.",
|
|
5
5
|
"author": "fabriciodev26",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"scripts": {
|
|
45
45
|
"test": "node --test test/unit.test.js test/e2e.test.js test/ui.test.js",
|
|
46
46
|
"doctor": "node bin/hopdeck.js doctor",
|
|
47
|
-
"screenshots": "node scripts/screenshots.js"
|
|
47
|
+
"screenshots": "node scripts/screenshots.js",
|
|
48
|
+
"demo": "node scripts/demo.js"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
51
|
"@lydell/node-pty": "1.2.0-beta.18",
|