ccman 3.0.22 → 3.0.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.
- package/dist/index.js +542 -665
- 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.
|
|
42
|
+
version: "3.0.24",
|
|
43
43
|
type: "module",
|
|
44
44
|
description: "Core business logic for ccman",
|
|
45
45
|
main: "./dist/index.js",
|
|
@@ -2271,6 +2271,9 @@ function writeClaudeConfig(provider) {
|
|
|
2271
2271
|
baseUrl: provider.baseUrl
|
|
2272
2272
|
});
|
|
2273
2273
|
const mergedConfig = deepMerge(defaultConfig, userConfig);
|
|
2274
|
+
mergedConfig.env = mergedConfig.env || {};
|
|
2275
|
+
mergedConfig.env.ANTHROPIC_AUTH_TOKEN = provider.apiKey;
|
|
2276
|
+
mergedConfig.env.ANTHROPIC_BASE_URL = provider.baseUrl;
|
|
2274
2277
|
fs3.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2), { mode: 384 });
|
|
2275
2278
|
}
|
|
2276
2279
|
var fs3, CLAUDE_CONFIG_TEMPLATE;
|
|
@@ -2357,20 +2360,20 @@ var init_claude2 = __esm({
|
|
|
2357
2360
|
});
|
|
2358
2361
|
|
|
2359
2362
|
// ../core/dist/tool-manager.js
|
|
2360
|
-
function
|
|
2361
|
-
const
|
|
2362
|
-
const
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2363
|
+
function createToolManager(tool) {
|
|
2364
|
+
const toolConfig = TOOL_CONFIGS[tool];
|
|
2365
|
+
const configPath = toolConfig.configPath;
|
|
2366
|
+
function generateId() {
|
|
2367
|
+
const timestamp = Date.now();
|
|
2368
|
+
const random = Math.random().toString(36).substring(2, 8);
|
|
2369
|
+
return `${tool}-${timestamp}-${random}`;
|
|
2370
|
+
}
|
|
2367
2371
|
function loadConfig2() {
|
|
2368
2372
|
if (!fileExists(configPath)) {
|
|
2369
2373
|
ensureDir(getCcmanDir());
|
|
2370
2374
|
const initialConfig = {
|
|
2371
2375
|
providers: [],
|
|
2372
2376
|
presets: []
|
|
2373
|
-
// 只存储用户自定义预置
|
|
2374
2377
|
};
|
|
2375
2378
|
writeJSON(configPath, initialConfig);
|
|
2376
2379
|
return initialConfig;
|
|
@@ -2389,12 +2392,11 @@ function createCodexManager() {
|
|
|
2389
2392
|
}
|
|
2390
2393
|
const timestamp = Date.now();
|
|
2391
2394
|
const provider = {
|
|
2392
|
-
id: generateId(
|
|
2395
|
+
id: generateId(),
|
|
2393
2396
|
name: input.name,
|
|
2394
2397
|
baseUrl: input.baseUrl,
|
|
2395
2398
|
apiKey: input.apiKey,
|
|
2396
2399
|
model: input.model,
|
|
2397
|
-
// 保存 model 字段
|
|
2398
2400
|
createdAt: timestamp,
|
|
2399
2401
|
lastModified: timestamp
|
|
2400
2402
|
};
|
|
@@ -2428,7 +2430,7 @@ function createCodexManager() {
|
|
|
2428
2430
|
config.currentProviderId = id;
|
|
2429
2431
|
provider.lastUsedAt = Date.now();
|
|
2430
2432
|
saveConfig2(config);
|
|
2431
|
-
|
|
2433
|
+
toolConfig.writer(provider);
|
|
2432
2434
|
},
|
|
2433
2435
|
getCurrent() {
|
|
2434
2436
|
const config = loadConfig2();
|
|
@@ -2461,7 +2463,7 @@ function createCodexManager() {
|
|
|
2461
2463
|
provider.lastModified = Date.now();
|
|
2462
2464
|
saveConfig2(config);
|
|
2463
2465
|
if (config.currentProviderId === id) {
|
|
2464
|
-
|
|
2466
|
+
toolConfig.writer(provider);
|
|
2465
2467
|
}
|
|
2466
2468
|
return provider;
|
|
2467
2469
|
},
|
|
@@ -2487,7 +2489,7 @@ function createCodexManager() {
|
|
|
2487
2489
|
const timestamp = Date.now();
|
|
2488
2490
|
const newProvider = {
|
|
2489
2491
|
...source,
|
|
2490
|
-
id: generateId(
|
|
2492
|
+
id: generateId(),
|
|
2491
2493
|
name: newName,
|
|
2492
2494
|
createdAt: timestamp,
|
|
2493
2495
|
lastModified: timestamp,
|
|
@@ -2502,7 +2504,7 @@ function createCodexManager() {
|
|
|
2502
2504
|
if (!config.presets) {
|
|
2503
2505
|
config.presets = [];
|
|
2504
2506
|
}
|
|
2505
|
-
const allPresets = [...
|
|
2507
|
+
const allPresets = [...toolConfig.builtinPresets, ...config.presets];
|
|
2506
2508
|
const nameExists = allPresets.some((p) => p.name === input.name);
|
|
2507
2509
|
if (nameExists) {
|
|
2508
2510
|
throw new PresetNameConflictError(input.name);
|
|
@@ -2514,12 +2516,23 @@ function createCodexManager() {
|
|
|
2514
2516
|
};
|
|
2515
2517
|
config.presets.push(preset);
|
|
2516
2518
|
saveConfig2(config);
|
|
2517
|
-
return
|
|
2519
|
+
return {
|
|
2520
|
+
...preset,
|
|
2521
|
+
isBuiltIn: false
|
|
2522
|
+
};
|
|
2518
2523
|
},
|
|
2519
2524
|
listPresets() {
|
|
2520
2525
|
const config = loadConfig2();
|
|
2521
2526
|
const userPresets = config.presets || [];
|
|
2522
|
-
|
|
2527
|
+
const builtinWithFlag = toolConfig.builtinPresets.map((p) => ({
|
|
2528
|
+
...p,
|
|
2529
|
+
isBuiltIn: true
|
|
2530
|
+
}));
|
|
2531
|
+
const userWithFlag = userPresets.map((p) => ({
|
|
2532
|
+
...p,
|
|
2533
|
+
isBuiltIn: false
|
|
2534
|
+
}));
|
|
2535
|
+
return [...builtinWithFlag, ...userWithFlag];
|
|
2523
2536
|
},
|
|
2524
2537
|
editPreset(name, updates) {
|
|
2525
2538
|
const config = loadConfig2();
|
|
@@ -2531,7 +2544,7 @@ function createCodexManager() {
|
|
|
2531
2544
|
throw new Error(`\u9884\u7F6E\u4E0D\u5B58\u5728: ${name}`);
|
|
2532
2545
|
}
|
|
2533
2546
|
if (updates.name !== void 0 && updates.name !== preset.name) {
|
|
2534
|
-
const allPresets = [...
|
|
2547
|
+
const allPresets = [...toolConfig.builtinPresets, ...config.presets];
|
|
2535
2548
|
const nameConflict = allPresets.some((p) => p.name !== name && p.name === updates.name);
|
|
2536
2549
|
if (nameConflict) {
|
|
2537
2550
|
throw new PresetNameConflictError(updates.name);
|
|
@@ -2544,7 +2557,10 @@ function createCodexManager() {
|
|
|
2544
2557
|
if (updates.description !== void 0)
|
|
2545
2558
|
preset.description = updates.description;
|
|
2546
2559
|
saveConfig2(config);
|
|
2547
|
-
return
|
|
2560
|
+
return {
|
|
2561
|
+
...preset,
|
|
2562
|
+
isBuiltIn: false
|
|
2563
|
+
};
|
|
2548
2564
|
},
|
|
2549
2565
|
removePreset(name) {
|
|
2550
2566
|
const config = loadConfig2();
|
|
@@ -2560,201 +2576,13 @@ function createCodexManager() {
|
|
|
2560
2576
|
}
|
|
2561
2577
|
};
|
|
2562
2578
|
}
|
|
2579
|
+
function createCodexManager() {
|
|
2580
|
+
return createToolManager("codex");
|
|
2581
|
+
}
|
|
2563
2582
|
function createClaudeManager() {
|
|
2564
|
-
|
|
2565
|
-
function loadConfig2() {
|
|
2566
|
-
if (!fileExists(configPath)) {
|
|
2567
|
-
ensureDir(getCcmanDir());
|
|
2568
|
-
const initialConfig = {
|
|
2569
|
-
providers: [],
|
|
2570
|
-
presets: []
|
|
2571
|
-
// 只存储用户自定义预置
|
|
2572
|
-
};
|
|
2573
|
-
writeJSON(configPath, initialConfig);
|
|
2574
|
-
return initialConfig;
|
|
2575
|
-
}
|
|
2576
|
-
return readJSON(configPath);
|
|
2577
|
-
}
|
|
2578
|
-
function saveConfig2(config) {
|
|
2579
|
-
writeJSON(configPath, config);
|
|
2580
|
-
}
|
|
2581
|
-
return {
|
|
2582
|
-
add(input) {
|
|
2583
|
-
const config = loadConfig2();
|
|
2584
|
-
const nameExists = config.providers.some((p) => p.name === input.name);
|
|
2585
|
-
if (nameExists) {
|
|
2586
|
-
throw new ProviderNameConflictError(input.name);
|
|
2587
|
-
}
|
|
2588
|
-
const timestamp = Date.now();
|
|
2589
|
-
const provider = {
|
|
2590
|
-
id: generateId("claude"),
|
|
2591
|
-
name: input.name,
|
|
2592
|
-
baseUrl: input.baseUrl,
|
|
2593
|
-
apiKey: input.apiKey,
|
|
2594
|
-
createdAt: timestamp,
|
|
2595
|
-
lastModified: timestamp
|
|
2596
|
-
};
|
|
2597
|
-
config.providers.push(provider);
|
|
2598
|
-
saveConfig2(config);
|
|
2599
|
-
return provider;
|
|
2600
|
-
},
|
|
2601
|
-
list() {
|
|
2602
|
-
const config = loadConfig2();
|
|
2603
|
-
return config.providers;
|
|
2604
|
-
},
|
|
2605
|
-
get(id) {
|
|
2606
|
-
const config = loadConfig2();
|
|
2607
|
-
const provider = config.providers.find((p) => p.id === id);
|
|
2608
|
-
if (!provider) {
|
|
2609
|
-
throw new ProviderNotFoundError(id);
|
|
2610
|
-
}
|
|
2611
|
-
return provider;
|
|
2612
|
-
},
|
|
2613
|
-
findByName(name) {
|
|
2614
|
-
const config = loadConfig2();
|
|
2615
|
-
const lowerName = name.toLowerCase();
|
|
2616
|
-
return config.providers.find((p) => p.name.toLowerCase() === lowerName);
|
|
2617
|
-
},
|
|
2618
|
-
switch(id) {
|
|
2619
|
-
const config = loadConfig2();
|
|
2620
|
-
const provider = config.providers.find((p) => p.id === id);
|
|
2621
|
-
if (!provider) {
|
|
2622
|
-
throw new ProviderNotFoundError(id);
|
|
2623
|
-
}
|
|
2624
|
-
config.currentProviderId = id;
|
|
2625
|
-
provider.lastUsedAt = Date.now();
|
|
2626
|
-
saveConfig2(config);
|
|
2627
|
-
writeClaudeConfig(provider);
|
|
2628
|
-
},
|
|
2629
|
-
getCurrent() {
|
|
2630
|
-
const config = loadConfig2();
|
|
2631
|
-
if (!config.currentProviderId) {
|
|
2632
|
-
return null;
|
|
2633
|
-
}
|
|
2634
|
-
const provider = config.providers.find((p) => p.id === config.currentProviderId);
|
|
2635
|
-
return provider || null;
|
|
2636
|
-
},
|
|
2637
|
-
edit(id, updates) {
|
|
2638
|
-
const config = loadConfig2();
|
|
2639
|
-
const provider = config.providers.find((p) => p.id === id);
|
|
2640
|
-
if (!provider) {
|
|
2641
|
-
throw new ProviderNotFoundError(id);
|
|
2642
|
-
}
|
|
2643
|
-
if (updates.name !== void 0 && updates.name !== provider.name) {
|
|
2644
|
-
const nameConflict = config.providers.some((p) => p.id !== id && p.name === updates.name);
|
|
2645
|
-
if (nameConflict) {
|
|
2646
|
-
throw new ProviderNameConflictError(updates.name);
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
if (updates.name !== void 0)
|
|
2650
|
-
provider.name = updates.name;
|
|
2651
|
-
if (updates.baseUrl !== void 0)
|
|
2652
|
-
provider.baseUrl = updates.baseUrl;
|
|
2653
|
-
if (updates.apiKey !== void 0)
|
|
2654
|
-
provider.apiKey = updates.apiKey;
|
|
2655
|
-
provider.lastModified = Date.now();
|
|
2656
|
-
saveConfig2(config);
|
|
2657
|
-
if (config.currentProviderId === id) {
|
|
2658
|
-
writeClaudeConfig(provider);
|
|
2659
|
-
}
|
|
2660
|
-
return provider;
|
|
2661
|
-
},
|
|
2662
|
-
remove(id) {
|
|
2663
|
-
const config = loadConfig2();
|
|
2664
|
-
const index = config.providers.findIndex((p) => p.id === id);
|
|
2665
|
-
if (index === -1) {
|
|
2666
|
-
throw new ProviderNotFoundError(id);
|
|
2667
|
-
}
|
|
2668
|
-
if (config.currentProviderId === id) {
|
|
2669
|
-
config.currentProviderId = void 0;
|
|
2670
|
-
}
|
|
2671
|
-
config.providers.splice(index, 1);
|
|
2672
|
-
saveConfig2(config);
|
|
2673
|
-
},
|
|
2674
|
-
clone(sourceId, newName) {
|
|
2675
|
-
const source = this.get(sourceId);
|
|
2676
|
-
const config = loadConfig2();
|
|
2677
|
-
const nameExists = config.providers.some((p) => p.name === newName);
|
|
2678
|
-
if (nameExists) {
|
|
2679
|
-
throw new ProviderNameConflictError(newName);
|
|
2680
|
-
}
|
|
2681
|
-
const timestamp = Date.now();
|
|
2682
|
-
const newProvider = {
|
|
2683
|
-
...source,
|
|
2684
|
-
id: generateId("claude"),
|
|
2685
|
-
name: newName,
|
|
2686
|
-
createdAt: timestamp,
|
|
2687
|
-
lastModified: timestamp,
|
|
2688
|
-
lastUsedAt: void 0
|
|
2689
|
-
};
|
|
2690
|
-
config.providers.push(newProvider);
|
|
2691
|
-
saveConfig2(config);
|
|
2692
|
-
return newProvider;
|
|
2693
|
-
},
|
|
2694
|
-
addPreset(input) {
|
|
2695
|
-
const config = loadConfig2();
|
|
2696
|
-
if (!config.presets) {
|
|
2697
|
-
config.presets = [];
|
|
2698
|
-
}
|
|
2699
|
-
const allPresets = [...CC_PRESETS, ...config.presets];
|
|
2700
|
-
const nameExists = allPresets.some((p) => p.name === input.name);
|
|
2701
|
-
if (nameExists) {
|
|
2702
|
-
throw new PresetNameConflictError(input.name);
|
|
2703
|
-
}
|
|
2704
|
-
const preset = {
|
|
2705
|
-
name: input.name,
|
|
2706
|
-
baseUrl: input.baseUrl,
|
|
2707
|
-
description: input.description
|
|
2708
|
-
};
|
|
2709
|
-
config.presets.push(preset);
|
|
2710
|
-
saveConfig2(config);
|
|
2711
|
-
return preset;
|
|
2712
|
-
},
|
|
2713
|
-
listPresets() {
|
|
2714
|
-
const config = loadConfig2();
|
|
2715
|
-
const userPresets = config.presets || [];
|
|
2716
|
-
return [...CC_PRESETS, ...userPresets];
|
|
2717
|
-
},
|
|
2718
|
-
editPreset(name, updates) {
|
|
2719
|
-
const config = loadConfig2();
|
|
2720
|
-
if (!config.presets) {
|
|
2721
|
-
config.presets = [];
|
|
2722
|
-
}
|
|
2723
|
-
const preset = config.presets.find((p) => p.name === name);
|
|
2724
|
-
if (!preset) {
|
|
2725
|
-
throw new Error(`\u9884\u7F6E\u4E0D\u5B58\u5728: ${name}`);
|
|
2726
|
-
}
|
|
2727
|
-
if (updates.name !== void 0 && updates.name !== preset.name) {
|
|
2728
|
-
const allPresets = [...CC_PRESETS, ...config.presets];
|
|
2729
|
-
const nameConflict = allPresets.some((p) => p.name !== name && p.name === updates.name);
|
|
2730
|
-
if (nameConflict) {
|
|
2731
|
-
throw new PresetNameConflictError(updates.name);
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
if (updates.name !== void 0)
|
|
2735
|
-
preset.name = updates.name;
|
|
2736
|
-
if (updates.baseUrl !== void 0)
|
|
2737
|
-
preset.baseUrl = updates.baseUrl;
|
|
2738
|
-
if (updates.description !== void 0)
|
|
2739
|
-
preset.description = updates.description;
|
|
2740
|
-
saveConfig2(config);
|
|
2741
|
-
return preset;
|
|
2742
|
-
},
|
|
2743
|
-
removePreset(name) {
|
|
2744
|
-
const config = loadConfig2();
|
|
2745
|
-
if (!config.presets) {
|
|
2746
|
-
return;
|
|
2747
|
-
}
|
|
2748
|
-
const index = config.presets.findIndex((p) => p.name === name);
|
|
2749
|
-
if (index === -1) {
|
|
2750
|
-
throw new Error(`Preset not found: ${name}`);
|
|
2751
|
-
}
|
|
2752
|
-
config.presets.splice(index, 1);
|
|
2753
|
-
saveConfig2(config);
|
|
2754
|
-
}
|
|
2755
|
-
};
|
|
2583
|
+
return createToolManager("claude");
|
|
2756
2584
|
}
|
|
2757
|
-
var path3, ProviderNotFoundError, ProviderNameConflictError, PresetNameConflictError;
|
|
2585
|
+
var path3, ProviderNotFoundError, ProviderNameConflictError, PresetNameConflictError, TOOL_CONFIGS;
|
|
2758
2586
|
var init_tool_manager = __esm({
|
|
2759
2587
|
"../core/dist/tool-manager.js"() {
|
|
2760
2588
|
"use strict";
|
|
@@ -2783,6 +2611,18 @@ var init_tool_manager = __esm({
|
|
|
2783
2611
|
this.name = "PresetNameConflictError";
|
|
2784
2612
|
}
|
|
2785
2613
|
};
|
|
2614
|
+
TOOL_CONFIGS = {
|
|
2615
|
+
codex: {
|
|
2616
|
+
configPath: path3.join(getCcmanDir(), "codex.json"),
|
|
2617
|
+
builtinPresets: CODEX_PRESETS,
|
|
2618
|
+
writer: writeCodexConfig
|
|
2619
|
+
},
|
|
2620
|
+
claude: {
|
|
2621
|
+
configPath: path3.join(getCcmanDir(), "claude.json"),
|
|
2622
|
+
builtinPresets: CC_PRESETS,
|
|
2623
|
+
writer: writeClaudeConfig
|
|
2624
|
+
}
|
|
2625
|
+
};
|
|
2786
2626
|
}
|
|
2787
2627
|
});
|
|
2788
2628
|
|
|
@@ -2835,6 +2675,13 @@ function saveSyncConfig(syncConfig) {
|
|
|
2835
2675
|
config.sync = syncConfig;
|
|
2836
2676
|
saveConfig(config);
|
|
2837
2677
|
}
|
|
2678
|
+
function updateLastSyncTime() {
|
|
2679
|
+
const config = loadConfig();
|
|
2680
|
+
if (config.sync) {
|
|
2681
|
+
config.sync.lastSync = Date.now();
|
|
2682
|
+
saveConfig(config);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2838
2685
|
var fs4;
|
|
2839
2686
|
var init_config = __esm({
|
|
2840
2687
|
"../core/dist/config.js"() {
|
|
@@ -16114,12 +15961,12 @@ function createWebDAVClient(config) {
|
|
|
16114
15961
|
return client;
|
|
16115
15962
|
}
|
|
16116
15963
|
async function testWebDAVConnection(config) {
|
|
15964
|
+
const remoteDir = normalizePath(config.remoteDir || "/");
|
|
16117
15965
|
try {
|
|
16118
15966
|
const client = createWebDAVClient(config);
|
|
16119
|
-
await client.
|
|
15967
|
+
await client.getDirectoryContents(remoteDir);
|
|
16120
15968
|
return true;
|
|
16121
15969
|
} catch (error) {
|
|
16122
|
-
console.error("WebDAV \u8FDE\u63A5\u5931\u8D25:", error.message);
|
|
16123
15970
|
return false;
|
|
16124
15971
|
}
|
|
16125
15972
|
}
|
|
@@ -16214,81 +16061,20 @@ var init_webdav_client = __esm({
|
|
|
16214
16061
|
}
|
|
16215
16062
|
});
|
|
16216
16063
|
|
|
16217
|
-
// ../core/dist/sync/
|
|
16218
|
-
function
|
|
16219
|
-
|
|
16220
|
-
throw new Error(`\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728: ${configPath}`);
|
|
16221
|
-
}
|
|
16222
|
-
const timestamp = Date.now();
|
|
16223
|
-
const backupPath = `${configPath}.backup.${timestamp}`;
|
|
16224
|
-
import_fs.default.copyFileSync(configPath, backupPath);
|
|
16225
|
-
cleanupOldBackups(configPath, keepCount);
|
|
16226
|
-
return backupPath;
|
|
16064
|
+
// ../core/dist/sync/crypto.js
|
|
16065
|
+
function deriveKey(password, salt) {
|
|
16066
|
+
return crypto.pbkdf2Sync(password, salt, PBKDF2_ITERATIONS, KEY_LENGTH, "sha256");
|
|
16227
16067
|
}
|
|
16228
|
-
function
|
|
16229
|
-
const
|
|
16230
|
-
const
|
|
16231
|
-
const
|
|
16232
|
-
|
|
16233
|
-
|
|
16234
|
-
|
|
16235
|
-
|
|
16236
|
-
|
|
16237
|
-
|
|
16238
|
-
return null;
|
|
16239
|
-
}
|
|
16240
|
-
return {
|
|
16241
|
-
name: f3,
|
|
16242
|
-
path: import_path17.default.join(dir, f3),
|
|
16243
|
-
timestamp
|
|
16244
|
-
};
|
|
16245
|
-
}).filter((backup) => backup !== null).sort((a, b) => b.timestamp - a.timestamp);
|
|
16246
|
-
const toDelete = backups.slice(keepCount);
|
|
16247
|
-
for (const backup of toDelete) {
|
|
16248
|
-
try {
|
|
16249
|
-
import_fs.default.unlinkSync(backup.path);
|
|
16250
|
-
} catch (error) {
|
|
16251
|
-
console.warn(`\u65E0\u6CD5\u5220\u9664\u65E7\u5907\u4EFD\u6587\u4EF6 ${backup.name}: ${error.message}`);
|
|
16252
|
-
}
|
|
16253
|
-
}
|
|
16254
|
-
} catch (error) {
|
|
16255
|
-
console.warn(`\u6E05\u7406\u65E7\u5907\u4EFD\u65F6\u51FA\u9519: ${error.message}`);
|
|
16256
|
-
}
|
|
16257
|
-
}
|
|
16258
|
-
var import_fs, import_path17;
|
|
16259
|
-
var init_merge2 = __esm({
|
|
16260
|
-
"../core/dist/sync/merge.js"() {
|
|
16261
|
-
"use strict";
|
|
16262
|
-
import_fs = __toESM(require("fs"), 1);
|
|
16263
|
-
import_path17 = __toESM(require("path"), 1);
|
|
16264
|
-
}
|
|
16265
|
-
});
|
|
16266
|
-
|
|
16267
|
-
// ../core/dist/sync/sync.js
|
|
16268
|
-
var init_sync = __esm({
|
|
16269
|
-
"../core/dist/sync/sync.js"() {
|
|
16270
|
-
"use strict";
|
|
16271
|
-
init_webdav_client();
|
|
16272
|
-
init_merge2();
|
|
16273
|
-
init_paths();
|
|
16274
|
-
init_file();
|
|
16275
|
-
}
|
|
16276
|
-
});
|
|
16277
|
-
|
|
16278
|
-
// ../core/dist/sync/crypto.js
|
|
16279
|
-
function deriveKey(password, salt) {
|
|
16280
|
-
return crypto.pbkdf2Sync(password, salt, PBKDF2_ITERATIONS, KEY_LENGTH, "sha256");
|
|
16281
|
-
}
|
|
16282
|
-
function encryptApiKey(apiKey, password) {
|
|
16283
|
-
const salt = crypto.randomBytes(SALT_LENGTH);
|
|
16284
|
-
const iv = crypto.randomBytes(IV_LENGTH);
|
|
16285
|
-
const key = deriveKey(password, salt);
|
|
16286
|
-
const cipher = crypto.createCipheriv(ALGORITHM, key, iv);
|
|
16287
|
-
let encrypted = cipher.update(apiKey, "utf8");
|
|
16288
|
-
encrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
16289
|
-
const tag = cipher.getAuthTag();
|
|
16290
|
-
const result = Buffer.concat([salt, iv, tag, encrypted]);
|
|
16291
|
-
return result.toString("base64");
|
|
16068
|
+
function encryptApiKey(apiKey, password) {
|
|
16069
|
+
const salt = crypto.randomBytes(SALT_LENGTH);
|
|
16070
|
+
const iv = crypto.randomBytes(IV_LENGTH);
|
|
16071
|
+
const key = deriveKey(password, salt);
|
|
16072
|
+
const cipher = crypto.createCipheriv(ALGORITHM, key, iv);
|
|
16073
|
+
let encrypted = cipher.update(apiKey, "utf8");
|
|
16074
|
+
encrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
16075
|
+
const tag = cipher.getAuthTag();
|
|
16076
|
+
const result = Buffer.concat([salt, iv, tag, encrypted]);
|
|
16077
|
+
return result.toString("base64");
|
|
16292
16078
|
}
|
|
16293
16079
|
function decryptApiKey(encryptedApiKey, password) {
|
|
16294
16080
|
try {
|
|
@@ -16429,6 +16215,56 @@ var init_merge_advanced = __esm({
|
|
|
16429
16215
|
}
|
|
16430
16216
|
});
|
|
16431
16217
|
|
|
16218
|
+
// ../core/dist/sync/merge.js
|
|
16219
|
+
function backupConfig(configPath, keepCount = 3) {
|
|
16220
|
+
if (!import_fs.default.existsSync(configPath)) {
|
|
16221
|
+
throw new Error(`\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728: ${configPath}`);
|
|
16222
|
+
}
|
|
16223
|
+
const timestamp = Date.now();
|
|
16224
|
+
const backupPath = `${configPath}.backup.${timestamp}`;
|
|
16225
|
+
import_fs.default.copyFileSync(configPath, backupPath);
|
|
16226
|
+
cleanupOldBackups(configPath, keepCount);
|
|
16227
|
+
return backupPath;
|
|
16228
|
+
}
|
|
16229
|
+
function cleanupOldBackups(configPath, keepCount) {
|
|
16230
|
+
const dir = import_path17.default.dirname(configPath);
|
|
16231
|
+
const basename2 = import_path17.default.basename(configPath);
|
|
16232
|
+
const backupPrefix = `${basename2}.backup.`;
|
|
16233
|
+
try {
|
|
16234
|
+
const files = import_fs.default.readdirSync(dir);
|
|
16235
|
+
const backups = files.filter((f3) => f3.startsWith(backupPrefix)).map((f3) => {
|
|
16236
|
+
const timestampStr = f3.substring(backupPrefix.length);
|
|
16237
|
+
const timestamp = parseInt(timestampStr, 10);
|
|
16238
|
+
if (isNaN(timestamp)) {
|
|
16239
|
+
return null;
|
|
16240
|
+
}
|
|
16241
|
+
return {
|
|
16242
|
+
name: f3,
|
|
16243
|
+
path: import_path17.default.join(dir, f3),
|
|
16244
|
+
timestamp
|
|
16245
|
+
};
|
|
16246
|
+
}).filter((backup) => backup !== null).sort((a, b) => b.timestamp - a.timestamp);
|
|
16247
|
+
const toDelete = backups.slice(keepCount);
|
|
16248
|
+
for (const backup of toDelete) {
|
|
16249
|
+
try {
|
|
16250
|
+
import_fs.default.unlinkSync(backup.path);
|
|
16251
|
+
} catch (error) {
|
|
16252
|
+
console.warn(`\u65E0\u6CD5\u5220\u9664\u65E7\u5907\u4EFD\u6587\u4EF6 ${backup.name}: ${error.message}`);
|
|
16253
|
+
}
|
|
16254
|
+
}
|
|
16255
|
+
} catch (error) {
|
|
16256
|
+
console.warn(`\u6E05\u7406\u65E7\u5907\u4EFD\u65F6\u51FA\u9519: ${error.message}`);
|
|
16257
|
+
}
|
|
16258
|
+
}
|
|
16259
|
+
var import_fs, import_path17;
|
|
16260
|
+
var init_merge2 = __esm({
|
|
16261
|
+
"../core/dist/sync/merge.js"() {
|
|
16262
|
+
"use strict";
|
|
16263
|
+
import_fs = __toESM(require("fs"), 1);
|
|
16264
|
+
import_path17 = __toESM(require("path"), 1);
|
|
16265
|
+
}
|
|
16266
|
+
});
|
|
16267
|
+
|
|
16432
16268
|
// ../core/dist/sync/sync-v2.js
|
|
16433
16269
|
async function uploadToCloud(config, password) {
|
|
16434
16270
|
const ccmanDir2 = getCcmanDir();
|
|
@@ -16454,6 +16290,7 @@ async function uploadToCloud(config, password) {
|
|
|
16454
16290
|
const claudeJson = JSON.stringify(encryptedClaudeConfig, null, 2);
|
|
16455
16291
|
await uploadToWebDAV(config, CODEX_REMOTE_PATH, codexJson);
|
|
16456
16292
|
await uploadToWebDAV(config, CLAUDE_REMOTE_PATH, claudeJson);
|
|
16293
|
+
updateLastSyncTime();
|
|
16457
16294
|
console.log("\u2705 \u914D\u7F6E\u5DF2\u4E0A\u4F20\u5230\u4E91\u7AEF");
|
|
16458
16295
|
}
|
|
16459
16296
|
async function downloadFromCloud(config, password) {
|
|
@@ -16513,6 +16350,7 @@ async function downloadFromCloud(config, password) {
|
|
|
16513
16350
|
writeJSON(claudeConfigPath, newClaudeConfig);
|
|
16514
16351
|
applyCurrentProvider("claude", newClaudeConfig);
|
|
16515
16352
|
}
|
|
16353
|
+
updateLastSyncTime();
|
|
16516
16354
|
console.log("\u2705 \u914D\u7F6E\u5DF2\u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u5E76\u5E94\u7528");
|
|
16517
16355
|
return backupPaths;
|
|
16518
16356
|
} catch (error) {
|
|
@@ -16619,6 +16457,7 @@ async function mergeSync(config, password) {
|
|
|
16619
16457
|
const claudeJson2 = JSON.stringify(encryptedClaudeConfig, null, 2);
|
|
16620
16458
|
await uploadToWebDAV(config, CODEX_REMOTE_PATH, codexJson2);
|
|
16621
16459
|
await uploadToWebDAV(config, CLAUDE_REMOTE_PATH, claudeJson2);
|
|
16460
|
+
updateLastSyncTime();
|
|
16622
16461
|
console.log("\u2705 \u914D\u7F6E\u5DF2\u5408\u5E76\u5E76\u540C\u6B65\u5230\u4E91\u7AEF");
|
|
16623
16462
|
return {
|
|
16624
16463
|
hasChanges: true,
|
|
@@ -16654,6 +16493,7 @@ var init_sync_v2 = __esm({
|
|
|
16654
16493
|
"use strict";
|
|
16655
16494
|
import_fs2 = __toESM(require("fs"), 1);
|
|
16656
16495
|
import_path18 = __toESM(require("path"), 1);
|
|
16496
|
+
init_config();
|
|
16657
16497
|
init_webdav_client();
|
|
16658
16498
|
init_crypto2();
|
|
16659
16499
|
init_merge_advanced();
|
|
@@ -16822,7 +16662,6 @@ var init_dist4 = __esm({
|
|
|
16822
16662
|
init_migrate();
|
|
16823
16663
|
init_paths();
|
|
16824
16664
|
init_config();
|
|
16825
|
-
init_sync();
|
|
16826
16665
|
init_webdav_client();
|
|
16827
16666
|
init_sync_v2();
|
|
16828
16667
|
init_crypto2();
|
|
@@ -16850,7 +16689,6 @@ function saveSyncConfig2(config) {
|
|
|
16850
16689
|
if (!configToSave.rememberSyncPassword) {
|
|
16851
16690
|
delete configToSave.syncPassword;
|
|
16852
16691
|
}
|
|
16853
|
-
configToSave.lastSync = Date.now();
|
|
16854
16692
|
saveSyncConfig(configToSave);
|
|
16855
16693
|
} catch (error) {
|
|
16856
16694
|
throw new Error(`\u4FDD\u5B58\u540C\u6B65\u914D\u7F6E\u5931\u8D25: ${error.message}`);
|
|
@@ -16966,8 +16804,7 @@ function configCommand(program2) {
|
|
|
16966
16804
|
hasChanges = true;
|
|
16967
16805
|
}
|
|
16968
16806
|
} else if (!existingConfig) {
|
|
16969
|
-
|
|
16970
|
-
process.exit(1);
|
|
16807
|
+
throw new Error("WebDAV \u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A");
|
|
16971
16808
|
}
|
|
16972
16809
|
if (trimmedAnswers.username) {
|
|
16973
16810
|
if (trimmedAnswers.username !== existingConfig?.username) {
|
|
@@ -16975,8 +16812,7 @@ function configCommand(program2) {
|
|
|
16975
16812
|
hasChanges = true;
|
|
16976
16813
|
}
|
|
16977
16814
|
} else if (!existingConfig) {
|
|
16978
|
-
|
|
16979
|
-
process.exit(1);
|
|
16815
|
+
throw new Error("\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A");
|
|
16980
16816
|
}
|
|
16981
16817
|
if (trimmedAnswers.password) {
|
|
16982
16818
|
if (trimmedAnswers.password !== existingConfig?.password) {
|
|
@@ -16984,8 +16820,7 @@ function configCommand(program2) {
|
|
|
16984
16820
|
hasChanges = true;
|
|
16985
16821
|
}
|
|
16986
16822
|
} else if (!existingConfig) {
|
|
16987
|
-
|
|
16988
|
-
process.exit(1);
|
|
16823
|
+
throw new Error("\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
|
|
16989
16824
|
}
|
|
16990
16825
|
if (trimmedAnswers.authType !== existingConfig?.authType) {
|
|
16991
16826
|
newConfig.authType = trimmedAnswers.authType;
|
|
@@ -17005,8 +16840,7 @@ function configCommand(program2) {
|
|
|
17005
16840
|
hasChanges = true;
|
|
17006
16841
|
}
|
|
17007
16842
|
} else if (!existingConfig) {
|
|
17008
|
-
|
|
17009
|
-
process.exit(1);
|
|
16843
|
+
throw new Error("\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
|
|
17010
16844
|
}
|
|
17011
16845
|
if (trimmedAnswers.rememberSyncPassword !== existingConfig?.rememberSyncPassword) {
|
|
17012
16846
|
newConfig.rememberSyncPassword = trimmedAnswers.rememberSyncPassword;
|
|
@@ -17033,13 +16867,30 @@ function configCommand(program2) {
|
|
|
17033
16867
|
}
|
|
17034
16868
|
]);
|
|
17035
16869
|
if (testNow) {
|
|
17036
|
-
console.log(import_chalk3.default.
|
|
16870
|
+
console.log(import_chalk3.default.bold("\n\u{1F50D} \u6D4B\u8BD5 WebDAV \u8FDE\u63A5...\n"));
|
|
16871
|
+
const success = await testWebDAVConnection(newConfig);
|
|
16872
|
+
if (success) {
|
|
16873
|
+
console.log(import_chalk3.default.green("\u2705 \u8FDE\u63A5\u6210\u529F"));
|
|
16874
|
+
console.log();
|
|
16875
|
+
console.log(" ", import_chalk3.default.gray("URL:"), newConfig.webdavUrl);
|
|
16876
|
+
console.log(" ", import_chalk3.default.gray("\u7528\u6237:"), newConfig.username);
|
|
16877
|
+
console.log(" ", import_chalk3.default.gray("\u8FDC\u7A0B\u76EE\u5F55:"), newConfig.remoteDir || "/");
|
|
16878
|
+
console.log(" ", import_chalk3.default.gray("\u8BA4\u8BC1\u7C7B\u578B:"), newConfig.authType === "password" ? "Basic Auth" : "Digest Auth");
|
|
16879
|
+
console.log();
|
|
16880
|
+
} else {
|
|
16881
|
+
console.log(import_chalk3.default.red("\u274C \u8FDE\u63A5\u5931\u8D25"));
|
|
16882
|
+
console.log();
|
|
16883
|
+
console.log(import_chalk3.default.yellow("\u8BF7\u68C0\u67E5:"));
|
|
16884
|
+
console.log(" 1. WebDAV \u670D\u52A1\u5668\u5730\u5740\u662F\u5426\u6B63\u786E");
|
|
16885
|
+
console.log(" 2. \u7528\u6237\u540D\u548C\u5BC6\u7801\u662F\u5426\u6B63\u786E");
|
|
16886
|
+
console.log(" 3. \u7F51\u7EDC\u8FDE\u63A5\u662F\u5426\u6B63\u5E38");
|
|
16887
|
+
console.log();
|
|
16888
|
+
}
|
|
17037
16889
|
}
|
|
17038
16890
|
} catch (error) {
|
|
17039
16891
|
console.error(import_chalk3.default.red(`
|
|
17040
16892
|
\u274C ${error.message}
|
|
17041
16893
|
`));
|
|
17042
|
-
process.exit(1);
|
|
17043
16894
|
}
|
|
17044
16895
|
});
|
|
17045
16896
|
}
|
|
@@ -17050,6 +16901,42 @@ var init_config2 = __esm({
|
|
|
17050
16901
|
import_chalk3 = __toESM(require("chalk"));
|
|
17051
16902
|
import_inquirer = __toESM(require("inquirer"));
|
|
17052
16903
|
init_sync_config();
|
|
16904
|
+
init_dist4();
|
|
16905
|
+
}
|
|
16906
|
+
});
|
|
16907
|
+
|
|
16908
|
+
// src/commands/sync/helpers.ts
|
|
16909
|
+
async function ensureConfigExists() {
|
|
16910
|
+
const config = loadSyncConfig();
|
|
16911
|
+
if (config) {
|
|
16912
|
+
return config;
|
|
16913
|
+
}
|
|
16914
|
+
console.log(import_chalk4.default.yellow("\n\u26A0\uFE0F \u672A\u627E\u5230 WebDAV \u914D\u7F6E\n"));
|
|
16915
|
+
const { shouldConfig } = await import_inquirer2.default.prompt([
|
|
16916
|
+
{
|
|
16917
|
+
type: "confirm",
|
|
16918
|
+
name: "shouldConfig",
|
|
16919
|
+
message: "\u662F\u5426\u73B0\u5728\u914D\u7F6E WebDAV?",
|
|
16920
|
+
default: true
|
|
16921
|
+
}
|
|
16922
|
+
]);
|
|
16923
|
+
if (!shouldConfig) {
|
|
16924
|
+
return null;
|
|
16925
|
+
}
|
|
16926
|
+
const { configCommand: configCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
16927
|
+
const cmd = new import_commander.Command();
|
|
16928
|
+
configCommand2(cmd);
|
|
16929
|
+
await cmd.parseAsync(["node", "ccman", "config"]);
|
|
16930
|
+
return loadSyncConfig();
|
|
16931
|
+
}
|
|
16932
|
+
var import_inquirer2, import_chalk4, import_commander;
|
|
16933
|
+
var init_helpers = __esm({
|
|
16934
|
+
"src/commands/sync/helpers.ts"() {
|
|
16935
|
+
"use strict";
|
|
16936
|
+
import_inquirer2 = __toESM(require("inquirer"));
|
|
16937
|
+
import_chalk4 = __toESM(require("chalk"));
|
|
16938
|
+
import_commander = require("commander");
|
|
16939
|
+
init_sync_config();
|
|
17053
16940
|
}
|
|
17054
16941
|
});
|
|
17055
16942
|
|
|
@@ -17061,47 +16948,44 @@ __export(test_exports, {
|
|
|
17061
16948
|
function testCommand(program2) {
|
|
17062
16949
|
program2.command("test").description("\u6D4B\u8BD5 WebDAV \u8FDE\u63A5").action(async () => {
|
|
17063
16950
|
try {
|
|
17064
|
-
const config =
|
|
16951
|
+
const config = await ensureConfigExists();
|
|
17065
16952
|
if (!config) {
|
|
17066
|
-
console.log(
|
|
17067
|
-
|
|
17068
|
-
process.exit(1);
|
|
16953
|
+
console.log(import_chalk5.default.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
16954
|
+
return;
|
|
17069
16955
|
}
|
|
17070
|
-
console.log(
|
|
16956
|
+
console.log(import_chalk5.default.bold("\n\u{1F50D} \u6D4B\u8BD5 WebDAV \u8FDE\u63A5...\n"));
|
|
17071
16957
|
const success = await testWebDAVConnection(config);
|
|
17072
16958
|
if (success) {
|
|
17073
|
-
console.log(
|
|
16959
|
+
console.log(import_chalk5.default.green("\u2705 \u8FDE\u63A5\u6210\u529F"));
|
|
17074
16960
|
console.log();
|
|
17075
|
-
console.log(" ",
|
|
17076
|
-
console.log(" ",
|
|
17077
|
-
console.log(" ",
|
|
17078
|
-
console.log(" ",
|
|
16961
|
+
console.log(" ", import_chalk5.default.gray("URL:"), config.webdavUrl);
|
|
16962
|
+
console.log(" ", import_chalk5.default.gray("\u7528\u6237:"), config.username);
|
|
16963
|
+
console.log(" ", import_chalk5.default.gray("\u8FDC\u7A0B\u76EE\u5F55:"), config.remoteDir);
|
|
16964
|
+
console.log(" ", import_chalk5.default.gray("\u8BA4\u8BC1\u7C7B\u578B:"), config.authType === "password" ? "Basic Auth" : "Digest Auth");
|
|
17079
16965
|
console.log();
|
|
17080
16966
|
} else {
|
|
17081
|
-
console.log(
|
|
16967
|
+
console.log(import_chalk5.default.red("\u274C \u8FDE\u63A5\u5931\u8D25"));
|
|
17082
16968
|
console.log();
|
|
17083
|
-
console.log(
|
|
16969
|
+
console.log(import_chalk5.default.yellow("\u8BF7\u68C0\u67E5:"));
|
|
17084
16970
|
console.log(" 1. WebDAV \u670D\u52A1\u5668\u5730\u5740\u662F\u5426\u6B63\u786E");
|
|
17085
16971
|
console.log(" 2. \u7528\u6237\u540D\u548C\u5BC6\u7801\u662F\u5426\u6B63\u786E");
|
|
17086
16972
|
console.log(" 3. \u7F51\u7EDC\u8FDE\u63A5\u662F\u5426\u6B63\u5E38");
|
|
17087
16973
|
console.log();
|
|
17088
|
-
process.exit(1);
|
|
17089
16974
|
}
|
|
17090
16975
|
} catch (error) {
|
|
17091
|
-
console.error(
|
|
16976
|
+
console.error(import_chalk5.default.red(`
|
|
17092
16977
|
\u274C ${error.message}
|
|
17093
16978
|
`));
|
|
17094
|
-
process.exit(1);
|
|
17095
16979
|
}
|
|
17096
16980
|
});
|
|
17097
16981
|
}
|
|
17098
|
-
var
|
|
16982
|
+
var import_chalk5;
|
|
17099
16983
|
var init_test = __esm({
|
|
17100
16984
|
"src/commands/sync/test.ts"() {
|
|
17101
16985
|
"use strict";
|
|
17102
|
-
|
|
16986
|
+
import_chalk5 = __toESM(require("chalk"));
|
|
17103
16987
|
init_dist4();
|
|
17104
|
-
|
|
16988
|
+
init_helpers();
|
|
17105
16989
|
}
|
|
17106
16990
|
});
|
|
17107
16991
|
|
|
@@ -17113,15 +16997,14 @@ __export(upload_exports, {
|
|
|
17113
16997
|
function uploadCommand(program2) {
|
|
17114
16998
|
program2.command("upload").description("\u4E0A\u4F20\u672C\u5730\u914D\u7F6E\u5230\u4E91\u7AEF").action(async () => {
|
|
17115
16999
|
try {
|
|
17116
|
-
const config =
|
|
17000
|
+
const config = await ensureConfigExists();
|
|
17117
17001
|
if (!config) {
|
|
17118
|
-
console.log(
|
|
17119
|
-
|
|
17120
|
-
process.exit(1);
|
|
17002
|
+
console.log(import_chalk6.default.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
17003
|
+
return;
|
|
17121
17004
|
}
|
|
17122
17005
|
let syncPassword = config.syncPassword;
|
|
17123
17006
|
if (!syncPassword) {
|
|
17124
|
-
const { password } = await
|
|
17007
|
+
const { password } = await import_inquirer3.default.prompt([
|
|
17125
17008
|
{
|
|
17126
17009
|
type: "password",
|
|
17127
17010
|
name: "password",
|
|
@@ -17136,14 +17019,14 @@ function uploadCommand(program2) {
|
|
|
17136
17019
|
const claudeManager = createClaudeManager();
|
|
17137
17020
|
const codexProviders = codexManager.list();
|
|
17138
17021
|
const claudeProviders = claudeManager.list();
|
|
17139
|
-
console.log(
|
|
17022
|
+
console.log(import_chalk6.default.bold("\n\u{1F4E4} \u4E0A\u4F20\u914D\u7F6E\u5230\u4E91\u7AEF\n"));
|
|
17140
17023
|
console.log("\u914D\u7F6E\u4FE1\u606F:");
|
|
17141
|
-
console.log(` Codex \u670D\u52A1\u5546: ${
|
|
17142
|
-
console.log(` Claude \u670D\u52A1\u5546: ${
|
|
17024
|
+
console.log(` Codex \u670D\u52A1\u5546: ${import_chalk6.default.cyan(codexProviders.length)} \u4E2A`);
|
|
17025
|
+
console.log(` Claude \u670D\u52A1\u5546: ${import_chalk6.default.cyan(claudeProviders.length)} \u4E2A`);
|
|
17143
17026
|
console.log();
|
|
17144
|
-
console.log(
|
|
17027
|
+
console.log(import_chalk6.default.yellow("\u26A0\uFE0F \u4E91\u7AEF\u73B0\u6709\u914D\u7F6E\u5C06\u88AB\u8986\u76D6"));
|
|
17145
17028
|
console.log();
|
|
17146
|
-
const { confirm } = await
|
|
17029
|
+
const { confirm } = await import_inquirer3.default.prompt([
|
|
17147
17030
|
{
|
|
17148
17031
|
type: "confirm",
|
|
17149
17032
|
name: "confirm",
|
|
@@ -17152,37 +17035,36 @@ function uploadCommand(program2) {
|
|
|
17152
17035
|
}
|
|
17153
17036
|
]);
|
|
17154
17037
|
if (!confirm) {
|
|
17155
|
-
console.log(
|
|
17038
|
+
console.log(import_chalk6.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
17156
17039
|
return;
|
|
17157
17040
|
}
|
|
17158
17041
|
console.log();
|
|
17159
|
-
console.log(
|
|
17160
|
-
console.log(
|
|
17042
|
+
console.log(import_chalk6.default.gray("\u{1F510} \u52A0\u5BC6 API Key..."));
|
|
17043
|
+
console.log(import_chalk6.default.gray("\u{1F4E4} \u4E0A\u4F20\u5230 WebDAV..."));
|
|
17161
17044
|
await uploadToCloud(config, syncPassword);
|
|
17162
17045
|
console.log();
|
|
17163
|
-
console.log(
|
|
17046
|
+
console.log(import_chalk6.default.green("\u2705 \u4E0A\u4F20\u6210\u529F"));
|
|
17164
17047
|
console.log();
|
|
17165
|
-
console.log(
|
|
17166
|
-
console.log(
|
|
17167
|
-
console.log(
|
|
17048
|
+
console.log(import_chalk6.default.gray("\u8FDC\u7A0B\u6587\u4EF6:"));
|
|
17049
|
+
console.log(import_chalk6.default.gray(` ${config.webdavUrl}${config.remoteDir}/.ccman/codex.json`));
|
|
17050
|
+
console.log(import_chalk6.default.gray(` ${config.webdavUrl}${config.remoteDir}/.ccman/claude.json`));
|
|
17168
17051
|
console.log();
|
|
17169
|
-
console.log(
|
|
17052
|
+
console.log(import_chalk6.default.blue("\u{1F4A1} \u5176\u4ED6\u8BBE\u5907\u53EF\u901A\u8FC7 'ccman sync download' \u83B7\u53D6\u914D\u7F6E\n"));
|
|
17170
17053
|
} catch (error) {
|
|
17171
|
-
console.error(
|
|
17054
|
+
console.error(import_chalk6.default.red(`
|
|
17172
17055
|
\u274C ${error.message}
|
|
17173
17056
|
`));
|
|
17174
|
-
process.exit(1);
|
|
17175
17057
|
}
|
|
17176
17058
|
});
|
|
17177
17059
|
}
|
|
17178
|
-
var
|
|
17060
|
+
var import_chalk6, import_inquirer3;
|
|
17179
17061
|
var init_upload = __esm({
|
|
17180
17062
|
"src/commands/sync/upload.ts"() {
|
|
17181
17063
|
"use strict";
|
|
17182
|
-
|
|
17183
|
-
|
|
17064
|
+
import_chalk6 = __toESM(require("chalk"));
|
|
17065
|
+
import_inquirer3 = __toESM(require("inquirer"));
|
|
17184
17066
|
init_dist4();
|
|
17185
|
-
|
|
17067
|
+
init_helpers();
|
|
17186
17068
|
}
|
|
17187
17069
|
});
|
|
17188
17070
|
|
|
@@ -17194,15 +17076,14 @@ __export(download_exports, {
|
|
|
17194
17076
|
function downloadCommand(program2) {
|
|
17195
17077
|
program2.command("download").description("\u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u914D\u7F6E\u5230\u672C\u5730").action(async () => {
|
|
17196
17078
|
try {
|
|
17197
|
-
const config =
|
|
17079
|
+
const config = await ensureConfigExists();
|
|
17198
17080
|
if (!config) {
|
|
17199
|
-
console.log(
|
|
17200
|
-
|
|
17201
|
-
process.exit(1);
|
|
17081
|
+
console.log(import_chalk7.default.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
17082
|
+
return;
|
|
17202
17083
|
}
|
|
17203
17084
|
let syncPassword = config.syncPassword;
|
|
17204
17085
|
if (!syncPassword) {
|
|
17205
|
-
const { password } = await
|
|
17086
|
+
const { password } = await import_inquirer4.default.prompt([
|
|
17206
17087
|
{
|
|
17207
17088
|
type: "password",
|
|
17208
17089
|
name: "password",
|
|
@@ -17213,10 +17094,10 @@ function downloadCommand(program2) {
|
|
|
17213
17094
|
]);
|
|
17214
17095
|
syncPassword = password;
|
|
17215
17096
|
}
|
|
17216
|
-
console.log(
|
|
17217
|
-
console.log(
|
|
17097
|
+
console.log(import_chalk7.default.bold("\n\u{1F4E5} \u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u914D\u7F6E\n"));
|
|
17098
|
+
console.log(import_chalk7.default.yellow("\u26A0\uFE0F \u5C06\u8986\u76D6\u672C\u5730\u914D\u7F6E\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
|
|
17218
17099
|
console.log();
|
|
17219
|
-
const { confirm } = await
|
|
17100
|
+
const { confirm } = await import_inquirer4.default.prompt([
|
|
17220
17101
|
{
|
|
17221
17102
|
type: "confirm",
|
|
17222
17103
|
name: "confirm",
|
|
@@ -17225,41 +17106,40 @@ function downloadCommand(program2) {
|
|
|
17225
17106
|
}
|
|
17226
17107
|
]);
|
|
17227
17108
|
if (!confirm) {
|
|
17228
|
-
console.log(
|
|
17109
|
+
console.log(import_chalk7.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
17229
17110
|
return;
|
|
17230
17111
|
}
|
|
17231
17112
|
console.log();
|
|
17232
|
-
console.log(
|
|
17233
|
-
console.log(
|
|
17234
|
-
console.log(
|
|
17113
|
+
console.log(import_chalk7.default.gray("\u{1F4BE} \u5907\u4EFD\u672C\u5730\u914D\u7F6E..."));
|
|
17114
|
+
console.log(import_chalk7.default.gray("\u{1F4E5} \u4E0B\u8F7D\u8FDC\u7A0B\u914D\u7F6E..."));
|
|
17115
|
+
console.log(import_chalk7.default.gray("\u{1F513} \u89E3\u5BC6 API Key..."));
|
|
17235
17116
|
const backupPaths = await downloadFromCloud(config, syncPassword);
|
|
17236
17117
|
console.log();
|
|
17237
|
-
console.log(
|
|
17118
|
+
console.log(import_chalk7.default.green("\u2705 \u4E0B\u8F7D\u6210\u529F"));
|
|
17238
17119
|
console.log();
|
|
17239
17120
|
if (backupPaths.length > 0) {
|
|
17240
|
-
console.log(
|
|
17121
|
+
console.log(import_chalk7.default.gray("\u672C\u5730\u5907\u4EFD:"));
|
|
17241
17122
|
backupPaths.forEach((path12) => {
|
|
17242
|
-
console.log(
|
|
17123
|
+
console.log(import_chalk7.default.gray(` ${path12}`));
|
|
17243
17124
|
});
|
|
17244
17125
|
console.log();
|
|
17245
17126
|
}
|
|
17246
|
-
console.log(
|
|
17127
|
+
console.log(import_chalk7.default.blue("\u{1F4A1} \u914D\u7F6E\u5DF2\u66F4\u65B0\uFF0C\u91CD\u65B0\u52A0\u8F7D\u751F\u6548\n"));
|
|
17247
17128
|
} catch (error) {
|
|
17248
|
-
console.error(
|
|
17129
|
+
console.error(import_chalk7.default.red(`
|
|
17249
17130
|
\u274C ${error.message}
|
|
17250
17131
|
`));
|
|
17251
|
-
process.exit(1);
|
|
17252
17132
|
}
|
|
17253
17133
|
});
|
|
17254
17134
|
}
|
|
17255
|
-
var
|
|
17135
|
+
var import_chalk7, import_inquirer4;
|
|
17256
17136
|
var init_download = __esm({
|
|
17257
17137
|
"src/commands/sync/download.ts"() {
|
|
17258
17138
|
"use strict";
|
|
17259
|
-
|
|
17260
|
-
|
|
17139
|
+
import_chalk7 = __toESM(require("chalk"));
|
|
17140
|
+
import_inquirer4 = __toESM(require("inquirer"));
|
|
17261
17141
|
init_dist4();
|
|
17262
|
-
|
|
17142
|
+
init_helpers();
|
|
17263
17143
|
}
|
|
17264
17144
|
});
|
|
17265
17145
|
|
|
@@ -17271,15 +17151,14 @@ __export(merge_exports, {
|
|
|
17271
17151
|
function mergeCommand(program2) {
|
|
17272
17152
|
program2.command("merge").description("\u667A\u80FD\u5408\u5E76\u672C\u5730\u548C\u4E91\u7AEF\u914D\u7F6E").action(async () => {
|
|
17273
17153
|
try {
|
|
17274
|
-
const config =
|
|
17154
|
+
const config = await ensureConfigExists();
|
|
17275
17155
|
if (!config) {
|
|
17276
|
-
console.log(
|
|
17277
|
-
|
|
17278
|
-
process.exit(1);
|
|
17156
|
+
console.log(import_chalk8.default.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
17157
|
+
return;
|
|
17279
17158
|
}
|
|
17280
17159
|
let syncPassword = config.syncPassword;
|
|
17281
17160
|
if (!syncPassword) {
|
|
17282
|
-
const { password } = await
|
|
17161
|
+
const { password } = await import_inquirer5.default.prompt([
|
|
17283
17162
|
{
|
|
17284
17163
|
type: "password",
|
|
17285
17164
|
name: "password",
|
|
@@ -17290,45 +17169,44 @@ function mergeCommand(program2) {
|
|
|
17290
17169
|
]);
|
|
17291
17170
|
syncPassword = password;
|
|
17292
17171
|
}
|
|
17293
|
-
console.log(
|
|
17294
|
-
console.log(
|
|
17172
|
+
console.log(import_chalk8.default.bold("\n\u{1F504} \u667A\u80FD\u5408\u5E76\u914D\u7F6E\n"));
|
|
17173
|
+
console.log(import_chalk8.default.gray("\u5206\u6790\u672C\u5730\u548C\u4E91\u7AEF\u914D\u7F6E..."));
|
|
17295
17174
|
const result = await mergeSync(config, syncPassword);
|
|
17296
17175
|
if (!result.hasChanges) {
|
|
17297
17176
|
console.log();
|
|
17298
|
-
console.log(
|
|
17177
|
+
console.log(import_chalk8.default.blue("\u2139\uFE0F \u914D\u7F6E\u5DF2\u540C\u6B65\uFF0C\u65E0\u9700\u64CD\u4F5C\n"));
|
|
17299
17178
|
return;
|
|
17300
17179
|
}
|
|
17301
17180
|
console.log();
|
|
17302
|
-
console.log(
|
|
17181
|
+
console.log(import_chalk8.default.green("\u2705 \u914D\u7F6E\u5DF2\u667A\u80FD\u5408\u5E76\u5E76\u540C\u6B65"));
|
|
17303
17182
|
console.log();
|
|
17304
17183
|
if (result.backupPaths.length > 0) {
|
|
17305
|
-
console.log(
|
|
17184
|
+
console.log(import_chalk8.default.gray("\u5907\u4EFD:"));
|
|
17306
17185
|
result.backupPaths.forEach((path12) => {
|
|
17307
|
-
console.log(
|
|
17186
|
+
console.log(import_chalk8.default.gray(` ${path12}`));
|
|
17308
17187
|
});
|
|
17309
17188
|
console.log();
|
|
17310
17189
|
}
|
|
17311
|
-
console.log(
|
|
17312
|
-
console.log(
|
|
17313
|
-
console.log(
|
|
17314
|
-
console.log(
|
|
17190
|
+
console.log(import_chalk8.default.blue("\u5408\u5E76\u89C4\u5219:"));
|
|
17191
|
+
console.log(import_chalk8.default.gray(" \u2022 \u76F8\u540C ID\uFF1A\u4FDD\u7559\u6700\u65B0\u4FEE\u6539"));
|
|
17192
|
+
console.log(import_chalk8.default.gray(" \u2022 \u76F8\u540C\u914D\u7F6E\uFF08URL+Key\uFF09\uFF1A\u4FDD\u7559\u6700\u65B0\u4FEE\u6539"));
|
|
17193
|
+
console.log(import_chalk8.default.gray(" \u2022 \u4E0D\u540C\u914D\u7F6E\uFF1A\u5168\u90E8\u4FDD\u7559\uFF0C\u81EA\u52A8\u5904\u7406 name \u51B2\u7A81"));
|
|
17315
17194
|
console.log();
|
|
17316
17195
|
} catch (error) {
|
|
17317
|
-
console.error(
|
|
17196
|
+
console.error(import_chalk8.default.red(`
|
|
17318
17197
|
\u274C ${error.message}
|
|
17319
17198
|
`));
|
|
17320
|
-
process.exit(1);
|
|
17321
17199
|
}
|
|
17322
17200
|
});
|
|
17323
17201
|
}
|
|
17324
|
-
var
|
|
17202
|
+
var import_chalk8, import_inquirer5;
|
|
17325
17203
|
var init_merge3 = __esm({
|
|
17326
17204
|
"src/commands/sync/merge.ts"() {
|
|
17327
17205
|
"use strict";
|
|
17328
|
-
|
|
17329
|
-
|
|
17206
|
+
import_chalk8 = __toESM(require("chalk"));
|
|
17207
|
+
import_inquirer5 = __toESM(require("inquirer"));
|
|
17330
17208
|
init_dist4();
|
|
17331
|
-
|
|
17209
|
+
init_helpers();
|
|
17332
17210
|
}
|
|
17333
17211
|
});
|
|
17334
17212
|
|
|
@@ -17341,50 +17219,49 @@ function statusCommand(program2) {
|
|
|
17341
17219
|
program2.command("status").description("\u67E5\u770B\u540C\u6B65\u72B6\u6001").action(async () => {
|
|
17342
17220
|
try {
|
|
17343
17221
|
const config = loadSyncConfig();
|
|
17344
|
-
console.log(
|
|
17222
|
+
console.log(import_chalk9.default.bold("\n\u{1F4CA} \u540C\u6B65\u72B6\u6001\n"));
|
|
17345
17223
|
if (!config) {
|
|
17346
|
-
console.log(
|
|
17224
|
+
console.log(import_chalk9.default.yellow("\u26A0\uFE0F \u672A\u914D\u7F6E WebDAV \u540C\u6B65"));
|
|
17347
17225
|
console.log();
|
|
17348
|
-
console.log(
|
|
17226
|
+
console.log(import_chalk9.default.blue("\u{1F4A1} \u5F00\u59CB\u914D\u7F6E: ccman sync config\n"));
|
|
17349
17227
|
return;
|
|
17350
17228
|
}
|
|
17351
|
-
console.log(
|
|
17352
|
-
console.log(` URL: ${
|
|
17353
|
-
console.log(` \u7528\u6237: ${
|
|
17354
|
-
console.log(` \u8FDC\u7A0B\u76EE\u5F55: ${
|
|
17355
|
-
console.log(` \u8BA4\u8BC1: ${
|
|
17356
|
-
console.log(` \u540C\u6B65\u5BC6\u7801: ${config.syncPassword ?
|
|
17229
|
+
console.log(import_chalk9.default.bold("WebDAV \u914D\u7F6E:"));
|
|
17230
|
+
console.log(` URL: ${import_chalk9.default.gray(config.webdavUrl)}`);
|
|
17231
|
+
console.log(` \u7528\u6237: ${import_chalk9.default.gray(config.username)}`);
|
|
17232
|
+
console.log(` \u8FDC\u7A0B\u76EE\u5F55: ${import_chalk9.default.gray(config.remoteDir)}`);
|
|
17233
|
+
console.log(` \u8BA4\u8BC1: ${import_chalk9.default.gray(config.authType === "password" ? "Basic Auth" : "Digest Auth")}`);
|
|
17234
|
+
console.log(` \u540C\u6B65\u5BC6\u7801: ${config.syncPassword ? import_chalk9.default.green("\u2713 \u5DF2\u4FDD\u5B58") : import_chalk9.default.yellow("\u2717 \u672A\u4FDD\u5B58")}`);
|
|
17357
17235
|
console.log();
|
|
17358
17236
|
const codexManager = createCodexManager();
|
|
17359
17237
|
const claudeManager = createClaudeManager();
|
|
17360
17238
|
const codexProviders = codexManager.list();
|
|
17361
17239
|
const claudeProviders = claudeManager.list();
|
|
17362
|
-
console.log(
|
|
17363
|
-
console.log(` Codex: ${
|
|
17364
|
-
console.log(` Claude: ${
|
|
17240
|
+
console.log(import_chalk9.default.bold("\u672C\u5730\u914D\u7F6E:"));
|
|
17241
|
+
console.log(` Codex: ${import_chalk9.default.cyan(codexProviders.length)} \u4E2A\u670D\u52A1\u5546`);
|
|
17242
|
+
console.log(` Claude: ${import_chalk9.default.cyan(claudeProviders.length)} \u4E2A\u670D\u52A1\u5546`);
|
|
17365
17243
|
if (config.lastSync) {
|
|
17366
17244
|
const date = new Date(config.lastSync).toLocaleString("zh-CN");
|
|
17367
|
-
console.log(` \u6700\u540E\u540C\u6B65: ${
|
|
17245
|
+
console.log(` \u6700\u540E\u540C\u6B65: ${import_chalk9.default.gray(date)}`);
|
|
17368
17246
|
}
|
|
17369
17247
|
console.log();
|
|
17370
|
-
console.log(
|
|
17371
|
-
console.log(
|
|
17372
|
-
console.log(
|
|
17373
|
-
console.log(
|
|
17248
|
+
console.log(import_chalk9.default.bold("\u540C\u6B65\u5EFA\u8BAE:"));
|
|
17249
|
+
console.log(import_chalk9.default.blue(" \u{1F4A1} \u4E0A\u4F20\u5230\u4E91\u7AEF: ccman sync upload"));
|
|
17250
|
+
console.log(import_chalk9.default.blue(" \u{1F4A1} \u4ECE\u4E91\u7AEF\u4E0B\u8F7D: ccman sync download"));
|
|
17251
|
+
console.log(import_chalk9.default.blue(" \u{1F4A1} \u667A\u80FD\u5408\u5E76: ccman sync merge"));
|
|
17374
17252
|
console.log();
|
|
17375
17253
|
} catch (error) {
|
|
17376
|
-
console.error(
|
|
17254
|
+
console.error(import_chalk9.default.red(`
|
|
17377
17255
|
\u274C ${error.message}
|
|
17378
17256
|
`));
|
|
17379
|
-
process.exit(1);
|
|
17380
17257
|
}
|
|
17381
17258
|
});
|
|
17382
17259
|
}
|
|
17383
|
-
var
|
|
17260
|
+
var import_chalk9;
|
|
17384
17261
|
var init_status = __esm({
|
|
17385
17262
|
"src/commands/sync/status.ts"() {
|
|
17386
17263
|
"use strict";
|
|
17387
|
-
|
|
17264
|
+
import_chalk9 = __toESM(require("chalk"));
|
|
17388
17265
|
init_dist4();
|
|
17389
17266
|
init_sync_config();
|
|
17390
17267
|
}
|
|
@@ -17407,7 +17284,7 @@ function createSyncCommands(program2) {
|
|
|
17407
17284
|
async function startSyncMenu() {
|
|
17408
17285
|
while (true) {
|
|
17409
17286
|
console.log();
|
|
17410
|
-
const { action } = await
|
|
17287
|
+
const { action } = await import_inquirer6.default.prompt([
|
|
17411
17288
|
{
|
|
17412
17289
|
type: "list",
|
|
17413
17290
|
name: "action",
|
|
@@ -17419,7 +17296,7 @@ async function startSyncMenu() {
|
|
|
17419
17296
|
{ name: "\u{1F4E5} \u4ECE\u4E91\u7AEF\u4E0B\u8F7D", value: "download" },
|
|
17420
17297
|
{ name: "\u{1F504} \u667A\u80FD\u5408\u5E76", value: "merge" },
|
|
17421
17298
|
{ name: "\u{1F4CA} \u67E5\u770B\u540C\u6B65\u72B6\u6001", value: "status" },
|
|
17422
|
-
{ name: "\u2B05\uFE0F \u8FD4\u56DE\
|
|
17299
|
+
{ name: "\u2B05\uFE0F \u8FD4\u56DE\u4E0A\u4E00\u7EA7", value: "back" }
|
|
17423
17300
|
]
|
|
17424
17301
|
}
|
|
17425
17302
|
]);
|
|
@@ -17430,53 +17307,53 @@ async function startSyncMenu() {
|
|
|
17430
17307
|
switch (action) {
|
|
17431
17308
|
case "config": {
|
|
17432
17309
|
const { configCommand: configCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
17433
|
-
const cmd = new
|
|
17310
|
+
const cmd = new import_commander2.Command();
|
|
17434
17311
|
configCommand2(cmd);
|
|
17435
17312
|
await cmd.parseAsync(["node", "ccman", "config"]);
|
|
17436
17313
|
break;
|
|
17437
17314
|
}
|
|
17438
17315
|
case "test": {
|
|
17439
17316
|
const { testCommand: testCommand2 } = await Promise.resolve().then(() => (init_test(), test_exports));
|
|
17440
|
-
const cmd = new
|
|
17317
|
+
const cmd = new import_commander2.Command();
|
|
17441
17318
|
testCommand2(cmd);
|
|
17442
17319
|
await cmd.parseAsync(["node", "ccman", "test"]);
|
|
17443
17320
|
break;
|
|
17444
17321
|
}
|
|
17445
17322
|
case "upload": {
|
|
17446
17323
|
const { uploadCommand: uploadCommand2 } = await Promise.resolve().then(() => (init_upload(), upload_exports));
|
|
17447
|
-
const cmd = new
|
|
17324
|
+
const cmd = new import_commander2.Command();
|
|
17448
17325
|
uploadCommand2(cmd);
|
|
17449
17326
|
await cmd.parseAsync(["node", "ccman", "upload"]);
|
|
17450
17327
|
break;
|
|
17451
17328
|
}
|
|
17452
17329
|
case "download": {
|
|
17453
17330
|
const { downloadCommand: downloadCommand2 } = await Promise.resolve().then(() => (init_download(), download_exports));
|
|
17454
|
-
const cmd = new
|
|
17331
|
+
const cmd = new import_commander2.Command();
|
|
17455
17332
|
downloadCommand2(cmd);
|
|
17456
17333
|
await cmd.parseAsync(["node", "ccman", "download"]);
|
|
17457
17334
|
break;
|
|
17458
17335
|
}
|
|
17459
17336
|
case "merge": {
|
|
17460
17337
|
const { mergeCommand: mergeCommand2 } = await Promise.resolve().then(() => (init_merge3(), merge_exports));
|
|
17461
|
-
const cmd = new
|
|
17338
|
+
const cmd = new import_commander2.Command();
|
|
17462
17339
|
mergeCommand2(cmd);
|
|
17463
17340
|
await cmd.parseAsync(["node", "ccman", "merge"]);
|
|
17464
17341
|
break;
|
|
17465
17342
|
}
|
|
17466
17343
|
case "status": {
|
|
17467
17344
|
const { statusCommand: statusCommand2 } = await Promise.resolve().then(() => (init_status(), status_exports));
|
|
17468
|
-
const cmd = new
|
|
17345
|
+
const cmd = new import_commander2.Command();
|
|
17469
17346
|
statusCommand2(cmd);
|
|
17470
17347
|
await cmd.parseAsync(["node", "ccman", "status"]);
|
|
17471
17348
|
break;
|
|
17472
17349
|
}
|
|
17473
17350
|
}
|
|
17474
17351
|
} catch (error) {
|
|
17475
|
-
console.error(
|
|
17352
|
+
console.error(import_chalk10.default.red(`
|
|
17476
17353
|
\u274C ${error.message}
|
|
17477
17354
|
`));
|
|
17478
17355
|
}
|
|
17479
|
-
await
|
|
17356
|
+
await import_inquirer6.default.prompt([
|
|
17480
17357
|
{
|
|
17481
17358
|
type: "input",
|
|
17482
17359
|
name: "continue",
|
|
@@ -17485,13 +17362,13 @@ async function startSyncMenu() {
|
|
|
17485
17362
|
]);
|
|
17486
17363
|
}
|
|
17487
17364
|
}
|
|
17488
|
-
var
|
|
17489
|
-
var
|
|
17365
|
+
var import_commander2, import_inquirer6, import_chalk10;
|
|
17366
|
+
var init_sync = __esm({
|
|
17490
17367
|
"src/commands/sync/index.ts"() {
|
|
17491
17368
|
"use strict";
|
|
17492
|
-
|
|
17493
|
-
|
|
17494
|
-
|
|
17369
|
+
import_commander2 = require("commander");
|
|
17370
|
+
import_inquirer6 = __toESM(require("inquirer"));
|
|
17371
|
+
import_chalk10 = __toESM(require("chalk"));
|
|
17495
17372
|
init_config2();
|
|
17496
17373
|
init_test();
|
|
17497
17374
|
init_upload();
|
|
@@ -17502,8 +17379,8 @@ var init_sync2 = __esm({
|
|
|
17502
17379
|
});
|
|
17503
17380
|
|
|
17504
17381
|
// src/index.ts
|
|
17505
|
-
var
|
|
17506
|
-
var
|
|
17382
|
+
var import_commander3 = require("commander");
|
|
17383
|
+
var import_chalk28 = __toESM(require("chalk"));
|
|
17507
17384
|
|
|
17508
17385
|
// src/utils/logo.ts
|
|
17509
17386
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -17527,13 +17404,13 @@ function printLogo() {
|
|
|
17527
17404
|
}
|
|
17528
17405
|
|
|
17529
17406
|
// src/commands/codex/add.ts
|
|
17530
|
-
var
|
|
17531
|
-
var
|
|
17407
|
+
var import_chalk12 = __toESM(require("chalk"));
|
|
17408
|
+
var import_inquirer8 = __toESM(require("inquirer"));
|
|
17532
17409
|
init_dist4();
|
|
17533
17410
|
|
|
17534
17411
|
// src/interactive.ts
|
|
17535
|
-
var
|
|
17536
|
-
var
|
|
17412
|
+
var import_inquirer7 = __toESM(require("inquirer"));
|
|
17413
|
+
var import_chalk11 = __toESM(require("chalk"));
|
|
17537
17414
|
init_dist4();
|
|
17538
17415
|
|
|
17539
17416
|
// src/utils/format.ts
|
|
@@ -17559,7 +17436,7 @@ function formatProviderTable(providers, currentId) {
|
|
|
17559
17436
|
|
|
17560
17437
|
// src/interactive.ts
|
|
17561
17438
|
async function promptProviderForm(defaults2) {
|
|
17562
|
-
const answers = await
|
|
17439
|
+
const answers = await import_inquirer7.default.prompt([
|
|
17563
17440
|
{
|
|
17564
17441
|
type: "input",
|
|
17565
17442
|
name: "name",
|
|
@@ -17604,7 +17481,7 @@ async function promptProviderForm(defaults2) {
|
|
|
17604
17481
|
async function startMainMenu() {
|
|
17605
17482
|
while (true) {
|
|
17606
17483
|
console.log();
|
|
17607
|
-
const { choice } = await
|
|
17484
|
+
const { choice } = await import_inquirer7.default.prompt([
|
|
17608
17485
|
{
|
|
17609
17486
|
type: "list",
|
|
17610
17487
|
name: "choice",
|
|
@@ -17619,7 +17496,7 @@ async function startMainMenu() {
|
|
|
17619
17496
|
}
|
|
17620
17497
|
]);
|
|
17621
17498
|
if (choice === "exit") {
|
|
17622
|
-
console.log(
|
|
17499
|
+
console.log(import_chalk11.default.gray("\n\u{1F44B} \u518D\u89C1!\n"));
|
|
17623
17500
|
break;
|
|
17624
17501
|
}
|
|
17625
17502
|
if (choice === "claude") {
|
|
@@ -17627,7 +17504,7 @@ async function startMainMenu() {
|
|
|
17627
17504
|
} else if (choice === "codex") {
|
|
17628
17505
|
await startCodexMenu();
|
|
17629
17506
|
} else if (choice === "sync") {
|
|
17630
|
-
const { startSyncMenu: startSyncMenu2 } = await Promise.resolve().then(() => (
|
|
17507
|
+
const { startSyncMenu: startSyncMenu2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
|
|
17631
17508
|
await startSyncMenu2();
|
|
17632
17509
|
} else if (choice === "presets") {
|
|
17633
17510
|
await showPresetsMenu();
|
|
@@ -17645,7 +17522,7 @@ async function showToolMenu(tool) {
|
|
|
17645
17522
|
const toolEmoji = tool === "claude" ? "\u{1F537}" : "\u{1F536}";
|
|
17646
17523
|
while (true) {
|
|
17647
17524
|
console.log();
|
|
17648
|
-
const { action } = await
|
|
17525
|
+
const { action } = await import_inquirer7.default.prompt([
|
|
17649
17526
|
{
|
|
17650
17527
|
type: "list",
|
|
17651
17528
|
name: "action",
|
|
@@ -17690,11 +17567,11 @@ async function showToolMenu(tool) {
|
|
|
17690
17567
|
break;
|
|
17691
17568
|
}
|
|
17692
17569
|
} catch (error) {
|
|
17693
|
-
console.error(
|
|
17570
|
+
console.error(import_chalk11.default.red(`
|
|
17694
17571
|
\u274C ${error.message}
|
|
17695
17572
|
`));
|
|
17696
17573
|
}
|
|
17697
|
-
await
|
|
17574
|
+
await import_inquirer7.default.prompt([
|
|
17698
17575
|
{
|
|
17699
17576
|
type: "input",
|
|
17700
17577
|
name: "continue",
|
|
@@ -17704,16 +17581,16 @@ async function showToolMenu(tool) {
|
|
|
17704
17581
|
}
|
|
17705
17582
|
}
|
|
17706
17583
|
async function showPresetsMenu() {
|
|
17707
|
-
console.log(
|
|
17584
|
+
console.log(import_chalk11.default.yellow("\n\u26A0\uFE0F \u9884\u7F6E\u670D\u52A1\u5546\u7BA1\u7406\u529F\u80FD\u5373\u5C06\u63A8\u51FA\n"));
|
|
17708
17585
|
}
|
|
17709
17586
|
async function handleAdd(tool) {
|
|
17710
17587
|
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
17711
17588
|
const toolName = tool === "claude" ? "Claude" : "Codex";
|
|
17712
17589
|
const presets = manager.listPresets();
|
|
17713
|
-
console.log(
|
|
17590
|
+
console.log(import_chalk11.default.bold(`
|
|
17714
17591
|
\u{1F4DD} \u6DFB\u52A0 ${toolName} \u670D\u52A1\u5546
|
|
17715
17592
|
`));
|
|
17716
|
-
const { usePreset } = await
|
|
17593
|
+
const { usePreset } = await import_inquirer7.default.prompt([
|
|
17717
17594
|
{
|
|
17718
17595
|
type: "list",
|
|
17719
17596
|
name: "usePreset",
|
|
@@ -17728,7 +17605,7 @@ async function handleAdd(tool) {
|
|
|
17728
17605
|
let baseUrl;
|
|
17729
17606
|
let apiKey;
|
|
17730
17607
|
if (usePreset) {
|
|
17731
|
-
const { presetName } = await
|
|
17608
|
+
const { presetName } = await import_inquirer7.default.prompt([
|
|
17732
17609
|
{
|
|
17733
17610
|
type: "list",
|
|
17734
17611
|
name: "presetName",
|
|
@@ -17740,7 +17617,7 @@ async function handleAdd(tool) {
|
|
|
17740
17617
|
}
|
|
17741
17618
|
]);
|
|
17742
17619
|
const preset = presets.find((p) => p.name === presetName);
|
|
17743
|
-
console.log(
|
|
17620
|
+
console.log(import_chalk11.default.blue(`
|
|
17744
17621
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
17745
17622
|
`));
|
|
17746
17623
|
const input = await promptProviderForm({
|
|
@@ -17752,7 +17629,7 @@ async function handleAdd(tool) {
|
|
|
17752
17629
|
baseUrl = input.baseUrl;
|
|
17753
17630
|
apiKey = input.apiKey;
|
|
17754
17631
|
} else {
|
|
17755
|
-
const answers = await
|
|
17632
|
+
const answers = await import_inquirer7.default.prompt([
|
|
17756
17633
|
{
|
|
17757
17634
|
type: "input",
|
|
17758
17635
|
name: "name",
|
|
@@ -17785,12 +17662,12 @@ async function handleAdd(tool) {
|
|
|
17785
17662
|
}
|
|
17786
17663
|
const provider = manager.add({ name, baseUrl, apiKey });
|
|
17787
17664
|
console.log();
|
|
17788
|
-
console.log(
|
|
17665
|
+
console.log(import_chalk11.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
|
|
17789
17666
|
console.log();
|
|
17790
|
-
console.log(` ${
|
|
17791
|
-
console.log(` ${
|
|
17667
|
+
console.log(` ${import_chalk11.default.bold(provider.name)} ${import_chalk11.default.blue(`[${toolName}]`)}`);
|
|
17668
|
+
console.log(` ${import_chalk11.default.gray(provider.baseUrl)}`);
|
|
17792
17669
|
console.log();
|
|
17793
|
-
const { switchNow } = await
|
|
17670
|
+
const { switchNow } = await import_inquirer7.default.prompt([
|
|
17794
17671
|
{
|
|
17795
17672
|
type: "confirm",
|
|
17796
17673
|
name: "switchNow",
|
|
@@ -17800,9 +17677,9 @@ async function handleAdd(tool) {
|
|
|
17800
17677
|
]);
|
|
17801
17678
|
if (switchNow) {
|
|
17802
17679
|
manager.switch(provider.id);
|
|
17803
|
-
console.log(
|
|
17680
|
+
console.log(import_chalk11.default.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546\n"));
|
|
17804
17681
|
} else {
|
|
17805
|
-
console.log(
|
|
17682
|
+
console.log(import_chalk11.default.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + import_chalk11.default.white(` ccman ${tool === "codex" ? "cx" : "cc"} use "${provider.name}"
|
|
17806
17683
|
`));
|
|
17807
17684
|
}
|
|
17808
17685
|
}
|
|
@@ -17811,23 +17688,23 @@ async function handleSwitch(tool) {
|
|
|
17811
17688
|
const providers = manager.list();
|
|
17812
17689
|
const current = manager.getCurrent();
|
|
17813
17690
|
if (providers.length === 0) {
|
|
17814
|
-
console.log(
|
|
17691
|
+
console.log(import_chalk11.default.yellow("\n\u26A0\uFE0F \u6682\u65E0\u670D\u52A1\u5546\n"));
|
|
17815
17692
|
return;
|
|
17816
17693
|
}
|
|
17817
|
-
const { providerId } = await
|
|
17694
|
+
const { providerId } = await import_inquirer7.default.prompt([
|
|
17818
17695
|
{
|
|
17819
17696
|
type: "list",
|
|
17820
17697
|
name: "providerId",
|
|
17821
17698
|
message: "\u9009\u62E9\u8981\u5207\u6362\u7684\u670D\u52A1\u5546:",
|
|
17822
17699
|
choices: providers.map((p) => ({
|
|
17823
|
-
name: `${p.name}${current?.id === p.id ?
|
|
17700
|
+
name: `${p.name}${current?.id === p.id ? import_chalk11.default.green(" (\u5F53\u524D)") : ""}`,
|
|
17824
17701
|
value: p.id
|
|
17825
17702
|
}))
|
|
17826
17703
|
}
|
|
17827
17704
|
]);
|
|
17828
17705
|
manager.switch(providerId);
|
|
17829
17706
|
const provider = providers.find((p) => p.id === providerId);
|
|
17830
|
-
console.log(
|
|
17707
|
+
console.log(import_chalk11.default.green(`
|
|
17831
17708
|
\u2705 \u5DF2\u5207\u6362\u5230: ${provider.name}
|
|
17832
17709
|
`));
|
|
17833
17710
|
}
|
|
@@ -17837,12 +17714,12 @@ async function handleList(tool) {
|
|
|
17837
17714
|
const current = manager.getCurrent();
|
|
17838
17715
|
const toolName = tool === "claude" ? "Claude" : "Codex";
|
|
17839
17716
|
if (providers.length === 0) {
|
|
17840
|
-
console.log(
|
|
17717
|
+
console.log(import_chalk11.default.yellow(`
|
|
17841
17718
|
\u26A0\uFE0F \u6682\u65E0 ${toolName} \u670D\u52A1\u5546
|
|
17842
17719
|
`));
|
|
17843
17720
|
return;
|
|
17844
17721
|
}
|
|
17845
|
-
console.log(
|
|
17722
|
+
console.log(import_chalk11.default.bold(`
|
|
17846
17723
|
\u{1F4CB} ${toolName} \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
|
|
17847
17724
|
console.log(formatProviderTable(providers, current?.id, toolName));
|
|
17848
17725
|
}
|
|
@@ -17851,19 +17728,19 @@ async function handleCurrent(tool) {
|
|
|
17851
17728
|
const current = manager.getCurrent();
|
|
17852
17729
|
const toolName = tool === "claude" ? "Claude" : "Codex";
|
|
17853
17730
|
if (!current) {
|
|
17854
|
-
console.log(
|
|
17731
|
+
console.log(import_chalk11.default.yellow(`
|
|
17855
17732
|
\u26A0\uFE0F \u672A\u9009\u62E9\u4EFB\u4F55 ${toolName} \u670D\u52A1\u5546
|
|
17856
17733
|
`));
|
|
17857
17734
|
return;
|
|
17858
17735
|
}
|
|
17859
|
-
console.log(
|
|
17736
|
+
console.log(import_chalk11.default.bold(`
|
|
17860
17737
|
\u{1F441}\uFE0F \u5F53\u524D ${toolName} \u670D\u52A1\u5546
|
|
17861
17738
|
`));
|
|
17862
|
-
console.log(` ${
|
|
17863
|
-
console.log(` ${
|
|
17739
|
+
console.log(` ${import_chalk11.default.green.bold(current.name)}`);
|
|
17740
|
+
console.log(` ${import_chalk11.default.gray(current.baseUrl)}`);
|
|
17864
17741
|
if (current.lastUsedAt) {
|
|
17865
17742
|
const date = new Date(current.lastUsedAt).toLocaleString("zh-CN");
|
|
17866
|
-
console.log(` ${
|
|
17743
|
+
console.log(` ${import_chalk11.default.gray(`\u6700\u540E\u4F7F\u7528: ${date}`)}`);
|
|
17867
17744
|
}
|
|
17868
17745
|
console.log();
|
|
17869
17746
|
}
|
|
@@ -17871,10 +17748,10 @@ async function handleEdit(tool) {
|
|
|
17871
17748
|
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
17872
17749
|
const providers = manager.list();
|
|
17873
17750
|
if (providers.length === 0) {
|
|
17874
|
-
console.log(
|
|
17751
|
+
console.log(import_chalk11.default.yellow("\n\u26A0\uFE0F \u6682\u65E0\u670D\u52A1\u5546\n"));
|
|
17875
17752
|
return;
|
|
17876
17753
|
}
|
|
17877
|
-
const { providerId } = await
|
|
17754
|
+
const { providerId } = await import_inquirer7.default.prompt([
|
|
17878
17755
|
{
|
|
17879
17756
|
type: "list",
|
|
17880
17757
|
name: "providerId",
|
|
@@ -17886,7 +17763,7 @@ async function handleEdit(tool) {
|
|
|
17886
17763
|
}
|
|
17887
17764
|
]);
|
|
17888
17765
|
const provider = providers.find((p) => p.id === providerId);
|
|
17889
|
-
const answers = await
|
|
17766
|
+
const answers = await import_inquirer7.default.prompt([
|
|
17890
17767
|
{
|
|
17891
17768
|
type: "input",
|
|
17892
17769
|
name: "name",
|
|
@@ -17919,16 +17796,16 @@ async function handleEdit(tool) {
|
|
|
17919
17796
|
baseUrl: answers.baseUrl,
|
|
17920
17797
|
apiKey: answers.apiKey || void 0
|
|
17921
17798
|
});
|
|
17922
|
-
console.log(
|
|
17799
|
+
console.log(import_chalk11.default.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
17923
17800
|
}
|
|
17924
17801
|
async function handleClone(tool) {
|
|
17925
17802
|
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
17926
17803
|
const providers = manager.list();
|
|
17927
17804
|
if (providers.length === 0) {
|
|
17928
|
-
console.log(
|
|
17805
|
+
console.log(import_chalk11.default.yellow("\n\u26A0\uFE0F \u6682\u65E0\u670D\u52A1\u5546\n"));
|
|
17929
17806
|
return;
|
|
17930
17807
|
}
|
|
17931
|
-
const { providerId } = await
|
|
17808
|
+
const { providerId } = await import_inquirer7.default.prompt([
|
|
17932
17809
|
{
|
|
17933
17810
|
type: "list",
|
|
17934
17811
|
name: "providerId",
|
|
@@ -17940,7 +17817,7 @@ async function handleClone(tool) {
|
|
|
17940
17817
|
}
|
|
17941
17818
|
]);
|
|
17942
17819
|
const provider = providers.find((p) => p.id === providerId);
|
|
17943
|
-
const answers = await
|
|
17820
|
+
const answers = await import_inquirer7.default.prompt([
|
|
17944
17821
|
{
|
|
17945
17822
|
type: "input",
|
|
17946
17823
|
name: "name",
|
|
@@ -17961,19 +17838,19 @@ async function handleClone(tool) {
|
|
|
17961
17838
|
baseUrl: provider.baseUrl,
|
|
17962
17839
|
apiKey: answers.apiKey
|
|
17963
17840
|
});
|
|
17964
|
-
console.log(
|
|
17965
|
-
console.log(` ${
|
|
17966
|
-
console.log(` ${
|
|
17841
|
+
console.log(import_chalk11.default.green("\n\u2705 \u514B\u9686\u6210\u529F\n"));
|
|
17842
|
+
console.log(` ${import_chalk11.default.bold(newProvider.name)}`);
|
|
17843
|
+
console.log(` ${import_chalk11.default.gray(newProvider.baseUrl)}`);
|
|
17967
17844
|
console.log();
|
|
17968
17845
|
}
|
|
17969
17846
|
async function handleRemove(tool) {
|
|
17970
17847
|
const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
|
|
17971
17848
|
const providers = manager.list();
|
|
17972
17849
|
if (providers.length === 0) {
|
|
17973
|
-
console.log(
|
|
17850
|
+
console.log(import_chalk11.default.yellow("\n\u26A0\uFE0F \u6682\u65E0\u670D\u52A1\u5546\n"));
|
|
17974
17851
|
return;
|
|
17975
17852
|
}
|
|
17976
|
-
const { providerId } = await
|
|
17853
|
+
const { providerId } = await import_inquirer7.default.prompt([
|
|
17977
17854
|
{
|
|
17978
17855
|
type: "list",
|
|
17979
17856
|
name: "providerId",
|
|
@@ -17985,7 +17862,7 @@ async function handleRemove(tool) {
|
|
|
17985
17862
|
}
|
|
17986
17863
|
]);
|
|
17987
17864
|
const provider = providers.find((p) => p.id === providerId);
|
|
17988
|
-
const { confirm } = await
|
|
17865
|
+
const { confirm } = await import_inquirer7.default.prompt([
|
|
17989
17866
|
{
|
|
17990
17867
|
type: "confirm",
|
|
17991
17868
|
name: "confirm",
|
|
@@ -17995,11 +17872,11 @@ async function handleRemove(tool) {
|
|
|
17995
17872
|
]);
|
|
17996
17873
|
if (confirm) {
|
|
17997
17874
|
manager.remove(providerId);
|
|
17998
|
-
console.log(
|
|
17875
|
+
console.log(import_chalk11.default.green(`
|
|
17999
17876
|
\u2705 \u5DF2\u5220\u9664: ${provider.name}
|
|
18000
17877
|
`));
|
|
18001
17878
|
} else {
|
|
18002
|
-
console.log(
|
|
17879
|
+
console.log(import_chalk11.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
18003
17880
|
}
|
|
18004
17881
|
}
|
|
18005
17882
|
|
|
@@ -18008,8 +17885,8 @@ function addCommand(program2) {
|
|
|
18008
17885
|
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Codex \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
|
|
18009
17886
|
try {
|
|
18010
17887
|
const manager = createCodexManager();
|
|
18011
|
-
console.log(
|
|
18012
|
-
const { usePreset } = await
|
|
17888
|
+
console.log(import_chalk12.default.bold("\n\u{1F4DD} \u6DFB\u52A0 Codex \u670D\u52A1\u5546\n"));
|
|
17889
|
+
const { usePreset } = await import_inquirer8.default.prompt([
|
|
18013
17890
|
{
|
|
18014
17891
|
type: "list",
|
|
18015
17892
|
name: "usePreset",
|
|
@@ -18024,7 +17901,7 @@ function addCommand(program2) {
|
|
|
18024
17901
|
let baseUrl;
|
|
18025
17902
|
let apiKey;
|
|
18026
17903
|
if (usePreset) {
|
|
18027
|
-
const { presetName } = await
|
|
17904
|
+
const { presetName } = await import_inquirer8.default.prompt([
|
|
18028
17905
|
{
|
|
18029
17906
|
type: "list",
|
|
18030
17907
|
name: "presetName",
|
|
@@ -18036,7 +17913,7 @@ function addCommand(program2) {
|
|
|
18036
17913
|
}
|
|
18037
17914
|
]);
|
|
18038
17915
|
const preset = CODEX_PRESETS.find((p) => p.name === presetName);
|
|
18039
|
-
console.log(
|
|
17916
|
+
console.log(import_chalk12.default.blue(`
|
|
18040
17917
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
18041
17918
|
`));
|
|
18042
17919
|
const input = await promptProviderForm({
|
|
@@ -18048,7 +17925,7 @@ function addCommand(program2) {
|
|
|
18048
17925
|
baseUrl = input.baseUrl;
|
|
18049
17926
|
apiKey = input.apiKey;
|
|
18050
17927
|
} else {
|
|
18051
|
-
const answers = await
|
|
17928
|
+
const answers = await import_inquirer8.default.prompt([
|
|
18052
17929
|
{
|
|
18053
17930
|
type: "input",
|
|
18054
17931
|
name: "name",
|
|
@@ -18087,12 +17964,12 @@ function addCommand(program2) {
|
|
|
18087
17964
|
}
|
|
18088
17965
|
const provider = manager.add({ name, baseUrl, apiKey });
|
|
18089
17966
|
console.log();
|
|
18090
|
-
console.log(
|
|
17967
|
+
console.log(import_chalk12.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
|
|
18091
17968
|
console.log();
|
|
18092
|
-
console.log(` ${
|
|
18093
|
-
console.log(` ${
|
|
17969
|
+
console.log(` ${import_chalk12.default.bold(provider.name)} ${import_chalk12.default.blue("[Codex]")}`);
|
|
17970
|
+
console.log(` ${import_chalk12.default.gray(provider.baseUrl)}`);
|
|
18094
17971
|
console.log();
|
|
18095
|
-
const { switchNow } = await
|
|
17972
|
+
const { switchNow } = await import_inquirer8.default.prompt([
|
|
18096
17973
|
{
|
|
18097
17974
|
type: "confirm",
|
|
18098
17975
|
name: "switchNow",
|
|
@@ -18102,16 +17979,16 @@ function addCommand(program2) {
|
|
|
18102
17979
|
]);
|
|
18103
17980
|
if (switchNow) {
|
|
18104
17981
|
manager.switch(provider.id);
|
|
18105
|
-
console.log(
|
|
17982
|
+
console.log(import_chalk12.default.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
|
|
18106
17983
|
console.log();
|
|
18107
|
-
console.log(
|
|
18108
|
-
console.log(
|
|
18109
|
-
console.log(
|
|
17984
|
+
console.log(import_chalk12.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
17985
|
+
console.log(import_chalk12.default.gray(` - ${getCodexConfigPath()}`));
|
|
17986
|
+
console.log(import_chalk12.default.gray(` - ${getCodexAuthPath()}`));
|
|
18110
17987
|
} else {
|
|
18111
|
-
console.log(
|
|
17988
|
+
console.log(import_chalk12.default.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + import_chalk12.default.white(` ccman cx use "${provider.name}"`));
|
|
18112
17989
|
}
|
|
18113
17990
|
} catch (error) {
|
|
18114
|
-
console.error(
|
|
17991
|
+
console.error(import_chalk12.default.red(`
|
|
18115
17992
|
\u274C ${error.message}
|
|
18116
17993
|
`));
|
|
18117
17994
|
process.exit(1);
|
|
@@ -18120,7 +17997,7 @@ function addCommand(program2) {
|
|
|
18120
17997
|
}
|
|
18121
17998
|
|
|
18122
17999
|
// src/commands/codex/list.ts
|
|
18123
|
-
var
|
|
18000
|
+
var import_chalk13 = __toESM(require("chalk"));
|
|
18124
18001
|
init_dist4();
|
|
18125
18002
|
function listCommand(program2) {
|
|
18126
18003
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 Codex \u670D\u52A1\u5546").action(async () => {
|
|
@@ -18129,15 +18006,15 @@ function listCommand(program2) {
|
|
|
18129
18006
|
const providers = manager.list();
|
|
18130
18007
|
const current = manager.getCurrent();
|
|
18131
18008
|
if (providers.length === 0) {
|
|
18132
|
-
console.log(
|
|
18133
|
-
console.log(
|
|
18009
|
+
console.log(import_chalk13.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
18010
|
+
console.log(import_chalk13.default.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + import_chalk13.default.white(" ccman cx add\n"));
|
|
18134
18011
|
return;
|
|
18135
18012
|
}
|
|
18136
|
-
console.log(
|
|
18013
|
+
console.log(import_chalk13.default.bold(`
|
|
18137
18014
|
\u{1F4CB} Codex \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
|
|
18138
18015
|
console.log(formatProviderTable(providers, current?.id, "Codex"));
|
|
18139
18016
|
} catch (error) {
|
|
18140
|
-
console.error(
|
|
18017
|
+
console.error(import_chalk13.default.red(`
|
|
18141
18018
|
\u274C ${error.message}
|
|
18142
18019
|
`));
|
|
18143
18020
|
process.exit(1);
|
|
@@ -18146,8 +18023,8 @@ function listCommand(program2) {
|
|
|
18146
18023
|
}
|
|
18147
18024
|
|
|
18148
18025
|
// src/commands/codex/use.ts
|
|
18149
|
-
var
|
|
18150
|
-
var
|
|
18026
|
+
var import_chalk14 = __toESM(require("chalk"));
|
|
18027
|
+
var import_inquirer9 = __toESM(require("inquirer"));
|
|
18151
18028
|
init_dist4();
|
|
18152
18029
|
function useCommand(program2) {
|
|
18153
18030
|
program2.command("use [name]").description("\u5207\u6362 Codex \u670D\u52A1\u5546").action(async (name) => {
|
|
@@ -18155,8 +18032,8 @@ function useCommand(program2) {
|
|
|
18155
18032
|
const manager = createCodexManager();
|
|
18156
18033
|
const providers = manager.list();
|
|
18157
18034
|
if (providers.length === 0) {
|
|
18158
|
-
console.log(
|
|
18159
|
-
console.log(
|
|
18035
|
+
console.log(import_chalk14.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
18036
|
+
console.log(import_chalk14.default.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + import_chalk14.default.white(" ccman cx add\n"));
|
|
18160
18037
|
return;
|
|
18161
18038
|
}
|
|
18162
18039
|
let targetId;
|
|
@@ -18167,7 +18044,7 @@ function useCommand(program2) {
|
|
|
18167
18044
|
}
|
|
18168
18045
|
targetId = provider2.id;
|
|
18169
18046
|
} else {
|
|
18170
|
-
const { selectedId } = await
|
|
18047
|
+
const { selectedId } = await import_inquirer9.default.prompt([
|
|
18171
18048
|
{
|
|
18172
18049
|
type: "list",
|
|
18173
18050
|
name: "selectedId",
|
|
@@ -18183,23 +18060,23 @@ function useCommand(program2) {
|
|
|
18183
18060
|
manager.switch(targetId);
|
|
18184
18061
|
const provider = manager.get(targetId);
|
|
18185
18062
|
console.log();
|
|
18186
|
-
console.log(
|
|
18063
|
+
console.log(import_chalk14.default.green("\u2705 \u5207\u6362\u6210\u529F"));
|
|
18187
18064
|
console.log();
|
|
18188
|
-
console.log(` ${
|
|
18189
|
-
console.log(` ${
|
|
18065
|
+
console.log(` ${import_chalk14.default.bold(provider.name)} ${import_chalk14.default.blue("[Codex]")}`);
|
|
18066
|
+
console.log(` ${import_chalk14.default.gray(`URL: ${provider.baseUrl}`)}`);
|
|
18190
18067
|
console.log();
|
|
18191
|
-
console.log(
|
|
18192
|
-
console.log(
|
|
18193
|
-
console.log(
|
|
18068
|
+
console.log(import_chalk14.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
18069
|
+
console.log(import_chalk14.default.gray(` - ${getCodexConfigPath()}`));
|
|
18070
|
+
console.log(import_chalk14.default.gray(` - ${getCodexAuthPath()}`));
|
|
18194
18071
|
console.log();
|
|
18195
18072
|
} catch (error) {
|
|
18196
18073
|
if (error instanceof ProviderNotFoundError) {
|
|
18197
|
-
console.error(
|
|
18074
|
+
console.error(import_chalk14.default.red(`
|
|
18198
18075
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${error.message}
|
|
18199
18076
|
`));
|
|
18200
|
-
console.log(
|
|
18077
|
+
console.log(import_chalk14.default.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + import_chalk14.default.white(" ccman cx list\n"));
|
|
18201
18078
|
} else {
|
|
18202
|
-
console.error(
|
|
18079
|
+
console.error(import_chalk14.default.red(`
|
|
18203
18080
|
\u274C ${error.message}
|
|
18204
18081
|
`));
|
|
18205
18082
|
}
|
|
@@ -18209,7 +18086,7 @@ function useCommand(program2) {
|
|
|
18209
18086
|
}
|
|
18210
18087
|
|
|
18211
18088
|
// src/commands/codex/current.ts
|
|
18212
|
-
var
|
|
18089
|
+
var import_chalk15 = __toESM(require("chalk"));
|
|
18213
18090
|
init_dist4();
|
|
18214
18091
|
function currentCommand(program2) {
|
|
18215
18092
|
program2.command("current").description("\u663E\u793A\u5F53\u524D\u4F7F\u7528\u7684 Codex \u670D\u52A1\u5546").action(async () => {
|
|
@@ -18217,21 +18094,21 @@ function currentCommand(program2) {
|
|
|
18217
18094
|
const manager = createCodexManager();
|
|
18218
18095
|
const current = manager.getCurrent();
|
|
18219
18096
|
if (!current) {
|
|
18220
|
-
console.log(
|
|
18221
|
-
console.log(
|
|
18097
|
+
console.log(import_chalk15.default.yellow("\n\u26A0\uFE0F \u672A\u9009\u62E9\u4EFB\u4F55 Codex \u670D\u52A1\u5546\n"));
|
|
18098
|
+
console.log(import_chalk15.default.blue("\u{1F4A1} \u9009\u62E9\u670D\u52A1\u5546:") + import_chalk15.default.white(" ccman cx use\n"));
|
|
18222
18099
|
return;
|
|
18223
18100
|
}
|
|
18224
|
-
console.log(
|
|
18225
|
-
console.log(` ${
|
|
18226
|
-
console.log(` ${
|
|
18227
|
-
console.log(` ${
|
|
18101
|
+
console.log(import_chalk15.default.bold("\n\u{1F4CD} \u5F53\u524D Codex \u670D\u52A1\u5546\n"));
|
|
18102
|
+
console.log(` ${import_chalk15.default.green.bold(current.name)}`);
|
|
18103
|
+
console.log(` ${import_chalk15.default.gray(`ID: ${current.id}`)}`);
|
|
18104
|
+
console.log(` ${import_chalk15.default.gray(`URL: ${current.baseUrl}`)}`);
|
|
18228
18105
|
if (current.lastUsedAt) {
|
|
18229
18106
|
const date = new Date(current.lastUsedAt).toLocaleString("zh-CN");
|
|
18230
|
-
console.log(` ${
|
|
18107
|
+
console.log(` ${import_chalk15.default.gray(`\u6700\u540E\u4F7F\u7528: ${date}`)}`);
|
|
18231
18108
|
}
|
|
18232
18109
|
console.log();
|
|
18233
18110
|
} catch (error) {
|
|
18234
|
-
console.error(
|
|
18111
|
+
console.error(import_chalk15.default.red(`
|
|
18235
18112
|
\u274C ${error.message}
|
|
18236
18113
|
`));
|
|
18237
18114
|
process.exit(1);
|
|
@@ -18240,8 +18117,8 @@ function currentCommand(program2) {
|
|
|
18240
18117
|
}
|
|
18241
18118
|
|
|
18242
18119
|
// src/commands/codex/remove.ts
|
|
18243
|
-
var
|
|
18244
|
-
var
|
|
18120
|
+
var import_chalk16 = __toESM(require("chalk"));
|
|
18121
|
+
var import_inquirer10 = __toESM(require("inquirer"));
|
|
18245
18122
|
init_dist4();
|
|
18246
18123
|
function removeCommand(program2) {
|
|
18247
18124
|
program2.command("remove [name]").alias("rm").description("\u5220\u9664 Codex \u670D\u52A1\u5546").action(async (name) => {
|
|
@@ -18249,7 +18126,7 @@ function removeCommand(program2) {
|
|
|
18249
18126
|
const manager = createCodexManager();
|
|
18250
18127
|
const providers = manager.list();
|
|
18251
18128
|
if (providers.length === 0) {
|
|
18252
|
-
console.log(
|
|
18129
|
+
console.log(import_chalk16.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
18253
18130
|
return;
|
|
18254
18131
|
}
|
|
18255
18132
|
let targetId;
|
|
@@ -18262,7 +18139,7 @@ function removeCommand(program2) {
|
|
|
18262
18139
|
targetId = provider.id;
|
|
18263
18140
|
targetName = provider.name;
|
|
18264
18141
|
} else {
|
|
18265
|
-
const { selectedId } = await
|
|
18142
|
+
const { selectedId } = await import_inquirer10.default.prompt([
|
|
18266
18143
|
{
|
|
18267
18144
|
type: "list",
|
|
18268
18145
|
name: "selectedId",
|
|
@@ -18277,7 +18154,7 @@ function removeCommand(program2) {
|
|
|
18277
18154
|
targetId = selectedId;
|
|
18278
18155
|
targetName = provider.name;
|
|
18279
18156
|
}
|
|
18280
|
-
const { confirmed } = await
|
|
18157
|
+
const { confirmed } = await import_inquirer10.default.prompt([
|
|
18281
18158
|
{
|
|
18282
18159
|
type: "confirm",
|
|
18283
18160
|
name: "confirmed",
|
|
@@ -18286,21 +18163,21 @@ function removeCommand(program2) {
|
|
|
18286
18163
|
}
|
|
18287
18164
|
]);
|
|
18288
18165
|
if (!confirmed) {
|
|
18289
|
-
console.log(
|
|
18166
|
+
console.log(import_chalk16.default.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
18290
18167
|
return;
|
|
18291
18168
|
}
|
|
18292
18169
|
manager.remove(targetId);
|
|
18293
18170
|
console.log();
|
|
18294
|
-
console.log(
|
|
18171
|
+
console.log(import_chalk16.default.green(`\u2705 \u5DF2\u5220\u9664: ${targetName}`));
|
|
18295
18172
|
console.log();
|
|
18296
18173
|
} catch (error) {
|
|
18297
18174
|
if (error instanceof ProviderNotFoundError) {
|
|
18298
|
-
console.error(
|
|
18175
|
+
console.error(import_chalk16.default.red(`
|
|
18299
18176
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728
|
|
18300
18177
|
`));
|
|
18301
|
-
console.log(
|
|
18178
|
+
console.log(import_chalk16.default.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + import_chalk16.default.white(" ccman cx list\n"));
|
|
18302
18179
|
} else {
|
|
18303
|
-
console.error(
|
|
18180
|
+
console.error(import_chalk16.default.red(`
|
|
18304
18181
|
\u274C ${error.message}
|
|
18305
18182
|
`));
|
|
18306
18183
|
}
|
|
@@ -18310,8 +18187,8 @@ function removeCommand(program2) {
|
|
|
18310
18187
|
}
|
|
18311
18188
|
|
|
18312
18189
|
// src/commands/codex/edit.ts
|
|
18313
|
-
var
|
|
18314
|
-
var
|
|
18190
|
+
var import_chalk17 = __toESM(require("chalk"));
|
|
18191
|
+
var import_inquirer11 = __toESM(require("inquirer"));
|
|
18315
18192
|
init_dist4();
|
|
18316
18193
|
function editCommand(program2) {
|
|
18317
18194
|
program2.command("edit [name]").description("\u7F16\u8F91 Codex \u670D\u52A1\u5546").action(async (name) => {
|
|
@@ -18319,7 +18196,7 @@ function editCommand(program2) {
|
|
|
18319
18196
|
const manager = createCodexManager();
|
|
18320
18197
|
const providers = manager.list();
|
|
18321
18198
|
if (providers.length === 0) {
|
|
18322
|
-
console.log(
|
|
18199
|
+
console.log(import_chalk17.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
18323
18200
|
return;
|
|
18324
18201
|
}
|
|
18325
18202
|
let targetId;
|
|
@@ -18330,7 +18207,7 @@ function editCommand(program2) {
|
|
|
18330
18207
|
}
|
|
18331
18208
|
targetId = provider2.id;
|
|
18332
18209
|
} else {
|
|
18333
|
-
const { selectedId } = await
|
|
18210
|
+
const { selectedId } = await import_inquirer11.default.prompt([
|
|
18334
18211
|
{
|
|
18335
18212
|
type: "list",
|
|
18336
18213
|
name: "selectedId",
|
|
@@ -18344,9 +18221,9 @@ function editCommand(program2) {
|
|
|
18344
18221
|
targetId = selectedId;
|
|
18345
18222
|
}
|
|
18346
18223
|
const provider = manager.get(targetId);
|
|
18347
|
-
console.log(
|
|
18348
|
-
console.log(
|
|
18349
|
-
const answers = await
|
|
18224
|
+
console.log(import_chalk17.default.bold("\n\u270F\uFE0F \u7F16\u8F91\u670D\u52A1\u5546\n"));
|
|
18225
|
+
console.log(import_chalk17.default.gray("\u63D0\u793A: \u7559\u7A7A\u5219\u4FDD\u6301\u539F\u503C\n"));
|
|
18226
|
+
const answers = await import_inquirer11.default.prompt([
|
|
18350
18227
|
{
|
|
18351
18228
|
type: "input",
|
|
18352
18229
|
name: "name",
|
|
@@ -18377,19 +18254,19 @@ function editCommand(program2) {
|
|
|
18377
18254
|
if (answers.baseUrl && answers.baseUrl !== provider.baseUrl) updates.baseUrl = answers.baseUrl;
|
|
18378
18255
|
if (answers.apiKey) updates.apiKey = answers.apiKey;
|
|
18379
18256
|
if (Object.keys(updates).length === 0) {
|
|
18380
|
-
console.log(
|
|
18257
|
+
console.log(import_chalk17.default.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
18381
18258
|
return;
|
|
18382
18259
|
}
|
|
18383
18260
|
const updated = manager.edit(targetId, updates);
|
|
18384
18261
|
console.log();
|
|
18385
|
-
console.log(
|
|
18262
|
+
console.log(import_chalk17.default.green("\u2705 \u7F16\u8F91\u6210\u529F"));
|
|
18386
18263
|
console.log();
|
|
18387
|
-
console.log(` ${
|
|
18388
|
-
console.log(` ${
|
|
18389
|
-
console.log(` ${
|
|
18264
|
+
console.log(` ${import_chalk17.default.bold(updated.name)} ${import_chalk17.default.blue("[Codex]")}`);
|
|
18265
|
+
console.log(` ${import_chalk17.default.gray(`ID: ${updated.id}`)}`);
|
|
18266
|
+
console.log(` ${import_chalk17.default.gray(`URL: ${updated.baseUrl}`)}`);
|
|
18390
18267
|
console.log();
|
|
18391
18268
|
} catch (error) {
|
|
18392
|
-
console.error(
|
|
18269
|
+
console.error(import_chalk17.default.red(`
|
|
18393
18270
|
\u274C ${error.message}
|
|
18394
18271
|
`));
|
|
18395
18272
|
process.exit(1);
|
|
@@ -18398,8 +18275,8 @@ function editCommand(program2) {
|
|
|
18398
18275
|
}
|
|
18399
18276
|
|
|
18400
18277
|
// src/commands/codex/clone.ts
|
|
18401
|
-
var
|
|
18402
|
-
var
|
|
18278
|
+
var import_chalk18 = __toESM(require("chalk"));
|
|
18279
|
+
var import_inquirer12 = __toESM(require("inquirer"));
|
|
18403
18280
|
init_dist4();
|
|
18404
18281
|
function cloneCommand(program2) {
|
|
18405
18282
|
program2.command("clone [source-name] [new-name]").description("\u514B\u9686 Codex \u670D\u52A1\u5546").action(async (sourceName, newName) => {
|
|
@@ -18407,7 +18284,7 @@ function cloneCommand(program2) {
|
|
|
18407
18284
|
const manager = createCodexManager();
|
|
18408
18285
|
const providers = manager.list();
|
|
18409
18286
|
if (providers.length === 0) {
|
|
18410
|
-
console.log(
|
|
18287
|
+
console.log(import_chalk18.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
18411
18288
|
return;
|
|
18412
18289
|
}
|
|
18413
18290
|
let sourceId;
|
|
@@ -18418,7 +18295,7 @@ function cloneCommand(program2) {
|
|
|
18418
18295
|
}
|
|
18419
18296
|
sourceId = provider.id;
|
|
18420
18297
|
} else {
|
|
18421
|
-
const { selectedId } = await
|
|
18298
|
+
const { selectedId } = await import_inquirer12.default.prompt([
|
|
18422
18299
|
{
|
|
18423
18300
|
type: "list",
|
|
18424
18301
|
name: "selectedId",
|
|
@@ -18436,7 +18313,7 @@ function cloneCommand(program2) {
|
|
|
18436
18313
|
if (newName) {
|
|
18437
18314
|
cloned = manager.clone(sourceId, newName);
|
|
18438
18315
|
} else {
|
|
18439
|
-
console.log(
|
|
18316
|
+
console.log(import_chalk18.default.blue(`
|
|
18440
18317
|
\u514B\u9686\u81EA: ${source.name}
|
|
18441
18318
|
`));
|
|
18442
18319
|
const input = await promptProviderForm({
|
|
@@ -18447,14 +18324,14 @@ function cloneCommand(program2) {
|
|
|
18447
18324
|
cloned = manager.add(input);
|
|
18448
18325
|
}
|
|
18449
18326
|
console.log();
|
|
18450
|
-
console.log(
|
|
18327
|
+
console.log(import_chalk18.default.green("\u2705 \u514B\u9686\u6210\u529F"));
|
|
18451
18328
|
console.log();
|
|
18452
|
-
console.log(` ${
|
|
18453
|
-
console.log(` ${
|
|
18454
|
-
console.log(` ${
|
|
18329
|
+
console.log(` ${import_chalk18.default.bold(cloned.name)} ${import_chalk18.default.blue("[Codex]")}`);
|
|
18330
|
+
console.log(` ${import_chalk18.default.gray(`ID: ${cloned.id}`)}`);
|
|
18331
|
+
console.log(` ${import_chalk18.default.gray(`URL: ${cloned.baseUrl}`)}`);
|
|
18455
18332
|
console.log();
|
|
18456
18333
|
} catch (error) {
|
|
18457
|
-
console.error(
|
|
18334
|
+
console.error(import_chalk18.default.red(`
|
|
18458
18335
|
\u274C ${error.message}
|
|
18459
18336
|
`));
|
|
18460
18337
|
process.exit(1);
|
|
@@ -18474,15 +18351,15 @@ function createCodexCommands(program2) {
|
|
|
18474
18351
|
}
|
|
18475
18352
|
|
|
18476
18353
|
// src/commands/claude/add.ts
|
|
18477
|
-
var
|
|
18478
|
-
var
|
|
18354
|
+
var import_chalk19 = __toESM(require("chalk"));
|
|
18355
|
+
var import_inquirer13 = __toESM(require("inquirer"));
|
|
18479
18356
|
init_dist4();
|
|
18480
18357
|
function addCommand2(program2) {
|
|
18481
18358
|
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Claude Code \u670D\u52A1\u5546(\u4EA4\u4E92\u5F0F)").action(async () => {
|
|
18482
18359
|
try {
|
|
18483
18360
|
const manager = createClaudeManager();
|
|
18484
|
-
console.log(
|
|
18485
|
-
const { usePreset } = await
|
|
18361
|
+
console.log(import_chalk19.default.bold("\n\u{1F4DD} \u6DFB\u52A0 Claude Code \u670D\u52A1\u5546\n"));
|
|
18362
|
+
const { usePreset } = await import_inquirer13.default.prompt([
|
|
18486
18363
|
{
|
|
18487
18364
|
type: "list",
|
|
18488
18365
|
name: "usePreset",
|
|
@@ -18497,7 +18374,7 @@ function addCommand2(program2) {
|
|
|
18497
18374
|
let baseUrl;
|
|
18498
18375
|
let apiKey;
|
|
18499
18376
|
if (usePreset) {
|
|
18500
|
-
const { presetName } = await
|
|
18377
|
+
const { presetName } = await import_inquirer13.default.prompt([
|
|
18501
18378
|
{
|
|
18502
18379
|
type: "list",
|
|
18503
18380
|
name: "presetName",
|
|
@@ -18509,7 +18386,7 @@ function addCommand2(program2) {
|
|
|
18509
18386
|
}
|
|
18510
18387
|
]);
|
|
18511
18388
|
const preset = CC_PRESETS.find((p) => p.name === presetName);
|
|
18512
|
-
console.log(
|
|
18389
|
+
console.log(import_chalk19.default.blue(`
|
|
18513
18390
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
18514
18391
|
`));
|
|
18515
18392
|
const input = await promptProviderForm({
|
|
@@ -18521,7 +18398,7 @@ function addCommand2(program2) {
|
|
|
18521
18398
|
baseUrl = input.baseUrl;
|
|
18522
18399
|
apiKey = input.apiKey;
|
|
18523
18400
|
} else {
|
|
18524
|
-
const answers = await
|
|
18401
|
+
const answers = await import_inquirer13.default.prompt([
|
|
18525
18402
|
{
|
|
18526
18403
|
type: "input",
|
|
18527
18404
|
name: "name",
|
|
@@ -18560,12 +18437,12 @@ function addCommand2(program2) {
|
|
|
18560
18437
|
}
|
|
18561
18438
|
const provider = manager.add({ name, baseUrl, apiKey });
|
|
18562
18439
|
console.log();
|
|
18563
|
-
console.log(
|
|
18440
|
+
console.log(import_chalk19.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
|
|
18564
18441
|
console.log();
|
|
18565
|
-
console.log(` ${
|
|
18566
|
-
console.log(` ${
|
|
18442
|
+
console.log(` ${import_chalk19.default.bold(provider.name)} ${import_chalk19.default.blue("[Claude Code]")}`);
|
|
18443
|
+
console.log(` ${import_chalk19.default.gray(provider.baseUrl)}`);
|
|
18567
18444
|
console.log();
|
|
18568
|
-
const { switchNow } = await
|
|
18445
|
+
const { switchNow } = await import_inquirer13.default.prompt([
|
|
18569
18446
|
{
|
|
18570
18447
|
type: "confirm",
|
|
18571
18448
|
name: "switchNow",
|
|
@@ -18575,15 +18452,15 @@ function addCommand2(program2) {
|
|
|
18575
18452
|
]);
|
|
18576
18453
|
if (switchNow) {
|
|
18577
18454
|
manager.switch(provider.id);
|
|
18578
|
-
console.log(
|
|
18455
|
+
console.log(import_chalk19.default.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546"));
|
|
18579
18456
|
console.log();
|
|
18580
|
-
console.log(
|
|
18581
|
-
console.log(
|
|
18457
|
+
console.log(import_chalk19.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
18458
|
+
console.log(import_chalk19.default.gray(` - ${getClaudeConfigPath()}`));
|
|
18582
18459
|
} else {
|
|
18583
|
-
console.log(
|
|
18460
|
+
console.log(import_chalk19.default.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + import_chalk19.default.white(` ccman cc use "${provider.name}"`));
|
|
18584
18461
|
}
|
|
18585
18462
|
} catch (error) {
|
|
18586
|
-
console.error(
|
|
18463
|
+
console.error(import_chalk19.default.red(`
|
|
18587
18464
|
\u274C ${error.message}
|
|
18588
18465
|
`));
|
|
18589
18466
|
process.exit(1);
|
|
@@ -18592,7 +18469,7 @@ function addCommand2(program2) {
|
|
|
18592
18469
|
}
|
|
18593
18470
|
|
|
18594
18471
|
// src/commands/claude/list.ts
|
|
18595
|
-
var
|
|
18472
|
+
var import_chalk20 = __toESM(require("chalk"));
|
|
18596
18473
|
init_dist4();
|
|
18597
18474
|
function listCommand2(program2) {
|
|
18598
18475
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 Claude Code \u670D\u52A1\u5546").action(async () => {
|
|
@@ -18601,15 +18478,15 @@ function listCommand2(program2) {
|
|
|
18601
18478
|
const providers = manager.list();
|
|
18602
18479
|
const current = manager.getCurrent();
|
|
18603
18480
|
if (providers.length === 0) {
|
|
18604
|
-
console.log(
|
|
18605
|
-
console.log(
|
|
18481
|
+
console.log(import_chalk20.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
18482
|
+
console.log(import_chalk20.default.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + import_chalk20.default.white(" ccman cc add\n"));
|
|
18606
18483
|
return;
|
|
18607
18484
|
}
|
|
18608
|
-
console.log(
|
|
18485
|
+
console.log(import_chalk20.default.bold(`
|
|
18609
18486
|
\u{1F4CB} Claude Code \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
|
|
18610
18487
|
console.log(formatProviderTable(providers, current?.id, "Claude Code"));
|
|
18611
18488
|
} catch (error) {
|
|
18612
|
-
console.error(
|
|
18489
|
+
console.error(import_chalk20.default.red(`
|
|
18613
18490
|
\u274C ${error.message}
|
|
18614
18491
|
`));
|
|
18615
18492
|
process.exit(1);
|
|
@@ -18618,8 +18495,8 @@ function listCommand2(program2) {
|
|
|
18618
18495
|
}
|
|
18619
18496
|
|
|
18620
18497
|
// src/commands/claude/use.ts
|
|
18621
|
-
var
|
|
18622
|
-
var
|
|
18498
|
+
var import_chalk21 = __toESM(require("chalk"));
|
|
18499
|
+
var import_inquirer14 = __toESM(require("inquirer"));
|
|
18623
18500
|
init_dist4();
|
|
18624
18501
|
function useCommand2(program2) {
|
|
18625
18502
|
program2.command("use [name]").description("\u5207\u6362 Claude Code \u670D\u52A1\u5546").action(async (name) => {
|
|
@@ -18627,8 +18504,8 @@ function useCommand2(program2) {
|
|
|
18627
18504
|
const manager = createClaudeManager();
|
|
18628
18505
|
const providers = manager.list();
|
|
18629
18506
|
if (providers.length === 0) {
|
|
18630
|
-
console.log(
|
|
18631
|
-
console.log(
|
|
18507
|
+
console.log(import_chalk21.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
18508
|
+
console.log(import_chalk21.default.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + import_chalk21.default.white(" ccman cc add\n"));
|
|
18632
18509
|
return;
|
|
18633
18510
|
}
|
|
18634
18511
|
let targetId;
|
|
@@ -18639,7 +18516,7 @@ function useCommand2(program2) {
|
|
|
18639
18516
|
}
|
|
18640
18517
|
targetId = provider2.id;
|
|
18641
18518
|
} else {
|
|
18642
|
-
const { selectedId } = await
|
|
18519
|
+
const { selectedId } = await import_inquirer14.default.prompt([
|
|
18643
18520
|
{
|
|
18644
18521
|
type: "list",
|
|
18645
18522
|
name: "selectedId",
|
|
@@ -18655,22 +18532,22 @@ function useCommand2(program2) {
|
|
|
18655
18532
|
manager.switch(targetId);
|
|
18656
18533
|
const provider = manager.get(targetId);
|
|
18657
18534
|
console.log();
|
|
18658
|
-
console.log(
|
|
18535
|
+
console.log(import_chalk21.default.green("\u2705 \u5207\u6362\u6210\u529F"));
|
|
18659
18536
|
console.log();
|
|
18660
|
-
console.log(` ${
|
|
18661
|
-
console.log(` ${
|
|
18537
|
+
console.log(` ${import_chalk21.default.bold(provider.name)} ${import_chalk21.default.blue("[Claude Code]")}`);
|
|
18538
|
+
console.log(` ${import_chalk21.default.gray(`URL: ${provider.baseUrl}`)}`);
|
|
18662
18539
|
console.log();
|
|
18663
|
-
console.log(
|
|
18664
|
-
console.log(
|
|
18540
|
+
console.log(import_chalk21.default.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
18541
|
+
console.log(import_chalk21.default.gray(` - ${getClaudeConfigPath()}`));
|
|
18665
18542
|
console.log();
|
|
18666
18543
|
} catch (error) {
|
|
18667
18544
|
if (error instanceof ProviderNotFoundError) {
|
|
18668
|
-
console.error(
|
|
18545
|
+
console.error(import_chalk21.default.red(`
|
|
18669
18546
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${error.message}
|
|
18670
18547
|
`));
|
|
18671
|
-
console.log(
|
|
18548
|
+
console.log(import_chalk21.default.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + import_chalk21.default.white(" ccman cc list\n"));
|
|
18672
18549
|
} else {
|
|
18673
|
-
console.error(
|
|
18550
|
+
console.error(import_chalk21.default.red(`
|
|
18674
18551
|
\u274C ${error.message}
|
|
18675
18552
|
`));
|
|
18676
18553
|
}
|
|
@@ -18680,7 +18557,7 @@ function useCommand2(program2) {
|
|
|
18680
18557
|
}
|
|
18681
18558
|
|
|
18682
18559
|
// src/commands/claude/current.ts
|
|
18683
|
-
var
|
|
18560
|
+
var import_chalk22 = __toESM(require("chalk"));
|
|
18684
18561
|
init_dist4();
|
|
18685
18562
|
function currentCommand2(program2) {
|
|
18686
18563
|
program2.command("current").description("\u663E\u793A\u5F53\u524D\u4F7F\u7528\u7684 Claude Code \u670D\u52A1\u5546").action(async () => {
|
|
@@ -18688,21 +18565,21 @@ function currentCommand2(program2) {
|
|
|
18688
18565
|
const manager = createClaudeManager();
|
|
18689
18566
|
const current = manager.getCurrent();
|
|
18690
18567
|
if (!current) {
|
|
18691
|
-
console.log(
|
|
18692
|
-
console.log(
|
|
18568
|
+
console.log(import_chalk22.default.yellow("\n\u26A0\uFE0F \u672A\u9009\u62E9\u4EFB\u4F55 Claude Code \u670D\u52A1\u5546\n"));
|
|
18569
|
+
console.log(import_chalk22.default.blue("\u{1F4A1} \u9009\u62E9\u670D\u52A1\u5546:") + import_chalk22.default.white(" ccman cc use\n"));
|
|
18693
18570
|
return;
|
|
18694
18571
|
}
|
|
18695
|
-
console.log(
|
|
18696
|
-
console.log(` ${
|
|
18697
|
-
console.log(` ${
|
|
18698
|
-
console.log(` ${
|
|
18572
|
+
console.log(import_chalk22.default.bold("\n\u{1F4CD} \u5F53\u524D Claude Code \u670D\u52A1\u5546\n"));
|
|
18573
|
+
console.log(` ${import_chalk22.default.green.bold(current.name)}`);
|
|
18574
|
+
console.log(` ${import_chalk22.default.gray(`ID: ${current.id}`)}`);
|
|
18575
|
+
console.log(` ${import_chalk22.default.gray(`URL: ${current.baseUrl}`)}`);
|
|
18699
18576
|
if (current.lastUsedAt) {
|
|
18700
18577
|
const date = new Date(current.lastUsedAt).toLocaleString("zh-CN");
|
|
18701
|
-
console.log(` ${
|
|
18578
|
+
console.log(` ${import_chalk22.default.gray(`\u6700\u540E\u4F7F\u7528: ${date}`)}`);
|
|
18702
18579
|
}
|
|
18703
18580
|
console.log();
|
|
18704
18581
|
} catch (error) {
|
|
18705
|
-
console.error(
|
|
18582
|
+
console.error(import_chalk22.default.red(`
|
|
18706
18583
|
\u274C ${error.message}
|
|
18707
18584
|
`));
|
|
18708
18585
|
process.exit(1);
|
|
@@ -18711,8 +18588,8 @@ function currentCommand2(program2) {
|
|
|
18711
18588
|
}
|
|
18712
18589
|
|
|
18713
18590
|
// src/commands/claude/remove.ts
|
|
18714
|
-
var
|
|
18715
|
-
var
|
|
18591
|
+
var import_chalk23 = __toESM(require("chalk"));
|
|
18592
|
+
var import_inquirer15 = __toESM(require("inquirer"));
|
|
18716
18593
|
init_dist4();
|
|
18717
18594
|
function removeCommand2(program2) {
|
|
18718
18595
|
program2.command("remove [name]").alias("rm").description("\u5220\u9664 Claude Code \u670D\u52A1\u5546").action(async (name) => {
|
|
@@ -18720,7 +18597,7 @@ function removeCommand2(program2) {
|
|
|
18720
18597
|
const manager = createClaudeManager();
|
|
18721
18598
|
const providers = manager.list();
|
|
18722
18599
|
if (providers.length === 0) {
|
|
18723
|
-
console.log(
|
|
18600
|
+
console.log(import_chalk23.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
18724
18601
|
return;
|
|
18725
18602
|
}
|
|
18726
18603
|
let targetId;
|
|
@@ -18733,7 +18610,7 @@ function removeCommand2(program2) {
|
|
|
18733
18610
|
targetId = provider.id;
|
|
18734
18611
|
targetName = provider.name;
|
|
18735
18612
|
} else {
|
|
18736
|
-
const { selectedId } = await
|
|
18613
|
+
const { selectedId } = await import_inquirer15.default.prompt([
|
|
18737
18614
|
{
|
|
18738
18615
|
type: "list",
|
|
18739
18616
|
name: "selectedId",
|
|
@@ -18748,7 +18625,7 @@ function removeCommand2(program2) {
|
|
|
18748
18625
|
targetId = selectedId;
|
|
18749
18626
|
targetName = provider.name;
|
|
18750
18627
|
}
|
|
18751
|
-
const { confirmed } = await
|
|
18628
|
+
const { confirmed } = await import_inquirer15.default.prompt([
|
|
18752
18629
|
{
|
|
18753
18630
|
type: "confirm",
|
|
18754
18631
|
name: "confirmed",
|
|
@@ -18757,21 +18634,21 @@ function removeCommand2(program2) {
|
|
|
18757
18634
|
}
|
|
18758
18635
|
]);
|
|
18759
18636
|
if (!confirmed) {
|
|
18760
|
-
console.log(
|
|
18637
|
+
console.log(import_chalk23.default.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
18761
18638
|
return;
|
|
18762
18639
|
}
|
|
18763
18640
|
manager.remove(targetId);
|
|
18764
18641
|
console.log();
|
|
18765
|
-
console.log(
|
|
18642
|
+
console.log(import_chalk23.default.green(`\u2705 \u5DF2\u5220\u9664: ${targetName}`));
|
|
18766
18643
|
console.log();
|
|
18767
18644
|
} catch (error) {
|
|
18768
18645
|
if (error instanceof ProviderNotFoundError) {
|
|
18769
|
-
console.error(
|
|
18646
|
+
console.error(import_chalk23.default.red(`
|
|
18770
18647
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728
|
|
18771
18648
|
`));
|
|
18772
|
-
console.log(
|
|
18649
|
+
console.log(import_chalk23.default.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + import_chalk23.default.white(" ccman cc list\n"));
|
|
18773
18650
|
} else {
|
|
18774
|
-
console.error(
|
|
18651
|
+
console.error(import_chalk23.default.red(`
|
|
18775
18652
|
\u274C ${error.message}
|
|
18776
18653
|
`));
|
|
18777
18654
|
}
|
|
@@ -18781,8 +18658,8 @@ function removeCommand2(program2) {
|
|
|
18781
18658
|
}
|
|
18782
18659
|
|
|
18783
18660
|
// src/commands/claude/edit.ts
|
|
18784
|
-
var
|
|
18785
|
-
var
|
|
18661
|
+
var import_chalk24 = __toESM(require("chalk"));
|
|
18662
|
+
var import_inquirer16 = __toESM(require("inquirer"));
|
|
18786
18663
|
init_dist4();
|
|
18787
18664
|
function editCommand2(program2) {
|
|
18788
18665
|
program2.command("edit [name]").description("\u7F16\u8F91 Claude Code \u670D\u52A1\u5546").action(async (name) => {
|
|
@@ -18790,7 +18667,7 @@ function editCommand2(program2) {
|
|
|
18790
18667
|
const manager = createClaudeManager();
|
|
18791
18668
|
const providers = manager.list();
|
|
18792
18669
|
if (providers.length === 0) {
|
|
18793
|
-
console.log(
|
|
18670
|
+
console.log(import_chalk24.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
18794
18671
|
return;
|
|
18795
18672
|
}
|
|
18796
18673
|
let targetId;
|
|
@@ -18801,7 +18678,7 @@ function editCommand2(program2) {
|
|
|
18801
18678
|
}
|
|
18802
18679
|
targetId = provider2.id;
|
|
18803
18680
|
} else {
|
|
18804
|
-
const { selectedId } = await
|
|
18681
|
+
const { selectedId } = await import_inquirer16.default.prompt([
|
|
18805
18682
|
{
|
|
18806
18683
|
type: "list",
|
|
18807
18684
|
name: "selectedId",
|
|
@@ -18815,9 +18692,9 @@ function editCommand2(program2) {
|
|
|
18815
18692
|
targetId = selectedId;
|
|
18816
18693
|
}
|
|
18817
18694
|
const provider = manager.get(targetId);
|
|
18818
|
-
console.log(
|
|
18819
|
-
console.log(
|
|
18820
|
-
const answers = await
|
|
18695
|
+
console.log(import_chalk24.default.bold("\n\u270F\uFE0F \u7F16\u8F91\u670D\u52A1\u5546\n"));
|
|
18696
|
+
console.log(import_chalk24.default.gray("\u63D0\u793A: \u7559\u7A7A\u5219\u4FDD\u6301\u539F\u503C\n"));
|
|
18697
|
+
const answers = await import_inquirer16.default.prompt([
|
|
18821
18698
|
{
|
|
18822
18699
|
type: "input",
|
|
18823
18700
|
name: "name",
|
|
@@ -18848,19 +18725,19 @@ function editCommand2(program2) {
|
|
|
18848
18725
|
if (answers.baseUrl && answers.baseUrl !== provider.baseUrl) updates.baseUrl = answers.baseUrl;
|
|
18849
18726
|
if (answers.apiKey) updates.apiKey = answers.apiKey;
|
|
18850
18727
|
if (Object.keys(updates).length === 0) {
|
|
18851
|
-
console.log(
|
|
18728
|
+
console.log(import_chalk24.default.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
18852
18729
|
return;
|
|
18853
18730
|
}
|
|
18854
18731
|
const updated = manager.edit(targetId, updates);
|
|
18855
18732
|
console.log();
|
|
18856
|
-
console.log(
|
|
18733
|
+
console.log(import_chalk24.default.green("\u2705 \u7F16\u8F91\u6210\u529F"));
|
|
18857
18734
|
console.log();
|
|
18858
|
-
console.log(` ${
|
|
18859
|
-
console.log(` ${
|
|
18860
|
-
console.log(` ${
|
|
18735
|
+
console.log(` ${import_chalk24.default.bold(updated.name)} ${import_chalk24.default.blue("[Claude Code]")}`);
|
|
18736
|
+
console.log(` ${import_chalk24.default.gray(`ID: ${updated.id}`)}`);
|
|
18737
|
+
console.log(` ${import_chalk24.default.gray(`URL: ${updated.baseUrl}`)}`);
|
|
18861
18738
|
console.log();
|
|
18862
18739
|
} catch (error) {
|
|
18863
|
-
console.error(
|
|
18740
|
+
console.error(import_chalk24.default.red(`
|
|
18864
18741
|
\u274C ${error.message}
|
|
18865
18742
|
`));
|
|
18866
18743
|
process.exit(1);
|
|
@@ -18869,8 +18746,8 @@ function editCommand2(program2) {
|
|
|
18869
18746
|
}
|
|
18870
18747
|
|
|
18871
18748
|
// src/commands/claude/clone.ts
|
|
18872
|
-
var
|
|
18873
|
-
var
|
|
18749
|
+
var import_chalk25 = __toESM(require("chalk"));
|
|
18750
|
+
var import_inquirer17 = __toESM(require("inquirer"));
|
|
18874
18751
|
init_dist4();
|
|
18875
18752
|
function cloneCommand2(program2) {
|
|
18876
18753
|
program2.command("clone [source-name] [new-name]").description("\u514B\u9686 Claude Code \u670D\u52A1\u5546").action(async (sourceName, newName) => {
|
|
@@ -18878,7 +18755,7 @@ function cloneCommand2(program2) {
|
|
|
18878
18755
|
const manager = createClaudeManager();
|
|
18879
18756
|
const providers = manager.list();
|
|
18880
18757
|
if (providers.length === 0) {
|
|
18881
|
-
console.log(
|
|
18758
|
+
console.log(import_chalk25.default.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
18882
18759
|
return;
|
|
18883
18760
|
}
|
|
18884
18761
|
let sourceId;
|
|
@@ -18889,7 +18766,7 @@ function cloneCommand2(program2) {
|
|
|
18889
18766
|
}
|
|
18890
18767
|
sourceId = provider.id;
|
|
18891
18768
|
} else {
|
|
18892
|
-
const { selectedId } = await
|
|
18769
|
+
const { selectedId } = await import_inquirer17.default.prompt([
|
|
18893
18770
|
{
|
|
18894
18771
|
type: "list",
|
|
18895
18772
|
name: "selectedId",
|
|
@@ -18907,7 +18784,7 @@ function cloneCommand2(program2) {
|
|
|
18907
18784
|
if (newName) {
|
|
18908
18785
|
cloned = manager.clone(sourceId, newName);
|
|
18909
18786
|
} else {
|
|
18910
|
-
console.log(
|
|
18787
|
+
console.log(import_chalk25.default.blue(`
|
|
18911
18788
|
\u514B\u9686\u81EA: ${source.name}
|
|
18912
18789
|
`));
|
|
18913
18790
|
const input = await promptProviderForm({
|
|
@@ -18918,14 +18795,14 @@ function cloneCommand2(program2) {
|
|
|
18918
18795
|
cloned = manager.add(input);
|
|
18919
18796
|
}
|
|
18920
18797
|
console.log();
|
|
18921
|
-
console.log(
|
|
18798
|
+
console.log(import_chalk25.default.green("\u2705 \u514B\u9686\u6210\u529F"));
|
|
18922
18799
|
console.log();
|
|
18923
|
-
console.log(` ${
|
|
18924
|
-
console.log(` ${
|
|
18925
|
-
console.log(` ${
|
|
18800
|
+
console.log(` ${import_chalk25.default.bold(cloned.name)} ${import_chalk25.default.blue("[Claude Code]")}`);
|
|
18801
|
+
console.log(` ${import_chalk25.default.gray(`ID: ${cloned.id}`)}`);
|
|
18802
|
+
console.log(` ${import_chalk25.default.gray(`URL: ${cloned.baseUrl}`)}`);
|
|
18926
18803
|
console.log();
|
|
18927
18804
|
} catch (error) {
|
|
18928
|
-
console.error(
|
|
18805
|
+
console.error(import_chalk25.default.red(`
|
|
18929
18806
|
\u274C ${error.message}
|
|
18930
18807
|
`));
|
|
18931
18808
|
process.exit(1);
|
|
@@ -18945,43 +18822,43 @@ function createClaudeCommands(program2) {
|
|
|
18945
18822
|
}
|
|
18946
18823
|
|
|
18947
18824
|
// src/index.ts
|
|
18948
|
-
|
|
18825
|
+
init_sync();
|
|
18949
18826
|
|
|
18950
18827
|
// src/commands/export.ts
|
|
18951
|
-
var
|
|
18828
|
+
var import_chalk26 = __toESM(require("chalk"));
|
|
18952
18829
|
var import_path19 = __toESM(require("path"));
|
|
18953
18830
|
init_dist4();
|
|
18954
18831
|
function exportCommand(program2) {
|
|
18955
18832
|
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) => {
|
|
18956
18833
|
try {
|
|
18957
|
-
console.log(
|
|
18834
|
+
console.log(import_chalk26.default.bold("\n\u{1F4E6} \u5BFC\u51FA\u914D\u7F6E\n"));
|
|
18958
18835
|
const validation = validateExport();
|
|
18959
18836
|
if (!validation.valid) {
|
|
18960
|
-
console.log(
|
|
18837
|
+
console.log(import_chalk26.default.red(`\u274C ${validation.message}
|
|
18961
18838
|
`));
|
|
18962
18839
|
process.exit(1);
|
|
18963
18840
|
}
|
|
18964
18841
|
const resolvedPath = targetDir.startsWith("~") ? import_path19.default.join(process.env.HOME || "", targetDir.slice(1)) : import_path19.default.resolve(targetDir);
|
|
18965
18842
|
console.log("\u5BFC\u51FA\u6587\u4EF6:");
|
|
18966
|
-
console.log(` ${
|
|
18967
|
-
console.log(` ${
|
|
18843
|
+
console.log(` ${import_chalk26.default.cyan("codex.json")} - Codex \u914D\u7F6E`);
|
|
18844
|
+
console.log(` ${import_chalk26.default.cyan("claude.json")} - Claude \u914D\u7F6E`);
|
|
18968
18845
|
console.log();
|
|
18969
|
-
console.log(`\u76EE\u6807\u76EE\u5F55: ${
|
|
18846
|
+
console.log(`\u76EE\u6807\u76EE\u5F55: ${import_chalk26.default.cyan(resolvedPath)}`);
|
|
18970
18847
|
console.log();
|
|
18971
|
-
console.log(
|
|
18848
|
+
console.log(import_chalk26.default.yellow("\u26A0\uFE0F \u5BFC\u51FA\u6587\u4EF6\u5305\u542B API Key\uFF0C\u8BF7\u59A5\u5584\u4FDD\u7BA1"));
|
|
18972
18849
|
console.log();
|
|
18973
18850
|
const result = exportConfig(resolvedPath);
|
|
18974
|
-
console.log(
|
|
18851
|
+
console.log(import_chalk26.default.green("\u2705 \u5BFC\u51FA\u6210\u529F"));
|
|
18975
18852
|
console.log();
|
|
18976
18853
|
console.log("\u5DF2\u5BFC\u51FA\u6587\u4EF6:");
|
|
18977
18854
|
for (const file of result.exportedFiles) {
|
|
18978
|
-
console.log(` ${
|
|
18855
|
+
console.log(` ${import_chalk26.default.cyan("\u2713")} ${file}`);
|
|
18979
18856
|
}
|
|
18980
18857
|
console.log();
|
|
18981
|
-
console.log(
|
|
18858
|
+
console.log(import_chalk26.default.blue(`\u{1F4A1} \u5BFC\u5165\u547D\u4EE4: ccman import ${resolvedPath}
|
|
18982
18859
|
`));
|
|
18983
18860
|
} catch (error) {
|
|
18984
|
-
console.error(
|
|
18861
|
+
console.error(import_chalk26.default.red(`
|
|
18985
18862
|
\u274C ${error.message}
|
|
18986
18863
|
`));
|
|
18987
18864
|
process.exit(1);
|
|
@@ -18990,32 +18867,32 @@ function exportCommand(program2) {
|
|
|
18990
18867
|
}
|
|
18991
18868
|
|
|
18992
18869
|
// src/commands/import.ts
|
|
18993
|
-
var
|
|
18994
|
-
var
|
|
18870
|
+
var import_chalk27 = __toESM(require("chalk"));
|
|
18871
|
+
var import_inquirer18 = __toESM(require("inquirer"));
|
|
18995
18872
|
var import_path20 = __toESM(require("path"));
|
|
18996
18873
|
init_dist4();
|
|
18997
18874
|
function importCommand(program2) {
|
|
18998
18875
|
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) => {
|
|
18999
18876
|
try {
|
|
19000
18877
|
const resolvedPath = sourceDir.startsWith("~") ? import_path20.default.join(process.env.HOME || "", sourceDir.slice(1)) : import_path20.default.resolve(sourceDir);
|
|
19001
|
-
console.log(
|
|
18878
|
+
console.log(import_chalk27.default.bold("\n\u{1F4E5} \u5BFC\u5165\u914D\u7F6E\n"));
|
|
19002
18879
|
const validation = validateImportDir(resolvedPath);
|
|
19003
18880
|
if (!validation.valid) {
|
|
19004
|
-
console.log(
|
|
18881
|
+
console.log(import_chalk27.default.red(`\u274C ${validation.message}
|
|
19005
18882
|
`));
|
|
19006
18883
|
process.exit(1);
|
|
19007
18884
|
}
|
|
19008
|
-
console.log(
|
|
19009
|
-
console.log(`\u6E90\u76EE\u5F55: ${
|
|
18885
|
+
console.log(import_chalk27.default.yellow("\u26A0\uFE0F \u8B66\u544A\uFF1A\u5BFC\u5165\u5C06\u8986\u76D6\u5F53\u524D\u914D\u7F6E\n"));
|
|
18886
|
+
console.log(`\u6E90\u76EE\u5F55: ${import_chalk27.default.cyan(resolvedPath)}`);
|
|
19010
18887
|
console.log();
|
|
19011
18888
|
console.log("\u627E\u5230\u914D\u7F6E\u6587\u4EF6:");
|
|
19012
18889
|
for (const file of validation.foundFiles) {
|
|
19013
|
-
console.log(` ${
|
|
18890
|
+
console.log(` ${import_chalk27.default.cyan("\u2713")} ${file}`);
|
|
19014
18891
|
}
|
|
19015
18892
|
console.log();
|
|
19016
|
-
console.log(
|
|
18893
|
+
console.log(import_chalk27.default.gray("\u5F53\u524D\u914D\u7F6E\u5C06\u88AB\u8986\u76D6\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
|
|
19017
18894
|
console.log();
|
|
19018
|
-
const { confirmFirst } = await
|
|
18895
|
+
const { confirmFirst } = await import_inquirer18.default.prompt([
|
|
19019
18896
|
{
|
|
19020
18897
|
type: "confirm",
|
|
19021
18898
|
name: "confirmFirst",
|
|
@@ -19024,13 +18901,13 @@ function importCommand(program2) {
|
|
|
19024
18901
|
}
|
|
19025
18902
|
]);
|
|
19026
18903
|
if (!confirmFirst) {
|
|
19027
|
-
console.log(
|
|
18904
|
+
console.log(import_chalk27.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
19028
18905
|
return;
|
|
19029
18906
|
}
|
|
19030
18907
|
console.log();
|
|
19031
|
-
console.log(
|
|
18908
|
+
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"));
|
|
19032
18909
|
console.log();
|
|
19033
|
-
const { confirmSecond } = await
|
|
18910
|
+
const { confirmSecond } = await import_inquirer18.default.prompt([
|
|
19034
18911
|
{
|
|
19035
18912
|
type: "confirm",
|
|
19036
18913
|
name: "confirmSecond",
|
|
@@ -19039,31 +18916,31 @@ function importCommand(program2) {
|
|
|
19039
18916
|
}
|
|
19040
18917
|
]);
|
|
19041
18918
|
if (!confirmSecond) {
|
|
19042
|
-
console.log(
|
|
18919
|
+
console.log(import_chalk27.default.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
19043
18920
|
return;
|
|
19044
18921
|
}
|
|
19045
18922
|
console.log();
|
|
19046
|
-
console.log(
|
|
19047
|
-
console.log(
|
|
18923
|
+
console.log(import_chalk27.default.gray("\u{1F4BE} \u5907\u4EFD\u5F53\u524D\u914D\u7F6E..."));
|
|
18924
|
+
console.log(import_chalk27.default.gray("\u{1F4E5} \u5BFC\u5165\u65B0\u914D\u7F6E..."));
|
|
19048
18925
|
const result = importConfig(resolvedPath);
|
|
19049
18926
|
console.log();
|
|
19050
|
-
console.log(
|
|
18927
|
+
console.log(import_chalk27.default.green("\u2705 \u5BFC\u5165\u6210\u529F"));
|
|
19051
18928
|
console.log();
|
|
19052
18929
|
if (result.backupPaths.length > 0) {
|
|
19053
18930
|
console.log("\u5907\u4EFD\u6587\u4EF6:");
|
|
19054
18931
|
for (const backupPath of result.backupPaths) {
|
|
19055
|
-
console.log(` ${
|
|
18932
|
+
console.log(` ${import_chalk27.default.gray(backupPath)}`);
|
|
19056
18933
|
}
|
|
19057
18934
|
console.log();
|
|
19058
18935
|
}
|
|
19059
18936
|
console.log("\u5DF2\u5BFC\u5165\u6587\u4EF6:");
|
|
19060
18937
|
for (const file of result.importedFiles) {
|
|
19061
|
-
console.log(` ${
|
|
18938
|
+
console.log(` ${import_chalk27.default.cyan("\u2713")} ${file}`);
|
|
19062
18939
|
}
|
|
19063
18940
|
console.log();
|
|
19064
|
-
console.log(
|
|
18941
|
+
console.log(import_chalk27.default.blue("\u{1F4A1} \u8BF7\u4F7F\u7528 'ccman cx use' \u6216 'ccman cc use' \u5207\u6362\u670D\u52A1\u5546\n"));
|
|
19065
18942
|
} catch (error) {
|
|
19066
|
-
console.error(
|
|
18943
|
+
console.error(import_chalk27.default.red(`
|
|
19067
18944
|
\u274C ${error.message}
|
|
19068
18945
|
`));
|
|
19069
18946
|
process.exit(1);
|
|
@@ -19074,13 +18951,13 @@ function importCommand(program2) {
|
|
|
19074
18951
|
// src/index.ts
|
|
19075
18952
|
init_dist4();
|
|
19076
18953
|
if (process.env.NODE_ENV === "development") {
|
|
19077
|
-
console.log(
|
|
19078
|
-
console.log(
|
|
19079
|
-
console.log(
|
|
19080
|
-
console.log(
|
|
18954
|
+
console.log(import_chalk28.default.gray("\n[\u5F00\u53D1\u6A21\u5F0F] \u914D\u7F6E\u76EE\u5F55:"));
|
|
18955
|
+
console.log(import_chalk28.default.gray(` ccman: ${getCcmanDir()}`));
|
|
18956
|
+
console.log(import_chalk28.default.gray(` codex: ${getCodexDir()}`));
|
|
18957
|
+
console.log(import_chalk28.default.gray(` claude: ${getClaudeDir()}`));
|
|
19081
18958
|
console.log();
|
|
19082
18959
|
}
|
|
19083
|
-
var program = new
|
|
18960
|
+
var program = new import_commander3.Command();
|
|
19084
18961
|
program.name("ccman").description("Codex/Claude Code API \u670D\u52A1\u5546\u914D\u7F6E\u7BA1\u7406\u5DE5\u5177").version(VERSION).showHelpAfterError(false).exitOverride((err) => {
|
|
19085
18962
|
if (err.code === "commander.helpDisplayed" || err.code === "commander.version") {
|
|
19086
18963
|
process.exit(0);
|
|
@@ -19089,7 +18966,7 @@ program.name("ccman").description("Codex/Claude Code API \u670D\u52A1\u5546\u914
|
|
|
19089
18966
|
});
|
|
19090
18967
|
program.on("command:*", (operands) => {
|
|
19091
18968
|
const unknownCommand = operands[0];
|
|
19092
|
-
console.error(
|
|
18969
|
+
console.error(import_chalk28.default.red(`
|
|
19093
18970
|
\u274C \u672A\u77E5\u547D\u4EE4: ${unknownCommand}
|
|
19094
18971
|
`));
|
|
19095
18972
|
const availableCommands = ["cx", "cc", "sync", "export", "import"];
|
|
@@ -19097,13 +18974,13 @@ program.on("command:*", (operands) => {
|
|
|
19097
18974
|
(cmd) => cmd.includes(unknownCommand) || unknownCommand.includes(cmd)
|
|
19098
18975
|
);
|
|
19099
18976
|
if (suggestions.length > 0) {
|
|
19100
|
-
console.log(
|
|
18977
|
+
console.log(import_chalk28.default.yellow("\u{1F4A1} \u4F60\u662F\u4E0D\u662F\u60F3\u8F93\u5165:"));
|
|
19101
18978
|
suggestions.forEach((cmd) => {
|
|
19102
|
-
console.log(
|
|
18979
|
+
console.log(import_chalk28.default.cyan(` ccman ${cmd}`));
|
|
19103
18980
|
});
|
|
19104
18981
|
console.log();
|
|
19105
18982
|
}
|
|
19106
|
-
console.log(
|
|
18983
|
+
console.log(import_chalk28.default.gray("\u67E5\u770B\u6240\u6709\u53EF\u7528\u547D\u4EE4: ") + import_chalk28.default.cyan("ccman --help"));
|
|
19107
18984
|
console.log();
|
|
19108
18985
|
process.exit(1);
|
|
19109
18986
|
});
|