@saulwade/swl-ses 1.4.1 → 1.4.2
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.
- package/CLAUDE.md +1 -1
- package/README.md +1 -1
- package/agentes/nemesis-auditor-swl.md +161 -161
- package/bin/swl-mcp-server.js +187 -187
- package/comandos/swl/.evolved.json +22 -22
- package/comandos/swl/contribuir.md +233 -233
- package/comandos/swl/nemesis.md +122 -122
- package/gateway/lib/event-channel.js +191 -191
- package/habilidades/backend-production-resilience/SKILL.md +288 -288
- package/habilidades/benchmark-memoria/SKILL.md +186 -186
- package/habilidades/diagrama-arquitectura/assets/template.html +276 -276
- package/habilidades/doubt-driven-review/SKILL.md +171 -171
- package/habilidades/doubt-driven-review/recursos/EXAMPLES.md +130 -130
- package/habilidades/eval-framework/SKILL.md +212 -212
- package/habilidades/feynman-auditor-swl/SKILL.md +123 -123
- package/habilidades/feynman-auditor-swl/recursos/preguntas-language-agnostic.md +108 -108
- package/habilidades/harness-claude-code/SKILL.md +299 -299
- package/habilidades/infra-github-actions/SKILL.md +166 -166
- package/habilidades/legacy-code-rescue/SKILL.md +267 -267
- package/habilidades/manejo-errores/.evolved.json +8 -8
- package/habilidades/meta-skills-estandar/recursos/convencion-examples.md +93 -93
- package/habilidades/meta-skills-estandar/recursos/skills-as-agents.md +163 -163
- package/habilidades/patrones-python/SKILL.md +229 -229
- package/habilidades/patrones-python/recursos/patrones-avanzados.md +469 -469
- package/habilidades/planear-fase/SKILL.md +319 -319
- package/habilidades/release-semver/.evolved.json +8 -8
- package/habilidades/state-inconsistency-auditor-swl/SKILL.md +166 -166
- package/habilidades/state-inconsistency-auditor-swl/recursos/coupled-state-patterns.md +147 -147
- package/habilidades/testing-python/SKILL.md +340 -340
- package/habilidades/web-fetcher-routing/SKILL.md +75 -75
- package/hooks/claudemd-bloat-detector.js +161 -161
- package/hooks/lib/agent-routing.js +107 -107
- package/hooks/lib/auto-consolidator.js +335 -335
- package/hooks/lib/error-classifier.js +308 -308
- package/hooks/lib/merkle-audit.js +96 -96
- package/hooks/lib/provenance-tracker.js +191 -191
- package/hooks/lib/rate-limit-tracker.js +253 -253
- package/hooks/lib/resource-quota.js +122 -122
- package/hooks/lib/retry-jitter.js +165 -165
- package/hooks/lib/security-net.js +201 -201
- package/hooks/lib/skill-auditor.js +588 -588
- package/hooks/lib/sync-status.js +228 -228
- package/hooks/lib/taint-tracker.js +107 -107
- package/hooks/lib/text-similarity.js +241 -241
- package/hooks/lib/toon-compressor.js +245 -245
- package/hooks/registro-turnos.js +209 -209
- package/hooks/sugerir-regenerar-inventario.js +170 -170
- package/hooks/validar-formato-post-subagente.js +140 -140
- package/hooks/validar-memoria-hook.js +218 -218
- package/instintos/prompt-appendices.yaml +57 -57
- package/manifiestos/agent-output-schemas.json +57 -57
- package/manifiestos/modulos.json +11 -6
- package/manifiestos/perfiles.json +2 -1
- package/manifiestos/skills-lock.json +1114 -1114
- package/package.json +1 -1
- package/plantillas/auditor-veto-template.md +105 -105
- package/plantillas/github-workflows/README.md +47 -47
- package/plantillas/github-workflows/release-please.yml +44 -44
- package/plantillas/github-workflows/swl-ci.yml +107 -107
- package/plantillas/github-workflows/swl-security.yml +51 -51
- package/plugin.json +9 -1
- package/reglas/analisis-previo-tareas-grandes.md +172 -172
- package/reglas/arreglar-al-detectar.md +147 -147
- package/reglas/fragmentos-compartidos.md +152 -152
- package/reglas/harness-claude-code.md +213 -213
- package/reglas/usar-context7.md +226 -226
- package/schemas/diary-entry.schema.json +80 -80
- package/scripts/audit-tools/audit-history.js +330 -330
- package/scripts/audit-tools/bundle-tracker.js +290 -290
- package/scripts/audit-tools/canary-monitor.js +352 -352
- package/scripts/audit-tools/code-profiler.js +605 -605
- package/scripts/audit-tools/dep-doctor.js +320 -320
- package/scripts/audit-tools/env-validator.js +206 -206
- package/scripts/audit-tools/lib/fs-walk.js +48 -48
- package/scripts/audit-tools/lib/output.js +23 -23
- package/scripts/audit-tools/migration-checker.js +392 -392
- package/scripts/audit-tools/pentest-scanner.js +1436 -1436
- package/scripts/benchmark-memoria.js +167 -167
- package/scripts/configurar-branch-protection.js +418 -418
- package/scripts/detectar-aprendizajes-duplicados.js +151 -151
- package/scripts/field-report.js +199 -199
- package/scripts/generar-checklists-consolidados.js +273 -273
- package/scripts/generar-inventario.js +420 -420
- package/scripts/generar-matriz-lenguajes.js +271 -271
- package/scripts/lib/artefactos-python.js +43 -43
- package/scripts/lib/benchmark-metrics.js +160 -160
- package/scripts/lib/budget-enforcer.js +252 -252
- package/scripts/lib/configurar-ci.js +380 -380
- package/scripts/lib/contadores-inventario.js +217 -217
- package/scripts/lib/detectar-stack-detallado.js +307 -307
- package/scripts/lib/diary-entry.js +234 -234
- package/scripts/lib/eval-metrics-store.js +218 -218
- package/scripts/lib/eval-quality.js +171 -171
- package/scripts/lib/eval-schemas.js +144 -144
- package/scripts/lib/eval-self-correct.js +106 -106
- package/scripts/lib/eval-validator.js +185 -185
- package/scripts/lib/jaccard-similarity.js +98 -98
- package/scripts/lib/longmemeval-runner.js +125 -125
- package/scripts/lib/manifiestos.js +42 -1
- package/scripts/lib/npm-version.js +261 -261
- package/scripts/lib/paquetes-conocidos.js +50 -50
- package/scripts/lib/prompt-builder.js +264 -264
- package/scripts/lib/rrf-fusion.js +175 -175
- package/scripts/lib/scoring-instintos.js +277 -277
- package/scripts/lib/semantic-search.js +252 -252
- package/scripts/limpiar-artefactos-python.js +131 -131
- package/scripts/mcp-server/README.md +128 -128
- package/scripts/mcp-server/handlers.js +206 -206
- package/scripts/migrar-csv-a-array.js +168 -168
- package/scripts/migrar-fase-dominio.js +201 -201
- package/scripts/publicar.js +511 -511
- package/scripts/run-eval.js +141 -141
- package/scripts/validar-manifest.js +231 -195
- package/scripts/validar-userland-vacio.js +110 -110
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
// Adaptado de temp/ultraship-main/tools/env-validator.mjs bajo MIT License
|
|
2
|
-
// Fuente: Houseofmvps/ultraship (https://github.com/Houseofmvps/ultraship)
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const { readFileSync, existsSync } = require('fs');
|
|
6
|
-
const { join, basename, resolve } = require('path');
|
|
7
|
-
const { outputJSON, outputError } = require('./lib/output');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Parsea un archivo .env y devuelve un mapa clave→valor.
|
|
11
|
-
* Maneja comillas simples/dobles y comentarios con #.
|
|
12
|
-
* @param {string} filePath
|
|
13
|
-
* @returns {Record<string, string>}
|
|
14
|
-
*/
|
|
15
|
-
function parseEnvFile(filePath) {
|
|
16
|
-
let content;
|
|
17
|
-
try {
|
|
18
|
-
content = readFileSync(filePath, 'utf8');
|
|
19
|
-
} catch {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const vars = {};
|
|
24
|
-
for (const line of content.split('\n')) {
|
|
25
|
-
const trimmed = line.trim();
|
|
26
|
-
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
27
|
-
const match = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)(\s*=\s*)(.*)/);
|
|
28
|
-
if (!match) continue;
|
|
29
|
-
const key = match[1];
|
|
30
|
-
let value = match[3].trim();
|
|
31
|
-
// Eliminar comillas envolventes
|
|
32
|
-
if (
|
|
33
|
-
(value.startsWith('"') && value.endsWith('"')) ||
|
|
34
|
-
(value.startsWith("'") && value.endsWith("'"))
|
|
35
|
-
) {
|
|
36
|
-
value = value.slice(1, -1);
|
|
37
|
-
}
|
|
38
|
-
vars[key] = value;
|
|
39
|
-
}
|
|
40
|
-
return vars;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Detecta si un valor es claramente un placeholder.
|
|
45
|
-
* @param {string} value
|
|
46
|
-
* @returns {boolean}
|
|
47
|
-
*/
|
|
48
|
-
function isPlaceholder(value) {
|
|
49
|
-
if (!value) return false;
|
|
50
|
-
const v = value.toLowerCase();
|
|
51
|
-
return (
|
|
52
|
-
v.includes('your_') ||
|
|
53
|
-
v.includes('xxx') ||
|
|
54
|
-
v.includes('placeholder') ||
|
|
55
|
-
v.includes('change_me') ||
|
|
56
|
-
v.includes('todo') ||
|
|
57
|
-
v.includes('replace') ||
|
|
58
|
-
v.includes('your-') ||
|
|
59
|
-
v === 'sk-...' ||
|
|
60
|
-
v === 'pk_...' ||
|
|
61
|
-
/^[a-z_]+_here$/i.test(v)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function main() {
|
|
66
|
-
const args = process.argv.slice(2);
|
|
67
|
-
const rawDir = args.find(a => !a.startsWith('--'));
|
|
68
|
-
const dir = resolve(rawDir || process.cwd());
|
|
69
|
-
|
|
70
|
-
if (!existsSync(dir)) {
|
|
71
|
-
outputError(`Directorio no encontrado: ${dir}`);
|
|
72
|
-
process.exit(0);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Buscar archivo de variables de entorno de ejemplo
|
|
76
|
-
const exampleNames = ['.env.example', '.env.sample', '.env.template', '.env.defaults'];
|
|
77
|
-
let exampleFile = null;
|
|
78
|
-
for (const name of exampleNames) {
|
|
79
|
-
const p = join(dir, name);
|
|
80
|
-
if (existsSync(p)) {
|
|
81
|
-
exampleFile = p;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!exampleFile) {
|
|
87
|
-
outputJSON({
|
|
88
|
-
success: true,
|
|
89
|
-
warning: 'No se encontró archivo .env.example. No es posible validar las variables de entorno requeridas.',
|
|
90
|
-
suggestion: 'Crea un archivo .env.example con todas las variables requeridas y valores de ejemplo.',
|
|
91
|
-
findings: [],
|
|
92
|
-
});
|
|
93
|
-
process.exit(0);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const requiredVars = parseEnvFile(exampleFile);
|
|
97
|
-
const requiredKeys = Object.keys(requiredVars);
|
|
98
|
-
|
|
99
|
-
if (requiredKeys.length === 0) {
|
|
100
|
-
outputJSON({
|
|
101
|
-
success: true,
|
|
102
|
-
message: 'No se encontraron variables en el archivo de ejemplo.',
|
|
103
|
-
findings: [],
|
|
104
|
-
});
|
|
105
|
-
process.exit(0);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Leer variables reales: .env.local, luego .env, luego process.env
|
|
109
|
-
let actualVars = {};
|
|
110
|
-
|
|
111
|
-
const envLocalFile = join(dir, '.env.local');
|
|
112
|
-
if (existsSync(envLocalFile)) {
|
|
113
|
-
Object.assign(actualVars, parseEnvFile(envLocalFile));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const envFile = join(dir, '.env');
|
|
117
|
-
if (existsSync(envFile)) {
|
|
118
|
-
Object.assign(actualVars, parseEnvFile(envFile));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Las variables de entorno en tiempo de ejecución tienen mayor precedencia
|
|
122
|
-
for (const key of requiredKeys) {
|
|
123
|
-
if (process.env[key] !== undefined) {
|
|
124
|
-
actualVars[key] = process.env[key];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const findings = [];
|
|
129
|
-
const missing = [];
|
|
130
|
-
const empty = [];
|
|
131
|
-
const placeholder = [];
|
|
132
|
-
const set = [];
|
|
133
|
-
|
|
134
|
-
for (const key of requiredKeys) {
|
|
135
|
-
const exampleValue = requiredVars[key];
|
|
136
|
-
const actualValue = actualVars[key];
|
|
137
|
-
|
|
138
|
-
if (actualValue === undefined) {
|
|
139
|
-
missing.push(key);
|
|
140
|
-
findings.push({
|
|
141
|
-
variable: key,
|
|
142
|
-
status: 'faltante',
|
|
143
|
-
severity: 'critical',
|
|
144
|
-
message: `${key} es requerida pero no está definida en .env ni en el entorno`,
|
|
145
|
-
example_value: exampleValue || '(sin valor de ejemplo)',
|
|
146
|
-
});
|
|
147
|
-
} else if (actualValue === '') {
|
|
148
|
-
empty.push(key);
|
|
149
|
-
findings.push({
|
|
150
|
-
variable: key,
|
|
151
|
-
status: 'vacía',
|
|
152
|
-
severity: 'high',
|
|
153
|
-
message: `${key} está definida pero su valor es vacío`,
|
|
154
|
-
});
|
|
155
|
-
} else if (actualValue === exampleValue && isPlaceholder(exampleValue)) {
|
|
156
|
-
placeholder.push(key);
|
|
157
|
-
findings.push({
|
|
158
|
-
variable: key,
|
|
159
|
-
status: 'placeholder',
|
|
160
|
-
severity: 'high',
|
|
161
|
-
message: `${key} aún tiene su valor de ejemplo — reemplázalo con el valor real`,
|
|
162
|
-
});
|
|
163
|
-
} else {
|
|
164
|
-
set.push(key);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Verificar que .env está en .gitignore
|
|
169
|
-
const gitignorePath = join(dir, '.gitignore');
|
|
170
|
-
let envInGitignore = false;
|
|
171
|
-
if (existsSync(gitignorePath)) {
|
|
172
|
-
const gitignore = readFileSync(gitignorePath, 'utf8');
|
|
173
|
-
envInGitignore = gitignore.split('\n').some(line => {
|
|
174
|
-
const t = line.trim();
|
|
175
|
-
return t === '.env' || t === '.env*' || t === '.env.local';
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!envInGitignore) {
|
|
180
|
-
findings.push({
|
|
181
|
-
variable: '.env',
|
|
182
|
-
status: 'gitignore_ausente',
|
|
183
|
-
severity: 'critical',
|
|
184
|
-
message: '.env no está en .gitignore — los secretos podrían commitearse accidentalmente',
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
outputJSON({
|
|
189
|
-
success: true,
|
|
190
|
-
example_file: basename(exampleFile),
|
|
191
|
-
total_required: requiredKeys.length,
|
|
192
|
-
set: set.length,
|
|
193
|
-
missing: missing.length,
|
|
194
|
-
empty: empty.length,
|
|
195
|
-
placeholder: placeholder.length,
|
|
196
|
-
env_in_gitignore: envInGitignore,
|
|
197
|
-
deploy_ready: missing.length === 0 && empty.length === 0 && placeholder.length === 0,
|
|
198
|
-
findings,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (require.main === module) {
|
|
203
|
-
main();
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
module.exports = { parseEnvFile, isPlaceholder };
|
|
1
|
+
// Adaptado de temp/ultraship-main/tools/env-validator.mjs bajo MIT License
|
|
2
|
+
// Fuente: Houseofmvps/ultraship (https://github.com/Houseofmvps/ultraship)
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { readFileSync, existsSync } = require('fs');
|
|
6
|
+
const { join, basename, resolve } = require('path');
|
|
7
|
+
const { outputJSON, outputError } = require('./lib/output');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parsea un archivo .env y devuelve un mapa clave→valor.
|
|
11
|
+
* Maneja comillas simples/dobles y comentarios con #.
|
|
12
|
+
* @param {string} filePath
|
|
13
|
+
* @returns {Record<string, string>}
|
|
14
|
+
*/
|
|
15
|
+
function parseEnvFile(filePath) {
|
|
16
|
+
let content;
|
|
17
|
+
try {
|
|
18
|
+
content = readFileSync(filePath, 'utf8');
|
|
19
|
+
} catch {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const vars = {};
|
|
24
|
+
for (const line of content.split('\n')) {
|
|
25
|
+
const trimmed = line.trim();
|
|
26
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
27
|
+
const match = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)(\s*=\s*)(.*)/);
|
|
28
|
+
if (!match) continue;
|
|
29
|
+
const key = match[1];
|
|
30
|
+
let value = match[3].trim();
|
|
31
|
+
// Eliminar comillas envolventes
|
|
32
|
+
if (
|
|
33
|
+
(value.startsWith('"') && value.endsWith('"')) ||
|
|
34
|
+
(value.startsWith("'") && value.endsWith("'"))
|
|
35
|
+
) {
|
|
36
|
+
value = value.slice(1, -1);
|
|
37
|
+
}
|
|
38
|
+
vars[key] = value;
|
|
39
|
+
}
|
|
40
|
+
return vars;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Detecta si un valor es claramente un placeholder.
|
|
45
|
+
* @param {string} value
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
function isPlaceholder(value) {
|
|
49
|
+
if (!value) return false;
|
|
50
|
+
const v = value.toLowerCase();
|
|
51
|
+
return (
|
|
52
|
+
v.includes('your_') ||
|
|
53
|
+
v.includes('xxx') ||
|
|
54
|
+
v.includes('placeholder') ||
|
|
55
|
+
v.includes('change_me') ||
|
|
56
|
+
v.includes('todo') ||
|
|
57
|
+
v.includes('replace') ||
|
|
58
|
+
v.includes('your-') ||
|
|
59
|
+
v === 'sk-...' ||
|
|
60
|
+
v === 'pk_...' ||
|
|
61
|
+
/^[a-z_]+_here$/i.test(v)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function main() {
|
|
66
|
+
const args = process.argv.slice(2);
|
|
67
|
+
const rawDir = args.find(a => !a.startsWith('--'));
|
|
68
|
+
const dir = resolve(rawDir || process.cwd());
|
|
69
|
+
|
|
70
|
+
if (!existsSync(dir)) {
|
|
71
|
+
outputError(`Directorio no encontrado: ${dir}`);
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Buscar archivo de variables de entorno de ejemplo
|
|
76
|
+
const exampleNames = ['.env.example', '.env.sample', '.env.template', '.env.defaults'];
|
|
77
|
+
let exampleFile = null;
|
|
78
|
+
for (const name of exampleNames) {
|
|
79
|
+
const p = join(dir, name);
|
|
80
|
+
if (existsSync(p)) {
|
|
81
|
+
exampleFile = p;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!exampleFile) {
|
|
87
|
+
outputJSON({
|
|
88
|
+
success: true,
|
|
89
|
+
warning: 'No se encontró archivo .env.example. No es posible validar las variables de entorno requeridas.',
|
|
90
|
+
suggestion: 'Crea un archivo .env.example con todas las variables requeridas y valores de ejemplo.',
|
|
91
|
+
findings: [],
|
|
92
|
+
});
|
|
93
|
+
process.exit(0);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const requiredVars = parseEnvFile(exampleFile);
|
|
97
|
+
const requiredKeys = Object.keys(requiredVars);
|
|
98
|
+
|
|
99
|
+
if (requiredKeys.length === 0) {
|
|
100
|
+
outputJSON({
|
|
101
|
+
success: true,
|
|
102
|
+
message: 'No se encontraron variables en el archivo de ejemplo.',
|
|
103
|
+
findings: [],
|
|
104
|
+
});
|
|
105
|
+
process.exit(0);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Leer variables reales: .env.local, luego .env, luego process.env
|
|
109
|
+
let actualVars = {};
|
|
110
|
+
|
|
111
|
+
const envLocalFile = join(dir, '.env.local');
|
|
112
|
+
if (existsSync(envLocalFile)) {
|
|
113
|
+
Object.assign(actualVars, parseEnvFile(envLocalFile));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const envFile = join(dir, '.env');
|
|
117
|
+
if (existsSync(envFile)) {
|
|
118
|
+
Object.assign(actualVars, parseEnvFile(envFile));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Las variables de entorno en tiempo de ejecución tienen mayor precedencia
|
|
122
|
+
for (const key of requiredKeys) {
|
|
123
|
+
if (process.env[key] !== undefined) {
|
|
124
|
+
actualVars[key] = process.env[key];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const findings = [];
|
|
129
|
+
const missing = [];
|
|
130
|
+
const empty = [];
|
|
131
|
+
const placeholder = [];
|
|
132
|
+
const set = [];
|
|
133
|
+
|
|
134
|
+
for (const key of requiredKeys) {
|
|
135
|
+
const exampleValue = requiredVars[key];
|
|
136
|
+
const actualValue = actualVars[key];
|
|
137
|
+
|
|
138
|
+
if (actualValue === undefined) {
|
|
139
|
+
missing.push(key);
|
|
140
|
+
findings.push({
|
|
141
|
+
variable: key,
|
|
142
|
+
status: 'faltante',
|
|
143
|
+
severity: 'critical',
|
|
144
|
+
message: `${key} es requerida pero no está definida en .env ni en el entorno`,
|
|
145
|
+
example_value: exampleValue || '(sin valor de ejemplo)',
|
|
146
|
+
});
|
|
147
|
+
} else if (actualValue === '') {
|
|
148
|
+
empty.push(key);
|
|
149
|
+
findings.push({
|
|
150
|
+
variable: key,
|
|
151
|
+
status: 'vacía',
|
|
152
|
+
severity: 'high',
|
|
153
|
+
message: `${key} está definida pero su valor es vacío`,
|
|
154
|
+
});
|
|
155
|
+
} else if (actualValue === exampleValue && isPlaceholder(exampleValue)) {
|
|
156
|
+
placeholder.push(key);
|
|
157
|
+
findings.push({
|
|
158
|
+
variable: key,
|
|
159
|
+
status: 'placeholder',
|
|
160
|
+
severity: 'high',
|
|
161
|
+
message: `${key} aún tiene su valor de ejemplo — reemplázalo con el valor real`,
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
set.push(key);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Verificar que .env está en .gitignore
|
|
169
|
+
const gitignorePath = join(dir, '.gitignore');
|
|
170
|
+
let envInGitignore = false;
|
|
171
|
+
if (existsSync(gitignorePath)) {
|
|
172
|
+
const gitignore = readFileSync(gitignorePath, 'utf8');
|
|
173
|
+
envInGitignore = gitignore.split('\n').some(line => {
|
|
174
|
+
const t = line.trim();
|
|
175
|
+
return t === '.env' || t === '.env*' || t === '.env.local';
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!envInGitignore) {
|
|
180
|
+
findings.push({
|
|
181
|
+
variable: '.env',
|
|
182
|
+
status: 'gitignore_ausente',
|
|
183
|
+
severity: 'critical',
|
|
184
|
+
message: '.env no está en .gitignore — los secretos podrían commitearse accidentalmente',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
outputJSON({
|
|
189
|
+
success: true,
|
|
190
|
+
example_file: basename(exampleFile),
|
|
191
|
+
total_required: requiredKeys.length,
|
|
192
|
+
set: set.length,
|
|
193
|
+
missing: missing.length,
|
|
194
|
+
empty: empty.length,
|
|
195
|
+
placeholder: placeholder.length,
|
|
196
|
+
env_in_gitignore: envInGitignore,
|
|
197
|
+
deploy_ready: missing.length === 0 && empty.length === 0 && placeholder.length === 0,
|
|
198
|
+
findings,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (require.main === module) {
|
|
203
|
+
main();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
module.exports = { parseEnvFile, isPlaceholder };
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
// Adaptado de temp/ultraship-main/tools/*.mjs bajo MIT License
|
|
2
|
-
// Fuente: Houseofmvps/ultraship (https://github.com/Houseofmvps/ultraship)
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const { readdirSync, statSync } = require('fs');
|
|
6
|
-
const { join, extname } = require('path');
|
|
7
|
-
|
|
8
|
-
const SKIP_DIRS = new Set([
|
|
9
|
-
'node_modules', '.git', 'dist', 'build', '.next', 'coverage',
|
|
10
|
-
'__pycache__', '.cache', 'venv', '.venv', 'target', 'vendor',
|
|
11
|
-
'.tox', 'eggs', '.eggs', 'htmlcov', '.mypy_cache', '.pytest_cache',
|
|
12
|
-
]);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Recorre recursivamente un directorio y retorna archivos de código.
|
|
16
|
-
* Omite directorios en SKIP_DIRS y entradas que empiecen con '.'.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} dir - Directorio raíz a recorrer
|
|
19
|
-
* @param {object} [opciones]
|
|
20
|
-
* @param {string[]} [opciones.extensions] - Extensiones a incluir
|
|
21
|
-
* @returns {string[]} Lista de rutas absolutas de archivos encontrados
|
|
22
|
-
*/
|
|
23
|
-
function walkCode(dir, opciones = {}) {
|
|
24
|
-
const extensions = opciones.extensions || [
|
|
25
|
-
'.js', '.ts', '.tsx', '.jsx', '.py', '.mjs', '.cjs',
|
|
26
|
-
];
|
|
27
|
-
const extSet = new Set(extensions.map(e => e.toLowerCase()));
|
|
28
|
-
const files = [];
|
|
29
|
-
|
|
30
|
-
function walk(d) {
|
|
31
|
-
try {
|
|
32
|
-
for (const entry of readdirSync(d)) {
|
|
33
|
-
if (entry.startsWith('.') || SKIP_DIRS.has(entry)) continue;
|
|
34
|
-
const p = join(d, entry);
|
|
35
|
-
try {
|
|
36
|
-
const s = statSync(p);
|
|
37
|
-
if (s.isDirectory()) walk(p);
|
|
38
|
-
else if (extSet.has(extname(entry).toLowerCase())) files.push(p);
|
|
39
|
-
} catch { /* skip archivos no accesibles */ }
|
|
40
|
-
}
|
|
41
|
-
} catch { /* skip directorios no accesibles */ }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
walk(dir);
|
|
45
|
-
return files;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
module.exports = { walkCode, SKIP_DIRS };
|
|
1
|
+
// Adaptado de temp/ultraship-main/tools/*.mjs bajo MIT License
|
|
2
|
+
// Fuente: Houseofmvps/ultraship (https://github.com/Houseofmvps/ultraship)
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { readdirSync, statSync } = require('fs');
|
|
6
|
+
const { join, extname } = require('path');
|
|
7
|
+
|
|
8
|
+
const SKIP_DIRS = new Set([
|
|
9
|
+
'node_modules', '.git', 'dist', 'build', '.next', 'coverage',
|
|
10
|
+
'__pycache__', '.cache', 'venv', '.venv', 'target', 'vendor',
|
|
11
|
+
'.tox', 'eggs', '.eggs', 'htmlcov', '.mypy_cache', '.pytest_cache',
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Recorre recursivamente un directorio y retorna archivos de código.
|
|
16
|
+
* Omite directorios en SKIP_DIRS y entradas que empiecen con '.'.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} dir - Directorio raíz a recorrer
|
|
19
|
+
* @param {object} [opciones]
|
|
20
|
+
* @param {string[]} [opciones.extensions] - Extensiones a incluir
|
|
21
|
+
* @returns {string[]} Lista de rutas absolutas de archivos encontrados
|
|
22
|
+
*/
|
|
23
|
+
function walkCode(dir, opciones = {}) {
|
|
24
|
+
const extensions = opciones.extensions || [
|
|
25
|
+
'.js', '.ts', '.tsx', '.jsx', '.py', '.mjs', '.cjs',
|
|
26
|
+
];
|
|
27
|
+
const extSet = new Set(extensions.map(e => e.toLowerCase()));
|
|
28
|
+
const files = [];
|
|
29
|
+
|
|
30
|
+
function walk(d) {
|
|
31
|
+
try {
|
|
32
|
+
for (const entry of readdirSync(d)) {
|
|
33
|
+
if (entry.startsWith('.') || SKIP_DIRS.has(entry)) continue;
|
|
34
|
+
const p = join(d, entry);
|
|
35
|
+
try {
|
|
36
|
+
const s = statSync(p);
|
|
37
|
+
if (s.isDirectory()) walk(p);
|
|
38
|
+
else if (extSet.has(extname(entry).toLowerCase())) files.push(p);
|
|
39
|
+
} catch { /* skip archivos no accesibles */ }
|
|
40
|
+
}
|
|
41
|
+
} catch { /* skip directorios no accesibles */ }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
walk(dir);
|
|
45
|
+
return files;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = { walkCode, SKIP_DIRS };
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
// Adaptado de temp/ultraship-main/tools/*.mjs bajo MIT License
|
|
2
|
-
// Fuente: Houseofmvps/ultraship (https://github.com/Houseofmvps/ultraship)
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Escribe datos como JSON formateado a stdout.
|
|
7
|
-
* @param {object} data
|
|
8
|
-
*/
|
|
9
|
-
function outputJSON(data) {
|
|
10
|
-
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Escribe un error a stderr. Nunca lanza excepción.
|
|
15
|
-
* @param {string} msg
|
|
16
|
-
* @param {object|null} contextData
|
|
17
|
-
*/
|
|
18
|
-
function outputError(msg, contextData = null) {
|
|
19
|
-
const err = contextData ? { error: msg, context: contextData } : { error: msg };
|
|
20
|
-
process.stderr.write(JSON.stringify(err, null, 2) + '\n');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = { outputJSON, outputError };
|
|
1
|
+
// Adaptado de temp/ultraship-main/tools/*.mjs bajo MIT License
|
|
2
|
+
// Fuente: Houseofmvps/ultraship (https://github.com/Houseofmvps/ultraship)
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Escribe datos como JSON formateado a stdout.
|
|
7
|
+
* @param {object} data
|
|
8
|
+
*/
|
|
9
|
+
function outputJSON(data) {
|
|
10
|
+
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Escribe un error a stderr. Nunca lanza excepción.
|
|
15
|
+
* @param {string} msg
|
|
16
|
+
* @param {object|null} contextData
|
|
17
|
+
*/
|
|
18
|
+
function outputError(msg, contextData = null) {
|
|
19
|
+
const err = contextData ? { error: msg, context: contextData } : { error: msg };
|
|
20
|
+
process.stderr.write(JSON.stringify(err, null, 2) + '\n');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = { outputJSON, outputError };
|