@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,101 +1,101 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- /**
5
- * evidencia-valor.js — CLI `swl-ses valor`: panel de evidencia de valor del
6
- * harness en el proyecto downstream actual.
7
- *
8
- * Uso:
9
- * swl-ses valor # panel legible (ventana 30 días)
10
- * swl-ses valor --dias 90 # ventana distinta
11
- * swl-ses valor --json # salida JSON para tooling
12
- *
13
- * Reglas duras del panel (docs/evidencia-valor.md):
14
- * - Cada métrica declara su PROCEDENCIA (git / GitHub / hook-event) y su
15
- * CARÁCTER (evidencia | proxy | contexto). Nunca scores autodeclarados.
16
- * - Todo se lee LOCAL. El repo madre no lee estos datos.
17
- */
18
-
19
- const { panelEvidencia } = require('./lib/evidencia-valor.js');
20
-
21
- /**
22
- * Contrato del CLI (bin/swl-ses.js): exportar UNA función(opciones) sin
23
- * efectos al require. Violarlo = "modulo is not a function" tras imprimir
24
- * el panel (caso real: SIGM, 2026-07-09).
25
- */
26
- function valor(opciones = {}) {
27
- const json = !!opciones.json;
28
- const ventanaDias = parseInt(opciones.dias, 10) || 30;
29
-
30
- const p = panelEvidencia(process.cwd(), { ventanaDias });
31
-
32
- if (json) {
33
- console.log(JSON.stringify(p, null, 2));
34
- return;
35
- }
36
-
37
- console.log(`Evidencia de valor — ventana ${p.ventanaDias} días (${p.generado})`);
38
- console.log(` ${p.frontera}`);
39
- console.log('');
40
-
41
- const i = p.intercepciones;
42
- console.log('1. Intercepciones de gates [evidencia · hook-event]');
43
- if (!i.disponible) {
44
- console.log(` no disponible — ${i.razon}`);
45
- } else {
46
- console.log(` intervenciones: ${i.intervenciones} de ${i.totalEventos} eventos`);
47
- const tipos = Object.entries(i.porTipo).sort((a, b) => b[1] - a[1]).slice(0, 6);
48
- for (const [t, n] of tipos) console.log(` - ${t}: ${n}`);
49
- }
50
- console.log('');
51
-
52
- const d = p.defectos;
53
- console.log('2. Presión de defectos [proxy · git log]');
54
- if (!d.disponible) {
55
- console.log(` no disponible — ${d.razon}`);
56
- } else {
57
- console.log(` commits: ${d.commits} | fix: ${d.fixes} | feat: ${d.feats} | ratio fix/feat: ${d.ratioFixFeat ?? 'n/a'}`);
58
- if (d.escapes.disponible) {
59
- console.log(` escapes: ${d.escapes.fixesTrasUltimaVerificacion} fix tras la última verificación (${d.escapes.ultimaVerificacion}) — ${d.escapes.nota}`);
60
- } else {
61
- console.log(` escapes: no disponible — ${d.escapes.razon}`);
62
- }
63
- }
64
- console.log('');
65
-
66
- const dc = p.doraCi;
67
- console.log('3. DORA-lite + CI [evidencia de tendencia · git + GitHub]');
68
- if (!dc.disponible) {
69
- console.log(` no disponible — ${dc.razon}`);
70
- } else {
71
- const dora = dc.dora;
72
- const nd = m => `n/d (${(m && m.razon) || 'sin datos'})`;
73
- const df = dora.deploymentFrequency;
74
- console.log(` deployment frequency: ${df && df.disponible !== false && df.valor != null ? `${df.valor} deploys/semana [${df.clasificacion}]` : nd(df)}`);
75
- const lt = dora.leadTime;
76
- console.log(` lead time: ${lt && lt.disponible !== false && lt.p50Horas != null ? `p50 ${(+lt.p50Horas).toFixed(1)}h / p95 ${(+lt.p95Horas).toFixed(1)}h [${lt.clasificacion}]` : nd(lt)}`);
77
- const cfr = dora.changeFailureRate;
78
- console.log(` change failure rate: ${cfr && cfr.disponible !== false && cfr.valor != null ? `${cfr.valor}% [${cfr.clasificacion || ''}]` : nd(cfr)}`);
79
- const mt = dora.mttr;
80
- console.log(` mttr: ${mt && mt.disponible !== false && mt.mttrHoras != null ? `${mt.mttrHoras}h` : nd(mt)}`);
81
- console.log(' (correlación con la adopción del flujo — no causalidad)');
82
- }
83
- console.log('');
84
-
85
- const u = p.uso;
86
- console.log('4. Uso del sistema [contexto · telemetría]');
87
- if (!u.disponible) {
88
- console.log(` no disponible — ${u.razon}`);
89
- } else {
90
- console.log(` invocaciones de skills: ${u.invocaciones} | top: ${u.top5.join(', ')}`);
91
- }
92
- console.log('');
93
- console.log('Compartir agregados con el autor (opt-in): swl-ses field-report — ver docs/evidencia-valor.md');
94
- }
95
-
96
- module.exports = valor;
97
-
98
- if (require.main === module) {
99
- const { parsearOpciones } = require('./lib/parsear-opciones.js');
100
- valor(parsearOpciones(process.argv.slice(2)));
101
- }
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * evidencia-valor.js — CLI `swl-ses valor`: panel de evidencia de valor del
6
+ * harness en el proyecto downstream actual.
7
+ *
8
+ * Uso:
9
+ * swl-ses valor # panel legible (ventana 30 días)
10
+ * swl-ses valor --dias 90 # ventana distinta
11
+ * swl-ses valor --json # salida JSON para tooling
12
+ *
13
+ * Reglas duras del panel (docs/evidencia-valor.md):
14
+ * - Cada métrica declara su PROCEDENCIA (git / GitHub / hook-event) y su
15
+ * CARÁCTER (evidencia | proxy | contexto). Nunca scores autodeclarados.
16
+ * - Todo se lee LOCAL. El repo madre no lee estos datos.
17
+ */
18
+
19
+ const { panelEvidencia } = require('./lib/evidencia-valor.js');
20
+
21
+ /**
22
+ * Contrato del CLI (bin/swl-ses.js): exportar UNA función(opciones) sin
23
+ * efectos al require. Violarlo = "modulo is not a function" tras imprimir
24
+ * el panel (caso real: SIGM, 2026-07-09).
25
+ */
26
+ function valor(opciones = {}) {
27
+ const json = !!opciones.json;
28
+ const ventanaDias = parseInt(opciones.dias, 10) || 30;
29
+
30
+ const p = panelEvidencia(process.cwd(), { ventanaDias });
31
+
32
+ if (json) {
33
+ console.log(JSON.stringify(p, null, 2));
34
+ return;
35
+ }
36
+
37
+ console.log(`Evidencia de valor — ventana ${p.ventanaDias} días (${p.generado})`);
38
+ console.log(` ${p.frontera}`);
39
+ console.log('');
40
+
41
+ const i = p.intercepciones;
42
+ console.log('1. Intercepciones de gates [evidencia · hook-event]');
43
+ if (!i.disponible) {
44
+ console.log(` no disponible — ${i.razon}`);
45
+ } else {
46
+ console.log(` intervenciones: ${i.intervenciones} de ${i.totalEventos} eventos`);
47
+ const tipos = Object.entries(i.porTipo).sort((a, b) => b[1] - a[1]).slice(0, 6);
48
+ for (const [t, n] of tipos) console.log(` - ${t}: ${n}`);
49
+ }
50
+ console.log('');
51
+
52
+ const d = p.defectos;
53
+ console.log('2. Presión de defectos [proxy · git log]');
54
+ if (!d.disponible) {
55
+ console.log(` no disponible — ${d.razon}`);
56
+ } else {
57
+ console.log(` commits: ${d.commits} | fix: ${d.fixes} | feat: ${d.feats} | ratio fix/feat: ${d.ratioFixFeat ?? 'n/a'}`);
58
+ if (d.escapes.disponible) {
59
+ console.log(` escapes: ${d.escapes.fixesTrasUltimaVerificacion} fix tras la última verificación (${d.escapes.ultimaVerificacion}) — ${d.escapes.nota}`);
60
+ } else {
61
+ console.log(` escapes: no disponible — ${d.escapes.razon}`);
62
+ }
63
+ }
64
+ console.log('');
65
+
66
+ const dc = p.doraCi;
67
+ console.log('3. DORA-lite + CI [evidencia de tendencia · git + GitHub]');
68
+ if (!dc.disponible) {
69
+ console.log(` no disponible — ${dc.razon}`);
70
+ } else {
71
+ const dora = dc.dora;
72
+ const nd = m => `n/d (${(m && m.razon) || 'sin datos'})`;
73
+ const df = dora.deploymentFrequency;
74
+ console.log(` deployment frequency: ${df && df.disponible !== false && df.valor != null ? `${df.valor} deploys/semana [${df.clasificacion}]` : nd(df)}`);
75
+ const lt = dora.leadTime;
76
+ console.log(` lead time: ${lt && lt.disponible !== false && lt.p50Horas != null ? `p50 ${(+lt.p50Horas).toFixed(1)}h / p95 ${(+lt.p95Horas).toFixed(1)}h [${lt.clasificacion}]` : nd(lt)}`);
77
+ const cfr = dora.changeFailureRate;
78
+ console.log(` change failure rate: ${cfr && cfr.disponible !== false && cfr.valor != null ? `${cfr.valor}% [${cfr.clasificacion || ''}]` : nd(cfr)}`);
79
+ const mt = dora.mttr;
80
+ console.log(` mttr: ${mt && mt.disponible !== false && mt.mttrHoras != null ? `${mt.mttrHoras}h` : nd(mt)}`);
81
+ console.log(' (correlación con la adopción del flujo — no causalidad)');
82
+ }
83
+ console.log('');
84
+
85
+ const u = p.uso;
86
+ console.log('4. Uso del sistema [contexto · telemetría]');
87
+ if (!u.disponible) {
88
+ console.log(` no disponible — ${u.razon}`);
89
+ } else {
90
+ console.log(` invocaciones de skills: ${u.invocaciones} | top: ${u.top5.join(', ')}`);
91
+ }
92
+ console.log('');
93
+ console.log('Compartir agregados con el autor (opt-in): swl-ses field-report — ver docs/evidencia-valor.md');
94
+ }
95
+
96
+ module.exports = valor;
97
+
98
+ if (require.main === module) {
99
+ const { parsearOpciones } = require('./lib/parsear-opciones.js');
100
+ valor(parsearOpciones(process.argv.slice(2)));
101
+ }
@@ -196,20 +196,20 @@ function generarReporte() {
196
196
  console.log(`\n> Generado por \`node scripts/field-report.js\``);
197
197
  }
198
198
 
199
- function fieldReport(opciones = {}) {
200
- DAYS = parseInt(opciones.days || opciones.dias, 10) || 0;
201
- PROJECT = opciones.project || null;
202
- OUTPUT = opciones.output || 'md';
203
- generarReporte();
204
- }
205
-
206
- module.exports = fieldReport;
207
-
208
- if (require.main === module) {
209
- const args = process.argv.slice(2).reduce((acc, arg) => {
210
- const [k, v] = arg.replace(/^--/, '').split('=');
211
- acc[k] = v || true;
212
- return acc;
213
- }, {});
214
- fieldReport(args);
199
+ function fieldReport(opciones = {}) {
200
+ DAYS = parseInt(opciones.days || opciones.dias, 10) || 0;
201
+ PROJECT = opciones.project || null;
202
+ OUTPUT = opciones.output || 'md';
203
+ generarReporte();
204
+ }
205
+
206
+ module.exports = fieldReport;
207
+
208
+ if (require.main === module) {
209
+ const args = process.argv.slice(2).reduce((acc, arg) => {
210
+ const [k, v] = arg.replace(/^--/, '').split('=');
211
+ acc[k] = v || true;
212
+ return acc;
213
+ }, {});
214
+ fieldReport(args);
215
215
  }
@@ -41,6 +41,7 @@ const { canonicalHash } = require('./lib/canonical-hash');
41
41
  const { auditarEscritura } = require('./lib/audit-evolved');
42
42
  const { detectarStack, filtrarReglasPorStack } = require('./lib/detectar-stack');
43
43
  const { actualizarGitignore, entradasParaRuntime, limpiarTracked, leerManifest, escribirManifest } = require('./lib/gitignore-manifest');
44
+ const { limpiarBasuraGlobal } = require('./lib/limpiar-basura-global');
44
45
 
45
46
  const RAIZ_PKG = path.resolve(__dirname, '..');
46
47
  const VERSION = require('../package.json').version;
@@ -352,6 +353,18 @@ async function install(opciones) {
352
353
  }
353
354
  }
354
355
 
356
+ // Scope global: purgar directorios basura sembrados en el HOME por versiones
357
+ // previas: ~/.planning/ scaffold (doctor confundía el HOME con un proyecto por
358
+ // ~/_userland) y ~/_userland/ vacío. Conservador: solo el .planning con la
359
+ // huella del scaffold y el _userland sin plugins reales, nunca contenido del
360
+ // usuario. Ver scripts/lib/limpiar-basura-global.js.
361
+ if (esGlobal) {
362
+ const basura = limpiarBasuraGlobal();
363
+ if (basura.eliminados.length > 0) {
364
+ console.log(`\n[global] Basura purgada del HOME: ${basura.eliminados.join(', ')}.`);
365
+ }
366
+ }
367
+
355
368
  // 4. Detectar _userland/
356
369
  const userlandAgentes = path.join(process.cwd(), '_userland', 'agentes');
357
370
  const userlandHabilidades = path.join(process.cwd(), '_userland', 'habilidades');
@@ -1,116 +1,116 @@
1
- 'use strict';
2
-
3
- /**
4
- * activar-hooks-proyecto.js — Camino "solo hooks" (DT-HOOKS-SOLO-PROYECTO).
5
- *
6
- * Registra en el `.claude/settings.json` del PROYECTO los hooks del scope
7
- * GLOBAL ya instalado, sin copiar ningún componente. Cierra el dilema del
8
- * install local: los hooks solo funcionan registrados a nivel proyecto
9
- * (ADR-0009), pero el install local completo duplica agentes/comandos en la
10
- * UI de Claude Code (lee ambos scopes). Con este camino:
11
- *
12
- * - Los comandos del settings apuntan con ruta ABSOLUTA al hooks/ global
13
- * (esGlobal: true en registrarHooks) → cero archivos copiados.
14
- * - `swl-ses update` del global refresca los hooks de TODOS los proyectos
15
- * activados así, gratis (apuntan a los mismos archivos).
16
- * - Hooks externos (no-SWL) del settings del proyecto se preservan
17
- * (garantía de registrarHooks).
18
- *
19
- * Uso: `swl-ses install --target claude --solo-hooks` (en la raíz del
20
- * proyecto). Requiere instalación global previa del runtime.
21
- */
22
-
23
- const fs = require('fs');
24
- const path = require('path');
25
-
26
- const RUNTIMES_SOPORTADOS = new Set(['claude', 'openclaude']);
27
-
28
- /**
29
- * @param {object} opciones
30
- * @param {string} [opciones.target='claude'] Runtime (claude|openclaude — formato de settings de Claude Code)
31
- * @param {string} [opciones.dirProyecto=cwd] Raíz del proyecto destino
32
- * @param {string} [opciones.hooksDirGlobal] Override del hooks/ global (tests)
33
- * @param {object} [opciones.deps] Inyección para tests: { registrarHooks, registrarOptimizaciones, cargarHooksConfig, scopesReales, obtenerRuntime }
34
- * @returns {{ok: boolean, error?: string, settingsPath?: string, hooksDirGlobal?: string, registrados?: number, preservados?: number}}
35
- */
36
- function activarHooksProyecto(opciones = {}) {
37
- const target = opciones.target || 'claude';
38
- if (!RUNTIMES_SOPORTADOS.has(target)) {
39
- return { ok: false, error: `--solo-hooks soporta por ahora targets con settings formato Claude Code (claude, openclaude); recibido: "${target}".` };
40
- }
41
-
42
- const deps = opciones.deps || {};
43
- const hs = require('./hooks-settings');
44
- const registrarHooks = deps.registrarHooks || hs.registrarHooks;
45
- const registrarOptimizaciones = deps.registrarOptimizaciones || hs.registrarOptimizaciones;
46
- const cargarHooksConfig = deps.cargarHooksConfig || hs.cargarHooksConfig;
47
-
48
- // 1. Localizar el hooks/ del scope GLOBAL del runtime.
49
- let hooksDirGlobal = opciones.hooksDirGlobal;
50
- if (!hooksDirGlobal) {
51
- try {
52
- const dr = require('./detectar-runtime');
53
- const obtenerRuntime = deps.obtenerRuntime || dr.obtenerRuntime;
54
- const scopesReales = deps.scopesReales || dr.scopesReales;
55
- const runtime = obtenerRuntime(target);
56
- const global = scopesReales(runtime).find(s => s.esGlobal);
57
- if (!global) return { ok: false, error: `No se pudo resolver el scope global del runtime "${target}".` };
58
- hooksDirGlobal = path.join(global.dir, 'hooks');
59
- } catch (err) {
60
- return { ok: false, error: `No se pudo detectar el runtime "${target}": ${err.message}` };
61
- }
62
- }
63
- if (!fs.existsSync(hooksDirGlobal)) {
64
- return { ok: false, error: `No hay instalación global con hooks en ${hooksDirGlobal}. Instala primero el global: npx -y @saulwade/swl-ses@latest install --target ${target} --global --perfil completo` };
65
- }
66
-
67
- // 2. Hooks disponibles = archivos del global ∩ hooks-config del paquete.
68
- const hooksConfig = cargarHooksConfig();
69
- const hookFiles = fs.readdirSync(hooksDirGlobal)
70
- .filter(f => f.endsWith('.js') && hooksConfig[f]);
71
- if (hookFiles.length === 0) {
72
- return { ok: false, error: `El hooks/ global (${hooksDirGlobal}) no contiene hooks reconocidos por hooks-config.json — instalación global corrupta o muy antigua; corre update primero.` };
73
- }
74
-
75
- // 3. Registrar en el settings.json del PROYECTO, apuntando al global.
76
- const dirProyecto = opciones.dirProyecto || process.cwd();
77
- const dirClaude = path.join(dirProyecto, '.claude');
78
- fs.mkdirSync(dirClaude, { recursive: true });
79
- const settingsPath = path.join(dirClaude, 'settings.json');
80
-
81
- const r = registrarHooks({
82
- settingsPath,
83
- hooksDir: hooksDirGlobal,
84
- esGlobal: true, // semántica: comandos con ruta ABSOLUTA al hooksDir (que es el global)
85
- hookFiles,
86
- });
87
-
88
- let optimizaciones = 0;
89
- try {
90
- const opt = registrarOptimizaciones(settingsPath);
91
- optimizaciones = (opt && opt.registradas) || 0;
92
- } catch { /* opcional — no bloquea la activación */ }
93
-
94
- // 4. Sembrar el .gitignore del proyecto: encender la telemetría hace que
95
- // los hooks ESCRIBAN (.planning/METRICAS.md, audit*.jsonl, evolution/...)
96
- // — sin la sección swl-ses esos archivos runtime aparecen como cambios
97
- // pendientes en el editor del usuario (caso real sistema-verificacion-oic,
98
- // 2026-07-10: 19 archivos sin trackear tras activar hooks).
99
- let gitignorePath = null;
100
- try {
101
- const { actualizarGitignore } = deps.gitignoreManifest || require('./gitignore-manifest');
102
- gitignorePath = actualizarGitignore(dirProyecto);
103
- } catch { /* no bloquea la activación — se reporta null */ }
104
-
105
- return {
106
- ok: true,
107
- settingsPath,
108
- hooksDirGlobal,
109
- registrados: r.registrados,
110
- preservados: r.preservados,
111
- optimizaciones,
112
- gitignorePath,
113
- };
114
- }
115
-
116
- module.exports = { activarHooksProyecto, RUNTIMES_SOPORTADOS };
1
+ 'use strict';
2
+
3
+ /**
4
+ * activar-hooks-proyecto.js — Camino "solo hooks" (DT-HOOKS-SOLO-PROYECTO).
5
+ *
6
+ * Registra en el `.claude/settings.json` del PROYECTO los hooks del scope
7
+ * GLOBAL ya instalado, sin copiar ningún componente. Cierra el dilema del
8
+ * install local: los hooks solo funcionan registrados a nivel proyecto
9
+ * (ADR-0009), pero el install local completo duplica agentes/comandos en la
10
+ * UI de Claude Code (lee ambos scopes). Con este camino:
11
+ *
12
+ * - Los comandos del settings apuntan con ruta ABSOLUTA al hooks/ global
13
+ * (esGlobal: true en registrarHooks) → cero archivos copiados.
14
+ * - `swl-ses update` del global refresca los hooks de TODOS los proyectos
15
+ * activados así, gratis (apuntan a los mismos archivos).
16
+ * - Hooks externos (no-SWL) del settings del proyecto se preservan
17
+ * (garantía de registrarHooks).
18
+ *
19
+ * Uso: `swl-ses install --target claude --solo-hooks` (en la raíz del
20
+ * proyecto). Requiere instalación global previa del runtime.
21
+ */
22
+
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+
26
+ const RUNTIMES_SOPORTADOS = new Set(['claude', 'openclaude']);
27
+
28
+ /**
29
+ * @param {object} opciones
30
+ * @param {string} [opciones.target='claude'] Runtime (claude|openclaude — formato de settings de Claude Code)
31
+ * @param {string} [opciones.dirProyecto=cwd] Raíz del proyecto destino
32
+ * @param {string} [opciones.hooksDirGlobal] Override del hooks/ global (tests)
33
+ * @param {object} [opciones.deps] Inyección para tests: { registrarHooks, registrarOptimizaciones, cargarHooksConfig, scopesReales, obtenerRuntime }
34
+ * @returns {{ok: boolean, error?: string, settingsPath?: string, hooksDirGlobal?: string, registrados?: number, preservados?: number}}
35
+ */
36
+ function activarHooksProyecto(opciones = {}) {
37
+ const target = opciones.target || 'claude';
38
+ if (!RUNTIMES_SOPORTADOS.has(target)) {
39
+ return { ok: false, error: `--solo-hooks soporta por ahora targets con settings formato Claude Code (claude, openclaude); recibido: "${target}".` };
40
+ }
41
+
42
+ const deps = opciones.deps || {};
43
+ const hs = require('./hooks-settings');
44
+ const registrarHooks = deps.registrarHooks || hs.registrarHooks;
45
+ const registrarOptimizaciones = deps.registrarOptimizaciones || hs.registrarOptimizaciones;
46
+ const cargarHooksConfig = deps.cargarHooksConfig || hs.cargarHooksConfig;
47
+
48
+ // 1. Localizar el hooks/ del scope GLOBAL del runtime.
49
+ let hooksDirGlobal = opciones.hooksDirGlobal;
50
+ if (!hooksDirGlobal) {
51
+ try {
52
+ const dr = require('./detectar-runtime');
53
+ const obtenerRuntime = deps.obtenerRuntime || dr.obtenerRuntime;
54
+ const scopesReales = deps.scopesReales || dr.scopesReales;
55
+ const runtime = obtenerRuntime(target);
56
+ const global = scopesReales(runtime).find(s => s.esGlobal);
57
+ if (!global) return { ok: false, error: `No se pudo resolver el scope global del runtime "${target}".` };
58
+ hooksDirGlobal = path.join(global.dir, 'hooks');
59
+ } catch (err) {
60
+ return { ok: false, error: `No se pudo detectar el runtime "${target}": ${err.message}` };
61
+ }
62
+ }
63
+ if (!fs.existsSync(hooksDirGlobal)) {
64
+ return { ok: false, error: `No hay instalación global con hooks en ${hooksDirGlobal}. Instala primero el global: npx -y @saulwade/swl-ses@latest install --target ${target} --global --perfil completo` };
65
+ }
66
+
67
+ // 2. Hooks disponibles = archivos del global ∩ hooks-config del paquete.
68
+ const hooksConfig = cargarHooksConfig();
69
+ const hookFiles = fs.readdirSync(hooksDirGlobal)
70
+ .filter(f => f.endsWith('.js') && hooksConfig[f]);
71
+ if (hookFiles.length === 0) {
72
+ return { ok: false, error: `El hooks/ global (${hooksDirGlobal}) no contiene hooks reconocidos por hooks-config.json — instalación global corrupta o muy antigua; corre update primero.` };
73
+ }
74
+
75
+ // 3. Registrar en el settings.json del PROYECTO, apuntando al global.
76
+ const dirProyecto = opciones.dirProyecto || process.cwd();
77
+ const dirClaude = path.join(dirProyecto, '.claude');
78
+ fs.mkdirSync(dirClaude, { recursive: true });
79
+ const settingsPath = path.join(dirClaude, 'settings.json');
80
+
81
+ const r = registrarHooks({
82
+ settingsPath,
83
+ hooksDir: hooksDirGlobal,
84
+ esGlobal: true, // semántica: comandos con ruta ABSOLUTA al hooksDir (que es el global)
85
+ hookFiles,
86
+ });
87
+
88
+ let optimizaciones = 0;
89
+ try {
90
+ const opt = registrarOptimizaciones(settingsPath);
91
+ optimizaciones = (opt && opt.registradas) || 0;
92
+ } catch { /* opcional — no bloquea la activación */ }
93
+
94
+ // 4. Sembrar el .gitignore del proyecto: encender la telemetría hace que
95
+ // los hooks ESCRIBAN (.planning/METRICAS.md, audit*.jsonl, evolution/...)
96
+ // — sin la sección swl-ses esos archivos runtime aparecen como cambios
97
+ // pendientes en el editor del usuario (caso real sistema-verificacion-oic,
98
+ // 2026-07-10: 19 archivos sin trackear tras activar hooks).
99
+ let gitignorePath = null;
100
+ try {
101
+ const { actualizarGitignore } = deps.gitignoreManifest || require('./gitignore-manifest');
102
+ gitignorePath = actualizarGitignore(dirProyecto);
103
+ } catch { /* no bloquea la activación — se reporta null */ }
104
+
105
+ return {
106
+ ok: true,
107
+ settingsPath,
108
+ hooksDirGlobal,
109
+ registrados: r.registrados,
110
+ preservados: r.preservados,
111
+ optimizaciones,
112
+ gitignorePath,
113
+ };
114
+ }
115
+
116
+ module.exports = { activarHooksProyecto, RUNTIMES_SOPORTADOS };