xiaozhou-chat 1.0.13 → 1.0.15
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/bin/cli.js +44 -0
- package/package.json +2 -3
package/bin/cli.js
CHANGED
|
@@ -36,6 +36,50 @@ if (args._.includes("init")) {
|
|
|
36
36
|
process.exit(0);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// 处理 config 命令 (CLI 模式)
|
|
40
|
+
if (args._[0] === "config") {
|
|
41
|
+
// 重新加载配置以确保最新
|
|
42
|
+
initConfigFile();
|
|
43
|
+
let config = loadConfig();
|
|
44
|
+
let changed = false;
|
|
45
|
+
const profileName = config.currentProfile || "default";
|
|
46
|
+
|
|
47
|
+
if (args.key || args.k) {
|
|
48
|
+
const val = args.key || args.k;
|
|
49
|
+
updateConfig("apiKey", val);
|
|
50
|
+
setProfileValue(profileName, "apiKey", val);
|
|
51
|
+
console.log(`✅ API Key 已更新`);
|
|
52
|
+
changed = true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (args.url || args.u) {
|
|
56
|
+
const val = args.url || args.u;
|
|
57
|
+
updateConfig("baseUrl", val);
|
|
58
|
+
setProfileValue(profileName, "baseUrl", val);
|
|
59
|
+
console.log(`✅ Base URL 已更新为: ${val}`);
|
|
60
|
+
changed = true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (args.model || args.m) {
|
|
64
|
+
const val = args.model || args.m;
|
|
65
|
+
updateConfig("model", val);
|
|
66
|
+
setProfileValue(profileName, "model", val);
|
|
67
|
+
console.log(`✅ Model 已更新为: ${val}`);
|
|
68
|
+
changed = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!changed) {
|
|
72
|
+
console.log("当前生效配置 (Active Profile):");
|
|
73
|
+
console.log(JSON.stringify(getActiveConfig(config), null, 2));
|
|
74
|
+
console.log("\n使用方法:");
|
|
75
|
+
console.log(" npx xiaozhou-chat config --key=sk-xxxx");
|
|
76
|
+
console.log(" npx xiaozhou-chat config --url=https://api.example.com/v1");
|
|
77
|
+
console.log(" npx xiaozhou-chat config --model=gpt-4");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
|
|
39
83
|
// --- 初始化 ---
|
|
40
84
|
initConfigFile();
|
|
41
85
|
let config = loadConfig();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xiaozhou-chat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "CLI chatbot based on NewAPI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"xiaozhou-chat": "bin/cli.js"
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
"marked": "^15.0.12",
|
|
23
23
|
"marked-terminal": "^7.3.0",
|
|
24
24
|
"minimist": "^1.2.8",
|
|
25
|
-
"moment": "^2.30.1"
|
|
26
|
-
"xiaozhou-chat": "^1.0.1-0.1"
|
|
25
|
+
"moment": "^2.30.1"
|
|
27
26
|
},
|
|
28
27
|
"pkg": {
|
|
29
28
|
"assets": []
|