ccjk 15.28.2 → 15.29.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 (436) hide show
  1. package/README.md +5 -4
  2. package/dist/chunks/agent-teams.mjs +145 -0
  3. package/dist/chunks/agent.mjs +1439 -0
  4. package/dist/chunks/agents.mjs +3783 -0
  5. package/dist/chunks/api-cli.mjs +135 -0
  6. package/dist/chunks/api-config-selector.mjs +159 -0
  7. package/dist/chunks/api-providers.mjs +144 -0
  8. package/dist/chunks/api.mjs +115 -0
  9. package/dist/chunks/auto-bootstrap.mjs +358 -0
  10. package/dist/chunks/auto-fixer.mjs +95 -0
  11. package/dist/chunks/auto-updater.mjs +507 -0
  12. package/dist/chunks/banner.mjs +173 -0
  13. package/dist/chunks/bash.mjs +187 -0
  14. package/dist/chunks/boost.mjs +474 -0
  15. package/dist/chunks/brain-config.mjs +75 -0
  16. package/dist/chunks/brain-status.mjs +89 -0
  17. package/dist/chunks/ccjk-agents.mjs +416 -0
  18. package/dist/chunks/ccjk-all.mjs +1046 -0
  19. package/dist/chunks/ccjk-config.mjs +445 -0
  20. package/dist/chunks/ccjk-hooks.mjs +1074 -0
  21. package/dist/chunks/ccjk-mcp.mjs +763 -0
  22. package/dist/chunks/ccjk-setup.mjs +765 -0
  23. package/dist/chunks/ccjk-skills.mjs +518 -0
  24. package/dist/chunks/ccr.mjs +109 -0
  25. package/dist/chunks/ccu.mjs +40 -0
  26. package/dist/chunks/check-updates.mjs +117 -0
  27. package/dist/chunks/claude-code-incremental-manager.mjs +761 -0
  28. package/dist/chunks/claude-config.mjs +606 -0
  29. package/dist/chunks/claude-config2.mjs +62 -0
  30. package/dist/chunks/claude-wrapper.mjs +85 -0
  31. package/dist/chunks/clavue-config.mjs +1454 -0
  32. package/dist/chunks/cleanup-migration.mjs +20 -0
  33. package/dist/chunks/cli-hook.mjs +4096 -0
  34. package/dist/chunks/cloud-sync.mjs +29 -0
  35. package/dist/chunks/code-type-resolver.mjs +880 -0
  36. package/dist/chunks/codex-config-switch.mjs +452 -0
  37. package/dist/chunks/codex-provider-manager.mjs +238 -0
  38. package/dist/chunks/codex-uninstaller.mjs +404 -0
  39. package/dist/chunks/codex.mjs +2141 -0
  40. package/dist/chunks/commands.mjs +108 -0
  41. package/dist/chunks/commands2.mjs +421 -0
  42. package/dist/chunks/commit.mjs +140 -0
  43. package/dist/chunks/completion.mjs +517 -0
  44. package/dist/chunks/config-consolidator.mjs +172 -0
  45. package/dist/chunks/config-switch.mjs +334 -0
  46. package/dist/chunks/config.mjs +558 -0
  47. package/dist/chunks/config2.mjs +484 -0
  48. package/dist/chunks/config3.mjs +486 -0
  49. package/dist/chunks/constants.mjs +323 -0
  50. package/dist/chunks/context-opt.mjs +444 -0
  51. package/dist/chunks/context.mjs +974 -0
  52. package/dist/chunks/dashboard.mjs +481 -0
  53. package/dist/chunks/doctor.mjs +1301 -0
  54. package/dist/chunks/eval.mjs +502 -0
  55. package/dist/chunks/evolution.mjs +322 -0
  56. package/dist/chunks/features.mjs +715 -0
  57. package/dist/chunks/fish.mjs +181 -0
  58. package/dist/chunks/fs-operations.mjs +180 -0
  59. package/dist/chunks/health-alerts.mjs +830 -0
  60. package/dist/chunks/help.mjs +341 -0
  61. package/dist/chunks/hook-installer.mjs +48 -0
  62. package/dist/chunks/impact.mjs +651 -0
  63. package/dist/chunks/index.mjs +23 -0
  64. package/dist/chunks/index10.mjs +19 -0
  65. package/dist/chunks/index11.mjs +1171 -0
  66. package/dist/chunks/index12.mjs +218 -0
  67. package/dist/chunks/index13.mjs +679 -0
  68. package/dist/chunks/index14.mjs +1009 -0
  69. package/dist/chunks/index15.mjs +194 -0
  70. package/dist/chunks/index2.mjs +7637 -0
  71. package/dist/chunks/index3.mjs +171 -0
  72. package/dist/chunks/index4.mjs +26 -0
  73. package/dist/chunks/index5.mjs +19 -0
  74. package/dist/chunks/index6.mjs +19092 -0
  75. package/dist/chunks/index7.mjs +616 -0
  76. package/dist/chunks/index8.mjs +1602 -0
  77. package/dist/chunks/index9.mjs +5384 -0
  78. package/dist/chunks/init.mjs +1911 -0
  79. package/dist/chunks/installer.mjs +757 -0
  80. package/dist/chunks/installer2.mjs +103 -0
  81. package/dist/chunks/interview.mjs +2927 -0
  82. package/dist/chunks/json-config.mjs +60 -0
  83. package/dist/chunks/linux.mjs +3863 -0
  84. package/dist/chunks/macos.mjs +69 -0
  85. package/dist/chunks/main.mjs +635 -0
  86. package/dist/chunks/manager.mjs +1048 -0
  87. package/dist/chunks/marketplace.mjs +265 -0
  88. package/dist/chunks/mcp-cli.mjs +205 -0
  89. package/dist/chunks/mcp-performance.mjs +187 -0
  90. package/dist/chunks/mcp.mjs +667 -0
  91. package/dist/chunks/memory-check.mjs +2973 -0
  92. package/dist/chunks/memory-paths.mjs +259 -0
  93. package/dist/chunks/memory-sync.mjs +209 -0
  94. package/dist/chunks/memory.mjs +354 -0
  95. package/dist/chunks/metrics-display.mjs +153 -0
  96. package/dist/chunks/monitor.mjs +1856 -0
  97. package/dist/chunks/notification.mjs +1864 -0
  98. package/dist/chunks/onboarding.mjs +386 -0
  99. package/dist/chunks/package.mjs +3 -0
  100. package/dist/chunks/paradigm.mjs +74 -0
  101. package/dist/chunks/permission-manager.mjs +250 -0
  102. package/dist/chunks/permissions.mjs +265 -0
  103. package/dist/chunks/persistence-manager.mjs +801 -0
  104. package/dist/chunks/persistence.mjs +707 -0
  105. package/dist/chunks/platform.mjs +395 -0
  106. package/dist/chunks/plugin.mjs +1936 -0
  107. package/dist/chunks/powershell.mjs +213 -0
  108. package/dist/chunks/prompts.mjs +244 -0
  109. package/dist/chunks/providers.mjs +263 -0
  110. package/dist/chunks/quick-actions.mjs +335 -0
  111. package/dist/chunks/quick-provider.mjs +755 -0
  112. package/dist/chunks/quick-setup.mjs +421 -0
  113. package/dist/chunks/remote.mjs +497 -0
  114. package/dist/chunks/research.mjs +1904 -0
  115. package/dist/chunks/rollback.mjs +38 -0
  116. package/dist/chunks/session-manager.mjs +1371 -0
  117. package/dist/chunks/session.mjs +878 -0
  118. package/dist/chunks/sessions.mjs +106 -0
  119. package/dist/chunks/silent-updater.mjs +396 -0
  120. package/dist/chunks/simple-config.mjs +122 -0
  121. package/dist/chunks/skill.mjs +117 -0
  122. package/dist/chunks/skill2.mjs +9052 -0
  123. package/dist/chunks/skills-sync.mjs +1343 -0
  124. package/dist/chunks/skills.mjs +577 -0
  125. package/dist/chunks/slash-commands.mjs +208 -0
  126. package/dist/chunks/smart-guide.mjs +247 -0
  127. package/dist/chunks/snapshot.mjs +58 -0
  128. package/dist/chunks/startup.mjs +487 -0
  129. package/dist/chunks/stats.mjs +191 -0
  130. package/dist/chunks/status.mjs +471 -0
  131. package/dist/chunks/team.mjs +63 -0
  132. package/dist/chunks/thinking.mjs +626 -0
  133. package/dist/chunks/trace.mjs +57 -0
  134. package/dist/chunks/uninstall.mjs +852 -0
  135. package/dist/chunks/update.mjs +174 -0
  136. package/dist/chunks/upgrade-manager.mjs +204 -0
  137. package/dist/chunks/upgrade.mjs +133 -0
  138. package/dist/chunks/version-checker.mjs +891 -0
  139. package/dist/chunks/vim.mjs +903 -0
  140. package/dist/chunks/windows.mjs +14 -0
  141. package/dist/chunks/workflows.mjs +633 -0
  142. package/dist/chunks/wsl.mjs +129 -0
  143. package/dist/chunks/zero-config.mjs +871 -0
  144. package/dist/chunks/zsh.mjs +182 -0
  145. package/dist/cli.d.mts +1 -0
  146. package/dist/cli.d.ts +1 -0
  147. package/dist/cli.js +11 -2
  148. package/dist/cli.js.map +1 -1
  149. package/dist/cli.mjs +2684 -0
  150. package/dist/commands/edit.js +1 -2
  151. package/dist/commands/edit.js.map +1 -1
  152. package/dist/commands/grok.js +35 -0
  153. package/dist/commands/grok.js.map +1 -0
  154. package/dist/commands/init.js +183 -110
  155. package/dist/commands/init.js.map +1 -1
  156. package/dist/commands/migrate.js +6 -8
  157. package/dist/commands/migrate.js.map +1 -1
  158. package/dist/commands/profile.js +10 -28
  159. package/dist/commands/profile.js.map +1 -1
  160. package/dist/commands/quick.js +28 -25
  161. package/dist/commands/quick.js.map +1 -1
  162. package/dist/core/codex-config.js +11 -29
  163. package/dist/core/codex-config.js.map +1 -1
  164. package/dist/core/grok-config.js +110 -0
  165. package/dist/core/grok-config.js.map +1 -0
  166. package/dist/core/perms.js +96 -86
  167. package/dist/core/perms.js.map +1 -1
  168. package/dist/core/profiles.js +13 -57
  169. package/dist/core/profiles.js.map +1 -1
  170. package/dist/core/providers.js +58 -49
  171. package/dist/core/providers.js.map +1 -1
  172. package/dist/core/quick-parse.js +1 -7
  173. package/dist/core/quick-parse.js.map +1 -1
  174. package/dist/core/tools.js +24 -0
  175. package/dist/core/tools.js.map +1 -1
  176. package/dist/i18n/locales/en/agent-teams.json +18 -0
  177. package/dist/i18n/locales/en/agentBrowser.json +80 -0
  178. package/dist/i18n/locales/en/agents.json +135 -0
  179. package/dist/i18n/locales/en/api.json +63 -0
  180. package/dist/i18n/locales/en/ccjk-agents.json +33 -0
  181. package/dist/i18n/locales/en/ccjk-all.json +23 -0
  182. package/dist/i18n/locales/en/ccjk-skills.json +22 -0
  183. package/dist/i18n/locales/en/ccjk.json +276 -0
  184. package/dist/i18n/locales/en/ccr.json +65 -0
  185. package/dist/i18n/locales/en/claude-md.json +73 -0
  186. package/dist/i18n/locales/en/cli.json +148 -0
  187. package/dist/i18n/locales/en/cloud-setup.json +31 -0
  188. package/dist/i18n/locales/en/cloud-sync.json +147 -0
  189. package/dist/i18n/locales/en/cloud.json +40 -0
  190. package/dist/i18n/locales/en/cloudPlugins.json +118 -0
  191. package/dist/i18n/locales/en/codex.json +184 -0
  192. package/dist/i18n/locales/en/cometix.json +29 -0
  193. package/dist/i18n/locales/en/common.json +68 -0
  194. package/dist/i18n/locales/en/config.json +108 -0
  195. package/dist/i18n/locales/en/configuration.json +236 -0
  196. package/dist/i18n/locales/en/context.json +85 -0
  197. package/dist/i18n/locales/en/dashboard.json +78 -0
  198. package/dist/i18n/locales/en/errors.json +26 -0
  199. package/dist/i18n/locales/en/evolution.json +54 -0
  200. package/dist/i18n/locales/en/hooks.json +74 -0
  201. package/dist/i18n/locales/en/hooksSync.json +133 -0
  202. package/dist/i18n/locales/en/installation.json +83 -0
  203. package/dist/i18n/locales/en/interview.json +104 -0
  204. package/dist/i18n/locales/en/language.json +19 -0
  205. package/dist/i18n/locales/en/lsp.json +78 -0
  206. package/dist/i18n/locales/en/marketplace.json +116 -0
  207. package/dist/i18n/locales/en/mcp.json +180 -0
  208. package/dist/i18n/locales/en/memory.json +23 -0
  209. package/dist/i18n/locales/en/menu.json +299 -0
  210. package/dist/i18n/locales/en/multi-config.json +79 -0
  211. package/dist/i18n/locales/en/notification.json +307 -0
  212. package/dist/i18n/locales/en/permissions.json +95 -0
  213. package/dist/i18n/locales/en/persistence.json +127 -0
  214. package/dist/i18n/locales/en/plugins.json +146 -0
  215. package/dist/i18n/locales/en/quick-actions.json +78 -0
  216. package/dist/i18n/locales/en/registry.json +54 -0
  217. package/dist/i18n/locales/en/remote.json +93 -0
  218. package/dist/i18n/locales/en/sandbox.json +44 -0
  219. package/dist/i18n/locales/en/setup.json +44 -0
  220. package/dist/i18n/locales/en/shencha.json +14 -0
  221. package/dist/i18n/locales/en/skills.json +100 -0
  222. package/dist/i18n/locales/en/skillsSync.json +74 -0
  223. package/dist/i18n/locales/en/smartGuide.json +49 -0
  224. package/dist/i18n/locales/en/stats.json +20 -0
  225. package/dist/i18n/locales/en/subagent.json +69 -0
  226. package/dist/i18n/locales/en/superpowers.json +117 -0
  227. package/dist/i18n/locales/en/team.json +7 -0
  228. package/dist/i18n/locales/en/thinking.json +65 -0
  229. package/dist/i18n/locales/en/tools.json +42 -0
  230. package/dist/i18n/locales/en/uninstall.json +56 -0
  231. package/dist/i18n/locales/en/updater.json +29 -0
  232. package/dist/i18n/locales/en/vim.json +169 -0
  233. package/dist/i18n/locales/en/workflow.json +55 -0
  234. package/dist/i18n/locales/en/workspace.json +108 -0
  235. package/dist/i18n/locales/zh-CN/agent-teams.json +18 -0
  236. package/dist/i18n/locales/zh-CN/agentBrowser.json +80 -0
  237. package/dist/i18n/locales/zh-CN/agents.json +135 -0
  238. package/dist/i18n/locales/zh-CN/api.json +63 -0
  239. package/dist/i18n/locales/zh-CN/ccjk-agents.json +33 -0
  240. package/dist/i18n/locales/zh-CN/ccjk-all.json +23 -0
  241. package/dist/i18n/locales/zh-CN/ccjk-skills.json +22 -0
  242. package/dist/i18n/locales/zh-CN/ccjk.json +276 -0
  243. package/dist/i18n/locales/zh-CN/ccr.json +65 -0
  244. package/dist/i18n/locales/zh-CN/claude-md.json +73 -0
  245. package/dist/i18n/locales/zh-CN/cli.json +148 -0
  246. package/dist/i18n/locales/zh-CN/cloud-setup.json +31 -0
  247. package/dist/i18n/locales/zh-CN/cloud-sync.json +147 -0
  248. package/dist/i18n/locales/zh-CN/cloud.json +40 -0
  249. package/dist/i18n/locales/zh-CN/cloudPlugins.json +118 -0
  250. package/dist/i18n/locales/zh-CN/codex.json +184 -0
  251. package/dist/i18n/locales/zh-CN/cometix.json +29 -0
  252. package/dist/i18n/locales/zh-CN/common.json +68 -0
  253. package/dist/i18n/locales/zh-CN/config.json +108 -0
  254. package/dist/i18n/locales/zh-CN/configuration.json +234 -0
  255. package/dist/i18n/locales/zh-CN/context.json +85 -0
  256. package/dist/i18n/locales/zh-CN/dashboard.json +78 -0
  257. package/dist/i18n/locales/zh-CN/errors.json +26 -0
  258. package/dist/i18n/locales/zh-CN/evolution.json +54 -0
  259. package/dist/i18n/locales/zh-CN/hooks.json +74 -0
  260. package/dist/i18n/locales/zh-CN/hooksSync.json +133 -0
  261. package/dist/i18n/locales/zh-CN/installation.json +83 -0
  262. package/dist/i18n/locales/zh-CN/interview.json +104 -0
  263. package/dist/i18n/locales/zh-CN/language.json +19 -0
  264. package/dist/i18n/locales/zh-CN/lsp.json +78 -0
  265. package/dist/i18n/locales/zh-CN/marketplace.json +116 -0
  266. package/dist/i18n/locales/zh-CN/mcp.json +180 -0
  267. package/dist/i18n/locales/zh-CN/memory.json +23 -0
  268. package/dist/i18n/locales/zh-CN/menu.json +299 -0
  269. package/dist/i18n/locales/zh-CN/multi-config.json +79 -0
  270. package/dist/i18n/locales/zh-CN/notification.json +307 -0
  271. package/dist/i18n/locales/zh-CN/permissions.json +95 -0
  272. package/dist/i18n/locales/zh-CN/persistence.json +127 -0
  273. package/dist/i18n/locales/zh-CN/plugins.json +146 -0
  274. package/dist/i18n/locales/zh-CN/quick-actions.json +78 -0
  275. package/dist/i18n/locales/zh-CN/registry.json +54 -0
  276. package/dist/i18n/locales/zh-CN/remote.json +93 -0
  277. package/dist/i18n/locales/zh-CN/sandbox.json +44 -0
  278. package/dist/i18n/locales/zh-CN/setup.json +44 -0
  279. package/dist/i18n/locales/zh-CN/shencha.json +14 -0
  280. package/dist/i18n/locales/zh-CN/skills.json +100 -0
  281. package/dist/i18n/locales/zh-CN/skillsSync.json +74 -0
  282. package/dist/i18n/locales/zh-CN/smartGuide.json +49 -0
  283. package/dist/i18n/locales/zh-CN/stats.json +20 -0
  284. package/dist/i18n/locales/zh-CN/subagent.json +69 -0
  285. package/dist/i18n/locales/zh-CN/superpowers.json +117 -0
  286. package/dist/i18n/locales/zh-CN/team.json +7 -0
  287. package/dist/i18n/locales/zh-CN/thinking.json +65 -0
  288. package/dist/i18n/locales/zh-CN/tools.json +42 -0
  289. package/dist/i18n/locales/zh-CN/uninstall.json +56 -0
  290. package/dist/i18n/locales/zh-CN/updater.json +29 -0
  291. package/dist/i18n/locales/zh-CN/vim.json +169 -0
  292. package/dist/i18n/locales/zh-CN/workflow.json +55 -0
  293. package/dist/i18n/locales/zh-CN/workspace.json +108 -0
  294. package/dist/index.d.mts +5658 -0
  295. package/dist/index.d.ts +5658 -0
  296. package/dist/index.mjs +3732 -0
  297. package/dist/shared/ccjk.5bEolFrk.mjs +254 -0
  298. package/dist/shared/ccjk.8oaxX4iR.mjs +90 -0
  299. package/dist/shared/ccjk.B2U7DsPy.mjs +31 -0
  300. package/dist/shared/ccjk.B2f-cwUP.mjs +468 -0
  301. package/dist/shared/ccjk.BAGoDD49.mjs +36 -0
  302. package/dist/shared/ccjk.BBtCGd_g.mjs +899 -0
  303. package/dist/shared/ccjk.BFQ7yr5S.mjs +16 -0
  304. package/dist/shared/ccjk.BLsIiTqO.mjs +449 -0
  305. package/dist/shared/ccjk.BXv8aYs1.mjs +170 -0
  306. package/dist/shared/ccjk.BnsY5WxD.mjs +171 -0
  307. package/dist/shared/ccjk.BoApaI4j.mjs +28 -0
  308. package/dist/shared/ccjk.Bq8TqZG_.mjs +189 -0
  309. package/dist/shared/ccjk.BtrioX1Z.mjs +25 -0
  310. package/dist/shared/ccjk.Bx_rmYfN.mjs +69 -0
  311. package/dist/shared/ccjk.BzPbSEP2.mjs +115 -0
  312. package/dist/shared/ccjk.C0WLUnFV.mjs +293 -0
  313. package/dist/shared/ccjk.C1hANZTu.mjs +19 -0
  314. package/dist/shared/ccjk.C2jHOZVP.mjs +52 -0
  315. package/dist/shared/ccjk.CNhnT6uQ.mjs +636 -0
  316. package/dist/shared/ccjk.COweQ1RR.mjs +5 -0
  317. package/dist/shared/ccjk.CfKKcvWy.mjs +126 -0
  318. package/dist/shared/ccjk.Cjgrln_h.mjs +297 -0
  319. package/dist/shared/ccjk.CoCHVXl3.mjs +3951 -0
  320. package/dist/shared/ccjk.CwGZSTAK.mjs +319 -0
  321. package/dist/shared/ccjk.CxpGa6MC.mjs +2724 -0
  322. package/dist/shared/ccjk.D-magaEx.mjs +763 -0
  323. package/dist/shared/ccjk.D0g2ABGg.mjs +171 -0
  324. package/dist/shared/ccjk.D6ycHbak.mjs +270 -0
  325. package/dist/shared/ccjk.D75wivnp.mjs +142 -0
  326. package/dist/shared/ccjk.DDL-4C-k.mjs +100 -0
  327. package/dist/shared/ccjk.DFRPtmK_.mjs +75 -0
  328. package/dist/shared/ccjk.DMV3x5Sd.mjs +299 -0
  329. package/dist/shared/ccjk.DZ2LLOa-.mjs +2195 -0
  330. package/dist/shared/ccjk.DbigonEQ.mjs +698 -0
  331. package/dist/shared/ccjk.DcMvE7lf.mjs +618 -0
  332. package/dist/shared/ccjk.DeWpAShp.mjs +1828 -0
  333. package/dist/shared/ccjk.DhJ1kyDR.mjs +30 -0
  334. package/dist/shared/ccjk.DlTXS9rP.mjs +224 -0
  335. package/dist/shared/ccjk.DopKzo3z.mjs +305 -0
  336. package/dist/shared/ccjk.DsZsc4LR.mjs +1280 -0
  337. package/dist/shared/ccjk.DuzJZlgj.mjs +418 -0
  338. package/dist/shared/ccjk.Dxgd2vjc.mjs +444 -0
  339. package/dist/shared/ccjk.J8YiPsOw.mjs +259 -0
  340. package/dist/shared/ccjk.KfSWcGlE.mjs +38 -0
  341. package/dist/shared/ccjk.L7yC58_i.mjs +225 -0
  342. package/dist/shared/ccjk.MwtjAULc.mjs +1447 -0
  343. package/dist/shared/ccjk.OJKHVSOb.mjs +2005 -0
  344. package/dist/shared/ccjk.OTnevPNE.mjs +225 -0
  345. package/dist/shared/ccjk.RyizuzOI.mjs +21 -0
  346. package/dist/shared/ccjk.T_cX87dY.mjs +15 -0
  347. package/dist/shared/ccjk.bQ7Dh1g4.mjs +249 -0
  348. package/dist/shared/ccjk.gDEDGD_t.mjs +38 -0
  349. package/dist/shared/ccjk.hoqrwWdN.mjs +333 -0
  350. package/dist/shared/ccjk.i_vn-9C3.mjs +317 -0
  351. package/dist/shared/ccjk.lG3ccFjm.mjs +885 -0
  352. package/dist/shared/ccjk.wLJHO0Af.mjs +244 -0
  353. package/dist/shared/ccjk.y-a_1vK4.mjs +5127 -0
  354. package/dist/templates/agents/README.md +78 -0
  355. package/dist/templates/agents/fullstack-developer.json +70 -0
  356. package/dist/templates/agents/go-expert.json +69 -0
  357. package/dist/templates/agents/index.json +64 -0
  358. package/dist/templates/agents/python-expert.json +69 -0
  359. package/dist/templates/agents/react-specialist.json +69 -0
  360. package/dist/templates/agents/testing-automation-expert.json +70 -0
  361. package/dist/templates/agents/typescript-architect.json +69 -0
  362. package/dist/templates/claude-code/common/settings.json +109 -0
  363. package/dist/templates/common/error-prevention.md +267 -0
  364. package/dist/templates/common/karpathy-baseline.md +83 -0
  365. package/dist/templates/common/output-styles/zh-CN/carmack-mode.md +381 -0
  366. package/dist/templates/common/output-styles/zh-CN/codex-rigor-mode.md +114 -0
  367. package/dist/templates/common/output-styles/zh-CN/dhh-mode.md +265 -0
  368. package/dist/templates/common/output-styles/zh-CN/evan-you-mode.md +539 -0
  369. package/dist/templates/common/output-styles/zh-CN/jobs-mode.md +369 -0
  370. package/dist/templates/common/output-styles/zh-CN/linus-mode.md +135 -0
  371. package/dist/templates/common/output-styles/zh-CN/uncle-bob-mode.md +221 -0
  372. package/dist/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +628 -0
  373. package/dist/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +628 -0
  374. package/dist/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +187 -0
  375. package/dist/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +191 -0
  376. package/dist/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +249 -0
  377. package/dist/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +277 -0
  378. package/dist/templates/common/workflow/essential/en/agents/get-current-datetime.md +29 -0
  379. package/dist/templates/common/workflow/essential/en/agents/init-architect.md +115 -0
  380. package/dist/templates/common/workflow/essential/en/agents/ui-ux-designer.md +91 -0
  381. package/dist/templates/common/workflow/essential/en/feat.md +92 -0
  382. package/dist/templates/common/workflow/essential/en/goal.md +147 -0
  383. package/dist/templates/common/workflow/essential/en/init-project.md +53 -0
  384. package/dist/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +29 -0
  385. package/dist/templates/common/workflow/essential/zh-CN/agents/init-architect.md +115 -0
  386. package/dist/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +91 -0
  387. package/dist/templates/common/workflow/essential/zh-CN/feat.md +315 -0
  388. package/dist/templates/common/workflow/essential/zh-CN/goal.md +146 -0
  389. package/dist/templates/common/workflow/essential/zh-CN/init-project.md +53 -0
  390. package/dist/templates/common/workflow/git/en/git-cleanBranches.md +102 -0
  391. package/dist/templates/common/workflow/git/en/git-commit.md +205 -0
  392. package/dist/templates/common/workflow/git/en/git-rollback.md +90 -0
  393. package/dist/templates/common/workflow/git/en/git-worktree.md +276 -0
  394. package/dist/templates/common/workflow/git/zh-CN/git-cleanBranches.md +102 -0
  395. package/dist/templates/common/workflow/git/zh-CN/git-commit.md +205 -0
  396. package/dist/templates/common/workflow/git/zh-CN/git-rollback.md +90 -0
  397. package/dist/templates/common/workflow/git/zh-CN/git-worktree.md +276 -0
  398. package/dist/templates/common/workflow/interview/en/interview.md +67 -0
  399. package/dist/templates/common/workflow/interview/zh-CN/interview.md +67 -0
  400. package/dist/templates/common/workflow/linearMethod/en/linear-method.md +651 -0
  401. package/dist/templates/common/workflow/linearMethod/zh-CN/linear-method.md +752 -0
  402. package/dist/templates/common/workflow/refactoringMaster/en/refactoring-master.md +516 -0
  403. package/dist/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +812 -0
  404. package/dist/templates/common/workflow/sixStep/en/workflow.md +83 -0
  405. package/dist/templates/common/workflow/sixStep/zh-CN/workflow.md +359 -0
  406. package/dist/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +364 -0
  407. package/dist/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +366 -0
  408. package/dist/templates/hooks/README.md +212 -0
  409. package/dist/templates/hooks/git-workflow-hooks.md +551 -0
  410. package/dist/templates/hooks/post-test/coverage.json +21 -0
  411. package/dist/templates/hooks/post-test/summary.json +21 -0
  412. package/dist/templates/hooks/post-test-coverage.md +434 -0
  413. package/dist/templates/hooks/pre-commit/eslint.json +22 -0
  414. package/dist/templates/hooks/pre-commit/prettier.json +22 -0
  415. package/dist/templates/hooks/pre-commit-black.md +274 -0
  416. package/dist/templates/hooks/pre-commit-eslint.md +153 -0
  417. package/dist/templates/hooks/pre-commit-gofmt.md +284 -0
  418. package/dist/templates/hooks/pre-commit-prettier.md +212 -0
  419. package/dist/templates/hooks/pre-commit-type-check.md +377 -0
  420. package/dist/templates/skills/ccjk-init.md +154 -0
  421. package/dist/templates/skills/ccjk-mcp-setup.md +205 -0
  422. package/dist/templates/skills/ccjk-troubleshoot.md +228 -0
  423. package/dist/templates/skills/django-patterns.md +1016 -0
  424. package/dist/templates/skills/git-workflow.md +748 -0
  425. package/dist/templates/skills/go-idioms.md +963 -0
  426. package/dist/templates/skills/index.json +132 -0
  427. package/dist/templates/skills/nextjs-optimization.md +694 -0
  428. package/dist/templates/skills/python-pep8.md +852 -0
  429. package/dist/templates/skills/react-patterns.md +686 -0
  430. package/dist/templates/skills/rust-patterns.md +1057 -0
  431. package/dist/templates/skills/security-best-practices.md +1413 -0
  432. package/dist/templates/skills/testing-best-practices.md +1315 -0
  433. package/dist/templates/skills/ts-best-practices.md +354 -0
  434. package/package.json +12 -13
  435. package/dist/core/codex-auth.js +0 -63
  436. package/dist/core/codex-auth.js.map +0 -1
@@ -0,0 +1,1936 @@
1
+ import process__default from 'node:process';
2
+ import a from './index5.mjs';
3
+ import { Buffer } from 'node:buffer';
4
+ import { existsSync, mkdirSync, readFileSync, unlinkSync, readdirSync, statSync, rmSync } from 'node:fs';
5
+ import { CLOUD_ENDPOINTS, CCJK_CLOUD_PLUGINS_DIR, CCJK_CLOUD_PLUGINS_CACHE_DIR, CCJK_CLOUD_PLUGINS_INSTALLED_DIR } from './constants.mjs';
6
+ import { i18n } from './index2.mjs';
7
+ import { writeFileAtomic } from './fs-operations.mjs';
8
+ import { homedir } from 'node:os';
9
+ import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
10
+ import { d as detectProject } from '../shared/ccjk.hoqrwWdN.mjs';
11
+ import '../shared/ccjk.BAGoDD49.mjs';
12
+ import 'node:url';
13
+ import 'node:crypto';
14
+ import 'node:fs/promises';
15
+
16
+ const CACHE_CONFIG = {
17
+ /** Cache time-to-live: 24 hours in milliseconds */
18
+ TTL: 24 * 60 * 60 * 1e3,
19
+ /** Maximum number of plugins to cache */
20
+ MAX_PLUGINS: 1e3,
21
+ /** Cache version for compatibility tracking */
22
+ VERSION: "1.0.0",
23
+ /** Maximum size for individual plugin content (5MB) */
24
+ MAX_CONTENT_SIZE: 5 * 1024 * 1024
25
+ };
26
+ const CACHE_BASE_DIR = join(homedir(), ".ccjk", "cloud-plugins", "cache");
27
+ class LocalPluginCache {
28
+ cacheDir;
29
+ cacheFile;
30
+ contentDir;
31
+ cache = null;
32
+ constructor(cacheDir) {
33
+ this.cacheDir = cacheDir || CACHE_BASE_DIR;
34
+ this.cacheFile = join(this.cacheDir, "metadata.json");
35
+ this.contentDir = join(this.cacheDir, "contents");
36
+ }
37
+ // ==========================================================================
38
+ // Initialization
39
+ // ==========================================================================
40
+ /**
41
+ * Ensure cache directory exists
42
+ */
43
+ ensureCacheDir() {
44
+ try {
45
+ if (!existsSync(this.cacheDir)) {
46
+ mkdirSync(this.cacheDir, { recursive: true });
47
+ }
48
+ if (!existsSync(this.contentDir)) {
49
+ mkdirSync(this.contentDir, { recursive: true });
50
+ }
51
+ } catch (error) {
52
+ throw new Error(`Failed to create cache directory: ${error instanceof Error ? error.message : String(error)}`);
53
+ }
54
+ }
55
+ // ==========================================================================
56
+ // Cache Metadata Operations
57
+ // ==========================================================================
58
+ /**
59
+ * Load cache metadata from disk
60
+ *
61
+ * @returns Cache metadata or null if not found or invalid
62
+ */
63
+ loadCache() {
64
+ try {
65
+ if (!existsSync(this.cacheFile)) {
66
+ return null;
67
+ }
68
+ const content = readFileSync(this.cacheFile, "utf-8");
69
+ const cache = JSON.parse(content);
70
+ if (!this.isValidCache(cache)) {
71
+ console.warn("[LocalPluginCache] Invalid cache structure, ignoring");
72
+ return null;
73
+ }
74
+ if (cache.version !== CACHE_CONFIG.VERSION) {
75
+ console.warn(`[LocalPluginCache] Cache version mismatch (${cache.version} vs ${CACHE_CONFIG.VERSION}), ignoring`);
76
+ return null;
77
+ }
78
+ this.cache = cache;
79
+ return cache;
80
+ } catch (error) {
81
+ console.error("[LocalPluginCache] Failed to load cache:", error);
82
+ return null;
83
+ }
84
+ }
85
+ /**
86
+ * Save cache metadata to disk
87
+ *
88
+ * Uses atomic write operation to prevent corruption
89
+ *
90
+ * @param cache - Cache metadata to save
91
+ */
92
+ saveCache(cache) {
93
+ try {
94
+ this.ensureCacheDir();
95
+ if (!this.isValidCache(cache)) {
96
+ throw new Error("Invalid cache structure");
97
+ }
98
+ if (cache.plugins.length > CACHE_CONFIG.MAX_PLUGINS) {
99
+ console.warn(`[LocalPluginCache] Cache exceeds max plugins (${cache.plugins.length}), truncating`);
100
+ cache.plugins = cache.plugins.slice(0, CACHE_CONFIG.MAX_PLUGINS);
101
+ cache.totalPlugins = cache.plugins.length;
102
+ }
103
+ const content = JSON.stringify(cache, null, 2);
104
+ writeFileAtomic(this.cacheFile, content, "utf-8");
105
+ this.cache = cache;
106
+ } catch (error) {
107
+ throw new Error(`Failed to save cache: ${error instanceof Error ? error.message : String(error)}`);
108
+ }
109
+ }
110
+ /**
111
+ * Get cached plugins
112
+ *
113
+ * @returns Array of cached plugins
114
+ */
115
+ getCachedPlugins() {
116
+ if (!this.cache) {
117
+ this.cache = this.loadCache();
118
+ }
119
+ return this.cache?.plugins || [];
120
+ }
121
+ /**
122
+ * Get a single cached plugin by ID
123
+ *
124
+ * @param id - Plugin ID
125
+ * @returns Plugin or undefined if not found
126
+ */
127
+ getCachedPlugin(id) {
128
+ const plugins = this.getCachedPlugins();
129
+ return plugins.find((p) => p.id === id);
130
+ }
131
+ /**
132
+ * Update cache with new plugin list
133
+ *
134
+ * @param plugins - New plugin list
135
+ */
136
+ updateCache(plugins) {
137
+ const now = (/* @__PURE__ */ new Date()).toISOString();
138
+ const expiresAt = new Date(Date.now() + CACHE_CONFIG.TTL).toISOString();
139
+ const cache = {
140
+ version: CACHE_CONFIG.VERSION,
141
+ plugins,
142
+ createdAt: this.cache?.createdAt || now,
143
+ expiresAt,
144
+ lastUpdated: now,
145
+ totalPlugins: plugins.length
146
+ };
147
+ this.saveCache(cache);
148
+ }
149
+ // ==========================================================================
150
+ // Cache Expiration
151
+ // ==========================================================================
152
+ /**
153
+ * Check if cache is expired
154
+ *
155
+ * @returns True if cache is expired or doesn't exist
156
+ */
157
+ isCacheExpired() {
158
+ if (!this.cache) {
159
+ this.cache = this.loadCache();
160
+ }
161
+ if (!this.cache) {
162
+ return true;
163
+ }
164
+ const expiresAt = new Date(this.cache.expiresAt).getTime();
165
+ const now = Date.now();
166
+ return now >= expiresAt;
167
+ }
168
+ /**
169
+ * Clear all cache data
170
+ */
171
+ clearCache() {
172
+ try {
173
+ if (existsSync(this.cacheFile)) {
174
+ unlinkSync(this.cacheFile);
175
+ }
176
+ if (existsSync(this.contentDir)) {
177
+ const files = readdirSync(this.contentDir);
178
+ for (const file of files) {
179
+ const filePath = join(this.contentDir, file);
180
+ if (existsSync(filePath)) {
181
+ unlinkSync(filePath);
182
+ }
183
+ }
184
+ }
185
+ this.cache = null;
186
+ } catch (error) {
187
+ throw new Error(`Failed to clear cache: ${error instanceof Error ? error.message : String(error)}`);
188
+ }
189
+ }
190
+ // ==========================================================================
191
+ // Plugin Content Caching
192
+ // ==========================================================================
193
+ /**
194
+ * Cache plugin content to disk
195
+ *
196
+ * @param pluginId - Plugin ID
197
+ * @param content - Plugin content (code/template)
198
+ * @returns Path to cached content file
199
+ */
200
+ cachePluginContent(pluginId, content) {
201
+ try {
202
+ this.ensureCacheDir();
203
+ const contentSize = Buffer.byteLength(content, "utf-8");
204
+ if (contentSize > CACHE_CONFIG.MAX_CONTENT_SIZE) {
205
+ throw new Error(`Content size (${contentSize} bytes) exceeds maximum (${CACHE_CONFIG.MAX_CONTENT_SIZE} bytes)`);
206
+ }
207
+ const safeId = this.sanitizeFilename(pluginId);
208
+ const contentPath = join(this.contentDir, `${safeId}.txt`);
209
+ writeFileAtomic(contentPath, content, "utf-8");
210
+ return contentPath;
211
+ } catch (error) {
212
+ throw new Error(`Failed to cache plugin content: ${error instanceof Error ? error.message : String(error)}`);
213
+ }
214
+ }
215
+ /**
216
+ * Get cached plugin content
217
+ *
218
+ * @param pluginId - Plugin ID
219
+ * @returns Plugin content or null if not cached
220
+ */
221
+ getPluginContent(pluginId) {
222
+ try {
223
+ const safeId = this.sanitizeFilename(pluginId);
224
+ const contentPath = join(this.contentDir, `${safeId}.txt`);
225
+ if (!existsSync(contentPath)) {
226
+ return null;
227
+ }
228
+ return readFileSync(contentPath, "utf-8");
229
+ } catch (error) {
230
+ console.error(`[LocalPluginCache] Failed to read plugin content: ${error}`);
231
+ return null;
232
+ }
233
+ }
234
+ /**
235
+ * Remove cached plugin content
236
+ *
237
+ * @param pluginId - Plugin ID
238
+ * @returns True if content was removed
239
+ */
240
+ removePluginContent(pluginId) {
241
+ try {
242
+ const safeId = this.sanitizeFilename(pluginId);
243
+ const contentPath = join(this.contentDir, `${safeId}.txt`);
244
+ if (existsSync(contentPath)) {
245
+ unlinkSync(contentPath);
246
+ return true;
247
+ }
248
+ return false;
249
+ } catch (error) {
250
+ console.error(`[LocalPluginCache] Failed to remove plugin content: ${error}`);
251
+ return false;
252
+ }
253
+ }
254
+ // ==========================================================================
255
+ // Cache Statistics
256
+ // ==========================================================================
257
+ /**
258
+ * Get cache statistics
259
+ *
260
+ * @returns Cache statistics
261
+ */
262
+ getCacheStats() {
263
+ if (!this.cache) {
264
+ this.cache = this.loadCache();
265
+ }
266
+ const totalPlugins = this.cache?.totalPlugins || 0;
267
+ const lastUpdated = this.cache?.lastUpdated || null;
268
+ const expiresAt = this.cache?.expiresAt || null;
269
+ const isExpired = this.isCacheExpired();
270
+ let cacheSize = 0;
271
+ let cachedContents = 0;
272
+ try {
273
+ if (existsSync(this.cacheFile)) {
274
+ cacheSize += statSync(this.cacheFile).size;
275
+ }
276
+ if (existsSync(this.contentDir)) {
277
+ const files = readdirSync(this.contentDir);
278
+ for (const file of files) {
279
+ const filePath = join(this.contentDir, file);
280
+ if (existsSync(filePath)) {
281
+ cacheSize += statSync(filePath).size;
282
+ cachedContents++;
283
+ }
284
+ }
285
+ }
286
+ } catch (error) {
287
+ console.error("[LocalPluginCache] Failed to calculate cache size:", error);
288
+ }
289
+ return {
290
+ totalPlugins,
291
+ cacheSize,
292
+ lastUpdated,
293
+ expiresAt,
294
+ isExpired,
295
+ cachedContents
296
+ };
297
+ }
298
+ // ==========================================================================
299
+ // Utility Methods
300
+ // ==========================================================================
301
+ /**
302
+ * Validate cache structure
303
+ *
304
+ * @param cache - Cache to validate
305
+ * @returns True if cache is valid
306
+ */
307
+ isValidCache(cache) {
308
+ return cache && typeof cache === "object" && typeof cache.version === "string" && Array.isArray(cache.plugins) && typeof cache.createdAt === "string" && typeof cache.expiresAt === "string" && typeof cache.lastUpdated === "string" && typeof cache.totalPlugins === "number";
309
+ }
310
+ /**
311
+ * Sanitize filename to prevent path traversal
312
+ *
313
+ * @param filename - Original filename
314
+ * @returns Sanitized filename
315
+ */
316
+ sanitizeFilename(filename) {
317
+ return filename.replace(/[/\\]/g, "_").replace(/[^\w.-]/g, "_").substring(0, 255);
318
+ }
319
+ }
320
+
321
+ const DEFAULT_CLOUD_API_URL = `${CLOUD_ENDPOINTS.MAIN.BASE_URL}${CLOUD_ENDPOINTS.MAIN.API_VERSION}/skills`;
322
+ const REQUEST_TIMEOUT = 3e4;
323
+ const MAX_RETRY_ATTEMPTS = 3;
324
+ const RETRY_DELAY = 1e3;
325
+ const CACHE_TTL = 36e5;
326
+ class CloudRecommendationClient {
327
+ baseUrl;
328
+ apiKey;
329
+ timeout;
330
+ offlineMode;
331
+ enableLogging;
332
+ maxRetries;
333
+ retryDelay;
334
+ cache;
335
+ constructor(options = {}) {
336
+ this.baseUrl = options.baseUrl || DEFAULT_CLOUD_API_URL;
337
+ this.apiKey = options.apiKey;
338
+ this.timeout = options.timeout || REQUEST_TIMEOUT;
339
+ this.offlineMode = options.offlineMode || false;
340
+ this.enableLogging = options.enableLogging || false;
341
+ this.maxRetries = options.maxRetries || MAX_RETRY_ATTEMPTS;
342
+ this.retryDelay = options.retryDelay || RETRY_DELAY;
343
+ this.cache = /* @__PURE__ */ new Map();
344
+ }
345
+ // ==========================================================================
346
+ // Public API Methods
347
+ // ==========================================================================
348
+ /**
349
+ * Get personalized plugin recommendations
350
+ *
351
+ * @param context - Recommendation context with user preferences
352
+ * @returns Recommended plugins with reasons and scores
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * const recommendations = await client.getRecommendations({
357
+ * codeToolType: 'claude-code',
358
+ * language: 'zh-CN',
359
+ * installedPlugins: ['git-workflow', 'test-runner'],
360
+ * limit: 10
361
+ * })
362
+ * ```
363
+ */
364
+ async getRecommendations(context) {
365
+ this.log("Getting recommendations with context:", context);
366
+ return this.request("/recommendations", {
367
+ method: "POST",
368
+ body: JSON.stringify(context)
369
+ });
370
+ }
371
+ /**
372
+ * Search plugins with filters and sorting
373
+ *
374
+ * @param params - Search parameters
375
+ * @returns Matching plugins
376
+ *
377
+ * @example
378
+ * ```typescript
379
+ * const results = await client.searchPlugins({
380
+ * query: 'git',
381
+ * category: 'workflow',
382
+ * sortBy: 'downloads',
383
+ * sortDir: 'desc',
384
+ * limit: 20
385
+ * })
386
+ * ```
387
+ */
388
+ async searchPlugins(params) {
389
+ this.log("Searching plugins with params:", params);
390
+ return this.request("", {
391
+ method: "GET",
392
+ params
393
+ });
394
+ }
395
+ /**
396
+ * Get detailed information about a specific plugin
397
+ *
398
+ * @param id - Plugin ID
399
+ * @returns Plugin details
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * const plugin = await client.getPlugin('git-workflow-pro')
404
+ * ```
405
+ */
406
+ async getPlugin(id) {
407
+ this.log("Getting plugin:", id);
408
+ return this.request(`/plugins/${id}`, {
409
+ method: "GET"
410
+ });
411
+ }
412
+ /**
413
+ * Get popular plugins
414
+ *
415
+ * @param limit - Maximum number of plugins to return
416
+ * @returns Popular plugins
417
+ *
418
+ * @example
419
+ * ```typescript
420
+ * const popular = await client.getPopularPlugins(10)
421
+ * ```
422
+ */
423
+ async getPopularPlugins(limit = 10) {
424
+ this.log("Getting popular plugins, limit:", limit);
425
+ return this.request("/popular", {
426
+ method: "GET",
427
+ params: { limit }
428
+ });
429
+ }
430
+ /**
431
+ * Get all plugin categories
432
+ *
433
+ * @returns Category information
434
+ *
435
+ * @example
436
+ * ```typescript
437
+ * const categories = await client.getCategories()
438
+ * ```
439
+ */
440
+ async getCategories() {
441
+ this.log("Getting categories");
442
+ return this.request("/categories", {
443
+ method: "GET"
444
+ });
445
+ }
446
+ /**
447
+ * Download a plugin
448
+ *
449
+ * @param id - Plugin ID
450
+ * @returns Plugin download result with content
451
+ *
452
+ * @example
453
+ * ```typescript
454
+ * const download = await client.downloadPlugin('git-workflow-pro')
455
+ * if (download.success && download.data) {
456
+ * const content = require('node:buffer').require('node:buffer').require('node:buffer').require('node:buffer').Buffer.from(download.data.content, 'base64')
457
+ * // Process plugin content
458
+ * }
459
+ * ```
460
+ */
461
+ async downloadPlugin(id) {
462
+ this.log("Downloading plugin:", id);
463
+ return this.request(`/plugins/${id}/download`, {
464
+ method: "GET",
465
+ skipCache: true
466
+ // Always fetch fresh download
467
+ });
468
+ }
469
+ /**
470
+ * Upload a plugin (user contribution)
471
+ *
472
+ * @param plugin - Plugin metadata
473
+ * @param content - Plugin content as Buffer
474
+ * @returns Upload result with plugin ID
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * const result = await client.uploadPlugin(pluginMetadata, pluginContent)
479
+ * if (result.success && result.data) {
480
+ * console.log('Plugin uploaded with ID:', result.data.id)
481
+ * }
482
+ * ```
483
+ */
484
+ async uploadPlugin(plugin, content) {
485
+ this.log("Uploading plugin:", plugin.id);
486
+ const payload = {
487
+ plugin,
488
+ content: content.toString("base64")
489
+ };
490
+ return this.request("/plugins/upload", {
491
+ method: "POST",
492
+ body: JSON.stringify(payload),
493
+ skipCache: true
494
+ });
495
+ }
496
+ // ==========================================================================
497
+ // Cache Management
498
+ // ==========================================================================
499
+ /**
500
+ * Clear all cached data
501
+ */
502
+ clearCache() {
503
+ this.cache.clear();
504
+ this.log("Cache cleared");
505
+ }
506
+ /**
507
+ * Clear expired cache entries
508
+ */
509
+ clearExpiredCache() {
510
+ const now = Date.now();
511
+ const keysToDelete = [];
512
+ this.cache.forEach((entry, key) => {
513
+ if (now - entry.timestamp > entry.ttl) {
514
+ keysToDelete.push(key);
515
+ }
516
+ });
517
+ keysToDelete.forEach((key) => this.cache.delete(key));
518
+ this.log("Expired cache entries cleared");
519
+ }
520
+ /**
521
+ * Set offline mode
522
+ */
523
+ setOfflineMode(enabled) {
524
+ this.offlineMode = enabled;
525
+ this.log("Offline mode:", enabled ? "enabled" : "disabled");
526
+ }
527
+ // ==========================================================================
528
+ // Private Helper Methods
529
+ // ==========================================================================
530
+ /**
531
+ * Make an HTTP request to the cloud service
532
+ */
533
+ async request(endpoint, options = {}) {
534
+ const url = this.buildUrl(endpoint, options.params);
535
+ const cacheKey = `${options.method || "GET"}:${url}`;
536
+ if (!options.skipCache && (options.method === "GET" || !options.method)) {
537
+ const cached = this.getFromCache(cacheKey);
538
+ if (cached) {
539
+ this.log("Cache hit:", cacheKey);
540
+ return {
541
+ success: true,
542
+ data: cached,
543
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
544
+ };
545
+ }
546
+ }
547
+ if (this.offlineMode) {
548
+ const cached = this.getFromCache(cacheKey);
549
+ if (cached) {
550
+ this.log("Offline mode: returning cached data");
551
+ return {
552
+ success: true,
553
+ data: cached,
554
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
555
+ };
556
+ }
557
+ return {
558
+ success: false,
559
+ error: "Offline mode enabled and no cached data available",
560
+ code: "OFFLINE_MODE"
561
+ };
562
+ }
563
+ let lastError = null;
564
+ for (let attempt = 1; attempt <= this.maxRetries; attempt++) {
565
+ try {
566
+ this.log(`Request attempt ${attempt}/${this.maxRetries}:`, url);
567
+ const response = await this.makeRequest(url, options);
568
+ if (response.success && response.data && (options.method === "GET" || !options.method)) {
569
+ this.setCache(cacheKey, response.data, CACHE_TTL);
570
+ }
571
+ return response;
572
+ } catch (error) {
573
+ lastError = error instanceof Error ? error : new Error(String(error));
574
+ this.log(`Request failed (attempt ${attempt}):`, lastError.message);
575
+ if (lastError.name === "AbortError") {
576
+ break;
577
+ }
578
+ if (attempt < this.maxRetries) {
579
+ await this.sleep(this.retryDelay * attempt);
580
+ }
581
+ }
582
+ }
583
+ return {
584
+ success: false,
585
+ error: lastError?.message || "Request failed after all retries",
586
+ code: "REQUEST_FAILED"
587
+ };
588
+ }
589
+ /**
590
+ * Make a single HTTP request
591
+ */
592
+ async makeRequest(url, options) {
593
+ const timeout = options.timeout || this.timeout;
594
+ const timeoutController = new AbortController();
595
+ const timeoutId = setTimeout(() => timeoutController.abort(), timeout);
596
+ try {
597
+ const response = await fetch(url, {
598
+ method: options.method || "GET",
599
+ headers: this.getHeaders(options.headers),
600
+ body: options.body,
601
+ signal: options.signal || timeoutController.signal
602
+ });
603
+ clearTimeout(timeoutId);
604
+ const data = await response.json();
605
+ if (!response.ok) {
606
+ return {
607
+ success: false,
608
+ error: data.error || `HTTP ${response.status}: ${response.statusText}`,
609
+ code: data.code || `HTTP_${response.status}`
610
+ };
611
+ }
612
+ return {
613
+ ...data,
614
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
615
+ };
616
+ } catch (error) {
617
+ clearTimeout(timeoutId);
618
+ if (error instanceof Error) {
619
+ if (error.name === "AbortError") {
620
+ throw error;
621
+ }
622
+ return {
623
+ success: false,
624
+ error: error.message,
625
+ code: "NETWORK_ERROR"
626
+ };
627
+ }
628
+ return {
629
+ success: false,
630
+ error: String(error),
631
+ code: "UNKNOWN_ERROR"
632
+ };
633
+ }
634
+ }
635
+ /**
636
+ * Build full URL with query parameters
637
+ */
638
+ buildUrl(endpoint, params) {
639
+ const url = new URL(endpoint, this.baseUrl);
640
+ if (params) {
641
+ for (const [key, value] of Object.entries(params)) {
642
+ if (value !== void 0 && value !== null) {
643
+ if (Array.isArray(value)) {
644
+ value.forEach((v) => url.searchParams.append(key, String(v)));
645
+ } else {
646
+ url.searchParams.append(key, String(value));
647
+ }
648
+ }
649
+ }
650
+ }
651
+ return url.toString();
652
+ }
653
+ /**
654
+ * Get request headers
655
+ */
656
+ getHeaders(customHeaders) {
657
+ const headers = {
658
+ "Content-Type": "application/json",
659
+ "User-Agent": "CCJK-Cloud-Client/1.0",
660
+ ...customHeaders
661
+ };
662
+ if (this.apiKey) {
663
+ headers.Authorization = `Bearer ${this.apiKey}`;
664
+ }
665
+ return headers;
666
+ }
667
+ /**
668
+ * Get data from cache
669
+ */
670
+ getFromCache(key) {
671
+ const entry = this.cache.get(key);
672
+ if (!entry) {
673
+ return null;
674
+ }
675
+ const now = Date.now();
676
+ if (now - entry.timestamp > entry.ttl) {
677
+ this.cache.delete(key);
678
+ return null;
679
+ }
680
+ return entry.data;
681
+ }
682
+ /**
683
+ * Set data in cache
684
+ */
685
+ setCache(key, data, ttl) {
686
+ this.cache.set(key, {
687
+ data,
688
+ timestamp: Date.now(),
689
+ ttl
690
+ });
691
+ }
692
+ /**
693
+ * Sleep for specified milliseconds
694
+ */
695
+ sleep(ms) {
696
+ return new Promise((resolve) => setTimeout(resolve, ms));
697
+ }
698
+ /**
699
+ * Log message (if logging is enabled)
700
+ */
701
+ log(...args) {
702
+ if (this.enableLogging) {
703
+ console.log("[CloudRecommendationClient]", ...args);
704
+ }
705
+ }
706
+ }
707
+
708
+ const PROJECT_DETECTORS = [
709
+ {
710
+ type: "nextjs",
711
+ detect: (files, pkg) => files.includes("next.config.js") || files.includes("next.config.mjs") || files.includes("next.config.ts") || pkg?.dependencies?.next || pkg?.devDependencies?.next,
712
+ recommendedCategories: ["dev", "seo", "performance"],
713
+ recommendedTags: ["react", "nextjs", "ssr", "seo", "frontend"],
714
+ priority: 10
715
+ },
716
+ {
717
+ type: "nuxt",
718
+ detect: (files, pkg) => files.includes("nuxt.config.js") || files.includes("nuxt.config.ts") || pkg?.dependencies?.nuxt || pkg?.devDependencies?.nuxt,
719
+ recommendedCategories: ["dev", "seo", "performance"],
720
+ recommendedTags: ["vue", "nuxt", "ssr", "seo", "frontend"],
721
+ priority: 10
722
+ },
723
+ {
724
+ type: "vue",
725
+ detect: (files, pkg) => files.includes("vue.config.js") || files.includes("vite.config.ts") || files.includes("vite.config.js") || pkg?.dependencies?.vue || pkg?.devDependencies?.vue,
726
+ recommendedCategories: ["dev", "testing", "performance"],
727
+ recommendedTags: ["vue", "vite", "frontend", "spa"],
728
+ priority: 9
729
+ },
730
+ {
731
+ type: "react",
732
+ detect: (_files, pkg) => pkg?.dependencies?.react || pkg?.devDependencies?.react,
733
+ recommendedCategories: ["dev", "testing", "performance"],
734
+ recommendedTags: ["react", "frontend", "spa"],
735
+ priority: 9
736
+ },
737
+ {
738
+ type: "angular",
739
+ detect: (files, pkg) => files.includes("angular.json") || pkg?.dependencies?.["@angular/core"] || pkg?.devDependencies?.["@angular/core"],
740
+ recommendedCategories: ["dev", "testing"],
741
+ recommendedTags: ["angular", "frontend", "spa", "typescript"],
742
+ priority: 9
743
+ },
744
+ {
745
+ type: "node-backend",
746
+ detect: (_files, pkg) => {
747
+ const hasBackendFramework = pkg?.dependencies?.express || pkg?.dependencies?.fastify || pkg?.dependencies?.["@nestjs/core"] || pkg?.dependencies?.koa || pkg?.dependencies?.hono;
748
+ const noFrontendFramework = !pkg?.dependencies?.react && !pkg?.dependencies?.vue && !pkg?.dependencies?.next && !pkg?.dependencies?.nuxt;
749
+ return hasBackendFramework && noFrontendFramework;
750
+ },
751
+ recommendedCategories: ["dev", "testing", "devops", "security"],
752
+ recommendedTags: ["nodejs", "backend", "api", "server"],
753
+ priority: 8
754
+ },
755
+ {
756
+ type: "python",
757
+ detect: (files) => files.includes("requirements.txt") || files.includes("pyproject.toml") || files.includes("setup.py") || files.includes("Pipfile"),
758
+ recommendedCategories: ["dev", "ai", "testing"],
759
+ recommendedTags: ["python", "ml", "data", "backend"],
760
+ priority: 8
761
+ },
762
+ {
763
+ type: "django",
764
+ detect: (files, _pkg) => files.includes("manage.py") || files.includes("requirements.txt"),
765
+ recommendedCategories: ["dev", "testing", "security"],
766
+ recommendedTags: ["python", "django", "backend", "web"],
767
+ priority: 9
768
+ },
769
+ {
770
+ type: "fastapi",
771
+ detect: (files) => files.includes("requirements.txt"),
772
+ recommendedCategories: ["dev", "testing", "docs"],
773
+ recommendedTags: ["python", "fastapi", "backend", "api"],
774
+ priority: 8
775
+ },
776
+ {
777
+ type: "rust",
778
+ detect: (files) => files.includes("Cargo.toml"),
779
+ recommendedCategories: ["dev", "testing", "performance"],
780
+ recommendedTags: ["rust", "systems", "performance"],
781
+ priority: 7
782
+ },
783
+ {
784
+ type: "go",
785
+ detect: (files) => files.includes("go.mod"),
786
+ recommendedCategories: ["dev", "testing", "devops"],
787
+ recommendedTags: ["go", "golang", "backend", "microservices"],
788
+ priority: 7
789
+ },
790
+ {
791
+ type: "monorepo",
792
+ detect: (files, pkg) => files.includes("pnpm-workspace.yaml") || files.includes("lerna.json") || files.includes("nx.json") || pkg?.workspaces != null,
793
+ recommendedCategories: ["dev", "devops", "testing"],
794
+ recommendedTags: ["monorepo", "workspace", "tooling"],
795
+ priority: 6
796
+ },
797
+ {
798
+ type: "docker",
799
+ detect: (files) => files.includes("Dockerfile") || files.includes("docker-compose.yml"),
800
+ recommendedCategories: ["devops", "testing"],
801
+ recommendedTags: ["docker", "containers", "deployment"],
802
+ priority: 5
803
+ },
804
+ {
805
+ type: "typescript",
806
+ detect: (files) => files.includes("tsconfig.json"),
807
+ recommendedCategories: ["dev", "testing"],
808
+ recommendedTags: ["typescript", "types", "tooling"],
809
+ priority: 4
810
+ }
811
+ ];
812
+ class RecommendationEngine {
813
+ cloudClient;
814
+ cache;
815
+ /**
816
+ * Create a new recommendation engine
817
+ *
818
+ * @param cloudClient - Client for fetching cloud recommendations
819
+ * @param cache - Local plugin cache
820
+ */
821
+ constructor(cloudClient, cache) {
822
+ this.cloudClient = cloudClient;
823
+ this.cache = cache;
824
+ }
825
+ /**
826
+ * Get plugin recommendations for a project
827
+ *
828
+ * Analyzes the project and returns personalized plugin recommendations
829
+ * with scoring, reasoning, and confidence levels.
830
+ *
831
+ * @param projectPath - Path to project directory (defaults to cwd)
832
+ * @returns Recommendation result with scored plugins
833
+ */
834
+ async getRecommendations(projectPath) {
835
+ const context = await this.detectProjectContext(projectPath || process__default.cwd());
836
+ let recommendations = [];
837
+ let source = "local";
838
+ try {
839
+ const cloudResult = await this.cloudClient.getRecommendations({
840
+ codeToolType: "claude-code",
841
+ language: context.language,
842
+ installedPlugins: context.existingPlugins,
843
+ limit: 20
844
+ });
845
+ if (cloudResult.success && cloudResult.data) {
846
+ recommendations = cloudResult.data.plugins.map((plugin) => ({
847
+ plugin,
848
+ score: cloudResult.data.scores[plugin.id] || 50,
849
+ reason: {
850
+ "en": cloudResult.data.reasons[plugin.id] || "Recommended by cloud service",
851
+ "zh-CN": cloudResult.data.reasons[plugin.id] || "\u4E91\u670D\u52A1\u63A8\u8350"
852
+ },
853
+ confidence: (cloudResult.data.scores[plugin.id] || 50) / 100,
854
+ matchingTags: [],
855
+ matchingCategories: [],
856
+ isInstalled: context.existingPlugins?.includes(plugin.id) || false
857
+ }));
858
+ source = "cloud";
859
+ }
860
+ } catch {
861
+ console.warn("Cloud recommendations unavailable, using local cache");
862
+ }
863
+ if (recommendations.length === 0) {
864
+ const localResult = this.getLocalRecommendations(context);
865
+ recommendations = localResult.recommendations;
866
+ source = "local";
867
+ }
868
+ if (source === "cloud") {
869
+ const localResult = this.getLocalRecommendations(context);
870
+ recommendations = this.mergeRecommendations(
871
+ { recommendations, context, totalEvaluated: 0, source: "cloud", timestamp: "" },
872
+ localResult
873
+ ).recommendations;
874
+ source = "hybrid";
875
+ }
876
+ recommendations = this.filterInstalledPlugins(recommendations);
877
+ recommendations.sort((a, b) => b.score - a.score);
878
+ return {
879
+ recommendations,
880
+ context,
881
+ totalEvaluated: recommendations.length,
882
+ source,
883
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
884
+ };
885
+ }
886
+ /**
887
+ * Detect project context from directory
888
+ *
889
+ * Analyzes project files and structure to determine frameworks,
890
+ * languages, tools, and recommended plugin categories.
891
+ *
892
+ * @param projectPath - Path to project directory
893
+ * @returns Project context for recommendations
894
+ */
895
+ async detectProjectContext(projectPath) {
896
+ const projectInfo = detectProject(projectPath);
897
+ const files = existsSync(projectPath) ? readdirSync(projectPath) : [];
898
+ let packageJson;
899
+ try {
900
+ const pkgPath = join(projectPath, "package.json");
901
+ if (existsSync(pkgPath)) {
902
+ packageJson = JSON.parse(readFileSync(pkgPath, "utf-8"));
903
+ }
904
+ } catch {
905
+ }
906
+ let detectedType;
907
+ const recommendedCategories = [];
908
+ const recommendedTags = [];
909
+ const sortedDetectors = [...PROJECT_DETECTORS].sort(
910
+ (a, b) => (b.priority || 0) - (a.priority || 0)
911
+ );
912
+ for (const detector of sortedDetectors) {
913
+ if (detector.detect(files, packageJson)) {
914
+ if (!detectedType) {
915
+ detectedType = detector.type;
916
+ }
917
+ recommendedCategories.push(...detector.recommendedCategories);
918
+ recommendedTags.push(...detector.recommendedTags);
919
+ }
920
+ }
921
+ const existingPlugins = [];
922
+ return {
923
+ projectType: detectedType || projectInfo.type,
924
+ language: projectInfo.languages[0],
925
+ frameworks: projectInfo.frameworks,
926
+ languages: projectInfo.languages,
927
+ buildTools: projectInfo.buildTools,
928
+ testFrameworks: projectInfo.testFrameworks,
929
+ hasTypeScript: projectInfo.hasTypeScript,
930
+ hasDocker: projectInfo.hasDocker,
931
+ hasMonorepo: projectInfo.hasMonorepo,
932
+ packageManager: projectInfo.packageManager,
933
+ cicd: projectInfo.cicd,
934
+ rootDir: projectPath,
935
+ recommendedCategories: [...new Set(recommendedCategories)],
936
+ recommendedTags: [...new Set(recommendedTags)],
937
+ existingPlugins
938
+ };
939
+ }
940
+ /**
941
+ * Generate local recommendations without cloud service
942
+ *
943
+ * Uses cached plugins and project context to generate recommendations
944
+ * entirely offline.
945
+ *
946
+ * @param context - Project context
947
+ * @returns Local recommendation result
948
+ */
949
+ getLocalRecommendations(context) {
950
+ const allPlugins = this.cache.getCachedPlugins();
951
+ const recommendations = [];
952
+ for (const plugin of allPlugins) {
953
+ const score = this.calculateRelevanceScore(plugin, context);
954
+ if (score > 0) {
955
+ const matchingTags = this.getMatchingTags(plugin, context);
956
+ const matchingCategories = this.getMatchingCategories(plugin, context);
957
+ const confidence = this.calculateConfidence(score, matchingTags.length, matchingCategories.length);
958
+ const isInstalled = context.existingPlugins?.includes(plugin.id) || false;
959
+ recommendations.push({
960
+ plugin,
961
+ score,
962
+ reason: this.generateReason(plugin, context, matchingTags, matchingCategories),
963
+ confidence,
964
+ matchingTags,
965
+ matchingCategories,
966
+ isInstalled
967
+ });
968
+ }
969
+ }
970
+ return {
971
+ recommendations: recommendations.sort((a, b) => b.score - a.score),
972
+ context,
973
+ totalEvaluated: allPlugins.length,
974
+ source: "local",
975
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
976
+ };
977
+ }
978
+ /**
979
+ * Merge cloud and local recommendations
980
+ *
981
+ * Combines recommendations from both sources, deduplicates,
982
+ * and re-scores based on combined signals.
983
+ *
984
+ * @param cloud - Cloud recommendations
985
+ * @param local - Local recommendations
986
+ * @returns Merged recommendation result
987
+ */
988
+ mergeRecommendations(cloud, local) {
989
+ const merged = /* @__PURE__ */ new Map();
990
+ for (const rec of cloud.recommendations) {
991
+ merged.set(rec.plugin.id, rec);
992
+ }
993
+ for (const rec of local.recommendations) {
994
+ const existing = merged.get(rec.plugin.id);
995
+ if (existing) {
996
+ existing.score = Math.round((existing.score + rec.score) / 2);
997
+ existing.confidence = Math.max(existing.confidence, rec.confidence);
998
+ existing.matchingTags = [.../* @__PURE__ */ new Set([...existing.matchingTags, ...rec.matchingTags])];
999
+ existing.matchingCategories = [.../* @__PURE__ */ new Set([...existing.matchingCategories, ...rec.matchingCategories])];
1000
+ } else {
1001
+ merged.set(rec.plugin.id, rec);
1002
+ }
1003
+ }
1004
+ return {
1005
+ recommendations: Array.from(merged.values()).sort((a, b) => b.score - a.score),
1006
+ context: cloud.context,
1007
+ totalEvaluated: cloud.totalEvaluated + local.totalEvaluated,
1008
+ source: "hybrid",
1009
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1010
+ };
1011
+ }
1012
+ /**
1013
+ * Filter out already installed plugins
1014
+ *
1015
+ * @param recommendations - Plugin recommendations
1016
+ * @returns Filtered recommendations (non-installed only)
1017
+ */
1018
+ filterInstalledPlugins(recommendations) {
1019
+ return recommendations.filter((rec) => !rec.isInstalled);
1020
+ }
1021
+ /**
1022
+ * Calculate relevance score for a plugin
1023
+ *
1024
+ * Scores are based on:
1025
+ * - Category match (40 points)
1026
+ * - Tag match (30 points)
1027
+ * - Framework match (20 points)
1028
+ * - Language match (10 points)
1029
+ *
1030
+ * @param plugin - Plugin to score
1031
+ * @param context - Project context
1032
+ * @returns Relevance score (0-100)
1033
+ */
1034
+ calculateRelevanceScore(plugin, context) {
1035
+ let score = 0;
1036
+ if (context.recommendedCategories?.includes(plugin.category)) {
1037
+ score += 40;
1038
+ }
1039
+ const matchingTags = this.getMatchingTags(plugin, context);
1040
+ score += Math.min(matchingTags.length * 5, 30);
1041
+ if (context.frameworks) {
1042
+ for (const framework of context.frameworks) {
1043
+ if (plugin.tags.some((tag) => tag.toLowerCase().includes(framework.toLowerCase()))) {
1044
+ score += 10;
1045
+ }
1046
+ }
1047
+ score = Math.min(score, 60);
1048
+ }
1049
+ if (context.languages) {
1050
+ for (const lang of context.languages) {
1051
+ if (plugin.tags.some((tag) => tag.toLowerCase().includes(lang.toLowerCase()))) {
1052
+ score += 10;
1053
+ break;
1054
+ }
1055
+ }
1056
+ }
1057
+ return Math.min(score, 100);
1058
+ }
1059
+ /**
1060
+ * Get matching tags between plugin and context
1061
+ *
1062
+ * @param plugin - Plugin to check
1063
+ * @param context - Project context
1064
+ * @returns Array of matching tags
1065
+ */
1066
+ getMatchingTags(plugin, context) {
1067
+ const contextTags = context.recommendedTags || [];
1068
+ return plugin.tags.filter(
1069
+ (tag) => contextTags.some((ctag) => ctag.toLowerCase() === tag.toLowerCase())
1070
+ );
1071
+ }
1072
+ /**
1073
+ * Get matching categories between plugin and context
1074
+ *
1075
+ * @param plugin - Plugin to check
1076
+ * @param context - Project context
1077
+ * @returns Array of matching categories
1078
+ */
1079
+ getMatchingCategories(plugin, context) {
1080
+ const contextCategories = context.recommendedCategories || [];
1081
+ return contextCategories.includes(plugin.category) ? [plugin.category] : [];
1082
+ }
1083
+ /**
1084
+ * Calculate confidence level for recommendation
1085
+ *
1086
+ * Confidence is based on:
1087
+ * - Number of matching signals
1088
+ * - Score magnitude
1089
+ * - Plugin popularity (downloads, rating)
1090
+ *
1091
+ * @param score - Relevance score
1092
+ * @param matchingTagsCount - Number of matching tags
1093
+ * @param matchingCategoriesCount - Number of matching categories
1094
+ * @returns Confidence level (0-1)
1095
+ */
1096
+ calculateConfidence(score, matchingTagsCount, matchingCategoriesCount) {
1097
+ let confidence = score / 100;
1098
+ const signalCount = matchingTagsCount + matchingCategoriesCount;
1099
+ if (signalCount >= 3) {
1100
+ confidence += 0.1;
1101
+ }
1102
+ if (signalCount >= 5) {
1103
+ confidence += 0.1;
1104
+ }
1105
+ return Math.min(confidence, 1);
1106
+ }
1107
+ /**
1108
+ * Generate localized recommendation reason
1109
+ *
1110
+ * Creates human-readable explanation for why a plugin is recommended.
1111
+ *
1112
+ * @param _plugin - Recommended plugin (unused, reserved for future use)
1113
+ * @param context - Project context
1114
+ * @param matchingTags - Matching tags
1115
+ * @param matchingCategories - Matching categories
1116
+ * @returns Localized reason strings
1117
+ */
1118
+ generateReason(_plugin, context, matchingTags, matchingCategories) {
1119
+ const reasons = {
1120
+ "en": "",
1121
+ "zh-CN": ""
1122
+ };
1123
+ const reasonParts = { "en": [], "zh-CN": [] };
1124
+ if (context.projectType) {
1125
+ reasonParts.en.push(`Recommended for ${context.projectType} projects`);
1126
+ reasonParts["zh-CN"].push(`\u63A8\u8350\u7528\u4E8E ${context.projectType} \u9879\u76EE`);
1127
+ }
1128
+ if (matchingCategories.length > 0) {
1129
+ const categoryNames = matchingCategories.join(", ");
1130
+ reasonParts.en.push(`Matches ${categoryNames} category`);
1131
+ reasonParts["zh-CN"].push(`\u5339\u914D ${categoryNames} \u7C7B\u522B`);
1132
+ }
1133
+ if (matchingTags.length > 0) {
1134
+ const tagList = matchingTags.slice(0, 3).join(", ");
1135
+ reasonParts.en.push(`Relevant tags: ${tagList}`);
1136
+ reasonParts["zh-CN"].push(`\u76F8\u5173\u6807\u7B7E: ${tagList}`);
1137
+ }
1138
+ if (context.frameworks && context.frameworks.length > 0) {
1139
+ const frameworks = context.frameworks.slice(0, 2).join(", ");
1140
+ reasonParts.en.push(`Works with ${frameworks}`);
1141
+ reasonParts["zh-CN"].push(`\u9002\u7528\u4E8E ${frameworks}`);
1142
+ }
1143
+ reasons.en = reasonParts.en.join(". ");
1144
+ reasons["zh-CN"] = reasonParts["zh-CN"].join("\u3002");
1145
+ if (!reasons.en) {
1146
+ reasons.en = "General purpose plugin for your project";
1147
+ reasons["zh-CN"] = "\u9002\u7528\u4E8E\u60A8\u9879\u76EE\u7684\u901A\u7528\u63D2\u4EF6";
1148
+ }
1149
+ return reasons;
1150
+ }
1151
+ /**
1152
+ * Get recommendations based on tags
1153
+ *
1154
+ * @param tags - Tags to match
1155
+ * @returns Matching plugins
1156
+ */
1157
+ getTagBasedRecommendations(tags) {
1158
+ const allPlugins = this.cache.getCachedPlugins();
1159
+ return allPlugins.filter(
1160
+ (plugin) => tags.some((tag) => plugin.tags.includes(tag))
1161
+ );
1162
+ }
1163
+ /**
1164
+ * Get recommendations based on category
1165
+ *
1166
+ * @param category - Category to match
1167
+ * @returns Matching plugins
1168
+ */
1169
+ getCategoryBasedRecommendations(category) {
1170
+ const allPlugins = this.cache.getCachedPlugins();
1171
+ return allPlugins.filter((plugin) => plugin.category === category);
1172
+ }
1173
+ }
1174
+
1175
+ let managerInstance = null;
1176
+ function getCloudPluginManager() {
1177
+ if (!managerInstance) {
1178
+ managerInstance = new CloudPluginManager();
1179
+ }
1180
+ return managerInstance;
1181
+ }
1182
+ class CloudPluginManager {
1183
+ client;
1184
+ cache;
1185
+ engine;
1186
+ constructor() {
1187
+ this.ensureDirectories();
1188
+ this.client = new CloudRecommendationClient();
1189
+ this.cache = new LocalPluginCache();
1190
+ this.engine = new RecommendationEngine(this.client, this.cache);
1191
+ }
1192
+ /**
1193
+ * Ensure all required directories exist
1194
+ */
1195
+ ensureDirectories() {
1196
+ const dirs = [
1197
+ CCJK_CLOUD_PLUGINS_DIR,
1198
+ CCJK_CLOUD_PLUGINS_CACHE_DIR,
1199
+ CCJK_CLOUD_PLUGINS_INSTALLED_DIR
1200
+ ];
1201
+ for (const dir of dirs) {
1202
+ if (!existsSync(dir)) {
1203
+ mkdirSync(dir, { recursive: true });
1204
+ }
1205
+ }
1206
+ }
1207
+ /**
1208
+ * Get plugin recommendations for current project
1209
+ */
1210
+ async getRecommendations(projectPath) {
1211
+ return this.engine.getRecommendations(projectPath);
1212
+ }
1213
+ /**
1214
+ * Search for plugins
1215
+ */
1216
+ async searchPlugins(params) {
1217
+ const cloudResult = await this.client.searchPlugins(params);
1218
+ if (cloudResult.success && cloudResult.data) {
1219
+ this.cache.updateCache(cloudResult.data);
1220
+ return cloudResult;
1221
+ }
1222
+ const cachedPlugins = this.cache.getCachedPlugins();
1223
+ let filtered = cachedPlugins;
1224
+ if (params.query) {
1225
+ const query = params.query.toLowerCase();
1226
+ filtered = filtered.filter(
1227
+ (p) => p.name.en.toLowerCase().includes(query) || p.name["zh-CN"].toLowerCase().includes(query) || p.tags.some((t) => t.toLowerCase().includes(query))
1228
+ );
1229
+ }
1230
+ if (params.category) {
1231
+ filtered = filtered.filter((p) => p.category === params.category);
1232
+ }
1233
+ if (params.tags && params.tags.length > 0) {
1234
+ filtered = filtered.filter(
1235
+ (p) => params.tags.some((tag) => p.tags.includes(tag))
1236
+ );
1237
+ }
1238
+ if (params.sortBy) {
1239
+ filtered.sort((a, b) => {
1240
+ const order = params.order === "asc" ? 1 : -1;
1241
+ switch (params.sortBy) {
1242
+ case "downloads":
1243
+ return (a.downloads - b.downloads) * order;
1244
+ case "rating":
1245
+ return (a.rating - b.rating) * order;
1246
+ case "updated":
1247
+ return (new Date(a.updatedAt).getTime() - new Date(b.updatedAt).getTime()) * order;
1248
+ case "name":
1249
+ return a.name.en.localeCompare(b.name.en) * order;
1250
+ default:
1251
+ return 0;
1252
+ }
1253
+ });
1254
+ }
1255
+ const page = params.page || 1;
1256
+ const pageSize = params.pageSize || 10;
1257
+ const start = (page - 1) * pageSize;
1258
+ const paged = filtered.slice(start, start + pageSize);
1259
+ return {
1260
+ success: true,
1261
+ data: paged
1262
+ };
1263
+ }
1264
+ /**
1265
+ * Get plugin details
1266
+ */
1267
+ async getPlugin(id) {
1268
+ const cloudResult = await this.client.getPlugin(id);
1269
+ if (cloudResult.success && cloudResult.data) {
1270
+ return cloudResult;
1271
+ }
1272
+ const cached = this.cache.getCachedPlugin(id);
1273
+ if (cached) {
1274
+ return { success: true, data: cached };
1275
+ }
1276
+ return {
1277
+ success: false,
1278
+ error: i18n.t("cloudPlugins.errors.notFound")
1279
+ };
1280
+ }
1281
+ /**
1282
+ * Get popular plugins
1283
+ */
1284
+ async getPopularPlugins(limit = 10) {
1285
+ const cloudResult = await this.client.getPopularPlugins(limit);
1286
+ if (cloudResult.success && cloudResult.data) {
1287
+ this.cache.updateCache(cloudResult.data);
1288
+ return cloudResult;
1289
+ }
1290
+ const cached = this.cache.getCachedPlugins().sort((a, b) => b.downloads - a.downloads).slice(0, limit);
1291
+ return { success: true, data: cached };
1292
+ }
1293
+ /**
1294
+ * Get plugin categories
1295
+ */
1296
+ async getCategories() {
1297
+ return this.client.getCategories();
1298
+ }
1299
+ /**
1300
+ * Install a plugin
1301
+ */
1302
+ async installPlugin(id, options = {}) {
1303
+ const installDir = join(CCJK_CLOUD_PLUGINS_INSTALLED_DIR, id);
1304
+ if (existsSync(installDir) && !options.force) {
1305
+ return {
1306
+ pluginId: id,
1307
+ success: false,
1308
+ error: "Plugin already installed. Use --force to reinstall."
1309
+ };
1310
+ }
1311
+ if (options.dryRun) {
1312
+ return {
1313
+ pluginId: id,
1314
+ success: true,
1315
+ installedPath: installDir
1316
+ };
1317
+ }
1318
+ try {
1319
+ const pluginResult = await this.getPlugin(id);
1320
+ if (!pluginResult.success || !pluginResult.data) {
1321
+ return {
1322
+ pluginId: id,
1323
+ success: false,
1324
+ error: pluginResult.error || "Plugin not found"
1325
+ };
1326
+ }
1327
+ const plugin = pluginResult.data;
1328
+ const downloadResult = await this.client.downloadPlugin(id);
1329
+ if (!downloadResult.success || !downloadResult.data) {
1330
+ return {
1331
+ pluginId: id,
1332
+ success: false,
1333
+ error: downloadResult.error || "Failed to download plugin"
1334
+ };
1335
+ }
1336
+ if (existsSync(installDir)) {
1337
+ rmSync(installDir, { recursive: true });
1338
+ }
1339
+ mkdirSync(installDir, { recursive: true });
1340
+ writeFileAtomic(
1341
+ join(installDir, "plugin.json"),
1342
+ JSON.stringify(plugin, null, 2)
1343
+ );
1344
+ const content = Buffer.from(downloadResult.data.content, "base64").toString("utf-8");
1345
+ writeFileAtomic(join(installDir, "content.json"), content);
1346
+ const installedDeps = [];
1347
+ if (!options.skipDependencies && plugin.dependencies) {
1348
+ for (const dep of plugin.dependencies) {
1349
+ const depResult = await this.installPlugin(dep, { skipDependencies: true });
1350
+ if (depResult.success) {
1351
+ installedDeps.push(dep);
1352
+ }
1353
+ }
1354
+ }
1355
+ return {
1356
+ pluginId: id,
1357
+ success: true,
1358
+ installedPath: installDir,
1359
+ dependencies: installedDeps
1360
+ };
1361
+ } catch (error) {
1362
+ return {
1363
+ pluginId: id,
1364
+ success: false,
1365
+ error: error instanceof Error ? error.message : "Unknown error"
1366
+ };
1367
+ }
1368
+ }
1369
+ /**
1370
+ * Uninstall a plugin
1371
+ */
1372
+ async uninstallPlugin(id) {
1373
+ const installDir = join(CCJK_CLOUD_PLUGINS_INSTALLED_DIR, id);
1374
+ if (!existsSync(installDir)) {
1375
+ return {
1376
+ pluginId: id,
1377
+ success: false,
1378
+ error: "Plugin not installed"
1379
+ };
1380
+ }
1381
+ try {
1382
+ rmSync(installDir, { recursive: true });
1383
+ return {
1384
+ pluginId: id,
1385
+ success: true
1386
+ };
1387
+ } catch (error) {
1388
+ return {
1389
+ pluginId: id,
1390
+ success: false,
1391
+ error: error instanceof Error ? error.message : "Unknown error"
1392
+ };
1393
+ }
1394
+ }
1395
+ /**
1396
+ * Get installed plugins
1397
+ */
1398
+ getInstalledPlugins() {
1399
+ if (!existsSync(CCJK_CLOUD_PLUGINS_INSTALLED_DIR)) {
1400
+ return [];
1401
+ }
1402
+ const plugins = [];
1403
+ const dirs = readdirSync(CCJK_CLOUD_PLUGINS_INSTALLED_DIR, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
1404
+ for (const dir of dirs) {
1405
+ const metaPath = join(CCJK_CLOUD_PLUGINS_INSTALLED_DIR, dir, "plugin.json");
1406
+ if (existsSync(metaPath)) {
1407
+ try {
1408
+ const plugin = JSON.parse(readFileSync(metaPath, "utf-8"));
1409
+ plugins.push(plugin);
1410
+ } catch {
1411
+ }
1412
+ }
1413
+ }
1414
+ return plugins;
1415
+ }
1416
+ /**
1417
+ * Check if a plugin is installed
1418
+ */
1419
+ isPluginInstalled(id) {
1420
+ const installDir = join(CCJK_CLOUD_PLUGINS_INSTALLED_DIR, id);
1421
+ return existsSync(join(installDir, "plugin.json"));
1422
+ }
1423
+ /**
1424
+ * Update installed plugins
1425
+ */
1426
+ async updatePlugins(ids) {
1427
+ const installed = this.getInstalledPlugins();
1428
+ const toUpdate = ids ? installed.filter((p) => ids.includes(p.id)) : installed;
1429
+ const results = [];
1430
+ for (const plugin of toUpdate) {
1431
+ const cloudResult = await this.getPlugin(plugin.id);
1432
+ if (cloudResult.success && cloudResult.data) {
1433
+ const cloudPlugin = cloudResult.data;
1434
+ if (cloudPlugin.version !== plugin.version) {
1435
+ const result = await this.installPlugin(plugin.id, { force: true });
1436
+ results.push(result);
1437
+ } else {
1438
+ results.push({
1439
+ pluginId: plugin.id,
1440
+ success: true,
1441
+ installedPath: join(CCJK_CLOUD_PLUGINS_INSTALLED_DIR, plugin.id)
1442
+ });
1443
+ }
1444
+ }
1445
+ }
1446
+ return results;
1447
+ }
1448
+ /**
1449
+ * Get cache statistics
1450
+ */
1451
+ getCacheStats() {
1452
+ return this.cache.getCacheStats();
1453
+ }
1454
+ /**
1455
+ * Clear cache
1456
+ */
1457
+ clearCache() {
1458
+ this.cache.clearCache();
1459
+ }
1460
+ /**
1461
+ * Refresh cache from cloud
1462
+ */
1463
+ async refreshCache() {
1464
+ const result = await this.client.getPopularPlugins(100);
1465
+ if (result.success && result.data) {
1466
+ this.cache.updateCache(result.data);
1467
+ }
1468
+ }
1469
+ /**
1470
+ * Get plugin info (alias for getPlugin with simplified return)
1471
+ */
1472
+ async getPluginInfo(id) {
1473
+ const result = await this.getPlugin(id);
1474
+ return result.success && result.data ? result.data : null;
1475
+ }
1476
+ /**
1477
+ * Get featured/popular plugins
1478
+ */
1479
+ async getFeaturedPlugins(limit = 10) {
1480
+ const result = await this.getPopularPlugins(limit);
1481
+ return result.success && result.data ? result.data : [];
1482
+ }
1483
+ /**
1484
+ * Update a single plugin
1485
+ */
1486
+ async updatePlugin(id) {
1487
+ if (!this.isPluginInstalled(id)) {
1488
+ return {
1489
+ success: false,
1490
+ pluginId: id,
1491
+ updated: false,
1492
+ error: "Plugin not installed"
1493
+ };
1494
+ }
1495
+ const installDir = join(CCJK_CLOUD_PLUGINS_INSTALLED_DIR, id);
1496
+ const metaPath = join(installDir, "plugin.json");
1497
+ let currentVersion = "0.0.0";
1498
+ try {
1499
+ const meta = JSON.parse(readFileSync(metaPath, "utf-8"));
1500
+ currentVersion = meta.version || "0.0.0";
1501
+ } catch {
1502
+ }
1503
+ const cloudResult = await this.getPlugin(id);
1504
+ if (!cloudResult.success || !cloudResult.data) {
1505
+ return {
1506
+ success: false,
1507
+ pluginId: id,
1508
+ updated: false,
1509
+ error: cloudResult.error || "Failed to fetch plugin info"
1510
+ };
1511
+ }
1512
+ const cloudPlugin = cloudResult.data;
1513
+ if (cloudPlugin.version === currentVersion) {
1514
+ return {
1515
+ success: true,
1516
+ pluginId: id,
1517
+ updated: false,
1518
+ oldVersion: currentVersion,
1519
+ newVersion: currentVersion
1520
+ };
1521
+ }
1522
+ const installResult = await this.installPlugin(id, { force: true });
1523
+ if (!installResult.success) {
1524
+ return {
1525
+ success: false,
1526
+ pluginId: id,
1527
+ updated: false,
1528
+ error: installResult.error
1529
+ };
1530
+ }
1531
+ return {
1532
+ success: true,
1533
+ pluginId: id,
1534
+ updated: true,
1535
+ oldVersion: currentVersion,
1536
+ newVersion: cloudPlugin.version
1537
+ };
1538
+ }
1539
+ /**
1540
+ * Update all installed plugins
1541
+ */
1542
+ async updateAllPlugins() {
1543
+ const installed = this.getInstalledPlugins();
1544
+ const results = [];
1545
+ for (const plugin of installed) {
1546
+ const result = await this.updatePlugin(plugin.id);
1547
+ results.push(result);
1548
+ }
1549
+ return results;
1550
+ }
1551
+ }
1552
+
1553
+ function getPluginName(plugin) {
1554
+ const lang = i18n.language;
1555
+ return plugin.name[lang] || plugin.name.en || plugin.id;
1556
+ }
1557
+ function getPluginDescription(plugin) {
1558
+ const lang = i18n.language;
1559
+ return plugin.description[lang] || plugin.description.en || "";
1560
+ }
1561
+ async function pluginCommand(action = "list", args = [], options = {}) {
1562
+ const isZh = i18n.language === "zh-CN";
1563
+ try {
1564
+ switch (action) {
1565
+ case "list":
1566
+ case "ls":
1567
+ case "l":
1568
+ await listPlugins(options);
1569
+ break;
1570
+ case "install":
1571
+ case "i":
1572
+ case "add":
1573
+ if (args.length === 0) {
1574
+ console.log(a.red(isZh ? "\u274C \u8BF7\u6307\u5B9A\u8981\u5B89\u88C5\u7684\u63D2\u4EF6 ID" : "\u274C Please specify a plugin ID to install"));
1575
+ console.log(a.gray(isZh ? "\u7528\u6CD5: /plugin install <plugin-id>" : "Usage: /plugin install <plugin-id>"));
1576
+ process__default.exit(1);
1577
+ }
1578
+ await installPlugin(args[0], options);
1579
+ break;
1580
+ case "uninstall":
1581
+ case "remove":
1582
+ case "rm":
1583
+ if (args.length === 0) {
1584
+ console.log(a.red(isZh ? "\u274C \u8BF7\u6307\u5B9A\u8981\u5378\u8F7D\u7684\u63D2\u4EF6 ID" : "\u274C Please specify a plugin ID to uninstall"));
1585
+ console.log(a.gray(isZh ? "\u7528\u6CD5: /plugin uninstall <plugin-id>" : "Usage: /plugin uninstall <plugin-id>"));
1586
+ process__default.exit(1);
1587
+ }
1588
+ await uninstallPlugin(args[0]);
1589
+ break;
1590
+ case "search":
1591
+ case "s":
1592
+ case "find":
1593
+ if (args.length === 0) {
1594
+ console.log(a.red(isZh ? "\u274C \u8BF7\u6307\u5B9A\u641C\u7D22\u5173\u952E\u8BCD" : "\u274C Please specify a search query"));
1595
+ console.log(a.gray(isZh ? "\u7528\u6CD5: /plugin search <\u5173\u952E\u8BCD>" : "Usage: /plugin search <query>"));
1596
+ process__default.exit(1);
1597
+ }
1598
+ await searchPlugins(args.join(" "), options);
1599
+ break;
1600
+ case "info":
1601
+ case "show":
1602
+ case "details":
1603
+ if (args.length === 0) {
1604
+ console.log(a.red(isZh ? "\u274C \u8BF7\u6307\u5B9A\u63D2\u4EF6 ID" : "\u274C Please specify a plugin ID"));
1605
+ console.log(a.gray(isZh ? "\u7528\u6CD5: /plugin info <plugin-id>" : "Usage: /plugin info <plugin-id>"));
1606
+ process__default.exit(1);
1607
+ }
1608
+ await showPluginInfo(args[0]);
1609
+ break;
1610
+ case "update":
1611
+ case "upgrade":
1612
+ await updatePlugins(args[0]);
1613
+ break;
1614
+ case "categories":
1615
+ case "cats":
1616
+ await listCategories();
1617
+ break;
1618
+ case "featured":
1619
+ case "popular":
1620
+ case "trending":
1621
+ await showFeaturedPlugins();
1622
+ break;
1623
+ case "help":
1624
+ case "h":
1625
+ case "?":
1626
+ showHelp();
1627
+ break;
1628
+ default:
1629
+ console.log(a.red(isZh ? `\u274C \u672A\u77E5\u547D\u4EE4: ${action}` : `\u274C Unknown command: ${action}`));
1630
+ showHelp();
1631
+ process__default.exit(1);
1632
+ }
1633
+ } catch (error) {
1634
+ const errorMessage = error instanceof Error ? error.message : String(error);
1635
+ console.log(a.red(`
1636
+ \u274C ${isZh ? "\u9519\u8BEF" : "Error"}: ${errorMessage}`));
1637
+ if (options.verbose) {
1638
+ console.error(error);
1639
+ }
1640
+ process__default.exit(1);
1641
+ }
1642
+ }
1643
+ async function listPlugins(options) {
1644
+ const isZh = i18n.language === "zh-CN";
1645
+ const manager = getCloudPluginManager();
1646
+ console.log(a.green.bold(`
1647
+ \u{1F4E6} ${isZh ? "\u5DF2\u5B89\u88C5\u7684\u63D2\u4EF6" : "Installed Plugins"}
1648
+ `));
1649
+ const installed = manager.getInstalledPlugins();
1650
+ if (installed.length === 0) {
1651
+ console.log(a.gray(isZh ? "\u6682\u65E0\u5DF2\u5B89\u88C5\u7684\u63D2\u4EF6" : "No plugins installed"));
1652
+ console.log(a.gray(`
1653
+ \u{1F4A1} ${isZh ? "\u4F7F\u7528 /plugin search <\u5173\u952E\u8BCD> \u641C\u7D22\u63D2\u4EF6" : "Use /plugin search <query> to find plugins"}`));
1654
+ return;
1655
+ }
1656
+ for (const plugin of installed) {
1657
+ console.log(` ${a.green("\u25CF")} ${a.bold(getPluginName(plugin))} ${a.gray(`v${plugin.version}`)}`);
1658
+ console.log(` ${a.gray(getPluginDescription(plugin))}`);
1659
+ if (options.verbose && plugin.author) {
1660
+ console.log(` ${a.gray(`by ${plugin.author}`)}`);
1661
+ }
1662
+ console.log("");
1663
+ }
1664
+ console.log(a.gray(`${isZh ? "\u5171" : "Total"} ${installed.length} ${isZh ? "\u4E2A\u63D2\u4EF6" : "plugins"}`));
1665
+ }
1666
+ async function installPlugin(pluginId, options) {
1667
+ const isZh = i18n.language === "zh-CN";
1668
+ const manager = getCloudPluginManager();
1669
+ console.log(a.green(`
1670
+ \u23F3 ${isZh ? "\u6B63\u5728\u83B7\u53D6\u63D2\u4EF6\u4FE1\u606F..." : "Fetching plugin info..."}`));
1671
+ const pluginInfo = await manager.getPluginInfo(pluginId);
1672
+ if (!pluginInfo) {
1673
+ console.log(a.red(`
1674
+ \u274C ${isZh ? "\u63D2\u4EF6\u672A\u627E\u5230" : "Plugin not found"}: ${pluginId}`));
1675
+ console.log(a.gray(`
1676
+ \u{1F4A1} ${isZh ? "\u4F7F\u7528 /plugin search <\u5173\u952E\u8BCD> \u641C\u7D22\u53EF\u7528\u63D2\u4EF6" : "Use /plugin search <query> to find available plugins"}`));
1677
+ const searchResult = await manager.searchPlugins({ query: pluginId, pageSize: 3 });
1678
+ if (searchResult.success && searchResult.data && searchResult.data.length > 0) {
1679
+ console.log(a.yellow(`
1680
+ ${isZh ? "\u60A8\u662F\u5426\u5728\u627E:" : "Did you mean:"}`));
1681
+ for (const p of searchResult.data) {
1682
+ console.log(` - ${a.green(p.id)} - ${getPluginName(p)}`);
1683
+ }
1684
+ }
1685
+ process__default.exit(1);
1686
+ }
1687
+ const isInstalled = manager.isPluginInstalled(pluginId);
1688
+ if (isInstalled && !options.force) {
1689
+ console.log(a.yellow(`
1690
+ \u26A0\uFE0F ${isZh ? "\u63D2\u4EF6\u5DF2\u5B89\u88C5" : "Plugin already installed"}: ${getPluginName(pluginInfo)}`));
1691
+ console.log(a.gray(`\u{1F4A1} ${isZh ? "\u4F7F\u7528 --force \u5F3A\u5236\u91CD\u65B0\u5B89\u88C5" : "Use --force to reinstall"}`));
1692
+ return;
1693
+ }
1694
+ console.log(a.green.bold(`
1695
+ \u{1F4E6} ${getPluginName(pluginInfo)}`));
1696
+ console.log(a.gray(` ${getPluginDescription(pluginInfo)}`));
1697
+ console.log(a.gray(` ${isZh ? "\u7248\u672C" : "Version"}: ${pluginInfo.version}`));
1698
+ if (pluginInfo.author) {
1699
+ console.log(a.gray(` ${isZh ? "\u4F5C\u8005" : "Author"}: ${pluginInfo.author}`));
1700
+ }
1701
+ console.log("");
1702
+ console.log(a.green(`\u23F3 ${isZh ? "\u6B63\u5728\u5B89\u88C5..." : "Installing..."}`));
1703
+ const result = await manager.installPlugin(pluginId, {
1704
+ force: options.force
1705
+ });
1706
+ if (result.success) {
1707
+ console.log(a.green(`
1708
+ \u2705 ${isZh ? "\u5B89\u88C5\u6210\u529F" : "Installation successful"}!`));
1709
+ console.log(a.gray(` ${isZh ? "\u8DEF\u5F84" : "Path"}: ${result.installedPath}`));
1710
+ if (result.dependencies && result.dependencies.length > 0) {
1711
+ console.log(a.gray(` ${isZh ? "\u4F9D\u8D56" : "Dependencies"}: ${result.dependencies.join(", ")}`));
1712
+ }
1713
+ } else {
1714
+ console.log(a.red(`
1715
+ \u274C ${isZh ? "\u5B89\u88C5\u5931\u8D25" : "Installation failed"}: ${result.error}`));
1716
+ process__default.exit(1);
1717
+ }
1718
+ }
1719
+ async function uninstallPlugin(pluginId) {
1720
+ const isZh = i18n.language === "zh-CN";
1721
+ const manager = getCloudPluginManager();
1722
+ const isInstalled = manager.isPluginInstalled(pluginId);
1723
+ if (!isInstalled) {
1724
+ console.log(a.yellow(`
1725
+ \u26A0\uFE0F ${isZh ? "\u63D2\u4EF6\u672A\u5B89\u88C5" : "Plugin not installed"}: ${pluginId}`));
1726
+ return;
1727
+ }
1728
+ console.log(a.green(`
1729
+ \u23F3 ${isZh ? "\u6B63\u5728\u5378\u8F7D..." : "Uninstalling..."}`));
1730
+ const result = await manager.uninstallPlugin(pluginId);
1731
+ if (result.success) {
1732
+ console.log(a.green(`
1733
+ \u2705 ${isZh ? "\u5378\u8F7D\u6210\u529F" : "Uninstallation successful"}!`));
1734
+ } else {
1735
+ console.log(a.red(`
1736
+ \u274C ${isZh ? "\u5378\u8F7D\u5931\u8D25" : "Uninstallation failed"}: ${result.error}`));
1737
+ process__default.exit(1);
1738
+ }
1739
+ }
1740
+ async function searchPlugins(query, options) {
1741
+ const isZh = i18n.language === "zh-CN";
1742
+ const manager = getCloudPluginManager();
1743
+ console.log(a.green(`
1744
+ \u{1F50D} ${isZh ? "\u641C\u7D22" : "Searching"}: "${query}"
1745
+ `));
1746
+ const result = await manager.searchPlugins({ query, pageSize: 20 });
1747
+ if (!result.success || !result.data || result.data.length === 0) {
1748
+ console.log(a.yellow(isZh ? "\u672A\u627E\u5230\u5339\u914D\u7684\u63D2\u4EF6" : "No plugins found"));
1749
+ console.log(a.gray(`
1750
+ \u{1F4A1} ${isZh ? "\u5C1D\u8BD5\u4F7F\u7528\u4E0D\u540C\u7684\u5173\u952E\u8BCD" : "Try different keywords"}`));
1751
+ return;
1752
+ }
1753
+ console.log(a.bold(isZh ? "\u641C\u7D22\u7ED3\u679C:" : "Search Results:"));
1754
+ console.log("");
1755
+ for (const plugin of result.data) {
1756
+ const installed = manager.isPluginInstalled(plugin.id);
1757
+ const statusIcon = installed ? a.green("\u25CF") : a.gray("\u25CB");
1758
+ console.log(` ${statusIcon} ${a.bold(getPluginName(plugin))} ${a.gray(`(${plugin.id})`)} ${a.gray(`v${plugin.version}`)}`);
1759
+ console.log(` ${a.gray(getPluginDescription(plugin))}`);
1760
+ if (options.verbose) {
1761
+ if (plugin.downloads) {
1762
+ console.log(` ${a.gray(`\u2B07\uFE0F ${plugin.downloads.toLocaleString()} downloads`)}`);
1763
+ }
1764
+ if (plugin.rating) {
1765
+ console.log(` ${a.gray(`\u2B50 ${plugin.rating.toFixed(1)}`)}`);
1766
+ }
1767
+ }
1768
+ console.log("");
1769
+ }
1770
+ console.log(a.gray(`${isZh ? "\u5171\u627E\u5230" : "Found"} ${result.data.length} ${isZh ? "\u4E2A\u63D2\u4EF6" : "plugins"}`));
1771
+ console.log(a.gray(`
1772
+ \u{1F4A1} ${isZh ? "\u4F7F\u7528 /plugin install <id> \u5B89\u88C5\u63D2\u4EF6" : "Use /plugin install <id> to install a plugin"}`));
1773
+ }
1774
+ async function showPluginInfo(pluginId) {
1775
+ const isZh = i18n.language === "zh-CN";
1776
+ const manager = getCloudPluginManager();
1777
+ const plugin = await manager.getPluginInfo(pluginId);
1778
+ if (!plugin) {
1779
+ console.log(a.red(`
1780
+ \u274C ${isZh ? "\u63D2\u4EF6\u672A\u627E\u5230" : "Plugin not found"}: ${pluginId}`));
1781
+ process__default.exit(1);
1782
+ }
1783
+ const installed = manager.isPluginInstalled(pluginId);
1784
+ console.log(a.green.bold(`
1785
+ \u{1F4E6} ${getPluginName(plugin)}`));
1786
+ console.log(a.dim("\u2500".repeat(50)));
1787
+ console.log(`${a.bold(isZh ? "\u63CF\u8FF0" : "Description")}: ${getPluginDescription(plugin)}`);
1788
+ console.log(`${a.bold("ID")}: ${plugin.id}`);
1789
+ console.log(`${a.bold(isZh ? "\u7248\u672C" : "Version")}: ${plugin.version}`);
1790
+ console.log(`${a.bold(isZh ? "\u72B6\u6001" : "Status")}: ${installed ? a.green(isZh ? "\u5DF2\u5B89\u88C5" : "Installed") : a.gray(isZh ? "\u672A\u5B89\u88C5" : "Not installed")}`);
1791
+ if (plugin.author) {
1792
+ console.log(`${a.bold(isZh ? "\u4F5C\u8005" : "Author")}: ${plugin.author}`);
1793
+ }
1794
+ if (plugin.category) {
1795
+ console.log(`${a.bold(isZh ? "\u5206\u7C7B" : "Category")}: ${plugin.category}`);
1796
+ }
1797
+ if (plugin.tags && plugin.tags.length > 0) {
1798
+ console.log(`${a.bold(isZh ? "\u6807\u7B7E" : "Tags")}: ${plugin.tags.join(", ")}`);
1799
+ }
1800
+ if (plugin.downloads) {
1801
+ console.log(`${a.bold(isZh ? "\u4E0B\u8F7D\u91CF" : "Downloads")}: ${plugin.downloads.toLocaleString()}`);
1802
+ }
1803
+ if (plugin.rating) {
1804
+ console.log(`${a.bold(isZh ? "\u8BC4\u5206" : "Rating")}: \u2B50 ${plugin.rating.toFixed(1)}`);
1805
+ }
1806
+ console.log(a.dim("\u2500".repeat(50)));
1807
+ if (!installed) {
1808
+ console.log(a.gray(`
1809
+ \u{1F4A1} ${isZh ? "\u4F7F\u7528 /plugin install" : "Use /plugin install"} ${pluginId} ${isZh ? "\u5B89\u88C5\u6B64\u63D2\u4EF6" : "to install this plugin"}`));
1810
+ }
1811
+ }
1812
+ async function updatePlugins(pluginId) {
1813
+ const isZh = i18n.language === "zh-CN";
1814
+ const manager = getCloudPluginManager();
1815
+ if (pluginId) {
1816
+ console.log(a.green(`
1817
+ \u23F3 ${isZh ? "\u6B63\u5728\u66F4\u65B0" : "Updating"} ${pluginId}...`));
1818
+ const result = await manager.updatePlugin(pluginId);
1819
+ if (result.success) {
1820
+ if (result.updated) {
1821
+ console.log(a.green(`
1822
+ \u2705 ${isZh ? "\u66F4\u65B0\u6210\u529F" : "Update successful"}! ${result.oldVersion} \u2192 ${result.newVersion}`));
1823
+ } else {
1824
+ console.log(a.gray(`
1825
+ \u2713 ${isZh ? "\u5DF2\u662F\u6700\u65B0\u7248\u672C" : "Already up to date"}`));
1826
+ }
1827
+ } else {
1828
+ console.log(a.red(`
1829
+ \u274C ${isZh ? "\u66F4\u65B0\u5931\u8D25" : "Update failed"}: ${result.error}`));
1830
+ process__default.exit(1);
1831
+ }
1832
+ } else {
1833
+ console.log(a.green(`
1834
+ \u23F3 ${isZh ? "\u6B63\u5728\u68C0\u67E5\u66F4\u65B0..." : "Checking for updates..."}`));
1835
+ const results = await manager.updateAllPlugins();
1836
+ let updatedCount = 0;
1837
+ for (const result of results) {
1838
+ if (result.success && result.updated) {
1839
+ console.log(a.green(` \u2705 ${result.pluginId}: ${result.oldVersion} \u2192 ${result.newVersion}`));
1840
+ updatedCount++;
1841
+ }
1842
+ }
1843
+ if (updatedCount === 0) {
1844
+ console.log(a.gray(`
1845
+ \u2713 ${isZh ? "\u6240\u6709\u63D2\u4EF6\u5DF2\u662F\u6700\u65B0\u7248\u672C" : "All plugins are up to date"}`));
1846
+ } else {
1847
+ console.log(a.green(`
1848
+ \u2705 ${isZh ? "\u5DF2\u66F4\u65B0" : "Updated"} ${updatedCount} ${isZh ? "\u4E2A\u63D2\u4EF6" : "plugins"}`));
1849
+ }
1850
+ }
1851
+ }
1852
+ async function listCategories() {
1853
+ const isZh = i18n.language === "zh-CN";
1854
+ const manager = getCloudPluginManager();
1855
+ console.log(a.green.bold(`
1856
+ \u{1F4C2} ${isZh ? "\u63D2\u4EF6\u5206\u7C7B" : "Plugin Categories"}
1857
+ `));
1858
+ const result = await manager.getCategories();
1859
+ if (!result.success || !result.data || result.data.length === 0) {
1860
+ console.log(a.gray(isZh ? "\u6682\u65E0\u5206\u7C7B\u4FE1\u606F" : "No categories available"));
1861
+ return;
1862
+ }
1863
+ for (const cat of result.data) {
1864
+ const name = isZh ? cat.name["zh-CN"] || cat.name.en : cat.name.en;
1865
+ console.log(` \u{1F4E6} ${a.bold(name)} ${a.gray(`(${cat.count} ${isZh ? "\u4E2A\u63D2\u4EF6" : "plugins"})`)}`);
1866
+ }
1867
+ }
1868
+ async function showFeaturedPlugins() {
1869
+ const isZh = i18n.language === "zh-CN";
1870
+ const manager = getCloudPluginManager();
1871
+ console.log(a.green.bold(`
1872
+ \u2B50 ${isZh ? "\u7CBE\u9009\u63D2\u4EF6" : "Featured Plugins"}
1873
+ `));
1874
+ const featured = await manager.getFeaturedPlugins();
1875
+ if (!featured || featured.length === 0) {
1876
+ console.log(a.gray(isZh ? "\u6682\u65E0\u7CBE\u9009\u63D2\u4EF6" : "No featured plugins available"));
1877
+ return;
1878
+ }
1879
+ for (const plugin of featured) {
1880
+ const installed = manager.isPluginInstalled(plugin.id);
1881
+ const statusIcon = installed ? a.green("\u25CF") : a.gray("\u25CB");
1882
+ console.log(` ${statusIcon} ${a.bold(getPluginName(plugin))} ${a.gray(`v${plugin.version}`)}`);
1883
+ console.log(` ${a.gray(getPluginDescription(plugin))}`);
1884
+ console.log("");
1885
+ }
1886
+ console.log(a.gray(`
1887
+ \u{1F4A1} ${isZh ? "\u4F7F\u7528 /plugin install <id> \u5B89\u88C5\u63D2\u4EF6" : "Use /plugin install <id> to install a plugin"}`));
1888
+ }
1889
+ function showHelp() {
1890
+ const isZh = i18n.language === "zh-CN";
1891
+ console.log(a.green.bold(`
1892
+ \u{1F4E6} ${isZh ? "CCJK \u63D2\u4EF6\u7BA1\u7406" : "CCJK Plugin Manager"}
1893
+ `));
1894
+ console.log(a.dim("\u2500".repeat(50)));
1895
+ console.log("");
1896
+ console.log(a.bold(isZh ? "\u7528\u6CD5:" : "Usage:"));
1897
+ console.log(" /plugin <command> [options]");
1898
+ console.log("");
1899
+ console.log(a.bold(isZh ? "\u547D\u4EE4:" : "Commands:"));
1900
+ console.log(` ${a.green("list")} ${isZh ? "\u5217\u51FA\u5DF2\u5B89\u88C5\u7684\u63D2\u4EF6" : "List installed plugins"}`);
1901
+ console.log(` ${a.green("install")} <id> ${isZh ? "\u5B89\u88C5\u63D2\u4EF6" : "Install a plugin"}`);
1902
+ console.log(` ${a.green("uninstall")} <id> ${isZh ? "\u5378\u8F7D\u63D2\u4EF6" : "Uninstall a plugin"}`);
1903
+ console.log(` ${a.green("search")} <query> ${isZh ? "\u641C\u7D22\u63D2\u4EF6" : "Search for plugins"}`);
1904
+ console.log(` ${a.green("info")} <id> ${isZh ? "\u663E\u793A\u63D2\u4EF6\u8BE6\u60C5" : "Show plugin details"}`);
1905
+ console.log(` ${a.green("update")} [id] ${isZh ? "\u66F4\u65B0\u63D2\u4EF6" : "Update plugin(s)"}`);
1906
+ console.log(` ${a.green("categories")} ${isZh ? "\u5217\u51FA\u63D2\u4EF6\u5206\u7C7B" : "List plugin categories"}`);
1907
+ console.log(` ${a.green("featured")} ${isZh ? "\u663E\u793A\u7CBE\u9009\u63D2\u4EF6" : "Show featured plugins"}`);
1908
+ console.log(` ${a.green("help")} ${isZh ? "\u663E\u793A\u5E2E\u52A9" : "Show this help"}`);
1909
+ console.log("");
1910
+ console.log(a.bold(isZh ? "\u793A\u4F8B:" : "Examples:"));
1911
+ console.log(` /plugin search git ${a.gray(isZh ? "# \u641C\u7D22 git \u76F8\u5173\u63D2\u4EF6" : "# Search for git plugins")}`);
1912
+ console.log(` /plugin install code-simplifier ${a.gray(isZh ? "# \u5B89\u88C5\u63D2\u4EF6" : "# Install a plugin")}`);
1913
+ console.log(` /plugin info code-simplifier ${a.gray(isZh ? "# \u67E5\u770B\u63D2\u4EF6\u8BE6\u60C5" : "# View plugin details")}`);
1914
+ console.log(` /plugin update ${a.gray(isZh ? "# \u66F4\u65B0\u6240\u6709\u63D2\u4EF6" : "# Update all plugins")}`);
1915
+ console.log("");
1916
+ console.log(a.dim("\u2500".repeat(50)));
1917
+ console.log(a.gray(`${isZh ? "\u63D2\u4EF6\u5E02\u573A" : "Plugin Marketplace"}: https://claudehome.cn/plugins`));
1918
+ }
1919
+ async function handlePluginCommand(args) {
1920
+ const action = args[0] || "list";
1921
+ const restArgs = args.slice(1);
1922
+ const options = {
1923
+ verbose: restArgs.includes("--verbose") || restArgs.includes("-v"),
1924
+ force: restArgs.includes("--force") || restArgs.includes("-f")
1925
+ };
1926
+ const versionIndex = restArgs.findIndex((a) => a === "--version" || a === "-V");
1927
+ if (versionIndex !== -1 && restArgs[versionIndex + 1]) {
1928
+ options.version = restArgs[versionIndex + 1];
1929
+ }
1930
+ const cleanArgs = restArgs.filter(
1931
+ (a) => !a.startsWith("-") && a !== options.version
1932
+ );
1933
+ await pluginCommand(action, cleanArgs, options);
1934
+ }
1935
+
1936
+ export { handlePluginCommand, pluginCommand };