@saulwade/swl-ses 2.6.0 → 2.6.1

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.
Files changed (207) hide show
  1. package/CLAUDE.md +197 -197
  2. package/README.md +600 -600
  3. package/agentes/_intent-spec.md +73 -73
  4. package/agentes/_propose-step.md +90 -90
  5. package/agentes/accesibilidad-wcag-swl.md +690 -690
  6. package/agentes/arquitecto-swl.md +267 -267
  7. package/agentes/auto-evolucion-swl.md +932 -932
  8. package/agentes/backend-csharp-swl.md +420 -420
  9. package/agentes/backend-go-swl.md +390 -390
  10. package/agentes/backend-java-swl.md +281 -281
  11. package/agentes/backend-rust-swl.md +364 -364
  12. package/agentes/backend-workers-swl.md +482 -482
  13. package/agentes/cloud-infra-swl.md +509 -509
  14. package/agentes/consolidador-swl.md +541 -541
  15. package/agentes/depurador-swl.md +352 -352
  16. package/agentes/devops-ci-swl.md +400 -400
  17. package/agentes/disenador-ui-swl.md +569 -569
  18. package/agentes/documentador-swl.md +345 -345
  19. package/agentes/frontend-angular-swl.md +621 -621
  20. package/agentes/frontend-css-swl.md +716 -716
  21. package/agentes/frontend-react-swl.md +692 -692
  22. package/agentes/frontend-swl.md +496 -496
  23. package/agentes/frontend-tailwind-swl.md +826 -826
  24. package/agentes/investigador-swl.md +432 -432
  25. package/agentes/investigador-ux-swl.md +505 -505
  26. package/agentes/migrador-swl.md +442 -442
  27. package/agentes/mobile-android-swl.md +511 -511
  28. package/agentes/mobile-cross-swl.md +541 -541
  29. package/agentes/mobile-ios-swl.md +502 -502
  30. package/agentes/mobile-testing-swl.md +302 -302
  31. package/agentes/nemesis-auditor-swl.md +285 -285
  32. package/agentes/observabilidad-swl.md +438 -438
  33. package/agentes/pagos-swl.md +310 -310
  34. package/agentes/perfilador-usuario-swl.md +321 -321
  35. package/agentes/planificador-swl.md +399 -399
  36. package/agentes/producto-prd-swl.md +589 -589
  37. package/agentes/red-team-swl.md +218 -218
  38. package/agentes/release-manager-swl.md +590 -590
  39. package/agentes/rendimiento-swl.md +713 -713
  40. package/agentes/revisor-angular-swl.md +278 -278
  41. package/agentes/revisor-csharp-swl.md +264 -264
  42. package/agentes/revisor-go-swl.md +259 -259
  43. package/agentes/revisor-java-swl.md +257 -257
  44. package/agentes/revisor-kotlin-swl.md +273 -273
  45. package/agentes/revisor-nextjs-swl.md +281 -281
  46. package/agentes/revisor-php-swl.md +271 -271
  47. package/agentes/revisor-react-swl.md +278 -278
  48. package/agentes/revisor-rust-swl.md +346 -346
  49. package/agentes/revisor-seguridad-swl.md +399 -399
  50. package/agentes/revisor-swift-swl.md +268 -268
  51. package/agentes/revisor-typescript-swl.md +346 -346
  52. package/agentes/tdd-qa-swl.md +393 -393
  53. package/comandos/swl/actualizar.md +174 -174
  54. package/comandos/swl/adoptar-proyecto.md +265 -265
  55. package/comandos/swl/aprender.md +836 -836
  56. package/comandos/swl/aprobar-plan.md +146 -146
  57. package/comandos/swl/auditar-deps.md +134 -134
  58. package/comandos/swl/autoresearch.md +264 -264
  59. package/comandos/swl/ayuda.md +224 -224
  60. package/comandos/swl/brainstorm.md +51 -51
  61. package/comandos/swl/briefing.md +119 -119
  62. package/comandos/swl/checkpoint.md +325 -325
  63. package/comandos/swl/claudemd.md +234 -234
  64. package/comandos/swl/compactar.md +310 -310
  65. package/comandos/swl/configurar-ci.md +235 -235
  66. package/comandos/swl/contexto.md +110 -110
  67. package/comandos/swl/contribuir.md +233 -233
  68. package/comandos/swl/crear-skill.md +292 -292
  69. package/comandos/swl/cron.md +194 -194
  70. package/comandos/swl/discutir-fase.md +169 -169
  71. package/comandos/swl/ejecutar-fase.md +233 -233
  72. package/comandos/swl/evaluar-skill.md +520 -520
  73. package/comandos/swl/evolucion-continua.md +73 -73
  74. package/comandos/swl/evolucionar.md +267 -267
  75. package/comandos/swl/exportar-vault.md +583 -583
  76. package/comandos/swl/fix.md +118 -118
  77. package/comandos/swl/gateway.md +158 -158
  78. package/comandos/swl/inbox.md +116 -116
  79. package/comandos/swl/instalar.md +220 -220
  80. package/comandos/swl/instintos.md +86 -86
  81. package/comandos/swl/mapear-codebase.md +312 -312
  82. package/comandos/swl/mcp-status.md +175 -175
  83. package/comandos/swl/modelo.md +100 -100
  84. package/comandos/swl/nemesis.md +433 -433
  85. package/comandos/swl/notificaciones.md +299 -299
  86. package/comandos/swl/nuevo-proyecto.md +251 -251
  87. package/comandos/swl/planear-fase.md +263 -263
  88. package/comandos/swl/plugins.md +256 -256
  89. package/comandos/swl/predecir.md +169 -169
  90. package/comandos/swl/reflect-skills.md +125 -125
  91. package/comandos/swl/release.md +450 -450
  92. package/comandos/swl/revisar-impacto.md +201 -201
  93. package/comandos/swl/revisar.md +330 -330
  94. package/comandos/swl/seguridad.md +189 -189
  95. package/comandos/swl/sesiones.md +200 -200
  96. package/comandos/swl/skill-search.md +113 -113
  97. package/comandos/swl/status.md +345 -345
  98. package/comandos/swl/verificar.md +817 -817
  99. package/comandos/swl/wiki.md +620 -620
  100. package/gateway/cron/jobs.example.json +12 -12
  101. package/habilidades/auto-evolucion-protocolo/SKILL.md +294 -294
  102. package/habilidades/backend-async-postgres-testing/SKILL.md +2 -1
  103. package/habilidades/changelog-generator/SKILL.md +174 -174
  104. package/habilidades/compactacion-contexto/SKILL.md +2 -1
  105. package/habilidades/contenedores-docker/SKILL.md +4 -2
  106. package/habilidades/doubt-driven-review/SKILL.md +207 -207
  107. package/habilidades/drift-detection/SKILL.md +1 -1
  108. package/habilidades/ejecutar-task-iterativo/SKILL.md +278 -278
  109. package/habilidades/extractor-de-aprendizajes/SKILL.md +8 -2
  110. package/habilidades/git-worktrees-paralelo/SKILL.md +19 -1
  111. package/habilidades/harness-claude-code/SKILL.md +314 -314
  112. package/habilidades/instalar-sistema/SKILL.md +227 -227
  113. package/habilidades/planear-fase/SKILL.md +358 -358
  114. package/habilidades/prevencion-sobreingenieria/recursos/soluciones-nativas.md +166 -166
  115. package/habilidades/prevencion-sobreingenieria/recursos/variables-residuales-post-refactor.md +85 -85
  116. package/habilidades/proceso-ingenieria-requerimientos/SKILL.md +147 -147
  117. package/habilidades/release-semver/SKILL.md +2 -2
  118. package/habilidades/tdd-workflow/SKILL.md +749 -749
  119. package/hooks/agente-lifecycle.js +1 -1
  120. package/hooks/audit-trail.js +1 -1
  121. package/hooks/auto-consolidacion.js +1 -1
  122. package/hooks/captura-acciones-post.js +1 -1
  123. package/hooks/captura-acciones-session.js +1 -1
  124. package/hooks/captura-feedback-usuario.js +1 -1
  125. package/hooks/contexto-iteracion.js +1 -1
  126. package/hooks/contexto-subagente.js +68 -68
  127. package/hooks/degradacion-instintos.js +1 -1
  128. package/hooks/grafo-contexto.js +1 -1
  129. package/hooks/guardrail-modelo.js +1 -1
  130. package/hooks/inbox-aviso.js +1 -1
  131. package/hooks/inyeccion-contexto.js +1 -1
  132. package/hooks/lib/agent-matcher.js +1 -1
  133. package/hooks/lib/agent-routing.js +1 -1
  134. package/hooks/lib/captura-acciones.js +1 -1
  135. package/hooks/lib/etapa-metricas.js +1 -1
  136. package/hooks/lib/evolution-tracker.js +1 -1
  137. package/hooks/lib/gateway-notify.js +193 -193
  138. package/hooks/lib/mcp-health.js +1 -1
  139. package/hooks/lib/notificacion-formato.js +58 -0
  140. package/hooks/lib/nudge-tracker.js +1 -1
  141. package/hooks/lib/otlp-exporter.js +1 -1
  142. package/hooks/lib/propose-step.js +1 -1
  143. package/hooks/lib/raiz-proyecto.js +127 -102
  144. package/hooks/lib/run-log.js +1 -1
  145. package/hooks/lib/singleton-guard.js +20 -13
  146. package/hooks/lib/telegram-cliente.js +11 -3
  147. package/hooks/notificacion-telegram.js +13 -3
  148. package/hooks/preservar-estado-pre-compact.js +1 -1
  149. package/hooks/registro-turnos.js +1 -1
  150. package/hooks/resumen-sesion.js +1 -1
  151. package/hooks/risk-scoring.js +1 -1
  152. package/hooks/session-briefing.js +1 -1
  153. package/hooks/spec-gate.js +1 -1
  154. package/hooks/sugerir-regenerar-inventario.js +1 -1
  155. package/hooks/tdd-gate.js +1 -1
  156. package/hooks/telemetria-agentes.js +1 -1
  157. package/hooks/telemetria-skill-routing.js +1 -1
  158. package/hooks/tracking-costos.js +1 -1
  159. package/hooks/validar-formato-post-subagente.js +1 -1
  160. package/hooks/validar-intent-spec.js +1 -1
  161. package/hooks/validar-planning-paths.js +1 -1
  162. package/llms.txt +29 -29
  163. package/manifiestos/canonical-hashes.json +5588 -5257
  164. package/manifiestos/hooks-config.json +469 -469
  165. package/manifiestos/invariantes-criticos.json +30 -30
  166. package/manifiestos/modulos.json +1429 -1428
  167. package/manifiestos/skills-lock.json +1275 -1275
  168. package/package.json +94 -94
  169. package/plugin.json +369 -369
  170. package/scripts/auditar-clases-conocidas.js +134 -134
  171. package/scripts/bootstrap-instintos.js +85 -14
  172. package/scripts/canario-hooks.js +166 -166
  173. package/scripts/cli/autonomia.js +23 -23
  174. package/scripts/cli/benchmark-memoria.js +37 -37
  175. package/scripts/cli/ciclo-autonomo.js +73 -73
  176. package/scripts/cli/ciclo-fase-b.js +102 -102
  177. package/scripts/cli/guardrail-metrics.js +39 -39
  178. package/scripts/cli/memoria-search.js +69 -69
  179. package/scripts/cli/nudge-accionar.js +39 -39
  180. package/scripts/cli/run-eval.js +38 -38
  181. package/scripts/doctor.js +26 -3
  182. package/scripts/evidencia-valor.js +101 -101
  183. package/scripts/field-report.js +16 -16
  184. package/scripts/instalador.js +13 -0
  185. package/scripts/lib/activar-hooks-proyecto.js +116 -116
  186. package/scripts/lib/ciclo-autonomo/candidatos.js +174 -174
  187. package/scripts/lib/ciclo-autonomo/config.js +165 -165
  188. package/scripts/lib/ciclo-autonomo/drenador-feedback.js +174 -174
  189. package/scripts/lib/ciclo-autonomo/fallback.js +77 -77
  190. package/scripts/lib/ciclo-autonomo/guard-convivencia.js +139 -139
  191. package/scripts/lib/ciclo-autonomo/higiene-nudges.js +112 -112
  192. package/scripts/lib/ciclo-autonomo/index.js +301 -301
  193. package/scripts/lib/ciclo-autonomo/lock.js +124 -124
  194. package/scripts/lib/ciclo-autonomo/presupuesto.js +122 -122
  195. package/scripts/lib/ciclo-autonomo/puente-degradacion.js +240 -240
  196. package/scripts/lib/ciclo-autonomo/runner-fase-b.js +248 -248
  197. package/scripts/lib/ciclo-autonomo/writer-instintos.js +190 -190
  198. package/scripts/lib/ciclo-autonomo/yaml-instintos.js +535 -535
  199. package/scripts/lib/evidencia-valor.js +228 -228
  200. package/scripts/lib/expandir-targets.js +71 -71
  201. package/scripts/lib/limpiar-basura-global.js +161 -0
  202. package/scripts/lib/toml-merge.js +204 -204
  203. package/scripts/mcp-server/auth.js +105 -105
  204. package/scripts/mcp-server/cache.js +106 -106
  205. package/scripts/tui/pantallas/install-wizard.js +403 -403
  206. package/instintos/.backups/perfil-usuario.yaml.2026-07-10-165128.bak +0 -53
  207. package/instintos/.backups/proyecto.yaml.2026-07-10-165128.bak +0 -372
@@ -1,299 +1,299 @@
1
- ---
2
- name: swl:notificaciones
3
- description: Gestiona el sistema de notificaciones Telegram de swl-ses (opt-in). Subcomandos: init (flujo interactivo de configuración), status (estado actual sin mostrar credenciales), disable (quitar hooks SWL de settings global), bot start|stop|status|restart|enable-autostart|disable-autostart (daemon bidireccional con autostart por OS — Windows Scheduled Task, Linux systemd --user, macOS LaunchAgent).
4
- allowed_tools: ["Read", "Bash"]
5
- ---
6
-
7
- # /swl:notificaciones — Gestión de notificaciones Telegram
8
-
9
- Gestiona el hook saliente y el daemon bidireccional de Telegram que swl-ses
10
- instala como feature opt-in. Toda la lógica de credenciales, settings y
11
- baseline la delega a `scripts/lib/notificaciones-telegram.js` — este
12
- comando solo orquesta.
13
-
14
- **Seguridad**: el comando NUNCA muestra el token. Solo muestra metadata
15
- (longitud, primeros 3 caracteres, últimos 4 dígitos del chat_id). Las
16
- credenciales viven en `~/.claude/notifications/.env`, fuera del repositorio.
17
-
18
- ## Cuándo NO invocarme
19
-
20
- - Para configurar el gateway bidireccional completo (`/swl:gateway`): ese
21
- componente gestiona adaptadores Telegram, Discord, Slack y Webhook con
22
- `node-telegram-bot-api`. Este comando es para el hook saliente zero-deps.
23
- - Para enviar mensajes a Telegram desde código: usar `hooks/lib/telegram-cliente.js`
24
- directamente.
25
- - Para revisar el estado del gateway: `/swl:gateway status`.
26
- - Para ejecutar el bot daemon: usar los subcomandos `bot start|stop|status|restart`
27
- o `bot enable-autostart|disable-autostart`. El binario está en `bin/swl-telegram-bot.js`.
28
-
29
- ## Subcomandos
30
-
31
- ### `/swl:notificaciones init`
32
-
33
- Lanza el flujo interactivo de configuración. Equivalente al paso 9 del
34
- instalador — útil cuando el usuario saltó el opt-in durante la instalación
35
- o quiere reconfigurar.
36
-
37
- **Flujo**:
38
- 1. Verifica la feature flag `SWL_NOTIFICACIONES_TELEGRAM`. Si vale `0`, sale sin tocar nada.
39
- 2. Si ya existe `~/.claude/notifications/.env`, pregunta si reutilizar o sobreescribir.
40
- 3. Muestra instrucciones para obtener token (BotFather) y chat_id (`/quien`).
41
- 4. Solicita `TELEGRAM_BOT_TOKEN` y `TELEGRAM_CHAT_ID`.
42
- 5. Escribe `.env` con permisos 600 en POSIX.
43
- 6. Genera `baseline-hooks.json` para auto-restauración de settings.
44
- 7. Hace merge de los hooks SWL en `~/.claude/settings.json` global (backup previo).
45
-
46
- **Ejemplo**:
47
- ```
48
- /swl:notificaciones init
49
- ```
50
-
51
- **Modo headless** (sin TTY):
52
- ```bash
53
- # Usar el instalador directamente con flag
54
- npx -y @saulwade/swl-ses@latest install --with-notificaciones=<TOKEN>,<CHAT_ID>
55
- ```
56
-
57
- **Criterio de éxito**: al terminar, el hook `notificacion-telegram.js` está
58
- registrado en `~/.claude/settings.json` y se envía una notificación de prueba.
59
-
60
- ### `/swl:notificaciones status`
61
-
62
- Muestra el estado actual sin revelar credenciales.
63
-
64
- **Salida esperada**:
65
- ```
66
- Notificaciones Telegram — estado actual
67
- .env: existe
68
- token: configurado (abc*** — longitud: 46)
69
- chat_id: configurado (...4521)
70
- proyectos mudos: ninguno
71
- bot daemon: detenido (usa `/swl:notificaciones bot start`)
72
- autostart: no configurado (usa `bot enable-autostart`)
73
- ```
74
-
75
- El token nunca aparece completo. El chat_id muestra solo los últimos 4 dígitos.
76
-
77
- **Ejemplo**:
78
- ```
79
- /swl:notificaciones status
80
- ```
81
-
82
- ### `/swl:notificaciones disable`
83
-
84
- Quita los hooks SWL de `~/.claude/settings.json`. Pide confirmación antes
85
- de actuar. Por defecto conserva `.env` (no borra credenciales sin pedirlo).
86
-
87
- **Opciones**:
88
- - Sin flags: quita hooks de settings, conserva `.env` y `baseline-hooks.json`.
89
- - Con `--purge`: quita hooks Y elimina `.env` y `baseline-hooks.json`. Pide
90
- confirmación adicional antes de borrar credenciales.
91
-
92
- **Flujo con confirmación**:
93
- ```
94
- ¿Confirmas deshabilitar las notificaciones Telegram? [s/N]
95
- s
96
- [notificaciones] 4 hook(s) SWL eliminados de settings.json (2 preservados).
97
- [notificaciones] .env conservado. Para eliminarlo usa: /swl:notificaciones disable --purge
98
- ```
99
-
100
- **Criterio de éxito**: `~/.claude/settings.json` ya no contiene referencias
101
- a `notificacion-telegram.js` ni `auto-restaurar-settings.js`.
102
-
103
- **Ejemplo**:
104
- ```
105
- /swl:notificaciones disable
106
- /swl:notificaciones disable --purge
107
- ```
108
-
109
- ### `/swl:notificaciones bot start|stop|status|restart`
110
-
111
- Gestiona el ciclo de vida del daemon bidireccional `bin/swl-telegram-bot.js`.
112
-
113
- El daemon se inicia en background (desacoplado del proceso padre) con stdout/stderr
114
- redirigidos a `~/.claude/notifications/bot.stdout.log` y `bot.stderr.log`.
115
- El PID se almacena en `~/.claude/notifications/bot.pid` para gestión posterior.
116
-
117
- **Ejemplos**:
118
- ```
119
- /swl:notificaciones bot start
120
- /swl:notificaciones bot stop
121
- /swl:notificaciones bot status
122
- /swl:notificaciones bot restart
123
- ```
124
-
125
- ### `/swl:notificaciones repair`
126
-
127
- Repara una instalación rota de notificaciones copiando los hook files al directorio
128
- `~/.claude/hooks/` y migrando entradas con ruta relativa en `~/.claude/settings.json`
129
- a ruta absoluta.
130
-
131
- Úsalo cuando el hook de Stop genera el error:
132
- ```
133
- Cannot find module 'D:\...\hooks\notificacion-telegram.js'
134
- ```
135
- o cuando `settings.json` contiene `node hooks/notificacion-telegram.js` en lugar
136
- de la ruta absoluta correcta.
137
-
138
- **Ejemplo**:
139
- ```
140
- /swl:notificaciones repair
141
- ```
142
-
143
- ### `/swl:notificaciones bot enable-autostart|disable-autostart`
144
-
145
- Configura el inicio automático del daemon al arrancar la sesión del usuario.
146
- Delega al generador correspondiente según el OS:
147
-
148
- - **Windows**: Scheduled Task (Programador de tareas) con RunLevel Limited (sin elevación)
149
- - **Linux**: unit systemd `--user` con `WantedBy=default.target` (sin root)
150
- - **macOS**: LaunchAgent en `~/Library/LaunchAgents/` (sin root, sin LaunchDaemons)
151
-
152
- El autostart se configura por usuario — nunca requiere sudo ni privilegios de sistema.
153
-
154
- **Rollback manual si algo sale mal**:
155
- - Windows: `schtasks /delete /tn "SWL-Telegram-Bot" /f`
156
- - Linux: `systemctl --user disable --now swl-telegram-bot && rm ~/.config/systemd/user/swl-telegram-bot.service`
157
- - macOS: `launchctl unload -w ~/Library/LaunchAgents/com.swl.telegram-bot.plist && rm ~/Library/LaunchAgents/com.swl.telegram-bot.plist`
158
-
159
- **Ejemplos**:
160
- ```
161
- /swl:notificaciones bot enable-autostart
162
- /swl:notificaciones bot disable-autostart
163
- ```
164
-
165
- ## Instrucciones de ejecución
166
-
167
- Al recibir `/swl:notificaciones [subcomando]`:
168
-
169
- ### Paso 1 — Identificar subcomando
170
-
171
- Parsear el primer argumento: `init`, `status`, `disable`, `repair`, `bot`.
172
-
173
- Si no hay argumento o el argumento no es reconocido, mostrar la ayuda:
174
-
175
- ```
176
- Uso: /swl:notificaciones <subcomando>
177
-
178
- Subcomandos disponibles:
179
- init Configurar notificaciones Telegram
180
- status Ver estado actual (sin mostrar credenciales)
181
- disable [--purge] Deshabilitar (conserva .env por defecto)
182
- repair Reparar hooks rotos (ruta relativa → absoluta)
183
- bot start Iniciar daemon bidireccional
184
- bot stop Detener daemon
185
- bot status Estado del daemon
186
- bot restart Reiniciar daemon
187
- bot enable-autostart Configurar inicio automático del bot
188
- bot disable-autostart Quitar inicio automático del bot
189
-
190
- ```
191
-
192
- ### Paso 2 — Ejecutar según subcomando
193
-
194
- Todos los subcomandos usan el CLI cross-scope (resuelve repo madre / `swl-ses`
195
- en PATH / `npx`; ver `docs/invocacion-cli-cross-scope.md`). El subcomando
196
- encapsula el formato de salida y la detección de TTY.
197
-
198
- **Para `init`** (requiere TTY; el subcomando detecta su ausencia y guía):
199
-
200
- ```bash
201
- swl-ses notificaciones init
202
- # fallback: npx -y @saulwade/swl-ses@latest notificaciones init
203
- ```
204
-
205
- **Para `status`**:
206
-
207
- ```bash
208
- swl-ses notificaciones status
209
- ```
210
-
211
- **Para `disable`**:
212
-
213
- Antes de invocar la lib, pedir confirmación al usuario:
214
-
215
- ```
216
- ¿Confirmas deshabilitar las notificaciones Telegram? [s/N]
217
- ```
218
-
219
- Si responde `n` o vacío: cancelar sin tocar nada.
220
-
221
- Si responde `s` (agregar `--purge` para eliminar también las credenciales, tras
222
- confirmación adicional del usuario):
223
-
224
- ```bash
225
- swl-ses notificaciones disable # conserva ~/.claude/notifications/.env
226
- swl-ses notificaciones disable --purge # elimina también las credenciales
227
- ```
228
-
229
- **Para `repair`**:
230
-
231
- ```bash
232
- swl-ses notificaciones repair
233
- ```
234
-
235
- **Para `bot start`**:
236
-
237
- ```bash
238
- swl-ses notificaciones bot-start
239
- ```
240
-
241
- **Para `bot stop`**:
242
-
243
- ```bash
244
- swl-ses notificaciones bot-stop
245
- ```
246
-
247
- **Para `bot status`**:
248
-
249
- ```bash
250
- swl-ses notificaciones bot-status
251
- ```
252
-
253
- **Para `bot restart`**:
254
-
255
- ```bash
256
- swl-ses notificaciones bot-restart
257
- ```
258
-
259
- **Para `bot enable-autostart`**:
260
-
261
- ```bash
262
- swl-ses notificaciones bot-enable-autostart
263
- ```
264
-
265
- **Para `bot disable-autostart`**:
266
-
267
- ```bash
268
- swl-ses notificaciones bot-disable-autostart
269
- ```
270
-
271
- ### Paso 3 — Reportar resultado
272
-
273
- Mostrar el resultado al usuario con el estado final. Si el subcomando fue
274
- `init` exitoso, recordar que el hook estará activo en la próxima sesión de
275
- Claude Code.
276
-
277
- ## Seguridad
278
-
279
- - NUNCA mostrar el valor de `TELEGRAM_BOT_TOKEN` en ningún output.
280
- - NUNCA sugerir comandos como `cat ~/.claude/notifications/.env`.
281
- - Los ejemplos de este comando usan placeholders `<TOKEN>` y `<CHAT_ID>`,
282
- nunca valores reales.
283
- - Al mostrar el chat_id, siempre usar solo los últimos 4 dígitos.
284
- - Si detectas que algún output podría exponer credenciales, truncar o
285
- enmascarar antes de mostrar.
286
-
287
- ## Variables de entorno relevantes
288
-
289
- | Variable | Efecto |
290
- |----------|--------|
291
- | `SWL_NOTIFICACIONES_TELEGRAM=0` | Desactiva los hooks sin tocar settings. El comando `init` respeta esta variable. |
292
-
293
- ## Referencias
294
-
295
- - Credenciales: `~/.claude/notifications/.env` (fuera del repo, permisos 600)
296
- - Lib de flujo: `scripts/lib/notificaciones-telegram.js`
297
- - Hook saliente: `hooks/notificacion-telegram.js`
298
- - Hook de restauración: `hooks/auto-restaurar-settings.js`
299
- - ADR-0009: excepción a la regla "SWL solo registra hooks a nivel proyecto"
1
+ ---
2
+ name: swl:notificaciones
3
+ description: Gestiona el sistema de notificaciones Telegram de swl-ses (opt-in). Subcomandos: init (flujo interactivo de configuración), status (estado actual sin mostrar credenciales), disable (quitar hooks SWL de settings global), bot start|stop|status|restart|enable-autostart|disable-autostart (daemon bidireccional con autostart por OS — Windows Scheduled Task, Linux systemd --user, macOS LaunchAgent).
4
+ allowed_tools: ["Read", "Bash"]
5
+ ---
6
+
7
+ # /swl:notificaciones — Gestión de notificaciones Telegram
8
+
9
+ Gestiona el hook saliente y el daemon bidireccional de Telegram que swl-ses
10
+ instala como feature opt-in. Toda la lógica de credenciales, settings y
11
+ baseline la delega a `scripts/lib/notificaciones-telegram.js` — este
12
+ comando solo orquesta.
13
+
14
+ **Seguridad**: el comando NUNCA muestra el token. Solo muestra metadata
15
+ (longitud, primeros 3 caracteres, últimos 4 dígitos del chat_id). Las
16
+ credenciales viven en `~/.claude/notifications/.env`, fuera del repositorio.
17
+
18
+ ## Cuándo NO invocarme
19
+
20
+ - Para configurar el gateway bidireccional completo (`/swl:gateway`): ese
21
+ componente gestiona adaptadores Telegram, Discord, Slack y Webhook con
22
+ `node-telegram-bot-api`. Este comando es para el hook saliente zero-deps.
23
+ - Para enviar mensajes a Telegram desde código: usar `hooks/lib/telegram-cliente.js`
24
+ directamente.
25
+ - Para revisar el estado del gateway: `/swl:gateway status`.
26
+ - Para ejecutar el bot daemon: usar los subcomandos `bot start|stop|status|restart`
27
+ o `bot enable-autostart|disable-autostart`. El binario está en `bin/swl-telegram-bot.js`.
28
+
29
+ ## Subcomandos
30
+
31
+ ### `/swl:notificaciones init`
32
+
33
+ Lanza el flujo interactivo de configuración. Equivalente al paso 9 del
34
+ instalador — útil cuando el usuario saltó el opt-in durante la instalación
35
+ o quiere reconfigurar.
36
+
37
+ **Flujo**:
38
+ 1. Verifica la feature flag `SWL_NOTIFICACIONES_TELEGRAM`. Si vale `0`, sale sin tocar nada.
39
+ 2. Si ya existe `~/.claude/notifications/.env`, pregunta si reutilizar o sobreescribir.
40
+ 3. Muestra instrucciones para obtener token (BotFather) y chat_id (`/quien`).
41
+ 4. Solicita `TELEGRAM_BOT_TOKEN` y `TELEGRAM_CHAT_ID`.
42
+ 5. Escribe `.env` con permisos 600 en POSIX.
43
+ 6. Genera `baseline-hooks.json` para auto-restauración de settings.
44
+ 7. Hace merge de los hooks SWL en `~/.claude/settings.json` global (backup previo).
45
+
46
+ **Ejemplo**:
47
+ ```
48
+ /swl:notificaciones init
49
+ ```
50
+
51
+ **Modo headless** (sin TTY):
52
+ ```bash
53
+ # Usar el instalador directamente con flag
54
+ npx -y @saulwade/swl-ses@latest install --with-notificaciones=<TOKEN>,<CHAT_ID>
55
+ ```
56
+
57
+ **Criterio de éxito**: al terminar, el hook `notificacion-telegram.js` está
58
+ registrado en `~/.claude/settings.json` y se envía una notificación de prueba.
59
+
60
+ ### `/swl:notificaciones status`
61
+
62
+ Muestra el estado actual sin revelar credenciales.
63
+
64
+ **Salida esperada**:
65
+ ```
66
+ Notificaciones Telegram — estado actual
67
+ .env: existe
68
+ token: configurado (abc*** — longitud: 46)
69
+ chat_id: configurado (...4521)
70
+ proyectos mudos: ninguno
71
+ bot daemon: detenido (usa `/swl:notificaciones bot start`)
72
+ autostart: no configurado (usa `bot enable-autostart`)
73
+ ```
74
+
75
+ El token nunca aparece completo. El chat_id muestra solo los últimos 4 dígitos.
76
+
77
+ **Ejemplo**:
78
+ ```
79
+ /swl:notificaciones status
80
+ ```
81
+
82
+ ### `/swl:notificaciones disable`
83
+
84
+ Quita los hooks SWL de `~/.claude/settings.json`. Pide confirmación antes
85
+ de actuar. Por defecto conserva `.env` (no borra credenciales sin pedirlo).
86
+
87
+ **Opciones**:
88
+ - Sin flags: quita hooks de settings, conserva `.env` y `baseline-hooks.json`.
89
+ - Con `--purge`: quita hooks Y elimina `.env` y `baseline-hooks.json`. Pide
90
+ confirmación adicional antes de borrar credenciales.
91
+
92
+ **Flujo con confirmación**:
93
+ ```
94
+ ¿Confirmas deshabilitar las notificaciones Telegram? [s/N]
95
+ s
96
+ [notificaciones] 4 hook(s) SWL eliminados de settings.json (2 preservados).
97
+ [notificaciones] .env conservado. Para eliminarlo usa: /swl:notificaciones disable --purge
98
+ ```
99
+
100
+ **Criterio de éxito**: `~/.claude/settings.json` ya no contiene referencias
101
+ a `notificacion-telegram.js` ni `auto-restaurar-settings.js`.
102
+
103
+ **Ejemplo**:
104
+ ```
105
+ /swl:notificaciones disable
106
+ /swl:notificaciones disable --purge
107
+ ```
108
+
109
+ ### `/swl:notificaciones bot start|stop|status|restart`
110
+
111
+ Gestiona el ciclo de vida del daemon bidireccional `bin/swl-telegram-bot.js`.
112
+
113
+ El daemon se inicia en background (desacoplado del proceso padre) con stdout/stderr
114
+ redirigidos a `~/.claude/notifications/bot.stdout.log` y `bot.stderr.log`.
115
+ El PID se almacena en `~/.claude/notifications/bot.pid` para gestión posterior.
116
+
117
+ **Ejemplos**:
118
+ ```
119
+ /swl:notificaciones bot start
120
+ /swl:notificaciones bot stop
121
+ /swl:notificaciones bot status
122
+ /swl:notificaciones bot restart
123
+ ```
124
+
125
+ ### `/swl:notificaciones repair`
126
+
127
+ Repara una instalación rota de notificaciones copiando los hook files al directorio
128
+ `~/.claude/hooks/` y migrando entradas con ruta relativa en `~/.claude/settings.json`
129
+ a ruta absoluta.
130
+
131
+ Úsalo cuando el hook de Stop genera el error:
132
+ ```
133
+ Cannot find module 'D:\...\hooks\notificacion-telegram.js'
134
+ ```
135
+ o cuando `settings.json` contiene `node hooks/notificacion-telegram.js` en lugar
136
+ de la ruta absoluta correcta.
137
+
138
+ **Ejemplo**:
139
+ ```
140
+ /swl:notificaciones repair
141
+ ```
142
+
143
+ ### `/swl:notificaciones bot enable-autostart|disable-autostart`
144
+
145
+ Configura el inicio automático del daemon al arrancar la sesión del usuario.
146
+ Delega al generador correspondiente según el OS:
147
+
148
+ - **Windows**: Scheduled Task (Programador de tareas) con RunLevel Limited (sin elevación)
149
+ - **Linux**: unit systemd `--user` con `WantedBy=default.target` (sin root)
150
+ - **macOS**: LaunchAgent en `~/Library/LaunchAgents/` (sin root, sin LaunchDaemons)
151
+
152
+ El autostart se configura por usuario — nunca requiere sudo ni privilegios de sistema.
153
+
154
+ **Rollback manual si algo sale mal**:
155
+ - Windows: `schtasks /delete /tn "SWL-Telegram-Bot" /f`
156
+ - Linux: `systemctl --user disable --now swl-telegram-bot && rm ~/.config/systemd/user/swl-telegram-bot.service`
157
+ - macOS: `launchctl unload -w ~/Library/LaunchAgents/com.swl.telegram-bot.plist && rm ~/Library/LaunchAgents/com.swl.telegram-bot.plist`
158
+
159
+ **Ejemplos**:
160
+ ```
161
+ /swl:notificaciones bot enable-autostart
162
+ /swl:notificaciones bot disable-autostart
163
+ ```
164
+
165
+ ## Instrucciones de ejecución
166
+
167
+ Al recibir `/swl:notificaciones [subcomando]`:
168
+
169
+ ### Paso 1 — Identificar subcomando
170
+
171
+ Parsear el primer argumento: `init`, `status`, `disable`, `repair`, `bot`.
172
+
173
+ Si no hay argumento o el argumento no es reconocido, mostrar la ayuda:
174
+
175
+ ```
176
+ Uso: /swl:notificaciones <subcomando>
177
+
178
+ Subcomandos disponibles:
179
+ init Configurar notificaciones Telegram
180
+ status Ver estado actual (sin mostrar credenciales)
181
+ disable [--purge] Deshabilitar (conserva .env por defecto)
182
+ repair Reparar hooks rotos (ruta relativa → absoluta)
183
+ bot start Iniciar daemon bidireccional
184
+ bot stop Detener daemon
185
+ bot status Estado del daemon
186
+ bot restart Reiniciar daemon
187
+ bot enable-autostart Configurar inicio automático del bot
188
+ bot disable-autostart Quitar inicio automático del bot
189
+
190
+ ```
191
+
192
+ ### Paso 2 — Ejecutar según subcomando
193
+
194
+ Todos los subcomandos usan el CLI cross-scope (resuelve repo madre / `swl-ses`
195
+ en PATH / `npx`; ver `docs/invocacion-cli-cross-scope.md`). El subcomando
196
+ encapsula el formato de salida y la detección de TTY.
197
+
198
+ **Para `init`** (requiere TTY; el subcomando detecta su ausencia y guía):
199
+
200
+ ```bash
201
+ swl-ses notificaciones init
202
+ # fallback: npx -y @saulwade/swl-ses@latest notificaciones init
203
+ ```
204
+
205
+ **Para `status`**:
206
+
207
+ ```bash
208
+ swl-ses notificaciones status
209
+ ```
210
+
211
+ **Para `disable`**:
212
+
213
+ Antes de invocar la lib, pedir confirmación al usuario:
214
+
215
+ ```
216
+ ¿Confirmas deshabilitar las notificaciones Telegram? [s/N]
217
+ ```
218
+
219
+ Si responde `n` o vacío: cancelar sin tocar nada.
220
+
221
+ Si responde `s` (agregar `--purge` para eliminar también las credenciales, tras
222
+ confirmación adicional del usuario):
223
+
224
+ ```bash
225
+ swl-ses notificaciones disable # conserva ~/.claude/notifications/.env
226
+ swl-ses notificaciones disable --purge # elimina también las credenciales
227
+ ```
228
+
229
+ **Para `repair`**:
230
+
231
+ ```bash
232
+ swl-ses notificaciones repair
233
+ ```
234
+
235
+ **Para `bot start`**:
236
+
237
+ ```bash
238
+ swl-ses notificaciones bot-start
239
+ ```
240
+
241
+ **Para `bot stop`**:
242
+
243
+ ```bash
244
+ swl-ses notificaciones bot-stop
245
+ ```
246
+
247
+ **Para `bot status`**:
248
+
249
+ ```bash
250
+ swl-ses notificaciones bot-status
251
+ ```
252
+
253
+ **Para `bot restart`**:
254
+
255
+ ```bash
256
+ swl-ses notificaciones bot-restart
257
+ ```
258
+
259
+ **Para `bot enable-autostart`**:
260
+
261
+ ```bash
262
+ swl-ses notificaciones bot-enable-autostart
263
+ ```
264
+
265
+ **Para `bot disable-autostart`**:
266
+
267
+ ```bash
268
+ swl-ses notificaciones bot-disable-autostart
269
+ ```
270
+
271
+ ### Paso 3 — Reportar resultado
272
+
273
+ Mostrar el resultado al usuario con el estado final. Si el subcomando fue
274
+ `init` exitoso, recordar que el hook estará activo en la próxima sesión de
275
+ Claude Code.
276
+
277
+ ## Seguridad
278
+
279
+ - NUNCA mostrar el valor de `TELEGRAM_BOT_TOKEN` en ningún output.
280
+ - NUNCA sugerir comandos como `cat ~/.claude/notifications/.env`.
281
+ - Los ejemplos de este comando usan placeholders `<TOKEN>` y `<CHAT_ID>`,
282
+ nunca valores reales.
283
+ - Al mostrar el chat_id, siempre usar solo los últimos 4 dígitos.
284
+ - Si detectas que algún output podría exponer credenciales, truncar o
285
+ enmascarar antes de mostrar.
286
+
287
+ ## Variables de entorno relevantes
288
+
289
+ | Variable | Efecto |
290
+ |----------|--------|
291
+ | `SWL_NOTIFICACIONES_TELEGRAM=0` | Desactiva los hooks sin tocar settings. El comando `init` respeta esta variable. |
292
+
293
+ ## Referencias
294
+
295
+ - Credenciales: `~/.claude/notifications/.env` (fuera del repo, permisos 600)
296
+ - Lib de flujo: `scripts/lib/notificaciones-telegram.js`
297
+ - Hook saliente: `hooks/notificacion-telegram.js`
298
+ - Hook de restauración: `hooks/auto-restaurar-settings.js`
299
+ - ADR-0009: excepción a la regla "SWL solo registra hooks a nivel proyecto"