@saulwade/swl-ses 1.6.8 → 1.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.
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * Hook: claudemd-duplicacion-detector.js
6
+ * Tipo: PostToolUse (aplica a: Write, Edit, MultiEdit)
7
+ *
8
+ * Detecta duplicación de reglas globales (`~/.claude/rules/`) inline en
9
+ * `CLAUDE.md` de proyecto recién modificados. Consume el detector
10
+ * `scripts/lib/detector-reglas-duplicadas.js` que lee el catálogo
11
+ * declarativo `scripts/lib/reglas-globales-conocidas.json`.
12
+ *
13
+ * Aplica la regla `reglas/sin-duplicacion-reglas-globales.md`:
14
+ * el `CLAUDE.md` del proyecto NO debe duplicar reglas que ya viven en
15
+ * `~/.claude/rules/`. La regla global es fuente de verdad; el proyecto
16
+ * referencia, no duplica.
17
+ *
18
+ * Opt-out: SWL_CLAUDEMD_DUPLICACION=0 desactiva completamente el hook.
19
+ *
20
+ * Comportamiento:
21
+ * - Nunca bloquea operaciones (exit code 0 siempre)
22
+ * - Solo emite nudge cuando hay duplicaciones detectadas
23
+ * - Solo se dispara con archivos cuyo basename sea exactamente CLAUDE.md
24
+ * - Respeta exclusiones: temp/, node_modules/, respositorios-git/
25
+ * - NO evalúa user-level (~/.claude/CLAUDE.md) — ahí sí pueden
26
+ * declararse preferencias personales
27
+ *
28
+ * Formato del nudge:
29
+ * {
30
+ * id: string,
31
+ * kind: "claudemd-duplicacion-reglas",
32
+ * target: "documentador-swl",
33
+ * source: "hooks/claudemd-duplicacion-detector.js",
34
+ * message: "...",
35
+ * data: { archivo, duplicaciones: [...] },
36
+ * ts: ISO,
37
+ * accionado: false
38
+ * }
39
+ */
40
+
41
+ const fs = require('fs');
42
+ const path = require('path');
43
+ const os = require('os');
44
+ const crypto = require('crypto');
45
+
46
+ // ─── Opt-out global ───────────────────────────────────────────────────────
47
+ if (process.env.SWL_CLAUDEMD_DUPLICACION === '0') {
48
+ process.exit(0);
49
+ }
50
+
51
+ let hookInput = '';
52
+ try {
53
+ hookInput = fs.readFileSync(0, 'utf-8');
54
+ } catch (_) {
55
+ process.exit(0);
56
+ }
57
+
58
+ let evento;
59
+ try {
60
+ evento = JSON.parse(hookInput);
61
+ } catch (_) {
62
+ process.exit(0);
63
+ }
64
+
65
+ const toolName = evento?.tool_name;
66
+ const toolInput = evento?.tool_input;
67
+
68
+ if (!toolName || !['Write', 'Edit', 'MultiEdit'].includes(toolName)) {
69
+ process.exit(0);
70
+ }
71
+
72
+ const filePath = toolInput?.file_path;
73
+ if (!filePath) {
74
+ process.exit(0);
75
+ }
76
+
77
+ // Solo CLAUDE.md (basename exacto, case-sensitive)
78
+ const basename = path.basename(filePath);
79
+ if (basename !== 'CLAUDE.md') {
80
+ process.exit(0);
81
+ }
82
+
83
+ const pathNormalized = filePath.replace(/\\/g, '/');
84
+ const RUTAS_EXCLUIDAS = [
85
+ '/temp/',
86
+ '/node_modules/',
87
+ '/respositorios-git/',
88
+ '/.planning/',
89
+ ];
90
+ if (RUTAS_EXCLUIDAS.some((excluida) => pathNormalized.includes(excluida))) {
91
+ process.exit(0);
92
+ }
93
+
94
+ // User-level: no evaluar (puede declarar preferencias personales)
95
+ const homeClaudeDir = path.resolve(path.join(os.homedir(), '.claude'));
96
+ const rutaAbs = path.resolve(filePath);
97
+ const esUserLevel = rutaAbs.startsWith(homeClaudeDir + path.sep) || rutaAbs === path.join(homeClaudeDir, 'CLAUDE.md');
98
+
99
+ // El archivo debe existir
100
+ if (!fs.existsSync(filePath)) {
101
+ process.exit(0);
102
+ }
103
+
104
+ // ─── Cargar detector ──────────────────────────────────────────────────────
105
+ const CWD = process.cwd();
106
+ const detectorPath = path.join(CWD, 'scripts', 'lib', 'detector-reglas-duplicadas.js');
107
+ if (!fs.existsSync(detectorPath)) {
108
+ // No hay detector instalado en este destino; salir silenciosamente
109
+ process.exit(0);
110
+ }
111
+
112
+ let resultado;
113
+ try {
114
+ const { detectarDuplicaciones } = require(detectorPath);
115
+ const contenido = fs.readFileSync(filePath, 'utf8');
116
+ resultado = detectarDuplicaciones(contenido, null, { esUserLevel });
117
+ } catch (_) {
118
+ // Cualquier error del detector: salir silenciosamente
119
+ process.exit(0);
120
+ }
121
+
122
+ // Solo emitir nudge si hay duplicaciones detectadas
123
+ if (!resultado || !resultado.evaluado || resultado.duplicaciones.length === 0) {
124
+ process.exit(0);
125
+ }
126
+
127
+ // ─── Construir nudge ──────────────────────────────────────────────────────
128
+ const rutaRelativa = path.relative(CWD, filePath).replace(/\\/g, '/');
129
+ const topDuplicaciones = resultado.duplicaciones
130
+ .slice(0, 5)
131
+ .map((d) => ` - [${d.severidad}] ${d.id} (regla global: ${d.regla_global}, línea ~${d.linea_aproximada})`)
132
+ .join('\n');
133
+
134
+ const nudge = {
135
+ id: crypto.randomBytes(8).toString('hex'),
136
+ kind: 'claudemd-duplicacion-reglas',
137
+ target: 'documentador-swl',
138
+ source: 'hooks/claudemd-duplicacion-detector.js',
139
+ message:
140
+ `[claudemd-dup] ${rutaRelativa} duplica ${resultado.duplicaciones.length} regla(s) global(es):\n` +
141
+ topDuplicaciones + '\n' +
142
+ ` Ejecutar \`/swl:claudemd audit\` para detalle, ` +
143
+ `\`/swl:claudemd refactor\` para sugerencias de reemplazo.\n` +
144
+ ` Ver regla: \`reglas/sin-duplicacion-reglas-globales.md\`.`,
145
+ data: {
146
+ archivo: rutaRelativa,
147
+ total_evaluadas: resultado.total_reglas_evaluadas,
148
+ detectadas: resultado.duplicaciones.length,
149
+ ids: resultado.duplicaciones.map((d) => d.id),
150
+ reglas_globales: [...new Set(resultado.duplicaciones.map((d) => d.regla_global))],
151
+ },
152
+ ts: new Date().toISOString(),
153
+ accionado: false,
154
+ accionado_ts: null,
155
+ accionado_por: null,
156
+ };
157
+
158
+ // ─── Persistir a nudges.jsonl ─────────────────────────────────────────────
159
+ try {
160
+ const nudgesPath = path.join(CWD, '.planning', 'evolucion', 'nudges.jsonl');
161
+ const nudgesDir = path.dirname(nudgesPath);
162
+ if (!fs.existsSync(nudgesDir)) {
163
+ fs.mkdirSync(nudgesDir, { recursive: true });
164
+ }
165
+ fs.appendFileSync(nudgesPath, JSON.stringify(nudge) + '\n', 'utf-8');
166
+ } catch (_) {
167
+ // No fallar el hook por error de escritura
168
+ }
169
+
170
+ process.exit(0);
@@ -356,6 +356,15 @@
356
356
  "maxConsecutiveFailures": 5,
357
357
  "degradeOnFailure": "skip"
358
358
  },
359
+ "claudemd-duplicacion-detector.js": {
360
+ "event": "PostToolUse",
361
+ "matcher": "Write|Edit|MultiEdit",
362
+ "description": "Detecta duplicación de reglas globales (~/.claude/rules/) inline en CLAUDE.md de proyecto. Consume scripts/lib/detector-reglas-duplicadas.js + catálogo scripts/lib/reglas-globales-conocidas.json. Aplica regla reglas/sin-duplicacion-reglas-globales.md. Emite nudge a .planning/evolucion/nudges.jsonl si hay duplicaciones detectadas. No bloquea — kind: claudemd-duplicacion-reglas. Excluye temp/, node_modules/, respositorios-git/, .planning/, ~/.claude/ (user-level). Opt-out: SWL_CLAUDEMD_DUPLICACION=0.",
363
+ "blocking": false,
364
+ "async": true,
365
+ "maxConsecutiveFailures": 5,
366
+ "degradeOnFailure": "skip"
367
+ },
359
368
  "validar-intent-spec.js": {
360
369
  "event": "PostToolUse",
361
370
  "matcher": "Write|Edit|MultiEdit",
@@ -905,7 +905,9 @@
905
905
  "reglas/registro-componentes-nuevos.md",
906
906
  "reglas/auditorias-documentales-estructurales.md",
907
907
  "reglas/intent-engineering.md",
908
- "reglas/tests-cleanup.md"
908
+ "reglas/tests-cleanup.md",
909
+ "reglas/verificar-citas-temporales.md",
910
+ "reglas/sin-duplicacion-reglas-globales.md"
909
911
  ],
910
912
  "targets": [
911
913
  "claude",
@@ -1024,6 +1026,7 @@
1024
1026
  "hooks/inbox-aviso.js",
1025
1027
  "hooks/aiisms-detector.js",
1026
1028
  "hooks/claudemd-bloat-detector.js",
1029
+ "hooks/claudemd-duplicacion-detector.js",
1027
1030
  "hooks/validar-intent-spec.js",
1028
1031
  "hooks/sugerir-regenerar-inventario.js",
1029
1032
  "hooks/sugerir-contribuir.js",
@@ -1219,6 +1222,8 @@
1219
1222
  "tipo": "scripts",
1220
1223
  "archivos": [
1221
1224
  "scripts/auditar-claudemd.js",
1225
+ "scripts/lib/detector-reglas-duplicadas.js",
1226
+ "scripts/lib/reglas-globales-conocidas.json",
1222
1227
  "docs/variables-entorno.md"
1223
1228
  ],
1224
1229
  "targets": [
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "lockfileVersion": 1,
3
- "generatedAt": "2026-05-22T17:02:33.598Z",
3
+ "generatedAt": "2026-05-22T23:28:47.439Z",
4
4
  "skillsCount": 177,
5
- "lockHash": "sha256:5d644809f2e8c7741a4553f1f6f493d309d4913782c9560bf06bd735eed1701e",
5
+ "lockHash": "sha256:d0306679d924ecbbd0071f532df9f2cfb499817eb42b0bb5e6e5ebcdacb941f2",
6
6
  "skills": [
7
7
  {
8
8
  "nombre": "accesibilidad-a11y",
@@ -1099,9 +1099,9 @@
1099
1099
  {
1100
1100
  "nombre": "swl-claudemd",
1101
1101
  "path": "habilidades/swl-claudemd/SKILL.md",
1102
- "hash": "sha256:dd8ef172d38668e261fc88ff22e614559a05a4f13b2c612c2da3ea2388494377",
1103
- "bytes": 13666,
1104
- "version": "\"1.0.2\""
1102
+ "hash": "sha256:0f5eed29f3fedb3bca8036ae5680901712520b31190ad416700c732b2b5897e4",
1103
+ "bytes": 21518,
1104
+ "version": "\"1.2.0\""
1105
1105
  },
1106
1106
  {
1107
1107
  "nombre": "swl-dashboard",
package/package.json CHANGED
@@ -1,92 +1,92 @@
1
- {
2
- "name": "@saulwade/swl-ses",
3
- "version": "1.6.8",
4
- "description": "Sistema de ingenieria de software auto-evolutivo multi-runtime polyglot con 61 agentes, 177 habilidades, 44 comandos, 69 reglas y 42 hooks. Soporta 11 lenguajes y 7 runtimes: Claude Code, OpenClaude, OpenCode, Gemini CLI, Cursor, Codex CLI (soporte completo); GitHub Copilot (soporte parcial). 100% en espanol (Mexico). Multi-target install (--target CSV / --all-runtimes), autoconfig MCP en Cursor/Codex con --with-mcp, agentes Codex en TOML, hooks Cursor (17 eventos) y Codex (6 eventos). Gateway bidireccional con relay Telegram y auditoria profunda Nemesis con loop evaluator-optimizer opt-in (ADR-0021) y 8 tools ejecutables. v1.6.5 integra 3 patrones de awesome-codex-skills (ComposioHQ, MIT) agent-deep-links + changelog-generator + gh-fix-ci-swl ADR-0029, y promueve 3 evoluciones SIGAF al sistema global (D1 nemesis SendMessage + D2 verificar smoke frontend + L2 alineacion veredicto).",
5
- "bin": {
6
- "swl-ses": "bin/swl-ses.js",
7
- "swl-telegram-bot": "bin/swl-telegram-bot.js",
8
- "swl-mcp-server": "bin/swl-mcp-server.js",
9
- "swl-webhook-server": "bin/swl-webhook-server.js"
10
- },
11
- "files": [
12
- "bin",
13
- "scripts",
14
- "manifiestos",
15
- "agentes",
16
- "habilidades",
17
- "comandos",
18
- "reglas",
19
- "hooks",
20
- "gateway",
21
- "plantillas",
22
- "contextos",
23
- "instintos",
24
- "schemas",
25
- "_userland",
26
- "plugin.json",
27
- "CLAUDE.md"
28
- ],
29
- "scripts": {
30
- "postinstall": "echo '\n swl-software-engineering-system instalado.\n Ejecuta: npx swl-ses init\n'",
31
- "test": "node --test tests/lib/*.test.js tests/scripts/*.test.js tests/scripts/lib/*.test.js tests/scripts/tui/*.test.js tests/hooks/*.test.js tests/hooks/lib/*.test.js tests/habilidades/*.test.js tests/gateway/*.test.js tests/bin/*.test.js tests/transformadores/*.test.js tests/mcp-server/*.test.js",
32
- "test:validate": "node scripts/validar.js",
33
- "test:manifest": "node scripts/validar-manifest.js",
34
- "test:docs": "node scripts/verificar-docs-vs-codigo.js",
35
- "test:smoke": "node scripts/smoke-test.js",
36
- "test:aislamiento": "node scripts/validar-tests-aislamiento.js",
37
- "test:all": "npm test && node scripts/validar.js && node scripts/validar-manifest.js && node scripts/verificar-docs-vs-codigo.js && node scripts/derivar-feature-list.js --check",
38
- "test:userland": "node scripts/validar-userland-vacio.js",
39
- "test:release": "npm run test:all && npm run test:userland && npm run test:smoke",
40
- "doctor": "node scripts/doctor.js",
41
- "prepack": "node scripts/limpiar-artefactos-python.js && node scripts/validar-userland-vacio.js",
42
- "prepublishOnly": "npm run test:release",
43
- "publish:all": "node scripts/publicar.js",
44
- "publish:github": "node scripts/publicar.js --solo-github",
45
- "publish:npmjs": "node scripts/publicar.js --solo-npmjs",
46
- "publish:dry": "node scripts/publicar.js --dry-run",
47
- "generate:docs": "node scripts/generar-inventario.js",
48
- "gen-checklists": "node scripts/generar-checklists-consolidados.js",
49
- "gen-checklists:check": "node scripts/generar-checklists-consolidados.js --check",
50
- "gen:feature-list": "node scripts/derivar-feature-list.js",
51
- "gen:feature-list:check": "node scripts/derivar-feature-list.js --check",
52
- "field-report": "node scripts/field-report.js",
53
- "configure:branch-protection": "node scripts/configurar-branch-protection.js"
54
- },
55
- "engines": {
56
- "node": ">=22.0.0"
57
- },
58
- "keywords": [
59
- "claude-code",
60
- "github-copilot",
61
- "gemini-cli",
62
- "opencode",
63
- "codex-cli",
64
- "agentes",
65
- "skills",
66
- "multi-runtime",
67
- "spec-driven",
68
- "orquestacion",
69
- "ingenieria-software"
70
- ],
71
- "author": "Saul Wade Leon",
72
- "license": "MIT",
73
- "repository": {
74
- "type": "git",
75
- "url": "git+https://github.com/saul-wade/swl-ses.git"
76
- },
77
- "homepage": "https://github.com/saul-wade/swl-ses#readme",
78
- "bugs": {
79
- "url": "https://github.com/saul-wade/swl-ses/issues"
80
- },
81
- "publishConfig": {
82
- "registry": "https://registry.npmjs.org/",
83
- "access": "public"
84
- },
85
- "dependencies": {
86
- "docx": "^9.6.1"
87
- },
88
- "overrides": {
89
- "pako": "^2.1.0",
90
- "readable-stream": "^4.7.0"
91
- }
92
- }
1
+ {
2
+ "name": "@saulwade/swl-ses",
3
+ "version": "1.7.0",
4
+ "description": "Sistema de ingenieria de software auto-evolutivo multi-runtime polyglot con 61 agentes, 177 habilidades, 44 comandos, 71 reglas y 43 hooks. Soporta 11 lenguajes y 7 runtimes: Claude Code, OpenClaude, OpenCode, Gemini CLI, Cursor, Codex CLI (soporte completo); GitHub Copilot (soporte parcial). 100% en espanol (Mexico). Multi-target install (--target CSV / --all-runtimes), autoconfig MCP en Cursor/Codex con --with-mcp, agentes Codex en TOML, hooks Cursor (17 eventos) y Codex (6 eventos). Gateway bidireccional con relay Telegram y auditoria profunda Nemesis con loop evaluator-optimizer opt-in (ADR-0021) y 8 tools ejecutables. v1.7.0 introduce dimension 8 del auditor CLAUDE.md (deteccion de duplicacion de reglas globales) + hook PostToolUse claudemd-duplicacion-detector + regla sin-duplicacion-reglas-globales.md + catalogo declarativo reglas-globales-conocidas.json con 6 reglas (idioma, brevedad, git-coauthor, arreglar-al-detectar, debatir, context7).",
5
+ "bin": {
6
+ "swl-ses": "bin/swl-ses.js",
7
+ "swl-telegram-bot": "bin/swl-telegram-bot.js",
8
+ "swl-mcp-server": "bin/swl-mcp-server.js",
9
+ "swl-webhook-server": "bin/swl-webhook-server.js"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "scripts",
14
+ "manifiestos",
15
+ "agentes",
16
+ "habilidades",
17
+ "comandos",
18
+ "reglas",
19
+ "hooks",
20
+ "gateway",
21
+ "plantillas",
22
+ "contextos",
23
+ "instintos",
24
+ "schemas",
25
+ "_userland",
26
+ "plugin.json",
27
+ "CLAUDE.md"
28
+ ],
29
+ "scripts": {
30
+ "postinstall": "echo '\n swl-software-engineering-system instalado.\n Ejecuta: npx swl-ses init\n'",
31
+ "test": "node --test tests/lib/*.test.js tests/scripts/*.test.js tests/scripts/lib/*.test.js tests/scripts/tui/*.test.js tests/hooks/*.test.js tests/hooks/lib/*.test.js tests/habilidades/*.test.js tests/gateway/*.test.js tests/bin/*.test.js tests/transformadores/*.test.js tests/mcp-server/*.test.js",
32
+ "test:validate": "node scripts/validar.js",
33
+ "test:manifest": "node scripts/validar-manifest.js",
34
+ "test:docs": "node scripts/verificar-docs-vs-codigo.js",
35
+ "test:smoke": "node scripts/smoke-test.js",
36
+ "test:aislamiento": "node scripts/validar-tests-aislamiento.js",
37
+ "test:all": "npm test && node scripts/validar.js && node scripts/validar-manifest.js && node scripts/verificar-docs-vs-codigo.js && node scripts/derivar-feature-list.js --check",
38
+ "test:userland": "node scripts/validar-userland-vacio.js",
39
+ "test:release": "npm run test:all && npm run test:userland && npm run test:smoke",
40
+ "doctor": "node scripts/doctor.js",
41
+ "prepack": "node scripts/limpiar-artefactos-python.js && node scripts/validar-userland-vacio.js",
42
+ "prepublishOnly": "npm run test:release",
43
+ "publish:all": "node scripts/publicar.js",
44
+ "publish:github": "node scripts/publicar.js --solo-github",
45
+ "publish:npmjs": "node scripts/publicar.js --solo-npmjs",
46
+ "publish:dry": "node scripts/publicar.js --dry-run",
47
+ "generate:docs": "node scripts/generar-inventario.js",
48
+ "gen-checklists": "node scripts/generar-checklists-consolidados.js",
49
+ "gen-checklists:check": "node scripts/generar-checklists-consolidados.js --check",
50
+ "gen:feature-list": "node scripts/derivar-feature-list.js",
51
+ "gen:feature-list:check": "node scripts/derivar-feature-list.js --check",
52
+ "field-report": "node scripts/field-report.js",
53
+ "configure:branch-protection": "node scripts/configurar-branch-protection.js"
54
+ },
55
+ "engines": {
56
+ "node": ">=22.0.0"
57
+ },
58
+ "keywords": [
59
+ "claude-code",
60
+ "github-copilot",
61
+ "gemini-cli",
62
+ "opencode",
63
+ "codex-cli",
64
+ "agentes",
65
+ "skills",
66
+ "multi-runtime",
67
+ "spec-driven",
68
+ "orquestacion",
69
+ "ingenieria-software"
70
+ ],
71
+ "author": "Saul Wade Leon",
72
+ "license": "MIT",
73
+ "repository": {
74
+ "type": "git",
75
+ "url": "git+https://github.com/saul-wade/swl-ses.git"
76
+ },
77
+ "homepage": "https://github.com/saul-wade/swl-ses#readme",
78
+ "bugs": {
79
+ "url": "https://github.com/saul-wade/swl-ses/issues"
80
+ },
81
+ "publishConfig": {
82
+ "registry": "https://registry.npmjs.org/",
83
+ "access": "public"
84
+ },
85
+ "dependencies": {
86
+ "docx": "^9.6.1"
87
+ },
88
+ "overrides": {
89
+ "pako": "^2.1.0",
90
+ "readable-stream": "^4.7.0"
91
+ }
92
+ }