shenxiang-ai-cli 0.5.5 → 0.5.6
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 +66 -69
- 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.6";
|
|
2230
2221
|
const avatarLines = [
|
|
2231
2222
|
` ${p("\u2584\u2580\u2580\u2580\u2584")}`,
|
|
2232
2223
|
` ${p("\u2588")} ${w("\u2580")} ${w("\u2580")} ${p("\u2588")}`,
|
|
@@ -2298,6 +2289,12 @@ function showBanner() {
|
|
|
2298
2289
|
}));
|
|
2299
2290
|
}
|
|
2300
2291
|
|
|
2292
|
+
// src/utils/input.ts
|
|
2293
|
+
var _questionFn = null;
|
|
2294
|
+
function registerQuestionFn(fn) {
|
|
2295
|
+
_questionFn = fn;
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2301
2298
|
// src/commands/chat.ts
|
|
2302
2299
|
async function chatCommand(options = {}) {
|
|
2303
2300
|
const config3 = getConfig();
|
|
@@ -2335,7 +2332,7 @@ async function chatCommand(options = {}) {
|
|
|
2335
2332
|
console.log();
|
|
2336
2333
|
}
|
|
2337
2334
|
registerQuestionFn(async (prompt) => {
|
|
2338
|
-
const { answer } = await
|
|
2335
|
+
const { answer } = await inquirer2.prompt([{
|
|
2339
2336
|
type: "input",
|
|
2340
2337
|
name: "answer",
|
|
2341
2338
|
message: prompt,
|
|
@@ -2385,7 +2382,7 @@ async function chatCommand(options = {}) {
|
|
|
2385
2382
|
while (true) {
|
|
2386
2383
|
let input;
|
|
2387
2384
|
try {
|
|
2388
|
-
const result = await
|
|
2385
|
+
const result = await inquirer2.prompt([{
|
|
2389
2386
|
type: "input",
|
|
2390
2387
|
name: "input",
|
|
2391
2388
|
message: theme.user("\u4F60:"),
|
|
@@ -2420,20 +2417,20 @@ async function chatCommand(options = {}) {
|
|
|
2420
2417
|
}
|
|
2421
2418
|
async function doInlineRegister() {
|
|
2422
2419
|
const config3 = getConfig();
|
|
2423
|
-
const { email } = await
|
|
2420
|
+
const { email } = await inquirer2.prompt([{
|
|
2424
2421
|
type: "input",
|
|
2425
2422
|
name: "email",
|
|
2426
2423
|
message: "\u90AE\u7BB1:",
|
|
2427
2424
|
validate: (v) => v.includes("@") ? true : "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1"
|
|
2428
2425
|
}]);
|
|
2429
|
-
const { password } = await
|
|
2426
|
+
const { password } = await inquirer2.prompt([{
|
|
2430
2427
|
type: "password",
|
|
2431
2428
|
name: "password",
|
|
2432
2429
|
message: "\u8BBE\u7F6E\u5BC6\u7801 (\u81F3\u5C116\u4F4D):",
|
|
2433
2430
|
mask: "*",
|
|
2434
2431
|
validate: (v) => v.length >= 6 ? true : "\u5BC6\u7801\u81F3\u5C116\u4F4D"
|
|
2435
2432
|
}]);
|
|
2436
|
-
const { name } = await
|
|
2433
|
+
const { name } = await inquirer2.prompt([{
|
|
2437
2434
|
type: "input",
|
|
2438
2435
|
name: "name",
|
|
2439
2436
|
message: "\u6635\u79F0:",
|
|
@@ -2685,19 +2682,19 @@ function fmtTokens(n) {
|
|
|
2685
2682
|
}
|
|
2686
2683
|
|
|
2687
2684
|
// src/commands/config.ts
|
|
2688
|
-
import
|
|
2685
|
+
import inquirer3 from "inquirer";
|
|
2689
2686
|
async function configCommand() {
|
|
2690
2687
|
const config3 = getConfig();
|
|
2691
2688
|
console.log(`
|
|
2692
2689
|
\u914D\u7F6E\u6587\u4EF6: ${theme.dim(getConfigPath())}
|
|
2693
2690
|
`);
|
|
2694
|
-
const { action } = await
|
|
2691
|
+
const { action } = await inquirer3.prompt([{
|
|
2695
2692
|
type: "list",
|
|
2696
2693
|
name: "action",
|
|
2697
2694
|
message: "\u9009\u62E9\u8981\u914D\u7F6E\u7684\u9879\u76EE:",
|
|
2698
2695
|
choices: [
|
|
2699
2696
|
{ name: "\u{1F916} \u8BBE\u7F6EAI\u6A21\u578B", value: "model" },
|
|
2700
|
-
new
|
|
2697
|
+
new inquirer3.Separator("\u2500\u2500 API Key \u8BBE\u7F6E \u2500\u2500"),
|
|
2701
2698
|
{ name: "\u{1F319} Kimi \u6708\u4E4B\u6697\u9762", value: "key_kimi" },
|
|
2702
2699
|
{ name: "\u{1F9E0} OpenAI", value: "key_openai" },
|
|
2703
2700
|
{ name: "\u{1F3AD} Anthropic Claude", value: "key_anthropic" },
|
|
@@ -2710,7 +2707,7 @@ async function configCommand() {
|
|
|
2710
2707
|
{ name: "\u26A1 Groq", value: "key_groq" },
|
|
2711
2708
|
{ name: "\u{1F3D4}\uFE0F \u767E\u5DDD Baichuan", value: "key_baichuan" },
|
|
2712
2709
|
{ name: "\u{1F31F} \u96F6\u4E00\u4E07\u7269 Yi", value: "key_lingyiwanwu" },
|
|
2713
|
-
new
|
|
2710
|
+
new inquirer3.Separator("\u2500\u2500 \u5176\u4ED6\u8BBE\u7F6E \u2500\u2500"),
|
|
2714
2711
|
{ name: "\u{1F310} \u8BBE\u7F6E\u540E\u7AEF\u670D\u52A1\u5730\u5740", value: "apiBaseUrl" },
|
|
2715
2712
|
{ name: "\u{1F30D} \u8BBE\u7F6E\u754C\u9762\u8BED\u8A00", value: "locale" },
|
|
2716
2713
|
{ name: "\u{1F4CB} \u67E5\u770B\u5F53\u524D\u914D\u7F6E", value: "show" },
|
|
@@ -2725,7 +2722,7 @@ async function configCommand() {
|
|
|
2725
2722
|
if (currentKey) {
|
|
2726
2723
|
printInfo(`\u5F53\u524D\u5DF2\u914D\u7F6E ${displayName} Key`);
|
|
2727
2724
|
}
|
|
2728
|
-
const { key } = await
|
|
2725
|
+
const { key } = await inquirer3.prompt([{
|
|
2729
2726
|
type: "password",
|
|
2730
2727
|
name: "key",
|
|
2731
2728
|
message: `\u8F93\u5165 ${displayName} API Key:`,
|
|
@@ -2747,7 +2744,7 @@ async function configCommand() {
|
|
|
2747
2744
|
}
|
|
2748
2745
|
const choices = [];
|
|
2749
2746
|
for (const [group, groupModels] of groups) {
|
|
2750
|
-
choices.push(new
|
|
2747
|
+
choices.push(new inquirer3.Separator(`\u2500\u2500 ${group} \u2500\u2500`));
|
|
2751
2748
|
for (const m of groupModels) {
|
|
2752
2749
|
choices.push({
|
|
2753
2750
|
name: `${m.name} (${m.id})`,
|
|
@@ -2755,7 +2752,7 @@ async function configCommand() {
|
|
|
2755
2752
|
});
|
|
2756
2753
|
}
|
|
2757
2754
|
}
|
|
2758
|
-
const { model } = await
|
|
2755
|
+
const { model } = await inquirer3.prompt([{
|
|
2759
2756
|
type: "list",
|
|
2760
2757
|
name: "model",
|
|
2761
2758
|
message: "\u9009\u62E9AI\u6A21\u578B:",
|
|
@@ -2768,7 +2765,7 @@ async function configCommand() {
|
|
|
2768
2765
|
break;
|
|
2769
2766
|
}
|
|
2770
2767
|
case "apiBaseUrl": {
|
|
2771
|
-
const { url } = await
|
|
2768
|
+
const { url } = await inquirer3.prompt([{
|
|
2772
2769
|
type: "input",
|
|
2773
2770
|
name: "url",
|
|
2774
2771
|
message: "\u8F93\u5165\u540E\u7AEF\u670D\u52A1\u5730\u5740:",
|
|
@@ -2779,7 +2776,7 @@ async function configCommand() {
|
|
|
2779
2776
|
break;
|
|
2780
2777
|
}
|
|
2781
2778
|
case "locale": {
|
|
2782
|
-
const { locale } = await
|
|
2779
|
+
const { locale } = await inquirer3.prompt([{
|
|
2783
2780
|
type: "list",
|
|
2784
2781
|
name: "locale",
|
|
2785
2782
|
message: "\u9009\u62E9\u754C\u9762\u8BED\u8A00:",
|
|
@@ -2815,12 +2812,12 @@ async function configCommand() {
|
|
|
2815
2812
|
}
|
|
2816
2813
|
|
|
2817
2814
|
// src/commands/login.ts
|
|
2818
|
-
import
|
|
2815
|
+
import inquirer4 from "inquirer";
|
|
2819
2816
|
async function loginCommand() {
|
|
2820
2817
|
const config3 = getConfig();
|
|
2821
2818
|
if (config3.authToken && config3.userEmail) {
|
|
2822
2819
|
printInfo(`\u5F53\u524D\u5DF2\u767B\u5F55: ${config3.userEmail}`);
|
|
2823
|
-
const { relogin } = await
|
|
2820
|
+
const { relogin } = await inquirer4.prompt([{
|
|
2824
2821
|
type: "confirm",
|
|
2825
2822
|
name: "relogin",
|
|
2826
2823
|
message: "\u662F\u5426\u91CD\u65B0\u767B\u5F55\uFF1F",
|
|
@@ -2829,7 +2826,7 @@ async function loginCommand() {
|
|
|
2829
2826
|
if (!relogin) return;
|
|
2830
2827
|
}
|
|
2831
2828
|
console.log(theme.brandBold("\n\u{1F511} \u767B\u5F55\u6C88\u7FD4\u7684AI\u52A9\u624B\n"));
|
|
2832
|
-
const { email } = await
|
|
2829
|
+
const { email } = await inquirer4.prompt([{
|
|
2833
2830
|
type: "input",
|
|
2834
2831
|
name: "email",
|
|
2835
2832
|
message: "\u90AE\u7BB1:",
|
|
@@ -2838,7 +2835,7 @@ async function loginCommand() {
|
|
|
2838
2835
|
return true;
|
|
2839
2836
|
}
|
|
2840
2837
|
}]);
|
|
2841
|
-
const { password } = await
|
|
2838
|
+
const { password } = await inquirer4.prompt([{
|
|
2842
2839
|
type: "password",
|
|
2843
2840
|
name: "password",
|
|
2844
2841
|
message: "\u5BC6\u7801:",
|
|
@@ -2864,7 +2861,7 @@ async function loginCommand() {
|
|
|
2864
2861
|
console.log();
|
|
2865
2862
|
} else if (response.status === 404) {
|
|
2866
2863
|
printInfo("\u8BE5\u90AE\u7BB1\u5C1A\u672A\u6CE8\u518C");
|
|
2867
|
-
const { register } = await
|
|
2864
|
+
const { register } = await inquirer4.prompt([{
|
|
2868
2865
|
type: "confirm",
|
|
2869
2866
|
name: "register",
|
|
2870
2867
|
message: "\u662F\u5426\u7ACB\u5373\u6CE8\u518C\uFF1F",
|
|
@@ -2898,12 +2895,12 @@ async function loginCommand() {
|
|
|
2898
2895
|
}
|
|
2899
2896
|
|
|
2900
2897
|
// src/commands/register.ts
|
|
2901
|
-
import
|
|
2898
|
+
import inquirer5 from "inquirer";
|
|
2902
2899
|
async function registerCommand() {
|
|
2903
2900
|
const config3 = getConfig();
|
|
2904
2901
|
if (config3.authToken && config3.userEmail) {
|
|
2905
2902
|
printInfo(`\u5F53\u524D\u5DF2\u767B\u5F55: ${config3.userEmail}`);
|
|
2906
|
-
const { proceed } = await
|
|
2903
|
+
const { proceed } = await inquirer5.prompt([{
|
|
2907
2904
|
type: "confirm",
|
|
2908
2905
|
name: "proceed",
|
|
2909
2906
|
message: "\u662F\u5426\u6CE8\u518C\u65B0\u8D26\u6237\uFF1F\uFF08\u5C06\u8986\u76D6\u5F53\u524D\u767B\u5F55\u72B6\u6001\uFF09",
|
|
@@ -2912,7 +2909,7 @@ async function registerCommand() {
|
|
|
2912
2909
|
if (!proceed) return;
|
|
2913
2910
|
}
|
|
2914
2911
|
console.log(theme.brandBold("\n\u{1F4DD} \u6CE8\u518C\u6C88\u7FD4\u7684AI\u52A9\u624B\u8D26\u6237\n"));
|
|
2915
|
-
const { email } = await
|
|
2912
|
+
const { email } = await inquirer5.prompt([{
|
|
2916
2913
|
type: "input",
|
|
2917
2914
|
name: "email",
|
|
2918
2915
|
message: "\u90AE\u7BB1:",
|
|
@@ -2921,13 +2918,13 @@ async function registerCommand() {
|
|
|
2921
2918
|
return true;
|
|
2922
2919
|
}
|
|
2923
2920
|
}]);
|
|
2924
|
-
const { name } = await
|
|
2921
|
+
const { name } = await inquirer5.prompt([{
|
|
2925
2922
|
type: "input",
|
|
2926
2923
|
name: "name",
|
|
2927
2924
|
message: "\u6635\u79F0 (\u53EF\u9009):",
|
|
2928
2925
|
default: email.split("@")[0]
|
|
2929
2926
|
}]);
|
|
2930
|
-
const { password } = await
|
|
2927
|
+
const { password } = await inquirer5.prompt([{
|
|
2931
2928
|
type: "password",
|
|
2932
2929
|
name: "password",
|
|
2933
2930
|
message: "\u5BC6\u7801 (\u81F3\u5C116\u4F4D):",
|
|
@@ -2937,7 +2934,7 @@ async function registerCommand() {
|
|
|
2937
2934
|
return true;
|
|
2938
2935
|
}
|
|
2939
2936
|
}]);
|
|
2940
|
-
const { confirmPassword } = await
|
|
2937
|
+
const { confirmPassword } = await inquirer5.prompt([{
|
|
2941
2938
|
type: "password",
|
|
2942
2939
|
name: "confirmPassword",
|
|
2943
2940
|
message: "\u786E\u8BA4\u5BC6\u7801:",
|
|
@@ -3070,7 +3067,7 @@ function progressBar(used, limit, width = 16) {
|
|
|
3070
3067
|
}
|
|
3071
3068
|
|
|
3072
3069
|
// src/commands/admin.ts
|
|
3073
|
-
import
|
|
3070
|
+
import inquirer6 from "inquirer";
|
|
3074
3071
|
async function adminCommand() {
|
|
3075
3072
|
const config3 = getConfig();
|
|
3076
3073
|
if (!config3.authToken) {
|
|
@@ -3078,7 +3075,7 @@ async function adminCommand() {
|
|
|
3078
3075
|
return;
|
|
3079
3076
|
}
|
|
3080
3077
|
console.log(theme.brandBold("\n\u2699\uFE0F \u7BA1\u7406\u5458\u63A7\u5236\u53F0\n"));
|
|
3081
|
-
const { action } = await
|
|
3078
|
+
const { action } = await inquirer6.prompt([{
|
|
3082
3079
|
type: "list",
|
|
3083
3080
|
name: "action",
|
|
3084
3081
|
message: "\u9009\u62E9\u64CD\u4F5C:",
|
|
@@ -3165,7 +3162,7 @@ async function listUsers(config3) {
|
|
|
3165
3162
|
async function setUserQuota(config3) {
|
|
3166
3163
|
const users = await fetchUserList(config3);
|
|
3167
3164
|
if (!users) return;
|
|
3168
|
-
const { userId } = await
|
|
3165
|
+
const { userId } = await inquirer6.prompt([{
|
|
3169
3166
|
type: "list",
|
|
3170
3167
|
name: "userId",
|
|
3171
3168
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3175,19 +3172,19 @@ async function setUserQuota(config3) {
|
|
|
3175
3172
|
console.log(theme.dim(`
|
|
3176
3173
|
\u5F53\u524D\u989D\u5EA6: \u65E5\u9650=${selectedUser.dailyLimit}\u6B21 \u6708Token=${fmtTokens3(selectedUser.monthlyTokenLimit)} \u514D\u8D39\u603B\u989D=${fmtTokens3(selectedUser.totalFreeTokens)}
|
|
3177
3174
|
`));
|
|
3178
|
-
const { dailyLimit } = await
|
|
3175
|
+
const { dailyLimit } = await inquirer6.prompt([{
|
|
3179
3176
|
type: "number",
|
|
3180
3177
|
name: "dailyLimit",
|
|
3181
3178
|
message: "\u6BCF\u65E5\u8BF7\u6C42\u4E0A\u9650:",
|
|
3182
3179
|
default: selectedUser.dailyLimit
|
|
3183
3180
|
}]);
|
|
3184
|
-
const { monthlyTokenLimit } = await
|
|
3181
|
+
const { monthlyTokenLimit } = await inquirer6.prompt([{
|
|
3185
3182
|
type: "number",
|
|
3186
3183
|
name: "monthlyTokenLimit",
|
|
3187
3184
|
message: "\u6BCF\u6708Token\u4E0A\u9650:",
|
|
3188
3185
|
default: selectedUser.monthlyTokenLimit
|
|
3189
3186
|
}]);
|
|
3190
|
-
const { totalFreeTokens } = await
|
|
3187
|
+
const { totalFreeTokens } = await inquirer6.prompt([{
|
|
3191
3188
|
type: "number",
|
|
3192
3189
|
name: "totalFreeTokens",
|
|
3193
3190
|
message: "\u514D\u8D39Token\u603B\u989D:",
|
|
@@ -3213,13 +3210,13 @@ async function setUserQuota(config3) {
|
|
|
3213
3210
|
async function setUserPlan(config3) {
|
|
3214
3211
|
const users = await fetchUserList(config3);
|
|
3215
3212
|
if (!users) return;
|
|
3216
|
-
const { userId } = await
|
|
3213
|
+
const { userId } = await inquirer6.prompt([{
|
|
3217
3214
|
type: "list",
|
|
3218
3215
|
name: "userId",
|
|
3219
3216
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
3220
3217
|
choices: users.map((u) => ({ name: `${u.email} (\u5F53\u524D: ${u.plan})`, value: u.id }))
|
|
3221
3218
|
}]);
|
|
3222
|
-
const { plan } = await
|
|
3219
|
+
const { plan } = await inquirer6.prompt([{
|
|
3223
3220
|
type: "list",
|
|
3224
3221
|
name: "plan",
|
|
3225
3222
|
message: "\u9009\u62E9\u8BA1\u5212:",
|
|
@@ -3249,7 +3246,7 @@ async function setUserPlan(config3) {
|
|
|
3249
3246
|
async function setUserRole(config3) {
|
|
3250
3247
|
const users = await fetchUserList(config3);
|
|
3251
3248
|
if (!users) return;
|
|
3252
|
-
const { userId } = await
|
|
3249
|
+
const { userId } = await inquirer6.prompt([{
|
|
3253
3250
|
type: "list",
|
|
3254
3251
|
name: "userId",
|
|
3255
3252
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3258,7 +3255,7 @@ async function setUserRole(config3) {
|
|
|
3258
3255
|
value: u.id
|
|
3259
3256
|
}))
|
|
3260
3257
|
}]);
|
|
3261
|
-
const { role } = await
|
|
3258
|
+
const { role } = await inquirer6.prompt([{
|
|
3262
3259
|
type: "list",
|
|
3263
3260
|
name: "role",
|
|
3264
3261
|
message: "\u8BBE\u7F6E\u89D2\u8272:",
|
|
@@ -3287,7 +3284,7 @@ async function setUserRole(config3) {
|
|
|
3287
3284
|
async function resetUsage(config3) {
|
|
3288
3285
|
const users = await fetchUserList(config3);
|
|
3289
3286
|
if (!users) return;
|
|
3290
|
-
const { userId } = await
|
|
3287
|
+
const { userId } = await inquirer6.prompt([{
|
|
3291
3288
|
type: "list",
|
|
3292
3289
|
name: "userId",
|
|
3293
3290
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3296,7 +3293,7 @@ async function resetUsage(config3) {
|
|
|
3296
3293
|
value: u.id
|
|
3297
3294
|
}))
|
|
3298
3295
|
}]);
|
|
3299
|
-
const { confirm } = await
|
|
3296
|
+
const { confirm } = await inquirer6.prompt([{
|
|
3300
3297
|
type: "confirm",
|
|
3301
3298
|
name: "confirm",
|
|
3302
3299
|
message: "\u786E\u5B9A\u8981\u91CD\u7F6E\u8BE5\u7528\u6237\u7684\u7D2F\u8BA1\u7528\u91CF\u5417\uFF1F",
|
|
@@ -3321,7 +3318,7 @@ async function resetUsage(config3) {
|
|
|
3321
3318
|
async function toggleUserStatus(config3) {
|
|
3322
3319
|
const users = await fetchUserList(config3);
|
|
3323
3320
|
if (!users) return;
|
|
3324
|
-
const { userId } = await
|
|
3321
|
+
const { userId } = await inquirer6.prompt([{
|
|
3325
3322
|
type: "list",
|
|
3326
3323
|
name: "userId",
|
|
3327
3324
|
message: "\u9009\u62E9\u7528\u6237:",
|
|
@@ -3390,7 +3387,7 @@ function fmtTokens3(n) {
|
|
|
3390
3387
|
var program = new Command();
|
|
3391
3388
|
var config2 = getConfig();
|
|
3392
3389
|
setLocale(config2.locale);
|
|
3393
|
-
program.name("sxai").description(t("description")).version("0.5.
|
|
3390
|
+
program.name("sxai").description(t("description")).version("0.5.6");
|
|
3394
3391
|
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
3392
|
if (options.model && options.model !== config2.model) {
|
|
3396
3393
|
setConfig("model", options.model);
|