ccjk 14.2.2 → 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 (528) 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 -1454
  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 -236
  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 -234
  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.5bEolFrk.mjs +0 -254
  309. package/dist/shared/ccjk.8oaxX4iR.mjs +0 -90
  310. package/dist/shared/ccjk.B2U7DsPy.mjs +0 -31
  311. package/dist/shared/ccjk.B2f-cwUP.mjs +0 -468
  312. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  313. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  314. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  315. package/dist/shared/ccjk.BLsIiTqO.mjs +0 -449
  316. package/dist/shared/ccjk.BXv8aYs1.mjs +0 -170
  317. package/dist/shared/ccjk.BnsY5WxD.mjs +0 -171
  318. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  319. package/dist/shared/ccjk.Bq8TqZG_.mjs +0 -189
  320. package/dist/shared/ccjk.BtrioX1Z.mjs +0 -25
  321. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  322. package/dist/shared/ccjk.BzPbSEP2.mjs +0 -115
  323. package/dist/shared/ccjk.C0WLUnFV.mjs +0 -293
  324. package/dist/shared/ccjk.C1hANZTu.mjs +0 -19
  325. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  326. package/dist/shared/ccjk.CNhnT6uQ.mjs +0 -636
  327. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  328. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  329. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  330. package/dist/shared/ccjk.CoCHVXl3.mjs +0 -3951
  331. package/dist/shared/ccjk.CwGZSTAK.mjs +0 -319
  332. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  333. package/dist/shared/ccjk.D-magaEx.mjs +0 -763
  334. package/dist/shared/ccjk.D0g2ABGg.mjs +0 -171
  335. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  336. package/dist/shared/ccjk.D75wivnp.mjs +0 -142
  337. package/dist/shared/ccjk.DDL-4C-k.mjs +0 -100
  338. package/dist/shared/ccjk.DFRPtmK_.mjs +0 -75
  339. package/dist/shared/ccjk.DMV3x5Sd.mjs +0 -299
  340. package/dist/shared/ccjk.DZ2LLOa-.mjs +0 -2195
  341. package/dist/shared/ccjk.DbigonEQ.mjs +0 -698
  342. package/dist/shared/ccjk.DcMvE7lf.mjs +0 -618
  343. package/dist/shared/ccjk.DeWpAShp.mjs +0 -1828
  344. package/dist/shared/ccjk.DhJ1kyDR.mjs +0 -30
  345. package/dist/shared/ccjk.DlTXS9rP.mjs +0 -224
  346. package/dist/shared/ccjk.DopKzo3z.mjs +0 -305
  347. package/dist/shared/ccjk.DsZsc4LR.mjs +0 -1280
  348. package/dist/shared/ccjk.DuzJZlgj.mjs +0 -418
  349. package/dist/shared/ccjk.Dxgd2vjc.mjs +0 -444
  350. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  351. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  352. package/dist/shared/ccjk.L7yC58_i.mjs +0 -225
  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/codex-rigor-mode.md +0 -114
  378. package/dist/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  379. package/dist/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  380. package/dist/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  381. package/dist/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  382. package/dist/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  383. package/dist/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  384. package/dist/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  385. package/dist/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  386. package/dist/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  387. package/dist/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  388. package/dist/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  389. package/dist/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  390. package/dist/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  391. package/dist/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  392. package/dist/templates/common/workflow/essential/en/feat.md +0 -92
  393. package/dist/templates/common/workflow/essential/en/goal.md +0 -147
  394. package/dist/templates/common/workflow/essential/en/init-project.md +0 -53
  395. package/dist/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  396. package/dist/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  397. package/dist/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  398. package/dist/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  399. package/dist/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  400. package/dist/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  401. package/dist/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  402. package/dist/templates/common/workflow/git/en/git-commit.md +0 -205
  403. package/dist/templates/common/workflow/git/en/git-rollback.md +0 -90
  404. package/dist/templates/common/workflow/git/en/git-worktree.md +0 -276
  405. package/dist/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  406. package/dist/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  407. package/dist/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  408. package/dist/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  409. package/dist/templates/common/workflow/interview/en/interview.md +0 -67
  410. package/dist/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  411. package/dist/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  412. package/dist/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  413. package/dist/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  414. package/dist/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  415. package/dist/templates/common/workflow/sixStep/en/workflow.md +0 -83
  416. package/dist/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  417. package/dist/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  418. package/dist/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  419. package/dist/templates/hooks/README.md +0 -212
  420. package/dist/templates/hooks/git-workflow-hooks.md +0 -551
  421. package/dist/templates/hooks/post-test/coverage.json +0 -21
  422. package/dist/templates/hooks/post-test/summary.json +0 -21
  423. package/dist/templates/hooks/post-test-coverage.md +0 -434
  424. package/dist/templates/hooks/pre-commit/eslint.json +0 -22
  425. package/dist/templates/hooks/pre-commit/prettier.json +0 -22
  426. package/dist/templates/hooks/pre-commit-black.md +0 -274
  427. package/dist/templates/hooks/pre-commit-eslint.md +0 -153
  428. package/dist/templates/hooks/pre-commit-gofmt.md +0 -284
  429. package/dist/templates/hooks/pre-commit-prettier.md +0 -212
  430. package/dist/templates/hooks/pre-commit-type-check.md +0 -377
  431. package/dist/templates/skills/ccjk-init.md +0 -154
  432. package/dist/templates/skills/ccjk-mcp-setup.md +0 -205
  433. package/dist/templates/skills/ccjk-troubleshoot.md +0 -228
  434. package/dist/templates/skills/django-patterns.md +0 -1016
  435. package/dist/templates/skills/git-workflow.md +0 -748
  436. package/dist/templates/skills/go-idioms.md +0 -963
  437. package/dist/templates/skills/index.json +0 -132
  438. package/dist/templates/skills/nextjs-optimization.md +0 -694
  439. package/dist/templates/skills/python-pep8.md +0 -852
  440. package/dist/templates/skills/react-patterns.md +0 -686
  441. package/dist/templates/skills/rust-patterns.md +0 -1057
  442. package/dist/templates/skills/security-best-practices.md +0 -1413
  443. package/dist/templates/skills/testing-best-practices.md +0 -1315
  444. package/dist/templates/skills/ts-best-practices.md +0 -354
  445. package/templates/agents/README.md +0 -78
  446. package/templates/agents/fullstack-developer.json +0 -70
  447. package/templates/agents/go-expert.json +0 -69
  448. package/templates/agents/index.json +0 -64
  449. package/templates/agents/python-expert.json +0 -69
  450. package/templates/agents/react-specialist.json +0 -69
  451. package/templates/agents/testing-automation-expert.json +0 -70
  452. package/templates/agents/typescript-architect.json +0 -69
  453. package/templates/claude-code/common/settings.json +0 -109
  454. package/templates/common/error-prevention.md +0 -267
  455. package/templates/common/karpathy-baseline.md +0 -83
  456. package/templates/common/output-styles/zh-CN/carmack-mode.md +0 -381
  457. package/templates/common/output-styles/zh-CN/codex-rigor-mode.md +0 -114
  458. package/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  459. package/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  460. package/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  461. package/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  462. package/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  463. package/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  464. package/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  465. package/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  466. package/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  467. package/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  468. package/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  469. package/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  470. package/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  471. package/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  472. package/templates/common/workflow/essential/en/feat.md +0 -92
  473. package/templates/common/workflow/essential/en/goal.md +0 -147
  474. package/templates/common/workflow/essential/en/init-project.md +0 -53
  475. package/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  476. package/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  477. package/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  478. package/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  479. package/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  480. package/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  481. package/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  482. package/templates/common/workflow/git/en/git-commit.md +0 -205
  483. package/templates/common/workflow/git/en/git-rollback.md +0 -90
  484. package/templates/common/workflow/git/en/git-worktree.md +0 -276
  485. package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  486. package/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  487. package/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  488. package/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  489. package/templates/common/workflow/interview/en/interview.md +0 -67
  490. package/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  491. package/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  492. package/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  493. package/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  494. package/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  495. package/templates/common/workflow/sixStep/en/workflow.md +0 -83
  496. package/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  497. package/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  498. package/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  499. package/templates/hooks/README.md +0 -212
  500. package/templates/hooks/git-workflow-hooks.md +0 -551
  501. package/templates/hooks/post-test/coverage.json +0 -21
  502. package/templates/hooks/post-test/summary.json +0 -21
  503. package/templates/hooks/post-test-coverage.md +0 -434
  504. package/templates/hooks/pre-commit/eslint.json +0 -22
  505. package/templates/hooks/pre-commit/prettier.json +0 -22
  506. package/templates/hooks/pre-commit-black.md +0 -274
  507. package/templates/hooks/pre-commit-eslint.md +0 -153
  508. package/templates/hooks/pre-commit-gofmt.md +0 -284
  509. package/templates/hooks/pre-commit-prettier.md +0 -212
  510. package/templates/hooks/pre-commit-type-check.md +0 -377
  511. package/templates/skills/basic.hbs +0 -72
  512. package/templates/skills/ccjk-init.md +0 -154
  513. package/templates/skills/ccjk-mcp-setup.md +0 -205
  514. package/templates/skills/ccjk-troubleshoot.md +0 -228
  515. package/templates/skills/code-refactor.hbs +0 -133
  516. package/templates/skills/code-review.hbs +0 -141
  517. package/templates/skills/django-patterns.md +0 -1016
  518. package/templates/skills/git-workflow.md +0 -748
  519. package/templates/skills/go-idioms.md +0 -963
  520. package/templates/skills/index.json +0 -132
  521. package/templates/skills/nextjs-optimization.md +0 -694
  522. package/templates/skills/python-pep8.md +0 -852
  523. package/templates/skills/react-patterns.md +0 -686
  524. package/templates/skills/rust-patterns.md +0 -1057
  525. package/templates/skills/security-best-practices.md +0 -1413
  526. package/templates/skills/testing-best-practices.md +0 -1315
  527. package/templates/skills/ts-best-practices.md +0 -354
  528. package/templates/skills/type-fix.hbs +0 -132
@@ -1,1280 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { j as join } from './ccjk.bQ7Dh1g4.mjs';
4
-
5
- class WildcardPatternMatcher {
6
- patternCache = /* @__PURE__ */ new Map();
7
- maxCacheSize;
8
- cacheHits = 0;
9
- cacheMisses = 0;
10
- constructor(maxCacheSize = 1e3) {
11
- this.maxCacheSize = maxCacheSize;
12
- }
13
- /**
14
- * Compile a pattern to a regex and cache it
15
- */
16
- compilePattern(pattern) {
17
- const cached = this.patternCache.get(pattern);
18
- if (cached) {
19
- this.cacheHits++;
20
- return cached;
21
- }
22
- this.cacheMisses++;
23
- const compiled = this.analyzeAndCompile(pattern);
24
- if (this.patternCache.size >= this.maxCacheSize) {
25
- const firstKey = this.patternCache.keys().next().value;
26
- if (firstKey) {
27
- this.patternCache.delete(firstKey);
28
- }
29
- }
30
- this.patternCache.set(pattern, compiled);
31
- return compiled;
32
- }
33
- /**
34
- * Test if a target matches a pattern
35
- */
36
- match(pattern, target) {
37
- const compiled = this.compilePattern(pattern);
38
- return compiled.regex.test(target);
39
- }
40
- /**
41
- * Test if a target matches any of the given patterns
42
- */
43
- matchAny(patterns, target) {
44
- for (const pattern of patterns) {
45
- if (this.match(pattern, target)) {
46
- return { matched: true, pattern };
47
- }
48
- }
49
- return { matched: false };
50
- }
51
- /**
52
- * Get all patterns that match a target
53
- */
54
- getAllMatches(patterns, target) {
55
- return patterns.filter((pattern) => this.match(pattern, target));
56
- }
57
- /**
58
- * Clear the pattern cache
59
- */
60
- clearCache() {
61
- this.patternCache.clear();
62
- this.cacheHits = 0;
63
- this.cacheMisses = 0;
64
- }
65
- /**
66
- * Get cache statistics
67
- */
68
- getCacheStats() {
69
- const total = this.cacheHits + this.cacheMisses;
70
- return {
71
- size: this.patternCache.size,
72
- hits: this.cacheHits,
73
- misses: this.cacheMisses,
74
- hitRate: total > 0 ? this.cacheHits / total : 0
75
- };
76
- }
77
- /**
78
- * Analyze pattern type and compile to regex
79
- */
80
- analyzeAndCompile(pattern) {
81
- const wildcardPositions = [];
82
- let specificity = 0;
83
- for (let i = 0; i < pattern.length; i++) {
84
- if (pattern[i] === "*" || pattern[i] === "?") {
85
- wildcardPositions.push(i);
86
- }
87
- }
88
- let type;
89
- const hasWildcards = wildcardPositions.length > 0;
90
- const hasDoubleWildcard = pattern.includes("**");
91
- if (!hasWildcards) {
92
- type = "exact" /* Exact */;
93
- specificity = 100;
94
- } else if (pattern.startsWith("mcp__") && pattern.includes("__*")) {
95
- type = "mcp" /* Mcp */;
96
- specificity = this.calculateMcpSpecificity(pattern);
97
- } else if (pattern.startsWith("Bash(") && pattern.includes(" ")) {
98
- type = "bash" /* Bash */;
99
- specificity = this.calculateBashSpecificity(pattern);
100
- } else if (hasDoubleWildcard) {
101
- type = "nested" /* Nested */;
102
- specificity = this.calculateNestedSpecificity(pattern, wildcardPositions);
103
- } else if (wildcardPositions.length === 1 && pattern.endsWith("*")) {
104
- type = "prefix" /* Prefix */;
105
- specificity = this.calculatePrefixSpecificity(pattern);
106
- } else if (wildcardPositions.length === 1 && pattern.startsWith("*")) {
107
- type = "suffix" /* Suffix */;
108
- specificity = this.calculateSuffixSpecificity(pattern);
109
- } else if (wildcardPositions.length > 1) {
110
- type = "complex" /* Complex */;
111
- specificity = this.calculateComplexSpecificity(pattern, wildcardPositions);
112
- } else {
113
- type = "middle" /* Middle */;
114
- specificity = this.calculateMiddleSpecificity(pattern, wildcardPositions[0]);
115
- }
116
- const regex = this.patternToRegex(pattern, type);
117
- const hash = this.generateHash(pattern);
118
- return {
119
- original: pattern,
120
- regex,
121
- type,
122
- wildcardPositions,
123
- specificity,
124
- hash
125
- };
126
- }
127
- /**
128
- * Convert pattern to regex based on type
129
- */
130
- patternToRegex(pattern, type) {
131
- let regexStr;
132
- switch (type) {
133
- case "mcp" /* Mcp */: {
134
- regexStr = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/__/g, "_{2}").replace(/\*/g, "[^_]*");
135
- break;
136
- }
137
- case "bash" /* Bash */: {
138
- regexStr = `^${this.escapeRegex(pattern).replace(/\*/g, ".*").replace(/\s+/g, "\\s+")}$`;
139
- break;
140
- }
141
- case "nested" /* Nested */: {
142
- regexStr = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
143
- if (pattern.endsWith("**")) {
144
- regexStr = `${pattern.slice(0, -2).replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*")}.*`;
145
- } else {
146
- regexStr = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*");
147
- }
148
- break;
149
- }
150
- default: {
151
- regexStr = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
152
- break;
153
- }
154
- }
155
- return new RegExp(`^${regexStr}$`, "i");
156
- }
157
- /**
158
- * Calculate specificity for MCP patterns
159
- */
160
- calculateMcpSpecificity(pattern) {
161
- const parts = pattern.split("__").length;
162
- if (pattern.endsWith("*")) {
163
- return 30 + parts * 10;
164
- }
165
- return 40 + parts * 15;
166
- }
167
- /**
168
- * Calculate specificity for Bash patterns
169
- */
170
- calculateBashSpecificity(pattern) {
171
- const match = pattern.match(/^Bash\((.*)\)$/);
172
- if (!match)
173
- return 20;
174
- const inner = match[1];
175
- if (!inner.includes("*")) {
176
- return 90;
177
- }
178
- const segments = inner.split(" ");
179
- let specificity = 30;
180
- for (const seg of segments) {
181
- if (seg && seg !== "*") {
182
- specificity += 15;
183
- } else if (seg === "*") {
184
- specificity += 5;
185
- }
186
- }
187
- return specificity;
188
- }
189
- /**
190
- * Calculate specificity for prefix patterns
191
- */
192
- calculatePrefixSpecificity(pattern) {
193
- const baseLen = pattern.length - 1;
194
- return Math.min(50 + baseLen, 80);
195
- }
196
- /**
197
- * Calculate specificity for suffix patterns
198
- */
199
- calculateSuffixSpecificity(_pattern) {
200
- return 45;
201
- }
202
- /**
203
- * Calculate specificity for middle wildcards
204
- */
205
- calculateMiddleSpecificity(pattern, pos) {
206
- const beforeLen = pos;
207
- const afterLen = pattern.length - pos - 1;
208
- return 40 + beforeLen + afterLen;
209
- }
210
- /**
211
- * Calculate specificity for complex patterns
212
- */
213
- calculateComplexSpecificity(pattern, positions) {
214
- const nonWildcard = pattern.length - positions.length;
215
- return 30 + nonWildcard * 2;
216
- }
217
- /**
218
- * Calculate specificity for nested path patterns
219
- */
220
- calculateNestedSpecificity(pattern, _positions) {
221
- let score = 25;
222
- const segments = pattern.split("/").filter((s) => s && s !== "**");
223
- score += segments.length * 10;
224
- for (const seg of segments) {
225
- if (seg !== "**" && !seg.includes("*")) {
226
- score += 10;
227
- }
228
- }
229
- return Math.min(score, 95);
230
- }
231
- /**
232
- * Escape special regex characters
233
- */
234
- escapeRegex(str) {
235
- return str.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
236
- }
237
- /**
238
- * Generate a simple hash for the pattern
239
- */
240
- generateHash(pattern) {
241
- let hash = 0;
242
- for (let i = 0; i < pattern.length; i++) {
243
- const char = pattern.charCodeAt(i);
244
- hash = (hash << 5) - hash + char;
245
- hash = hash & hash;
246
- }
247
- return Math.abs(hash).toString(36);
248
- }
249
- /**
250
- * Validate if a pattern string is well-formed
251
- */
252
- validatePattern(pattern) {
253
- if (!pattern || pattern.trim().length === 0) {
254
- return { valid: false, error: "Pattern cannot be empty" };
255
- }
256
- let parenDepth = 0;
257
- for (const char of pattern) {
258
- if (char === "(")
259
- parenDepth++;
260
- if (char === ")")
261
- parenDepth--;
262
- if (parenDepth < 0) {
263
- return { valid: false, error: "Unbalanced parentheses" };
264
- }
265
- }
266
- if (parenDepth !== 0) {
267
- return { valid: false, error: "Unbalanced parentheses" };
268
- }
269
- if (pattern.includes("***")) {
270
- return { valid: false, error: "Invalid wildcard sequence (***" };
271
- }
272
- if (pattern.startsWith("Bash(")) {
273
- if (!pattern.endsWith(")")) {
274
- return { valid: false, error: "Bash pattern must end with )" };
275
- }
276
- const inner = pattern.slice(5, -1);
277
- if (inner.length === 0) {
278
- return { valid: false, error: "Bash pattern cannot be empty" };
279
- }
280
- }
281
- if (pattern.startsWith("mcp__") && pattern.includes("__*")) {
282
- const parts = pattern.split("__");
283
- if (parts.length < 3) {
284
- return { valid: false, error: "MCP pattern must have at least 3 parts" };
285
- }
286
- }
287
- return { valid: true };
288
- }
289
- /**
290
- * Get pattern type as a human-readable string
291
- */
292
- getPatternType(pattern) {
293
- const compiled = this.compilePattern(pattern);
294
- return compiled.type;
295
- }
296
- }
297
- class WildcardPermissionRules {
298
- matcher;
299
- rules = [];
300
- config;
301
- beforeHooks = [];
302
- afterHooks = [];
303
- constructor(config = {}) {
304
- this.matcher = new WildcardPatternMatcher(config.maxCacheSize);
305
- this.config = {
306
- allowUnsandboxedCommands: false,
307
- disallowedTools: [],
308
- maxCacheSize: 1e3,
309
- enableDiagnostics: false,
310
- ...config
311
- };
312
- if (config.beforeCheck) {
313
- this.beforeHooks.push(config.beforeCheck);
314
- }
315
- if (config.afterCheck) {
316
- this.afterHooks.push(config.afterCheck);
317
- }
318
- }
319
- /**
320
- * Add a permission rule
321
- */
322
- addRule(rule) {
323
- const validation = this.matcher.validatePattern(rule.pattern);
324
- if (!validation.valid) {
325
- throw new Error(`Invalid pattern: ${validation.error}`);
326
- }
327
- const existingIndex = this.rules.findIndex(
328
- (r) => r.pattern === rule.pattern && r.type === rule.type
329
- );
330
- const newRule = {
331
- ...rule,
332
- createdAt: rule.createdAt ?? Date.now(),
333
- modifiedAt: Date.now(),
334
- enabled: rule.enabled ?? true,
335
- priority: rule.priority ?? this.calculateDefaultPriority(rule)
336
- };
337
- if (existingIndex >= 0) {
338
- this.rules[existingIndex] = {
339
- ...this.rules[existingIndex],
340
- ...newRule,
341
- createdAt: this.rules[existingIndex].createdAt
342
- };
343
- } else {
344
- this.rules.push(newRule);
345
- this.sortRulesByPriority();
346
- }
347
- }
348
- /**
349
- * Remove a permission rule
350
- */
351
- removeRule(pattern, type) {
352
- const initialLength = this.rules.length;
353
- this.rules = this.rules.filter((rule) => {
354
- if (type && rule.type !== type) {
355
- return true;
356
- }
357
- return rule.pattern !== pattern;
358
- });
359
- return this.rules.length < initialLength;
360
- }
361
- /**
362
- * Check if a target is allowed
363
- */
364
- async checkPermission(target, context = {}) {
365
- const fullContext = {
366
- action: "check",
367
- target,
368
- timestamp: Date.now(),
369
- ...context
370
- };
371
- for (const hook of this.beforeHooks) {
372
- await hook(fullContext, { allowed: false, reason: "Checking..." });
373
- }
374
- let result;
375
- if (this.config.disallowedTools?.some((tool) => target.includes(tool))) {
376
- result = {
377
- allowed: false,
378
- reason: `Tool is in disallowed list: ${this.config.disallowedTools.join(", ")}`
379
- };
380
- } else {
381
- const denyRule = this.findMatchingRule(target, "deny");
382
- if (denyRule && denyRule.enabled !== false) {
383
- result = {
384
- allowed: false,
385
- matchedRule: denyRule,
386
- matchedPattern: denyRule.pattern,
387
- reason: `Denied by rule: ${denyRule.pattern}`,
388
- source: denyRule.source
389
- };
390
- } else {
391
- const allowRule = this.findMatchingRule(target, "allow");
392
- if (allowRule && allowRule.enabled !== false) {
393
- result = {
394
- allowed: true,
395
- matchedRule: allowRule,
396
- matchedPattern: allowRule.pattern,
397
- reason: `Allowed by rule: ${allowRule.pattern}`,
398
- source: allowRule.source
399
- };
400
- } else {
401
- result = {
402
- allowed: false,
403
- reason: "No matching allow rule found (default deny)"
404
- };
405
- }
406
- }
407
- }
408
- for (const hook of this.afterHooks) {
409
- await hook(fullContext, result);
410
- }
411
- return result;
412
- }
413
- /**
414
- * Find the highest priority matching rule for a target
415
- */
416
- findMatchingRule(target, type) {
417
- const matchingRules = this.rules.filter(
418
- (rule) => rule.type === type && rule.enabled !== false && this.matcher.match(rule.pattern, target)
419
- );
420
- if (matchingRules.length === 0) {
421
- return void 0;
422
- }
423
- if (matchingRules.length === 1) {
424
- return matchingRules[0];
425
- }
426
- return matchingRules.reduce((best, current) => {
427
- const bestCompiled = this.matcher.compilePattern(best.pattern);
428
- const currentCompiled = this.matcher.compilePattern(current.pattern);
429
- if (currentCompiled.specificity > bestCompiled.specificity) {
430
- return current;
431
- }
432
- return best;
433
- });
434
- }
435
- /**
436
- * Get all rules
437
- */
438
- getAllRules() {
439
- return [...this.rules];
440
- }
441
- /**
442
- * Get rules by type
443
- */
444
- getRulesByType(type) {
445
- return this.rules.filter((rule) => rule.type === type);
446
- }
447
- /**
448
- * Get rules by category
449
- */
450
- getRulesByCategory(category) {
451
- return this.rules.filter((rule) => rule.category === category);
452
- }
453
- /**
454
- * Clear all rules
455
- */
456
- clearRules() {
457
- this.rules = [];
458
- }
459
- /**
460
- * Test a pattern against sample targets
461
- */
462
- testPattern(pattern, targets) {
463
- const validation = this.matcher.validatePattern(pattern);
464
- if (!validation.valid) {
465
- return {
466
- pattern,
467
- matched: [],
468
- notMatched: [],
469
- errors: [validation.error],
470
- valid: false
471
- };
472
- }
473
- const matched = [];
474
- const notMatched = [];
475
- const errors = [];
476
- for (const target of targets) {
477
- try {
478
- if (this.matcher.match(pattern, target)) {
479
- matched.push(target);
480
- } else {
481
- notMatched.push(target);
482
- }
483
- } catch (error) {
484
- errors.push(error instanceof Error ? error.message : String(error));
485
- }
486
- }
487
- return {
488
- pattern,
489
- matched,
490
- notMatched,
491
- errors,
492
- valid: errors.length === 0
493
- };
494
- }
495
- /**
496
- * Get diagnostics for a specific rule
497
- */
498
- getDiagnostics(rulePattern) {
499
- const rule = this.rules.find((r) => r.pattern === rulePattern);
500
- if (!rule) {
501
- return null;
502
- }
503
- const shadowedBy = [];
504
- const shadows = [];
505
- const conflicts = [];
506
- const suggestions = [];
507
- const ruleCompiled = this.matcher.compilePattern(rule.pattern);
508
- for (const other of this.rules) {
509
- if (other === rule)
510
- continue;
511
- const otherCompiled = this.matcher.compilePattern(other.pattern);
512
- if (other.type === rule.type) {
513
- if (otherCompiled.specificity < ruleCompiled.specificity) {
514
- if (this.matcher.match(other.pattern, rule.pattern)) {
515
- shadowedBy.push(other);
516
- }
517
- }
518
- }
519
- if (other.pattern === rule.pattern && other.type !== rule.type) {
520
- conflicts.push({
521
- rule: other,
522
- conflict: `Conflicting rule type: ${other.type} vs ${rule.type}`
523
- });
524
- }
525
- }
526
- if (shadowedBy.length > 0) {
527
- suggestions.push(`Rule is shadowed by ${shadowedBy.length} other rule(s) with higher priority`);
528
- suggestions.push("Consider increasing the priority of this rule");
529
- suggestions.push("Or remove/reduce the specificity of shadowing rules");
530
- for (const shadow of shadowedBy) {
531
- if (shadow.pattern === "*") {
532
- suggestions.push(`Remove or narrow the catch-all rule: ${shadow.pattern}`);
533
- }
534
- }
535
- }
536
- let reachable = true;
537
- const testTargets = this.generateTestTargets(rule.category, rule.pattern);
538
- const testResult = this.testPattern(rule.pattern, testTargets);
539
- if (testResult.matched.length === 0 && testResult.notMatched.length === testTargets.length) {
540
- reachable = false;
541
- suggestions.push("Pattern does not match any common targets");
542
- suggestions.push("Verify the pattern syntax and expected resource format");
543
- }
544
- return {
545
- rule,
546
- reachable,
547
- shadowedBy,
548
- shadows,
549
- suggestions,
550
- conflicts
551
- };
552
- }
553
- /**
554
- * Get diagnostics for all rules
555
- */
556
- getAllDiagnostics() {
557
- return this.rules.map((rule) => this.getDiagnostics(rule.pattern)).filter((d) => d !== null);
558
- }
559
- /**
560
- * Get unreachable rules
561
- */
562
- getUnreachableRules() {
563
- return this.getAllDiagnostics().filter((d) => !d.reachable).map((d) => d.rule);
564
- }
565
- /**
566
- * Sort rules by priority (highest first)
567
- */
568
- sortRulesByPriority() {
569
- this.rules.sort((a, b) => {
570
- const priorityA = a.priority ?? this.calculateDefaultPriority(a);
571
- const priorityB = b.priority ?? this.calculateDefaultPriority(b);
572
- if (priorityA !== priorityB) {
573
- return priorityB - priorityA;
574
- }
575
- const specificityA = this.matcher.compilePattern(a.pattern).specificity;
576
- const specificityB = this.matcher.compilePattern(b.pattern).specificity;
577
- return specificityB - specificityA;
578
- });
579
- }
580
- /**
581
- * Calculate default priority for a rule
582
- */
583
- calculateDefaultPriority(rule) {
584
- const compiled = this.matcher.compilePattern(rule.pattern);
585
- return compiled.specificity;
586
- }
587
- /**
588
- * Check if pattern1 is more general than pattern2
589
- */
590
- isMoreGeneralPattern(pattern1, pattern2) {
591
- const compiled1 = this.matcher.compilePattern(pattern1);
592
- const compiled2 = this.matcher.compilePattern(pattern2);
593
- return compiled1.specificity < compiled2.specificity;
594
- }
595
- /**
596
- * Generate test targets for a category
597
- */
598
- generateTestTargets(category, pattern) {
599
- const commonTargets = {
600
- bash: [
601
- "Bash(*)",
602
- "Bash(npm install)",
603
- "Bash(npm test)",
604
- "Bash(git status)",
605
- "Bash(ls -la)",
606
- "Bash(cat file.txt)",
607
- "Bash(python -m pytest tests)"
608
- ],
609
- mcp: [
610
- "MCP(*)",
611
- "mcp__server__tool1",
612
- "mcp__server__tool2",
613
- "mcp__context7__query-docs",
614
- "mcp__mcp-deepwiki__deepwiki_fetch",
615
- "mcp__other__func"
616
- ],
617
- filesystem: [
618
- "Read(*)",
619
- "Edit(*)",
620
- "Write(*)",
621
- "NotebookEdit(*)",
622
- "Read(/path/to/file.txt)",
623
- "Edit(CLAUDE.md)",
624
- "Write(/home/user/file.txt)",
625
- "/path/to/file.txt",
626
- "/home/user/.bashrc",
627
- "/etc/config"
628
- ],
629
- network: ["https://api.example.com", "https://github.com/*", "wss://socket.server"],
630
- tool: ["Read", "Write", "Edit", "Bash", "WebSearch", "WebFetch(*)", "Task", "TodoWrite"],
631
- command: ["init", "update", "doctor", "permissions", "Task", "TodoWrite"],
632
- workflow: ["sixStep", "featPlan", "bmad"],
633
- provider: ["302ai", "glm", "minimax", "kimi"],
634
- model: ["claude-opus", "claude-sonnet", "gpt-4"]
635
- };
636
- return [...new Set([pattern, ...commonTargets[category] || []].filter((item) => Boolean(item)))];
637
- }
638
- /**
639
- * Add a before-check hook
640
- */
641
- addBeforeHook(hook) {
642
- this.beforeHooks.push(hook);
643
- }
644
- /**
645
- * Add an after-check hook
646
- */
647
- addAfterHook(hook) {
648
- this.afterHooks.push(hook);
649
- }
650
- /**
651
- * Get cache statistics
652
- */
653
- getCacheStats() {
654
- return this.matcher.getCacheStats();
655
- }
656
- /**
657
- * Clear the pattern cache
658
- */
659
- clearCache() {
660
- this.matcher.clearCache();
661
- }
662
- /**
663
- * Import rules from configuration
664
- */
665
- importFromConfig(config, defaultSource = "config") {
666
- if (config.allow) {
667
- for (const pattern of config.allow) {
668
- try {
669
- this.addRule({
670
- type: "allow",
671
- pattern,
672
- category: this.inferCategory(pattern),
673
- source: defaultSource
674
- });
675
- } catch {
676
- }
677
- }
678
- }
679
- if (config.deny) {
680
- for (const pattern of config.deny) {
681
- try {
682
- this.addRule({
683
- type: "deny",
684
- pattern,
685
- category: this.inferCategory(pattern),
686
- source: defaultSource
687
- });
688
- } catch {
689
- }
690
- }
691
- }
692
- }
693
- /**
694
- * Export rules to configuration format
695
- */
696
- exportToConfig() {
697
- return {
698
- allow: this.rules.filter((r) => r.type === "allow").map((r) => r.pattern),
699
- deny: this.rules.filter((r) => r.type === "deny").map((r) => r.pattern)
700
- };
701
- }
702
- /**
703
- * Validate a pattern string (public wrapper)
704
- */
705
- validatePattern(pattern) {
706
- return this.matcher.validatePattern(pattern);
707
- }
708
- /**
709
- * Get pattern type (public wrapper)
710
- */
711
- getPatternType(pattern) {
712
- return this.matcher.getPatternType(pattern);
713
- }
714
- /**
715
- * Infer category from pattern
716
- */
717
- inferCategory(pattern) {
718
- if (pattern.startsWith("Bash(")) {
719
- return "bash";
720
- }
721
- if (pattern.startsWith("mcp__") || pattern.startsWith("MCP(")) {
722
- return "mcp";
723
- }
724
- if (/^(Read|Write|Edit|NotebookEdit)\(/.test(pattern)) {
725
- return "filesystem";
726
- }
727
- if (/^(WebSearch|WebFetch)\(/.test(pattern)) {
728
- return "network";
729
- }
730
- if (["Read", "Write", "Edit", "Bash", "WebSearch", "WebFetch", "Task", "TodoWrite"].includes(pattern)) {
731
- return "tool";
732
- }
733
- if (pattern.startsWith("http://") || pattern.startsWith("https://") || pattern.startsWith("ws://") || pattern.startsWith("wss://")) {
734
- return "network";
735
- }
736
- if (pattern.startsWith("/")) {
737
- return "filesystem";
738
- }
739
- return "command";
740
- }
741
- /**
742
- * Match a pattern against a target string
743
- */
744
- match(pattern, target) {
745
- return this.matcher.match(pattern, target);
746
- }
747
- /**
748
- * Get statistics about the rules
749
- */
750
- getStats() {
751
- const byCategory = {};
752
- const bySource = {};
753
- for (const rule of this.rules) {
754
- byCategory[rule.category] = (byCategory[rule.category] || 0) + 1;
755
- bySource[rule.source] = (bySource[rule.source] || 0) + 1;
756
- }
757
- return {
758
- total: this.rules.length,
759
- allow: this.rules.filter((r) => r.type === "allow").length,
760
- deny: this.rules.filter((r) => r.type === "deny").length,
761
- enabled: this.rules.filter((r) => r.enabled !== false).length,
762
- disabled: this.rules.filter((r) => r.enabled === false).length,
763
- byCategory,
764
- bySource
765
- };
766
- }
767
- }
768
- let singletonInstance = null;
769
- function getWildcardPermissionRules(config) {
770
- if (!singletonInstance) {
771
- singletonInstance = new WildcardPermissionRules(config);
772
- }
773
- return singletonInstance;
774
- }
775
- const SAMPLE_PATTERNS = {
776
- // Bash command patterns
777
- bash: [
778
- "Bash(npm *)",
779
- "Bash(npm install)",
780
- "Bash(npm test)",
781
- "Bash(git *)",
782
- "Bash(git status)",
783
- "Bash(* install)"
784
- // Any * install command
785
- ],
786
- // MCP tool patterns
787
- mcp: [
788
- "mcp__server__*",
789
- "mcp__filesystem__*",
790
- "mcp__github__*",
791
- "mcp__*__*"
792
- // Any MCP tool
793
- ],
794
- // Filesystem patterns
795
- filesystem: [
796
- "/home/user/*",
797
- "/home/user/**/*.txt",
798
- "*.md",
799
- "/tmp/*"
800
- ],
801
- // Network patterns
802
- network: [
803
- "https://api.example.com/*",
804
- "https://github.com/*",
805
- "wss://socket.example.com"
806
- ]
807
- };
808
-
809
- class PermissionManager {
810
- wildcardRules;
811
- configPath;
812
- settingsPath;
813
- legacyMode = false;
814
- constructor(configPath, settingsPath) {
815
- this.configPath = configPath || join(homedir(), ".ccjk", "permissions.json");
816
- this.settingsPath = settingsPath || join(homedir(), ".claude", "settings.json");
817
- const config = {
818
- maxCacheSize: 1e3,
819
- enableDiagnostics: true
820
- };
821
- this.wildcardRules = new WildcardPermissionRules(config);
822
- this.loadPermissions();
823
- }
824
- /**
825
- * Load permissions from config files
826
- * Loads from both legacy config and Claude Code settings.json
827
- */
828
- loadPermissions() {
829
- this.loadFromSettingsJson();
830
- this.loadFromLegacyConfig();
831
- this.loadFromClaudePermissions();
832
- }
833
- /**
834
- * Load permissions from Claude Code settings.json
835
- */
836
- loadFromSettingsJson() {
837
- try {
838
- if (!existsSync(this.settingsPath)) {
839
- return;
840
- }
841
- const content = readFileSync(this.settingsPath, "utf-8");
842
- const settings = JSON.parse(content);
843
- if (settings.experimental?.allowUnsandboxedCommands) {
844
- this.wildcardRules = getWildcardPermissionRules({
845
- allowUnsandboxedCommands: true
846
- });
847
- }
848
- if (settings.experimental?.disallowedTools) {
849
- this.wildcardRules = getWildcardPermissionRules({
850
- disallowedTools: settings.experimental.disallowedTools
851
- });
852
- }
853
- if (settings.chat?.alwaysApprove) {
854
- for (const pattern of settings.chat.alwaysApprove) {
855
- try {
856
- this.wildcardRules.addRule({
857
- type: "allow",
858
- pattern,
859
- category: this.inferCategory(pattern),
860
- source: "settings",
861
- description: "From chat.alwaysApprove"
862
- });
863
- } catch {
864
- }
865
- }
866
- }
867
- } catch {
868
- }
869
- }
870
- /**
871
- * Load from legacy CCJK config
872
- */
873
- loadFromLegacyConfig() {
874
- try {
875
- if (!existsSync(this.configPath)) {
876
- return;
877
- }
878
- const content = readFileSync(this.configPath, "utf-8");
879
- const config = JSON.parse(content);
880
- if (config.allow || config.deny) {
881
- this.wildcardRules.importFromConfig(config, "config");
882
- this.legacyMode = true;
883
- }
884
- } catch {
885
- }
886
- }
887
- /**
888
- * Load from Claude Code 2.0.70+ permissions format
889
- */
890
- loadFromClaudePermissions() {
891
- try {
892
- if (!existsSync(this.settingsPath)) {
893
- return;
894
- }
895
- const content = readFileSync(this.settingsPath, "utf-8");
896
- const settings = JSON.parse(content);
897
- if (settings.permissions) {
898
- this.wildcardRules.importFromConfig(settings.permissions, "settings");
899
- }
900
- } catch {
901
- }
902
- }
903
- /**
904
- * Save permissions to config files
905
- */
906
- savePermissions() {
907
- try {
908
- this.saveToSettingsJson();
909
- if (this.legacyMode) {
910
- this.saveToLegacyConfig();
911
- }
912
- } catch (error) {
913
- throw new Error(`Failed to save permissions: ${error instanceof Error ? error.message : String(error)}`);
914
- }
915
- }
916
- /**
917
- * Save to Claude Code settings.json
918
- */
919
- saveToSettingsJson() {
920
- try {
921
- let settings = {};
922
- if (existsSync(this.settingsPath)) {
923
- const content = readFileSync(this.settingsPath, "utf-8");
924
- settings = JSON.parse(content);
925
- }
926
- const exported = this.wildcardRules.exportToConfig();
927
- settings.permissions = {
928
- allow: exported.allow,
929
- deny: exported.deny
930
- };
931
- writeFileSync(this.settingsPath, JSON.stringify(settings, null, 2), "utf-8");
932
- } catch (error) {
933
- throw new Error(`Failed to save to settings.json: ${error instanceof Error ? error.message : String(error)}`);
934
- }
935
- }
936
- /**
937
- * Save to legacy CCJK config
938
- */
939
- saveToLegacyConfig() {
940
- try {
941
- const exported = this.wildcardRules.exportToConfig();
942
- writeFileSync(this.configPath, JSON.stringify(exported, null, 2), "utf-8");
943
- } catch (error) {
944
- throw new Error(`Failed to save to legacy config: ${error instanceof Error ? error.message : String(error)}`);
945
- }
946
- }
947
- /**
948
- * Check if an action on a resource is permitted
949
- * @param action - The action to check (e.g., "read", "write", "execute")
950
- * @param resource - The resource identifier (e.g., "Bash(npm install)", "mcp__server__tool")
951
- * @returns Permission check result
952
- */
953
- async checkPermission(action, resource) {
954
- const context = {
955
- action,
956
- target: resource,
957
- timestamp: Date.now()
958
- };
959
- return await this.wildcardRules.checkPermission(resource, context);
960
- }
961
- /**
962
- * Legacy checkPermission method for backward compatibility
963
- */
964
- checkPermissionSync(action, resource) {
965
- const result = {
966
- allowed: false,
967
- reason: "Use async checkPermission for full wildcard support"
968
- };
969
- const target = `${resource}:${action}`;
970
- const denyRule = this.wildcardRules.findMatchingRule(target, "deny");
971
- if (denyRule) {
972
- return {
973
- allowed: false,
974
- matchedRule: denyRule,
975
- matchedPattern: denyRule.pattern,
976
- reason: `Denied by rule: ${denyRule.pattern}`,
977
- source: denyRule.source
978
- };
979
- }
980
- const allowRule = this.wildcardRules.findMatchingRule(target, "allow");
981
- if (allowRule) {
982
- return {
983
- allowed: true,
984
- matchedRule: allowRule,
985
- matchedPattern: allowRule.pattern,
986
- reason: `Allowed by rule: ${allowRule.pattern}`,
987
- source: allowRule.source
988
- };
989
- }
990
- return result;
991
- }
992
- /**
993
- * Match a pattern against a target string (legacy method)
994
- */
995
- matchPattern(pattern, target) {
996
- return this.wildcardRules.match(pattern, target);
997
- }
998
- /**
999
- * Add a permission rule
1000
- */
1001
- addPermission(permission) {
1002
- this.wildcardRules.addRule({
1003
- type: permission.type,
1004
- pattern: permission.pattern,
1005
- category: this.inferCategory(permission.pattern),
1006
- source: "user",
1007
- description: permission.description,
1008
- priority: permission.pattern === "*" ? 0 : void 0
1009
- });
1010
- this.savePermissions();
1011
- }
1012
- /**
1013
- * Add a wildcard permission rule (new API)
1014
- */
1015
- addRule(rule) {
1016
- this.wildcardRules.addRule(rule);
1017
- this.savePermissions();
1018
- }
1019
- /**
1020
- * Remove a permission rule by pattern
1021
- */
1022
- removePermission(pattern, type) {
1023
- const removed = this.wildcardRules.removeRule(pattern, type);
1024
- if (removed) {
1025
- this.savePermissions();
1026
- }
1027
- return removed;
1028
- }
1029
- /**
1030
- * List all permissions (legacy format)
1031
- */
1032
- listPermissions(type, _scope) {
1033
- const rules = this.wildcardRules.getAllRules();
1034
- let filtered = rules;
1035
- if (type) {
1036
- filtered = filtered.filter((r) => r.type === type);
1037
- }
1038
- return filtered.map((r) => ({
1039
- type: r.type,
1040
- pattern: r.pattern,
1041
- scope: "global",
1042
- description: r.description,
1043
- createdAt: r.createdAt ? new Date(r.createdAt).toISOString() : void 0
1044
- }));
1045
- }
1046
- /**
1047
- * Get all wildcard rules
1048
- */
1049
- getAllRules() {
1050
- return this.wildcardRules.getAllRules();
1051
- }
1052
- /**
1053
- * Get rules by type
1054
- */
1055
- getRulesByType(type) {
1056
- return this.wildcardRules.getRulesByType(type);
1057
- }
1058
- /**
1059
- * Get rules by category
1060
- */
1061
- getRulesByCategory(category) {
1062
- return this.wildcardRules.getRulesByCategory(category);
1063
- }
1064
- /**
1065
- * Clear all permissions
1066
- */
1067
- clearPermissions(type) {
1068
- if (type) {
1069
- const rulesToRemove = this.wildcardRules.getRulesByType(type);
1070
- for (const rule of rulesToRemove) {
1071
- this.wildcardRules.removeRule(rule.pattern, rule.type);
1072
- }
1073
- } else {
1074
- this.wildcardRules.clearRules();
1075
- }
1076
- this.savePermissions();
1077
- }
1078
- /**
1079
- * Get permission statistics
1080
- */
1081
- getStats() {
1082
- const stats = this.wildcardRules.getStats();
1083
- return {
1084
- total: stats.total,
1085
- allow: stats.allow,
1086
- deny: stats.deny
1087
- };
1088
- }
1089
- /**
1090
- * Export permissions to JSON (legacy format)
1091
- */
1092
- exportPermissions() {
1093
- return this.wildcardRules.exportToConfig();
1094
- }
1095
- /**
1096
- * Import permissions from JSON (legacy format)
1097
- */
1098
- importPermissions(config, merge = false) {
1099
- if (!merge) {
1100
- this.wildcardRules.clearRules();
1101
- }
1102
- this.wildcardRules.importFromConfig(config, "config");
1103
- this.savePermissions();
1104
- }
1105
- /**
1106
- * Test a pattern against sample targets
1107
- */
1108
- testPattern(pattern, targets) {
1109
- const defaultTargets = [
1110
- "npm install",
1111
- "npm test",
1112
- "git status",
1113
- "mcp__server__tool",
1114
- "Read",
1115
- "Write",
1116
- "Edit"
1117
- ];
1118
- return this.wildcardRules.testPattern(pattern, targets || defaultTargets);
1119
- }
1120
- /**
1121
- * Get diagnostics for a specific rule
1122
- */
1123
- getDiagnostics(pattern) {
1124
- return this.wildcardRules.getDiagnostics(pattern);
1125
- }
1126
- /**
1127
- * Get diagnostics for all rules
1128
- */
1129
- getAllDiagnostics() {
1130
- return this.wildcardRules.getAllDiagnostics();
1131
- }
1132
- /**
1133
- * Get unreachable rules (rules that can never match)
1134
- */
1135
- getUnreachableRules() {
1136
- return this.wildcardRules.getUnreachableRules();
1137
- }
1138
- /**
1139
- * Add a before-check hook
1140
- */
1141
- addBeforeHook(hook) {
1142
- this.wildcardRules.addBeforeHook(hook);
1143
- }
1144
- /**
1145
- * Add an after-check hook
1146
- */
1147
- addAfterHook(hook) {
1148
- this.wildcardRules.addAfterHook(hook);
1149
- }
1150
- /**
1151
- * Set allowUnsandboxedCommands flag
1152
- */
1153
- setAllowUnsandboxedCommands(allow) {
1154
- this.wildcardRules = getWildcardPermissionRules({
1155
- allowUnsandboxedCommands: allow
1156
- });
1157
- this.updateSettingsExperimental({
1158
- allowUnsandboxedCommands: allow
1159
- });
1160
- }
1161
- /**
1162
- * Set disallowed tools list
1163
- */
1164
- setDisallowedTools(tools) {
1165
- this.wildcardRules = getWildcardPermissionRules({
1166
- disallowedTools: tools
1167
- });
1168
- this.updateSettingsExperimental({
1169
- disallowedTools: tools
1170
- });
1171
- }
1172
- /**
1173
- * Get current configuration
1174
- */
1175
- getConfig() {
1176
- this.wildcardRules.getStats();
1177
- return {
1178
- disallowedTools: [],
1179
- maxCacheSize: 1e3,
1180
- enableDiagnostics: true
1181
- };
1182
- }
1183
- /**
1184
- * Search for rules by pattern
1185
- */
1186
- searchRules(query) {
1187
- const lowerQuery = query.toLowerCase();
1188
- return this.wildcardRules.getAllRules().filter(
1189
- (rule) => rule.pattern.toLowerCase().includes(lowerQuery) || rule.description?.toLowerCase().includes(lowerQuery) || rule.category.toLowerCase().includes(lowerQuery)
1190
- );
1191
- }
1192
- /**
1193
- * Validate a pattern string
1194
- */
1195
- validatePattern(pattern) {
1196
- return this.wildcardRules.validatePattern(pattern);
1197
- }
1198
- /**
1199
- * Get pattern type
1200
- */
1201
- getPatternType(pattern) {
1202
- return this.wildcardRules.getPatternType(pattern);
1203
- }
1204
- /**
1205
- * Get cache statistics
1206
- */
1207
- getCacheStats() {
1208
- return this.wildcardRules.getCacheStats();
1209
- }
1210
- /**
1211
- * Clear the pattern cache
1212
- */
1213
- clearCache() {
1214
- this.wildcardRules.clearCache();
1215
- }
1216
- /**
1217
- * Update experimental settings in settings.json
1218
- */
1219
- updateSettingsExperimental(updates) {
1220
- try {
1221
- let settings = {};
1222
- if (existsSync(this.settingsPath)) {
1223
- const content = readFileSync(this.settingsPath, "utf-8");
1224
- settings = JSON.parse(content);
1225
- }
1226
- if (!settings.experimental) {
1227
- settings.experimental = {};
1228
- }
1229
- Object.assign(settings.experimental, updates);
1230
- writeFileSync(this.settingsPath, JSON.stringify(settings, null, 2), "utf-8");
1231
- } catch (error) {
1232
- console.error("Failed to update settings.json:", error);
1233
- }
1234
- }
1235
- /**
1236
- * Infer category from pattern
1237
- */
1238
- inferCategory(pattern) {
1239
- if (pattern.startsWith("Bash(")) {
1240
- return "bash";
1241
- }
1242
- if (pattern.startsWith("mcp__") || pattern.startsWith("MCP(")) {
1243
- return "mcp";
1244
- }
1245
- if (/^(Read|Write|Edit|NotebookEdit)\(/.test(pattern)) {
1246
- return "filesystem";
1247
- }
1248
- if (/^(WebSearch|WebFetch)\(/.test(pattern)) {
1249
- return "network";
1250
- }
1251
- if (pattern.startsWith("http://") || pattern.startsWith("https://") || pattern.startsWith("ws://") || pattern.startsWith("wss://")) {
1252
- return "network";
1253
- }
1254
- if (pattern.startsWith("/")) {
1255
- return "filesystem";
1256
- }
1257
- if (["Read", "Write", "Edit", "Bash", "WebSearch", "WebFetch", "Task", "TodoWrite"].includes(pattern)) {
1258
- return "tool";
1259
- }
1260
- if (["init", "update", "doctor", "permissions"].includes(pattern)) {
1261
- return "command";
1262
- }
1263
- return "command";
1264
- }
1265
- /**
1266
- * Get sample patterns for reference
1267
- */
1268
- static getSamplePatterns() {
1269
- return SAMPLE_PATTERNS;
1270
- }
1271
- }
1272
- let instance = null;
1273
- function getPermissionManager(configPath, settingsPath) {
1274
- if (!instance) {
1275
- instance = new PermissionManager(configPath, settingsPath);
1276
- }
1277
- return instance;
1278
- }
1279
-
1280
- export { getPermissionManager as g };