@thebattlearena/battle-arena-hooks 0.5.3-beta.54 → 0.7.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/README.md +168 -5
- package/cli.mjs +114 -10
- package/fonts/battle-arena-icons/BattleArenaIcons.ttf +0 -0
- package/fonts/battle-arena-icons/LICENSE-lucide.txt +39 -0
- package/lib/ghostty-theme.mjs +162 -0
- package/lib/icon-font.mjs +143 -0
- package/lib/plugin-install.mjs +26 -0
- package/lib/radio-install.mjs +2 -2
- package/package.json +6 -2
- package/plugin/.claude-plugin/plugin.json +3 -1
- package/plugin/hooks/close-pane.tsx +4 -3
- package/plugin/hooks/close.ts +6 -5
- package/plugin/hooks/colors.ts +18 -0
- package/plugin/hooks/complements.ts +3 -2
- package/plugin/hooks/format.ts +30 -10
- package/plugin/hooks/icon-files.ts +35 -0
- package/plugin/hooks/icons-diag.tsx +155 -0
- package/plugin/hooks/icons.generated.ts +104 -0
- package/plugin/hooks/icons.ts +161 -0
- package/plugin/hooks/label-links.tsx +55 -0
- package/plugin/hooks/pane.tsx +190 -51
- package/plugin/hooks/radio-pane.tsx +95 -25
- package/plugin/hooks/radio-queue.ts +41 -0
- package/plugin/hooks/register.tsx +193 -7
- package/plugin/hooks/ring-io.ts +248 -0
- package/plugin/hooks/ring-pane.tsx +823 -0
- package/plugin/hooks/ring.ts +595 -0
- package/plugin/hooks/terminal-caps.ts +31 -0
- package/plugin/icons/activo-grey-2x1.png +0 -0
- package/plugin/icons/activo-grey-4x2.png +0 -0
- package/plugin/icons/activo-grey-5x2.png +0 -0
- package/plugin/icons/activo-grey-6x2.png +0 -0
- package/plugin/icons/arbitro-amber-2x1.png +0 -0
- package/plugin/icons/arbitro-amber-4x2.png +0 -0
- package/plugin/icons/arbitro-amber-5x2.png +0 -0
- package/plugin/icons/arbitro-amber-6x2.png +0 -0
- package/plugin/icons/arbitro-grey-2x1.png +0 -0
- package/plugin/icons/arbitro-grey-4x2.png +0 -0
- package/plugin/icons/arbitro-grey-5x2.png +0 -0
- package/plugin/icons/arbitro-grey-6x2.png +0 -0
- package/plugin/icons/arbitro-red-2x1.png +0 -0
- package/plugin/icons/arbitro-red-4x2.png +0 -0
- package/plugin/icons/arbitro-red-5x2.png +0 -0
- package/plugin/icons/arbitro-red-6x2.png +0 -0
- package/plugin/icons/arbitro-slate-2x1.png +0 -0
- package/plugin/icons/arbitro-slate-4x2.png +0 -0
- package/plugin/icons/arbitro-slate-5x2.png +0 -0
- package/plugin/icons/arbitro-slate-6x2.png +0 -0
- package/plugin/icons/arbitro-slate-dim-2x1.png +0 -0
- package/plugin/icons/arbitro-slate-dim-4x2.png +0 -0
- package/plugin/icons/arbitro-slate-dim-5x2.png +0 -0
- package/plugin/icons/arbitro-slate-dim-6x2.png +0 -0
- package/plugin/icons/arena-grey-2x1.png +0 -0
- package/plugin/icons/arena-grey-4x2.png +0 -0
- package/plugin/icons/arena-grey-5x2.png +0 -0
- package/plugin/icons/arena-grey-6x2.png +0 -0
- package/plugin/icons/bateria-grey-2x1.png +0 -0
- package/plugin/icons/bateria-grey-4x2.png +0 -0
- package/plugin/icons/bateria-grey-5x2.png +0 -0
- package/plugin/icons/bateria-grey-6x2.png +0 -0
- package/plugin/icons/campana-amber-2x1.png +0 -0
- package/plugin/icons/campana-amber-4x2.png +0 -0
- package/plugin/icons/campana-amber-5x2.png +0 -0
- package/plugin/icons/campana-amber-6x2.png +0 -0
- package/plugin/icons/campana-amber-dim-2x1.png +0 -0
- package/plugin/icons/campana-amber-dim-4x2.png +0 -0
- package/plugin/icons/campana-amber-dim-5x2.png +0 -0
- package/plugin/icons/campana-amber-dim-6x2.png +0 -0
- package/plugin/icons/campana-grey-2x1.png +0 -0
- package/plugin/icons/campana-grey-4x2.png +0 -0
- package/plugin/icons/campana-grey-5x2.png +0 -0
- package/plugin/icons/campana-grey-6x2.png +0 -0
- package/plugin/icons/campana-red-2x1.png +0 -0
- package/plugin/icons/campana-red-4x2.png +0 -0
- package/plugin/icons/campana-red-5x2.png +0 -0
- package/plugin/icons/campana-red-6x2.png +0 -0
- package/plugin/icons/copilot-amber-2x1.png +0 -0
- package/plugin/icons/copilot-amber-4x2.png +0 -0
- package/plugin/icons/copilot-amber-5x2.png +0 -0
- package/plugin/icons/copilot-amber-6x2.png +0 -0
- package/plugin/icons/copilot-grey-2x1.png +0 -0
- package/plugin/icons/copilot-grey-4x2.png +0 -0
- package/plugin/icons/copilot-grey-5x2.png +0 -0
- package/plugin/icons/copilot-grey-6x2.png +0 -0
- package/plugin/icons/copilot-purple-2x1.png +0 -0
- package/plugin/icons/copilot-purple-4x2.png +0 -0
- package/plugin/icons/copilot-purple-5x2.png +0 -0
- package/plugin/icons/copilot-purple-6x2.png +0 -0
- package/plugin/icons/copilot-purple-dim-2x1.png +0 -0
- package/plugin/icons/copilot-purple-dim-4x2.png +0 -0
- package/plugin/icons/copilot-purple-dim-5x2.png +0 -0
- package/plugin/icons/copilot-purple-dim-6x2.png +0 -0
- package/plugin/icons/copilot-red-2x1.png +0 -0
- package/plugin/icons/copilot-red-4x2.png +0 -0
- package/plugin/icons/copilot-red-5x2.png +0 -0
- package/plugin/icons/copilot-red-6x2.png +0 -0
- package/plugin/icons/cronica-grey-2x1.png +0 -0
- package/plugin/icons/cronica-grey-4x2.png +0 -0
- package/plugin/icons/cronica-grey-5x2.png +0 -0
- package/plugin/icons/cronica-grey-6x2.png +0 -0
- package/plugin/icons/emergente-grey-2x1.png +0 -0
- package/plugin/icons/emergente-grey-4x2.png +0 -0
- package/plugin/icons/emergente-grey-5x2.png +0 -0
- package/plugin/icons/emergente-grey-6x2.png +0 -0
- package/plugin/icons/en-la-esquina-grey-2x1.png +0 -0
- package/plugin/icons/en-la-esquina-grey-4x2.png +0 -0
- package/plugin/icons/en-la-esquina-grey-5x2.png +0 -0
- package/plugin/icons/en-la-esquina-grey-6x2.png +0 -0
- package/plugin/icons/espera-grey-2x1.png +0 -0
- package/plugin/icons/espera-grey-4x2.png +0 -0
- package/plugin/icons/espera-grey-5x2.png +0 -0
- package/plugin/icons/espera-grey-6x2.png +0 -0
- package/plugin/icons/esquinero-amber-2x1.png +0 -0
- package/plugin/icons/esquinero-amber-4x2.png +0 -0
- package/plugin/icons/esquinero-amber-5x2.png +0 -0
- package/plugin/icons/esquinero-amber-6x2.png +0 -0
- package/plugin/icons/esquinero-grey-2x1.png +0 -0
- package/plugin/icons/esquinero-grey-4x2.png +0 -0
- package/plugin/icons/esquinero-grey-5x2.png +0 -0
- package/plugin/icons/esquinero-grey-6x2.png +0 -0
- package/plugin/icons/esquinero-red-2x1.png +0 -0
- package/plugin/icons/esquinero-red-4x2.png +0 -0
- package/plugin/icons/esquinero-red-5x2.png +0 -0
- package/plugin/icons/esquinero-red-6x2.png +0 -0
- package/plugin/icons/esquinero-teal-2x1.png +0 -0
- package/plugin/icons/esquinero-teal-4x2.png +0 -0
- package/plugin/icons/esquinero-teal-5x2.png +0 -0
- package/plugin/icons/esquinero-teal-6x2.png +0 -0
- package/plugin/icons/esquinero-teal-dim-2x1.png +0 -0
- package/plugin/icons/esquinero-teal-dim-4x2.png +0 -0
- package/plugin/icons/esquinero-teal-dim-5x2.png +0 -0
- package/plugin/icons/esquinero-teal-dim-6x2.png +0 -0
- package/plugin/icons/fallo-grey-2x1.png +0 -0
- package/plugin/icons/fallo-grey-4x2.png +0 -0
- package/plugin/icons/fallo-grey-5x2.png +0 -0
- package/plugin/icons/fallo-grey-6x2.png +0 -0
- package/plugin/icons/finalizando-grey-2x1.png +0 -0
- package/plugin/icons/finalizando-grey-4x2.png +0 -0
- package/plugin/icons/finalizando-grey-5x2.png +0 -0
- package/plugin/icons/finalizando-grey-6x2.png +0 -0
- package/plugin/icons/fuego-grey-2x1.png +0 -0
- package/plugin/icons/fuego-grey-4x2.png +0 -0
- package/plugin/icons/fuego-grey-5x2.png +0 -0
- package/plugin/icons/fuego-grey-6x2.png +0 -0
- package/plugin/icons/golpe-grey-2x1.png +0 -0
- package/plugin/icons/golpe-grey-4x2.png +0 -0
- package/plugin/icons/golpe-grey-5x2.png +0 -0
- package/plugin/icons/golpe-grey-6x2.png +0 -0
- package/plugin/icons/juez-amber-2x1.png +0 -0
- package/plugin/icons/juez-amber-4x2.png +0 -0
- package/plugin/icons/juez-amber-5x2.png +0 -0
- package/plugin/icons/juez-amber-6x2.png +0 -0
- package/plugin/icons/juez-grey-2x1.png +0 -0
- package/plugin/icons/juez-grey-4x2.png +0 -0
- package/plugin/icons/juez-grey-5x2.png +0 -0
- package/plugin/icons/juez-grey-6x2.png +0 -0
- package/plugin/icons/juez-orange-2x1.png +0 -0
- package/plugin/icons/juez-orange-4x2.png +0 -0
- package/plugin/icons/juez-orange-5x2.png +0 -0
- package/plugin/icons/juez-orange-6x2.png +0 -0
- package/plugin/icons/juez-orange-dim-2x1.png +0 -0
- package/plugin/icons/juez-orange-dim-4x2.png +0 -0
- package/plugin/icons/juez-orange-dim-5x2.png +0 -0
- package/plugin/icons/juez-orange-dim-6x2.png +0 -0
- package/plugin/icons/juez-red-2x1.png +0 -0
- package/plugin/icons/juez-red-4x2.png +0 -0
- package/plugin/icons/juez-red-5x2.png +0 -0
- package/plugin/icons/juez-red-6x2.png +0 -0
- package/plugin/icons/listo-grey-2x1.png +0 -0
- package/plugin/icons/listo-grey-4x2.png +0 -0
- package/plugin/icons/listo-grey-5x2.png +0 -0
- package/plugin/icons/listo-grey-6x2.png +0 -0
- package/plugin/icons/luchador-amber-2x1.png +0 -0
- package/plugin/icons/luchador-amber-4x2.png +0 -0
- package/plugin/icons/luchador-amber-5x2.png +0 -0
- package/plugin/icons/luchador-amber-6x2.png +0 -0
- package/plugin/icons/luchador-blue-2x1.png +0 -0
- package/plugin/icons/luchador-blue-4x2.png +0 -0
- package/plugin/icons/luchador-blue-5x2.png +0 -0
- package/plugin/icons/luchador-blue-6x2.png +0 -0
- package/plugin/icons/luchador-blue-dim-2x1.png +0 -0
- package/plugin/icons/luchador-blue-dim-4x2.png +0 -0
- package/plugin/icons/luchador-blue-dim-5x2.png +0 -0
- package/plugin/icons/luchador-blue-dim-6x2.png +0 -0
- package/plugin/icons/luchador-grey-2x1.png +0 -0
- package/plugin/icons/luchador-grey-4x2.png +0 -0
- package/plugin/icons/luchador-grey-5x2.png +0 -0
- package/plugin/icons/luchador-grey-6x2.png +0 -0
- package/plugin/icons/luchador-red-2x1.png +0 -0
- package/plugin/icons/luchador-red-4x2.png +0 -0
- package/plugin/icons/luchador-red-5x2.png +0 -0
- package/plugin/icons/luchador-red-6x2.png +0 -0
- package/plugin/icons/modificando-grey-2x1.png +0 -0
- package/plugin/icons/modificando-grey-4x2.png +0 -0
- package/plugin/icons/modificando-grey-5x2.png +0 -0
- package/plugin/icons/modificando-grey-6x2.png +0 -0
- package/plugin/icons/monitor-grey-2x1.png +0 -0
- package/plugin/icons/monitor-grey-4x2.png +0 -0
- package/plugin/icons/monitor-grey-5x2.png +0 -0
- package/plugin/icons/monitor-grey-6x2.png +0 -0
- package/plugin/icons/objetivo-grey-2x1.png +0 -0
- package/plugin/icons/objetivo-grey-4x2.png +0 -0
- package/plugin/icons/objetivo-grey-5x2.png +0 -0
- package/plugin/icons/objetivo-grey-6x2.png +0 -0
- package/plugin/icons/pensando-grey-2x1.png +0 -0
- package/plugin/icons/pensando-grey-4x2.png +0 -0
- package/plugin/icons/pensando-grey-5x2.png +0 -0
- package/plugin/icons/pensando-grey-6x2.png +0 -0
- package/plugin/icons/plan-grey-2x1.png +0 -0
- package/plugin/icons/plan-grey-4x2.png +0 -0
- package/plugin/icons/plan-grey-5x2.png +0 -0
- package/plugin/icons/plan-grey-6x2.png +0 -0
- package/plugin/icons/pr-grey-2x1.png +0 -0
- package/plugin/icons/pr-grey-4x2.png +0 -0
- package/plugin/icons/pr-grey-5x2.png +0 -0
- package/plugin/icons/pr-grey-6x2.png +0 -0
- package/plugin/icons/probando-grey-2x1.png +0 -0
- package/plugin/icons/probando-grey-4x2.png +0 -0
- package/plugin/icons/probando-grey-5x2.png +0 -0
- package/plugin/icons/probando-grey-6x2.png +0 -0
- package/plugin/icons/punto-grey-2x1.png +0 -0
- package/plugin/icons/punto-grey-4x2.png +0 -0
- package/plugin/icons/punto-grey-5x2.png +0 -0
- package/plugin/icons/punto-grey-6x2.png +0 -0
- package/plugin/icons/rama-grey-2x1.png +0 -0
- package/plugin/icons/rama-grey-4x2.png +0 -0
- package/plugin/icons/rama-grey-5x2.png +0 -0
- package/plugin/icons/rama-grey-6x2.png +0 -0
- package/plugin/icons/reunion-grey-2x1.png +0 -0
- package/plugin/icons/reunion-grey-4x2.png +0 -0
- package/plugin/icons/reunion-grey-5x2.png +0 -0
- package/plugin/icons/reunion-grey-6x2.png +0 -0
- package/plugin/icons/revisando-grey-2x1.png +0 -0
- package/plugin/icons/revisando-grey-4x2.png +0 -0
- package/plugin/icons/revisando-grey-5x2.png +0 -0
- package/plugin/icons/revisando-grey-6x2.png +0 -0
- package/plugin/icons/riesgo-grey-2x1.png +0 -0
- package/plugin/icons/riesgo-grey-4x2.png +0 -0
- package/plugin/icons/riesgo-grey-5x2.png +0 -0
- package/plugin/icons/riesgo-grey-6x2.png +0 -0
- package/plugin/icons/ronda-grey-2x1.png +0 -0
- package/plugin/icons/ronda-grey-4x2.png +0 -0
- package/plugin/icons/ronda-grey-5x2.png +0 -0
- package/plugin/icons/ronda-grey-6x2.png +0 -0
- package/plugin/icons/subiendo-grey-2x1.png +0 -0
- package/plugin/icons/subiendo-grey-4x2.png +0 -0
- package/plugin/icons/subiendo-grey-5x2.png +0 -0
- package/plugin/icons/subiendo-grey-6x2.png +0 -0
- package/plugin/icons/te-toca-grey-2x1.png +0 -0
- package/plugin/icons/te-toca-grey-4x2.png +0 -0
- package/plugin/icons/te-toca-grey-5x2.png +0 -0
- package/plugin/icons/te-toca-grey-6x2.png +0 -0
- package/plugin/icons/ticket-grey-2x1.png +0 -0
- package/plugin/icons/ticket-grey-4x2.png +0 -0
- package/plugin/icons/ticket-grey-5x2.png +0 -0
- package/plugin/icons/ticket-grey-6x2.png +0 -0
- package/plugin/icons/tiempo-grey-2x1.png +0 -0
- package/plugin/icons/tiempo-grey-4x2.png +0 -0
- package/plugin/icons/tiempo-grey-5x2.png +0 -0
- package/plugin/icons/tiempo-grey-6x2.png +0 -0
- package/plugin/icons/trofeo-grey-2x1.png +0 -0
- package/plugin/icons/trofeo-grey-4x2.png +0 -0
- package/plugin/icons/trofeo-grey-5x2.png +0 -0
- package/plugin/icons/trofeo-grey-6x2.png +0 -0
- package/plugin/tests/format.test.ts +39 -0
- package/plugin/tests/radio.test.tsx +180 -13
- package/plugin/tests/ring-pane.test.tsx +1348 -0
- package/plugin/tests/ring.test.ts +646 -0
- package/plugin/tests/support/ghostty-baseline-radio.ts +6 -0
- package/plugin/tests/support/ghostty-baseline.ts +8 -0
- package/plugin/tests/support/text.ts +301 -0
- package/plugin/types/index.d.ts +99 -0
- package/ring/hooks/hooks.json +67 -0
- package/ring/scripts/config.mjs +5 -1
- package/ring/scripts/judges-card.mjs +21 -1
- package/ring/scripts/live-hook.mjs +273 -0
- package/ring/scripts/live.mjs +443 -0
- package/ring/scripts/monitors.mjs +199 -0
- package/ring/scripts/one-at-a-time.mjs +44 -3
- package/ring/scripts/round-bell.mjs +30 -15
- package/ring/scripts/title-defense.mjs +53 -2
- package/ring/skills/referee/SKILL.md +3 -0
- package/ring/skills/weigh-in/SKILL.md +30 -1
- package/themes/ghostty/Battle Arena +25 -0
package/README.md
CHANGED
|
@@ -80,6 +80,24 @@ y `npm install` baja su dependencia SOLO en esa carpeta; los hooks `.mjs` siguen
|
|
|
80
80
|
canciones siguen en la web). La API no da la duración ni el artista: el panel muestra lo que lleva
|
|
81
81
|
sonando y el título que arma la API.
|
|
82
82
|
|
|
83
|
+
### El tema de Ghostty — opcional
|
|
84
|
+
|
|
85
|
+
Los colores de la marca en la terminal: fondo navy `#061224`, cursor coral `#F26464`, azul `#2684FF`
|
|
86
|
+
y la paleta ANSI de los tokens dark de `apps/web`. El tema vive en `themes/ghostty/Battle Arena`:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx @thebattlearena/battle-arena-hooks@latest install --with theme
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Lo copia a `~/.config/ghostty/themes/` y lo elige en la config de Ghostty que ya exista
|
|
93
|
+
(`config.ghostty` o `config`, en `~/.config/ghostty/` o en `~/Library/Application Support/com.mitchellh.ghostty/`):
|
|
94
|
+
Ghostty las carga en orden y gana el último `theme =`, así que sólo toca la config que decide: la
|
|
95
|
+
última con tema (cambia su último `theme =` y anota el anterior, tal cual, en un comentario) o, si
|
|
96
|
+
ninguna tiene, la última que exista. Si ya tenías un tema «Battle Arena» propio, no lo pisa. Nunca crea la config: sin ella imprime `theme = Battle Arena` para que
|
|
97
|
+
la pegues. También imprime, sin escribirlas, las líneas del look completo (JetBrains Mono, márgenes de
|
|
98
|
+
la ventana e ícono coral en macOS). Como la radio, queda en `"with"` de config.json. `uninstall`
|
|
99
|
+
regresa el tema que tenías y quita el archivo sólo si es el nuestro y ninguna config lo sigue eligiendo. Se ve al recargar la config de Ghostty (⌘⇧,).
|
|
100
|
+
|
|
83
101
|
Los comandos del Scorecard no llevan el prefijo del plugin (así registra Claude Code los comandos de
|
|
84
102
|
un módulo), por eso su nombre ya es único.
|
|
85
103
|
|
|
@@ -114,6 +132,7 @@ apps/claude-hooks/
|
|
|
114
132
|
skills/ las skills (las genera `npm run bundle:skill`)
|
|
115
133
|
tests/ pruebas del Scorecard (`claude plugin test plugin`)
|
|
116
134
|
radio/player.mjs radio/package.json reproductor de la radio (solo con `install --with radio`)
|
|
135
|
+
themes/ghostty/Battle Arena tema de Ghostty (solo con `install --with theme`)
|
|
117
136
|
```
|
|
118
137
|
|
|
119
138
|
### Plan de batalla (skill `/battlearena:conquer` + `plan.mjs`, ADR-0042)
|
|
@@ -202,8 +221,8 @@ Agentes: `ring:wrestler` (ejecutor, `effort: medium`) y `ring:cornerman` (reviso
|
|
|
202
221
|
|
|
203
222
|
**Config del repo** (`.claude/ring.json`, opcional): `gates` (typecheck, tests por ruta con
|
|
204
223
|
`{paths}`, lint), `validateCommand`, `rulebook` (por defecto el genérico del plugin),
|
|
205
|
-
`protectedBranches`, `forbidAiTrailers` (por defecto `true`), `heavyCommands`, `delegation
|
|
206
|
-
`precedents
|
|
224
|
+
`protectedBranches`, `forbidAiTrailers` (por defecto `true`), `heavyCommands`, `delegation`,
|
|
225
|
+
`precedents` y `monitors` (ver «Monitores del repo»). Sin el archivo, `ring` usa los gates que detecta en `package.json`, `pyproject.toml`,
|
|
207
226
|
`go.mod` y el `Makefile`.
|
|
208
227
|
|
|
209
228
|
**Delegación y precedentes**: con `delegation: "referee"` (el default) el árbitro decide él mismo
|
|
@@ -238,6 +257,150 @@ primera vez que un script lo busca (las rutas absolutas de `state.json` y del ju
|
|
|
238
257
|
siguen); si existen los dos, gana el nuevo, el viejo no se toca y se avisa por stderr. Si la
|
|
239
258
|
mudanza falla, `mask-guard` bloquea diciendo por qué en vez de dejar pasar. Nunca en el scratchpad de la sesión, que se borra al reiniciar.
|
|
240
259
|
|
|
260
|
+
**El ring en vivo en el Scorecard.** Si el repo de la sesión tiene un combate activo, el punto del
|
|
261
|
+
plan cuyas ligas (`refs`) nombran el PR del combate (`agents-studio-be#1060`, `owner/repo#N` o su URL)
|
|
262
|
+
dice junto a su tiempo si ahí se está trabajando: spinner mientras alguien trabaja, ■ ámbar si te toca
|
|
263
|
+
decidir, 👊N en rojo si Copilot dejó hilos, nada en reposo. Al abrir el punto aparece la fila
|
|
264
|
+
«▸ Revisión #N» con el tiempo del ring de hoy (si ningún punto liga el PR, la fila va sola tras los
|
|
265
|
+
puntos). Desplegada (▾), como la lámina «Cuerpo»: la cabecera (spinner o ■ ámbar, `#PR`, los rounds de
|
|
266
|
+
la defensa del título con su barra ▮▯ sacados de los `## Round N` de `title-defense.md` contra su
|
|
267
|
+
tope, la última round-bell y la crónica); la tarjeta en vivo con acento a la izquierda (azul
|
|
268
|
+
trabajando, roja «👊×N HIGH» si Copilot golpeó, ámbar llena «TE TOCA DECIDIR» con el tiempo, o «sin
|
|
269
|
+
actividad desde hace X»); las fichas en una fila, cajas redondeadas con el ícono al centro y el
|
|
270
|
+
estado en el borde (quieta gris, activa azul con barra, en la esquina morada con ◣, golpeó roja con
|
|
271
|
+
👊N, te toca ámbar con «tú», abierta con borde grueso y ▾); y la ficha abierta: título con desde
|
|
272
|
+
cuándo, el verbo con su barra, la tabla de `fields` del evento (rama, commits, archivo; rango, modo,
|
|
273
|
+
veredicto; hilos, severidad; pregunta con «responde en la terminal ↵»), ÚLTIMOS y cómo cerrarla.
|
|
274
|
+
Las fichas son cuadrados rellenos de 4×2 celdas (con celdas de ~1:2.1 se ven cuadrados), sin
|
|
275
|
+
borde, en un tinte del color del actor (más fuerte trabajando y abierta), con el glifo centrado arriba
|
|
276
|
+
y el indicador centrado abajo, dentro de la ficha; toda la ficha es el clic. Si la terminal dibuja
|
|
277
|
+
imágenes (el panel lo pregunta con `$.ui.blit` sobre la campana de la cabecera), va el PNG del
|
|
278
|
+
ícono en su lugar; Ghostty hoy no las dibuja con este engine (lo confirma `/scorecard-icons`, que
|
|
279
|
+
muestra cada forma de imagen con lo que contestó el engine), así que lo normal son los glifos, o dos
|
|
280
|
+
letras ASCII sin la fuente. Los
|
|
281
|
+
íconos chicos (campana, crónica, tarjeta y título) van con la fuente y, con ella instalada, todos los
|
|
282
|
+
símbolos del Scorecard (estados del punto ↻ ↷ ○ ● ✓, ▸ ▾ ▴, ↗, ✋ 👍 👎, ✎, 📅 💡, ♪ ▶ ⏸ ▲…) son sus
|
|
283
|
+
glifos, en sus mismos colores; sin ella, los caracteres de siempre (`ic()` en `icons.ts`). La
|
|
284
|
+
última round-bell sale del
|
|
285
|
+
feed en vivo o, en combates de antes, de `gh pr list --head ring/<pr>/round-<n>` (una vez por
|
|
286
|
+
round). Un escritor puede mandar la tabla de la ficha con `fields` (`live.mjs emit --field
|
|
287
|
+
rama=feat/x`).
|
|
288
|
+
|
|
289
|
+
**La fuente de íconos.** `fonts/battle-arena-icons/BattleArenaIcons.ttf`: 58 glifos en el área de
|
|
290
|
+
uso privado suplementaria A (U+FBA00–U+FBA85, lejos de los de Nerd Fonts), con nombre de glifo igual
|
|
291
|
+
al id de `src/codepoints.json`. UPM 1000; un ícono de una celda avanza 600 y uno de dos, 1200 (la
|
|
292
|
+
celda de una mono típica es 0.6 em), centrados en vertical en y = 340. 31 vienen de Lucide (ISC,
|
|
293
|
+
`LICENSE-lucide.txt`) y 5 son propios. `install` la copia a `~/Library/Fonts` (macOS) o a
|
|
294
|
+
`~/.local/share/fonts` (Linux, con `fc-cache -f` si está) y deja `iconFont: true` en
|
|
295
|
+
`~/.claude/battle-arena/config.json`: un mod no puede saber qué fuentes tiene la terminal, así que el
|
|
296
|
+
Scorecard sólo dibuja glifos con esa bandera. Si Ghostty ya tiene config (`config.ghostty` o `config`, en `~/.config/ghostty/`
|
|
297
|
+
o en `~/Library/Application Support/com.mitchellh.ghostty/`), le agrega
|
|
298
|
+
`font-codepoint-map = U+FBA00-U+FBAFF=Battle Arena Icons` (el bloque entero de la fuente); si no, imprime la línea para que la
|
|
299
|
+
agregues tú (nunca crea ni reescribe tu config). `uninstall` quita la fuente, esa línea y apaga
|
|
300
|
+
`iconFont`. Para regenerarla tras cambiar un SVG: `python3 -m venv /tmp/ba-icons &&
|
|
301
|
+
/tmp/ba-icons/bin/pip install -r fonts/battle-arena-icons/requirements.txt &&
|
|
302
|
+
/tmp/ba-icons/bin/python fonts/battle-arena-icons/build.py` (picosvg pasa los trazos a contornos y
|
|
303
|
+
fonttools arma el `.ttf`; nada de esto corre al instalar).
|
|
304
|
+
|
|
305
|
+
La fuente es `<combate>/live.jsonl`, un evento JSON por línea (se queda con los últimos 60 más el
|
|
306
|
+
último de cada actor y cada trabajo abierto). La escriben, de mejor esfuerzo y sin hacer ruido
|
|
307
|
+
nunca: `round-bell.mjs open` (campana), `title-defense.mjs requested|wait|feedback` (Copilot en la
|
|
308
|
+
esquina, revisó, 👊N), `judges-card.mjs log|approve-contract|play-by-play-url` (árbitro y juez),
|
|
309
|
+
`one-at-a-time.mjs run` y el hook `live-hook.mjs` (`PreToolUse`/`PostToolUse`/`PostToolUseFailure`
|
|
310
|
+
sobre `Agent`, `AskUserQuestion` y `Bash`, y `SubagentStop`). **Convención de subagentes**: cuentan
|
|
311
|
+
los de tipo `ring:wrestler` / `ring:cornerman` y, si son `general-purpose`, los que empiezan su
|
|
312
|
+
`description` con `Wrestler:` o `Cornerman:` (también `Luchador:` / `Esquinero:`); el resto de la
|
|
313
|
+
descripción es la etiqueta del chip. Un `AskUserQuestion` pendiente pone al juez en «te toca
|
|
314
|
+
decidir»; si la pregunta se descarta sin contestar (Claude Code no avisa), el siguiente
|
|
315
|
+
`UserPromptSubmit` o `Stop` de esa sesión la cierra como «sin respuesta», y el Scorecard la da por
|
|
316
|
+
caducada a los 30 min. **Sólo las sesiones del combate escriben**: una sesión se registra sola
|
|
317
|
+
(`state.json` → `sessions`, con su rol y cuándo se vio) la primera vez que corre un script del ring;
|
|
318
|
+
sus subagentes comparten su `session_id`. Otra sesión que trabaje en el mismo repo no cuenta.
|
|
319
|
+
|
|
320
|
+
**Monitores del repo.** `ring` es genérico y no trae monitores: **cada repo declara los suyos, con
|
|
321
|
+
sus íconos y colores, en SU `.claude/ring.json`**, y salen como fichas extra tras las del ring. Un
|
|
322
|
+
ejemplo, el de agents-studio-be (su batería de campañas, que además abre la vista del mod
|
|
323
|
+
`campaign-test-monitor`; no es parte del plugin):
|
|
324
|
+
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"monitors": [
|
|
328
|
+
{
|
|
329
|
+
"id": "bateria",
|
|
330
|
+
"label": "Batería",
|
|
331
|
+
"icon": "bateria",
|
|
332
|
+
"color": "green",
|
|
333
|
+
"match": { "command": "campaign-mock-report/scripts/run\\.mjs" },
|
|
334
|
+
"open": { "command": "campaign-test-monitor" }
|
|
335
|
+
}
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
- `id` (minúsculas, dígitos, `_`, `-`; nunca el de un actor del ring) y `label`. Una entrada
|
|
341
|
+
inválida se ignora con un aviso en `config.mjs show`; nunca tumba `mask-guard`.
|
|
342
|
+
- `icon` (opcional): cualquiera de los 58 nombres de la fuente Battle Arena Icons; uno que no exista,
|
|
343
|
+
o ninguno, deja las dos primeras letras del `label` (los de puntos, acciones y medios son de la
|
|
344
|
+
interfaz del Scorecard y no tienen imagen, sólo glifo):
|
|
345
|
+
- marca: `arena`
|
|
346
|
+
- actores: `arbitro`, `luchador`, `esquinero`, `campana`, `copilot`, `juez`
|
|
347
|
+
- estados: `activo`, `en-la-esquina`, `golpe`, `listo`, `fallo`, `espera`, `te-toca`, `pensando`, `modificando`, `probando`, `revisando`, `subiendo`, `finalizando`
|
|
348
|
+
- objetos: `pr`, `ronda`, `cronica`, `monitor`, `bateria`, `rama`, `ticket`
|
|
349
|
+
- scorecard: `plan`, `punto`, `emergente`, `riesgo`, `reunion`, `objetivo`, `tiempo`, `trofeo`, `fuego`
|
|
350
|
+
- puntos: `en-curso`, `desplazado`, `por-hacer`, `con-avance`, `decision-pendiente`
|
|
351
|
+
- acciones: `expandir`, `contraer`, `cerrar-detalle`, `abrir-web`, `cerrar`, `levantar-mano`, `voto-a-favor`, `voto-en-contra`, `responder`, `enviar`, `siguiente`
|
|
352
|
+
- medios: `calendario`, `cabinas`, `radio`, `reproducir`, `pausar`, `votar-cancion`
|
|
353
|
+
- `color` (opcional): uno de la paleta (`slate`, `blue`, `teal`, `amber`, `purple`, `orange`,
|
|
354
|
+
`green`, `red`, `pink`); sin él, verde. Va en el borde de la ficha; el ícono de un monitor se
|
|
355
|
+
dibuja en gris neutro (sólo los actores del ring tienen PNG en su color).
|
|
356
|
+
- `match.command` (opcional): regex sobre lo que el comando de Bash **ejecuta**. Antes de probarla
|
|
357
|
+
se quitan los cuerpos de heredoc (`<<'EOF' … EOF`, `<<EOF … EOF`) y los textos entre comillas con
|
|
358
|
+
espacios (una comilla con una sola palabra, como una ruta, se queda sin las comillas), y se prueba
|
|
359
|
+
tramo por tramo (`;`, `&&`, `||`, `|`): escribir un script que menciona `scripts/run.mjs` no activa
|
|
360
|
+
la batería, correrlo sí. Mientras corre uno que la cumple, el monitor está activo (`PreToolUse` →
|
|
361
|
+
`PostToolUse`/`PostToolUseFailure`), con la descripción del Bash como etiqueta o, sin ella, el
|
|
362
|
+
programa que corrió (`node run.mjs`): **nunca el comando ni una ruta entera** (toda ruta absoluta se
|
|
363
|
+
corta a su último tramo). Ese evento lleva `source: "hook"` y su id, y sólo cierra lo suyo: nunca
|
|
364
|
+
termina una corrida que un script abrió con `emit`. Un comando en segundo plano no cuenta, para eso
|
|
365
|
+
está `emit`. `one-at-a-time` también lo marca mientras tiene el candado,
|
|
366
|
+
pero sólo fuera de Claude Code (dentro, ya lo hace el hook de Bash).
|
|
367
|
+
- `open` (opcional): `{ "command": "<comando sin />" }` pone un botón «abrir ↗» en el detalle del
|
|
368
|
+
chip que corre ese comando (por ejemplo el de otro mod que abre su propio panel); si el comando no
|
|
369
|
+
existe en la sesión, o con `{ "pane": "<id>" }` (un mod no puede abrir el panel de otro), el
|
|
370
|
+
detalle dice qué escribir.
|
|
371
|
+
- Procesos largos fuera de una herramienta (una batería en segundo plano):
|
|
372
|
+
`node "$RING/scripts/live.mjs" emit --monitor bateria --state probando --label "t1 de 6" --progress 1/6 [--detail "…"] [--done|--failed] [--pr <n>] || true`.
|
|
373
|
+
Sin `--pr` busca el combate de esa carpeta. Con `RING_LIVE_FILE` en el entorno (`one-at-a-time`
|
|
374
|
+
se la pasa a su hijo) escribe directo ahí, y un script puede agregar él mismo la línea JSON
|
|
375
|
+
(`{"at":"<ISO>","monitor":"bateria","state":"active","label":"probando","progress":{"done":1,"total":6}}`)
|
|
376
|
+
sin depender de `ring`. Esquema: `actor` (uno del ring) o `monitor` (declarado), `state`
|
|
377
|
+
(`active`, `waiting`, `done`, `failed`), `label` (≤3 palabras) y, opcionales, `note`, `detail`,
|
|
378
|
+
`progress`, `id` (para cerrar justo ese trabajo), `count`, `severity`, `pr`, `url`, `fields`,
|
|
379
|
+
`health`, `reason` y `source`. Un monitor no declarado se rechaza (`emit` sale con 1) y el
|
|
380
|
+
Scorecard lo ignora. En la ficha, un valor de `fields` que es una ruta se ve como link a su último
|
|
381
|
+
tramo (`file://`; en Terminal.app, un botón que lo abre), nunca la ruta entera, y un valor largo se
|
|
382
|
+
recorta a un renglón con «…».
|
|
383
|
+
- **Salud** (cualquier monitor o actor, cualquier repo): cada evento puede decir cómo fue ese paso
|
|
384
|
+
con `health` (`ok`, `warn` o `fail`) y por qué con `reason` (corto, ≤80). Desde un script:
|
|
385
|
+
`emit … --health warn --reason "t1 sin medir"`; `--failed` es siempre `fail` y `--done` es `ok`
|
|
386
|
+
salvo que `--health` diga otra cosa. La salud de una ficha es **la peor de su corrida en curso**
|
|
387
|
+
(desde el evento que sigue al último `done`/`failed` de un script; ese cierre cuenta en ella):
|
|
388
|
+
`fail` gana a `warn` y `warn` a `ok`, así que un paso que falló o no se midió sigue avisando
|
|
389
|
+
mientras corren los siguientes, y la corrida nueva empieza limpia. Se ve en la barrita de la ficha
|
|
390
|
+
(verde, ámbar o rojo, con ✓ ⚠ ✗), en una línea bajo el verbo del detalle («⚠ va con avisos: t1 sin
|
|
391
|
+
medir», «✓ va bien», «✗ falla: t3 dobles 2»), en cada renglón de ÚLTIMOS, y —sólo `warn` y
|
|
392
|
+
`fail`— junto al tiempo del punto y en la banda «Revisión #N». Sin `health` en ningún paso, nada
|
|
393
|
+
cambia. Una batería de pruebas, por ejemplo:
|
|
394
|
+
|
|
395
|
+
```sh
|
|
396
|
+
emit() { node "$RING/scripts/live.mjs" emit --monitor bateria "$@" || true; }
|
|
397
|
+
emit --state preparando
|
|
398
|
+
emit --state probando --label "t1 de 6" --progress 1/6 --health warn --reason "t1 sin medir"
|
|
399
|
+
emit --state probando --label "t2 de 6" --progress 2/6 --health ok
|
|
400
|
+
emit --state probando --label "t3 de 6" --progress 3/6 --health fail --reason "t3 dobles 2"
|
|
401
|
+
emit --state terminó --done # la corrida queda en fail (la peor); la siguiente empieza limpia
|
|
402
|
+
```
|
|
403
|
+
|
|
241
404
|
**`mask-guard`** (hook `PreToolUse` sobre Bash) bloquea **siempre** `git add -A/./--all`,
|
|
242
405
|
`git stash pop`, `git reset --hard` con el árbol sucio y, si `forbidAiTrailers` está activo, los
|
|
243
406
|
commits con trailers de atribución de IA (los coautores humanos pasan). **Sólo mientras hay un
|
|
@@ -309,11 +472,11 @@ Requiere Claude Code CLI (`claude` en el PATH) y node ≥ 18. El instalador:
|
|
|
309
472
|
(`claude plugin marketplace add` + `claude plugin install --scope user`). Se lee directo de esa
|
|
310
473
|
carpeta: para actualizar basta volver a correr el instalador y `/reload-plugins`.
|
|
311
474
|
|
|
312
|
-
5. Con `--with radio` (o si ya
|
|
313
|
-
(Arena FM) en el Scorecard»). Correr `install` sin `--url`/`--api-key` reusa los de config.json.
|
|
475
|
+
5. Con `--with radio` y/o `--with theme` (o si ya los habías pedido), instala además la radio del
|
|
476
|
+
Scorecard y el tema de Ghostty (ver «La radio (Arena FM) en el Scorecard» y «El tema de Ghostty»). Correr `install` sin `--url`/`--api-key` reusa los de config.json.
|
|
314
477
|
|
|
315
478
|
Desde el clone (contribuidores): `HOOK_STREAM_URL=… HOOK_STREAM_API_KEY=… bash apps/claude-hooks/install.sh`
|
|
316
|
-
(acepta `--with radio` al final).
|
|
479
|
+
(acepta `--with radio` o `--with theme` al final).
|
|
317
480
|
Para probar el plugin sin instalarlo: `npm run bundle:skill` y `claude --plugin-dir apps/claude-hooks/plugin`.
|
|
318
481
|
|
|
319
482
|
## Configuración
|
package/cli.mjs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// npx @thebattlearena/battle-arena-hooks install \
|
|
7
7
|
// --url https://api.battlearena.dev --api-key sk_xxx
|
|
8
8
|
// npx @thebattlearena/battle-arena-hooks install --with radio (agrega la radio; reusa url y llave)
|
|
9
|
+
// npx @thebattlearena/battle-arena-hooks install --with theme (el tema Battle Arena de Ghostty)
|
|
9
10
|
// npx @thebattlearena/battle-arena-hooks uninstall
|
|
10
11
|
//
|
|
11
12
|
// (también lee HOOK_STREAM_URL / HOOK_STREAM_API_KEY del entorno)
|
|
@@ -23,13 +24,26 @@ import os from 'node:os';
|
|
|
23
24
|
import {
|
|
24
25
|
copyPlugin,
|
|
25
26
|
hasClaudeCli,
|
|
27
|
+
installConfig,
|
|
26
28
|
moveLegacySkills,
|
|
27
29
|
PLUGIN_ID,
|
|
30
|
+
readInstallConfig,
|
|
28
31
|
registerPlugin,
|
|
29
32
|
RING_PLUGIN_ID,
|
|
30
33
|
unregisterPlugin,
|
|
31
34
|
withoutLegacyHooks,
|
|
32
35
|
} from './lib/plugin-install.mjs';
|
|
36
|
+
import {
|
|
37
|
+
FONT_FAMILY,
|
|
38
|
+
installIconFont,
|
|
39
|
+
uninstallIconFont,
|
|
40
|
+
} from './lib/icon-font.mjs';
|
|
41
|
+
import {
|
|
42
|
+
installTheme,
|
|
43
|
+
LOOK_HINT,
|
|
44
|
+
THEME_NAME,
|
|
45
|
+
uninstallTheme,
|
|
46
|
+
} from './lib/ghostty-theme.mjs';
|
|
33
47
|
import {
|
|
34
48
|
installRadio,
|
|
35
49
|
mergeConfig,
|
|
@@ -93,6 +107,66 @@ function cleanLegacy() {
|
|
|
93
107
|
console.log(`🧹 skills sueltas movidas a ${backup}: ${moved.join(', ')}`);
|
|
94
108
|
}
|
|
95
109
|
|
|
110
|
+
/** Instala la fuente de íconos; un fallo no tumba la instalación (el Scorecard usa letras). */
|
|
111
|
+
function installFontSafely() {
|
|
112
|
+
try {
|
|
113
|
+
return installIconFont({ pkgDir: PKG_DIR, home: HOME });
|
|
114
|
+
} catch (error) {
|
|
115
|
+
return { font: null, ghostty: [], hint: null, error: error.message };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function reportFont({ font, ghostty, hint, error }) {
|
|
120
|
+
if (error)
|
|
121
|
+
console.log(
|
|
122
|
+
`⚠️ la fuente de íconos no se instaló (${error}); el Scorecard usa letras`,
|
|
123
|
+
);
|
|
124
|
+
if (!font) return;
|
|
125
|
+
console.log(`✅ fuente ${FONT_FAMILY} en ${font}`);
|
|
126
|
+
for (const { path, status } of ghostty)
|
|
127
|
+
console.log(
|
|
128
|
+
status === 'added'
|
|
129
|
+
? `✅ Ghostty: agregué el mapa de íconos a ${path}`
|
|
130
|
+
: ` Ghostty: ${path} ya tenía el mapa de íconos`,
|
|
131
|
+
);
|
|
132
|
+
if (hint)
|
|
133
|
+
console.log(
|
|
134
|
+
` Si usas Ghostty, agrega a su config (y recárgala):\n ${hint}`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** El tema de Ghostty: lo copia y lo elige en la config que ya exista. Si falla, lo demás sigue. */
|
|
139
|
+
function addTheme() {
|
|
140
|
+
try {
|
|
141
|
+
const { theme, file, ghostty, hint } = installTheme({
|
|
142
|
+
pkgDir: PKG_DIR,
|
|
143
|
+
home: HOME,
|
|
144
|
+
});
|
|
145
|
+
console.log(
|
|
146
|
+
file === 'copied'
|
|
147
|
+
? `✅ tema ${THEME_NAME} de Ghostty en ${theme}`
|
|
148
|
+
: ` Ghostty: ya tenías un tema «${THEME_NAME}» propio en ${theme}; no lo toqué`,
|
|
149
|
+
);
|
|
150
|
+
for (const { path, status } of ghostty)
|
|
151
|
+
console.log(
|
|
152
|
+
status === 'set'
|
|
153
|
+
? `✅ Ghostty: elegí el tema en ${path} (el anterior quedó anotado)`
|
|
154
|
+
: ` Ghostty: ${path} ya usaba el tema`,
|
|
155
|
+
);
|
|
156
|
+
if (hint)
|
|
157
|
+
console.log(
|
|
158
|
+
` Si usas Ghostty, agrega a su config (y recárgala):\n ${hint}`,
|
|
159
|
+
);
|
|
160
|
+
console.log(
|
|
161
|
+
` Para el look completo, agrega si quieres:\n ${LOOK_HINT.join('\n ')}`,
|
|
162
|
+
);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
console.error(
|
|
165
|
+
`⚠️ No pude instalar el tema (lo demás quedó bien): ${error.message}`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
96
170
|
/** La config que ya había (url, llave y extras pedidos), o null en una instalación nueva. */
|
|
97
171
|
function previousConfig() {
|
|
98
172
|
try {
|
|
@@ -123,12 +197,17 @@ function install() {
|
|
|
123
197
|
process.exit(1);
|
|
124
198
|
}
|
|
125
199
|
// Lo que no se pasa (url, llave) sale de la config anterior: `install --with radio` no la pide
|
|
126
|
-
// otra vez. Los extras se suman a los ya pedidos: reinstalar no quita la radio en silencio.
|
|
127
|
-
|
|
200
|
+
// otra vez. Los extras se suman a los ya pedidos: reinstalar no quita la radio en silencio. Las
|
|
201
|
+
// demás claves de la config (iconFont…) también se quedan.
|
|
202
|
+
const previous = previousConfig();
|
|
203
|
+
const passed = {
|
|
128
204
|
url: arg('url') || process.env.HOOK_STREAM_URL,
|
|
129
205
|
apiKey: arg('api-key') || process.env.HOOK_STREAM_API_KEY,
|
|
130
|
-
|
|
131
|
-
|
|
206
|
+
};
|
|
207
|
+
const config = {
|
|
208
|
+
...installConfig(previous, passed),
|
|
209
|
+
...mergeConfig(previous, { ...passed, extras }),
|
|
210
|
+
};
|
|
132
211
|
const { url, apiKey: key } = config;
|
|
133
212
|
|
|
134
213
|
if (!hasClaudeCli()) {
|
|
@@ -153,14 +232,19 @@ function install() {
|
|
|
153
232
|
// marketplace local, junto a los scripts
|
|
154
233
|
copyPlugin(PKG_DIR, HOOKS_DEST);
|
|
155
234
|
|
|
156
|
-
// 3)
|
|
235
|
+
// 3) La fuente de íconos del Scorecard. Si no se puede instalar, el Scorecard sigue con letras.
|
|
236
|
+
const font = installFontSafely();
|
|
237
|
+
|
|
238
|
+
// 4) Config (url + api-key) → ~/.claude/battle-arena/config.json. Los hooks y el Scorecard lo leen
|
|
157
239
|
// de ahí; así el comando es solo `node "<ruta>"`, idéntico en los 3 SOs.
|
|
240
|
+
// Lo que no se pasa se queda como estaba (reinstalar sin --api-key no borra la llave), e
|
|
241
|
+
// `iconFont` dice si el Scorecard puede dibujar los glifos.
|
|
158
242
|
writeFileSync(
|
|
159
243
|
join(BA_DIR, 'config.json'),
|
|
160
|
-
JSON.stringify(config, null, 2) + '\n',
|
|
244
|
+
JSON.stringify({ ...config, iconFont: !!font.font }, null, 2) + '\n',
|
|
161
245
|
);
|
|
162
246
|
|
|
163
|
-
//
|
|
247
|
+
// 5) Registrar e instalar los dos plugins (idempotente). Va ANTES de limpiar lo anterior: si falla,
|
|
164
248
|
// la instalación vieja sigue funcionando intacta.
|
|
165
249
|
try {
|
|
166
250
|
registerPlugin(HOOKS_DEST);
|
|
@@ -171,7 +255,7 @@ function install() {
|
|
|
171
255
|
process.exit(1);
|
|
172
256
|
}
|
|
173
257
|
|
|
174
|
-
//
|
|
258
|
+
// 6) Ya con el plugin activo, lo que dejó la versión anterior: hooks en settings.json y skills
|
|
175
259
|
// sueltas (no duplicar cada evento)
|
|
176
260
|
cleanLegacy();
|
|
177
261
|
|
|
@@ -182,9 +266,12 @@ function install() {
|
|
|
182
266
|
`✅ plugin ${RING_PLUGIN_ID} instalado (se lee de ${join(HOOKS_DEST, 'ring')})`,
|
|
183
267
|
);
|
|
184
268
|
console.log(` colector: ${url}${key ? '' : ' (sin api-key)'}`);
|
|
269
|
+
reportFont(font);
|
|
185
270
|
|
|
186
|
-
//
|
|
271
|
+
// 7) Lo opcional que se pidió (ahora o antes): la radio baja su propia dependencia; el tema elige
|
|
272
|
+
// los colores de Ghostty.
|
|
187
273
|
if (config.with?.includes('radio')) addRadio();
|
|
274
|
+
if (config.with?.includes('theme')) addTheme();
|
|
188
275
|
console.log(
|
|
189
276
|
'\nListo. Abre Claude Code: /battlearena:conquer arma tu plan y /scorecard abre tu día.' +
|
|
190
277
|
'\nSi ya tenías una sesión abierta, corre /reload-plugins.',
|
|
@@ -196,6 +283,23 @@ function uninstall() {
|
|
|
196
283
|
? unregisterPlugin()
|
|
197
284
|
: { plugin: false, ring: false, marketplace: false };
|
|
198
285
|
cleanLegacyHooks();
|
|
286
|
+
const font = uninstallIconFont({ home: HOME });
|
|
287
|
+
const configPath = join(BA_DIR, 'config.json');
|
|
288
|
+
const config = readInstallConfig(configPath);
|
|
289
|
+
if (config)
|
|
290
|
+
writeFileSync(
|
|
291
|
+
configPath,
|
|
292
|
+
JSON.stringify({ ...config, iconFont: false }, null, 2) + '\n',
|
|
293
|
+
);
|
|
294
|
+
if (font.font)
|
|
295
|
+
console.log(`✅ fuente ${FONT_FAMILY} quitada de ${font.font}`);
|
|
296
|
+
for (const path of font.ghostty)
|
|
297
|
+
console.log(`✅ Ghostty: quité el mapa de íconos de ${path}`);
|
|
298
|
+
const theme = uninstallTheme({ home: HOME });
|
|
299
|
+
if (theme.theme)
|
|
300
|
+
console.log(`✅ tema ${THEME_NAME} quitado de ${theme.theme}`);
|
|
301
|
+
for (const path of theme.ghostty)
|
|
302
|
+
console.log(`✅ Ghostty: regresé el tema anterior en ${path}`);
|
|
199
303
|
console.log(
|
|
200
304
|
result.plugin
|
|
201
305
|
? `✅ plugin ${PLUGIN_ID} desinstalado`
|
|
@@ -216,7 +320,7 @@ const command = process.argv[2];
|
|
|
216
320
|
const run = COMMANDS[command];
|
|
217
321
|
if (!run) {
|
|
218
322
|
console.log(
|
|
219
|
-
'Uso: npx @thebattlearena/battle-arena-hooks install [--url <colector>] [--api-key <key>] [--with radio]\n' +
|
|
323
|
+
'Uso: npx @thebattlearena/battle-arena-hooks install [--url <colector>] [--api-key <key>] [--with radio,theme]\n' +
|
|
220
324
|
' npx @thebattlearena/battle-arena-hooks uninstall',
|
|
221
325
|
);
|
|
222
326
|
process.exit(command ? 1 : 0);
|
|
Binary file
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Battle Arena Icons incluye geometría de Lucide (https://lucide.dev): los glifos cuyo «source» en
|
|
2
|
+
src/codepoints.json empieza con «lucide:». Los de «source: propio» son de Battle Arena.
|
|
3
|
+
|
|
4
|
+
ISC License
|
|
5
|
+
|
|
6
|
+
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All
|
|
7
|
+
other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without
|
|
10
|
+
fee is hereby granted, provided that the above copyright notice and this permission notice appear
|
|
11
|
+
in all copies.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
14
|
+
SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
|
15
|
+
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
16
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
17
|
+
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
18
|
+
THIS SOFTWARE.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
The MIT License (MIT) (for portions derived from Feather)
|
|
23
|
+
|
|
24
|
+
Copyright (c) 2013-2022 Cole Bemis
|
|
25
|
+
|
|
26
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
27
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
28
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
29
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
30
|
+
furnished to do so, subject to the following conditions:
|
|
31
|
+
|
|
32
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
33
|
+
substantial portions of the Software.
|
|
34
|
+
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
36
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
37
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
38
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
39
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// El tema «Battle Arena» de Ghostty (themes/ghostty/Battle Arena): navy, coral y azul del logo.
|
|
2
|
+
// `install --with theme` lo copia a la carpeta de temas del usuario y lo elige en la config de Ghostty
|
|
3
|
+
// que ya exista, guardando en un comentario el tema que había para que `uninstall` lo regrese. Nunca
|
|
4
|
+
// crea la config ni pisa un tema «Battle Arena» que no sea el nuestro. Zero-dependency.
|
|
5
|
+
import {
|
|
6
|
+
copyFileSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
rmSync,
|
|
11
|
+
writeFileSync,
|
|
12
|
+
} from 'node:fs';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
|
|
15
|
+
import { ghosttyConfigs } from './icon-font.mjs';
|
|
16
|
+
|
|
17
|
+
export const THEME_NAME = 'Battle Arena';
|
|
18
|
+
export const THEME_LINE = `theme = ${THEME_NAME}`;
|
|
19
|
+
/** La primera línea del archivo del tema: dice que es el nuestro y que se puede reemplazar o quitar. */
|
|
20
|
+
export const THEME_HEADER = '# battle-arena-hooks: tema Battle Arena';
|
|
21
|
+
const MARKER =
|
|
22
|
+
'# Battle Arena: tema de battle-arena-hooks install --with theme';
|
|
23
|
+
const BEFORE = '; antes: ';
|
|
24
|
+
/** Cualquier línea `theme = …` (Ghostty usa la última). */
|
|
25
|
+
const THEME_PATTERN = /^\s*theme\s*=.*$/;
|
|
26
|
+
const isOurs = (line) => /^\s*theme\s*=\s*Battle Arena\s*$/.test(line);
|
|
27
|
+
const hasTheme = (text) =>
|
|
28
|
+
text.split('\n').some((line) => THEME_PATTERN.test(line));
|
|
29
|
+
/** El tema que vale en una config: su último `theme =`, o `null`. */
|
|
30
|
+
const lastTheme = (text) =>
|
|
31
|
+
text.split('\n').findLast((line) => THEME_PATTERN.test(line)) ?? null;
|
|
32
|
+
|
|
33
|
+
/** Lo de la ventana que completa el look; se sugiere, no se escribe. */
|
|
34
|
+
export const LOOK_HINT = [
|
|
35
|
+
'font-family = JetBrains Mono',
|
|
36
|
+
'window-padding-x = 10',
|
|
37
|
+
'window-padding-y = 8',
|
|
38
|
+
'window-padding-color = extend',
|
|
39
|
+
'macos-icon = custom-style',
|
|
40
|
+
'macos-icon-frame = chrome',
|
|
41
|
+
'macos-icon-ghost-color = #F26464',
|
|
42
|
+
'macos-icon-screen-color = #061224,#0B1B33',
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
/** La carpeta de temas del usuario (Ghostty la lee en macOS y Linux). PURA. */
|
|
46
|
+
export function themesDir(home, env = {}) {
|
|
47
|
+
return join(
|
|
48
|
+
env.XDG_CONFIG_HOME || join(home, '.config'),
|
|
49
|
+
'ghostty',
|
|
50
|
+
'themes',
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* La config con nuestro tema: igual si ya es el que vale (el último `theme =`); si hay otro, el
|
|
56
|
+
* último se cambia por el nuestro y se anota tal cual en el comentario; si no hay ninguno, se agrega
|
|
57
|
+
* al final sólo con `append`. PURA.
|
|
58
|
+
*/
|
|
59
|
+
export function withTheme(text, append = false) {
|
|
60
|
+
const lines = text.split('\n');
|
|
61
|
+
const last = lines.findLastIndex((line) => THEME_PATTERN.test(line));
|
|
62
|
+
if (last !== -1 && isOurs(lines[last])) return text;
|
|
63
|
+
if (last !== -1) {
|
|
64
|
+
lines.splice(last, 1, `${MARKER}${BEFORE}${lines[last]}`, THEME_LINE);
|
|
65
|
+
return lines.join('\n');
|
|
66
|
+
}
|
|
67
|
+
if (!append) return text;
|
|
68
|
+
const base = text === '' || text.endsWith('\n') ? text : `${text}\n`;
|
|
69
|
+
return `${base}\n${MARKER}\n${THEME_LINE}\n`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** La config sin nuestro tema, con el que había antes de vuelta: deshace `withTheme`. PURA. */
|
|
73
|
+
export function withoutTheme(text) {
|
|
74
|
+
const lines = text.split('\n');
|
|
75
|
+
const at = lines.findIndex((line) => line.startsWith(MARKER));
|
|
76
|
+
if (at === -1 || !isOurs(lines[at + 1] ?? '')) return text;
|
|
77
|
+
const note = lines[at];
|
|
78
|
+
const before = note.indexOf(BEFORE);
|
|
79
|
+
if (before !== -1) {
|
|
80
|
+
lines.splice(at, 2, note.slice(before + BEFORE.length));
|
|
81
|
+
return lines.join('\n');
|
|
82
|
+
}
|
|
83
|
+
const blank = at > 0 && lines[at - 1] === '' ? 1 : 0;
|
|
84
|
+
lines.splice(at - blank, 2 + blank);
|
|
85
|
+
return lines.join('\n');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* La config que decide el tema: Ghostty las carga todas en orden y gana el último `theme =`, así que
|
|
90
|
+
* es la última que lo tiene; si ninguna lo tiene, la última que existe. PURA.
|
|
91
|
+
*/
|
|
92
|
+
export function effectiveConfig(configs) {
|
|
93
|
+
return (
|
|
94
|
+
configs.findLast(({ text }) => hasTheme(text)) ?? configs.at(-1) ?? null
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const isOurFile = (path) =>
|
|
99
|
+
readFileSync(path, 'utf8').startsWith(`${THEME_HEADER}\n`);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Copia el tema (salvo que ya haya otro «Battle Arena» que no es el nuestro) y lo elige sólo en la
|
|
103
|
+
* config que decide. Devuelve { theme: ruta, file: 'copied' | 'foreign', ghostty: [{ path, status:
|
|
104
|
+
* 'set' | 'present' }], hint: línea | null } (`hint` cuando no hay config de Ghostty).
|
|
105
|
+
*/
|
|
106
|
+
export function installTheme({
|
|
107
|
+
pkgDir,
|
|
108
|
+
platform = process.platform,
|
|
109
|
+
home,
|
|
110
|
+
env = process.env,
|
|
111
|
+
}) {
|
|
112
|
+
const dir = themesDir(home, env);
|
|
113
|
+
mkdirSync(dir, { recursive: true });
|
|
114
|
+
const theme = join(dir, THEME_NAME);
|
|
115
|
+
const foreign = existsSync(theme) && !isOurFile(theme);
|
|
116
|
+
if (!foreign)
|
|
117
|
+
copyFileSync(join(pkgDir, 'themes', 'ghostty', THEME_NAME), theme);
|
|
118
|
+
const configs = ghosttyConfigs(platform, home, env)
|
|
119
|
+
.filter((path) => existsSync(path))
|
|
120
|
+
.map((path) => ({ path, text: readFileSync(path, 'utf8') }));
|
|
121
|
+
const target = effectiveConfig(configs);
|
|
122
|
+
const ghostty = [target].filter(Boolean).map(({ path, text }) => {
|
|
123
|
+
const next = withTheme(text, true);
|
|
124
|
+
if (next === text) return { path, status: 'present' };
|
|
125
|
+
writeFileSync(path, next);
|
|
126
|
+
return { path, status: 'set' };
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
theme,
|
|
130
|
+
file: foreign ? 'foreign' : 'copied',
|
|
131
|
+
ghostty,
|
|
132
|
+
hint: configs.length ? null : THEME_LINE,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Regresa el tema que había en cada config y quita el archivo sólo si es el nuestro y ninguna config
|
|
138
|
+
* lo sigue eligiendo (p. ej. un `theme = Battle Arena` escrito a mano). Devuelve lo que tocó.
|
|
139
|
+
*/
|
|
140
|
+
export function uninstallTheme({
|
|
141
|
+
platform = process.platform,
|
|
142
|
+
home,
|
|
143
|
+
env = process.env,
|
|
144
|
+
}) {
|
|
145
|
+
const configs = ghosttyConfigs(platform, home, env).filter((path) =>
|
|
146
|
+
existsSync(path),
|
|
147
|
+
);
|
|
148
|
+
const ghostty = configs.filter((path) => {
|
|
149
|
+
const text = readFileSync(path, 'utf8');
|
|
150
|
+
const next = withoutTheme(text);
|
|
151
|
+
if (next === text) return false;
|
|
152
|
+
writeFileSync(path, next);
|
|
153
|
+
return true;
|
|
154
|
+
});
|
|
155
|
+
const theme = join(themesDir(home, env), THEME_NAME);
|
|
156
|
+
const stillUsed = configs.some((path) =>
|
|
157
|
+
isOurs(lastTheme(readFileSync(path, 'utf8')) ?? ''),
|
|
158
|
+
);
|
|
159
|
+
const removed = existsSync(theme) && isOurFile(theme) && !stillUsed;
|
|
160
|
+
if (removed) rmSync(theme);
|
|
161
|
+
return { theme: removed ? theme : null, ghostty };
|
|
162
|
+
}
|