ccjk 14.2.1 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (526) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +58 -341
  3. package/dist/cli.js +59 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/detect.js +15 -0
  6. package/dist/commands/detect.js.map +1 -0
  7. package/dist/commands/doctor.js +68 -0
  8. package/dist/commands/doctor.js.map +1 -0
  9. package/dist/commands/git-install.js +50 -0
  10. package/dist/commands/git-install.js.map +1 -0
  11. package/dist/commands/init.js +102 -0
  12. package/dist/commands/init.js.map +1 -0
  13. package/dist/commands/mcp.js +66 -0
  14. package/dist/commands/mcp.js.map +1 -0
  15. package/dist/commands/menu.js +33 -0
  16. package/dist/commands/menu.js.map +1 -0
  17. package/dist/core/detect.js +24 -0
  18. package/dist/core/detect.js.map +1 -0
  19. package/dist/core/lint.js +49 -0
  20. package/dist/core/lint.js.map +1 -0
  21. package/dist/core/mcp.js +41 -0
  22. package/dist/core/mcp.js.map +1 -0
  23. package/dist/core/paths.js +9 -0
  24. package/dist/core/paths.js.map +1 -0
  25. package/dist/core/providers.js +53 -0
  26. package/dist/core/providers.js.map +1 -0
  27. package/dist/core/settings.js +31 -0
  28. package/dist/core/settings.js.map +1 -0
  29. package/dist/core/slash-templates.js +56 -0
  30. package/dist/core/slash-templates.js.map +1 -0
  31. package/dist/core/tools.js +27 -0
  32. package/dist/core/tools.js.map +1 -0
  33. package/package.json +43 -164
  34. package/README.HONEST.md +0 -176
  35. package/README.en.md +0 -67
  36. package/README.ja.md +0 -67
  37. package/README.ko.md +0 -67
  38. package/README.zh-CN.md +0 -86
  39. package/bin/ccjk.mjs +0 -5
  40. package/bin/ccjk.ts +0 -222
  41. package/dist/chunks/agent-teams.mjs +0 -145
  42. package/dist/chunks/agent.mjs +0 -1439
  43. package/dist/chunks/agents.mjs +0 -3783
  44. package/dist/chunks/api-cli.mjs +0 -135
  45. package/dist/chunks/api-config-selector.mjs +0 -159
  46. package/dist/chunks/api-providers.mjs +0 -144
  47. package/dist/chunks/api.mjs +0 -115
  48. package/dist/chunks/auto-bootstrap.mjs +0 -358
  49. package/dist/chunks/auto-fixer.mjs +0 -95
  50. package/dist/chunks/auto-updater.mjs +0 -507
  51. package/dist/chunks/banner.mjs +0 -173
  52. package/dist/chunks/bash.mjs +0 -187
  53. package/dist/chunks/boost.mjs +0 -474
  54. package/dist/chunks/brain-config.mjs +0 -75
  55. package/dist/chunks/brain-status.mjs +0 -89
  56. package/dist/chunks/ccjk-agents.mjs +0 -416
  57. package/dist/chunks/ccjk-all.mjs +0 -1046
  58. package/dist/chunks/ccjk-config.mjs +0 -445
  59. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  60. package/dist/chunks/ccjk-mcp.mjs +0 -763
  61. package/dist/chunks/ccjk-setup.mjs +0 -765
  62. package/dist/chunks/ccjk-skills.mjs +0 -518
  63. package/dist/chunks/ccr.mjs +0 -109
  64. package/dist/chunks/ccu.mjs +0 -40
  65. package/dist/chunks/check-updates.mjs +0 -117
  66. package/dist/chunks/claude-code-incremental-manager.mjs +0 -761
  67. package/dist/chunks/claude-config.mjs +0 -606
  68. package/dist/chunks/claude-config2.mjs +0 -62
  69. package/dist/chunks/claude-wrapper.mjs +0 -85
  70. package/dist/chunks/clavue-config.mjs +0 -1390
  71. package/dist/chunks/cleanup-migration.mjs +0 -20
  72. package/dist/chunks/cli-hook.mjs +0 -4096
  73. package/dist/chunks/cloud-sync.mjs +0 -29
  74. package/dist/chunks/code-type-resolver.mjs +0 -880
  75. package/dist/chunks/codex-config-switch.mjs +0 -452
  76. package/dist/chunks/codex-provider-manager.mjs +0 -238
  77. package/dist/chunks/codex-uninstaller.mjs +0 -404
  78. package/dist/chunks/codex.mjs +0 -2141
  79. package/dist/chunks/commands.mjs +0 -108
  80. package/dist/chunks/commands2.mjs +0 -421
  81. package/dist/chunks/commit.mjs +0 -140
  82. package/dist/chunks/completion.mjs +0 -517
  83. package/dist/chunks/config-consolidator.mjs +0 -172
  84. package/dist/chunks/config-switch.mjs +0 -334
  85. package/dist/chunks/config.mjs +0 -558
  86. package/dist/chunks/config2.mjs +0 -484
  87. package/dist/chunks/config3.mjs +0 -486
  88. package/dist/chunks/constants.mjs +0 -323
  89. package/dist/chunks/context-opt.mjs +0 -444
  90. package/dist/chunks/context.mjs +0 -974
  91. package/dist/chunks/dashboard.mjs +0 -481
  92. package/dist/chunks/doctor.mjs +0 -1301
  93. package/dist/chunks/eval.mjs +0 -502
  94. package/dist/chunks/evolution.mjs +0 -322
  95. package/dist/chunks/features.mjs +0 -715
  96. package/dist/chunks/fish.mjs +0 -181
  97. package/dist/chunks/fs-operations.mjs +0 -180
  98. package/dist/chunks/health-alerts.mjs +0 -830
  99. package/dist/chunks/help.mjs +0 -341
  100. package/dist/chunks/hook-installer.mjs +0 -48
  101. package/dist/chunks/impact.mjs +0 -651
  102. package/dist/chunks/index.mjs +0 -23
  103. package/dist/chunks/index10.mjs +0 -19
  104. package/dist/chunks/index11.mjs +0 -1171
  105. package/dist/chunks/index12.mjs +0 -218
  106. package/dist/chunks/index13.mjs +0 -679
  107. package/dist/chunks/index14.mjs +0 -1009
  108. package/dist/chunks/index15.mjs +0 -194
  109. package/dist/chunks/index2.mjs +0 -7637
  110. package/dist/chunks/index3.mjs +0 -171
  111. package/dist/chunks/index4.mjs +0 -26
  112. package/dist/chunks/index5.mjs +0 -19
  113. package/dist/chunks/index6.mjs +0 -19092
  114. package/dist/chunks/index7.mjs +0 -616
  115. package/dist/chunks/index8.mjs +0 -1602
  116. package/dist/chunks/index9.mjs +0 -5384
  117. package/dist/chunks/init.mjs +0 -1911
  118. package/dist/chunks/installer.mjs +0 -757
  119. package/dist/chunks/installer2.mjs +0 -103
  120. package/dist/chunks/interview.mjs +0 -2927
  121. package/dist/chunks/json-config.mjs +0 -60
  122. package/dist/chunks/linux.mjs +0 -3863
  123. package/dist/chunks/macos.mjs +0 -69
  124. package/dist/chunks/main.mjs +0 -635
  125. package/dist/chunks/manager.mjs +0 -1048
  126. package/dist/chunks/marketplace.mjs +0 -265
  127. package/dist/chunks/mcp-cli.mjs +0 -205
  128. package/dist/chunks/mcp-performance.mjs +0 -187
  129. package/dist/chunks/mcp.mjs +0 -667
  130. package/dist/chunks/memory-check.mjs +0 -2973
  131. package/dist/chunks/memory-paths.mjs +0 -259
  132. package/dist/chunks/memory-sync.mjs +0 -209
  133. package/dist/chunks/memory.mjs +0 -354
  134. package/dist/chunks/metrics-display.mjs +0 -153
  135. package/dist/chunks/monitor.mjs +0 -1856
  136. package/dist/chunks/notification.mjs +0 -1864
  137. package/dist/chunks/onboarding.mjs +0 -386
  138. package/dist/chunks/package.mjs +0 -3
  139. package/dist/chunks/paradigm.mjs +0 -74
  140. package/dist/chunks/permission-manager.mjs +0 -250
  141. package/dist/chunks/permissions.mjs +0 -265
  142. package/dist/chunks/persistence-manager.mjs +0 -801
  143. package/dist/chunks/persistence.mjs +0 -707
  144. package/dist/chunks/platform.mjs +0 -395
  145. package/dist/chunks/plugin.mjs +0 -1936
  146. package/dist/chunks/powershell.mjs +0 -213
  147. package/dist/chunks/prompts.mjs +0 -244
  148. package/dist/chunks/providers.mjs +0 -263
  149. package/dist/chunks/quick-actions.mjs +0 -335
  150. package/dist/chunks/quick-provider.mjs +0 -755
  151. package/dist/chunks/quick-setup.mjs +0 -421
  152. package/dist/chunks/remote.mjs +0 -497
  153. package/dist/chunks/research.mjs +0 -1904
  154. package/dist/chunks/rollback.mjs +0 -38
  155. package/dist/chunks/session-manager.mjs +0 -1371
  156. package/dist/chunks/session.mjs +0 -878
  157. package/dist/chunks/sessions.mjs +0 -106
  158. package/dist/chunks/silent-updater.mjs +0 -396
  159. package/dist/chunks/simple-config.mjs +0 -122
  160. package/dist/chunks/skill.mjs +0 -117
  161. package/dist/chunks/skill2.mjs +0 -9052
  162. package/dist/chunks/skills-sync.mjs +0 -1343
  163. package/dist/chunks/skills.mjs +0 -577
  164. package/dist/chunks/slash-commands.mjs +0 -208
  165. package/dist/chunks/smart-guide.mjs +0 -247
  166. package/dist/chunks/snapshot.mjs +0 -58
  167. package/dist/chunks/startup.mjs +0 -487
  168. package/dist/chunks/stats.mjs +0 -191
  169. package/dist/chunks/status.mjs +0 -471
  170. package/dist/chunks/team.mjs +0 -63
  171. package/dist/chunks/thinking.mjs +0 -626
  172. package/dist/chunks/trace.mjs +0 -57
  173. package/dist/chunks/uninstall.mjs +0 -852
  174. package/dist/chunks/update.mjs +0 -174
  175. package/dist/chunks/upgrade-manager.mjs +0 -204
  176. package/dist/chunks/upgrade.mjs +0 -133
  177. package/dist/chunks/version-checker.mjs +0 -891
  178. package/dist/chunks/vim.mjs +0 -903
  179. package/dist/chunks/windows.mjs +0 -14
  180. package/dist/chunks/workflows.mjs +0 -633
  181. package/dist/chunks/wsl.mjs +0 -129
  182. package/dist/chunks/zero-config.mjs +0 -871
  183. package/dist/chunks/zsh.mjs +0 -182
  184. package/dist/cli.d.mts +0 -1
  185. package/dist/cli.d.ts +0 -1
  186. package/dist/cli.mjs +0 -2684
  187. package/dist/i18n/locales/en/agent-teams.json +0 -18
  188. package/dist/i18n/locales/en/agentBrowser.json +0 -80
  189. package/dist/i18n/locales/en/agents.json +0 -135
  190. package/dist/i18n/locales/en/api.json +0 -63
  191. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  192. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  193. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  194. package/dist/i18n/locales/en/ccjk.json +0 -276
  195. package/dist/i18n/locales/en/ccr.json +0 -65
  196. package/dist/i18n/locales/en/claude-md.json +0 -73
  197. package/dist/i18n/locales/en/cli.json +0 -148
  198. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  199. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  200. package/dist/i18n/locales/en/cloud.json +0 -40
  201. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  202. package/dist/i18n/locales/en/codex.json +0 -184
  203. package/dist/i18n/locales/en/cometix.json +0 -29
  204. package/dist/i18n/locales/en/common.json +0 -68
  205. package/dist/i18n/locales/en/config.json +0 -108
  206. package/dist/i18n/locales/en/configuration.json +0 -234
  207. package/dist/i18n/locales/en/context.json +0 -85
  208. package/dist/i18n/locales/en/dashboard.json +0 -78
  209. package/dist/i18n/locales/en/errors.json +0 -26
  210. package/dist/i18n/locales/en/evolution.json +0 -54
  211. package/dist/i18n/locales/en/hooks.json +0 -74
  212. package/dist/i18n/locales/en/hooksSync.json +0 -133
  213. package/dist/i18n/locales/en/installation.json +0 -83
  214. package/dist/i18n/locales/en/interview.json +0 -104
  215. package/dist/i18n/locales/en/language.json +0 -19
  216. package/dist/i18n/locales/en/lsp.json +0 -78
  217. package/dist/i18n/locales/en/marketplace.json +0 -116
  218. package/dist/i18n/locales/en/mcp.json +0 -180
  219. package/dist/i18n/locales/en/memory.json +0 -23
  220. package/dist/i18n/locales/en/menu.json +0 -299
  221. package/dist/i18n/locales/en/multi-config.json +0 -79
  222. package/dist/i18n/locales/en/notification.json +0 -307
  223. package/dist/i18n/locales/en/permissions.json +0 -95
  224. package/dist/i18n/locales/en/persistence.json +0 -127
  225. package/dist/i18n/locales/en/plugins.json +0 -146
  226. package/dist/i18n/locales/en/quick-actions.json +0 -78
  227. package/dist/i18n/locales/en/registry.json +0 -54
  228. package/dist/i18n/locales/en/remote.json +0 -93
  229. package/dist/i18n/locales/en/sandbox.json +0 -44
  230. package/dist/i18n/locales/en/setup.json +0 -44
  231. package/dist/i18n/locales/en/shencha.json +0 -14
  232. package/dist/i18n/locales/en/skills.json +0 -100
  233. package/dist/i18n/locales/en/skillsSync.json +0 -74
  234. package/dist/i18n/locales/en/smartGuide.json +0 -49
  235. package/dist/i18n/locales/en/stats.json +0 -20
  236. package/dist/i18n/locales/en/subagent.json +0 -69
  237. package/dist/i18n/locales/en/superpowers.json +0 -117
  238. package/dist/i18n/locales/en/team.json +0 -7
  239. package/dist/i18n/locales/en/thinking.json +0 -65
  240. package/dist/i18n/locales/en/tools.json +0 -42
  241. package/dist/i18n/locales/en/uninstall.json +0 -56
  242. package/dist/i18n/locales/en/updater.json +0 -29
  243. package/dist/i18n/locales/en/vim.json +0 -169
  244. package/dist/i18n/locales/en/workflow.json +0 -55
  245. package/dist/i18n/locales/en/workspace.json +0 -108
  246. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  247. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -80
  248. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  249. package/dist/i18n/locales/zh-CN/api.json +0 -63
  250. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  251. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  252. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  253. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  254. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  255. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  256. package/dist/i18n/locales/zh-CN/cli.json +0 -148
  257. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  258. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  259. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  260. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  261. package/dist/i18n/locales/zh-CN/codex.json +0 -184
  262. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  263. package/dist/i18n/locales/zh-CN/common.json +0 -68
  264. package/dist/i18n/locales/zh-CN/config.json +0 -108
  265. package/dist/i18n/locales/zh-CN/configuration.json +0 -232
  266. package/dist/i18n/locales/zh-CN/context.json +0 -85
  267. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  268. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  269. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  270. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  271. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  272. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  273. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  274. package/dist/i18n/locales/zh-CN/language.json +0 -19
  275. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  276. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  277. package/dist/i18n/locales/zh-CN/mcp.json +0 -180
  278. package/dist/i18n/locales/zh-CN/memory.json +0 -23
  279. package/dist/i18n/locales/zh-CN/menu.json +0 -299
  280. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  281. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  282. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  283. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  284. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  285. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  286. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  287. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  288. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  289. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  290. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  291. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  292. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  293. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  294. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  295. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  296. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  297. package/dist/i18n/locales/zh-CN/team.json +0 -7
  298. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  299. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  300. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  301. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  302. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  303. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  304. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  305. package/dist/index.d.mts +0 -5658
  306. package/dist/index.d.ts +0 -5658
  307. package/dist/index.mjs +0 -3732
  308. package/dist/shared/ccjk.8oaxX4iR.mjs +0 -90
  309. package/dist/shared/ccjk.B2U7DsPy.mjs +0 -31
  310. package/dist/shared/ccjk.B2f-cwUP.mjs +0 -468
  311. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  312. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  313. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  314. package/dist/shared/ccjk.BLsIiTqO.mjs +0 -449
  315. package/dist/shared/ccjk.BXv8aYs1.mjs +0 -170
  316. package/dist/shared/ccjk.BnsY5WxD.mjs +0 -171
  317. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  318. package/dist/shared/ccjk.Bq8TqZG_.mjs +0 -189
  319. package/dist/shared/ccjk.BtrioX1Z.mjs +0 -25
  320. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  321. package/dist/shared/ccjk.BzPbSEP2.mjs +0 -115
  322. package/dist/shared/ccjk.C1Be3aJN.mjs +0 -254
  323. package/dist/shared/ccjk.C1hANZTu.mjs +0 -19
  324. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  325. package/dist/shared/ccjk.C94P8gCY.mjs +0 -283
  326. package/dist/shared/ccjk.CNhnT6uQ.mjs +0 -636
  327. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  328. package/dist/shared/ccjk.CTr4yCZ1.mjs +0 -225
  329. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  330. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  331. package/dist/shared/ccjk.CoCHVXl3.mjs +0 -3951
  332. package/dist/shared/ccjk.CwGZSTAK.mjs +0 -319
  333. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  334. package/dist/shared/ccjk.D-magaEx.mjs +0 -763
  335. package/dist/shared/ccjk.D0g2ABGg.mjs +0 -171
  336. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  337. package/dist/shared/ccjk.D75wivnp.mjs +0 -142
  338. package/dist/shared/ccjk.DDL-4C-k.mjs +0 -100
  339. package/dist/shared/ccjk.DFRPtmK_.mjs +0 -75
  340. package/dist/shared/ccjk.DMV3x5Sd.mjs +0 -299
  341. package/dist/shared/ccjk.DZ2LLOa-.mjs +0 -2195
  342. package/dist/shared/ccjk.DbigonEQ.mjs +0 -698
  343. package/dist/shared/ccjk.DcMvE7lf.mjs +0 -618
  344. package/dist/shared/ccjk.DeWpAShp.mjs +0 -1828
  345. package/dist/shared/ccjk.DhJ1kyDR.mjs +0 -30
  346. package/dist/shared/ccjk.DlTXS9rP.mjs +0 -224
  347. package/dist/shared/ccjk.DopKzo3z.mjs +0 -305
  348. package/dist/shared/ccjk.DsZsc4LR.mjs +0 -1280
  349. package/dist/shared/ccjk.DuzJZlgj.mjs +0 -418
  350. package/dist/shared/ccjk.Dxgd2vjc.mjs +0 -444
  351. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  352. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  353. package/dist/shared/ccjk.MwtjAULc.mjs +0 -1447
  354. package/dist/shared/ccjk.OJKHVSOb.mjs +0 -2005
  355. package/dist/shared/ccjk.OTnevPNE.mjs +0 -225
  356. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  357. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  358. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  359. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  360. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  361. package/dist/shared/ccjk.i_vn-9C3.mjs +0 -317
  362. package/dist/shared/ccjk.lG3ccFjm.mjs +0 -885
  363. package/dist/shared/ccjk.wLJHO0Af.mjs +0 -244
  364. package/dist/shared/ccjk.y-a_1vK4.mjs +0 -5127
  365. package/dist/templates/agents/README.md +0 -78
  366. package/dist/templates/agents/fullstack-developer.json +0 -70
  367. package/dist/templates/agents/go-expert.json +0 -69
  368. package/dist/templates/agents/index.json +0 -64
  369. package/dist/templates/agents/python-expert.json +0 -69
  370. package/dist/templates/agents/react-specialist.json +0 -69
  371. package/dist/templates/agents/testing-automation-expert.json +0 -70
  372. package/dist/templates/agents/typescript-architect.json +0 -69
  373. package/dist/templates/claude-code/common/settings.json +0 -109
  374. package/dist/templates/common/error-prevention.md +0 -267
  375. package/dist/templates/common/karpathy-baseline.md +0 -83
  376. package/dist/templates/common/output-styles/zh-CN/carmack-mode.md +0 -381
  377. package/dist/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  378. package/dist/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  379. package/dist/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  380. package/dist/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  381. package/dist/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  382. package/dist/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  383. package/dist/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  384. package/dist/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  385. package/dist/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  386. package/dist/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  387. package/dist/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  388. package/dist/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  389. package/dist/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  390. package/dist/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  391. package/dist/templates/common/workflow/essential/en/feat.md +0 -92
  392. package/dist/templates/common/workflow/essential/en/goal.md +0 -147
  393. package/dist/templates/common/workflow/essential/en/init-project.md +0 -53
  394. package/dist/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  395. package/dist/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  396. package/dist/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  397. package/dist/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  398. package/dist/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  399. package/dist/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  400. package/dist/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  401. package/dist/templates/common/workflow/git/en/git-commit.md +0 -205
  402. package/dist/templates/common/workflow/git/en/git-rollback.md +0 -90
  403. package/dist/templates/common/workflow/git/en/git-worktree.md +0 -276
  404. package/dist/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  405. package/dist/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  406. package/dist/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  407. package/dist/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  408. package/dist/templates/common/workflow/interview/en/interview.md +0 -67
  409. package/dist/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  410. package/dist/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  411. package/dist/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  412. package/dist/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  413. package/dist/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  414. package/dist/templates/common/workflow/sixStep/en/workflow.md +0 -83
  415. package/dist/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  416. package/dist/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  417. package/dist/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  418. package/dist/templates/hooks/README.md +0 -212
  419. package/dist/templates/hooks/git-workflow-hooks.md +0 -551
  420. package/dist/templates/hooks/post-test/coverage.json +0 -21
  421. package/dist/templates/hooks/post-test/summary.json +0 -21
  422. package/dist/templates/hooks/post-test-coverage.md +0 -434
  423. package/dist/templates/hooks/pre-commit/eslint.json +0 -22
  424. package/dist/templates/hooks/pre-commit/prettier.json +0 -22
  425. package/dist/templates/hooks/pre-commit-black.md +0 -274
  426. package/dist/templates/hooks/pre-commit-eslint.md +0 -153
  427. package/dist/templates/hooks/pre-commit-gofmt.md +0 -284
  428. package/dist/templates/hooks/pre-commit-prettier.md +0 -212
  429. package/dist/templates/hooks/pre-commit-type-check.md +0 -377
  430. package/dist/templates/skills/ccjk-init.md +0 -154
  431. package/dist/templates/skills/ccjk-mcp-setup.md +0 -205
  432. package/dist/templates/skills/ccjk-troubleshoot.md +0 -228
  433. package/dist/templates/skills/django-patterns.md +0 -1016
  434. package/dist/templates/skills/git-workflow.md +0 -748
  435. package/dist/templates/skills/go-idioms.md +0 -963
  436. package/dist/templates/skills/index.json +0 -132
  437. package/dist/templates/skills/nextjs-optimization.md +0 -694
  438. package/dist/templates/skills/python-pep8.md +0 -852
  439. package/dist/templates/skills/react-patterns.md +0 -686
  440. package/dist/templates/skills/rust-patterns.md +0 -1057
  441. package/dist/templates/skills/security-best-practices.md +0 -1413
  442. package/dist/templates/skills/testing-best-practices.md +0 -1315
  443. package/dist/templates/skills/ts-best-practices.md +0 -354
  444. package/templates/agents/README.md +0 -78
  445. package/templates/agents/fullstack-developer.json +0 -70
  446. package/templates/agents/go-expert.json +0 -69
  447. package/templates/agents/index.json +0 -64
  448. package/templates/agents/python-expert.json +0 -69
  449. package/templates/agents/react-specialist.json +0 -69
  450. package/templates/agents/testing-automation-expert.json +0 -70
  451. package/templates/agents/typescript-architect.json +0 -69
  452. package/templates/claude-code/common/settings.json +0 -109
  453. package/templates/common/error-prevention.md +0 -267
  454. package/templates/common/karpathy-baseline.md +0 -83
  455. package/templates/common/output-styles/zh-CN/carmack-mode.md +0 -381
  456. package/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  457. package/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  458. package/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  459. package/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  460. package/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  461. package/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  462. package/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  463. package/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  464. package/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  465. package/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  466. package/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  467. package/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  468. package/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  469. package/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  470. package/templates/common/workflow/essential/en/feat.md +0 -92
  471. package/templates/common/workflow/essential/en/goal.md +0 -147
  472. package/templates/common/workflow/essential/en/init-project.md +0 -53
  473. package/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  474. package/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  475. package/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  476. package/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  477. package/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  478. package/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  479. package/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  480. package/templates/common/workflow/git/en/git-commit.md +0 -205
  481. package/templates/common/workflow/git/en/git-rollback.md +0 -90
  482. package/templates/common/workflow/git/en/git-worktree.md +0 -276
  483. package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  484. package/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  485. package/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  486. package/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  487. package/templates/common/workflow/interview/en/interview.md +0 -67
  488. package/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  489. package/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  490. package/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  491. package/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  492. package/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  493. package/templates/common/workflow/sixStep/en/workflow.md +0 -83
  494. package/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  495. package/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  496. package/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  497. package/templates/hooks/README.md +0 -212
  498. package/templates/hooks/git-workflow-hooks.md +0 -551
  499. package/templates/hooks/post-test/coverage.json +0 -21
  500. package/templates/hooks/post-test/summary.json +0 -21
  501. package/templates/hooks/post-test-coverage.md +0 -434
  502. package/templates/hooks/pre-commit/eslint.json +0 -22
  503. package/templates/hooks/pre-commit/prettier.json +0 -22
  504. package/templates/hooks/pre-commit-black.md +0 -274
  505. package/templates/hooks/pre-commit-eslint.md +0 -153
  506. package/templates/hooks/pre-commit-gofmt.md +0 -284
  507. package/templates/hooks/pre-commit-prettier.md +0 -212
  508. package/templates/hooks/pre-commit-type-check.md +0 -377
  509. package/templates/skills/basic.hbs +0 -72
  510. package/templates/skills/ccjk-init.md +0 -154
  511. package/templates/skills/ccjk-mcp-setup.md +0 -205
  512. package/templates/skills/ccjk-troubleshoot.md +0 -228
  513. package/templates/skills/code-refactor.hbs +0 -133
  514. package/templates/skills/code-review.hbs +0 -141
  515. package/templates/skills/django-patterns.md +0 -1016
  516. package/templates/skills/git-workflow.md +0 -748
  517. package/templates/skills/go-idioms.md +0 -963
  518. package/templates/skills/index.json +0 -132
  519. package/templates/skills/nextjs-optimization.md +0 -694
  520. package/templates/skills/python-pep8.md +0 -852
  521. package/templates/skills/react-patterns.md +0 -686
  522. package/templates/skills/rust-patterns.md +0 -1057
  523. package/templates/skills/security-best-practices.md +0 -1413
  524. package/templates/skills/testing-best-practices.md +0 -1315
  525. package/templates/skills/ts-best-practices.md +0 -354
  526. package/templates/skills/type-fix.hbs +0 -132
@@ -1,1447 +0,0 @@
1
- import { existsSync, mkdirSync, rmSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
2
- import { tmpdir, homedir } from 'node:os';
3
- import { x as K } from '../chunks/main.mjs';
4
- import { CCJK_PLUGINS_DIR, CCJK_SKILLS_DIR, CLAUDE_AGENTS_DIR, CCJK_CONFIG_DIR } from '../chunks/constants.mjs';
5
- import { w as writeAgentFile, g as getAgentsDir } from './ccjk.CfKKcvWy.mjs';
6
- import { j as join, d as dirname } from './ccjk.bQ7Dh1g4.mjs';
7
- import { spawn } from 'node:child_process';
8
- import { g as getSkillParser } from './ccjk.i_vn-9C3.mjs';
9
-
10
- const DEFAULT_MIN_CONFIDENCE = 0.6;
11
- const PATTERN_WEIGHT = 0.4;
12
- const KEYWORD_WEIGHT = 0.3;
13
- const CONTEXT_WEIGHT = 0.3;
14
- class IntentEngine {
15
- rules = /* @__PURE__ */ new Map();
16
- contextCache = /* @__PURE__ */ new Map();
17
- cacheTTL = 5e3;
18
- // 5 seconds
19
- constructor() {
20
- }
21
- // ==========================================================================
22
- // Rule Management
23
- // ==========================================================================
24
- /**
25
- * Register an intent rule
26
- */
27
- registerRule(rule) {
28
- this.rules.set(rule.id, rule);
29
- }
30
- /**
31
- * Register multiple intent rules
32
- */
33
- registerRules(rules) {
34
- for (const rule of rules) {
35
- this.registerRule(rule);
36
- }
37
- }
38
- /**
39
- * Unregister an intent rule
40
- */
41
- unregisterRule(ruleId) {
42
- this.rules.delete(ruleId);
43
- }
44
- /**
45
- * Unregister all rules for a plugin
46
- */
47
- unregisterPluginRules(pluginId) {
48
- for (const [id, rule] of this.rules) {
49
- if (rule.pluginId === pluginId) {
50
- this.rules.delete(id);
51
- }
52
- }
53
- }
54
- /**
55
- * Get all registered rules
56
- */
57
- getRules() {
58
- return Array.from(this.rules.values());
59
- }
60
- // ==========================================================================
61
- // Intent Detection
62
- // ==========================================================================
63
- /**
64
- * Detect intent from user input and context
65
- *
66
- * @param userInput - User's input text
67
- * @param cwd - Current working directory
68
- * @returns Array of intent matches sorted by confidence
69
- */
70
- async detect(userInput, cwd) {
71
- const context = await this.buildContext(userInput, cwd);
72
- const matches = [];
73
- for (const rule of this.rules.values()) {
74
- const match = this.matchRule(rule, context);
75
- if (match && match.confidence >= (rule.minConfidence ?? DEFAULT_MIN_CONFIDENCE)) {
76
- matches.push(match);
77
- }
78
- }
79
- matches.sort((a, b) => {
80
- const confDiff = b.confidence - a.confidence;
81
- if (Math.abs(confDiff) > 0.1) {
82
- return confDiff;
83
- }
84
- const ruleA = this.rules.get(a.intentId);
85
- const ruleB = this.rules.get(b.intentId);
86
- return (ruleB?.priority ?? 0) - (ruleA?.priority ?? 0);
87
- });
88
- return matches;
89
- }
90
- /**
91
- * Get the best matching intent
92
- */
93
- async detectBest(userInput, cwd) {
94
- const matches = await this.detect(userInput, cwd);
95
- return matches.length > 0 ? matches[0] : null;
96
- }
97
- /**
98
- * Check if any intent should auto-execute
99
- */
100
- async detectAutoExecute(userInput, cwd) {
101
- const matches = await this.detect(userInput, cwd);
102
- return matches.find((m) => m.autoExecute && m.confidence >= 0.8) ?? null;
103
- }
104
- // ==========================================================================
105
- // Context Building
106
- // ==========================================================================
107
- /**
108
- * Build detection context from user input and environment
109
- */
110
- async buildContext(userInput, cwd) {
111
- const [gitStatus, projectType, activeSignals] = await Promise.all([
112
- this.detectGitStatus(cwd),
113
- this.detectProjectType(cwd),
114
- this.detectActiveSignals(cwd)
115
- ]);
116
- return {
117
- userInput,
118
- cwd,
119
- gitStatus,
120
- projectType,
121
- activeSignals
122
- };
123
- }
124
- /**
125
- * Detect git status
126
- */
127
- async detectGitStatus(cwd) {
128
- const isRepo = existsSync(join(cwd, ".git"));
129
- if (!isRepo) {
130
- return { isRepo: false, hasChanges: false, hasStaged: false };
131
- }
132
- try {
133
- const statusResult = await K("git", ["status", "--porcelain"], { nodeOptions: { cwd } });
134
- const hasChanges = statusResult.stdout.trim().length > 0;
135
- const stagedResult = await K("git", ["diff", "--cached", "--name-only"], { nodeOptions: { cwd } });
136
- const hasStaged = stagedResult.stdout.trim().length > 0;
137
- const branchResult = await K("git", ["branch", "--show-current"], { nodeOptions: { cwd } });
138
- const branch = branchResult.stdout.trim();
139
- const remoteResult = await K("git", ["remote", "get-url", "origin"], { nodeOptions: { cwd } });
140
- const remote = remoteResult.stdout.trim() || void 0;
141
- return { isRepo, hasChanges, hasStaged, branch, remote };
142
- } catch {
143
- return { isRepo, hasChanges: false, hasStaged: false };
144
- }
145
- }
146
- /**
147
- * Detect project type from files
148
- */
149
- async detectProjectType(cwd) {
150
- if (existsSync(join(cwd, "next.config.js")) || existsSync(join(cwd, "next.config.mjs")) || existsSync(join(cwd, "next.config.ts"))) {
151
- return "nextjs";
152
- }
153
- if (existsSync(join(cwd, "vue.config.js")) || existsSync(join(cwd, "vite.config.ts"))) {
154
- const pkgPath2 = join(cwd, "package.json");
155
- if (existsSync(pkgPath2)) {
156
- try {
157
- const pkg = await import(pkgPath2);
158
- if (pkg.dependencies?.vue || pkg.devDependencies?.vue) {
159
- return "vue";
160
- }
161
- } catch {
162
- }
163
- }
164
- }
165
- const pkgPath = join(cwd, "package.json");
166
- if (existsSync(pkgPath)) {
167
- try {
168
- const pkg = await import(pkgPath);
169
- if (pkg.dependencies?.react || pkg.devDependencies?.react) {
170
- return "react";
171
- }
172
- } catch {
173
- }
174
- }
175
- if (existsSync(join(cwd, "tsconfig.json"))) {
176
- return "typescript";
177
- }
178
- if (existsSync(join(cwd, "package.json"))) {
179
- return "nodejs";
180
- }
181
- if (existsSync(join(cwd, "requirements.txt")) || existsSync(join(cwd, "pyproject.toml"))) {
182
- return "python";
183
- }
184
- if (existsSync(join(cwd, "Cargo.toml"))) {
185
- return "rust";
186
- }
187
- if (existsSync(join(cwd, "go.mod"))) {
188
- return "go";
189
- }
190
- return "unknown";
191
- }
192
- /**
193
- * Detect active context signals
194
- */
195
- async detectActiveSignals(cwd) {
196
- const signals = [];
197
- const gitStatus = await this.detectGitStatus(cwd);
198
- if (gitStatus.isRepo) {
199
- signals.push("git_is_repo");
200
- if (gitStatus.hasChanges)
201
- signals.push("git_has_changes");
202
- if (gitStatus.hasStaged)
203
- signals.push("git_has_staged");
204
- if (gitStatus.remote)
205
- signals.push("git_has_remote");
206
- }
207
- if (existsSync(join(cwd, "package.json")))
208
- signals.push("has_package_json");
209
- if (existsSync(join(cwd, "tsconfig.json")))
210
- signals.push("has_tsconfig");
211
- if (existsSync(join(cwd, "Dockerfile")) || existsSync(join(cwd, "docker-compose.yml")))
212
- signals.push("has_dockerfile");
213
- if (existsSync(join(cwd, "tests")) || existsSync(join(cwd, "__tests__")) || existsSync(join(cwd, "test"))) {
214
- signals.push("has_tests");
215
- }
216
- if (cwd.includes("/src") || existsSync(join(cwd, "src"))) {
217
- signals.push("in_src_directory");
218
- }
219
- return signals;
220
- }
221
- // ==========================================================================
222
- // Rule Matching
223
- // ==========================================================================
224
- /**
225
- * Match a single rule against context
226
- */
227
- matchRule(rule, context) {
228
- const matchedPatterns = [];
229
- const matchedSignals = [];
230
- let patternScore = 0;
231
- for (const pattern of rule.patterns) {
232
- try {
233
- const regex = new RegExp(pattern, "i");
234
- if (regex.test(context.userInput)) {
235
- matchedPatterns.push(pattern);
236
- patternScore += 1 / rule.patterns.length;
237
- }
238
- } catch {
239
- if (context.userInput.toLowerCase().includes(pattern.toLowerCase())) {
240
- matchedPatterns.push(pattern);
241
- patternScore += 1 / rule.patterns.length;
242
- }
243
- }
244
- }
245
- let keywordScore = 0;
246
- const inputLower = context.userInput.toLowerCase();
247
- for (const keyword of rule.keywords) {
248
- if (inputLower.includes(keyword.toLowerCase())) {
249
- keywordScore += 1 / rule.keywords.length;
250
- }
251
- }
252
- let contextScore = 0;
253
- if (rule.contextSignals.length > 0) {
254
- for (const signal of rule.contextSignals) {
255
- if (context.activeSignals.includes(signal)) {
256
- matchedSignals.push(signal);
257
- contextScore += 1 / rule.contextSignals.length;
258
- }
259
- }
260
- } else {
261
- contextScore = 1;
262
- }
263
- let fileBonus = 0;
264
- if (rule.filePatterns && rule.filePatterns.length > 0) {
265
- for (const pattern of rule.filePatterns) {
266
- if (existsSync(join(context.cwd, pattern))) {
267
- fileBonus += 0.1;
268
- }
269
- }
270
- }
271
- const confidence = Math.min(1, patternScore * PATTERN_WEIGHT + keywordScore * KEYWORD_WEIGHT + contextScore * CONTEXT_WEIGHT + fileBonus);
272
- if (patternScore === 0 && keywordScore === 0) {
273
- return null;
274
- }
275
- return {
276
- pluginId: rule.pluginId,
277
- intentId: rule.id,
278
- confidence,
279
- matchedPatterns,
280
- matchedSignals,
281
- suggestedAction: rule.name,
282
- autoExecute: rule.autoExecute && confidence >= 0.8
283
- };
284
- }
285
- // ==========================================================================
286
- // Cache Management
287
- // ==========================================================================
288
- /**
289
- * Clear context cache
290
- */
291
- clearCache() {
292
- this.contextCache.clear();
293
- }
294
- /**
295
- * Get cached value or compute
296
- */
297
- async getCachedOrCompute(key, compute) {
298
- const cached = this.contextCache.get(key);
299
- if (cached && Date.now() - cached.timestamp < this.cacheTTL) {
300
- return cached.value;
301
- }
302
- const value = await compute();
303
- this.contextCache.set(key, { value, timestamp: Date.now() });
304
- return value;
305
- }
306
- }
307
- const DEFAULT_INTENT_RULES = [
308
- // Git Commit Intent
309
- {
310
- id: "intent:git-commit",
311
- name: { "en": "Git Commit", "zh-CN": "Git \u63D0\u4EA4" },
312
- patterns: [
313
- "\u63D0\u4EA4.*\u4EE3\u7801",
314
- "\u63D0\u4EA4.*\u66F4\u6539",
315
- "\u63D0\u4EA4.*\u4FEE\u6539",
316
- "commit.*changes",
317
- "commit.*code",
318
- "save.*changes",
319
- "\u4FDD\u5B58.*\u4FEE\u6539"
320
- ],
321
- keywords: ["commit", "\u63D0\u4EA4", "save", "push", "\u4FDD\u5B58"],
322
- contextSignals: ["git_is_repo", "git_has_changes"],
323
- filePatterns: [".git/"],
324
- priority: 90,
325
- pluginId: "git-helper",
326
- skillId: "smart-commit",
327
- autoExecute: false
328
- },
329
- // Code Review Intent
330
- {
331
- id: "intent:code-review",
332
- name: { "en": "Code Review", "zh-CN": "\u4EE3\u7801\u5BA1\u67E5" },
333
- patterns: [
334
- "\u5BA1\u67E5.*\u4EE3\u7801",
335
- "review.*code",
336
- "\u68C0\u67E5.*\u4EE3\u7801",
337
- "check.*code",
338
- "\u4EE3\u7801.*\u95EE\u9898"
339
- ],
340
- keywords: ["review", "\u5BA1\u67E5", "check", "\u68C0\u67E5", "lint"],
341
- contextSignals: ["git_has_changes", "in_src_directory"],
342
- priority: 85,
343
- pluginId: "code-reviewer",
344
- autoExecute: false
345
- },
346
- // Test Generation Intent
347
- {
348
- id: "intent:generate-tests",
349
- name: { "en": "Generate Tests", "zh-CN": "\u751F\u6210\u6D4B\u8BD5" },
350
- patterns: [
351
- "\u5199.*\u6D4B\u8BD5",
352
- "\u751F\u6210.*\u6D4B\u8BD5",
353
- "write.*test",
354
- "generate.*test",
355
- "create.*test",
356
- "\u6DFB\u52A0.*\u6D4B\u8BD5"
357
- ],
358
- keywords: ["test", "\u6D4B\u8BD5", "spec", "jest", "vitest"],
359
- contextSignals: ["has_package_json", "has_tests"],
360
- priority: 80,
361
- pluginId: "test-generator",
362
- autoExecute: false
363
- },
364
- // Documentation Intent
365
- {
366
- id: "intent:generate-docs",
367
- name: { "en": "Generate Documentation", "zh-CN": "\u751F\u6210\u6587\u6863" },
368
- patterns: [
369
- "\u5199.*\u6587\u6863",
370
- "\u751F\u6210.*\u6587\u6863",
371
- "write.*doc",
372
- "generate.*doc",
373
- "\u6DFB\u52A0.*\u6CE8\u91CA",
374
- "add.*comment"
375
- ],
376
- keywords: ["doc", "\u6587\u6863", "readme", "comment", "\u6CE8\u91CA"],
377
- contextSignals: ["in_src_directory"],
378
- priority: 75,
379
- pluginId: "doc-generator",
380
- autoExecute: false
381
- },
382
- // Deploy Intent
383
- {
384
- id: "intent:deploy",
385
- name: { "en": "Deploy", "zh-CN": "\u90E8\u7F72" },
386
- patterns: [
387
- "\u90E8\u7F72.*\u9879\u76EE",
388
- "\u90E8\u7F72.*\u5E94\u7528",
389
- "deploy.*project",
390
- "deploy.*app",
391
- "\u53D1\u5E03.*\u7EBF\u4E0A"
392
- ],
393
- keywords: ["deploy", "\u90E8\u7F72", "publish", "\u53D1\u5E03", "release"],
394
- contextSignals: ["has_package_json", "git_has_remote"],
395
- priority: 70,
396
- pluginId: "vercel-deploy",
397
- autoExecute: false
398
- },
399
- // Docker Intent
400
- {
401
- id: "intent:docker",
402
- name: { "en": "Docker Operations", "zh-CN": "Docker \u64CD\u4F5C" },
403
- patterns: [
404
- "\u521B\u5EFA.*dockerfile",
405
- "\u751F\u6210.*docker",
406
- "create.*dockerfile",
407
- "generate.*docker",
408
- "\u5BB9\u5668\u5316"
409
- ],
410
- keywords: ["docker", "container", "\u5BB9\u5668", "dockerfile"],
411
- contextSignals: ["has_package_json"],
412
- filePatterns: ["Dockerfile", "docker-compose.yml"],
413
- priority: 65,
414
- pluginId: "docker-helper",
415
- autoExecute: false
416
- },
417
- // Refactor Intent
418
- {
419
- id: "intent:refactor",
420
- name: { "en": "Refactor Code", "zh-CN": "\u91CD\u6784\u4EE3\u7801" },
421
- patterns: [
422
- "\u91CD\u6784.*\u4EE3\u7801",
423
- "\u4F18\u5316.*\u4EE3\u7801",
424
- "refactor.*code",
425
- "optimize.*code",
426
- "\u7B80\u5316.*\u4EE3\u7801",
427
- "simplify.*code"
428
- ],
429
- keywords: ["refactor", "\u91CD\u6784", "optimize", "\u4F18\u5316", "simplify", "\u7B80\u5316"],
430
- contextSignals: ["in_src_directory"],
431
- priority: 60,
432
- pluginId: "code-simplifier",
433
- autoExecute: false
434
- }
435
- ];
436
- let engineInstance = null;
437
- function getIntentEngine() {
438
- if (!engineInstance) {
439
- engineInstance = new IntentEngine();
440
- engineInstance.registerRules(DEFAULT_INTENT_RULES);
441
- }
442
- return engineInstance;
443
- }
444
-
445
- const DEFAULT_TIMEOUT = 3e4;
446
- const MAX_TIMEOUT = 3e5;
447
- const MAX_OUTPUT_SIZE = 1024 * 1024;
448
- const SCRIPT_INTERPRETERS = {
449
- bash: ["bash", "-e"],
450
- node: ["node"],
451
- python: ["python3", "-u"],
452
- deno: ["deno", "run", "--allow-all"],
453
- bun: ["bun", "run"]
454
- };
455
- const SCRIPT_EXTENSIONS = {
456
- bash: [".sh", ".bash"],
457
- node: [".js", ".mjs", ".cjs"],
458
- python: [".py"],
459
- deno: [".ts", ".js"],
460
- bun: [".ts", ".js"]
461
- };
462
- class ScriptRunner {
463
- grantedPermissions = /* @__PURE__ */ new Set();
464
- runningProcesses = /* @__PURE__ */ new Map();
465
- constructor() {
466
- this.grantedPermissions.add("file:read");
467
- this.grantedPermissions.add("git:read");
468
- this.grantedPermissions.add("env:read");
469
- }
470
- // ==========================================================================
471
- // Permission Management
472
- // ==========================================================================
473
- /**
474
- * Grant a permission
475
- */
476
- grantPermission(permission) {
477
- this.grantedPermissions.add(permission);
478
- }
479
- /**
480
- * Grant multiple permissions
481
- */
482
- grantPermissions(permissions) {
483
- for (const p of permissions) {
484
- this.grantedPermissions.add(p);
485
- }
486
- }
487
- /**
488
- * Revoke a permission
489
- */
490
- revokePermission(permission) {
491
- this.grantedPermissions.delete(permission);
492
- }
493
- /**
494
- * Check if permission is granted
495
- */
496
- hasPermission(permission) {
497
- return this.grantedPermissions.has(permission);
498
- }
499
- /**
500
- * Check if all required permissions are granted
501
- */
502
- hasAllPermissions(permissions) {
503
- return permissions.every((p) => this.grantedPermissions.has(p));
504
- }
505
- /**
506
- * Get missing permissions
507
- */
508
- getMissingPermissions(required) {
509
- return required.filter((p) => !this.grantedPermissions.has(p));
510
- }
511
- // ==========================================================================
512
- // Script Execution
513
- // ==========================================================================
514
- /**
515
- * Execute a script
516
- *
517
- * @param script - Script definition
518
- * @param pluginPath - Path to the plugin directory
519
- * @param options - Execution options
520
- * @returns Script execution result
521
- */
522
- async execute(script, pluginPath, options = {}) {
523
- const startTime = Date.now();
524
- const missingPermissions = this.getMissingPermissions(script.permissions);
525
- if (missingPermissions.length > 0) {
526
- return {
527
- success: false,
528
- exitCode: -1,
529
- stdout: "",
530
- stderr: `Permission denied. Missing permissions: ${missingPermissions.join(", ")}`,
531
- duration: 0
532
- };
533
- }
534
- const scriptPath = join(pluginPath, script.path);
535
- if (!existsSync(scriptPath)) {
536
- return {
537
- success: false,
538
- exitCode: -1,
539
- stdout: "",
540
- stderr: `Script not found: ${scriptPath}`,
541
- duration: 0
542
- };
543
- }
544
- const interpreter = this.getInterpreter(script.type);
545
- if (!interpreter) {
546
- return {
547
- success: false,
548
- exitCode: -1,
549
- stdout: "",
550
- stderr: `Unsupported script type: ${script.type}`,
551
- duration: 0
552
- };
553
- }
554
- const args = [...interpreter.slice(1), scriptPath, ...options.args ?? script.defaultArgs ?? []];
555
- const command = interpreter[0];
556
- const env = this.buildEnvironment(script, options);
557
- const cwd = options.cwd ?? dirname(scriptPath);
558
- const timeout = Math.min(options.timeout ?? script.timeout ?? DEFAULT_TIMEOUT, MAX_TIMEOUT);
559
- try {
560
- const result = await this.spawn(command, args, {
561
- cwd,
562
- env,
563
- timeout,
564
- stdin: options.stdin,
565
- captureOutput: options.captureOutput ?? true,
566
- background: options.background,
567
- scriptId: `${script.name}-${Date.now()}`
568
- });
569
- return {
570
- ...result,
571
- duration: Date.now() - startTime
572
- };
573
- } catch (error) {
574
- return {
575
- success: false,
576
- exitCode: -1,
577
- stdout: "",
578
- stderr: error instanceof Error ? error.message : String(error),
579
- duration: Date.now() - startTime
580
- };
581
- }
582
- }
583
- /**
584
- * Execute a script from raw content
585
- */
586
- async executeRaw(content, type, options = {}) {
587
- const startTime = Date.now();
588
- if (!this.hasPermission("shell:execute")) {
589
- return {
590
- success: false,
591
- exitCode: -1,
592
- stdout: "",
593
- stderr: "Permission denied. shell:execute permission required for raw script execution.",
594
- duration: 0
595
- };
596
- }
597
- const interpreter = this.getInterpreter(type);
598
- if (!interpreter) {
599
- return {
600
- success: false,
601
- exitCode: -1,
602
- stdout: "",
603
- stderr: `Unsupported script type: ${type}`,
604
- duration: 0
605
- };
606
- }
607
- if (type === "bash") {
608
- const args = ["-c", content, ...options.args ?? []];
609
- const timeout = Math.min(options.timeout ?? DEFAULT_TIMEOUT, MAX_TIMEOUT);
610
- try {
611
- const result = await this.spawn("bash", args, {
612
- cwd: options.cwd,
613
- env: {
614
- ...Object.fromEntries(
615
- Object.entries(process.env).filter(([, v]) => v !== void 0)
616
- ),
617
- ...options.env
618
- },
619
- timeout,
620
- stdin: options.stdin,
621
- captureOutput: options.captureOutput ?? true
622
- });
623
- return {
624
- ...result,
625
- duration: Date.now() - startTime
626
- };
627
- } catch (error) {
628
- return {
629
- success: false,
630
- exitCode: -1,
631
- stdout: "",
632
- stderr: error instanceof Error ? error.message : String(error),
633
- duration: Date.now() - startTime
634
- };
635
- }
636
- }
637
- const tempPath = join(tmpdir(), `ccjk-script-${Date.now()}${SCRIPT_EXTENSIONS[type][0]}`);
638
- const { writeFileSync, unlinkSync } = await import('node:fs');
639
- try {
640
- writeFileSync(tempPath, content, "utf-8");
641
- const args = [...interpreter.slice(1), tempPath, ...options.args ?? []];
642
- const timeout = Math.min(options.timeout ?? DEFAULT_TIMEOUT, MAX_TIMEOUT);
643
- const result = await this.spawn(interpreter[0], args, {
644
- cwd: options.cwd,
645
- env: {
646
- ...Object.fromEntries(
647
- Object.entries(process.env).filter(([, v]) => v !== void 0)
648
- ),
649
- ...options.env
650
- },
651
- timeout,
652
- stdin: options.stdin,
653
- captureOutput: options.captureOutput ?? true
654
- });
655
- return {
656
- ...result,
657
- duration: Date.now() - startTime
658
- };
659
- } catch (error) {
660
- return {
661
- success: false,
662
- exitCode: -1,
663
- stdout: "",
664
- stderr: error instanceof Error ? error.message : String(error),
665
- duration: Date.now() - startTime
666
- };
667
- } finally {
668
- try {
669
- unlinkSync(tempPath);
670
- } catch {
671
- }
672
- }
673
- }
674
- /**
675
- * Execute inline bash command
676
- */
677
- async bash(command, options = {}) {
678
- return this.executeRaw(command, "bash", options);
679
- }
680
- // ==========================================================================
681
- // Process Management
682
- // ==========================================================================
683
- /**
684
- * Kill a running script
685
- */
686
- kill(scriptId) {
687
- const process2 = this.runningProcesses.get(scriptId);
688
- if (process2) {
689
- process2.kill();
690
- this.runningProcesses.delete(scriptId);
691
- return true;
692
- }
693
- return false;
694
- }
695
- /**
696
- * Kill all running scripts
697
- */
698
- killAll() {
699
- for (const [id, process2] of Array.from(this.runningProcesses.entries())) {
700
- process2.kill();
701
- this.runningProcesses.delete(id);
702
- }
703
- }
704
- /**
705
- * Get running script IDs
706
- */
707
- getRunningScripts() {
708
- return Array.from(this.runningProcesses.keys());
709
- }
710
- // ==========================================================================
711
- // Private Helpers
712
- // ==========================================================================
713
- /**
714
- * Get interpreter for script type
715
- */
716
- getInterpreter(type) {
717
- return SCRIPT_INTERPRETERS[type] ?? null;
718
- }
719
- /**
720
- * Build environment variables
721
- */
722
- buildEnvironment(script, options) {
723
- const env = {};
724
- if (this.hasPermission("env:read")) {
725
- const safeVars = ["PATH", "HOME", "USER", "SHELL", "LANG", "LC_ALL", "TERM", "NODE_ENV"];
726
- for (const key of safeVars) {
727
- if (process.env[key]) {
728
- env[key] = process.env[key];
729
- }
730
- }
731
- }
732
- if (script.env) {
733
- Object.assign(env, script.env);
734
- }
735
- if (options.env) {
736
- Object.assign(env, options.env);
737
- }
738
- env.CCJK_PLUGIN = "true";
739
- env.CCJK_VERSION = "2.0";
740
- return env;
741
- }
742
- /**
743
- * Spawn a process
744
- */
745
- spawn(command, args, options) {
746
- return new Promise((resolve, reject) => {
747
- let stdout = "";
748
- let stderr = "";
749
- let killed = false;
750
- const proc = spawn(command, args, {
751
- cwd: options.cwd,
752
- env: options.env,
753
- stdio: options.captureOutput ? ["pipe", "pipe", "pipe"] : "inherit",
754
- shell: false
755
- });
756
- if (options.scriptId) {
757
- this.runningProcesses.set(options.scriptId, {
758
- pid: proc.pid,
759
- kill: () => {
760
- killed = true;
761
- proc.kill("SIGTERM");
762
- }
763
- });
764
- }
765
- let timeoutId;
766
- if (options.timeout) {
767
- timeoutId = setTimeout(() => {
768
- killed = true;
769
- proc.kill("SIGTERM");
770
- setTimeout(() => {
771
- if (!proc.killed) {
772
- proc.kill("SIGKILL");
773
- }
774
- }, 1e3);
775
- }, options.timeout);
776
- }
777
- if (options.stdin && proc.stdin) {
778
- proc.stdin.write(options.stdin);
779
- proc.stdin.end();
780
- }
781
- if (options.captureOutput) {
782
- proc.stdout?.on("data", (data) => {
783
- const chunk = data.toString();
784
- if (stdout.length + chunk.length <= MAX_OUTPUT_SIZE) {
785
- stdout += chunk;
786
- }
787
- });
788
- proc.stderr?.on("data", (data) => {
789
- const chunk = data.toString();
790
- if (stderr.length + chunk.length <= MAX_OUTPUT_SIZE) {
791
- stderr += chunk;
792
- }
793
- });
794
- }
795
- proc.on("close", (code) => {
796
- if (timeoutId) {
797
- clearTimeout(timeoutId);
798
- }
799
- if (options.scriptId) {
800
- this.runningProcesses.delete(options.scriptId);
801
- }
802
- if (killed && code !== 0) {
803
- resolve({
804
- success: false,
805
- exitCode: code ?? -1,
806
- stdout,
807
- stderr: stderr || "Script was killed (timeout or manual)"
808
- });
809
- } else {
810
- resolve({
811
- success: code === 0,
812
- exitCode: code ?? 0,
813
- stdout,
814
- stderr
815
- });
816
- }
817
- });
818
- proc.on("error", (error) => {
819
- if (timeoutId) {
820
- clearTimeout(timeoutId);
821
- }
822
- if (options.scriptId) {
823
- this.runningProcesses.delete(options.scriptId);
824
- }
825
- reject(error);
826
- });
827
- if (options.background) {
828
- resolve({
829
- success: true,
830
- exitCode: 0,
831
- stdout: `Background process started with PID: ${proc.pid}`,
832
- stderr: ""
833
- });
834
- }
835
- });
836
- }
837
- }
838
- let runnerInstance = null;
839
- function getScriptRunner() {
840
- if (!runnerInstance) {
841
- runnerInstance = new ScriptRunner();
842
- }
843
- return runnerInstance;
844
- }
845
-
846
- const PLUGINS_DIR = CCJK_PLUGINS_DIR;
847
- const SKILLS_DIR = CCJK_SKILLS_DIR;
848
- const AGENTS_DIR = CLAUDE_AGENTS_DIR;
849
- const CONFIG_FILE = join(CCJK_CONFIG_DIR, "plugins.json");
850
- class PluginManager {
851
- plugins = /* @__PURE__ */ new Map();
852
- agents = /* @__PURE__ */ new Map();
853
- eventHandlers = /* @__PURE__ */ new Set();
854
- initialized = false;
855
- constructor() {
856
- this.ensureDirectories();
857
- }
858
- // ==========================================================================
859
- // Initialization
860
- // ==========================================================================
861
- /**
862
- * Initialize the plugin manager
863
- */
864
- async initialize() {
865
- if (this.initialized)
866
- return;
867
- await this.loadInstalledPlugins();
868
- await this.loadInstalledAgents();
869
- this.registerAllIntents();
870
- this.initialized = true;
871
- }
872
- /**
873
- * Ensure required directories exist
874
- */
875
- ensureDirectories() {
876
- for (const dir of [PLUGINS_DIR, SKILLS_DIR, AGENTS_DIR]) {
877
- if (!existsSync(dir)) {
878
- mkdirSync(dir, { recursive: true });
879
- }
880
- }
881
- }
882
- // ==========================================================================
883
- // Plugin Installation
884
- // ==========================================================================
885
- /**
886
- * Install a plugin from various sources
887
- *
888
- * @param source - Plugin source (cloud, github, local, npm)
889
- * @param options - Installation options
890
- */
891
- async install(source, options = {}) {
892
- const resolvedSource = typeof source === "string" ? this.resolveSource(source) : source;
893
- try {
894
- let result;
895
- switch (resolvedSource.type) {
896
- case "cloud":
897
- result = await this.installFromCloud(resolvedSource.url, options);
898
- break;
899
- case "github":
900
- result = await this.installFromGitHub(resolvedSource.repo, resolvedSource.ref, options);
901
- break;
902
- case "local":
903
- result = await this.installFromLocal(resolvedSource.path, options);
904
- break;
905
- case "npm":
906
- result = await this.installFromNpm(resolvedSource.package, options);
907
- break;
908
- default:
909
- return { success: false, pluginId: "", error: "Unknown source type" };
910
- }
911
- if (result.success) {
912
- this.emit({ type: "plugin:installed", pluginId: result.pluginId, version: result.version });
913
- }
914
- return result;
915
- } catch (error) {
916
- return {
917
- success: false,
918
- pluginId: "",
919
- error: error instanceof Error ? error.message : String(error)
920
- };
921
- }
922
- }
923
- /**
924
- * Install from GitHub (supports Vercel Agent Skills format)
925
- */
926
- async installFromGitHub(repo, ref, options = {}) {
927
- const parts = repo.split("/");
928
- if (parts.length < 2) {
929
- return { success: false, pluginId: "", error: "Invalid GitHub repo format" };
930
- }
931
- const owner = parts[0];
932
- const repoName = parts[1];
933
- const subPath = parts.slice(2).join("/");
934
- const targetDir = join(SKILLS_DIR, `${owner}-${repoName}${subPath ? `-${subPath.replace(/\//g, "-")}` : ""}`);
935
- if (existsSync(targetDir)) {
936
- if (options.force) {
937
- rmSync(targetDir, { recursive: true });
938
- } else {
939
- return { success: false, pluginId: "", error: "Plugin already installed. Use --force to reinstall." };
940
- }
941
- }
942
- try {
943
- const cloneUrl = `https://github.com/${owner}/${repoName}.git`;
944
- await K("git", ["clone", "--depth", "1", ...ref ? ["--branch", ref] : [], cloneUrl, targetDir]);
945
- if (subPath) {
946
- const subDir = join(targetDir, subPath);
947
- if (!existsSync(subDir)) {
948
- rmSync(targetDir, { recursive: true });
949
- return { success: false, pluginId: "", error: `Path ${subPath} not found in repo` };
950
- }
951
- const tempDir = `${targetDir}-temp`;
952
- await K("mv", [subDir, tempDir]);
953
- rmSync(targetDir, { recursive: true });
954
- await K("mv", [tempDir, targetDir]);
955
- }
956
- const plugin = await this.loadPluginFromDirectory(targetDir);
957
- if (!plugin) {
958
- rmSync(targetDir, { recursive: true });
959
- return { success: false, pluginId: "", error: "Invalid plugin format" };
960
- }
961
- this.plugins.set(plugin.manifest.id, plugin);
962
- this.registerPluginIntents(plugin);
963
- this.saveConfig();
964
- return {
965
- success: true,
966
- pluginId: plugin.manifest.id,
967
- version: plugin.manifest.version,
968
- path: targetDir
969
- };
970
- } catch (error) {
971
- if (existsSync(targetDir)) {
972
- rmSync(targetDir, { recursive: true });
973
- }
974
- return {
975
- success: false,
976
- pluginId: "",
977
- error: error instanceof Error ? error.message : String(error)
978
- };
979
- }
980
- }
981
- /**
982
- * Install from local directory
983
- */
984
- async installFromLocal(path, options = {}) {
985
- if (!existsSync(path)) {
986
- return { success: false, pluginId: "", error: `Path not found: ${path}` };
987
- }
988
- const plugin = await this.loadPluginFromDirectory(path);
989
- if (!plugin) {
990
- return { success: false, pluginId: "", error: "Invalid plugin format" };
991
- }
992
- const targetDir = join(PLUGINS_DIR, plugin.manifest.id);
993
- if (existsSync(targetDir) && !options.force) {
994
- return { success: false, pluginId: "", error: "Plugin already installed. Use --force to reinstall." };
995
- }
996
- await K("cp", ["-r", path, targetDir]);
997
- this.plugins.set(plugin.manifest.id, { ...plugin, source: { type: "local", path: targetDir } });
998
- this.registerPluginIntents(plugin);
999
- this.saveConfig();
1000
- return {
1001
- success: true,
1002
- pluginId: plugin.manifest.id,
1003
- version: plugin.manifest.version,
1004
- path: targetDir
1005
- };
1006
- }
1007
- /**
1008
- * Install from cloud registry
1009
- */
1010
- async installFromCloud(url, _options = {}) {
1011
- return { success: false, pluginId: "", error: "Cloud installation not yet implemented in v2" };
1012
- }
1013
- /**
1014
- * Install from NPM
1015
- */
1016
- async installFromNpm(packageName, _options = {}) {
1017
- const targetDir = join(PLUGINS_DIR, packageName.replace(/\//g, "-"));
1018
- try {
1019
- await K("npm", ["pack", packageName, "--pack-destination", targetDir]);
1020
- return { success: false, pluginId: "", error: "NPM installation not yet fully implemented" };
1021
- } catch (error) {
1022
- return {
1023
- success: false,
1024
- pluginId: "",
1025
- error: error instanceof Error ? error.message : String(error)
1026
- };
1027
- }
1028
- }
1029
- /**
1030
- * Resolve source string to PluginSource
1031
- */
1032
- resolveSource(source) {
1033
- if (source.startsWith("github:") || source.match(/^[\w-]+\/[\w-]+/)) {
1034
- const repo = source.replace("github:", "");
1035
- return { type: "github", repo };
1036
- }
1037
- if (source.startsWith("npm:") || source.startsWith("@")) {
1038
- const pkg = source.replace("npm:", "");
1039
- return { type: "npm", package: pkg };
1040
- }
1041
- if (source.startsWith("/") || source.startsWith("./") || source.startsWith("~")) {
1042
- const path = source.startsWith("~") ? source.replace("~", homedir()) : source;
1043
- return { type: "local", path };
1044
- }
1045
- return { type: "cloud", url: source };
1046
- }
1047
- // ==========================================================================
1048
- // Plugin Loading
1049
- // ==========================================================================
1050
- /**
1051
- * Load plugin from directory
1052
- */
1053
- async loadPluginFromDirectory(dirPath) {
1054
- const parser = getSkillParser();
1055
- const manifestPath = join(dirPath, "plugin.json");
1056
- const skillPath = join(dirPath, "SKILL.md");
1057
- let manifest;
1058
- if (existsSync(manifestPath)) {
1059
- manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
1060
- } else if (existsSync(skillPath)) {
1061
- const skill2 = parser.parse(skillPath);
1062
- manifest = this.generateManifestFromSkill(skill2, dirPath);
1063
- } else {
1064
- return null;
1065
- }
1066
- const skill = existsSync(skillPath) ? await Promise.resolve(parser.parse(skillPath)) : void 0;
1067
- const scripts = this.loadScripts(dirPath);
1068
- const intents = this.loadIntents(dirPath, manifest.id);
1069
- return {
1070
- manifest,
1071
- skill,
1072
- scripts,
1073
- intents,
1074
- source: { type: "local", path: dirPath }
1075
- };
1076
- }
1077
- /**
1078
- * Generate manifest from SKILL.md
1079
- */
1080
- generateManifestFromSkill(skill, dirPath) {
1081
- const dirName = dirPath.split("/").pop() || "unknown";
1082
- return {
1083
- id: dirName,
1084
- name: { "en": skill.title, "zh-CN": skill.title },
1085
- description: { "en": skill.description, "zh-CN": skill.description },
1086
- version: "1.0.0",
1087
- author: { name: "Unknown" },
1088
- category: "other",
1089
- tags: [],
1090
- permissions: ["file:read"],
1091
- formatVersion: "2.0"
1092
- };
1093
- }
1094
- /**
1095
- * Load scripts from directory
1096
- */
1097
- loadScripts(dirPath) {
1098
- const scripts = [];
1099
- const scriptsDir = join(dirPath, "scripts");
1100
- if (!existsSync(scriptsDir))
1101
- return scripts;
1102
- const entries = readdirSync(scriptsDir, { withFileTypes: true });
1103
- for (const entry of entries) {
1104
- if (entry.isFile()) {
1105
- const ext = entry.name.substring(entry.name.lastIndexOf("."));
1106
- let type = null;
1107
- if ([".sh", ".bash"].includes(ext))
1108
- type = "bash";
1109
- else if ([".js", ".mjs"].includes(ext))
1110
- type = "node";
1111
- else if (ext === ".py")
1112
- type = "python";
1113
- if (type) {
1114
- scripts.push({
1115
- name: entry.name.replace(/\.[^.]+$/, ""),
1116
- path: `scripts/${entry.name}`,
1117
- type,
1118
- permissions: ["shell:execute"]
1119
- });
1120
- }
1121
- }
1122
- }
1123
- return scripts;
1124
- }
1125
- /**
1126
- * Load intents from directory
1127
- */
1128
- loadIntents(dirPath, _pluginId) {
1129
- const intentsPath = join(dirPath, "intents", "intents.yaml");
1130
- if (!existsSync(intentsPath))
1131
- return void 0;
1132
- return void 0;
1133
- }
1134
- /**
1135
- * Load all installed plugins
1136
- */
1137
- async loadInstalledPlugins() {
1138
- if (existsSync(PLUGINS_DIR)) {
1139
- const entries = readdirSync(PLUGINS_DIR, { withFileTypes: true });
1140
- for (const entry of entries) {
1141
- if (entry.isDirectory()) {
1142
- const plugin = await this.loadPluginFromDirectory(join(PLUGINS_DIR, entry.name));
1143
- if (plugin) {
1144
- this.plugins.set(plugin.manifest.id, plugin);
1145
- }
1146
- }
1147
- }
1148
- }
1149
- if (existsSync(SKILLS_DIR)) {
1150
- const entries = readdirSync(SKILLS_DIR, { withFileTypes: true });
1151
- for (const entry of entries) {
1152
- if (entry.isDirectory()) {
1153
- const plugin = await this.loadPluginFromDirectory(join(SKILLS_DIR, entry.name));
1154
- if (plugin) {
1155
- this.plugins.set(plugin.manifest.id, plugin);
1156
- }
1157
- }
1158
- }
1159
- }
1160
- }
1161
- // ==========================================================================
1162
- // Intent Management
1163
- // ==========================================================================
1164
- /**
1165
- * Register intents from all plugins
1166
- */
1167
- registerAllIntents() {
1168
- const engine = getIntentEngine();
1169
- for (const plugin of Array.from(this.plugins.values())) {
1170
- if (plugin.intents) {
1171
- engine.registerRules(plugin.intents);
1172
- }
1173
- }
1174
- }
1175
- /**
1176
- * Register intents from a single plugin
1177
- */
1178
- registerPluginIntents(plugin) {
1179
- if (plugin.intents) {
1180
- const engine = getIntentEngine();
1181
- engine.registerRules(plugin.intents);
1182
- }
1183
- }
1184
- /**
1185
- * Detect intent and get matching plugins
1186
- */
1187
- async detectIntent(userInput, cwd) {
1188
- const engine = getIntentEngine();
1189
- return engine.detect(userInput, cwd);
1190
- }
1191
- /**
1192
- * Execute based on detected intent
1193
- */
1194
- async executeIntent(match, cwd) {
1195
- const plugin = this.plugins.get(match.pluginId);
1196
- if (!plugin) {
1197
- throw new Error(`Plugin not found: ${match.pluginId}`);
1198
- }
1199
- this.emit({ type: "plugin:activated", pluginId: match.pluginId, trigger: "intent" });
1200
- if (plugin.scripts && plugin.scripts.length > 0) {
1201
- const mainScript = plugin.scripts.find((s) => s.name === "main") || plugin.scripts[0];
1202
- const runner = getScriptRunner();
1203
- const pluginPath = plugin.source.type === "local" ? plugin.source.path : "";
1204
- const result = await runner.execute(mainScript, pluginPath, { cwd });
1205
- this.emit({ type: "intent:executed", match, result });
1206
- return result;
1207
- }
1208
- if (plugin.skill) {
1209
- this.emit({ type: "intent:executed", match, result: plugin.skill });
1210
- return plugin.skill;
1211
- }
1212
- return null;
1213
- }
1214
- // ==========================================================================
1215
- // Agent Management
1216
- // ==========================================================================
1217
- /**
1218
- * Create an agent from skills and MCP servers
1219
- *
1220
- * Writes agent to project-local `.claude-code/agents/` in Markdown format
1221
- * for Claude Code compatibility.
1222
- */
1223
- async createAgent(definition, options) {
1224
- for (const skillRef of definition.skills) {
1225
- if (!this.plugins.has(skillRef.pluginId)) {
1226
- throw new Error(`Skill not found: ${skillRef.pluginId}`);
1227
- }
1228
- }
1229
- await writeAgentFile(definition, {
1230
- format: "markdown",
1231
- projectDir: options?.projectDir,
1232
- global: options?.global || false
1233
- });
1234
- this.agents.set(definition.id, definition);
1235
- this.emit({ type: "agent:created", agentId: definition.id });
1236
- }
1237
- /**
1238
- * Get an agent by ID
1239
- */
1240
- getAgent(agentId) {
1241
- return this.agents.get(agentId);
1242
- }
1243
- /**
1244
- * List all agents
1245
- */
1246
- listAgents() {
1247
- return Array.from(this.agents.values());
1248
- }
1249
- /**
1250
- * Load installed agents from both project-local and global directories
1251
- *
1252
- * Supports:
1253
- * - Project-local `.claude-code/agents/*.md` (Claude Code format)
1254
- * - Global `~/.claude/agents/*.md` (Claude Code compatible)
1255
- */
1256
- async loadInstalledAgents() {
1257
- const projectAgentsDir = getAgentsDir();
1258
- if (existsSync(projectAgentsDir)) {
1259
- const entries = readdirSync(projectAgentsDir, { withFileTypes: true });
1260
- for (const entry of entries) {
1261
- if (entry.isFile() && entry.name.endsWith(".md")) {
1262
- try {
1263
- const content = readFileSync(join(projectAgentsDir, entry.name), "utf-8");
1264
- const agent = this.parseMarkdownAgent(content, entry.name);
1265
- if (agent) {
1266
- this.agents.set(agent.id, agent);
1267
- }
1268
- } catch {
1269
- }
1270
- }
1271
- }
1272
- }
1273
- if (existsSync(AGENTS_DIR)) {
1274
- const entries = readdirSync(AGENTS_DIR, { withFileTypes: true });
1275
- for (const entry of entries) {
1276
- if (entry.isFile() && entry.name.endsWith(".json")) {
1277
- try {
1278
- const content = readFileSync(join(AGENTS_DIR, entry.name), "utf-8");
1279
- const agent = JSON.parse(content);
1280
- if (!this.agents.has(agent.id)) {
1281
- this.agents.set(agent.id, agent);
1282
- }
1283
- } catch {
1284
- }
1285
- }
1286
- }
1287
- }
1288
- }
1289
- /**
1290
- * Parse a Markdown agent file to AgentDefinition
1291
- */
1292
- parseMarkdownAgent(content, filename) {
1293
- const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
1294
- if (!frontmatterMatch)
1295
- return null;
1296
- const frontmatter = frontmatterMatch[1];
1297
- const lines = frontmatter.split("\n");
1298
- let id = filename.replace(/\.md$/, "");
1299
- let name = id;
1300
- let description = "";
1301
- const tools = [];
1302
- for (const line of lines) {
1303
- const colonIndex = line.indexOf(":");
1304
- if (colonIndex === -1)
1305
- continue;
1306
- const key = line.slice(0, colonIndex).trim();
1307
- const value = line.slice(colonIndex + 1).trim();
1308
- if (key === "name") {
1309
- id = value;
1310
- name = value;
1311
- } else if (key === "description") {
1312
- description = value;
1313
- } else if (key === "tools") {
1314
- tools.push(...value.split(",").map((t) => t.trim()).filter(Boolean));
1315
- }
1316
- }
1317
- const bodyMatch = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);
1318
- const persona = bodyMatch ? bodyMatch[1].trim() : "";
1319
- return {
1320
- id,
1321
- name: { "en": name, "zh-CN": name },
1322
- description: { "en": description, "zh-CN": description },
1323
- persona,
1324
- instructions: persona,
1325
- // Use persona as instructions
1326
- skills: [],
1327
- mcpServers: [],
1328
- capabilities: []
1329
- };
1330
- }
1331
- // ==========================================================================
1332
- // Plugin Management
1333
- // ==========================================================================
1334
- /**
1335
- * Uninstall a plugin
1336
- */
1337
- async uninstall(pluginId) {
1338
- const plugin = this.plugins.get(pluginId);
1339
- if (!plugin)
1340
- return false;
1341
- if (plugin.source.type === "local") {
1342
- rmSync(plugin.source.path, { recursive: true });
1343
- }
1344
- const engine = getIntentEngine();
1345
- engine.unregisterPluginRules(pluginId);
1346
- this.plugins.delete(pluginId);
1347
- this.saveConfig();
1348
- this.emit({ type: "plugin:uninstalled", pluginId });
1349
- return true;
1350
- }
1351
- /**
1352
- * Get a plugin by ID
1353
- */
1354
- getPlugin(pluginId) {
1355
- return this.plugins.get(pluginId);
1356
- }
1357
- /**
1358
- * List all installed plugins
1359
- */
1360
- listPlugins() {
1361
- return Array.from(this.plugins.values());
1362
- }
1363
- /**
1364
- * Check for updates
1365
- */
1366
- async checkUpdates() {
1367
- return [];
1368
- }
1369
- // ==========================================================================
1370
- // Script Execution
1371
- // ==========================================================================
1372
- /**
1373
- * Execute a plugin script
1374
- */
1375
- async executeScript(pluginId, scriptName, options = {}) {
1376
- const plugin = this.plugins.get(pluginId);
1377
- if (!plugin) {
1378
- throw new Error(`Plugin not found: ${pluginId}`);
1379
- }
1380
- const script = plugin.scripts?.find((s) => s.name === scriptName);
1381
- if (!script) {
1382
- throw new Error(`Script not found: ${scriptName}`);
1383
- }
1384
- const runner = getScriptRunner();
1385
- const pluginPath = plugin.source.type === "local" ? plugin.source.path : "";
1386
- this.emit({ type: "script:started", pluginId, scriptName });
1387
- const result = await runner.execute(script, pluginPath, options);
1388
- this.emit({ type: "script:completed", pluginId, scriptName, result });
1389
- return result;
1390
- }
1391
- /**
1392
- * Grant permission to script runner
1393
- */
1394
- grantPermission(permission) {
1395
- const runner = getScriptRunner();
1396
- runner.grantPermission(permission);
1397
- }
1398
- // ==========================================================================
1399
- // Event System
1400
- // ==========================================================================
1401
- /**
1402
- * Subscribe to plugin events
1403
- */
1404
- on(handler) {
1405
- this.eventHandlers.add(handler);
1406
- return () => this.eventHandlers.delete(handler);
1407
- }
1408
- /**
1409
- * Emit an event
1410
- */
1411
- emit(event) {
1412
- for (const handler of Array.from(this.eventHandlers)) {
1413
- try {
1414
- handler(event);
1415
- } catch (error) {
1416
- console.error("Event handler error:", error);
1417
- }
1418
- }
1419
- }
1420
- // ==========================================================================
1421
- // Configuration
1422
- // ==========================================================================
1423
- /**
1424
- * Save configuration
1425
- */
1426
- saveConfig() {
1427
- const config = {
1428
- plugins: Array.from(this.plugins.entries()).map(([id, p]) => ({
1429
- id,
1430
- source: p.source,
1431
- version: p.manifest.version
1432
- })),
1433
- agents: Array.from(this.agents.keys())
1434
- };
1435
- writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
1436
- }
1437
- }
1438
- let managerInstance = null;
1439
- async function getPluginManager() {
1440
- if (!managerInstance) {
1441
- managerInstance = new PluginManager();
1442
- await managerInstance.initialize();
1443
- }
1444
- return managerInstance;
1445
- }
1446
-
1447
- export { getPluginManager as g };