claude-smart 0.1.16 → 0.1.17
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 +1 -1
- package/bin/claude-smart.js +37 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
|
|
14
14
|
</a>
|
|
15
15
|
<a href="plugin/pyproject.toml">
|
|
16
|
-
<img src="https://img.shields.io/badge/version-0.1.
|
|
16
|
+
<img src="https://img.shields.io/badge/version-0.1.17-green.svg" alt="Version">
|
|
17
17
|
</a>
|
|
18
18
|
<a href="plugin/pyproject.toml">
|
|
19
19
|
<img src="https://img.shields.io/badge/python-%3E%3D3.12-brightgreen.svg" alt="Python">
|
package/bin/claude-smart.js
CHANGED
|
@@ -25,31 +25,53 @@ function runClaude(args, { spinnerLabel } = {}) {
|
|
|
25
25
|
stdio: useSpinner ? ["inherit", "pipe", "pipe"] : "inherit",
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
let spinnerActive = false;
|
|
29
|
-
let timer = null;
|
|
30
28
|
if (useSpinner) {
|
|
31
29
|
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
32
30
|
let i = 0;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
let spinTimer = null;
|
|
32
|
+
let rearmTimer = null;
|
|
33
|
+
let exited = false;
|
|
34
|
+
|
|
35
|
+
const draw = () => {
|
|
36
|
+
process.stdout.write(`\r⠿ ${spinnerLabel}`.replace("⠿", frames[i = (i + 1) % frames.length]));
|
|
37
|
+
};
|
|
38
|
+
const clearLine = () => process.stdout.write("\r\x1b[2K");
|
|
39
|
+
const startSpin = () => {
|
|
40
|
+
if (spinTimer || exited) return;
|
|
41
|
+
draw();
|
|
42
|
+
spinTimer = setInterval(draw, 80);
|
|
43
|
+
};
|
|
44
|
+
const stopSpin = () => {
|
|
45
|
+
if (!spinTimer) return;
|
|
46
|
+
clearInterval(spinTimer);
|
|
47
|
+
spinTimer = null;
|
|
48
|
+
clearLine();
|
|
36
49
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
clearInterval(timer);
|
|
44
|
-
process.stdout.write("\r\x1b[2K");
|
|
50
|
+
const armRearm = () => {
|
|
51
|
+
if (rearmTimer) clearTimeout(rearmTimer);
|
|
52
|
+
rearmTimer = setTimeout(() => {
|
|
53
|
+
rearmTimer = null;
|
|
54
|
+
startSpin();
|
|
55
|
+
}, 200);
|
|
45
56
|
};
|
|
57
|
+
|
|
58
|
+
startSpin();
|
|
59
|
+
|
|
46
60
|
const passthrough = (stream) => (chunk) => {
|
|
47
|
-
|
|
61
|
+
stopSpin();
|
|
48
62
|
stream.write(chunk);
|
|
63
|
+
armRearm();
|
|
49
64
|
};
|
|
50
65
|
child.stdout.on("data", passthrough(process.stdout));
|
|
51
66
|
child.stderr.on("data", passthrough(process.stderr));
|
|
52
|
-
child.on("exit",
|
|
67
|
+
child.on("exit", () => {
|
|
68
|
+
exited = true;
|
|
69
|
+
if (rearmTimer) {
|
|
70
|
+
clearTimeout(rearmTimer);
|
|
71
|
+
rearmTimer = null;
|
|
72
|
+
}
|
|
73
|
+
stopSpin();
|
|
74
|
+
});
|
|
53
75
|
}
|
|
54
76
|
|
|
55
77
|
child.on("exit", (code) => resolve(typeof code === "number" ? code : 1));
|