hopdeck 1.2.6 → 1.3.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 +11 -0
- package/README.en.md +37 -5
- package/README.md +37 -5
- package/bin/hopdeck.js +118 -10
- package/lib/git.js +94 -0
- package/lib/i18n.js +4 -4
- package/lib/sixel.js +14 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Cambios
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Nuevo
|
|
6
|
+
- **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
|
+
|
|
8
|
+
### Mejorado
|
|
9
|
+
- **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
|
+
- **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
|
+
- **Resumen de chats abiertos en la cabecera de la lista:** `⠋` trabajando, `✔` terminados sin ver, `●` abiertos. La ayuda (`?`) explica los símbolos.
|
|
12
|
+
- **Capturas del README en claro y oscuro:** se muestra la que corresponde al tema de quien lee.
|
|
13
|
+
|
|
3
14
|
## 1.2.6
|
|
4
15
|
|
|
5
16
|
### Mejorado
|
package/README.en.md
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
Type `claude` in your terminal and **pick which project and conversation to continue**, without leaving and without `cd`.
|
|
18
18
|
The project list stays on the left and the conversation on the right.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
<picture>
|
|
21
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/02-vista-dividida-light.svg">
|
|
22
|
+
<img alt="Split view: project list on the left, chat on the right" src="docs/screenshots/02-vista-dividida.svg">
|
|
23
|
+
</picture>
|
|
21
24
|
|
|
22
25
|
> **Independent community project.** Not affiliated with, endorsed or sponsored by Anthropic.
|
|
23
26
|
> "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.
|
|
@@ -61,7 +64,10 @@ You can say no and always use `hopdeck`. If you change your mind: `hopdeck short
|
|
|
61
64
|
|
|
62
65
|
## Getting started
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
<picture>
|
|
68
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/01-lista-y-vista-previa-light.svg">
|
|
69
|
+
<img alt="Project list and preview of the selected conversation" src="docs/screenshots/01-lista-y-vista-previa.svg">
|
|
70
|
+
</picture>
|
|
65
71
|
|
|
66
72
|
1. Pick a project with `↑` `↓` or by hovering it with the mouse.
|
|
67
73
|
2. `→` or `⏎` expands its conversations. While you move, the right pane shows **a preview**.
|
|
@@ -90,6 +96,7 @@ You can say no and always use `hopdeck`. If you change your mind: `hopdeck short
|
|
|
90
96
|
| `[` `]` | Narrow / widen the list |
|
|
91
97
|
| `F3` | Turn the mouse off/on (to select text with the terminal) |
|
|
92
98
|
| `F4` | Hide/show the list to give the chat the full width |
|
|
99
|
+
| `F8` · `b` | Show/hide the git panel (third panel). `b` works with the focus on the list; on macOS `F8` usually needs `Fn` |
|
|
93
100
|
| `r` · `?` · `q` | Reload · help · quit |
|
|
94
101
|
|
|
95
102
|
Every text box supports a cursor: `←` `→`, `Home`/`End`, `Delete`, and `Ctrl+U` to clear up to the start.
|
|
@@ -102,7 +109,10 @@ With no chat open, the right pane shows the last messages of the selected conver
|
|
|
102
109
|
|
|
103
110
|
### Pick a folder
|
|
104
111
|
|
|
105
|
-
|
|
112
|
+
<picture>
|
|
113
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/03-selector-de-carpetas-light.svg">
|
|
114
|
+
<img alt="Folder picker" src="docs/screenshots/03-selector-de-carpetas.svg">
|
|
115
|
+
</picture>
|
|
106
116
|
|
|
107
117
|
Press `o` to open a chat in **any folder**, with or without history, without typing paths:
|
|
108
118
|
|
|
@@ -122,18 +132,40 @@ It always starts at `~`. Recently used folders appear on top (`↻ recent`).
|
|
|
122
132
|
|
|
123
133
|
### Quick jump
|
|
124
134
|
|
|
125
|
-
|
|
135
|
+
<picture>
|
|
136
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/05-salto-rapido-light.svg">
|
|
137
|
+
<img alt="Quick jump with Ctrl+P" src="docs/screenshots/05-salto-rapido.svg">
|
|
138
|
+
</picture>
|
|
126
139
|
|
|
127
140
|
`Ctrl+P` searches **every** conversation of **every** project (title, project and first message). `⏎` opens it directly.
|
|
128
141
|
|
|
129
142
|
### Images in the chat
|
|
130
143
|
|
|
131
|
-
|
|
144
|
+
<picture>
|
|
145
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/04-hover-imagen-light.svg">
|
|
146
|
+
<img alt="Floating box with the image when hovering [Image #1]" src="docs/screenshots/04-hover-imagen.svg">
|
|
147
|
+
</picture>
|
|
132
148
|
|
|
133
149
|
- 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
150
|
- `i` / `F7` opens a **gallery** with all the conversation's images (`← →` navigate, `o` opens it in the system viewer, `Esc` closes).
|
|
135
151
|
- An image you just pasted and have not sent yet **cannot** be shown: it is not in the history yet.
|
|
136
152
|
|
|
153
|
+
### Git panel
|
|
154
|
+
|
|
155
|
+
`F8` (or `b` with the focus on the list) opens a read-only **third panel** to the right of the chat with the git state of the chat's folder (or the selected project):
|
|
156
|
+
|
|
157
|
+
- the **current branch**, with how far ahead or behind the remote it is;
|
|
158
|
+
- the **uncommitted changes** (modified, new or deleted files);
|
|
159
|
+
- the **recent branches**;
|
|
160
|
+
- the **branch activity**: branch switches, created branches and merges, taken from git's `reflog`. Anything from the last 10 minutes has an orange dot. It tells you when a branch was created or switched, whether by Claude or by anyone else (git does not record who did it).
|
|
161
|
+
|
|
162
|
+
<picture>
|
|
163
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/06-panel-git-light.svg">
|
|
164
|
+
<img alt="Git panel with the branch, the changes and the branch activity" src="docs/screenshots/06-panel-git.svg">
|
|
165
|
+
</picture>
|
|
166
|
+
|
|
167
|
+
It refreshes itself every few seconds and never modifies the repository. It needs `git` and a terminal of about 140 columns or more (if it does not fit, you get a notice). It is only in the built-in terminal, not in tmux mode.
|
|
168
|
+
|
|
137
169
|
### Chat status
|
|
138
170
|
|
|
139
171
|
- A new chat shows up in the list immediately (`● New conversation`), even if the folder has no history yet.
|
package/README.md
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
Escribe `claude` en tu terminal y **elige en qué proyecto y conversación seguir**, sin salir y sin hacer `cd`.
|
|
18
18
|
La lista de proyectos queda a la izquierda y la conversación a la derecha.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
<picture>
|
|
21
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/02-vista-dividida-light.svg">
|
|
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
|
+
</picture>
|
|
21
24
|
|
|
22
25
|
> **Proyecto independiente de la comunidad.** No está afiliado, respaldado ni patrocinado por Anthropic.
|
|
23
26
|
> "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.
|
|
@@ -61,7 +64,10 @@ Puedes decir que no y usar siempre `hopdeck`. Si cambias de idea: `hopdeck short
|
|
|
61
64
|
|
|
62
65
|
## Primeros pasos
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
<picture>
|
|
68
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/01-lista-y-vista-previa-light.svg">
|
|
69
|
+
<img alt="Lista de proyectos y vista previa de la conversación seleccionada" src="docs/screenshots/01-lista-y-vista-previa.svg">
|
|
70
|
+
</picture>
|
|
65
71
|
|
|
66
72
|
1. Elige un proyecto con `↑` `↓` o pasando el ratón por encima.
|
|
67
73
|
2. `→` o `⏎` despliega sus conversaciones. Mientras te mueves, el panel derecho muestra **una vista previa**.
|
|
@@ -90,6 +96,7 @@ Puedes decir que no y usar siempre `hopdeck`. Si cambias de idea: `hopdeck short
|
|
|
90
96
|
| `[` `]` | Estrechar / ensanchar la lista |
|
|
91
97
|
| `F3` | Apagar/encender el ratón (para seleccionar texto con el terminal) |
|
|
92
98
|
| `F4` | Ocultar/mostrar la lista para dar todo el ancho al chat |
|
|
99
|
+
| `F8` · `b` | Mostrar/ocultar el panel de git (tercer panel). `b` funciona con el foco en la lista; en macOS `F8` suele necesitar `Fn` |
|
|
93
100
|
| `r` · `?` · `q` | Recargar · ayuda · salir |
|
|
94
101
|
|
|
95
102
|
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`.
|
|
@@ -102,7 +109,10 @@ Sin ningún chat abierto, el panel derecho muestra los últimos mensajes de la c
|
|
|
102
109
|
|
|
103
110
|
### Elegir una carpeta
|
|
104
111
|
|
|
105
|
-
|
|
112
|
+
<picture>
|
|
113
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/03-selector-de-carpetas-light.svg">
|
|
114
|
+
<img alt="Selector de carpetas" src="docs/screenshots/03-selector-de-carpetas.svg">
|
|
115
|
+
</picture>
|
|
106
116
|
|
|
107
117
|
Pulsa `o` para abrir un chat en **cualquier carpeta**, tenga o no historial, sin escribir rutas:
|
|
108
118
|
|
|
@@ -122,18 +132,40 @@ Empieza siempre en `~`. Las carpetas que usaste hace poco aparecen arriba (`↻
|
|
|
122
132
|
|
|
123
133
|
### Salto rápido
|
|
124
134
|
|
|
125
|
-
|
|
135
|
+
<picture>
|
|
136
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/05-salto-rapido-light.svg">
|
|
137
|
+
<img alt="Salto rápido con Ctrl+P" src="docs/screenshots/05-salto-rapido.svg">
|
|
138
|
+
</picture>
|
|
126
139
|
|
|
127
140
|
`Ctrl+P` busca entre **todas** las conversaciones de **todos** los proyectos (título, proyecto y primer mensaje). `⏎` la abre directamente.
|
|
128
141
|
|
|
129
142
|
### Imágenes del chat
|
|
130
143
|
|
|
131
|
-
|
|
144
|
+
<picture>
|
|
145
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/04-hover-imagen-light.svg">
|
|
146
|
+
<img alt="Cuadro flotante con la imagen al pasar el cursor por [Image #1]" src="docs/screenshots/04-hover-imagen.svg">
|
|
147
|
+
</picture>
|
|
132
148
|
|
|
133
149
|
- 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
150
|
- `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
151
|
- Una imagen recién pegada y aún sin enviar **no** se puede mostrar: todavía no está en el historial.
|
|
136
152
|
|
|
153
|
+
### Panel de git
|
|
154
|
+
|
|
155
|
+
`F8` (o `b` con el foco en la lista) abre un **tercer panel** a la derecha del chat, de solo lectura, con el estado git de la carpeta del chat (o del proyecto seleccionado):
|
|
156
|
+
|
|
157
|
+
- la **rama actual**, con lo que lleva por delante o por detrás del remoto;
|
|
158
|
+
- los **cambios sin guardar** (archivos modificados, nuevos o borrados);
|
|
159
|
+
- las **ramas recientes**;
|
|
160
|
+
- la **actividad de ramas**: cambios de rama, ramas creadas y merges, tomados del registro (`reflog`) de git. Los de los últimos 10 minutos llevan un punto naranja. Sirve para enterarte de cuándo se creó o cambió de rama, desde Claude o desde donde sea (git no dice quién lo hizo).
|
|
161
|
+
|
|
162
|
+
<picture>
|
|
163
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/screenshots/06-panel-git-light.svg">
|
|
164
|
+
<img alt="Panel de git con la rama, los cambios y la actividad de ramas" src="docs/screenshots/06-panel-git.svg">
|
|
165
|
+
</picture>
|
|
166
|
+
|
|
167
|
+
Se refresca solo cada pocos segundos y no modifica nada en el repositorio. Necesita `git` y una terminal de unas 140 columnas o más (si no cabe, te lo avisa). Solo está en el terminal integrado, no en el modo tmux.
|
|
168
|
+
|
|
137
169
|
### Estado de los chats
|
|
138
170
|
|
|
139
171
|
- Un chat nuevo aparece al instante en la lista (`● Nueva conversación`), aunque la carpeta aún no tenga historial.
|
package/bin/hopdeck.js
CHANGED
|
@@ -18,6 +18,7 @@ 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
|
+
const gitlib = require('../lib/git');
|
|
21
22
|
const { collectImages, decodePNG, decodeImage, scaleBox, fitSize, halfBlocks } = images;
|
|
22
23
|
const { parseKeys, KEYMAP, printable, editBuf, normalizeKeys } = require('../lib/keys');
|
|
23
24
|
const { stripJsonc, wtCtrlV, wtSettingsFile } = require('../lib/windows-terminal');
|
|
@@ -127,7 +128,7 @@ function ago(ms) {
|
|
|
127
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: '' };
|
|
128
129
|
const SIDEBAR = process.argv.includes('--sidebar');
|
|
129
130
|
let EMBED = false; // vista dividida con terminal embebido (Windows / sin tmux)
|
|
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 };
|
|
131
|
+
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 };
|
|
131
132
|
const SPIN = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
132
133
|
let spinT = null, frameN = 0, reloading = false;
|
|
133
134
|
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)));
|
|
@@ -345,6 +346,34 @@ function chatMark(id) {
|
|
|
345
346
|
return ['● ', C.ok];
|
|
346
347
|
}
|
|
347
348
|
|
|
349
|
+
/** Trocea `text` en segmentos [[texto, estilo]] resaltando las coincidencias (sin distinguir mayúsculas) con la búsqueda `q` (en minúsculas). */
|
|
350
|
+
function hl(text, q, style) {
|
|
351
|
+
const t = String(text);
|
|
352
|
+
if (!q) return [[t, style]];
|
|
353
|
+
const low = t.toLowerCase();
|
|
354
|
+
if (low.length !== t.length) return [[t, style]]; // algunas letras cambian de largo al pasar a minúsculas: no se resalta
|
|
355
|
+
const out = []; let i = 0;
|
|
356
|
+
for (let at = low.indexOf(q); at >= 0; at = low.indexOf(q, i)) {
|
|
357
|
+
if (at > i) out.push([t.slice(i, at), style]);
|
|
358
|
+
out.push([t.slice(at, at + q.length), C.brand + C.bold]);
|
|
359
|
+
i = at + q.length;
|
|
360
|
+
}
|
|
361
|
+
if (i < t.length) out.push([t.slice(i), style]);
|
|
362
|
+
return out.length ? out : [[t, style]];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** Resumen de los chats abiertos para la cabecera de la lista: trabajando ⠋, terminados sin ver ✔, abiertos ●. */
|
|
366
|
+
function liveSummary() {
|
|
367
|
+
if (!EMBED) return [];
|
|
368
|
+
let w = 0, u = 0, o = 0;
|
|
369
|
+
for (const x of E.sessions.values()) { if (x.working) w++; else if (x.unseen) u++; else o++; }
|
|
370
|
+
const segs = [];
|
|
371
|
+
if (w) segs.push([' ' + spin() + ' ' + w, C.accent]);
|
|
372
|
+
if (u) segs.push([' ✔ ' + u, C.warn]);
|
|
373
|
+
if (o) segs.push([' ● ' + o, C.ok]);
|
|
374
|
+
return segs;
|
|
375
|
+
}
|
|
376
|
+
|
|
348
377
|
const tailFit = (t, n) => (strW(t) > n && n > 3 ? '…' + t.slice(t.length - (n - 1)) : t);
|
|
349
378
|
|
|
350
379
|
function frameTree(W, H) {
|
|
@@ -354,8 +383,9 @@ function frameTree(W, H) {
|
|
|
354
383
|
const bodyH = H - 5;
|
|
355
384
|
S.coff = scroll(S.coff, S.c, bodyH);
|
|
356
385
|
const lines = [];
|
|
357
|
-
lines.push(fit([[' » ', C.brand], ['Hop', C.brand + C.bold], ['deck', C.text + C.bold], [' ' + S.projects.length, C.dim], [S.loading ? ' ' + spin() : '', C.accent]], W));
|
|
386
|
+
lines.push(fit([[' » ', C.brand], ['Hop', C.brand + C.bold], ['deck', C.text + C.bold], [' ' + S.projects.length, C.dim], [S.loading ? ' ' + spin() : '', C.accent], ...liveSummary()], W));
|
|
358
387
|
lines.push(C.faint + '─'.repeat(W) + R);
|
|
388
|
+
const sq0 = S.query.trim().toLowerCase(); // búsqueda activa: se resaltan las coincidencias
|
|
359
389
|
const qsList = S.qs ? qsItems() : null;
|
|
360
390
|
const fbList = S.fb && !S.qs ? fbRows() : null;
|
|
361
391
|
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); }
|
|
@@ -399,7 +429,7 @@ function frameTree(W, H) {
|
|
|
399
429
|
// 4) los proyectos plegados se atenúan: el desplegado, el de esta carpeta y el seleccionado destacan
|
|
400
430
|
const nameC = sel ? C.text + C.bold : e.p.hidden ? C.dim : e.p.isCwd ? C.ok : e.open ? C.text : C.dim;
|
|
401
431
|
lines.push(fit([mark, [e.open ? ' ▾ ' : ' ▸ ', e.open ? C.accent : C.dim],
|
|
402
|
-
[(e.p.pinned ? '★ ' : '') + (e.p.isCwd ? '● ' : '')
|
|
432
|
+
[(e.p.pinned ? '★ ' : '') + (e.p.isCwd ? '● ' : ''), nameC], ...hl(e.p.name, sq0, nameC)], W - 13, base) +
|
|
403
433
|
fit(right, 13, base));
|
|
404
434
|
} else if (e.t === 'm') {
|
|
405
435
|
lines.push(fit([mark, [' ', ''], [T.more(e.n), sel ? C.text : C.dim]], W, base));
|
|
@@ -412,7 +442,8 @@ function frameTree(W, H) {
|
|
|
412
442
|
} else {
|
|
413
443
|
const [mk, mc] = chatMark(e.s.id);
|
|
414
444
|
const arch = CFG.archived.includes(e.s.id), tag = e.s.dup ? '#' + e.s.id.slice(0, 4) : '';
|
|
415
|
-
|
|
445
|
+
const ts = sel ? C.text + C.bold : arch ? C.dim : C.text, inTxt = sq0 && !e.s.title.toLowerCase().includes(sq0);
|
|
446
|
+
lines.push(fit([mark, [' ', ''], [mk, mc], ...hl(e.s.title, sq0, ts), ...(inTxt ? [[' ⌕', C.dim]] : [])], W - 13, base) +
|
|
416
447
|
fit([[tag.padEnd(6), C.accent], [ago(e.s.mtime).padStart(6), C.dim], [' ', '']], 13, base));
|
|
417
448
|
}
|
|
418
449
|
}
|
|
@@ -752,6 +783,7 @@ function onKeyTree(raw) {
|
|
|
752
783
|
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;
|
|
753
784
|
return key ? closeChat(key) : flash(T.notOpen);
|
|
754
785
|
}
|
|
786
|
+
case 'b': return toggleGit(); // panel de git (F8 en macOS pide Fn: por defecto son las teclas multimedia)
|
|
755
787
|
case 'i': case 'f7':
|
|
756
788
|
if (e && e.t === 's') {
|
|
757
789
|
if (EMBED) return openGallery(e.p.name, e.s);
|
|
@@ -837,7 +869,79 @@ function loadDeps() {
|
|
|
837
869
|
function embedLayout() {
|
|
838
870
|
const W = process.stdout.columns || 100, H = process.stdout.rows || 30;
|
|
839
871
|
const SW = E.hideSide ? 0 : CFG.sidebar ? clamp(CFG.sidebar, 24, 80) : clamp(Math.floor(W * 0.3), 36, 46);
|
|
840
|
-
|
|
872
|
+
const room = Math.max(10, W - SW - (SW ? 1 : 0));
|
|
873
|
+
const GW = E.git && room - GIT_W - 1 >= GIT_MIN_CHAT ? GIT_W : 0; // tercer panel (git): solo si el chat conserva un ancho cómodo
|
|
874
|
+
return { W, H, SW, GW, rw: GW ? room - GW - 1 : room, rh: Math.max(3, H - 1), th: Math.max(3, H - 3) };
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// ───────────────────────── panel de git (tercer panel, F8) ─────────────────────────
|
|
878
|
+
const GIT_W = 38, GIT_MIN_CHAT = 60;
|
|
879
|
+
const GITC = new Map(); // carpeta → { t, loading, data }
|
|
880
|
+
/** Estado de git de la carpeta, de la caché; si tiene más de 4 s se vuelve a leer en segundo plano. */
|
|
881
|
+
function gitInfo(cwd) {
|
|
882
|
+
const hit = GITC.get(cwd), now = Date.now();
|
|
883
|
+
if (hit && (hit.loading || now - hit.t < 4000)) return hit.data;
|
|
884
|
+
GITC.set(cwd, { t: hit ? hit.t : 0, loading: true, data: hit ? hit.data : null });
|
|
885
|
+
gitlib.readGit(cwd).then((data) => { GITC.set(cwd, { t: Date.now(), loading: false, data }); if (active && E.git) scheduleRender(); });
|
|
886
|
+
return hit ? hit.data : null;
|
|
887
|
+
}
|
|
888
|
+
const gitCwd = () => {
|
|
889
|
+
const sh = E.sessions.get(E.shown);
|
|
890
|
+
if (sh && sh.cwd) return sh.cwd;
|
|
891
|
+
const e = !S.help && !S.qs ? flatList()[S.c] : null;
|
|
892
|
+
return e && e.p ? e.p.cwd : null;
|
|
893
|
+
};
|
|
894
|
+
function toggleGit() {
|
|
895
|
+
if (!EMBED) return flash(T.gitOnlyEmbed);
|
|
896
|
+
if (!E.git) {
|
|
897
|
+
const SW = E.hideSide ? 0 : CFG.sidebar ? clamp(CFG.sidebar, 24, 80) : clamp(Math.floor((process.stdout.columns || 100) * 0.3), 36, 46);
|
|
898
|
+
const need = SW + (SW ? 1 : 0) + GIT_MIN_CHAT + GIT_W + 1;
|
|
899
|
+
if ((process.stdout.columns || 100) < need) return flash(T.gitNarrow(need));
|
|
900
|
+
}
|
|
901
|
+
E.git = !E.git; CFG.git = E.git; saveCfg();
|
|
902
|
+
embedResize();
|
|
903
|
+
}
|
|
904
|
+
/** Las `rh` filas del panel de git: título, línea y contenido (rama, cambios, ramas recientes, actividad de ramas). */
|
|
905
|
+
function gitRows(GW, rh) {
|
|
906
|
+
const cwd = gitCwd(), d = cwd ? gitInfo(cwd) : null;
|
|
907
|
+
const out = [fit([[' ⎇ Git', C.accent + C.bold], [cwd ? ' ' + baseName(cwd) : '', C.dim]], GW), C.faint + '─'.repeat(GW) + R];
|
|
908
|
+
const body = [], line = (...segs) => body.push(segs);
|
|
909
|
+
const row = (left, right, rc) => body.push({ left, right, rc });
|
|
910
|
+
if (!cwd) line([' ' + T.gitNone, C.dim]);
|
|
911
|
+
else if (!d) line([' ' + spin() + ' …', C.accent]);
|
|
912
|
+
else if (!d.ok) { line([' ' + (d.missing ? T.gitMissing : d.repo ? T.gitErr : T.gitNoRepo), C.dim]); if (d.err && d.repo && !d.missing) line([' ' + d.err, C.faint]); }
|
|
913
|
+
else {
|
|
914
|
+
const s = d.status, n = s.files.length, now = Date.now();
|
|
915
|
+
line([' ', ''], [(s.detached ? '⌀ ' : '⎇ ') + s.branch, C.brand + C.bold], [s.ahead ? ' ↑' + s.ahead : '', C.ok], [s.behind ? ' ↓' + s.behind : '', C.warn]);
|
|
916
|
+
line(n ? [' ● ', C.warn] : [' ✔ ', C.ok], [n ? T.gitDirty(n) : T.gitClean, n ? C.warn : C.dim]);
|
|
917
|
+
const room = Math.max(0, Math.min(6, rh - 2 - 14));
|
|
918
|
+
for (const f of s.files.slice(0, room)) {
|
|
919
|
+
const code = f.x === '?' ? '?' : f.x !== ' ' ? f.x : f.y;
|
|
920
|
+
line([' ', ''], [code + ' ', code === 'D' ? C.brand : code === 'M' ? C.warn : C.ok], [f.path, C.text]);
|
|
921
|
+
}
|
|
922
|
+
if (n > room && room > 0) line([' ', ''], [T.gitMore(n - room), C.dim]);
|
|
923
|
+
body.push(null);
|
|
924
|
+
line([' ' + T.gitBranches, C.dim + C.bold]);
|
|
925
|
+
for (const b of d.branches.slice(0, 5)) row([[b.cur ? ' ● ' : ' ', b.cur ? C.ok : ''], [b.name, b.cur ? C.text + C.bold : C.text]], b.t ? ago(b.t * 1000) : '');
|
|
926
|
+
body.push(null);
|
|
927
|
+
line([' ' + T.gitActivity, C.dim + C.bold]);
|
|
928
|
+
if (!d.activity.length) line([' ' + T.gitNoActivity, C.dim]);
|
|
929
|
+
for (const a of d.activity) {
|
|
930
|
+
const fresh = now - a.t * 1000 < 10 * 60 * 1000, mark = [fresh ? ' ● ' : ' ', fresh ? C.brand : ''];
|
|
931
|
+
const txt = a.k === 'switch' ? [[a.from, C.dim], [' → ', C.accent], [a.to, C.text]]
|
|
932
|
+
: a.k === 'create' ? [['+ ', C.ok], [a.name, C.text], ...(a.from !== 'HEAD' && strW(a.name) + strW(a.from) + strW(T.gitFrom) + 19 <= GW ? [[' ' + T.gitFrom + ' ' + a.from, C.dim]] : [])]
|
|
933
|
+
: a.k === 'merge' ? [['⇄ merge ', C.accent], [a.what, C.text]] : [['↻ rebase', C.accent]];
|
|
934
|
+
row([mark, ...txt], ago(a.t * 1000));
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
for (const b of body) {
|
|
938
|
+
if (out.length >= rh) break;
|
|
939
|
+
if (b === null) out.push(' '.repeat(GW));
|
|
940
|
+
else if (Array.isArray(b)) out.push(fit(b, GW));
|
|
941
|
+
else { const rw = strW(b.right) + 1; out.push(fit(b.left, GW - rw) + fit([[b.right, b.rc || C.dim], [' ', '']], rw)); }
|
|
942
|
+
}
|
|
943
|
+
while (out.length < rh) out.push(' '.repeat(GW));
|
|
944
|
+
return out;
|
|
841
945
|
}
|
|
842
946
|
|
|
843
947
|
function sgr(c, fgMode) {
|
|
@@ -1206,7 +1310,7 @@ function headerRow(sh, width) {
|
|
|
1206
1310
|
}
|
|
1207
1311
|
|
|
1208
1312
|
function renderEmbed() {
|
|
1209
|
-
const { W, H, SW, rw, rh, th } = embedLayout();
|
|
1313
|
+
const { W, H, SW, GW, rw, rh, th } = embedLayout();
|
|
1210
1314
|
if (W < 70 || H < 12) { process.stdout.write('\x1b[2J\x1b[H' + T.small); invalidate(); return; }
|
|
1211
1315
|
const left = SW ? frameTree(SW, rh) : null;
|
|
1212
1316
|
const sh = E.sessions.get(E.shown);
|
|
@@ -1223,6 +1327,7 @@ function renderEmbed() {
|
|
|
1223
1327
|
? 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)
|
|
1224
1328
|
: null);
|
|
1225
1329
|
const div = (E.focus === 'right' ? C.accent : C.faint) + '│' + R;
|
|
1330
|
+
const gitR = GW ? gitRows(GW, rh) : null;
|
|
1226
1331
|
for (let y = 0; y < rh; y++) {
|
|
1227
1332
|
const ty = y - 2; // las 2 primeras filas del panel derecho son el título y su línea
|
|
1228
1333
|
const gd = E.gallery && E.gallery.dec.get(E.gallery.i);
|
|
@@ -1231,14 +1336,14 @@ function renderEmbed() {
|
|
|
1231
1336
|
: y === 1 ? C.faint + '─'.repeat(rw) + R : gRows[ty])
|
|
1232
1337
|
: y === 0 ? headerRow(hdr, rw) : y === 1 ? C.faint + '─'.repeat(rw) + R
|
|
1233
1338
|
: 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);
|
|
1234
|
-
rowsOut.push((left ? (left[y] || ' '.repeat(SW)) + div : '') + right);
|
|
1339
|
+
rowsOut.push((left ? (left[y] || ' '.repeat(SW)) + div : '') + right + (gitR ? C.faint + '│' + R + gitR[y] : ''));
|
|
1235
1340
|
}
|
|
1236
1341
|
const live = E.sessions.size;
|
|
1237
1342
|
const k = (key, d) => [[key, C.accent], [' ' + d + ' ', C.dim]];
|
|
1238
1343
|
const sb = sh && sh.ready ? sh.term.buffer.active : null;
|
|
1239
1344
|
const back = sb ? sb.baseY - sb.viewportY : 0;
|
|
1240
1345
|
rowsOut.push(fit([[' ', ''], [E.note ? E.note.t + ' ' : '', C.ok], [back > 0 ? T.up(back, sb && sb.baseY ? Math.round((100 * sb.viewportY) / sb.baseY) : -1) + ' ' : '', C.warn],
|
|
1241
|
-
...k('F1', T.bar1), ...k('F2', T.bar2), ...k('F3', E.mouse ? T.bar4 : T.bar5), ...k('F4', E.hideSide ? T.bar7 : T.bar6),
|
|
1346
|
+
...k('F1', T.bar1), ...k('F2', T.bar2), ...k('F3', E.mouse ? T.bar4 : T.bar5), ...k('F4', E.hideSide ? T.bar7 : T.bar6), ...k('F8', T.bar8),
|
|
1242
1347
|
[live ? '● ' + live : '', C.ok]], W));
|
|
1243
1348
|
const changes = diffRows(rowsOut);
|
|
1244
1349
|
// 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)
|
|
@@ -1388,8 +1493,9 @@ function sidebarMouse(b, x, y, type, rows = process.stdout.rows || 30) {
|
|
|
1388
1493
|
|
|
1389
1494
|
function onMouse(b, x, y, type) {
|
|
1390
1495
|
if (E.gallery) return;
|
|
1391
|
-
const { SW, rh } = embedLayout();
|
|
1496
|
+
const { SW, GW, rw, rh } = embedLayout();
|
|
1392
1497
|
const sh = E.sessions.get(E.shown);
|
|
1498
|
+
if (GW && x > (SW ? SW + 1 : 0) + rw) { if (E.hover) { E.hover = null; scheduleRender(); } return; } // el panel de git es de solo lectura
|
|
1393
1499
|
if (b & 64) { // rueda
|
|
1394
1500
|
E.hover = null;
|
|
1395
1501
|
const up = (b & 1) === 0;
|
|
@@ -1725,6 +1831,7 @@ async function run() {
|
|
|
1725
1831
|
}
|
|
1726
1832
|
process.stdout.on('resize', EMBED ? embedResize : () => { invalidate(); render(); });
|
|
1727
1833
|
if (EMBED) setInterval(pollChats, 400);
|
|
1834
|
+
if (EMBED) setInterval(() => { if (active && E.git && embedLayout().GW) scheduleRender(); }, 4000); // el panel de git se refresca solo
|
|
1728
1835
|
setInterval(() => { // lista siempre al día
|
|
1729
1836
|
if (S.loading || reloading || S.searching || S.query || S.prompt !== null || S.help) return;
|
|
1730
1837
|
if (SIDEBAR || EMBED) { const e = flatList()[S.c]; reloadAsync(() => { if (!e) return; const i = flatList().findIndex((x) => x.t === e.t && x.p.key === e.p.key && (e.t !== 's' || x.s.id === e.s.id)); if (i >= 0) S.c = i; }, true); }
|
|
@@ -1741,6 +1848,7 @@ async function run() {
|
|
|
1741
1848
|
if (E.gallery) { for (const k of parseKeys(s)) galleryKey(k); return; }
|
|
1742
1849
|
if (s === '\x1b[17~' && E.focus === 'right') return closeChat(E.shown);
|
|
1743
1850
|
if (s === '\x1b[18~') return openGalleryShown();
|
|
1851
|
+
if (s === '\x1b[19~') return toggleGit();
|
|
1744
1852
|
if (s === '\x1b[15~') { E.focus = 'left'; if (E.hideSide) E.hideSide = false; S.qs = { q: '', pc: 0, i: 0, off: 0 }; return embedResize(); }
|
|
1745
1853
|
if (s === '\x1bOS' || s === '\x1b[14~') {
|
|
1746
1854
|
E.hideSide = !E.hideSide && E.sessions.has(E.shown);
|
|
@@ -2071,7 +2179,7 @@ if (require.main === module) main();
|
|
|
2071
2179
|
else {
|
|
2072
2180
|
// al hacer require() (pruebas automáticas) no se ejecuta nada: solo se exponen las piezas puras
|
|
2073
2181
|
module.exports = {
|
|
2074
|
-
cw, strW, fit, clean, imageExt, exportImages, safeId, findClaude, install, backupProfile, ago, tidy, fuzzy, wrapText, parseKeys, KEYMAP, isType, T, S, CFG, E,
|
|
2182
|
+
cw, strW, fit, clean, hl, gitRows, gitInfo, toggleGit, imageExt, exportImages, safeId, findClaude, install, backupProfile, ago, tidy, fuzzy, wrapText, parseKeys, KEYMAP, isType, T, S, CFG, E,
|
|
2075
2183
|
readSession, buildProject, scan, scanAsync, finishScan, sortProjects, projectDirs,
|
|
2076
2184
|
view, flatList, stripBlock, offerShortcut, uninstallAll, commandName, suggestCommand, parseTermReplies, sixelOn, SNIP, MARK_A, MARK_B, toggleProject, cacheLoad, selNorm,
|
|
2077
2185
|
decodePNG, decodeImage, scaleBox, fitSize, halfBlocks, collectImages, extractImages,
|
package/lib/git.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Lectura de solo lectura del estado de git de una carpeta, para el panel de git: rama actual, cambios sin guardar,
|
|
3
|
+
// ramas recientes y la actividad de ramas (cambios de rama, ramas creadas, merges) que git guarda en su reflog.
|
|
4
|
+
// Nunca modifica el repositorio. Solo se ejecutan comandos fijos (`status`, `reflog show`, `for-each-ref`) sin shell.
|
|
5
|
+
const cp = require('child_process');
|
|
6
|
+
|
|
7
|
+
// GIT_OPTIONAL_LOCKS=0: `status` no escribe en .git. core.fsmonitor=false: un repositorio ajeno no puede lanzar un programa
|
|
8
|
+
// propio a través de su configuración mientras lo miramos. LC_ALL=C: salida estable, sin traducir.
|
|
9
|
+
const ENV = { ...process.env, GIT_OPTIONAL_LOCKS: '0', GIT_TERMINAL_PROMPT: '0', GIT_PAGER: 'cat', LC_ALL: 'C' };
|
|
10
|
+
const BASE = ['-c', 'core.fsmonitor=false', '--no-pager'];
|
|
11
|
+
|
|
12
|
+
function run(cwd, args) {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
try {
|
|
15
|
+
cp.execFile('git', [...BASE, ...args], { cwd, env: ENV, timeout: 6000, maxBuffer: 2 * 1024 * 1024, windowsHide: true },
|
|
16
|
+
(err, out, errOut) => resolve({ ok: !err, out: String(out || ''), err: String(errOut || ''), missing: !!(err && err.code === 'ENOENT') }));
|
|
17
|
+
} catch (e) { resolve({ ok: false, out: '', err: String(e.message || e), missing: false }); }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** `git status --porcelain=v1 -b` → { branch, upstream, ahead, behind, detached, files: [{ x, y, path }] } */
|
|
22
|
+
function parseStatus(out) {
|
|
23
|
+
const res = { branch: '', upstream: '', ahead: 0, behind: 0, detached: false, files: [] };
|
|
24
|
+
for (const line of String(out).split('\n')) {
|
|
25
|
+
if (!line) continue;
|
|
26
|
+
if (line.startsWith('## ')) {
|
|
27
|
+
const h = line.slice(3);
|
|
28
|
+
let m;
|
|
29
|
+
if ((m = h.match(/^No commits yet on (.+)$/))) { res.branch = m[1]; continue; }
|
|
30
|
+
if (/^HEAD \(no branch\)/.test(h)) { res.detached = true; res.branch = 'HEAD'; continue; }
|
|
31
|
+
m = h.match(/^(.+?)(?:\.\.\.(\S+))?(?: \[(.+)\])?$/);
|
|
32
|
+
if (m) {
|
|
33
|
+
res.branch = m[1]; res.upstream = m[2] || '';
|
|
34
|
+
const a = (m[3] || '').match(/ahead (\d+)/), b = (m[3] || '').match(/behind (\d+)/);
|
|
35
|
+
res.ahead = a ? +a[1] : 0; res.behind = b ? +b[1] : 0;
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (line.length < 4) continue;
|
|
40
|
+
res.files.push({ x: line[0], y: line[1], path: line.slice(3).replace(/^"(.*)"$/, '$1') });
|
|
41
|
+
}
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `git reflog show --all --date=unix --format=%gd%x09%gs` → actividad de ramas, la más reciente primero:
|
|
47
|
+
* { k: 'switch', from, to, t } · { k: 'create', name, from, t } · { k: 'merge', what, t } · { k: 'rebase', t } (t en segundos)
|
|
48
|
+
*/
|
|
49
|
+
function parseActivity(out, limit = 20) {
|
|
50
|
+
const list = [];
|
|
51
|
+
String(out).split('\n').forEach((line, idx) => {
|
|
52
|
+
const m = line.match(/^(.+)@\{(\d+)\}\t(.*)$/);
|
|
53
|
+
if (!m) return;
|
|
54
|
+
const [, ref, ts, subj] = m, t = +ts;
|
|
55
|
+
let e = null, s;
|
|
56
|
+
if (ref === 'HEAD' && (s = subj.match(/^checkout: moving from (.+) to (.+)$/))) e = { k: 'switch', from: s[1], to: s[2], t };
|
|
57
|
+
else if (ref !== 'HEAD' && (s = subj.match(/^branch: Created from (.+)$/))) e = { k: 'create', name: ref, from: s[1], t };
|
|
58
|
+
else if (ref === 'HEAD' && (s = subj.match(/^merge (.+?)(?:: .*)?$/))) e = { k: 'merge', what: s[1], t };
|
|
59
|
+
else if (ref === 'HEAD' && /^rebase.*\(finish\)/.test(subj)) e = { k: 'rebase', t };
|
|
60
|
+
if (e) list.push({ ...e, idx });
|
|
61
|
+
});
|
|
62
|
+
return list.sort((a, b) => b.t - a.t || a.idx - b.idx).slice(0, limit).map(({ idx, ...e }) => e);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `git for-each-ref …` con %(HEAD)\t%(refname:short)\t%(committerdate:unix) → [{ cur, name, t }] */
|
|
66
|
+
function parseBranches(out) {
|
|
67
|
+
return String(out).split('\n').map((l) => l.split('\t')).filter((p) => p.length >= 3 && p[1])
|
|
68
|
+
.map(([h, name, t]) => ({ cur: h.trim() === '*', name, t: +t || 0 }));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// En macOS, sin las Command Line Tools /usr/bin/git es un atajo que abre el instalador de Apple: no se llama a git si es lo único que hay.
|
|
72
|
+
let macGit = null;
|
|
73
|
+
async function gitUsableOnMac() {
|
|
74
|
+
if (process.platform !== 'darwin') return true;
|
|
75
|
+
if (macGit !== null) return macGit;
|
|
76
|
+
const run1 = (cmd, args) => new Promise((res) => { try { cp.execFile(cmd, args, { timeout: 3000 }, (err, out) => res({ ok: !err, out: String(out || '').trim() })); } catch { res({ ok: false, out: '' }); } });
|
|
77
|
+
macGit = (await run1('/usr/bin/xcode-select', ['-p'])).ok || (await run1('/usr/bin/which', ['git'])).out.replace(/\/+$/, '') !== '/usr/bin/git';
|
|
78
|
+
return macGit;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Estado completo de una carpeta: { ok, repo, missing, status, activity, branches } (nunca lanza). */
|
|
82
|
+
async function readGit(cwd) {
|
|
83
|
+
if (!(await gitUsableOnMac())) return { ok: false, repo: true, missing: true };
|
|
84
|
+
const st = await run(cwd, ['status', '--porcelain=v1', '-b']);
|
|
85
|
+
if (st.missing) return { ok: false, repo: true, missing: true };
|
|
86
|
+
if (!st.ok) return { ok: false, repo: !/not a git repository/i.test(st.err), err: st.err.trim().split('\n')[0] || '' };
|
|
87
|
+
const [rl, br] = await Promise.all([
|
|
88
|
+
run(cwd, ['reflog', 'show', '--all', '--date=unix', '--format=%gd%x09%gs']),
|
|
89
|
+
run(cwd, ['for-each-ref', '--sort=-committerdate', '--count=8', '--format=%(HEAD)%09%(refname:short)%09%(committerdate:unix)', 'refs/heads']),
|
|
90
|
+
]);
|
|
91
|
+
return { ok: true, repo: true, status: parseStatus(st.out), activity: rl.ok ? parseActivity(rl.out) : [], branches: br.ok ? parseBranches(br.out) : [] };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = { readGit, parseStatus, parseActivity, parseBranches };
|
package/lib/i18n.js
CHANGED
|
@@ -18,7 +18,7 @@ const T = {
|
|
|
18
18
|
imgNoPrev: 'No se puede previsualizar este formato', imgHint: '← → navegar o abrir en el visor esc cerrar', imgFolder: 'Imágenes abiertas en el visor',
|
|
19
19
|
more: (n) => `mostrar ${n} más…`, busyRename: 'Cierra la conversación antes de renombrarla', renameLbl: 'nombre',
|
|
20
20
|
copied: (n) => `Copiado (${n} caracteres)`, archMsg: 'Archivada (H para verlas)', unarchMsg: 'Desarchivada', qsHint: 'saltar a cualquier conversación',
|
|
21
|
-
prevHint: '⏎ reanudar esta conversación', prevInfo: (a, n) => `${a === 'ahora' ? 'ahora mismo' : 'hace ' + a} · últimos ${n} mensajes`, kUnfold: 'desplegar', kRename: 'renombrar', kPin: 'fijar', kHelp: 'ayuda', noPrev: 'Sin mensajes para mostrar',
|
|
21
|
+
prevHint: '⏎ reanudar esta conversación', bar8: 'git', gitNone: 'Elige un proyecto', gitNoRepo: 'Esta carpeta no es un repositorio git', gitMissing: 'git no está instalado', gitErr: 'No se pudo leer el repositorio', gitClean: 'sin cambios', gitDirty: (n) => (n === 1 ? '1 cambio sin guardar' : `${n} cambios sin guardar`), gitMore: (n) => `… y ${n} más`, gitBranches: 'Ramas recientes', gitActivity: 'Actividad de ramas', gitNoActivity: 'Sin cambios de rama', gitFrom: 'desde', gitNarrow: (n) => `Terminal estrecha: el panel de git necesita ${n} columnas`, gitOnlyEmbed: 'El panel de git solo está en el terminal integrado', prevInfo: (a, n) => `${a === 'ahora' ? 'ahora mismo' : 'hace ' + a} · últimos ${n} mensajes`, kUnfold: 'desplegar', kRename: 'renombrar', kPin: 'fijar', kHelp: 'ayuda', noPrev: 'Sin mensajes para mostrar',
|
|
22
22
|
bar6: 'ocultar lista', bar7: 'mostrar lista', deep: 'contenido', pathPrompt: 'nombre de la nueva carpeta', mkIn: 'se crea en', fbTitle: 'Elegir carpeta', fbHere: 'Abrir chat aquí', fbNew: 'Nueva carpeta aquí…', fbUp: 'Subir un nivel', fbProj: 'proyecto', fbHint: '⏎ entrar · ␣ abrir · / buscar · . ocultas', fbDrives: 'Este equipo', fbRecent: 'reciente', hoverMiss: (n) => `[Image #${n}]: aún no está en el historial`, fbEmpty: 'Sin subcarpetas', badId: 'Identificador de sesión no válido',
|
|
23
23
|
imgClickHint: 'clic: abrir en grande', imgOpened: (n) => `[Image #${n}] abierta en el visor de imágenes`,
|
|
24
24
|
unknownCmd: (c) => `Comando desconocido: "${c}"`, didYouMean: (s) => `¿Quisiste decir "${s}"?`, cmdList: 'Comandos: hopdeck shortcut on|off · uninstall · doctor · help (y --list, --version).\nLas opciones de claude (por ejemplo --model opus) se pasan tal cual: hopdeck --model opus',
|
|
@@ -38,7 +38,7 @@ const T = {
|
|
|
38
38
|
help: ['Teclas', '↑↓ j k mover', '⏎ → l abrir / desplegar', '← h volver / plegar', 'n nueva conversación',
|
|
39
39
|
'/ buscar (Tab: contenido)', 'p fijar proyecto ★', 'x H ocultar / ver ocultos', 'o abrir una carpeta',
|
|
40
40
|
'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', 'q salir'],
|
|
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'],
|
|
42
42
|
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
43
|
idle3: 'F1 proyectos · F2 chat', bar1: 'proyectos', bar2: 'chat', bar3: 'minimizar',
|
|
44
44
|
inside: 'Ya estás dentro de Hopdeck (F1 para ir a la lista de proyectos).',
|
|
@@ -58,7 +58,7 @@ const T = {
|
|
|
58
58
|
imgNoPrev: 'This format cannot be previewed', imgHint: '← → browse o open in viewer esc close', imgFolder: 'Images opened in the viewer',
|
|
59
59
|
more: (n) => `show ${n} more…`, busyRename: 'Close the conversation before renaming it', renameLbl: 'name',
|
|
60
60
|
copied: (n) => `Copied (${n} chars)`, archMsg: 'Archived (H to show)', unarchMsg: 'Unarchived', qsHint: 'jump to any conversation',
|
|
61
|
-
prevHint: '⏎ resume this conversation', 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',
|
|
61
|
+
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
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
63
|
imgClickHint: 'click: open full size', imgOpened: (n) => `[Image #${n}] opened in the image viewer`,
|
|
64
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',
|
|
@@ -78,7 +78,7 @@ const T = {
|
|
|
78
78
|
help: ['Keys', '↑↓ j k move', '⏎ → l open / expand', '← h back / collapse', 'n new conversation',
|
|
79
79
|
'/ search (Tab: content)', 'p pin project ★', 'x H hide / show hidden', 'o open a folder',
|
|
80
80
|
'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', 'q quit'],
|
|
81
|
+
'F1 F2 focus list / chat', 'F3 copy text (mouse)', 'F4 hide the list', 'b F8 git panel', '⠋ ✔ ● working · done · open', 'q quit'],
|
|
82
82
|
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
83
|
idle3: 'F1 projects · F2 chat', bar1: 'projects', bar2: 'chat', bar3: 'minimize',
|
|
84
84
|
inside: 'You are already inside Hopdeck (F1 jumps to the project list).',
|
package/lib/sixel.js
CHANGED
|
@@ -29,22 +29,24 @@ function quantize(rgb, w, h, maxColors = 256) {
|
|
|
29
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
30
|
const bins = [];
|
|
31
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
|
-
|
|
32
|
+
// cada caja guarda su mejor corte (canal y puntuación) calculado una sola vez al crearla: así cada paso solo recalcula las dos cajas nuevas
|
|
33
|
+
const mk = (items) => {
|
|
34
|
+
let cnt = 0; const lo = [255, 255, 255], hi = [0, 0, 0];
|
|
35
|
+
for (const p of items) { cnt += p.c; if (p.r < lo[0]) lo[0] = p.r; if (p.r > hi[0]) hi[0] = p.r; if (p.g < lo[1]) lo[1] = p.g; if (p.g > hi[1]) hi[1] = p.g; if (p.b < lo[2]) lo[2] = p.b; if (p.b > hi[2]) hi[2] = p.b; }
|
|
36
|
+
let ch = 0, rng = hi[0] - lo[0]; if (hi[1] - lo[1] > rng) { ch = 1; rng = hi[1] - lo[1]; } if (hi[2] - lo[2] > rng) { ch = 2; rng = hi[2] - lo[2]; }
|
|
37
|
+
return { items, ch: 'rgb'[ch], score: items.length < 2 ? -1 : rng * Math.sqrt(cnt) };
|
|
38
|
+
};
|
|
39
|
+
let boxes = [mk(bins)];
|
|
33
40
|
while (boxes.length < maxColors) {
|
|
34
|
-
|
|
35
|
-
let
|
|
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
|
-
});
|
|
41
|
+
let bi = -1, best = -1;
|
|
42
|
+
for (let i = 0; i < boxes.length; i++) if (boxes[i].score > best) { best = boxes[i].score; bi = i; }
|
|
42
43
|
if (bi < 0) break;
|
|
43
|
-
const
|
|
44
|
-
const half = bx.reduce((
|
|
44
|
+
const { items, ch } = boxes[bi], bx = items.slice().sort((p, q) => p[ch] - q[ch]);
|
|
45
|
+
const half = bx.reduce((s2, p) => s2 + p.c, 0) / 2; let acc = 0, cut = 1;
|
|
45
46
|
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
|
+
boxes.splice(bi, 1, mk(bx.slice(0, cut)), mk(bx.slice(cut)));
|
|
47
48
|
}
|
|
49
|
+
boxes = boxes.map((bx) => bx.items);
|
|
48
50
|
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
51
|
const map = new Int16Array(32768).fill(-1); // cada color de 5 bits → su caja
|
|
50
52
|
boxes.forEach((bx, i) => { for (const p of bx) map[p.id] = i; });
|
package/package.json
CHANGED