@saulwade/swl-ses 1.6.1 → 1.6.3

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 (50) hide show
  1. package/CLAUDE.md +2 -2
  2. package/README.md +4 -4
  3. package/agentes/_intent-spec.md +73 -0
  4. package/agentes/auto-evolucion-swl.md +24 -0
  5. package/agentes/cloud-infra-swl.md +25 -0
  6. package/agentes/datos-swl.md +23 -0
  7. package/agentes/devops-ci-swl.md +24 -0
  8. package/agentes/migrador-swl.md +22 -0
  9. package/agentes/pagos-swl.md +25 -0
  10. package/agentes/release-manager-swl.md +24 -0
  11. package/agentes/sre-swl.md +24 -0
  12. package/comandos/swl/planear-fase.md +16 -0
  13. package/habilidades/aprender-de-git-diff/SKILL.md +288 -0
  14. package/habilidades/diseno-herramientas-agente/SKILL.md +17 -1
  15. package/habilidades/meta-skills-estandar/SKILL.md +6 -0
  16. package/habilidades/meta-skills-estandar/recursos/skill-judge-rubrica.md +281 -0
  17. package/habilidades/proceso-autoverificacion-evidencias/SKILL.md +258 -0
  18. package/habilidades/proceso-confianza-pre-implementacion/SKILL.md +246 -0
  19. package/habilidades/proceso-ddia-fundamentos/SKILL.md +255 -0
  20. package/habilidades/proceso-ddia-streaming/SKILL.md +231 -0
  21. package/habilidades/proceso-intent-engineering/SKILL.md +269 -0
  22. package/habilidades/reducir-entropia/SKILL.md +219 -0
  23. package/hooks/lib/task-budget.js +218 -0
  24. package/hooks/validar-intent-spec.js +222 -0
  25. package/manifiestos/hooks-config.json +9 -0
  26. package/manifiestos/modulos.json +11 -2
  27. package/manifiestos/skills-lock.json +90 -41
  28. package/package.json +2 -2
  29. package/plugin.json +9 -2
  30. package/reglas/fragmentos-compartidos.md +26 -0
  31. package/reglas/intent-engineering.md +214 -0
  32. package/reglas/registro-componentes-nuevos.md +38 -0
  33. package/schemas/agent-frontmatter.schema.json +294 -167
  34. package/schemas/agent-message.schema.json +73 -53
  35. package/schemas/agent-output-implementacion.schema.json +114 -85
  36. package/schemas/agent-output-planificacion.schema.json +150 -113
  37. package/schemas/agent-output-review.schema.json +98 -78
  38. package/schemas/diary-entry.schema.json +42 -10
  39. package/schemas/hook-profiles.schema.json +54 -39
  40. package/schemas/hooks-config.schema.json +89 -74
  41. package/schemas/instinct.schema.json +152 -115
  42. package/schemas/modulos.schema.json +38 -29
  43. package/schemas/perfiles.schema.json +36 -28
  44. package/schemas/plugin.schema.json +77 -64
  45. package/schemas/skill-evals.schema.json +119 -95
  46. package/schemas/skill-frontmatter.schema.json +245 -170
  47. package/scripts/generar-inventario.js +3 -1
  48. package/scripts/lib/schema-version.js +164 -0
  49. package/scripts/validar-manifest.js +1 -1
  50. package/scripts/validar.js +3 -2
@@ -1,170 +1,245 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://swl-ses.dev/schemas/skill-frontmatter.json",
4
- "title": "SWL Skill Frontmatter",
5
- "description": "Schema de validacion para el frontmatter YAML de skills del sistema SWL",
6
- "type": "object",
7
- "required": ["name", "description"],
8
- "properties": {
9
- "name": {
10
- "type": "string",
11
- "pattern": "^[a-z][a-z0-9-]+$",
12
- "maxLength": 64,
13
- "description": "Nombre en kebab-case que coincide con el directorio"
14
- },
15
- "description": {
16
- "type": "string",
17
- "minLength": 20,
18
- "maxLength": 1024,
19
- "description": "Descripcion que incluye QUE hace y CUANDO cargarla"
20
- },
21
- "version": {
22
- "type": "string",
23
- "pattern": "^\\d+\\.\\d+\\.\\d+$"
24
- },
25
- "provenance": {
26
- "type": "object",
27
- "description": "Campo legacy. Equivalente espanol: 'procedencia'. Si ambos presentes deben coincidir (W010).",
28
- "properties": {
29
- "origin": {
30
- "type": "string",
31
- "enum": ["manual", "auto-evolution", "imported", "community"]
32
- },
33
- "created_at": {
34
- "type": "string",
35
- "format": "date"
36
- },
37
- "confidence": {
38
- "type": "number",
39
- "minimum": 0,
40
- "maximum": 1
41
- },
42
- "author": {
43
- "type": "string"
44
- }
45
- }
46
- },
47
- "procedencia": {
48
- "type": "object",
49
- "description": "Alias en espanol de 'provenance'. Campo propio de swl-ses. Si ambos presentes, deben coincidir (W010).",
50
- "properties": {
51
- "origin": {
52
- "type": "string",
53
- "enum": ["manual", "auto-evolution", "imported", "community"]
54
- },
55
- "created_at": {
56
- "type": "string",
57
- "format": "date"
58
- },
59
- "confidence": {
60
- "type": "number",
61
- "minimum": 0,
62
- "maximum": 1
63
- },
64
- "author": {
65
- "type": "string"
66
- }
67
- }
68
- },
69
- "targets": {
70
- "type": "array",
71
- "items": {
72
- "type": "string",
73
- "enum": ["claude", "openclaude", "copilot", "opencode", "codex", "gemini"]
74
- },
75
- "description": "Campo legacy. Equivalente espanol: 'destinos'. Runtimes a los que se sincroniza este skill. Patron adoptado de skillshare (targets.yaml). Si ambos presentes deben coincidir (W010)."
76
- },
77
- "destinos": {
78
- "type": "array",
79
- "items": {
80
- "type": "string",
81
- "enum": ["claude", "openclaude", "copilot", "opencode", "codex", "gemini"]
82
- },
83
- "description": "Alias en espanol de 'targets'. Campo propio de swl-ses. Runtimes a los que se sincroniza este skill."
84
- },
85
- "user-invocable": {
86
- "type": "boolean",
87
- "description": "Si el usuario puede invocar este skill directamente con Skill(nombre)"
88
- },
89
- "license": {
90
- "type": "string",
91
- "description": "Licencia del skill si es externo o adaptado"
92
- },
93
- "evolvable": {
94
- "type": "boolean",
95
- "description": "Campo legacy. Equivalente espanol: 'evolucionable'. Marca AGP learnability. Si false, el loop de auto-evolucion NO debe proponer cambios a este skill. Recomendado: false para skills criticos. Si ambos presentes deben coincidir (W010)."
96
- },
97
- "evolucionable": {
98
- "type": "boolean",
99
- "description": "Alias en espanol de 'evolvable'. Campo propio de swl-ses. Marca AGP learnability. Si false, el loop de auto-evolucion NO propone cambios a este skill."
100
- },
101
- "evolvable_scope": {
102
- "type": "array",
103
- "items": {
104
- "type": "string",
105
- "enum": ["description", "content", "examples", "references", "anti-patterns"]
106
- },
107
- "description": "Campo legacy. Equivalente espanol: 'evolucionable_alcance'. Si evolvable=true, limita las secciones del SKILL.md que pueden modificarse. Ausente implica 'content' y 'examples' unicamente. Si ambos presentes deben coincidir (W010)."
108
- },
109
- "evolucionable_alcance": {
110
- "type": "array",
111
- "items": {
112
- "type": "string",
113
- "enum": ["description", "content", "examples", "references", "anti-patterns"]
114
- },
115
- "description": "Alias en espanol de 'evolvable_scope'. Campo propio de swl-ses. Si evolucionable=true, limita las secciones modificables."
116
- },
117
- "when_to_use": {
118
- "type": "string",
119
- "maxLength": 512,
120
- "description": "Campo del protocolo Anthropic. Contexto adicional sobre cuando activar la skill, leido por Claude Code como bloque combinado con description (total max 1536 chars). Usar cuando description ocupa mas de 900 chars y aun hay triggers que no caben."
121
- },
122
- "exclusiones": {
123
- "type": "array",
124
- "items": { "type": "string" },
125
- "description": "Situaciones donde esta skill NO debe activarse aunque parezca relevante superficialmente. Campo propio de swl-ses; previene skill hijacking por similitud de terminos. Equivalente estructural de la seccion 'Cuando NO cargar' en el cuerpo de SKILL.md, legible por herramientas de analisis sin parsear markdown."
126
- },
127
- "allowed-tools": {
128
- "type": "array",
129
- "items": {
130
- "type": "string",
131
- "enum": ["Read", "Write", "Edit", "Bash", "Glob", "Grep", "WebSearch", "WebFetch"]
132
- },
133
- "description": "Campo del protocolo Anthropic. Pre-aprobacion de UX leida por Claude Code. NO es restriccion de seguridad real. Las restricciones reales provienen de permission rules en .claude/settings.json o del matcher en hooks."
134
- },
135
- "herramientasPermitidas": {
136
- "type": "array",
137
- "items": {
138
- "type": "string",
139
- "enum": ["Read", "Write", "Edit", "Bash", "Glob", "Grep", "WebSearch", "WebFetch"]
140
- },
141
- "description": "Campo propio de swl-ses. Alias semantico de allowed-tools, usado por las herramientas internas (evaluar-skill, validadores). Debe coincidir con allowed-tools cuando ambos estan presentes. Si divergen, el validador emite W011. Para skills nuevos en swl-ses, declarar solo este campo; una herramienta de sincronizacion propagara el valor a allowed-tools al construir artefactos para Claude Code."
142
- },
143
- "nist_csf": {
144
- "type": "array",
145
- "items": { "type": "string", "pattern": "^(GV|ID|PR|DE|RS|RC)\\.[A-Z]{2}(-[0-9]{2})?$" },
146
- "description": "Campo propio de swl-ses. Mapeo a NIST Cybersecurity Framework 2.0. Cada entrada es un ID de subcategoria tipo 'GV.SC-07', 'PR.PS-01', 'DE.CM-01'. Opcional. Usado para reportes de cobertura en /swl:salud y /swl:dashboard. Referencia: https://www.nist.gov/cyberframework"
147
- },
148
- "nist_ai_rmf": {
149
- "type": "array",
150
- "items": { "type": "string", "pattern": "^(GOVERN|MAP|MEASURE|MANAGE)(-[0-9]+(\\.[0-9]+)?)?$" },
151
- "description": "Campo propio de swl-ses. Mapeo a NIST AI Risk Management Framework 1.0. Cada entrada es un ID de subcategoria tipo 'GOVERN-1.1', 'MAP-5.1', 'MEASURE-2.7'. Opcional. Particularmente relevante para skills de seguridad de sistemas agenticos. Referencia: https://airc.nist.gov/AI_RMF"
152
- },
153
- "atlas_techniques": {
154
- "type": "array",
155
- "items": { "type": "string", "pattern": "^AML\\.T[0-9]{4}(\\.[0-9]{3})?$" },
156
- "description": "Campo propio de swl-ses. Mapeo a MITRE ATLAS v5.4 (Adversarial Threat Landscape for AI Systems). Cada entrada es una tecnica tipo 'AML.T0051' (LLM Prompt Injection), 'AML.T0080' (AI Agent Context Poisoning). Opcional. Critico para skills que protegen el sistema agentico mismo. Referencia: https://atlas.mitre.org"
157
- },
158
- "attack_techniques": {
159
- "type": "array",
160
- "items": { "type": "string", "pattern": "^T[0-9]{4}(\\.[0-9]{3})?$" },
161
- "description": "Campo propio de swl-ses. Mapeo a MITRE ATT&CK v18. Cada entrada es una tecnica tipo 'T1071' (Application Layer Protocol), 'T1190' (Exploit Public-Facing Application). Opcional. Mas aplicable a skills de defensa de infraestructura o deteccion de amenazas en el sistema desplegado. Referencia: https://attack.mitre.org"
162
- },
163
- "d3fend_techniques": {
164
- "type": "array",
165
- "items": { "type": "string", "pattern": "^D3-[A-Z]+$" },
166
- "description": "Campo propio de swl-ses. Mapeo a MITRE D3FEND v1.3 (Defensive countermeasures). Cada entrada es una tecnica tipo 'D3-NTA' (Network Traffic Analysis), 'D3-PSA' (Process Spawn Analysis). Opcional. Referencia: https://d3fend.mitre.org"
167
- }
168
- },
169
- "additionalProperties": true
170
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://swl-ses.dev/schemas/skill-frontmatter.json",
4
+ "$schemaVersion": "1.0.0",
5
+ "title": "SWL Skill Frontmatter",
6
+ "description": "Schema de validacion para el frontmatter YAML de skills del sistema SWL",
7
+ "type": "object",
8
+ "required": [
9
+ "name",
10
+ "description"
11
+ ],
12
+ "properties": {
13
+ "name": {
14
+ "type": "string",
15
+ "pattern": "^[a-z][a-z0-9-]+$",
16
+ "maxLength": 64,
17
+ "description": "Nombre en kebab-case que coincide con el directorio"
18
+ },
19
+ "description": {
20
+ "type": "string",
21
+ "minLength": 20,
22
+ "maxLength": 1024,
23
+ "description": "Descripcion que incluye QUE hace y CUANDO cargarla"
24
+ },
25
+ "version": {
26
+ "type": "string",
27
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
28
+ },
29
+ "provenance": {
30
+ "type": "object",
31
+ "description": "Campo legacy. Equivalente espanol: 'procedencia'. Si ambos presentes deben coincidir (W010).",
32
+ "properties": {
33
+ "origin": {
34
+ "type": "string",
35
+ "enum": [
36
+ "manual",
37
+ "auto-evolution",
38
+ "imported",
39
+ "community"
40
+ ]
41
+ },
42
+ "created_at": {
43
+ "type": "string",
44
+ "format": "date"
45
+ },
46
+ "confidence": {
47
+ "type": "number",
48
+ "minimum": 0,
49
+ "maximum": 1
50
+ },
51
+ "author": {
52
+ "type": "string"
53
+ }
54
+ }
55
+ },
56
+ "procedencia": {
57
+ "type": "object",
58
+ "description": "Alias en espanol de 'provenance'. Campo propio de swl-ses. Si ambos presentes, deben coincidir (W010).",
59
+ "properties": {
60
+ "origin": {
61
+ "type": "string",
62
+ "enum": [
63
+ "manual",
64
+ "auto-evolution",
65
+ "imported",
66
+ "community"
67
+ ]
68
+ },
69
+ "created_at": {
70
+ "type": "string",
71
+ "format": "date"
72
+ },
73
+ "confidence": {
74
+ "type": "number",
75
+ "minimum": 0,
76
+ "maximum": 1
77
+ },
78
+ "author": {
79
+ "type": "string"
80
+ }
81
+ }
82
+ },
83
+ "targets": {
84
+ "type": "array",
85
+ "items": {
86
+ "type": "string",
87
+ "enum": [
88
+ "claude",
89
+ "openclaude",
90
+ "copilot",
91
+ "opencode",
92
+ "codex",
93
+ "gemini"
94
+ ]
95
+ },
96
+ "description": "Campo legacy. Equivalente espanol: 'destinos'. Runtimes a los que se sincroniza este skill. Patron adoptado de skillshare (targets.yaml). Si ambos presentes deben coincidir (W010)."
97
+ },
98
+ "destinos": {
99
+ "type": "array",
100
+ "items": {
101
+ "type": "string",
102
+ "enum": [
103
+ "claude",
104
+ "openclaude",
105
+ "copilot",
106
+ "opencode",
107
+ "codex",
108
+ "gemini"
109
+ ]
110
+ },
111
+ "description": "Alias en espanol de 'targets'. Campo propio de swl-ses. Runtimes a los que se sincroniza este skill."
112
+ },
113
+ "user-invocable": {
114
+ "type": "boolean",
115
+ "description": "Si el usuario puede invocar este skill directamente con Skill(nombre)"
116
+ },
117
+ "license": {
118
+ "type": "string",
119
+ "description": "Licencia del skill si es externo o adaptado"
120
+ },
121
+ "evolvable": {
122
+ "type": "boolean",
123
+ "description": "Campo legacy. Equivalente espanol: 'evolucionable'. Marca AGP learnability. Si false, el loop de auto-evolucion NO debe proponer cambios a este skill. Recomendado: false para skills criticos. Si ambos presentes deben coincidir (W010)."
124
+ },
125
+ "evolucionable": {
126
+ "type": "boolean",
127
+ "description": "Alias en espanol de 'evolvable'. Campo propio de swl-ses. Marca AGP learnability. Si false, el loop de auto-evolucion NO propone cambios a este skill."
128
+ },
129
+ "evolvable_scope": {
130
+ "type": "array",
131
+ "items": {
132
+ "type": "string",
133
+ "enum": [
134
+ "description",
135
+ "content",
136
+ "examples",
137
+ "references",
138
+ "anti-patterns"
139
+ ]
140
+ },
141
+ "description": "Campo legacy. Equivalente espanol: 'evolucionable_alcance'. Si evolvable=true, limita las secciones del SKILL.md que pueden modificarse. Ausente implica 'content' y 'examples' unicamente. Si ambos presentes deben coincidir (W010)."
142
+ },
143
+ "evolucionable_alcance": {
144
+ "type": "array",
145
+ "items": {
146
+ "type": "string",
147
+ "enum": [
148
+ "description",
149
+ "content",
150
+ "examples",
151
+ "references",
152
+ "anti-patterns"
153
+ ]
154
+ },
155
+ "description": "Alias en espanol de 'evolvable_scope'. Campo propio de swl-ses. Si evolucionable=true, limita las secciones modificables."
156
+ },
157
+ "when_to_use": {
158
+ "type": "string",
159
+ "maxLength": 512,
160
+ "description": "Campo del protocolo Anthropic. Contexto adicional sobre cuando activar la skill, leido por Claude Code como bloque combinado con description (total max 1536 chars). Usar cuando description ocupa mas de 900 chars y aun hay triggers que no caben."
161
+ },
162
+ "exclusiones": {
163
+ "type": "array",
164
+ "items": {
165
+ "type": "string"
166
+ },
167
+ "description": "Situaciones donde esta skill NO debe activarse aunque parezca relevante superficialmente. Campo propio de swl-ses; previene skill hijacking por similitud de terminos. Equivalente estructural de la seccion 'Cuando NO cargar' en el cuerpo de SKILL.md, legible por herramientas de analisis sin parsear markdown."
168
+ },
169
+ "allowed-tools": {
170
+ "type": "array",
171
+ "items": {
172
+ "type": "string",
173
+ "enum": [
174
+ "Read",
175
+ "Write",
176
+ "Edit",
177
+ "Bash",
178
+ "Glob",
179
+ "Grep",
180
+ "WebSearch",
181
+ "WebFetch"
182
+ ]
183
+ },
184
+ "description": "Campo del protocolo Anthropic. Pre-aprobacion de UX leida por Claude Code. NO es restriccion de seguridad real. Las restricciones reales provienen de permission rules en .claude/settings.json o del matcher en hooks."
185
+ },
186
+ "herramientasPermitidas": {
187
+ "type": "array",
188
+ "items": {
189
+ "type": "string",
190
+ "enum": [
191
+ "Read",
192
+ "Write",
193
+ "Edit",
194
+ "Bash",
195
+ "Glob",
196
+ "Grep",
197
+ "WebSearch",
198
+ "WebFetch"
199
+ ]
200
+ },
201
+ "description": "Campo propio de swl-ses. Alias semantico de allowed-tools, usado por las herramientas internas (evaluar-skill, validadores). Debe coincidir con allowed-tools cuando ambos estan presentes. Si divergen, el validador emite W011. Para skills nuevos en swl-ses, declarar solo este campo; una herramienta de sincronizacion propagara el valor a allowed-tools al construir artefactos para Claude Code."
202
+ },
203
+ "nist_csf": {
204
+ "type": "array",
205
+ "items": {
206
+ "type": "string",
207
+ "pattern": "^(GV|ID|PR|DE|RS|RC)\\.[A-Z]{2}(-[0-9]{2})?$"
208
+ },
209
+ "description": "Campo propio de swl-ses. Mapeo a NIST Cybersecurity Framework 2.0. Cada entrada es un ID de subcategoria tipo 'GV.SC-07', 'PR.PS-01', 'DE.CM-01'. Opcional. Usado para reportes de cobertura en /swl:salud y /swl:dashboard. Referencia: https://www.nist.gov/cyberframework"
210
+ },
211
+ "nist_ai_rmf": {
212
+ "type": "array",
213
+ "items": {
214
+ "type": "string",
215
+ "pattern": "^(GOVERN|MAP|MEASURE|MANAGE)(-[0-9]+(\\.[0-9]+)?)?$"
216
+ },
217
+ "description": "Campo propio de swl-ses. Mapeo a NIST AI Risk Management Framework 1.0. Cada entrada es un ID de subcategoria tipo 'GOVERN-1.1', 'MAP-5.1', 'MEASURE-2.7'. Opcional. Particularmente relevante para skills de seguridad de sistemas agenticos. Referencia: https://airc.nist.gov/AI_RMF"
218
+ },
219
+ "atlas_techniques": {
220
+ "type": "array",
221
+ "items": {
222
+ "type": "string",
223
+ "pattern": "^AML\\.T[0-9]{4}(\\.[0-9]{3})?$"
224
+ },
225
+ "description": "Campo propio de swl-ses. Mapeo a MITRE ATLAS v5.4 (Adversarial Threat Landscape for AI Systems). Cada entrada es una tecnica tipo 'AML.T0051' (LLM Prompt Injection), 'AML.T0080' (AI Agent Context Poisoning). Opcional. Critico para skills que protegen el sistema agentico mismo. Referencia: https://atlas.mitre.org"
226
+ },
227
+ "attack_techniques": {
228
+ "type": "array",
229
+ "items": {
230
+ "type": "string",
231
+ "pattern": "^T[0-9]{4}(\\.[0-9]{3})?$"
232
+ },
233
+ "description": "Campo propio de swl-ses. Mapeo a MITRE ATT&CK v18. Cada entrada es una tecnica tipo 'T1071' (Application Layer Protocol), 'T1190' (Exploit Public-Facing Application). Opcional. Mas aplicable a skills de defensa de infraestructura o deteccion de amenazas en el sistema desplegado. Referencia: https://attack.mitre.org"
234
+ },
235
+ "d3fend_techniques": {
236
+ "type": "array",
237
+ "items": {
238
+ "type": "string",
239
+ "pattern": "^D3-[A-Z]+$"
240
+ },
241
+ "description": "Campo propio de swl-ses. Mapeo a MITRE D3FEND v1.3 (Defensive countermeasures). Cada entrada es una tecnica tipo 'D3-NTA' (Network Traffic Analysis), 'D3-PSA' (Process Spawn Analysis). Opcional. Referencia: https://d3fend.mitre.org"
242
+ }
243
+ },
244
+ "additionalProperties": true
245
+ }
@@ -82,7 +82,9 @@ function contarSkills(dir) {
82
82
 
83
83
  function recolectarAgentes() {
84
84
  const dir = path.join(RAIZ, 'agentes');
85
- const archivos = fs.readdirSync(dir).filter(f => f.endsWith('.md'));
85
+ // Excluir fragmentos compartidos (`_*.md`) no son agentes routables.
86
+ // Ver reglas/fragmentos-compartidos.md.
87
+ const archivos = fs.readdirSync(dir).filter(f => f.endsWith('.md') && !f.startsWith('_'));
86
88
  return archivos.map(f => {
87
89
  const fm = leerFrontmatter(path.join(dir, f));
88
90
  return {
@@ -0,0 +1,164 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * scripts/lib/schema-version.js
5
+ *
6
+ * Helper de compatibilidad de schemas JSON aplicando reglas backward/forward
7
+ * del libro "Designing Data-Intensive Applications" de Martin Kleppmann
8
+ * (Capítulo 4, "Encoding and Evolution", p.112).
9
+ *
10
+ * Reglas implementadas (cita textual del libro):
11
+ *
12
+ * "Backward compatibility — Newer code can read data that was written by
13
+ * older code.
14
+ *
15
+ * Forward compatibility — Older code can read data that was written by
16
+ * newer code."
17
+ *
18
+ * Aplicado a SWL: cuando un schema evoluciona, el helper indica si un
19
+ * documento dado puede leerse con el schema dado y bajo qué modalidad
20
+ * de compatibilidad.
21
+ *
22
+ * Convenciones SemVer asumidas para $schemaVersion:
23
+ * - MAJOR (X.0.0): breaking change (renombre, cambio de tipo, eliminación)
24
+ * - MINOR (1.X.0): campo nuevo opcional, enum value nuevo
25
+ * - PATCH (1.0.X): clarificación de descripción, sin cambio estructural
26
+ *
27
+ * Skill relacionado: proceso-ddia-fundamentos § Schema Evolution.
28
+ * ADR: 0026 — Versionado de schemas JSON con $schemaVersion.
29
+ */
30
+
31
+ /**
32
+ * Parsea un string SemVer "MAJOR.MINOR.PATCH" a tupla numérica.
33
+ * @param {string} version
34
+ * @returns {[number, number, number] | null}
35
+ */
36
+ function parsearVersion(version) {
37
+ if (typeof version !== 'string') return null;
38
+ const m = version.match(/^(\d+)\.(\d+)\.(\d+)$/);
39
+ if (!m) return null;
40
+ return [parseInt(m[1], 10), parseInt(m[2], 10), parseInt(m[3], 10)];
41
+ }
42
+
43
+ /**
44
+ * Verifica si un documento es compatible con un schema según sus $schemaVersion.
45
+ *
46
+ * @param {object} documento - Documento JSON con propiedad opcional $schemaVersion
47
+ * @param {object} schema - JSON Schema con propiedad opcional $schemaVersion
48
+ * @returns {{
49
+ * compatible: boolean,
50
+ * modo: "none" | "backward" | "forward" | "incompatible",
51
+ * advertencias: string[]
52
+ * }}
53
+ *
54
+ * Casos:
55
+ * - Ambos sin $schemaVersion → { compatible: true, modo: "none", advertencias: [warning] }
56
+ * - Documento sin, schema con → { compatible: true, modo: "forward", advertencias: [warning] }
57
+ * - Doc 1.0.0 vs Schema 1.0.0 → { compatible: true, modo: "none" }
58
+ * - Doc 1.0.0 vs Schema 1.1.0 → { compatible: true, modo: "forward" } (dato viejo + código nuevo)
59
+ * - Doc 1.1.0 vs Schema 1.0.0 → { compatible: true, modo: "backward" } (dato nuevo + código viejo)
60
+ * - Doc 2.0.0 vs Schema 1.0.0 → { compatible: false, modo: "incompatible" } (MAJOR rompe)
61
+ * - Doc 1.0.0 vs Schema 2.0.0 → { compatible: false, modo: "incompatible" }
62
+ * - Versión malformada → { compatible: false, modo: "incompatible", advertencias: [error] }
63
+ */
64
+ function verificarCompatibilidad(documento, schema) {
65
+ const advertencias = [];
66
+
67
+ const docVerStr = documento && documento.$schemaVersion;
68
+ const schVerStr = schema && schema.$schemaVersion;
69
+
70
+ if (!docVerStr && !schVerStr) {
71
+ return {
72
+ compatible: true,
73
+ modo: 'none',
74
+ advertencias: [
75
+ 'Ni documento ni schema declaran $schemaVersion. Compatibilidad asumida pero no verificable.',
76
+ ],
77
+ };
78
+ }
79
+
80
+ if (!docVerStr && schVerStr) {
81
+ return {
82
+ compatible: true,
83
+ modo: 'forward',
84
+ advertencias: [
85
+ `Documento sin $schemaVersion contra schema ${schVerStr}. Asumiendo forward-compat (código nuevo lee dato viejo sin versión).`,
86
+ ],
87
+ };
88
+ }
89
+
90
+ if (docVerStr && !schVerStr) {
91
+ return {
92
+ compatible: false,
93
+ modo: 'incompatible',
94
+ advertencias: [
95
+ `Documento declara $schemaVersion ${docVerStr} pero schema no la declara. Schema debe actualizarse a $schemaVersion para validación correcta.`,
96
+ ],
97
+ };
98
+ }
99
+
100
+ const docVer = parsearVersion(docVerStr);
101
+ const schVer = parsearVersion(schVerStr);
102
+
103
+ if (!docVer) {
104
+ return {
105
+ compatible: false,
106
+ modo: 'incompatible',
107
+ advertencias: [`Documento $schemaVersion malformada: "${docVerStr}". Debe ser MAJOR.MINOR.PATCH (ej: "1.0.0").`],
108
+ };
109
+ }
110
+ if (!schVer) {
111
+ return {
112
+ compatible: false,
113
+ modo: 'incompatible',
114
+ advertencias: [`Schema $schemaVersion malformada: "${schVerStr}". Debe ser MAJOR.MINOR.PATCH (ej: "1.0.0").`],
115
+ };
116
+ }
117
+
118
+ const [docMaj, docMin] = docVer;
119
+ const [schMaj, schMin] = schVer;
120
+
121
+ // MAJOR distinto → incompatible (regla DDIA Cap 4: MAJOR es breaking)
122
+ if (docMaj !== schMaj) {
123
+ return {
124
+ compatible: false,
125
+ modo: 'incompatible',
126
+ advertencias: [
127
+ `MAJOR diferente: documento ${docVerStr} vs schema ${schVerStr}. ` +
128
+ `Cambios MAJOR son breaking por convención SemVer. Migración explícita requerida.`,
129
+ ],
130
+ };
131
+ }
132
+
133
+ // Mismo MAJOR.MINOR → compatible total (PATCH no afecta estructura)
134
+ if (docMin === schMin) {
135
+ return { compatible: true, modo: 'none', advertencias: [] };
136
+ }
137
+
138
+ // Documento MINOR menor que schema → forward (código nuevo lee dato viejo)
139
+ if (docMin < schMin) {
140
+ return {
141
+ compatible: true,
142
+ modo: 'forward',
143
+ advertencias: [
144
+ `Documento ${docVerStr} más antiguo que schema ${schVerStr}. ` +
145
+ `Forward-compat: código nuevo debe ignorar campos nuevos ausentes en dato viejo.`,
146
+ ],
147
+ };
148
+ }
149
+
150
+ // Documento MINOR mayor que schema → backward (código viejo lee dato nuevo)
151
+ return {
152
+ compatible: true,
153
+ modo: 'backward',
154
+ advertencias: [
155
+ `Documento ${docVerStr} más nuevo que schema ${schVerStr}. ` +
156
+ `Backward-compat: código viejo debe ignorar campos desconocidos en dato nuevo.`,
157
+ ],
158
+ };
159
+ }
160
+
161
+ module.exports = {
162
+ parsearVersion,
163
+ verificarCompatibilidad,
164
+ };
@@ -188,7 +188,7 @@ function main() {
188
188
  const categorias = [
189
189
  { etiqueta: 'comandos/swl/', archivos: listarArchivos('comandos/swl', '.md') },
190
190
  { etiqueta: 'hooks/ (ejecutables)', archivos: hooksEjecutables },
191
- { etiqueta: 'agentes/', archivos: listarArchivos('agentes', '.md') },
191
+ { etiqueta: 'agentes/', archivos: listarArchivos('agentes', '.md').filter(a => !path.basename(a).startsWith('_')) },
192
192
  { etiqueta: 'habilidades/ (dirs)', archivos: listarDirectoriosHabilidades() },
193
193
  { etiqueta: 'reglas/', archivos: listarArchivos('reglas', '.md', true) },
194
194
  ];
@@ -63,8 +63,9 @@ if (fs.existsSync(hooksConfigPath)) {
63
63
  }
64
64
  }
65
65
 
66
- // 5. Agentes (mínimo 12)
67
- const agentes = fs.readdirSync(path.join(RAIZ, 'agentes')).filter(f => f.endsWith('.md'));
66
+ // 5. Agentes (mínimo 12) — excluye fragmentos compartidos (`_*.md`, ver `reglas/fragmentos-compartidos.md`)
67
+ const agentes = fs.readdirSync(path.join(RAIZ, 'agentes'))
68
+ .filter(f => f.endsWith('.md') && !f.startsWith('_'));
68
69
  verificar(agentes.length >= 12, `Agentes: ${agentes.length} (mínimo 12)`);
69
70
 
70
71
  // Verificar frontmatter en agentes