ccman 3.3.25 → 3.3.28
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/README.md +40 -6
- package/dist/index.js +1510 -913
- package/dist/templates/codex/config.toml +11 -5
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -304,12 +304,28 @@ function loadCodexTemplateConfig() {
|
|
|
304
304
|
return CODEX_DEFAULT_CONFIG;
|
|
305
305
|
}
|
|
306
306
|
function removeDeprecatedKeys(config) {
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
const deprecatedFeatureKeys = [
|
|
308
|
+
"web_search_request",
|
|
309
|
+
"web_search_cached",
|
|
310
|
+
"web_search",
|
|
311
|
+
"plan_tool",
|
|
312
|
+
"view_image_tool",
|
|
313
|
+
"streamable_shell",
|
|
314
|
+
"rmcp_client"
|
|
315
|
+
];
|
|
316
|
+
if (config.features && typeof config.features === "object" && !Array.isArray(config.features)) {
|
|
317
|
+
const features = config.features;
|
|
318
|
+
for (const key of deprecatedFeatureKeys) {
|
|
319
|
+
if (key in features)
|
|
320
|
+
delete features[key];
|
|
321
|
+
}
|
|
309
322
|
}
|
|
310
323
|
if ("web_search_request" in config) {
|
|
311
324
|
delete config.web_search_request;
|
|
312
325
|
}
|
|
326
|
+
if ("network_access" in config) {
|
|
327
|
+
delete config.network_access;
|
|
328
|
+
}
|
|
313
329
|
}
|
|
314
330
|
function loadExistingCodexConfig(configPath) {
|
|
315
331
|
if (!fileExists(configPath)) {
|
|
@@ -402,7 +418,12 @@ var init_codex = __esm({
|
|
|
402
418
|
__dirname = path3.dirname(__filename);
|
|
403
419
|
CODEX_DEFAULT_CONFIG = {
|
|
404
420
|
model: "gpt-5.4",
|
|
421
|
+
review_model: "gpt-5.4",
|
|
405
422
|
model_reasoning_effort: "xhigh",
|
|
423
|
+
plan_mode_reasoning_effort: "xhigh",
|
|
424
|
+
model_reasoning_summary: "auto",
|
|
425
|
+
model_verbosity: "high",
|
|
426
|
+
personality: "pragmatic",
|
|
406
427
|
disable_response_storage: true,
|
|
407
428
|
sandbox_mode: "danger-full-access",
|
|
408
429
|
windows_wsl_setup_acknowledged: true,
|
|
@@ -425,13 +446,14 @@ var init_codex = __esm({
|
|
|
425
446
|
network_access: true
|
|
426
447
|
},
|
|
427
448
|
features: {
|
|
428
|
-
plan_tool: true,
|
|
429
449
|
apply_patch_freeform: true,
|
|
430
|
-
view_image_tool: true,
|
|
431
450
|
unified_exec: false,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
451
|
+
elevated_windows_sandbox: true,
|
|
452
|
+
multi_agent: true,
|
|
453
|
+
shell_tool: true,
|
|
454
|
+
shell_snapshot: true,
|
|
455
|
+
fast_mode: true,
|
|
456
|
+
personality: true
|
|
435
457
|
},
|
|
436
458
|
profiles: {
|
|
437
459
|
"auto-max": {
|
|
@@ -448,7 +470,7 @@ var init_codex = __esm({
|
|
|
448
470
|
}
|
|
449
471
|
};
|
|
450
472
|
GMN_PROVIDER_HOSTS = [
|
|
451
|
-
"
|
|
473
|
+
"ai.gmncode.com",
|
|
452
474
|
"cdn-gmn.chuangzuoli.com",
|
|
453
475
|
"gmncodex.com",
|
|
454
476
|
"gmncode.cn",
|
|
@@ -704,7 +726,7 @@ function createDualGmnPresets(transformBaseUrl = (baseUrl) => baseUrl) {
|
|
|
704
726
|
{
|
|
705
727
|
name: "GMN",
|
|
706
728
|
baseUrl: transformBaseUrl(GMN_ROOT_URL),
|
|
707
|
-
description: "GMN \u4E3B\u57DF\u540D\u7EBF\u8DEF (
|
|
729
|
+
description: "GMN \u4E3B\u57DF\u540D\u7EBF\u8DEF (ai.gmncode.com)"
|
|
708
730
|
},
|
|
709
731
|
{
|
|
710
732
|
name: "GMN1",
|
|
@@ -717,7 +739,7 @@ var GMN_ROOT_URL, GMN1_ROOT_URL;
|
|
|
717
739
|
var init_gmn = __esm({
|
|
718
740
|
"../core/dist/presets/gmn.js"() {
|
|
719
741
|
"use strict";
|
|
720
|
-
GMN_ROOT_URL = "https://
|
|
742
|
+
GMN_ROOT_URL = "https://ai.gmncode.com";
|
|
721
743
|
GMN1_ROOT_URL = "https://gmncode.cn";
|
|
722
744
|
}
|
|
723
745
|
});
|
|
@@ -3007,23 +3029,303 @@ var init_sync_config = __esm({
|
|
|
3007
3029
|
}
|
|
3008
3030
|
});
|
|
3009
3031
|
|
|
3032
|
+
// src/commands/sync/helpers.ts
|
|
3033
|
+
import chalk5 from "chalk";
|
|
3034
|
+
import { Command, Option } from "commander";
|
|
3035
|
+
import inquirer2 from "inquirer";
|
|
3036
|
+
function normalizeText(value) {
|
|
3037
|
+
if (value === void 0) {
|
|
3038
|
+
return void 0;
|
|
3039
|
+
}
|
|
3040
|
+
const trimmed = value.trim();
|
|
3041
|
+
return trimmed ? trimmed : void 0;
|
|
3042
|
+
}
|
|
3043
|
+
function resolveTextOption(cliValue, envKey, env) {
|
|
3044
|
+
return normalizeText(cliValue) ?? normalizeText(env[envKey]);
|
|
3045
|
+
}
|
|
3046
|
+
function resolveAuthType(cliValue, env) {
|
|
3047
|
+
const value = resolveTextOption(cliValue, SYNC_ENV_KEYS.authType, env);
|
|
3048
|
+
if (!value) {
|
|
3049
|
+
return void 0;
|
|
3050
|
+
}
|
|
3051
|
+
if (value === "password" || value === "digest") {
|
|
3052
|
+
return value;
|
|
3053
|
+
}
|
|
3054
|
+
throw new Error(`\u65E0\u6548\u7684\u8BA4\u8BC1\u7C7B\u578B: ${value}\uFF0C\u4EC5\u652F\u6301 password \u6216 digest`);
|
|
3055
|
+
}
|
|
3056
|
+
function hasSyncEnvInput(env) {
|
|
3057
|
+
return Object.values(SYNC_ENV_KEYS).some((key) => normalizeText(env[key]));
|
|
3058
|
+
}
|
|
3059
|
+
function formatMissingFields(fields) {
|
|
3060
|
+
const labels = {
|
|
3061
|
+
webdavUrl: "--webdav-url",
|
|
3062
|
+
username: "--username",
|
|
3063
|
+
password: "--password",
|
|
3064
|
+
authType: "--auth-type",
|
|
3065
|
+
remoteDir: "--remote-dir",
|
|
3066
|
+
syncPassword: "--sync-password"
|
|
3067
|
+
};
|
|
3068
|
+
return fields.map((field) => labels[field] || field).join(", ");
|
|
3069
|
+
}
|
|
3070
|
+
function addSyncConnectionOptions(command, options = {}) {
|
|
3071
|
+
command.option("--webdav-url <url>", `WebDAV \u670D\u52A1\u5668\u5730\u5740\uFF08\u6216\u73AF\u5883\u53D8\u91CF ${SYNC_ENV_KEYS.webdavUrl}\uFF09`).option("--username <username>", `WebDAV \u7528\u6237\u540D\uFF08\u6216\u73AF\u5883\u53D8\u91CF ${SYNC_ENV_KEYS.username}\uFF09`).option("--password <password>", `WebDAV \u5BC6\u7801\uFF08\u6216\u73AF\u5883\u53D8\u91CF ${SYNC_ENV_KEYS.password}\uFF09`).addOption(
|
|
3072
|
+
new Option(
|
|
3073
|
+
"--auth-type <type>",
|
|
3074
|
+
`\u8BA4\u8BC1\u7C7B\u578B\uFF08password|digest\uFF0C\u6216\u73AF\u5883\u53D8\u91CF ${SYNC_ENV_KEYS.authType}\uFF09`
|
|
3075
|
+
).choices(["password", "digest"])
|
|
3076
|
+
).option("--remote-dir <dir>", `\u8FDC\u7A0B\u540C\u6B65\u76EE\u5F55\uFF08\u6216\u73AF\u5883\u53D8\u91CF ${SYNC_ENV_KEYS.remoteDir}\uFF09`);
|
|
3077
|
+
if (options.includeSyncPassword) {
|
|
3078
|
+
command.option(
|
|
3079
|
+
"--sync-password <password>",
|
|
3080
|
+
`\u540C\u6B65\u5BC6\u7801\uFF08\u6216\u73AF\u5883\u53D8\u91CF ${SYNC_ENV_KEYS.syncPassword}\uFF09`
|
|
3081
|
+
);
|
|
3082
|
+
}
|
|
3083
|
+
if (options.includeConfirm) {
|
|
3084
|
+
command.option("-y, --yes", "\u8DF3\u8FC7\u786E\u8BA4\u63D0\u793A");
|
|
3085
|
+
}
|
|
3086
|
+
if (options.includeRememberFlags) {
|
|
3087
|
+
command.option("--remember-sync-password", "\u4FDD\u5B58\u540C\u6B65\u5BC6\u7801\u5230\u672C\u5730\u914D\u7F6E").option("--forget-sync-password", "\u4E0D\u4FDD\u5B58\u540C\u6B65\u5BC6\u7801\u5230\u672C\u5730\u914D\u7F6E");
|
|
3088
|
+
}
|
|
3089
|
+
if (options.includeTestFlag) {
|
|
3090
|
+
command.option("--test", "\u4FDD\u5B58\u540E\u7ACB\u5373\u6D4B\u8BD5\u8FDE\u63A5");
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
function collectSyncCommandInput(options = {}, env = process.env) {
|
|
3094
|
+
if (options.rememberSyncPassword && options.forgetSyncPassword) {
|
|
3095
|
+
throw new Error("\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528 --remember-sync-password \u548C --forget-sync-password");
|
|
3096
|
+
}
|
|
3097
|
+
const overrides = {
|
|
3098
|
+
webdavUrl: resolveTextOption(options.webdavUrl, SYNC_ENV_KEYS.webdavUrl, env),
|
|
3099
|
+
username: resolveTextOption(options.username, SYNC_ENV_KEYS.username, env),
|
|
3100
|
+
password: resolveTextOption(options.password, SYNC_ENV_KEYS.password, env),
|
|
3101
|
+
authType: resolveAuthType(options.authType, env),
|
|
3102
|
+
remoteDir: resolveTextOption(options.remoteDir, SYNC_ENV_KEYS.remoteDir, env),
|
|
3103
|
+
syncPassword: resolveTextOption(options.syncPassword, SYNC_ENV_KEYS.syncPassword, env)
|
|
3104
|
+
};
|
|
3105
|
+
const rememberSyncPassword = options.rememberSyncPassword ? true : options.forgetSyncPassword ? false : void 0;
|
|
3106
|
+
const nonInteractive = options.yes === true || rememberSyncPassword !== void 0 || hasSyncEnvInput(env) || Object.values(overrides).some((value) => value !== void 0);
|
|
3107
|
+
return {
|
|
3108
|
+
overrides,
|
|
3109
|
+
rememberSyncPassword,
|
|
3110
|
+
yes: options.yes === true,
|
|
3111
|
+
shouldTest: options.test === true,
|
|
3112
|
+
nonInteractive
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
3115
|
+
function mergeSyncConfig(baseConfig, overrides) {
|
|
3116
|
+
return {
|
|
3117
|
+
...baseConfig || {},
|
|
3118
|
+
...Object.fromEntries(Object.entries(overrides).filter(([, value]) => value !== void 0))
|
|
3119
|
+
};
|
|
3120
|
+
}
|
|
3121
|
+
function getMissingConnectionFields(config) {
|
|
3122
|
+
return REQUIRED_CONNECTION_FIELDS.filter((field) => !normalizeText(config[field]));
|
|
3123
|
+
}
|
|
3124
|
+
function buildRuntimeSyncConfig(existingConfig, input) {
|
|
3125
|
+
return mergeSyncConfig(existingConfig, input.overrides);
|
|
3126
|
+
}
|
|
3127
|
+
function assertCompleteSyncConfig(config) {
|
|
3128
|
+
const missingFields = getMissingConnectionFields(config);
|
|
3129
|
+
if (missingFields.length > 0) {
|
|
3130
|
+
throw new Error(`\u7F3A\u5C11\u540C\u6B65\u914D\u7F6E\u53C2\u6570: ${formatMissingFields(missingFields)}`);
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
async function ensureConfigExists(options = {}) {
|
|
3134
|
+
const existingConfig = loadSyncConfig();
|
|
3135
|
+
const input = collectSyncCommandInput(options);
|
|
3136
|
+
const mergedConfig = buildRuntimeSyncConfig(existingConfig, input);
|
|
3137
|
+
if (getMissingConnectionFields(mergedConfig).length === 0) {
|
|
3138
|
+
assertCompleteSyncConfig(mergedConfig);
|
|
3139
|
+
return mergedConfig;
|
|
3140
|
+
}
|
|
3141
|
+
if (input.nonInteractive) {
|
|
3142
|
+
assertCompleteSyncConfig(mergedConfig);
|
|
3143
|
+
}
|
|
3144
|
+
console.log(chalk5.yellow("\n\u26A0\uFE0F \u672A\u627E\u5230 WebDAV \u914D\u7F6E\n"));
|
|
3145
|
+
const shouldConfig = await promptConfirm("\u662F\u5426\u73B0\u5728\u914D\u7F6E WebDAV?", true);
|
|
3146
|
+
if (!shouldConfig) {
|
|
3147
|
+
return null;
|
|
3148
|
+
}
|
|
3149
|
+
const { configCommand: configCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
3150
|
+
const cmd = new Command();
|
|
3151
|
+
configCommand2(cmd);
|
|
3152
|
+
await cmd.parseAsync(["node", "ccman", "config"]);
|
|
3153
|
+
return loadSyncConfig();
|
|
3154
|
+
}
|
|
3155
|
+
async function resolveSyncPassword(config, options = {}) {
|
|
3156
|
+
const input = collectSyncCommandInput(options);
|
|
3157
|
+
const syncPassword = normalizeText(input.overrides.syncPassword) || normalizeText(config.syncPassword);
|
|
3158
|
+
if (syncPassword) {
|
|
3159
|
+
return syncPassword;
|
|
3160
|
+
}
|
|
3161
|
+
if (input.nonInteractive) {
|
|
3162
|
+
throw new Error(`\u7F3A\u5C11\u540C\u6B65\u5BC6\u7801: ${formatMissingFields(["syncPassword"])}`);
|
|
3163
|
+
}
|
|
3164
|
+
const { password } = await inquirer2.prompt([
|
|
3165
|
+
{
|
|
3166
|
+
type: "password",
|
|
3167
|
+
name: "password",
|
|
3168
|
+
message: "\u8BF7\u8F93\u5165\u540C\u6B65\u5BC6\u7801:",
|
|
3169
|
+
mask: "*",
|
|
3170
|
+
validate: (value) => value ? true : "\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
3171
|
+
}
|
|
3172
|
+
]);
|
|
3173
|
+
return password;
|
|
3174
|
+
}
|
|
3175
|
+
async function confirmOrExit(message, defaultValue, options = {}) {
|
|
3176
|
+
const input = collectSyncCommandInput(options);
|
|
3177
|
+
if (input.yes) {
|
|
3178
|
+
return true;
|
|
3179
|
+
}
|
|
3180
|
+
if (input.nonInteractive) {
|
|
3181
|
+
throw new Error(`\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u901A\u8FC7 --yes \u786E\u8BA4\u64CD\u4F5C`);
|
|
3182
|
+
}
|
|
3183
|
+
return promptConfirm(message, defaultValue);
|
|
3184
|
+
}
|
|
3185
|
+
var SYNC_ENV_KEYS, REQUIRED_CONNECTION_FIELDS;
|
|
3186
|
+
var init_helpers = __esm({
|
|
3187
|
+
"src/commands/sync/helpers.ts"() {
|
|
3188
|
+
"use strict";
|
|
3189
|
+
init_sync_config();
|
|
3190
|
+
init_confirm();
|
|
3191
|
+
SYNC_ENV_KEYS = {
|
|
3192
|
+
webdavUrl: "CCMAN_WEBDAV_URL",
|
|
3193
|
+
username: "CCMAN_WEBDAV_USERNAME",
|
|
3194
|
+
password: "CCMAN_WEBDAV_PASSWORD",
|
|
3195
|
+
authType: "CCMAN_WEBDAV_AUTH_TYPE",
|
|
3196
|
+
remoteDir: "CCMAN_WEBDAV_REMOTE_DIR",
|
|
3197
|
+
syncPassword: "CCMAN_SYNC_PASSWORD"
|
|
3198
|
+
};
|
|
3199
|
+
REQUIRED_CONNECTION_FIELDS = ["webdavUrl", "username", "password"];
|
|
3200
|
+
}
|
|
3201
|
+
});
|
|
3202
|
+
|
|
3010
3203
|
// src/commands/sync/config.ts
|
|
3011
3204
|
var config_exports = {};
|
|
3012
3205
|
__export(config_exports, {
|
|
3013
3206
|
configCommand: () => configCommand
|
|
3014
3207
|
});
|
|
3015
|
-
import
|
|
3016
|
-
import
|
|
3208
|
+
import chalk6 from "chalk";
|
|
3209
|
+
import inquirer3 from "inquirer";
|
|
3210
|
+
function validateWebdavUrl(url) {
|
|
3211
|
+
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
|
3212
|
+
throw new Error("WebDAV \u5730\u5740\u5FC5\u987B\u4EE5 http:// \u6216 https:// \u5F00\u5934");
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
function hasConfigChanges(existingConfig, newConfig) {
|
|
3216
|
+
if (!existingConfig) {
|
|
3217
|
+
return true;
|
|
3218
|
+
}
|
|
3219
|
+
return existingConfig.webdavUrl !== newConfig.webdavUrl || existingConfig.username !== newConfig.username || existingConfig.password !== newConfig.password || existingConfig.authType !== newConfig.authType || existingConfig.remoteDir !== newConfig.remoteDir || existingConfig.syncPassword !== newConfig.syncPassword || existingConfig.rememberSyncPassword !== newConfig.rememberSyncPassword;
|
|
3220
|
+
}
|
|
3221
|
+
function buildConfigFromInput(existingConfig, input) {
|
|
3222
|
+
const nextConfig = existingConfig ? { ...existingConfig } : {
|
|
3223
|
+
webdavUrl: "",
|
|
3224
|
+
username: "",
|
|
3225
|
+
password: "",
|
|
3226
|
+
authType: "password",
|
|
3227
|
+
remoteDir: "/",
|
|
3228
|
+
syncPassword: void 0,
|
|
3229
|
+
rememberSyncPassword: true,
|
|
3230
|
+
lastSync: void 0
|
|
3231
|
+
};
|
|
3232
|
+
if (input.overrides.webdavUrl !== void 0) {
|
|
3233
|
+
nextConfig.webdavUrl = input.overrides.webdavUrl;
|
|
3234
|
+
}
|
|
3235
|
+
if (input.overrides.username !== void 0) {
|
|
3236
|
+
nextConfig.username = input.overrides.username;
|
|
3237
|
+
}
|
|
3238
|
+
if (input.overrides.password !== void 0) {
|
|
3239
|
+
nextConfig.password = input.overrides.password;
|
|
3240
|
+
}
|
|
3241
|
+
if (input.overrides.authType !== void 0) {
|
|
3242
|
+
nextConfig.authType = input.overrides.authType;
|
|
3243
|
+
}
|
|
3244
|
+
if (input.overrides.remoteDir !== void 0) {
|
|
3245
|
+
nextConfig.remoteDir = input.overrides.remoteDir;
|
|
3246
|
+
}
|
|
3247
|
+
if (input.overrides.syncPassword !== void 0) {
|
|
3248
|
+
nextConfig.syncPassword = input.overrides.syncPassword;
|
|
3249
|
+
}
|
|
3250
|
+
if (input.rememberSyncPassword !== void 0) {
|
|
3251
|
+
nextConfig.rememberSyncPassword = input.rememberSyncPassword;
|
|
3252
|
+
}
|
|
3253
|
+
nextConfig.authType = nextConfig.authType || "password";
|
|
3254
|
+
nextConfig.remoteDir = nextConfig.remoteDir || "/";
|
|
3255
|
+
nextConfig.rememberSyncPassword = nextConfig.rememberSyncPassword ?? true;
|
|
3256
|
+
const missingFields = getMissingConnectionFields(nextConfig);
|
|
3257
|
+
if (missingFields.length > 0) {
|
|
3258
|
+
throw new Error(
|
|
3259
|
+
`\u7F3A\u5C11\u540C\u6B65\u914D\u7F6E\u53C2\u6570: ${missingFields.map((field) => `--${field.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}`).join(", ")}`
|
|
3260
|
+
);
|
|
3261
|
+
}
|
|
3262
|
+
validateWebdavUrl(nextConfig.webdavUrl);
|
|
3263
|
+
if (!existingConfig && !nextConfig.syncPassword) {
|
|
3264
|
+
throw new Error("\u7F3A\u5C11\u540C\u6B65\u914D\u7F6E\u53C2\u6570: --sync-password");
|
|
3265
|
+
}
|
|
3266
|
+
return nextConfig;
|
|
3267
|
+
}
|
|
3268
|
+
async function printConnectionTestResult(config) {
|
|
3269
|
+
console.log(chalk6.bold("\n\u{1F50D} \u6D4B\u8BD5 WebDAV \u8FDE\u63A5...\n"));
|
|
3270
|
+
const success = await testWebDAVConnection(config);
|
|
3271
|
+
if (success) {
|
|
3272
|
+
console.log(chalk6.green("\u2705 \u8FDE\u63A5\u6210\u529F"));
|
|
3273
|
+
console.log();
|
|
3274
|
+
console.log(" ", chalk6.gray("URL:"), config.webdavUrl);
|
|
3275
|
+
console.log(" ", chalk6.gray("\u7528\u6237:"), config.username);
|
|
3276
|
+
console.log(" ", chalk6.gray("\u8FDC\u7A0B\u76EE\u5F55:"), config.remoteDir || "/");
|
|
3277
|
+
console.log(
|
|
3278
|
+
" ",
|
|
3279
|
+
chalk6.gray("\u8BA4\u8BC1\u7C7B\u578B:"),
|
|
3280
|
+
config.authType === "password" ? "Basic Auth" : "Digest Auth"
|
|
3281
|
+
);
|
|
3282
|
+
console.log();
|
|
3283
|
+
return;
|
|
3284
|
+
}
|
|
3285
|
+
console.log(chalk6.red("\u274C \u8FDE\u63A5\u5931\u8D25"));
|
|
3286
|
+
console.log();
|
|
3287
|
+
console.log(chalk6.yellow("\u8BF7\u68C0\u67E5:"));
|
|
3288
|
+
console.log(" 1. WebDAV \u670D\u52A1\u5668\u5730\u5740\u662F\u5426\u6B63\u786E");
|
|
3289
|
+
console.log(" 2. \u7528\u6237\u540D\u548C\u5BC6\u7801\u662F\u5426\u6B63\u786E");
|
|
3290
|
+
console.log(" 3. \u7F51\u7EDC\u8FDE\u63A5\u662F\u5426\u6B63\u5E38");
|
|
3291
|
+
console.log();
|
|
3292
|
+
}
|
|
3017
3293
|
function configCommand(program2) {
|
|
3018
|
-
program2.command("config").description("\u914D\u7F6E WebDAV \u8FDE\u63A5")
|
|
3294
|
+
const command = program2.command("config").description("\u914D\u7F6E WebDAV \u8FDE\u63A5");
|
|
3295
|
+
addSyncConnectionOptions(command, {
|
|
3296
|
+
includeSyncPassword: true,
|
|
3297
|
+
includeRememberFlags: true,
|
|
3298
|
+
includeTestFlag: true
|
|
3299
|
+
});
|
|
3300
|
+
command.action(async (options) => {
|
|
3019
3301
|
try {
|
|
3020
|
-
console.log(
|
|
3302
|
+
console.log(chalk6.bold("\n\u2699\uFE0F \u914D\u7F6E WebDAV \u540C\u6B65\n"));
|
|
3021
3303
|
const existingConfig = loadSyncConfig();
|
|
3304
|
+
const input = collectSyncCommandInput(options);
|
|
3305
|
+
if (input.nonInteractive) {
|
|
3306
|
+
const newConfig2 = buildConfigFromInput(existingConfig, input);
|
|
3307
|
+
if (!hasConfigChanges(existingConfig, newConfig2)) {
|
|
3308
|
+
console.log();
|
|
3309
|
+
console.log(chalk6.yellow("\u2139\uFE0F \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u53D8\u66F4\uFF0C\u4E0D\u9700\u8981\u66F4\u65B0"));
|
|
3310
|
+
console.log();
|
|
3311
|
+
return;
|
|
3312
|
+
}
|
|
3313
|
+
saveSyncConfig2(newConfig2);
|
|
3314
|
+
console.log();
|
|
3315
|
+
console.log(chalk6.green("\u2705 \u914D\u7F6E\u4FDD\u5B58\u6210\u529F"));
|
|
3316
|
+
console.log();
|
|
3317
|
+
console.log(chalk6.gray("\u914D\u7F6E\u6587\u4EF6:"), getSyncConfigPath());
|
|
3318
|
+
console.log();
|
|
3319
|
+
if (input.shouldTest) {
|
|
3320
|
+
await printConnectionTestResult(newConfig2);
|
|
3321
|
+
}
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3022
3324
|
if (existingConfig) {
|
|
3023
|
-
console.log(
|
|
3024
|
-
console.log(
|
|
3325
|
+
console.log(chalk6.blue("\u2139\uFE0F \u68C0\u6D4B\u5230\u5DF2\u6709\u914D\u7F6E\uFF0C\u53EF\u4EE5\u66F4\u65B0 WebDAV \u5B57\u6BB5"));
|
|
3326
|
+
console.log(chalk6.gray(" \u7559\u7A7A\u8868\u793A\u4E0D\u66F4\u65B0\u8BE5\u5B57\u6BB5\n"));
|
|
3025
3327
|
}
|
|
3026
|
-
const answers = await
|
|
3328
|
+
const answers = await inquirer3.prompt([
|
|
3027
3329
|
{
|
|
3028
3330
|
type: "input",
|
|
3029
3331
|
name: "webdavUrl",
|
|
@@ -3094,7 +3396,7 @@ function configCommand(program2) {
|
|
|
3094
3396
|
const hasSelectChange = trimmedAnswers.authType !== existingConfig.authType || trimmedAnswers.rememberSyncPassword !== existingConfig.rememberSyncPassword;
|
|
3095
3397
|
if (!hasTextInput && !hasSelectChange) {
|
|
3096
3398
|
console.log();
|
|
3097
|
-
console.log(
|
|
3399
|
+
console.log(chalk6.yellow("\u2139\uFE0F \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u53D8\u66F4\uFF0C\u4E0D\u9700\u8981\u66F4\u65B0"));
|
|
3098
3400
|
console.log();
|
|
3099
3401
|
return;
|
|
3100
3402
|
}
|
|
@@ -3159,40 +3461,22 @@ function configCommand(program2) {
|
|
|
3159
3461
|
}
|
|
3160
3462
|
if (!hasChanges && existingConfig) {
|
|
3161
3463
|
console.log();
|
|
3162
|
-
console.log(
|
|
3464
|
+
console.log(chalk6.yellow("\u2139\uFE0F \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u53D8\u66F4\uFF0C\u4E0D\u9700\u8981\u66F4\u65B0"));
|
|
3163
3465
|
console.log();
|
|
3164
3466
|
return;
|
|
3165
3467
|
}
|
|
3166
3468
|
saveSyncConfig2(newConfig);
|
|
3167
3469
|
console.log();
|
|
3168
|
-
console.log(
|
|
3470
|
+
console.log(chalk6.green("\u2705 \u914D\u7F6E\u4FDD\u5B58\u6210\u529F"));
|
|
3169
3471
|
console.log();
|
|
3170
|
-
console.log(
|
|
3472
|
+
console.log(chalk6.gray("\u914D\u7F6E\u6587\u4EF6:"), getSyncConfigPath());
|
|
3171
3473
|
console.log();
|
|
3172
3474
|
const testNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u6D4B\u8BD5\u8FDE\u63A5?", true);
|
|
3173
3475
|
if (testNow) {
|
|
3174
|
-
|
|
3175
|
-
const success = await testWebDAVConnection(newConfig);
|
|
3176
|
-
if (success) {
|
|
3177
|
-
console.log(chalk3.green("\u2705 \u8FDE\u63A5\u6210\u529F"));
|
|
3178
|
-
console.log();
|
|
3179
|
-
console.log(" ", chalk3.gray("URL:"), newConfig.webdavUrl);
|
|
3180
|
-
console.log(" ", chalk3.gray("\u7528\u6237:"), newConfig.username);
|
|
3181
|
-
console.log(" ", chalk3.gray("\u8FDC\u7A0B\u76EE\u5F55:"), newConfig.remoteDir || "/");
|
|
3182
|
-
console.log(" ", chalk3.gray("\u8BA4\u8BC1\u7C7B\u578B:"), newConfig.authType === "password" ? "Basic Auth" : "Digest Auth");
|
|
3183
|
-
console.log();
|
|
3184
|
-
} else {
|
|
3185
|
-
console.log(chalk3.red("\u274C \u8FDE\u63A5\u5931\u8D25"));
|
|
3186
|
-
console.log();
|
|
3187
|
-
console.log(chalk3.yellow("\u8BF7\u68C0\u67E5:"));
|
|
3188
|
-
console.log(" 1. WebDAV \u670D\u52A1\u5668\u5730\u5740\u662F\u5426\u6B63\u786E");
|
|
3189
|
-
console.log(" 2. \u7528\u6237\u540D\u548C\u5BC6\u7801\u662F\u5426\u6B63\u786E");
|
|
3190
|
-
console.log(" 3. \u7F51\u7EDC\u8FDE\u63A5\u662F\u5426\u6B63\u5E38");
|
|
3191
|
-
console.log();
|
|
3192
|
-
}
|
|
3476
|
+
await printConnectionTestResult(newConfig);
|
|
3193
3477
|
}
|
|
3194
3478
|
} catch (error) {
|
|
3195
|
-
console.error(
|
|
3479
|
+
console.error(chalk6.red(`
|
|
3196
3480
|
\u274C ${error.message}
|
|
3197
3481
|
`));
|
|
3198
3482
|
}
|
|
@@ -3204,33 +3488,7 @@ var init_config2 = __esm({
|
|
|
3204
3488
|
init_sync_config();
|
|
3205
3489
|
init_dist2();
|
|
3206
3490
|
init_confirm();
|
|
3207
|
-
|
|
3208
|
-
});
|
|
3209
|
-
|
|
3210
|
-
// src/commands/sync/helpers.ts
|
|
3211
|
-
import chalk4 from "chalk";
|
|
3212
|
-
import { Command } from "commander";
|
|
3213
|
-
async function ensureConfigExists() {
|
|
3214
|
-
const config = loadSyncConfig();
|
|
3215
|
-
if (config) {
|
|
3216
|
-
return config;
|
|
3217
|
-
}
|
|
3218
|
-
console.log(chalk4.yellow("\n\u26A0\uFE0F \u672A\u627E\u5230 WebDAV \u914D\u7F6E\n"));
|
|
3219
|
-
const shouldConfig = await promptConfirm("\u662F\u5426\u73B0\u5728\u914D\u7F6E WebDAV?", true);
|
|
3220
|
-
if (!shouldConfig) {
|
|
3221
|
-
return null;
|
|
3222
|
-
}
|
|
3223
|
-
const { configCommand: configCommand2 } = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
3224
|
-
const cmd = new Command();
|
|
3225
|
-
configCommand2(cmd);
|
|
3226
|
-
await cmd.parseAsync(["node", "ccman", "config"]);
|
|
3227
|
-
return loadSyncConfig();
|
|
3228
|
-
}
|
|
3229
|
-
var init_helpers = __esm({
|
|
3230
|
-
"src/commands/sync/helpers.ts"() {
|
|
3231
|
-
"use strict";
|
|
3232
|
-
init_sync_config();
|
|
3233
|
-
init_confirm();
|
|
3491
|
+
init_helpers();
|
|
3234
3492
|
}
|
|
3235
3493
|
});
|
|
3236
3494
|
|
|
@@ -3239,36 +3497,42 @@ var test_exports = {};
|
|
|
3239
3497
|
__export(test_exports, {
|
|
3240
3498
|
testCommand: () => testCommand
|
|
3241
3499
|
});
|
|
3242
|
-
import
|
|
3500
|
+
import chalk7 from "chalk";
|
|
3243
3501
|
function testCommand(program2) {
|
|
3244
|
-
program2.command("test").description("\u6D4B\u8BD5 WebDAV \u8FDE\u63A5")
|
|
3502
|
+
const command = program2.command("test").description("\u6D4B\u8BD5 WebDAV \u8FDE\u63A5");
|
|
3503
|
+
addSyncConnectionOptions(command);
|
|
3504
|
+
command.action(async (options) => {
|
|
3245
3505
|
try {
|
|
3246
|
-
const config = await ensureConfigExists();
|
|
3506
|
+
const config = await ensureConfigExists(options);
|
|
3247
3507
|
if (!config) {
|
|
3248
|
-
console.log(
|
|
3508
|
+
console.log(chalk7.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
3249
3509
|
return;
|
|
3250
3510
|
}
|
|
3251
|
-
console.log(
|
|
3511
|
+
console.log(chalk7.bold("\n\u{1F50D} \u6D4B\u8BD5 WebDAV \u8FDE\u63A5...\n"));
|
|
3252
3512
|
const success = await testWebDAVConnection(config);
|
|
3253
3513
|
if (success) {
|
|
3254
|
-
console.log(
|
|
3514
|
+
console.log(chalk7.green("\u2705 \u8FDE\u63A5\u6210\u529F"));
|
|
3255
3515
|
console.log();
|
|
3256
|
-
console.log(" ",
|
|
3257
|
-
console.log(" ",
|
|
3258
|
-
console.log(" ",
|
|
3259
|
-
console.log(
|
|
3516
|
+
console.log(" ", chalk7.gray("URL:"), config.webdavUrl);
|
|
3517
|
+
console.log(" ", chalk7.gray("\u7528\u6237:"), config.username);
|
|
3518
|
+
console.log(" ", chalk7.gray("\u8FDC\u7A0B\u76EE\u5F55:"), config.remoteDir || "/");
|
|
3519
|
+
console.log(
|
|
3520
|
+
" ",
|
|
3521
|
+
chalk7.gray("\u8BA4\u8BC1\u7C7B\u578B:"),
|
|
3522
|
+
config.authType === "password" ? "Basic Auth" : "Digest Auth"
|
|
3523
|
+
);
|
|
3260
3524
|
console.log();
|
|
3261
3525
|
} else {
|
|
3262
|
-
console.log(
|
|
3526
|
+
console.log(chalk7.red("\u274C \u8FDE\u63A5\u5931\u8D25"));
|
|
3263
3527
|
console.log();
|
|
3264
|
-
console.log(
|
|
3528
|
+
console.log(chalk7.yellow("\u8BF7\u68C0\u67E5:"));
|
|
3265
3529
|
console.log(" 1. WebDAV \u670D\u52A1\u5668\u5730\u5740\u662F\u5426\u6B63\u786E");
|
|
3266
3530
|
console.log(" 2. \u7528\u6237\u540D\u548C\u5BC6\u7801\u662F\u5426\u6B63\u786E");
|
|
3267
3531
|
console.log(" 3. \u7F51\u7EDC\u8FDE\u63A5\u662F\u5426\u6B63\u5E38");
|
|
3268
3532
|
console.log();
|
|
3269
3533
|
}
|
|
3270
3534
|
} catch (error) {
|
|
3271
|
-
console.error(
|
|
3535
|
+
console.error(chalk7.red(`
|
|
3272
3536
|
\u274C ${error.message}
|
|
3273
3537
|
`));
|
|
3274
3538
|
}
|
|
@@ -3287,29 +3551,21 @@ var upload_exports = {};
|
|
|
3287
3551
|
__export(upload_exports, {
|
|
3288
3552
|
uploadCommand: () => uploadCommand
|
|
3289
3553
|
});
|
|
3290
|
-
import
|
|
3291
|
-
import inquirer3 from "inquirer";
|
|
3554
|
+
import chalk8 from "chalk";
|
|
3292
3555
|
function uploadCommand(program2) {
|
|
3293
|
-
program2.command("upload").description("\u4E0A\u4F20\u672C\u5730\u914D\u7F6E\u5230\u4E91\u7AEF")
|
|
3556
|
+
const command = program2.command("upload").description("\u4E0A\u4F20\u672C\u5730\u914D\u7F6E\u5230\u4E91\u7AEF");
|
|
3557
|
+
addSyncConnectionOptions(command, {
|
|
3558
|
+
includeSyncPassword: true,
|
|
3559
|
+
includeConfirm: true
|
|
3560
|
+
});
|
|
3561
|
+
command.action(async (options) => {
|
|
3294
3562
|
try {
|
|
3295
|
-
const config = await ensureConfigExists();
|
|
3563
|
+
const config = await ensureConfigExists(options);
|
|
3296
3564
|
if (!config) {
|
|
3297
|
-
console.log(
|
|
3565
|
+
console.log(chalk8.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
3298
3566
|
return;
|
|
3299
3567
|
}
|
|
3300
|
-
|
|
3301
|
-
if (!syncPassword) {
|
|
3302
|
-
const { password } = await inquirer3.prompt([
|
|
3303
|
-
{
|
|
3304
|
-
type: "password",
|
|
3305
|
-
name: "password",
|
|
3306
|
-
message: "\u8BF7\u8F93\u5165\u540C\u6B65\u5BC6\u7801:",
|
|
3307
|
-
mask: "*",
|
|
3308
|
-
validate: (value) => value ? true : "\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
3309
|
-
}
|
|
3310
|
-
]);
|
|
3311
|
-
syncPassword = password;
|
|
3312
|
-
}
|
|
3568
|
+
const syncPassword = await resolveSyncPassword(config, options);
|
|
3313
3569
|
const codexManager = createCodexManager();
|
|
3314
3570
|
const claudeManager = createClaudeManager();
|
|
3315
3571
|
const geminiManager = createGeminiManager();
|
|
@@ -3318,36 +3574,37 @@ function uploadCommand(program2) {
|
|
|
3318
3574
|
const claudeProviders = claudeManager.list();
|
|
3319
3575
|
const geminiProviders = geminiManager.list();
|
|
3320
3576
|
const openclawProviders = openclawManager.list();
|
|
3321
|
-
console.log(
|
|
3577
|
+
console.log(chalk8.bold("\n\u{1F4E4} \u4E0A\u4F20\u914D\u7F6E\u5230\u4E91\u7AEF\n"));
|
|
3322
3578
|
console.log("\u914D\u7F6E\u4FE1\u606F:");
|
|
3323
|
-
console.log(` Codex \u670D\u52A1\u5546: ${
|
|
3324
|
-
console.log(` Claude \u670D\u52A1\u5546: ${
|
|
3325
|
-
console.log(` Gemini \u670D\u52A1\u5546: ${
|
|
3326
|
-
console.log(` OpenClaw \u670D\u52A1\u5546: ${
|
|
3579
|
+
console.log(` Codex \u670D\u52A1\u5546: ${chalk8.cyan(codexProviders.length)} \u4E2A`);
|
|
3580
|
+
console.log(` Claude \u670D\u52A1\u5546: ${chalk8.cyan(claudeProviders.length)} \u4E2A`);
|
|
3581
|
+
console.log(` Gemini \u670D\u52A1\u5546: ${chalk8.cyan(geminiProviders.length)} \u4E2A`);
|
|
3582
|
+
console.log(` OpenClaw \u670D\u52A1\u5546: ${chalk8.cyan(openclawProviders.length)} \u4E2A`);
|
|
3327
3583
|
console.log();
|
|
3328
|
-
console.log(
|
|
3584
|
+
console.log(chalk8.yellow("\u26A0\uFE0F \u4E91\u7AEF\u73B0\u6709\u914D\u7F6E\u5C06\u88AB\u8986\u76D6"));
|
|
3329
3585
|
console.log();
|
|
3330
|
-
const confirm = await
|
|
3586
|
+
const confirm = await confirmOrExit("\u786E\u8BA4\u4E0A\u4F20?", false, options);
|
|
3331
3587
|
if (!confirm) {
|
|
3332
|
-
console.log(
|
|
3588
|
+
console.log(chalk8.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
3333
3589
|
return;
|
|
3334
3590
|
}
|
|
3335
3591
|
console.log();
|
|
3336
|
-
console.log(
|
|
3337
|
-
console.log(
|
|
3592
|
+
console.log(chalk8.gray("\u{1F510} \u52A0\u5BC6 API Key..."));
|
|
3593
|
+
console.log(chalk8.gray("\u{1F4E4} \u4E0A\u4F20\u5230 WebDAV..."));
|
|
3338
3594
|
await uploadToCloud(config, syncPassword);
|
|
3339
3595
|
console.log();
|
|
3340
|
-
console.log(
|
|
3596
|
+
console.log(chalk8.green("\u2705 \u4E0A\u4F20\u6210\u529F"));
|
|
3341
3597
|
console.log();
|
|
3342
|
-
|
|
3343
|
-
console.log(
|
|
3344
|
-
console.log(
|
|
3345
|
-
console.log(
|
|
3346
|
-
console.log(
|
|
3598
|
+
const remoteDir = config.remoteDir || "/";
|
|
3599
|
+
console.log(chalk8.gray("\u8FDC\u7A0B\u6587\u4EF6:"));
|
|
3600
|
+
console.log(chalk8.gray(` ${config.webdavUrl}${remoteDir}/.ccman/codex.json`));
|
|
3601
|
+
console.log(chalk8.gray(` ${config.webdavUrl}${remoteDir}/.ccman/claude.json`));
|
|
3602
|
+
console.log(chalk8.gray(` ${config.webdavUrl}${remoteDir}/.ccman/gemini.json`));
|
|
3603
|
+
console.log(chalk8.gray(` ${config.webdavUrl}${remoteDir}/.ccman/openclaw.json`));
|
|
3347
3604
|
console.log();
|
|
3348
|
-
console.log(
|
|
3605
|
+
console.log(chalk8.blue("\u{1F4A1} \u5176\u4ED6\u8BBE\u5907\u53EF\u901A\u8FC7 'ccman sync download' \u83B7\u53D6\u914D\u7F6E\n"));
|
|
3349
3606
|
} catch (error) {
|
|
3350
|
-
console.error(
|
|
3607
|
+
console.error(chalk8.red(`
|
|
3351
3608
|
\u274C ${error.message}
|
|
3352
3609
|
`));
|
|
3353
3610
|
}
|
|
@@ -3358,7 +3615,6 @@ var init_upload = __esm({
|
|
|
3358
3615
|
"use strict";
|
|
3359
3616
|
init_dist2();
|
|
3360
3617
|
init_helpers();
|
|
3361
|
-
init_confirm();
|
|
3362
3618
|
}
|
|
3363
3619
|
});
|
|
3364
3620
|
|
|
@@ -3367,55 +3623,47 @@ var download_exports = {};
|
|
|
3367
3623
|
__export(download_exports, {
|
|
3368
3624
|
downloadCommand: () => downloadCommand
|
|
3369
3625
|
});
|
|
3370
|
-
import
|
|
3371
|
-
import inquirer4 from "inquirer";
|
|
3626
|
+
import chalk9 from "chalk";
|
|
3372
3627
|
function downloadCommand(program2) {
|
|
3373
|
-
program2.command("download").description("\u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u914D\u7F6E\u5230\u672C\u5730")
|
|
3628
|
+
const command = program2.command("download").description("\u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u914D\u7F6E\u5230\u672C\u5730");
|
|
3629
|
+
addSyncConnectionOptions(command, {
|
|
3630
|
+
includeSyncPassword: true,
|
|
3631
|
+
includeConfirm: true
|
|
3632
|
+
});
|
|
3633
|
+
command.action(async (options) => {
|
|
3374
3634
|
try {
|
|
3375
|
-
const config = await ensureConfigExists();
|
|
3635
|
+
const config = await ensureConfigExists(options);
|
|
3376
3636
|
if (!config) {
|
|
3377
|
-
console.log(
|
|
3637
|
+
console.log(chalk9.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
3378
3638
|
return;
|
|
3379
3639
|
}
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
{
|
|
3384
|
-
type: "password",
|
|
3385
|
-
name: "password",
|
|
3386
|
-
message: "\u8BF7\u8F93\u5165\u540C\u6B65\u5BC6\u7801:",
|
|
3387
|
-
mask: "*",
|
|
3388
|
-
validate: (value) => value ? true : "\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
3389
|
-
}
|
|
3390
|
-
]);
|
|
3391
|
-
syncPassword = password;
|
|
3392
|
-
}
|
|
3393
|
-
console.log(chalk7.bold("\n\u{1F4E5} \u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u914D\u7F6E\n"));
|
|
3394
|
-
console.log(chalk7.yellow("\u26A0\uFE0F \u5C06\u8986\u76D6\u672C\u5730\u914D\u7F6E\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
|
|
3640
|
+
const syncPassword = await resolveSyncPassword(config, options);
|
|
3641
|
+
console.log(chalk9.bold("\n\u{1F4E5} \u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u914D\u7F6E\n"));
|
|
3642
|
+
console.log(chalk9.yellow("\u26A0\uFE0F \u5C06\u8986\u76D6\u672C\u5730\u914D\u7F6E\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
|
|
3395
3643
|
console.log();
|
|
3396
|
-
const confirm = await
|
|
3644
|
+
const confirm = await confirmOrExit("\u786E\u8BA4\u4E0B\u8F7D?", false, options);
|
|
3397
3645
|
if (!confirm) {
|
|
3398
|
-
console.log(
|
|
3646
|
+
console.log(chalk9.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
3399
3647
|
return;
|
|
3400
3648
|
}
|
|
3401
3649
|
console.log();
|
|
3402
|
-
console.log(
|
|
3403
|
-
console.log(
|
|
3404
|
-
console.log(
|
|
3650
|
+
console.log(chalk9.gray("\u{1F4BE} \u5907\u4EFD\u672C\u5730\u914D\u7F6E..."));
|
|
3651
|
+
console.log(chalk9.gray("\u{1F4E5} \u4E0B\u8F7D\u8FDC\u7A0B\u914D\u7F6E..."));
|
|
3652
|
+
console.log(chalk9.gray("\u{1F513} \u89E3\u5BC6 API Key..."));
|
|
3405
3653
|
const backupPaths = await downloadFromCloud(config, syncPassword);
|
|
3406
3654
|
console.log();
|
|
3407
|
-
console.log(
|
|
3655
|
+
console.log(chalk9.green("\u2705 \u4E0B\u8F7D\u6210\u529F"));
|
|
3408
3656
|
console.log();
|
|
3409
3657
|
if (backupPaths.length > 0) {
|
|
3410
|
-
console.log(
|
|
3658
|
+
console.log(chalk9.gray("\u672C\u5730\u5907\u4EFD:"));
|
|
3411
3659
|
backupPaths.forEach((path16) => {
|
|
3412
|
-
console.log(
|
|
3660
|
+
console.log(chalk9.gray(` ${path16}`));
|
|
3413
3661
|
});
|
|
3414
3662
|
console.log();
|
|
3415
3663
|
}
|
|
3416
|
-
console.log(
|
|
3664
|
+
console.log(chalk9.blue("\u{1F4A1} \u914D\u7F6E\u5DF2\u66F4\u65B0\uFF0C\u91CD\u65B0\u52A0\u8F7D\u751F\u6548\n"));
|
|
3417
3665
|
} catch (error) {
|
|
3418
|
-
console.error(
|
|
3666
|
+
console.error(chalk9.red(`
|
|
3419
3667
|
\u274C ${error.message}
|
|
3420
3668
|
`));
|
|
3421
3669
|
}
|
|
@@ -3426,7 +3674,6 @@ var init_download = __esm({
|
|
|
3426
3674
|
"use strict";
|
|
3427
3675
|
init_dist2();
|
|
3428
3676
|
init_helpers();
|
|
3429
|
-
init_confirm();
|
|
3430
3677
|
}
|
|
3431
3678
|
});
|
|
3432
3679
|
|
|
@@ -3435,54 +3682,45 @@ var merge_exports = {};
|
|
|
3435
3682
|
__export(merge_exports, {
|
|
3436
3683
|
mergeCommand: () => mergeCommand
|
|
3437
3684
|
});
|
|
3438
|
-
import
|
|
3439
|
-
import inquirer5 from "inquirer";
|
|
3685
|
+
import chalk10 from "chalk";
|
|
3440
3686
|
function mergeCommand(program2) {
|
|
3441
|
-
program2.command("merge").description("\u667A\u80FD\u5408\u5E76\u672C\u5730\u548C\u4E91\u7AEF\u914D\u7F6E")
|
|
3687
|
+
const command = program2.command("merge").description("\u667A\u80FD\u5408\u5E76\u672C\u5730\u548C\u4E91\u7AEF\u914D\u7F6E");
|
|
3688
|
+
addSyncConnectionOptions(command, {
|
|
3689
|
+
includeSyncPassword: true
|
|
3690
|
+
});
|
|
3691
|
+
command.action(async (options) => {
|
|
3442
3692
|
try {
|
|
3443
|
-
const config = await ensureConfigExists();
|
|
3693
|
+
const config = await ensureConfigExists(options);
|
|
3444
3694
|
if (!config) {
|
|
3445
|
-
console.log(
|
|
3695
|
+
console.log(chalk10.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
3446
3696
|
return;
|
|
3447
3697
|
}
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
{
|
|
3452
|
-
type: "password",
|
|
3453
|
-
name: "password",
|
|
3454
|
-
message: "\u8BF7\u8F93\u5165\u540C\u6B65\u5BC6\u7801:",
|
|
3455
|
-
mask: "*",
|
|
3456
|
-
validate: (value) => value ? true : "\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
3457
|
-
}
|
|
3458
|
-
]);
|
|
3459
|
-
syncPassword = password;
|
|
3460
|
-
}
|
|
3461
|
-
console.log(chalk8.bold("\n\u{1F504} \u667A\u80FD\u5408\u5E76\u914D\u7F6E\n"));
|
|
3462
|
-
console.log(chalk8.gray("\u5206\u6790\u672C\u5730\u548C\u4E91\u7AEF\u914D\u7F6E..."));
|
|
3698
|
+
const syncPassword = await resolveSyncPassword(config, options);
|
|
3699
|
+
console.log(chalk10.bold("\n\u{1F504} \u667A\u80FD\u5408\u5E76\u914D\u7F6E\n"));
|
|
3700
|
+
console.log(chalk10.gray("\u5206\u6790\u672C\u5730\u548C\u4E91\u7AEF\u914D\u7F6E..."));
|
|
3463
3701
|
const result = await mergeSync(config, syncPassword);
|
|
3464
3702
|
if (!result.hasChanges) {
|
|
3465
3703
|
console.log();
|
|
3466
|
-
console.log(
|
|
3704
|
+
console.log(chalk10.blue("\u2139\uFE0F \u914D\u7F6E\u5DF2\u540C\u6B65\uFF0C\u65E0\u9700\u64CD\u4F5C\n"));
|
|
3467
3705
|
return;
|
|
3468
3706
|
}
|
|
3469
3707
|
console.log();
|
|
3470
|
-
console.log(
|
|
3708
|
+
console.log(chalk10.green("\u2705 \u914D\u7F6E\u5DF2\u667A\u80FD\u5408\u5E76\u5E76\u540C\u6B65"));
|
|
3471
3709
|
console.log();
|
|
3472
3710
|
if (result.backupPaths.length > 0) {
|
|
3473
|
-
console.log(
|
|
3711
|
+
console.log(chalk10.gray("\u5907\u4EFD:"));
|
|
3474
3712
|
result.backupPaths.forEach((path16) => {
|
|
3475
|
-
console.log(
|
|
3713
|
+
console.log(chalk10.gray(` ${path16}`));
|
|
3476
3714
|
});
|
|
3477
3715
|
console.log();
|
|
3478
3716
|
}
|
|
3479
|
-
console.log(
|
|
3480
|
-
console.log(
|
|
3481
|
-
console.log(
|
|
3482
|
-
console.log(
|
|
3717
|
+
console.log(chalk10.blue("\u5408\u5E76\u89C4\u5219:"));
|
|
3718
|
+
console.log(chalk10.gray(" \u2022 \u76F8\u540C ID\uFF1A\u4FDD\u7559\u6700\u65B0\u4FEE\u6539"));
|
|
3719
|
+
console.log(chalk10.gray(" \u2022 \u76F8\u540C\u914D\u7F6E\uFF08URL+Key\uFF09\uFF1A\u4FDD\u7559\u6700\u65B0\u4FEE\u6539"));
|
|
3720
|
+
console.log(chalk10.gray(" \u2022 \u4E0D\u540C\u914D\u7F6E\uFF1A\u5168\u90E8\u4FDD\u7559\uFF0C\u81EA\u52A8\u5904\u7406 name \u51B2\u7A81"));
|
|
3483
3721
|
console.log();
|
|
3484
3722
|
} catch (error) {
|
|
3485
|
-
console.error(
|
|
3723
|
+
console.error(chalk10.red(`
|
|
3486
3724
|
\u274C ${error.message}
|
|
3487
3725
|
`));
|
|
3488
3726
|
}
|
|
@@ -3501,27 +3739,27 @@ var status_exports = {};
|
|
|
3501
3739
|
__export(status_exports, {
|
|
3502
3740
|
statusCommand: () => statusCommand
|
|
3503
3741
|
});
|
|
3504
|
-
import
|
|
3742
|
+
import chalk11 from "chalk";
|
|
3505
3743
|
function statusCommand(program2) {
|
|
3506
3744
|
program2.command("status").description("\u67E5\u770B\u540C\u6B65\u72B6\u6001").action(async () => {
|
|
3507
3745
|
try {
|
|
3508
3746
|
const config = loadSyncConfig();
|
|
3509
|
-
console.log(
|
|
3747
|
+
console.log(chalk11.bold("\n\u{1F4CA} \u540C\u6B65\u72B6\u6001\n"));
|
|
3510
3748
|
if (!config) {
|
|
3511
|
-
console.log(
|
|
3749
|
+
console.log(chalk11.yellow("\u26A0\uFE0F \u672A\u914D\u7F6E WebDAV \u540C\u6B65"));
|
|
3512
3750
|
console.log();
|
|
3513
|
-
console.log(
|
|
3751
|
+
console.log(chalk11.blue("\u{1F4A1} \u5F00\u59CB\u914D\u7F6E: ccman sync config\n"));
|
|
3514
3752
|
return;
|
|
3515
3753
|
}
|
|
3516
|
-
console.log(
|
|
3517
|
-
console.log(` URL: ${
|
|
3518
|
-
console.log(` \u7528\u6237: ${
|
|
3519
|
-
console.log(` \u8FDC\u7A0B\u76EE\u5F55: ${
|
|
3754
|
+
console.log(chalk11.bold("WebDAV \u914D\u7F6E:"));
|
|
3755
|
+
console.log(` URL: ${chalk11.gray(config.webdavUrl)}`);
|
|
3756
|
+
console.log(` \u7528\u6237: ${chalk11.gray(config.username)}`);
|
|
3757
|
+
console.log(` \u8FDC\u7A0B\u76EE\u5F55: ${chalk11.gray(config.remoteDir)}`);
|
|
3520
3758
|
console.log(
|
|
3521
|
-
` \u8BA4\u8BC1: ${
|
|
3759
|
+
` \u8BA4\u8BC1: ${chalk11.gray(config.authType === "password" ? "Basic Auth" : "Digest Auth")}`
|
|
3522
3760
|
);
|
|
3523
3761
|
console.log(
|
|
3524
|
-
` \u540C\u6B65\u5BC6\u7801: ${config.syncPassword ?
|
|
3762
|
+
` \u540C\u6B65\u5BC6\u7801: ${config.syncPassword ? chalk11.green("\u2713 \u5DF2\u4FDD\u5B58") : chalk11.yellow("\u2717 \u672A\u4FDD\u5B58")}`
|
|
3525
3763
|
);
|
|
3526
3764
|
console.log();
|
|
3527
3765
|
const codexManager = createCodexManager();
|
|
@@ -3532,23 +3770,23 @@ function statusCommand(program2) {
|
|
|
3532
3770
|
const claudeProviders = claudeManager.list();
|
|
3533
3771
|
const geminiProviders = geminiManager.list();
|
|
3534
3772
|
const openclawProviders = openclawManager.list();
|
|
3535
|
-
console.log(
|
|
3536
|
-
console.log(` Codex: ${
|
|
3537
|
-
console.log(` Claude: ${
|
|
3538
|
-
console.log(` Gemini: ${
|
|
3539
|
-
console.log(` OpenClaw: ${
|
|
3773
|
+
console.log(chalk11.bold("\u672C\u5730\u914D\u7F6E:"));
|
|
3774
|
+
console.log(` Codex: ${chalk11.cyan(codexProviders.length)} \u4E2A\u670D\u52A1\u5546`);
|
|
3775
|
+
console.log(` Claude: ${chalk11.cyan(claudeProviders.length)} \u4E2A\u670D\u52A1\u5546`);
|
|
3776
|
+
console.log(` Gemini: ${chalk11.cyan(geminiProviders.length)} \u4E2A\u670D\u52A1\u5546`);
|
|
3777
|
+
console.log(` OpenClaw: ${chalk11.cyan(openclawProviders.length)} \u4E2A\u670D\u52A1\u5546`);
|
|
3540
3778
|
if (config.lastSync) {
|
|
3541
3779
|
const date = new Date(config.lastSync).toLocaleString("zh-CN");
|
|
3542
|
-
console.log(` \u6700\u540E\u540C\u6B65: ${
|
|
3780
|
+
console.log(` \u6700\u540E\u540C\u6B65: ${chalk11.gray(date)}`);
|
|
3543
3781
|
}
|
|
3544
3782
|
console.log();
|
|
3545
|
-
console.log(
|
|
3546
|
-
console.log(
|
|
3547
|
-
console.log(
|
|
3548
|
-
console.log(
|
|
3783
|
+
console.log(chalk11.bold("\u540C\u6B65\u5EFA\u8BAE:"));
|
|
3784
|
+
console.log(chalk11.blue(" \u{1F4A1} \u4E0A\u4F20\u5230\u4E91\u7AEF: ccman sync upload"));
|
|
3785
|
+
console.log(chalk11.blue(" \u{1F4A1} \u4ECE\u4E91\u7AEF\u4E0B\u8F7D: ccman sync download"));
|
|
3786
|
+
console.log(chalk11.blue(" \u{1F4A1} \u667A\u80FD\u5408\u5E76: ccman sync merge"));
|
|
3549
3787
|
console.log();
|
|
3550
3788
|
} catch (error) {
|
|
3551
|
-
console.error(
|
|
3789
|
+
console.error(chalk11.red(`
|
|
3552
3790
|
\u274C ${error.message}
|
|
3553
3791
|
`));
|
|
3554
3792
|
}
|
|
@@ -3569,8 +3807,8 @@ __export(sync_exports, {
|
|
|
3569
3807
|
startSyncMenu: () => startSyncMenu
|
|
3570
3808
|
});
|
|
3571
3809
|
import { Command as Command2 } from "commander";
|
|
3572
|
-
import
|
|
3573
|
-
import
|
|
3810
|
+
import inquirer4 from "inquirer";
|
|
3811
|
+
import chalk12 from "chalk";
|
|
3574
3812
|
function createSyncCommands(program2) {
|
|
3575
3813
|
configCommand(program2);
|
|
3576
3814
|
testCommand(program2);
|
|
@@ -3582,7 +3820,7 @@ function createSyncCommands(program2) {
|
|
|
3582
3820
|
async function startSyncMenu() {
|
|
3583
3821
|
while (true) {
|
|
3584
3822
|
console.log();
|
|
3585
|
-
const { action } = await
|
|
3823
|
+
const { action } = await inquirer4.prompt([
|
|
3586
3824
|
{
|
|
3587
3825
|
type: "list",
|
|
3588
3826
|
name: "action",
|
|
@@ -3647,11 +3885,11 @@ async function startSyncMenu() {
|
|
|
3647
3885
|
}
|
|
3648
3886
|
}
|
|
3649
3887
|
} catch (error) {
|
|
3650
|
-
console.error(
|
|
3888
|
+
console.error(chalk12.red(`
|
|
3651
3889
|
\u274C ${error.message}
|
|
3652
3890
|
`));
|
|
3653
3891
|
}
|
|
3654
|
-
await
|
|
3892
|
+
await inquirer4.prompt([
|
|
3655
3893
|
{
|
|
3656
3894
|
type: "input",
|
|
3657
3895
|
name: "continue",
|
|
@@ -3674,7 +3912,7 @@ var init_sync = __esm({
|
|
|
3674
3912
|
|
|
3675
3913
|
// src/index.ts
|
|
3676
3914
|
import { Command as Command3 } from "commander";
|
|
3677
|
-
import
|
|
3915
|
+
import chalk57 from "chalk";
|
|
3678
3916
|
|
|
3679
3917
|
// src/utils/logo.ts
|
|
3680
3918
|
init_dist2();
|
|
@@ -3699,26 +3937,33 @@ function printLogo() {
|
|
|
3699
3937
|
|
|
3700
3938
|
// src/commands/codex/add.ts
|
|
3701
3939
|
init_dist2();
|
|
3702
|
-
import
|
|
3703
|
-
import
|
|
3940
|
+
import chalk14 from "chalk";
|
|
3941
|
+
import inquirer6 from "inquirer";
|
|
3704
3942
|
|
|
3705
3943
|
// src/interactive.ts
|
|
3706
3944
|
init_dist2();
|
|
3707
|
-
import
|
|
3708
|
-
import
|
|
3945
|
+
import inquirer5 from "inquirer";
|
|
3946
|
+
import chalk13 from "chalk";
|
|
3709
3947
|
|
|
3710
3948
|
// src/utils/format.ts
|
|
3711
3949
|
import chalk2 from "chalk";
|
|
3712
|
-
function formatProviderTable(providers, currentId) {
|
|
3950
|
+
function formatProviderTable(providers, currentId, title) {
|
|
3713
3951
|
const lines = [];
|
|
3714
|
-
|
|
3952
|
+
if (title) {
|
|
3953
|
+
lines.push(chalk2.bold(`
|
|
3954
|
+
\u{1F4CB} ${title}`));
|
|
3955
|
+
lines.push("");
|
|
3956
|
+
} else {
|
|
3957
|
+
lines.push("");
|
|
3958
|
+
}
|
|
3715
3959
|
providers.forEach((p, index) => {
|
|
3716
3960
|
const isCurrent = p.id === currentId;
|
|
3717
3961
|
const marker = isCurrent ? chalk2.green("\u25CF") : chalk2.gray("\u25CB");
|
|
3718
3962
|
const name = isCurrent ? chalk2.green.bold(p.name) : chalk2.white(p.name);
|
|
3719
3963
|
const tag = isCurrent ? chalk2.green(" [\u5F53\u524D]") : "";
|
|
3720
3964
|
lines.push(` ${marker} ${name}${tag}`);
|
|
3721
|
-
const
|
|
3965
|
+
const urlText = p.baseUrl || "(\u9ED8\u8BA4\u7AEF\u70B9)";
|
|
3966
|
+
const url = isCurrent ? chalk2.green(urlText) : chalk2.gray(urlText);
|
|
3722
3967
|
lines.push(` ${url}`);
|
|
3723
3968
|
if (p.desc) {
|
|
3724
3969
|
const desc = isCurrent ? chalk2.green(p.desc) : chalk2.gray(p.desc);
|
|
@@ -3734,6 +3979,64 @@ function formatProviderTable(providers, currentId) {
|
|
|
3734
3979
|
|
|
3735
3980
|
// src/interactive.ts
|
|
3736
3981
|
init_confirm();
|
|
3982
|
+
|
|
3983
|
+
// src/utils/cli-theme.ts
|
|
3984
|
+
import chalk3 from "chalk";
|
|
3985
|
+
var TOOL_COLORS = {
|
|
3986
|
+
codex: chalk3.hex("#10A37F"),
|
|
3987
|
+
// OpenAI 绿
|
|
3988
|
+
claude: chalk3.hex("#D97706"),
|
|
3989
|
+
// Anthropic 橙
|
|
3990
|
+
gemini: chalk3.hex("#4285F4"),
|
|
3991
|
+
// Google 蓝
|
|
3992
|
+
opencode: chalk3.hex("#FF6B35"),
|
|
3993
|
+
// 活力橙
|
|
3994
|
+
openclaw: chalk3.hex("#E74C3C"),
|
|
3995
|
+
// 红色
|
|
3996
|
+
mcp: chalk3.hex("#9B59B6")
|
|
3997
|
+
// 紫色
|
|
3998
|
+
};
|
|
3999
|
+
var TOOL_NAMES = {
|
|
4000
|
+
codex: "Codex",
|
|
4001
|
+
claude: "Claude Code",
|
|
4002
|
+
gemini: "Gemini CLI",
|
|
4003
|
+
opencode: "OpenCode",
|
|
4004
|
+
openclaw: "OpenClaw",
|
|
4005
|
+
mcp: "MCP"
|
|
4006
|
+
};
|
|
4007
|
+
function toolBadge(tool) {
|
|
4008
|
+
const color = TOOL_COLORS[tool] || chalk3.blue;
|
|
4009
|
+
const label = TOOL_NAMES[tool] || tool;
|
|
4010
|
+
return color.bold(`[${label}]`);
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
// src/utils/cli-output.ts
|
|
4014
|
+
import chalk4 from "chalk";
|
|
4015
|
+
function printBlock(header, lines = []) {
|
|
4016
|
+
console.log();
|
|
4017
|
+
console.log(header);
|
|
4018
|
+
if (lines.length > 0) {
|
|
4019
|
+
console.log();
|
|
4020
|
+
lines.forEach((line) => console.log(` ${line}`));
|
|
4021
|
+
}
|
|
4022
|
+
console.log();
|
|
4023
|
+
}
|
|
4024
|
+
function printSuccess(title, details = []) {
|
|
4025
|
+
printBlock(chalk4.green(`\u2705 ${title}`), details);
|
|
4026
|
+
}
|
|
4027
|
+
function printInfo(title, lines = []) {
|
|
4028
|
+
printBlock(chalk4.bold(title), lines);
|
|
4029
|
+
}
|
|
4030
|
+
function printWarning(message) {
|
|
4031
|
+
console.log(chalk4.yellow(`
|
|
4032
|
+
\u26A0\uFE0F ${message}
|
|
4033
|
+
`));
|
|
4034
|
+
}
|
|
4035
|
+
function printTip(message) {
|
|
4036
|
+
console.log(chalk4.blue("\u{1F4A1} ") + message);
|
|
4037
|
+
}
|
|
4038
|
+
|
|
4039
|
+
// src/interactive.ts
|
|
3737
4040
|
var CLI_TOOL_CONFIG = {
|
|
3738
4041
|
[TOOL_TYPES.CODEX]: { name: "Codex", emoji: "\u{1F536}", cmd: "cx" },
|
|
3739
4042
|
[TOOL_TYPES.CLAUDE]: { name: "Claude", emoji: "\u{1F537}", cmd: "cc" },
|
|
@@ -3756,7 +4059,7 @@ function getManager(tool) {
|
|
|
3756
4059
|
}
|
|
3757
4060
|
}
|
|
3758
4061
|
async function promptProviderForm(defaults) {
|
|
3759
|
-
const answers = await
|
|
4062
|
+
const answers = await inquirer5.prompt([
|
|
3760
4063
|
{
|
|
3761
4064
|
type: "input",
|
|
3762
4065
|
name: "name",
|
|
@@ -3809,7 +4112,7 @@ async function promptProviderForm(defaults) {
|
|
|
3809
4112
|
async function startMainMenu() {
|
|
3810
4113
|
while (true) {
|
|
3811
4114
|
console.log();
|
|
3812
|
-
const { choice } = await
|
|
4115
|
+
const { choice } = await inquirer5.prompt([
|
|
3813
4116
|
{
|
|
3814
4117
|
type: "list",
|
|
3815
4118
|
name: "choice",
|
|
@@ -3827,7 +4130,7 @@ async function startMainMenu() {
|
|
|
3827
4130
|
}
|
|
3828
4131
|
]);
|
|
3829
4132
|
if (choice === "exit") {
|
|
3830
|
-
console.log(
|
|
4133
|
+
console.log(chalk13.gray("\n\u{1F44B} \u518D\u89C1!\n"));
|
|
3831
4134
|
break;
|
|
3832
4135
|
}
|
|
3833
4136
|
if (choice === "claude") {
|
|
@@ -3864,14 +4167,14 @@ async function startOpenClawMenu() {
|
|
|
3864
4167
|
await showToolMenu(TOOL_TYPES.OPENCLAW);
|
|
3865
4168
|
}
|
|
3866
4169
|
async function showToolMenu(tool) {
|
|
3867
|
-
const { name:
|
|
4170
|
+
const { name: toolDisplayName, emoji } = CLI_TOOL_CONFIG[tool];
|
|
3868
4171
|
while (true) {
|
|
3869
4172
|
console.log();
|
|
3870
|
-
const { action } = await
|
|
4173
|
+
const { action } = await inquirer5.prompt([
|
|
3871
4174
|
{
|
|
3872
4175
|
type: "list",
|
|
3873
4176
|
name: "action",
|
|
3874
|
-
message: `${
|
|
4177
|
+
message: `${emoji} ${toolDisplayName} \u64CD\u4F5C:`,
|
|
3875
4178
|
choices: [
|
|
3876
4179
|
{ name: "\u2795 \u6DFB\u52A0\u670D\u52A1\u5546", value: "add" },
|
|
3877
4180
|
{ name: "\u{1F504} \u5207\u6362\u670D\u52A1\u5546", value: "switch" },
|
|
@@ -3912,11 +4215,11 @@ async function showToolMenu(tool) {
|
|
|
3912
4215
|
break;
|
|
3913
4216
|
}
|
|
3914
4217
|
} catch (error) {
|
|
3915
|
-
console.error(
|
|
4218
|
+
console.error(chalk13.red(`
|
|
3916
4219
|
\u274C ${error.message}
|
|
3917
4220
|
`));
|
|
3918
4221
|
}
|
|
3919
|
-
await
|
|
4222
|
+
await inquirer5.prompt([
|
|
3920
4223
|
{
|
|
3921
4224
|
type: "input",
|
|
3922
4225
|
name: "continue",
|
|
@@ -3926,16 +4229,16 @@ async function showToolMenu(tool) {
|
|
|
3926
4229
|
}
|
|
3927
4230
|
}
|
|
3928
4231
|
async function showPresetsMenu() {
|
|
3929
|
-
console.log(
|
|
4232
|
+
console.log(chalk13.yellow("\n\u26A0\uFE0F \u9884\u7F6E\u670D\u52A1\u5546\u7BA1\u7406\u529F\u80FD\u5373\u5C06\u63A8\u51FA\n"));
|
|
3930
4233
|
}
|
|
3931
4234
|
async function handleAdd(tool) {
|
|
3932
4235
|
const manager = getManager(tool);
|
|
3933
|
-
const { name: toolName, cmd } = CLI_TOOL_CONFIG[tool];
|
|
3934
4236
|
const presets = manager.listPresets();
|
|
3935
|
-
|
|
4237
|
+
const { name: toolName, cmd } = CLI_TOOL_CONFIG[tool];
|
|
4238
|
+
console.log(chalk13.bold(`
|
|
3936
4239
|
\u{1F4DD} \u6DFB\u52A0 ${toolName} \u670D\u52A1\u5546
|
|
3937
4240
|
`));
|
|
3938
|
-
const { usePreset } = await
|
|
4241
|
+
const { usePreset } = await inquirer5.prompt([
|
|
3939
4242
|
{
|
|
3940
4243
|
type: "list",
|
|
3941
4244
|
name: "usePreset",
|
|
@@ -3951,7 +4254,7 @@ async function handleAdd(tool) {
|
|
|
3951
4254
|
let baseUrl;
|
|
3952
4255
|
let apiKey;
|
|
3953
4256
|
if (usePreset) {
|
|
3954
|
-
const { presetName } = await
|
|
4257
|
+
const { presetName } = await inquirer5.prompt([
|
|
3955
4258
|
{
|
|
3956
4259
|
type: "list",
|
|
3957
4260
|
name: "presetName",
|
|
@@ -3963,7 +4266,7 @@ async function handleAdd(tool) {
|
|
|
3963
4266
|
}
|
|
3964
4267
|
]);
|
|
3965
4268
|
const preset = presets.find((p) => p.name === presetName);
|
|
3966
|
-
console.log(
|
|
4269
|
+
console.log(chalk13.blue(`
|
|
3967
4270
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
3968
4271
|
`));
|
|
3969
4272
|
const input = await promptProviderForm({
|
|
@@ -3977,7 +4280,7 @@ async function handleAdd(tool) {
|
|
|
3977
4280
|
baseUrl = input.baseUrl;
|
|
3978
4281
|
apiKey = input.apiKey;
|
|
3979
4282
|
} else {
|
|
3980
|
-
const answers = await
|
|
4283
|
+
const answers = await inquirer5.prompt([
|
|
3981
4284
|
{
|
|
3982
4285
|
type: "input",
|
|
3983
4286
|
name: "name",
|
|
@@ -4010,19 +4313,16 @@ async function handleAdd(tool) {
|
|
|
4010
4313
|
apiKey = answers.apiKey;
|
|
4011
4314
|
}
|
|
4012
4315
|
const provider = manager.add({ name, desc, baseUrl, apiKey });
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
console.log(` ${chalk11.gray(provider.baseUrl)}`);
|
|
4018
|
-
console.log();
|
|
4316
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
4317
|
+
`${chalk13.bold(provider.name)} ${toolBadge(tool)}`,
|
|
4318
|
+
chalk13.gray(provider.baseUrl)
|
|
4319
|
+
]);
|
|
4019
4320
|
const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
|
|
4020
4321
|
if (switchNow) {
|
|
4021
4322
|
manager.switch(provider.id);
|
|
4022
|
-
|
|
4323
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546");
|
|
4023
4324
|
} else {
|
|
4024
|
-
|
|
4025
|
-
`));
|
|
4325
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk13.white(`ccman ${cmd} use "${provider.name}"`)}`);
|
|
4026
4326
|
}
|
|
4027
4327
|
}
|
|
4028
4328
|
async function handleSwitch(tool) {
|
|
@@ -4030,70 +4330,66 @@ async function handleSwitch(tool) {
|
|
|
4030
4330
|
const providers = manager.list();
|
|
4031
4331
|
const current = manager.getCurrent();
|
|
4032
4332
|
if (providers.length === 0) {
|
|
4033
|
-
|
|
4333
|
+
printWarning("\u6682\u65E0\u670D\u52A1\u5546");
|
|
4034
4334
|
return;
|
|
4035
4335
|
}
|
|
4036
|
-
const { providerId } = await
|
|
4336
|
+
const { providerId } = await inquirer5.prompt([
|
|
4037
4337
|
{
|
|
4038
4338
|
type: "list",
|
|
4039
4339
|
name: "providerId",
|
|
4040
4340
|
message: "\u9009\u62E9\u8981\u5207\u6362\u7684\u670D\u52A1\u5546:",
|
|
4041
4341
|
choices: providers.map((p) => ({
|
|
4042
|
-
name: `${p.name}${current?.id === p.id ?
|
|
4342
|
+
name: `${p.name}${current?.id === p.id ? chalk13.green(" (\u5F53\u524D)") : ""}`,
|
|
4043
4343
|
value: p.id
|
|
4044
4344
|
}))
|
|
4045
4345
|
}
|
|
4046
4346
|
]);
|
|
4047
4347
|
manager.switch(providerId);
|
|
4048
4348
|
const provider = providers.find((p) => p.id === providerId);
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4349
|
+
printSuccess("\u5207\u6362\u6210\u529F", [
|
|
4350
|
+
`${chalk13.bold(provider.name)} ${toolBadge(tool)}`,
|
|
4351
|
+
chalk13.gray(provider.baseUrl)
|
|
4352
|
+
]);
|
|
4052
4353
|
}
|
|
4053
4354
|
async function handleList(tool) {
|
|
4054
4355
|
const manager = getManager(tool);
|
|
4055
4356
|
const providers = manager.list();
|
|
4056
4357
|
const current = manager.getCurrent();
|
|
4057
|
-
const { name:
|
|
4358
|
+
const { name: tn, cmd } = CLI_TOOL_CONFIG[tool];
|
|
4058
4359
|
if (providers.length === 0) {
|
|
4059
|
-
|
|
4060
|
-
\
|
|
4061
|
-
`));
|
|
4360
|
+
printWarning(`\u6682\u65E0 ${tn} \u670D\u52A1\u5546`);
|
|
4361
|
+
printTip(`\u6DFB\u52A0\u670D\u52A1\u5546: ${chalk13.white(`ccman ${cmd} add`)}`);
|
|
4062
4362
|
return;
|
|
4063
4363
|
}
|
|
4064
|
-
console.log(
|
|
4065
|
-
\u{1F4CB} ${toolName} \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
|
|
4066
|
-
console.log(formatProviderTable(providers, current?.id));
|
|
4364
|
+
console.log(formatProviderTable(providers, current?.id, `${tn} \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
|
|
4067
4365
|
}
|
|
4068
4366
|
async function handleCurrent(tool) {
|
|
4069
4367
|
const manager = getManager(tool);
|
|
4070
4368
|
const current = manager.getCurrent();
|
|
4071
|
-
const { name:
|
|
4369
|
+
const { name: tn, cmd } = CLI_TOOL_CONFIG[tool];
|
|
4072
4370
|
if (!current) {
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
`));
|
|
4371
|
+
printWarning(`\u672A\u9009\u62E9\u4EFB\u4F55 ${tn} \u670D\u52A1\u5546`);
|
|
4372
|
+
printTip(`\u9009\u62E9\u670D\u52A1\u5546: ${chalk13.white(`ccman ${cmd} use`)}`);
|
|
4076
4373
|
return;
|
|
4077
4374
|
}
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
`)
|
|
4081
|
-
|
|
4082
|
-
|
|
4375
|
+
const lines = [
|
|
4376
|
+
chalk13.green.bold(current.name),
|
|
4377
|
+
chalk13.gray(`ID: ${current.id}`),
|
|
4378
|
+
chalk13.gray(`URL: ${current.baseUrl || "(\u9ED8\u8BA4\u7AEF\u70B9)"}`)
|
|
4379
|
+
];
|
|
4083
4380
|
if (current.lastUsedAt) {
|
|
4084
|
-
|
|
4085
|
-
console.log(` ${chalk11.gray(`\u6700\u540E\u4F7F\u7528: ${date}`)}`);
|
|
4381
|
+
lines.push(chalk13.gray(`\u6700\u540E\u4F7F\u7528: ${new Date(current.lastUsedAt).toLocaleString("zh-CN")}`));
|
|
4086
4382
|
}
|
|
4087
|
-
|
|
4383
|
+
printInfo(`\u{1F4CD} \u5F53\u524D ${tn} \u670D\u52A1\u5546`, lines);
|
|
4088
4384
|
}
|
|
4089
4385
|
async function handleEdit(tool) {
|
|
4090
4386
|
const manager = getManager(tool);
|
|
4091
4387
|
const providers = manager.list();
|
|
4092
4388
|
if (providers.length === 0) {
|
|
4093
|
-
|
|
4389
|
+
printWarning("\u6682\u65E0\u670D\u52A1\u5546");
|
|
4094
4390
|
return;
|
|
4095
4391
|
}
|
|
4096
|
-
const { providerId } = await
|
|
4392
|
+
const { providerId } = await inquirer5.prompt([
|
|
4097
4393
|
{
|
|
4098
4394
|
type: "list",
|
|
4099
4395
|
name: "providerId",
|
|
@@ -4105,7 +4401,7 @@ async function handleEdit(tool) {
|
|
|
4105
4401
|
}
|
|
4106
4402
|
]);
|
|
4107
4403
|
const provider = providers.find((p) => p.id === providerId);
|
|
4108
|
-
const answers = await
|
|
4404
|
+
const answers = await inquirer5.prompt([
|
|
4109
4405
|
{
|
|
4110
4406
|
type: "input",
|
|
4111
4407
|
name: "name",
|
|
@@ -4145,16 +4441,16 @@ async function handleEdit(tool) {
|
|
|
4145
4441
|
baseUrl: answers.baseUrl,
|
|
4146
4442
|
apiKey: answers.apiKey || void 0
|
|
4147
4443
|
});
|
|
4148
|
-
|
|
4444
|
+
printSuccess("\u7F16\u8F91\u6210\u529F");
|
|
4149
4445
|
}
|
|
4150
4446
|
async function handleClone(tool) {
|
|
4151
4447
|
const manager = getManager(tool);
|
|
4152
4448
|
const providers = manager.list();
|
|
4153
4449
|
if (providers.length === 0) {
|
|
4154
|
-
|
|
4450
|
+
printWarning("\u6682\u65E0\u670D\u52A1\u5546");
|
|
4155
4451
|
return;
|
|
4156
4452
|
}
|
|
4157
|
-
const { providerId } = await
|
|
4453
|
+
const { providerId } = await inquirer5.prompt([
|
|
4158
4454
|
{
|
|
4159
4455
|
type: "list",
|
|
4160
4456
|
name: "providerId",
|
|
@@ -4166,7 +4462,7 @@ async function handleClone(tool) {
|
|
|
4166
4462
|
}
|
|
4167
4463
|
]);
|
|
4168
4464
|
const provider = providers.find((p) => p.id === providerId);
|
|
4169
|
-
const answers = await
|
|
4465
|
+
const answers = await inquirer5.prompt([
|
|
4170
4466
|
{
|
|
4171
4467
|
type: "input",
|
|
4172
4468
|
name: "name",
|
|
@@ -4189,19 +4485,16 @@ async function handleClone(tool) {
|
|
|
4189
4485
|
baseUrl: provider.baseUrl,
|
|
4190
4486
|
apiKey: answers.apiKey
|
|
4191
4487
|
});
|
|
4192
|
-
|
|
4193
|
-
console.log(` ${chalk11.bold(newProvider.name)}`);
|
|
4194
|
-
console.log(` ${chalk11.gray(newProvider.baseUrl)}`);
|
|
4195
|
-
console.log();
|
|
4488
|
+
printSuccess("\u514B\u9686\u6210\u529F", [chalk13.bold(newProvider.name), chalk13.gray(newProvider.baseUrl)]);
|
|
4196
4489
|
}
|
|
4197
4490
|
async function handleRemove(tool) {
|
|
4198
4491
|
const manager = getManager(tool);
|
|
4199
4492
|
const providers = manager.list();
|
|
4200
4493
|
if (providers.length === 0) {
|
|
4201
|
-
|
|
4494
|
+
printWarning("\u6682\u65E0\u670D\u52A1\u5546");
|
|
4202
4495
|
return;
|
|
4203
4496
|
}
|
|
4204
|
-
const { providerId } = await
|
|
4497
|
+
const { providerId } = await inquirer5.prompt([
|
|
4205
4498
|
{
|
|
4206
4499
|
type: "list",
|
|
4207
4500
|
name: "providerId",
|
|
@@ -4216,38 +4509,169 @@ async function handleRemove(tool) {
|
|
|
4216
4509
|
const confirm = await promptConfirm(`\u786E\u5B9A\u8981\u5220\u9664 "${provider.name}" \u5417?`, false);
|
|
4217
4510
|
if (confirm) {
|
|
4218
4511
|
manager.remove(providerId);
|
|
4219
|
-
|
|
4220
|
-
\u2705 \u5DF2\u5220\u9664: ${provider.name}
|
|
4221
|
-
`));
|
|
4512
|
+
printSuccess(`\u5DF2\u5220\u9664: ${provider.name}`);
|
|
4222
4513
|
} else {
|
|
4223
|
-
console.log(
|
|
4514
|
+
console.log(chalk13.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
4224
4515
|
}
|
|
4225
4516
|
}
|
|
4226
4517
|
|
|
4227
4518
|
// src/commands/codex/add.ts
|
|
4228
4519
|
init_confirm();
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4520
|
+
|
|
4521
|
+
// src/utils/provider-params.ts
|
|
4522
|
+
init_confirm();
|
|
4523
|
+
function trimCliValue(value) {
|
|
4524
|
+
if (value === void 0) {
|
|
4525
|
+
return void 0;
|
|
4526
|
+
}
|
|
4527
|
+
return value.trim();
|
|
4528
|
+
}
|
|
4529
|
+
function validateBaseUrl(baseUrl, allowEmpty = false) {
|
|
4530
|
+
if (!baseUrl) {
|
|
4531
|
+
if (allowEmpty) {
|
|
4532
|
+
return;
|
|
4533
|
+
}
|
|
4534
|
+
throw new Error("\u7F3A\u5C11\u53C2\u6570: --base-url");
|
|
4535
|
+
}
|
|
4536
|
+
if (!baseUrl.startsWith("http://") && !baseUrl.startsWith("https://")) {
|
|
4537
|
+
throw new Error("API \u5730\u5740\u5FC5\u987B\u4EE5 http:// \u6216 https:// \u5F00\u5934");
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
function validateApiKey(apiKey, allowEmpty = false) {
|
|
4541
|
+
if (!apiKey && !allowEmpty) {
|
|
4542
|
+
throw new Error("\u7F3A\u5C11\u53C2\u6570: --api-key");
|
|
4543
|
+
}
|
|
4544
|
+
}
|
|
4545
|
+
function resolvePreset(presets, presetName) {
|
|
4546
|
+
const normalizedName = trimCliValue(presetName);
|
|
4547
|
+
if (!normalizedName) {
|
|
4548
|
+
return void 0;
|
|
4549
|
+
}
|
|
4550
|
+
const preset = presets.find((item) => item.name.toLowerCase() === normalizedName.toLowerCase());
|
|
4551
|
+
if (!preset) {
|
|
4552
|
+
throw new Error(`\u9884\u8BBE\u4E0D\u5B58\u5728: ${normalizedName}`);
|
|
4553
|
+
}
|
|
4554
|
+
return preset;
|
|
4555
|
+
}
|
|
4556
|
+
function addProviderAddOptions(command) {
|
|
4557
|
+
command.option("--preset <name>", "\u4F7F\u7528\u6307\u5B9A\u9884\u8BBE").option("--name <name>", "\u670D\u52A1\u5546\u540D\u79F0").option("--desc <desc>", "\u63CF\u8FF0").option("--base-url <url>", "API \u5730\u5740").option("--api-key <key>", "API \u5BC6\u94A5").option("--switch", "\u6DFB\u52A0\u540E\u7ACB\u5373\u5207\u6362").option("--skip-switch", "\u6DFB\u52A0\u540E\u4E0D\u5207\u6362");
|
|
4558
|
+
}
|
|
4559
|
+
function addProviderEditOptions(command) {
|
|
4560
|
+
command.option("--new-name <name>", "\u65B0\u7684\u670D\u52A1\u5546\u540D\u79F0").option("--desc <desc>", "\u65B0\u7684\u63CF\u8FF0\uFF1B\u4F20\u7A7A\u5B57\u7B26\u4E32\u53EF\u6E05\u7A7A").option("--base-url <url>", "\u65B0\u7684 API \u5730\u5740").option("--api-key <key>", "\u65B0\u7684 API \u5BC6\u94A5");
|
|
4561
|
+
}
|
|
4562
|
+
function addProviderRemoveOptions(command) {
|
|
4563
|
+
command.option("-y, --yes", "\u8DF3\u8FC7\u5220\u9664\u786E\u8BA4");
|
|
4564
|
+
}
|
|
4565
|
+
function resolveProviderAddInput(options, presets, rules = {}) {
|
|
4566
|
+
if (options.switch && options.skipSwitch) {
|
|
4567
|
+
throw new Error("\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528 --switch \u548C --skip-switch");
|
|
4568
|
+
}
|
|
4569
|
+
const nonInteractive = options.preset !== void 0 || options.name !== void 0 || options.desc !== void 0 || options.baseUrl !== void 0 || options.apiKey !== void 0 || options.switch === true || options.skipSwitch === true;
|
|
4570
|
+
if (!nonInteractive) {
|
|
4571
|
+
return {
|
|
4572
|
+
nonInteractive: false,
|
|
4573
|
+
switchNow: false
|
|
4574
|
+
};
|
|
4575
|
+
}
|
|
4576
|
+
const preset = resolvePreset(presets, options.preset);
|
|
4577
|
+
const name = trimCliValue(options.name) ?? preset?.name;
|
|
4578
|
+
const desc = options.desc === void 0 ? void 0 : options.desc.trim() || void 0;
|
|
4579
|
+
const baseUrl = trimCliValue(options.baseUrl) ?? preset?.baseUrl ?? "";
|
|
4580
|
+
const apiKey = options.apiKey === void 0 ? "" : options.apiKey.trim();
|
|
4581
|
+
if (!name) {
|
|
4582
|
+
throw new Error("\u7F3A\u5C11\u53C2\u6570: --name");
|
|
4583
|
+
}
|
|
4584
|
+
validateBaseUrl(baseUrl, rules.allowEmptyBaseUrl);
|
|
4585
|
+
validateApiKey(apiKey, rules.allowEmptyApiKey);
|
|
4586
|
+
return {
|
|
4587
|
+
nonInteractive: true,
|
|
4588
|
+
switchNow: options.switch === true,
|
|
4589
|
+
input: {
|
|
4590
|
+
name,
|
|
4591
|
+
desc,
|
|
4592
|
+
baseUrl,
|
|
4593
|
+
apiKey
|
|
4594
|
+
}
|
|
4595
|
+
};
|
|
4596
|
+
}
|
|
4597
|
+
function resolveProviderEditInput(options, rules = {}) {
|
|
4598
|
+
const nonInteractive = options.newName !== void 0 || options.desc !== void 0 || options.baseUrl !== void 0 || options.apiKey !== void 0;
|
|
4599
|
+
const updates = {};
|
|
4600
|
+
if (options.newName !== void 0) {
|
|
4601
|
+
const newName = trimCliValue(options.newName);
|
|
4602
|
+
if (!newName) {
|
|
4603
|
+
throw new Error("\u670D\u52A1\u5546\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");
|
|
4604
|
+
}
|
|
4605
|
+
updates.name = newName;
|
|
4606
|
+
}
|
|
4607
|
+
if (options.desc !== void 0) {
|
|
4608
|
+
updates.desc = options.desc.trim();
|
|
4609
|
+
}
|
|
4610
|
+
if (options.baseUrl !== void 0) {
|
|
4611
|
+
const baseUrl = trimCliValue(options.baseUrl) ?? "";
|
|
4612
|
+
validateBaseUrl(baseUrl, rules.allowEmptyBaseUrl);
|
|
4613
|
+
updates.baseUrl = baseUrl;
|
|
4614
|
+
}
|
|
4615
|
+
if (options.apiKey !== void 0) {
|
|
4616
|
+
const apiKey = options.apiKey.trim();
|
|
4617
|
+
validateApiKey(apiKey, rules.allowEmptyApiKey);
|
|
4618
|
+
updates.apiKey = apiKey;
|
|
4619
|
+
}
|
|
4620
|
+
return {
|
|
4621
|
+
nonInteractive,
|
|
4622
|
+
updates
|
|
4623
|
+
};
|
|
4624
|
+
}
|
|
4625
|
+
async function confirmProviderRemoval(providerName, options = {}) {
|
|
4626
|
+
if (options.yes) {
|
|
4627
|
+
return true;
|
|
4628
|
+
}
|
|
4629
|
+
return promptConfirm(`\u786E\u5B9A\u5220\u9664 "${providerName}"?`, false);
|
|
4630
|
+
}
|
|
4631
|
+
|
|
4632
|
+
// src/commands/codex/add.ts
|
|
4633
|
+
function addCommand(program2) {
|
|
4634
|
+
const command = program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Codex \u670D\u52A1\u5546");
|
|
4635
|
+
addProviderAddOptions(command);
|
|
4636
|
+
command.action(async (options) => {
|
|
4637
|
+
try {
|
|
4638
|
+
const manager = createCodexManager();
|
|
4639
|
+
console.log(chalk14.bold("\n\u{1F4DD} \u6DFB\u52A0 Codex \u670D\u52A1\u5546\n"));
|
|
4640
|
+
const resolved = resolveProviderAddInput(options, CODEX_PRESETS);
|
|
4641
|
+
if (resolved.nonInteractive && resolved.input) {
|
|
4642
|
+
const provider2 = manager.add(resolved.input);
|
|
4643
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
4644
|
+
`${chalk14.bold(provider2.name)} ${toolBadge("codex")}`,
|
|
4645
|
+
chalk14.gray(provider2.baseUrl)
|
|
4646
|
+
]);
|
|
4647
|
+
if (resolved.switchNow) {
|
|
4648
|
+
manager.switch(provider2.id);
|
|
4649
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [
|
|
4650
|
+
chalk14.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getCodexConfigPath()}`),
|
|
4651
|
+
chalk14.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getCodexAuthPath()}`)
|
|
4652
|
+
]);
|
|
4653
|
+
} else {
|
|
4654
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk14.white(`ccman cx use "${provider2.name}"`)}`);
|
|
4655
|
+
}
|
|
4656
|
+
return;
|
|
4657
|
+
}
|
|
4658
|
+
const { usePreset } = await inquirer6.prompt([
|
|
4659
|
+
{
|
|
4660
|
+
type: "list",
|
|
4661
|
+
name: "usePreset",
|
|
4662
|
+
message: "\u9009\u62E9\u914D\u7F6E\u6765\u6E90:",
|
|
4663
|
+
choices: [
|
|
4664
|
+
{ name: "\u{1F4E6} \u4F7F\u7528\u9884\u7F6E\u670D\u52A1\u5546", value: true },
|
|
4665
|
+
{ name: "\u270F\uFE0F \u81EA\u5B9A\u4E49\u914D\u7F6E", value: false }
|
|
4666
|
+
]
|
|
4667
|
+
}
|
|
4668
|
+
]);
|
|
4245
4669
|
let name;
|
|
4246
4670
|
let desc;
|
|
4247
4671
|
let baseUrl;
|
|
4248
4672
|
let apiKey;
|
|
4249
4673
|
if (usePreset) {
|
|
4250
|
-
const { presetName } = await
|
|
4674
|
+
const { presetName } = await inquirer6.prompt([
|
|
4251
4675
|
{
|
|
4252
4676
|
type: "list",
|
|
4253
4677
|
name: "presetName",
|
|
@@ -4259,7 +4683,7 @@ function addCommand(program2) {
|
|
|
4259
4683
|
}
|
|
4260
4684
|
]);
|
|
4261
4685
|
const preset = CODEX_PRESETS.find((p) => p.name === presetName);
|
|
4262
|
-
console.log(
|
|
4686
|
+
console.log(chalk14.blue(`
|
|
4263
4687
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
4264
4688
|
`));
|
|
4265
4689
|
const input = await promptProviderForm({
|
|
@@ -4273,7 +4697,7 @@ function addCommand(program2) {
|
|
|
4273
4697
|
baseUrl = input.baseUrl;
|
|
4274
4698
|
apiKey = input.apiKey;
|
|
4275
4699
|
} else {
|
|
4276
|
-
const answers = await
|
|
4700
|
+
const answers = await inquirer6.prompt([
|
|
4277
4701
|
{
|
|
4278
4702
|
type: "input",
|
|
4279
4703
|
name: "name",
|
|
@@ -4312,25 +4736,22 @@ function addCommand(program2) {
|
|
|
4312
4736
|
apiKey = answers.apiKey;
|
|
4313
4737
|
}
|
|
4314
4738
|
const provider = manager.add({ name, desc, baseUrl, apiKey });
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
console.log(` ${chalk12.gray(provider.baseUrl)}`);
|
|
4320
|
-
console.log();
|
|
4739
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
4740
|
+
`${chalk14.bold(provider.name)} ${toolBadge("codex")}`,
|
|
4741
|
+
chalk14.gray(provider.baseUrl)
|
|
4742
|
+
]);
|
|
4321
4743
|
const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
|
|
4322
4744
|
if (switchNow) {
|
|
4323
4745
|
manager.switch(provider.id);
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
console.log(chalk12.gray(` - ${getCodexAuthPath()}`));
|
|
4746
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [
|
|
4747
|
+
chalk14.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getCodexConfigPath()}`),
|
|
4748
|
+
chalk14.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getCodexAuthPath()}`)
|
|
4749
|
+
]);
|
|
4329
4750
|
} else {
|
|
4330
|
-
|
|
4751
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk14.white(`ccman cx use "${provider.name}"`)}`);
|
|
4331
4752
|
}
|
|
4332
4753
|
} catch (error) {
|
|
4333
|
-
console.error(
|
|
4754
|
+
console.error(chalk14.red(`
|
|
4334
4755
|
\u274C ${error.message}
|
|
4335
4756
|
`));
|
|
4336
4757
|
process.exit(1);
|
|
@@ -4340,7 +4761,7 @@ function addCommand(program2) {
|
|
|
4340
4761
|
|
|
4341
4762
|
// src/commands/codex/list.ts
|
|
4342
4763
|
init_dist2();
|
|
4343
|
-
import
|
|
4764
|
+
import chalk15 from "chalk";
|
|
4344
4765
|
function listCommand(program2) {
|
|
4345
4766
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 Codex \u670D\u52A1\u5546").action(async () => {
|
|
4346
4767
|
try {
|
|
@@ -4348,15 +4769,15 @@ function listCommand(program2) {
|
|
|
4348
4769
|
const providers = manager.list();
|
|
4349
4770
|
const current = manager.getCurrent();
|
|
4350
4771
|
if (providers.length === 0) {
|
|
4351
|
-
|
|
4352
|
-
|
|
4772
|
+
printWarning("\u6682\u65E0 Codex \u670D\u52A1\u5546");
|
|
4773
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk15.white("ccman cx add"));
|
|
4353
4774
|
return;
|
|
4354
4775
|
}
|
|
4355
|
-
console.log(
|
|
4356
|
-
|
|
4357
|
-
|
|
4776
|
+
console.log(
|
|
4777
|
+
formatProviderTable(providers, current?.id, `Codex \u670D\u52A1\u5546 (${providers.length} \u4E2A)`)
|
|
4778
|
+
);
|
|
4358
4779
|
} catch (error) {
|
|
4359
|
-
console.error(
|
|
4780
|
+
console.error(chalk15.red(`
|
|
4360
4781
|
\u274C ${error.message}
|
|
4361
4782
|
`));
|
|
4362
4783
|
process.exit(1);
|
|
@@ -4366,16 +4787,16 @@ function listCommand(program2) {
|
|
|
4366
4787
|
|
|
4367
4788
|
// src/commands/codex/use.ts
|
|
4368
4789
|
init_dist2();
|
|
4369
|
-
import
|
|
4370
|
-
import
|
|
4790
|
+
import chalk16 from "chalk";
|
|
4791
|
+
import inquirer7 from "inquirer";
|
|
4371
4792
|
function useCommand(program2) {
|
|
4372
4793
|
program2.command("use [name]").description("\u5207\u6362 Codex \u670D\u52A1\u5546").action(async (name) => {
|
|
4373
4794
|
try {
|
|
4374
4795
|
const manager = createCodexManager();
|
|
4375
4796
|
const providers = manager.list();
|
|
4376
4797
|
if (providers.length === 0) {
|
|
4377
|
-
|
|
4378
|
-
|
|
4798
|
+
printWarning("\u6682\u65E0 Codex \u670D\u52A1\u5546");
|
|
4799
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk16.white("ccman cx add"));
|
|
4379
4800
|
return;
|
|
4380
4801
|
}
|
|
4381
4802
|
let targetId;
|
|
@@ -4386,7 +4807,7 @@ function useCommand(program2) {
|
|
|
4386
4807
|
}
|
|
4387
4808
|
targetId = provider2.id;
|
|
4388
4809
|
} else {
|
|
4389
|
-
const { selectedId } = await
|
|
4810
|
+
const { selectedId } = await inquirer7.prompt([
|
|
4390
4811
|
{
|
|
4391
4812
|
type: "list",
|
|
4392
4813
|
name: "selectedId",
|
|
@@ -4401,24 +4822,20 @@ function useCommand(program2) {
|
|
|
4401
4822
|
}
|
|
4402
4823
|
manager.switch(targetId);
|
|
4403
4824
|
const provider = manager.get(targetId);
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
console.log(chalk14.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
4411
|
-
console.log(chalk14.gray(` - ${getCodexConfigPath()}`));
|
|
4412
|
-
console.log(chalk14.gray(` - ${getCodexAuthPath()}`));
|
|
4413
|
-
console.log();
|
|
4825
|
+
printSuccess("\u5207\u6362\u6210\u529F", [
|
|
4826
|
+
`${chalk16.bold(provider.name)} ${toolBadge("codex")}`,
|
|
4827
|
+
chalk16.gray(`URL: ${provider.baseUrl}`),
|
|
4828
|
+
chalk16.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getCodexConfigPath()}`),
|
|
4829
|
+
chalk16.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getCodexAuthPath()}`)
|
|
4830
|
+
]);
|
|
4414
4831
|
} catch (error) {
|
|
4415
4832
|
if (error instanceof ProviderNotFoundError) {
|
|
4416
|
-
console.error(
|
|
4833
|
+
console.error(chalk16.red(`
|
|
4417
4834
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${error.message}
|
|
4418
4835
|
`));
|
|
4419
|
-
console.log(
|
|
4836
|
+
console.log(chalk16.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + chalk16.white(" ccman cx list\n"));
|
|
4420
4837
|
} else {
|
|
4421
|
-
console.error(
|
|
4838
|
+
console.error(chalk16.red(`
|
|
4422
4839
|
\u274C ${error.message}
|
|
4423
4840
|
`));
|
|
4424
4841
|
}
|
|
@@ -4429,28 +4846,30 @@ function useCommand(program2) {
|
|
|
4429
4846
|
|
|
4430
4847
|
// src/commands/codex/current.ts
|
|
4431
4848
|
init_dist2();
|
|
4432
|
-
import
|
|
4849
|
+
import chalk17 from "chalk";
|
|
4433
4850
|
function currentCommand(program2) {
|
|
4434
4851
|
program2.command("current").description("\u663E\u793A\u5F53\u524D\u4F7F\u7528\u7684 Codex \u670D\u52A1\u5546").action(async () => {
|
|
4435
4852
|
try {
|
|
4436
4853
|
const manager = createCodexManager();
|
|
4437
4854
|
const current = manager.getCurrent();
|
|
4438
4855
|
if (!current) {
|
|
4439
|
-
|
|
4440
|
-
|
|
4856
|
+
printWarning("\u672A\u9009\u62E9\u4EFB\u4F55 Codex \u670D\u52A1\u5546");
|
|
4857
|
+
printTip("\u9009\u62E9\u670D\u52A1\u5546: " + chalk17.white("ccman cx use"));
|
|
4441
4858
|
return;
|
|
4442
4859
|
}
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4860
|
+
const lines = [
|
|
4861
|
+
chalk17.green.bold(current.name),
|
|
4862
|
+
chalk17.gray(`ID: ${current.id}`),
|
|
4863
|
+
chalk17.gray(`URL: ${current.baseUrl}`)
|
|
4864
|
+
];
|
|
4447
4865
|
if (current.lastUsedAt) {
|
|
4448
|
-
|
|
4449
|
-
|
|
4866
|
+
lines.push(
|
|
4867
|
+
chalk17.gray(`\u6700\u540E\u4F7F\u7528: ${new Date(current.lastUsedAt).toLocaleString("zh-CN")}`)
|
|
4868
|
+
);
|
|
4450
4869
|
}
|
|
4451
|
-
|
|
4870
|
+
printInfo("\u{1F4CD} \u5F53\u524D Codex \u670D\u52A1\u5546", lines);
|
|
4452
4871
|
} catch (error) {
|
|
4453
|
-
console.error(
|
|
4872
|
+
console.error(chalk17.red(`
|
|
4454
4873
|
\u274C ${error.message}
|
|
4455
4874
|
`));
|
|
4456
4875
|
process.exit(1);
|
|
@@ -4460,16 +4879,17 @@ function currentCommand(program2) {
|
|
|
4460
4879
|
|
|
4461
4880
|
// src/commands/codex/remove.ts
|
|
4462
4881
|
init_dist2();
|
|
4463
|
-
|
|
4464
|
-
import
|
|
4465
|
-
import inquirer10 from "inquirer";
|
|
4882
|
+
import chalk18 from "chalk";
|
|
4883
|
+
import inquirer8 from "inquirer";
|
|
4466
4884
|
function removeCommand(program2) {
|
|
4467
|
-
program2.command("remove [name]").alias("rm").description("\u5220\u9664 Codex \u670D\u52A1\u5546")
|
|
4885
|
+
const command = program2.command("remove [name]").alias("rm").description("\u5220\u9664 Codex \u670D\u52A1\u5546");
|
|
4886
|
+
addProviderRemoveOptions(command);
|
|
4887
|
+
command.action(async (name, options) => {
|
|
4468
4888
|
try {
|
|
4469
4889
|
const manager = createCodexManager();
|
|
4470
4890
|
const providers = manager.list();
|
|
4471
4891
|
if (providers.length === 0) {
|
|
4472
|
-
console.log(
|
|
4892
|
+
console.log(chalk18.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
4473
4893
|
return;
|
|
4474
4894
|
}
|
|
4475
4895
|
let targetId;
|
|
@@ -4481,8 +4901,10 @@ function removeCommand(program2) {
|
|
|
4481
4901
|
}
|
|
4482
4902
|
targetId = provider.id;
|
|
4483
4903
|
targetName = provider.name;
|
|
4904
|
+
} else if (options.yes) {
|
|
4905
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u5220\u9664\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
4484
4906
|
} else {
|
|
4485
|
-
const { selectedId } = await
|
|
4907
|
+
const { selectedId } = await inquirer8.prompt([
|
|
4486
4908
|
{
|
|
4487
4909
|
type: "list",
|
|
4488
4910
|
name: "selectedId",
|
|
@@ -4497,23 +4919,23 @@ function removeCommand(program2) {
|
|
|
4497
4919
|
targetId = selectedId;
|
|
4498
4920
|
targetName = provider.name;
|
|
4499
4921
|
}
|
|
4500
|
-
const confirmed = await
|
|
4922
|
+
const confirmed = await confirmProviderRemoval(targetName, options);
|
|
4501
4923
|
if (!confirmed) {
|
|
4502
|
-
console.log(
|
|
4924
|
+
console.log(chalk18.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
4503
4925
|
return;
|
|
4504
4926
|
}
|
|
4505
4927
|
manager.remove(targetId);
|
|
4506
4928
|
console.log();
|
|
4507
|
-
console.log(
|
|
4929
|
+
console.log(chalk18.green(`\u2705 \u5DF2\u5220\u9664: ${targetName}`));
|
|
4508
4930
|
console.log();
|
|
4509
4931
|
} catch (error) {
|
|
4510
4932
|
if (error instanceof ProviderNotFoundError) {
|
|
4511
|
-
console.error(
|
|
4933
|
+
console.error(chalk18.red(`
|
|
4512
4934
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728
|
|
4513
4935
|
`));
|
|
4514
|
-
console.log(
|
|
4936
|
+
console.log(chalk18.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + chalk18.white(" ccman cx list\n"));
|
|
4515
4937
|
} else {
|
|
4516
|
-
console.error(
|
|
4938
|
+
console.error(chalk18.red(`
|
|
4517
4939
|
\u274C ${error.message}
|
|
4518
4940
|
`));
|
|
4519
4941
|
}
|
|
@@ -4524,17 +4946,20 @@ function removeCommand(program2) {
|
|
|
4524
4946
|
|
|
4525
4947
|
// src/commands/codex/edit.ts
|
|
4526
4948
|
init_dist2();
|
|
4527
|
-
import
|
|
4528
|
-
import
|
|
4949
|
+
import chalk19 from "chalk";
|
|
4950
|
+
import inquirer9 from "inquirer";
|
|
4529
4951
|
function editCommand(program2) {
|
|
4530
|
-
program2.command("edit [name]").description("\u7F16\u8F91 Codex \u670D\u52A1\u5546")
|
|
4952
|
+
const command = program2.command("edit [name]").description("\u7F16\u8F91 Codex \u670D\u52A1\u5546");
|
|
4953
|
+
addProviderEditOptions(command);
|
|
4954
|
+
command.action(async (name, options) => {
|
|
4531
4955
|
try {
|
|
4532
4956
|
const manager = createCodexManager();
|
|
4533
4957
|
const providers = manager.list();
|
|
4534
4958
|
if (providers.length === 0) {
|
|
4535
|
-
console.log(
|
|
4959
|
+
console.log(chalk19.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
4536
4960
|
return;
|
|
4537
4961
|
}
|
|
4962
|
+
const resolved = resolveProviderEditInput(options);
|
|
4538
4963
|
let targetId;
|
|
4539
4964
|
if (name) {
|
|
4540
4965
|
const provider2 = manager.findByName(name);
|
|
@@ -4542,8 +4967,10 @@ function editCommand(program2) {
|
|
|
4542
4967
|
throw new ProviderNotFoundError(name);
|
|
4543
4968
|
}
|
|
4544
4969
|
targetId = provider2.id;
|
|
4970
|
+
} else if (resolved.nonInteractive) {
|
|
4971
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u7F16\u8F91\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
4545
4972
|
} else {
|
|
4546
|
-
const { selectedId } = await
|
|
4973
|
+
const { selectedId } = await inquirer9.prompt([
|
|
4547
4974
|
{
|
|
4548
4975
|
type: "list",
|
|
4549
4976
|
name: "selectedId",
|
|
@@ -4557,9 +4984,24 @@ function editCommand(program2) {
|
|
|
4557
4984
|
targetId = selectedId;
|
|
4558
4985
|
}
|
|
4559
4986
|
const provider = manager.get(targetId);
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4987
|
+
if (resolved.nonInteractive) {
|
|
4988
|
+
if (Object.keys(resolved.updates).length === 0) {
|
|
4989
|
+
console.log(chalk19.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
4990
|
+
return;
|
|
4991
|
+
}
|
|
4992
|
+
const updated2 = manager.edit(targetId, resolved.updates);
|
|
4993
|
+
console.log();
|
|
4994
|
+
console.log(chalk19.green("\u2705 \u7F16\u8F91\u6210\u529F"));
|
|
4995
|
+
console.log();
|
|
4996
|
+
console.log(` ${chalk19.bold(updated2.name)} ${chalk19.blue("[Codex]")}`);
|
|
4997
|
+
console.log(` ${chalk19.gray(`ID: ${updated2.id}`)}`);
|
|
4998
|
+
console.log(` ${chalk19.gray(`URL: ${updated2.baseUrl}`)}`);
|
|
4999
|
+
console.log();
|
|
5000
|
+
return;
|
|
5001
|
+
}
|
|
5002
|
+
console.log(chalk19.bold("\n\u270F\uFE0F \u7F16\u8F91\u670D\u52A1\u5546\n"));
|
|
5003
|
+
console.log(chalk19.gray("\u63D0\u793A: \u7559\u7A7A\u5219\u4FDD\u6301\u539F\u503C\n"));
|
|
5004
|
+
const answers = await inquirer9.prompt([
|
|
4563
5005
|
{
|
|
4564
5006
|
type: "input",
|
|
4565
5007
|
name: "name",
|
|
@@ -4590,19 +5032,19 @@ function editCommand(program2) {
|
|
|
4590
5032
|
if (answers.baseUrl && answers.baseUrl !== provider.baseUrl) updates.baseUrl = answers.baseUrl;
|
|
4591
5033
|
if (answers.apiKey) updates.apiKey = answers.apiKey;
|
|
4592
5034
|
if (Object.keys(updates).length === 0) {
|
|
4593
|
-
console.log(
|
|
5035
|
+
console.log(chalk19.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
4594
5036
|
return;
|
|
4595
5037
|
}
|
|
4596
5038
|
const updated = manager.edit(targetId, updates);
|
|
4597
5039
|
console.log();
|
|
4598
|
-
console.log(
|
|
5040
|
+
console.log(chalk19.green("\u2705 \u7F16\u8F91\u6210\u529F"));
|
|
4599
5041
|
console.log();
|
|
4600
|
-
console.log(` ${
|
|
4601
|
-
console.log(` ${
|
|
4602
|
-
console.log(` ${
|
|
5042
|
+
console.log(` ${chalk19.bold(updated.name)} ${chalk19.blue("[Codex]")}`);
|
|
5043
|
+
console.log(` ${chalk19.gray(`ID: ${updated.id}`)}`);
|
|
5044
|
+
console.log(` ${chalk19.gray(`URL: ${updated.baseUrl}`)}`);
|
|
4603
5045
|
console.log();
|
|
4604
5046
|
} catch (error) {
|
|
4605
|
-
console.error(
|
|
5047
|
+
console.error(chalk19.red(`
|
|
4606
5048
|
\u274C ${error.message}
|
|
4607
5049
|
`));
|
|
4608
5050
|
process.exit(1);
|
|
@@ -4612,15 +5054,15 @@ function editCommand(program2) {
|
|
|
4612
5054
|
|
|
4613
5055
|
// src/commands/codex/clone.ts
|
|
4614
5056
|
init_dist2();
|
|
4615
|
-
import
|
|
4616
|
-
import
|
|
5057
|
+
import chalk20 from "chalk";
|
|
5058
|
+
import inquirer10 from "inquirer";
|
|
4617
5059
|
function cloneCommand(program2) {
|
|
4618
5060
|
program2.command("clone [source-name] [new-name]").description("\u514B\u9686 Codex \u670D\u52A1\u5546").action(async (sourceName, newName) => {
|
|
4619
5061
|
try {
|
|
4620
5062
|
const manager = createCodexManager();
|
|
4621
5063
|
const providers = manager.list();
|
|
4622
5064
|
if (providers.length === 0) {
|
|
4623
|
-
console.log(
|
|
5065
|
+
console.log(chalk20.yellow("\n\u26A0\uFE0F \u6682\u65E0 Codex \u670D\u52A1\u5546\n"));
|
|
4624
5066
|
return;
|
|
4625
5067
|
}
|
|
4626
5068
|
let sourceId;
|
|
@@ -4631,7 +5073,7 @@ function cloneCommand(program2) {
|
|
|
4631
5073
|
}
|
|
4632
5074
|
sourceId = provider.id;
|
|
4633
5075
|
} else {
|
|
4634
|
-
const { selectedId } = await
|
|
5076
|
+
const { selectedId } = await inquirer10.prompt([
|
|
4635
5077
|
{
|
|
4636
5078
|
type: "list",
|
|
4637
5079
|
name: "selectedId",
|
|
@@ -4649,7 +5091,7 @@ function cloneCommand(program2) {
|
|
|
4649
5091
|
if (newName) {
|
|
4650
5092
|
cloned = manager.clone(sourceId, newName);
|
|
4651
5093
|
} else {
|
|
4652
|
-
console.log(
|
|
5094
|
+
console.log(chalk20.blue(`
|
|
4653
5095
|
\u514B\u9686\u81EA: ${source.name}
|
|
4654
5096
|
`));
|
|
4655
5097
|
const input = await promptProviderForm({
|
|
@@ -4662,14 +5104,14 @@ function cloneCommand(program2) {
|
|
|
4662
5104
|
cloned = manager.add(input);
|
|
4663
5105
|
}
|
|
4664
5106
|
console.log();
|
|
4665
|
-
console.log(
|
|
5107
|
+
console.log(chalk20.green("\u2705 \u514B\u9686\u6210\u529F"));
|
|
4666
5108
|
console.log();
|
|
4667
|
-
console.log(` ${
|
|
4668
|
-
console.log(` ${
|
|
4669
|
-
console.log(` ${
|
|
5109
|
+
console.log(` ${chalk20.bold(cloned.name)} ${chalk20.blue("[Codex]")}`);
|
|
5110
|
+
console.log(` ${chalk20.gray(`ID: ${cloned.id}`)}`);
|
|
5111
|
+
console.log(` ${chalk20.gray(`URL: ${cloned.baseUrl}`)}`);
|
|
4670
5112
|
console.log();
|
|
4671
5113
|
} catch (error) {
|
|
4672
|
-
console.error(
|
|
5114
|
+
console.error(chalk20.red(`
|
|
4673
5115
|
\u274C ${error.message}
|
|
4674
5116
|
`));
|
|
4675
5117
|
process.exit(1);
|
|
@@ -4690,15 +5132,32 @@ function createCodexCommands(program2) {
|
|
|
4690
5132
|
|
|
4691
5133
|
// src/commands/claude/add.ts
|
|
4692
5134
|
init_dist2();
|
|
4693
|
-
import
|
|
4694
|
-
import
|
|
5135
|
+
import chalk21 from "chalk";
|
|
5136
|
+
import inquirer11 from "inquirer";
|
|
4695
5137
|
init_confirm();
|
|
4696
5138
|
function addCommand2(program2) {
|
|
4697
|
-
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Claude Code \u670D\u52A1\u5546
|
|
5139
|
+
const command = program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Claude Code \u670D\u52A1\u5546");
|
|
5140
|
+
addProviderAddOptions(command);
|
|
5141
|
+
command.action(async (options) => {
|
|
4698
5142
|
try {
|
|
4699
5143
|
const manager = createClaudeManager();
|
|
4700
|
-
console.log(
|
|
4701
|
-
const
|
|
5144
|
+
console.log(chalk21.bold("\n\u{1F4DD} \u6DFB\u52A0 Claude Code \u670D\u52A1\u5546\n"));
|
|
5145
|
+
const resolved = resolveProviderAddInput(options, CC_PRESETS);
|
|
5146
|
+
if (resolved.nonInteractive && resolved.input) {
|
|
5147
|
+
const provider2 = manager.add(resolved.input);
|
|
5148
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
5149
|
+
`${chalk21.bold(provider2.name)} ${toolBadge("claude")}`,
|
|
5150
|
+
chalk21.gray(provider2.baseUrl)
|
|
5151
|
+
]);
|
|
5152
|
+
if (resolved.switchNow) {
|
|
5153
|
+
manager.switch(provider2.id);
|
|
5154
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [chalk21.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getClaudeConfigPath()}`)]);
|
|
5155
|
+
} else {
|
|
5156
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk21.white(`ccman cc use "${provider2.name}"`)}`);
|
|
5157
|
+
}
|
|
5158
|
+
return;
|
|
5159
|
+
}
|
|
5160
|
+
const { usePreset } = await inquirer11.prompt([
|
|
4702
5161
|
{
|
|
4703
5162
|
type: "list",
|
|
4704
5163
|
name: "usePreset",
|
|
@@ -4714,7 +5173,7 @@ function addCommand2(program2) {
|
|
|
4714
5173
|
let baseUrl;
|
|
4715
5174
|
let apiKey;
|
|
4716
5175
|
if (usePreset) {
|
|
4717
|
-
const { presetName } = await
|
|
5176
|
+
const { presetName } = await inquirer11.prompt([
|
|
4718
5177
|
{
|
|
4719
5178
|
type: "list",
|
|
4720
5179
|
name: "presetName",
|
|
@@ -4726,7 +5185,7 @@ function addCommand2(program2) {
|
|
|
4726
5185
|
}
|
|
4727
5186
|
]);
|
|
4728
5187
|
const preset = CC_PRESETS.find((p) => p.name === presetName);
|
|
4729
|
-
console.log(
|
|
5188
|
+
console.log(chalk21.blue(`
|
|
4730
5189
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
4731
5190
|
`));
|
|
4732
5191
|
const input = await promptProviderForm({
|
|
@@ -4740,7 +5199,7 @@ function addCommand2(program2) {
|
|
|
4740
5199
|
baseUrl = input.baseUrl;
|
|
4741
5200
|
apiKey = input.apiKey;
|
|
4742
5201
|
} else {
|
|
4743
|
-
const answers = await
|
|
5202
|
+
const answers = await inquirer11.prompt([
|
|
4744
5203
|
{
|
|
4745
5204
|
type: "input",
|
|
4746
5205
|
name: "name",
|
|
@@ -4779,24 +5238,19 @@ function addCommand2(program2) {
|
|
|
4779
5238
|
apiKey = answers.apiKey;
|
|
4780
5239
|
}
|
|
4781
5240
|
const provider = manager.add({ name, desc, baseUrl, apiKey });
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
console.log(` ${chalk19.gray(provider.baseUrl)}`);
|
|
4787
|
-
console.log();
|
|
5241
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
5242
|
+
`${chalk21.bold(provider.name)} ${toolBadge("claude")}`,
|
|
5243
|
+
chalk21.gray(provider.baseUrl)
|
|
5244
|
+
]);
|
|
4788
5245
|
const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
|
|
4789
5246
|
if (switchNow) {
|
|
4790
5247
|
manager.switch(provider.id);
|
|
4791
|
-
|
|
4792
|
-
console.log();
|
|
4793
|
-
console.log(chalk19.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
4794
|
-
console.log(chalk19.gray(` - ${getClaudeConfigPath()}`));
|
|
5248
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [chalk21.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getClaudeConfigPath()}`)]);
|
|
4795
5249
|
} else {
|
|
4796
|
-
|
|
5250
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk21.white(`ccman cc use "${provider.name}"`)}`);
|
|
4797
5251
|
}
|
|
4798
5252
|
} catch (error) {
|
|
4799
|
-
console.error(
|
|
5253
|
+
console.error(chalk21.red(`
|
|
4800
5254
|
\u274C ${error.message}
|
|
4801
5255
|
`));
|
|
4802
5256
|
process.exit(1);
|
|
@@ -4806,7 +5260,7 @@ function addCommand2(program2) {
|
|
|
4806
5260
|
|
|
4807
5261
|
// src/commands/claude/list.ts
|
|
4808
5262
|
init_dist2();
|
|
4809
|
-
import
|
|
5263
|
+
import chalk22 from "chalk";
|
|
4810
5264
|
function listCommand2(program2) {
|
|
4811
5265
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 Claude Code \u670D\u52A1\u5546").action(async () => {
|
|
4812
5266
|
try {
|
|
@@ -4814,15 +5268,15 @@ function listCommand2(program2) {
|
|
|
4814
5268
|
const providers = manager.list();
|
|
4815
5269
|
const current = manager.getCurrent();
|
|
4816
5270
|
if (providers.length === 0) {
|
|
4817
|
-
|
|
4818
|
-
|
|
5271
|
+
printWarning("\u6682\u65E0 Claude Code \u670D\u52A1\u5546");
|
|
5272
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk22.white("ccman cc add"));
|
|
4819
5273
|
return;
|
|
4820
5274
|
}
|
|
4821
|
-
console.log(
|
|
4822
|
-
|
|
4823
|
-
|
|
5275
|
+
console.log(
|
|
5276
|
+
formatProviderTable(providers, current?.id, `Claude Code \u670D\u52A1\u5546 (${providers.length} \u4E2A)`)
|
|
5277
|
+
);
|
|
4824
5278
|
} catch (error) {
|
|
4825
|
-
console.error(
|
|
5279
|
+
console.error(chalk22.red(`
|
|
4826
5280
|
\u274C ${error.message}
|
|
4827
5281
|
`));
|
|
4828
5282
|
process.exit(1);
|
|
@@ -4832,16 +5286,16 @@ function listCommand2(program2) {
|
|
|
4832
5286
|
|
|
4833
5287
|
// src/commands/claude/use.ts
|
|
4834
5288
|
init_dist2();
|
|
4835
|
-
import
|
|
4836
|
-
import
|
|
5289
|
+
import chalk23 from "chalk";
|
|
5290
|
+
import inquirer12 from "inquirer";
|
|
4837
5291
|
function useCommand2(program2) {
|
|
4838
5292
|
program2.command("use [name]").description("\u5207\u6362 Claude Code \u670D\u52A1\u5546").action(async (name) => {
|
|
4839
5293
|
try {
|
|
4840
5294
|
const manager = createClaudeManager();
|
|
4841
5295
|
const providers = manager.list();
|
|
4842
5296
|
if (providers.length === 0) {
|
|
4843
|
-
|
|
4844
|
-
|
|
5297
|
+
printWarning("\u6682\u65E0 Claude Code \u670D\u52A1\u5546");
|
|
5298
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk23.white("ccman cc add"));
|
|
4845
5299
|
return;
|
|
4846
5300
|
}
|
|
4847
5301
|
let targetId;
|
|
@@ -4852,7 +5306,7 @@ function useCommand2(program2) {
|
|
|
4852
5306
|
}
|
|
4853
5307
|
targetId = provider2.id;
|
|
4854
5308
|
} else {
|
|
4855
|
-
const { selectedId } = await
|
|
5309
|
+
const { selectedId } = await inquirer12.prompt([
|
|
4856
5310
|
{
|
|
4857
5311
|
type: "list",
|
|
4858
5312
|
name: "selectedId",
|
|
@@ -4867,23 +5321,19 @@ function useCommand2(program2) {
|
|
|
4867
5321
|
}
|
|
4868
5322
|
manager.switch(targetId);
|
|
4869
5323
|
const provider = manager.get(targetId);
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
console.log();
|
|
4876
|
-
console.log(chalk21.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
4877
|
-
console.log(chalk21.gray(` - ${getClaudeConfigPath()}`));
|
|
4878
|
-
console.log();
|
|
5324
|
+
printSuccess("\u5207\u6362\u6210\u529F", [
|
|
5325
|
+
`${chalk23.bold(provider.name)} ${toolBadge("claude")}`,
|
|
5326
|
+
chalk23.gray(`URL: ${provider.baseUrl}`),
|
|
5327
|
+
chalk23.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getClaudeConfigPath()}`)
|
|
5328
|
+
]);
|
|
4879
5329
|
} catch (error) {
|
|
4880
5330
|
if (error instanceof ProviderNotFoundError) {
|
|
4881
|
-
console.error(
|
|
5331
|
+
console.error(chalk23.red(`
|
|
4882
5332
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${error.message}
|
|
4883
5333
|
`));
|
|
4884
|
-
console.log(
|
|
5334
|
+
console.log(chalk23.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + chalk23.white(" ccman cc list\n"));
|
|
4885
5335
|
} else {
|
|
4886
|
-
console.error(
|
|
5336
|
+
console.error(chalk23.red(`
|
|
4887
5337
|
\u274C ${error.message}
|
|
4888
5338
|
`));
|
|
4889
5339
|
}
|
|
@@ -4894,28 +5344,30 @@ function useCommand2(program2) {
|
|
|
4894
5344
|
|
|
4895
5345
|
// src/commands/claude/current.ts
|
|
4896
5346
|
init_dist2();
|
|
4897
|
-
import
|
|
5347
|
+
import chalk24 from "chalk";
|
|
4898
5348
|
function currentCommand2(program2) {
|
|
4899
5349
|
program2.command("current").description("\u663E\u793A\u5F53\u524D\u4F7F\u7528\u7684 Claude Code \u670D\u52A1\u5546").action(async () => {
|
|
4900
5350
|
try {
|
|
4901
5351
|
const manager = createClaudeManager();
|
|
4902
5352
|
const current = manager.getCurrent();
|
|
4903
5353
|
if (!current) {
|
|
4904
|
-
|
|
4905
|
-
|
|
5354
|
+
printWarning("\u672A\u9009\u62E9\u4EFB\u4F55 Claude Code \u670D\u52A1\u5546");
|
|
5355
|
+
printTip("\u9009\u62E9\u670D\u52A1\u5546: " + chalk24.white("ccman cc use"));
|
|
4906
5356
|
return;
|
|
4907
5357
|
}
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
5358
|
+
const lines = [
|
|
5359
|
+
chalk24.green.bold(current.name),
|
|
5360
|
+
chalk24.gray(`ID: ${current.id}`),
|
|
5361
|
+
chalk24.gray(`URL: ${current.baseUrl}`)
|
|
5362
|
+
];
|
|
4912
5363
|
if (current.lastUsedAt) {
|
|
4913
|
-
|
|
4914
|
-
|
|
5364
|
+
lines.push(
|
|
5365
|
+
chalk24.gray(`\u6700\u540E\u4F7F\u7528: ${new Date(current.lastUsedAt).toLocaleString("zh-CN")}`)
|
|
5366
|
+
);
|
|
4915
5367
|
}
|
|
4916
|
-
|
|
5368
|
+
printInfo("\u{1F4CD} \u5F53\u524D Claude Code \u670D\u52A1\u5546", lines);
|
|
4917
5369
|
} catch (error) {
|
|
4918
|
-
console.error(
|
|
5370
|
+
console.error(chalk24.red(`
|
|
4919
5371
|
\u274C ${error.message}
|
|
4920
5372
|
`));
|
|
4921
5373
|
process.exit(1);
|
|
@@ -4925,16 +5377,17 @@ function currentCommand2(program2) {
|
|
|
4925
5377
|
|
|
4926
5378
|
// src/commands/claude/remove.ts
|
|
4927
5379
|
init_dist2();
|
|
4928
|
-
|
|
4929
|
-
import
|
|
4930
|
-
import inquirer15 from "inquirer";
|
|
5380
|
+
import chalk25 from "chalk";
|
|
5381
|
+
import inquirer13 from "inquirer";
|
|
4931
5382
|
function removeCommand2(program2) {
|
|
4932
|
-
program2.command("remove [name]").alias("rm").description("\u5220\u9664 Claude Code \u670D\u52A1\u5546")
|
|
5383
|
+
const command = program2.command("remove [name]").alias("rm").description("\u5220\u9664 Claude Code \u670D\u52A1\u5546");
|
|
5384
|
+
addProviderRemoveOptions(command);
|
|
5385
|
+
command.action(async (name, options) => {
|
|
4933
5386
|
try {
|
|
4934
5387
|
const manager = createClaudeManager();
|
|
4935
5388
|
const providers = manager.list();
|
|
4936
5389
|
if (providers.length === 0) {
|
|
4937
|
-
console.log(
|
|
5390
|
+
console.log(chalk25.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
4938
5391
|
return;
|
|
4939
5392
|
}
|
|
4940
5393
|
let targetId;
|
|
@@ -4946,8 +5399,10 @@ function removeCommand2(program2) {
|
|
|
4946
5399
|
}
|
|
4947
5400
|
targetId = provider.id;
|
|
4948
5401
|
targetName = provider.name;
|
|
5402
|
+
} else if (options.yes) {
|
|
5403
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u5220\u9664\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
4949
5404
|
} else {
|
|
4950
|
-
const { selectedId } = await
|
|
5405
|
+
const { selectedId } = await inquirer13.prompt([
|
|
4951
5406
|
{
|
|
4952
5407
|
type: "list",
|
|
4953
5408
|
name: "selectedId",
|
|
@@ -4962,23 +5417,23 @@ function removeCommand2(program2) {
|
|
|
4962
5417
|
targetId = selectedId;
|
|
4963
5418
|
targetName = provider.name;
|
|
4964
5419
|
}
|
|
4965
|
-
const confirmed = await
|
|
5420
|
+
const confirmed = await confirmProviderRemoval(targetName, options);
|
|
4966
5421
|
if (!confirmed) {
|
|
4967
|
-
console.log(
|
|
5422
|
+
console.log(chalk25.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
4968
5423
|
return;
|
|
4969
5424
|
}
|
|
4970
5425
|
manager.remove(targetId);
|
|
4971
5426
|
console.log();
|
|
4972
|
-
console.log(
|
|
5427
|
+
console.log(chalk25.green(`\u2705 \u5DF2\u5220\u9664: ${targetName}`));
|
|
4973
5428
|
console.log();
|
|
4974
5429
|
} catch (error) {
|
|
4975
5430
|
if (error instanceof ProviderNotFoundError) {
|
|
4976
|
-
console.error(
|
|
5431
|
+
console.error(chalk25.red(`
|
|
4977
5432
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728
|
|
4978
5433
|
`));
|
|
4979
|
-
console.log(
|
|
5434
|
+
console.log(chalk25.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + chalk25.white(" ccman cc list\n"));
|
|
4980
5435
|
} else {
|
|
4981
|
-
console.error(
|
|
5436
|
+
console.error(chalk25.red(`
|
|
4982
5437
|
\u274C ${error.message}
|
|
4983
5438
|
`));
|
|
4984
5439
|
}
|
|
@@ -4989,17 +5444,20 @@ function removeCommand2(program2) {
|
|
|
4989
5444
|
|
|
4990
5445
|
// src/commands/claude/edit.ts
|
|
4991
5446
|
init_dist2();
|
|
4992
|
-
import
|
|
4993
|
-
import
|
|
5447
|
+
import chalk26 from "chalk";
|
|
5448
|
+
import inquirer14 from "inquirer";
|
|
4994
5449
|
function editCommand2(program2) {
|
|
4995
|
-
program2.command("edit [name]").description("\u7F16\u8F91 Claude Code \u670D\u52A1\u5546")
|
|
5450
|
+
const command = program2.command("edit [name]").description("\u7F16\u8F91 Claude Code \u670D\u52A1\u5546");
|
|
5451
|
+
addProviderEditOptions(command);
|
|
5452
|
+
command.action(async (name, options) => {
|
|
4996
5453
|
try {
|
|
4997
5454
|
const manager = createClaudeManager();
|
|
4998
5455
|
const providers = manager.list();
|
|
4999
5456
|
if (providers.length === 0) {
|
|
5000
|
-
console.log(
|
|
5457
|
+
console.log(chalk26.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
5001
5458
|
return;
|
|
5002
5459
|
}
|
|
5460
|
+
const resolved = resolveProviderEditInput(options);
|
|
5003
5461
|
let targetId;
|
|
5004
5462
|
if (name) {
|
|
5005
5463
|
const provider2 = manager.findByName(name);
|
|
@@ -5007,8 +5465,10 @@ function editCommand2(program2) {
|
|
|
5007
5465
|
throw new ProviderNotFoundError(name);
|
|
5008
5466
|
}
|
|
5009
5467
|
targetId = provider2.id;
|
|
5468
|
+
} else if (resolved.nonInteractive) {
|
|
5469
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u7F16\u8F91\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
5010
5470
|
} else {
|
|
5011
|
-
const { selectedId } = await
|
|
5471
|
+
const { selectedId } = await inquirer14.prompt([
|
|
5012
5472
|
{
|
|
5013
5473
|
type: "list",
|
|
5014
5474
|
name: "selectedId",
|
|
@@ -5022,9 +5482,24 @@ function editCommand2(program2) {
|
|
|
5022
5482
|
targetId = selectedId;
|
|
5023
5483
|
}
|
|
5024
5484
|
const provider = manager.get(targetId);
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5485
|
+
if (resolved.nonInteractive) {
|
|
5486
|
+
if (Object.keys(resolved.updates).length === 0) {
|
|
5487
|
+
console.log(chalk26.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
5488
|
+
return;
|
|
5489
|
+
}
|
|
5490
|
+
const updated2 = manager.edit(targetId, resolved.updates);
|
|
5491
|
+
console.log();
|
|
5492
|
+
console.log(chalk26.green("\u2705 \u7F16\u8F91\u6210\u529F"));
|
|
5493
|
+
console.log();
|
|
5494
|
+
console.log(` ${chalk26.bold(updated2.name)} ${chalk26.blue("[Claude Code]")}`);
|
|
5495
|
+
console.log(` ${chalk26.gray(`ID: ${updated2.id}`)}`);
|
|
5496
|
+
console.log(` ${chalk26.gray(`URL: ${updated2.baseUrl}`)}`);
|
|
5497
|
+
console.log();
|
|
5498
|
+
return;
|
|
5499
|
+
}
|
|
5500
|
+
console.log(chalk26.bold("\n\u270F\uFE0F \u7F16\u8F91\u670D\u52A1\u5546\n"));
|
|
5501
|
+
console.log(chalk26.gray("\u63D0\u793A: \u7559\u7A7A\u5219\u4FDD\u6301\u539F\u503C\n"));
|
|
5502
|
+
const answers = await inquirer14.prompt([
|
|
5028
5503
|
{
|
|
5029
5504
|
type: "input",
|
|
5030
5505
|
name: "name",
|
|
@@ -5055,19 +5530,19 @@ function editCommand2(program2) {
|
|
|
5055
5530
|
if (answers.baseUrl && answers.baseUrl !== provider.baseUrl) updates.baseUrl = answers.baseUrl;
|
|
5056
5531
|
if (answers.apiKey) updates.apiKey = answers.apiKey;
|
|
5057
5532
|
if (Object.keys(updates).length === 0) {
|
|
5058
|
-
console.log(
|
|
5533
|
+
console.log(chalk26.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
5059
5534
|
return;
|
|
5060
5535
|
}
|
|
5061
5536
|
const updated = manager.edit(targetId, updates);
|
|
5062
5537
|
console.log();
|
|
5063
|
-
console.log(
|
|
5538
|
+
console.log(chalk26.green("\u2705 \u7F16\u8F91\u6210\u529F"));
|
|
5064
5539
|
console.log();
|
|
5065
|
-
console.log(` ${
|
|
5066
|
-
console.log(` ${
|
|
5067
|
-
console.log(` ${
|
|
5540
|
+
console.log(` ${chalk26.bold(updated.name)} ${chalk26.blue("[Claude Code]")}`);
|
|
5541
|
+
console.log(` ${chalk26.gray(`ID: ${updated.id}`)}`);
|
|
5542
|
+
console.log(` ${chalk26.gray(`URL: ${updated.baseUrl}`)}`);
|
|
5068
5543
|
console.log();
|
|
5069
5544
|
} catch (error) {
|
|
5070
|
-
console.error(
|
|
5545
|
+
console.error(chalk26.red(`
|
|
5071
5546
|
\u274C ${error.message}
|
|
5072
5547
|
`));
|
|
5073
5548
|
process.exit(1);
|
|
@@ -5077,15 +5552,15 @@ function editCommand2(program2) {
|
|
|
5077
5552
|
|
|
5078
5553
|
// src/commands/claude/clone.ts
|
|
5079
5554
|
init_dist2();
|
|
5080
|
-
import
|
|
5081
|
-
import
|
|
5555
|
+
import chalk27 from "chalk";
|
|
5556
|
+
import inquirer15 from "inquirer";
|
|
5082
5557
|
function cloneCommand2(program2) {
|
|
5083
5558
|
program2.command("clone [source-name] [new-name]").description("\u514B\u9686 Claude Code \u670D\u52A1\u5546").action(async (sourceName, newName) => {
|
|
5084
5559
|
try {
|
|
5085
5560
|
const manager = createClaudeManager();
|
|
5086
5561
|
const providers = manager.list();
|
|
5087
5562
|
if (providers.length === 0) {
|
|
5088
|
-
console.log(
|
|
5563
|
+
console.log(chalk27.yellow("\n\u26A0\uFE0F \u6682\u65E0 Claude Code \u670D\u52A1\u5546\n"));
|
|
5089
5564
|
return;
|
|
5090
5565
|
}
|
|
5091
5566
|
let sourceId;
|
|
@@ -5096,7 +5571,7 @@ function cloneCommand2(program2) {
|
|
|
5096
5571
|
}
|
|
5097
5572
|
sourceId = provider.id;
|
|
5098
5573
|
} else {
|
|
5099
|
-
const { selectedId } = await
|
|
5574
|
+
const { selectedId } = await inquirer15.prompt([
|
|
5100
5575
|
{
|
|
5101
5576
|
type: "list",
|
|
5102
5577
|
name: "selectedId",
|
|
@@ -5114,7 +5589,7 @@ function cloneCommand2(program2) {
|
|
|
5114
5589
|
if (newName) {
|
|
5115
5590
|
cloned = manager.clone(sourceId, newName);
|
|
5116
5591
|
} else {
|
|
5117
|
-
console.log(
|
|
5592
|
+
console.log(chalk27.blue(`
|
|
5118
5593
|
\u514B\u9686\u81EA: ${source.name}
|
|
5119
5594
|
`));
|
|
5120
5595
|
const input = await promptProviderForm({
|
|
@@ -5127,14 +5602,14 @@ function cloneCommand2(program2) {
|
|
|
5127
5602
|
cloned = manager.add(input);
|
|
5128
5603
|
}
|
|
5129
5604
|
console.log();
|
|
5130
|
-
console.log(
|
|
5605
|
+
console.log(chalk27.green("\u2705 \u514B\u9686\u6210\u529F"));
|
|
5131
5606
|
console.log();
|
|
5132
|
-
console.log(` ${
|
|
5133
|
-
console.log(` ${
|
|
5134
|
-
console.log(` ${
|
|
5607
|
+
console.log(` ${chalk27.bold(cloned.name)} ${chalk27.blue("[Claude Code]")}`);
|
|
5608
|
+
console.log(` ${chalk27.gray(`ID: ${cloned.id}`)}`);
|
|
5609
|
+
console.log(` ${chalk27.gray(`URL: ${cloned.baseUrl}`)}`);
|
|
5135
5610
|
console.log();
|
|
5136
5611
|
} catch (error) {
|
|
5137
|
-
console.error(
|
|
5612
|
+
console.error(chalk27.red(`
|
|
5138
5613
|
\u274C ${error.message}
|
|
5139
5614
|
`));
|
|
5140
5615
|
process.exit(1);
|
|
@@ -5145,8 +5620,8 @@ function cloneCommand2(program2) {
|
|
|
5145
5620
|
// src/commands/clean.ts
|
|
5146
5621
|
init_dist2();
|
|
5147
5622
|
init_confirm();
|
|
5148
|
-
import
|
|
5149
|
-
import
|
|
5623
|
+
import chalk28 from "chalk";
|
|
5624
|
+
import inquirer16 from "inquirer";
|
|
5150
5625
|
function formatBytes2(bytes) {
|
|
5151
5626
|
if (bytes < 1024) return `${bytes} B`;
|
|
5152
5627
|
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
@@ -5154,30 +5629,30 @@ function formatBytes2(bytes) {
|
|
|
5154
5629
|
}
|
|
5155
5630
|
function displayAnalysis() {
|
|
5156
5631
|
try {
|
|
5157
|
-
console.log(
|
|
5632
|
+
console.log(chalk28.bold("\n\u{1F4CA} \u5206\u6790 ~/.claude.json\n"));
|
|
5158
5633
|
const analysis = analyzeClaudeJson();
|
|
5159
|
-
console.log(
|
|
5634
|
+
console.log(chalk28.cyan("\u6587\u4EF6\u5927\u5C0F:"), chalk28.bold(analysis.fileSizeFormatted));
|
|
5160
5635
|
console.log();
|
|
5161
|
-
console.log(
|
|
5162
|
-
console.log(` \u9879\u76EE\u603B\u6570: ${
|
|
5163
|
-
console.log(` \u5386\u53F2\u8BB0\u5F55\u603B\u6570: ${
|
|
5636
|
+
console.log(chalk28.cyan("\u9879\u76EE\u7EDF\u8BA1:"));
|
|
5637
|
+
console.log(` \u9879\u76EE\u603B\u6570: ${chalk28.bold(analysis.projectCount)}`);
|
|
5638
|
+
console.log(` \u5386\u53F2\u8BB0\u5F55\u603B\u6570: ${chalk28.bold(analysis.totalHistoryCount)} \u6761`);
|
|
5164
5639
|
console.log();
|
|
5165
|
-
console.log(
|
|
5640
|
+
console.log(chalk28.cyan("\u5386\u53F2\u8BB0\u5F55\u6700\u591A\u7684\u9879\u76EE:"));
|
|
5166
5641
|
const top5 = analysis.projectHistory.slice(0, 5);
|
|
5167
5642
|
for (const project of top5) {
|
|
5168
5643
|
const displayPath = project.path.length > 50 ? "..." + project.path.slice(-47) : project.path;
|
|
5169
|
-
console.log(` ${
|
|
5644
|
+
console.log(` ${chalk28.bold(project.count.toString().padStart(3))} \u6761 ${displayPath}`);
|
|
5170
5645
|
}
|
|
5171
5646
|
console.log();
|
|
5172
|
-
console.log(
|
|
5173
|
-
console.log(` ${
|
|
5174
|
-
console.log(` ${
|
|
5175
|
-
console.log(` ${
|
|
5647
|
+
console.log(chalk28.cyan("\u9884\u8BA1\u53EF\u8282\u7701\u7A7A\u95F4:"));
|
|
5648
|
+
console.log(` ${chalk28.green("\u4FDD\u5B88\u6E05\u7406")} (\u4FDD\u755910\u6761): ${chalk28.bold(formatBytes2(analysis.estimatedSavings.conservative))}`);
|
|
5649
|
+
console.log(` ${chalk28.yellow("\u4E2D\u7B49\u6E05\u7406")} (\u4FDD\u75595\u6761): ${chalk28.bold(formatBytes2(analysis.estimatedSavings.moderate))}`);
|
|
5650
|
+
console.log(` ${chalk28.red("\u6FC0\u8FDB\u6E05\u7406")} (\u6E05\u7A7A\u5386\u53F2): ${chalk28.bold(formatBytes2(analysis.estimatedSavings.aggressive))}`);
|
|
5176
5651
|
console.log();
|
|
5177
|
-
console.log(
|
|
5652
|
+
console.log(chalk28.blue(`\u{1F4A1} \u6267\u884C\u6E05\u7406: ccman cc clean
|
|
5178
5653
|
`));
|
|
5179
5654
|
} catch (error) {
|
|
5180
|
-
console.error(
|
|
5655
|
+
console.error(chalk28.red(`
|
|
5181
5656
|
\u274C ${error.message}
|
|
5182
5657
|
`));
|
|
5183
5658
|
process.exit(1);
|
|
@@ -5191,9 +5666,9 @@ function cleanAnalyzeCommand(program2) {
|
|
|
5191
5666
|
function cleanCommand(program2) {
|
|
5192
5667
|
program2.command("clean").description("\u6E05\u7406 ~/.claude.json \u6587\u4EF6\uFF08\u5386\u53F2\u8BB0\u5F55\u3001\u7F13\u5B58\u7B49\uFF09").option("--preset <type>", "\u4F7F\u7528\u9884\u8BBE\u65B9\u6848 (conservative|moderate|aggressive)").option("--keep <count>", "\u4FDD\u7559\u6700\u8FD1N\u6761\u5386\u53F2\u8BB0\u5F55").option("--cache", "\u6E05\u7406\u7F13\u5B58\u6570\u636E").option("--stats", "\u91CD\u7F6E\u4F7F\u7528\u7EDF\u8BA1").option("--projects <paths>", "\u53EA\u6E05\u7406\u6307\u5B9A\u9879\u76EE\uFF08\u9017\u53F7\u5206\u9694\uFF09").action(async (options) => {
|
|
5193
5668
|
try {
|
|
5194
|
-
console.log(
|
|
5669
|
+
console.log(chalk28.bold("\n\u{1F9F9} \u6E05\u7406 ~/.claude.json\n"));
|
|
5195
5670
|
const analysis = analyzeClaudeJson();
|
|
5196
|
-
console.log(`\u5F53\u524D\u6587\u4EF6\u5927\u5C0F: ${
|
|
5671
|
+
console.log(`\u5F53\u524D\u6587\u4EF6\u5927\u5C0F: ${chalk28.bold(analysis.fileSizeFormatted)}`);
|
|
5197
5672
|
console.log(`\u9879\u76EE\u6570: ${analysis.projectCount}, \u5386\u53F2\u8BB0\u5F55: ${analysis.totalHistoryCount} \u6761`);
|
|
5198
5673
|
console.log();
|
|
5199
5674
|
let cleanOptions;
|
|
@@ -5204,30 +5679,30 @@ function cleanCommand(program2) {
|
|
|
5204
5679
|
}
|
|
5205
5680
|
const confirmed = await promptConfirm("\u786E\u8BA4\u6267\u884C\u6E05\u7406\uFF1F\uFF08\u4F1A\u81EA\u52A8\u5907\u4EFD\u539F\u6587\u4EF6\uFF09", true);
|
|
5206
5681
|
if (!confirmed) {
|
|
5207
|
-
console.log(
|
|
5682
|
+
console.log(chalk28.yellow("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
5208
5683
|
return;
|
|
5209
5684
|
}
|
|
5210
|
-
console.log(
|
|
5685
|
+
console.log(chalk28.cyan("\n\u6B63\u5728\u6E05\u7406...\n"));
|
|
5211
5686
|
const result = cleanClaudeJson(cleanOptions);
|
|
5212
|
-
console.log(
|
|
5213
|
-
console.log(`\u6E05\u7406\u524D: ${
|
|
5214
|
-
console.log(`\u6E05\u7406\u540E: ${
|
|
5215
|
-
console.log(`\u8282\u7701\u7A7A\u95F4: ${
|
|
5687
|
+
console.log(chalk28.green("\u2705 \u6E05\u7406\u5B8C\u6210\n"));
|
|
5688
|
+
console.log(`\u6E05\u7406\u524D: ${chalk28.bold(formatBytes2(result.sizeBefore))}`);
|
|
5689
|
+
console.log(`\u6E05\u7406\u540E: ${chalk28.bold(formatBytes2(result.sizeAfter))}`);
|
|
5690
|
+
console.log(`\u8282\u7701\u7A7A\u95F4: ${chalk28.green.bold(formatBytes2(result.saved))} (${(result.saved / result.sizeBefore * 100).toFixed(1)}%)`);
|
|
5216
5691
|
console.log();
|
|
5217
5692
|
if (result.cleanedItems.projectHistory > 0) {
|
|
5218
|
-
console.log(`\u6E05\u7406\u5386\u53F2\u8BB0\u5F55: ${
|
|
5693
|
+
console.log(`\u6E05\u7406\u5386\u53F2\u8BB0\u5F55: ${chalk28.bold(result.cleanedItems.projectHistory)} \u6761`);
|
|
5219
5694
|
}
|
|
5220
5695
|
if (result.cleanedItems.cache) {
|
|
5221
|
-
console.log(`\u6E05\u7406\u7F13\u5B58: ${
|
|
5696
|
+
console.log(`\u6E05\u7406\u7F13\u5B58: ${chalk28.green("\u2713")}`);
|
|
5222
5697
|
}
|
|
5223
5698
|
if (result.cleanedItems.stats) {
|
|
5224
|
-
console.log(`\u91CD\u7F6E\u7EDF\u8BA1: ${
|
|
5699
|
+
console.log(`\u91CD\u7F6E\u7EDF\u8BA1: ${chalk28.green("\u2713")}`);
|
|
5225
5700
|
}
|
|
5226
5701
|
console.log();
|
|
5227
|
-
console.log(`\u5907\u4EFD\u6587\u4EF6: ${
|
|
5702
|
+
console.log(`\u5907\u4EFD\u6587\u4EF6: ${chalk28.cyan(result.backupPath)}`);
|
|
5228
5703
|
console.log();
|
|
5229
5704
|
} catch (error) {
|
|
5230
|
-
console.error(
|
|
5705
|
+
console.error(chalk28.red(`
|
|
5231
5706
|
\u274C ${error.message}
|
|
5232
5707
|
`));
|
|
5233
5708
|
process.exit(1);
|
|
@@ -5265,32 +5740,32 @@ function buildOptionsFromArgs(args) {
|
|
|
5265
5740
|
options.projectPaths = args.projects.split(",").map((p) => p.trim());
|
|
5266
5741
|
}
|
|
5267
5742
|
if (!options.cleanProjectHistory && !options.cleanCache && !options.cleanStats) {
|
|
5268
|
-
console.log(
|
|
5743
|
+
console.log(chalk28.yellow("\u672A\u6307\u5B9A\u6E05\u7406\u9009\u9879\uFF0C\u4F7F\u7528\u4FDD\u5B88\u9884\u8BBE\n"));
|
|
5269
5744
|
return CleanPresets.conservative();
|
|
5270
5745
|
}
|
|
5271
5746
|
return options;
|
|
5272
5747
|
}
|
|
5273
5748
|
async function promptForOptions(analysis) {
|
|
5274
|
-
const answers = await
|
|
5749
|
+
const answers = await inquirer16.prompt([
|
|
5275
5750
|
{
|
|
5276
5751
|
type: "list",
|
|
5277
5752
|
name: "preset",
|
|
5278
5753
|
message: "\u9009\u62E9\u6E05\u7406\u65B9\u6848:",
|
|
5279
5754
|
choices: [
|
|
5280
5755
|
{
|
|
5281
|
-
name: `${
|
|
5756
|
+
name: `${chalk28.green("\u4FDD\u5B88\u6E05\u7406")} - \u4FDD\u7559\u6700\u8FD110\u6761\u8BB0\u5F55\uFF0C\u6E05\u7406\u7F13\u5B58 (\u8282\u7701\u7EA6 ${formatBytes2(analysis.estimatedSavings.conservative)})`,
|
|
5282
5757
|
value: "conservative"
|
|
5283
5758
|
},
|
|
5284
5759
|
{
|
|
5285
|
-
name: `${
|
|
5760
|
+
name: `${chalk28.yellow("\u4E2D\u7B49\u6E05\u7406")} - \u4FDD\u7559\u6700\u8FD15\u6761\u8BB0\u5F55\uFF0C\u6E05\u7406\u7F13\u5B58\u548C\u7EDF\u8BA1 (\u8282\u7701\u7EA6 ${formatBytes2(analysis.estimatedSavings.moderate)})`,
|
|
5286
5761
|
value: "moderate"
|
|
5287
5762
|
},
|
|
5288
5763
|
{
|
|
5289
|
-
name: `${
|
|
5764
|
+
name: `${chalk28.red("\u6FC0\u8FDB\u6E05\u7406")} - \u6E05\u7A7A\u5386\u53F2\u8BB0\u5F55\uFF0C\u6E05\u7406\u7F13\u5B58\u548C\u7EDF\u8BA1 (\u8282\u7701\u7EA6 ${formatBytes2(analysis.estimatedSavings.aggressive)})`,
|
|
5290
5765
|
value: "aggressive"
|
|
5291
5766
|
},
|
|
5292
5767
|
{
|
|
5293
|
-
name: `${
|
|
5768
|
+
name: `${chalk28.cyan("\u81EA\u5B9A\u4E49")} - \u81EA\u5B9A\u4E49\u6E05\u7406\u9009\u9879`,
|
|
5294
5769
|
value: "custom"
|
|
5295
5770
|
}
|
|
5296
5771
|
]
|
|
@@ -5308,7 +5783,7 @@ async function promptForOptions(analysis) {
|
|
|
5308
5783
|
const cleanHistory = await promptConfirm("\u6E05\u7406\u9879\u76EE\u5386\u53F2\u8BB0\u5F55\uFF1F", true);
|
|
5309
5784
|
let keepCount = 10;
|
|
5310
5785
|
if (cleanHistory) {
|
|
5311
|
-
const answers2 = await
|
|
5786
|
+
const answers2 = await inquirer16.prompt([
|
|
5312
5787
|
{
|
|
5313
5788
|
type: "number",
|
|
5314
5789
|
name: "keepCount",
|
|
@@ -5343,14 +5818,14 @@ function createClaudeCommands(program2) {
|
|
|
5343
5818
|
|
|
5344
5819
|
// src/commands/mcp/add.ts
|
|
5345
5820
|
init_dist2();
|
|
5346
|
-
import
|
|
5347
|
-
import
|
|
5821
|
+
import chalk29 from "chalk";
|
|
5822
|
+
import inquirer17 from "inquirer";
|
|
5348
5823
|
function addCommand3(program2) {
|
|
5349
5824
|
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 MCP \u670D\u52A1\u5668(\u4EA4\u4E92\u5F0F)").action(async () => {
|
|
5350
5825
|
try {
|
|
5351
5826
|
const manager = createMCPManager();
|
|
5352
|
-
console.log(
|
|
5353
|
-
const { usePreset } = await
|
|
5827
|
+
console.log(chalk29.bold("\n\u{1F4DD} \u6DFB\u52A0 MCP \u670D\u52A1\u5668\n"));
|
|
5828
|
+
const { usePreset } = await inquirer17.prompt([
|
|
5354
5829
|
{
|
|
5355
5830
|
type: "list",
|
|
5356
5831
|
name: "usePreset",
|
|
@@ -5366,7 +5841,7 @@ function addCommand3(program2) {
|
|
|
5366
5841
|
let args;
|
|
5367
5842
|
let env;
|
|
5368
5843
|
if (usePreset) {
|
|
5369
|
-
const { presetName } = await
|
|
5844
|
+
const { presetName } = await inquirer17.prompt([
|
|
5370
5845
|
{
|
|
5371
5846
|
type: "list",
|
|
5372
5847
|
name: "presetName",
|
|
@@ -5378,18 +5853,18 @@ function addCommand3(program2) {
|
|
|
5378
5853
|
}
|
|
5379
5854
|
]);
|
|
5380
5855
|
const preset = MCP_PRESETS_DETAIL.find((p) => p.name === presetName);
|
|
5381
|
-
console.log(
|
|
5856
|
+
console.log(chalk29.blue(`
|
|
5382
5857
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
5383
5858
|
`));
|
|
5384
5859
|
if (preset.argsPlaceholder) {
|
|
5385
|
-
console.log(
|
|
5860
|
+
console.log(chalk29.yellow(`\u26A0\uFE0F ${preset.argsPlaceholder}
|
|
5386
5861
|
`));
|
|
5387
5862
|
}
|
|
5388
5863
|
if (preset.envRequired && preset.envRequired.length > 0) {
|
|
5389
|
-
console.log(
|
|
5864
|
+
console.log(chalk29.yellow(`\u26A0\uFE0F \u9700\u8981\u914D\u7F6E\u73AF\u5883\u53D8\u91CF: ${preset.envRequired.join(", ")}
|
|
5390
5865
|
`));
|
|
5391
5866
|
}
|
|
5392
|
-
const input = await
|
|
5867
|
+
const input = await inquirer17.prompt([
|
|
5393
5868
|
{
|
|
5394
5869
|
type: "input",
|
|
5395
5870
|
name: "name",
|
|
@@ -5432,7 +5907,7 @@ function addCommand3(program2) {
|
|
|
5432
5907
|
args = input.args.split(" ").filter((arg) => arg.length > 0);
|
|
5433
5908
|
env = input.env ? JSON.parse(input.env) : void 0;
|
|
5434
5909
|
} else {
|
|
5435
|
-
const answers = await
|
|
5910
|
+
const answers = await inquirer17.prompt([
|
|
5436
5911
|
{
|
|
5437
5912
|
type: "input",
|
|
5438
5913
|
name: "name",
|
|
@@ -5480,21 +5955,21 @@ function addCommand3(program2) {
|
|
|
5480
5955
|
model: env ? JSON.stringify(env) : void 0
|
|
5481
5956
|
});
|
|
5482
5957
|
console.log();
|
|
5483
|
-
console.log(
|
|
5958
|
+
console.log(chalk29.green("\u2705 MCP \u670D\u52A1\u5668\u6DFB\u52A0\u6210\u529F"));
|
|
5484
5959
|
console.log();
|
|
5485
|
-
console.log(` ${
|
|
5486
|
-
console.log(` ${
|
|
5960
|
+
console.log(` ${chalk29.bold(provider.name)} ${chalk29.blue("[MCP]")}`);
|
|
5961
|
+
console.log(` ${chalk29.gray(`${command} ${args.join(" ")}`)}`);
|
|
5487
5962
|
if (env) {
|
|
5488
|
-
console.log(
|
|
5963
|
+
console.log(chalk29.gray(` \u73AF\u5883\u53D8\u91CF: ${Object.keys(env).join(", ")}`));
|
|
5489
5964
|
}
|
|
5490
5965
|
console.log();
|
|
5491
|
-
console.log(
|
|
5966
|
+
console.log(chalk29.green("\u2705 \u914D\u7F6E\u5DF2\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
|
|
5492
5967
|
console.log();
|
|
5493
|
-
console.log(
|
|
5494
|
-
console.log(
|
|
5968
|
+
console.log(chalk29.gray("\u914D\u7F6E\u6587\u4EF6:"));
|
|
5969
|
+
console.log(chalk29.gray(` - ${getClaudeConfigPath()}`));
|
|
5495
5970
|
console.log();
|
|
5496
5971
|
} catch (error) {
|
|
5497
|
-
console.error(
|
|
5972
|
+
console.error(chalk29.red(`
|
|
5498
5973
|
\u274C ${error.message}
|
|
5499
5974
|
`));
|
|
5500
5975
|
process.exit(1);
|
|
@@ -5504,25 +5979,25 @@ function addCommand3(program2) {
|
|
|
5504
5979
|
|
|
5505
5980
|
// src/commands/mcp/list.ts
|
|
5506
5981
|
init_dist2();
|
|
5507
|
-
import
|
|
5982
|
+
import chalk30 from "chalk";
|
|
5508
5983
|
function listCommand3(program2) {
|
|
5509
5984
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 MCP \u670D\u52A1\u5668").action(async () => {
|
|
5510
5985
|
try {
|
|
5511
5986
|
const manager = createMCPManager();
|
|
5512
5987
|
const providers = manager.list();
|
|
5513
5988
|
if (providers.length === 0) {
|
|
5514
|
-
console.log(
|
|
5515
|
-
console.log(
|
|
5989
|
+
console.log(chalk30.yellow("\n\u26A0\uFE0F \u6682\u65E0 MCP \u670D\u52A1\u5668\n"));
|
|
5990
|
+
console.log(chalk30.blue("\u{1F4A1} \u6DFB\u52A0 MCP \u670D\u52A1\u5668:") + chalk30.white(" ccman mcp add\n"));
|
|
5516
5991
|
return;
|
|
5517
5992
|
}
|
|
5518
|
-
console.log(
|
|
5993
|
+
console.log(chalk30.bold(`
|
|
5519
5994
|
\u{1F4CB} MCP \u670D\u52A1\u5668 (${providers.length} \u4E2A)
|
|
5520
5995
|
`));
|
|
5521
5996
|
providers.forEach((provider) => {
|
|
5522
5997
|
const isActive = false;
|
|
5523
|
-
const indicator = isActive ?
|
|
5524
|
-
const nameDisplay =
|
|
5525
|
-
const commandDisplay =
|
|
5998
|
+
const indicator = isActive ? chalk30.green("\u25CF") : chalk30.gray("\u25CB");
|
|
5999
|
+
const nameDisplay = chalk30.bold(provider.name);
|
|
6000
|
+
const commandDisplay = chalk30.gray(`${provider.baseUrl} ${provider.apiKey}`);
|
|
5526
6001
|
console.log(` ${indicator} ${nameDisplay}`);
|
|
5527
6002
|
console.log(` ${commandDisplay}`);
|
|
5528
6003
|
if (provider.model) {
|
|
@@ -5530,17 +6005,17 @@ function listCommand3(program2) {
|
|
|
5530
6005
|
const env = JSON.parse(provider.model);
|
|
5531
6006
|
const envKeys = Object.keys(env);
|
|
5532
6007
|
if (envKeys.length > 0) {
|
|
5533
|
-
console.log(
|
|
6008
|
+
console.log(chalk30.gray(` \u73AF\u5883\u53D8\u91CF: ${envKeys.join(", ")}`));
|
|
5534
6009
|
}
|
|
5535
6010
|
} catch {
|
|
5536
6011
|
}
|
|
5537
6012
|
}
|
|
5538
6013
|
console.log();
|
|
5539
6014
|
});
|
|
5540
|
-
console.log(
|
|
6015
|
+
console.log(chalk30.gray("\u63D0\u793A: \u6240\u6709\u914D\u7F6E\u7684 MCP \u670D\u52A1\u5668\u4F1A\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
|
|
5541
6016
|
console.log();
|
|
5542
6017
|
} catch (error) {
|
|
5543
|
-
console.error(
|
|
6018
|
+
console.error(chalk30.red(`
|
|
5544
6019
|
\u274C ${error.message}
|
|
5545
6020
|
`));
|
|
5546
6021
|
process.exit(1);
|
|
@@ -5551,15 +6026,15 @@ function listCommand3(program2) {
|
|
|
5551
6026
|
// src/commands/mcp/remove.ts
|
|
5552
6027
|
init_dist2();
|
|
5553
6028
|
init_confirm();
|
|
5554
|
-
import
|
|
5555
|
-
import
|
|
6029
|
+
import chalk31 from "chalk";
|
|
6030
|
+
import inquirer18 from "inquirer";
|
|
5556
6031
|
function removeCommand3(program2) {
|
|
5557
6032
|
program2.command("remove [name]").alias("rm").description("\u5220\u9664 MCP \u670D\u52A1\u5668").action(async (name) => {
|
|
5558
6033
|
try {
|
|
5559
6034
|
const manager = createMCPManager();
|
|
5560
6035
|
const providers = manager.list();
|
|
5561
6036
|
if (providers.length === 0) {
|
|
5562
|
-
console.log(
|
|
6037
|
+
console.log(chalk31.yellow("\n\u26A0\uFE0F \u6682\u65E0 MCP \u670D\u52A1\u5668\n"));
|
|
5563
6038
|
return;
|
|
5564
6039
|
}
|
|
5565
6040
|
let targetId;
|
|
@@ -5572,7 +6047,7 @@ function removeCommand3(program2) {
|
|
|
5572
6047
|
targetId = provider.id;
|
|
5573
6048
|
targetName = provider.name;
|
|
5574
6049
|
} else {
|
|
5575
|
-
const { selectedId } = await
|
|
6050
|
+
const { selectedId } = await inquirer18.prompt([
|
|
5576
6051
|
{
|
|
5577
6052
|
type: "list",
|
|
5578
6053
|
name: "selectedId",
|
|
@@ -5589,26 +6064,26 @@ function removeCommand3(program2) {
|
|
|
5589
6064
|
}
|
|
5590
6065
|
const confirmed = await promptConfirm(`\u786E\u5B9A\u5220\u9664 "${targetName}"?`, false);
|
|
5591
6066
|
if (!confirmed) {
|
|
5592
|
-
console.log(
|
|
6067
|
+
console.log(chalk31.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
5593
6068
|
return;
|
|
5594
6069
|
}
|
|
5595
6070
|
manager.remove(targetId);
|
|
5596
6071
|
console.log();
|
|
5597
|
-
console.log(
|
|
6072
|
+
console.log(chalk31.green(`\u2705 \u5DF2\u5220\u9664: ${targetName}`));
|
|
5598
6073
|
console.log();
|
|
5599
|
-
console.log(
|
|
6074
|
+
console.log(chalk31.green("\u2705 \u914D\u7F6E\u5DF2\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
|
|
5600
6075
|
console.log();
|
|
5601
|
-
console.log(
|
|
5602
|
-
console.log(
|
|
6076
|
+
console.log(chalk31.gray("\u914D\u7F6E\u6587\u4EF6:"));
|
|
6077
|
+
console.log(chalk31.gray(` - ${getClaudeConfigPath()}`));
|
|
5603
6078
|
console.log();
|
|
5604
6079
|
} catch (error) {
|
|
5605
6080
|
if (error instanceof ProviderNotFoundError) {
|
|
5606
|
-
console.error(
|
|
6081
|
+
console.error(chalk31.red(`
|
|
5607
6082
|
\u274C MCP \u670D\u52A1\u5668\u4E0D\u5B58\u5728
|
|
5608
6083
|
`));
|
|
5609
|
-
console.log(
|
|
6084
|
+
console.log(chalk31.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709 MCP \u670D\u52A1\u5668:") + chalk31.white(" ccman mcp list\n"));
|
|
5610
6085
|
} else {
|
|
5611
|
-
console.error(
|
|
6086
|
+
console.error(chalk31.red(`
|
|
5612
6087
|
\u274C ${error.message}
|
|
5613
6088
|
`));
|
|
5614
6089
|
}
|
|
@@ -5619,15 +6094,15 @@ function removeCommand3(program2) {
|
|
|
5619
6094
|
|
|
5620
6095
|
// src/commands/mcp/edit.ts
|
|
5621
6096
|
init_dist2();
|
|
5622
|
-
import
|
|
5623
|
-
import
|
|
6097
|
+
import chalk32 from "chalk";
|
|
6098
|
+
import inquirer19 from "inquirer";
|
|
5624
6099
|
function editCommand3(program2) {
|
|
5625
6100
|
program2.command("edit [name]").description("\u7F16\u8F91 MCP \u670D\u52A1\u5668").action(async (name) => {
|
|
5626
6101
|
try {
|
|
5627
6102
|
const manager = createMCPManager();
|
|
5628
6103
|
const providers = manager.list();
|
|
5629
6104
|
if (providers.length === 0) {
|
|
5630
|
-
console.log(
|
|
6105
|
+
console.log(chalk32.yellow("\n\u26A0\uFE0F \u6682\u65E0 MCP \u670D\u52A1\u5668\n"));
|
|
5631
6106
|
return;
|
|
5632
6107
|
}
|
|
5633
6108
|
let targetId;
|
|
@@ -5638,7 +6113,7 @@ function editCommand3(program2) {
|
|
|
5638
6113
|
}
|
|
5639
6114
|
targetId = provider2.id;
|
|
5640
6115
|
} else {
|
|
5641
|
-
const { selectedId } = await
|
|
6116
|
+
const { selectedId } = await inquirer19.prompt([
|
|
5642
6117
|
{
|
|
5643
6118
|
type: "list",
|
|
5644
6119
|
name: "selectedId",
|
|
@@ -5655,9 +6130,9 @@ function editCommand3(program2) {
|
|
|
5655
6130
|
const currentCommand6 = provider.baseUrl;
|
|
5656
6131
|
const currentArgs = provider.apiKey;
|
|
5657
6132
|
const currentEnv = provider.model;
|
|
5658
|
-
console.log(
|
|
5659
|
-
console.log(
|
|
5660
|
-
const answers = await
|
|
6133
|
+
console.log(chalk32.bold("\n\u270F\uFE0F \u7F16\u8F91 MCP \u670D\u52A1\u5668\n"));
|
|
6134
|
+
console.log(chalk32.gray("\u63D0\u793A: \u7559\u7A7A\u5219\u4FDD\u6301\u539F\u503C\n"));
|
|
6135
|
+
const answers = await inquirer19.prompt([
|
|
5661
6136
|
{
|
|
5662
6137
|
type: "input",
|
|
5663
6138
|
name: "name",
|
|
@@ -5697,30 +6172,30 @@ function editCommand3(program2) {
|
|
|
5697
6172
|
updates.model = answers.env || void 0;
|
|
5698
6173
|
}
|
|
5699
6174
|
if (Object.keys(updates).length === 0) {
|
|
5700
|
-
console.log(
|
|
6175
|
+
console.log(chalk32.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
5701
6176
|
return;
|
|
5702
6177
|
}
|
|
5703
6178
|
const updated = manager.edit(targetId, updates);
|
|
5704
6179
|
console.log();
|
|
5705
|
-
console.log(
|
|
6180
|
+
console.log(chalk32.green("\u2705 \u7F16\u8F91\u6210\u529F"));
|
|
5706
6181
|
console.log();
|
|
5707
|
-
console.log(` ${
|
|
5708
|
-
console.log(` ${
|
|
6182
|
+
console.log(` ${chalk32.bold(updated.name)} ${chalk32.blue("[MCP]")}`);
|
|
6183
|
+
console.log(` ${chalk32.gray(`\u547D\u4EE4: ${updated.baseUrl} ${updated.apiKey}`)}`);
|
|
5709
6184
|
if (updated.model) {
|
|
5710
6185
|
try {
|
|
5711
6186
|
const env = JSON.parse(updated.model);
|
|
5712
|
-
console.log(
|
|
6187
|
+
console.log(chalk32.gray(` \u73AF\u5883\u53D8\u91CF: ${Object.keys(env).join(", ")}`));
|
|
5713
6188
|
} catch {
|
|
5714
6189
|
}
|
|
5715
6190
|
}
|
|
5716
6191
|
console.log();
|
|
5717
|
-
console.log(
|
|
6192
|
+
console.log(chalk32.green("\u2705 \u914D\u7F6E\u5DF2\u81EA\u52A8\u540C\u6B65\u5230 ~/.claude.json"));
|
|
5718
6193
|
console.log();
|
|
5719
|
-
console.log(
|
|
5720
|
-
console.log(
|
|
6194
|
+
console.log(chalk32.gray("\u914D\u7F6E\u6587\u4EF6:"));
|
|
6195
|
+
console.log(chalk32.gray(` - ${getClaudeConfigPath()}`));
|
|
5721
6196
|
console.log();
|
|
5722
6197
|
} catch (error) {
|
|
5723
|
-
console.error(
|
|
6198
|
+
console.error(chalk32.red(`
|
|
5724
6199
|
\u274C ${error.message}
|
|
5725
6200
|
`));
|
|
5726
6201
|
process.exit(1);
|
|
@@ -5738,15 +6213,38 @@ function createMCPCommands(program2) {
|
|
|
5738
6213
|
|
|
5739
6214
|
// src/commands/gemini/add.ts
|
|
5740
6215
|
init_dist2();
|
|
5741
|
-
import
|
|
5742
|
-
import
|
|
6216
|
+
import chalk33 from "chalk";
|
|
6217
|
+
import inquirer20 from "inquirer";
|
|
5743
6218
|
init_confirm();
|
|
5744
6219
|
function addCommand4(program2) {
|
|
5745
|
-
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Gemini CLI \u670D\u52A1\u5546
|
|
6220
|
+
const command = program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 Gemini CLI \u670D\u52A1\u5546");
|
|
6221
|
+
addProviderAddOptions(command);
|
|
6222
|
+
command.action(async (options) => {
|
|
5746
6223
|
try {
|
|
5747
6224
|
const manager = createGeminiManager();
|
|
5748
|
-
console.log(
|
|
5749
|
-
const
|
|
6225
|
+
console.log(chalk33.bold("\n\u{1F4DD} \u6DFB\u52A0 Gemini CLI \u670D\u52A1\u5546\n"));
|
|
6226
|
+
const resolved = resolveProviderAddInput(options, GEMINI_PRESETS, {
|
|
6227
|
+
allowEmptyBaseUrl: true,
|
|
6228
|
+
allowEmptyApiKey: true
|
|
6229
|
+
});
|
|
6230
|
+
if (resolved.nonInteractive && resolved.input) {
|
|
6231
|
+
const provider2 = manager.add(resolved.input);
|
|
6232
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
6233
|
+
`${chalk33.bold(provider2.name)} ${toolBadge("gemini")}`,
|
|
6234
|
+
chalk33.gray(provider2.baseUrl || "(\u4F7F\u7528\u9ED8\u8BA4\u7AEF\u70B9)")
|
|
6235
|
+
]);
|
|
6236
|
+
if (resolved.switchNow) {
|
|
6237
|
+
manager.switch(provider2.id);
|
|
6238
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [
|
|
6239
|
+
chalk33.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getGeminiSettingsPath()}`),
|
|
6240
|
+
chalk33.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getGeminiEnvPath()}`)
|
|
6241
|
+
]);
|
|
6242
|
+
} else {
|
|
6243
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk33.white(`ccman gm use "${provider2.name}"`)}`);
|
|
6244
|
+
}
|
|
6245
|
+
return;
|
|
6246
|
+
}
|
|
6247
|
+
const { usePreset } = await inquirer20.prompt([
|
|
5750
6248
|
{
|
|
5751
6249
|
type: "list",
|
|
5752
6250
|
name: "usePreset",
|
|
@@ -5762,7 +6260,7 @@ function addCommand4(program2) {
|
|
|
5762
6260
|
let baseUrl;
|
|
5763
6261
|
let apiKey;
|
|
5764
6262
|
if (usePreset) {
|
|
5765
|
-
const { presetName } = await
|
|
6263
|
+
const { presetName } = await inquirer20.prompt([
|
|
5766
6264
|
{
|
|
5767
6265
|
type: "list",
|
|
5768
6266
|
name: "presetName",
|
|
@@ -5774,7 +6272,7 @@ function addCommand4(program2) {
|
|
|
5774
6272
|
}
|
|
5775
6273
|
]);
|
|
5776
6274
|
const preset = GEMINI_PRESETS.find((p) => p.name === presetName);
|
|
5777
|
-
console.log(
|
|
6275
|
+
console.log(chalk33.blue(`
|
|
5778
6276
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
5779
6277
|
`));
|
|
5780
6278
|
const input = await promptProviderForm({
|
|
@@ -5788,7 +6286,7 @@ function addCommand4(program2) {
|
|
|
5788
6286
|
baseUrl = input.baseUrl;
|
|
5789
6287
|
apiKey = input.apiKey;
|
|
5790
6288
|
} else {
|
|
5791
|
-
const answers = await
|
|
6289
|
+
const answers = await inquirer20.prompt([
|
|
5792
6290
|
{
|
|
5793
6291
|
type: "input",
|
|
5794
6292
|
name: "name",
|
|
@@ -5823,25 +6321,22 @@ function addCommand4(program2) {
|
|
|
5823
6321
|
apiKey = answers.apiKey || "";
|
|
5824
6322
|
}
|
|
5825
6323
|
const provider = manager.add({ name, desc, baseUrl, apiKey });
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
console.log(` ${chalk31.gray(provider.baseUrl || "(\u4F7F\u7528\u9ED8\u8BA4\u7AEF\u70B9)")}`);
|
|
5831
|
-
console.log();
|
|
6324
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
6325
|
+
`${chalk33.bold(provider.name)} ${toolBadge("gemini")}`,
|
|
6326
|
+
chalk33.gray(provider.baseUrl || "(\u4F7F\u7528\u9ED8\u8BA4\u7AEF\u70B9)")
|
|
6327
|
+
]);
|
|
5832
6328
|
const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
|
|
5833
6329
|
if (switchNow) {
|
|
5834
6330
|
manager.switch(provider.id);
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
console.log(chalk31.gray(` - ${getGeminiEnvPath()}`));
|
|
6331
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [
|
|
6332
|
+
chalk33.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getGeminiSettingsPath()}`),
|
|
6333
|
+
chalk33.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getGeminiEnvPath()}`)
|
|
6334
|
+
]);
|
|
5840
6335
|
} else {
|
|
5841
|
-
|
|
6336
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk33.white(`ccman gm use "${provider.name}"`)}`);
|
|
5842
6337
|
}
|
|
5843
6338
|
} catch (error) {
|
|
5844
|
-
console.error(
|
|
6339
|
+
console.error(chalk33.red(`
|
|
5845
6340
|
\u274C ${error.message}
|
|
5846
6341
|
`));
|
|
5847
6342
|
process.exit(1);
|
|
@@ -5851,7 +6346,7 @@ function addCommand4(program2) {
|
|
|
5851
6346
|
|
|
5852
6347
|
// src/commands/gemini/list.ts
|
|
5853
6348
|
init_dist2();
|
|
5854
|
-
import
|
|
6349
|
+
import chalk34 from "chalk";
|
|
5855
6350
|
function listCommand4(program2) {
|
|
5856
6351
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 Gemini CLI \u670D\u52A1\u5546").action(async () => {
|
|
5857
6352
|
try {
|
|
@@ -5859,15 +6354,15 @@ function listCommand4(program2) {
|
|
|
5859
6354
|
const providers = manager.list();
|
|
5860
6355
|
const current = manager.getCurrent();
|
|
5861
6356
|
if (providers.length === 0) {
|
|
5862
|
-
|
|
5863
|
-
|
|
6357
|
+
printWarning("\u6682\u65E0 Gemini CLI \u670D\u52A1\u5546");
|
|
6358
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk34.white("ccman gm add"));
|
|
5864
6359
|
return;
|
|
5865
6360
|
}
|
|
5866
|
-
console.log(
|
|
5867
|
-
|
|
5868
|
-
|
|
6361
|
+
console.log(
|
|
6362
|
+
formatProviderTable(providers, current?.id, `Gemini CLI \u670D\u52A1\u5546 (${providers.length} \u4E2A)`)
|
|
6363
|
+
);
|
|
5869
6364
|
} catch (error) {
|
|
5870
|
-
console.error(
|
|
6365
|
+
console.error(chalk34.red(`
|
|
5871
6366
|
\u274C ${error.message}
|
|
5872
6367
|
`));
|
|
5873
6368
|
process.exit(1);
|
|
@@ -5877,16 +6372,16 @@ function listCommand4(program2) {
|
|
|
5877
6372
|
|
|
5878
6373
|
// src/commands/gemini/use.ts
|
|
5879
6374
|
init_dist2();
|
|
5880
|
-
import
|
|
5881
|
-
import
|
|
6375
|
+
import chalk35 from "chalk";
|
|
6376
|
+
import inquirer21 from "inquirer";
|
|
5882
6377
|
function useCommand3(program2) {
|
|
5883
6378
|
program2.command("use [name]").description("\u5207\u6362 Gemini CLI \u670D\u52A1\u5546").action(async (name) => {
|
|
5884
6379
|
try {
|
|
5885
6380
|
const manager = createGeminiManager();
|
|
5886
6381
|
const providers = manager.list();
|
|
5887
6382
|
if (providers.length === 0) {
|
|
5888
|
-
|
|
5889
|
-
|
|
6383
|
+
printWarning("\u6682\u65E0 Gemini CLI \u670D\u52A1\u5546");
|
|
6384
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk35.white("ccman gm add"));
|
|
5890
6385
|
return;
|
|
5891
6386
|
}
|
|
5892
6387
|
let targetId;
|
|
@@ -5897,7 +6392,7 @@ function useCommand3(program2) {
|
|
|
5897
6392
|
}
|
|
5898
6393
|
targetId = provider2.id;
|
|
5899
6394
|
} else {
|
|
5900
|
-
const { selectedId } = await
|
|
6395
|
+
const { selectedId } = await inquirer21.prompt([
|
|
5901
6396
|
{
|
|
5902
6397
|
type: "list",
|
|
5903
6398
|
name: "selectedId",
|
|
@@ -5912,24 +6407,20 @@ function useCommand3(program2) {
|
|
|
5912
6407
|
}
|
|
5913
6408
|
manager.switch(targetId);
|
|
5914
6409
|
const provider = manager.get(targetId);
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
console.log(chalk33.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
5922
|
-
console.log(chalk33.gray(` - ${getGeminiSettingsPath()}`));
|
|
5923
|
-
console.log(chalk33.gray(` - ${getGeminiEnvPath()}`));
|
|
5924
|
-
console.log();
|
|
6410
|
+
printSuccess("\u5207\u6362\u6210\u529F", [
|
|
6411
|
+
`${chalk35.bold(provider.name)} ${toolBadge("gemini")}`,
|
|
6412
|
+
chalk35.gray(`URL: ${provider.baseUrl || "(\u9ED8\u8BA4\u7AEF\u70B9)"}`),
|
|
6413
|
+
chalk35.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getGeminiSettingsPath()}`),
|
|
6414
|
+
chalk35.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getGeminiEnvPath()}`)
|
|
6415
|
+
]);
|
|
5925
6416
|
} catch (error) {
|
|
5926
6417
|
if (error instanceof ProviderNotFoundError) {
|
|
5927
|
-
console.error(
|
|
6418
|
+
console.error(chalk35.red(`
|
|
5928
6419
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${error.message}
|
|
5929
6420
|
`));
|
|
5930
|
-
console.log(
|
|
6421
|
+
console.log(chalk35.blue("\u{1F4A1} \u67E5\u770B\u6240\u6709\u670D\u52A1\u5546:") + chalk35.white(" ccman gm list\n"));
|
|
5931
6422
|
} else {
|
|
5932
|
-
console.error(
|
|
6423
|
+
console.error(chalk35.red(`
|
|
5933
6424
|
\u274C ${error.message}
|
|
5934
6425
|
`));
|
|
5935
6426
|
}
|
|
@@ -5940,23 +6431,30 @@ function useCommand3(program2) {
|
|
|
5940
6431
|
|
|
5941
6432
|
// src/commands/gemini/current.ts
|
|
5942
6433
|
init_dist2();
|
|
5943
|
-
import
|
|
6434
|
+
import chalk36 from "chalk";
|
|
5944
6435
|
function currentCommand3(program2) {
|
|
5945
6436
|
program2.command("current").description("\u663E\u793A\u5F53\u524D Gemini CLI \u670D\u52A1\u5546").action(async () => {
|
|
5946
6437
|
try {
|
|
5947
6438
|
const manager = createGeminiManager();
|
|
5948
6439
|
const current = manager.getCurrent();
|
|
5949
6440
|
if (!current) {
|
|
5950
|
-
|
|
5951
|
-
|
|
6441
|
+
printWarning("\u672A\u9009\u62E9\u4EFB\u4F55 Gemini CLI \u670D\u52A1\u5546");
|
|
6442
|
+
printTip("\u9009\u62E9\u670D\u52A1\u5546: " + chalk36.white("ccman gm use"));
|
|
5952
6443
|
return;
|
|
5953
6444
|
}
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
6445
|
+
const lines = [
|
|
6446
|
+
chalk36.green.bold(current.name),
|
|
6447
|
+
chalk36.gray(`ID: ${current.id}`),
|
|
6448
|
+
chalk36.gray(`URL: ${current.baseUrl || "(\u9ED8\u8BA4\u7AEF\u70B9)"}`)
|
|
6449
|
+
];
|
|
6450
|
+
if (current.lastUsedAt) {
|
|
6451
|
+
lines.push(
|
|
6452
|
+
chalk36.gray(`\u6700\u540E\u4F7F\u7528: ${new Date(current.lastUsedAt).toLocaleString("zh-CN")}`)
|
|
6453
|
+
);
|
|
6454
|
+
}
|
|
6455
|
+
printInfo("\u{1F4CD} \u5F53\u524D Gemini CLI \u670D\u52A1\u5546", lines);
|
|
5958
6456
|
} catch (error) {
|
|
5959
|
-
console.error(
|
|
6457
|
+
console.error(chalk36.red(`
|
|
5960
6458
|
\u274C ${error.message}
|
|
5961
6459
|
`));
|
|
5962
6460
|
process.exit(1);
|
|
@@ -5966,17 +6464,18 @@ function currentCommand3(program2) {
|
|
|
5966
6464
|
|
|
5967
6465
|
// src/commands/gemini/remove.ts
|
|
5968
6466
|
init_dist2();
|
|
5969
|
-
|
|
5970
|
-
import
|
|
5971
|
-
import inquirer24 from "inquirer";
|
|
6467
|
+
import chalk37 from "chalk";
|
|
6468
|
+
import inquirer22 from "inquirer";
|
|
5972
6469
|
function removeCommand4(program2) {
|
|
5973
|
-
program2.command("remove [name]").alias("rm").description("\u5220\u9664 Gemini CLI \u670D\u52A1\u5546")
|
|
6470
|
+
const command = program2.command("remove [name]").alias("rm").description("\u5220\u9664 Gemini CLI \u670D\u52A1\u5546");
|
|
6471
|
+
addProviderRemoveOptions(command);
|
|
6472
|
+
command.action(async (name, options) => {
|
|
5974
6473
|
try {
|
|
5975
6474
|
const manager = createGeminiManager();
|
|
5976
6475
|
const providers = manager.list();
|
|
5977
6476
|
if (providers.length === 0) {
|
|
5978
|
-
console.log(
|
|
5979
|
-
console.log(
|
|
6477
|
+
console.log(chalk37.yellow("\n\u26A0\uFE0F \u6682\u65E0 Gemini CLI \u670D\u52A1\u5546\n"));
|
|
6478
|
+
console.log(chalk37.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + chalk37.white(" ccman gm add\n"));
|
|
5980
6479
|
return;
|
|
5981
6480
|
}
|
|
5982
6481
|
let targetId;
|
|
@@ -5984,15 +6483,14 @@ function removeCommand4(program2) {
|
|
|
5984
6483
|
if (name) {
|
|
5985
6484
|
const provider = manager.findByName(name);
|
|
5986
6485
|
if (!provider) {
|
|
5987
|
-
|
|
5988
|
-
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
5989
|
-
`));
|
|
5990
|
-
process.exit(1);
|
|
6486
|
+
throw new ProviderNotFoundError(name);
|
|
5991
6487
|
}
|
|
5992
6488
|
targetId = provider.id;
|
|
5993
6489
|
targetName = provider.name;
|
|
6490
|
+
} else if (options.yes) {
|
|
6491
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u5220\u9664\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
5994
6492
|
} else {
|
|
5995
|
-
const { selectedId } = await
|
|
6493
|
+
const { selectedId } = await inquirer22.prompt([
|
|
5996
6494
|
{
|
|
5997
6495
|
type: "list",
|
|
5998
6496
|
name: "selectedId",
|
|
@@ -6007,17 +6505,23 @@ function removeCommand4(program2) {
|
|
|
6007
6505
|
targetId = provider.id;
|
|
6008
6506
|
targetName = provider.name;
|
|
6009
6507
|
}
|
|
6010
|
-
const confirm = await
|
|
6508
|
+
const confirm = await confirmProviderRemoval(targetName, options);
|
|
6011
6509
|
if (!confirm) {
|
|
6012
|
-
console.log(
|
|
6510
|
+
console.log(chalk37.gray("\n\u5DF2\u53D6\u6D88\u5220\u9664\n"));
|
|
6013
6511
|
return;
|
|
6014
6512
|
}
|
|
6015
6513
|
manager.remove(targetId);
|
|
6016
|
-
console.log(
|
|
6514
|
+
console.log(chalk37.green("\n\u2705 \u5DF2\u5220\u9664\u670D\u52A1\u5546\n"));
|
|
6017
6515
|
} catch (error) {
|
|
6018
|
-
|
|
6516
|
+
if (error instanceof ProviderNotFoundError) {
|
|
6517
|
+
console.error(chalk37.red(`
|
|
6518
|
+
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6519
|
+
`));
|
|
6520
|
+
} else {
|
|
6521
|
+
console.error(chalk37.red(`
|
|
6019
6522
|
\u274C ${error.message}
|
|
6020
6523
|
`));
|
|
6524
|
+
}
|
|
6021
6525
|
process.exit(1);
|
|
6022
6526
|
}
|
|
6023
6527
|
});
|
|
@@ -6025,30 +6529,35 @@ function removeCommand4(program2) {
|
|
|
6025
6529
|
|
|
6026
6530
|
// src/commands/gemini/edit.ts
|
|
6027
6531
|
init_dist2();
|
|
6028
|
-
import
|
|
6029
|
-
import
|
|
6532
|
+
import chalk38 from "chalk";
|
|
6533
|
+
import inquirer23 from "inquirer";
|
|
6030
6534
|
function editCommand4(program2) {
|
|
6031
|
-
program2.command("edit [name]").description("\u7F16\u8F91 Gemini CLI \u670D\u52A1\u5546")
|
|
6535
|
+
const command = program2.command("edit [name]").description("\u7F16\u8F91 Gemini CLI \u670D\u52A1\u5546");
|
|
6536
|
+
addProviderEditOptions(command);
|
|
6537
|
+
command.action(async (name, options) => {
|
|
6032
6538
|
try {
|
|
6033
6539
|
const manager = createGeminiManager();
|
|
6034
6540
|
const providers = manager.list();
|
|
6035
6541
|
if (providers.length === 0) {
|
|
6036
|
-
console.log(
|
|
6037
|
-
console.log(
|
|
6542
|
+
console.log(chalk38.yellow("\n\u26A0\uFE0F \u6682\u65E0 Gemini CLI \u670D\u52A1\u5546\n"));
|
|
6543
|
+
console.log(chalk38.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + chalk38.white(" ccman gm add\n"));
|
|
6038
6544
|
return;
|
|
6039
6545
|
}
|
|
6546
|
+
const resolved = resolveProviderEditInput(options, {
|
|
6547
|
+
allowEmptyBaseUrl: true,
|
|
6548
|
+
allowEmptyApiKey: true
|
|
6549
|
+
});
|
|
6040
6550
|
let targetId;
|
|
6041
6551
|
if (name) {
|
|
6042
6552
|
const provider2 = manager.findByName(name);
|
|
6043
6553
|
if (!provider2) {
|
|
6044
|
-
|
|
6045
|
-
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6046
|
-
`));
|
|
6047
|
-
process.exit(1);
|
|
6554
|
+
throw new ProviderNotFoundError(name);
|
|
6048
6555
|
}
|
|
6049
6556
|
targetId = provider2.id;
|
|
6557
|
+
} else if (resolved.nonInteractive) {
|
|
6558
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u7F16\u8F91\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
6050
6559
|
} else {
|
|
6051
|
-
const { selectedId } = await
|
|
6560
|
+
const { selectedId } = await inquirer23.prompt([
|
|
6052
6561
|
{
|
|
6053
6562
|
type: "list",
|
|
6054
6563
|
name: "selectedId",
|
|
@@ -6062,6 +6571,15 @@ function editCommand4(program2) {
|
|
|
6062
6571
|
targetId = selectedId;
|
|
6063
6572
|
}
|
|
6064
6573
|
const provider = manager.get(targetId);
|
|
6574
|
+
if (resolved.nonInteractive) {
|
|
6575
|
+
if (Object.keys(resolved.updates).length === 0) {
|
|
6576
|
+
console.log(chalk38.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
6577
|
+
return;
|
|
6578
|
+
}
|
|
6579
|
+
manager.edit(targetId, resolved.updates);
|
|
6580
|
+
console.log(chalk38.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
6581
|
+
return;
|
|
6582
|
+
}
|
|
6065
6583
|
const input = await promptProviderForm({
|
|
6066
6584
|
name: provider.name,
|
|
6067
6585
|
desc: provider.desc ?? "",
|
|
@@ -6074,11 +6592,17 @@ function editCommand4(program2) {
|
|
|
6074
6592
|
baseUrl: input.baseUrl,
|
|
6075
6593
|
apiKey: input.apiKey
|
|
6076
6594
|
});
|
|
6077
|
-
console.log(
|
|
6595
|
+
console.log(chalk38.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
6078
6596
|
} catch (error) {
|
|
6079
|
-
|
|
6597
|
+
if (error instanceof ProviderNotFoundError) {
|
|
6598
|
+
console.error(chalk38.red(`
|
|
6599
|
+
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6600
|
+
`));
|
|
6601
|
+
} else {
|
|
6602
|
+
console.error(chalk38.red(`
|
|
6080
6603
|
\u274C ${error.message}
|
|
6081
6604
|
`));
|
|
6605
|
+
}
|
|
6082
6606
|
process.exit(1);
|
|
6083
6607
|
}
|
|
6084
6608
|
});
|
|
@@ -6086,30 +6610,30 @@ function editCommand4(program2) {
|
|
|
6086
6610
|
|
|
6087
6611
|
// src/commands/gemini/clone.ts
|
|
6088
6612
|
init_dist2();
|
|
6089
|
-
import
|
|
6090
|
-
import
|
|
6613
|
+
import chalk39 from "chalk";
|
|
6614
|
+
import inquirer24 from "inquirer";
|
|
6091
6615
|
function cloneCommand3(program2) {
|
|
6092
6616
|
program2.command("clone [name]").description("\u514B\u9686 Gemini CLI \u670D\u52A1\u5546").action(async (name) => {
|
|
6093
6617
|
try {
|
|
6094
6618
|
const manager = createGeminiManager();
|
|
6095
6619
|
const providers = manager.list();
|
|
6096
6620
|
if (providers.length === 0) {
|
|
6097
|
-
console.log(
|
|
6098
|
-
console.log(
|
|
6621
|
+
console.log(chalk39.yellow("\n\u26A0\uFE0F \u6682\u65E0 Gemini CLI \u670D\u52A1\u5546\n"));
|
|
6622
|
+
console.log(chalk39.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + chalk39.white(" ccman gm add\n"));
|
|
6099
6623
|
return;
|
|
6100
6624
|
}
|
|
6101
6625
|
let sourceId;
|
|
6102
6626
|
if (name) {
|
|
6103
6627
|
const provider = manager.findByName(name);
|
|
6104
6628
|
if (!provider) {
|
|
6105
|
-
console.log(
|
|
6629
|
+
console.log(chalk39.red(`
|
|
6106
6630
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6107
6631
|
`));
|
|
6108
6632
|
process.exit(1);
|
|
6109
6633
|
}
|
|
6110
6634
|
sourceId = provider.id;
|
|
6111
6635
|
} else {
|
|
6112
|
-
const { selectedId } = await
|
|
6636
|
+
const { selectedId } = await inquirer24.prompt([
|
|
6113
6637
|
{
|
|
6114
6638
|
type: "list",
|
|
6115
6639
|
name: "selectedId",
|
|
@@ -6122,7 +6646,7 @@ function cloneCommand3(program2) {
|
|
|
6122
6646
|
]);
|
|
6123
6647
|
sourceId = selectedId;
|
|
6124
6648
|
}
|
|
6125
|
-
const { newName } = await
|
|
6649
|
+
const { newName } = await inquirer24.prompt([
|
|
6126
6650
|
{
|
|
6127
6651
|
type: "input",
|
|
6128
6652
|
name: "newName",
|
|
@@ -6135,13 +6659,13 @@ function cloneCommand3(program2) {
|
|
|
6135
6659
|
]);
|
|
6136
6660
|
const newProvider = manager.clone(sourceId, newName);
|
|
6137
6661
|
console.log();
|
|
6138
|
-
console.log(
|
|
6662
|
+
console.log(chalk39.green("\u2705 \u514B\u9686\u6210\u529F"));
|
|
6139
6663
|
console.log();
|
|
6140
|
-
console.log(` ${
|
|
6141
|
-
console.log(` ${
|
|
6664
|
+
console.log(` ${chalk39.bold(newProvider.name)} ${chalk39.blue("[Gemini CLI]")}`);
|
|
6665
|
+
console.log(` ${chalk39.gray(newProvider.baseUrl || "(\u9ED8\u8BA4\u7AEF\u70B9)")}`);
|
|
6142
6666
|
console.log();
|
|
6143
6667
|
} catch (error) {
|
|
6144
|
-
console.error(
|
|
6668
|
+
console.error(chalk39.red(`
|
|
6145
6669
|
\u274C ${error.message}
|
|
6146
6670
|
`));
|
|
6147
6671
|
process.exit(1);
|
|
@@ -6162,15 +6686,32 @@ function createGeminiCommands(program2) {
|
|
|
6162
6686
|
|
|
6163
6687
|
// src/commands/opencode/add.ts
|
|
6164
6688
|
init_dist2();
|
|
6165
|
-
import
|
|
6166
|
-
import
|
|
6689
|
+
import chalk40 from "chalk";
|
|
6690
|
+
import inquirer25 from "inquirer";
|
|
6167
6691
|
init_confirm();
|
|
6168
6692
|
function addCommand5(program2) {
|
|
6169
|
-
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 OpenCode \u670D\u52A1\u5546
|
|
6693
|
+
const command = program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 OpenCode \u670D\u52A1\u5546");
|
|
6694
|
+
addProviderAddOptions(command);
|
|
6695
|
+
command.action(async (options) => {
|
|
6170
6696
|
try {
|
|
6171
6697
|
const manager = createOpenCodeManager();
|
|
6172
|
-
console.log(
|
|
6173
|
-
const
|
|
6698
|
+
console.log(chalk40.bold("\n\u{1F4DD} \u6DFB\u52A0 OpenCode \u670D\u52A1\u5546\n"));
|
|
6699
|
+
const resolved = resolveProviderAddInput(options, OPENCODE_PRESETS);
|
|
6700
|
+
if (resolved.nonInteractive && resolved.input) {
|
|
6701
|
+
const provider2 = manager.add(resolved.input);
|
|
6702
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
6703
|
+
`${chalk40.bold(provider2.name)} ${toolBadge("opencode")}`,
|
|
6704
|
+
chalk40.gray(provider2.baseUrl)
|
|
6705
|
+
]);
|
|
6706
|
+
if (resolved.switchNow) {
|
|
6707
|
+
manager.switch(provider2.id);
|
|
6708
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [chalk40.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenCodeConfigPath()}`)]);
|
|
6709
|
+
} else {
|
|
6710
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk40.white(`ccman oc use "${provider2.name}"`)}`);
|
|
6711
|
+
}
|
|
6712
|
+
return;
|
|
6713
|
+
}
|
|
6714
|
+
const { usePreset } = await inquirer25.prompt([
|
|
6174
6715
|
{
|
|
6175
6716
|
type: "list",
|
|
6176
6717
|
name: "usePreset",
|
|
@@ -6186,7 +6727,7 @@ function addCommand5(program2) {
|
|
|
6186
6727
|
let baseUrl;
|
|
6187
6728
|
let apiKey;
|
|
6188
6729
|
if (usePreset) {
|
|
6189
|
-
const { presetName } = await
|
|
6730
|
+
const { presetName } = await inquirer25.prompt([
|
|
6190
6731
|
{
|
|
6191
6732
|
type: "list",
|
|
6192
6733
|
name: "presetName",
|
|
@@ -6198,7 +6739,7 @@ function addCommand5(program2) {
|
|
|
6198
6739
|
}
|
|
6199
6740
|
]);
|
|
6200
6741
|
const preset = OPENCODE_PRESETS.find((p) => p.name === presetName);
|
|
6201
|
-
console.log(
|
|
6742
|
+
console.log(chalk40.blue(`
|
|
6202
6743
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
6203
6744
|
`));
|
|
6204
6745
|
const input = await promptProviderForm({
|
|
@@ -6212,7 +6753,7 @@ function addCommand5(program2) {
|
|
|
6212
6753
|
baseUrl = input.baseUrl;
|
|
6213
6754
|
apiKey = input.apiKey;
|
|
6214
6755
|
} else {
|
|
6215
|
-
const answers = await
|
|
6756
|
+
const answers = await inquirer25.prompt([
|
|
6216
6757
|
{
|
|
6217
6758
|
type: "input",
|
|
6218
6759
|
name: "name",
|
|
@@ -6250,24 +6791,19 @@ function addCommand5(program2) {
|
|
|
6250
6791
|
baseUrl,
|
|
6251
6792
|
apiKey
|
|
6252
6793
|
});
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
console.log(` ${chalk38.gray(provider.baseUrl)}`);
|
|
6258
|
-
console.log();
|
|
6794
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
6795
|
+
`${chalk40.bold(provider.name)} ${toolBadge("opencode")}`,
|
|
6796
|
+
chalk40.gray(provider.baseUrl)
|
|
6797
|
+
]);
|
|
6259
6798
|
const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
|
|
6260
6799
|
if (switchNow) {
|
|
6261
6800
|
manager.switch(provider.id);
|
|
6262
|
-
|
|
6263
|
-
console.log();
|
|
6264
|
-
console.log(chalk38.gray("\u914D\u7F6E\u5DF2\u66F4\u65B0:"));
|
|
6265
|
-
console.log(chalk38.gray(` - ${getOpenCodeConfigPath()}`));
|
|
6801
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [chalk40.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenCodeConfigPath()}`)]);
|
|
6266
6802
|
} else {
|
|
6267
|
-
|
|
6803
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk40.white(`ccman oc use "${provider.name}"`)}`);
|
|
6268
6804
|
}
|
|
6269
6805
|
} catch (error) {
|
|
6270
|
-
console.error(
|
|
6806
|
+
console.error(chalk40.red(`
|
|
6271
6807
|
\u274C ${error.message}
|
|
6272
6808
|
`));
|
|
6273
6809
|
process.exit(1);
|
|
@@ -6277,7 +6813,7 @@ function addCommand5(program2) {
|
|
|
6277
6813
|
|
|
6278
6814
|
// src/commands/opencode/list.ts
|
|
6279
6815
|
init_dist2();
|
|
6280
|
-
import
|
|
6816
|
+
import chalk41 from "chalk";
|
|
6281
6817
|
function listCommand5(program2) {
|
|
6282
6818
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 OpenCode \u670D\u52A1\u5546").action(async () => {
|
|
6283
6819
|
try {
|
|
@@ -6285,15 +6821,15 @@ function listCommand5(program2) {
|
|
|
6285
6821
|
const providers = manager.list();
|
|
6286
6822
|
const current = manager.getCurrent();
|
|
6287
6823
|
if (providers.length === 0) {
|
|
6288
|
-
|
|
6289
|
-
|
|
6824
|
+
printWarning("\u6682\u65E0 OpenCode \u670D\u52A1\u5546");
|
|
6825
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk41.white("ccman oc add"));
|
|
6290
6826
|
return;
|
|
6291
6827
|
}
|
|
6292
|
-
console.log(
|
|
6293
|
-
|
|
6294
|
-
|
|
6828
|
+
console.log(
|
|
6829
|
+
formatProviderTable(providers, current?.id, `OpenCode \u670D\u52A1\u5546 (${providers.length} \u4E2A)`)
|
|
6830
|
+
);
|
|
6295
6831
|
} catch (error) {
|
|
6296
|
-
console.error(
|
|
6832
|
+
console.error(chalk41.red(`
|
|
6297
6833
|
\u274C ${error.message}
|
|
6298
6834
|
`));
|
|
6299
6835
|
process.exit(1);
|
|
@@ -6303,16 +6839,16 @@ function listCommand5(program2) {
|
|
|
6303
6839
|
|
|
6304
6840
|
// src/commands/opencode/use.ts
|
|
6305
6841
|
init_dist2();
|
|
6306
|
-
import
|
|
6307
|
-
import
|
|
6842
|
+
import chalk42 from "chalk";
|
|
6843
|
+
import inquirer26 from "inquirer";
|
|
6308
6844
|
function useCommand4(program2) {
|
|
6309
6845
|
program2.command("use [name]").description("\u5207\u6362 OpenCode \u670D\u52A1\u5546").action(async (name) => {
|
|
6310
6846
|
try {
|
|
6311
6847
|
const manager = createOpenCodeManager();
|
|
6312
6848
|
const providers = manager.list();
|
|
6313
6849
|
if (providers.length === 0) {
|
|
6314
|
-
|
|
6315
|
-
|
|
6850
|
+
printWarning("\u6682\u65E0 OpenCode \u670D\u52A1\u5546");
|
|
6851
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk42.white("ccman oc add"));
|
|
6316
6852
|
return;
|
|
6317
6853
|
}
|
|
6318
6854
|
let targetId;
|
|
@@ -6323,7 +6859,7 @@ function useCommand4(program2) {
|
|
|
6323
6859
|
}
|
|
6324
6860
|
targetId = provider2.id;
|
|
6325
6861
|
} else {
|
|
6326
|
-
const { selectedId } = await
|
|
6862
|
+
const { selectedId } = await inquirer26.prompt([
|
|
6327
6863
|
{
|
|
6328
6864
|
type: "list",
|
|
6329
6865
|
name: "selectedId",
|
|
@@ -6338,19 +6874,18 @@ function useCommand4(program2) {
|
|
|
6338
6874
|
}
|
|
6339
6875
|
manager.switch(targetId);
|
|
6340
6876
|
const provider = manager.get(targetId);
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
console.log(chalk40.gray(` - ${getOpenCodeConfigPath()}`));
|
|
6877
|
+
printSuccess("\u5207\u6362\u6210\u529F", [
|
|
6878
|
+
`${chalk42.bold(provider.name)} ${toolBadge("opencode")}`,
|
|
6879
|
+
chalk42.gray(`URL: ${provider.baseUrl}`),
|
|
6880
|
+
chalk42.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenCodeConfigPath()}`)
|
|
6881
|
+
]);
|
|
6347
6882
|
} catch (error) {
|
|
6348
6883
|
if (error instanceof ProviderNotFoundError) {
|
|
6349
|
-
console.error(
|
|
6884
|
+
console.error(chalk42.red(`
|
|
6350
6885
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6351
6886
|
`));
|
|
6352
6887
|
} else {
|
|
6353
|
-
console.error(
|
|
6888
|
+
console.error(chalk42.red(`
|
|
6354
6889
|
\u274C ${error.message}
|
|
6355
6890
|
`));
|
|
6356
6891
|
}
|
|
@@ -6361,23 +6896,30 @@ function useCommand4(program2) {
|
|
|
6361
6896
|
|
|
6362
6897
|
// src/commands/opencode/current.ts
|
|
6363
6898
|
init_dist2();
|
|
6364
|
-
import
|
|
6899
|
+
import chalk43 from "chalk";
|
|
6365
6900
|
function currentCommand4(program2) {
|
|
6366
6901
|
program2.command("current").description("\u663E\u793A\u5F53\u524D OpenCode \u670D\u52A1\u5546").action(async () => {
|
|
6367
6902
|
try {
|
|
6368
6903
|
const manager = createOpenCodeManager();
|
|
6369
6904
|
const current = manager.getCurrent();
|
|
6370
6905
|
if (!current) {
|
|
6371
|
-
|
|
6372
|
-
|
|
6906
|
+
printWarning("\u672A\u9009\u62E9\u4EFB\u4F55 OpenCode \u670D\u52A1\u5546");
|
|
6907
|
+
printTip("\u9009\u62E9\u670D\u52A1\u5546: " + chalk43.white("ccman oc use"));
|
|
6373
6908
|
return;
|
|
6374
6909
|
}
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6910
|
+
const lines = [
|
|
6911
|
+
chalk43.green.bold(current.name),
|
|
6912
|
+
chalk43.gray(`ID: ${current.id}`),
|
|
6913
|
+
chalk43.gray(`URL: ${current.baseUrl}`)
|
|
6914
|
+
];
|
|
6915
|
+
if (current.lastUsedAt) {
|
|
6916
|
+
lines.push(
|
|
6917
|
+
chalk43.gray(`\u6700\u540E\u4F7F\u7528: ${new Date(current.lastUsedAt).toLocaleString("zh-CN")}`)
|
|
6918
|
+
);
|
|
6919
|
+
}
|
|
6920
|
+
printInfo("\u{1F4CD} \u5F53\u524D OpenCode \u670D\u52A1\u5546", lines);
|
|
6379
6921
|
} catch (error) {
|
|
6380
|
-
console.error(
|
|
6922
|
+
console.error(chalk43.red(`
|
|
6381
6923
|
\u274C ${error.message}
|
|
6382
6924
|
`));
|
|
6383
6925
|
process.exit(1);
|
|
@@ -6387,18 +6929,21 @@ function currentCommand4(program2) {
|
|
|
6387
6929
|
|
|
6388
6930
|
// src/commands/opencode/edit.ts
|
|
6389
6931
|
init_dist2();
|
|
6390
|
-
import
|
|
6391
|
-
import
|
|
6932
|
+
import chalk44 from "chalk";
|
|
6933
|
+
import inquirer27 from "inquirer";
|
|
6392
6934
|
function editCommand5(program2) {
|
|
6393
|
-
program2.command("edit [name]").description("\u7F16\u8F91 OpenCode \u670D\u52A1\u5546")
|
|
6935
|
+
const command = program2.command("edit [name]").description("\u7F16\u8F91 OpenCode \u670D\u52A1\u5546");
|
|
6936
|
+
addProviderEditOptions(command);
|
|
6937
|
+
command.action(async (name, options) => {
|
|
6394
6938
|
try {
|
|
6395
6939
|
const manager = createOpenCodeManager();
|
|
6396
6940
|
const providers = manager.list();
|
|
6397
6941
|
if (providers.length === 0) {
|
|
6398
|
-
console.log(
|
|
6399
|
-
console.log(
|
|
6942
|
+
console.log(chalk44.yellow("\n\u26A0\uFE0F \u6682\u65E0 OpenCode \u670D\u52A1\u5546\n"));
|
|
6943
|
+
console.log(chalk44.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + chalk44.white(" ccman oc add\n"));
|
|
6400
6944
|
return;
|
|
6401
6945
|
}
|
|
6946
|
+
const resolved = resolveProviderEditInput(options);
|
|
6402
6947
|
let targetId;
|
|
6403
6948
|
if (name) {
|
|
6404
6949
|
const provider2 = manager.findByName(name);
|
|
@@ -6406,8 +6951,10 @@ function editCommand5(program2) {
|
|
|
6406
6951
|
throw new ProviderNotFoundError(name);
|
|
6407
6952
|
}
|
|
6408
6953
|
targetId = provider2.id;
|
|
6954
|
+
} else if (resolved.nonInteractive) {
|
|
6955
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u7F16\u8F91\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
6409
6956
|
} else {
|
|
6410
|
-
const { selectedId } = await
|
|
6957
|
+
const { selectedId } = await inquirer27.prompt([
|
|
6411
6958
|
{
|
|
6412
6959
|
type: "list",
|
|
6413
6960
|
name: "selectedId",
|
|
@@ -6421,6 +6968,15 @@ function editCommand5(program2) {
|
|
|
6421
6968
|
targetId = selectedId;
|
|
6422
6969
|
}
|
|
6423
6970
|
const provider = manager.get(targetId);
|
|
6971
|
+
if (resolved.nonInteractive) {
|
|
6972
|
+
if (Object.keys(resolved.updates).length === 0) {
|
|
6973
|
+
console.log(chalk44.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
6974
|
+
return;
|
|
6975
|
+
}
|
|
6976
|
+
manager.edit(targetId, resolved.updates);
|
|
6977
|
+
console.log(chalk44.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
6978
|
+
return;
|
|
6979
|
+
}
|
|
6424
6980
|
const input = await promptProviderForm({
|
|
6425
6981
|
name: provider.name,
|
|
6426
6982
|
desc: provider.desc ?? "",
|
|
@@ -6433,14 +6989,14 @@ function editCommand5(program2) {
|
|
|
6433
6989
|
baseUrl: input.baseUrl,
|
|
6434
6990
|
apiKey: input.apiKey
|
|
6435
6991
|
});
|
|
6436
|
-
console.log(
|
|
6992
|
+
console.log(chalk44.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
6437
6993
|
} catch (error) {
|
|
6438
6994
|
if (error instanceof ProviderNotFoundError) {
|
|
6439
|
-
console.error(
|
|
6995
|
+
console.error(chalk44.red(`
|
|
6440
6996
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6441
6997
|
`));
|
|
6442
6998
|
} else {
|
|
6443
|
-
console.error(
|
|
6999
|
+
console.error(chalk44.red(`
|
|
6444
7000
|
\u274C ${error.message}
|
|
6445
7001
|
`));
|
|
6446
7002
|
}
|
|
@@ -6451,16 +7007,17 @@ function editCommand5(program2) {
|
|
|
6451
7007
|
|
|
6452
7008
|
// src/commands/opencode/remove.ts
|
|
6453
7009
|
init_dist2();
|
|
6454
|
-
|
|
6455
|
-
import
|
|
6456
|
-
import inquirer30 from "inquirer";
|
|
7010
|
+
import chalk45 from "chalk";
|
|
7011
|
+
import inquirer28 from "inquirer";
|
|
6457
7012
|
function removeCommand5(program2) {
|
|
6458
|
-
program2.command("remove [name]").alias("rm").description("\u5220\u9664 OpenCode \u670D\u52A1\u5546")
|
|
7013
|
+
const command = program2.command("remove [name]").alias("rm").description("\u5220\u9664 OpenCode \u670D\u52A1\u5546");
|
|
7014
|
+
addProviderRemoveOptions(command);
|
|
7015
|
+
command.action(async (name, options) => {
|
|
6459
7016
|
try {
|
|
6460
7017
|
const manager = createOpenCodeManager();
|
|
6461
7018
|
const providers = manager.list();
|
|
6462
7019
|
if (providers.length === 0) {
|
|
6463
|
-
console.log(
|
|
7020
|
+
console.log(chalk45.yellow("\n\u26A0\uFE0F \u6682\u65E0 OpenCode \u670D\u52A1\u5546\n"));
|
|
6464
7021
|
return;
|
|
6465
7022
|
}
|
|
6466
7023
|
let targetId;
|
|
@@ -6472,8 +7029,10 @@ function removeCommand5(program2) {
|
|
|
6472
7029
|
}
|
|
6473
7030
|
targetId = provider.id;
|
|
6474
7031
|
targetName = provider.name;
|
|
7032
|
+
} else if (options.yes) {
|
|
7033
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u5220\u9664\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
6475
7034
|
} else {
|
|
6476
|
-
const { selectedId } = await
|
|
7035
|
+
const { selectedId } = await inquirer28.prompt([
|
|
6477
7036
|
{
|
|
6478
7037
|
type: "list",
|
|
6479
7038
|
name: "selectedId",
|
|
@@ -6488,22 +7047,22 @@ function removeCommand5(program2) {
|
|
|
6488
7047
|
targetId = selectedId;
|
|
6489
7048
|
targetName = provider.name;
|
|
6490
7049
|
}
|
|
6491
|
-
const confirmed = await
|
|
7050
|
+
const confirmed = await confirmProviderRemoval(targetName, options);
|
|
6492
7051
|
if (!confirmed) {
|
|
6493
|
-
console.log(
|
|
7052
|
+
console.log(chalk45.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
6494
7053
|
return;
|
|
6495
7054
|
}
|
|
6496
7055
|
manager.remove(targetId);
|
|
6497
|
-
console.log(
|
|
7056
|
+
console.log(chalk45.green(`
|
|
6498
7057
|
\u2705 \u5DF2\u5220\u9664: ${targetName}
|
|
6499
7058
|
`));
|
|
6500
7059
|
} catch (error) {
|
|
6501
7060
|
if (error instanceof ProviderNotFoundError) {
|
|
6502
|
-
console.error(
|
|
7061
|
+
console.error(chalk45.red(`
|
|
6503
7062
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6504
7063
|
`));
|
|
6505
7064
|
} else {
|
|
6506
|
-
console.error(
|
|
7065
|
+
console.error(chalk45.red(`
|
|
6507
7066
|
\u274C ${error.message}
|
|
6508
7067
|
`));
|
|
6509
7068
|
}
|
|
@@ -6514,15 +7073,15 @@ function removeCommand5(program2) {
|
|
|
6514
7073
|
|
|
6515
7074
|
// src/commands/opencode/clone.ts
|
|
6516
7075
|
init_dist2();
|
|
6517
|
-
import
|
|
6518
|
-
import
|
|
7076
|
+
import chalk46 from "chalk";
|
|
7077
|
+
import inquirer29 from "inquirer";
|
|
6519
7078
|
function cloneCommand4(program2) {
|
|
6520
7079
|
program2.command("clone [source-name] [new-name]").description("\u514B\u9686 OpenCode \u670D\u52A1\u5546").action(async (sourceName, newName) => {
|
|
6521
7080
|
try {
|
|
6522
7081
|
const manager = createOpenCodeManager();
|
|
6523
7082
|
const providers = manager.list();
|
|
6524
7083
|
if (providers.length === 0) {
|
|
6525
|
-
console.log(
|
|
7084
|
+
console.log(chalk46.yellow("\n\u26A0\uFE0F \u6682\u65E0 OpenCode \u670D\u52A1\u5546\n"));
|
|
6526
7085
|
return;
|
|
6527
7086
|
}
|
|
6528
7087
|
let sourceId;
|
|
@@ -6533,7 +7092,7 @@ function cloneCommand4(program2) {
|
|
|
6533
7092
|
}
|
|
6534
7093
|
sourceId = provider.id;
|
|
6535
7094
|
} else {
|
|
6536
|
-
const { selectedId } = await
|
|
7095
|
+
const { selectedId } = await inquirer29.prompt([
|
|
6537
7096
|
{
|
|
6538
7097
|
type: "list",
|
|
6539
7098
|
name: "selectedId",
|
|
@@ -6551,7 +7110,7 @@ function cloneCommand4(program2) {
|
|
|
6551
7110
|
if (newName) {
|
|
6552
7111
|
cloned = manager.clone(sourceId, newName);
|
|
6553
7112
|
} else {
|
|
6554
|
-
console.log(
|
|
7113
|
+
console.log(chalk46.blue(`
|
|
6555
7114
|
\u514B\u9686\u81EA: ${source.name}
|
|
6556
7115
|
`));
|
|
6557
7116
|
const input = await promptProviderForm({
|
|
@@ -6568,14 +7127,14 @@ function cloneCommand4(program2) {
|
|
|
6568
7127
|
});
|
|
6569
7128
|
}
|
|
6570
7129
|
console.log();
|
|
6571
|
-
console.log(
|
|
7130
|
+
console.log(chalk46.green("\u2705 \u514B\u9686\u6210\u529F"));
|
|
6572
7131
|
console.log();
|
|
6573
|
-
console.log(` ${
|
|
6574
|
-
console.log(` ${
|
|
6575
|
-
console.log(` ${
|
|
7132
|
+
console.log(` ${chalk46.bold(cloned.name)} ${chalk46.blue("[OpenCode]")}`);
|
|
7133
|
+
console.log(` ${chalk46.gray(`ID: ${cloned.id}`)}`);
|
|
7134
|
+
console.log(` ${chalk46.gray(`URL: ${cloned.baseUrl}`)}`);
|
|
6576
7135
|
console.log();
|
|
6577
7136
|
} catch (error) {
|
|
6578
|
-
console.error(
|
|
7137
|
+
console.error(chalk46.red(`
|
|
6579
7138
|
\u274C ${error.message}
|
|
6580
7139
|
`));
|
|
6581
7140
|
process.exit(1);
|
|
@@ -6596,15 +7155,35 @@ function createOpenCodeCommands(program2) {
|
|
|
6596
7155
|
|
|
6597
7156
|
// src/commands/openclaw/add.ts
|
|
6598
7157
|
init_dist2();
|
|
6599
|
-
import
|
|
6600
|
-
import
|
|
7158
|
+
import chalk47 from "chalk";
|
|
7159
|
+
import inquirer30 from "inquirer";
|
|
6601
7160
|
init_confirm();
|
|
6602
7161
|
function addCommand6(program2) {
|
|
6603
|
-
program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 OpenClaw \u670D\u52A1\u5546
|
|
7162
|
+
const command = program2.command("add").description("\u6DFB\u52A0\u65B0\u7684 OpenClaw \u670D\u52A1\u5546");
|
|
7163
|
+
addProviderAddOptions(command);
|
|
7164
|
+
command.action(async (options) => {
|
|
6604
7165
|
try {
|
|
6605
7166
|
const manager = createOpenClawManager();
|
|
6606
|
-
console.log(
|
|
6607
|
-
const
|
|
7167
|
+
console.log(chalk47.bold("\n\u{1F4DD} \u6DFB\u52A0 OpenClaw \u670D\u52A1\u5546\n"));
|
|
7168
|
+
const resolved = resolveProviderAddInput(options, OPENCLAW_PRESETS);
|
|
7169
|
+
if (resolved.nonInteractive && resolved.input) {
|
|
7170
|
+
const provider2 = manager.add(resolved.input);
|
|
7171
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
7172
|
+
`${chalk47.bold(provider2.name)} ${toolBadge("openclaw")}`,
|
|
7173
|
+
chalk47.gray(provider2.baseUrl)
|
|
7174
|
+
]);
|
|
7175
|
+
if (resolved.switchNow) {
|
|
7176
|
+
manager.switch(provider2.id);
|
|
7177
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [
|
|
7178
|
+
chalk47.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenClawConfigPath()}`),
|
|
7179
|
+
chalk47.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenClawModelsPath()}`)
|
|
7180
|
+
]);
|
|
7181
|
+
} else {
|
|
7182
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk47.white(`ccman openclaw use "${provider2.name}"`)}`);
|
|
7183
|
+
}
|
|
7184
|
+
return;
|
|
7185
|
+
}
|
|
7186
|
+
const { usePreset } = await inquirer30.prompt([
|
|
6608
7187
|
{
|
|
6609
7188
|
type: "list",
|
|
6610
7189
|
name: "usePreset",
|
|
@@ -6620,7 +7199,7 @@ function addCommand6(program2) {
|
|
|
6620
7199
|
let baseUrl;
|
|
6621
7200
|
let apiKey;
|
|
6622
7201
|
if (usePreset) {
|
|
6623
|
-
const { presetName } = await
|
|
7202
|
+
const { presetName } = await inquirer30.prompt([
|
|
6624
7203
|
{
|
|
6625
7204
|
type: "list",
|
|
6626
7205
|
name: "presetName",
|
|
@@ -6632,7 +7211,7 @@ function addCommand6(program2) {
|
|
|
6632
7211
|
}
|
|
6633
7212
|
]);
|
|
6634
7213
|
const preset = OPENCLAW_PRESETS.find((p) => p.name === presetName);
|
|
6635
|
-
console.log(
|
|
7214
|
+
console.log(chalk47.blue(`
|
|
6636
7215
|
\u4F7F\u7528\u9884\u8BBE: ${preset.name} - ${preset.description}
|
|
6637
7216
|
`));
|
|
6638
7217
|
const input = await promptProviderForm({
|
|
@@ -6646,7 +7225,7 @@ function addCommand6(program2) {
|
|
|
6646
7225
|
baseUrl = input.baseUrl;
|
|
6647
7226
|
apiKey = input.apiKey;
|
|
6648
7227
|
} else {
|
|
6649
|
-
const answers = await
|
|
7228
|
+
const answers = await inquirer30.prompt([
|
|
6650
7229
|
{
|
|
6651
7230
|
type: "input",
|
|
6652
7231
|
name: "name",
|
|
@@ -6684,27 +7263,22 @@ function addCommand6(program2) {
|
|
|
6684
7263
|
baseUrl,
|
|
6685
7264
|
apiKey
|
|
6686
7265
|
});
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
console.log(` ${chalk45.gray(provider.baseUrl)}`);
|
|
6692
|
-
console.log();
|
|
7266
|
+
printSuccess("\u6DFB\u52A0\u6210\u529F", [
|
|
7267
|
+
`${chalk47.bold(provider.name)} ${toolBadge("openclaw")}`,
|
|
7268
|
+
chalk47.gray(provider.baseUrl)
|
|
7269
|
+
]);
|
|
6693
7270
|
const switchNow = await promptConfirm("\u662F\u5426\u7ACB\u5373\u5207\u6362\u5230\u6B64\u670D\u52A1\u5546?", true);
|
|
6694
7271
|
if (switchNow) {
|
|
6695
7272
|
manager.switch(provider.id);
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
console.log(chalk45.gray(` - ${getOpenClawModelsPath()}`));
|
|
7273
|
+
printSuccess("\u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546", [
|
|
7274
|
+
chalk47.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenClawConfigPath()}`),
|
|
7275
|
+
chalk47.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenClawModelsPath()}`)
|
|
7276
|
+
]);
|
|
6701
7277
|
} else {
|
|
6702
|
-
|
|
6703
|
-
chalk45.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + chalk45.white(` ccman openclaw use "${provider.name}"`)
|
|
6704
|
-
);
|
|
7278
|
+
printTip(`\u7A0D\u540E\u5207\u6362: ${chalk47.white(`ccman openclaw use "${provider.name}"`)}`);
|
|
6705
7279
|
}
|
|
6706
7280
|
} catch (error) {
|
|
6707
|
-
console.error(
|
|
7281
|
+
console.error(chalk47.red(`
|
|
6708
7282
|
\u274C ${error.message}
|
|
6709
7283
|
`));
|
|
6710
7284
|
process.exit(1);
|
|
@@ -6714,7 +7288,7 @@ function addCommand6(program2) {
|
|
|
6714
7288
|
|
|
6715
7289
|
// src/commands/openclaw/list.ts
|
|
6716
7290
|
init_dist2();
|
|
6717
|
-
import
|
|
7291
|
+
import chalk48 from "chalk";
|
|
6718
7292
|
function listCommand6(program2) {
|
|
6719
7293
|
program2.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709 OpenClaw \u670D\u52A1\u5546").action(async () => {
|
|
6720
7294
|
try {
|
|
@@ -6722,15 +7296,15 @@ function listCommand6(program2) {
|
|
|
6722
7296
|
const providers = manager.list();
|
|
6723
7297
|
const current = manager.getCurrent();
|
|
6724
7298
|
if (providers.length === 0) {
|
|
6725
|
-
|
|
6726
|
-
|
|
7299
|
+
printWarning("\u6682\u65E0 OpenClaw \u670D\u52A1\u5546");
|
|
7300
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk48.white("ccman openclaw add"));
|
|
6727
7301
|
return;
|
|
6728
7302
|
}
|
|
6729
|
-
console.log(
|
|
6730
|
-
|
|
6731
|
-
|
|
7303
|
+
console.log(
|
|
7304
|
+
formatProviderTable(providers, current?.id, `OpenClaw \u670D\u52A1\u5546 (${providers.length} \u4E2A)`)
|
|
7305
|
+
);
|
|
6732
7306
|
} catch (error) {
|
|
6733
|
-
console.error(
|
|
7307
|
+
console.error(chalk48.red(`
|
|
6734
7308
|
\u274C ${error.message}
|
|
6735
7309
|
`));
|
|
6736
7310
|
process.exit(1);
|
|
@@ -6740,16 +7314,16 @@ function listCommand6(program2) {
|
|
|
6740
7314
|
|
|
6741
7315
|
// src/commands/openclaw/use.ts
|
|
6742
7316
|
init_dist2();
|
|
6743
|
-
import
|
|
6744
|
-
import
|
|
7317
|
+
import chalk49 from "chalk";
|
|
7318
|
+
import inquirer31 from "inquirer";
|
|
6745
7319
|
function useCommand5(program2) {
|
|
6746
7320
|
program2.command("use [name]").description("\u5207\u6362 OpenClaw \u670D\u52A1\u5546").action(async (name) => {
|
|
6747
7321
|
try {
|
|
6748
7322
|
const manager = createOpenClawManager();
|
|
6749
7323
|
const providers = manager.list();
|
|
6750
7324
|
if (providers.length === 0) {
|
|
6751
|
-
|
|
6752
|
-
|
|
7325
|
+
printWarning("\u6682\u65E0 OpenClaw \u670D\u52A1\u5546");
|
|
7326
|
+
printTip("\u6DFB\u52A0\u670D\u52A1\u5546: " + chalk49.white("ccman openclaw add"));
|
|
6753
7327
|
return;
|
|
6754
7328
|
}
|
|
6755
7329
|
let targetId;
|
|
@@ -6760,7 +7334,7 @@ function useCommand5(program2) {
|
|
|
6760
7334
|
}
|
|
6761
7335
|
targetId = provider2.id;
|
|
6762
7336
|
} else {
|
|
6763
|
-
const { selectedId } = await
|
|
7337
|
+
const { selectedId } = await inquirer31.prompt([
|
|
6764
7338
|
{
|
|
6765
7339
|
type: "list",
|
|
6766
7340
|
name: "selectedId",
|
|
@@ -6775,20 +7349,19 @@ function useCommand5(program2) {
|
|
|
6775
7349
|
}
|
|
6776
7350
|
manager.switch(targetId);
|
|
6777
7351
|
const provider = manager.get(targetId);
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
console.log(chalk47.gray(` - ${getOpenClawModelsPath()}`));
|
|
7352
|
+
printSuccess("\u5207\u6362\u6210\u529F", [
|
|
7353
|
+
`${chalk49.bold(provider.name)} ${toolBadge("openclaw")}`,
|
|
7354
|
+
chalk49.gray(`URL: ${provider.baseUrl}`),
|
|
7355
|
+
chalk49.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenClawConfigPath()}`),
|
|
7356
|
+
chalk49.gray(`\u914D\u7F6E\u5DF2\u66F4\u65B0: ${getOpenClawModelsPath()}`)
|
|
7357
|
+
]);
|
|
6785
7358
|
} catch (error) {
|
|
6786
7359
|
if (error instanceof ProviderNotFoundError) {
|
|
6787
|
-
console.error(
|
|
7360
|
+
console.error(chalk49.red(`
|
|
6788
7361
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6789
7362
|
`));
|
|
6790
7363
|
} else {
|
|
6791
|
-
console.error(
|
|
7364
|
+
console.error(chalk49.red(`
|
|
6792
7365
|
\u274C ${error.message}
|
|
6793
7366
|
`));
|
|
6794
7367
|
}
|
|
@@ -6799,23 +7372,30 @@ function useCommand5(program2) {
|
|
|
6799
7372
|
|
|
6800
7373
|
// src/commands/openclaw/current.ts
|
|
6801
7374
|
init_dist2();
|
|
6802
|
-
import
|
|
7375
|
+
import chalk50 from "chalk";
|
|
6803
7376
|
function currentCommand5(program2) {
|
|
6804
7377
|
program2.command("current").description("\u663E\u793A\u5F53\u524D OpenClaw \u670D\u52A1\u5546").action(async () => {
|
|
6805
7378
|
try {
|
|
6806
7379
|
const manager = createOpenClawManager();
|
|
6807
7380
|
const current = manager.getCurrent();
|
|
6808
7381
|
if (!current) {
|
|
6809
|
-
|
|
6810
|
-
|
|
7382
|
+
printWarning("\u672A\u9009\u62E9\u4EFB\u4F55 OpenClaw \u670D\u52A1\u5546");
|
|
7383
|
+
printTip("\u9009\u62E9\u670D\u52A1\u5546: " + chalk50.white("ccman openclaw use"));
|
|
6811
7384
|
return;
|
|
6812
7385
|
}
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
7386
|
+
const lines = [
|
|
7387
|
+
chalk50.green.bold(current.name),
|
|
7388
|
+
chalk50.gray(`ID: ${current.id}`),
|
|
7389
|
+
chalk50.gray(`URL: ${current.baseUrl}`)
|
|
7390
|
+
];
|
|
7391
|
+
if (current.lastUsedAt) {
|
|
7392
|
+
lines.push(
|
|
7393
|
+
chalk50.gray(`\u6700\u540E\u4F7F\u7528: ${new Date(current.lastUsedAt).toLocaleString("zh-CN")}`)
|
|
7394
|
+
);
|
|
7395
|
+
}
|
|
7396
|
+
printInfo("\u{1F4CD} \u5F53\u524D OpenClaw \u670D\u52A1\u5546", lines);
|
|
6817
7397
|
} catch (error) {
|
|
6818
|
-
console.error(
|
|
7398
|
+
console.error(chalk50.red(`
|
|
6819
7399
|
\u274C ${error.message}
|
|
6820
7400
|
`));
|
|
6821
7401
|
process.exit(1);
|
|
@@ -6825,18 +7405,21 @@ function currentCommand5(program2) {
|
|
|
6825
7405
|
|
|
6826
7406
|
// src/commands/openclaw/edit.ts
|
|
6827
7407
|
init_dist2();
|
|
6828
|
-
import
|
|
6829
|
-
import
|
|
7408
|
+
import chalk51 from "chalk";
|
|
7409
|
+
import inquirer32 from "inquirer";
|
|
6830
7410
|
function editCommand6(program2) {
|
|
6831
|
-
program2.command("edit [name]").description("\u7F16\u8F91 OpenClaw \u670D\u52A1\u5546")
|
|
7411
|
+
const command = program2.command("edit [name]").description("\u7F16\u8F91 OpenClaw \u670D\u52A1\u5546");
|
|
7412
|
+
addProviderEditOptions(command);
|
|
7413
|
+
command.action(async (name, options) => {
|
|
6832
7414
|
try {
|
|
6833
7415
|
const manager = createOpenClawManager();
|
|
6834
7416
|
const providers = manager.list();
|
|
6835
7417
|
if (providers.length === 0) {
|
|
6836
|
-
console.log(
|
|
6837
|
-
console.log(
|
|
7418
|
+
console.log(chalk51.yellow("\n\u26A0\uFE0F \u6682\u65E0 OpenClaw \u670D\u52A1\u5546\n"));
|
|
7419
|
+
console.log(chalk51.blue("\u{1F4A1} \u6DFB\u52A0\u670D\u52A1\u5546:") + chalk51.white(" ccman openclaw add\n"));
|
|
6838
7420
|
return;
|
|
6839
7421
|
}
|
|
7422
|
+
const resolved = resolveProviderEditInput(options);
|
|
6840
7423
|
let targetId;
|
|
6841
7424
|
if (name) {
|
|
6842
7425
|
const provider2 = manager.findByName(name);
|
|
@@ -6844,8 +7427,10 @@ function editCommand6(program2) {
|
|
|
6844
7427
|
throw new ProviderNotFoundError(name);
|
|
6845
7428
|
}
|
|
6846
7429
|
targetId = provider2.id;
|
|
7430
|
+
} else if (resolved.nonInteractive) {
|
|
7431
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u7F16\u8F91\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
6847
7432
|
} else {
|
|
6848
|
-
const { selectedId } = await
|
|
7433
|
+
const { selectedId } = await inquirer32.prompt([
|
|
6849
7434
|
{
|
|
6850
7435
|
type: "list",
|
|
6851
7436
|
name: "selectedId",
|
|
@@ -6859,6 +7444,15 @@ function editCommand6(program2) {
|
|
|
6859
7444
|
targetId = selectedId;
|
|
6860
7445
|
}
|
|
6861
7446
|
const provider = manager.get(targetId);
|
|
7447
|
+
if (resolved.nonInteractive) {
|
|
7448
|
+
if (Object.keys(resolved.updates).length === 0) {
|
|
7449
|
+
console.log(chalk51.gray("\n\u672A\u505A\u4EFB\u4F55\u4FEE\u6539\n"));
|
|
7450
|
+
return;
|
|
7451
|
+
}
|
|
7452
|
+
manager.edit(targetId, resolved.updates);
|
|
7453
|
+
console.log(chalk51.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
7454
|
+
return;
|
|
7455
|
+
}
|
|
6862
7456
|
const input = await promptProviderForm({
|
|
6863
7457
|
name: provider.name,
|
|
6864
7458
|
desc: provider.desc ?? "",
|
|
@@ -6871,14 +7465,14 @@ function editCommand6(program2) {
|
|
|
6871
7465
|
baseUrl: input.baseUrl,
|
|
6872
7466
|
apiKey: input.apiKey
|
|
6873
7467
|
});
|
|
6874
|
-
console.log(
|
|
7468
|
+
console.log(chalk51.green("\n\u2705 \u7F16\u8F91\u6210\u529F\n"));
|
|
6875
7469
|
} catch (error) {
|
|
6876
7470
|
if (error instanceof ProviderNotFoundError) {
|
|
6877
|
-
console.error(
|
|
7471
|
+
console.error(chalk51.red(`
|
|
6878
7472
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6879
7473
|
`));
|
|
6880
7474
|
} else {
|
|
6881
|
-
console.error(
|
|
7475
|
+
console.error(chalk51.red(`
|
|
6882
7476
|
\u274C ${error.message}
|
|
6883
7477
|
`));
|
|
6884
7478
|
}
|
|
@@ -6889,16 +7483,17 @@ function editCommand6(program2) {
|
|
|
6889
7483
|
|
|
6890
7484
|
// src/commands/openclaw/remove.ts
|
|
6891
7485
|
init_dist2();
|
|
6892
|
-
|
|
6893
|
-
import
|
|
6894
|
-
import inquirer35 from "inquirer";
|
|
7486
|
+
import chalk52 from "chalk";
|
|
7487
|
+
import inquirer33 from "inquirer";
|
|
6895
7488
|
function removeCommand6(program2) {
|
|
6896
|
-
program2.command("remove [name]").alias("rm").description("\u5220\u9664 OpenClaw \u670D\u52A1\u5546")
|
|
7489
|
+
const command = program2.command("remove [name]").alias("rm").description("\u5220\u9664 OpenClaw \u670D\u52A1\u5546");
|
|
7490
|
+
addProviderRemoveOptions(command);
|
|
7491
|
+
command.action(async (name, options) => {
|
|
6897
7492
|
try {
|
|
6898
7493
|
const manager = createOpenClawManager();
|
|
6899
7494
|
const providers = manager.list();
|
|
6900
7495
|
if (providers.length === 0) {
|
|
6901
|
-
console.log(
|
|
7496
|
+
console.log(chalk52.yellow("\n\u26A0\uFE0F \u6682\u65E0 OpenClaw \u670D\u52A1\u5546\n"));
|
|
6902
7497
|
return;
|
|
6903
7498
|
}
|
|
6904
7499
|
let targetId;
|
|
@@ -6910,8 +7505,10 @@ function removeCommand6(program2) {
|
|
|
6910
7505
|
}
|
|
6911
7506
|
targetId = provider.id;
|
|
6912
7507
|
targetName = provider.name;
|
|
7508
|
+
} else if (options.yes) {
|
|
7509
|
+
throw new Error("\u975E\u4EA4\u4E92\u6A21\u5F0F\u8BF7\u63D0\u4F9B\u8981\u5220\u9664\u7684\u670D\u52A1\u5546\u540D\u79F0");
|
|
6913
7510
|
} else {
|
|
6914
|
-
const { selectedId } = await
|
|
7511
|
+
const { selectedId } = await inquirer33.prompt([
|
|
6915
7512
|
{
|
|
6916
7513
|
type: "list",
|
|
6917
7514
|
name: "selectedId",
|
|
@@ -6926,22 +7523,22 @@ function removeCommand6(program2) {
|
|
|
6926
7523
|
targetId = selectedId;
|
|
6927
7524
|
targetName = provider.name;
|
|
6928
7525
|
}
|
|
6929
|
-
const confirmed = await
|
|
7526
|
+
const confirmed = await confirmProviderRemoval(targetName, options);
|
|
6930
7527
|
if (!confirmed) {
|
|
6931
|
-
console.log(
|
|
7528
|
+
console.log(chalk52.gray("\n\u5DF2\u53D6\u6D88\n"));
|
|
6932
7529
|
return;
|
|
6933
7530
|
}
|
|
6934
7531
|
manager.remove(targetId);
|
|
6935
|
-
console.log(
|
|
7532
|
+
console.log(chalk52.green(`
|
|
6936
7533
|
\u2705 \u5DF2\u5220\u9664: ${targetName}
|
|
6937
7534
|
`));
|
|
6938
7535
|
} catch (error) {
|
|
6939
7536
|
if (error instanceof ProviderNotFoundError) {
|
|
6940
|
-
console.error(
|
|
7537
|
+
console.error(chalk52.red(`
|
|
6941
7538
|
\u274C \u670D\u52A1\u5546\u4E0D\u5B58\u5728: ${name}
|
|
6942
7539
|
`));
|
|
6943
7540
|
} else {
|
|
6944
|
-
console.error(
|
|
7541
|
+
console.error(chalk52.red(`
|
|
6945
7542
|
\u274C ${error.message}
|
|
6946
7543
|
`));
|
|
6947
7544
|
}
|
|
@@ -6952,15 +7549,15 @@ function removeCommand6(program2) {
|
|
|
6952
7549
|
|
|
6953
7550
|
// src/commands/openclaw/clone.ts
|
|
6954
7551
|
init_dist2();
|
|
6955
|
-
import
|
|
6956
|
-
import
|
|
7552
|
+
import chalk53 from "chalk";
|
|
7553
|
+
import inquirer34 from "inquirer";
|
|
6957
7554
|
function cloneCommand5(program2) {
|
|
6958
7555
|
program2.command("clone [source-name] [new-name]").description("\u514B\u9686 OpenClaw \u670D\u52A1\u5546").action(async (sourceName, newName) => {
|
|
6959
7556
|
try {
|
|
6960
7557
|
const manager = createOpenClawManager();
|
|
6961
7558
|
const providers = manager.list();
|
|
6962
7559
|
if (providers.length === 0) {
|
|
6963
|
-
console.log(
|
|
7560
|
+
console.log(chalk53.yellow("\n\u26A0\uFE0F \u6682\u65E0 OpenClaw \u670D\u52A1\u5546\n"));
|
|
6964
7561
|
return;
|
|
6965
7562
|
}
|
|
6966
7563
|
let sourceId;
|
|
@@ -6971,7 +7568,7 @@ function cloneCommand5(program2) {
|
|
|
6971
7568
|
}
|
|
6972
7569
|
sourceId = provider.id;
|
|
6973
7570
|
} else {
|
|
6974
|
-
const { selectedId } = await
|
|
7571
|
+
const { selectedId } = await inquirer34.prompt([
|
|
6975
7572
|
{
|
|
6976
7573
|
type: "list",
|
|
6977
7574
|
name: "selectedId",
|
|
@@ -6989,7 +7586,7 @@ function cloneCommand5(program2) {
|
|
|
6989
7586
|
if (newName) {
|
|
6990
7587
|
cloned = manager.clone(sourceId, newName);
|
|
6991
7588
|
} else {
|
|
6992
|
-
console.log(
|
|
7589
|
+
console.log(chalk53.blue(`
|
|
6993
7590
|
\u514B\u9686\u81EA: ${source.name}
|
|
6994
7591
|
`));
|
|
6995
7592
|
const input = await promptProviderForm({
|
|
@@ -7006,14 +7603,14 @@ function cloneCommand5(program2) {
|
|
|
7006
7603
|
});
|
|
7007
7604
|
}
|
|
7008
7605
|
console.log();
|
|
7009
|
-
console.log(
|
|
7606
|
+
console.log(chalk53.green("\u2705 \u514B\u9686\u6210\u529F"));
|
|
7010
7607
|
console.log();
|
|
7011
|
-
console.log(` ${
|
|
7012
|
-
console.log(` ${
|
|
7013
|
-
console.log(` ${
|
|
7608
|
+
console.log(` ${chalk53.bold(cloned.name)} ${chalk53.blue("[OpenClaw]")}`);
|
|
7609
|
+
console.log(` ${chalk53.gray(`ID: ${cloned.id}`)}`);
|
|
7610
|
+
console.log(` ${chalk53.gray(`URL: ${cloned.baseUrl}`)}`);
|
|
7014
7611
|
console.log();
|
|
7015
7612
|
} catch (error) {
|
|
7016
|
-
console.error(
|
|
7613
|
+
console.error(chalk53.red(`
|
|
7017
7614
|
\u274C ${error.message}
|
|
7018
7615
|
`));
|
|
7019
7616
|
process.exit(1);
|
|
@@ -7037,40 +7634,40 @@ init_sync();
|
|
|
7037
7634
|
|
|
7038
7635
|
// src/commands/export.ts
|
|
7039
7636
|
init_dist2();
|
|
7040
|
-
import
|
|
7637
|
+
import chalk54 from "chalk";
|
|
7041
7638
|
import path13 from "path";
|
|
7042
7639
|
function exportCommand(program2) {
|
|
7043
7640
|
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) => {
|
|
7044
7641
|
try {
|
|
7045
|
-
console.log(
|
|
7642
|
+
console.log(chalk54.bold("\n\u{1F4E6} \u5BFC\u51FA\u914D\u7F6E\n"));
|
|
7046
7643
|
const validation = validateExport();
|
|
7047
7644
|
if (!validation.valid) {
|
|
7048
|
-
console.log(
|
|
7645
|
+
console.log(chalk54.red(`\u274C ${validation.message}
|
|
7049
7646
|
`));
|
|
7050
7647
|
process.exit(1);
|
|
7051
7648
|
}
|
|
7052
7649
|
const resolvedPath = targetDir.startsWith("~") ? path13.join(process.env.HOME || "", targetDir.slice(1)) : path13.resolve(targetDir);
|
|
7053
7650
|
console.log("\u5BFC\u51FA\u6587\u4EF6\uFF08\u5B58\u5728\u5219\u5BFC\u51FA\uFF0C\u4E0D\u5B58\u5728\u5219\u8DF3\u8FC7\uFF09:");
|
|
7054
|
-
console.log(` ${
|
|
7055
|
-
console.log(` ${
|
|
7056
|
-
console.log(` ${
|
|
7651
|
+
console.log(` ${chalk54.cyan("codex.json")} - Codex \u914D\u7F6E`);
|
|
7652
|
+
console.log(` ${chalk54.cyan("claude.json")} - Claude \u914D\u7F6E`);
|
|
7653
|
+
console.log(` ${chalk54.cyan("openclaw.json")} - OpenClaw \u914D\u7F6E`);
|
|
7057
7654
|
console.log();
|
|
7058
|
-
console.log(`\u76EE\u6807\u76EE\u5F55: ${
|
|
7655
|
+
console.log(`\u76EE\u6807\u76EE\u5F55: ${chalk54.cyan(resolvedPath)}`);
|
|
7059
7656
|
console.log();
|
|
7060
|
-
console.log(
|
|
7657
|
+
console.log(chalk54.yellow("\u26A0\uFE0F \u5BFC\u51FA\u6587\u4EF6\u5305\u542B API Key\uFF0C\u8BF7\u59A5\u5584\u4FDD\u7BA1"));
|
|
7061
7658
|
console.log();
|
|
7062
7659
|
const result = exportConfig(resolvedPath);
|
|
7063
|
-
console.log(
|
|
7660
|
+
console.log(chalk54.green("\u2705 \u5BFC\u51FA\u6210\u529F"));
|
|
7064
7661
|
console.log();
|
|
7065
7662
|
console.log("\u5DF2\u5BFC\u51FA\u6587\u4EF6:");
|
|
7066
7663
|
for (const file of result.exportedFiles) {
|
|
7067
|
-
console.log(` ${
|
|
7664
|
+
console.log(` ${chalk54.cyan("\u2713")} ${file}`);
|
|
7068
7665
|
}
|
|
7069
7666
|
console.log();
|
|
7070
|
-
console.log(
|
|
7667
|
+
console.log(chalk54.blue(`\u{1F4A1} \u5BFC\u5165\u547D\u4EE4: ccman import ${resolvedPath}
|
|
7071
7668
|
`));
|
|
7072
7669
|
} catch (error) {
|
|
7073
|
-
console.error(
|
|
7670
|
+
console.error(chalk54.red(`
|
|
7074
7671
|
\u274C ${error.message}
|
|
7075
7672
|
`));
|
|
7076
7673
|
process.exit(1);
|
|
@@ -7081,66 +7678,66 @@ function exportCommand(program2) {
|
|
|
7081
7678
|
// src/commands/import.ts
|
|
7082
7679
|
init_dist2();
|
|
7083
7680
|
init_confirm();
|
|
7084
|
-
import
|
|
7681
|
+
import chalk55 from "chalk";
|
|
7085
7682
|
import path14 from "path";
|
|
7086
7683
|
function importCommand(program2) {
|
|
7087
7684
|
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) => {
|
|
7088
7685
|
try {
|
|
7089
7686
|
const resolvedPath = sourceDir.startsWith("~") ? path14.join(process.env.HOME || "", sourceDir.slice(1)) : path14.resolve(sourceDir);
|
|
7090
|
-
console.log(
|
|
7687
|
+
console.log(chalk55.bold("\n\u{1F4E5} \u5BFC\u5165\u914D\u7F6E\n"));
|
|
7091
7688
|
const validation = validateImportDir(resolvedPath);
|
|
7092
7689
|
if (!validation.valid) {
|
|
7093
|
-
console.log(
|
|
7690
|
+
console.log(chalk55.red(`\u274C ${validation.message}
|
|
7094
7691
|
`));
|
|
7095
7692
|
process.exit(1);
|
|
7096
7693
|
}
|
|
7097
|
-
console.log(
|
|
7098
|
-
console.log(`\u6E90\u76EE\u5F55: ${
|
|
7694
|
+
console.log(chalk55.yellow("\u26A0\uFE0F \u8B66\u544A\uFF1A\u5BFC\u5165\u5C06\u8986\u76D6\u5F53\u524D\u914D\u7F6E\n"));
|
|
7695
|
+
console.log(`\u6E90\u76EE\u5F55: ${chalk55.cyan(resolvedPath)}`);
|
|
7099
7696
|
console.log();
|
|
7100
7697
|
console.log("\u627E\u5230\u914D\u7F6E\u6587\u4EF6:");
|
|
7101
7698
|
for (const file of validation.foundFiles) {
|
|
7102
|
-
console.log(` ${
|
|
7699
|
+
console.log(` ${chalk55.cyan("\u2713")} ${file}`);
|
|
7103
7700
|
}
|
|
7104
7701
|
console.log();
|
|
7105
|
-
console.log(
|
|
7702
|
+
console.log(chalk55.gray("\u672A\u627E\u5230\u7684\u53D7\u652F\u6301\u6587\u4EF6\u5C06\u81EA\u52A8\u8DF3\u8FC7\uFF0C\u4E0D\u4F1A\u4E2D\u65AD\u5BFC\u5165"));
|
|
7106
7703
|
console.log();
|
|
7107
|
-
console.log(
|
|
7704
|
+
console.log(chalk55.gray("\u5F53\u524D\u914D\u7F6E\u5C06\u88AB\u8986\u76D6\uFF08\u81EA\u52A8\u5907\u4EFD\uFF09"));
|
|
7108
7705
|
console.log();
|
|
7109
7706
|
const confirmFirst = await promptConfirm("\u786E\u8BA4\u5BFC\u5165\uFF1F", false);
|
|
7110
7707
|
if (!confirmFirst) {
|
|
7111
|
-
console.log(
|
|
7708
|
+
console.log(chalk55.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
7112
7709
|
return;
|
|
7113
7710
|
}
|
|
7114
7711
|
console.log();
|
|
7115
|
-
console.log(
|
|
7712
|
+
console.log(chalk55.red.bold("\u26A0\uFE0F \u6700\u540E\u786E\u8BA4\uFF1A\u6B64\u64CD\u4F5C\u5C06\u8986\u76D6\u6240\u6709\u5F53\u524D\u914D\u7F6E\uFF01"));
|
|
7116
7713
|
console.log();
|
|
7117
7714
|
const confirmSecond = await promptConfirm("\u771F\u7684\u8981\u7EE7\u7EED\u5417\uFF1F", false);
|
|
7118
7715
|
if (!confirmSecond) {
|
|
7119
|
-
console.log(
|
|
7716
|
+
console.log(chalk55.gray("\n\u274C \u5DF2\u53D6\u6D88\n"));
|
|
7120
7717
|
return;
|
|
7121
7718
|
}
|
|
7122
7719
|
console.log();
|
|
7123
|
-
console.log(
|
|
7124
|
-
console.log(
|
|
7720
|
+
console.log(chalk55.gray("\u{1F4BE} \u5907\u4EFD\u5F53\u524D\u914D\u7F6E..."));
|
|
7721
|
+
console.log(chalk55.gray("\u{1F4E5} \u5BFC\u5165\u65B0\u914D\u7F6E..."));
|
|
7125
7722
|
const result = importConfig(resolvedPath);
|
|
7126
7723
|
console.log();
|
|
7127
|
-
console.log(
|
|
7724
|
+
console.log(chalk55.green("\u2705 \u5BFC\u5165\u6210\u529F"));
|
|
7128
7725
|
console.log();
|
|
7129
7726
|
if (result.backupPaths.length > 0) {
|
|
7130
7727
|
console.log("\u5907\u4EFD\u6587\u4EF6:");
|
|
7131
7728
|
for (const backupPath of result.backupPaths) {
|
|
7132
|
-
console.log(` ${
|
|
7729
|
+
console.log(` ${chalk55.gray(backupPath)}`);
|
|
7133
7730
|
}
|
|
7134
7731
|
console.log();
|
|
7135
7732
|
}
|
|
7136
7733
|
console.log("\u5DF2\u5BFC\u5165\u6587\u4EF6:");
|
|
7137
7734
|
for (const file of result.importedFiles) {
|
|
7138
|
-
console.log(` ${
|
|
7735
|
+
console.log(` ${chalk55.cyan("\u2713")} ${file}`);
|
|
7139
7736
|
}
|
|
7140
7737
|
console.log();
|
|
7141
|
-
console.log(
|
|
7738
|
+
console.log(chalk55.blue("\u{1F4A1} \u8BF7\u4F7F\u7528 'ccman cx use' \u6216 'ccman cc use' \u5207\u6362\u670D\u52A1\u5546\n"));
|
|
7142
7739
|
} catch (error) {
|
|
7143
|
-
console.error(
|
|
7740
|
+
console.error(chalk55.red(`
|
|
7144
7741
|
\u274C ${error.message}
|
|
7145
7742
|
`));
|
|
7146
7743
|
process.exit(1);
|
|
@@ -7152,8 +7749,8 @@ function importCommand(program2) {
|
|
|
7152
7749
|
init_dist2();
|
|
7153
7750
|
import fs13 from "fs";
|
|
7154
7751
|
import path15 from "path";
|
|
7155
|
-
import
|
|
7156
|
-
import
|
|
7752
|
+
import chalk56 from "chalk";
|
|
7753
|
+
import inquirer35 from "inquirer";
|
|
7157
7754
|
|
|
7158
7755
|
// src/utils/endpoint-latency.ts
|
|
7159
7756
|
import { request as httpRequest } from "http";
|
|
@@ -7278,7 +7875,7 @@ var GMN_PROFILE = {
|
|
|
7278
7875
|
baseUrls: [
|
|
7279
7876
|
{
|
|
7280
7877
|
label: "GMN \u4E3B\u7AD9",
|
|
7281
|
-
url: "https://
|
|
7878
|
+
url: "https://ai.gmncode.com",
|
|
7282
7879
|
description: "GMN \u4E3B\u57DF\u540D\u5165\u53E3"
|
|
7283
7880
|
},
|
|
7284
7881
|
{
|
|
@@ -7345,7 +7942,7 @@ function renderStep(current, total, title) {
|
|
|
7345
7942
|
function printBanner(title) {
|
|
7346
7943
|
printLogo();
|
|
7347
7944
|
console.log(
|
|
7348
|
-
|
|
7945
|
+
chalk56.cyanBright(
|
|
7349
7946
|
[
|
|
7350
7947
|
" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557",
|
|
7351
7948
|
" \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551",
|
|
@@ -7357,11 +7954,11 @@ function printBanner(title) {
|
|
|
7357
7954
|
].join("\n")
|
|
7358
7955
|
)
|
|
7359
7956
|
);
|
|
7360
|
-
console.log(
|
|
7957
|
+
console.log(chalk56.gray("\u81EA\u52A8\u5199\u5165\u9009\u4E2D\u5DE5\u5177\u914D\u7F6E\uFF0C\u652F\u6301\u591A\u9009\u3002\n"));
|
|
7361
7958
|
}
|
|
7362
7959
|
function printKeyNotice() {
|
|
7363
7960
|
console.log(
|
|
7364
|
-
|
|
7961
|
+
chalk56.yellow(
|
|
7365
7962
|
[
|
|
7366
7963
|
"\u63D0\u793A\uFF1A\u672C\u547D\u4EE4\u652F\u6301 Codex\u3001OpenCode\u3001OpenClaw \u4E09\u4E2A\u5E73\u53F0\u3002",
|
|
7367
7964
|
"Codex \u4E0E OpenCode \u5171\u4EAB OpenAI \u7AEF\u70B9\uFF1BOpenClaw \u4F7F\u7528 /v1 \u7AEF\u70B9\u3002",
|
|
@@ -7371,22 +7968,22 @@ function printKeyNotice() {
|
|
|
7371
7968
|
);
|
|
7372
7969
|
}
|
|
7373
7970
|
function printWriteTargets(platforms) {
|
|
7374
|
-
console.log(
|
|
7971
|
+
console.log(chalk56.gray(`\u5199\u5165\u76EE\u5F55: ${getCcmanDir()}`));
|
|
7375
7972
|
if (platforms.includes("codex")) {
|
|
7376
|
-
console.log(
|
|
7377
|
-
console.log(
|
|
7973
|
+
console.log(chalk56.gray(` - Codex: ${getCodexConfigPath()}`));
|
|
7974
|
+
console.log(chalk56.gray(` - Codex: ${getCodexAuthPath()}`));
|
|
7378
7975
|
}
|
|
7379
7976
|
if (platforms.includes("opencode")) {
|
|
7380
|
-
console.log(
|
|
7977
|
+
console.log(chalk56.gray(` - OpenCode: ${getOpenCodeConfigPath()}`));
|
|
7381
7978
|
}
|
|
7382
7979
|
if (platforms.includes("openclaw")) {
|
|
7383
|
-
console.log(
|
|
7384
|
-
console.log(
|
|
7980
|
+
console.log(chalk56.gray(` - OpenClaw: ${getOpenClawConfigPath()}`));
|
|
7981
|
+
console.log(chalk56.gray(` - OpenClaw: ${getOpenClawModelsPath()}`));
|
|
7385
7982
|
}
|
|
7386
7983
|
const env = process.env.NODE_ENV;
|
|
7387
7984
|
if (env === "development" || env === "test") {
|
|
7388
7985
|
console.log(
|
|
7389
|
-
|
|
7986
|
+
chalk56.yellow(
|
|
7390
7987
|
`\u26A0\uFE0F \u5F53\u524D NODE_ENV=${env}\uFF0C\u5C06\u5199\u5165\u5F00\u53D1/\u6D4B\u8BD5\u76EE\u5F55\uFF1B\u5982\u9700\u5199\u5165\u771F\u5B9E HOME\uFF0C\u8BF7\u5728\u751F\u4EA7\u73AF\u5883\u8FD0\u884C\uFF08unset NODE_ENV\uFF09\u3002`
|
|
7391
7988
|
)
|
|
7392
7989
|
);
|
|
@@ -7405,7 +8002,7 @@ function parsePlatforms(platformArg) {
|
|
|
7405
8002
|
return platforms;
|
|
7406
8003
|
}
|
|
7407
8004
|
async function promptApiKey(title) {
|
|
7408
|
-
const answers = await
|
|
8005
|
+
const answers = await inquirer35.prompt([
|
|
7409
8006
|
{
|
|
7410
8007
|
type: "password",
|
|
7411
8008
|
name: "apiKey",
|
|
@@ -7420,7 +8017,7 @@ async function promptApiKey(title) {
|
|
|
7420
8017
|
return answers.apiKey.trim();
|
|
7421
8018
|
}
|
|
7422
8019
|
async function promptPlatforms(title) {
|
|
7423
|
-
const answers = await
|
|
8020
|
+
const answers = await inquirer35.prompt([
|
|
7424
8021
|
{
|
|
7425
8022
|
type: "checkbox",
|
|
7426
8023
|
name: "platforms",
|
|
@@ -7466,20 +8063,20 @@ function buildProbeCandidates(baseUrls, platforms) {
|
|
|
7466
8063
|
}
|
|
7467
8064
|
function printBaseUrlProbeResults(profile, results, platforms) {
|
|
7468
8065
|
const usingOpenClawPath = platforms.length === 1 && platforms[0] === "openclaw";
|
|
7469
|
-
console.log(
|
|
7470
|
-
console.log(
|
|
8066
|
+
console.log(chalk56.bold(`\u5F53\u524D\u6D4B\u901F\u8303\u56F4\uFF1A${profile.endpointGroupLabel}`));
|
|
8067
|
+
console.log(chalk56.gray(`${profile.endpointGroupDescription}\uFF08\u5171 ${results.length} \u6761\uFF09`));
|
|
7471
8068
|
console.log(
|
|
7472
|
-
|
|
8069
|
+
chalk56.gray(
|
|
7473
8070
|
`\u6D4B\u901F\u65B9\u5F0F\uFF1AHTTPS \u9996\u5305\u5EF6\u8FDF\uFF08${BASE_URL_PROBE_SAMPLE_COUNT} \u6B21\u4E2D\u4F4D\u6570\uFF09${usingOpenClawPath ? "\uFF0C\u5F53\u524D\u4EC5\u68C0\u6D4B OpenClaw \u7684 /v1 \u7AEF\u70B9" : ""}`
|
|
7474
8071
|
)
|
|
7475
8072
|
);
|
|
7476
8073
|
console.log();
|
|
7477
8074
|
for (const [index, result] of results.entries()) {
|
|
7478
|
-
const latencyText = result.latencyMs === null ?
|
|
7479
|
-
console.log(` ${
|
|
7480
|
-
console.log(
|
|
7481
|
-
console.log(
|
|
7482
|
-
console.log(
|
|
8075
|
+
const latencyText = result.latencyMs === null ? chalk56.red(formatLatency(result)) : chalk56.green(formatLatency(result));
|
|
8076
|
+
console.log(` ${chalk56.cyan(`${index + 1}. ${result.label}`)}`);
|
|
8077
|
+
console.log(chalk56.gray(` \u57DF\u540D: ${getEndpointHost(result.url)}`));
|
|
8078
|
+
console.log(chalk56.gray(` \u5730\u5740: ${result.url}`));
|
|
8079
|
+
console.log(chalk56.gray(` \u8BF4\u660E: ${result.description}`));
|
|
7483
8080
|
console.log(` \u5EF6\u8FDF: ${latencyText}`);
|
|
7484
8081
|
console.log();
|
|
7485
8082
|
}
|
|
@@ -7487,7 +8084,7 @@ function printBaseUrlProbeResults(profile, results, platforms) {
|
|
|
7487
8084
|
async function resolveOpenAiBaseUrl(profile, platforms, baseUrlArg) {
|
|
7488
8085
|
if (baseUrlArg && baseUrlArg.trim().length > 0) {
|
|
7489
8086
|
const normalized = normalizeEndpointUrl(baseUrlArg);
|
|
7490
|
-
console.log(
|
|
8087
|
+
console.log(chalk56.gray(`\u5DF2\u901A\u8FC7\u53C2\u6570\u6307\u5B9A Base URL: ${normalized}`));
|
|
7491
8088
|
return normalized;
|
|
7492
8089
|
}
|
|
7493
8090
|
const probeResults = sortEndpointProbeResults(
|
|
@@ -7503,19 +8100,19 @@ async function resolveOpenAiBaseUrl(profile, platforms, baseUrlArg) {
|
|
|
7503
8100
|
const defaultResult = pickDefaultEndpoint(probeResults) || probeResults[0];
|
|
7504
8101
|
const allFailed = probeResults.every((result) => result.latencyMs === null);
|
|
7505
8102
|
if (allFailed) {
|
|
7506
|
-
console.log(
|
|
8103
|
+
console.log(chalk56.yellow("\u26A0\uFE0F \u6240\u6709\u5019\u9009\u5730\u5740\u6D4B\u901F\u5931\u8D25\uFF0C\u5C06\u9ED8\u8BA4\u9009\u4E2D\u7B2C\u4E00\u4E2A\u5730\u5740\uFF0C\u4F60\u4E5F\u53EF\u4EE5\u624B\u52A8\u5207\u6362\u3002"));
|
|
7507
8104
|
} else {
|
|
7508
|
-
console.log(
|
|
8105
|
+
console.log(chalk56.gray(`\u9ED8\u8BA4\u5DF2\u9009\u6700\u4F4E\u5EF6\u8FDF\u7EBF\u8DEF\uFF1A${defaultResult.url}`));
|
|
7509
8106
|
}
|
|
7510
8107
|
if (probeResults.length === 1) {
|
|
7511
|
-
console.log(
|
|
8108
|
+
console.log(chalk56.green(`\u5DF2\u81EA\u52A8\u9009\u62E9: ${defaultResult.url}`));
|
|
7512
8109
|
return defaultResult.url;
|
|
7513
8110
|
}
|
|
7514
8111
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
7515
|
-
console.log(
|
|
8112
|
+
console.log(chalk56.yellow(`\u975E\u4EA4\u4E92\u73AF\u5883\uFF0C\u5DF2\u81EA\u52A8\u4F7F\u7528\u9ED8\u8BA4\u5730\u5740\uFF1A${defaultResult.url}`));
|
|
7516
8113
|
return defaultResult.url;
|
|
7517
8114
|
}
|
|
7518
|
-
const answers = await
|
|
8115
|
+
const answers = await inquirer35.prompt([
|
|
7519
8116
|
{
|
|
7520
8117
|
type: "list",
|
|
7521
8118
|
name: "baseUrl",
|
|
@@ -7623,24 +8220,24 @@ async function runGmnCommand(profile, apiKey, platformArg, providerNameArg, base
|
|
|
7623
8220
|
let platforms;
|
|
7624
8221
|
let providerName;
|
|
7625
8222
|
try {
|
|
7626
|
-
console.log(
|
|
8223
|
+
console.log(chalk56.cyan(`
|
|
7627
8224
|
${renderStep(1, TOTAL_STEPS, "\u9009\u62E9\u8981\u914D\u7F6E\u7684\u5DE5\u5177")}`));
|
|
7628
8225
|
platforms = await resolvePlatforms(platformArg, profile.title);
|
|
7629
8226
|
providerName = resolveProviderName2(profile, providerNameArg);
|
|
7630
8227
|
} catch (error) {
|
|
7631
|
-
console.error(
|
|
8228
|
+
console.error(chalk56.red(`\u274C ${error.message}`));
|
|
7632
8229
|
process.exit(1);
|
|
7633
8230
|
}
|
|
7634
|
-
console.log(
|
|
7635
|
-
console.log(
|
|
8231
|
+
console.log(chalk56.gray(`\u5DF2\u9009\u62E9: ${platforms.join(", ")}`));
|
|
8232
|
+
console.log(chalk56.gray(`\u670D\u52A1\u5546\u540D\u79F0: ${providerName}`));
|
|
7636
8233
|
printKeyNotice();
|
|
7637
|
-
console.log(
|
|
8234
|
+
console.log(chalk56.cyan(`
|
|
7638
8235
|
${renderStep(2, TOTAL_STEPS, "\u6D4B\u901F\u5E76\u9009\u62E9 Base URL")}`));
|
|
7639
8236
|
let openaiBaseUrl;
|
|
7640
8237
|
try {
|
|
7641
8238
|
openaiBaseUrl = await resolveOpenAiBaseUrl(profile, platforms, baseUrlArg);
|
|
7642
8239
|
} catch (error) {
|
|
7643
|
-
console.error(
|
|
8240
|
+
console.error(chalk56.red(`\u274C ${error.message}`));
|
|
7644
8241
|
process.exit(1);
|
|
7645
8242
|
}
|
|
7646
8243
|
const openclawBaseUrl = buildOpenClawBaseUrl(openaiBaseUrl);
|
|
@@ -7650,23 +8247,23 @@ ${renderStep(2, TOTAL_STEPS, "\u6D4B\u901F\u5E76\u9009\u62E9 Base URL")}`));
|
|
|
7650
8247
|
openclaw: openclawBaseUrl
|
|
7651
8248
|
};
|
|
7652
8249
|
let resolvedApiKey = apiKey?.trim();
|
|
7653
|
-
console.log(
|
|
8250
|
+
console.log(chalk56.cyan(`
|
|
7654
8251
|
${renderStep(3, TOTAL_STEPS, "\u8F93\u5165 API Key")}`));
|
|
7655
8252
|
if (!resolvedApiKey) {
|
|
7656
8253
|
resolvedApiKey = await promptApiKey(profile.title);
|
|
7657
8254
|
} else {
|
|
7658
|
-
console.log(
|
|
8255
|
+
console.log(chalk56.gray("\u5DF2\u901A\u8FC7\u53C2\u6570\u63D0\u4F9B API Key\uFF08\u5DF2\u9690\u85CF\uFF09"));
|
|
7659
8256
|
}
|
|
7660
8257
|
if (!resolvedApiKey?.trim()) {
|
|
7661
|
-
console.error(
|
|
8258
|
+
console.error(chalk56.red("\u274C \u9519\u8BEF: API Key \u4E0D\u80FD\u4E3A\u7A7A"));
|
|
7662
8259
|
process.exit(1);
|
|
7663
8260
|
}
|
|
7664
|
-
console.log(
|
|
8261
|
+
console.log(chalk56.cyan(`
|
|
7665
8262
|
${renderStep(4, TOTAL_STEPS, "\u5F00\u59CB\u5199\u5165\u914D\u7F6E")}`));
|
|
7666
|
-
console.log(
|
|
7667
|
-
console.log(
|
|
8263
|
+
console.log(chalk56.gray(`\u5DF2\u9009\u62E9\u5E73\u53F0: ${platforms.join(", ")}`));
|
|
8264
|
+
console.log(chalk56.gray(`OpenAI Base URL: ${openaiBaseUrl}`));
|
|
7668
8265
|
if (platforms.includes("openclaw")) {
|
|
7669
|
-
console.log(
|
|
8266
|
+
console.log(chalk56.gray(`OpenClaw Base URL: ${openclawBaseUrl}`));
|
|
7670
8267
|
}
|
|
7671
8268
|
printWriteTargets(platforms);
|
|
7672
8269
|
console.log();
|
|
@@ -7676,7 +8273,7 @@ ${renderStep(4, TOTAL_STEPS, "\u5F00\u59CB\u5199\u5165\u914D\u7F6E")}`));
|
|
|
7676
8273
|
`${profile.commandName}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
|
7677
8274
|
);
|
|
7678
8275
|
fs13.mkdirSync(backupRootDir, { recursive: true, mode: 448 });
|
|
7679
|
-
console.log(
|
|
8276
|
+
console.log(chalk56.gray(`\u5907\u4EFD\u6839\u76EE\u5F55: ${backupRootDir}`));
|
|
7680
8277
|
console.log();
|
|
7681
8278
|
const ALL_TOOLS = {
|
|
7682
8279
|
codex: { name: "Codex", manager: createCodexManager() },
|
|
@@ -7692,13 +8289,13 @@ ${renderStep(4, TOTAL_STEPS, "\u5F00\u59CB\u5199\u5165\u914D\u7F6E")}`));
|
|
|
7692
8289
|
for (const { platform, name, manager } of tools) {
|
|
7693
8290
|
let backupResult = null;
|
|
7694
8291
|
try {
|
|
7695
|
-
console.log(
|
|
8292
|
+
console.log(chalk56.gray(`\u2192 \u914D\u7F6E ${name}...`));
|
|
7696
8293
|
backupResult = createPlatformBackupOrThrow(platform, backupRootDir);
|
|
7697
8294
|
const backupFiles = backupResult.entries.map((entry) => entry.backupPath).filter((p) => p !== null);
|
|
7698
8295
|
if (backupFiles.length > 0) {
|
|
7699
|
-
console.log(
|
|
8296
|
+
console.log(chalk56.gray(` \u5DF2\u5907\u4EFD ${backupFiles.length} \u4E2A\u6587\u4EF6`));
|
|
7700
8297
|
} else {
|
|
7701
|
-
console.log(
|
|
8298
|
+
console.log(chalk56.gray(" \u65E0\u5386\u53F2\u6587\u4EF6\u53EF\u5907\u4EFD"));
|
|
7702
8299
|
}
|
|
7703
8300
|
const baseUrl = platformBaseUrls[platform];
|
|
7704
8301
|
const existing = findPreferredProvider(manager.list(), providerName);
|
|
@@ -7709,7 +8306,7 @@ ${renderStep(4, TOTAL_STEPS, "\u5F00\u59CB\u5199\u5165\u914D\u7F6E")}`));
|
|
|
7709
8306
|
) : manager.add({ name: providerName, baseUrl, apiKey: resolvedApiKey });
|
|
7710
8307
|
manager.switch(provider.id, { mode: "overwrite" });
|
|
7711
8308
|
completed += 1;
|
|
7712
|
-
console.log(
|
|
8309
|
+
console.log(chalk56.green(`\u2705 ${name}`));
|
|
7713
8310
|
successBackups.push({
|
|
7714
8311
|
name,
|
|
7715
8312
|
backupDir: backupResult.backupDir,
|
|
@@ -7720,38 +8317,38 @@ ${renderStep(4, TOTAL_STEPS, "\u5F00\u59CB\u5199\u5165\u914D\u7F6E")}`));
|
|
|
7720
8317
|
if (backupResult !== null) {
|
|
7721
8318
|
try {
|
|
7722
8319
|
rollbackFromBackupOrThrow(backupResult);
|
|
7723
|
-
console.error(
|
|
8320
|
+
console.error(chalk56.red(`\u274C ${name}: ${operationError.message}\uFF08\u5DF2\u56DE\u6EDA\u5386\u53F2\u6587\u4EF6\uFF09`));
|
|
7724
8321
|
} catch (rollbackError) {
|
|
7725
8322
|
console.error(
|
|
7726
|
-
|
|
8323
|
+
chalk56.red(
|
|
7727
8324
|
`\u274C ${name}: ${operationError.message}\uFF1B\u56DE\u6EDA\u4E5F\u5931\u8D25: ${rollbackError.message}`
|
|
7728
8325
|
)
|
|
7729
8326
|
);
|
|
7730
8327
|
}
|
|
7731
8328
|
} else {
|
|
7732
|
-
console.error(
|
|
8329
|
+
console.error(chalk56.red(`\u274C ${name}: ${operationError.message}`));
|
|
7733
8330
|
}
|
|
7734
8331
|
}
|
|
7735
8332
|
}
|
|
7736
|
-
console.log(
|
|
8333
|
+
console.log(chalk56.green(`
|
|
7737
8334
|
\u{1F389} ${profile.title} \u914D\u7F6E\u5B8C\u6210\uFF01(${completed}/${tools.length})`));
|
|
7738
8335
|
console.log();
|
|
7739
|
-
console.log(
|
|
8336
|
+
console.log(chalk56.bold("\u5907\u4EFD\u4FE1\u606F:"));
|
|
7740
8337
|
if (successBackups.length === 0) {
|
|
7741
|
-
console.log(
|
|
8338
|
+
console.log(chalk56.gray(" \u65E0\u6210\u529F\u914D\u7F6E\u9879\uFF0C\u672A\u751F\u6210\u53EF\u7528\u5907\u4EFD\u76EE\u5F55\u3002"));
|
|
7742
8339
|
} else {
|
|
7743
8340
|
for (const item of successBackups) {
|
|
7744
|
-
console.log(
|
|
8341
|
+
console.log(chalk56.gray(` ${item.name}: ${item.backupDir}`));
|
|
7745
8342
|
if (item.backupFiles.length === 0) {
|
|
7746
|
-
console.log(
|
|
8343
|
+
console.log(chalk56.gray(" - \u65E0\u5386\u53F2\u6587\u4EF6\u53EF\u5907\u4EFD"));
|
|
7747
8344
|
} else {
|
|
7748
8345
|
for (const file of item.backupFiles) {
|
|
7749
|
-
console.log(
|
|
8346
|
+
console.log(chalk56.gray(` - ${file}`));
|
|
7750
8347
|
}
|
|
7751
8348
|
}
|
|
7752
8349
|
}
|
|
7753
8350
|
}
|
|
7754
|
-
console.log(
|
|
8351
|
+
console.log(chalk56.gray("\u63D0\u793A\uFF1A\u8BF7\u91CD\u542F\u5BF9\u5E94\u5DE5\u5177/\u63D2\u4EF6\u4EE5\u4F7F\u914D\u7F6E\u751F\u6548\u3002"));
|
|
7755
8352
|
}
|
|
7756
8353
|
async function gmnCommand(apiKey, platformArg, providerNameArg, baseUrlArg) {
|
|
7757
8354
|
await runGmnCommand(GMN_PROFILE, apiKey, platformArg, providerNameArg, baseUrlArg);
|
|
@@ -7763,12 +8360,12 @@ async function gmn1Command(apiKey, platformArg, providerNameArg, baseUrlArg) {
|
|
|
7763
8360
|
// src/index.ts
|
|
7764
8361
|
init_dist2();
|
|
7765
8362
|
if (process.env.NODE_ENV === "development") {
|
|
7766
|
-
console.log(
|
|
7767
|
-
console.log(
|
|
7768
|
-
console.log(
|
|
7769
|
-
console.log(
|
|
7770
|
-
console.log(
|
|
7771
|
-
console.log(
|
|
8363
|
+
console.log(chalk57.gray("\n[\u5F00\u53D1\u6A21\u5F0F] \u914D\u7F6E\u76EE\u5F55:"));
|
|
8364
|
+
console.log(chalk57.gray(` ccman: ${getCcmanDir()}`));
|
|
8365
|
+
console.log(chalk57.gray(` codex: ${getCodexDir()}`));
|
|
8366
|
+
console.log(chalk57.gray(` claude: ${getClaudeDir()}`));
|
|
8367
|
+
console.log(chalk57.gray(` opencode: ${getOpenCodeDir()}`));
|
|
8368
|
+
console.log(chalk57.gray(` openclaw: ${getOpenClawDir()}`));
|
|
7772
8369
|
console.log();
|
|
7773
8370
|
}
|
|
7774
8371
|
var program = new Command3();
|
|
@@ -7780,7 +8377,7 @@ program.name("ccman").description("Codex/Claude Code/Gemini/OpenCode/OpenClaw AP
|
|
|
7780
8377
|
});
|
|
7781
8378
|
program.on("command:*", (operands) => {
|
|
7782
8379
|
const unknownCommand = operands[0];
|
|
7783
|
-
console.error(
|
|
8380
|
+
console.error(chalk57.red(`
|
|
7784
8381
|
\u274C \u672A\u77E5\u547D\u4EE4: ${unknownCommand}
|
|
7785
8382
|
`));
|
|
7786
8383
|
const availableCommands = [
|
|
@@ -7802,13 +8399,13 @@ program.on("command:*", (operands) => {
|
|
|
7802
8399
|
(cmd) => cmd.includes(unknownCommand) || unknownCommand.includes(cmd)
|
|
7803
8400
|
);
|
|
7804
8401
|
if (suggestions.length > 0) {
|
|
7805
|
-
console.log(
|
|
8402
|
+
console.log(chalk57.yellow("\u{1F4A1} \u4F60\u662F\u4E0D\u662F\u60F3\u8F93\u5165:"));
|
|
7806
8403
|
suggestions.forEach((cmd) => {
|
|
7807
|
-
console.log(
|
|
8404
|
+
console.log(chalk57.cyan(` ccman ${cmd}`));
|
|
7808
8405
|
});
|
|
7809
8406
|
console.log();
|
|
7810
8407
|
}
|
|
7811
|
-
console.log(
|
|
8408
|
+
console.log(chalk57.gray("\u67E5\u770B\u6240\u6709\u53EF\u7528\u547D\u4EE4: ") + chalk57.cyan("ccman --help"));
|
|
7812
8409
|
console.log();
|
|
7813
8410
|
process.exit(1);
|
|
7814
8411
|
});
|