scai 0.1.34 → 0.1.35
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/dist/lib/generate.js +7 -6
- package/dist/lib/spinner.js +31 -0
- package/package.json +1 -2
package/dist/lib/generate.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// File: lib/generate.ts
|
|
2
|
-
import
|
|
2
|
+
import { Spinner } from './spinner.js';
|
|
3
3
|
export async function generate(input, model) {
|
|
4
|
-
const spinner =
|
|
4
|
+
const spinner = new Spinner(`🧠 Thinking with ${model}...`);
|
|
5
|
+
spinner.start();
|
|
5
6
|
try {
|
|
6
7
|
const res = await fetch('http://localhost:11434/api/generate', {
|
|
7
8
|
method: 'POST',
|
|
@@ -13,16 +14,16 @@ export async function generate(input, model) {
|
|
|
13
14
|
}),
|
|
14
15
|
});
|
|
15
16
|
const data = await res.json();
|
|
16
|
-
spinner.succeed('
|
|
17
|
-
process.stdout.write('\n');
|
|
17
|
+
spinner.succeed('Model response received.');
|
|
18
|
+
process.stdout.write('\n');
|
|
18
19
|
return {
|
|
19
20
|
content: data.response?.trim() ?? '',
|
|
20
21
|
filepath: input.filepath,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
|
-
spinner.fail('
|
|
25
|
-
process.stdout.write('\n');
|
|
25
|
+
spinner.fail('Model request failed.');
|
|
26
|
+
process.stdout.write('\n');
|
|
26
27
|
throw err;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// lib/spinner.ts
|
|
2
|
+
export class Spinner {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
5
|
+
this.interval = null;
|
|
6
|
+
this.i = 0;
|
|
7
|
+
this.text = message;
|
|
8
|
+
}
|
|
9
|
+
start() {
|
|
10
|
+
process.stdout.write('\x1b[?25l'); // hide cursor
|
|
11
|
+
this.interval = setInterval(() => {
|
|
12
|
+
const frame = this.frames[this.i = ++this.i % this.frames.length];
|
|
13
|
+
process.stdout.write(`\r${frame} ${this.text} `);
|
|
14
|
+
}, 80);
|
|
15
|
+
}
|
|
16
|
+
succeed(msg) {
|
|
17
|
+
this.stop();
|
|
18
|
+
process.stdout.write(`\r✅ ${msg}\n`);
|
|
19
|
+
}
|
|
20
|
+
fail(msg) {
|
|
21
|
+
this.stop();
|
|
22
|
+
process.stdout.write(`\r❌ ${msg}\n`);
|
|
23
|
+
}
|
|
24
|
+
stop() {
|
|
25
|
+
if (this.interval) {
|
|
26
|
+
clearInterval(this.interval);
|
|
27
|
+
this.interval = null;
|
|
28
|
+
}
|
|
29
|
+
process.stdout.write('\x1b[?25h'); // show cursor
|
|
30
|
+
}
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"scai": "./dist/index.js"
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"better-sqlite3": "^12.1.1",
|
|
29
29
|
"commander": "^11.0.0",
|
|
30
30
|
"fast-glob": "^3.3.3",
|
|
31
|
-
"ora": "^8.2.0",
|
|
32
31
|
"proper-lockfile": "^4.1.2"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|