base_parts_ai 1.0.35 → 1.0.36
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/lib/claude_utils.js +1 -1
- package/lib/setapi.js +21 -29
- package/package.json +1 -1
package/lib/claude_utils.js
CHANGED
|
@@ -9,6 +9,7 @@ var fs = require('fs');
|
|
|
9
9
|
var path = require('path');
|
|
10
10
|
var http = require('http');
|
|
11
11
|
var { execSync } = require('child_process');
|
|
12
|
+
var { select } = require('@inquirer/prompts');
|
|
12
13
|
|
|
13
14
|
// ============================================================
|
|
14
15
|
// AI 渠道列表(运行时由 fetchConfig 从服务端拉取填充)
|
|
@@ -55,7 +56,6 @@ function fetchConfig(buildCfg) {
|
|
|
55
56
|
if (newVer && newVer !== currentVer) {
|
|
56
57
|
console.log('[fetchConfig] 检测到新版本 jcc: ' + newVer + '(当前 ' + currentVer + ')');
|
|
57
58
|
// 用 select 上下选,默认高亮"立即升级"
|
|
58
|
-
var { select } = require('@inquirer/prompts');
|
|
59
59
|
var confirmed = await select({
|
|
60
60
|
message: '是否立即升级?',
|
|
61
61
|
default: 'yes',
|
package/lib/setapi.js
CHANGED
|
@@ -104,36 +104,28 @@ module.exports = async function (cmd, buildCfg) {
|
|
|
104
104
|
console.log(' BASE_URL: ' + settings.env.ANTHROPIC_BASE_URL);
|
|
105
105
|
console.log(' Token: ' + utils.maskKey(settings.env.ANTHROPIC_AUTH_TOKEN));
|
|
106
106
|
} else {
|
|
107
|
-
// 查询该渠道是否有缓存的 Key
|
|
107
|
+
// 查询该渠道是否有缓存的 Key,作为输入框默认值(方便用户确认或修改)
|
|
108
108
|
var savedKey = (jccJson.keys && jccJson.keys[selected.id]) || '';
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// 缓存到 jcc.json
|
|
131
|
-
if (!jccJson.keys) { jccJson.keys = {}; }
|
|
132
|
-
jccJson.keys[selected.id] = newKey;
|
|
133
|
-
utils.writeJsonFile(buildCfg.jccJsonPath, jccJson);
|
|
134
|
-
|
|
135
|
-
console.log('✅ 已切换到渠道: ' + selected.name + ',Key 已保存到本地缓存。');
|
|
136
|
-
}
|
|
109
|
+
var newKey = await input({
|
|
110
|
+
message: '请输入 ANTHROPIC_AUTH_TOKEN:',
|
|
111
|
+
default: savedKey,
|
|
112
|
+
validate: function (v) {
|
|
113
|
+
return v.trim().length > 0 ? true : 'Key 不能为空';
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
newKey = newKey.trim();
|
|
117
|
+
|
|
118
|
+
// 写入 settings.json
|
|
119
|
+
settings.env.ANTHROPIC_AUTH_TOKEN = newKey;
|
|
120
|
+
utils.writeJsonFile(buildCfg.claudeSettingsPath, settings);
|
|
121
|
+
|
|
122
|
+
// 缓存到 jcc.json
|
|
123
|
+
if (!jccJson.keys) { jccJson.keys = {}; }
|
|
124
|
+
jccJson.keys[selected.id] = newKey;
|
|
125
|
+
utils.writeJsonFile(buildCfg.jccJsonPath, jccJson);
|
|
126
|
+
|
|
127
|
+
console.log('✅ 已切换到渠道: ' + selected.name + ',Key 已保存到本地缓存。');
|
|
128
|
+
console.log(' Key: ' + utils.maskKey(newKey));
|
|
137
129
|
}
|
|
138
130
|
|
|
139
131
|
// 从 ccVersionList 对象中确定目标版本号
|