spec-driven-agility 0.1.0 → 0.4.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/README.md +5 -0
- package/package.json +1 -1
- package/src/animation.js +208 -0
- package/src/cli.js +3 -0
package/README.md
CHANGED
|
@@ -53,11 +53,16 @@ Re-sincroniza comandos y skills. No toca `Backlog/` ni `specs/`.
|
|
|
53
53
|
sda <comando> [ruta]
|
|
54
54
|
|
|
55
55
|
init [ruta] Instala todo en el proyecto (por defecto, el directorio actual).
|
|
56
|
+
Muestra la intro animada; usa --no-animation para omitirla.
|
|
56
57
|
update [ruta] Re-sincroniza comandos y skills.
|
|
57
58
|
version Muestra la versión.
|
|
58
59
|
help Muestra la ayuda.
|
|
59
60
|
```
|
|
60
61
|
|
|
62
|
+
`sda init` muestra una **planta pixel-art en verdes oscuros** hecha con bloques de mosaico
|
|
63
|
+
(`█▓▒░`); el patrón de sombra se desplaza suavemente en bucle, **sin apagarse**, hasta que presionas
|
|
64
|
+
ENTER. En CI o scripts se omite sola; también puedes forzarlo con `sda init --no-animation`.
|
|
65
|
+
|
|
61
66
|
## Filosofía
|
|
62
67
|
|
|
63
68
|
- La fuente de verdad es un **Backlog de Sprint** con historias modificables y descartables.
|
package/package.json
CHANGED
package/src/animation.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Planta pixel-art en verdes oscuros. El mosaico de sombras se desplaza
|
|
2
|
+
// suavemente en bucle continuo hasta que el usuario presiona ENTER.
|
|
3
|
+
// La planta NUNCA se apaga ni se vuelve transparente: el cuerpo siempre
|
|
4
|
+
// queda visible (verde medio/oscuro) y solo cambia el patrón de sombra.
|
|
5
|
+
// Sin dependencias.
|
|
6
|
+
|
|
7
|
+
const W = 27;
|
|
8
|
+
const H = 15;
|
|
9
|
+
|
|
10
|
+
// Niveles: 0 = vacío, 1 = borde, 2 = anillo, 3 = interior.
|
|
11
|
+
function buildLevels() {
|
|
12
|
+
const filled = Array.from({ length: H }, () => Array(W).fill(false));
|
|
13
|
+
|
|
14
|
+
const ell = (cx, cy, rx, ry, on) => {
|
|
15
|
+
for (let y = 0; y < H; y += 1) {
|
|
16
|
+
for (let x = 0; x < W; x += 1) {
|
|
17
|
+
const dx = (x - cx) / rx;
|
|
18
|
+
const dy = (y - cy) / ry;
|
|
19
|
+
if (dx * dx + dy * dy <= 1) filled[y][x] = on;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Dos hojas.
|
|
25
|
+
ell(7.5, 6, 7.5, 5.5, true);
|
|
26
|
+
ell(19.5, 6, 7.5, 5.5, true);
|
|
27
|
+
|
|
28
|
+
// V central entre las hojas.
|
|
29
|
+
for (let y = 2; y <= 9; y += 1) {
|
|
30
|
+
const half = Math.max(0, (9 - y) * 0.7);
|
|
31
|
+
for (let x = Math.floor(13.5 - half); x <= Math.ceil(13.5 + half); x += 1) {
|
|
32
|
+
if (filled[y] && filled[y][x] !== undefined) filled[y][x] = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Tallo.
|
|
37
|
+
for (let y = 9; y <= 12; y += 1) {
|
|
38
|
+
for (let x = 13; x <= 14; x += 1) filled[y][x] = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Montículo.
|
|
42
|
+
ell(13.5, 17, 12, 5, true);
|
|
43
|
+
|
|
44
|
+
const isFilled = (x, y) => x >= 0 && x < W && y >= 0 && y < H && filled[y][x];
|
|
45
|
+
const isEdge = (x, y) =>
|
|
46
|
+
[[1, 0], [-1, 0], [0, 1], [0, -1]].some(([dx, dy]) => !isFilled(x + dx, y + dy));
|
|
47
|
+
|
|
48
|
+
const levels = Array.from({ length: H }, () => Array(W).fill(0));
|
|
49
|
+
for (let y = 0; y < H; y += 1) {
|
|
50
|
+
for (let x = 0; x < W; x += 1) {
|
|
51
|
+
if (!filled[y][x]) continue;
|
|
52
|
+
if (isEdge(x, y)) {
|
|
53
|
+
levels[y][x] = 1;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const nearEdge = [[1, 0], [-1, 0], [0, 1], [0, -1]].some(([dx, dy]) => isEdge(x + dx, y + dy));
|
|
57
|
+
levels[y][x] = nearEdge ? 2 : 3;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return levels;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const LEVELS = buildLevels();
|
|
65
|
+
|
|
66
|
+
const RESET = '\x1b[0m';
|
|
67
|
+
const HIDE = '\x1b[?25l';
|
|
68
|
+
const SHOW = '\x1b[?25h';
|
|
69
|
+
const CLEAR = '\x1b[2K';
|
|
70
|
+
const BLOCK_HEIGHT = H + 1; // sprite + línea del prompt
|
|
71
|
+
|
|
72
|
+
// Verdes oscuros: cuerpo siempre visible (40/34), borde más oscuro (28/22).
|
|
73
|
+
const COLOR = {
|
|
74
|
+
'░': '\x1b[38;5;22m',
|
|
75
|
+
'▒': '\x1b[38;5;28m',
|
|
76
|
+
'▓': '\x1b[38;5;34m',
|
|
77
|
+
'█': '\x1b[38;5;40m',
|
|
78
|
+
};
|
|
79
|
+
const PROMPT_COLOR = '\x1b[38;5;28m';
|
|
80
|
+
const PROMPT = ' Presiona ENTER para continuar... ';
|
|
81
|
+
|
|
82
|
+
function sleep(ms) {
|
|
83
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function canAnimate(stream) {
|
|
87
|
+
if (!stream || !stream.isTTY) return false;
|
|
88
|
+
if (process.env.CI) return false;
|
|
89
|
+
if (process.env.TERM === 'dumb') return false;
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function lineFor(y, phase) {
|
|
94
|
+
let out = '';
|
|
95
|
+
for (let x = 0; x < W; x += 1) {
|
|
96
|
+
const level = LEVELS[y][x];
|
|
97
|
+
if (level === 0) {
|
|
98
|
+
out += ' ';
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
let ch;
|
|
102
|
+
if (level === 1) ch = '░';
|
|
103
|
+
else if (level === 2) ch = '▒';
|
|
104
|
+
else ch = (x + y + phase) % 2 === 0 ? '█' : '▓';
|
|
105
|
+
out += COLOR[ch] + ch + RESET;
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function drawFrame(stream, phase) {
|
|
111
|
+
for (let y = 0; y < H; y += 1) {
|
|
112
|
+
stream.write(`\r${CLEAR}${lineFor(y, phase)}\n`);
|
|
113
|
+
}
|
|
114
|
+
stream.write(`\r${CLEAR}${PROMPT_COLOR}${PROMPT}${RESET}\n`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function erase(stream) {
|
|
118
|
+
stream.write(`\x1b[${BLOCK_HEIGHT}A`);
|
|
119
|
+
for (let i = 0; i < BLOCK_HEIGHT; i += 1) {
|
|
120
|
+
stream.write(`\r${CLEAR}\n`);
|
|
121
|
+
}
|
|
122
|
+
stream.write(`\x1b[${BLOCK_HEIGHT}A`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function drawLoop(stream, { frames, delay = 110, stopWhen } = {}) {
|
|
126
|
+
let first = true;
|
|
127
|
+
let frame = 0;
|
|
128
|
+
|
|
129
|
+
while (true) {
|
|
130
|
+
if (stopWhen && stopWhen()) break;
|
|
131
|
+
if (frames !== undefined && frame >= frames) break;
|
|
132
|
+
|
|
133
|
+
if (!first) stream.write(`\x1b[${BLOCK_HEIGHT}A`);
|
|
134
|
+
// La sombra se desplaza cada 3 frames: movimiento lento y continuo.
|
|
135
|
+
const phase = Math.floor(frame / 3) % 2;
|
|
136
|
+
drawFrame(stream, phase);
|
|
137
|
+
first = false;
|
|
138
|
+
frame += 1;
|
|
139
|
+
await sleep(delay);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function waitForKey(stdin) {
|
|
144
|
+
return new Promise((resolve) => {
|
|
145
|
+
const onData = (key) => {
|
|
146
|
+
if (key === '\u0003') {
|
|
147
|
+
stdin.setRawMode(false);
|
|
148
|
+
stdin.pause();
|
|
149
|
+
stdin.removeListener('data', onData);
|
|
150
|
+
process.stdout.write(SHOW);
|
|
151
|
+
process.exit(130);
|
|
152
|
+
}
|
|
153
|
+
if (key === '\r' || key === '\n') {
|
|
154
|
+
stdin.setRawMode(false);
|
|
155
|
+
stdin.pause();
|
|
156
|
+
stdin.removeListener('data', onData);
|
|
157
|
+
resolve();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
stdin.setRawMode(true);
|
|
162
|
+
stdin.resume();
|
|
163
|
+
stdin.setEncoding('utf8');
|
|
164
|
+
stdin.on('data', onData);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Intro animada: planta pixel-art con sombra en movimiento hasta ENTER.
|
|
170
|
+
* Se omite en CI, salidas no interactivas o con `--no-animation`.
|
|
171
|
+
*/
|
|
172
|
+
export async function playIntro({
|
|
173
|
+
enabled = true,
|
|
174
|
+
stream = process.stdout,
|
|
175
|
+
stdin = process.stdin,
|
|
176
|
+
frames,
|
|
177
|
+
} = {}) {
|
|
178
|
+
if (!enabled || !canAnimate(stream)) return false;
|
|
179
|
+
|
|
180
|
+
stream.write(HIDE);
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
if (frames !== undefined) {
|
|
184
|
+
await drawLoop(stream, { frames, delay: 80 });
|
|
185
|
+
erase(stream);
|
|
186
|
+
stream.write(SHOW);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let stop = false;
|
|
191
|
+
const loop = drawLoop(stream, { stopWhen: () => stop });
|
|
192
|
+
|
|
193
|
+
if (stdin.isTTY) {
|
|
194
|
+
await waitForKey(stdin);
|
|
195
|
+
} else {
|
|
196
|
+
await sleep(2000);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
stop = true;
|
|
200
|
+
await loop;
|
|
201
|
+
erase(stream);
|
|
202
|
+
stream.write(SHOW);
|
|
203
|
+
return true;
|
|
204
|
+
} catch {
|
|
205
|
+
stream.write(SHOW);
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { PACKAGE_ROOT } from './templates.js';
|
|
4
4
|
import { runInit, runUpdate } from './installer.js';
|
|
5
|
+
import { playIntro } from './animation.js';
|
|
5
6
|
|
|
6
7
|
function readVersion() {
|
|
7
8
|
const pkg = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
|
|
@@ -18,6 +19,7 @@ Uso:
|
|
|
18
19
|
Comandos:
|
|
19
20
|
init [ruta] Instala los comandos /sda-*, las skills y las carpetas
|
|
20
21
|
Backlog/ y specs/. Por defecto usa el directorio actual.
|
|
22
|
+
Usa --no-animation para omitir la intro animada.
|
|
21
23
|
update [ruta] Re-sincroniza comandos y skills. No toca config ni datos.
|
|
22
24
|
version Muestra la versión instalada.
|
|
23
25
|
help Muestra esta ayuda.
|
|
@@ -47,6 +49,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
47
49
|
console.log(readVersion());
|
|
48
50
|
return;
|
|
49
51
|
case 'init':
|
|
52
|
+
await playIntro({ enabled: !rest.includes('--no-animation') });
|
|
50
53
|
runInit(target);
|
|
51
54
|
return;
|
|
52
55
|
case 'update':
|