shenxiang-ai-cli 0.5.5 → 0.5.7
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 +72 -70
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/commands/chat.ts
|
|
7
|
-
import
|
|
7
|
+
import inquirer2 from "inquirer";
|
|
8
8
|
import fs5 from "fs/promises";
|
|
9
9
|
import path5 from "path";
|
|
10
10
|
import { glob as glob4 } from "glob";
|
|
@@ -1289,6 +1289,9 @@ var gitLogTool = {
|
|
|
1289
1289
|
requiresConfirmation: false
|
|
1290
1290
|
};
|
|
1291
1291
|
|
|
1292
|
+
// src/core/tools/index.ts
|
|
1293
|
+
import inquirer from "inquirer";
|
|
1294
|
+
|
|
1292
1295
|
// src/i18n/zh.ts
|
|
1293
1296
|
var zh = {
|
|
1294
1297
|
welcome: "\u6B22\u8FCE\u4F7F\u7528\u6C88\u7FD4\u7684AI\u52A9\u624B \u2014 \u4F60\u7684AI\u5168\u6808\u5F00\u53D1\u642D\u6863",
|
|
@@ -1440,25 +1443,6 @@ function t(key, params) {
|
|
|
1440
1443
|
return value.replace(/\{(\w+)\}/g, (_, k) => params[k] ?? `{${k}}`);
|
|
1441
1444
|
}
|
|
1442
1445
|
|
|
1443
|
-
// src/utils/input.ts
|
|
1444
|
-
var _questionFn = null;
|
|
1445
|
-
function registerQuestionFn(fn) {
|
|
1446
|
-
_questionFn = fn;
|
|
1447
|
-
}
|
|
1448
|
-
async function askQuestion(prompt) {
|
|
1449
|
-
if (_questionFn) {
|
|
1450
|
-
return _questionFn(prompt);
|
|
1451
|
-
}
|
|
1452
|
-
return new Promise((resolve) => {
|
|
1453
|
-
process.stdout.write(prompt);
|
|
1454
|
-
const onData = (data) => {
|
|
1455
|
-
process.stdin.removeListener("data", onData);
|
|
1456
|
-
resolve(data.toString().trim());
|
|
1457
|
-
};
|
|
1458
|
-
process.stdin.once("data", onData);
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
1446
|
// src/core/tools/index.ts
|
|
1463
1447
|
var toolRegistry = /* @__PURE__ */ new Map();
|
|
1464
1448
|
var _yoloMode = false;
|
|
@@ -1496,10 +1480,18 @@ async function confirmExecution(toolName, args) {
|
|
|
1496
1480
|
else if (toolName === "edit_file") description = `\u7F16\u8F91\u6587\u4EF6: ${args.path}`;
|
|
1497
1481
|
else if (toolName === "delete_file") description = `\u5220\u9664\u6587\u4EF6: ${args.path}`;
|
|
1498
1482
|
else if (toolName === "git_commit") description = `Git\u63D0\u4EA4: ${args.message}`;
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1483
|
+
console.log(theme.warning(` \u26A1 ${description}`));
|
|
1484
|
+
const { confirmation } = await inquirer.prompt([{
|
|
1485
|
+
type: "list",
|
|
1486
|
+
name: "confirmation",
|
|
1487
|
+
message: "\u662F\u5426\u5141\u8BB8\u6267\u884C?",
|
|
1488
|
+
choices: [
|
|
1489
|
+
{ name: "\u540C\u610F\u6267\u884C (Yes)", value: true },
|
|
1490
|
+
{ name: "\u62D2\u7EDD\u6267\u884C (No)", value: false }
|
|
1491
|
+
],
|
|
1492
|
+
default: true
|
|
1493
|
+
}]);
|
|
1494
|
+
return confirmation;
|
|
1503
1495
|
}
|
|
1504
1496
|
async function executeTool(name, args, autoConfirm = false) {
|
|
1505
1497
|
const tool = toolRegistry.get(name);
|
|
@@ -1869,10 +1861,10 @@ var Agent = class {
|
|
|
1869
1861
|
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");
|
|
1870
1862
|
}
|
|
1871
1863
|
if (!spinner.isSpinning && spinnerStopped) {
|
|
1872
|
-
spinner.text = "AI \u6B63\u5728\
|
|
1864
|
+
spinner.text = "AI \u6B63\u5728\u601D\u8003...";
|
|
1873
1865
|
spinner.start();
|
|
1874
1866
|
}
|
|
1875
|
-
},
|
|
1867
|
+
}, 800);
|
|
1876
1868
|
};
|
|
1877
1869
|
const clearIdleTimer = () => {
|
|
1878
1870
|
if (idleTimer) {
|
|
@@ -1928,7 +1920,7 @@ var Agent = class {
|
|
|
1928
1920
|
}
|
|
1929
1921
|
if (!toolSpinnerStarted) {
|
|
1930
1922
|
if (hasTextOutput) process.stdout.write("\n");
|
|
1931
|
-
spinner.text = "\u6B63\u5728\
|
|
1923
|
+
spinner.text = "\u6B63\u5728\u89C4\u5212\u64CD\u4F5C...";
|
|
1932
1924
|
spinner.start();
|
|
1933
1925
|
toolSpinnerStarted = true;
|
|
1934
1926
|
}
|
|
@@ -1937,7 +1929,6 @@ var Agent = class {
|
|
|
1937
1929
|
if (chunk.toolCallInfo) {
|
|
1938
1930
|
const fnName = chunk.toolCallInfo.functionName || "";
|
|
1939
1931
|
const delta = chunk.toolCallInfo.argumentsDelta || "";
|
|
1940
|
-
const size = chunk.toolCallInfo.argumentsLength || 0;
|
|
1941
1932
|
if (!toolSpinnerStarted || spinner.isSpinning && delta) {
|
|
1942
1933
|
if (spinner.isSpinning) spinner.stop();
|
|
1943
1934
|
if (!toolSpinnerStarted) {
|
|
@@ -1948,7 +1939,7 @@ var Agent = class {
|
|
|
1948
1939
|
process.stdout.write(theme.tool(`
|
|
1949
1940
|
\u25B8 ${name}
|
|
1950
1941
|
`));
|
|
1951
|
-
this._codeStreamState = { inContent: false, buffer: "", escaping: false };
|
|
1942
|
+
this._codeStreamState = { inContent: false, buffer: "", escaping: false, keyBuffer: "", inKey: false, afterColon: false };
|
|
1952
1943
|
}
|
|
1953
1944
|
}
|
|
1954
1945
|
if (delta && this._codeStreamState) {
|
|
@@ -2226,7 +2217,7 @@ function showBanner() {
|
|
|
2226
2217
|
console.clear();
|
|
2227
2218
|
const p = chalk3.hex("#A78BFA");
|
|
2228
2219
|
const w = chalk3.white;
|
|
2229
|
-
const version = "v0.5.
|
|
2220
|
+
const version = "v0.5.7";
|
|
2230
2221
|
const avatarLines = [
|
|
2231
2222
|
` ${p("\u2584\u2580\u2580\u2580\u2584")}`,
|
|
2232
2223
|
` ${p("\u2588")} ${w("\u2580")} ${w("\u2580")} ${p("\u2588")}`,
|
|
@@ -2277,11 +2268,16 @@ function showBanner() {
|
|
|
2277
2268
|
...wrappedQuote.map((l) => theme.dim(l)),
|
|
2278
2269
|
""
|
|
2279
2270
|
];
|
|
2271
|
+
const getVisualWidth = (str) => {
|
|
2272
|
+
return stripAnsi(str).split("").reduce((width, char) => {
|
|
2273
|
+
return width + (char.codePointAt(0) > 255 ? 2 : 1);
|
|
2274
|
+
}, 0);
|
|
2275
|
+
};
|
|
2280
2276
|
const maxLines = Math.max(leftContent.length, rightContent.length);
|
|
2281
2277
|
const lines = [];
|
|
2282
2278
|
for (let i = 0; i < maxLines; i++) {
|
|
2283
2279
|
const left = leftContent[i] || "";
|
|
2284
|
-
const leftVisible =
|
|
2280
|
+
const leftVisible = getVisualWidth(left);
|
|
2285
2281
|
const leftPadding = " ".repeat(Math.max(0, leftColWidth - leftVisible));
|
|
2286
2282
|
const right = rightContent[i] || "";
|
|
2287
2283
|
lines.push(`${left}${leftPadding} ${theme.dim("\u2502")} ${right}`);
|
|
@@ -2298,6 +2294,12 @@ function showBanner() {
|
|
|
2298
2294
|
}));
|
|
2299
2295
|
}
|
|
2300
2296
|
|
|
2297
|
+
// src/utils/input.ts
|
|
2298
|
+
var _questionFn = null;
|
|
2299
|
+
function registerQuestionFn(fn) {
|
|
2300
|
+
_questionFn = fn;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2301
2303
|
// src/commands/chat.ts
|
|
2302
2304
|
async function chatCommand(options = {}) {
|
|
2303
2305
|
const config3 = getConfig();
|
|
@@ -2335,7 +2337,7 @@ async function chatCommand(options = {}) {
|
|
|
2335
2337
|
console.log();
|
|
2336
2338
|
}
|
|
2337
2339
|
registerQuestionFn(async (prompt) => {
|
|
2338
|
-
const { answer } = await
|
|
2340
|
+
const { answer } = await inquirer2.prompt([{
|
|
2339
2341
|
type: "input",
|
|
2340
2342
|
name: "answer",
|
|
2341
2343
|
message: prompt,
|
|
@@ -2385,7 +2387,7 @@ async function chatCommand(options = {}) {
|
|
|
2385
2387
|
while (true) {
|
|
2386
2388
|
let input;
|
|
2387
2389
|
try {
|
|
2388
|
-
const result = await
|
|
2390
|
+
const result = await inquirer2.prompt([{
|
|
2389
2391
|
type: "input",
|
|
2390
2392
|
name: "input",
|
|
2391
2393
|
message: theme.user("\u4F60:"),
|
|
@@ -2420,20 +2422,20 @@ async function chatCommand(options = {}) {
|
|
|
2420
2422
|
}
|
|
2421
2423
|
async function doInlineRegister() {
|
|
2422
2424
|
const config3 = getConfig();
|
|
2423
|
-
const { email } = await
|
|
2425
|
+
const { email } = await inquirer2.prompt([{
|
|
2424
2426
|
type: "input",
|
|
2425
2427
|
name: "email",
|
|
2426
2428
|
message: "\u90AE\u7BB1:",
|
|
2427
2429
|
validate: (v) => v.includes("@") ? true : "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1"
|
|
2428
2430
|
}]);
|
|
2429
|
-
const { password } = await
|
|
2431
|
+
const { password } = await inquirer2.prompt([{
|
|
2430
2432
|
type: "password",
|
|
2431
2433
|
name: "password",
|
|
2432
2434
|
message: "\u8BBE\u7F6E\u5BC6\u7801 (\u81F3\u5C116\u4F4D):",
|
|
2433
2435
|
mask: "*",
|
|
2434
2436
|
validate: (v) => v.length >= 6 ? true : "\u5BC6\u7801\u81F3\u5C116\u4F4D"
|
|
2435
2437
|
}]);
|
|
2436
|
-
const { name } = await
|
|
2438
|
+
const { name } = await inquirer2.prompt([{
|
|
2437
2439
|
type: "input",
|
|
2438
2440
|
name: "name",
|
|
2439
2441
|
message: "\u6635\u79F0:",
|
|
@@ -2685,19 +2687,19 @@ function fmtTokens(n) {
|
|
|
2685
2687
|
}
|
|
2686
2688
|
|
|
2687
2689
|
// src/commands/config.ts
|
|
2688
|
-
import
|
|
2690
|
+
import inquirer3 from "inquirer";
|
|
2689
2691
|
async function configCommand() {
|
|
2690
2692
|
const config3 = getConfig();
|
|
2691
2693
|
console.log(`
|
|
2692
2694
|
\u914D\u7F6E\u6587\u4EF6: ${theme.dim(getConfigPath())}
|
|
2693
2695
|
`);
|
|
2694
|
-
const { action } = await
|
|
2696
|
+
const { action } = await inquirer3.prompt([{
|
|
2695
2697
|
type: "list",
|
|
2696
2698
|
name: "action",
|
|
2697
2699
|
message: "\u9009\u62E9\u8981\u914D\u7F6E\u7684\u9879\u76EE:",
|
|
2698
2700
|
choices: [
|
|
2699
2701
|
{ name: "\u{1F916} \u8BBE\u7F6EAI\u6A21\u578B", value: "model" },
|
|
2700
|
-
new
|
|
2702
|
+
new inquirer3.Separator("\u2500\u2500 API Key \u8BBE\u7F6E \u2500\u2500"),
|
|
2701
2703
|
{ name: "\u{1F319} Kimi \u6708\u4E4B\u6697\u9762", value: "key_kimi" },
|
|
2702
2704
|
{ name: "\u{1F9E0} OpenAI", value: "key_openai" },
|
|
2703
2705
|
{ name: "\u{1F3AD} Anthropic Claude", value: "key_anthropic" },
|
|
@@ -2710,7 +2712,7 @@ async function configCommand() {
|
|
|
2710
2712
|
{ name: "\u26A1 Groq", value: "key_groq" },
|
|
2711
2713
|
{ name: "\u{1F3D4}\uFE0F \u767E\u5DDD Baichuan", value: "key_baichuan" },
|
|
2712
2714
|
{ name: "\u{1F31F} \u96F6\u4E00\u4E07\u7269 Yi", value: "key_lingyiwanwu" },
|
|
2713
|
-
new
|
|
2715
|
+
new inquirer3.Separator("\u2500\u2500 \u5176\u4ED6\u8BBE\u7F6E \u2500\u2500"),
|
|
2714
2716
|
{ name: "\u{1F310} \u8BBE\u7F6E\u540E\u7AEF\u670D\u52A1\u5730\u5740", value: "apiBaseUrl" },
|
|
2715
2717
|
{ name: "\u{1F30D} \u8BBE\u7F6E\u754C\u9762\u8BED\u8A00", value: "locale" },
|
|
2716
2718
|
{ name: "\u{1F4CB} \u67E5\u770B\u5F53\u524D\u914D\u7F6E", value: "show" },
|
|
@@ -2725,7 +2727,7 @@ async function configCommand() {
|
|
|
2725
2727
|
if (currentKey) {
|
|
2726
2728
|
printInfo(`\u5F53\u524D\u5DF2\u914D\u7F6E ${displayName} Key`);
|
|
2727
2729
|
}
|
|
2728
|
-
const { key } = await
|
|
2730
|
+
const { key } = await inquirer3.prompt([{
|
|
2729
2731
|
type: "password",
|
|
2730
2732
|
name: "key",
|
|
2731
2733
|
message: `\u8F93\u5165 ${displayName} API Key:`,
|
|
@@ -2747,7 +2749,7 @@ async function configCommand() {
|
|
|
2747
2749
|
}
|
|
2748
2750
|
const choices = [];
|
|
2749
2751
|
for (const [group, groupModels] of groups) {
|
|
2750
|
-
choices.push(new
|
|
2752
|
+
choices.push(new inquirer3.Separator(`\u2500\u2500 ${group} \u2500\u2500`));
|
|
2751
2753
|
for (const m of groupModels) {
|
|
2752
2754
|
choices.push({
|
|
2753
2755
|
name: `${m.name} (${m.id})`,
|
|
@@ -2755,7 +2757,7 @@ async function configCommand() {
|
|
|
2755
2757
|
});
|
|
2756
2758
|
}
|
|
2757
2759
|
}
|
|
2758
|
-
const { model } = await
|
|
2760
|
+
const { model } = await inquirer3.prompt([{
|
|
2759
2761
|
type: "list",
|
|
2760
2762
|
name: "model",
|
|
2761
2763
|
message: "\u9009\u62E9AI\u6A21\u578B:",
|
|
@@ -2768,7 +2770,7 @@ async function configCommand() {
|
|
|
2768
2770
|
break;
|
|
2769
2771
|
}
|
|
2770
2772
|
case "apiBaseUrl": {
|
|
2771
|
-
const { url } = await
|
|
2773
|
+
const { url } = await inquirer3.prompt([{
|
|
2772
2774
|
type: "input",
|
|
2773
2775
|
name: "url",
|
|
2774
2776
|
message: "\u8F93\u5165\u540E\u7AEF\u670D\u52A1\u5730\u5740:",
|
|
@@ -2779,7 +2781,7 @@ async function configCommand() {
|
|
|
2779
2781
|
break;
|
|
2780
2782
|
}
|
|
2781
2783
|
case "locale": {
|
|
2782
|
-
const { locale } = await
|
|
2784
|
+
const { locale } = await inquirer3.prompt([{
|
|
2783
2785
|
type: "list",
|
|
2784
2786
|
name: "locale",
|
|
2785
2787
|
message: "\u9009\u62E9\u754C\u9762\u8BED\u8A00:",
|
|
@@ -2815,12 +2817,12 @@ async function configCommand() {
|
|
|
2815
2817
|
}
|
|
2816
2818
|
|
|
2817
2819
|
// src/commands/login.ts
|
|
2818
|
-
import
|
|
2820
|
+
import inquirer4 from "inquirer";
|
|
2819
2821
|
async function loginCommand() {
|
|
2820
2822
|
const config3 = getConfig();
|
|
2821
2823
|
if (config3.authToken && config3.userEmail) {
|
|
2822
2824
|
printInfo(`\u5F53\u524D\u5DF2\u767B\u5F55: ${config3.userEmail}`);
|
|
2823
|
-
const { relogin } = await
|
|
2825
|
+
const { relogin } = await inquirer4.prompt([{
|
|
2824
2826
|
type: "confirm",
|
|
2825
2827
|
name: "relogin",
|
|
2826
2828
|
message: "\u662F\u5426\u91CD\u65B0\u767B\u5F55\uFF1F",
|
|
@@ -2829,7 +2831,7 @@ async function loginCommand() {
|
|
|
2829
2831
|
if (!relogin) return;
|
|
2830
2832
|
}
|
|
2831
2833
|
console.log(theme.brandBold("\n\u{1F511} \u767B\u5F55\u6C88\u7FD4\u7684AI\u52A9\u624B\n"));
|
|
2832
|
-
const { email } = await
|
|
2834
|
+
const { email } = await inquirer4.prompt([{
|
|
2833
2835
|
type: "input",
|
|
2834
2836
|
name: "email",
|
|
2835
2837
|
message: "\u90AE\u7BB1:",
|
|
@@ -2838,7 +2840,7 @@ async function loginCommand() {
|
|
|
2838
2840
|
return true;
|
|
2839
2841
|
}
|
|
2840
2842
|
}]);
|
|
2841
|
-
const { password } = await
|
|
2843
|
+
const { password } = await inquirer4.prompt([{
|
|
2842
2844
|
type: "password",
|
|
2843
2845
|
name: "password",
|
|
2844
2846
|
message: "\u5BC6\u7801:",
|
|
@@ -2864,7 +2866,7 @@ async function loginCommand() {
|
|
|
2864
2866
|
console.log();
|
|
2865
2867
|
} else if (response.status === 404) {
|
|
2866
2868
|
printInfo("\u8BE5\u90AE\u7BB1\u5C1A\u672A\u6CE8\u518C");
|
|
2867
|
-
const { register } = await
|
|
2869
|
+
const { register } = await inquirer4.prompt([{
|
|
2868
2870
|
type: "confirm",
|
|
2869
2871
|
name: "register",
|
|
2870
2872
|
message: "\u662F\u5426\u7ACB\u5373\u6CE8\u518C\uFF1F",
|
|
@@ -2898,12 +2900,12 @@ async function loginCommand() {
|
|
|
2898
2900
|
}
|
|
2899
2901
|
|
|
2900
2902
|
// src/commands/register.ts
|
|
2901
|
-
import
|
|
2903
|
+
import inquirer5 from "inquirer";
|
|
2902
2904
|
async function registerCommand() {
|
|
2903
2905
|
const config3 = getConfig();
|
|
2904
2906
|
if (config3.authToken && config3.userEmail) {
|
|
2905
2907
|
printInfo(`\u5F53\u524D\u5DF2\u767B\u5F55: ${config3.userEmail}`);
|
|
2906
|
-
const { proceed } = await
|
|
2908
|
+
const { proceed } = await inquirer5.prompt([{
|
|
2907
2909
|
type: "confirm",
|
|
2908
2910
|
name: "proceed",
|
|
2909
2911
|
message: "\u662F\u5426\u6CE8\u518C\u65B0\u8D26\u6237\uFF1F\uFF08\u5C06\u8986\u76D6\u5F53\u524D\u767B\u5F55\u72B6\u6001\uFF09",
|
|
@@ -2912,7 +2914,7 @@ async function registerCommand() {
|
|
|
2912
2914
|
if (!proceed) return;
|
|
2913
2915
|
}
|
|
2914
2916
|
console.log(theme.brandBold("\n\u{1F4DD} \u6CE8\u518C\u6C88\u7FD4\u7684AI\u52A9\u624B\u8D26\u6237\n"));
|
|
2915
|
-
const { email } = await
|
|
2917
|
+
const { email } = await inquirer5.prompt([{
|
|
2916
2918
|
type: "input",
|
|
2917
2919
|
name: "email",
|
|
2918
2920
|
message: "\u90AE\u7BB1:",
|
|
@@ -2921,13 +2923,13 @@ async function registerCommand() {
|
|
|
2921
2923
|
return true;
|
|
2922
2924
|
}
|
|
2923
2925
|
}]);
|
|
2924
|
-
const { name } = await
|
|
2926
|
+
const { name } = await inquirer5.prompt([{
|
|
2925
2927
|
type: "input",
|
|
2926
2928
|
name: "name",
|
|
2927
2929
|
message: "\u6635\u79F0 (\u53EF\u9009):",
|
|
2928
2930
|
default: email.split("@")[0]
|
|
2929
2931
|
}]);
|
|
2930
|
-
const { password } = await
|
|
2932
|
+
const { password } = await inquirer5.prompt([{
|
|
2931
2933
|
type: "password",
|
|
2932
2934
|
name: "password",
|
|
2933
2935
|
message: "\u5BC6\u7801 (\u81F3\u5C116\u4F4D):",
|
|
@@ -2937,7 +2939,7 @@ async function registerCommand() {
|
|
|
2937
2939
|
return true;
|
|
2938
2940
|
}
|
|
2939
2941
|
}]);
|
|
2940
|
-
const { confirmPassword } = await
|
|
2942
|
+
const { confirmPassword } = await inquirer5.prompt([{
|
|
2941
2943
|
type: "password",
|
|
2942
2944
|
name: "confirmPassword",
|
|
2943
2945
|
message: "\u786E\u8BA4\u5BC6\u7801:",
|
|
@@ -3070,7 +3072,7 @@ function progressBar(used, limit, width = 16) {
|
|
|
3070
3072
|
}
|
|
3071
3073
|
|
|
3072
3074
|
// src/commands/admin.ts
|
|
3073
|
-
import
|
|
3075
|
+
import inquirer6 from "inquirer";
|
|
3074
3076
|
async function adminCommand() {
|
|
3075
3077
|
const config3 = getConfig();
|
|
3076
3078
|
if (!config3.authToken) {
|
|
@@ -3078,7 +3080,7 @@ async function adminCommand() {
|
|
|
3078
3080
|
return;
|
|
3079
3081
|
}
|
|
3080
3082
|
console.log(theme.brandBold("\n\u2699\uFE0F \u7BA1\u7406\u5458\u63A7\u5236\u53F0\n"));
|
|
3081
|
-
const { action } = await
|
|
3083
|
+
const { action } = await inquirer6.prompt([{
|
|
3082
3084
|
type: "list",
|
|
3083
3085
|
name: "action",
|
|
3084
3086
|
message: "\u9009\u62E9\u64CD\u4F5C:",
|
|
@@ -3165,7 +3167,7 @@ async function listUsers(config3) {
|
|
|
3165
3167
|
async function setUserQuota(config3) {
|
|
3166
3168
|
const users = await fetchUserList(config3);
|
|
3167
3169
|
if (!users) return;
|
|
3168
|
-
const { userId } = await
|
|
3170
|
+
const { userId } = await inquirer6.prompt([{
|
|
3169
3171
|
type: "list",
|
|
3170
3172
|
name: "userId",
|
|
3171
3173
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3175,19 +3177,19 @@ async function setUserQuota(config3) {
|
|
|
3175
3177
|
console.log(theme.dim(`
|
|
3176
3178
|
\u5F53\u524D\u989D\u5EA6: \u65E5\u9650=${selectedUser.dailyLimit}\u6B21 \u6708Token=${fmtTokens3(selectedUser.monthlyTokenLimit)} \u514D\u8D39\u603B\u989D=${fmtTokens3(selectedUser.totalFreeTokens)}
|
|
3177
3179
|
`));
|
|
3178
|
-
const { dailyLimit } = await
|
|
3180
|
+
const { dailyLimit } = await inquirer6.prompt([{
|
|
3179
3181
|
type: "number",
|
|
3180
3182
|
name: "dailyLimit",
|
|
3181
3183
|
message: "\u6BCF\u65E5\u8BF7\u6C42\u4E0A\u9650:",
|
|
3182
3184
|
default: selectedUser.dailyLimit
|
|
3183
3185
|
}]);
|
|
3184
|
-
const { monthlyTokenLimit } = await
|
|
3186
|
+
const { monthlyTokenLimit } = await inquirer6.prompt([{
|
|
3185
3187
|
type: "number",
|
|
3186
3188
|
name: "monthlyTokenLimit",
|
|
3187
3189
|
message: "\u6BCF\u6708Token\u4E0A\u9650:",
|
|
3188
3190
|
default: selectedUser.monthlyTokenLimit
|
|
3189
3191
|
}]);
|
|
3190
|
-
const { totalFreeTokens } = await
|
|
3192
|
+
const { totalFreeTokens } = await inquirer6.prompt([{
|
|
3191
3193
|
type: "number",
|
|
3192
3194
|
name: "totalFreeTokens",
|
|
3193
3195
|
message: "\u514D\u8D39Token\u603B\u989D:",
|
|
@@ -3213,13 +3215,13 @@ async function setUserQuota(config3) {
|
|
|
3213
3215
|
async function setUserPlan(config3) {
|
|
3214
3216
|
const users = await fetchUserList(config3);
|
|
3215
3217
|
if (!users) return;
|
|
3216
|
-
const { userId } = await
|
|
3218
|
+
const { userId } = await inquirer6.prompt([{
|
|
3217
3219
|
type: "list",
|
|
3218
3220
|
name: "userId",
|
|
3219
3221
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
3220
3222
|
choices: users.map((u) => ({ name: `${u.email} (\u5F53\u524D: ${u.plan})`, value: u.id }))
|
|
3221
3223
|
}]);
|
|
3222
|
-
const { plan } = await
|
|
3224
|
+
const { plan } = await inquirer6.prompt([{
|
|
3223
3225
|
type: "list",
|
|
3224
3226
|
name: "plan",
|
|
3225
3227
|
message: "\u9009\u62E9\u8BA1\u5212:",
|
|
@@ -3249,7 +3251,7 @@ async function setUserPlan(config3) {
|
|
|
3249
3251
|
async function setUserRole(config3) {
|
|
3250
3252
|
const users = await fetchUserList(config3);
|
|
3251
3253
|
if (!users) return;
|
|
3252
|
-
const { userId } = await
|
|
3254
|
+
const { userId } = await inquirer6.prompt([{
|
|
3253
3255
|
type: "list",
|
|
3254
3256
|
name: "userId",
|
|
3255
3257
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3258,7 +3260,7 @@ async function setUserRole(config3) {
|
|
|
3258
3260
|
value: u.id
|
|
3259
3261
|
}))
|
|
3260
3262
|
}]);
|
|
3261
|
-
const { role } = await
|
|
3263
|
+
const { role } = await inquirer6.prompt([{
|
|
3262
3264
|
type: "list",
|
|
3263
3265
|
name: "role",
|
|
3264
3266
|
message: "\u8BBE\u7F6E\u89D2\u8272:",
|
|
@@ -3287,7 +3289,7 @@ async function setUserRole(config3) {
|
|
|
3287
3289
|
async function resetUsage(config3) {
|
|
3288
3290
|
const users = await fetchUserList(config3);
|
|
3289
3291
|
if (!users) return;
|
|
3290
|
-
const { userId } = await
|
|
3292
|
+
const { userId } = await inquirer6.prompt([{
|
|
3291
3293
|
type: "list",
|
|
3292
3294
|
name: "userId",
|
|
3293
3295
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3296,7 +3298,7 @@ async function resetUsage(config3) {
|
|
|
3296
3298
|
value: u.id
|
|
3297
3299
|
}))
|
|
3298
3300
|
}]);
|
|
3299
|
-
const { confirm } = await
|
|
3301
|
+
const { confirm } = await inquirer6.prompt([{
|
|
3300
3302
|
type: "confirm",
|
|
3301
3303
|
name: "confirm",
|
|
3302
3304
|
message: "\u786E\u5B9A\u8981\u91CD\u7F6E\u8BE5\u7528\u6237\u7684\u7D2F\u8BA1\u7528\u91CF\u5417\uFF1F",
|
|
@@ -3321,7 +3323,7 @@ async function resetUsage(config3) {
|
|
|
3321
3323
|
async function toggleUserStatus(config3) {
|
|
3322
3324
|
const users = await fetchUserList(config3);
|
|
3323
3325
|
if (!users) return;
|
|
3324
|
-
const { userId } = await
|
|
3326
|
+
const { userId } = await inquirer6.prompt([{
|
|
3325
3327
|
type: "list",
|
|
3326
3328
|
name: "userId",
|
|
3327
3329
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3390,7 +3392,7 @@ function fmtTokens3(n) {
|
|
|
3390
3392
|
var program = new Command();
|
|
3391
3393
|
var config2 = getConfig();
|
|
3392
3394
|
setLocale(config2.locale);
|
|
3393
|
-
program.name("sxai").description(t("description")).version("0.5.
|
|
3395
|
+
program.name("sxai").description(t("description")).version("0.5.7");
|
|
3394
3396
|
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) => {
|
|
3395
3397
|
if (options.model && options.model !== config2.model) {
|
|
3396
3398
|
setConfig("model", options.model);
|