ccjk 12.0.7 → 12.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/package.json +1 -1
  2. package/dist/chunks/agent-teams.mjs +0 -136
  3. package/dist/chunks/agent.mjs +0 -1439
  4. package/dist/chunks/agents.mjs +0 -3778
  5. package/dist/chunks/api-cli.mjs +0 -132
  6. package/dist/chunks/api-providers.mjs +0 -129
  7. package/dist/chunks/api.mjs +0 -112
  8. package/dist/chunks/auto-bootstrap.mjs +0 -358
  9. package/dist/chunks/auto-init.mjs +0 -7584
  10. package/dist/chunks/auto-updater.mjs +0 -410
  11. package/dist/chunks/banner.mjs +0 -188
  12. package/dist/chunks/bash.mjs +0 -187
  13. package/dist/chunks/boost.mjs +0 -397
  14. package/dist/chunks/ccjk-agents.mjs +0 -414
  15. package/dist/chunks/ccjk-all.mjs +0 -1028
  16. package/dist/chunks/ccjk-config.mjs +0 -261
  17. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  18. package/dist/chunks/ccjk-mcp.mjs +0 -761
  19. package/dist/chunks/ccjk-setup.mjs +0 -763
  20. package/dist/chunks/ccjk-skills.mjs +0 -514
  21. package/dist/chunks/ccr.mjs +0 -98
  22. package/dist/chunks/ccu.mjs +0 -40
  23. package/dist/chunks/check-updates.mjs +0 -108
  24. package/dist/chunks/claude-code-config-manager.mjs +0 -750
  25. package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
  26. package/dist/chunks/claude-config.mjs +0 -236
  27. package/dist/chunks/claude-wrapper.mjs +0 -85
  28. package/dist/chunks/cleanup-migration.mjs +0 -20
  29. package/dist/chunks/cli-hook.mjs +0 -2285
  30. package/dist/chunks/cloud-sync.mjs +0 -29
  31. package/dist/chunks/codex-config-switch.mjs +0 -451
  32. package/dist/chunks/codex-provider-manager.mjs +0 -236
  33. package/dist/chunks/codex-uninstaller.mjs +0 -404
  34. package/dist/chunks/codex.mjs +0 -2077
  35. package/dist/chunks/commands.mjs +0 -108
  36. package/dist/chunks/commands2.mjs +0 -413
  37. package/dist/chunks/commit.mjs +0 -138
  38. package/dist/chunks/completion.mjs +0 -515
  39. package/dist/chunks/config-consolidator.mjs +0 -172
  40. package/dist/chunks/config-switch.mjs +0 -317
  41. package/dist/chunks/config.mjs +0 -379
  42. package/dist/chunks/config2.mjs +0 -477
  43. package/dist/chunks/config3.mjs +0 -470
  44. package/dist/chunks/constants.mjs +0 -133
  45. package/dist/chunks/context-loader.mjs +0 -343
  46. package/dist/chunks/context.mjs +0 -372
  47. package/dist/chunks/convoy-manager.mjs +0 -880
  48. package/dist/chunks/dashboard.mjs +0 -476
  49. package/dist/chunks/doctor.mjs +0 -964
  50. package/dist/chunks/evolution.mjs +0 -382
  51. package/dist/chunks/features.mjs +0 -698
  52. package/dist/chunks/fish.mjs +0 -181
  53. package/dist/chunks/fs-operations.mjs +0 -192
  54. package/dist/chunks/health-alerts.mjs +0 -304
  55. package/dist/chunks/health-check.mjs +0 -532
  56. package/dist/chunks/help.mjs +0 -340
  57. package/dist/chunks/hook-installer.mjs +0 -45
  58. package/dist/chunks/index.mjs +0 -24
  59. package/dist/chunks/index10.mjs +0 -1171
  60. package/dist/chunks/index11.mjs +0 -1008
  61. package/dist/chunks/index12.mjs +0 -193
  62. package/dist/chunks/index13.mjs +0 -218
  63. package/dist/chunks/index14.mjs +0 -663
  64. package/dist/chunks/index2.mjs +0 -19
  65. package/dist/chunks/index3.mjs +0 -19092
  66. package/dist/chunks/index4.mjs +0 -8
  67. package/dist/chunks/index5.mjs +0 -7600
  68. package/dist/chunks/index6.mjs +0 -171
  69. package/dist/chunks/index7.mjs +0 -3583
  70. package/dist/chunks/index8.mjs +0 -19
  71. package/dist/chunks/index9.mjs +0 -616
  72. package/dist/chunks/init.mjs +0 -1606
  73. package/dist/chunks/installer.mjs +0 -690
  74. package/dist/chunks/installer2.mjs +0 -179
  75. package/dist/chunks/interview.mjs +0 -2927
  76. package/dist/chunks/json-config.mjs +0 -60
  77. package/dist/chunks/linux.mjs +0 -3863
  78. package/dist/chunks/macos.mjs +0 -69
  79. package/dist/chunks/main.mjs +0 -635
  80. package/dist/chunks/manager.mjs +0 -1048
  81. package/dist/chunks/marketplace.mjs +0 -949
  82. package/dist/chunks/mcp-cli.mjs +0 -204
  83. package/dist/chunks/mcp-performance.mjs +0 -187
  84. package/dist/chunks/mcp.mjs +0 -1231
  85. package/dist/chunks/menu.mjs +0 -652
  86. package/dist/chunks/metrics-display.mjs +0 -153
  87. package/dist/chunks/migrator.mjs +0 -178
  88. package/dist/chunks/monitor.mjs +0 -1856
  89. package/dist/chunks/notification.mjs +0 -1864
  90. package/dist/chunks/onboarding.mjs +0 -385
  91. package/dist/chunks/package.mjs +0 -3
  92. package/dist/chunks/paradigm.mjs +0 -74
  93. package/dist/chunks/permission-manager.mjs +0 -132
  94. package/dist/chunks/permissions.mjs +0 -265
  95. package/dist/chunks/persistence-manager.mjs +0 -794
  96. package/dist/chunks/persistence.mjs +0 -667
  97. package/dist/chunks/platform.mjs +0 -391
  98. package/dist/chunks/plugin.mjs +0 -1936
  99. package/dist/chunks/powershell.mjs +0 -213
  100. package/dist/chunks/prompts.mjs +0 -241
  101. package/dist/chunks/providers.mjs +0 -260
  102. package/dist/chunks/quick-actions.mjs +0 -320
  103. package/dist/chunks/quick-provider.mjs +0 -682
  104. package/dist/chunks/quick-setup.mjs +0 -412
  105. package/dist/chunks/remote.mjs +0 -497
  106. package/dist/chunks/session.mjs +0 -878
  107. package/dist/chunks/sessions.mjs +0 -106
  108. package/dist/chunks/silent-updater.mjs +0 -396
  109. package/dist/chunks/simple-config.mjs +0 -98
  110. package/dist/chunks/skill.mjs +0 -117
  111. package/dist/chunks/skill2.mjs +0 -9003
  112. package/dist/chunks/skills-sync.mjs +0 -6460
  113. package/dist/chunks/skills.mjs +0 -567
  114. package/dist/chunks/slash-commands.mjs +0 -207
  115. package/dist/chunks/smart-defaults.mjs +0 -412
  116. package/dist/chunks/smart-guide.mjs +0 -194
  117. package/dist/chunks/startup.mjs +0 -487
  118. package/dist/chunks/stats.mjs +0 -410
  119. package/dist/chunks/status.mjs +0 -289
  120. package/dist/chunks/team.mjs +0 -63
  121. package/dist/chunks/thinking.mjs +0 -626
  122. package/dist/chunks/trace.mjs +0 -57
  123. package/dist/chunks/uninstall.mjs +0 -849
  124. package/dist/chunks/update.mjs +0 -167
  125. package/dist/chunks/upgrade-manager.mjs +0 -204
  126. package/dist/chunks/version-checker.mjs +0 -881
  127. package/dist/chunks/vim.mjs +0 -903
  128. package/dist/chunks/windows.mjs +0 -14
  129. package/dist/chunks/workflows.mjs +0 -633
  130. package/dist/chunks/wsl.mjs +0 -129
  131. package/dist/chunks/zero-config.mjs +0 -374
  132. package/dist/chunks/zsh.mjs +0 -182
  133. package/dist/cli.d.mts +0 -1
  134. package/dist/cli.d.ts +0 -1
  135. package/dist/cli.mjs +0 -2199
  136. package/dist/i18n/locales/en/agent-teams.json +0 -18
  137. package/dist/i18n/locales/en/agentBrowser.json +0 -79
  138. package/dist/i18n/locales/en/agents.json +0 -135
  139. package/dist/i18n/locales/en/api.json +0 -63
  140. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  141. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  142. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  143. package/dist/i18n/locales/en/ccjk.json +0 -276
  144. package/dist/i18n/locales/en/ccr.json +0 -65
  145. package/dist/i18n/locales/en/claude-md.json +0 -73
  146. package/dist/i18n/locales/en/cli.json +0 -152
  147. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  148. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  149. package/dist/i18n/locales/en/cloud.json +0 -40
  150. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  151. package/dist/i18n/locales/en/codex.json +0 -127
  152. package/dist/i18n/locales/en/cometix.json +0 -29
  153. package/dist/i18n/locales/en/common.json +0 -68
  154. package/dist/i18n/locales/en/config.json +0 -108
  155. package/dist/i18n/locales/en/configuration.json +0 -226
  156. package/dist/i18n/locales/en/context.json +0 -85
  157. package/dist/i18n/locales/en/dashboard.json +0 -78
  158. package/dist/i18n/locales/en/errors.json +0 -26
  159. package/dist/i18n/locales/en/evolution.json +0 -54
  160. package/dist/i18n/locales/en/hooks.json +0 -74
  161. package/dist/i18n/locales/en/hooksSync.json +0 -133
  162. package/dist/i18n/locales/en/installation.json +0 -83
  163. package/dist/i18n/locales/en/interview.json +0 -104
  164. package/dist/i18n/locales/en/language.json +0 -19
  165. package/dist/i18n/locales/en/lsp.json +0 -78
  166. package/dist/i18n/locales/en/marketplace.json +0 -116
  167. package/dist/i18n/locales/en/mcp.json +0 -178
  168. package/dist/i18n/locales/en/memory.json +0 -92
  169. package/dist/i18n/locales/en/menu.json +0 -143
  170. package/dist/i18n/locales/en/multi-config.json +0 -79
  171. package/dist/i18n/locales/en/notification.json +0 -307
  172. package/dist/i18n/locales/en/permissions.json +0 -95
  173. package/dist/i18n/locales/en/persistence.json +0 -127
  174. package/dist/i18n/locales/en/plugins.json +0 -146
  175. package/dist/i18n/locales/en/quick-actions.json +0 -78
  176. package/dist/i18n/locales/en/registry.json +0 -54
  177. package/dist/i18n/locales/en/remote.json +0 -93
  178. package/dist/i18n/locales/en/sandbox.json +0 -44
  179. package/dist/i18n/locales/en/setup.json +0 -44
  180. package/dist/i18n/locales/en/shencha.json +0 -14
  181. package/dist/i18n/locales/en/skills.json +0 -100
  182. package/dist/i18n/locales/en/skillsSync.json +0 -74
  183. package/dist/i18n/locales/en/smartGuide.json +0 -49
  184. package/dist/i18n/locales/en/stats.json +0 -20
  185. package/dist/i18n/locales/en/subagent.json +0 -69
  186. package/dist/i18n/locales/en/superpowers.json +0 -117
  187. package/dist/i18n/locales/en/team.json +0 -7
  188. package/dist/i18n/locales/en/thinking.json +0 -65
  189. package/dist/i18n/locales/en/tools.json +0 -42
  190. package/dist/i18n/locales/en/uninstall.json +0 -56
  191. package/dist/i18n/locales/en/updater.json +0 -29
  192. package/dist/i18n/locales/en/vim.json +0 -169
  193. package/dist/i18n/locales/en/workflow.json +0 -55
  194. package/dist/i18n/locales/en/workspace.json +0 -108
  195. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  196. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
  197. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  198. package/dist/i18n/locales/zh-CN/api.json +0 -63
  199. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  200. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  201. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  202. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  203. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  204. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  205. package/dist/i18n/locales/zh-CN/cli.json +0 -152
  206. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  207. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  208. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  209. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  210. package/dist/i18n/locales/zh-CN/codex.json +0 -127
  211. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  212. package/dist/i18n/locales/zh-CN/common.json +0 -68
  213. package/dist/i18n/locales/zh-CN/config.json +0 -108
  214. package/dist/i18n/locales/zh-CN/configuration.json +0 -224
  215. package/dist/i18n/locales/zh-CN/context.json +0 -85
  216. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  217. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  218. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  219. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  220. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  221. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  222. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  223. package/dist/i18n/locales/zh-CN/language.json +0 -19
  224. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  225. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  226. package/dist/i18n/locales/zh-CN/mcp.json +0 -178
  227. package/dist/i18n/locales/zh-CN/memory.json +0 -92
  228. package/dist/i18n/locales/zh-CN/menu.json +0 -143
  229. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  230. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  231. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  232. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  233. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  234. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  235. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  236. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  237. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  238. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  239. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  240. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  241. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  242. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  243. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  244. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  245. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  246. package/dist/i18n/locales/zh-CN/team.json +0 -7
  247. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  248. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  249. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  250. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  251. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  252. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  253. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  254. package/dist/index.d.mts +0 -5295
  255. package/dist/index.d.ts +0 -5295
  256. package/dist/index.mjs +0 -4941
  257. package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
  258. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  259. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  260. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  261. package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
  262. package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
  263. package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
  264. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  265. package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
  266. package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
  267. package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
  268. package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
  269. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  270. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  271. package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
  272. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  273. package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
  274. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  275. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  276. package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
  277. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  278. package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
  279. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  280. package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
  281. package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
  282. package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
  283. package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
  284. package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
  285. package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
  286. package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
  287. package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
  288. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  289. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  290. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  291. package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
  292. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  293. package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
  294. package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
  295. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  296. package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
  297. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  298. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  299. package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
@@ -1,260 +0,0 @@
1
- import a from './index2.mjs';
2
- import { getApiProviderPresets } from './api-providers.mjs';
3
- import { i18n } from './index5.mjs';
4
- import { P as ProviderHealthMonitor } from '../shared/ccjk.J8YiPsOw.mjs';
5
- import '../shared/ccjk.BAGoDD49.mjs';
6
- import './constants.mjs';
7
- import 'node:os';
8
- import '../shared/ccjk.bQ7Dh1g4.mjs';
9
- import 'node:fs';
10
- import 'node:process';
11
- import 'node:url';
12
-
13
- async function listProviders(options = {}) {
14
- const isZh = i18n.language === "zh-CN";
15
- const codeType = options.codeType || "claude-code";
16
- console.log("");
17
- console.log(a.bold.cyan(isZh ? "\u{1F4CB} \u53EF\u7528\u7684 API \u4F9B\u5E94\u5546" : "\u{1F4CB} Available API Providers"));
18
- console.log(a.dim("\u2500".repeat(60)));
19
- console.log("");
20
- try {
21
- const providers = await getApiProviderPresets(codeType);
22
- if (providers.length === 0) {
23
- console.log(a.yellow(isZh ? "\u672A\u627E\u5230\u4F9B\u5E94\u5546" : "No providers found"));
24
- console.log("");
25
- return;
26
- }
27
- const cloudProviders = providers.filter((p) => p.isCloud);
28
- const localProviders = providers.filter((p) => !p.isCloud);
29
- if (cloudProviders.length > 0) {
30
- console.log(a.bold.green(isZh ? "\u2601\uFE0F \u4E91\u7AEF\u4F9B\u5E94\u5546" : "\u2601\uFE0F Cloud Providers"));
31
- console.log("");
32
- for (const provider of cloudProviders) {
33
- displayProvider(provider, codeType, options.verbose || false, isZh);
34
- }
35
- }
36
- if (localProviders.length > 0) {
37
- if (cloudProviders.length > 0) {
38
- console.log("");
39
- }
40
- console.log(a.bold.blue(isZh ? "\u{1F4BE} \u672C\u5730\u4F9B\u5E94\u5546" : "\u{1F4BE} Local Providers"));
41
- console.log("");
42
- for (const provider of localProviders) {
43
- displayProvider(provider, codeType, options.verbose || false, isZh);
44
- }
45
- }
46
- console.log("");
47
- console.log(a.dim("\u2500".repeat(60)));
48
- console.log(a.dim(isZh ? `\u603B\u8BA1: ${providers.length} \u4E2A\u4F9B\u5E94\u5546 (${cloudProviders.length} \u4E91\u7AEF, ${localProviders.length} \u672C\u5730)` : `Total: ${providers.length} providers (${cloudProviders.length} cloud, ${localProviders.length} local)`));
49
- console.log("");
50
- } catch (error) {
51
- console.error(a.red(isZh ? "\u274C \u83B7\u53D6\u4F9B\u5E94\u5546\u5217\u8868\u5931\u8D25" : "\u274C Failed to fetch providers"));
52
- if (options.verbose && error instanceof Error) {
53
- console.error(a.dim(error.message));
54
- }
55
- console.log("");
56
- }
57
- }
58
- function displayProvider(provider, codeType, verbose, isZh) {
59
- const config = codeType === "codex" ? provider.codex : provider.claudeCode;
60
- console.log(` ${a.bold(provider.name)} ${a.dim(`(${provider.id})`)}`);
61
- if (provider.description) {
62
- console.log(` ${a.dim(provider.description)}`);
63
- }
64
- if (config) {
65
- console.log(` ${a.green(isZh ? "\u63A5\u53E3\u5730\u5740" : "Base URL")}: ${config.baseUrl}`);
66
- if (codeType === "claude-code" && config.authType) {
67
- console.log(` ${a.green(isZh ? "\u8BA4\u8BC1\u65B9\u5F0F" : "Auth Type")}: ${config.authType}`);
68
- }
69
- if (codeType === "codex" && config.wireApi) {
70
- console.log(` ${a.green(isZh ? "\u534F\u8BAE\u7C7B\u578B" : "Wire API")}: ${config.wireApi}`);
71
- }
72
- if (verbose) {
73
- if (config.defaultModels && config.defaultModels.length > 0) {
74
- console.log(` ${a.green(isZh ? "\u9ED8\u8BA4\u6A21\u578B" : "Default Models")}: ${config.defaultModels.join(", ")}`);
75
- }
76
- if (config.defaultModel) {
77
- console.log(` ${a.green(isZh ? "\u9ED8\u8BA4\u6A21\u578B" : "Default Model")}: ${config.defaultModel}`);
78
- }
79
- if (provider.website) {
80
- console.log(` ${a.green(isZh ? "\u5B98\u7F51" : "Website")}: ${provider.website}`);
81
- }
82
- }
83
- }
84
- console.log("");
85
- }
86
- async function checkProvidersHealth(options = {}) {
87
- const isZh = i18n.language === "zh-CN";
88
- const codeType = options.codeType || "claude-code";
89
- console.log("");
90
- console.log(a.bold.cyan(isZh ? "\u{1F3E5} \u4F9B\u5E94\u5546\u5065\u5EB7\u68C0\u67E5" : "\u{1F3E5} Provider Health Check"));
91
- console.log(a.dim("\u2500".repeat(60)));
92
- console.log("");
93
- try {
94
- const providers = await getApiProviderPresets(codeType);
95
- if (providers.length === 0) {
96
- console.log(a.yellow(isZh ? "\u672A\u627E\u5230\u4F9B\u5E94\u5546" : "No providers found"));
97
- console.log("");
98
- return;
99
- }
100
- const monitor = new ProviderHealthMonitor({
101
- timeout: 5e3,
102
- degradedLatencyThreshold: 1e3,
103
- unhealthyLatencyThreshold: 3e3
104
- });
105
- monitor.setProviders(providers);
106
- console.log(a.dim(isZh ? "\u6B63\u5728\u68C0\u67E5\u4F9B\u5E94\u5546\u5065\u5EB7\u72B6\u6001..." : "Checking provider health..."));
107
- console.log("");
108
- const results = await Promise.all(
109
- providers.map(async (provider) => {
110
- const result = await monitor.checkHealth(provider);
111
- return { provider, result };
112
- })
113
- );
114
- for (const { provider, result } of results) {
115
- const statusIcon = result.success ? a.green("\u2705") : a.red("\u274C");
116
- const latencyColor = result.latency < 1e3 ? a.green : result.latency < 3e3 ? a.yellow : a.red;
117
- console.log(`${statusIcon} ${a.bold(provider.name)}`);
118
- if (result.success) {
119
- console.log(` ${a.green(isZh ? "\u5EF6\u8FDF" : "Latency")}: ${latencyColor(`${result.latency}ms`)}`);
120
- console.log(` ${a.green(isZh ? "\u72B6\u6001: \u6B63\u5E38" : "Status: Healthy")}`);
121
- } else {
122
- console.log(` ${a.red(isZh ? "\u72B6\u6001: \u4E0D\u53EF\u7528" : "Status: Unavailable")}`);
123
- if (result.error) {
124
- console.log(` ${a.dim(isZh ? "\u9519\u8BEF" : "Error")}: ${result.error}`);
125
- }
126
- }
127
- console.log("");
128
- }
129
- const healthyCount = results.filter((r) => r.result.success).length;
130
- const unhealthyCount = results.length - healthyCount;
131
- console.log(a.dim("\u2500".repeat(60)));
132
- console.log(a.bold(isZh ? "\u6458\u8981" : "Summary"));
133
- console.log(` ${a.green("\u2705")} ${isZh ? "\u5065\u5EB7" : "Healthy"}: ${healthyCount}`);
134
- console.log(` ${a.red("\u274C")} ${isZh ? "\u4E0D\u53EF\u7528" : "Unavailable"}: ${unhealthyCount}`);
135
- console.log("");
136
- } catch (error) {
137
- console.error(a.red(isZh ? "\u274C \u5065\u5EB7\u68C0\u67E5\u5931\u8D25" : "\u274C Health check failed"));
138
- if (options.verbose && error instanceof Error) {
139
- console.error(a.dim(error.message));
140
- }
141
- console.log("");
142
- }
143
- }
144
- async function recommendProvider(options = {}) {
145
- const isZh = i18n.language === "zh-CN";
146
- const codeType = options.codeType || "claude-code";
147
- console.log("");
148
- console.log(a.bold.cyan(isZh ? "\u{1F3AF} \u4F9B\u5E94\u5546\u63A8\u8350" : "\u{1F3AF} Provider Recommendation"));
149
- console.log(a.dim("\u2500".repeat(60)));
150
- console.log("");
151
- try {
152
- const providers = await getApiProviderPresets(codeType);
153
- if (providers.length === 0) {
154
- console.log(a.yellow(isZh ? "\u672A\u627E\u5230\u4F9B\u5E94\u5546" : "No providers found"));
155
- console.log("");
156
- return;
157
- }
158
- const monitor = new ProviderHealthMonitor({
159
- timeout: 5e3,
160
- degradedLatencyThreshold: 1e3,
161
- unhealthyLatencyThreshold: 3e3
162
- });
163
- monitor.setProviders(providers);
164
- console.log(a.dim(isZh ? "\u6B63\u5728\u5206\u6790\u4F9B\u5E94\u5546\u6027\u80FD..." : "Analyzing provider performance..."));
165
- console.log("");
166
- await Promise.all(
167
- providers.map(async (provider) => {
168
- const result = await monitor.checkHealth(provider);
169
- return result;
170
- })
171
- );
172
- const sortedProviders = monitor.getProvidersByHealth();
173
- const bestProvider = sortedProviders[0];
174
- if (!bestProvider) {
175
- console.log(a.yellow(isZh ? "\u65E0\u6CD5\u786E\u5B9A\u6700\u4F73\u4F9B\u5E94\u5546" : "Unable to determine best provider"));
176
- console.log("");
177
- return;
178
- }
179
- console.log(a.bold.green(isZh ? "\u{1F3C6} \u63A8\u8350\u4F9B\u5E94\u5546" : "\u{1F3C6} Recommended Provider"));
180
- console.log("");
181
- console.log(` ${a.bold.cyan(bestProvider.name)} ${a.dim(`(${bestProvider.id})`)}`);
182
- if (bestProvider.description) {
183
- console.log(` ${a.dim(bestProvider.description)}`);
184
- }
185
- const health = monitor.getProviderHealth(bestProvider.id);
186
- if (health) {
187
- console.log("");
188
- console.log(a.bold(isZh ? "\u6027\u80FD\u6307\u6807" : "Performance Metrics"));
189
- console.log(` ${a.green(isZh ? "\u5EF6\u8FDF" : "Latency")}: ${health.latency.toFixed(0)}ms`);
190
- console.log(` ${a.green(isZh ? "\u6210\u529F\u7387" : "Success Rate")}: ${(health.successRate * 100).toFixed(1)}%`);
191
- console.log(` ${a.green(isZh ? "\u72B6\u6001" : "Status")}: ${getStatusDisplay(health.status, isZh)}`);
192
- }
193
- if (sortedProviders.length > 1) {
194
- console.log("");
195
- console.log(a.bold(isZh ? "\u5907\u9009\u4F9B\u5E94\u5546" : "Alternative Providers"));
196
- console.log("");
197
- for (let i = 1; i < Math.min(4, sortedProviders.length); i++) {
198
- const provider = sortedProviders[i];
199
- const health2 = monitor.getProviderHealth(provider.id);
200
- console.log(` ${i}. ${a.bold(provider.name)} ${a.dim(`(${provider.id})`)}`);
201
- if (health2) {
202
- console.log(` ${a.dim(`${health2.latency.toFixed(0)}ms | ${(health2.successRate * 100).toFixed(1)}% | ${health2.status}`)}`);
203
- }
204
- }
205
- }
206
- console.log("");
207
- console.log(a.dim("\u2500".repeat(60)));
208
- console.log(a.dim(isZh ? '\u{1F4A1} \u63D0\u793A: \u4F7F\u7528 "ccjk config set provider <id>" \u5207\u6362\u4F9B\u5E94\u5546' : '\u{1F4A1} Tip: Use "ccjk config set provider <id>" to switch provider'));
209
- console.log("");
210
- } catch (error) {
211
- console.error(a.red(isZh ? "\u274C \u63A8\u8350\u5931\u8D25" : "\u274C Recommendation failed"));
212
- if (options.verbose && error instanceof Error) {
213
- console.error(a.dim(error.message));
214
- }
215
- console.log("");
216
- }
217
- }
218
- function getStatusDisplay(status, isZh) {
219
- const statusMap = {
220
- healthy: { en: "Healthy", zh: "\u5065\u5EB7", color: a.green },
221
- degraded: { en: "Degraded", zh: "\u964D\u7EA7", color: a.yellow },
222
- unhealthy: { en: "Unhealthy", zh: "\u4E0D\u5065\u5EB7", color: a.red },
223
- unknown: { en: "Unknown", zh: "\u672A\u77E5", color: a.dim }
224
- };
225
- const info = statusMap[status] || statusMap.unknown;
226
- const text = isZh ? info.zh : info.en;
227
- return info.color(text);
228
- }
229
- async function providersCommand(action, options = {}) {
230
- switch (action) {
231
- case "list":
232
- case "ls":
233
- await listProviders(options);
234
- break;
235
- case "health":
236
- case "check":
237
- await checkProvidersHealth(options);
238
- break;
239
- case "recommend":
240
- case "rec":
241
- await recommendProvider(options);
242
- break;
243
- default: {
244
- const isZh = i18n.language === "zh-CN";
245
- console.log("");
246
- console.log(a.bold.cyan(isZh ? "\u{1F4E6} \u4F9B\u5E94\u5546\u7BA1\u7406\u547D\u4EE4" : "\u{1F4E6} Provider Management Commands"));
247
- console.log("");
248
- console.log(` ${a.green("ccjk providers list")} ${isZh ? "\u5217\u51FA\u6240\u6709\u4F9B\u5E94\u5546" : "List all providers"}`);
249
- console.log(` ${a.green("ccjk providers health")} ${isZh ? "\u68C0\u67E5\u4F9B\u5E94\u5546\u5065\u5EB7\u72B6\u6001" : "Check provider health"}`);
250
- console.log(` ${a.green("ccjk providers recommend")} ${isZh ? "\u63A8\u8350\u6700\u4F73\u4F9B\u5E94\u5546" : "Recommend best provider"}`);
251
- console.log("");
252
- console.log(a.bold(isZh ? "\u9009\u9879" : "Options"));
253
- console.log(` ${a.green("--code-type, -T")} <type> ${isZh ? "\u4EE3\u7801\u5DE5\u5177\u7C7B\u578B (claude-code, codex)" : "Code tool type (claude-code, codex)"}`);
254
- console.log(` ${a.green("--verbose, -v")} ${isZh ? "\u8BE6\u7EC6\u8F93\u51FA" : "Verbose output"}`);
255
- console.log("");
256
- }
257
- }
258
- }
259
-
260
- export { checkProvidersHealth, listProviders, providersCommand, recommendProvider };
@@ -1,320 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import a from './index2.mjs';
4
- import { getContextPersistence } from './persistence.mjs';
5
- import { MetricsDisplay } from './metrics-display.mjs';
6
- import { r as runHealthCheck } from '../shared/ccjk.D5MFQT7w.mjs';
7
- import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
8
- import '../shared/ccjk.BAGoDD49.mjs';
9
- import 'better-sqlite3';
10
- import './constants.mjs';
11
- import './index5.mjs';
12
- import 'node:process';
13
- import 'node:url';
14
-
15
- const HABIT_FILE = join(homedir(), ".ccjk", "habits.json");
16
- function loadHabitStats() {
17
- try {
18
- if (!existsSync(HABIT_FILE)) {
19
- return {
20
- totalCommands: 0,
21
- lastUsed: 0,
22
- streak: 0,
23
- longestStreak: 0,
24
- commandCounts: {},
25
- firstUsed: Date.now()
26
- };
27
- }
28
- return JSON.parse(readFileSync(HABIT_FILE, "utf-8"));
29
- } catch {
30
- return {
31
- totalCommands: 0,
32
- lastUsed: 0,
33
- streak: 0,
34
- longestStreak: 0,
35
- commandCounts: {},
36
- firstUsed: Date.now()
37
- };
38
- }
39
- }
40
- function saveHabitStats(stats) {
41
- try {
42
- const dir = join(homedir(), ".ccjk");
43
- if (!existsSync(dir)) {
44
- require("node:fs").mkdirSync(dir, { recursive: true });
45
- }
46
- writeFileSync(HABIT_FILE, JSON.stringify(stats, null, 2), "utf-8");
47
- } catch {
48
- }
49
- }
50
- function updateHabitStats(command) {
51
- const stats = loadHabitStats();
52
- const now = Date.now();
53
- const lastUsedDate = new Date(stats.lastUsed).toDateString();
54
- const todayDate = new Date(now).toDateString();
55
- const yesterdayDate = new Date(now - 24 * 60 * 60 * 1e3).toDateString();
56
- if (lastUsedDate === todayDate) ; else if (lastUsedDate === yesterdayDate) {
57
- stats.streak++;
58
- } else {
59
- stats.streak = 1;
60
- }
61
- if (stats.streak > stats.longestStreak) {
62
- stats.longestStreak = stats.streak;
63
- }
64
- stats.commandCounts[command] = (stats.commandCounts[command] || 0) + 1;
65
- stats.totalCommands++;
66
- stats.lastUsed = now;
67
- saveHabitStats(stats);
68
- return stats;
69
- }
70
- function getDaysUsed() {
71
- const stats = loadHabitStats();
72
- if (stats.totalCommands === 0) return 0;
73
- const firstDate = new Date(stats.firstUsed);
74
- const now = /* @__PURE__ */ new Date();
75
- const diffTime = Math.abs(now.getTime() - firstDate.getTime());
76
- const diffDays = Math.ceil(diffTime / (1e3 * 60 * 60 * 24));
77
- return diffDays;
78
- }
79
- function getMotivationalMessage(stats, tokensSaved, costSavings) {
80
- const messages = [];
81
- if (stats.streak >= 7) {
82
- messages.push(a.green.bold(`\u{1F389} ${stats.streak}-day streak! You're on fire!`));
83
- } else if (stats.streak >= 3) {
84
- messages.push(a.cyan(`\u{1F525} ${stats.streak}-day streak! Keep it going!`));
85
- } else if (stats.streak === 1) {
86
- messages.push(a.yellow(`\u2728 New streak started! Come back tomorrow!`));
87
- }
88
- if (costSavings >= 50) {
89
- messages.push(a.green.bold(`\u{1F4B0} You've saved $${costSavings.toFixed(2)} this week!`));
90
- } else if (costSavings >= 10) {
91
- messages.push(a.cyan(`\u{1F4B5} $${costSavings.toFixed(2)} saved this week!`));
92
- }
93
- if (tokensSaved >= 1e5) {
94
- messages.push(a.magenta.bold(`\u{1F680} ${MetricsDisplay.formatTokenCount(tokensSaved)} tokens saved!`));
95
- } else if (tokensSaved >= 1e4) {
96
- messages.push(a.blue(`\u{1F4CA} ${MetricsDisplay.formatTokenCount(tokensSaved)} tokens saved!`));
97
- }
98
- if (stats.totalCommands === 10) {
99
- messages.push(a.yellow(`\u{1F3AF} 10 commands milestone! You're getting the hang of it!`));
100
- } else if (stats.totalCommands === 50) {
101
- messages.push(a.green(`\u{1F3C6} 50 commands milestone! You're a power user!`));
102
- } else if (stats.totalCommands === 100) {
103
- messages.push(a.magenta.bold(`\u{1F451} 100 commands milestone! You're a CCJK master!`));
104
- }
105
- if (stats.longestStreak >= 30) {
106
- messages.push(a.magenta.bold(`\u{1F3C5} Longest streak: ${stats.longestStreak} days! Legendary!`));
107
- } else if (stats.longestStreak >= 14) {
108
- messages.push(a.green(`\u{1F3C5} Longest streak: ${stats.longestStreak} days!`));
109
- }
110
- return messages.length > 0 ? messages.join("\n ") : "";
111
- }
112
- function getSuggestion(stats) {
113
- const now = Date.now();
114
- const lastUsed = stats.lastUsed;
115
- const hoursSinceLastUse = (now - lastUsed) / (1e3 * 60 * 60);
116
- if (hoursSinceLastUse >= 168) {
117
- return a.yellow(`\u{1F4A1} Tip: Run ${a.cyan("ccjk cleanup")} weekly to keep DB healthy`);
118
- }
119
- if (hoursSinceLastUse >= 24) {
120
- return a.yellow(`\u{1F4A1} Tip: Run ${a.cyan("ccjk review")} to see your daily stats`);
121
- }
122
- if ((stats.commandCounts.commit || 0) < 5) {
123
- return a.yellow(`\u{1F4A1} Tip: Try ${a.cyan("ccjk commit")} for smart commits with compression stats`);
124
- }
125
- const tips = [
126
- `\u{1F4A1} Tip: ${a.cyan("ccjk morning")} gives you a quick health check`,
127
- `\u{1F4A1} Tip: ${a.cyan("ccjk review")} shows your token savings`,
128
- `\u{1F4A1} Tip: ${a.cyan("ccjk cleanup")} keeps your database optimized`
129
- ];
130
- return tips[Math.floor(Math.random() * tips.length)];
131
- }
132
- async function morningCommand(options = {}) {
133
- const stats = updateHabitStats("morning");
134
- if (!options.silent) {
135
- console.log();
136
- console.log(a.cyan.bold("\u2600\uFE0F Good morning! Here's your CCJK status:"));
137
- console.log();
138
- }
139
- try {
140
- const health = await runHealthCheck();
141
- const persistence = getContextPersistence();
142
- const metrics = persistence.getCompressionMetricsStats();
143
- if (options.json) {
144
- console.log(JSON.stringify({
145
- health,
146
- metrics,
147
- habits: stats
148
- }, null, 2));
149
- return;
150
- }
151
- const gradeColor = health.grade === "S" ? a.magenta.bold : health.grade === "A" ? a.green.bold : health.grade === "B" ? a.cyan.bold : health.grade === "C" ? a.yellow.bold : a.red.bold;
152
- console.log(` ${a.gray("Health Score:")} ${gradeColor(health.grade)} ${a.gray(`(${health.totalScore}/100)`)}`);
153
- if (metrics.totalCompressions > 0) {
154
- console.log(` ${a.gray("Total Saved:")} ${a.green(MetricsDisplay.formatTokenCount(metrics.totalTokensSaved))} tokens`);
155
- console.log(` ${a.gray("Cost Savings:")} ${a.green.bold(MetricsDisplay.formatCost(metrics.estimatedCostSavings))}`);
156
- if (metrics.sessionStats && metrics.sessionStats.compressions > 0) {
157
- console.log(` ${a.gray("Last 24h:")} ${a.white(metrics.sessionStats.compressions)} compressions, ${a.green(MetricsDisplay.formatCost(metrics.sessionStats.costSavings))} saved`);
158
- }
159
- }
160
- if (stats.streak > 0) {
161
- console.log(` ${a.gray("Streak:")} ${a.yellow(`${stats.streak} day${stats.streak > 1 ? "s" : ""}`)}`);
162
- }
163
- console.log();
164
- const message = getMotivationalMessage(stats, metrics.totalTokensSaved, metrics.weeklyStats?.costSavings || 0);
165
- if (message) {
166
- console.log(` ${message}`);
167
- console.log();
168
- }
169
- if (health.recommendations.length > 0) {
170
- console.log(a.yellow.bold(" \u{1F4CB} Top Recommendations:"));
171
- for (const rec of health.recommendations.slice(0, 2)) {
172
- const priority = rec.priority === "high" ? a.red("!") : rec.priority === "medium" ? a.yellow("\u2022") : a.gray("\xB7");
173
- console.log(` ${priority} ${rec.title}`);
174
- if (rec.command) {
175
- console.log(` ${a.gray("\u2192")} ${a.cyan(rec.command)}`);
176
- }
177
- }
178
- console.log();
179
- }
180
- const suggestion = getSuggestion(stats);
181
- if (suggestion) {
182
- console.log(` ${suggestion}`);
183
- console.log();
184
- }
185
- } catch (error) {
186
- console.error(a.red("Error running morning command:"), error);
187
- process.exit(1);
188
- }
189
- }
190
- async function reviewCommand(options = {}) {
191
- const stats = updateHabitStats("review");
192
- if (!options.silent) {
193
- console.log();
194
- console.log(a.cyan.bold("\u{1F4CA} Daily Review"));
195
- console.log();
196
- }
197
- try {
198
- const persistence = getContextPersistence();
199
- const metrics = persistence.getCompressionMetricsStats();
200
- if (options.json) {
201
- console.log(JSON.stringify({
202
- metrics,
203
- habits: stats
204
- }, null, 2));
205
- return;
206
- }
207
- console.log(a.cyan.bold(" Overall Statistics"));
208
- console.log(` ${a.gray("Total Compressions:")} ${a.white(metrics.totalCompressions)}`);
209
- console.log(` ${a.gray("Total Saved:")} ${a.green(MetricsDisplay.formatTokenCount(metrics.totalTokensSaved))} tokens`);
210
- console.log(` ${a.gray("Avg Reduction:")} ${a.yellow(MetricsDisplay.formatRatio(metrics.averageCompressionRatio))}`);
211
- console.log(` ${a.gray("Cost Savings:")} ${a.green.bold(MetricsDisplay.formatCost(metrics.estimatedCostSavings))}`);
212
- console.log();
213
- if (metrics.sessionStats && metrics.sessionStats.compressions > 0) {
214
- console.log(a.cyan.bold(" Last 24 Hours"));
215
- console.log(` ${a.gray("Compressions:")} ${a.white(metrics.sessionStats.compressions)}`);
216
- console.log(` ${a.gray("Tokens Saved:")} ${a.green(MetricsDisplay.formatTokenCount(metrics.sessionStats.tokensSaved))}`);
217
- console.log(` ${a.gray("Cost Savings:")} ${a.green(MetricsDisplay.formatCost(metrics.sessionStats.costSavings))}`);
218
- console.log();
219
- }
220
- if (metrics.weeklyStats && metrics.weeklyStats.compressions > 0) {
221
- console.log(a.cyan.bold(" Last 7 Days"));
222
- console.log(` ${a.gray("Compressions:")} ${a.white(metrics.weeklyStats.compressions)}`);
223
- console.log(` ${a.gray("Tokens Saved:")} ${a.green(MetricsDisplay.formatTokenCount(metrics.weeklyStats.tokensSaved))}`);
224
- console.log(` ${a.gray("Cost Savings:")} ${a.green(MetricsDisplay.formatCost(metrics.weeklyStats.costSavings))}`);
225
- console.log();
226
- }
227
- if (metrics.monthlyStats && metrics.monthlyStats.compressions > 0) {
228
- console.log(a.cyan.bold(" Last 30 Days"));
229
- console.log(` ${a.gray("Compressions:")} ${a.white(metrics.monthlyStats.compressions)}`);
230
- console.log(` ${a.gray("Tokens Saved:")} ${a.green(MetricsDisplay.formatTokenCount(metrics.monthlyStats.tokensSaved))}`);
231
- console.log(` ${a.gray("Cost Savings:")} ${a.green(MetricsDisplay.formatCost(metrics.monthlyStats.costSavings))}`);
232
- console.log();
233
- }
234
- console.log(a.cyan.bold(" Your Habits"));
235
- console.log(` ${a.gray("Total Commands:")} ${a.white(stats.totalCommands)}`);
236
- console.log(` ${a.gray("Current Streak:")} ${a.yellow(`${stats.streak} day${stats.streak !== 1 ? "s" : ""}`)}`);
237
- console.log(` ${a.gray("Longest Streak:")} ${a.yellow(`${stats.longestStreak} day${stats.longestStreak !== 1 ? "s" : ""}`)}`);
238
- console.log(` ${a.gray("Days Active:")} ${a.white(getDaysUsed())}`);
239
- console.log();
240
- const message = getMotivationalMessage(stats, metrics.totalTokensSaved, metrics.weeklyStats?.costSavings || 0);
241
- if (message) {
242
- console.log(` ${message}`);
243
- console.log();
244
- }
245
- const suggestion = getSuggestion(stats);
246
- if (suggestion) {
247
- console.log(` ${suggestion}`);
248
- console.log();
249
- }
250
- } catch (error) {
251
- console.error(a.red("Error running review command:"), error);
252
- process.exit(1);
253
- }
254
- }
255
- async function cleanupCommand(options = {}) {
256
- const stats = updateHabitStats("cleanup");
257
- if (!options.silent) {
258
- console.log();
259
- console.log(a.cyan.bold("\u{1F9F9} Database Cleanup"));
260
- console.log();
261
- }
262
- try {
263
- const persistence = getContextPersistence();
264
- const statsBefore = persistence.getStats();
265
- if (!options.silent) {
266
- console.log(` ${a.gray("Database size before:")} ${a.white(MetricsDisplay.formatBytes(statsBefore.totalSize))}`);
267
- console.log(` ${a.gray("Total contexts:")} ${a.white(statsBefore.totalContexts)}`);
268
- console.log();
269
- }
270
- const maxAge = 30 * 24 * 60 * 60 * 1e3;
271
- const deletedContexts = persistence.cleanup(maxAge);
272
- if (!options.silent && deletedContexts > 0) {
273
- console.log(` ${a.green("\u2713")} Deleted ${a.white(deletedContexts)} old context${deletedContexts !== 1 ? "s" : ""}`);
274
- }
275
- const metricsMaxAge = 90 * 24 * 60 * 60 * 1e3;
276
- const deletedMetrics = persistence.cleanupCompressionMetrics(metricsMaxAge);
277
- if (!options.silent && deletedMetrics > 0) {
278
- console.log(` ${a.green("\u2713")} Deleted ${a.white(deletedMetrics)} old metric${deletedMetrics !== 1 ? "s" : ""}`);
279
- }
280
- if (!options.silent) {
281
- console.log(` ${a.gray("Running VACUUM...")}`);
282
- }
283
- persistence.vacuum();
284
- const statsAfter = persistence.getStats();
285
- const sizeSaved = statsBefore.totalSize - statsAfter.totalSize;
286
- if (!options.silent) {
287
- console.log(` ${a.green("\u2713")} VACUUM complete`);
288
- console.log();
289
- console.log(` ${a.gray("Database size after:")} ${a.white(MetricsDisplay.formatBytes(statsAfter.totalSize))}`);
290
- console.log(` ${a.gray("Space reclaimed:")} ${a.green(MetricsDisplay.formatBytes(sizeSaved))}`);
291
- console.log(` ${a.gray("Total contexts:")} ${a.white(statsAfter.totalContexts)}`);
292
- console.log();
293
- console.log(` ${a.green.bold("\u2713 Cleanup complete!")}`);
294
- console.log();
295
- }
296
- if (options.json) {
297
- console.log(JSON.stringify({
298
- deletedContexts,
299
- deletedMetrics,
300
- sizeSaved,
301
- statsBefore,
302
- statsAfter
303
- }, null, 2));
304
- }
305
- if (!options.silent) {
306
- const message = getMotivationalMessage(stats, 0, 0);
307
- if (message) {
308
- console.log(` ${message}`);
309
- console.log();
310
- }
311
- console.log(` ${a.yellow(`\u{1F4A1} Tip: Run cleanup weekly to keep your database healthy`)}`);
312
- console.log();
313
- }
314
- } catch (error) {
315
- console.error(a.red("Error running cleanup command:"), error);
316
- process.exit(1);
317
- }
318
- }
319
-
320
- export { cleanupCommand, morningCommand, reviewCommand };