sam-coder-cli 1.0.58 → 1.0.59
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/bin/agi-animation.js +38 -21
- package/package.json +1 -1
package/bin/agi-animation.js
CHANGED
|
@@ -168,19 +168,30 @@ function clearScreen() {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
function getTerminalSize() {
|
|
171
|
+
// Ensure we always have valid numeric values
|
|
172
|
+
const width = Number(process.stdout.columns) || 80;
|
|
173
|
+
const height = Number(process.stdout.rows) || 24;
|
|
174
|
+
|
|
171
175
|
return {
|
|
172
|
-
width:
|
|
173
|
-
height:
|
|
176
|
+
width: Math.max(width, 40), // Minimum width of 40
|
|
177
|
+
height: Math.max(height, 10) // Minimum height of 10
|
|
174
178
|
};
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
function centerText(text, width = getTerminalSize().width) {
|
|
178
|
-
if (!text) return '';
|
|
182
|
+
if (!text || typeof text !== 'string') return '';
|
|
183
|
+
|
|
184
|
+
// Ensure width is a valid number
|
|
185
|
+
const safeWidth = Number(width) || 80;
|
|
186
|
+
|
|
179
187
|
const lines = text.split('\n');
|
|
180
188
|
return lines.map(line => {
|
|
189
|
+
if (!line) return line; // Handle empty lines
|
|
190
|
+
|
|
181
191
|
// Strip ANSI codes to calculate actual text length
|
|
182
192
|
const cleanLine = line.replace(/\x1b\[[0-9;]*m/g, '');
|
|
183
|
-
const
|
|
193
|
+
const lineLength = cleanLine.length || 0;
|
|
194
|
+
const padding = Math.max(0, Math.floor((safeWidth - lineLength) / 2));
|
|
184
195
|
return ' '.repeat(padding) + line;
|
|
185
196
|
}).join('\n');
|
|
186
197
|
}
|
|
@@ -194,6 +205,12 @@ function safeWrite(content) {
|
|
|
194
205
|
}
|
|
195
206
|
}
|
|
196
207
|
|
|
208
|
+
function safeRepeat(str, count) {
|
|
209
|
+
// Ensure count is a valid positive integer
|
|
210
|
+
const safeCount = Math.max(0, Math.floor(Number(count) || 0));
|
|
211
|
+
return str.repeat(safeCount);
|
|
212
|
+
}
|
|
213
|
+
|
|
197
214
|
// Frame interpolation system
|
|
198
215
|
class FrameInterpolator {
|
|
199
216
|
constructor() {
|
|
@@ -329,9 +346,9 @@ async function runAGIAnimation() {
|
|
|
329
346
|
for (let i = 0; i < 30; i++) {
|
|
330
347
|
const dotCount = (i % 4) + 1;
|
|
331
348
|
const dots = '•'.repeat(dotCount) + ' '.repeat(4 - dotCount);
|
|
332
|
-
const frame = '\n'
|
|
349
|
+
const frame = safeRepeat('\n', Math.floor(height / 2) - 2) +
|
|
333
350
|
centerText(dots) +
|
|
334
|
-
'\n'
|
|
351
|
+
safeRepeat('\n', Math.floor(height / 2) - 2);
|
|
335
352
|
voidFrames.push(frame);
|
|
336
353
|
}
|
|
337
354
|
|
|
@@ -358,9 +375,9 @@ async function runAGIAnimation() {
|
|
|
358
375
|
sparkPattern = ` · · ·\n· ·${core}· ·\n · · ·`;
|
|
359
376
|
}
|
|
360
377
|
|
|
361
|
-
const frame = '\n'
|
|
378
|
+
const frame = safeRepeat('\n', Math.floor(height / 2) - 3) +
|
|
362
379
|
centerText(sparkPattern) +
|
|
363
|
-
'\n'
|
|
380
|
+
safeRepeat('\n', Math.floor(height / 2) - 3);
|
|
364
381
|
sparkFrames.push(frame);
|
|
365
382
|
}
|
|
366
383
|
|
|
@@ -390,7 +407,7 @@ async function runAGIAnimation() {
|
|
|
390
407
|
const baseSize = 2 + progress * 4;
|
|
391
408
|
const pulseSize = baseSize + Math.sin(phase * 2) * 1.5;
|
|
392
409
|
|
|
393
|
-
let frame = '\n'
|
|
410
|
+
let frame = safeRepeat('\n', Math.floor(height / 2) - Math.floor(pulseSize) - 2);
|
|
394
411
|
|
|
395
412
|
for (let y = -Math.floor(pulseSize); y <= Math.floor(pulseSize); y++) {
|
|
396
413
|
let line = '';
|
|
@@ -447,7 +464,7 @@ async function runAGIAnimation() {
|
|
|
447
464
|
|
|
448
465
|
for (let i = 0; i < 45; i++) {
|
|
449
466
|
const progress = i / 44;
|
|
450
|
-
let frame = '\n'
|
|
467
|
+
let frame = safeRepeat('\n', Math.floor(height / 2) - layers * 2);
|
|
451
468
|
|
|
452
469
|
for (let layer = 0; layer < layers; layer++) {
|
|
453
470
|
let line = '';
|
|
@@ -525,7 +542,7 @@ async function runAGIAnimation() {
|
|
|
525
542
|
const streamWidth = Math.min(60, Math.floor(width * 0.7));
|
|
526
543
|
|
|
527
544
|
for (let i = 0; i < 30; i++) {
|
|
528
|
-
let frame = '\n'
|
|
545
|
+
let frame = safeRepeat('\n', Math.floor((height - streamHeight) / 2));
|
|
529
546
|
|
|
530
547
|
for (let y = 0; y < streamHeight; y++) {
|
|
531
548
|
let line = '';
|
|
@@ -689,7 +706,7 @@ async function runAGIAnimation() {
|
|
|
689
706
|
// Transition from Matrix Rain to DNA
|
|
690
707
|
clearScreen();
|
|
691
708
|
const matrixToDNAText = centerText('[ DECODING GENETIC ALGORITHMS ]');
|
|
692
|
-
|
|
709
|
+
safeWrite(chalk.greenBright(safeRepeat('\n', Math.floor(height / 2)) + matrixToDNAText));
|
|
693
710
|
await sleep(500);
|
|
694
711
|
|
|
695
712
|
// Fade out transition
|
|
@@ -697,9 +714,9 @@ async function runAGIAnimation() {
|
|
|
697
714
|
clearScreen();
|
|
698
715
|
const opacity = 1 - (i / 10);
|
|
699
716
|
if (opacity > 0.5) {
|
|
700
|
-
safeWrite(chalk.green('\n'
|
|
717
|
+
safeWrite(chalk.green(safeRepeat('\n', Math.floor(height / 2)) + matrixToDNAText));
|
|
701
718
|
} else if (opacity > 0.2) {
|
|
702
|
-
safeWrite(chalk.green.dim('\n'
|
|
719
|
+
safeWrite(chalk.green.dim(safeRepeat('\n', Math.floor(height / 2)) + matrixToDNAText));
|
|
703
720
|
}
|
|
704
721
|
await sleep(frameTime);
|
|
705
722
|
frameCount++;
|
|
@@ -715,7 +732,7 @@ async function runAGIAnimation() {
|
|
|
715
732
|
const helixHeight = Math.min(20, Math.floor(height * 0.6));
|
|
716
733
|
const phase = progress * Math.PI * 4; // Two full rotations
|
|
717
734
|
|
|
718
|
-
let dnaFrame = '\n'
|
|
735
|
+
let dnaFrame = safeRepeat('\n', Math.floor((height - helixHeight) / 2));
|
|
719
736
|
|
|
720
737
|
for (let y = 0; y < helixHeight; y++) {
|
|
721
738
|
const yProgress = y / helixHeight;
|
|
@@ -792,7 +809,7 @@ async function runAGIAnimation() {
|
|
|
792
809
|
|
|
793
810
|
for (let frame = 0; frame < 60; frame++) {
|
|
794
811
|
const progress = frame / 59;
|
|
795
|
-
let circuitFrame = '\n'
|
|
812
|
+
let circuitFrame = safeRepeat('\n', Math.floor((height - circuitHeight) / 2));
|
|
796
813
|
|
|
797
814
|
// Build circuit board progressively
|
|
798
815
|
for (let y = 0; y < circuitHeight; y++) {
|
|
@@ -872,7 +889,7 @@ async function runAGIAnimation() {
|
|
|
872
889
|
const progress = frame / 59;
|
|
873
890
|
const wavePhase = frame * 0.1;
|
|
874
891
|
|
|
875
|
-
let consciousnessFrame = '\n'
|
|
892
|
+
let consciousnessFrame = safeRepeat('\n', Math.floor((height - brainHeight) / 2));
|
|
876
893
|
|
|
877
894
|
// Create brain outline with neural activity
|
|
878
895
|
const brainArt = [
|
|
@@ -981,7 +998,7 @@ async function runAGIAnimation() {
|
|
|
981
998
|
const progress = frame / 59;
|
|
982
999
|
const rotation = progress * Math.PI * 2;
|
|
983
1000
|
|
|
984
|
-
let galaxyFrame = '\n'
|
|
1001
|
+
let galaxyFrame = safeRepeat('\n', Math.floor((height - galaxySize) / 2));
|
|
985
1002
|
|
|
986
1003
|
// Create spiral galaxy
|
|
987
1004
|
for (let y = 0; y < galaxySize; y++) {
|
|
@@ -1051,7 +1068,7 @@ async function runAGIAnimation() {
|
|
|
1051
1068
|
const galaxyToCodeFrames = [];
|
|
1052
1069
|
for (let i = 0; i < 15; i++) {
|
|
1053
1070
|
const progress = i / 14;
|
|
1054
|
-
let transitionFrame = '\n'
|
|
1071
|
+
let transitionFrame = safeRepeat('\n', Math.floor(height / 2) - 2);
|
|
1055
1072
|
|
|
1056
1073
|
// Stars morphing into code characters
|
|
1057
1074
|
const morphChars = ['*', '/', '{', '}', '(', ')', ';', '='];
|
|
@@ -1117,7 +1134,7 @@ async function runAGIAnimation() {
|
|
|
1117
1134
|
|
|
1118
1135
|
for (let frame = 0; frame < 60; frame++) {
|
|
1119
1136
|
const progress = frame / 59;
|
|
1120
|
-
let compilationFrame = '\n'
|
|
1137
|
+
let compilationFrame = safeRepeat('\n', Math.floor((height - codeHeight) / 2));
|
|
1121
1138
|
|
|
1122
1139
|
// Terminal header
|
|
1123
1140
|
compilationFrame += centerText(chalk.gray('┌' + '─'.repeat(codeWidth - 2) + '┐')) + '\n';
|
|
@@ -1405,7 +1422,7 @@ async function runAGIAnimation() {
|
|
|
1405
1422
|
|
|
1406
1423
|
// Final hold with status
|
|
1407
1424
|
clearScreen();
|
|
1408
|
-
let finalDisplay = '\n'
|
|
1425
|
+
let finalDisplay = safeRepeat('\n', Math.max(0, centerY));
|
|
1409
1426
|
for (const line of lines) {
|
|
1410
1427
|
finalDisplay += centerText(line) + '\n';
|
|
1411
1428
|
}
|