@pikecode/api-key-manager 1.1.3 → 1.3.0

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.
Files changed (35) hide show
  1. package/README.md +35 -5
  2. package/bin/akm.js +0 -0
  3. package/package.json +1 -1
  4. package/src/commands/BaseCommand.js +1 -1
  5. package/src/commands/add/prompts.js +251 -0
  6. package/src/commands/add/providerSaver.js +75 -0
  7. package/src/commands/add/summaryPrinter.js +29 -0
  8. package/src/commands/add.js +7 -419
  9. package/src/commands/backup.js +0 -1
  10. package/src/commands/batch.js +65 -66
  11. package/src/commands/benchmark.js +0 -21
  12. package/src/commands/current.js +1 -1
  13. package/src/commands/edit.js +1 -2
  14. package/src/commands/health.js +0 -2
  15. package/src/commands/list.js +1 -1
  16. package/src/commands/remove.js +63 -19
  17. package/src/commands/stats.js +1 -2
  18. package/src/commands/switch/claude-settings-compatibility.js +113 -0
  19. package/src/commands/switch/provider-choices-helper.js +71 -0
  20. package/src/commands/switch/provider-details-helper.js +46 -0
  21. package/src/commands/switch/provider-edit-questions-helper.js +102 -0
  22. package/src/commands/switch/provider-launcher.js +20 -0
  23. package/src/commands/switch.js +85 -435
  24. package/src/commands/validate.js +17 -17
  25. package/src/config.js +144 -47
  26. package/src/constants/ui.js +108 -0
  27. package/src/navigation/EscNavigationManager.js +5 -5
  28. package/src/utils/codex-launcher.js +3 -0
  29. package/src/utils/env-utils.js +2 -2
  30. package/src/utils/error-handler.js +0 -1
  31. package/src/utils/health-checker.js +34 -34
  32. package/src/utils/logger.js +0 -1
  33. package/src/utils/provider-status-checker.js +10 -41
  34. package/src/utils/update-checker.js +6 -1
  35. package/src/utils/validator.js +3 -16
@@ -4,17 +4,12 @@
4
4
  * @module commands/add
5
5
  */
6
6
 
7
- const inquirer = require('inquirer');
8
- const chalk = require('chalk');
9
7
  const { configManager } = require('../config');
10
- const { validator } = require('../utils/validator');
11
8
  const { Logger } = require('../utils/logger');
12
9
  const { UIHelper } = require('../utils/ui-helper');
13
10
  const { BaseCommand } = require('./BaseCommand');
14
- const {
15
- AUTH_MODE_DISPLAY_DETAILED,
16
- IDE_NAMES
17
- } = require('../constants');
11
+ const { promptProviderInfo, promptCodexLaunchArgs } = require('./add/prompts');
12
+ const { saveProvider } = require('./add/providerSaver');
18
13
 
19
14
  /**
20
15
  * 供应商添加器类
@@ -62,134 +57,7 @@ class ProviderAdder extends BaseCommand {
62
57
 
63
58
  async addCustomProvider() {
64
59
  try {
65
- const answers = await this.promptWithESC([
66
- {
67
- type: 'list',
68
- name: 'ideName',
69
- message: '选择要管理的 IDE:',
70
- choices: [
71
- { name: 'Claude Code (Anthropic)', value: 'claude' },
72
- { name: 'Codex CLI (OpenAI)', value: 'codex' }
73
- ],
74
- default: this.presetIdeName || 'claude',
75
- when: () => !this.presetIdeName
76
- },
77
- {
78
- type: 'list',
79
- name: 'importFromExisting',
80
- message: '是否从现有 Codex 配置导入?',
81
- choices: [
82
- { name: '从 ~/.codex 导入现有配置', value: 'import' },
83
- { name: '手动输入配置', value: 'manual' }
84
- ],
85
- default: 'import',
86
- when: (answers) => (answers.ideName || this.presetIdeName) === 'codex'
87
- },
88
- {
89
- type: 'input',
90
- name: 'name',
91
- message: '请输入供应商名称:',
92
- validate: (input) => {
93
- const error = validator.validateName(input);
94
- if (error) return error;
95
- return true;
96
- }
97
- },
98
- {
99
- type: 'list',
100
- name: 'authMode',
101
- message: '选择认证模式:',
102
- choices: [
103
- { name: '🔑 ANTHROPIC_API_KEY - 大多数第三方代理使用', value: 'api_key' },
104
- { name: '🔐 ANTHROPIC_AUTH_TOKEN - 部分服务商使用', value: 'auth_token' }
105
- ],
106
- default: 'api_key',
107
- when: (answers) => (answers.ideName || this.presetIdeName) !== 'codex'
108
- },
109
- {
110
- type: 'input',
111
- name: 'baseUrl',
112
- message: '请输入 API 基础URL (ANTHROPIC_BASE_URL):',
113
- validate: (input) => {
114
- if (!input) return 'API 基础URL不能为空';
115
- const error = validator.validateUrl(input);
116
- if (error) return error;
117
- return true;
118
- },
119
- when: (answers) => (answers.ideName || this.presetIdeName) !== 'codex'
120
- },
121
- {
122
- type: 'input',
123
- name: 'authToken',
124
- message: (answers) => {
125
- const envVar = answers.authMode === 'auth_token' ? 'ANTHROPIC_AUTH_TOKEN' : 'ANTHROPIC_API_KEY';
126
- return `请输入 Token (${envVar}):`;
127
- },
128
- validate: (input) => {
129
- const error = validator.validateToken(input);
130
- if (error) return error;
131
- return true;
132
- },
133
- when: (answers) => (answers.ideName || this.presetIdeName) !== 'codex'
134
- },
135
- {
136
- type: 'input',
137
- name: 'baseUrl',
138
- message: '请输入 OpenAI API 基础URL (如使用官方API可留空):',
139
- default: '',
140
- validate: (input) => {
141
- if (!input) return true;
142
- const error = validator.validateUrl(input);
143
- if (error) return error;
144
- return true;
145
- },
146
- when: (answers) => (answers.ideName || this.presetIdeName) === 'codex' && answers.importFromExisting === 'manual'
147
- },
148
- {
149
- type: 'input',
150
- name: 'authToken',
151
- message: '请输入 OpenAI API Key (OPENAI_API_KEY):',
152
- validate: (input) => {
153
- if (!input) return 'API Key 不能为空';
154
- const error = validator.validateToken(input);
155
- if (error) return error;
156
- return true;
157
- },
158
- when: (answers) => (answers.ideName || this.presetIdeName) === 'codex' && answers.importFromExisting === 'manual'
159
- },
160
- {
161
- type: 'confirm',
162
- name: 'setAsDefault',
163
- message: '是否设置为当前供应商?',
164
- default: true
165
- },
166
- {
167
- type: 'confirm',
168
- name: 'configureLaunchArgs',
169
- message: '是否配置启动参数?',
170
- default: false,
171
- when: (answers) => (answers.ideName || this.presetIdeName) !== 'codex'
172
- },
173
- {
174
- type: 'confirm',
175
- name: 'configureCodexLaunchArgs',
176
- message: '是否配置 Codex 启动参数?',
177
- default: false,
178
- when: (answers) => (answers.ideName || this.presetIdeName) === 'codex'
179
- },
180
- {
181
- type: 'confirm',
182
- name: 'configureModels',
183
- message: '是否配置模型参数?',
184
- default: false,
185
- when: (answers) => (answers.ideName || this.presetIdeName) !== 'codex'
186
- }
187
- ], '取消添加', () => {
188
- Logger.info('取消添加供应商');
189
- // 使用CommandRegistry避免循环引用
190
- const { registry } = require('../CommandRegistry');
191
- registry.executeCommand('switch');
192
- });
60
+ const answers = await promptProviderInfo(this);
193
61
 
194
62
  // 如果是预设的 ideName,设置到 answers 中
195
63
  if (!answers.ideName && this.presetIdeName) {
@@ -200,91 +68,17 @@ class ProviderAdder extends BaseCommand {
200
68
  answers.authMode = 'openai_api_key';
201
69
  answers.codexFiles = null;
202
70
 
203
- // 从现有配置导入
204
- if (answers.importFromExisting === 'import') {
205
- const importedConfig = await this.importCodexConfig();
206
- if (importedConfig) {
207
- answers.authToken = importedConfig.apiKey;
208
- answers.baseUrl = importedConfig.baseUrl;
209
- } else {
210
- Logger.warning('未能导入现有配置,请手动输入');
211
- const manualAnswers = await this.prompt([
212
- {
213
- type: 'input',
214
- name: 'baseUrl',
215
- message: '请输入 OpenAI API 基础URL (如使用官方API可留空):',
216
- default: ''
217
- },
218
- {
219
- type: 'input',
220
- name: 'authToken',
221
- message: '请输入 OpenAI API Key (OPENAI_API_KEY):',
222
- validate: (input) => input ? true : 'API Key 不能为空'
223
- }
224
- ]);
225
- answers.authToken = manualAnswers.authToken;
226
- answers.baseUrl = manualAnswers.baseUrl;
227
- }
228
- }
229
-
230
71
  // Codex 启动参数配置
231
72
  if (answers.configureCodexLaunchArgs) {
232
- answers.launchArgs = await this.promptCodexLaunchArgsSelection();
233
- }
234
- }
235
-
236
- await this.saveProvider(answers);
237
- } catch (error) {
238
- if (this.isEscCancelled(error)) {
239
- return;
240
- }
241
- throw error;
242
- }
243
- }
244
-
245
- async saveProvider(answers) {
246
- try {
247
- await this.configManager.load();
248
-
249
- if (this.configManager.getProvider(answers.name)) {
250
- const shouldOverwrite = await this.confirmOverwrite(answers.name);
251
- if (!shouldOverwrite) {
252
- Logger.warning('操作已取消');
253
- return;
73
+ answers.launchArgs = await promptCodexLaunchArgs(this);
254
74
  }
255
75
  }
256
76
 
257
- const launchArgs = answers.ideName === 'codex'
258
- ? (Array.isArray(answers.launchArgs) ? answers.launchArgs : [])
259
- : (answers.configureLaunchArgs ? await this.promptLaunchArgsSelection() : []);
260
-
261
- const modelConfig = answers.configureModels
262
- ? await this.promptModelConfiguration()
263
- : { primaryModel: null, smallFastModel: null };
264
-
265
- await this.configManager.addProvider(answers.name, {
266
- displayName: answers.displayName || answers.name,
267
- ideName: answers.ideName || 'claude',
268
- baseUrl: answers.baseUrl,
269
- authToken: answers.authToken,
270
- authMode: answers.authMode,
271
- codexFiles: answers.codexFiles || null,
272
- launchArgs,
273
- primaryModel: modelConfig.primaryModel,
274
- smallFastModel: modelConfig.smallFastModel,
275
- setAsDefault: answers.setAsDefault
276
- });
277
-
278
- this.printProviderSummary(answers, launchArgs, modelConfig);
279
- await this.pauseBeforeReturn();
280
-
281
- const { registry } = require('../CommandRegistry');
282
- return await registry.executeCommand('switch');
77
+ await saveProvider(this, answers);
283
78
  } catch (error) {
284
79
  if (this.isEscCancelled(error)) {
285
80
  return;
286
81
  }
287
- Logger.error(`添加供应商失败: ${error.message}`);
288
82
  throw error;
289
83
  }
290
84
  }
@@ -300,8 +94,8 @@ class ProviderAdder extends BaseCommand {
300
94
  }
301
95
  ], '取消覆盖', () => {
302
96
  Logger.info('取消覆盖供应商');
303
- const { switchCommand } = require('./switch');
304
- switchCommand();
97
+ const { registry } = require('../CommandRegistry');
98
+ registry.executeCommand('switch');
305
99
  });
306
100
 
307
101
  return overwrite;
@@ -310,212 +104,6 @@ class ProviderAdder extends BaseCommand {
310
104
  }
311
105
  }
312
106
 
313
- async promptLaunchArgsSelection() {
314
- console.log(UIHelper.createTitle('配置启动参数', UIHelper.icons.settings));
315
- console.log();
316
- console.log(UIHelper.createTooltip('选择要使用的启动参数'));
317
- console.log();
318
- console.log(UIHelper.createStepIndicator(2, 2, '可选: 配置启动参数'));
319
- console.log(UIHelper.createHintLine([
320
- ['空格', '切换选中'],
321
- ['A', '全选'],
322
- ['I', '反选'],
323
- ['Enter', '确认选择'],
324
- ['ESC', '跳过配置']
325
- ]));
326
- console.log();
327
-
328
- const result = await this.promptWithESCAndDefault([
329
- {
330
- type: 'checkbox',
331
- name: 'launchArgs',
332
- message: '请选择启动参数:',
333
- choices: validator.getAvailableLaunchArgs().map(arg => ({
334
- name: `${arg.name} - ${arg.description}`,
335
- value: arg.name,
336
- checked: false
337
- }))
338
- }
339
- ], '跳过配置', () => {
340
- Logger.info('跳过启动参数配置');
341
- }, { launchArgs: [] });
342
-
343
- return result.launchArgs;
344
- }
345
-
346
- async promptModelConfiguration() {
347
- console.log(UIHelper.createTitle('配置模型参数', UIHelper.icons.settings));
348
- console.log();
349
- console.log(UIHelper.createTooltip('配置主模型和快速模型(可选)'));
350
- console.log();
351
- console.log(UIHelper.createStepIndicator(2, 2, '可选: 配置模型参数'));
352
- console.log(UIHelper.createHintLine([
353
- ['Enter', '确认输入'],
354
- ['ESC', '跳过配置']
355
- ]));
356
- console.log();
357
-
358
- const responses = await this.promptWithESCAndDefault([
359
- {
360
- type: 'input',
361
- name: 'primaryModel',
362
- message: '主模型 (ANTHROPIC_MODEL):',
363
- default: '',
364
- validate: (input) => {
365
- const error = validator.validateModel(input);
366
- if (error) return error;
367
- return true;
368
- }
369
- },
370
- {
371
- type: 'input',
372
- name: 'smallFastModel',
373
- message: '快速模型 (ANTHROPIC_SMALL_FAST_MODEL):',
374
- default: '',
375
- validate: (input) => {
376
- const error = validator.validateModel(input);
377
- if (error) return error;
378
- return true;
379
- }
380
- }
381
- ], '跳过配置', () => {
382
- Logger.info('跳过模型参数配置');
383
- }, { primaryModel: null, smallFastModel: null });
384
-
385
- return {
386
- primaryModel: responses.primaryModel,
387
- smallFastModel: responses.smallFastModel
388
- };
389
- }
390
-
391
- async importCodexConfig() {
392
- try {
393
- const { readCodexFiles, extractBaseUrlFromConfigToml } = require('../utils/codex-files');
394
- const codexFiles = await readCodexFiles();
395
-
396
- if (!codexFiles.authJson) {
397
- return null;
398
- }
399
-
400
- // 解析 auth.json 获取 API Key
401
- const authData = JSON.parse(codexFiles.authJson);
402
- const apiKey = authData.api_key || authData.openai_api_key || authData.OPENAI_API_KEY;
403
-
404
- if (!apiKey) {
405
- return null;
406
- }
407
-
408
- // 从 config.toml 中读取当前激活 provider 的 base_url
409
- // 优先从 [model_providers.<key>] section 读取,兼容旧的顶层 api_base_url 格式
410
- let baseUrl = null;
411
- if (codexFiles.configToml) {
412
- baseUrl = extractBaseUrlFromConfigToml(codexFiles.configToml);
413
- if (!baseUrl) {
414
- // 兼容旧格式(akm 之前错误写入的顶层字段)
415
- const legacyMatch = codexFiles.configToml.match(/^api_base_url\s*=\s*["']([^"']+)["']/m);
416
- if (legacyMatch) baseUrl = legacyMatch[1];
417
- }
418
- }
419
-
420
- Logger.success(`成功从 ${codexFiles.codexHome} 导入配置`);
421
- return { apiKey, baseUrl };
422
- } catch (error) {
423
- Logger.warning(`导入配置失败: ${error.message}`);
424
- return null;
425
- }
426
- }
427
-
428
- async promptCodexLaunchArgsSelection() {
429
- console.log(UIHelper.createTitle('配置 Codex 启动参数', UIHelper.icons.settings));
430
- console.log();
431
- console.log(UIHelper.createTooltip('选择要使用的 Codex 启动参数'));
432
- console.log();
433
- console.log(UIHelper.createHintLine([
434
- ['空格', '切换选中'],
435
- ['A', '全选'],
436
- ['I', '反选'],
437
- ['Enter', '确认选择'],
438
- ['ESC', '跳过配置']
439
- ]));
440
- console.log();
441
-
442
- try {
443
- const { getCodexLaunchArgs, checkExclusiveArgs } = require('../utils/launch-args');
444
- const codexArgs = getCodexLaunchArgs();
445
-
446
- const result = await this.promptWithESCAndDefault([
447
- {
448
- type: 'checkbox',
449
- name: 'launchArgs',
450
- message: '请选择 Codex 启动参数:',
451
- choices: codexArgs.map(arg => ({
452
- name: `${arg.label} (${arg.name}) - ${arg.description}`,
453
- value: arg.name,
454
- checked: arg.checked
455
- }))
456
- }
457
- ], '跳过配置', () => {
458
- Logger.info('跳过 Codex 启动参数配置');
459
- }, { launchArgs: [] });
460
-
461
- const { launchArgs } = result;
462
-
463
- const conflictError = checkExclusiveArgs(launchArgs, codexArgs);
464
- if (conflictError) {
465
- Logger.warning(conflictError);
466
- return await this.promptCodexLaunchArgsSelection();
467
- }
468
- return launchArgs;
469
- } catch (error) {
470
- throw error;
471
- }
472
- }
473
-
474
- printProviderSummary(answers, launchArgs, modelConfig) {
475
- const finalDisplayName = answers.displayName || answers.name;
476
- Logger.success(`供应商 '${finalDisplayName}' 添加成功!`);
477
-
478
- console.log(chalk.blue('\n配置详情:'));
479
- console.log(chalk.gray(` 名称: ${answers.name}`));
480
- console.log(chalk.gray(` 显示名称: ${finalDisplayName}`));
481
-
482
- if (answers.ideName === 'codex') {
483
- console.log(chalk.gray(' IDE: Codex CLI'));
484
- if (answers.baseUrl) {
485
- console.log(chalk.gray(` OPENAI_BASE_URL: ${answers.baseUrl}`));
486
- }
487
- if (answers.authToken) {
488
- console.log(chalk.gray(` OPENAI_API_KEY: ${answers.authToken}`));
489
- }
490
- if (answers.launchArgs && answers.launchArgs.length > 0) {
491
- console.log(chalk.gray(` 启动参数: ${answers.launchArgs.join(' ')}`));
492
- }
493
- console.log(chalk.green('\n🎉 供应商添加完成!正在返回主界面...'));
494
- return;
495
- }
496
-
497
- console.log(chalk.gray(` 认证模式: ${AUTH_MODE_DISPLAY_DETAILED[answers.authMode] || answers.authMode}`));
498
-
499
- if (answers.baseUrl) {
500
- console.log(chalk.gray(` 基础URL: ${answers.baseUrl}`));
501
- }
502
- console.log(chalk.gray(` Token: ${answers.authToken}`));
503
-
504
- if (launchArgs.length > 0) {
505
- console.log(chalk.gray(` 启动参数: ${launchArgs.join(' ')}`));
506
- }
507
-
508
- if (modelConfig.primaryModel) {
509
- console.log(chalk.gray(` 主模型: ${modelConfig.primaryModel}`));
510
- }
511
-
512
- if (modelConfig.smallFastModel) {
513
- console.log(chalk.gray(` 快速模型: ${modelConfig.smallFastModel}`));
514
- }
515
-
516
- console.log(chalk.green('\n🎉 供应商添加完成!正在返回主界面...'));
517
- }
518
-
519
107
  async pauseBeforeReturn(delay = 1500) {
520
108
  await new Promise(resolve => setTimeout(resolve, delay));
521
109
  }
@@ -101,7 +101,6 @@ class BackupManager {
101
101
  // 导入前自动备份当前配置
102
102
  await this.backup();
103
103
 
104
- const importedCount = Object.keys(importData.providers).length;
105
104
  let addedCount = 0;
106
105
  let skippedCount = 0;
107
106
 
@@ -7,7 +7,6 @@
7
7
  const chalk = require('chalk');
8
8
  const { configManager } = require('../config');
9
9
  const { Logger } = require('../utils/logger');
10
- const { UIHelper } = require('../utils/ui-helper');
11
10
  const inquirer = require('inquirer');
12
11
 
13
12
  /**
@@ -31,7 +30,7 @@ async function batchUpdate(options = {}) {
31
30
  return;
32
31
  }
33
32
 
34
- console.log(chalk.blue(`\n📦 批量更新供应商配置`));
33
+ console.log(chalk.blue('\n📦 批量更新供应商配置'));
35
34
  console.log(chalk.gray('═'.repeat(60)));
36
35
  console.log();
37
36
 
@@ -67,62 +66,62 @@ async function batchUpdate(options = {}) {
67
66
  for (const field of fields) {
68
67
  let answer;
69
68
  switch (field) {
70
- case 'baseUrl':
71
- answer = await inquirer.prompt([
72
- {
73
- type: 'input',
74
- name: 'value',
75
- message: '输入新的 Base URL (留空表示清除):',
76
- validate: (input) => {
77
- if (input && !input.startsWith('http://') && !input.startsWith('https://')) {
78
- return 'Base URL 必须以 http:// 或 https:// 开头';
79
- }
80
- return true;
69
+ case 'baseUrl':
70
+ answer = await inquirer.prompt([
71
+ {
72
+ type: 'input',
73
+ name: 'value',
74
+ message: '输入新的 Base URL (留空表示清除):',
75
+ validate: (input) => {
76
+ if (input && !input.startsWith('http://') && !input.startsWith('https://')) {
77
+ return 'Base URL 必须以 http:// 或 https:// 开头';
81
78
  }
79
+ return true;
82
80
  }
83
- ]);
84
- updates.baseUrl = answer.value || null;
85
- break;
86
-
87
- case 'tokenExpiry':
88
- answer = await inquirer.prompt([
89
- {
90
- type: 'input',
91
- name: 'value',
92
- message: '输入 Token 过期时间 (YYYY-MM-DD 格式, 留空表示清除):',
93
- validate: (input) => {
94
- if (input && !/^\d{4}-\d{2}-\d{2}$/.test(input)) {
95
- return '请使用 YYYY-MM-DD 格式';
96
- }
97
- return true;
81
+ }
82
+ ]);
83
+ updates.baseUrl = answer.value || null;
84
+ break;
85
+
86
+ case 'tokenExpiry':
87
+ answer = await inquirer.prompt([
88
+ {
89
+ type: 'input',
90
+ name: 'value',
91
+ message: '输入 Token 过期时间 (YYYY-MM-DD 格式, 留空表示清除):',
92
+ validate: (input) => {
93
+ if (input && !/^\d{4}-\d{2}-\d{2}$/.test(input)) {
94
+ return '请使用 YYYY-MM-DD 格式';
98
95
  }
96
+ return true;
99
97
  }
100
- ]);
101
- updates.tokenExpiry = answer.value ? new Date(answer.value).toISOString() : null;
102
- break;
103
-
104
- case 'quotaLimit':
105
- answer = await inquirer.prompt([
106
- {
107
- type: 'number',
108
- name: 'value',
109
- message: '输入配额限制 (数字, 0 表示清除):',
110
- default: 0
111
- }
112
- ]);
113
- updates.quota = answer.value > 0 ? { limit: answer.value } : null;
114
- break;
115
-
116
- case 'launchArgs':
117
- answer = await inquirer.prompt([
118
- {
119
- type: 'input',
120
- name: 'value',
121
- message: '输入启动参数 (空格分隔, 留空表示清除):',
122
- }
123
- ]);
124
- updates.launchArgs = answer.value ? answer.value.split(/\s+/).filter(Boolean) : [];
125
- break;
98
+ }
99
+ ]);
100
+ updates.tokenExpiry = answer.value ? new Date(answer.value).toISOString() : null;
101
+ break;
102
+
103
+ case 'quotaLimit':
104
+ answer = await inquirer.prompt([
105
+ {
106
+ type: 'number',
107
+ name: 'value',
108
+ message: '输入配额限制 (数字, 0 表示清除):',
109
+ default: 0
110
+ }
111
+ ]);
112
+ updates.quota = answer.value > 0 ? { limit: answer.value } : null;
113
+ break;
114
+
115
+ case 'launchArgs':
116
+ answer = await inquirer.prompt([
117
+ {
118
+ type: 'input',
119
+ name: 'value',
120
+ message: '输入启动参数 (空格分隔, 留空表示清除):'
121
+ }
122
+ ]);
123
+ updates.launchArgs = answer.value ? answer.value.split(/\s+/).filter(Boolean) : [];
124
+ break;
126
125
  }
127
126
  }
128
127
 
@@ -218,7 +217,7 @@ async function batchDelete(options = {}) {
218
217
  return;
219
218
  }
220
219
 
221
- console.log(chalk.blue(`\n🗑️ 批量删除供应商`));
220
+ console.log(chalk.blue('\n🗑️ 批量删除供应商'));
222
221
  console.log(chalk.gray('═'.repeat(60)));
223
222
  console.log();
224
223
 
@@ -247,11 +246,11 @@ async function batchDelete(options = {}) {
247
246
  }
248
247
 
249
248
  // 再次确认
250
- const { confirmAgain } = await inquirer.prompt([
249
+ await inquirer.prompt([
251
250
  {
252
251
  type: 'input',
253
252
  name: 'confirmAgain',
254
- message: `请输入 "DELETE" 以确认删除:`,
253
+ message: '请输入 "DELETE" 以确认删除:',
255
254
  validate: (input) => {
256
255
  if (input !== 'DELETE') {
257
256
  return '请输入 "DELETE" 以确认';
@@ -295,15 +294,15 @@ async function batchDelete(options = {}) {
295
294
  async function batchCommand(operation, options = {}) {
296
295
  try {
297
296
  switch (operation) {
298
- case 'update':
299
- await batchUpdate(options);
300
- break;
301
- case 'delete':
302
- await batchDelete(options);
303
- break;
304
- default:
305
- Logger.error(`未知的批量操作: ${operation}`);
306
- Logger.info('支持的操作: update, delete');
297
+ case 'update':
298
+ await batchUpdate(options);
299
+ break;
300
+ case 'delete':
301
+ await batchDelete(options);
302
+ break;
303
+ default:
304
+ Logger.error(`未知的批量操作: ${operation}`);
305
+ Logger.info('支持的操作: update, delete');
307
306
  }
308
307
  } catch (error) {
309
308
  Logger.error(`批量操作失败: ${error.message}`);