spec-driven-agility 0.2.0 → 0.5.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.
- package/README.md +3 -2
- package/package.json +1 -1
- package/src/animation.js +189 -89
package/README.md
CHANGED
|
@@ -59,8 +59,9 @@ version Muestra la versión.
|
|
|
59
59
|
help Muestra la ayuda.
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
`sda init`
|
|
63
|
-
|
|
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`.
|
|
64
65
|
|
|
65
66
|
## Filosofía
|
|
66
67
|
|
package/package.json
CHANGED
package/src/animation.js
CHANGED
|
@@ -1,72 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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',
|
|
67
78
|
};
|
|
79
|
+
const PROMPT_COLOR = '\x1b[38;5;28m';
|
|
80
|
+
const PROMPT = ' Press ENTER to continue... ';
|
|
68
81
|
|
|
69
|
-
|
|
82
|
+
// Panel a la derecha de la planta.
|
|
83
|
+
const PANEL_GAP = ' ';
|
|
84
|
+
const PANEL = {
|
|
85
|
+
6: { text: 'Spec Driven Agility', color: '\x1b[1m\x1b[38;5;40m' },
|
|
86
|
+
8: { text: 'Injecting commands and skills', color: '\x1b[38;5;34m' },
|
|
87
|
+
9: { text: 'into the repository root.', color: '\x1b[38;5;34m' },
|
|
88
|
+
};
|
|
70
89
|
|
|
71
90
|
function sleep(ms) {
|
|
72
91
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -79,44 +98,125 @@ function canAnimate(stream) {
|
|
|
79
98
|
return true;
|
|
80
99
|
}
|
|
81
100
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for (let line = 0; line < HEIGHT; line += 1) {
|
|
90
|
-
stream.write(`\r${ESC.clear}${FRAMES[frame][line]}\n`);
|
|
101
|
+
function lineFor(y, phase) {
|
|
102
|
+
let out = '';
|
|
103
|
+
for (let x = 0; x < W; x += 1) {
|
|
104
|
+
const level = LEVELS[y][x];
|
|
105
|
+
if (level === 0) {
|
|
106
|
+
out += ' ';
|
|
107
|
+
continue;
|
|
91
108
|
}
|
|
109
|
+
let ch;
|
|
110
|
+
if (level === 1) ch = '░';
|
|
111
|
+
else if (level === 2) ch = '▒';
|
|
112
|
+
else ch = (x + y + phase) % 2 === 0 ? '█' : '▓';
|
|
113
|
+
out += COLOR[ch] + ch + RESET;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const panel = PANEL[y];
|
|
117
|
+
if (panel) {
|
|
118
|
+
out += `${PANEL_GAP}${panel.color}${panel.text}${RESET}`;
|
|
92
119
|
}
|
|
93
120
|
|
|
94
|
-
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function drawFrame(stream, phase) {
|
|
125
|
+
for (let y = 0; y < H; y += 1) {
|
|
126
|
+
stream.write(`\r${CLEAR}${lineFor(y, phase)}\n`);
|
|
127
|
+
}
|
|
128
|
+
stream.write(`\r${CLEAR}${PROMPT_COLOR}${PROMPT}${RESET}\n`);
|
|
95
129
|
}
|
|
96
130
|
|
|
97
|
-
function
|
|
131
|
+
function erase(stream) {
|
|
132
|
+
stream.write(`\x1b[${BLOCK_HEIGHT}A`);
|
|
133
|
+
for (let i = 0; i < BLOCK_HEIGHT; i += 1) {
|
|
134
|
+
stream.write(`\r${CLEAR}\n`);
|
|
135
|
+
}
|
|
136
|
+
stream.write(`\x1b[${BLOCK_HEIGHT}A`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function drawLoop(stream, { frames, delay = 110, stopWhen } = {}) {
|
|
140
|
+
let first = true;
|
|
141
|
+
let frame = 0;
|
|
142
|
+
|
|
143
|
+
while (true) {
|
|
144
|
+
if (stopWhen && stopWhen()) break;
|
|
145
|
+
if (frames !== undefined && frame >= frames) break;
|
|
146
|
+
|
|
147
|
+
if (!first) stream.write(`\x1b[${BLOCK_HEIGHT}A`);
|
|
148
|
+
// La sombra se desplaza cada 3 frames: movimiento lento y continuo.
|
|
149
|
+
const phase = Math.floor(frame / 3) % 2;
|
|
150
|
+
drawFrame(stream, phase);
|
|
151
|
+
first = false;
|
|
152
|
+
frame += 1;
|
|
153
|
+
await sleep(delay);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function waitForKey(stdin) {
|
|
98
158
|
return new Promise((resolve) => {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
159
|
+
const onData = (key) => {
|
|
160
|
+
if (key === '\u0003') {
|
|
161
|
+
stdin.setRawMode(false);
|
|
162
|
+
stdin.pause();
|
|
163
|
+
stdin.removeListener('data', onData);
|
|
164
|
+
process.stdout.write(SHOW);
|
|
165
|
+
process.exit(130);
|
|
166
|
+
}
|
|
167
|
+
if (key === '\r' || key === '\n') {
|
|
168
|
+
stdin.setRawMode(false);
|
|
169
|
+
stdin.pause();
|
|
170
|
+
stdin.removeListener('data', onData);
|
|
171
|
+
resolve();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
stdin.setRawMode(true);
|
|
176
|
+
stdin.resume();
|
|
177
|
+
stdin.setEncoding('utf8');
|
|
178
|
+
stdin.on('data', onData);
|
|
104
179
|
});
|
|
105
180
|
}
|
|
106
181
|
|
|
107
182
|
/**
|
|
108
|
-
*
|
|
109
|
-
* Se omite
|
|
183
|
+
* Intro animada: planta pixel-art con sombra en movimiento hasta ENTER.
|
|
184
|
+
* Se omite en CI, salidas no interactivas o con `--no-animation`.
|
|
110
185
|
*/
|
|
111
|
-
export async function playIntro({
|
|
186
|
+
export async function playIntro({
|
|
187
|
+
enabled = true,
|
|
188
|
+
stream = process.stdout,
|
|
189
|
+
stdin = process.stdin,
|
|
190
|
+
frames,
|
|
191
|
+
} = {}) {
|
|
112
192
|
if (!enabled || !canAnimate(stream)) return false;
|
|
113
193
|
|
|
194
|
+
stream.write(HIDE);
|
|
195
|
+
|
|
114
196
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
197
|
+
if (frames !== undefined) {
|
|
198
|
+
await drawLoop(stream, { frames, delay: 80 });
|
|
199
|
+
erase(stream);
|
|
200
|
+
stream.write(SHOW);
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
let stop = false;
|
|
205
|
+
const loop = drawLoop(stream, { stopWhen: () => stop });
|
|
206
|
+
|
|
207
|
+
if (stdin.isTTY) {
|
|
208
|
+
await waitForKey(stdin);
|
|
209
|
+
} else {
|
|
210
|
+
await sleep(2000);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
stop = true;
|
|
214
|
+
await loop;
|
|
215
|
+
erase(stream);
|
|
216
|
+
stream.write(SHOW);
|
|
117
217
|
return true;
|
|
118
218
|
} catch {
|
|
119
|
-
stream.write(
|
|
219
|
+
stream.write(SHOW);
|
|
120
220
|
return false;
|
|
121
221
|
}
|
|
122
222
|
}
|