base_parts_ai 1.0.33 → 1.0.34

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/jcc.js CHANGED
@@ -96,38 +96,35 @@ function loadLib(libName) {
96
96
  return require(libPath);
97
97
  }
98
98
 
99
+ /**
100
+ * 公共命令执行流程:拉取配置 → 显示公告 → 执行业务模块 → 完成提示
101
+ * @param {string} libName lib 目录下的业务模块名(不含 .js)
102
+ * @param {object} opts commander 解析出的选项
103
+ */
104
+ async function runCommand(libName, opts) {
105
+ var buildCfg = getBuildCfg(opts);
106
+ // 从服务端拉取渠道配置(含 jcc 自动升级检查)
107
+ var utils = loadLib('claude_utils');
108
+ await utils.fetchConfig(buildCfg);
109
+ // 显示公告,有公告时等待用户按回车继续
110
+ await utils.showNotice();
111
+ // 执行业务模块
112
+ await loadLib(libName)(opts, buildCfg);
113
+ console.log('\n✅ 完成!重启 Claude 后生效。');
114
+ }
115
+
99
116
  // 命令:setapi —— 选择 AI 渠道,修改 Claude settings.json 中的 ANTHROPIC_BASE_URL
100
117
  program
101
118
  .command('setapi')
102
- // .option('-c, --config <file>', 'Config file,default:jai_cfg.json')
103
119
  .action(async function () {
104
- // commander v14:通过 this.opts() 获取选项
105
- var opts = this.opts();
106
- var buildCfg = getBuildCfg(opts);
107
- // 从服务端拉取渠道配置(含 jcc 自动升级检查)
108
- var utils = loadLib('claude_utils');
109
- await utils.fetchConfig(buildCfg);
110
- // 显示公告,有公告时等待用户按回车继续
111
- await utils.showNotice();
112
- await loadLib('setapi')(opts, buildCfg);
113
- console.log("\nfinish");
120
+ await runCommand('setapi', this.opts());
114
121
  });
115
122
 
116
123
  // 命令:setkey —— 设置 AI Key,修改 Claude settings.json 中的 ANTHROPIC_API_KEY
117
124
  program
118
125
  .command('setkey')
119
- // .option('-c, --config <file>', 'Config file,default:jai_cfg.json')
120
126
  .action(async function () {
121
- // commander v14:通过 this.opts() 获取选项
122
- var opts = this.opts();
123
- var buildCfg = getBuildCfg(opts);
124
- // 从服务端拉取渠道配置(含 jcc 自动升级检查)
125
- var utils = loadLib('claude_utils');
126
- await utils.fetchConfig(buildCfg);
127
- // 显示公告,有公告时等待用户按回车继续
128
- await utils.showNotice();
129
- await loadLib('setkey')(opts, buildCfg);
130
- console.log("\nfinish");
127
+ await runCommand('setkey', this.opts());
131
128
  });
132
129
 
133
130
 
@@ -160,14 +160,13 @@ function maskKey(key) {
160
160
  */
161
161
  function printCurrentInfo(settings) {
162
162
  var info = getCurrentInfo(settings);
163
- console.log('\n====== 当前 Claude 配置 ======');
163
+ // console.log('\n====== 当前 Claude 配置 ======');
164
+ let curSelectedChannel = '(' + (info.jid || '未设置') + ')';
164
165
  if (info.channel) {
165
- console.log('当前渠道: ' + info.channel.name + ' (' + info.channel.id + ')');
166
- } else {
167
- console.log('当前渠道: 未知/自定义 (' + (info.jid || '未设置') + ')');
166
+ curSelectedChannel = info.channel.name;
168
167
  }
169
- console.log('当前 Key: ' + maskKey(info.key));
170
- console.log('==============================\n');
168
+ console.log('\x1b[33m当前渠道: ' + curSelectedChannel + ', Key: ' + maskKey(info.key) + '');
169
+ console.log('============================================================\x1b[0m\n');
171
170
  }
172
171
 
173
172
  /**
@@ -176,19 +175,19 @@ function printCurrentInfo(settings) {
176
175
  */
177
176
  function showNotice() {
178
177
  if (!noticeList.length) return Promise.resolve();
179
- console.log('\n\x1b[33m====== 公告 ======');
178
+ console.log('\n\x1b[33m=========================== 公告 ===========================');
180
179
  noticeList.forEach(function (line) {
181
180
  console.log(line);
182
181
  });
183
- console.log('==================\x1b[0m\n');
184
- // 等待用户按回车继续
185
- return new Promise(function (resolve) {
186
- var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
187
- rl.question('按回车键继续...', function () {
188
- rl.close();
189
- resolve();
190
- });
191
- });
182
+ console.log('============================================================\x1b[0m');
183
+ // // 等待用户按回车继续
184
+ // return new Promise(function (resolve) {
185
+ // var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
186
+ // rl.question('按回车键继续...', function () {
187
+ // rl.close();
188
+ // resolve();
189
+ // });
190
+ // });
192
191
  }
193
192
 
194
193
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "base_parts_ai",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "jaskle base_parts_ai",
5
5
  "main": "./main.js",
6
6
  "registry": true,