ccman 3.3.0 → 3.3.2
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 +7 -4
- package/dist/index.js +191 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,31 +226,34 @@ ccman mcp remove # 删除 MCP 服务器
|
|
|
226
226
|
|
|
227
227
|
添加服务商时可以选择"使用预设模板",只需填写 API Key:
|
|
228
228
|
|
|
229
|
-
### Claude Code 预设(
|
|
229
|
+
### Claude Code 预设(2 个)
|
|
230
230
|
|
|
231
231
|
| 预设名称 | Base URL |
|
|
232
232
|
|---------|----------|
|
|
233
233
|
| Anthropic Official | `https://api.anthropic.com` |
|
|
234
|
+
| GMN | `https://gmn.chuangzuoli.cn/api` |
|
|
234
235
|
|
|
235
236
|
### Gemini CLI 预设(2 个)
|
|
236
237
|
|
|
237
238
|
| 预设名称 | Base URL |
|
|
238
239
|
|---------|----------|
|
|
239
240
|
| Google Gemini (API Key) | 官方默认 |
|
|
240
|
-
| GMN | `https://gmn.chuangzuoli.cn/
|
|
241
|
+
| GMN | `https://gmn.chuangzuoli.cn/gemini` |
|
|
241
242
|
|
|
242
|
-
### Codex 预设(
|
|
243
|
+
### Codex 预设(3 个)
|
|
243
244
|
|
|
244
245
|
| 预设名称 | Base URL |
|
|
245
246
|
|---------|----------|
|
|
246
247
|
| OpenAI Official | `https://api.openai.com/v1` |
|
|
247
248
|
| GMN | `https://gmn.chuangzuoli.cn/openai` |
|
|
249
|
+
| GMN (COM) | `https://gmn.chuangzuoli.com` |
|
|
248
250
|
|
|
249
|
-
### OpenCode 预设(
|
|
251
|
+
### OpenCode 预设(2 个)
|
|
250
252
|
|
|
251
253
|
| 预设名称 | Base URL |
|
|
252
254
|
|---------|----------|
|
|
253
255
|
| GMN | `https://gmn.chuangzuoli.cn/openai` |
|
|
256
|
+
| GMN (COM) | `https://gmn.chuangzuoli.com` |
|
|
254
257
|
|
|
255
258
|
### MCP 预设(多个)
|
|
256
259
|
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var init_package = __esm({
|
|
|
15
15
|
"../core/package.json"() {
|
|
16
16
|
package_default = {
|
|
17
17
|
name: "@ccman/core",
|
|
18
|
-
version: "3.3.
|
|
18
|
+
version: "3.3.2",
|
|
19
19
|
type: "module",
|
|
20
20
|
description: "Core business logic for ccman - Manage Codex, Claude Code, Gemini CLI, and MCP configurations",
|
|
21
21
|
main: "./dist/index.js",
|
|
@@ -599,7 +599,12 @@ var init_codex2 = __esm({
|
|
|
599
599
|
{
|
|
600
600
|
name: "GMN",
|
|
601
601
|
baseUrl: "https://gmn.chuangzuoli.cn/openai",
|
|
602
|
-
description: "GMN \u670D\u52A1 (Codex
|
|
602
|
+
description: "GMN \u670D\u52A1 (OpenAI/Codex \u517C\u5BB9)"
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
name: "GMN (COM)",
|
|
606
|
+
baseUrl: "https://gmn.chuangzuoli.com",
|
|
607
|
+
description: "GMN \u670D\u52A1 (OpenAI/Codex \u517C\u5BB9)"
|
|
603
608
|
}
|
|
604
609
|
];
|
|
605
610
|
}
|
|
@@ -615,6 +620,11 @@ var init_claude2 = __esm({
|
|
|
615
620
|
name: "Anthropic Official",
|
|
616
621
|
baseUrl: "https://api.anthropic.com",
|
|
617
622
|
description: "Anthropic \u5B98\u65B9 API"
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
name: "GMN",
|
|
626
|
+
baseUrl: "https://gmn.chuangzuoli.cn/api",
|
|
627
|
+
description: "GMN \u670D\u52A1 (Claude \u517C\u5BB9)"
|
|
618
628
|
}
|
|
619
629
|
];
|
|
620
630
|
}
|
|
@@ -703,8 +713,8 @@ var init_gemini = __esm({
|
|
|
703
713
|
},
|
|
704
714
|
{
|
|
705
715
|
name: "GMN",
|
|
706
|
-
baseUrl: "https://gmn.chuangzuoli.cn/
|
|
707
|
-
description: "GMN \u670D\u52A1 (
|
|
716
|
+
baseUrl: "https://gmn.chuangzuoli.cn/gemini",
|
|
717
|
+
description: "GMN \u670D\u52A1 (Gemini \u517C\u5BB9)"
|
|
708
718
|
}
|
|
709
719
|
];
|
|
710
720
|
}
|
|
@@ -720,6 +730,11 @@ var init_opencode = __esm({
|
|
|
720
730
|
name: "GMN",
|
|
721
731
|
baseUrl: "https://gmn.chuangzuoli.cn/openai",
|
|
722
732
|
description: "GMN \u670D\u52A1 (OpenCode \u517C\u5BB9)"
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
name: "GMN (COM)",
|
|
736
|
+
baseUrl: "https://gmn.chuangzuoli.com",
|
|
737
|
+
description: "GMN \u670D\u52A1 (OpenCode \u517C\u5BB9)"
|
|
723
738
|
}
|
|
724
739
|
];
|
|
725
740
|
}
|
|
@@ -2973,7 +2988,7 @@ var init_sync = __esm({
|
|
|
2973
2988
|
|
|
2974
2989
|
// src/index.ts
|
|
2975
2990
|
import { Command as Command3 } from "commander";
|
|
2976
|
-
import
|
|
2991
|
+
import chalk48 from "chalk";
|
|
2977
2992
|
|
|
2978
2993
|
// src/utils/logo.ts
|
|
2979
2994
|
init_dist2();
|
|
@@ -6201,14 +6216,172 @@ function importCommand(program2) {
|
|
|
6201
6216
|
});
|
|
6202
6217
|
}
|
|
6203
6218
|
|
|
6219
|
+
// src/commands/gmn.ts
|
|
6220
|
+
init_dist2();
|
|
6221
|
+
import chalk47 from "chalk";
|
|
6222
|
+
import inquirer33 from "inquirer";
|
|
6223
|
+
var PROVIDER_NAME = "GMN";
|
|
6224
|
+
var VALID_PLATFORMS = ["claude", "codex", "gemini", "opencode"];
|
|
6225
|
+
var DEFAULT_PLATFORMS = ["codex", "opencode"];
|
|
6226
|
+
var GMN_BASE_URLS = {
|
|
6227
|
+
claude: "https://gmn.chuangzuoli.cn/api",
|
|
6228
|
+
gemini: "https://gmn.chuangzuoli.cn/gemini"
|
|
6229
|
+
};
|
|
6230
|
+
var GMN_OPENAI_BASE_URLS = {
|
|
6231
|
+
cn: "https://gmn.chuangzuoli.cn/openai",
|
|
6232
|
+
com: "https://gmn.chuangzuoli.com"
|
|
6233
|
+
};
|
|
6234
|
+
function parsePlatforms(platformArg) {
|
|
6235
|
+
if (platformArg === "all") {
|
|
6236
|
+
return [...VALID_PLATFORMS];
|
|
6237
|
+
}
|
|
6238
|
+
const platforms = platformArg.split(",").map((p) => p.trim().toLowerCase());
|
|
6239
|
+
for (const platform of platforms) {
|
|
6240
|
+
if (!VALID_PLATFORMS.includes(platform)) {
|
|
6241
|
+
throw new Error(`\u65E0\u6548\u7684\u5E73\u53F0: ${platform}\u3002\u6709\u6548\u503C: ${VALID_PLATFORMS.join(", ")}, all`);
|
|
6242
|
+
}
|
|
6243
|
+
}
|
|
6244
|
+
return platforms;
|
|
6245
|
+
}
|
|
6246
|
+
async function promptApiKey() {
|
|
6247
|
+
const answers = await inquirer33.prompt([
|
|
6248
|
+
{
|
|
6249
|
+
type: "password",
|
|
6250
|
+
name: "apiKey",
|
|
6251
|
+
message: "\u8BF7\u8F93\u5165 GMN API Key:",
|
|
6252
|
+
mask: "*",
|
|
6253
|
+
validate: (value) => {
|
|
6254
|
+
if (!value) return "API Key \u4E0D\u80FD\u4E3A\u7A7A";
|
|
6255
|
+
return true;
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6258
|
+
]);
|
|
6259
|
+
return answers.apiKey;
|
|
6260
|
+
}
|
|
6261
|
+
async function promptPlatforms() {
|
|
6262
|
+
const answers = await inquirer33.prompt([
|
|
6263
|
+
{
|
|
6264
|
+
type: "checkbox",
|
|
6265
|
+
name: "platforms",
|
|
6266
|
+
message: "\u9009\u62E9\u5E73\u53F0:",
|
|
6267
|
+
choices: [
|
|
6268
|
+
{ name: "Claude Code", value: "claude" },
|
|
6269
|
+
{ name: "Codex", value: "codex" },
|
|
6270
|
+
{ name: "Gemini CLI", value: "gemini" },
|
|
6271
|
+
{ name: "OpenCode", value: "opencode" },
|
|
6272
|
+
{ name: "\u5168\u90E8 (all)", value: "all" }
|
|
6273
|
+
],
|
|
6274
|
+
default: DEFAULT_PLATFORMS,
|
|
6275
|
+
validate: (value) => {
|
|
6276
|
+
if (!value || value.length === 0) return "\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u5E73\u53F0";
|
|
6277
|
+
return true;
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6280
|
+
]);
|
|
6281
|
+
const selected = answers.platforms;
|
|
6282
|
+
if (selected.includes("all")) {
|
|
6283
|
+
return [...VALID_PLATFORMS];
|
|
6284
|
+
}
|
|
6285
|
+
return selected;
|
|
6286
|
+
}
|
|
6287
|
+
async function resolvePlatforms(platformArg) {
|
|
6288
|
+
if (platformArg && platformArg.trim().length > 0) {
|
|
6289
|
+
return parsePlatforms(platformArg);
|
|
6290
|
+
}
|
|
6291
|
+
return promptPlatforms();
|
|
6292
|
+
}
|
|
6293
|
+
async function resolveOpenAIDomain(domainArg, platforms) {
|
|
6294
|
+
const needsOpenAI = platforms.includes("codex") || platforms.includes("opencode");
|
|
6295
|
+
if (!needsOpenAI) {
|
|
6296
|
+
return "cn";
|
|
6297
|
+
}
|
|
6298
|
+
if (domainArg && domainArg.trim().length > 0) {
|
|
6299
|
+
const normalized = domainArg.trim().toLowerCase();
|
|
6300
|
+
if (normalized === "cn" || normalized === "com") {
|
|
6301
|
+
return normalized;
|
|
6302
|
+
}
|
|
6303
|
+
throw new Error(`\u65E0\u6548\u7684 domain: ${domainArg} (\u53EF\u9009: cn, com)`);
|
|
6304
|
+
}
|
|
6305
|
+
const answers = await inquirer33.prompt([
|
|
6306
|
+
{
|
|
6307
|
+
type: "list",
|
|
6308
|
+
name: "domain",
|
|
6309
|
+
message: "\u9009\u62E9 Codex/OpenCode \u7684 OpenAI Base URL:",
|
|
6310
|
+
choices: [
|
|
6311
|
+
{ name: `CN ${GMN_OPENAI_BASE_URLS.cn}`, value: "cn" },
|
|
6312
|
+
{ name: `COM ${GMN_OPENAI_BASE_URLS.com}`, value: "com" }
|
|
6313
|
+
],
|
|
6314
|
+
default: "cn"
|
|
6315
|
+
}
|
|
6316
|
+
]);
|
|
6317
|
+
return answers.domain;
|
|
6318
|
+
}
|
|
6319
|
+
async function gmnCommand(apiKey, platformArg, domainArg) {
|
|
6320
|
+
let resolvedApiKey = apiKey?.trim();
|
|
6321
|
+
if (!resolvedApiKey) {
|
|
6322
|
+
resolvedApiKey = await promptApiKey();
|
|
6323
|
+
}
|
|
6324
|
+
let platforms;
|
|
6325
|
+
try {
|
|
6326
|
+
platforms = await resolvePlatforms(platformArg);
|
|
6327
|
+
} catch (error) {
|
|
6328
|
+
console.error(chalk47.red(`\u274C ${error.message}`));
|
|
6329
|
+
process.exit(1);
|
|
6330
|
+
}
|
|
6331
|
+
let openaiDomain;
|
|
6332
|
+
try {
|
|
6333
|
+
openaiDomain = await resolveOpenAIDomain(domainArg, platforms);
|
|
6334
|
+
} catch (error) {
|
|
6335
|
+
console.error(chalk47.red(`\u274C ${error.message}`));
|
|
6336
|
+
process.exit(1);
|
|
6337
|
+
}
|
|
6338
|
+
if (!resolvedApiKey?.trim()) {
|
|
6339
|
+
console.error(chalk47.red("\u274C \u9519\u8BEF: API Key \u4E0D\u80FD\u4E3A\u7A7A"));
|
|
6340
|
+
process.exit(1);
|
|
6341
|
+
}
|
|
6342
|
+
const openaiBaseUrl = GMN_OPENAI_BASE_URLS[openaiDomain];
|
|
6343
|
+
const platformBaseUrls = {
|
|
6344
|
+
claude: GMN_BASE_URLS.claude,
|
|
6345
|
+
codex: openaiBaseUrl,
|
|
6346
|
+
gemini: GMN_BASE_URLS.gemini,
|
|
6347
|
+
opencode: openaiBaseUrl
|
|
6348
|
+
};
|
|
6349
|
+
console.log(chalk47.cyan("\u{1F680} \u5F00\u59CB\u914D\u7F6E GMN..."));
|
|
6350
|
+
console.log(chalk47.gray(`\u5E73\u53F0: ${platforms.join(", ")}
|
|
6351
|
+
`));
|
|
6352
|
+
const ALL_TOOLS = {
|
|
6353
|
+
claude: { name: "Claude Code", manager: createClaudeManager() },
|
|
6354
|
+
codex: { name: "Codex", manager: createCodexManager() },
|
|
6355
|
+
gemini: { name: "Gemini CLI", manager: createGeminiManager() },
|
|
6356
|
+
opencode: { name: "OpenCode", manager: createOpenCodeManager() }
|
|
6357
|
+
};
|
|
6358
|
+
const tools = platforms.map((platform) => ({
|
|
6359
|
+
platform,
|
|
6360
|
+
...ALL_TOOLS[platform]
|
|
6361
|
+
}));
|
|
6362
|
+
for (const { platform, name, manager } of tools) {
|
|
6363
|
+
try {
|
|
6364
|
+
const baseUrl = platformBaseUrls[platform];
|
|
6365
|
+
const existing = manager.findByName(PROVIDER_NAME);
|
|
6366
|
+
const provider = existing ? manager.edit(existing.id, { baseUrl, apiKey: resolvedApiKey }) : manager.add({ name: PROVIDER_NAME, baseUrl, apiKey: resolvedApiKey });
|
|
6367
|
+
manager.switch(provider.id);
|
|
6368
|
+
console.log(chalk47.green(`\u2705 ${name}`));
|
|
6369
|
+
} catch (error) {
|
|
6370
|
+
console.error(chalk47.red(`\u274C ${name}: ${error.message}`));
|
|
6371
|
+
}
|
|
6372
|
+
}
|
|
6373
|
+
console.log(chalk47.green("\n\u{1F389} GMN \u914D\u7F6E\u5B8C\u6210\uFF01"));
|
|
6374
|
+
console.log(chalk47.gray("\u63D0\u793A\uFF1A\u8BF7\u91CD\u542F\u5BF9\u5E94\u7684\u5DE5\u5177\u4EE5\u4F7F\u914D\u7F6E\u751F\u6548\u3002"));
|
|
6375
|
+
}
|
|
6376
|
+
|
|
6204
6377
|
// src/index.ts
|
|
6205
6378
|
init_dist2();
|
|
6206
6379
|
if (process.env.NODE_ENV === "development") {
|
|
6207
|
-
console.log(
|
|
6208
|
-
console.log(
|
|
6209
|
-
console.log(
|
|
6210
|
-
console.log(
|
|
6211
|
-
console.log(
|
|
6380
|
+
console.log(chalk48.gray("\n[\u5F00\u53D1\u6A21\u5F0F] \u914D\u7F6E\u76EE\u5F55:"));
|
|
6381
|
+
console.log(chalk48.gray(` ccman: ${getCcmanDir()}`));
|
|
6382
|
+
console.log(chalk48.gray(` codex: ${getCodexDir()}`));
|
|
6383
|
+
console.log(chalk48.gray(` claude: ${getClaudeDir()}`));
|
|
6384
|
+
console.log(chalk48.gray(` opencode: ${getOpenCodeDir()}`));
|
|
6212
6385
|
console.log();
|
|
6213
6386
|
}
|
|
6214
6387
|
var program = new Command3();
|
|
@@ -6220,21 +6393,21 @@ program.name("ccman").description("Codex/Claude Code/Gemini/OpenCode API \u670D\
|
|
|
6220
6393
|
});
|
|
6221
6394
|
program.on("command:*", (operands) => {
|
|
6222
6395
|
const unknownCommand = operands[0];
|
|
6223
|
-
console.error(
|
|
6396
|
+
console.error(chalk48.red(`
|
|
6224
6397
|
\u274C \u672A\u77E5\u547D\u4EE4: ${unknownCommand}
|
|
6225
6398
|
`));
|
|
6226
|
-
const availableCommands = ["cx", "cc", "gm", "oc", "mcp", "sync", "export", "import"];
|
|
6399
|
+
const availableCommands = ["cx", "cc", "gm", "oc", "mcp", "sync", "export", "import", "gmn"];
|
|
6227
6400
|
const suggestions = availableCommands.filter(
|
|
6228
6401
|
(cmd) => cmd.includes(unknownCommand) || unknownCommand.includes(cmd)
|
|
6229
6402
|
);
|
|
6230
6403
|
if (suggestions.length > 0) {
|
|
6231
|
-
console.log(
|
|
6404
|
+
console.log(chalk48.yellow("\u{1F4A1} \u4F60\u662F\u4E0D\u662F\u60F3\u8F93\u5165:"));
|
|
6232
6405
|
suggestions.forEach((cmd) => {
|
|
6233
|
-
console.log(
|
|
6406
|
+
console.log(chalk48.cyan(` ccman ${cmd}`));
|
|
6234
6407
|
});
|
|
6235
6408
|
console.log();
|
|
6236
6409
|
}
|
|
6237
|
-
console.log(
|
|
6410
|
+
console.log(chalk48.gray("\u67E5\u770B\u6240\u6709\u53EF\u7528\u547D\u4EE4: ") + chalk48.cyan("ccman --help"));
|
|
6238
6411
|
console.log();
|
|
6239
6412
|
process.exit(1);
|
|
6240
6413
|
});
|
|
@@ -6275,6 +6448,9 @@ sync.action(async () => {
|
|
|
6275
6448
|
});
|
|
6276
6449
|
exportCommand(program);
|
|
6277
6450
|
importCommand(program);
|
|
6451
|
+
program.command("gmn [apiKey]").description("\u914D\u7F6E GMN \u5230\u6240\u6709\u5DE5\u5177").option("-p, --platform <platforms>", "\u6307\u5B9A\u5E73\u53F0 (claude,codex,gemini,opencode,all)").option("-d, --domain <domain>", "\u9009\u62E9 OpenAI \u7AEF\u70B9 (cn|com)").action(async (apiKey, options) => {
|
|
6452
|
+
await gmnCommand(apiKey, options.platform, options.domain);
|
|
6453
|
+
});
|
|
6278
6454
|
(async () => {
|
|
6279
6455
|
if (!process.argv.slice(2).length) {
|
|
6280
6456
|
printLogo();
|