ccman 3.0.27 → 3.0.29

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.
Files changed (2) hide show
  1. package/dist/index.js +295 -201
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -39,13 +39,14 @@ var init_package = __esm({
39
39
  "../core/package.json"() {
40
40
  package_default = {
41
41
  name: "@ccman/core",
42
- version: "3.0.27",
42
+ version: "3.0.29",
43
43
  type: "module",
44
44
  description: "Core business logic for ccman",
45
45
  main: "./dist/index.js",
46
46
  types: "./dist/index.d.ts",
47
47
  files: [
48
- "dist"
48
+ "dist",
49
+ "templates"
49
50
  ],
50
51
  scripts: {
51
52
  build: "tsc",
@@ -1779,20 +1780,20 @@ var require_parse_async = __commonJS({
1779
1780
  const index = 0;
1780
1781
  const blocksize = opts.blocksize || 40960;
1781
1782
  const parser = new TOMLParser();
1782
- return new Promise((resolve, reject) => {
1783
- setImmediate(parseAsyncNext, index, blocksize, resolve, reject);
1783
+ return new Promise((resolve3, reject) => {
1784
+ setImmediate(parseAsyncNext, index, blocksize, resolve3, reject);
1784
1785
  });
1785
- function parseAsyncNext(index2, blocksize2, resolve, reject) {
1786
+ function parseAsyncNext(index2, blocksize2, resolve3, reject) {
1786
1787
  if (index2 >= str.length) {
1787
1788
  try {
1788
- return resolve(parser.finish());
1789
+ return resolve3(parser.finish());
1789
1790
  } catch (err) {
1790
1791
  return reject(prettyError(err, str));
1791
1792
  }
1792
1793
  }
1793
1794
  try {
1794
1795
  parser.parse(str.slice(index2, index2 + blocksize2));
1795
- setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve, reject);
1796
+ setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve3, reject);
1796
1797
  } catch (err) {
1797
1798
  reject(prettyError(err, str));
1798
1799
  }
@@ -1818,7 +1819,7 @@ var require_parse_stream = __commonJS({
1818
1819
  function parseReadable(stm) {
1819
1820
  const parser = new TOMLParser();
1820
1821
  stm.setEncoding("utf8");
1821
- return new Promise((resolve, reject) => {
1822
+ return new Promise((resolve3, reject) => {
1822
1823
  let readable;
1823
1824
  let ended = false;
1824
1825
  let errored = false;
@@ -1826,7 +1827,7 @@ var require_parse_stream = __commonJS({
1826
1827
  ended = true;
1827
1828
  if (readable) return;
1828
1829
  try {
1829
- resolve(parser.finish());
1830
+ resolve3(parser.finish());
1830
1831
  } catch (err) {
1831
1832
  reject(err);
1832
1833
  }
@@ -2191,6 +2192,17 @@ var init_template = __esm({
2191
2192
  });
2192
2193
 
2193
2194
  // ../core/dist/writers/codex.js
2195
+ function loadCodexTemplateConfig() {
2196
+ try {
2197
+ const templatePath = path3.resolve(__dirname, "../../templates/codex/config.toml");
2198
+ if (fs2.existsSync(templatePath)) {
2199
+ const content = fs2.readFileSync(templatePath, "utf-8");
2200
+ return (0, import_toml.parse)(content);
2201
+ }
2202
+ } catch {
2203
+ }
2204
+ return CODEX_DEFAULT_CONFIG;
2205
+ }
2194
2206
  function writeCodexConfig(provider) {
2195
2207
  ensureDir(getCodexDir());
2196
2208
  const configPath = getCodexConfigPath();
@@ -2199,7 +2211,8 @@ function writeCodexConfig(provider) {
2199
2211
  const content = fs2.readFileSync(configPath, "utf-8");
2200
2212
  userConfig = (0, import_toml.parse)(content);
2201
2213
  }
2202
- const mergedConfig = deepMerge(CODEX_DEFAULT_CONFIG, userConfig);
2214
+ const templateConfig = loadCodexTemplateConfig();
2215
+ const mergedConfig = deepMerge(templateConfig, userConfig);
2203
2216
  mergedConfig.model_provider = provider.name;
2204
2217
  mergedConfig.model = provider.model || mergedConfig.model || "gpt-5-codex";
2205
2218
  mergedConfig.model_providers = mergedConfig.model_providers || {};
@@ -2221,15 +2234,20 @@ function writeCodexConfig(provider) {
2221
2234
  auth.OPENAI_API_KEY = provider.apiKey;
2222
2235
  fs2.writeFileSync(authPath, JSON.stringify(auth, null, 2), { mode: 384 });
2223
2236
  }
2224
- var fs2, import_toml, CODEX_DEFAULT_CONFIG;
2237
+ var fs2, path3, import_url, import_toml, import_meta, __filename, __dirname, CODEX_DEFAULT_CONFIG;
2225
2238
  var init_codex = __esm({
2226
2239
  "../core/dist/writers/codex.js"() {
2227
2240
  "use strict";
2228
2241
  fs2 = __toESM(require("fs"), 1);
2242
+ path3 = __toESM(require("path"), 1);
2243
+ import_url = require("url");
2229
2244
  import_toml = __toESM(require_toml(), 1);
2230
2245
  init_paths();
2231
2246
  init_file();
2232
2247
  init_template();
2248
+ import_meta = {};
2249
+ __filename = (0, import_url.fileURLToPath)(import_meta.url);
2250
+ __dirname = path3.dirname(__filename);
2233
2251
  CODEX_DEFAULT_CONFIG = {
2234
2252
  model_reasoning_effort: "high",
2235
2253
  disable_response_storage: true,
@@ -2244,10 +2262,6 @@ var init_codex = __esm({
2244
2262
  streamable_shell: false,
2245
2263
  rmcp_client: true
2246
2264
  },
2247
- tools: {
2248
- web_search: true,
2249
- view_image: true
2250
- },
2251
2265
  sandbox_workspace_write: {
2252
2266
  network_access: true
2253
2267
  }
@@ -2256,6 +2270,17 @@ var init_codex = __esm({
2256
2270
  });
2257
2271
 
2258
2272
  // ../core/dist/writers/claude.js
2273
+ function loadClaudeTemplateConfig() {
2274
+ try {
2275
+ const templatePath = path4.resolve(__dirname2, "../../templates/claude/settings.json");
2276
+ if (fs3.existsSync(templatePath)) {
2277
+ const content = fs3.readFileSync(templatePath, "utf-8");
2278
+ return JSON.parse(content);
2279
+ }
2280
+ } catch {
2281
+ }
2282
+ return CLAUDE_CONFIG_TEMPLATE;
2283
+ }
2259
2284
  function writeClaudeConfig(provider) {
2260
2285
  ensureDir(getClaudeDir());
2261
2286
  const configPath = getClaudeConfigPath();
@@ -2264,7 +2289,8 @@ function writeClaudeConfig(provider) {
2264
2289
  const content = fs3.readFileSync(configPath, "utf-8");
2265
2290
  userConfig = JSON.parse(content);
2266
2291
  }
2267
- const defaultConfig = replaceVariables(CLAUDE_CONFIG_TEMPLATE, {
2292
+ const defaultTemplate = loadClaudeTemplateConfig();
2293
+ const defaultConfig = replaceVariables(defaultTemplate, {
2268
2294
  apiKey: provider.apiKey,
2269
2295
  baseUrl: provider.baseUrl
2270
2296
  });
@@ -2274,14 +2300,19 @@ function writeClaudeConfig(provider) {
2274
2300
  mergedConfig.env.ANTHROPIC_BASE_URL = provider.baseUrl;
2275
2301
  fs3.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2), { mode: 384 });
2276
2302
  }
2277
- var fs3, CLAUDE_CONFIG_TEMPLATE;
2303
+ var fs3, path4, import_url2, import_meta2, __filename2, __dirname2, CLAUDE_CONFIG_TEMPLATE;
2278
2304
  var init_claude = __esm({
2279
2305
  "../core/dist/writers/claude.js"() {
2280
2306
  "use strict";
2281
2307
  fs3 = __toESM(require("fs"), 1);
2308
+ path4 = __toESM(require("path"), 1);
2309
+ import_url2 = require("url");
2282
2310
  init_paths();
2283
2311
  init_file();
2284
2312
  init_template();
2313
+ import_meta2 = {};
2314
+ __filename2 = (0, import_url2.fileURLToPath)(import_meta2.url);
2315
+ __dirname2 = path4.dirname(__filename2);
2285
2316
  CLAUDE_CONFIG_TEMPLATE = {
2286
2317
  env: {
2287
2318
  ANTHROPIC_AUTH_TOKEN: "{{apiKey}}",
@@ -2299,7 +2330,7 @@ var init_claude = __esm({
2299
2330
 
2300
2331
  // ../core/dist/writers/mcp.js
2301
2332
  function getMCPConfigPath() {
2302
- return path3.join(getCcmanDir(), "mcp.json");
2333
+ return path5.join(getCcmanDir(), "mcp.json");
2303
2334
  }
2304
2335
  function migrateMCPConfig(config) {
2305
2336
  if (Array.isArray(config.managedServerNames)) {
@@ -2323,6 +2354,8 @@ function migrateMCPConfig(config) {
2323
2354
  server.enabledApps = ["claude"];
2324
2355
  }
2325
2356
  }
2357
+ } else {
2358
+ config.servers = [];
2326
2359
  }
2327
2360
  return config;
2328
2361
  }
@@ -2447,12 +2480,12 @@ function writeMCPConfigForApp(app, _provider) {
2447
2480
  function writeMCPConfig(_provider) {
2448
2481
  writeMCPConfigForApp("claude", _provider);
2449
2482
  }
2450
- var fs4, path3;
2483
+ var fs4, path5;
2451
2484
  var init_mcp = __esm({
2452
2485
  "../core/dist/writers/mcp.js"() {
2453
2486
  "use strict";
2454
2487
  fs4 = __toESM(require("fs"), 1);
2455
- path3 = __toESM(require("path"), 1);
2488
+ path5 = __toESM(require("path"), 1);
2456
2489
  init_paths();
2457
2490
  init_file();
2458
2491
  }
@@ -2656,6 +2689,7 @@ function createToolManager(tool) {
2656
2689
  const provider = {
2657
2690
  id: generateId(),
2658
2691
  name: input.name,
2692
+ desc: input.desc,
2659
2693
  baseUrl: input.baseUrl,
2660
2694
  apiKey: input.apiKey,
2661
2695
  model: input.model,
@@ -2722,6 +2756,8 @@ function createToolManager(tool) {
2722
2756
  }
2723
2757
  if (updates.name !== void 0)
2724
2758
  provider.name = updates.name;
2759
+ if (updates.desc !== void 0)
2760
+ provider.desc = updates.desc;
2725
2761
  if (updates.baseUrl !== void 0)
2726
2762
  provider.baseUrl = updates.baseUrl;
2727
2763
  if (updates.apiKey !== void 0)
@@ -2765,6 +2801,7 @@ function createToolManager(tool) {
2765
2801
  ...source,
2766
2802
  id: generateId(),
2767
2803
  name: newName,
2804
+ desc: void 0,
2768
2805
  createdAt: timestamp,
2769
2806
  lastModified: timestamp,
2770
2807
  lastUsedAt: void 0
@@ -2859,11 +2896,11 @@ function createClaudeManager() {
2859
2896
  function createMCPManager() {
2860
2897
  return createToolManager("mcp");
2861
2898
  }
2862
- var path4, TOOL_CONFIGS;
2899
+ var path6, TOOL_CONFIGS;
2863
2900
  var init_tool_manager = __esm({
2864
2901
  "../core/dist/tool-manager.js"() {
2865
2902
  "use strict";
2866
- path4 = __toESM(require("path"), 1);
2903
+ path6 = __toESM(require("path"), 1);
2867
2904
  init_paths();
2868
2905
  init_file();
2869
2906
  init_codex();
@@ -2875,17 +2912,17 @@ var init_tool_manager = __esm({
2875
2912
  init_tool_manager_types();
2876
2913
  TOOL_CONFIGS = {
2877
2914
  codex: {
2878
- configPath: path4.join(getCcmanDir(), "codex.json"),
2915
+ configPath: path6.join(getCcmanDir(), "codex.json"),
2879
2916
  builtinPresets: CODEX_PRESETS,
2880
2917
  writer: writeCodexConfig
2881
2918
  },
2882
2919
  claude: {
2883
- configPath: path4.join(getCcmanDir(), "claude.json"),
2920
+ configPath: path6.join(getCcmanDir(), "claude.json"),
2884
2921
  builtinPresets: CC_PRESETS,
2885
2922
  writer: writeClaudeConfig
2886
2923
  },
2887
2924
  mcp: {
2888
- configPath: path4.join(getCcmanDir(), "mcp.json"),
2925
+ configPath: path6.join(getCcmanDir(), "mcp.json"),
2889
2926
  builtinPresets: MCP_PRESETS,
2890
2927
  writer: writeMCPConfig,
2891
2928
  autoSync: true,
@@ -3171,24 +3208,24 @@ var require_url_parse = __commonJS({
3171
3208
  rest
3172
3209
  };
3173
3210
  }
3174
- function resolve(relative, base) {
3211
+ function resolve3(relative, base) {
3175
3212
  if (relative === "") return base;
3176
- var path13 = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i2 = path13.length, last = path13[i2 - 1], unshift = false, up = 0;
3213
+ var path15 = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i2 = path15.length, last = path15[i2 - 1], unshift = false, up = 0;
3177
3214
  while (i2--) {
3178
- if (path13[i2] === ".") {
3179
- path13.splice(i2, 1);
3180
- } else if (path13[i2] === "..") {
3181
- path13.splice(i2, 1);
3215
+ if (path15[i2] === ".") {
3216
+ path15.splice(i2, 1);
3217
+ } else if (path15[i2] === "..") {
3218
+ path15.splice(i2, 1);
3182
3219
  up++;
3183
3220
  } else if (up) {
3184
3221
  if (i2 === 0) unshift = true;
3185
- path13.splice(i2, 1);
3222
+ path15.splice(i2, 1);
3186
3223
  up--;
3187
3224
  }
3188
3225
  }
3189
- if (unshift) path13.unshift("");
3190
- if (last === "." || last === "..") path13.push("");
3191
- return path13.join("/");
3226
+ if (unshift) path15.unshift("");
3227
+ if (last === "." || last === "..") path15.push("");
3228
+ return path15.join("/");
3192
3229
  }
3193
3230
  function Url(address, location, parser) {
3194
3231
  address = trimLeft(address);
@@ -3241,7 +3278,7 @@ var require_url_parse = __commonJS({
3241
3278
  }
3242
3279
  if (parser) url.query = parser(url.query);
3243
3280
  if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
3244
- url.pathname = resolve(url.pathname, location.pathname);
3281
+ url.pathname = resolve3(url.pathname, location.pathname);
3245
3282
  }
3246
3283
  if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
3247
3284
  url.pathname = "/" + url.pathname;
@@ -3614,14 +3651,14 @@ var require_path_posix = __commonJS({
3614
3651
  posix.resolve = function() {
3615
3652
  var resolvedPath = "", resolvedAbsolute = false;
3616
3653
  for (var i2 = arguments.length - 1; i2 >= -1 && !resolvedAbsolute; i2--) {
3617
- var path13 = i2 >= 0 ? arguments[i2] : process.cwd();
3618
- if (!isString(path13)) {
3654
+ var path15 = i2 >= 0 ? arguments[i2] : process.cwd();
3655
+ if (!isString(path15)) {
3619
3656
  throw new TypeError("Arguments to path.resolve must be strings");
3620
- } else if (!path13) {
3657
+ } else if (!path15) {
3621
3658
  continue;
3622
3659
  }
3623
- resolvedPath = path13 + "/" + resolvedPath;
3624
- resolvedAbsolute = path13.charAt(0) === "/";
3660
+ resolvedPath = path15 + "/" + resolvedPath;
3661
+ resolvedAbsolute = path15.charAt(0) === "/";
3625
3662
  }
3626
3663
  resolvedPath = normalizeArray(
3627
3664
  resolvedPath.split("/"),
@@ -3629,36 +3666,36 @@ var require_path_posix = __commonJS({
3629
3666
  ).join("/");
3630
3667
  return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
3631
3668
  };
3632
- posix.normalize = function(path13) {
3633
- var isAbsolute = posix.isAbsolute(path13), trailingSlash = path13.substr(-1) === "/";
3634
- path13 = normalizeArray(path13.split("/"), !isAbsolute).join("/");
3635
- if (!path13 && !isAbsolute) {
3636
- path13 = ".";
3669
+ posix.normalize = function(path15) {
3670
+ var isAbsolute = posix.isAbsolute(path15), trailingSlash = path15.substr(-1) === "/";
3671
+ path15 = normalizeArray(path15.split("/"), !isAbsolute).join("/");
3672
+ if (!path15 && !isAbsolute) {
3673
+ path15 = ".";
3637
3674
  }
3638
- if (path13 && trailingSlash) {
3639
- path13 += "/";
3675
+ if (path15 && trailingSlash) {
3676
+ path15 += "/";
3640
3677
  }
3641
- return (isAbsolute ? "/" : "") + path13;
3678
+ return (isAbsolute ? "/" : "") + path15;
3642
3679
  };
3643
- posix.isAbsolute = function(path13) {
3644
- return path13.charAt(0) === "/";
3680
+ posix.isAbsolute = function(path15) {
3681
+ return path15.charAt(0) === "/";
3645
3682
  };
3646
3683
  posix.join = function() {
3647
- var path13 = "";
3684
+ var path15 = "";
3648
3685
  for (var i2 = 0; i2 < arguments.length; i2++) {
3649
3686
  var segment = arguments[i2];
3650
3687
  if (!isString(segment)) {
3651
3688
  throw new TypeError("Arguments to path.join must be strings");
3652
3689
  }
3653
3690
  if (segment) {
3654
- if (!path13) {
3655
- path13 += segment;
3691
+ if (!path15) {
3692
+ path15 += segment;
3656
3693
  } else {
3657
- path13 += "/" + segment;
3694
+ path15 += "/" + segment;
3658
3695
  }
3659
3696
  }
3660
3697
  }
3661
- return posix.normalize(path13);
3698
+ return posix.normalize(path15);
3662
3699
  };
3663
3700
  posix.relative = function(from, to) {
3664
3701
  from = posix.resolve(from).substr(1);
@@ -3692,11 +3729,11 @@ var require_path_posix = __commonJS({
3692
3729
  outputParts = outputParts.concat(toParts.slice(samePartsLength));
3693
3730
  return outputParts.join("/");
3694
3731
  };
3695
- posix._makeLong = function(path13) {
3696
- return path13;
3732
+ posix._makeLong = function(path15) {
3733
+ return path15;
3697
3734
  };
3698
- posix.dirname = function(path13) {
3699
- var result = posixSplitPath(path13), root = result[0], dir = result[1];
3735
+ posix.dirname = function(path15) {
3736
+ var result = posixSplitPath(path15), root = result[0], dir = result[1];
3700
3737
  if (!root && !dir) {
3701
3738
  return ".";
3702
3739
  }
@@ -3705,15 +3742,15 @@ var require_path_posix = __commonJS({
3705
3742
  }
3706
3743
  return root + dir;
3707
3744
  };
3708
- posix.basename = function(path13, ext2) {
3709
- var f3 = posixSplitPath(path13)[2];
3745
+ posix.basename = function(path15, ext2) {
3746
+ var f3 = posixSplitPath(path15)[2];
3710
3747
  if (ext2 && f3.substr(-1 * ext2.length) === ext2) {
3711
3748
  f3 = f3.substr(0, f3.length - ext2.length);
3712
3749
  }
3713
3750
  return f3;
3714
3751
  };
3715
- posix.extname = function(path13) {
3716
- return posixSplitPath(path13)[3];
3752
+ posix.extname = function(path15) {
3753
+ return posixSplitPath(path15)[3];
3717
3754
  };
3718
3755
  posix.format = function(pathObject) {
3719
3756
  if (!util.isObject(pathObject)) {
@@ -4556,7 +4593,7 @@ var require_ponyfill_es2018 = __commonJS({
4556
4593
  return new originalPromise(executor);
4557
4594
  }
4558
4595
  function promiseResolvedWith(value) {
4559
- return newPromise((resolve) => resolve(value));
4596
+ return newPromise((resolve3) => resolve3(value));
4560
4597
  }
4561
4598
  function promiseRejectedWith(reason) {
4562
4599
  return originalPromiseReject(reason);
@@ -4726,8 +4763,8 @@ var require_ponyfill_es2018 = __commonJS({
4726
4763
  return new TypeError("Cannot " + name + " a stream using a released reader");
4727
4764
  }
4728
4765
  function defaultReaderClosedPromiseInitialize(reader) {
4729
- reader._closedPromise = newPromise((resolve, reject) => {
4730
- reader._closedPromise_resolve = resolve;
4766
+ reader._closedPromise = newPromise((resolve3, reject) => {
4767
+ reader._closedPromise_resolve = resolve3;
4731
4768
  reader._closedPromise_reject = reject;
4732
4769
  });
4733
4770
  }
@@ -4901,8 +4938,8 @@ var require_ponyfill_es2018 = __commonJS({
4901
4938
  }
4902
4939
  let resolvePromise;
4903
4940
  let rejectPromise;
4904
- const promise = newPromise((resolve, reject) => {
4905
- resolvePromise = resolve;
4941
+ const promise = newPromise((resolve3, reject) => {
4942
+ resolvePromise = resolve3;
4906
4943
  rejectPromise = reject;
4907
4944
  });
4908
4945
  const readRequest = {
@@ -5007,8 +5044,8 @@ var require_ponyfill_es2018 = __commonJS({
5007
5044
  const reader = this._reader;
5008
5045
  let resolvePromise;
5009
5046
  let rejectPromise;
5010
- const promise = newPromise((resolve, reject) => {
5011
- resolvePromise = resolve;
5047
+ const promise = newPromise((resolve3, reject) => {
5048
+ resolvePromise = resolve3;
5012
5049
  rejectPromise = reject;
5013
5050
  });
5014
5051
  const readRequest = {
@@ -6027,8 +6064,8 @@ var require_ponyfill_es2018 = __commonJS({
6027
6064
  }
6028
6065
  let resolvePromise;
6029
6066
  let rejectPromise;
6030
- const promise = newPromise((resolve, reject) => {
6031
- resolvePromise = resolve;
6067
+ const promise = newPromise((resolve3, reject) => {
6068
+ resolvePromise = resolve3;
6032
6069
  rejectPromise = reject;
6033
6070
  });
6034
6071
  const readIntoRequest = {
@@ -6340,10 +6377,10 @@ var require_ponyfill_es2018 = __commonJS({
6340
6377
  wasAlreadyErroring = true;
6341
6378
  reason = void 0;
6342
6379
  }
6343
- const promise = newPromise((resolve, reject) => {
6380
+ const promise = newPromise((resolve3, reject) => {
6344
6381
  stream._pendingAbortRequest = {
6345
6382
  _promise: void 0,
6346
- _resolve: resolve,
6383
+ _resolve: resolve3,
6347
6384
  _reject: reject,
6348
6385
  _reason: reason,
6349
6386
  _wasAlreadyErroring: wasAlreadyErroring
@@ -6360,9 +6397,9 @@ var require_ponyfill_es2018 = __commonJS({
6360
6397
  if (state === "closed" || state === "errored") {
6361
6398
  return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
6362
6399
  }
6363
- const promise = newPromise((resolve, reject) => {
6400
+ const promise = newPromise((resolve3, reject) => {
6364
6401
  const closeRequest = {
6365
- _resolve: resolve,
6402
+ _resolve: resolve3,
6366
6403
  _reject: reject
6367
6404
  };
6368
6405
  stream._closeRequest = closeRequest;
@@ -6375,9 +6412,9 @@ var require_ponyfill_es2018 = __commonJS({
6375
6412
  return promise;
6376
6413
  }
6377
6414
  function WritableStreamAddWriteRequest(stream) {
6378
- const promise = newPromise((resolve, reject) => {
6415
+ const promise = newPromise((resolve3, reject) => {
6379
6416
  const writeRequest = {
6380
- _resolve: resolve,
6417
+ _resolve: resolve3,
6381
6418
  _reject: reject
6382
6419
  };
6383
6420
  stream._writeRequests.push(writeRequest);
@@ -6993,8 +7030,8 @@ var require_ponyfill_es2018 = __commonJS({
6993
7030
  return new TypeError("Cannot " + name + " a stream using a released writer");
6994
7031
  }
6995
7032
  function defaultWriterClosedPromiseInitialize(writer) {
6996
- writer._closedPromise = newPromise((resolve, reject) => {
6997
- writer._closedPromise_resolve = resolve;
7033
+ writer._closedPromise = newPromise((resolve3, reject) => {
7034
+ writer._closedPromise_resolve = resolve3;
6998
7035
  writer._closedPromise_reject = reject;
6999
7036
  writer._closedPromiseState = "pending";
7000
7037
  });
@@ -7030,8 +7067,8 @@ var require_ponyfill_es2018 = __commonJS({
7030
7067
  writer._closedPromiseState = "resolved";
7031
7068
  }
7032
7069
  function defaultWriterReadyPromiseInitialize(writer) {
7033
- writer._readyPromise = newPromise((resolve, reject) => {
7034
- writer._readyPromise_resolve = resolve;
7070
+ writer._readyPromise = newPromise((resolve3, reject) => {
7071
+ writer._readyPromise_resolve = resolve3;
7035
7072
  writer._readyPromise_reject = reject;
7036
7073
  });
7037
7074
  writer._readyPromiseState = "pending";
@@ -7118,7 +7155,7 @@ var require_ponyfill_es2018 = __commonJS({
7118
7155
  source._disturbed = true;
7119
7156
  let shuttingDown = false;
7120
7157
  let currentWrite = promiseResolvedWith(void 0);
7121
- return newPromise((resolve, reject) => {
7158
+ return newPromise((resolve3, reject) => {
7122
7159
  let abortAlgorithm;
7123
7160
  if (signal !== void 0) {
7124
7161
  abortAlgorithm = () => {
@@ -7263,7 +7300,7 @@ var require_ponyfill_es2018 = __commonJS({
7263
7300
  if (isError2) {
7264
7301
  reject(error);
7265
7302
  } else {
7266
- resolve(void 0);
7303
+ resolve3(void 0);
7267
7304
  }
7268
7305
  return null;
7269
7306
  }
@@ -7544,8 +7581,8 @@ var require_ponyfill_es2018 = __commonJS({
7544
7581
  let branch1;
7545
7582
  let branch2;
7546
7583
  let resolveCancelPromise;
7547
- const cancelPromise = newPromise((resolve) => {
7548
- resolveCancelPromise = resolve;
7584
+ const cancelPromise = newPromise((resolve3) => {
7585
+ resolveCancelPromise = resolve3;
7549
7586
  });
7550
7587
  function pullAlgorithm() {
7551
7588
  if (reading) {
@@ -7636,8 +7673,8 @@ var require_ponyfill_es2018 = __commonJS({
7636
7673
  let branch1;
7637
7674
  let branch2;
7638
7675
  let resolveCancelPromise;
7639
- const cancelPromise = newPromise((resolve) => {
7640
- resolveCancelPromise = resolve;
7676
+ const cancelPromise = newPromise((resolve3) => {
7677
+ resolveCancelPromise = resolve3;
7641
7678
  });
7642
7679
  function forwardReaderError(thisReader) {
7643
7680
  uponRejection(thisReader._closedPromise, (r2) => {
@@ -8417,8 +8454,8 @@ var require_ponyfill_es2018 = __commonJS({
8417
8454
  const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
8418
8455
  const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
8419
8456
  let startPromise_resolve;
8420
- const startPromise = newPromise((resolve) => {
8421
- startPromise_resolve = resolve;
8457
+ const startPromise = newPromise((resolve3) => {
8458
+ startPromise_resolve = resolve3;
8422
8459
  });
8423
8460
  InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
8424
8461
  SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
@@ -8511,8 +8548,8 @@ var require_ponyfill_es2018 = __commonJS({
8511
8548
  if (stream._backpressureChangePromise !== void 0) {
8512
8549
  stream._backpressureChangePromise_resolve();
8513
8550
  }
8514
- stream._backpressureChangePromise = newPromise((resolve) => {
8515
- stream._backpressureChangePromise_resolve = resolve;
8551
+ stream._backpressureChangePromise = newPromise((resolve3) => {
8552
+ stream._backpressureChangePromise_resolve = resolve3;
8516
8553
  });
8517
8554
  stream._backpressure = backpressure;
8518
8555
  }
@@ -8680,8 +8717,8 @@ var require_ponyfill_es2018 = __commonJS({
8680
8717
  return controller._finishPromise;
8681
8718
  }
8682
8719
  const readable = stream._readable;
8683
- controller._finishPromise = newPromise((resolve, reject) => {
8684
- controller._finishPromise_resolve = resolve;
8720
+ controller._finishPromise = newPromise((resolve3, reject) => {
8721
+ controller._finishPromise_resolve = resolve3;
8685
8722
  controller._finishPromise_reject = reject;
8686
8723
  });
8687
8724
  const cancelPromise = controller._cancelAlgorithm(reason);
@@ -8707,8 +8744,8 @@ var require_ponyfill_es2018 = __commonJS({
8707
8744
  return controller._finishPromise;
8708
8745
  }
8709
8746
  const readable = stream._readable;
8710
- controller._finishPromise = newPromise((resolve, reject) => {
8711
- controller._finishPromise_resolve = resolve;
8747
+ controller._finishPromise = newPromise((resolve3, reject) => {
8748
+ controller._finishPromise_resolve = resolve3;
8712
8749
  controller._finishPromise_reject = reject;
8713
8750
  });
8714
8751
  const flushPromise = controller._flushAlgorithm();
@@ -8738,8 +8775,8 @@ var require_ponyfill_es2018 = __commonJS({
8738
8775
  return controller._finishPromise;
8739
8776
  }
8740
8777
  const writable = stream._writable;
8741
- controller._finishPromise = newPromise((resolve, reject) => {
8742
- controller._finishPromise_resolve = resolve;
8778
+ controller._finishPromise = newPromise((resolve3, reject) => {
8779
+ controller._finishPromise_resolve = resolve3;
8743
8780
  controller._finishPromise_reject = reject;
8744
8781
  });
8745
8782
  const cancelPromise = controller._cancelAlgorithm(reason);
@@ -10635,7 +10672,7 @@ var init_abort_error = __esm({
10635
10672
 
10636
10673
  // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
10637
10674
  async function fetch(url, options_) {
10638
- return new Promise((resolve, reject) => {
10675
+ return new Promise((resolve3, reject) => {
10639
10676
  const request2 = new Request(url, options_);
10640
10677
  const { parsedURL, options } = getNodeRequestOptions(request2);
10641
10678
  if (!supportedSchemas.has(parsedURL.protocol)) {
@@ -10644,7 +10681,7 @@ async function fetch(url, options_) {
10644
10681
  if (parsedURL.protocol === "data:") {
10645
10682
  const data = dist_default(request2.url);
10646
10683
  const response2 = new Response(data, { headers: { "Content-Type": data.typeFull } });
10647
- resolve(response2);
10684
+ resolve3(response2);
10648
10685
  return;
10649
10686
  }
10650
10687
  const send = (parsedURL.protocol === "https:" ? import_node_https.default : import_node_http2.default).request;
@@ -10766,7 +10803,7 @@ async function fetch(url, options_) {
10766
10803
  if (responseReferrerPolicy) {
10767
10804
  requestOptions.referrerPolicy = responseReferrerPolicy;
10768
10805
  }
10769
- resolve(fetch(new Request(locationURL, requestOptions)));
10806
+ resolve3(fetch(new Request(locationURL, requestOptions)));
10770
10807
  finalize();
10771
10808
  return;
10772
10809
  }
@@ -10799,7 +10836,7 @@ async function fetch(url, options_) {
10799
10836
  const codings = headers.get("Content-Encoding");
10800
10837
  if (!request2.compress || request2.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
10801
10838
  response = new Response(body, responseOptions);
10802
- resolve(response);
10839
+ resolve3(response);
10803
10840
  return;
10804
10841
  }
10805
10842
  const zlibOptions = {
@@ -10813,7 +10850,7 @@ async function fetch(url, options_) {
10813
10850
  }
10814
10851
  });
10815
10852
  response = new Response(body, responseOptions);
10816
- resolve(response);
10853
+ resolve3(response);
10817
10854
  return;
10818
10855
  }
10819
10856
  if (codings === "deflate" || codings === "x-deflate") {
@@ -10837,12 +10874,12 @@ async function fetch(url, options_) {
10837
10874
  });
10838
10875
  }
10839
10876
  response = new Response(body, responseOptions);
10840
- resolve(response);
10877
+ resolve3(response);
10841
10878
  });
10842
10879
  raw.once("end", () => {
10843
10880
  if (!response) {
10844
10881
  response = new Response(body, responseOptions);
10845
- resolve(response);
10882
+ resolve3(response);
10846
10883
  }
10847
10884
  });
10848
10885
  return;
@@ -10854,11 +10891,11 @@ async function fetch(url, options_) {
10854
10891
  }
10855
10892
  });
10856
10893
  response = new Response(body, responseOptions);
10857
- resolve(response);
10894
+ resolve3(response);
10858
10895
  return;
10859
10896
  }
10860
10897
  response = new Response(body, responseOptions);
10861
- resolve(response);
10898
+ resolve3(response);
10862
10899
  });
10863
10900
  writeToStream(request_, request2).catch(reject);
10864
10901
  });
@@ -12375,7 +12412,7 @@ var init_escape2 = __esm({
12375
12412
  });
12376
12413
 
12377
12414
  // ../../node_modules/.pnpm/minimatch@9.0.5/node_modules/minimatch/dist/esm/index.js
12378
- var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path6, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
12415
+ var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path8, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
12379
12416
  var init_esm2 = __esm({
12380
12417
  "../../node_modules/.pnpm/minimatch@9.0.5/node_modules/minimatch/dist/esm/index.js"() {
12381
12418
  "use strict";
@@ -12445,11 +12482,11 @@ var init_esm2 = __esm({
12445
12482
  return (f3) => f3.length === len && f3 !== "." && f3 !== "..";
12446
12483
  };
12447
12484
  defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
12448
- path6 = {
12485
+ path8 = {
12449
12486
  win32: { sep: "\\" },
12450
12487
  posix: { sep: "/" }
12451
12488
  };
12452
- sep = defaultPlatform === "win32" ? path6.win32.sep : path6.posix.sep;
12489
+ sep = defaultPlatform === "win32" ? path8.win32.sep : path8.posix.sep;
12453
12490
  minimatch.sep = sep;
12454
12491
  GLOBSTAR = Symbol("globstar **");
12455
12492
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -15111,10 +15148,10 @@ var require_nested_property = __commonJS({
15111
15148
  return false;
15112
15149
  }
15113
15150
  }
15114
- function traverse(object, path13) {
15151
+ function traverse(object, path15) {
15115
15152
  var callback = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
15116
15153
  };
15117
- var segments = path13.split(PATH_DELIMITER);
15154
+ var segments = path15.split(PATH_DELIMITER);
15118
15155
  var length = segments.length;
15119
15156
  var _loop = function _loop2(idx2) {
15120
15157
  var currentSegment = segments[idx2];
@@ -15222,9 +15259,9 @@ function normaliseResult(result) {
15222
15259
  return output;
15223
15260
  }
15224
15261
  function parseXML(xml) {
15225
- return new Promise((resolve) => {
15262
+ return new Promise((resolve3) => {
15226
15263
  const result = getParser().parse(xml);
15227
- resolve(normaliseResult(result));
15264
+ resolve3(normaliseResult(result));
15228
15265
  });
15229
15266
  }
15230
15267
  function prepareFileFromProps(props, filename, isDetailed = false) {
@@ -15356,11 +15393,11 @@ async function createDirectory(context, dirPath, options = {}) {
15356
15393
  const response = await request(requestOptions, context);
15357
15394
  handleResponseCode(context, response);
15358
15395
  }
15359
- function ensureCollectionPath(path13) {
15360
- if (!path13.endsWith("/")) {
15361
- return path13 + "/";
15396
+ function ensureCollectionPath(path15) {
15397
+ if (!path15.endsWith("/")) {
15398
+ return path15 + "/";
15362
15399
  }
15363
- return path13;
15400
+ return path15;
15364
15401
  }
15365
15402
  async function createDirectoryRecursively(context, dirPath, options = {}) {
15366
15403
  const paths = getAllDirectories(normalisePath(dirPath));
@@ -15735,7 +15772,7 @@ var init_xml = __esm({
15735
15772
  });
15736
15773
 
15737
15774
  // ../../node_modules/.pnpm/webdav@5.8.0/node_modules/webdav/dist/node/operations/lock.js
15738
- async function lock(context, path13, options = {}) {
15775
+ async function lock(context, path15, options = {}) {
15739
15776
  const { refreshToken, timeout = DEFAULT_TIMEOUT } = options;
15740
15777
  const headers = {
15741
15778
  Accept: "text/plain,application/xml",
@@ -15745,7 +15782,7 @@ async function lock(context, path13, options = {}) {
15745
15782
  headers.If = refreshToken;
15746
15783
  }
15747
15784
  const requestOptions = prepareRequestOptions({
15748
- url: joinURL(context.remoteURL, encodePath(path13)),
15785
+ url: joinURL(context.remoteURL, encodePath(path15)),
15749
15786
  method: "LOCK",
15750
15787
  headers,
15751
15788
  data: generateLockXML(context.contactHref)
@@ -15765,9 +15802,9 @@ async function lock(context, path13, options = {}) {
15765
15802
  serverTimeout
15766
15803
  };
15767
15804
  }
15768
- async function unlock(context, path13, token, options = {}) {
15805
+ async function unlock(context, path15, token, options = {}) {
15769
15806
  const requestOptions = prepareRequestOptions({
15770
- url: joinURL(context.remoteURL, encodePath(path13)),
15807
+ url: joinURL(context.remoteURL, encodePath(path15)),
15771
15808
  method: "UNLOCK",
15772
15809
  headers: {
15773
15810
  "Lock-Token": token
@@ -15817,9 +15854,9 @@ var init_quota = __esm({
15817
15854
 
15818
15855
  // ../../node_modules/.pnpm/webdav@5.8.0/node_modules/webdav/dist/node/operations/getQuota.js
15819
15856
  async function getQuota(context, options = {}) {
15820
- const path13 = options.path || "/";
15857
+ const path15 = options.path || "/";
15821
15858
  const requestOptions = prepareRequestOptions({
15822
- url: joinURL(context.remoteURL, path13),
15859
+ url: joinURL(context.remoteURL, path15),
15823
15860
  method: "PROPFIND",
15824
15861
  headers: {
15825
15862
  Accept: "text/plain,application/xml",
@@ -16159,29 +16196,29 @@ function createClient(remoteURL, options = {}) {
16159
16196
  setupAuth(context, username, password, token, ha1);
16160
16197
  return {
16161
16198
  copyFile: (filename, destination, options2) => copyFile(context, filename, destination, options2),
16162
- createDirectory: (path13, options2) => createDirectory(context, path13, options2),
16199
+ createDirectory: (path15, options2) => createDirectory(context, path15, options2),
16163
16200
  createReadStream: (filename, options2) => createReadStream2(context, filename, options2),
16164
16201
  createWriteStream: (filename, options2, callback) => createWriteStream(context, filename, options2, callback),
16165
- customRequest: (path13, requestOptions) => customRequest(context, path13, requestOptions),
16202
+ customRequest: (path15, requestOptions) => customRequest(context, path15, requestOptions),
16166
16203
  deleteFile: (filename, options2) => deleteFile(context, filename, options2),
16167
- exists: (path13, options2) => exists(context, path13, options2),
16168
- getDirectoryContents: (path13, options2) => getDirectoryContents(context, path13, options2),
16204
+ exists: (path15, options2) => exists(context, path15, options2),
16205
+ getDirectoryContents: (path15, options2) => getDirectoryContents(context, path15, options2),
16169
16206
  getFileContents: (filename, options2) => getFileContents(context, filename, options2),
16170
16207
  getFileDownloadLink: (filename) => getFileDownloadLink(context, filename),
16171
16208
  getFileUploadLink: (filename) => getFileUploadLink(context, filename),
16172
16209
  getHeaders: () => Object.assign({}, context.headers),
16173
16210
  getQuota: (options2) => getQuota(context, options2),
16174
- lock: (path13, options2) => lock(context, path13, options2),
16211
+ lock: (path15, options2) => lock(context, path15, options2),
16175
16212
  moveFile: (filename, destinationFilename, options2) => moveFile(context, filename, destinationFilename, options2),
16176
16213
  putFileContents: (filename, data, options2) => putFileContents(context, filename, data, options2),
16177
16214
  partialUpdateFileContents: (filePath, start, end, data, options2) => partialUpdateFileContents(context, filePath, start, end, data, options2),
16178
- getDAVCompliance: (path13) => getDAVCompliance(context, path13),
16179
- search: (path13, options2) => getSearch2(context, path13, options2),
16215
+ getDAVCompliance: (path15) => getDAVCompliance(context, path15),
16216
+ search: (path15, options2) => getSearch2(context, path15, options2),
16180
16217
  setHeaders: (headers2) => {
16181
16218
  context.headers = Object.assign({}, headers2);
16182
16219
  },
16183
- stat: (path13, options2) => getStat(context, path13, options2),
16184
- unlock: (path13, token2, options2) => unlock(context, path13, token2, options2)
16220
+ stat: (path15, options2) => getStat(context, path15, options2),
16221
+ unlock: (path15, token2, options2) => unlock(context, path15, token2, options2)
16185
16222
  };
16186
16223
  }
16187
16224
  var DEFAULT_CONTACT_HREF;
@@ -16228,7 +16265,7 @@ function normalizePath(dir) {
16228
16265
  if (!dir || dir === "/") {
16229
16266
  return "/";
16230
16267
  }
16231
- let normalized = dir.trim().replace(/^\/+/, "").replace(/\/+$/, "");
16268
+ const normalized = dir.trim().replace(/^\/+/, "").replace(/\/+$/, "");
16232
16269
  return `/${normalized}`;
16233
16270
  }
16234
16271
  function joinPath(baseDir, filename) {
@@ -16358,6 +16395,12 @@ function deriveKey(password, salt) {
16358
16395
  return crypto.pbkdf2Sync(password, salt, PBKDF2_ITERATIONS, KEY_LENGTH, "sha256");
16359
16396
  }
16360
16397
  function encryptApiKey(apiKey, password) {
16398
+ if (typeof apiKey !== "string") {
16399
+ throw new Error("API Key \u7F3A\u5931\u6216\u7C7B\u578B\u9519\u8BEF\uFF0C\u65E0\u6CD5\u52A0\u5BC6");
16400
+ }
16401
+ if (!password) {
16402
+ throw new Error("\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
16403
+ }
16361
16404
  const salt = crypto.randomBytes(SALT_LENGTH);
16362
16405
  const iv = crypto.randomBytes(IV_LENGTH);
16363
16406
  const key = deriveKey(password, salt);
@@ -16386,10 +16429,15 @@ function decryptApiKey(encryptedApiKey, password) {
16386
16429
  }
16387
16430
  }
16388
16431
  function encryptProviders(providers, password) {
16389
- return providers.map((provider) => ({
16390
- ...provider,
16391
- apiKey: encryptApiKey(provider.apiKey, password)
16392
- }));
16432
+ return providers.map((provider) => {
16433
+ if (typeof provider.apiKey !== "string" || provider.apiKey.length === 0) {
16434
+ throw new Error(`\u670D\u52A1\u5546 "${provider.name}" \u7684 API Key \u4E3A\u7A7A\u6216\u7F3A\u5931\uFF0C\u8BF7\u5148\u5728 ccman \u4E2D\u8865\u5168\u540E\u518D\u8FDB\u884C\u540C\u6B65`);
16435
+ }
16436
+ return {
16437
+ ...provider,
16438
+ apiKey: encryptApiKey(provider.apiKey, password)
16439
+ };
16440
+ });
16393
16441
  }
16394
16442
  function decryptProviders(encryptedProviders, password) {
16395
16443
  return encryptedProviders.map((provider) => ({
@@ -16802,8 +16850,8 @@ var init_sync_v2 = __esm({
16802
16850
  // ../core/dist/export.js
16803
16851
  function validateExport() {
16804
16852
  const ccmanDir2 = getCcmanDir();
16805
- const codexPath = path10.join(ccmanDir2, CODEX_CONFIG_FILE);
16806
- const claudePath = path10.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16853
+ const codexPath = path12.join(ccmanDir2, CODEX_CONFIG_FILE);
16854
+ const claudePath = path12.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16807
16855
  const missingFiles = [];
16808
16856
  if (!fileExists(codexPath)) {
16809
16857
  missingFiles.push(CODEX_CONFIG_FILE);
@@ -16836,8 +16884,8 @@ function validateImportDir(sourceDir) {
16836
16884
  foundFiles: []
16837
16885
  };
16838
16886
  }
16839
- const codexPath = path10.join(sourceDir, CODEX_CONFIG_FILE);
16840
- const claudePath = path10.join(sourceDir, CLAUDE_CONFIG_FILE);
16887
+ const codexPath = path12.join(sourceDir, CODEX_CONFIG_FILE);
16888
+ const claudePath = path12.join(sourceDir, CLAUDE_CONFIG_FILE);
16841
16889
  const foundFiles = [];
16842
16890
  if (fileExists(codexPath)) {
16843
16891
  foundFiles.push(CODEX_CONFIG_FILE);
@@ -16865,14 +16913,14 @@ function exportConfig(targetDir) {
16865
16913
  ensureDir(targetDir);
16866
16914
  const ccmanDir2 = getCcmanDir();
16867
16915
  const exportedFiles = [];
16868
- const codexSrc = path10.join(ccmanDir2, CODEX_CONFIG_FILE);
16869
- const codexDst = path10.join(targetDir, CODEX_CONFIG_FILE);
16916
+ const codexSrc = path12.join(ccmanDir2, CODEX_CONFIG_FILE);
16917
+ const codexDst = path12.join(targetDir, CODEX_CONFIG_FILE);
16870
16918
  if (fileExists(codexSrc)) {
16871
16919
  fs9.copyFileSync(codexSrc, codexDst);
16872
16920
  exportedFiles.push(CODEX_CONFIG_FILE);
16873
16921
  }
16874
- const claudeSrc = path10.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16875
- const claudeDst = path10.join(targetDir, CLAUDE_CONFIG_FILE);
16922
+ const claudeSrc = path12.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16923
+ const claudeDst = path12.join(targetDir, CLAUDE_CONFIG_FILE);
16876
16924
  if (fileExists(claudeSrc)) {
16877
16925
  fs9.copyFileSync(claudeSrc, claudeDst);
16878
16926
  exportedFiles.push(CLAUDE_CONFIG_FILE);
@@ -16894,22 +16942,22 @@ function importConfig(sourceDir) {
16894
16942
  ensureDir(ccmanDir2);
16895
16943
  try {
16896
16944
  if (validation.foundFiles.includes(CODEX_CONFIG_FILE)) {
16897
- const codexDst = path10.join(ccmanDir2, CODEX_CONFIG_FILE);
16945
+ const codexDst = path12.join(ccmanDir2, CODEX_CONFIG_FILE);
16898
16946
  if (fileExists(codexDst)) {
16899
16947
  const backupPath = backupConfig(codexDst);
16900
16948
  backupPaths.push(backupPath);
16901
16949
  }
16902
- const codexSrc = path10.join(sourceDir, CODEX_CONFIG_FILE);
16950
+ const codexSrc = path12.join(sourceDir, CODEX_CONFIG_FILE);
16903
16951
  fs9.copyFileSync(codexSrc, codexDst);
16904
16952
  importedFiles.push(CODEX_CONFIG_FILE);
16905
16953
  }
16906
16954
  if (validation.foundFiles.includes(CLAUDE_CONFIG_FILE)) {
16907
- const claudeDst = path10.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16955
+ const claudeDst = path12.join(ccmanDir2, CLAUDE_CONFIG_FILE);
16908
16956
  if (fileExists(claudeDst)) {
16909
16957
  const backupPath = backupConfig(claudeDst);
16910
16958
  backupPaths.push(backupPath);
16911
16959
  }
16912
- const claudeSrc = path10.join(sourceDir, CLAUDE_CONFIG_FILE);
16960
+ const claudeSrc = path12.join(sourceDir, CLAUDE_CONFIG_FILE);
16913
16961
  fs9.copyFileSync(claudeSrc, claudeDst);
16914
16962
  importedFiles.push(CLAUDE_CONFIG_FILE);
16915
16963
  }
@@ -16928,12 +16976,12 @@ function importConfig(sourceDir) {
16928
16976
  throw new Error(`\u5BFC\u5165\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u5907\u4EFD: ${error.message}`);
16929
16977
  }
16930
16978
  }
16931
- var fs9, path10, CODEX_CONFIG_FILE, CLAUDE_CONFIG_FILE;
16979
+ var fs9, path12, CODEX_CONFIG_FILE, CLAUDE_CONFIG_FILE;
16932
16980
  var init_export = __esm({
16933
16981
  "../core/dist/export.js"() {
16934
16982
  "use strict";
16935
16983
  fs9 = __toESM(require("fs"), 1);
16936
- path10 = __toESM(require("path"), 1);
16984
+ path12 = __toESM(require("path"), 1);
16937
16985
  init_paths();
16938
16986
  init_file();
16939
16987
  init_merge2();
@@ -17240,55 +17288,63 @@ function configCommand(program2) {
17240
17288
  return;
17241
17289
  }
17242
17290
  }
17243
- const newConfig = { ...existingConfig };
17291
+ let newConfig;
17292
+ if (existingConfig) {
17293
+ newConfig = { ...existingConfig };
17294
+ } else {
17295
+ if (!trimmedAnswers.webdavUrl) {
17296
+ throw new Error("WebDAV \u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A");
17297
+ }
17298
+ if (!trimmedAnswers.username) {
17299
+ throw new Error("\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A");
17300
+ }
17301
+ if (!trimmedAnswers.password) {
17302
+ throw new Error("\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
17303
+ }
17304
+ if (!trimmedAnswers.syncPassword) {
17305
+ throw new Error("\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
17306
+ }
17307
+ newConfig = {
17308
+ webdavUrl: trimmedAnswers.webdavUrl,
17309
+ username: trimmedAnswers.username,
17310
+ password: trimmedAnswers.password,
17311
+ authType: trimmedAnswers.authType,
17312
+ remoteDir: trimmedAnswers.remoteDir || "/",
17313
+ syncPassword: trimmedAnswers.syncPassword,
17314
+ rememberSyncPassword: trimmedAnswers.rememberSyncPassword,
17315
+ lastSync: void 0
17316
+ };
17317
+ }
17244
17318
  let hasChanges = false;
17245
- if (trimmedAnswers.webdavUrl) {
17246
- if (trimmedAnswers.webdavUrl !== existingConfig?.webdavUrl) {
17319
+ if (existingConfig) {
17320
+ if (trimmedAnswers.webdavUrl && trimmedAnswers.webdavUrl !== existingConfig.webdavUrl) {
17247
17321
  newConfig.webdavUrl = trimmedAnswers.webdavUrl;
17248
17322
  hasChanges = true;
17249
17323
  }
17250
- } else if (!existingConfig) {
17251
- throw new Error("WebDAV \u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A");
17252
- }
17253
- if (trimmedAnswers.username) {
17254
- if (trimmedAnswers.username !== existingConfig?.username) {
17324
+ if (trimmedAnswers.username && trimmedAnswers.username !== existingConfig.username) {
17255
17325
  newConfig.username = trimmedAnswers.username;
17256
17326
  hasChanges = true;
17257
17327
  }
17258
- } else if (!existingConfig) {
17259
- throw new Error("\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A");
17260
- }
17261
- if (trimmedAnswers.password) {
17262
- if (trimmedAnswers.password !== existingConfig?.password) {
17328
+ if (trimmedAnswers.password && trimmedAnswers.password !== existingConfig.password) {
17263
17329
  newConfig.password = trimmedAnswers.password;
17264
17330
  hasChanges = true;
17265
17331
  }
17266
- } else if (!existingConfig) {
17267
- throw new Error("\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
17268
- }
17269
- if (trimmedAnswers.authType !== existingConfig?.authType) {
17270
- newConfig.authType = trimmedAnswers.authType;
17271
- hasChanges = true;
17272
- }
17273
- if (trimmedAnswers.remoteDir) {
17274
- if (trimmedAnswers.remoteDir !== existingConfig?.remoteDir) {
17332
+ if (trimmedAnswers.authType !== existingConfig.authType) {
17333
+ newConfig.authType = trimmedAnswers.authType;
17334
+ hasChanges = true;
17335
+ }
17336
+ if (trimmedAnswers.remoteDir && trimmedAnswers.remoteDir !== existingConfig.remoteDir) {
17275
17337
  newConfig.remoteDir = trimmedAnswers.remoteDir;
17276
17338
  hasChanges = true;
17277
17339
  }
17278
- } else if (!existingConfig) {
17279
- newConfig.remoteDir = "/";
17280
- }
17281
- if (trimmedAnswers.syncPassword) {
17282
- if (trimmedAnswers.syncPassword !== existingConfig?.syncPassword) {
17340
+ if (trimmedAnswers.syncPassword && trimmedAnswers.syncPassword !== existingConfig.syncPassword) {
17283
17341
  newConfig.syncPassword = trimmedAnswers.syncPassword;
17284
17342
  hasChanges = true;
17285
17343
  }
17286
- } else if (!existingConfig) {
17287
- throw new Error("\u540C\u6B65\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
17288
- }
17289
- if (trimmedAnswers.rememberSyncPassword !== existingConfig?.rememberSyncPassword) {
17290
- newConfig.rememberSyncPassword = trimmedAnswers.rememberSyncPassword;
17291
- hasChanges = true;
17344
+ if (trimmedAnswers.rememberSyncPassword !== existingConfig.rememberSyncPassword) {
17345
+ newConfig.rememberSyncPassword = trimmedAnswers.rememberSyncPassword;
17346
+ hasChanges = true;
17347
+ }
17292
17348
  }
17293
17349
  if (!hasChanges && existingConfig) {
17294
17350
  console.log();
@@ -17446,7 +17502,7 @@ function uploadCommand(program2) {
17446
17502
  console.log(import_chalk6.default.gray("\n\u5DF2\u53D6\u6D88\n"));
17447
17503
  return;
17448
17504
  }
17449
- let syncPassword = config.syncPassword;
17505
+ let syncPassword = config.syncPassword || "";
17450
17506
  if (!syncPassword) {
17451
17507
  const { password } = await import_inquirer3.default.prompt([
17452
17508
  {
@@ -17525,7 +17581,7 @@ function downloadCommand(program2) {
17525
17581
  console.log(import_chalk7.default.gray("\n\u5DF2\u53D6\u6D88\n"));
17526
17582
  return;
17527
17583
  }
17528
- let syncPassword = config.syncPassword;
17584
+ let syncPassword = config.syncPassword || "";
17529
17585
  if (!syncPassword) {
17530
17586
  const { password } = await import_inquirer4.default.prompt([
17531
17587
  {
@@ -17563,8 +17619,8 @@ function downloadCommand(program2) {
17563
17619
  console.log();
17564
17620
  if (backupPaths.length > 0) {
17565
17621
  console.log(import_chalk7.default.gray("\u672C\u5730\u5907\u4EFD:"));
17566
- backupPaths.forEach((path13) => {
17567
- console.log(import_chalk7.default.gray(` ${path13}`));
17622
+ backupPaths.forEach((path15) => {
17623
+ console.log(import_chalk7.default.gray(` ${path15}`));
17568
17624
  });
17569
17625
  console.log();
17570
17626
  }
@@ -17600,7 +17656,7 @@ function mergeCommand(program2) {
17600
17656
  console.log(import_chalk8.default.gray("\n\u5DF2\u53D6\u6D88\n"));
17601
17657
  return;
17602
17658
  }
17603
- let syncPassword = config.syncPassword;
17659
+ let syncPassword = config.syncPassword || "";
17604
17660
  if (!syncPassword) {
17605
17661
  const { password } = await import_inquirer5.default.prompt([
17606
17662
  {
@@ -17626,8 +17682,8 @@ function mergeCommand(program2) {
17626
17682
  console.log();
17627
17683
  if (result.backupPaths.length > 0) {
17628
17684
  console.log(import_chalk8.default.gray("\u5907\u4EFD:"));
17629
- result.backupPaths.forEach((path13) => {
17630
- console.log(import_chalk8.default.gray(` ${path13}`));
17685
+ result.backupPaths.forEach((path15) => {
17686
+ console.log(import_chalk8.default.gray(` ${path15}`));
17631
17687
  });
17632
17688
  console.log();
17633
17689
  }
@@ -17870,6 +17926,10 @@ function formatProviderTable(providers, currentId) {
17870
17926
  lines.push(` ${marker} ${name}${tag}`);
17871
17927
  const url = isCurrent ? import_chalk2.default.green(p.baseUrl) : import_chalk2.default.gray(p.baseUrl);
17872
17928
  lines.push(` ${url}`);
17929
+ if (p.desc) {
17930
+ const desc = isCurrent ? import_chalk2.default.green(p.desc) : import_chalk2.default.gray(p.desc);
17931
+ lines.push(` ${desc}`);
17932
+ }
17873
17933
  if (index < providers.length - 1) {
17874
17934
  lines.push("");
17875
17935
  }
@@ -17891,6 +17951,12 @@ async function promptProviderForm(defaults2) {
17891
17951
  return true;
17892
17952
  }
17893
17953
  },
17954
+ {
17955
+ type: "input",
17956
+ name: "desc",
17957
+ message: "\u63CF\u8FF0(\u53EF\u9009):",
17958
+ default: defaults2?.desc || void 0
17959
+ },
17894
17960
  {
17895
17961
  type: "input",
17896
17962
  name: "baseUrl",
@@ -17918,6 +17984,7 @@ async function promptProviderForm(defaults2) {
17918
17984
  ]);
17919
17985
  return {
17920
17986
  name: answers.name,
17987
+ desc: answers.desc || void 0,
17921
17988
  baseUrl: answers.baseUrl,
17922
17989
  apiKey: answers.apiKey
17923
17990
  };
@@ -18046,6 +18113,7 @@ async function handleAdd(tool) {
18046
18113
  }
18047
18114
  ]);
18048
18115
  let name;
18116
+ let desc;
18049
18117
  let baseUrl;
18050
18118
  let apiKey;
18051
18119
  if (usePreset) {
@@ -18066,10 +18134,12 @@ async function handleAdd(tool) {
18066
18134
  `));
18067
18135
  const input = await promptProviderForm({
18068
18136
  name: preset.name,
18137
+ desc: "",
18069
18138
  baseUrl: preset.baseUrl,
18070
18139
  apiKey: ""
18071
18140
  });
18072
18141
  name = input.name;
18142
+ desc = input.desc;
18073
18143
  baseUrl = input.baseUrl;
18074
18144
  apiKey = input.apiKey;
18075
18145
  } else {
@@ -18101,10 +18171,11 @@ async function handleAdd(tool) {
18101
18171
  }
18102
18172
  ]);
18103
18173
  name = answers.name;
18174
+ desc = void 0;
18104
18175
  baseUrl = answers.baseUrl;
18105
18176
  apiKey = answers.apiKey;
18106
18177
  }
18107
- const provider = manager.add({ name, baseUrl, apiKey });
18178
+ const provider = manager.add({ name, desc, baseUrl, apiKey });
18108
18179
  console.log();
18109
18180
  console.log(import_chalk11.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
18110
18181
  console.log();
@@ -18123,8 +18194,10 @@ async function handleAdd(tool) {
18123
18194
  manager.switch(provider.id);
18124
18195
  console.log(import_chalk11.default.green("\u2705 \u5DF2\u5207\u6362\u5230\u65B0\u670D\u52A1\u5546\n"));
18125
18196
  } else {
18126
- console.log(import_chalk11.default.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + import_chalk11.default.white(` ccman ${tool === "codex" ? "cx" : "cc"} use "${provider.name}"
18127
- `));
18197
+ console.log(
18198
+ import_chalk11.default.blue("\u{1F4A1} \u7A0D\u540E\u5207\u6362:") + import_chalk11.default.white(` ccman ${tool === "codex" ? "cx" : "cc"} use "${provider.name}"
18199
+ `)
18200
+ );
18128
18201
  }
18129
18202
  }
18130
18203
  async function handleSwitch(tool) {
@@ -18165,7 +18238,7 @@ async function handleList(tool) {
18165
18238
  }
18166
18239
  console.log(import_chalk11.default.bold(`
18167
18240
  \u{1F4CB} ${toolName} \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
18168
- console.log(formatProviderTable(providers, current?.id, toolName));
18241
+ console.log(formatProviderTable(providers, current?.id));
18169
18242
  }
18170
18243
  async function handleCurrent(tool) {
18171
18244
  const manager = tool === "codex" ? createCodexManager() : createClaudeManager();
@@ -18228,6 +18301,12 @@ async function handleEdit(tool) {
18228
18301
  return true;
18229
18302
  }
18230
18303
  },
18304
+ {
18305
+ type: "input",
18306
+ name: "desc",
18307
+ message: "\u63CF\u8FF0(\u53EF\u9009):",
18308
+ default: provider.desc || ""
18309
+ },
18231
18310
  {
18232
18311
  type: "password",
18233
18312
  name: "apiKey",
@@ -18237,6 +18316,7 @@ async function handleEdit(tool) {
18237
18316
  ]);
18238
18317
  manager.edit(providerId, {
18239
18318
  name: answers.name,
18319
+ desc: answers.desc || void 0,
18240
18320
  baseUrl: answers.baseUrl,
18241
18321
  apiKey: answers.apiKey || void 0
18242
18322
  });
@@ -18279,6 +18359,8 @@ async function handleClone(tool) {
18279
18359
  ]);
18280
18360
  const newProvider = manager.add({
18281
18361
  name: answers.name,
18362
+ // 克隆时不继承描述,留空让用户后续编辑
18363
+ desc: void 0,
18282
18364
  baseUrl: provider.baseUrl,
18283
18365
  apiKey: answers.apiKey
18284
18366
  });
@@ -18342,6 +18424,7 @@ function addCommand(program2) {
18342
18424
  }
18343
18425
  ]);
18344
18426
  let name;
18427
+ let desc;
18345
18428
  let baseUrl;
18346
18429
  let apiKey;
18347
18430
  if (usePreset) {
@@ -18362,10 +18445,12 @@ function addCommand(program2) {
18362
18445
  `));
18363
18446
  const input = await promptProviderForm({
18364
18447
  name: preset.name,
18448
+ desc: "",
18365
18449
  baseUrl: preset.baseUrl,
18366
18450
  apiKey: ""
18367
18451
  });
18368
18452
  name = input.name;
18453
+ desc = input.desc;
18369
18454
  baseUrl = input.baseUrl;
18370
18455
  apiKey = input.apiKey;
18371
18456
  } else {
@@ -18403,10 +18488,11 @@ function addCommand(program2) {
18403
18488
  }
18404
18489
  ]);
18405
18490
  name = answers.name;
18491
+ desc = void 0;
18406
18492
  baseUrl = answers.baseUrl;
18407
18493
  apiKey = answers.apiKey;
18408
18494
  }
18409
- const provider = manager.add({ name, baseUrl, apiKey });
18495
+ const provider = manager.add({ name, desc, baseUrl, apiKey });
18410
18496
  console.log();
18411
18497
  console.log(import_chalk12.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
18412
18498
  console.log();
@@ -18456,7 +18542,7 @@ function listCommand(program2) {
18456
18542
  }
18457
18543
  console.log(import_chalk13.default.bold(`
18458
18544
  \u{1F4CB} Codex \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
18459
- console.log(formatProviderTable(providers, current?.id, "Codex"));
18545
+ console.log(formatProviderTable(providers, current?.id));
18460
18546
  } catch (error) {
18461
18547
  console.error(import_chalk13.default.red(`
18462
18548
  \u274C ${error.message}
@@ -18762,6 +18848,8 @@ function cloneCommand(program2) {
18762
18848
  `));
18763
18849
  const input = await promptProviderForm({
18764
18850
  name: `${source.name}\uFF08\u526F\u672C\uFF09`,
18851
+ // 克隆时不继承描述
18852
+ desc: "",
18765
18853
  baseUrl: source.baseUrl,
18766
18854
  apiKey: source.apiKey
18767
18855
  });
@@ -18815,6 +18903,7 @@ function addCommand2(program2) {
18815
18903
  }
18816
18904
  ]);
18817
18905
  let name;
18906
+ let desc;
18818
18907
  let baseUrl;
18819
18908
  let apiKey;
18820
18909
  if (usePreset) {
@@ -18835,10 +18924,12 @@ function addCommand2(program2) {
18835
18924
  `));
18836
18925
  const input = await promptProviderForm({
18837
18926
  name: preset.name,
18927
+ desc: "",
18838
18928
  baseUrl: preset.baseUrl,
18839
18929
  apiKey: ""
18840
18930
  });
18841
18931
  name = input.name;
18932
+ desc = input.desc;
18842
18933
  baseUrl = input.baseUrl;
18843
18934
  apiKey = input.apiKey;
18844
18935
  } else {
@@ -18876,10 +18967,11 @@ function addCommand2(program2) {
18876
18967
  }
18877
18968
  ]);
18878
18969
  name = answers.name;
18970
+ desc = void 0;
18879
18971
  baseUrl = answers.baseUrl;
18880
18972
  apiKey = answers.apiKey;
18881
18973
  }
18882
- const provider = manager.add({ name, baseUrl, apiKey });
18974
+ const provider = manager.add({ name, desc, baseUrl, apiKey });
18883
18975
  console.log();
18884
18976
  console.log(import_chalk19.default.green("\u2705 \u6DFB\u52A0\u6210\u529F"));
18885
18977
  console.log();
@@ -18928,7 +19020,7 @@ function listCommand2(program2) {
18928
19020
  }
18929
19021
  console.log(import_chalk20.default.bold(`
18930
19022
  \u{1F4CB} Claude Code \u670D\u52A1\u5546 (${providers.length} \u4E2A)`));
18931
- console.log(formatProviderTable(providers, current?.id, "Claude Code"));
19023
+ console.log(formatProviderTable(providers, current?.id));
18932
19024
  } catch (error) {
18933
19025
  console.error(import_chalk20.default.red(`
18934
19026
  \u274C ${error.message}
@@ -19233,6 +19325,8 @@ function cloneCommand2(program2) {
19233
19325
  `));
19234
19326
  const input = await promptProviderForm({
19235
19327
  name: `${source.name}\uFF08\u526F\u672C\uFF09`,
19328
+ // 克隆时不继承描述
19329
+ desc: "",
19236
19330
  baseUrl: source.baseUrl,
19237
19331
  apiKey: source.apiKey
19238
19332
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccman",
3
- "version": "3.0.27",
3
+ "version": "3.0.29",
4
4
  "description": "Manage Codex and Claude Code API service provider configurations",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {