shenxiang-ai-cli 0.4.3 → 0.4.4
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/index.js +16 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -737,7 +737,7 @@ function banner() {
|
|
|
737
737
|
const w = chalk.white.bold;
|
|
738
738
|
const lines = [
|
|
739
739
|
``,
|
|
740
|
-
` ${p("/\\_/\\")} ${b("\u6C88\u7FD4\u7684AI\u52A9\u624B")} ${m("v0.4.
|
|
740
|
+
` ${p("/\\_/\\")} ${b("\u6C88\u7FD4\u7684AI\u52A9\u624B")} ${m("v0.4.4")}`,
|
|
741
741
|
` ${p("(")} ${y("o")}${p(".")}${y("o")} ${p(")")} ${d("\u7EC8\u7AEF\u91CC\u7684AI\u5168\u6808\u5F00\u53D1\u642D\u6863")}`,
|
|
742
742
|
` ${p("> ")}${r("^")}${p(" <")}`,
|
|
743
743
|
` ${p("/|")}${p(" |")}${p("\\")} ${d("\u4F60\u7684\u7F16\u7A0B\u597D\u4F19\u4F34")} ${chalk.hex("#A78BFA")("\u{1F43E}")}`,
|
|
@@ -754,9 +754,6 @@ var marked = new Marked(markedTerminal());
|
|
|
754
754
|
function streamChunk(text) {
|
|
755
755
|
process.stdout.write(text);
|
|
756
756
|
}
|
|
757
|
-
function streamThinking(text) {
|
|
758
|
-
process.stdout.write(theme.dim(text));
|
|
759
|
-
}
|
|
760
757
|
function printColoredDiff(oldContent, newContent, filepath) {
|
|
761
758
|
const oldLines = oldContent.split("\n");
|
|
762
759
|
const newLines = newContent.split("\n");
|
|
@@ -1875,10 +1872,11 @@ var Agent = class {
|
|
|
1875
1872
|
let hasThinkingOutput = false;
|
|
1876
1873
|
let toolSpinnerStarted = false;
|
|
1877
1874
|
let idleTimer = null;
|
|
1875
|
+
let isStreamingThinking = false;
|
|
1878
1876
|
const resetIdleTimer = () => {
|
|
1879
1877
|
if (idleTimer) clearTimeout(idleTimer);
|
|
1880
1878
|
idleTimer = setTimeout(() => {
|
|
1881
|
-
if (!spinner.isSpinning && spinnerStopped) {
|
|
1879
|
+
if (!spinner.isSpinning && spinnerStopped && !isStreamingThinking) {
|
|
1882
1880
|
spinner.text = "AI \u6B63\u5728\u601D\u8003...";
|
|
1883
1881
|
spinner.start();
|
|
1884
1882
|
}
|
|
@@ -1912,21 +1910,30 @@ var Agent = class {
|
|
|
1912
1910
|
}
|
|
1913
1911
|
switch (chunk.type) {
|
|
1914
1912
|
case "thinking":
|
|
1913
|
+
isStreamingThinking = true;
|
|
1915
1914
|
if (!hasThinkingOutput) {
|
|
1916
1915
|
hasThinkingOutput = true;
|
|
1917
|
-
|
|
1916
|
+
process.stdout.write("\n");
|
|
1917
|
+
process.stdout.write(theme.dim(" \u250C\u2500 \u{1F4AD} \u601D\u8003\u4E2D \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n"));
|
|
1918
|
+
process.stdout.write(theme.dim(" \u2502 "));
|
|
1918
1919
|
}
|
|
1919
|
-
|
|
1920
|
+
const thinkText = (chunk.content || "").replace(/\n/g, "\n" + theme.dim(" \u2502 "));
|
|
1921
|
+
process.stdout.write(theme.dim(thinkText));
|
|
1920
1922
|
break;
|
|
1921
1923
|
case "text":
|
|
1922
1924
|
if (hasThinkingOutput && !hasTextOutput) {
|
|
1923
|
-
|
|
1925
|
+
isStreamingThinking = false;
|
|
1926
|
+
process.stdout.write("\n" + theme.dim(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500") + "\n\n");
|
|
1924
1927
|
}
|
|
1925
1928
|
responseText += chunk.content || "";
|
|
1926
1929
|
hasTextOutput = true;
|
|
1927
1930
|
streamChunk(chunk.content || "");
|
|
1928
1931
|
break;
|
|
1929
1932
|
case "tool_call_start":
|
|
1933
|
+
if (hasThinkingOutput && isStreamingThinking) {
|
|
1934
|
+
isStreamingThinking = false;
|
|
1935
|
+
process.stdout.write("\n" + theme.dim(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500") + "\n");
|
|
1936
|
+
}
|
|
1930
1937
|
if (!toolSpinnerStarted) {
|
|
1931
1938
|
if (hasTextOutput) process.stdout.write("\n");
|
|
1932
1939
|
spinner.text = "\u6B63\u5728\u51C6\u5907\u64CD\u4F5C...";
|
|
@@ -3168,7 +3175,7 @@ function fmtTokens3(n) {
|
|
|
3168
3175
|
var program = new Command();
|
|
3169
3176
|
var config2 = getConfig();
|
|
3170
3177
|
setLocale(config2.locale);
|
|
3171
|
-
program.name("sxai").description(t("description")).version("0.4.
|
|
3178
|
+
program.name("sxai").description(t("description")).version("0.4.4");
|
|
3172
3179
|
program.command("chat", { isDefault: true }).description("\u542F\u52A8\u4EA4\u4E92\u5F0FAI\u5BF9\u8BDD\uFF08\u9ED8\u8BA4\u547D\u4EE4\uFF09").option("-m, --model <model>", "\u6307\u5B9AAI\u6A21\u578B", config2.model).option("-y, --yolo", "\u81EA\u52A8\u6A21\u5F0F\uFF1A\u8DF3\u8FC7\u6240\u6709\u786E\u8BA4\uFF0C\u8BA9AI\u81EA\u4E3B\u6267\u884C").action(async (options) => {
|
|
3173
3180
|
if (options.model && options.model !== config2.model) {
|
|
3174
3181
|
setConfig("model", options.model);
|