ccman 3.3.22 → 3.3.24

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 (2) hide show
  1. package/dist/index.js +149 -224
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -9,6 +9,33 @@ var __export = (target, all) => {
9
9
  __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
11
 
12
+ // ../core/dist/version.js
13
+ import { existsSync, readFileSync } from "fs";
14
+ import { dirname, join } from "path";
15
+ import { fileURLToPath } from "url";
16
+ function resolveVersionFromRuntimeDir(runtimeDir) {
17
+ const candidates = [join(runtimeDir, "../package.json"), join(runtimeDir, "../../package.json")];
18
+ for (const packageJsonPath of candidates) {
19
+ if (!existsSync(packageJsonPath)) {
20
+ continue;
21
+ }
22
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
23
+ if (typeof pkg.version === "string" && pkg.version.length > 0) {
24
+ return pkg.version;
25
+ }
26
+ }
27
+ throw new Error(`Unable to resolve package.json version from runtime dir: ${runtimeDir}`);
28
+ }
29
+ function loadVersion(moduleUrl = import.meta.url) {
30
+ const runtimeDir = dirname(fileURLToPath(moduleUrl));
31
+ return resolveVersionFromRuntimeDir(runtimeDir);
32
+ }
33
+ var init_version = __esm({
34
+ "../core/dist/version.js"() {
35
+ "use strict";
36
+ }
37
+ });
38
+
12
39
  // ../types/dist/index.js
13
40
  var TOOL_TYPES, MAIN_TOOL_TYPES, TOOL_CONFIG;
14
41
  var init_dist = __esm({
@@ -242,7 +269,7 @@ var init_template = __esm({
242
269
  // ../core/dist/writers/codex.js
243
270
  import * as fs2 from "fs";
244
271
  import * as path3 from "path";
245
- import { fileURLToPath } from "url";
272
+ import { fileURLToPath as fileURLToPath2 } from "url";
246
273
  import { parse as parseToml, stringify as stringifyToml } from "@iarna/toml";
247
274
  function resolveTemplatePath(relativePath) {
248
275
  const candidates = [
@@ -371,7 +398,7 @@ var init_codex = __esm({
371
398
  init_paths();
372
399
  init_file();
373
400
  init_template();
374
- __filename = fileURLToPath(import.meta.url);
401
+ __filename = fileURLToPath2(import.meta.url);
375
402
  __dirname = path3.dirname(__filename);
376
403
  CODEX_DEFAULT_CONFIG = {
377
404
  model: "gpt-5.4",
@@ -437,7 +464,7 @@ var init_codex = __esm({
437
464
  // ../core/dist/writers/claude.js
438
465
  import * as fs3 from "fs";
439
466
  import * as path4 from "path";
440
- import { fileURLToPath as fileURLToPath2 } from "url";
467
+ import { fileURLToPath as fileURLToPath3 } from "url";
441
468
  function resolveTemplatePath2(relativePath) {
442
469
  const candidates = [
443
470
  // @ccman/core runtime (dist/writers -> templates)
@@ -494,7 +521,7 @@ var init_claude = __esm({
494
521
  init_paths();
495
522
  init_file();
496
523
  init_template();
497
- __filename2 = fileURLToPath2(import.meta.url);
524
+ __filename2 = fileURLToPath3(import.meta.url);
498
525
  __dirname2 = path4.dirname(__filename2);
499
526
  CLAUDE_CONFIG_TEMPLATE = {
500
527
  env: {
@@ -834,7 +861,7 @@ var init_openclaw = __esm({
834
861
  // ../core/dist/writers/gemini.js
835
862
  import * as fs5 from "fs";
836
863
  import * as path6 from "path";
837
- import { fileURLToPath as fileURLToPath3 } from "url";
864
+ import { fileURLToPath as fileURLToPath4 } from "url";
838
865
  function resolveTemplatePath3(relativePath) {
839
866
  const candidates = [
840
867
  // @ccman/core runtime (dist/writers -> templates)
@@ -994,7 +1021,7 @@ var init_gemini2 = __esm({
994
1021
  init_paths();
995
1022
  init_file();
996
1023
  init_template();
997
- __filename3 = fileURLToPath3(import.meta.url);
1024
+ __filename3 = fileURLToPath4(import.meta.url);
998
1025
  __dirname3 = path6.dirname(__filename3);
999
1026
  GEMINI_SETTINGS_TEMPLATE = {
1000
1027
  ide: {
@@ -1017,7 +1044,7 @@ var init_gemini2 = __esm({
1017
1044
  // ../core/dist/writers/opencode.js
1018
1045
  import * as fs6 from "fs";
1019
1046
  import * as path7 from "path";
1020
- import { fileURLToPath as fileURLToPath4 } from "url";
1047
+ import { fileURLToPath as fileURLToPath5 } from "url";
1021
1048
  function resolveTemplatePath4(relativePath) {
1022
1049
  const candidates = [
1023
1050
  // @ccman/core runtime (dist/writers -> templates)
@@ -1151,7 +1178,7 @@ var init_opencode2 = __esm({
1151
1178
  OPENCODE_MODEL = "openai/gpt-5.4";
1152
1179
  OPENCODE_MODEL_KEY = "gpt-5.4";
1153
1180
  OPENCODE_SECONDARY_MODEL_KEY = "gpt-5.3-codex";
1154
- __filename4 = fileURLToPath4(import.meta.url);
1181
+ __filename4 = fileURLToPath5(import.meta.url);
1155
1182
  __dirname4 = path7.dirname(__filename4);
1156
1183
  DEFAULT_MODELS = {
1157
1184
  [OPENCODE_MODEL_KEY]: {
@@ -1210,7 +1237,7 @@ var init_opencode2 = __esm({
1210
1237
  // ../core/dist/writers/openclaw.js
1211
1238
  import * as fs7 from "fs";
1212
1239
  import * as path8 from "path";
1213
- import { fileURLToPath as fileURLToPath5 } from "url";
1240
+ import { fileURLToPath as fileURLToPath6 } from "url";
1214
1241
  function resolveTemplatePath5(relativePath) {
1215
1242
  const candidates = [
1216
1243
  // @ccman/core runtime (dist/writers -> templates)
@@ -1381,7 +1408,7 @@ var init_openclaw2 = __esm({
1381
1408
  SECONDARY_MODEL_ID = "gpt-5.3-codex";
1382
1409
  PRIMARY_MODEL_INPUTS = ["text", "image"];
1383
1410
  SECONDARY_MODEL_INPUTS = ["text", "image"];
1384
- __filename5 = fileURLToPath5(import.meta.url);
1411
+ __filename5 = fileURLToPath6(import.meta.url);
1385
1412
  __dirname5 = path8.dirname(__filename5);
1386
1413
  OPENCLAW_CONFIG_TEMPLATE = {
1387
1414
  models: {
@@ -2872,13 +2899,11 @@ var init_claude_clean = __esm({
2872
2899
  });
2873
2900
 
2874
2901
  // ../core/dist/index.js
2875
- import { readFileSync as readFileSync10 } from "fs";
2876
- import { join as join5, dirname as dirname7 } from "path";
2877
- import { fileURLToPath as fileURLToPath6 } from "url";
2878
- var __filename6, __dirname6, pkg, VERSION;
2902
+ var VERSION;
2879
2903
  var init_dist2 = __esm({
2880
2904
  "../core/dist/index.js"() {
2881
2905
  "use strict";
2906
+ init_version();
2882
2907
  init_constants();
2883
2908
  init_tool_manager();
2884
2909
  init_codex2();
@@ -2897,10 +2922,48 @@ var init_dist2 = __esm({
2897
2922
  init_merge_advanced();
2898
2923
  init_export();
2899
2924
  init_claude_clean();
2900
- __filename6 = fileURLToPath6(import.meta.url);
2901
- __dirname6 = dirname7(__filename6);
2902
- pkg = JSON.parse(readFileSync10(join5(__dirname6, "../../package.json"), "utf-8"));
2903
- VERSION = pkg.version;
2925
+ VERSION = loadVersion();
2926
+ }
2927
+ });
2928
+
2929
+ // src/utils/confirm.ts
2930
+ import inquirer from "inquirer";
2931
+ function parseConfirmAnswer(value, defaultValue) {
2932
+ const normalized = value.trim().toLowerCase();
2933
+ if (normalized === "") {
2934
+ return defaultValue;
2935
+ }
2936
+ if (normalized === "y") {
2937
+ return true;
2938
+ }
2939
+ if (normalized === "n") {
2940
+ return false;
2941
+ }
2942
+ throw new Error(`\u65E0\u6548\u7684\u786E\u8BA4\u8F93\u5165: ${value}`);
2943
+ }
2944
+ async function promptConfirm(message, defaultValue = false) {
2945
+ const { answer } = await inquirer.prompt([
2946
+ {
2947
+ type: "input",
2948
+ name: "answer",
2949
+ message: `${message} (Y(y) / N(n))`,
2950
+ filter: (value) => value.trim(),
2951
+ validate: (value) => {
2952
+ if (value === "") {
2953
+ return true;
2954
+ }
2955
+ if (/^(y|n)$/i.test(value)) {
2956
+ return true;
2957
+ }
2958
+ return "\u8BF7\u8F93\u5165 Y \u6216 N";
2959
+ }
2960
+ }
2961
+ ]);
2962
+ return parseConfirmAnswer(answer, defaultValue);
2963
+ }
2964
+ var init_confirm = __esm({
2965
+ "src/utils/confirm.ts"() {
2966
+ "use strict";
2904
2967
  }
2905
2968
  });
2906
2969
 
@@ -2943,7 +3006,7 @@ __export(config_exports, {
2943
3006
  configCommand: () => configCommand
2944
3007
  });
2945
3008
  import chalk3 from "chalk";
2946
- import inquirer from "inquirer";
3009
+ import inquirer2 from "inquirer";
2947
3010
  function configCommand(program2) {
2948
3011
  program2.command("config").description("\u914D\u7F6E WebDAV \u8FDE\u63A5").action(async () => {
2949
3012
  try {
@@ -2953,7 +3016,7 @@ function configCommand(program2) {
2953
3016
  console.log(chalk3.blue("\u2139\uFE0F \u68C0\u6D4B\u5230\u5DF2\u6709\u914D\u7F6E\uFF0C\u53EF\u4EE5\u66F4\u65B0 WebDAV \u5B57\u6BB5"));
2954
3017
  console.log(chalk3.gray(" \u7559\u7A7A\u8868\u793A\u4E0D\u66F4\u65B0\u8BE5\u5B57\u6BB5\n"));
2955
3018
  }
2956
- const answers = await inquirer.prompt([
3019
+ const answers = await inquirer2.prompt([
2957
3020
  {
2958
3021
  type: "input",
2959
3022
  name: "webdavUrl",
@@ -3004,14 +3067,12 @@ function configCommand(program2) {
3004
3067
  name: "syncPassword",
3005
3068
  message: existingConfig ? "\u540C\u6B65\u5BC6\u7801\uFF08\u7528\u4E8E\u52A0\u5BC6 API Key\uFF0C\u7559\u7A7A\u4E0D\u66F4\u65B0\uFF09:" : "\u540C\u6B65\u5BC6\u7801\uFF08\u7528\u4E8E\u52A0\u5BC6 API Key\uFF09:",
3006
3069
  mask: "*"
3007
- },
3008
- {
3009
- type: "confirm",
3010
- name: "rememberSyncPassword",
3011
- message: "\u8BB0\u4F4F\u540C\u6B65\u5BC6\u7801?",
3012
- default: existingConfig?.rememberSyncPassword ?? true
3013
3070
  }
3014
3071
  ]);
3072
+ const rememberSyncPassword = await promptConfirm(
3073
+ "\u8BB0\u4F4F\u540C\u6B65\u5BC6\u7801?",
3074
+ existingConfig?.rememberSyncPassword ?? true
3075
+ );
3015
3076
  const trimmedAnswers = {
3016
3077
  webdavUrl: answers.webdavUrl?.trim(),
3017
3078
  username: answers.username?.trim(),
@@ -3019,7 +3080,7 @@ function configCommand(program2) {
3019
3080
  authType: answers.authType,
3020
3081
  remoteDir: answers.remoteDir?.trim(),
3021
3082
  syncPassword: answers.syncPassword?.trim(),
3022
- rememberSyncPassword: answers.rememberSyncPassword
3083
+ rememberSyncPassword
3023
3084
  };
3024
3085
  if (existingConfig) {
3025
3086
  const hasTextInput = trimmedAnswers.webdavUrl || trimmedAnswers.username || trimmedAnswers.password || trimmedAnswers.remoteDir || trimmedAnswers.syncPassword;
@@ -3101,14 +3162,7 @@ function configCommand(program2) {
3101
3162
  console.log();
3102
3163
  console.log(chalk3.gray("\u914D\u7F6E\u6587\u4EF6:"), getSyncConfigPath());
3103
3164
  console.log();
3104
- const { testNow } = await inquirer.prompt([
3105
- {
3106
- type: "confirm",
3107
- name: "testNow",
3108
- message: "\u662F\u5426\u7ACB\u5373\u6D4B\u8BD5\u8FDE\u63A5?",
3109
- default: true
3110
- }
3111
- ]);
3165
+ const testNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u6D4B\u8BD5\u8FDE\u63A5?", true);
3112
3166
  if (testNow) {
3113
3167
  console.log(chalk3.bold("\n\u{1F50D} \u6D4B\u8BD5 WebDAV \u8FDE\u63A5...\n"));
3114
3168
  const success = await testWebDAVConnection(newConfig);
@@ -3142,11 +3196,11 @@ var init_config2 = __esm({
3142
3196
  "use strict";
3143
3197
  init_sync_config();
3144
3198
  init_dist2();
3199
+ init_confirm();
3145
3200
  }
3146
3201
  });
3147
3202
 
3148
3203
  // src/commands/sync/helpers.ts
3149
- import inquirer2 from "inquirer";
3150
3204
  import chalk4 from "chalk";
3151
3205
  import { Command } from "commander";
3152
3206
  async function ensureConfigExists() {
@@ -3155,14 +3209,7 @@ async function ensureConfigExists() {
3155
3209
  return config;
3156
3210
  }
3157
3211
  console.log(chalk4.yellow("\n\u26A0\uFE0F \u672A\u627E\u5230 WebDAV \u914D\u7F6E\n"));
3158
- const { shouldConfig } = await inquirer2.prompt([
3159
- {
3160
- type: "confirm",
3161
- name: "shouldConfig",
3162
- message: "\u662F\u5426\u73B0\u5728\u914D\u7F6E WebDAV?",
3163
- default: true
3164
- }
3165
- ]);
3212
+ const shouldConfig = await promptConfirm("\u662F\u5426\u73B0\u5728\u914D\u7F6E WebDAV?", true);
3166
3213
  if (!shouldConfig) {
3167
3214
  return null;
3168
3215
  }
@@ -3176,6 +3223,7 @@ var init_helpers = __esm({
3176
3223
  "src/commands/sync/helpers.ts"() {
3177
3224
  "use strict";
3178
3225
  init_sync_config();
3226
+ init_confirm();
3179
3227
  }
3180
3228
  });
3181
3229
 
@@ -3272,14 +3320,7 @@ function uploadCommand(program2) {
3272
3320
  console.log();
3273
3321
  console.log(chalk6.yellow("\u26A0\uFE0F \u4E91\u7AEF\u73B0\u6709\u914D\u7F6E\u5C06\u88AB\u8986\u76D6"));
3274
3322
  console.log();
3275
- const { confirm } = await inquirer3.prompt([
3276
- {
3277
- type: "confirm",
3278
- name: "confirm",
3279
- message: "\u786E\u8BA4\u4E0A\u4F20?",
3280
- default: false
3281
- }
3282
- ]);
3323
+ const confirm = await promptConfirm("\u786E\u8BA4\u4E0A\u4F20?", false);
3283
3324
  if (!confirm) {
3284
3325
  console.log(chalk6.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
3285
3326
  return;
@@ -3310,6 +3351,7 @@ var init_upload = __esm({
3310
3351
  "use strict";
3311
3352
  init_dist2();
3312
3353
  init_helpers();
3354
+ init_confirm();
3313
3355
  }
3314
3356
  });
3315
3357
 
@@ -3344,14 +3386,7 @@ function downloadCommand(program2) {
3344
3386
  console.log(chalk7.bold("\n\u{1F4E5} \u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u914D\u7F6E\n"));
3345
3387
  console.log(chalk7.yellow("\u26A0\uFE0F \u5C06\u8986\u76D6\u672C\u5730\u914D\u7F6E\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
3346
3388
  console.log();
3347
- const { confirm } = await inquirer4.prompt([
3348
- {
3349
- type: "confirm",
3350
- name: "confirm",
3351
- message: "\u786E\u8BA4\u4E0B\u8F7D?",
3352
- default: false
3353
- }
3354
- ]);
3389
+ const confirm = await promptConfirm("\u786E\u8BA4\u4E0B\u8F7D?", false);
3355
3390
  if (!confirm) {
3356
3391
  console.log(chalk7.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
3357
3392
  return;
@@ -3384,6 +3419,7 @@ var init_download = __esm({
3384
3419
  "use strict";
3385
3420
  init_dist2();
3386
3421
  init_helpers();
3422
+ init_confirm();
3387
3423
  }
3388
3424
  });
3389
3425
 
@@ -3690,6 +3726,7 @@ function formatProviderTable(providers, currentId) {
3690
3726
  }
3691
3727
 
3692
3728
  // src/interactive.ts
3729
+ init_confirm();
3693
3730
  var CLI_TOOL_CONFIG = {
3694
3731
  [TOOL_TYPES.CODEX]: { name: "Codex", emoji: "\u{1F536}", cmd: "cx" },
3695
3732
  [TOOL_TYPES.CLAUDE]: { name: "Claude", emoji: "\u{1F537}", cmd: "cc" },
@@ -3972,14 +4009,7 @@ async function handleAdd(tool) {
3972
4009
  console.log(` ${chalk11.bold(provider.name)} ${chalk11.blue(`[${toolName}]`)}`);
3973
4010
  console.log(` ${chalk11.gray(provider.baseUrl)}`);
3974
4011
  console.log();
3975
- const { switchNow } = await inquirer7.prompt([
3976
- {
3977
- type: "confirm",
3978
- name: "switchNow",
3979
- message: "\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?",
3980
- default: true
3981
- }
3982
- ]);
4012
+ const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
3983
4013
  if (switchNow) {
3984
4014
  manager.switch(provider.id);
3985
4015
  console.log(chalk11.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546\n"));
@@ -4176,14 +4206,7 @@ async function handleRemove(tool) {
4176
4206
  }
4177
4207
  ]);
4178
4208
  const provider = providers.find((p) => p.id === providerId);
4179
- const { confirm } = await inquirer7.prompt([
4180
- {
4181
- type: "confirm",
4182
- name: "confirm",
4183
- message: `\u786E\u5B9A\u8981\u5220\u9664 "${provider.name}" \u5417?`,
4184
- default: false
4185
- }
4186
- ]);
4209
+ const confirm = await promptConfirm(`\u786E\u5B9A\u8981\u5220\u9664 "${provider.name}" \u5417?`, false);
4187
4210
  if (confirm) {
4188
4211
  manager.remove(providerId);
4189
4212
  console.log(chalk11.green(`
@@ -4195,6 +4218,7 @@ async function handleRemove(tool) {
4195
4218
  }
4196
4219
 
4197
4220
  // src/commands/codex/add.ts
4221
+ init_confirm();
4198
4222
  function addCommand(program2) {
4199
4223
  program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Codex \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
4200
4224
  try {
@@ -4287,14 +4311,7 @@ function addCommand(program2) {
4287
4311
  console.log(` ${chalk12.bold(provider.name)} ${chalk12.blue("[Codex]")}`);
4288
4312
  console.log(` ${chalk12.gray(provider.baseUrl)}`);
4289
4313
  console.log();
4290
- const { switchNow } = await inquirer8.prompt([
4291
- {
4292
- type: "confirm",
4293
- name: "switchNow",
4294
- message: "\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?",
4295
- default: true
4296
- }
4297
- ]);
4314
+ const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
4298
4315
  if (switchNow) {
4299
4316
  manager.switch(provider.id);
4300
4317
  console.log(chalk12.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
@@ -4436,6 +4453,7 @@ function currentCommand(program2) {
4436
4453
 
4437
4454
  // src/commands/codex/remove.ts
4438
4455
  init_dist2();
4456
+ init_confirm();
4439
4457
  import chalk16 from "chalk";
4440
4458
  import inquirer10 from "inquirer";
4441
4459
  function removeCommand(program2) {
@@ -4472,14 +4490,7 @@ function removeCommand(program2) {
4472
4490
  targetId = selectedId;
4473
4491
  targetName = provider.name;
4474
4492
  }
4475
- const { confirmed } = await inquirer10.prompt([
4476
- {
4477
- type: "confirm",
4478
- name: "confirmed",
4479
- message: `\u786E\u5B9A\u5220\u9664 "${targetName}"?`,
4480
- default: false
4481
- }
4482
- ]);
4493
+ const confirmed = await promptConfirm(`\u786E\u5B9A\u5220\u9664 "${targetName}"?`, false);
4483
4494
  if (!confirmed) {
4484
4495
  console.log(chalk16.gray("\n\u5DF2\u53D6\u6D88\n"));
4485
4496
  return;
@@ -4674,6 +4685,7 @@ function createCodexCommands(program2) {
4674
4685
  init_dist2();
4675
4686
  import chalk19 from "chalk";
4676
4687
  import inquirer13 from "inquirer";
4688
+ init_confirm();
4677
4689
  function addCommand2(program2) {
4678
4690
  program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Claude Code \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
4679
4691
  try {
@@ -4766,14 +4778,7 @@ function addCommand2(program2) {
4766
4778
  console.log(` ${chalk19.bold(provider.name)} ${chalk19.blue("[Claude Code]")}`);
4767
4779
  console.log(` ${chalk19.gray(provider.baseUrl)}`);
4768
4780
  console.log();
4769
- const { switchNow } = await inquirer13.prompt([
4770
- {
4771
- type: "confirm",
4772
- name: "switchNow",
4773
- message: "\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?",
4774
- default: true
4775
- }
4776
- ]);
4781
+ const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
4777
4782
  if (switchNow) {
4778
4783
  manager.switch(provider.id);
4779
4784
  console.log(chalk19.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
@@ -4913,6 +4918,7 @@ function currentCommand2(program2) {
4913
4918
 
4914
4919
  // src/commands/claude/remove.ts
4915
4920
  init_dist2();
4921
+ init_confirm();
4916
4922
  import chalk23 from "chalk";
4917
4923
  import inquirer15 from "inquirer";
4918
4924
  function removeCommand2(program2) {
@@ -4949,14 +4955,7 @@ function removeCommand2(program2) {
4949
4955
  targetId = selectedId;
4950
4956
  targetName = provider.name;
4951
4957
  }
4952
- const { confirmed } = await inquirer15.prompt([
4953
- {
4954
- type: "confirm",
4955
- name: "confirmed",
4956
- message: `\u786E\u5B9A\u5220\u9664 "${targetName}"?`,
4957
- default: false
4958
- }
4959
- ]);
4958
+ const confirmed = await promptConfirm(`\u786E\u5B9A\u5220\u9664 "${targetName}"?`, false);
4960
4959
  if (!confirmed) {
4961
4960
  console.log(chalk23.gray("\n\u5DF2\u53D6\u6D88\n"));
4962
4961
  return;
@@ -5138,6 +5137,7 @@ function cloneCommand2(program2) {
5138
5137
 
5139
5138
  // src/commands/clean.ts
5140
5139
  init_dist2();
5140
+ init_confirm();
5141
5141
  import chalk26 from "chalk";
5142
5142
  import inquirer18 from "inquirer";
5143
5143
  function formatBytes2(bytes) {
@@ -5195,14 +5195,7 @@ function cleanCommand(program2) {
5195
5195
  } else {
5196
5196
  cleanOptions = await promptForOptions(analysis);
5197
5197
  }
5198
- const { confirmed } = await inquirer18.prompt([
5199
- {
5200
- type: "confirm",
5201
- name: "confirmed",
5202
- message: "\u786E\u8BA4\u6267\u884C\u6E05\u7406\uFF1F\uFF08\u4F1A\u81EA\u52A8\u5907\u4EFD\u539F\u6587\u4EF6\uFF09",
5203
- default: true
5204
- }
5205
- ]);
5198
+ const confirmed = await promptConfirm("\u786E\u8BA4\u6267\u884C\u6E05\u7406\uFF1F\uFF08\u4F1A\u81EA\u52A8\u5907\u4EFD\u539F\u6587\u4EF6\uFF09", true);
5206
5199
  if (!confirmed) {
5207
5200
  console.log(chalk26.yellow("\n\u274C \u5DF2\u53D6\u6D88\n"));
5208
5201
  return;
@@ -5305,38 +5298,26 @@ async function promptForOptions(analysis) {
5305
5298
  return CleanPresets.aggressive();
5306
5299
  }
5307
5300
  }
5308
- const customAnswers = await inquirer18.prompt([
5309
- {
5310
- type: "confirm",
5311
- name: "cleanHistory",
5312
- message: "\u6E05\u7406\u9879\u76EE\u5386\u53F2\u8BB0\u5F55\uFF1F",
5313
- default: true
5314
- },
5315
- {
5316
- type: "number",
5317
- name: "keepCount",
5318
- message: "\u6BCF\u4E2A\u9879\u76EE\u4FDD\u7559\u6700\u8FD1\u591A\u5C11\u6761\u8BB0\u5F55\uFF1F",
5319
- default: 10,
5320
- when: (answers2) => answers2.cleanHistory
5321
- },
5322
- {
5323
- type: "confirm",
5324
- name: "cleanCache",
5325
- message: "\u6E05\u7406\u7F13\u5B58\u6570\u636E\uFF1F",
5326
- default: true
5327
- },
5328
- {
5329
- type: "confirm",
5330
- name: "cleanStats",
5331
- message: "\u91CD\u7F6E\u4F7F\u7528\u7EDF\u8BA1\uFF1F",
5332
- default: false
5333
- }
5334
- ]);
5301
+ const cleanHistory = await promptConfirm("\u6E05\u7406\u9879\u76EE\u5386\u53F2\u8BB0\u5F55\uFF1F", true);
5302
+ let keepCount = 10;
5303
+ if (cleanHistory) {
5304
+ const answers2 = await inquirer18.prompt([
5305
+ {
5306
+ type: "number",
5307
+ name: "keepCount",
5308
+ message: "\u6BCF\u4E2A\u9879\u76EE\u4FDD\u7559\u6700\u8FD1\u591A\u5C11\u6761\u8BB0\u5F55\uFF1F",
5309
+ default: 10
5310
+ }
5311
+ ]);
5312
+ keepCount = answers2.keepCount;
5313
+ }
5314
+ const cleanCache = await promptConfirm("\u6E05\u7406\u7F13\u5B58\u6570\u636E\uFF1F", true);
5315
+ const cleanStats = await promptConfirm("\u91CD\u7F6E\u4F7F\u7528\u7EDF\u8BA1\uFF1F", false);
5335
5316
  return {
5336
- cleanProjectHistory: customAnswers.cleanHistory,
5337
- keepRecentCount: customAnswers.keepCount || 0,
5338
- cleanCache: customAnswers.cleanCache,
5339
- cleanStats: customAnswers.cleanStats
5317
+ cleanProjectHistory: cleanHistory,
5318
+ keepRecentCount: cleanHistory ? keepCount || 0 : 0,
5319
+ cleanCache,
5320
+ cleanStats
5340
5321
  };
5341
5322
  }
5342
5323
 
@@ -5562,6 +5543,7 @@ function listCommand3(program2) {
5562
5543
 
5563
5544
  // src/commands/mcp/remove.ts
5564
5545
  init_dist2();
5546
+ init_confirm();
5565
5547
  import chalk29 from "chalk";
5566
5548
  import inquirer20 from "inquirer";
5567
5549
  function removeCommand3(program2) {
@@ -5598,14 +5580,7 @@ function removeCommand3(program2) {
5598
5580
  targetId = selectedId;
5599
5581
  targetName = provider.name;
5600
5582
  }
5601
- const { confirmed } = await inquirer20.prompt([
5602
- {
5603
- type: "confirm",
5604
- name: "confirmed",
5605
- message: `\u786E\u5B9A\u5220\u9664 "${targetName}"?`,
5606
- default: false
5607
- }
5608
- ]);
5583
+ const confirmed = await promptConfirm(`\u786E\u5B9A\u5220\u9664 "${targetName}"?`, false);
5609
5584
  if (!confirmed) {
5610
5585
  console.log(chalk29.gray("\n\u5DF2\u53D6\u6D88\n"));
5611
5586
  return;
@@ -5758,6 +5733,7 @@ function createMCPCommands(program2) {
5758
5733
  init_dist2();
5759
5734
  import chalk31 from "chalk";
5760
5735
  import inquirer22 from "inquirer";
5736
+ init_confirm();
5761
5737
  function addCommand4(program2) {
5762
5738
  program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Gemini CLI \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
5763
5739
  try {
@@ -5846,14 +5822,7 @@ function addCommand4(program2) {
5846
5822
  console.log(` ${chalk31.bold(provider.name)} ${chalk31.blue("[Gemini CLI]")}`);
5847
5823
  console.log(` ${chalk31.gray(provider.baseUrl || "(\u4F7F\u7528\u9ED8\u8BA4\u7AEF\u70B9)")}`);
5848
5824
  console.log();
5849
- const { switchNow } = await inquirer22.prompt([
5850
- {
5851
- type: "confirm",
5852
- name: "switchNow",
5853
- message: "\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?",
5854
- default: true
5855
- }
5856
- ]);
5825
+ const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
5857
5826
  if (switchNow) {
5858
5827
  manager.switch(provider.id);
5859
5828
  console.log(chalk31.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
@@ -5990,6 +5959,7 @@ function currentCommand3(program2) {
5990
5959
 
5991
5960
  // src/commands/gemini/remove.ts
5992
5961
  init_dist2();
5962
+ init_confirm();
5993
5963
  import chalk35 from "chalk";
5994
5964
  import inquirer24 from "inquirer";
5995
5965
  function removeCommand4(program2) {
@@ -6030,14 +6000,7 @@ function removeCommand4(program2) {
6030
6000
  targetId = provider.id;
6031
6001
  targetName = provider.name;
6032
6002
  }
6033
- const { confirm } = await inquirer24.prompt([
6034
- {
6035
- type: "confirm",
6036
- name: "confirm",
6037
- message: `\u786E\u5B9A\u8981\u5220\u9664\u670D\u52A1\u5546 "${targetName}" \u5417\uFF1F`,
6038
- default: false
6039
- }
6040
- ]);
6003
+ const confirm = await promptConfirm(`\u786E\u5B9A\u8981\u5220\u9664\u670D\u52A1\u5546 "${targetName}" \u5417\uFF1F`, false);
6041
6004
  if (!confirm) {
6042
6005
  console.log(chalk35.gray("\n\u5DF2\u53D6\u6D88\u5220\u9664\n"));
6043
6006
  return;
@@ -6194,6 +6157,7 @@ function createGeminiCommands(program2) {
6194
6157
  init_dist2();
6195
6158
  import chalk38 from "chalk";
6196
6159
  import inquirer27 from "inquirer";
6160
+ init_confirm();
6197
6161
  function addCommand5(program2) {
6198
6162
  program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 OpenCode \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
6199
6163
  try {
@@ -6285,14 +6249,7 @@ function addCommand5(program2) {
6285
6249
  console.log(` ${chalk38.bold(provider.name)} ${chalk38.blue("[OpenCode]")}`);
6286
6250
  console.log(` ${chalk38.gray(provider.baseUrl)}`);
6287
6251
  console.log();
6288
- const { switchNow } = await inquirer27.prompt([
6289
- {
6290
- type: "confirm",
6291
- name: "switchNow",
6292
- message: "\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?",
6293
- default: true
6294
- }
6295
- ]);
6252
+ const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
6296
6253
  if (switchNow) {
6297
6254
  manager.switch(provider.id);
6298
6255
  console.log(chalk38.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
@@ -6487,6 +6444,7 @@ function editCommand5(program2) {
6487
6444
 
6488
6445
  // src/commands/opencode/remove.ts
6489
6446
  init_dist2();
6447
+ init_confirm();
6490
6448
  import chalk43 from "chalk";
6491
6449
  import inquirer30 from "inquirer";
6492
6450
  function removeCommand5(program2) {
@@ -6523,14 +6481,7 @@ function removeCommand5(program2) {
6523
6481
  targetId = selectedId;
6524
6482
  targetName = provider.name;
6525
6483
  }
6526
- const { confirmed } = await inquirer30.prompt([
6527
- {
6528
- type: "confirm",
6529
- name: "confirmed",
6530
- message: `\u786E\u5B9A\u5220\u9664 "${targetName}"?`,
6531
- default: false
6532
- }
6533
- ]);
6484
+ const confirmed = await promptConfirm(`\u786E\u5B9A\u5220\u9664 "${targetName}"?`, false);
6534
6485
  if (!confirmed) {
6535
6486
  console.log(chalk43.gray("\n\u5DF2\u53D6\u6D88\n"));
6536
6487
  return;
@@ -6640,6 +6591,7 @@ function createOpenCodeCommands(program2) {
6640
6591
  init_dist2();
6641
6592
  import chalk45 from "chalk";
6642
6593
  import inquirer32 from "inquirer";
6594
+ init_confirm();
6643
6595
  function addCommand6(program2) {
6644
6596
  program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 OpenClaw \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
6645
6597
  try {
@@ -6731,14 +6683,7 @@ function addCommand6(program2) {
6731
6683
  console.log(` ${chalk45.bold(provider.name)} ${chalk45.blue("[OpenClaw]")}`);
6732
6684
  console.log(` ${chalk45.gray(provider.baseUrl)}`);
6733
6685
  console.log();
6734
- const { switchNow } = await inquirer32.prompt([
6735
- {
6736
- type: "confirm",
6737
- name: "switchNow",
6738
- message: "\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?",
6739
- default: true
6740
- }
6741
- ]);
6686
+ const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
6742
6687
  if (switchNow) {
6743
6688
  manager.switch(provider.id);
6744
6689
  console.log(chalk45.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
@@ -6937,6 +6882,7 @@ function editCommand6(program2) {
6937
6882
 
6938
6883
  // src/commands/openclaw/remove.ts
6939
6884
  init_dist2();
6885
+ init_confirm();
6940
6886
  import chalk50 from "chalk";
6941
6887
  import inquirer35 from "inquirer";
6942
6888
  function removeCommand6(program2) {
@@ -6973,14 +6919,7 @@ function removeCommand6(program2) {
6973
6919
  targetId = selectedId;
6974
6920
  targetName = provider.name;
6975
6921
  }
6976
- const { confirmed } = await inquirer35.prompt([
6977
- {
6978
- type: "confirm",
6979
- name: "confirmed",
6980
- message: `\u786E\u5B9A\u5220\u9664 "${targetName}"?`,
6981
- default: false
6982
- }
6983
- ]);
6922
+ const confirmed = await promptConfirm(`\u786E\u5B9A\u5220\u9664 "${targetName}"?`, false);
6984
6923
  if (!confirmed) {
6985
6924
  console.log(chalk50.gray("\n\u5DF2\u53D6\u6D88\n"));
6986
6925
  return;
@@ -7134,8 +7073,8 @@ function exportCommand(program2) {
7134
7073
 
7135
7074
  // src/commands/import.ts
7136
7075
  init_dist2();
7076
+ init_confirm();
7137
7077
  import chalk53 from "chalk";
7138
- import inquirer37 from "inquirer";
7139
7078
  import path14 from "path";
7140
7079
  function importCommand(program2) {
7141
7080
  program2.command("import <\u6E90\u76EE\u5F55>").description("\u4ECE\u672C\u5730\u76EE\u5F55\u5BFC\u5165\u914D\u7F6E\uFF08\u4F1A\u8986\u76D6\u5F53\u524D\u914D\u7F6E\uFF09").action(async (sourceDir) => {
@@ -7160,14 +7099,7 @@ function importCommand(program2) {
7160
7099
  console.log();
7161
7100
  console.log(chalk53.gray("\u5F53\u524D\u914D\u7F6E\u5C06\u88AB\u8986\u76D6\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
7162
7101
  console.log();
7163
- const { confirmFirst } = await inquirer37.prompt([
7164
- {
7165
- type: "confirm",
7166
- name: "confirmFirst",
7167
- message: "\u786E\u8BA4\u5BFC\u5165\uFF1F",
7168
- default: false
7169
- }
7170
- ]);
7102
+ const confirmFirst = await promptConfirm("\u786E\u8BA4\u5BFC\u5165\uFF1F", false);
7171
7103
  if (!confirmFirst) {
7172
7104
  console.log(chalk53.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
7173
7105
  return;
@@ -7175,14 +7107,7 @@ function importCommand(program2) {
7175
7107
  console.log();
7176
7108
  console.log(chalk53.red.bold("\u26A0\uFE0F \u6700\u540E\u786E\u8BA4\uFF1A\u6B64\u64CD\u4F5C\u5C06\u8986\u76D6\u6240\u6709\u5F53\u524D\u914D\u7F6E\uFF01"));
7177
7109
  console.log();
7178
- const { confirmSecond } = await inquirer37.prompt([
7179
- {
7180
- type: "confirm",
7181
- name: "confirmSecond",
7182
- message: "\u771F\u7684\u8981\u7EE7\u7EED\u5417\uFF1F",
7183
- default: false
7184
- }
7185
- ]);
7110
+ const confirmSecond = await promptConfirm("\u771F\u7684\u8981\u7EE7\u7EED\u5417\uFF1F", false);
7186
7111
  if (!confirmSecond) {
7187
7112
  console.log(chalk53.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
7188
7113
  return;
@@ -7221,7 +7146,7 @@ init_dist2();
7221
7146
  import fs13 from "fs";
7222
7147
  import path15 from "path";
7223
7148
  import chalk54 from "chalk";
7224
- import inquirer38 from "inquirer";
7149
+ import inquirer37 from "inquirer";
7225
7150
 
7226
7151
  // src/utils/endpoint-latency.ts
7227
7152
  import { request as httpRequest } from "http";
@@ -7472,7 +7397,7 @@ function parsePlatforms(platformArg) {
7472
7397
  return platforms;
7473
7398
  }
7474
7399
  async function promptApiKey(title) {
7475
- const answers = await inquirer38.prompt([
7400
+ const answers = await inquirer37.prompt([
7476
7401
  {
7477
7402
  type: "password",
7478
7403
  name: "apiKey",
@@ -7487,7 +7412,7 @@ async function promptApiKey(title) {
7487
7412
  return answers.apiKey.trim();
7488
7413
  }
7489
7414
  async function promptPlatforms(title) {
7490
- const answers = await inquirer38.prompt([
7415
+ const answers = await inquirer37.prompt([
7491
7416
  {
7492
7417
  type: "checkbox",
7493
7418
  name: "platforms",
@@ -7582,7 +7507,7 @@ async function resolveOpenAiBaseUrl(profile, platforms, baseUrlArg) {
7582
7507
  console.log(chalk54.yellow(`\u975E\u4EA4\u4E92\u73AF\u5883\uFF0C\u5DF2\u81EA\u52A8\u4F7F\u7528\u9ED8\u8BA4\u5730\u5740\uFF1A${defaultResult.url}`));
7583
7508
  return defaultResult.url;
7584
7509
  }
7585
- const answers = await inquirer38.prompt([
7510
+ const answers = await inquirer37.prompt([
7586
7511
  {
7587
7512
  type: "list",
7588
7513
  name: "baseUrl",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccman",
3
- "version": "3.3.22",
3
+ "version": "3.3.24",
4
4
  "type": "module",
5
5
  "description": "Manage Codex, Claude Code, Gemini CLI, OpenCode, OpenClaw, and MCP API service provider configurations",
6
6
  "main": "./dist/index.js",
@@ -14,6 +14,7 @@
14
14
  "scripts": {
15
15
  "build": "tsup",
16
16
  "dev": "NODE_ENV=development tsx src/index.ts",
17
+ "test": "tsx --test src/utils/*.test.ts",
17
18
  "clean": "rm -rf dist"
18
19
  },
19
20
  "keywords": [