@saulwade/swl-ses 1.3.8 → 1.4.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 (148) hide show
  1. package/CLAUDE.md +15 -6
  2. package/README.md +15 -14
  3. package/agentes/nemesis-auditor-swl.md +161 -0
  4. package/bin/swl-mcp-server.js +187 -187
  5. package/bin/swl-webhook-server.js +198 -0
  6. package/comandos/swl/.evolved.json +22 -22
  7. package/comandos/swl/adoptar-proyecto.md +21 -1
  8. package/comandos/swl/claudemd.md +14 -1
  9. package/comandos/swl/contribuir.md +233 -233
  10. package/comandos/swl/exportar-vault.md +108 -0
  11. package/comandos/swl/nemesis.md +122 -0
  12. package/comandos/swl/nuevo-proyecto.md +24 -2
  13. package/comandos/swl/salud.md +34 -0
  14. package/comandos/swl/verificar.md +45 -0
  15. package/gateway/adapters/base.js +109 -0
  16. package/gateway/adapters/discord.js +167 -0
  17. package/gateway/adapters/email.js +221 -0
  18. package/gateway/adapters/slack.js +192 -0
  19. package/gateway/adapters/telegram.js +183 -0
  20. package/gateway/adapters/webhook.js +113 -0
  21. package/gateway/adapters/whatsapp.js +214 -0
  22. package/gateway/agent-executor.js +322 -0
  23. package/gateway/command-relay.js +271 -0
  24. package/gateway/cron/jobs.js +263 -0
  25. package/gateway/cron/scheduler.js +322 -0
  26. package/gateway/cron/store.js +335 -0
  27. package/gateway/index.js +320 -0
  28. package/gateway/lib/event-channel.js +191 -0
  29. package/gateway/session.js +131 -0
  30. package/gateway/webhook-server.js +324 -0
  31. package/habilidades/backend-production-resilience/SKILL.md +288 -288
  32. package/habilidades/benchmark-memoria/SKILL.md +186 -186
  33. package/habilidades/build-errors-nextjs/SKILL.md +55 -1
  34. package/habilidades/diagrama-arquitectura/assets/template.html +276 -276
  35. package/habilidades/doubt-driven-review/SKILL.md +171 -171
  36. package/habilidades/doubt-driven-review/recursos/EXAMPLES.md +130 -130
  37. package/habilidades/eval-framework/SKILL.md +212 -212
  38. package/habilidades/extractor-de-aprendizajes/SKILL.md +20 -10
  39. package/habilidades/feynman-auditor-swl/SKILL.md +123 -0
  40. package/habilidades/feynman-auditor-swl/recursos/preguntas-language-agnostic.md +108 -0
  41. package/habilidades/harness-claude-code/SKILL.md +299 -299
  42. package/habilidades/infra-github-actions/SKILL.md +166 -166
  43. package/habilidades/legacy-code-rescue/SKILL.md +267 -267
  44. package/habilidades/manejo-errores/.evolved.json +8 -8
  45. package/habilidades/meta-skills-estandar/recursos/convencion-examples.md +93 -93
  46. package/habilidades/meta-skills-estandar/recursos/skills-as-agents.md +163 -163
  47. package/habilidades/nextjs-testing/SKILL.md +89 -5
  48. package/habilidades/node-experto/SKILL.md +37 -1
  49. package/habilidades/patrones-python/SKILL.md +229 -229
  50. package/habilidades/patrones-python/recursos/patrones-avanzados.md +469 -469
  51. package/habilidades/planear-fase/SKILL.md +319 -319
  52. package/habilidades/react-experto/SKILL.md +45 -4
  53. package/habilidades/release-semver/.evolved.json +8 -8
  54. package/habilidades/state-inconsistency-auditor-swl/SKILL.md +166 -0
  55. package/habilidades/state-inconsistency-auditor-swl/recursos/coupled-state-patterns.md +147 -0
  56. package/habilidades/tdd-workflow/SKILL.md +36 -4
  57. package/habilidades/testing-python/SKILL.md +340 -340
  58. package/habilidades/web-fetcher-routing/SKILL.md +75 -0
  59. package/hooks/claudemd-bloat-detector.js +161 -161
  60. package/hooks/inyeccion-contexto.js +8 -3
  61. package/hooks/lib/agent-routing.js +107 -107
  62. package/hooks/lib/auto-consolidator.js +335 -335
  63. package/hooks/lib/error-classifier.js +308 -308
  64. package/hooks/lib/merkle-audit.js +96 -96
  65. package/hooks/lib/provenance-tracker.js +191 -191
  66. package/hooks/lib/rate-limit-ip.js +177 -0
  67. package/hooks/lib/rate-limit-tracker.js +253 -253
  68. package/hooks/lib/resource-quota.js +122 -122
  69. package/hooks/lib/retry-jitter.js +165 -165
  70. package/hooks/lib/security-net.js +201 -0
  71. package/hooks/lib/skill-auditor.js +588 -588
  72. package/hooks/lib/sync-status.js +228 -228
  73. package/hooks/lib/taint-tracker.js +107 -107
  74. package/hooks/lib/text-similarity.js +241 -241
  75. package/hooks/lib/toon-compressor.js +245 -245
  76. package/hooks/lib/webhook-dedup.js +184 -0
  77. package/hooks/lib/webhook-verify.js +123 -0
  78. package/hooks/proteccion-rutas.js +120 -15
  79. package/hooks/registro-turnos.js +209 -209
  80. package/hooks/sugerir-regenerar-inventario.js +170 -170
  81. package/hooks/validar-formato-post-subagente.js +140 -140
  82. package/hooks/validar-memoria-hook.js +218 -218
  83. package/instintos/prompt-appendices.yaml +57 -57
  84. package/manifiestos/agent-output-schemas.json +57 -57
  85. package/manifiestos/modulos.json +31 -0
  86. package/manifiestos/skills-lock.json +1114 -1093
  87. package/package.json +6 -4
  88. package/plantillas/auditor-veto-template.md +105 -105
  89. package/plantillas/github-workflows/README.md +47 -47
  90. package/plantillas/github-workflows/release-please.yml +44 -44
  91. package/plantillas/github-workflows/swl-ci.yml +107 -107
  92. package/plantillas/github-workflows/swl-security.yml +51 -51
  93. package/plugin.json +2 -2
  94. package/reglas/analisis-previo-tareas-grandes.md +172 -172
  95. package/reglas/arreglar-al-detectar.md +147 -147
  96. package/reglas/fragmentos-compartidos.md +152 -152
  97. package/reglas/harness-claude-code.md +213 -213
  98. package/reglas/usar-context7.md +226 -226
  99. package/reglas/usar-sistema-swl.md +251 -0
  100. package/schemas/diary-entry.schema.json +80 -80
  101. package/scripts/audit-tools/audit-history.js +330 -0
  102. package/scripts/audit-tools/bundle-tracker.js +290 -0
  103. package/scripts/audit-tools/canary-monitor.js +352 -0
  104. package/scripts/audit-tools/code-profiler.js +605 -0
  105. package/scripts/audit-tools/dep-doctor.js +320 -0
  106. package/scripts/audit-tools/env-validator.js +206 -0
  107. package/scripts/audit-tools/lib/fs-walk.js +48 -0
  108. package/scripts/audit-tools/lib/output.js +23 -0
  109. package/scripts/audit-tools/migration-checker.js +392 -0
  110. package/scripts/audit-tools/pentest-scanner.js +1436 -0
  111. package/scripts/benchmark-memoria.js +167 -167
  112. package/scripts/comandos/skills.js +251 -2
  113. package/scripts/configurar-branch-protection.js +418 -418
  114. package/scripts/detectar-aprendizajes-duplicados.js +151 -151
  115. package/scripts/field-report.js +199 -199
  116. package/scripts/generar-checklists-consolidados.js +273 -273
  117. package/scripts/generar-inventario.js +420 -420
  118. package/scripts/generar-matriz-lenguajes.js +271 -271
  119. package/scripts/lib/artefactos-python.js +43 -43
  120. package/scripts/lib/benchmark-metrics.js +160 -160
  121. package/scripts/lib/budget-enforcer.js +252 -252
  122. package/scripts/lib/configurar-ci.js +380 -380
  123. package/scripts/lib/contadores-inventario.js +217 -217
  124. package/scripts/lib/detectar-stack-detallado.js +307 -307
  125. package/scripts/lib/diary-entry.js +234 -234
  126. package/scripts/lib/eval-metrics-store.js +218 -218
  127. package/scripts/lib/eval-quality.js +171 -171
  128. package/scripts/lib/eval-schemas.js +144 -144
  129. package/scripts/lib/eval-self-correct.js +106 -106
  130. package/scripts/lib/eval-validator.js +185 -185
  131. package/scripts/lib/jaccard-similarity.js +98 -98
  132. package/scripts/lib/longmemeval-runner.js +125 -125
  133. package/scripts/lib/npm-version.js +261 -261
  134. package/scripts/lib/paquetes-conocidos.js +50 -50
  135. package/scripts/lib/prompt-builder.js +264 -264
  136. package/scripts/lib/rrf-fusion.js +175 -175
  137. package/scripts/lib/scoring-instintos.js +277 -277
  138. package/scripts/lib/semantic-search.js +252 -252
  139. package/scripts/limpiar-artefactos-python.js +131 -131
  140. package/scripts/mcp-server/README.md +128 -128
  141. package/scripts/mcp-server/handlers.js +206 -206
  142. package/scripts/migrar-csv-a-array.js +168 -168
  143. package/scripts/migrar-fase-dominio.js +201 -201
  144. package/scripts/publicar.js +511 -511
  145. package/scripts/run-eval.js +141 -141
  146. package/scripts/validar-manifest.js +195 -195
  147. package/scripts/validar-userland-vacio.js +110 -110
  148. package/scripts/verificar-release.js +110 -0
@@ -0,0 +1,392 @@
1
+ // Adaptado de temp/ultraship-main/tools/migration-checker.mjs bajo MIT License
2
+ // Fuente: Houseofmvps/ultraship (https://github.com/Houseofmvps/ultraship)
3
+ 'use strict';
4
+
5
+ const { readFileSync, existsSync, readdirSync, statSync } = require('fs');
6
+ const { join, relative, resolve } = require('path');
7
+ const { outputJSON, outputError } = require('./lib/output');
8
+
9
+ /**
10
+ * Detecta el ORM de un directorio revisando package.json o archivos Python.
11
+ * @param {string} dir
12
+ * @returns {string|null}
13
+ */
14
+ function detectOrm(dir) {
15
+ // Verificar primero ORM de Python (Alembic)
16
+ const alembicDetected = (
17
+ existsSync(join(dir, 'alembic.ini')) ||
18
+ (existsSync(join(dir, 'alembic')) && existsSync(join(dir, 'alembic', 'versions')))
19
+ );
20
+ if (alembicDetected) return 'alembic';
21
+
22
+ // Verificar requirements.txt / pyproject.toml para alembic
23
+ const reqPath = join(dir, 'requirements.txt');
24
+ if (existsSync(reqPath)) {
25
+ const content = readFileSync(reqPath, 'utf8').toLowerCase();
26
+ if (content.includes('alembic')) return 'alembic';
27
+ }
28
+ const pyprojectPath = join(dir, 'pyproject.toml');
29
+ if (existsSync(pyprojectPath)) {
30
+ const content = readFileSync(pyprojectPath, 'utf8').toLowerCase();
31
+ if (content.includes('alembic')) return 'alembic';
32
+ }
33
+
34
+ // ORM de Node.js desde package.json
35
+ const pkgPath = join(dir, 'package.json');
36
+ if (!existsSync(pkgPath)) return null;
37
+
38
+ let pkg;
39
+ try {
40
+ pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
41
+ } catch {
42
+ return null;
43
+ }
44
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
45
+
46
+ if (allDeps['drizzle-orm'] || allDeps['drizzle-kit']) return 'drizzle';
47
+ if (allDeps['prisma'] || allDeps['@prisma/client']) return 'prisma';
48
+ if (allDeps['knex']) return 'knex';
49
+ if (allDeps['typeorm']) return 'typeorm';
50
+ if (allDeps['sequelize']) return 'sequelize';
51
+ if (allDeps['mongoose']) return 'mongoose';
52
+ return null;
53
+ }
54
+
55
+ /**
56
+ * Revisa migraciones de Drizzle ORM.
57
+ * @param {string} dir
58
+ * @returns {object}
59
+ */
60
+ function checkDrizzle(dir) {
61
+ const findings = [];
62
+ const info = { orm: 'drizzle', migration_dir: null, schema_files: [], migrations: [] };
63
+
64
+ // Buscar config de Drizzle
65
+ const configNames = ['drizzle.config.ts', 'drizzle.config.js', 'drizzle.config.mjs'];
66
+ let configPath = null;
67
+ for (const name of configNames) {
68
+ const p = join(dir, name);
69
+ if (existsSync(p)) { configPath = p; break; }
70
+ }
71
+
72
+ if (!configPath) {
73
+ findings.push({ severity: 'high', message: 'No se encontró drizzle.config — las migraciones podrían no estar configuradas' });
74
+ } else {
75
+ const config = readFileSync(configPath, 'utf8');
76
+ const outMatch = config.match(/out\s*:\s*['"]([^'"]+)['"]/);
77
+ if (outMatch) info.migration_dir = outMatch[1];
78
+ }
79
+
80
+ // Buscar directorio de migraciones
81
+ const migrationDirs = [info.migration_dir, 'drizzle', 'migrations', 'db/migrations'].filter(Boolean);
82
+ let migDir = null;
83
+ for (const d of migrationDirs) {
84
+ const p = join(dir, d);
85
+ try {
86
+ if (existsSync(p) && statSync(p).isDirectory()) { migDir = p; info.migration_dir = d; break; }
87
+ } catch { /* skip */ }
88
+ }
89
+
90
+ if (migDir) {
91
+ const files = readdirSync(migDir).filter(f => f.endsWith('.sql') || f.endsWith('.ts') || f.endsWith('.js'));
92
+ info.migrations = files.map(f => {
93
+ try {
94
+ const s = statSync(join(migDir, f));
95
+ return { name: f, modified: s.mtime.toISOString().split('T')[0] };
96
+ } catch { return { name: f }; }
97
+ });
98
+ info.migration_count = files.length;
99
+
100
+ // Verificar journal (Drizzle registra migraciones aplicadas)
101
+ const journalPath = join(migDir, 'meta', '_journal.json');
102
+ if (existsSync(journalPath)) {
103
+ try {
104
+ const journal = JSON.parse(readFileSync(journalPath, 'utf8'));
105
+ info.applied_count = journal.entries ? journal.entries.length : 0;
106
+ if (info.migration_count > info.applied_count) {
107
+ findings.push({
108
+ severity: 'critical',
109
+ message: `${info.migration_count - info.applied_count} migración(es) pendiente(s) sin aplicar — ejecutar: npx drizzle-kit push`,
110
+ });
111
+ }
112
+ } catch { /* ignorar */ }
113
+ }
114
+ } else {
115
+ findings.push({ severity: 'medium', message: 'No se encontró directorio de migraciones — ejecutar: npx drizzle-kit generate' });
116
+ }
117
+
118
+ // Buscar archivos de schema
119
+ const schemaPatterns = ['schema.ts', 'schema.js', 'db/schema.ts', 'src/db/schema.ts', 'src/schema.ts'];
120
+ for (const pattern of schemaPatterns) {
121
+ if (existsSync(join(dir, pattern))) info.schema_files.push(pattern);
122
+ }
123
+ const schemaDirs = ['src/db', 'db', 'src/schema'];
124
+ for (const d of schemaDirs) {
125
+ const p = join(dir, d);
126
+ try {
127
+ if (existsSync(p) && statSync(p).isDirectory()) {
128
+ const files = readdirSync(p).filter(f => f.includes('schema') && (f.endsWith('.ts') || f.endsWith('.js')));
129
+ for (const f of files) info.schema_files.push(join(d, f));
130
+ }
131
+ } catch { /* skip */ }
132
+ }
133
+
134
+ if (info.schema_files.length === 0) {
135
+ findings.push({ severity: 'high', message: 'No se encontraron archivos de schema — Drizzle ORM requiere definiciones de schema' });
136
+ }
137
+
138
+ return { ...info, findings };
139
+ }
140
+
141
+ /**
142
+ * Revisa migraciones de Prisma.
143
+ * @param {string} dir
144
+ * @returns {object}
145
+ */
146
+ function checkPrisma(dir) {
147
+ const findings = [];
148
+ const info = { orm: 'prisma', schema_file: null, migrations: [] };
149
+
150
+ const schemaPaths = ['prisma/schema.prisma', 'schema.prisma'];
151
+ for (const p of schemaPaths) {
152
+ if (existsSync(join(dir, p))) { info.schema_file = p; break; }
153
+ }
154
+
155
+ if (!info.schema_file) {
156
+ findings.push({ severity: 'critical', message: 'No se encontró prisma/schema.prisma' });
157
+ return { ...info, findings };
158
+ }
159
+
160
+ const migDir = join(dir, 'prisma/migrations');
161
+ try {
162
+ if (existsSync(migDir) && statSync(migDir).isDirectory()) {
163
+ const dirs = readdirSync(migDir).filter(f => {
164
+ try {
165
+ const p = join(migDir, f);
166
+ return statSync(p).isDirectory() && f !== '_lock';
167
+ } catch { return false; }
168
+ });
169
+ info.migrations = dirs.map(d => ({ name: d }));
170
+ info.migration_count = dirs.length;
171
+ } else {
172
+ findings.push({ severity: 'medium', message: 'No se encontró directorio de migraciones de Prisma — ejecutar: npx prisma migrate dev' });
173
+ }
174
+ } catch { /* skip */ }
175
+
176
+ const nodeModulesPrisma = join(dir, 'node_modules/.prisma/client');
177
+ if (!existsSync(nodeModulesPrisma)) {
178
+ findings.push({ severity: 'high', message: 'Cliente de Prisma no generado — ejecutar: npx prisma generate' });
179
+ }
180
+
181
+ return { ...info, findings };
182
+ }
183
+
184
+ /**
185
+ * Revisa migraciones de Knex.
186
+ * @param {string} dir
187
+ * @returns {object}
188
+ */
189
+ function checkKnex(dir) {
190
+ const findings = [];
191
+ const info = { orm: 'knex', migration_dir: null, migrations: [] };
192
+
193
+ const knexfileNames = ['knexfile.js', 'knexfile.ts', 'knexfile.mjs'];
194
+ let found = false;
195
+ for (const name of knexfileNames) {
196
+ if (existsSync(join(dir, name))) { found = true; break; }
197
+ }
198
+
199
+ if (!found) {
200
+ findings.push({ severity: 'medium', message: 'No se encontró knexfile — la configuración de migraciones podría estar inline' });
201
+ }
202
+
203
+ const migDirs = ['migrations', 'db/migrations', 'src/migrations'];
204
+ for (const d of migDirs) {
205
+ const p = join(dir, d);
206
+ try {
207
+ if (existsSync(p) && statSync(p).isDirectory()) {
208
+ info.migration_dir = d;
209
+ const files = readdirSync(p).filter(f => f.endsWith('.js') || f.endsWith('.ts'));
210
+ info.migrations = files.map(f => ({ name: f }));
211
+ info.migration_count = files.length;
212
+ break;
213
+ }
214
+ } catch { /* skip */ }
215
+ }
216
+
217
+ if (!info.migration_dir) {
218
+ findings.push({ severity: 'medium', message: 'No se encontró directorio de migraciones — ejecutar: npx knex migrate:make initial' });
219
+ }
220
+
221
+ return { ...info, findings };
222
+ }
223
+
224
+ /**
225
+ * Revisa migraciones de Alembic (Python/SQLAlchemy).
226
+ * Detecta mediante alembic.ini, directorio alembic/versions/, requirements.txt o pyproject.toml.
227
+ * Compara revisiones encontradas en archivos contra .alembic_applied.txt (opcional).
228
+ * @param {string} dir
229
+ * @returns {object}
230
+ */
231
+ function checkAlembic(dir) {
232
+ const findings = [];
233
+ const info = {
234
+ orm: 'alembic',
235
+ versions_dir: null,
236
+ revisions_found: [],
237
+ revisions_applied: null,
238
+ pending: [],
239
+ extra_applied: [],
240
+ };
241
+
242
+ // Localizar directorio de versiones
243
+ const versionsDir = join(dir, 'alembic', 'versions');
244
+ if (existsSync(versionsDir)) {
245
+ info.versions_dir = 'alembic/versions';
246
+ }
247
+
248
+ if (!info.versions_dir) {
249
+ findings.push({
250
+ severity: 'medium',
251
+ message: 'No se encontró directorio alembic/versions/ — ejecutar: alembic init alembic',
252
+ });
253
+ return { ...info, findings };
254
+ }
255
+
256
+ // Parsear revision IDs de archivos de migración Python
257
+ let versionFiles = [];
258
+ try {
259
+ versionFiles = readdirSync(versionsDir).filter(f => f.endsWith('.py') && f !== '__init__.py');
260
+ } catch {
261
+ findings.push({ severity: 'high', message: `No se pudo leer el directorio ${info.versions_dir}` });
262
+ return { ...info, findings };
263
+ }
264
+
265
+ const revisionRegex = /revision\s*=\s*['"]([^'"]+)['"]/;
266
+ for (const file of versionFiles) {
267
+ try {
268
+ const content = readFileSync(join(versionsDir, file), 'utf8');
269
+ const match = content.match(revisionRegex);
270
+ if (match) {
271
+ info.revisions_found.push({ revision: match[1], file });
272
+ }
273
+ } catch { /* skip archivos no legibles */ }
274
+ }
275
+
276
+ if (info.revisions_found.length === 0 && versionFiles.length > 0) {
277
+ findings.push({
278
+ severity: 'medium',
279
+ message: `Se encontraron ${versionFiles.length} archivo(s) en alembic/versions/ pero ninguno tiene campo 'revision' — revisar formato`,
280
+ });
281
+ }
282
+
283
+ // Comparar contra .alembic_applied.txt (opcional)
284
+ const appliedPath = join(dir, '.alembic_applied.txt');
285
+ if (existsSync(appliedPath)) {
286
+ try {
287
+ const appliedContent = readFileSync(appliedPath, 'utf8');
288
+ const appliedRevisions = new Set(
289
+ appliedContent.split('\n').map(l => l.trim()).filter(Boolean)
290
+ );
291
+ info.revisions_applied = [...appliedRevisions];
292
+
293
+ const foundRevisions = new Set(info.revisions_found.map(r => r.revision));
294
+
295
+ // Pendientes: en archivos pero no aplicadas
296
+ info.pending = info.revisions_found
297
+ .filter(r => !appliedRevisions.has(r.revision))
298
+ .map(r => r.revision);
299
+
300
+ // Extra: aplicadas pero no en archivos (posible eliminación de migración)
301
+ info.extra_applied = [...appliedRevisions].filter(r => !foundRevisions.has(r));
302
+
303
+ if (info.pending.length > 0) {
304
+ findings.push({
305
+ severity: 'critical',
306
+ message: `${info.pending.length} migración(es) de Alembic pendiente(s) sin aplicar — ejecutar: alembic upgrade head`,
307
+ pending_revisions: info.pending,
308
+ });
309
+ }
310
+
311
+ if (info.extra_applied.length > 0) {
312
+ findings.push({
313
+ severity: 'high',
314
+ message: `${info.extra_applied.length} revisión(es) aplicada(s) no encontradas en archivos — posible eliminación de migración`,
315
+ extra_revisions: info.extra_applied,
316
+ });
317
+ }
318
+ } catch {
319
+ findings.push({ severity: 'low', message: 'No se pudo leer .alembic_applied.txt — sin comparación de estado aplicado' });
320
+ }
321
+ } else {
322
+ // Sin archivo de aplicadas — solo reportar conteo
323
+ if (info.revisions_found.length > 0) {
324
+ findings.push({
325
+ severity: 'info',
326
+ message: `${info.revisions_found.length} revisión(es) de Alembic encontradas. Crear .alembic_applied.txt con IDs aplicados para rastrear estado`,
327
+ });
328
+ }
329
+ }
330
+
331
+ info.revision_count = info.revisions_found.length;
332
+
333
+ return { ...info, findings };
334
+ }
335
+
336
+ function main() {
337
+ const args = process.argv.slice(2);
338
+ const rawDir = args.find(a => !a.startsWith('--'));
339
+ const dir = resolve(rawDir || process.cwd());
340
+
341
+ if (!existsSync(dir)) {
342
+ outputError(`Directorio no encontrado: ${dir}`);
343
+ process.exit(0);
344
+ }
345
+
346
+ const orm = detectOrm(dir);
347
+
348
+ if (!orm) {
349
+ outputJSON({
350
+ success: true,
351
+ packages_scanned: 1,
352
+ orm: null,
353
+ message: 'No se detectó un ORM compatible (Drizzle, Prisma, Knex, Alembic, TypeORM, Sequelize)',
354
+ findings: [],
355
+ });
356
+ process.exit(0);
357
+ }
358
+
359
+ let result;
360
+ switch (orm) {
361
+ case 'drizzle': result = checkDrizzle(dir); break;
362
+ case 'prisma': result = checkPrisma(dir); break;
363
+ case 'knex': result = checkKnex(dir); break;
364
+ case 'alembic': result = checkAlembic(dir); break;
365
+ default:
366
+ result = {
367
+ orm,
368
+ findings: [{
369
+ severity: 'info',
370
+ message: `${orm} detectado pero la verificación de migraciones aún no está implementada para este ORM`,
371
+ }],
372
+ };
373
+ }
374
+
375
+ const allFindings = result.findings || [];
376
+ const deploySafe = allFindings.filter(f => f.severity === 'critical').length === 0;
377
+
378
+ outputJSON({
379
+ success: true,
380
+ packages_scanned: 1,
381
+ deploy_safe: deploySafe,
382
+ orm,
383
+ result,
384
+ findings: allFindings,
385
+ });
386
+ }
387
+
388
+ if (require.main === module) {
389
+ main();
390
+ }
391
+
392
+ module.exports = { detectOrm, checkDrizzle, checkPrisma, checkKnex, checkAlembic };