sam-coder-cli 1.0.57 → 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 +44 -37
- 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++) {
|
|
@@ -859,28 +876,20 @@ async function runAGIAnimation() {
|
|
|
859
876
|
frameCount++;
|
|
860
877
|
}
|
|
861
878
|
|
|
862
|
-
//
|
|
863
|
-
console.log('\n[DEBUG] Neural pathways phase completed, starting consciousness...');
|
|
864
|
-
await sleep(1000);
|
|
879
|
+
// Neural pathways phase completed
|
|
865
880
|
|
|
866
881
|
// PHASE 10: Consciousness Awakening (2 seconds - 60 frames)
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
// Temporarily disable consciousness sound to test
|
|
870
|
-
// sound.playConsciousnessSound().catch(() => {});
|
|
871
|
-
|
|
872
|
-
console.log('[DEBUG] Starting consciousness frame generation...');
|
|
882
|
+
// Play consciousness sound (non-blocking)
|
|
883
|
+
sound.playConsciousnessSound().catch(() => {});
|
|
873
884
|
const consciousnessFrames = [];
|
|
874
885
|
const brainWidth = Math.min(60, Math.floor(width * 0.7));
|
|
875
886
|
const brainHeight = Math.min(24, Math.floor(height * 0.7));
|
|
876
887
|
|
|
877
|
-
console.log('[DEBUG] About to generate 60 consciousness frames...');
|
|
878
888
|
for (let frame = 0; frame < 60; frame++) {
|
|
879
|
-
if (frame % 10 === 0) console.log(`[DEBUG] Generating consciousness frame ${frame}/60`);
|
|
880
889
|
const progress = frame / 59;
|
|
881
890
|
const wavePhase = frame * 0.1;
|
|
882
891
|
|
|
883
|
-
let consciousnessFrame = '\n'
|
|
892
|
+
let consciousnessFrame = safeRepeat('\n', Math.floor((height - brainHeight) / 2));
|
|
884
893
|
|
|
885
894
|
// Create brain outline with neural activity
|
|
886
895
|
const brainArt = [
|
|
@@ -968,7 +977,7 @@ async function runAGIAnimation() {
|
|
|
968
977
|
consciousnessFrames.push(consciousnessFrame);
|
|
969
978
|
}
|
|
970
979
|
|
|
971
|
-
|
|
980
|
+
|
|
972
981
|
for (const frame of consciousnessFrames) {
|
|
973
982
|
clearScreen();
|
|
974
983
|
safeWrite(frame);
|
|
@@ -976,9 +985,7 @@ async function runAGIAnimation() {
|
|
|
976
985
|
frameCount++;
|
|
977
986
|
}
|
|
978
987
|
|
|
979
|
-
//
|
|
980
|
-
console.log('\n[DEBUG] Consciousness phase completed, starting galaxy formation...');
|
|
981
|
-
await sleep(1000);
|
|
988
|
+
// Consciousness phase completed
|
|
982
989
|
|
|
983
990
|
// PHASE 11: Galaxy Formation (2 seconds - 60 frames)
|
|
984
991
|
// Play galaxy sound (non-blocking)
|
|
@@ -991,7 +998,7 @@ async function runAGIAnimation() {
|
|
|
991
998
|
const progress = frame / 59;
|
|
992
999
|
const rotation = progress * Math.PI * 2;
|
|
993
1000
|
|
|
994
|
-
let galaxyFrame = '\n'
|
|
1001
|
+
let galaxyFrame = safeRepeat('\n', Math.floor((height - galaxySize) / 2));
|
|
995
1002
|
|
|
996
1003
|
// Create spiral galaxy
|
|
997
1004
|
for (let y = 0; y < galaxySize; y++) {
|
|
@@ -1061,7 +1068,7 @@ async function runAGIAnimation() {
|
|
|
1061
1068
|
const galaxyToCodeFrames = [];
|
|
1062
1069
|
for (let i = 0; i < 15; i++) {
|
|
1063
1070
|
const progress = i / 14;
|
|
1064
|
-
let transitionFrame = '\n'
|
|
1071
|
+
let transitionFrame = safeRepeat('\n', Math.floor(height / 2) - 2);
|
|
1065
1072
|
|
|
1066
1073
|
// Stars morphing into code characters
|
|
1067
1074
|
const morphChars = ['*', '/', '{', '}', '(', ')', ';', '='];
|
|
@@ -1127,7 +1134,7 @@ async function runAGIAnimation() {
|
|
|
1127
1134
|
|
|
1128
1135
|
for (let frame = 0; frame < 60; frame++) {
|
|
1129
1136
|
const progress = frame / 59;
|
|
1130
|
-
let compilationFrame = '\n'
|
|
1137
|
+
let compilationFrame = safeRepeat('\n', Math.floor((height - codeHeight) / 2));
|
|
1131
1138
|
|
|
1132
1139
|
// Terminal header
|
|
1133
1140
|
compilationFrame += centerText(chalk.gray('┌' + '─'.repeat(codeWidth - 2) + '┐')) + '\n';
|
|
@@ -1415,7 +1422,7 @@ async function runAGIAnimation() {
|
|
|
1415
1422
|
|
|
1416
1423
|
// Final hold with status
|
|
1417
1424
|
clearScreen();
|
|
1418
|
-
let finalDisplay = '\n'
|
|
1425
|
+
let finalDisplay = safeRepeat('\n', Math.max(0, centerY));
|
|
1419
1426
|
for (const line of lines) {
|
|
1420
1427
|
finalDisplay += centerText(line) + '\n';
|
|
1421
1428
|
}
|
|
@@ -1430,7 +1437,7 @@ async function runAGIAnimation() {
|
|
|
1430
1437
|
process.stdin.resume();
|
|
1431
1438
|
process.stdin.once('data', () => {
|
|
1432
1439
|
process.stdin.setRawMode(false);
|
|
1433
|
-
|
|
1440
|
+
// Don't pause stdin here - let the CLI handle it
|
|
1434
1441
|
resolve();
|
|
1435
1442
|
});
|
|
1436
1443
|
});
|