ccman 3.0.23 → 3.0.26

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 +1229 -170
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var init_package = __esm({
39
39
  "../core/package.json"() {
40
40
  package_default = {
41
41
  name: "@ccman/core",
42
- version: "3.0.23",
42
+ version: "3.0.26",
43
43
  type: "module",
44
44
  description: "Core business logic for ccman",
45
45
  main: "./dist/index.js",
@@ -110,7 +110,10 @@ function getCodexAuthPath() {
110
110
  function getClaudeConfigPath() {
111
111
  return path.join(claudeDir, "settings.json");
112
112
  }
113
- var os, path, isDev, isTest, ccmanDir, codexDir, claudeDir;
113
+ function getClaudeJsonPath() {
114
+ return path.join(rootDir, ".claude.json");
115
+ }
116
+ var os, path, isDev, isTest, rootDir, ccmanDir, codexDir, claudeDir;
114
117
  var init_paths = __esm({
115
118
  "../core/dist/paths.js"() {
116
119
  "use strict";
@@ -119,20 +122,15 @@ var init_paths = __esm({
119
122
  isDev = process.env.NODE_ENV === "development";
120
123
  isTest = process.env.NODE_ENV === "test";
121
124
  if (isTest) {
122
- const testRoot = path.join(os.tmpdir(), `ccman-test-${process.pid}`);
123
- ccmanDir = path.join(testRoot, ".ccman");
124
- codexDir = path.join(testRoot, ".codex");
125
- claudeDir = path.join(testRoot, ".claude");
125
+ rootDir = path.join(os.tmpdir(), `ccman-test-${process.pid}`);
126
126
  } else if (isDev) {
127
- const devRoot = path.join(os.tmpdir(), "ccman-dev");
128
- ccmanDir = path.join(devRoot, ".ccman");
129
- codexDir = path.join(devRoot, ".codex");
130
- claudeDir = path.join(devRoot, ".claude");
127
+ rootDir = path.join(os.tmpdir(), "ccman-dev");
131
128
  } else {
132
- ccmanDir = path.join(os.homedir(), ".ccman");
133
- codexDir = path.join(os.homedir(), ".codex");
134
- claudeDir = path.join(os.homedir(), ".claude");
129
+ rootDir = os.homedir();
135
130
  }
131
+ ccmanDir = path.join(rootDir, ".ccman");
132
+ codexDir = path.join(rootDir, ".codex");
133
+ claudeDir = path.join(rootDir, ".claude");
136
134
  }
137
135
  });
138
136
 
@@ -2271,6 +2269,9 @@ function writeClaudeConfig(provider) {
2271
2269
  baseUrl: provider.baseUrl
2272
2270
  });
2273
2271
  const mergedConfig = deepMerge(defaultConfig, userConfig);
2272
+ mergedConfig.env = mergedConfig.env || {};
2273
+ mergedConfig.env.ANTHROPIC_AUTH_TOKEN = provider.apiKey;
2274
+ mergedConfig.env.ANTHROPIC_BASE_URL = provider.baseUrl;
2274
2275
  fs3.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2), { mode: 384 });
2275
2276
  }
2276
2277
  var fs3, CLAUDE_CONFIG_TEMPLATE;
@@ -2296,6 +2297,167 @@ var init_claude = __esm({
2296
2297
  }
2297
2298
  });
2298
2299
 
2300
+ // ../core/dist/writers/mcp.js
2301
+ function getMCPConfigPath() {
2302
+ return path3.join(getCcmanDir(), "mcp.json");
2303
+ }
2304
+ function migrateMCPConfig(config) {
2305
+ if (Array.isArray(config.managedServerNames)) {
2306
+ config.managedServerNames = {
2307
+ claude: config.managedServerNames,
2308
+ codex: [],
2309
+ cursor: [],
2310
+ windsurf: []
2311
+ };
2312
+ } else if (!config.managedServerNames) {
2313
+ config.managedServerNames = {
2314
+ claude: [],
2315
+ codex: [],
2316
+ cursor: [],
2317
+ windsurf: []
2318
+ };
2319
+ }
2320
+ if (config.servers) {
2321
+ for (const server of config.servers) {
2322
+ if (!server.enabledApps) {
2323
+ server.enabledApps = ["claude"];
2324
+ }
2325
+ }
2326
+ }
2327
+ return config;
2328
+ }
2329
+ function loadMCPConfig() {
2330
+ const configPath = getMCPConfigPath();
2331
+ if (!fileExists(configPath)) {
2332
+ return {
2333
+ servers: [],
2334
+ managedServerNames: {
2335
+ claude: [],
2336
+ codex: [],
2337
+ cursor: [],
2338
+ windsurf: []
2339
+ }
2340
+ };
2341
+ }
2342
+ const config = readJSON(configPath);
2343
+ return migrateMCPConfig(config);
2344
+ }
2345
+ function saveMCPConfig(config) {
2346
+ const configPath = getMCPConfigPath();
2347
+ writeJSON(configPath, config);
2348
+ }
2349
+ function providerToMCPServer(provider) {
2350
+ let env;
2351
+ let description;
2352
+ if (provider.model) {
2353
+ try {
2354
+ const modelData = JSON.parse(provider.model);
2355
+ env = modelData.env;
2356
+ description = modelData.description;
2357
+ } catch (error) {
2358
+ env = JSON.parse(provider.model);
2359
+ }
2360
+ }
2361
+ return {
2362
+ id: provider.id,
2363
+ name: provider.name,
2364
+ command: provider.baseUrl,
2365
+ args: provider.apiKey.split(" ").filter((arg) => arg.length > 0),
2366
+ env,
2367
+ description,
2368
+ createdAt: provider.createdAt,
2369
+ lastModified: provider.lastModified,
2370
+ enabledApps: ["claude"]
2371
+ // 新创建的 MCP 默认启用 Claude
2372
+ };
2373
+ }
2374
+ function mcpServerToProvider(server) {
2375
+ let model;
2376
+ if (server.env || server.description) {
2377
+ model = JSON.stringify({
2378
+ env: server.env,
2379
+ description: server.description
2380
+ });
2381
+ }
2382
+ return {
2383
+ id: server.id,
2384
+ name: server.name,
2385
+ baseUrl: server.command,
2386
+ apiKey: server.args.join(" "),
2387
+ model,
2388
+ createdAt: server.createdAt,
2389
+ lastModified: server.lastModified
2390
+ };
2391
+ }
2392
+ function writeMCPConfigForApp(app, _provider) {
2393
+ const mcpConfig = loadMCPConfig();
2394
+ const enabledServers = mcpConfig.servers.filter((server) => server.enabledApps.includes(app));
2395
+ let configPath;
2396
+ let configDir;
2397
+ switch (app) {
2398
+ case "claude":
2399
+ configPath = getClaudeConfigPath();
2400
+ configDir = getClaudeDir();
2401
+ break;
2402
+ case "codex":
2403
+ return;
2404
+ case "cursor":
2405
+ return;
2406
+ case "windsurf":
2407
+ return;
2408
+ }
2409
+ ensureDir(configDir);
2410
+ let appConfig = {};
2411
+ if (fileExists(configPath)) {
2412
+ try {
2413
+ const content = fs4.readFileSync(configPath, "utf-8");
2414
+ appConfig = JSON.parse(content);
2415
+ } catch (error) {
2416
+ throw new Error(`\u65E0\u6CD5\u8BFB\u53D6 ${app} \u914D\u7F6E\u6587\u4EF6: ${error.message}`);
2417
+ }
2418
+ }
2419
+ const existingMCPs = appConfig.mcpServers || {};
2420
+ const userMCPs = {};
2421
+ const managedNames = mcpConfig.managedServerNames[app] || [];
2422
+ for (const [name, config] of Object.entries(existingMCPs)) {
2423
+ if (!managedNames.includes(name)) {
2424
+ userMCPs[name] = config;
2425
+ }
2426
+ }
2427
+ const ccmanMCPs = {};
2428
+ for (const server of enabledServers) {
2429
+ ccmanMCPs[server.name] = {
2430
+ command: server.command,
2431
+ args: server.args,
2432
+ env: server.env
2433
+ };
2434
+ }
2435
+ appConfig.mcpServers = {
2436
+ ...ccmanMCPs,
2437
+ // ccman 管理的
2438
+ ...userMCPs
2439
+ // 用户手动配置的(优先级更高)
2440
+ };
2441
+ const tempPath = `${configPath}.tmp`;
2442
+ fs4.writeFileSync(tempPath, JSON.stringify(appConfig, null, 2), {
2443
+ mode: 384
2444
+ });
2445
+ fs4.renameSync(tempPath, configPath);
2446
+ }
2447
+ function writeMCPConfig(_provider) {
2448
+ writeMCPConfigForApp("claude", _provider);
2449
+ }
2450
+ var fs4, path3;
2451
+ var init_mcp = __esm({
2452
+ "../core/dist/writers/mcp.js"() {
2453
+ "use strict";
2454
+ fs4 = __toESM(require("fs"), 1);
2455
+ path3 = __toESM(require("path"), 1);
2456
+ init_paths();
2457
+ init_file();
2458
+ }
2459
+ });
2460
+
2299
2461
  // ../core/dist/presets/codex.js
2300
2462
  var CODEX_PRESETS;
2301
2463
  var init_codex2 = __esm({
@@ -2356,6 +2518,102 @@ var init_claude2 = __esm({
2356
2518
  }
2357
2519
  });
2358
2520
 
2521
+ // ../core/dist/presets/mcp.js
2522
+ var MCP_PRESETS_DETAIL, MCP_PRESETS;
2523
+ var init_mcp2 = __esm({
2524
+ "../core/dist/presets/mcp.js"() {
2525
+ "use strict";
2526
+ MCP_PRESETS_DETAIL = [
2527
+ {
2528
+ name: "filesystem",
2529
+ command: "npx",
2530
+ args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"],
2531
+ description: "\u6587\u4EF6\u7CFB\u7EDF\u8BBF\u95EE",
2532
+ argsPlaceholder: "\u9700\u8981\u4FEE\u6539\u7B2C3\u4E2A\u53C2\u6570\u4E3A\u5141\u8BB8\u8BBF\u95EE\u7684\u76EE\u5F55\u8DEF\u5F84"
2533
+ },
2534
+ {
2535
+ name: "github",
2536
+ command: "npx",
2537
+ args: ["-y", "@modelcontextprotocol/server-github"],
2538
+ description: "GitHub \u96C6\u6210",
2539
+ envRequired: ["GITHUB_PERSONAL_ACCESS_TOKEN"]
2540
+ },
2541
+ {
2542
+ name: "postgres",
2543
+ command: "npx",
2544
+ args: ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"],
2545
+ description: "PostgreSQL \u6570\u636E\u5E93",
2546
+ argsPlaceholder: "\u9700\u8981\u4FEE\u6539\u7B2C3\u4E2A\u53C2\u6570\u4E3A\u6570\u636E\u5E93\u8FDE\u63A5\u5B57\u7B26\u4E32"
2547
+ },
2548
+ {
2549
+ name: "brave-search",
2550
+ command: "npx",
2551
+ args: ["-y", "@modelcontextprotocol/server-brave-search"],
2552
+ description: "Brave \u641C\u7D22",
2553
+ envRequired: ["BRAVE_API_KEY"]
2554
+ },
2555
+ {
2556
+ name: "google-maps",
2557
+ command: "npx",
2558
+ args: ["-y", "@modelcontextprotocol/server-google-maps"],
2559
+ description: "Google Maps",
2560
+ envRequired: ["GOOGLE_MAPS_API_KEY"]
2561
+ },
2562
+ {
2563
+ name: "puppeteer",
2564
+ command: "npx",
2565
+ args: ["-y", "@modelcontextprotocol/server-puppeteer"],
2566
+ description: "\u6D4F\u89C8\u5668\u81EA\u52A8\u5316"
2567
+ },
2568
+ {
2569
+ name: "sqlite",
2570
+ command: "npx",
2571
+ args: ["-y", "@modelcontextprotocol/server-sqlite", "/path/to/database.db"],
2572
+ description: "SQLite \u6570\u636E\u5E93",
2573
+ argsPlaceholder: "\u9700\u8981\u4FEE\u6539\u7B2C3\u4E2A\u53C2\u6570\u4E3A\u6570\u636E\u5E93\u6587\u4EF6\u8DEF\u5F84"
2574
+ },
2575
+ {
2576
+ name: "sequential-thinking",
2577
+ command: "npx",
2578
+ args: ["-y", "@modelcontextprotocol/server-sequential-thinking"],
2579
+ description: "\u5E8F\u5217\u601D\u8003\u589E\u5F3A"
2580
+ }
2581
+ ];
2582
+ MCP_PRESETS = MCP_PRESETS_DETAIL.map((preset) => ({
2583
+ name: preset.name,
2584
+ baseUrl: preset.command,
2585
+ // 字段映射:command → baseUrl
2586
+ description: preset.description
2587
+ }));
2588
+ }
2589
+ });
2590
+
2591
+ // ../core/dist/tool-manager.types.js
2592
+ var ProviderNotFoundError, ProviderNameConflictError, PresetNameConflictError;
2593
+ var init_tool_manager_types = __esm({
2594
+ "../core/dist/tool-manager.types.js"() {
2595
+ "use strict";
2596
+ ProviderNotFoundError = class extends Error {
2597
+ constructor(id) {
2598
+ super(`\u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${id}`);
2599
+ this.name = "ProviderNotFoundError";
2600
+ }
2601
+ };
2602
+ ProviderNameConflictError = class extends Error {
2603
+ constructor(name) {
2604
+ super(`\u670D\u52A1\u5546\u540D\u79F0\u5DF2\u5B58\u5728: ${name}`);
2605
+ this.name = "ProviderNameConflictError";
2606
+ }
2607
+ };
2608
+ PresetNameConflictError = class extends Error {
2609
+ constructor(name) {
2610
+ super(`\u9884\u7F6E\u540D\u79F0\u5DF2\u5B58\u5728: ${name}`);
2611
+ this.name = "PresetNameConflictError";
2612
+ }
2613
+ };
2614
+ }
2615
+ });
2616
+
2359
2617
  // ../core/dist/tool-manager.js
2360
2618
  function createToolManager(tool) {
2361
2619
  const toolConfig = TOOL_CONFIGS[tool];
@@ -2366,6 +2624,9 @@ function createToolManager(tool) {
2366
2624
  return `${tool}-${timestamp}-${random}`;
2367
2625
  }
2368
2626
  function loadConfig2() {
2627
+ if (toolConfig.customLoader) {
2628
+ return toolConfig.customLoader();
2629
+ }
2369
2630
  if (!fileExists(configPath)) {
2370
2631
  ensureDir(getCcmanDir());
2371
2632
  const initialConfig = {
@@ -2378,6 +2639,10 @@ function createToolManager(tool) {
2378
2639
  return readJSON(configPath);
2379
2640
  }
2380
2641
  function saveConfig2(config) {
2642
+ if (toolConfig.customSaver) {
2643
+ toolConfig.customSaver(config);
2644
+ return;
2645
+ }
2381
2646
  writeJSON(configPath, config);
2382
2647
  }
2383
2648
  return {
@@ -2399,6 +2664,9 @@ function createToolManager(tool) {
2399
2664
  };
2400
2665
  config.providers.push(provider);
2401
2666
  saveConfig2(config);
2667
+ if (toolConfig.autoSync) {
2668
+ toolConfig.writer(provider);
2669
+ }
2402
2670
  return provider;
2403
2671
  },
2404
2672
  list() {
@@ -2437,6 +2705,9 @@ function createToolManager(tool) {
2437
2705
  const provider = config.providers.find((p) => p.id === config.currentProviderId);
2438
2706
  return provider || null;
2439
2707
  },
2708
+ // 注:edit 方法的"复杂度"来自必要的业务逻辑(检查存在性、名称冲突、更新 4 个可选字段、同步配置)
2709
+ // 每个 if 都不可避免,没有特殊情况或嵌套逻辑,因此禁用 complexity 检查
2710
+ // eslint-disable-next-line complexity
2440
2711
  edit(id, updates) {
2441
2712
  const config = loadConfig2();
2442
2713
  const provider = config.providers.find((p) => p.id === id);
@@ -2462,6 +2733,9 @@ function createToolManager(tool) {
2462
2733
  if (config.currentProviderId === id) {
2463
2734
  toolConfig.writer(provider);
2464
2735
  }
2736
+ if (toolConfig.autoSync) {
2737
+ toolConfig.writer(provider);
2738
+ }
2465
2739
  return provider;
2466
2740
  },
2467
2741
  remove(id) {
@@ -2475,6 +2749,9 @@ function createToolManager(tool) {
2475
2749
  }
2476
2750
  config.providers.splice(index, 1);
2477
2751
  saveConfig2(config);
2752
+ if (toolConfig.autoSync) {
2753
+ toolConfig.writer({});
2754
+ }
2478
2755
  },
2479
2756
  clone(sourceId, newName) {
2480
2757
  const source = this.get(sourceId);
@@ -2579,45 +2856,63 @@ function createCodexManager() {
2579
2856
  function createClaudeManager() {
2580
2857
  return createToolManager("claude");
2581
2858
  }
2582
- var path3, ProviderNotFoundError, ProviderNameConflictError, PresetNameConflictError, TOOL_CONFIGS;
2859
+ function createMCPManager() {
2860
+ return createToolManager("mcp");
2861
+ }
2862
+ var path4, TOOL_CONFIGS;
2583
2863
  var init_tool_manager = __esm({
2584
2864
  "../core/dist/tool-manager.js"() {
2585
2865
  "use strict";
2586
- path3 = __toESM(require("path"), 1);
2866
+ path4 = __toESM(require("path"), 1);
2587
2867
  init_paths();
2588
2868
  init_file();
2589
2869
  init_codex();
2590
2870
  init_claude();
2871
+ init_mcp();
2591
2872
  init_codex2();
2592
2873
  init_claude2();
2593
- ProviderNotFoundError = class extends Error {
2594
- constructor(id) {
2595
- super(`\u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${id}`);
2596
- this.name = "ProviderNotFoundError";
2597
- }
2598
- };
2599
- ProviderNameConflictError = class extends Error {
2600
- constructor(name) {
2601
- super(`\u670D\u52A1\u5546\u540D\u79F0\u5DF2\u5B58\u5728: ${name}`);
2602
- this.name = "ProviderNameConflictError";
2603
- }
2604
- };
2605
- PresetNameConflictError = class extends Error {
2606
- constructor(name) {
2607
- super(`\u9884\u7F6E\u540D\u79F0\u5DF2\u5B58\u5728: ${name}`);
2608
- this.name = "PresetNameConflictError";
2609
- }
2610
- };
2874
+ init_mcp2();
2875
+ init_tool_manager_types();
2611
2876
  TOOL_CONFIGS = {
2612
2877
  codex: {
2613
- configPath: path3.join(getCcmanDir(), "codex.json"),
2878
+ configPath: path4.join(getCcmanDir(), "codex.json"),
2614
2879
  builtinPresets: CODEX_PRESETS,
2615
2880
  writer: writeCodexConfig
2616
2881
  },
2617
2882
  claude: {
2618
- configPath: path3.join(getCcmanDir(), "claude.json"),
2883
+ configPath: path4.join(getCcmanDir(), "claude.json"),
2619
2884
  builtinPresets: CC_PRESETS,
2620
2885
  writer: writeClaudeConfig
2886
+ },
2887
+ mcp: {
2888
+ configPath: path4.join(getCcmanDir(), "mcp.json"),
2889
+ builtinPresets: MCP_PRESETS,
2890
+ writer: writeMCPConfig,
2891
+ autoSync: true,
2892
+ // MCP 需要在每个操作后自动同步到 ~/.claude.json
2893
+ // MCP 使用特殊的配置格式(MCPConfig),需要自定义 loader/saver
2894
+ customLoader: () => {
2895
+ const mcpConfig = loadMCPConfig();
2896
+ return {
2897
+ providers: mcpConfig.servers.map(mcpServerToProvider),
2898
+ presets: []
2899
+ };
2900
+ },
2901
+ customSaver: (config) => {
2902
+ const mcpConfig = loadMCPConfig();
2903
+ mcpConfig.servers = config.providers.map((provider) => {
2904
+ const existingServer = mcpConfig.servers.find((s2) => s2.id === provider.id);
2905
+ const mcpServer = providerToMCPServer(provider);
2906
+ if (existingServer) {
2907
+ mcpServer.enabledApps = existingServer.enabledApps;
2908
+ }
2909
+ return mcpServer;
2910
+ });
2911
+ for (const app of ["claude", "codex", "cursor", "windsurf"]) {
2912
+ mcpConfig.managedServerNames[app] = mcpConfig.servers.filter((s2) => s2.enabledApps.includes(app)).map((s2) => s2.name);
2913
+ }
2914
+ saveMCPConfig(mcpConfig);
2915
+ }
2621
2916
  }
2622
2917
  };
2623
2918
  }
@@ -2634,17 +2929,17 @@ var init_migrate = __esm({
2634
2929
  // ../core/dist/config.js
2635
2930
  function ensureConfigDir() {
2636
2931
  const dir = getCcmanDir();
2637
- if (!fs4.existsSync(dir)) {
2638
- fs4.mkdirSync(dir, { recursive: true, mode: 448 });
2932
+ if (!fs5.existsSync(dir)) {
2933
+ fs5.mkdirSync(dir, { recursive: true, mode: 448 });
2639
2934
  }
2640
2935
  }
2641
2936
  function loadConfig() {
2642
2937
  const configPath = getConfigPath();
2643
- if (!fs4.existsSync(configPath)) {
2938
+ if (!fs5.existsSync(configPath)) {
2644
2939
  return {};
2645
2940
  }
2646
2941
  try {
2647
- const content = fs4.readFileSync(configPath, "utf-8");
2942
+ const content = fs5.readFileSync(configPath, "utf-8");
2648
2943
  return JSON.parse(content);
2649
2944
  } catch (error) {
2650
2945
  throw new Error(`Failed to load config: ${error.message}`);
@@ -2655,10 +2950,10 @@ function saveConfig(config) {
2655
2950
  const configPath = getConfigPath();
2656
2951
  try {
2657
2952
  const tempPath = `${configPath}.tmp`;
2658
- fs4.writeFileSync(tempPath, JSON.stringify(config, null, 2), {
2953
+ fs5.writeFileSync(tempPath, JSON.stringify(config, null, 2), {
2659
2954
  mode: 384
2660
2955
  });
2661
- fs4.renameSync(tempPath, configPath);
2956
+ fs5.renameSync(tempPath, configPath);
2662
2957
  } catch (error) {
2663
2958
  throw new Error(`Failed to save config: ${error.message}`);
2664
2959
  }
@@ -2679,11 +2974,11 @@ function updateLastSyncTime() {
2679
2974
  saveConfig(config);
2680
2975
  }
2681
2976
  }
2682
- var fs4;
2977
+ var fs5;
2683
2978
  var init_config = __esm({
2684
2979
  "../core/dist/config.js"() {
2685
2980
  "use strict";
2686
- fs4 = __toESM(require("fs"), 1);
2981
+ fs5 = __toESM(require("fs"), 1);
2687
2982
  init_paths();
2688
2983
  }
2689
2984
  });
@@ -2878,22 +3173,22 @@ var require_url_parse = __commonJS({
2878
3173
  }
2879
3174
  function resolve(relative, base) {
2880
3175
  if (relative === "") return base;
2881
- var path12 = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i2 = path12.length, last = path12[i2 - 1], unshift = false, up = 0;
3176
+ var path13 = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i2 = path13.length, last = path13[i2 - 1], unshift = false, up = 0;
2882
3177
  while (i2--) {
2883
- if (path12[i2] === ".") {
2884
- path12.splice(i2, 1);
2885
- } else if (path12[i2] === "..") {
2886
- path12.splice(i2, 1);
3178
+ if (path13[i2] === ".") {
3179
+ path13.splice(i2, 1);
3180
+ } else if (path13[i2] === "..") {
3181
+ path13.splice(i2, 1);
2887
3182
  up++;
2888
3183
  } else if (up) {
2889
3184
  if (i2 === 0) unshift = true;
2890
- path12.splice(i2, 1);
3185
+ path13.splice(i2, 1);
2891
3186
  up--;
2892
3187
  }
2893
3188
  }
2894
- if (unshift) path12.unshift("");
2895
- if (last === "." || last === "..") path12.push("");
2896
- return path12.join("/");
3189
+ if (unshift) path13.unshift("");
3190
+ if (last === "." || last === "..") path13.push("");
3191
+ return path13.join("/");
2897
3192
  }
2898
3193
  function Url(address, location, parser) {
2899
3194
  address = trimLeft(address);
@@ -3319,14 +3614,14 @@ var require_path_posix = __commonJS({
3319
3614
  posix.resolve = function() {
3320
3615
  var resolvedPath = "", resolvedAbsolute = false;
3321
3616
  for (var i2 = arguments.length - 1; i2 >= -1 && !resolvedAbsolute; i2--) {
3322
- var path12 = i2 >= 0 ? arguments[i2] : process.cwd();
3323
- if (!isString(path12)) {
3617
+ var path13 = i2 >= 0 ? arguments[i2] : process.cwd();
3618
+ if (!isString(path13)) {
3324
3619
  throw new TypeError("Arguments to path.resolve must be strings");
3325
- } else if (!path12) {
3620
+ } else if (!path13) {
3326
3621
  continue;
3327
3622
  }
3328
- resolvedPath = path12 + "/" + resolvedPath;
3329
- resolvedAbsolute = path12.charAt(0) === "/";
3623
+ resolvedPath = path13 + "/" + resolvedPath;
3624
+ resolvedAbsolute = path13.charAt(0) === "/";
3330
3625
  }
3331
3626
  resolvedPath = normalizeArray(
3332
3627
  resolvedPath.split("/"),
@@ -3334,36 +3629,36 @@ var require_path_posix = __commonJS({
3334
3629
  ).join("/");
3335
3630
  return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
3336
3631
  };
3337
- posix.normalize = function(path12) {
3338
- var isAbsolute = posix.isAbsolute(path12), trailingSlash = path12.substr(-1) === "/";
3339
- path12 = normalizeArray(path12.split("/"), !isAbsolute).join("/");
3340
- if (!path12 && !isAbsolute) {
3341
- path12 = ".";
3632
+ posix.normalize = function(path13) {
3633
+ var isAbsolute = posix.isAbsolute(path13), trailingSlash = path13.substr(-1) === "/";
3634
+ path13 = normalizeArray(path13.split("/"), !isAbsolute).join("/");
3635
+ if (!path13 && !isAbsolute) {
3636
+ path13 = ".";
3342
3637
  }
3343
- if (path12 && trailingSlash) {
3344
- path12 += "/";
3638
+ if (path13 && trailingSlash) {
3639
+ path13 += "/";
3345
3640
  }
3346
- return (isAbsolute ? "/" : "") + path12;
3641
+ return (isAbsolute ? "/" : "") + path13;
3347
3642
  };
3348
- posix.isAbsolute = function(path12) {
3349
- return path12.charAt(0) === "/";
3643
+ posix.isAbsolute = function(path13) {
3644
+ return path13.charAt(0) === "/";
3350
3645
  };
3351
3646
  posix.join = function() {
3352
- var path12 = "";
3647
+ var path13 = "";
3353
3648
  for (var i2 = 0; i2 < arguments.length; i2++) {
3354
3649
  var segment = arguments[i2];
3355
3650
  if (!isString(segment)) {
3356
3651
  throw new TypeError("Arguments to path.join must be strings");
3357
3652
  }
3358
3653
  if (segment) {
3359
- if (!path12) {
3360
- path12 += segment;
3654
+ if (!path13) {
3655
+ path13 += segment;
3361
3656
  } else {
3362
- path12 += "/" + segment;
3657
+ path13 += "/" + segment;
3363
3658
  }
3364
3659
  }
3365
3660
  }
3366
- return posix.normalize(path12);
3661
+ return posix.normalize(path13);
3367
3662
  };
3368
3663
  posix.relative = function(from, to) {
3369
3664
  from = posix.resolve(from).substr(1);
@@ -3397,11 +3692,11 @@ var require_path_posix = __commonJS({
3397
3692
  outputParts = outputParts.concat(toParts.slice(samePartsLength));
3398
3693
  return outputParts.join("/");
3399
3694
  };
3400
- posix._makeLong = function(path12) {
3401
- return path12;
3695
+ posix._makeLong = function(path13) {
3696
+ return path13;
3402
3697
  };
3403
- posix.dirname = function(path12) {
3404
- var result = posixSplitPath(path12), root = result[0], dir = result[1];
3698
+ posix.dirname = function(path13) {
3699
+ var result = posixSplitPath(path13), root = result[0], dir = result[1];
3405
3700
  if (!root && !dir) {
3406
3701
  return ".";
3407
3702
  }
@@ -3410,15 +3705,15 @@ var require_path_posix = __commonJS({
3410
3705
  }
3411
3706
  return root + dir;
3412
3707
  };
3413
- posix.basename = function(path12, ext2) {
3414
- var f3 = posixSplitPath(path12)[2];
3708
+ posix.basename = function(path13, ext2) {
3709
+ var f3 = posixSplitPath(path13)[2];
3415
3710
  if (ext2 && f3.substr(-1 * ext2.length) === ext2) {
3416
3711
  f3 = f3.substr(0, f3.length - ext2.length);
3417
3712
  }
3418
3713
  return f3;
3419
3714
  };
3420
- posix.extname = function(path12) {
3421
- return posixSplitPath(path12)[3];
3715
+ posix.extname = function(path13) {
3716
+ return posixSplitPath(path13)[3];
3422
3717
  };
3423
3718
  posix.format = function(pathObject) {
3424
3719
  if (!util.isObject(pathObject)) {
@@ -12080,7 +12375,7 @@ var init_escape2 = __esm({
12080
12375
  });
12081
12376
 
12082
12377
  // ../../node_modules/.pnpm/minimatch@9.0.5/node_modules/minimatch/dist/esm/index.js
12083
- var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path5, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
12378
+ var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path6, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
12084
12379
  var init_esm2 = __esm({
12085
12380
  "../../node_modules/.pnpm/minimatch@9.0.5/node_modules/minimatch/dist/esm/index.js"() {
12086
12381
  "use strict";
@@ -12150,11 +12445,11 @@ var init_esm2 = __esm({
12150
12445
  return (f3) => f3.length === len && f3 !== "." && f3 !== "..";
12151
12446
  };
12152
12447
  defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
12153
- path5 = {
12448
+ path6 = {
12154
12449
  win32: { sep: "\\" },
12155
12450
  posix: { sep: "/" }
12156
12451
  };
12157
- sep = defaultPlatform === "win32" ? path5.win32.sep : path5.posix.sep;
12452
+ sep = defaultPlatform === "win32" ? path6.win32.sep : path6.posix.sep;
12158
12453
  minimatch.sep = sep;
12159
12454
  GLOBSTAR = Symbol("globstar **");
12160
12455
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -14816,10 +15111,10 @@ var require_nested_property = __commonJS({
14816
15111
  return false;
14817
15112
  }
14818
15113
  }
14819
- function traverse(object, path12) {
15114
+ function traverse(object, path13) {
14820
15115
  var callback = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
14821
15116
  };
14822
- var segments = path12.split(PATH_DELIMITER);
15117
+ var segments = path13.split(PATH_DELIMITER);
14823
15118
  var length = segments.length;
14824
15119
  var _loop = function _loop2(idx2) {
14825
15120
  var currentSegment = segments[idx2];
@@ -15061,11 +15356,11 @@ async function createDirectory(context, dirPath, options = {}) {
15061
15356
  const response = await request(requestOptions, context);
15062
15357
  handleResponseCode(context, response);
15063
15358
  }
15064
- function ensureCollectionPath(path12) {
15065
- if (!path12.endsWith("/")) {
15066
- return path12 + "/";
15359
+ function ensureCollectionPath(path13) {
15360
+ if (!path13.endsWith("/")) {
15361
+ return path13 + "/";
15067
15362
  }
15068
- return path12;
15363
+ return path13;
15069
15364
  }
15070
15365
  async function createDirectoryRecursively(context, dirPath, options = {}) {
15071
15366
  const paths = getAllDirectories(normalisePath(dirPath));
@@ -15440,7 +15735,7 @@ var init_xml = __esm({
15440
15735
  });
15441
15736
 
15442
15737
  // ../../node_modules/.pnpm/webdav@5.8.0/node_modules/webdav/dist/node/operations/lock.js
15443
- async function lock(context, path12, options = {}) {
15738
+ async function lock(context, path13, options = {}) {
15444
15739
  const { refreshToken, timeout = DEFAULT_TIMEOUT } = options;
15445
15740
  const headers = {
15446
15741
  Accept: "text/plain,application/xml",
@@ -15450,7 +15745,7 @@ async function lock(context, path12, options = {}) {
15450
15745
  headers.If = refreshToken;
15451
15746
  }
15452
15747
  const requestOptions = prepareRequestOptions({
15453
- url: joinURL(context.remoteURL, encodePath(path12)),
15748
+ url: joinURL(context.remoteURL, encodePath(path13)),
15454
15749
  method: "LOCK",
15455
15750
  headers,
15456
15751
  data: generateLockXML(context.contactHref)
@@ -15470,9 +15765,9 @@ async function lock(context, path12, options = {}) {
15470
15765
  serverTimeout
15471
15766
  };
15472
15767
  }
15473
- async function unlock(context, path12, token, options = {}) {
15768
+ async function unlock(context, path13, token, options = {}) {
15474
15769
  const requestOptions = prepareRequestOptions({
15475
- url: joinURL(context.remoteURL, encodePath(path12)),
15770
+ url: joinURL(context.remoteURL, encodePath(path13)),
15476
15771
  method: "UNLOCK",
15477
15772
  headers: {
15478
15773
  "Lock-Token": token
@@ -15522,9 +15817,9 @@ var init_quota = __esm({
15522
15817
 
15523
15818
  // ../../node_modules/.pnpm/webdav@5.8.0/node_modules/webdav/dist/node/operations/getQuota.js
15524
15819
  async function getQuota(context, options = {}) {
15525
- const path12 = options.path || "/";
15820
+ const path13 = options.path || "/";
15526
15821
  const requestOptions = prepareRequestOptions({
15527
- url: joinURL(context.remoteURL, path12),
15822
+ url: joinURL(context.remoteURL, path13),
15528
15823
  method: "PROPFIND",
15529
15824
  headers: {
15530
15825
  Accept: "text/plain,application/xml",
@@ -15864,29 +16159,29 @@ function createClient(remoteURL, options = {}) {
15864
16159
  setupAuth(context, username, password, token, ha1);
15865
16160
  return {
15866
16161
  copyFile: (filename, destination, options2) => copyFile(context, filename, destination, options2),
15867
- createDirectory: (path12, options2) => createDirectory(context, path12, options2),
16162
+ createDirectory: (path13, options2) => createDirectory(context, path13, options2),
15868
16163
  createReadStream: (filename, options2) => createReadStream2(context, filename, options2),
15869
16164
  createWriteStream: (filename, options2, callback) => createWriteStream(context, filename, options2, callback),
15870
- customRequest: (path12, requestOptions) => customRequest(context, path12, requestOptions),
16165
+ customRequest: (path13, requestOptions) => customRequest(context, path13, requestOptions),
15871
16166
  deleteFile: (filename, options2) => deleteFile(context, filename, options2),
15872
- exists: (path12, options2) => exists(context, path12, options2),
15873
- getDirectoryContents: (path12, options2) => getDirectoryContents(context, path12, options2),
16167
+ exists: (path13, options2) => exists(context, path13, options2),
16168
+ getDirectoryContents: (path13, options2) => getDirectoryContents(context, path13, options2),
15874
16169
  getFileContents: (filename, options2) => getFileContents(context, filename, options2),
15875
16170
  getFileDownloadLink: (filename) => getFileDownloadLink(context, filename),
15876
16171
  getFileUploadLink: (filename) => getFileUploadLink(context, filename),
15877
16172
  getHeaders: () => Object.assign({}, context.headers),
15878
16173
  getQuota: (options2) => getQuota(context, options2),
15879
- lock: (path12, options2) => lock(context, path12, options2),
16174
+ lock: (path13, options2) => lock(context, path13, options2),
15880
16175
  moveFile: (filename, destinationFilename, options2) => moveFile(context, filename, destinationFilename, options2),
15881
16176
  putFileContents: (filename, data, options2) => putFileContents(context, filename, data, options2),
15882
16177
  partialUpdateFileContents: (filePath, start, end, data, options2) => partialUpdateFileContents(context, filePath, start, end, data, options2),
15883
- getDAVCompliance: (path12) => getDAVCompliance(context, path12),
15884
- search: (path12, options2) => getSearch2(context, path12, options2),
16178
+ getDAVCompliance: (path13) => getDAVCompliance(context, path13),
16179
+ search: (path13, options2) => getSearch2(context, path13, options2),
15885
16180
  setHeaders: (headers2) => {
15886
16181
  context.headers = Object.assign({}, headers2);
15887
16182
  },
15888
- stat: (path12, options2) => getStat(context, path12, options2),
15889
- unlock: (path12, token2, options2) => unlock(context, path12, token2, options2)
16183
+ stat: (path13, options2) => getStat(context, path13, options2),
16184
+ unlock: (path13, token2, options2) => unlock(context, path13, token2, options2)
15890
16185
  };
15891
16186
  }
15892
16187
  var DEFAULT_CONTACT_HREF;
@@ -16507,8 +16802,8 @@ var init_sync_v2 = __esm({
16507
16802
  // ../core/dist/export.js
16508
16803
  function validateExport() {
16509
16804
  const ccmanDir2 = getCcmanDir();
16510
- const codexPath = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
16511
- const claudePath = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16805
+ const codexPath = path10.join(ccmanDir2, CODEX_CONFIG_FILE);
16806
+ const claudePath = path10.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16512
16807
  const missingFiles = [];
16513
16808
  if (!fileExists(codexPath)) {
16514
16809
  missingFiles.push(CODEX_CONFIG_FILE);
@@ -16533,7 +16828,7 @@ function validateImportDir(sourceDir) {
16533
16828
  foundFiles: []
16534
16829
  };
16535
16830
  }
16536
- const stats = fs8.statSync(sourceDir);
16831
+ const stats = fs9.statSync(sourceDir);
16537
16832
  if (!stats.isDirectory()) {
16538
16833
  return {
16539
16834
  valid: false,
@@ -16541,8 +16836,8 @@ function validateImportDir(sourceDir) {
16541
16836
  foundFiles: []
16542
16837
  };
16543
16838
  }
16544
- const codexPath = path9.join(sourceDir, CODEX_CONFIG_FILE);
16545
- const claudePath = path9.join(sourceDir, CLAUDE_CONFIG_FILE);
16839
+ const codexPath = path10.join(sourceDir, CODEX_CONFIG_FILE);
16840
+ const claudePath = path10.join(sourceDir, CLAUDE_CONFIG_FILE);
16546
16841
  const foundFiles = [];
16547
16842
  if (fileExists(codexPath)) {
16548
16843
  foundFiles.push(CODEX_CONFIG_FILE);
@@ -16570,16 +16865,16 @@ function exportConfig(targetDir) {
16570
16865
  ensureDir(targetDir);
16571
16866
  const ccmanDir2 = getCcmanDir();
16572
16867
  const exportedFiles = [];
16573
- const codexSrc = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
16574
- const codexDst = path9.join(targetDir, CODEX_CONFIG_FILE);
16868
+ const codexSrc = path10.join(ccmanDir2, CODEX_CONFIG_FILE);
16869
+ const codexDst = path10.join(targetDir, CODEX_CONFIG_FILE);
16575
16870
  if (fileExists(codexSrc)) {
16576
- fs8.copyFileSync(codexSrc, codexDst);
16871
+ fs9.copyFileSync(codexSrc, codexDst);
16577
16872
  exportedFiles.push(CODEX_CONFIG_FILE);
16578
16873
  }
16579
- const claudeSrc = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16580
- const claudeDst = path9.join(targetDir, CLAUDE_CONFIG_FILE);
16874
+ const claudeSrc = path10.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16875
+ const claudeDst = path10.join(targetDir, CLAUDE_CONFIG_FILE);
16581
16876
  if (fileExists(claudeSrc)) {
16582
- fs8.copyFileSync(claudeSrc, claudeDst);
16877
+ fs9.copyFileSync(claudeSrc, claudeDst);
16583
16878
  exportedFiles.push(CLAUDE_CONFIG_FILE);
16584
16879
  }
16585
16880
  return {
@@ -16599,23 +16894,23 @@ function importConfig(sourceDir) {
16599
16894
  ensureDir(ccmanDir2);
16600
16895
  try {
16601
16896
  if (validation.foundFiles.includes(CODEX_CONFIG_FILE)) {
16602
- const codexDst = path9.join(ccmanDir2, CODEX_CONFIG_FILE);
16897
+ const codexDst = path10.join(ccmanDir2, CODEX_CONFIG_FILE);
16603
16898
  if (fileExists(codexDst)) {
16604
16899
  const backupPath = backupConfig(codexDst);
16605
16900
  backupPaths.push(backupPath);
16606
16901
  }
16607
- const codexSrc = path9.join(sourceDir, CODEX_CONFIG_FILE);
16608
- fs8.copyFileSync(codexSrc, codexDst);
16902
+ const codexSrc = path10.join(sourceDir, CODEX_CONFIG_FILE);
16903
+ fs9.copyFileSync(codexSrc, codexDst);
16609
16904
  importedFiles.push(CODEX_CONFIG_FILE);
16610
16905
  }
16611
16906
  if (validation.foundFiles.includes(CLAUDE_CONFIG_FILE)) {
16612
- const claudeDst = path9.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16907
+ const claudeDst = path10.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16613
16908
  if (fileExists(claudeDst)) {
16614
16909
  const backupPath = backupConfig(claudeDst);
16615
16910
  backupPaths.push(backupPath);
16616
16911
  }
16617
- const claudeSrc = path9.join(sourceDir, CLAUDE_CONFIG_FILE);
16618
- fs8.copyFileSync(claudeSrc, claudeDst);
16912
+ const claudeSrc = path10.join(sourceDir, CLAUDE_CONFIG_FILE);
16913
+ fs9.copyFileSync(claudeSrc, claudeDst);
16619
16914
  importedFiles.push(CLAUDE_CONFIG_FILE);
16620
16915
  }
16621
16916
  return {
@@ -16627,18 +16922,18 @@ function importConfig(sourceDir) {
16627
16922
  for (const backupPath of backupPaths) {
16628
16923
  const originalPath = backupPath.replace(/\.backup\.\d+$/, "");
16629
16924
  if (fileExists(backupPath)) {
16630
- fs8.copyFileSync(backupPath, originalPath);
16925
+ fs9.copyFileSync(backupPath, originalPath);
16631
16926
  }
16632
16927
  }
16633
16928
  throw new Error(`\u5BFC\u5165\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u5907\u4EFD: ${error.message}`);
16634
16929
  }
16635
16930
  }
16636
- var fs8, path9, CODEX_CONFIG_FILE, CLAUDE_CONFIG_FILE;
16931
+ var fs9, path10, CODEX_CONFIG_FILE, CLAUDE_CONFIG_FILE;
16637
16932
  var init_export = __esm({
16638
16933
  "../core/dist/export.js"() {
16639
16934
  "use strict";
16640
- fs8 = __toESM(require("fs"), 1);
16641
- path9 = __toESM(require("path"), 1);
16935
+ fs9 = __toESM(require("fs"), 1);
16936
+ path10 = __toESM(require("path"), 1);
16642
16937
  init_paths();
16643
16938
  init_file();
16644
16939
  init_merge2();
@@ -16647,6 +16942,155 @@ var init_export = __esm({
16647
16942
  }
16648
16943
  });
16649
16944
 
16945
+ // ../core/dist/claude-clean.js
16946
+ function formatBytes(bytes) {
16947
+ if (bytes < 1024)
16948
+ return `${bytes} B`;
16949
+ if (bytes < 1024 * 1024)
16950
+ return `${(bytes / 1024).toFixed(1)} KB`;
16951
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
16952
+ }
16953
+ function getFileSize(filePath) {
16954
+ try {
16955
+ const stats = fs10.statSync(filePath);
16956
+ return stats.size;
16957
+ } catch {
16958
+ return 0;
16959
+ }
16960
+ }
16961
+ function backupFile(filePath) {
16962
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-").split(".")[0];
16963
+ const backupPath = `${filePath}.backup-${timestamp}`;
16964
+ fs10.copyFileSync(filePath, backupPath);
16965
+ return backupPath;
16966
+ }
16967
+ function saveJsonAtomic(filePath, data) {
16968
+ const tempPath = `${filePath}.tmp`;
16969
+ const content = JSON.stringify(data, null, 2);
16970
+ fs10.writeFileSync(tempPath, content, { mode: 384 });
16971
+ fs10.renameSync(tempPath, filePath);
16972
+ }
16973
+ function analyzeClaudeJson() {
16974
+ const filePath = getClaudeJsonPath();
16975
+ if (!fs10.existsSync(filePath)) {
16976
+ throw new Error("~/.claude.json \u6587\u4EF6\u4E0D\u5B58\u5728");
16977
+ }
16978
+ const fileSize = getFileSize(filePath);
16979
+ const content = fs10.readFileSync(filePath, "utf-8");
16980
+ const config = JSON.parse(content);
16981
+ const projects = config.projects || {};
16982
+ const projectHistory = [];
16983
+ let totalHistoryCount = 0;
16984
+ for (const [projectPath, projectData] of Object.entries(projects)) {
16985
+ const historyCount = projectData.history?.length || 0;
16986
+ totalHistoryCount += historyCount;
16987
+ projectHistory.push({
16988
+ path: projectPath,
16989
+ count: historyCount
16990
+ });
16991
+ }
16992
+ projectHistory.sort((a, b) => b.count - a.count);
16993
+ const cacheSize = config.cachedChangelog?.length || 0;
16994
+ const historySize = fileSize - cacheSize - 2e4;
16995
+ const avgHistorySize = totalHistoryCount > 0 ? historySize / totalHistoryCount : 0;
16996
+ const estimatedSavings = {
16997
+ conservative: Math.floor(avgHistorySize * Math.max(0, totalHistoryCount - projectHistory.length * 10)) + cacheSize,
16998
+ moderate: Math.floor(avgHistorySize * Math.max(0, totalHistoryCount - projectHistory.length * 5)) + cacheSize,
16999
+ aggressive: Math.floor(historySize) + cacheSize
17000
+ };
17001
+ return {
17002
+ fileSize,
17003
+ fileSizeFormatted: formatBytes(fileSize),
17004
+ projectCount: projectHistory.length,
17005
+ totalHistoryCount,
17006
+ projectHistory,
17007
+ cacheSize,
17008
+ estimatedSavings
17009
+ };
17010
+ }
17011
+ function cleanClaudeJson(options = {}) {
17012
+ const filePath = getClaudeJsonPath();
17013
+ if (!fs10.existsSync(filePath)) {
17014
+ throw new Error("~/.claude.json \u6587\u4EF6\u4E0D\u5B58\u5728");
17015
+ }
17016
+ const backupPath = backupFile(filePath);
17017
+ const sizeBefore = getFileSize(filePath);
17018
+ const content = fs10.readFileSync(filePath, "utf-8");
17019
+ const config = JSON.parse(content);
17020
+ const cleanedItems = applyCleanOptions(config, options);
17021
+ saveJsonAtomic(filePath, config);
17022
+ const sizeAfter = getFileSize(filePath);
17023
+ return {
17024
+ sizeBefore,
17025
+ sizeAfter,
17026
+ saved: sizeBefore - sizeAfter,
17027
+ cleanedItems,
17028
+ backupPath
17029
+ };
17030
+ }
17031
+ function applyCleanOptions(config, options) {
17032
+ let projectHistoryCount = 0;
17033
+ if (options.cleanProjectHistory && config.projects) {
17034
+ const keepCount = options.keepRecentCount ?? 10;
17035
+ const targetProjects = options.projectPaths || [];
17036
+ for (const [projectPath, projectData] of Object.entries(config.projects)) {
17037
+ if (targetProjects.length > 0 && !targetProjects.includes(projectPath)) {
17038
+ continue;
17039
+ }
17040
+ if (projectData.history && Array.isArray(projectData.history)) {
17041
+ const originalCount = projectData.history.length;
17042
+ projectData.history = projectData.history.slice(-keepCount);
17043
+ projectHistoryCount += originalCount - projectData.history.length;
17044
+ }
17045
+ }
17046
+ }
17047
+ if (options.cleanCache) {
17048
+ delete config.cachedChangelog;
17049
+ config.changelogLastFetched = 0;
17050
+ }
17051
+ if (options.cleanStats) {
17052
+ config.numStartups = 0;
17053
+ config.promptQueueUseCount = 0;
17054
+ config.tipsHistory = {};
17055
+ }
17056
+ return {
17057
+ projectHistory: projectHistoryCount,
17058
+ cache: options.cleanCache || false,
17059
+ stats: options.cleanStats || false
17060
+ };
17061
+ }
17062
+ var fs10, CleanPresets;
17063
+ var init_claude_clean = __esm({
17064
+ "../core/dist/claude-clean.js"() {
17065
+ "use strict";
17066
+ fs10 = __toESM(require("fs"), 1);
17067
+ init_paths();
17068
+ CleanPresets = {
17069
+ /** 保守清理:保留最近10条记录,清理缓存 */
17070
+ conservative: () => ({
17071
+ cleanProjectHistory: true,
17072
+ keepRecentCount: 10,
17073
+ cleanCache: true,
17074
+ cleanStats: false
17075
+ }),
17076
+ /** 中等清理:保留最近5条记录,清理缓存和统计 */
17077
+ moderate: () => ({
17078
+ cleanProjectHistory: true,
17079
+ keepRecentCount: 5,
17080
+ cleanCache: true,
17081
+ cleanStats: true
17082
+ }),
17083
+ /** 激进清理:清空历史记录,清理缓存和统计 */
17084
+ aggressive: () => ({
17085
+ cleanProjectHistory: true,
17086
+ keepRecentCount: 0,
17087
+ cleanCache: true,
17088
+ cleanStats: true
17089
+ })
17090
+ };
17091
+ }
17092
+ });
17093
+
16650
17094
  // ../core/dist/index.js
16651
17095
  var VERSION;
16652
17096
  var init_dist4 = __esm({
@@ -16656,6 +17100,8 @@ var init_dist4 = __esm({
16656
17100
  init_tool_manager();
16657
17101
  init_codex2();
16658
17102
  init_claude2();
17103
+ init_mcp2();
17104
+ init_mcp();
16659
17105
  init_migrate();
16660
17106
  init_paths();
16661
17107
  init_config();
@@ -16664,6 +17110,7 @@ var init_dist4 = __esm({
16664
17110
  init_crypto2();
16665
17111
  init_merge_advanced();
16666
17112
  init_export();
17113
+ init_claude_clean();
16667
17114
  VERSION = package_default.version;
16668
17115
  }
16669
17116
  });
@@ -17116,8 +17563,8 @@ function downloadCommand(program2) {
17116
17563
  console.log();
17117
17564
  if (backupPaths.length > 0) {
17118
17565
  console.log(import_chalk7.default.gray("\u672C\u5730\u5907\u4EFD:"));
17119
- backupPaths.forEach((path12) => {
17120
- console.log(import_chalk7.default.gray(` ${path12}`));
17566
+ backupPaths.forEach((path13) => {
17567
+ console.log(import_chalk7.default.gray(` ${path13}`));
17121
17568
  });
17122
17569
  console.log();
17123
17570
  }
@@ -17179,8 +17626,8 @@ function mergeCommand(program2) {
17179
17626
  console.log();
17180
17627
  if (result.backupPaths.length > 0) {
17181
17628
  console.log(import_chalk8.default.gray("\u5907\u4EFD:"));
17182
- result.backupPaths.forEach((path12) => {
17183
- console.log(import_chalk8.default.gray(` ${path12}`));
17629
+ result.backupPaths.forEach((path13) => {
17630
+ console.log(import_chalk8.default.gray(` ${path13}`));
17184
17631
  });
17185
17632
  console.log();
17186
17633
  }
@@ -17377,7 +17824,7 @@ var init_sync = __esm({
17377
17824
 
17378
17825
  // src/index.ts
17379
17826
  var import_commander3 = require("commander");
17380
- var import_chalk28 = __toESM(require("chalk"));
17827
+ var import_chalk33 = __toESM(require("chalk"));
17381
17828
 
17382
17829
  // src/utils/logo.ts
17383
17830
  var import_chalk = __toESM(require("chalk"));
@@ -18807,6 +19254,210 @@ function cloneCommand2(program2) {
18807
19254
  });
18808
19255
  }
18809
19256
 
19257
+ // src/commands/clean.ts
19258
+ var import_chalk26 = __toESM(require("chalk"));
19259
+ var import_inquirer18 = __toESM(require("inquirer"));
19260
+ init_dist4();
19261
+ function formatBytes2(bytes) {
19262
+ if (bytes < 1024) return `${bytes} B`;
19263
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
19264
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
19265
+ }
19266
+ function displayAnalysis() {
19267
+ try {
19268
+ console.log(import_chalk26.default.bold("\n\u{1F4CA} \u5206\u6790 ~/.claude.json\n"));
19269
+ const analysis = analyzeClaudeJson();
19270
+ console.log(import_chalk26.default.cyan("\u6587\u4EF6\u5927\u5C0F:"), import_chalk26.default.bold(analysis.fileSizeFormatted));
19271
+ console.log();
19272
+ console.log(import_chalk26.default.cyan("\u9879\u76EE\u7EDF\u8BA1:"));
19273
+ console.log(` \u9879\u76EE\u603B\u6570: ${import_chalk26.default.bold(analysis.projectCount)}`);
19274
+ console.log(` \u5386\u53F2\u8BB0\u5F55\u603B\u6570: ${import_chalk26.default.bold(analysis.totalHistoryCount)} \u6761`);
19275
+ console.log();
19276
+ console.log(import_chalk26.default.cyan("\u5386\u53F2\u8BB0\u5F55\u6700\u591A\u7684\u9879\u76EE:"));
19277
+ const top5 = analysis.projectHistory.slice(0, 5);
19278
+ for (const project of top5) {
19279
+ const displayPath = project.path.length > 50 ? "..." + project.path.slice(-47) : project.path;
19280
+ console.log(` ${import_chalk26.default.bold(project.count.toString().padStart(3))} \u6761 ${displayPath}`);
19281
+ }
19282
+ console.log();
19283
+ console.log(import_chalk26.default.cyan("\u9884\u8BA1\u53EF\u8282\u7701\u7A7A\u95F4:"));
19284
+ console.log(` ${import_chalk26.default.green("\u4FDD\u5B88\u6E05\u7406")} (\u4FDD\u755910\u6761): ${import_chalk26.default.bold(formatBytes2(analysis.estimatedSavings.conservative))}`);
19285
+ console.log(` ${import_chalk26.default.yellow("\u4E2D\u7B49\u6E05\u7406")} (\u4FDD\u75595\u6761): ${import_chalk26.default.bold(formatBytes2(analysis.estimatedSavings.moderate))}`);
19286
+ console.log(` ${import_chalk26.default.red("\u6FC0\u8FDB\u6E05\u7406")} (\u6E05\u7A7A\u5386\u53F2): ${import_chalk26.default.bold(formatBytes2(analysis.estimatedSavings.aggressive))}`);
19287
+ console.log();
19288
+ console.log(import_chalk26.default.blue(`\u{1F4A1} \u6267\u884C\u6E05\u7406: ccman cc clean
19289
+ `));
19290
+ } catch (error) {
19291
+ console.error(import_chalk26.default.red(`
19292
+ \u274C ${error.message}
19293
+ `));
19294
+ process.exit(1);
19295
+ }
19296
+ }
19297
+ function cleanAnalyzeCommand(program2) {
19298
+ program2.command("clean:analyze").description("\u5206\u6790 ~/.claude.json \u6587\u4EF6\u5927\u5C0F\u548C\u5360\u7528").action(() => {
19299
+ displayAnalysis();
19300
+ });
19301
+ }
19302
+ function cleanCommand(program2) {
19303
+ program2.command("clean").description("\u6E05\u7406 ~/.claude.json \u6587\u4EF6\uFF08\u5386\u53F2\u8BB0\u5F55\u3001\u7F13\u5B58\u7B49\uFF09").option("--preset <type>", "\u4F7F\u7528\u9884\u8BBE\u65B9\u6848 (conservative|moderate|aggressive)").option("--keep <count>", "\u4FDD\u7559\u6700\u8FD1N\u6761\u5386\u53F2\u8BB0\u5F55").option("--cache", "\u6E05\u7406\u7F13\u5B58\u6570\u636E").option("--stats", "\u91CD\u7F6E\u4F7F\u7528\u7EDF\u8BA1").option("--projects <paths>", "\u53EA\u6E05\u7406\u6307\u5B9A\u9879\u76EE\uFF08\u9017\u53F7\u5206\u9694\uFF09").action(async (options) => {
19304
+ try {
19305
+ console.log(import_chalk26.default.bold("\n\u{1F9F9} \u6E05\u7406 ~/.claude.json\n"));
19306
+ const analysis = analyzeClaudeJson();
19307
+ console.log(`\u5F53\u524D\u6587\u4EF6\u5927\u5C0F: ${import_chalk26.default.bold(analysis.fileSizeFormatted)}`);
19308
+ console.log(`\u9879\u76EE\u6570: ${analysis.projectCount}, \u5386\u53F2\u8BB0\u5F55: ${analysis.totalHistoryCount} \u6761`);
19309
+ console.log();
19310
+ let cleanOptions;
19311
+ if (options.preset || options.keep || options.cache || options.stats || options.projects) {
19312
+ cleanOptions = buildOptionsFromArgs(options);
19313
+ } else {
19314
+ cleanOptions = await promptForOptions(analysis);
19315
+ }
19316
+ const { confirmed } = await import_inquirer18.default.prompt([
19317
+ {
19318
+ type: "confirm",
19319
+ name: "confirmed",
19320
+ message: "\u786E\u8BA4\u6267\u884C\u6E05\u7406\uFF1F\uFF08\u4F1A\u81EA\u52A8\u5907\u4EFD\u539F\u6587\u4EF6\uFF09",
19321
+ default: true
19322
+ }
19323
+ ]);
19324
+ if (!confirmed) {
19325
+ console.log(import_chalk26.default.yellow("\n\u274C \u5DF2\u53D6\u6D88\n"));
19326
+ return;
19327
+ }
19328
+ console.log(import_chalk26.default.cyan("\n\u6B63\u5728\u6E05\u7406...\n"));
19329
+ const result = cleanClaudeJson(cleanOptions);
19330
+ console.log(import_chalk26.default.green("\u2705 \u6E05\u7406\u5B8C\u6210\n"));
19331
+ console.log(`\u6E05\u7406\u524D: ${import_chalk26.default.bold(formatBytes2(result.sizeBefore))}`);
19332
+ console.log(`\u6E05\u7406\u540E: ${import_chalk26.default.bold(formatBytes2(result.sizeAfter))}`);
19333
+ console.log(`\u8282\u7701\u7A7A\u95F4: ${import_chalk26.default.green.bold(formatBytes2(result.saved))} (${(result.saved / result.sizeBefore * 100).toFixed(1)}%)`);
19334
+ console.log();
19335
+ if (result.cleanedItems.projectHistory > 0) {
19336
+ console.log(`\u6E05\u7406\u5386\u53F2\u8BB0\u5F55: ${import_chalk26.default.bold(result.cleanedItems.projectHistory)} \u6761`);
19337
+ }
19338
+ if (result.cleanedItems.cache) {
19339
+ console.log(`\u6E05\u7406\u7F13\u5B58: ${import_chalk26.default.green("\u2713")}`);
19340
+ }
19341
+ if (result.cleanedItems.stats) {
19342
+ console.log(`\u91CD\u7F6E\u7EDF\u8BA1: ${import_chalk26.default.green("\u2713")}`);
19343
+ }
19344
+ console.log();
19345
+ console.log(`\u5907\u4EFD\u6587\u4EF6: ${import_chalk26.default.cyan(result.backupPath)}`);
19346
+ console.log();
19347
+ } catch (error) {
19348
+ console.error(import_chalk26.default.red(`
19349
+ \u274C ${error.message}
19350
+ `));
19351
+ process.exit(1);
19352
+ }
19353
+ });
19354
+ }
19355
+ function buildOptionsFromArgs(args) {
19356
+ if (args.preset) {
19357
+ const preset = args.preset.toLowerCase();
19358
+ if (preset === "conservative") {
19359
+ return CleanPresets.conservative();
19360
+ } else if (preset === "moderate") {
19361
+ return CleanPresets.moderate();
19362
+ } else if (preset === "aggressive") {
19363
+ return CleanPresets.aggressive();
19364
+ } else {
19365
+ throw new Error(`\u672A\u77E5\u7684\u9884\u8BBE\u65B9\u6848: ${preset}\u3002\u53EF\u7528: conservative, moderate, aggressive`);
19366
+ }
19367
+ }
19368
+ const options = {};
19369
+ if (args.keep !== void 0) {
19370
+ options.cleanProjectHistory = true;
19371
+ options.keepRecentCount = parseInt(args.keep, 10);
19372
+ if (isNaN(options.keepRecentCount)) {
19373
+ throw new Error("--keep \u53C2\u6570\u5FC5\u987B\u662F\u6570\u5B57");
19374
+ }
19375
+ }
19376
+ if (args.cache) {
19377
+ options.cleanCache = true;
19378
+ }
19379
+ if (args.stats) {
19380
+ options.cleanStats = true;
19381
+ }
19382
+ if (args.projects) {
19383
+ options.projectPaths = args.projects.split(",").map((p) => p.trim());
19384
+ }
19385
+ if (!options.cleanProjectHistory && !options.cleanCache && !options.cleanStats) {
19386
+ console.log(import_chalk26.default.yellow("\u672A\u6307\u5B9A\u6E05\u7406\u9009\u9879\uFF0C\u4F7F\u7528\u4FDD\u5B88\u9884\u8BBE\n"));
19387
+ return CleanPresets.conservative();
19388
+ }
19389
+ return options;
19390
+ }
19391
+ async function promptForOptions(analysis) {
19392
+ const answers = await import_inquirer18.default.prompt([
19393
+ {
19394
+ type: "list",
19395
+ name: "preset",
19396
+ message: "\u9009\u62E9\u6E05\u7406\u65B9\u6848:",
19397
+ choices: [
19398
+ {
19399
+ name: `${import_chalk26.default.green("\u4FDD\u5B88\u6E05\u7406")} - \u4FDD\u7559\u6700\u8FD110\u6761\u8BB0\u5F55\uFF0C\u6E05\u7406\u7F13\u5B58 (\u8282\u7701\u7EA6 ${formatBytes2(analysis.estimatedSavings.conservative)})`,
19400
+ value: "conservative"
19401
+ },
19402
+ {
19403
+ name: `${import_chalk26.default.yellow("\u4E2D\u7B49\u6E05\u7406")} - \u4FDD\u7559\u6700\u8FD15\u6761\u8BB0\u5F55\uFF0C\u6E05\u7406\u7F13\u5B58\u548C\u7EDF\u8BA1 (\u8282\u7701\u7EA6 ${formatBytes2(analysis.estimatedSavings.moderate)})`,
19404
+ value: "moderate"
19405
+ },
19406
+ {
19407
+ name: `${import_chalk26.default.red("\u6FC0\u8FDB\u6E05\u7406")} - \u6E05\u7A7A\u5386\u53F2\u8BB0\u5F55\uFF0C\u6E05\u7406\u7F13\u5B58\u548C\u7EDF\u8BA1 (\u8282\u7701\u7EA6 ${formatBytes2(analysis.estimatedSavings.aggressive)})`,
19408
+ value: "aggressive"
19409
+ },
19410
+ {
19411
+ name: `${import_chalk26.default.cyan("\u81EA\u5B9A\u4E49")} - \u81EA\u5B9A\u4E49\u6E05\u7406\u9009\u9879`,
19412
+ value: "custom"
19413
+ }
19414
+ ]
19415
+ }
19416
+ ]);
19417
+ if (answers.preset !== "custom") {
19418
+ if (answers.preset === "conservative") {
19419
+ return CleanPresets.conservative();
19420
+ } else if (answers.preset === "moderate") {
19421
+ return CleanPresets.moderate();
19422
+ } else {
19423
+ return CleanPresets.aggressive();
19424
+ }
19425
+ }
19426
+ const customAnswers = await import_inquirer18.default.prompt([
19427
+ {
19428
+ type: "confirm",
19429
+ name: "cleanHistory",
19430
+ message: "\u6E05\u7406\u9879\u76EE\u5386\u53F2\u8BB0\u5F55\uFF1F",
19431
+ default: true
19432
+ },
19433
+ {
19434
+ type: "number",
19435
+ name: "keepCount",
19436
+ message: "\u6BCF\u4E2A\u9879\u76EE\u4FDD\u7559\u6700\u8FD1\u591A\u5C11\u6761\u8BB0\u5F55\uFF1F",
19437
+ default: 10,
19438
+ when: (answers2) => answers2.cleanHistory
19439
+ },
19440
+ {
19441
+ type: "confirm",
19442
+ name: "cleanCache",
19443
+ message: "\u6E05\u7406\u7F13\u5B58\u6570\u636E\uFF1F",
19444
+ default: true
19445
+ },
19446
+ {
19447
+ type: "confirm",
19448
+ name: "cleanStats",
19449
+ message: "\u91CD\u7F6E\u4F7F\u7528\u7EDF\u8BA1\uFF1F",
19450
+ default: false
19451
+ }
19452
+ ]);
19453
+ return {
19454
+ cleanProjectHistory: customAnswers.cleanHistory,
19455
+ keepRecentCount: customAnswers.keepCount || 0,
19456
+ cleanCache: customAnswers.cleanCache,
19457
+ cleanStats: customAnswers.cleanStats
19458
+ };
19459
+ }
19460
+
18810
19461
  // src/commands/claude/index.ts
18811
19462
  function createClaudeCommands(program2) {
18812
19463
  addCommand2(program2);
@@ -18816,46 +19467,449 @@ function createClaudeCommands(program2) {
18816
19467
  removeCommand2(program2);
18817
19468
  editCommand2(program2);
18818
19469
  cloneCommand2(program2);
19470
+ cleanAnalyzeCommand(program2);
19471
+ cleanCommand(program2);
19472
+ }
19473
+
19474
+ // src/commands/mcp/add.ts
19475
+ var import_chalk27 = __toESM(require("chalk"));
19476
+ var import_inquirer19 = __toESM(require("inquirer"));
19477
+ init_dist4();
19478
+ function addCommand3(program2) {
19479
+ program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 MCP \u670D\u52A1\u5668(\u4EA4\u4E92\u5F0F)").action(async () => {
19480
+ try {
19481
+ const manager = createMCPManager();
19482
+ console.log(import_chalk27.default.bold("\n\u{1F4DD} \u6DFB\u52A0 MCP \u670D\u52A1\u5668\n"));
19483
+ const { usePreset } = await import_inquirer19.default.prompt([
19484
+ {
19485
+ type: "list",
19486
+ name: "usePreset",
19487
+ message: "\u9009\u62E9\u914D\u7F6E\u6765\u6E90:",
19488
+ choices: [
19489
+ { name: "\u{1F4E6} \u4F7F\u7528\u9884\u7F6E MCP \u670D\u52A1\u5668", value: true },
19490
+ { name: "\u270F\uFE0F \u81EA\u5B9A\u4E49\u914D\u7F6E", value: false }
19491
+ ]
19492
+ }
19493
+ ]);
19494
+ let name;
19495
+ let command;
19496
+ let args;
19497
+ let env;
19498
+ if (usePreset) {
19499
+ const { presetName } = await import_inquirer19.default.prompt([
19500
+ {
19501
+ type: "list",
19502
+ name: "presetName",
19503
+ message: "\u9009\u62E9\u9884\u7F6E MCP \u670D\u52A1\u5668:",
19504
+ choices: MCP_PRESETS_DETAIL.map((p) => ({
19505
+ name: `${p.name} - ${p.description}`,
19506
+ value: p.name
19507
+ }))
19508
+ }
19509
+ ]);
19510
+ const preset = MCP_PRESETS_DETAIL.find((p) => p.name === presetName);
19511
+ console.log(import_chalk27.default.blue(`
19512
+ \u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
19513
+ `));
19514
+ if (preset.argsPlaceholder) {
19515
+ console.log(import_chalk27.default.yellow(`\u26A0\uFE0F ${preset.argsPlaceholder}
19516
+ `));
19517
+ }
19518
+ if (preset.envRequired && preset.envRequired.length > 0) {
19519
+ console.log(import_chalk27.default.yellow(`\u26A0\uFE0F \u9700\u8981\u914D\u7F6E\u73AF\u5883\u53D8\u91CF: ${preset.envRequired.join(", ")}
19520
+ `));
19521
+ }
19522
+ const input = await import_inquirer19.default.prompt([
19523
+ {
19524
+ type: "input",
19525
+ name: "name",
19526
+ message: "MCP \u670D\u52A1\u5668\u540D\u79F0:",
19527
+ default: preset.name,
19528
+ validate: (value) => {
19529
+ if (!value) return "\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";
19530
+ return true;
19531
+ }
19532
+ },
19533
+ {
19534
+ type: "input",
19535
+ name: "command",
19536
+ message: "\u542F\u52A8\u547D\u4EE4:",
19537
+ default: preset.command,
19538
+ validate: (value) => {
19539
+ if (!value) return "\u547D\u4EE4\u4E0D\u80FD\u4E3A\u7A7A";
19540
+ return true;
19541
+ }
19542
+ },
19543
+ {
19544
+ type: "input",
19545
+ name: "args",
19546
+ message: "\u547D\u4EE4\u53C2\u6570 (\u7A7A\u683C\u5206\u9694):",
19547
+ default: preset.args.join(" "),
19548
+ validate: (value) => {
19549
+ if (!value) return "\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A";
19550
+ return true;
19551
+ }
19552
+ },
19553
+ {
19554
+ type: "input",
19555
+ name: "env",
19556
+ message: '\u73AF\u5883\u53D8\u91CF (JSON \u683C\u5F0F, \u5982 {"API_KEY": "xxx"}, \u53EF\u7559\u7A7A):',
19557
+ default: ""
19558
+ }
19559
+ ]);
19560
+ name = input.name;
19561
+ command = input.command;
19562
+ args = input.args.split(" ").filter((arg) => arg.length > 0);
19563
+ env = input.env ? JSON.parse(input.env) : void 0;
19564
+ } else {
19565
+ const answers = await import_inquirer19.default.prompt([
19566
+ {
19567
+ type: "input",
19568
+ name: "name",
19569
+ message: "MCP \u670D\u52A1\u5668\u540D\u79F0:",
19570
+ validate: (value) => {
19571
+ if (!value) return "\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";
19572
+ return true;
19573
+ }
19574
+ },
19575
+ {
19576
+ type: "input",
19577
+ name: "command",
19578
+ message: "\u542F\u52A8\u547D\u4EE4 (\u5982 npx, node, python):",
19579
+ default: "npx",
19580
+ validate: (value) => {
19581
+ if (!value) return "\u547D\u4EE4\u4E0D\u80FD\u4E3A\u7A7A";
19582
+ return true;
19583
+ }
19584
+ },
19585
+ {
19586
+ type: "input",
19587
+ name: "args",
19588
+ message: "\u547D\u4EE4\u53C2\u6570 (\u7A7A\u683C\u5206\u9694):",
19589
+ validate: (value) => {
19590
+ if (!value) return "\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A";
19591
+ return true;
19592
+ }
19593
+ },
19594
+ {
19595
+ type: "input",
19596
+ name: "env",
19597
+ message: '\u73AF\u5883\u53D8\u91CF (JSON \u683C\u5F0F, \u5982 {"API_KEY": "xxx"}, \u53EF\u7559\u7A7A):',
19598
+ default: ""
19599
+ }
19600
+ ]);
19601
+ name = answers.name;
19602
+ command = answers.command;
19603
+ args = answers.args.split(" ").filter((arg) => arg.length > 0);
19604
+ env = answers.env ? JSON.parse(answers.env) : void 0;
19605
+ }
19606
+ const provider = manager.add({
19607
+ name,
19608
+ baseUrl: command,
19609
+ apiKey: args.join(" "),
19610
+ model: env ? JSON.stringify(env) : void 0
19611
+ });
19612
+ console.log();
19613
+ console.log(import_chalk27.default.green("\u2705 MCP \u670D\u52A1\u5668\u6DFB\u52A0\u6210\u529F"));
19614
+ console.log();
19615
+ console.log(` ${import_chalk27.default.bold(provider.name)} ${import_chalk27.default.blue("[MCP]")}`);
19616
+ console.log(` ${import_chalk27.default.gray(`${command} ${args.join(" ")}`)}`);
19617
+ if (env) {
19618
+ console.log(import_chalk27.default.gray(` \u73AF\u5883\u53D8\u91CF: ${Object.keys(env).join(", ")}`));
19619
+ }
19620
+ console.log();
19621
+ console.log(import_chalk27.default.green("\u2705 \u914D\u7F6E\u5DF2\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
19622
+ console.log();
19623
+ console.log(import_chalk27.default.gray("\u914D\u7F6E\u6587\u4EF6:"));
19624
+ console.log(import_chalk27.default.gray(` - ${getClaudeConfigPath()}`));
19625
+ console.log();
19626
+ } catch (error) {
19627
+ console.error(import_chalk27.default.red(`
19628
+ \u274C ${error.message}
19629
+ `));
19630
+ process.exit(1);
19631
+ }
19632
+ });
19633
+ }
19634
+
19635
+ // src/commands/mcp/list.ts
19636
+ var import_chalk28 = __toESM(require("chalk"));
19637
+ init_dist4();
19638
+ function listCommand3(program2) {
19639
+ program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 MCP \u670D\u52A1\u5668").action(async () => {
19640
+ try {
19641
+ const manager = createMCPManager();
19642
+ const providers = manager.list();
19643
+ if (providers.length === 0) {
19644
+ console.log(import_chalk28.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 MCP \u670D\u52A1\u5668\n"));
19645
+ console.log(import_chalk28.default.blue("\u{1F4A1} \u6DFB\u52A0 MCP \u670D\u52A1\u5668:") + import_chalk28.default.white(" ccman mcp add\n"));
19646
+ return;
19647
+ }
19648
+ console.log(import_chalk28.default.bold(`
19649
+ \u{1F4CB} MCP \u670D\u52A1\u5668 (${providers.length} \u4E2A)
19650
+ `));
19651
+ providers.forEach((provider) => {
19652
+ const isActive = false;
19653
+ const indicator = isActive ? import_chalk28.default.green("\u25CF") : import_chalk28.default.gray("\u25CB");
19654
+ const nameDisplay = import_chalk28.default.bold(provider.name);
19655
+ const commandDisplay = import_chalk28.default.gray(`${provider.baseUrl} ${provider.apiKey}`);
19656
+ console.log(` ${indicator} ${nameDisplay}`);
19657
+ console.log(` ${commandDisplay}`);
19658
+ if (provider.model) {
19659
+ try {
19660
+ const env = JSON.parse(provider.model);
19661
+ const envKeys = Object.keys(env);
19662
+ if (envKeys.length > 0) {
19663
+ console.log(import_chalk28.default.gray(` \u73AF\u5883\u53D8\u91CF: ${envKeys.join(", ")}`));
19664
+ }
19665
+ } catch {
19666
+ }
19667
+ }
19668
+ console.log();
19669
+ });
19670
+ console.log(import_chalk28.default.gray("\u63D0\u793A: \u6240\u6709\u914D\u7F6E\u7684 MCP \u670D\u52A1\u5668\u4F1A\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
19671
+ console.log();
19672
+ } catch (error) {
19673
+ console.error(import_chalk28.default.red(`
19674
+ \u274C ${error.message}
19675
+ `));
19676
+ process.exit(1);
19677
+ }
19678
+ });
19679
+ }
19680
+
19681
+ // src/commands/mcp/remove.ts
19682
+ var import_chalk29 = __toESM(require("chalk"));
19683
+ var import_inquirer20 = __toESM(require("inquirer"));
19684
+ init_dist4();
19685
+ function removeCommand3(program2) {
19686
+ program2.command("remove [name]").alias("rm").description("\u5220\u9664 MCP \u670D\u52A1\u5668").action(async (name) => {
19687
+ try {
19688
+ const manager = createMCPManager();
19689
+ const providers = manager.list();
19690
+ if (providers.length === 0) {
19691
+ console.log(import_chalk29.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 MCP \u670D\u52A1\u5668\n"));
19692
+ return;
19693
+ }
19694
+ let targetId;
19695
+ let targetName;
19696
+ if (name) {
19697
+ const provider = manager.findByName(name);
19698
+ if (!provider) {
19699
+ throw new ProviderNotFoundError(name);
19700
+ }
19701
+ targetId = provider.id;
19702
+ targetName = provider.name;
19703
+ } else {
19704
+ const { selectedId } = await import_inquirer20.default.prompt([
19705
+ {
19706
+ type: "list",
19707
+ name: "selectedId",
19708
+ message: "\u9009\u62E9\u8981\u5220\u9664\u7684 MCP \u670D\u52A1\u5668:",
19709
+ choices: providers.map((p) => ({
19710
+ name: `${p.name} - ${p.baseUrl} ${p.apiKey}`,
19711
+ value: p.id
19712
+ }))
19713
+ }
19714
+ ]);
19715
+ const provider = manager.get(selectedId);
19716
+ targetId = selectedId;
19717
+ targetName = provider.name;
19718
+ }
19719
+ const { confirmed } = await import_inquirer20.default.prompt([
19720
+ {
19721
+ type: "confirm",
19722
+ name: "confirmed",
19723
+ message: `\u786E\u5B9A\u5220\u9664 "${targetName}"?`,
19724
+ default: false
19725
+ }
19726
+ ]);
19727
+ if (!confirmed) {
19728
+ console.log(import_chalk29.default.gray("\n\u5DF2\u53D6\u6D88\n"));
19729
+ return;
19730
+ }
19731
+ manager.remove(targetId);
19732
+ console.log();
19733
+ console.log(import_chalk29.default.green(`\u2705 \u5DF2\u5220\u9664: ${targetName}`));
19734
+ console.log();
19735
+ console.log(import_chalk29.default.green("\u2705 \u914D\u7F6E\u5DF2\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
19736
+ console.log();
19737
+ console.log(import_chalk29.default.gray("\u914D\u7F6E\u6587\u4EF6:"));
19738
+ console.log(import_chalk29.default.gray(` - ${getClaudeConfigPath()}`));
19739
+ console.log();
19740
+ } catch (error) {
19741
+ if (error instanceof ProviderNotFoundError) {
19742
+ console.error(import_chalk29.default.red(`
19743
+ \u274C MCP \u670D\u52A1\u5668\u4E0D\u5B58\u5728
19744
+ `));
19745
+ console.log(import_chalk29.default.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709 MCP \u670D\u52A1\u5668:") + import_chalk29.default.white(" ccman mcp list\n"));
19746
+ } else {
19747
+ console.error(import_chalk29.default.red(`
19748
+ \u274C ${error.message}
19749
+ `));
19750
+ }
19751
+ process.exit(1);
19752
+ }
19753
+ });
19754
+ }
19755
+
19756
+ // src/commands/mcp/edit.ts
19757
+ var import_chalk30 = __toESM(require("chalk"));
19758
+ var import_inquirer21 = __toESM(require("inquirer"));
19759
+ init_dist4();
19760
+ function editCommand3(program2) {
19761
+ program2.command("edit [name]").description("\u7F16\u8F91 MCP \u670D\u52A1\u5668").action(async (name) => {
19762
+ try {
19763
+ const manager = createMCPManager();
19764
+ const providers = manager.list();
19765
+ if (providers.length === 0) {
19766
+ console.log(import_chalk30.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 MCP \u670D\u52A1\u5668\n"));
19767
+ return;
19768
+ }
19769
+ let targetId;
19770
+ if (name) {
19771
+ const provider2 = manager.findByName(name);
19772
+ if (!provider2) {
19773
+ throw new ProviderNotFoundError(name);
19774
+ }
19775
+ targetId = provider2.id;
19776
+ } else {
19777
+ const { selectedId } = await import_inquirer21.default.prompt([
19778
+ {
19779
+ type: "list",
19780
+ name: "selectedId",
19781
+ message: "\u9009\u62E9\u8981\u7F16\u8F91\u7684 MCP \u670D\u52A1\u5668:",
19782
+ choices: providers.map((p) => ({
19783
+ name: `${p.name} - ${p.baseUrl} ${p.apiKey}`,
19784
+ value: p.id
19785
+ }))
19786
+ }
19787
+ ]);
19788
+ targetId = selectedId;
19789
+ }
19790
+ const provider = manager.get(targetId);
19791
+ const currentCommand3 = provider.baseUrl;
19792
+ const currentArgs = provider.apiKey;
19793
+ const currentEnv = provider.model;
19794
+ console.log(import_chalk30.default.bold("\n\u270F\uFE0F \u7F16\u8F91 MCP \u670D\u52A1\u5668\n"));
19795
+ console.log(import_chalk30.default.gray("\u63D0\u793A: \u7559\u7A7A\u5219\u4FDD\u6301\u539F\u503C\n"));
19796
+ const answers = await import_inquirer21.default.prompt([
19797
+ {
19798
+ type: "input",
19799
+ name: "name",
19800
+ message: "MCP \u670D\u52A1\u5668\u540D\u79F0:",
19801
+ default: provider.name
19802
+ },
19803
+ {
19804
+ type: "input",
19805
+ name: "command",
19806
+ message: "\u542F\u52A8\u547D\u4EE4:",
19807
+ default: currentCommand3
19808
+ },
19809
+ {
19810
+ type: "input",
19811
+ name: "args",
19812
+ message: "\u547D\u4EE4\u53C2\u6570 (\u7A7A\u683C\u5206\u9694, \u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8):",
19813
+ default: currentArgs
19814
+ },
19815
+ {
19816
+ type: "input",
19817
+ name: "env",
19818
+ message: "\u73AF\u5883\u53D8\u91CF (JSON \u683C\u5F0F, \u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8):",
19819
+ default: currentEnv || ""
19820
+ }
19821
+ ]);
19822
+ const updates = {};
19823
+ if (answers.name && answers.name !== provider.name) {
19824
+ updates.name = answers.name;
19825
+ }
19826
+ if (answers.command && answers.command !== currentCommand3) {
19827
+ updates.baseUrl = answers.command;
19828
+ }
19829
+ if (answers.args && answers.args !== currentArgs) {
19830
+ updates.apiKey = answers.args;
19831
+ }
19832
+ if (answers.env !== currentEnv) {
19833
+ updates.model = answers.env || void 0;
19834
+ }
19835
+ if (Object.keys(updates).length === 0) {
19836
+ console.log(import_chalk30.default.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
19837
+ return;
19838
+ }
19839
+ const updated = manager.edit(targetId, updates);
19840
+ console.log();
19841
+ console.log(import_chalk30.default.green("\u2705 \u7F16\u8F91\u6210\u529F"));
19842
+ console.log();
19843
+ console.log(` ${import_chalk30.default.bold(updated.name)} ${import_chalk30.default.blue("[MCP]")}`);
19844
+ console.log(` ${import_chalk30.default.gray(`\u547D\u4EE4: ${updated.baseUrl} ${updated.apiKey}`)}`);
19845
+ if (updated.model) {
19846
+ try {
19847
+ const env = JSON.parse(updated.model);
19848
+ console.log(import_chalk30.default.gray(` \u73AF\u5883\u53D8\u91CF: ${Object.keys(env).join(", ")}`));
19849
+ } catch {
19850
+ }
19851
+ }
19852
+ console.log();
19853
+ console.log(import_chalk30.default.green("\u2705 \u914D\u7F6E\u5DF2\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
19854
+ console.log();
19855
+ console.log(import_chalk30.default.gray("\u914D\u7F6E\u6587\u4EF6:"));
19856
+ console.log(import_chalk30.default.gray(` - ${getClaudeConfigPath()}`));
19857
+ console.log();
19858
+ } catch (error) {
19859
+ console.error(import_chalk30.default.red(`
19860
+ \u274C ${error.message}
19861
+ `));
19862
+ process.exit(1);
19863
+ }
19864
+ });
19865
+ }
19866
+
19867
+ // src/commands/mcp/index.ts
19868
+ function createMCPCommands(program2) {
19869
+ addCommand3(program2);
19870
+ listCommand3(program2);
19871
+ removeCommand3(program2);
19872
+ editCommand3(program2);
18819
19873
  }
18820
19874
 
18821
19875
  // src/index.ts
18822
19876
  init_sync();
18823
19877
 
18824
19878
  // src/commands/export.ts
18825
- var import_chalk26 = __toESM(require("chalk"));
19879
+ var import_chalk31 = __toESM(require("chalk"));
18826
19880
  var import_path19 = __toESM(require("path"));
18827
19881
  init_dist4();
18828
19882
  function exportCommand(program2) {
18829
19883
  program2.command("export <\u76EE\u6807\u76EE\u5F55>").description("\u5BFC\u51FA\u914D\u7F6E\u5230\u672C\u5730\u76EE\u5F55\uFF08\u5305\u542B API Key\uFF09").action(async (targetDir) => {
18830
19884
  try {
18831
- console.log(import_chalk26.default.bold("\n\u{1F4E6} \u5BFC\u51FA\u914D\u7F6E\n"));
19885
+ console.log(import_chalk31.default.bold("\n\u{1F4E6} \u5BFC\u51FA\u914D\u7F6E\n"));
18832
19886
  const validation = validateExport();
18833
19887
  if (!validation.valid) {
18834
- console.log(import_chalk26.default.red(`\u274C ${validation.message}
19888
+ console.log(import_chalk31.default.red(`\u274C ${validation.message}
18835
19889
  `));
18836
19890
  process.exit(1);
18837
19891
  }
18838
19892
  const resolvedPath = targetDir.startsWith("~") ? import_path19.default.join(process.env.HOME || "", targetDir.slice(1)) : import_path19.default.resolve(targetDir);
18839
19893
  console.log("\u5BFC\u51FA\u6587\u4EF6:");
18840
- console.log(` ${import_chalk26.default.cyan("codex.json")} - Codex \u914D\u7F6E`);
18841
- console.log(` ${import_chalk26.default.cyan("claude.json")} - Claude \u914D\u7F6E`);
19894
+ console.log(` ${import_chalk31.default.cyan("codex.json")} - Codex \u914D\u7F6E`);
19895
+ console.log(` ${import_chalk31.default.cyan("claude.json")} - Claude \u914D\u7F6E`);
18842
19896
  console.log();
18843
- console.log(`\u76EE\u6807\u76EE\u5F55: ${import_chalk26.default.cyan(resolvedPath)}`);
19897
+ console.log(`\u76EE\u6807\u76EE\u5F55: ${import_chalk31.default.cyan(resolvedPath)}`);
18844
19898
  console.log();
18845
- console.log(import_chalk26.default.yellow("\u26A0\uFE0F \u5BFC\u51FA\u6587\u4EF6\u5305\u542B API Key\uFF0C\u8BF7\u59A5\u5584\u4FDD\u7BA1"));
19899
+ console.log(import_chalk31.default.yellow("\u26A0\uFE0F \u5BFC\u51FA\u6587\u4EF6\u5305\u542B API Key\uFF0C\u8BF7\u59A5\u5584\u4FDD\u7BA1"));
18846
19900
  console.log();
18847
19901
  const result = exportConfig(resolvedPath);
18848
- console.log(import_chalk26.default.green("\u2705 \u5BFC\u51FA\u6210\u529F"));
19902
+ console.log(import_chalk31.default.green("\u2705 \u5BFC\u51FA\u6210\u529F"));
18849
19903
  console.log();
18850
19904
  console.log("\u5DF2\u5BFC\u51FA\u6587\u4EF6:");
18851
19905
  for (const file of result.exportedFiles) {
18852
- console.log(` ${import_chalk26.default.cyan("\u2713")} ${file}`);
19906
+ console.log(` ${import_chalk31.default.cyan("\u2713")} ${file}`);
18853
19907
  }
18854
19908
  console.log();
18855
- console.log(import_chalk26.default.blue(`\u{1F4A1} \u5BFC\u5165\u547D\u4EE4: ccman import ${resolvedPath}
19909
+ console.log(import_chalk31.default.blue(`\u{1F4A1} \u5BFC\u5165\u547D\u4EE4: ccman import ${resolvedPath}
18856
19910
  `));
18857
19911
  } catch (error) {
18858
- console.error(import_chalk26.default.red(`
19912
+ console.error(import_chalk31.default.red(`
18859
19913
  \u274C ${error.message}
18860
19914
  `));
18861
19915
  process.exit(1);
@@ -18864,32 +19918,32 @@ function exportCommand(program2) {
18864
19918
  }
18865
19919
 
18866
19920
  // src/commands/import.ts
18867
- var import_chalk27 = __toESM(require("chalk"));
18868
- var import_inquirer18 = __toESM(require("inquirer"));
19921
+ var import_chalk32 = __toESM(require("chalk"));
19922
+ var import_inquirer22 = __toESM(require("inquirer"));
18869
19923
  var import_path20 = __toESM(require("path"));
18870
19924
  init_dist4();
18871
19925
  function importCommand(program2) {
18872
19926
  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) => {
18873
19927
  try {
18874
19928
  const resolvedPath = sourceDir.startsWith("~") ? import_path20.default.join(process.env.HOME || "", sourceDir.slice(1)) : import_path20.default.resolve(sourceDir);
18875
- console.log(import_chalk27.default.bold("\n\u{1F4E5} \u5BFC\u5165\u914D\u7F6E\n"));
19929
+ console.log(import_chalk32.default.bold("\n\u{1F4E5} \u5BFC\u5165\u914D\u7F6E\n"));
18876
19930
  const validation = validateImportDir(resolvedPath);
18877
19931
  if (!validation.valid) {
18878
- console.log(import_chalk27.default.red(`\u274C ${validation.message}
19932
+ console.log(import_chalk32.default.red(`\u274C ${validation.message}
18879
19933
  `));
18880
19934
  process.exit(1);
18881
19935
  }
18882
- console.log(import_chalk27.default.yellow("\u26A0\uFE0F \u8B66\u544A\uFF1A\u5BFC\u5165\u5C06\u8986\u76D6\u5F53\u524D\u914D\u7F6E\n"));
18883
- console.log(`\u6E90\u76EE\u5F55: ${import_chalk27.default.cyan(resolvedPath)}`);
19936
+ console.log(import_chalk32.default.yellow("\u26A0\uFE0F \u8B66\u544A\uFF1A\u5BFC\u5165\u5C06\u8986\u76D6\u5F53\u524D\u914D\u7F6E\n"));
19937
+ console.log(`\u6E90\u76EE\u5F55: ${import_chalk32.default.cyan(resolvedPath)}`);
18884
19938
  console.log();
18885
19939
  console.log("\u627E\u5230\u914D\u7F6E\u6587\u4EF6:");
18886
19940
  for (const file of validation.foundFiles) {
18887
- console.log(` ${import_chalk27.default.cyan("\u2713")} ${file}`);
19941
+ console.log(` ${import_chalk32.default.cyan("\u2713")} ${file}`);
18888
19942
  }
18889
19943
  console.log();
18890
- console.log(import_chalk27.default.gray("\u5F53\u524D\u914D\u7F6E\u5C06\u88AB\u8986\u76D6\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
19944
+ console.log(import_chalk32.default.gray("\u5F53\u524D\u914D\u7F6E\u5C06\u88AB\u8986\u76D6\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
18891
19945
  console.log();
18892
- const { confirmFirst } = await import_inquirer18.default.prompt([
19946
+ const { confirmFirst } = await import_inquirer22.default.prompt([
18893
19947
  {
18894
19948
  type: "confirm",
18895
19949
  name: "confirmFirst",
@@ -18898,13 +19952,13 @@ function importCommand(program2) {
18898
19952
  }
18899
19953
  ]);
18900
19954
  if (!confirmFirst) {
18901
- console.log(import_chalk27.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
19955
+ console.log(import_chalk32.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
18902
19956
  return;
18903
19957
  }
18904
19958
  console.log();
18905
- console.log(import_chalk27.default.red.bold("\u26A0\uFE0F \u6700\u540E\u786E\u8BA4\uFF1A\u6B64\u64CD\u4F5C\u5C06\u8986\u76D6\u6240\u6709\u5F53\u524D\u914D\u7F6E\uFF01"));
19959
+ console.log(import_chalk32.default.red.bold("\u26A0\uFE0F \u6700\u540E\u786E\u8BA4\uFF1A\u6B64\u64CD\u4F5C\u5C06\u8986\u76D6\u6240\u6709\u5F53\u524D\u914D\u7F6E\uFF01"));
18906
19960
  console.log();
18907
- const { confirmSecond } = await import_inquirer18.default.prompt([
19961
+ const { confirmSecond } = await import_inquirer22.default.prompt([
18908
19962
  {
18909
19963
  type: "confirm",
18910
19964
  name: "confirmSecond",
@@ -18913,31 +19967,31 @@ function importCommand(program2) {
18913
19967
  }
18914
19968
  ]);
18915
19969
  if (!confirmSecond) {
18916
- console.log(import_chalk27.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
19970
+ console.log(import_chalk32.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
18917
19971
  return;
18918
19972
  }
18919
19973
  console.log();
18920
- console.log(import_chalk27.default.gray("\u{1F4BE} \u5907\u4EFD\u5F53\u524D\u914D\u7F6E..."));
18921
- console.log(import_chalk27.default.gray("\u{1F4E5} \u5BFC\u5165\u65B0\u914D\u7F6E..."));
19974
+ console.log(import_chalk32.default.gray("\u{1F4BE} \u5907\u4EFD\u5F53\u524D\u914D\u7F6E..."));
19975
+ console.log(import_chalk32.default.gray("\u{1F4E5} \u5BFC\u5165\u65B0\u914D\u7F6E..."));
18922
19976
  const result = importConfig(resolvedPath);
18923
19977
  console.log();
18924
- console.log(import_chalk27.default.green("\u2705 \u5BFC\u5165\u6210\u529F"));
19978
+ console.log(import_chalk32.default.green("\u2705 \u5BFC\u5165\u6210\u529F"));
18925
19979
  console.log();
18926
19980
  if (result.backupPaths.length > 0) {
18927
19981
  console.log("\u5907\u4EFD\u6587\u4EF6:");
18928
19982
  for (const backupPath of result.backupPaths) {
18929
- console.log(` ${import_chalk27.default.gray(backupPath)}`);
19983
+ console.log(` ${import_chalk32.default.gray(backupPath)}`);
18930
19984
  }
18931
19985
  console.log();
18932
19986
  }
18933
19987
  console.log("\u5DF2\u5BFC\u5165\u6587\u4EF6:");
18934
19988
  for (const file of result.importedFiles) {
18935
- console.log(` ${import_chalk27.default.cyan("\u2713")} ${file}`);
19989
+ console.log(` ${import_chalk32.default.cyan("\u2713")} ${file}`);
18936
19990
  }
18937
19991
  console.log();
18938
- console.log(import_chalk27.default.blue("\u{1F4A1} \u8BF7\u4F7F\u7528 'ccman cx use' \u6216 'ccman cc use' \u5207\u6362\u670D\u52A1\u5546\n"));
19992
+ console.log(import_chalk32.default.blue("\u{1F4A1} \u8BF7\u4F7F\u7528 'ccman cx use' \u6216 'ccman cc use' \u5207\u6362\u670D\u52A1\u5546\n"));
18939
19993
  } catch (error) {
18940
- console.error(import_chalk27.default.red(`
19994
+ console.error(import_chalk32.default.red(`
18941
19995
  \u274C ${error.message}
18942
19996
  `));
18943
19997
  process.exit(1);
@@ -18948,10 +20002,10 @@ function importCommand(program2) {
18948
20002
  // src/index.ts
18949
20003
  init_dist4();
18950
20004
  if (process.env.NODE_ENV === "development") {
18951
- console.log(import_chalk28.default.gray("\n[\u5F00\u53D1\u6A21\u5F0F] \u914D\u7F6E\u76EE\u5F55:"));
18952
- console.log(import_chalk28.default.gray(` ccman: ${getCcmanDir()}`));
18953
- console.log(import_chalk28.default.gray(` codex: ${getCodexDir()}`));
18954
- console.log(import_chalk28.default.gray(` claude: ${getClaudeDir()}`));
20005
+ console.log(import_chalk33.default.gray("\n[\u5F00\u53D1\u6A21\u5F0F] \u914D\u7F6E\u76EE\u5F55:"));
20006
+ console.log(import_chalk33.default.gray(` ccman: ${getCcmanDir()}`));
20007
+ console.log(import_chalk33.default.gray(` codex: ${getCodexDir()}`));
20008
+ console.log(import_chalk33.default.gray(` claude: ${getClaudeDir()}`));
18955
20009
  console.log();
18956
20010
  }
18957
20011
  var program = new import_commander3.Command();
@@ -18963,21 +20017,21 @@ program.name("ccman").description("Codex/Claude Code API \u670D\u52A1\u5546\u914
18963
20017
  });
18964
20018
  program.on("command:*", (operands) => {
18965
20019
  const unknownCommand = operands[0];
18966
- console.error(import_chalk28.default.red(`
20020
+ console.error(import_chalk33.default.red(`
18967
20021
  \u274C \u672A\u77E5\u547D\u4EE4: ${unknownCommand}
18968
20022
  `));
18969
- const availableCommands = ["cx", "cc", "sync", "export", "import"];
20023
+ const availableCommands = ["cx", "cc", "mcp", "sync", "export", "import"];
18970
20024
  const suggestions = availableCommands.filter(
18971
20025
  (cmd) => cmd.includes(unknownCommand) || unknownCommand.includes(cmd)
18972
20026
  );
18973
20027
  if (suggestions.length > 0) {
18974
- console.log(import_chalk28.default.yellow("\u{1F4A1} \u4F60\u662F\u4E0D\u662F\u60F3\u8F93\u5165:"));
20028
+ console.log(import_chalk33.default.yellow("\u{1F4A1} \u4F60\u662F\u4E0D\u662F\u60F3\u8F93\u5165:"));
18975
20029
  suggestions.forEach((cmd) => {
18976
- console.log(import_chalk28.default.cyan(` ccman ${cmd}`));
20030
+ console.log(import_chalk33.default.cyan(` ccman ${cmd}`));
18977
20031
  });
18978
20032
  console.log();
18979
20033
  }
18980
- console.log(import_chalk28.default.gray("\u67E5\u770B\u6240\u6709\u53EF\u7528\u547D\u4EE4: ") + import_chalk28.default.cyan("ccman --help"));
20034
+ console.log(import_chalk33.default.gray("\u67E5\u770B\u6240\u6709\u53EF\u7528\u547D\u4EE4: ") + import_chalk33.default.cyan("ccman --help"));
18981
20035
  console.log();
18982
20036
  process.exit(1);
18983
20037
  });
@@ -18993,6 +20047,11 @@ cc.action(async () => {
18993
20047
  printLogo();
18994
20048
  await startClaudeMenu();
18995
20049
  });
20050
+ var mcp = program.command("mcp").description("\u7BA1\u7406 MCP \u670D\u52A1\u5668");
20051
+ createMCPCommands(mcp);
20052
+ mcp.action(() => {
20053
+ mcp.help();
20054
+ });
18996
20055
  var sync = program.command("sync").description("WebDAV \u540C\u6B65\u914D\u7F6E");
18997
20056
  createSyncCommands(sync);
18998
20057
  sync.action(async () => {