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