ccjk 14.2.2 → 15.0.0

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 (528) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +58 -341
  3. package/dist/cli.js +59 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/detect.js +15 -0
  6. package/dist/commands/detect.js.map +1 -0
  7. package/dist/commands/doctor.js +68 -0
  8. package/dist/commands/doctor.js.map +1 -0
  9. package/dist/commands/git-install.js +50 -0
  10. package/dist/commands/git-install.js.map +1 -0
  11. package/dist/commands/init.js +102 -0
  12. package/dist/commands/init.js.map +1 -0
  13. package/dist/commands/mcp.js +66 -0
  14. package/dist/commands/mcp.js.map +1 -0
  15. package/dist/commands/menu.js +33 -0
  16. package/dist/commands/menu.js.map +1 -0
  17. package/dist/core/detect.js +24 -0
  18. package/dist/core/detect.js.map +1 -0
  19. package/dist/core/lint.js +49 -0
  20. package/dist/core/lint.js.map +1 -0
  21. package/dist/core/mcp.js +41 -0
  22. package/dist/core/mcp.js.map +1 -0
  23. package/dist/core/paths.js +9 -0
  24. package/dist/core/paths.js.map +1 -0
  25. package/dist/core/providers.js +53 -0
  26. package/dist/core/providers.js.map +1 -0
  27. package/dist/core/settings.js +31 -0
  28. package/dist/core/settings.js.map +1 -0
  29. package/dist/core/slash-templates.js +56 -0
  30. package/dist/core/slash-templates.js.map +1 -0
  31. package/dist/core/tools.js +27 -0
  32. package/dist/core/tools.js.map +1 -0
  33. package/package.json +43 -164
  34. package/README.HONEST.md +0 -176
  35. package/README.en.md +0 -67
  36. package/README.ja.md +0 -67
  37. package/README.ko.md +0 -67
  38. package/README.zh-CN.md +0 -86
  39. package/bin/ccjk.mjs +0 -5
  40. package/bin/ccjk.ts +0 -222
  41. package/dist/chunks/agent-teams.mjs +0 -145
  42. package/dist/chunks/agent.mjs +0 -1439
  43. package/dist/chunks/agents.mjs +0 -3783
  44. package/dist/chunks/api-cli.mjs +0 -135
  45. package/dist/chunks/api-config-selector.mjs +0 -159
  46. package/dist/chunks/api-providers.mjs +0 -144
  47. package/dist/chunks/api.mjs +0 -115
  48. package/dist/chunks/auto-bootstrap.mjs +0 -358
  49. package/dist/chunks/auto-fixer.mjs +0 -95
  50. package/dist/chunks/auto-updater.mjs +0 -507
  51. package/dist/chunks/banner.mjs +0 -173
  52. package/dist/chunks/bash.mjs +0 -187
  53. package/dist/chunks/boost.mjs +0 -474
  54. package/dist/chunks/brain-config.mjs +0 -75
  55. package/dist/chunks/brain-status.mjs +0 -89
  56. package/dist/chunks/ccjk-agents.mjs +0 -416
  57. package/dist/chunks/ccjk-all.mjs +0 -1046
  58. package/dist/chunks/ccjk-config.mjs +0 -445
  59. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  60. package/dist/chunks/ccjk-mcp.mjs +0 -763
  61. package/dist/chunks/ccjk-setup.mjs +0 -765
  62. package/dist/chunks/ccjk-skills.mjs +0 -518
  63. package/dist/chunks/ccr.mjs +0 -109
  64. package/dist/chunks/ccu.mjs +0 -40
  65. package/dist/chunks/check-updates.mjs +0 -117
  66. package/dist/chunks/claude-code-incremental-manager.mjs +0 -761
  67. package/dist/chunks/claude-config.mjs +0 -606
  68. package/dist/chunks/claude-config2.mjs +0 -62
  69. package/dist/chunks/claude-wrapper.mjs +0 -85
  70. package/dist/chunks/clavue-config.mjs +0 -1454
  71. package/dist/chunks/cleanup-migration.mjs +0 -20
  72. package/dist/chunks/cli-hook.mjs +0 -4096
  73. package/dist/chunks/cloud-sync.mjs +0 -29
  74. package/dist/chunks/code-type-resolver.mjs +0 -880
  75. package/dist/chunks/codex-config-switch.mjs +0 -452
  76. package/dist/chunks/codex-provider-manager.mjs +0 -238
  77. package/dist/chunks/codex-uninstaller.mjs +0 -404
  78. package/dist/chunks/codex.mjs +0 -2141
  79. package/dist/chunks/commands.mjs +0 -108
  80. package/dist/chunks/commands2.mjs +0 -421
  81. package/dist/chunks/commit.mjs +0 -140
  82. package/dist/chunks/completion.mjs +0 -517
  83. package/dist/chunks/config-consolidator.mjs +0 -172
  84. package/dist/chunks/config-switch.mjs +0 -334
  85. package/dist/chunks/config.mjs +0 -558
  86. package/dist/chunks/config2.mjs +0 -484
  87. package/dist/chunks/config3.mjs +0 -486
  88. package/dist/chunks/constants.mjs +0 -323
  89. package/dist/chunks/context-opt.mjs +0 -444
  90. package/dist/chunks/context.mjs +0 -974
  91. package/dist/chunks/dashboard.mjs +0 -481
  92. package/dist/chunks/doctor.mjs +0 -1301
  93. package/dist/chunks/eval.mjs +0 -502
  94. package/dist/chunks/evolution.mjs +0 -322
  95. package/dist/chunks/features.mjs +0 -715
  96. package/dist/chunks/fish.mjs +0 -181
  97. package/dist/chunks/fs-operations.mjs +0 -180
  98. package/dist/chunks/health-alerts.mjs +0 -830
  99. package/dist/chunks/help.mjs +0 -341
  100. package/dist/chunks/hook-installer.mjs +0 -48
  101. package/dist/chunks/impact.mjs +0 -651
  102. package/dist/chunks/index.mjs +0 -23
  103. package/dist/chunks/index10.mjs +0 -19
  104. package/dist/chunks/index11.mjs +0 -1171
  105. package/dist/chunks/index12.mjs +0 -218
  106. package/dist/chunks/index13.mjs +0 -679
  107. package/dist/chunks/index14.mjs +0 -1009
  108. package/dist/chunks/index15.mjs +0 -194
  109. package/dist/chunks/index2.mjs +0 -7637
  110. package/dist/chunks/index3.mjs +0 -171
  111. package/dist/chunks/index4.mjs +0 -26
  112. package/dist/chunks/index5.mjs +0 -19
  113. package/dist/chunks/index6.mjs +0 -19092
  114. package/dist/chunks/index7.mjs +0 -616
  115. package/dist/chunks/index8.mjs +0 -1602
  116. package/dist/chunks/index9.mjs +0 -5384
  117. package/dist/chunks/init.mjs +0 -1911
  118. package/dist/chunks/installer.mjs +0 -757
  119. package/dist/chunks/installer2.mjs +0 -103
  120. package/dist/chunks/interview.mjs +0 -2927
  121. package/dist/chunks/json-config.mjs +0 -60
  122. package/dist/chunks/linux.mjs +0 -3863
  123. package/dist/chunks/macos.mjs +0 -69
  124. package/dist/chunks/main.mjs +0 -635
  125. package/dist/chunks/manager.mjs +0 -1048
  126. package/dist/chunks/marketplace.mjs +0 -265
  127. package/dist/chunks/mcp-cli.mjs +0 -205
  128. package/dist/chunks/mcp-performance.mjs +0 -187
  129. package/dist/chunks/mcp.mjs +0 -667
  130. package/dist/chunks/memory-check.mjs +0 -2973
  131. package/dist/chunks/memory-paths.mjs +0 -259
  132. package/dist/chunks/memory-sync.mjs +0 -209
  133. package/dist/chunks/memory.mjs +0 -354
  134. package/dist/chunks/metrics-display.mjs +0 -153
  135. package/dist/chunks/monitor.mjs +0 -1856
  136. package/dist/chunks/notification.mjs +0 -1864
  137. package/dist/chunks/onboarding.mjs +0 -386
  138. package/dist/chunks/package.mjs +0 -3
  139. package/dist/chunks/paradigm.mjs +0 -74
  140. package/dist/chunks/permission-manager.mjs +0 -250
  141. package/dist/chunks/permissions.mjs +0 -265
  142. package/dist/chunks/persistence-manager.mjs +0 -801
  143. package/dist/chunks/persistence.mjs +0 -707
  144. package/dist/chunks/platform.mjs +0 -395
  145. package/dist/chunks/plugin.mjs +0 -1936
  146. package/dist/chunks/powershell.mjs +0 -213
  147. package/dist/chunks/prompts.mjs +0 -244
  148. package/dist/chunks/providers.mjs +0 -263
  149. package/dist/chunks/quick-actions.mjs +0 -335
  150. package/dist/chunks/quick-provider.mjs +0 -755
  151. package/dist/chunks/quick-setup.mjs +0 -421
  152. package/dist/chunks/remote.mjs +0 -497
  153. package/dist/chunks/research.mjs +0 -1904
  154. package/dist/chunks/rollback.mjs +0 -38
  155. package/dist/chunks/session-manager.mjs +0 -1371
  156. package/dist/chunks/session.mjs +0 -878
  157. package/dist/chunks/sessions.mjs +0 -106
  158. package/dist/chunks/silent-updater.mjs +0 -396
  159. package/dist/chunks/simple-config.mjs +0 -122
  160. package/dist/chunks/skill.mjs +0 -117
  161. package/dist/chunks/skill2.mjs +0 -9052
  162. package/dist/chunks/skills-sync.mjs +0 -1343
  163. package/dist/chunks/skills.mjs +0 -577
  164. package/dist/chunks/slash-commands.mjs +0 -208
  165. package/dist/chunks/smart-guide.mjs +0 -247
  166. package/dist/chunks/snapshot.mjs +0 -58
  167. package/dist/chunks/startup.mjs +0 -487
  168. package/dist/chunks/stats.mjs +0 -191
  169. package/dist/chunks/status.mjs +0 -471
  170. package/dist/chunks/team.mjs +0 -63
  171. package/dist/chunks/thinking.mjs +0 -626
  172. package/dist/chunks/trace.mjs +0 -57
  173. package/dist/chunks/uninstall.mjs +0 -852
  174. package/dist/chunks/update.mjs +0 -174
  175. package/dist/chunks/upgrade-manager.mjs +0 -204
  176. package/dist/chunks/upgrade.mjs +0 -133
  177. package/dist/chunks/version-checker.mjs +0 -891
  178. package/dist/chunks/vim.mjs +0 -903
  179. package/dist/chunks/windows.mjs +0 -14
  180. package/dist/chunks/workflows.mjs +0 -633
  181. package/dist/chunks/wsl.mjs +0 -129
  182. package/dist/chunks/zero-config.mjs +0 -871
  183. package/dist/chunks/zsh.mjs +0 -182
  184. package/dist/cli.d.mts +0 -1
  185. package/dist/cli.d.ts +0 -1
  186. package/dist/cli.mjs +0 -2684
  187. package/dist/i18n/locales/en/agent-teams.json +0 -18
  188. package/dist/i18n/locales/en/agentBrowser.json +0 -80
  189. package/dist/i18n/locales/en/agents.json +0 -135
  190. package/dist/i18n/locales/en/api.json +0 -63
  191. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  192. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  193. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  194. package/dist/i18n/locales/en/ccjk.json +0 -276
  195. package/dist/i18n/locales/en/ccr.json +0 -65
  196. package/dist/i18n/locales/en/claude-md.json +0 -73
  197. package/dist/i18n/locales/en/cli.json +0 -148
  198. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  199. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  200. package/dist/i18n/locales/en/cloud.json +0 -40
  201. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  202. package/dist/i18n/locales/en/codex.json +0 -184
  203. package/dist/i18n/locales/en/cometix.json +0 -29
  204. package/dist/i18n/locales/en/common.json +0 -68
  205. package/dist/i18n/locales/en/config.json +0 -108
  206. package/dist/i18n/locales/en/configuration.json +0 -236
  207. package/dist/i18n/locales/en/context.json +0 -85
  208. package/dist/i18n/locales/en/dashboard.json +0 -78
  209. package/dist/i18n/locales/en/errors.json +0 -26
  210. package/dist/i18n/locales/en/evolution.json +0 -54
  211. package/dist/i18n/locales/en/hooks.json +0 -74
  212. package/dist/i18n/locales/en/hooksSync.json +0 -133
  213. package/dist/i18n/locales/en/installation.json +0 -83
  214. package/dist/i18n/locales/en/interview.json +0 -104
  215. package/dist/i18n/locales/en/language.json +0 -19
  216. package/dist/i18n/locales/en/lsp.json +0 -78
  217. package/dist/i18n/locales/en/marketplace.json +0 -116
  218. package/dist/i18n/locales/en/mcp.json +0 -180
  219. package/dist/i18n/locales/en/memory.json +0 -23
  220. package/dist/i18n/locales/en/menu.json +0 -299
  221. package/dist/i18n/locales/en/multi-config.json +0 -79
  222. package/dist/i18n/locales/en/notification.json +0 -307
  223. package/dist/i18n/locales/en/permissions.json +0 -95
  224. package/dist/i18n/locales/en/persistence.json +0 -127
  225. package/dist/i18n/locales/en/plugins.json +0 -146
  226. package/dist/i18n/locales/en/quick-actions.json +0 -78
  227. package/dist/i18n/locales/en/registry.json +0 -54
  228. package/dist/i18n/locales/en/remote.json +0 -93
  229. package/dist/i18n/locales/en/sandbox.json +0 -44
  230. package/dist/i18n/locales/en/setup.json +0 -44
  231. package/dist/i18n/locales/en/shencha.json +0 -14
  232. package/dist/i18n/locales/en/skills.json +0 -100
  233. package/dist/i18n/locales/en/skillsSync.json +0 -74
  234. package/dist/i18n/locales/en/smartGuide.json +0 -49
  235. package/dist/i18n/locales/en/stats.json +0 -20
  236. package/dist/i18n/locales/en/subagent.json +0 -69
  237. package/dist/i18n/locales/en/superpowers.json +0 -117
  238. package/dist/i18n/locales/en/team.json +0 -7
  239. package/dist/i18n/locales/en/thinking.json +0 -65
  240. package/dist/i18n/locales/en/tools.json +0 -42
  241. package/dist/i18n/locales/en/uninstall.json +0 -56
  242. package/dist/i18n/locales/en/updater.json +0 -29
  243. package/dist/i18n/locales/en/vim.json +0 -169
  244. package/dist/i18n/locales/en/workflow.json +0 -55
  245. package/dist/i18n/locales/en/workspace.json +0 -108
  246. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  247. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -80
  248. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  249. package/dist/i18n/locales/zh-CN/api.json +0 -63
  250. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  251. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  252. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  253. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  254. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  255. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  256. package/dist/i18n/locales/zh-CN/cli.json +0 -148
  257. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  258. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  259. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  260. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  261. package/dist/i18n/locales/zh-CN/codex.json +0 -184
  262. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  263. package/dist/i18n/locales/zh-CN/common.json +0 -68
  264. package/dist/i18n/locales/zh-CN/config.json +0 -108
  265. package/dist/i18n/locales/zh-CN/configuration.json +0 -234
  266. package/dist/i18n/locales/zh-CN/context.json +0 -85
  267. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  268. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  269. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  270. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  271. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  272. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  273. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  274. package/dist/i18n/locales/zh-CN/language.json +0 -19
  275. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  276. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  277. package/dist/i18n/locales/zh-CN/mcp.json +0 -180
  278. package/dist/i18n/locales/zh-CN/memory.json +0 -23
  279. package/dist/i18n/locales/zh-CN/menu.json +0 -299
  280. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  281. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  282. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  283. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  284. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  285. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  286. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  287. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  288. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  289. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  290. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  291. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  292. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  293. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  294. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  295. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  296. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  297. package/dist/i18n/locales/zh-CN/team.json +0 -7
  298. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  299. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  300. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  301. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  302. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  303. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  304. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  305. package/dist/index.d.mts +0 -5658
  306. package/dist/index.d.ts +0 -5658
  307. package/dist/index.mjs +0 -3732
  308. package/dist/shared/ccjk.5bEolFrk.mjs +0 -254
  309. package/dist/shared/ccjk.8oaxX4iR.mjs +0 -90
  310. package/dist/shared/ccjk.B2U7DsPy.mjs +0 -31
  311. package/dist/shared/ccjk.B2f-cwUP.mjs +0 -468
  312. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  313. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  314. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  315. package/dist/shared/ccjk.BLsIiTqO.mjs +0 -449
  316. package/dist/shared/ccjk.BXv8aYs1.mjs +0 -170
  317. package/dist/shared/ccjk.BnsY5WxD.mjs +0 -171
  318. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  319. package/dist/shared/ccjk.Bq8TqZG_.mjs +0 -189
  320. package/dist/shared/ccjk.BtrioX1Z.mjs +0 -25
  321. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  322. package/dist/shared/ccjk.BzPbSEP2.mjs +0 -115
  323. package/dist/shared/ccjk.C0WLUnFV.mjs +0 -293
  324. package/dist/shared/ccjk.C1hANZTu.mjs +0 -19
  325. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  326. package/dist/shared/ccjk.CNhnT6uQ.mjs +0 -636
  327. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  328. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  329. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  330. package/dist/shared/ccjk.CoCHVXl3.mjs +0 -3951
  331. package/dist/shared/ccjk.CwGZSTAK.mjs +0 -319
  332. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  333. package/dist/shared/ccjk.D-magaEx.mjs +0 -763
  334. package/dist/shared/ccjk.D0g2ABGg.mjs +0 -171
  335. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  336. package/dist/shared/ccjk.D75wivnp.mjs +0 -142
  337. package/dist/shared/ccjk.DDL-4C-k.mjs +0 -100
  338. package/dist/shared/ccjk.DFRPtmK_.mjs +0 -75
  339. package/dist/shared/ccjk.DMV3x5Sd.mjs +0 -299
  340. package/dist/shared/ccjk.DZ2LLOa-.mjs +0 -2195
  341. package/dist/shared/ccjk.DbigonEQ.mjs +0 -698
  342. package/dist/shared/ccjk.DcMvE7lf.mjs +0 -618
  343. package/dist/shared/ccjk.DeWpAShp.mjs +0 -1828
  344. package/dist/shared/ccjk.DhJ1kyDR.mjs +0 -30
  345. package/dist/shared/ccjk.DlTXS9rP.mjs +0 -224
  346. package/dist/shared/ccjk.DopKzo3z.mjs +0 -305
  347. package/dist/shared/ccjk.DsZsc4LR.mjs +0 -1280
  348. package/dist/shared/ccjk.DuzJZlgj.mjs +0 -418
  349. package/dist/shared/ccjk.Dxgd2vjc.mjs +0 -444
  350. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  351. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  352. package/dist/shared/ccjk.L7yC58_i.mjs +0 -225
  353. package/dist/shared/ccjk.MwtjAULc.mjs +0 -1447
  354. package/dist/shared/ccjk.OJKHVSOb.mjs +0 -2005
  355. package/dist/shared/ccjk.OTnevPNE.mjs +0 -225
  356. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  357. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  358. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  359. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  360. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  361. package/dist/shared/ccjk.i_vn-9C3.mjs +0 -317
  362. package/dist/shared/ccjk.lG3ccFjm.mjs +0 -885
  363. package/dist/shared/ccjk.wLJHO0Af.mjs +0 -244
  364. package/dist/shared/ccjk.y-a_1vK4.mjs +0 -5127
  365. package/dist/templates/agents/README.md +0 -78
  366. package/dist/templates/agents/fullstack-developer.json +0 -70
  367. package/dist/templates/agents/go-expert.json +0 -69
  368. package/dist/templates/agents/index.json +0 -64
  369. package/dist/templates/agents/python-expert.json +0 -69
  370. package/dist/templates/agents/react-specialist.json +0 -69
  371. package/dist/templates/agents/testing-automation-expert.json +0 -70
  372. package/dist/templates/agents/typescript-architect.json +0 -69
  373. package/dist/templates/claude-code/common/settings.json +0 -109
  374. package/dist/templates/common/error-prevention.md +0 -267
  375. package/dist/templates/common/karpathy-baseline.md +0 -83
  376. package/dist/templates/common/output-styles/zh-CN/carmack-mode.md +0 -381
  377. package/dist/templates/common/output-styles/zh-CN/codex-rigor-mode.md +0 -114
  378. package/dist/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  379. package/dist/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  380. package/dist/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  381. package/dist/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  382. package/dist/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  383. package/dist/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  384. package/dist/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  385. package/dist/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  386. package/dist/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  387. package/dist/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  388. package/dist/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  389. package/dist/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  390. package/dist/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  391. package/dist/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  392. package/dist/templates/common/workflow/essential/en/feat.md +0 -92
  393. package/dist/templates/common/workflow/essential/en/goal.md +0 -147
  394. package/dist/templates/common/workflow/essential/en/init-project.md +0 -53
  395. package/dist/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  396. package/dist/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  397. package/dist/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  398. package/dist/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  399. package/dist/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  400. package/dist/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  401. package/dist/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  402. package/dist/templates/common/workflow/git/en/git-commit.md +0 -205
  403. package/dist/templates/common/workflow/git/en/git-rollback.md +0 -90
  404. package/dist/templates/common/workflow/git/en/git-worktree.md +0 -276
  405. package/dist/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  406. package/dist/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  407. package/dist/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  408. package/dist/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  409. package/dist/templates/common/workflow/interview/en/interview.md +0 -67
  410. package/dist/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  411. package/dist/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  412. package/dist/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  413. package/dist/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  414. package/dist/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  415. package/dist/templates/common/workflow/sixStep/en/workflow.md +0 -83
  416. package/dist/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  417. package/dist/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  418. package/dist/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  419. package/dist/templates/hooks/README.md +0 -212
  420. package/dist/templates/hooks/git-workflow-hooks.md +0 -551
  421. package/dist/templates/hooks/post-test/coverage.json +0 -21
  422. package/dist/templates/hooks/post-test/summary.json +0 -21
  423. package/dist/templates/hooks/post-test-coverage.md +0 -434
  424. package/dist/templates/hooks/pre-commit/eslint.json +0 -22
  425. package/dist/templates/hooks/pre-commit/prettier.json +0 -22
  426. package/dist/templates/hooks/pre-commit-black.md +0 -274
  427. package/dist/templates/hooks/pre-commit-eslint.md +0 -153
  428. package/dist/templates/hooks/pre-commit-gofmt.md +0 -284
  429. package/dist/templates/hooks/pre-commit-prettier.md +0 -212
  430. package/dist/templates/hooks/pre-commit-type-check.md +0 -377
  431. package/dist/templates/skills/ccjk-init.md +0 -154
  432. package/dist/templates/skills/ccjk-mcp-setup.md +0 -205
  433. package/dist/templates/skills/ccjk-troubleshoot.md +0 -228
  434. package/dist/templates/skills/django-patterns.md +0 -1016
  435. package/dist/templates/skills/git-workflow.md +0 -748
  436. package/dist/templates/skills/go-idioms.md +0 -963
  437. package/dist/templates/skills/index.json +0 -132
  438. package/dist/templates/skills/nextjs-optimization.md +0 -694
  439. package/dist/templates/skills/python-pep8.md +0 -852
  440. package/dist/templates/skills/react-patterns.md +0 -686
  441. package/dist/templates/skills/rust-patterns.md +0 -1057
  442. package/dist/templates/skills/security-best-practices.md +0 -1413
  443. package/dist/templates/skills/testing-best-practices.md +0 -1315
  444. package/dist/templates/skills/ts-best-practices.md +0 -354
  445. package/templates/agents/README.md +0 -78
  446. package/templates/agents/fullstack-developer.json +0 -70
  447. package/templates/agents/go-expert.json +0 -69
  448. package/templates/agents/index.json +0 -64
  449. package/templates/agents/python-expert.json +0 -69
  450. package/templates/agents/react-specialist.json +0 -69
  451. package/templates/agents/testing-automation-expert.json +0 -70
  452. package/templates/agents/typescript-architect.json +0 -69
  453. package/templates/claude-code/common/settings.json +0 -109
  454. package/templates/common/error-prevention.md +0 -267
  455. package/templates/common/karpathy-baseline.md +0 -83
  456. package/templates/common/output-styles/zh-CN/carmack-mode.md +0 -381
  457. package/templates/common/output-styles/zh-CN/codex-rigor-mode.md +0 -114
  458. package/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  459. package/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  460. package/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  461. package/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  462. package/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  463. package/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  464. package/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  465. package/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  466. package/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  467. package/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  468. package/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  469. package/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  470. package/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  471. package/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  472. package/templates/common/workflow/essential/en/feat.md +0 -92
  473. package/templates/common/workflow/essential/en/goal.md +0 -147
  474. package/templates/common/workflow/essential/en/init-project.md +0 -53
  475. package/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  476. package/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  477. package/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  478. package/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  479. package/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  480. package/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  481. package/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  482. package/templates/common/workflow/git/en/git-commit.md +0 -205
  483. package/templates/common/workflow/git/en/git-rollback.md +0 -90
  484. package/templates/common/workflow/git/en/git-worktree.md +0 -276
  485. package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  486. package/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  487. package/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  488. package/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  489. package/templates/common/workflow/interview/en/interview.md +0 -67
  490. package/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  491. package/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  492. package/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  493. package/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  494. package/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  495. package/templates/common/workflow/sixStep/en/workflow.md +0 -83
  496. package/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  497. package/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  498. package/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  499. package/templates/hooks/README.md +0 -212
  500. package/templates/hooks/git-workflow-hooks.md +0 -551
  501. package/templates/hooks/post-test/coverage.json +0 -21
  502. package/templates/hooks/post-test/summary.json +0 -21
  503. package/templates/hooks/post-test-coverage.md +0 -434
  504. package/templates/hooks/pre-commit/eslint.json +0 -22
  505. package/templates/hooks/pre-commit/prettier.json +0 -22
  506. package/templates/hooks/pre-commit-black.md +0 -274
  507. package/templates/hooks/pre-commit-eslint.md +0 -153
  508. package/templates/hooks/pre-commit-gofmt.md +0 -284
  509. package/templates/hooks/pre-commit-prettier.md +0 -212
  510. package/templates/hooks/pre-commit-type-check.md +0 -377
  511. package/templates/skills/basic.hbs +0 -72
  512. package/templates/skills/ccjk-init.md +0 -154
  513. package/templates/skills/ccjk-mcp-setup.md +0 -205
  514. package/templates/skills/ccjk-troubleshoot.md +0 -228
  515. package/templates/skills/code-refactor.hbs +0 -133
  516. package/templates/skills/code-review.hbs +0 -141
  517. package/templates/skills/django-patterns.md +0 -1016
  518. package/templates/skills/git-workflow.md +0 -748
  519. package/templates/skills/go-idioms.md +0 -963
  520. package/templates/skills/index.json +0 -132
  521. package/templates/skills/nextjs-optimization.md +0 -694
  522. package/templates/skills/python-pep8.md +0 -852
  523. package/templates/skills/react-patterns.md +0 -686
  524. package/templates/skills/rust-patterns.md +0 -1057
  525. package/templates/skills/security-best-practices.md +0 -1413
  526. package/templates/skills/testing-best-practices.md +0 -1315
  527. package/templates/skills/ts-best-practices.md +0 -354
  528. package/templates/skills/type-fix.hbs +0 -132
@@ -1,1454 +0,0 @@
1
- import { chmodSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import { ZCF_CONFIG_FILE, ZCF_CONFIG_DIR, CLAVUE_CONFIG_FILE, CLAVUE_CREDENTIALS_FILE, CLAVUE_SETTINGS_FILE, CLAVUE_DIR } from './constants.mjs';
4
- import { d as dayjs } from '../shared/ccjk.RyizuzOI.mjs';
5
- import { readDefaultTomlConfig, createDefaultTomlConfig, writeTomlConfig } from './ccjk-config.mjs';
6
- import { r as resolveClaudeFamilySettingsTarget, n as normalizeClaudeFamilySettings } from '../shared/ccjk.DDL-4C-k.mjs';
7
- import { h as clearLegacyTopLevelRuntimeSettings, o as overwriteModelSettings } from './config.mjs';
8
- import { ensureDir, exists, copyFile } from './fs-operations.mjs';
9
- import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
10
- import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
11
-
12
- class ClaudeCodeConfigManager {
13
- static CONFIG_FILE = ZCF_CONFIG_FILE;
14
- static LEGACY_CONFIG_FILE = join(ZCF_CONFIG_DIR, "claude-code-configs.json");
15
- /**
16
- * Ensure configuration directory exists
17
- */
18
- static ensureConfigDir() {
19
- ensureDir(ZCF_CONFIG_DIR);
20
- }
21
- /**
22
- * Read TOML configuration
23
- */
24
- static readTomlConfig() {
25
- return readDefaultTomlConfig();
26
- }
27
- /**
28
- * Load TOML configuration, falling back to default when missing
29
- */
30
- static loadTomlConfig() {
31
- const existingConfig = this.readTomlConfig();
32
- if (existingConfig) {
33
- return existingConfig;
34
- }
35
- return createDefaultTomlConfig();
36
- }
37
- /**
38
- * Migrate legacy JSON-based configuration into TOML storage
39
- */
40
- static migrateFromLegacyConfig() {
41
- if (!exists(this.LEGACY_CONFIG_FILE)) {
42
- return null;
43
- }
44
- try {
45
- const legacyConfig = readJsonConfig(this.LEGACY_CONFIG_FILE);
46
- if (!legacyConfig) {
47
- return null;
48
- }
49
- const normalizedProfiles = {};
50
- const existingKeys = /* @__PURE__ */ new Set();
51
- let migratedCurrentKey = "";
52
- Object.entries(legacyConfig.profiles || {}).forEach(([legacyKey, profile]) => {
53
- const sourceProfile = profile;
54
- const name = sourceProfile.name?.trim() || legacyKey;
55
- const baseKey = this.generateProfileId(name);
56
- let uniqueKey = baseKey || legacyKey;
57
- let suffix = 2;
58
- while (existingKeys.has(uniqueKey)) {
59
- uniqueKey = `${baseKey || legacyKey}-${suffix++}`;
60
- }
61
- existingKeys.add(uniqueKey);
62
- const sanitizedProfile = this.sanitizeProfile({
63
- ...sourceProfile,
64
- name
65
- });
66
- normalizedProfiles[uniqueKey] = {
67
- ...sanitizedProfile,
68
- id: uniqueKey
69
- };
70
- if (legacyConfig.currentProfileId === legacyKey || legacyConfig.currentProfileId === sourceProfile.id) {
71
- migratedCurrentKey = uniqueKey;
72
- }
73
- });
74
- if (!migratedCurrentKey && legacyConfig.currentProfileId) {
75
- const fallbackKey = this.generateProfileId(legacyConfig.currentProfileId);
76
- if (existingKeys.has(fallbackKey)) {
77
- migratedCurrentKey = fallbackKey;
78
- }
79
- }
80
- if (!migratedCurrentKey && existingKeys.size > 0) {
81
- migratedCurrentKey = Array.from(existingKeys)[0];
82
- }
83
- const migratedConfig = {
84
- currentProfileId: migratedCurrentKey,
85
- profiles: normalizedProfiles
86
- };
87
- this.writeConfig(migratedConfig);
88
- return migratedConfig;
89
- } catch (error) {
90
- console.error("Failed to migrate legacy Claude Code config:", error);
91
- return null;
92
- }
93
- }
94
- /**
95
- * Read configuration
96
- */
97
- static readConfig() {
98
- try {
99
- const tomlConfig = readDefaultTomlConfig();
100
- if (!tomlConfig || !tomlConfig.claudeCode) {
101
- return this.migrateFromLegacyConfig();
102
- }
103
- const { claudeCode } = tomlConfig;
104
- const rawProfiles = claudeCode.profiles || {};
105
- const sanitizedProfiles = Object.fromEntries(
106
- Object.entries(rawProfiles).map(([key, profile]) => {
107
- const storedProfile = this.sanitizeProfile({
108
- ...profile,
109
- name: profile.name || key
110
- });
111
- return [key, { ...storedProfile, id: key }];
112
- })
113
- );
114
- const configData = {
115
- currentProfileId: claudeCode.currentProfile || "",
116
- profiles: sanitizedProfiles
117
- };
118
- if (Object.keys(configData.profiles).length === 0) {
119
- const migrated = this.migrateFromLegacyConfig();
120
- if (migrated) {
121
- return migrated;
122
- }
123
- }
124
- return configData;
125
- } catch (error) {
126
- console.error("Failed to read Claude Code config:", error);
127
- return null;
128
- }
129
- }
130
- /**
131
- * Write configuration
132
- */
133
- static writeConfig(config) {
134
- try {
135
- this.ensureConfigDir();
136
- const keyMap = /* @__PURE__ */ new Map();
137
- const sanitizedProfiles = Object.fromEntries(
138
- Object.entries(config.profiles).map(([key, profile]) => {
139
- const normalizedName = profile.name?.trim() || key;
140
- const profileKey = this.generateProfileId(normalizedName);
141
- keyMap.set(key, profileKey);
142
- const sanitizedProfile = this.sanitizeProfile({
143
- ...profile,
144
- name: normalizedName
145
- });
146
- return [profileKey, sanitizedProfile];
147
- })
148
- );
149
- const tomlConfig = this.loadTomlConfig();
150
- const nextTomlConfig = {
151
- ...tomlConfig,
152
- claudeCode: {
153
- ...tomlConfig.claudeCode,
154
- currentProfile: keyMap.get(config.currentProfileId) || config.currentProfileId,
155
- profiles: sanitizedProfiles
156
- }
157
- };
158
- writeTomlConfig(this.CONFIG_FILE, nextTomlConfig);
159
- } catch (error) {
160
- console.error("Failed to write Claude Code config:", error);
161
- throw new Error(`Failed to write config: ${error instanceof Error ? error.message : String(error)}`);
162
- }
163
- }
164
- /**
165
- * Create empty configuration
166
- */
167
- static createEmptyConfig() {
168
- return {
169
- currentProfileId: "",
170
- profiles: {}
171
- };
172
- }
173
- static settingsMatchProfile(settings, profile) {
174
- const env = settings?.env || {};
175
- if (!profile) {
176
- return !settings?.model && !env.ANTHROPIC_MODEL && !env.ANTHROPIC_DEFAULT_HAIKU_MODEL && !env.ANTHROPIC_DEFAULT_SONNET_MODEL && !env.ANTHROPIC_DEFAULT_OPUS_MODEL;
177
- }
178
- const expectedPrimary = profile.primaryModel?.trim();
179
- const expectedHaiku = profile.defaultHaikuModel?.trim();
180
- const expectedSonnet = profile.defaultSonnetModel?.trim();
181
- const expectedOpus = profile.defaultOpusModel?.trim();
182
- const hasExplicitModelConfig = Boolean(expectedPrimary || expectedHaiku || expectedSonnet || expectedOpus);
183
- if (!hasExplicitModelConfig) {
184
- return !settings?.model && (env.ANTHROPIC_MODEL === "" || env.ANTHROPIC_MODEL === void 0) && env.ANTHROPIC_DEFAULT_HAIKU_MODEL === void 0 && env.ANTHROPIC_DEFAULT_SONNET_MODEL === void 0 && env.ANTHROPIC_DEFAULT_OPUS_MODEL === void 0;
185
- }
186
- const hasAdaptiveRouting = Boolean(expectedHaiku || expectedSonnet || expectedOpus);
187
- if (hasAdaptiveRouting) {
188
- return !settings?.model && env.ANTHROPIC_MODEL === void 0 && env.ANTHROPIC_DEFAULT_HAIKU_MODEL === expectedHaiku && env.ANTHROPIC_SMALL_FAST_MODEL === expectedHaiku && env.ANTHROPIC_DEFAULT_SONNET_MODEL === expectedSonnet && env.ANTHROPIC_DEFAULT_OPUS_MODEL === expectedOpus;
189
- }
190
- return settings?.model === expectedPrimary && env.ANTHROPIC_MODEL === void 0 && env.ANTHROPIC_DEFAULT_HAIKU_MODEL === expectedHaiku && env.ANTHROPIC_SMALL_FAST_MODEL === expectedHaiku && env.ANTHROPIC_DEFAULT_SONNET_MODEL === expectedSonnet && env.ANTHROPIC_DEFAULT_OPUS_MODEL === expectedOpus;
191
- }
192
- static async syncCurrentProfileToSettings() {
193
- const currentProfile = this.getCurrentProfile();
194
- await this.applyProfileSettings(currentProfile);
195
- }
196
- /**
197
- * Apply profile settings to Claude Code runtime
198
- */
199
- static async applyProfileSettings(profile) {
200
- const { ensureI18nInitialized, i18n } = await import('./index2.mjs');
201
- ensureI18nInitialized();
202
- const target = resolveClaudeFamilySettingsTarget();
203
- try {
204
- if (!profile) {
205
- const { switchToOfficialLogin } = await import('./config.mjs').then(function (n) { return n.k; });
206
- switchToOfficialLogin(target.codeTool);
207
- return;
208
- }
209
- const { readJsonConfig: readJsonConfig2, writeJsonConfig } = await import('./json-config.mjs');
210
- const settings = readJsonConfig2(target.settingsFile) || {};
211
- clearLegacyTopLevelRuntimeSettings(settings);
212
- if (!settings.env)
213
- settings.env = {};
214
- let shouldRestartCcr = false;
215
- if (profile.authType === "api_key") {
216
- settings.env.ANTHROPIC_API_KEY = profile.apiKey;
217
- delete settings.env.ANTHROPIC_AUTH_TOKEN;
218
- } else if (profile.authType === "auth_token") {
219
- settings.env.ANTHROPIC_AUTH_TOKEN = profile.apiKey;
220
- delete settings.env.ANTHROPIC_API_KEY;
221
- } else if (profile.authType === "ccr_proxy") {
222
- const { readCcrConfig } = await import('./config2.mjs');
223
- const ccrConfig = readCcrConfig();
224
- if (!ccrConfig) {
225
- throw new Error(i18n.t("ccr:ccrNotConfigured") || "CCR proxy configuration not found");
226
- }
227
- const host = ccrConfig.HOST || "127.0.0.1";
228
- const port = ccrConfig.PORT || 3456;
229
- const apiKey = ccrConfig.APIKEY || "sk-ccjk-x-ccr";
230
- settings.env.ANTHROPIC_BASE_URL = `http://${host}:${port}`;
231
- settings.env.ANTHROPIC_API_KEY = apiKey;
232
- delete settings.env.ANTHROPIC_AUTH_TOKEN;
233
- shouldRestartCcr = true;
234
- }
235
- if (profile.authType !== "ccr_proxy") {
236
- if (profile.baseUrl)
237
- settings.env.ANTHROPIC_BASE_URL = profile.baseUrl;
238
- else
239
- delete settings.env.ANTHROPIC_BASE_URL;
240
- }
241
- const hasModelConfig = Boolean(
242
- profile.primaryModel || profile.defaultHaikuModel || profile.defaultSonnetModel || profile.defaultOpusModel
243
- );
244
- const modelMode = hasModelConfig ? "override" : "reset";
245
- overwriteModelSettings(settings, {
246
- primaryModel: profile.primaryModel,
247
- haikuModel: profile.defaultHaikuModel,
248
- sonnetModel: profile.defaultSonnetModel,
249
- opusModel: profile.defaultOpusModel
250
- }, modelMode);
251
- normalizeClaudeFamilySettings(settings);
252
- writeJsonConfig(target.settingsFile, settings);
253
- const { setPrimaryApiKey, addCompletedOnboarding } = await import('./claude-config.mjs').then(function (n) { return n.n; });
254
- setPrimaryApiKey(target.codeTool);
255
- addCompletedOnboarding(target.codeTool);
256
- let verifiedSettings = readJsonConfig2(target.settingsFile) || {};
257
- if (!this.settingsMatchProfile(verifiedSettings, profile)) {
258
- const repairedSettings = readJsonConfig2(target.settingsFile) || {};
259
- clearLegacyTopLevelRuntimeSettings(repairedSettings);
260
- repairedSettings.env = repairedSettings.env || {};
261
- if (profile?.authType === "api_key") {
262
- repairedSettings.env.ANTHROPIC_API_KEY = profile.apiKey;
263
- delete repairedSettings.env.ANTHROPIC_AUTH_TOKEN;
264
- } else if (profile?.authType === "auth_token") {
265
- repairedSettings.env.ANTHROPIC_AUTH_TOKEN = profile.apiKey;
266
- delete repairedSettings.env.ANTHROPIC_API_KEY;
267
- }
268
- if (profile?.authType !== "ccr_proxy") {
269
- if (profile?.baseUrl)
270
- repairedSettings.env.ANTHROPIC_BASE_URL = profile.baseUrl;
271
- else
272
- delete repairedSettings.env.ANTHROPIC_BASE_URL;
273
- }
274
- overwriteModelSettings(repairedSettings, {
275
- primaryModel: profile?.primaryModel,
276
- haikuModel: profile?.defaultHaikuModel,
277
- sonnetModel: profile?.defaultSonnetModel,
278
- opusModel: profile?.defaultOpusModel
279
- }, profile ? modelMode : "reset");
280
- normalizeClaudeFamilySettings(repairedSettings);
281
- writeJsonConfig(target.settingsFile, repairedSettings);
282
- verifiedSettings = readJsonConfig2(target.settingsFile) || {};
283
- }
284
- if (!this.settingsMatchProfile(verifiedSettings, profile)) {
285
- throw new Error("settings.json verification failed after applying current profile");
286
- }
287
- if (shouldRestartCcr) {
288
- const { runCcrRestart } = await import('./commands.mjs');
289
- await runCcrRestart();
290
- }
291
- } catch (error) {
292
- const reason = error instanceof Error ? error.message : String(error);
293
- throw new Error(`${i18n.t("multi-config:failedToApplySettings")}: ${reason}`);
294
- }
295
- }
296
- static async applyCurrentProfile() {
297
- await this.syncCurrentProfileToSettings();
298
- }
299
- /**
300
- * Remove unsupported fields from profile payload
301
- */
302
- static sanitizeProfile(profile) {
303
- const sanitized = {
304
- name: profile.name,
305
- authType: profile.authType
306
- };
307
- if (profile.provider)
308
- sanitized.provider = profile.provider;
309
- if (profile.apiKey)
310
- sanitized.apiKey = profile.apiKey;
311
- if (profile.baseUrl)
312
- sanitized.baseUrl = profile.baseUrl;
313
- if (profile.primaryModel)
314
- sanitized.primaryModel = profile.primaryModel;
315
- if (profile.defaultHaikuModel)
316
- sanitized.defaultHaikuModel = profile.defaultHaikuModel;
317
- if (profile.defaultSonnetModel)
318
- sanitized.defaultSonnetModel = profile.defaultSonnetModel;
319
- if (profile.defaultOpusModel)
320
- sanitized.defaultOpusModel = profile.defaultOpusModel;
321
- return sanitized;
322
- }
323
- /**
324
- * Backup configuration
325
- */
326
- static backupConfig() {
327
- try {
328
- if (!exists(this.CONFIG_FILE)) {
329
- return null;
330
- }
331
- const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
332
- const backupPath = join(ZCF_CONFIG_DIR, `config.backup.${timestamp}.toml`);
333
- copyFile(this.CONFIG_FILE, backupPath);
334
- return backupPath;
335
- } catch (error) {
336
- console.error("Failed to backup Claude Code config:", error);
337
- return null;
338
- }
339
- }
340
- /**
341
- * Add configuration
342
- */
343
- static async addProfile(profile) {
344
- try {
345
- const validationErrors = this.validateProfile(profile);
346
- if (validationErrors.length > 0) {
347
- return {
348
- success: false,
349
- error: `Validation failed: ${validationErrors.join(", ")}`
350
- };
351
- }
352
- const backupPath = this.backupConfig();
353
- let config = this.readConfig();
354
- if (!config) {
355
- config = this.createEmptyConfig();
356
- }
357
- if (profile.id && config.profiles[profile.id]) {
358
- return {
359
- success: false,
360
- error: `Profile with ID "${profile.id}" already exists`,
361
- backupPath: backupPath || void 0
362
- };
363
- }
364
- const normalizedName = profile.name.trim();
365
- const profileKey = this.generateProfileId(normalizedName);
366
- const existingNames = Object.values(config.profiles).map((p) => p.name || "");
367
- if (config.profiles[profileKey] || existingNames.some((name) => name.toLowerCase() === normalizedName.toLowerCase())) {
368
- return {
369
- success: false,
370
- error: `Profile with name "${profile.name}" already exists`,
371
- backupPath: backupPath || void 0
372
- };
373
- }
374
- const sanitizedProfile = this.sanitizeProfile({
375
- ...profile,
376
- name: normalizedName
377
- });
378
- const runtimeProfile = {
379
- ...sanitizedProfile,
380
- id: profileKey
381
- };
382
- config.profiles[profileKey] = runtimeProfile;
383
- if (!config.currentProfileId) {
384
- config.currentProfileId = profileKey;
385
- }
386
- this.writeConfig(config);
387
- if (config.currentProfileId === profileKey) {
388
- await this.syncCurrentProfileToSettings();
389
- }
390
- return {
391
- success: true,
392
- backupPath: backupPath || void 0,
393
- addedProfile: runtimeProfile
394
- };
395
- } catch (error) {
396
- return {
397
- success: false,
398
- error: error instanceof Error ? error.message : String(error)
399
- };
400
- }
401
- }
402
- /**
403
- * Update configuration
404
- */
405
- static async updateProfile(id, data) {
406
- try {
407
- const validationErrors = this.validateProfile(data, true);
408
- if (validationErrors.length > 0) {
409
- return {
410
- success: false,
411
- error: `Validation failed: ${validationErrors.join(", ")}`
412
- };
413
- }
414
- const backupPath = this.backupConfig();
415
- const config = this.readConfig();
416
- if (!config || !config.profiles[id]) {
417
- return {
418
- success: false,
419
- error: `Profile with ID "${id}" not found`,
420
- backupPath: backupPath || void 0
421
- };
422
- }
423
- const existingProfile = config.profiles[id];
424
- const nextName = data.name !== void 0 ? data.name.trim() : existingProfile.name;
425
- const nextKey = this.generateProfileId(nextName);
426
- const nameChanged = nextKey !== id;
427
- if (nameChanged) {
428
- const duplicateName = Object.entries(config.profiles).some(([key, profile]) => key !== id && (profile.name || "").toLowerCase() === nextName.toLowerCase());
429
- if (duplicateName || config.profiles[nextKey]) {
430
- return {
431
- success: false,
432
- error: `Profile with name "${data.name}" already exists`,
433
- backupPath: backupPath || void 0
434
- };
435
- }
436
- }
437
- const mergedProfile = this.sanitizeProfile({
438
- ...existingProfile,
439
- ...data,
440
- name: nextName
441
- });
442
- if (nameChanged) {
443
- delete config.profiles[id];
444
- config.profiles[nextKey] = {
445
- ...mergedProfile,
446
- id: nextKey
447
- };
448
- if (config.currentProfileId === id) {
449
- config.currentProfileId = nextKey;
450
- }
451
- } else {
452
- config.profiles[id] = {
453
- ...mergedProfile,
454
- id
455
- };
456
- }
457
- this.writeConfig(config);
458
- if (config.currentProfileId === (nameChanged ? nextKey : id)) {
459
- await this.syncCurrentProfileToSettings();
460
- }
461
- return {
462
- success: true,
463
- backupPath: backupPath || void 0,
464
- updatedProfile: {
465
- ...mergedProfile,
466
- id: nameChanged ? nextKey : id
467
- }
468
- };
469
- } catch (error) {
470
- return {
471
- success: false,
472
- error: error instanceof Error ? error.message : String(error)
473
- };
474
- }
475
- }
476
- /**
477
- * Delete configuration
478
- */
479
- static async deleteProfile(id) {
480
- try {
481
- const backupPath = this.backupConfig();
482
- const config = this.readConfig();
483
- if (!config || !config.profiles[id]) {
484
- return {
485
- success: false,
486
- error: `Profile with ID "${id}" not found`,
487
- backupPath: backupPath || void 0
488
- };
489
- }
490
- const profileCount = Object.keys(config.profiles).length;
491
- if (profileCount === 1) {
492
- return {
493
- success: false,
494
- error: "Cannot delete the last profile. At least one profile must remain.",
495
- backupPath: backupPath || void 0
496
- };
497
- }
498
- delete config.profiles[id];
499
- if (config.currentProfileId === id) {
500
- const remainingIds = Object.keys(config.profiles);
501
- config.currentProfileId = remainingIds[0];
502
- }
503
- this.writeConfig(config);
504
- if (config.currentProfileId) {
505
- await this.syncCurrentProfileToSettings();
506
- }
507
- return {
508
- success: true,
509
- backupPath: backupPath || void 0,
510
- remainingProfiles: Object.entries(config.profiles).map(([key, profile]) => ({
511
- ...profile,
512
- id: key
513
- }))
514
- };
515
- } catch (error) {
516
- return {
517
- success: false,
518
- error: error instanceof Error ? error.message : String(error)
519
- };
520
- }
521
- }
522
- /**
523
- * Delete multiple configurations
524
- */
525
- static async deleteProfiles(ids) {
526
- try {
527
- const backupPath = this.backupConfig();
528
- const config = this.readConfig();
529
- if (!config) {
530
- return {
531
- success: false,
532
- error: "No configuration found",
533
- backupPath: backupPath || void 0
534
- };
535
- }
536
- const missingIds = ids.filter((id) => !config.profiles[id]);
537
- if (missingIds.length > 0) {
538
- return {
539
- success: false,
540
- error: `Profiles not found: ${missingIds.join(", ")}`,
541
- backupPath: backupPath || void 0
542
- };
543
- }
544
- const remainingCount = Object.keys(config.profiles).length - ids.length;
545
- if (remainingCount === 0) {
546
- return {
547
- success: false,
548
- error: "Cannot delete all profiles. At least one profile must remain.",
549
- backupPath: backupPath || void 0
550
- };
551
- }
552
- let newCurrentProfileId;
553
- ids.forEach((id) => {
554
- delete config.profiles[id];
555
- });
556
- if (ids.includes(config.currentProfileId)) {
557
- const remainingIds = Object.keys(config.profiles);
558
- config.currentProfileId = remainingIds[0];
559
- newCurrentProfileId = config.currentProfileId;
560
- }
561
- this.writeConfig(config);
562
- if (config.currentProfileId) {
563
- await this.syncCurrentProfileToSettings();
564
- }
565
- return {
566
- success: true,
567
- backupPath: backupPath || void 0,
568
- newCurrentProfileId,
569
- deletedProfiles: ids,
570
- remainingProfiles: Object.entries(config.profiles).map(([key, profile]) => ({
571
- ...profile,
572
- id: key
573
- }))
574
- };
575
- } catch (error) {
576
- return {
577
- success: false,
578
- error: error instanceof Error ? error.message : String(error)
579
- };
580
- }
581
- }
582
- /**
583
- * Generate profile ID from name
584
- */
585
- static generateProfileId(name) {
586
- return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "profile";
587
- }
588
- /**
589
- * Switch configuration
590
- */
591
- static async switchProfile(id) {
592
- try {
593
- const config = this.readConfig();
594
- if (!config || !config.profiles[id]) {
595
- return {
596
- success: false,
597
- error: "Profile not found"
598
- };
599
- }
600
- if (config.currentProfileId === id) {
601
- return { success: true };
602
- }
603
- config.currentProfileId = id;
604
- this.writeConfig(config);
605
- await this.syncCurrentProfileToSettings();
606
- return { success: true };
607
- } catch (error) {
608
- return {
609
- success: false,
610
- error: error instanceof Error ? error.message : String(error)
611
- };
612
- }
613
- }
614
- /**
615
- * List all configurations
616
- */
617
- static listProfiles() {
618
- const config = this.readConfig();
619
- if (!config) {
620
- return [];
621
- }
622
- return Object.values(config.profiles);
623
- }
624
- /**
625
- * Get current configuration
626
- */
627
- static getCurrentProfile() {
628
- const config = this.readConfig();
629
- if (!config || !config.currentProfileId) {
630
- return null;
631
- }
632
- return config.profiles[config.currentProfileId] || null;
633
- }
634
- /**
635
- * Get configuration by ID
636
- */
637
- static getProfileById(id) {
638
- const config = this.readConfig();
639
- if (!config) {
640
- return null;
641
- }
642
- return config.profiles[id] || null;
643
- }
644
- /**
645
- * Get configuration by name
646
- */
647
- static getProfileByName(name) {
648
- const config = this.readConfig();
649
- if (!config) {
650
- return null;
651
- }
652
- return Object.values(config.profiles).find((p) => p.name === name) || null;
653
- }
654
- /**
655
- * Sync CCR configuration
656
- */
657
- static async syncCcrProfile() {
658
- try {
659
- const { readCcrConfig } = await import('./config2.mjs');
660
- const ccrConfig = readCcrConfig();
661
- if (!ccrConfig) {
662
- await this.ensureCcrProfileExists(ccrConfig);
663
- return;
664
- }
665
- await this.ensureCcrProfileExists(ccrConfig);
666
- } catch (error) {
667
- console.error("Failed to sync CCR profile:", error);
668
- }
669
- }
670
- /**
671
- * 确保CCR配置文件存在
672
- */
673
- static async ensureCcrProfileExists(ccrConfig) {
674
- const config = this.readConfig() || this.createEmptyConfig();
675
- const ccrProfileId = "ccr-proxy";
676
- const existingCcrProfile = config.profiles[ccrProfileId];
677
- if (!ccrConfig) {
678
- if (existingCcrProfile) {
679
- delete config.profiles[ccrProfileId];
680
- if (config.currentProfileId === ccrProfileId) {
681
- const remainingIds = Object.keys(config.profiles);
682
- config.currentProfileId = remainingIds[0] || "";
683
- }
684
- this.writeConfig(config);
685
- }
686
- return;
687
- }
688
- const host = ccrConfig.HOST || "127.0.0.1";
689
- const port = ccrConfig.PORT || 3456;
690
- const apiKey = ccrConfig.APIKEY || "sk-ccjk-x-ccr";
691
- const baseUrl = `http://${host}:${port}`;
692
- const ccrProfile = {
693
- name: "CCR Proxy",
694
- authType: "ccr_proxy",
695
- baseUrl,
696
- apiKey
697
- };
698
- config.profiles[ccrProfileId] = {
699
- ...ccrProfile,
700
- id: ccrProfileId
701
- };
702
- if (!config.currentProfileId) {
703
- config.currentProfileId = ccrProfileId;
704
- }
705
- this.writeConfig(config);
706
- }
707
- /**
708
- * Switch to official login
709
- */
710
- static async switchToOfficial() {
711
- try {
712
- const config = this.readConfig();
713
- if (!config) {
714
- return { success: true };
715
- }
716
- config.currentProfileId = "";
717
- this.writeConfig(config);
718
- await this.applyProfileSettings(null);
719
- return { success: true };
720
- } catch (error) {
721
- return {
722
- success: false,
723
- error: error instanceof Error ? error.message : String(error)
724
- };
725
- }
726
- }
727
- /**
728
- * Switch to CCR proxy
729
- */
730
- static async switchToCcr() {
731
- try {
732
- await this.syncCcrProfile();
733
- const config = this.readConfig();
734
- if (!config || !config.profiles["ccr-proxy"]) {
735
- return {
736
- success: false,
737
- error: "CCR proxy configuration not found. Please configure CCR first."
738
- };
739
- }
740
- return await this.switchProfile("ccr-proxy");
741
- } catch (error) {
742
- return {
743
- success: false,
744
- error: error instanceof Error ? error.message : String(error)
745
- };
746
- }
747
- }
748
- /**
749
- * Validate configuration
750
- */
751
- static validateProfile(profile, isUpdate = false) {
752
- const errors = [];
753
- if (!isUpdate && (!profile.name || typeof profile.name !== "string" || profile.name.trim() === "")) {
754
- errors.push("Profile name is required");
755
- }
756
- if (profile.name && typeof profile.name !== "string") {
757
- errors.push("Profile name must be a string");
758
- }
759
- if (profile.authType && !["api_key", "auth_token", "ccr_proxy"].includes(profile.authType)) {
760
- errors.push("Invalid auth type. Must be one of: api_key, auth_token, ccr_proxy");
761
- }
762
- if (profile.authType === "api_key" || profile.authType === "auth_token") {
763
- if (!profile.apiKey || typeof profile.apiKey !== "string" || profile.apiKey.trim() === "") {
764
- errors.push("API key is required for api_key and auth_token types");
765
- }
766
- }
767
- if (profile.baseUrl) {
768
- try {
769
- new URL(profile.baseUrl);
770
- } catch {
771
- errors.push("Invalid base URL format");
772
- }
773
- }
774
- return errors;
775
- }
776
- /**
777
- * 检查是否为最后一个配置
778
- */
779
- static isLastProfile(id) {
780
- const config = this.readConfig();
781
- if (!config || !config.profiles[id]) {
782
- return false;
783
- }
784
- return Object.keys(config.profiles).length === 1;
785
- }
786
- }
787
-
788
- const claudeCodeConfigManager = {
789
- __proto__: null,
790
- ClaudeCodeConfigManager: ClaudeCodeConfigManager
791
- };
792
-
793
- function readClavueConfig() {
794
- return readJsonConfig(CLAVUE_CONFIG_FILE);
795
- }
796
- function writeClavueConfig(config) {
797
- writeJsonConfig(CLAVUE_CONFIG_FILE, config);
798
- }
799
- function normalizeMyclaudeProviderProfile(profile) {
800
- return {
801
- ...profile,
802
- ...describeMyclaudeProviderProfile(profile)
803
- };
804
- }
805
- function normalizeClavueBaseUrl(url) {
806
- if (typeof url !== "string") {
807
- return void 0;
808
- }
809
- const normalized = url.trim().replace(/\/v1(?:\/messages|\/responses)?\/?$/i, "").replace(/\/+$/, "");
810
- return normalized || void 0;
811
- }
812
- function normalizeClavueAuthType(authType) {
813
- return authType === "auth_token" ? "auth_token" : "api_key";
814
- }
815
- function inferClavueProviderId(provider, baseUrl) {
816
- const providerId = typeof provider === "string" ? provider.trim() : "";
817
- if (providerId && providerId !== "ccr_proxy") {
818
- return providerId;
819
- }
820
- if (baseUrl === "https://api.anthropic.com") {
821
- return "anthropic";
822
- }
823
- return "custom";
824
- }
825
- function isOpenAiFamilyModel(model) {
826
- return /^(?:gpt-|o\d|codex|kimi|glm|moonshot|deepseek|qwen|doubao|yi-|minimax)/i.test(model.trim());
827
- }
828
- function inferClavueModelMode(profile) {
829
- if (profile.authType === "ccr_proxy" || profile.mode === "ccr-proxy") {
830
- return "hybrid_compatible";
831
- }
832
- const routedModels = [
833
- profile.primaryModel,
834
- profile.model,
835
- profile.defaultHaikuModel,
836
- profile.fastModel,
837
- profile.defaultSonnetModel,
838
- profile.defaultOpusModel
839
- ].filter((model) => typeof model === "string" && model.trim().length > 0);
840
- if (routedModels.length > 0 && routedModels.every(isOpenAiFamilyModel)) {
841
- return "openai_native";
842
- }
843
- if (routedModels.length > 0 && !routedModels.some(isOpenAiFamilyModel)) {
844
- return "anthropic_native";
845
- }
846
- if (routedModels.length > 0) {
847
- return "hybrid_compatible";
848
- }
849
- if (profile.mode === "openai-native") {
850
- return "openai_native";
851
- }
852
- if (!profile.baseUrl || profile.provider === "anthropic" || profile.mode === "official") {
853
- return "anthropic_native";
854
- }
855
- return routedModels.some(isOpenAiFamilyModel) ? "hybrid_compatible" : "anthropic_native";
856
- }
857
- function getClavueRoutingPresetId(profile) {
858
- const mode = inferClavueModelMode(profile);
859
- if (mode === "openai_native") {
860
- return "gpt_5_4_codex";
861
- }
862
- if (mode === "anthropic_native") {
863
- return "claude_code_heritage";
864
- }
865
- return "custom";
866
- }
867
- function isCcjkClavueProfile(profile) {
868
- return profile.provenance?.kind === "imported" && profile.provenance.sourceId === "ccjk";
869
- }
870
- const CCJK_CLAVUE_PROFILE_ID_PREFIX = "ccjk-";
871
- function getSourceProfileId(profile) {
872
- const id = typeof profile.id === "string" ? profile.id.trim() : "";
873
- if (id) {
874
- return id;
875
- }
876
- const name = typeof profile.name === "string" ? profile.name.trim() : "";
877
- return name || "profile";
878
- }
879
- function getCcjkExternalProfileId(profile) {
880
- const externalProfileId = profile.provenance?.externalProfileId;
881
- if (typeof externalProfileId === "string" && externalProfileId.trim()) {
882
- return externalProfileId.trim();
883
- }
884
- const profileId = typeof profile.id === "string" ? profile.id.trim() : "";
885
- if (profileId.startsWith(CCJK_CLAVUE_PROFILE_ID_PREFIX) && profileId.length > CCJK_CLAVUE_PROFILE_ID_PREFIX.length) {
886
- return profileId.slice(CCJK_CLAVUE_PROFILE_ID_PREFIX.length);
887
- }
888
- return profileId || "profile";
889
- }
890
- function getCcjkClavueProfileId(externalProfileId) {
891
- const cleanExternalId = externalProfileId.trim() || "profile";
892
- return cleanExternalId.startsWith(CCJK_CLAVUE_PROFILE_ID_PREFIX) ? cleanExternalId : `${CCJK_CLAVUE_PROFILE_ID_PREFIX}${cleanExternalId}`;
893
- }
894
- function getUniqueClavueProfileId(baseProfileId, reservedProfileIds) {
895
- if (!reservedProfileIds.has(baseProfileId)) {
896
- return baseProfileId;
897
- }
898
- let index = 2;
899
- let candidate = `${baseProfileId}-${index}`;
900
- while (reservedProfileIds.has(candidate)) {
901
- index += 1;
902
- candidate = `${baseProfileId}-${index}`;
903
- }
904
- return candidate;
905
- }
906
- function buildExistingCcjkProfileByExternalId(existingProfiles) {
907
- const existingByExternalId = /* @__PURE__ */ new Map();
908
- for (const profile of existingProfiles) {
909
- if (!isCcjkClavueProfile(profile)) {
910
- continue;
911
- }
912
- const externalProfileId = getCcjkExternalProfileId(profile);
913
- const current = existingByExternalId.get(externalProfileId);
914
- if (!current || profile.id.startsWith(CCJK_CLAVUE_PROFILE_ID_PREFIX)) {
915
- existingByExternalId.set(externalProfileId, profile);
916
- }
917
- }
918
- return existingByExternalId;
919
- }
920
- function resolveClavueProviderProfiles(profiles, existingProfiles) {
921
- const existingCcjkByExternalId = buildExistingCcjkProfileByExternalId(existingProfiles);
922
- const reservedProfileIds = new Set(existingProfiles.filter((profile) => !isCcjkClavueProfile(profile)).map((profile) => profile.id));
923
- return profiles.map((profile) => {
924
- const externalProfileId = getSourceProfileId(profile);
925
- const existing = existingCcjkByExternalId.get(externalProfileId);
926
- const canReuseExistingManagedId = Boolean(
927
- existing && existing.id.startsWith(CCJK_CLAVUE_PROFILE_ID_PREFIX) && !reservedProfileIds.has(existing.id)
928
- );
929
- const clavueProfileId = canReuseExistingManagedId ? existing.id : getUniqueClavueProfileId(getCcjkClavueProfileId(externalProfileId), reservedProfileIds);
930
- reservedProfileIds.add(clavueProfileId);
931
- return {
932
- source: profile,
933
- clavueProfileId,
934
- existing
935
- };
936
- });
937
- }
938
- function findResolvedClavueProfile(profiles, profileId) {
939
- const requestedProfileId = typeof profileId === "string" ? profileId.trim() : "";
940
- if (!requestedProfileId) {
941
- return void 0;
942
- }
943
- return profiles.find((profile) => {
944
- return profile.clavueProfileId === requestedProfileId || getSourceProfileId(profile.source) === requestedProfileId;
945
- });
946
- }
947
- function resolveClavueActiveProviderProfileId(config, activeProfileId) {
948
- const requestedProfileId = typeof activeProfileId === "string" ? activeProfileId.trim() : "";
949
- if (!requestedProfileId) {
950
- return void 0;
951
- }
952
- const existingProfiles = getClavueProviderProfiles(config);
953
- if (existingProfiles.some((profile) => profile.id === requestedProfileId)) {
954
- return requestedProfileId;
955
- }
956
- return existingProfiles.find((profile) => {
957
- return isCcjkClavueProfile(profile) && getCcjkExternalProfileId(profile) === requestedProfileId;
958
- })?.id || requestedProfileId;
959
- }
960
- function createClavueModelRouting(profile) {
961
- const primaryModel = (profile.primaryModel || profile.model || "").trim();
962
- const haikuModel = (profile.defaultHaikuModel || profile.fastModel || "").trim();
963
- const sonnetModel = (profile.defaultSonnetModel || primaryModel).trim();
964
- const opusModel = (profile.defaultOpusModel || primaryModel).trim();
965
- const executionModel = sonnetModel || primaryModel;
966
- return {
967
- presetId: getClavueRoutingPresetId(profile),
968
- primaryModel,
969
- subagentModel: executionModel && executionModel !== primaryModel ? executionModel : "",
970
- smallFastModel: haikuModel,
971
- planModel: opusModel || primaryModel,
972
- exploreModel: executionModel,
973
- generalModel: executionModel,
974
- teamModel: executionModel,
975
- guideModel: opusModel || primaryModel
976
- };
977
- }
978
- function toClavueProviderProfile(profile, clavueProfileId, existing) {
979
- const now = Date.now();
980
- const normalizedBaseUrl = normalizeClavueBaseUrl(profile.baseUrl);
981
- const createdAt = typeof existing?.createdAt === "number" ? existing.createdAt : now;
982
- return {
983
- id: clavueProfileId,
984
- name: profile.name,
985
- providerId: inferClavueProviderId(profile.provider, normalizedBaseUrl),
986
- modelMode: inferClavueModelMode(profile),
987
- ...normalizedBaseUrl ? { baseUrl: normalizedBaseUrl } : {},
988
- authType: normalizeClavueAuthType(profile.authType),
989
- modelRouting: createClavueModelRouting(profile),
990
- provenance: {
991
- kind: "imported",
992
- sourceId: "ccjk",
993
- importedAt: typeof existing?.provenance?.importedAt === "number" ? existing.provenance.importedAt : createdAt,
994
- externalProfileId: getSourceProfileId(profile)
995
- },
996
- createdAt,
997
- updatedAt: now
998
- };
999
- }
1000
- function readClavueCredentialsConfig() {
1001
- return readJsonConfig(CLAVUE_CREDENTIALS_FILE) || {};
1002
- }
1003
- function writeClavueCredentialsConfig(config) {
1004
- writeJsonConfig(CLAVUE_CREDENTIALS_FILE, config);
1005
- try {
1006
- chmodSync(CLAVUE_CREDENTIALS_FILE, 384);
1007
- } catch {
1008
- }
1009
- }
1010
- function syncClavueProviderCredentials(profiles, replaceProfileIds = /* @__PURE__ */ new Set()) {
1011
- const existingCredentials = readClavueCredentialsConfig();
1012
- const providerProfiles = { ...existingCredentials.providerProfiles || {} };
1013
- for (const profileId of replaceProfileIds) {
1014
- delete providerProfiles[profileId];
1015
- }
1016
- for (const profile of profiles) {
1017
- const credential = typeof profile.source.apiKey === "string" ? profile.source.apiKey.trim() : "";
1018
- if (!profile.clavueProfileId || !credential) {
1019
- continue;
1020
- }
1021
- providerProfiles[profile.clavueProfileId] = {
1022
- credential,
1023
- authType: normalizeClavueAuthType(profile.source.authType)
1024
- };
1025
- }
1026
- writeClavueCredentialsConfig({
1027
- ...existingCredentials,
1028
- providerProfiles: Object.keys(providerProfiles).length > 0 ? providerProfiles : void 0
1029
- });
1030
- }
1031
- function getClavueProviderProfiles(config) {
1032
- return Array.isArray(config?.clavueProviderProfiles) ? config.clavueProviderProfiles : [];
1033
- }
1034
- function getLegacyMyclaudeProviderProfiles(config) {
1035
- return Array.isArray(config?.myclaudeProviderProfiles) ? config.myclaudeProviderProfiles : [];
1036
- }
1037
- function toLegacyProviderProfile(profile) {
1038
- const routing = profile.modelRouting || createClavueModelRouting({ id: profile.id, name: profile.name, provider: profile.providerId });
1039
- return {
1040
- id: isCcjkClavueProfile(profile) ? getCcjkExternalProfileId(profile) : profile.id,
1041
- name: profile.name,
1042
- provider: profile.providerId || "custom",
1043
- baseUrl: profile.baseUrl,
1044
- model: routing.primaryModel,
1045
- fastModel: routing.smallFastModel,
1046
- authType: profile.authType,
1047
- primaryModel: routing.primaryModel,
1048
- defaultHaikuModel: routing.smallFastModel,
1049
- defaultSonnetModel: routing.generalModel || routing.subagentModel,
1050
- defaultOpusModel: routing.planModel,
1051
- ...describeMyclaudeProviderProfile({
1052
- authType: profile.authType,
1053
- baseUrl: profile.baseUrl,
1054
- mode: profile.modelMode === "openai_native" ? "openai-native" : profile.modelMode === "hybrid_compatible" ? "ccr-proxy" : "official"
1055
- })
1056
- };
1057
- }
1058
- function normalizeModelSlot(model) {
1059
- return typeof model === "string" && model.trim() ? model.trim() : void 0;
1060
- }
1061
- function resolveClavueModelSelectionSlots(options) {
1062
- if (options.reset) {
1063
- return {};
1064
- }
1065
- const selectedModel = normalizeModelSlot(options.selectedModel);
1066
- if (selectedModel) {
1067
- return {
1068
- primaryModel: selectedModel,
1069
- haikuModel: selectedModel,
1070
- sonnetModel: selectedModel,
1071
- opusModel: selectedModel
1072
- };
1073
- }
1074
- const primaryModel = normalizeModelSlot(options.primaryModel);
1075
- const haikuModel = normalizeModelSlot(options.haikuModel);
1076
- const sonnetModel = normalizeModelSlot(options.sonnetModel);
1077
- const opusModel = normalizeModelSlot(options.opusModel);
1078
- if (primaryModel) {
1079
- return {
1080
- primaryModel,
1081
- haikuModel: haikuModel || primaryModel,
1082
- sonnetModel: sonnetModel || primaryModel,
1083
- opusModel: opusModel || primaryModel
1084
- };
1085
- }
1086
- return {
1087
- haikuModel,
1088
- sonnetModel,
1089
- opusModel
1090
- };
1091
- }
1092
- function getClavueActiveProfile(config) {
1093
- const activeId = config?.clavueActiveProviderProfileId || config?.myclaudeActiveProviderProfileId || "";
1094
- const legacyProfiles = getLegacyMyclaudeProviderProfiles(config);
1095
- const activeLegacyProfile = legacyProfiles.find((profile) => profile.id === activeId);
1096
- if (activeLegacyProfile) {
1097
- return activeLegacyProfile;
1098
- }
1099
- const nativeProfiles = getClavueProviderProfiles(config);
1100
- const activeNativeProfile = nativeProfiles.find((profile) => profile.id === activeId);
1101
- if (activeNativeProfile) {
1102
- return toLegacyProviderProfile(activeNativeProfile);
1103
- }
1104
- return nativeProfiles.map(toLegacyProviderProfile).find((profile) => profile.id === activeId) || null;
1105
- }
1106
- function syncClavueActiveProviderModelSelection(options) {
1107
- const config = readClavueConfig();
1108
- const activeId = config?.clavueActiveProviderProfileId || config?.myclaudeActiveProviderProfileId || "";
1109
- if (!config || !activeId) {
1110
- return false;
1111
- }
1112
- const slots = resolveClavueModelSelectionSlots(options);
1113
- const nativeProfiles = getClavueProviderProfiles(config);
1114
- const nativeProfileIndex = nativeProfiles.findIndex((profile) => profile.id === activeId);
1115
- if (nativeProfileIndex >= 0) {
1116
- const currentProfile = nativeProfiles[nativeProfileIndex];
1117
- const routingProfile = {
1118
- id: currentProfile.id,
1119
- name: currentProfile.name,
1120
- provider: currentProfile.providerId,
1121
- baseUrl: currentProfile.baseUrl,
1122
- authType: currentProfile.authType,
1123
- model: slots.primaryModel,
1124
- fastModel: slots.haikuModel,
1125
- primaryModel: slots.primaryModel,
1126
- defaultHaikuModel: slots.haikuModel,
1127
- defaultSonnetModel: slots.sonnetModel,
1128
- defaultOpusModel: slots.opusModel,
1129
- mode: currentProfile.modelMode === "openai_native" ? "openai-native" : currentProfile.modelMode === "hybrid_compatible" ? "ccr-proxy" : "official"
1130
- };
1131
- const nextProfile = {
1132
- ...currentProfile,
1133
- modelMode: options.reset ? currentProfile.modelMode : inferClavueModelMode(routingProfile),
1134
- modelRouting: createClavueModelRouting(routingProfile),
1135
- updatedAt: Date.now()
1136
- };
1137
- config.clavueProviderProfiles = nativeProfiles.map((profile, index) => index === nativeProfileIndex ? nextProfile : profile);
1138
- delete config.myclaudeProviderProfiles;
1139
- delete config.myclaudeActiveProviderProfileId;
1140
- writeClavueConfig(config);
1141
- syncMyclaudeActiveProfileToSettings(toLegacyProviderProfile(nextProfile));
1142
- return true;
1143
- }
1144
- const legacyProfiles = getLegacyMyclaudeProviderProfiles(config);
1145
- const legacyProfileIndex = legacyProfiles.findIndex((profile) => profile.id === activeId);
1146
- if (legacyProfileIndex < 0) {
1147
- return false;
1148
- }
1149
- const updatedProfiles = legacyProfiles.map((profile, index) => {
1150
- if (index !== legacyProfileIndex) {
1151
- return profile;
1152
- }
1153
- return {
1154
- ...profile,
1155
- model: slots.primaryModel,
1156
- fastModel: slots.haikuModel,
1157
- primaryModel: slots.primaryModel,
1158
- defaultHaikuModel: slots.haikuModel,
1159
- defaultSonnetModel: slots.sonnetModel,
1160
- defaultOpusModel: slots.opusModel
1161
- };
1162
- });
1163
- setMyclaudeProviderProfiles(updatedProfiles, activeId);
1164
- return true;
1165
- }
1166
- function setMyclaudeProviderProfiles(profiles, activeProfileId) {
1167
- const config = readClavueConfig() || { mcpServers: {} };
1168
- const normalizedProfiles = profiles.map(normalizeMyclaudeProviderProfile);
1169
- const existingProfiles = getClavueProviderProfiles(config);
1170
- const resolvedProfiles = resolveClavueProviderProfiles(normalizedProfiles, existingProfiles);
1171
- const selectedProfile = findResolvedClavueProfile(
1172
- resolvedProfiles,
1173
- activeProfileId ?? (normalizedProfiles[0] ? getSourceProfileId(normalizedProfiles[0]) : void 0)
1174
- );
1175
- const nextActiveProfileId = selectedProfile?.clavueProfileId;
1176
- const existingCcjkProfileIds = new Set(existingProfiles.filter(isCcjkClavueProfile).map((profile) => profile.id));
1177
- const preservedProfiles = existingProfiles.filter((profile) => !isCcjkClavueProfile(profile));
1178
- const preservedProfileIds = new Set(preservedProfiles.map((profile) => profile.id));
1179
- const replacedCredentialIds = new Set([...existingCcjkProfileIds].filter((profileId) => !preservedProfileIds.has(profileId)));
1180
- const clavueProfiles = resolvedProfiles.map((profile) => toClavueProviderProfile(
1181
- profile.source,
1182
- profile.clavueProfileId,
1183
- profile.existing
1184
- ));
1185
- config.clavueProviderProfiles = [...preservedProfiles, ...clavueProfiles];
1186
- if (nextActiveProfileId) {
1187
- config.clavueActiveProviderProfileId = nextActiveProfileId;
1188
- } else {
1189
- delete config.clavueActiveProviderProfileId;
1190
- }
1191
- delete config.myclaudeProviderProfiles;
1192
- delete config.myclaudeActiveProviderProfileId;
1193
- writeClavueConfig(config);
1194
- syncClavueProviderCredentials(resolvedProfiles, replacedCredentialIds);
1195
- const activeProfile = selectedProfile?.source || null;
1196
- syncMyclaudeActiveProfileToSettings(activeProfile);
1197
- return nextActiveProfileId;
1198
- }
1199
- function setMyclaudeActiveProviderProfile(activeProfileId) {
1200
- const config = readClavueConfig() || { mcpServers: {} };
1201
- const nextActiveProfileId = resolveClavueActiveProviderProfileId(config, activeProfileId);
1202
- if (nextActiveProfileId) {
1203
- config.clavueActiveProviderProfileId = nextActiveProfileId;
1204
- } else {
1205
- delete config.clavueActiveProviderProfileId;
1206
- }
1207
- delete config.myclaudeActiveProviderProfileId;
1208
- writeClavueConfig(config);
1209
- syncMyclaudeActiveProfileToSettings(getClavueActiveProfile(config));
1210
- }
1211
- function detectMyclaudeProviderMode(profile) {
1212
- if (profile.authType === "ccr_proxy") {
1213
- return "ccr-proxy";
1214
- }
1215
- if (profile.baseUrl) {
1216
- return "openai-native";
1217
- }
1218
- return "official";
1219
- }
1220
- function describeMyclaudeProviderProfile(profile) {
1221
- const mode = profile.mode || detectMyclaudeProviderMode({
1222
- authType: profile.authType,
1223
- baseUrl: profile.baseUrl
1224
- });
1225
- return { mode };
1226
- }
1227
- function buildMyclaudeProviderPresentation(profile) {
1228
- const mode = profile.mode || detectMyclaudeProviderMode({
1229
- authType: profile.authType,
1230
- baseUrl: profile.baseUrl
1231
- });
1232
- const hasAdaptiveRouting = Boolean(profile.defaultHaikuModel || profile.defaultSonnetModel || profile.defaultOpusModel);
1233
- const hasPrimaryModel = Boolean(profile.primaryModel || profile.model);
1234
- const modeLabel = mode === "ccr-proxy" ? "CCR-proxy" : mode === "openai-native" ? "OpenAI-native" : "Anthropic-native";
1235
- const routeLabel = mode === "ccr-proxy" ? profile.baseUrl ? `Claude-family route through CCR \xB7 ${profile.baseUrl}` : "Claude-family route through CCR" : mode === "openai-native" ? profile.baseUrl ? `OpenAI-family route through a compatible gateway \xB7 ${profile.baseUrl}` : "OpenAI-family route through a compatible gateway" : "Official Anthropic route";
1236
- const strategyLabel = hasAdaptiveRouting ? "Custom routing \xB7 Advanced custom routing. Validate carefully when mixing model families." : hasPrimaryModel ? "Single-model override \xB7 Primary model is pinned for the active profile." : "Native runtime default \xB7 Runtime follows the official provider defaults.";
1237
- return {
1238
- modeLabel,
1239
- sourceLabel: "Imported from ccjk \xB7 Reusable profile imported from the compatible ccjk configuration.",
1240
- routeLabel,
1241
- strategyLabel
1242
- };
1243
- }
1244
- function toMyclaudeProviderProfile(profile, existing) {
1245
- return {
1246
- id: profile.id || existing?.id || profile.name,
1247
- name: profile.name,
1248
- provider: profile.provider || existing?.provider || "custom",
1249
- apiKey: profile.apiKey,
1250
- baseUrl: profile.baseUrl,
1251
- model: profile.primaryModel,
1252
- fastModel: profile.defaultHaikuModel,
1253
- authType: profile.authType,
1254
- primaryModel: profile.primaryModel,
1255
- defaultHaikuModel: profile.defaultHaikuModel,
1256
- defaultSonnetModel: profile.defaultSonnetModel,
1257
- defaultOpusModel: profile.defaultOpusModel,
1258
- ...describeMyclaudeProviderProfile({
1259
- authType: profile.authType,
1260
- baseUrl: profile.baseUrl,
1261
- mode: existing?.mode
1262
- })
1263
- };
1264
- }
1265
- function syncMyclaudeActiveProfileToSettings(profile) {
1266
- const settings = readJsonConfig(CLAVUE_SETTINGS_FILE) || {};
1267
- settings.env = settings.env || {};
1268
- clearLegacyTopLevelRuntimeSettings(settings);
1269
- delete settings.env.ANTHROPIC_API_KEY;
1270
- delete settings.env.ANTHROPIC_AUTH_TOKEN;
1271
- if (profile?.baseUrl) {
1272
- settings.env.ANTHROPIC_BASE_URL = normalizeClavueBaseUrl(profile.baseUrl);
1273
- } else {
1274
- delete settings.env.ANTHROPIC_BASE_URL;
1275
- }
1276
- overwriteModelSettings(settings, {
1277
- primaryModel: typeof profile?.primaryModel === "string" ? profile.primaryModel : typeof profile?.model === "string" ? profile.model : void 0,
1278
- haikuModel: typeof profile?.defaultHaikuModel === "string" ? profile.defaultHaikuModel : typeof profile?.fastModel === "string" ? profile.fastModel : void 0,
1279
- sonnetModel: typeof profile?.defaultSonnetModel === "string" ? profile.defaultSonnetModel : void 0,
1280
- opusModel: typeof profile?.defaultOpusModel === "string" ? profile.defaultOpusModel : void 0
1281
- }, profile ? "override" : "reset");
1282
- const primaryModel = typeof profile?.primaryModel === "string" ? profile.primaryModel.trim() : typeof profile?.model === "string" ? profile.model.trim() : "";
1283
- const subagentModel = typeof profile?.defaultSonnetModel === "string" ? profile.defaultSonnetModel.trim() : "";
1284
- const hasAdaptiveRouting = Boolean(
1285
- typeof profile?.defaultHaikuModel === "string" && profile.defaultHaikuModel.trim() || typeof profile?.defaultSonnetModel === "string" && profile.defaultSonnetModel.trim() || typeof profile?.defaultOpusModel === "string" && profile.defaultOpusModel.trim()
1286
- );
1287
- if (primaryModel && !hasAdaptiveRouting) {
1288
- settings.env.ANTHROPIC_MODEL = primaryModel;
1289
- settings.env.ANTHROPIC_CUSTOM_MODEL_OPTION = primaryModel;
1290
- settings.model = primaryModel;
1291
- } else if (primaryModel) {
1292
- settings.env.ANTHROPIC_CUSTOM_MODEL_OPTION = primaryModel;
1293
- delete settings.env.ANTHROPIC_MODEL;
1294
- delete settings.model;
1295
- } else if (profile) {
1296
- delete settings.env.ANTHROPIC_MODEL;
1297
- delete settings.env.ANTHROPIC_CUSTOM_MODEL_OPTION;
1298
- delete settings.model;
1299
- } else {
1300
- delete settings.env.ANTHROPIC_CUSTOM_MODEL_OPTION;
1301
- delete settings.model;
1302
- }
1303
- if (subagentModel) {
1304
- settings.env.CLAUDE_CODE_SUBAGENT_MODEL = subagentModel;
1305
- } else {
1306
- delete settings.env.CLAUDE_CODE_SUBAGENT_MODEL;
1307
- }
1308
- applyAutoOutputStyle(settings, profile);
1309
- normalizeClaudeFamilySettings(settings);
1310
- writeJsonConfig(CLAVUE_SETTINGS_FILE, settings);
1311
- }
1312
- function applyAutoOutputStyle(settings, profile) {
1313
- const ccjkMeta = settings.__ccjk && typeof settings.__ccjk === "object" ? settings.__ccjk : {};
1314
- const isCcjkManaged = ccjkMeta.autoOutputStyle === true;
1315
- const currentStyle = typeof settings.outputStyle === "string" ? settings.outputStyle : "";
1316
- if (currentStyle && !isCcjkManaged) {
1317
- return;
1318
- }
1319
- const desired = pickAutoOutputStyle(profile);
1320
- if (desired) {
1321
- ensureOutputStyleTemplate(desired);
1322
- settings.outputStyle = desired;
1323
- settings.__ccjk = { ...ccjkMeta, autoOutputStyle: true };
1324
- } else if (isCcjkManaged) {
1325
- delete settings.outputStyle;
1326
- const { autoOutputStyle: _drop, ...restMeta } = ccjkMeta;
1327
- if (Object.keys(restMeta).length === 0) {
1328
- delete settings.__ccjk;
1329
- } else {
1330
- settings.__ccjk = restMeta;
1331
- }
1332
- }
1333
- }
1334
- function pickAutoOutputStyle(profile) {
1335
- if (!profile) {
1336
- return null;
1337
- }
1338
- const candidates = [
1339
- profile.primaryModel,
1340
- profile.model,
1341
- profile.defaultSonnetModel,
1342
- profile.defaultOpusModel,
1343
- profile.defaultHaikuModel
1344
- ].filter((m) => typeof m === "string" && m.trim().length > 0);
1345
- if (candidates.length === 0) {
1346
- return null;
1347
- }
1348
- const isCodexFamily = candidates.some((m) => /^(?:gpt-5|codex|gpt-6)/i.test(m.trim()));
1349
- return isCodexFamily ? "codex-rigor-mode" : null;
1350
- }
1351
- function ensureOutputStyleTemplate(styleId) {
1352
- try {
1353
- const targetDir = join(CLAVUE_DIR, "output-styles");
1354
- const targetFile = join(targetDir, `${styleId}.md`);
1355
- if (exists(targetFile)) {
1356
- return;
1357
- }
1358
- const currentFilePath = fileURLToPath(import.meta.url);
1359
- const distDir = dirname(dirname(currentFilePath));
1360
- const rootDir = dirname(distDir);
1361
- const candidates = [
1362
- join(rootDir, "templates", "common", "output-styles", "zh-CN", `${styleId}.md`),
1363
- join(rootDir, "templates", "common", "output-styles", "en", `${styleId}.md`)
1364
- ];
1365
- const sourcePath = candidates.find(exists);
1366
- if (!sourcePath) {
1367
- return;
1368
- }
1369
- ensureDir(targetDir);
1370
- copyFile(sourcePath, targetFile);
1371
- } catch {
1372
- }
1373
- }
1374
- function syncMyclaudeProviderProfilesFromClaudeConfig(configData) {
1375
- if (!configData) {
1376
- clearMyclaudeProviderProfiles();
1377
- return {
1378
- activeProfileId: "",
1379
- activeProfile: null,
1380
- profiles: []
1381
- };
1382
- }
1383
- const existingConfig = readClavueConfig();
1384
- const existingProfiles = getLegacyMyclaudeProviderProfiles(existingConfig).length > 0 ? getLegacyMyclaudeProviderProfiles(existingConfig) : getClavueProviderProfiles(existingConfig).map(toLegacyProviderProfile);
1385
- const existingById = new Map(existingProfiles.map((profile) => [String(profile.id), profile]));
1386
- const profiles = Object.entries(configData.profiles).map(([id, profile]) => toMyclaudeProviderProfile({ ...profile, id }, existingById.get(id)));
1387
- const activeProfileId = configData.currentProfileId ?? "";
1388
- const activeProfile = profiles.find((profile) => profile.id === activeProfileId) || null;
1389
- const activeClavueProfileId = setMyclaudeProviderProfiles(profiles, activeProfileId);
1390
- return {
1391
- activeProfileId: activeClavueProfileId || "",
1392
- activeProfile,
1393
- profiles
1394
- };
1395
- }
1396
- function syncMyclaudeProviderProfilesFromCurrentClaudeConfig() {
1397
- const configData = ClaudeCodeConfigManager.readConfig();
1398
- return syncMyclaudeProviderProfilesFromClaudeConfig(configData);
1399
- }
1400
- function clearMyclaudeProviderProfiles() {
1401
- const config = readClavueConfig();
1402
- let preservedActiveProfile = null;
1403
- if (config) {
1404
- const existingProfiles = getClavueProviderProfiles(config);
1405
- const removedIds = /* @__PURE__ */ new Set([
1406
- ...existingProfiles.filter(isCcjkClavueProfile).map((profile) => profile.id),
1407
- ...getLegacyMyclaudeProviderProfiles(config).map((profile) => profile.id)
1408
- ]);
1409
- const preservedProfiles = existingProfiles.filter((profile) => !removedIds.has(profile.id));
1410
- const currentActiveId = config.clavueActiveProviderProfileId || config.myclaudeActiveProviderProfileId;
1411
- const nextActiveId = preservedProfiles.some((profile) => profile.id === currentActiveId) ? currentActiveId : preservedProfiles[0]?.id;
1412
- if (preservedProfiles.length > 0) {
1413
- config.clavueProviderProfiles = preservedProfiles;
1414
- config.clavueActiveProviderProfileId = nextActiveId;
1415
- preservedActiveProfile = preservedProfiles.find((profile) => profile.id === nextActiveId) ? toLegacyProviderProfile(preservedProfiles.find((profile) => profile.id === nextActiveId)) : null;
1416
- } else {
1417
- delete config.clavueProviderProfiles;
1418
- delete config.clavueActiveProviderProfileId;
1419
- }
1420
- delete config.myclaudeProviderProfiles;
1421
- delete config.myclaudeActiveProviderProfileId;
1422
- writeClavueConfig(config);
1423
- if (removedIds.size > 0) {
1424
- const credentials = readClavueCredentialsConfig();
1425
- if (credentials.providerProfiles) {
1426
- const nextProviderProfiles = { ...credentials.providerProfiles };
1427
- for (const profileId of removedIds) {
1428
- delete nextProviderProfiles[profileId];
1429
- }
1430
- writeClavueCredentialsConfig({
1431
- ...credentials,
1432
- providerProfiles: Object.keys(nextProviderProfiles).length > 0 ? nextProviderProfiles : void 0
1433
- });
1434
- }
1435
- }
1436
- }
1437
- syncMyclaudeActiveProfileToSettings(preservedActiveProfile);
1438
- }
1439
-
1440
- const clavueConfig = {
1441
- __proto__: null,
1442
- buildMyclaudeProviderPresentation: buildMyclaudeProviderPresentation,
1443
- clearMyclaudeProviderProfiles: clearMyclaudeProviderProfiles,
1444
- describeMyclaudeProviderProfile: describeMyclaudeProviderProfile,
1445
- readClavueConfig: readClavueConfig,
1446
- setMyclaudeActiveProviderProfile: setMyclaudeActiveProviderProfile,
1447
- setMyclaudeProviderProfiles: setMyclaudeProviderProfiles,
1448
- syncClavueActiveProviderModelSelection: syncClavueActiveProviderModelSelection,
1449
- syncMyclaudeProviderProfilesFromClaudeConfig: syncMyclaudeProviderProfilesFromClaudeConfig,
1450
- syncMyclaudeProviderProfilesFromCurrentClaudeConfig: syncMyclaudeProviderProfilesFromCurrentClaudeConfig,
1451
- writeClavueConfig: writeClavueConfig
1452
- };
1453
-
1454
- export { ClaudeCodeConfigManager as C, setMyclaudeActiveProviderProfile as a, syncMyclaudeProviderProfilesFromClaudeConfig as b, setMyclaudeProviderProfiles as c, clearMyclaudeProviderProfiles as d, buildMyclaudeProviderPresentation as e, claudeCodeConfigManager as f, clavueConfig as g, syncClavueActiveProviderModelSelection as s };