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,2141 +0,0 @@
1
- import { readdirSync } from 'node:fs';
2
- import process__default from 'node:process';
3
- import { fileURLToPath } from 'node:url';
4
- import a from './index5.mjs';
5
- import { d as dayjs } from '../shared/ccjk.RyizuzOI.mjs';
6
- import { i as inquirer } from './index6.mjs';
7
- import ora from './index8.mjs';
8
- import { a as semver } from '../shared/ccjk.CxpGa6MC.mjs';
9
- import { p as parse } from '../shared/ccjk.BBtCGd_g.mjs';
10
- import { x as K } from './main.mjs';
11
- import { CODEX_CONFIG_FILE, CODEX_AUTH_FILE, CODEX_DIR, SUPPORTED_LANGS, CODEX_AGENTS_FILE, CODEX_PROMPTS_DIR, ZCF_CONFIG_FILE, AI_OUTPUT_LANGUAGES } from './constants.mjs';
12
- import { ensureI18nInitialized, i18n, format } from './index2.mjs';
13
- import { updateZcfConfig, readZcfConfig, readDefaultTomlConfig, updateTomlConfig } from './ccjk-config.mjs';
14
- import { i as applyAiLanguageDirective } from './config.mjs';
15
- import { exists, readFile, ensureDir, writeFileAtomic, writeFile, copyDir, copyFile } from './fs-operations.mjs';
16
- import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
17
- import { i as isWindows, m as getMcpCommand, g as getSystemRoot, w as wrapCommandWithSudo, n as normalizeTomlPath } from './platform.mjs';
18
- import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
19
- import { resolveAiOutputLanguage } from './prompts.mjs';
20
- import { p as promptBoolean } from '../shared/ccjk.DZ2LLOa-.mjs';
21
- import { M as MCP_SERVICE_CONFIGS, j as isMcpServiceCompatible, g as getMcpServices, k as getMcpServicesWithCompatibility } from './claude-config.mjs';
22
- import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
23
-
24
- function detectConfigManagementMode() {
25
- try {
26
- const config = readCodexConfig();
27
- if (!config || !config.providers || config.providers.length === 0) {
28
- return {
29
- mode: "initial",
30
- hasProviders: false,
31
- providerCount: 0
32
- };
33
- }
34
- return {
35
- mode: "management",
36
- hasProviders: true,
37
- providerCount: config.providers.length,
38
- currentProvider: config.modelProvider,
39
- providers: config.providers,
40
- isUnmanaged: config.managed === false ? true : void 0
41
- };
42
- } catch (error) {
43
- return {
44
- mode: "initial",
45
- hasProviders: false,
46
- providerCount: 0,
47
- error: error instanceof Error ? error.message : "Unknown error"
48
- };
49
- }
50
- }
51
-
52
- function applyCodexPlatformCommand(config) {
53
- if (isWindows() && config.command) {
54
- const mcpCmd = getMcpCommand(config.command);
55
- if (mcpCmd[0] === "cmd") {
56
- config.command = mcpCmd[0];
57
- config.args = [...mcpCmd.slice(1), ...config.args || []];
58
- }
59
- }
60
- }
61
-
62
- const CODEX_RECOMMENDED_MCP_SERVICE_IDS = ["context7", "open-websearch", "mcp-deepwiki", "serena"];
63
- const CODEX_MANAGED_MCP_SERVICE_IDS = new Set(MCP_SERVICE_CONFIGS.map((service) => service.id.toLowerCase()));
64
- function getRecommendedCodexMcpServiceIds() {
65
- return CODEX_RECOMMENDED_MCP_SERVICE_IDS.filter((id) => {
66
- const config = MCP_SERVICE_CONFIGS.find((service) => service.id === id);
67
- if (!config) {
68
- return false;
69
- }
70
- return isMcpServiceCompatible(id).compatible;
71
- });
72
- }
73
- function reconcileCodexMcpServices(existingServices, selectedServices) {
74
- const preservedServices = existingServices.filter((service) => !CODEX_MANAGED_MCP_SERVICE_IDS.has(service.id.toLowerCase()));
75
- return [...preservedServices, ...selectedServices];
76
- }
77
- function applyWindowsEnvToCodexMcpServices(services) {
78
- return services.map((svc) => {
79
- if (isWindows()) {
80
- const systemRoot = getSystemRoot();
81
- if (systemRoot) {
82
- return {
83
- ...svc,
84
- env: {
85
- ...svc.env || {},
86
- SYSTEMROOT: systemRoot
87
- }
88
- };
89
- }
90
- }
91
- return svc;
92
- });
93
- }
94
- async function selectCodexMcpServices(existingServiceIds) {
95
- ensureI18nInitialized();
96
- const services = await getMcpServicesWithCompatibility();
97
- const recommendedIds = new Set(getRecommendedCodexMcpServiceIds());
98
- const currentIds = new Set(existingServiceIds.map((id) => id.toLowerCase()));
99
- const useCurrentSelection = currentIds.size > 0;
100
- const choices = addNumbersToChoices(services.map((service) => ({
101
- name: `${service.name} - ${a.gray(service.description)}`,
102
- value: service.id,
103
- checked: useCurrentSelection ? currentIds.has(service.id.toLowerCase()) : recommendedIds.has(service.id),
104
- disabled: service.compatible ? false : service.incompatibleReason || true
105
- })));
106
- const { services: selectedIds } = await inquirer.prompt({
107
- type: "checkbox",
108
- name: "services",
109
- message: `${i18n.t("mcp:selectMcpServices")}${i18n.t("common:multiSelectHint")}`,
110
- choices
111
- });
112
- if (selectedIds === void 0) {
113
- console.log(a.yellow(i18n.t("common:cancelled")));
114
- return void 0;
115
- }
116
- return selectedIds;
117
- }
118
- async function configureCodexMcp(options) {
119
- ensureI18nInitialized();
120
- const { skipPrompt = false } = options ?? {};
121
- const existingConfig = readCodexConfig();
122
- const backupPath = backupCodexComplete();
123
- if (backupPath)
124
- console.log(a.gray(getBackupMessage(backupPath)));
125
- if (skipPrompt) {
126
- const { runCodexWorkflowSelection } = await Promise.resolve().then(function () { return codex; });
127
- await runCodexWorkflowSelection({ skipPrompt: true, workflows: options?.workflows ?? [] });
128
- if (options?.mcpServices === false) {
129
- updateZcfConfig({ codeToolType: "codex" });
130
- console.log(a.green(i18n.t("codex:mcpConfigured")));
131
- return;
132
- }
133
- const defaultServiceIds = Array.isArray(options?.mcpServices) ? options.mcpServices : getRecommendedCodexMcpServiceIds();
134
- const baseProviders2 = existingConfig?.providers || [];
135
- const existingServices2 = existingConfig?.mcpServices || [];
136
- const selection2 = [];
137
- for (const id of defaultServiceIds) {
138
- const configInfo = MCP_SERVICE_CONFIGS.find((service) => service.id === id);
139
- if (!configInfo)
140
- continue;
141
- if (!isMcpServiceCompatible(id).compatible)
142
- continue;
143
- let command = configInfo.config.command || id;
144
- let args = (configInfo.config.args || []).map((arg) => String(arg));
145
- if (id === "serena") {
146
- const idx = args.indexOf("--context");
147
- if (idx >= 0 && idx + 1 < args.length)
148
- args[idx + 1] = "codex";
149
- else
150
- args.push("--context", "codex");
151
- }
152
- const serviceConfig = { id: id.toLowerCase(), command, args };
153
- applyCodexPlatformCommand(serviceConfig);
154
- command = serviceConfig.command;
155
- args = serviceConfig.args || [];
156
- const env = { ...configInfo.config.env || {} };
157
- if (isWindows()) {
158
- const systemRoot = getSystemRoot();
159
- if (systemRoot)
160
- env.SYSTEMROOT = systemRoot;
161
- }
162
- selection2.push({
163
- id: id.toLowerCase(),
164
- command,
165
- args,
166
- env: Object.keys(env).length > 0 ? env : void 0,
167
- startup_timeout_sec: 30
168
- });
169
- }
170
- const finalServices2 = applyWindowsEnvToCodexMcpServices(reconcileCodexMcpServices(existingServices2, selection2));
171
- writeCodexConfig({
172
- model: existingConfig?.model || null,
173
- modelProvider: existingConfig?.modelProvider || null,
174
- providers: baseProviders2,
175
- mcpServices: finalServices2,
176
- features: existingConfig?.features,
177
- otherConfig: existingConfig?.otherConfig || []
178
- });
179
- updateZcfConfig({ codeToolType: "codex" });
180
- console.log(a.green(i18n.t("codex:mcpConfigured")));
181
- return;
182
- }
183
- const selectedIds = await selectCodexMcpServices(existingConfig?.mcpServices?.map((service) => service.id) || []);
184
- if (!selectedIds)
185
- return;
186
- const servicesMeta = await getMcpServices();
187
- const baseProviders = existingConfig?.providers || [];
188
- const selection = [];
189
- const existingServices = existingConfig?.mcpServices || [];
190
- if (selectedIds.length === 0) {
191
- console.log(a.yellow(i18n.t("codex:noMcpConfigured")));
192
- const preserved = applyWindowsEnvToCodexMcpServices(reconcileCodexMcpServices(existingServices, []));
193
- writeCodexConfig({
194
- model: existingConfig?.model || null,
195
- modelProvider: existingConfig?.modelProvider || null,
196
- providers: baseProviders,
197
- mcpServices: preserved,
198
- features: existingConfig?.features,
199
- otherConfig: existingConfig?.otherConfig || []
200
- });
201
- updateZcfConfig({ codeToolType: "codex" });
202
- return;
203
- }
204
- for (const id of selectedIds) {
205
- const configInfo = MCP_SERVICE_CONFIGS.find((service) => service.id === id);
206
- if (!configInfo)
207
- continue;
208
- const serviceMeta = servicesMeta.find((service) => service.id === id);
209
- let command = configInfo.config.command || id;
210
- let args = (configInfo.config.args || []).map((arg) => String(arg));
211
- if (id === "serena") {
212
- const idx = args.indexOf("--context");
213
- if (idx >= 0 && idx + 1 < args.length) {
214
- args[idx + 1] = "codex";
215
- } else {
216
- args.push("--context", "codex");
217
- }
218
- }
219
- const serviceConfig = { id: id.toLowerCase(), command, args };
220
- applyCodexPlatformCommand(serviceConfig);
221
- command = serviceConfig.command;
222
- args = serviceConfig.args || [];
223
- const env = { ...configInfo.config.env || {} };
224
- if (isWindows()) {
225
- const systemRoot = getSystemRoot();
226
- if (systemRoot)
227
- env.SYSTEMROOT = systemRoot;
228
- }
229
- if (configInfo.requiresApiKey && configInfo.apiKeyEnvVar) {
230
- const promptMessage = serviceMeta?.apiKeyPrompt || i18n.t("mcp:apiKeyPrompt");
231
- const { apiKey } = await inquirer.prompt([{
232
- type: "input",
233
- name: "apiKey",
234
- message: promptMessage,
235
- validate: (input) => !!input || i18n.t("api:keyRequired")
236
- }]);
237
- if (!apiKey)
238
- continue;
239
- env[configInfo.apiKeyEnvVar] = apiKey;
240
- }
241
- selection.push({
242
- id: id.toLowerCase(),
243
- command: serviceConfig.command,
244
- args: serviceConfig.args,
245
- env: Object.keys(env).length > 0 ? env : void 0,
246
- startup_timeout_sec: 30
247
- });
248
- }
249
- const finalServices = applyWindowsEnvToCodexMcpServices(reconcileCodexMcpServices(existingServices, selection));
250
- writeCodexConfig({
251
- model: existingConfig?.model || null,
252
- modelProvider: existingConfig?.modelProvider || null,
253
- providers: baseProviders,
254
- mcpServices: finalServices,
255
- features: existingConfig?.features,
256
- otherConfig: existingConfig?.otherConfig || []
257
- });
258
- updateZcfConfig({ codeToolType: "codex" });
259
- console.log(a.green(i18n.t("codex:mcpConfigured")));
260
- }
261
-
262
- let cachedSkipPromptBackup = null;
263
- function getRootDir() {
264
- const currentFilePath = fileURLToPath(import.meta.url);
265
- let dir = dirname(currentFilePath);
266
- while (dir !== dirname(dir)) {
267
- if (exists(join(dir, "templates"))) {
268
- return dir;
269
- }
270
- dir = dirname(dir);
271
- }
272
- return dirname(currentFilePath);
273
- }
274
- async function detectCodexInstallMethod() {
275
- try {
276
- const brewResult = await K("brew", ["list", "--cask", "codex"], { throwOnError: false });
277
- if (brewResult.exitCode === 0) {
278
- return "homebrew";
279
- }
280
- } catch {
281
- }
282
- try {
283
- const npmResult = await K("npm", ["list", "-g", "@openai/codex"], { throwOnError: false });
284
- if (npmResult.exitCode === 0 && npmResult.stdout.includes("@openai/codex")) {
285
- return "npm";
286
- }
287
- } catch {
288
- }
289
- return "unknown";
290
- }
291
- async function executeCodexInstallation(isUpdate, skipMethodSelection = false) {
292
- if (isUpdate) {
293
- console.log(a.green(i18n.t("codex:updatingCli")));
294
- const installMethod = await detectCodexInstallMethod();
295
- if (installMethod === "homebrew") {
296
- console.log(a.gray(i18n.t("codex:detectedHomebrew")));
297
- const result = await K("brew", ["upgrade", "--cask", "codex"]);
298
- if (result.exitCode !== 0) {
299
- throw new Error(`Failed to update codex via Homebrew: exit code ${result.exitCode}`);
300
- }
301
- } else if (installMethod === "npm") {
302
- console.log(a.gray(i18n.t("codex:detectedNpm")));
303
- const { command, args, usedSudo } = wrapCommandWithSudo("npm", ["install", "-g", "@openai/codex@latest"]);
304
- if (usedSudo)
305
- console.log(a.yellow(i18n.t("codex:usingSudo")));
306
- const result = await K(command, args);
307
- if (result.exitCode !== 0) {
308
- throw new Error(`Failed to update codex CLI: exit code ${result.exitCode}`);
309
- }
310
- } else {
311
- console.log(a.yellow(i18n.t("codex:unknownInstallMethod")));
312
- console.log(a.gray(i18n.t("codex:fallingBackToNpm")));
313
- const { command, args, usedSudo } = wrapCommandWithSudo("npm", ["install", "-g", "@openai/codex@latest"]);
314
- if (usedSudo)
315
- console.log(a.yellow(i18n.t("codex:usingSudo")));
316
- const result = await K(command, args);
317
- if (result.exitCode !== 0) {
318
- throw new Error(`Failed to update codex CLI: exit code ${result.exitCode}`);
319
- }
320
- }
321
- console.log(a.green(i18n.t("codex:updateSuccess")));
322
- } else {
323
- const { installCodex } = await import('./installer.mjs');
324
- await installCodex(skipMethodSelection);
325
- }
326
- }
327
- function getUninstallOptions() {
328
- return [
329
- { name: i18n.t("codex:uninstallItemConfig"), value: "config" },
330
- { name: i18n.t("codex:uninstallItemAuth"), value: "auth" },
331
- { name: i18n.t("codex:uninstallItemApiConfig"), value: "api-config" },
332
- { name: i18n.t("codex:uninstallItemMcpConfig"), value: "mcp-config" },
333
- { name: i18n.t("codex:uninstallItemSystemPrompt"), value: "system-prompt" },
334
- { name: i18n.t("codex:uninstallItemWorkflow"), value: "workflow" },
335
- { name: i18n.t("codex:uninstallItemCliPackage"), value: "cli-package" },
336
- { name: i18n.t("codex:uninstallItemBackups"), value: "backups" }
337
- ];
338
- }
339
- function handleUninstallCancellation() {
340
- console.log(a.yellow(i18n.t("codex:uninstallCancelled")));
341
- }
342
- function createBackupDirectory(timestamp) {
343
- const backupBaseDir = join(CODEX_DIR, "backup");
344
- const backupDir = join(backupBaseDir, `backup_${timestamp}`);
345
- ensureDir(backupDir);
346
- return backupDir;
347
- }
348
- function backupCodexFiles() {
349
- if (!exists(CODEX_DIR))
350
- return null;
351
- if (process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP === "true" && cachedSkipPromptBackup)
352
- return cachedSkipPromptBackup;
353
- const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
354
- const backupDir = createBackupDirectory(timestamp);
355
- const filter = (path) => {
356
- return !path.includes("/backup");
357
- };
358
- copyDir(CODEX_DIR, backupDir, { filter });
359
- if (process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP === "true")
360
- cachedSkipPromptBackup = backupDir;
361
- return backupDir;
362
- }
363
- function backupCodexComplete() {
364
- return backupCodexFiles();
365
- }
366
- function backupCodexConfig() {
367
- if (!exists(CODEX_CONFIG_FILE))
368
- return null;
369
- try {
370
- const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
371
- const backupDir = createBackupDirectory(timestamp);
372
- const backupPath = join(backupDir, "config.toml");
373
- copyFile(CODEX_CONFIG_FILE, backupPath);
374
- return backupPath;
375
- } catch {
376
- return null;
377
- }
378
- }
379
- function backupCodexAgents() {
380
- if (process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP === "true" && cachedSkipPromptBackup)
381
- return cachedSkipPromptBackup;
382
- if (!exists(CODEX_AGENTS_FILE))
383
- return null;
384
- try {
385
- const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
386
- const backupDir = createBackupDirectory(timestamp);
387
- const backupPath = join(backupDir, "AGENTS.md");
388
- copyFile(CODEX_AGENTS_FILE, backupPath);
389
- return backupPath;
390
- } catch {
391
- return null;
392
- }
393
- }
394
- function backupCodexPrompts() {
395
- if (process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP === "true" && cachedSkipPromptBackup)
396
- return cachedSkipPromptBackup;
397
- if (!exists(CODEX_PROMPTS_DIR))
398
- return null;
399
- try {
400
- const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
401
- const backupDir = createBackupDirectory(timestamp);
402
- const backupPath = join(backupDir, "prompts");
403
- copyDir(CODEX_PROMPTS_DIR, backupPath);
404
- return backupPath;
405
- } catch {
406
- return null;
407
- }
408
- }
409
- function getBackupMessage(path) {
410
- if (!path)
411
- return "";
412
- if (!i18n.isInitialized) {
413
- return `Backup created: ${path}`;
414
- }
415
- return i18n.t("codex:backupSuccess", { path });
416
- }
417
- function needsEnvKeyMigration() {
418
- if (!exists(CODEX_CONFIG_FILE))
419
- return false;
420
- try {
421
- const content = readFile(CODEX_CONFIG_FILE);
422
- const hasOldEnvKey = /^\s*env_key\s*=/m.test(content);
423
- return hasOldEnvKey;
424
- } catch {
425
- return false;
426
- }
427
- }
428
- function migrateEnvKeyToTempEnvKey() {
429
- if (!exists(CODEX_CONFIG_FILE))
430
- return false;
431
- try {
432
- const content = readFile(CODEX_CONFIG_FILE);
433
- if (!needsEnvKeyMigration())
434
- return false;
435
- const backupPath = backupCodexConfig();
436
- if (backupPath) {
437
- console.log(a.gray(getBackupMessage(backupPath)));
438
- }
439
- const migratedContent = migrateEnvKeyInContent(content);
440
- writeFileAtomic(CODEX_CONFIG_FILE, migratedContent);
441
- updateTomlConfig(ZCF_CONFIG_FILE, {
442
- codex: {
443
- envKeyMigrated: true
444
- }
445
- });
446
- const message = i18n.isInitialized ? i18n.t("codex:envKeyMigrationComplete") : "\u2714 env_key to temp_env_key migration completed";
447
- console.log(a.green(message));
448
- return true;
449
- } catch (error) {
450
- console.error(a.yellow(`env_key migration warning: ${error.message}`));
451
- return false;
452
- }
453
- }
454
- function migrateEnvKeyInContent(content) {
455
- const lines = content.split("\n");
456
- const result = [];
457
- let currentSectionHasTempEnvKey = false;
458
- let currentSection = "";
459
- const sectionHasTempEnvKey = /* @__PURE__ */ new Map();
460
- let tempSection = "";
461
- for (const line of lines) {
462
- const sectionMatch = line.match(/^\s*\[([^\]]+)\]/);
463
- if (sectionMatch) {
464
- tempSection = sectionMatch[1];
465
- }
466
- if (tempSection && /^\s*temp_env_key\s*=/.test(line)) {
467
- sectionHasTempEnvKey.set(tempSection, true);
468
- }
469
- }
470
- for (const line of lines) {
471
- const sectionMatch = line.match(/^\s*\[([^\]]+)\]/);
472
- if (sectionMatch) {
473
- currentSection = sectionMatch[1];
474
- currentSectionHasTempEnvKey = sectionHasTempEnvKey.get(currentSection) || false;
475
- }
476
- const envKeyMatch = line.match(/^(\s*)env_key(\s*=.*)$/);
477
- if (envKeyMatch) {
478
- if (currentSectionHasTempEnvKey) {
479
- continue;
480
- } else {
481
- result.push(`${envKeyMatch[1]}temp_env_key${envKeyMatch[2]}`);
482
- continue;
483
- }
484
- }
485
- result.push(line);
486
- }
487
- return result.join("\n");
488
- }
489
- function isCodexGoalsFeatureEnabled(content) {
490
- try {
491
- const parsed = parse(content);
492
- return parsed.features?.goals === true;
493
- } catch {
494
- return false;
495
- }
496
- }
497
- function escapeRegExp(input) {
498
- return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
499
- }
500
- function setCodexFeatureFlagInContent(content, key, enabled) {
501
- const normalized = content.trimEnd();
502
- const lines = normalized ? normalized.split("\n") : [];
503
- const featuresHeaderIndex = lines.findIndex((line) => line.trim() === "[features]");
504
- if (featuresHeaderIndex === -1) {
505
- const prefix = normalized ? `${normalized}
506
-
507
- ` : "";
508
- return `${prefix}[features]
509
- ${key} = ${enabled}
510
- `;
511
- }
512
- let insertIndex = lines.length;
513
- let featureIndex = -1;
514
- const keyPattern = new RegExp(`^${escapeRegExp(key)}\\s*=`);
515
- for (let index = featuresHeaderIndex + 1; index < lines.length; index += 1) {
516
- const trimmed = lines[index].trim();
517
- if (/^\[[^\]]+\]\s*$/.test(trimmed)) {
518
- insertIndex = index;
519
- break;
520
- }
521
- if (keyPattern.test(trimmed)) {
522
- featureIndex = index;
523
- break;
524
- }
525
- }
526
- if (featureIndex !== -1) {
527
- const replacePattern = new RegExp(`^(\\s*)${escapeRegExp(key)}\\s*=.*$`);
528
- lines[featureIndex] = lines[featureIndex].replace(replacePattern, `$1${key} = ${enabled}`);
529
- } else {
530
- lines.splice(insertIndex, 0, `${key} = ${enabled}`);
531
- }
532
- return `${lines.join("\n")}
533
- `;
534
- }
535
- function normalizeCodexFeatureFlags(input) {
536
- if (!input || typeof input !== "object" || Array.isArray(input)) {
537
- return void 0;
538
- }
539
- const flags = {};
540
- for (const [key, value] of Object.entries(input)) {
541
- if (/^\w+$/.test(key) && typeof value === "boolean") {
542
- flags[key] = value;
543
- }
544
- }
545
- return Object.keys(flags).length > 0 ? flags : void 0;
546
- }
547
- function applyCodexFeatureFlagsToContent(content, features) {
548
- let nextContent = content;
549
- for (const [key, enabled] of Object.entries(features).sort(([a], [b]) => a.localeCompare(b))) {
550
- nextContent = setCodexFeatureFlagInContent(nextContent, key, enabled);
551
- }
552
- return nextContent;
553
- }
554
- function setCodexGoalsFeatureInContent(content, enabled = true) {
555
- return setCodexFeatureFlagInContent(content, "goals", enabled);
556
- }
557
- function readCodexGoalsFeatureEnabled() {
558
- if (!exists(CODEX_CONFIG_FILE)) {
559
- return false;
560
- }
561
- try {
562
- return isCodexGoalsFeatureEnabled(readFile(CODEX_CONFIG_FILE));
563
- } catch {
564
- return false;
565
- }
566
- }
567
- function buildCodexGoalsFeatureConfigContent(existingContent = "") {
568
- return setCodexGoalsFeatureInContent(existingContent, true);
569
- }
570
- function ensureEnvKeyMigration() {
571
- const tomlConfig = readDefaultTomlConfig();
572
- if (tomlConfig?.codex?.envKeyMigrated)
573
- return;
574
- if (needsEnvKeyMigration()) {
575
- migrateEnvKeyToTempEnvKey();
576
- }
577
- }
578
- function sanitizeProviderName(input) {
579
- const cleaned = input.trim();
580
- if (!cleaned)
581
- return "";
582
- return cleaned.toLowerCase().replace(/\./g, "-").replace(/\s+/g, "-").replace(/[^a-z0-9\-]/g, "");
583
- }
584
- function parseCodexConfig(content) {
585
- if (!content.trim()) {
586
- return {
587
- model: null,
588
- modelProvider: null,
589
- providers: [],
590
- mcpServices: [],
591
- managed: false,
592
- features: void 0,
593
- otherConfig: [],
594
- modelProviderCommented: void 0
595
- };
596
- }
597
- try {
598
- const normalizedContent = content.replace(/(SYSTEMROOT\s*=\s*")[^"\n]+("?)/g, (match) => {
599
- return match.replace(/\\\\/g, "/").replace(/\\/g, "/").replace('C:/Windows"?', 'C:/Windows"');
600
- });
601
- const tomlData = parse(normalizedContent);
602
- const features = normalizeCodexFeatureFlags(tomlData.features);
603
- const providers = [];
604
- if (tomlData.model_providers) {
605
- for (const [id, providerData] of Object.entries(tomlData.model_providers)) {
606
- const provider = providerData;
607
- providers.push({
608
- id,
609
- name: provider.name || id,
610
- baseUrl: provider.base_url || "",
611
- wireApi: provider.wire_api || "responses",
612
- tempEnvKey: provider.temp_env_key || "OPENAI_API_KEY",
613
- requiresOpenaiAuth: provider.requires_openai_auth !== false,
614
- model: provider.model || void 0
615
- // Parse model field from provider
616
- });
617
- }
618
- }
619
- const mcpServices = [];
620
- if (tomlData.mcp_servers) {
621
- const KNOWN_MCP_FIELDS = /* @__PURE__ */ new Set(["command", "args", "env", "startup_timeout_sec"]);
622
- for (const [id, mcpData] of Object.entries(tomlData.mcp_servers)) {
623
- const mcp = mcpData;
624
- const extraFields = {};
625
- for (const [key, value] of Object.entries(mcp)) {
626
- if (!KNOWN_MCP_FIELDS.has(key)) {
627
- extraFields[key] = value;
628
- }
629
- }
630
- mcpServices.push({
631
- id,
632
- command: mcp.command || id,
633
- args: mcp.args || [],
634
- env: Object.keys(mcp.env || {}).length > 0 ? mcp.env : void 0,
635
- startup_timeout_sec: mcp.startup_timeout_sec,
636
- // Only add extraFields if there are any extra fields
637
- extraFields: Object.keys(extraFields).length > 0 ? extraFields : void 0
638
- });
639
- }
640
- }
641
- const model = tomlData.model || null;
642
- let modelProvider = null;
643
- let modelProviderCommented;
644
- const commentedMatch = content.match(/^(\s*)#\s*model_provider\s*=\s*"([^"]+)"/m);
645
- if (commentedMatch) {
646
- modelProvider = commentedMatch[2];
647
- modelProviderCommented = true;
648
- } else {
649
- const lines2 = content.split("\n");
650
- let inSection = false;
651
- for (const line of lines2) {
652
- const trimmedLine = line.trim();
653
- if (!trimmedLine)
654
- continue;
655
- if (trimmedLine.startsWith("[")) {
656
- inSection = true;
657
- continue;
658
- }
659
- if (trimmedLine.startsWith("#")) {
660
- if (trimmedLine.includes("--- model provider added by CCJK ---")) {
661
- inSection = false;
662
- }
663
- continue;
664
- }
665
- if (!inSection && trimmedLine.startsWith("model_provider")) {
666
- const match = trimmedLine.match(/model_provider\s*=\s*"([^"]+)"/);
667
- if (match) {
668
- modelProvider = match[1];
669
- modelProviderCommented = false;
670
- break;
671
- }
672
- }
673
- }
674
- if (!modelProvider) {
675
- modelProvider = tomlData.model_provider || null;
676
- modelProviderCommented = false;
677
- }
678
- }
679
- const otherConfig = [];
680
- const lines = content.split("\n");
681
- let skipCurrentSection = false;
682
- for (const line of lines) {
683
- const trimmed = line.trim();
684
- if (!trimmed)
685
- continue;
686
- if (/^#\s*---\s*model provider added by CCJK\s*---\s*$/i.test(trimmed))
687
- continue;
688
- if (/^#\s*---\s*MCP servers added by CCJK\s*---\s*$/i.test(trimmed))
689
- continue;
690
- if (/Managed by CCJK/i.test(trimmed))
691
- continue;
692
- const sec = trimmed.match(/^\[([^\]]+)\]/);
693
- if (sec) {
694
- const name = sec[1];
695
- skipCurrentSection = name.startsWith("model_providers.") || name.startsWith("mcp_servers.");
696
- if (skipCurrentSection)
697
- continue;
698
- otherConfig.push(line);
699
- continue;
700
- }
701
- if (/^#?\s*model_provider\s*=/.test(trimmed))
702
- continue;
703
- if (/^model\s*=/.test(trimmed))
704
- continue;
705
- if (!skipCurrentSection) {
706
- otherConfig.push(line);
707
- }
708
- }
709
- const managed = providers.length > 0 || mcpServices.length > 0 || modelProvider !== null || model !== null;
710
- return {
711
- model,
712
- modelProvider,
713
- providers,
714
- mcpServices,
715
- managed,
716
- features,
717
- otherConfig,
718
- modelProviderCommented
719
- };
720
- } catch (error) {
721
- if (process__default.env.NODE_ENV === "development" || process__default.env.DEBUG) {
722
- console.warn("TOML parsing failed, falling back to basic parsing:", error);
723
- }
724
- const cleaned = content.replace(/^\s*#\s*---\s*model provider added by CCJK\s*---\s*$/gim, "").replace(/^\s*#\s*---\s*MCP servers added by CCJK\s*---\s*$/gim, "").replace(/^\[model_providers\.[^\]]+\][\s\S]*?(?=^\[|$)/gim, "").replace(/^\[mcp_servers\.[^\]]+\][\s\S]*?(?=^\[|$)/gim, "").replace(/^\s*(?:#\s*)?model_provider\s*=.*$/gim, "").replace(/^\s*model\s*=.*$/gim, "").replace(/\n{3,}/g, "\n\n");
725
- const otherConfig = cleaned.split("\n").map((l) => l.replace(/\s+$/g, "")).filter((l) => l.trim().length > 0);
726
- return {
727
- model: null,
728
- modelProvider: null,
729
- providers: [],
730
- mcpServices: [],
731
- managed: false,
732
- features: void 0,
733
- otherConfig,
734
- modelProviderCommented: void 0
735
- };
736
- }
737
- }
738
- function formatInlineTableValue(value) {
739
- if (value === null || value === void 0) {
740
- return "";
741
- }
742
- if (typeof value === "string") {
743
- const normalized = normalizeTomlPath(value);
744
- return `'${normalized}'`;
745
- }
746
- if (typeof value === "number" || typeof value === "boolean") {
747
- return String(value);
748
- }
749
- if (Array.isArray(value)) {
750
- const items = value.map((item) => {
751
- if (typeof item === "string") {
752
- const normalized = normalizeTomlPath(item);
753
- return `'${normalized}'`;
754
- }
755
- if (typeof item === "object" && item !== null && !Array.isArray(item)) {
756
- return formatInlineTable(item);
757
- }
758
- return String(item);
759
- }).join(", ");
760
- return `[${items}]`;
761
- }
762
- if (typeof value === "object") {
763
- return formatInlineTable(value);
764
- }
765
- return String(value);
766
- }
767
- function formatInlineTable(obj) {
768
- const entries = Object.entries(obj).filter(([_, v]) => v !== null && v !== void 0).map(([k, v]) => `${k} = ${formatInlineTableValue(v)}`).join(", ");
769
- return `{${entries}}`;
770
- }
771
- function formatTomlField(key, value) {
772
- if (value === null || value === void 0) {
773
- return "";
774
- }
775
- if (typeof value === "string") {
776
- const normalized = normalizeTomlPath(value);
777
- const escaped = normalized.replace(/"/g, '\\"');
778
- return `${key} = "${escaped}"`;
779
- }
780
- if (typeof value === "number" || typeof value === "boolean") {
781
- return `${key} = ${value}`;
782
- }
783
- if (Array.isArray(value)) {
784
- const items = value.map((item) => {
785
- if (typeof item === "string") {
786
- const normalized = normalizeTomlPath(item);
787
- const escaped = normalized.replace(/"/g, '\\"');
788
- return `"${escaped}"`;
789
- }
790
- if (typeof item === "object" && item !== null && !Array.isArray(item)) {
791
- return formatInlineTable(item);
792
- }
793
- return String(item);
794
- }).join(", ");
795
- return `${key} = [${items}]`;
796
- }
797
- if (typeof value === "object") {
798
- return `${key} = ${formatInlineTable(value)}`;
799
- }
800
- return "";
801
- }
802
- function readCodexConfig() {
803
- if (!exists(CODEX_CONFIG_FILE))
804
- return null;
805
- ensureEnvKeyMigration();
806
- try {
807
- const content = readFile(CODEX_CONFIG_FILE);
808
- return parseCodexConfig(content);
809
- } catch {
810
- return null;
811
- }
812
- }
813
- function renderCodexConfig(data) {
814
- const lines = [];
815
- if (data.model || data.modelProvider || data.providers.length > 0 || data.modelProviderCommented) {
816
- lines.push("# --- model provider added by CCJK ---");
817
- if (data.model) {
818
- lines.push(`model = "${data.model}"`);
819
- }
820
- if (data.modelProvider) {
821
- const commentPrefix = data.modelProviderCommented ? "# " : "";
822
- lines.push(`${commentPrefix}model_provider = "${data.modelProvider}"`);
823
- }
824
- lines.push("");
825
- }
826
- if (data.otherConfig && data.otherConfig.length > 0) {
827
- const preserved = data.otherConfig.filter((raw) => {
828
- const l = String(raw).trim();
829
- if (!l)
830
- return false;
831
- if (/^#\s*---\s*model provider added by CCJK\s*---\s*$/i.test(l))
832
- return false;
833
- if (/^#\s*---\s*MCP servers added by CCJK\s*---\s*$/i.test(l))
834
- return false;
835
- if (/^\[\s*mcp_servers\./i.test(l))
836
- return false;
837
- if (/^\[\s*model_providers\./i.test(l))
838
- return false;
839
- if (/^#?\s*model_provider\s*=/.test(l))
840
- return false;
841
- if (/^\s*model\s*=/.test(l) && !l.includes("["))
842
- return false;
843
- return true;
844
- });
845
- if (preserved.length > 0) {
846
- lines.push(...preserved);
847
- if (data.providers.length > 0 || data.mcpServices.length > 0) {
848
- lines.push("");
849
- }
850
- }
851
- }
852
- if (data.providers.length > 0) {
853
- for (const provider of data.providers) {
854
- lines.push("");
855
- lines.push(`[model_providers.${provider.id}]`);
856
- lines.push(`name = "${provider.name}"`);
857
- lines.push(`base_url = "${provider.baseUrl}"`);
858
- lines.push(`wire_api = "${provider.wireApi}"`);
859
- lines.push(`temp_env_key = "${provider.tempEnvKey}"`);
860
- lines.push(`requires_openai_auth = ${provider.requiresOpenaiAuth}`);
861
- if (provider.model) {
862
- lines.push(`model = "${provider.model}"`);
863
- }
864
- }
865
- }
866
- if (data.mcpServices.length > 0) {
867
- lines.push("");
868
- lines.push("# --- MCP servers added by CCJK ---");
869
- for (const service of data.mcpServices) {
870
- lines.push(`[mcp_servers.${service.id}]`);
871
- const normalizedCommand = normalizeTomlPath(service.command);
872
- lines.push(`command = "${normalizedCommand}"`);
873
- const argsString = service.args.length > 0 ? service.args.map((arg) => `"${arg}"`).join(", ") : "";
874
- lines.push(`args = [${argsString}]`);
875
- if (service.env && Object.keys(service.env).length > 0) {
876
- const envEntries = Object.entries(service.env).map(([key, value]) => `${key} = '${value}'`).join(", ");
877
- lines.push(`env = {${envEntries}}`);
878
- }
879
- if (service.startup_timeout_sec) {
880
- lines.push(`startup_timeout_sec = ${service.startup_timeout_sec}`);
881
- }
882
- if (service.extraFields) {
883
- for (const [key, value] of Object.entries(service.extraFields)) {
884
- const formatted = formatTomlField(key, value);
885
- if (formatted) {
886
- lines.push(formatted);
887
- }
888
- }
889
- }
890
- lines.push("");
891
- }
892
- if (lines[lines.length - 1] === "") {
893
- lines.pop();
894
- }
895
- }
896
- let result = lines.join("\n");
897
- if (result && !result.endsWith("\n")) {
898
- result += "\n";
899
- }
900
- if (data.features && Object.keys(data.features).length > 0) {
901
- result = applyCodexFeatureFlagsToContent(result, data.features);
902
- }
903
- return result;
904
- }
905
- function writeCodexConfig(data) {
906
- ensureEnvKeyMigration();
907
- ensureDir(CODEX_DIR);
908
- writeFileAtomic(CODEX_CONFIG_FILE, renderCodexConfig(data));
909
- }
910
- function writeAuthFile(newEntries, authMode) {
911
- ensureDir(CODEX_DIR);
912
- const existing = readJsonConfig(CODEX_AUTH_FILE, { defaultValue: {} }) || {};
913
- const merged = { ...existing, ...newEntries };
914
- if (authMode) {
915
- merged.auth_mode = authMode;
916
- }
917
- writeJsonConfig(CODEX_AUTH_FILE, merged, { pretty: true });
918
- }
919
- async function isCodexInstalled() {
920
- try {
921
- const npmResult = await K("npm", ["list", "-g", "--depth=0"]);
922
- if (npmResult.exitCode === 0 && npmResult.stdout.includes("@openai/codex@")) {
923
- return true;
924
- }
925
- } catch {
926
- }
927
- try {
928
- const brewResult = await K("brew", ["list", "--cask", "codex"], { throwOnError: false });
929
- if (brewResult.exitCode === 0) {
930
- return true;
931
- }
932
- } catch {
933
- }
934
- return false;
935
- }
936
- async function getCodexVersion() {
937
- try {
938
- const npmResult = await K("npm", ["list", "-g", "--depth=0"]);
939
- if (npmResult.exitCode === 0) {
940
- const match = npmResult.stdout.match(/@openai\/codex@(\S+)/);
941
- if (match) {
942
- return match[1];
943
- }
944
- }
945
- } catch {
946
- }
947
- try {
948
- const brewResult = await K("brew", ["info", "--cask", "codex", "--json=v2"], { throwOnError: false });
949
- if (brewResult.exitCode === 0) {
950
- const info = JSON.parse(brewResult.stdout);
951
- if (info.casks && Array.isArray(info.casks) && info.casks.length > 0) {
952
- const cask = info.casks[0];
953
- if (cask.installed && typeof cask.installed === "string") {
954
- return cask.installed;
955
- }
956
- }
957
- }
958
- } catch {
959
- }
960
- return null;
961
- }
962
- async function checkCodexUpdate() {
963
- try {
964
- const currentVersion = await getCodexVersion();
965
- if (!currentVersion) {
966
- return {
967
- installed: false,
968
- currentVersion: null,
969
- latestVersion: null,
970
- needsUpdate: false
971
- };
972
- }
973
- const result = await K("npm", ["view", "@openai/codex", "--json"]);
974
- if (result.exitCode !== 0) {
975
- return {
976
- installed: true,
977
- currentVersion,
978
- latestVersion: null,
979
- needsUpdate: false
980
- };
981
- }
982
- const packageInfo = JSON.parse(result.stdout);
983
- const latestVersion = packageInfo["dist-tags"]?.latest;
984
- if (!latestVersion) {
985
- return {
986
- installed: true,
987
- currentVersion,
988
- latestVersion: null,
989
- needsUpdate: false
990
- };
991
- }
992
- const needsUpdate = semver.gt(latestVersion, currentVersion);
993
- return {
994
- installed: true,
995
- currentVersion,
996
- latestVersion,
997
- needsUpdate
998
- };
999
- } catch {
1000
- return {
1001
- installed: false,
1002
- currentVersion: null,
1003
- latestVersion: null,
1004
- needsUpdate: false
1005
- };
1006
- }
1007
- }
1008
- async function installCodexCli(skipMethodSelection = false) {
1009
- ensureI18nInitialized();
1010
- if (await isCodexInstalled()) {
1011
- const { needsUpdate } = await checkCodexUpdate();
1012
- if (needsUpdate) {
1013
- await executeCodexInstallation(true, skipMethodSelection);
1014
- return;
1015
- } else {
1016
- console.log(a.yellow(i18n.t("codex:alreadyInstalled")));
1017
- return;
1018
- }
1019
- }
1020
- await executeCodexInstallation(false, skipMethodSelection);
1021
- }
1022
- async function runCodexWorkflowImportWithLanguageSelection(options) {
1023
- ensureI18nInitialized();
1024
- const zcfConfig = readZcfConfig();
1025
- const { aiOutputLang: commandLineOption, skipPrompt = false } = options ?? {};
1026
- const aiOutputLang = await resolveAiOutputLanguage(
1027
- i18n.language,
1028
- commandLineOption,
1029
- zcfConfig,
1030
- skipPrompt
1031
- );
1032
- updateZcfConfig({ aiOutputLang });
1033
- applyAiLanguageDirective(aiOutputLang);
1034
- await runCodexSystemPromptSelection(skipPrompt);
1035
- ensureCodexAgentsLanguageDirective(aiOutputLang);
1036
- await runCodexWorkflowSelection(options);
1037
- console.log(a.green(i18n.t("codex:workflowInstall")));
1038
- return aiOutputLang;
1039
- }
1040
- async function runCodexSystemPromptSelection(skipPrompt = false) {
1041
- ensureI18nInitialized();
1042
- const rootDir = getRootDir();
1043
- const zcfConfig = readZcfConfig();
1044
- const { readDefaultTomlConfig: readDefaultTomlConfig2 } = await import('./ccjk-config.mjs');
1045
- const tomlConfig = readDefaultTomlConfig2();
1046
- const { resolveTemplateLanguage } = await import('./prompts.mjs');
1047
- const preferredLang = await resolveTemplateLanguage(
1048
- void 0,
1049
- // No command line option for this function
1050
- zcfConfig,
1051
- skipPrompt
1052
- // Pass skipPrompt flag
1053
- );
1054
- updateZcfConfig({ templateLang: preferredLang });
1055
- let systemPromptSrc = join(rootDir, "templates", "common", "output-styles", preferredLang);
1056
- if (!exists(systemPromptSrc))
1057
- systemPromptSrc = join(rootDir, "templates", "common", "output-styles", "zh-CN");
1058
- if (!exists(systemPromptSrc))
1059
- return;
1060
- const availablePrompts = [
1061
- {
1062
- id: "speed-coder",
1063
- name: i18n.t("configuration:outputStyles.speed-coder.name"),
1064
- description: i18n.t("configuration:outputStyles.speed-coder.description")
1065
- },
1066
- {
1067
- id: "senior-architect",
1068
- name: i18n.t("configuration:outputStyles.senior-architect.name"),
1069
- description: i18n.t("configuration:outputStyles.senior-architect.description")
1070
- },
1071
- {
1072
- id: "pair-programmer",
1073
- name: i18n.t("configuration:outputStyles.pair-programmer.name"),
1074
- description: i18n.t("configuration:outputStyles.pair-programmer.description")
1075
- }
1076
- ].filter((style) => exists(join(systemPromptSrc, `${style.id}.md`)));
1077
- if (availablePrompts.length === 0)
1078
- return;
1079
- const { resolveSystemPromptStyle } = await import('./prompts.mjs');
1080
- const systemPrompt = await resolveSystemPromptStyle(
1081
- availablePrompts,
1082
- void 0,
1083
- // No command line option for this function
1084
- tomlConfig,
1085
- skipPrompt
1086
- // Pass skipPrompt flag
1087
- );
1088
- if (!systemPrompt)
1089
- return;
1090
- const promptFile = join(systemPromptSrc, `${systemPrompt}.md`);
1091
- const content = readFile(promptFile);
1092
- ensureDir(CODEX_DIR);
1093
- const backupPath = backupCodexAgents();
1094
- if (backupPath) {
1095
- console.log(a.gray(getBackupMessage(backupPath)));
1096
- }
1097
- writeFileAtomic(CODEX_AGENTS_FILE, content);
1098
- try {
1099
- const { updateTomlConfig: updateTomlConfig2 } = await import('./ccjk-config.mjs');
1100
- const { ZCF_CONFIG_FILE: ZCF_CONFIG_FILE2 } = await import('./constants.mjs');
1101
- updateTomlConfig2(ZCF_CONFIG_FILE2, {
1102
- codex: {
1103
- systemPromptStyle: systemPrompt
1104
- }
1105
- });
1106
- } catch (error) {
1107
- console.error("Failed to update CCJK config:", error);
1108
- }
1109
- }
1110
- async function runCodexWorkflowSelection(options) {
1111
- ensureI18nInitialized();
1112
- const { skipPrompt = false, workflows: presetWorkflows = [] } = options ?? {};
1113
- const rootDir = getRootDir();
1114
- const zcfConfig = readZcfConfig();
1115
- const templateLang = zcfConfig?.templateLang || zcfConfig?.preferredLang || "en";
1116
- let preferredLang = templateLang === "en" ? "en" : "zh-CN";
1117
- const workflowSrc = join(rootDir, "templates", "common", "workflow");
1118
- if (!exists(workflowSrc))
1119
- return;
1120
- let allWorkflows = getCodexWorkflowOptionDefinitions(workflowSrc, preferredLang);
1121
- if (allWorkflows.length === 0 && preferredLang === "en") {
1122
- preferredLang = "zh-CN";
1123
- allWorkflows = getCodexWorkflowOptionDefinitions(workflowSrc, preferredLang);
1124
- }
1125
- if (allWorkflows.length === 0)
1126
- return;
1127
- if (skipPrompt) {
1128
- ensureDir(CODEX_PROMPTS_DIR);
1129
- const backupPath2 = backupCodexPrompts();
1130
- if (backupPath2) {
1131
- console.log(a.gray(getBackupMessage(backupPath2)));
1132
- }
1133
- let workflowsToInstall;
1134
- if (presetWorkflows.length > 0) {
1135
- const selectedWorkflows = allWorkflows.filter(
1136
- (workflow) => presetWorkflows.includes(workflow.id) || presetWorkflows.includes(workflow.name)
1137
- );
1138
- workflowsToInstall = expandSelectedWorkflowPaths(selectedWorkflows.map((w) => w.path), workflowSrc, preferredLang);
1139
- } else {
1140
- workflowsToInstall = expandSelectedWorkflowPaths(allWorkflows.map((w) => w.path), workflowSrc, preferredLang);
1141
- }
1142
- for (const workflowPath of workflowsToInstall) {
1143
- const content = readFile(workflowPath);
1144
- const filename = workflowPath.split("/").pop() || "workflow.md";
1145
- const targetPath = join(CODEX_PROMPTS_DIR, filename);
1146
- writeFile(targetPath, content);
1147
- }
1148
- return;
1149
- }
1150
- const { workflows } = await inquirer.prompt([{
1151
- type: "checkbox",
1152
- name: "workflows",
1153
- message: i18n.t("codex:workflowSelectionPrompt"),
1154
- choices: addNumbersToChoices(allWorkflows.map((workflow) => ({
1155
- name: `${workflow.name} ${a.gray(`- ${workflow.description}`)}`,
1156
- value: workflow.path,
1157
- checked: true
1158
- // Default all selected
1159
- })))
1160
- }]);
1161
- if (!workflows || workflows.length === 0)
1162
- return;
1163
- ensureDir(CODEX_PROMPTS_DIR);
1164
- const backupPath = backupCodexPrompts();
1165
- if (backupPath) {
1166
- console.log(a.gray(getBackupMessage(backupPath)));
1167
- }
1168
- const finalWorkflowPaths = expandSelectedWorkflowPaths(workflows, workflowSrc, preferredLang);
1169
- for (const workflowPath of finalWorkflowPaths) {
1170
- const content = readFile(workflowPath);
1171
- const filename = workflowPath.split("/").pop() || "workflow.md";
1172
- const targetPath = join(CODEX_PROMPTS_DIR, filename);
1173
- writeFile(targetPath, content);
1174
- }
1175
- }
1176
- const ESSENTIAL_GROUP_SENTINEL = "::essentialGroup";
1177
- const GIT_GROUP_SENTINEL = "::gitGroup";
1178
- function getCodexWorkflowOptionDefinitions(workflowSrc, preferredLang) {
1179
- const options = [];
1180
- const pushIfExists = (id, nameKey, descriptionKey, path, existsCheck = () => exists(path)) => {
1181
- if (!existsCheck()) {
1182
- return;
1183
- }
1184
- options.push({
1185
- id,
1186
- name: i18n.t(nameKey),
1187
- description: i18n.t(descriptionKey),
1188
- path
1189
- });
1190
- };
1191
- pushIfExists(
1192
- "sixStepsWorkflow",
1193
- "workflow:workflowOption.sixStepsWorkflow",
1194
- "workflow:workflowDescription.sixStepsWorkflow",
1195
- join(workflowSrc, "sixStep", preferredLang, "workflow.md")
1196
- );
1197
- pushIfExists(
1198
- "essentialTools",
1199
- "workflow:workflowOption.essentialTools",
1200
- "workflow:workflowDescription.essentialTools",
1201
- ESSENTIAL_GROUP_SENTINEL,
1202
- () => getEssentialPromptFiles(workflowSrc, preferredLang).length > 0
1203
- );
1204
- pushIfExists(
1205
- "gitWorkflow",
1206
- "workflow:workflowOption.gitWorkflow",
1207
- "workflow:workflowDescription.gitWorkflow",
1208
- GIT_GROUP_SENTINEL,
1209
- () => getGitPromptFiles(workflowSrc, preferredLang).length > 0
1210
- );
1211
- pushIfExists(
1212
- "interviewWorkflow",
1213
- "workflow:workflowOption.interviewWorkflow",
1214
- "workflow:workflowDescription.interviewWorkflow",
1215
- join(workflowSrc, "interview", preferredLang, "interview.md")
1216
- );
1217
- pushIfExists(
1218
- "specFirstTDD",
1219
- "workflow:workflowOption.specFirstTDD",
1220
- "workflow:workflowDescription.specFirstTDD",
1221
- join(workflowSrc, "specFirstTDD", preferredLang, "spec-first-tdd.md")
1222
- );
1223
- pushIfExists(
1224
- "continuousDelivery",
1225
- "workflow:workflowOption.continuousDelivery",
1226
- "workflow:workflowDescription.continuousDelivery",
1227
- join(workflowSrc, "continuousDelivery", preferredLang, "continuous-delivery.md")
1228
- );
1229
- pushIfExists(
1230
- "refactoringMaster",
1231
- "workflow:workflowOption.refactoringMaster",
1232
- "workflow:workflowDescription.refactoringMaster",
1233
- join(workflowSrc, "refactoringMaster", preferredLang, "refactoring-master.md")
1234
- );
1235
- pushIfExists(
1236
- "linearMethod",
1237
- "workflow:workflowOption.linearMethod",
1238
- "workflow:workflowDescription.linearMethod",
1239
- join(workflowSrc, "linearMethod", preferredLang, "linear-method.md")
1240
- );
1241
- return options;
1242
- }
1243
- function expandSelectedWorkflowPaths(paths, workflowSrc, preferredLang) {
1244
- const expanded = [];
1245
- for (const p of paths) {
1246
- if (p === ESSENTIAL_GROUP_SENTINEL) {
1247
- expanded.push(...getEssentialPromptFiles(workflowSrc, preferredLang));
1248
- } else if (p === GIT_GROUP_SENTINEL) {
1249
- expanded.push(...getGitPromptFiles(workflowSrc, preferredLang));
1250
- } else {
1251
- expanded.push(p);
1252
- }
1253
- }
1254
- return expanded;
1255
- }
1256
- function getEssentialPromptFiles(workflowSrc, preferredLang) {
1257
- const essentialDir = join(workflowSrc, "essential", preferredLang);
1258
- const files = [
1259
- "feat.md",
1260
- "goal.md",
1261
- "init-project.md"
1262
- ];
1263
- const resolved = [];
1264
- for (const f of files) {
1265
- const full = join(essentialDir, f);
1266
- if (exists(full))
1267
- resolved.push(full);
1268
- }
1269
- return resolved;
1270
- }
1271
- function getGitPromptFiles(workflowSrc, preferredLang) {
1272
- const gitPromptsDir = join(workflowSrc, "git", preferredLang);
1273
- const files = [
1274
- "git-commit.md",
1275
- "git-rollback.md",
1276
- "git-cleanBranches.md",
1277
- "git-worktree.md"
1278
- ];
1279
- const resolved = [];
1280
- for (const f of files) {
1281
- const full = join(gitPromptsDir, f);
1282
- if (exists(full))
1283
- resolved.push(full);
1284
- }
1285
- return resolved;
1286
- }
1287
- function resolveCodexWorkflowNames(workflowIds, preferredLang) {
1288
- const workflowSrc = join(getRootDir(), "templates", "common", "workflow");
1289
- const options = getCodexWorkflowOptionDefinitions(workflowSrc, preferredLang);
1290
- const optionMap = new Map(options.map((option) => [option.id, option.name]));
1291
- return workflowIds.map((workflowId) => optionMap.get(workflowId)).filter((workflowName) => Boolean(workflowName));
1292
- }
1293
- function toProvidersList(providers) {
1294
- return providers.map((provider) => ({ name: provider.name || provider.id, value: provider.id }));
1295
- }
1296
- function createApiConfigChoices(providers, currentProvider, isCommented) {
1297
- const choices = [];
1298
- const isOfficialMode = !currentProvider || isCommented;
1299
- choices.push({
1300
- name: isOfficialMode ? `${a.green("\u25CF ")}${i18n.t("codex:useOfficialLogin")} ${a.yellow("(\u5F53\u524D)")}` : ` ${i18n.t("codex:useOfficialLogin")}`,
1301
- value: "official"
1302
- });
1303
- providers.forEach((provider) => {
1304
- const isCurrent = currentProvider === provider.id && !isCommented;
1305
- choices.push({
1306
- name: isCurrent ? `${a.green("\u25CF ")}${provider.name} - ${a.gray(provider.id)} ${a.yellow("(\u5F53\u524D)")}` : ` ${provider.name} - ${a.gray(provider.id)}`,
1307
- value: provider.id
1308
- });
1309
- });
1310
- return choices;
1311
- }
1312
- async function applyCustomApiConfig(customApiConfig) {
1313
- const { type, token, baseUrl, model } = customApiConfig;
1314
- const backupPath = backupCodexComplete();
1315
- if (backupPath) {
1316
- console.log(a.gray(getBackupMessage(backupPath)));
1317
- }
1318
- const existingConfig = readCodexConfig();
1319
- const existingAuth = readJsonConfig(CODEX_AUTH_FILE, { defaultValue: {} }) || {};
1320
- const providers = [];
1321
- const authEntries = { ...existingAuth };
1322
- const providerId = type === "auth_token" ? "official-auth-token" : "custom-api-key";
1323
- const providerName = type === "auth_token" ? "Official Auth Token" : "Custom API Key";
1324
- const existingProvider = existingConfig?.providers.find((p) => p.id === providerId);
1325
- providers.push({
1326
- id: providerId,
1327
- name: providerName,
1328
- baseUrl: baseUrl || existingProvider?.baseUrl || "https://api.anthropic.com",
1329
- wireApi: existingProvider?.wireApi || "responses",
1330
- tempEnvKey: existingProvider?.tempEnvKey || `${providerId.toUpperCase()}_API_KEY`,
1331
- requiresOpenaiAuth: existingProvider?.requiresOpenaiAuth ?? false,
1332
- model: model || existingProvider?.model
1333
- });
1334
- if (existingConfig?.providers) {
1335
- providers.push(...existingConfig.providers.filter((p) => p.id !== providerId));
1336
- }
1337
- if (token) {
1338
- authEntries[providerId] = token;
1339
- authEntries.OPENAI_API_KEY = token;
1340
- }
1341
- const configData = {
1342
- model: model || existingConfig?.model || "gpt-5-codex",
1343
- // Prefer provided model, then existing, fallback default
1344
- modelProvider: providerId,
1345
- modelProviderCommented: false,
1346
- providers,
1347
- mcpServices: existingConfig?.mcpServices || [],
1348
- features: existingConfig?.features,
1349
- otherConfig: existingConfig?.otherConfig || []
1350
- };
1351
- writeCodexConfig(configData);
1352
- writeJsonConfig(CODEX_AUTH_FILE, { ...authEntries, auth_mode: "apikey" });
1353
- updateZcfConfig({ codeToolType: "codex" });
1354
- console.log(a.green(`\u2714 ${i18n.t("codex:apiConfigured")}`));
1355
- }
1356
- async function configureCodexApi(options) {
1357
- ensureI18nInitialized();
1358
- const { skipPrompt = false, apiMode, customApiConfig } = options ?? {};
1359
- const existingConfig = readCodexConfig();
1360
- const existingAuth = readJsonConfig(CODEX_AUTH_FILE, { defaultValue: {} }) || {};
1361
- if (skipPrompt) {
1362
- if (apiMode === "skip") {
1363
- return;
1364
- }
1365
- if (apiMode === "custom" && customApiConfig) {
1366
- await applyCustomApiConfig(customApiConfig);
1367
- return;
1368
- }
1369
- if (apiMode === "official") {
1370
- const success = await switchToOfficialLogin();
1371
- if (success) {
1372
- updateZcfConfig({ codeToolType: "codex" });
1373
- }
1374
- return;
1375
- }
1376
- }
1377
- const hasProviders = existingConfig?.providers && existingConfig.providers.length > 0;
1378
- const modeChoices = [
1379
- { name: i18n.t("codex:apiModeOfficial"), value: "official" },
1380
- { name: i18n.t("codex:apiModeCustom"), value: "custom" }
1381
- ];
1382
- if (hasProviders) {
1383
- modeChoices.push({ name: i18n.t("codex:configSwitchMode"), value: "switch" });
1384
- }
1385
- const { mode } = await inquirer.prompt([{
1386
- type: "list",
1387
- name: "mode",
1388
- message: i18n.t("codex:apiModePrompt"),
1389
- choices: addNumbersToChoices(modeChoices),
1390
- default: "custom"
1391
- }]);
1392
- if (!mode) {
1393
- console.log(a.yellow(i18n.t("common:cancelled")));
1394
- return;
1395
- }
1396
- if (mode === "official") {
1397
- const success = await switchToOfficialLogin();
1398
- if (success) {
1399
- updateZcfConfig({ codeToolType: "codex" });
1400
- }
1401
- return;
1402
- }
1403
- if (mode === "switch") {
1404
- if (!hasProviders) {
1405
- console.log(a.yellow(i18n.t("codex:noProvidersAvailable")));
1406
- return;
1407
- }
1408
- const currentProvider = existingConfig?.modelProvider;
1409
- const isCommented = existingConfig?.modelProviderCommented;
1410
- const choices = createApiConfigChoices(existingConfig.providers, currentProvider, isCommented);
1411
- const { selectedConfig } = await inquirer.prompt([{
1412
- type: "list",
1413
- name: "selectedConfig",
1414
- message: i18n.t("codex:apiConfigSwitchPrompt"),
1415
- choices: addNumbersToChoices(choices)
1416
- }]);
1417
- if (!selectedConfig) {
1418
- console.log(a.yellow(i18n.t("common:cancelled")));
1419
- return;
1420
- }
1421
- let success = false;
1422
- if (selectedConfig === "official") {
1423
- success = await switchToOfficialLogin();
1424
- } else {
1425
- success = await switchToProvider(selectedConfig);
1426
- }
1427
- if (success) {
1428
- updateZcfConfig({ codeToolType: "codex" });
1429
- }
1430
- return;
1431
- }
1432
- const managementMode = detectConfigManagementMode();
1433
- if (managementMode.mode === "management" && managementMode.hasProviders) {
1434
- const { default: { configureIncrementalManagement } } = await import('./codex-config-switch.mjs');
1435
- await configureIncrementalManagement();
1436
- return;
1437
- }
1438
- const backupPath = backupCodexComplete();
1439
- if (backupPath) {
1440
- console.log(a.gray(getBackupMessage(backupPath)));
1441
- }
1442
- const providers = [];
1443
- const authEntries = {};
1444
- const existingMap = new Map(existingConfig?.providers.map((provider) => [provider.id, provider]));
1445
- const currentSessionProviders = /* @__PURE__ */ new Map();
1446
- let addMore = true;
1447
- const existingValues = existingMap.size ? Array.from(existingMap.values()) : [];
1448
- const firstExisting = existingValues.length === 1 ? existingValues[0] : void 0;
1449
- while (addMore) {
1450
- const { getApiProviders } = await import('./api-providers.mjs');
1451
- const apiProviders = getApiProviders("codex");
1452
- const providerChoices = [
1453
- { name: i18n.t("api:customProvider"), value: "custom" },
1454
- ...apiProviders.map((p) => ({ name: p.name, value: p.id }))
1455
- ];
1456
- const { selectedProvider: selectedProvider2 } = await inquirer.prompt([{
1457
- type: "list",
1458
- name: "selectedProvider",
1459
- message: i18n.t("api:selectApiProvider"),
1460
- choices: addNumbersToChoices(providerChoices)
1461
- }]);
1462
- let prefilledBaseUrl;
1463
- let prefilledWireApi;
1464
- let prefilledModel;
1465
- if (selectedProvider2 !== "custom") {
1466
- const provider = apiProviders.find((p) => p.id === selectedProvider2);
1467
- if (provider?.codex) {
1468
- prefilledBaseUrl = provider.codex.baseUrl;
1469
- prefilledWireApi = provider.codex.wireApi;
1470
- prefilledModel = provider.codex.defaultModel;
1471
- console.log(a.gray(i18n.t("api:providerSelected", { name: provider.name })));
1472
- }
1473
- }
1474
- const answers = await inquirer.prompt([
1475
- {
1476
- type: "input",
1477
- name: "providerName",
1478
- message: i18n.t("codex:providerNamePrompt"),
1479
- default: selectedProvider2 !== "custom" ? apiProviders.find((p) => p.id === selectedProvider2)?.name : firstExisting?.name,
1480
- validate: (input) => {
1481
- const sanitized = sanitizeProviderName(input);
1482
- if (!sanitized)
1483
- return i18n.t("codex:providerNameRequired");
1484
- if (sanitized !== input.trim())
1485
- return i18n.t("codex:providerNameInvalid");
1486
- return true;
1487
- }
1488
- },
1489
- {
1490
- type: "input",
1491
- name: "baseUrl",
1492
- message: i18n.t("codex:providerBaseUrlPrompt"),
1493
- default: prefilledBaseUrl || ((answers2) => existingMap.get(answers2.providerId)?.baseUrl || "https://api.openai.com/v1"),
1494
- when: () => selectedProvider2 === "custom",
1495
- validate: (input) => !!input || i18n.t("codex:providerBaseUrlRequired")
1496
- },
1497
- {
1498
- type: "list",
1499
- name: "wireApi",
1500
- message: i18n.t("codex:providerProtocolPrompt"),
1501
- choices: [
1502
- { name: i18n.t("codex:protocolResponses"), value: "responses" },
1503
- { name: i18n.t("codex:protocolChat"), value: "chat" }
1504
- ],
1505
- default: prefilledWireApi || ((answers2) => existingMap.get(sanitizeProviderName(answers2.providerName))?.wireApi || "responses"),
1506
- when: () => selectedProvider2 === "custom"
1507
- // Only ask if custom
1508
- },
1509
- {
1510
- type: "input",
1511
- name: "apiKey",
1512
- message: selectedProvider2 !== "custom" ? i18n.t("api:enterProviderApiKey", { provider: apiProviders.find((p) => p.id === selectedProvider2)?.name || selectedProvider2 }) : i18n.t("codex:providerApiKeyPrompt"),
1513
- validate: (input) => !!input || i18n.t("codex:providerApiKeyRequired")
1514
- }
1515
- ]);
1516
- let customModel;
1517
- if (selectedProvider2 === "custom") {
1518
- const { model } = await inquirer.prompt([{
1519
- type: "input",
1520
- name: "model",
1521
- message: `${i18n.t("configuration:enterCustomModel")}${i18n.t("common:emptyToSkip")}`,
1522
- default: "gpt-5-codex"
1523
- }]);
1524
- if (model.trim()) {
1525
- customModel = model.trim();
1526
- }
1527
- }
1528
- const providerId = sanitizeProviderName(answers.providerName);
1529
- const tempEnvKey = `${providerId.toUpperCase().replace(/-/g, "_")}_API_KEY`;
1530
- const existingProvider = existingMap.get(providerId);
1531
- const sessionProvider = currentSessionProviders.get(providerId);
1532
- if (existingProvider || sessionProvider) {
1533
- const sourceType = existingProvider ? "existing" : "session";
1534
- const sourceProvider = existingProvider || sessionProvider;
1535
- const shouldOverwrite = await promptBoolean({
1536
- message: i18n.t("codex:providerDuplicatePrompt", {
1537
- name: sourceProvider.name,
1538
- source: sourceType === "existing" ? i18n.t("codex:existingConfig") : i18n.t("codex:currentSession")
1539
- }),
1540
- defaultValue: false
1541
- });
1542
- if (!shouldOverwrite) {
1543
- console.log(a.yellow(i18n.t("codex:providerDuplicateSkipped")));
1544
- continue;
1545
- }
1546
- if (sessionProvider) {
1547
- currentSessionProviders.delete(providerId);
1548
- const sessionIndex = providers.findIndex((p) => p.id === providerId);
1549
- if (sessionIndex !== -1) {
1550
- providers.splice(sessionIndex, 1);
1551
- }
1552
- }
1553
- }
1554
- const newProvider = {
1555
- id: providerId,
1556
- name: answers.providerName,
1557
- baseUrl: selectedProvider2 === "custom" ? answers.baseUrl : prefilledBaseUrl,
1558
- wireApi: selectedProvider2 === "custom" ? answers.wireApi || "responses" : prefilledWireApi,
1559
- tempEnvKey,
1560
- requiresOpenaiAuth: false,
1561
- // Custom/third-party providers use their own API key, not OpenAI OAuth
1562
- model: customModel || prefilledModel || "gpt-5-codex"
1563
- // Use custom model, provider's default model, or fallback
1564
- };
1565
- providers.push(newProvider);
1566
- currentSessionProviders.set(providerId, newProvider);
1567
- authEntries[tempEnvKey] = answers.apiKey;
1568
- const addAnother = await promptBoolean({
1569
- message: i18n.t("codex:addProviderPrompt"),
1570
- defaultValue: false
1571
- });
1572
- addMore = addAnother;
1573
- }
1574
- if (providers.length === 0) {
1575
- console.log(a.yellow(i18n.t("codex:noProvidersConfigured")));
1576
- return;
1577
- }
1578
- const { defaultProvider } = await inquirer.prompt([{
1579
- type: "list",
1580
- name: "defaultProvider",
1581
- message: i18n.t("codex:selectDefaultProviderPrompt"),
1582
- choices: addNumbersToChoices(toProvidersList(providers)),
1583
- default: existingConfig?.modelProvider || providers[0].id
1584
- }]);
1585
- const selectedProvider = providers.find((provider) => provider.id === defaultProvider);
1586
- if (selectedProvider) {
1587
- const tempEnvKey = selectedProvider.tempEnvKey;
1588
- const defaultApiKey = authEntries[tempEnvKey] ?? existingAuth[tempEnvKey] ?? null;
1589
- if (defaultApiKey)
1590
- authEntries.OPENAI_API_KEY = defaultApiKey;
1591
- }
1592
- writeCodexConfig({
1593
- model: existingConfig?.model || null,
1594
- modelProvider: defaultProvider,
1595
- providers,
1596
- mcpServices: existingConfig?.mcpServices || [],
1597
- features: existingConfig?.features,
1598
- otherConfig: existingConfig?.otherConfig || []
1599
- });
1600
- writeAuthFile(authEntries, "apikey");
1601
- updateZcfConfig({ codeToolType: "codex" });
1602
- console.log(a.green(i18n.t("codex:apiConfigured")));
1603
- }
1604
- const CODEX_PRESET_DEFINITIONS = {
1605
- minimal: {
1606
- id: "minimal",
1607
- workflows: ["sixStepsWorkflow", "gitWorkflow"],
1608
- mcpServices: ["context7", "open-websearch"]
1609
- },
1610
- dev: {
1611
- id: "dev",
1612
- workflows: ["sixStepsWorkflow", "essentialTools", "gitWorkflow"],
1613
- mcpServices: ["context7", "open-websearch", "mcp-deepwiki"]
1614
- },
1615
- full: {
1616
- id: "full",
1617
- workflows: ["sixStepsWorkflow", "essentialTools", "gitWorkflow", "specFirstTDD", "refactoringMaster", "linearMethod", "interviewWorkflow"],
1618
- mcpServices: ["context7", "open-websearch", "mcp-deepwiki", "serena"]
1619
- }
1620
- };
1621
- function getCodexPresetDefinitions() {
1622
- return Object.values(CODEX_PRESET_DEFINITIONS);
1623
- }
1624
- async function runCodexFullInit(options) {
1625
- ensureI18nInitialized();
1626
- await installCodexCli(options?.skipPrompt || false);
1627
- const aiOutputLang = await runCodexWorkflowImportWithLanguageSelection(options);
1628
- await configureCodexApi(options);
1629
- await configureCodexMcp(options);
1630
- return aiOutputLang;
1631
- }
1632
- function resolveCodexPresetTemplateLang() {
1633
- const savedConfig = readZcfConfig();
1634
- const savedTemplateLang = savedConfig?.templateLang;
1635
- if (savedTemplateLang && SUPPORTED_LANGS.includes(savedTemplateLang)) {
1636
- return savedTemplateLang;
1637
- }
1638
- const preferredLang = savedConfig?.preferredLang;
1639
- if (preferredLang && SUPPORTED_LANGS.includes(preferredLang)) {
1640
- return preferredLang;
1641
- }
1642
- return i18n.language === "zh-CN" ? "zh-CN" : "en";
1643
- }
1644
- async function applyCodexPreset(presetId) {
1645
- ensureI18nInitialized();
1646
- const preset = CODEX_PRESET_DEFINITIONS[presetId];
1647
- if (!preset) {
1648
- throw new Error(`Unknown Codex preset: ${presetId}`);
1649
- }
1650
- const savedConfig = readZcfConfig();
1651
- const templateLang = resolveCodexPresetTemplateLang();
1652
- const preferredLang = savedConfig?.preferredLang || templateLang;
1653
- const aiOutputLang = savedConfig?.aiOutputLang || templateLang;
1654
- const workflowIds = preset.workflows;
1655
- const workflowNames = resolveCodexWorkflowNames(workflowIds, templateLang);
1656
- const previousSingleBackupMode = process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP;
1657
- process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP = "true";
1658
- try {
1659
- updateTomlConfig(ZCF_CONFIG_FILE, {
1660
- general: {
1661
- preferredLang,
1662
- currentTool: "codex",
1663
- templateLang,
1664
- aiOutputLang
1665
- }
1666
- });
1667
- await runCodexWorkflowImportWithLanguageSelection({
1668
- skipPrompt: true,
1669
- aiOutputLang,
1670
- workflows: workflowIds
1671
- });
1672
- await configureCodexMcp({
1673
- skipPrompt: true,
1674
- workflows: workflowIds,
1675
- mcpServices: preset.mcpServices
1676
- });
1677
- } finally {
1678
- cachedSkipPromptBackup = null;
1679
- if (previousSingleBackupMode === void 0) {
1680
- delete process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP;
1681
- } else {
1682
- process__default.env.CCJK_CODEX_SKIP_PROMPT_SINGLE_BACKUP = previousSingleBackupMode;
1683
- }
1684
- }
1685
- console.log(a.green(i18n.t("codex:presetApplied", { preset: i18n.t(`codex:presets.${preset.id}.name`) })));
1686
- console.log(a.gray(i18n.t("codex:presetSummary", {
1687
- workflows: workflowNames.join(", "),
1688
- services: preset.mcpServices.join(", ")
1689
- })));
1690
- }
1691
- function formatCodexModelSummary(model) {
1692
- if (!model)
1693
- return i18n.t("codex:efficiency.notConfigured");
1694
- const labels = {
1695
- "gpt-5-codex": "GPT-5-Codex",
1696
- "codex-mini-latest": "codex-mini-latest",
1697
- "gpt-5": "GPT-5"
1698
- };
1699
- return labels[model] || model;
1700
- }
1701
- function formatCodexStyleSummary(style) {
1702
- if (!style)
1703
- return i18n.t("codex:efficiency.notConfigured");
1704
- const styleLabels = {
1705
- "senior-architect": i18n.t("codex:efficiency.styleLabels.seniorArchitect"),
1706
- "speed-coder": i18n.t("codex:efficiency.styleLabels.speedCoder"),
1707
- "pair-programmer": i18n.t("codex:efficiency.styleLabels.pairProgrammer")
1708
- };
1709
- return styleLabels[style] || style;
1710
- }
1711
- function getInstalledCodexPromptCount() {
1712
- if (!exists(CODEX_PROMPTS_DIR)) {
1713
- return 0;
1714
- }
1715
- return readdirSync(CODEX_PROMPTS_DIR, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).length;
1716
- }
1717
- function buildCodexEfficiencyChoices() {
1718
- const codexConfig = readCodexConfig();
1719
- const zcfConfig = readDefaultTomlConfig();
1720
- const modelSummary = formatCodexModelSummary(codexConfig?.model);
1721
- const mcpSummary = codexConfig?.mcpServices?.length ?? 0;
1722
- const workflowSummary = getInstalledCodexPromptCount();
1723
- const promptSummary = formatCodexStyleSummary(zcfConfig?.codex?.systemPromptStyle);
1724
- const languageSummary = zcfConfig?.general?.aiOutputLang || zcfConfig?.general?.preferredLang || i18n.t("codex:efficiency.notConfigured");
1725
- return addNumbersToChoices([
1726
- {
1727
- name: `${i18n.t("codex:efficiency.actions.quickOptimize.name")} ${a.gray(`- ${i18n.t("codex:efficiency.actions.quickOptimize.description")}`)}`,
1728
- value: "quick-optimize"
1729
- },
1730
- {
1731
- name: `${i18n.t("codex:efficiency.actions.presetBundles.name")} ${a.gray(`- ${i18n.t("codex:efficiency.actions.presetBundles.description")}`)}`,
1732
- value: "preset-bundles"
1733
- },
1734
- {
1735
- name: `${i18n.t("codex:efficiency.actions.workflowPrompts.name")} ${a.gray(`- ${i18n.t("codex:efficiency.actions.workflowPrompts.description", { count: workflowSummary })}`)}`,
1736
- value: "workflow-prompts"
1737
- },
1738
- {
1739
- name: `${i18n.t("codex:efficiency.actions.model.name")} ${a.gray(`- ${i18n.t("codex:efficiency.actions.model.description", { model: modelSummary })}`)}`,
1740
- value: "model"
1741
- },
1742
- {
1743
- name: `${i18n.t("codex:efficiency.actions.docsMcp.name")} ${a.gray(`- ${i18n.t("codex:efficiency.actions.docsMcp.description", { count: mcpSummary })}`)}`,
1744
- value: "docs-mcp"
1745
- },
1746
- {
1747
- name: `${i18n.t("codex:efficiency.actions.promptMemory.name")} ${a.gray(`- ${i18n.t("codex:efficiency.actions.promptMemory.description", { prompt: promptSummary, language: languageSummary })}`)}`,
1748
- value: "prompt-memory"
1749
- },
1750
- {
1751
- name: i18n.t("codex:efficiency.actions.back.name"),
1752
- value: "back"
1753
- }
1754
- ]);
1755
- }
1756
- async function promptCodexPresetBundle() {
1757
- const { preset } = await inquirer.prompt([{
1758
- type: "list",
1759
- name: "preset",
1760
- message: i18n.t("codex:presetPrompt"),
1761
- choices: addNumbersToChoices(getCodexPresetDefinitions().map((item) => ({
1762
- name: `${i18n.t(`codex:presets.${item.id}.name`)} ${a.gray(`- ${i18n.t(`codex:presets.${item.id}.description`)}`)}`,
1763
- value: item.id
1764
- }))),
1765
- default: "dev"
1766
- }]);
1767
- return preset || null;
1768
- }
1769
- function ensureCodexRecommendedModel(defaultModel = "gpt-5-codex") {
1770
- const existingConfig = readCodexConfig();
1771
- if (existingConfig?.model) {
1772
- return null;
1773
- }
1774
- writeCodexConfig({
1775
- model: defaultModel,
1776
- modelProvider: existingConfig?.modelProvider || null,
1777
- providers: existingConfig?.providers || [],
1778
- mcpServices: existingConfig?.mcpServices || [],
1779
- features: existingConfig?.features,
1780
- otherConfig: existingConfig?.otherConfig || [],
1781
- modelProviderCommented: existingConfig?.modelProviderCommented
1782
- });
1783
- return defaultModel;
1784
- }
1785
- async function runCodexQuickOptimize() {
1786
- await applyCodexPreset("dev");
1787
- const appliedModel = ensureCodexRecommendedModel();
1788
- if (appliedModel) {
1789
- console.log(a.green(i18n.t("codex:efficiency.quickOptimizeModelApplied", { model: appliedModel })));
1790
- } else {
1791
- const currentModel = readCodexConfig()?.model;
1792
- if (currentModel) {
1793
- console.log(a.gray(i18n.t("codex:efficiency.quickOptimizeModelKept", { model: formatCodexModelSummary(currentModel) })));
1794
- }
1795
- }
1796
- }
1797
- async function configureCodexPresetFeature() {
1798
- ensureI18nInitialized();
1799
- while (true) {
1800
- const { action } = await inquirer.prompt([{
1801
- type: "list",
1802
- name: "action",
1803
- message: i18n.t("codex:efficiency.prompt"),
1804
- choices: buildCodexEfficiencyChoices(),
1805
- default: "quick-optimize"
1806
- }]);
1807
- if (!action || action === "back") {
1808
- return;
1809
- }
1810
- if (action === "quick-optimize") {
1811
- await runCodexQuickOptimize();
1812
- continue;
1813
- }
1814
- if (action === "preset-bundles") {
1815
- const preset = await promptCodexPresetBundle();
1816
- if (preset) {
1817
- await applyCodexPreset(preset);
1818
- }
1819
- continue;
1820
- }
1821
- if (action === "workflow-prompts") {
1822
- await runCodexWorkflowSelection();
1823
- continue;
1824
- }
1825
- if (action === "model") {
1826
- const { configureCodexDefaultModelFeature: configureCodexDefaultModelFeature2 } = await import('./features.mjs');
1827
- await configureCodexDefaultModelFeature2();
1828
- continue;
1829
- }
1830
- if (action === "docs-mcp") {
1831
- await configureCodexMcp();
1832
- continue;
1833
- }
1834
- if (action === "prompt-memory") {
1835
- const { configureCodexAiMemoryFeature: configureCodexAiMemoryFeature2 } = await import('./features.mjs');
1836
- await configureCodexAiMemoryFeature2();
1837
- }
1838
- }
1839
- }
1840
- function ensureCodexAgentsLanguageDirective(aiOutputLang) {
1841
- if (!exists(CODEX_AGENTS_FILE))
1842
- return;
1843
- const content = readFile(CODEX_AGENTS_FILE);
1844
- const targetLabel = resolveCodexLanguageLabel(aiOutputLang);
1845
- const directiveRegex = /\*\*Most Important:\s*Always respond in ([^*]+)\*\*/i;
1846
- const existingMatch = directiveRegex.exec(content);
1847
- if (existingMatch && normalizeLanguageLabel(existingMatch[1]) === normalizeLanguageLabel(targetLabel))
1848
- return;
1849
- let updatedContent = content.replace(/\*\*Most Important:\s*Always respond in [^*]+\*\*\s*/gi, "").trimEnd();
1850
- if (updatedContent.length > 0 && !updatedContent.endsWith("\n"))
1851
- updatedContent += "\n";
1852
- updatedContent += `
1853
- **Most Important:Always respond in ${targetLabel}**
1854
- `;
1855
- const backupPath = backupCodexAgents();
1856
- if (backupPath)
1857
- console.log(a.gray(getBackupMessage(backupPath)));
1858
- writeFileAtomic(CODEX_AGENTS_FILE, updatedContent);
1859
- console.log(a.gray(` ${i18n.t("configuration:addedLanguageDirective")}: ${targetLabel}`));
1860
- }
1861
- function resolveCodexLanguageLabel(aiOutputLang) {
1862
- const directive = AI_OUTPUT_LANGUAGES[aiOutputLang]?.directive;
1863
- if (directive) {
1864
- const match = directive.match(/Always respond in\s+(.+)/i);
1865
- if (match)
1866
- return match[1].trim();
1867
- }
1868
- if (typeof aiOutputLang === "string")
1869
- return aiOutputLang;
1870
- return "English";
1871
- }
1872
- function normalizeLanguageLabel(label) {
1873
- return label.trim().toLowerCase();
1874
- }
1875
- async function runCodexUpdate(force = false, skipPrompt = false) {
1876
- ensureI18nInitialized();
1877
- console.log(a.bold.cyan(`
1878
- \u{1F50D} ${i18n.t("updater:checkingTools")}
1879
- `));
1880
- const spinner = ora(i18n.t("updater:checkingVersion")).start();
1881
- try {
1882
- const { installed, currentVersion, latestVersion, needsUpdate } = await checkCodexUpdate();
1883
- spinner.stop();
1884
- if (!installed) {
1885
- console.log(a.yellow(i18n.t("codex:notInstalled")));
1886
- return false;
1887
- }
1888
- if (!needsUpdate && !force) {
1889
- console.log(a.green(format(i18n.t("codex:upToDate"), { version: currentVersion || "" })));
1890
- return true;
1891
- }
1892
- if (!latestVersion) {
1893
- console.log(a.yellow(i18n.t("codex:cannotCheckVersion")));
1894
- return false;
1895
- }
1896
- console.log(a.green(format(i18n.t("codex:currentVersion"), { version: currentVersion || "" })));
1897
- console.log(a.green(format(i18n.t("codex:latestVersion"), { version: latestVersion })));
1898
- if (!skipPrompt) {
1899
- const confirm = await promptBoolean({
1900
- message: i18n.t("codex:confirmUpdate"),
1901
- defaultValue: true
1902
- });
1903
- if (!confirm) {
1904
- console.log(a.gray(i18n.t("codex:updateSkipped")));
1905
- return true;
1906
- }
1907
- } else {
1908
- console.log(a.green(i18n.t("codex:autoUpdating")));
1909
- }
1910
- const updateSpinner = ora(i18n.t("codex:updating")).start();
1911
- try {
1912
- await executeCodexInstallation(true);
1913
- updateSpinner.succeed(i18n.t("codex:updateSuccess"));
1914
- return true;
1915
- } catch (error) {
1916
- updateSpinner.fail(i18n.t("codex:updateFailed"));
1917
- console.error(a.red(error instanceof Error ? error.message : String(error)));
1918
- return false;
1919
- }
1920
- } catch (error) {
1921
- spinner.fail(i18n.t("codex:checkFailed"));
1922
- console.error(a.red(error instanceof Error ? error.message : String(error)));
1923
- return false;
1924
- }
1925
- }
1926
- async function runCodexUninstall() {
1927
- ensureI18nInitialized();
1928
- const { CodexUninstaller } = await import('./codex-uninstaller.mjs');
1929
- const zcfConfig = readZcfConfig();
1930
- const preferredLang = zcfConfig?.preferredLang;
1931
- const uninstallLang = preferredLang && SUPPORTED_LANGS.includes(preferredLang) ? preferredLang : "en";
1932
- const uninstaller = new CodexUninstaller(uninstallLang);
1933
- const { mode } = await inquirer.prompt([{
1934
- type: "list",
1935
- name: "mode",
1936
- message: i18n.t("codex:uninstallModePrompt"),
1937
- choices: addNumbersToChoices([
1938
- { name: i18n.t("codex:uninstallModeComplete"), value: "complete" },
1939
- { name: i18n.t("codex:uninstallModeCustom"), value: "custom" }
1940
- ]),
1941
- default: "complete"
1942
- }]);
1943
- if (!mode) {
1944
- handleUninstallCancellation();
1945
- return;
1946
- }
1947
- try {
1948
- if (mode === "complete") {
1949
- const confirm = await promptBoolean({
1950
- message: i18n.t("codex:uninstallPrompt"),
1951
- defaultValue: false
1952
- });
1953
- if (!confirm) {
1954
- handleUninstallCancellation();
1955
- return;
1956
- }
1957
- const result = await uninstaller.completeUninstall();
1958
- displayUninstallResults([result]);
1959
- } else if (mode === "custom") {
1960
- const { items } = await inquirer.prompt([{
1961
- type: "checkbox",
1962
- name: "items",
1963
- message: i18n.t("codex:customUninstallPrompt"),
1964
- choices: addNumbersToChoices(getUninstallOptions())
1965
- }]);
1966
- if (!items || items.length === 0) {
1967
- handleUninstallCancellation();
1968
- return;
1969
- }
1970
- const results = await uninstaller.customUninstall(items);
1971
- displayUninstallResults(results);
1972
- }
1973
- console.log(a.green(i18n.t("codex:uninstallSuccess")));
1974
- } catch (error) {
1975
- console.error(a.red(i18n.t("codex:errorDuringUninstall", { error: error.message })));
1976
- throw error;
1977
- }
1978
- }
1979
- function displayUninstallResults(results) {
1980
- for (const result of results) {
1981
- for (const item of result.removed) {
1982
- console.log(a.green(`\u2714 ${i18n.t("codex:removedItem", { item })}`));
1983
- }
1984
- for (const config of result.removedConfigs) {
1985
- console.log(a.green(`\u2714 ${i18n.t("codex:removedConfig", { config })}`));
1986
- }
1987
- for (const warning of result.warnings) {
1988
- console.log(a.yellow(`\u26A0\uFE0F ${warning}`));
1989
- }
1990
- for (const error of result.errors) {
1991
- console.log(a.red(`\u274C ${error}`));
1992
- }
1993
- }
1994
- }
1995
- async function listCodexProviders() {
1996
- const config = readCodexConfig();
1997
- return config?.providers || [];
1998
- }
1999
- async function switchToOfficialLogin() {
2000
- ensureI18nInitialized();
2001
- const existingConfig = readCodexConfig();
2002
- if (!existingConfig) {
2003
- console.log(a.red(i18n.t("codex:configNotFound")));
2004
- return false;
2005
- }
2006
- const backupPath = backupCodexComplete();
2007
- if (backupPath) {
2008
- console.log(a.gray(getBackupMessage(backupPath)));
2009
- }
2010
- try {
2011
- let preservedModelProvider = existingConfig.modelProvider;
2012
- if (!preservedModelProvider) {
2013
- try {
2014
- const rawContent = readFile(CODEX_CONFIG_FILE);
2015
- const parsedToml = parse(rawContent);
2016
- if (typeof parsedToml.model_provider === "string" && parsedToml.model_provider.trim().length > 0)
2017
- preservedModelProvider = parsedToml.model_provider.trim();
2018
- } catch {
2019
- }
2020
- }
2021
- const shouldCommentModelProvider = typeof preservedModelProvider === "string" && preservedModelProvider.length > 0;
2022
- const updatedConfig = {
2023
- ...existingConfig,
2024
- modelProvider: shouldCommentModelProvider ? preservedModelProvider : existingConfig.modelProvider,
2025
- modelProviderCommented: shouldCommentModelProvider ? true : existingConfig.modelProviderCommented
2026
- };
2027
- writeCodexConfig(updatedConfig);
2028
- const auth = readJsonConfig(CODEX_AUTH_FILE, { defaultValue: {} }) || {};
2029
- auth.OPENAI_API_KEY = null;
2030
- auth.auth_mode = "chatgpt";
2031
- writeJsonConfig(CODEX_AUTH_FILE, auth, { pretty: true });
2032
- console.log(a.green(i18n.t("codex:officialConfigured")));
2033
- return true;
2034
- } catch (error) {
2035
- console.error(a.red(i18n.t("codex:errorSwitchingToOfficialLogin", { error: error.message })));
2036
- return false;
2037
- }
2038
- }
2039
- async function switchToProvider(providerId) {
2040
- ensureI18nInitialized();
2041
- const existingConfig = readCodexConfig();
2042
- if (!existingConfig) {
2043
- console.log(a.red(i18n.t("codex:configNotFound")));
2044
- return false;
2045
- }
2046
- const provider = existingConfig.providers.find((p) => p.id === providerId);
2047
- if (!provider) {
2048
- console.log(a.red(i18n.t("codex:providerNotFound", { provider: providerId })));
2049
- return false;
2050
- }
2051
- const backupPath = backupCodexComplete();
2052
- if (backupPath) {
2053
- console.log(a.gray(getBackupMessage(backupPath)));
2054
- }
2055
- try {
2056
- let targetModel = existingConfig.model;
2057
- if (provider.model) {
2058
- targetModel = provider.model;
2059
- } else {
2060
- const currentModel = existingConfig.model;
2061
- const stableCodexModels = /* @__PURE__ */ new Set(["gpt-5", "gpt-5-codex", "codex-mini-latest"]);
2062
- if (!currentModel || !stableCodexModels.has(currentModel)) {
2063
- targetModel = "gpt-5-codex";
2064
- }
2065
- }
2066
- const updatedConfig = {
2067
- ...existingConfig,
2068
- model: targetModel,
2069
- modelProvider: providerId,
2070
- modelProviderCommented: false
2071
- // Ensure it's not commented
2072
- };
2073
- writeCodexConfig(updatedConfig);
2074
- const auth = readJsonConfig(CODEX_AUTH_FILE, { defaultValue: {} }) || {};
2075
- const envValue = auth[provider.tempEnvKey] || null;
2076
- auth.OPENAI_API_KEY = envValue;
2077
- auth.auth_mode = "apikey";
2078
- writeJsonConfig(CODEX_AUTH_FILE, auth, { pretty: true });
2079
- console.log(a.green(i18n.t("codex:providerSwitchSuccess", { provider: providerId })));
2080
- return true;
2081
- } catch (error) {
2082
- console.error(a.red(i18n.t("codex:errorSwitchingProvider", { error: error.message })));
2083
- return false;
2084
- }
2085
- }
2086
- async function configureCodexDefaultModelFeature() {
2087
- const { configureCodexDefaultModelFeature: configureEnhancedCodexDefaultModelFeature } = await import('./features.mjs');
2088
- await configureEnhancedCodexDefaultModelFeature();
2089
- }
2090
- async function configureCodexAiMemoryFeature() {
2091
- const { configureCodexAiMemoryFeature: configureEnhancedCodexAiMemoryFeature } = await import('./features.mjs');
2092
- await configureEnhancedCodexAiMemoryFeature();
2093
- }
2094
-
2095
- const codex = {
2096
- __proto__: null,
2097
- CODEX_DIR: CODEX_DIR,
2098
- applyCodexPlatformCommand: applyCodexPlatformCommand,
2099
- applyCodexPreset: applyCodexPreset,
2100
- backupCodexAgents: backupCodexAgents,
2101
- backupCodexComplete: backupCodexComplete,
2102
- backupCodexConfig: backupCodexConfig,
2103
- backupCodexFiles: backupCodexFiles,
2104
- backupCodexPrompts: backupCodexPrompts,
2105
- buildCodexGoalsFeatureConfigContent: buildCodexGoalsFeatureConfigContent,
2106
- checkCodexUpdate: checkCodexUpdate,
2107
- configureCodexAiMemoryFeature: configureCodexAiMemoryFeature,
2108
- configureCodexApi: configureCodexApi,
2109
- configureCodexDefaultModelFeature: configureCodexDefaultModelFeature,
2110
- configureCodexMcp: configureCodexMcp,
2111
- configureCodexPresetFeature: configureCodexPresetFeature,
2112
- createBackupDirectory: createBackupDirectory,
2113
- ensureEnvKeyMigration: ensureEnvKeyMigration,
2114
- getBackupMessage: getBackupMessage,
2115
- getCodexPresetDefinitions: getCodexPresetDefinitions,
2116
- getCodexVersion: getCodexVersion,
2117
- installCodexCli: installCodexCli,
2118
- isCodexGoalsFeatureEnabled: isCodexGoalsFeatureEnabled,
2119
- isCodexInstalled: isCodexInstalled,
2120
- listCodexProviders: listCodexProviders,
2121
- migrateEnvKeyInContent: migrateEnvKeyInContent,
2122
- migrateEnvKeyToTempEnvKey: migrateEnvKeyToTempEnvKey,
2123
- needsEnvKeyMigration: needsEnvKeyMigration,
2124
- parseCodexConfig: parseCodexConfig,
2125
- readCodexConfig: readCodexConfig,
2126
- readCodexGoalsFeatureEnabled: readCodexGoalsFeatureEnabled,
2127
- renderCodexConfig: renderCodexConfig,
2128
- runCodexFullInit: runCodexFullInit,
2129
- runCodexSystemPromptSelection: runCodexSystemPromptSelection,
2130
- runCodexUninstall: runCodexUninstall,
2131
- runCodexUpdate: runCodexUpdate,
2132
- runCodexWorkflowImportWithLanguageSelection: runCodexWorkflowImportWithLanguageSelection,
2133
- runCodexWorkflowSelection: runCodexWorkflowSelection,
2134
- setCodexGoalsFeatureInContent: setCodexGoalsFeatureInContent,
2135
- switchToOfficialLogin: switchToOfficialLogin,
2136
- switchToProvider: switchToProvider,
2137
- writeAuthFile: writeAuthFile,
2138
- writeCodexConfig: writeCodexConfig
2139
- };
2140
-
2141
- export { readCodexConfig as a, applyCodexPlatformCommand as b, switchToProvider as c, backupCodexComplete as d, writeAuthFile as e, detectConfigManagementMode as f, readCodexGoalsFeatureEnabled as g, buildCodexGoalsFeatureConfigContent as h, runCodexFullInit as i, runCodexUninstall as j, configureCodexAiMemoryFeature as k, listCodexProviders as l, configureCodexDefaultModelFeature as m, configureCodexMcp as n, configureCodexApi as o, configureCodexPresetFeature as p, runCodexWorkflowImportWithLanguageSelection as q, runCodexUpdate as r, switchToOfficialLogin as s, codex as t, writeCodexConfig as w };