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,949 +0,0 @@
1
- import a from './index2.mjs';
2
- import { i18n } from './index5.mjs';
3
- import { createHash } from 'node:crypto';
4
- import { existsSync, createWriteStream } from 'node:fs';
5
- import { readFile, mkdir, rm } from 'node:fs/promises';
6
- import { homedir } from 'node:os';
7
- import { Readable } from 'node:stream';
8
- import { pipeline } from 'node:stream/promises';
9
- import { extract } from 'tar';
10
- import { exec as q } from './main.mjs';
11
- import { writeFileAtomicAsync, exists, readJsonFile } from './fs-operations.mjs';
12
- import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
13
- import '../shared/ccjk.BAGoDD49.mjs';
14
- import 'node:process';
15
- import 'node:url';
16
- import 'module';
17
- import 'node:child_process';
18
- import 'node:path';
19
- import 'node:readline';
20
-
21
- const DEFAULT_REGISTRY_URL = "https://registry.api.claudehome.cn/v1";
22
- const DEFAULT_CACHE_CONFIG = {
23
- cacheDir: join(homedir(), ".ccjk", "cache"),
24
- ttl: 3600,
25
- // 1 hour
26
- enabled: true
27
- };
28
- const BUILTIN_PACKAGES = [
29
- // Built-in packages will be added here in future versions
30
- ];
31
- function getCacheFilePath(cacheDir) {
32
- return join(cacheDir, "registry-cache.json");
33
- }
34
- async function isCacheValid(cacheDir, ttl) {
35
- const cachePath = getCacheFilePath(cacheDir);
36
- if (!existsSync(cachePath)) {
37
- return false;
38
- }
39
- try {
40
- const content = await readFile(cachePath, "utf-8");
41
- const cache = JSON.parse(content);
42
- const cacheTime = new Date(cache.lastUpdated).getTime();
43
- const now = Date.now();
44
- return now - cacheTime < ttl * 1e3;
45
- } catch {
46
- return false;
47
- }
48
- }
49
- async function readCachedRegistry(cacheDir) {
50
- const cachePath = getCacheFilePath(cacheDir);
51
- if (!existsSync(cachePath)) {
52
- return null;
53
- }
54
- try {
55
- const content = await readFile(cachePath, "utf-8");
56
- return JSON.parse(content);
57
- } catch {
58
- return null;
59
- }
60
- }
61
- async function writeCacheRegistry(cacheDir, registry) {
62
- await mkdir(cacheDir, { recursive: true });
63
- const cachePath = getCacheFilePath(cacheDir);
64
- await writeFileAtomicAsync(cachePath, JSON.stringify(registry, null, 2));
65
- }
66
- async function fetchRemoteRegistry(registryUrl = DEFAULT_REGISTRY_URL, timeout = 3e4) {
67
- const controller = new AbortController();
68
- const timeoutId = setTimeout(() => controller.abort(), timeout);
69
- try {
70
- const response = await fetch(`${registryUrl}/registry.json`, {
71
- signal: controller.signal,
72
- headers: {
73
- "Accept": "application/json",
74
- "User-Agent": "ccjk-cli"
75
- }
76
- });
77
- if (!response.ok) {
78
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
79
- }
80
- return await response.json();
81
- } finally {
82
- clearTimeout(timeoutId);
83
- }
84
- }
85
- async function getRegistry(options = {}) {
86
- const cacheConfig = { ...DEFAULT_CACHE_CONFIG, ...options.cache };
87
- const registryUrl = options.registryUrl || DEFAULT_REGISTRY_URL;
88
- if (cacheConfig.enabled && !options.forceRefresh) {
89
- const cacheValid = await isCacheValid(cacheConfig.cacheDir, cacheConfig.ttl);
90
- if (cacheValid) {
91
- const cached = await readCachedRegistry(cacheConfig.cacheDir);
92
- if (cached) {
93
- return cached;
94
- }
95
- }
96
- }
97
- try {
98
- const registry = await fetchRemoteRegistry(registryUrl);
99
- if (cacheConfig.enabled) {
100
- await writeCacheRegistry(cacheConfig.cacheDir, registry);
101
- }
102
- return registry;
103
- } catch {
104
- const cached = await readCachedRegistry(cacheConfig.cacheDir);
105
- if (cached) {
106
- return cached;
107
- }
108
- return {
109
- version: "1.0.0",
110
- lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
111
- url: registryUrl,
112
- packages: BUILTIN_PACKAGES,
113
- categories: {
114
- "plugin": 0,
115
- "skill": 0,
116
- "workflow": 0,
117
- "agent": 0,
118
- "mcp-service": 0,
119
- "output-style": 0,
120
- "bundle": 0
121
- }
122
- };
123
- }
124
- }
125
- async function searchPackages(options = {}) {
126
- const registry = await getRegistry();
127
- let packages = [...registry.packages];
128
- if (options.query) {
129
- const query = options.query.toLowerCase();
130
- packages = packages.filter(
131
- (pkg) => pkg.name.toLowerCase().includes(query) || pkg.id.toLowerCase().includes(query) || pkg.keywords.some((k) => k.toLowerCase().includes(query)) || Object.values(pkg.description).some((d) => d.toLowerCase().includes(query))
132
- );
133
- }
134
- if (options.category) {
135
- packages = packages.filter((pkg) => pkg.category === options.category);
136
- }
137
- if (options.author) {
138
- packages = packages.filter(
139
- (pkg) => pkg.author.toLowerCase().includes(options.author.toLowerCase())
140
- );
141
- }
142
- if (options.verified) {
143
- packages = packages.filter((pkg) => pkg.verified === options.verified);
144
- }
145
- if (options.keywords?.length) {
146
- packages = packages.filter(
147
- (pkg) => options.keywords.some((k) => pkg.keywords.includes(k))
148
- );
149
- }
150
- if (options.minRating) {
151
- packages = packages.filter((pkg) => pkg.rating >= options.minRating);
152
- }
153
- if (options.supportedTool) {
154
- packages = packages.filter(
155
- (pkg) => pkg.supportedTools?.includes(options.supportedTool)
156
- );
157
- }
158
- const sortBy = options.sortBy || "downloads";
159
- const sortDir = options.sortDir || "desc";
160
- packages.sort((a, b) => {
161
- let comparison = 0;
162
- switch (sortBy) {
163
- case "downloads":
164
- comparison = a.downloads - b.downloads;
165
- break;
166
- case "rating":
167
- comparison = a.rating - b.rating;
168
- break;
169
- case "updated":
170
- comparison = new Date(a.updatedAt).getTime() - new Date(b.updatedAt).getTime();
171
- break;
172
- case "created":
173
- comparison = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
174
- break;
175
- case "name":
176
- comparison = a.name.localeCompare(b.name);
177
- break;
178
- }
179
- return sortDir === "desc" ? -comparison : comparison;
180
- });
181
- const total = packages.length;
182
- const offset = options.offset || 0;
183
- const limit = options.limit || 20;
184
- packages = packages.slice(offset, offset + limit);
185
- return {
186
- packages,
187
- total,
188
- offset,
189
- limit,
190
- query: options.query,
191
- filters: options
192
- };
193
- }
194
- async function getPackage(packageId) {
195
- const registry = await getRegistry();
196
- return registry.packages.find((pkg) => pkg.id === packageId) || null;
197
- }
198
-
199
- async function resolveDependencies(pkg, visited = /* @__PURE__ */ new Set()) {
200
- if (visited.has(pkg.id)) {
201
- return {
202
- package: pkg,
203
- dependencies: [],
204
- totalCount: 0,
205
- hasCircular: true
206
- };
207
- }
208
- visited.add(pkg.id);
209
- const dependencies = [];
210
- let totalCount = 0;
211
- let hasCircular = false;
212
- if (pkg.dependencies) {
213
- for (const [depId, versionRange] of Object.entries(pkg.dependencies)) {
214
- try {
215
- const depPkg = await getPackage(depId);
216
- if (!depPkg) {
217
- throw new Error(`Dependency not found: ${depId}`);
218
- }
219
- if (!isVersionCompatible(depPkg.version, versionRange)) {
220
- throw new Error(
221
- `Version mismatch for ${depId}: required ${versionRange}, found ${depPkg.version}`
222
- );
223
- }
224
- const nestedTree = await resolveDependencies(depPkg, new Set(visited));
225
- const node = {
226
- package: depPkg,
227
- versionRange,
228
- dependencies: nestedTree.dependencies,
229
- circular: nestedTree.hasCircular
230
- };
231
- dependencies.push(node);
232
- totalCount += 1 + nestedTree.totalCount;
233
- if (nestedTree.hasCircular) {
234
- hasCircular = true;
235
- }
236
- } catch (error) {
237
- throw new Error(
238
- `Failed to resolve dependency ${depId}: ${error instanceof Error ? error.message : String(error)}`
239
- );
240
- }
241
- }
242
- }
243
- return {
244
- package: pkg,
245
- dependencies,
246
- totalCount,
247
- hasCircular
248
- };
249
- }
250
- function isVersionCompatible(version, range) {
251
- if (range === "*") {
252
- return true;
253
- }
254
- const versionParts = parseVersion(version);
255
- if (!versionParts) {
256
- return false;
257
- }
258
- if (!range.match(/^[~^><]/)) {
259
- return version === range;
260
- }
261
- if (range.startsWith("^")) {
262
- const rangeParts = parseVersion(range.slice(1));
263
- if (!rangeParts) {
264
- return false;
265
- }
266
- return versionParts.major === rangeParts.major && (versionParts.minor > rangeParts.minor || versionParts.minor === rangeParts.minor && versionParts.patch >= rangeParts.patch);
267
- }
268
- if (range.startsWith("~")) {
269
- const rangeParts = parseVersion(range.slice(1));
270
- if (!rangeParts) {
271
- return false;
272
- }
273
- return versionParts.major === rangeParts.major && versionParts.minor === rangeParts.minor && versionParts.patch >= rangeParts.patch;
274
- }
275
- if (range.startsWith(">=")) {
276
- const rangeParts = parseVersion(range.slice(2));
277
- if (!rangeParts) {
278
- return false;
279
- }
280
- return compareVersions(versionParts, rangeParts) >= 0;
281
- }
282
- if (range.startsWith(">")) {
283
- const rangeParts = parseVersion(range.slice(1));
284
- if (!rangeParts) {
285
- return false;
286
- }
287
- return compareVersions(versionParts, rangeParts) > 0;
288
- }
289
- if (range.startsWith("<=")) {
290
- const rangeParts = parseVersion(range.slice(2));
291
- if (!rangeParts) {
292
- return false;
293
- }
294
- return compareVersions(versionParts, rangeParts) <= 0;
295
- }
296
- if (range.startsWith("<")) {
297
- const rangeParts = parseVersion(range.slice(1));
298
- if (!rangeParts) {
299
- return false;
300
- }
301
- return compareVersions(versionParts, rangeParts) < 0;
302
- }
303
- return false;
304
- }
305
- function parseVersion(version) {
306
- const match = version.trim().match(/^(\d+)\.(\d+)\.(\d+)/);
307
- if (!match) {
308
- return null;
309
- }
310
- return {
311
- major: Number.parseInt(match[1], 10),
312
- minor: Number.parseInt(match[2], 10),
313
- patch: Number.parseInt(match[3], 10)
314
- };
315
- }
316
- function compareVersions(a, b) {
317
- if (a.major !== b.major) {
318
- return a.major - b.major;
319
- }
320
- if (a.minor !== b.minor) {
321
- return a.minor - b.minor;
322
- }
323
- return a.patch - b.patch;
324
- }
325
-
326
- const DEFAULT_INSTALL_DIR = join(homedir(), ".ccjk", "packages");
327
- const INSTALLED_MANIFEST = join(homedir(), ".ccjk", "installed-packages.json");
328
- const MAX_DOWNLOAD_RETRIES = 3;
329
- const DOWNLOAD_RETRY_DELAY = 2e3;
330
- const DOWNLOAD_TIMEOUT = 3e4;
331
- async function getInstalledPackages() {
332
- if (!existsSync(INSTALLED_MANIFEST)) {
333
- return [];
334
- }
335
- try {
336
- const content = await readFile(INSTALLED_MANIFEST, "utf-8");
337
- return JSON.parse(content);
338
- } catch {
339
- return [];
340
- }
341
- }
342
- async function saveInstalledPackages(packages) {
343
- const dir = join(homedir(), ".ccjk");
344
- await mkdir(dir, { recursive: true });
345
- await writeFileAtomicAsync(INSTALLED_MANIFEST, JSON.stringify(packages, null, 2));
346
- }
347
- async function isPackageInstalled(packageId) {
348
- const installed = await getInstalledPackages();
349
- return installed.some((pkg) => pkg.package.id === packageId);
350
- }
351
- async function downloadPackage(url, destPath, retries = MAX_DOWNLOAD_RETRIES) {
352
- let lastError = null;
353
- for (let attempt = 1; attempt <= retries; attempt++) {
354
- try {
355
- await mkdir(join(destPath, ".."), { recursive: true });
356
- const controller = new AbortController();
357
- const timeoutId = setTimeout(() => controller.abort(), DOWNLOAD_TIMEOUT);
358
- try {
359
- const response = await fetch(url, {
360
- signal: controller.signal
361
- });
362
- if (!response.ok) {
363
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
364
- }
365
- if (!response.body) {
366
- throw new Error("Response body is null");
367
- }
368
- const fileStream = createWriteStream(destPath);
369
- await pipeline(
370
- Readable.fromWeb(response.body),
371
- fileStream
372
- );
373
- clearTimeout(timeoutId);
374
- return true;
375
- } catch (error) {
376
- clearTimeout(timeoutId);
377
- throw error;
378
- }
379
- } catch (error) {
380
- lastError = error instanceof Error ? error : new Error(String(error));
381
- if (lastError.name === "AbortError") {
382
- throw new Error(`Download timeout after ${DOWNLOAD_TIMEOUT}ms`);
383
- }
384
- if (attempt < retries) {
385
- await new Promise((resolve) => setTimeout(resolve, DOWNLOAD_RETRY_DELAY * attempt));
386
- }
387
- }
388
- }
389
- throw new Error(
390
- `Failed to download package after ${retries} attempts: ${lastError?.message || "Unknown error"}`
391
- );
392
- }
393
- async function verifyChecksum(filePath, expectedChecksum) {
394
- try {
395
- const fileBuffer = await readFile(filePath);
396
- const hash = createHash("sha256");
397
- hash.update(fileBuffer);
398
- const actualChecksum = hash.digest("hex");
399
- if (actualChecksum !== expectedChecksum) {
400
- throw new Error(
401
- `Checksum mismatch: expected ${expectedChecksum}, got ${actualChecksum}`
402
- );
403
- }
404
- return true;
405
- } catch (error) {
406
- throw new Error(
407
- `Checksum verification failed: ${error instanceof Error ? error.message : String(error)}`
408
- );
409
- }
410
- }
411
- async function extractPackage(archivePath, destDir) {
412
- try {
413
- await mkdir(destDir, { recursive: true });
414
- if (archivePath.endsWith(".tar.gz") || archivePath.endsWith(".tgz")) {
415
- await extract({
416
- file: archivePath,
417
- cwd: destDir,
418
- strip: 1
419
- // Strip top-level directory
420
- });
421
- } else if (archivePath.endsWith(".zip")) {
422
- const result = await q("unzip", ["-q", "-o", archivePath, "-d", destDir]);
423
- if (result.exitCode !== 0) {
424
- throw new Error(`Unzip failed: ${result.stderr || "Unknown error"}`);
425
- }
426
- } else {
427
- throw new Error(`Unsupported archive format: ${archivePath}`);
428
- }
429
- } catch (error) {
430
- throw new Error(
431
- `Failed to extract package: ${error instanceof Error ? error.message : String(error)}`
432
- );
433
- }
434
- }
435
- async function runPostInstall(installPath, manifest) {
436
- if (!manifest.postInstall) {
437
- return;
438
- }
439
- try {
440
- const scriptPath = join(installPath, manifest.postInstall);
441
- if (!exists(scriptPath)) {
442
- throw new Error(`Post-install script not found: ${scriptPath}`);
443
- }
444
- const result = await q("node", [scriptPath], {
445
- nodeOptions: {
446
- cwd: installPath
447
- }
448
- });
449
- if (result.exitCode !== 0) {
450
- throw new Error(`Script exited with code ${result.exitCode}: ${result.stderr || ""}`);
451
- }
452
- } catch (error) {
453
- throw new Error(
454
- `Post-install script failed: ${error instanceof Error ? error.message : String(error)}`
455
- );
456
- }
457
- }
458
- async function rollbackInstallation(installPath, archivePath) {
459
- try {
460
- if (existsSync(installPath)) {
461
- await rm(installPath, { recursive: true, force: true });
462
- }
463
- if (archivePath && existsSync(archivePath)) {
464
- await rm(archivePath, { force: true });
465
- }
466
- } catch (error) {
467
- console.error("Rollback failed:", error);
468
- }
469
- }
470
- async function installPackage(packageId, options = {}) {
471
- const startTime = Date.now();
472
- let archivePath;
473
- let installPath;
474
- try {
475
- const alreadyInstalled = await isPackageInstalled(packageId);
476
- if (alreadyInstalled && !options.force) {
477
- const pkg2 = await getPackage(packageId);
478
- if (!pkg2) {
479
- return {
480
- success: false,
481
- package: {},
482
- error: i18n.t("marketplace:packageNotFound", { name: packageId })
483
- };
484
- }
485
- return {
486
- success: true,
487
- package: pkg2,
488
- alreadyInstalled: true,
489
- durationMs: Date.now() - startTime
490
- };
491
- }
492
- const pkg = await getPackage(packageId);
493
- if (!pkg) {
494
- return {
495
- success: false,
496
- package: {},
497
- error: i18n.t("marketplace:packageNotFound", { name: packageId })
498
- };
499
- }
500
- if (!pkg.downloadUrl) {
501
- return {
502
- success: false,
503
- package: pkg,
504
- error: i18n.t("marketplace:noDownloadUrl", { name: pkg.name })
505
- };
506
- }
507
- const warnings = [];
508
- if (options.codeToolType && pkg.supportedTools) {
509
- if (!pkg.supportedTools.includes(options.codeToolType)) {
510
- warnings.push(
511
- i18n.t("marketplace:incompatibleTool", {
512
- tool: options.codeToolType,
513
- supported: pkg.supportedTools.join(", ")
514
- })
515
- );
516
- }
517
- }
518
- const dependencyResults = [];
519
- if (options.installDependencies !== false && pkg.dependencies) {
520
- try {
521
- const dependencyTree = await resolveDependencies(pkg);
522
- for (const dep of dependencyTree.dependencies) {
523
- const depResult = await installPackage(dep.package.id, {
524
- ...options,
525
- installDependencies: true
526
- // Recursive dependency installation
527
- });
528
- dependencyResults.push(depResult);
529
- if (!depResult.success) {
530
- throw new Error(
531
- `Failed to install dependency ${dep.package.id}: ${depResult.error}`
532
- );
533
- }
534
- }
535
- } catch (error) {
536
- return {
537
- success: false,
538
- package: pkg,
539
- error: `Dependency resolution failed: ${error instanceof Error ? error.message : String(error)}`,
540
- durationMs: Date.now() - startTime
541
- };
542
- }
543
- }
544
- const targetDir = options.targetDir || DEFAULT_INSTALL_DIR;
545
- installPath = join(targetDir, pkg.id);
546
- await mkdir(installPath, { recursive: true });
547
- const archiveExt = pkg.downloadUrl.endsWith(".zip") ? ".zip" : ".tar.gz";
548
- archivePath = join(targetDir, `${pkg.id}-${pkg.version}${archiveExt}`);
549
- try {
550
- await downloadPackage(pkg.downloadUrl, archivePath);
551
- } catch (error) {
552
- throw new Error(
553
- `Download failed: ${error instanceof Error ? error.message : String(error)}`
554
- );
555
- }
556
- if (pkg.checksum && !options.skipChecksum) {
557
- try {
558
- await verifyChecksum(archivePath, pkg.checksum);
559
- } catch (error) {
560
- throw new Error(
561
- `Checksum verification failed: ${error instanceof Error ? error.message : String(error)}`
562
- );
563
- }
564
- }
565
- try {
566
- await extractPackage(archivePath, installPath);
567
- } catch (error) {
568
- throw new Error(
569
- `Extraction failed: ${error instanceof Error ? error.message : String(error)}`
570
- );
571
- }
572
- const manifestPath = join(installPath, "ccjk.json");
573
- let manifest = null;
574
- if (exists(manifestPath)) {
575
- try {
576
- manifest = readJsonFile(manifestPath);
577
- } catch (error) {
578
- warnings.push(
579
- `Failed to read package manifest: ${error instanceof Error ? error.message : String(error)}`
580
- );
581
- }
582
- }
583
- if (manifest?.postInstall) {
584
- try {
585
- await runPostInstall(installPath, manifest);
586
- } catch (error) {
587
- warnings.push(
588
- `Post-install script failed: ${error instanceof Error ? error.message : String(error)}`
589
- );
590
- }
591
- }
592
- if (archivePath && existsSync(archivePath)) {
593
- await rm(archivePath, { force: true });
594
- }
595
- const installed = await getInstalledPackages();
596
- const installedPackage = {
597
- package: pkg,
598
- path: installPath,
599
- installedAt: (/* @__PURE__ */ new Date()).toISOString(),
600
- source: "marketplace",
601
- enabled: true
602
- };
603
- const existingIndex = installed.findIndex((p) => p.package.id === pkg.id);
604
- if (existingIndex >= 0) {
605
- installed[existingIndex] = installedPackage;
606
- } else {
607
- installed.push(installedPackage);
608
- }
609
- await saveInstalledPackages(installed);
610
- return {
611
- success: true,
612
- package: pkg,
613
- installedPath: installPath,
614
- dependencies: dependencyResults.length > 0 ? dependencyResults : void 0,
615
- warnings: warnings.length > 0 ? warnings : void 0,
616
- durationMs: Date.now() - startTime
617
- };
618
- } catch (error) {
619
- if (installPath) {
620
- await rollbackInstallation(installPath, archivePath);
621
- }
622
- return {
623
- success: false,
624
- package: {},
625
- error: error instanceof Error ? error.message : String(error),
626
- durationMs: Date.now() - startTime
627
- };
628
- }
629
- }
630
- async function uninstallPackage(packageId, options = {}) {
631
- try {
632
- const installed = await getInstalledPackages();
633
- const pkg = installed.find((p) => p.package.id === packageId);
634
- if (!pkg) {
635
- return {
636
- success: false,
637
- packageId,
638
- error: i18n.t("marketplace:packageNotInstalled", { name: packageId })
639
- };
640
- }
641
- if (!options.force) {
642
- const dependents = installed.filter(
643
- (p) => p.package.dependencies && Object.keys(p.package.dependencies).includes(packageId)
644
- );
645
- if (dependents.length > 0) {
646
- return {
647
- success: false,
648
- packageId,
649
- error: i18n.t("marketplace:packageHasDependents", {
650
- name: packageId,
651
- dependents: dependents.map((p) => p.package.name).join(", ")
652
- })
653
- };
654
- }
655
- }
656
- if (existsSync(pkg.path)) {
657
- await rm(pkg.path, { recursive: true, force: true });
658
- }
659
- const updated = installed.filter((p) => p.package.id !== packageId);
660
- await saveInstalledPackages(updated);
661
- return {
662
- success: true,
663
- packageId
664
- };
665
- } catch (error) {
666
- return {
667
- success: false,
668
- packageId,
669
- error: error instanceof Error ? error.message : String(error)
670
- };
671
- }
672
- }
673
- async function updatePackage(packageId) {
674
- const uninstallResult = await uninstallPackage(packageId, { keepConfig: true });
675
- if (!uninstallResult.success) {
676
- return {
677
- success: false,
678
- package: {},
679
- error: uninstallResult.error
680
- };
681
- }
682
- return await installPackage(packageId, { force: true });
683
- }
684
- async function checkForUpdates() {
685
- const installed = await getInstalledPackages();
686
- const updates = [];
687
- for (const installedPkg of installed) {
688
- const latestPkg = await getPackage(installedPkg.package.id);
689
- if (!latestPkg)
690
- continue;
691
- if (latestPkg.version !== installedPkg.package.version) {
692
- updates.push({
693
- id: installedPkg.package.id,
694
- currentVersion: installedPkg.package.version,
695
- latestVersion: latestPkg.version,
696
- breaking: false,
697
- // TODO: Implement semver comparison
698
- changelog: latestPkg.changelog,
699
- releaseDate: latestPkg.updatedAt
700
- });
701
- }
702
- }
703
- return updates;
704
- }
705
-
706
- async function searchCommand(query, _options) {
707
- try {
708
- console.log(a.green(i18n.t("marketplace:searching", { query })));
709
- const results = await searchPackages({ query });
710
- if (results.packages.length === 0) {
711
- console.log(a.yellow(i18n.t("marketplace:noResults")));
712
- return;
713
- }
714
- console.log(a.green(i18n.t("marketplace:searchResults", { count: results.packages.length })));
715
- console.log();
716
- for (const pkg of results.packages) {
717
- const installed = await isPackageInstalled(pkg.name);
718
- const installedMark = installed ? a.green("\u2713") : a.gray("\u25CB");
719
- console.log(`${installedMark} ${a.bold(pkg.name)} ${a.gray(`v${pkg.version}`)}`);
720
- console.log(` ${pkg.description.en || Object.values(pkg.description)[0]}`);
721
- console.log(` ${a.gray(i18n.t("marketplace:packageInfo.category"))}: ${pkg.category}`);
722
- if (pkg.verified === "verified") {
723
- console.log(` ${a.green("\u2713")} ${i18n.t("marketplace:packageInfo.verified")}`);
724
- }
725
- console.log();
726
- }
727
- } catch (err) {
728
- console.error(a.red(i18n.t("marketplace:searchFailed")));
729
- console.error(err);
730
- throw err;
731
- }
732
- }
733
- async function installCommand(packageName, options) {
734
- try {
735
- if (await isPackageInstalled(packageName)) {
736
- console.log(a.yellow(`Package '${packageName}' is already installed`));
737
- return;
738
- }
739
- const pkg = await getPackage(packageName);
740
- if (!pkg) {
741
- console.error(a.red(i18n.t("marketplace:packageNotFound", { name: packageName })));
742
- throw new Error(`Package not found: ${packageName}`);
743
- }
744
- console.log(a.green(i18n.t("marketplace:installing", { name: packageName })));
745
- const result = await installPackage(packageName, {
746
- force: options.force,
747
- skipVerification: options.skipVerification
748
- });
749
- if (result.success) {
750
- console.log(a.green(i18n.t("marketplace:installSuccess", { name: packageName })));
751
- if (result.installedPath) {
752
- console.log(a.gray(`${i18n.t("marketplace:installedAt")}: ${result.installedPath}`));
753
- }
754
- } else {
755
- console.error(a.red(i18n.t("marketplace:installFailed", { name: packageName })));
756
- if (result.error) {
757
- console.error(a.red(i18n.t("marketplace:errors.installError", { error: result.error })));
758
- }
759
- throw new Error(`Install failed: ${packageName}`);
760
- }
761
- } catch (err) {
762
- console.error(a.red(i18n.t("marketplace:installFailed", { name: packageName })));
763
- console.error(err);
764
- throw err;
765
- }
766
- }
767
- async function uninstallCommand(packageName, options) {
768
- try {
769
- if (!await isPackageInstalled(packageName)) {
770
- console.error(a.red(i18n.t("marketplace:packageNotInstalled", { name: packageName })));
771
- throw new Error(`Package not installed: ${packageName}`);
772
- }
773
- console.log(a.green(i18n.t("marketplace:uninstalling", { name: packageName })));
774
- const result = await uninstallPackage(packageName, {
775
- force: options.force
776
- });
777
- if (result.success) {
778
- console.log(a.green(i18n.t("marketplace:uninstallSuccess", { name: packageName })));
779
- } else {
780
- console.error(a.red(i18n.t("marketplace:uninstallFailed", { name: packageName })));
781
- if (result.error) {
782
- console.error(a.red(i18n.t("marketplace:errors.uninstallError", { error: result.error })));
783
- }
784
- throw new Error(`Uninstall failed: ${packageName}`);
785
- }
786
- } catch (err) {
787
- console.error(a.red(i18n.t("marketplace:uninstallFailed", { name: packageName })));
788
- console.error(err);
789
- throw err;
790
- }
791
- }
792
- async function updateCommand(packageName, _options) {
793
- try {
794
- if (packageName) {
795
- console.log(a.green(i18n.t("marketplace:updating", { name: packageName })));
796
- const result = await updatePackage(packageName);
797
- if (result.success) {
798
- console.log(a.green(i18n.t("marketplace:updateSuccess", { name: packageName })));
799
- } else {
800
- console.error(a.red(i18n.t("marketplace:updateFailed", { name: packageName })));
801
- if (result.error) {
802
- console.error(a.red(result.error));
803
- }
804
- throw new Error(`Update failed: ${packageName}`);
805
- }
806
- } else {
807
- console.log(a.green(i18n.t("marketplace:checkingUpdates")));
808
- const updates = await checkForUpdates();
809
- if (updates.length === 0) {
810
- console.log(a.green(i18n.t("marketplace:noUpdates")));
811
- return;
812
- }
813
- console.log(a.yellow(i18n.t("marketplace:updatesAvailable", { count: updates.length })));
814
- console.log();
815
- for (const update of updates) {
816
- console.log(` ${a.bold(update.id)}: ${a.gray(update.currentVersion)} \u2192 ${a.green(update.latestVersion)}`);
817
- }
818
- console.log();
819
- console.log(a.gray(i18n.t("marketplace:updateHint")));
820
- }
821
- } catch (err) {
822
- console.error(a.red(i18n.t("marketplace:updateCheckFailed")));
823
- console.error(err);
824
- throw err;
825
- }
826
- }
827
- async function listCommand(_options) {
828
- try {
829
- const installedList = await getInstalledPackages();
830
- if (installedList.length === 0) {
831
- console.log(a.yellow(i18n.t("marketplace:noInstalled")));
832
- return;
833
- }
834
- console.log(a.green(i18n.t("marketplace:installedPackages", { count: installedList.length })));
835
- console.log();
836
- for (const installed of installedList) {
837
- const pkg = installed.package;
838
- console.log(`${a.green("\u2713")} ${a.bold(pkg.name)} ${a.gray(`v${pkg.version}`)}`);
839
- console.log(` ${pkg.description.en || Object.values(pkg.description)[0]}`);
840
- console.log(` ${a.gray(i18n.t("marketplace:packageInfo.category"))}: ${pkg.category}`);
841
- console.log();
842
- }
843
- } catch (err) {
844
- console.error(a.red(i18n.t("marketplace:listFailed")));
845
- console.error(err);
846
- throw err;
847
- }
848
- }
849
- async function infoCommand(packageName, _options) {
850
- try {
851
- const pkg = await getPackage(packageName);
852
- if (!pkg) {
853
- console.error(a.red(i18n.t("marketplace:packageNotFound", { name: packageName })));
854
- throw new Error(`Package not found: ${packageName}`);
855
- }
856
- const installed = await isPackageInstalled(packageName);
857
- console.log();
858
- console.log(a.bold.cyan(pkg.name));
859
- console.log(a.gray("\u2500".repeat(50)));
860
- console.log();
861
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.description"))}: ${pkg.description.en || Object.values(pkg.description)[0]}`);
862
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.version"))}: ${pkg.version}`);
863
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.category"))}: ${pkg.category}`);
864
- if (pkg.author) {
865
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.author"))}: ${pkg.author}`);
866
- }
867
- if (pkg.license) {
868
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.license"))}: ${pkg.license}`);
869
- }
870
- if (pkg.repository) {
871
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.repository"))}: ${pkg.repository}`);
872
- }
873
- if (pkg.downloads !== void 0) {
874
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.downloads"))}: ${pkg.downloads.toLocaleString()}`);
875
- }
876
- if (pkg.rating !== void 0) {
877
- const stars = "\u2605".repeat(Math.round(pkg.rating));
878
- const emptyStars = "\u2606".repeat(5 - Math.round(pkg.rating));
879
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.rating"))}: ${a.yellow(stars)}${a.gray(emptyStars)} (${pkg.rating}/5)`);
880
- }
881
- if (pkg.keywords && pkg.keywords.length > 0) {
882
- console.log(`${a.bold(i18n.t("marketplace:packageInfo.keywords"))}: ${pkg.keywords.join(", ")}`);
883
- }
884
- if (pkg.verified === "verified") {
885
- console.log(`${a.green("\u2713")} ${i18n.t("marketplace:packageInfo.verified")}`);
886
- }
887
- console.log();
888
- console.log(`${a.bold("Status")}: ${installed ? a.green("Installed") : a.gray("Not installed")}`);
889
- console.log();
890
- } catch (err) {
891
- console.error(a.red(i18n.t("marketplace:infoFailed")));
892
- console.error(err);
893
- throw err;
894
- }
895
- }
896
- async function marketplaceMenu(action, options) {
897
- const opts = options || {};
898
- if (!action) {
899
- console.log(a.green("\n\u{1F6D2} Marketplace Commands:\n"));
900
- console.log(" ccjk cloud plugins search <query> - Search packages");
901
- console.log(" ccjk cloud plugins install <pkg> - Install package");
902
- console.log(" ccjk cloud plugins uninstall <pkg> - Uninstall package");
903
- console.log(" ccjk cloud plugins update [pkg] - Update packages");
904
- console.log(" ccjk cloud plugins list - List installed");
905
- console.log(" ccjk cloud plugins info <pkg> - Package details\n");
906
- return;
907
- }
908
- const args = action.split(" ");
909
- const cmd = args[0];
910
- const param = args.slice(1).join(" ");
911
- switch (cmd) {
912
- case "search":
913
- if (param)
914
- await searchCommand(param);
915
- else
916
- console.log(a.yellow("Usage: ccjk cloud plugins search <query>"));
917
- break;
918
- case "install":
919
- if (param)
920
- await installCommand(param, opts);
921
- else
922
- console.log(a.yellow("Usage: ccjk cloud plugins install <package>"));
923
- break;
924
- case "uninstall":
925
- if (param)
926
- await uninstallCommand(param, opts);
927
- else
928
- console.log(a.yellow("Usage: ccjk cloud plugins uninstall <package>"));
929
- break;
930
- case "update":
931
- await updateCommand(param || void 0);
932
- break;
933
- case "list":
934
- case "ls":
935
- await listCommand();
936
- break;
937
- case "info":
938
- if (param)
939
- await infoCommand(param);
940
- else
941
- console.log(a.yellow("Usage: ccjk cloud plugins info <package>"));
942
- break;
943
- default:
944
- console.log(a.yellow(`Unknown action: ${cmd}`));
945
- await marketplaceMenu(void 0, opts);
946
- }
947
- }
948
-
949
- export { marketplaceMenu };