ccman 3.0.18 → 3.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +122 -66
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var init_package = __esm({
|
|
|
39
39
|
"../core/package.json"() {
|
|
40
40
|
package_default = {
|
|
41
41
|
name: "@ccman/core",
|
|
42
|
-
version: "3.0.
|
|
42
|
+
version: "3.0.20",
|
|
43
43
|
type: "module",
|
|
44
44
|
description: "Core business logic for ccman",
|
|
45
45
|
main: "./dist/index.js",
|
|
@@ -2163,37 +2163,55 @@ var require_toml = __commonJS({
|
|
|
2163
2163
|
}
|
|
2164
2164
|
});
|
|
2165
2165
|
|
|
2166
|
+
// ../core/dist/utils/template.js
|
|
2167
|
+
function replaceVariables(template, variables) {
|
|
2168
|
+
const jsonStr = JSON.stringify(template);
|
|
2169
|
+
let result = jsonStr;
|
|
2170
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
2171
|
+
const escapedValue = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
2172
|
+
result = result.replace(new RegExp(`{{${key}}}`, "g"), escapedValue);
|
|
2173
|
+
}
|
|
2174
|
+
return JSON.parse(result);
|
|
2175
|
+
}
|
|
2176
|
+
function deepMerge(target, source) {
|
|
2177
|
+
const result = { ...target };
|
|
2178
|
+
for (const key in source) {
|
|
2179
|
+
const sourceValue = source[key];
|
|
2180
|
+
const targetValue = result[key];
|
|
2181
|
+
if (sourceValue && typeof sourceValue === "object" && !Array.isArray(sourceValue) && targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) {
|
|
2182
|
+
result[key] = deepMerge(targetValue, sourceValue);
|
|
2183
|
+
} else {
|
|
2184
|
+
result[key] = sourceValue;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
return result;
|
|
2188
|
+
}
|
|
2189
|
+
var init_template = __esm({
|
|
2190
|
+
"../core/dist/utils/template.js"() {
|
|
2191
|
+
"use strict";
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
|
|
2166
2195
|
// ../core/dist/writers/codex.js
|
|
2167
2196
|
function writeCodexConfig(provider) {
|
|
2168
2197
|
ensureDir(getCodexDir());
|
|
2169
2198
|
const configPath = getCodexConfigPath();
|
|
2170
|
-
let
|
|
2199
|
+
let userConfig = {};
|
|
2171
2200
|
if (fileExists(configPath)) {
|
|
2172
2201
|
const content = fs2.readFileSync(configPath, "utf-8");
|
|
2173
|
-
|
|
2174
|
-
} else {
|
|
2175
|
-
config = {};
|
|
2202
|
+
userConfig = (0, import_toml.parse)(content);
|
|
2176
2203
|
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2204
|
+
const mergedConfig = deepMerge(CODEX_DEFAULT_CONFIG, userConfig);
|
|
2205
|
+
mergedConfig.model_provider = provider.name;
|
|
2206
|
+
mergedConfig.model = provider.model || mergedConfig.model || "gpt-5-codex";
|
|
2207
|
+
mergedConfig.model_providers = mergedConfig.model_providers || {};
|
|
2208
|
+
mergedConfig.model_providers[provider.name] = {
|
|
2180
2209
|
name: provider.name,
|
|
2181
2210
|
base_url: provider.baseUrl,
|
|
2182
2211
|
wire_api: "responses",
|
|
2183
|
-
// 固定值
|
|
2184
2212
|
requires_openai_auth: true
|
|
2185
|
-
// 固定值
|
|
2186
2213
|
};
|
|
2187
|
-
|
|
2188
|
-
config.model = "gpt-5";
|
|
2189
|
-
}
|
|
2190
|
-
if (!config.model_reasoning_effort) {
|
|
2191
|
-
config.model_reasoning_effort = "high";
|
|
2192
|
-
}
|
|
2193
|
-
if (!("disable_response_storage" in config)) {
|
|
2194
|
-
config.disable_response_storage = true;
|
|
2195
|
-
}
|
|
2196
|
-
fs2.writeFileSync(configPath, (0, import_toml.stringify)(config), { mode: 384 });
|
|
2214
|
+
fs2.writeFileSync(configPath, (0, import_toml.stringify)(mergedConfig), { mode: 384 });
|
|
2197
2215
|
const authPath = getCodexAuthPath();
|
|
2198
2216
|
let auth;
|
|
2199
2217
|
if (fileExists(authPath)) {
|
|
@@ -2205,7 +2223,7 @@ function writeCodexConfig(provider) {
|
|
|
2205
2223
|
auth.OPENAI_API_KEY = provider.apiKey;
|
|
2206
2224
|
fs2.writeFileSync(authPath, JSON.stringify(auth, null, 2), { mode: 384 });
|
|
2207
2225
|
}
|
|
2208
|
-
var fs2, import_toml;
|
|
2226
|
+
var fs2, import_toml, CODEX_DEFAULT_CONFIG;
|
|
2209
2227
|
var init_codex = __esm({
|
|
2210
2228
|
"../core/dist/writers/codex.js"() {
|
|
2211
2229
|
"use strict";
|
|
@@ -2213,6 +2231,29 @@ var init_codex = __esm({
|
|
|
2213
2231
|
import_toml = __toESM(require_toml(), 1);
|
|
2214
2232
|
init_paths();
|
|
2215
2233
|
init_file();
|
|
2234
|
+
init_template();
|
|
2235
|
+
CODEX_DEFAULT_CONFIG = {
|
|
2236
|
+
model_reasoning_effort: "high",
|
|
2237
|
+
disable_response_storage: true,
|
|
2238
|
+
sandbox_mode: "workspace-write",
|
|
2239
|
+
windows_wsl_setup_acknowledged: true,
|
|
2240
|
+
features: {
|
|
2241
|
+
plan_tool: true,
|
|
2242
|
+
apply_patch_freeform: true,
|
|
2243
|
+
view_image_tool: true,
|
|
2244
|
+
web_search_request: true,
|
|
2245
|
+
unified_exec: false,
|
|
2246
|
+
streamable_shell: false,
|
|
2247
|
+
rmcp_client: true
|
|
2248
|
+
},
|
|
2249
|
+
tools: {
|
|
2250
|
+
web_search: true,
|
|
2251
|
+
view_image: true
|
|
2252
|
+
},
|
|
2253
|
+
sandbox_workspace_write: {
|
|
2254
|
+
network_access: true
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2216
2257
|
}
|
|
2217
2258
|
});
|
|
2218
2259
|
|
|
@@ -2220,42 +2261,38 @@ var init_codex = __esm({
|
|
|
2220
2261
|
function writeClaudeConfig(provider) {
|
|
2221
2262
|
ensureDir(getClaudeDir());
|
|
2222
2263
|
const configPath = getClaudeConfigPath();
|
|
2223
|
-
let
|
|
2264
|
+
let userConfig = {};
|
|
2224
2265
|
if (fileExists(configPath)) {
|
|
2225
2266
|
const content = fs3.readFileSync(configPath, "utf-8");
|
|
2226
|
-
|
|
2227
|
-
} else {
|
|
2228
|
-
settings = {};
|
|
2229
|
-
}
|
|
2230
|
-
if (!settings.env) {
|
|
2231
|
-
settings.env = {};
|
|
2232
|
-
}
|
|
2233
|
-
settings.env.ANTHROPIC_AUTH_TOKEN = provider.apiKey;
|
|
2234
|
-
settings.env.ANTHROPIC_BASE_URL = provider.baseUrl;
|
|
2235
|
-
if (!("CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC" in settings.env)) {
|
|
2236
|
-
settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = 1;
|
|
2237
|
-
}
|
|
2238
|
-
if (!("CLAUDE_CODE_MAX_OUTPUT_TOKENS" in settings.env)) {
|
|
2239
|
-
settings.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS = 32e3;
|
|
2240
|
-
}
|
|
2241
|
-
if (!settings.permissions) {
|
|
2242
|
-
settings.permissions = { allow: [], deny: [] };
|
|
2243
|
-
}
|
|
2244
|
-
if (!settings.permissions.allow) {
|
|
2245
|
-
settings.permissions.allow = [];
|
|
2246
|
-
}
|
|
2247
|
-
if (!settings.permissions.deny) {
|
|
2248
|
-
settings.permissions.deny = [];
|
|
2267
|
+
userConfig = JSON.parse(content);
|
|
2249
2268
|
}
|
|
2250
|
-
|
|
2269
|
+
const defaultConfig = replaceVariables(CLAUDE_CONFIG_TEMPLATE, {
|
|
2270
|
+
apiKey: provider.apiKey,
|
|
2271
|
+
baseUrl: provider.baseUrl
|
|
2272
|
+
});
|
|
2273
|
+
const mergedConfig = deepMerge(defaultConfig, userConfig);
|
|
2274
|
+
fs3.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2), { mode: 384 });
|
|
2251
2275
|
}
|
|
2252
|
-
var fs3;
|
|
2276
|
+
var fs3, CLAUDE_CONFIG_TEMPLATE;
|
|
2253
2277
|
var init_claude = __esm({
|
|
2254
2278
|
"../core/dist/writers/claude.js"() {
|
|
2255
2279
|
"use strict";
|
|
2256
2280
|
fs3 = __toESM(require("fs"), 1);
|
|
2257
2281
|
init_paths();
|
|
2258
2282
|
init_file();
|
|
2283
|
+
init_template();
|
|
2284
|
+
CLAUDE_CONFIG_TEMPLATE = {
|
|
2285
|
+
env: {
|
|
2286
|
+
ANTHROPIC_AUTH_TOKEN: "{{apiKey}}",
|
|
2287
|
+
ANTHROPIC_BASE_URL: "{{baseUrl}}",
|
|
2288
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: 1,
|
|
2289
|
+
CLAUDE_CODE_MAX_OUTPUT_TOKENS: 32e3
|
|
2290
|
+
},
|
|
2291
|
+
permissions: {
|
|
2292
|
+
allow: [],
|
|
2293
|
+
deny: []
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2259
2296
|
}
|
|
2260
2297
|
});
|
|
2261
2298
|
|
|
@@ -2265,14 +2302,9 @@ var init_codex2 = __esm({
|
|
|
2265
2302
|
"../core/dist/presets/codex.js"() {
|
|
2266
2303
|
"use strict";
|
|
2267
2304
|
CODEX_PRESETS = [
|
|
2268
|
-
{
|
|
2269
|
-
name: "PackyCode",
|
|
2270
|
-
baseUrl: "https://api.packycode.com",
|
|
2271
|
-
description: "PackyCode API \u670D\u52A1"
|
|
2272
|
-
},
|
|
2273
2305
|
{
|
|
2274
2306
|
name: "88Code",
|
|
2275
|
-
baseUrl: "https://www.88code.org/
|
|
2307
|
+
baseUrl: "https://www.88code.org/openai/v1",
|
|
2276
2308
|
description: "88Code API \u670D\u52A1"
|
|
2277
2309
|
}
|
|
2278
2310
|
];
|
|
@@ -2300,11 +2332,6 @@ var init_claude2 = __esm({
|
|
|
2300
2332
|
baseUrl: "https://api.packycode.com",
|
|
2301
2333
|
description: "PackyCode API \u670D\u52A1"
|
|
2302
2334
|
},
|
|
2303
|
-
{
|
|
2304
|
-
name: "CoordCode",
|
|
2305
|
-
baseUrl: "https://api.coordcode.com/api",
|
|
2306
|
-
description: "CoordCode API \u670D\u52A1"
|
|
2307
|
-
},
|
|
2308
2335
|
{
|
|
2309
2336
|
name: "88Code",
|
|
2310
2337
|
baseUrl: "https://www.88code.org/api",
|
|
@@ -2342,8 +2369,8 @@ function createCodexManager() {
|
|
|
2342
2369
|
ensureDir(getCcmanDir());
|
|
2343
2370
|
const initialConfig = {
|
|
2344
2371
|
providers: [],
|
|
2345
|
-
presets: [
|
|
2346
|
-
//
|
|
2372
|
+
presets: []
|
|
2373
|
+
// 只存储用户自定义预置
|
|
2347
2374
|
};
|
|
2348
2375
|
writeJSON(configPath, initialConfig);
|
|
2349
2376
|
return initialConfig;
|
|
@@ -2366,6 +2393,8 @@ function createCodexManager() {
|
|
|
2366
2393
|
name: input.name,
|
|
2367
2394
|
baseUrl: input.baseUrl,
|
|
2368
2395
|
apiKey: input.apiKey,
|
|
2396
|
+
model: input.model,
|
|
2397
|
+
// 保存 model 字段
|
|
2369
2398
|
createdAt: timestamp,
|
|
2370
2399
|
lastModified: timestamp
|
|
2371
2400
|
};
|
|
@@ -2387,7 +2416,8 @@ function createCodexManager() {
|
|
|
2387
2416
|
},
|
|
2388
2417
|
findByName(name) {
|
|
2389
2418
|
const config = loadConfig2();
|
|
2390
|
-
|
|
2419
|
+
const lowerName = name.toLowerCase();
|
|
2420
|
+
return config.providers.find((p) => p.name.toLowerCase() === lowerName);
|
|
2391
2421
|
},
|
|
2392
2422
|
switch(id) {
|
|
2393
2423
|
const config = loadConfig2();
|
|
@@ -2426,6 +2456,8 @@ function createCodexManager() {
|
|
|
2426
2456
|
provider.baseUrl = updates.baseUrl;
|
|
2427
2457
|
if (updates.apiKey !== void 0)
|
|
2428
2458
|
provider.apiKey = updates.apiKey;
|
|
2459
|
+
if (updates.model !== void 0)
|
|
2460
|
+
provider.model = updates.model;
|
|
2429
2461
|
provider.lastModified = Date.now();
|
|
2430
2462
|
saveConfig2(config);
|
|
2431
2463
|
if (config.currentProviderId === id) {
|
|
@@ -2535,8 +2567,8 @@ function createClaudeManager() {
|
|
|
2535
2567
|
ensureDir(getCcmanDir());
|
|
2536
2568
|
const initialConfig = {
|
|
2537
2569
|
providers: [],
|
|
2538
|
-
presets: [
|
|
2539
|
-
//
|
|
2570
|
+
presets: []
|
|
2571
|
+
// 只存储用户自定义预置
|
|
2540
2572
|
};
|
|
2541
2573
|
writeJSON(configPath, initialConfig);
|
|
2542
2574
|
return initialConfig;
|
|
@@ -2580,7 +2612,8 @@ function createClaudeManager() {
|
|
|
2580
2612
|
},
|
|
2581
2613
|
findByName(name) {
|
|
2582
2614
|
const config = loadConfig2();
|
|
2583
|
-
|
|
2615
|
+
const lowerName = name.toLowerCase();
|
|
2616
|
+
return config.providers.find((p) => p.name.toLowerCase() === lowerName);
|
|
2584
2617
|
},
|
|
2585
2618
|
switch(id) {
|
|
2586
2619
|
const config = loadConfig2();
|
|
@@ -16471,6 +16504,7 @@ async function downloadFromCloud(config, password) {
|
|
|
16471
16504
|
// 保留本地 presets
|
|
16472
16505
|
};
|
|
16473
16506
|
writeJSON(codexConfigPath, newCodexConfig);
|
|
16507
|
+
applyCurrentProvider("codex", newCodexConfig);
|
|
16474
16508
|
}
|
|
16475
16509
|
if (remoteClaudeConfig && decryptedClaudeProviders) {
|
|
16476
16510
|
const newClaudeConfig = {
|
|
@@ -16480,8 +16514,9 @@ async function downloadFromCloud(config, password) {
|
|
|
16480
16514
|
// 保留本地 presets
|
|
16481
16515
|
};
|
|
16482
16516
|
writeJSON(claudeConfigPath, newClaudeConfig);
|
|
16517
|
+
applyCurrentProvider("claude", newClaudeConfig);
|
|
16483
16518
|
}
|
|
16484
|
-
console.log("\u2705 \u914D\u7F6E\u5DF2\u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u5E76\
|
|
16519
|
+
console.log("\u2705 \u914D\u7F6E\u5DF2\u4ECE\u4E91\u7AEF\u4E0B\u8F7D\u5E76\u5E94\u7528");
|
|
16485
16520
|
return backupPaths;
|
|
16486
16521
|
} catch (error) {
|
|
16487
16522
|
for (const backupPath of backupPaths) {
|
|
@@ -16559,6 +16594,8 @@ async function mergeSync(config, password) {
|
|
|
16559
16594
|
};
|
|
16560
16595
|
writeJSON(codexConfigPath, mergedCodexConfig);
|
|
16561
16596
|
writeJSON(claudeConfigPath, mergedClaudeConfig);
|
|
16597
|
+
applyCurrentProvider("codex", mergedCodexConfig);
|
|
16598
|
+
applyCurrentProvider("claude", mergedClaudeConfig);
|
|
16562
16599
|
const encryptedCodexProviders = encryptProviders(codexMergeResult.merged, password);
|
|
16563
16600
|
const encryptedClaudeProviders = encryptProviders(claudeMergeResult.merged, password);
|
|
16564
16601
|
const encryptedCodexConfig = {
|
|
@@ -16588,6 +16625,20 @@ async function mergeSync(config, password) {
|
|
|
16588
16625
|
throw new Error(`\u5408\u5E76\u914D\u7F6E\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u5907\u4EFD: ${error.message}`);
|
|
16589
16626
|
}
|
|
16590
16627
|
}
|
|
16628
|
+
function applyCurrentProvider(tool, config) {
|
|
16629
|
+
if (!config.currentProviderId) {
|
|
16630
|
+
return;
|
|
16631
|
+
}
|
|
16632
|
+
const provider = config.providers.find((p) => p.id === config.currentProviderId);
|
|
16633
|
+
if (!provider) {
|
|
16634
|
+
return;
|
|
16635
|
+
}
|
|
16636
|
+
if (tool === "codex") {
|
|
16637
|
+
writeCodexConfig(provider);
|
|
16638
|
+
} else {
|
|
16639
|
+
writeClaudeConfig(provider);
|
|
16640
|
+
}
|
|
16641
|
+
}
|
|
16591
16642
|
var import_fs2, import_path18, CODEX_REMOTE_PATH, CLAUDE_REMOTE_PATH;
|
|
16592
16643
|
var init_sync_v2 = __esm({
|
|
16593
16644
|
"../core/dist/sync/sync-v2.js"() {
|
|
@@ -16600,6 +16651,8 @@ var init_sync_v2 = __esm({
|
|
|
16600
16651
|
init_merge2();
|
|
16601
16652
|
init_paths();
|
|
16602
16653
|
init_file();
|
|
16654
|
+
init_codex();
|
|
16655
|
+
init_claude();
|
|
16603
16656
|
CODEX_REMOTE_PATH = ".ccman/codex.json";
|
|
16604
16657
|
CLAUDE_REMOTE_PATH = ".ccman/claude.json";
|
|
16605
16658
|
}
|
|
@@ -17486,6 +17539,7 @@ var import_chalk27 = __toESM(require("chalk"));
|
|
|
17486
17539
|
|
|
17487
17540
|
// src/utils/logo.ts
|
|
17488
17541
|
var import_chalk = __toESM(require("chalk"));
|
|
17542
|
+
init_dist4();
|
|
17489
17543
|
function printLogo() {
|
|
17490
17544
|
console.log(
|
|
17491
17545
|
import_chalk.default.bold(
|
|
@@ -17499,7 +17553,9 @@ function printLogo() {
|
|
|
17499
17553
|
`
|
|
17500
17554
|
)
|
|
17501
17555
|
);
|
|
17502
|
-
console.log(import_chalk.default.gray(" Codex/Claude Code API \u670D\u52A1\u5546\u914D\u7F6E\u7BA1\u7406\u5DE5\u5177
|
|
17556
|
+
console.log(import_chalk.default.gray(" Codex/Claude Code API \u670D\u52A1\u5546\u914D\u7F6E\u7BA1\u7406\u5DE5\u5177"));
|
|
17557
|
+
console.log(import_chalk.default.gray(` \u7248\u672C ${VERSION}
|
|
17558
|
+
`));
|
|
17503
17559
|
}
|
|
17504
17560
|
|
|
17505
17561
|
// src/commands/codex/add.ts
|