@saulwade/swl-ses 2.1.0 → 2.2.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.
- package/CLAUDE.md +1 -1
- package/README.md +1 -1
- package/bin/swl-ses.js +63 -0
- package/comandos/swl/adoptar-proyecto.md +258 -255
- package/comandos/swl/aprender.md +828 -840
- package/comandos/swl/aprobar-plan.md +23 -35
- package/comandos/swl/autoresearch.md +12 -14
- package/comandos/swl/briefing.md +5 -8
- package/comandos/swl/checkpoint.md +10 -15
- package/comandos/swl/claudemd.md +239 -234
- package/comandos/swl/configurar-ci.md +20 -19
- package/comandos/swl/cron.md +10 -12
- package/comandos/swl/ejecutar-fase.md +10 -3
- package/comandos/swl/evolucionar.md +6 -11
- package/comandos/swl/inbox.md +10 -10
- package/comandos/swl/modelo.md +7 -9
- package/comandos/swl/notificaciones.md +19 -116
- package/comandos/swl/nuevo-proyecto.md +205 -205
- package/comandos/swl/status.md +333 -348
- package/comandos/swl/verificar.md +817 -813
- package/habilidades/swl-claudemd/SKILL.md +10 -6
- package/hooks/lib/propose-step.js +1 -0
- package/llms.txt +1 -1
- package/manifiestos/skills-lock.json +5 -5
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/auditar-claudemd.js +38 -0
- package/scripts/cli/aprobar-plan.js +73 -0
- package/scripts/cli/briefing.js +23 -0
- package/scripts/cli/ciclo-evolucion.js +26 -0
- package/scripts/cli/configurar-ci.js +40 -0
- package/scripts/cli/derivar-feature-list.js +25 -0
- package/scripts/cli/detectar-host.js +27 -0
- package/scripts/cli/diary-entry.js +69 -0
- package/scripts/cli/execution-state.js +18 -0
- package/scripts/cli/gateway-notify.js +41 -0
- package/scripts/cli/liberar-fase.js +42 -0
- package/scripts/cli/loop-telemetry.js +125 -0
- package/scripts/cli/mark-evolved.js +56 -0
- package/scripts/cli/metricas-dora.js +26 -0
- package/scripts/cli/near-duplicate.js +55 -0
- package/scripts/cli/notificaciones.js +123 -0
- package/scripts/cli/propose-step.js +29 -0
- package/scripts/cli/schedule-parse.js +19 -0
- package/scripts/cli/sugerir-modelo.js +20 -0
- package/scripts/cli/verificar-plan.js +36 -0
- package/scripts/cli/verificar-trazabilidad.js +35 -0
- package/scripts/derivar-feature-list.js +1 -0
- package/scripts/lib/auditar-invocaciones-comandos.js +104 -0
- package/scripts/lib/resolver-plan-fase.js +37 -0
- package/scripts/validar.js +13 -0
- package/scripts/verificar-trazabilidad.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: swl-claudemd
|
|
3
3
|
description: Conocimiento operacional para auditar y mantener archivos CLAUDE.md — contrato canónico de secciones (best practices Anthropic, ADR-0016), umbrales de bloat (líneas totales, bullets gigantes, placeholders, @references rotas), reglas de extracción a archivos referenciados con @, y plantillas de inicialización (init-user para ~/.claude/CLAUDE.md, init-project para CLAUDE.md raíz detectando stack). Provee las reglas; el comando /swl:claudemd ejecuta el flujo. Cargar desde ese comando o cuando el hook claudemd-bloat-detector sugiera intervención.
|
|
4
|
-
version: "1.
|
|
4
|
+
version: "1.3.0"
|
|
5
5
|
herramientasPermitidas: [Read, Write, Edit, Bash, Glob, Grep]
|
|
6
6
|
exclusiones:
|
|
7
7
|
- "No cargar para editar reglas globales en ~/.claude/rules/ — usar Edit directo."
|
|
@@ -58,12 +58,15 @@ Más dos prácticas auxiliares del video:
|
|
|
58
58
|
Ejecuta el auditor determinista:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
node scripts/auditar-claudemd.js
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
# Repo de swl-ses (script local): node scripts/auditar-claudemd.js [--json|--strict]
|
|
62
|
+
# Proyecto downstream (NO existe el script local): usar el subcomando del CLI:
|
|
63
|
+
npx -y @saulwade/swl-ses@latest audit-claudemd [--json|--strict]
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
Regla: si `scripts/auditar-claudemd.js` no existe en el CWD, usar SIEMPRE
|
|
67
|
+
`npx ... audit-claudemd` — ambas rutas ejecutan el mismo auditor.
|
|
68
|
+
|
|
69
|
+
El auditor verifica nueve dimensiones (la fila `@references rotos` caza el `@reglas/...` roto downstream):
|
|
67
70
|
|
|
68
71
|
| Dimensión | Regla | Severidad |
|
|
69
72
|
|---|---|---|
|
|
@@ -72,6 +75,7 @@ El auditor verifica ocho dimensiones:
|
|
|
72
75
|
| Bullets monolíticos | Cada bullet/párrafo ≤ `SWL_CLAUDEMD_MAX_BULLET_CHARS` (default 1000). Tablas y bloques de código se ignoran | WARN |
|
|
73
76
|
| Secciones canónicas | Stack, Comandos, Code style, Conventions presentes | WARN |
|
|
74
77
|
| @references | Archivos >80 líneas usan al menos un `@docs/...md` | WARN |
|
|
78
|
+
| @references rotos | `@-include` con path relativo cuyo destino no existe (resuelto relativo al CLAUDE.md; omite `~/` y absolutas). Caza el `@reglas/...` roto en proyectos donde las reglas viven en `.claude/rules/` | WARN |
|
|
75
79
|
| Placeholders | `[TBD]`, `[TODO]`, `[COMPLETAR]` | ERROR |
|
|
76
80
|
| Karpathy reference | Project-level >50 LOC menciona "Karpathy", los 4 principios, o `prevencion-sobreingenieria` | WARN |
|
|
77
81
|
| Duplicación reglas globales | Bloque inline parafrasea regla de `~/.claude/rules/` ya cargada globalmente (catálogo en `scripts/lib/reglas-globales-conocidas.json`) | WARN |
|
|
@@ -167,7 +171,7 @@ Genera `./CLAUDE.md` raíz del proyecto detectando stack actual.
|
|
|
167
171
|
2. Ejecutar `detectarStackDetallado(process.cwd())` (de
|
|
168
172
|
`scripts/lib/detectar-stack-detallado.js`).
|
|
169
173
|
3. Generar archivo con secciones pobladas:
|
|
170
|
-
- **Reglas obligatorias**: `@reglas/usar-sistema-swl.md`
|
|
174
|
+
- **Reglas obligatorias**: mención de texto de la regla global `usar-sistema-swl.md` (auto-cargada desde `.claude/rules/`). NUNCA `@reglas/usar-sistema-swl.md` — esa ruta no existe en proyectos downstream y queda como @-include roto
|
|
171
175
|
- **Reglas de máxima prioridad** con sub-sección **Cuatro principios de
|
|
172
176
|
implementación (Karpathy)** — bloque exacto definido abajo
|
|
173
177
|
- **Stack**: lenguaje + framework + ORM + package manager detectados
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# swl-ses (@saulwade/swl-ses)
|
|
2
2
|
|
|
3
|
-
> Sistema de ingeniería de software auto-evolutivo multi-runtime polyglot (SDLC completo), distribuido como paquete npm y plugin de Claude Code. 60 agentes, 182 habilidades, 44 comandos, 37 reglas base y 48 hooks. Soporta 11 lenguajes y 7 runtimes (Claude Code, OpenClaude, OpenCode, Gemini, Cursor, Codex, Copilot). Versión 2.
|
|
3
|
+
> Sistema de ingeniería de software auto-evolutivo multi-runtime polyglot (SDLC completo), distribuido como paquete npm y plugin de Claude Code. 60 agentes, 182 habilidades, 44 comandos, 37 reglas base y 48 hooks. Soporta 11 lenguajes y 7 runtimes (Claude Code, OpenClaude, OpenCode, Gemini, Cursor, Codex, Copilot). Versión 2.2.0.
|
|
4
4
|
|
|
5
5
|
Archivo generado por `node scripts/generar-inventario.js` — no editar a mano. Las cifras se sincronizan con INVENTARIO.md en cada regeneración.
|
|
6
6
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"lockfileVersion": 1,
|
|
3
|
-
"generatedAt": "2026-06-
|
|
3
|
+
"generatedAt": "2026-06-13T23:48:35.239Z",
|
|
4
4
|
"skillsCount": 182,
|
|
5
|
-
"lockHash": "sha256:
|
|
5
|
+
"lockHash": "sha256:9a83648f9615e563db51b1ff72c083526892f9dd1e0a34513dbc104e1caf29ff",
|
|
6
6
|
"skills": [
|
|
7
7
|
{
|
|
8
8
|
"nombre": "accesibilidad-a11y",
|
|
@@ -1134,9 +1134,9 @@
|
|
|
1134
1134
|
{
|
|
1135
1135
|
"nombre": "swl-claudemd",
|
|
1136
1136
|
"path": "habilidades/swl-claudemd/SKILL.md",
|
|
1137
|
-
"hash": "sha256:
|
|
1138
|
-
"bytes":
|
|
1139
|
-
"version": "\"1.
|
|
1137
|
+
"hash": "sha256:6e8abe48bacd9059047df2b33bcd4df20e46c88e3df6d6692800896c003050e7",
|
|
1138
|
+
"bytes": 16060,
|
|
1139
|
+
"version": "\"1.3.0\""
|
|
1140
1140
|
},
|
|
1141
1141
|
{
|
|
1142
1142
|
"nombre": "swl-dashboard",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saulwade/swl-ses",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Sistema de ingenieria de software auto-evolutivo multi-runtime polyglot con 60 agentes, 182 habilidades, 44 comandos, 77 reglas y 48 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.8.0 unifica los directorios runtime de .planning/ al ingles (evolution/, auto-evolution/, user-profile/, archive/), manteniendo fases/ en espanol, con guard validar-planning-paths y allowlist canonica (ADR-0031). Hereda de v1.7.4: skill calidad-anti-patrones-universales + scripts/lib/pr-analyzer.js + 3 sub-secciones en estilo-sin-ai-isms.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"swl-ses": "bin/swl-ses.js",
|
package/plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swl-ses",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Sistema de ingenieria de software auto-evolutivo multi-runtime polyglot. 60 agentes, 182 habilidades, 44 comandos, 77 reglas y 48 hooks. 76 librerias. 11 lenguajes. Soporta Claude Code, Copilot, OpenCode, Codex y Gemini CLI. Loop evaluator-optimizer en /swl:nemesis (ADR-0021). v1.8.0 unifica los directorios runtime de .planning/ al ingles (evolution/, auto-evolution/, user-profile/, archive/), manteniendo fases/ en espanol, con guard validar-planning-paths y allowlist canonica (ADR-0031). Hereda de v1.7.4: skill calidad-anti-patrones-universales + scripts/lib/pr-analyzer.js + 3 sub-secciones en estilo-sin-ai-isms.",
|
|
5
5
|
"author": "Saul Wade Leon",
|
|
6
6
|
"license": "MIT",
|
|
@@ -86,6 +86,28 @@ function ubicarClaudeMd(dir = process.cwd()) {
|
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// Detecta @-includes con path RELATIVO al CLAUDE.md cuyo destino no existe.
|
|
90
|
+
// Solo evalúa rutas relativas al proyecto — omite `~/` y rutas absolutas
|
|
91
|
+
// porque su existencia depende del entorno de instalación, no del repo.
|
|
92
|
+
// Causa raíz del bug downstream: plantillas que emitían `@reglas/...` cuando
|
|
93
|
+
// las reglas se instalan en `.claude/rules/` (no en `reglas/` del proyecto).
|
|
94
|
+
function detectarReferenciasRotas(contenido, rutaClaudeMd) {
|
|
95
|
+
const baseDir = path.dirname(rutaClaudeMd);
|
|
96
|
+
// Primer char [A-Za-z0-9_.] excluye `~` y `/` → solo captura rutas relativas.
|
|
97
|
+
const re = /@([A-Za-z0-9_.][A-Za-z0-9_./\-]*\.md)\b/g;
|
|
98
|
+
const rotas = [];
|
|
99
|
+
const vistos = new Set();
|
|
100
|
+
let m;
|
|
101
|
+
while ((m = re.exec(contenido)) !== null) {
|
|
102
|
+
const ref = m[1];
|
|
103
|
+
if (vistos.has(ref)) continue;
|
|
104
|
+
vistos.add(ref);
|
|
105
|
+
if (ref.startsWith('~') || path.isAbsolute(ref)) continue;
|
|
106
|
+
if (!fs.existsSync(path.resolve(baseDir, ref))) rotas.push(ref);
|
|
107
|
+
}
|
|
108
|
+
return rotas;
|
|
109
|
+
}
|
|
110
|
+
|
|
89
111
|
function auditar(rutaClaudeMd) {
|
|
90
112
|
if (!rutaClaudeMd || !fs.existsSync(rutaClaudeMd)) {
|
|
91
113
|
return {
|
|
@@ -150,6 +172,17 @@ function auditar(rutaClaudeMd) {
|
|
|
150
172
|
}
|
|
151
173
|
}
|
|
152
174
|
|
|
175
|
+
// 4b. @references rotos: @-includes con path relativo cuyo destino no existe.
|
|
176
|
+
const referenciasRotas = detectarReferenciasRotas(contenido, rutaClaudeMd);
|
|
177
|
+
for (const ref of referenciasRotas) {
|
|
178
|
+
hallazgos.push({
|
|
179
|
+
severidad: 'WARN',
|
|
180
|
+
regla: 'at-reference-rota',
|
|
181
|
+
mensaje: `@-reference rota: \`@${ref}\` no existe (resuelto relativo al CLAUDE.md)`,
|
|
182
|
+
sugerencia: 'Corregir la ruta o, si es una regla global auto-cargada (p. ej. usar-sistema-swl), eliminar el @-include y dejar solo mención de texto',
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
153
186
|
// 5. Placeholders sin reemplazar
|
|
154
187
|
const matches = [...contenido.matchAll(PLACEHOLDERS)];
|
|
155
188
|
if (matches.length > 0) {
|
|
@@ -237,6 +270,7 @@ function auditar(rutaClaudeMd) {
|
|
|
237
270
|
secciones_presentes: SECCIONES_CANONICAS.filter(s => s.regex.test(contenido)).map(s => s.nombre),
|
|
238
271
|
secciones_ausentes: seccionesAusentes.map(s => s.nombre),
|
|
239
272
|
tiene_at_references: /@[a-zA-Z][a-zA-Z0-9_\-./]+\.md/.test(contenido),
|
|
273
|
+
at_references_rotas: referenciasRotas,
|
|
240
274
|
tiene_referencia_karpathy: tieneReferenciaKarpathy,
|
|
241
275
|
es_project_level: esProjectLevel,
|
|
242
276
|
duplicaciones_reglas_globales: {
|
|
@@ -375,6 +409,9 @@ function imprimirReporte(resultado) {
|
|
|
375
409
|
console.log(` - Secciones ausentes: ${m.secciones_ausentes.join(', ')}`);
|
|
376
410
|
}
|
|
377
411
|
console.log(` - @references: ${m.tiene_at_references ? 'sí' : 'no'}`);
|
|
412
|
+
if (m.at_references_rotas && m.at_references_rotas.length > 0) {
|
|
413
|
+
console.log(` - @references rotas: ${m.at_references_rotas.length} (${m.at_references_rotas.join(', ')})`);
|
|
414
|
+
}
|
|
378
415
|
if (m.es_project_level) {
|
|
379
416
|
console.log(` - Referencia Karpathy: ${m.tiene_referencia_karpathy ? 'sí' : 'no'}`);
|
|
380
417
|
}
|
|
@@ -436,6 +473,7 @@ module.exports = {
|
|
|
436
473
|
ubicarClaudeMd,
|
|
437
474
|
detectarBulletsGigantes,
|
|
438
475
|
detectarReferenciaKarpathy,
|
|
476
|
+
detectarReferenciasRotas,
|
|
439
477
|
esRutaUserLevel,
|
|
440
478
|
main,
|
|
441
479
|
MAX_LINES,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Subcomando `swl-ses aprobar-plan --fase=N` — parte determinista del gate G1.
|
|
5
|
+
*
|
|
6
|
+
* Reemplaza los `node -e "require('./scripts/lib/plan-lock')"` y
|
|
7
|
+
* `require('./hooks/lib/atomic-write')` que el slash command /swl:aprobar-plan
|
|
8
|
+
* tenía inline — rutas relativas al proyecto que se rompían en instalaciones
|
|
9
|
+
* downstream (ver docs/invocacion-cli-cross-scope.md).
|
|
10
|
+
*
|
|
11
|
+
* Hace: firma el PLAN (SHA256 → .planning/locks/0N-PLAN.md.lock), lo verifica,
|
|
12
|
+
* y escribe .planning/locks/fase-activa.json (gate G0). El HITL (confirmación,
|
|
13
|
+
* transición de frontmatter, REQ×T) lo sigue manejando el prompt del comando.
|
|
14
|
+
*
|
|
15
|
+
* Uso: swl-ses aprobar-plan --fase=N [--plan=<ruta>] [--aprobado-por="texto"]
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const path = require('node:path');
|
|
19
|
+
const { firmarPlan, verificarPlan } = require('../lib/plan-lock');
|
|
20
|
+
const { atomicWriteJSON } = require('../../hooks/lib/atomic-write');
|
|
21
|
+
const { resolverPlanPath } = require('../lib/resolver-plan-fase');
|
|
22
|
+
|
|
23
|
+
function aprobarPlan(opciones = {}) {
|
|
24
|
+
opciones = opciones || {};
|
|
25
|
+
const planPath = resolverPlanPath(opciones);
|
|
26
|
+
if (!planPath) {
|
|
27
|
+
console.error('Uso: swl-ses aprobar-plan --fase=N [--plan=<ruta>] [--aprobado-por="texto"]');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const firmadoPor = opciones['aprobado-por'] || opciones.aprobado_por || 'swl:aprobar-plan';
|
|
32
|
+
const firma = firmarPlan(planPath, { firmadoPor });
|
|
33
|
+
if (!firma.ok) {
|
|
34
|
+
console.error(`[aprobar-plan] no se pudo firmar el PLAN: ${firma.motivo}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ver = verificarPlan(planPath);
|
|
39
|
+
const numero =
|
|
40
|
+
opciones.fase != null && opciones.fase !== true ? Number(opciones.fase) : null;
|
|
41
|
+
const locksDir = path.dirname(firma.lockPath);
|
|
42
|
+
const faseActivaPath = path.join(locksDir, 'fase-activa.json');
|
|
43
|
+
|
|
44
|
+
atomicWriteJSON(faseActivaPath, {
|
|
45
|
+
numero,
|
|
46
|
+
planPath,
|
|
47
|
+
sha256: firma.sha256,
|
|
48
|
+
aprobadoEn: new Date().toISOString(),
|
|
49
|
+
aprobadoPor: opciones['aprobado-por'] || opciones.aprobado_por || 'usuario via /swl:aprobar-plan',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
console.log(
|
|
53
|
+
JSON.stringify(
|
|
54
|
+
{
|
|
55
|
+
ok: true,
|
|
56
|
+
planPath,
|
|
57
|
+
sha256: firma.sha256,
|
|
58
|
+
lockPath: firma.lockPath,
|
|
59
|
+
modo: ver.modo,
|
|
60
|
+
faseActiva: faseActivaPath,
|
|
61
|
+
},
|
|
62
|
+
null,
|
|
63
|
+
2
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = aprobarPlan;
|
|
69
|
+
|
|
70
|
+
if (require.main === module) {
|
|
71
|
+
const { parsearOpciones } = require('../lib/parsear-opciones');
|
|
72
|
+
aprobarPlan(parsearOpciones(process.argv.slice(2)));
|
|
73
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses briefing` — recolecta las señales baratas del briefing
|
|
5
|
+
* (adr-vencido, deuda-trigger, nudges-pendientes, gate-calibracion,
|
|
6
|
+
* continue-here) y las imprime sin tope. Reemplaza el inline
|
|
7
|
+
* `require('./hooks/lib/briefing.js')` relativo al proyecto (roto downstream;
|
|
8
|
+
* ver docs/invocacion-cli-cross-scope.md).
|
|
9
|
+
*
|
|
10
|
+
* Uso: swl-ses briefing
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const b = require('../../hooks/lib/briefing.js');
|
|
14
|
+
|
|
15
|
+
function briefingCli() {
|
|
16
|
+
const items = b.recolectarTodo(process.cwd(), new Date());
|
|
17
|
+
for (const it of items) {
|
|
18
|
+
console.log('— [' + it.categoria + '] ' + it.titulo + ' → ' + it.accion);
|
|
19
|
+
}
|
|
20
|
+
if (items.length === 0) console.log('(sin señales baratas)');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = briefingCli;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses ciclo-evolucion` — regenera las métricas de evolución
|
|
5
|
+
* (.planning/evolution/metricas.json) ejecutando la sub-etapa Stop del ciclo.
|
|
6
|
+
* Reemplaza `echo '{}' | node hooks/ciclo-evolucion.js` relativo al proyecto
|
|
7
|
+
* (roto downstream; ver docs/invocacion-cli-cross-scope.md).
|
|
8
|
+
*
|
|
9
|
+
* Uso: swl-ses ciclo-evolucion
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const cicloEvolucion = require('../../hooks/lib/ciclo-evolucion');
|
|
13
|
+
|
|
14
|
+
function cicloEvolucionCli() {
|
|
15
|
+
try {
|
|
16
|
+
cicloEvolucion.ejecutarStop('{}');
|
|
17
|
+
console.log('[ciclo-evolucion] métricas de evolución regeneradas');
|
|
18
|
+
} catch (e) {
|
|
19
|
+
// A diferencia del hook (que nunca bloquea el harness), el CLI sí debe
|
|
20
|
+
// distinguir fallo de éxito para el caller: stderr + exit code != 0.
|
|
21
|
+
console.error('[ciclo-evolucion] no se pudo regenerar: ' + e.message);
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = cicloEvolucionCli;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses configurar-ci <op>` — gestiona los workflows CI/CD de SWL
|
|
5
|
+
* en el proyecto actual. Reemplaza los inline `require('./scripts/lib/configurar-ci')`
|
|
6
|
+
* relativos al proyecto (rotos downstream; ver docs/invocacion-cli-cross-scope.md).
|
|
7
|
+
*
|
|
8
|
+
* Ops (todas imprimen el resultado como JSON para que el comando lo inspeccione):
|
|
9
|
+
* init [--no-security] [--no-ci] [--with-release-please] [--dry-run] [--force]
|
|
10
|
+
* status (default)
|
|
11
|
+
* uninstall [--confirmar]
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const ci = require('../lib/configurar-ci');
|
|
15
|
+
|
|
16
|
+
function configurarCi(opciones = {}) {
|
|
17
|
+
const op = (opciones._args && opciones._args[0]) || opciones.op || 'status';
|
|
18
|
+
|
|
19
|
+
if (op === 'init') {
|
|
20
|
+
const r = ci.init({
|
|
21
|
+
withSecurity: !opciones['no-security'],
|
|
22
|
+
withCi: !opciones['no-ci'],
|
|
23
|
+
withReleasePlease: !!opciones['with-release-please'],
|
|
24
|
+
dryRun: !!opciones['dry-run'],
|
|
25
|
+
force: !!opciones.force,
|
|
26
|
+
});
|
|
27
|
+
console.log(JSON.stringify(r, null, 2));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (op === 'uninstall') {
|
|
32
|
+
const r = ci.uninstall({ confirmar: !!opciones.confirmar });
|
|
33
|
+
console.log(JSON.stringify(r, null, 2));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(JSON.stringify(ci.status(), null, 2));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = configurarCi;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses derivar-feature-list` — genera .planning/feature-list.json
|
|
5
|
+
* desde HOJA-RUTA.md. Reemplaza `node scripts/derivar-feature-list.js` relativo
|
|
6
|
+
* al proyecto (roto downstream; ver docs/invocacion-cli-cross-scope.md).
|
|
7
|
+
*
|
|
8
|
+
* Uso: swl-ses derivar-feature-list [--check] (--check: exit 2 si hay drift)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { main } = require('../derivar-feature-list.js');
|
|
12
|
+
|
|
13
|
+
function derivarFeatureList(opciones = {}) {
|
|
14
|
+
const args = ['node', 'derivar-feature-list'];
|
|
15
|
+
if (opciones && opciones.check) args.push('--check');
|
|
16
|
+
const argvOriginal = process.argv;
|
|
17
|
+
process.argv = args;
|
|
18
|
+
try {
|
|
19
|
+
return main();
|
|
20
|
+
} finally {
|
|
21
|
+
process.argv = argvOriginal;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = derivarFeatureList;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses detectar-host` — determina si el CWD es el repo host de
|
|
5
|
+
* SWL o un proyecto consumidor. Reemplaza `node scripts/lib/detectar-host-swl.js`
|
|
6
|
+
* relativo al proyecto (roto downstream; ver docs/invocacion-cli-cross-scope.md).
|
|
7
|
+
*
|
|
8
|
+
* Uso: swl-ses detectar-host [--json]
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { detectarHostSwl } = require('../lib/detectar-host-swl');
|
|
12
|
+
|
|
13
|
+
function detectarHost(opciones = {}) {
|
|
14
|
+
const r = detectarHostSwl(process.cwd());
|
|
15
|
+
if (opciones && opciones.json) {
|
|
16
|
+
console.log(JSON.stringify(r, null, 2));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (r.esHost) {
|
|
20
|
+
console.log(`[host] ${r.razon}`);
|
|
21
|
+
} else {
|
|
22
|
+
console.log(`[consumidor] ${r.razon}`);
|
|
23
|
+
for (const s of r.sugerencias) console.log(` - ${s}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = detectarHost;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses diary-entry` — construye y persiste una entrada de diario
|
|
5
|
+
* de sesión en .planning/sessions/diary/<id>.json. Reemplaza el inline
|
|
6
|
+
* `require('./scripts/lib/diary-entry')` relativo al proyecto (roto downstream;
|
|
7
|
+
* ver docs/invocacion-cli-cross-scope.md).
|
|
8
|
+
*
|
|
9
|
+
* Entrada: objeto JSON por stdin (o --json='{...}') con la forma:
|
|
10
|
+
* {
|
|
11
|
+
* "sessionId": "...", "agent": "orquestador-swl",
|
|
12
|
+
* "accomplishments": ["..."], "decisions": ["..."],
|
|
13
|
+
* "learnings": ["..."], "challenges": ["..."],
|
|
14
|
+
* "sourceAgents": ["implementador-swl"], "tags": ["..."]
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* Imprime la ruta del archivo escrito. Uso:
|
|
18
|
+
* echo '{"sessionId":"s1","agent":"orquestador-swl"}' | swl-ses diary-entry
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const fs = require('node:fs');
|
|
22
|
+
const path = require('node:path');
|
|
23
|
+
const diary = require('../lib/diary-entry');
|
|
24
|
+
const { atomicWriteSync } = require('../../hooks/lib/atomic-write');
|
|
25
|
+
|
|
26
|
+
function diaryEntry(opciones = {}) {
|
|
27
|
+
let raw = opciones.json;
|
|
28
|
+
if (!raw && !process.stdin.isTTY) {
|
|
29
|
+
try {
|
|
30
|
+
raw = fs.readFileSync(0, 'utf8');
|
|
31
|
+
} catch (e) {
|
|
32
|
+
// No degradar en silencio: avisar que stdin fue ilegible antes del fallback.
|
|
33
|
+
console.error('[diary-entry] aviso: stdin ilegible (' + e.code + ')');
|
|
34
|
+
raw = '';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
let input;
|
|
38
|
+
try {
|
|
39
|
+
input = JSON.parse(raw || '{}');
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error('Error: JSON inválido: ' + e.message);
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let entry = diary.createDiary({ sessionId: input.sessionId, agent: input.agent });
|
|
47
|
+
for (const a of input.accomplishments || []) entry = diary.addAccomplishment(entry, a);
|
|
48
|
+
for (const d of input.decisions || []) entry = diary.addDecision(entry, d);
|
|
49
|
+
for (const c of input.challenges || []) entry = diary.addChallenge(entry, c);
|
|
50
|
+
for (const l of input.learnings || []) entry = diary.addLearning(entry, l);
|
|
51
|
+
for (const tg of input.tags || []) entry = diary.addTag(entry, tg);
|
|
52
|
+
for (const sa of input.sourceAgents || []) entry = diary.addSourceAgent(entry, sa);
|
|
53
|
+
entry = diary.closeDiary(entry);
|
|
54
|
+
|
|
55
|
+
const val = diary.validateDiary(entry);
|
|
56
|
+
if (!val.valid) {
|
|
57
|
+
console.error('Error de validación: ' + val.errors.join('; '));
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const dir = path.join(process.cwd(), '.planning', 'sessions', 'diary');
|
|
63
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
64
|
+
const dest = path.join(dir, entry.id + '.json');
|
|
65
|
+
atomicWriteSync(dest, diary.serializeDiary(entry));
|
|
66
|
+
console.log(dest);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = diaryEntry;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses execution-state` — imprime el resumen estructurado del
|
|
5
|
+
* estado de ejecución (.planning/execution-state.json). Reemplaza el inline
|
|
6
|
+
* `require('./hooks/lib/execution-state')` relativo al proyecto (roto downstream;
|
|
7
|
+
* ver docs/invocacion-cli-cross-scope.md).
|
|
8
|
+
*
|
|
9
|
+
* Uso: swl-ses execution-state
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const es = require('../../hooks/lib/execution-state');
|
|
13
|
+
|
|
14
|
+
function executionState() {
|
|
15
|
+
console.log(es.formatearResumen(process.cwd()));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = executionState;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper CLI `swl-ses gateway-notify` — encola una notificación de vuelta al
|
|
5
|
+
* canal origen del gateway (Telegram, Discord). Reemplaza el inline
|
|
6
|
+
* `require('./hooks/lib/gateway-notify')` relativo al proyecto (roto downstream;
|
|
7
|
+
* ver docs/invocacion-cli-cross-scope.md).
|
|
8
|
+
*
|
|
9
|
+
* Uso: swl-ses gateway-notify --texto="✅ ..." [--tipo=custom] [--to=telegram]
|
|
10
|
+
* [--reply-to=<chatId>]
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { notificarGateway } = require('../../hooks/lib/gateway-notify');
|
|
14
|
+
|
|
15
|
+
function gatewayNotify(opciones = {}) {
|
|
16
|
+
if (!opciones.texto) {
|
|
17
|
+
console.error('Error: falta --texto="mensaje"');
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// --reply-to debe ser un chatId numérico: evita redirigir la notificación a
|
|
22
|
+
// un chat arbitrario cuando el flag se sintetiza desde input no confiable.
|
|
23
|
+
if (opciones['reply-to'] !== undefined && !/^-?\d+$/.test(String(opciones['reply-to']))) {
|
|
24
|
+
console.error('Error: --reply-to debe ser un chatId numérico');
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const params = { tipo: opciones.tipo || 'custom', texto: opciones.texto };
|
|
29
|
+
if (opciones.to) params.to = opciones.to;
|
|
30
|
+
if (opciones['reply-to'] !== undefined) params.payload = { replyTo: opciones['reply-to'] };
|
|
31
|
+
|
|
32
|
+
const r = notificarGateway(params);
|
|
33
|
+
if (r === false) {
|
|
34
|
+
console.log(JSON.stringify({ ok: false, motivo: 'gateway deshabilitado o tipo no habilitado' }, null, 2));
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
console.log(JSON.stringify(r ?? { ok: true }, null, 2));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = gatewayNotify;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Subcomando `swl-ses liberar-fase` — cierra el gate G0 borrando
|
|
5
|
+
* .planning/locks/fase-activa.json. Lo usa /swl:ejecutar-fase al terminar una
|
|
6
|
+
* fase para que spec-gate.js vuelva a advertir si se reanuda trabajo.
|
|
7
|
+
*
|
|
8
|
+
* Reemplaza el `node -e "...unlinkSync('.planning/locks/fase-activa.json')"`
|
|
9
|
+
* inline (relativo al proyecto). Busca el archivo ascendiendo desde el CWD para
|
|
10
|
+
* funcionar aunque el comando se ejecute desde un subdirectorio.
|
|
11
|
+
*
|
|
12
|
+
* Uso: swl-ses liberar-fase
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const fs = require('node:fs');
|
|
16
|
+
const path = require('node:path');
|
|
17
|
+
|
|
18
|
+
function liberarFase(opciones = {}) {
|
|
19
|
+
let dir = (opciones && opciones.cwd) || process.cwd();
|
|
20
|
+
let target = null;
|
|
21
|
+
while (dir !== path.dirname(dir)) {
|
|
22
|
+
const cand = path.join(dir, '.planning', 'locks', 'fase-activa.json');
|
|
23
|
+
if (fs.existsSync(cand)) {
|
|
24
|
+
target = cand;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
dir = path.dirname(dir);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (target) {
|
|
31
|
+
fs.unlinkSync(target);
|
|
32
|
+
console.log(JSON.stringify({ ok: true, liberado: target }));
|
|
33
|
+
} else {
|
|
34
|
+
console.log(
|
|
35
|
+
JSON.stringify({ ok: true, liberado: null, motivo: 'sin fase activa que liberar' })
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = liberarFase;
|
|
41
|
+
|
|
42
|
+
if (require.main === module) liberarFase();
|