ccjk 12.0.7 → 12.0.8

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 (299) hide show
  1. package/package.json +1 -1
  2. package/dist/chunks/agent-teams.mjs +0 -136
  3. package/dist/chunks/agent.mjs +0 -1439
  4. package/dist/chunks/agents.mjs +0 -3778
  5. package/dist/chunks/api-cli.mjs +0 -132
  6. package/dist/chunks/api-providers.mjs +0 -129
  7. package/dist/chunks/api.mjs +0 -112
  8. package/dist/chunks/auto-bootstrap.mjs +0 -358
  9. package/dist/chunks/auto-init.mjs +0 -7584
  10. package/dist/chunks/auto-updater.mjs +0 -410
  11. package/dist/chunks/banner.mjs +0 -188
  12. package/dist/chunks/bash.mjs +0 -187
  13. package/dist/chunks/boost.mjs +0 -397
  14. package/dist/chunks/ccjk-agents.mjs +0 -414
  15. package/dist/chunks/ccjk-all.mjs +0 -1028
  16. package/dist/chunks/ccjk-config.mjs +0 -261
  17. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  18. package/dist/chunks/ccjk-mcp.mjs +0 -761
  19. package/dist/chunks/ccjk-setup.mjs +0 -763
  20. package/dist/chunks/ccjk-skills.mjs +0 -514
  21. package/dist/chunks/ccr.mjs +0 -98
  22. package/dist/chunks/ccu.mjs +0 -40
  23. package/dist/chunks/check-updates.mjs +0 -108
  24. package/dist/chunks/claude-code-config-manager.mjs +0 -750
  25. package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
  26. package/dist/chunks/claude-config.mjs +0 -236
  27. package/dist/chunks/claude-wrapper.mjs +0 -85
  28. package/dist/chunks/cleanup-migration.mjs +0 -20
  29. package/dist/chunks/cli-hook.mjs +0 -2285
  30. package/dist/chunks/cloud-sync.mjs +0 -29
  31. package/dist/chunks/codex-config-switch.mjs +0 -451
  32. package/dist/chunks/codex-provider-manager.mjs +0 -236
  33. package/dist/chunks/codex-uninstaller.mjs +0 -404
  34. package/dist/chunks/codex.mjs +0 -2077
  35. package/dist/chunks/commands.mjs +0 -108
  36. package/dist/chunks/commands2.mjs +0 -413
  37. package/dist/chunks/commit.mjs +0 -138
  38. package/dist/chunks/completion.mjs +0 -515
  39. package/dist/chunks/config-consolidator.mjs +0 -172
  40. package/dist/chunks/config-switch.mjs +0 -317
  41. package/dist/chunks/config.mjs +0 -379
  42. package/dist/chunks/config2.mjs +0 -477
  43. package/dist/chunks/config3.mjs +0 -470
  44. package/dist/chunks/constants.mjs +0 -133
  45. package/dist/chunks/context-loader.mjs +0 -343
  46. package/dist/chunks/context.mjs +0 -372
  47. package/dist/chunks/convoy-manager.mjs +0 -880
  48. package/dist/chunks/dashboard.mjs +0 -476
  49. package/dist/chunks/doctor.mjs +0 -964
  50. package/dist/chunks/evolution.mjs +0 -382
  51. package/dist/chunks/features.mjs +0 -698
  52. package/dist/chunks/fish.mjs +0 -181
  53. package/dist/chunks/fs-operations.mjs +0 -192
  54. package/dist/chunks/health-alerts.mjs +0 -304
  55. package/dist/chunks/health-check.mjs +0 -532
  56. package/dist/chunks/help.mjs +0 -340
  57. package/dist/chunks/hook-installer.mjs +0 -45
  58. package/dist/chunks/index.mjs +0 -24
  59. package/dist/chunks/index10.mjs +0 -1171
  60. package/dist/chunks/index11.mjs +0 -1008
  61. package/dist/chunks/index12.mjs +0 -193
  62. package/dist/chunks/index13.mjs +0 -218
  63. package/dist/chunks/index14.mjs +0 -663
  64. package/dist/chunks/index2.mjs +0 -19
  65. package/dist/chunks/index3.mjs +0 -19092
  66. package/dist/chunks/index4.mjs +0 -8
  67. package/dist/chunks/index5.mjs +0 -7600
  68. package/dist/chunks/index6.mjs +0 -171
  69. package/dist/chunks/index7.mjs +0 -3583
  70. package/dist/chunks/index8.mjs +0 -19
  71. package/dist/chunks/index9.mjs +0 -616
  72. package/dist/chunks/init.mjs +0 -1606
  73. package/dist/chunks/installer.mjs +0 -690
  74. package/dist/chunks/installer2.mjs +0 -179
  75. package/dist/chunks/interview.mjs +0 -2927
  76. package/dist/chunks/json-config.mjs +0 -60
  77. package/dist/chunks/linux.mjs +0 -3863
  78. package/dist/chunks/macos.mjs +0 -69
  79. package/dist/chunks/main.mjs +0 -635
  80. package/dist/chunks/manager.mjs +0 -1048
  81. package/dist/chunks/marketplace.mjs +0 -949
  82. package/dist/chunks/mcp-cli.mjs +0 -204
  83. package/dist/chunks/mcp-performance.mjs +0 -187
  84. package/dist/chunks/mcp.mjs +0 -1231
  85. package/dist/chunks/menu.mjs +0 -652
  86. package/dist/chunks/metrics-display.mjs +0 -153
  87. package/dist/chunks/migrator.mjs +0 -178
  88. package/dist/chunks/monitor.mjs +0 -1856
  89. package/dist/chunks/notification.mjs +0 -1864
  90. package/dist/chunks/onboarding.mjs +0 -385
  91. package/dist/chunks/package.mjs +0 -3
  92. package/dist/chunks/paradigm.mjs +0 -74
  93. package/dist/chunks/permission-manager.mjs +0 -132
  94. package/dist/chunks/permissions.mjs +0 -265
  95. package/dist/chunks/persistence-manager.mjs +0 -794
  96. package/dist/chunks/persistence.mjs +0 -667
  97. package/dist/chunks/platform.mjs +0 -391
  98. package/dist/chunks/plugin.mjs +0 -1936
  99. package/dist/chunks/powershell.mjs +0 -213
  100. package/dist/chunks/prompts.mjs +0 -241
  101. package/dist/chunks/providers.mjs +0 -260
  102. package/dist/chunks/quick-actions.mjs +0 -320
  103. package/dist/chunks/quick-provider.mjs +0 -682
  104. package/dist/chunks/quick-setup.mjs +0 -412
  105. package/dist/chunks/remote.mjs +0 -497
  106. package/dist/chunks/session.mjs +0 -878
  107. package/dist/chunks/sessions.mjs +0 -106
  108. package/dist/chunks/silent-updater.mjs +0 -396
  109. package/dist/chunks/simple-config.mjs +0 -98
  110. package/dist/chunks/skill.mjs +0 -117
  111. package/dist/chunks/skill2.mjs +0 -9003
  112. package/dist/chunks/skills-sync.mjs +0 -6460
  113. package/dist/chunks/skills.mjs +0 -567
  114. package/dist/chunks/slash-commands.mjs +0 -207
  115. package/dist/chunks/smart-defaults.mjs +0 -412
  116. package/dist/chunks/smart-guide.mjs +0 -194
  117. package/dist/chunks/startup.mjs +0 -487
  118. package/dist/chunks/stats.mjs +0 -410
  119. package/dist/chunks/status.mjs +0 -289
  120. package/dist/chunks/team.mjs +0 -63
  121. package/dist/chunks/thinking.mjs +0 -626
  122. package/dist/chunks/trace.mjs +0 -57
  123. package/dist/chunks/uninstall.mjs +0 -849
  124. package/dist/chunks/update.mjs +0 -167
  125. package/dist/chunks/upgrade-manager.mjs +0 -204
  126. package/dist/chunks/version-checker.mjs +0 -881
  127. package/dist/chunks/vim.mjs +0 -903
  128. package/dist/chunks/windows.mjs +0 -14
  129. package/dist/chunks/workflows.mjs +0 -633
  130. package/dist/chunks/wsl.mjs +0 -129
  131. package/dist/chunks/zero-config.mjs +0 -374
  132. package/dist/chunks/zsh.mjs +0 -182
  133. package/dist/cli.d.mts +0 -1
  134. package/dist/cli.d.ts +0 -1
  135. package/dist/cli.mjs +0 -2199
  136. package/dist/i18n/locales/en/agent-teams.json +0 -18
  137. package/dist/i18n/locales/en/agentBrowser.json +0 -79
  138. package/dist/i18n/locales/en/agents.json +0 -135
  139. package/dist/i18n/locales/en/api.json +0 -63
  140. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  141. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  142. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  143. package/dist/i18n/locales/en/ccjk.json +0 -276
  144. package/dist/i18n/locales/en/ccr.json +0 -65
  145. package/dist/i18n/locales/en/claude-md.json +0 -73
  146. package/dist/i18n/locales/en/cli.json +0 -152
  147. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  148. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  149. package/dist/i18n/locales/en/cloud.json +0 -40
  150. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  151. package/dist/i18n/locales/en/codex.json +0 -127
  152. package/dist/i18n/locales/en/cometix.json +0 -29
  153. package/dist/i18n/locales/en/common.json +0 -68
  154. package/dist/i18n/locales/en/config.json +0 -108
  155. package/dist/i18n/locales/en/configuration.json +0 -226
  156. package/dist/i18n/locales/en/context.json +0 -85
  157. package/dist/i18n/locales/en/dashboard.json +0 -78
  158. package/dist/i18n/locales/en/errors.json +0 -26
  159. package/dist/i18n/locales/en/evolution.json +0 -54
  160. package/dist/i18n/locales/en/hooks.json +0 -74
  161. package/dist/i18n/locales/en/hooksSync.json +0 -133
  162. package/dist/i18n/locales/en/installation.json +0 -83
  163. package/dist/i18n/locales/en/interview.json +0 -104
  164. package/dist/i18n/locales/en/language.json +0 -19
  165. package/dist/i18n/locales/en/lsp.json +0 -78
  166. package/dist/i18n/locales/en/marketplace.json +0 -116
  167. package/dist/i18n/locales/en/mcp.json +0 -178
  168. package/dist/i18n/locales/en/memory.json +0 -92
  169. package/dist/i18n/locales/en/menu.json +0 -143
  170. package/dist/i18n/locales/en/multi-config.json +0 -79
  171. package/dist/i18n/locales/en/notification.json +0 -307
  172. package/dist/i18n/locales/en/permissions.json +0 -95
  173. package/dist/i18n/locales/en/persistence.json +0 -127
  174. package/dist/i18n/locales/en/plugins.json +0 -146
  175. package/dist/i18n/locales/en/quick-actions.json +0 -78
  176. package/dist/i18n/locales/en/registry.json +0 -54
  177. package/dist/i18n/locales/en/remote.json +0 -93
  178. package/dist/i18n/locales/en/sandbox.json +0 -44
  179. package/dist/i18n/locales/en/setup.json +0 -44
  180. package/dist/i18n/locales/en/shencha.json +0 -14
  181. package/dist/i18n/locales/en/skills.json +0 -100
  182. package/dist/i18n/locales/en/skillsSync.json +0 -74
  183. package/dist/i18n/locales/en/smartGuide.json +0 -49
  184. package/dist/i18n/locales/en/stats.json +0 -20
  185. package/dist/i18n/locales/en/subagent.json +0 -69
  186. package/dist/i18n/locales/en/superpowers.json +0 -117
  187. package/dist/i18n/locales/en/team.json +0 -7
  188. package/dist/i18n/locales/en/thinking.json +0 -65
  189. package/dist/i18n/locales/en/tools.json +0 -42
  190. package/dist/i18n/locales/en/uninstall.json +0 -56
  191. package/dist/i18n/locales/en/updater.json +0 -29
  192. package/dist/i18n/locales/en/vim.json +0 -169
  193. package/dist/i18n/locales/en/workflow.json +0 -55
  194. package/dist/i18n/locales/en/workspace.json +0 -108
  195. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  196. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
  197. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  198. package/dist/i18n/locales/zh-CN/api.json +0 -63
  199. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  200. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  201. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  202. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  203. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  204. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  205. package/dist/i18n/locales/zh-CN/cli.json +0 -152
  206. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  207. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  208. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  209. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  210. package/dist/i18n/locales/zh-CN/codex.json +0 -127
  211. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  212. package/dist/i18n/locales/zh-CN/common.json +0 -68
  213. package/dist/i18n/locales/zh-CN/config.json +0 -108
  214. package/dist/i18n/locales/zh-CN/configuration.json +0 -224
  215. package/dist/i18n/locales/zh-CN/context.json +0 -85
  216. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  217. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  218. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  219. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  220. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  221. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  222. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  223. package/dist/i18n/locales/zh-CN/language.json +0 -19
  224. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  225. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  226. package/dist/i18n/locales/zh-CN/mcp.json +0 -178
  227. package/dist/i18n/locales/zh-CN/memory.json +0 -92
  228. package/dist/i18n/locales/zh-CN/menu.json +0 -143
  229. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  230. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  231. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  232. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  233. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  234. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  235. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  236. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  237. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  238. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  239. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  240. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  241. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  242. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  243. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  244. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  245. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  246. package/dist/i18n/locales/zh-CN/team.json +0 -7
  247. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  248. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  249. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  250. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  251. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  252. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  253. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  254. package/dist/index.d.mts +0 -5295
  255. package/dist/index.d.ts +0 -5295
  256. package/dist/index.mjs +0 -4941
  257. package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
  258. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  259. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  260. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  261. package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
  262. package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
  263. package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
  264. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  265. package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
  266. package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
  267. package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
  268. package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
  269. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  270. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  271. package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
  272. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  273. package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
  274. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  275. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  276. package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
  277. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  278. package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
  279. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  280. package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
  281. package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
  282. package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
  283. package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
  284. package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
  285. package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
  286. package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
  287. package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
  288. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  289. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  290. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  291. package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
  292. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  293. package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
  294. package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
  295. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  296. package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
  297. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  298. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  299. package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
@@ -1,750 +0,0 @@
1
- import { d as dayjs } from '../shared/ccjk.RyizuzOI.mjs';
2
- import { ZCF_CONFIG_FILE, ZCF_CONFIG_DIR, SETTINGS_FILE } from './constants.mjs';
3
- import { readDefaultTomlConfig, createDefaultTomlConfig, writeTomlConfig } from './ccjk-config.mjs';
4
- import { h as clearModelEnv } from './config.mjs';
5
- import { ensureDir, exists, copyFile } from './fs-operations.mjs';
6
- import { readJsonConfig } from './json-config.mjs';
7
- import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
8
- import '../shared/ccjk.BAGoDD49.mjs';
9
- import 'node:os';
10
- import './index5.mjs';
11
- import 'node:fs';
12
- import 'node:process';
13
- import 'node:url';
14
- import '../shared/ccjk.BBtCGd_g.mjs';
15
- import './index6.mjs';
16
- import 'node:crypto';
17
- import 'node:fs/promises';
18
- import './index2.mjs';
19
- import './index3.mjs';
20
- import 'node:readline';
21
- import 'stream';
22
- import 'node:tty';
23
- import 'node:async_hooks';
24
- import '../shared/ccjk.Cjgrln_h.mjs';
25
- import 'node:util';
26
- import 'tty';
27
- import 'fs';
28
- import 'child_process';
29
- import 'node:path';
30
- import 'buffer';
31
- import 'string_decoder';
32
- import './claude-config.mjs';
33
- import './platform.mjs';
34
- import './main.mjs';
35
- import 'module';
36
- import 'node:child_process';
37
- import 'node:stream';
38
- import '../shared/ccjk.DXRAZcix.mjs';
39
-
40
- class ClaudeCodeConfigManager {
41
- static CONFIG_FILE = ZCF_CONFIG_FILE;
42
- static LEGACY_CONFIG_FILE = join(ZCF_CONFIG_DIR, "claude-code-configs.json");
43
- /**
44
- * Ensure configuration directory exists
45
- */
46
- static ensureConfigDir() {
47
- ensureDir(ZCF_CONFIG_DIR);
48
- }
49
- /**
50
- * Read TOML configuration
51
- */
52
- static readTomlConfig() {
53
- return readDefaultTomlConfig();
54
- }
55
- /**
56
- * Load TOML configuration, falling back to default when missing
57
- */
58
- static loadTomlConfig() {
59
- const existingConfig = this.readTomlConfig();
60
- if (existingConfig) {
61
- return existingConfig;
62
- }
63
- return createDefaultTomlConfig();
64
- }
65
- /**
66
- * Migrate legacy JSON-based configuration into TOML storage
67
- */
68
- static migrateFromLegacyConfig() {
69
- if (!exists(this.LEGACY_CONFIG_FILE)) {
70
- return null;
71
- }
72
- try {
73
- const legacyConfig = readJsonConfig(this.LEGACY_CONFIG_FILE);
74
- if (!legacyConfig) {
75
- return null;
76
- }
77
- const normalizedProfiles = {};
78
- const existingKeys = /* @__PURE__ */ new Set();
79
- let migratedCurrentKey = "";
80
- Object.entries(legacyConfig.profiles || {}).forEach(([legacyKey, profile]) => {
81
- const sourceProfile = profile;
82
- const name = sourceProfile.name?.trim() || legacyKey;
83
- const baseKey = this.generateProfileId(name);
84
- let uniqueKey = baseKey || legacyKey;
85
- let suffix = 2;
86
- while (existingKeys.has(uniqueKey)) {
87
- uniqueKey = `${baseKey || legacyKey}-${suffix++}`;
88
- }
89
- existingKeys.add(uniqueKey);
90
- const sanitizedProfile = this.sanitizeProfile({
91
- ...sourceProfile,
92
- name
93
- });
94
- normalizedProfiles[uniqueKey] = {
95
- ...sanitizedProfile,
96
- id: uniqueKey
97
- };
98
- if (legacyConfig.currentProfileId === legacyKey || legacyConfig.currentProfileId === sourceProfile.id) {
99
- migratedCurrentKey = uniqueKey;
100
- }
101
- });
102
- if (!migratedCurrentKey && legacyConfig.currentProfileId) {
103
- const fallbackKey = this.generateProfileId(legacyConfig.currentProfileId);
104
- if (existingKeys.has(fallbackKey)) {
105
- migratedCurrentKey = fallbackKey;
106
- }
107
- }
108
- if (!migratedCurrentKey && existingKeys.size > 0) {
109
- migratedCurrentKey = Array.from(existingKeys)[0];
110
- }
111
- const migratedConfig = {
112
- currentProfileId: migratedCurrentKey,
113
- profiles: normalizedProfiles
114
- };
115
- this.writeConfig(migratedConfig);
116
- return migratedConfig;
117
- } catch (error) {
118
- console.error("Failed to migrate legacy Claude Code config:", error);
119
- return null;
120
- }
121
- }
122
- /**
123
- * Read configuration
124
- */
125
- static readConfig() {
126
- try {
127
- const tomlConfig = readDefaultTomlConfig();
128
- if (!tomlConfig || !tomlConfig.claudeCode) {
129
- return this.migrateFromLegacyConfig();
130
- }
131
- const { claudeCode } = tomlConfig;
132
- const rawProfiles = claudeCode.profiles || {};
133
- const sanitizedProfiles = Object.fromEntries(
134
- Object.entries(rawProfiles).map(([key, profile]) => {
135
- const storedProfile = this.sanitizeProfile({
136
- ...profile,
137
- name: profile.name || key
138
- });
139
- return [key, { ...storedProfile, id: key }];
140
- })
141
- );
142
- const configData = {
143
- currentProfileId: claudeCode.currentProfile || "",
144
- profiles: sanitizedProfiles
145
- };
146
- if (Object.keys(configData.profiles).length === 0) {
147
- const migrated = this.migrateFromLegacyConfig();
148
- if (migrated) {
149
- return migrated;
150
- }
151
- }
152
- return configData;
153
- } catch (error) {
154
- console.error("Failed to read Claude Code config:", error);
155
- return null;
156
- }
157
- }
158
- /**
159
- * Write configuration
160
- */
161
- static writeConfig(config) {
162
- try {
163
- this.ensureConfigDir();
164
- const keyMap = /* @__PURE__ */ new Map();
165
- const sanitizedProfiles = Object.fromEntries(
166
- Object.entries(config.profiles).map(([key, profile]) => {
167
- const normalizedName = profile.name?.trim() || key;
168
- const profileKey = this.generateProfileId(normalizedName);
169
- keyMap.set(key, profileKey);
170
- const sanitizedProfile = this.sanitizeProfile({
171
- ...profile,
172
- name: normalizedName
173
- });
174
- return [profileKey, sanitizedProfile];
175
- })
176
- );
177
- const tomlConfig = this.loadTomlConfig();
178
- const nextTomlConfig = {
179
- ...tomlConfig,
180
- claudeCode: {
181
- ...tomlConfig.claudeCode,
182
- currentProfile: keyMap.get(config.currentProfileId) || config.currentProfileId,
183
- profiles: sanitizedProfiles
184
- }
185
- };
186
- writeTomlConfig(this.CONFIG_FILE, nextTomlConfig);
187
- } catch (error) {
188
- console.error("Failed to write Claude Code config:", error);
189
- throw new Error(`Failed to write config: ${error instanceof Error ? error.message : String(error)}`);
190
- }
191
- }
192
- /**
193
- * Create empty configuration
194
- */
195
- static createEmptyConfig() {
196
- return {
197
- currentProfileId: "",
198
- profiles: {}
199
- };
200
- }
201
- /**
202
- * Apply profile settings to Claude Code runtime
203
- */
204
- static async applyProfileSettings(profile) {
205
- const { ensureI18nInitialized, i18n } = await import('./index5.mjs');
206
- ensureI18nInitialized();
207
- try {
208
- if (!profile) {
209
- const { switchToOfficialLogin } = await import('./config.mjs').then(function (n) { return n.j; });
210
- switchToOfficialLogin();
211
- return;
212
- }
213
- const { readJsonConfig: readJsonConfig2, writeJsonConfig } = await import('./json-config.mjs');
214
- const settings = readJsonConfig2(SETTINGS_FILE) || {};
215
- if (!settings.env)
216
- settings.env = {};
217
- clearModelEnv(settings.env);
218
- let shouldRestartCcr = false;
219
- if (profile.authType === "api_key") {
220
- settings.env.ANTHROPIC_API_KEY = profile.apiKey;
221
- delete settings.env.ANTHROPIC_AUTH_TOKEN;
222
- } else if (profile.authType === "auth_token") {
223
- settings.env.ANTHROPIC_AUTH_TOKEN = profile.apiKey;
224
- delete settings.env.ANTHROPIC_API_KEY;
225
- } else if (profile.authType === "ccr_proxy") {
226
- const { readCcrConfig } = await import('./config2.mjs');
227
- const ccrConfig = readCcrConfig();
228
- if (!ccrConfig) {
229
- throw new Error(i18n.t("ccr:ccrNotConfigured") || "CCR proxy configuration not found");
230
- }
231
- const host = ccrConfig.HOST || "127.0.0.1";
232
- const port = ccrConfig.PORT || 3456;
233
- const apiKey = ccrConfig.APIKEY || "sk-ccjk-x-ccr";
234
- settings.env.ANTHROPIC_BASE_URL = `http://${host}:${port}`;
235
- settings.env.ANTHROPIC_API_KEY = apiKey;
236
- delete settings.env.ANTHROPIC_AUTH_TOKEN;
237
- shouldRestartCcr = true;
238
- }
239
- if (profile.authType !== "ccr_proxy") {
240
- if (profile.baseUrl)
241
- settings.env.ANTHROPIC_BASE_URL = profile.baseUrl;
242
- else
243
- delete settings.env.ANTHROPIC_BASE_URL;
244
- }
245
- const hasModelConfig = Boolean(
246
- profile.primaryModel || profile.defaultHaikuModel || profile.defaultSonnetModel || profile.defaultOpusModel
247
- );
248
- if (hasModelConfig) {
249
- if (profile.primaryModel)
250
- settings.env.ANTHROPIC_MODEL = profile.primaryModel;
251
- if (profile.defaultHaikuModel)
252
- settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = profile.defaultHaikuModel;
253
- if (profile.defaultSonnetModel)
254
- settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = profile.defaultSonnetModel;
255
- if (profile.defaultOpusModel)
256
- settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = profile.defaultOpusModel;
257
- } else {
258
- clearModelEnv(settings.env);
259
- }
260
- writeJsonConfig(SETTINGS_FILE, settings);
261
- const { setPrimaryApiKey, addCompletedOnboarding } = await import('./claude-config.mjs').then(function (n) { return n.h; });
262
- setPrimaryApiKey();
263
- addCompletedOnboarding();
264
- if (shouldRestartCcr) {
265
- const { runCcrRestart } = await import('./commands.mjs');
266
- await runCcrRestart();
267
- }
268
- } catch (error) {
269
- const reason = error instanceof Error ? error.message : String(error);
270
- throw new Error(`${i18n.t("multi-config:failedToApplySettings")}: ${reason}`);
271
- }
272
- }
273
- static async applyCurrentProfile() {
274
- const currentProfile = this.getCurrentProfile();
275
- await this.applyProfileSettings(currentProfile);
276
- }
277
- /**
278
- * Remove unsupported fields from profile payload
279
- */
280
- static sanitizeProfile(profile) {
281
- const sanitized = {
282
- name: profile.name,
283
- authType: profile.authType
284
- };
285
- if (profile.apiKey)
286
- sanitized.apiKey = profile.apiKey;
287
- if (profile.baseUrl)
288
- sanitized.baseUrl = profile.baseUrl;
289
- if (profile.primaryModel)
290
- sanitized.primaryModel = profile.primaryModel;
291
- if (profile.defaultHaikuModel)
292
- sanitized.defaultHaikuModel = profile.defaultHaikuModel;
293
- if (profile.defaultSonnetModel)
294
- sanitized.defaultSonnetModel = profile.defaultSonnetModel;
295
- if (profile.defaultOpusModel)
296
- sanitized.defaultOpusModel = profile.defaultOpusModel;
297
- return sanitized;
298
- }
299
- /**
300
- * Backup configuration
301
- */
302
- static backupConfig() {
303
- try {
304
- if (!exists(this.CONFIG_FILE)) {
305
- return null;
306
- }
307
- const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
308
- const backupPath = join(ZCF_CONFIG_DIR, `config.backup.${timestamp}.toml`);
309
- copyFile(this.CONFIG_FILE, backupPath);
310
- return backupPath;
311
- } catch (error) {
312
- console.error("Failed to backup Claude Code config:", error);
313
- return null;
314
- }
315
- }
316
- /**
317
- * Add configuration
318
- */
319
- static async addProfile(profile) {
320
- try {
321
- const validationErrors = this.validateProfile(profile);
322
- if (validationErrors.length > 0) {
323
- return {
324
- success: false,
325
- error: `Validation failed: ${validationErrors.join(", ")}`
326
- };
327
- }
328
- const backupPath = this.backupConfig();
329
- let config = this.readConfig();
330
- if (!config) {
331
- config = this.createEmptyConfig();
332
- }
333
- if (profile.id && config.profiles[profile.id]) {
334
- return {
335
- success: false,
336
- error: `Profile with ID "${profile.id}" already exists`,
337
- backupPath: backupPath || void 0
338
- };
339
- }
340
- const normalizedName = profile.name.trim();
341
- const profileKey = this.generateProfileId(normalizedName);
342
- const existingNames = Object.values(config.profiles).map((p) => p.name || "");
343
- if (config.profiles[profileKey] || existingNames.some((name) => name.toLowerCase() === normalizedName.toLowerCase())) {
344
- return {
345
- success: false,
346
- error: `Profile with name "${profile.name}" already exists`,
347
- backupPath: backupPath || void 0
348
- };
349
- }
350
- const sanitizedProfile = this.sanitizeProfile({
351
- ...profile,
352
- name: normalizedName
353
- });
354
- const runtimeProfile = {
355
- ...sanitizedProfile,
356
- id: profileKey
357
- };
358
- config.profiles[profileKey] = runtimeProfile;
359
- if (!config.currentProfileId) {
360
- config.currentProfileId = profileKey;
361
- }
362
- this.writeConfig(config);
363
- return {
364
- success: true,
365
- backupPath: backupPath || void 0,
366
- addedProfile: runtimeProfile
367
- };
368
- } catch (error) {
369
- return {
370
- success: false,
371
- error: error instanceof Error ? error.message : String(error)
372
- };
373
- }
374
- }
375
- /**
376
- * Update configuration
377
- */
378
- static async updateProfile(id, data) {
379
- try {
380
- const validationErrors = this.validateProfile(data, true);
381
- if (validationErrors.length > 0) {
382
- return {
383
- success: false,
384
- error: `Validation failed: ${validationErrors.join(", ")}`
385
- };
386
- }
387
- const backupPath = this.backupConfig();
388
- const config = this.readConfig();
389
- if (!config || !config.profiles[id]) {
390
- return {
391
- success: false,
392
- error: `Profile with ID "${id}" not found`,
393
- backupPath: backupPath || void 0
394
- };
395
- }
396
- const existingProfile = config.profiles[id];
397
- const nextName = data.name !== void 0 ? data.name.trim() : existingProfile.name;
398
- const nextKey = this.generateProfileId(nextName);
399
- const nameChanged = nextKey !== id;
400
- if (nameChanged) {
401
- const duplicateName = Object.entries(config.profiles).some(([key, profile]) => key !== id && (profile.name || "").toLowerCase() === nextName.toLowerCase());
402
- if (duplicateName || config.profiles[nextKey]) {
403
- return {
404
- success: false,
405
- error: `Profile with name "${data.name}" already exists`,
406
- backupPath: backupPath || void 0
407
- };
408
- }
409
- }
410
- const mergedProfile = this.sanitizeProfile({
411
- ...existingProfile,
412
- ...data,
413
- name: nextName
414
- });
415
- if (nameChanged) {
416
- delete config.profiles[id];
417
- config.profiles[nextKey] = {
418
- ...mergedProfile,
419
- id: nextKey
420
- };
421
- if (config.currentProfileId === id) {
422
- config.currentProfileId = nextKey;
423
- }
424
- } else {
425
- config.profiles[id] = {
426
- ...mergedProfile,
427
- id
428
- };
429
- }
430
- this.writeConfig(config);
431
- return {
432
- success: true,
433
- backupPath: backupPath || void 0,
434
- updatedProfile: {
435
- ...mergedProfile,
436
- id: nameChanged ? nextKey : id
437
- }
438
- };
439
- } catch (error) {
440
- return {
441
- success: false,
442
- error: error instanceof Error ? error.message : String(error)
443
- };
444
- }
445
- }
446
- /**
447
- * Delete configuration
448
- */
449
- static async deleteProfile(id) {
450
- try {
451
- const backupPath = this.backupConfig();
452
- const config = this.readConfig();
453
- if (!config || !config.profiles[id]) {
454
- return {
455
- success: false,
456
- error: `Profile with ID "${id}" not found`,
457
- backupPath: backupPath || void 0
458
- };
459
- }
460
- const profileCount = Object.keys(config.profiles).length;
461
- if (profileCount === 1) {
462
- return {
463
- success: false,
464
- error: "Cannot delete the last profile. At least one profile must remain.",
465
- backupPath: backupPath || void 0
466
- };
467
- }
468
- delete config.profiles[id];
469
- if (config.currentProfileId === id) {
470
- const remainingIds = Object.keys(config.profiles);
471
- config.currentProfileId = remainingIds[0];
472
- }
473
- this.writeConfig(config);
474
- return {
475
- success: true,
476
- backupPath: backupPath || void 0,
477
- remainingProfiles: Object.entries(config.profiles).map(([key, profile]) => ({
478
- ...profile,
479
- id: key
480
- }))
481
- };
482
- } catch (error) {
483
- return {
484
- success: false,
485
- error: error instanceof Error ? error.message : String(error)
486
- };
487
- }
488
- }
489
- /**
490
- * Delete multiple configurations
491
- */
492
- static async deleteProfiles(ids) {
493
- try {
494
- const backupPath = this.backupConfig();
495
- const config = this.readConfig();
496
- if (!config) {
497
- return {
498
- success: false,
499
- error: "No configuration found",
500
- backupPath: backupPath || void 0
501
- };
502
- }
503
- const missingIds = ids.filter((id) => !config.profiles[id]);
504
- if (missingIds.length > 0) {
505
- return {
506
- success: false,
507
- error: `Profiles not found: ${missingIds.join(", ")}`,
508
- backupPath: backupPath || void 0
509
- };
510
- }
511
- const remainingCount = Object.keys(config.profiles).length - ids.length;
512
- if (remainingCount === 0) {
513
- return {
514
- success: false,
515
- error: "Cannot delete all profiles. At least one profile must remain.",
516
- backupPath: backupPath || void 0
517
- };
518
- }
519
- let newCurrentProfileId;
520
- ids.forEach((id) => {
521
- delete config.profiles[id];
522
- });
523
- if (ids.includes(config.currentProfileId)) {
524
- const remainingIds = Object.keys(config.profiles);
525
- config.currentProfileId = remainingIds[0];
526
- newCurrentProfileId = config.currentProfileId;
527
- }
528
- this.writeConfig(config);
529
- return {
530
- success: true,
531
- backupPath: backupPath || void 0,
532
- newCurrentProfileId,
533
- deletedProfiles: ids,
534
- remainingProfiles: Object.entries(config.profiles).map(([key, profile]) => ({
535
- ...profile,
536
- id: key
537
- }))
538
- };
539
- } catch (error) {
540
- return {
541
- success: false,
542
- error: error instanceof Error ? error.message : String(error)
543
- };
544
- }
545
- }
546
- /**
547
- * Generate profile ID from name
548
- */
549
- static generateProfileId(name) {
550
- return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "profile";
551
- }
552
- /**
553
- * Switch configuration
554
- */
555
- static async switchProfile(id) {
556
- try {
557
- const config = this.readConfig();
558
- if (!config || !config.profiles[id]) {
559
- return {
560
- success: false,
561
- error: "Profile not found"
562
- };
563
- }
564
- if (config.currentProfileId === id) {
565
- return { success: true };
566
- }
567
- config.currentProfileId = id;
568
- this.writeConfig(config);
569
- return { success: true };
570
- } catch (error) {
571
- return {
572
- success: false,
573
- error: error instanceof Error ? error.message : String(error)
574
- };
575
- }
576
- }
577
- /**
578
- * List all configurations
579
- */
580
- static listProfiles() {
581
- const config = this.readConfig();
582
- if (!config) {
583
- return [];
584
- }
585
- return Object.values(config.profiles);
586
- }
587
- /**
588
- * Get current configuration
589
- */
590
- static getCurrentProfile() {
591
- const config = this.readConfig();
592
- if (!config || !config.currentProfileId) {
593
- return null;
594
- }
595
- return config.profiles[config.currentProfileId] || null;
596
- }
597
- /**
598
- * Get configuration by ID
599
- */
600
- static getProfileById(id) {
601
- const config = this.readConfig();
602
- if (!config) {
603
- return null;
604
- }
605
- return config.profiles[id] || null;
606
- }
607
- /**
608
- * Get configuration by name
609
- */
610
- static getProfileByName(name) {
611
- const config = this.readConfig();
612
- if (!config) {
613
- return null;
614
- }
615
- return Object.values(config.profiles).find((p) => p.name === name) || null;
616
- }
617
- /**
618
- * Sync CCR configuration
619
- */
620
- static async syncCcrProfile() {
621
- try {
622
- const { readCcrConfig } = await import('./config2.mjs');
623
- const ccrConfig = readCcrConfig();
624
- if (!ccrConfig) {
625
- await this.ensureCcrProfileExists(ccrConfig);
626
- return;
627
- }
628
- await this.ensureCcrProfileExists(ccrConfig);
629
- } catch (error) {
630
- console.error("Failed to sync CCR profile:", error);
631
- }
632
- }
633
- /**
634
- * 确保CCR配置文件存在
635
- */
636
- static async ensureCcrProfileExists(ccrConfig) {
637
- const config = this.readConfig() || this.createEmptyConfig();
638
- const ccrProfileId = "ccr-proxy";
639
- const existingCcrProfile = config.profiles[ccrProfileId];
640
- if (!ccrConfig) {
641
- if (existingCcrProfile) {
642
- delete config.profiles[ccrProfileId];
643
- if (config.currentProfileId === ccrProfileId) {
644
- const remainingIds = Object.keys(config.profiles);
645
- config.currentProfileId = remainingIds[0] || "";
646
- }
647
- this.writeConfig(config);
648
- }
649
- return;
650
- }
651
- const host = ccrConfig.HOST || "127.0.0.1";
652
- const port = ccrConfig.PORT || 3456;
653
- const apiKey = ccrConfig.APIKEY || "sk-ccjk-x-ccr";
654
- const baseUrl = `http://${host}:${port}`;
655
- const ccrProfile = {
656
- name: "CCR Proxy",
657
- authType: "ccr_proxy",
658
- baseUrl,
659
- apiKey
660
- };
661
- config.profiles[ccrProfileId] = {
662
- ...ccrProfile,
663
- id: ccrProfileId
664
- };
665
- if (!config.currentProfileId) {
666
- config.currentProfileId = ccrProfileId;
667
- }
668
- this.writeConfig(config);
669
- }
670
- /**
671
- * Switch to official login
672
- */
673
- static async switchToOfficial() {
674
- try {
675
- const config = this.readConfig();
676
- if (!config) {
677
- return { success: true };
678
- }
679
- config.currentProfileId = "";
680
- this.writeConfig(config);
681
- return { success: true };
682
- } catch (error) {
683
- return {
684
- success: false,
685
- error: error instanceof Error ? error.message : String(error)
686
- };
687
- }
688
- }
689
- /**
690
- * Switch to CCR proxy
691
- */
692
- static async switchToCcr() {
693
- try {
694
- await this.syncCcrProfile();
695
- const config = this.readConfig();
696
- if (!config || !config.profiles["ccr-proxy"]) {
697
- return {
698
- success: false,
699
- error: "CCR proxy configuration not found. Please configure CCR first."
700
- };
701
- }
702
- return await this.switchProfile("ccr-proxy");
703
- } catch (error) {
704
- return {
705
- success: false,
706
- error: error instanceof Error ? error.message : String(error)
707
- };
708
- }
709
- }
710
- /**
711
- * Validate configuration
712
- */
713
- static validateProfile(profile, isUpdate = false) {
714
- const errors = [];
715
- if (!isUpdate && (!profile.name || typeof profile.name !== "string" || profile.name.trim() === "")) {
716
- errors.push("Profile name is required");
717
- }
718
- if (profile.name && typeof profile.name !== "string") {
719
- errors.push("Profile name must be a string");
720
- }
721
- if (profile.authType && !["api_key", "auth_token", "ccr_proxy"].includes(profile.authType)) {
722
- errors.push("Invalid auth type. Must be one of: api_key, auth_token, ccr_proxy");
723
- }
724
- if (profile.authType === "api_key" || profile.authType === "auth_token") {
725
- if (!profile.apiKey || typeof profile.apiKey !== "string" || profile.apiKey.trim() === "") {
726
- errors.push("API key is required for api_key and auth_token types");
727
- }
728
- }
729
- if (profile.baseUrl) {
730
- try {
731
- new URL(profile.baseUrl);
732
- } catch {
733
- errors.push("Invalid base URL format");
734
- }
735
- }
736
- return errors;
737
- }
738
- /**
739
- * 检查是否为最后一个配置
740
- */
741
- static isLastProfile(id) {
742
- const config = this.readConfig();
743
- if (!config || !config.profiles[id]) {
744
- return false;
745
- }
746
- return Object.keys(config.profiles).length === 1;
747
- }
748
- }
749
-
750
- export { ClaudeCodeConfigManager };