ccjk 12.0.7 → 12.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/package.json +1 -1
  2. package/dist/chunks/agent-teams.mjs +0 -136
  3. package/dist/chunks/agent.mjs +0 -1439
  4. package/dist/chunks/agents.mjs +0 -3778
  5. package/dist/chunks/api-cli.mjs +0 -132
  6. package/dist/chunks/api-providers.mjs +0 -129
  7. package/dist/chunks/api.mjs +0 -112
  8. package/dist/chunks/auto-bootstrap.mjs +0 -358
  9. package/dist/chunks/auto-init.mjs +0 -7584
  10. package/dist/chunks/auto-updater.mjs +0 -410
  11. package/dist/chunks/banner.mjs +0 -188
  12. package/dist/chunks/bash.mjs +0 -187
  13. package/dist/chunks/boost.mjs +0 -397
  14. package/dist/chunks/ccjk-agents.mjs +0 -414
  15. package/dist/chunks/ccjk-all.mjs +0 -1028
  16. package/dist/chunks/ccjk-config.mjs +0 -261
  17. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  18. package/dist/chunks/ccjk-mcp.mjs +0 -761
  19. package/dist/chunks/ccjk-setup.mjs +0 -763
  20. package/dist/chunks/ccjk-skills.mjs +0 -514
  21. package/dist/chunks/ccr.mjs +0 -98
  22. package/dist/chunks/ccu.mjs +0 -40
  23. package/dist/chunks/check-updates.mjs +0 -108
  24. package/dist/chunks/claude-code-config-manager.mjs +0 -750
  25. package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
  26. package/dist/chunks/claude-config.mjs +0 -236
  27. package/dist/chunks/claude-wrapper.mjs +0 -85
  28. package/dist/chunks/cleanup-migration.mjs +0 -20
  29. package/dist/chunks/cli-hook.mjs +0 -2285
  30. package/dist/chunks/cloud-sync.mjs +0 -29
  31. package/dist/chunks/codex-config-switch.mjs +0 -451
  32. package/dist/chunks/codex-provider-manager.mjs +0 -236
  33. package/dist/chunks/codex-uninstaller.mjs +0 -404
  34. package/dist/chunks/codex.mjs +0 -2077
  35. package/dist/chunks/commands.mjs +0 -108
  36. package/dist/chunks/commands2.mjs +0 -413
  37. package/dist/chunks/commit.mjs +0 -138
  38. package/dist/chunks/completion.mjs +0 -515
  39. package/dist/chunks/config-consolidator.mjs +0 -172
  40. package/dist/chunks/config-switch.mjs +0 -317
  41. package/dist/chunks/config.mjs +0 -379
  42. package/dist/chunks/config2.mjs +0 -477
  43. package/dist/chunks/config3.mjs +0 -470
  44. package/dist/chunks/constants.mjs +0 -133
  45. package/dist/chunks/context-loader.mjs +0 -343
  46. package/dist/chunks/context.mjs +0 -372
  47. package/dist/chunks/convoy-manager.mjs +0 -880
  48. package/dist/chunks/dashboard.mjs +0 -476
  49. package/dist/chunks/doctor.mjs +0 -964
  50. package/dist/chunks/evolution.mjs +0 -382
  51. package/dist/chunks/features.mjs +0 -698
  52. package/dist/chunks/fish.mjs +0 -181
  53. package/dist/chunks/fs-operations.mjs +0 -192
  54. package/dist/chunks/health-alerts.mjs +0 -304
  55. package/dist/chunks/health-check.mjs +0 -532
  56. package/dist/chunks/help.mjs +0 -340
  57. package/dist/chunks/hook-installer.mjs +0 -45
  58. package/dist/chunks/index.mjs +0 -24
  59. package/dist/chunks/index10.mjs +0 -1171
  60. package/dist/chunks/index11.mjs +0 -1008
  61. package/dist/chunks/index12.mjs +0 -193
  62. package/dist/chunks/index13.mjs +0 -218
  63. package/dist/chunks/index14.mjs +0 -663
  64. package/dist/chunks/index2.mjs +0 -19
  65. package/dist/chunks/index3.mjs +0 -19092
  66. package/dist/chunks/index4.mjs +0 -8
  67. package/dist/chunks/index5.mjs +0 -7600
  68. package/dist/chunks/index6.mjs +0 -171
  69. package/dist/chunks/index7.mjs +0 -3583
  70. package/dist/chunks/index8.mjs +0 -19
  71. package/dist/chunks/index9.mjs +0 -616
  72. package/dist/chunks/init.mjs +0 -1606
  73. package/dist/chunks/installer.mjs +0 -690
  74. package/dist/chunks/installer2.mjs +0 -179
  75. package/dist/chunks/interview.mjs +0 -2927
  76. package/dist/chunks/json-config.mjs +0 -60
  77. package/dist/chunks/linux.mjs +0 -3863
  78. package/dist/chunks/macos.mjs +0 -69
  79. package/dist/chunks/main.mjs +0 -635
  80. package/dist/chunks/manager.mjs +0 -1048
  81. package/dist/chunks/marketplace.mjs +0 -949
  82. package/dist/chunks/mcp-cli.mjs +0 -204
  83. package/dist/chunks/mcp-performance.mjs +0 -187
  84. package/dist/chunks/mcp.mjs +0 -1231
  85. package/dist/chunks/menu.mjs +0 -652
  86. package/dist/chunks/metrics-display.mjs +0 -153
  87. package/dist/chunks/migrator.mjs +0 -178
  88. package/dist/chunks/monitor.mjs +0 -1856
  89. package/dist/chunks/notification.mjs +0 -1864
  90. package/dist/chunks/onboarding.mjs +0 -385
  91. package/dist/chunks/package.mjs +0 -3
  92. package/dist/chunks/paradigm.mjs +0 -74
  93. package/dist/chunks/permission-manager.mjs +0 -132
  94. package/dist/chunks/permissions.mjs +0 -265
  95. package/dist/chunks/persistence-manager.mjs +0 -794
  96. package/dist/chunks/persistence.mjs +0 -667
  97. package/dist/chunks/platform.mjs +0 -391
  98. package/dist/chunks/plugin.mjs +0 -1936
  99. package/dist/chunks/powershell.mjs +0 -213
  100. package/dist/chunks/prompts.mjs +0 -241
  101. package/dist/chunks/providers.mjs +0 -260
  102. package/dist/chunks/quick-actions.mjs +0 -320
  103. package/dist/chunks/quick-provider.mjs +0 -682
  104. package/dist/chunks/quick-setup.mjs +0 -412
  105. package/dist/chunks/remote.mjs +0 -497
  106. package/dist/chunks/session.mjs +0 -878
  107. package/dist/chunks/sessions.mjs +0 -106
  108. package/dist/chunks/silent-updater.mjs +0 -396
  109. package/dist/chunks/simple-config.mjs +0 -98
  110. package/dist/chunks/skill.mjs +0 -117
  111. package/dist/chunks/skill2.mjs +0 -9003
  112. package/dist/chunks/skills-sync.mjs +0 -6460
  113. package/dist/chunks/skills.mjs +0 -567
  114. package/dist/chunks/slash-commands.mjs +0 -207
  115. package/dist/chunks/smart-defaults.mjs +0 -412
  116. package/dist/chunks/smart-guide.mjs +0 -194
  117. package/dist/chunks/startup.mjs +0 -487
  118. package/dist/chunks/stats.mjs +0 -410
  119. package/dist/chunks/status.mjs +0 -289
  120. package/dist/chunks/team.mjs +0 -63
  121. package/dist/chunks/thinking.mjs +0 -626
  122. package/dist/chunks/trace.mjs +0 -57
  123. package/dist/chunks/uninstall.mjs +0 -849
  124. package/dist/chunks/update.mjs +0 -167
  125. package/dist/chunks/upgrade-manager.mjs +0 -204
  126. package/dist/chunks/version-checker.mjs +0 -881
  127. package/dist/chunks/vim.mjs +0 -903
  128. package/dist/chunks/windows.mjs +0 -14
  129. package/dist/chunks/workflows.mjs +0 -633
  130. package/dist/chunks/wsl.mjs +0 -129
  131. package/dist/chunks/zero-config.mjs +0 -374
  132. package/dist/chunks/zsh.mjs +0 -182
  133. package/dist/cli.d.mts +0 -1
  134. package/dist/cli.d.ts +0 -1
  135. package/dist/cli.mjs +0 -2199
  136. package/dist/i18n/locales/en/agent-teams.json +0 -18
  137. package/dist/i18n/locales/en/agentBrowser.json +0 -79
  138. package/dist/i18n/locales/en/agents.json +0 -135
  139. package/dist/i18n/locales/en/api.json +0 -63
  140. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  141. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  142. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  143. package/dist/i18n/locales/en/ccjk.json +0 -276
  144. package/dist/i18n/locales/en/ccr.json +0 -65
  145. package/dist/i18n/locales/en/claude-md.json +0 -73
  146. package/dist/i18n/locales/en/cli.json +0 -152
  147. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  148. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  149. package/dist/i18n/locales/en/cloud.json +0 -40
  150. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  151. package/dist/i18n/locales/en/codex.json +0 -127
  152. package/dist/i18n/locales/en/cometix.json +0 -29
  153. package/dist/i18n/locales/en/common.json +0 -68
  154. package/dist/i18n/locales/en/config.json +0 -108
  155. package/dist/i18n/locales/en/configuration.json +0 -226
  156. package/dist/i18n/locales/en/context.json +0 -85
  157. package/dist/i18n/locales/en/dashboard.json +0 -78
  158. package/dist/i18n/locales/en/errors.json +0 -26
  159. package/dist/i18n/locales/en/evolution.json +0 -54
  160. package/dist/i18n/locales/en/hooks.json +0 -74
  161. package/dist/i18n/locales/en/hooksSync.json +0 -133
  162. package/dist/i18n/locales/en/installation.json +0 -83
  163. package/dist/i18n/locales/en/interview.json +0 -104
  164. package/dist/i18n/locales/en/language.json +0 -19
  165. package/dist/i18n/locales/en/lsp.json +0 -78
  166. package/dist/i18n/locales/en/marketplace.json +0 -116
  167. package/dist/i18n/locales/en/mcp.json +0 -178
  168. package/dist/i18n/locales/en/memory.json +0 -92
  169. package/dist/i18n/locales/en/menu.json +0 -143
  170. package/dist/i18n/locales/en/multi-config.json +0 -79
  171. package/dist/i18n/locales/en/notification.json +0 -307
  172. package/dist/i18n/locales/en/permissions.json +0 -95
  173. package/dist/i18n/locales/en/persistence.json +0 -127
  174. package/dist/i18n/locales/en/plugins.json +0 -146
  175. package/dist/i18n/locales/en/quick-actions.json +0 -78
  176. package/dist/i18n/locales/en/registry.json +0 -54
  177. package/dist/i18n/locales/en/remote.json +0 -93
  178. package/dist/i18n/locales/en/sandbox.json +0 -44
  179. package/dist/i18n/locales/en/setup.json +0 -44
  180. package/dist/i18n/locales/en/shencha.json +0 -14
  181. package/dist/i18n/locales/en/skills.json +0 -100
  182. package/dist/i18n/locales/en/skillsSync.json +0 -74
  183. package/dist/i18n/locales/en/smartGuide.json +0 -49
  184. package/dist/i18n/locales/en/stats.json +0 -20
  185. package/dist/i18n/locales/en/subagent.json +0 -69
  186. package/dist/i18n/locales/en/superpowers.json +0 -117
  187. package/dist/i18n/locales/en/team.json +0 -7
  188. package/dist/i18n/locales/en/thinking.json +0 -65
  189. package/dist/i18n/locales/en/tools.json +0 -42
  190. package/dist/i18n/locales/en/uninstall.json +0 -56
  191. package/dist/i18n/locales/en/updater.json +0 -29
  192. package/dist/i18n/locales/en/vim.json +0 -169
  193. package/dist/i18n/locales/en/workflow.json +0 -55
  194. package/dist/i18n/locales/en/workspace.json +0 -108
  195. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  196. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
  197. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  198. package/dist/i18n/locales/zh-CN/api.json +0 -63
  199. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  200. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  201. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  202. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  203. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  204. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  205. package/dist/i18n/locales/zh-CN/cli.json +0 -152
  206. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  207. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  208. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  209. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  210. package/dist/i18n/locales/zh-CN/codex.json +0 -127
  211. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  212. package/dist/i18n/locales/zh-CN/common.json +0 -68
  213. package/dist/i18n/locales/zh-CN/config.json +0 -108
  214. package/dist/i18n/locales/zh-CN/configuration.json +0 -224
  215. package/dist/i18n/locales/zh-CN/context.json +0 -85
  216. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  217. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  218. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  219. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  220. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  221. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  222. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  223. package/dist/i18n/locales/zh-CN/language.json +0 -19
  224. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  225. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  226. package/dist/i18n/locales/zh-CN/mcp.json +0 -178
  227. package/dist/i18n/locales/zh-CN/memory.json +0 -92
  228. package/dist/i18n/locales/zh-CN/menu.json +0 -143
  229. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  230. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  231. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  232. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  233. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  234. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  235. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  236. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  237. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  238. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  239. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  240. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  241. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  242. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  243. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  244. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  245. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  246. package/dist/i18n/locales/zh-CN/team.json +0 -7
  247. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  248. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  249. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  250. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  251. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  252. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  253. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  254. package/dist/index.d.mts +0 -5295
  255. package/dist/index.d.ts +0 -5295
  256. package/dist/index.mjs +0 -4941
  257. package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
  258. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  259. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  260. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  261. package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
  262. package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
  263. package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
  264. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  265. package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
  266. package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
  267. package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
  268. package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
  269. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  270. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  271. package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
  272. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  273. package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
  274. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  275. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  276. package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
  277. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  278. package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
  279. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  280. package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
  281. package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
  282. package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
  283. package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
  284. package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
  285. package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
  286. package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
  287. package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
  288. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  289. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  290. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  291. package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
  292. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  293. package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
  294. package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
  295. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  296. package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
  297. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  298. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  299. package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
@@ -1,1008 +0,0 @@
1
- import a from './index2.mjs';
2
- import ora from './index7.mjs';
3
- import fs from 'node:fs/promises';
4
- import os__default from 'node:os';
5
- import path__default from 'node:path';
6
- import { exec } from 'node:child_process';
7
- import { promisify } from 'node:util';
8
- import '../shared/ccjk.BAGoDD49.mjs';
9
- import 'node:process';
10
- import '../shared/ccjk.Cjgrln_h.mjs';
11
-
12
- function getCcjkConfigDir() {
13
- if (process.env.CCJK_CONFIG_DIR) {
14
- return process.env.CCJK_CONFIG_DIR;
15
- }
16
- return path__default.join(os__default.homedir(), ".ccjk");
17
- }
18
- function getInstallPath(pluginType, name) {
19
- const configDir = getCcjkConfigDir();
20
- const typeDir = {
21
- skill: "skills",
22
- mcp: "mcp-servers",
23
- agent: "agents",
24
- hook: "hooks"
25
- }[pluginType];
26
- return path__default.join(configDir, typeDir, name);
27
- }
28
- async function copyDirectory(src, dest) {
29
- await fs.mkdir(dest, { recursive: true });
30
- const entries = await fs.readdir(src, { withFileTypes: true });
31
- for (const entry of entries) {
32
- const srcPath = path__default.join(src, entry.name);
33
- const destPath = path__default.join(dest, entry.name);
34
- if (entry.isDirectory()) {
35
- await copyDirectory(srcPath, destPath);
36
- } else {
37
- await fs.copyFile(srcPath, destPath);
38
- }
39
- }
40
- }
41
- async function downloadFile(url, destPath) {
42
- const response = await fetch(url, {
43
- headers: {
44
- "User-Agent": "ccjk-cli"
45
- },
46
- redirect: "follow"
47
- });
48
- if (!response.ok) {
49
- throw new Error(`Failed to download: ${response.statusText}`);
50
- }
51
- const buffer = Buffer.from(await response.arrayBuffer());
52
- await fs.writeFile(destPath, buffer);
53
- }
54
-
55
- async function installFromGitHub(sourceInfo, pluginType, options = {}) {
56
- const { force = false, dryRun = false } = options;
57
- const { owner, repo, ref = "main", subpath } = sourceInfo;
58
- try {
59
- const repoInfo = await fetchRepoInfo(owner, repo);
60
- const defaultBranch = repoInfo.default_branch || "main";
61
- const actualRef = ref || defaultBranch;
62
- const installPath = getInstallPath(pluginType, repo);
63
- if (!force) {
64
- try {
65
- await fs.access(installPath);
66
- return {
67
- success: false,
68
- source: sourceInfo.originalUrl,
69
- sourceType: "github",
70
- pluginType,
71
- error: `Plugin already exists at ${installPath}. Use --force to overwrite.`
72
- };
73
- } catch {
74
- }
75
- }
76
- if (dryRun) {
77
- const files = await listRepoFiles(owner, repo, actualRef, subpath);
78
- return {
79
- success: true,
80
- source: sourceInfo.originalUrl,
81
- sourceType: "github",
82
- pluginType,
83
- installedPath: installPath,
84
- details: {
85
- name: repo,
86
- version: actualRef,
87
- description: repoInfo.description || void 0,
88
- files: files.slice(0, 20)
89
- }
90
- };
91
- }
92
- const tempDir = await downloadRepo(owner, repo, actualRef);
93
- const sourcePath = subpath ? path__default.join(tempDir, subpath) : tempDir;
94
- await fs.mkdir(path__default.dirname(installPath), { recursive: true });
95
- await copyDirectory(sourcePath, installPath);
96
- await fs.rm(tempDir, { recursive: true, force: true });
97
- const installedFiles = await listInstalledFiles$1(installPath);
98
- return {
99
- success: true,
100
- source: sourceInfo.originalUrl,
101
- sourceType: "github",
102
- pluginType,
103
- installedPath: installPath,
104
- details: {
105
- name: repo,
106
- version: actualRef,
107
- description: repoInfo.description || void 0,
108
- files: installedFiles
109
- }
110
- };
111
- } catch (error) {
112
- return {
113
- success: false,
114
- source: sourceInfo.originalUrl,
115
- sourceType: "github",
116
- pluginType,
117
- error: error instanceof Error ? error.message : String(error)
118
- };
119
- }
120
- }
121
- async function fetchRepoInfo(owner, repo) {
122
- const url = `https://api.github.com/repos/${owner}/${repo}`;
123
- const response = await fetch(url, {
124
- headers: {
125
- "Accept": "application/vnd.github.v3+json",
126
- "User-Agent": "ccjk-cli"
127
- }
128
- });
129
- if (!response.ok) {
130
- if (response.status === 404) {
131
- throw new Error(`Repository not found: ${owner}/${repo}`);
132
- }
133
- throw new Error(`Failed to fetch repository info: ${response.statusText}`);
134
- }
135
- return response.json();
136
- }
137
- async function listRepoFiles(owner, repo, ref, subpath) {
138
- const treePath = subpath || "";
139
- const url = `https://api.github.com/repos/${owner}/${repo}/git/trees/${ref}?recursive=1`;
140
- const response = await fetch(url, {
141
- headers: {
142
- "Accept": "application/vnd.github.v3+json",
143
- "User-Agent": "ccjk-cli"
144
- }
145
- });
146
- if (!response.ok) {
147
- return [];
148
- }
149
- const data = await response.json();
150
- const files = (data.tree || []).filter((item) => item.type === "blob").map((item) => item.path).filter((filePath) => !treePath || filePath.startsWith(treePath));
151
- return files;
152
- }
153
- async function downloadRepo(owner, repo, ref) {
154
- const zipUrl = `https://github.com/${owner}/${repo}/archive/${ref}.zip`;
155
- const tempDir = path__default.join(os__default.tmpdir(), `ccjk-${repo}-${Date.now()}`);
156
- const zipPath = path__default.join(tempDir, "repo.zip");
157
- await fs.mkdir(tempDir, { recursive: true });
158
- await downloadFile(zipUrl, zipPath);
159
- const extractedDir = await extractZip(zipPath, tempDir);
160
- await fs.unlink(zipPath);
161
- return extractedDir;
162
- }
163
- async function extractZip(zipPath, destDir) {
164
- const { exec } = await import('node:child_process');
165
- const { promisify } = await import('node:util');
166
- const execAsync = promisify(exec);
167
- try {
168
- await execAsync(`unzip -q "${zipPath}" -d "${destDir}"`);
169
- } catch {
170
- try {
171
- await execAsync(`tar -xf "${zipPath}" -C "${destDir}"`);
172
- } catch {
173
- throw new Error("Failed to extract archive. Please ensure unzip or tar is installed.");
174
- }
175
- }
176
- const entries = await fs.readdir(destDir);
177
- const extractedDir = entries.find((entry) => !entry.endsWith(".zip"));
178
- if (!extractedDir) {
179
- throw new Error("Failed to find extracted directory");
180
- }
181
- return path__default.join(destDir, extractedDir);
182
- }
183
- async function listInstalledFiles$1(dir) {
184
- const files = [];
185
- async function walk(currentDir, prefix = "") {
186
- const entries = await fs.readdir(currentDir, { withFileTypes: true });
187
- for (const entry of entries) {
188
- const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
189
- if (entry.isDirectory()) {
190
- await walk(path__default.join(currentDir, entry.name), relativePath);
191
- } else {
192
- files.push(relativePath);
193
- }
194
- }
195
- }
196
- await walk(dir);
197
- return files;
198
- }
199
-
200
- async function installFromLocal(sourceInfo, pluginType, options = {}) {
201
- const { force = false, dryRun = false } = options;
202
- const { absolutePath, originalPath } = sourceInfo;
203
- try {
204
- const stat = await fs.stat(absolutePath);
205
- const isFile = stat.isFile();
206
- const isDirectory = stat.isDirectory();
207
- if (!isFile && !isDirectory) {
208
- return {
209
- success: false,
210
- source: originalPath,
211
- sourceType: "local",
212
- pluginType,
213
- error: `Source path is neither a file nor a directory: ${absolutePath}`
214
- };
215
- }
216
- const pluginName = path__default.basename(absolutePath, path__default.extname(absolutePath));
217
- const installPath = getInstallPath(pluginType, pluginName);
218
- if (!force) {
219
- try {
220
- await fs.access(installPath);
221
- return {
222
- success: false,
223
- source: originalPath,
224
- sourceType: "local",
225
- pluginType,
226
- error: `Plugin already exists at ${installPath}. Use --force to overwrite.`
227
- };
228
- } catch {
229
- }
230
- }
231
- const files = isFile ? [path__default.basename(absolutePath)] : await listFiles(absolutePath);
232
- const pluginInfo = await readPluginInfo(absolutePath, isFile);
233
- if (dryRun) {
234
- return {
235
- success: true,
236
- source: originalPath,
237
- sourceType: "local",
238
- pluginType,
239
- installedPath: installPath,
240
- details: {
241
- name: pluginInfo.name || pluginName,
242
- version: pluginInfo.version,
243
- description: pluginInfo.description,
244
- files
245
- }
246
- };
247
- }
248
- if (isFile) {
249
- await fs.mkdir(path__default.dirname(installPath), { recursive: true });
250
- if (absolutePath.endsWith(".md")) {
251
- await fs.copyFile(absolutePath, installPath);
252
- } else {
253
- await fs.mkdir(installPath, { recursive: true });
254
- await fs.copyFile(
255
- absolutePath,
256
- path__default.join(installPath, path__default.basename(absolutePath))
257
- );
258
- }
259
- } else {
260
- await fs.mkdir(path__default.dirname(installPath), { recursive: true });
261
- await copyDirectory(absolutePath, installPath);
262
- }
263
- const installedFiles = isFile ? [path__default.basename(absolutePath)] : await listFiles(installPath);
264
- return {
265
- success: true,
266
- source: originalPath,
267
- sourceType: "local",
268
- pluginType,
269
- installedPath: installPath,
270
- details: {
271
- name: pluginInfo.name || pluginName,
272
- version: pluginInfo.version,
273
- description: pluginInfo.description,
274
- files: installedFiles
275
- }
276
- };
277
- } catch (error) {
278
- return {
279
- success: false,
280
- source: originalPath,
281
- sourceType: "local",
282
- pluginType,
283
- error: error instanceof Error ? error.message : String(error)
284
- };
285
- }
286
- }
287
- async function listFiles(dir) {
288
- const files = [];
289
- async function walk(currentDir, prefix = "") {
290
- const entries = await fs.readdir(currentDir, { withFileTypes: true });
291
- for (const entry of entries) {
292
- if (entry.name.startsWith(".") || entry.name === "node_modules") {
293
- continue;
294
- }
295
- const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
296
- if (entry.isDirectory()) {
297
- await walk(path__default.join(currentDir, entry.name), relativePath);
298
- } else {
299
- files.push(relativePath);
300
- }
301
- }
302
- }
303
- await walk(dir);
304
- return files;
305
- }
306
- async function readPluginInfo(sourcePath, isFile) {
307
- if (isFile) {
308
- const name = path__default.basename(sourcePath, path__default.extname(sourcePath));
309
- return { name };
310
- }
311
- try {
312
- const packageJsonPath = path__default.join(sourcePath, "package.json");
313
- const content = await fs.readFile(packageJsonPath, "utf-8");
314
- const packageJson = JSON.parse(content);
315
- return {
316
- name: packageJson.name,
317
- version: packageJson.version,
318
- description: packageJson.description
319
- };
320
- } catch {
321
- }
322
- const metaFiles = ["SKILL.md", "skill.md", "README.md", "readme.md"];
323
- for (const metaFile of metaFiles) {
324
- try {
325
- const metaPath = path__default.join(sourcePath, metaFile);
326
- const content = await fs.readFile(metaPath, "utf-8");
327
- const titleMatch = content.match(/^#\s+(.+)$/m);
328
- if (titleMatch) {
329
- return { name: titleMatch[1].trim() };
330
- }
331
- } catch {
332
- }
333
- }
334
- return {};
335
- }
336
-
337
- const execAsync = promisify(exec);
338
- async function installFromNpm(sourceInfo, pluginType, options = {}) {
339
- const { force = false, dryRun = false } = options;
340
- const { packageName, version } = sourceInfo;
341
- try {
342
- const packageInfo = await fetchPackageInfo(packageName, version);
343
- const packageVersion = version || packageInfo.version;
344
- const shortName = getShortName(packageName);
345
- const installPath = getInstallPath(pluginType, shortName);
346
- if (!force) {
347
- try {
348
- await fs.access(installPath);
349
- return {
350
- success: false,
351
- source: packageName,
352
- sourceType: "npm",
353
- pluginType,
354
- error: `Plugin already exists at ${installPath}. Use --force to overwrite.`
355
- };
356
- } catch {
357
- }
358
- }
359
- if (dryRun) {
360
- const files = packageInfo.files || ["(package files)"];
361
- return {
362
- success: true,
363
- source: packageName,
364
- sourceType: "npm",
365
- pluginType,
366
- installedPath: installPath,
367
- details: {
368
- name: packageName,
369
- version: packageVersion,
370
- description: packageInfo.description,
371
- files
372
- }
373
- };
374
- }
375
- if (pluginType === "mcp") {
376
- await installMcpPackage(packageName, packageVersion, installPath);
377
- } else {
378
- await installGenericPackage(packageName, packageVersion, installPath);
379
- }
380
- const installedFiles = await listInstalledFiles(installPath);
381
- return {
382
- success: true,
383
- source: packageName,
384
- sourceType: "npm",
385
- pluginType,
386
- installedPath: installPath,
387
- details: {
388
- name: packageName,
389
- version: packageVersion,
390
- description: packageInfo.description,
391
- files: installedFiles
392
- }
393
- };
394
- } catch (error) {
395
- return {
396
- success: false,
397
- source: packageName,
398
- sourceType: "npm",
399
- pluginType,
400
- error: error instanceof Error ? error.message : String(error)
401
- };
402
- }
403
- }
404
- async function fetchPackageInfo(packageName, version) {
405
- const url = version ? `https://registry.npmjs.org/${packageName}/${version}` : `https://registry.npmjs.org/${packageName}/latest`;
406
- const response = await fetch(url);
407
- if (!response.ok) {
408
- if (response.status === 404) {
409
- throw new Error(`Package not found: ${packageName}`);
410
- }
411
- throw new Error(`Failed to fetch package info: ${response.statusText}`);
412
- }
413
- const data = await response.json();
414
- return {
415
- version: data.version,
416
- description: data.description,
417
- files: data.files
418
- };
419
- }
420
- function getShortName(packageName) {
421
- if (packageName.startsWith("@")) {
422
- const parts = packageName.split("/");
423
- return parts[1] || packageName;
424
- }
425
- return packageName;
426
- }
427
- async function installMcpPackage(packageName, version, installPath) {
428
- await fs.mkdir(installPath, { recursive: true });
429
- const packageJson = {
430
- name: `ccjk-mcp-${getShortName(packageName)}`,
431
- version: "1.0.0",
432
- private: true,
433
- dependencies: {
434
- [packageName]: version
435
- }
436
- };
437
- await fs.writeFile(
438
- path__default.join(installPath, "package.json"),
439
- JSON.stringify(packageJson, null, 2)
440
- );
441
- try {
442
- await execAsync("npm install", { cwd: installPath });
443
- } catch (error) {
444
- try {
445
- await execAsync("pnpm install", { cwd: installPath });
446
- } catch {
447
- throw new Error(
448
- `Failed to install package. Original error: ${error instanceof Error ? error.message : String(error)}`
449
- );
450
- }
451
- }
452
- }
453
- async function installGenericPackage(packageName, version, installPath) {
454
- const registryUrl = `https://registry.npmjs.org/${packageName}/${version}`;
455
- const response = await fetch(registryUrl);
456
- if (!response.ok) {
457
- throw new Error(`Failed to fetch package info: ${response.statusText}`);
458
- }
459
- const data = await response.json();
460
- const tarballUrl = data.dist?.tarball;
461
- if (!tarballUrl) {
462
- throw new Error("Failed to get tarball URL");
463
- }
464
- const tarballResponse = await fetch(tarballUrl);
465
- if (!tarballResponse.ok) {
466
- throw new Error(`Failed to download tarball: ${tarballResponse.statusText}`);
467
- }
468
- await fs.mkdir(installPath, { recursive: true });
469
- const tarballBuffer = Buffer.from(await tarballResponse.arrayBuffer());
470
- const tarballPath = path__default.join(installPath, "package.tgz");
471
- await fs.writeFile(tarballPath, tarballBuffer);
472
- try {
473
- await execAsync(`tar -xzf package.tgz --strip-components=1`, { cwd: installPath });
474
- } finally {
475
- await fs.unlink(tarballPath).catch(() => {
476
- });
477
- }
478
- }
479
- async function listInstalledFiles(dir) {
480
- const files = [];
481
- async function walk(currentDir, prefix = "") {
482
- try {
483
- const entries = await fs.readdir(currentDir, { withFileTypes: true });
484
- for (const entry of entries) {
485
- if (entry.name === "node_modules")
486
- continue;
487
- const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
488
- if (entry.isDirectory()) {
489
- await walk(path__default.join(currentDir, entry.name), relativePath);
490
- } else {
491
- files.push(relativePath);
492
- }
493
- }
494
- } catch {
495
- }
496
- }
497
- await walk(dir);
498
- return files;
499
- }
500
-
501
- function parseSource(source) {
502
- const trimmed = source.trim();
503
- const githubInfo = parseGitHubSource(trimmed);
504
- if (githubInfo) {
505
- return githubInfo;
506
- }
507
- const localInfo = parseLocalSource(trimmed);
508
- if (localInfo) {
509
- return localInfo;
510
- }
511
- return parseNpmSource(trimmed);
512
- }
513
- function parseGitHubSource(source) {
514
- const prefixMatch = source.match(/^(?:github|gh):([^/]+)\/([^#@/]+)(?:#(.+))?$/);
515
- if (prefixMatch) {
516
- return {
517
- type: "github",
518
- owner: prefixMatch[1],
519
- repo: prefixMatch[2],
520
- ref: prefixMatch[3],
521
- originalUrl: source
522
- };
523
- }
524
- const urlMatch = source.match(
525
- /^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+))?(?:\/(.+))?$/
526
- );
527
- if (urlMatch) {
528
- return {
529
- type: "github",
530
- owner: urlMatch[1],
531
- repo: urlMatch[2],
532
- ref: urlMatch[3],
533
- subpath: urlMatch[4],
534
- originalUrl: source
535
- };
536
- }
537
- const shortMatch = source.match(/^([\w-]+)\/([\w.-]+)(?:#(.+))?$/);
538
- if (shortMatch && !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("~")) {
539
- return {
540
- type: "github",
541
- owner: shortMatch[1],
542
- repo: shortMatch[2],
543
- ref: shortMatch[3],
544
- originalUrl: source
545
- };
546
- }
547
- return null;
548
- }
549
- function parseLocalSource(source) {
550
- if (source.startsWith("./") || source.startsWith("../") || source.startsWith("/") || source.startsWith("~/")) {
551
- let absolutePath;
552
- if (source.startsWith("~/")) {
553
- absolutePath = path__default.join(os__default.homedir(), source.slice(2));
554
- } else if (path__default.isAbsolute(source)) {
555
- absolutePath = source;
556
- } else {
557
- absolutePath = path__default.resolve(process.cwd(), source);
558
- }
559
- return {
560
- type: "local",
561
- absolutePath,
562
- originalPath: source
563
- };
564
- }
565
- if (/^[a-z]:[\\/]/i.test(source)) {
566
- return {
567
- type: "local",
568
- absolutePath: path__default.resolve(source),
569
- originalPath: source
570
- };
571
- }
572
- return null;
573
- }
574
- function parseNpmSource(source) {
575
- const npmPrefixMatch = source.match(/^npm:(.+)$/);
576
- const packageStr = npmPrefixMatch ? npmPrefixMatch[1] : source;
577
- const scopedMatch = packageStr.match(/^(@[^/]+)\/([^@]+)(?:@(.+))?$/);
578
- if (scopedMatch) {
579
- return {
580
- type: "npm",
581
- scope: scopedMatch[1],
582
- packageName: `${scopedMatch[1]}/${scopedMatch[2]}`,
583
- version: scopedMatch[3]
584
- };
585
- }
586
- const versionMatch = packageStr.match(/^([^@]+)@(.+)$/);
587
- if (versionMatch) {
588
- return {
589
- type: "npm",
590
- packageName: versionMatch[1],
591
- version: versionMatch[2]
592
- };
593
- }
594
- return {
595
- type: "npm",
596
- packageName: packageStr
597
- };
598
- }
599
- function buildGitHubRawUrl(info, filePath) {
600
- const ref = info.ref || "main";
601
- return `https://raw.githubusercontent.com/${info.owner}/${info.repo}/${ref}/${filePath}`;
602
- }
603
-
604
- async function detectPluginType(sourceInfo) {
605
- const result = await detectPluginTypeWithConfidence(sourceInfo);
606
- return result.type;
607
- }
608
- async function detectPluginTypeWithConfidence(sourceInfo) {
609
- switch (sourceInfo.type) {
610
- case "github":
611
- return detectFromGitHub(sourceInfo);
612
- case "npm":
613
- return detectFromNpm(sourceInfo);
614
- case "local":
615
- return detectFromLocal(sourceInfo);
616
- default:
617
- return { type: "skill", confidence: "low", reason: "Unknown source type" };
618
- }
619
- }
620
- async function detectFromGitHub(info) {
621
- const repoNameResult = detectFromRepoName(info.repo);
622
- if (repoNameResult.confidence === "high") {
623
- return repoNameResult;
624
- }
625
- try {
626
- const packageJsonUrl = buildGitHubRawUrl(info, "package.json");
627
- const response = await fetch(packageJsonUrl);
628
- if (response.ok) {
629
- const packageJson = await response.json();
630
- const pkgResult = detectFromPackageJson(packageJson);
631
- if (pkgResult.confidence !== "low") {
632
- return pkgResult;
633
- }
634
- }
635
- } catch {
636
- }
637
- const filePatterns = [
638
- { file: "SKILL.md", type: "skill" },
639
- { file: "skill.md", type: "skill" },
640
- { file: "AGENT.md", type: "agent" },
641
- { file: "agent.md", type: "agent" },
642
- { file: "mcp.json", type: "mcp" },
643
- { file: "hook.json", type: "hook" }
644
- ];
645
- for (const pattern of filePatterns) {
646
- try {
647
- const fileUrl = buildGitHubRawUrl(info, pattern.file);
648
- const response = await fetch(fileUrl, { method: "HEAD" });
649
- if (response.ok) {
650
- return {
651
- type: pattern.type,
652
- confidence: "high",
653
- reason: `Found ${pattern.file}`
654
- };
655
- }
656
- } catch {
657
- }
658
- }
659
- return repoNameResult.confidence !== "low" ? repoNameResult : { type: "skill", confidence: "low", reason: "Default type" };
660
- }
661
- async function detectFromNpm(info) {
662
- const nameResult = detectFromPackageName(info.packageName);
663
- if (nameResult.confidence === "high") {
664
- return nameResult;
665
- }
666
- try {
667
- const registryUrl = `https://registry.npmjs.org/${info.packageName}`;
668
- const response = await fetch(registryUrl);
669
- if (response.ok) {
670
- const data = await response.json();
671
- const latestVersion = data["dist-tags"]?.latest;
672
- if (latestVersion && data.versions?.[latestVersion]) {
673
- const packageJson = data.versions[latestVersion];
674
- const pkgResult = detectFromPackageJson(packageJson);
675
- if (pkgResult.confidence !== "low") {
676
- return pkgResult;
677
- }
678
- }
679
- }
680
- } catch {
681
- }
682
- return nameResult.confidence !== "low" ? nameResult : { type: "skill", confidence: "low", reason: "Default type" };
683
- }
684
- async function detectFromLocal(info) {
685
- const { absolutePath } = info;
686
- const dirName = path__default.basename(absolutePath);
687
- const dirResult = detectFromRepoName(dirName);
688
- if (dirResult.confidence === "high") {
689
- return dirResult;
690
- }
691
- try {
692
- const packageJsonPath = path__default.join(absolutePath, "package.json");
693
- const content = await fs.readFile(packageJsonPath, "utf-8");
694
- const packageJson = JSON.parse(content);
695
- const pkgResult = detectFromPackageJson(packageJson);
696
- if (pkgResult.confidence !== "low") {
697
- return pkgResult;
698
- }
699
- } catch {
700
- }
701
- const filePatterns = [
702
- { file: "SKILL.md", type: "skill" },
703
- { file: "skill.md", type: "skill" },
704
- { file: "AGENT.md", type: "agent" },
705
- { file: "agent.md", type: "agent" },
706
- { file: "mcp.json", type: "mcp" },
707
- { file: "hook.json", type: "hook" }
708
- ];
709
- for (const pattern of filePatterns) {
710
- try {
711
- const filePath = path__default.join(absolutePath, pattern.file);
712
- await fs.access(filePath);
713
- return {
714
- type: pattern.type,
715
- confidence: "high",
716
- reason: `Found ${pattern.file}`
717
- };
718
- } catch {
719
- }
720
- }
721
- try {
722
- const stat = await fs.stat(absolutePath);
723
- if (stat.isFile() && absolutePath.endsWith(".md")) {
724
- return {
725
- type: "skill",
726
- confidence: "high",
727
- reason: "Single markdown file"
728
- };
729
- }
730
- } catch {
731
- }
732
- return dirResult.confidence !== "low" ? dirResult : { type: "skill", confidence: "low", reason: "Default type" };
733
- }
734
- function detectFromRepoName(name) {
735
- const lowerName = name.toLowerCase();
736
- if (lowerName.includes("mcp-server") || lowerName.includes("mcp_server") || lowerName.startsWith("mcp-") || lowerName.endsWith("-mcp")) {
737
- return { type: "mcp", confidence: "high", reason: `Name contains MCP pattern: ${name}` };
738
- }
739
- if (lowerName.includes("agent") || lowerName.includes("-agent") || lowerName.endsWith("-agent")) {
740
- return { type: "agent", confidence: "medium", reason: `Name contains agent pattern: ${name}` };
741
- }
742
- if (lowerName.includes("hook") || lowerName.includes("-hook") || lowerName.endsWith("-hook")) {
743
- return { type: "hook", confidence: "medium", reason: `Name contains hook pattern: ${name}` };
744
- }
745
- if (lowerName.includes("skill") || lowerName.includes("-skill") || lowerName.endsWith("-skill")) {
746
- return { type: "skill", confidence: "medium", reason: `Name contains skill pattern: ${name}` };
747
- }
748
- return { type: "skill", confidence: "low", reason: "No pattern matched" };
749
- }
750
- function detectFromPackageName(packageName) {
751
- const lowerName = packageName.toLowerCase();
752
- if (lowerName.startsWith("@modelcontextprotocol/")) {
753
- return { type: "mcp", confidence: "high", reason: "MCP official scope" };
754
- }
755
- if (lowerName.includes("mcp-server") || lowerName.includes("mcp_server")) {
756
- return { type: "mcp", confidence: "high", reason: "MCP server pattern in name" };
757
- }
758
- return detectFromRepoName(packageName);
759
- }
760
- function detectFromPackageJson(packageJson) {
761
- if (packageJson.ccjk && typeof packageJson.ccjk === "object") {
762
- const ccjk = packageJson.ccjk;
763
- if (ccjk.type && typeof ccjk.type === "string") {
764
- const type = ccjk.type;
765
- if (["skill", "mcp", "agent", "hook"].includes(type)) {
766
- return { type, confidence: "high", reason: "Explicit ccjk.type field" };
767
- }
768
- }
769
- }
770
- if (Array.isArray(packageJson.keywords)) {
771
- const keywords = packageJson.keywords;
772
- const keywordMap = {
773
- "mcp-server": "mcp",
774
- "mcp": "mcp",
775
- "model-context-protocol": "mcp",
776
- "ccjk-skill": "skill",
777
- "claude-skill": "skill",
778
- "ccjk-agent": "agent",
779
- "ccjk-hook": "hook"
780
- };
781
- for (const keyword of keywords) {
782
- const type = keywordMap[keyword.toLowerCase()];
783
- if (type) {
784
- return { type, confidence: "high", reason: `Keyword: ${keyword}` };
785
- }
786
- }
787
- }
788
- if (packageJson.bin) {
789
- const binKeys = Object.keys(packageJson.bin);
790
- for (const key of binKeys) {
791
- if (key.includes("mcp") || key.includes("server")) {
792
- return { type: "mcp", confidence: "medium", reason: `Binary name: ${key}` };
793
- }
794
- }
795
- }
796
- if (typeof packageJson.main === "string") {
797
- const main = packageJson.main.toLowerCase();
798
- if (main.includes("server") || main.includes("mcp")) {
799
- return { type: "mcp", confidence: "low", reason: `Main file: ${packageJson.main}` };
800
- }
801
- }
802
- return { type: "skill", confidence: "low", reason: "No specific indicators" };
803
- }
804
-
805
- async function addCommand(source, options = {}) {
806
- const { force = false, dryRun = false, json = false, lang = "en" } = options;
807
- const i18n = getI18n(lang);
808
- const spinner = json ? null : ora(i18n.parsing).start();
809
- let sourceInfo;
810
- try {
811
- sourceInfo = parseSource(source);
812
- spinner?.succeed(i18n.parsed(sourceInfo.type));
813
- } catch (error) {
814
- spinner?.fail(i18n.parseFailed);
815
- const result = {
816
- success: false,
817
- source,
818
- sourceType: "local",
819
- pluginType: "skill",
820
- error: error instanceof Error ? error.message : String(error)
821
- };
822
- if (json) {
823
- console.log(JSON.stringify(result, null, 2));
824
- } else {
825
- console.error(a.red(`
826
- ${i18n.error}: ${result.error}
827
- `));
828
- }
829
- return result;
830
- }
831
- let pluginType = options.type;
832
- if (!pluginType) {
833
- spinner?.start(i18n.detectingType);
834
- try {
835
- pluginType = await detectPluginType(sourceInfo);
836
- spinner?.succeed(i18n.detectedType(pluginType));
837
- } catch {
838
- spinner?.info(i18n.defaultType);
839
- pluginType = "skill";
840
- }
841
- }
842
- spinner?.start(dryRun ? i18n.previewInstall : i18n.installing);
843
- try {
844
- let result;
845
- switch (sourceInfo.type) {
846
- case "github":
847
- result = await installFromGitHub(sourceInfo, pluginType, { force, dryRun });
848
- break;
849
- case "npm":
850
- result = await installFromNpm(sourceInfo, pluginType, { force, dryRun });
851
- break;
852
- case "local":
853
- result = await installFromLocal(sourceInfo, pluginType, { force, dryRun });
854
- break;
855
- default:
856
- throw new Error(`Unsupported source type: ${sourceInfo.type}`);
857
- }
858
- if (result.success) {
859
- spinner?.succeed(dryRun ? i18n.previewSuccess : i18n.installSuccess);
860
- } else {
861
- spinner?.fail(i18n.installFailed);
862
- }
863
- if (json) {
864
- console.log(JSON.stringify(result, null, 2));
865
- } else if (result.success && !dryRun) {
866
- printSuccessMessage(result, i18n);
867
- } else if (result.success && dryRun) {
868
- printPreviewMessage(result, i18n);
869
- } else {
870
- console.error(a.red(`
871
- ${i18n.error}: ${result.error}
872
- `));
873
- }
874
- return result;
875
- } catch (error) {
876
- spinner?.fail(i18n.installFailed);
877
- const result = {
878
- success: false,
879
- source,
880
- sourceType: sourceInfo.type,
881
- pluginType,
882
- error: error instanceof Error ? error.message : String(error)
883
- };
884
- if (json) {
885
- console.log(JSON.stringify(result, null, 2));
886
- } else {
887
- console.error(a.red(`
888
- ${i18n.error}: ${result.error}
889
- `));
890
- }
891
- return result;
892
- }
893
- }
894
- function printSuccessMessage(result, i18n) {
895
- console.log();
896
- console.log(a.green.bold(`\u2713 ${i18n.installed}`));
897
- console.log();
898
- console.log(` ${a.gray(i18n.name)}: ${result.details?.name || result.source}`);
899
- if (result.details?.version) {
900
- console.log(` ${a.gray(i18n.version)}: ${result.details.version}`);
901
- }
902
- console.log(` ${a.gray(i18n.type)}: ${result.pluginType}`);
903
- console.log(` ${a.gray(i18n.path)}: ${result.installedPath}`);
904
- console.log();
905
- console.log(a.cyan(i18n.nextSteps));
906
- switch (result.pluginType) {
907
- case "skill":
908
- console.log(` ${a.gray("\u2022")} ${i18n.skillHint}`);
909
- break;
910
- case "mcp":
911
- console.log(` ${a.gray("\u2022")} ${i18n.mcpHint}`);
912
- break;
913
- case "agent":
914
- console.log(` ${a.gray("\u2022")} ${i18n.agentHint}`);
915
- break;
916
- case "hook":
917
- console.log(` ${a.gray("\u2022")} ${i18n.hookHint}`);
918
- break;
919
- }
920
- console.log();
921
- }
922
- function printPreviewMessage(result, i18n) {
923
- console.log();
924
- console.log(a.yellow.bold(`\u26A1 ${i18n.preview}`));
925
- console.log();
926
- console.log(` ${a.gray(i18n.source)}: ${result.source}`);
927
- console.log(` ${a.gray(i18n.type)}: ${result.pluginType}`);
928
- console.log(` ${a.gray(i18n.target)}: ${result.installedPath}`);
929
- if (result.details?.files?.length) {
930
- console.log(` ${a.gray(i18n.files)}:`);
931
- for (const file of result.details.files.slice(0, 5)) {
932
- console.log(` ${a.gray("\u2022")} ${file}`);
933
- }
934
- if (result.details.files.length > 5) {
935
- console.log(` ${a.gray("...")} ${i18n.andMore(result.details.files.length - 5)}`);
936
- }
937
- }
938
- console.log();
939
- console.log(a.gray(i18n.dryRunNote));
940
- console.log();
941
- }
942
- function getI18n(lang) {
943
- const texts = {
944
- "zh-CN": {
945
- parsing: "\u89E3\u6790\u6765\u6E90...",
946
- parsed: (type) => `\u6765\u6E90\u7C7B\u578B: ${type}`,
947
- parseFailed: "\u89E3\u6790\u6765\u6E90\u5931\u8D25",
948
- detectingType: "\u68C0\u6D4B\u63D2\u4EF6\u7C7B\u578B...",
949
- detectedType: (type) => `\u68C0\u6D4B\u5230\u7C7B\u578B: ${type}`,
950
- defaultType: "\u4F7F\u7528\u9ED8\u8BA4\u7C7B\u578B: skill",
951
- installing: "\u5B89\u88C5\u4E2D...",
952
- previewInstall: "\u9884\u89C8\u5B89\u88C5...",
953
- installSuccess: "\u5B89\u88C5\u6210\u529F",
954
- previewSuccess: "\u9884\u89C8\u5B8C\u6210",
955
- installFailed: "\u5B89\u88C5\u5931\u8D25",
956
- error: "\u9519\u8BEF",
957
- installed: "\u63D2\u4EF6\u5DF2\u5B89\u88C5",
958
- preview: "\u5B89\u88C5\u9884\u89C8 (dry-run)",
959
- name: "\u540D\u79F0",
960
- version: "\u7248\u672C",
961
- type: "\u7C7B\u578B",
962
- path: "\u8DEF\u5F84",
963
- source: "\u6765\u6E90",
964
- target: "\u76EE\u6807",
965
- files: "\u6587\u4EF6",
966
- nextSteps: "\u4E0B\u4E00\u6B65:",
967
- skillHint: "\u4F7F\u7528 /skill-name \u5728 Claude Code \u4E2D\u8C03\u7528",
968
- mcpHint: "\u8FD0\u884C ccjk mcp status \u67E5\u770B\u72B6\u6001",
969
- agentHint: "\u4F7F\u7528 ccjk agent list \u67E5\u770B\u5DF2\u5B89\u88C5\u7684 agent",
970
- hookHint: "\u8FD0\u884C ccjk hooks list \u67E5\u770B\u5DF2\u5B89\u88C5\u7684 hook",
971
- dryRunNote: "\u8FD9\u662F\u9884\u89C8\u6A21\u5F0F\uFF0C\u672A\u5B9E\u9645\u5B89\u88C5\u3002\u79FB\u9664 --dry-run \u6267\u884C\u5B89\u88C5\u3002",
972
- andMore: (n) => `\u8FD8\u6709 ${n} \u4E2A\u6587\u4EF6`
973
- },
974
- "en": {
975
- parsing: "Parsing source...",
976
- parsed: (type) => `Source type: ${type}`,
977
- parseFailed: "Failed to parse source",
978
- detectingType: "Detecting plugin type...",
979
- detectedType: (type) => `Detected type: ${type}`,
980
- defaultType: "Using default type: skill",
981
- installing: "Installing...",
982
- previewInstall: "Previewing installation...",
983
- installSuccess: "Installation successful",
984
- previewSuccess: "Preview complete",
985
- installFailed: "Installation failed",
986
- error: "Error",
987
- installed: "Plugin installed",
988
- preview: "Installation preview (dry-run)",
989
- name: "Name",
990
- version: "Version",
991
- type: "Type",
992
- path: "Path",
993
- source: "Source",
994
- target: "Target",
995
- files: "Files",
996
- nextSteps: "Next steps:",
997
- skillHint: "Use /skill-name in Claude Code to invoke",
998
- mcpHint: "Run ccjk mcp status to check status",
999
- agentHint: "Use ccjk agent list to see installed agents",
1000
- hookHint: "Run ccjk hooks list to see installed hooks",
1001
- dryRunNote: "This is preview mode, nothing was installed. Remove --dry-run to install.",
1002
- andMore: (n) => `and ${n} more files`
1003
- }
1004
- };
1005
- return texts[lang];
1006
- }
1007
-
1008
- export { addCommand, parseSource };