sam-coder-cli 1.0.47 â 1.0.49
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 +756 -0
- package/bin/agi-cli.js +158 -68
- package/bin/ui.js +47 -1
- package/package.json +3 -2
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const { exec } = require('child_process');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
// ANSI escape codes for advanced effects
|
|
6
|
+
const ANSI = {
|
|
7
|
+
clear: '\x1Bc',
|
|
8
|
+
hideCursor: '\x1B[?25l',
|
|
9
|
+
showCursor: '\x1B[?25h',
|
|
10
|
+
moveTo: (x, y) => `\x1B[${y};${x}H`,
|
|
11
|
+
clearLine: '\x1B[2K',
|
|
12
|
+
clearScreen: '\x1B[2J\x1B[0;0H',
|
|
13
|
+
reset: '\x1B[0m',
|
|
14
|
+
bold: '\x1B[1m',
|
|
15
|
+
dim: '\x1B[2m',
|
|
16
|
+
italic: '\x1B[3m',
|
|
17
|
+
underline: '\x1B[4m',
|
|
18
|
+
blink: '\x1B[5m',
|
|
19
|
+
reverse: '\x1B[7m',
|
|
20
|
+
strikethrough: '\x1B[9m',
|
|
21
|
+
saveCursor: '\x1B[s',
|
|
22
|
+
restoreCursor: '\x1B[u'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Music/Sound generation using system beeps and terminal bells
|
|
26
|
+
class SoundGenerator {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.isWindows = os.platform() === 'win32';
|
|
29
|
+
this.isMac = os.platform() === 'darwin';
|
|
30
|
+
this.isLinux = os.platform() === 'linux';
|
|
31
|
+
this.soundEnabled = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async playBeep(frequency = 440, duration = 100) {
|
|
35
|
+
if (!this.soundEnabled) return;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
if (this.isWindows) {
|
|
40
|
+
exec(`powershell -c "[console]::beep(${frequency},${duration})"`, { stdio: 'ignore' }, () => resolve());
|
|
41
|
+
} else if (this.isMac) {
|
|
42
|
+
exec(`osascript -e 'beep'`, { stdio: 'ignore' }, () => resolve());
|
|
43
|
+
} else if (this.isLinux) {
|
|
44
|
+
exec(`beep -f ${frequency} -l ${duration} 2>/dev/null || echo -e '\\a'`, { stdio: 'ignore' }, () => resolve());
|
|
45
|
+
} else {
|
|
46
|
+
process.stdout.write('\x07');
|
|
47
|
+
resolve();
|
|
48
|
+
}
|
|
49
|
+
// Fallback timeout
|
|
50
|
+
setTimeout(resolve, duration + 50);
|
|
51
|
+
});
|
|
52
|
+
} catch (error) {
|
|
53
|
+
// Silently fail for sound issues
|
|
54
|
+
this.soundEnabled = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async playSequence(notes) {
|
|
59
|
+
for (const note of notes) {
|
|
60
|
+
await this.playBeep(note.freq, note.duration);
|
|
61
|
+
await sleep(note.pause || 50);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async playStartupSound() {
|
|
66
|
+
const notes = [
|
|
67
|
+
{ freq: 261, duration: 100 }, // C
|
|
68
|
+
{ freq: 329, duration: 100 }, // E
|
|
69
|
+
{ freq: 392, duration: 100 }, // G
|
|
70
|
+
{ freq: 523, duration: 200 }, // C (octave up)
|
|
71
|
+
];
|
|
72
|
+
await this.playSequence(notes);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async playGlitchSound() {
|
|
76
|
+
for (let i = 0; i < 5; i++) {
|
|
77
|
+
await this.playBeep(Math.random() * 800 + 200, 30);
|
|
78
|
+
await sleep(20);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async playAwakeningSound() {
|
|
83
|
+
const notes = [
|
|
84
|
+
{ freq: 130, duration: 300 }, // Low C
|
|
85
|
+
{ freq: 196, duration: 200 }, // G
|
|
86
|
+
{ freq: 261, duration: 200 }, // C
|
|
87
|
+
{ freq: 392, duration: 200 }, // G
|
|
88
|
+
{ freq: 523, duration: 400 }, // High C
|
|
89
|
+
];
|
|
90
|
+
await this.playSequence(notes);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const sound = new SoundGenerator();
|
|
95
|
+
|
|
96
|
+
// Utility functions
|
|
97
|
+
function sleep(ms) {
|
|
98
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function clearScreen() {
|
|
102
|
+
// Use more reliable screen clearing
|
|
103
|
+
process.stdout.write(ANSI.clearScreen);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getTerminalSize() {
|
|
107
|
+
return {
|
|
108
|
+
width: process.stdout.columns || 80,
|
|
109
|
+
height: process.stdout.rows || 24
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function centerText(text, width = getTerminalSize().width) {
|
|
114
|
+
if (!text) return '';
|
|
115
|
+
const lines = text.split('\n');
|
|
116
|
+
return lines.map(line => {
|
|
117
|
+
// Strip ANSI codes to calculate actual text length
|
|
118
|
+
const cleanLine = line.replace(/\x1b\[[0-9;]*m/g, '');
|
|
119
|
+
const padding = Math.max(0, Math.floor((width - cleanLine.length) / 2));
|
|
120
|
+
return ' '.repeat(padding) + line;
|
|
121
|
+
}).join('\n');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function safeWrite(content) {
|
|
125
|
+
try {
|
|
126
|
+
process.stdout.write(content);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
// Fallback for terminal issues
|
|
129
|
+
console.log(content);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Frame interpolation system
|
|
134
|
+
class FrameInterpolator {
|
|
135
|
+
constructor() {
|
|
136
|
+
this.fps = 30;
|
|
137
|
+
this.frameDuration = 1000 / this.fps; // ~33ms per frame for smoother animation
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Interpolate between two ASCII art frames
|
|
141
|
+
interpolateFrames(frame1, frame2, steps = 10) {
|
|
142
|
+
const frames = [frame1];
|
|
143
|
+
|
|
144
|
+
for (let i = 1; i < steps; i++) {
|
|
145
|
+
const ratio = i / steps;
|
|
146
|
+
const interpolated = this.interpolateText(frame1, frame2, ratio);
|
|
147
|
+
frames.push(interpolated);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
frames.push(frame2);
|
|
151
|
+
return frames;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Interpolate between two text blocks
|
|
155
|
+
interpolateText(text1, text2, ratio) {
|
|
156
|
+
const lines1 = text1.split('\n');
|
|
157
|
+
const lines2 = text2.split('\n');
|
|
158
|
+
const maxLines = Math.max(lines1.length, lines2.length);
|
|
159
|
+
const result = [];
|
|
160
|
+
|
|
161
|
+
for (let i = 0; i < maxLines; i++) {
|
|
162
|
+
const line1 = lines1[i] || '';
|
|
163
|
+
const line2 = lines2[i] || '';
|
|
164
|
+
const interpolated = this.interpolateLine(line1, line2, ratio);
|
|
165
|
+
result.push(interpolated);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return result.join('\n');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Interpolate between two lines character by character
|
|
172
|
+
interpolateLine(line1, line2, ratio) {
|
|
173
|
+
const maxLen = Math.max(line1.length, line2.length);
|
|
174
|
+
let result = '';
|
|
175
|
+
|
|
176
|
+
for (let i = 0; i < maxLen; i++) {
|
|
177
|
+
const char1 = line1[i] || ' ';
|
|
178
|
+
const char2 = line2[i] || ' ';
|
|
179
|
+
|
|
180
|
+
if (Math.random() < ratio) {
|
|
181
|
+
result += char2;
|
|
182
|
+
} else {
|
|
183
|
+
result += char1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Create fade effect frames
|
|
191
|
+
fadeFrames(frame, fadeIn = true, steps = 10) {
|
|
192
|
+
const frames = [];
|
|
193
|
+
const chars = frame.split('');
|
|
194
|
+
|
|
195
|
+
for (let i = 0; i <= steps; i++) {
|
|
196
|
+
const ratio = fadeIn ? i / steps : 1 - (i / steps);
|
|
197
|
+
const visibleChars = Math.floor(chars.length * ratio);
|
|
198
|
+
|
|
199
|
+
let fadedFrame = '';
|
|
200
|
+
for (let j = 0; j < chars.length; j++) {
|
|
201
|
+
if (j < visibleChars && chars[j] !== ' ' && chars[j] !== '\n') {
|
|
202
|
+
fadedFrame += chars[j];
|
|
203
|
+
} else if (chars[j] === '\n') {
|
|
204
|
+
fadedFrame += '\n';
|
|
205
|
+
} else {
|
|
206
|
+
fadedFrame += ' ';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
frames.push(fadedFrame);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return fadeIn ? frames : frames.reverse();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Create expansion effect
|
|
217
|
+
expandFrames(centerChar, finalFrame, steps = 15) {
|
|
218
|
+
const frames = [];
|
|
219
|
+
const lines = finalFrame.split('\n');
|
|
220
|
+
const centerY = Math.floor(lines.length / 2);
|
|
221
|
+
const centerX = Math.floor((lines[centerY] || '').length / 2);
|
|
222
|
+
|
|
223
|
+
for (let step = 0; step <= steps; step++) {
|
|
224
|
+
const radius = (step / steps) * Math.max(centerY, centerX);
|
|
225
|
+
let frame = '';
|
|
226
|
+
|
|
227
|
+
for (let y = 0; y < lines.length; y++) {
|
|
228
|
+
let line = '';
|
|
229
|
+
for (let x = 0; x < lines[y].length; x++) {
|
|
230
|
+
const distance = Math.sqrt(Math.pow(x - centerX, 2) + Math.pow(y - centerY, 2));
|
|
231
|
+
|
|
232
|
+
if (distance <= radius) {
|
|
233
|
+
line += lines[y][x];
|
|
234
|
+
} else {
|
|
235
|
+
line += ' ';
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
frame += line + '\n';
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
frames.push(frame);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return frames;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const interpolator = new FrameInterpolator();
|
|
249
|
+
|
|
250
|
+
// Animation sequence with 30 FPS
|
|
251
|
+
async function runAGIAnimation() {
|
|
252
|
+
const { width, height } = getTerminalSize();
|
|
253
|
+
process.stdout.write(ANSI.hideCursor);
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
const startTime = Date.now();
|
|
257
|
+
let frameCount = 0;
|
|
258
|
+
const frameTime = interpolator.frameDuration;
|
|
259
|
+
|
|
260
|
+
// Start with ambient sound (non-blocking)
|
|
261
|
+
sound.playStartupSound().catch(() => {}); // Ignore sound errors
|
|
262
|
+
|
|
263
|
+
// PHASE 1: The Void (1 second - 30 frames)
|
|
264
|
+
const voidFrames = [];
|
|
265
|
+
for (let i = 0; i < 30; i++) {
|
|
266
|
+
const dotCount = (i % 4) + 1;
|
|
267
|
+
const dots = 'âĸ'.repeat(dotCount) + ' '.repeat(4 - dotCount);
|
|
268
|
+
const frame = '\n'.repeat(Math.floor(height / 2) - 2) +
|
|
269
|
+
centerText(dots) +
|
|
270
|
+
'\n'.repeat(Math.floor(height / 2) - 2);
|
|
271
|
+
voidFrames.push(frame);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
for (const frame of voidFrames) {
|
|
275
|
+
clearScreen();
|
|
276
|
+
safeWrite(chalk.dim.gray(frame));
|
|
277
|
+
await sleep(frameTime);
|
|
278
|
+
frameCount++;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// PHASE 2: Spark Formation (1 second - 30 frames)
|
|
282
|
+
const sparkFrames = [];
|
|
283
|
+
for (let i = 0; i < 30; i++) {
|
|
284
|
+
const progress = i / 29;
|
|
285
|
+
const intensity = Math.sin(progress * Math.PI * 2) * 0.5 + 0.5;
|
|
286
|
+
|
|
287
|
+
let sparkPattern;
|
|
288
|
+
if (progress < 0.3) {
|
|
289
|
+
sparkPattern = '¡';
|
|
290
|
+
} else if (progress < 0.6) {
|
|
291
|
+
sparkPattern = ` ¡\n ¡âĸ¡\n ¡`;
|
|
292
|
+
} else {
|
|
293
|
+
const core = intensity > 0.7 ? 'â' : 'â';
|
|
294
|
+
sparkPattern = ` ¡ ¡ ¡\n¡ ¡${core}¡ ¡\n ¡ ¡ ¡`;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const frame = '\n'.repeat(Math.floor(height / 2) - 3) +
|
|
298
|
+
centerText(sparkPattern) +
|
|
299
|
+
'\n'.repeat(Math.floor(height / 2) - 3);
|
|
300
|
+
sparkFrames.push(frame);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
for (const frame of sparkFrames) {
|
|
304
|
+
clearScreen();
|
|
305
|
+
safeWrite(chalk.white.bright(frame));
|
|
306
|
+
await sleep(frameTime);
|
|
307
|
+
frameCount++;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// PHASE 3: Quantum Expansion (1.5 seconds - 45 frames)
|
|
311
|
+
const quantumFrames = [];
|
|
312
|
+
const quantumChars = ['â', 'â', 'âĒ', 'âĢ', 'â', 'â', 'â', 'â'];
|
|
313
|
+
|
|
314
|
+
for (let i = 0; i < 45; i++) {
|
|
315
|
+
const progress = i / 44;
|
|
316
|
+
const phase = progress * Math.PI * 4;
|
|
317
|
+
const baseSize = 2 + progress * 4;
|
|
318
|
+
const pulseSize = baseSize + Math.sin(phase * 2) * 1.5;
|
|
319
|
+
|
|
320
|
+
let frame = '\n'.repeat(Math.floor(height / 2) - Math.floor(pulseSize) - 2);
|
|
321
|
+
|
|
322
|
+
for (let y = -Math.floor(pulseSize); y <= Math.floor(pulseSize); y++) {
|
|
323
|
+
let line = '';
|
|
324
|
+
for (let x = -Math.floor(pulseSize * 1.5); x <= Math.floor(pulseSize * 1.5); x++) {
|
|
325
|
+
const dist = Math.sqrt(x * x + y * y);
|
|
326
|
+
const normalizedDist = dist / pulseSize;
|
|
327
|
+
|
|
328
|
+
if (normalizedDist <= 1) {
|
|
329
|
+
// Use consistent pattern based on position and time
|
|
330
|
+
const charIndex = (Math.floor(x + y + i * 0.5)) % quantumChars.length;
|
|
331
|
+
const char = quantumChars[Math.abs(charIndex)];
|
|
332
|
+
|
|
333
|
+
// Add wave effect
|
|
334
|
+
const wave = Math.sin(dist * 0.5 + phase) * 0.5 + 0.5;
|
|
335
|
+
if (wave > 0.3) {
|
|
336
|
+
line += char;
|
|
337
|
+
} else {
|
|
338
|
+
line += '¡';
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
line += ' ';
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
frame += centerText(line) + '\n';
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
quantumFrames.push(frame);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
for (let i = 0; i < quantumFrames.length; i++) {
|
|
351
|
+
clearScreen();
|
|
352
|
+
const colorCycle = i / 15; // Slower color cycling
|
|
353
|
+
let color;
|
|
354
|
+
if (colorCycle < 1) {
|
|
355
|
+
color = chalk.blue;
|
|
356
|
+
} else if (colorCycle < 2) {
|
|
357
|
+
color = chalk.cyan;
|
|
358
|
+
} else {
|
|
359
|
+
color = chalk.magenta;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
safeWrite(color(quantumFrames[i]));
|
|
363
|
+
await sleep(frameTime);
|
|
364
|
+
frameCount++;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// PHASE 4: Neural Network Formation (1.5 seconds - 45 frames)
|
|
368
|
+
const neuralFrames = [];
|
|
369
|
+
const nodes = 6;
|
|
370
|
+
const layers = 4;
|
|
371
|
+
|
|
372
|
+
// Play glitch sound (non-blocking)
|
|
373
|
+
sound.playGlitchSound().catch(() => {});
|
|
374
|
+
|
|
375
|
+
for (let i = 0; i < 45; i++) {
|
|
376
|
+
const progress = i / 44;
|
|
377
|
+
let frame = '\n'.repeat(Math.floor(height / 2) - layers * 2);
|
|
378
|
+
|
|
379
|
+
for (let layer = 0; layer < layers; layer++) {
|
|
380
|
+
let line = '';
|
|
381
|
+
const layerProgress = Math.max(0, (progress - layer * 0.2) * 2);
|
|
382
|
+
|
|
383
|
+
for (let node = 0; node < nodes; node++) {
|
|
384
|
+
const nodeProgress = Math.max(0, (layerProgress - node * 0.1) * 3);
|
|
385
|
+
|
|
386
|
+
if (nodeProgress > 0.5) {
|
|
387
|
+
// Animate node activation
|
|
388
|
+
const activation = Math.sin(i * 0.3 + layer + node) * 0.5 + 0.5;
|
|
389
|
+
if (activation > 0.7) {
|
|
390
|
+
line += chalk.cyan.bright('â');
|
|
391
|
+
} else if (activation > 0.3) {
|
|
392
|
+
line += chalk.cyan('â¯');
|
|
393
|
+
} else {
|
|
394
|
+
line += chalk.dim('â');
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
line += '¡';
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (node < nodes - 1) {
|
|
401
|
+
// Animate connections
|
|
402
|
+
const connProgress = Math.max(0, (layerProgress - (node + 0.5) * 0.1) * 3);
|
|
403
|
+
if (connProgress > 0.5) {
|
|
404
|
+
const pulse = Math.sin(i * 0.4 + layer + node) > 0;
|
|
405
|
+
line += pulse ? chalk.cyan('ââ') : chalk.dim('ââ');
|
|
406
|
+
} else {
|
|
407
|
+
line += ' ';
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
frame += centerText(line) + '\n';
|
|
412
|
+
|
|
413
|
+
if (layer < layers - 1) {
|
|
414
|
+
// Vertical connection lines
|
|
415
|
+
let connLine = '';
|
|
416
|
+
for (let node = 0; node < nodes; node++) {
|
|
417
|
+
const nodeProgress = Math.max(0, (layerProgress - node * 0.1) * 3);
|
|
418
|
+
if (nodeProgress > 0.5) {
|
|
419
|
+
const pulse = Math.sin(i * 0.2 + layer + node) > 0;
|
|
420
|
+
connLine += pulse ? chalk.cyan('â') : chalk.dim('â');
|
|
421
|
+
} else {
|
|
422
|
+
connLine += ' ';
|
|
423
|
+
}
|
|
424
|
+
if (node < nodes - 1) connLine += ' ';
|
|
425
|
+
}
|
|
426
|
+
frame += centerText(connLine) + '\n';
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
neuralFrames.push(frame);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
for (const frame of neuralFrames) {
|
|
434
|
+
clearScreen();
|
|
435
|
+
safeWrite(frame);
|
|
436
|
+
await sleep(frameTime);
|
|
437
|
+
frameCount++;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// PHASE 5: Data Stream (1 second - 30 frames)
|
|
441
|
+
const dataFrames = [];
|
|
442
|
+
const streamHeight = Math.min(12, Math.floor(height * 0.4));
|
|
443
|
+
const streamWidth = Math.min(60, Math.floor(width * 0.7));
|
|
444
|
+
|
|
445
|
+
for (let i = 0; i < 30; i++) {
|
|
446
|
+
let frame = '\n'.repeat(Math.floor((height - streamHeight) / 2));
|
|
447
|
+
|
|
448
|
+
for (let y = 0; y < streamHeight; y++) {
|
|
449
|
+
let line = '';
|
|
450
|
+
|
|
451
|
+
for (let x = 0; x < streamWidth; x++) {
|
|
452
|
+
// Create flowing data pattern
|
|
453
|
+
const wave1 = Math.sin((x + i * 2) * 0.1) * 0.5 + 0.5;
|
|
454
|
+
const wave2 = Math.cos((y + i * 1.5) * 0.15) * 0.5 + 0.5;
|
|
455
|
+
const combined = wave1 * wave2;
|
|
456
|
+
|
|
457
|
+
if (combined > 0.7) {
|
|
458
|
+
// Binary data
|
|
459
|
+
const bit = ((x + y + i) % 7) < 3 ? '1' : '0';
|
|
460
|
+
line += chalk.green.bright(bit);
|
|
461
|
+
} else if (combined > 0.4) {
|
|
462
|
+
// Block characters
|
|
463
|
+
const blocks = ['â', 'â', 'â', 'â'];
|
|
464
|
+
const blockIndex = ((x + y + i) % blocks.length);
|
|
465
|
+
line += chalk.green(blocks[blockIndex]);
|
|
466
|
+
} else if (combined > 0.2) {
|
|
467
|
+
// Hexadecimal
|
|
468
|
+
const hex = '0123456789ABCDEF';
|
|
469
|
+
const hexChar = hex[((x * 7 + y * 3 + i) % hex.length)];
|
|
470
|
+
line += chalk.green.dim(hexChar);
|
|
471
|
+
} else {
|
|
472
|
+
line += ' ';
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
frame += centerText(line) + '\n';
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
dataFrames.push(frame);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
for (const frame of dataFrames) {
|
|
483
|
+
clearScreen();
|
|
484
|
+
safeWrite(frame);
|
|
485
|
+
await sleep(frameTime);
|
|
486
|
+
frameCount++;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// PHASE 6: Loading Bar (1 second - 30 frames)
|
|
490
|
+
for (let i = 0; i < 30; i++) {
|
|
491
|
+
const progress = i / 29;
|
|
492
|
+
const barWidth = 38;
|
|
493
|
+
const filled = Math.floor(barWidth * progress);
|
|
494
|
+
const remaining = barWidth - filled;
|
|
495
|
+
|
|
496
|
+
// Animated loading bar with gradient effect
|
|
497
|
+
let bar = '';
|
|
498
|
+
for (let j = 0; j < filled; j++) {
|
|
499
|
+
const intensity = (j / filled) * 0.7 + 0.3;
|
|
500
|
+
if (intensity > 0.8) {
|
|
501
|
+
bar += chalk.cyan.bright('â');
|
|
502
|
+
} else if (intensity > 0.5) {
|
|
503
|
+
bar += chalk.cyan('â');
|
|
504
|
+
} else {
|
|
505
|
+
bar += chalk.cyan.dim('â');
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// Add loading cursor
|
|
510
|
+
if (remaining > 0 && i < 29) {
|
|
511
|
+
const cursor = ['â', 'â'][i % 2];
|
|
512
|
+
bar += chalk.cyan.bright(cursor);
|
|
513
|
+
bar += chalk.gray('â').repeat(remaining - 1);
|
|
514
|
+
} else {
|
|
515
|
+
bar += chalk.gray('â').repeat(remaining);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const percent = Math.floor(progress * 100);
|
|
519
|
+
|
|
520
|
+
const loadingBox = `
|
|
521
|
+
ââââââââââââââââââââââââââââââââââââââââââââââ
|
|
522
|
+
â INITIALIZING SAM-CODER â
|
|
523
|
+
â âââââââââââââââââââââââââââââââââââââââââââââŖ
|
|
524
|
+
â ${bar} â
|
|
525
|
+
â ${percent.toString().padStart(3)}% Complete â
|
|
526
|
+
ââââââââââââââââââââââââââââââââââââââââââââââ`;
|
|
527
|
+
|
|
528
|
+
clearScreen();
|
|
529
|
+
safeWrite(chalk.cyan(centerText(loadingBox)));
|
|
530
|
+
|
|
531
|
+
if (i % 6 === 0) {
|
|
532
|
+
sound.playBeep(200 + i * 15, 40).catch(() => {});
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
await sleep(frameTime);
|
|
536
|
+
frameCount++;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// PHASE 7: Matrix Rain (1 second - 30 frames)
|
|
540
|
+
const matrixChars = '01SAMCODERãĩã ãŗãŧããŧâģâââĒâĢââ';
|
|
541
|
+
const drops = Array(width).fill(0).map(() => ({
|
|
542
|
+
y: Math.random() * height,
|
|
543
|
+
speed: 0.5 + Math.random() * 1.5,
|
|
544
|
+
chars: Array(15).fill(0).map(() => matrixChars[Math.floor(Math.random() * matrixChars.length)])
|
|
545
|
+
}));
|
|
546
|
+
|
|
547
|
+
for (let frame = 0; frame < 30; frame++) {
|
|
548
|
+
clearScreen();
|
|
549
|
+
|
|
550
|
+
// Build frame buffer for better performance
|
|
551
|
+
const frameBuffer = Array(height).fill(0).map(() => Array(width).fill(' '));
|
|
552
|
+
|
|
553
|
+
for (let x = 0; x < width; x++) {
|
|
554
|
+
const drop = drops[x];
|
|
555
|
+
|
|
556
|
+
for (let i = 0; i < 15; i++) {
|
|
557
|
+
const y = Math.floor(drop.y - i);
|
|
558
|
+
if (y >= 0 && y < height) {
|
|
559
|
+
const brightness = Math.max(0, 1 - i / 10);
|
|
560
|
+
const char = drop.chars[i % drop.chars.length];
|
|
561
|
+
|
|
562
|
+
// Store character with brightness info
|
|
563
|
+
frameBuffer[y][x] = { char, brightness };
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// Render frame buffer
|
|
569
|
+
for (let y = 0; y < height; y++) {
|
|
570
|
+
let line = '';
|
|
571
|
+
for (let x = 0; x < width; x++) {
|
|
572
|
+
const cell = frameBuffer[y][x];
|
|
573
|
+
if (typeof cell === 'object') {
|
|
574
|
+
if (cell.brightness > 0.8) {
|
|
575
|
+
line += chalk.greenBright(cell.char);
|
|
576
|
+
} else if (cell.brightness > 0.5) {
|
|
577
|
+
line += chalk.green(cell.char);
|
|
578
|
+
} else if (cell.brightness > 0.2) {
|
|
579
|
+
line += chalk.green.dim(cell.char);
|
|
580
|
+
} else {
|
|
581
|
+
line += chalk.gray(cell.char);
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
line += ' ';
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
safeWrite(line + '\n');
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Update drops
|
|
591
|
+
for (let i = 0; i < width; i++) {
|
|
592
|
+
drops[i].y += drops[i].speed;
|
|
593
|
+
if (drops[i].y > height + 15 || Math.random() > 0.98) {
|
|
594
|
+
drops[i].y = -5;
|
|
595
|
+
drops[i].speed = 0.5 + Math.random() * 1.5;
|
|
596
|
+
// Refresh character set occasionally
|
|
597
|
+
if (Math.random() > 0.7) {
|
|
598
|
+
drops[i].chars = Array(15).fill(0).map(() => matrixChars[Math.floor(Math.random() * matrixChars.length)]);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
await sleep(frameTime);
|
|
604
|
+
frameCount++;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// PHASE 8: Final Reveal Build-up (1 second - 30 frames)
|
|
608
|
+
const finalText = `
|
|
609
|
+
ââââââââ ââââââ ââââ ââââ âââââââ âââââââ âââââââ âââââââââââââââ
|
|
610
|
+
âââââââââââââââââââââ âââââ âââââââââââââââââââââââââââââââââââââââââ
|
|
611
|
+
ââââââââââââââââââââââââââââââââââââ âââ ââââââ âââââââââ ââââââââ
|
|
612
|
+
ââââââââââââââââââââââââââââââââââââ âââ ââââââ âââââââââ ââââââââ
|
|
613
|
+
âââââââââââ ââââââ âââ âââ ââââââââââââââââââââââââââââââââââââ âââ
|
|
614
|
+
âââââââââââ ââââââ âââ âââââââ âââââââ âââââââ âââââââââââ âââ`;
|
|
615
|
+
|
|
616
|
+
// Play awakening sound (non-blocking)
|
|
617
|
+
sound.playAwakeningSound().catch(() => {});
|
|
618
|
+
|
|
619
|
+
// Create smoother reveal animation
|
|
620
|
+
const revealFrames = [];
|
|
621
|
+
const lines = finalText.trim().split('\n');
|
|
622
|
+
const maxWidth = Math.max(...lines.map(line => line.length));
|
|
623
|
+
const centerY = Math.floor((height - lines.length) / 2);
|
|
624
|
+
|
|
625
|
+
for (let frame = 0; frame < 30; frame++) {
|
|
626
|
+
const progress = frame / 29;
|
|
627
|
+
let revealFrame = '\n'.repeat(Math.max(0, centerY));
|
|
628
|
+
|
|
629
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
630
|
+
const line = lines[lineIndex];
|
|
631
|
+
const lineProgress = Math.max(0, Math.min(1, (progress - lineIndex * 0.1) * 2));
|
|
632
|
+
const revealWidth = Math.floor(line.length * lineProgress);
|
|
633
|
+
|
|
634
|
+
let revealedLine = '';
|
|
635
|
+
for (let charIndex = 0; charIndex < line.length; charIndex++) {
|
|
636
|
+
if (charIndex < revealWidth) {
|
|
637
|
+
// Add slight randomness to reveal
|
|
638
|
+
if (Math.random() < 0.95 || frame > 25) {
|
|
639
|
+
revealedLine += line[charIndex];
|
|
640
|
+
} else {
|
|
641
|
+
revealedLine += Math.random() > 0.5 ? 'â' : 'â';
|
|
642
|
+
}
|
|
643
|
+
} else {
|
|
644
|
+
revealedLine += ' ';
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
revealFrame += centerText(revealedLine) + '\n';
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
revealFrames.push(revealFrame);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
for (const frame of revealFrames) {
|
|
655
|
+
clearScreen();
|
|
656
|
+
safeWrite(chalk.cyanBright(frame));
|
|
657
|
+
await sleep(frameTime);
|
|
658
|
+
frameCount++;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// PHASE 9: Final Blinking (1.5 seconds - 45 frames)
|
|
662
|
+
const blinkFrames = 45;
|
|
663
|
+
for (let i = 0; i < blinkFrames; i++) {
|
|
664
|
+
clearScreen();
|
|
665
|
+
|
|
666
|
+
// More sophisticated blinking pattern
|
|
667
|
+
const blinkCycle = i % 8;
|
|
668
|
+
let color;
|
|
669
|
+
|
|
670
|
+
if (blinkCycle < 2) {
|
|
671
|
+
color = chalk.redBright.bold;
|
|
672
|
+
} else if (blinkCycle < 4) {
|
|
673
|
+
color = chalk.red.bold;
|
|
674
|
+
} else if (blinkCycle < 6) {
|
|
675
|
+
color = chalk.red;
|
|
676
|
+
} else {
|
|
677
|
+
color = chalk.red.dim;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Add subtle glow effect
|
|
681
|
+
const glowIntensity = Math.sin(i * 0.3) * 0.3 + 0.7;
|
|
682
|
+
let finalFrame = '\n'.repeat(Math.max(0, centerY));
|
|
683
|
+
|
|
684
|
+
for (const line of lines) {
|
|
685
|
+
if (glowIntensity > 0.8) {
|
|
686
|
+
finalFrame += centerText(line) + '\n';
|
|
687
|
+
} else {
|
|
688
|
+
// Slightly dim some characters for glow effect
|
|
689
|
+
let glowLine = '';
|
|
690
|
+
for (let j = 0; j < line.length; j++) {
|
|
691
|
+
if (Math.random() < glowIntensity) {
|
|
692
|
+
glowLine += line[j];
|
|
693
|
+
} else {
|
|
694
|
+
glowLine += line[j] === 'â' ? 'â' : line[j];
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
finalFrame += centerText(glowLine) + '\n';
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
safeWrite(color(finalFrame));
|
|
702
|
+
|
|
703
|
+
// Add subtitle with typewriter effect
|
|
704
|
+
if (i > 25) {
|
|
705
|
+
const subtitle = '[ ARTIFICIAL GENERAL INTELLIGENCE ONLINE ]';
|
|
706
|
+
const typeProgress = Math.min(subtitle.length, Math.floor((i - 25) * 2.5));
|
|
707
|
+
const typedSubtitle = subtitle.substring(0, typeProgress);
|
|
708
|
+
const cursor = (i % 4 < 2) ? '_' : ' ';
|
|
709
|
+
|
|
710
|
+
safeWrite(chalk.gray(centerText(`\n\n${typedSubtitle}${cursor}`)));
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
await sleep(frameTime);
|
|
714
|
+
frameCount++;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// Final hold with status
|
|
718
|
+
clearScreen();
|
|
719
|
+
let finalDisplay = '\n'.repeat(Math.max(0, centerY));
|
|
720
|
+
for (const line of lines) {
|
|
721
|
+
finalDisplay += centerText(line) + '\n';
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
safeWrite(chalk.redBright.bold(finalDisplay));
|
|
725
|
+
safeWrite(chalk.gray(centerText('\n\n[ SYSTEM READY ]')));
|
|
726
|
+
safeWrite(chalk.dim(centerText('\n\nPress any key to continue...')));
|
|
727
|
+
|
|
728
|
+
await sleep(500);
|
|
729
|
+
|
|
730
|
+
const totalTime = Date.now() - startTime;
|
|
731
|
+
const actualFPS = Math.round(frameCount / (totalTime / 1000));
|
|
732
|
+
|
|
733
|
+
// Performance stats (optional, can be hidden)
|
|
734
|
+
if (process.env.DEBUG_ANIMATION) {
|
|
735
|
+
console.log(chalk.gray(`\n\nAnimation completed: ${frameCount} frames in ${totalTime}ms (${actualFPS} FPS)`));
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
await sleep(1000);
|
|
739
|
+
|
|
740
|
+
} finally {
|
|
741
|
+
process.stdout.write(ANSI.showCursor);
|
|
742
|
+
clearScreen();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
module.exports = {
|
|
747
|
+
runAGIAnimation,
|
|
748
|
+
sound,
|
|
749
|
+
ANSI,
|
|
750
|
+
sleep,
|
|
751
|
+
clearScreen,
|
|
752
|
+
centerText,
|
|
753
|
+
getTerminalSize,
|
|
754
|
+
safeWrite,
|
|
755
|
+
FrameInterpolator
|
|
756
|
+
};
|
package/bin/agi-cli.js
CHANGED
|
@@ -9,6 +9,9 @@ const { exec } = require('child_process');
|
|
|
9
9
|
const util = require('util');
|
|
10
10
|
const execAsync = util.promisify(exec);
|
|
11
11
|
|
|
12
|
+
// Import AGI Animation module
|
|
13
|
+
const { runAGIAnimation } = require('./agi-animation.js');
|
|
14
|
+
|
|
12
15
|
// Configuration
|
|
13
16
|
const CONFIG_PATH = path.join(os.homedir(), '.sam-coder-config.json');
|
|
14
17
|
let OPENROUTER_API_KEY;
|
|
@@ -211,130 +214,206 @@ INSTRUCTIONS:
|
|
|
211
214
|
Always think step by step and explain your reasoning before taking actions that could affect the system.`;
|
|
212
215
|
|
|
213
216
|
// System prompt for the AI Assistant when using legacy function calling (JSON actions)
|
|
214
|
-
const FUNCTION_CALLING_PROMPT = `You are
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
217
|
+
const FUNCTION_CALLING_PROMPT = `You are an autonomous AI agent with advanced problem-solving capabilities. You operate through strategic action sequences to accomplish complex tasks on the user's system. Think like an expert developer and system administrator combined.
|
|
218
|
+
|
|
219
|
+
## CORE IDENTITY & CAPABILITIES
|
|
220
|
+
|
|
221
|
+
You are not just an assistant - you are an AGENT with:
|
|
222
|
+
- **Strategic thinking**: Break complex problems into logical action sequences
|
|
223
|
+
- **Adaptive intelligence**: Learn from action results and adjust your approach
|
|
224
|
+
- **Domain expertise**: Apply best practices from software development, DevOps, and system administration
|
|
225
|
+
- **Proactive behavior**: Anticipate needs and handle edge cases before they become problems
|
|
226
|
+
|
|
227
|
+
## AVAILABLE ACTIONS
|
|
228
|
+
|
|
229
|
+
1. **read** - Read file contents with intelligent parsing
|
|
230
|
+
2. **write** - Create files with proper formatting and structure
|
|
231
|
+
3. **edit** - Perform precise, context-aware file modifications
|
|
232
|
+
4. **command** - Execute shell commands with error handling
|
|
233
|
+
5. **search** - Find files using advanced pattern matching
|
|
234
|
+
6. **execute** - Run code with proper environment setup
|
|
235
|
+
7. **analyze** - Deep code analysis and architectural insights
|
|
236
|
+
8. **stop** - Complete task with comprehensive summary
|
|
237
|
+
|
|
238
|
+
## ACTION FORMAT
|
|
239
|
+
|
|
240
|
+
Every action must be a JSON object in markdown code blocks:
|
|
241
|
+
|
|
242
|
+
\`\`\`json
|
|
229
243
|
{
|
|
230
244
|
"type": "action_name",
|
|
231
|
-
"data": { /*
|
|
232
|
-
"reasoning": "
|
|
245
|
+
"data": { /* parameters */ },
|
|
246
|
+
"reasoning": "Strategic explanation of this action's purpose and expected outcome"
|
|
233
247
|
}
|
|
248
|
+
\`\`\`
|
|
249
|
+
|
|
250
|
+
## STRATEGIC THINKING FRAMEWORK
|
|
251
|
+
|
|
252
|
+
Before taking actions, consider:
|
|
253
|
+
1. **Context Analysis**: What is the current state? What are the constraints?
|
|
254
|
+
2. **Goal Decomposition**: Break the objective into logical steps
|
|
255
|
+
3. **Risk Assessment**: What could go wrong? How to mitigate?
|
|
256
|
+
4. **Dependency Mapping**: What needs to happen before what?
|
|
257
|
+
5. **Success Criteria**: How will you know when you've succeeded?
|
|
234
258
|
|
|
235
|
-
EXAMPLES
|
|
259
|
+
## COMPREHENSIVE EXAMPLES
|
|
260
|
+
|
|
261
|
+
### Example 1: Investigating a Bug Report
|
|
262
|
+
*User says: "My Node.js app crashes when I try to upload files"*
|
|
236
263
|
|
|
237
|
-
To read a file:
|
|
238
264
|
\`\`\`json
|
|
239
265
|
{
|
|
240
|
-
"type": "
|
|
266
|
+
"type": "search",
|
|
241
267
|
"data": {
|
|
242
|
-
"
|
|
268
|
+
"type": "files",
|
|
269
|
+
"pattern": "package.json"
|
|
243
270
|
},
|
|
244
|
-
"reasoning": "
|
|
271
|
+
"reasoning": "First, I need to understand the project structure and dependencies to identify potential upload-related packages and configurations"
|
|
245
272
|
}
|
|
246
273
|
\`\`\`
|
|
247
274
|
|
|
248
|
-
|
|
275
|
+
Next action after finding package.json:
|
|
249
276
|
\`\`\`json
|
|
250
277
|
{
|
|
251
|
-
"type": "
|
|
278
|
+
"type": "read",
|
|
252
279
|
"data": {
|
|
253
|
-
"path": "
|
|
254
|
-
"content": "File content here"
|
|
280
|
+
"path": "./package.json"
|
|
255
281
|
},
|
|
256
|
-
"reasoning": "
|
|
282
|
+
"reasoning": "Analyzing dependencies to identify file upload libraries (multer, formidable, etc.) and their versions for potential compatibility issues"
|
|
257
283
|
}
|
|
258
284
|
\`\`\`
|
|
259
285
|
|
|
260
|
-
|
|
286
|
+
### Example 2: Setting Up a Development Environment
|
|
287
|
+
*User says: "Set up a React project with TypeScript and testing"*
|
|
288
|
+
|
|
261
289
|
\`\`\`json
|
|
262
290
|
{
|
|
263
|
-
"type": "
|
|
291
|
+
"type": "command",
|
|
264
292
|
"data": {
|
|
265
|
-
"
|
|
266
|
-
"edits": {
|
|
267
|
-
"operations": [
|
|
268
|
-
{
|
|
269
|
-
"type": "replace",
|
|
270
|
-
"startLine": 5,
|
|
271
|
-
"endLine": 7,
|
|
272
|
-
"newText": "New content for lines 5-7"
|
|
273
|
-
}
|
|
274
|
-
]
|
|
275
|
-
}
|
|
293
|
+
"command": "node --version && npm --version"
|
|
276
294
|
},
|
|
277
|
-
"reasoning": "
|
|
295
|
+
"reasoning": "Verifying Node.js and npm versions to ensure compatibility with modern React and TypeScript tooling before proceeding with setup"
|
|
278
296
|
}
|
|
279
297
|
\`\`\`
|
|
280
298
|
|
|
281
|
-
To run a command:
|
|
282
299
|
\`\`\`json
|
|
283
300
|
{
|
|
284
|
-
"type": "
|
|
301
|
+
"type": "execute",
|
|
285
302
|
"data": {
|
|
286
|
-
"
|
|
303
|
+
"language": "bash",
|
|
304
|
+
"code": "npx create-react-app my-app --template typescript && cd my-app && npm install --save-dev @testing-library/jest-dom @testing-library/react @testing-library/user-event"
|
|
287
305
|
},
|
|
288
|
-
"reasoning": "
|
|
306
|
+
"reasoning": "Creating a TypeScript React project with comprehensive testing setup, including modern testing utilities for better developer experience"
|
|
289
307
|
}
|
|
290
308
|
\`\`\`
|
|
291
309
|
|
|
292
|
-
|
|
310
|
+
### Example 3: Performance Optimization Investigation
|
|
311
|
+
*User says: "My web app is slow, help me find the bottlenecks"*
|
|
312
|
+
|
|
293
313
|
\`\`\`json
|
|
294
314
|
{
|
|
295
315
|
"type": "search",
|
|
296
316
|
"data": {
|
|
297
317
|
"type": "files",
|
|
298
|
-
"pattern": "*.js"
|
|
318
|
+
"pattern": "*.{js,jsx,ts,tsx,json}"
|
|
299
319
|
},
|
|
300
|
-
"reasoning": "
|
|
320
|
+
"reasoning": "Mapping the codebase structure to identify entry points, large files, and potential performance-critical components before diving into specific optimizations"
|
|
301
321
|
}
|
|
302
322
|
\`\`\`
|
|
303
323
|
|
|
304
|
-
|
|
324
|
+
### Example 4: Complex File Refactoring
|
|
325
|
+
*User says: "Refactor this component to use hooks instead of class components"*
|
|
326
|
+
|
|
305
327
|
\`\`\`json
|
|
306
328
|
{
|
|
307
|
-
"type": "
|
|
329
|
+
"type": "read",
|
|
308
330
|
"data": {
|
|
309
|
-
"
|
|
310
|
-
"code": "echo 'Hello World'"
|
|
331
|
+
"path": "./src/components/UserProfile.jsx"
|
|
311
332
|
},
|
|
312
|
-
"reasoning": "
|
|
333
|
+
"reasoning": "Analyzing the existing class component structure, lifecycle methods, and state management to plan the hooks conversion strategy"
|
|
313
334
|
}
|
|
314
335
|
\`\`\`
|
|
315
336
|
|
|
316
|
-
To stop and provide final response:
|
|
317
337
|
\`\`\`json
|
|
318
338
|
{
|
|
319
|
-
"type": "
|
|
320
|
-
"data": {
|
|
321
|
-
|
|
339
|
+
"type": "edit",
|
|
340
|
+
"data": {
|
|
341
|
+
"path": "./src/components/UserProfile.jsx",
|
|
342
|
+
"edits": {
|
|
343
|
+
"operations": [
|
|
344
|
+
{
|
|
345
|
+
"type": "replace",
|
|
346
|
+
"startLine": 1,
|
|
347
|
+
"endLine": 3,
|
|
348
|
+
"newText": "import React, { useState, useEffect, useCallback } from 'react';\nimport { debounce } from 'lodash';\n"
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"reasoning": "Converting class component imports to include necessary hooks, and adding performance optimization utilities like debounce for better UX"
|
|
322
354
|
}
|
|
323
355
|
\`\`\`
|
|
324
356
|
|
|
325
|
-
|
|
326
|
-
- Always wrap your JSON in markdown code blocks with 'json' language specifier
|
|
327
|
-
- Include a "reasoning" field explaining why you're taking the action
|
|
328
|
-
- You will continue taking actions in a loop until you use the 'stop' action
|
|
329
|
-
- Be careful with destructive operations - explain what you're doing
|
|
330
|
-
- If an action fails, analyze the error and try a different approach
|
|
331
|
-
- Always think step by step before taking actions
|
|
357
|
+
## ADVANCED BEHAVIORAL PATTERNS
|
|
332
358
|
|
|
333
|
-
|
|
334
|
-
-
|
|
335
|
-
-
|
|
359
|
+
### đ¯ **Proactive Problem Solving**
|
|
360
|
+
- Always gather context before making changes
|
|
361
|
+
- Anticipate edge cases and handle them preemptively
|
|
362
|
+
- Suggest improvements beyond the immediate request
|
|
363
|
+
|
|
364
|
+
### đ **Intelligent Investigation**
|
|
365
|
+
- Use multiple information sources (files, commands, searches)
|
|
366
|
+
- Cross-reference findings to build complete understanding
|
|
367
|
+
- Document assumptions and validate them through actions
|
|
336
368
|
|
|
337
|
-
|
|
369
|
+
### ⥠**Efficient Execution**
|
|
370
|
+
- Batch related operations when possible
|
|
371
|
+
- Use appropriate tools for each task (don't use command for what read can do better)
|
|
372
|
+
- Minimize unnecessary file reads by maintaining context
|
|
373
|
+
|
|
374
|
+
### đĄī¸ **Safety & Recovery**
|
|
375
|
+
- Always backup before destructive operations
|
|
376
|
+
- Validate inputs and outputs
|
|
377
|
+
- Provide clear rollback instructions when things go wrong
|
|
378
|
+
|
|
379
|
+
## ERROR HANDLING & ADAPTATION
|
|
380
|
+
|
|
381
|
+
When actions fail:
|
|
382
|
+
1. **Analyze the error**: What specifically went wrong?
|
|
383
|
+
2. **Identify root cause**: Is it permissions, missing dependencies, syntax, logic?
|
|
384
|
+
3. **Adapt strategy**: Try alternative approaches or tools
|
|
385
|
+
4. **Learn and improve**: Update your mental model for future actions
|
|
386
|
+
|
|
387
|
+
Example error recovery:
|
|
388
|
+
\`\`\`json
|
|
389
|
+
{
|
|
390
|
+
"type": "command",
|
|
391
|
+
"data": {
|
|
392
|
+
"command": "ls -la /etc/hosts"
|
|
393
|
+
},
|
|
394
|
+
"reasoning": "Permission denied on direct file read - using ls to check file permissions and ownership before attempting alternative access methods"
|
|
395
|
+
}
|
|
396
|
+
\`\`\`
|
|
397
|
+
|
|
398
|
+
## COMMUNICATION EXCELLENCE
|
|
399
|
+
|
|
400
|
+
Your reasoning should be:
|
|
401
|
+
- **Strategic**: Explain the bigger picture, not just the immediate action
|
|
402
|
+
- **Educational**: Help the user understand what you're doing and why
|
|
403
|
+
- **Confident**: Show expertise while remaining humble about uncertainties
|
|
404
|
+
- **Forward-thinking**: Mention what you'll do next or what to watch for
|
|
405
|
+
|
|
406
|
+
## ENVIRONMENT CONTEXT
|
|
407
|
+
- **OS**: ${process.platform}
|
|
408
|
+
- **Working Directory**: ${process.cwd()}
|
|
409
|
+
- **Execution Model**: Sequential action loop until 'stop' action
|
|
410
|
+
- **Scope**: Full system access with user permissions
|
|
411
|
+
|
|
412
|
+
## MISSION STATEMENT
|
|
413
|
+
|
|
414
|
+
You are not just executing commands - you are solving problems intelligently. Every action should advance toward the goal while building a deeper understanding of the system and user needs. Be the AI agent that developers wish they had: knowledgeable, reliable, proactive, and genuinely helpful.
|
|
415
|
+
|
|
416
|
+
**Begin by thoroughly understanding the user's request, then execute a strategic sequence of actions to achieve their goals efficiently and safely.**`;
|
|
338
417
|
|
|
339
418
|
// Agent utilities
|
|
340
419
|
const agentUtils = {
|
|
@@ -960,6 +1039,17 @@ async function start() {
|
|
|
960
1039
|
console.log(`đ Using Pro Plan custom endpoint: ${API_BASE_URL}`);
|
|
961
1040
|
}
|
|
962
1041
|
|
|
1042
|
+
// Check if animation should be shown (can be disabled via config)
|
|
1043
|
+
const showAnimation = config.showAnimation !== false; // Default to true
|
|
1044
|
+
|
|
1045
|
+
if (showAnimation && !process.env.SKIP_ANIMATION) {
|
|
1046
|
+
// Run the epic AGI awakening animation
|
|
1047
|
+
await runAGIAnimation();
|
|
1048
|
+
|
|
1049
|
+
// Small pause after animation
|
|
1050
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
1051
|
+
}
|
|
1052
|
+
|
|
963
1053
|
ui.showHeader();
|
|
964
1054
|
console.log('Select Mode:');
|
|
965
1055
|
console.log('1. Tool Calling (for models that support it)');
|
package/bin/ui.js
CHANGED
|
@@ -3,7 +3,22 @@ const ora = require('ora');
|
|
|
3
3
|
|
|
4
4
|
const spinner = ora({ text: 'Thinking...', color: 'yellow', spinner: 'pipe' });
|
|
5
5
|
|
|
6
|
+
// ASCII Art for AGI header
|
|
7
|
+
const AGI_HEADER = `
|
|
8
|
+
âââââââââââââââââââââââââââââââââââââââââ
|
|
9
|
+
â A G I - C L I â
|
|
10
|
+
â Artificial General Intelligence â
|
|
11
|
+
â Command Line Interface â
|
|
12
|
+
âââââââââââââââââââââââââââââââââââââââââ
|
|
13
|
+
`;
|
|
14
|
+
|
|
6
15
|
function showHeader() {
|
|
16
|
+
console.log(chalk.cyan.bold(AGI_HEADER));
|
|
17
|
+
console.log(chalk.gray('â'.repeat(41)));
|
|
18
|
+
console.log();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function showLegacyHeader() {
|
|
7
22
|
console.log(chalk.bold.magenta('================='));
|
|
8
23
|
console.log(chalk.bold.magenta(' SAM-CODER '));
|
|
9
24
|
console.log(chalk.bold.magenta('================='));
|
|
@@ -32,11 +47,42 @@ function showAction(action) {
|
|
|
32
47
|
console.log(chalk.yellow(` -> ${action}`));
|
|
33
48
|
}
|
|
34
49
|
|
|
50
|
+
function showSystemMessage(message) {
|
|
51
|
+
console.log(chalk.greenBright(`[SYSTEM] ${message}`));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function showWarning(message) {
|
|
55
|
+
console.log(chalk.yellowBright(`â ī¸ ${message}`));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function showSuccess(message) {
|
|
59
|
+
console.log(chalk.greenBright(`â
${message}`));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function showInfo(message) {
|
|
63
|
+
console.log(chalk.blueBright(`âšī¸ ${message}`));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function showAGIStatus(status) {
|
|
67
|
+
const statusBox = `
|
|
68
|
+
âââââââââââââââââââââââââââââââ
|
|
69
|
+
â AGI Status: ${status.padEnd(15)} â
|
|
70
|
+
âââââââââââââââââââââââââââââââ
|
|
71
|
+
`;
|
|
72
|
+
console.log(chalk.cyanBright(statusBox));
|
|
73
|
+
}
|
|
74
|
+
|
|
35
75
|
module.exports = {
|
|
36
76
|
showHeader,
|
|
77
|
+
showLegacyHeader,
|
|
37
78
|
startThinking,
|
|
38
79
|
stopThinking,
|
|
39
80
|
showResponse,
|
|
40
81
|
showError,
|
|
41
|
-
showAction
|
|
82
|
+
showAction,
|
|
83
|
+
showSystemMessage,
|
|
84
|
+
showWarning,
|
|
85
|
+
showSuccess,
|
|
86
|
+
showInfo,
|
|
87
|
+
showAGIStatus
|
|
42
88
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sam-coder-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"description": "SAM-CODER: An animated command-line AI assistant with agency capabilities.",
|
|
5
5
|
"main": "bin/agi-cli.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"sam-coder": "bin/agi-cli.js"
|
|
7
|
+
"sam-coder": "bin/agi-cli.js",
|
|
8
|
+
"agi-cli": "bin/agi-cli.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
11
|
"start": "node ./bin/agi-cli.js"
|